@adhdev/daemon-standalone 0.6.3 → 0.6.5
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.
|
@@ -67,7 +67,7 @@ Error generating stack: `+s.message+`
|
|
|
67
67
|
*/function Bh(e){return e===void 0&&(e=""),new URLSearchParams(typeof e=="string"||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((t,r)=>{let n=e[r];return t.concat(Array.isArray(n)?n.map(i=>[r,i]):[[r,n]])},[]))}function Ck(e,t){let r=Bh(e);return t&&t.forEach((n,i)=>{r.has(i)||t.getAll(i).forEach(s=>{r.append(i,s)})}),r}const Ek="6";try{window.__reactRouterVersion=Ek}catch{}const Nk="startTransition",Pm=Sb[Nk];function Tk(e){let{basename:t,children:r,future:n,window:i}=e,s=x.useRef();s.current==null&&(s.current=jS({window:i,v5Compat:!0}));let o=s.current,[l,a]=x.useState({action:o.action,location:o.location}),{v7_startTransition:c}=n||{},d=x.useCallback(h=>{c&&Pm?Pm(()=>a(h)):a(h)},[a,c]);return x.useLayoutEffect(()=>o.listen(d),[o,d]),x.useEffect(()=>wk(n),[n]),x.createElement(Sk,{basename:t,children:r,location:l.location,navigationType:l.action,navigator:o,future:n})}var Rm;(function(e){e.UseScrollRestoration="useScrollRestoration",e.UseSubmit="useSubmit",e.UseSubmitFetcher="useSubmitFetcher",e.UseFetcher="useFetcher",e.useViewTransitionState="useViewTransitionState"})(Rm||(Rm={}));var Mm;(function(e){e.UseFetcher="useFetcher",e.UseFetchers="useFetchers",e.UseScrollRestoration="useScrollRestoration"})(Mm||(Mm={}));function Cy(e){let t=x.useRef(Bh(e)),r=x.useRef(!1),n=ol(),i=x.useMemo(()=>Ck(n.search,r.current?null:t.current),[n.search]),s=En(),o=x.useCallback((l,a)=>{const c=Bh(typeof l=="function"?l(i):l);r.current=!0,s("?"+c,a)},[s,i]);return[i,o]}const Ey=x.createContext({ides:[],updateIdeChats:()=>{},screenshotMap:{},setScreenshotMap:()=>{},initialLoaded:!1,toasts:[],setToasts:()=>{},wsStatus:"connected",isConnected:!0,connectionStates:{},connectionTransports:{},showReconnected:!1,userName:void 0,setUserName:()=>{},isP2PActive:!1,p2pStates:{},userRole:void 0}),Ny=x.createContext({injectEntries:()=>{},markLoaded:()=>{},getIdes:()=>[]});function Lm(e){var r,n;let t=0;return"activeChat"in e&&(t+=4),(r=e.agentStreams)!=null&&r.length&&(t+=2),e.workspace&&(t+=1),e.machine&&(t+=1),(n=e.agents)!=null&&n.length&&(t+=1),t}function Pk(e,t){var o,l,a,c,d,h,f;const r=Date.now();if(t.length===0)return e.map(p=>({...p,_lastUpdate:r}));const n=new Map;for(const p of t)n.set(p.id,p);for(const p of e){const m=n.get(p.id);if(!m){n.set(p.id,{...p,_lastUpdate:r});continue}const _=Lm(p),b=Lm(m);if(_>b){const g=(o=p.chats)!=null&&o.length?p.chats:m.chats;n.set(p.id,{...m,...p,chats:g,_lastUpdate:r})}else if(_<b){const g={};p.status&&p.status!==m.status&&(g.status=p.status),p.cdpConnected!==void 0&&(g.cdpConnected=p.cdpConnected),(l=p.chats)!=null&&l.length&&!((a=m.chats)!=null&&a.length)&&(g.chats=p.chats),Object.keys(g).length>0&&n.set(p.id,{...m,...g,_lastUpdate:m._lastUpdate})}else{const g=p.timestamp||r,v=m._lastUpdate||m.timestamp||0;if(g>=v){const y=(c=p.chats)!=null&&c.length?p.chats:m.chats;n.set(p.id,{...m,...p,chats:y,_lastUpdate:r})}else(d=p.chats)!=null&&d.length&&!((h=m.chats)!=null&&h.length)&&n.set(p.id,{...m,chats:p.chats})}}const i=new Set(e.map(p=>p.id)),s=new Set;for(const p of e){const m=p.daemonId||((f=p.id)==null?void 0:f.split(":")[0]);m&&s.add(m)}for(const[p,m]of n){const _=m.daemonId||p.split(":")[0];if(!s.has(_))continue;const b=r-(m._lastUpdate||m.timestamp||0);(p.includes(":cli:")&&!i.has(p)&&b>1e4||p.includes(":acp:")&&!i.has(p)&&b>1e4||p.includes(":ide:")&&!i.has(p)&&b>3e4)&&n.delete(p)}for(const[p,m]of n)r-(m._lastUpdate||m.timestamp||0)>3e5&&m.status!=="online"&&n.delete(p);return Array.from(n.values())}function Rk({children:e,connectionOverrides:t}){const[r,n]=x.useState([]),[i,s]=x.useState({}),[o,l]=x.useState(!1),[a,c]=x.useState([]),[d,h]=x.useState(void 0),f=x.useCallback((_,b)=>{n(g=>g.map(v=>v.id===_?{...v,chats:b}:v))},[]),p={injectEntries:_=>{n(b=>b.length===0?_:Pk(_,b))},markLoaded:()=>l(!0),getIdes:()=>r},m=t;return u.jsx(Ny.Provider,{value:p,children:u.jsx(Ey.Provider,{value:{ides:r,updateIdeChats:f,screenshotMap:i,setScreenshotMap:s,initialLoaded:o,toasts:a,setToasts:c,wsStatus:(m==null?void 0:m.wsStatus)??"connected",isConnected:(m==null?void 0:m.isConnected)??!0,connectionStates:(m==null?void 0:m.connectionStates)??{},connectionTransports:(m==null?void 0:m.connectionTransports)??{},showReconnected:(m==null?void 0:m.showReconnected)??!1,retryConnection:m==null?void 0:m.retryConnection,isP2PActive:(m==null?void 0:m.isP2PActive)??!1,p2pStates:(m==null?void 0:m.p2pStates)??{},userRole:m==null?void 0:m.userRole,userName:d,setUserName:h},children:e})})}function Ko(){return x.useContext(Ey)}function Im(){return x.useContext(Ny)}function Mk(e){const{baseUrl:t,getToken:r,onUnauthorized:n}=e;async function i(s,o={}){const l={"Content-Type":"application/json",...o.headers||{}},a=r==null?void 0:r();a&&(l.Authorization=`Bearer ${a}`);const c=s.startsWith("http")?s:`${t}${s.startsWith("/")?"":"/"}${s}`,d=await fetch(c,{...o,headers:l});if(d.status===401)throw n==null||n(),new Error("Unauthorized");if(!d.ok){const h=await d.json().catch(()=>({error:d.statusText}));throw new Error(h.error||`API Error: ${d.status}`)}return d.json()}return{getDaemons:()=>i("/api/v1/daemons"),getDaemonStatus:s=>i(`/api/v1/daemons/${s}/status`),sendCommand:(s,o,l={})=>i(`/api/v1/daemons/${s}/command`,{method:"POST",body:JSON.stringify({type:o,payload:l})}),execTerminal:(s,o,l)=>i(`/api/v1/daemons/${s}/terminal`,{method:"POST",body:JSON.stringify({command:o,name:l})}),sendAgentMessage:(s,o,l)=>i(`/api/v1/shortcuts/${s}/chat`,{method:"POST",body:JSON.stringify({agentType:o,message:l})}),getAgentStatus:s=>i(`/api/v1/shortcuts/${s}/status`),approveAgent:(s,o,l)=>i(`/api/v1/shortcuts/${s}/approve`,{method:"POST",body:JSON.stringify({agentType:o,action:l?"approve":"reject"})}),request:i}}const Lk=Mk({baseUrl:"http://localhost:3847"});x.createContext(Lk);const Ik={sendCommand:async()=>{throw new Error("TransportContext not initialized")}},Ty=x.createContext(Ik);function jk({value:e,children:t}){return u.jsx(Ty.Provider,{value:e,children:t})}function ui(){return x.useContext(Ty)}function Dk(e,t){const r={};return(e[e.length-1]===""?[...e,""]:e).join((r.padRight?" ":"")+","+(r.padLeft===!1?"":" ")).trim()}const Ak=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Bk=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Ok={};function jm(e,t){return(Ok.jsx?Bk:Ak).test(e)}const zk=/[ \t\n\f\r]/g;function $k(e){return typeof e=="object"?e.type==="text"?Dm(e.value):!1:Dm(e)}function Dm(e){return e.replace(zk,"")===""}class ll{constructor(t,r,n){this.normal=r,this.property=t,n&&(this.space=n)}}ll.prototype.normal={};ll.prototype.property={};ll.prototype.space=void 0;function Py(e,t){const r={},n={};for(const i of e)Object.assign(r,i.property),Object.assign(n,i.normal);return new ll(r,n,t)}function Oh(e){return e.toLowerCase()}class fr{constructor(t,r){this.attribute=r,this.property=t}}fr.prototype.attribute="";fr.prototype.booleanish=!1;fr.prototype.boolean=!1;fr.prototype.commaOrSpaceSeparated=!1;fr.prototype.commaSeparated=!1;fr.prototype.defined=!1;fr.prototype.mustUseProperty=!1;fr.prototype.number=!1;fr.prototype.overloadedBoolean=!1;fr.prototype.property="";fr.prototype.spaceSeparated=!1;fr.prototype.space=void 0;let Fk=0;const Ie=Ui(),mt=Ui(),zh=Ui(),ie=Ui(),Xe=Ui(),xs=Ui(),gr=Ui();function Ui(){return 2**++Fk}const $h=Object.freeze(Object.defineProperty({__proto__:null,boolean:Ie,booleanish:mt,commaOrSpaceSeparated:gr,commaSeparated:xs,number:ie,overloadedBoolean:zh,spaceSeparated:Xe},Symbol.toStringTag,{value:"Module"})),ou=Object.keys($h);class Of extends fr{constructor(t,r,n,i){let s=-1;if(super(t,r),Am(this,"space",i),typeof n=="number")for(;++s<ou.length;){const o=ou[s];Am(this,ou[s],(n&$h[o])===$h[o])}}}Of.prototype.defined=!0;function Am(e,t,r){r&&(e[t]=r)}function Is(e){const t={},r={};for(const[n,i]of Object.entries(e.properties)){const s=new Of(n,e.transform(e.attributes||{},n),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(n)&&(s.mustUseProperty=!0),t[n]=s,r[Oh(n)]=n,r[Oh(s.attribute)]=n}return new ll(t,r,e.space)}const Ry=Is({properties:{ariaActiveDescendant:null,ariaAtomic:mt,ariaAutoComplete:null,ariaBusy:mt,ariaChecked:mt,ariaColCount:ie,ariaColIndex:ie,ariaColSpan:ie,ariaControls:Xe,ariaCurrent:null,ariaDescribedBy:Xe,ariaDetails:null,ariaDisabled:mt,ariaDropEffect:Xe,ariaErrorMessage:null,ariaExpanded:mt,ariaFlowTo:Xe,ariaGrabbed:mt,ariaHasPopup:null,ariaHidden:mt,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Xe,ariaLevel:ie,ariaLive:null,ariaModal:mt,ariaMultiLine:mt,ariaMultiSelectable:mt,ariaOrientation:null,ariaOwns:Xe,ariaPlaceholder:null,ariaPosInSet:ie,ariaPressed:mt,ariaReadOnly:mt,ariaRelevant:null,ariaRequired:mt,ariaRoleDescription:Xe,ariaRowCount:ie,ariaRowIndex:ie,ariaRowSpan:ie,ariaSelected:mt,ariaSetSize:ie,ariaSort:null,ariaValueMax:ie,ariaValueMin:ie,ariaValueNow:ie,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function My(e,t){return t in e?e[t]:t}function Ly(e,t){return My(e,t.toLowerCase())}const Wk=Is({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:xs,acceptCharset:Xe,accessKey:Xe,action:null,allow:null,allowFullScreen:Ie,allowPaymentRequest:Ie,allowUserMedia:Ie,alt:null,as:null,async:Ie,autoCapitalize:null,autoComplete:Xe,autoFocus:Ie,autoPlay:Ie,blocking:Xe,capture:null,charSet:null,checked:Ie,cite:null,className:Xe,cols:ie,colSpan:null,content:null,contentEditable:mt,controls:Ie,controlsList:Xe,coords:ie|xs,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Ie,defer:Ie,dir:null,dirName:null,disabled:Ie,download:zh,draggable:mt,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Ie,formTarget:null,headers:Xe,height:ie,hidden:zh,high:ie,href:null,hrefLang:null,htmlFor:Xe,httpEquiv:Xe,id:null,imageSizes:null,imageSrcSet:null,inert:Ie,inputMode:null,integrity:null,is:null,isMap:Ie,itemId:null,itemProp:Xe,itemRef:Xe,itemScope:Ie,itemType:Xe,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Ie,low:ie,manifest:null,max:null,maxLength:ie,media:null,method:null,min:null,minLength:ie,multiple:Ie,muted:Ie,name:null,nonce:null,noModule:Ie,noValidate:Ie,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:Ie,optimum:ie,pattern:null,ping:Xe,placeholder:null,playsInline:Ie,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Ie,referrerPolicy:null,rel:Xe,required:Ie,reversed:Ie,rows:ie,rowSpan:ie,sandbox:Xe,scope:null,scoped:Ie,seamless:Ie,selected:Ie,shadowRootClonable:Ie,shadowRootDelegatesFocus:Ie,shadowRootMode:null,shape:null,size:ie,sizes:null,slot:null,span:ie,spellCheck:mt,src:null,srcDoc:null,srcLang:null,srcSet:null,start:ie,step:null,style:null,tabIndex:ie,target:null,title:null,translate:null,type:null,typeMustMatch:Ie,useMap:null,value:mt,width:ie,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Xe,axis:null,background:null,bgColor:null,border:ie,borderColor:null,bottomMargin:ie,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Ie,declare:Ie,event:null,face:null,frame:null,frameBorder:null,hSpace:ie,leftMargin:ie,link:null,longDesc:null,lowSrc:null,marginHeight:ie,marginWidth:ie,noResize:Ie,noHref:Ie,noShade:Ie,noWrap:Ie,object:null,profile:null,prompt:null,rev:null,rightMargin:ie,rules:null,scheme:null,scrolling:mt,standby:null,summary:null,text:null,topMargin:ie,valueType:null,version:null,vAlign:null,vLink:null,vSpace:ie,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:Ie,disableRemotePlayback:Ie,prefix:null,property:null,results:ie,security:null,unselectable:null},space:"html",transform:Ly}),Hk=Is({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:gr,accentHeight:ie,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:ie,amplitude:ie,arabicForm:null,ascent:ie,attributeName:null,attributeType:null,azimuth:ie,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:ie,by:null,calcMode:null,capHeight:ie,className:Xe,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:ie,diffuseConstant:ie,direction:null,display:null,dur:null,divisor:ie,dominantBaseline:null,download:Ie,dx:null,dy:null,edgeMode:null,editable:null,elevation:ie,enableBackground:null,end:null,event:null,exponent:ie,externalResourcesRequired:null,fill:null,fillOpacity:ie,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:xs,g2:xs,glyphName:xs,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:ie,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:ie,horizOriginX:ie,horizOriginY:ie,id:null,ideographic:ie,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:ie,k:ie,k1:ie,k2:ie,k3:ie,k4:ie,kernelMatrix:gr,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:ie,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:ie,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:ie,overlineThickness:ie,paintOrder:null,panose1:null,path:null,pathLength:ie,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Xe,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:ie,pointsAtY:ie,pointsAtZ:ie,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:gr,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:gr,rev:gr,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:gr,requiredFeatures:gr,requiredFonts:gr,requiredFormats:gr,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:ie,specularExponent:ie,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:ie,strikethroughThickness:ie,string:null,stroke:null,strokeDashArray:gr,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:ie,strokeOpacity:ie,strokeWidth:null,style:null,surfaceScale:ie,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:gr,tabIndex:ie,tableValues:null,target:null,targetX:ie,targetY:ie,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:gr,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:ie,underlineThickness:ie,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:ie,values:null,vAlphabetic:ie,vMathematical:ie,vectorEffect:null,vHanging:ie,vIdeographic:ie,version:null,vertAdvY:ie,vertOriginX:ie,vertOriginY:ie,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:ie,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:My}),Iy=Is({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),jy=Is({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:Ly}),Dy=Is({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),Uk={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},Kk=/[A-Z]/g,Bm=/-[a-z]/g,Vk=/^data[-\w.:]+$/i;function qk(e,t){const r=Oh(t);let n=t,i=fr;if(r in e.normal)return e.property[e.normal[r]];if(r.length>4&&r.slice(0,4)==="data"&&Vk.test(t)){if(t.charAt(4)==="-"){const s=t.slice(5).replace(Bm,Xk);n="data"+s.charAt(0).toUpperCase()+s.slice(1)}else{const s=t.slice(4);if(!Bm.test(s)){let o=s.replace(Kk,Yk);o.charAt(0)!=="-"&&(o="-"+o),t="data"+o}}i=Of}return new i(n,t)}function Yk(e){return"-"+e.toLowerCase()}function Xk(e){return e.charAt(1).toUpperCase()}const Gk=Py([Ry,Wk,Iy,jy,Dy],"html"),zf=Py([Ry,Hk,Iy,jy,Dy],"svg");function Qk(e){return e.join(" ").trim()}var $f={},Om=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,Jk=/\n/g,Zk=/^\s*/,eC=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,tC=/^:\s*/,rC=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,nC=/^[;\s]*/,iC=/^\s+|\s+$/g,sC=`
|
|
68
68
|
`,zm="/",$m="*",ki="",oC="comment",lC="declaration";function aC(e,t){if(typeof e!="string")throw new TypeError("First argument must be a string");if(!e)return[];t=t||{};var r=1,n=1;function i(m){var _=m.match(Jk);_&&(r+=_.length);var b=m.lastIndexOf(sC);n=~b?m.length-b:n+m.length}function s(){var m={line:r,column:n};return function(_){return _.position=new o(m),c(),_}}function o(m){this.start=m,this.end={line:r,column:n},this.source=t.source}o.prototype.content=e;function l(m){var _=new Error(t.source+":"+r+":"+n+": "+m);if(_.reason=m,_.filename=t.source,_.line=r,_.column=n,_.source=e,!t.silent)throw _}function a(m){var _=m.exec(e);if(_){var b=_[0];return i(b),e=e.slice(b.length),_}}function c(){a(Zk)}function d(m){var _;for(m=m||[];_=h();)_!==!1&&m.push(_);return m}function h(){var m=s();if(!(zm!=e.charAt(0)||$m!=e.charAt(1))){for(var _=2;ki!=e.charAt(_)&&($m!=e.charAt(_)||zm!=e.charAt(_+1));)++_;if(_+=2,ki===e.charAt(_-1))return l("End of comment missing");var b=e.slice(2,_-2);return n+=2,i(b),e=e.slice(_),n+=2,m({type:oC,comment:b})}}function f(){var m=s(),_=a(eC);if(_){if(h(),!a(tC))return l("property missing ':'");var b=a(rC),g=m({type:lC,property:Fm(_[0].replace(Om,ki)),value:b?Fm(b[0].replace(Om,ki)):ki});return a(nC),g}}function p(){var m=[];d(m);for(var _;_=f();)_!==!1&&(m.push(_),d(m));return m}return c(),p()}function Fm(e){return e?e.replace(iC,ki):ki}var cC=aC,uC=xa&&xa.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty($f,"__esModule",{value:!0});$f.default=dC;const hC=uC(cC);function dC(e,t){let r=null;if(!e||typeof e!="string")return r;const n=(0,hC.default)(e),i=typeof t=="function";return n.forEach(s=>{if(s.type!=="declaration")return;const{property:o,value:l}=s;i?t(o,l,s):l&&(r=r||{},r[o]=l)}),r}var bc={};Object.defineProperty(bc,"__esModule",{value:!0});bc.camelCase=void 0;var fC=/^--[a-zA-Z0-9_-]+$/,pC=/-([a-z])/g,mC=/^[^-]+$/,gC=/^-(webkit|moz|ms|o|khtml)-/,_C=/^-(ms)-/,vC=function(e){return!e||mC.test(e)||fC.test(e)},xC=function(e,t){return t.toUpperCase()},Wm=function(e,t){return"".concat(t,"-")},yC=function(e,t){return t===void 0&&(t={}),vC(e)?e:(e=e.toLowerCase(),t.reactCompat?e=e.replace(_C,Wm):e=e.replace(gC,Wm),e.replace(pC,xC))};bc.camelCase=yC;var bC=xa&&xa.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},wC=bC($f),SC=bc;function Fh(e,t){var r={};return!e||typeof e!="string"||(0,wC.default)(e,function(n,i){n&&i&&(r[(0,SC.camelCase)(n,t)]=i)}),r}Fh.default=Fh;var kC=Fh;const CC=$d(kC),Ay=By("end"),Ff=By("start");function By(e){return t;function t(r){const n=r&&r.position&&r.position[e]||{};if(typeof n.line=="number"&&n.line>0&&typeof n.column=="number"&&n.column>0)return{line:n.line,column:n.column,offset:typeof n.offset=="number"&&n.offset>-1?n.offset:void 0}}}function EC(e){const t=Ff(e),r=Ay(e);if(t&&r)return{start:t,end:r}}function yo(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?Hm(e.position):"start"in e||"end"in e?Hm(e):"line"in e||"column"in e?Wh(e):""}function Wh(e){return Um(e&&e.line)+":"+Um(e&&e.column)}function Hm(e){return Wh(e&&e.start)+"-"+Wh(e&&e.end)}function Um(e){return e&&typeof e=="number"?e:1}class qt extends Error{constructor(t,r,n){super(),typeof r=="string"&&(n=r,r=void 0);let i="",s={},o=!1;if(r&&("line"in r&&"column"in r?s={place:r}:"start"in r&&"end"in r?s={place:r}:"type"in r?s={ancestors:[r],place:r.position}:s={...r}),typeof t=="string"?i=t:!s.cause&&t&&(o=!0,i=t.message,s.cause=t),!s.ruleId&&!s.source&&typeof n=="string"){const a=n.indexOf(":");a===-1?s.ruleId=n:(s.source=n.slice(0,a),s.ruleId=n.slice(a+1))}if(!s.place&&s.ancestors&&s.ancestors){const a=s.ancestors[s.ancestors.length-1];a&&(s.place=a.position)}const l=s.place&&"start"in s.place?s.place.start:s.place;this.ancestors=s.ancestors||void 0,this.cause=s.cause||void 0,this.column=l?l.column:void 0,this.fatal=void 0,this.file="",this.message=i,this.line=l?l.line:void 0,this.name=yo(s.place)||"1:1",this.place=s.place||void 0,this.reason=this.message,this.ruleId=s.ruleId||void 0,this.source=s.source||void 0,this.stack=o&&s.cause&&typeof s.cause.stack=="string"?s.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}qt.prototype.file="";qt.prototype.name="";qt.prototype.reason="";qt.prototype.message="";qt.prototype.stack="";qt.prototype.column=void 0;qt.prototype.line=void 0;qt.prototype.ancestors=void 0;qt.prototype.cause=void 0;qt.prototype.fatal=void 0;qt.prototype.place=void 0;qt.prototype.ruleId=void 0;qt.prototype.source=void 0;const Wf={}.hasOwnProperty,NC=new Map,TC=/[A-Z]/g,PC=new Set(["table","tbody","thead","tfoot","tr"]),RC=new Set(["td","th"]),Oy="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function MC(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const r=t.filePath||void 0;let n;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");n=zC(r,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");n=OC(r,t.jsx,t.jsxs)}const i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:n,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:r,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?zf:Gk,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},s=zy(i,e,void 0);return s&&typeof s!="string"?s:i.create(e,i.Fragment,{children:s||void 0},void 0)}function zy(e,t,r){if(t.type==="element")return LC(e,t,r);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return IC(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return DC(e,t,r);if(t.type==="mdxjsEsm")return jC(e,t);if(t.type==="root")return AC(e,t,r);if(t.type==="text")return BC(e,t)}function LC(e,t,r){const n=e.schema;let i=n;t.tagName.toLowerCase()==="svg"&&n.space==="html"&&(i=zf,e.schema=i),e.ancestors.push(t);const s=Fy(e,t.tagName,!1),o=$C(e,t);let l=Uf(e,t);return PC.has(t.tagName)&&(l=l.filter(function(a){return typeof a=="string"?!$k(a):!0})),$y(e,o,s,t),Hf(o,l),e.ancestors.pop(),e.schema=n,e.create(t,s,o,r)}function IC(e,t){if(t.data&&t.data.estree&&e.evaluater){const n=t.data.estree.body[0];return n.type,e.evaluater.evaluateExpression(n.expression)}Vo(e,t.position)}function jC(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Vo(e,t.position)}function DC(e,t,r){const n=e.schema;let i=n;t.name==="svg"&&n.space==="html"&&(i=zf,e.schema=i),e.ancestors.push(t);const s=t.name===null?e.Fragment:Fy(e,t.name,!0),o=FC(e,t),l=Uf(e,t);return $y(e,o,s,t),Hf(o,l),e.ancestors.pop(),e.schema=n,e.create(t,s,o,r)}function AC(e,t,r){const n={};return Hf(n,Uf(e,t)),e.create(t,e.Fragment,n,r)}function BC(e,t){return t.value}function $y(e,t,r,n){typeof r!="string"&&r!==e.Fragment&&e.passNode&&(t.node=n)}function Hf(e,t){if(t.length>0){const r=t.length>1?t:t[0];r&&(e.children=r)}}function OC(e,t,r){return n;function n(i,s,o,l){const c=Array.isArray(o.children)?r:t;return l?c(s,o,l):c(s,o)}}function zC(e,t){return r;function r(n,i,s,o){const l=Array.isArray(s.children),a=Ff(n);return t(i,s,o,l,{columnNumber:a?a.column-1:void 0,fileName:e,lineNumber:a?a.line:void 0},void 0)}}function $C(e,t){const r={};let n,i;for(i in t.properties)if(i!=="children"&&Wf.call(t.properties,i)){const s=WC(e,i,t.properties[i]);if(s){const[o,l]=s;e.tableCellAlignToStyle&&o==="align"&&typeof l=="string"&&RC.has(t.tagName)?n=l:r[o]=l}}if(n){const s=r.style||(r.style={});s[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=n}return r}function FC(e,t){const r={};for(const n of t.attributes)if(n.type==="mdxJsxExpressionAttribute")if(n.data&&n.data.estree&&e.evaluater){const s=n.data.estree.body[0];s.type;const o=s.expression;o.type;const l=o.properties[0];l.type,Object.assign(r,e.evaluater.evaluateExpression(l.argument))}else Vo(e,t.position);else{const i=n.name;let s;if(n.value&&typeof n.value=="object")if(n.value.data&&n.value.data.estree&&e.evaluater){const l=n.value.data.estree.body[0];l.type,s=e.evaluater.evaluateExpression(l.expression)}else Vo(e,t.position);else s=n.value===null?!0:n.value;r[i]=s}return r}function Uf(e,t){const r=[];let n=-1;const i=e.passKeys?new Map:NC;for(;++n<t.children.length;){const s=t.children[n];let o;if(e.passKeys){const a=s.type==="element"?s.tagName:s.type==="mdxJsxFlowElement"||s.type==="mdxJsxTextElement"?s.name:void 0;if(a){const c=i.get(a)||0;o=a+"-"+c,i.set(a,c+1)}}const l=zy(e,s,o);l!==void 0&&r.push(l)}return r}function WC(e,t,r){const n=qk(e.schema,t);if(!(r==null||typeof r=="number"&&Number.isNaN(r))){if(Array.isArray(r)&&(r=n.commaSeparated?Dk(r):Qk(r)),n.property==="style"){let i=typeof r=="object"?r:HC(e,String(r));return e.stylePropertyNameCase==="css"&&(i=UC(i)),["style",i]}return[e.elementAttributeNameCase==="react"&&n.space?Uk[n.property]||n.property:n.attribute,r]}}function HC(e,t){try{return CC(t,{reactCompat:!0})}catch(r){if(e.ignoreInvalidStyle)return{};const n=r,i=new qt("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:n,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw i.file=e.filePath||void 0,i.url=Oy+"#cannot-parse-style-attribute",i}}function Fy(e,t,r){let n;if(!r)n={type:"Literal",value:t};else if(t.includes(".")){const i=t.split(".");let s=-1,o;for(;++s<i.length;){const l=jm(i[s])?{type:"Identifier",name:i[s]}:{type:"Literal",value:i[s]};o=o?{type:"MemberExpression",object:o,property:l,computed:!!(s&&l.type==="Literal"),optional:!1}:l}n=o}else n=jm(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(n.type==="Literal"){const i=n.value;return Wf.call(e.components,i)?e.components[i]:i}if(e.evaluater)return e.evaluater.evaluateExpression(n);Vo(e)}function Vo(e,t){const r=new qt("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw r.file=e.filePath||void 0,r.url=Oy+"#cannot-handle-mdx-estrees-without-createevaluater",r}function UC(e){const t={};let r;for(r in e)Wf.call(e,r)&&(t[KC(r)]=e[r]);return t}function KC(e){let t=e.replace(TC,VC);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function VC(e){return"-"+e.toLowerCase()}const lu={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},qC={};function Kf(e,t){const r=qC,n=typeof r.includeImageAlt=="boolean"?r.includeImageAlt:!0,i=typeof r.includeHtml=="boolean"?r.includeHtml:!0;return Wy(e,n,i)}function Wy(e,t,r){if(YC(e)){if("value"in e)return e.type==="html"&&!r?"":e.value;if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return Km(e.children,t,r)}return Array.isArray(e)?Km(e,t,r):""}function Km(e,t,r){const n=[];let i=-1;for(;++i<e.length;)n[i]=Wy(e[i],t,r);return n.join("")}function YC(e){return!!(e&&typeof e=="object")}const Vm=document.createElement("i");function Vf(e){const t="&"+e+";";Vm.innerHTML=t;const r=Vm.textContent;return r.charCodeAt(r.length-1)===59&&e!=="semi"||r===t?!1:r}function br(e,t,r,n){const i=e.length;let s=0,o;if(t<0?t=-t>i?0:i+t:t=t>i?i:t,r=r>0?r:0,n.length<1e4)o=Array.from(n),o.unshift(t,r),e.splice(...o);else for(r&&e.splice(t,r);s<n.length;)o=n.slice(s,s+1e4),o.unshift(t,0),e.splice(...o),s+=1e4,t+=1e4}function Lr(e,t){return e.length>0?(br(e,e.length,0,t),e):t}const qm={}.hasOwnProperty;function Hy(e){const t={};let r=-1;for(;++r<e.length;)XC(t,e[r]);return t}function XC(e,t){let r;for(r in t){const i=(qm.call(e,r)?e[r]:void 0)||(e[r]={}),s=t[r];let o;if(s)for(o in s){qm.call(i,o)||(i[o]=[]);const l=s[o];GC(i[o],Array.isArray(l)?l:l?[l]:[])}}}function GC(e,t){let r=-1;const n=[];for(;++r<t.length;)(t[r].add==="after"?e:n).push(t[r]);br(e,0,0,n)}function Uy(e,t){const r=Number.parseInt(e,t);return r<9||r===11||r>13&&r<32||r>126&&r<160||r>55295&&r<57344||r>64975&&r<65008||(r&65535)===65535||(r&65535)===65534||r>1114111?"�":String.fromCodePoint(r)}function qr(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Qt=hi(/[A-Za-z]/),Kt=hi(/[\dA-Za-z]/),QC=hi(/[#-'*+\--9=?A-Z^-~]/);function Ua(e){return e!==null&&(e<32||e===127)}const Hh=hi(/\d/),JC=hi(/[\dA-Fa-f]/),ZC=hi(/[!-/:-@[-`{-~]/);function be(e){return e!==null&&e<-2}function Ye(e){return e!==null&&(e<0||e===32)}function ze(e){return e===-2||e===-1||e===32}const wc=hi(new RegExp("\\p{P}|\\p{S}","u")),zi=hi(/\s/);function hi(e){return t;function t(r){return r!==null&&r>-1&&e.test(String.fromCharCode(r))}}function js(e){const t=[];let r=-1,n=0,i=0;for(;++r<e.length;){const s=e.charCodeAt(r);let o="";if(s===37&&Kt(e.charCodeAt(r+1))&&Kt(e.charCodeAt(r+2)))i=2;else if(s<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(s))||(o=String.fromCharCode(s));else if(s>55295&&s<57344){const l=e.charCodeAt(r+1);s<56320&&l>56319&&l<57344?(o=String.fromCharCode(s,l),i=1):o="�"}else o=String.fromCharCode(s);o&&(t.push(e.slice(n,r),encodeURIComponent(o)),n=r+i+1,o=""),i&&(r+=i,i=0)}return t.join("")+e.slice(n)}function Fe(e,t,r,n){const i=n?n-1:Number.POSITIVE_INFINITY;let s=0;return o;function o(a){return ze(a)?(e.enter(r),l(a)):t(a)}function l(a){return ze(a)&&s++<i?(e.consume(a),l):(e.exit(r),t(a))}}const e2={tokenize:t2};function t2(e){const t=e.attempt(this.parser.constructs.contentInitial,n,i);let r;return t;function n(l){if(l===null){e.consume(l);return}return e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),Fe(e,t,"linePrefix")}function i(l){return e.enter("paragraph"),s(l)}function s(l){const a=e.enter("chunkText",{contentType:"text",previous:r});return r&&(r.next=a),r=a,o(l)}function o(l){if(l===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(l);return}return be(l)?(e.consume(l),e.exit("chunkText"),s):(e.consume(l),o)}}const r2={tokenize:n2},Ym={tokenize:i2};function n2(e){const t=this,r=[];let n=0,i,s,o;return l;function l(y){if(n<r.length){const S=r[n];return t.containerState=S[1],e.attempt(S[0].continuation,a,c)(y)}return c(y)}function a(y){if(n++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&v();const S=t.events.length;let R=S,E;for(;R--;)if(t.events[R][0]==="exit"&&t.events[R][1].type==="chunkFlow"){E=t.events[R][1].end;break}g(n);let P=S;for(;P<t.events.length;)t.events[P][1].end={...E},P++;return br(t.events,R+1,0,t.events.slice(S)),t.events.length=P,c(y)}return l(y)}function c(y){if(n===r.length){if(!i)return f(y);if(i.currentConstruct&&i.currentConstruct.concrete)return m(y);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(Ym,d,h)(y)}function d(y){return i&&v(),g(n),f(y)}function h(y){return t.parser.lazy[t.now().line]=n!==r.length,o=t.now().offset,m(y)}function f(y){return t.containerState={},e.attempt(Ym,p,m)(y)}function p(y){return n++,r.push([t.currentConstruct,t.containerState]),f(y)}function m(y){if(y===null){i&&v(),g(0),e.consume(y);return}return i=i||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:s}),_(y)}function _(y){if(y===null){b(e.exit("chunkFlow"),!0),g(0),e.consume(y);return}return be(y)?(e.consume(y),b(e.exit("chunkFlow")),n=0,t.interrupt=void 0,l):(e.consume(y),_)}function b(y,S){const R=t.sliceStream(y);if(S&&R.push(null),y.previous=s,s&&(s.next=y),s=y,i.defineSkip(y.start),i.write(R),t.parser.lazy[y.start.line]){let E=i.events.length;for(;E--;)if(i.events[E][1].start.offset<o&&(!i.events[E][1].end||i.events[E][1].end.offset>o))return;const P=t.events.length;let N=P,D,k;for(;N--;)if(t.events[N][0]==="exit"&&t.events[N][1].type==="chunkFlow"){if(D){k=t.events[N][1].end;break}D=!0}for(g(n),E=P;E<t.events.length;)t.events[E][1].end={...k},E++;br(t.events,N+1,0,t.events.slice(P)),t.events.length=E}}function g(y){let S=r.length;for(;S-- >y;){const R=r[S];t.containerState=R[1],R[0].exit.call(t,e)}r.length=y}function v(){i.write([null]),s=void 0,i=void 0,t.containerState._closeFlow=void 0}}function i2(e,t,r){return Fe(e,e.attempt(this.parser.constructs.document,t,r),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Ns(e){if(e===null||Ye(e)||zi(e))return 1;if(wc(e))return 2}function Sc(e,t,r){const n=[];let i=-1;for(;++i<e.length;){const s=e[i].resolveAll;s&&!n.includes(s)&&(t=s(t,r),n.push(s))}return t}const Uh={name:"attention",resolveAll:s2,tokenize:o2};function s2(e,t){let r=-1,n,i,s,o,l,a,c,d;for(;++r<e.length;)if(e[r][0]==="enter"&&e[r][1].type==="attentionSequence"&&e[r][1]._close){for(n=r;n--;)if(e[n][0]==="exit"&&e[n][1].type==="attentionSequence"&&e[n][1]._open&&t.sliceSerialize(e[n][1]).charCodeAt(0)===t.sliceSerialize(e[r][1]).charCodeAt(0)){if((e[n][1]._close||e[r][1]._open)&&(e[r][1].end.offset-e[r][1].start.offset)%3&&!((e[n][1].end.offset-e[n][1].start.offset+e[r][1].end.offset-e[r][1].start.offset)%3))continue;a=e[n][1].end.offset-e[n][1].start.offset>1&&e[r][1].end.offset-e[r][1].start.offset>1?2:1;const h={...e[n][1].end},f={...e[r][1].start};Xm(h,-a),Xm(f,a),o={type:a>1?"strongSequence":"emphasisSequence",start:h,end:{...e[n][1].end}},l={type:a>1?"strongSequence":"emphasisSequence",start:{...e[r][1].start},end:f},s={type:a>1?"strongText":"emphasisText",start:{...e[n][1].end},end:{...e[r][1].start}},i={type:a>1?"strong":"emphasis",start:{...o.start},end:{...l.end}},e[n][1].end={...o.start},e[r][1].start={...l.end},c=[],e[n][1].end.offset-e[n][1].start.offset&&(c=Lr(c,[["enter",e[n][1],t],["exit",e[n][1],t]])),c=Lr(c,[["enter",i,t],["enter",o,t],["exit",o,t],["enter",s,t]]),c=Lr(c,Sc(t.parser.constructs.insideSpan.null,e.slice(n+1,r),t)),c=Lr(c,[["exit",s,t],["enter",l,t],["exit",l,t],["exit",i,t]]),e[r][1].end.offset-e[r][1].start.offset?(d=2,c=Lr(c,[["enter",e[r][1],t],["exit",e[r][1],t]])):d=0,br(e,n-1,r-n+3,c),r=n+c.length-d-2;break}}for(r=-1;++r<e.length;)e[r][1].type==="attentionSequence"&&(e[r][1].type="data");return e}function o2(e,t){const r=this.parser.constructs.attentionMarkers.null,n=this.previous,i=Ns(n);let s;return o;function o(a){return s=a,e.enter("attentionSequence"),l(a)}function l(a){if(a===s)return e.consume(a),l;const c=e.exit("attentionSequence"),d=Ns(a),h=!d||d===2&&i||r.includes(a),f=!i||i===2&&d||r.includes(n);return c._open=!!(s===42?h:h&&(i||!f)),c._close=!!(s===42?f:f&&(d||!h)),t(a)}}function Xm(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const l2={name:"autolink",tokenize:a2};function a2(e,t,r){let n=0;return i;function i(p){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),s}function s(p){return Qt(p)?(e.consume(p),o):p===64?r(p):c(p)}function o(p){return p===43||p===45||p===46||Kt(p)?(n=1,l(p)):c(p)}function l(p){return p===58?(e.consume(p),n=0,a):(p===43||p===45||p===46||Kt(p))&&n++<32?(e.consume(p),l):(n=0,c(p))}function a(p){return p===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.exit("autolink"),t):p===null||p===32||p===60||Ua(p)?r(p):(e.consume(p),a)}function c(p){return p===64?(e.consume(p),d):QC(p)?(e.consume(p),c):r(p)}function d(p){return Kt(p)?h(p):r(p)}function h(p){return p===46?(e.consume(p),n=0,d):p===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.exit("autolink"),t):f(p)}function f(p){if((p===45||Kt(p))&&n++<63){const m=p===45?f:h;return e.consume(p),m}return r(p)}}const al={partial:!0,tokenize:c2};function c2(e,t,r){return n;function n(s){return ze(s)?Fe(e,i,"linePrefix")(s):i(s)}function i(s){return s===null||be(s)?t(s):r(s)}}const Ky={continuation:{tokenize:h2},exit:d2,name:"blockQuote",tokenize:u2};function u2(e,t,r){const n=this;return i;function i(o){if(o===62){const l=n.containerState;return l.open||(e.enter("blockQuote",{_container:!0}),l.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(o),e.exit("blockQuoteMarker"),s}return r(o)}function s(o){return ze(o)?(e.enter("blockQuotePrefixWhitespace"),e.consume(o),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(o))}}function h2(e,t,r){const n=this;return i;function i(o){return ze(o)?Fe(e,s,"linePrefix",n.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o):s(o)}function s(o){return e.attempt(Ky,t,r)(o)}}function d2(e){e.exit("blockQuote")}const Vy={name:"characterEscape",tokenize:f2};function f2(e,t,r){return n;function n(s){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(s),e.exit("escapeMarker"),i}function i(s){return ZC(s)?(e.enter("characterEscapeValue"),e.consume(s),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):r(s)}}const qy={name:"characterReference",tokenize:p2};function p2(e,t,r){const n=this;let i=0,s,o;return l;function l(h){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(h),e.exit("characterReferenceMarker"),a}function a(h){return h===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(h),e.exit("characterReferenceMarkerNumeric"),c):(e.enter("characterReferenceValue"),s=31,o=Kt,d(h))}function c(h){return h===88||h===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(h),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),s=6,o=JC,d):(e.enter("characterReferenceValue"),s=7,o=Hh,d(h))}function d(h){if(h===59&&i){const f=e.exit("characterReferenceValue");return o===Kt&&!Vf(n.sliceSerialize(f))?r(h):(e.enter("characterReferenceMarker"),e.consume(h),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return o(h)&&i++<s?(e.consume(h),d):r(h)}}const Gm={partial:!0,tokenize:g2},Qm={concrete:!0,name:"codeFenced",tokenize:m2};function m2(e,t,r){const n=this,i={partial:!0,tokenize:R};let s=0,o=0,l;return a;function a(E){return c(E)}function c(E){const P=n.events[n.events.length-1];return s=P&&P[1].type==="linePrefix"?P[2].sliceSerialize(P[1],!0).length:0,l=E,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),d(E)}function d(E){return E===l?(o++,e.consume(E),d):o<3?r(E):(e.exit("codeFencedFenceSequence"),ze(E)?Fe(e,h,"whitespace")(E):h(E))}function h(E){return E===null||be(E)?(e.exit("codeFencedFence"),n.interrupt?t(E):e.check(Gm,_,S)(E)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),f(E))}function f(E){return E===null||be(E)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),h(E)):ze(E)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),Fe(e,p,"whitespace")(E)):E===96&&E===l?r(E):(e.consume(E),f)}function p(E){return E===null||be(E)?h(E):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),m(E))}function m(E){return E===null||be(E)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),h(E)):E===96&&E===l?r(E):(e.consume(E),m)}function _(E){return e.attempt(i,S,b)(E)}function b(E){return e.enter("lineEnding"),e.consume(E),e.exit("lineEnding"),g}function g(E){return s>0&&ze(E)?Fe(e,v,"linePrefix",s+1)(E):v(E)}function v(E){return E===null||be(E)?e.check(Gm,_,S)(E):(e.enter("codeFlowValue"),y(E))}function y(E){return E===null||be(E)?(e.exit("codeFlowValue"),v(E)):(e.consume(E),y)}function S(E){return e.exit("codeFenced"),t(E)}function R(E,P,N){let D=0;return k;function k(A){return E.enter("lineEnding"),E.consume(A),E.exit("lineEnding"),B}function B(A){return E.enter("codeFencedFence"),ze(A)?Fe(E,j,"linePrefix",n.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(A):j(A)}function j(A){return A===l?(E.enter("codeFencedFenceSequence"),M(A)):N(A)}function M(A){return A===l?(D++,E.consume(A),M):D>=o?(E.exit("codeFencedFenceSequence"),ze(A)?Fe(E,C,"whitespace")(A):C(A)):N(A)}function C(A){return A===null||be(A)?(E.exit("codeFencedFence"),P(A)):N(A)}}}function g2(e,t,r){const n=this;return i;function i(o){return o===null?r(o):(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),s)}function s(o){return n.parser.lazy[n.now().line]?r(o):t(o)}}const au={name:"codeIndented",tokenize:v2},_2={partial:!0,tokenize:x2};function v2(e,t,r){const n=this;return i;function i(c){return e.enter("codeIndented"),Fe(e,s,"linePrefix",5)(c)}function s(c){const d=n.events[n.events.length-1];return d&&d[1].type==="linePrefix"&&d[2].sliceSerialize(d[1],!0).length>=4?o(c):r(c)}function o(c){return c===null?a(c):be(c)?e.attempt(_2,o,a)(c):(e.enter("codeFlowValue"),l(c))}function l(c){return c===null||be(c)?(e.exit("codeFlowValue"),o(c)):(e.consume(c),l)}function a(c){return e.exit("codeIndented"),t(c)}}function x2(e,t,r){const n=this;return i;function i(o){return n.parser.lazy[n.now().line]?r(o):be(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),i):Fe(e,s,"linePrefix",5)(o)}function s(o){const l=n.events[n.events.length-1];return l&&l[1].type==="linePrefix"&&l[2].sliceSerialize(l[1],!0).length>=4?t(o):be(o)?i(o):r(o)}}const y2={name:"codeText",previous:w2,resolve:b2,tokenize:S2};function b2(e){let t=e.length-4,r=3,n,i;if((e[r][1].type==="lineEnding"||e[r][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(n=r;++n<t;)if(e[n][1].type==="codeTextData"){e[r][1].type="codeTextPadding",e[t][1].type="codeTextPadding",r+=2,t-=2;break}}for(n=r-1,t++;++n<=t;)i===void 0?n!==t&&e[n][1].type!=="lineEnding"&&(i=n):(n===t||e[n][1].type==="lineEnding")&&(e[i][1].type="codeTextData",n!==i+2&&(e[i][1].end=e[n-1][1].end,e.splice(i+2,n-i-2),t-=n-i-2,n=i+2),i=void 0);return e}function w2(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function S2(e,t,r){let n=0,i,s;return o;function o(h){return e.enter("codeText"),e.enter("codeTextSequence"),l(h)}function l(h){return h===96?(e.consume(h),n++,l):(e.exit("codeTextSequence"),a(h))}function a(h){return h===null?r(h):h===32?(e.enter("space"),e.consume(h),e.exit("space"),a):h===96?(s=e.enter("codeTextSequence"),i=0,d(h)):be(h)?(e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),a):(e.enter("codeTextData"),c(h))}function c(h){return h===null||h===32||h===96||be(h)?(e.exit("codeTextData"),a(h)):(e.consume(h),c)}function d(h){return h===96?(e.consume(h),i++,d):i===n?(e.exit("codeTextSequence"),e.exit("codeText"),t(h)):(s.type="codeTextData",c(h))}}class k2{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,r){const n=r??Number.POSITIVE_INFINITY;return n<this.left.length?this.left.slice(t,n):t>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(t,r,n){const i=r||0;this.setCursor(Math.trunc(t));const s=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return n&&Ks(this.left,n),s.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),Ks(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Ks(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const r=this.left.splice(t,Number.POSITIVE_INFINITY);Ks(this.right,r.reverse())}else{const r=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);Ks(this.left,r.reverse())}}}function Ks(e,t){let r=0;if(t.length<1e4)e.push(...t);else for(;r<t.length;)e.push(...t.slice(r,r+1e4)),r+=1e4}function Yy(e){const t={};let r=-1,n,i,s,o,l,a,c;const d=new k2(e);for(;++r<d.length;){for(;r in t;)r=t[r];if(n=d.get(r),r&&n[1].type==="chunkFlow"&&d.get(r-1)[1].type==="listItemPrefix"&&(a=n[1]._tokenizer.events,s=0,s<a.length&&a[s][1].type==="lineEndingBlank"&&(s+=2),s<a.length&&a[s][1].type==="content"))for(;++s<a.length&&a[s][1].type!=="content";)a[s][1].type==="chunkText"&&(a[s][1]._isInFirstContentOfListItem=!0,s++);if(n[0]==="enter")n[1].contentType&&(Object.assign(t,C2(d,r)),r=t[r],c=!0);else if(n[1]._container){for(s=r,i=void 0;s--;)if(o=d.get(s),o[1].type==="lineEnding"||o[1].type==="lineEndingBlank")o[0]==="enter"&&(i&&(d.get(i)[1].type="lineEndingBlank"),o[1].type="lineEnding",i=s);else if(!(o[1].type==="linePrefix"||o[1].type==="listItemIndent"))break;i&&(n[1].end={...d.get(i)[1].start},l=d.slice(i,r),l.unshift(n),d.splice(i,r-i+1,l))}}return br(e,0,Number.POSITIVE_INFINITY,d.slice(0)),!c}function C2(e,t){const r=e.get(t)[1],n=e.get(t)[2];let i=t-1;const s=[];let o=r._tokenizer;o||(o=n.parser[r.contentType](r.start),r._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));const l=o.events,a=[],c={};let d,h,f=-1,p=r,m=0,_=0;const b=[_];for(;p;){for(;e.get(++i)[1]!==p;);s.push(i),p._tokenizer||(d=n.sliceStream(p),p.next||d.push(null),h&&o.defineSkip(p.start),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(d),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),h=p,p=p.next}for(p=r;++f<l.length;)l[f][0]==="exit"&&l[f-1][0]==="enter"&&l[f][1].type===l[f-1][1].type&&l[f][1].start.line!==l[f][1].end.line&&(_=f+1,b.push(_),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(o.events=[],p?(p._tokenizer=void 0,p.previous=void 0):b.pop(),f=b.length;f--;){const g=l.slice(b[f],b[f+1]),v=s.pop();a.push([v,v+g.length-1]),e.splice(v,2,g)}for(a.reverse(),f=-1;++f<a.length;)c[m+a[f][0]]=m+a[f][1],m+=a[f][1]-a[f][0]-1;return c}const E2={resolve:T2,tokenize:P2},N2={partial:!0,tokenize:R2};function T2(e){return Yy(e),e}function P2(e,t){let r;return n;function n(l){return e.enter("content"),r=e.enter("chunkContent",{contentType:"content"}),i(l)}function i(l){return l===null?s(l):be(l)?e.check(N2,o,s)(l):(e.consume(l),i)}function s(l){return e.exit("chunkContent"),e.exit("content"),t(l)}function o(l){return e.consume(l),e.exit("chunkContent"),r.next=e.enter("chunkContent",{contentType:"content",previous:r}),r=r.next,i}}function R2(e,t,r){const n=this;return i;function i(o){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),Fe(e,s,"linePrefix")}function s(o){if(o===null||be(o))return r(o);const l=n.events[n.events.length-1];return!n.parser.constructs.disable.null.includes("codeIndented")&&l&&l[1].type==="linePrefix"&&l[2].sliceSerialize(l[1],!0).length>=4?t(o):e.interrupt(n.parser.constructs.flow,r,t)(o)}}function Xy(e,t,r,n,i,s,o,l,a){const c=a||Number.POSITIVE_INFINITY;let d=0;return h;function h(g){return g===60?(e.enter(n),e.enter(i),e.enter(s),e.consume(g),e.exit(s),f):g===null||g===32||g===41||Ua(g)?r(g):(e.enter(n),e.enter(o),e.enter(l),e.enter("chunkString",{contentType:"string"}),_(g))}function f(g){return g===62?(e.enter(s),e.consume(g),e.exit(s),e.exit(i),e.exit(n),t):(e.enter(l),e.enter("chunkString",{contentType:"string"}),p(g))}function p(g){return g===62?(e.exit("chunkString"),e.exit(l),f(g)):g===null||g===60||be(g)?r(g):(e.consume(g),g===92?m:p)}function m(g){return g===60||g===62||g===92?(e.consume(g),p):p(g)}function _(g){return!d&&(g===null||g===41||Ye(g))?(e.exit("chunkString"),e.exit(l),e.exit(o),e.exit(n),t(g)):d<c&&g===40?(e.consume(g),d++,_):g===41?(e.consume(g),d--,_):g===null||g===32||g===40||Ua(g)?r(g):(e.consume(g),g===92?b:_)}function b(g){return g===40||g===41||g===92?(e.consume(g),_):_(g)}}function Gy(e,t,r,n,i,s){const o=this;let l=0,a;return c;function c(p){return e.enter(n),e.enter(i),e.consume(p),e.exit(i),e.enter(s),d}function d(p){return l>999||p===null||p===91||p===93&&!a||p===94&&!l&&"_hiddenFootnoteSupport"in o.parser.constructs?r(p):p===93?(e.exit(s),e.enter(i),e.consume(p),e.exit(i),e.exit(n),t):be(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),d):(e.enter("chunkString",{contentType:"string"}),h(p))}function h(p){return p===null||p===91||p===93||be(p)||l++>999?(e.exit("chunkString"),d(p)):(e.consume(p),a||(a=!ze(p)),p===92?f:h)}function f(p){return p===91||p===92||p===93?(e.consume(p),l++,h):h(p)}}function Qy(e,t,r,n,i,s){let o;return l;function l(f){return f===34||f===39||f===40?(e.enter(n),e.enter(i),e.consume(f),e.exit(i),o=f===40?41:f,a):r(f)}function a(f){return f===o?(e.enter(i),e.consume(f),e.exit(i),e.exit(n),t):(e.enter(s),c(f))}function c(f){return f===o?(e.exit(s),a(o)):f===null?r(f):be(f)?(e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),Fe(e,c,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),d(f))}function d(f){return f===o||f===null||be(f)?(e.exit("chunkString"),c(f)):(e.consume(f),f===92?h:d)}function h(f){return f===o||f===92?(e.consume(f),d):d(f)}}function bo(e,t){let r;return n;function n(i){return be(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),r=!0,n):ze(i)?Fe(e,n,r?"linePrefix":"lineSuffix")(i):t(i)}}const M2={name:"definition",tokenize:I2},L2={partial:!0,tokenize:j2};function I2(e,t,r){const n=this;let i;return s;function s(p){return e.enter("definition"),o(p)}function o(p){return Gy.call(n,e,l,r,"definitionLabel","definitionLabelMarker","definitionLabelString")(p)}function l(p){return i=qr(n.sliceSerialize(n.events[n.events.length-1][1]).slice(1,-1)),p===58?(e.enter("definitionMarker"),e.consume(p),e.exit("definitionMarker"),a):r(p)}function a(p){return Ye(p)?bo(e,c)(p):c(p)}function c(p){return Xy(e,d,r,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(p)}function d(p){return e.attempt(L2,h,h)(p)}function h(p){return ze(p)?Fe(e,f,"whitespace")(p):f(p)}function f(p){return p===null||be(p)?(e.exit("definition"),n.parser.defined.push(i),t(p)):r(p)}}function j2(e,t,r){return n;function n(l){return Ye(l)?bo(e,i)(l):r(l)}function i(l){return Qy(e,s,r,"definitionTitle","definitionTitleMarker","definitionTitleString")(l)}function s(l){return ze(l)?Fe(e,o,"whitespace")(l):o(l)}function o(l){return l===null||be(l)?t(l):r(l)}}const D2={name:"hardBreakEscape",tokenize:A2};function A2(e,t,r){return n;function n(s){return e.enter("hardBreakEscape"),e.consume(s),i}function i(s){return be(s)?(e.exit("hardBreakEscape"),t(s)):r(s)}}const B2={name:"headingAtx",resolve:O2,tokenize:z2};function O2(e,t){let r=e.length-2,n=3,i,s;return e[n][1].type==="whitespace"&&(n+=2),r-2>n&&e[r][1].type==="whitespace"&&(r-=2),e[r][1].type==="atxHeadingSequence"&&(n===r-1||r-4>n&&e[r-2][1].type==="whitespace")&&(r-=n+1===r?2:4),r>n&&(i={type:"atxHeadingText",start:e[n][1].start,end:e[r][1].end},s={type:"chunkText",start:e[n][1].start,end:e[r][1].end,contentType:"text"},br(e,n,r-n+1,[["enter",i,t],["enter",s,t],["exit",s,t],["exit",i,t]])),e}function z2(e,t,r){let n=0;return i;function i(d){return e.enter("atxHeading"),s(d)}function s(d){return e.enter("atxHeadingSequence"),o(d)}function o(d){return d===35&&n++<6?(e.consume(d),o):d===null||Ye(d)?(e.exit("atxHeadingSequence"),l(d)):r(d)}function l(d){return d===35?(e.enter("atxHeadingSequence"),a(d)):d===null||be(d)?(e.exit("atxHeading"),t(d)):ze(d)?Fe(e,l,"whitespace")(d):(e.enter("atxHeadingText"),c(d))}function a(d){return d===35?(e.consume(d),a):(e.exit("atxHeadingSequence"),l(d))}function c(d){return d===null||d===35||Ye(d)?(e.exit("atxHeadingText"),l(d)):(e.consume(d),c)}}const $2=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],Jm=["pre","script","style","textarea"],F2={concrete:!0,name:"htmlFlow",resolveTo:U2,tokenize:K2},W2={partial:!0,tokenize:q2},H2={partial:!0,tokenize:V2};function U2(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function K2(e,t,r){const n=this;let i,s,o,l,a;return c;function c(T){return d(T)}function d(T){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(T),h}function h(T){return T===33?(e.consume(T),f):T===47?(e.consume(T),s=!0,_):T===63?(e.consume(T),i=3,n.interrupt?t:w):Qt(T)?(e.consume(T),o=String.fromCharCode(T),b):r(T)}function f(T){return T===45?(e.consume(T),i=2,p):T===91?(e.consume(T),i=5,l=0,m):Qt(T)?(e.consume(T),i=4,n.interrupt?t:w):r(T)}function p(T){return T===45?(e.consume(T),n.interrupt?t:w):r(T)}function m(T){const X="CDATA[";return T===X.charCodeAt(l++)?(e.consume(T),l===X.length?n.interrupt?t:j:m):r(T)}function _(T){return Qt(T)?(e.consume(T),o=String.fromCharCode(T),b):r(T)}function b(T){if(T===null||T===47||T===62||Ye(T)){const X=T===47,I=o.toLowerCase();return!X&&!s&&Jm.includes(I)?(i=1,n.interrupt?t(T):j(T)):$2.includes(o.toLowerCase())?(i=6,X?(e.consume(T),g):n.interrupt?t(T):j(T)):(i=7,n.interrupt&&!n.parser.lazy[n.now().line]?r(T):s?v(T):y(T))}return T===45||Kt(T)?(e.consume(T),o+=String.fromCharCode(T),b):r(T)}function g(T){return T===62?(e.consume(T),n.interrupt?t:j):r(T)}function v(T){return ze(T)?(e.consume(T),v):k(T)}function y(T){return T===47?(e.consume(T),k):T===58||T===95||Qt(T)?(e.consume(T),S):ze(T)?(e.consume(T),y):k(T)}function S(T){return T===45||T===46||T===58||T===95||Kt(T)?(e.consume(T),S):R(T)}function R(T){return T===61?(e.consume(T),E):ze(T)?(e.consume(T),R):y(T)}function E(T){return T===null||T===60||T===61||T===62||T===96?r(T):T===34||T===39?(e.consume(T),a=T,P):ze(T)?(e.consume(T),E):N(T)}function P(T){return T===a?(e.consume(T),a=null,D):T===null||be(T)?r(T):(e.consume(T),P)}function N(T){return T===null||T===34||T===39||T===47||T===60||T===61||T===62||T===96||Ye(T)?R(T):(e.consume(T),N)}function D(T){return T===47||T===62||ze(T)?y(T):r(T)}function k(T){return T===62?(e.consume(T),B):r(T)}function B(T){return T===null||be(T)?j(T):ze(T)?(e.consume(T),B):r(T)}function j(T){return T===45&&i===2?(e.consume(T),O):T===60&&i===1?(e.consume(T),U):T===62&&i===4?(e.consume(T),ee):T===63&&i===3?(e.consume(T),w):T===93&&i===5?(e.consume(T),$):be(T)&&(i===6||i===7)?(e.exit("htmlFlowData"),e.check(W2,ne,M)(T)):T===null||be(T)?(e.exit("htmlFlowData"),M(T)):(e.consume(T),j)}function M(T){return e.check(H2,C,ne)(T)}function C(T){return e.enter("lineEnding"),e.consume(T),e.exit("lineEnding"),A}function A(T){return T===null||be(T)?M(T):(e.enter("htmlFlowData"),j(T))}function O(T){return T===45?(e.consume(T),w):j(T)}function U(T){return T===47?(e.consume(T),o="",L):j(T)}function L(T){if(T===62){const X=o.toLowerCase();return Jm.includes(X)?(e.consume(T),ee):j(T)}return Qt(T)&&o.length<8?(e.consume(T),o+=String.fromCharCode(T),L):j(T)}function $(T){return T===93?(e.consume(T),w):j(T)}function w(T){return T===62?(e.consume(T),ee):T===45&&i===2?(e.consume(T),w):j(T)}function ee(T){return T===null||be(T)?(e.exit("htmlFlowData"),ne(T)):(e.consume(T),ee)}function ne(T){return e.exit("htmlFlow"),t(T)}}function V2(e,t,r){const n=this;return i;function i(o){return be(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),s):r(o)}function s(o){return n.parser.lazy[n.now().line]?r(o):t(o)}}function q2(e,t,r){return n;function n(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e.attempt(al,t,r)}}const Y2={name:"htmlText",tokenize:X2};function X2(e,t,r){const n=this;let i,s,o;return l;function l(w){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(w),a}function a(w){return w===33?(e.consume(w),c):w===47?(e.consume(w),R):w===63?(e.consume(w),y):Qt(w)?(e.consume(w),N):r(w)}function c(w){return w===45?(e.consume(w),d):w===91?(e.consume(w),s=0,m):Qt(w)?(e.consume(w),v):r(w)}function d(w){return w===45?(e.consume(w),p):r(w)}function h(w){return w===null?r(w):w===45?(e.consume(w),f):be(w)?(o=h,U(w)):(e.consume(w),h)}function f(w){return w===45?(e.consume(w),p):h(w)}function p(w){return w===62?O(w):w===45?f(w):h(w)}function m(w){const ee="CDATA[";return w===ee.charCodeAt(s++)?(e.consume(w),s===ee.length?_:m):r(w)}function _(w){return w===null?r(w):w===93?(e.consume(w),b):be(w)?(o=_,U(w)):(e.consume(w),_)}function b(w){return w===93?(e.consume(w),g):_(w)}function g(w){return w===62?O(w):w===93?(e.consume(w),g):_(w)}function v(w){return w===null||w===62?O(w):be(w)?(o=v,U(w)):(e.consume(w),v)}function y(w){return w===null?r(w):w===63?(e.consume(w),S):be(w)?(o=y,U(w)):(e.consume(w),y)}function S(w){return w===62?O(w):y(w)}function R(w){return Qt(w)?(e.consume(w),E):r(w)}function E(w){return w===45||Kt(w)?(e.consume(w),E):P(w)}function P(w){return be(w)?(o=P,U(w)):ze(w)?(e.consume(w),P):O(w)}function N(w){return w===45||Kt(w)?(e.consume(w),N):w===47||w===62||Ye(w)?D(w):r(w)}function D(w){return w===47?(e.consume(w),O):w===58||w===95||Qt(w)?(e.consume(w),k):be(w)?(o=D,U(w)):ze(w)?(e.consume(w),D):O(w)}function k(w){return w===45||w===46||w===58||w===95||Kt(w)?(e.consume(w),k):B(w)}function B(w){return w===61?(e.consume(w),j):be(w)?(o=B,U(w)):ze(w)?(e.consume(w),B):D(w)}function j(w){return w===null||w===60||w===61||w===62||w===96?r(w):w===34||w===39?(e.consume(w),i=w,M):be(w)?(o=j,U(w)):ze(w)?(e.consume(w),j):(e.consume(w),C)}function M(w){return w===i?(e.consume(w),i=void 0,A):w===null?r(w):be(w)?(o=M,U(w)):(e.consume(w),M)}function C(w){return w===null||w===34||w===39||w===60||w===61||w===96?r(w):w===47||w===62||Ye(w)?D(w):(e.consume(w),C)}function A(w){return w===47||w===62||Ye(w)?D(w):r(w)}function O(w){return w===62?(e.consume(w),e.exit("htmlTextData"),e.exit("htmlText"),t):r(w)}function U(w){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(w),e.exit("lineEnding"),L}function L(w){return ze(w)?Fe(e,$,"linePrefix",n.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(w):$(w)}function $(w){return e.enter("htmlTextData"),o(w)}}const qf={name:"labelEnd",resolveAll:Z2,resolveTo:eE,tokenize:tE},G2={tokenize:rE},Q2={tokenize:nE},J2={tokenize:iE};function Z2(e){let t=-1;const r=[];for(;++t<e.length;){const n=e[t][1];if(r.push(e[t]),n.type==="labelImage"||n.type==="labelLink"||n.type==="labelEnd"){const i=n.type==="labelImage"?4:2;n.type="data",t+=i}}return e.length!==r.length&&br(e,0,e.length,r),e}function eE(e,t){let r=e.length,n=0,i,s,o,l;for(;r--;)if(i=e[r][1],s){if(i.type==="link"||i.type==="labelLink"&&i._inactive)break;e[r][0]==="enter"&&i.type==="labelLink"&&(i._inactive=!0)}else if(o){if(e[r][0]==="enter"&&(i.type==="labelImage"||i.type==="labelLink")&&!i._balanced&&(s=r,i.type!=="labelLink")){n=2;break}}else i.type==="labelEnd"&&(o=r);const a={type:e[s][1].type==="labelLink"?"link":"image",start:{...e[s][1].start},end:{...e[e.length-1][1].end}},c={type:"label",start:{...e[s][1].start},end:{...e[o][1].end}},d={type:"labelText",start:{...e[s+n+2][1].end},end:{...e[o-2][1].start}};return l=[["enter",a,t],["enter",c,t]],l=Lr(l,e.slice(s+1,s+n+3)),l=Lr(l,[["enter",d,t]]),l=Lr(l,Sc(t.parser.constructs.insideSpan.null,e.slice(s+n+4,o-3),t)),l=Lr(l,[["exit",d,t],e[o-2],e[o-1],["exit",c,t]]),l=Lr(l,e.slice(o+1)),l=Lr(l,[["exit",a,t]]),br(e,s,e.length,l),e}function tE(e,t,r){const n=this;let i=n.events.length,s,o;for(;i--;)if((n.events[i][1].type==="labelImage"||n.events[i][1].type==="labelLink")&&!n.events[i][1]._balanced){s=n.events[i][1];break}return l;function l(f){return s?s._inactive?h(f):(o=n.parser.defined.includes(qr(n.sliceSerialize({start:s.end,end:n.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(f),e.exit("labelMarker"),e.exit("labelEnd"),a):r(f)}function a(f){return f===40?e.attempt(G2,d,o?d:h)(f):f===91?e.attempt(Q2,d,o?c:h)(f):o?d(f):h(f)}function c(f){return e.attempt(J2,d,h)(f)}function d(f){return t(f)}function h(f){return s._balanced=!0,r(f)}}function rE(e,t,r){return n;function n(h){return e.enter("resource"),e.enter("resourceMarker"),e.consume(h),e.exit("resourceMarker"),i}function i(h){return Ye(h)?bo(e,s)(h):s(h)}function s(h){return h===41?d(h):Xy(e,o,l,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(h)}function o(h){return Ye(h)?bo(e,a)(h):d(h)}function l(h){return r(h)}function a(h){return h===34||h===39||h===40?Qy(e,c,r,"resourceTitle","resourceTitleMarker","resourceTitleString")(h):d(h)}function c(h){return Ye(h)?bo(e,d)(h):d(h)}function d(h){return h===41?(e.enter("resourceMarker"),e.consume(h),e.exit("resourceMarker"),e.exit("resource"),t):r(h)}}function nE(e,t,r){const n=this;return i;function i(l){return Gy.call(n,e,s,o,"reference","referenceMarker","referenceString")(l)}function s(l){return n.parser.defined.includes(qr(n.sliceSerialize(n.events[n.events.length-1][1]).slice(1,-1)))?t(l):r(l)}function o(l){return r(l)}}function iE(e,t,r){return n;function n(s){return e.enter("reference"),e.enter("referenceMarker"),e.consume(s),e.exit("referenceMarker"),i}function i(s){return s===93?(e.enter("referenceMarker"),e.consume(s),e.exit("referenceMarker"),e.exit("reference"),t):r(s)}}const sE={name:"labelStartImage",resolveAll:qf.resolveAll,tokenize:oE};function oE(e,t,r){const n=this;return i;function i(l){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(l),e.exit("labelImageMarker"),s}function s(l){return l===91?(e.enter("labelMarker"),e.consume(l),e.exit("labelMarker"),e.exit("labelImage"),o):r(l)}function o(l){return l===94&&"_hiddenFootnoteSupport"in n.parser.constructs?r(l):t(l)}}const lE={name:"labelStartLink",resolveAll:qf.resolveAll,tokenize:aE};function aE(e,t,r){const n=this;return i;function i(o){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(o),e.exit("labelMarker"),e.exit("labelLink"),s}function s(o){return o===94&&"_hiddenFootnoteSupport"in n.parser.constructs?r(o):t(o)}}const cu={name:"lineEnding",tokenize:cE};function cE(e,t){return r;function r(n){return e.enter("lineEnding"),e.consume(n),e.exit("lineEnding"),Fe(e,t,"linePrefix")}}const oa={name:"thematicBreak",tokenize:uE};function uE(e,t,r){let n=0,i;return s;function s(c){return e.enter("thematicBreak"),o(c)}function o(c){return i=c,l(c)}function l(c){return c===i?(e.enter("thematicBreakSequence"),a(c)):n>=3&&(c===null||be(c))?(e.exit("thematicBreak"),t(c)):r(c)}function a(c){return c===i?(e.consume(c),n++,a):(e.exit("thematicBreakSequence"),ze(c)?Fe(e,l,"whitespace")(c):l(c))}}const lr={continuation:{tokenize:pE},exit:gE,name:"list",tokenize:fE},hE={partial:!0,tokenize:_E},dE={partial:!0,tokenize:mE};function fE(e,t,r){const n=this,i=n.events[n.events.length-1];let s=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0,o=0;return l;function l(p){const m=n.containerState.type||(p===42||p===43||p===45?"listUnordered":"listOrdered");if(m==="listUnordered"?!n.containerState.marker||p===n.containerState.marker:Hh(p)){if(n.containerState.type||(n.containerState.type=m,e.enter(m,{_container:!0})),m==="listUnordered")return e.enter("listItemPrefix"),p===42||p===45?e.check(oa,r,c)(p):c(p);if(!n.interrupt||p===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),a(p)}return r(p)}function a(p){return Hh(p)&&++o<10?(e.consume(p),a):(!n.interrupt||o<2)&&(n.containerState.marker?p===n.containerState.marker:p===41||p===46)?(e.exit("listItemValue"),c(p)):r(p)}function c(p){return e.enter("listItemMarker"),e.consume(p),e.exit("listItemMarker"),n.containerState.marker=n.containerState.marker||p,e.check(al,n.interrupt?r:d,e.attempt(hE,f,h))}function d(p){return n.containerState.initialBlankLine=!0,s++,f(p)}function h(p){return ze(p)?(e.enter("listItemPrefixWhitespace"),e.consume(p),e.exit("listItemPrefixWhitespace"),f):r(p)}function f(p){return n.containerState.size=s+n.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(p)}}function pE(e,t,r){const n=this;return n.containerState._closeFlow=void 0,e.check(al,i,s);function i(l){return n.containerState.furtherBlankLines=n.containerState.furtherBlankLines||n.containerState.initialBlankLine,Fe(e,t,"listItemIndent",n.containerState.size+1)(l)}function s(l){return n.containerState.furtherBlankLines||!ze(l)?(n.containerState.furtherBlankLines=void 0,n.containerState.initialBlankLine=void 0,o(l)):(n.containerState.furtherBlankLines=void 0,n.containerState.initialBlankLine=void 0,e.attempt(dE,t,o)(l))}function o(l){return n.containerState._closeFlow=!0,n.interrupt=void 0,Fe(e,e.attempt(lr,t,r),"linePrefix",n.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(l)}}function mE(e,t,r){const n=this;return Fe(e,i,"listItemIndent",n.containerState.size+1);function i(s){const o=n.events[n.events.length-1];return o&&o[1].type==="listItemIndent"&&o[2].sliceSerialize(o[1],!0).length===n.containerState.size?t(s):r(s)}}function gE(e){e.exit(this.containerState.type)}function _E(e,t,r){const n=this;return Fe(e,i,"listItemPrefixWhitespace",n.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(s){const o=n.events[n.events.length-1];return!ze(s)&&o&&o[1].type==="listItemPrefixWhitespace"?t(s):r(s)}}const Zm={name:"setextUnderline",resolveTo:vE,tokenize:xE};function vE(e,t){let r=e.length,n,i,s;for(;r--;)if(e[r][0]==="enter"){if(e[r][1].type==="content"){n=r;break}e[r][1].type==="paragraph"&&(i=r)}else e[r][1].type==="content"&&e.splice(r,1),!s&&e[r][1].type==="definition"&&(s=r);const o={type:"setextHeading",start:{...e[n][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type="setextHeadingText",s?(e.splice(i,0,["enter",o,t]),e.splice(s+1,0,["exit",e[n][1],t]),e[n][1].end={...e[s][1].end}):e[n][1]=o,e.push(["exit",o,t]),e}function xE(e,t,r){const n=this;let i;return s;function s(c){let d=n.events.length,h;for(;d--;)if(n.events[d][1].type!=="lineEnding"&&n.events[d][1].type!=="linePrefix"&&n.events[d][1].type!=="content"){h=n.events[d][1].type==="paragraph";break}return!n.parser.lazy[n.now().line]&&(n.interrupt||h)?(e.enter("setextHeadingLine"),i=c,o(c)):r(c)}function o(c){return e.enter("setextHeadingLineSequence"),l(c)}function l(c){return c===i?(e.consume(c),l):(e.exit("setextHeadingLineSequence"),ze(c)?Fe(e,a,"lineSuffix")(c):a(c))}function a(c){return c===null||be(c)?(e.exit("setextHeadingLine"),t(c)):r(c)}}const yE={tokenize:bE};function bE(e){const t=this,r=e.attempt(al,n,e.attempt(this.parser.constructs.flowInitial,i,Fe(e,e.attempt(this.parser.constructs.flow,i,e.attempt(E2,i)),"linePrefix")));return r;function n(s){if(s===null){e.consume(s);return}return e.enter("lineEndingBlank"),e.consume(s),e.exit("lineEndingBlank"),t.currentConstruct=void 0,r}function i(s){if(s===null){e.consume(s);return}return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),t.currentConstruct=void 0,r}}const wE={resolveAll:Zy()},SE=Jy("string"),kE=Jy("text");function Jy(e){return{resolveAll:Zy(e==="text"?CE:void 0),tokenize:t};function t(r){const n=this,i=this.parser.constructs[e],s=r.attempt(i,o,l);return o;function o(d){return c(d)?s(d):l(d)}function l(d){if(d===null){r.consume(d);return}return r.enter("data"),r.consume(d),a}function a(d){return c(d)?(r.exit("data"),s(d)):(r.consume(d),a)}function c(d){if(d===null)return!0;const h=i[d];let f=-1;if(h)for(;++f<h.length;){const p=h[f];if(!p.previous||p.previous.call(n,n.previous))return!0}return!1}}}function Zy(e){return t;function t(r,n){let i=-1,s;for(;++i<=r.length;)s===void 0?r[i]&&r[i][1].type==="data"&&(s=i,i++):(!r[i]||r[i][1].type!=="data")&&(i!==s+2&&(r[s][1].end=r[i-1][1].end,r.splice(s+2,i-s-2),i=s+2),s=void 0);return e?e(r,n):r}}function CE(e,t){let r=0;for(;++r<=e.length;)if((r===e.length||e[r][1].type==="lineEnding")&&e[r-1][1].type==="data"){const n=e[r-1][1],i=t.sliceStream(n);let s=i.length,o=-1,l=0,a;for(;s--;){const c=i[s];if(typeof c=="string"){for(o=c.length;c.charCodeAt(o-1)===32;)l++,o--;if(o)break;o=-1}else if(c===-2)a=!0,l++;else if(c!==-1){s++;break}}if(t._contentTypeTextTrailing&&r===e.length&&(l=0),l){const c={type:r===e.length||a||l<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:s?o:n.start._bufferIndex+o,_index:n.start._index+s,line:n.end.line,column:n.end.column-l,offset:n.end.offset-l},end:{...n.end}};n.end={...c.start},n.start.offset===n.end.offset?Object.assign(n,c):(e.splice(r,0,["enter",c,t],["exit",c,t]),r+=2)}r++}return e}const EE={42:lr,43:lr,45:lr,48:lr,49:lr,50:lr,51:lr,52:lr,53:lr,54:lr,55:lr,56:lr,57:lr,62:Ky},NE={91:M2},TE={[-2]:au,[-1]:au,32:au},PE={35:B2,42:oa,45:[Zm,oa],60:F2,61:Zm,95:oa,96:Qm,126:Qm},RE={38:qy,92:Vy},ME={[-5]:cu,[-4]:cu,[-3]:cu,33:sE,38:qy,42:Uh,60:[l2,Y2],91:lE,92:[D2,Vy],93:qf,95:Uh,96:y2},LE={null:[Uh,wE]},IE={null:[42,95]},jE={null:[]},DE=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:IE,contentInitial:NE,disable:jE,document:EE,flow:PE,flowInitial:TE,insideSpan:LE,string:RE,text:ME},Symbol.toStringTag,{value:"Module"}));function AE(e,t,r){let n={_bufferIndex:-1,_index:0,line:r&&r.line||1,column:r&&r.column||1,offset:r&&r.offset||0};const i={},s=[];let o=[],l=[];const a={attempt:P(R),check:P(E),consume:v,enter:y,exit:S,interrupt:P(E,{interrupt:!0})},c={code:null,containerState:{},defineSkip:_,events:[],now:m,parser:e,previous:null,sliceSerialize:f,sliceStream:p,write:h};let d=t.tokenize.call(c,a);return t.resolveAll&&s.push(t),c;function h(B){return o=Lr(o,B),b(),o[o.length-1]!==null?[]:(N(t,0),c.events=Sc(s,c.events,c),c.events)}function f(B,j){return OE(p(B),j)}function p(B){return BE(o,B)}function m(){const{_bufferIndex:B,_index:j,line:M,column:C,offset:A}=n;return{_bufferIndex:B,_index:j,line:M,column:C,offset:A}}function _(B){i[B.line]=B.column,k()}function b(){let B;for(;n._index<o.length;){const j=o[n._index];if(typeof j=="string")for(B=n._index,n._bufferIndex<0&&(n._bufferIndex=0);n._index===B&&n._bufferIndex<j.length;)g(j.charCodeAt(n._bufferIndex));else g(j)}}function g(B){d=d(B)}function v(B){be(B)?(n.line++,n.column=1,n.offset+=B===-3?2:1,k()):B!==-1&&(n.column++,n.offset++),n._bufferIndex<0?n._index++:(n._bufferIndex++,n._bufferIndex===o[n._index].length&&(n._bufferIndex=-1,n._index++)),c.previous=B}function y(B,j){const M=j||{};return M.type=B,M.start=m(),c.events.push(["enter",M,c]),l.push(M),M}function S(B){const j=l.pop();return j.end=m(),c.events.push(["exit",j,c]),j}function R(B,j){N(B,j.from)}function E(B,j){j.restore()}function P(B,j){return M;function M(C,A,O){let U,L,$,w;return Array.isArray(C)?ne(C):"tokenize"in C?ne([C]):ee(C);function ee(F){return G;function G(he){const me=he!==null&&F[he],je=he!==null&&F.null,Pe=[...Array.isArray(me)?me:me?[me]:[],...Array.isArray(je)?je:je?[je]:[]];return ne(Pe)(he)}}function ne(F){return U=F,L=0,F.length===0?O:T(F[L])}function T(F){return G;function G(he){return w=D(),$=F,F.partial||(c.currentConstruct=F),F.name&&c.parser.constructs.disable.null.includes(F.name)?I():F.tokenize.call(j?Object.assign(Object.create(c),j):c,a,X,I)(he)}}function X(F){return B($,w),A}function I(F){return w.restore(),++L<U.length?T(U[L]):O}}}function N(B,j){B.resolveAll&&!s.includes(B)&&s.push(B),B.resolve&&br(c.events,j,c.events.length-j,B.resolve(c.events.slice(j),c)),B.resolveTo&&(c.events=B.resolveTo(c.events,c))}function D(){const B=m(),j=c.previous,M=c.currentConstruct,C=c.events.length,A=Array.from(l);return{from:C,restore:O};function O(){n=B,c.previous=j,c.currentConstruct=M,c.events.length=C,l=A,k()}}function k(){n.line in i&&n.column<2&&(n.column=i[n.line],n.offset+=i[n.line]-1)}}function BE(e,t){const r=t.start._index,n=t.start._bufferIndex,i=t.end._index,s=t.end._bufferIndex;let o;if(r===i)o=[e[r].slice(n,s)];else{if(o=e.slice(r,i),n>-1){const l=o[0];typeof l=="string"?o[0]=l.slice(n):o.shift()}s>0&&o.push(e[i].slice(0,s))}return o}function OE(e,t){let r=-1;const n=[];let i;for(;++r<e.length;){const s=e[r];let o;if(typeof s=="string")o=s;else switch(s){case-5:{o="\r";break}case-4:{o=`
|
|
69
69
|
`;break}case-3:{o=`\r
|
|
70
|
-
`;break}case-2:{o=t?" ":" ";break}case-1:{if(!t&&i)continue;o=" ";break}default:o=String.fromCharCode(s)}i=s===-2,n.push(o)}return n.join("")}function zE(e){const n={constructs:Hy([DE,...(e||{}).extensions||[]]),content:i(e2),defined:[],document:i(r2),flow:i(yE),lazy:{},string:i(SE),text:i(kE)};return n;function i(s){return o;function o(l){return AE(n,s,l)}}}function $E(e){for(;!Yy(e););return e}const eg=/[\0\t\n\r]/g;function FE(){let e=1,t="",r=!0,n;return i;function i(s,o,l){const a=[];let c,d,h,f,p;for(s=t+(typeof s=="string"?s.toString():new TextDecoder(o||void 0).decode(s)),h=0,t="",r&&(s.charCodeAt(0)===65279&&h++,r=void 0);h<s.length;){if(eg.lastIndex=h,c=eg.exec(s),f=c&&c.index!==void 0?c.index:s.length,p=s.charCodeAt(f),!c){t=s.slice(h);break}if(p===10&&h===f&&n)a.push(-3),n=void 0;else switch(n&&(a.push(-5),n=void 0),h<f&&(a.push(s.slice(h,f)),e+=f-h),p){case 0:{a.push(65533),e++;break}case 9:{for(d=Math.ceil(e/4)*4,a.push(-2);e++<d;)a.push(-1);break}case 10:{a.push(-4),e=1;break}default:n=!0,e=1}h=f+1}return l&&(n&&a.push(-5),t&&a.push(t),a.push(null)),a}}const WE=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function HE(e){return e.replace(WE,UE)}function UE(e,t,r){if(t)return t;if(r.charCodeAt(0)===35){const i=r.charCodeAt(1),s=i===120||i===88;return Uy(r.slice(s?2:1),s?16:10)}return Vf(r)||e}const e0={}.hasOwnProperty;function KE(e,t,r){return t&&typeof t=="object"&&(r=t,t=void 0),VE(r)($E(zE(r).document().write(FE()(e,t,!0))))}function VE(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:s(we),autolinkProtocol:D,autolinkEmail:D,atxHeading:s(J),blockQuote:s(je),characterEscape:D,characterReference:D,codeFenced:s(Pe),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:s(Pe,o),codeText:s(Ce,o),codeTextData:D,data:D,codeFlowValue:D,definition:s(de),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:s(Te),hardBreakEscape:s(fe),hardBreakTrailing:s(fe),htmlFlow:s(ke,o),htmlFlowData:D,htmlText:s(ke,o),htmlTextData:D,image:s(Me),label:o,link:s(we),listItem:s(nr),listItemValue:f,listOrdered:s(Ke,h),listUnordered:s(Ke),paragraph:s(Qe),reference:T,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:s(J),strong:s(ir),thematicBreak:s($t)},exit:{atxHeading:a(),atxHeadingSequence:R,autolink:a(),autolinkEmail:me,autolinkProtocol:he,blockQuote:a(),characterEscapeValue:k,characterReferenceMarkerHexadecimal:I,characterReferenceMarkerNumeric:I,characterReferenceValue:F,characterReference:G,codeFenced:a(b),codeFencedFence:_,codeFencedFenceInfo:p,codeFencedFenceMeta:m,codeFlowValue:k,codeIndented:a(g),codeText:a(A),codeTextData:k,data:k,definition:a(),definitionDestinationString:S,definitionLabelString:v,definitionTitleString:y,emphasis:a(),hardBreakEscape:a(j),hardBreakTrailing:a(j),htmlFlow:a(M),htmlFlowData:k,htmlText:a(C),htmlTextData:k,image:a(U),label:$,labelText:L,lineEnding:B,link:a(O),listItem:a(),listOrdered:a(),listUnordered:a(),paragraph:a(),referenceString:X,resourceDestinationString:w,resourceTitleString:ee,resource:ne,setextHeading:a(N),setextHeadingLineSequence:P,setextHeadingText:E,strong:a(),thematicBreak:a()}};t0(t,(e||{}).mdastExtensions||[]);const r={};return n;function n(Y){let se={type:"root",children:[]};const ye={stack:[se],tokenStack:[],config:t,enter:l,exit:c,buffer:o,resume:d,data:r},K=[];let oe=-1;for(;++oe<Y.length;)if(Y[oe][1].type==="listOrdered"||Y[oe][1].type==="listUnordered")if(Y[oe][0]==="enter")K.push(oe);else{const xe=K.pop();oe=i(Y,xe,oe)}for(oe=-1;++oe<Y.length;){const xe=t[Y[oe][0]];e0.call(xe,Y[oe][1].type)&&xe[Y[oe][1].type].call(Object.assign({sliceSerialize:Y[oe][2].sliceSerialize},ye),Y[oe][1])}if(ye.tokenStack.length>0){const xe=ye.tokenStack[ye.tokenStack.length-1];(xe[1]||tg).call(ye,void 0,xe[0])}for(se.position={start:Ln(Y.length>0?Y[0][1].start:{line:1,column:1,offset:0}),end:Ln(Y.length>0?Y[Y.length-2][1].end:{line:1,column:1,offset:0})},oe=-1;++oe<t.transforms.length;)se=t.transforms[oe](se)||se;return se}function i(Y,se,ye){let K=se-1,oe=-1,xe=!1,Oe,Se,q,te;for(;++K<=ye;){const Z=Y[K];switch(Z[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{Z[0]==="enter"?oe++:oe--,te=void 0;break}case"lineEndingBlank":{Z[0]==="enter"&&(Oe&&!te&&!oe&&!q&&(q=K),te=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:te=void 0}if(!oe&&Z[0]==="enter"&&Z[1].type==="listItemPrefix"||oe===-1&&Z[0]==="exit"&&(Z[1].type==="listUnordered"||Z[1].type==="listOrdered")){if(Oe){let ve=K;for(Se=void 0;ve--;){const Re=Y[ve];if(Re[1].type==="lineEnding"||Re[1].type==="lineEndingBlank"){if(Re[0]==="exit")continue;Se&&(Y[Se][1].type="lineEndingBlank",xe=!0),Re[1].type="lineEnding",Se=ve}else if(!(Re[1].type==="linePrefix"||Re[1].type==="blockQuotePrefix"||Re[1].type==="blockQuotePrefixWhitespace"||Re[1].type==="blockQuoteMarker"||Re[1].type==="listItemIndent"))break}q&&(!Se||q<Se)&&(Oe._spread=!0),Oe.end=Object.assign({},Se?Y[Se][1].start:Z[1].end),Y.splice(Se||K,0,["exit",Oe,Z[2]]),K++,ye++}if(Z[1].type==="listItemPrefix"){const ve={type:"listItem",_spread:!1,start:Object.assign({},Z[1].start),end:void 0};Oe=ve,Y.splice(K,0,["enter",ve,Z[2]]),K++,ye++,q=void 0,te=!0}}}return Y[se][1]._spread=xe,ye}function s(Y,se){return ye;function ye(K){l.call(this,Y(K),K),se&&se.call(this,K)}}function o(){this.stack.push({type:"fragment",children:[]})}function l(Y,se,ye){this.stack[this.stack.length-1].children.push(Y),this.stack.push(Y),this.tokenStack.push([se,ye||void 0]),Y.position={start:Ln(se.start),end:void 0}}function a(Y){return se;function se(ye){Y&&Y.call(this,ye),c.call(this,ye)}}function c(Y,se){const ye=this.stack.pop(),K=this.tokenStack.pop();if(K)K[0].type!==Y.type&&(se?se.call(this,Y,K[0]):(K[1]||tg).call(this,Y,K[0]));else throw new Error("Cannot close `"+Y.type+"` ("+yo({start:Y.start,end:Y.end})+"): it’s not open");ye.position.end=Ln(Y.end)}function d(){return Kf(this.stack.pop())}function h(){this.data.expectingFirstListItemValue=!0}function f(Y){if(this.data.expectingFirstListItemValue){const se=this.stack[this.stack.length-2];se.start=Number.parseInt(this.sliceSerialize(Y),10),this.data.expectingFirstListItemValue=void 0}}function p(){const Y=this.resume(),se=this.stack[this.stack.length-1];se.lang=Y}function m(){const Y=this.resume(),se=this.stack[this.stack.length-1];se.meta=Y}function _(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function b(){const Y=this.resume(),se=this.stack[this.stack.length-1];se.value=Y.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function g(){const Y=this.resume(),se=this.stack[this.stack.length-1];se.value=Y.replace(/(\r?\n|\r)$/g,"")}function v(Y){const se=this.resume(),ye=this.stack[this.stack.length-1];ye.label=se,ye.identifier=qr(this.sliceSerialize(Y)).toLowerCase()}function y(){const Y=this.resume(),se=this.stack[this.stack.length-1];se.title=Y}function S(){const Y=this.resume(),se=this.stack[this.stack.length-1];se.url=Y}function R(Y){const se=this.stack[this.stack.length-1];if(!se.depth){const ye=this.sliceSerialize(Y).length;se.depth=ye}}function E(){this.data.setextHeadingSlurpLineEnding=!0}function P(Y){const se=this.stack[this.stack.length-1];se.depth=this.sliceSerialize(Y).codePointAt(0)===61?1:2}function N(){this.data.setextHeadingSlurpLineEnding=void 0}function D(Y){const ye=this.stack[this.stack.length-1].children;let K=ye[ye.length-1];(!K||K.type!=="text")&&(K=sr(),K.position={start:Ln(Y.start),end:void 0},ye.push(K)),this.stack.push(K)}function k(Y){const se=this.stack.pop();se.value+=this.sliceSerialize(Y),se.position.end=Ln(Y.end)}function B(Y){const se=this.stack[this.stack.length-1];if(this.data.atHardBreak){const ye=se.children[se.children.length-1];ye.position.end=Ln(Y.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(se.type)&&(D.call(this,Y),k.call(this,Y))}function j(){this.data.atHardBreak=!0}function M(){const Y=this.resume(),se=this.stack[this.stack.length-1];se.value=Y}function C(){const Y=this.resume(),se=this.stack[this.stack.length-1];se.value=Y}function A(){const Y=this.resume(),se=this.stack[this.stack.length-1];se.value=Y}function O(){const Y=this.stack[this.stack.length-1];if(this.data.inReference){const se=this.data.referenceType||"shortcut";Y.type+="Reference",Y.referenceType=se,delete Y.url,delete Y.title}else delete Y.identifier,delete Y.label;this.data.referenceType=void 0}function U(){const Y=this.stack[this.stack.length-1];if(this.data.inReference){const se=this.data.referenceType||"shortcut";Y.type+="Reference",Y.referenceType=se,delete Y.url,delete Y.title}else delete Y.identifier,delete Y.label;this.data.referenceType=void 0}function L(Y){const se=this.sliceSerialize(Y),ye=this.stack[this.stack.length-2];ye.label=HE(se),ye.identifier=qr(se).toLowerCase()}function $(){const Y=this.stack[this.stack.length-1],se=this.resume(),ye=this.stack[this.stack.length-1];if(this.data.inReference=!0,ye.type==="link"){const K=Y.children;ye.children=K}else ye.alt=se}function w(){const Y=this.resume(),se=this.stack[this.stack.length-1];se.url=Y}function ee(){const Y=this.resume(),se=this.stack[this.stack.length-1];se.title=Y}function ne(){this.data.inReference=void 0}function T(){this.data.referenceType="collapsed"}function X(Y){const se=this.resume(),ye=this.stack[this.stack.length-1];ye.label=se,ye.identifier=qr(this.sliceSerialize(Y)).toLowerCase(),this.data.referenceType="full"}function I(Y){this.data.characterReferenceType=Y.type}function F(Y){const se=this.sliceSerialize(Y),ye=this.data.characterReferenceType;let K;ye?(K=Uy(se,ye==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):K=Vf(se);const oe=this.stack[this.stack.length-1];oe.value+=K}function G(Y){const se=this.stack.pop();se.position.end=Ln(Y.end)}function he(Y){k.call(this,Y);const se=this.stack[this.stack.length-1];se.url=this.sliceSerialize(Y)}function me(Y){k.call(this,Y);const se=this.stack[this.stack.length-1];se.url="mailto:"+this.sliceSerialize(Y)}function je(){return{type:"blockquote",children:[]}}function Pe(){return{type:"code",lang:null,meta:null,value:""}}function Ce(){return{type:"inlineCode",value:""}}function de(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function Te(){return{type:"emphasis",children:[]}}function J(){return{type:"heading",depth:0,children:[]}}function fe(){return{type:"break"}}function ke(){return{type:"html",value:""}}function Me(){return{type:"image",title:null,url:"",alt:null}}function we(){return{type:"link",title:null,url:"",children:[]}}function Ke(Y){return{type:"list",ordered:Y.type==="listOrdered",start:null,spread:Y._spread,children:[]}}function nr(Y){return{type:"listItem",spread:Y._spread,checked:null,children:[]}}function Qe(){return{type:"paragraph",children:[]}}function ir(){return{type:"strong",children:[]}}function sr(){return{type:"text",value:""}}function $t(){return{type:"thematicBreak"}}}function Ln(e){return{line:e.line,column:e.column,offset:e.offset}}function t0(e,t){let r=-1;for(;++r<t.length;){const n=t[r];Array.isArray(n)?t0(e,n):qE(e,n)}}function qE(e,t){let r;for(r in t)if(e0.call(t,r))switch(r){case"canContainEols":{const n=t[r];n&&e[r].push(...n);break}case"transforms":{const n=t[r];n&&e[r].push(...n);break}case"enter":case"exit":{const n=t[r];n&&Object.assign(e[r],n);break}}}function tg(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+yo({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+yo({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+yo({start:t.start,end:t.end})+") is still open")}function YE(e){const t=this;t.parser=r;function r(n){return KE(n,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function XE(e,t){const r={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,r),e.applyData(t,r)}function GE(e,t){const r={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,r),[e.applyData(t,r),{type:"text",value:`
|
|
70
|
+
`;break}case-2:{o=t?" ":" ";break}case-1:{if(!t&&i)continue;o=" ";break}default:o=String.fromCharCode(s)}i=s===-2,n.push(o)}return n.join("")}function zE(e){const n={constructs:Hy([DE,...(e||{}).extensions||[]]),content:i(e2),defined:[],document:i(r2),flow:i(yE),lazy:{},string:i(SE),text:i(kE)};return n;function i(s){return o;function o(l){return AE(n,s,l)}}}function $E(e){for(;!Yy(e););return e}const eg=/[\0\t\n\r]/g;function FE(){let e=1,t="",r=!0,n;return i;function i(s,o,l){const a=[];let c,d,h,f,p;for(s=t+(typeof s=="string"?s.toString():new TextDecoder(o||void 0).decode(s)),h=0,t="",r&&(s.charCodeAt(0)===65279&&h++,r=void 0);h<s.length;){if(eg.lastIndex=h,c=eg.exec(s),f=c&&c.index!==void 0?c.index:s.length,p=s.charCodeAt(f),!c){t=s.slice(h);break}if(p===10&&h===f&&n)a.push(-3),n=void 0;else switch(n&&(a.push(-5),n=void 0),h<f&&(a.push(s.slice(h,f)),e+=f-h),p){case 0:{a.push(65533),e++;break}case 9:{for(d=Math.ceil(e/4)*4,a.push(-2);e++<d;)a.push(-1);break}case 10:{a.push(-4),e=1;break}default:n=!0,e=1}h=f+1}return l&&(n&&a.push(-5),t&&a.push(t),a.push(null)),a}}const WE=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function HE(e){return e.replace(WE,UE)}function UE(e,t,r){if(t)return t;if(r.charCodeAt(0)===35){const i=r.charCodeAt(1),s=i===120||i===88;return Uy(r.slice(s?2:1),s?16:10)}return Vf(r)||e}const e0={}.hasOwnProperty;function KE(e,t,r){return t&&typeof t=="object"&&(r=t,t=void 0),VE(r)($E(zE(r).document().write(FE()(e,t,!0))))}function VE(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:s(we),autolinkProtocol:D,autolinkEmail:D,atxHeading:s(J),blockQuote:s(je),characterEscape:D,characterReference:D,codeFenced:s(Pe),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:s(Pe,o),codeText:s(Ce,o),codeTextData:D,data:D,codeFlowValue:D,definition:s(de),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:s(Te),hardBreakEscape:s(fe),hardBreakTrailing:s(fe),htmlFlow:s(ke,o),htmlFlowData:D,htmlText:s(ke,o),htmlTextData:D,image:s(Me),label:o,link:s(we),listItem:s(nr),listItemValue:f,listOrdered:s(Ke,h),listUnordered:s(Ke),paragraph:s(Qe),reference:T,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:s(J),strong:s(ir),thematicBreak:s($t)},exit:{atxHeading:a(),atxHeadingSequence:R,autolink:a(),autolinkEmail:me,autolinkProtocol:he,blockQuote:a(),characterEscapeValue:k,characterReferenceMarkerHexadecimal:I,characterReferenceMarkerNumeric:I,characterReferenceValue:F,characterReference:G,codeFenced:a(b),codeFencedFence:_,codeFencedFenceInfo:p,codeFencedFenceMeta:m,codeFlowValue:k,codeIndented:a(g),codeText:a(A),codeTextData:k,data:k,definition:a(),definitionDestinationString:S,definitionLabelString:v,definitionTitleString:y,emphasis:a(),hardBreakEscape:a(j),hardBreakTrailing:a(j),htmlFlow:a(M),htmlFlowData:k,htmlText:a(C),htmlTextData:k,image:a(U),label:$,labelText:L,lineEnding:B,link:a(O),listItem:a(),listOrdered:a(),listUnordered:a(),paragraph:a(),referenceString:X,resourceDestinationString:w,resourceTitleString:ee,resource:ne,setextHeading:a(N),setextHeadingLineSequence:P,setextHeadingText:E,strong:a(),thematicBreak:a()}};t0(t,(e||{}).mdastExtensions||[]);const r={};return n;function n(Y){let se={type:"root",children:[]};const ye={stack:[se],tokenStack:[],config:t,enter:l,exit:c,buffer:o,resume:d,data:r},K=[];let ae=-1;for(;++ae<Y.length;)if(Y[ae][1].type==="listOrdered"||Y[ae][1].type==="listUnordered")if(Y[ae][0]==="enter")K.push(ae);else{const xe=K.pop();ae=i(Y,xe,ae)}for(ae=-1;++ae<Y.length;){const xe=t[Y[ae][0]];e0.call(xe,Y[ae][1].type)&&xe[Y[ae][1].type].call(Object.assign({sliceSerialize:Y[ae][2].sliceSerialize},ye),Y[ae][1])}if(ye.tokenStack.length>0){const xe=ye.tokenStack[ye.tokenStack.length-1];(xe[1]||tg).call(ye,void 0,xe[0])}for(se.position={start:Ln(Y.length>0?Y[0][1].start:{line:1,column:1,offset:0}),end:Ln(Y.length>0?Y[Y.length-2][1].end:{line:1,column:1,offset:0})},ae=-1;++ae<t.transforms.length;)se=t.transforms[ae](se)||se;return se}function i(Y,se,ye){let K=se-1,ae=-1,xe=!1,Oe,Se,q,te;for(;++K<=ye;){const Z=Y[K];switch(Z[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{Z[0]==="enter"?ae++:ae--,te=void 0;break}case"lineEndingBlank":{Z[0]==="enter"&&(Oe&&!te&&!ae&&!q&&(q=K),te=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:te=void 0}if(!ae&&Z[0]==="enter"&&Z[1].type==="listItemPrefix"||ae===-1&&Z[0]==="exit"&&(Z[1].type==="listUnordered"||Z[1].type==="listOrdered")){if(Oe){let ve=K;for(Se=void 0;ve--;){const Re=Y[ve];if(Re[1].type==="lineEnding"||Re[1].type==="lineEndingBlank"){if(Re[0]==="exit")continue;Se&&(Y[Se][1].type="lineEndingBlank",xe=!0),Re[1].type="lineEnding",Se=ve}else if(!(Re[1].type==="linePrefix"||Re[1].type==="blockQuotePrefix"||Re[1].type==="blockQuotePrefixWhitespace"||Re[1].type==="blockQuoteMarker"||Re[1].type==="listItemIndent"))break}q&&(!Se||q<Se)&&(Oe._spread=!0),Oe.end=Object.assign({},Se?Y[Se][1].start:Z[1].end),Y.splice(Se||K,0,["exit",Oe,Z[2]]),K++,ye++}if(Z[1].type==="listItemPrefix"){const ve={type:"listItem",_spread:!1,start:Object.assign({},Z[1].start),end:void 0};Oe=ve,Y.splice(K,0,["enter",ve,Z[2]]),K++,ye++,q=void 0,te=!0}}}return Y[se][1]._spread=xe,ye}function s(Y,se){return ye;function ye(K){l.call(this,Y(K),K),se&&se.call(this,K)}}function o(){this.stack.push({type:"fragment",children:[]})}function l(Y,se,ye){this.stack[this.stack.length-1].children.push(Y),this.stack.push(Y),this.tokenStack.push([se,ye||void 0]),Y.position={start:Ln(se.start),end:void 0}}function a(Y){return se;function se(ye){Y&&Y.call(this,ye),c.call(this,ye)}}function c(Y,se){const ye=this.stack.pop(),K=this.tokenStack.pop();if(K)K[0].type!==Y.type&&(se?se.call(this,Y,K[0]):(K[1]||tg).call(this,Y,K[0]));else throw new Error("Cannot close `"+Y.type+"` ("+yo({start:Y.start,end:Y.end})+"): it’s not open");ye.position.end=Ln(Y.end)}function d(){return Kf(this.stack.pop())}function h(){this.data.expectingFirstListItemValue=!0}function f(Y){if(this.data.expectingFirstListItemValue){const se=this.stack[this.stack.length-2];se.start=Number.parseInt(this.sliceSerialize(Y),10),this.data.expectingFirstListItemValue=void 0}}function p(){const Y=this.resume(),se=this.stack[this.stack.length-1];se.lang=Y}function m(){const Y=this.resume(),se=this.stack[this.stack.length-1];se.meta=Y}function _(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function b(){const Y=this.resume(),se=this.stack[this.stack.length-1];se.value=Y.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function g(){const Y=this.resume(),se=this.stack[this.stack.length-1];se.value=Y.replace(/(\r?\n|\r)$/g,"")}function v(Y){const se=this.resume(),ye=this.stack[this.stack.length-1];ye.label=se,ye.identifier=qr(this.sliceSerialize(Y)).toLowerCase()}function y(){const Y=this.resume(),se=this.stack[this.stack.length-1];se.title=Y}function S(){const Y=this.resume(),se=this.stack[this.stack.length-1];se.url=Y}function R(Y){const se=this.stack[this.stack.length-1];if(!se.depth){const ye=this.sliceSerialize(Y).length;se.depth=ye}}function E(){this.data.setextHeadingSlurpLineEnding=!0}function P(Y){const se=this.stack[this.stack.length-1];se.depth=this.sliceSerialize(Y).codePointAt(0)===61?1:2}function N(){this.data.setextHeadingSlurpLineEnding=void 0}function D(Y){const ye=this.stack[this.stack.length-1].children;let K=ye[ye.length-1];(!K||K.type!=="text")&&(K=sr(),K.position={start:Ln(Y.start),end:void 0},ye.push(K)),this.stack.push(K)}function k(Y){const se=this.stack.pop();se.value+=this.sliceSerialize(Y),se.position.end=Ln(Y.end)}function B(Y){const se=this.stack[this.stack.length-1];if(this.data.atHardBreak){const ye=se.children[se.children.length-1];ye.position.end=Ln(Y.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(se.type)&&(D.call(this,Y),k.call(this,Y))}function j(){this.data.atHardBreak=!0}function M(){const Y=this.resume(),se=this.stack[this.stack.length-1];se.value=Y}function C(){const Y=this.resume(),se=this.stack[this.stack.length-1];se.value=Y}function A(){const Y=this.resume(),se=this.stack[this.stack.length-1];se.value=Y}function O(){const Y=this.stack[this.stack.length-1];if(this.data.inReference){const se=this.data.referenceType||"shortcut";Y.type+="Reference",Y.referenceType=se,delete Y.url,delete Y.title}else delete Y.identifier,delete Y.label;this.data.referenceType=void 0}function U(){const Y=this.stack[this.stack.length-1];if(this.data.inReference){const se=this.data.referenceType||"shortcut";Y.type+="Reference",Y.referenceType=se,delete Y.url,delete Y.title}else delete Y.identifier,delete Y.label;this.data.referenceType=void 0}function L(Y){const se=this.sliceSerialize(Y),ye=this.stack[this.stack.length-2];ye.label=HE(se),ye.identifier=qr(se).toLowerCase()}function $(){const Y=this.stack[this.stack.length-1],se=this.resume(),ye=this.stack[this.stack.length-1];if(this.data.inReference=!0,ye.type==="link"){const K=Y.children;ye.children=K}else ye.alt=se}function w(){const Y=this.resume(),se=this.stack[this.stack.length-1];se.url=Y}function ee(){const Y=this.resume(),se=this.stack[this.stack.length-1];se.title=Y}function ne(){this.data.inReference=void 0}function T(){this.data.referenceType="collapsed"}function X(Y){const se=this.resume(),ye=this.stack[this.stack.length-1];ye.label=se,ye.identifier=qr(this.sliceSerialize(Y)).toLowerCase(),this.data.referenceType="full"}function I(Y){this.data.characterReferenceType=Y.type}function F(Y){const se=this.sliceSerialize(Y),ye=this.data.characterReferenceType;let K;ye?(K=Uy(se,ye==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):K=Vf(se);const ae=this.stack[this.stack.length-1];ae.value+=K}function G(Y){const se=this.stack.pop();se.position.end=Ln(Y.end)}function he(Y){k.call(this,Y);const se=this.stack[this.stack.length-1];se.url=this.sliceSerialize(Y)}function me(Y){k.call(this,Y);const se=this.stack[this.stack.length-1];se.url="mailto:"+this.sliceSerialize(Y)}function je(){return{type:"blockquote",children:[]}}function Pe(){return{type:"code",lang:null,meta:null,value:""}}function Ce(){return{type:"inlineCode",value:""}}function de(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function Te(){return{type:"emphasis",children:[]}}function J(){return{type:"heading",depth:0,children:[]}}function fe(){return{type:"break"}}function ke(){return{type:"html",value:""}}function Me(){return{type:"image",title:null,url:"",alt:null}}function we(){return{type:"link",title:null,url:"",children:[]}}function Ke(Y){return{type:"list",ordered:Y.type==="listOrdered",start:null,spread:Y._spread,children:[]}}function nr(Y){return{type:"listItem",spread:Y._spread,checked:null,children:[]}}function Qe(){return{type:"paragraph",children:[]}}function ir(){return{type:"strong",children:[]}}function sr(){return{type:"text",value:""}}function $t(){return{type:"thematicBreak"}}}function Ln(e){return{line:e.line,column:e.column,offset:e.offset}}function t0(e,t){let r=-1;for(;++r<t.length;){const n=t[r];Array.isArray(n)?t0(e,n):qE(e,n)}}function qE(e,t){let r;for(r in t)if(e0.call(t,r))switch(r){case"canContainEols":{const n=t[r];n&&e[r].push(...n);break}case"transforms":{const n=t[r];n&&e[r].push(...n);break}case"enter":case"exit":{const n=t[r];n&&Object.assign(e[r],n);break}}}function tg(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+yo({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+yo({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+yo({start:t.start,end:t.end})+") is still open")}function YE(e){const t=this;t.parser=r;function r(n){return KE(n,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function XE(e,t){const r={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,r),e.applyData(t,r)}function GE(e,t){const r={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,r),[e.applyData(t,r),{type:"text",value:`
|
|
71
71
|
`}]}function QE(e,t){const r=t.value?t.value+`
|
|
72
72
|
`:"",n={},i=t.lang?t.lang.split(/\s+/):[];i.length>0&&(n.className=["language-"+i[0]]);let s={type:"element",tagName:"code",properties:n,children:[{type:"text",value:r}]};return t.meta&&(s.data={meta:t.meta}),e.patch(t,s),s=e.applyData(t,s),s={type:"element",tagName:"pre",properties:{},children:[s]},e.patch(t,s),s}function JE(e,t){const r={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function ZE(e,t){const r={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function e5(e,t){const r=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=String(t.identifier).toUpperCase(),i=js(n.toLowerCase()),s=e.footnoteOrder.indexOf(n);let o,l=e.footnoteCounts.get(n);l===void 0?(l=0,e.footnoteOrder.push(n),o=e.footnoteOrder.length):o=s+1,l+=1,e.footnoteCounts.set(n,l);const a={type:"element",tagName:"a",properties:{href:"#"+r+"fn-"+i,id:r+"fnref-"+i+(l>1?"-"+l:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(o)}]};e.patch(t,a);const c={type:"element",tagName:"sup",properties:{},children:[a]};return e.patch(t,c),e.applyData(t,c)}function t5(e,t){const r={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function r5(e,t){if(e.options.allowDangerousHtml){const r={type:"raw",value:t.value};return e.patch(t,r),e.applyData(t,r)}}function r0(e,t){const r=t.referenceType;let n="]";if(r==="collapsed"?n+="[]":r==="full"&&(n+="["+(t.label||t.identifier)+"]"),t.type==="imageReference")return[{type:"text",value:"!["+t.alt+n}];const i=e.all(t),s=i[0];s&&s.type==="text"?s.value="["+s.value:i.unshift({type:"text",value:"["});const o=i[i.length-1];return o&&o.type==="text"?o.value+=n:i.push({type:"text",value:n}),i}function n5(e,t){const r=String(t.identifier).toUpperCase(),n=e.definitionById.get(r);if(!n)return r0(e,t);const i={src:js(n.url||""),alt:t.alt};n.title!==null&&n.title!==void 0&&(i.title=n.title);const s={type:"element",tagName:"img",properties:i,children:[]};return e.patch(t,s),e.applyData(t,s)}function i5(e,t){const r={src:js(t.url)};t.alt!==null&&t.alt!==void 0&&(r.alt=t.alt),t.title!==null&&t.title!==void 0&&(r.title=t.title);const n={type:"element",tagName:"img",properties:r,children:[]};return e.patch(t,n),e.applyData(t,n)}function s5(e,t){const r={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,r);const n={type:"element",tagName:"code",properties:{},children:[r]};return e.patch(t,n),e.applyData(t,n)}function o5(e,t){const r=String(t.identifier).toUpperCase(),n=e.definitionById.get(r);if(!n)return r0(e,t);const i={href:js(n.url||"")};n.title!==null&&n.title!==void 0&&(i.title=n.title);const s={type:"element",tagName:"a",properties:i,children:e.all(t)};return e.patch(t,s),e.applyData(t,s)}function l5(e,t){const r={href:js(t.url)};t.title!==null&&t.title!==void 0&&(r.title=t.title);const n={type:"element",tagName:"a",properties:r,children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function a5(e,t,r){const n=e.all(t),i=r?c5(r):n0(t),s={},o=[];if(typeof t.checked=="boolean"){const d=n[0];let h;d&&d.type==="element"&&d.tagName==="p"?h=d:(h={type:"element",tagName:"p",properties:{},children:[]},n.unshift(h)),h.children.length>0&&h.children.unshift({type:"text",value:" "}),h.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),s.className=["task-list-item"]}let l=-1;for(;++l<n.length;){const d=n[l];(i||l!==0||d.type!=="element"||d.tagName!=="p")&&o.push({type:"text",value:`
|
|
73
73
|
`}),d.type==="element"&&d.tagName==="p"&&!i?o.push(...d.children):o.push(d)}const a=n[n.length-1];a&&(i||a.type!=="element"||a.tagName!=="p")&&o.push({type:"text",value:`
|
|
@@ -119,15 +119,15 @@ WARNING: This link could potentially be dangerous`)){let r=window.open();if(r){t
|
|
|
119
119
|
|
|
120
120
|
`+e.stack):new Error(e.message+`
|
|
121
121
|
|
|
122
|
-
`+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)}},o3=new s3;function aa(e){l3(e)||o3.onUnexpectedError(e)}var ed="Canceled";function l3(e){return e instanceof a3?!0:e instanceof Error&&e.name===ed&&e.message===ed}var a3=class extends Error{constructor(){super(ed),this.name=this.message}};function c3(e){return new Error(`Illegal argument: ${e}`)}var Ag=class td extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof td)return t;let r=new td;return r.message=t.message,r.stack=t.stack,r}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},rd=class J0 extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,J0.prototype)}};function pr(e,t=0){return e[e.length-(1+t)]}var u3;(e=>{function t(s){return s<0}e.isLessThan=t;function r(s){return s<=0}e.isLessThanOrEqual=r;function n(s){return s>0}e.isGreaterThan=n;function i(s){return s===0}e.isNeitherLessOrGreaterThan=i,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(u3||(u3={}));function h3(e,t){let r=this,n=!1,i;return function(){return n||(n=!0,t||(i=e.apply(r,arguments))),i}}var Z0;(e=>{function t(S){return S&&typeof S=="object"&&typeof S[Symbol.iterator]=="function"}e.is=t;let r=Object.freeze([]);function n(){return r}e.empty=n;function*i(S){yield S}e.single=i;function s(S){return t(S)?S:i(S)}e.wrap=s;function o(S){return S||r}e.from=o;function*l(S){for(let R=S.length-1;R>=0;R--)yield S[R]}e.reverse=l;function a(S){return!S||S[Symbol.iterator]().next().done===!0}e.isEmpty=a;function c(S){return S[Symbol.iterator]().next().value}e.first=c;function d(S,R){let E=0;for(let P of S)if(R(P,E++))return!0;return!1}e.some=d;function h(S,R){for(let E of S)if(R(E))return E}e.find=h;function*f(S,R){for(let E of S)R(E)&&(yield E)}e.filter=f;function*p(S,R){let E=0;for(let P of S)yield R(P,E++)}e.map=p;function*m(S,R){let E=0;for(let P of S)yield*R(P,E++)}e.flatMap=m;function*_(...S){for(let R of S)yield*R}e.concat=_;function b(S,R,E){let P=E;for(let N of S)P=R(P,N);return P}e.reduce=b;function*g(S,R,E=S.length){for(R<0&&(R+=S.length),E<0?E+=S.length:E>S.length&&(E=S.length);R<E;R++)yield S[R]}e.slice=g;function v(S,R=Number.POSITIVE_INFINITY){let E=[];if(R===0)return[E,S];let P=S[Symbol.iterator]();for(let N=0;N<R;N++){let D=P.next();if(D.done)return[E,e.empty()];E.push(D.value)}return[E,{[Symbol.iterator](){return P}}]}e.consume=v;async function y(S){let R=[];for await(let E of S)R.push(E);return Promise.resolve(R)}e.asyncToArray=y})(Z0||(Z0={}));function $i(e){if(Z0.is(e)){let t=[];for(let r of e)if(r)try{r.dispose()}catch(n){t.push(n)}if(t.length===1)throw t[0];if(t.length>1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function d3(...e){return rt(()=>$i(e))}function rt(e){return{dispose:h3(()=>{e()})}}var e1=class t1{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{$i(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?t1.DISABLE_DISPOSED_WARNING||console.warn(new Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(t),t}delete(t){if(t){if(t===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(t),t.dispose()}}deleteAndLeak(t){t&&this._toDispose.has(t)&&(this._toDispose.delete(t),void 0)}};e1.DISABLE_DISPOSED_WARNING=!1;var ri=e1,Be=class{constructor(){this._store=new ri,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)}};Be.None=Object.freeze({dispose(){}});var Ts=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}},xn=typeof window=="object"?window:globalThis,nd=class id{constructor(t){this.element=t,this.next=id.Undefined,this.prev=id.Undefined}};nd.Undefined=new nd(void 0);var nt=nd,Bg=class{constructor(){this._first=nt.Undefined,this._last=nt.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===nt.Undefined}clear(){let e=this._first;for(;e!==nt.Undefined;){let t=e.next;e.prev=nt.Undefined,e.next=nt.Undefined,e=t}this._first=nt.Undefined,this._last=nt.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new nt(e);if(this._first===nt.Undefined)this._first=r,this._last=r;else if(t){let i=this._last;this._last=r,r.prev=i,i.next=r}else{let i=this._first;this._first=r,r.next=i,i.prev=r}this._size+=1;let n=!1;return()=>{n||(n=!0,this._remove(r))}}shift(){if(this._first!==nt.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==nt.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==nt.Undefined&&e.next!==nt.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===nt.Undefined&&e.next===nt.Undefined?(this._first=nt.Undefined,this._last=nt.Undefined):e.next===nt.Undefined?(this._last=this._last.prev,this._last.next=nt.Undefined):e.prev===nt.Undefined&&(this._first=this._first.next,this._first.prev=nt.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==nt.Undefined;)yield e.element,e=e.next}},f3=globalThis.performance&&typeof globalThis.performance.now=="function",p3=class r1{static create(t){return new r1(t)}constructor(t){this._now=f3&&t===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime!==-1?this._stopTime-this._startTime:this._now()-this._startTime}},Bt;(e=>{e.None=()=>Be.None;function t(j,M){return h(j,()=>{},0,void 0,!0,void 0,M)}e.defer=t;function r(j){return(M,C=null,A)=>{let O=!1,U;return U=j(L=>{if(!O)return U?U.dispose():O=!0,M.call(C,L)},null,A),O&&U.dispose(),U}}e.once=r;function n(j,M,C){return c((A,O=null,U)=>j(L=>A.call(O,M(L)),null,U),C)}e.map=n;function i(j,M,C){return c((A,O=null,U)=>j(L=>{M(L),A.call(O,L)},null,U),C)}e.forEach=i;function s(j,M,C){return c((A,O=null,U)=>j(L=>M(L)&&A.call(O,L),null,U),C)}e.filter=s;function o(j){return j}e.signal=o;function l(...j){return(M,C=null,A)=>{let O=d3(...j.map(U=>U(L=>M.call(C,L))));return d(O,A)}}e.any=l;function a(j,M,C,A){let O=C;return n(j,U=>(O=M(O,U),O),A)}e.reduce=a;function c(j,M){let C,A={onWillAddFirstListener(){C=j(O.fire,O)},onDidRemoveLastListener(){C==null||C.dispose()}},O=new ae(A);return M==null||M.add(O),O.event}function d(j,M){return M instanceof Array?M.push(j):M&&M.add(j),j}function h(j,M,C=100,A=!1,O=!1,U,L){let $,w,ee,ne=0,T,X={leakWarningThreshold:U,onWillAddFirstListener(){$=j(F=>{ne++,w=M(w,F),A&&!ee&&(I.fire(w),w=void 0),T=()=>{let G=w;w=void 0,ee=void 0,(!A||ne>1)&&I.fire(G),ne=0},typeof C=="number"?(clearTimeout(ee),ee=setTimeout(T,C)):ee===void 0&&(ee=0,queueMicrotask(T))})},onWillRemoveListener(){O&&ne>0&&(T==null||T())},onDidRemoveLastListener(){T=void 0,$.dispose()}},I=new ae(X);return L==null||L.add(I),I.event}e.debounce=h;function f(j,M=0,C){return e.debounce(j,(A,O)=>A?(A.push(O),A):[O],M,void 0,!0,void 0,C)}e.accumulate=f;function p(j,M=(A,O)=>A===O,C){let A=!0,O;return s(j,U=>{let L=A||!M(U,O);return A=!1,O=U,L},C)}e.latch=p;function m(j,M,C){return[e.filter(j,M,C),e.filter(j,A=>!M(A),C)]}e.split=m;function _(j,M=!1,C=[],A){let O=C.slice(),U=j(w=>{O?O.push(w):$.fire(w)});A&&A.add(U);let L=()=>{O==null||O.forEach(w=>$.fire(w)),O=null},$=new ae({onWillAddFirstListener(){U||(U=j(w=>$.fire(w)),A&&A.add(U))},onDidAddFirstListener(){O&&(M?setTimeout(L):L())},onDidRemoveLastListener(){U&&U.dispose(),U=null}});return A&&A.add($),$.event}e.buffer=_;function b(j,M){return(C,A,O)=>{let U=M(new v);return j(function(L){let $=U.evaluate(L);$!==g&&C.call(A,$)},void 0,O)}}e.chain=b;let g=Symbol("HaltChainable");class v{constructor(){this.steps=[]}map(M){return this.steps.push(M),this}forEach(M){return this.steps.push(C=>(M(C),C)),this}filter(M){return this.steps.push(C=>M(C)?C:g),this}reduce(M,C){let A=C;return this.steps.push(O=>(A=M(A,O),A)),this}latch(M=(C,A)=>C===A){let C=!0,A;return this.steps.push(O=>{let U=C||!M(O,A);return C=!1,A=O,U?O:g}),this}evaluate(M){for(let C of this.steps)if(M=C(M),M===g)break;return M}}function y(j,M,C=A=>A){let A=(...$)=>L.fire(C(...$)),O=()=>j.on(M,A),U=()=>j.removeListener(M,A),L=new ae({onWillAddFirstListener:O,onDidRemoveLastListener:U});return L.event}e.fromNodeEventEmitter=y;function S(j,M,C=A=>A){let A=(...$)=>L.fire(C(...$)),O=()=>j.addEventListener(M,A),U=()=>j.removeEventListener(M,A),L=new ae({onWillAddFirstListener:O,onDidRemoveLastListener:U});return L.event}e.fromDOMEventEmitter=S;function R(j){return new Promise(M=>r(j)(M))}e.toPromise=R;function E(j){let M=new ae;return j.then(C=>{M.fire(C)},()=>{M.fire(void 0)}).finally(()=>{M.dispose()}),M.event}e.fromPromise=E;function P(j,M){return j(C=>M.fire(C))}e.forward=P;function N(j,M,C){return M(C),j(A=>M(A))}e.runAndSubscribe=N;class D{constructor(M,C){this._observable=M,this._counter=0,this._hasChanged=!1;let A={onWillAddFirstListener:()=>{M.addObserver(this)},onDidRemoveLastListener:()=>{M.removeObserver(this)}};this.emitter=new ae(A),C&&C.add(this.emitter)}beginUpdate(M){this._counter++}handlePossibleChange(M){}handleChange(M,C){this._hasChanged=!0}endUpdate(M){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function k(j,M){return new D(j,M).emitter.event}e.fromObservable=k;function B(j){return(M,C,A)=>{let O=0,U=!1,L={beginUpdate(){O++},endUpdate(){O--,O===0&&(j.reportChanges(),U&&(U=!1,M.call(C)))},handlePossibleChange(){},handleChange(){U=!0}};j.addObserver(L),j.reportChanges();let $={dispose(){j.removeObserver(L)}};return A instanceof ri?A.add($):Array.isArray(A)&&A.push($),$}}e.fromObservableLight=B})(Bt||(Bt={}));var sd=class od{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${od._idPool++}`,od.all.add(this)}start(t){this._stopWatch=new p3,this.listenerCount=t}stop(){if(this._stopWatch){let t=this._stopWatch.elapsed();this.durations.push(t),this.elapsedOverall+=t,this.invocationCount+=1,this._stopWatch=void 0}}};sd.all=new Set,sd._idPool=0;var m3=sd,g3=-1,n1=class i1{constructor(t,r,n=(i1._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=r,this.name=n,this._warnCountdown=0}dispose(){var t;(t=this._stacks)==null||t.clear()}check(t,r){let n=this.threshold;if(n<=0||r<n)return;this._stacks||(this._stacks=new Map);let i=this._stacks.get(t.value)||0;if(this._stacks.set(t.value,i+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=n*.5;let[s,o]=this.getMostFrequentStack(),l=`[${this.name}] potential listener LEAK detected, having ${r} listeners already. MOST frequent listener (${o}):`;console.warn(l),console.warn(s);let a=new x3(l,s);this._errorHandler(a)}return()=>{let s=this._stacks.get(t.value)||0;this._stacks.set(t.value,s-1)}}getMostFrequentStack(){if(!this._stacks)return;let t,r=0;for(let[n,i]of this._stacks)(!t||r<i)&&(t=[n,i],r=i);return t}};n1._idPool=1;var _3=n1,v3=class s1{constructor(t){this.value=t}static create(){let t=new Error;return new s1(t.stack??"")}print(){console.warn(this.value.split(`
|
|
122
|
+
`+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)}},o3=new s3;function aa(e){l3(e)||o3.onUnexpectedError(e)}var ed="Canceled";function l3(e){return e instanceof a3?!0:e instanceof Error&&e.name===ed&&e.message===ed}var a3=class extends Error{constructor(){super(ed),this.name=this.message}};function c3(e){return new Error(`Illegal argument: ${e}`)}var Ag=class td extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof td)return t;let r=new td;return r.message=t.message,r.stack=t.stack,r}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},rd=class J0 extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,J0.prototype)}};function pr(e,t=0){return e[e.length-(1+t)]}var u3;(e=>{function t(s){return s<0}e.isLessThan=t;function r(s){return s<=0}e.isLessThanOrEqual=r;function n(s){return s>0}e.isGreaterThan=n;function i(s){return s===0}e.isNeitherLessOrGreaterThan=i,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(u3||(u3={}));function h3(e,t){let r=this,n=!1,i;return function(){return n||(n=!0,t||(i=e.apply(r,arguments))),i}}var Z0;(e=>{function t(S){return S&&typeof S=="object"&&typeof S[Symbol.iterator]=="function"}e.is=t;let r=Object.freeze([]);function n(){return r}e.empty=n;function*i(S){yield S}e.single=i;function s(S){return t(S)?S:i(S)}e.wrap=s;function o(S){return S||r}e.from=o;function*l(S){for(let R=S.length-1;R>=0;R--)yield S[R]}e.reverse=l;function a(S){return!S||S[Symbol.iterator]().next().done===!0}e.isEmpty=a;function c(S){return S[Symbol.iterator]().next().value}e.first=c;function d(S,R){let E=0;for(let P of S)if(R(P,E++))return!0;return!1}e.some=d;function h(S,R){for(let E of S)if(R(E))return E}e.find=h;function*f(S,R){for(let E of S)R(E)&&(yield E)}e.filter=f;function*p(S,R){let E=0;for(let P of S)yield R(P,E++)}e.map=p;function*m(S,R){let E=0;for(let P of S)yield*R(P,E++)}e.flatMap=m;function*_(...S){for(let R of S)yield*R}e.concat=_;function b(S,R,E){let P=E;for(let N of S)P=R(P,N);return P}e.reduce=b;function*g(S,R,E=S.length){for(R<0&&(R+=S.length),E<0?E+=S.length:E>S.length&&(E=S.length);R<E;R++)yield S[R]}e.slice=g;function v(S,R=Number.POSITIVE_INFINITY){let E=[];if(R===0)return[E,S];let P=S[Symbol.iterator]();for(let N=0;N<R;N++){let D=P.next();if(D.done)return[E,e.empty()];E.push(D.value)}return[E,{[Symbol.iterator](){return P}}]}e.consume=v;async function y(S){let R=[];for await(let E of S)R.push(E);return Promise.resolve(R)}e.asyncToArray=y})(Z0||(Z0={}));function $i(e){if(Z0.is(e)){let t=[];for(let r of e)if(r)try{r.dispose()}catch(n){t.push(n)}if(t.length===1)throw t[0];if(t.length>1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function d3(...e){return rt(()=>$i(e))}function rt(e){return{dispose:h3(()=>{e()})}}var e1=class t1{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{$i(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?t1.DISABLE_DISPOSED_WARNING||console.warn(new Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(t),t}delete(t){if(t){if(t===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(t),t.dispose()}}deleteAndLeak(t){t&&this._toDispose.has(t)&&(this._toDispose.delete(t),void 0)}};e1.DISABLE_DISPOSED_WARNING=!1;var ri=e1,Be=class{constructor(){this._store=new ri,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)}};Be.None=Object.freeze({dispose(){}});var Ts=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}},xn=typeof window=="object"?window:globalThis,nd=class id{constructor(t){this.element=t,this.next=id.Undefined,this.prev=id.Undefined}};nd.Undefined=new nd(void 0);var nt=nd,Bg=class{constructor(){this._first=nt.Undefined,this._last=nt.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===nt.Undefined}clear(){let e=this._first;for(;e!==nt.Undefined;){let t=e.next;e.prev=nt.Undefined,e.next=nt.Undefined,e=t}this._first=nt.Undefined,this._last=nt.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new nt(e);if(this._first===nt.Undefined)this._first=r,this._last=r;else if(t){let i=this._last;this._last=r,r.prev=i,i.next=r}else{let i=this._first;this._first=r,r.next=i,i.prev=r}this._size+=1;let n=!1;return()=>{n||(n=!0,this._remove(r))}}shift(){if(this._first!==nt.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==nt.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==nt.Undefined&&e.next!==nt.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===nt.Undefined&&e.next===nt.Undefined?(this._first=nt.Undefined,this._last=nt.Undefined):e.next===nt.Undefined?(this._last=this._last.prev,this._last.next=nt.Undefined):e.prev===nt.Undefined&&(this._first=this._first.next,this._first.prev=nt.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==nt.Undefined;)yield e.element,e=e.next}},f3=globalThis.performance&&typeof globalThis.performance.now=="function",p3=class r1{static create(t){return new r1(t)}constructor(t){this._now=f3&&t===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime!==-1?this._stopTime-this._startTime:this._now()-this._startTime}},Bt;(e=>{e.None=()=>Be.None;function t(j,M){return h(j,()=>{},0,void 0,!0,void 0,M)}e.defer=t;function r(j){return(M,C=null,A)=>{let O=!1,U;return U=j(L=>{if(!O)return U?U.dispose():O=!0,M.call(C,L)},null,A),O&&U.dispose(),U}}e.once=r;function n(j,M,C){return c((A,O=null,U)=>j(L=>A.call(O,M(L)),null,U),C)}e.map=n;function i(j,M,C){return c((A,O=null,U)=>j(L=>{M(L),A.call(O,L)},null,U),C)}e.forEach=i;function s(j,M,C){return c((A,O=null,U)=>j(L=>M(L)&&A.call(O,L),null,U),C)}e.filter=s;function o(j){return j}e.signal=o;function l(...j){return(M,C=null,A)=>{let O=d3(...j.map(U=>U(L=>M.call(C,L))));return d(O,A)}}e.any=l;function a(j,M,C,A){let O=C;return n(j,U=>(O=M(O,U),O),A)}e.reduce=a;function c(j,M){let C,A={onWillAddFirstListener(){C=j(O.fire,O)},onDidRemoveLastListener(){C==null||C.dispose()}},O=new le(A);return M==null||M.add(O),O.event}function d(j,M){return M instanceof Array?M.push(j):M&&M.add(j),j}function h(j,M,C=100,A=!1,O=!1,U,L){let $,w,ee,ne=0,T,X={leakWarningThreshold:U,onWillAddFirstListener(){$=j(F=>{ne++,w=M(w,F),A&&!ee&&(I.fire(w),w=void 0),T=()=>{let G=w;w=void 0,ee=void 0,(!A||ne>1)&&I.fire(G),ne=0},typeof C=="number"?(clearTimeout(ee),ee=setTimeout(T,C)):ee===void 0&&(ee=0,queueMicrotask(T))})},onWillRemoveListener(){O&&ne>0&&(T==null||T())},onDidRemoveLastListener(){T=void 0,$.dispose()}},I=new le(X);return L==null||L.add(I),I.event}e.debounce=h;function f(j,M=0,C){return e.debounce(j,(A,O)=>A?(A.push(O),A):[O],M,void 0,!0,void 0,C)}e.accumulate=f;function p(j,M=(A,O)=>A===O,C){let A=!0,O;return s(j,U=>{let L=A||!M(U,O);return A=!1,O=U,L},C)}e.latch=p;function m(j,M,C){return[e.filter(j,M,C),e.filter(j,A=>!M(A),C)]}e.split=m;function _(j,M=!1,C=[],A){let O=C.slice(),U=j(w=>{O?O.push(w):$.fire(w)});A&&A.add(U);let L=()=>{O==null||O.forEach(w=>$.fire(w)),O=null},$=new le({onWillAddFirstListener(){U||(U=j(w=>$.fire(w)),A&&A.add(U))},onDidAddFirstListener(){O&&(M?setTimeout(L):L())},onDidRemoveLastListener(){U&&U.dispose(),U=null}});return A&&A.add($),$.event}e.buffer=_;function b(j,M){return(C,A,O)=>{let U=M(new v);return j(function(L){let $=U.evaluate(L);$!==g&&C.call(A,$)},void 0,O)}}e.chain=b;let g=Symbol("HaltChainable");class v{constructor(){this.steps=[]}map(M){return this.steps.push(M),this}forEach(M){return this.steps.push(C=>(M(C),C)),this}filter(M){return this.steps.push(C=>M(C)?C:g),this}reduce(M,C){let A=C;return this.steps.push(O=>(A=M(A,O),A)),this}latch(M=(C,A)=>C===A){let C=!0,A;return this.steps.push(O=>{let U=C||!M(O,A);return C=!1,A=O,U?O:g}),this}evaluate(M){for(let C of this.steps)if(M=C(M),M===g)break;return M}}function y(j,M,C=A=>A){let A=(...$)=>L.fire(C(...$)),O=()=>j.on(M,A),U=()=>j.removeListener(M,A),L=new le({onWillAddFirstListener:O,onDidRemoveLastListener:U});return L.event}e.fromNodeEventEmitter=y;function S(j,M,C=A=>A){let A=(...$)=>L.fire(C(...$)),O=()=>j.addEventListener(M,A),U=()=>j.removeEventListener(M,A),L=new le({onWillAddFirstListener:O,onDidRemoveLastListener:U});return L.event}e.fromDOMEventEmitter=S;function R(j){return new Promise(M=>r(j)(M))}e.toPromise=R;function E(j){let M=new le;return j.then(C=>{M.fire(C)},()=>{M.fire(void 0)}).finally(()=>{M.dispose()}),M.event}e.fromPromise=E;function P(j,M){return j(C=>M.fire(C))}e.forward=P;function N(j,M,C){return M(C),j(A=>M(A))}e.runAndSubscribe=N;class D{constructor(M,C){this._observable=M,this._counter=0,this._hasChanged=!1;let A={onWillAddFirstListener:()=>{M.addObserver(this)},onDidRemoveLastListener:()=>{M.removeObserver(this)}};this.emitter=new le(A),C&&C.add(this.emitter)}beginUpdate(M){this._counter++}handlePossibleChange(M){}handleChange(M,C){this._hasChanged=!0}endUpdate(M){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function k(j,M){return new D(j,M).emitter.event}e.fromObservable=k;function B(j){return(M,C,A)=>{let O=0,U=!1,L={beginUpdate(){O++},endUpdate(){O--,O===0&&(j.reportChanges(),U&&(U=!1,M.call(C)))},handlePossibleChange(){},handleChange(){U=!0}};j.addObserver(L),j.reportChanges();let $={dispose(){j.removeObserver(L)}};return A instanceof ri?A.add($):Array.isArray(A)&&A.push($),$}}e.fromObservableLight=B})(Bt||(Bt={}));var sd=class od{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${od._idPool++}`,od.all.add(this)}start(t){this._stopWatch=new p3,this.listenerCount=t}stop(){if(this._stopWatch){let t=this._stopWatch.elapsed();this.durations.push(t),this.elapsedOverall+=t,this.invocationCount+=1,this._stopWatch=void 0}}};sd.all=new Set,sd._idPool=0;var m3=sd,g3=-1,n1=class i1{constructor(t,r,n=(i1._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=r,this.name=n,this._warnCountdown=0}dispose(){var t;(t=this._stacks)==null||t.clear()}check(t,r){let n=this.threshold;if(n<=0||r<n)return;this._stacks||(this._stacks=new Map);let i=this._stacks.get(t.value)||0;if(this._stacks.set(t.value,i+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=n*.5;let[s,o]=this.getMostFrequentStack(),l=`[${this.name}] potential listener LEAK detected, having ${r} listeners already. MOST frequent listener (${o}):`;console.warn(l),console.warn(s);let a=new x3(l,s);this._errorHandler(a)}return()=>{let s=this._stacks.get(t.value)||0;this._stacks.set(t.value,s-1)}}getMostFrequentStack(){if(!this._stacks)return;let t,r=0;for(let[n,i]of this._stacks)(!t||r<i)&&(t=[n,i],r=i);return t}};n1._idPool=1;var _3=n1,v3=class s1{constructor(t){this.value=t}static create(){let t=new Error;return new s1(t.stack??"")}print(){console.warn(this.value.split(`
|
|
123
123
|
`).slice(2).join(`
|
|
124
|
-
`))}},x3=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},y3=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},b3=0,Su=class{constructor(e){this.value=e,this.id=b3++}},w3=2,S3,ae=class{constructor(t){var r,n,i,s;this._size=0,this._options=t,this._leakageMon=(r=this._options)!=null&&r.leakWarningThreshold?new _3((t==null?void 0:t.onListenerError)??aa,((n=this._options)==null?void 0:n.leakWarningThreshold)??g3):void 0,this._perfMon=(i=this._options)!=null&&i._profName?new m3(this._options._profName):void 0,this._deliveryQueue=(s=this._options)==null?void 0:s.deliveryQueue}dispose(){var t,r,n,i;this._disposed||(this._disposed=!0,((t=this._deliveryQueue)==null?void 0:t.current)===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),(n=(r=this._options)==null?void 0:r.onDidRemoveLastListener)==null||n.call(r),(i=this._leakageMon)==null||i.dispose())}get event(){return this._event??(this._event=(t,r,n)=>{var l,a,c,d,h;if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let f=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(f);let p=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],m=new y3(`${f}. HINT: Stack shows most frequent listener (${p[1]}-times)`,p[0]);return(((l=this._options)==null?void 0:l.onListenerError)||aa)(m),Be.None}if(this._disposed)return Be.None;r&&(t=t.bind(r));let i=new Su(t),s;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(i.stack=v3.create(),s=this._leakageMon.check(i.stack,this._size+1)),this._listeners?this._listeners instanceof Su?(this._deliveryQueue??(this._deliveryQueue=new k3),this._listeners=[this._listeners,i]):this._listeners.push(i):((c=(a=this._options)==null?void 0:a.onWillAddFirstListener)==null||c.call(a,this),this._listeners=i,(h=(d=this._options)==null?void 0:d.onDidAddFirstListener)==null||h.call(d,this)),this._size++;let o=rt(()=>{s==null||s(),this._removeListener(i)});return n instanceof ri?n.add(o):Array.isArray(n)&&n.push(o),o}),this._event}_removeListener(t){var s,o,l,a;if((o=(s=this._options)==null?void 0:s.onWillRemoveListener)==null||o.call(s,this),!this._listeners)return;if(this._size===1){this._listeners=void 0,(a=(l=this._options)==null?void 0:l.onDidRemoveLastListener)==null||a.call(l,this),this._size=0;return}let r=this._listeners,n=r.indexOf(t);if(n===-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--,r[n]=void 0;let i=this._deliveryQueue.current===this;if(this._size*w3<=r.length){let c=0;for(let d=0;d<r.length;d++)r[d]?r[c++]=r[d]:i&&(this._deliveryQueue.end--,c<this._deliveryQueue.i&&this._deliveryQueue.i--);r.length=c}}_deliver(t,r){var i;if(!t)return;let n=((i=this._options)==null?void 0:i.onListenerError)||aa;if(!n){t.value(r);return}try{t.value(r)}catch(s){n(s)}}_deliverQueue(t){let r=t.current._listeners;for(;t.i<t.end;)this._deliver(r[t.i++],t.value);t.reset()}fire(t){var r,n,i,s;if((r=this._deliveryQueue)!=null&&r.current&&(this._deliverQueue(this._deliveryQueue),(n=this._perfMon)==null||n.stop()),(i=this._perfMon)==null||i.start(this._size),this._listeners)if(this._listeners instanceof Su)this._deliver(this._listeners,t);else{let o=this._deliveryQueue;o.enqueue(this,t,this._listeners.length),this._deliverQueue(o)}(s=this._perfMon)==null||s.stop()}hasListeners(){return this._size>0}},k3=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,r){this.i=0,this.end=r,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},ld=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new ae,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new ae,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(t){return this.mapWindowIdToZoomLevel.get(this.getWindowId(t))??0}setZoomLevel(t,r){if(this.getZoomLevel(r)===t)return;let n=this.getWindowId(r);this.mapWindowIdToZoomLevel.set(n,t),this._onDidChangeZoomLevel.fire(n)}getZoomFactor(t){return this.mapWindowIdToZoomFactor.get(this.getWindowId(t))??1}setZoomFactor(t,r){this.mapWindowIdToZoomFactor.set(this.getWindowId(r),t)}setFullscreen(t,r){if(this.isFullscreen(r)===t)return;let n=this.getWindowId(r);this.mapWindowIdToFullScreen.set(n,t),this._onDidChangeFullscreen.fire(n)}isFullscreen(t){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(t))}getWindowId(t){return t.vscodeWindowId}};ld.INSTANCE=new ld;var ip=ld;function C3(e,t,r){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",r)}ip.INSTANCE.onDidChangeZoomLevel;function E3(e){return ip.INSTANCE.getZoomFactor(e)}ip.INSTANCE.onDidChangeFullscreen;var As=typeof navigator=="object"?navigator.userAgent:"",ad=As.indexOf("Firefox")>=0,N3=As.indexOf("AppleWebKit")>=0,sp=As.indexOf("Chrome")>=0,T3=!sp&&As.indexOf("Safari")>=0;As.indexOf("Electron/")>=0;As.indexOf("Android")>=0;var ku=!1;if(typeof xn.matchMedia=="function"){let e=xn.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=xn.matchMedia("(display-mode: fullscreen)");ku=e.matches,C3(xn,e,({matches:r})=>{ku&&t.matches||(ku=r)})}var ds="en",cd=!1,ud=!1,ca=!1,o1=!1,Bl,ua=ds,Og=ds,P3,$r,Li=globalThis,At,Y_;typeof Li.vscode<"u"&&typeof Li.vscode.process<"u"?At=Li.vscode.process:typeof process<"u"&&typeof((Y_=process==null?void 0:process.versions)==null?void 0:Y_.node)=="string"&&(At=process);var X_,R3=typeof((X_=At==null?void 0:At.versions)==null?void 0:X_.electron)=="string",M3=R3&&(At==null?void 0:At.type)==="renderer",G_;if(typeof At=="object"){cd=At.platform==="win32",ud=At.platform==="darwin",ca=At.platform==="linux",ca&&At.env.SNAP&&At.env.SNAP_REVISION,At.env.CI||At.env.BUILD_ARTIFACTSTAGINGDIRECTORY,Bl=ds,ua=ds;let e=At.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);Bl=t.userLocale,Og=t.osLocale,ua=t.resolvedLanguage||ds,P3=(G_=t.languagePack)==null?void 0:G_.translationsConfigFile}catch{}o1=!0}else typeof navigator=="object"&&!M3?($r=navigator.userAgent,cd=$r.indexOf("Windows")>=0,ud=$r.indexOf("Macintosh")>=0,($r.indexOf("Macintosh")>=0||$r.indexOf("iPad")>=0||$r.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,ca=$r.indexOf("Linux")>=0,($r==null?void 0:$r.indexOf("Mobi"))>=0,ua=globalThis._VSCODE_NLS_LANGUAGE||ds,Bl=navigator.language.toLowerCase(),Og=Bl):console.error("Unable to resolve platform.");var l1=cd,on=ud,L3=ca,zg=o1,an=$r,In=ua,I3;(e=>{function t(){return In}e.value=t;function r(){return In.length===2?In==="en":In.length>=3?In[0]==="e"&&In[1]==="n"&&In[2]==="-":!1}e.isDefaultVariant=r;function n(){return In==="en"}e.isDefault=n})(I3||(I3={}));var j3=typeof Li.postMessage=="function"&&!Li.importScripts;(()=>{if(j3){let e=[];Li.addEventListener("message",r=>{if(r.data&&r.data.vscodeScheduleAsyncWork)for(let n=0,i=e.length;n<i;n++){let s=e[n];if(s.id===r.data.vscodeScheduleAsyncWork){e.splice(n,1),s.callback();return}}});let t=0;return r=>{let n=++t;e.push({id:n,callback:r}),Li.postMessage({vscodeScheduleAsyncWork:n},"*")}}return e=>setTimeout(e)})();var D3=!!(an&&an.indexOf("Chrome")>=0);an&&an.indexOf("Firefox")>=0;!D3&&an&&an.indexOf("Safari")>=0;an&&an.indexOf("Edg/")>=0;an&&an.indexOf("Android")>=0;var Xi=typeof navigator=="object"?navigator:{};zg||document.queryCommandSupported&&document.queryCommandSupported("copy")||Xi&&Xi.clipboard&&Xi.clipboard.writeText,zg||Xi&&Xi.clipboard&&Xi.clipboard.readText;var op=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}},Cu=new op,$g=new op,Fg=new op,A3=new Array(230),a1;(e=>{function t(l){return Cu.keyCodeToStr(l)}e.toString=t;function r(l){return Cu.strToKeyCode(l)}e.fromString=r;function n(l){return $g.keyCodeToStr(l)}e.toUserSettingsUS=n;function i(l){return Fg.keyCodeToStr(l)}e.toUserSettingsGeneral=i;function s(l){return $g.strToKeyCode(l)||Fg.strToKeyCode(l)}e.fromUserSettings=s;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 Cu.keyCodeToStr(l)}e.toElectronAccelerator=o})(a1||(a1={}));var B3=class c1{constructor(t,r,n,i,s){this.ctrlKey=t,this.shiftKey=r,this.altKey=n,this.metaKey=i,this.keyCode=s}equals(t){return t instanceof c1&&this.ctrlKey===t.ctrlKey&&this.shiftKey===t.shiftKey&&this.altKey===t.altKey&&this.metaKey===t.metaKey&&this.keyCode===t.keyCode}getHashCode(){let t=this.ctrlKey?"1":"0",r=this.shiftKey?"1":"0",n=this.altKey?"1":"0",i=this.metaKey?"1":"0";return`K${t}${r}${n}${i}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new O3([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},O3=class{constructor(e){if(e.length===0)throw c3("chords");this.chords=e}getHashCode(){let e="";for(let t=0,r=this.chords.length;t<r;t++)t!==0&&(e+=";"),e+=this.chords[t].getHashCode();return e}equals(e){if(e===null||this.chords.length!==e.chords.length)return!1;for(let t=0;t<this.chords.length;t++)if(!this.chords[t].equals(e.chords[t]))return!1;return!0}};function z3(e){if(e.charCode){let r=String.fromCharCode(e.charCode).toUpperCase();return a1.fromString(r)}let t=e.keyCode;if(t===3)return 7;if(ad)switch(t){case 59:return 85;case 60:if(L3)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(on)return 57;break}else if(N3&&(on&&t===93||!on&&t===92))return 57;return A3[t]||0}var $3=on?256:2048,F3=512,W3=1024,H3=on?2048:256,Wg=class{constructor(e){var r;this._standardKeyboardEventBrand=!0;let t=e;this.browserEvent=t,this.target=t.target,this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,this.altGraphKey=(r=t.getModifierState)==null?void 0:r.call(t,"AltGraph"),this.keyCode=z3(t),this.code=t.code,this.ctrlKey=this.ctrlKey||this.keyCode===5,this.altKey=this.altKey||this.keyCode===6,this.shiftKey=this.shiftKey||this.keyCode===4,this.metaKey=this.metaKey||this.keyCode===57,this._asKeybinding=this._computeKeybinding(),this._asKeyCodeChord=this._computeKeyCodeChord()}preventDefault(){this.browserEvent&&this.browserEvent.preventDefault&&this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent&&this.browserEvent.stopPropagation&&this.browserEvent.stopPropagation()}toKeyCodeChord(){return this._asKeyCodeChord}equals(e){return this._asKeybinding===e}_computeKeybinding(){let e=0;this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode);let t=0;return this.ctrlKey&&(t|=$3),this.altKey&&(t|=F3),this.shiftKey&&(t|=W3),this.metaKey&&(t|=H3),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new B3(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},Hg=new WeakMap;function U3(e){if(!e.parent||e.parent===e)return null;try{let t=e.location,r=e.parent.location;if(t.origin!=="null"&&r.origin!=="null"&&t.origin!==r.origin)return null}catch{return null}return e.parent}var K3=class{static getSameOriginWindowChain(e){let t=Hg.get(e);if(!t){t=[],Hg.set(e,t);let r=e,n;do n=U3(r),n?t.push({window:new WeakRef(r),iframeElement:r.frameElement||null}):t.push({window:new WeakRef(r),iframeElement:null}),r=n;while(r)}return t.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,t){if(!t||e===t)return{top:0,left:0};let r=0,n=0,i=this.getSameOriginWindowChain(e);for(let s of i){let o=s.window.deref();if(r+=(o==null?void 0:o.scrollY)??0,n+=(o==null?void 0:o.scrollX)??0,o===t||!s.iframeElement)break;let l=s.iframeElement.getBoundingClientRect();r+=l.top,n+=l.left}return{top:r,left:n}}},Ol=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 r=K3.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=r.left,this.posy-=r.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},Ug=class{constructor(e,t=0,r=0){var i;this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=r,this.deltaX=t;let n=!1;if(sp){let s=navigator.userAgent.match(/Chrome\/(\d+)/);n=(s?parseInt(s[1]):123)<=122}if(e){let s=e,o=e,l=((i=e.view)==null?void 0:i.devicePixelRatio)||1;if(typeof s.wheelDeltaY<"u")n?this.deltaY=s.wheelDeltaY/(120*l):this.deltaY=s.wheelDeltaY/120;else if(typeof o.VERTICAL_AXIS<"u"&&o.axis===o.VERTICAL_AXIS)this.deltaY=-o.detail/3;else if(e.type==="wheel"){let a=e;a.deltaMode===a.DOM_DELTA_LINE?ad&&!on?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof s.wheelDeltaX<"u")T3&&l1?this.deltaX=-(s.wheelDeltaX/120):n?this.deltaX=s.wheelDeltaX/(120*l):this.deltaX=s.wheelDeltaX/120;else if(typeof o.HORIZONTAL_AXIS<"u"&&o.axis===o.HORIZONTAL_AXIS)this.deltaX=-e.detail/3;else if(e.type==="wheel"){let a=e;a.deltaMode===a.DOM_DELTA_LINE?ad&&!on?this.deltaX=-e.deltaX/3:this.deltaX=-e.deltaX:this.deltaX=-e.deltaX/40}this.deltaY===0&&this.deltaX===0&&e.wheelDelta&&(n?this.deltaY=e.wheelDelta/(120*l):this.deltaY=e.wheelDelta/120)}}preventDefault(){var e;(e=this.browserEvent)==null||e.preventDefault()}stopPropagation(){var e;(e=this.browserEvent)==null||e.stopPropagation()}},u1=Object.freeze(function(e,t){let r=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(r)}}}),V3;(e=>{function t(r){return r===e.None||r===e.Cancelled||r instanceof q3?!0:!r||typeof r!="object"?!1:typeof r.isCancellationRequested=="boolean"&&typeof r.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Bt.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:u1})})(V3||(V3={}));var q3=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?u1:(this._emitter||(this._emitter=new ae),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},lp=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 rd("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new rd("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},Y3=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,r=globalThis){if(this.isDisposed)throw new rd("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let n=r.setInterval(()=>{e()},t);this.disposable=rt(()=>{r.clearInterval(n),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},X3;(e=>{async function t(n){let i,s=await Promise.all(n.map(o=>o.then(l=>l,l=>{i||(i=l)})));if(typeof i<"u")throw i;return s}e.settled=t;function r(n){return new Promise(async(i,s)=>{try{await n(i,s)}catch(o){s(o)}})}e.withAsyncBody=r})(X3||(X3={}));var Kg=class Tr{static fromArray(t){return new Tr(r=>{r.emitMany(t)})}static fromPromise(t){return new Tr(async r=>{r.emitMany(await t)})}static fromPromises(t){return new Tr(async r=>{await Promise.all(t.map(async n=>r.emitOne(await n)))})}static merge(t){return new Tr(async r=>{await Promise.all(t.map(async n=>{for await(let i of n)r.emitOne(i)}))})}constructor(t,r){this._state=0,this._results=[],this._error=null,this._onReturn=r,this._onStateChanged=new ae,queueMicrotask(async()=>{let n={emitOne:i=>this.emitOne(i),emitMany:i=>this.emitMany(i),reject:i=>this.reject(i)};try{await Promise.resolve(t(n)),this.resolve()}catch(i){this.reject(i)}finally{n.emitOne=void 0,n.emitMany=void 0,n.reject=void 0}})}[Symbol.asyncIterator](){let t=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(t<this._results.length)return{done:!1,value:this._results[t++]};if(this._state===1)return{done:!0,value:void 0};await Bt.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>{var r;return(r=this._onReturn)==null||r.call(this),{done:!0,value:void 0}}}}static map(t,r){return new Tr(async n=>{for await(let i of t)n.emitOne(r(i))})}map(t){return Tr.map(this,t)}static filter(t,r){return new Tr(async n=>{for await(let i of t)r(i)&&n.emitOne(i)})}filter(t){return Tr.filter(this,t)}static coalesce(t){return Tr.filter(t,r=>!!r)}coalesce(){return Tr.coalesce(this)}static async toPromise(t){let r=[];for await(let n of t)r.push(n);return r}toPromise(){return Tr.toPromise(this)}emitOne(t){this._state===0&&(this._results.push(t),this._onStateChanged.fire())}emitMany(t){this._state===0&&(this._results=this._results.concat(t),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(t){this._state===0&&(this._state=2,this._error=t,this._onStateChanged.fire())}};Kg.EMPTY=Kg.fromArray([]);var{getWindow:rn,getWindowId:G3,onDidRegisterWindow:Q3}=function(){let e=new Map,t={window:xn,disposables:new ri};e.set(xn.vscodeWindowId,t);let r=new ae,n=new ae,i=new ae;function s(o,l){return(typeof o=="number"?e.get(o):void 0)??(l?t:void 0)}return{onDidRegisterWindow:r.event,onWillUnregisterWindow:i.event,onDidUnregisterWindow:n.event,registerWindow(o){if(e.has(o.vscodeWindowId))return Be.None;let l=new ri,a={window:o,disposables:l.add(new ri)};return e.set(o.vscodeWindowId,a),l.add(rt(()=>{e.delete(o.vscodeWindowId),n.fire(o)})),l.add(Ne(o,Tt.BEFORE_UNLOAD,()=>{i.fire(o)})),r.fire(a),l},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(o){return o.vscodeWindowId},hasWindow(o){return e.has(o)},getWindowById:s,getWindow(o){var c;let l=o;if((c=l==null?void 0:l.ownerDocument)!=null&&c.defaultView)return l.ownerDocument.defaultView.window;let a=o;return a!=null&&a.view?a.view.window:xn},getDocument(o){return rn(o).document}}}(),J3=class{constructor(e,t,r,n){this._node=e,this._type=t,this._handler=r,this._options=n||!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 Ne(e,t,r,n){return new J3(e,t,r,n)}var Vg=function(e,t,r,n){return Ne(e,t,r,n)},ap,Z3=class extends Y3{constructor(e){super(),this.defaultTarget=e&&rn(e)}cancelAndSet(e,t,r){return super.cancelAndSet(e,t,r??this.defaultTarget)}},qg=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){aa(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,r=new Map,n=new Map,i=s=>{r.set(s,!1);let o=e.get(s)??[];for(t.set(s,o),e.set(s,[]),n.set(s,!0);o.length>0;)o.sort(qg.sort),o.shift().execute();n.set(s,!1)};ap=(s,o,l=0)=>{let a=G3(s),c=new qg(o,l),d=e.get(a);return d||(d=[],e.set(a,d)),d.push(c),r.get(a)||(r.set(a,!0),s.requestAnimationFrame(()=>i(a))),c}})();function eR(e){let t=e.getBoundingClientRect(),r=rn(e);return{left:t.left+r.scrollX,top:t.top+r.scrollY,width:t.width,height:t.height}}var Tt={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"},tR=class{constructor(e){this.domNode=e,this._maxWidth="",this._width="",this._height="",this._top="",this._left="",this._bottom="",this._right="",this._paddingTop="",this._paddingLeft="",this._paddingBottom="",this._paddingRight="",this._fontFamily="",this._fontWeight="",this._fontSize="",this._fontStyle="",this._fontFeatureSettings="",this._fontVariationSettings="",this._textDecoration="",this._lineHeight="",this._letterSpacing="",this._className="",this._display="",this._position="",this._visibility="",this._color="",this._backgroundColor="",this._layerHint=!1,this._contain="none",this._boxShadow=""}setMaxWidth(e){let t=or(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=or(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=or(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=or(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=or(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=or(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=or(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=or(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=or(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=or(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=or(e);this._paddingRight!==t&&(this._paddingRight=t,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(e){this._fontFamily!==e&&(this._fontFamily=e,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(e){this._fontWeight!==e&&(this._fontWeight=e,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(e){let t=or(e);this._fontSize!==t&&(this._fontSize=t,this.domNode.style.fontSize=this._fontSize)}setFontStyle(e){this._fontStyle!==e&&(this._fontStyle=e,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(e){this._fontFeatureSettings!==e&&(this._fontFeatureSettings=e,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(e){this._fontVariationSettings!==e&&(this._fontVariationSettings=e,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(e){this._textDecoration!==e&&(this._textDecoration=e,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(e){let t=or(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=or(e);this._letterSpacing!==t&&(this._letterSpacing=t,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(e){this._className!==e&&(this._className=e,this.domNode.className=this._className)}toggleClassName(e,t){this.domNode.classList.toggle(e,t),this._className=this.domNode.className}setDisplay(e){this._display!==e&&(this._display=e,this.domNode.style.display=this._display)}setPosition(e){this._position!==e&&(this._position=e,this.domNode.style.position=this._position)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this.domNode.style.visibility=this._visibility)}setColor(e){this._color!==e&&(this._color=e,this.domNode.style.color=this._color)}setBackgroundColor(e){this._backgroundColor!==e&&(this._backgroundColor=e,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(e){this._layerHint!==e&&(this._layerHint=e,this.domNode.style.transform=this._layerHint?"translate3d(0px, 0px, 0px)":"")}setBoxShadow(e){this._boxShadow!==e&&(this._boxShadow=e,this.domNode.style.boxShadow=e)}setContain(e){this._contain!==e&&(this._contain=e,this.domNode.style.contain=this._contain)}setAttribute(e,t){this.domNode.setAttribute(e,t)}removeAttribute(e){this.domNode.removeAttribute(e)}appendChild(e){this.domNode.appendChild(e.domNode)}removeChild(e){this.domNode.removeChild(e.domNode)}};function or(e){return typeof e=="number"?`${e}px`:e}function So(e){return new tR(e)}var h1=class{constructor(){this._hooks=new ri,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 r=this._onStopCallback;this._onStopCallback=null,e&&r&&r(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,r,n,i){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=n,this._onStopCallback=i;let s=e;try{e.setPointerCapture(t),this._hooks.add(rt(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{s=rn(e)}this._hooks.add(Ne(s,Tt.POINTER_MOVE,o=>{if(o.buttons!==r){this.stopMonitoring(!0);return}o.preventDefault(),this._pointerMoveCallback(o)})),this._hooks.add(Ne(s,Tt.POINTER_UP,o=>this.stopMonitoring(!0)))}};function rR(e,t,r){let n=null,i=null;if(typeof r.value=="function"?(n="value",i=r.value,i.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof r.get=="function"&&(n="get",i=r.get),!i)throw new Error("not supported");let s=`$memoize$${t}`;r[n]=function(...o){return this.hasOwnProperty(s)||Object.defineProperty(this,s,{configurable:!1,enumerable:!1,writable:!1,value:i.apply(this,o)}),this[s]}}var Jr;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(Jr||(Jr={}));var so=class Ht extends Be{constructor(){super(),this.dispatched=!1,this.targets=new Bg,this.ignoreTargets=new Bg,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(Bt.runAndSubscribe(Q3,({window:t,disposables:r})=>{r.add(Ne(t.document,"touchstart",n=>this.onTouchStart(n),{passive:!1})),r.add(Ne(t.document,"touchend",n=>this.onTouchEnd(t,n))),r.add(Ne(t.document,"touchmove",n=>this.onTouchMove(n),{passive:!1}))},{window:xn,disposables:this._store}))}static addTarget(t){if(!Ht.isTouchDevice())return Be.None;Ht.INSTANCE||(Ht.INSTANCE=new Ht);let r=Ht.INSTANCE.targets.push(t);return rt(r)}static ignoreTarget(t){if(!Ht.isTouchDevice())return Be.None;Ht.INSTANCE||(Ht.INSTANCE=new Ht);let r=Ht.INSTANCE.ignoreTargets.push(t);return rt(r)}static isTouchDevice(){return"ontouchstart"in xn||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(t){let r=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let n=0,i=t.targetTouches.length;n<i;n++){let s=t.targetTouches.item(n);this.activeTouches[s.identifier]={id:s.identifier,initialTarget:s.target,initialTimeStamp:r,initialPageX:s.pageX,initialPageY:s.pageY,rollingTimestamps:[r],rollingPageX:[s.pageX],rollingPageY:[s.pageY]};let o=this.newGestureEvent(Jr.Start,s.target);o.pageX=s.pageX,o.pageY=s.pageY,this.dispatchEvent(o)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}onTouchEnd(t,r){let n=Date.now(),i=Object.keys(this.activeTouches).length;for(let s=0,o=r.changedTouches.length;s<o;s++){let l=r.changedTouches.item(s);if(!this.activeTouches.hasOwnProperty(String(l.identifier))){console.warn("move of an UNKNOWN touch",l);continue}let a=this.activeTouches[l.identifier],c=Date.now()-a.initialTimeStamp;if(c<Ht.HOLD_DELAY&&Math.abs(a.initialPageX-pr(a.rollingPageX))<30&&Math.abs(a.initialPageY-pr(a.rollingPageY))<30){let d=this.newGestureEvent(Jr.Tap,a.initialTarget);d.pageX=pr(a.rollingPageX),d.pageY=pr(a.rollingPageY),this.dispatchEvent(d)}else if(c>=Ht.HOLD_DELAY&&Math.abs(a.initialPageX-pr(a.rollingPageX))<30&&Math.abs(a.initialPageY-pr(a.rollingPageY))<30){let d=this.newGestureEvent(Jr.Contextmenu,a.initialTarget);d.pageX=pr(a.rollingPageX),d.pageY=pr(a.rollingPageY),this.dispatchEvent(d)}else if(i===1){let d=pr(a.rollingPageX),h=pr(a.rollingPageY),f=pr(a.rollingTimestamps)-a.rollingTimestamps[0],p=d-a.rollingPageX[0],m=h-a.rollingPageY[0],_=[...this.targets].filter(b=>a.initialTarget instanceof Node&&b.contains(a.initialTarget));this.inertia(t,_,n,Math.abs(p)/f,p>0?1:-1,d,Math.abs(m)/f,m>0?1:-1,h)}this.dispatchEvent(this.newGestureEvent(Jr.End,a.initialTarget)),delete this.activeTouches[l.identifier]}this.dispatched&&(r.preventDefault(),r.stopPropagation(),this.dispatched=!1)}newGestureEvent(t,r){let n=document.createEvent("CustomEvent");return n.initEvent(t,!1,!0),n.initialTarget=r,n.tapCount=0,n}dispatchEvent(t){if(t.type===Jr.Tap){let r=new Date().getTime(),n=0;r-this._lastSetTapCountTime>Ht.CLEAR_TAP_COUNT_TIME?n=1:n=2,this._lastSetTapCountTime=r,t.tapCount=n}else(t.type===Jr.Change||t.type===Jr.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let n of this.ignoreTargets)if(n.contains(t.initialTarget))return;let r=[];for(let n of this.targets)if(n.contains(t.initialTarget)){let i=0,s=t.initialTarget;for(;s&&s!==n;)i++,s=s.parentElement;r.push([i,n])}r.sort((n,i)=>n[0]-i[0]);for(let[n,i]of r)i.dispatchEvent(t),this.dispatched=!0}}inertia(t,r,n,i,s,o,l,a,c){this.handle=ap(t,()=>{let d=Date.now(),h=d-n,f=0,p=0,m=!0;i+=Ht.SCROLL_FRICTION*h,l+=Ht.SCROLL_FRICTION*h,i>0&&(m=!1,f=s*i*h),l>0&&(m=!1,p=a*l*h);let _=this.newGestureEvent(Jr.Change);_.translationX=f,_.translationY=p,r.forEach(b=>b.dispatchEvent(_)),m||this.inertia(t,r,d,i,s,o+f,l,a,c+p)})}onTouchMove(t){let r=Date.now();for(let n=0,i=t.changedTouches.length;n<i;n++){let s=t.changedTouches.item(n);if(!this.activeTouches.hasOwnProperty(String(s.identifier))){console.warn("end of an UNKNOWN touch",s);continue}let o=this.activeTouches[s.identifier],l=this.newGestureEvent(Jr.Change,o.initialTarget);l.translationX=s.pageX-pr(o.rollingPageX),l.translationY=s.pageY-pr(o.rollingPageY),l.pageX=s.pageX,l.pageY=s.pageY,this.dispatchEvent(l),o.rollingPageX.length>3&&(o.rollingPageX.shift(),o.rollingPageY.shift(),o.rollingTimestamps.shift()),o.rollingPageX.push(s.pageX),o.rollingPageY.push(s.pageY),o.rollingTimestamps.push(r)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}};so.SCROLL_FRICTION=-.005,so.HOLD_DELAY=700,so.CLEAR_TAP_COUNT_TIME=400,ut([rR],so,"isTouchDevice",1);var nR=so,cp=class extends Be{onclick(e,t){this._register(Ne(e,Tt.CLICK,r=>t(new Ol(rn(e),r))))}onmousedown(e,t){this._register(Ne(e,Tt.MOUSE_DOWN,r=>t(new Ol(rn(e),r))))}onmouseover(e,t){this._register(Ne(e,Tt.MOUSE_OVER,r=>t(new Ol(rn(e),r))))}onmouseleave(e,t){this._register(Ne(e,Tt.MOUSE_LEAVE,r=>t(new Ol(rn(e),r))))}onkeydown(e,t){this._register(Ne(e,Tt.KEY_DOWN,r=>t(new Wg(r))))}onkeyup(e,t){this._register(Ne(e,Tt.KEY_UP,r=>t(new Wg(r))))}oninput(e,t){this._register(Ne(e,Tt.INPUT,t))}onblur(e,t){this._register(Ne(e,Tt.BLUR,t))}onfocus(e,t){this._register(Ne(e,Tt.FOCUS,t))}onchange(e,t){this._register(Ne(e,Tt.CHANGE,t))}ignoreGesture(e){return nR.ignoreTarget(e)}},Yg=11,iR=class extends cp{constructor(e){super(),this._onActivate=e.onActivate,this.bgDomNode=document.createElement("div"),this.bgDomNode.className="arrow-background",this.bgDomNode.style.position="absolute",this.bgDomNode.style.width=e.bgWidth+"px",this.bgDomNode.style.height=e.bgHeight+"px",typeof e.top<"u"&&(this.bgDomNode.style.top="0px"),typeof e.left<"u"&&(this.bgDomNode.style.left="0px"),typeof e.bottom<"u"&&(this.bgDomNode.style.bottom="0px"),typeof e.right<"u"&&(this.bgDomNode.style.right="0px"),this.domNode=document.createElement("div"),this.domNode.className=e.className,this.domNode.style.position="absolute",this.domNode.style.width=Yg+"px",this.domNode.style.height=Yg+"px",typeof e.top<"u"&&(this.domNode.style.top=e.top+"px"),typeof e.left<"u"&&(this.domNode.style.left=e.left+"px"),typeof e.bottom<"u"&&(this.domNode.style.bottom=e.bottom+"px"),typeof e.right<"u"&&(this.domNode.style.right=e.right+"px"),this._pointerMoveMonitor=this._register(new h1),this._register(Vg(this.bgDomNode,Tt.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(Vg(this.domNode,Tt.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new Z3),this._pointerdownScheduleRepeatTimer=this._register(new lp)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,rn(e))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(t,200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,r=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault()}},sR=class hd{constructor(t,r,n,i,s,o,l){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(r=r|0,n=n|0,i=i|0,s=s|0,o=o|0,l=l|0),this.rawScrollLeft=i,this.rawScrollTop=l,r<0&&(r=0),i+r>n&&(i=n-r),i<0&&(i=0),s<0&&(s=0),l+s>o&&(l=o-s),l<0&&(l=0),this.width=r,this.scrollWidth=n,this.scrollLeft=i,this.height=s,this.scrollHeight=o,this.scrollTop=l}equals(t){return this.rawScrollLeft===t.rawScrollLeft&&this.rawScrollTop===t.rawScrollTop&&this.width===t.width&&this.scrollWidth===t.scrollWidth&&this.scrollLeft===t.scrollLeft&&this.height===t.height&&this.scrollHeight===t.scrollHeight&&this.scrollTop===t.scrollTop}withScrollDimensions(t,r){return new hd(this._forceIntegerValues,typeof t.width<"u"?t.width:this.width,typeof t.scrollWidth<"u"?t.scrollWidth:this.scrollWidth,r?this.rawScrollLeft:this.scrollLeft,typeof t.height<"u"?t.height:this.height,typeof t.scrollHeight<"u"?t.scrollHeight:this.scrollHeight,r?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new hd(this._forceIntegerValues,this.width,this.scrollWidth,typeof t.scrollLeft<"u"?t.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof t.scrollTop<"u"?t.scrollTop:this.rawScrollTop)}createScrollEvent(t,r){let n=this.width!==t.width,i=this.scrollWidth!==t.scrollWidth,s=this.scrollLeft!==t.scrollLeft,o=this.height!==t.height,l=this.scrollHeight!==t.scrollHeight,a=this.scrollTop!==t.scrollTop;return{inSmoothScrolling:r,oldWidth:t.width,oldScrollWidth:t.scrollWidth,oldScrollLeft:t.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:t.height,oldScrollHeight:t.scrollHeight,oldScrollTop:t.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:n,scrollWidthChanged:i,scrollLeftChanged:s,heightChanged:o,scrollHeightChanged:l,scrollTopChanged:a}}},oR=class extends Be{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new ae),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new sR(e.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),super.dispose()}setSmoothScrollDuration(e){this._smoothScrollDuration=e}validateScrollPosition(e){return this._state.withScrollPosition(e)}getScrollDimensions(){return this._state}setScrollDimensions(e,t){var n;let r=this._state.withScrollDimensions(e,t);this._setState(r,!!this._smoothScrolling),(n=this._smoothScrolling)==null||n.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(e){let t=this._state.withScrollPosition(e);this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),this._setState(t,!1)}setScrollPositionSmooth(e,t){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(e);if(this._smoothScrolling){e={scrollLeft:typeof e.scrollLeft>"u"?this._smoothScrolling.to.scrollLeft:e.scrollLeft,scrollTop:typeof e.scrollTop>"u"?this._smoothScrolling.to.scrollTop:e.scrollTop};let r=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===r.scrollLeft&&this._smoothScrolling.to.scrollTop===r.scrollTop)return;let n;t?n=new Gg(this._smoothScrolling.from,r,this._smoothScrolling.startTime,this._smoothScrolling.duration):n=this._smoothScrolling.combine(this._state,r,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=n}else{let r=this._state.withScrollPosition(e);this._smoothScrolling=Gg.start(this._state,r,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let e=this._smoothScrolling.tick(),t=this._state.withScrollPosition(e);if(this._setState(t,!0),!!this._smoothScrolling){if(e.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(e,t){let r=this._state;r.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(r,t)))}},Xg=class{constructor(e,t,r){this.scrollLeft=e,this.scrollTop=t,this.isDone=r}};function Eu(e,t){let r=t-e;return function(n){return e+r*cR(n)}}function lR(e,t,r){return function(n){return n<r?e(n/r):t((n-r)/(1-r))}}var Gg=class dd{constructor(t,r,n,i){this.from=t,this.to=r,this.duration=i,this.startTime=n,this.animationFrameDisposable=null,this._initAnimations()}_initAnimations(){this.scrollLeft=this._initAnimation(this.from.scrollLeft,this.to.scrollLeft,this.to.width),this.scrollTop=this._initAnimation(this.from.scrollTop,this.to.scrollTop,this.to.height)}_initAnimation(t,r,n){if(Math.abs(t-r)>2.5*n){let i,s;return t<r?(i=t+.75*n,s=r-.75*n):(i=t-.75*n,s=r+.75*n),lR(Eu(t,i),Eu(s,r),.33)}return Eu(t,r)}dispose(){this.animationFrameDisposable!==null&&(this.animationFrameDisposable.dispose(),this.animationFrameDisposable=null)}acceptScrollDimensions(t){this.to=t.withScrollPosition(this.to),this._initAnimations()}tick(){return this._tick(Date.now())}_tick(t){let r=(t-this.startTime)/this.duration;if(r<1){let n=this.scrollLeft(r),i=this.scrollTop(r);return new Xg(n,i,!1)}return new Xg(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,r,n){return dd.start(t,r,n)}static start(t,r,n){n=n+10;let i=Date.now()-10;return new dd(t,r,i,n)}};function aR(e){return Math.pow(e,3)}function cR(e){return 1-aR(1-e)}var uR=class extends Be{constructor(e,t,r){super(),this._visibility=e,this._visibleClassName=t,this._invisibleClassName=r,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new lp)}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":"")))}},hR=140,d1=class extends cp{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 uR(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new h1),this._shouldRender=!0,this.domNode=So(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(Ne(this.domNode.domNode,Tt.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new iR(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,r,n){this.slider=So(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(t),typeof r=="number"&&this.slider.setWidth(r),typeof n=="number"&&this.slider.setHeight(n),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(Ne(this.slider.domNode,Tt.POINTER_DOWN,i=>{i.button===0&&(i.preventDefault(),this._sliderPointerDown(i))})),this.onclick(this.slider.domNode,i=>{i.leftButton&&i.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,r=t+this._scrollbarState.getSliderPosition(),n=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),i=this._sliderPointerPosition(e);r<=i&&i<=n?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,r;if(e.target===this.domNode.domNode&&typeof e.offsetX=="number"&&typeof e.offsetY=="number")t=e.offsetX,r=e.offsetY;else{let i=eR(this.domNode.domNode);t=e.pageX-i.left,r=e.pageY-i.top}let n=this._pointerDownRelativePosition(t,r);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(n):this._scrollbarState.getDesiredScrollPositionFromOffset(n)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),r=this._sliderOrthogonalPointerPosition(e),n=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,i=>{let s=this._sliderOrthogonalPointerPosition(i),o=Math.abs(s-r);if(l1&&o>hR){this._setDesiredScrollPositionNow(n.getScrollPosition());return}let l=this._sliderPointerPosition(i)-t;this._setDesiredScrollPositionNow(n.getDesiredScrollPositionFromDelta(l))},()=>{this.slider.toggleClassName("active",!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(e){let t={};this.writeScrollPosition(t,e),this._scrollable.setScrollPositionNow(t)}updateScrollbarSize(e){this._updateScrollbarSize(e),this._scrollbarState.setScrollbarSize(e),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},f1=class fd{constructor(t,r,n,i,s,o){this._scrollbarSize=Math.round(r),this._oppositeScrollbarSize=Math.round(n),this._arrowSize=Math.round(t),this._visibleSize=i,this._scrollSize=s,this._scrollPosition=o,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new fd(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(t){let r=Math.round(t);return this._visibleSize!==r?(this._visibleSize=r,this._refreshComputedValues(),!0):!1}setScrollSize(t){let r=Math.round(t);return this._scrollSize!==r?(this._scrollSize=r,this._refreshComputedValues(),!0):!1}setScrollPosition(t){let r=Math.round(t);return this._scrollPosition!==r?(this._scrollPosition=r,this._refreshComputedValues(),!0):!1}setScrollbarSize(t){this._scrollbarSize=Math.round(t)}setOppositeScrollbarSize(t){this._oppositeScrollbarSize=Math.round(t)}static _computeValues(t,r,n,i,s){let o=Math.max(0,n-t),l=Math.max(0,o-2*r),a=i>0&&i>n;if(!a)return{computedAvailableSize:Math.round(o),computedIsNeeded:a,computedSliderSize:Math.round(l),computedSliderRatio:0,computedSliderPosition:0};let c=Math.round(Math.max(20,Math.floor(n*l/i))),d=(l-c)/(i-n),h=s*d;return{computedAvailableSize:Math.round(o),computedIsNeeded:a,computedSliderSize:Math.round(c),computedSliderRatio:d,computedSliderPosition:Math.round(h)}}_refreshComputedValues(){let t=fd._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=t.computedAvailableSize,this._computedIsNeeded=t.computedIsNeeded,this._computedSliderSize=t.computedSliderSize,this._computedSliderRatio=t.computedSliderRatio,this._computedSliderPosition=t.computedSliderPosition}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(t){if(!this._computedIsNeeded)return 0;let r=t-this._arrowSize-this._computedSliderSize/2;return Math.round(r/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(t){if(!this._computedIsNeeded)return 0;let r=t-this._arrowSize,n=this._scrollPosition;return r<this._computedSliderPosition?n-=this._visibleSize:n+=this._visibleSize,n}getDesiredScrollPositionFromDelta(t){if(!this._computedIsNeeded)return 0;let r=this._computedSliderPosition+t;return Math.round(r/this._computedSliderRatio)}},dR=class extends d1{constructor(e,t,r){let n=e.getScrollDimensions(),i=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:r,scrollbarState:new f1(t.horizontalHasArrows?t.arrowSize:0,t.horizontal===2?0:t.horizontalScrollbarSize,t.vertical===2?0:t.verticalScrollbarSize,n.width,n.scrollWidth,i.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}},fR=class extends d1{constructor(e,t,r){let n=e.getScrollDimensions(),i=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:r,scrollbarState:new f1(t.verticalHasArrows?t.arrowSize:0,t.vertical===2?0:t.verticalScrollbarSize,0,n.height,n.scrollHeight,i.scrollTop),visibility:t.vertical,extraScrollbarClassName:"vertical",scrollable:e,scrollByPage:t.scrollByPage}),t.verticalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(0,Math.floor((t.verticalScrollbarSize-t.verticalSliderSize)/2),t.verticalSliderSize,void 0)}_updateSlider(e,t){this.slider.setHeight(e),this.slider.setTop(t)}_renderDomNode(e,t){this.domNode.setWidth(t),this.domNode.setHeight(e),this.domNode.setRight(0),this.domNode.setTop(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollHeight)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollTop)||this._shouldRender,this._shouldRender=this._onElementSize(e.height)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return t}_sliderPointerPosition(e){return e.pageY}_sliderOrthogonalPointerPosition(e){return e.pageX}_updateScrollbarSize(e){this.slider.setWidth(e)}writeScrollPosition(e,t){e.scrollTop=t}updateOptions(e){this.updateScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(0),this._visibilityController.setVisibility(e.vertical),this._scrollByPage=e.scrollByPage}},pR=500,Qg=50,mR=class{constructor(e,t,r){this.timestamp=e,this.deltaX=t,this.deltaY=r,this.score=0}},pd=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(this._front===-1&&this._rear===-1)return!1;let t=1,r=0,n=1,i=this._rear;do{let s=i===this._front?t:Math.pow(2,-n);if(t-=s,r+=this._memory[i].score*s,i===this._front)break;i=(this._capacity+i-1)%this._capacity,n++}while(!0);return r<=.5}acceptStandardWheelEvent(t){if(sp){let r=rn(t.browserEvent),n=E3(r);this.accept(Date.now(),t.deltaX*n,t.deltaY*n)}else this.accept(Date.now(),t.deltaX,t.deltaY)}accept(t,r,n){let i=null,s=new mR(t,r,n);this._front===-1&&this._rear===-1?(this._memory[0]=s,this._front=0,this._rear=0):(i=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]=s),s.score=this._computeScore(s,i)}_computeScore(t,r){if(Math.abs(t.deltaX)>0&&Math.abs(t.deltaY)>0)return 1;let n=.5;if((!this._isAlmostInt(t.deltaX)||!this._isAlmostInt(t.deltaY))&&(n+=.25),r){let i=Math.abs(t.deltaX),s=Math.abs(t.deltaY),o=Math.abs(r.deltaX),l=Math.abs(r.deltaY),a=Math.max(Math.min(i,o),1),c=Math.max(Math.min(s,l),1),d=Math.max(i,o),h=Math.max(s,l);d%a===0&&h%c===0&&(n-=.5)}return Math.min(Math.max(n,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};pd.INSTANCE=new pd;var gR=pd,_R=class extends cp{constructor(e,t,r){super(),this._onScroll=this._register(new ae),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new ae),this.onWillScroll=this._onWillScroll.event,this._options=xR(t),this._scrollable=r,this._register(this._scrollable.onScroll(i=>{this._onWillScroll.fire(i),this._onDidScroll(i),this._onScroll.fire(i)}));let n={onMouseWheel:i=>this._onMouseWheel(i),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new fR(this._scrollable,this._options,n)),this._horizontalScrollbar=this._register(new dR(this._scrollable,this._options,n)),this._domNode=document.createElement("div"),this._domNode.className="xterm-scrollable-element "+this._options.className,this._domNode.setAttribute("role","presentation"),this._domNode.style.position="relative",this._domNode.appendChild(e),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=So(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=So(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=So(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,i=>this._onMouseOver(i)),this.onmouseleave(this._listenOnDomNode,i=>this._onMouseLeave(i)),this._hideTimeout=this._register(new lp),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=$i(this._mouseWheelToDispose),super.dispose()}getDomNode(){return this._domNode}getOverviewRulerLayoutInfo(){return{parent:this._domNode,insertBefore:this._verticalScrollbar.domNode.domNode}}delegateVerticalScrollbarPointerDown(e){this._verticalScrollbar.delegatePointerDown(e)}getScrollDimensions(){return this._scrollable.getScrollDimensions()}setScrollDimensions(e){this._scrollable.setScrollDimensions(e,!1)}updateClassName(e){this._options.className=e,on&&(this._options.className+=" mac"),this._domNode.className="xterm-scrollable-element "+this._options.className}updateOptions(e){typeof e.handleMouseWheel<"u"&&(this._options.handleMouseWheel=e.handleMouseWheel,this._setListeningToMouseWheel(this._options.handleMouseWheel)),typeof e.mouseWheelScrollSensitivity<"u"&&(this._options.mouseWheelScrollSensitivity=e.mouseWheelScrollSensitivity),typeof e.fastScrollSensitivity<"u"&&(this._options.fastScrollSensitivity=e.fastScrollSensitivity),typeof e.scrollPredominantAxis<"u"&&(this._options.scrollPredominantAxis=e.scrollPredominantAxis),typeof e.horizontal<"u"&&(this._options.horizontal=e.horizontal),typeof e.vertical<"u"&&(this._options.vertical=e.vertical),typeof e.horizontalScrollbarSize<"u"&&(this._options.horizontalScrollbarSize=e.horizontalScrollbarSize),typeof e.verticalScrollbarSize<"u"&&(this._options.verticalScrollbarSize=e.verticalScrollbarSize),typeof e.scrollByPage<"u"&&(this._options.scrollByPage=e.scrollByPage),this._horizontalScrollbar.updateOptions(this._options),this._verticalScrollbar.updateOptions(this._options),this._options.lazyRender||this._render()}setRevealOnScroll(e){this._revealOnScroll=e}delegateScrollFromMouseWheelEvent(e){this._onMouseWheel(new Ug(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=$i(this._mouseWheelToDispose),e)){let t=r=>{this._onMouseWheel(new Ug(r))};this._mouseWheelToDispose.push(Ne(this._listenOnDomNode,Tt.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){var i;if((i=e.browserEvent)!=null&&i.defaultPrevented)return;let t=gR.INSTANCE;t.acceptStandardWheelEvent(e);let r=!1;if(e.deltaY||e.deltaX){let s=e.deltaY*this._options.mouseWheelScrollSensitivity,o=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&o+s===0?o=s=0:Math.abs(s)>=Math.abs(o)?o=0:s=0),this._options.flipAxes&&([s,o]=[o,s]);let l=!on&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||l)&&!o&&(o=s,s=0),e.browserEvent&&e.browserEvent.altKey&&(o=o*this._options.fastScrollSensitivity,s=s*this._options.fastScrollSensitivity);let a=this._scrollable.getFutureScrollPosition(),c={};if(s){let d=Qg*s,h=a.scrollTop-(d<0?Math.floor(d):Math.ceil(d));this._verticalScrollbar.writeScrollPosition(c,h)}if(o){let d=Qg*o,h=a.scrollLeft-(d<0?Math.floor(d):Math.ceil(d));this._horizontalScrollbar.writeScrollPosition(c,h)}c=this._scrollable.validateScrollPosition(c),(a.scrollLeft!==c.scrollLeft||a.scrollTop!==c.scrollTop)&&(this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(c):this._scrollable.setScrollPositionNow(c),r=!0)}let n=r;!n&&this._options.alwaysConsumeMouseWheel&&(n=!0),!n&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(n=!0),n&&(e.preventDefault(),e.stopPropagation())}_onDidScroll(e){this._shouldRender=this._horizontalScrollbar.onDidScroll(e)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(e)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw new Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let e=this._scrollable.getCurrentScrollPosition(),t=e.scrollTop>0,r=e.scrollLeft>0,n=r?" left":"",i=t?" top":"",s=r||t?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${n}`),this._topShadowDomNode.setClassName(`shadow${i}`),this._topLeftShadowDomNode.setClassName(`shadow${s}${i}${n}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(e){this._mouseIsOver=!1,this._hide()}_onMouseOver(e){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){!this._mouseIsOver&&!this._isDragging&&(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){!this._mouseIsOver&&!this._isDragging&&this._hideTimeout.cancelAndSet(()=>this._hide(),pR)}},vR=class extends _R{constructor(e,t,r){super(e,t,r)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function xR(e){let t={lazyRender:typeof e.lazyRender<"u"?e.lazyRender:!1,className:typeof e.className<"u"?e.className:"",useShadows:typeof e.useShadows<"u"?e.useShadows:!0,handleMouseWheel:typeof e.handleMouseWheel<"u"?e.handleMouseWheel:!0,flipAxes:typeof e.flipAxes<"u"?e.flipAxes:!1,consumeMouseWheelIfScrollbarIsNeeded:typeof e.consumeMouseWheelIfScrollbarIsNeeded<"u"?e.consumeMouseWheelIfScrollbarIsNeeded:!1,alwaysConsumeMouseWheel:typeof e.alwaysConsumeMouseWheel<"u"?e.alwaysConsumeMouseWheel:!1,scrollYToX:typeof e.scrollYToX<"u"?e.scrollYToX:!1,mouseWheelScrollSensitivity:typeof e.mouseWheelScrollSensitivity<"u"?e.mouseWheelScrollSensitivity:1,fastScrollSensitivity:typeof e.fastScrollSensitivity<"u"?e.fastScrollSensitivity:5,scrollPredominantAxis:typeof e.scrollPredominantAxis<"u"?e.scrollPredominantAxis:!0,mouseWheelSmoothScroll:typeof e.mouseWheelSmoothScroll<"u"?e.mouseWheelSmoothScroll:!0,arrowSize:typeof e.arrowSize<"u"?e.arrowSize:11,listenOnDomNode:typeof e.listenOnDomNode<"u"?e.listenOnDomNode:null,horizontal:typeof e.horizontal<"u"?e.horizontal:1,horizontalScrollbarSize:typeof e.horizontalScrollbarSize<"u"?e.horizontalScrollbarSize:10,horizontalSliderSize:typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:0,horizontalHasArrows:typeof e.horizontalHasArrows<"u"?e.horizontalHasArrows:!1,vertical:typeof e.vertical<"u"?e.vertical:1,verticalScrollbarSize:typeof e.verticalScrollbarSize<"u"?e.verticalScrollbarSize:10,verticalHasArrows:typeof e.verticalHasArrows<"u"?e.verticalHasArrows:!1,verticalSliderSize:typeof e.verticalSliderSize<"u"?e.verticalSliderSize:0,scrollByPage:typeof e.scrollByPage<"u"?e.scrollByPage:!1};return t.horizontalSliderSize=typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:t.horizontalScrollbarSize,t.verticalSliderSize=typeof e.verticalSliderSize<"u"?e.verticalSliderSize:t.verticalScrollbarSize,on&&(t.className+=" mac"),t}var md=class extends Be{constructor(e,t,r,n,i,s,o,l){super(),this._bufferService=r,this._optionsService=o,this._renderService=l,this._onRequestScrollLines=this._register(new ae),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let a=this._register(new oR({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:c=>ap(n.window,c)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{a.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new vR(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},a)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(i.onProtocolChange(c=>{this._scrollableElement.updateOptions({handleMouseWheel:!(c&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(Bt.runAndSubscribe(s.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=s.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(rt(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=n.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(rt(()=>this._styleElement.remove())),this._register(Bt.runAndSubscribe(s.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${s.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${s.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${s.colors.scrollbarSliderActiveBackground.css};`,"}"].join(`
|
|
124
|
+
`))}},x3=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},y3=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},b3=0,Su=class{constructor(e){this.value=e,this.id=b3++}},w3=2,S3,le=class{constructor(t){var r,n,i,s;this._size=0,this._options=t,this._leakageMon=(r=this._options)!=null&&r.leakWarningThreshold?new _3((t==null?void 0:t.onListenerError)??aa,((n=this._options)==null?void 0:n.leakWarningThreshold)??g3):void 0,this._perfMon=(i=this._options)!=null&&i._profName?new m3(this._options._profName):void 0,this._deliveryQueue=(s=this._options)==null?void 0:s.deliveryQueue}dispose(){var t,r,n,i;this._disposed||(this._disposed=!0,((t=this._deliveryQueue)==null?void 0:t.current)===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),(n=(r=this._options)==null?void 0:r.onDidRemoveLastListener)==null||n.call(r),(i=this._leakageMon)==null||i.dispose())}get event(){return this._event??(this._event=(t,r,n)=>{var l,a,c,d,h;if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let f=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(f);let p=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],m=new y3(`${f}. HINT: Stack shows most frequent listener (${p[1]}-times)`,p[0]);return(((l=this._options)==null?void 0:l.onListenerError)||aa)(m),Be.None}if(this._disposed)return Be.None;r&&(t=t.bind(r));let i=new Su(t),s;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(i.stack=v3.create(),s=this._leakageMon.check(i.stack,this._size+1)),this._listeners?this._listeners instanceof Su?(this._deliveryQueue??(this._deliveryQueue=new k3),this._listeners=[this._listeners,i]):this._listeners.push(i):((c=(a=this._options)==null?void 0:a.onWillAddFirstListener)==null||c.call(a,this),this._listeners=i,(h=(d=this._options)==null?void 0:d.onDidAddFirstListener)==null||h.call(d,this)),this._size++;let o=rt(()=>{s==null||s(),this._removeListener(i)});return n instanceof ri?n.add(o):Array.isArray(n)&&n.push(o),o}),this._event}_removeListener(t){var s,o,l,a;if((o=(s=this._options)==null?void 0:s.onWillRemoveListener)==null||o.call(s,this),!this._listeners)return;if(this._size===1){this._listeners=void 0,(a=(l=this._options)==null?void 0:l.onDidRemoveLastListener)==null||a.call(l,this),this._size=0;return}let r=this._listeners,n=r.indexOf(t);if(n===-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--,r[n]=void 0;let i=this._deliveryQueue.current===this;if(this._size*w3<=r.length){let c=0;for(let d=0;d<r.length;d++)r[d]?r[c++]=r[d]:i&&(this._deliveryQueue.end--,c<this._deliveryQueue.i&&this._deliveryQueue.i--);r.length=c}}_deliver(t,r){var i;if(!t)return;let n=((i=this._options)==null?void 0:i.onListenerError)||aa;if(!n){t.value(r);return}try{t.value(r)}catch(s){n(s)}}_deliverQueue(t){let r=t.current._listeners;for(;t.i<t.end;)this._deliver(r[t.i++],t.value);t.reset()}fire(t){var r,n,i,s;if((r=this._deliveryQueue)!=null&&r.current&&(this._deliverQueue(this._deliveryQueue),(n=this._perfMon)==null||n.stop()),(i=this._perfMon)==null||i.start(this._size),this._listeners)if(this._listeners instanceof Su)this._deliver(this._listeners,t);else{let o=this._deliveryQueue;o.enqueue(this,t,this._listeners.length),this._deliverQueue(o)}(s=this._perfMon)==null||s.stop()}hasListeners(){return this._size>0}},k3=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,r){this.i=0,this.end=r,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},ld=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new le,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new le,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(t){return this.mapWindowIdToZoomLevel.get(this.getWindowId(t))??0}setZoomLevel(t,r){if(this.getZoomLevel(r)===t)return;let n=this.getWindowId(r);this.mapWindowIdToZoomLevel.set(n,t),this._onDidChangeZoomLevel.fire(n)}getZoomFactor(t){return this.mapWindowIdToZoomFactor.get(this.getWindowId(t))??1}setZoomFactor(t,r){this.mapWindowIdToZoomFactor.set(this.getWindowId(r),t)}setFullscreen(t,r){if(this.isFullscreen(r)===t)return;let n=this.getWindowId(r);this.mapWindowIdToFullScreen.set(n,t),this._onDidChangeFullscreen.fire(n)}isFullscreen(t){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(t))}getWindowId(t){return t.vscodeWindowId}};ld.INSTANCE=new ld;var ip=ld;function C3(e,t,r){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",r)}ip.INSTANCE.onDidChangeZoomLevel;function E3(e){return ip.INSTANCE.getZoomFactor(e)}ip.INSTANCE.onDidChangeFullscreen;var As=typeof navigator=="object"?navigator.userAgent:"",ad=As.indexOf("Firefox")>=0,N3=As.indexOf("AppleWebKit")>=0,sp=As.indexOf("Chrome")>=0,T3=!sp&&As.indexOf("Safari")>=0;As.indexOf("Electron/")>=0;As.indexOf("Android")>=0;var ku=!1;if(typeof xn.matchMedia=="function"){let e=xn.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=xn.matchMedia("(display-mode: fullscreen)");ku=e.matches,C3(xn,e,({matches:r})=>{ku&&t.matches||(ku=r)})}var ds="en",cd=!1,ud=!1,ca=!1,o1=!1,Bl,ua=ds,Og=ds,P3,$r,Li=globalThis,At,Y_;typeof Li.vscode<"u"&&typeof Li.vscode.process<"u"?At=Li.vscode.process:typeof process<"u"&&typeof((Y_=process==null?void 0:process.versions)==null?void 0:Y_.node)=="string"&&(At=process);var X_,R3=typeof((X_=At==null?void 0:At.versions)==null?void 0:X_.electron)=="string",M3=R3&&(At==null?void 0:At.type)==="renderer",G_;if(typeof At=="object"){cd=At.platform==="win32",ud=At.platform==="darwin",ca=At.platform==="linux",ca&&At.env.SNAP&&At.env.SNAP_REVISION,At.env.CI||At.env.BUILD_ARTIFACTSTAGINGDIRECTORY,Bl=ds,ua=ds;let e=At.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);Bl=t.userLocale,Og=t.osLocale,ua=t.resolvedLanguage||ds,P3=(G_=t.languagePack)==null?void 0:G_.translationsConfigFile}catch{}o1=!0}else typeof navigator=="object"&&!M3?($r=navigator.userAgent,cd=$r.indexOf("Windows")>=0,ud=$r.indexOf("Macintosh")>=0,($r.indexOf("Macintosh")>=0||$r.indexOf("iPad")>=0||$r.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,ca=$r.indexOf("Linux")>=0,($r==null?void 0:$r.indexOf("Mobi"))>=0,ua=globalThis._VSCODE_NLS_LANGUAGE||ds,Bl=navigator.language.toLowerCase(),Og=Bl):console.error("Unable to resolve platform.");var l1=cd,on=ud,L3=ca,zg=o1,an=$r,In=ua,I3;(e=>{function t(){return In}e.value=t;function r(){return In.length===2?In==="en":In.length>=3?In[0]==="e"&&In[1]==="n"&&In[2]==="-":!1}e.isDefaultVariant=r;function n(){return In==="en"}e.isDefault=n})(I3||(I3={}));var j3=typeof Li.postMessage=="function"&&!Li.importScripts;(()=>{if(j3){let e=[];Li.addEventListener("message",r=>{if(r.data&&r.data.vscodeScheduleAsyncWork)for(let n=0,i=e.length;n<i;n++){let s=e[n];if(s.id===r.data.vscodeScheduleAsyncWork){e.splice(n,1),s.callback();return}}});let t=0;return r=>{let n=++t;e.push({id:n,callback:r}),Li.postMessage({vscodeScheduleAsyncWork:n},"*")}}return e=>setTimeout(e)})();var D3=!!(an&&an.indexOf("Chrome")>=0);an&&an.indexOf("Firefox")>=0;!D3&&an&&an.indexOf("Safari")>=0;an&&an.indexOf("Edg/")>=0;an&&an.indexOf("Android")>=0;var Xi=typeof navigator=="object"?navigator:{};zg||document.queryCommandSupported&&document.queryCommandSupported("copy")||Xi&&Xi.clipboard&&Xi.clipboard.writeText,zg||Xi&&Xi.clipboard&&Xi.clipboard.readText;var op=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}},Cu=new op,$g=new op,Fg=new op,A3=new Array(230),a1;(e=>{function t(l){return Cu.keyCodeToStr(l)}e.toString=t;function r(l){return Cu.strToKeyCode(l)}e.fromString=r;function n(l){return $g.keyCodeToStr(l)}e.toUserSettingsUS=n;function i(l){return Fg.keyCodeToStr(l)}e.toUserSettingsGeneral=i;function s(l){return $g.strToKeyCode(l)||Fg.strToKeyCode(l)}e.fromUserSettings=s;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 Cu.keyCodeToStr(l)}e.toElectronAccelerator=o})(a1||(a1={}));var B3=class c1{constructor(t,r,n,i,s){this.ctrlKey=t,this.shiftKey=r,this.altKey=n,this.metaKey=i,this.keyCode=s}equals(t){return t instanceof c1&&this.ctrlKey===t.ctrlKey&&this.shiftKey===t.shiftKey&&this.altKey===t.altKey&&this.metaKey===t.metaKey&&this.keyCode===t.keyCode}getHashCode(){let t=this.ctrlKey?"1":"0",r=this.shiftKey?"1":"0",n=this.altKey?"1":"0",i=this.metaKey?"1":"0";return`K${t}${r}${n}${i}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new O3([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},O3=class{constructor(e){if(e.length===0)throw c3("chords");this.chords=e}getHashCode(){let e="";for(let t=0,r=this.chords.length;t<r;t++)t!==0&&(e+=";"),e+=this.chords[t].getHashCode();return e}equals(e){if(e===null||this.chords.length!==e.chords.length)return!1;for(let t=0;t<this.chords.length;t++)if(!this.chords[t].equals(e.chords[t]))return!1;return!0}};function z3(e){if(e.charCode){let r=String.fromCharCode(e.charCode).toUpperCase();return a1.fromString(r)}let t=e.keyCode;if(t===3)return 7;if(ad)switch(t){case 59:return 85;case 60:if(L3)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(on)return 57;break}else if(N3&&(on&&t===93||!on&&t===92))return 57;return A3[t]||0}var $3=on?256:2048,F3=512,W3=1024,H3=on?2048:256,Wg=class{constructor(e){var r;this._standardKeyboardEventBrand=!0;let t=e;this.browserEvent=t,this.target=t.target,this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,this.altGraphKey=(r=t.getModifierState)==null?void 0:r.call(t,"AltGraph"),this.keyCode=z3(t),this.code=t.code,this.ctrlKey=this.ctrlKey||this.keyCode===5,this.altKey=this.altKey||this.keyCode===6,this.shiftKey=this.shiftKey||this.keyCode===4,this.metaKey=this.metaKey||this.keyCode===57,this._asKeybinding=this._computeKeybinding(),this._asKeyCodeChord=this._computeKeyCodeChord()}preventDefault(){this.browserEvent&&this.browserEvent.preventDefault&&this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent&&this.browserEvent.stopPropagation&&this.browserEvent.stopPropagation()}toKeyCodeChord(){return this._asKeyCodeChord}equals(e){return this._asKeybinding===e}_computeKeybinding(){let e=0;this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode);let t=0;return this.ctrlKey&&(t|=$3),this.altKey&&(t|=F3),this.shiftKey&&(t|=W3),this.metaKey&&(t|=H3),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new B3(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},Hg=new WeakMap;function U3(e){if(!e.parent||e.parent===e)return null;try{let t=e.location,r=e.parent.location;if(t.origin!=="null"&&r.origin!=="null"&&t.origin!==r.origin)return null}catch{return null}return e.parent}var K3=class{static getSameOriginWindowChain(e){let t=Hg.get(e);if(!t){t=[],Hg.set(e,t);let r=e,n;do n=U3(r),n?t.push({window:new WeakRef(r),iframeElement:r.frameElement||null}):t.push({window:new WeakRef(r),iframeElement:null}),r=n;while(r)}return t.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,t){if(!t||e===t)return{top:0,left:0};let r=0,n=0,i=this.getSameOriginWindowChain(e);for(let s of i){let o=s.window.deref();if(r+=(o==null?void 0:o.scrollY)??0,n+=(o==null?void 0:o.scrollX)??0,o===t||!s.iframeElement)break;let l=s.iframeElement.getBoundingClientRect();r+=l.top,n+=l.left}return{top:r,left:n}}},Ol=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 r=K3.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=r.left,this.posy-=r.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},Ug=class{constructor(e,t=0,r=0){var i;this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=r,this.deltaX=t;let n=!1;if(sp){let s=navigator.userAgent.match(/Chrome\/(\d+)/);n=(s?parseInt(s[1]):123)<=122}if(e){let s=e,o=e,l=((i=e.view)==null?void 0:i.devicePixelRatio)||1;if(typeof s.wheelDeltaY<"u")n?this.deltaY=s.wheelDeltaY/(120*l):this.deltaY=s.wheelDeltaY/120;else if(typeof o.VERTICAL_AXIS<"u"&&o.axis===o.VERTICAL_AXIS)this.deltaY=-o.detail/3;else if(e.type==="wheel"){let a=e;a.deltaMode===a.DOM_DELTA_LINE?ad&&!on?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof s.wheelDeltaX<"u")T3&&l1?this.deltaX=-(s.wheelDeltaX/120):n?this.deltaX=s.wheelDeltaX/(120*l):this.deltaX=s.wheelDeltaX/120;else if(typeof o.HORIZONTAL_AXIS<"u"&&o.axis===o.HORIZONTAL_AXIS)this.deltaX=-e.detail/3;else if(e.type==="wheel"){let a=e;a.deltaMode===a.DOM_DELTA_LINE?ad&&!on?this.deltaX=-e.deltaX/3:this.deltaX=-e.deltaX:this.deltaX=-e.deltaX/40}this.deltaY===0&&this.deltaX===0&&e.wheelDelta&&(n?this.deltaY=e.wheelDelta/(120*l):this.deltaY=e.wheelDelta/120)}}preventDefault(){var e;(e=this.browserEvent)==null||e.preventDefault()}stopPropagation(){var e;(e=this.browserEvent)==null||e.stopPropagation()}},u1=Object.freeze(function(e,t){let r=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(r)}}}),V3;(e=>{function t(r){return r===e.None||r===e.Cancelled||r instanceof q3?!0:!r||typeof r!="object"?!1:typeof r.isCancellationRequested=="boolean"&&typeof r.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Bt.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:u1})})(V3||(V3={}));var q3=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?u1:(this._emitter||(this._emitter=new le),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},lp=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 rd("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new rd("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},Y3=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,r=globalThis){if(this.isDisposed)throw new rd("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let n=r.setInterval(()=>{e()},t);this.disposable=rt(()=>{r.clearInterval(n),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},X3;(e=>{async function t(n){let i,s=await Promise.all(n.map(o=>o.then(l=>l,l=>{i||(i=l)})));if(typeof i<"u")throw i;return s}e.settled=t;function r(n){return new Promise(async(i,s)=>{try{await n(i,s)}catch(o){s(o)}})}e.withAsyncBody=r})(X3||(X3={}));var Kg=class Tr{static fromArray(t){return new Tr(r=>{r.emitMany(t)})}static fromPromise(t){return new Tr(async r=>{r.emitMany(await t)})}static fromPromises(t){return new Tr(async r=>{await Promise.all(t.map(async n=>r.emitOne(await n)))})}static merge(t){return new Tr(async r=>{await Promise.all(t.map(async n=>{for await(let i of n)r.emitOne(i)}))})}constructor(t,r){this._state=0,this._results=[],this._error=null,this._onReturn=r,this._onStateChanged=new le,queueMicrotask(async()=>{let n={emitOne:i=>this.emitOne(i),emitMany:i=>this.emitMany(i),reject:i=>this.reject(i)};try{await Promise.resolve(t(n)),this.resolve()}catch(i){this.reject(i)}finally{n.emitOne=void 0,n.emitMany=void 0,n.reject=void 0}})}[Symbol.asyncIterator](){let t=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(t<this._results.length)return{done:!1,value:this._results[t++]};if(this._state===1)return{done:!0,value:void 0};await Bt.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>{var r;return(r=this._onReturn)==null||r.call(this),{done:!0,value:void 0}}}}static map(t,r){return new Tr(async n=>{for await(let i of t)n.emitOne(r(i))})}map(t){return Tr.map(this,t)}static filter(t,r){return new Tr(async n=>{for await(let i of t)r(i)&&n.emitOne(i)})}filter(t){return Tr.filter(this,t)}static coalesce(t){return Tr.filter(t,r=>!!r)}coalesce(){return Tr.coalesce(this)}static async toPromise(t){let r=[];for await(let n of t)r.push(n);return r}toPromise(){return Tr.toPromise(this)}emitOne(t){this._state===0&&(this._results.push(t),this._onStateChanged.fire())}emitMany(t){this._state===0&&(this._results=this._results.concat(t),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(t){this._state===0&&(this._state=2,this._error=t,this._onStateChanged.fire())}};Kg.EMPTY=Kg.fromArray([]);var{getWindow:rn,getWindowId:G3,onDidRegisterWindow:Q3}=function(){let e=new Map,t={window:xn,disposables:new ri};e.set(xn.vscodeWindowId,t);let r=new le,n=new le,i=new le;function s(o,l){return(typeof o=="number"?e.get(o):void 0)??(l?t:void 0)}return{onDidRegisterWindow:r.event,onWillUnregisterWindow:i.event,onDidUnregisterWindow:n.event,registerWindow(o){if(e.has(o.vscodeWindowId))return Be.None;let l=new ri,a={window:o,disposables:l.add(new ri)};return e.set(o.vscodeWindowId,a),l.add(rt(()=>{e.delete(o.vscodeWindowId),n.fire(o)})),l.add(Ne(o,Tt.BEFORE_UNLOAD,()=>{i.fire(o)})),r.fire(a),l},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(o){return o.vscodeWindowId},hasWindow(o){return e.has(o)},getWindowById:s,getWindow(o){var c;let l=o;if((c=l==null?void 0:l.ownerDocument)!=null&&c.defaultView)return l.ownerDocument.defaultView.window;let a=o;return a!=null&&a.view?a.view.window:xn},getDocument(o){return rn(o).document}}}(),J3=class{constructor(e,t,r,n){this._node=e,this._type=t,this._handler=r,this._options=n||!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 Ne(e,t,r,n){return new J3(e,t,r,n)}var Vg=function(e,t,r,n){return Ne(e,t,r,n)},ap,Z3=class extends Y3{constructor(e){super(),this.defaultTarget=e&&rn(e)}cancelAndSet(e,t,r){return super.cancelAndSet(e,t,r??this.defaultTarget)}},qg=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){aa(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,r=new Map,n=new Map,i=s=>{r.set(s,!1);let o=e.get(s)??[];for(t.set(s,o),e.set(s,[]),n.set(s,!0);o.length>0;)o.sort(qg.sort),o.shift().execute();n.set(s,!1)};ap=(s,o,l=0)=>{let a=G3(s),c=new qg(o,l),d=e.get(a);return d||(d=[],e.set(a,d)),d.push(c),r.get(a)||(r.set(a,!0),s.requestAnimationFrame(()=>i(a))),c}})();function eR(e){let t=e.getBoundingClientRect(),r=rn(e);return{left:t.left+r.scrollX,top:t.top+r.scrollY,width:t.width,height:t.height}}var Tt={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"},tR=class{constructor(e){this.domNode=e,this._maxWidth="",this._width="",this._height="",this._top="",this._left="",this._bottom="",this._right="",this._paddingTop="",this._paddingLeft="",this._paddingBottom="",this._paddingRight="",this._fontFamily="",this._fontWeight="",this._fontSize="",this._fontStyle="",this._fontFeatureSettings="",this._fontVariationSettings="",this._textDecoration="",this._lineHeight="",this._letterSpacing="",this._className="",this._display="",this._position="",this._visibility="",this._color="",this._backgroundColor="",this._layerHint=!1,this._contain="none",this._boxShadow=""}setMaxWidth(e){let t=or(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=or(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=or(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=or(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=or(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=or(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=or(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=or(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=or(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=or(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=or(e);this._paddingRight!==t&&(this._paddingRight=t,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(e){this._fontFamily!==e&&(this._fontFamily=e,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(e){this._fontWeight!==e&&(this._fontWeight=e,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(e){let t=or(e);this._fontSize!==t&&(this._fontSize=t,this.domNode.style.fontSize=this._fontSize)}setFontStyle(e){this._fontStyle!==e&&(this._fontStyle=e,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(e){this._fontFeatureSettings!==e&&(this._fontFeatureSettings=e,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(e){this._fontVariationSettings!==e&&(this._fontVariationSettings=e,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(e){this._textDecoration!==e&&(this._textDecoration=e,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(e){let t=or(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=or(e);this._letterSpacing!==t&&(this._letterSpacing=t,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(e){this._className!==e&&(this._className=e,this.domNode.className=this._className)}toggleClassName(e,t){this.domNode.classList.toggle(e,t),this._className=this.domNode.className}setDisplay(e){this._display!==e&&(this._display=e,this.domNode.style.display=this._display)}setPosition(e){this._position!==e&&(this._position=e,this.domNode.style.position=this._position)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this.domNode.style.visibility=this._visibility)}setColor(e){this._color!==e&&(this._color=e,this.domNode.style.color=this._color)}setBackgroundColor(e){this._backgroundColor!==e&&(this._backgroundColor=e,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(e){this._layerHint!==e&&(this._layerHint=e,this.domNode.style.transform=this._layerHint?"translate3d(0px, 0px, 0px)":"")}setBoxShadow(e){this._boxShadow!==e&&(this._boxShadow=e,this.domNode.style.boxShadow=e)}setContain(e){this._contain!==e&&(this._contain=e,this.domNode.style.contain=this._contain)}setAttribute(e,t){this.domNode.setAttribute(e,t)}removeAttribute(e){this.domNode.removeAttribute(e)}appendChild(e){this.domNode.appendChild(e.domNode)}removeChild(e){this.domNode.removeChild(e.domNode)}};function or(e){return typeof e=="number"?`${e}px`:e}function So(e){return new tR(e)}var h1=class{constructor(){this._hooks=new ri,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 r=this._onStopCallback;this._onStopCallback=null,e&&r&&r(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,r,n,i){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=n,this._onStopCallback=i;let s=e;try{e.setPointerCapture(t),this._hooks.add(rt(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{s=rn(e)}this._hooks.add(Ne(s,Tt.POINTER_MOVE,o=>{if(o.buttons!==r){this.stopMonitoring(!0);return}o.preventDefault(),this._pointerMoveCallback(o)})),this._hooks.add(Ne(s,Tt.POINTER_UP,o=>this.stopMonitoring(!0)))}};function rR(e,t,r){let n=null,i=null;if(typeof r.value=="function"?(n="value",i=r.value,i.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof r.get=="function"&&(n="get",i=r.get),!i)throw new Error("not supported");let s=`$memoize$${t}`;r[n]=function(...o){return this.hasOwnProperty(s)||Object.defineProperty(this,s,{configurable:!1,enumerable:!1,writable:!1,value:i.apply(this,o)}),this[s]}}var Jr;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(Jr||(Jr={}));var so=class Ht extends Be{constructor(){super(),this.dispatched=!1,this.targets=new Bg,this.ignoreTargets=new Bg,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(Bt.runAndSubscribe(Q3,({window:t,disposables:r})=>{r.add(Ne(t.document,"touchstart",n=>this.onTouchStart(n),{passive:!1})),r.add(Ne(t.document,"touchend",n=>this.onTouchEnd(t,n))),r.add(Ne(t.document,"touchmove",n=>this.onTouchMove(n),{passive:!1}))},{window:xn,disposables:this._store}))}static addTarget(t){if(!Ht.isTouchDevice())return Be.None;Ht.INSTANCE||(Ht.INSTANCE=new Ht);let r=Ht.INSTANCE.targets.push(t);return rt(r)}static ignoreTarget(t){if(!Ht.isTouchDevice())return Be.None;Ht.INSTANCE||(Ht.INSTANCE=new Ht);let r=Ht.INSTANCE.ignoreTargets.push(t);return rt(r)}static isTouchDevice(){return"ontouchstart"in xn||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(t){let r=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let n=0,i=t.targetTouches.length;n<i;n++){let s=t.targetTouches.item(n);this.activeTouches[s.identifier]={id:s.identifier,initialTarget:s.target,initialTimeStamp:r,initialPageX:s.pageX,initialPageY:s.pageY,rollingTimestamps:[r],rollingPageX:[s.pageX],rollingPageY:[s.pageY]};let o=this.newGestureEvent(Jr.Start,s.target);o.pageX=s.pageX,o.pageY=s.pageY,this.dispatchEvent(o)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}onTouchEnd(t,r){let n=Date.now(),i=Object.keys(this.activeTouches).length;for(let s=0,o=r.changedTouches.length;s<o;s++){let l=r.changedTouches.item(s);if(!this.activeTouches.hasOwnProperty(String(l.identifier))){console.warn("move of an UNKNOWN touch",l);continue}let a=this.activeTouches[l.identifier],c=Date.now()-a.initialTimeStamp;if(c<Ht.HOLD_DELAY&&Math.abs(a.initialPageX-pr(a.rollingPageX))<30&&Math.abs(a.initialPageY-pr(a.rollingPageY))<30){let d=this.newGestureEvent(Jr.Tap,a.initialTarget);d.pageX=pr(a.rollingPageX),d.pageY=pr(a.rollingPageY),this.dispatchEvent(d)}else if(c>=Ht.HOLD_DELAY&&Math.abs(a.initialPageX-pr(a.rollingPageX))<30&&Math.abs(a.initialPageY-pr(a.rollingPageY))<30){let d=this.newGestureEvent(Jr.Contextmenu,a.initialTarget);d.pageX=pr(a.rollingPageX),d.pageY=pr(a.rollingPageY),this.dispatchEvent(d)}else if(i===1){let d=pr(a.rollingPageX),h=pr(a.rollingPageY),f=pr(a.rollingTimestamps)-a.rollingTimestamps[0],p=d-a.rollingPageX[0],m=h-a.rollingPageY[0],_=[...this.targets].filter(b=>a.initialTarget instanceof Node&&b.contains(a.initialTarget));this.inertia(t,_,n,Math.abs(p)/f,p>0?1:-1,d,Math.abs(m)/f,m>0?1:-1,h)}this.dispatchEvent(this.newGestureEvent(Jr.End,a.initialTarget)),delete this.activeTouches[l.identifier]}this.dispatched&&(r.preventDefault(),r.stopPropagation(),this.dispatched=!1)}newGestureEvent(t,r){let n=document.createEvent("CustomEvent");return n.initEvent(t,!1,!0),n.initialTarget=r,n.tapCount=0,n}dispatchEvent(t){if(t.type===Jr.Tap){let r=new Date().getTime(),n=0;r-this._lastSetTapCountTime>Ht.CLEAR_TAP_COUNT_TIME?n=1:n=2,this._lastSetTapCountTime=r,t.tapCount=n}else(t.type===Jr.Change||t.type===Jr.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let n of this.ignoreTargets)if(n.contains(t.initialTarget))return;let r=[];for(let n of this.targets)if(n.contains(t.initialTarget)){let i=0,s=t.initialTarget;for(;s&&s!==n;)i++,s=s.parentElement;r.push([i,n])}r.sort((n,i)=>n[0]-i[0]);for(let[n,i]of r)i.dispatchEvent(t),this.dispatched=!0}}inertia(t,r,n,i,s,o,l,a,c){this.handle=ap(t,()=>{let d=Date.now(),h=d-n,f=0,p=0,m=!0;i+=Ht.SCROLL_FRICTION*h,l+=Ht.SCROLL_FRICTION*h,i>0&&(m=!1,f=s*i*h),l>0&&(m=!1,p=a*l*h);let _=this.newGestureEvent(Jr.Change);_.translationX=f,_.translationY=p,r.forEach(b=>b.dispatchEvent(_)),m||this.inertia(t,r,d,i,s,o+f,l,a,c+p)})}onTouchMove(t){let r=Date.now();for(let n=0,i=t.changedTouches.length;n<i;n++){let s=t.changedTouches.item(n);if(!this.activeTouches.hasOwnProperty(String(s.identifier))){console.warn("end of an UNKNOWN touch",s);continue}let o=this.activeTouches[s.identifier],l=this.newGestureEvent(Jr.Change,o.initialTarget);l.translationX=s.pageX-pr(o.rollingPageX),l.translationY=s.pageY-pr(o.rollingPageY),l.pageX=s.pageX,l.pageY=s.pageY,this.dispatchEvent(l),o.rollingPageX.length>3&&(o.rollingPageX.shift(),o.rollingPageY.shift(),o.rollingTimestamps.shift()),o.rollingPageX.push(s.pageX),o.rollingPageY.push(s.pageY),o.rollingTimestamps.push(r)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}};so.SCROLL_FRICTION=-.005,so.HOLD_DELAY=700,so.CLEAR_TAP_COUNT_TIME=400,ut([rR],so,"isTouchDevice",1);var nR=so,cp=class extends Be{onclick(e,t){this._register(Ne(e,Tt.CLICK,r=>t(new Ol(rn(e),r))))}onmousedown(e,t){this._register(Ne(e,Tt.MOUSE_DOWN,r=>t(new Ol(rn(e),r))))}onmouseover(e,t){this._register(Ne(e,Tt.MOUSE_OVER,r=>t(new Ol(rn(e),r))))}onmouseleave(e,t){this._register(Ne(e,Tt.MOUSE_LEAVE,r=>t(new Ol(rn(e),r))))}onkeydown(e,t){this._register(Ne(e,Tt.KEY_DOWN,r=>t(new Wg(r))))}onkeyup(e,t){this._register(Ne(e,Tt.KEY_UP,r=>t(new Wg(r))))}oninput(e,t){this._register(Ne(e,Tt.INPUT,t))}onblur(e,t){this._register(Ne(e,Tt.BLUR,t))}onfocus(e,t){this._register(Ne(e,Tt.FOCUS,t))}onchange(e,t){this._register(Ne(e,Tt.CHANGE,t))}ignoreGesture(e){return nR.ignoreTarget(e)}},Yg=11,iR=class extends cp{constructor(e){super(),this._onActivate=e.onActivate,this.bgDomNode=document.createElement("div"),this.bgDomNode.className="arrow-background",this.bgDomNode.style.position="absolute",this.bgDomNode.style.width=e.bgWidth+"px",this.bgDomNode.style.height=e.bgHeight+"px",typeof e.top<"u"&&(this.bgDomNode.style.top="0px"),typeof e.left<"u"&&(this.bgDomNode.style.left="0px"),typeof e.bottom<"u"&&(this.bgDomNode.style.bottom="0px"),typeof e.right<"u"&&(this.bgDomNode.style.right="0px"),this.domNode=document.createElement("div"),this.domNode.className=e.className,this.domNode.style.position="absolute",this.domNode.style.width=Yg+"px",this.domNode.style.height=Yg+"px",typeof e.top<"u"&&(this.domNode.style.top=e.top+"px"),typeof e.left<"u"&&(this.domNode.style.left=e.left+"px"),typeof e.bottom<"u"&&(this.domNode.style.bottom=e.bottom+"px"),typeof e.right<"u"&&(this.domNode.style.right=e.right+"px"),this._pointerMoveMonitor=this._register(new h1),this._register(Vg(this.bgDomNode,Tt.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(Vg(this.domNode,Tt.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new Z3),this._pointerdownScheduleRepeatTimer=this._register(new lp)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,rn(e))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(t,200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,r=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault()}},sR=class hd{constructor(t,r,n,i,s,o,l){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(r=r|0,n=n|0,i=i|0,s=s|0,o=o|0,l=l|0),this.rawScrollLeft=i,this.rawScrollTop=l,r<0&&(r=0),i+r>n&&(i=n-r),i<0&&(i=0),s<0&&(s=0),l+s>o&&(l=o-s),l<0&&(l=0),this.width=r,this.scrollWidth=n,this.scrollLeft=i,this.height=s,this.scrollHeight=o,this.scrollTop=l}equals(t){return this.rawScrollLeft===t.rawScrollLeft&&this.rawScrollTop===t.rawScrollTop&&this.width===t.width&&this.scrollWidth===t.scrollWidth&&this.scrollLeft===t.scrollLeft&&this.height===t.height&&this.scrollHeight===t.scrollHeight&&this.scrollTop===t.scrollTop}withScrollDimensions(t,r){return new hd(this._forceIntegerValues,typeof t.width<"u"?t.width:this.width,typeof t.scrollWidth<"u"?t.scrollWidth:this.scrollWidth,r?this.rawScrollLeft:this.scrollLeft,typeof t.height<"u"?t.height:this.height,typeof t.scrollHeight<"u"?t.scrollHeight:this.scrollHeight,r?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new hd(this._forceIntegerValues,this.width,this.scrollWidth,typeof t.scrollLeft<"u"?t.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof t.scrollTop<"u"?t.scrollTop:this.rawScrollTop)}createScrollEvent(t,r){let n=this.width!==t.width,i=this.scrollWidth!==t.scrollWidth,s=this.scrollLeft!==t.scrollLeft,o=this.height!==t.height,l=this.scrollHeight!==t.scrollHeight,a=this.scrollTop!==t.scrollTop;return{inSmoothScrolling:r,oldWidth:t.width,oldScrollWidth:t.scrollWidth,oldScrollLeft:t.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:t.height,oldScrollHeight:t.scrollHeight,oldScrollTop:t.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:n,scrollWidthChanged:i,scrollLeftChanged:s,heightChanged:o,scrollHeightChanged:l,scrollTopChanged:a}}},oR=class extends Be{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new le),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new sR(e.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),super.dispose()}setSmoothScrollDuration(e){this._smoothScrollDuration=e}validateScrollPosition(e){return this._state.withScrollPosition(e)}getScrollDimensions(){return this._state}setScrollDimensions(e,t){var n;let r=this._state.withScrollDimensions(e,t);this._setState(r,!!this._smoothScrolling),(n=this._smoothScrolling)==null||n.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(e){let t=this._state.withScrollPosition(e);this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),this._setState(t,!1)}setScrollPositionSmooth(e,t){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(e);if(this._smoothScrolling){e={scrollLeft:typeof e.scrollLeft>"u"?this._smoothScrolling.to.scrollLeft:e.scrollLeft,scrollTop:typeof e.scrollTop>"u"?this._smoothScrolling.to.scrollTop:e.scrollTop};let r=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===r.scrollLeft&&this._smoothScrolling.to.scrollTop===r.scrollTop)return;let n;t?n=new Gg(this._smoothScrolling.from,r,this._smoothScrolling.startTime,this._smoothScrolling.duration):n=this._smoothScrolling.combine(this._state,r,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=n}else{let r=this._state.withScrollPosition(e);this._smoothScrolling=Gg.start(this._state,r,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let e=this._smoothScrolling.tick(),t=this._state.withScrollPosition(e);if(this._setState(t,!0),!!this._smoothScrolling){if(e.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(e,t){let r=this._state;r.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(r,t)))}},Xg=class{constructor(e,t,r){this.scrollLeft=e,this.scrollTop=t,this.isDone=r}};function Eu(e,t){let r=t-e;return function(n){return e+r*cR(n)}}function lR(e,t,r){return function(n){return n<r?e(n/r):t((n-r)/(1-r))}}var Gg=class dd{constructor(t,r,n,i){this.from=t,this.to=r,this.duration=i,this.startTime=n,this.animationFrameDisposable=null,this._initAnimations()}_initAnimations(){this.scrollLeft=this._initAnimation(this.from.scrollLeft,this.to.scrollLeft,this.to.width),this.scrollTop=this._initAnimation(this.from.scrollTop,this.to.scrollTop,this.to.height)}_initAnimation(t,r,n){if(Math.abs(t-r)>2.5*n){let i,s;return t<r?(i=t+.75*n,s=r-.75*n):(i=t-.75*n,s=r+.75*n),lR(Eu(t,i),Eu(s,r),.33)}return Eu(t,r)}dispose(){this.animationFrameDisposable!==null&&(this.animationFrameDisposable.dispose(),this.animationFrameDisposable=null)}acceptScrollDimensions(t){this.to=t.withScrollPosition(this.to),this._initAnimations()}tick(){return this._tick(Date.now())}_tick(t){let r=(t-this.startTime)/this.duration;if(r<1){let n=this.scrollLeft(r),i=this.scrollTop(r);return new Xg(n,i,!1)}return new Xg(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,r,n){return dd.start(t,r,n)}static start(t,r,n){n=n+10;let i=Date.now()-10;return new dd(t,r,i,n)}};function aR(e){return Math.pow(e,3)}function cR(e){return 1-aR(1-e)}var uR=class extends Be{constructor(e,t,r){super(),this._visibility=e,this._visibleClassName=t,this._invisibleClassName=r,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new lp)}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":"")))}},hR=140,d1=class extends cp{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 uR(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new h1),this._shouldRender=!0,this.domNode=So(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(Ne(this.domNode.domNode,Tt.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new iR(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,r,n){this.slider=So(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(t),typeof r=="number"&&this.slider.setWidth(r),typeof n=="number"&&this.slider.setHeight(n),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(Ne(this.slider.domNode,Tt.POINTER_DOWN,i=>{i.button===0&&(i.preventDefault(),this._sliderPointerDown(i))})),this.onclick(this.slider.domNode,i=>{i.leftButton&&i.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,r=t+this._scrollbarState.getSliderPosition(),n=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),i=this._sliderPointerPosition(e);r<=i&&i<=n?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,r;if(e.target===this.domNode.domNode&&typeof e.offsetX=="number"&&typeof e.offsetY=="number")t=e.offsetX,r=e.offsetY;else{let i=eR(this.domNode.domNode);t=e.pageX-i.left,r=e.pageY-i.top}let n=this._pointerDownRelativePosition(t,r);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(n):this._scrollbarState.getDesiredScrollPositionFromOffset(n)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),r=this._sliderOrthogonalPointerPosition(e),n=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,i=>{let s=this._sliderOrthogonalPointerPosition(i),o=Math.abs(s-r);if(l1&&o>hR){this._setDesiredScrollPositionNow(n.getScrollPosition());return}let l=this._sliderPointerPosition(i)-t;this._setDesiredScrollPositionNow(n.getDesiredScrollPositionFromDelta(l))},()=>{this.slider.toggleClassName("active",!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(e){let t={};this.writeScrollPosition(t,e),this._scrollable.setScrollPositionNow(t)}updateScrollbarSize(e){this._updateScrollbarSize(e),this._scrollbarState.setScrollbarSize(e),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},f1=class fd{constructor(t,r,n,i,s,o){this._scrollbarSize=Math.round(r),this._oppositeScrollbarSize=Math.round(n),this._arrowSize=Math.round(t),this._visibleSize=i,this._scrollSize=s,this._scrollPosition=o,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new fd(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(t){let r=Math.round(t);return this._visibleSize!==r?(this._visibleSize=r,this._refreshComputedValues(),!0):!1}setScrollSize(t){let r=Math.round(t);return this._scrollSize!==r?(this._scrollSize=r,this._refreshComputedValues(),!0):!1}setScrollPosition(t){let r=Math.round(t);return this._scrollPosition!==r?(this._scrollPosition=r,this._refreshComputedValues(),!0):!1}setScrollbarSize(t){this._scrollbarSize=Math.round(t)}setOppositeScrollbarSize(t){this._oppositeScrollbarSize=Math.round(t)}static _computeValues(t,r,n,i,s){let o=Math.max(0,n-t),l=Math.max(0,o-2*r),a=i>0&&i>n;if(!a)return{computedAvailableSize:Math.round(o),computedIsNeeded:a,computedSliderSize:Math.round(l),computedSliderRatio:0,computedSliderPosition:0};let c=Math.round(Math.max(20,Math.floor(n*l/i))),d=(l-c)/(i-n),h=s*d;return{computedAvailableSize:Math.round(o),computedIsNeeded:a,computedSliderSize:Math.round(c),computedSliderRatio:d,computedSliderPosition:Math.round(h)}}_refreshComputedValues(){let t=fd._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=t.computedAvailableSize,this._computedIsNeeded=t.computedIsNeeded,this._computedSliderSize=t.computedSliderSize,this._computedSliderRatio=t.computedSliderRatio,this._computedSliderPosition=t.computedSliderPosition}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(t){if(!this._computedIsNeeded)return 0;let r=t-this._arrowSize-this._computedSliderSize/2;return Math.round(r/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(t){if(!this._computedIsNeeded)return 0;let r=t-this._arrowSize,n=this._scrollPosition;return r<this._computedSliderPosition?n-=this._visibleSize:n+=this._visibleSize,n}getDesiredScrollPositionFromDelta(t){if(!this._computedIsNeeded)return 0;let r=this._computedSliderPosition+t;return Math.round(r/this._computedSliderRatio)}},dR=class extends d1{constructor(e,t,r){let n=e.getScrollDimensions(),i=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:r,scrollbarState:new f1(t.horizontalHasArrows?t.arrowSize:0,t.horizontal===2?0:t.horizontalScrollbarSize,t.vertical===2?0:t.verticalScrollbarSize,n.width,n.scrollWidth,i.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}},fR=class extends d1{constructor(e,t,r){let n=e.getScrollDimensions(),i=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:r,scrollbarState:new f1(t.verticalHasArrows?t.arrowSize:0,t.vertical===2?0:t.verticalScrollbarSize,0,n.height,n.scrollHeight,i.scrollTop),visibility:t.vertical,extraScrollbarClassName:"vertical",scrollable:e,scrollByPage:t.scrollByPage}),t.verticalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(0,Math.floor((t.verticalScrollbarSize-t.verticalSliderSize)/2),t.verticalSliderSize,void 0)}_updateSlider(e,t){this.slider.setHeight(e),this.slider.setTop(t)}_renderDomNode(e,t){this.domNode.setWidth(t),this.domNode.setHeight(e),this.domNode.setRight(0),this.domNode.setTop(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollHeight)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollTop)||this._shouldRender,this._shouldRender=this._onElementSize(e.height)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return t}_sliderPointerPosition(e){return e.pageY}_sliderOrthogonalPointerPosition(e){return e.pageX}_updateScrollbarSize(e){this.slider.setWidth(e)}writeScrollPosition(e,t){e.scrollTop=t}updateOptions(e){this.updateScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(0),this._visibilityController.setVisibility(e.vertical),this._scrollByPage=e.scrollByPage}},pR=500,Qg=50,mR=class{constructor(e,t,r){this.timestamp=e,this.deltaX=t,this.deltaY=r,this.score=0}},pd=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(this._front===-1&&this._rear===-1)return!1;let t=1,r=0,n=1,i=this._rear;do{let s=i===this._front?t:Math.pow(2,-n);if(t-=s,r+=this._memory[i].score*s,i===this._front)break;i=(this._capacity+i-1)%this._capacity,n++}while(!0);return r<=.5}acceptStandardWheelEvent(t){if(sp){let r=rn(t.browserEvent),n=E3(r);this.accept(Date.now(),t.deltaX*n,t.deltaY*n)}else this.accept(Date.now(),t.deltaX,t.deltaY)}accept(t,r,n){let i=null,s=new mR(t,r,n);this._front===-1&&this._rear===-1?(this._memory[0]=s,this._front=0,this._rear=0):(i=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]=s),s.score=this._computeScore(s,i)}_computeScore(t,r){if(Math.abs(t.deltaX)>0&&Math.abs(t.deltaY)>0)return 1;let n=.5;if((!this._isAlmostInt(t.deltaX)||!this._isAlmostInt(t.deltaY))&&(n+=.25),r){let i=Math.abs(t.deltaX),s=Math.abs(t.deltaY),o=Math.abs(r.deltaX),l=Math.abs(r.deltaY),a=Math.max(Math.min(i,o),1),c=Math.max(Math.min(s,l),1),d=Math.max(i,o),h=Math.max(s,l);d%a===0&&h%c===0&&(n-=.5)}return Math.min(Math.max(n,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};pd.INSTANCE=new pd;var gR=pd,_R=class extends cp{constructor(e,t,r){super(),this._onScroll=this._register(new le),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new le),this.onWillScroll=this._onWillScroll.event,this._options=xR(t),this._scrollable=r,this._register(this._scrollable.onScroll(i=>{this._onWillScroll.fire(i),this._onDidScroll(i),this._onScroll.fire(i)}));let n={onMouseWheel:i=>this._onMouseWheel(i),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new fR(this._scrollable,this._options,n)),this._horizontalScrollbar=this._register(new dR(this._scrollable,this._options,n)),this._domNode=document.createElement("div"),this._domNode.className="xterm-scrollable-element "+this._options.className,this._domNode.setAttribute("role","presentation"),this._domNode.style.position="relative",this._domNode.appendChild(e),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=So(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=So(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=So(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,i=>this._onMouseOver(i)),this.onmouseleave(this._listenOnDomNode,i=>this._onMouseLeave(i)),this._hideTimeout=this._register(new lp),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=$i(this._mouseWheelToDispose),super.dispose()}getDomNode(){return this._domNode}getOverviewRulerLayoutInfo(){return{parent:this._domNode,insertBefore:this._verticalScrollbar.domNode.domNode}}delegateVerticalScrollbarPointerDown(e){this._verticalScrollbar.delegatePointerDown(e)}getScrollDimensions(){return this._scrollable.getScrollDimensions()}setScrollDimensions(e){this._scrollable.setScrollDimensions(e,!1)}updateClassName(e){this._options.className=e,on&&(this._options.className+=" mac"),this._domNode.className="xterm-scrollable-element "+this._options.className}updateOptions(e){typeof e.handleMouseWheel<"u"&&(this._options.handleMouseWheel=e.handleMouseWheel,this._setListeningToMouseWheel(this._options.handleMouseWheel)),typeof e.mouseWheelScrollSensitivity<"u"&&(this._options.mouseWheelScrollSensitivity=e.mouseWheelScrollSensitivity),typeof e.fastScrollSensitivity<"u"&&(this._options.fastScrollSensitivity=e.fastScrollSensitivity),typeof e.scrollPredominantAxis<"u"&&(this._options.scrollPredominantAxis=e.scrollPredominantAxis),typeof e.horizontal<"u"&&(this._options.horizontal=e.horizontal),typeof e.vertical<"u"&&(this._options.vertical=e.vertical),typeof e.horizontalScrollbarSize<"u"&&(this._options.horizontalScrollbarSize=e.horizontalScrollbarSize),typeof e.verticalScrollbarSize<"u"&&(this._options.verticalScrollbarSize=e.verticalScrollbarSize),typeof e.scrollByPage<"u"&&(this._options.scrollByPage=e.scrollByPage),this._horizontalScrollbar.updateOptions(this._options),this._verticalScrollbar.updateOptions(this._options),this._options.lazyRender||this._render()}setRevealOnScroll(e){this._revealOnScroll=e}delegateScrollFromMouseWheelEvent(e){this._onMouseWheel(new Ug(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=$i(this._mouseWheelToDispose),e)){let t=r=>{this._onMouseWheel(new Ug(r))};this._mouseWheelToDispose.push(Ne(this._listenOnDomNode,Tt.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){var i;if((i=e.browserEvent)!=null&&i.defaultPrevented)return;let t=gR.INSTANCE;t.acceptStandardWheelEvent(e);let r=!1;if(e.deltaY||e.deltaX){let s=e.deltaY*this._options.mouseWheelScrollSensitivity,o=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&o+s===0?o=s=0:Math.abs(s)>=Math.abs(o)?o=0:s=0),this._options.flipAxes&&([s,o]=[o,s]);let l=!on&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||l)&&!o&&(o=s,s=0),e.browserEvent&&e.browserEvent.altKey&&(o=o*this._options.fastScrollSensitivity,s=s*this._options.fastScrollSensitivity);let a=this._scrollable.getFutureScrollPosition(),c={};if(s){let d=Qg*s,h=a.scrollTop-(d<0?Math.floor(d):Math.ceil(d));this._verticalScrollbar.writeScrollPosition(c,h)}if(o){let d=Qg*o,h=a.scrollLeft-(d<0?Math.floor(d):Math.ceil(d));this._horizontalScrollbar.writeScrollPosition(c,h)}c=this._scrollable.validateScrollPosition(c),(a.scrollLeft!==c.scrollLeft||a.scrollTop!==c.scrollTop)&&(this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(c):this._scrollable.setScrollPositionNow(c),r=!0)}let n=r;!n&&this._options.alwaysConsumeMouseWheel&&(n=!0),!n&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(n=!0),n&&(e.preventDefault(),e.stopPropagation())}_onDidScroll(e){this._shouldRender=this._horizontalScrollbar.onDidScroll(e)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(e)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw new Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let e=this._scrollable.getCurrentScrollPosition(),t=e.scrollTop>0,r=e.scrollLeft>0,n=r?" left":"",i=t?" top":"",s=r||t?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${n}`),this._topShadowDomNode.setClassName(`shadow${i}`),this._topLeftShadowDomNode.setClassName(`shadow${s}${i}${n}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(e){this._mouseIsOver=!1,this._hide()}_onMouseOver(e){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){!this._mouseIsOver&&!this._isDragging&&(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){!this._mouseIsOver&&!this._isDragging&&this._hideTimeout.cancelAndSet(()=>this._hide(),pR)}},vR=class extends _R{constructor(e,t,r){super(e,t,r)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function xR(e){let t={lazyRender:typeof e.lazyRender<"u"?e.lazyRender:!1,className:typeof e.className<"u"?e.className:"",useShadows:typeof e.useShadows<"u"?e.useShadows:!0,handleMouseWheel:typeof e.handleMouseWheel<"u"?e.handleMouseWheel:!0,flipAxes:typeof e.flipAxes<"u"?e.flipAxes:!1,consumeMouseWheelIfScrollbarIsNeeded:typeof e.consumeMouseWheelIfScrollbarIsNeeded<"u"?e.consumeMouseWheelIfScrollbarIsNeeded:!1,alwaysConsumeMouseWheel:typeof e.alwaysConsumeMouseWheel<"u"?e.alwaysConsumeMouseWheel:!1,scrollYToX:typeof e.scrollYToX<"u"?e.scrollYToX:!1,mouseWheelScrollSensitivity:typeof e.mouseWheelScrollSensitivity<"u"?e.mouseWheelScrollSensitivity:1,fastScrollSensitivity:typeof e.fastScrollSensitivity<"u"?e.fastScrollSensitivity:5,scrollPredominantAxis:typeof e.scrollPredominantAxis<"u"?e.scrollPredominantAxis:!0,mouseWheelSmoothScroll:typeof e.mouseWheelSmoothScroll<"u"?e.mouseWheelSmoothScroll:!0,arrowSize:typeof e.arrowSize<"u"?e.arrowSize:11,listenOnDomNode:typeof e.listenOnDomNode<"u"?e.listenOnDomNode:null,horizontal:typeof e.horizontal<"u"?e.horizontal:1,horizontalScrollbarSize:typeof e.horizontalScrollbarSize<"u"?e.horizontalScrollbarSize:10,horizontalSliderSize:typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:0,horizontalHasArrows:typeof e.horizontalHasArrows<"u"?e.horizontalHasArrows:!1,vertical:typeof e.vertical<"u"?e.vertical:1,verticalScrollbarSize:typeof e.verticalScrollbarSize<"u"?e.verticalScrollbarSize:10,verticalHasArrows:typeof e.verticalHasArrows<"u"?e.verticalHasArrows:!1,verticalSliderSize:typeof e.verticalSliderSize<"u"?e.verticalSliderSize:0,scrollByPage:typeof e.scrollByPage<"u"?e.scrollByPage:!1};return t.horizontalSliderSize=typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:t.horizontalScrollbarSize,t.verticalSliderSize=typeof e.verticalSliderSize<"u"?e.verticalSliderSize:t.verticalScrollbarSize,on&&(t.className+=" mac"),t}var md=class extends Be{constructor(e,t,r,n,i,s,o,l){super(),this._bufferService=r,this._optionsService=o,this._renderService=l,this._onRequestScrollLines=this._register(new le),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let a=this._register(new oR({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:c=>ap(n.window,c)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{a.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new vR(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},a)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(i.onProtocolChange(c=>{this._scrollableElement.updateOptions({handleMouseWheel:!(c&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(Bt.runAndSubscribe(s.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=s.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(rt(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=n.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(rt(()=>this._styleElement.remove())),this._register(Bt.runAndSubscribe(s.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${s.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${s.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${s.colors.scrollbarSliderActiveBackground.css};`,"}"].join(`
|
|
125
125
|
`)})),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(c=>this._handleScroll(c)))}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),r=t-this._bufferService.buffer.ydisp;r!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(r)),this._isHandlingScroll=!1}};md=ut([ue(2,tr),ue(3,Tn),ue(4,q0),ue(5,Ds),ue(6,rr),ue(7,Pn)],md);var gd=class extends Be{constructor(e,t,r,n,i){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=r,this._decorationService=n,this._renderService=i,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(s=>this._removeDecoration(s))),this._register(rt(()=>{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 n;let t=this._coreBrowserService.mainDocument.createElement("div");t.classList.add("xterm-decoration"),t.classList.toggle("xterm-decoration-top-layer",((n=e==null?void 0:e.options)==null?void 0:n.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 r=e.options.x??0;return r&&r>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 r=this._decorationElements.get(e);r||(r=this._createElement(e),e.element=r,this._decorationElements.set(e,r),this._container.appendChild(r),e.onDispose(()=>{this._decorationElements.delete(e),r.remove()})),r.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(r.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,r.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,r.style.top=`${t*this._renderService.dimensions.css.cell.height}px`,r.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(r)}}_refreshXPosition(e,t=e.element){if(!t)return;let r=e.options.x??0;(e.options.anchor||"left")==="right"?t.style.right=r?`${r*this._renderService.dimensions.css.cell.width}px`:"":t.style.left=r?`${r*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()}};gd=ut([ue(1,tr),ue(2,Tn),ue(3,dl),ue(4,Pn)],gd);var yR=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,r){return t>=e.startBufferLine-this._linePadding[r||"full"]&&t<=e.endBufferLine+this._linePadding[r||"full"]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},Gr={full:0,left:0,center:0,right:0},jn={full:0,left:0,center:0,right:0},qs={full:0,left:0,center:0,right:0},Qa=class extends Be{constructor(e,t,r,n,i,s,o,l){var c;super(),this._viewportElement=e,this._screenElement=t,this._bufferService=r,this._decorationService=n,this._renderService=i,this._optionsService=s,this._themeService=o,this._coreBrowserService=l,this._colorZoneStore=new yR,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(),(c=this._viewportElement.parentElement)==null||c.insertBefore(this._canvas,this._viewportElement),this._register(rt(()=>{var d;return(d=this._canvas)==null?void 0:d.remove()}));let a=this._canvas.getContext("2d");if(a)this._ctx=a;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);jn.full=this._canvas.width,jn.left=e,jn.center=t,jn.right=e,this._refreshDrawHeightConstants(),qs.full=1,qs.left=1,qs.center=1+jn.left,qs.right=1+jn.left+jn.center}_refreshDrawHeightConstants(){Gr.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);Gr.left=t,Gr.center=t,Gr.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Gr.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Gr.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Gr.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Gr.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(qs[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-Gr[e.position||"full"]/2),jn[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+Gr[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}))}};Qa=ut([ue(2,tr),ue(3,dl),ue(4,Pn),ue(5,rr),ue(6,Ds),ue(7,Tn)],Qa);var Q;(e=>(e.NUL="\0",e.SOH="",e.STX="",e.ETX="",e.EOT="",e.ENQ="",e.ACK="",e.BEL="\x07",e.BS="\b",e.HT=" ",e.LF=`
|
|
126
|
-
`,e.VT="\v",e.FF="\f",e.CR="\r",e.SO="",e.SI="",e.DLE="",e.DC1="",e.DC2="",e.DC3="",e.DC4="",e.NAK="",e.SYN="",e.ETB="",e.CAN="",e.EM="",e.SUB="",e.ESC="\x1B",e.FS="",e.GS="",e.RS="",e.US="",e.SP=" ",e.DEL=""))(Q||(Q={}));var ha;(e=>(e.PAD="",e.HOP="",e.BPH="",e.NBH="",e.IND="",e.NEL="
",e.SSA="",e.ESA="",e.HTS="",e.HTJ="",e.VTS="",e.PLD="",e.PLU="",e.RI="",e.SS2="",e.SS3="",e.DCS="",e.PU1="",e.PU2="",e.STS="",e.CCH="",e.MW="",e.SPA="",e.EPA="",e.SOS="",e.SGCI="",e.SCI="",e.CSI="",e.ST="",e.OSC="",e.PM="",e.APC=""))(ha||(ha={}));var p1;(e=>e.ST=`${Q.ESC}\\`)(p1||(p1={}));var _d=class{constructor(e,t,r,n,i,s){this._textarea=e,this._compositionView=t,this._bufferService=r,this._optionsService=n,this._coreService=i,this._renderService=s,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 r;t.start+=this._dataAlreadySent.length,this._isComposing?r=this._textarea.value.substring(t.start,this._compositionPosition.start):r=this._textarea.value.substring(t.start),r.length>0&&this._coreService.triggerDataEvent(r,!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,r=t.replace(e,"");this._dataAlreadySent=r,t.length>e.length?this._coreService.triggerDataEvent(r,!0):t.length<e.length?this._coreService.triggerDataEvent(`${Q.DEL}`,!0):t.length===e.length&&t!==e&&this._coreService.triggerDataEvent(t,!0)}},0)}updateCompositionElements(e){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let t=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),r=this._renderService.dimensions.css.cell.height,n=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,i=t*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=i+"px",this._compositionView.style.top=n+"px",this._compositionView.style.height=r+"px",this._compositionView.style.lineHeight=r+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let s=this._compositionView.getBoundingClientRect();this._textarea.style.left=i+"px",this._textarea.style.top=n+"px",this._textarea.style.width=Math.max(s.width,1)+"px",this._textarea.style.height=Math.max(s.height,1)+"px",this._textarea.style.lineHeight=s.height+"px"}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};_d=ut([ue(2,tr),ue(3,rr),ue(4,Ki),ue(5,Pn)],_d);var Rt=0,Mt=0,Lt=0,at=0,Jg={css:"#00000000",rgba:0},_t;(e=>{function t(i,s,o,l){return l!==void 0?`#${pi(i)}${pi(s)}${pi(o)}${pi(l)}`:`#${pi(i)}${pi(s)}${pi(o)}`}e.toCss=t;function r(i,s,o,l=255){return(i<<24|s<<16|o<<8|l)>>>0}e.toRgba=r;function n(i,s,o,l){return{css:e.toCss(i,s,o,l),rgba:e.toRgba(i,s,o,l)}}e.toColor=n})(_t||(_t={}));var Ze;(e=>{function t(a,c){if(at=(c.rgba&255)/255,at===1)return{css:c.css,rgba:c.rgba};let d=c.rgba>>24&255,h=c.rgba>>16&255,f=c.rgba>>8&255,p=a.rgba>>24&255,m=a.rgba>>16&255,_=a.rgba>>8&255;Rt=p+Math.round((d-p)*at),Mt=m+Math.round((h-m)*at),Lt=_+Math.round((f-_)*at);let b=_t.toCss(Rt,Mt,Lt),g=_t.toRgba(Rt,Mt,Lt);return{css:b,rgba:g}}e.blend=t;function r(a){return(a.rgba&255)===255}e.isOpaque=r;function n(a,c,d){let h=da.ensureContrastRatio(a.rgba,c.rgba,d);if(h)return _t.toColor(h>>24&255,h>>16&255,h>>8&255)}e.ensureContrastRatio=n;function i(a){let c=(a.rgba|255)>>>0;return[Rt,Mt,Lt]=da.toChannels(c),{css:_t.toCss(Rt,Mt,Lt),rgba:c}}e.opaque=i;function s(a,c){return at=Math.round(c*255),[Rt,Mt,Lt]=da.toChannels(a.rgba),{css:_t.toCss(Rt,Mt,Lt,at),rgba:_t.toRgba(Rt,Mt,Lt,at)}}e.opacity=s;function o(a,c){return at=a.rgba&255,s(a,at*c/255)}e.multiplyOpacity=o;function l(a){return[a.rgba>>24&255,a.rgba>>16&255,a.rgba>>8&255]}e.toColorRGB=l})(Ze||(Ze={}));var it;(e=>{let t,r;try{let i=document.createElement("canvas");i.width=1,i.height=1;let s=i.getContext("2d",{willReadFrequently:!0});s&&(t=s,t.globalCompositeOperation="copy",r=t.createLinearGradient(0,0,1,1))}catch{}function n(i){if(i.match(/#[\da-f]{3,8}/i))switch(i.length){case 4:return Rt=parseInt(i.slice(1,2).repeat(2),16),Mt=parseInt(i.slice(2,3).repeat(2),16),Lt=parseInt(i.slice(3,4).repeat(2),16),_t.toColor(Rt,Mt,Lt);case 5:return Rt=parseInt(i.slice(1,2).repeat(2),16),Mt=parseInt(i.slice(2,3).repeat(2),16),Lt=parseInt(i.slice(3,4).repeat(2),16),at=parseInt(i.slice(4,5).repeat(2),16),_t.toColor(Rt,Mt,Lt,at);case 7:return{css:i,rgba:(parseInt(i.slice(1),16)<<8|255)>>>0};case 9:return{css:i,rgba:parseInt(i.slice(1),16)>>>0}}let s=i.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(s)return Rt=parseInt(s[1]),Mt=parseInt(s[2]),Lt=parseInt(s[3]),at=Math.round((s[5]===void 0?1:parseFloat(s[5]))*255),_t.toColor(Rt,Mt,Lt,at);if(!t||!r)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=r,t.fillStyle=i,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[Rt,Mt,Lt,at]=t.getImageData(0,0,1,1).data,at!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:_t.toRgba(Rt,Mt,Lt,at),css:i}}e.toColor=n})(it||(it={}));var Xt;(e=>{function t(n){return r(n>>16&255,n>>8&255,n&255)}e.relativeLuminance=t;function r(n,i,s){let o=n/255,l=i/255,a=s/255,c=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),h=a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4);return c*.2126+d*.7152+h*.0722}e.relativeLuminance2=r})(Xt||(Xt={}));var da;(e=>{function t(o,l){if(at=(l&255)/255,at===1)return l;let a=l>>24&255,c=l>>16&255,d=l>>8&255,h=o>>24&255,f=o>>16&255,p=o>>8&255;return Rt=h+Math.round((a-h)*at),Mt=f+Math.round((c-f)*at),Lt=p+Math.round((d-p)*at),_t.toRgba(Rt,Mt,Lt)}e.blend=t;function r(o,l,a){let c=Xt.relativeLuminance(o>>8),d=Xt.relativeLuminance(l>>8);if(un(c,d)<a){if(d<c){let p=n(o,l,a),m=un(c,Xt.relativeLuminance(p>>8));if(m<a){let _=i(o,l,a),b=un(c,Xt.relativeLuminance(_>>8));return m>b?p:_}return p}let h=i(o,l,a),f=un(c,Xt.relativeLuminance(h>>8));if(f<a){let p=n(o,l,a),m=un(c,Xt.relativeLuminance(p>>8));return f>m?h:p}return h}}e.ensureContrastRatio=r;function n(o,l,a){let c=o>>24&255,d=o>>16&255,h=o>>8&255,f=l>>24&255,p=l>>16&255,m=l>>8&255,_=un(Xt.relativeLuminance2(f,p,m),Xt.relativeLuminance2(c,d,h));for(;_<a&&(f>0||p>0||m>0);)f-=Math.max(0,Math.ceil(f*.1)),p-=Math.max(0,Math.ceil(p*.1)),m-=Math.max(0,Math.ceil(m*.1)),_=un(Xt.relativeLuminance2(f,p,m),Xt.relativeLuminance2(c,d,h));return(f<<24|p<<16|m<<8|255)>>>0}e.reduceLuminance=n;function i(o,l,a){let c=o>>24&255,d=o>>16&255,h=o>>8&255,f=l>>24&255,p=l>>16&255,m=l>>8&255,_=un(Xt.relativeLuminance2(f,p,m),Xt.relativeLuminance2(c,d,h));for(;_<a&&(f<255||p<255||m<255);)f=Math.min(255,f+Math.ceil((255-f)*.1)),p=Math.min(255,p+Math.ceil((255-p)*.1)),m=Math.min(255,m+Math.ceil((255-m)*.1)),_=un(Xt.relativeLuminance2(f,p,m),Xt.relativeLuminance2(c,d,h));return(f<<24|p<<16|m<<8|255)>>>0}e.increaseLuminance=i;function s(o){return[o>>24&255,o>>16&255,o>>8&255,o&255]}e.toChannels=s})(da||(da={}));function pi(e){let t=e.toString(16);return t.length<2?"0"+t:t}function un(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var bR=class extends hl{constructor(e,t,r){super(),this.content=0,this.combinedData="",this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=r}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()]}},Ja=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new Ar}register(e){let t={id:this._nextCharacterJoinerId++,handler:e};return this._characterJoiners.push(t),t.id}deregister(e){for(let t=0;t<this._characterJoiners.length;t++)if(this._characterJoiners[t].id===e)return this._characterJoiners.splice(t,1),!0;return!1}getJoinedCharacters(e){if(this._characterJoiners.length===0)return[];let t=this._bufferService.buffer.lines.get(e);if(!t||t.length===0)return[];let r=[],n=t.translateToString(!0),i=0,s=0,o=0,l=t.getFg(0),a=t.getBg(0);for(let c=0;c<t.getTrimmedLength();c++)if(t.loadCell(c,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==l||this._workCell.bg!==a){if(c-i>1){let d=this._getJoinedRanges(n,o,s,t,i);for(let h=0;h<d.length;h++)r.push(d[h])}i=c,o=s,l=this._workCell.fg,a=this._workCell.bg}s+=this._workCell.getChars().length||qn.length}if(this._bufferService.cols-i>1){let c=this._getJoinedRanges(n,o,s,t,i);for(let d=0;d<c.length;d++)r.push(c[d])}return r}_getJoinedRanges(e,t,r,n,i){let s=e.substring(t,r),o=[];try{o=this._characterJoiners[0].handler(s)}catch(l){console.error(l)}for(let l=1;l<this._characterJoiners.length;l++)try{let a=this._characterJoiners[l].handler(s);for(let c=0;c<a.length;c++)Ja._mergeRanges(o,a[c])}catch(a){console.error(a)}return this._stringRangesToCellRanges(o,n,i),o}_stringRangesToCellRanges(e,t,r){let n=0,i=!1,s=0,o=e[n];if(o){for(let l=r;l<this._bufferService.cols;l++){let a=t.getWidth(l),c=t.getString(l).length||qn.length;if(a!==0){if(!i&&o[0]<=s&&(o[0]=l,i=!0),o[1]<=s){if(o[1]=l,o=e[++n],!o)break;o[0]<=s?(o[0]=l,i=!0):i=!1}s+=c}}o&&(o[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let r=!1;for(let n=0;n<e.length;n++){let i=e[n];if(r){if(t[1]<=i[0])return e[n-1][1]=t[1],e;if(t[1]<=i[1])return e[n-1][1]=Math.max(t[1],i[1]),e.splice(n,1),e;e.splice(n,1),n--}else{if(t[1]<=i[0])return e.splice(n,0,t),e;if(t[1]<=i[1])return i[0]=Math.min(t[0],i[0]),e;t[0]<i[1]&&(i[0]=Math.min(t[0],i[0]),r=!0);continue}}return r?e[e.length-1][1]=t[1]:e.push(t),e}};Ja=ut([ue(0,tr)],Ja);function wR(e){return 57508<=e&&e<=57558}function SR(e){return 9472<=e&&e<=9631}function kR(e){return wR(e)||SR(e)}function CR(){return{css:{canvas:zl(),cell:zl()},device:{canvas:zl(),cell:zl(),char:{width:0,height:0,left:0,top:0}}}}function zl(){return{width:0,height:0}}var vd=class{constructor(e,t,r,n,i,s,o){this._document=e,this._characterJoinerService=t,this._optionsService=r,this._coreBrowserService=n,this._coreService=i,this._decorationService=s,this._themeService=o,this._workCell=new Ar,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,r){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=r}createRow(e,t,r,n,i,s,o,l,a,c,d){let h=[],f=this._characterJoinerService.getJoinedCharacters(t),p=this._themeService.colors,m=e.getNoBgTrimmedLength();r&&m<s+1&&(m=s+1);let _,b=0,g="",v=0,y=0,S=0,R=0,E=!1,P=0,N=!1,D=0,k=0,B=[],j=c!==-1&&d!==-1;for(let M=0;M<m;M++){e.loadCell(M,this._workCell);let C=this._workCell.getWidth();if(C===0)continue;let A=!1,O=M>=k,U=M,L=this._workCell;if(f.length>0&&M===f[0][0]&&O){let de=f.shift(),Te=this._isCellInSelection(de[0],t);for(v=de[0]+1;v<de[1];v++)O&&(O=Te===this._isCellInSelection(v,t));O&&(O=!r||s<de[0]||s>=de[1]),O?(A=!0,L=new bR(this._workCell,e.translateToString(!0,de[0],de[1]),de[1]-de[0]),U=de[1]-1,C=L.getWidth()):k=de[1]}let $=this._isCellInSelection(M,t),w=r&&M===s,ee=j&&M>=c&&M<=d,ne=!1;this._decorationService.forEachDecorationAtCell(M,t,void 0,de=>{ne=!0});let T=L.getChars()||qn;if(T===" "&&(L.isUnderline()||L.isOverline())&&(T=" "),D=C*l-a.get(T,L.isBold(),L.isItalic()),!_)_=this._document.createElement("span");else if(b&&($&&N||!$&&!N&&L.bg===y)&&($&&N&&p.selectionForeground||L.fg===S)&&L.extended.ext===R&&ee===E&&D===P&&!w&&!A&&!ne&&O){L.isInvisible()?g+=qn:g+=T,b++;continue}else b&&(_.textContent=g),_=this._document.createElement("span"),b=0,g="";if(y=L.bg,S=L.fg,R=L.extended.ext,E=ee,P=D,N=$,A&&s>=M&&s<=U&&(s=M),!this._coreService.isCursorHidden&&w&&this._coreService.isCursorInitialized){if(B.push("xterm-cursor"),this._coreBrowserService.isFocused)o&&B.push("xterm-cursor-blink"),B.push(n==="bar"?"xterm-cursor-bar":n==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(i)switch(i){case"outline":B.push("xterm-cursor-outline");break;case"block":B.push("xterm-cursor-block");break;case"bar":B.push("xterm-cursor-bar");break;case"underline":B.push("xterm-cursor-underline");break}}if(L.isBold()&&B.push("xterm-bold"),L.isItalic()&&B.push("xterm-italic"),L.isDim()&&B.push("xterm-dim"),L.isInvisible()?g=qn:g=L.getChars()||qn,L.isUnderline()&&(B.push(`xterm-underline-${L.extended.underlineStyle}`),g===" "&&(g=" "),!L.isUnderlineColorDefault()))if(L.isUnderlineColorRGB())_.style.textDecorationColor=`rgb(${hl.toColorRGB(L.getUnderlineColor()).join(",")})`;else{let de=L.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&L.isBold()&&de<8&&(de+=8),_.style.textDecorationColor=p.ansi[de].css}L.isOverline()&&(B.push("xterm-overline"),g===" "&&(g=" ")),L.isStrikethrough()&&B.push("xterm-strikethrough"),ee&&(_.style.textDecoration="underline");let X=L.getFgColor(),I=L.getFgColorMode(),F=L.getBgColor(),G=L.getBgColorMode(),he=!!L.isInverse();if(he){let de=X;X=F,F=de;let Te=I;I=G,G=Te}let me,je,Pe=!1;this._decorationService.forEachDecorationAtCell(M,t,void 0,de=>{de.options.layer!=="top"&&Pe||(de.backgroundColorRGB&&(G=50331648,F=de.backgroundColorRGB.rgba>>8&16777215,me=de.backgroundColorRGB),de.foregroundColorRGB&&(I=50331648,X=de.foregroundColorRGB.rgba>>8&16777215,je=de.foregroundColorRGB),Pe=de.options.layer==="top")}),!Pe&&$&&(me=this._coreBrowserService.isFocused?p.selectionBackgroundOpaque:p.selectionInactiveBackgroundOpaque,F=me.rgba>>8&16777215,G=50331648,Pe=!0,p.selectionForeground&&(I=50331648,X=p.selectionForeground.rgba>>8&16777215,je=p.selectionForeground)),Pe&&B.push("xterm-decoration-top");let Ce;switch(G){case 16777216:case 33554432:Ce=p.ansi[F],B.push(`xterm-bg-${F}`);break;case 50331648:Ce=_t.toColor(F>>16,F>>8&255,F&255),this._addStyle(_,`background-color:#${Zg((F>>>0).toString(16),"0",6)}`);break;case 0:default:he?(Ce=p.foreground,B.push("xterm-bg-257")):Ce=p.background}switch(me||L.isDim()&&(me=Ze.multiplyOpacity(Ce,.5)),I){case 16777216:case 33554432:L.isBold()&&X<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(X+=8),this._applyMinimumContrast(_,Ce,p.ansi[X],L,me,void 0)||B.push(`xterm-fg-${X}`);break;case 50331648:let de=_t.toColor(X>>16&255,X>>8&255,X&255);this._applyMinimumContrast(_,Ce,de,L,me,je)||this._addStyle(_,`color:#${Zg(X.toString(16),"0",6)}`);break;case 0:default:this._applyMinimumContrast(_,Ce,p.foreground,L,me,je)||he&&B.push("xterm-fg-257")}B.length&&(_.className=B.join(" "),B.length=0),!w&&!A&&!ne&&O?b++:_.textContent=g,D!==this.defaultSpacing&&(_.style.letterSpacing=`${D}px`),h.push(_),M=U}return _&&b&&(_.textContent=g),h}_applyMinimumContrast(e,t,r,n,i,s){if(this._optionsService.rawOptions.minimumContrastRatio===1||kR(n.getCode()))return!1;let o=this._getContrastCache(n),l;if(!i&&!s&&(l=o.getColor(t.rgba,r.rgba)),l===void 0){let a=this._optionsService.rawOptions.minimumContrastRatio/(n.isDim()?2:1);l=Ze.ensureContrastRatio(i||t,s||r,a),o.setColor((i||t).rgba,(s||r).rgba,l??null)}return l?(this._addStyle(e,`color:${l.css}`),!0):!1}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,t){e.setAttribute("style",`${e.getAttribute("style")||""}${t};`)}_isCellInSelection(e,t){let r=this._selectionStart,n=this._selectionEnd;return!r||!n?!1:this._columnSelectMode?r[0]<=n[0]?e>=r[0]&&t>=r[1]&&e<n[0]&&t<=n[1]:e<r[0]&&t>=r[1]&&e>=n[0]&&t<=n[1]:t>r[1]&&t<n[1]||r[1]===n[1]&&t===r[1]&&e>=r[0]&&e<n[0]||r[1]<n[1]&&t===n[1]&&e<n[0]||r[1]<n[1]&&t===r[1]&&e>=r[0]}};vd=ut([ue(1,G0),ue(2,rr),ue(3,Tn),ue(4,Ki),ue(5,dl),ue(6,Ds)],vd);function Zg(e,t,r){for(;e.length<r;)e=t+e;return e}var ER=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 r=e.createElement("span");r.classList.add("xterm-char-measure-element");let n=e.createElement("span");n.classList.add("xterm-char-measure-element"),n.style.fontWeight="bold";let i=e.createElement("span");i.classList.add("xterm-char-measure-element"),i.style.fontStyle="italic";let s=e.createElement("span");s.classList.add("xterm-char-measure-element"),s.style.fontWeight="bold",s.style.fontStyle="italic",this._measureElements=[r,n,i,s],this._container.appendChild(r),this._container.appendChild(n),this._container.appendChild(i),this._container.appendChild(s),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,r,n){e===this._font&&t===this._fontSize&&r===this._weight&&n===this._weightBold||(this._font=e,this._fontSize=t,this._weight=r,this._weightBold=n,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${r}`,this._measureElements[1].style.fontWeight=`${n}`,this._measureElements[2].style.fontWeight=`${r}`,this._measureElements[3].style.fontWeight=`${n}`,this.clear())}get(e,t,r){let n=0;if(!t&&!r&&e.length===1&&(n=e.charCodeAt(0))<256){if(this._flat[n]!==-9999)return this._flat[n];let o=this._measure(e,0);return o>0&&(this._flat[n]=o),o}let i=e;t&&(i+="B"),r&&(i+="I");let s=this._holey.get(i);if(s===void 0){let o=0;t&&(o|=1),r&&(o|=2),s=this._measure(e,o),s>0&&this._holey.set(i,s)}return s}_measure(e,t){let r=this._measureElements[t];return r.textContent=e.repeat(32),r.offsetWidth/32}},NR=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,r,n=!1){if(this.selectionStart=t,this.selectionEnd=r,!t||!r||t[0]===r[0]&&t[1]===r[1]){this.clear();return}let i=e.buffers.active.ydisp,s=t[1]-i,o=r[1]-i,l=Math.max(s,0),a=Math.min(o,e.rows-1);if(l>=e.rows||a<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=n,this.viewportStartRow=s,this.viewportEndRow=o,this.viewportCappedStartRow=l,this.viewportCappedEndRow=a,this.startCol=t[0],this.endCol=r[0]}isCellSelected(e,t,r){return this.hasSelection?(r-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&r>=this.viewportCappedStartRow&&t<this.endCol&&r<=this.viewportCappedEndRow:t<this.startCol&&r>=this.viewportCappedStartRow&&t>=this.endCol&&r<=this.viewportCappedEndRow:r>this.viewportStartRow&&r<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&r===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&r===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&r===this.viewportStartRow&&t>=this.startCol):!1}};function TR(){return new NR}var Nu="xterm-dom-renderer-owner-",Er="xterm-rows",$l="xterm-fg-",e_="xterm-bg-",Ys="xterm-focus",Fl="xterm-selection",PR=1,xd=class extends Be{constructor(e,t,r,n,i,s,o,l,a,c,d,h,f,p){super(),this._terminal=e,this._document=t,this._element=r,this._screenElement=n,this._viewportElement=i,this._helperContainer=s,this._linkifier2=o,this._charSizeService=a,this._optionsService=c,this._bufferService=d,this._coreService=h,this._coreBrowserService=f,this._themeService=p,this._terminalClass=PR++,this._rowElements=[],this._selectionRenderModel=TR(),this.onRequestRedraw=this._register(new ae).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(Er),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(Fl),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=CR(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(m=>this._injectCss(m))),this._injectCss(this._themeService.colors),this._rowFactory=l.createInstance(vd,document),this._element.classList.add(Nu+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(m=>this._handleLinkHover(m))),this._register(this._linkifier2.onHideLinkUnderline(m=>this._handleLinkLeave(m))),this._register(rt(()=>{this._element.classList.remove(Nu+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new ER(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 r of this._rowElements)r.style.width=`${this.dimensions.css.canvas.width}px`,r.style.height=`${this.dimensions.css.cell.height}px`,r.style.lineHeight=`${this.dimensions.css.cell.height}px`,r.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${Er} 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} .${Er} { 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} .${Er} .xterm-dim { color: ${Ze.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 r=`blink_underline_${this._terminalClass}`,n=`blink_bar_${this._terminalClass}`,i=`blink_block_${this._terminalClass}`;t+=`@keyframes ${r} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${n} { 50% { box-shadow: none; }}`,t+=`@keyframes ${i} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${Er}.${Ys} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${Er}.${Ys} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${Er}.${Ys} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${Er} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${Er} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${Er} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${Er} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${Er} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${Fl} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${Fl} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${Fl} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[s,o]of e.ansi.entries())t+=`${this._terminalSelector} .${$l}${s} { color: ${o.css}; }${this._terminalSelector} .${$l}${s}.xterm-dim { color: ${Ze.multiplyOpacity(o,.5).css}; }${this._terminalSelector} .${e_}${s} { background-color: ${o.css}; }`;t+=`${this._terminalSelector} .${$l}257 { color: ${Ze.opaque(e.background).css}; }${this._terminalSelector} .${$l}257.xterm-dim { color: ${Ze.multiplyOpacity(Ze.opaque(e.background),.5).css}; }${this._terminalSelector} .${e_}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 r=this._rowElements.length;r<=t;r++){let n=this._document.createElement("div");this._rowContainer.appendChild(n),this._rowElements.push(n)}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(Ys),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(Ys),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,r){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,r),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,r),!this._selectionRenderModel.hasSelection))return;let n=this._selectionRenderModel.viewportStartRow,i=this._selectionRenderModel.viewportEndRow,s=this._selectionRenderModel.viewportCappedStartRow,o=this._selectionRenderModel.viewportCappedEndRow,l=this._document.createDocumentFragment();if(r){let a=e[0]>t[0];l.appendChild(this._createSelectionElement(s,a?t[0]:e[0],a?e[0]:t[0],o-s+1))}else{let a=n===s?e[0]:0,c=s===i?t[0]:this._bufferService.cols;l.appendChild(this._createSelectionElement(s,a,c));let d=o-s-1;if(l.appendChild(this._createSelectionElement(s+1,0,this._bufferService.cols,d)),s!==o){let h=i===o?t[0]:this._bufferService.cols;l.appendChild(this._createSelectionElement(o,0,h))}}this._selectionContainer.appendChild(l)}_createSelectionElement(e,t,r,n=1){let i=this._document.createElement("div"),s=t*this.dimensions.css.cell.width,o=this.dimensions.css.cell.width*(r-t);return s+o>this.dimensions.css.canvas.width&&(o=this.dimensions.css.canvas.width-s),i.style.height=`${n*this.dimensions.css.cell.height}px`,i.style.top=`${e*this.dimensions.css.cell.height}px`,i.style.left=`${s}px`,i.style.width=`${o}px`,i}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 r=this._bufferService.buffer,n=r.ybase+r.y,i=Math.min(r.x,this._bufferService.cols-1),s=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,o=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,l=this._optionsService.rawOptions.cursorInactiveStyle;for(let a=e;a<=t;a++){let c=a+r.ydisp,d=this._rowElements[a],h=r.lines.get(c);if(!d||!h)break;d.replaceChildren(...this._rowFactory.createRow(h,c,c===n,o,l,i,s,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${Nu}${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,r,n,i,s){r<0&&(e=0),n<0&&(t=0);let o=this._bufferService.rows-1;r=Math.max(Math.min(r,o),0),n=Math.max(Math.min(n,o),0),i=Math.min(i,this._bufferService.cols);let l=this._bufferService.buffer,a=l.ybase+l.y,c=Math.min(l.x,i-1),d=this._optionsService.rawOptions.cursorBlink,h=this._optionsService.rawOptions.cursorStyle,f=this._optionsService.rawOptions.cursorInactiveStyle;for(let p=r;p<=n;++p){let m=p+l.ydisp,_=this._rowElements[p],b=l.lines.get(m);if(!_||!b)break;_.replaceChildren(...this._rowFactory.createRow(b,m,m===a,h,f,c,d,this.dimensions.css.cell.width,this._widthCache,s?p===r?e:0:-1,s?(p===n?t:i)-1:-1))}}};xd=ut([ue(7,rp),ue(8,Pc),ue(9,rr),ue(10,tr),ue(11,Ki),ue(12,Tn),ue(13,Ds)],xd);var yd=class extends Be{constructor(e,t,r){super(),this._optionsService=r,this.width=0,this.height=0,this._onCharSizeChange=this._register(new ae),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new MR(this._optionsService))}catch{this._measureStrategy=this._register(new RR(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())}};yd=ut([ue(2,rr)],yd);var m1=class extends Be{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(e,t){e!==void 0&&e>0&&t!==void 0&&t>0&&(this._result.width=e,this._result.height=t)}},RR=class extends m1{constructor(e,t,r){super(),this._document=e,this._parentElement=t,this._optionsService=r,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}},MR=class extends m1{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}},LR=class extends Be{constructor(e,t,r){super(),this._textarea=e,this._window=t,this.mainDocument=r,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new IR(this._window)),this._onDprChange=this._register(new ae),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new ae),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(n=>this._screenDprMonitor.setWindow(n))),this._register(Bt.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(Ne(this._textarea,"focus",()=>this._isFocused=!0)),this._register(Ne(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}},IR=class extends Be{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new Ts),this._onDprChange=this._register(new ae),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(rt(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=Ne(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)}},jR=class extends Be{constructor(){super(),this.linkProviders=[],this._register(rt(()=>this.linkProviders.length=0))}registerLinkProvider(e){return this.linkProviders.push(e),{dispose:()=>{let t=this.linkProviders.indexOf(e);t!==-1&&this.linkProviders.splice(t,1)}}}};function up(e,t,r){let n=r.getBoundingClientRect(),i=e.getComputedStyle(r),s=parseInt(i.getPropertyValue("padding-left")),o=parseInt(i.getPropertyValue("padding-top"));return[t.clientX-n.left-s,t.clientY-n.top-o]}function DR(e,t,r,n,i,s,o,l,a){if(!s)return;let c=up(e,t,r);if(c)return c[0]=Math.ceil((c[0]+(a?o/2:0))/o),c[1]=Math.ceil(c[1]/l),c[0]=Math.min(Math.max(c[0],1),n+(a?1:0)),c[1]=Math.min(Math.max(c[1],1),i),c}var bd=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,r,n,i){return DR(window,e,t,r,n,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,i)}getMouseReportCoords(e,t){let r=up(window,e,t);if(this._charSizeService.hasValidSize)return r[0]=Math.min(Math.max(r[0],0),this._renderService.dimensions.css.canvas.width-1),r[1]=Math.min(Math.max(r[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(r[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(r[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(r[0]),y:Math.floor(r[1])}}};bd=ut([ue(0,Pn),ue(1,Pc)],bd);var AR=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,r){this._rowCount=r,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=[]}},g1={};VP(g1,{getSafariVersion:()=>OR,isChromeOS:()=>y1,isFirefox:()=>_1,isIpad:()=>zR,isIphone:()=>$R,isLegacyEdge:()=>BR,isLinux:()=>hp,isMac:()=>Za,isNode:()=>Rc,isSafari:()=>v1,isWindows:()=>x1});var Rc=typeof process<"u"&&"title"in process,fl=Rc?"node":navigator.userAgent,pl=Rc?"node":navigator.platform,_1=fl.includes("Firefox"),BR=fl.includes("Edge"),v1=/^((?!chrome|android).)*safari/i.test(fl);function OR(){if(!v1)return 0;let e=fl.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var Za=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(pl),zR=pl==="iPad",$R=pl==="iPhone",x1=["Windows","Win16","Win32","WinCE"].includes(pl),hp=pl.indexOf("Linux")>=0,y1=/\bCrOS\b/.test(fl),b1=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(e){this._idleCallback=void 0;let t=0,r=0,n=e.timeRemaining(),i=0;for(;this._i<this._tasks.length;){if(t=performance.now(),this._tasks[this._i]()||this._i++,t=Math.max(1,performance.now()-t),r=Math.max(t,r),i=e.timeRemaining(),r*1.5>i){n-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(n-t))}ms`),this._start();return}n=i}this.clear()}},FR=class extends b1{_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())}}},WR=class extends b1{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},ec=!Rc&&"requestIdleCallback"in window?WR:FR,HR=class{constructor(){this._queue=new ec}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},wd=class extends Be{constructor(e,t,r,n,i,s,o,l,a){super(),this._rowCount=e,this._optionsService=r,this._charSizeService=n,this._coreService=i,this._coreBrowserService=l,this._renderer=this._register(new Ts),this._pausedResizeTask=new HR,this._observerDisposable=this._register(new Ts),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 ae),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new ae),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new ae),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new ae),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new AR((c,d)=>this._renderRows(c,d),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new UR(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(rt(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(o.onResize(()=>this._fullRefresh())),this._register(o.buffers.onBufferActivate(()=>{var c;return(c=this._renderer.value)==null?void 0:c.clear()})),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(s.onDecorationRegistered(()=>this._fullRefresh())),this._register(s.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(o.cols,o.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(o.buffer.y,o.buffer.y,!0))),this._register(a.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(c=>this._registerIntersectionObserver(c,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if("IntersectionObserver"in e){let r=new e.IntersectionObserver(n=>this._handleIntersectionChange(n[n.length-1]),{threshold:0});r.observe(t),this._observerDisposable.value=rt(()=>r.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,r=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let n=this._syncOutputHandler.flush();n&&(e=Math.min(e,n.start),t=Math.max(t,n.end)),r||(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 r;return(r=this._renderer.value)==null?void 0:r.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,r){var n;this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=r,(n=this._renderer.value)==null||n.handleSelectionChanged(e,t,r)}handleCursorMove(){var e;(e=this._renderer.value)==null||e.handleCursorMove()}clear(){var e;(e=this._renderer.value)==null||e.clear()}};wd=ut([ue(2,rr),ue(3,Pc),ue(4,Ki),ue(5,dl),ue(6,tr),ue(7,Tn),ue(8,Ds)],wd);var UR=class{constructor(e,t,r){this._coreBrowserService=e,this._coreService=t,this._onTimeout=r,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(e,t){this._isBuffering?(this._start=Math.min(this._start,e),this._end=Math.max(this._end,t)):(this._start=e,this._end=t,this._isBuffering=!0),this._timeout===void 0&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let e={start:this._start,end:this._end};return this._isBuffering=!1,e}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function KR(e,t,r,n){let i=r.buffer.x,s=r.buffer.y;if(!r.buffer.hasScrollback)return YR(i,s,e,t,r,n)+Mc(s,t,r,n)+XR(i,s,e,t,r,n);let o;if(s===t)return o=i>e?"D":"C",Xo(Math.abs(i-e),Yo(o,n));o=s>t?"D":"C";let l=Math.abs(s-t),a=qR(s>t?e:i,r)+(l-1)*r.cols+1+VR(s>t?i:e);return Xo(a,Yo(o,n))}function VR(e,t){return e-1}function qR(e,t){return t.cols-e}function YR(e,t,r,n,i,s){return Mc(t,n,i,s).length===0?"":Xo(S1(e,t,e,t-Fi(t,i),!1,i).length,Yo("D",s))}function Mc(e,t,r,n){let i=e-Fi(e,r),s=t-Fi(t,r),o=Math.abs(i-s)-GR(e,t,r);return Xo(o,Yo(w1(e,t),n))}function XR(e,t,r,n,i,s){let o;Mc(t,n,i,s).length>0?o=n-Fi(n,i):o=t;let l=n,a=QR(e,t,r,n,i,s);return Xo(S1(e,o,r,l,a==="C",i).length,Yo(a,s))}function GR(e,t,r){var o;let n=0,i=e-Fi(e,r),s=t-Fi(t,r);for(let l=0;l<Math.abs(i-s);l++){let a=w1(e,t)==="A"?-1:1;(o=r.buffer.lines.get(i+a*l))!=null&&o.isWrapped&&n++}return n}function Fi(e,t){let r=0,n=t.buffer.lines.get(e),i=n==null?void 0:n.isWrapped;for(;i&&e>=0&&e<t.rows;)r++,n=t.buffer.lines.get(--e),i=n==null?void 0:n.isWrapped;return r}function QR(e,t,r,n,i,s){let o;return Mc(r,n,i,s).length>0?o=n-Fi(n,i):o=t,e<r&&o<=n||e>=r&&o<n?"C":"D"}function w1(e,t){return e>t?"A":"B"}function S1(e,t,r,n,i,s){let o=e,l=t,a="";for(;(o!==r||l!==n)&&l>=0&&l<s.buffer.lines.length;)o+=i?1:-1,i&&o>s.cols-1?(a+=s.buffer.translateBufferLineToString(l,!1,e,o),o=0,e=0,l++):!i&&o<0&&(a+=s.buffer.translateBufferLineToString(l,!1,0,e+1),o=s.cols-1,e=o,l--);return a+s.buffer.translateBufferLineToString(l,!1,e,o)}function Yo(e,t){let r=t?"O":"[";return Q.ESC+r+e}function Xo(e,t){e=Math.floor(e);let r="";for(let n=0;n<e;n++)r+=t;return r}var JR=class{constructor(e){this._bufferService=e,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:!this.selectionEnd||!this.selectionStart?this.selectionStart:this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?e%this._bufferService.cols===0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)-1]:[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[e,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[Math.max(e,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let e=this.selectionStart,t=this.selectionEnd;return!e||!t?!1:e[1]>t[1]||e[1]===t[1]&&e[0]>t[0]}handleTrim(e){return this.selectionStart&&(this.selectionStart[1]-=e),this.selectionEnd&&(this.selectionEnd[1]-=e),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}};function t_(e,t){if(e.start.y>e.end.y)throw new Error(`Buffer range end (${e.end.x}, ${e.end.y}) cannot be before start (${e.start.x}, ${e.start.y})`);return t*(e.end.y-e.start.y)+(e.end.x-e.start.x+1)}var Tu=50,ZR=15,eM=50,tM=500,rM=" ",nM=new RegExp(rM,"g"),Sd=class extends Be{constructor(e,t,r,n,i,s,o,l,a){super(),this._element=e,this._screenElement=t,this._linkifier=r,this._bufferService=n,this._coreService=i,this._mouseService=s,this._optionsService=o,this._renderService=l,this._coreBrowserService=a,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new Ar,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new ae),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new ae),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new ae),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new ae),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=c=>this._handleMouseMove(c),this._mouseUpListener=c=>this._handleMouseUp(c),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(c=>this._handleTrim(c)),this._register(this._bufferService.buffers.onBufferActivate(c=>this._handleBufferActivate(c))),this.enable(),this._model=new JR(this._bufferService),this._activeSelectionMode=0,this._register(rt(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(c=>{c.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 r=this._bufferService.buffer,n=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return"";let i=e[0]<t[0]?e[0]:t[0],s=e[0]<t[0]?t[0]:e[0];for(let o=e[1];o<=t[1];o++){let l=r.translateBufferLineToString(o,!0,i,s);n.push(l)}}else{let i=e[1]===t[1]?t[0]:void 0;n.push(r.translateBufferLineToString(e[1],!0,e[0],i));for(let s=e[1]+1;s<=t[1]-1;s++){let o=r.lines.get(s),l=r.translateBufferLineToString(s,!0);o!=null&&o.isWrapped?n[n.length-1]+=l:n.push(l)}if(e[1]!==t[1]){let s=r.lines.get(t[1]),o=r.translateBufferLineToString(t[1],!0,0,t[0]);s&&s.isWrapped?n[n.length-1]+=o:n.push(o)}}return n.map(i=>i.replace(nM," ")).join(x1?`\r
|
|
126
|
+
`,e.VT="\v",e.FF="\f",e.CR="\r",e.SO="",e.SI="",e.DLE="",e.DC1="",e.DC2="",e.DC3="",e.DC4="",e.NAK="",e.SYN="",e.ETB="",e.CAN="",e.EM="",e.SUB="",e.ESC="\x1B",e.FS="",e.GS="",e.RS="",e.US="",e.SP=" ",e.DEL=""))(Q||(Q={}));var ha;(e=>(e.PAD="",e.HOP="",e.BPH="",e.NBH="",e.IND="",e.NEL="
",e.SSA="",e.ESA="",e.HTS="",e.HTJ="",e.VTS="",e.PLD="",e.PLU="",e.RI="",e.SS2="",e.SS3="",e.DCS="",e.PU1="",e.PU2="",e.STS="",e.CCH="",e.MW="",e.SPA="",e.EPA="",e.SOS="",e.SGCI="",e.SCI="",e.CSI="",e.ST="",e.OSC="",e.PM="",e.APC=""))(ha||(ha={}));var p1;(e=>e.ST=`${Q.ESC}\\`)(p1||(p1={}));var _d=class{constructor(e,t,r,n,i,s){this._textarea=e,this._compositionView=t,this._bufferService=r,this._optionsService=n,this._coreService=i,this._renderService=s,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 r;t.start+=this._dataAlreadySent.length,this._isComposing?r=this._textarea.value.substring(t.start,this._compositionPosition.start):r=this._textarea.value.substring(t.start),r.length>0&&this._coreService.triggerDataEvent(r,!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,r=t.replace(e,"");this._dataAlreadySent=r,t.length>e.length?this._coreService.triggerDataEvent(r,!0):t.length<e.length?this._coreService.triggerDataEvent(`${Q.DEL}`,!0):t.length===e.length&&t!==e&&this._coreService.triggerDataEvent(t,!0)}},0)}updateCompositionElements(e){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let t=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),r=this._renderService.dimensions.css.cell.height,n=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,i=t*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=i+"px",this._compositionView.style.top=n+"px",this._compositionView.style.height=r+"px",this._compositionView.style.lineHeight=r+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let s=this._compositionView.getBoundingClientRect();this._textarea.style.left=i+"px",this._textarea.style.top=n+"px",this._textarea.style.width=Math.max(s.width,1)+"px",this._textarea.style.height=Math.max(s.height,1)+"px",this._textarea.style.lineHeight=s.height+"px"}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};_d=ut([ue(2,tr),ue(3,rr),ue(4,Ki),ue(5,Pn)],_d);var Rt=0,Mt=0,Lt=0,at=0,Jg={css:"#00000000",rgba:0},_t;(e=>{function t(i,s,o,l){return l!==void 0?`#${pi(i)}${pi(s)}${pi(o)}${pi(l)}`:`#${pi(i)}${pi(s)}${pi(o)}`}e.toCss=t;function r(i,s,o,l=255){return(i<<24|s<<16|o<<8|l)>>>0}e.toRgba=r;function n(i,s,o,l){return{css:e.toCss(i,s,o,l),rgba:e.toRgba(i,s,o,l)}}e.toColor=n})(_t||(_t={}));var Ze;(e=>{function t(a,c){if(at=(c.rgba&255)/255,at===1)return{css:c.css,rgba:c.rgba};let d=c.rgba>>24&255,h=c.rgba>>16&255,f=c.rgba>>8&255,p=a.rgba>>24&255,m=a.rgba>>16&255,_=a.rgba>>8&255;Rt=p+Math.round((d-p)*at),Mt=m+Math.round((h-m)*at),Lt=_+Math.round((f-_)*at);let b=_t.toCss(Rt,Mt,Lt),g=_t.toRgba(Rt,Mt,Lt);return{css:b,rgba:g}}e.blend=t;function r(a){return(a.rgba&255)===255}e.isOpaque=r;function n(a,c,d){let h=da.ensureContrastRatio(a.rgba,c.rgba,d);if(h)return _t.toColor(h>>24&255,h>>16&255,h>>8&255)}e.ensureContrastRatio=n;function i(a){let c=(a.rgba|255)>>>0;return[Rt,Mt,Lt]=da.toChannels(c),{css:_t.toCss(Rt,Mt,Lt),rgba:c}}e.opaque=i;function s(a,c){return at=Math.round(c*255),[Rt,Mt,Lt]=da.toChannels(a.rgba),{css:_t.toCss(Rt,Mt,Lt,at),rgba:_t.toRgba(Rt,Mt,Lt,at)}}e.opacity=s;function o(a,c){return at=a.rgba&255,s(a,at*c/255)}e.multiplyOpacity=o;function l(a){return[a.rgba>>24&255,a.rgba>>16&255,a.rgba>>8&255]}e.toColorRGB=l})(Ze||(Ze={}));var it;(e=>{let t,r;try{let i=document.createElement("canvas");i.width=1,i.height=1;let s=i.getContext("2d",{willReadFrequently:!0});s&&(t=s,t.globalCompositeOperation="copy",r=t.createLinearGradient(0,0,1,1))}catch{}function n(i){if(i.match(/#[\da-f]{3,8}/i))switch(i.length){case 4:return Rt=parseInt(i.slice(1,2).repeat(2),16),Mt=parseInt(i.slice(2,3).repeat(2),16),Lt=parseInt(i.slice(3,4).repeat(2),16),_t.toColor(Rt,Mt,Lt);case 5:return Rt=parseInt(i.slice(1,2).repeat(2),16),Mt=parseInt(i.slice(2,3).repeat(2),16),Lt=parseInt(i.slice(3,4).repeat(2),16),at=parseInt(i.slice(4,5).repeat(2),16),_t.toColor(Rt,Mt,Lt,at);case 7:return{css:i,rgba:(parseInt(i.slice(1),16)<<8|255)>>>0};case 9:return{css:i,rgba:parseInt(i.slice(1),16)>>>0}}let s=i.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(s)return Rt=parseInt(s[1]),Mt=parseInt(s[2]),Lt=parseInt(s[3]),at=Math.round((s[5]===void 0?1:parseFloat(s[5]))*255),_t.toColor(Rt,Mt,Lt,at);if(!t||!r)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=r,t.fillStyle=i,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[Rt,Mt,Lt,at]=t.getImageData(0,0,1,1).data,at!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:_t.toRgba(Rt,Mt,Lt,at),css:i}}e.toColor=n})(it||(it={}));var Xt;(e=>{function t(n){return r(n>>16&255,n>>8&255,n&255)}e.relativeLuminance=t;function r(n,i,s){let o=n/255,l=i/255,a=s/255,c=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),h=a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4);return c*.2126+d*.7152+h*.0722}e.relativeLuminance2=r})(Xt||(Xt={}));var da;(e=>{function t(o,l){if(at=(l&255)/255,at===1)return l;let a=l>>24&255,c=l>>16&255,d=l>>8&255,h=o>>24&255,f=o>>16&255,p=o>>8&255;return Rt=h+Math.round((a-h)*at),Mt=f+Math.round((c-f)*at),Lt=p+Math.round((d-p)*at),_t.toRgba(Rt,Mt,Lt)}e.blend=t;function r(o,l,a){let c=Xt.relativeLuminance(o>>8),d=Xt.relativeLuminance(l>>8);if(un(c,d)<a){if(d<c){let p=n(o,l,a),m=un(c,Xt.relativeLuminance(p>>8));if(m<a){let _=i(o,l,a),b=un(c,Xt.relativeLuminance(_>>8));return m>b?p:_}return p}let h=i(o,l,a),f=un(c,Xt.relativeLuminance(h>>8));if(f<a){let p=n(o,l,a),m=un(c,Xt.relativeLuminance(p>>8));return f>m?h:p}return h}}e.ensureContrastRatio=r;function n(o,l,a){let c=o>>24&255,d=o>>16&255,h=o>>8&255,f=l>>24&255,p=l>>16&255,m=l>>8&255,_=un(Xt.relativeLuminance2(f,p,m),Xt.relativeLuminance2(c,d,h));for(;_<a&&(f>0||p>0||m>0);)f-=Math.max(0,Math.ceil(f*.1)),p-=Math.max(0,Math.ceil(p*.1)),m-=Math.max(0,Math.ceil(m*.1)),_=un(Xt.relativeLuminance2(f,p,m),Xt.relativeLuminance2(c,d,h));return(f<<24|p<<16|m<<8|255)>>>0}e.reduceLuminance=n;function i(o,l,a){let c=o>>24&255,d=o>>16&255,h=o>>8&255,f=l>>24&255,p=l>>16&255,m=l>>8&255,_=un(Xt.relativeLuminance2(f,p,m),Xt.relativeLuminance2(c,d,h));for(;_<a&&(f<255||p<255||m<255);)f=Math.min(255,f+Math.ceil((255-f)*.1)),p=Math.min(255,p+Math.ceil((255-p)*.1)),m=Math.min(255,m+Math.ceil((255-m)*.1)),_=un(Xt.relativeLuminance2(f,p,m),Xt.relativeLuminance2(c,d,h));return(f<<24|p<<16|m<<8|255)>>>0}e.increaseLuminance=i;function s(o){return[o>>24&255,o>>16&255,o>>8&255,o&255]}e.toChannels=s})(da||(da={}));function pi(e){let t=e.toString(16);return t.length<2?"0"+t:t}function un(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var bR=class extends hl{constructor(e,t,r){super(),this.content=0,this.combinedData="",this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=r}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()]}},Ja=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new Ar}register(e){let t={id:this._nextCharacterJoinerId++,handler:e};return this._characterJoiners.push(t),t.id}deregister(e){for(let t=0;t<this._characterJoiners.length;t++)if(this._characterJoiners[t].id===e)return this._characterJoiners.splice(t,1),!0;return!1}getJoinedCharacters(e){if(this._characterJoiners.length===0)return[];let t=this._bufferService.buffer.lines.get(e);if(!t||t.length===0)return[];let r=[],n=t.translateToString(!0),i=0,s=0,o=0,l=t.getFg(0),a=t.getBg(0);for(let c=0;c<t.getTrimmedLength();c++)if(t.loadCell(c,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==l||this._workCell.bg!==a){if(c-i>1){let d=this._getJoinedRanges(n,o,s,t,i);for(let h=0;h<d.length;h++)r.push(d[h])}i=c,o=s,l=this._workCell.fg,a=this._workCell.bg}s+=this._workCell.getChars().length||qn.length}if(this._bufferService.cols-i>1){let c=this._getJoinedRanges(n,o,s,t,i);for(let d=0;d<c.length;d++)r.push(c[d])}return r}_getJoinedRanges(e,t,r,n,i){let s=e.substring(t,r),o=[];try{o=this._characterJoiners[0].handler(s)}catch(l){console.error(l)}for(let l=1;l<this._characterJoiners.length;l++)try{let a=this._characterJoiners[l].handler(s);for(let c=0;c<a.length;c++)Ja._mergeRanges(o,a[c])}catch(a){console.error(a)}return this._stringRangesToCellRanges(o,n,i),o}_stringRangesToCellRanges(e,t,r){let n=0,i=!1,s=0,o=e[n];if(o){for(let l=r;l<this._bufferService.cols;l++){let a=t.getWidth(l),c=t.getString(l).length||qn.length;if(a!==0){if(!i&&o[0]<=s&&(o[0]=l,i=!0),o[1]<=s){if(o[1]=l,o=e[++n],!o)break;o[0]<=s?(o[0]=l,i=!0):i=!1}s+=c}}o&&(o[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let r=!1;for(let n=0;n<e.length;n++){let i=e[n];if(r){if(t[1]<=i[0])return e[n-1][1]=t[1],e;if(t[1]<=i[1])return e[n-1][1]=Math.max(t[1],i[1]),e.splice(n,1),e;e.splice(n,1),n--}else{if(t[1]<=i[0])return e.splice(n,0,t),e;if(t[1]<=i[1])return i[0]=Math.min(t[0],i[0]),e;t[0]<i[1]&&(i[0]=Math.min(t[0],i[0]),r=!0);continue}}return r?e[e.length-1][1]=t[1]:e.push(t),e}};Ja=ut([ue(0,tr)],Ja);function wR(e){return 57508<=e&&e<=57558}function SR(e){return 9472<=e&&e<=9631}function kR(e){return wR(e)||SR(e)}function CR(){return{css:{canvas:zl(),cell:zl()},device:{canvas:zl(),cell:zl(),char:{width:0,height:0,left:0,top:0}}}}function zl(){return{width:0,height:0}}var vd=class{constructor(e,t,r,n,i,s,o){this._document=e,this._characterJoinerService=t,this._optionsService=r,this._coreBrowserService=n,this._coreService=i,this._decorationService=s,this._themeService=o,this._workCell=new Ar,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,r){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=r}createRow(e,t,r,n,i,s,o,l,a,c,d){let h=[],f=this._characterJoinerService.getJoinedCharacters(t),p=this._themeService.colors,m=e.getNoBgTrimmedLength();r&&m<s+1&&(m=s+1);let _,b=0,g="",v=0,y=0,S=0,R=0,E=!1,P=0,N=!1,D=0,k=0,B=[],j=c!==-1&&d!==-1;for(let M=0;M<m;M++){e.loadCell(M,this._workCell);let C=this._workCell.getWidth();if(C===0)continue;let A=!1,O=M>=k,U=M,L=this._workCell;if(f.length>0&&M===f[0][0]&&O){let de=f.shift(),Te=this._isCellInSelection(de[0],t);for(v=de[0]+1;v<de[1];v++)O&&(O=Te===this._isCellInSelection(v,t));O&&(O=!r||s<de[0]||s>=de[1]),O?(A=!0,L=new bR(this._workCell,e.translateToString(!0,de[0],de[1]),de[1]-de[0]),U=de[1]-1,C=L.getWidth()):k=de[1]}let $=this._isCellInSelection(M,t),w=r&&M===s,ee=j&&M>=c&&M<=d,ne=!1;this._decorationService.forEachDecorationAtCell(M,t,void 0,de=>{ne=!0});let T=L.getChars()||qn;if(T===" "&&(L.isUnderline()||L.isOverline())&&(T=" "),D=C*l-a.get(T,L.isBold(),L.isItalic()),!_)_=this._document.createElement("span");else if(b&&($&&N||!$&&!N&&L.bg===y)&&($&&N&&p.selectionForeground||L.fg===S)&&L.extended.ext===R&&ee===E&&D===P&&!w&&!A&&!ne&&O){L.isInvisible()?g+=qn:g+=T,b++;continue}else b&&(_.textContent=g),_=this._document.createElement("span"),b=0,g="";if(y=L.bg,S=L.fg,R=L.extended.ext,E=ee,P=D,N=$,A&&s>=M&&s<=U&&(s=M),!this._coreService.isCursorHidden&&w&&this._coreService.isCursorInitialized){if(B.push("xterm-cursor"),this._coreBrowserService.isFocused)o&&B.push("xterm-cursor-blink"),B.push(n==="bar"?"xterm-cursor-bar":n==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(i)switch(i){case"outline":B.push("xterm-cursor-outline");break;case"block":B.push("xterm-cursor-block");break;case"bar":B.push("xterm-cursor-bar");break;case"underline":B.push("xterm-cursor-underline");break}}if(L.isBold()&&B.push("xterm-bold"),L.isItalic()&&B.push("xterm-italic"),L.isDim()&&B.push("xterm-dim"),L.isInvisible()?g=qn:g=L.getChars()||qn,L.isUnderline()&&(B.push(`xterm-underline-${L.extended.underlineStyle}`),g===" "&&(g=" "),!L.isUnderlineColorDefault()))if(L.isUnderlineColorRGB())_.style.textDecorationColor=`rgb(${hl.toColorRGB(L.getUnderlineColor()).join(",")})`;else{let de=L.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&L.isBold()&&de<8&&(de+=8),_.style.textDecorationColor=p.ansi[de].css}L.isOverline()&&(B.push("xterm-overline"),g===" "&&(g=" ")),L.isStrikethrough()&&B.push("xterm-strikethrough"),ee&&(_.style.textDecoration="underline");let X=L.getFgColor(),I=L.getFgColorMode(),F=L.getBgColor(),G=L.getBgColorMode(),he=!!L.isInverse();if(he){let de=X;X=F,F=de;let Te=I;I=G,G=Te}let me,je,Pe=!1;this._decorationService.forEachDecorationAtCell(M,t,void 0,de=>{de.options.layer!=="top"&&Pe||(de.backgroundColorRGB&&(G=50331648,F=de.backgroundColorRGB.rgba>>8&16777215,me=de.backgroundColorRGB),de.foregroundColorRGB&&(I=50331648,X=de.foregroundColorRGB.rgba>>8&16777215,je=de.foregroundColorRGB),Pe=de.options.layer==="top")}),!Pe&&$&&(me=this._coreBrowserService.isFocused?p.selectionBackgroundOpaque:p.selectionInactiveBackgroundOpaque,F=me.rgba>>8&16777215,G=50331648,Pe=!0,p.selectionForeground&&(I=50331648,X=p.selectionForeground.rgba>>8&16777215,je=p.selectionForeground)),Pe&&B.push("xterm-decoration-top");let Ce;switch(G){case 16777216:case 33554432:Ce=p.ansi[F],B.push(`xterm-bg-${F}`);break;case 50331648:Ce=_t.toColor(F>>16,F>>8&255,F&255),this._addStyle(_,`background-color:#${Zg((F>>>0).toString(16),"0",6)}`);break;case 0:default:he?(Ce=p.foreground,B.push("xterm-bg-257")):Ce=p.background}switch(me||L.isDim()&&(me=Ze.multiplyOpacity(Ce,.5)),I){case 16777216:case 33554432:L.isBold()&&X<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(X+=8),this._applyMinimumContrast(_,Ce,p.ansi[X],L,me,void 0)||B.push(`xterm-fg-${X}`);break;case 50331648:let de=_t.toColor(X>>16&255,X>>8&255,X&255);this._applyMinimumContrast(_,Ce,de,L,me,je)||this._addStyle(_,`color:#${Zg(X.toString(16),"0",6)}`);break;case 0:default:this._applyMinimumContrast(_,Ce,p.foreground,L,me,je)||he&&B.push("xterm-fg-257")}B.length&&(_.className=B.join(" "),B.length=0),!w&&!A&&!ne&&O?b++:_.textContent=g,D!==this.defaultSpacing&&(_.style.letterSpacing=`${D}px`),h.push(_),M=U}return _&&b&&(_.textContent=g),h}_applyMinimumContrast(e,t,r,n,i,s){if(this._optionsService.rawOptions.minimumContrastRatio===1||kR(n.getCode()))return!1;let o=this._getContrastCache(n),l;if(!i&&!s&&(l=o.getColor(t.rgba,r.rgba)),l===void 0){let a=this._optionsService.rawOptions.minimumContrastRatio/(n.isDim()?2:1);l=Ze.ensureContrastRatio(i||t,s||r,a),o.setColor((i||t).rgba,(s||r).rgba,l??null)}return l?(this._addStyle(e,`color:${l.css}`),!0):!1}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,t){e.setAttribute("style",`${e.getAttribute("style")||""}${t};`)}_isCellInSelection(e,t){let r=this._selectionStart,n=this._selectionEnd;return!r||!n?!1:this._columnSelectMode?r[0]<=n[0]?e>=r[0]&&t>=r[1]&&e<n[0]&&t<=n[1]:e<r[0]&&t>=r[1]&&e>=n[0]&&t<=n[1]:t>r[1]&&t<n[1]||r[1]===n[1]&&t===r[1]&&e>=r[0]&&e<n[0]||r[1]<n[1]&&t===n[1]&&e<n[0]||r[1]<n[1]&&t===r[1]&&e>=r[0]}};vd=ut([ue(1,G0),ue(2,rr),ue(3,Tn),ue(4,Ki),ue(5,dl),ue(6,Ds)],vd);function Zg(e,t,r){for(;e.length<r;)e=t+e;return e}var ER=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 r=e.createElement("span");r.classList.add("xterm-char-measure-element");let n=e.createElement("span");n.classList.add("xterm-char-measure-element"),n.style.fontWeight="bold";let i=e.createElement("span");i.classList.add("xterm-char-measure-element"),i.style.fontStyle="italic";let s=e.createElement("span");s.classList.add("xterm-char-measure-element"),s.style.fontWeight="bold",s.style.fontStyle="italic",this._measureElements=[r,n,i,s],this._container.appendChild(r),this._container.appendChild(n),this._container.appendChild(i),this._container.appendChild(s),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,r,n){e===this._font&&t===this._fontSize&&r===this._weight&&n===this._weightBold||(this._font=e,this._fontSize=t,this._weight=r,this._weightBold=n,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${r}`,this._measureElements[1].style.fontWeight=`${n}`,this._measureElements[2].style.fontWeight=`${r}`,this._measureElements[3].style.fontWeight=`${n}`,this.clear())}get(e,t,r){let n=0;if(!t&&!r&&e.length===1&&(n=e.charCodeAt(0))<256){if(this._flat[n]!==-9999)return this._flat[n];let o=this._measure(e,0);return o>0&&(this._flat[n]=o),o}let i=e;t&&(i+="B"),r&&(i+="I");let s=this._holey.get(i);if(s===void 0){let o=0;t&&(o|=1),r&&(o|=2),s=this._measure(e,o),s>0&&this._holey.set(i,s)}return s}_measure(e,t){let r=this._measureElements[t];return r.textContent=e.repeat(32),r.offsetWidth/32}},NR=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,r,n=!1){if(this.selectionStart=t,this.selectionEnd=r,!t||!r||t[0]===r[0]&&t[1]===r[1]){this.clear();return}let i=e.buffers.active.ydisp,s=t[1]-i,o=r[1]-i,l=Math.max(s,0),a=Math.min(o,e.rows-1);if(l>=e.rows||a<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=n,this.viewportStartRow=s,this.viewportEndRow=o,this.viewportCappedStartRow=l,this.viewportCappedEndRow=a,this.startCol=t[0],this.endCol=r[0]}isCellSelected(e,t,r){return this.hasSelection?(r-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&r>=this.viewportCappedStartRow&&t<this.endCol&&r<=this.viewportCappedEndRow:t<this.startCol&&r>=this.viewportCappedStartRow&&t>=this.endCol&&r<=this.viewportCappedEndRow:r>this.viewportStartRow&&r<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&r===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&r===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&r===this.viewportStartRow&&t>=this.startCol):!1}};function TR(){return new NR}var Nu="xterm-dom-renderer-owner-",Er="xterm-rows",$l="xterm-fg-",e_="xterm-bg-",Ys="xterm-focus",Fl="xterm-selection",PR=1,xd=class extends Be{constructor(e,t,r,n,i,s,o,l,a,c,d,h,f,p){super(),this._terminal=e,this._document=t,this._element=r,this._screenElement=n,this._viewportElement=i,this._helperContainer=s,this._linkifier2=o,this._charSizeService=a,this._optionsService=c,this._bufferService=d,this._coreService=h,this._coreBrowserService=f,this._themeService=p,this._terminalClass=PR++,this._rowElements=[],this._selectionRenderModel=TR(),this.onRequestRedraw=this._register(new le).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(Er),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(Fl),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=CR(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(m=>this._injectCss(m))),this._injectCss(this._themeService.colors),this._rowFactory=l.createInstance(vd,document),this._element.classList.add(Nu+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(m=>this._handleLinkHover(m))),this._register(this._linkifier2.onHideLinkUnderline(m=>this._handleLinkLeave(m))),this._register(rt(()=>{this._element.classList.remove(Nu+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new ER(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 r of this._rowElements)r.style.width=`${this.dimensions.css.canvas.width}px`,r.style.height=`${this.dimensions.css.cell.height}px`,r.style.lineHeight=`${this.dimensions.css.cell.height}px`,r.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${Er} 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} .${Er} { 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} .${Er} .xterm-dim { color: ${Ze.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 r=`blink_underline_${this._terminalClass}`,n=`blink_bar_${this._terminalClass}`,i=`blink_block_${this._terminalClass}`;t+=`@keyframes ${r} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${n} { 50% { box-shadow: none; }}`,t+=`@keyframes ${i} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${Er}.${Ys} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${Er}.${Ys} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${Er}.${Ys} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${Er} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${Er} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${Er} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${Er} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${Er} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${Fl} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${Fl} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${Fl} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[s,o]of e.ansi.entries())t+=`${this._terminalSelector} .${$l}${s} { color: ${o.css}; }${this._terminalSelector} .${$l}${s}.xterm-dim { color: ${Ze.multiplyOpacity(o,.5).css}; }${this._terminalSelector} .${e_}${s} { background-color: ${o.css}; }`;t+=`${this._terminalSelector} .${$l}257 { color: ${Ze.opaque(e.background).css}; }${this._terminalSelector} .${$l}257.xterm-dim { color: ${Ze.multiplyOpacity(Ze.opaque(e.background),.5).css}; }${this._terminalSelector} .${e_}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 r=this._rowElements.length;r<=t;r++){let n=this._document.createElement("div");this._rowContainer.appendChild(n),this._rowElements.push(n)}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(Ys),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(Ys),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,r){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,r),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,r),!this._selectionRenderModel.hasSelection))return;let n=this._selectionRenderModel.viewportStartRow,i=this._selectionRenderModel.viewportEndRow,s=this._selectionRenderModel.viewportCappedStartRow,o=this._selectionRenderModel.viewportCappedEndRow,l=this._document.createDocumentFragment();if(r){let a=e[0]>t[0];l.appendChild(this._createSelectionElement(s,a?t[0]:e[0],a?e[0]:t[0],o-s+1))}else{let a=n===s?e[0]:0,c=s===i?t[0]:this._bufferService.cols;l.appendChild(this._createSelectionElement(s,a,c));let d=o-s-1;if(l.appendChild(this._createSelectionElement(s+1,0,this._bufferService.cols,d)),s!==o){let h=i===o?t[0]:this._bufferService.cols;l.appendChild(this._createSelectionElement(o,0,h))}}this._selectionContainer.appendChild(l)}_createSelectionElement(e,t,r,n=1){let i=this._document.createElement("div"),s=t*this.dimensions.css.cell.width,o=this.dimensions.css.cell.width*(r-t);return s+o>this.dimensions.css.canvas.width&&(o=this.dimensions.css.canvas.width-s),i.style.height=`${n*this.dimensions.css.cell.height}px`,i.style.top=`${e*this.dimensions.css.cell.height}px`,i.style.left=`${s}px`,i.style.width=`${o}px`,i}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 r=this._bufferService.buffer,n=r.ybase+r.y,i=Math.min(r.x,this._bufferService.cols-1),s=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,o=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,l=this._optionsService.rawOptions.cursorInactiveStyle;for(let a=e;a<=t;a++){let c=a+r.ydisp,d=this._rowElements[a],h=r.lines.get(c);if(!d||!h)break;d.replaceChildren(...this._rowFactory.createRow(h,c,c===n,o,l,i,s,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${Nu}${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,r,n,i,s){r<0&&(e=0),n<0&&(t=0);let o=this._bufferService.rows-1;r=Math.max(Math.min(r,o),0),n=Math.max(Math.min(n,o),0),i=Math.min(i,this._bufferService.cols);let l=this._bufferService.buffer,a=l.ybase+l.y,c=Math.min(l.x,i-1),d=this._optionsService.rawOptions.cursorBlink,h=this._optionsService.rawOptions.cursorStyle,f=this._optionsService.rawOptions.cursorInactiveStyle;for(let p=r;p<=n;++p){let m=p+l.ydisp,_=this._rowElements[p],b=l.lines.get(m);if(!_||!b)break;_.replaceChildren(...this._rowFactory.createRow(b,m,m===a,h,f,c,d,this.dimensions.css.cell.width,this._widthCache,s?p===r?e:0:-1,s?(p===n?t:i)-1:-1))}}};xd=ut([ue(7,rp),ue(8,Pc),ue(9,rr),ue(10,tr),ue(11,Ki),ue(12,Tn),ue(13,Ds)],xd);var yd=class extends Be{constructor(e,t,r){super(),this._optionsService=r,this.width=0,this.height=0,this._onCharSizeChange=this._register(new le),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new MR(this._optionsService))}catch{this._measureStrategy=this._register(new RR(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())}};yd=ut([ue(2,rr)],yd);var m1=class extends Be{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(e,t){e!==void 0&&e>0&&t!==void 0&&t>0&&(this._result.width=e,this._result.height=t)}},RR=class extends m1{constructor(e,t,r){super(),this._document=e,this._parentElement=t,this._optionsService=r,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}},MR=class extends m1{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}},LR=class extends Be{constructor(e,t,r){super(),this._textarea=e,this._window=t,this.mainDocument=r,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new IR(this._window)),this._onDprChange=this._register(new le),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new le),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(n=>this._screenDprMonitor.setWindow(n))),this._register(Bt.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(Ne(this._textarea,"focus",()=>this._isFocused=!0)),this._register(Ne(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}},IR=class extends Be{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new Ts),this._onDprChange=this._register(new le),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(rt(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=Ne(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)}},jR=class extends Be{constructor(){super(),this.linkProviders=[],this._register(rt(()=>this.linkProviders.length=0))}registerLinkProvider(e){return this.linkProviders.push(e),{dispose:()=>{let t=this.linkProviders.indexOf(e);t!==-1&&this.linkProviders.splice(t,1)}}}};function up(e,t,r){let n=r.getBoundingClientRect(),i=e.getComputedStyle(r),s=parseInt(i.getPropertyValue("padding-left")),o=parseInt(i.getPropertyValue("padding-top"));return[t.clientX-n.left-s,t.clientY-n.top-o]}function DR(e,t,r,n,i,s,o,l,a){if(!s)return;let c=up(e,t,r);if(c)return c[0]=Math.ceil((c[0]+(a?o/2:0))/o),c[1]=Math.ceil(c[1]/l),c[0]=Math.min(Math.max(c[0],1),n+(a?1:0)),c[1]=Math.min(Math.max(c[1],1),i),c}var bd=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,r,n,i){return DR(window,e,t,r,n,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,i)}getMouseReportCoords(e,t){let r=up(window,e,t);if(this._charSizeService.hasValidSize)return r[0]=Math.min(Math.max(r[0],0),this._renderService.dimensions.css.canvas.width-1),r[1]=Math.min(Math.max(r[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(r[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(r[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(r[0]),y:Math.floor(r[1])}}};bd=ut([ue(0,Pn),ue(1,Pc)],bd);var AR=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,r){this._rowCount=r,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=[]}},g1={};VP(g1,{getSafariVersion:()=>OR,isChromeOS:()=>y1,isFirefox:()=>_1,isIpad:()=>zR,isIphone:()=>$R,isLegacyEdge:()=>BR,isLinux:()=>hp,isMac:()=>Za,isNode:()=>Rc,isSafari:()=>v1,isWindows:()=>x1});var Rc=typeof process<"u"&&"title"in process,fl=Rc?"node":navigator.userAgent,pl=Rc?"node":navigator.platform,_1=fl.includes("Firefox"),BR=fl.includes("Edge"),v1=/^((?!chrome|android).)*safari/i.test(fl);function OR(){if(!v1)return 0;let e=fl.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var Za=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(pl),zR=pl==="iPad",$R=pl==="iPhone",x1=["Windows","Win16","Win32","WinCE"].includes(pl),hp=pl.indexOf("Linux")>=0,y1=/\bCrOS\b/.test(fl),b1=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(e){this._idleCallback=void 0;let t=0,r=0,n=e.timeRemaining(),i=0;for(;this._i<this._tasks.length;){if(t=performance.now(),this._tasks[this._i]()||this._i++,t=Math.max(1,performance.now()-t),r=Math.max(t,r),i=e.timeRemaining(),r*1.5>i){n-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(n-t))}ms`),this._start();return}n=i}this.clear()}},FR=class extends b1{_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())}}},WR=class extends b1{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},ec=!Rc&&"requestIdleCallback"in window?WR:FR,HR=class{constructor(){this._queue=new ec}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},wd=class extends Be{constructor(e,t,r,n,i,s,o,l,a){super(),this._rowCount=e,this._optionsService=r,this._charSizeService=n,this._coreService=i,this._coreBrowserService=l,this._renderer=this._register(new Ts),this._pausedResizeTask=new HR,this._observerDisposable=this._register(new Ts),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 le),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new le),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new le),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new le),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new AR((c,d)=>this._renderRows(c,d),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new UR(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(rt(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(o.onResize(()=>this._fullRefresh())),this._register(o.buffers.onBufferActivate(()=>{var c;return(c=this._renderer.value)==null?void 0:c.clear()})),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(s.onDecorationRegistered(()=>this._fullRefresh())),this._register(s.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(o.cols,o.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(o.buffer.y,o.buffer.y,!0))),this._register(a.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(c=>this._registerIntersectionObserver(c,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if("IntersectionObserver"in e){let r=new e.IntersectionObserver(n=>this._handleIntersectionChange(n[n.length-1]),{threshold:0});r.observe(t),this._observerDisposable.value=rt(()=>r.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,r=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let n=this._syncOutputHandler.flush();n&&(e=Math.min(e,n.start),t=Math.max(t,n.end)),r||(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 r;return(r=this._renderer.value)==null?void 0:r.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,r){var n;this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=r,(n=this._renderer.value)==null||n.handleSelectionChanged(e,t,r)}handleCursorMove(){var e;(e=this._renderer.value)==null||e.handleCursorMove()}clear(){var e;(e=this._renderer.value)==null||e.clear()}};wd=ut([ue(2,rr),ue(3,Pc),ue(4,Ki),ue(5,dl),ue(6,tr),ue(7,Tn),ue(8,Ds)],wd);var UR=class{constructor(e,t,r){this._coreBrowserService=e,this._coreService=t,this._onTimeout=r,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(e,t){this._isBuffering?(this._start=Math.min(this._start,e),this._end=Math.max(this._end,t)):(this._start=e,this._end=t,this._isBuffering=!0),this._timeout===void 0&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let e={start:this._start,end:this._end};return this._isBuffering=!1,e}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function KR(e,t,r,n){let i=r.buffer.x,s=r.buffer.y;if(!r.buffer.hasScrollback)return YR(i,s,e,t,r,n)+Mc(s,t,r,n)+XR(i,s,e,t,r,n);let o;if(s===t)return o=i>e?"D":"C",Xo(Math.abs(i-e),Yo(o,n));o=s>t?"D":"C";let l=Math.abs(s-t),a=qR(s>t?e:i,r)+(l-1)*r.cols+1+VR(s>t?i:e);return Xo(a,Yo(o,n))}function VR(e,t){return e-1}function qR(e,t){return t.cols-e}function YR(e,t,r,n,i,s){return Mc(t,n,i,s).length===0?"":Xo(S1(e,t,e,t-Fi(t,i),!1,i).length,Yo("D",s))}function Mc(e,t,r,n){let i=e-Fi(e,r),s=t-Fi(t,r),o=Math.abs(i-s)-GR(e,t,r);return Xo(o,Yo(w1(e,t),n))}function XR(e,t,r,n,i,s){let o;Mc(t,n,i,s).length>0?o=n-Fi(n,i):o=t;let l=n,a=QR(e,t,r,n,i,s);return Xo(S1(e,o,r,l,a==="C",i).length,Yo(a,s))}function GR(e,t,r){var o;let n=0,i=e-Fi(e,r),s=t-Fi(t,r);for(let l=0;l<Math.abs(i-s);l++){let a=w1(e,t)==="A"?-1:1;(o=r.buffer.lines.get(i+a*l))!=null&&o.isWrapped&&n++}return n}function Fi(e,t){let r=0,n=t.buffer.lines.get(e),i=n==null?void 0:n.isWrapped;for(;i&&e>=0&&e<t.rows;)r++,n=t.buffer.lines.get(--e),i=n==null?void 0:n.isWrapped;return r}function QR(e,t,r,n,i,s){let o;return Mc(r,n,i,s).length>0?o=n-Fi(n,i):o=t,e<r&&o<=n||e>=r&&o<n?"C":"D"}function w1(e,t){return e>t?"A":"B"}function S1(e,t,r,n,i,s){let o=e,l=t,a="";for(;(o!==r||l!==n)&&l>=0&&l<s.buffer.lines.length;)o+=i?1:-1,i&&o>s.cols-1?(a+=s.buffer.translateBufferLineToString(l,!1,e,o),o=0,e=0,l++):!i&&o<0&&(a+=s.buffer.translateBufferLineToString(l,!1,0,e+1),o=s.cols-1,e=o,l--);return a+s.buffer.translateBufferLineToString(l,!1,e,o)}function Yo(e,t){let r=t?"O":"[";return Q.ESC+r+e}function Xo(e,t){e=Math.floor(e);let r="";for(let n=0;n<e;n++)r+=t;return r}var JR=class{constructor(e){this._bufferService=e,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:!this.selectionEnd||!this.selectionStart?this.selectionStart:this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?e%this._bufferService.cols===0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)-1]:[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[e,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[Math.max(e,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let e=this.selectionStart,t=this.selectionEnd;return!e||!t?!1:e[1]>t[1]||e[1]===t[1]&&e[0]>t[0]}handleTrim(e){return this.selectionStart&&(this.selectionStart[1]-=e),this.selectionEnd&&(this.selectionEnd[1]-=e),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}};function t_(e,t){if(e.start.y>e.end.y)throw new Error(`Buffer range end (${e.end.x}, ${e.end.y}) cannot be before start (${e.start.x}, ${e.start.y})`);return t*(e.end.y-e.start.y)+(e.end.x-e.start.x+1)}var Tu=50,ZR=15,eM=50,tM=500,rM=" ",nM=new RegExp(rM,"g"),Sd=class extends Be{constructor(e,t,r,n,i,s,o,l,a){super(),this._element=e,this._screenElement=t,this._linkifier=r,this._bufferService=n,this._coreService=i,this._mouseService=s,this._optionsService=o,this._renderService=l,this._coreBrowserService=a,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new Ar,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new le),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new le),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new le),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new le),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=c=>this._handleMouseMove(c),this._mouseUpListener=c=>this._handleMouseUp(c),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(c=>this._handleTrim(c)),this._register(this._bufferService.buffers.onBufferActivate(c=>this._handleBufferActivate(c))),this.enable(),this._model=new JR(this._bufferService),this._activeSelectionMode=0,this._register(rt(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(c=>{c.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 r=this._bufferService.buffer,n=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return"";let i=e[0]<t[0]?e[0]:t[0],s=e[0]<t[0]?t[0]:e[0];for(let o=e[1];o<=t[1];o++){let l=r.translateBufferLineToString(o,!0,i,s);n.push(l)}}else{let i=e[1]===t[1]?t[0]:void 0;n.push(r.translateBufferLineToString(e[1],!0,e[0],i));for(let s=e[1]+1;s<=t[1]-1;s++){let o=r.lines.get(s),l=r.translateBufferLineToString(s,!0);o!=null&&o.isWrapped?n[n.length-1]+=l:n.push(l)}if(e[1]!==t[1]){let s=r.lines.get(t[1]),o=r.translateBufferLineToString(t[1],!0,0,t[0]);s&&s.isWrapped?n[n.length-1]+=o:n.push(o)}}return n.map(i=>i.replace(nM," ")).join(x1?`\r
|
|
127
127
|
`:`
|
|
128
|
-
`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),hp&&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),r=this._model.finalSelectionStart,n=this._model.finalSelectionEnd;return!r||!n||!t?!1:this._areCoordsInSelection(t,r,n)}isCellInSelection(e,t){let r=this._model.finalSelectionStart,n=this._model.finalSelectionEnd;return!r||!n?!1:this._areCoordsInSelection([e,t],r,n)}_areCoordsInSelection(e,t,r){return e[1]>t[1]&&e[1]<r[1]||t[1]===r[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<r[0]||t[1]<r[1]&&e[1]===r[1]&&e[0]<r[0]||t[1]<r[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){var i,s;let r=(s=(i=this._linkifier.currentLink)==null?void 0:i.link)==null?void 0:s.range;if(r)return this._model.selectionStart=[r.start.x-1,r.start.y-1],this._model.selectionStartLength=t_(r,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let n=this._getMouseBufferCoords(e);return n?(this._selectWordAt(n,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=up(this._coreBrowserService.window,e,this._screenElement)[1],r=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=r?0:(t>r&&(t-=r),t=Math.min(Math.max(t,-Tu),Tu),t/=Tu,t/Math.abs(t)+Math.round(t*(ZR-1)))}shouldForceSelection(e){return Za?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(),eM)}_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&&!(Za&&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 r=this._bufferService.buffer;if(this._model.selectionEnd[1]<r.lines.length){let n=r.lines.get(this._model.selectionEnd[1]);n&&n.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<tM&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let r=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(r&&r[0]!==void 0&&r[1]!==void 0){let n=KR(r[0]-1,r[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(n,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,r=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);if(!r){this._oldHasSelection&&this._fireOnSelectionChange(e,t,r);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,r)}_fireOnSelectionChange(e,t,r){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=r,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(t=>this._handleTrim(t))}_convertViewportColToCharacterIndex(e,t){let r=t;for(let n=0;t>=n;n++){let i=e.loadCell(n,this._workCell).getChars().length;this._workCell.getWidth()===0?r--:i>1&&t!==n&&(r+=i-1)}return r}setSelection(e,t,r){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=r,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,r=!0,n=!0){if(e[0]>=this._bufferService.cols)return;let i=this._bufferService.buffer,s=i.lines.get(e[1]);if(!s)return;let o=i.translateBufferLineToString(e[1],!1),l=this._convertViewportColToCharacterIndex(s,e[0]),a=l,c=e[0]-l,d=0,h=0,f=0,p=0;if(o.charAt(l)===" "){for(;l>0&&o.charAt(l-1)===" ";)l--;for(;a<o.length&&o.charAt(a+1)===" ";)a++}else{let b=e[0],g=e[0];s.getWidth(b)===0&&(d++,b--),s.getWidth(g)===2&&(h++,g++);let v=s.getString(g).length;for(v>1&&(p+=v-1,a+=v-1);b>0&&l>0&&!this._isCharWordSeparator(s.loadCell(b-1,this._workCell));){s.loadCell(b-1,this._workCell);let y=this._workCell.getChars().length;this._workCell.getWidth()===0?(d++,b--):y>1&&(f+=y-1,l-=y-1),l--,b--}for(;g<s.length&&a+1<o.length&&!this._isCharWordSeparator(s.loadCell(g+1,this._workCell));){s.loadCell(g+1,this._workCell);let y=this._workCell.getChars().length;this._workCell.getWidth()===2?(h++,g++):y>1&&(p+=y-1,a+=y-1),a++,g++}}a++;let m=l+c-d+f,_=Math.min(this._bufferService.cols,a-l+d+h-f-p);if(!(!t&&o.slice(l,a).trim()==="")){if(r&&m===0&&s.getCodePoint(0)!==32){let b=i.lines.get(e[1]-1);if(b&&s.isWrapped&&b.getCodePoint(this._bufferService.cols-1)!==32){let g=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(g){let v=this._bufferService.cols-g.start;m-=v,_+=v}}}if(n&&m+_===this._bufferService.cols&&s.getCodePoint(this._bufferService.cols-1)!==32){let b=i.lines.get(e[1]+1);if(b!=null&&b.isWrapped&&b.getCodePoint(0)!==32){let g=this._getWordAt([0,e[1]+1],!1,!1,!0);g&&(_+=g.length)}}return{start:m,length:_}}}_selectWordAt(e,t){let r=this._getWordAt(e,t);if(r){for(;r.start<0;)r.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[r.start,e[1]],this._model.selectionStartLength=r.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let r=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,r--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,r++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,r]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),r={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=t_(r,this._bufferService.cols)}};Sd=ut([ue(3,tr),ue(4,Ki),ue(5,np),ue(6,rr),ue(7,Pn),ue(8,Tn)],Sd);var r_=class{constructor(){this._data={}}set(e,t,r){this._data[e]||(this._data[e]={}),this._data[e][t]=r}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},n_=class{constructor(){this._color=new r_,this._css=new r_}setCss(e,t,r){this._css.set(e,t,r)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,r){this._color.set(e,t,r)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},yt=Object.freeze((()=>{let e=[it.toColor("#2e3436"),it.toColor("#cc0000"),it.toColor("#4e9a06"),it.toColor("#c4a000"),it.toColor("#3465a4"),it.toColor("#75507b"),it.toColor("#06989a"),it.toColor("#d3d7cf"),it.toColor("#555753"),it.toColor("#ef2929"),it.toColor("#8ae234"),it.toColor("#fce94f"),it.toColor("#729fcf"),it.toColor("#ad7fa8"),it.toColor("#34e2e2"),it.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let r=0;r<216;r++){let n=t[r/36%6|0],i=t[r/6%6|0],s=t[r%6];e.push({css:_t.toCss(n,i,s),rgba:_t.toRgba(n,i,s)})}for(let r=0;r<24;r++){let n=8+r*10;e.push({css:_t.toCss(n,n,n),rgba:_t.toRgba(n,n,n)})}return e})()),wi=it.toColor("#ffffff"),oo=it.toColor("#000000"),i_=it.toColor("#ffffff"),s_=oo,Xs={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},iM=wi,kd=class extends Be{constructor(e){super(),this._optionsService=e,this._contrastCache=new n_,this._halfContrastCache=new n_,this._onChangeColors=this._register(new ae),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:wi,background:oo,cursor:i_,cursorAccent:s_,selectionForeground:void 0,selectionBackgroundTransparent:Xs,selectionBackgroundOpaque:Ze.blend(oo,Xs),selectionInactiveBackgroundTransparent:Xs,selectionInactiveBackgroundOpaque:Ze.blend(oo,Xs),scrollbarSliderBackground:Ze.opacity(wi,.2),scrollbarSliderHoverBackground:Ze.opacity(wi,.4),scrollbarSliderActiveBackground:Ze.opacity(wi,.5),overviewRulerBorder:wi,ansi:yt.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this._register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",()=>this._contrastCache.clear())),this._register(this._optionsService.onSpecificOptionChange("theme",()=>this._setTheme(this._optionsService.rawOptions.theme)))}get colors(){return this._colors}_setTheme(e={}){let t=this._colors;if(t.foreground=qe(e.foreground,wi),t.background=qe(e.background,oo),t.cursor=Ze.blend(t.background,qe(e.cursor,i_)),t.cursorAccent=Ze.blend(t.background,qe(e.cursorAccent,s_)),t.selectionBackgroundTransparent=qe(e.selectionBackground,Xs),t.selectionBackgroundOpaque=Ze.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=qe(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=Ze.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?qe(e.selectionForeground,Jg):void 0,t.selectionForeground===Jg&&(t.selectionForeground=void 0),Ze.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=Ze.opacity(t.selectionBackgroundTransparent,.3)),Ze.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=Ze.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=qe(e.scrollbarSliderBackground,Ze.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=qe(e.scrollbarSliderHoverBackground,Ze.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=qe(e.scrollbarSliderActiveBackground,Ze.opacity(t.foreground,.5)),t.overviewRulerBorder=qe(e.overviewRulerBorder,iM),t.ansi=yt.slice(),t.ansi[0]=qe(e.black,yt[0]),t.ansi[1]=qe(e.red,yt[1]),t.ansi[2]=qe(e.green,yt[2]),t.ansi[3]=qe(e.yellow,yt[3]),t.ansi[4]=qe(e.blue,yt[4]),t.ansi[5]=qe(e.magenta,yt[5]),t.ansi[6]=qe(e.cyan,yt[6]),t.ansi[7]=qe(e.white,yt[7]),t.ansi[8]=qe(e.brightBlack,yt[8]),t.ansi[9]=qe(e.brightRed,yt[9]),t.ansi[10]=qe(e.brightGreen,yt[10]),t.ansi[11]=qe(e.brightYellow,yt[11]),t.ansi[12]=qe(e.brightBlue,yt[12]),t.ansi[13]=qe(e.brightMagenta,yt[13]),t.ansi[14]=qe(e.brightCyan,yt[14]),t.ansi[15]=qe(e.brightWhite,yt[15]),e.extendedAnsi){let r=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let n=0;n<r;n++)t.ansi[n+16]=qe(e.extendedAnsi[n],yt[n+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()}}};kd=ut([ue(0,rr)],kd);function qe(e,t){if(e!==void 0)try{return it.toColor(e)}catch{}return t}var sM=class{constructor(...e){this._entries=new Map;for(let[t,r]of e)this.set(t,r)}set(e,t){let r=this._entries.get(e);return this._entries.set(e,t),r}forEach(e){for(let[t,r]of this._entries.entries())e(t,r)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},oM=class{constructor(){this._services=new sM,this._services.set(rp,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let r=ZP(e).sort((s,o)=>s.index-o.index),n=[];for(let s of r){let o=this._services.get(s.id);if(!o)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${s.id._id}.`);n.push(o)}let i=r.length>0?r[0].index:t.length;if(t.length!==i)throw new Error(`[createInstance] First service dependency of ${e.name} at position ${i+1} conflicts with ${t.length} static arguments`);return new e(...t,...n)}},lM={trace:0,debug:1,info:2,warn:3,error:4,off:5},aM="xterm.js: ",Cd=class extends Be{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=lM[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,r){this._evalLazyOptionalParams(r),e.call(console,(this._optionsService.options.logger?"":aM)+t,...r)}trace(e,...t){var r;this._logLevel<=0&&this._log(((r=this._optionsService.options.logger)==null?void 0:r.trace.bind(this._optionsService.options.logger))??console.log,e,t)}debug(e,...t){var r;this._logLevel<=1&&this._log(((r=this._optionsService.options.logger)==null?void 0:r.debug.bind(this._optionsService.options.logger))??console.log,e,t)}info(e,...t){var r;this._logLevel<=2&&this._log(((r=this._optionsService.options.logger)==null?void 0:r.info.bind(this._optionsService.options.logger))??console.info,e,t)}warn(e,...t){var r;this._logLevel<=3&&this._log(((r=this._optionsService.options.logger)==null?void 0:r.warn.bind(this._optionsService.options.logger))??console.warn,e,t)}error(e,...t){var r;this._logLevel<=4&&this._log(((r=this._optionsService.options.logger)==null?void 0:r.error.bind(this._optionsService.options.logger))??console.error,e,t)}};Cd=ut([ue(0,rr)],Cd);var o_=class extends Be{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new ae),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new ae),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new ae),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 r=0;r<Math.min(e,this.length);r++)t[r]=this._array[this._getCyclicIndex(r)];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,...r){if(t){for(let n=e;n<this._length-t;n++)this._array[this._getCyclicIndex(n)]=this._array[this._getCyclicIndex(n+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let n=this._length-1;n>=e;n--)this._array[this._getCyclicIndex(n+r.length)]=this._array[this._getCyclicIndex(n)];for(let n=0;n<r.length;n++)this._array[this._getCyclicIndex(e+n)]=r[n];if(r.length&&this.onInsertEmitter.fire({index:e,amount:r.length}),this._length+r.length>this._maxLength){let n=this._length+r.length-this._maxLength;this._startIndex+=n,this._length=this._maxLength,this.onTrimEmitter.fire(n)}else this._length+=r.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,r){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+r<0)throw new Error("Cannot shift elements in list beyond index 0");if(r>0){for(let i=t-1;i>=0;i--)this.set(e+i+r,this.get(e+i));let n=e+t+r-this._length;if(n>0)for(this._length+=n;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let n=0;n<t;n++)this.set(e+n+r,this.get(e+n))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},De=3,gt=Object.freeze(new hl),Wl=0,Pu=2,lo=class k1{constructor(t,r,n=!1){this.isWrapped=n,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*De);let i=r||Ar.fromCharData([0,H0,1,0]);for(let s=0;s<t;++s)this.setCell(s,i);this.length=t}get(t){let r=this._data[t*De+0],n=r&2097151;return[this._data[t*De+1],r&2097152?this._combined[t]:n?Fn(n):"",r>>22,r&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):n]}set(t,r){this._data[t*De+1]=r[0],r[1].length>1?(this._combined[t]=r[1],this._data[t*De+0]=t|2097152|r[2]<<22):this._data[t*De+0]=r[1].charCodeAt(0)|r[2]<<22}getWidth(t){return this._data[t*De+0]>>22}hasWidth(t){return this._data[t*De+0]&12582912}getFg(t){return this._data[t*De+1]}getBg(t){return this._data[t*De+2]}hasContent(t){return this._data[t*De+0]&4194303}getCodePoint(t){let r=this._data[t*De+0];return r&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):r&2097151}isCombined(t){return this._data[t*De+0]&2097152}getString(t){let r=this._data[t*De+0];return r&2097152?this._combined[t]:r&2097151?Fn(r&2097151):""}isProtected(t){return this._data[t*De+2]&536870912}loadCell(t,r){return Wl=t*De,r.content=this._data[Wl+0],r.fg=this._data[Wl+1],r.bg=this._data[Wl+2],r.content&2097152&&(r.combinedData=this._combined[t]),r.bg&268435456&&(r.extended=this._extendedAttrs[t]),r}setCell(t,r){r.content&2097152&&(this._combined[t]=r.combinedData),r.bg&268435456&&(this._extendedAttrs[t]=r.extended),this._data[t*De+0]=r.content,this._data[t*De+1]=r.fg,this._data[t*De+2]=r.bg}setCellFromCodepoint(t,r,n,i){i.bg&268435456&&(this._extendedAttrs[t]=i.extended),this._data[t*De+0]=r|n<<22,this._data[t*De+1]=i.fg,this._data[t*De+2]=i.bg}addCodepointToCell(t,r,n){let i=this._data[t*De+0];i&2097152?this._combined[t]+=Fn(r):i&2097151?(this._combined[t]=Fn(i&2097151)+Fn(r),i&=-2097152,i|=2097152):i=r|1<<22,n&&(i&=-12582913,i|=n<<22),this._data[t*De+0]=i}insertCells(t,r,n){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,n),r<this.length-t){let i=new Ar;for(let s=this.length-t-r-1;s>=0;--s)this.setCell(t+r+s,this.loadCell(t+s,i));for(let s=0;s<r;++s)this.setCell(t+s,n)}else for(let i=t;i<this.length;++i)this.setCell(i,n);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,n)}deleteCells(t,r,n){if(t%=this.length,r<this.length-t){let i=new Ar;for(let s=0;s<this.length-t-r;++s)this.setCell(t+s,this.loadCell(t+r+s,i));for(let s=this.length-r;s<this.length;++s)this.setCell(s,n)}else for(let i=t;i<this.length;++i)this.setCell(i,n);t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,n),this.getWidth(t)===0&&!this.hasContent(t)&&this.setCellFromCodepoint(t,0,1,n)}replaceCells(t,r,n,i=!1){if(i){for(t&&this.getWidth(t-1)===2&&!this.isProtected(t-1)&&this.setCellFromCodepoint(t-1,0,1,n),r<this.length&&this.getWidth(r-1)===2&&!this.isProtected(r)&&this.setCellFromCodepoint(r,0,1,n);t<r&&t<this.length;)this.isProtected(t)||this.setCell(t,n),t++;return}for(t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,n),r<this.length&&this.getWidth(r-1)===2&&this.setCellFromCodepoint(r,0,1,n);t<r&&t<this.length;)this.setCell(t++,n)}resize(t,r){if(t===this.length)return this._data.length*4*Pu<this._data.buffer.byteLength;let n=t*De;if(t>this.length){if(this._data.buffer.byteLength>=n*4)this._data=new Uint32Array(this._data.buffer,0,n);else{let i=new Uint32Array(n);i.set(this._data),this._data=i}for(let i=this.length;i<t;++i)this.setCell(i,r)}else{this._data=this._data.subarray(0,n);let i=Object.keys(this._combined);for(let o=0;o<i.length;o++){let l=parseInt(i[o],10);l>=t&&delete this._combined[l]}let s=Object.keys(this._extendedAttrs);for(let o=0;o<s.length;o++){let l=parseInt(s[o],10);l>=t&&delete this._extendedAttrs[l]}}return this.length=t,n*4*Pu<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*Pu<this._data.buffer.byteLength){let t=new Uint32Array(this._data.length);return t.set(this._data),this._data=t,1}return 0}fill(t,r=!1){if(r){for(let n=0;n<this.length;++n)this.isProtected(n)||this.setCell(n,t);return}this._combined={},this._extendedAttrs={};for(let n=0;n<this.length;++n)this.setCell(n,t)}copyFrom(t){this.length!==t.length?this._data=new Uint32Array(t._data):this._data.set(t._data),this.length=t.length,this._combined={};for(let r in t._combined)this._combined[r]=t._combined[r];this._extendedAttrs={};for(let r in t._extendedAttrs)this._extendedAttrs[r]=t._extendedAttrs[r];this.isWrapped=t.isWrapped}clone(){let t=new k1(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let r in this._combined)t._combined[r]=this._combined[r];for(let r in this._extendedAttrs)t._extendedAttrs[r]=this._extendedAttrs[r];return t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*De+0]&4194303)return t+(this._data[t*De+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*De+0]&4194303||this._data[t*De+2]&50331648)return t+(this._data[t*De+0]>>22);return 0}copyCellsFrom(t,r,n,i,s){let o=t._data;if(s)for(let a=i-1;a>=0;a--){for(let c=0;c<De;c++)this._data[(n+a)*De+c]=o[(r+a)*De+c];o[(r+a)*De+2]&268435456&&(this._extendedAttrs[n+a]=t._extendedAttrs[r+a])}else for(let a=0;a<i;a++){for(let c=0;c<De;c++)this._data[(n+a)*De+c]=o[(r+a)*De+c];o[(r+a)*De+2]&268435456&&(this._extendedAttrs[n+a]=t._extendedAttrs[r+a])}let l=Object.keys(t._combined);for(let a=0;a<l.length;a++){let c=parseInt(l[a],10);c>=r&&(this._combined[c-r+n]=t._combined[c])}}translateToString(t,r,n,i){r=r??0,n=n??this.length,t&&(n=Math.min(n,this.getTrimmedLength())),i&&(i.length=0);let s="";for(;r<n;){let o=this._data[r*De+0],l=o&2097151,a=o&2097152?this._combined[r]:l?Fn(l):qn;if(s+=a,i)for(let c=0;c<a.length;++c)i.push(r);r+=o>>22||1}return i&&i.push(r),s}};function cM(e,t,r,n,i,s){let o=[];for(let l=0;l<e.length-1;l++){let a=l,c=e.get(++a);if(!c.isWrapped)continue;let d=[e.get(l)];for(;a<e.length&&c.isWrapped;)d.push(c),c=e.get(++a);if(!s&&n>=l&&n<a){l+=d.length-1;continue}let h=0,f=Go(d,h,t),p=1,m=0;for(;p<d.length;){let b=Go(d,p,t),g=b-m,v=r-f,y=Math.min(g,v);d[h].copyCellsFrom(d[p],m,f,y,!1),f+=y,f===r&&(h++,f=0),m+=y,m===b&&(p++,m=0),f===0&&h!==0&&d[h-1].getWidth(r-1)===2&&(d[h].copyCellsFrom(d[h-1],r-1,f++,1,!1),d[h-1].setCell(r-1,i))}d[h].replaceCells(f,r,i);let _=0;for(let b=d.length-1;b>0&&(b>h||d[b].getTrimmedLength()===0);b--)_++;_>0&&(o.push(l+d.length-_),o.push(_)),l+=d.length-1}return o}function uM(e,t){let r=[],n=0,i=t[n],s=0;for(let o=0;o<e.length;o++)if(i===o){let l=t[++n];e.onDeleteEmitter.fire({index:o-s,amount:l}),o+=l-1,s+=l,i=t[++n]}else r.push(o);return{layout:r,countRemoved:s}}function hM(e,t){let r=[];for(let n=0;n<t.length;n++)r.push(e.get(t[n]));for(let n=0;n<r.length;n++)e.set(n,r[n]);e.length=t.length}function dM(e,t,r){let n=[],i=e.map((a,c)=>Go(e,c,t)).reduce((a,c)=>a+c),s=0,o=0,l=0;for(;l<i;){if(i-l<r){n.push(i-l);break}s+=r;let a=Go(e,o,t);s>a&&(s-=a,o++);let c=e[o].getWidth(s-1)===2;c&&s--;let d=c?r-1:r;n.push(d),l+=d}return n}function Go(e,t,r){if(t===e.length-1)return e[t].getTrimmedLength();let n=!e[t].hasContent(r-1)&&e[t].getWidth(r-1)===1,i=e[t+1].getWidth(0)===2;return n&&i?r-1:r}var C1=class E1{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=E1._nextId++,this._onDispose=this.register(new ae),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),$i(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};C1._nextId=1;var fM=C1,Ct={},Si=Ct.B;Ct[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:"≥","{":"π","|":"≠","}":"£","~":"·"};Ct.A={"#":"£"};Ct.B=void 0;Ct[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};Ct.C=Ct[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Ct.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};Ct.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};Ct.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};Ct.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};Ct.E=Ct[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};Ct.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};Ct.H=Ct[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Ct["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var l_=4294967295,a_=class{constructor(e,t,r){this._hasScrollback=e,this._optionsService=t,this._bufferService=r,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=gt.clone(),this.savedCharset=Si,this.markers=[],this._nullCell=Ar.fromCharData([0,H0,1,0]),this._whitespaceCell=Ar.fromCharData([0,qn,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new ec,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new o_(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(e){return e?(this._nullCell.fg=e.fg,this._nullCell.bg=e.bg,this._nullCell.extended=e.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new Ga),this._nullCell}getWhitespaceCell(e){return e?(this._whitespaceCell.fg=e.fg,this._whitespaceCell.bg=e.bg,this._whitespaceCell.extended=e.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new Ga),this._whitespaceCell}getBlankLine(e,t){return new lo(this._bufferService.cols,this.getNullCell(e),t)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let e=this.ybase+this.y-this.ydisp;return e>=0&&e<this._rows}_getCorrectBufferLength(e){if(!this._hasScrollback)return e;let t=e+this._optionsService.rawOptions.scrollback;return t>l_?l_:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=gt);let t=this._rows;for(;t--;)this.lines.push(this.getBlankLine(e))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new o_(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let r=this.getNullCell(gt),n=0,i=this._getCorrectBufferLength(t);if(i>this.lines.maxLength&&(this.lines.maxLength=i),this.lines.length>0){if(this._cols<e)for(let o=0;o<this.lines.length;o++)n+=+this.lines.get(o).resize(e,r);let s=0;if(this._rows<t)for(let o=this._rows;o<t;o++)this.lines.length<t+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new lo(e,r)):this.ybase>0&&this.lines.length<=this.ybase+this.y+s+1?(this.ybase--,s++,this.ydisp>0&&this.ydisp--):this.lines.push(new lo(e,r)));else for(let o=this._rows;o>t;o--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(i<this.lines.maxLength){let o=this.lines.length-i;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=i}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),s&&(this.y+=s),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=t-1,this._isReflowEnabled&&(this._reflow(e,t),this._cols>e))for(let s=0;s<this.lines.length;s++)n+=+this.lines.get(s).resize(e,r);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),n>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition<this.lines.length;)if(t+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),t>100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend==="conpty"&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let r=this._optionsService.rawOptions.reflowCursorLine,n=cM(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(gt),r);if(n.length>0){let i=uM(this.lines,n);hM(this.lines,i.layout),this._reflowLargerAdjustViewport(e,t,i.countRemoved)}}_reflowLargerAdjustViewport(e,t,r){let n=this.getNullCell(gt),i=r;for(;i-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new lo(e,n))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-r,0)}_reflowSmaller(e,t){let r=this._optionsService.rawOptions.reflowCursorLine,n=this.getNullCell(gt),i=[],s=0;for(let o=this.lines.length-1;o>=0;o--){let l=this.lines.get(o);if(!l||!l.isWrapped&&l.getTrimmedLength()<=e)continue;let a=[l];for(;l.isWrapped&&o>0;)l=this.lines.get(--o),a.unshift(l);if(!r){let y=this.ybase+this.y;if(y>=o&&y<o+a.length)continue}let c=a[a.length-1].getTrimmedLength(),d=dM(a,this._cols,e),h=d.length-a.length,f;this.ybase===0&&this.y!==this.lines.length-1?f=Math.max(0,this.y-this.lines.maxLength+h):f=Math.max(0,this.lines.length-this.lines.maxLength+h);let p=[];for(let y=0;y<h;y++){let S=this.getBlankLine(gt,!0);p.push(S)}p.length>0&&(i.push({start:o+a.length+s,newLines:p}),s+=p.length),a.push(...p);let m=d.length-1,_=d[m];_===0&&(m--,_=d[m]);let b=a.length-h-1,g=c;for(;b>=0;){let y=Math.min(g,_);if(a[m]===void 0)break;if(a[m].copyCellsFrom(a[b],g-y,_-y,y,!0),_-=y,_===0&&(m--,_=d[m]),g-=y,g===0){b--;let S=Math.max(b,0);g=Go(a,S,this._cols)}}for(let y=0;y<a.length;y++)d[y]<e&&a[y].setCell(d[y],n);let v=h-f;for(;v-- >0;)this.ybase===0?this.y<t-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+s)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+h,this.ybase+t-1)}if(i.length>0){let o=[],l=[];for(let _=0;_<this.lines.length;_++)l.push(this.lines.get(_));let a=this.lines.length,c=a-1,d=0,h=i[d];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+s);let f=0;for(let _=Math.min(this.lines.maxLength-1,a+s-1);_>=0;_--)if(h&&h.start>c+f){for(let b=h.newLines.length-1;b>=0;b--)this.lines.set(_--,h.newLines[b]);_++,o.push({index:c+1,amount:h.newLines.length}),f+=h.newLines.length,h=i[++d]}else this.lines.set(_,l[c--]);let p=0;for(let _=o.length-1;_>=0;_--)o[_].index+=p,this.lines.onInsertEmitter.fire(o[_]),p+=o[_].amount;let m=Math.max(0,a+s-this.lines.maxLength);m>0&&this.lines.onTrimEmitter.fire(m)}}translateBufferLineToString(e,t,r=0,n){let i=this.lines.get(e);return i?i.translateToString(t,r,n):""}getWrappedRangeForLine(e){let t=e,r=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;r+1<this.lines.length&&this.lines.get(r+1).isWrapped;)r++;return{first:t,last:r}}setupTabStops(e){for(e!=null?this.tabs[e]||(e=this.prevStop(e)):(this.tabs={},e=0);e<this._cols;e+=this._optionsService.rawOptions.tabStopWidth)this.tabs[e]=!0}prevStop(e){for(e==null&&(e=this.x);!this.tabs[--e]&&e>0;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e==null&&(e=this.x);!this.tabs[++e]&&e<this._cols;);return e>=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let t=0;t<this.markers.length;t++)this.markers[t].line===e&&(this.markers[t].dispose(),this.markers.splice(t--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].dispose();this.markers.length=0,this._isClearing=!1}addMarker(e){let t=new fM(e);return this.markers.push(t),t.register(this.lines.onTrim(r=>{t.line-=r,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(r=>{t.line>=r.index&&(t.line+=r.amount)})),t.register(this.lines.onDelete(r=>{t.line>=r.index&&t.line<r.index+r.amount&&t.dispose(),t.line>r.index&&(t.line-=r.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},pM=class extends Be{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new ae),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 a_(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new a_(!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)}},N1=2,T1=1,Ed=class extends Be{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new ae),this.onResize=this._onResize.event,this._onScroll=this._register(new ae),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,N1),this.rows=Math.max(e.rawOptions.rows||0,T1),this.buffers=this._register(new pM(e,this)),this._register(this.buffers.onBufferActivate(t=>{this._onScroll.fire(t.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let r=this.cols!==e,n=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:r,rowsChanged:n})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let r=this.buffer,n;n=this._cachedBlankLine,(!n||n.length!==this.cols||n.getFg(0)!==e.fg||n.getBg(0)!==e.bg)&&(n=r.getBlankLine(e,t),this._cachedBlankLine=n),n.isWrapped=t;let i=r.ybase+r.scrollTop,s=r.ybase+r.scrollBottom;if(r.scrollTop===0){let o=r.lines.isFull;s===r.lines.length-1?o?r.lines.recycle().copyFrom(n):r.lines.push(n.clone()):r.lines.splice(s+1,0,n.clone()),o?this.isUserScrolling&&(r.ydisp=Math.max(r.ydisp-1,0)):(r.ybase++,this.isUserScrolling||r.ydisp++)}else{let o=s-i+1;r.lines.shiftElements(i+1,o-1,-1),r.lines.set(s,n.clone())}this.isUserScrolling||(r.ydisp=r.ybase),this._onScroll.fire(r.ydisp)}scrollLines(e,t){let r=this.buffer;if(e<0){if(r.ydisp===0)return;this.isUserScrolling=!0}else e+r.ydisp>=r.ybase&&(this.isUserScrolling=!1);let n=r.ydisp;r.ydisp=Math.max(Math.min(r.ydisp+e,r.ybase),0),n!==r.ydisp&&(t||this._onScroll.fire(r.ydisp))}};Ed=ut([ue(0,rr)],Ed);var Gi={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:Za,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},mM=["normal","bold","100","200","300","400","500","600","700","800","900"],gM=class extends Be{constructor(e){super(),this._onOptionChange=this._register(new ae),this.onOptionChange=this._onOptionChange.event;let t={...Gi};for(let r in e)if(r in t)try{let n=e[r];t[r]=this._sanitizeAndValidateOption(r,n)}catch(n){console.error(n)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(rt(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(r=>{r===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(r=>{e.indexOf(r)!==-1&&t()})}_setupOptions(){let e=r=>{if(!(r in Gi))throw new Error(`No option with key "${r}"`);return this.rawOptions[r]},t=(r,n)=>{if(!(r in Gi))throw new Error(`No option with key "${r}"`);n=this._sanitizeAndValidateOption(r,n),this.rawOptions[r]!==n&&(this.rawOptions[r]=n,this._onOptionChange.fire(r))};for(let r in this.rawOptions){let n={get:e.bind(this,r),set:t.bind(this,r)};Object.defineProperty(this.options,r,n)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=Gi[e]),!_M(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=Gi[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=mM.includes(t)?t:Gi[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 _M(e){return e==="block"||e==="underline"||e==="bar"}function ao(e,t=5){if(typeof e!="object")return e;let r=Array.isArray(e)?[]:{};for(let n in e)r[n]=t<=1?e[n]:e[n]&&ao(e[n],t-1);return r}var c_=Object.freeze({insertMode:!1}),u_=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),Nd=class extends Be{constructor(e,t,r){super(),this._bufferService=e,this._logService=t,this._optionsService=r,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new ae),this.onData=this._onData.event,this._onUserInput=this._register(new ae),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new ae),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new ae),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=ao(c_),this.decPrivateModes=ao(u_)}reset(){this.modes=ao(c_),this.decPrivateModes=ao(u_)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let r=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&r.ybase!==r.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(n=>n.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))}};Nd=ut([ue(0,tr),ue(1,Y0),ue(2,rr)],Nd);var h_={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:e=>e.button===4||e.action!==1?!1:(e.ctrl=!1,e.alt=!1,e.shift=!1,!0)},VT200:{events:19,restrict:e=>e.action!==32},DRAG:{events:23,restrict:e=>!(e.action===32&&e.button===3)},ANY:{events:31,restrict:e=>!0}};function Ru(e,t){let r=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(r|=64,r|=e.action):(r|=e.button&3,e.button&4&&(r|=64),e.button&8&&(r|=128),e.action===32?r|=32:e.action===0&&!t&&(r|=3)),r}var Mu=String.fromCharCode,d_={DEFAULT:e=>{let t=[Ru(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${Mu(t[0])}${Mu(t[1])}${Mu(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${Ru(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${Ru(e,!0)};${e.x};${e.y}${t}`}},Td=class extends Be{constructor(e,t,r){super(),this._bufferService=e,this._coreService=t,this._optionsService=r,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new ae),this.onProtocolChange=this._onProtocolChange.event;for(let n of Object.keys(h_))this.addProtocol(n,h_[n]);for(let n of Object.keys(d_))this.addEncoding(n,d_[n]);this.reset()}addProtocol(e,t){this._protocols[e]=t}addEncoding(e,t){this._encodings[e]=t}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e){if(!this._protocols[e])throw new Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw new Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,t,r){if(e.deltaY===0||e.shiftKey||t===void 0||r===void 0)return 0;let n=t/r,i=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(i/=n+0,Math.abs(e.deltaY)<50&&(i*=.3),this._wheelPartialScroll+=i,i=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(i*=this._bufferService.rows),i}_applyScrollModifier(e,t){return t.altKey||t.ctrlKey||t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||e.button===4&&e.action===32||e.button===3&&e.action!==32||e.button!==4&&(e.action===2||e.action===3)||(e.col++,e.row++,e.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,e,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(e))return!1;let t=this._encodings[this._activeEncoding](e);return t&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(e&1),up:!!(e&2),drag:!!(e&4),move:!!(e&8),wheel:!!(e&16)}}_equalEvents(e,t,r){if(r){if(e.x!==t.x||e.y!==t.y)return!1}else if(e.col!==t.col||e.row!==t.row)return!1;return!(e.button!==t.button||e.action!==t.action||e.ctrl!==t.ctrl||e.alt!==t.alt||e.shift!==t.shift)}};Td=ut([ue(0,tr),ue(1,Ki),ue(2,rr)],Td);var Lu=[[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]],vM=[[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]],bt;function xM(e,t){let r=0,n=t.length-1,i;if(e<t[0][0]||e>t[n][1])return!1;for(;n>=r;)if(i=r+n>>1,e>t[i][1])r=i+1;else if(e<t[i][0])n=i-1;else return!0;return!1}var yM=class{constructor(){if(this.version="6",!bt){bt=new Uint8Array(65536),bt.fill(1),bt[0]=0,bt.fill(0,1,32),bt.fill(0,127,160),bt.fill(2,4352,4448),bt[9001]=2,bt[9002]=2,bt.fill(2,11904,42192),bt[12351]=1,bt.fill(2,44032,55204),bt.fill(2,63744,64256),bt.fill(2,65040,65050),bt.fill(2,65072,65136),bt.fill(2,65280,65377),bt.fill(2,65504,65511);for(let e=0;e<Lu.length;++e)bt.fill(0,Lu[e][0],Lu[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?bt[e]:xM(e,vM)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let r=this.wcwidth(e),n=r===0&&t!==0;if(n){let i=Ti.extractWidth(t);i===0?n=!1:i>r&&(r=i)}return Ti.createPropertyValue(0,r,n)}},Ti=class fa{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new ae,this.onChange=this._onChange.event;let t=new yM;this.register(t),this._active=t.version,this._activeProvider=t}static extractShouldJoin(t){return(t&1)!==0}static extractWidth(t){return t>>1&3}static extractCharKind(t){return t>>3}static createPropertyValue(t,r,n=!1){return(t&16777215)<<3|(r&3)<<1|(n?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(t){if(!this._providers[t])throw new Error(`unknown Unicode version "${t}"`);this._active=t,this._activeProvider=this._providers[t],this._onChange.fire(t)}register(t){this._providers[t.version]=t}wcwidth(t){return this._activeProvider.wcwidth(t)}getStringCellWidth(t){let r=0,n=0,i=t.length;for(let s=0;s<i;++s){let o=t.charCodeAt(s);if(55296<=o&&o<=56319){if(++s>=i)return r+this.wcwidth(o);let c=t.charCodeAt(s);56320<=c&&c<=57343?o=(o-55296)*1024+c-56320+65536:r+=this.wcwidth(c)}let l=this.charProperties(o,n),a=fa.extractWidth(l);fa.extractShouldJoin(l)&&(a-=fa.extractWidth(n)),r+=a,n=l}return r}charProperties(t,r){return this._activeProvider.charProperties(t,r)}},bM=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 f_(e){var n;let t=(n=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1))==null?void 0:n.get(e.cols-1),r=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);r&&t&&(r.isWrapped=t[3]!==0&&t[3]!==32)}var Gs=2147483647,wM=256,P1=class Pd{constructor(t=32,r=32){if(this.maxLength=t,this.maxSubParamsLength=r,r>wM)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(t),this.length=0,this._subParams=new Int32Array(r),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(t),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let r=new Pd;if(!t.length)return r;for(let n=Array.isArray(t[0])?1:0;n<t.length;++n){let i=t[n];if(Array.isArray(i))for(let s=0;s<i.length;++s)r.addSubParam(i[s]);else r.addParam(i)}return r}clone(){let t=new Pd(this.maxLength,this.maxSubParamsLength);return t.params.set(this.params),t.length=this.length,t._subParams.set(this._subParams),t._subParamsLength=this._subParamsLength,t._subParamsIdx.set(this._subParamsIdx),t._rejectDigits=this._rejectDigits,t._rejectSubDigits=this._rejectSubDigits,t._digitIsSub=this._digitIsSub,t}toArray(){let t=[];for(let r=0;r<this.length;++r){t.push(this.params[r]);let n=this._subParamsIdx[r]>>8,i=this._subParamsIdx[r]&255;i-n>0&&t.push(Array.prototype.slice.call(this._subParams,n,i))}return t}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(t){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=t>Gs?Gs:t}addSubParam(t){if(this._digitIsSub=!0,!!this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=t>Gs?Gs:t,this._subParamsIdx[this.length-1]++}}hasSubParams(t){return(this._subParamsIdx[t]&255)-(this._subParamsIdx[t]>>8)>0}getSubParams(t){let r=this._subParamsIdx[t]>>8,n=this._subParamsIdx[t]&255;return n-r>0?this._subParams.subarray(r,n):null}getSubParamsAll(){let t={};for(let r=0;r<this.length;++r){let n=this._subParamsIdx[r]>>8,i=this._subParamsIdx[r]&255;i-n>0&&(t[r]=this._subParams.slice(n,i))}return t}addDigit(t){let r;if(this._rejectDigits||!(r=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let n=this._digitIsSub?this._subParams:this.params,i=n[r-1];n[r-1]=~i?Math.min(i*10+t,Gs):t}},Qs=[],SM=class{constructor(){this._state=0,this._active=Qs,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 r=this._handlers[e];return r.push(t),{dispose:()=>{let n=r.indexOf(t);n!==-1&&r.splice(n,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=Qs}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=Qs,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||Qs,!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,r){if(!this._active.length)this._handlerFb(this._id,"PUT",Tc(e,t,r));else for(let n=this._active.length-1;n>=0;n--)this._active[n].put(e,t,r)}start(){this.reset(),this._state=1}put(e,t,r){if(this._state!==3){if(this._state===1)for(;t<r;){let n=e[t++];if(n===59){this._state=2,this._start();break}if(n<48||57<n){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+n-48}this._state===2&&r-t>0&&this._put(e,t,r)}}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 r=!1,n=this._active.length-1,i=!1;if(this._stack.paused&&(n=this._stack.loopPosition-1,r=t,i=this._stack.fallThrough,this._stack.paused=!1),!i&&r===!1){for(;n>=0&&(r=this._active[n].end(e),r!==!0);n--)if(r instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=n,this._stack.fallThrough=!1,r;n--}for(;n>=0;n--)if(r=this._active[n].end(!1),r instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=n,this._stack.fallThrough=!0,r}this._active=Qs,this._id=-1,this._state=0}}},mr=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,t,r){this._hitLimit||(this._data+=Tc(e,t,r),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(r=>(this._data="",this._hitLimit=!1,r));return this._data="",this._hitLimit=!1,t}},Js=[],kM=class{constructor(){this._handlers=Object.create(null),this._active=Js,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Js}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let r=this._handlers[e];return r.push(t),{dispose:()=>{let n=r.indexOf(t);n!==-1&&r.splice(n,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=Js,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||Js,!this._active.length)this._handlerFb(this._ident,"HOOK",t);else for(let r=this._active.length-1;r>=0;r--)this._active[r].hook(t)}put(e,t,r){if(!this._active.length)this._handlerFb(this._ident,"PUT",Tc(e,t,r));else for(let n=this._active.length-1;n>=0;n--)this._active[n].put(e,t,r)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let r=!1,n=this._active.length-1,i=!1;if(this._stack.paused&&(n=this._stack.loopPosition-1,r=t,i=this._stack.fallThrough,this._stack.paused=!1),!i&&r===!1){for(;n>=0&&(r=this._active[n].unhook(e),r!==!0);n--)if(r instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=n,this._stack.fallThrough=!1,r;n--}for(;n>=0;n--)if(r=this._active[n].unhook(!1),r instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=n,this._stack.fallThrough=!0,r}this._active=Js,this._ident=0}},co=new P1;co.addParam(0);var p_=class{constructor(e){this._handler=e,this._data="",this._params=co,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():co,this._data="",this._hitLimit=!1}put(e,t,r){this._hitLimit||(this._data+=Tc(e,t,r),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data,this._params),t instanceof Promise))return t.then(r=>(this._params=co,this._data="",this._hitLimit=!1,r));return this._params=co,this._data="",this._hitLimit=!1,t}},CM=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,r,n){this.table[t<<8|e]=r<<4|n}addMany(e,t,r,n){for(let i=0;i<e.length;i++)this.table[t<<8|e[i]]=r<<4|n}},Pr=160,EM=function(){let e=new CM(4095),t=Array.apply(null,Array(256)).map((l,a)=>a),r=(l,a)=>t.slice(l,a),n=r(32,127),i=r(0,24);i.push(25),i.push.apply(i,r(28,32));let s=r(0,14),o;e.setDefault(1,0),e.addMany(n,0,2,0);for(o in s)e.addMany([24,26,153,154],o,3,0),e.addMany(r(128,144),o,3,0),e.addMany(r(144,152),o,3,0),e.add(156,o,0,0),e.add(27,o,11,1),e.add(157,o,4,8),e.addMany([152,158,159],o,0,7),e.add(155,o,11,3),e.add(144,o,11,9);return e.addMany(i,0,3,0),e.addMany(i,1,3,1),e.add(127,1,0,1),e.addMany(i,8,0,8),e.addMany(i,3,3,3),e.add(127,3,0,3),e.addMany(i,4,3,4),e.add(127,4,0,4),e.addMany(i,6,3,6),e.addMany(i,5,3,5),e.add(127,5,0,5),e.addMany(i,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(n,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(r(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(n,7,0,7),e.addMany(i,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(r(64,127),3,7,0),e.addMany(r(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(r(48,60),4,8,4),e.addMany(r(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(r(32,64),6,0,6),e.add(127,6,0,6),e.addMany(r(64,127),6,0,0),e.addMany(r(32,48),3,9,5),e.addMany(r(32,48),5,9,5),e.addMany(r(48,64),5,0,6),e.addMany(r(64,127),5,7,0),e.addMany(r(32,48),4,9,5),e.addMany(r(32,48),1,9,2),e.addMany(r(32,48),2,9,2),e.addMany(r(48,127),2,10,0),e.addMany(r(48,80),1,10,0),e.addMany(r(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(r(96,127),1,10,0),e.add(80,1,11,9),e.addMany(i,9,0,9),e.add(127,9,0,9),e.addMany(r(28,32),9,0,9),e.addMany(r(32,48),9,9,12),e.addMany(r(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(i,11,0,11),e.addMany(r(32,128),11,0,11),e.addMany(r(28,32),11,0,11),e.addMany(i,10,0,10),e.add(127,10,0,10),e.addMany(r(28,32),10,0,10),e.addMany(r(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(r(32,48),10,9,12),e.addMany(i,12,0,12),e.add(127,12,0,12),e.addMany(r(28,32),12,0,12),e.addMany(r(32,48),12,9,12),e.addMany(r(48,64),12,0,11),e.addMany(r(64,127),12,12,13),e.addMany(r(64,127),10,12,13),e.addMany(r(64,127),9,12,13),e.addMany(i,13,13,13),e.addMany(n,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(Pr,0,2,0),e.add(Pr,8,5,8),e.add(Pr,6,0,6),e.add(Pr,11,0,11),e.add(Pr,13,13,13),e}(),NM=class extends Be{constructor(e=EM){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 P1,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,r,n)=>{},this._executeHandlerFb=t=>{},this._csiHandlerFb=(t,r)=>{},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(rt(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new SM),this._dcsParser=this._register(new kM),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,t=[64,126]){let r=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(r=e.prefix.charCodeAt(0),r&&60>r||r>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 i=0;i<e.intermediates.length;++i){let s=e.intermediates.charCodeAt(i);if(32>s||s>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");r<<=8,r|=s}}if(e.final.length!==1)throw new Error("final must be a single byte");let n=e.final.charCodeAt(0);if(t[0]>n||n>t[1])throw new Error(`final must be in range ${t[0]} .. ${t[1]}`);return r<<=8,r|=n,r}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 r=this._identifier(e,[48,126]);this._escHandlers[r]===void 0&&(this._escHandlers[r]=[]);let n=this._escHandlers[r];return n.push(t),{dispose:()=>{let i=n.indexOf(t);i!==-1&&n.splice(i,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 r=this._identifier(e);this._csiHandlers[r]===void 0&&(this._csiHandlers[r]=[]);let n=this._csiHandlers[r];return n.push(t),{dispose:()=>{let i=n.indexOf(t);i!==-1&&n.splice(i,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,r,n,i){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=r,this._parseStack.transition=n,this._parseStack.chunkPos=i}parse(e,t,r){let n=0,i=0,s=0,o;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,s=this._parseStack.chunkPos+1;else{if(r===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let l=this._parseStack.handlers,a=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(r===!1&&a>-1){for(;a>=0&&(o=l[a](this._params),o!==!0);a--)if(o instanceof Promise)return this._parseStack.handlerPos=a,o}this._parseStack.handlers=[];break;case 4:if(r===!1&&a>-1){for(;a>=0&&(o=l[a](),o!==!0);a--)if(o instanceof Promise)return this._parseStack.handlerPos=a,o}this._parseStack.handlers=[];break;case 6:if(n=e[this._parseStack.chunkPos],o=this._dcsParser.unhook(n!==24&&n!==26,r),o)return o;n===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(n=e[this._parseStack.chunkPos],o=this._oscParser.end(n!==24&&n!==26,r),o)return o;n===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,s=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let l=s;l<t;++l){switch(n=e[l],i=this._transitions.table[this.currentState<<8|(n<160?n:Pr)],i>>4){case 2:for(let f=l+1;;++f){if(f>=t||(n=e[f])<32||n>126&&n<Pr){this._printHandler(e,l,f),l=f-1;break}if(++f>=t||(n=e[f])<32||n>126&&n<Pr){this._printHandler(e,l,f),l=f-1;break}if(++f>=t||(n=e[f])<32||n>126&&n<Pr){this._printHandler(e,l,f),l=f-1;break}if(++f>=t||(n=e[f])<32||n>126&&n<Pr){this._printHandler(e,l,f),l=f-1;break}}break;case 3:this._executeHandlers[n]?this._executeHandlers[n]():this._executeHandlerFb(n),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:l,code:n,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let a=this._csiHandlers[this._collect<<8|n],c=a?a.length-1:-1;for(;c>=0&&(o=a[c](this._params),o!==!0);c--)if(o instanceof Promise)return this._preserveStack(3,a,c,i,l),o;c<0&&this._csiHandlerFb(this._collect<<8|n,this._params),this.precedingJoinState=0;break;case 8:do switch(n){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(n-48)}while(++l<t&&(n=e[l])>47&&n<60);l--;break;case 9:this._collect<<=8,this._collect|=n;break;case 10:let d=this._escHandlers[this._collect<<8|n],h=d?d.length-1:-1;for(;h>=0&&(o=d[h](),o!==!0);h--)if(o instanceof Promise)return this._preserveStack(4,d,h,i,l),o;h<0&&this._escHandlerFb(this._collect<<8|n),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|n,this._params);break;case 13:for(let f=l+1;;++f)if(f>=t||(n=e[f])===24||n===26||n===27||n>127&&n<Pr){this._dcsParser.put(e,l,f),l=f-1;break}break;case 14:if(o=this._dcsParser.unhook(n!==24&&n!==26),o)return this._preserveStack(6,[],0,i,l),o;n===27&&(i|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let f=l+1;;f++)if(f>=t||(n=e[f])<32||n>127&&n<Pr){this._oscParser.put(e,l,f),l=f-1;break}break;case 6:if(o=this._oscParser.end(n!==24&&n!==26),o)return this._preserveStack(5,[],0,i,l),o;n===27&&(i|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=i&15}}},TM=/^([\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})$/,PM=/^[\da-f]+$/;function m_(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let r=TM.exec(t);if(r){let n=r[1]?15:r[4]?255:r[7]?4095:65535;return[Math.round(parseInt(r[1]||r[4]||r[7]||r[10],16)/n*255),Math.round(parseInt(r[2]||r[5]||r[8]||r[11],16)/n*255),Math.round(parseInt(r[3]||r[6]||r[9]||r[12],16)/n*255)]}}else if(t.indexOf("#")===0&&(t=t.slice(1),PM.exec(t)&&[3,6,9,12].includes(t.length))){let r=t.length/3,n=[0,0,0];for(let i=0;i<3;++i){let s=parseInt(t.slice(r*i,r*i+r),16);n[i]=r===1?s<<4:r===2?s:r===3?s>>4:s>>8}return n}}function Iu(e,t){let r=e.toString(16),n=r.length<2?"0"+r:r;switch(t){case 4:return r[0];case 8:return n;case 12:return(n+n).slice(0,3);default:return n+n}}function RM(e,t=16){let[r,n,i]=e;return`rgb:${Iu(r,t)}/${Iu(n,t)}/${Iu(i,t)}`}var MM={"(":0,")":1,"*":2,"+":3,"-":1,".":2},Dn=131072,g_=10;function __(e,t){if(e>24)return t.setWinLines||!1;switch(e){case 1:return!!t.restoreWin;case 2:return!!t.minimizeWin;case 3:return!!t.setWinPosition;case 4:return!!t.setWinSizePixels;case 5:return!!t.raiseWin;case 6:return!!t.lowerWin;case 7:return!!t.refreshWin;case 8:return!!t.setWinSizeChars;case 9:return!!t.maximizeWin;case 10:return!!t.fullscreenWin;case 11:return!!t.getWinState;case 13:return!!t.getWinPosition;case 14:return!!t.getWinSizePixels;case 15:return!!t.getScreenSizePixels;case 16:return!!t.getCellSizePixels;case 18:return!!t.getWinSizeChars;case 19:return!!t.getScreenSizeChars;case 20:return!!t.getIconTitle;case 21:return!!t.getWinTitle;case 22:return!!t.pushTitle;case 23:return!!t.popTitle;case 24:return!!t.setWinLines}return!1}var v_=5e3,x_=0,LM=class extends Be{constructor(e,t,r,n,i,s,o,l,a=new NM){super(),this._bufferService=e,this._charsetService=t,this._coreService=r,this._logService=n,this._optionsService=i,this._oscLinkService=s,this._coreMouseService=o,this._unicodeService=l,this._parser=a,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new QP,this._utf8Decoder=new JP,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=gt.clone(),this._eraseAttrDataInternal=gt.clone(),this._onRequestBell=this._register(new ae),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new ae),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new ae),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new ae),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new ae),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new ae),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new ae),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new ae),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new ae),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new ae),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new ae),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new ae),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new ae),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 Rd(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(c=>this._activeBuffer=c.activeBuffer)),this._parser.setCsiHandlerFallback((c,d)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(c),params:d.toArray()})}),this._parser.setEscHandlerFallback(c=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(c)})}),this._parser.setExecuteHandlerFallback(c=>{this._logService.debug("Unknown EXECUTE code: ",{code:c})}),this._parser.setOscHandlerFallback((c,d,h)=>{this._logService.debug("Unknown OSC code: ",{identifier:c,action:d,data:h})}),this._parser.setDcsHandlerFallback((c,d,h)=>{d==="HOOK"&&(h=h.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(c),action:d,payload:h})}),this._parser.setPrintHandler((c,d,h)=>this.print(c,d,h)),this._parser.registerCsiHandler({final:"@"},c=>this.insertChars(c)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},c=>this.scrollLeft(c)),this._parser.registerCsiHandler({final:"A"},c=>this.cursorUp(c)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},c=>this.scrollRight(c)),this._parser.registerCsiHandler({final:"B"},c=>this.cursorDown(c)),this._parser.registerCsiHandler({final:"C"},c=>this.cursorForward(c)),this._parser.registerCsiHandler({final:"D"},c=>this.cursorBackward(c)),this._parser.registerCsiHandler({final:"E"},c=>this.cursorNextLine(c)),this._parser.registerCsiHandler({final:"F"},c=>this.cursorPrecedingLine(c)),this._parser.registerCsiHandler({final:"G"},c=>this.cursorCharAbsolute(c)),this._parser.registerCsiHandler({final:"H"},c=>this.cursorPosition(c)),this._parser.registerCsiHandler({final:"I"},c=>this.cursorForwardTab(c)),this._parser.registerCsiHandler({final:"J"},c=>this.eraseInDisplay(c,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},c=>this.eraseInDisplay(c,!0)),this._parser.registerCsiHandler({final:"K"},c=>this.eraseInLine(c,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},c=>this.eraseInLine(c,!0)),this._parser.registerCsiHandler({final:"L"},c=>this.insertLines(c)),this._parser.registerCsiHandler({final:"M"},c=>this.deleteLines(c)),this._parser.registerCsiHandler({final:"P"},c=>this.deleteChars(c)),this._parser.registerCsiHandler({final:"S"},c=>this.scrollUp(c)),this._parser.registerCsiHandler({final:"T"},c=>this.scrollDown(c)),this._parser.registerCsiHandler({final:"X"},c=>this.eraseChars(c)),this._parser.registerCsiHandler({final:"Z"},c=>this.cursorBackwardTab(c)),this._parser.registerCsiHandler({final:"`"},c=>this.charPosAbsolute(c)),this._parser.registerCsiHandler({final:"a"},c=>this.hPositionRelative(c)),this._parser.registerCsiHandler({final:"b"},c=>this.repeatPrecedingCharacter(c)),this._parser.registerCsiHandler({final:"c"},c=>this.sendDeviceAttributesPrimary(c)),this._parser.registerCsiHandler({prefix:">",final:"c"},c=>this.sendDeviceAttributesSecondary(c)),this._parser.registerCsiHandler({final:"d"},c=>this.linePosAbsolute(c)),this._parser.registerCsiHandler({final:"e"},c=>this.vPositionRelative(c)),this._parser.registerCsiHandler({final:"f"},c=>this.hVPosition(c)),this._parser.registerCsiHandler({final:"g"},c=>this.tabClear(c)),this._parser.registerCsiHandler({final:"h"},c=>this.setMode(c)),this._parser.registerCsiHandler({prefix:"?",final:"h"},c=>this.setModePrivate(c)),this._parser.registerCsiHandler({final:"l"},c=>this.resetMode(c)),this._parser.registerCsiHandler({prefix:"?",final:"l"},c=>this.resetModePrivate(c)),this._parser.registerCsiHandler({final:"m"},c=>this.charAttributes(c)),this._parser.registerCsiHandler({final:"n"},c=>this.deviceStatus(c)),this._parser.registerCsiHandler({prefix:"?",final:"n"},c=>this.deviceStatusPrivate(c)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},c=>this.softReset(c)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},c=>this.setCursorStyle(c)),this._parser.registerCsiHandler({final:"r"},c=>this.setScrollRegion(c)),this._parser.registerCsiHandler({final:"s"},c=>this.saveCursor(c)),this._parser.registerCsiHandler({final:"t"},c=>this.windowOptions(c)),this._parser.registerCsiHandler({final:"u"},c=>this.restoreCursor(c)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},c=>this.insertColumns(c)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},c=>this.deleteColumns(c)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},c=>this.selectProtected(c)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},c=>this.requestMode(c,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},c=>this.requestMode(c,!1)),this._parser.setExecuteHandler(Q.BEL,()=>this.bell()),this._parser.setExecuteHandler(Q.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(Q.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(Q.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(Q.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(Q.BS,()=>this.backspace()),this._parser.setExecuteHandler(Q.HT,()=>this.tab()),this._parser.setExecuteHandler(Q.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(Q.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(ha.IND,()=>this.index()),this._parser.setExecuteHandler(ha.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(ha.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new mr(c=>(this.setTitle(c),this.setIconName(c),!0))),this._parser.registerOscHandler(1,new mr(c=>this.setIconName(c))),this._parser.registerOscHandler(2,new mr(c=>this.setTitle(c))),this._parser.registerOscHandler(4,new mr(c=>this.setOrReportIndexedColor(c))),this._parser.registerOscHandler(8,new mr(c=>this.setHyperlink(c))),this._parser.registerOscHandler(10,new mr(c=>this.setOrReportFgColor(c))),this._parser.registerOscHandler(11,new mr(c=>this.setOrReportBgColor(c))),this._parser.registerOscHandler(12,new mr(c=>this.setOrReportCursorColor(c))),this._parser.registerOscHandler(104,new mr(c=>this.restoreIndexedColor(c))),this._parser.registerOscHandler(110,new mr(c=>this.restoreFgColor(c))),this._parser.registerOscHandler(111,new mr(c=>this.restoreBgColor(c))),this._parser.registerOscHandler(112,new mr(c=>this.restoreCursorColor(c))),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 c in Ct)this._parser.registerEscHandler({intermediates:"(",final:c},()=>this.selectCharset("("+c)),this._parser.registerEscHandler({intermediates:")",final:c},()=>this.selectCharset(")"+c)),this._parser.registerEscHandler({intermediates:"*",final:c},()=>this.selectCharset("*"+c)),this._parser.registerEscHandler({intermediates:"+",final:c},()=>this.selectCharset("+"+c)),this._parser.registerEscHandler({intermediates:"-",final:c},()=>this.selectCharset("-"+c)),this._parser.registerEscHandler({intermediates:".",final:c},()=>this.selectCharset("."+c)),this._parser.registerEscHandler({intermediates:"/",final:c},()=>this.selectCharset("/"+c));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(c=>(this._logService.error("Parsing error: ",c),c)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new p_((c,d)=>this.requestStatusString(c,d)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,r,n){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=r,this._parseStack.position=n}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((t,r)=>setTimeout(()=>r("#SLOW_TIMEOUT"),v_))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${v_} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let r,n=this._activeBuffer.x,i=this._activeBuffer.y,s=0,o=this._parseStack.paused;if(o){if(r=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(r),r;n=this._parseStack.cursorStartX,i=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>Dn&&(s=this._parseStack.position+Dn)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e=="string"?` "${e}"`:` "${Array.prototype.map.call(e,c=>String.fromCharCode(c)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof e=="string"?e.split("").map(c=>c.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<Dn&&(this._parseBuffer=new Uint32Array(Math.min(e.length,Dn))),o||this._dirtyRowTracker.clearRange(),e.length>Dn)for(let c=s;c<e.length;c+=Dn){let d=c+Dn<e.length?c+Dn:e.length,h=typeof e=="string"?this._stringDecoder.decode(e.substring(c,d),this._parseBuffer):this._utf8Decoder.decode(e.subarray(c,d),this._parseBuffer);if(r=this._parser.parse(this._parseBuffer,h))return this._preserveStack(n,i,h,c),this._logSlowResolvingAsync(r),r}else if(!o){let c=typeof e=="string"?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(r=this._parser.parse(this._parseBuffer,c))return this._preserveStack(n,i,c,0),this._logSlowResolvingAsync(r),r}(this._activeBuffer.x!==n||this._activeBuffer.y!==i)&&this._onCursorMove.fire();let l=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),a=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);a<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(a,this._bufferService.rows-1),end:Math.min(l,this._bufferService.rows-1)})}print(e,t,r){let n,i,s=this._charsetService.charset,o=this._optionsService.rawOptions.screenReaderMode,l=this._bufferService.cols,a=this._coreService.decPrivateModes.wraparound,c=this._coreService.modes.insertMode,d=this._curAttrData,h=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&r-t>0&&h.getWidth(this._activeBuffer.x-1)===2&&h.setCellFromCodepoint(this._activeBuffer.x-1,0,1,d);let f=this._parser.precedingJoinState;for(let p=t;p<r;++p){if(n=e[p],n<127&&s){let g=s[String.fromCharCode(n)];g&&(n=g.charCodeAt(0))}let m=this._unicodeService.charProperties(n,f);i=Ti.extractWidth(m);let _=Ti.extractShouldJoin(m),b=_?Ti.extractWidth(f):0;if(f=m,o&&this._onA11yChar.fire(Fn(n)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+i-b>l){if(a){let g=h,v=this._activeBuffer.x-b;for(this._activeBuffer.x=b,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),h=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),b>0&&h instanceof lo&&h.copyCellsFrom(g,v,0,b,!1);v<l;)g.setCellFromCodepoint(v++,0,1,d)}else if(this._activeBuffer.x=l-1,i===2)continue}if(_&&this._activeBuffer.x){let g=h.getWidth(this._activeBuffer.x-1)?1:2;h.addCodepointToCell(this._activeBuffer.x-g,n,i);for(let v=i-b;--v>=0;)h.setCellFromCodepoint(this._activeBuffer.x++,0,0,d);continue}if(c&&(h.insertCells(this._activeBuffer.x,i-b,this._activeBuffer.getNullCell(d)),h.getWidth(l-1)===2&&h.setCellFromCodepoint(l-1,0,1,d)),h.setCellFromCodepoint(this._activeBuffer.x++,n,i,d),i>0)for(;--i;)h.setCellFromCodepoint(this._activeBuffer.x++,0,0,d)}this._parser.precedingJoinState=f,this._activeBuffer.x<l&&r-t>0&&h.getWidth(this._activeBuffer.x)===0&&!h.hasContent(this._activeBuffer.x)&&h.setCellFromCodepoint(this._activeBuffer.x,0,1,d),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,r=>__(r.params[0],this._optionsService.rawOptions.windowOptions)?t(r):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new p_(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new mr(t))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){var e;if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&((e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))!=null&&e.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);t.hasWidth(this._activeBuffer.x)&&!t.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),(t===2||t===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,r,n=!1,i=!1){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);s.replaceCells(t,r,this._activeBuffer.getNullCell(this._eraseAttrData()),i),n&&(s.isWrapped=!1)}_resetBufferLine(e,t=!1){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);r&&(r.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),r.isWrapped=!1)}eraseInDisplay(e,t=!1){var n;this._restrictCursor(this._bufferService.cols);let r;switch(e.params[0]){case 0:for(r=this._activeBuffer.y,this._dirtyRowTracker.markDirty(r),this._eraseInBufferLine(r++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);r<this._bufferService.rows;r++)this._resetBufferLine(r,t);this._dirtyRowTracker.markDirty(r);break;case 1:for(r=this._activeBuffer.y,this._dirtyRowTracker.markDirty(r),this._eraseInBufferLine(r,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(r+1).isWrapped=!1);r--;)this._resetBufferLine(r,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(r=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,r-1);r--&&!((n=this._activeBuffer.lines.get(this._activeBuffer.ybase+r))!=null&&n.getTrimmedLength()););for(;r>=0;r--)this._bufferService.scroll(this._eraseAttrData())}else{for(r=this._bufferService.rows,this._dirtyRowTracker.markDirty(r-1);r--;)this._resetBufferLine(r,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let i=this._activeBuffer.lines.length-this._bufferService.rows;i>0&&(this._activeBuffer.lines.trimStart(i),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-i,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-i,0),this._onScroll.fire(0));break}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let r=this._activeBuffer.ybase+this._activeBuffer.y,n=this._bufferService.rows-1-this._activeBuffer.scrollBottom,i=this._bufferService.rows-1+this._activeBuffer.ybase-n+1;for(;t--;)this._activeBuffer.lines.splice(i-1,1),this._activeBuffer.lines.splice(r,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let r=this._activeBuffer.ybase+this._activeBuffer.y,n;for(n=this._bufferService.rows-1-this._activeBuffer.scrollBottom,n=this._bufferService.rows-1+this._activeBuffer.ybase-n;t--;)this._activeBuffer.lines.splice(r,1),this._activeBuffer.lines.splice(n,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.insertCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.deleteCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(gt));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let r=this._activeBuffer.scrollTop;r<=this._activeBuffer.scrollBottom;++r){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+r);n.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let r=this._activeBuffer.scrollTop;r<=this._activeBuffer.scrollBottom;++r){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+r);n.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let r=this._activeBuffer.scrollTop;r<=this._activeBuffer.scrollBottom;++r){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+r);n.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let r=this._activeBuffer.scrollTop;r<=this._activeBuffer.scrollBottom;++r){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+r);n.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e){let t=this._parser.precedingJoinState;if(!t)return!0;let r=e.params[0]||1,n=Ti.extractWidth(t),i=this._activeBuffer.x-n,s=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(i),o=new Uint32Array(s.length*r),l=0;for(let c=0;c<s.length;){let d=s.codePointAt(c)||0;o[l++]=d,c+=d>65535?2:1}let a=l;for(let c=1;c<r;++c)o.copyWithin(a,0,l),a+=l;return this.print(o,0,a),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(Q.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(Q.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(Q.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(Q.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(Q.ESC+"[>83;40003;0c")),!0}_is(e){return(this._optionsService.rawOptions.termName+"").indexOf(e)===0}setMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0;break}return!0}setModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,Si),this._charsetService.setgCharset(1,Si),this._charsetService.setgCharset(2,Si),this._charsetService.setgCharset(3,Si);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1e3:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!0;break}return!0}resetMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1;break}return!0}resetModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),e.params[t]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!1,this._onRequestRefreshRows.fire(void 0);break}return!0}requestMode(e,t){(_=>(_[_.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",_[_.SET=1]="SET",_[_.RESET=2]="RESET",_[_.PERMANENTLY_SET=3]="PERMANENTLY_SET",_[_.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(void 0||(r={}));let n=this._coreService.decPrivateModes,{activeProtocol:i,activeEncoding:s}=this._coreMouseService,o=this._coreService,{buffers:l,cols:a}=this._bufferService,{active:c,alt:d}=l,h=this._optionsService.rawOptions,f=(_,b)=>(o.triggerDataEvent(`${Q.ESC}[${t?"":"?"}${_};${b}$y`),!0),p=_=>_?1:2,m=e.params[0];return t?m===2?f(m,4):m===4?f(m,p(o.modes.insertMode)):m===12?f(m,3):m===20?f(m,p(h.convertEol)):f(m,0):m===1?f(m,p(n.applicationCursorKeys)):m===3?f(m,h.windowOptions.setWinLines?a===80?2:a===132?1:0:0):m===6?f(m,p(n.origin)):m===7?f(m,p(n.wraparound)):m===8?f(m,3):m===9?f(m,p(i==="X10")):m===12?f(m,p(h.cursorBlink)):m===25?f(m,p(!o.isCursorHidden)):m===45?f(m,p(n.reverseWraparound)):m===66?f(m,p(n.applicationKeypad)):m===67?f(m,4):m===1e3?f(m,p(i==="VT200")):m===1002?f(m,p(i==="DRAG")):m===1003?f(m,p(i==="ANY")):m===1004?f(m,p(n.sendFocus)):m===1005?f(m,4):m===1006?f(m,p(s==="SGR")):m===1015?f(m,4):m===1016?f(m,p(s==="SGR_PIXELS")):m===1048?f(m,1):m===47||m===1047||m===1049?f(m,p(c===d)):m===2004?f(m,p(n.bracketedPasteMode)):m===2026?f(m,p(n.synchronizedOutput)):f(m,0)}_updateAttrColor(e,t,r,n,i){return t===2?(e|=50331648,e&=-16777216,e|=hl.fromColorRGB([r,n,i])):t===5&&(e&=-50331904,e|=33554432|r&255),e}_extractColor(e,t,r){let n=[0,0,-1,0,0,0],i=0,s=0;do{if(n[s+i]=e.params[t+s],e.hasSubParams(t+s)){let o=e.getSubParams(t+s),l=0;do n[1]===5&&(i=1),n[s+l+1+i]=o[l];while(++l<o.length&&l+s+1+i<n.length);break}if(n[1]===5&&s+i>=2||n[1]===2&&s+i>=5)break;n[1]&&(i=1)}while(++s+t<e.length&&s+i<n.length);for(let o=2;o<n.length;++o)n[o]===-1&&(n[o]=0);switch(n[0]){case 38:r.fg=this._updateAttrColor(r.fg,n[1],n[3],n[4],n[5]);break;case 48:r.bg=this._updateAttrColor(r.bg,n[1],n[3],n[4],n[5]);break;case 58:r.extended=r.extended.clone(),r.extended.underlineColor=this._updateAttrColor(r.extended.underlineColor,n[1],n[3],n[4],n[5])}return s}_processUnderline(e,t){t.extended=t.extended.clone(),(!~e||e>5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,e===0&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=gt.fg,e.bg=gt.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let t=e.length,r,n=this._curAttrData;for(let i=0;i<t;i++)r=e.params[i],r>=30&&r<=37?(n.fg&=-50331904,n.fg|=16777216|r-30):r>=40&&r<=47?(n.bg&=-50331904,n.bg|=16777216|r-40):r>=90&&r<=97?(n.fg&=-50331904,n.fg|=16777216|r-90|8):r>=100&&r<=107?(n.bg&=-50331904,n.bg|=16777216|r-100|8):r===0?this._processSGR0(n):r===1?n.fg|=134217728:r===3?n.bg|=67108864:r===4?(n.fg|=268435456,this._processUnderline(e.hasSubParams(i)?e.getSubParams(i)[0]:1,n)):r===5?n.fg|=536870912:r===7?n.fg|=67108864:r===8?n.fg|=1073741824:r===9?n.fg|=2147483648:r===2?n.bg|=134217728:r===21?this._processUnderline(2,n):r===22?(n.fg&=-134217729,n.bg&=-134217729):r===23?n.bg&=-67108865:r===24?(n.fg&=-268435457,this._processUnderline(0,n)):r===25?n.fg&=-536870913:r===27?n.fg&=-67108865:r===28?n.fg&=-1073741825:r===29?n.fg&=2147483647:r===39?(n.fg&=-67108864,n.fg|=gt.fg&16777215):r===49?(n.bg&=-67108864,n.bg|=gt.bg&16777215):r===38||r===48||r===58?i+=this._extractColor(e,i,n):r===53?n.bg|=1073741824:r===55?n.bg&=-1073741825:r===59?(n.extended=n.extended.clone(),n.extended.underlineColor=-1,n.updateExtended()):r===100?(n.fg&=-67108864,n.fg|=gt.fg&16777215,n.bg&=-67108864,n.bg|=gt.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",r);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${Q.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,r=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${Q.ESC}[${t};${r}R`);break}return!0}deviceStatusPrivate(e){switch(e.params[0]){case 6:let t=this._activeBuffer.y+1,r=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${Q.ESC}[?${t};${r}R`);break}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=gt.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(e){let t=e.length===0?1:e.params[0];if(t===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(t){case 1:case 2:this._coreService.decPrivateModes.cursorStyle="block";break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle="underline";break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle="bar";break}let r=t%2===1;this._coreService.decPrivateModes.cursorBlink=r}return!0}setScrollRegion(e){let t=e.params[0]||1,r;return(e.length<2||(r=e.params[1])>this._bufferService.rows||r===0)&&(r=this._bufferService.rows),r>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=r-1,this._setCursor(0,0)),!0}windowOptions(e){if(!__(e.params[0],this._optionsService.rawOptions.windowOptions))return!0;let t=e.length>1?e.params[1]:0;switch(e.params[0]){case 14:t!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${Q.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>g_&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>g_&&this._iconNameStack.shift());break;case 23:(t===0||t===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(t===0||t===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop());break}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let t=[],r=e.split(";");for(;r.length>1;){let n=r.shift(),i=r.shift();if(/^\d+$/.exec(n)){let s=parseInt(n);if(y_(s))if(i==="?")t.push({type:0,index:s});else{let o=m_(i);o&&t.push({type:1,index:s,color:o})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(";");if(t===-1)return!0;let r=e.slice(0,t).trim(),n=e.slice(t+1);return n?this._createHyperlink(r,n):r.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let r=e.split(":"),n,i=r.findIndex(s=>s.startsWith("id="));return i!==-1&&(n=r[i].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:n,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let r=e.split(";");for(let n=0;n<r.length&&!(t>=this._specialColors.length);++n,++t)if(r[n]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let i=m_(r[n]);i&&this._onColor.fire([{type:1,index:this._specialColors[t],color:i}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let t=[],r=e.split(";");for(let n=0;n<r.length;++n)if(/^\d+$/.exec(r[n])){let i=parseInt(r[n]);y_(i)&&t.push({type:2,index:i})}return t.length&&this._onColor.fire(t),!0}restoreFgColor(e){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(e){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(e){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,Si),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(MM[e[0]],Ct[e[1]]||Si),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){let e=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,e,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=gt.clone(),this._eraseAttrDataInternal=gt.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(e){return this._charsetService.setgLevel(e),!0}screenAlignmentPattern(){let e=new Ar;e.content=1<<22|69,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t<this._bufferService.rows;++t){let r=this._activeBuffer.ybase+this._activeBuffer.y+t,n=this._activeBuffer.lines.get(r);n&&(n.fill(e),n.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let r=o=>(this._coreService.triggerDataEvent(`${Q.ESC}${o}${Q.ESC}\\`),!0),n=this._bufferService.buffer,i=this._optionsService.rawOptions;return r(e==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:e==='"p'?'P1$r61;1"p':e==="r"?`P1$r${n.scrollTop+1};${n.scrollBottom+1}r`:e==="m"?"P1$r0m":e===" q"?`P1$r${{block:2,underline:4,bar:6}[i.cursorStyle]-(i.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},Rd=class{constructor(e){this._bufferService=e,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(e){e<this.start?this.start=e:e>this.end&&(this.end=e)}markRangeDirty(e,t){e>t&&(x_=e,e=t,t=x_),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};Rd=ut([ue(0,tr)],Rd);function y_(e){return 0<=e&&e<256}var IM=5e7,b_=12,jM=50,DM=class extends Be{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 ae),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 r;for(;r=this._writeBuffer.shift();){this._action(r);let n=this._callbacks.shift();n&&n()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>IM)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 r=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let n=this._writeBuffer[this._bufferOffset],i=this._action(n,t);if(i){let o=l=>performance.now()-r>=b_?setTimeout(()=>this._innerWrite(0,l)):this._innerWrite(r,l);i.catch(l=>(queueMicrotask(()=>{throw l}),Promise.resolve(!1))).then(o);return}let s=this._callbacks[this._bufferOffset];if(s&&s(),this._bufferOffset++,this._pendingData-=n.length,performance.now()-r>=b_)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>jM&&(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()}},Md=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let t=this._bufferService.buffer;if(e.id===void 0){let l=t.addMarker(t.ybase+t.y),a={data:e,id:this._nextId++,lines:[l]};return l.onDispose(()=>this._removeMarkerFromLink(a,l)),this._dataByLinkId.set(a.id,a),a.id}let r=e,n=this._getEntryIdKey(r),i=this._entriesWithId.get(n);if(i)return this.addLineToLink(i.id,t.ybase+t.y),i.id;let s=t.addMarker(t.ybase+t.y),o={id:this._nextId++,key:this._getEntryIdKey(r),data:r,lines:[s]};return s.onDispose(()=>this._removeMarkerFromLink(o,s)),this._entriesWithId.set(o.key,o),this._dataByLinkId.set(o.id,o),o.id}addLineToLink(e,t){let r=this._dataByLinkId.get(e);if(r&&r.lines.every(n=>n.line!==t)){let n=this._bufferService.buffer.addMarker(t);r.lines.push(n),n.onDispose(()=>this._removeMarkerFromLink(r,n))}}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 r=e.lines.indexOf(t);r!==-1&&(e.lines.splice(r,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};Md=ut([ue(0,tr)],Md);var w_=!1,AM=class extends Be{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new Ts),this._onBinary=this._register(new ae),this.onBinary=this._onBinary.event,this._onData=this._register(new ae),this.onData=this._onData.event,this._onLineFeed=this._register(new ae),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new ae),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new ae),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new ae),this._instantiationService=new oM,this.optionsService=this._register(new gM(e)),this._instantiationService.setService(rr,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(Ed)),this._instantiationService.setService(tr,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(Cd)),this._instantiationService.setService(Y0,this._logService),this.coreService=this._register(this._instantiationService.createInstance(Nd)),this._instantiationService.setService(Ki,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(Td)),this._instantiationService.setService(q0,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(Ti)),this._instantiationService.setService(r3,this.unicodeService),this._charsetService=this._instantiationService.createInstance(bM),this._instantiationService.setService(t3,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(Md),this._instantiationService.setService(X0,this._oscLinkService),this._inputHandler=this._register(new LM(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(Bt.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(Bt.forward(this._bufferService.onResize,this._onResize)),this._register(Bt.forward(this.coreService.onData,this._onData)),this._register(Bt.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 DM((t,r)=>this._inputHandler.parse(t,r))),this._register(Bt.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new ae),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&&!w_&&(this._logService.warn("writeSync is unreliable and will be removed soon."),w_=!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,N1),t=Math.max(t,T1),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(f_.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(f_(this._bufferService),!1))),this._windowsWrappingHeuristics.value=rt(()=>{for(let t of e)t.dispose()})}}},BM={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 OM(e,t,r,n){var o;let i={type:0,cancel:!1,key:void 0},s=(e.shiftKey?1:0)|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:e.key==="UIKeyInputUpArrow"?t?i.key=Q.ESC+"OA":i.key=Q.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?i.key=Q.ESC+"OD":i.key=Q.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?i.key=Q.ESC+"OC":i.key=Q.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?i.key=Q.ESC+"OB":i.key=Q.ESC+"[B");break;case 8:i.key=e.ctrlKey?"\b":Q.DEL,e.altKey&&(i.key=Q.ESC+i.key);break;case 9:if(e.shiftKey){i.key=Q.ESC+"[Z";break}i.key=Q.HT,i.cancel=!0;break;case 13:i.key=e.altKey?Q.ESC+Q.CR:Q.CR,i.cancel=!0;break;case 27:i.key=Q.ESC,e.altKey&&(i.key=Q.ESC+Q.ESC),i.cancel=!0;break;case 37:if(e.metaKey)break;s?i.key=Q.ESC+"[1;"+(s+1)+"D":t?i.key=Q.ESC+"OD":i.key=Q.ESC+"[D";break;case 39:if(e.metaKey)break;s?i.key=Q.ESC+"[1;"+(s+1)+"C":t?i.key=Q.ESC+"OC":i.key=Q.ESC+"[C";break;case 38:if(e.metaKey)break;s?i.key=Q.ESC+"[1;"+(s+1)+"A":t?i.key=Q.ESC+"OA":i.key=Q.ESC+"[A";break;case 40:if(e.metaKey)break;s?i.key=Q.ESC+"[1;"+(s+1)+"B":t?i.key=Q.ESC+"OB":i.key=Q.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(i.key=Q.ESC+"[2~");break;case 46:s?i.key=Q.ESC+"[3;"+(s+1)+"~":i.key=Q.ESC+"[3~";break;case 36:s?i.key=Q.ESC+"[1;"+(s+1)+"H":t?i.key=Q.ESC+"OH":i.key=Q.ESC+"[H";break;case 35:s?i.key=Q.ESC+"[1;"+(s+1)+"F":t?i.key=Q.ESC+"OF":i.key=Q.ESC+"[F";break;case 33:e.shiftKey?i.type=2:e.ctrlKey?i.key=Q.ESC+"[5;"+(s+1)+"~":i.key=Q.ESC+"[5~";break;case 34:e.shiftKey?i.type=3:e.ctrlKey?i.key=Q.ESC+"[6;"+(s+1)+"~":i.key=Q.ESC+"[6~";break;case 112:s?i.key=Q.ESC+"[1;"+(s+1)+"P":i.key=Q.ESC+"OP";break;case 113:s?i.key=Q.ESC+"[1;"+(s+1)+"Q":i.key=Q.ESC+"OQ";break;case 114:s?i.key=Q.ESC+"[1;"+(s+1)+"R":i.key=Q.ESC+"OR";break;case 115:s?i.key=Q.ESC+"[1;"+(s+1)+"S":i.key=Q.ESC+"OS";break;case 116:s?i.key=Q.ESC+"[15;"+(s+1)+"~":i.key=Q.ESC+"[15~";break;case 117:s?i.key=Q.ESC+"[17;"+(s+1)+"~":i.key=Q.ESC+"[17~";break;case 118:s?i.key=Q.ESC+"[18;"+(s+1)+"~":i.key=Q.ESC+"[18~";break;case 119:s?i.key=Q.ESC+"[19;"+(s+1)+"~":i.key=Q.ESC+"[19~";break;case 120:s?i.key=Q.ESC+"[20;"+(s+1)+"~":i.key=Q.ESC+"[20~";break;case 121:s?i.key=Q.ESC+"[21;"+(s+1)+"~":i.key=Q.ESC+"[21~";break;case 122:s?i.key=Q.ESC+"[23;"+(s+1)+"~":i.key=Q.ESC+"[23~";break;case 123:s?i.key=Q.ESC+"[24;"+(s+1)+"~":i.key=Q.ESC+"[24~";break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?i.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?i.key=Q.NUL:e.keyCode>=51&&e.keyCode<=55?i.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?i.key=Q.DEL:e.keyCode===219?i.key=Q.ESC:e.keyCode===220?i.key=Q.FS:e.keyCode===221&&(i.key=Q.GS);else if((!r||n)&&e.altKey&&!e.metaKey){let l=(o=BM[e.keyCode])==null?void 0:o[e.shiftKey?1:0];if(l)i.key=Q.ESC+l;else if(e.keyCode>=65&&e.keyCode<=90){let a=e.ctrlKey?e.keyCode-64:e.keyCode+32,c=String.fromCharCode(a);e.shiftKey&&(c=c.toUpperCase()),i.key=Q.ESC+c}else if(e.keyCode===32)i.key=Q.ESC+(e.ctrlKey?Q.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let a=e.code.slice(3,4);e.shiftKey||(a=a.toLowerCase()),i.key=Q.ESC+a,i.cancel=!0}}else r&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(i.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?i.key=e.key:e.key&&e.ctrlKey&&(e.key==="_"&&(i.key=Q.US),e.key==="@"&&(i.key=Q.NUL));break}return i}var ht=0,zM=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new ec,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new ec,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((i,s)=>this._getKey(i)-this._getKey(s)),t=0,r=0,n=new Array(this._array.length+this._insertedValues.length);for(let i=0;i<n.length;i++)r>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[r])?(n[i]=e[t],t++):n[i]=this._array[r++];this._array=n,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||(ht=this._search(t),ht===-1)||this._getKey(this._array[ht])!==t)return!1;do if(this._array[ht]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(ht),!0;while(++ht<this._array.length&&this._getKey(this._array[ht])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((i,s)=>i-s),t=0,r=new Array(this._array.length-e.length),n=0;for(let i=0;i<this._array.length;i++)e[t]===i?t++:r[n++]=this._array[i];this._array=r,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(ht=this._search(e),!(ht<0||ht>=this._array.length)&&this._getKey(this._array[ht])===e))do yield this._array[ht];while(++ht<this._array.length&&this._getKey(this._array[ht])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(ht=this._search(e),!(ht<0||ht>=this._array.length)&&this._getKey(this._array[ht])===e))do t(this._array[ht]);while(++ht<this._array.length&&this._getKey(this._array[ht])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,r=this._array.length-1;for(;r>=t;){let n=t+r>>1,i=this._getKey(this._array[n]);if(i>e)r=n-1;else if(i<e)t=n+1;else{for(;n>0&&this._getKey(this._array[n-1])===e;)n--;return n}}return t}},ju=0,S_=0,$M=class extends Be{constructor(){super(),this._decorations=new zM(e=>e==null?void 0:e.marker.line),this._onDecorationRegistered=this._register(new ae),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new ae),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(rt(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new FM(e);if(t){let r=t.marker.onDispose(()=>t.dispose()),n=t.onDispose(()=>{n.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),r.dispose())});this._decorations.insert(t),this._onDecorationRegistered.fire(t)}return t}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,t,r){let n=0,i=0;for(let s of this._decorations.getKeyIterator(t))n=s.options.x??0,i=n+(s.options.width??1),e>=n&&e<i&&(!r||(s.options.layer??"bottom")===r)&&(yield s)}forEachDecorationAtCell(e,t,r,n){this._decorations.forEachByKey(t,i=>{ju=i.options.x??0,S_=ju+(i.options.width??1),e>=ju&&e<S_&&(!r||(i.options.layer??"bottom")===r)&&n(i)})}},FM=class extends ri{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new ae),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new ae),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=e.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=it.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=it.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},WM=1e3,HM=class{constructor(e,t=WM){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,r){this._rowCount=r,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 n=performance.now();if(n-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=n,this._innerRefresh();else if(!this._additionalRefreshRequested){let i=n-this._lastRefreshMs,s=this._debounceThresholdMS-i;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},s)}}_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)}},k_=20,tc=class extends Be{constructor(e,t,r,n){super(),this._terminal=e,this._coreBrowserService=r,this._renderService=n,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let i=this._coreBrowserService.mainDocument;this._accessibilityContainer=i.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=i.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let s=0;s<this._terminal.rows;s++)this._rowElements[s]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[s]);if(this._topBoundaryFocusListener=s=>this._handleBoundaryFocus(s,0),this._bottomBoundaryFocusListener=s=>this._handleBoundaryFocus(s,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=i.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new HM(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(s=>this._handleResize(s.rows))),this._register(this._terminal.onRender(s=>this._refreshRows(s.start,s.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(s=>this._handleChar(s))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
|
|
128
|
+
`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),hp&&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),r=this._model.finalSelectionStart,n=this._model.finalSelectionEnd;return!r||!n||!t?!1:this._areCoordsInSelection(t,r,n)}isCellInSelection(e,t){let r=this._model.finalSelectionStart,n=this._model.finalSelectionEnd;return!r||!n?!1:this._areCoordsInSelection([e,t],r,n)}_areCoordsInSelection(e,t,r){return e[1]>t[1]&&e[1]<r[1]||t[1]===r[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<r[0]||t[1]<r[1]&&e[1]===r[1]&&e[0]<r[0]||t[1]<r[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){var i,s;let r=(s=(i=this._linkifier.currentLink)==null?void 0:i.link)==null?void 0:s.range;if(r)return this._model.selectionStart=[r.start.x-1,r.start.y-1],this._model.selectionStartLength=t_(r,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let n=this._getMouseBufferCoords(e);return n?(this._selectWordAt(n,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=up(this._coreBrowserService.window,e,this._screenElement)[1],r=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=r?0:(t>r&&(t-=r),t=Math.min(Math.max(t,-Tu),Tu),t/=Tu,t/Math.abs(t)+Math.round(t*(ZR-1)))}shouldForceSelection(e){return Za?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(),eM)}_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&&!(Za&&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 r=this._bufferService.buffer;if(this._model.selectionEnd[1]<r.lines.length){let n=r.lines.get(this._model.selectionEnd[1]);n&&n.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<tM&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let r=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(r&&r[0]!==void 0&&r[1]!==void 0){let n=KR(r[0]-1,r[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(n,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,r=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);if(!r){this._oldHasSelection&&this._fireOnSelectionChange(e,t,r);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,r)}_fireOnSelectionChange(e,t,r){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=r,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(t=>this._handleTrim(t))}_convertViewportColToCharacterIndex(e,t){let r=t;for(let n=0;t>=n;n++){let i=e.loadCell(n,this._workCell).getChars().length;this._workCell.getWidth()===0?r--:i>1&&t!==n&&(r+=i-1)}return r}setSelection(e,t,r){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=r,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,r=!0,n=!0){if(e[0]>=this._bufferService.cols)return;let i=this._bufferService.buffer,s=i.lines.get(e[1]);if(!s)return;let o=i.translateBufferLineToString(e[1],!1),l=this._convertViewportColToCharacterIndex(s,e[0]),a=l,c=e[0]-l,d=0,h=0,f=0,p=0;if(o.charAt(l)===" "){for(;l>0&&o.charAt(l-1)===" ";)l--;for(;a<o.length&&o.charAt(a+1)===" ";)a++}else{let b=e[0],g=e[0];s.getWidth(b)===0&&(d++,b--),s.getWidth(g)===2&&(h++,g++);let v=s.getString(g).length;for(v>1&&(p+=v-1,a+=v-1);b>0&&l>0&&!this._isCharWordSeparator(s.loadCell(b-1,this._workCell));){s.loadCell(b-1,this._workCell);let y=this._workCell.getChars().length;this._workCell.getWidth()===0?(d++,b--):y>1&&(f+=y-1,l-=y-1),l--,b--}for(;g<s.length&&a+1<o.length&&!this._isCharWordSeparator(s.loadCell(g+1,this._workCell));){s.loadCell(g+1,this._workCell);let y=this._workCell.getChars().length;this._workCell.getWidth()===2?(h++,g++):y>1&&(p+=y-1,a+=y-1),a++,g++}}a++;let m=l+c-d+f,_=Math.min(this._bufferService.cols,a-l+d+h-f-p);if(!(!t&&o.slice(l,a).trim()==="")){if(r&&m===0&&s.getCodePoint(0)!==32){let b=i.lines.get(e[1]-1);if(b&&s.isWrapped&&b.getCodePoint(this._bufferService.cols-1)!==32){let g=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(g){let v=this._bufferService.cols-g.start;m-=v,_+=v}}}if(n&&m+_===this._bufferService.cols&&s.getCodePoint(this._bufferService.cols-1)!==32){let b=i.lines.get(e[1]+1);if(b!=null&&b.isWrapped&&b.getCodePoint(0)!==32){let g=this._getWordAt([0,e[1]+1],!1,!1,!0);g&&(_+=g.length)}}return{start:m,length:_}}}_selectWordAt(e,t){let r=this._getWordAt(e,t);if(r){for(;r.start<0;)r.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[r.start,e[1]],this._model.selectionStartLength=r.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let r=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,r--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,r++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,r]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),r={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=t_(r,this._bufferService.cols)}};Sd=ut([ue(3,tr),ue(4,Ki),ue(5,np),ue(6,rr),ue(7,Pn),ue(8,Tn)],Sd);var r_=class{constructor(){this._data={}}set(e,t,r){this._data[e]||(this._data[e]={}),this._data[e][t]=r}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},n_=class{constructor(){this._color=new r_,this._css=new r_}setCss(e,t,r){this._css.set(e,t,r)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,r){this._color.set(e,t,r)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},yt=Object.freeze((()=>{let e=[it.toColor("#2e3436"),it.toColor("#cc0000"),it.toColor("#4e9a06"),it.toColor("#c4a000"),it.toColor("#3465a4"),it.toColor("#75507b"),it.toColor("#06989a"),it.toColor("#d3d7cf"),it.toColor("#555753"),it.toColor("#ef2929"),it.toColor("#8ae234"),it.toColor("#fce94f"),it.toColor("#729fcf"),it.toColor("#ad7fa8"),it.toColor("#34e2e2"),it.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let r=0;r<216;r++){let n=t[r/36%6|0],i=t[r/6%6|0],s=t[r%6];e.push({css:_t.toCss(n,i,s),rgba:_t.toRgba(n,i,s)})}for(let r=0;r<24;r++){let n=8+r*10;e.push({css:_t.toCss(n,n,n),rgba:_t.toRgba(n,n,n)})}return e})()),wi=it.toColor("#ffffff"),oo=it.toColor("#000000"),i_=it.toColor("#ffffff"),s_=oo,Xs={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},iM=wi,kd=class extends Be{constructor(e){super(),this._optionsService=e,this._contrastCache=new n_,this._halfContrastCache=new n_,this._onChangeColors=this._register(new le),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:wi,background:oo,cursor:i_,cursorAccent:s_,selectionForeground:void 0,selectionBackgroundTransparent:Xs,selectionBackgroundOpaque:Ze.blend(oo,Xs),selectionInactiveBackgroundTransparent:Xs,selectionInactiveBackgroundOpaque:Ze.blend(oo,Xs),scrollbarSliderBackground:Ze.opacity(wi,.2),scrollbarSliderHoverBackground:Ze.opacity(wi,.4),scrollbarSliderActiveBackground:Ze.opacity(wi,.5),overviewRulerBorder:wi,ansi:yt.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this._register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",()=>this._contrastCache.clear())),this._register(this._optionsService.onSpecificOptionChange("theme",()=>this._setTheme(this._optionsService.rawOptions.theme)))}get colors(){return this._colors}_setTheme(e={}){let t=this._colors;if(t.foreground=qe(e.foreground,wi),t.background=qe(e.background,oo),t.cursor=Ze.blend(t.background,qe(e.cursor,i_)),t.cursorAccent=Ze.blend(t.background,qe(e.cursorAccent,s_)),t.selectionBackgroundTransparent=qe(e.selectionBackground,Xs),t.selectionBackgroundOpaque=Ze.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=qe(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=Ze.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?qe(e.selectionForeground,Jg):void 0,t.selectionForeground===Jg&&(t.selectionForeground=void 0),Ze.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=Ze.opacity(t.selectionBackgroundTransparent,.3)),Ze.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=Ze.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=qe(e.scrollbarSliderBackground,Ze.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=qe(e.scrollbarSliderHoverBackground,Ze.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=qe(e.scrollbarSliderActiveBackground,Ze.opacity(t.foreground,.5)),t.overviewRulerBorder=qe(e.overviewRulerBorder,iM),t.ansi=yt.slice(),t.ansi[0]=qe(e.black,yt[0]),t.ansi[1]=qe(e.red,yt[1]),t.ansi[2]=qe(e.green,yt[2]),t.ansi[3]=qe(e.yellow,yt[3]),t.ansi[4]=qe(e.blue,yt[4]),t.ansi[5]=qe(e.magenta,yt[5]),t.ansi[6]=qe(e.cyan,yt[6]),t.ansi[7]=qe(e.white,yt[7]),t.ansi[8]=qe(e.brightBlack,yt[8]),t.ansi[9]=qe(e.brightRed,yt[9]),t.ansi[10]=qe(e.brightGreen,yt[10]),t.ansi[11]=qe(e.brightYellow,yt[11]),t.ansi[12]=qe(e.brightBlue,yt[12]),t.ansi[13]=qe(e.brightMagenta,yt[13]),t.ansi[14]=qe(e.brightCyan,yt[14]),t.ansi[15]=qe(e.brightWhite,yt[15]),e.extendedAnsi){let r=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let n=0;n<r;n++)t.ansi[n+16]=qe(e.extendedAnsi[n],yt[n+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()}}};kd=ut([ue(0,rr)],kd);function qe(e,t){if(e!==void 0)try{return it.toColor(e)}catch{}return t}var sM=class{constructor(...e){this._entries=new Map;for(let[t,r]of e)this.set(t,r)}set(e,t){let r=this._entries.get(e);return this._entries.set(e,t),r}forEach(e){for(let[t,r]of this._entries.entries())e(t,r)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},oM=class{constructor(){this._services=new sM,this._services.set(rp,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let r=ZP(e).sort((s,o)=>s.index-o.index),n=[];for(let s of r){let o=this._services.get(s.id);if(!o)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${s.id._id}.`);n.push(o)}let i=r.length>0?r[0].index:t.length;if(t.length!==i)throw new Error(`[createInstance] First service dependency of ${e.name} at position ${i+1} conflicts with ${t.length} static arguments`);return new e(...t,...n)}},lM={trace:0,debug:1,info:2,warn:3,error:4,off:5},aM="xterm.js: ",Cd=class extends Be{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=lM[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,r){this._evalLazyOptionalParams(r),e.call(console,(this._optionsService.options.logger?"":aM)+t,...r)}trace(e,...t){var r;this._logLevel<=0&&this._log(((r=this._optionsService.options.logger)==null?void 0:r.trace.bind(this._optionsService.options.logger))??console.log,e,t)}debug(e,...t){var r;this._logLevel<=1&&this._log(((r=this._optionsService.options.logger)==null?void 0:r.debug.bind(this._optionsService.options.logger))??console.log,e,t)}info(e,...t){var r;this._logLevel<=2&&this._log(((r=this._optionsService.options.logger)==null?void 0:r.info.bind(this._optionsService.options.logger))??console.info,e,t)}warn(e,...t){var r;this._logLevel<=3&&this._log(((r=this._optionsService.options.logger)==null?void 0:r.warn.bind(this._optionsService.options.logger))??console.warn,e,t)}error(e,...t){var r;this._logLevel<=4&&this._log(((r=this._optionsService.options.logger)==null?void 0:r.error.bind(this._optionsService.options.logger))??console.error,e,t)}};Cd=ut([ue(0,rr)],Cd);var o_=class extends Be{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new le),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new le),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new le),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 r=0;r<Math.min(e,this.length);r++)t[r]=this._array[this._getCyclicIndex(r)];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,...r){if(t){for(let n=e;n<this._length-t;n++)this._array[this._getCyclicIndex(n)]=this._array[this._getCyclicIndex(n+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let n=this._length-1;n>=e;n--)this._array[this._getCyclicIndex(n+r.length)]=this._array[this._getCyclicIndex(n)];for(let n=0;n<r.length;n++)this._array[this._getCyclicIndex(e+n)]=r[n];if(r.length&&this.onInsertEmitter.fire({index:e,amount:r.length}),this._length+r.length>this._maxLength){let n=this._length+r.length-this._maxLength;this._startIndex+=n,this._length=this._maxLength,this.onTrimEmitter.fire(n)}else this._length+=r.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,r){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+r<0)throw new Error("Cannot shift elements in list beyond index 0");if(r>0){for(let i=t-1;i>=0;i--)this.set(e+i+r,this.get(e+i));let n=e+t+r-this._length;if(n>0)for(this._length+=n;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let n=0;n<t;n++)this.set(e+n+r,this.get(e+n))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},De=3,gt=Object.freeze(new hl),Wl=0,Pu=2,lo=class k1{constructor(t,r,n=!1){this.isWrapped=n,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*De);let i=r||Ar.fromCharData([0,H0,1,0]);for(let s=0;s<t;++s)this.setCell(s,i);this.length=t}get(t){let r=this._data[t*De+0],n=r&2097151;return[this._data[t*De+1],r&2097152?this._combined[t]:n?Fn(n):"",r>>22,r&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):n]}set(t,r){this._data[t*De+1]=r[0],r[1].length>1?(this._combined[t]=r[1],this._data[t*De+0]=t|2097152|r[2]<<22):this._data[t*De+0]=r[1].charCodeAt(0)|r[2]<<22}getWidth(t){return this._data[t*De+0]>>22}hasWidth(t){return this._data[t*De+0]&12582912}getFg(t){return this._data[t*De+1]}getBg(t){return this._data[t*De+2]}hasContent(t){return this._data[t*De+0]&4194303}getCodePoint(t){let r=this._data[t*De+0];return r&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):r&2097151}isCombined(t){return this._data[t*De+0]&2097152}getString(t){let r=this._data[t*De+0];return r&2097152?this._combined[t]:r&2097151?Fn(r&2097151):""}isProtected(t){return this._data[t*De+2]&536870912}loadCell(t,r){return Wl=t*De,r.content=this._data[Wl+0],r.fg=this._data[Wl+1],r.bg=this._data[Wl+2],r.content&2097152&&(r.combinedData=this._combined[t]),r.bg&268435456&&(r.extended=this._extendedAttrs[t]),r}setCell(t,r){r.content&2097152&&(this._combined[t]=r.combinedData),r.bg&268435456&&(this._extendedAttrs[t]=r.extended),this._data[t*De+0]=r.content,this._data[t*De+1]=r.fg,this._data[t*De+2]=r.bg}setCellFromCodepoint(t,r,n,i){i.bg&268435456&&(this._extendedAttrs[t]=i.extended),this._data[t*De+0]=r|n<<22,this._data[t*De+1]=i.fg,this._data[t*De+2]=i.bg}addCodepointToCell(t,r,n){let i=this._data[t*De+0];i&2097152?this._combined[t]+=Fn(r):i&2097151?(this._combined[t]=Fn(i&2097151)+Fn(r),i&=-2097152,i|=2097152):i=r|1<<22,n&&(i&=-12582913,i|=n<<22),this._data[t*De+0]=i}insertCells(t,r,n){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,n),r<this.length-t){let i=new Ar;for(let s=this.length-t-r-1;s>=0;--s)this.setCell(t+r+s,this.loadCell(t+s,i));for(let s=0;s<r;++s)this.setCell(t+s,n)}else for(let i=t;i<this.length;++i)this.setCell(i,n);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,n)}deleteCells(t,r,n){if(t%=this.length,r<this.length-t){let i=new Ar;for(let s=0;s<this.length-t-r;++s)this.setCell(t+s,this.loadCell(t+r+s,i));for(let s=this.length-r;s<this.length;++s)this.setCell(s,n)}else for(let i=t;i<this.length;++i)this.setCell(i,n);t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,n),this.getWidth(t)===0&&!this.hasContent(t)&&this.setCellFromCodepoint(t,0,1,n)}replaceCells(t,r,n,i=!1){if(i){for(t&&this.getWidth(t-1)===2&&!this.isProtected(t-1)&&this.setCellFromCodepoint(t-1,0,1,n),r<this.length&&this.getWidth(r-1)===2&&!this.isProtected(r)&&this.setCellFromCodepoint(r,0,1,n);t<r&&t<this.length;)this.isProtected(t)||this.setCell(t,n),t++;return}for(t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,n),r<this.length&&this.getWidth(r-1)===2&&this.setCellFromCodepoint(r,0,1,n);t<r&&t<this.length;)this.setCell(t++,n)}resize(t,r){if(t===this.length)return this._data.length*4*Pu<this._data.buffer.byteLength;let n=t*De;if(t>this.length){if(this._data.buffer.byteLength>=n*4)this._data=new Uint32Array(this._data.buffer,0,n);else{let i=new Uint32Array(n);i.set(this._data),this._data=i}for(let i=this.length;i<t;++i)this.setCell(i,r)}else{this._data=this._data.subarray(0,n);let i=Object.keys(this._combined);for(let o=0;o<i.length;o++){let l=parseInt(i[o],10);l>=t&&delete this._combined[l]}let s=Object.keys(this._extendedAttrs);for(let o=0;o<s.length;o++){let l=parseInt(s[o],10);l>=t&&delete this._extendedAttrs[l]}}return this.length=t,n*4*Pu<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*Pu<this._data.buffer.byteLength){let t=new Uint32Array(this._data.length);return t.set(this._data),this._data=t,1}return 0}fill(t,r=!1){if(r){for(let n=0;n<this.length;++n)this.isProtected(n)||this.setCell(n,t);return}this._combined={},this._extendedAttrs={};for(let n=0;n<this.length;++n)this.setCell(n,t)}copyFrom(t){this.length!==t.length?this._data=new Uint32Array(t._data):this._data.set(t._data),this.length=t.length,this._combined={};for(let r in t._combined)this._combined[r]=t._combined[r];this._extendedAttrs={};for(let r in t._extendedAttrs)this._extendedAttrs[r]=t._extendedAttrs[r];this.isWrapped=t.isWrapped}clone(){let t=new k1(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let r in this._combined)t._combined[r]=this._combined[r];for(let r in this._extendedAttrs)t._extendedAttrs[r]=this._extendedAttrs[r];return t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*De+0]&4194303)return t+(this._data[t*De+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*De+0]&4194303||this._data[t*De+2]&50331648)return t+(this._data[t*De+0]>>22);return 0}copyCellsFrom(t,r,n,i,s){let o=t._data;if(s)for(let a=i-1;a>=0;a--){for(let c=0;c<De;c++)this._data[(n+a)*De+c]=o[(r+a)*De+c];o[(r+a)*De+2]&268435456&&(this._extendedAttrs[n+a]=t._extendedAttrs[r+a])}else for(let a=0;a<i;a++){for(let c=0;c<De;c++)this._data[(n+a)*De+c]=o[(r+a)*De+c];o[(r+a)*De+2]&268435456&&(this._extendedAttrs[n+a]=t._extendedAttrs[r+a])}let l=Object.keys(t._combined);for(let a=0;a<l.length;a++){let c=parseInt(l[a],10);c>=r&&(this._combined[c-r+n]=t._combined[c])}}translateToString(t,r,n,i){r=r??0,n=n??this.length,t&&(n=Math.min(n,this.getTrimmedLength())),i&&(i.length=0);let s="";for(;r<n;){let o=this._data[r*De+0],l=o&2097151,a=o&2097152?this._combined[r]:l?Fn(l):qn;if(s+=a,i)for(let c=0;c<a.length;++c)i.push(r);r+=o>>22||1}return i&&i.push(r),s}};function cM(e,t,r,n,i,s){let o=[];for(let l=0;l<e.length-1;l++){let a=l,c=e.get(++a);if(!c.isWrapped)continue;let d=[e.get(l)];for(;a<e.length&&c.isWrapped;)d.push(c),c=e.get(++a);if(!s&&n>=l&&n<a){l+=d.length-1;continue}let h=0,f=Go(d,h,t),p=1,m=0;for(;p<d.length;){let b=Go(d,p,t),g=b-m,v=r-f,y=Math.min(g,v);d[h].copyCellsFrom(d[p],m,f,y,!1),f+=y,f===r&&(h++,f=0),m+=y,m===b&&(p++,m=0),f===0&&h!==0&&d[h-1].getWidth(r-1)===2&&(d[h].copyCellsFrom(d[h-1],r-1,f++,1,!1),d[h-1].setCell(r-1,i))}d[h].replaceCells(f,r,i);let _=0;for(let b=d.length-1;b>0&&(b>h||d[b].getTrimmedLength()===0);b--)_++;_>0&&(o.push(l+d.length-_),o.push(_)),l+=d.length-1}return o}function uM(e,t){let r=[],n=0,i=t[n],s=0;for(let o=0;o<e.length;o++)if(i===o){let l=t[++n];e.onDeleteEmitter.fire({index:o-s,amount:l}),o+=l-1,s+=l,i=t[++n]}else r.push(o);return{layout:r,countRemoved:s}}function hM(e,t){let r=[];for(let n=0;n<t.length;n++)r.push(e.get(t[n]));for(let n=0;n<r.length;n++)e.set(n,r[n]);e.length=t.length}function dM(e,t,r){let n=[],i=e.map((a,c)=>Go(e,c,t)).reduce((a,c)=>a+c),s=0,o=0,l=0;for(;l<i;){if(i-l<r){n.push(i-l);break}s+=r;let a=Go(e,o,t);s>a&&(s-=a,o++);let c=e[o].getWidth(s-1)===2;c&&s--;let d=c?r-1:r;n.push(d),l+=d}return n}function Go(e,t,r){if(t===e.length-1)return e[t].getTrimmedLength();let n=!e[t].hasContent(r-1)&&e[t].getWidth(r-1)===1,i=e[t+1].getWidth(0)===2;return n&&i?r-1:r}var C1=class E1{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=E1._nextId++,this._onDispose=this.register(new le),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),$i(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};C1._nextId=1;var fM=C1,Ct={},Si=Ct.B;Ct[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:"≥","{":"π","|":"≠","}":"£","~":"·"};Ct.A={"#":"£"};Ct.B=void 0;Ct[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};Ct.C=Ct[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Ct.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};Ct.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};Ct.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};Ct.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};Ct.E=Ct[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};Ct.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};Ct.H=Ct[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Ct["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var l_=4294967295,a_=class{constructor(e,t,r){this._hasScrollback=e,this._optionsService=t,this._bufferService=r,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=gt.clone(),this.savedCharset=Si,this.markers=[],this._nullCell=Ar.fromCharData([0,H0,1,0]),this._whitespaceCell=Ar.fromCharData([0,qn,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new ec,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new o_(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(e){return e?(this._nullCell.fg=e.fg,this._nullCell.bg=e.bg,this._nullCell.extended=e.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new Ga),this._nullCell}getWhitespaceCell(e){return e?(this._whitespaceCell.fg=e.fg,this._whitespaceCell.bg=e.bg,this._whitespaceCell.extended=e.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new Ga),this._whitespaceCell}getBlankLine(e,t){return new lo(this._bufferService.cols,this.getNullCell(e),t)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let e=this.ybase+this.y-this.ydisp;return e>=0&&e<this._rows}_getCorrectBufferLength(e){if(!this._hasScrollback)return e;let t=e+this._optionsService.rawOptions.scrollback;return t>l_?l_:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=gt);let t=this._rows;for(;t--;)this.lines.push(this.getBlankLine(e))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new o_(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let r=this.getNullCell(gt),n=0,i=this._getCorrectBufferLength(t);if(i>this.lines.maxLength&&(this.lines.maxLength=i),this.lines.length>0){if(this._cols<e)for(let o=0;o<this.lines.length;o++)n+=+this.lines.get(o).resize(e,r);let s=0;if(this._rows<t)for(let o=this._rows;o<t;o++)this.lines.length<t+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new lo(e,r)):this.ybase>0&&this.lines.length<=this.ybase+this.y+s+1?(this.ybase--,s++,this.ydisp>0&&this.ydisp--):this.lines.push(new lo(e,r)));else for(let o=this._rows;o>t;o--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(i<this.lines.maxLength){let o=this.lines.length-i;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=i}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),s&&(this.y+=s),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=t-1,this._isReflowEnabled&&(this._reflow(e,t),this._cols>e))for(let s=0;s<this.lines.length;s++)n+=+this.lines.get(s).resize(e,r);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),n>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition<this.lines.length;)if(t+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),t>100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend==="conpty"&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let r=this._optionsService.rawOptions.reflowCursorLine,n=cM(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(gt),r);if(n.length>0){let i=uM(this.lines,n);hM(this.lines,i.layout),this._reflowLargerAdjustViewport(e,t,i.countRemoved)}}_reflowLargerAdjustViewport(e,t,r){let n=this.getNullCell(gt),i=r;for(;i-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new lo(e,n))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-r,0)}_reflowSmaller(e,t){let r=this._optionsService.rawOptions.reflowCursorLine,n=this.getNullCell(gt),i=[],s=0;for(let o=this.lines.length-1;o>=0;o--){let l=this.lines.get(o);if(!l||!l.isWrapped&&l.getTrimmedLength()<=e)continue;let a=[l];for(;l.isWrapped&&o>0;)l=this.lines.get(--o),a.unshift(l);if(!r){let y=this.ybase+this.y;if(y>=o&&y<o+a.length)continue}let c=a[a.length-1].getTrimmedLength(),d=dM(a,this._cols,e),h=d.length-a.length,f;this.ybase===0&&this.y!==this.lines.length-1?f=Math.max(0,this.y-this.lines.maxLength+h):f=Math.max(0,this.lines.length-this.lines.maxLength+h);let p=[];for(let y=0;y<h;y++){let S=this.getBlankLine(gt,!0);p.push(S)}p.length>0&&(i.push({start:o+a.length+s,newLines:p}),s+=p.length),a.push(...p);let m=d.length-1,_=d[m];_===0&&(m--,_=d[m]);let b=a.length-h-1,g=c;for(;b>=0;){let y=Math.min(g,_);if(a[m]===void 0)break;if(a[m].copyCellsFrom(a[b],g-y,_-y,y,!0),_-=y,_===0&&(m--,_=d[m]),g-=y,g===0){b--;let S=Math.max(b,0);g=Go(a,S,this._cols)}}for(let y=0;y<a.length;y++)d[y]<e&&a[y].setCell(d[y],n);let v=h-f;for(;v-- >0;)this.ybase===0?this.y<t-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+s)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+h,this.ybase+t-1)}if(i.length>0){let o=[],l=[];for(let _=0;_<this.lines.length;_++)l.push(this.lines.get(_));let a=this.lines.length,c=a-1,d=0,h=i[d];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+s);let f=0;for(let _=Math.min(this.lines.maxLength-1,a+s-1);_>=0;_--)if(h&&h.start>c+f){for(let b=h.newLines.length-1;b>=0;b--)this.lines.set(_--,h.newLines[b]);_++,o.push({index:c+1,amount:h.newLines.length}),f+=h.newLines.length,h=i[++d]}else this.lines.set(_,l[c--]);let p=0;for(let _=o.length-1;_>=0;_--)o[_].index+=p,this.lines.onInsertEmitter.fire(o[_]),p+=o[_].amount;let m=Math.max(0,a+s-this.lines.maxLength);m>0&&this.lines.onTrimEmitter.fire(m)}}translateBufferLineToString(e,t,r=0,n){let i=this.lines.get(e);return i?i.translateToString(t,r,n):""}getWrappedRangeForLine(e){let t=e,r=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;r+1<this.lines.length&&this.lines.get(r+1).isWrapped;)r++;return{first:t,last:r}}setupTabStops(e){for(e!=null?this.tabs[e]||(e=this.prevStop(e)):(this.tabs={},e=0);e<this._cols;e+=this._optionsService.rawOptions.tabStopWidth)this.tabs[e]=!0}prevStop(e){for(e==null&&(e=this.x);!this.tabs[--e]&&e>0;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e==null&&(e=this.x);!this.tabs[++e]&&e<this._cols;);return e>=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let t=0;t<this.markers.length;t++)this.markers[t].line===e&&(this.markers[t].dispose(),this.markers.splice(t--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].dispose();this.markers.length=0,this._isClearing=!1}addMarker(e){let t=new fM(e);return this.markers.push(t),t.register(this.lines.onTrim(r=>{t.line-=r,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(r=>{t.line>=r.index&&(t.line+=r.amount)})),t.register(this.lines.onDelete(r=>{t.line>=r.index&&t.line<r.index+r.amount&&t.dispose(),t.line>r.index&&(t.line-=r.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},pM=class extends Be{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new le),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 a_(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new a_(!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)}},N1=2,T1=1,Ed=class extends Be{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new le),this.onResize=this._onResize.event,this._onScroll=this._register(new le),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,N1),this.rows=Math.max(e.rawOptions.rows||0,T1),this.buffers=this._register(new pM(e,this)),this._register(this.buffers.onBufferActivate(t=>{this._onScroll.fire(t.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let r=this.cols!==e,n=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:r,rowsChanged:n})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let r=this.buffer,n;n=this._cachedBlankLine,(!n||n.length!==this.cols||n.getFg(0)!==e.fg||n.getBg(0)!==e.bg)&&(n=r.getBlankLine(e,t),this._cachedBlankLine=n),n.isWrapped=t;let i=r.ybase+r.scrollTop,s=r.ybase+r.scrollBottom;if(r.scrollTop===0){let o=r.lines.isFull;s===r.lines.length-1?o?r.lines.recycle().copyFrom(n):r.lines.push(n.clone()):r.lines.splice(s+1,0,n.clone()),o?this.isUserScrolling&&(r.ydisp=Math.max(r.ydisp-1,0)):(r.ybase++,this.isUserScrolling||r.ydisp++)}else{let o=s-i+1;r.lines.shiftElements(i+1,o-1,-1),r.lines.set(s,n.clone())}this.isUserScrolling||(r.ydisp=r.ybase),this._onScroll.fire(r.ydisp)}scrollLines(e,t){let r=this.buffer;if(e<0){if(r.ydisp===0)return;this.isUserScrolling=!0}else e+r.ydisp>=r.ybase&&(this.isUserScrolling=!1);let n=r.ydisp;r.ydisp=Math.max(Math.min(r.ydisp+e,r.ybase),0),n!==r.ydisp&&(t||this._onScroll.fire(r.ydisp))}};Ed=ut([ue(0,rr)],Ed);var Gi={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:Za,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},mM=["normal","bold","100","200","300","400","500","600","700","800","900"],gM=class extends Be{constructor(e){super(),this._onOptionChange=this._register(new le),this.onOptionChange=this._onOptionChange.event;let t={...Gi};for(let r in e)if(r in t)try{let n=e[r];t[r]=this._sanitizeAndValidateOption(r,n)}catch(n){console.error(n)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(rt(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(r=>{r===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(r=>{e.indexOf(r)!==-1&&t()})}_setupOptions(){let e=r=>{if(!(r in Gi))throw new Error(`No option with key "${r}"`);return this.rawOptions[r]},t=(r,n)=>{if(!(r in Gi))throw new Error(`No option with key "${r}"`);n=this._sanitizeAndValidateOption(r,n),this.rawOptions[r]!==n&&(this.rawOptions[r]=n,this._onOptionChange.fire(r))};for(let r in this.rawOptions){let n={get:e.bind(this,r),set:t.bind(this,r)};Object.defineProperty(this.options,r,n)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=Gi[e]),!_M(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=Gi[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=mM.includes(t)?t:Gi[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 _M(e){return e==="block"||e==="underline"||e==="bar"}function ao(e,t=5){if(typeof e!="object")return e;let r=Array.isArray(e)?[]:{};for(let n in e)r[n]=t<=1?e[n]:e[n]&&ao(e[n],t-1);return r}var c_=Object.freeze({insertMode:!1}),u_=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),Nd=class extends Be{constructor(e,t,r){super(),this._bufferService=e,this._logService=t,this._optionsService=r,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new le),this.onData=this._onData.event,this._onUserInput=this._register(new le),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new le),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new le),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=ao(c_),this.decPrivateModes=ao(u_)}reset(){this.modes=ao(c_),this.decPrivateModes=ao(u_)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let r=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&r.ybase!==r.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(n=>n.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))}};Nd=ut([ue(0,tr),ue(1,Y0),ue(2,rr)],Nd);var h_={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:e=>e.button===4||e.action!==1?!1:(e.ctrl=!1,e.alt=!1,e.shift=!1,!0)},VT200:{events:19,restrict:e=>e.action!==32},DRAG:{events:23,restrict:e=>!(e.action===32&&e.button===3)},ANY:{events:31,restrict:e=>!0}};function Ru(e,t){let r=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(r|=64,r|=e.action):(r|=e.button&3,e.button&4&&(r|=64),e.button&8&&(r|=128),e.action===32?r|=32:e.action===0&&!t&&(r|=3)),r}var Mu=String.fromCharCode,d_={DEFAULT:e=>{let t=[Ru(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${Mu(t[0])}${Mu(t[1])}${Mu(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${Ru(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${Ru(e,!0)};${e.x};${e.y}${t}`}},Td=class extends Be{constructor(e,t,r){super(),this._bufferService=e,this._coreService=t,this._optionsService=r,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new le),this.onProtocolChange=this._onProtocolChange.event;for(let n of Object.keys(h_))this.addProtocol(n,h_[n]);for(let n of Object.keys(d_))this.addEncoding(n,d_[n]);this.reset()}addProtocol(e,t){this._protocols[e]=t}addEncoding(e,t){this._encodings[e]=t}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e){if(!this._protocols[e])throw new Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw new Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,t,r){if(e.deltaY===0||e.shiftKey||t===void 0||r===void 0)return 0;let n=t/r,i=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(i/=n+0,Math.abs(e.deltaY)<50&&(i*=.3),this._wheelPartialScroll+=i,i=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(i*=this._bufferService.rows),i}_applyScrollModifier(e,t){return t.altKey||t.ctrlKey||t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||e.button===4&&e.action===32||e.button===3&&e.action!==32||e.button!==4&&(e.action===2||e.action===3)||(e.col++,e.row++,e.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,e,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(e))return!1;let t=this._encodings[this._activeEncoding](e);return t&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(e&1),up:!!(e&2),drag:!!(e&4),move:!!(e&8),wheel:!!(e&16)}}_equalEvents(e,t,r){if(r){if(e.x!==t.x||e.y!==t.y)return!1}else if(e.col!==t.col||e.row!==t.row)return!1;return!(e.button!==t.button||e.action!==t.action||e.ctrl!==t.ctrl||e.alt!==t.alt||e.shift!==t.shift)}};Td=ut([ue(0,tr),ue(1,Ki),ue(2,rr)],Td);var Lu=[[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]],vM=[[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]],bt;function xM(e,t){let r=0,n=t.length-1,i;if(e<t[0][0]||e>t[n][1])return!1;for(;n>=r;)if(i=r+n>>1,e>t[i][1])r=i+1;else if(e<t[i][0])n=i-1;else return!0;return!1}var yM=class{constructor(){if(this.version="6",!bt){bt=new Uint8Array(65536),bt.fill(1),bt[0]=0,bt.fill(0,1,32),bt.fill(0,127,160),bt.fill(2,4352,4448),bt[9001]=2,bt[9002]=2,bt.fill(2,11904,42192),bt[12351]=1,bt.fill(2,44032,55204),bt.fill(2,63744,64256),bt.fill(2,65040,65050),bt.fill(2,65072,65136),bt.fill(2,65280,65377),bt.fill(2,65504,65511);for(let e=0;e<Lu.length;++e)bt.fill(0,Lu[e][0],Lu[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?bt[e]:xM(e,vM)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let r=this.wcwidth(e),n=r===0&&t!==0;if(n){let i=Ti.extractWidth(t);i===0?n=!1:i>r&&(r=i)}return Ti.createPropertyValue(0,r,n)}},Ti=class fa{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new le,this.onChange=this._onChange.event;let t=new yM;this.register(t),this._active=t.version,this._activeProvider=t}static extractShouldJoin(t){return(t&1)!==0}static extractWidth(t){return t>>1&3}static extractCharKind(t){return t>>3}static createPropertyValue(t,r,n=!1){return(t&16777215)<<3|(r&3)<<1|(n?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(t){if(!this._providers[t])throw new Error(`unknown Unicode version "${t}"`);this._active=t,this._activeProvider=this._providers[t],this._onChange.fire(t)}register(t){this._providers[t.version]=t}wcwidth(t){return this._activeProvider.wcwidth(t)}getStringCellWidth(t){let r=0,n=0,i=t.length;for(let s=0;s<i;++s){let o=t.charCodeAt(s);if(55296<=o&&o<=56319){if(++s>=i)return r+this.wcwidth(o);let c=t.charCodeAt(s);56320<=c&&c<=57343?o=(o-55296)*1024+c-56320+65536:r+=this.wcwidth(c)}let l=this.charProperties(o,n),a=fa.extractWidth(l);fa.extractShouldJoin(l)&&(a-=fa.extractWidth(n)),r+=a,n=l}return r}charProperties(t,r){return this._activeProvider.charProperties(t,r)}},bM=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 f_(e){var n;let t=(n=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1))==null?void 0:n.get(e.cols-1),r=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);r&&t&&(r.isWrapped=t[3]!==0&&t[3]!==32)}var Gs=2147483647,wM=256,P1=class Pd{constructor(t=32,r=32){if(this.maxLength=t,this.maxSubParamsLength=r,r>wM)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(t),this.length=0,this._subParams=new Int32Array(r),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(t),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let r=new Pd;if(!t.length)return r;for(let n=Array.isArray(t[0])?1:0;n<t.length;++n){let i=t[n];if(Array.isArray(i))for(let s=0;s<i.length;++s)r.addSubParam(i[s]);else r.addParam(i)}return r}clone(){let t=new Pd(this.maxLength,this.maxSubParamsLength);return t.params.set(this.params),t.length=this.length,t._subParams.set(this._subParams),t._subParamsLength=this._subParamsLength,t._subParamsIdx.set(this._subParamsIdx),t._rejectDigits=this._rejectDigits,t._rejectSubDigits=this._rejectSubDigits,t._digitIsSub=this._digitIsSub,t}toArray(){let t=[];for(let r=0;r<this.length;++r){t.push(this.params[r]);let n=this._subParamsIdx[r]>>8,i=this._subParamsIdx[r]&255;i-n>0&&t.push(Array.prototype.slice.call(this._subParams,n,i))}return t}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(t){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=t>Gs?Gs:t}addSubParam(t){if(this._digitIsSub=!0,!!this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=t>Gs?Gs:t,this._subParamsIdx[this.length-1]++}}hasSubParams(t){return(this._subParamsIdx[t]&255)-(this._subParamsIdx[t]>>8)>0}getSubParams(t){let r=this._subParamsIdx[t]>>8,n=this._subParamsIdx[t]&255;return n-r>0?this._subParams.subarray(r,n):null}getSubParamsAll(){let t={};for(let r=0;r<this.length;++r){let n=this._subParamsIdx[r]>>8,i=this._subParamsIdx[r]&255;i-n>0&&(t[r]=this._subParams.slice(n,i))}return t}addDigit(t){let r;if(this._rejectDigits||!(r=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let n=this._digitIsSub?this._subParams:this.params,i=n[r-1];n[r-1]=~i?Math.min(i*10+t,Gs):t}},Qs=[],SM=class{constructor(){this._state=0,this._active=Qs,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 r=this._handlers[e];return r.push(t),{dispose:()=>{let n=r.indexOf(t);n!==-1&&r.splice(n,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=Qs}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=Qs,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||Qs,!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,r){if(!this._active.length)this._handlerFb(this._id,"PUT",Tc(e,t,r));else for(let n=this._active.length-1;n>=0;n--)this._active[n].put(e,t,r)}start(){this.reset(),this._state=1}put(e,t,r){if(this._state!==3){if(this._state===1)for(;t<r;){let n=e[t++];if(n===59){this._state=2,this._start();break}if(n<48||57<n){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+n-48}this._state===2&&r-t>0&&this._put(e,t,r)}}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 r=!1,n=this._active.length-1,i=!1;if(this._stack.paused&&(n=this._stack.loopPosition-1,r=t,i=this._stack.fallThrough,this._stack.paused=!1),!i&&r===!1){for(;n>=0&&(r=this._active[n].end(e),r!==!0);n--)if(r instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=n,this._stack.fallThrough=!1,r;n--}for(;n>=0;n--)if(r=this._active[n].end(!1),r instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=n,this._stack.fallThrough=!0,r}this._active=Qs,this._id=-1,this._state=0}}},mr=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,t,r){this._hitLimit||(this._data+=Tc(e,t,r),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(r=>(this._data="",this._hitLimit=!1,r));return this._data="",this._hitLimit=!1,t}},Js=[],kM=class{constructor(){this._handlers=Object.create(null),this._active=Js,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Js}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let r=this._handlers[e];return r.push(t),{dispose:()=>{let n=r.indexOf(t);n!==-1&&r.splice(n,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=Js,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||Js,!this._active.length)this._handlerFb(this._ident,"HOOK",t);else for(let r=this._active.length-1;r>=0;r--)this._active[r].hook(t)}put(e,t,r){if(!this._active.length)this._handlerFb(this._ident,"PUT",Tc(e,t,r));else for(let n=this._active.length-1;n>=0;n--)this._active[n].put(e,t,r)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let r=!1,n=this._active.length-1,i=!1;if(this._stack.paused&&(n=this._stack.loopPosition-1,r=t,i=this._stack.fallThrough,this._stack.paused=!1),!i&&r===!1){for(;n>=0&&(r=this._active[n].unhook(e),r!==!0);n--)if(r instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=n,this._stack.fallThrough=!1,r;n--}for(;n>=0;n--)if(r=this._active[n].unhook(!1),r instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=n,this._stack.fallThrough=!0,r}this._active=Js,this._ident=0}},co=new P1;co.addParam(0);var p_=class{constructor(e){this._handler=e,this._data="",this._params=co,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():co,this._data="",this._hitLimit=!1}put(e,t,r){this._hitLimit||(this._data+=Tc(e,t,r),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data,this._params),t instanceof Promise))return t.then(r=>(this._params=co,this._data="",this._hitLimit=!1,r));return this._params=co,this._data="",this._hitLimit=!1,t}},CM=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,r,n){this.table[t<<8|e]=r<<4|n}addMany(e,t,r,n){for(let i=0;i<e.length;i++)this.table[t<<8|e[i]]=r<<4|n}},Pr=160,EM=function(){let e=new CM(4095),t=Array.apply(null,Array(256)).map((l,a)=>a),r=(l,a)=>t.slice(l,a),n=r(32,127),i=r(0,24);i.push(25),i.push.apply(i,r(28,32));let s=r(0,14),o;e.setDefault(1,0),e.addMany(n,0,2,0);for(o in s)e.addMany([24,26,153,154],o,3,0),e.addMany(r(128,144),o,3,0),e.addMany(r(144,152),o,3,0),e.add(156,o,0,0),e.add(27,o,11,1),e.add(157,o,4,8),e.addMany([152,158,159],o,0,7),e.add(155,o,11,3),e.add(144,o,11,9);return e.addMany(i,0,3,0),e.addMany(i,1,3,1),e.add(127,1,0,1),e.addMany(i,8,0,8),e.addMany(i,3,3,3),e.add(127,3,0,3),e.addMany(i,4,3,4),e.add(127,4,0,4),e.addMany(i,6,3,6),e.addMany(i,5,3,5),e.add(127,5,0,5),e.addMany(i,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(n,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(r(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(n,7,0,7),e.addMany(i,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(r(64,127),3,7,0),e.addMany(r(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(r(48,60),4,8,4),e.addMany(r(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(r(32,64),6,0,6),e.add(127,6,0,6),e.addMany(r(64,127),6,0,0),e.addMany(r(32,48),3,9,5),e.addMany(r(32,48),5,9,5),e.addMany(r(48,64),5,0,6),e.addMany(r(64,127),5,7,0),e.addMany(r(32,48),4,9,5),e.addMany(r(32,48),1,9,2),e.addMany(r(32,48),2,9,2),e.addMany(r(48,127),2,10,0),e.addMany(r(48,80),1,10,0),e.addMany(r(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(r(96,127),1,10,0),e.add(80,1,11,9),e.addMany(i,9,0,9),e.add(127,9,0,9),e.addMany(r(28,32),9,0,9),e.addMany(r(32,48),9,9,12),e.addMany(r(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(i,11,0,11),e.addMany(r(32,128),11,0,11),e.addMany(r(28,32),11,0,11),e.addMany(i,10,0,10),e.add(127,10,0,10),e.addMany(r(28,32),10,0,10),e.addMany(r(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(r(32,48),10,9,12),e.addMany(i,12,0,12),e.add(127,12,0,12),e.addMany(r(28,32),12,0,12),e.addMany(r(32,48),12,9,12),e.addMany(r(48,64),12,0,11),e.addMany(r(64,127),12,12,13),e.addMany(r(64,127),10,12,13),e.addMany(r(64,127),9,12,13),e.addMany(i,13,13,13),e.addMany(n,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(Pr,0,2,0),e.add(Pr,8,5,8),e.add(Pr,6,0,6),e.add(Pr,11,0,11),e.add(Pr,13,13,13),e}(),NM=class extends Be{constructor(e=EM){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 P1,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,r,n)=>{},this._executeHandlerFb=t=>{},this._csiHandlerFb=(t,r)=>{},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(rt(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new SM),this._dcsParser=this._register(new kM),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,t=[64,126]){let r=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(r=e.prefix.charCodeAt(0),r&&60>r||r>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 i=0;i<e.intermediates.length;++i){let s=e.intermediates.charCodeAt(i);if(32>s||s>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");r<<=8,r|=s}}if(e.final.length!==1)throw new Error("final must be a single byte");let n=e.final.charCodeAt(0);if(t[0]>n||n>t[1])throw new Error(`final must be in range ${t[0]} .. ${t[1]}`);return r<<=8,r|=n,r}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 r=this._identifier(e,[48,126]);this._escHandlers[r]===void 0&&(this._escHandlers[r]=[]);let n=this._escHandlers[r];return n.push(t),{dispose:()=>{let i=n.indexOf(t);i!==-1&&n.splice(i,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 r=this._identifier(e);this._csiHandlers[r]===void 0&&(this._csiHandlers[r]=[]);let n=this._csiHandlers[r];return n.push(t),{dispose:()=>{let i=n.indexOf(t);i!==-1&&n.splice(i,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,r,n,i){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=r,this._parseStack.transition=n,this._parseStack.chunkPos=i}parse(e,t,r){let n=0,i=0,s=0,o;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,s=this._parseStack.chunkPos+1;else{if(r===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let l=this._parseStack.handlers,a=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(r===!1&&a>-1){for(;a>=0&&(o=l[a](this._params),o!==!0);a--)if(o instanceof Promise)return this._parseStack.handlerPos=a,o}this._parseStack.handlers=[];break;case 4:if(r===!1&&a>-1){for(;a>=0&&(o=l[a](),o!==!0);a--)if(o instanceof Promise)return this._parseStack.handlerPos=a,o}this._parseStack.handlers=[];break;case 6:if(n=e[this._parseStack.chunkPos],o=this._dcsParser.unhook(n!==24&&n!==26,r),o)return o;n===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(n=e[this._parseStack.chunkPos],o=this._oscParser.end(n!==24&&n!==26,r),o)return o;n===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,s=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let l=s;l<t;++l){switch(n=e[l],i=this._transitions.table[this.currentState<<8|(n<160?n:Pr)],i>>4){case 2:for(let f=l+1;;++f){if(f>=t||(n=e[f])<32||n>126&&n<Pr){this._printHandler(e,l,f),l=f-1;break}if(++f>=t||(n=e[f])<32||n>126&&n<Pr){this._printHandler(e,l,f),l=f-1;break}if(++f>=t||(n=e[f])<32||n>126&&n<Pr){this._printHandler(e,l,f),l=f-1;break}if(++f>=t||(n=e[f])<32||n>126&&n<Pr){this._printHandler(e,l,f),l=f-1;break}}break;case 3:this._executeHandlers[n]?this._executeHandlers[n]():this._executeHandlerFb(n),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:l,code:n,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let a=this._csiHandlers[this._collect<<8|n],c=a?a.length-1:-1;for(;c>=0&&(o=a[c](this._params),o!==!0);c--)if(o instanceof Promise)return this._preserveStack(3,a,c,i,l),o;c<0&&this._csiHandlerFb(this._collect<<8|n,this._params),this.precedingJoinState=0;break;case 8:do switch(n){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(n-48)}while(++l<t&&(n=e[l])>47&&n<60);l--;break;case 9:this._collect<<=8,this._collect|=n;break;case 10:let d=this._escHandlers[this._collect<<8|n],h=d?d.length-1:-1;for(;h>=0&&(o=d[h](),o!==!0);h--)if(o instanceof Promise)return this._preserveStack(4,d,h,i,l),o;h<0&&this._escHandlerFb(this._collect<<8|n),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|n,this._params);break;case 13:for(let f=l+1;;++f)if(f>=t||(n=e[f])===24||n===26||n===27||n>127&&n<Pr){this._dcsParser.put(e,l,f),l=f-1;break}break;case 14:if(o=this._dcsParser.unhook(n!==24&&n!==26),o)return this._preserveStack(6,[],0,i,l),o;n===27&&(i|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let f=l+1;;f++)if(f>=t||(n=e[f])<32||n>127&&n<Pr){this._oscParser.put(e,l,f),l=f-1;break}break;case 6:if(o=this._oscParser.end(n!==24&&n!==26),o)return this._preserveStack(5,[],0,i,l),o;n===27&&(i|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=i&15}}},TM=/^([\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})$/,PM=/^[\da-f]+$/;function m_(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let r=TM.exec(t);if(r){let n=r[1]?15:r[4]?255:r[7]?4095:65535;return[Math.round(parseInt(r[1]||r[4]||r[7]||r[10],16)/n*255),Math.round(parseInt(r[2]||r[5]||r[8]||r[11],16)/n*255),Math.round(parseInt(r[3]||r[6]||r[9]||r[12],16)/n*255)]}}else if(t.indexOf("#")===0&&(t=t.slice(1),PM.exec(t)&&[3,6,9,12].includes(t.length))){let r=t.length/3,n=[0,0,0];for(let i=0;i<3;++i){let s=parseInt(t.slice(r*i,r*i+r),16);n[i]=r===1?s<<4:r===2?s:r===3?s>>4:s>>8}return n}}function Iu(e,t){let r=e.toString(16),n=r.length<2?"0"+r:r;switch(t){case 4:return r[0];case 8:return n;case 12:return(n+n).slice(0,3);default:return n+n}}function RM(e,t=16){let[r,n,i]=e;return`rgb:${Iu(r,t)}/${Iu(n,t)}/${Iu(i,t)}`}var MM={"(":0,")":1,"*":2,"+":3,"-":1,".":2},Dn=131072,g_=10;function __(e,t){if(e>24)return t.setWinLines||!1;switch(e){case 1:return!!t.restoreWin;case 2:return!!t.minimizeWin;case 3:return!!t.setWinPosition;case 4:return!!t.setWinSizePixels;case 5:return!!t.raiseWin;case 6:return!!t.lowerWin;case 7:return!!t.refreshWin;case 8:return!!t.setWinSizeChars;case 9:return!!t.maximizeWin;case 10:return!!t.fullscreenWin;case 11:return!!t.getWinState;case 13:return!!t.getWinPosition;case 14:return!!t.getWinSizePixels;case 15:return!!t.getScreenSizePixels;case 16:return!!t.getCellSizePixels;case 18:return!!t.getWinSizeChars;case 19:return!!t.getScreenSizeChars;case 20:return!!t.getIconTitle;case 21:return!!t.getWinTitle;case 22:return!!t.pushTitle;case 23:return!!t.popTitle;case 24:return!!t.setWinLines}return!1}var v_=5e3,x_=0,LM=class extends Be{constructor(e,t,r,n,i,s,o,l,a=new NM){super(),this._bufferService=e,this._charsetService=t,this._coreService=r,this._logService=n,this._optionsService=i,this._oscLinkService=s,this._coreMouseService=o,this._unicodeService=l,this._parser=a,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new QP,this._utf8Decoder=new JP,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=gt.clone(),this._eraseAttrDataInternal=gt.clone(),this._onRequestBell=this._register(new le),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new le),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new le),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new le),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new le),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new le),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new le),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new le),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new le),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new le),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new le),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new le),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new le),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 Rd(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(c=>this._activeBuffer=c.activeBuffer)),this._parser.setCsiHandlerFallback((c,d)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(c),params:d.toArray()})}),this._parser.setEscHandlerFallback(c=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(c)})}),this._parser.setExecuteHandlerFallback(c=>{this._logService.debug("Unknown EXECUTE code: ",{code:c})}),this._parser.setOscHandlerFallback((c,d,h)=>{this._logService.debug("Unknown OSC code: ",{identifier:c,action:d,data:h})}),this._parser.setDcsHandlerFallback((c,d,h)=>{d==="HOOK"&&(h=h.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(c),action:d,payload:h})}),this._parser.setPrintHandler((c,d,h)=>this.print(c,d,h)),this._parser.registerCsiHandler({final:"@"},c=>this.insertChars(c)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},c=>this.scrollLeft(c)),this._parser.registerCsiHandler({final:"A"},c=>this.cursorUp(c)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},c=>this.scrollRight(c)),this._parser.registerCsiHandler({final:"B"},c=>this.cursorDown(c)),this._parser.registerCsiHandler({final:"C"},c=>this.cursorForward(c)),this._parser.registerCsiHandler({final:"D"},c=>this.cursorBackward(c)),this._parser.registerCsiHandler({final:"E"},c=>this.cursorNextLine(c)),this._parser.registerCsiHandler({final:"F"},c=>this.cursorPrecedingLine(c)),this._parser.registerCsiHandler({final:"G"},c=>this.cursorCharAbsolute(c)),this._parser.registerCsiHandler({final:"H"},c=>this.cursorPosition(c)),this._parser.registerCsiHandler({final:"I"},c=>this.cursorForwardTab(c)),this._parser.registerCsiHandler({final:"J"},c=>this.eraseInDisplay(c,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},c=>this.eraseInDisplay(c,!0)),this._parser.registerCsiHandler({final:"K"},c=>this.eraseInLine(c,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},c=>this.eraseInLine(c,!0)),this._parser.registerCsiHandler({final:"L"},c=>this.insertLines(c)),this._parser.registerCsiHandler({final:"M"},c=>this.deleteLines(c)),this._parser.registerCsiHandler({final:"P"},c=>this.deleteChars(c)),this._parser.registerCsiHandler({final:"S"},c=>this.scrollUp(c)),this._parser.registerCsiHandler({final:"T"},c=>this.scrollDown(c)),this._parser.registerCsiHandler({final:"X"},c=>this.eraseChars(c)),this._parser.registerCsiHandler({final:"Z"},c=>this.cursorBackwardTab(c)),this._parser.registerCsiHandler({final:"`"},c=>this.charPosAbsolute(c)),this._parser.registerCsiHandler({final:"a"},c=>this.hPositionRelative(c)),this._parser.registerCsiHandler({final:"b"},c=>this.repeatPrecedingCharacter(c)),this._parser.registerCsiHandler({final:"c"},c=>this.sendDeviceAttributesPrimary(c)),this._parser.registerCsiHandler({prefix:">",final:"c"},c=>this.sendDeviceAttributesSecondary(c)),this._parser.registerCsiHandler({final:"d"},c=>this.linePosAbsolute(c)),this._parser.registerCsiHandler({final:"e"},c=>this.vPositionRelative(c)),this._parser.registerCsiHandler({final:"f"},c=>this.hVPosition(c)),this._parser.registerCsiHandler({final:"g"},c=>this.tabClear(c)),this._parser.registerCsiHandler({final:"h"},c=>this.setMode(c)),this._parser.registerCsiHandler({prefix:"?",final:"h"},c=>this.setModePrivate(c)),this._parser.registerCsiHandler({final:"l"},c=>this.resetMode(c)),this._parser.registerCsiHandler({prefix:"?",final:"l"},c=>this.resetModePrivate(c)),this._parser.registerCsiHandler({final:"m"},c=>this.charAttributes(c)),this._parser.registerCsiHandler({final:"n"},c=>this.deviceStatus(c)),this._parser.registerCsiHandler({prefix:"?",final:"n"},c=>this.deviceStatusPrivate(c)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},c=>this.softReset(c)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},c=>this.setCursorStyle(c)),this._parser.registerCsiHandler({final:"r"},c=>this.setScrollRegion(c)),this._parser.registerCsiHandler({final:"s"},c=>this.saveCursor(c)),this._parser.registerCsiHandler({final:"t"},c=>this.windowOptions(c)),this._parser.registerCsiHandler({final:"u"},c=>this.restoreCursor(c)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},c=>this.insertColumns(c)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},c=>this.deleteColumns(c)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},c=>this.selectProtected(c)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},c=>this.requestMode(c,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},c=>this.requestMode(c,!1)),this._parser.setExecuteHandler(Q.BEL,()=>this.bell()),this._parser.setExecuteHandler(Q.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(Q.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(Q.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(Q.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(Q.BS,()=>this.backspace()),this._parser.setExecuteHandler(Q.HT,()=>this.tab()),this._parser.setExecuteHandler(Q.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(Q.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(ha.IND,()=>this.index()),this._parser.setExecuteHandler(ha.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(ha.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new mr(c=>(this.setTitle(c),this.setIconName(c),!0))),this._parser.registerOscHandler(1,new mr(c=>this.setIconName(c))),this._parser.registerOscHandler(2,new mr(c=>this.setTitle(c))),this._parser.registerOscHandler(4,new mr(c=>this.setOrReportIndexedColor(c))),this._parser.registerOscHandler(8,new mr(c=>this.setHyperlink(c))),this._parser.registerOscHandler(10,new mr(c=>this.setOrReportFgColor(c))),this._parser.registerOscHandler(11,new mr(c=>this.setOrReportBgColor(c))),this._parser.registerOscHandler(12,new mr(c=>this.setOrReportCursorColor(c))),this._parser.registerOscHandler(104,new mr(c=>this.restoreIndexedColor(c))),this._parser.registerOscHandler(110,new mr(c=>this.restoreFgColor(c))),this._parser.registerOscHandler(111,new mr(c=>this.restoreBgColor(c))),this._parser.registerOscHandler(112,new mr(c=>this.restoreCursorColor(c))),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 c in Ct)this._parser.registerEscHandler({intermediates:"(",final:c},()=>this.selectCharset("("+c)),this._parser.registerEscHandler({intermediates:")",final:c},()=>this.selectCharset(")"+c)),this._parser.registerEscHandler({intermediates:"*",final:c},()=>this.selectCharset("*"+c)),this._parser.registerEscHandler({intermediates:"+",final:c},()=>this.selectCharset("+"+c)),this._parser.registerEscHandler({intermediates:"-",final:c},()=>this.selectCharset("-"+c)),this._parser.registerEscHandler({intermediates:".",final:c},()=>this.selectCharset("."+c)),this._parser.registerEscHandler({intermediates:"/",final:c},()=>this.selectCharset("/"+c));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(c=>(this._logService.error("Parsing error: ",c),c)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new p_((c,d)=>this.requestStatusString(c,d)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,r,n){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=r,this._parseStack.position=n}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((t,r)=>setTimeout(()=>r("#SLOW_TIMEOUT"),v_))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${v_} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let r,n=this._activeBuffer.x,i=this._activeBuffer.y,s=0,o=this._parseStack.paused;if(o){if(r=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(r),r;n=this._parseStack.cursorStartX,i=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>Dn&&(s=this._parseStack.position+Dn)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e=="string"?` "${e}"`:` "${Array.prototype.map.call(e,c=>String.fromCharCode(c)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof e=="string"?e.split("").map(c=>c.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<Dn&&(this._parseBuffer=new Uint32Array(Math.min(e.length,Dn))),o||this._dirtyRowTracker.clearRange(),e.length>Dn)for(let c=s;c<e.length;c+=Dn){let d=c+Dn<e.length?c+Dn:e.length,h=typeof e=="string"?this._stringDecoder.decode(e.substring(c,d),this._parseBuffer):this._utf8Decoder.decode(e.subarray(c,d),this._parseBuffer);if(r=this._parser.parse(this._parseBuffer,h))return this._preserveStack(n,i,h,c),this._logSlowResolvingAsync(r),r}else if(!o){let c=typeof e=="string"?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(r=this._parser.parse(this._parseBuffer,c))return this._preserveStack(n,i,c,0),this._logSlowResolvingAsync(r),r}(this._activeBuffer.x!==n||this._activeBuffer.y!==i)&&this._onCursorMove.fire();let l=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),a=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);a<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(a,this._bufferService.rows-1),end:Math.min(l,this._bufferService.rows-1)})}print(e,t,r){let n,i,s=this._charsetService.charset,o=this._optionsService.rawOptions.screenReaderMode,l=this._bufferService.cols,a=this._coreService.decPrivateModes.wraparound,c=this._coreService.modes.insertMode,d=this._curAttrData,h=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&r-t>0&&h.getWidth(this._activeBuffer.x-1)===2&&h.setCellFromCodepoint(this._activeBuffer.x-1,0,1,d);let f=this._parser.precedingJoinState;for(let p=t;p<r;++p){if(n=e[p],n<127&&s){let g=s[String.fromCharCode(n)];g&&(n=g.charCodeAt(0))}let m=this._unicodeService.charProperties(n,f);i=Ti.extractWidth(m);let _=Ti.extractShouldJoin(m),b=_?Ti.extractWidth(f):0;if(f=m,o&&this._onA11yChar.fire(Fn(n)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+i-b>l){if(a){let g=h,v=this._activeBuffer.x-b;for(this._activeBuffer.x=b,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),h=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),b>0&&h instanceof lo&&h.copyCellsFrom(g,v,0,b,!1);v<l;)g.setCellFromCodepoint(v++,0,1,d)}else if(this._activeBuffer.x=l-1,i===2)continue}if(_&&this._activeBuffer.x){let g=h.getWidth(this._activeBuffer.x-1)?1:2;h.addCodepointToCell(this._activeBuffer.x-g,n,i);for(let v=i-b;--v>=0;)h.setCellFromCodepoint(this._activeBuffer.x++,0,0,d);continue}if(c&&(h.insertCells(this._activeBuffer.x,i-b,this._activeBuffer.getNullCell(d)),h.getWidth(l-1)===2&&h.setCellFromCodepoint(l-1,0,1,d)),h.setCellFromCodepoint(this._activeBuffer.x++,n,i,d),i>0)for(;--i;)h.setCellFromCodepoint(this._activeBuffer.x++,0,0,d)}this._parser.precedingJoinState=f,this._activeBuffer.x<l&&r-t>0&&h.getWidth(this._activeBuffer.x)===0&&!h.hasContent(this._activeBuffer.x)&&h.setCellFromCodepoint(this._activeBuffer.x,0,1,d),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,r=>__(r.params[0],this._optionsService.rawOptions.windowOptions)?t(r):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new p_(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new mr(t))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){var e;if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&((e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))!=null&&e.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);t.hasWidth(this._activeBuffer.x)&&!t.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),(t===2||t===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,r,n=!1,i=!1){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);s.replaceCells(t,r,this._activeBuffer.getNullCell(this._eraseAttrData()),i),n&&(s.isWrapped=!1)}_resetBufferLine(e,t=!1){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);r&&(r.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),r.isWrapped=!1)}eraseInDisplay(e,t=!1){var n;this._restrictCursor(this._bufferService.cols);let r;switch(e.params[0]){case 0:for(r=this._activeBuffer.y,this._dirtyRowTracker.markDirty(r),this._eraseInBufferLine(r++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);r<this._bufferService.rows;r++)this._resetBufferLine(r,t);this._dirtyRowTracker.markDirty(r);break;case 1:for(r=this._activeBuffer.y,this._dirtyRowTracker.markDirty(r),this._eraseInBufferLine(r,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(r+1).isWrapped=!1);r--;)this._resetBufferLine(r,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(r=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,r-1);r--&&!((n=this._activeBuffer.lines.get(this._activeBuffer.ybase+r))!=null&&n.getTrimmedLength()););for(;r>=0;r--)this._bufferService.scroll(this._eraseAttrData())}else{for(r=this._bufferService.rows,this._dirtyRowTracker.markDirty(r-1);r--;)this._resetBufferLine(r,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let i=this._activeBuffer.lines.length-this._bufferService.rows;i>0&&(this._activeBuffer.lines.trimStart(i),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-i,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-i,0),this._onScroll.fire(0));break}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let r=this._activeBuffer.ybase+this._activeBuffer.y,n=this._bufferService.rows-1-this._activeBuffer.scrollBottom,i=this._bufferService.rows-1+this._activeBuffer.ybase-n+1;for(;t--;)this._activeBuffer.lines.splice(i-1,1),this._activeBuffer.lines.splice(r,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let r=this._activeBuffer.ybase+this._activeBuffer.y,n;for(n=this._bufferService.rows-1-this._activeBuffer.scrollBottom,n=this._bufferService.rows-1+this._activeBuffer.ybase-n;t--;)this._activeBuffer.lines.splice(r,1),this._activeBuffer.lines.splice(n,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.insertCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.deleteCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(gt));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let r=this._activeBuffer.scrollTop;r<=this._activeBuffer.scrollBottom;++r){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+r);n.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let r=this._activeBuffer.scrollTop;r<=this._activeBuffer.scrollBottom;++r){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+r);n.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let r=this._activeBuffer.scrollTop;r<=this._activeBuffer.scrollBottom;++r){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+r);n.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let r=this._activeBuffer.scrollTop;r<=this._activeBuffer.scrollBottom;++r){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+r);n.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e){let t=this._parser.precedingJoinState;if(!t)return!0;let r=e.params[0]||1,n=Ti.extractWidth(t),i=this._activeBuffer.x-n,s=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(i),o=new Uint32Array(s.length*r),l=0;for(let c=0;c<s.length;){let d=s.codePointAt(c)||0;o[l++]=d,c+=d>65535?2:1}let a=l;for(let c=1;c<r;++c)o.copyWithin(a,0,l),a+=l;return this.print(o,0,a),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(Q.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(Q.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(Q.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(Q.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(Q.ESC+"[>83;40003;0c")),!0}_is(e){return(this._optionsService.rawOptions.termName+"").indexOf(e)===0}setMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0;break}return!0}setModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,Si),this._charsetService.setgCharset(1,Si),this._charsetService.setgCharset(2,Si),this._charsetService.setgCharset(3,Si);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1e3:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!0;break}return!0}resetMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1;break}return!0}resetModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),e.params[t]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!1,this._onRequestRefreshRows.fire(void 0);break}return!0}requestMode(e,t){(_=>(_[_.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",_[_.SET=1]="SET",_[_.RESET=2]="RESET",_[_.PERMANENTLY_SET=3]="PERMANENTLY_SET",_[_.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(void 0||(r={}));let n=this._coreService.decPrivateModes,{activeProtocol:i,activeEncoding:s}=this._coreMouseService,o=this._coreService,{buffers:l,cols:a}=this._bufferService,{active:c,alt:d}=l,h=this._optionsService.rawOptions,f=(_,b)=>(o.triggerDataEvent(`${Q.ESC}[${t?"":"?"}${_};${b}$y`),!0),p=_=>_?1:2,m=e.params[0];return t?m===2?f(m,4):m===4?f(m,p(o.modes.insertMode)):m===12?f(m,3):m===20?f(m,p(h.convertEol)):f(m,0):m===1?f(m,p(n.applicationCursorKeys)):m===3?f(m,h.windowOptions.setWinLines?a===80?2:a===132?1:0:0):m===6?f(m,p(n.origin)):m===7?f(m,p(n.wraparound)):m===8?f(m,3):m===9?f(m,p(i==="X10")):m===12?f(m,p(h.cursorBlink)):m===25?f(m,p(!o.isCursorHidden)):m===45?f(m,p(n.reverseWraparound)):m===66?f(m,p(n.applicationKeypad)):m===67?f(m,4):m===1e3?f(m,p(i==="VT200")):m===1002?f(m,p(i==="DRAG")):m===1003?f(m,p(i==="ANY")):m===1004?f(m,p(n.sendFocus)):m===1005?f(m,4):m===1006?f(m,p(s==="SGR")):m===1015?f(m,4):m===1016?f(m,p(s==="SGR_PIXELS")):m===1048?f(m,1):m===47||m===1047||m===1049?f(m,p(c===d)):m===2004?f(m,p(n.bracketedPasteMode)):m===2026?f(m,p(n.synchronizedOutput)):f(m,0)}_updateAttrColor(e,t,r,n,i){return t===2?(e|=50331648,e&=-16777216,e|=hl.fromColorRGB([r,n,i])):t===5&&(e&=-50331904,e|=33554432|r&255),e}_extractColor(e,t,r){let n=[0,0,-1,0,0,0],i=0,s=0;do{if(n[s+i]=e.params[t+s],e.hasSubParams(t+s)){let o=e.getSubParams(t+s),l=0;do n[1]===5&&(i=1),n[s+l+1+i]=o[l];while(++l<o.length&&l+s+1+i<n.length);break}if(n[1]===5&&s+i>=2||n[1]===2&&s+i>=5)break;n[1]&&(i=1)}while(++s+t<e.length&&s+i<n.length);for(let o=2;o<n.length;++o)n[o]===-1&&(n[o]=0);switch(n[0]){case 38:r.fg=this._updateAttrColor(r.fg,n[1],n[3],n[4],n[5]);break;case 48:r.bg=this._updateAttrColor(r.bg,n[1],n[3],n[4],n[5]);break;case 58:r.extended=r.extended.clone(),r.extended.underlineColor=this._updateAttrColor(r.extended.underlineColor,n[1],n[3],n[4],n[5])}return s}_processUnderline(e,t){t.extended=t.extended.clone(),(!~e||e>5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,e===0&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=gt.fg,e.bg=gt.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let t=e.length,r,n=this._curAttrData;for(let i=0;i<t;i++)r=e.params[i],r>=30&&r<=37?(n.fg&=-50331904,n.fg|=16777216|r-30):r>=40&&r<=47?(n.bg&=-50331904,n.bg|=16777216|r-40):r>=90&&r<=97?(n.fg&=-50331904,n.fg|=16777216|r-90|8):r>=100&&r<=107?(n.bg&=-50331904,n.bg|=16777216|r-100|8):r===0?this._processSGR0(n):r===1?n.fg|=134217728:r===3?n.bg|=67108864:r===4?(n.fg|=268435456,this._processUnderline(e.hasSubParams(i)?e.getSubParams(i)[0]:1,n)):r===5?n.fg|=536870912:r===7?n.fg|=67108864:r===8?n.fg|=1073741824:r===9?n.fg|=2147483648:r===2?n.bg|=134217728:r===21?this._processUnderline(2,n):r===22?(n.fg&=-134217729,n.bg&=-134217729):r===23?n.bg&=-67108865:r===24?(n.fg&=-268435457,this._processUnderline(0,n)):r===25?n.fg&=-536870913:r===27?n.fg&=-67108865:r===28?n.fg&=-1073741825:r===29?n.fg&=2147483647:r===39?(n.fg&=-67108864,n.fg|=gt.fg&16777215):r===49?(n.bg&=-67108864,n.bg|=gt.bg&16777215):r===38||r===48||r===58?i+=this._extractColor(e,i,n):r===53?n.bg|=1073741824:r===55?n.bg&=-1073741825:r===59?(n.extended=n.extended.clone(),n.extended.underlineColor=-1,n.updateExtended()):r===100?(n.fg&=-67108864,n.fg|=gt.fg&16777215,n.bg&=-67108864,n.bg|=gt.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",r);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${Q.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,r=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${Q.ESC}[${t};${r}R`);break}return!0}deviceStatusPrivate(e){switch(e.params[0]){case 6:let t=this._activeBuffer.y+1,r=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${Q.ESC}[?${t};${r}R`);break}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=gt.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(e){let t=e.length===0?1:e.params[0];if(t===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(t){case 1:case 2:this._coreService.decPrivateModes.cursorStyle="block";break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle="underline";break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle="bar";break}let r=t%2===1;this._coreService.decPrivateModes.cursorBlink=r}return!0}setScrollRegion(e){let t=e.params[0]||1,r;return(e.length<2||(r=e.params[1])>this._bufferService.rows||r===0)&&(r=this._bufferService.rows),r>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=r-1,this._setCursor(0,0)),!0}windowOptions(e){if(!__(e.params[0],this._optionsService.rawOptions.windowOptions))return!0;let t=e.length>1?e.params[1]:0;switch(e.params[0]){case 14:t!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${Q.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>g_&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>g_&&this._iconNameStack.shift());break;case 23:(t===0||t===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(t===0||t===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop());break}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let t=[],r=e.split(";");for(;r.length>1;){let n=r.shift(),i=r.shift();if(/^\d+$/.exec(n)){let s=parseInt(n);if(y_(s))if(i==="?")t.push({type:0,index:s});else{let o=m_(i);o&&t.push({type:1,index:s,color:o})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(";");if(t===-1)return!0;let r=e.slice(0,t).trim(),n=e.slice(t+1);return n?this._createHyperlink(r,n):r.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let r=e.split(":"),n,i=r.findIndex(s=>s.startsWith("id="));return i!==-1&&(n=r[i].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:n,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let r=e.split(";");for(let n=0;n<r.length&&!(t>=this._specialColors.length);++n,++t)if(r[n]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let i=m_(r[n]);i&&this._onColor.fire([{type:1,index:this._specialColors[t],color:i}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let t=[],r=e.split(";");for(let n=0;n<r.length;++n)if(/^\d+$/.exec(r[n])){let i=parseInt(r[n]);y_(i)&&t.push({type:2,index:i})}return t.length&&this._onColor.fire(t),!0}restoreFgColor(e){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(e){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(e){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,Si),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(MM[e[0]],Ct[e[1]]||Si),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){let e=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,e,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=gt.clone(),this._eraseAttrDataInternal=gt.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(e){return this._charsetService.setgLevel(e),!0}screenAlignmentPattern(){let e=new Ar;e.content=1<<22|69,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t<this._bufferService.rows;++t){let r=this._activeBuffer.ybase+this._activeBuffer.y+t,n=this._activeBuffer.lines.get(r);n&&(n.fill(e),n.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let r=o=>(this._coreService.triggerDataEvent(`${Q.ESC}${o}${Q.ESC}\\`),!0),n=this._bufferService.buffer,i=this._optionsService.rawOptions;return r(e==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:e==='"p'?'P1$r61;1"p':e==="r"?`P1$r${n.scrollTop+1};${n.scrollBottom+1}r`:e==="m"?"P1$r0m":e===" q"?`P1$r${{block:2,underline:4,bar:6}[i.cursorStyle]-(i.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},Rd=class{constructor(e){this._bufferService=e,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(e){e<this.start?this.start=e:e>this.end&&(this.end=e)}markRangeDirty(e,t){e>t&&(x_=e,e=t,t=x_),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};Rd=ut([ue(0,tr)],Rd);function y_(e){return 0<=e&&e<256}var IM=5e7,b_=12,jM=50,DM=class extends Be{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 le),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 r;for(;r=this._writeBuffer.shift();){this._action(r);let n=this._callbacks.shift();n&&n()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>IM)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 r=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let n=this._writeBuffer[this._bufferOffset],i=this._action(n,t);if(i){let o=l=>performance.now()-r>=b_?setTimeout(()=>this._innerWrite(0,l)):this._innerWrite(r,l);i.catch(l=>(queueMicrotask(()=>{throw l}),Promise.resolve(!1))).then(o);return}let s=this._callbacks[this._bufferOffset];if(s&&s(),this._bufferOffset++,this._pendingData-=n.length,performance.now()-r>=b_)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>jM&&(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()}},Md=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let t=this._bufferService.buffer;if(e.id===void 0){let l=t.addMarker(t.ybase+t.y),a={data:e,id:this._nextId++,lines:[l]};return l.onDispose(()=>this._removeMarkerFromLink(a,l)),this._dataByLinkId.set(a.id,a),a.id}let r=e,n=this._getEntryIdKey(r),i=this._entriesWithId.get(n);if(i)return this.addLineToLink(i.id,t.ybase+t.y),i.id;let s=t.addMarker(t.ybase+t.y),o={id:this._nextId++,key:this._getEntryIdKey(r),data:r,lines:[s]};return s.onDispose(()=>this._removeMarkerFromLink(o,s)),this._entriesWithId.set(o.key,o),this._dataByLinkId.set(o.id,o),o.id}addLineToLink(e,t){let r=this._dataByLinkId.get(e);if(r&&r.lines.every(n=>n.line!==t)){let n=this._bufferService.buffer.addMarker(t);r.lines.push(n),n.onDispose(()=>this._removeMarkerFromLink(r,n))}}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 r=e.lines.indexOf(t);r!==-1&&(e.lines.splice(r,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};Md=ut([ue(0,tr)],Md);var w_=!1,AM=class extends Be{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new Ts),this._onBinary=this._register(new le),this.onBinary=this._onBinary.event,this._onData=this._register(new le),this.onData=this._onData.event,this._onLineFeed=this._register(new le),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new le),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new le),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new le),this._instantiationService=new oM,this.optionsService=this._register(new gM(e)),this._instantiationService.setService(rr,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(Ed)),this._instantiationService.setService(tr,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(Cd)),this._instantiationService.setService(Y0,this._logService),this.coreService=this._register(this._instantiationService.createInstance(Nd)),this._instantiationService.setService(Ki,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(Td)),this._instantiationService.setService(q0,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(Ti)),this._instantiationService.setService(r3,this.unicodeService),this._charsetService=this._instantiationService.createInstance(bM),this._instantiationService.setService(t3,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(Md),this._instantiationService.setService(X0,this._oscLinkService),this._inputHandler=this._register(new LM(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(Bt.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(Bt.forward(this._bufferService.onResize,this._onResize)),this._register(Bt.forward(this.coreService.onData,this._onData)),this._register(Bt.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 DM((t,r)=>this._inputHandler.parse(t,r))),this._register(Bt.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new le),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&&!w_&&(this._logService.warn("writeSync is unreliable and will be removed soon."),w_=!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,N1),t=Math.max(t,T1),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(f_.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(f_(this._bufferService),!1))),this._windowsWrappingHeuristics.value=rt(()=>{for(let t of e)t.dispose()})}}},BM={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 OM(e,t,r,n){var o;let i={type:0,cancel:!1,key:void 0},s=(e.shiftKey?1:0)|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:e.key==="UIKeyInputUpArrow"?t?i.key=Q.ESC+"OA":i.key=Q.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?i.key=Q.ESC+"OD":i.key=Q.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?i.key=Q.ESC+"OC":i.key=Q.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?i.key=Q.ESC+"OB":i.key=Q.ESC+"[B");break;case 8:i.key=e.ctrlKey?"\b":Q.DEL,e.altKey&&(i.key=Q.ESC+i.key);break;case 9:if(e.shiftKey){i.key=Q.ESC+"[Z";break}i.key=Q.HT,i.cancel=!0;break;case 13:i.key=e.altKey?Q.ESC+Q.CR:Q.CR,i.cancel=!0;break;case 27:i.key=Q.ESC,e.altKey&&(i.key=Q.ESC+Q.ESC),i.cancel=!0;break;case 37:if(e.metaKey)break;s?i.key=Q.ESC+"[1;"+(s+1)+"D":t?i.key=Q.ESC+"OD":i.key=Q.ESC+"[D";break;case 39:if(e.metaKey)break;s?i.key=Q.ESC+"[1;"+(s+1)+"C":t?i.key=Q.ESC+"OC":i.key=Q.ESC+"[C";break;case 38:if(e.metaKey)break;s?i.key=Q.ESC+"[1;"+(s+1)+"A":t?i.key=Q.ESC+"OA":i.key=Q.ESC+"[A";break;case 40:if(e.metaKey)break;s?i.key=Q.ESC+"[1;"+(s+1)+"B":t?i.key=Q.ESC+"OB":i.key=Q.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(i.key=Q.ESC+"[2~");break;case 46:s?i.key=Q.ESC+"[3;"+(s+1)+"~":i.key=Q.ESC+"[3~";break;case 36:s?i.key=Q.ESC+"[1;"+(s+1)+"H":t?i.key=Q.ESC+"OH":i.key=Q.ESC+"[H";break;case 35:s?i.key=Q.ESC+"[1;"+(s+1)+"F":t?i.key=Q.ESC+"OF":i.key=Q.ESC+"[F";break;case 33:e.shiftKey?i.type=2:e.ctrlKey?i.key=Q.ESC+"[5;"+(s+1)+"~":i.key=Q.ESC+"[5~";break;case 34:e.shiftKey?i.type=3:e.ctrlKey?i.key=Q.ESC+"[6;"+(s+1)+"~":i.key=Q.ESC+"[6~";break;case 112:s?i.key=Q.ESC+"[1;"+(s+1)+"P":i.key=Q.ESC+"OP";break;case 113:s?i.key=Q.ESC+"[1;"+(s+1)+"Q":i.key=Q.ESC+"OQ";break;case 114:s?i.key=Q.ESC+"[1;"+(s+1)+"R":i.key=Q.ESC+"OR";break;case 115:s?i.key=Q.ESC+"[1;"+(s+1)+"S":i.key=Q.ESC+"OS";break;case 116:s?i.key=Q.ESC+"[15;"+(s+1)+"~":i.key=Q.ESC+"[15~";break;case 117:s?i.key=Q.ESC+"[17;"+(s+1)+"~":i.key=Q.ESC+"[17~";break;case 118:s?i.key=Q.ESC+"[18;"+(s+1)+"~":i.key=Q.ESC+"[18~";break;case 119:s?i.key=Q.ESC+"[19;"+(s+1)+"~":i.key=Q.ESC+"[19~";break;case 120:s?i.key=Q.ESC+"[20;"+(s+1)+"~":i.key=Q.ESC+"[20~";break;case 121:s?i.key=Q.ESC+"[21;"+(s+1)+"~":i.key=Q.ESC+"[21~";break;case 122:s?i.key=Q.ESC+"[23;"+(s+1)+"~":i.key=Q.ESC+"[23~";break;case 123:s?i.key=Q.ESC+"[24;"+(s+1)+"~":i.key=Q.ESC+"[24~";break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?i.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?i.key=Q.NUL:e.keyCode>=51&&e.keyCode<=55?i.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?i.key=Q.DEL:e.keyCode===219?i.key=Q.ESC:e.keyCode===220?i.key=Q.FS:e.keyCode===221&&(i.key=Q.GS);else if((!r||n)&&e.altKey&&!e.metaKey){let l=(o=BM[e.keyCode])==null?void 0:o[e.shiftKey?1:0];if(l)i.key=Q.ESC+l;else if(e.keyCode>=65&&e.keyCode<=90){let a=e.ctrlKey?e.keyCode-64:e.keyCode+32,c=String.fromCharCode(a);e.shiftKey&&(c=c.toUpperCase()),i.key=Q.ESC+c}else if(e.keyCode===32)i.key=Q.ESC+(e.ctrlKey?Q.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let a=e.code.slice(3,4);e.shiftKey||(a=a.toLowerCase()),i.key=Q.ESC+a,i.cancel=!0}}else r&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(i.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?i.key=e.key:e.key&&e.ctrlKey&&(e.key==="_"&&(i.key=Q.US),e.key==="@"&&(i.key=Q.NUL));break}return i}var ht=0,zM=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new ec,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new ec,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((i,s)=>this._getKey(i)-this._getKey(s)),t=0,r=0,n=new Array(this._array.length+this._insertedValues.length);for(let i=0;i<n.length;i++)r>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[r])?(n[i]=e[t],t++):n[i]=this._array[r++];this._array=n,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||(ht=this._search(t),ht===-1)||this._getKey(this._array[ht])!==t)return!1;do if(this._array[ht]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(ht),!0;while(++ht<this._array.length&&this._getKey(this._array[ht])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((i,s)=>i-s),t=0,r=new Array(this._array.length-e.length),n=0;for(let i=0;i<this._array.length;i++)e[t]===i?t++:r[n++]=this._array[i];this._array=r,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(ht=this._search(e),!(ht<0||ht>=this._array.length)&&this._getKey(this._array[ht])===e))do yield this._array[ht];while(++ht<this._array.length&&this._getKey(this._array[ht])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(ht=this._search(e),!(ht<0||ht>=this._array.length)&&this._getKey(this._array[ht])===e))do t(this._array[ht]);while(++ht<this._array.length&&this._getKey(this._array[ht])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,r=this._array.length-1;for(;r>=t;){let n=t+r>>1,i=this._getKey(this._array[n]);if(i>e)r=n-1;else if(i<e)t=n+1;else{for(;n>0&&this._getKey(this._array[n-1])===e;)n--;return n}}return t}},ju=0,S_=0,$M=class extends Be{constructor(){super(),this._decorations=new zM(e=>e==null?void 0:e.marker.line),this._onDecorationRegistered=this._register(new le),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new le),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(rt(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new FM(e);if(t){let r=t.marker.onDispose(()=>t.dispose()),n=t.onDispose(()=>{n.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),r.dispose())});this._decorations.insert(t),this._onDecorationRegistered.fire(t)}return t}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,t,r){let n=0,i=0;for(let s of this._decorations.getKeyIterator(t))n=s.options.x??0,i=n+(s.options.width??1),e>=n&&e<i&&(!r||(s.options.layer??"bottom")===r)&&(yield s)}forEachDecorationAtCell(e,t,r,n){this._decorations.forEachByKey(t,i=>{ju=i.options.x??0,S_=ju+(i.options.width??1),e>=ju&&e<S_&&(!r||(i.options.layer??"bottom")===r)&&n(i)})}},FM=class extends ri{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new le),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new le),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=e.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=it.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=it.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},WM=1e3,HM=class{constructor(e,t=WM){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,r){this._rowCount=r,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 n=performance.now();if(n-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=n,this._innerRefresh();else if(!this._additionalRefreshRequested){let i=n-this._lastRefreshMs,s=this._debounceThresholdMS-i;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},s)}}_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)}},k_=20,tc=class extends Be{constructor(e,t,r,n){super(),this._terminal=e,this._coreBrowserService=r,this._renderService=n,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let i=this._coreBrowserService.mainDocument;this._accessibilityContainer=i.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=i.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let s=0;s<this._terminal.rows;s++)this._rowElements[s]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[s]);if(this._topBoundaryFocusListener=s=>this._handleBoundaryFocus(s,0),this._bottomBoundaryFocusListener=s=>this._handleBoundaryFocus(s,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=i.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new HM(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(s=>this._handleResize(s.rows))),this._register(this._terminal.onRender(s=>this._refreshRows(s.start,s.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(s=>this._handleChar(s))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
|
|
129
129
|
`))),this._register(this._terminal.onA11yTab(s=>this._handleTab(s))),this._register(this._terminal.onKey(s=>this._handleKey(s.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(Ne(i,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(rt(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<k_+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
|
|
130
|
-
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===k_+1&&(this._liveRegion.textContent+=Qh.get())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let r=this._terminal.buffer,n=r.lines.length.toString();for(let i=e;i<=t;i++){let s=r.lines.get(r.ydisp+i),o=[],l=(s==null?void 0:s.translateToString(!0,void 0,void 0,o))||"",a=(r.ydisp+i+1).toString(),c=this._rowElements[i];c&&(l.length===0?(c.textContent=" ",this._rowColumns.set(c,[0,1])):(c.textContent=l,this._rowColumns.set(c,o)),c.setAttribute("aria-posinset",a),c.setAttribute("aria-setsize",n),this._alignRowWidth(c))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){let r=e.target,n=this._rowElements[t===0?1:this._rowElements.length-2],i=r.getAttribute("aria-posinset"),s=t===0?"1":`${this._terminal.buffer.lines.length}`;if(i===s||e.relatedTarget!==n)return;let o,l;if(t===0?(o=r,l=this._rowElements.pop(),this._rowContainer.removeChild(l)):(o=this._rowElements.shift(),l=r,this._rowContainer.removeChild(o)),o.removeEventListener("focus",this._topBoundaryFocusListener),l.removeEventListener("focus",this._bottomBoundaryFocusListener),t===0){let a=this._createAccessibilityTreeNode();this._rowElements.unshift(a),this._rowContainer.insertAdjacentElement("afterbegin",a)}else{let a=this._createAccessibilityTreeNode();this._rowElements.push(a),this._rowContainer.appendChild(a)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){var l;if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error("anchorNode and/or focusNode are null");return}let t={node:e.anchorNode,offset:e.anchorOffset},r={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(r.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===r.node&&t.offset>r.offset)&&([t,r]=[r,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let n=this._rowElements.slice(-1)[0];if(r.node.compareDocumentPosition(n)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(r={node:n,offset:((l=n.textContent)==null?void 0:l.length)??0}),!this._rowContainer.contains(r.node))return;let i=({node:a,offset:c})=>{let d=a instanceof Text?a.parentNode:a,h=parseInt(d==null?void 0:d.getAttribute("aria-posinset"),10)-1;if(isNaN(h))return console.warn("row is invalid. Race condition?"),null;let f=this._rowColumns.get(d);if(!f)return console.warn("columns is null. Race condition?"),null;let p=c<f.length?f[c]:f.slice(-1)[0]+1;return p>=this._terminal.cols&&(++h,p=0),{row:h,column:p}},s=i(t),o=i(r);if(!(!s||!o)){if(s.row>o.row||s.row===o.row&&s.column>=o.column)throw new Error("invalid range");this._terminal.select(s.column,s.row,(o.row-s.row)*this._terminal.cols-s.column+o.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let t=this._rowContainer.children.length;t<this._terminal.rows;t++)this._rowElements[t]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[t]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement("div");return e.setAttribute("role","listitem"),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e]),this._alignRowWidth(this._rowElements[e])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(e){var i,s;e.style.transform="";let t=e.getBoundingClientRect().width,r=(s=(i=this._rowColumns.get(e))==null?void 0:i.slice(-1))==null?void 0:s[0];if(!r)return;let n=r*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${n/t})`}};tc=ut([ue(1,rp),ue(2,Tn),ue(3,Pn)],tc);var Ld=class extends Be{constructor(e,t,r,n,i){super(),this._element=e,this._mouseService=t,this._renderService=r,this._bufferService=n,this._linkProviderService=i,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new ae),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new ae),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(rt(()=>{var s;$i(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,(s=this._activeProviderReplies)==null||s.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(Ne(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(Ne(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(Ne(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(Ne(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let r=e.composedPath();for(let n=0;n<r.length;n++){let i=r[n];if(i.classList.contains("xterm"))break;if(i.classList.contains("xterm-hover"))return}(!this._lastBufferCell||t.x!==this._lastBufferCell.x||t.y!==this._lastBufferCell.y)&&(this._handleHover(t),this._lastBufferCell=t)}_handleHover(e){if(this._activeLine!==e.y||this._wasResized){this._clearCurrentLink(),this._askForLink(e,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,t){var n,i;(!this._activeProviderReplies||!t)&&((n=this._activeProviderReplies)==null||n.forEach(s=>{s==null||s.forEach(o=>{o.link.dispose&&o.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let r=!1;for(let[s,o]of this._linkProviderService.linkProviders.entries())t?(i=this._activeProviderReplies)!=null&&i.get(s)&&(r=this._checkLinkProviderResult(s,e,r)):o.provideLinks(e.y,l=>{var c,d;if(this._isMouseOut)return;let a=l==null?void 0:l.map(h=>({link:h}));(c=this._activeProviderReplies)==null||c.set(s,a),r=this._checkLinkProviderResult(s,e,r),((d=this._activeProviderReplies)==null?void 0:d.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let r=new Set;for(let n=0;n<t.size;n++){let i=t.get(n);if(i)for(let s=0;s<i.length;s++){let o=i[s],l=o.link.range.start.y<e?0:o.link.range.start.x,a=o.link.range.end.y>e?this._bufferService.cols:o.link.range.end.x;for(let c=l;c<=a;c++){if(r.has(c)){i.splice(s--,1);break}r.add(c)}}}}_checkLinkProviderResult(e,t,r){var s;if(!this._activeProviderReplies)return r;let n=this._activeProviderReplies.get(e),i=!1;for(let o=0;o<e;o++)(!this._activeProviderReplies.has(o)||this._activeProviderReplies.get(o))&&(i=!0);if(!i&&n){let o=n.find(l=>this._linkAtPosition(l.link,t));o&&(r=!0,this._handleNewLink(o))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!r)for(let o=0;o<this._activeProviderReplies.size;o++){let l=(s=this._activeProviderReplies.get(o))==null?void 0:s.find(a=>this._linkAtPosition(a.link,t));if(l){r=!0,this._handleNewLink(l);break}}return r}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&UM(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,t)&&this._currentLink.link.activate(e,this._currentLink.link.text)}_clearCurrentLink(e,t){!this._currentLink||!this._lastMouseEvent||(!e||!t||this._currentLink.link.range.start.y>=e&&this._currentLink.link.range.end.y<=t)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,$i(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._linkAtPosition(e.link,t)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0?!0:e.link.decorations.underline,pointerCursor:e.link.decorations===void 0?!0:e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>{var r,n;return(n=(r=this._currentLink)==null?void 0:r.state)==null?void 0:n.decorations.pointerCursor},set:r=>{var n;(n=this._currentLink)!=null&&n.state&&this._currentLink.state.decorations.pointerCursor!==r&&(this._currentLink.state.decorations.pointerCursor=r,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",r))}},underline:{get:()=>{var r,n;return(n=(r=this._currentLink)==null?void 0:r.state)==null?void 0:n.decorations.underline},set:r=>{var n,i,s;(n=this._currentLink)!=null&&n.state&&((s=(i=this._currentLink)==null?void 0:i.state)==null?void 0:s.decorations.underline)!==r&&(this._currentLink.state.decorations.underline=r,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,r))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(r=>{if(!this._currentLink)return;let n=r.start===0?0:r.start+1+this._bufferService.buffer.ydisp,i=this._bufferService.buffer.ydisp+1+r.end;if(this._currentLink.link.range.start.y>=n&&this._currentLink.link.range.end.y<=i&&(this._clearCurrentLink(n,i),this._lastMouseEvent)){let s=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);s&&this._askForLink(s,!1)}})))}_linkHover(e,t,r){var n;(n=this._currentLink)!=null&&n.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add("xterm-cursor-pointer")),t.hover&&t.hover(r,t.text)}_fireUnderlineEvent(e,t){let r=e.range,n=this._bufferService.buffer.ydisp,i=this._createLinkUnderlineEvent(r.start.x-1,r.start.y-n-1,r.end.x,r.end.y-n-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(i)}_linkLeave(e,t,r){var n;(n=this._currentLink)!=null&&n.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove("xterm-cursor-pointer")),t.leave&&t.leave(r,t.text)}_linkAtPosition(e,t){let r=e.range.start.y*this._bufferService.cols+e.range.start.x,n=e.range.end.y*this._bufferService.cols+e.range.end.x,i=t.y*this._bufferService.cols+t.x;return r<=i&&i<=n}_positionFromMouseEvent(e,t,r){let n=r.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(n)return{x:n[0],y:n[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,r,n,i){return{x1:e,y1:t,x2:r,y2:n,cols:this._bufferService.cols,fg:i}}};Ld=ut([ue(1,np),ue(2,Pn),ue(3,tr),ue(4,Q0)],Ld);function UM(e,t){return e.text===t.text&&e.range.start.x===t.range.start.x&&e.range.start.y===t.range.start.y&&e.range.end.x===t.range.end.x&&e.range.end.y===t.range.end.y}var KM=class extends AM{constructor(e={}){super(e),this._linkifier=this._register(new Ts),this.browser=g1,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new Ts),this._onCursorMove=this._register(new ae),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new ae),this.onKey=this._onKey.event,this._onRender=this._register(new ae),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new ae),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new ae),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new ae),this.onBell=this._onBell.event,this._onFocus=this._register(new ae),this._onBlur=this._register(new ae),this._onA11yCharEmitter=this._register(new ae),this._onA11yTabEmitter=this._register(new ae),this._onWillOpen=this._register(new ae),this._setup(),this._decorationService=this._instantiationService.createInstance($M),this._instantiationService.setService(dl,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(jR),this._instantiationService.setService(Q0,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(Zh)),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(Bt.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(Bt.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(Bt.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(Bt.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(rt(()=>{var t,r;this._customKeyEventHandler=void 0,(r=(t=this.element)==null?void 0:t.parentNode)==null||r.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 r,n="";switch(t.index){case 256:r="foreground",n="10";break;case 257:r="background",n="11";break;case 258:r="cursor",n="12";break;default:r="ansi",n="4;"+t.index}switch(t.type){case 0:let i=Ze.toColorRGB(r==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[r]);this.coreService.triggerDataEvent(`${Q.ESC}]${n};${RM(i)}${p1.ST}`);break;case 1:if(r==="ansi")this._themeService.modifyColors(s=>s.ansi[t.index]=_t.toColor(...t.color));else{let s=r;this._themeService.modifyColors(o=>o[s]=_t.toColor(...t.color))}break;case 2:this._themeService.restoreColor(t.index);break}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(tc,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(Q.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){var e;return(e=this.textarea)==null?void 0:e.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(Q.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let r=Math.min(this.buffer.x,this.cols-1),n=this._renderService.dimensions.css.cell.height,i=t.getWidth(r),s=this._renderService.dimensions.css.cell.width*i,o=this.buffer.y*this._renderService.dimensions.css.cell.height,l=r*this._renderService.dimensions.css.cell.width;this.textarea.style.left=l+"px",this.textarea.style.top=o+"px",this.textarea.style.width=s+"px",this.textarea.style.height=n+"px",this.textarea.style.lineHeight=n+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(Ne(this.element,"copy",t=>{this.hasSelection()&&XP(t,this._selectionService)}));let e=t=>GP(t,this.textarea,this.coreService,this.optionsService);this._register(Ne(this.textarea,"paste",e)),this._register(Ne(this.element,"paste",e)),_1?this._register(Ne(this.element,"mousedown",t=>{t.button===2&&jg(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(Ne(this.element,"contextmenu",t=>{jg(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),hp&&this._register(Ne(this.element,"auxclick",t=>{t.button===1&&W0(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(Ne(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(Ne(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(Ne(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(Ne(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(Ne(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(Ne(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(Ne(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){var i;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"),((i=this.element)==null?void 0:i.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(Ne(this.screenElement,"mousemove",s=>this.updateCursorStyle(s))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let r=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",Gh.get()),y1||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",()=>r.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(LR,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(Tn,this._coreBrowserService),this._register(Ne(this.textarea,"focus",s=>this._handleTextAreaFocus(s))),this._register(Ne(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(yd,this._document,this._helperContainer),this._instantiationService.setService(Pc,this._charSizeService),this._themeService=this._instantiationService.createInstance(kd),this._instantiationService.setService(Ds,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(Ja),this._instantiationService.setService(G0,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(wd,this.rows,this.screenElement)),this._instantiationService.setService(Pn,this._renderService),this._register(this._renderService.onRenderedViewportChange(s=>this._onRender.fire(s))),this.onResize(s=>this._renderService.resize(s.cols,s.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(_d,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(bd),this._instantiationService.setService(np,this._mouseService);let n=this._linkifier.value=this._register(this._instantiationService.createInstance(Ld,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(md,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(s=>{super.scrollLines(s,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(Sd,this.element,this.screenElement,n)),this._instantiationService.setService(i3,this._selectionService),this._register(this._selectionService.onRequestScrollLines(s=>this.scrollLines(s.amount,s.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(s=>this._renderService.handleSelectionChanged(s.start,s.end,s.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(s=>{this.textarea.value=s,this.textarea.focus(),this.textarea.select()})),this._register(Bt.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{var s;this._selectionService.refresh(),(s=this._viewport)==null||s.queueSync()})),this._register(this._instantiationService.createInstance(gd,this.screenElement)),this._register(Ne(this.element,"mousedown",s=>this._selectionService.handleMouseDown(s))),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(tc,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",s=>this._handleScreenReaderModeOptionChange(s))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Qa,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",s=>{!this._overviewRulerRenderer&&s&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Qa,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(xd,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function r(s){var c,d,h,f,p;let o=e._mouseService.getMouseReportCoords(s,e.screenElement);if(!o)return!1;let l,a;switch(s.overrideType||s.type){case"mousemove":a=32,s.buttons===void 0?(l=3,s.button!==void 0&&(l=s.button<3?s.button:3)):l=s.buttons&1?0:s.buttons&4?1:s.buttons&2?2:3;break;case"mouseup":a=0,l=s.button<3?s.button:3;break;case"mousedown":a=1,l=s.button<3?s.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(s)===!1)return!1;let m=s.deltaY;if(m===0||e.coreMouseService.consumeWheelEvent(s,(f=(h=(d=(c=e._renderService)==null?void 0:c.dimensions)==null?void 0:d.device)==null?void 0:h.cell)==null?void 0:f.height,(p=e._coreBrowserService)==null?void 0:p.dpr)===0)return!1;a=m<0?0:1,l=4;break;default:return!1}return a===void 0||l===void 0||l>4?!1:e.coreMouseService.triggerMouseEvent({col:o.col,row:o.row,x:o.x,y:o.y,button:l,action:a,ctrl:s.ctrlKey,alt:s.altKey,shift:s.shiftKey})}let n={mouseup:null,wheel:null,mousedrag:null,mousemove:null},i={mouseup:s=>(r(s),s.buttons||(this._document.removeEventListener("mouseup",n.mouseup),n.mousedrag&&this._document.removeEventListener("mousemove",n.mousedrag)),this.cancel(s)),wheel:s=>(r(s),this.cancel(s,!0)),mousedrag:s=>{s.buttons&&r(s)},mousemove:s=>{s.buttons||r(s)}};this._register(this.coreMouseService.onProtocolChange(s=>{s?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(s)),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()),s&8?n.mousemove||(t.addEventListener("mousemove",i.mousemove),n.mousemove=i.mousemove):(t.removeEventListener("mousemove",n.mousemove),n.mousemove=null),s&16?n.wheel||(t.addEventListener("wheel",i.wheel,{passive:!1}),n.wheel=i.wheel):(t.removeEventListener("wheel",n.wheel),n.wheel=null),s&2?n.mouseup||(n.mouseup=i.mouseup):(this._document.removeEventListener("mouseup",n.mouseup),n.mouseup=null),s&4?n.mousedrag||(n.mousedrag=i.mousedrag):(this._document.removeEventListener("mousemove",n.mousedrag),n.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(Ne(t,"mousedown",s=>{if(s.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(s)))return r(s),n.mouseup&&this._document.addEventListener("mouseup",n.mouseup),n.mousedrag&&this._document.addEventListener("mousemove",n.mousedrag),this.cancel(s)})),this._register(Ne(t,"wheel",s=>{var o,l,a,c,d;if(!n.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(s)===!1)return!1;if(!this.buffer.hasScrollback){if(s.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(s,(c=(a=(l=(o=e._renderService)==null?void 0:o.dimensions)==null?void 0:l.device)==null?void 0:a.cell)==null?void 0:c.height,(d=e._coreBrowserService)==null?void 0:d.dpr)===0)return this.cancel(s,!0);let h=Q.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(s.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(h,!0),this.cancel(s,!0)}}},{passive:!1}))}refresh(e,t){var r;(r=this._renderService)==null||r.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){F0(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,r){this._selectionService.setSelection(e,t,r)}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 r;(r=this._selectionService)==null||r.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 r=OM(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),r.type===3||r.type===2){let n=this.rows-1;return this.scrollLines(r.type===2?-n:n),this.cancel(e,!0)}if(r.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(r.cancel&&this.cancel(e,!0),!r.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((r.key===Q.ETX||r.key===Q.CR)&&(this.textarea.value=""),this._onKey.fire({key:r.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(r.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let r=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"?r:r&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(VM(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 r;(r=this._charSizeService)==null||r.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(gt));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){var t;this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),(t=this._selectionService)==null||t.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){var e;(e=this._renderService)==null||e.clearTextureAtlas()}_reportFocus(){var e;(e=this.element)!=null&&e.classList.contains("focus")?this.coreService.triggerDataEvent(Q.ESC+"[I"):this.coreService.triggerDataEvent(Q.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let t=this._renderService.dimensions.css.canvas.width.toFixed(0),r=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${Q.ESC}[4;${r};${t}t`);break;case 1:let n=this._renderService.dimensions.css.cell.width.toFixed(0),i=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${Q.ESC}[6;${i};${n}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function VM(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var qM=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let r={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(r),t.dispose=()=>this._wrappedAddonDispose(r),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let r=0;r<this._addons.length;r++)if(this._addons[r]===e){t=r;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)}},YM=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 Ar)}translateToString(e,t,r){return this._line.translateToString(e,t,r)}},C_=class{constructor(e,t){this._buffer=e,this.type=t}init(e){return this._buffer=e,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(e){let t=this._buffer.lines.get(e);if(t)return new YM(t)}getNullCell(){return new Ar}},XM=class extends Be{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new ae),this.onBufferChange=this._onBufferChange.event,this._normal=new C_(this._core.buffers.normal,"normal"),this._alternate=new C_(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)}},GM=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,r=>t(r.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(r,n)=>t(r,n.toArray()))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}},QM=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}},JM=["cols","rows"],Qr=0,ZM=class extends Be{constructor(e){super(),this._core=this._register(new KM(e)),this._addonManager=this._register(new qM),this._publicOptions={...this._core.options};let t=n=>this._core.options[n],r=(n,i)=>{this._checkReadonlyOptions(n),this._core.options[n]=i};for(let n in this._core.options){let i={get:t.bind(this,n),set:r.bind(this,n)};Object.defineProperty(this._publicOptions,n,i)}}_checkReadonlyOptions(e){if(JM.includes(e))throw new Error(`Option "${e}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw new Error("You must set the allowProposedApi option to true to use proposed API")}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||(this._parser=new GM(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new QM(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 XM(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,t="none";switch(this._core.coreMouseService.activeProtocol){case"X10":t="x10";break;case"VT200":t="vt200";break;case"DRAG":t="drag";break;case"ANY":t="any";break}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,r){this._verifyIntegers(e,t,r),this._core.select(e,t,r)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r
|
|
130
|
+
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===k_+1&&(this._liveRegion.textContent+=Qh.get())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let r=this._terminal.buffer,n=r.lines.length.toString();for(let i=e;i<=t;i++){let s=r.lines.get(r.ydisp+i),o=[],l=(s==null?void 0:s.translateToString(!0,void 0,void 0,o))||"",a=(r.ydisp+i+1).toString(),c=this._rowElements[i];c&&(l.length===0?(c.textContent=" ",this._rowColumns.set(c,[0,1])):(c.textContent=l,this._rowColumns.set(c,o)),c.setAttribute("aria-posinset",a),c.setAttribute("aria-setsize",n),this._alignRowWidth(c))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){let r=e.target,n=this._rowElements[t===0?1:this._rowElements.length-2],i=r.getAttribute("aria-posinset"),s=t===0?"1":`${this._terminal.buffer.lines.length}`;if(i===s||e.relatedTarget!==n)return;let o,l;if(t===0?(o=r,l=this._rowElements.pop(),this._rowContainer.removeChild(l)):(o=this._rowElements.shift(),l=r,this._rowContainer.removeChild(o)),o.removeEventListener("focus",this._topBoundaryFocusListener),l.removeEventListener("focus",this._bottomBoundaryFocusListener),t===0){let a=this._createAccessibilityTreeNode();this._rowElements.unshift(a),this._rowContainer.insertAdjacentElement("afterbegin",a)}else{let a=this._createAccessibilityTreeNode();this._rowElements.push(a),this._rowContainer.appendChild(a)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){var l;if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error("anchorNode and/or focusNode are null");return}let t={node:e.anchorNode,offset:e.anchorOffset},r={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(r.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===r.node&&t.offset>r.offset)&&([t,r]=[r,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let n=this._rowElements.slice(-1)[0];if(r.node.compareDocumentPosition(n)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(r={node:n,offset:((l=n.textContent)==null?void 0:l.length)??0}),!this._rowContainer.contains(r.node))return;let i=({node:a,offset:c})=>{let d=a instanceof Text?a.parentNode:a,h=parseInt(d==null?void 0:d.getAttribute("aria-posinset"),10)-1;if(isNaN(h))return console.warn("row is invalid. Race condition?"),null;let f=this._rowColumns.get(d);if(!f)return console.warn("columns is null. Race condition?"),null;let p=c<f.length?f[c]:f.slice(-1)[0]+1;return p>=this._terminal.cols&&(++h,p=0),{row:h,column:p}},s=i(t),o=i(r);if(!(!s||!o)){if(s.row>o.row||s.row===o.row&&s.column>=o.column)throw new Error("invalid range");this._terminal.select(s.column,s.row,(o.row-s.row)*this._terminal.cols-s.column+o.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let t=this._rowContainer.children.length;t<this._terminal.rows;t++)this._rowElements[t]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[t]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement("div");return e.setAttribute("role","listitem"),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e]),this._alignRowWidth(this._rowElements[e])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(e){var i,s;e.style.transform="";let t=e.getBoundingClientRect().width,r=(s=(i=this._rowColumns.get(e))==null?void 0:i.slice(-1))==null?void 0:s[0];if(!r)return;let n=r*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${n/t})`}};tc=ut([ue(1,rp),ue(2,Tn),ue(3,Pn)],tc);var Ld=class extends Be{constructor(e,t,r,n,i){super(),this._element=e,this._mouseService=t,this._renderService=r,this._bufferService=n,this._linkProviderService=i,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new le),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new le),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(rt(()=>{var s;$i(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,(s=this._activeProviderReplies)==null||s.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(Ne(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(Ne(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(Ne(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(Ne(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let r=e.composedPath();for(let n=0;n<r.length;n++){let i=r[n];if(i.classList.contains("xterm"))break;if(i.classList.contains("xterm-hover"))return}(!this._lastBufferCell||t.x!==this._lastBufferCell.x||t.y!==this._lastBufferCell.y)&&(this._handleHover(t),this._lastBufferCell=t)}_handleHover(e){if(this._activeLine!==e.y||this._wasResized){this._clearCurrentLink(),this._askForLink(e,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,t){var n,i;(!this._activeProviderReplies||!t)&&((n=this._activeProviderReplies)==null||n.forEach(s=>{s==null||s.forEach(o=>{o.link.dispose&&o.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let r=!1;for(let[s,o]of this._linkProviderService.linkProviders.entries())t?(i=this._activeProviderReplies)!=null&&i.get(s)&&(r=this._checkLinkProviderResult(s,e,r)):o.provideLinks(e.y,l=>{var c,d;if(this._isMouseOut)return;let a=l==null?void 0:l.map(h=>({link:h}));(c=this._activeProviderReplies)==null||c.set(s,a),r=this._checkLinkProviderResult(s,e,r),((d=this._activeProviderReplies)==null?void 0:d.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let r=new Set;for(let n=0;n<t.size;n++){let i=t.get(n);if(i)for(let s=0;s<i.length;s++){let o=i[s],l=o.link.range.start.y<e?0:o.link.range.start.x,a=o.link.range.end.y>e?this._bufferService.cols:o.link.range.end.x;for(let c=l;c<=a;c++){if(r.has(c)){i.splice(s--,1);break}r.add(c)}}}}_checkLinkProviderResult(e,t,r){var s;if(!this._activeProviderReplies)return r;let n=this._activeProviderReplies.get(e),i=!1;for(let o=0;o<e;o++)(!this._activeProviderReplies.has(o)||this._activeProviderReplies.get(o))&&(i=!0);if(!i&&n){let o=n.find(l=>this._linkAtPosition(l.link,t));o&&(r=!0,this._handleNewLink(o))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!r)for(let o=0;o<this._activeProviderReplies.size;o++){let l=(s=this._activeProviderReplies.get(o))==null?void 0:s.find(a=>this._linkAtPosition(a.link,t));if(l){r=!0,this._handleNewLink(l);break}}return r}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&UM(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,t)&&this._currentLink.link.activate(e,this._currentLink.link.text)}_clearCurrentLink(e,t){!this._currentLink||!this._lastMouseEvent||(!e||!t||this._currentLink.link.range.start.y>=e&&this._currentLink.link.range.end.y<=t)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,$i(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._linkAtPosition(e.link,t)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0?!0:e.link.decorations.underline,pointerCursor:e.link.decorations===void 0?!0:e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>{var r,n;return(n=(r=this._currentLink)==null?void 0:r.state)==null?void 0:n.decorations.pointerCursor},set:r=>{var n;(n=this._currentLink)!=null&&n.state&&this._currentLink.state.decorations.pointerCursor!==r&&(this._currentLink.state.decorations.pointerCursor=r,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",r))}},underline:{get:()=>{var r,n;return(n=(r=this._currentLink)==null?void 0:r.state)==null?void 0:n.decorations.underline},set:r=>{var n,i,s;(n=this._currentLink)!=null&&n.state&&((s=(i=this._currentLink)==null?void 0:i.state)==null?void 0:s.decorations.underline)!==r&&(this._currentLink.state.decorations.underline=r,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,r))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(r=>{if(!this._currentLink)return;let n=r.start===0?0:r.start+1+this._bufferService.buffer.ydisp,i=this._bufferService.buffer.ydisp+1+r.end;if(this._currentLink.link.range.start.y>=n&&this._currentLink.link.range.end.y<=i&&(this._clearCurrentLink(n,i),this._lastMouseEvent)){let s=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);s&&this._askForLink(s,!1)}})))}_linkHover(e,t,r){var n;(n=this._currentLink)!=null&&n.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add("xterm-cursor-pointer")),t.hover&&t.hover(r,t.text)}_fireUnderlineEvent(e,t){let r=e.range,n=this._bufferService.buffer.ydisp,i=this._createLinkUnderlineEvent(r.start.x-1,r.start.y-n-1,r.end.x,r.end.y-n-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(i)}_linkLeave(e,t,r){var n;(n=this._currentLink)!=null&&n.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove("xterm-cursor-pointer")),t.leave&&t.leave(r,t.text)}_linkAtPosition(e,t){let r=e.range.start.y*this._bufferService.cols+e.range.start.x,n=e.range.end.y*this._bufferService.cols+e.range.end.x,i=t.y*this._bufferService.cols+t.x;return r<=i&&i<=n}_positionFromMouseEvent(e,t,r){let n=r.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(n)return{x:n[0],y:n[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,r,n,i){return{x1:e,y1:t,x2:r,y2:n,cols:this._bufferService.cols,fg:i}}};Ld=ut([ue(1,np),ue(2,Pn),ue(3,tr),ue(4,Q0)],Ld);function UM(e,t){return e.text===t.text&&e.range.start.x===t.range.start.x&&e.range.start.y===t.range.start.y&&e.range.end.x===t.range.end.x&&e.range.end.y===t.range.end.y}var KM=class extends AM{constructor(e={}){super(e),this._linkifier=this._register(new Ts),this.browser=g1,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new Ts),this._onCursorMove=this._register(new le),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new le),this.onKey=this._onKey.event,this._onRender=this._register(new le),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new le),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new le),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new le),this.onBell=this._onBell.event,this._onFocus=this._register(new le),this._onBlur=this._register(new le),this._onA11yCharEmitter=this._register(new le),this._onA11yTabEmitter=this._register(new le),this._onWillOpen=this._register(new le),this._setup(),this._decorationService=this._instantiationService.createInstance($M),this._instantiationService.setService(dl,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(jR),this._instantiationService.setService(Q0,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(Zh)),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(Bt.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(Bt.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(Bt.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(Bt.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(rt(()=>{var t,r;this._customKeyEventHandler=void 0,(r=(t=this.element)==null?void 0:t.parentNode)==null||r.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 r,n="";switch(t.index){case 256:r="foreground",n="10";break;case 257:r="background",n="11";break;case 258:r="cursor",n="12";break;default:r="ansi",n="4;"+t.index}switch(t.type){case 0:let i=Ze.toColorRGB(r==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[r]);this.coreService.triggerDataEvent(`${Q.ESC}]${n};${RM(i)}${p1.ST}`);break;case 1:if(r==="ansi")this._themeService.modifyColors(s=>s.ansi[t.index]=_t.toColor(...t.color));else{let s=r;this._themeService.modifyColors(o=>o[s]=_t.toColor(...t.color))}break;case 2:this._themeService.restoreColor(t.index);break}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(tc,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(Q.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){var e;return(e=this.textarea)==null?void 0:e.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(Q.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let r=Math.min(this.buffer.x,this.cols-1),n=this._renderService.dimensions.css.cell.height,i=t.getWidth(r),s=this._renderService.dimensions.css.cell.width*i,o=this.buffer.y*this._renderService.dimensions.css.cell.height,l=r*this._renderService.dimensions.css.cell.width;this.textarea.style.left=l+"px",this.textarea.style.top=o+"px",this.textarea.style.width=s+"px",this.textarea.style.height=n+"px",this.textarea.style.lineHeight=n+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(Ne(this.element,"copy",t=>{this.hasSelection()&&XP(t,this._selectionService)}));let e=t=>GP(t,this.textarea,this.coreService,this.optionsService);this._register(Ne(this.textarea,"paste",e)),this._register(Ne(this.element,"paste",e)),_1?this._register(Ne(this.element,"mousedown",t=>{t.button===2&&jg(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(Ne(this.element,"contextmenu",t=>{jg(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),hp&&this._register(Ne(this.element,"auxclick",t=>{t.button===1&&W0(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(Ne(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(Ne(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(Ne(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(Ne(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(Ne(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(Ne(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(Ne(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){var i;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"),((i=this.element)==null?void 0:i.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(Ne(this.screenElement,"mousemove",s=>this.updateCursorStyle(s))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let r=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",Gh.get()),y1||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",()=>r.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(LR,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(Tn,this._coreBrowserService),this._register(Ne(this.textarea,"focus",s=>this._handleTextAreaFocus(s))),this._register(Ne(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(yd,this._document,this._helperContainer),this._instantiationService.setService(Pc,this._charSizeService),this._themeService=this._instantiationService.createInstance(kd),this._instantiationService.setService(Ds,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(Ja),this._instantiationService.setService(G0,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(wd,this.rows,this.screenElement)),this._instantiationService.setService(Pn,this._renderService),this._register(this._renderService.onRenderedViewportChange(s=>this._onRender.fire(s))),this.onResize(s=>this._renderService.resize(s.cols,s.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(_d,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(bd),this._instantiationService.setService(np,this._mouseService);let n=this._linkifier.value=this._register(this._instantiationService.createInstance(Ld,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(md,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(s=>{super.scrollLines(s,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(Sd,this.element,this.screenElement,n)),this._instantiationService.setService(i3,this._selectionService),this._register(this._selectionService.onRequestScrollLines(s=>this.scrollLines(s.amount,s.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(s=>this._renderService.handleSelectionChanged(s.start,s.end,s.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(s=>{this.textarea.value=s,this.textarea.focus(),this.textarea.select()})),this._register(Bt.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{var s;this._selectionService.refresh(),(s=this._viewport)==null||s.queueSync()})),this._register(this._instantiationService.createInstance(gd,this.screenElement)),this._register(Ne(this.element,"mousedown",s=>this._selectionService.handleMouseDown(s))),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(tc,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",s=>this._handleScreenReaderModeOptionChange(s))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Qa,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",s=>{!this._overviewRulerRenderer&&s&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Qa,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(xd,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function r(s){var c,d,h,f,p;let o=e._mouseService.getMouseReportCoords(s,e.screenElement);if(!o)return!1;let l,a;switch(s.overrideType||s.type){case"mousemove":a=32,s.buttons===void 0?(l=3,s.button!==void 0&&(l=s.button<3?s.button:3)):l=s.buttons&1?0:s.buttons&4?1:s.buttons&2?2:3;break;case"mouseup":a=0,l=s.button<3?s.button:3;break;case"mousedown":a=1,l=s.button<3?s.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(s)===!1)return!1;let m=s.deltaY;if(m===0||e.coreMouseService.consumeWheelEvent(s,(f=(h=(d=(c=e._renderService)==null?void 0:c.dimensions)==null?void 0:d.device)==null?void 0:h.cell)==null?void 0:f.height,(p=e._coreBrowserService)==null?void 0:p.dpr)===0)return!1;a=m<0?0:1,l=4;break;default:return!1}return a===void 0||l===void 0||l>4?!1:e.coreMouseService.triggerMouseEvent({col:o.col,row:o.row,x:o.x,y:o.y,button:l,action:a,ctrl:s.ctrlKey,alt:s.altKey,shift:s.shiftKey})}let n={mouseup:null,wheel:null,mousedrag:null,mousemove:null},i={mouseup:s=>(r(s),s.buttons||(this._document.removeEventListener("mouseup",n.mouseup),n.mousedrag&&this._document.removeEventListener("mousemove",n.mousedrag)),this.cancel(s)),wheel:s=>(r(s),this.cancel(s,!0)),mousedrag:s=>{s.buttons&&r(s)},mousemove:s=>{s.buttons||r(s)}};this._register(this.coreMouseService.onProtocolChange(s=>{s?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(s)),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()),s&8?n.mousemove||(t.addEventListener("mousemove",i.mousemove),n.mousemove=i.mousemove):(t.removeEventListener("mousemove",n.mousemove),n.mousemove=null),s&16?n.wheel||(t.addEventListener("wheel",i.wheel,{passive:!1}),n.wheel=i.wheel):(t.removeEventListener("wheel",n.wheel),n.wheel=null),s&2?n.mouseup||(n.mouseup=i.mouseup):(this._document.removeEventListener("mouseup",n.mouseup),n.mouseup=null),s&4?n.mousedrag||(n.mousedrag=i.mousedrag):(this._document.removeEventListener("mousemove",n.mousedrag),n.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(Ne(t,"mousedown",s=>{if(s.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(s)))return r(s),n.mouseup&&this._document.addEventListener("mouseup",n.mouseup),n.mousedrag&&this._document.addEventListener("mousemove",n.mousedrag),this.cancel(s)})),this._register(Ne(t,"wheel",s=>{var o,l,a,c,d;if(!n.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(s)===!1)return!1;if(!this.buffer.hasScrollback){if(s.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(s,(c=(a=(l=(o=e._renderService)==null?void 0:o.dimensions)==null?void 0:l.device)==null?void 0:a.cell)==null?void 0:c.height,(d=e._coreBrowserService)==null?void 0:d.dpr)===0)return this.cancel(s,!0);let h=Q.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(s.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(h,!0),this.cancel(s,!0)}}},{passive:!1}))}refresh(e,t){var r;(r=this._renderService)==null||r.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){F0(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,r){this._selectionService.setSelection(e,t,r)}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 r;(r=this._selectionService)==null||r.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 r=OM(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),r.type===3||r.type===2){let n=this.rows-1;return this.scrollLines(r.type===2?-n:n),this.cancel(e,!0)}if(r.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(r.cancel&&this.cancel(e,!0),!r.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((r.key===Q.ETX||r.key===Q.CR)&&(this.textarea.value=""),this._onKey.fire({key:r.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(r.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let r=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"?r:r&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(VM(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 r;(r=this._charSizeService)==null||r.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(gt));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){var t;this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),(t=this._selectionService)==null||t.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){var e;(e=this._renderService)==null||e.clearTextureAtlas()}_reportFocus(){var e;(e=this.element)!=null&&e.classList.contains("focus")?this.coreService.triggerDataEvent(Q.ESC+"[I"):this.coreService.triggerDataEvent(Q.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let t=this._renderService.dimensions.css.canvas.width.toFixed(0),r=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${Q.ESC}[4;${r};${t}t`);break;case 1:let n=this._renderService.dimensions.css.cell.width.toFixed(0),i=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${Q.ESC}[6;${i};${n}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function VM(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var qM=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let r={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(r),t.dispose=()=>this._wrappedAddonDispose(r),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let r=0;r<this._addons.length;r++)if(this._addons[r]===e){t=r;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)}},YM=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 Ar)}translateToString(e,t,r){return this._line.translateToString(e,t,r)}},C_=class{constructor(e,t){this._buffer=e,this.type=t}init(e){return this._buffer=e,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(e){let t=this._buffer.lines.get(e);if(t)return new YM(t)}getNullCell(){return new Ar}},XM=class extends Be{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new le),this.onBufferChange=this._onBufferChange.event,this._normal=new C_(this._core.buffers.normal,"normal"),this._alternate=new C_(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)}},GM=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,r=>t(r.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(r,n)=>t(r,n.toArray()))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}},QM=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}},JM=["cols","rows"],Qr=0,ZM=class extends Be{constructor(e){super(),this._core=this._register(new KM(e)),this._addonManager=this._register(new qM),this._publicOptions={...this._core.options};let t=n=>this._core.options[n],r=(n,i)=>{this._checkReadonlyOptions(n),this._core.options[n]=i};for(let n in this._core.options){let i={get:t.bind(this,n),set:r.bind(this,n)};Object.defineProperty(this._publicOptions,n,i)}}_checkReadonlyOptions(e){if(JM.includes(e))throw new Error(`Option "${e}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw new Error("You must set the allowProposedApi option to true to use proposed API")}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||(this._parser=new GM(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new QM(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 XM(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,t="none";switch(this._core.coreMouseService.activeProtocol){case"X10":t="x10";break;case"VT200":t="vt200";break;case"DRAG":t="drag";break;case"ANY":t="any";break}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,r){this._verifyIntegers(e,t,r),this._core.select(e,t,r)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r
|
|
131
131
|
`,t)}paste(e){this._core.paste(e)}refresh(e,t){this._verifyIntegers(e,t),this._core.refresh(e,t)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return Gh.get()},set promptLabel(e){Gh.set(e)},get tooMuchOutput(){return Qh.get()},set tooMuchOutput(e){Qh.set(e)}}}_verifyIntegers(...e){for(Qr of e)if(Qr===1/0||isNaN(Qr)||Qr%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(Qr of e)if(Qr&&(Qr===1/0||isNaN(Qr)||Qr%1!==0||Qr<0))throw new Error("This API only accepts positive integers")}};/**
|
|
132
132
|
* Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
|
|
133
133
|
* @license MIT
|
|
@@ -150,7 +150,7 @@ WARNING: This link could potentially be dangerous`)){let r=window.open();if(r){t
|
|
|
150
150
|
* Fabrice Bellard's javascript vt100 for jslinux:
|
|
151
151
|
* http://bellard.org/jslinux/
|
|
152
152
|
* Copyright (c) 2011 Fabrice Bellard
|
|
153
|
-
*/var nL=class{constructor(e,t,r,n={}){this._terminal=e,this._regex=t,this._handler=r,this._options=n}provideLinks(e,t){let r=sL.computeLink(e,this._regex,this._terminal,this._handler);t(this._addCallbacks(r))}_addCallbacks(e){return e.map(t=>(t.leave=this._options.leave,t.hover=(r,n)=>{if(this._options.hover){let{range:i}=t;this._options.hover(r,n,i)}},t))}};function iL(e){try{let t=new URL(e),r=t.password&&t.username?`${t.protocol}//${t.username}:${t.password}@${t.host}`:t.username?`${t.protocol}//${t.username}@${t.host}`:`${t.protocol}//${t.host}`;return e.toLocaleLowerCase().startsWith(r.toLocaleLowerCase())}catch{return!1}}var sL=class pa{static computeLink(t,r,n,i){let s=new RegExp(r.source,(r.flags||"")+"g"),[o,l]=pa._getWindowedLineStrings(t-1,n),a=o.join(""),c,d=[];for(;c=s.exec(a);){let h=c[0];if(!iL(h))continue;let[f,p]=pa._mapStrIdx(n,l,0,c.index),[m,_]=pa._mapStrIdx(n,f,p,h.length);if(f===-1||p===-1||m===-1||_===-1)continue;let b={start:{x:p+1,y:f+1},end:{x:_,y:m+1}};d.push({range:b,text:h,activate:i})}return d}static _getWindowedLineStrings(t,r){let n,i=t,s=t,o=0,l="",a=[];if(n=r.buffer.active.getLine(t)){let c=n.translateToString(!0);if(n.isWrapped&&c[0]!==" "){for(o=0;(n=r.buffer.active.getLine(--i))&&o<2048&&(l=n.translateToString(!0),o+=l.length,a.push(l),!(!n.isWrapped||l.indexOf(" ")!==-1)););a.reverse()}for(a.push(c),o=0;(n=r.buffer.active.getLine(++s))&&n.isWrapped&&o<2048&&(l=n.translateToString(!0),o+=l.length,a.push(l),l.indexOf(" ")===-1););}return[a,i]}static _mapStrIdx(t,r,n,i){let s=t.buffer.active,o=s.getNullCell(),l=n;for(;i;){let a=s.getLine(r);if(!a)return[-1,-1];for(let c=l;c<a.length;++c){a.getCell(c,o);let d=o.getChars();if(o.getWidth()&&(i-=d.length||1,c===a.length-1&&d==="")){let h=s.getLine(r+1);h&&h.isWrapped&&(h.getCell(0,o),o.getWidth()===2&&(i+=1))}if(i<0)return[r,c]}r++,l=0}return[r,l]}},oL=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function lL(e,t){let r=window.open();if(r){try{r.opener=null}catch{}r.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}var aL=class{constructor(e=lL,t={}){this._handler=e,this._options=t}activate(e){this._terminal=e;let t=this._options,r=t.urlRegex||oL;this._linkProvider=this._terminal.registerLinkProvider(new nL(this._terminal,r,this._handler,t))}dispose(){var e;(e=this._linkProvider)==null||e.dispose()}};const E_={background:"#0f1117",foreground:"#cdd6f4",cursor:"#f38ba8",cursorAccent:"#0f1117",selectionBackground:"rgba(166, 227, 161, 0.3)",selectionForeground:"#cdd6f4",black:"#45475a",red:"#f38ba8",green:"#a6e3a1",yellow:"#f9e2af",blue:"#89b4fa",magenta:"#cba6f7",cyan:"#94e2d5",white:"#bac2de",brightBlack:"#585b70",brightRed:"#f38ba8",brightGreen:"#a6e3a1",brightYellow:"#f9e2af",brightBlue:"#89b4fa",brightMagenta:"#cba6f7",brightCyan:"#94e2d5",brightWhite:"#a6adc8"},R1=x.forwardRef(({onInput:e,onResize:t,fontSize:r=13},n)=>{const i=x.useRef(null),s=x.useRef(null),o=x.useRef(null),[l,a]=x.useState(!1);return x.useImperativeHandle(n,()=>({write:c=>{var d;(d=s.current)==null||d.write(c)},clear:()=>{var c;(c=s.current)==null||c.clear()},fit:()=>{var c;try{(c=o.current)==null||c.fit(),s.current&&(t==null||t(s.current.cols,s.current.rows))}catch{}},bumpResize:()=>{var c;try{(c=o.current)==null||c.fit();const d=s.current;if(!d)return;const h=d.cols,f=d.rows;t==null||t(h+5,f),setTimeout(()=>{t==null||t(h,f)},100)}catch{}}})),x.useEffect(()=>{if(!i.current)return;const c=new ZM({cursorBlink:!0,cursorStyle:"bar",fontSize:r,fontFamily:"'JetBrains Mono', 'Fira Code', 'SF Mono', 'Menlo', monospace",fontWeight:"400",letterSpacing:0,lineHeight:1.2,theme:E_,allowTransparency:!0,scrollback:5e3,convertEol:!1}),d=new rL,h=new aL;c.loadAddon(d),c.loadAddon(h),c.open(i.current),requestAnimationFrame(()=>{d.fit(),t==null||t(c.cols,c.rows),a(!0)});const f=c.onData(m=>{e(m)}),p=new ResizeObserver(()=>{requestAnimationFrame(()=>{try{d.fit(),t==null||t(c.cols,c.rows)}catch{}})});return p.observe(i.current),s.current=c,o.current=d,()=>{f.dispose(),p.disconnect(),c.dispose(),s.current=null,o.current=null}},[r]),u.jsx("div",{ref:i,className:"w-full h-full rounded-lg overflow-hidden transition-opacity duration-200",style:{background:E_.background,opacity:l?1:0}})});R1.displayName="CliTerminal";function Hl({label:e,value:t,sub:r,icon:n}){return u.jsxs("div",{className:"px-4 py-3.5 rounded-xl bg-bg-secondary border border-border-subtle",children:[u.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[u.jsx("span",{className:"text-base flex items-center",children:n}),u.jsx("span",{className:"text-[10px] text-text-muted uppercase tracking-wide font-semibold",children:e})]}),u.jsx("div",{className:"text-[22px] font-bold text-text-primary tracking-tight",children:t}),r&&u.jsx("div",{className:"text-[11px] text-text-muted mt-0.5",children:r})]})}function N_({value:e,max:t,label:r,color:n="#8b5cf6",detail:i,compact:s=!1}){const o=t>0?Math.min(Math.round(e/t*100),100):0,l=o>85?"#ef4444":o>60?"#f59e0b":n;return s?u.jsxs("div",{className:"flex-1",children:[u.jsxs("div",{className:"flex justify-between mb-0.5",children:[u.jsx("span",{className:"text-[9px] text-text-muted uppercase tracking-wide font-semibold",children:r}),u.jsxs("span",{className:"text-[10px] text-text-secondary font-semibold",children:[o,"%"]})]}),u.jsx("div",{className:"h-1 bg-white/[0.04] rounded-sm overflow-hidden",children:u.jsx("div",{className:"h-full rounded-sm transition-[width] duration-500",style:{width:`${o}%`,background:l}})})]}):u.jsxs("div",{className:"flex-1",children:[u.jsxs("div",{className:"flex justify-between mb-1.5",children:[u.jsx("span",{className:"text-[11px] text-text-secondary font-medium",children:r}),u.jsxs("span",{className:"text-[13px] text-text-primary font-bold",children:[o,"%"]})]}),u.jsx("div",{className:"h-1.5 bg-white/[0.04] rounded-sm overflow-hidden",children:u.jsx("div",{className:"h-full rounded-sm transition-[width] duration-[600ms]",style:{width:`${o}%`,background:`linear-gradient(90deg, ${l}, ${l}cc)`}})}),i&&u.jsx("div",{className:"text-[10px] text-text-muted mt-0.5",children:i})]})}function cL({screenshot:e,isCapturing:t,onRefresh:r,onAction:n,addLog:i,connState:s,connScreenshot:o}){const l=x.useRef(null),a=x.useRef(null),c=x.useRef(null),[d,h]=x.useState(!0),[f,p]=x.useState(2e3),[m,_]=x.useState(null),[b,g]=x.useState(""),[,v]=x.useState(!1),[y,S]=x.useState([]),R=x.useRef(0),[E,P]=x.useState(!1),[N,D]=x.useState(!1),k=typeof window<"u"&&window.matchMedia("(max-width: 768px)").matches,[B,j]=x.useState(k?"mouse":"touch"),[M,C]=x.useState(1),A=x.useRef(!1),[O,U]=x.useState(1),[L,$]=x.useState(0),[w,ee]=x.useState(0),ne=x.useRef(0),T=x.useRef(t),X=x.useRef(r),I=x.useRef(n),F=x.useRef(null),G=x.useRef(null),he=x.useRef(!1),me=x.useRef(null),je=x.useRef(0),Pe=x.useRef(null),Ce=x.useRef(1),de=x.useRef({x:0,y:0}),Te=x.useRef(!1),J=x.useRef(O),fe=x.useRef(L),ke=x.useRef(w),Me=x.useRef(B);x.useEffect(()=>{T.current=t},[t]),x.useEffect(()=>{X.current=r},[r]),x.useEffect(()=>{J.current=O},[O]),x.useEffect(()=>{fe.current=L},[L]),x.useEffect(()=>{ke.current=w},[w]),x.useEffect(()=>{I.current=n},[n]),x.useEffect(()=>{Me.current=B},[B]),x.useEffect(()=>{var q;(q=l.current)==null||q.focus()},[]);const we=s==="connected",Ke=s!=="connected"&&s!=="connecting",nr=we&&o?o:e;x.useEffect(()=>{if(!k||A.current||!nr)return;const q=c.current,te=a.current;if(!q||!te)return;const Z=()=>{const ve=te.clientWidth,Re=te.clientHeight,Le=q.naturalWidth,pt=q.naturalHeight;if(!Le||!pt||!ve||!Re)return;const z=Math.min(ve/Le,Re/pt),H=Math.max(ve/Le,Re/pt)/z;H>1.01&&(C(H),U(H),J.current=H),A.current=!0};q.complete&&q.naturalWidth?Z():q.addEventListener("load",Z,{once:!0})},[nr,k]);const Qe=.5;x.useEffect(()=>{O<=Qe&&($(0),ee(0))},[O,Qe]);const ir=(q,te,Z)=>{if(Z<=Qe)return{x:0,y:0};const ve=(Z-1)/(2*Z)*100,Re=(Z-1)/(2*Z)*100;return{x:Math.max(-ve,Math.min(ve,q)),y:Math.max(-Re,Math.min(Re,te))}};x.useEffect(()=>{if(!d||!Ke)return;let q=null;const te=()=>{q&&clearInterval(q),!document.hidden&&(q=setInterval(()=>{var ve;if(!T.current){const Re=((ve=l.current)==null?void 0:ve.clientWidth)||0,Le=Math.max(400,Math.ceil(Re/100)*100);X.current(Le)}},f))},Z=()=>{document.hidden?(q&&clearInterval(q),q=null):te()};return te(),document.addEventListener("visibilitychange",Z),()=>{q&&clearInterval(q),document.removeEventListener("visibilitychange",Z)}},[d,Ke,f]);const sr=(q,te)=>{if(!c.current)return null;const Z=c.current.getBoundingClientRect();return!Z.width||!Z.height?null:{nx:Math.max(0,Math.min(1,(q-Z.left)/Z.width)),ny:Math.max(0,Math.min(1,(te-Z.top)/Z.height))}},$t=(q,te,Z)=>{const ve=a.current;if(!ve)return;const Re=ve.getBoundingClientRect(),Le=++R.current;S(pt=>[...pt,{id:Le,x:q-Re.left,y:te-Re.top,type:Z}]),setTimeout(()=>S(pt=>pt.filter(z=>z.id!==Le)),600)},Y=(q,te,Z)=>{const ve=c.current,Re=a.current;if(!ve||!Re)return;const Le=ve.getBoundingClientRect(),pt=Re.getBoundingClientRect(),z=ve.naturalWidth||Le.width,W=ve.naturalHeight||Le.height,H=z/W,V=Le.width/Le.height;let ce,le,Ee,Ue;H>V?(ce=Le.width,le=Le.width/H,Ee=0,Ue=(Le.height-le)/2):(le=Le.height,ce=Le.height*H,Ee=(Le.width-ce)/2,Ue=0);const He=Le.left-pt.left+Ee+ce*q,Et=Le.top-pt.top+Ue+le*te,Cr=++R.current;S(Nt=>[...Nt,{id:Cr,x:He,y:Et,type:Z}]),setTimeout(()=>S(Nt=>Nt.filter(Rn=>Rn.id!==Cr)),600)},se=async q=>{var Z;const te=sr(q.clientX,q.clientY);if(te){_(`Click: ${Math.round(te.nx*100)}%, ${Math.round(te.ny*100)}%`),$t(q.clientX,q.clientY,"left"),(Z=l.current)==null||Z.focus();try{const ve=await n("input_click",{nx:te.nx,ny:te.ny});ve!=null&&ve.success||i(`❌ Click failed: ${ve==null?void 0:ve.error}`)}catch(ve){i(`❌ Click error: ${ve.message||ve}`)}}},ye=async(q,te,Z,ve=0)=>{try{await n("input_key",{type:Z?"char":"keyDown",key:q,code:te,text:Z?q:void 0,unmodifiedText:Z?q:void 0,modifiers:ve})}catch(Re){i(`❌ Key error: ${Re.message||Re}`)}},K=async q=>{if(q.target.tagName==="INPUT")return;["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Backspace","Tab","Enter","Escape"].includes(q.key)&&q.preventDefault();let Z=0;q.altKey&&(Z|=1),q.ctrlKey&&(Z|=2),q.metaKey&&(Z|=4),q.shiftKey&&(Z|=8),_(`Key: ${q.key}`),await ye(q.key,q.code,q.key.length===1,Z)},oe=async q=>{if(q.key==="Enter"){if(q.nativeEvent.isComposing)return;if(b){const te=b;g(""),_(`IME Sent: ${te}`);try{const Z=await n("input_type",{text:te});Z!=null&&Z.success||i(`❌ IME error: ${Z==null?void 0:Z.error}`)}catch(Z){i(`❌ IME error: ${Z.message}`)}}else _("Key: Enter"),await ye("Enter","Enter",!1)}};x.useEffect(()=>{const q=l.current;if(!q)return;const te=Z=>{var ve;if((ve=c.current)!=null&&ve.contains(Z.target)){Z.preventDefault();const Re=Date.now();if(Re-ne.current<40)return;ne.current=Re;const Le=sr(Z.clientX,Z.clientY);if(!Le)return;_(`Scroll: ${Math.round(Z.deltaY)}`),n("input_wheel",{nx:Le.nx,ny:Le.ny,deltaX:Math.round(Z.deltaX),deltaY:Math.round(Z.deltaY)}).catch(()=>{})}};return q.addEventListener("wheel",te,{passive:!1}),()=>q.removeEventListener("wheel",te)},[n]);const[xe,Oe]=x.useState(null),Se=x.useRef(null);return x.useEffect(()=>{if(B==="mouse"&&!Se.current){const q={nx:.5,ny:.5};Se.current=q,Oe(q)}},[B]),x.useEffect(()=>{const q=l.current;if(!q)return;const te=z=>{if(!c.current)return null;const W=c.current.getBoundingClientRect();return!W.width||!W.height?null:{nx:Math.max(0,Math.min(1,(z.clientX-W.left)/W.width)),ny:Math.max(0,Math.min(1,(z.clientY-W.top)/W.height))}},Z=(z,W)=>{if(!c.current)return{dnx:0,dny:0};const H=c.current,V=H.getBoundingClientRect(),ce=H.naturalWidth||V.width,le=H.naturalHeight||V.height,Ee=ce/le,Ue=V.width/V.height;let He,Et;return Ee>Ue?(He=V.width,Et=V.width/Ee):(Et=V.height,He=V.height*Ee),{dnx:z/He,dny:W/Et}},ve=(z,W,H)=>{if(H<=1.05)return;const V=-(z-.5)*100,ce=-(W-.5)*100,le=ir(V,ce,H);(Math.abs(le.x-fe.current)>.1||Math.abs(le.y-ke.current)>.1)&&($(le.x),ee(le.y),fe.current=le.x,ke.current=le.y)},Re=z=>{const W=a.current;if(W&&z.target instanceof Node&&W.contains(z.target))z.preventDefault();else return;if(z.touches.length===1){const H=z.touches[0];F.current={x:H.clientX,y:H.clientY,time:Date.now()},G.current={x:H.clientX,y:H.clientY},Te.current||(he.current=!1),me.current=setTimeout(()=>{if(!he.current&&!Te.current)if(he.current=!0,Me.current==="mouse"){const V=Se.current||{nx:.5,ny:.5};_("Right Click"),Y(V.nx,V.ny,"right"),I.current("input_click",{...V,button:"right"}).catch(()=>{})}else{const V=te(H);V&&(_("Right Click"),Y(V.nx,V.ny,"right"),I.current("input_click",{...V,button:"right"}).catch(()=>{}))}},500)}else if(z.touches.length===2){clearTimeout(me.current),he.current=!0,Te.current=!0;const H=z.touches[1].clientX-z.touches[0].clientX,V=z.touches[1].clientY-z.touches[0].clientY;Pe.current=Math.sqrt(H*H+V*V),Ce.current=J.current,de.current={x:(z.touches[0].clientX+z.touches[1].clientX)/2,y:(z.touches[0].clientY+z.touches[1].clientY)/2}}},Le=z=>{const W=a.current;if(W&&z.target instanceof Node&&W.contains(z.target)&&z.preventDefault(),z.touches.length===1&&G.current){const H=z.touches[0],V=H.clientX-G.current.x,ce=H.clientY-G.current.y;if(!he.current&&F.current){const le=H.clientX-F.current.x,Ee=H.clientY-F.current.y;Math.sqrt(le*le+Ee*Ee)>8&&(he.current=!0,clearTimeout(me.current))}if(he.current)if(Me.current==="mouse"){const le=Z(V,ce),Ee=Se.current||{nx:.5,ny:.5},Ue=Math.max(0,Math.min(1,Ee.nx+le.dnx)),He=Math.max(0,Math.min(1,Ee.ny+le.dny));Se.current={nx:Ue,ny:He},Oe({nx:Ue,ny:He}),_(`Cursor: ${Math.round(Ue*100)}%, ${Math.round(He*100)}%`),ve(Ue,He,J.current);const Et=Date.now();Et-ne.current>=30&&(ne.current=Et,I.current("input_mouseMoved",{nx:Ue,ny:He}).catch(()=>{}))}else if(J.current>1){const le=a.current;if(le){const Ee=le.clientWidth,Ue=le.clientHeight,He=fe.current+V/Ee*100,Et=ke.current+ce/Ue*100,Cr=ir(He,Et,J.current);$(Cr.x),ee(Cr.y),fe.current=Cr.x,ke.current=Cr.y}}else{const le=te(H);if(le){const Ee=Date.now();Ee-ne.current>=40&&(ne.current=Ee,_("Scroll"),I.current("input_wheel",{nx:le.nx,ny:le.ny,deltaX:Math.round(-V*2.5),deltaY:Math.round(-ce*2.5)}).catch(()=>{}))}}G.current={x:H.clientX,y:H.clientY}}else if(z.touches.length===2&&Pe.current!==null){const H=z.touches[1].clientX-z.touches[0].clientX,V=z.touches[1].clientY-z.touches[0].clientY,le=Math.sqrt(H*H+V*V)/Pe.current,Ee=(z.touches[0].clientX+z.touches[1].clientX)/2,Ue=(z.touches[0].clientY+z.touches[1].clientY)/2,He=Ee-de.current.x,Et=Ue-de.current.y,Cr=Math.abs(le-1)>.03;if(Me.current==="mouse"){if(Cr){const Nt=Math.max(Qe,Math.min(5,Ce.current*le));U(Nt),J.current=Nt}else if(Math.abs(He)>2||Math.abs(Et)>2){const Nt=Se.current||{nx:.5,ny:.5},Rn=Date.now();Rn-ne.current>=30&&(ne.current=Rn,_("Scroll"),I.current("input_wheel",{nx:Nt.nx,ny:Nt.ny,deltaX:Math.round(-He*3),deltaY:Math.round(-Et*3)}).catch(()=>{}))}}else{const Nt=Math.max(Qe,Math.min(5,Ce.current*le));U(Nt),J.current=Nt;const Rn=a.current;if(Rn&&Nt>1){const tb=Rn.clientWidth,rb=Rn.clientHeight,nb=fe.current+He/tb*100,ib=ke.current+Et/rb*100,ml=ir(nb,ib,Nt);$(ml.x),ee(ml.y),fe.current=ml.x,ke.current=ml.y}}de.current={x:Ee,y:Ue}}},pt=z=>{var W;if(clearTimeout(me.current),Pe.current=null,z.touches.length===1&&Te.current){const H=z.touches[0];F.current={x:H.clientX,y:H.clientY,time:Date.now()},G.current={x:H.clientX,y:H.clientY},he.current=!0;return}if(z.touches.length===0){if(Te.current){Te.current=!1,he.current=!1;return}if(z.changedTouches.length===1&&!he.current){const H=z.changedTouches[0],V=Date.now(),ce=V-(((W=F.current)==null?void 0:W.time)||0);if(ce<60||ce>400){he.current=!1;return}if(F.current){const le=H.clientX-F.current.x,Ee=H.clientY-F.current.y;if(Math.sqrt(le*le+Ee*Ee)>12){he.current=!1;return}}if(Me.current==="mouse"){const le=Se.current||te(H);le&&(_(`Click: ${Math.round(le.nx*100)}%, ${Math.round(le.ny*100)}%`),Y(le.nx,le.ny,"left"),I.current("input_click",{...le}).catch(()=>{}))}else{const le=te(H);if(!le)return;V-je.current<300?(_("Double tap"),Y(le.nx,le.ny,"double"),I.current("input_click",{...le,clickCount:2}).catch(()=>{}),je.current=0):(_(`Tap: ${Math.round(le.nx*100)}%, ${Math.round(le.ny*100)}%`),Y(le.nx,le.ny,"left"),I.current("input_click",{...le}).catch(()=>{}),je.current=V)}}he.current=!1}};return q.addEventListener("touchstart",Re,{passive:!1}),q.addEventListener("touchmove",Le,{passive:!1}),q.addEventListener("touchend",pt,{passive:!1}),()=>{q.removeEventListener("touchstart",Re),q.removeEventListener("touchmove",Le),q.removeEventListener("touchend",pt),clearTimeout(me.current)}},[]),u.jsxs("div",{ref:l,className:"flex-1 flex flex-col bg-black relative overflow-hidden outline-none touch-none",onKeyDown:K,onContextMenu:q=>q.preventDefault(),onFocus:()=>v(!0),onBlur:()=>v(!1),tabIndex:0,children:[u.jsxs("div",{ref:a,className:"flex-1 relative overflow-hidden flex items-center justify-center bg-black",children:[nr?u.jsx("img",{ref:c,src:nr,alt:"Remote View",style:{display:"block",maxWidth:"100%",maxHeight:"100%",width:"auto",height:"auto",transform:`scale(${O}) translate(${L}%, ${w}%)`,transformOrigin:"center center",cursor:B==="mouse"?"default":"crosshair",userSelect:"none",WebkitTouchCallout:"none"},onClick:se,onContextMenu:q=>q.preventDefault(),onDragStart:q=>q.preventDefault()}):u.jsxs("div",{className:"text-slate-800 text-center",children:[u.jsx("div",{className:"text-5xl mb-3",children:"🌑"}),u.jsx("div",{className:"text-[13px] font-semibold",children:"Connecting to Host..."})]}),B==="mouse"&&xe&&nr&&c.current&&(()=>{var He;const q=c.current,te=q.getBoundingClientRect(),Z=(He=a.current)==null?void 0:He.getBoundingClientRect();if(!Z)return null;const ve=q.naturalWidth||te.width,Re=q.naturalHeight||te.height,Le=ve/Re,pt=te.width/te.height;let z,W,H,V;Le>pt?(z=te.width,W=te.width/Le,H=0,V=(te.height-W)/2):(W=te.height,z=te.height*Le,H=(te.width-z)/2,V=0);const ce=te.left-Z.left+H+z*xe.nx,le=te.top-Z.top+V+W*xe.ny,Ee=Math.max(8,Math.min(Z.width-8,ce)),Ue=Math.max(8,Math.min(Z.height-8,le));return u.jsxs("div",{style:{position:"absolute",left:Ee-8,top:Ue-8,width:16,height:16,pointerEvents:"none",zIndex:100},children:[u.jsx("div",{style:{position:"absolute",left:7,top:0,width:2,height:16,background:"rgba(59,130,246,0.8)"}}),u.jsx("div",{style:{position:"absolute",left:0,top:7,width:16,height:2,background:"rgba(59,130,246,0.8)"}}),u.jsx("div",{style:{position:"absolute",left:5,top:5,width:6,height:6,borderRadius:"50%",background:"#3b82f6",boxShadow:"0 0 8px rgba(59,130,246,0.6)"}})]})})(),y.map(q=>{const Z={left:"59,130,246",right:"239,68,68",double:"34,197,94"}[q.type];return u.jsxs("div",{style:{position:"absolute",left:q.x,top:q.y,pointerEvents:"none",zIndex:200,transform:"translate(-50%, -50%)"},children:[u.jsx("div",{style:{width:40,height:40,borderRadius:"50%",border:`2px solid rgba(${Z}, 0.8)`,animation:"click-ripple-ring 0.5s ease-out forwards",position:"absolute",left:-20,top:-20}}),u.jsx("div",{style:{width:8,height:8,borderRadius:"50%",background:`rgba(${Z}, 0.9)`,boxShadow:`0 0 12px rgba(${Z}, 0.6)`,animation:"click-ripple-dot 0.4s ease-out forwards",position:"absolute",left:-4,top:-4}})]},q.id)})]}),u.jsxs("div",{onTouchStart:q=>q.stopPropagation(),className:"absolute bottom-0 left-0 right-0 z-[1000] flex items-center justify-center gap-1.5 px-3 py-2 bg-black/75 backdrop-blur-xl border-t border-white/[0.08] touch-none",children:[u.jsxs("div",{onClick:()=>{j(q=>{const te=q==="touch"?"mouse":"touch";if(te==="mouse"&&!Se.current){const Z={nx:.5,ny:.5};Se.current=Z,Oe(Z)}return te})},className:`h-8 px-2.5 rounded-lg flex items-center gap-[5px] cursor-pointer ${B==="mouse"?"bg-blue-500/25 border border-blue-500/40":"bg-white/[0.08] border border-white/10"}`,children:[u.jsx("span",{className:"text-sm",children:B==="mouse"?"🖱️":"👆"}),u.jsx("span",{className:`text-[10px] font-bold ${B==="mouse"?"text-blue-400":"text-slate-400"}`,children:B==="mouse"?"Mouse":"Touch"})]}),u.jsxs("div",{className:"relative",children:[u.jsx("div",{onClick:()=>{D(!N),P(!1)},className:`w-8 h-8 rounded-lg flex items-center justify-center cursor-pointer ${N?"bg-emerald-500/25 border border-emerald-500/40":"bg-white/[0.08] border border-white/10"}`,children:u.jsx("span",{className:"text-sm",children:"⌨️"})}),N&&u.jsx("div",{className:"absolute bottom-10 left-1/2 -translate-x-1/2 w-[220px] bg-neutral-950/[0.98] backdrop-blur-[30px] rounded-xl border border-white/20 p-[10px_12px] shadow-[0_10px_30px_rgba(0,0,0,0.8)] flex flex-col gap-2 z-[2000]",style:{animation:"slideUp 0.15s ease-out"},children:u.jsx("input",{type:"text",placeholder:"Type & Enter...",value:b,autoFocus:!0,onTouchStart:q=>q.stopPropagation(),onChange:q=>g(q.target.value),onKeyDown:oe,className:"w-full bg-black/60 border border-white/15 rounded-lg px-2.5 py-2 text-white text-[13px] outline-none"})})]}),u.jsx("div",{className:"relative",children:u.jsx("div",{onClick:()=>{P(!E),D(!1)},className:`w-8 h-8 rounded-lg flex items-center justify-center cursor-pointer ${E?"bg-blue-500/25 border border-blue-500/40":"bg-white/[0.08] border border-white/10"}`,children:u.jsx("span",{className:"text-sm",children:"⚙️"})})}),u.jsx("div",{className:"w-px h-[18px] bg-white/10"}),u.jsxs("div",{className:"flex items-center gap-1.5",children:[u.jsxs("div",{className:"flex items-center gap-0.5 px-1.5 py-0.5 rounded-md",style:{background:we?"rgba(16,185,129,0.12)":"rgba(251,191,36,0.12)"},children:[u.jsx("div",{className:"w-1 h-1 rounded-full",style:{background:we?"#10b981":"#fbbf24"}}),u.jsx("span",{className:"text-[8px] font-extrabold",style:{color:we?"#10b981":"#fbbf24"},children:we?"Connected":"WS"})]}),O>1&&u.jsxs("span",{className:"text-[8px] font-bold text-indigo-400",children:[Math.round(O*100),"%"]}),m&&u.jsx("span",{className:"text-[8px] text-neutral-500 font-semibold max-w-[100px] overflow-hidden text-ellipsis whitespace-nowrap",children:m})]})]}),E&&u.jsxs("div",{onTouchStart:q=>q.stopPropagation(),style:{position:"absolute",bottom:56,left:"50%",transform:"translateX(-50%)",width:220,background:"rgba(23, 23, 23, 0.95)",backdropFilter:"blur(25px)",borderRadius:14,border:"1px solid rgba(255,255,255,0.1)",padding:14,boxShadow:"0 12px 40px rgba(0,0,0,0.6)",display:"flex",flexDirection:"column",gap:12,zIndex:1001,touchAction:"none",animation:"slideUpSidebar 0.15s ease-out"},children:[u.jsx("div",{style:{fontSize:9,fontWeight:900,color:"#3b82f6",letterSpacing:1.5},children:"SETTINGS"}),u.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[u.jsxs("div",{style:{fontSize:10,color:"#888",fontWeight:700},children:["ZOOM: ",O<=(k?M:1)+.01?k?"FILL":"FIT":`${Math.round(O*100)}%`]}),u.jsxs("div",{style:{display:"flex",gap:4},children:[u.jsx("button",{onClick:q=>{q.stopPropagation(),U(te=>Math.max(.5,te-.25))},style:{flex:1,background:"rgba(255,255,255,0.1)",color:"#fff",border:"none",padding:"6px",borderRadius:6,fontSize:12,fontWeight:800,cursor:"pointer"},children:"−"}),u.jsx("button",{onClick:q=>{q.stopPropagation();const te=k?M:1;U(te),J.current=te,$(0),ee(0)},style:{flex:1,background:"rgba(255,255,255,0.1)",color:"#fff",border:"none",padding:"6px",borderRadius:6,fontSize:9,fontWeight:800,cursor:"pointer"},children:k?"FILL":"FIT"}),u.jsx("button",{onClick:q=>{q.stopPropagation(),U(te=>Math.min(5,te+.25))},style:{flex:1,background:"rgba(255,255,255,0.1)",color:"#fff",border:"none",padding:"6px",borderRadius:6,fontSize:12,fontWeight:800,cursor:"pointer"},children:"+"})]})]}),u.jsx("button",{onClick:q=>{var ve;q.stopPropagation();const te=((ve=l.current)==null?void 0:ve.clientWidth)||0,Z=te>0?Math.max(400,Math.ceil(te/100)*100):void 0;r(Z)},style:{width:"100%",background:"#3b82f6",color:"#fff",border:"none",padding:"8px",borderRadius:6,fontSize:11,fontWeight:800,cursor:"pointer"},children:"FORCE SYNC"}),u.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",background:"rgba(255,255,255,0.05)",padding:"6px 10px",borderRadius:6},children:[u.jsx("span",{style:{fontSize:10,color:"#888",fontWeight:700},children:"AUTO REF."}),u.jsx("input",{type:"checkbox",checked:d,onChange:q=>h(q.target.checked)})]}),u.jsxs("select",{value:f,onChange:q=>p(Number(q.target.value)),style:{background:"rgba(255,255,255,0.05)",color:"#fff",border:"none",borderRadius:6,padding:"6px",fontSize:10,fontWeight:600,outline:"none"},children:[u.jsx("option",{value:500,children:"0.5s Interval"}),u.jsx("option",{value:1e3,children:"1.0s Interval"}),u.jsx("option",{value:2e3,children:"2.0s Interval"}),u.jsx("option",{value:4e3,children:"4.0s Interval"})]})]}),u.jsx("style",{children:`
|
|
153
|
+
*/var nL=class{constructor(e,t,r,n={}){this._terminal=e,this._regex=t,this._handler=r,this._options=n}provideLinks(e,t){let r=sL.computeLink(e,this._regex,this._terminal,this._handler);t(this._addCallbacks(r))}_addCallbacks(e){return e.map(t=>(t.leave=this._options.leave,t.hover=(r,n)=>{if(this._options.hover){let{range:i}=t;this._options.hover(r,n,i)}},t))}};function iL(e){try{let t=new URL(e),r=t.password&&t.username?`${t.protocol}//${t.username}:${t.password}@${t.host}`:t.username?`${t.protocol}//${t.username}@${t.host}`:`${t.protocol}//${t.host}`;return e.toLocaleLowerCase().startsWith(r.toLocaleLowerCase())}catch{return!1}}var sL=class pa{static computeLink(t,r,n,i){let s=new RegExp(r.source,(r.flags||"")+"g"),[o,l]=pa._getWindowedLineStrings(t-1,n),a=o.join(""),c,d=[];for(;c=s.exec(a);){let h=c[0];if(!iL(h))continue;let[f,p]=pa._mapStrIdx(n,l,0,c.index),[m,_]=pa._mapStrIdx(n,f,p,h.length);if(f===-1||p===-1||m===-1||_===-1)continue;let b={start:{x:p+1,y:f+1},end:{x:_,y:m+1}};d.push({range:b,text:h,activate:i})}return d}static _getWindowedLineStrings(t,r){let n,i=t,s=t,o=0,l="",a=[];if(n=r.buffer.active.getLine(t)){let c=n.translateToString(!0);if(n.isWrapped&&c[0]!==" "){for(o=0;(n=r.buffer.active.getLine(--i))&&o<2048&&(l=n.translateToString(!0),o+=l.length,a.push(l),!(!n.isWrapped||l.indexOf(" ")!==-1)););a.reverse()}for(a.push(c),o=0;(n=r.buffer.active.getLine(++s))&&n.isWrapped&&o<2048&&(l=n.translateToString(!0),o+=l.length,a.push(l),l.indexOf(" ")===-1););}return[a,i]}static _mapStrIdx(t,r,n,i){let s=t.buffer.active,o=s.getNullCell(),l=n;for(;i;){let a=s.getLine(r);if(!a)return[-1,-1];for(let c=l;c<a.length;++c){a.getCell(c,o);let d=o.getChars();if(o.getWidth()&&(i-=d.length||1,c===a.length-1&&d==="")){let h=s.getLine(r+1);h&&h.isWrapped&&(h.getCell(0,o),o.getWidth()===2&&(i+=1))}if(i<0)return[r,c]}r++,l=0}return[r,l]}},oL=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function lL(e,t){let r=window.open();if(r){try{r.opener=null}catch{}r.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}var aL=class{constructor(e=lL,t={}){this._handler=e,this._options=t}activate(e){this._terminal=e;let t=this._options,r=t.urlRegex||oL;this._linkProvider=this._terminal.registerLinkProvider(new nL(this._terminal,r,this._handler,t))}dispose(){var e;(e=this._linkProvider)==null||e.dispose()}};const E_={background:"#0f1117",foreground:"#cdd6f4",cursor:"#f38ba8",cursorAccent:"#0f1117",selectionBackground:"rgba(166, 227, 161, 0.3)",selectionForeground:"#cdd6f4",black:"#45475a",red:"#f38ba8",green:"#a6e3a1",yellow:"#f9e2af",blue:"#89b4fa",magenta:"#cba6f7",cyan:"#94e2d5",white:"#bac2de",brightBlack:"#585b70",brightRed:"#f38ba8",brightGreen:"#a6e3a1",brightYellow:"#f9e2af",brightBlue:"#89b4fa",brightMagenta:"#cba6f7",brightCyan:"#94e2d5",brightWhite:"#a6adc8"},R1=x.forwardRef(({onInput:e,onResize:t,fontSize:r=13},n)=>{const i=x.useRef(null),s=x.useRef(null),o=x.useRef(null),[l,a]=x.useState(!1);return x.useImperativeHandle(n,()=>({write:c=>{var d;(d=s.current)==null||d.write(c)},clear:()=>{var c;(c=s.current)==null||c.clear()},fit:()=>{var c;try{(c=o.current)==null||c.fit(),s.current&&(t==null||t(s.current.cols,s.current.rows))}catch{}},bumpResize:()=>{var c;try{(c=o.current)==null||c.fit();const d=s.current;if(!d)return;const h=d.cols,f=d.rows;t==null||t(h+5,f),setTimeout(()=>{t==null||t(h,f)},100)}catch{}}})),x.useEffect(()=>{if(!i.current)return;const c=new ZM({cursorBlink:!0,cursorStyle:"bar",fontSize:r,fontFamily:"'JetBrains Mono', 'Fira Code', 'SF Mono', 'Menlo', monospace",fontWeight:"400",letterSpacing:0,lineHeight:1.2,theme:E_,allowTransparency:!0,scrollback:5e3,convertEol:!1}),d=new rL,h=new aL;c.loadAddon(d),c.loadAddon(h),c.open(i.current),requestAnimationFrame(()=>{d.fit(),t==null||t(c.cols,c.rows),a(!0)});const f=c.onData(m=>{e(m)}),p=new ResizeObserver(()=>{requestAnimationFrame(()=>{try{d.fit(),t==null||t(c.cols,c.rows)}catch{}})});return p.observe(i.current),s.current=c,o.current=d,()=>{f.dispose(),p.disconnect(),c.dispose(),s.current=null,o.current=null}},[r]),u.jsx("div",{ref:i,className:"w-full h-full rounded-lg overflow-hidden transition-opacity duration-200",style:{background:E_.background,opacity:l?1:0}})});R1.displayName="CliTerminal";function Hl({label:e,value:t,sub:r,icon:n}){return u.jsxs("div",{className:"px-4 py-3.5 rounded-xl bg-bg-secondary border border-border-subtle",children:[u.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[u.jsx("span",{className:"text-base flex items-center",children:n}),u.jsx("span",{className:"text-[10px] text-text-muted uppercase tracking-wide font-semibold",children:e})]}),u.jsx("div",{className:"text-[22px] font-bold text-text-primary tracking-tight",children:t}),r&&u.jsx("div",{className:"text-[11px] text-text-muted mt-0.5",children:r})]})}function N_({value:e,max:t,label:r,color:n="#8b5cf6",detail:i,compact:s=!1}){const o=t>0?Math.min(Math.round(e/t*100),100):0,l=o>85?"#ef4444":o>60?"#f59e0b":n;return s?u.jsxs("div",{className:"flex-1",children:[u.jsxs("div",{className:"flex justify-between mb-0.5",children:[u.jsx("span",{className:"text-[9px] text-text-muted uppercase tracking-wide font-semibold",children:r}),u.jsxs("span",{className:"text-[10px] text-text-secondary font-semibold",children:[o,"%"]})]}),u.jsx("div",{className:"h-1 bg-white/[0.04] rounded-sm overflow-hidden",children:u.jsx("div",{className:"h-full rounded-sm transition-[width] duration-500",style:{width:`${o}%`,background:l}})})]}):u.jsxs("div",{className:"flex-1",children:[u.jsxs("div",{className:"flex justify-between mb-1.5",children:[u.jsx("span",{className:"text-[11px] text-text-secondary font-medium",children:r}),u.jsxs("span",{className:"text-[13px] text-text-primary font-bold",children:[o,"%"]})]}),u.jsx("div",{className:"h-1.5 bg-white/[0.04] rounded-sm overflow-hidden",children:u.jsx("div",{className:"h-full rounded-sm transition-[width] duration-[600ms]",style:{width:`${o}%`,background:`linear-gradient(90deg, ${l}, ${l}cc)`}})}),i&&u.jsx("div",{className:"text-[10px] text-text-muted mt-0.5",children:i})]})}function cL({screenshot:e,isCapturing:t,onRefresh:r,onAction:n,addLog:i,connState:s,connScreenshot:o}){const l=x.useRef(null),a=x.useRef(null),c=x.useRef(null),[d,h]=x.useState(!0),[f,p]=x.useState(2e3),[m,_]=x.useState(null),[b,g]=x.useState(""),[,v]=x.useState(!1),[y,S]=x.useState([]),R=x.useRef(0),[E,P]=x.useState(!1),[N,D]=x.useState(!1),k=typeof window<"u"&&window.matchMedia("(max-width: 768px)").matches,[B,j]=x.useState(k?"mouse":"touch"),[M,C]=x.useState(1),A=x.useRef(!1),[O,U]=x.useState(1),[L,$]=x.useState(0),[w,ee]=x.useState(0),ne=x.useRef(0),T=x.useRef(t),X=x.useRef(r),I=x.useRef(n),F=x.useRef(null),G=x.useRef(null),he=x.useRef(!1),me=x.useRef(null),je=x.useRef(0),Pe=x.useRef(null),Ce=x.useRef(1),de=x.useRef({x:0,y:0}),Te=x.useRef(!1),J=x.useRef(O),fe=x.useRef(L),ke=x.useRef(w),Me=x.useRef(B);x.useEffect(()=>{T.current=t},[t]),x.useEffect(()=>{X.current=r},[r]),x.useEffect(()=>{J.current=O},[O]),x.useEffect(()=>{fe.current=L},[L]),x.useEffect(()=>{ke.current=w},[w]),x.useEffect(()=>{I.current=n},[n]),x.useEffect(()=>{Me.current=B},[B]),x.useEffect(()=>{var q;(q=l.current)==null||q.focus()},[]);const we=s==="connected",Ke=s!=="connected"&&s!=="connecting",nr=we&&o?o:e;x.useEffect(()=>{if(!k||A.current||!nr)return;const q=c.current,te=a.current;if(!q||!te)return;const Z=()=>{const ve=te.clientWidth,Re=te.clientHeight,Le=q.naturalWidth,pt=q.naturalHeight;if(!Le||!pt||!ve||!Re)return;const z=Math.min(ve/Le,Re/pt),H=Math.max(ve/Le,Re/pt)/z;H>1.01&&(C(H),U(H),J.current=H),A.current=!0};q.complete&&q.naturalWidth?Z():q.addEventListener("load",Z,{once:!0})},[nr,k]);const Qe=.5;x.useEffect(()=>{O<=Qe&&($(0),ee(0))},[O,Qe]);const ir=(q,te,Z)=>{if(Z<=Qe)return{x:0,y:0};const ve=(Z-1)/(2*Z)*100,Re=(Z-1)/(2*Z)*100;return{x:Math.max(-ve,Math.min(ve,q)),y:Math.max(-Re,Math.min(Re,te))}};x.useEffect(()=>{if(!d||!Ke)return;let q=null;const te=()=>{q&&clearInterval(q),!document.hidden&&(q=setInterval(()=>{var ve;if(!T.current){const Re=((ve=l.current)==null?void 0:ve.clientWidth)||0,Le=Math.max(400,Math.ceil(Re/100)*100);X.current(Le)}},f))},Z=()=>{document.hidden?(q&&clearInterval(q),q=null):te()};return te(),document.addEventListener("visibilitychange",Z),()=>{q&&clearInterval(q),document.removeEventListener("visibilitychange",Z)}},[d,Ke,f]);const sr=(q,te)=>{if(!c.current)return null;const Z=c.current.getBoundingClientRect();return!Z.width||!Z.height?null:{nx:Math.max(0,Math.min(1,(q-Z.left)/Z.width)),ny:Math.max(0,Math.min(1,(te-Z.top)/Z.height))}},$t=(q,te,Z)=>{const ve=a.current;if(!ve)return;const Re=ve.getBoundingClientRect(),Le=++R.current;S(pt=>[...pt,{id:Le,x:q-Re.left,y:te-Re.top,type:Z}]),setTimeout(()=>S(pt=>pt.filter(z=>z.id!==Le)),600)},Y=(q,te,Z)=>{const ve=c.current,Re=a.current;if(!ve||!Re)return;const Le=ve.getBoundingClientRect(),pt=Re.getBoundingClientRect(),z=ve.naturalWidth||Le.width,W=ve.naturalHeight||Le.height,H=z/W,V=Le.width/Le.height;let ce,oe,Ee,Ue;H>V?(ce=Le.width,oe=Le.width/H,Ee=0,Ue=(Le.height-oe)/2):(oe=Le.height,ce=Le.height*H,Ee=(Le.width-ce)/2,Ue=0);const He=Le.left-pt.left+Ee+ce*q,Et=Le.top-pt.top+Ue+oe*te,Cr=++R.current;S(Nt=>[...Nt,{id:Cr,x:He,y:Et,type:Z}]),setTimeout(()=>S(Nt=>Nt.filter(Rn=>Rn.id!==Cr)),600)},se=async q=>{var Z;const te=sr(q.clientX,q.clientY);if(te){_(`Click: ${Math.round(te.nx*100)}%, ${Math.round(te.ny*100)}%`),$t(q.clientX,q.clientY,"left"),(Z=l.current)==null||Z.focus();try{const ve=await n("input_click",{nx:te.nx,ny:te.ny});ve!=null&&ve.success||i(`❌ Click failed: ${ve==null?void 0:ve.error}`)}catch(ve){i(`❌ Click error: ${ve.message||ve}`)}}},ye=async(q,te,Z,ve=0)=>{try{await n("input_key",{type:Z?"char":"keyDown",key:q,code:te,text:Z?q:void 0,unmodifiedText:Z?q:void 0,modifiers:ve})}catch(Re){i(`❌ Key error: ${Re.message||Re}`)}},K=async q=>{if(q.target.tagName==="INPUT")return;["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Backspace","Tab","Enter","Escape"].includes(q.key)&&q.preventDefault();let Z=0;q.altKey&&(Z|=1),q.ctrlKey&&(Z|=2),q.metaKey&&(Z|=4),q.shiftKey&&(Z|=8),_(`Key: ${q.key}`),await ye(q.key,q.code,q.key.length===1,Z)},ae=async q=>{if(q.key==="Enter"){if(q.nativeEvent.isComposing)return;if(b){const te=b;g(""),_(`IME Sent: ${te}`);try{const Z=await n("input_type",{text:te});Z!=null&&Z.success||i(`❌ IME error: ${Z==null?void 0:Z.error}`)}catch(Z){i(`❌ IME error: ${Z.message}`)}}else _("Key: Enter"),await ye("Enter","Enter",!1)}};x.useEffect(()=>{const q=l.current;if(!q)return;const te=Z=>{var ve;if((ve=c.current)!=null&&ve.contains(Z.target)){Z.preventDefault();const Re=Date.now();if(Re-ne.current<40)return;ne.current=Re;const Le=sr(Z.clientX,Z.clientY);if(!Le)return;_(`Scroll: ${Math.round(Z.deltaY)}`),n("input_wheel",{nx:Le.nx,ny:Le.ny,deltaX:Math.round(Z.deltaX),deltaY:Math.round(Z.deltaY)}).catch(()=>{})}};return q.addEventListener("wheel",te,{passive:!1}),()=>q.removeEventListener("wheel",te)},[n]);const[xe,Oe]=x.useState(null),Se=x.useRef(null);return x.useEffect(()=>{if(B==="mouse"&&!Se.current){const q={nx:.5,ny:.5};Se.current=q,Oe(q)}},[B]),x.useEffect(()=>{const q=l.current;if(!q)return;const te=z=>{if(!c.current)return null;const W=c.current.getBoundingClientRect();return!W.width||!W.height?null:{nx:Math.max(0,Math.min(1,(z.clientX-W.left)/W.width)),ny:Math.max(0,Math.min(1,(z.clientY-W.top)/W.height))}},Z=(z,W)=>{if(!c.current)return{dnx:0,dny:0};const H=c.current,V=H.getBoundingClientRect(),ce=H.naturalWidth||V.width,oe=H.naturalHeight||V.height,Ee=ce/oe,Ue=V.width/V.height;let He,Et;return Ee>Ue?(He=V.width,Et=V.width/Ee):(Et=V.height,He=V.height*Ee),{dnx:z/He,dny:W/Et}},ve=(z,W,H)=>{if(H<=1.05)return;const V=-(z-.5)*100,ce=-(W-.5)*100,oe=ir(V,ce,H);(Math.abs(oe.x-fe.current)>.1||Math.abs(oe.y-ke.current)>.1)&&($(oe.x),ee(oe.y),fe.current=oe.x,ke.current=oe.y)},Re=z=>{const W=a.current;if(W&&z.target instanceof Node&&W.contains(z.target))z.preventDefault();else return;if(z.touches.length===1){const H=z.touches[0];F.current={x:H.clientX,y:H.clientY,time:Date.now()},G.current={x:H.clientX,y:H.clientY},Te.current||(he.current=!1),me.current=setTimeout(()=>{if(!he.current&&!Te.current)if(he.current=!0,Me.current==="mouse"){const V=Se.current||{nx:.5,ny:.5};_("Right Click"),Y(V.nx,V.ny,"right"),I.current("input_click",{...V,button:"right"}).catch(()=>{})}else{const V=te(H);V&&(_("Right Click"),Y(V.nx,V.ny,"right"),I.current("input_click",{...V,button:"right"}).catch(()=>{}))}},500)}else if(z.touches.length===2){clearTimeout(me.current),he.current=!0,Te.current=!0;const H=z.touches[1].clientX-z.touches[0].clientX,V=z.touches[1].clientY-z.touches[0].clientY;Pe.current=Math.sqrt(H*H+V*V),Ce.current=J.current,de.current={x:(z.touches[0].clientX+z.touches[1].clientX)/2,y:(z.touches[0].clientY+z.touches[1].clientY)/2}}},Le=z=>{const W=a.current;if(W&&z.target instanceof Node&&W.contains(z.target)&&z.preventDefault(),z.touches.length===1&&G.current){const H=z.touches[0],V=H.clientX-G.current.x,ce=H.clientY-G.current.y;if(!he.current&&F.current){const oe=H.clientX-F.current.x,Ee=H.clientY-F.current.y;Math.sqrt(oe*oe+Ee*Ee)>8&&(he.current=!0,clearTimeout(me.current))}if(he.current)if(Me.current==="mouse"){const oe=Z(V,ce),Ee=Se.current||{nx:.5,ny:.5},Ue=Math.max(0,Math.min(1,Ee.nx+oe.dnx)),He=Math.max(0,Math.min(1,Ee.ny+oe.dny));Se.current={nx:Ue,ny:He},Oe({nx:Ue,ny:He}),_(`Cursor: ${Math.round(Ue*100)}%, ${Math.round(He*100)}%`),ve(Ue,He,J.current);const Et=Date.now();Et-ne.current>=30&&(ne.current=Et,I.current("input_mouseMoved",{nx:Ue,ny:He}).catch(()=>{}))}else if(J.current>1){const oe=a.current;if(oe){const Ee=oe.clientWidth,Ue=oe.clientHeight,He=fe.current+V/Ee*100,Et=ke.current+ce/Ue*100,Cr=ir(He,Et,J.current);$(Cr.x),ee(Cr.y),fe.current=Cr.x,ke.current=Cr.y}}else{const oe=te(H);if(oe){const Ee=Date.now();Ee-ne.current>=40&&(ne.current=Ee,_("Scroll"),I.current("input_wheel",{nx:oe.nx,ny:oe.ny,deltaX:Math.round(-V*2.5),deltaY:Math.round(-ce*2.5)}).catch(()=>{}))}}G.current={x:H.clientX,y:H.clientY}}else if(z.touches.length===2&&Pe.current!==null){const H=z.touches[1].clientX-z.touches[0].clientX,V=z.touches[1].clientY-z.touches[0].clientY,oe=Math.sqrt(H*H+V*V)/Pe.current,Ee=(z.touches[0].clientX+z.touches[1].clientX)/2,Ue=(z.touches[0].clientY+z.touches[1].clientY)/2,He=Ee-de.current.x,Et=Ue-de.current.y,Cr=Math.abs(oe-1)>.03;if(Me.current==="mouse"){if(Cr){const Nt=Math.max(Qe,Math.min(5,Ce.current*oe));U(Nt),J.current=Nt}else if(Math.abs(He)>2||Math.abs(Et)>2){const Nt=Se.current||{nx:.5,ny:.5},Rn=Date.now();Rn-ne.current>=30&&(ne.current=Rn,_("Scroll"),I.current("input_wheel",{nx:Nt.nx,ny:Nt.ny,deltaX:Math.round(-He*3),deltaY:Math.round(-Et*3)}).catch(()=>{}))}}else{const Nt=Math.max(Qe,Math.min(5,Ce.current*oe));U(Nt),J.current=Nt;const Rn=a.current;if(Rn&&Nt>1){const tb=Rn.clientWidth,rb=Rn.clientHeight,nb=fe.current+He/tb*100,ib=ke.current+Et/rb*100,ml=ir(nb,ib,Nt);$(ml.x),ee(ml.y),fe.current=ml.x,ke.current=ml.y}}de.current={x:Ee,y:Ue}}},pt=z=>{var W;if(clearTimeout(me.current),Pe.current=null,z.touches.length===1&&Te.current){const H=z.touches[0];F.current={x:H.clientX,y:H.clientY,time:Date.now()},G.current={x:H.clientX,y:H.clientY},he.current=!0;return}if(z.touches.length===0){if(Te.current){Te.current=!1,he.current=!1;return}if(z.changedTouches.length===1&&!he.current){const H=z.changedTouches[0],V=Date.now(),ce=V-(((W=F.current)==null?void 0:W.time)||0);if(ce<60||ce>400){he.current=!1;return}if(F.current){const oe=H.clientX-F.current.x,Ee=H.clientY-F.current.y;if(Math.sqrt(oe*oe+Ee*Ee)>12){he.current=!1;return}}if(Me.current==="mouse"){const oe=Se.current||te(H);oe&&(_(`Click: ${Math.round(oe.nx*100)}%, ${Math.round(oe.ny*100)}%`),Y(oe.nx,oe.ny,"left"),I.current("input_click",{...oe}).catch(()=>{}))}else{const oe=te(H);if(!oe)return;V-je.current<300?(_("Double tap"),Y(oe.nx,oe.ny,"double"),I.current("input_click",{...oe,clickCount:2}).catch(()=>{}),je.current=0):(_(`Tap: ${Math.round(oe.nx*100)}%, ${Math.round(oe.ny*100)}%`),Y(oe.nx,oe.ny,"left"),I.current("input_click",{...oe}).catch(()=>{}),je.current=V)}}he.current=!1}};return q.addEventListener("touchstart",Re,{passive:!1}),q.addEventListener("touchmove",Le,{passive:!1}),q.addEventListener("touchend",pt,{passive:!1}),()=>{q.removeEventListener("touchstart",Re),q.removeEventListener("touchmove",Le),q.removeEventListener("touchend",pt),clearTimeout(me.current)}},[]),u.jsxs("div",{ref:l,className:"flex-1 flex flex-col bg-black relative overflow-hidden outline-none touch-none",onKeyDown:K,onContextMenu:q=>q.preventDefault(),onFocus:()=>v(!0),onBlur:()=>v(!1),tabIndex:0,children:[u.jsxs("div",{ref:a,className:"flex-1 relative overflow-hidden flex items-center justify-center bg-black",children:[nr?u.jsx("img",{ref:c,src:nr,alt:"Remote View",style:{display:"block",maxWidth:"100%",maxHeight:"100%",width:"auto",height:"auto",transform:`scale(${O}) translate(${L}%, ${w}%)`,transformOrigin:"center center",cursor:B==="mouse"?"default":"crosshair",userSelect:"none",WebkitTouchCallout:"none"},onClick:se,onContextMenu:q=>q.preventDefault(),onDragStart:q=>q.preventDefault()}):u.jsxs("div",{className:"text-slate-800 text-center",children:[u.jsx("div",{className:"text-5xl mb-3",children:"🌑"}),u.jsx("div",{className:"text-[13px] font-semibold",children:"Connecting to Host..."})]}),B==="mouse"&&xe&&nr&&c.current&&(()=>{var He;const q=c.current,te=q.getBoundingClientRect(),Z=(He=a.current)==null?void 0:He.getBoundingClientRect();if(!Z)return null;const ve=q.naturalWidth||te.width,Re=q.naturalHeight||te.height,Le=ve/Re,pt=te.width/te.height;let z,W,H,V;Le>pt?(z=te.width,W=te.width/Le,H=0,V=(te.height-W)/2):(W=te.height,z=te.height*Le,H=(te.width-z)/2,V=0);const ce=te.left-Z.left+H+z*xe.nx,oe=te.top-Z.top+V+W*xe.ny,Ee=Math.max(8,Math.min(Z.width-8,ce)),Ue=Math.max(8,Math.min(Z.height-8,oe));return u.jsxs("div",{style:{position:"absolute",left:Ee-8,top:Ue-8,width:16,height:16,pointerEvents:"none",zIndex:100},children:[u.jsx("div",{style:{position:"absolute",left:7,top:0,width:2,height:16,background:"rgba(59,130,246,0.8)"}}),u.jsx("div",{style:{position:"absolute",left:0,top:7,width:16,height:2,background:"rgba(59,130,246,0.8)"}}),u.jsx("div",{style:{position:"absolute",left:5,top:5,width:6,height:6,borderRadius:"50%",background:"#3b82f6",boxShadow:"0 0 8px rgba(59,130,246,0.6)"}})]})})(),y.map(q=>{const Z={left:"59,130,246",right:"239,68,68",double:"34,197,94"}[q.type];return u.jsxs("div",{style:{position:"absolute",left:q.x,top:q.y,pointerEvents:"none",zIndex:200,transform:"translate(-50%, -50%)"},children:[u.jsx("div",{style:{width:40,height:40,borderRadius:"50%",border:`2px solid rgba(${Z}, 0.8)`,animation:"click-ripple-ring 0.5s ease-out forwards",position:"absolute",left:-20,top:-20}}),u.jsx("div",{style:{width:8,height:8,borderRadius:"50%",background:`rgba(${Z}, 0.9)`,boxShadow:`0 0 12px rgba(${Z}, 0.6)`,animation:"click-ripple-dot 0.4s ease-out forwards",position:"absolute",left:-4,top:-4}})]},q.id)})]}),u.jsxs("div",{onTouchStart:q=>q.stopPropagation(),className:"absolute bottom-0 left-0 right-0 z-[1000] flex items-center justify-center gap-1.5 px-3 py-2 bg-black/75 backdrop-blur-xl border-t border-white/[0.08] touch-none",children:[u.jsxs("div",{onClick:()=>{j(q=>{const te=q==="touch"?"mouse":"touch";if(te==="mouse"&&!Se.current){const Z={nx:.5,ny:.5};Se.current=Z,Oe(Z)}return te})},className:`h-8 px-2.5 rounded-lg flex items-center gap-[5px] cursor-pointer ${B==="mouse"?"bg-blue-500/25 border border-blue-500/40":"bg-white/[0.08] border border-white/10"}`,children:[u.jsx("span",{className:"text-sm",children:B==="mouse"?"🖱️":"👆"}),u.jsx("span",{className:`text-[10px] font-bold ${B==="mouse"?"text-blue-400":"text-slate-400"}`,children:B==="mouse"?"Mouse":"Touch"})]}),u.jsxs("div",{className:"relative",children:[u.jsx("div",{onClick:()=>{D(!N),P(!1)},className:`w-8 h-8 rounded-lg flex items-center justify-center cursor-pointer ${N?"bg-emerald-500/25 border border-emerald-500/40":"bg-white/[0.08] border border-white/10"}`,children:u.jsx("span",{className:"text-sm",children:"⌨️"})}),N&&u.jsx("div",{className:"absolute bottom-10 left-1/2 -translate-x-1/2 w-[220px] bg-neutral-950/[0.98] backdrop-blur-[30px] rounded-xl border border-white/20 p-[10px_12px] shadow-[0_10px_30px_rgba(0,0,0,0.8)] flex flex-col gap-2 z-[2000]",style:{animation:"slideUp 0.15s ease-out"},children:u.jsx("input",{type:"text",placeholder:"Type & Enter...",value:b,autoFocus:!0,onTouchStart:q=>q.stopPropagation(),onChange:q=>g(q.target.value),onKeyDown:ae,className:"w-full bg-black/60 border border-white/15 rounded-lg px-2.5 py-2 text-white text-[13px] outline-none"})})]}),u.jsx("div",{className:"relative",children:u.jsx("div",{onClick:()=>{P(!E),D(!1)},className:`w-8 h-8 rounded-lg flex items-center justify-center cursor-pointer ${E?"bg-blue-500/25 border border-blue-500/40":"bg-white/[0.08] border border-white/10"}`,children:u.jsx("span",{className:"text-sm",children:"⚙️"})})}),u.jsx("div",{className:"w-px h-[18px] bg-white/10"}),u.jsxs("div",{className:"flex items-center gap-1.5",children:[u.jsxs("div",{className:"flex items-center gap-0.5 px-1.5 py-0.5 rounded-md",style:{background:we?"rgba(16,185,129,0.12)":"rgba(251,191,36,0.12)"},children:[u.jsx("div",{className:"w-1 h-1 rounded-full",style:{background:we?"#10b981":"#fbbf24"}}),u.jsx("span",{className:"text-[8px] font-extrabold",style:{color:we?"#10b981":"#fbbf24"},children:we?"Connected":"WS"})]}),O>1&&u.jsxs("span",{className:"text-[8px] font-bold text-indigo-400",children:[Math.round(O*100),"%"]}),m&&u.jsx("span",{className:"text-[8px] text-neutral-500 font-semibold max-w-[100px] overflow-hidden text-ellipsis whitespace-nowrap",children:m})]})]}),E&&u.jsxs("div",{onTouchStart:q=>q.stopPropagation(),style:{position:"absolute",bottom:56,left:"50%",transform:"translateX(-50%)",width:220,background:"rgba(23, 23, 23, 0.95)",backdropFilter:"blur(25px)",borderRadius:14,border:"1px solid rgba(255,255,255,0.1)",padding:14,boxShadow:"0 12px 40px rgba(0,0,0,0.6)",display:"flex",flexDirection:"column",gap:12,zIndex:1001,touchAction:"none",animation:"slideUpSidebar 0.15s ease-out"},children:[u.jsx("div",{style:{fontSize:9,fontWeight:900,color:"#3b82f6",letterSpacing:1.5},children:"SETTINGS"}),u.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[u.jsxs("div",{style:{fontSize:10,color:"#888",fontWeight:700},children:["ZOOM: ",O<=(k?M:1)+.01?k?"FILL":"FIT":`${Math.round(O*100)}%`]}),u.jsxs("div",{style:{display:"flex",gap:4},children:[u.jsx("button",{onClick:q=>{q.stopPropagation(),U(te=>Math.max(.5,te-.25))},style:{flex:1,background:"rgba(255,255,255,0.1)",color:"#fff",border:"none",padding:"6px",borderRadius:6,fontSize:12,fontWeight:800,cursor:"pointer"},children:"−"}),u.jsx("button",{onClick:q=>{q.stopPropagation();const te=k?M:1;U(te),J.current=te,$(0),ee(0)},style:{flex:1,background:"rgba(255,255,255,0.1)",color:"#fff",border:"none",padding:"6px",borderRadius:6,fontSize:9,fontWeight:800,cursor:"pointer"},children:k?"FILL":"FIT"}),u.jsx("button",{onClick:q=>{q.stopPropagation(),U(te=>Math.min(5,te+.25))},style:{flex:1,background:"rgba(255,255,255,0.1)",color:"#fff",border:"none",padding:"6px",borderRadius:6,fontSize:12,fontWeight:800,cursor:"pointer"},children:"+"})]})]}),u.jsx("button",{onClick:q=>{var ve;q.stopPropagation();const te=((ve=l.current)==null?void 0:ve.clientWidth)||0,Z=te>0?Math.max(400,Math.ceil(te/100)*100):void 0;r(Z)},style:{width:"100%",background:"#3b82f6",color:"#fff",border:"none",padding:"8px",borderRadius:6,fontSize:11,fontWeight:800,cursor:"pointer"},children:"FORCE SYNC"}),u.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",background:"rgba(255,255,255,0.05)",padding:"6px 10px",borderRadius:6},children:[u.jsx("span",{style:{fontSize:10,color:"#888",fontWeight:700},children:"AUTO REF."}),u.jsx("input",{type:"checkbox",checked:d,onChange:q=>h(q.target.checked)})]}),u.jsxs("select",{value:f,onChange:q=>p(Number(q.target.value)),style:{background:"rgba(255,255,255,0.05)",color:"#fff",border:"none",borderRadius:6,padding:"6px",fontSize:10,fontWeight:600,outline:"none"},children:[u.jsx("option",{value:500,children:"0.5s Interval"}),u.jsx("option",{value:1e3,children:"1.0s Interval"}),u.jsx("option",{value:2e3,children:"2.0s Interval"}),u.jsx("option",{value:4e3,children:"4.0s Interval"})]})]}),u.jsx("style",{children:`
|
|
154
154
|
@keyframes slideUp {
|
|
155
155
|
from { opacity: 0; transform: translateY(6px); }
|
|
156
156
|
to { opacity: 1; transform: translateY(0); }
|
|
@@ -170,7 +170,7 @@ WARNING: This link could potentially be dangerous`)){let r=window.open();if(r){t
|
|
|
170
170
|
}
|
|
171
171
|
`})]})}function uL({screenshotUrl:e,mode:t="preview",zoom:r=100,interactive:n=!1,connectionState:i,onDismiss:s,onClickAt:o,onKeyDown:l,badge:a,emptyMessage:c,aspectRatio:d,className:h,style:f}){const p=x.useRef(null),m=x.useCallback(_=>{if(!n||!o||!p.current)return;const b=p.current,g=b.getBoundingClientRect(),v=(_.clientX-g.left)/g.width*b.naturalWidth,y=(_.clientY-g.top)/g.height*b.naturalHeight;o(v,y,b.naturalWidth,b.naturalHeight)},[n,o]);return t==="preview"?e?u.jsxs("div",{className:`relative rounded-xl overflow-hidden border border-border-subtle bg-bg-secondary ${h||""}`,style:{aspectRatio:d||"16/9",...f},children:[u.jsx("img",{ref:p,src:e,alt:"IDE Screenshot",className:"w-full h-full object-cover"}),s&&u.jsx("button",{onClick:s,className:"absolute top-2.5 right-2.5 bg-black/50 border-none text-white w-5 h-5 rounded-full text-[10px] z-10 cursor-pointer flex items-center justify-center",children:"✕"})]}):null:e?u.jsxs("div",{className:`${n?"screenshot-interactive":""} ${h||""} relative h-full flex items-center justify-center overflow-auto`,tabIndex:n?0:void 0,onKeyDown:n?l:void 0,style:f,children:[u.jsx("img",{ref:p,src:e,alt:"IDE Screenshot",onClick:n?m:void 0,className:"max-w-full max-h-full object-contain",style:{...n?{cursor:"crosshair"}:{},...r!==100?{transform:`scale(${r/100})`,transformOrigin:"center center"}:{}}}),a&&u.jsx("div",{className:"absolute bottom-4 left-1/2 -translate-x-1/2 bg-black/70 text-white px-3.5 py-1.5 rounded-[20px] text-xs font-semibold backdrop-blur-sm",children:a})]}):u.jsxs("div",{className:`flex items-center justify-center flex-col gap-2 h-full text-text-muted ${h||""}`,style:f,children:[u.jsx("p",{className:"text-base",children:c||"🖥 Waiting for screenshot stream..."}),i&&u.jsxs("p",{className:"text-[13px] mt-2 opacity-50",children:["P2P: ",i]})]})}function M1({activeConv:e,onModalButton:t}){const[r,n]=x.useState(null);if(x.useEffect(()=>{n(null)},[e.modalMessage,e.status]),e.status!=="waiting_approval"||!e.modalButtons)return null;const i=o=>{r||(n(o),t(o))},s=o=>o.replace(/[⌥⏎⇧⌫⌘⌃↵]/g,"").replace(/\s*(Alt|Ctrl|Shift|Cmd|Enter|Return|Esc|Tab|Backspace)(\+\s*\w+)*/gi,"").trim();return u.jsxs("div",{className:"bg-gradient-to-br from-amber-600 to-amber-700 text-white py-2.5 px-4 shrink-0 z-[5]",children:[e.modalMessage&&u.jsx("div",{className:"text-[11px] opacity-85 mb-1.5 whitespace-nowrap overflow-hidden text-ellipsis max-w-full",children:e.modalMessage.replace(/[\n\r]+/g," ").slice(0,120)}),u.jsxs("div",{className:"flex justify-between items-center",children:[u.jsxs("div",{className:"font-black text-xs flex items-center gap-2",children:[u.jsx(A0,{size:14})," ",r?"PROCESSING...":"ACTION REQUIRED"]}),u.jsx("div",{className:"flex gap-2 flex-wrap",children:e.modalButtons.map((o,l)=>{const a=s(o).toLowerCase(),c=/^(run|approve|accept|yes|allow|always)/.test(a),d=/^(reject|deny|delete|remove|abort)/.test(a),h=r===o,f=r!==null;return u.jsx("button",{onClick:()=>i(o),disabled:f,className:`btn btn-sm border-none rounded-md text-xs px-3 py-1 ${c?"bg-white text-amber-700 font-extrabold":d?"bg-red-500/30 text-white font-semibold":"bg-white/15 text-white font-semibold"} ${f&&!h?"opacity-40":"opacity-100"} ${f?"cursor-not-allowed":"cursor-pointer"}`,children:h?"⏳ ...":s(o)},l)})})]})]})}const Nr=new Map;function hL({ideId:e,ideType:t,agentType:r,agentName:n,serverModel:i,serverMode:s,acpConfigOptions:o,acpModes:l}){var X;const{sendCommand:a}=ui(),c=!!(o||l),d=`${e}:${r}`,h=Nr.get(d),[f,p]=x.useState(!1),[m,_]=x.useState(!1),[b,g]=x.useState((h==null?void 0:h.models)||[]),[v,y]=x.useState((h==null?void 0:h.modes)||[]),S=I=>I?typeof I=="string"?I:typeof I=="object"?I.name||I.id||JSON.stringify(I):String(I):"",[R,E]=x.useState(S(i)),[P,N]=x.useState(S(s)),[D,k]=x.useState(!1),[B,j]=x.useState(!1),M=x.useRef(0),C=I=>I.map(F=>typeof F=="string"?F:(F==null?void 0:F.name)||(F==null?void 0:F.id)||String(F));x.useEffect(()=>{if(o){const I=o.find(F=>F.category==="model");if(I){const F=C(I.options.map(he=>he.value));g(F),I.currentValue&&E(S(I.currentValue));const G=Nr.get(d)||{models:[],modes:[]};Nr.set(d,{...G,models:F})}}if(l&&l.length>0){const I=C(l.map(G=>G.id));y(I);const F=Nr.get(d)||{models:[],modes:[]};Nr.set(d,{...F,modes:I})}else if(o){const I=o.find(F=>F.category!=="model");if(I){const F=C(I.options.map(he=>he.value));y(F),I.currentValue&&N(S(I.currentValue));const G=Nr.get(d)||{models:[],modes:[]};Nr.set(d,{...G,modes:F})}}},[o,l,d]),x.useEffect(()=>{p(!1),_(!1),E(S(i)),N(S(s));const I=Nr.get(d);I?(g(I.models),y(I.modes)):(g([]),y([]))},[e,r]),x.useEffect(()=>{i&&Date.now()>M.current&&E(S(i))},[i]),x.useEffect(()=>{s&&Date.now()>M.current&&N(S(s))},[s]);const A=x.useCallback(async(I,F={})=>{const G={...F},he=e.split(":");return he.length>=3&&(he[1]==="ide"||he[1]==="cli"||he[1]==="acp")&&(G._targetInstance=he.slice(2).join(":"),G._targetType=he[1]),await a(e,I,G)},[e]),O=async()=>{var I,F;if(b.length>0){p(!f);return}if(c){p(!0);return}k(!0);try{const G=await A("list_extension_models",{agentType:r,ideType:t}),he=(G==null?void 0:G.models)||((I=G==null?void 0:G.result)==null?void 0:I.models)||[],me=C(he);g(me),G!=null&&G.current&&E(S(G.current)),(F=G==null?void 0:G.result)!=null&&F.current&&E(S(G.result.current));const je=Nr.get(d)||{models:[],modes:[]};Nr.set(d,{...je,models:me}),p(!0)}catch{}finally{k(!1)}},U=async()=>{var I,F;if(v.length>0){_(!m);return}if(c){_(!0);return}j(!0);try{const G=await A("list_extension_modes",{agentType:r,ideType:t}),he=(G==null?void 0:G.modes)||((I=G==null?void 0:G.result)==null?void 0:I.modes)||[],me=C(he);y(me),G!=null&&G.current&&N(S(G.current)),(F=G==null?void 0:G.result)!=null&&F.current&&N(S(G.result.current));const je=Nr.get(d)||{models:[],modes:[]};Nr.set(d,{...je,modes:me}),_(!0)}catch{}finally{j(!1)}},L=async I=>{p(!1),E(I),M.current=Date.now()+5e3;try{c?await A("change_model",{agentType:r,ideType:t,model:I}):await A("set_extension_model",{agentType:r,ideType:t,model:I})}catch{}},$=c&&!(l&&l.length>0)&&(o==null?void 0:o.some(I=>I.category!=="model")),w=$?(X=o==null?void 0:o.find(I=>I.category!=="model"))==null?void 0:X.configId:void 0,ee=async I=>{_(!1),N(I),M.current=Date.now()+5e3;try{c&&$&&w?await A("set_thought_level",{agentType:r,ideType:t,configId:w,value:I}):c?await A("set_mode",{agentType:r,ideType:t,mode:I}):await A("set_extension_mode",{agentType:r,ideType:t,mode:I})}catch{}},T={cline:"#22d3ee","roo-code":"#a78bfa",cursor:"#60a5fa",antigravity:"#f97316",windsurf:"#34d399"}[r]||"#94a3b8";return u.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-1 flex-wrap text-[10px] border-t border-border-subtle bg-[var(--surface-primary)]",children:[u.jsx("span",{className:"text-[9px] font-bold tracking-wide uppercase opacity-70",style:{color:T},children:n}),u.jsx("span",{className:"text-border-subtle text-[10px]",children:"│"}),u.jsxs("div",{className:"relative",children:[u.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-xl text-[10px] font-medium cursor-pointer transition-all bg-[var(--surface-tertiary)] whitespace-nowrap max-w-40 overflow-hidden text-ellipsis",style:{borderColor:f?`${T}55`:"transparent",border:"1px solid",color:R?"var(--text-primary)":"var(--text-muted)"},onClick:O,children:[u.jsx("span",{className:"text-[9px] opacity-60",children:"🤖"}),D?"...":R||"Model",u.jsx("span",{className:"text-[7px] opacity-50",children:"▼"})]}),f&&b.length>0&&u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"fixed inset-0 z-[59]",onClick:()=>p(!1)}),u.jsxs("div",{className:"absolute bottom-full left-0 z-[60] bg-[var(--surface-primary)] border border-border-subtle rounded-lg mb-1 max-h-[220px] overflow-y-auto min-w-40 shadow-[0_-4px_16px_rgba(0,0,0,0.3)]",children:[u.jsx("div",{className:"px-3 py-1.5 text-[9px] font-bold text-text-muted tracking-wider border-b border-border-subtle",children:"SELECT MODEL"}),b.map(I=>u.jsx("div",{className:"px-3 py-[7px] text-[11px] cursor-pointer whitespace-nowrap overflow-hidden text-ellipsis",style:{background:I===R?`${T}18`:"transparent",color:I===R?T:"var(--text-secondary)",fontWeight:I===R?600:400,borderLeft:I===R?`2px solid ${T}`:"2px solid transparent"},onMouseEnter:F=>{F.currentTarget.style.background=`${T}12`},onMouseLeave:F=>{F.currentTarget.style.background=I===R?`${T}18`:"transparent"},onClick:()=>L(I),children:I},I))]})]})]}),u.jsxs("div",{className:"relative",children:[u.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-xl text-[10px] font-medium cursor-pointer transition-all bg-[var(--surface-tertiary)] whitespace-nowrap max-w-40 overflow-hidden text-ellipsis",style:{borderColor:m?`${T}55`:"transparent",border:"1px solid",color:P?"var(--text-primary)":"var(--text-muted)"},onClick:U,children:[u.jsx("span",{className:"text-[9px] opacity-60",children:$?"🧠":"⚡"}),B?"...":P||($?"Thinking":"Mode"),u.jsx("span",{className:"text-[7px] opacity-50",children:"▼"})]}),m&&v.length>0&&u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"fixed inset-0 z-[59]",onClick:()=>_(!1)}),u.jsxs("div",{className:"absolute bottom-full left-0 z-[60] bg-[var(--surface-primary)] border border-border-subtle rounded-lg mb-1 max-h-[220px] overflow-y-auto min-w-40 shadow-[0_-4px_16px_rgba(0,0,0,0.3)]",children:[u.jsx("div",{className:"px-3 py-1.5 text-[9px] font-bold text-text-muted tracking-wider border-b border-border-subtle",children:$?"SELECT THINKING LEVEL":"SELECT MODE"}),v.map(I=>u.jsx("div",{className:"px-3 py-[7px] text-[11px] cursor-pointer whitespace-nowrap overflow-hidden text-ellipsis",style:{background:I===P?`${T}18`:"transparent",color:I===P?T:"var(--text-secondary)",fontWeight:I===P?600:400,borderLeft:I===P?`2px solid ${T}`:"2px solid transparent"},onMouseEnter:F=>{F.currentTarget.style.background=`${T}12`},onMouseLeave:F=>{F.currentTarget.style.background=I===P?`${T}18`:"transparent"},onClick:()=>ee(I),children:I},I))]})]})]})]})}const si=e=>(e.ideId||e.tabKey||e.id||"").includes(":cli:"),ln=e=>(e.ideId||e.tabKey||e.id||"").includes(":acp:");function L1({activeConv:e,ides:t,agentInput:r,setAgentInput:n,handleSendChat:i,handleFocusAgent:s,isFocusingAgent:o,messageReceivedAt:l,actionLogs:a,userName:c}){const d=x.useRef(null),{sendCommand:h}=ui(),[f,p]=x.useState([]),[m,_]=x.useState(0),[b,g]=x.useState(!0),[v,y]=x.useState(!1),S=x.useRef("");e.tabKey!==S.current&&(S.current=e.tabKey,p([]),_(0),g(!0));const R=x.useCallback(async()=>{var N,D,k,B,j,M;if(!(v||!b)){y(!0);try{const C=t.find(w=>w.id===e.ideId),A=(C==null?void 0:C.daemonId)||((N=e.ideId)==null?void 0:N.split(":")[0])||"";if(!A){g(!1);return}const O=e.ideType||e.agentType||"",U=(e.ideId||"").split(":"),L=U.length>=3?U.slice(2).join(":"):void 0;console.log("[ChatPane] requestChatHistory:",{daemonId:A,agentType:O,instanceId:L,offset:m});const $=await h(A,"chat_history",{agentType:O,offset:m,limit:30,instanceId:L});console.log("[ChatPane] got result:",{count:((D=$.messages)==null?void 0:D.length)||0,hasMore:$.hasMore}),((k=$.messages)==null?void 0:k.length)>0&&(p(w=>[...$.messages,...w]),_(w=>w+$.messages.length)),g($.hasMore)}catch(C){console.warn("[ChatPane] Failed to load history:",C),!((B=C==null?void 0:C.message)!=null&&B.includes("P2P not available"))&&!((j=C==null?void 0:C.message)!=null&&j.includes("channel not open"))&&!((M=C==null?void 0:C.message)!=null&&M.includes("P2P not connected"))&&g(!1)}finally{y(!1)}}},[v,b,m,t,e]),E=x.useRef(0);x.useEffect(()=>{if(e.messages.length<10&&b&&!v&&f.length===0){const N=E.current;if(N>8)return;const k=setTimeout(()=>{E.current=N+1,R()},N===0?500:3e3);return()=>clearTimeout(k)}else f.length>0&&(E.current=0)},[e.tabKey,e.messages.length,b,v,f.length,R]);const P=(()=>{const N=e.messages.map((B,j)=>{const M=`${e.ideId}-${B.id??`i-${j}`}`;return{...B,receivedAt:B.receivedAt||l[M]||0}});if(f.length===0)return N;const D=new Set(N.map(B=>`${B.role}:${(B.content||"").slice(0,100)}`));return[...f.filter(B=>!D.has(`${B.role}:${(B.content||"").slice(0,100)}`)),...N]})();return u.jsxs(u.Fragment,{children:[u.jsx(UP,{messages:P,actionLogs:a.filter(N=>N.ideId===e.tabKey).sort((N,D)=>N.timestamp-D.timestamp),agentName:e.agentName||e.displayPrimary||"Agent",userName:c,isCliMode:si(e)||ln(e),isWorking:e.status==="working",contextKey:e.tabKey,onLoadMore:R,isLoadingMore:v,hasMoreHistory:b,emptyState:e.messages.length===0?e.connectionState==="connecting"||e.connectionState==="new"?u.jsxs("div",{className:"text-center mt-16 flex flex-col items-center gap-4",children:[u.jsx("div",{className:"connecting-logo-float",children:u.jsx("div",{style:{width:64,height:64,borderRadius:"50%",background:"radial-gradient(circle, rgba(96,165,250,0.12), transparent 70%)",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:"0 0 40px rgba(96,165,250,0.08)"},children:u.jsx("img",{src:"/otter-logo.png",alt:"ADHDev",style:{width:40,height:40,borderRadius:"50%",opacity:.85}})})}),u.jsxs("div",{className:"flex flex-col items-center gap-1.5",children:[u.jsxs("div",{className:"text-[13px] text-blue-400 font-medium",children:["Connecting to your machine",u.jsx("span",{className:"connecting-dots"})]}),u.jsx("div",{className:"text-[11px] opacity-35",children:"Establishing P2P connection"})]})]}):e.status==="not_monitored"?u.jsxs("div",{className:"text-center mt-16 flex flex-col items-center gap-3",children:[u.jsx("div",{className:"text-3xl opacity-60",children:u.jsx(B0,{size:28})}),u.jsx("div",{className:"text-[13px] opacity-50",children:"Agent not monitored"}),u.jsx("button",{onClick:s,disabled:o,className:"btn btn-sm bg-accent text-white border-none rounded-[10px] px-5 py-2 font-bold text-[13px] cursor-pointer transition-all",children:o?"⌛ Switching...":u.jsxs("span",{className:"flex items-center gap-1.5",children:[u.jsx(Xa,{size:14})," Open ",e.displayPrimary," Panel"]})}),u.jsx("div",{className:"text-[11px] opacity-35 max-w-[280px]",children:"Click to switch monitoring to this agent"})]}):e.status==="panel_hidden"?u.jsxs("div",{className:"text-center mt-16 flex flex-col items-center gap-3",children:[u.jsx("div",{className:"text-3xl opacity-60",children:u.jsx(OP,{size:28})}),u.jsx("div",{className:"text-[13px] opacity-50",children:"Panel is not visible in IDE"}),u.jsx("button",{onClick:s,disabled:o,className:"btn btn-sm bg-accent text-white border-none rounded-[10px] px-5 py-2 font-bold text-[13px] cursor-pointer transition-all",children:o?"⌛ Opening...":u.jsxs("span",{className:"flex items-center gap-1.5",children:[u.jsx(Xa,{size:14})," Open ",e.displayPrimary," Panel"]})}),u.jsx("div",{className:"text-[11px] opacity-35 max-w-[280px]",children:"Open the agent sidebar in your IDE to start viewing messages"})]}):e.status==="idle"&&!v?u.jsxs("div",{className:"text-center mt-16 flex flex-col items-center gap-3",children:[u.jsx("div",{className:"text-2xl opacity-40 animate-pulse",children:"💬"}),u.jsx("div",{className:"text-[13px] opacity-40",children:"Loading chat..."})]}):void 0:void 0}),!si(e)&&(()=>{var D,k,B,j;const N=t.find(M=>M.id===e.ideId);return u.jsx(hL,{ideId:e.ideId,ideType:e.ideType,agentType:e.streamSource==="agent-stream"?e.agentType:((k=(D=N==null?void 0:N.agents)==null?void 0:D[0])==null?void 0:k.type)||e.ideType,agentName:e.streamSource==="agent-stream"?e.agentName:((j=(B=N==null?void 0:N.agents)==null?void 0:B[0])==null?void 0:j.name)||e.agentName,serverModel:(N==null?void 0:N.currentModel)||void 0,serverMode:(N==null?void 0:N.currentPlan)||void 0,acpConfigOptions:ln(e)?N==null?void 0:N.acpConfigOptions:void 0,acpModes:ln(e)?N==null?void 0:N.acpModes:void 0})})(),u.jsx("div",{className:"dashboard-input-area px-3 py-2.5 bg-[var(--surface-primary)] border-t border-border-subtle shrink-0",children:u.jsxs("div",{className:"flex gap-2.5 items-center",children:[u.jsx("div",{className:"flex-1 relative",children:u.jsx("input",{ref:d,type:"text",placeholder:`Send message to ${e.displayPrimary}...`,value:r,onChange:N=>n(N.target.value),onPaste:N=>{const D=N.clipboardData.getData("text");D&&n(k=>k+D),N.preventDefault()},onKeyDown:N=>{if(N.key==="Enter"){if(N.nativeEvent.isComposing){N.preventDefault();return}N.preventDefault(),i()}},onBlur:N=>{if(window.innerWidth<768){const D=N.relatedTarget;if((D==null?void 0:D.tagName)==="BUTTON")return;setTimeout(()=>{document.documentElement.scrollTop=0},300)}},className:"w-full h-10 rounded-[20px] px-4 bg-bg-secondary text-sm text-text-primary",style:{border:"1px solid var(--chat-input-border, var(--border-subtle))"}})}),u.jsx("button",{onClick:i,disabled:!r.trim(),className:`w-10 h-10 rounded-full flex items-center justify-center border-none shrink-0 transition-all duration-300 ${r.trim()?"cursor-pointer":"bg-bg-secondary cursor-default"}`,style:r.trim()?{background:"var(--chat-send-bg, var(--accent-primary))"}:void 0,children:u.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",className:r.trim()?"text-white":"text-text-muted",children:u.jsx("path",{d:"M22 2L11 13M22 2l-7 20-4-9-9-4 20-7z"})})})]})})]})}const Du=new Set,I1={emit(e,t){for(const r of Du)r(e,t)},on(e){return Du.add(e),()=>{Du.delete(e)}}};function dL({activeConv:e,ptyBuffers:t,terminalRef:r,agentInput:n,setAgentInput:i,handleSendChat:s,handleModalButton:o}){var p;const l=x.useRef(null),{sendCommand:a,sendData:c}=ui(),d=(p=e.ideId)!=null&&p.includes(":cli:")?e.ideId.split(":cli:")[1]:"",h=e.tabKey,f=e.ideType||e.agentType||"";return x.useEffect(()=>{const m=t.current.get(h);if(m&&m.length>0){const _=setTimeout(()=>{var b;for(const g of m)(b=r.current)==null||b.write(g);requestAnimationFrame(()=>{var g;(g=r.current)==null||g.bumpResize()})},100);return()=>clearTimeout(_)}},[h]),x.useEffect(()=>{const m=I1.on((_,b)=>{var v;if(!b)return;(_===d||_===f)&&((v=r.current)==null||v.write(b))});return()=>{m()}},[d,f]),u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 bg-[var(--surface-primary)] border-b border-border-subtle shrink-0",children:[u.jsx("div",{className:"flex gap-1",children:u.jsx("div",{className:"px-3 py-1 rounded-md text-[11px] font-semibold bg-accent text-white",children:"⬛ Terminal"})}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsxs("div",{className:"text-[10px] text-text-muted",children:[e.agentName," — Terminal"]}),u.jsx("button",{onClick:()=>{if(!r.current||!e)return;const m=t.current.get(e.tabKey);if(m&&m.length>0)for(const _ of m)r.current.write(_);requestAnimationFrame(()=>{requestAnimationFrame(()=>{var _;(_=r.current)==null||_.bumpResize()})})},title:"Refresh terminal (replay buffer + TUI redraw)",className:"px-2 py-0.5 rounded-[5px] text-[11px] bg-bg-secondary text-text-secondary border border-border-subtle cursor-pointer leading-none",children:"↺"}),u.jsx("button",{onClick:async()=>{var b;const m=(b=e.ideId)!=null&&b.includes(":cli:")?e.ideId.split(":cli:")[1]:e.ideType||e.agentType||"";if(!window.confirm(`Stop ${m}?
|
|
172
172
|
This will terminate the CLI process.`))return;const _=e.ideId||e.daemonId||"";try{await a(_,"stop_cli",{cliType:m})}catch(g){console.error("Stop CLI failed:",g)}},title:"Stop CLI process",className:"px-2 py-0.5 rounded-[5px] text-[11px] bg-red-500/[0.08] text-red-400 border border-red-500/30 cursor-pointer leading-none font-semibold",children:"■ Stop"})]})]}),u.jsx(M1,{activeConv:e,onModalButton:o}),u.jsx("div",{className:"flex-1 min-h-0 p-2 bg-[#0f1117]",children:u.jsx(R1,{ref:r,onInput:m=>{var g;const _=e.ideId||e.daemonId||"",b=(g=e.ideId)!=null&&g.includes(":cli:")?e.ideId.split(":cli:")[1]:e.ideType||e.agentType||"";c!=null&&c(_,{type:"pty_input",cliType:b,data:m})||a(_,"pty_input",{cliType:b,data:m}).catch(console.error)},onResize:(m,_)=>{var v;const b=e.ideId||e.daemonId||"",g=(v=e.ideId)!=null&&v.includes(":cli:")?e.ideId.split(":cli:")[1]:e.ideType||e.agentType||"";c!=null&&c(b,{type:"pty_resize",cliType:g,cols:m,rows:_})||a(b,"pty_resize",{cliType:g,cols:m,rows:_,force:!0}).catch(()=>{})}},e.tabKey)}),u.jsx("div",{className:"px-3 py-2 bg-[var(--surface-primary)] border-t border-border-subtle shrink-0",children:u.jsxs("div",{className:"flex gap-2.5 items-center",children:[u.jsx("div",{className:"flex-1 relative",children:u.jsx("input",{ref:l,type:"text",placeholder:`Send message to ${e.displayPrimary}...`,value:n,onChange:m=>i(m.target.value),onPaste:m=>{const _=m.clipboardData.getData("text");_&&i(b=>b+_),m.preventDefault()},onKeyDown:m=>{if(m.key==="Enter"){if(m.nativeEvent.isComposing){m.preventDefault();return}m.preventDefault(),s()}},className:"w-full h-9 rounded-[18px] px-4 bg-bg-secondary text-[13px] text-text-primary",style:{border:"1px solid var(--chat-input-border, var(--border-subtle))"}})}),u.jsx("button",{onClick:s,disabled:!n.trim(),className:`w-9 h-9 rounded-full flex items-center justify-center border-none shrink-0 transition-all duration-300 ${n.trim()?"cursor-pointer":"bg-bg-secondary cursor-default"}`,style:n.trim()?{background:"var(--chat-send-bg, var(--accent-primary))"}:void 0,children:u.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",className:n.trim()?"text-white":"text-text-muted",children:u.jsx("path",{d:"M22 2L11 13M22 2l-7 20-4-9-9-4 20-7z"})})})]})})]})}function fL({wsStatus:e,showReconnected:t,loginUrl:r}){const n=e==="disconnected"||e==="reconnecting"||e==="offline"||e==="auth_failed",i=e==="auth_failed"?"red":e==="offline"?"orange":"violet",s={red:"linear-gradient(90deg, rgba(239,68,68,0.12), rgba(239,68,68,0.04))",orange:"linear-gradient(90deg, rgba(255,107,53,0.12), rgba(255,107,53,0.04))",violet:"linear-gradient(90deg, rgba(139,92,246,0.12), rgba(139,92,246,0.04))"},o={red:"1px solid rgba(239,68,68,0.2)",orange:"1px solid rgba(255,107,53,0.2)",violet:"1px solid rgba(139,92,246,0.2)"},l={red:"#ef4444",orange:"#ff6b35",violet:"#a78bfa"};return u.jsxs(u.Fragment,{children:[n&&u.jsxs("div",{className:"py-2.5 px-5 text-[13px] font-semibold flex items-center gap-2.5 justify-center",style:{background:s[i],borderBottom:o[i],color:l[i]},children:[u.jsx("img",{src:"/otter-logo.png",alt:"",className:"w-5 h-5",style:{opacity:e==="auth_failed"?.6:1,animation:e==="auth_failed"?void 0:"pulse 2s ease-in-out infinite",filter:e==="auth_failed"?"grayscale(1)":void 0}}),e==="offline"&&"Network offline — waiting for connection...",e==="disconnected"&&"Reconnecting to server...",e==="reconnecting"&&"Reconnecting to server...",e==="auth_failed"&&(r?u.jsxs(u.Fragment,{children:["Session expired."," ",u.jsx("a",{href:r,className:"text-inherit underline",children:"Log in again"})]}):"Connection failed — please restart the server.")]}),t&&e==="connected"&&u.jsxs("div",{className:"py-2 px-4 text-xs font-semibold flex items-center gap-2 justify-center bg-gradient-to-r from-green-500/[0.12] to-green-500/[0.04] text-green-400 border-b border-green-500/15 animate-[fadeIn_0.3s_ease]",children:[u.jsx("img",{src:"/otter-logo.png",alt:"",className:"w-4 h-4"}),"Connected"]})]})}let pL=Ko;function Lc(){return pL()}class mL{constructor(){Yt(this,"listeners",new Map)}send(t){}isConnected(){return!1}on(t,r){return this.listeners.has(t)||this.listeners.set(t,new Set),this.listeners.get(t).add(r),()=>{var n;(n=this.listeners.get(t))==null||n.delete(r)}}emit(t,...r){var n;(n=this.listeners.get(t))==null||n.forEach(i=>i(...r))}}let gL=new mL;class _L{constructor(){Yt(this,"ptyCallbacks",new Set)}sendPtyInput(t,r,n){return!1}sendPtyResize(t,r,n,i){return!1}async requestChatHistory(t,r,n,i,s){return{messages:[],hasMore:!1}}retryConnection(t){}getState(t){return"disconnected"}sendData(t,r){return!1}get(t){}onScreenshot(t,r){return()=>{}}onStatusEvent(t){return()=>{}}onPtyOutput(t){return this.ptyCallbacks.add(t),()=>{this.ptyCallbacks.delete(t)}}emitPtyOutput(t,r){this.ptyCallbacks.forEach(n=>n(t,r))}}let vr=new _L,T_=vr;const Au=e=>(e.ideId||e.tabKey||e.id||"").includes(":cli:"),Bu=e=>(e.ideId||e.tabKey||e.id||"").includes(":acp:");function vL({activeConv:e,agentCount:t,wsStatus:r,isConnected:n,onOpenHistory:i}){const s=En(),o=Lc(),l=o.p2pStates||{},a=o.ides||[],c=n?"#22c55e":r==="connected"?"#eab308":"#ef4444",d=n?"0 0 4px #22c55e80":r==="connected"?"0 0 4px #eab30880":"0 0 4px #ef444480",h=a.filter(g=>g.type==="adhdev-daemon"),f=Object.values(l),p=f.filter(g=>g==="connected").length,m=f.filter(g=>g==="connecting"||g==="new"||g==="checking").length,b=r!=="connected"||h.length===0?null:m>0&&p===0?"P2P connecting...":p>0&&t===0?"Waiting for IDE...":null;return u.jsxs("div",{className:"dashboard-header",children:[u.jsx("div",{className:"flex items-center gap-3",children:u.jsxs("div",{className:"leading-tight",children:[u.jsxs("h1",{className:"header-title m-0 flex items-center gap-1.5",children:[u.jsx(Ya,{size:18}),u.jsx("span",{className:"header-title-desktop",children:"Dashboard"}),u.jsx("span",{className:"header-title-mobile",children:(e==null?void 0:e.displayPrimary)||"Dashboard"}),u.jsx("span",{className:"header-count-mobile text-[10px] font-semibold opacity-60 ml-2 tracking-wide",children:u.jsx("span",{className:"inline-block w-[6px] h-[6px] rounded-full align-middle",style:{background:c,boxShadow:d}})})]}),u.jsxs("div",{className:"header-subtitle text-[11px] items-center gap-1",children:[t," agent",t!==1?"s":""," active",u.jsx("span",{title:n?"Connected":r==="connected"?"Partial":"Disconnected",className:"inline-block w-1.5 h-1.5 rounded-full shrink-0",style:{background:c,boxShadow:d}}),b&&u.jsxs("span",{className:"text-[10px] text-text-muted animate-pulse ml-1",children:["· ",b]})]})]})}),u.jsxs("div",{className:"flex gap-2 items-center",children:[e&&!Au(e)&&!Bu(e)&&u.jsxs("button",{onClick:()=>s(`/ide/${e.ideId}`),className:"btn btn-primary btn-sm border-none px-2.5 py-1.5 flex items-center gap-1 text-xs",title:"IDE View",children:[u.jsx(O0,{size:14})," IDE"]}),e&&!Au(e)&&!Bu(e)&&u.jsx("button",{onClick:i,className:"btn btn-secondary btn-sm border-none bg-bg-secondary px-2.5 py-1.5 flex items-center gap-1",title:"Chat History",children:u.jsx(DP,{size:16})}),e&&!Au(e)&&!Bu(e)&&u.jsx("button",{onClick:()=>s(`/ide/${e.ideId}?view=remote`),className:"btn btn-secondary btn-sm border-none bg-bg-secondary px-2.5 py-1.5",title:"Remote Control",children:u.jsx(ul,{size:16})})]})]})}function Ir(e){return e?e.charAt(0).toUpperCase()+e.slice(1).toLowerCase():"IDE"}function xL(e){if(e<60)return`${Math.round(e)}s`;const t=Math.floor(e/60);if(t<60)return`${t}m`;const r=Math.floor(t/60),n=t%60;if(r<24)return n>0?`${r}h ${n}m`:`${r}h`;const i=Math.floor(r/24),s=r%24;return`${i}d ${s}h`}function P_(e){return e<1024*1024*1024?`${(e/(1024*1024)).toFixed(0)} MB`:`${(e/(1024*1024*1024)).toFixed(1)} GB`}function R_(e){return(e.id||"").includes(":cli:")}function M_(e){return(e.id||"").includes(":acp:")}function Id(e,t){return Ir(e)}function yL(e){if(!Array.isArray(e)||e.length<=1)return e;const t=new Map,r=["generating","streaming","active","connected","idle","panel_hidden"];for(const n of e){const i=(n.name||n.id||"").toLowerCase().replace(/\s+/g,"-"),s=t.get(i);if(!s){t.set(i,n);continue}const o=r.indexOf(s.status||"idle"),l=r.indexOf(n.status||"idle");l>=0&&(o<0||l<o)&&t.set(i,n)}return Array.from(t.values())}function bL({activeConv:e,ides:t,isCreatingChat:r,isRefreshingHistory:n,onClose:i,onNewChat:s,onSwitchSession:o,onRefreshHistory:l}){var h;const a=t.find(f=>f.id===e.ideId),c=(a==null?void 0:a.chats)||[],d=(h=a==null?void 0:a.activeChat)==null?void 0:h.id;return u.jsxs("div",{className:"fixed inset-0 z-[1000] flex items-center justify-center",children:[u.jsx("div",{onClick:i,className:"absolute inset-0 bg-black/60 backdrop-blur-sm"}),u.jsxs("div",{className:"card fade-in relative w-[90%] max-w-[500px] max-h-[80vh] flex flex-col p-0 overflow-hidden shadow-[0_20px_40px_rgba(0,0,0,0.4)] rounded-[20px]",children:[u.jsxs("div",{className:"px-6 py-5 border-b border-border-subtle flex justify-between items-center bg-[var(--surface-primary)]",children:[u.jsxs("div",{children:[u.jsx("h3",{className:"m-0 text-lg font-extrabold",children:"Chat History"}),u.jsxs("div",{className:"text-xs text-text-muted mt-0.5",children:[e.displayPrimary," — ",Ir(e.ideType)]})]}),u.jsx("button",{onClick:i,className:"bg-transparent border-none text-xl text-text-muted cursor-pointer",children:"✕"})]}),u.jsxs("div",{className:"flex-1 overflow-y-auto p-3 bg-bg-primary",children:[u.jsx("button",{onClick:s,disabled:r,className:"w-full p-3.5 rounded-xl mb-3 bg-indigo-500/10 border border-dashed border-accent text-accent font-bold text-sm cursor-pointer",children:r?"⌛ Creating...":"+ Start New Chat Session"}),c.map(f=>u.jsxs("div",{onClick:()=>{o(e.ideId,f.id),i()},className:`p-4 rounded-xl mb-2 cursor-pointer border transition-all ${d===f.id?"bg-[var(--bg-glass-hover)] border-accent":"bg-[var(--surface-secondary)] border-border-subtle"}`,children:[u.jsx("div",{className:`font-bold text-sm mb-1 ${d===f.id?"text-[var(--accent-primary-light)]":"text-text-primary"}`,children:f.title||"Untitled Session"}),u.jsxs("div",{className:"flex justify-between items-center",children:[u.jsxs("div",{className:"text-[11px] text-text-muted font-mono",children:[f.id.substring(0,12),"..."]}),d===f.id&&u.jsx("span",{className:"text-[10px] bg-accent text-white px-2 py-0.5 rounded-[10px] font-extrabold",children:"ACTIVE"})]})]},f.id)),c.length===0&&u.jsxs("div",{className:"py-10 px-5 text-center text-text-muted",children:[u.jsx("div",{className:"text-3xl mb-3 opacity-60",children:u.jsx(WP,{size:32})}),u.jsx("div",{className:"text-[13px]",children:"No recent chat sessions found."})]})]}),u.jsx("div",{className:"px-5 py-4 bg-[var(--surface-tertiary)] border-t border-border-subtle text-right",children:u.jsx("button",{onClick:l,disabled:n,className:"btn btn-secondary btn-sm rounded-[10px]",children:n?"⌛ Refreshing...":u.jsxs("span",{className:"flex items-center gap-1.5",children:[u.jsx(BP,{size:13})," Refresh History"]})})})]})]})}const L_={success:"rgba(16, 185, 129, 0.95)",warning:"rgba(245, 158, 11, 0.95)",info:"rgba(99, 102, 241, 0.95)"};function wL({toasts:e,onDismiss:t,onClickToast:r}){return u.jsx("div",{className:"fixed top-4 right-4 z-[9999] flex flex-col gap-2 pointer-events-none",children:e.map(n=>u.jsxs("div",{className:"fade-in text-white px-5 py-3 rounded-xl text-[13px] font-semibold shadow-[0_8px_32px_rgba(0,0,0,0.3)] backdrop-blur-lg pointer-events-auto cursor-pointer animate-[toast-in_0.3s_ease-out] max-w-[360px]",style:{background:L_[n.type]||L_.info},onClick:()=>{var i;(i=n.actions)!=null&&i.length||(r&&r(n),t(n.id))},children:[u.jsx("div",{children:n.message}),n.actions&&n.actions.length>0&&u.jsx("div",{className:"flex gap-2 mt-2",children:n.actions.map((i,s)=>u.jsx("button",{className:`text-xs px-3 py-1 rounded-md font-bold transition-all cursor-pointer ${i.variant==="primary"?"bg-white text-amber-700 hover:bg-gray-100":i.variant==="danger"?"bg-red-500/30 text-white hover:bg-red-500/50":"bg-white/20 text-white hover:bg-white/30"}`,onClick:o=>{o.stopPropagation(),i.onClick(),t(n.id)},children:i.label},s))})]},n.id))})}const SL=e=>(e.id||"").includes(":cli:")||(e.id||"").includes(":acp:")||(e.id||"").includes(":ide:")?!0:e.daemonId!==e.id;function kL(e){return e.workspace||""}function CL(e,t,r,n){var s;const i={};if(r)for(const o of r){const l=o;if(l.type==="adhdev-daemon"||l.daemonMode){const a=l.machine||{},c=l.machineNickname,d=a.hostname||((s=l.system)==null?void 0:s.hostname)||"",h=c||(d&&d!=="Unknown"?d.replace(/\.local$/,""):null)||`Machine ${(l.id||"").substring(0,6)}`;i[l.id]=h}}return e.flatMap(o=>{var b,g,v,y,S;const l=[],a=o.daemonId&&i[o.daemonId]||void 0,c=o.daemonId||((b=o.id)==null?void 0:b.split(":")[0])||o.id,d=n?n[c]||"new":void 0,h=kL(o),f=Ir(o.type),p=o.agentStreams,m=Array.isArray(p)?p.map(R=>({...R,activeModal:R.activeModal??void 0})):[],_=SL(o);if(_){const R=Id(o.type),E=(g=o.agents)==null?void 0:g[0],P=(v=o.activeChat)==null?void 0:v.activeModal,N=P&&Array.isArray(P.buttons)&&P.buttons.length>0,D=(y=o.activeChat)==null?void 0:y.status,k=D==="generating"||D==="loading"||D&&D.toLowerCase()==="thinking",j=N||D==="waiting_approval"?"waiting_approval":k?"working":(E==null?void 0:E.status)||"idle",M=o.activeChat||{title:"",messages:[]};let C=M.title&&String(M.title).trim()?String(M.title).trim():"";const A=(S=o.activeChat)==null?void 0:S.id,O=o.chats;if(A&&Array.isArray(O)&&O.length>0){const ee=O.find(ne=>ne.id===A||ne.id&&String(ne.id)===String(A));ee!=null&&ee.title&&String(ee.title).trim()&&(C=String(ee.title).trim())}const U=M.messages||[],L=t[o.id]||[],$=new Map;U.filter(ee=>ee.role==="user").forEach(ee=>{$.set(ee.content,($.get(ee.content)||0)+1)});const w=L.filter(ee=>{const ne=$.get(ee.content)||0;return ne>0?($.set(ee.content,ne-1),!1):!0});l.push({ideId:o.id,daemonId:o.daemonId||void 0,agentName:R,agentType:si(o)||ln(o)?o.type:(E==null?void 0:E.type)||"ide-native",status:j,title:C,messages:[...U,...w],ideType:o.type,workspaceName:h,displayPrimary:C||h||R,displaySecondary:f,cdpConnected:o.cdpConnected,modalButtons:N?P.buttons:void 0,modalMessage:N?P.message:void 0,streamSource:"native",tabKey:o.id,machineName:a,connectionState:d})}if(_&&(si(o)||ln(o)))return l;for(const R of m){const E=R.activeModal&&Array.isArray(R.activeModal.buttons)&&R.activeModal.buttons.length>0,P=E?"waiting_approval":R.status==="streaming"?"working":R.status,N=`${o.id}:${R.agentType}`,D=R.messages||[],k=t[N]||[],B=new Map;D.filter(M=>M.role==="user").forEach(M=>{B.set(M.content,(B.get(M.content)||0)+1)});const j=k.filter(M=>{const C=B.get(M.content)||0;return C>0?(B.set(M.content,C-1),!1):!0});l.push({ideId:o.id,daemonId:o.daemonId||void 0,agentName:R.agentName,agentType:R.agentType,status:P,title:"",messages:[...D,...j],ideType:o.type,workspaceName:h,displayPrimary:h||R.agentName,displaySecondary:`${f}·${R.agentName}`,cdpConnected:o.cdpConnected,modalButtons:E?R.activeModal.buttons:void 0,modalMessage:E?R.activeModal.message:void 0,streamSource:"agent-stream",tabKey:N,machineName:a,connectionState:d})}return l.length===0&&l.push({ideId:o.id,daemonId:o.daemonId||void 0,agentName:Id(o.type),agentType:"ide-native",status:"idle",title:"",messages:[],ideType:o.type,workspaceName:h,displayPrimary:h||f,displaySecondary:f,cdpConnected:o.cdpConnected,streamSource:"native",tabKey:o.id,connectionState:d}),l})}function EL(e,t){var l,a,c,d;const r=[],{daemonId:n,existingDaemon:i,timestamp:s}=t,o=s||e.timestamp||Date.now();r.push({...i||{},id:n,type:"adhdev-daemon",status:"online",daemonMode:!0,timestamp:o,...e.version&&{version:e.version},...e.machine&&{machine:e.machine,platform:e.machine.platform},...e.instanceId&&{instanceId:e.instanceId},...e.machineNickname!==void 0&&{machineNickname:e.machineNickname},...e.p2p&&{p2p:e.p2p},..."system"in e&&{system:e.system},..."hostname"in e&&{hostname:e.hostname},...e.workspaces&&{workspaces:e.workspaces},...e.defaultWorkspaceId!==void 0&&{defaultWorkspaceId:e.defaultWorkspaceId},...e.defaultWorkspacePath!==void 0&&{defaultWorkspacePath:e.defaultWorkspacePath},...e.workspaceActivity&&{workspaceActivity:e.workspaceActivity},...e.detectedIdes&&{detectedIdes:e.detectedIdes},..."availableProviders"in e&&{availableProviders:e.availableProviders},cdpConnected:e.managedIdes.some(h=>h.cdpConnected),managedIdeIds:e.managedIdes.map(h=>`${n}:ide:${h.instanceId}`),managedCliIds:e.managedClis.map(h=>h.id?`${n}:cli:${h.id}`:`${n}:cli:${h.cliType}`),managedAcpIds:e.managedAcps.map(h=>h.id?`${n}:acp:${h.id}`:`${n}:acp:${h.acpType}`)});for(const h of e.managedIdes)r.push({id:`${n}:ide:${h.instanceId}`,type:h.ideType,ideType:h.ideType,version:h.ideVersion,status:h.cdpConnected?"online":"detected",daemonId:n,instanceId:h.instanceId,workspace:h.workspace,terminals:h.terminals,agents:h.aiAgents,activeChat:h.activeChat,chats:h.chats,agentStreams:h.agentStreams,cdpConnected:h.cdpConnected,currentModel:h.currentModel,currentPlan:h.currentPlan,currentAutoApprove:h.currentAutoApprove,timestamp:o});for(const h of e.managedClis){const f=h.id?`${n}:cli:${h.id}`:`${n}:cli:${h.cliType}`;r.push({id:f,type:h.cliType,ideType:h.cliType,agentType:h.cliType,status:h.status||"running",daemonId:n,instanceId:h.id,cliName:h.cliName,mode:h.mode||"terminal",workspace:h.workspace,activeChat:h.activeChat,agentStreams:[{agentType:h.cliType,agentName:h.cliName,extensionId:"cli-agent",status:h.status==="generating"?"streaming":h.status==="waiting_approval"?"waiting_approval":"idle",messages:((l=h.activeChat)==null?void 0:l.messages)||[],inputContent:"",activeModal:(a=h.activeChat)==null?void 0:a.activeModal}],timestamp:o,_isCli:!0})}for(const h of e.managedAcps){const f=h.id?`${n}:acp:${h.id}`:`${n}:acp:${h.acpType}`;r.push({id:f,type:h.acpType,ideType:h.acpType,agentType:h.acpType,status:h.status||"running",daemonId:n,instanceId:h.id,cliName:h.acpName,mode:"chat",workspace:h.workspace,activeChat:h.activeChat,currentModel:h.currentModel,currentPlan:h.currentPlan,acpConfigOptions:h.acpConfigOptions,acpModes:h.acpModes,agentStreams:[{agentType:h.acpType,agentName:h.acpName,extensionId:"acp-agent",status:h.status==="generating"?"streaming":h.status==="waiting_approval"?"waiting_approval":"idle",messages:((c=h.activeChat)==null?void 0:c.messages)||[],inputContent:"",activeModal:(d=h.activeChat)==null?void 0:d.activeModal}],timestamp:o,_isAcp:!0})}return r}const j1="adhdev_notification_prefs",I_={globalEnabled:!0,disconnectAlert:!0,browserNotifications:!0,completionAlert:!0,approvalAlert:!0};function NL(){try{const e=localStorage.getItem(j1);if(e){const t=JSON.parse(e);return{...I_,...t}}}catch{}return{...I_}}function TL(e){try{localStorage.setItem(j1,JSON.stringify(e))}catch{}}let gn=NL(),ma=[];function PL(){ma.forEach(e=>e())}function RL(e){gn={...gn,...e},TL(gn),PL()}function ML(){const[,e]=x.useState(0);x.useEffect(()=>{const r=()=>e(n=>n+1);return ma.push(r),()=>{ma=ma.filter(n=>n!==r)}},[]);const t=x.useCallback(r=>{RL(r)},[]);return[{...gn},t]}function ko(e){if(!gn.globalEnabled)return!1;switch(e){case"disconnect":return gn.disconnectAlert;case"completion":return gn.completionAlert;case"approval":return gn.approvalAlert;case"browser":return gn.browserNotifications;default:return!0}}const LL={enabled:!0,onApproval:!0,onComplete:!0,onError:!0,throttleMs:5e3};async function IL(){return"Notification"in window?Notification.permission==="granted"?"granted":Notification.permission==="denied"?"denied":Notification.requestPermission():"denied"}function D1(){return"Notification"in window&&Notification.permission==="granted"}let mi=null;async function jL(){if(mi!==null)return mi;try{if(!("serviceWorker"in navigator)||!("PushManager"in window))return mi=!1,!1;const e=await navigator.serviceWorker.getRegistration();return e?(mi=!!await e.pushManager.getSubscription(),mi):(mi=!1,!1)}catch{return mi=!1,!1}}function jd(e,t,r){if(D1())try{const n=new Notification(e,{body:t,icon:"/otter-logo.png",tag:r||`adhdev-${Date.now()}`,silent:!1});setTimeout(()=>n.close(),8e3),n.onclick=()=>{window.focus(),n.close()}}catch{}}function DL(e,t={}){const r={...LL,...t},n=x.useRef(new Map),i=x.useRef(0),s=x.useRef(null);x.useEffect(()=>{jL().then(l=>{s.current=l})},[]);const o=x.useCallback((l,a,c)=>{const d=Date.now();d-i.current<r.throttleMs||(i.current=d,jd(l,a,c))},[r.throttleMs]);x.useEffect(()=>{var l;if(!(!r.enabled||!D1())&&ko("browser")&&s.current!==!0){if(document.hasFocus()){for(const a of e)n.current.set(a.id,a.status||"idle");return}for(const a of e){const c=n.current.get(a.id),d=a.status||"idle",h=a.name||a.id;if(r.onApproval&&ko("approval")&&d==="waiting_approval"&&c!=="waiting_approval"){const f=((l=a.activeModal)==null?void 0:l.message)||"Action requires your approval";o(`🔔 ${h} — Approval needed`,f.slice(0,120),`approval-${a.id}`)}r.onComplete&&ko("completion")&&c==="generating"&&d==="idle"&&o(`✅ ${h} — Task complete`,"Agent has finished working",`complete-${a.id}`),r.onError&&d==="error"&&c!=="error"&&o(`⚠️ ${h} — Error`,"Agent encountered an error",`error-${a.id}`),n.current.set(a.id,d)}}},[e,r.enabled,r.onApproval,r.onComplete,r.onError,o])}class AL{constructor(){Yt(this,"dedupMap",new Map);Yt(this,"DEDUP_WINDOW_MS",5e3);Yt(this,"DEDUP_MAX_SIZE",50);Yt(this,"DEDUP_CLEANUP_AGE_MS",1e4);Yt(this,"toastCallbacks",[]);Yt(this,"systemMessageCallbacks",[]);Yt(this,"clearSystemMessageCallbacks",[]);Yt(this,"resolveActionFn",null);Yt(this,"viewRequestRespondFn",null);Yt(this,"ides",[])}onToast(t){return this.toastCallbacks.push(t),()=>{this.toastCallbacks=this.toastCallbacks.filter(r=>r!==t)}}onSystemMessage(t){return this.systemMessageCallbacks.push(t),()=>{this.systemMessageCallbacks=this.systemMessageCallbacks.filter(r=>r!==t)}}onClearSystemMessage(t){return this.clearSystemMessageCallbacks.push(t),()=>{this.clearSystemMessageCallbacks=this.clearSystemMessageCallbacks.filter(r=>r!==t)}}setResolveAction(t){this.resolveActionFn=t}setIdes(t){this.ides=t}setViewRequestRespond(t){this.viewRequestRespondFn=t}emitToast(t){for(const r of this.toastCallbacks)r(t)}emitSystemMessage(t,r){for(const n of this.systemMessageCallbacks)n(t,r)}emitClearSystemMessage(t,r){for(const n of this.clearSystemMessageCallbacks)n(t,r)}isDuplicate(t){const r=Date.now(),n=this.dedupMap.get(t)||0;if(r-n<this.DEDUP_WINDOW_MS)return!0;if(this.dedupMap.set(t,r),this.dedupMap.size>this.DEDUP_MAX_SIZE)for(const[i,s]of this.dedupMap)r-s>this.DEDUP_CLEANUP_AGE_MS&&this.dedupMap.delete(i);return!1}resolveRouteId(t,r){for(const n of this.ides)if(n.id.startsWith(t)&&(!r||r===n.type))return n.id;return t}handleRawEvent(t,r){var l,a;const n=`${t.ideId||""}:${t.event}`;if(this.isDuplicate(n))return;const i=Ir(t.ideType||"");let s="",o="info";if(t.event==="agent:generating_completed"){const c=t.duration?` (${t.duration}s)`:"";s=`✅ ${i} agent task completed${c}`,o="success";try{new Audio("data:audio/wav;base64,UklGRigAAABXQVZFZm10IBAAAAABAAEAQB8AAEAfAAABAAgAZGF0YQQAAAB/f39/").play().catch(()=>{})}catch{}t.ideId&&this.emitSystemMessage(t.ideId,{role:"system",timestamp:Date.now(),content:`✅ Task completed${c}`,_localId:`sys_complete_${Date.now()}`})}else if(t.event==="agent:generating_started")t.ideId&&this.emitClearSystemMessage(t.ideId,"sys_complete_");else if(t.event==="agent:waiting_approval"){if(s=`⚡ ${i} approval needed`,o="warning",t.ideId){const c=t.modalMessage||"Approval requested",d=(l=t.modalButtons)!=null&&l.length?t.modalButtons.map(h=>`[${h}]`).join(" "):"[Approve] [Reject]";this.emitSystemMessage(t.ideId,{role:"system",timestamp:Date.now(),content:`⚡ Approval requested: ${c}
|
|
173
|
-
${d}`,_localId:`sys_approval_${Date.now()}`})}if(t.ideId&&((a=t.modalButtons)!=null&&a.length)&&this.resolveActionFn){const c=t.ideId,d=t.agentType||t.ideType||"",h=t.ideType||"",f=t.modalButtons,p=v=>v.replace(/[⌥⏎⇧⌫⌘⌃↵]/g,"").replace(/\s*(Alt|Ctrl|Shift|Cmd|Enter|Return|Esc|Tab|Backspace)(\+\s*\w+)*/gi,"").trim(),m=this.resolveActionFn,_=f.map((v,y)=>{const S=p(v).toLowerCase(),R=/^(run|approve|accept|yes|allow|always)/.test(S),E=/^(reject|deny|delete|remove|abort|cancel|no)/.test(S);return{label:p(v),variant:R?"primary":E?"danger":"default",onClick:()=>{const P=this.resolveRouteId(c,d),N=/^(run|approve|accept|yes|allow|always|proceed|save)/.test(S);m(P,"resolve_action",{action:N?"approve":"reject",button:v,buttonIndex:y,agentType:d,ideType:h})}}}),b=t.modalMessage?`⚡ ${i}: ${t.modalMessage.replace(/[\n\r]+/g," ").slice(0,80)}`:s,g=Date.now();this.emitToast({id:g,message:b,type:o,timestamp:g,ideId:c,actions:_,duration:15e3}),s=""}}else if(t.event==="monitor:long_generating"){const c=t.elapsedSec?` (${Math.round(t.elapsedSec/60)}m)`:"";s=`⚠️ ${i} agent is taking a long time${c}`,o="warning",ko("browser")&&!document.hasFocus()&&jd(`⚠️ ${i} — Long Running`,`Agent has been generating for over ${c.replace(/[()]/g,"")}`,`long-${t.ideId||t.agentType}`)}else if(t.event==="team:view_request"){const c=t.requesterName||"A team member",d=t.requestId,h=t.orgId;if(s=`👁️ ${c} wants to view your session`,o="warning",d&&h&&this.viewRequestRespondFn){const f=this.viewRequestRespondFn,p=Date.now(),m=[{label:"Approve",variant:"primary",onClick:()=>{f(h,d,"approve").catch(_=>console.error("[EventManager] approve view request failed:",_))}},{label:"Decline",variant:"danger",onClick:()=>{f(h,d,"reject").catch(_=>console.error("[EventManager] reject view request failed:",_))}}];this.emitToast({id:p,message:s,type:o,timestamp:p,actions:m,duration:3e4}),s=""}ko("browser")&&!document.hasFocus()&&jd("👁️ View Request",`${c} wants to view your session`,`view-request-${d}`)}else t.event==="team:view_request_approved"?(s="✅ View request approved",o="success"):t.event==="team:view_request_rejected"&&(s=`❌ ${t.targetName||"Team member"} declined your view request`,o="warning");if(s){const c=Date.now();this.emitToast({id:c,message:s,type:o,timestamp:c,ideId:t.ideId,duration:5e3})}}}const gi=new AL;function A1(e){var t,r,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(r=A1(e[t]))&&(n&&(n+=" "),n+=r)}else for(r in e)e[r]&&(n&&(n+=" "),n+=r);return n}function BL(){for(var e,t,r=0,n="",i=arguments.length;r<i;r++)(e=arguments[r])&&(t=A1(e))&&(n&&(n+=" "),n+=t);return n}const OL=(e,t)=>{const r=new Array(e.length+t.length);for(let n=0;n<e.length;n++)r[n]=e[n];for(let n=0;n<t.length;n++)r[e.length+n]=t[n];return r},zL=(e,t)=>({classGroupId:e,validator:t}),B1=(e=new Map,t=null,r)=>({nextPart:e,validators:t,classGroupId:r}),rc="-",j_=[],$L="arbitrary..",FL=e=>{const t=HL(e),{conflictingClassGroups:r,conflictingClassGroupModifiers:n}=e;return{getClassGroupId:o=>{if(o.startsWith("[")&&o.endsWith("]"))return WL(o);const l=o.split(rc),a=l[0]===""&&l.length>1?1:0;return O1(l,a,t)},getConflictingClassGroupIds:(o,l)=>{if(l){const a=n[o],c=r[o];return a?c?OL(c,a):a:c||j_}return r[o]||j_}}},O1=(e,t,r)=>{if(e.length-t===0)return r.classGroupId;const i=e[t],s=r.nextPart.get(i);if(s){const c=O1(e,t+1,s);if(c)return c}const o=r.validators;if(o===null)return;const l=t===0?e.join(rc):e.slice(t).join(rc),a=o.length;for(let c=0;c<a;c++){const d=o[c];if(d.validator(l))return d.classGroupId}},WL=e=>e.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const t=e.slice(1,-1),r=t.indexOf(":"),n=t.slice(0,r);return n?$L+n:void 0})(),HL=e=>{const{theme:t,classGroups:r}=e;return UL(r,t)},UL=(e,t)=>{const r=B1();for(const n in e){const i=e[n];dp(i,r,n,t)}return r},dp=(e,t,r,n)=>{const i=e.length;for(let s=0;s<i;s++){const o=e[s];KL(o,t,r,n)}},KL=(e,t,r,n)=>{if(typeof e=="string"){VL(e,t,r);return}if(typeof e=="function"){qL(e,t,r,n);return}YL(e,t,r,n)},VL=(e,t,r)=>{const n=e===""?t:z1(t,e);n.classGroupId=r},qL=(e,t,r,n)=>{if(XL(e)){dp(e(n),t,r,n);return}t.validators===null&&(t.validators=[]),t.validators.push(zL(r,e))},YL=(e,t,r,n)=>{const i=Object.entries(e),s=i.length;for(let o=0;o<s;o++){const[l,a]=i[o];dp(a,z1(t,l),r,n)}},z1=(e,t)=>{let r=e;const n=t.split(rc),i=n.length;for(let s=0;s<i;s++){const o=n[s];let l=r.nextPart.get(o);l||(l=B1(),r.nextPart.set(o,l)),r=l}return r},XL=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,GL=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,r=Object.create(null),n=Object.create(null);const i=(s,o)=>{r[s]=o,t++,t>e&&(t=0,n=r,r=Object.create(null))};return{get(s){let o=r[s];if(o!==void 0)return o;if((o=n[s])!==void 0)return i(s,o),o},set(s,o){s in r?r[s]=o:i(s,o)}}},Dd="!",D_=":",QL=[],A_=(e,t,r,n,i)=>({modifiers:e,hasImportantModifier:t,baseClassName:r,maybePostfixModifierPosition:n,isExternal:i}),JL=e=>{const{prefix:t,experimentalParseClassName:r}=e;let n=i=>{const s=[];let o=0,l=0,a=0,c;const d=i.length;for(let _=0;_<d;_++){const b=i[_];if(o===0&&l===0){if(b===D_){s.push(i.slice(a,_)),a=_+1;continue}if(b==="/"){c=_;continue}}b==="["?o++:b==="]"?o--:b==="("?l++:b===")"&&l--}const h=s.length===0?i:i.slice(a);let f=h,p=!1;h.endsWith(Dd)?(f=h.slice(0,-1),p=!0):h.startsWith(Dd)&&(f=h.slice(1),p=!0);const m=c&&c>a?c-a:void 0;return A_(s,p,f,m)};if(t){const i=t+D_,s=n;n=o=>o.startsWith(i)?s(o.slice(i.length)):A_(QL,!1,o,void 0,!0)}if(r){const i=n;n=s=>r({className:s,parseClassName:i})}return n},ZL=e=>{const t=new Map;return e.orderSensitiveModifiers.forEach((r,n)=>{t.set(r,1e6+n)}),r=>{const n=[];let i=[];for(let s=0;s<r.length;s++){const o=r[s],l=o[0]==="[",a=t.has(o);l||a?(i.length>0&&(i.sort(),n.push(...i),i=[]),n.push(o)):i.push(o)}return i.length>0&&(i.sort(),n.push(...i)),n}},e4=e=>({cache:GL(e.cacheSize),parseClassName:JL(e),sortModifiers:ZL(e),...FL(e)}),t4=/\s+/,r4=(e,t)=>{const{parseClassName:r,getClassGroupId:n,getConflictingClassGroupIds:i,sortModifiers:s}=t,o=[],l=e.trim().split(t4);let a="";for(let c=l.length-1;c>=0;c-=1){const d=l[c],{isExternal:h,modifiers:f,hasImportantModifier:p,baseClassName:m,maybePostfixModifierPosition:_}=r(d);if(h){a=d+(a.length>0?" "+a:a);continue}let b=!!_,g=n(b?m.substring(0,_):m);if(!g){if(!b){a=d+(a.length>0?" "+a:a);continue}if(g=n(m),!g){a=d+(a.length>0?" "+a:a);continue}b=!1}const v=f.length===0?"":f.length===1?f[0]:s(f).join(":"),y=p?v+Dd:v,S=y+g;if(o.indexOf(S)>-1)continue;o.push(S);const R=i(g,b);for(let E=0;E<R.length;++E){const P=R[E];o.push(y+P)}a=d+(a.length>0?" "+a:a)}return a},n4=(...e)=>{let t=0,r,n,i="";for(;t<e.length;)(r=e[t++])&&(n=$1(r))&&(i&&(i+=" "),i+=n);return i},$1=e=>{if(typeof e=="string")return e;let t,r="";for(let n=0;n<e.length;n++)e[n]&&(t=$1(e[n]))&&(r&&(r+=" "),r+=t);return r},i4=(e,...t)=>{let r,n,i,s;const o=a=>{const c=t.reduce((d,h)=>h(d),e());return r=e4(c),n=r.cache.get,i=r.cache.set,s=l,l(a)},l=a=>{const c=n(a);if(c)return c;const d=r4(a,r);return i(a,d),d};return s=o,(...a)=>s(n4(...a))},s4=[],wt=e=>{const t=r=>r[e]||s4;return t.isThemeGetter=!0,t},F1=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,W1=/^\((?:(\w[\w-]*):)?(.+)\)$/i,o4=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,l4=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,a4=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,c4=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,u4=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,h4=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,An=e=>o4.test(e),Ae=e=>!!e&&!Number.isNaN(Number(e)),Bn=e=>!!e&&Number.isInteger(Number(e)),Ou=e=>e.endsWith("%")&&Ae(e.slice(0,-1)),hn=e=>l4.test(e),H1=()=>!0,d4=e=>a4.test(e)&&!c4.test(e),fp=()=>!1,f4=e=>u4.test(e),p4=e=>h4.test(e),m4=e=>!ge(e)&&!_e(e),g4=e=>di(e,V1,fp),ge=e=>F1.test(e),_i=e=>di(e,q1,d4),B_=e=>di(e,k4,Ae),_4=e=>di(e,X1,H1),v4=e=>di(e,Y1,fp),O_=e=>di(e,U1,fp),x4=e=>di(e,K1,p4),Ul=e=>di(e,G1,f4),_e=e=>W1.test(e),Zs=e=>Vi(e,q1),y4=e=>Vi(e,Y1),z_=e=>Vi(e,U1),b4=e=>Vi(e,V1),w4=e=>Vi(e,K1),Kl=e=>Vi(e,G1,!0),S4=e=>Vi(e,X1,!0),di=(e,t,r)=>{const n=F1.exec(e);return n?n[1]?t(n[1]):r(n[2]):!1},Vi=(e,t,r=!1)=>{const n=W1.exec(e);return n?n[1]?t(n[1]):r:!1},U1=e=>e==="position"||e==="percentage",K1=e=>e==="image"||e==="url",V1=e=>e==="length"||e==="size"||e==="bg-size",q1=e=>e==="length",k4=e=>e==="number",Y1=e=>e==="family-name",X1=e=>e==="number"||e==="weight",G1=e=>e==="shadow",C4=()=>{const e=wt("color"),t=wt("font"),r=wt("text"),n=wt("font-weight"),i=wt("tracking"),s=wt("leading"),o=wt("breakpoint"),l=wt("container"),a=wt("spacing"),c=wt("radius"),d=wt("shadow"),h=wt("inset-shadow"),f=wt("text-shadow"),p=wt("drop-shadow"),m=wt("blur"),_=wt("perspective"),b=wt("aspect"),g=wt("ease"),v=wt("animate"),y=()=>["auto","avoid","all","avoid-page","page","left","right","column"],S=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],R=()=>[...S(),_e,ge],E=()=>["auto","hidden","clip","visible","scroll"],P=()=>["auto","contain","none"],N=()=>[_e,ge,a],D=()=>[An,"full","auto",...N()],k=()=>[Bn,"none","subgrid",_e,ge],B=()=>["auto",{span:["full",Bn,_e,ge]},Bn,_e,ge],j=()=>[Bn,"auto",_e,ge],M=()=>["auto","min","max","fr",_e,ge],C=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],A=()=>["start","end","center","stretch","center-safe","end-safe"],O=()=>["auto",...N()],U=()=>[An,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...N()],L=()=>[An,"screen","full","dvw","lvw","svw","min","max","fit",...N()],$=()=>[An,"screen","full","lh","dvh","lvh","svh","min","max","fit",...N()],w=()=>[e,_e,ge],ee=()=>[...S(),z_,O_,{position:[_e,ge]}],ne=()=>["no-repeat",{repeat:["","x","y","space","round"]}],T=()=>["auto","cover","contain",b4,g4,{size:[_e,ge]}],X=()=>[Ou,Zs,_i],I=()=>["","none","full",c,_e,ge],F=()=>["",Ae,Zs,_i],G=()=>["solid","dashed","dotted","double"],he=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],me=()=>[Ae,Ou,z_,O_],je=()=>["","none",m,_e,ge],Pe=()=>["none",Ae,_e,ge],Ce=()=>["none",Ae,_e,ge],de=()=>[Ae,_e,ge],Te=()=>[An,"full",...N()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[hn],breakpoint:[hn],color:[H1],container:[hn],"drop-shadow":[hn],ease:["in","out","in-out"],font:[m4],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[hn],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[hn],shadow:[hn],spacing:["px",Ae],text:[hn],"text-shadow":[hn],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",An,ge,_e,b]}],container:["container"],columns:[{columns:[Ae,ge,_e,l]}],"break-after":[{"break-after":y()}],"break-before":[{"break-before":y()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:R()}],overflow:[{overflow:E()}],"overflow-x":[{"overflow-x":E()}],"overflow-y":[{"overflow-y":E()}],overscroll:[{overscroll:P()}],"overscroll-x":[{"overscroll-x":P()}],"overscroll-y":[{"overscroll-y":P()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:D()}],"inset-x":[{"inset-x":D()}],"inset-y":[{"inset-y":D()}],start:[{"inset-s":D(),start:D()}],end:[{"inset-e":D(),end:D()}],"inset-bs":[{"inset-bs":D()}],"inset-be":[{"inset-be":D()}],top:[{top:D()}],right:[{right:D()}],bottom:[{bottom:D()}],left:[{left:D()}],visibility:["visible","invisible","collapse"],z:[{z:[Bn,"auto",_e,ge]}],basis:[{basis:[An,"full","auto",l,...N()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Ae,An,"auto","initial","none",ge]}],grow:[{grow:["",Ae,_e,ge]}],shrink:[{shrink:["",Ae,_e,ge]}],order:[{order:[Bn,"first","last","none",_e,ge]}],"grid-cols":[{"grid-cols":k()}],"col-start-end":[{col:B()}],"col-start":[{"col-start":j()}],"col-end":[{"col-end":j()}],"grid-rows":[{"grid-rows":k()}],"row-start-end":[{row:B()}],"row-start":[{"row-start":j()}],"row-end":[{"row-end":j()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":M()}],"auto-rows":[{"auto-rows":M()}],gap:[{gap:N()}],"gap-x":[{"gap-x":N()}],"gap-y":[{"gap-y":N()}],"justify-content":[{justify:[...C(),"normal"]}],"justify-items":[{"justify-items":[...A(),"normal"]}],"justify-self":[{"justify-self":["auto",...A()]}],"align-content":[{content:["normal",...C()]}],"align-items":[{items:[...A(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...A(),{baseline:["","last"]}]}],"place-content":[{"place-content":C()}],"place-items":[{"place-items":[...A(),"baseline"]}],"place-self":[{"place-self":["auto",...A()]}],p:[{p:N()}],px:[{px:N()}],py:[{py:N()}],ps:[{ps:N()}],pe:[{pe:N()}],pbs:[{pbs:N()}],pbe:[{pbe:N()}],pt:[{pt:N()}],pr:[{pr:N()}],pb:[{pb:N()}],pl:[{pl:N()}],m:[{m:O()}],mx:[{mx:O()}],my:[{my:O()}],ms:[{ms:O()}],me:[{me:O()}],mbs:[{mbs:O()}],mbe:[{mbe:O()}],mt:[{mt:O()}],mr:[{mr:O()}],mb:[{mb:O()}],ml:[{ml:O()}],"space-x":[{"space-x":N()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":N()}],"space-y-reverse":["space-y-reverse"],size:[{size:U()}],"inline-size":[{inline:["auto",...L()]}],"min-inline-size":[{"min-inline":["auto",...L()]}],"max-inline-size":[{"max-inline":["none",...L()]}],"block-size":[{block:["auto",...$()]}],"min-block-size":[{"min-block":["auto",...$()]}],"max-block-size":[{"max-block":["none",...$()]}],w:[{w:[l,"screen",...U()]}],"min-w":[{"min-w":[l,"screen","none",...U()]}],"max-w":[{"max-w":[l,"screen","none","prose",{screen:[o]},...U()]}],h:[{h:["screen","lh",...U()]}],"min-h":[{"min-h":["screen","lh","none",...U()]}],"max-h":[{"max-h":["screen","lh",...U()]}],"font-size":[{text:["base",r,Zs,_i]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[n,S4,_4]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Ou,ge]}],"font-family":[{font:[y4,v4,t]}],"font-features":[{"font-features":[ge]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[i,_e,ge]}],"line-clamp":[{"line-clamp":[Ae,"none",_e,B_]}],leading:[{leading:[s,...N()]}],"list-image":[{"list-image":["none",_e,ge]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",_e,ge]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:w()}],"text-color":[{text:w()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...G(),"wavy"]}],"text-decoration-thickness":[{decoration:[Ae,"from-font","auto",_e,_i]}],"text-decoration-color":[{decoration:w()}],"underline-offset":[{"underline-offset":[Ae,"auto",_e,ge]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:N()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",_e,ge]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",_e,ge]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:ee()}],"bg-repeat":[{bg:ne()}],"bg-size":[{bg:T()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Bn,_e,ge],radial:["",_e,ge],conic:[Bn,_e,ge]},w4,x4]}],"bg-color":[{bg:w()}],"gradient-from-pos":[{from:X()}],"gradient-via-pos":[{via:X()}],"gradient-to-pos":[{to:X()}],"gradient-from":[{from:w()}],"gradient-via":[{via:w()}],"gradient-to":[{to:w()}],rounded:[{rounded:I()}],"rounded-s":[{"rounded-s":I()}],"rounded-e":[{"rounded-e":I()}],"rounded-t":[{"rounded-t":I()}],"rounded-r":[{"rounded-r":I()}],"rounded-b":[{"rounded-b":I()}],"rounded-l":[{"rounded-l":I()}],"rounded-ss":[{"rounded-ss":I()}],"rounded-se":[{"rounded-se":I()}],"rounded-ee":[{"rounded-ee":I()}],"rounded-es":[{"rounded-es":I()}],"rounded-tl":[{"rounded-tl":I()}],"rounded-tr":[{"rounded-tr":I()}],"rounded-br":[{"rounded-br":I()}],"rounded-bl":[{"rounded-bl":I()}],"border-w":[{border:F()}],"border-w-x":[{"border-x":F()}],"border-w-y":[{"border-y":F()}],"border-w-s":[{"border-s":F()}],"border-w-e":[{"border-e":F()}],"border-w-bs":[{"border-bs":F()}],"border-w-be":[{"border-be":F()}],"border-w-t":[{"border-t":F()}],"border-w-r":[{"border-r":F()}],"border-w-b":[{"border-b":F()}],"border-w-l":[{"border-l":F()}],"divide-x":[{"divide-x":F()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":F()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...G(),"hidden","none"]}],"divide-style":[{divide:[...G(),"hidden","none"]}],"border-color":[{border:w()}],"border-color-x":[{"border-x":w()}],"border-color-y":[{"border-y":w()}],"border-color-s":[{"border-s":w()}],"border-color-e":[{"border-e":w()}],"border-color-bs":[{"border-bs":w()}],"border-color-be":[{"border-be":w()}],"border-color-t":[{"border-t":w()}],"border-color-r":[{"border-r":w()}],"border-color-b":[{"border-b":w()}],"border-color-l":[{"border-l":w()}],"divide-color":[{divide:w()}],"outline-style":[{outline:[...G(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Ae,_e,ge]}],"outline-w":[{outline:["",Ae,Zs,_i]}],"outline-color":[{outline:w()}],shadow:[{shadow:["","none",d,Kl,Ul]}],"shadow-color":[{shadow:w()}],"inset-shadow":[{"inset-shadow":["none",h,Kl,Ul]}],"inset-shadow-color":[{"inset-shadow":w()}],"ring-w":[{ring:F()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:w()}],"ring-offset-w":[{"ring-offset":[Ae,_i]}],"ring-offset-color":[{"ring-offset":w()}],"inset-ring-w":[{"inset-ring":F()}],"inset-ring-color":[{"inset-ring":w()}],"text-shadow":[{"text-shadow":["none",f,Kl,Ul]}],"text-shadow-color":[{"text-shadow":w()}],opacity:[{opacity:[Ae,_e,ge]}],"mix-blend":[{"mix-blend":[...he(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":he()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[Ae]}],"mask-image-linear-from-pos":[{"mask-linear-from":me()}],"mask-image-linear-to-pos":[{"mask-linear-to":me()}],"mask-image-linear-from-color":[{"mask-linear-from":w()}],"mask-image-linear-to-color":[{"mask-linear-to":w()}],"mask-image-t-from-pos":[{"mask-t-from":me()}],"mask-image-t-to-pos":[{"mask-t-to":me()}],"mask-image-t-from-color":[{"mask-t-from":w()}],"mask-image-t-to-color":[{"mask-t-to":w()}],"mask-image-r-from-pos":[{"mask-r-from":me()}],"mask-image-r-to-pos":[{"mask-r-to":me()}],"mask-image-r-from-color":[{"mask-r-from":w()}],"mask-image-r-to-color":[{"mask-r-to":w()}],"mask-image-b-from-pos":[{"mask-b-from":me()}],"mask-image-b-to-pos":[{"mask-b-to":me()}],"mask-image-b-from-color":[{"mask-b-from":w()}],"mask-image-b-to-color":[{"mask-b-to":w()}],"mask-image-l-from-pos":[{"mask-l-from":me()}],"mask-image-l-to-pos":[{"mask-l-to":me()}],"mask-image-l-from-color":[{"mask-l-from":w()}],"mask-image-l-to-color":[{"mask-l-to":w()}],"mask-image-x-from-pos":[{"mask-x-from":me()}],"mask-image-x-to-pos":[{"mask-x-to":me()}],"mask-image-x-from-color":[{"mask-x-from":w()}],"mask-image-x-to-color":[{"mask-x-to":w()}],"mask-image-y-from-pos":[{"mask-y-from":me()}],"mask-image-y-to-pos":[{"mask-y-to":me()}],"mask-image-y-from-color":[{"mask-y-from":w()}],"mask-image-y-to-color":[{"mask-y-to":w()}],"mask-image-radial":[{"mask-radial":[_e,ge]}],"mask-image-radial-from-pos":[{"mask-radial-from":me()}],"mask-image-radial-to-pos":[{"mask-radial-to":me()}],"mask-image-radial-from-color":[{"mask-radial-from":w()}],"mask-image-radial-to-color":[{"mask-radial-to":w()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":S()}],"mask-image-conic-pos":[{"mask-conic":[Ae]}],"mask-image-conic-from-pos":[{"mask-conic-from":me()}],"mask-image-conic-to-pos":[{"mask-conic-to":me()}],"mask-image-conic-from-color":[{"mask-conic-from":w()}],"mask-image-conic-to-color":[{"mask-conic-to":w()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:ee()}],"mask-repeat":[{mask:ne()}],"mask-size":[{mask:T()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",_e,ge]}],filter:[{filter:["","none",_e,ge]}],blur:[{blur:je()}],brightness:[{brightness:[Ae,_e,ge]}],contrast:[{contrast:[Ae,_e,ge]}],"drop-shadow":[{"drop-shadow":["","none",p,Kl,Ul]}],"drop-shadow-color":[{"drop-shadow":w()}],grayscale:[{grayscale:["",Ae,_e,ge]}],"hue-rotate":[{"hue-rotate":[Ae,_e,ge]}],invert:[{invert:["",Ae,_e,ge]}],saturate:[{saturate:[Ae,_e,ge]}],sepia:[{sepia:["",Ae,_e,ge]}],"backdrop-filter":[{"backdrop-filter":["","none",_e,ge]}],"backdrop-blur":[{"backdrop-blur":je()}],"backdrop-brightness":[{"backdrop-brightness":[Ae,_e,ge]}],"backdrop-contrast":[{"backdrop-contrast":[Ae,_e,ge]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Ae,_e,ge]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Ae,_e,ge]}],"backdrop-invert":[{"backdrop-invert":["",Ae,_e,ge]}],"backdrop-opacity":[{"backdrop-opacity":[Ae,_e,ge]}],"backdrop-saturate":[{"backdrop-saturate":[Ae,_e,ge]}],"backdrop-sepia":[{"backdrop-sepia":["",Ae,_e,ge]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":N()}],"border-spacing-x":[{"border-spacing-x":N()}],"border-spacing-y":[{"border-spacing-y":N()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",_e,ge]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Ae,"initial",_e,ge]}],ease:[{ease:["linear","initial",g,_e,ge]}],delay:[{delay:[Ae,_e,ge]}],animate:[{animate:["none",v,_e,ge]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[_,_e,ge]}],"perspective-origin":[{"perspective-origin":R()}],rotate:[{rotate:Pe()}],"rotate-x":[{"rotate-x":Pe()}],"rotate-y":[{"rotate-y":Pe()}],"rotate-z":[{"rotate-z":Pe()}],scale:[{scale:Ce()}],"scale-x":[{"scale-x":Ce()}],"scale-y":[{"scale-y":Ce()}],"scale-z":[{"scale-z":Ce()}],"scale-3d":["scale-3d"],skew:[{skew:de()}],"skew-x":[{"skew-x":de()}],"skew-y":[{"skew-y":de()}],transform:[{transform:[_e,ge,"","none","gpu","cpu"]}],"transform-origin":[{origin:R()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:Te()}],"translate-x":[{"translate-x":Te()}],"translate-y":[{"translate-y":Te()}],"translate-z":[{"translate-z":Te()}],"translate-none":["translate-none"],accent:[{accent:w()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:w()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",_e,ge]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":N()}],"scroll-mx":[{"scroll-mx":N()}],"scroll-my":[{"scroll-my":N()}],"scroll-ms":[{"scroll-ms":N()}],"scroll-me":[{"scroll-me":N()}],"scroll-mbs":[{"scroll-mbs":N()}],"scroll-mbe":[{"scroll-mbe":N()}],"scroll-mt":[{"scroll-mt":N()}],"scroll-mr":[{"scroll-mr":N()}],"scroll-mb":[{"scroll-mb":N()}],"scroll-ml":[{"scroll-ml":N()}],"scroll-p":[{"scroll-p":N()}],"scroll-px":[{"scroll-px":N()}],"scroll-py":[{"scroll-py":N()}],"scroll-ps":[{"scroll-ps":N()}],"scroll-pe":[{"scroll-pe":N()}],"scroll-pbs":[{"scroll-pbs":N()}],"scroll-pbe":[{"scroll-pbe":N()}],"scroll-pt":[{"scroll-pt":N()}],"scroll-pr":[{"scroll-pr":N()}],"scroll-pb":[{"scroll-pb":N()}],"scroll-pl":[{"scroll-pl":N()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",_e,ge]}],fill:[{fill:["none",...w()]}],"stroke-w":[{stroke:[Ae,Zs,_i,B_]}],stroke:[{stroke:["none",...w()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},E4=i4(C4);function Qo(...e){return E4(BL(e))}function N4({icon:e,title:t,subtitle:r,badge:n,actions:i,className:s}){return u.jsxs("div",{className:Qo("flex items-center justify-between px-6 py-4 border-b border-border-subtle bg-surface-primary animate-[fadeIn_0.3s_ease-out_forwards]",s),children:[u.jsxs("div",{children:[u.jsxs("h1",{className:"text-lg font-bold text-text-primary flex items-center gap-2.5 tracking-tight",children:[u.jsx("span",{children:e})," ",t,n&&u.jsxs("span",{className:"text-xs font-semibold px-2 py-0.5 rounded-full bg-accent/10 text-accent-light",children:[n.count!==void 0?n.count:""," ",n.text]})]}),u.jsx("p",{className:"text-[13px] text-text-muted mt-1",children:r})]}),i&&u.jsx("div",{className:"flex gap-2",children:i})]})}function Qi({title:e,icon:t,description:r,accentColor:n,className:i,children:s}){return u.jsxs("div",{className:Qo("bg-bg-card border border-border-subtle rounded-2xl p-5 backdrop-blur-xl transition-all","hover:border-border-default hover:shadow-glow",n&&"border-l-[3px]",i),style:n?{borderLeftColor:n}:void 0,children:[(e||r)&&u.jsxs("div",{className:"mb-4",children:[e&&u.jsxs("h3",{className:"text-base font-semibold text-text-primary",children:[t&&u.jsx("span",{className:"mr-1.5",children:t}),e]}),r&&u.jsx("p",{className:"text-[13px] text-text-muted mt-1",children:r})]}),s]})}function T4({icon:e,title:t,description:r,action:n,className:i}){return u.jsxs("div",{className:Qo("py-16 px-5 text-center bg-bg-glass border-2 border-dashed border-border-subtle rounded-2xl",i),children:[u.jsx("div",{className:"text-5xl mb-4 opacity-50",children:e}),u.jsx("h3",{className:"text-lg font-bold text-text-secondary mb-2",children:t}),u.jsx("p",{className:"text-sm text-text-muted max-w-sm mx-auto mb-5 leading-relaxed",children:r}),n]})}const P4={online:"bg-green-500/10 text-green-400 border-green-500/30",idle:"bg-yellow-500/10 text-yellow-400 border-yellow-500/30",busy:"bg-orange-500/10 text-orange-400 border-orange-500/30",error:"bg-red-500/10 text-red-400 border-red-500/30",offline:"bg-gray-500/10 text-text-secondary border-gray-500/30"},R4={online:"bg-green-500",idle:"bg-yellow-500",busy:"bg-orange-500",error:"bg-red-500",offline:"bg-gray-500"};function M4({status:e,label:t,className:r}){const n=t||e;return u.jsxs("span",{className:Qo("inline-flex items-center gap-1.5 text-xs font-medium px-2.5 py-1 rounded-full border",P4[e],r),children:[u.jsx("span",{className:Qo("w-2 h-2 rounded-full animate-[pulse-dot_2s_ease-in-out_infinite]",R4[e])}),n]})}function L4(){return typeof window>"u"?"dark":window.matchMedia("(prefers-color-scheme: light)").matches?"light":"dark"}function $_(){try{const e=localStorage.getItem("theme");if(e==="dark"||e==="light"||e==="system")return e}catch{}return"system"}function zu(e){return e==="system"?L4():e}function I4(){const[e,t]=x.useState($_),[r,n]=x.useState(()=>zu($_()));x.useEffect(()=>{document.documentElement.setAttribute("data-theme",r)},[r]),x.useEffect(()=>{const o=window.matchMedia("(prefers-color-scheme: light)"),l=a=>{e==="system"&&n(a.matches?"light":"dark")};return o.addEventListener("change",l),()=>o.removeEventListener("change",l)},[e]);const i=x.useCallback(o=>{t(o),n(zu(o));try{localStorage.setItem("theme",o)}catch{}},[]),s=x.useCallback(()=>{t(o=>{const l=o==="dark"?"light":o==="light"?"system":"dark";n(zu(l));try{localStorage.setItem("theme",l)}catch{}return l})},[]);return{theme:r,preference:e,setPreference:i,cycleTheme:s,isDark:r==="dark"}}function Zi({label:e,description:t,checked:r,disabled:n,onChange:i,extra:s}){return u.jsxs("label",{className:"flex justify-between items-center cursor-pointer",children:[u.jsxs("div",{children:[u.jsx("div",{className:"font-medium text-sm",children:e}),u.jsx("div",{className:"text-[11px] text-text-muted",children:t})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[s,u.jsx("input",{type:"checkbox",checked:r,disabled:n,onChange:o=>i(o.target.checked),className:"w-5 h-5 accent-accent"})]})]})}function j4({onPrefChange:e}){const[t,r]=ML(),n=(i,s)=>{r({[i]:s}),e==null||e(i,s)};return u.jsxs("div",{className:"flex flex-col gap-3",children:[u.jsx(Zi,{label:"🔔 Notifications",description:"Master toggle for all alerts",checked:t.globalEnabled,onChange:i=>n("globalEnabled",i)}),t.globalEnabled&&u.jsx("div",{className:"border-t border-border-subtle my-0.5"}),t.globalEnabled&&u.jsx(Zi,{label:"🖥️ Browser Notifications",description:"Desktop alerts when tab is inactive",checked:t.browserNotifications,onChange:i=>n("browserNotifications",i)}),t.globalEnabled&&t.browserNotifications&&u.jsxs("div",{className:"ml-5 pl-3 border-l-2 border-border-subtle flex flex-col gap-2",children:[u.jsx(Zi,{label:"✅ Completion Alerts",description:"Notify when agent finishes a task",checked:t.completionAlert,onChange:i=>n("completionAlert",i)}),u.jsx(Zi,{label:"⚡ Approval Alerts",description:"Notify when agent needs approval",checked:t.approvalAlert,onChange:i=>n("approvalAlert",i)}),u.jsx(Zi,{label:"📡 Connection Alerts",description:"Alert when a daemon disconnects",checked:t.disconnectAlert,onChange:i=>n("disconnectAlert",i)})]}),!t.globalEnabled&&u.jsx("p",{className:"text-[11px] text-text-muted italic",children:"All notifications are disabled. Enable the master toggle to configure individual alerts."})]})}function D4({ides:e,emptyMessage:t,sendDaemonCommand:r,onDisconnect:n,onRevokeToken:i}){const s=e.filter(o=>o.type==="adhdev-daemon");return s.length===0?u.jsx(T4,{icon:"🔌",title:"No machines connected",description:t||"Run 'adhdev daemon' on your machine to connect."}):u.jsx("div",{className:"flex flex-col gap-2",children:s.map(o=>u.jsx(O4,{ide:o,allIdes:e,sendDaemonCommand:r,onDisconnect:n,onRevokeToken:i},o.id))})}function F_({title:e,message:t,confirmLabel:r,confirmColor:n,onConfirm:i,onCancel:s}){const o=n==="red"?"bg-red-500/20 text-red-400 border-red-500/30 hover:bg-red-500/30":"bg-amber-500/20 text-amber-400 border-amber-500/30 hover:bg-amber-500/30";return uy.createPortal(u.jsx("div",{className:"fixed inset-0 flex items-center justify-center bg-black/60 backdrop-blur-sm",style:{zIndex:9999},onClick:s,children:u.jsxs("div",{className:"bg-bg-primary border border-border-subtle rounded-xl p-5 max-w-sm w-full mx-4 shadow-2xl",onClick:l=>l.stopPropagation(),children:[u.jsx("div",{className:"font-semibold text-sm mb-3",children:e}),u.jsx("div",{className:"text-xs text-text-muted leading-relaxed mb-5 whitespace-pre-line",children:t}),u.jsxs("div",{className:"flex gap-2 justify-end",children:[u.jsx("button",{onClick:s,className:"text-xs px-3 py-1.5 rounded-lg font-medium bg-bg-secondary text-text-secondary border border-border-subtle hover:bg-bg-glass transition-colors",children:"Cancel"}),u.jsx("button",{onClick:i,className:`text-xs px-3 py-1.5 rounded-lg font-medium border transition-colors ${o}`,children:r})]})]})}),document.body)}const A4={vscode:{icon:"💠",name:"VS Code"},cursor:{icon:"⚡",name:"Cursor"},windsurf:{icon:"🏄",name:"Windsurf"},codex:{icon:"🤖",name:"Codex"},"claude-code":{icon:"🟠",name:"Claude Code"},aider:{icon:"🔧",name:"Aider"}};function B4(e){const t=e.replace(/^ide-/,"").replace(/-provider$/,"").toLowerCase();return A4[t]||{icon:"📝",name:e}}function O4({ide:e,allIdes:t,sendDaemonCommand:r,onDisconnect:n,onRevokeToken:i}){var A,O,U,L;const[s,o]=x.useState("idle"),[l,a]=x.useState(""),[c,d]=x.useState(null),[h,f]=x.useState("idle"),[p,m]=x.useState(""),_=e,b=_.version||_.daemonVersion||null,g=((A=_.machine)==null?void 0:A.hostname)||((O=_.system)==null?void 0:O.hostname)||"",v=((U=_.machine)==null?void 0:U.platform)||((L=_.system)==null?void 0:L.platform)||"",y=_.machineNickname||(g==null?void 0:g.replace(/\.local$/,""))||"Machine",S=v==="win32"?"🪟":v==="darwin"?"🍎":"🐧",R=t.filter($=>$.daemonId===e.id&&$.id.includes(":ide:")),E=t.filter($=>$.daemonId===e.id&&$.id.includes(":cli:")),P=t.filter($=>$.daemonId===e.id&&$.id.includes(":acp:")),N=_.p2p,D=async()=>{var $,w,ee;if(r){o("upgrading"),a("Installing latest version...");try{const ne=await r(e.id,"daemon_upgrade",{});($=ne==null?void 0:ne.result)!=null&&$.upgraded||(w=ne==null?void 0:ne.result)!=null&&w.success?(o("done"),a(`Upgraded to v${ne.result.version||"latest"}. Daemon is restarting...`)):(o("error"),a(((ee=ne==null?void 0:ne.result)==null?void 0:ee.error)||"Upgrade failed"))}catch(ne){o("error"),a((ne==null?void 0:ne.message)||"Connection lost during upgrade")}}},k=async()=>{if(d(null),!!n){f("loading");try{await n(e.id),f("done"),m("Machine disconnected.")}catch($){f("error"),m(($==null?void 0:$.message)||"Failed to disconnect")}}},B=async()=>{if(d(null),!!i){f("loading");try{await i(e.id),f("done"),m('Token revoked. Machine must run "adhdev setup" to reconnect.')}catch($){f("error"),m(($==null?void 0:$.message)||"Failed to revoke token")}}},j="0.6.3",M=!b||b!==j,C=R.length+E.length+P.length;return u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"bg-bg-glass rounded-lg px-4 py-3 border border-border-subtle",children:[u.jsxs("div",{className:"flex justify-between items-center",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsx("span",{className:"text-xl",children:S}),u.jsxs("div",{children:[u.jsx("div",{className:"font-medium text-sm",children:y}),u.jsxs("div",{className:"text-xs text-text-muted font-mono flex items-center gap-2",children:[u.jsxs("span",{children:[e.id.substring(0,12),"…"]}),b&&u.jsxs("span",{className:`px-1.5 py-0.5 rounded text-[10px] ${M?"bg-amber-500/15 text-amber-400":"bg-bg-secondary"}`,children:["v",b,!M&&" ✓"]})]})]})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[r&&M&&u.jsx("button",{onClick:D,disabled:s==="upgrading"||s==="done",className:"btn btn-sm btn-primary disabled:opacity-50 disabled:cursor-not-allowed",title:`Update to v${j}`,children:s==="upgrading"?u.jsxs("span",{className:"flex items-center gap-1",children:[u.jsx("span",{className:"animate-spin",children:"⟳"})," Upgrading..."]}):s==="done"?"✓ Updated":`↑ Update${` to v${j}`}`}),n&&u.jsx("button",{onClick:()=>d("disconnect"),disabled:h==="loading",className:"btn btn-sm btn-warning disabled:opacity-50 disabled:cursor-not-allowed",title:"Disconnect this machine",children:"Disconnect"}),i&&u.jsx("button",{onClick:()=>d("revoke"),disabled:h==="loading",className:"btn btn-sm btn-danger disabled:opacity-50 disabled:cursor-not-allowed",title:"Revoke token (requires re-setup)",children:"Revoke"}),u.jsx(M4,{status:e.status==="online"?"online":"error"})]})]}),u.jsxs("div",{className:"flex items-center gap-3 mt-2.5 pt-2.5 border-t border-border-subtle/50",children:[N&&u.jsxs("div",{className:"flex items-center gap-1.5 text-[11px]",children:[u.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${N.state==="connected"?"bg-green-400":N.state==="connecting"||N.state==="new"?"bg-amber-400 animate-pulse":"bg-text-muted/30"}`}),u.jsxs("span",{className:"text-text-muted",children:["P2P ",N.state==="connected"?"connected":N.state==="connecting"||N.state==="new"?"connecting...":N.state||"off"]}),N.peers!==void 0&&N.peers>0&&u.jsxs("span",{className:"text-text-muted/60",children:["(",N.peers," peer",N.peers!==1?"s":"",")"]})]}),N&&C>0&&u.jsx("span",{className:"text-border-subtle",children:"·"}),C>0?u.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-text-muted",children:[R.map($=>{const w=B4($.type),ee=$.cdpConnected;return u.jsxs("span",{className:"flex items-center gap-1 bg-bg-secondary px-1.5 py-0.5 rounded",children:[u.jsx("span",{children:w.icon}),u.jsx("span",{children:w.name}),ee!==void 0&&u.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${ee?"bg-green-400":"bg-amber-400 animate-pulse"}`,title:ee?"CDP connected":"CDP connecting..."})]},$.id)}),E.map($=>u.jsxs("span",{className:"flex items-center gap-1 bg-bg-secondary px-1.5 py-0.5 rounded",children:[u.jsx("span",{children:"⌨️"}),u.jsx("span",{children:$.cliName||"CLI"})]},$.id)),P.map($=>u.jsxs("span",{className:"flex items-center gap-1 bg-bg-secondary px-1.5 py-0.5 rounded",children:[u.jsx("span",{children:"🔗"}),u.jsx("span",{children:$.cliName||"ACP"})]},$.id))]}):u.jsx("span",{className:"text-[11px] text-text-muted/60 italic",children:"No IDEs connected"})]}),(l||p)&&u.jsx("div",{className:`text-xs mt-2 px-1 ${s==="error"||h==="error"?"text-red-400":s==="done"||h==="done"?"text-green-400":"text-text-muted"}`,children:p||l})]}),c==="disconnect"&&u.jsx(F_,{title:"🔌 Disconnect Machine",message:`Disconnect "${y}" from ADHDev?
|
|
173
|
+
${d}`,_localId:`sys_approval_${Date.now()}`})}if(t.ideId&&((a=t.modalButtons)!=null&&a.length)&&this.resolveActionFn){const c=t.ideId,d=t.agentType||t.ideType||"",h=t.ideType||"",f=t.modalButtons,p=v=>v.replace(/[⌥⏎⇧⌫⌘⌃↵]/g,"").replace(/\s*(Alt|Ctrl|Shift|Cmd|Enter|Return|Esc|Tab|Backspace)(\+\s*\w+)*/gi,"").trim(),m=this.resolveActionFn,_=f.map((v,y)=>{const S=p(v).toLowerCase(),R=/^(run|approve|accept|yes|allow|always)/.test(S),E=/^(reject|deny|delete|remove|abort|cancel|no)/.test(S);return{label:p(v),variant:R?"primary":E?"danger":"default",onClick:()=>{const P=this.resolveRouteId(c,d),N=/^(run|approve|accept|yes|allow|always|proceed|save)/.test(S);m(P,"resolve_action",{action:N?"approve":"reject",button:v,buttonIndex:y,agentType:d,ideType:h})}}}),b=t.modalMessage?`⚡ ${i}: ${t.modalMessage.replace(/[\n\r]+/g," ").slice(0,80)}`:s,g=Date.now();this.emitToast({id:g,message:b,type:o,timestamp:g,ideId:c,actions:_,duration:15e3}),s=""}}else if(t.event==="monitor:long_generating"){const c=t.elapsedSec?` (${Math.round(t.elapsedSec/60)}m)`:"";s=`⚠️ ${i} agent is taking a long time${c}`,o="warning",ko("browser")&&!document.hasFocus()&&jd(`⚠️ ${i} — Long Running`,`Agent has been generating for over ${c.replace(/[()]/g,"")}`,`long-${t.ideId||t.agentType}`)}else if(t.event==="team:view_request"){const c=t.requesterName||"A team member",d=t.requestId,h=t.orgId;if(s=`👁️ ${c} wants to view your session`,o="warning",d&&h&&this.viewRequestRespondFn){const f=this.viewRequestRespondFn,p=Date.now(),m=[{label:"Approve",variant:"primary",onClick:()=>{f(h,d,"approve").catch(_=>console.error("[EventManager] approve view request failed:",_))}},{label:"Decline",variant:"danger",onClick:()=>{f(h,d,"reject").catch(_=>console.error("[EventManager] reject view request failed:",_))}}];this.emitToast({id:p,message:s,type:o,timestamp:p,actions:m,duration:3e4}),s=""}ko("browser")&&!document.hasFocus()&&jd("👁️ View Request",`${c} wants to view your session`,`view-request-${d}`)}else t.event==="team:view_request_approved"?(s="✅ View request approved",o="success"):t.event==="team:view_request_rejected"&&(s=`❌ ${t.targetName||"Team member"} declined your view request`,o="warning");if(s){const c=Date.now();this.emitToast({id:c,message:s,type:o,timestamp:c,ideId:t.ideId,duration:5e3})}}}const gi=new AL;function A1(e){var t,r,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(r=A1(e[t]))&&(n&&(n+=" "),n+=r)}else for(r in e)e[r]&&(n&&(n+=" "),n+=r);return n}function BL(){for(var e,t,r=0,n="",i=arguments.length;r<i;r++)(e=arguments[r])&&(t=A1(e))&&(n&&(n+=" "),n+=t);return n}const OL=(e,t)=>{const r=new Array(e.length+t.length);for(let n=0;n<e.length;n++)r[n]=e[n];for(let n=0;n<t.length;n++)r[e.length+n]=t[n];return r},zL=(e,t)=>({classGroupId:e,validator:t}),B1=(e=new Map,t=null,r)=>({nextPart:e,validators:t,classGroupId:r}),rc="-",j_=[],$L="arbitrary..",FL=e=>{const t=HL(e),{conflictingClassGroups:r,conflictingClassGroupModifiers:n}=e;return{getClassGroupId:o=>{if(o.startsWith("[")&&o.endsWith("]"))return WL(o);const l=o.split(rc),a=l[0]===""&&l.length>1?1:0;return O1(l,a,t)},getConflictingClassGroupIds:(o,l)=>{if(l){const a=n[o],c=r[o];return a?c?OL(c,a):a:c||j_}return r[o]||j_}}},O1=(e,t,r)=>{if(e.length-t===0)return r.classGroupId;const i=e[t],s=r.nextPart.get(i);if(s){const c=O1(e,t+1,s);if(c)return c}const o=r.validators;if(o===null)return;const l=t===0?e.join(rc):e.slice(t).join(rc),a=o.length;for(let c=0;c<a;c++){const d=o[c];if(d.validator(l))return d.classGroupId}},WL=e=>e.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const t=e.slice(1,-1),r=t.indexOf(":"),n=t.slice(0,r);return n?$L+n:void 0})(),HL=e=>{const{theme:t,classGroups:r}=e;return UL(r,t)},UL=(e,t)=>{const r=B1();for(const n in e){const i=e[n];dp(i,r,n,t)}return r},dp=(e,t,r,n)=>{const i=e.length;for(let s=0;s<i;s++){const o=e[s];KL(o,t,r,n)}},KL=(e,t,r,n)=>{if(typeof e=="string"){VL(e,t,r);return}if(typeof e=="function"){qL(e,t,r,n);return}YL(e,t,r,n)},VL=(e,t,r)=>{const n=e===""?t:z1(t,e);n.classGroupId=r},qL=(e,t,r,n)=>{if(XL(e)){dp(e(n),t,r,n);return}t.validators===null&&(t.validators=[]),t.validators.push(zL(r,e))},YL=(e,t,r,n)=>{const i=Object.entries(e),s=i.length;for(let o=0;o<s;o++){const[l,a]=i[o];dp(a,z1(t,l),r,n)}},z1=(e,t)=>{let r=e;const n=t.split(rc),i=n.length;for(let s=0;s<i;s++){const o=n[s];let l=r.nextPart.get(o);l||(l=B1(),r.nextPart.set(o,l)),r=l}return r},XL=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,GL=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,r=Object.create(null),n=Object.create(null);const i=(s,o)=>{r[s]=o,t++,t>e&&(t=0,n=r,r=Object.create(null))};return{get(s){let o=r[s];if(o!==void 0)return o;if((o=n[s])!==void 0)return i(s,o),o},set(s,o){s in r?r[s]=o:i(s,o)}}},Dd="!",D_=":",QL=[],A_=(e,t,r,n,i)=>({modifiers:e,hasImportantModifier:t,baseClassName:r,maybePostfixModifierPosition:n,isExternal:i}),JL=e=>{const{prefix:t,experimentalParseClassName:r}=e;let n=i=>{const s=[];let o=0,l=0,a=0,c;const d=i.length;for(let _=0;_<d;_++){const b=i[_];if(o===0&&l===0){if(b===D_){s.push(i.slice(a,_)),a=_+1;continue}if(b==="/"){c=_;continue}}b==="["?o++:b==="]"?o--:b==="("?l++:b===")"&&l--}const h=s.length===0?i:i.slice(a);let f=h,p=!1;h.endsWith(Dd)?(f=h.slice(0,-1),p=!0):h.startsWith(Dd)&&(f=h.slice(1),p=!0);const m=c&&c>a?c-a:void 0;return A_(s,p,f,m)};if(t){const i=t+D_,s=n;n=o=>o.startsWith(i)?s(o.slice(i.length)):A_(QL,!1,o,void 0,!0)}if(r){const i=n;n=s=>r({className:s,parseClassName:i})}return n},ZL=e=>{const t=new Map;return e.orderSensitiveModifiers.forEach((r,n)=>{t.set(r,1e6+n)}),r=>{const n=[];let i=[];for(let s=0;s<r.length;s++){const o=r[s],l=o[0]==="[",a=t.has(o);l||a?(i.length>0&&(i.sort(),n.push(...i),i=[]),n.push(o)):i.push(o)}return i.length>0&&(i.sort(),n.push(...i)),n}},e4=e=>({cache:GL(e.cacheSize),parseClassName:JL(e),sortModifiers:ZL(e),...FL(e)}),t4=/\s+/,r4=(e,t)=>{const{parseClassName:r,getClassGroupId:n,getConflictingClassGroupIds:i,sortModifiers:s}=t,o=[],l=e.trim().split(t4);let a="";for(let c=l.length-1;c>=0;c-=1){const d=l[c],{isExternal:h,modifiers:f,hasImportantModifier:p,baseClassName:m,maybePostfixModifierPosition:_}=r(d);if(h){a=d+(a.length>0?" "+a:a);continue}let b=!!_,g=n(b?m.substring(0,_):m);if(!g){if(!b){a=d+(a.length>0?" "+a:a);continue}if(g=n(m),!g){a=d+(a.length>0?" "+a:a);continue}b=!1}const v=f.length===0?"":f.length===1?f[0]:s(f).join(":"),y=p?v+Dd:v,S=y+g;if(o.indexOf(S)>-1)continue;o.push(S);const R=i(g,b);for(let E=0;E<R.length;++E){const P=R[E];o.push(y+P)}a=d+(a.length>0?" "+a:a)}return a},n4=(...e)=>{let t=0,r,n,i="";for(;t<e.length;)(r=e[t++])&&(n=$1(r))&&(i&&(i+=" "),i+=n);return i},$1=e=>{if(typeof e=="string")return e;let t,r="";for(let n=0;n<e.length;n++)e[n]&&(t=$1(e[n]))&&(r&&(r+=" "),r+=t);return r},i4=(e,...t)=>{let r,n,i,s;const o=a=>{const c=t.reduce((d,h)=>h(d),e());return r=e4(c),n=r.cache.get,i=r.cache.set,s=l,l(a)},l=a=>{const c=n(a);if(c)return c;const d=r4(a,r);return i(a,d),d};return s=o,(...a)=>s(n4(...a))},s4=[],wt=e=>{const t=r=>r[e]||s4;return t.isThemeGetter=!0,t},F1=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,W1=/^\((?:(\w[\w-]*):)?(.+)\)$/i,o4=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,l4=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,a4=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,c4=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,u4=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,h4=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,An=e=>o4.test(e),Ae=e=>!!e&&!Number.isNaN(Number(e)),Bn=e=>!!e&&Number.isInteger(Number(e)),Ou=e=>e.endsWith("%")&&Ae(e.slice(0,-1)),hn=e=>l4.test(e),H1=()=>!0,d4=e=>a4.test(e)&&!c4.test(e),fp=()=>!1,f4=e=>u4.test(e),p4=e=>h4.test(e),m4=e=>!ge(e)&&!_e(e),g4=e=>di(e,V1,fp),ge=e=>F1.test(e),_i=e=>di(e,q1,d4),B_=e=>di(e,k4,Ae),_4=e=>di(e,X1,H1),v4=e=>di(e,Y1,fp),O_=e=>di(e,U1,fp),x4=e=>di(e,K1,p4),Ul=e=>di(e,G1,f4),_e=e=>W1.test(e),Zs=e=>Vi(e,q1),y4=e=>Vi(e,Y1),z_=e=>Vi(e,U1),b4=e=>Vi(e,V1),w4=e=>Vi(e,K1),Kl=e=>Vi(e,G1,!0),S4=e=>Vi(e,X1,!0),di=(e,t,r)=>{const n=F1.exec(e);return n?n[1]?t(n[1]):r(n[2]):!1},Vi=(e,t,r=!1)=>{const n=W1.exec(e);return n?n[1]?t(n[1]):r:!1},U1=e=>e==="position"||e==="percentage",K1=e=>e==="image"||e==="url",V1=e=>e==="length"||e==="size"||e==="bg-size",q1=e=>e==="length",k4=e=>e==="number",Y1=e=>e==="family-name",X1=e=>e==="number"||e==="weight",G1=e=>e==="shadow",C4=()=>{const e=wt("color"),t=wt("font"),r=wt("text"),n=wt("font-weight"),i=wt("tracking"),s=wt("leading"),o=wt("breakpoint"),l=wt("container"),a=wt("spacing"),c=wt("radius"),d=wt("shadow"),h=wt("inset-shadow"),f=wt("text-shadow"),p=wt("drop-shadow"),m=wt("blur"),_=wt("perspective"),b=wt("aspect"),g=wt("ease"),v=wt("animate"),y=()=>["auto","avoid","all","avoid-page","page","left","right","column"],S=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],R=()=>[...S(),_e,ge],E=()=>["auto","hidden","clip","visible","scroll"],P=()=>["auto","contain","none"],N=()=>[_e,ge,a],D=()=>[An,"full","auto",...N()],k=()=>[Bn,"none","subgrid",_e,ge],B=()=>["auto",{span:["full",Bn,_e,ge]},Bn,_e,ge],j=()=>[Bn,"auto",_e,ge],M=()=>["auto","min","max","fr",_e,ge],C=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],A=()=>["start","end","center","stretch","center-safe","end-safe"],O=()=>["auto",...N()],U=()=>[An,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...N()],L=()=>[An,"screen","full","dvw","lvw","svw","min","max","fit",...N()],$=()=>[An,"screen","full","lh","dvh","lvh","svh","min","max","fit",...N()],w=()=>[e,_e,ge],ee=()=>[...S(),z_,O_,{position:[_e,ge]}],ne=()=>["no-repeat",{repeat:["","x","y","space","round"]}],T=()=>["auto","cover","contain",b4,g4,{size:[_e,ge]}],X=()=>[Ou,Zs,_i],I=()=>["","none","full",c,_e,ge],F=()=>["",Ae,Zs,_i],G=()=>["solid","dashed","dotted","double"],he=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],me=()=>[Ae,Ou,z_,O_],je=()=>["","none",m,_e,ge],Pe=()=>["none",Ae,_e,ge],Ce=()=>["none",Ae,_e,ge],de=()=>[Ae,_e,ge],Te=()=>[An,"full",...N()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[hn],breakpoint:[hn],color:[H1],container:[hn],"drop-shadow":[hn],ease:["in","out","in-out"],font:[m4],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[hn],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[hn],shadow:[hn],spacing:["px",Ae],text:[hn],"text-shadow":[hn],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",An,ge,_e,b]}],container:["container"],columns:[{columns:[Ae,ge,_e,l]}],"break-after":[{"break-after":y()}],"break-before":[{"break-before":y()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:R()}],overflow:[{overflow:E()}],"overflow-x":[{"overflow-x":E()}],"overflow-y":[{"overflow-y":E()}],overscroll:[{overscroll:P()}],"overscroll-x":[{"overscroll-x":P()}],"overscroll-y":[{"overscroll-y":P()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:D()}],"inset-x":[{"inset-x":D()}],"inset-y":[{"inset-y":D()}],start:[{"inset-s":D(),start:D()}],end:[{"inset-e":D(),end:D()}],"inset-bs":[{"inset-bs":D()}],"inset-be":[{"inset-be":D()}],top:[{top:D()}],right:[{right:D()}],bottom:[{bottom:D()}],left:[{left:D()}],visibility:["visible","invisible","collapse"],z:[{z:[Bn,"auto",_e,ge]}],basis:[{basis:[An,"full","auto",l,...N()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Ae,An,"auto","initial","none",ge]}],grow:[{grow:["",Ae,_e,ge]}],shrink:[{shrink:["",Ae,_e,ge]}],order:[{order:[Bn,"first","last","none",_e,ge]}],"grid-cols":[{"grid-cols":k()}],"col-start-end":[{col:B()}],"col-start":[{"col-start":j()}],"col-end":[{"col-end":j()}],"grid-rows":[{"grid-rows":k()}],"row-start-end":[{row:B()}],"row-start":[{"row-start":j()}],"row-end":[{"row-end":j()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":M()}],"auto-rows":[{"auto-rows":M()}],gap:[{gap:N()}],"gap-x":[{"gap-x":N()}],"gap-y":[{"gap-y":N()}],"justify-content":[{justify:[...C(),"normal"]}],"justify-items":[{"justify-items":[...A(),"normal"]}],"justify-self":[{"justify-self":["auto",...A()]}],"align-content":[{content:["normal",...C()]}],"align-items":[{items:[...A(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...A(),{baseline:["","last"]}]}],"place-content":[{"place-content":C()}],"place-items":[{"place-items":[...A(),"baseline"]}],"place-self":[{"place-self":["auto",...A()]}],p:[{p:N()}],px:[{px:N()}],py:[{py:N()}],ps:[{ps:N()}],pe:[{pe:N()}],pbs:[{pbs:N()}],pbe:[{pbe:N()}],pt:[{pt:N()}],pr:[{pr:N()}],pb:[{pb:N()}],pl:[{pl:N()}],m:[{m:O()}],mx:[{mx:O()}],my:[{my:O()}],ms:[{ms:O()}],me:[{me:O()}],mbs:[{mbs:O()}],mbe:[{mbe:O()}],mt:[{mt:O()}],mr:[{mr:O()}],mb:[{mb:O()}],ml:[{ml:O()}],"space-x":[{"space-x":N()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":N()}],"space-y-reverse":["space-y-reverse"],size:[{size:U()}],"inline-size":[{inline:["auto",...L()]}],"min-inline-size":[{"min-inline":["auto",...L()]}],"max-inline-size":[{"max-inline":["none",...L()]}],"block-size":[{block:["auto",...$()]}],"min-block-size":[{"min-block":["auto",...$()]}],"max-block-size":[{"max-block":["none",...$()]}],w:[{w:[l,"screen",...U()]}],"min-w":[{"min-w":[l,"screen","none",...U()]}],"max-w":[{"max-w":[l,"screen","none","prose",{screen:[o]},...U()]}],h:[{h:["screen","lh",...U()]}],"min-h":[{"min-h":["screen","lh","none",...U()]}],"max-h":[{"max-h":["screen","lh",...U()]}],"font-size":[{text:["base",r,Zs,_i]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[n,S4,_4]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Ou,ge]}],"font-family":[{font:[y4,v4,t]}],"font-features":[{"font-features":[ge]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[i,_e,ge]}],"line-clamp":[{"line-clamp":[Ae,"none",_e,B_]}],leading:[{leading:[s,...N()]}],"list-image":[{"list-image":["none",_e,ge]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",_e,ge]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:w()}],"text-color":[{text:w()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...G(),"wavy"]}],"text-decoration-thickness":[{decoration:[Ae,"from-font","auto",_e,_i]}],"text-decoration-color":[{decoration:w()}],"underline-offset":[{"underline-offset":[Ae,"auto",_e,ge]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:N()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",_e,ge]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",_e,ge]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:ee()}],"bg-repeat":[{bg:ne()}],"bg-size":[{bg:T()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Bn,_e,ge],radial:["",_e,ge],conic:[Bn,_e,ge]},w4,x4]}],"bg-color":[{bg:w()}],"gradient-from-pos":[{from:X()}],"gradient-via-pos":[{via:X()}],"gradient-to-pos":[{to:X()}],"gradient-from":[{from:w()}],"gradient-via":[{via:w()}],"gradient-to":[{to:w()}],rounded:[{rounded:I()}],"rounded-s":[{"rounded-s":I()}],"rounded-e":[{"rounded-e":I()}],"rounded-t":[{"rounded-t":I()}],"rounded-r":[{"rounded-r":I()}],"rounded-b":[{"rounded-b":I()}],"rounded-l":[{"rounded-l":I()}],"rounded-ss":[{"rounded-ss":I()}],"rounded-se":[{"rounded-se":I()}],"rounded-ee":[{"rounded-ee":I()}],"rounded-es":[{"rounded-es":I()}],"rounded-tl":[{"rounded-tl":I()}],"rounded-tr":[{"rounded-tr":I()}],"rounded-br":[{"rounded-br":I()}],"rounded-bl":[{"rounded-bl":I()}],"border-w":[{border:F()}],"border-w-x":[{"border-x":F()}],"border-w-y":[{"border-y":F()}],"border-w-s":[{"border-s":F()}],"border-w-e":[{"border-e":F()}],"border-w-bs":[{"border-bs":F()}],"border-w-be":[{"border-be":F()}],"border-w-t":[{"border-t":F()}],"border-w-r":[{"border-r":F()}],"border-w-b":[{"border-b":F()}],"border-w-l":[{"border-l":F()}],"divide-x":[{"divide-x":F()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":F()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...G(),"hidden","none"]}],"divide-style":[{divide:[...G(),"hidden","none"]}],"border-color":[{border:w()}],"border-color-x":[{"border-x":w()}],"border-color-y":[{"border-y":w()}],"border-color-s":[{"border-s":w()}],"border-color-e":[{"border-e":w()}],"border-color-bs":[{"border-bs":w()}],"border-color-be":[{"border-be":w()}],"border-color-t":[{"border-t":w()}],"border-color-r":[{"border-r":w()}],"border-color-b":[{"border-b":w()}],"border-color-l":[{"border-l":w()}],"divide-color":[{divide:w()}],"outline-style":[{outline:[...G(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Ae,_e,ge]}],"outline-w":[{outline:["",Ae,Zs,_i]}],"outline-color":[{outline:w()}],shadow:[{shadow:["","none",d,Kl,Ul]}],"shadow-color":[{shadow:w()}],"inset-shadow":[{"inset-shadow":["none",h,Kl,Ul]}],"inset-shadow-color":[{"inset-shadow":w()}],"ring-w":[{ring:F()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:w()}],"ring-offset-w":[{"ring-offset":[Ae,_i]}],"ring-offset-color":[{"ring-offset":w()}],"inset-ring-w":[{"inset-ring":F()}],"inset-ring-color":[{"inset-ring":w()}],"text-shadow":[{"text-shadow":["none",f,Kl,Ul]}],"text-shadow-color":[{"text-shadow":w()}],opacity:[{opacity:[Ae,_e,ge]}],"mix-blend":[{"mix-blend":[...he(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":he()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[Ae]}],"mask-image-linear-from-pos":[{"mask-linear-from":me()}],"mask-image-linear-to-pos":[{"mask-linear-to":me()}],"mask-image-linear-from-color":[{"mask-linear-from":w()}],"mask-image-linear-to-color":[{"mask-linear-to":w()}],"mask-image-t-from-pos":[{"mask-t-from":me()}],"mask-image-t-to-pos":[{"mask-t-to":me()}],"mask-image-t-from-color":[{"mask-t-from":w()}],"mask-image-t-to-color":[{"mask-t-to":w()}],"mask-image-r-from-pos":[{"mask-r-from":me()}],"mask-image-r-to-pos":[{"mask-r-to":me()}],"mask-image-r-from-color":[{"mask-r-from":w()}],"mask-image-r-to-color":[{"mask-r-to":w()}],"mask-image-b-from-pos":[{"mask-b-from":me()}],"mask-image-b-to-pos":[{"mask-b-to":me()}],"mask-image-b-from-color":[{"mask-b-from":w()}],"mask-image-b-to-color":[{"mask-b-to":w()}],"mask-image-l-from-pos":[{"mask-l-from":me()}],"mask-image-l-to-pos":[{"mask-l-to":me()}],"mask-image-l-from-color":[{"mask-l-from":w()}],"mask-image-l-to-color":[{"mask-l-to":w()}],"mask-image-x-from-pos":[{"mask-x-from":me()}],"mask-image-x-to-pos":[{"mask-x-to":me()}],"mask-image-x-from-color":[{"mask-x-from":w()}],"mask-image-x-to-color":[{"mask-x-to":w()}],"mask-image-y-from-pos":[{"mask-y-from":me()}],"mask-image-y-to-pos":[{"mask-y-to":me()}],"mask-image-y-from-color":[{"mask-y-from":w()}],"mask-image-y-to-color":[{"mask-y-to":w()}],"mask-image-radial":[{"mask-radial":[_e,ge]}],"mask-image-radial-from-pos":[{"mask-radial-from":me()}],"mask-image-radial-to-pos":[{"mask-radial-to":me()}],"mask-image-radial-from-color":[{"mask-radial-from":w()}],"mask-image-radial-to-color":[{"mask-radial-to":w()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":S()}],"mask-image-conic-pos":[{"mask-conic":[Ae]}],"mask-image-conic-from-pos":[{"mask-conic-from":me()}],"mask-image-conic-to-pos":[{"mask-conic-to":me()}],"mask-image-conic-from-color":[{"mask-conic-from":w()}],"mask-image-conic-to-color":[{"mask-conic-to":w()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:ee()}],"mask-repeat":[{mask:ne()}],"mask-size":[{mask:T()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",_e,ge]}],filter:[{filter:["","none",_e,ge]}],blur:[{blur:je()}],brightness:[{brightness:[Ae,_e,ge]}],contrast:[{contrast:[Ae,_e,ge]}],"drop-shadow":[{"drop-shadow":["","none",p,Kl,Ul]}],"drop-shadow-color":[{"drop-shadow":w()}],grayscale:[{grayscale:["",Ae,_e,ge]}],"hue-rotate":[{"hue-rotate":[Ae,_e,ge]}],invert:[{invert:["",Ae,_e,ge]}],saturate:[{saturate:[Ae,_e,ge]}],sepia:[{sepia:["",Ae,_e,ge]}],"backdrop-filter":[{"backdrop-filter":["","none",_e,ge]}],"backdrop-blur":[{"backdrop-blur":je()}],"backdrop-brightness":[{"backdrop-brightness":[Ae,_e,ge]}],"backdrop-contrast":[{"backdrop-contrast":[Ae,_e,ge]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Ae,_e,ge]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Ae,_e,ge]}],"backdrop-invert":[{"backdrop-invert":["",Ae,_e,ge]}],"backdrop-opacity":[{"backdrop-opacity":[Ae,_e,ge]}],"backdrop-saturate":[{"backdrop-saturate":[Ae,_e,ge]}],"backdrop-sepia":[{"backdrop-sepia":["",Ae,_e,ge]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":N()}],"border-spacing-x":[{"border-spacing-x":N()}],"border-spacing-y":[{"border-spacing-y":N()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",_e,ge]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Ae,"initial",_e,ge]}],ease:[{ease:["linear","initial",g,_e,ge]}],delay:[{delay:[Ae,_e,ge]}],animate:[{animate:["none",v,_e,ge]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[_,_e,ge]}],"perspective-origin":[{"perspective-origin":R()}],rotate:[{rotate:Pe()}],"rotate-x":[{"rotate-x":Pe()}],"rotate-y":[{"rotate-y":Pe()}],"rotate-z":[{"rotate-z":Pe()}],scale:[{scale:Ce()}],"scale-x":[{"scale-x":Ce()}],"scale-y":[{"scale-y":Ce()}],"scale-z":[{"scale-z":Ce()}],"scale-3d":["scale-3d"],skew:[{skew:de()}],"skew-x":[{"skew-x":de()}],"skew-y":[{"skew-y":de()}],transform:[{transform:[_e,ge,"","none","gpu","cpu"]}],"transform-origin":[{origin:R()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:Te()}],"translate-x":[{"translate-x":Te()}],"translate-y":[{"translate-y":Te()}],"translate-z":[{"translate-z":Te()}],"translate-none":["translate-none"],accent:[{accent:w()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:w()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",_e,ge]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":N()}],"scroll-mx":[{"scroll-mx":N()}],"scroll-my":[{"scroll-my":N()}],"scroll-ms":[{"scroll-ms":N()}],"scroll-me":[{"scroll-me":N()}],"scroll-mbs":[{"scroll-mbs":N()}],"scroll-mbe":[{"scroll-mbe":N()}],"scroll-mt":[{"scroll-mt":N()}],"scroll-mr":[{"scroll-mr":N()}],"scroll-mb":[{"scroll-mb":N()}],"scroll-ml":[{"scroll-ml":N()}],"scroll-p":[{"scroll-p":N()}],"scroll-px":[{"scroll-px":N()}],"scroll-py":[{"scroll-py":N()}],"scroll-ps":[{"scroll-ps":N()}],"scroll-pe":[{"scroll-pe":N()}],"scroll-pbs":[{"scroll-pbs":N()}],"scroll-pbe":[{"scroll-pbe":N()}],"scroll-pt":[{"scroll-pt":N()}],"scroll-pr":[{"scroll-pr":N()}],"scroll-pb":[{"scroll-pb":N()}],"scroll-pl":[{"scroll-pl":N()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",_e,ge]}],fill:[{fill:["none",...w()]}],"stroke-w":[{stroke:[Ae,Zs,_i,B_]}],stroke:[{stroke:["none",...w()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},E4=i4(C4);function Qo(...e){return E4(BL(e))}function N4({icon:e,title:t,subtitle:r,badge:n,actions:i,className:s}){return u.jsxs("div",{className:Qo("flex items-center justify-between px-6 py-4 border-b border-border-subtle bg-surface-primary animate-[fadeIn_0.3s_ease-out_forwards]",s),children:[u.jsxs("div",{children:[u.jsxs("h1",{className:"text-lg font-bold text-text-primary flex items-center gap-2.5 tracking-tight",children:[u.jsx("span",{children:e})," ",t,n&&u.jsxs("span",{className:"text-xs font-semibold px-2 py-0.5 rounded-full bg-accent/10 text-accent-light",children:[n.count!==void 0?n.count:""," ",n.text]})]}),u.jsx("p",{className:"text-[13px] text-text-muted mt-1",children:r})]}),i&&u.jsx("div",{className:"flex gap-2",children:i})]})}function Qi({title:e,icon:t,description:r,accentColor:n,className:i,children:s}){return u.jsxs("div",{className:Qo("bg-bg-card border border-border-subtle rounded-2xl p-5 backdrop-blur-xl transition-all","hover:border-border-default hover:shadow-glow",n&&"border-l-[3px]",i),style:n?{borderLeftColor:n}:void 0,children:[(e||r)&&u.jsxs("div",{className:"mb-4",children:[e&&u.jsxs("h3",{className:"text-base font-semibold text-text-primary",children:[t&&u.jsx("span",{className:"mr-1.5",children:t}),e]}),r&&u.jsx("p",{className:"text-[13px] text-text-muted mt-1",children:r})]}),s]})}function T4({icon:e,title:t,description:r,action:n,className:i}){return u.jsxs("div",{className:Qo("py-16 px-5 text-center bg-bg-glass border-2 border-dashed border-border-subtle rounded-2xl",i),children:[u.jsx("div",{className:"text-5xl mb-4 opacity-50",children:e}),u.jsx("h3",{className:"text-lg font-bold text-text-secondary mb-2",children:t}),u.jsx("p",{className:"text-sm text-text-muted max-w-sm mx-auto mb-5 leading-relaxed",children:r}),n]})}const P4={online:"bg-green-500/10 text-green-400 border-green-500/30",idle:"bg-yellow-500/10 text-yellow-400 border-yellow-500/30",busy:"bg-orange-500/10 text-orange-400 border-orange-500/30",error:"bg-red-500/10 text-red-400 border-red-500/30",offline:"bg-gray-500/10 text-text-secondary border-gray-500/30"},R4={online:"bg-green-500",idle:"bg-yellow-500",busy:"bg-orange-500",error:"bg-red-500",offline:"bg-gray-500"};function M4({status:e,label:t,className:r}){const n=t||e;return u.jsxs("span",{className:Qo("inline-flex items-center gap-1.5 text-xs font-medium px-2.5 py-1 rounded-full border",P4[e],r),children:[u.jsx("span",{className:Qo("w-2 h-2 rounded-full animate-[pulse-dot_2s_ease-in-out_infinite]",R4[e])}),n]})}function L4(){return typeof window>"u"?"dark":window.matchMedia("(prefers-color-scheme: light)").matches?"light":"dark"}function $_(){try{const e=localStorage.getItem("theme");if(e==="dark"||e==="light"||e==="system")return e}catch{}return"system"}function zu(e){return e==="system"?L4():e}function I4(){const[e,t]=x.useState($_),[r,n]=x.useState(()=>zu($_()));x.useEffect(()=>{document.documentElement.setAttribute("data-theme",r)},[r]),x.useEffect(()=>{const o=window.matchMedia("(prefers-color-scheme: light)"),l=a=>{e==="system"&&n(a.matches?"light":"dark")};return o.addEventListener("change",l),()=>o.removeEventListener("change",l)},[e]);const i=x.useCallback(o=>{t(o),n(zu(o));try{localStorage.setItem("theme",o)}catch{}},[]),s=x.useCallback(()=>{t(o=>{const l=o==="dark"?"light":o==="light"?"system":"dark";n(zu(l));try{localStorage.setItem("theme",l)}catch{}return l})},[]);return{theme:r,preference:e,setPreference:i,cycleTheme:s,isDark:r==="dark"}}function Zi({label:e,description:t,checked:r,disabled:n,onChange:i,extra:s}){return u.jsxs("label",{className:"flex justify-between items-center cursor-pointer",children:[u.jsxs("div",{children:[u.jsx("div",{className:"font-medium text-sm",children:e}),u.jsx("div",{className:"text-[11px] text-text-muted",children:t})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[s,u.jsx("input",{type:"checkbox",checked:r,disabled:n,onChange:o=>i(o.target.checked),className:"w-5 h-5 accent-accent"})]})]})}function j4({onPrefChange:e}){const[t,r]=ML(),n=(i,s)=>{r({[i]:s}),e==null||e(i,s)};return u.jsxs("div",{className:"flex flex-col gap-3",children:[u.jsx(Zi,{label:"🔔 Notifications",description:"Master toggle for all alerts",checked:t.globalEnabled,onChange:i=>n("globalEnabled",i)}),t.globalEnabled&&u.jsx("div",{className:"border-t border-border-subtle my-0.5"}),t.globalEnabled&&u.jsx(Zi,{label:"🖥️ Browser Notifications",description:"Desktop alerts when tab is inactive",checked:t.browserNotifications,onChange:i=>n("browserNotifications",i)}),t.globalEnabled&&t.browserNotifications&&u.jsxs("div",{className:"ml-5 pl-3 border-l-2 border-border-subtle flex flex-col gap-2",children:[u.jsx(Zi,{label:"✅ Completion Alerts",description:"Notify when agent finishes a task",checked:t.completionAlert,onChange:i=>n("completionAlert",i)}),u.jsx(Zi,{label:"⚡ Approval Alerts",description:"Notify when agent needs approval",checked:t.approvalAlert,onChange:i=>n("approvalAlert",i)}),u.jsx(Zi,{label:"📡 Connection Alerts",description:"Alert when a daemon disconnects",checked:t.disconnectAlert,onChange:i=>n("disconnectAlert",i)})]}),!t.globalEnabled&&u.jsx("p",{className:"text-[11px] text-text-muted italic",children:"All notifications are disabled. Enable the master toggle to configure individual alerts."})]})}function D4({ides:e,emptyMessage:t,sendDaemonCommand:r,onDisconnect:n,onRevokeToken:i}){const s=e.filter(o=>o.type==="adhdev-daemon");return s.length===0?u.jsx(T4,{icon:"🔌",title:"No machines connected",description:t||"Run 'adhdev daemon' on your machine to connect."}):u.jsx("div",{className:"flex flex-col gap-2",children:s.map(o=>u.jsx(O4,{ide:o,allIdes:e,sendDaemonCommand:r,onDisconnect:n,onRevokeToken:i},o.id))})}function F_({title:e,message:t,confirmLabel:r,confirmColor:n,onConfirm:i,onCancel:s}){const o=n==="red"?"bg-red-500/20 text-red-400 border-red-500/30 hover:bg-red-500/30":"bg-amber-500/20 text-amber-400 border-amber-500/30 hover:bg-amber-500/30";return uy.createPortal(u.jsx("div",{className:"fixed inset-0 flex items-center justify-center bg-black/60 backdrop-blur-sm",style:{zIndex:9999},onClick:s,children:u.jsxs("div",{className:"bg-bg-primary border border-border-subtle rounded-xl p-5 max-w-sm w-full mx-4 shadow-2xl",onClick:l=>l.stopPropagation(),children:[u.jsx("div",{className:"font-semibold text-sm mb-3",children:e}),u.jsx("div",{className:"text-xs text-text-muted leading-relaxed mb-5 whitespace-pre-line",children:t}),u.jsxs("div",{className:"flex gap-2 justify-end",children:[u.jsx("button",{onClick:s,className:"text-xs px-3 py-1.5 rounded-lg font-medium bg-bg-secondary text-text-secondary border border-border-subtle hover:bg-bg-glass transition-colors",children:"Cancel"}),u.jsx("button",{onClick:i,className:`text-xs px-3 py-1.5 rounded-lg font-medium border transition-colors ${o}`,children:r})]})]})}),document.body)}const A4={vscode:{icon:"💠",name:"VS Code"},cursor:{icon:"⚡",name:"Cursor"},windsurf:{icon:"🏄",name:"Windsurf"},codex:{icon:"🤖",name:"Codex"},"claude-code":{icon:"🟠",name:"Claude Code"},aider:{icon:"🔧",name:"Aider"}};function B4(e){const t=e.replace(/^ide-/,"").replace(/-provider$/,"").toLowerCase();return A4[t]||{icon:"📝",name:e}}function O4({ide:e,allIdes:t,sendDaemonCommand:r,onDisconnect:n,onRevokeToken:i}){var A,O,U,L;const[s,o]=x.useState("idle"),[l,a]=x.useState(""),[c,d]=x.useState(null),[h,f]=x.useState("idle"),[p,m]=x.useState(""),_=e,b=_.version||_.daemonVersion||null,g=((A=_.machine)==null?void 0:A.hostname)||((O=_.system)==null?void 0:O.hostname)||"",v=((U=_.machine)==null?void 0:U.platform)||((L=_.system)==null?void 0:L.platform)||"",y=_.machineNickname||(g==null?void 0:g.replace(/\.local$/,""))||"Machine",S=v==="win32"?"🪟":v==="darwin"?"🍎":"🐧",R=t.filter($=>$.daemonId===e.id&&$.id.includes(":ide:")),E=t.filter($=>$.daemonId===e.id&&$.id.includes(":cli:")),P=t.filter($=>$.daemonId===e.id&&$.id.includes(":acp:")),N=_.p2p,D=async()=>{var $,w,ee;if(r){o("upgrading"),a("Installing latest version...");try{const ne=await r(e.id,"daemon_upgrade",{});($=ne==null?void 0:ne.result)!=null&&$.upgraded||(w=ne==null?void 0:ne.result)!=null&&w.success?(o("done"),a(`Upgraded to v${ne.result.version||"latest"}. Daemon is restarting...`)):(o("error"),a(((ee=ne==null?void 0:ne.result)==null?void 0:ee.error)||"Upgrade failed"))}catch(ne){o("error"),a((ne==null?void 0:ne.message)||"Connection lost during upgrade")}}},k=async()=>{if(d(null),!!n){f("loading");try{await n(e.id),f("done"),m("Machine disconnected.")}catch($){f("error"),m(($==null?void 0:$.message)||"Failed to disconnect")}}},B=async()=>{if(d(null),!!i){f("loading");try{await i(e.id),f("done"),m('Token revoked. Machine must run "adhdev setup" to reconnect.')}catch($){f("error"),m(($==null?void 0:$.message)||"Failed to revoke token")}}},j="0.6.5",M=!b||b!==j,C=R.length+E.length+P.length;return u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"bg-bg-glass rounded-lg px-4 py-3 border border-border-subtle",children:[u.jsxs("div",{className:"flex justify-between items-center",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsx("span",{className:"text-xl",children:S}),u.jsxs("div",{children:[u.jsx("div",{className:"font-medium text-sm",children:y}),u.jsxs("div",{className:"text-xs text-text-muted font-mono flex items-center gap-2",children:[u.jsxs("span",{children:[e.id.substring(0,12),"…"]}),b&&u.jsxs("span",{className:`px-1.5 py-0.5 rounded text-[10px] ${M?"bg-amber-500/15 text-amber-400":"bg-bg-secondary"}`,children:["v",b,!M&&" ✓"]})]})]})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[r&&M&&u.jsx("button",{onClick:D,disabled:s==="upgrading"||s==="done",className:"btn btn-sm btn-primary disabled:opacity-50 disabled:cursor-not-allowed",title:`Update to v${j}`,children:s==="upgrading"?u.jsxs("span",{className:"flex items-center gap-1",children:[u.jsx("span",{className:"animate-spin",children:"⟳"})," Upgrading..."]}):s==="done"?"✓ Updated":`↑ Update${` to v${j}`}`}),n&&u.jsx("button",{onClick:()=>d("disconnect"),disabled:h==="loading",className:"btn btn-sm btn-warning disabled:opacity-50 disabled:cursor-not-allowed",title:"Disconnect this machine",children:"Disconnect"}),i&&u.jsx("button",{onClick:()=>d("revoke"),disabled:h==="loading",className:"btn btn-sm btn-danger disabled:opacity-50 disabled:cursor-not-allowed",title:"Revoke token (requires re-setup)",children:"Revoke"}),u.jsx(M4,{status:e.status==="online"?"online":"error"})]})]}),u.jsxs("div",{className:"flex items-center gap-3 mt-2.5 pt-2.5 border-t border-border-subtle/50",children:[N&&u.jsxs("div",{className:"flex items-center gap-1.5 text-[11px]",children:[u.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${N.state==="connected"?"bg-green-400":N.state==="connecting"||N.state==="new"?"bg-amber-400 animate-pulse":"bg-text-muted/30"}`}),u.jsxs("span",{className:"text-text-muted",children:["P2P ",N.state==="connected"?"connected":N.state==="connecting"||N.state==="new"?"connecting...":N.state||"off"]}),N.peers!==void 0&&N.peers>0&&u.jsxs("span",{className:"text-text-muted/60",children:["(",N.peers," peer",N.peers!==1?"s":"",")"]})]}),N&&C>0&&u.jsx("span",{className:"text-border-subtle",children:"·"}),C>0?u.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-text-muted",children:[R.map($=>{const w=B4($.type),ee=$.cdpConnected;return u.jsxs("span",{className:"flex items-center gap-1 bg-bg-secondary px-1.5 py-0.5 rounded",children:[u.jsx("span",{children:w.icon}),u.jsx("span",{children:w.name}),ee!==void 0&&u.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${ee?"bg-green-400":"bg-amber-400 animate-pulse"}`,title:ee?"CDP connected":"CDP connecting..."})]},$.id)}),E.map($=>u.jsxs("span",{className:"flex items-center gap-1 bg-bg-secondary px-1.5 py-0.5 rounded",children:[u.jsx("span",{children:"⌨️"}),u.jsx("span",{children:$.cliName||"CLI"})]},$.id)),P.map($=>u.jsxs("span",{className:"flex items-center gap-1 bg-bg-secondary px-1.5 py-0.5 rounded",children:[u.jsx("span",{children:"🔗"}),u.jsx("span",{children:$.cliName||"ACP"})]},$.id))]}):u.jsx("span",{className:"text-[11px] text-text-muted/60 italic",children:"No IDEs connected"})]}),(l||p)&&u.jsx("div",{className:`text-xs mt-2 px-1 ${s==="error"||h==="error"?"text-red-400":s==="done"||h==="done"?"text-green-400":"text-text-muted"}`,children:p||l})]}),c==="disconnect"&&u.jsx(F_,{title:"🔌 Disconnect Machine",message:`Disconnect "${y}" from ADHDev?
|
|
174
174
|
|
|
175
175
|
This will close the server connection. The daemon process will continue running on the machine and will automatically reconnect.
|
|
176
176
|
|
|
@@ -181,10 +181,10 @@ This will:
|
|
|
181
181
|
• Invalidate the connection token
|
|
182
182
|
• Require running "adhdev setup" again on that machine
|
|
183
183
|
|
|
184
|
-
Use this if you accidentally set up on a shared/public computer and want to ensure it can never reconnect.`,confirmLabel:"Revoke Token",confirmColor:"red",onConfirm:B,onCancel:()=>d(null)})]})}const z4=[{id:"dark",label:"Dark",icon:"🌙"},{id:"light",label:"Light",icon:"☀️"},{id:"system",label:"System",icon:"💻"}];function $4(){const{preference:e,setPreference:t}=I4();return u.jsx("div",{className:"flex gap-2",children:z4.map(r=>u.jsxs("button",{onClick:()=>t(r.id),className:`px-3 py-1.5 rounded-lg border text-sm font-medium transition-colors flex items-center gap-1.5 ${e===r.id?"bg-accent-primary border-accent-primary text-white":"bg-bg-glass border-border-subtle hover:bg-bg-secondary text-text-muted hover:text-text-primary"}`,children:[u.jsx("span",{children:r.icon}),r.label]},r.id))})}const Ad={userBubble:"#6366f1",userText:"#ffffff",assistantBubble:"#1e1e24",assistantText:"#e0e0e0",containerBg:"#111114",accentColor:"#818cf8",sendButton:"#6366f1",inputBorder:"#2a2a35",bubbleRadius:16},Bd={userBubble:"#6366f1",userText:"#ffffff",assistantBubble:"#f3f4f6",assistantText:"#1f2937",containerBg:"#f9fafb",accentColor:"#6366f1",sendButton:"#6366f1",inputBorder:"#d1d5db",bubbleRadius:16},F4=[{id:"midnight",name:"Midnight",description:"Default gradient with violet accents",preview:{dark:{userBubble:"linear-gradient(135deg, #8b5cf6, #4f46e5)",assistantBubble:"#18181d",assistantBorder:"1px solid rgba(255,255,255,0.08)",containerBg:"#0f0f13",textColor:"rgba(255,255,255,0.7)"},light:{userBubble:"linear-gradient(135deg, #7c3aed, #0ea5e9)",assistantBubble:"#ffffff",assistantBorder:"1px solid rgba(0,0,0,0.08)",containerBg:"#f6f7f9",textColor:"#52525b"}}},{id:"aurora",name:"Aurora",description:"Vibrant pink-orange with rounded bubbles",preview:{dark:{userBubble:"linear-gradient(135deg, #ec4899, #f97316)",assistantBubble:"#1e1b2e",assistantBorder:"1px solid rgba(236,72,153,0.12)",containerBg:"#0f0d17",textColor:"rgba(255,255,255,0.7)"},light:{userBubble:"linear-gradient(135deg, #ec4899, #f97316)",assistantBubble:"#fef2f8",assistantBorder:"1px solid rgba(236,72,153,0.15)",containerBg:"#f6f7f9",textColor:"#1a1a2e"}}},{id:"honey",name:"Honey",description:"Warm yellow bubbles with clean design",preview:{dark:{userBubble:"#fbbf24",assistantBubble:"#1c1c1e",assistantBorder:"1px solid rgba(255,255,255,0.06)",containerBg:"#111113",textColor:"rgba(255,255,255,0.7)"},light:{userBubble:"#fbbf24",assistantBubble:"#fffbeb",assistantBorder:"1px solid rgba(251,191,36,0.15)",containerBg:"#f6f7f9",textColor:"#1a1a2e"}}}],Q1="adhdev-chat-theme",J1="adhdev-chat-theme-custom";function ga(){return typeof window>"u"?"midnight":localStorage.getItem(Q1)||"midnight"}function Ur(e){try{const t=localStorage.getItem(J1);if(t){const r=JSON.parse(t);return{...e==="dark"?Ad:Bd,...r[e]}}}catch{}return e==="dark"?Ad:Bd}function Vl(e,t){localStorage.setItem(J1,JSON.stringify({dark:e,light:t}))}function Ii(e){const t=document.documentElement;t.style.setProperty("--chat-user-bg",e.userBubble),t.style.setProperty("--chat-user-color",e.userText),t.style.setProperty("--chat-user-radius",`${e.bubbleRadius}px ${e.bubbleRadius}px 4px ${e.bubbleRadius}px`),t.style.setProperty("--chat-assistant-bg",e.assistantBubble),t.style.setProperty("--chat-assistant-color",e.assistantText),t.style.setProperty("--chat-assistant-radius",`${e.bubbleRadius}px ${e.bubbleRadius}px ${e.bubbleRadius}px 4px`),t.style.setProperty("--chat-assistant-border",`1px solid ${e.accentColor}22`),t.style.setProperty("--chat-container-bg",e.containerBg),t.style.setProperty("--chat-thought-accent",e.accentColor),t.style.setProperty("--chat-tool-accent",e.accentColor),t.style.setProperty("--chat-action-color",e.accentColor),t.style.setProperty("--chat-send-bg",e.sendButton),t.style.setProperty("--chat-input-border",e.inputBorder)}function W4(){const e=document.documentElement;["--chat-user-bg","--chat-user-color","--chat-user-radius","--chat-assistant-bg","--chat-assistant-color","--chat-assistant-radius","--chat-assistant-border","--chat-container-bg","--chat-thought-accent","--chat-tool-accent","--chat-action-color","--chat-send-bg","--chat-input-border"].forEach(r=>e.style.removeProperty(r))}function H4(e){if(localStorage.setItem(Q1,e),document.documentElement.setAttribute("data-chat-theme",e),e==="custom"){const t=Co()?"dark":"light";Ii(Ur(t))}else W4()}function U4(){const e=ga();if(e!=="midnight"&&document.documentElement.setAttribute("data-chat-theme",e),e==="custom"){const t=Co()?"dark":"light";Ii(Ur(t))}}function Co(){const e=document.documentElement.getAttribute("data-theme");return e?e==="dark":window.matchMedia("(prefers-color-scheme: dark)").matches}function On({label:e,value:t,onChange:r}){return u.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[u.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-secondary)",minWidth:90},children:e}),u.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[u.jsx("input",{type:"color",value:t,onChange:n=>r(n.target.value),style:{width:28,height:28,border:"none",borderRadius:6,cursor:"pointer",background:"transparent",padding:0}}),u.jsx("input",{type:"text",value:t,onChange:n=>{/^#[0-9a-fA-F]{0,6}$/.test(n.target.value)&&r(n.target.value)},style:{width:72,fontSize:"0.7rem",fontFamily:"monospace",background:"var(--bg-primary)",border:"1px solid var(--border-subtle)",borderRadius:4,padding:"3px 6px",color:"var(--text-primary)"}})]})]})}function K4({dark:e,onColorsChange:t}){const r=e?"dark":"light",[n,i]=x.useState(()=>Ur(r));x.useEffect(()=>{i(Ur(r))},[r]);const s=x.useCallback((o,l)=>{i(a=>{const c={...a,[o]:l},h=Ur(r==="dark"?"light":"dark");return r==="dark"?Vl(c,h):Vl(h,c),Ii(c),t(c),c})},[r,t]);return u.jsxs("div",{style:{marginTop:12,padding:"14px 16px",background:"var(--bg-glass)",border:"1px solid var(--border-subtle)",borderRadius:12},children:[u.jsxs("div",{style:{fontSize:"0.7rem",fontWeight:700,textTransform:"uppercase",color:"var(--text-muted)",letterSpacing:"0.06em",marginBottom:10},children:["Customize (",e?"Dark":"Light"," mode)"]}),u.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[u.jsx(On,{label:"User bubble",value:n.userBubble,onChange:o=>s("userBubble",o)}),u.jsx(On,{label:"User text",value:n.userText,onChange:o=>s("userText",o)}),u.jsx(On,{label:"Agent bubble",value:n.assistantBubble,onChange:o=>s("assistantBubble",o)}),u.jsx(On,{label:"Agent text",value:n.assistantText,onChange:o=>s("assistantText",o)}),u.jsx(On,{label:"Background",value:n.containerBg,onChange:o=>s("containerBg",o)}),u.jsx(On,{label:"Accent",value:n.accentColor,onChange:o=>s("accentColor",o)}),u.jsx(On,{label:"Send button",value:n.sendButton,onChange:o=>s("sendButton",o)}),u.jsx(On,{label:"Input border",value:n.inputBorder,onChange:o=>s("inputBorder",o)}),u.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[u.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-secondary)",minWidth:90},children:"Radius"}),u.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flex:1},children:[u.jsx("input",{type:"range",min:4,max:24,value:n.bubbleRadius,onChange:o=>s("bubbleRadius",Number(o.target.value)),style:{flex:1,accentColor:"var(--accent-primary)"}}),u.jsxs("span",{style:{fontSize:"0.7rem",color:"var(--text-muted)",width:28,textAlign:"right"},children:[n.bubbleRadius,"px"]})]})]})]}),u.jsx("button",{onClick:()=>{const o=e?Ad:Bd,a=Ur(e?"light":"dark");e?Vl(o,a):Vl(a,o),i(o),Ii(o),t(o)},style:{marginTop:10,fontSize:"0.7rem",color:"var(--text-muted)",background:"transparent",border:"1px solid var(--border-subtle)",borderRadius:6,padding:"4px 10px",cursor:"pointer"},children:"Reset to defaults"})]})}function V4(){const[e,t]=x.useState(ga),[r,n]=x.useState(!0),[i,s]=x.useState(()=>Ur("dark"));x.useEffect(()=>{n(Co());const a=new MutationObserver(()=>{const h=Co();n(h),ga()==="custom"&&Ii(Ur(h?"dark":"light"))});a.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]});const c=window.matchMedia("(prefers-color-scheme: dark)"),d=()=>{const h=Co();n(h),ga()==="custom"&&Ii(Ur(h?"dark":"light"))};return c.addEventListener("change",d),()=>{a.disconnect(),c.removeEventListener("change",d)}},[]),x.useEffect(()=>{e!=="midnight"&&document.documentElement.setAttribute("data-chat-theme",e),e==="custom"&&Ii(Ur(r?"dark":"light"))},[]),x.useEffect(()=>{s(Ur(r?"dark":"light"))},[r]);const o=a=>{t(a),H4(a),a==="midnight"&&document.documentElement.removeAttribute("data-chat-theme")},l=[...F4,{id:"custom",name:"Custom",description:"Design your own theme",preview:{dark:{userBubble:i.userBubble,assistantBubble:i.assistantBubble,assistantBorder:`1px solid ${i.accentColor}22`,containerBg:i.containerBg,textColor:i.assistantText},light:{userBubble:i.userBubble,assistantBubble:i.assistantBubble,assistantBorder:`1px solid ${i.accentColor}22`,containerBg:i.containerBg,textColor:i.assistantText}}}];return u.jsxs("div",{children:[u.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-4 gap-3",children:l.map(a=>{const c=e===a.id,d=r?a.preview.dark:a.preview.light,h=a.id==="honey"?"#1a1a1a":a.id==="custom"?i.userText:"#fff";return u.jsxs("button",{onClick:()=>o(a.id),className:"text-left rounded-xl p-3 transition-all",style:{background:c?"var(--bg-glass-hover)":"var(--bg-glass)",border:c?"2px solid var(--accent-primary)":"2px solid var(--border-subtle)",opacity:c?1:.75},children:[u.jsxs("div",{className:"rounded-lg p-3 mb-2.5 flex flex-col gap-1.5",style:{background:d.containerBg},children:[u.jsx("div",{className:"self-start rounded-xl px-3 py-1.5 text-[10px] max-w-[75%]",style:{background:d.assistantBubble,border:d.assistantBorder,color:d.textColor},children:"Hello! How can I help?"}),u.jsx("div",{className:"self-end rounded-xl px-3 py-1.5 text-[10px] max-w-[75%]",style:{background:d.userBubble,color:h},children:"Fix the bug please"}),u.jsx("div",{className:"self-start rounded-xl px-3 py-1.5 text-[10px] max-w-[75%]",style:{background:d.assistantBubble,border:d.assistantBorder,color:d.textColor},children:"On it! ✨"})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[c&&u.jsx("span",{className:"w-2 h-2 rounded-full bg-accent shrink-0"}),u.jsxs("div",{children:[u.jsx("div",{className:"text-sm font-bold text-text-primary",children:a.id==="custom"?"🎨 Custom":a.name}),u.jsx("div",{className:"text-[10px] text-text-muted",children:a.description})]})]})]},a.id)})}),e==="custom"&&u.jsx(K4,{dark:r,onColorsChange:a=>s(a)})]})}const Od="adhdev-accent-color",q4=[{name:"Violet",color:"#8b5cf6"},{name:"Indigo",color:"#6366f1"},{name:"Blue",color:"#3b82f6"},{name:"Cyan",color:"#06b6d4"},{name:"Emerald",color:"#10b981"},{name:"Rose",color:"#f43f5e"},{name:"Orange",color:"#f97316"},{name:"Amber",color:"#f59e0b"}],Jo="#8b5cf6";function Y4(e){const t=parseInt(e.slice(1,3),16)/255,r=parseInt(e.slice(3,5),16)/255,n=parseInt(e.slice(5,7),16)/255,i=Math.max(t,r,n),s=Math.min(t,r,n);let o=0,l=0;const a=(i+s)/2;if(i!==s){const c=i-s;switch(l=a>.5?c/(2-i-s):c/(i+s),i){case t:o=((r-n)/c+(r<n?6:0))/6;break;case r:o=((n-t)/c+2)/6;break;case n:o=((t-r)/c+4)/6;break}}return{h:Math.round(o*360),s:Math.round(l*100),l:Math.round(a*100)}}function W_(e,t){const{h:r,s:n,l:i}=Y4(e),s=Math.min(100,i+t);return`hsl(${r}, ${n}%, ${s}%)`}function _a(e,t){const r=parseInt(e.slice(1,3),16),n=parseInt(e.slice(3,5),16),i=parseInt(e.slice(5,7),16);return`rgba(${r}, ${n}, ${i}, ${t})`}function H_(){return typeof window>"u"?Jo:localStorage.getItem(Od)||Jo}function X4(e){const t=document.documentElement;t.style.setProperty("--accent-primary",e),t.style.setProperty("--accent-primary-light",W_(e,15)),t.style.setProperty("--accent-gradient",`linear-gradient(135deg, ${e}, ${W_(e,20)})`),t.style.setProperty("--border-accent",_a(e,.4)),t.style.setProperty("--nav-active-bg",_a(e,.1)),t.style.setProperty("--nav-active-shadow",`inset 3px 0 0 ${e}, 0 0 12px ${_a(e,.06)}`)}function G4(){const e=document.documentElement;["--accent-primary","--accent-primary-light","--accent-gradient","--border-accent","--nav-active-bg","--nav-active-shadow"].forEach(r=>e.style.removeProperty(r))}function Q4(e){e===Jo?(localStorage.removeItem(Od),G4()):(localStorage.setItem(Od,e),X4(e))}function J4(){const[e,t]=x.useState(H_),[r,n]=x.useState("");x.useEffect(()=>{t(H_())},[]);const i=s=>{t(s),Q4(s)};return u.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[u.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:8},children:q4.map(s=>{const o=e===s.color;return u.jsx("button",{onClick:()=>i(s.color),title:s.name,style:{width:36,height:36,borderRadius:10,background:s.color,border:o?"3px solid var(--text-primary)":"3px solid transparent",cursor:"pointer",position:"relative",transition:"transform 0.15s, border-color 0.15s",transform:o?"scale(1.1)":"scale(1)",boxShadow:o?`0 0 12px ${_a(s.color,.4)}`:"none"},children:o&&u.jsx("span",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",color:"#fff",fontSize:14,fontWeight:700,textShadow:"0 1px 2px rgba(0,0,0,0.5)"},children:"✓"})},s.color)})}),u.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[u.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"Custom:"}),u.jsx("input",{type:"color",value:e,onChange:s=>i(s.target.value),style:{width:28,height:28,border:"none",borderRadius:6,cursor:"pointer",background:"transparent",padding:0}}),u.jsx("input",{type:"text",value:r||e,onChange:s=>{n(s.target.value),/^#[0-9a-fA-F]{6}$/.test(s.target.value)&&i(s.target.value)},onBlur:()=>n(""),style:{width:80,fontSize:"0.7rem",fontFamily:"monospace",background:"var(--bg-primary)",border:"1px solid var(--border-subtle)",borderRadius:4,padding:"3px 6px",color:"var(--text-primary)"}}),e!==Jo&&u.jsx("button",{onClick:()=>i(Jo),style:{fontSize:"0.7rem",color:"var(--text-muted)",background:"transparent",border:"1px solid var(--border-subtle)",borderRadius:5,padding:"3px 8px",cursor:"pointer"},children:"Reset"})]})]})}const Z1="adhdev_hiddenTabs";function Z4(){try{const e=localStorage.getItem(Z1);if(e)return new Set(JSON.parse(e))}catch{}return new Set}function eo(e){try{localStorage.setItem(Z1,JSON.stringify([...e]))}catch{}}function eI(){const[e,t]=x.useState(Z4),r=x.useCallback(a=>{t(c=>{const d=new Set(c);return d.has(a)?d.delete(a):d.add(a),eo(d),d})},[]),n=x.useCallback(a=>{t(c=>{if(c.has(a))return c;const d=new Set(c);return d.add(a),eo(d),d})},[]),i=x.useCallback(a=>{t(c=>{if(!c.has(a))return c;const d=new Set(c);return d.delete(a),eo(d),d})},[]),s=x.useCallback((a,c)=>{t(d=>{const h=new Set(d);for(const f of c)h.add(f);return eo(h),h})},[]),o=x.useCallback((a,c)=>{t(d=>{const h=new Set(d);for(const f of c)h.delete(f);return eo(h),h})},[]),l=x.useCallback(a=>e.has(a),[e]);return{hiddenTabs:e,toggleTab:r,hideTab:n,showTab:i,hideAllForDaemon:s,showAllForDaemon:o,isHidden:l}}function eb({sendDaemonCommand:e,activeConv:t,ides:r,updateIdeChats:n,setToasts:i,setLocalUserMessages:s,setClearedTabs:o,setActionLogs:l,pinTab:a,isStandalone:c}){const[d,h]=x.useState(""),[f,p]=x.useState(!1),[m,_]=x.useState(!1),[b,g]=x.useState(!1),v=x.useCallback(async()=>{if(!t)return;const k=d.trim();if(!k)return;const B=t.ideId,j=t.tabKey;h(""),a(j,[100,500,1500,3e3]);const M=`${Date.now()}-${Math.random().toString(36).slice(2,8)}`,C={role:"user",content:k,timestamp:Date.now(),_localId:M};s(A=>({...A,[j]:[...A[j]||[],C]}));try{if(si(t)&&!ln(t)){const A=B||t.daemonId||"";if(!A)return;const O=t.ideType||t.agentType||"";await e(A,"agent_command",{agentType:O,cliType:O,action:"send_chat",message:k,text:k})}else if(ln(t)){const A=B||t.daemonId||"";if(!A)return;await e(A,"send_chat",{message:k,text:k,agentType:t.agentType})}else{const A=B||t.daemonId||"";if(!A)return;await e(A,"send_chat",{message:k,text:k,...t.streamSource==="agent-stream"&&{agentType:t.agentType}})}setTimeout(()=>{const A=Date.now()-6e4;s(O=>{const U=O[j];if(!U)return O;const L=U.filter($=>$.timestamp>A);return L.length===U.length?O:{...O,[j]:L}})},6e4)}catch(A){console.error("Send failed",A),h(k),s(O=>({...O,[j]:(O[j]||[]).filter(U=>U._localId!==M)}))}},[t,d,e,s,a]),y=x.useCallback(async()=>{if(t)try{c?await e(t.ideId,"launch_ide",{ideType:t.ideType,enableCdp:!0}):await e(t.ideId,"vscode_command_exec",{commandId:"adhdev.relaunchWithCdp",args:[{force:!0}]})}catch(k){console.error("Relaunch failed",k)}},[t,c,e]),S=x.useCallback(async k=>{try{await e("standalone","launch_ide",{ideType:k,enableCdp:!0})}catch(B){console.error("Launch failed",B)}},[e]),R=x.useCallback(async k=>{if(t){console.log("[ModalButton] ideId:",t.ideId,"button:",k),l(B=>[...B,{ideId:t.tabKey,text:`🖱️ **${k}** clicked`,timestamp:Date.now()}]);try{const j=(t.modalButtons||[]).indexOf(k),M=k.replace(/[⌥⏎⇧⌫⌘⌃]/g,"").trim().toLowerCase(),C=/^(run|approve|accept|yes|allow|always|proceed|save)/.test(M),A=t.ideId||t.daemonId||"";(await e(A,"resolve_action",{button:k,action:C?"approve":"reject",...j>=0&&{buttonIndex:j},...t.streamSource==="agent-stream"&&{agentType:t.agentType}})).success||l(U=>[...U,{ideId:t.tabKey,text:`⚠️ **${k}** failed — button not found`,timestamp:Date.now()}])}catch(B){console.error("[ModalButton] Error:",B),l(j=>[...j,{ideId:t.tabKey,text:`❌ **${k}** error`,timestamp:Date.now()}])}}},[t,e,l]),E=x.useCallback(async(k,B)=>{try{const j=k||(t==null?void 0:t.daemonId)||"",M=await e(j,"switch_chat",{id:B,sessionId:B,...(t==null?void 0:t.streamSource)==="agent-stream"&&{agentType:t==null?void 0:t.agentType}}),C=M==null?void 0:M.result;(M==null?void 0:M.success)===!0||C==="switched"||C==="switched-by-title"||(C===!1||C==="not_found"?i(O=>[...O,{id:Date.now(),message:"⚠️ Session tab not found — try refreshing history",type:"warning",timestamp:Date.now()}]):typeof C=="string"&&C.startsWith("error:")?i(O=>[...O,{id:Date.now(),message:`⚠️ Switch error: ${C}`,type:"warning",timestamp:Date.now()}]):i(O=>[...O,{id:Date.now(),message:"⚠️ Session switch failed",type:"warning",timestamp:Date.now()}]))}catch(j){console.error("Switch failed",j),i(M=>[...M,{id:Date.now(),message:`❌ Switch failed: ${j.message||"connection error"}`,type:"warning",timestamp:Date.now()}])}},[t,e,i]),P=x.useCallback(async()=>{if(!(!t||f)){p(!0);try{const k=t.ideId||t.daemonId||"";await e(k,"new_chat",{...t.streamSource==="agent-stream"&&{agentType:t.agentType}}),o(B=>({...B,[t.tabKey]:Date.now()})),s(B=>({...B,[t.tabKey]:[]}))}catch(k){console.error("New chat failed",k)}finally{p(!1)}}},[t,f,e,o,s]),N=x.useCallback(async()=>{if(!t||b)return;g(!0);const k=t.tabKey;try{await e(t.ideId,"agent_stream_focus",{agentType:t.agentType}),a(k,[200,1500,3e3])}catch(B){console.error("Focus agent failed",B)}finally{g(!1)}},[t,b,e,a]),D=x.useCallback(async()=>{var k;if(!(!t||m)){_(!0);try{const B=t.ideId||t.daemonId||"",j=await e(B,"list_chats",{forceExpand:!0,...t.streamSource==="agent-stream"&&{agentType:t.agentType}}),M=(j==null?void 0:j.chats)||((k=j==null?void 0:j.result)==null?void 0:k.chats);j!=null&&j.success&&Array.isArray(M)&&n(t.ideId,M)}catch(B){console.error("Refresh history failed",B)}finally{_(!1)}}},[t,m,e,n]);return{agentInput:d,setAgentInput:h,isCreatingChat:f,isRefreshingHistory:m,isFocusingAgent:b,handleSendChat:v,handleRelaunch:y,handleLaunchIde:S,handleModalButton:R,handleSwitchSession:E,handleNewChat:P,handleFocusAgent:N,handleRefreshHistory:D}}let $u=null;function tI({conversations:e,ides:t,messageReceivedAt:r,actionLogs:n,ptyBuffers:i,screenshotMap:s,setScreenshotMap:o,sendDaemonCommand:l,updateIdeChats:a,setToasts:c,setLocalUserMessages:d,setClearedTabs:h,setActionLogs:f,pinTab:p,isStandalone:m,userName:_,groupIndex:b,isFocused:g,onFocus:v,isSplitMode:y,numGroups:S,onMoveTab:R,onClose:E,onReceiveTab:P,style:N,detectedIdes:D,handleLaunchIde:k,onActiveTabChange:B,initialActiveTabId:j,initialTabOrder:M,onTabOrderChange:C,onHideTab:A}){const{sendCommand:O}=ui(),U=x.useRef(null),[L,$]=x.useState(!1),w=x.useRef(0),ee=x.useRef(null),[ne,T]=x.useState(j??null);x.useEffect(()=>{j&&j!==ne&&T(j)},[j]);const[X,I]=x.useState(M??[]),[F,G]=x.useState(null),he=x.useRef(null),me=x.useRef(null);x.useEffect(()=>{const K=new Set(e.map(oe=>oe.tabKey));I(oe=>{const xe=oe.filter(q=>K.has(q)),Oe=e.filter(q=>!oe.includes(q.tabKey)).map(q=>q.tabKey),Se=[...xe,...Oe];return Se.length===oe.length&&Se.every((q,te)=>q===oe[te])?oe:Se})},[e]);const je=F??X,Pe=x.useMemo(()=>{if(je.length===0)return e;const K=new Map(je.map((oe,xe)=>[oe,xe]));return[...e].sort((oe,xe)=>{const Oe=K.get(oe.tabKey)??999,Se=K.get(xe.tabKey)??999;return Oe-Se})},[e,je]);x.useEffect(()=>{if(Pe.length===0){T(null),B==null||B(null);return}ne&&Pe.some(K=>K.tabKey===ne)||(T(Pe[0].tabKey),B==null||B(Pe[0].tabKey))},[Pe,ne]);const Ce=Pe.find(K=>K.tabKey===ne),de=x.useCallback((K,oe,xe)=>{I(Oe=>{const Se=Oe.filter(Z=>Z!==K),q=Se.indexOf(oe);if(q<0)return Oe;const te=xe==="left"?q:q+1;return Se.splice(te,0,K),C==null||C(Se),Se}),G(null)},[C]),Te=x.useCallback((K,oe,xe)=>{const Se=(X.length>0?X:e.map(Z=>Z.tabKey)).filter(Z=>Z!==K),q=Se.indexOf(oe);if(q<0)return;const te=xe==="left"?q:q+1;Se.splice(te,0,K),he.current=Se,G(Se)},[X,e]),J=eb({sendDaemonCommand:l,activeConv:Ce,ides:t,updateIdeChats:a,setToasts:c,setLocalUserMessages:d,setClearedTabs:h,setActionLogs:f,pinTab:p,isStandalone:m}),[fe,ke]=x.useState(null);x.useEffect(()=>{if(!fe)return;const K=oe=>{const xe=document.querySelector("[data-pane-context-menu]");xe&&xe.contains(oe.target)||ke(null)};return window.addEventListener("mousedown",K,!0),()=>window.removeEventListener("mousedown",K,!0)},[fe]);const Me="adhdev-tab-shortcuts",we=typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.userAgent),[Ke,nr]=x.useState(()=>{try{return JSON.parse(localStorage.getItem(Me)||"{}")}catch{return{}}}),[Qe,ir]=x.useState(null),sr=x.useCallback(K=>{const oe=[];K.metaKey&&oe.push(we?"⌘":"Meta"),K.ctrlKey&&oe.push("Ctrl"),K.altKey&&oe.push(we?"⌥":"Alt"),K.shiftKey&&oe.push(we?"⇧":"Shift");const xe=K.key;if(["Control","Alt","Shift","Meta"].includes(xe))return null;const Oe=xe.length===1?xe.toUpperCase():xe;return oe.push(Oe),oe.join("+")},[we]),$t=x.useCallback((K,oe)=>sr(K)===oe,[sr]),Y=x.useCallback(K=>{nr(K),localStorage.setItem(Me,JSON.stringify(K))},[]);x.useEffect(()=>{if(!Qe)return;const K=oe=>{if(oe.preventDefault(),oe.stopPropagation(),oe.key==="Escape"){ir(null);return}const xe=sr(oe);if(!xe)return;const Oe={...Ke};for(const[Se,q]of Object.entries(Oe))q===xe&&delete Oe[Se];Oe[Qe]=xe,Y(Oe),ir(null)};return window.addEventListener("keydown",K,!0),()=>window.removeEventListener("keydown",K,!0)},[Qe,Ke,Y,sr]),x.useEffect(()=>{const K=oe=>{if(!(!oe.ctrlKey&&!oe.metaKey&&!oe.altKey)){for(const[xe,Oe]of Object.entries(Ke))if($t(oe,Oe)&&Pe.some(Se=>Se.tabKey===xe)){oe.preventDefault(),v(),T(xe),B==null||B(xe);return}}};return window.addEventListener("keydown",K),()=>window.removeEventListener("keydown",K)},[Ke,Pe,v,B,$t]);const se=Ce&&si(Ce)&&!ln(Ce);x.useEffect(()=>{const K=()=>{w.current=0,$(!1)};return window.addEventListener("dragend",K),window.addEventListener("drop",K),()=>{window.removeEventListener("dragend",K),window.removeEventListener("drop",K)}},[]);const ye=x.useRef(null);return x.useEffect(()=>{const K=ye.current;if(!K)return;const oe=xe=>{Math.abs(xe.deltaY)>Math.abs(xe.deltaX)&&(xe.preventDefault(),K.scrollLeft+=xe.deltaY)};return K.addEventListener("wheel",oe,{passive:!1}),()=>K.removeEventListener("wheel",oe)},[]),u.jsxs("div",{className:"flex flex-col min-h-0 min-w-0 flex-1 overflow-hidden",onClick:v,onDragEnter:K=>{if(K.dataTransfer.types.includes("text/tab-key")){w.current++;const oe=$u;oe&&e.some(Oe=>Oe.tabKey===oe)||$(!0)}},onDragOver:K=>{K.dataTransfer.types.includes("text/tab-key")&&K.preventDefault()},onDragLeave:()=>{w.current--,w.current<=0&&(w.current=0,$(!1))},onDrop:K=>{w.current=0,$(!1),G(null);const oe=K.dataTransfer.getData("text/tab-key");if(!oe)return;K.preventDefault(),e.some(Oe=>Oe.tabKey===oe)?I(Oe=>{const Se=Oe.filter(q=>q!==oe);return Se.push(oe),C==null||C(Se),Se}):P&&P(oe)},style:{...N,outline:L?"2px dashed var(--accent-primary)":"none",outlineOffset:"-2px",transition:"outline 0.15s ease"},children:[u.jsx("div",{className:"flex items-center bg-bg-secondary border-b border-border-subtle shrink-0 gap-0",children:u.jsxs("div",{ref:ye,className:"flex-1 flex overflow-x-auto overflow-y-visible pt-1.5 pb-0 gap-1 select-none",style:{paddingLeft:8,paddingRight:4,scrollbarWidth:"none"},children:[Pe.map((K,oe)=>{const xe=ne===K.tabKey,Oe=K.status==="working"?"agent-tab-working":K.status==="waiting_approval"?"agent-tab-waiting":"",Se=K.connectionState==="failed"||K.connectionState==="closed",q=me.current===K.tabKey;return u.jsxs("div",{"data-tabkey":K.tabKey,className:`${Oe} shrink-0 px-2.5 py-1.5 rounded-t-lg cursor-pointer flex items-center gap-2 relative`,draggable:!("ontouchstart"in window),onDragStart:te=>{$u=K.tabKey,me.current=K.tabKey,te.dataTransfer.setData("text/tab-key",K.tabKey),te.dataTransfer.effectAllowed="move"},onDragEnd:()=>{$u=null,me.current=null;const te=he.current;te&&(I(te),C==null||C(te)),he.current=null,G(null),w.current=0,$(!1)},onDragOver:te=>{const Z=me.current;if(!(!Z||Z===K.tabKey)&&te.dataTransfer.types.includes("text/tab-key")){te.preventDefault(),te.stopPropagation();const ve=te.currentTarget.getBoundingClientRect(),Re=ve.left+ve.width/2,Le=te.clientX<Re?"left":"right";Te(Z,K.tabKey,Le)}},onDrop:te=>{te.preventDefault(),te.stopPropagation();const Z=te.dataTransfer.getData("text/tab-key");if(Z&&Z!==K.tabKey){const ve=te.currentTarget.getBoundingClientRect(),Re=ve.left+ve.width/2,Le=te.clientX<Re?"left":"right";Pe.some(pt=>pt.tabKey===Z)?de(Z,K.tabKey,Le):P&&P(Z)}G(null)},onClick:te=>{te.stopPropagation(),v(),T(K.tabKey),B==null||B(K.tabKey),K.streamSource==="agent-stream"&&K.agentType&&O(K.ideId,"agent_stream_focus",{agentType:K.agentType}).catch(()=>{}),si(K)&&setTimeout(()=>{var Z,ve;return(ve=(Z=U.current)==null?void 0:Z.bumpResize)==null?void 0:ve.call(Z)},100)},onContextMenu:te=>{te.preventDefault(),ke({x:te.clientX,y:te.clientY,tabKey:K.tabKey})},onTouchStart:te=>{const Z=te.touches[0],ve=Z.clientX,Re=Z.clientY;ee.current=setTimeout(()=>{ke({x:ve,y:Re,tabKey:K.tabKey})},600)},onTouchEnd:()=>{ee.current&&clearTimeout(ee.current)},onTouchMove:()=>{ee.current&&clearTimeout(ee.current)},style:{background:xe?"var(--bg-primary)":"var(--bg-glass)",borderTop:xe?"1px solid var(--border-subtle)":"1px solid transparent",borderLeft:xe?"1px solid var(--border-subtle)":"1px solid transparent",borderRight:xe?"1px solid var(--border-subtle)":"1px solid transparent",opacity:q?.4:Se?xe?.6:.3:xe?1:.65,transition:"transform 0.2s ease, opacity 0.15s ease"},children:[K.status==="working"?u.jsx("div",{className:"tab-spinner"}):K.status==="waiting_approval"?u.jsx("span",{className:"text-[8px] px-[5px] py-px text-yellow-400",children:"▲"}):Se?u.jsx("span",{className:"text-[8px] px-[5px] py-px text-yellow-400 animate-pulse",children:"○"}):K.connectionState==="connecting"||K.connectionState==="new"?u.jsx("div",{className:"tab-connecting-spinner"}):K.connectionState==="connected"?u.jsx("span",{className:"text-[8px] px-[5px] py-px text-green-400",children:"●"}):u.jsx("span",{className:"text-[8px] px-[5px] py-px text-text-muted animate-pulse",children:"○"}),u.jsxs("div",{className:"min-w-0",children:[u.jsx("div",{className:"text-xs font-bold whitespace-nowrap overflow-hidden text-ellipsis",children:K.displayPrimary}),u.jsx("div",{className:"text-[8px] opacity-50 flex gap-1 items-center",children:Se?u.jsx("span",{className:"text-yellow-400 opacity-100",children:"Reconnecting…"}):K.connectionState==="connecting"||K.connectionState==="new"?u.jsxs("span",{className:"text-blue-400 opacity-100",children:["Connecting",u.jsx("span",{className:"connecting-dots"})]}):u.jsxs(u.Fragment,{children:[K.displaySecondary,K.machineName&&u.jsxs(u.Fragment,{children:[u.jsx("span",{className:"opacity-40",children:"·"}),u.jsxs("span",{className:"opacity-70",children:["🖥 ",K.machineName]})]})]})})]}),Ke[K.tabKey]&&u.jsx("span",{className:"text-[9px] opacity-50 font-mono ml-0.5 shrink-0 bg-bg-secondary px-1 rounded",title:`Ctrl+${Ke[K.tabKey]}`,children:Ke[K.tabKey]})]},K.tabKey)}),e.length===0&&u.jsx("div",{className:"p-2 text-xs opacity-40",children:"No tabs in this group"})]})}),u.jsx("div",{className:"flex-1 min-h-0 flex flex-col overflow-hidden relative",children:Ce?u.jsxs(u.Fragment,{children:[u.jsx(M1,{activeConv:Ce,onModalButton:J.handleModalButton}),u.jsx("div",{className:"desktop-only px-3 pt-1 pb-2",children:!se&&!ln(Ce)&&s[Ce.ideId]?u.jsx(uL,{screenshotUrl:s[Ce.ideId],mode:"preview",onDismiss:()=>{const K={...s};delete K[Ce.ideId],o(K)}}):!se&&!ln(Ce)&&Ce.cdpConnected===!1?u.jsxs("div",{className:"flex items-center gap-2.5 px-3.5 py-2 bg-yellow-500/[0.08] border border-yellow-500/20 rounded-lg text-xs text-text-secondary",children:[u.jsx("span",{className:"text-sm",children:u.jsx(A0,{size:14})}),u.jsx("span",{className:"flex-1",children:"CDP not connected — chat history & screenshots unavailable."}),u.jsx("button",{className:"btn btn-sm bg-yellow-500/15 text-yellow-500 border border-yellow-500/30 text-[10px] whitespace-nowrap shrink-0",onClick:J.handleRelaunch,children:"Relaunch with CDP"})]}):null}),se?u.jsx(dL,{activeConv:Ce,ptyBuffers:i,terminalRef:U,agentInput:J.agentInput,setAgentInput:J.setAgentInput,handleSendChat:J.handleSendChat,handleModalButton:J.handleModalButton}):u.jsx(L1,{activeConv:Ce,ides:t,agentInput:J.agentInput,setAgentInput:J.setAgentInput,handleSendChat:J.handleSendChat,handleFocusAgent:J.handleFocusAgent,isFocusingAgent:J.isFocusingAgent,messageReceivedAt:r,actionLogs:n,userName:_})]}):u.jsx("div",{className:"flex-1 flex flex-col items-center justify-center",children:e.length===0&&!y&&D&&k?u.jsxs("div",{className:"empty-dashboard",children:[u.jsx("div",{className:"glow-orb",children:u.jsx("img",{src:"/otter-logo.png",alt:"",className:"w-12 h-12"})}),u.jsxs("div",{className:"text-center",children:[u.jsx("div",{className:"font-bold text-lg mb-1.5",children:"Waiting for your IDE"}),u.jsx("div",{className:"text-[13px] text-text-muted",style:{marginBottom:12},children:m?"Launch an IDE with CDP to start monitoring":"Install the daemon, then open your IDE — it connects automatically."}),!m&&u.jsxs("div",{style:{background:"var(--bg-secondary, #111)",borderRadius:"0.5rem",padding:"0.5rem 0.75rem",display:"inline-block",fontFamily:"monospace",fontSize:"0.75rem",color:"var(--accent, #a78bfa)",marginBottom:12,textAlign:"left",border:"1px solid var(--border-subtle, #333)"},children:[u.jsx("span",{style:{color:"var(--text-muted)"},children:"$ "}),"npm i -g adhdev && adhdev setup && adhdev daemon"]}),m&&D.length>0&&u.jsx("div",{className:"flex flex-wrap gap-2 justify-center",children:D.map(K=>u.jsx("button",{className:"btn btn-sm bg-violet-500/10 border border-violet-500/25 text-violet-400 text-xs font-semibold px-4 py-2 rounded-lg cursor-pointer flex items-center gap-1.5 transition-all",onClick:()=>k(K.type),onMouseEnter:oe=>oe.currentTarget.style.background="rgba(139,92,246,0.2)",onMouseLeave:oe=>oe.currentTarget.style.background="rgba(139,92,246,0.1)",children:u.jsxs("span",{className:"flex items-center gap-1.5",children:[u.jsx($P,{size:14})," Launch ",K.name]})},K.type))}),u.jsx("div",{style:{marginTop:8},children:u.jsx("a",{href:"https://docs.adhf.dev/guide/getting-started",target:"_blank",rel:"noopener noreferrer",style:{fontSize:"0.75rem",color:"var(--accent, #a78bfa)",textDecoration:"none"},children:"📚 Setup guide →"})})]})]}):u.jsx("div",{className:"text-sm text-text-muted opacity-50",children:y?"Move a tab here to view":"No active agent"})})}),fe&&u.jsxs("div",{"data-pane-context-menu":!0,className:"fixed z-50 bg-bg-primary border border-border-subtle rounded-lg shadow-lg py-1 min-w-[160px]",style:{left:fe.x,top:fe.y},children:[R&&b>0&&u.jsx("button",{className:"w-full text-left px-3 py-1.5 text-xs hover:bg-bg-secondary transition-colors hidden md:block",onClick:()=>{R(fe.tabKey,"left"),ke(null)},children:"← Move to Left Group"}),R&&b<S-1&&u.jsx("button",{className:"w-full text-left px-3 py-1.5 text-xs hover:bg-bg-secondary transition-colors hidden md:block",onClick:()=>{R(fe.tabKey,"right"),ke(null)},children:"Move to Right Group →"}),R&&S<4&&u.jsx("button",{className:"w-full text-left px-3 py-1.5 text-xs hover:bg-bg-secondary transition-colors hidden md:block",onClick:()=>{R(fe.tabKey,"new"),ke(null)},children:"Split to New Group ◨"}),u.jsx("div",{className:"border-t border-border-subtle my-1 hidden md:block"}),u.jsxs("button",{className:"w-full text-left px-3 py-1.5 text-xs hover:bg-bg-secondary transition-colors hidden md:block",onClick:K=>{K.stopPropagation(),ir(fe.tabKey),ke(null)},children:["⌨ ",Ke[fe.tabKey]?`Change shortcut (${Ke[fe.tabKey]})`:"Set shortcut"]}),Ke[fe.tabKey]&&u.jsx("button",{className:"w-full text-left px-3 py-1.5 text-xs hover:bg-bg-secondary transition-colors text-text-muted hidden md:block",onClick:()=>{const K={...Ke};delete K[fe.tabKey],Y(K),ke(null)},children:"✕ Remove shortcut"}),A&&u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"border-t border-border-subtle my-1"}),u.jsx("button",{className:"w-full text-left px-3 py-1.5 text-xs hover:bg-bg-secondary transition-colors text-text-muted",onClick:()=>{A(fe.tabKey),ke(null)},children:"🚫 Hide from Dashboard"})]}),!R&&!A&&u.jsx("div",{className:"px-3 py-1.5 text-[11px] text-text-muted opacity-50 italic",children:"No actions available"})]}),Qe&&u.jsx("div",{className:"fixed inset-0 z-[60] flex items-center justify-center",style:{background:"rgba(0,0,0,0.5)",backdropFilter:"blur(2px)"},onClick:()=>ir(null),children:u.jsxs("div",{className:"bg-bg-primary border border-border-subtle rounded-xl px-8 py-6 text-center shadow-xl",onClick:K=>K.stopPropagation(),children:[u.jsx("div",{className:"text-sm font-bold text-text-primary mb-2",children:"⌨ Set shortcut"}),u.jsxs("div",{className:"text-xs text-text-secondary mb-4",children:["Press a key combo (e.g. ",we?"⌘+1":"Ctrl+1",", ",we?"⌥+A":"Alt+A",")"]}),u.jsx("div",{className:"text-lg font-mono text-accent-primary animate-pulse",children:"Listening..."}),u.jsx("div",{className:"text-[10px] text-text-muted mt-3",children:"Press Esc to cancel"})]})})]})}const Fu=[{icon:"🦦",title:"Welcome to ADHDev",desc:"Monitor and control your AI coding agents from anywhere — web, mobile, or CLI.",visual:"🎉"},{icon:"💬",title:"Real-time chat",desc:"See what your AI agent is doing in real-time. Send messages, approve or reject actions — all from your browser or phone.",visual:"📱"},{icon:"🖥️",title:"Remote desktop",desc:"View and control your IDE screen via P2P connection. Click, type, scroll — just like being there.",visual:"🖱️"},{icon:"🚀",title:"Get started",desc:"Install the daemon and open your IDE — it connects automatically.",code:"curl -fsSL https://adhf.dev/install | sh"}];function rI({onClose:e}){const[t,r]=x.useState(0),n=Fu[t],i=t===Fu.length-1;return u.jsxs("div",{className:"onboarding-overlay",style:{position:"fixed",inset:0,zIndex:9999,background:"rgba(0,0,0,0.65)",backdropFilter:"blur(6px)",display:"flex",alignItems:"center",justifyContent:"center",animation:"fadeIn 0.3s ease-out"},onClick:s=>{s.target===s.currentTarget&&e()},children:[u.jsxs("div",{style:{background:"var(--bg-secondary, #1a1a2e)",border:"1px solid var(--border-subtle, #333)",borderRadius:"1.25rem",width:"min(440px, 92vw)",padding:"2.5rem 2rem 2rem",position:"relative",animation:"slideUp 0.3s ease-out"},children:[u.jsx("button",{onClick:e,style:{position:"absolute",top:12,right:16,background:"transparent",border:"none",color:"var(--text-muted)",fontSize:"1.2rem",cursor:"pointer"},children:"✕"}),u.jsx("div",{style:{display:"flex",justifyContent:"center",gap:6,marginBottom:"1.5rem"},children:Fu.map((s,o)=>u.jsx("div",{style:{width:o===t?24:8,height:8,borderRadius:4,background:o===t?"var(--accent, #7c3aed)":"var(--border-subtle, #444)",transition:"all 0.3s ease"}},o))}),u.jsx("div",{style:{textAlign:"center",fontSize:"3rem",marginBottom:"1rem"},children:n.visual||n.icon}),u.jsxs("div",{style:{textAlign:"center"},children:[u.jsxs("h2",{style:{fontSize:"1.35rem",fontWeight:700,color:"var(--text-primary)",marginBottom:"0.75rem",display:"flex",alignItems:"center",justifyContent:"center",gap:8},children:[u.jsx("span",{children:n.icon})," ",n.title]}),u.jsx("p",{style:{fontSize:"0.9rem",color:"var(--text-secondary)",lineHeight:1.6,marginBottom:"1.25rem"},children:n.desc}),n.code&&u.jsxs("div",{style:{background:"var(--bg-primary, #111)",border:"1px solid var(--border-subtle, #333)",borderRadius:"0.5rem",padding:"0.75rem 1rem",fontFamily:"monospace",fontSize:"0.8rem",color:"var(--accent, #a78bfa)",textAlign:"left",overflowX:"auto",marginBottom:"0.5rem"},children:[u.jsx("span",{style:{color:"var(--text-muted)",marginRight:8},children:"$"}),n.code]}),i&&u.jsx("a",{href:"https://docs.adhf.dev",target:"_blank",rel:"noopener noreferrer",style:{fontSize:"0.75rem",color:"var(--accent, #a78bfa)",textDecoration:"none"},children:"📚 Learn more in the docs →"})]}),u.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginTop:"1.5rem"},children:[u.jsx("button",{onClick:e,style:{background:"transparent",border:"none",color:"var(--text-muted)",fontSize:"0.85rem",cursor:"pointer"},children:"Skip"}),u.jsx("button",{onClick:()=>i?e():r(s=>s+1),style:{background:"linear-gradient(135deg, #7c3aed, #6366f1)",color:"#fff",border:"none",borderRadius:"0.5rem",padding:"0.55rem 1.5rem",fontSize:"0.9rem",fontWeight:600,cursor:"pointer",transition:"opacity 0.2s"},onMouseEnter:s=>s.currentTarget.style.opacity="0.85",onMouseLeave:s=>s.currentTarget.style.opacity="1",children:i?"Get Started →":"Next →"})]})]}),u.jsx("style",{children:`
|
|
184
|
+
Use this if you accidentally set up on a shared/public computer and want to ensure it can never reconnect.`,confirmLabel:"Revoke Token",confirmColor:"red",onConfirm:B,onCancel:()=>d(null)})]})}const z4=[{id:"dark",label:"Dark",icon:"🌙"},{id:"light",label:"Light",icon:"☀️"},{id:"system",label:"System",icon:"💻"}];function $4(){const{preference:e,setPreference:t}=I4();return u.jsx("div",{className:"flex gap-2",children:z4.map(r=>u.jsxs("button",{onClick:()=>t(r.id),className:`px-3 py-1.5 rounded-lg border text-sm font-medium transition-colors flex items-center gap-1.5 ${e===r.id?"bg-accent-primary border-accent-primary text-white":"bg-bg-glass border-border-subtle hover:bg-bg-secondary text-text-muted hover:text-text-primary"}`,children:[u.jsx("span",{children:r.icon}),r.label]},r.id))})}const Ad={userBubble:"#6366f1",userText:"#ffffff",assistantBubble:"#1e1e24",assistantText:"#e0e0e0",containerBg:"#111114",accentColor:"#818cf8",sendButton:"#6366f1",inputBorder:"#2a2a35",bubbleRadius:16},Bd={userBubble:"#6366f1",userText:"#ffffff",assistantBubble:"#f3f4f6",assistantText:"#1f2937",containerBg:"#f9fafb",accentColor:"#6366f1",sendButton:"#6366f1",inputBorder:"#d1d5db",bubbleRadius:16},F4=[{id:"midnight",name:"Midnight",description:"Default gradient with violet accents",preview:{dark:{userBubble:"linear-gradient(135deg, #8b5cf6, #4f46e5)",assistantBubble:"#18181d",assistantBorder:"1px solid rgba(255,255,255,0.08)",containerBg:"#0f0f13",textColor:"rgba(255,255,255,0.7)"},light:{userBubble:"linear-gradient(135deg, #7c3aed, #0ea5e9)",assistantBubble:"#ffffff",assistantBorder:"1px solid rgba(0,0,0,0.08)",containerBg:"#f6f7f9",textColor:"#52525b"}}},{id:"aurora",name:"Aurora",description:"Vibrant pink-orange with rounded bubbles",preview:{dark:{userBubble:"linear-gradient(135deg, #ec4899, #f97316)",assistantBubble:"#1e1b2e",assistantBorder:"1px solid rgba(236,72,153,0.12)",containerBg:"#0f0d17",textColor:"rgba(255,255,255,0.7)"},light:{userBubble:"linear-gradient(135deg, #ec4899, #f97316)",assistantBubble:"#fef2f8",assistantBorder:"1px solid rgba(236,72,153,0.15)",containerBg:"#f6f7f9",textColor:"#1a1a2e"}}},{id:"honey",name:"Honey",description:"Warm yellow bubbles with clean design",preview:{dark:{userBubble:"#fbbf24",assistantBubble:"#1c1c1e",assistantBorder:"1px solid rgba(255,255,255,0.06)",containerBg:"#111113",textColor:"rgba(255,255,255,0.7)"},light:{userBubble:"#fbbf24",assistantBubble:"#fffbeb",assistantBorder:"1px solid rgba(251,191,36,0.15)",containerBg:"#f6f7f9",textColor:"#1a1a2e"}}}],Q1="adhdev-chat-theme",J1="adhdev-chat-theme-custom";function ga(){return typeof window>"u"?"midnight":localStorage.getItem(Q1)||"midnight"}function Ur(e){try{const t=localStorage.getItem(J1);if(t){const r=JSON.parse(t);return{...e==="dark"?Ad:Bd,...r[e]}}}catch{}return e==="dark"?Ad:Bd}function Vl(e,t){localStorage.setItem(J1,JSON.stringify({dark:e,light:t}))}function Ii(e){const t=document.documentElement;t.style.setProperty("--chat-user-bg",e.userBubble),t.style.setProperty("--chat-user-color",e.userText),t.style.setProperty("--chat-user-radius",`${e.bubbleRadius}px ${e.bubbleRadius}px 4px ${e.bubbleRadius}px`),t.style.setProperty("--chat-assistant-bg",e.assistantBubble),t.style.setProperty("--chat-assistant-color",e.assistantText),t.style.setProperty("--chat-assistant-radius",`${e.bubbleRadius}px ${e.bubbleRadius}px ${e.bubbleRadius}px 4px`),t.style.setProperty("--chat-assistant-border",`1px solid ${e.accentColor}22`),t.style.setProperty("--chat-container-bg",e.containerBg),t.style.setProperty("--chat-thought-accent",e.accentColor),t.style.setProperty("--chat-tool-accent",e.accentColor),t.style.setProperty("--chat-action-color",e.accentColor),t.style.setProperty("--chat-send-bg",e.sendButton),t.style.setProperty("--chat-input-border",e.inputBorder)}function W4(){const e=document.documentElement;["--chat-user-bg","--chat-user-color","--chat-user-radius","--chat-assistant-bg","--chat-assistant-color","--chat-assistant-radius","--chat-assistant-border","--chat-container-bg","--chat-thought-accent","--chat-tool-accent","--chat-action-color","--chat-send-bg","--chat-input-border"].forEach(r=>e.style.removeProperty(r))}function H4(e){if(localStorage.setItem(Q1,e),document.documentElement.setAttribute("data-chat-theme",e),e==="custom"){const t=Co()?"dark":"light";Ii(Ur(t))}else W4()}function U4(){const e=ga();if(e!=="midnight"&&document.documentElement.setAttribute("data-chat-theme",e),e==="custom"){const t=Co()?"dark":"light";Ii(Ur(t))}}function Co(){const e=document.documentElement.getAttribute("data-theme");return e?e==="dark":window.matchMedia("(prefers-color-scheme: dark)").matches}function On({label:e,value:t,onChange:r}){return u.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[u.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-secondary)",minWidth:90},children:e}),u.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[u.jsx("input",{type:"color",value:t,onChange:n=>r(n.target.value),style:{width:28,height:28,border:"none",borderRadius:6,cursor:"pointer",background:"transparent",padding:0}}),u.jsx("input",{type:"text",value:t,onChange:n=>{/^#[0-9a-fA-F]{0,6}$/.test(n.target.value)&&r(n.target.value)},style:{width:72,fontSize:"0.7rem",fontFamily:"monospace",background:"var(--bg-primary)",border:"1px solid var(--border-subtle)",borderRadius:4,padding:"3px 6px",color:"var(--text-primary)"}})]})]})}function K4({dark:e,onColorsChange:t}){const r=e?"dark":"light",[n,i]=x.useState(()=>Ur(r));x.useEffect(()=>{i(Ur(r))},[r]);const s=x.useCallback((o,l)=>{i(a=>{const c={...a,[o]:l},h=Ur(r==="dark"?"light":"dark");return r==="dark"?Vl(c,h):Vl(h,c),Ii(c),t(c),c})},[r,t]);return u.jsxs("div",{style:{marginTop:12,padding:"14px 16px",background:"var(--bg-glass)",border:"1px solid var(--border-subtle)",borderRadius:12},children:[u.jsxs("div",{style:{fontSize:"0.7rem",fontWeight:700,textTransform:"uppercase",color:"var(--text-muted)",letterSpacing:"0.06em",marginBottom:10},children:["Customize (",e?"Dark":"Light"," mode)"]}),u.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[u.jsx(On,{label:"User bubble",value:n.userBubble,onChange:o=>s("userBubble",o)}),u.jsx(On,{label:"User text",value:n.userText,onChange:o=>s("userText",o)}),u.jsx(On,{label:"Agent bubble",value:n.assistantBubble,onChange:o=>s("assistantBubble",o)}),u.jsx(On,{label:"Agent text",value:n.assistantText,onChange:o=>s("assistantText",o)}),u.jsx(On,{label:"Background",value:n.containerBg,onChange:o=>s("containerBg",o)}),u.jsx(On,{label:"Accent",value:n.accentColor,onChange:o=>s("accentColor",o)}),u.jsx(On,{label:"Send button",value:n.sendButton,onChange:o=>s("sendButton",o)}),u.jsx(On,{label:"Input border",value:n.inputBorder,onChange:o=>s("inputBorder",o)}),u.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[u.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-secondary)",minWidth:90},children:"Radius"}),u.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flex:1},children:[u.jsx("input",{type:"range",min:4,max:24,value:n.bubbleRadius,onChange:o=>s("bubbleRadius",Number(o.target.value)),style:{flex:1,accentColor:"var(--accent-primary)"}}),u.jsxs("span",{style:{fontSize:"0.7rem",color:"var(--text-muted)",width:28,textAlign:"right"},children:[n.bubbleRadius,"px"]})]})]})]}),u.jsx("button",{onClick:()=>{const o=e?Ad:Bd,a=Ur(e?"light":"dark");e?Vl(o,a):Vl(a,o),i(o),Ii(o),t(o)},style:{marginTop:10,fontSize:"0.7rem",color:"var(--text-muted)",background:"transparent",border:"1px solid var(--border-subtle)",borderRadius:6,padding:"4px 10px",cursor:"pointer"},children:"Reset to defaults"})]})}function V4(){const[e,t]=x.useState(ga),[r,n]=x.useState(!0),[i,s]=x.useState(()=>Ur("dark"));x.useEffect(()=>{n(Co());const a=new MutationObserver(()=>{const h=Co();n(h),ga()==="custom"&&Ii(Ur(h?"dark":"light"))});a.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]});const c=window.matchMedia("(prefers-color-scheme: dark)"),d=()=>{const h=Co();n(h),ga()==="custom"&&Ii(Ur(h?"dark":"light"))};return c.addEventListener("change",d),()=>{a.disconnect(),c.removeEventListener("change",d)}},[]),x.useEffect(()=>{e!=="midnight"&&document.documentElement.setAttribute("data-chat-theme",e),e==="custom"&&Ii(Ur(r?"dark":"light"))},[]),x.useEffect(()=>{s(Ur(r?"dark":"light"))},[r]);const o=a=>{t(a),H4(a),a==="midnight"&&document.documentElement.removeAttribute("data-chat-theme")},l=[...F4,{id:"custom",name:"Custom",description:"Design your own theme",preview:{dark:{userBubble:i.userBubble,assistantBubble:i.assistantBubble,assistantBorder:`1px solid ${i.accentColor}22`,containerBg:i.containerBg,textColor:i.assistantText},light:{userBubble:i.userBubble,assistantBubble:i.assistantBubble,assistantBorder:`1px solid ${i.accentColor}22`,containerBg:i.containerBg,textColor:i.assistantText}}}];return u.jsxs("div",{children:[u.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-4 gap-3",children:l.map(a=>{const c=e===a.id,d=r?a.preview.dark:a.preview.light,h=a.id==="honey"?"#1a1a1a":a.id==="custom"?i.userText:"#fff";return u.jsxs("button",{onClick:()=>o(a.id),className:"text-left rounded-xl p-3 transition-all",style:{background:c?"var(--bg-glass-hover)":"var(--bg-glass)",border:c?"2px solid var(--accent-primary)":"2px solid var(--border-subtle)",opacity:c?1:.75},children:[u.jsxs("div",{className:"rounded-lg p-3 mb-2.5 flex flex-col gap-1.5",style:{background:d.containerBg},children:[u.jsx("div",{className:"self-start rounded-xl px-3 py-1.5 text-[10px] max-w-[75%]",style:{background:d.assistantBubble,border:d.assistantBorder,color:d.textColor},children:"Hello! How can I help?"}),u.jsx("div",{className:"self-end rounded-xl px-3 py-1.5 text-[10px] max-w-[75%]",style:{background:d.userBubble,color:h},children:"Fix the bug please"}),u.jsx("div",{className:"self-start rounded-xl px-3 py-1.5 text-[10px] max-w-[75%]",style:{background:d.assistantBubble,border:d.assistantBorder,color:d.textColor},children:"On it! ✨"})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[c&&u.jsx("span",{className:"w-2 h-2 rounded-full bg-accent shrink-0"}),u.jsxs("div",{children:[u.jsx("div",{className:"text-sm font-bold text-text-primary",children:a.id==="custom"?"🎨 Custom":a.name}),u.jsx("div",{className:"text-[10px] text-text-muted",children:a.description})]})]})]},a.id)})}),e==="custom"&&u.jsx(K4,{dark:r,onColorsChange:a=>s(a)})]})}const Od="adhdev-accent-color",q4=[{name:"Violet",color:"#8b5cf6"},{name:"Indigo",color:"#6366f1"},{name:"Blue",color:"#3b82f6"},{name:"Cyan",color:"#06b6d4"},{name:"Emerald",color:"#10b981"},{name:"Rose",color:"#f43f5e"},{name:"Orange",color:"#f97316"},{name:"Amber",color:"#f59e0b"}],Jo="#8b5cf6";function Y4(e){const t=parseInt(e.slice(1,3),16)/255,r=parseInt(e.slice(3,5),16)/255,n=parseInt(e.slice(5,7),16)/255,i=Math.max(t,r,n),s=Math.min(t,r,n);let o=0,l=0;const a=(i+s)/2;if(i!==s){const c=i-s;switch(l=a>.5?c/(2-i-s):c/(i+s),i){case t:o=((r-n)/c+(r<n?6:0))/6;break;case r:o=((n-t)/c+2)/6;break;case n:o=((t-r)/c+4)/6;break}}return{h:Math.round(o*360),s:Math.round(l*100),l:Math.round(a*100)}}function W_(e,t){const{h:r,s:n,l:i}=Y4(e),s=Math.min(100,i+t);return`hsl(${r}, ${n}%, ${s}%)`}function _a(e,t){const r=parseInt(e.slice(1,3),16),n=parseInt(e.slice(3,5),16),i=parseInt(e.slice(5,7),16);return`rgba(${r}, ${n}, ${i}, ${t})`}function H_(){return typeof window>"u"?Jo:localStorage.getItem(Od)||Jo}function X4(e){const t=document.documentElement;t.style.setProperty("--accent-primary",e),t.style.setProperty("--accent-primary-light",W_(e,15)),t.style.setProperty("--accent-gradient",`linear-gradient(135deg, ${e}, ${W_(e,20)})`),t.style.setProperty("--border-accent",_a(e,.4)),t.style.setProperty("--nav-active-bg",_a(e,.1)),t.style.setProperty("--nav-active-shadow",`inset 3px 0 0 ${e}, 0 0 12px ${_a(e,.06)}`)}function G4(){const e=document.documentElement;["--accent-primary","--accent-primary-light","--accent-gradient","--border-accent","--nav-active-bg","--nav-active-shadow"].forEach(r=>e.style.removeProperty(r))}function Q4(e){e===Jo?(localStorage.removeItem(Od),G4()):(localStorage.setItem(Od,e),X4(e))}function J4(){const[e,t]=x.useState(H_),[r,n]=x.useState("");x.useEffect(()=>{t(H_())},[]);const i=s=>{t(s),Q4(s)};return u.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[u.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:8},children:q4.map(s=>{const o=e===s.color;return u.jsx("button",{onClick:()=>i(s.color),title:s.name,style:{width:36,height:36,borderRadius:10,background:s.color,border:o?"3px solid var(--text-primary)":"3px solid transparent",cursor:"pointer",position:"relative",transition:"transform 0.15s, border-color 0.15s",transform:o?"scale(1.1)":"scale(1)",boxShadow:o?`0 0 12px ${_a(s.color,.4)}`:"none"},children:o&&u.jsx("span",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",color:"#fff",fontSize:14,fontWeight:700,textShadow:"0 1px 2px rgba(0,0,0,0.5)"},children:"✓"})},s.color)})}),u.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[u.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"Custom:"}),u.jsx("input",{type:"color",value:e,onChange:s=>i(s.target.value),style:{width:28,height:28,border:"none",borderRadius:6,cursor:"pointer",background:"transparent",padding:0}}),u.jsx("input",{type:"text",value:r||e,onChange:s=>{n(s.target.value),/^#[0-9a-fA-F]{6}$/.test(s.target.value)&&i(s.target.value)},onBlur:()=>n(""),style:{width:80,fontSize:"0.7rem",fontFamily:"monospace",background:"var(--bg-primary)",border:"1px solid var(--border-subtle)",borderRadius:4,padding:"3px 6px",color:"var(--text-primary)"}}),e!==Jo&&u.jsx("button",{onClick:()=>i(Jo),style:{fontSize:"0.7rem",color:"var(--text-muted)",background:"transparent",border:"1px solid var(--border-subtle)",borderRadius:5,padding:"3px 8px",cursor:"pointer"},children:"Reset"})]})]})}const Z1="adhdev_hiddenTabs";function Z4(){try{const e=localStorage.getItem(Z1);if(e)return new Set(JSON.parse(e))}catch{}return new Set}function eo(e){try{localStorage.setItem(Z1,JSON.stringify([...e]))}catch{}}function eI(){const[e,t]=x.useState(Z4),r=x.useCallback(a=>{t(c=>{const d=new Set(c);return d.has(a)?d.delete(a):d.add(a),eo(d),d})},[]),n=x.useCallback(a=>{t(c=>{if(c.has(a))return c;const d=new Set(c);return d.add(a),eo(d),d})},[]),i=x.useCallback(a=>{t(c=>{if(!c.has(a))return c;const d=new Set(c);return d.delete(a),eo(d),d})},[]),s=x.useCallback((a,c)=>{t(d=>{const h=new Set(d);for(const f of c)h.add(f);return eo(h),h})},[]),o=x.useCallback((a,c)=>{t(d=>{const h=new Set(d);for(const f of c)h.delete(f);return eo(h),h})},[]),l=x.useCallback(a=>e.has(a),[e]);return{hiddenTabs:e,toggleTab:r,hideTab:n,showTab:i,hideAllForDaemon:s,showAllForDaemon:o,isHidden:l}}function eb({sendDaemonCommand:e,activeConv:t,ides:r,updateIdeChats:n,setToasts:i,setLocalUserMessages:s,setClearedTabs:o,setActionLogs:l,pinTab:a,isStandalone:c}){const[d,h]=x.useState(""),[f,p]=x.useState(!1),[m,_]=x.useState(!1),[b,g]=x.useState(!1),v=x.useCallback(async()=>{if(!t)return;const k=d.trim();if(!k)return;const B=t.ideId,j=t.tabKey;h(""),a(j,[100,500,1500,3e3]);const M=`${Date.now()}-${Math.random().toString(36).slice(2,8)}`,C={role:"user",content:k,timestamp:Date.now(),_localId:M};s(A=>({...A,[j]:[...A[j]||[],C]}));try{if(si(t)&&!ln(t)){const A=B||t.daemonId||"";if(!A)return;const O=t.ideType||t.agentType||"";await e(A,"agent_command",{agentType:O,cliType:O,action:"send_chat",message:k,text:k})}else if(ln(t)){const A=B||t.daemonId||"";if(!A)return;await e(A,"send_chat",{message:k,text:k,agentType:t.agentType})}else{const A=B||t.daemonId||"";if(!A)return;await e(A,"send_chat",{message:k,text:k,...t.streamSource==="agent-stream"&&{agentType:t.agentType}})}setTimeout(()=>{const A=Date.now()-6e4;s(O=>{const U=O[j];if(!U)return O;const L=U.filter($=>$.timestamp>A);return L.length===U.length?O:{...O,[j]:L}})},6e4)}catch(A){console.error("Send failed",A),h(k),s(O=>({...O,[j]:(O[j]||[]).filter(U=>U._localId!==M)}))}},[t,d,e,s,a]),y=x.useCallback(async()=>{if(t)try{c?await e(t.ideId,"launch_ide",{ideType:t.ideType,enableCdp:!0}):await e(t.ideId,"vscode_command_exec",{commandId:"adhdev.relaunchWithCdp",args:[{force:!0}]})}catch(k){console.error("Relaunch failed",k)}},[t,c,e]),S=x.useCallback(async k=>{try{await e("standalone","launch_ide",{ideType:k,enableCdp:!0})}catch(B){console.error("Launch failed",B)}},[e]),R=x.useCallback(async k=>{if(t){console.log("[ModalButton] ideId:",t.ideId,"button:",k),l(B=>[...B,{ideId:t.tabKey,text:`🖱️ **${k}** clicked`,timestamp:Date.now()}]);try{const j=(t.modalButtons||[]).indexOf(k),M=k.replace(/[⌥⏎⇧⌫⌘⌃]/g,"").trim().toLowerCase(),C=/^(run|approve|accept|yes|allow|always|proceed|save)/.test(M),A=t.ideId||t.daemonId||"";(await e(A,"resolve_action",{button:k,action:C?"approve":"reject",...j>=0&&{buttonIndex:j},...t.streamSource==="agent-stream"&&{agentType:t.agentType}})).success||l(U=>[...U,{ideId:t.tabKey,text:`⚠️ **${k}** failed — button not found`,timestamp:Date.now()}])}catch(B){console.error("[ModalButton] Error:",B),l(j=>[...j,{ideId:t.tabKey,text:`❌ **${k}** error`,timestamp:Date.now()}])}}},[t,e,l]),E=x.useCallback(async(k,B)=>{try{const j=k||(t==null?void 0:t.daemonId)||"",M=await e(j,"switch_chat",{id:B,sessionId:B,...(t==null?void 0:t.streamSource)==="agent-stream"&&{agentType:t==null?void 0:t.agentType}}),C=M==null?void 0:M.result;(M==null?void 0:M.success)===!0||C==="switched"||C==="switched-by-title"||(C===!1||C==="not_found"?i(O=>[...O,{id:Date.now(),message:"⚠️ Session tab not found — try refreshing history",type:"warning",timestamp:Date.now()}]):typeof C=="string"&&C.startsWith("error:")?i(O=>[...O,{id:Date.now(),message:`⚠️ Switch error: ${C}`,type:"warning",timestamp:Date.now()}]):i(O=>[...O,{id:Date.now(),message:"⚠️ Session switch failed",type:"warning",timestamp:Date.now()}]))}catch(j){console.error("Switch failed",j),i(M=>[...M,{id:Date.now(),message:`❌ Switch failed: ${j.message||"connection error"}`,type:"warning",timestamp:Date.now()}])}},[t,e,i]),P=x.useCallback(async()=>{if(!(!t||f)){p(!0);try{const k=t.ideId||t.daemonId||"";await e(k,"new_chat",{...t.streamSource==="agent-stream"&&{agentType:t.agentType}}),o(B=>({...B,[t.tabKey]:Date.now()})),s(B=>({...B,[t.tabKey]:[]}))}catch(k){console.error("New chat failed",k)}finally{p(!1)}}},[t,f,e,o,s]),N=x.useCallback(async()=>{if(!t||b)return;g(!0);const k=t.tabKey;try{await e(t.ideId,"agent_stream_focus",{agentType:t.agentType}),a(k,[200,1500,3e3])}catch(B){console.error("Focus agent failed",B)}finally{g(!1)}},[t,b,e,a]),D=x.useCallback(async()=>{var k;if(!(!t||m)){_(!0);try{const B=t.ideId||t.daemonId||"",j=await e(B,"list_chats",{forceExpand:!0,...t.streamSource==="agent-stream"&&{agentType:t.agentType}}),M=(j==null?void 0:j.chats)||((k=j==null?void 0:j.result)==null?void 0:k.chats);j!=null&&j.success&&Array.isArray(M)&&n(t.ideId,M)}catch(B){console.error("Refresh history failed",B)}finally{_(!1)}}},[t,m,e,n]);return{agentInput:d,setAgentInput:h,isCreatingChat:f,isRefreshingHistory:m,isFocusingAgent:b,handleSendChat:v,handleRelaunch:y,handleLaunchIde:S,handleModalButton:R,handleSwitchSession:E,handleNewChat:P,handleFocusAgent:N,handleRefreshHistory:D}}let $u=null;function tI({conversations:e,ides:t,messageReceivedAt:r,actionLogs:n,ptyBuffers:i,screenshotMap:s,setScreenshotMap:o,sendDaemonCommand:l,updateIdeChats:a,setToasts:c,setLocalUserMessages:d,setClearedTabs:h,setActionLogs:f,pinTab:p,isStandalone:m,userName:_,groupIndex:b,isFocused:g,onFocus:v,isSplitMode:y,numGroups:S,onMoveTab:R,onClose:E,onReceiveTab:P,style:N,detectedIdes:D,handleLaunchIde:k,onActiveTabChange:B,initialActiveTabId:j,initialTabOrder:M,onTabOrderChange:C,onHideTab:A}){const{sendCommand:O}=ui(),U=x.useRef(null),[L,$]=x.useState(!1),w=x.useRef(0),ee=x.useRef(null),[ne,T]=x.useState(j??null);x.useEffect(()=>{j&&j!==ne&&T(j)},[j]);const[X,I]=x.useState(M??[]),[F,G]=x.useState(null),he=x.useRef(null),me=x.useRef(null);x.useEffect(()=>{const K=new Set(e.map(ae=>ae.tabKey));I(ae=>{const xe=ae.filter(q=>K.has(q)),Oe=e.filter(q=>!ae.includes(q.tabKey)).map(q=>q.tabKey),Se=[...xe,...Oe];return Se.length===ae.length&&Se.every((q,te)=>q===ae[te])?ae:Se})},[e]);const je=F??X,Pe=x.useMemo(()=>{if(je.length===0)return e;const K=new Map(je.map((ae,xe)=>[ae,xe]));return[...e].sort((ae,xe)=>{const Oe=K.get(ae.tabKey)??999,Se=K.get(xe.tabKey)??999;return Oe-Se})},[e,je]);x.useEffect(()=>{if(Pe.length===0){T(null),B==null||B(null);return}ne&&Pe.some(K=>K.tabKey===ne)||(T(Pe[0].tabKey),B==null||B(Pe[0].tabKey))},[Pe,ne]);const Ce=Pe.find(K=>K.tabKey===ne),de=x.useCallback((K,ae,xe)=>{I(Oe=>{const Se=Oe.filter(Z=>Z!==K),q=Se.indexOf(ae);if(q<0)return Oe;const te=xe==="left"?q:q+1;return Se.splice(te,0,K),C==null||C(Se),Se}),G(null)},[C]),Te=x.useCallback((K,ae,xe)=>{const Se=(X.length>0?X:e.map(Z=>Z.tabKey)).filter(Z=>Z!==K),q=Se.indexOf(ae);if(q<0)return;const te=xe==="left"?q:q+1;Se.splice(te,0,K),he.current=Se,G(Se)},[X,e]),J=eb({sendDaemonCommand:l,activeConv:Ce,ides:t,updateIdeChats:a,setToasts:c,setLocalUserMessages:d,setClearedTabs:h,setActionLogs:f,pinTab:p,isStandalone:m}),[fe,ke]=x.useState(null);x.useEffect(()=>{if(!fe)return;const K=ae=>{const xe=document.querySelector("[data-pane-context-menu]");xe&&xe.contains(ae.target)||ke(null)};return window.addEventListener("mousedown",K,!0),()=>window.removeEventListener("mousedown",K,!0)},[fe]);const Me="adhdev-tab-shortcuts",we=typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.userAgent),[Ke,nr]=x.useState(()=>{try{return JSON.parse(localStorage.getItem(Me)||"{}")}catch{return{}}}),[Qe,ir]=x.useState(null),sr=x.useCallback(K=>{const ae=[];K.metaKey&&ae.push(we?"⌘":"Meta"),K.ctrlKey&&ae.push("Ctrl"),K.altKey&&ae.push(we?"⌥":"Alt"),K.shiftKey&&ae.push(we?"⇧":"Shift");const xe=K.key;if(["Control","Alt","Shift","Meta"].includes(xe))return null;const Oe=xe.length===1?xe.toUpperCase():xe;return ae.push(Oe),ae.join("+")},[we]),$t=x.useCallback((K,ae)=>sr(K)===ae,[sr]),Y=x.useCallback(K=>{nr(K),localStorage.setItem(Me,JSON.stringify(K))},[]);x.useEffect(()=>{if(!Qe)return;const K=ae=>{if(ae.preventDefault(),ae.stopPropagation(),ae.key==="Escape"){ir(null);return}const xe=sr(ae);if(!xe)return;const Oe={...Ke};for(const[Se,q]of Object.entries(Oe))q===xe&&delete Oe[Se];Oe[Qe]=xe,Y(Oe),ir(null)};return window.addEventListener("keydown",K,!0),()=>window.removeEventListener("keydown",K,!0)},[Qe,Ke,Y,sr]),x.useEffect(()=>{const K=ae=>{if(!(!ae.ctrlKey&&!ae.metaKey&&!ae.altKey)){for(const[xe,Oe]of Object.entries(Ke))if($t(ae,Oe)&&Pe.some(Se=>Se.tabKey===xe)){ae.preventDefault(),v(),T(xe),B==null||B(xe);return}}};return window.addEventListener("keydown",K),()=>window.removeEventListener("keydown",K)},[Ke,Pe,v,B,$t]);const se=Ce&&si(Ce)&&!ln(Ce);x.useEffect(()=>{const K=()=>{w.current=0,$(!1)};return window.addEventListener("dragend",K),window.addEventListener("drop",K),()=>{window.removeEventListener("dragend",K),window.removeEventListener("drop",K)}},[]);const ye=x.useRef(null);return x.useEffect(()=>{const K=ye.current;if(!K)return;const ae=xe=>{Math.abs(xe.deltaY)>Math.abs(xe.deltaX)&&(xe.preventDefault(),K.scrollLeft+=xe.deltaY)};return K.addEventListener("wheel",ae,{passive:!1}),()=>K.removeEventListener("wheel",ae)},[]),u.jsxs("div",{className:"flex flex-col min-h-0 min-w-0 flex-1 overflow-hidden",onClick:v,onDragEnter:K=>{if(K.dataTransfer.types.includes("text/tab-key")){w.current++;const ae=$u;ae&&e.some(Oe=>Oe.tabKey===ae)||$(!0)}},onDragOver:K=>{K.dataTransfer.types.includes("text/tab-key")&&K.preventDefault()},onDragLeave:()=>{w.current--,w.current<=0&&(w.current=0,$(!1))},onDrop:K=>{w.current=0,$(!1),G(null);const ae=K.dataTransfer.getData("text/tab-key");if(!ae)return;K.preventDefault(),e.some(Oe=>Oe.tabKey===ae)?I(Oe=>{const Se=Oe.filter(q=>q!==ae);return Se.push(ae),C==null||C(Se),Se}):P&&P(ae)},style:{...N,outline:L?"2px dashed var(--accent-primary)":"none",outlineOffset:"-2px",transition:"outline 0.15s ease"},children:[u.jsx("div",{className:"flex items-center bg-bg-secondary border-b border-border-subtle shrink-0 gap-0",children:u.jsxs("div",{ref:ye,className:"flex-1 flex overflow-x-auto overflow-y-visible pt-1.5 pb-0 gap-1 select-none",style:{paddingLeft:8,paddingRight:4,scrollbarWidth:"none"},children:[Pe.map((K,ae)=>{const xe=ne===K.tabKey,Oe=K.status==="working"?"agent-tab-working":K.status==="waiting_approval"?"agent-tab-waiting":"",Se=K.connectionState==="failed"||K.connectionState==="closed",q=me.current===K.tabKey;return u.jsxs("div",{"data-tabkey":K.tabKey,className:`${Oe} shrink-0 px-2.5 py-1.5 rounded-t-lg cursor-pointer flex items-center gap-2 relative`,draggable:!("ontouchstart"in window),onDragStart:te=>{$u=K.tabKey,me.current=K.tabKey,te.dataTransfer.setData("text/tab-key",K.tabKey),te.dataTransfer.effectAllowed="move"},onDragEnd:()=>{$u=null,me.current=null;const te=he.current;te&&(I(te),C==null||C(te)),he.current=null,G(null),w.current=0,$(!1)},onDragOver:te=>{const Z=me.current;if(!(!Z||Z===K.tabKey)&&te.dataTransfer.types.includes("text/tab-key")){te.preventDefault(),te.stopPropagation();const ve=te.currentTarget.getBoundingClientRect(),Re=ve.left+ve.width/2,Le=te.clientX<Re?"left":"right";Te(Z,K.tabKey,Le)}},onDrop:te=>{te.preventDefault(),te.stopPropagation();const Z=te.dataTransfer.getData("text/tab-key");if(Z&&Z!==K.tabKey){const ve=te.currentTarget.getBoundingClientRect(),Re=ve.left+ve.width/2,Le=te.clientX<Re?"left":"right";Pe.some(pt=>pt.tabKey===Z)?de(Z,K.tabKey,Le):P&&P(Z)}G(null)},onClick:te=>{te.stopPropagation(),v(),T(K.tabKey),B==null||B(K.tabKey),K.streamSource==="agent-stream"&&K.agentType&&O(K.ideId,"agent_stream_focus",{agentType:K.agentType}).catch(()=>{}),si(K)&&setTimeout(()=>{var Z,ve;return(ve=(Z=U.current)==null?void 0:Z.bumpResize)==null?void 0:ve.call(Z)},100)},onContextMenu:te=>{te.preventDefault(),ke({x:te.clientX,y:te.clientY,tabKey:K.tabKey})},onTouchStart:te=>{const Z=te.touches[0],ve=Z.clientX,Re=Z.clientY;ee.current=setTimeout(()=>{ke({x:ve,y:Re,tabKey:K.tabKey})},600)},onTouchEnd:()=>{ee.current&&clearTimeout(ee.current)},onTouchMove:()=>{ee.current&&clearTimeout(ee.current)},style:{background:xe?"var(--bg-primary)":"var(--bg-glass)",borderTop:xe?"1px solid var(--border-subtle)":"1px solid transparent",borderLeft:xe?"1px solid var(--border-subtle)":"1px solid transparent",borderRight:xe?"1px solid var(--border-subtle)":"1px solid transparent",opacity:q?.4:Se?xe?.6:.3:xe?1:.65,transition:"transform 0.2s ease, opacity 0.15s ease"},children:[K.status==="working"?u.jsx("div",{className:"tab-spinner"}):K.status==="waiting_approval"?u.jsx("span",{className:"text-[8px] px-[5px] py-px text-yellow-400",children:"▲"}):Se?u.jsx("span",{className:"text-[8px] px-[5px] py-px text-yellow-400 animate-pulse",children:"○"}):K.connectionState==="connecting"||K.connectionState==="new"?u.jsx("div",{className:"tab-connecting-spinner"}):K.connectionState==="connected"?u.jsx("span",{className:"text-[8px] px-[5px] py-px text-green-400",children:"●"}):u.jsx("span",{className:"text-[8px] px-[5px] py-px text-text-muted animate-pulse",children:"○"}),u.jsxs("div",{className:"min-w-0",children:[u.jsx("div",{className:"text-xs font-bold whitespace-nowrap overflow-hidden text-ellipsis",children:K.displayPrimary}),u.jsx("div",{className:"text-[8px] opacity-50 flex gap-1 items-center",children:Se?u.jsx("span",{className:"text-yellow-400 opacity-100",children:"Reconnecting…"}):K.connectionState==="connecting"||K.connectionState==="new"?u.jsxs("span",{className:"text-blue-400 opacity-100",children:["Connecting",u.jsx("span",{className:"connecting-dots"})]}):u.jsxs(u.Fragment,{children:[K.displaySecondary,K.machineName&&u.jsxs(u.Fragment,{children:[u.jsx("span",{className:"opacity-40",children:"·"}),u.jsxs("span",{className:"opacity-70",children:["🖥 ",K.machineName]})]})]})})]}),Ke[K.tabKey]&&u.jsx("span",{className:"text-[9px] opacity-50 font-mono ml-0.5 shrink-0 bg-bg-secondary px-1 rounded",title:`Ctrl+${Ke[K.tabKey]}`,children:Ke[K.tabKey]})]},K.tabKey)}),e.length===0&&u.jsx("div",{className:"p-2 text-xs opacity-40",children:"No tabs in this group"})]})}),u.jsx("div",{className:"flex-1 min-h-0 flex flex-col overflow-hidden relative",children:Ce?u.jsxs(u.Fragment,{children:[u.jsx(M1,{activeConv:Ce,onModalButton:J.handleModalButton}),u.jsx("div",{className:"desktop-only px-3 pt-1 pb-2",children:!se&&!ln(Ce)&&s[Ce.ideId]?u.jsx(uL,{screenshotUrl:s[Ce.ideId],mode:"preview",onDismiss:()=>{const K={...s};delete K[Ce.ideId],o(K)}}):!se&&!ln(Ce)&&Ce.cdpConnected===!1?u.jsxs("div",{className:"flex items-center gap-2.5 px-3.5 py-2 bg-yellow-500/[0.08] border border-yellow-500/20 rounded-lg text-xs text-text-secondary",children:[u.jsx("span",{className:"text-sm",children:u.jsx(A0,{size:14})}),u.jsx("span",{className:"flex-1",children:"CDP not connected — chat history & screenshots unavailable."}),u.jsx("button",{className:"btn btn-sm bg-yellow-500/15 text-yellow-500 border border-yellow-500/30 text-[10px] whitespace-nowrap shrink-0",onClick:J.handleRelaunch,children:"Relaunch with CDP"})]}):null}),se?u.jsx(dL,{activeConv:Ce,ptyBuffers:i,terminalRef:U,agentInput:J.agentInput,setAgentInput:J.setAgentInput,handleSendChat:J.handleSendChat,handleModalButton:J.handleModalButton}):u.jsx(L1,{activeConv:Ce,ides:t,agentInput:J.agentInput,setAgentInput:J.setAgentInput,handleSendChat:J.handleSendChat,handleFocusAgent:J.handleFocusAgent,isFocusingAgent:J.isFocusingAgent,messageReceivedAt:r,actionLogs:n,userName:_})]}):u.jsx("div",{className:"flex-1 flex flex-col items-center justify-center",children:e.length===0&&!y&&D&&k?u.jsxs("div",{className:"empty-dashboard",children:[u.jsx("div",{className:"glow-orb",children:u.jsx("img",{src:"/otter-logo.png",alt:"",className:"w-12 h-12"})}),u.jsxs("div",{className:"text-center",children:[u.jsx("div",{className:"font-bold text-lg mb-1.5",children:"Waiting for your IDE"}),u.jsx("div",{className:"text-[13px] text-text-muted",style:{marginBottom:12},children:m?"Launch an IDE with CDP to start monitoring":"Install the daemon, then open your IDE — it connects automatically."}),!m&&u.jsxs("div",{style:{background:"var(--bg-secondary, #111)",borderRadius:"0.5rem",padding:"0.5rem 0.75rem",display:"inline-block",fontFamily:"monospace",fontSize:"0.75rem",color:"var(--accent, #a78bfa)",marginBottom:12,textAlign:"left",border:"1px solid var(--border-subtle, #333)"},children:[u.jsx("span",{style:{color:"var(--text-muted)"},children:"$ "}),"npm i -g adhdev && adhdev setup && adhdev daemon"]}),m&&D.length>0&&u.jsx("div",{className:"flex flex-wrap gap-2 justify-center",children:D.map(K=>u.jsx("button",{className:"btn btn-sm bg-violet-500/10 border border-violet-500/25 text-violet-400 text-xs font-semibold px-4 py-2 rounded-lg cursor-pointer flex items-center gap-1.5 transition-colors hover:bg-violet-500/20",onClick:()=>k(K.type),children:u.jsxs("span",{className:"flex items-center gap-1.5",children:[u.jsx($P,{size:14})," Launch ",K.name]})},K.type))}),u.jsx("div",{style:{marginTop:8},children:u.jsx("a",{href:"https://docs.adhf.dev/guide/getting-started",target:"_blank",rel:"noopener noreferrer",style:{fontSize:"0.75rem",color:"var(--accent, #a78bfa)",textDecoration:"none"},children:"📚 Setup guide →"})})]})]}):u.jsx("div",{className:"text-sm text-text-muted opacity-50",children:y?"Move a tab here to view":"No active agent"})})}),fe&&u.jsxs("div",{"data-pane-context-menu":!0,className:"fixed z-50 bg-bg-primary border border-border-subtle rounded-lg shadow-lg py-1 min-w-[160px]",style:{left:fe.x,top:fe.y},children:[R&&b>0&&u.jsx("button",{className:"w-full text-left px-3 py-1.5 text-xs hover:bg-bg-secondary transition-colors hidden md:block",onClick:()=>{R(fe.tabKey,"left"),ke(null)},children:"← Move to Left Group"}),R&&b<S-1&&u.jsx("button",{className:"w-full text-left px-3 py-1.5 text-xs hover:bg-bg-secondary transition-colors hidden md:block",onClick:()=>{R(fe.tabKey,"right"),ke(null)},children:"Move to Right Group →"}),R&&S<4&&u.jsx("button",{className:"w-full text-left px-3 py-1.5 text-xs hover:bg-bg-secondary transition-colors hidden md:block",onClick:()=>{R(fe.tabKey,"new"),ke(null)},children:"Split to New Group ◨"}),u.jsx("div",{className:"border-t border-border-subtle my-1 hidden md:block"}),u.jsxs("button",{className:"w-full text-left px-3 py-1.5 text-xs hover:bg-bg-secondary transition-colors hidden md:block",onClick:K=>{K.stopPropagation(),ir(fe.tabKey),ke(null)},children:["⌨ ",Ke[fe.tabKey]?`Change shortcut (${Ke[fe.tabKey]})`:"Set shortcut"]}),Ke[fe.tabKey]&&u.jsx("button",{className:"w-full text-left px-3 py-1.5 text-xs hover:bg-bg-secondary transition-colors text-text-muted hidden md:block",onClick:()=>{const K={...Ke};delete K[fe.tabKey],Y(K),ke(null)},children:"✕ Remove shortcut"}),A&&u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"border-t border-border-subtle my-1"}),u.jsx("button",{className:"w-full text-left px-3 py-1.5 text-xs hover:bg-bg-secondary transition-colors text-text-muted",onClick:()=>{A(fe.tabKey),ke(null)},children:"🚫 Hide from Dashboard"})]}),!R&&!A&&u.jsx("div",{className:"px-3 py-1.5 text-[11px] text-text-muted opacity-50 italic",children:"No actions available"})]}),Qe&&u.jsx("div",{className:"fixed inset-0 z-[60] flex items-center justify-center",style:{background:"rgba(0,0,0,0.5)",backdropFilter:"blur(2px)"},onClick:()=>ir(null),children:u.jsxs("div",{className:"bg-bg-primary border border-border-subtle rounded-xl px-8 py-6 text-center shadow-xl",onClick:K=>K.stopPropagation(),children:[u.jsx("div",{className:"text-sm font-bold text-text-primary mb-2",children:"⌨ Set shortcut"}),u.jsxs("div",{className:"text-xs text-text-secondary mb-4",children:["Press a key combo (e.g. ",we?"⌘+1":"Ctrl+1",", ",we?"⌥+A":"Alt+A",")"]}),u.jsx("div",{className:"text-lg font-mono text-accent-primary animate-pulse",children:"Listening..."}),u.jsx("div",{className:"text-[10px] text-text-muted mt-3",children:"Press Esc to cancel"})]})})]})}const Fu=[{icon:"🦦",title:"Welcome to ADHDev",desc:"Monitor and control your AI coding agents from anywhere — web, mobile, or CLI.",visual:"🎉"},{icon:"💬",title:"Real-time chat",desc:"See what your AI agent is doing in real-time. Send messages, approve or reject actions — all from your browser or phone.",visual:"📱"},{icon:"🖥️",title:"Remote desktop",desc:"View and control your IDE screen via P2P connection. Click, type, scroll — just like being there.",visual:"🖱️"},{icon:"🚀",title:"Get started",desc:"Install the daemon and open your IDE — it connects automatically.",code:"curl -fsSL https://adhf.dev/install | sh"}];function rI({onClose:e}){const[t,r]=x.useState(0),n=Fu[t],i=t===Fu.length-1;return u.jsxs("div",{className:"onboarding-overlay",style:{position:"fixed",inset:0,zIndex:9999,background:"rgba(0,0,0,0.65)",backdropFilter:"blur(6px)",display:"flex",alignItems:"center",justifyContent:"center",animation:"fadeIn 0.3s ease-out"},onClick:s=>{s.target===s.currentTarget&&e()},children:[u.jsxs("div",{style:{background:"var(--bg-secondary, #1a1a2e)",border:"1px solid var(--border-subtle, #333)",borderRadius:"1.25rem",width:"min(440px, 92vw)",padding:"2.5rem 2rem 2rem",position:"relative",animation:"slideUp 0.3s ease-out"},children:[u.jsx("button",{onClick:e,style:{position:"absolute",top:12,right:16,background:"transparent",border:"none",color:"var(--text-muted)",fontSize:"1.2rem",cursor:"pointer"},children:"✕"}),u.jsx("div",{style:{display:"flex",justifyContent:"center",gap:6,marginBottom:"1.5rem"},children:Fu.map((s,o)=>u.jsx("div",{style:{width:o===t?24:8,height:8,borderRadius:4,background:o===t?"var(--accent, #7c3aed)":"var(--border-subtle, #444)",transition:"all 0.3s ease"}},o))}),u.jsx("div",{style:{textAlign:"center",fontSize:"3rem",marginBottom:"1rem"},children:n.visual||n.icon}),u.jsxs("div",{style:{textAlign:"center"},children:[u.jsxs("h2",{style:{fontSize:"1.35rem",fontWeight:700,color:"var(--text-primary)",marginBottom:"0.75rem",display:"flex",alignItems:"center",justifyContent:"center",gap:8},children:[u.jsx("span",{children:n.icon})," ",n.title]}),u.jsx("p",{style:{fontSize:"0.9rem",color:"var(--text-secondary)",lineHeight:1.6,marginBottom:"1.25rem"},children:n.desc}),n.code&&u.jsxs("div",{style:{background:"var(--bg-primary, #111)",border:"1px solid var(--border-subtle, #333)",borderRadius:"0.5rem",padding:"0.75rem 1rem",fontFamily:"monospace",fontSize:"0.8rem",color:"var(--accent, #a78bfa)",textAlign:"left",overflowX:"auto",marginBottom:"0.5rem"},children:[u.jsx("span",{style:{color:"var(--text-muted)",marginRight:8},children:"$"}),n.code]}),i&&u.jsx("a",{href:"https://docs.adhf.dev",target:"_blank",rel:"noopener noreferrer",style:{fontSize:"0.75rem",color:"var(--accent, #a78bfa)",textDecoration:"none"},children:"📚 Learn more in the docs →"})]}),u.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginTop:"1.5rem"},children:[u.jsx("button",{onClick:e,style:{background:"transparent",border:"none",color:"var(--text-muted)",fontSize:"0.85rem",cursor:"pointer"},children:"Skip"}),u.jsx("button",{onClick:()=>i?e():r(s=>s+1),className:"transition-opacity hover:opacity-90",style:{background:"linear-gradient(135deg, #7c3aed, #6366f1)",color:"#fff",border:"none",borderRadius:"0.5rem",padding:"0.55rem 1.5rem",fontSize:"0.9rem",fontWeight:600,cursor:"pointer"},children:i?"Get Started →":"Next →"})]})]}),u.jsx("style",{children:`
|
|
185
185
|
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
|
|
186
186
|
@keyframes slideUp { from { opacity: 0; transform: translateY(20px) } to { opacity: 1; transform: translateY(0) } }
|
|
187
|
-
`})]})}function nI(){const{sendCommand:e}=ui(),[t,r]=Cy(),n=t.get("activeTab"),i=Lc(),{updateIdeChats:s,screenshotMap:o,setScreenshotMap:l}=i,a=i.ides||[],[c,d]=x.useState(()=>{try{return!localStorage.getItem("adhdev_onboarding_v1")}catch{return!1}}),h=i.toasts||[],f=i.setToasts||(()=>{}),p=i.wsStatus||"connected",m=i.isConnected??!0,_=i.connectionStates||{};i.retryConnection;const b=i.showReconnected||!1,[g,v]=x.useState(()=>{try{const z=localStorage.getItem("adhdev_splitGroups");if(z){const W=JSON.parse(z);return new Map(W)}}catch{}return new Map}),[y,S]=x.useState(()=>{try{const z=localStorage.getItem("adhdev_focusedGroup");if(z)return parseInt(z,10)||0}catch{}return 0}),[R,E]=x.useState(()=>{try{const z=localStorage.getItem("adhdev_groupActiveTabs");if(z)return JSON.parse(z)}catch{}return{}}),P=x.useRef(!1),[N,D]=x.useState(()=>{try{const z=localStorage.getItem("adhdev_groupTabOrders");if(z)return JSON.parse(z)}catch{}return{}}),[k,B]=x.useState(()=>{try{const z=localStorage.getItem("adhdev_splitSizes");if(z)return JSON.parse(z)}catch{}return[]});x.useEffect(()=>{try{g.size===0?localStorage.removeItem("adhdev_splitGroups"):localStorage.setItem("adhdev_splitGroups",JSON.stringify([...g.entries()]))}catch{}},[g]),x.useEffect(()=>{try{k.length>0?localStorage.setItem("adhdev_splitSizes",JSON.stringify(k)):localStorage.removeItem("adhdev_splitSizes")}catch{}},[k]),x.useEffect(()=>{try{localStorage.setItem("adhdev_focusedGroup",String(y))}catch{}},[y]),x.useEffect(()=>{try{localStorage.setItem("adhdev_groupActiveTabs",JSON.stringify(R))}catch{}},[R]),x.useEffect(()=>{try{localStorage.setItem("adhdev_groupTabOrders",JSON.stringify(N))}catch{}},[N]);const[j,M]=x.useState(()=>typeof window<"u"&&window.innerWidth<768);x.useEffect(()=>{const z=window.matchMedia("(max-width: 767px)"),W=H=>M(H.matches);return z.addEventListener("change",W),()=>z.removeEventListener("change",W)},[]);const C=x.useMemo(()=>j||g.size===0?1:Math.max(1,...g.values())+1,[g,j]),A=C>1,O=x.useCallback((z,W)=>{v(H=>{const V=new Map(H);return W===0?V.delete(z):V.set(z,W),V}),S(W)},[]),U=x.useCallback(z=>{v(W=>{const V=(W.size===0?0:Math.max(0,...W.values()))+1;if(V>=4)return W;const ce=new Map(W);return ce.set(z,V),ce}),S(W=>W+1)},[]),L=x.useCallback(z=>{v(W=>{const H=new Map;for(const[V,ce]of W)ce!==z&&(ce>z?H.set(V,ce-1):H.set(V,ce));return H}),B(W=>{if(W.length<=1)return[];const H=[...W];H.splice(z,1);const V=H.reduce((ce,le)=>ce+le,0);return H.map(ce=>ce/V*100)}),S(0)},[]),$=x.useRef(null),w=x.useCallback((z,W)=>{W.preventDefault();const H=$.current;if(!H)return;const V=W.clientX,ce=H.offsetWidth,le=k.length===C?[...k]:Array(C).fill(100/C),Ee=He=>{const Cr=(He.clientX-V)/ce*100,Nt=[...le];Nt[z]=Math.max(15,le[z]+Cr),Nt[z+1]=Math.max(15,le[z+1]-Cr),B(Nt)},Ue=()=>{document.removeEventListener("mousemove",Ee),document.removeEventListener("mouseup",Ue),document.body.style.cursor="",document.body.style.userSelect=""};document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",Ee),document.addEventListener("mouseup",Ue)},[k,C]),[ee,ne]=x.useState({}),[T,X]=x.useState(!1),[I,F]=x.useState([]),[G,he]=x.useState({}),[me,je]=x.useState({}),[Pe,Ce]=x.useState(!1),[de,Te]=x.useState(!1);x.useEffect(()=>{const z=H=>{var V;(V=H.dataTransfer)!=null&&V.types.includes("text/tab-key")&&Te(!0)},W=()=>{Te(!1),Ce(!1)};return window.addEventListener("dragstart",z),window.addEventListener("dragend",W),window.addEventListener("drop",W),()=>{window.removeEventListener("dragstart",z),window.removeEventListener("dragend",W),window.removeEventListener("drop",W)}},[]);const J=a.find(z=>z.type==="adhdev-daemon"),fe=(J==null?void 0:J.detectedIdes)||[],ke=!!J,Me=x.useMemo(()=>{const z=a.filter(H=>H.type!=="adhdev-daemon"),W=new Map;for(const H of z){const V=W.get(H.id);if(!V)W.set(H.id,H);else{const ce=(V.workspace?1:0)+(V.activeChat?1:0);((H.workspace?1:0)+(H.activeChat?1:0)>ce||(H.timestamp||0)>(V.timestamp||0))&&W.set(H.id,H)}}return Array.from(W.values())},[a]),we=x.useMemo(()=>{const z=CL(Me,G,a,_),W=Date.now();return z.map(H=>{const V=me[H.tabKey];return V&&W-V<5e3?{...H,messages:[],title:""}:H})},[Me,G,me,a]),{hiddenTabs:Ke,toggleTab:nr}=eI(),Qe=x.useMemo(()=>we.filter(z=>!Ke.has(z.tabKey)),[we,Ke]);x.useEffect(()=>{IL()},[]);const ir=x.useMemo(()=>Qe.map(z=>({id:z.tabKey,name:z.title||z.agentName||z.ideId,status:z.status,activeModal:z.modalMessage?{message:z.modalMessage,buttons:z.modalButtons}:null})),[Qe]);DL(ir);const sr=x.useMemo(()=>{const z=Array.from({length:C},()=>[]);for(const W of Qe){const H=g.get(W.tabKey)??0,V=Math.min(H,C-1);z[V].push(W)}return z},[Qe,g,C]);x.useEffect(()=>{const z=new Set(Qe.map(W=>W.tabKey));v(W=>{let H=!1;const V=new Map;for(const[ce,le]of W)z.has(ce)?V.set(ce,le):H=!0;return H?V:W})},[we]),x.useEffect(()=>{if(A)for(let z=C-1;z>=1;z--)[...g.values()].some(H=>H===z)||L(z)},[g,C,A,L]),x.useEffect(()=>{if(!n||P.current||we.length===0)return;const z=we.find(W=>W.tabKey===n)||we.find(W=>W.ideId===n)||we.find(W=>W.ideType===n||W.agentType===n);if(z){const W=g.get(z.tabKey)??0;E(H=>({...H,[W]:z.tabKey})),S(W),P.current=!0,r(H=>{const V=new URLSearchParams(H);return V.delete("activeTab"),V},{replace:!0})}},[n,we,g]),x.useEffect(()=>{if(Object.keys(me).length===0)return;const W=setTimeout(()=>{je(H=>{const V=Date.now(),ce={};for(const[le,Ee]of Object.entries(H))V-Ee<5e3&&(ce[le]=Ee);return Object.keys(ce).length===Object.keys(H).length?H:ce})},5500);return()=>clearTimeout(W)},[me]);const $t=x.useMemo(()=>{var W,H;const z=R[y];if(z){const V=we.find(ce=>ce.tabKey===z);if(V)return V}return((W=sr[y])==null?void 0:W[0])||((H=sr[0])==null?void 0:H[0])},[R,y,we,sr]),Y=x.useCallback((z,W)=>{},[]);x.useEffect(()=>{var V;const z=Date.now();let W=!1;const H={...ee};for(const ce of we)(V=ce.messages)!=null&&V.length&&ce.messages.forEach((le,Ee)=>{const Ue=`${ce.ideId}-${le.id??`i-${Ee}`}`;H[Ue]==null&&(H[Ue]=z,W=!0)});W&&ne(H)},[we]);const se=x.useRef(!1);x.useEffect(()=>{if(!T){se.current=!1;return}if(!$t||se.current||oe)return;const z=a.find(W=>W.id===$t.ideId);z&&(!z.chats||z.chats.length===0)&&(se.current=!0,q())},[T,$t==null?void 0:$t.ideId]),x.useEffect(()=>{const z=setInterval(()=>{const W=Date.now()-3e5;F(H=>{const V=H.filter(ce=>ce.timestamp>W).slice(-100);return V.length===H.length?H:V})},6e4);return()=>clearInterval(z)},[]);const ye=x.useRef(new Map);x.useEffect(()=>{const z=(H,V)=>{var ce;if(V){I1.emit(H,V);for(const le of we){if(!si(le))continue;const Ee=(ce=le.ideId)!=null&&ce.includes(":cli:")?le.ideId.split(":cli:")[1]:"";if(H===Ee||H===le.agentType||H===le.ideType){const He=ye.current.get(le.tabKey)||[];He.push(V),He.length>1e4&&He.splice(0,He.length-5e3),ye.current.set(le.tabKey,He)}}}},W=T_.onPtyOutput(z);return()=>{W()}},[we]),x.useEffect(()=>{const z=W=>{if(W.ctrlKey&&W.key==="\\"){if(W.preventDefault(),A)v(new Map),S(0);else{const H=we[1];H&&U(H.tabKey)}return}W.ctrlKey&&(W.key==="["||W.key==="]")&&A&&(W.preventDefault(),S(H=>W.key==="]"?Math.min(H+1,C-1):Math.max(H-1,0)))};return window.addEventListener("keydown",z),()=>window.removeEventListener("keydown",z)},[A,we,U,C]),x.useEffect(()=>{gi.setIdes(a)},[a]),x.useEffect(()=>{gi.setResolveAction((z,W,H)=>{e(z,W,H).catch(()=>{})})},[e]),x.useEffect(()=>{const z=gi.onToast(V=>{f(le=>[...le.slice(-4),{id:V.id,message:V.message,type:V.type,timestamp:V.timestamp,ideId:V.ideId,actions:V.actions}]);const ce=V.duration||5e3;setTimeout(()=>f(le=>le.filter(Ee=>Ee.id!==V.id)),ce)}),W=gi.onSystemMessage((V,ce)=>{he(le=>{for(const Ee of Object.keys(le))if(Ee.includes(V))return{...le,[Ee]:[...le[Ee]||[],ce]};return le})}),H=gi.onClearSystemMessage((V,ce)=>{he(le=>{const Ee={...le};for(const Ue of Object.keys(Ee))Ue.includes(V)&&(Ee[Ue]=(Ee[Ue]||[]).filter(He=>{var Et;return!(He.role==="system"&&((Et=He._localId)!=null&&Et.startsWith(ce)))}));return Ee})});return()=>{z(),W(),H()}},[]),x.useEffect(()=>{const z=gL.on("status_event",H=>gi.handleRawEvent(H,"ws")),W=T_.onStatusEvent((H,V)=>gi.handleRawEvent(V,"p2p"));return()=>{z(),W()}},[]),x.useEffect(()=>{var W;const z=H=>{const V=H.data;(V==null?void 0:V.type)==="notification_action"&&V.action==="approve"&&V.ideId&&e(V.ideId,"resolve_action",{action:"approve",button:"Approve"}).catch(ce=>console.error("[SW Action] approve failed:",ce))};return(W=navigator.serviceWorker)==null||W.addEventListener("message",z),()=>{var H;return(H=navigator.serviceWorker)==null?void 0:H.removeEventListener("message",z)}},[]);const{isCreatingChat:K,isRefreshingHistory:oe,handleLaunchIde:xe,handleSwitchSession:Oe,handleNewChat:Se,handleRefreshHistory:q}=eb({sendDaemonCommand:e,activeConv:$t,ides:a,updateIdeChats:s,setToasts:f,setLocalUserMessages:he,setClearedTabs:je,setActionLogs:F,pinTab:Y,isStandalone:ke}),te=x.useMemo(()=>a.filter(z=>z.type==="adhdev-daemon"&&z.versionMismatch),[a]),[Z,ve]=x.useState(!1),[Re,Le]=x.useState({}),pt=x.useCallback(async z=>{var W,H;Le(V=>({...V,[z]:"upgrading"}));try{const V=await e(z,"daemon_upgrade",{});(W=V==null?void 0:V.result)!=null&&W.upgraded||(H=V==null?void 0:V.result)!=null&&H.success?Le(ce=>({...ce,[z]:"done"})):Le(ce=>({...ce,[z]:"error"}))}catch{Le(V=>({...V,[z]:"error"}))}},[e]);return u.jsxs("div",{className:"page-dashboard flex-1 min-h-0 bg-bg-primary text-text-primary flex flex-col overflow-hidden",children:[u.jsx(fL,{wsStatus:p,showReconnected:b}),te.length>0&&!Z&&u.jsxs("div",{className:"flex items-center gap-2.5 px-4 py-2 bg-amber-500/[0.08] border-b border-amber-500/20 text-xs text-text-secondary shrink-0 flex-wrap",children:[u.jsx("span",{className:"text-sm shrink-0",children:"🔄"}),u.jsxs("span",{className:"flex-1 flex items-center gap-2 flex-wrap min-w-0",children:[u.jsxs("span",{children:["Update available: ",u.jsxs("strong",{children:["v",te[0].version]})," → ",u.jsxs("strong",{children:["v",te[0].serverVersion]})]}),te.map(z=>{var V;const W=z.machineNickname||((V=z.machine)==null?void 0:V.hostname)||z.hostname||"Machine",H=Re[z.id];return u.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2 py-0.5 rounded-md bg-amber-500/[0.08] border border-amber-500/15",children:[u.jsx("span",{className:"font-medium text-text-primary",children:W}),u.jsxs("span",{className:"text-[10px] text-text-muted",children:["v",z.version]}),H==="upgrading"?u.jsx("span",{className:"text-[10px] text-amber-400 animate-pulse",children:"upgrading…"}):H==="done"?u.jsx("span",{className:"text-[10px] text-green-400",children:"✓ restarting"}):H==="error"?u.jsx("button",{className:"text-[10px] text-red-400 hover:text-red-300 underline cursor-pointer",onClick:()=>pt(z.id),children:"retry"}):u.jsx("button",{className:"text-[10px] font-semibold text-amber-400 hover:text-amber-300 cursor-pointer px-1.5 py-px rounded bg-amber-500/10 border border-amber-500/20 transition-colors",onClick:()=>pt(z.id),children:"Upgrade"})]},z.id)})]}),u.jsx("button",{className:"text-text-muted hover:text-text-primary transition-colors text-sm px-1 shrink-0",onClick:()=>ve(!0),title:"Dismiss",children:"✕"})]}),u.jsx(vL,{activeConv:$t,agentCount:Me.length,wsStatus:p,isConnected:m,onOpenHistory:()=>X(!0)}),u.jsxs("div",{ref:$,className:`flex-1 min-h-0 flex ${A?"flex-row":"flex-col"} overflow-hidden`,children:[sr.map((z,W)=>{const H=A&&k.length===C?`${k[W]}%`:void 0;return u.jsxs(lv.Fragment,{children:[A&&W>0&&u.jsx("div",{className:"shrink-0 w-1 cursor-col-resize hover:bg-accent-primary/30 transition-colors relative group",style:{background:"var(--border-subtle)"},onMouseDown:V=>w(W-1,V),onDoubleClick:()=>L(W),title:"Drag to resize · Double-click to merge",children:u.jsx("div",{className:"absolute inset-y-0 -left-1 -right-1 group-hover:bg-accent-primary/10"})}),u.jsx(tI,{style:A?{flexBasis:H??`${100/C}%`,flexGrow:H?0:1,flexShrink:H?0:1}:void 0,conversations:z,ides:a,messageReceivedAt:ee,actionLogs:I,ptyBuffers:ye,screenshotMap:o,setScreenshotMap:l,sendDaemonCommand:e,updateIdeChats:s,setToasts:f,setLocalUserMessages:he,setClearedTabs:je,setActionLogs:F,pinTab:Y,isStandalone:ke,userName:i.userName,groupIndex:W,isFocused:y===W,onFocus:()=>S(W),isSplitMode:A,numGroups:C,onMoveTab:(V,ce)=>{ce==="left"&&W>0?O(V,W-1):ce==="right"&&W<C-1?O(V,W+1):ce==="new"&&C<4&&U(V)},onClose:A?()=>L(W):void 0,onReceiveTab:V=>O(V,W),detectedIdes:W===0?fe:void 0,handleLaunchIde:W===0?xe:void 0,onActiveTabChange:V=>E(ce=>({...ce,[W]:V})),initialActiveTabId:R[W],initialTabOrder:N[W],onTabOrderChange:V=>D(ce=>({...ce,[W]:V})),onHideTab:nr})]},W)}),!j&&C<4&&u.jsxs("div",{className:"relative shrink-0 w-0 z-50",children:[u.jsx("div",{className:"fixed right-0 top-0 bottom-0 w-16",style:{pointerEvents:de?"auto":"none"},onDragOver:z=>{z.dataTransfer.types.includes("text/tab-key")&&(z.preventDefault(),Ce(!0))},onDragLeave:()=>Ce(!1),onDrop:z=>{z.preventDefault(),Ce(!1);const W=z.dataTransfer.getData("text/tab-key");W&&U(W)}}),u.jsx("div",{className:"absolute right-0 top-0 bottom-0 pointer-events-none transition-all duration-200",style:{width:Pe?"120px":"0px",background:"var(--accent-primary)",opacity:Pe?.15:0,borderLeft:Pe?"2px dashed var(--accent-primary)":"none"}})]})]}),T&&$t&&u.jsx(bL,{activeConv:$t,ides:a,isCreatingChat:K,isRefreshingHistory:oe,onClose:()=>X(!1),onNewChat:Se,onSwitchSession:Oe,onRefreshHistory:q}),u.jsx("style",{children:`
|
|
187
|
+
`})]})}function nI(){const{sendCommand:e}=ui(),[t,r]=Cy(),n=t.get("activeTab"),i=Lc(),{updateIdeChats:s,screenshotMap:o,setScreenshotMap:l}=i,a=i.ides||[],[c,d]=x.useState(()=>{try{return!localStorage.getItem("adhdev_onboarding_v1")}catch{return!1}}),h=i.toasts||[],f=i.setToasts||(()=>{}),p=i.wsStatus||"connected",m=i.isConnected??!0,_=i.connectionStates||{};i.retryConnection;const b=i.showReconnected||!1,[g,v]=x.useState(()=>{try{const z=localStorage.getItem("adhdev_splitGroups");if(z){const W=JSON.parse(z);return new Map(W)}}catch{}return new Map}),[y,S]=x.useState(()=>{try{const z=localStorage.getItem("adhdev_focusedGroup");if(z)return parseInt(z,10)||0}catch{}return 0}),[R,E]=x.useState(()=>{try{const z=localStorage.getItem("adhdev_groupActiveTabs");if(z)return JSON.parse(z)}catch{}return{}}),P=x.useRef(!1),[N,D]=x.useState(()=>{try{const z=localStorage.getItem("adhdev_groupTabOrders");if(z)return JSON.parse(z)}catch{}return{}}),[k,B]=x.useState(()=>{try{const z=localStorage.getItem("adhdev_splitSizes");if(z)return JSON.parse(z)}catch{}return[]});x.useEffect(()=>{try{g.size===0?localStorage.removeItem("adhdev_splitGroups"):localStorage.setItem("adhdev_splitGroups",JSON.stringify([...g.entries()]))}catch{}},[g]),x.useEffect(()=>{try{k.length>0?localStorage.setItem("adhdev_splitSizes",JSON.stringify(k)):localStorage.removeItem("adhdev_splitSizes")}catch{}},[k]),x.useEffect(()=>{try{localStorage.setItem("adhdev_focusedGroup",String(y))}catch{}},[y]),x.useEffect(()=>{try{localStorage.setItem("adhdev_groupActiveTabs",JSON.stringify(R))}catch{}},[R]),x.useEffect(()=>{try{localStorage.setItem("adhdev_groupTabOrders",JSON.stringify(N))}catch{}},[N]);const[j,M]=x.useState(()=>typeof window<"u"&&window.innerWidth<768);x.useEffect(()=>{const z=window.matchMedia("(max-width: 767px)"),W=H=>M(H.matches);return z.addEventListener("change",W),()=>z.removeEventListener("change",W)},[]);const C=x.useMemo(()=>j||g.size===0?1:Math.max(1,...g.values())+1,[g,j]),A=C>1,O=x.useCallback((z,W)=>{v(H=>{const V=new Map(H);return W===0?V.delete(z):V.set(z,W),V}),S(W)},[]),U=x.useCallback(z=>{v(W=>{const V=(W.size===0?0:Math.max(0,...W.values()))+1;if(V>=4)return W;const ce=new Map(W);return ce.set(z,V),ce}),S(W=>W+1)},[]),L=x.useCallback(z=>{v(W=>{const H=new Map;for(const[V,ce]of W)ce!==z&&(ce>z?H.set(V,ce-1):H.set(V,ce));return H}),B(W=>{if(W.length<=1)return[];const H=[...W];H.splice(z,1);const V=H.reduce((ce,oe)=>ce+oe,0);return H.map(ce=>ce/V*100)}),S(0)},[]),$=x.useRef(null),w=x.useCallback((z,W)=>{W.preventDefault();const H=$.current;if(!H)return;const V=W.clientX,ce=H.offsetWidth,oe=k.length===C?[...k]:Array(C).fill(100/C),Ee=He=>{const Cr=(He.clientX-V)/ce*100,Nt=[...oe];Nt[z]=Math.max(15,oe[z]+Cr),Nt[z+1]=Math.max(15,oe[z+1]-Cr),B(Nt)},Ue=()=>{document.removeEventListener("mousemove",Ee),document.removeEventListener("mouseup",Ue),document.body.style.cursor="",document.body.style.userSelect=""};document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",Ee),document.addEventListener("mouseup",Ue)},[k,C]),[ee,ne]=x.useState({}),[T,X]=x.useState(!1),[I,F]=x.useState([]),[G,he]=x.useState({}),[me,je]=x.useState({}),[Pe,Ce]=x.useState(!1),[de,Te]=x.useState(!1);x.useEffect(()=>{const z=H=>{var V;(V=H.dataTransfer)!=null&&V.types.includes("text/tab-key")&&Te(!0)},W=()=>{Te(!1),Ce(!1)};return window.addEventListener("dragstart",z),window.addEventListener("dragend",W),window.addEventListener("drop",W),()=>{window.removeEventListener("dragstart",z),window.removeEventListener("dragend",W),window.removeEventListener("drop",W)}},[]);const J=a.find(z=>z.type==="adhdev-daemon"),fe=(J==null?void 0:J.detectedIdes)||[],ke=!!J,Me=x.useMemo(()=>{const z=a.filter(H=>H.type!=="adhdev-daemon"),W=new Map;for(const H of z){const V=W.get(H.id);if(!V)W.set(H.id,H);else{const ce=(V.workspace?1:0)+(V.activeChat?1:0);((H.workspace?1:0)+(H.activeChat?1:0)>ce||(H.timestamp||0)>(V.timestamp||0))&&W.set(H.id,H)}}return Array.from(W.values())},[a]),we=x.useMemo(()=>{const z=CL(Me,G,a,_),W=Date.now();return z.map(H=>{const V=me[H.tabKey];return V&&W-V<5e3?{...H,messages:[],title:""}:H})},[Me,G,me,a]),{hiddenTabs:Ke,toggleTab:nr}=eI(),Qe=x.useMemo(()=>we.filter(z=>!Ke.has(z.tabKey)),[we,Ke]);x.useEffect(()=>{IL()},[]);const ir=x.useMemo(()=>Qe.map(z=>({id:z.tabKey,name:z.title||z.agentName||z.ideId,status:z.status,activeModal:z.modalMessage?{message:z.modalMessage,buttons:z.modalButtons}:null})),[Qe]);DL(ir);const sr=x.useMemo(()=>{const z=Array.from({length:C},()=>[]);for(const W of Qe){const H=g.get(W.tabKey)??0,V=Math.min(H,C-1);z[V].push(W)}return z},[Qe,g,C]);x.useEffect(()=>{const z=new Set(Qe.map(W=>W.tabKey));v(W=>{let H=!1;const V=new Map;for(const[ce,oe]of W)z.has(ce)?V.set(ce,oe):H=!0;return H?V:W})},[we]),x.useEffect(()=>{if(A)for(let z=C-1;z>=1;z--)[...g.values()].some(H=>H===z)||L(z)},[g,C,A,L]),x.useEffect(()=>{if(!n||P.current||we.length===0)return;const z=we.find(W=>W.tabKey===n)||we.find(W=>W.ideId===n)||we.find(W=>W.ideType===n||W.agentType===n);if(z){const W=g.get(z.tabKey)??0;E(H=>({...H,[W]:z.tabKey})),S(W),P.current=!0,r(H=>{const V=new URLSearchParams(H);return V.delete("activeTab"),V},{replace:!0})}},[n,we,g]),x.useEffect(()=>{if(Object.keys(me).length===0)return;const W=setTimeout(()=>{je(H=>{const V=Date.now(),ce={};for(const[oe,Ee]of Object.entries(H))V-Ee<5e3&&(ce[oe]=Ee);return Object.keys(ce).length===Object.keys(H).length?H:ce})},5500);return()=>clearTimeout(W)},[me]);const $t=x.useMemo(()=>{var W,H;const z=R[y];if(z){const V=we.find(ce=>ce.tabKey===z);if(V)return V}return((W=sr[y])==null?void 0:W[0])||((H=sr[0])==null?void 0:H[0])},[R,y,we,sr]),Y=x.useCallback((z,W)=>{},[]);x.useEffect(()=>{var V;const z=Date.now();let W=!1;const H={...ee};for(const ce of we)(V=ce.messages)!=null&&V.length&&ce.messages.forEach((oe,Ee)=>{const Ue=`${ce.ideId}-${oe.id??`i-${Ee}`}`;H[Ue]==null&&(H[Ue]=z,W=!0)});W&&ne(H)},[we]);const se=x.useRef(!1);x.useEffect(()=>{if(!T){se.current=!1;return}if(!$t||se.current||ae)return;const z=a.find(W=>W.id===$t.ideId);z&&(!z.chats||z.chats.length===0)&&(se.current=!0,q())},[T,$t==null?void 0:$t.ideId]),x.useEffect(()=>{const z=setInterval(()=>{const W=Date.now()-3e5;F(H=>{const V=H.filter(ce=>ce.timestamp>W).slice(-100);return V.length===H.length?H:V})},6e4);return()=>clearInterval(z)},[]);const ye=x.useRef(new Map);x.useEffect(()=>{const z=(H,V)=>{var ce;if(V){I1.emit(H,V);for(const oe of we){if(!si(oe))continue;const Ee=(ce=oe.ideId)!=null&&ce.includes(":cli:")?oe.ideId.split(":cli:")[1]:"";if(H===Ee||H===oe.agentType||H===oe.ideType){const He=ye.current.get(oe.tabKey)||[];He.push(V),He.length>1e4&&He.splice(0,He.length-5e3),ye.current.set(oe.tabKey,He)}}}},W=T_.onPtyOutput(z);return()=>{W()}},[we]),x.useEffect(()=>{const z=W=>{if(W.ctrlKey&&W.key==="\\"){if(W.preventDefault(),A)v(new Map),S(0);else{const H=we[1];H&&U(H.tabKey)}return}W.ctrlKey&&(W.key==="["||W.key==="]")&&A&&(W.preventDefault(),S(H=>W.key==="]"?Math.min(H+1,C-1):Math.max(H-1,0)))};return window.addEventListener("keydown",z),()=>window.removeEventListener("keydown",z)},[A,we,U,C]),x.useEffect(()=>{gi.setIdes(a)},[a]),x.useEffect(()=>{gi.setResolveAction((z,W,H)=>{e(z,W,H).catch(()=>{})})},[e]),x.useEffect(()=>{const z=gi.onToast(V=>{f(oe=>[...oe.slice(-4),{id:V.id,message:V.message,type:V.type,timestamp:V.timestamp,ideId:V.ideId,actions:V.actions}]);const ce=V.duration||5e3;setTimeout(()=>f(oe=>oe.filter(Ee=>Ee.id!==V.id)),ce)}),W=gi.onSystemMessage((V,ce)=>{he(oe=>{for(const Ee of Object.keys(oe))if(Ee.includes(V))return{...oe,[Ee]:[...oe[Ee]||[],ce]};return oe})}),H=gi.onClearSystemMessage((V,ce)=>{he(oe=>{const Ee={...oe};for(const Ue of Object.keys(Ee))Ue.includes(V)&&(Ee[Ue]=(Ee[Ue]||[]).filter(He=>{var Et;return!(He.role==="system"&&((Et=He._localId)!=null&&Et.startsWith(ce)))}));return Ee})});return()=>{z(),W(),H()}},[]),x.useEffect(()=>{const z=gL.on("status_event",H=>gi.handleRawEvent(H,"ws")),W=T_.onStatusEvent((H,V)=>gi.handleRawEvent(V,"p2p"));return()=>{z(),W()}},[]),x.useEffect(()=>{var W;const z=H=>{const V=H.data;(V==null?void 0:V.type)==="notification_action"&&V.action==="approve"&&V.ideId&&e(V.ideId,"resolve_action",{action:"approve",button:"Approve"}).catch(ce=>console.error("[SW Action] approve failed:",ce))};return(W=navigator.serviceWorker)==null||W.addEventListener("message",z),()=>{var H;return(H=navigator.serviceWorker)==null?void 0:H.removeEventListener("message",z)}},[]);const{isCreatingChat:K,isRefreshingHistory:ae,handleLaunchIde:xe,handleSwitchSession:Oe,handleNewChat:Se,handleRefreshHistory:q}=eb({sendDaemonCommand:e,activeConv:$t,ides:a,updateIdeChats:s,setToasts:f,setLocalUserMessages:he,setClearedTabs:je,setActionLogs:F,pinTab:Y,isStandalone:ke}),te=x.useMemo(()=>a.filter(z=>z.type==="adhdev-daemon"&&z.versionMismatch),[a]),[Z,ve]=x.useState(!1),[Re,Le]=x.useState({}),pt=x.useCallback(async z=>{var W,H;Le(V=>({...V,[z]:"upgrading"}));try{const V=await e(z,"daemon_upgrade",{});(W=V==null?void 0:V.result)!=null&&W.upgraded||(H=V==null?void 0:V.result)!=null&&H.success?Le(ce=>({...ce,[z]:"done"})):Le(ce=>({...ce,[z]:"error"}))}catch{Le(V=>({...V,[z]:"error"}))}},[e]);return u.jsxs("div",{className:"page-dashboard flex-1 min-h-0 bg-bg-primary text-text-primary flex flex-col overflow-hidden",children:[u.jsx(fL,{wsStatus:p,showReconnected:b}),te.length>0&&!Z&&u.jsxs("div",{className:"flex items-center gap-2.5 px-4 py-2 bg-amber-500/[0.08] border-b border-amber-500/20 text-xs text-text-secondary shrink-0 flex-wrap",children:[u.jsx("span",{className:"text-sm shrink-0",children:"🔄"}),u.jsxs("span",{className:"flex-1 flex items-center gap-2 flex-wrap min-w-0",children:[u.jsxs("span",{children:["Update available: ",u.jsxs("strong",{children:["v",te[0].version]})," → ",u.jsxs("strong",{children:["v",te[0].serverVersion]})]}),te.map(z=>{var V;const W=z.machineNickname||((V=z.machine)==null?void 0:V.hostname)||z.hostname||"Machine",H=Re[z.id];return u.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2 py-0.5 rounded-md bg-amber-500/[0.08] border border-amber-500/15",children:[u.jsx("span",{className:"font-medium text-text-primary",children:W}),u.jsxs("span",{className:"text-[10px] text-text-muted",children:["v",z.version]}),H==="upgrading"?u.jsx("span",{className:"text-[10px] text-amber-400 animate-pulse",children:"upgrading…"}):H==="done"?u.jsx("span",{className:"text-[10px] text-green-400",children:"✓ restarting"}):H==="error"?u.jsx("button",{className:"text-[10px] text-red-400 hover:text-red-300 underline cursor-pointer",onClick:()=>pt(z.id),children:"retry"}):u.jsx("button",{className:"text-[10px] font-semibold text-amber-400 hover:text-amber-300 cursor-pointer px-1.5 py-px rounded bg-amber-500/10 border border-amber-500/20 transition-colors",onClick:()=>pt(z.id),children:"Upgrade"})]},z.id)})]}),u.jsx("button",{className:"text-text-muted hover:text-text-primary transition-colors text-sm px-1 shrink-0",onClick:()=>ve(!0),title:"Dismiss",children:"✕"})]}),u.jsx(vL,{activeConv:$t,agentCount:Me.length,wsStatus:p,isConnected:m,onOpenHistory:()=>X(!0)}),u.jsxs("div",{ref:$,className:`flex-1 min-h-0 flex ${A?"flex-row":"flex-col"} overflow-hidden`,children:[sr.map((z,W)=>{const H=A&&k.length===C?`${k[W]}%`:void 0;return u.jsxs(lv.Fragment,{children:[A&&W>0&&u.jsx("div",{className:"shrink-0 w-1 cursor-col-resize hover:bg-accent-primary/30 transition-colors relative group",style:{background:"var(--border-subtle)"},onMouseDown:V=>w(W-1,V),onDoubleClick:()=>L(W),title:"Drag to resize · Double-click to merge",children:u.jsx("div",{className:"absolute inset-y-0 -left-1 -right-1 group-hover:bg-accent-primary/10"})}),u.jsx(tI,{style:A?{flexBasis:H??`${100/C}%`,flexGrow:H?0:1,flexShrink:H?0:1}:void 0,conversations:z,ides:a,messageReceivedAt:ee,actionLogs:I,ptyBuffers:ye,screenshotMap:o,setScreenshotMap:l,sendDaemonCommand:e,updateIdeChats:s,setToasts:f,setLocalUserMessages:he,setClearedTabs:je,setActionLogs:F,pinTab:Y,isStandalone:ke,userName:i.userName,groupIndex:W,isFocused:y===W,onFocus:()=>S(W),isSplitMode:A,numGroups:C,onMoveTab:(V,ce)=>{ce==="left"&&W>0?O(V,W-1):ce==="right"&&W<C-1?O(V,W+1):ce==="new"&&C<4&&U(V)},onClose:A?()=>L(W):void 0,onReceiveTab:V=>O(V,W),detectedIdes:W===0?fe:void 0,handleLaunchIde:W===0?xe:void 0,onActiveTabChange:V=>E(ce=>({...ce,[W]:V})),initialActiveTabId:R[W],initialTabOrder:N[W],onTabOrderChange:V=>D(ce=>({...ce,[W]:V})),onHideTab:nr})]},W)}),!j&&C<4&&u.jsxs("div",{className:"relative shrink-0 w-0 z-50",children:[u.jsx("div",{className:"fixed right-0 top-0 bottom-0 w-16",style:{pointerEvents:de?"auto":"none"},onDragOver:z=>{z.dataTransfer.types.includes("text/tab-key")&&(z.preventDefault(),Ce(!0))},onDragLeave:()=>Ce(!1),onDrop:z=>{z.preventDefault(),Ce(!1);const W=z.dataTransfer.getData("text/tab-key");W&&U(W)}}),u.jsx("div",{className:"fixed right-0 top-0 bottom-0 pointer-events-none transition-all duration-200",style:{width:Pe?"120px":"0px",background:"var(--accent-primary)",opacity:Pe?.15:0,borderLeft:Pe?"2px dashed var(--accent-primary)":"none"}})]})]}),T&&$t&&u.jsx(bL,{activeConv:$t,ides:a,isCreatingChat:K,isRefreshingHistory:ae,onClose:()=>X(!1),onNewChat:Se,onSwitchSession:Oe,onRefreshHistory:q}),u.jsx("style",{children:`
|
|
188
188
|
body { overflow: hidden; overscroll-behavior: none; }
|
|
189
189
|
.pulse-amber { animation: pulse-amber 2s infinite ease-in-out; }
|
|
190
190
|
@keyframes pulse-amber {
|
|
@@ -199,4 +199,4 @@ Use this if you accidentally set up on a shared/public computer and want to ensu
|
|
|
199
199
|
}
|
|
200
200
|
`}),c&&u.jsx(rI,{onClose:()=>{try{localStorage.setItem("adhdev_onboarding_v1","done")}catch{}d(!1)}})]})}function iI(e){return e.split(":")[0]||""}function sI({renderHeaderActions:e}={}){var Ce,de,Te;const{id:t}=by(),r=En(),n=Lc(),i=n.ides||[],s=n.connectionStates||{},{sendCommand:o}=ui(),l=x.useMemo(()=>iI(t||""),[t]),a=x.useMemo(()=>i.find(J=>J.id===t),[i,t]),c=(a==null?void 0:a.type)||void 0,d=c?c.charAt(0).toUpperCase()+c.slice(1):"IDE",h=(a==null?void 0:a.activeChat)||null,f=(a==null?void 0:a.agentStreams)||[],p=n.isConnected??!0,m=s[l]||(p?"connected":"new"),_=x.useMemo(()=>i.find(J=>J.id===l||J.daemonId===l),[i,l]),b=(_==null?void 0:_.machineNickname)||((Ce=_==null?void 0:_.machine)==null?void 0:Ce.hostname)||"",g=(a==null?void 0:a.workspace)||"",[v]=Cy(),y=typeof window<"u"&&window.innerWidth<=768,S=v.get("view")||(y?"chat":"split"),[R,E]=x.useState(S),[P,N]=x.useState("native"),[D,k]=x.useState(""),[B,j]=x.useState(!1),[M,C]=x.useState(null),[A,O]=x.useState(null),[U,L]=x.useState([]),$=h==null?void 0:h.status,w=(((Te=(de=h==null?void 0:h.activeModal)==null?void 0:de.buttons)==null?void 0:Te.length)??0)>0,ee=$==="generating"||$==="loading"||$&&$.toLowerCase()==="thinking",T=w||$==="waiting_approval"?"waiting_approval":ee?"working":$||"idle",X=x.useMemo(()=>{var J,fe;return{ideId:t||"",daemonId:l,agentName:Id(c||""),agentType:c||"",status:T,title:(h==null?void 0:h.title)||"",messages:(h==null?void 0:h.messages)||[],ideType:c||"",workspaceName:(a==null?void 0:a.workspaceName)||"",displayPrimary:d,displaySecondary:(a==null?void 0:a.workspaceName)||"",cdpConnected:!0,modalButtons:(J=h==null?void 0:h.activeModal)==null?void 0:J.buttons,modalMessage:(fe=h==null?void 0:h.activeModal)==null?void 0:fe.message,streamSource:"native",tabKey:`ide-${t}`}},[t,l,c,h,a,d,T]),I=x.useMemo(()=>f.map(J=>{var ke,Me;const fe=J.activeModal?"waiting_approval":J.status==="streaming"?"working":J.status||"idle";return{ideId:t||"",daemonId:l,agentName:J.agentName,agentType:J.agentType,status:fe,title:"",messages:J.messages.map((we,Ke)=>({role:we.role,content:we.content,kind:we.kind,id:`${J.agentType}-${Ke}`,receivedAt:we.timestamp})),ideType:J.agentType,workspaceName:"",displayPrimary:J.agentName,displaySecondary:"",cdpConnected:!0,modalButtons:(ke=J.activeModal)==null?void 0:ke.buttons,modalMessage:(Me=J.activeModal)==null?void 0:Me.message,streamSource:"agent-stream",tabKey:`agent-stream-${J.agentType}`}}),[f,t,l]),F=x.useMemo(()=>P==="native"?X:I.find(J=>J.agentType===P)||X,[P,X,I]);x.useEffect(()=>l?vr.onScreenshot("ide-page",(fe,ke)=>{if(fe!==l)return;const Me=new FileReader;Me.onload=()=>C(Me.result),Me.readAsDataURL(ke)}):void 0,[l]),x.useEffect(()=>l?vr.onStatusEvent((fe,ke)=>{if(fe!==l)return;let Me="",we="info";if(ke.event==="agent:generating_completed"?(Me=`✅ Task completed${ke.duration?` (${ke.duration}s)`:""}`,we="success"):ke.event==="agent:waiting_approval"&&(Me="⚡ Approval needed",we="warning"),Me){const Ke=Date.now();L(Qe=>[...Qe.slice(-4),{id:Ke,message:Me,type:we}]),setTimeout(()=>L(Qe=>Qe.filter(ir=>ir.id!==Ke)),we==="warning"?1e4:5e3)}}):void 0,[l]);const G=x.useMemo(()=>{if(!t)return c;const J=t.split(":");return J.length>=3&&J[1]==="ide"?J.slice(2).join(":"):c},[t,c]);x.useEffect(()=>{const J=l?vr.get(l):null;!J||!(m==="connected")||(R!=="chat"&&G?J.startScreenshots(G):J.stopScreenshots(G))},[R,m,G,l]);const he=x.useCallback(async(J,fe={})=>{if(!t)throw new Error("No IDE ID");const ke={...fe};if(!ke._targetInstance&&t){const we=t.split(":");we.length>=3&&(we[1]==="ide"||we[1]==="cli")&&(ke._targetInstance=we.slice(2).join(":"),ke._targetType=we[1])}const Me=l?vr.get(l):null;return Me!=null&&Me.hasCommandChannel?await Me.sendCommand(J,ke):Me&&Me.connectionState!=="failed"&&Me.connectionState!=="closed"&&await new Promise(Ke=>{const nr=Date.now(),Qe=()=>{if(Me.hasCommandChannel)return Ke(!0);if(Date.now()-nr>3e3)return Ke(!1);setTimeout(Qe,200)};Qe()})&&Me.hasCommandChannel?await Me.sendCommand(J,ke):await o(t,J,ke)},[t,l]),me=async()=>{const J=D.trim();if(!(!J||!t||B)){k(""),j(!0);try{await he("send_chat",{message:J,text:J,waitForResponse:!0,...P!=="native"&&{agentType:P}})}catch(fe){console.error("[IDE] Send failed:",fe)}finally{j(!1)}}},je=async J=>{if(t)try{const fe=await o(t,"screenshot",{width:J?Math.min(J,1280):1280});fe!=null&&fe.success&&(fe!=null&&fe.base64)&&O(`data:image/jpeg;base64,${fe.base64}`)}catch(fe){console.error("[IDE] Screenshot failed:",fe)}},Pe=f.length>0;return t?u.jsxs("div",{className:"ide-page",children:[u.jsxs("header",{className:"ide-header",children:[u.jsxs("div",{className:"ide-header-left",children:[u.jsxs("div",{className:"ide-title",children:[u.jsx(Ya,{size:16}),u.jsx("span",{className:"ide-name",children:d}),u.jsx("span",{className:"ide-name-mobile",children:"IDE"}),g&&u.jsx("span",{className:"ide-workspace",children:g}),u.jsx("span",{className:"ide-badge",children:"REMOTE"})]}),u.jsxs("div",{className:"ide-status-pill",children:[u.jsx("span",{className:`ide-dot ${m==="connected"?"online":"connecting"}`}),u.jsx("span",{className:"ide-status-text",children:m==="connected"?"Connected":m==="connecting"?"Connecting":"WS"})]}),b&&u.jsx("span",{className:"ide-machine-label",children:b})]}),u.jsxs("div",{className:"ide-header-right",children:[["chat","split","remote"].map(J=>u.jsx("button",{className:"btn btn-secondary btn-sm",style:{border:R===J?"1px solid var(--accent-primary)":"none",background:R===J?"rgba(99,102,241,0.12)":"var(--bg-secondary)",padding:"6px 10px",color:R===J?"var(--accent-primary)":void 0},onClick:()=>E(J),children:J==="chat"?u.jsx(Ya,{size:14}):J==="split"?"⊞":u.jsx(ul,{size:14})},J)),e&&e({daemonId:l,ideInstanceId:t||""}),u.jsxs("button",{className:"btn btn-primary btn-sm border-none px-3 py-1.5 text-xs flex items-center justify-center shrink-0",onClick:()=>r(-1),children:["←",u.jsx("span",{className:"hidden md:inline ml-1",children:"Back"})]})]})]}),u.jsxs("div",{className:"ide-content",children:[u.jsxs("div",{className:`ide-chat-panel ${R==="chat"?"full":""} ${R==="remote"?"hidden":""}`,children:[Pe&&u.jsxs("div",{className:"ide-chat-tabs",children:[u.jsx("button",{className:`ide-chat-tab ${P==="native"?"active":""}`,onClick:()=>N("native"),children:d}),f.map(J=>{const fe=P===J.agentType,ke=J.status==="waiting_approval"||!!J.activeModal,Me=J.status==="streaming";return u.jsxs("button",{className:`ide-chat-tab ${fe?"active":""}`,onClick:()=>N(J.agentType),children:[u.jsx("span",{style:{display:"inline-block",width:6,height:6,borderRadius:"50%",marginRight:5,background:ke?"#f59e0b":Me?"var(--accent-primary)":"#64748b",boxShadow:Me?"0 0 6px var(--accent-primary)":"none"}}),J.agentName,ke&&u.jsx("span",{className:"ide-ext-badge",style:{background:"#f59e0b22",color:"#f59e0b",marginLeft:4},children:"!"})]},J.agentType)})]}),u.jsx(L1,{activeConv:F,ides:i,agentInput:D,setAgentInput:k,handleSendChat:me,handleFocusAgent:()=>{},isFocusingAgent:!1,messageReceivedAt:{},actionLogs:[],userName:n.userName})]}),u.jsx("div",{className:`ide-remote-panel ${R==="remote"?"full":""} ${R==="chat"?"hidden":""}`,children:u.jsx(cL,{screenshot:A,isCapturing:!1,onRefresh:je,addLog:()=>{},connState:m,connScreenshot:M,onAction:async(J,fe)=>{const ke=l?vr.get(l):null;if(!ke||m!=="connected")return console.warn("[RemoteInput] P2P not connected"),{success:!1,error:"P2P not connected"};const Me=(a==null?void 0:a.instanceId)||G;return await ke.sendInput(J,fe,Me)}})})]}),U.length>0&&u.jsx("div",{className:"ide-toasts",children:U.map(J=>u.jsx("div",{className:`ide-toast ${J.type}`,onClick:()=>L(fe=>fe.filter(ke=>ke.id!==J.id)),children:J.message},J.id))})]}):u.jsx("div",{className:"ide-empty",children:"No IDE selected"})}function oI({machineId:e,sendDaemonCommand:t,logsEndRef:r}){const[n,i]=x.useState([]),[s,o]=x.useState(null),[l,a]=x.useState(!1),[c,d]=x.useState(!1),[h,f]=x.useState(!1),[p,m]=x.useState([]),[_,b]=x.useState([]),[g,v]=x.useState(null),[y,S]=x.useState(!1),[R,E]=x.useState(""),P=x.useRef(null),N=x.useCallback(X=>{P.current=X},[]),D=x.useCallback((X,I)=>{i(F=>[...F.slice(-100),{timestamp:Date.now(),level:X,message:I}]),setTimeout(()=>{var F;return(F=r.current)==null?void 0:F.scrollIntoView({behavior:"smooth"})},100)},[r]),k=x.useCallback(async X=>{if(!(!e||s)){o(X),D("info",`Launching ${Ir(X)}...`);try{const I=await t(e,"launch_ide",{ideType:X,enableCdp:!0});D(I!=null&&I.success?"info":"error",I!=null&&I.success?`${Ir(X)} launched`:`Failed: ${I==null?void 0:I.error}`)}catch(I){D("error",`Launch error: ${I.message}`)}finally{o(null)}}},[e,s,D,t]),B=x.useCallback(async X=>{if(!e)return;const{cliType:I,dir:F,workspaceId:G,useDefaultWorkspace:he,useHome:me,argsStr:je,model:Pe}=X;if(!I){D("warn","Select a CLI or ACP provider first");return}const Ce=je?je.split(/\s+/).filter(Boolean):void 0,de=(F==null?void 0:F.trim())||(G?"(saved id)":he?"(default workspace)":me?"(home)":"");D("info",`Launching ${I}${de?` in ${de}`:""}${Pe?` (model: ${Pe})`:""}...`);try{const Te={cliType:I,cliArgs:Ce,initialModel:Pe||void 0};F!=null&&F.trim()?Te.dir=F.trim():G?Te.workspaceId=G:he?Te.useDefaultWorkspace=!0:me&&(Te.useHome=!0);const J=await t(e,"launch_cli",Te),fe=(J==null?void 0:J.result)||J;J!=null&&J.success?(D("info",`${I} launched`),(fe==null?void 0:fe.launchSource)==="home"?D("info","📂 Running in home directory (explicit choice)"):(fe==null?void 0:fe.launchSource)==="defaultWorkspace"&&D("info","📂 Using default workspace (explicit choice)")):(D("error",`Failed: ${(J==null?void 0:J.error)||(fe==null?void 0:fe.error)}`),(J==null?void 0:J.code)==="WORKSPACE_LAUNCH_CONTEXT_REQUIRED"&&v({cliType:I,argsStr:je,model:Pe}))}catch(Te){D("error",`Launch error: ${Te.message}`)}},[e,D,t]),j=x.useCallback((X,I,F,G)=>{if(e){if(!X){D("warn","Select a provider");return}if(!I.trim()){v({cliType:X,argsStr:F,model:G});return}B({cliType:X,dir:I,argsStr:F,model:G})}},[e,D,B]),M=x.useCallback(async(X,I,F)=>{if(e&&window.confirm(`Stop ${X}?
|
|
201
201
|
This will terminate the process.`))try{const G=await t(e,"stop_cli",{cliType:X,dir:I,_targetInstance:F});G!=null&&G.success?D("info",`${X} stopped`):D("error",`Stop failed: ${(G==null?void 0:G.error)||"Unknown error"}`)}catch(G){D("error",`Stop failed: ${G.message}`)}},[e,D,t]),C=x.useCallback(async X=>{try{await t(X.daemonId,"restart_ide",{ideType:X.type}),D("info",`${Ir(X.type)} restart initiated`)}catch(I){D("error",`Restart failed: ${I.message}`)}},[D,t]),A=x.useCallback(async X=>{if(window.confirm(`Stop ${Ir(X.type)}?
|
|
202
|
-
This will disconnect CDP and optionally kill the process.`))try{const I=await t(X.daemonId,"stop_ide",{ideType:X.type,killProcess:!0});I!=null&&I.success?D("info",`${Ir(X.type)} stopped`):D("error",`Stop failed: ${(I==null?void 0:I.error)||"Unknown error"}`)}catch(I){D("error",`Stop failed: ${I.message}`)}},[D,t]),O=x.useCallback(async()=>{if(e)try{const X=await t(e,"detect_ides",{});D("info",`Found ${((X==null?void 0:X.result)||[]).length} IDE(s)`)}catch(X){D("error",`Detection failed: ${X.message}`)}},[e,D,t]),U=x.useCallback(async()=>{if(e){a(!0);try{const X=await t(e,"get_recent_workspaces",{});X!=null&&X.success&&Array.isArray(X==null?void 0:X.result)&&b(X.result)}catch(X){D("error",`Failed: ${X.message}`)}finally{a(!1)}}},[e,D,t]),L=x.useCallback(async X=>{if(!(!e||!X.trim())){d(!0);try{const I=await t(e,"workspace_add",{path:X.trim()});I!=null&&I.success?D("info",`Workspace added: ${X.trim()}`):D("error",(I==null?void 0:I.error)||"workspace_add failed")}catch(I){D("error",I.message)}finally{d(!1)}return!0}},[e,D,t]),$=x.useCallback(async X=>{if(!(!e||!window.confirm("Remove this workspace from the list?"))){d(!0);try{const I=await t(e,"workspace_remove",{id:X});I!=null&&I.success?D("info","Workspace removed"):D("error",(I==null?void 0:I.error)||"workspace_remove failed")}catch(I){D("error",I.message)}finally{d(!1)}}},[e,D,t]),w=x.useCallback(async X=>{var I;if(e){d(!0);try{const F=await t(e,"workspace_set_default",X===null?{clear:!0}:{id:X});if(F!=null&&F.success){D("info",X?"Default workspace updated":"Default workspace cleared");const G=typeof F.defaultWorkspacePath=="string"?F.defaultWorkspacePath:"";G&&((I=P.current)==null||I.call(P,G))}else D("error",(F==null?void 0:F.error)||"workspace_set_default failed")}catch(F){D("error",F.message)}finally{d(!1)}}},[e,D,t]),ee=x.useCallback(async X=>{var F;if(!e||!X.trim())return;const I=X.trim();d(!0);try{const G=await t(e,"workspace_set_default",{path:I});G!=null&&G.success?(D("info","Default workspace set from history"),(F=P.current)==null||F.call(P,I)):D("error",(G==null?void 0:G.error)||"Could not set default (path missing on disk?)")}catch(G){D("error",G.message)}finally{d(!1)}},[e,D,t]),ne=x.useCallback(async()=>{var X;if(e){f(!0);try{const I=await t(e,"get_cli_history",{}),F=(I==null?void 0:I.history)??((X=I==null?void 0:I.result)==null?void 0:X.history);I!=null&&I.success&&Array.isArray(F)&&m(F)}catch{}f(!1)}},[e,t]),T=x.useCallback(async()=>{if(e)try{await t(e,"set_machine_nickname",{nickname:R}),D("info",`Nickname set to "${R||"(cleared)"}"`),S(!1)}catch(X){D("error",`Failed: ${X.message}`)}},[e,R,D,t]);return{logs:n,launchingIde:s,loadingWorkspaces:l,workspaceBusy:c,loadingHistory:h,cliHistory:p,recentWorkspaces:_,launchPick:g,setLaunchPick:v,editingNickname:y,setEditingNickname:S,nicknameInput:R,setNicknameInput:E,addLog:D,handleLaunchIde:k,runLaunchCliCore:B,handleLaunchCli:j,handleStopCli:M,handleRestartIde:C,handleStopIde:A,handleDetectIdes:O,handleLoadRecentWorkspaces:U,handleWorkspaceAdd:L,handleWorkspaceRemove:$,handleWorkspaceSetDefault:w,handleWorkspaceResumePath:ee,loadCliHistory:ne,handleSaveNickname:T,setOnDefaultWorkspaceChanged:N}}function lI(e){const t=Math.floor((Date.now()-e)/1e3);return t<45?"just now":t<3600?`${Math.floor(t/60)}m ago`:t<86400?`${Math.floor(t/3600)}h ago`:`${Math.floor(t/86400)}d ago`}function aI({machine:e,managedIdes:t,managedClis:r,managedAcps:n,providers:i,getIcon:s,actions:o,setActiveTab:l}){const a=En(),{cliHistory:c,loadCliHistory:d,workspaceBusy:h,handleWorkspaceAdd:f,handleWorkspaceRemove:p,handleWorkspaceSetDefault:m,handleWorkspaceResumePath:_,runLaunchCliCore:b}=o,[g,v]=x.useState("");x.useEffect(()=>(o.setOnDefaultWorkspaceChanged(()=>{}),()=>o.setOnDefaultWorkspaceChanged(null)),[o]),x.useEffect(()=>{d()},[d]);const y=e.availableMem??e.freeMem,S=e.totalMem>0?Math.min(100,Math.max(0,Math.round((e.totalMem-y)/e.totalMem*100))):0,R=e.loadavg[0]||0,E=P=>{const N=i.find(D=>D.type===P);(N==null?void 0:N.category)==="acp"?l("acps"):l("clis")};return u.jsxs("div",{children:[u.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-2.5 mb-5",children:[u.jsx(Hl,{icon:u.jsx(Mg,{size:16}),label:"Uptime",value:xL(e.uptime)}),u.jsx(Hl,{icon:u.jsx(ul,{size:16}),label:"IDEs",value:`${t.length}`}),u.jsx(Hl,{icon:u.jsx(O0,{size:16}),label:"CLIs",value:`${r.length}`}),u.jsx(Hl,{icon:u.jsx(z0,{size:16}),label:"ACPs",value:`${n.length}`})]}),u.jsxs("div",{className:"px-5 py-4 rounded-xl mb-5 bg-bg-secondary border border-border-subtle",children:[u.jsx("div",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider mb-3",children:"Resource Usage"}),u.jsxs("div",{className:"flex gap-6",children:[u.jsx(N_,{value:Math.min(Math.round(R/e.cpus*100),100),max:100,label:"CPU Load",color:"#8b5cf6",detail:`${R.toFixed(2)} avg / ${e.cpus} cores`}),u.jsx(N_,{value:S,max:100,label:"Memory",color:"#3b82f6",detail:`${P_(e.totalMem-y)} / ${P_(e.totalMem)}${e.platform==="darwin"?" (approx.)":""}`})]})]}),u.jsxs("div",{className:"px-5 py-4 rounded-xl mb-5 bg-bg-secondary border border-border-subtle",children:[u.jsx("div",{className:"flex flex-wrap items-center justify-between gap-2 mb-3",children:u.jsxs("div",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider flex items-center gap-1.5",children:[u.jsx(Xa,{size:14})," Workspaces"]})}),u.jsxs("p",{className:"text-[10px] text-text-muted m-0 mb-3",children:["One list for IDE, CLI, and ACP: saved paths below, and a single ",u.jsx("strong",{className:"text-text-secondary font-medium",children:"default"}),'. The default opens in the IDE when you launch it, pre-fills CLI/ACP directories, and is what "Default" launch uses.']}),u.jsxs("div",{className:"flex flex-wrap gap-2 items-center mb-3",children:[u.jsx("span",{className:"text-[10px] text-text-muted",children:"Default:"}),u.jsxs("select",{className:"text-xs bg-bg-primary border border-border-subtle rounded-lg px-2 py-1 max-w-[min(100%,420px)]",disabled:h,value:e.defaultWorkspaceId||"",onChange:P=>void m(P.target.value===""?null:P.target.value),children:[u.jsx("option",{value:"",children:"(none — set a default to align IDE folder + CLI/ACP fields)"}),(e.workspaces||[]).map(P=>u.jsx("option",{value:P.id,children:P.label||P.path},P.id))]}),e.defaultWorkspacePath&&u.jsx("span",{className:"text-[10px] text-text-muted font-mono truncate max-w-[min(100%,360px)]",title:e.defaultWorkspacePath,children:e.defaultWorkspacePath})]}),u.jsxs("div",{className:"flex flex-wrap gap-2 items-end",children:[u.jsx("input",{className:"flex-1 min-w-[200px] text-xs bg-bg-primary border border-border-subtle rounded-lg px-2.5 py-1.5",placeholder:"Absolute workspace path to add…",value:g,disabled:h,onChange:P=>v(P.target.value),onKeyDown:P=>P.key==="Enter"&&void(async()=>{await f(g)&&v("")})()}),u.jsx("button",{type:"button",className:"machine-btn text-xs px-3 py-1.5",disabled:h,onClick:async()=>{await f(g)&&v("")},children:"Add"})]}),(e.workspaces||[]).length>0&&u.jsx("ul",{className:"mt-3 space-y-1 max-h-32 overflow-y-auto",children:(e.workspaces||[]).map(P=>u.jsxs("li",{className:"flex items-center gap-2 text-[11px] text-text-muted",children:[u.jsx("span",{className:"font-mono truncate flex-1",title:P.path,children:P.path}),u.jsx("button",{type:"button",className:"text-[10px] text-red-400/90 hover:underline",disabled:h,onClick:()=>void p(P.id),children:"Remove"})]},P.id))})]}),u.jsxs("div",{className:"px-5 py-4 rounded-xl mb-5 bg-bg-secondary border border-border-subtle border-violet-500/15",children:[u.jsxs("div",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider mb-1 flex items-center gap-1.5",children:[u.jsx(Mg,{size:14})," Pick up where you left off"]}),u.jsx("p",{className:"text-[10px] text-text-muted m-0 mb-3",children:"Same workspaces as above. Re-run CLI/ACP, or open CLIs/ACP tab with a path filled; IDE launch uses the default automatically when set."}),u.jsx("div",{className:"text-[10px] font-semibold text-text-muted uppercase tracking-wide mb-2",children:"Recent CLI / ACP launches"}),c.length>0?u.jsx("div",{className:"flex flex-col gap-1.5 mb-4",children:c.slice(0,10).map((P,N)=>{const D=P.label||`${P.cliType} · ${(P.dir||"").split("/").filter(Boolean).pop()||P.dir||"?"}`;return u.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-[11px] rounded-lg px-2.5 py-1.5 bg-bg-primary/80 border border-border-subtle",children:[u.jsxs("span",{className:"font-medium text-text-primary truncate max-w-[min(100%,240px)]",title:P.dir,children:[s(P.cliType)," ",D]}),u.jsx("span",{className:"text-[9px] text-text-muted font-mono truncate max-w-[min(100%,200px)]",title:P.dir,children:P.dir}),u.jsxs("span",{className:"flex flex-wrap gap-1.5 ml-auto",children:[u.jsx("button",{type:"button",className:"machine-btn text-[10px] px-2 py-0.5",onClick:()=>void b({cliType:P.cliType,dir:P.dir,argsStr:(P.cliArgs||[]).join(" ")}),children:"Run again"}),u.jsx("button",{type:"button",className:"machine-btn text-[10px] px-2 py-0.5",onClick:()=>E(P.cliType),children:"Open tab…"})]})]},`${P.cliType}-${P.dir}-${P.timestamp}-${N}`)})}):u.jsx("p",{className:"text-[11px] text-text-muted mb-4",children:"No launch history yet — start a CLI or ACP from the tabs below, then return here."}),(e.workspaceActivity||[]).length>0&&u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"text-[10px] font-semibold text-text-muted uppercase tracking-wide mb-2",children:"Recent workspace paths"}),u.jsx("div",{className:"flex flex-col gap-1.5",children:(e.workspaceActivity||[]).slice(0,12).map(P=>{const N=P.path.split("/").filter(Boolean).pop()||P.path,D=P.kind==="ide"?"IDE":P.kind==="cli"?"CLI":P.kind==="acp"?"ACP":P.kind==="default"||P.kind==="active"?"●":"",k=(P.kind==="cli"||P.kind==="acp")&&!!P.agentType;return u.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-[11px] rounded-lg px-2.5 py-1.5 bg-bg-primary/80 border border-border-subtle",children:[u.jsx("span",{className:"font-medium text-text-primary truncate max-w-[min(100%,200px)]",title:P.path,children:N}),D&&u.jsx("span",{className:"text-[9px] px-1.5 py-px rounded bg-violet-500/15 text-violet-400",children:D}),P.agentType&&u.jsx("span",{className:"text-[9px] text-text-muted font-mono",children:P.agentType}),u.jsx("span",{className:"text-[9px] text-text-muted",children:lI(P.lastUsedAt)}),u.jsxs("span",{className:"flex flex-wrap gap-1.5 ml-auto",children:[k&&u.jsx("button",{type:"button",className:"machine-btn text-[10px] px-2 py-0.5",onClick:()=>void b({cliType:P.agentType,dir:P.path}),children:"Run again"}),u.jsx("button",{type:"button",className:"machine-btn text-[10px] px-2 py-0.5",onClick:()=>l("clis"),children:"CLIs tab"}),u.jsx("button",{type:"button",className:"machine-btn text-[10px] px-2 py-0.5",onClick:()=>l("acps"),children:"ACP tab"}),u.jsx("button",{type:"button",className:"machine-btn text-[10px] px-2 py-0.5",disabled:h,onClick:()=>void _(P.path),children:"Set default"})]})]},`${P.path}-${P.lastUsedAt}`)})})]})]}),u.jsxs("div",{className:"grid grid-cols-[repeat(auto-fit,minmax(200px,1fr))] gap-3",children:[u.jsxs("div",{className:"px-5 py-4 rounded-xl bg-bg-secondary border border-border-subtle",children:[u.jsxs("div",{className:"flex justify-between items-center mb-2.5",children:[u.jsx("span",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider",children:"IDEs"}),u.jsx("button",{onClick:()=>l("ides"),className:"machine-btn text-[10px]",children:"View All →"})]}),t.length===0?u.jsx("div",{className:"text-xs text-text-muted italic",children:"No IDEs running"}):u.jsx("div",{className:"flex flex-col gap-1.5",children:t.map(P=>{var D;const N=(P.agentStreams||[]).some(k=>k.status==="generating"||k.status==="streaming")||((D=P.activeChat)==null?void 0:D.status)==="generating";return u.jsxs("div",{onClick:()=>a(`/ide/${P.id}`),className:`flex items-center gap-2 px-2.5 py-1.5 rounded-lg cursor-pointer transition-[background] duration-150 ${N?"bg-orange-500/[0.04] border border-orange-500/10":"bg-bg-glass border border-transparent"}`,children:[u.jsx("span",{children:s(P.type)}),u.jsx("span",{className:"text-xs text-text-primary font-medium",children:Ir(P.type)}),u.jsx("span",{className:"text-[10px] text-text-muted overflow-hidden text-ellipsis whitespace-nowrap",children:P.workspace||""}),N&&u.jsx("span",{className:"text-[10px] text-orange-400 font-semibold ml-auto",children:"⚡ Working"}),u.jsx("span",{className:`${N?"ml-1.5":"ml-auto"} w-1.5 h-1.5 rounded-full`,style:{background:N?"#fb923c":"#22c55e",boxShadow:N?"0 0 8px rgba(249,115,22,0.4)":"none",animation:N?"pulse-dot 1.5s infinite":"none"}})]},P.id)})})]}),u.jsxs("div",{className:"px-5 py-4 rounded-xl bg-bg-secondary border border-border-subtle",children:[u.jsxs("div",{className:"flex justify-between items-center mb-2.5",children:[u.jsx("span",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider",children:"CLIs"}),u.jsx("button",{onClick:()=>l("clis"),className:"machine-btn text-[10px]",children:"View All →"})]}),r.length===0?u.jsx("div",{className:"text-xs text-text-muted italic",children:"No CLIs running"}):u.jsx("div",{className:"flex flex-col gap-1.5",children:r.map(P=>u.jsxs("div",{className:"flex items-center gap-2 px-2.5 py-1.5 rounded-lg bg-bg-glass",children:[u.jsx("span",{children:s(P.type)}),u.jsx("span",{className:"text-xs text-text-primary font-medium",children:P.cliName}),u.jsx("span",{className:"text-[10px] text-text-muted overflow-hidden text-ellipsis whitespace-nowrap",children:P.workspace.split("/").pop()}),u.jsx("span",{className:"ml-auto w-1.5 h-1.5 rounded-full",style:{background:P.status==="stopped"?"#ef4444":"#22c55e"}})]},P.id))})]})]}),e.detectedIdes.length>0&&u.jsxs("div",{className:"mt-4 px-4.5 py-3.5 rounded-xl bg-bg-secondary border border-border-subtle",children:[u.jsx("div",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider mb-2",children:"Detected on this machine"}),u.jsx("div",{className:"flex flex-wrap gap-1.5",children:e.detectedIdes.map(P=>u.jsxs("div",{className:`px-2.5 py-1 rounded-md text-[11px] flex items-center gap-1 ${P.running?"bg-green-500/[0.06] border border-green-500/[0.12] text-green-300":"bg-bg-glass border border-border-subtle text-text-muted"}`,children:[u.jsx("span",{children:s(P.type)}),P.name||P.type,u.jsx("span",{className:"w-1 h-1 rounded-full",style:{background:P.running?"#22c55e":"#475569"}})]},P.type))})]})]})}function cI({machine:e,machineId:t,managedIdes:r,getIcon:n,actions:i,sendDaemonCommand:s}){const o=En(),{launchingIde:l,handleLaunchIde:a,handleRestartIde:c,handleStopIde:d,handleDetectIdes:h}=i,[f,p]=x.useState({}),[m,_]=x.useState(null),b=e.detectedIdes||[];return x.useEffect(()=>{if(!t)return;(async()=>{try{const v=await s(t,"get_ide_extensions",{}),y=(v==null?void 0:v.result)||v;y!=null&&y.success&&(y!=null&&y.ides)&&p(y.ides)}catch{}})()},[t,s]),u.jsxs("div",{children:[u.jsxs("div",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider mb-2.5",children:["Running (",r.length,")"]}),r.length===0?u.jsx("div",{className:"py-10 px-5 text-center rounded-xl bg-bg-secondary border border-dashed border-border-subtle text-text-muted text-[13px] mb-5",children:"No IDEs currently running. Launch one below."}):u.jsx("div",{className:"flex flex-col gap-2.5 mb-5",children:r.map(g=>u.jsxs("div",{className:"px-4.5 py-3.5 rounded-xl bg-bg-secondary border border-border-subtle",children:[u.jsxs("div",{className:"flex justify-between items-center mb-2.5",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("span",{className:"text-lg",children:n(g.type)}),u.jsx("span",{className:"font-semibold text-sm text-text-primary",children:Ir(g.type)}),g.version&&u.jsxs("span",{className:"text-[10px] text-text-muted",children:["v",g.version]}),u.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-green-500 shadow-[0_0_6px_rgba(34,197,94,0.3)]"})]}),u.jsxs("div",{className:"flex gap-1.5",children:[u.jsxs("button",{onClick:()=>o(`/ide/${g.id}`),className:"machine-btn flex items-center gap-1",children:[u.jsx(ul,{size:13})," Control"]}),u.jsx("button",{onClick:()=>c(g),className:"machine-btn text-amber-500 border-amber-500/30",children:"↻ Restart"}),u.jsx("button",{onClick:()=>d(g),className:"machine-btn text-red-400 border-red-500/30",children:"■ Stop"})]})]}),u.jsxs("div",{className:"text-xs text-text-secondary mb-2",children:[u.jsx("span",{className:"text-text-muted",children:"Workspace:"})," ",g.workspace||"—"]}),g.aiAgents.length>0&&u.jsx("div",{className:"flex gap-1 mb-2 flex-wrap",children:g.aiAgents.map(v=>u.jsxs("span",{className:`px-2 py-0.5 rounded-md text-[10px] ${v.status==="generating"||v.status==="streaming"?"bg-orange-500/[0.08] text-orange-400":"bg-indigo-500/[0.06] text-indigo-400"}`,children:[v.name," · ",v.status]},v.id))}),(f[g.type]||[]).length>0&&u.jsxs("div",{className:"mt-2 pt-2 border-t border-border-subtle",children:[u.jsx("div",{className:"text-[10px] text-text-muted font-semibold uppercase tracking-wider mb-1.5",children:"Extensions"}),u.jsx("div",{className:"flex flex-wrap gap-2",children:(f[g.type]||[]).map(v=>u.jsxs("button",{disabled:m===`${g.type}.${v.type}`,onClick:async()=>{const y=`${g.type}.${v.type}`;_(y);try{await s(t,"set_ide_extension",{ideType:g.type,extensionType:v.type,enabled:!v.enabled}),p(S=>({...S,[g.type]:(S[g.type]||[]).map(R=>R.type===v.type?{...R,enabled:!R.enabled}:R)}))}catch(S){console.error("Extension toggle failed:",S)}finally{_(null)}},className:`flex items-center gap-1.5 px-2.5 py-1 rounded-lg text-[11px] font-medium border transition-colors duration-150 cursor-pointer ${v.enabled?"bg-violet-500/[0.08] border-violet-500/20 text-violet-400":"bg-bg-glass border-border-subtle text-text-muted"}`,children:[u.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${v.enabled?"bg-violet-400 shadow-[0_0_4px_rgba(139,92,246,0.4)]":"bg-zinc-600"}`}),v.name,u.jsx("span",{className:"text-[9px] font-normal",children:v.enabled?"ON":"OFF"})]},v.type))})]})]},g.id))}),u.jsxs("div",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider mb-1",children:["Available to Launch (",b.length,")"]}),u.jsxs("p",{className:"text-[10px] text-text-muted m-0 mb-2.5",children:[e.defaultWorkspacePath?`Opens in default workspace: ${e.defaultWorkspacePath.split("/").filter(Boolean).pop()||e.defaultWorkspacePath}`:"No default workspace — IDE opens without a project folder from ADHDev (set one on Overview)."," ","Multi-window supported — running IDEs can be launched again as a new window."]}),u.jsxs("div",{className:"flex flex-wrap gap-2",children:[b.map(g=>{const v=g.running||r.some(y=>(y.type||"").toLowerCase()===(g.type||"").toLowerCase());return u.jsxs("button",{onClick:()=>a(g.type||g.id||""),disabled:!!l,className:`machine-btn-primary flex items-center gap-1.5 ${v?"!border-green-500/30":""}`,style:{opacity:l&&l!==g.type?.4:1},children:[u.jsx("span",{children:n(g.type)}),v&&u.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-green-500 shadow-[0_0_4px_rgba(34,197,94,0.4)]"}),l===g.type?"⏳ Launching...":`▶ ${g.name||Ir(g.type)}`,v&&u.jsx("span",{className:"text-[9px] text-green-400 font-normal",children:"+ window"})]},g.type)}),b.length===0&&u.jsxs("div",{className:"text-xs text-text-muted italic",children:["No IDEs detected.",u.jsxs("button",{onClick:h,className:"machine-btn ml-2 flex items-center gap-1",children:[u.jsx(AP,{size:12})," Scan"]})]})]})]})}function U_({category:e,machine:t,providers:r,managedEntries:n,getIcon:i,actions:s}){const o=En(),{handleLaunchCli:l,handleStopCli:a,runLaunchCliCore:c,handleLoadRecentWorkspaces:d,loadingWorkspaces:h,recentWorkspaces:f,cliHistory:p,loadingHistory:m,loadCliHistory:_}=s,b=e==="cli",g=b?"border-violet-500/[0.12]":"border-emerald-500/[0.12]",v=b?"CLI":"ACP Agent",y=r.filter(M=>M.category===e),[S,R]=x.useState(""),[E,P]=x.useState(""),[N,D]=x.useState(""),[k,B]=x.useState("");x.useEffect(()=>{!S&&y.length>0&&R(y[0].type)},[S,y.length]),x.useEffect(()=>{t.defaultWorkspacePath&&!E&&P(t.defaultWorkspacePath)},[t.defaultWorkspacePath]);const j=M=>b?M.cliName:M.acpName;return u.jsxs("div",{children:[u.jsxs("div",{className:`px-5 py-4 rounded-xl mb-5 bg-bg-secondary border ${g}`,children:[u.jsxs("div",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider mb-1",children:["Launch New ",v]}),u.jsx("p",{className:"text-[10px] text-text-muted m-0 mb-2.5",children:"Same workspaces and default as Overview — use path, Default, or Home explicitly."}),u.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[u.jsx("select",{value:S,onChange:M=>R(M.target.value),className:"machine-input",children:y.length>0?y.map(M=>u.jsxs("option",{value:M.type,children:[M.icon," ",M.displayName]},M.type)):u.jsxs("option",{value:"",disabled:!0,children:["No ",e.toUpperCase()," providers available"]})}),u.jsx("input",{type:"text",placeholder:"Working directory (or use Launch picker / Default / Home)",value:E,onChange:M=>P(M.target.value),className:"machine-input flex-1 min-w-[200px]"}),!b&&u.jsx("input",{type:"text",placeholder:"Model (default)",value:k,onChange:M=>B(M.target.value),className:"machine-input min-w-[120px]"}),u.jsx("input",{type:"text",placeholder:"Args (optional)",value:N,onChange:M=>D(M.target.value),className:"machine-input min-w-[120px]"}),u.jsx("button",{onClick:()=>l(S,E,N||void 0,b?void 0:k||void 0),className:"machine-btn-primary",children:"▶ Launch"}),u.jsx("button",{type:"button",disabled:!(t!=null&&t.defaultWorkspacePath),title:t!=null&&t.defaultWorkspacePath?void 0:"Set a default workspace in Overview first",onClick:()=>void c({cliType:S,useDefaultWorkspace:!0,argsStr:N||void 0,model:b?void 0:k||void 0}),className:"machine-btn text-[10px]",children:"Default"}),u.jsx("button",{type:"button",onClick:()=>void c({cliType:S,useHome:!0,argsStr:N||void 0,model:b?void 0:k||void 0}),className:"machine-btn text-[10px]",children:"Home"})]})]}),u.jsxs("div",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider mb-2.5",children:["Running (",n.length,")"]}),n.length===0?u.jsxs("div",{className:"py-7.5 px-5 text-center rounded-xl bg-bg-secondary border border-dashed border-border-subtle text-text-muted text-[13px] mb-5",children:["No ",b?"CLIs":"ACP agents"," running"]}):u.jsx("div",{className:"flex flex-col gap-2 mb-5",children:n.map(M=>{const C=b?null:M;return u.jsxs("div",{className:"px-4 py-3 rounded-[10px] bg-bg-secondary border border-border-subtle flex items-center justify-between",children:[u.jsxs("div",{className:"flex items-center gap-2.5",children:[u.jsx("span",{className:"text-lg",children:i(M.type)}),u.jsxs("div",{children:[u.jsx("div",{className:"font-semibold text-[13px] text-text-primary",children:j(M)}),u.jsxs("div",{className:"text-[11px] text-text-muted flex gap-2",children:[u.jsx("span",{children:M.workspace}),(C==null?void 0:C.currentModel)&&u.jsxs("span",{className:"text-cyan-500",children:["🤖 ",C.currentModel]}),(C==null?void 0:C.currentPlan)&&u.jsxs("span",{className:"text-amber-500",children:["📋 ",C.currentPlan]})]})]})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("span",{className:`px-2 py-0.5 rounded-md text-[10px] font-semibold ${M.status==="stopped"?"bg-red-500/[0.08] text-red-500":M.status==="generating"?"bg-orange-500/[0.08] text-orange-400":"bg-green-500/[0.08] text-green-500"}`,children:M.status}),!b&&u.jsx("button",{onClick:()=>o(`/ide/${M.id}`),className:"machine-btn",title:"View chat",children:u.jsx(Ya,{size:14})}),M.status==="stopped"?u.jsx("button",{onClick:()=>l(M.type,M.workspace),className:"machine-btn text-green-500 border-green-500/30",children:"▶"}):u.jsx("button",{onClick:()=>a(M.type,M.workspace,M.id),className:"machine-btn text-red-500 border-red-500/30",children:"■"})]})]},M.id)})}),u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"flex items-center gap-2 mb-2.5",children:[u.jsx("span",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider",children:"History"}),u.jsx("button",{onClick:_,disabled:m,className:"machine-btn",children:m?"⏳":"↻ Load"})]}),(()=>{const M=new Set(y.map(A=>A.type)),C=p.filter(A=>M.has(A.cliType));return C.length>0?u.jsx("div",{className:"flex flex-col gap-1 max-h-[200px] overflow-y-auto",children:C.map((A,O)=>{var U,L;return u.jsxs("div",{onClick:()=>{R(A.cliType),P(A.dir),D((A.cliArgs||[]).join(" "))},className:"flex justify-between items-center px-2.5 py-1.5 rounded-md cursor-pointer bg-bg-glass border border-border-subtle text-xs transition-[background] duration-150",onMouseEnter:$=>$.currentTarget.style.background="var(--bg-glass-hover)",onMouseLeave:$=>$.currentTarget.style.background="var(--bg-glass)",children:[u.jsxs("div",{className:"flex gap-1.5 items-center text-text-secondary",children:[u.jsx("span",{children:i(A.cliType)}),u.jsx("span",{children:((U=A.dir)==null?void 0:U.split("/").filter(Boolean).pop())||"root"}),((L=A.cliArgs)==null?void 0:L.length)>0&&u.jsx("span",{className:"text-text-muted text-[10px]",children:A.cliArgs.join(" ")})]}),u.jsx("span",{className:"text-text-muted text-[10px]",children:A.timestamp?new Date(A.timestamp).toLocaleDateString():""})]},O)})}):u.jsxs("div",{className:"text-[11px] text-text-muted italic mb-2",children:["No ",b?"CLI":"ACP"," launch history yet."]})})()]}),u.jsxs("div",{className:"mt-5",children:[u.jsxs("div",{className:"flex items-center gap-2 mb-2.5",children:[u.jsx("span",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider",children:"Recent Workspaces"}),u.jsx("button",{onClick:d,disabled:h,className:"machine-btn",children:h?"⏳":"↻ Load"})]}),f.length>0&&u.jsx("div",{className:"flex flex-wrap gap-1.5",children:f.map((M,C)=>u.jsx("button",{onClick:()=>P(M),className:"machine-btn max-w-[200px] overflow-hidden text-ellipsis whitespace-nowrap",title:M,children:u.jsxs("span",{className:"flex items-center gap-1",children:[u.jsx(Xa,{size:12})," ",M.split("/").filter(Boolean).pop()||M]})},C))})]})]})}function uI({machineId:e,providers:t,sendDaemonCommand:r}){const[n,i]=x.useState([]),[s,o]=x.useState(!1),[l,a]=x.useState(null),[c,d]=x.useState("all"),h=x.useCallback(async()=>{var p;if(e){o(!0);try{const m=await r(e,"get_provider_settings",{}),_=(m==null?void 0:m.result)||m;if(m!=null&&m.success&&(_!=null&&_.settings)){const b=[];for(const[g,v]of Object.entries(_.settings)){const y=t.find(S=>S.type===g);b.push({type:g,displayName:(y==null?void 0:y.displayName)||g,icon:(y==null?void 0:y.icon)||"",category:(y==null?void 0:y.category)||"unknown",schema:v,values:((p=_.values)==null?void 0:p[g])||{}})}b.sort((g,v)=>g.category.localeCompare(v.category)||g.displayName.localeCompare(v.displayName)),i(b)}}catch{}o(!1)}},[e,t,r]);x.useEffect(()=>{n.length===0&&h()},[]);const f=async(p,m,_)=>{a(`${p}.${m}`),i(b=>b.map(g=>g.type===p?{...g,values:{...g.values,[m]:_}}:g));try{const b=await r(e,"set_provider_setting",{providerType:p,key:m,value:_});b!=null&&b.success||h()}catch{h()}a(null)};return u.jsxs("div",{children:[u.jsxs("div",{className:"flex justify-between items-center mb-4",children:[u.jsxs("div",{className:"flex gap-1 items-center",children:[u.jsx("span",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider mr-2",children:"Filter"}),["all","acp","cli","ide","extension"].map(p=>u.jsx("button",{onClick:()=>d(p),className:`machine-btn text-[10px] px-2 py-0.5 ${c===p?"bg-violet-500/15 border-violet-500/40 text-violet-400":""}`,children:p.toUpperCase()},p))]}),u.jsx("button",{onClick:h,disabled:s,className:"machine-btn",children:s?"⏳ Loading...":"↻ Refresh"})]}),c!=="all"&&n.filter(p=>p.category===c).length>1&&(()=>{const p=n.filter(g=>g.category===c),m=new Map;for(const g of p)for(const v of g.schema){if(v.type!=="boolean")continue;const y=m.get(v.key),S=!!(g.values[v.key]??v.default);y?(y.onCount+=S?1:0,y.total+=1):m.set(v.key,{label:v.label||v.key,onCount:S?1:0,total:1})}const _=[...m.entries()].filter(([,g])=>g.total===p.length);if(_.length===0)return null;const b=async(g,v)=>{for(const y of p)await f(y.type,g,v)};return u.jsxs("div",{className:"px-4 py-3 rounded-xl bg-violet-500/[0.04] border border-violet-500/10 mb-4",children:[u.jsxs("div",{className:"text-[10px] text-violet-400 font-semibold uppercase tracking-wider mb-2",children:["Bulk — Apply to all ",c.toUpperCase()," providers (",p.length,")"]}),u.jsx("div",{className:"flex flex-wrap gap-2",children:_.map(([g,v])=>{const y=v.onCount===v.total,S=v.onCount===0;return u.jsxs("div",{className:"flex items-center gap-1.5 text-[11px]",children:[u.jsx("span",{className:"text-text-secondary font-medium",children:v.label}),u.jsxs("span",{className:"text-[9px] text-text-muted",children:["(",v.onCount,"/",v.total,")"]}),u.jsx("button",{onClick:()=>void b(g,!0),disabled:y,className:`machine-btn text-[9px] px-1.5 py-px ${y?"opacity-40":"text-green-400 border-green-500/30"}`,children:"All ON"}),u.jsx("button",{onClick:()=>void b(g,!1),disabled:S,className:`machine-btn text-[9px] px-1.5 py-px ${S?"opacity-40":"text-red-400 border-red-500/30"}`,children:"All OFF"})]},g)})})]})})(),s&&n.length===0?u.jsx("div",{className:"p-10 text-center text-text-muted",children:"Loading provider settings..."}):u.jsx("div",{className:"flex flex-col gap-2",children:n.filter(p=>c==="all"||p.category===c).map(p=>u.jsxs("div",{className:"px-4.5 py-3.5 rounded-xl bg-bg-secondary border border-border-subtle",children:[u.jsxs("div",{className:"flex items-center gap-2 mb-2.5",children:[u.jsx("span",{className:"text-lg",children:p.icon}),u.jsx("span",{className:"font-semibold text-[13px] text-text-primary",children:p.displayName}),u.jsx("span",{className:"px-1.5 py-px rounded text-[9px] font-semibold",style:{background:p.category==="acp"?"rgba(139,92,246,0.08)":p.category==="cli"?"rgba(59,130,246,0.08)":p.category==="ide"?"rgba(34,197,94,0.08)":"rgba(245,158,11,0.08)",color:p.category==="acp"?"#a78bfa":p.category==="cli"?"#60a5fa":p.category==="ide"?"#86efac":"#fbbf24"},children:p.category})]}),u.jsx("div",{className:"flex flex-col gap-2",children:p.schema.map(m=>u.jsxs("div",{className:"flex items-center justify-between gap-3",children:[u.jsxs("div",{className:"flex-1 min-w-0",children:[u.jsxs("div",{className:"text-xs font-medium text-text-primary",children:[m.label||m.key,l===`${p.type}.${m.key}`&&u.jsx("span",{className:"ml-1.5 text-[9px] text-violet-500",children:"saving..."})]}),m.description&&u.jsx("div",{className:"text-[10px] text-text-muted mt-px",children:m.description})]}),u.jsx("div",{className:"shrink-0",children:m.type==="boolean"?u.jsx("button",{onClick:()=>f(p.type,m.key,!(p.values[m.key]??m.default)),className:"w-10 h-[22px] rounded-[11px] border-none relative cursor-pointer transition-colors duration-200",style:{background:p.values[m.key]??m.default?"#8b5cf6":"var(--border-subtle)"},children:u.jsx("div",{className:"w-4 h-4 rounded-full bg-white absolute top-[3px] transition-[left] duration-200 shadow-[0_1px_3px_rgba(0,0,0,0.3)]",style:{left:p.values[m.key]??m.default?21:3}})}):m.type==="number"?u.jsx("input",{type:"number",value:p.values[m.key]??m.default??0,min:m.min,max:m.max,onChange:_=>{const b=parseInt(_.target.value)||0;m.min!==void 0&&b<m.min||m.max!==void 0&&b>m.max||f(p.type,m.key,b)},className:"machine-input w-20 text-center text-[11px]"}):m.type==="select"&&m.options?u.jsx("select",{value:p.values[m.key]??m.default??"",onChange:_=>f(p.type,m.key,_.target.value),className:"machine-input text-[11px]",children:m.options.map(_=>u.jsx("option",{value:_,children:_},_))}):u.jsx("input",{type:"text",value:p.values[m.key]??m.default??"",onBlur:_=>f(p.type,m.key,_.target.value),className:"machine-input w-[120px] text-[11px]"})})]},m.key))})]},p.type))})]})}function hI({machineId:e,sendDaemonCommand:t}){const[r,n]=x.useState([]),[i,s]=x.useState(0),[o,l]=x.useState(!0),[a,c]=x.useState("debug"),d=x.useRef(null),h=x.useRef(!1);return x.useEffect(()=>{if(!e||!o)return;const f=async()=>{try{const m=await t(e,"get_logs",{count:200,minLevel:a,since:i}),_=(m==null?void 0:m.result)||m;if(m!=null&&m.success&&Array.isArray(_==null?void 0:_.logs)&&_.logs.length>0){n(g=>[...g,..._.logs.map(y=>({timestamp:y.ts,level:y.level,message:`[${y.category}] ${y.message}`}))].slice(-300));const b=Math.max(..._.logs.map(g=>g.ts));s(b)}}catch{}};f();const p=setInterval(f,3e3);return()=>clearInterval(p)},[e,o,i,a,t]),x.useEffect(()=>{if(o&&r.length>0){const f=h.current?"smooth":"instant";setTimeout(()=>{var p;(p=d.current)==null||p.scrollIntoView({behavior:f}),h.current=!0},50)}},[r.length,o]),u.jsxs("div",{children:[u.jsxs("div",{className:"flex justify-between items-center mb-3",children:[u.jsxs("div",{className:"flex gap-1 items-center",children:[u.jsx("span",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider mr-2",children:"Level"}),["debug","info","warn","error"].map(f=>u.jsx("button",{onClick:()=>{c(f),n([]),s(0)},className:`machine-btn text-[10px] px-2 py-0.5 ${a===f?"bg-violet-500/15 border-violet-500/40 text-violet-400":""}`,children:f.toUpperCase()},f))]}),u.jsxs("div",{className:"flex gap-1.5 items-center",children:[u.jsxs("span",{className:"text-[10px] text-text-muted",children:[r.length," entries"]}),u.jsx("button",{onClick:()=>l(!o),className:`machine-btn ${o?"text-green-500 border-green-500/30":""}`,children:o?"⏸ Pause":"▶ Resume"}),u.jsx("button",{onClick:()=>{n([]),s(0)},className:"machine-btn",children:"Clear"})]})]}),u.jsxs("div",{className:"bg-bg-secondary border border-border-subtle rounded-xl p-3 min-h-[200px] max-h-[500px] overflow-y-auto font-mono text-[11px] leading-relaxed",children:[r.length===0&&u.jsx("div",{className:"p-10 text-center text-text-muted",children:"Loading daemon logs..."}),r.map((f,p)=>u.jsxs("div",{className:"flex gap-2 py-px",style:{color:f.level==="error"?"#ef4444":f.level==="warn"?"#f59e0b":f.level==="debug"?"#64748b":"#94a3b8"},children:[u.jsx("span",{className:"text-text-muted min-w-[75px] shrink-0",children:new Date(f.timestamp).toLocaleTimeString()}),u.jsx("span",{className:"font-semibold min-w-[32px] shrink-0 text-[9px]",style:{color:f.level==="error"?"#ef4444":f.level==="warn"?"#f59e0b":f.level==="debug"?"#475569":"#8b5cf6"},children:f.level==="error"?"ERR":f.level==="warn"?"WRN":f.level==="debug"?"DBG":"INF"}),u.jsx("span",{children:f.message})]},p)),u.jsx("div",{ref:d})]})]})}function dI({machine:e,launchPick:t,actions:r}){const{runLaunchCliCore:n,setLaunchPick:i}=r;return u.jsx("div",{className:"fixed inset-0 z-[100] flex items-center justify-center p-4 bg-black/55 backdrop-blur-[2px]",role:"dialog","aria-modal":"true","aria-labelledby":"launch-pick-title",children:u.jsxs("div",{className:"w-full max-w-md rounded-xl border border-border-subtle bg-bg-secondary shadow-xl p-5",children:[u.jsx("h2",{id:"launch-pick-title",className:"text-sm font-semibold text-text-primary m-0 mb-1",children:"Where should this run?"}),u.jsx("p",{className:"text-[11px] text-text-muted m-0 mb-4",children:"Nothing is assumed. Pick a saved workspace, your default workspace, or home — or cancel and type a path."}),u.jsx("div",{className:"flex flex-col gap-2 mb-4 max-h-48 overflow-y-auto",children:(e.workspaces||[]).length===0?u.jsx("span",{className:"text-[11px] text-text-muted",children:"No saved workspaces yet. Add one in Overview or type a path above."}):(e.workspaces||[]).map(s=>u.jsxs("button",{type:"button",className:"text-left text-xs px-3 py-2 rounded-lg border border-border-subtle bg-bg-primary hover:bg-violet-500/[0.08] transition-colors",onClick:()=>{i(null),n({cliType:t.cliType,workspaceId:s.id,argsStr:t.argsStr,model:t.model})},children:[u.jsx("span",{className:"font-medium text-text-primary block truncate",children:s.label||s.path}),u.jsx("span",{className:"text-[10px] text-text-muted font-mono truncate block",children:s.path})]},s.id))}),u.jsxs("div",{className:"flex flex-wrap gap-2",children:[u.jsx("button",{type:"button",className:"machine-btn text-[11px] flex-1 min-w-[120px]",disabled:!e.defaultWorkspacePath,onClick:()=>{i(null),n({cliType:t.cliType,useDefaultWorkspace:!0,argsStr:t.argsStr,model:t.model})},children:"Default workspace"}),u.jsx("button",{type:"button",className:"machine-btn text-[11px] flex-1 min-w-[120px]",onClick:()=>{i(null),n({cliType:t.cliType,useHome:!0,argsStr:t.argsStr,model:t.model})},children:"Home directory"}),u.jsx("button",{type:"button",className:"machine-btn text-[11px] flex-1 min-w-[80px]",onClick:()=>i(null),children:"Cancel"})]})]})})}function fI(){var S,R,E,P,N,D,k,B,j,M;const{id:e}=by(),t=En(),{sendCommand:r}=ui(),n=Lc(),i=n.ides||[],s=n.initialLoaded??!0,[o,l]=x.useState("overview"),a=x.useRef(null),c=oI({machineId:e,sendDaemonCommand:r,logsEndRef:a}),d=i.find(C=>C.id===e&&C.daemonMode),h=((d==null?void 0:d.availableProviders)||[]).map(C=>({type:C.type,displayName:C.displayName,icon:C.icon,category:C.category})),f={};for(const C of h)f[C.type]=C.icon;const p=C=>f[C]||"",m=d?{id:d.id,hostname:((S=d.machine)==null?void 0:S.hostname)||d.id,platform:((R=d.machine)==null?void 0:R.platform)||"unknown",arch:((E=d.machine)==null?void 0:E.arch)||"",cpus:((P=d.machine)==null?void 0:P.cpus)||0,totalMem:((N=d.machine)==null?void 0:N.totalMem)||0,freeMem:((D=d.machine)==null?void 0:D.freeMem)||0,availableMem:(k=d.machine)==null?void 0:k.availableMem,loadavg:((B=d.machine)==null?void 0:B.loadavg)||[],uptime:((j=d.machine)==null?void 0:j.uptime)||0,release:((M=d.machine)==null?void 0:M.release)||"",cdpConnected:!!(d.ides||[]).some(C=>C.cdpConnected),machineNickname:d.machineNickname||null,p2p:d.p2p||{available:!1,state:"unavailable",peers:0,screenshotActive:!1},detectedIdes:d.detectedIdes||[],managedIdeIds:d.managedIdeIds||[],managedCliIds:d.managedCliIds||[],workspaces:d.workspaces||[],defaultWorkspaceId:d.defaultWorkspaceId??d.activeWorkspaceId??null,defaultWorkspacePath:d.defaultWorkspacePath??d.activeWorkspacePath??null,workspaceActivity:d.workspaceActivity||[]}:null,_=i.filter(C=>C.daemonId===e&&!C.daemonMode).filter(C=>!R_(C)&&!M_(C)).map(C=>({id:C.id,type:C.type,version:C.version||"",instanceId:C.instanceId||"",status:C.status,workspace:C.workspace||null,terminals:C.terminals||0,aiAgents:yL(C.aiAgents||C.agents||[]),activeChat:C.activeChat||null,chats:C.chats||[],agentStreams:C.agentStreams||[],cdpConnected:C.cdpConnected||!1,daemonId:e})),b=i.filter(C=>C.daemonId===e&&R_(C)).map(C=>({id:C.id,type:C.type,cliName:C.cliName||C.type,status:C.status,workspace:C.workspace||"",activeChat:C.activeChat||null,daemonId:e})),g=i.filter(C=>C.daemonId===e&&M_(C)).map(C=>({id:C.id,type:C.type,acpName:C.cliName||C.type,status:C.status,workspace:C.workspace||"",activeChat:C.activeChat||null,currentModel:C.currentModel,currentPlan:C.currentPlan,daemonId:e}));if(!m)return s?u.jsxs("div",{className:"p-10 text-center text-text-muted",children:[u.jsx("h2",{className:"text-text-primary",children:"Machine not found"}),u.jsx("p",{className:"mt-3",children:"The machine may be offline or not yet connected."}),u.jsx("button",{onClick:()=>t("/machines"),className:"machine-btn-back",children:"← Back to Burrows"})]}):u.jsx("div",{className:"p-10 text-center text-text-muted",children:u.jsx("p",{children:"⏳ Loading machine..."})});const v=m.machineNickname||m.hostname,y=[{id:"overview",label:u.jsxs("span",{className:"flex items-center gap-1.5",children:[u.jsx(zP,{size:14})," Overview"]})},{id:"ides",label:u.jsxs("span",{className:"flex items-center gap-1.5",children:[u.jsx(ul,{size:14})," IDEs"]}),count:_.length},{id:"clis",label:u.jsxs("span",{className:"flex items-center gap-1.5",children:[u.jsx(B0,{size:14})," CLIs"]}),count:b.length},{id:"acps",label:u.jsxs("span",{className:"flex items-center gap-1.5",children:[u.jsx(z0,{size:14})," ACP Agents"]}),count:g.length},{id:"providers",label:u.jsxs("span",{className:"flex items-center gap-1.5",children:[u.jsx(D0,{size:14})," Providers"]})},{id:"logs",label:u.jsxs("span",{className:"flex items-center gap-1.5",children:[u.jsx(IP,{size:14})," Logs"]})}];return u.jsxs("div",{className:"flex flex-col h-full",children:[u.jsxs("div",{className:"dashboard-header !flex-col !items-stretch",children:[u.jsx("div",{className:"flex items-center justify-between w-full",children:u.jsxs("div",{className:"flex items-center gap-2 md:gap-3.5 w-full min-w-0",children:[u.jsx("button",{onClick:()=>t("/machines"),className:"machine-btn-back flex shrink-0",children:"←"}),u.jsxs("div",{className:"min-w-0",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[c.editingNickname?u.jsxs("div",{className:"flex gap-1.5 items-center",children:[u.jsx("input",{autoFocus:!0,value:c.nicknameInput,onChange:C=>c.setNicknameInput(C.target.value),onKeyDown:C=>{C.key==="Enter"&&c.handleSaveNickname(),C.key==="Escape"&&c.setEditingNickname(!1)},placeholder:"Machine nickname...",className:"px-2.5 py-1 rounded-md border border-violet-500/30 bg-bg-secondary text-text-primary text-sm font-semibold w-[140px] md:w-[200px]"}),u.jsx("button",{onClick:c.handleSaveNickname,className:"machine-btn text-green-500 border-green-500/30 shrink-0",children:"✓"}),u.jsx("button",{onClick:()=>c.setEditingNickname(!1),className:"machine-btn shrink-0",children:"✕"})]}):u.jsx("h1",{className:"header-title cursor-pointer truncate",onClick:()=>{c.setEditingNickname(!0),c.setNicknameInput(m.machineNickname||"")},title:"Click to set nickname",children:v}),u.jsx("span",{className:"status-dot-md online shrink-0"})]}),u.jsxs("div",{className:"header-subtitle mt-1 flex-wrap gap-1 md:gap-2 items-center display-none-mobile",children:[u.jsxs("span",{children:[m.platform," · ",m.arch," · ",m.cpus," cores"]}),m.p2p.available&&u.jsxs("span",{className:"px-1.5 py-px rounded text-[9px] font-semibold",style:{background:m.p2p.state==="connected"?"rgba(34,197,94,0.08)":"rgba(234,179,8,0.08)",color:m.p2p.state==="connected"?"#22c55e":"#eab308"},children:["P2P ",m.p2p.state==="connected"?`● ${m.p2p.peers}`:"○"]}),m.cdpConnected&&u.jsx("span",{className:"px-1.5 py-px rounded text-[9px] font-semibold bg-green-500/[0.08] text-green-500 shrink-0",children:"CDP ●"}),m.machineNickname&&u.jsxs("span",{className:"text-text-muted opacity-80 shrink-0",children:["(",m.hostname,")"]})]})]})]})}),u.jsx("div",{className:"machine-tabs w-full overflow-x-auto overflow-y-hidden pb-1 -mb-1 mt-2",children:y.map(C=>u.jsxs("button",{onClick:()=>l(C.id),className:`machine-tab shrink-0${o===C.id?" active":""}`,children:[C.label,C.count!==void 0&&u.jsx("span",{className:"tab-count",children:C.count})]},C.id))})]}),u.jsxs("div",{className:"page-content",children:[o==="overview"&&u.jsx(aI,{machine:m,managedIdes:_,managedClis:b,managedAcps:g,providers:h,getIcon:p,actions:c,setActiveTab:C=>l(C)}),o==="ides"&&u.jsx(cI,{machine:m,machineId:e,managedIdes:_,getIcon:p,actions:c,sendDaemonCommand:r}),o==="clis"&&u.jsx(U_,{category:"cli",machine:m,providers:h,managedEntries:b,getIcon:p,actions:c}),o==="acps"&&u.jsx(U_,{category:"acp",machine:m,providers:h,managedEntries:g,getIcon:p,actions:c}),o==="providers"&&u.jsx(uI,{machineId:e,providers:h,sendDaemonCommand:r}),o==="logs"&&u.jsx(hI,{machineId:e,sendDaemonCommand:r})]}),c.launchPick&&m&&u.jsx(dI,{machine:m,launchPick:c.launchPick,actions:c})]})}function pI(){if(typeof window>"u")return"ws://localhost:3847/ws";const t=`${window.location.protocol==="https:"?"wss":"ws"}://${window.location.host}/ws`,n=new URLSearchParams(window.location.search).get("token");return n?`${t}?token=${encodeURIComponent(n)}`:t}const K_=pI(),V_=3e3,mI=3e4;let mn=null,gI=0;const nc=new Map,zd=new Set;let vi=null;async function va(e,t,r){const n=mn;if(n&&n.readyState===WebSocket.OPEN){const s=`req_${++gI}_${Date.now()}`;return new Promise((o,l)=>{const a=setTimeout(()=>{nc.delete(s),l(new Error(`WS command timeout: ${t}`))},3e4);nc.set(s,{resolve:c=>{clearTimeout(a),o(c)},reject:c=>{clearTimeout(a),l(c)}}),n.send(JSON.stringify({type:"command",requestId:s,data:{type:t,payload:r||{},target:e}}))})}const i=await fetch("/api/v1/command",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:t,payload:r||{},target:e})});if(!i.ok)throw new Error(`HTTP ${i.status}`);return i.json()}class _I{constructor(t){Yt(this,"daemonId");Yt(this,"screenshotIdeType",null);this.daemonId=t}get hasCommandChannel(){return(mn==null?void 0:mn.readyState)===WebSocket.OPEN}get connectionState(){return(mn==null?void 0:mn.readyState)===WebSocket.OPEN?"connected":"disconnected"}async sendCommand(t,r){return va(this.daemonId,t,r)}async sendInput(t,r){const n=this.screenshotIdeType?`${this.daemonId}:ide:${this.screenshotIdeType}`:this.daemonId;return va(n,"cdp_remote_action",{action:t,params:r})}startScreenshots(t){this.screenshotIdeType=t||null,vi&&(clearInterval(vi),vi=null);const r=async()=>{if(this.hasCommandChannel)try{const n=this.screenshotIdeType?`${this.daemonId}:ide:${this.screenshotIdeType}`:this.daemonId,i=await va(n,"screenshot",{width:1280});if(i!=null&&i.success&&(i!=null&&i.base64)){const s=await fetch(`data:image/jpeg;base64,${i.base64}`).then(o=>o.blob());zd.forEach(o=>o(this.daemonId,s))}}catch{}};r(),vi=setInterval(r,2e3)}stopScreenshots(t){vi&&(clearInterval(vi),vi=null)}}let xi=null;function vI(e){(!xi||xi.daemonId!==e)&&(xi=new _I(e));const t=vr._originalGet||vr.get.bind(vr);vr._originalGet=t,vr.get=r=>r===e||r.startsWith("standalone")?xi:t(r),vr.getState=r=>(r===e||r.startsWith("standalone"))&&(xi==null?void 0:xi.connectionState)||"disconnected",vr.onScreenshot=(r,n)=>(zd.add(n),()=>{zd.delete(n)})}function xI({children:e}){const t=x.useRef(Im()),r=Im();t.current=r;const{setUserName:n}=Ko(),i=x.useRef(n);i.current=n;const[,s]=x.useState("disconnected"),o=x.useRef(null),l=x.useRef(),a=x.useRef(V_),c=x.useRef(!0);return x.useEffect(()=>{c.current=!0;function d(){var p,m;if(!c.current||((p=o.current)==null?void 0:p.readyState)===WebSocket.OPEN||((m=o.current)==null?void 0:m.readyState)===WebSocket.CONNECTING)return;s("connecting"),console.log(`[Standalone WS] Connecting to ${K_}...`);let f;try{f=new WebSocket(K_)}catch(_){console.error("[Standalone WS] Failed to create WebSocket:",_),h();return}o.current=f,f.onopen=()=>{if(!c.current){f.close();return}s("connected"),a.current=V_,console.log("[Standalone WS] Connected")},mn=f,f.onmessage=_=>{var b;try{const g=JSON.parse(_.data);if((g.type==="command_result"||g.type==="error")&&g.requestId){const v=nc.get(g.requestId);v&&(nc.delete(g.requestId),g.type==="error"?v.reject(new Error(((b=g.data)==null?void 0:b.message)||"Command failed")):v.resolve(g.data));return}if(g.type==="status"||g.type==="initial_state"){const v=g.data;if(!v)return;const{injectEntries:y,markLoaded:S}=t.current,R=v.id||"standalone";vI(R);const E=EL(v,{daemonId:R});E.length>0&&y(E),S(),v.userName&&i.current&&i.current(v.userName)}}catch(g){console.error("[Standalone WS] Parse error:",g)}},f.onclose=()=>{c.current&&(s("disconnected"),o.current=null,h())},f.onerror=_=>{console.warn("[Standalone WS] Error, will reconnect:",_)}}function h(){if(!c.current)return;clearTimeout(l.current);const f=a.current;console.log(`[Standalone WS] Reconnecting in ${f}ms...`),l.current=setTimeout(()=>{a.current=Math.min(a.current*1.5,mI),d()},f)}return d(),()=>{c.current=!1,clearTimeout(l.current),o.current&&(o.current.onclose=null,o.current.close(),o.current=null,mn=null)}},[]),u.jsx(u.Fragment,{children:e})}function yI({children:e}){return u.jsx(Rk,{children:u.jsx(xI,{children:e})})}const bI=[{id:"dashboard",path:"/dashboard",icon:u.jsx(MP,{}),label:"Dashboard"},{id:"machine",path:"/machines",icon:u.jsx(LP,{}),label:"Burrow"},{id:"settings",path:"/settings",icon:u.jsx(D0,{}),label:"Settings"}];function wI({children:e}){const t=En(),r=ol(),[n,i]=x.useState(!1),[s,o]=x.useState(()=>{try{return localStorage.getItem("sidebar-collapsed")==="1"}catch{return!1}}),l=d=>{t(d),i(!1)},a=()=>{o(d=>{const h=!d;try{localStorage.setItem("sidebar-collapsed",h?"1":"0")}catch{}return h})},c=d=>`nav-item${r.pathname.startsWith(d)?" active":""} cursor-pointer ${s?"justify-center py-2.5 px-0":""}`;return u.jsxs("div",{className:`app-layout${n?" mobile-menu-open":""}${s?" sidebar-collapsed":""}`,children:[u.jsxs("button",{type:"button",className:"mobile-menu-btn","aria-label":"Open menu",onClick:()=>i(!0),children:[u.jsx("span",{className:"mobile-menu-icon"}),u.jsx("span",{className:"mobile-menu-icon"}),u.jsx("span",{className:"mobile-menu-icon"})]}),n&&u.jsx("div",{className:"sidebar-overlay",role:"button",tabIndex:0,"aria-label":"Close menu",onClick:()=>i(!1),onKeyDown:d=>d.key==="Escape"&&i(!1)}),u.jsxs("aside",{className:`sidebar ${n?"sidebar-open":""}`,children:[u.jsxs("div",{className:"sidebar-header",children:[u.jsxs("div",{className:`sidebar-logo ${s?"justify-center gap-0":""}`,children:[u.jsx("img",{src:"/otter-logo.png",alt:"ADHDev",className:"w-7 h-7"}),!s&&u.jsx("span",{children:"ADHDev"})]}),u.jsx("button",{type:"button",className:"sidebar-close-btn","aria-label":"Close menu",onClick:()=>i(!1),children:"✕"})]}),u.jsx("nav",{className:"sidebar-nav",children:bI.map(d=>u.jsxs("div",{className:c(d.path),id:`nav-${d.id}`,onClick:()=>l(d.path),title:s?d.label:void 0,children:[u.jsx("span",{className:"nav-icon",children:d.icon}),!s&&d.label]},d.id))}),u.jsxs("div",{className:"border-t border-border-subtle pt-4 mt-2",children:[u.jsxs("div",{className:`nav-item cursor-pointer${r.pathname==="/about"?" active":""} ${s?"justify-center py-2.5 px-0":""}`,id:"nav-about",onClick:()=>t("/about"),title:s?"About":void 0,children:[u.jsx("span",{className:"nav-icon",children:u.jsx(jP,{})}),!s&&"About"]}),!s&&u.jsxs("div",{className:"px-3 py-2 text-xs text-text-muted",children:["Selfhost v","0.6.3"]}),u.jsxs("div",{className:`nav-item cursor-pointer ${s?"justify-center py-2.5 px-0":"mt-1"}`,onClick:a,title:s?"Expand sidebar":"Collapse sidebar",children:[u.jsx("span",{className:"nav-icon text-base",children:s?"›":"‹"}),!s&&u.jsx("span",{className:"text-xs",children:"Collapse"})]})]})]}),u.jsx("main",{className:"main-content relative",children:u.jsx("div",{className:"main-content-inner",children:e})})]})}const SI=[{icon:"🏠",title:"Local-first",desc:"Everything runs on your machine. No data leaves your network. Full privacy by design."},{icon:"💬",title:"Agent chat relay",desc:"Read and respond to AI conversations in real-time across all connected IDEs."},{icon:"📸",title:"Live screenshots",desc:"View your IDE screens directly in the browser via local WebSocket streaming."},{icon:"🎛️",title:"Remote control",desc:"Click, type, and interact with your IDE from the dashboard — no window switching."},{icon:"🔌",title:"Multi-IDE support",desc:"Monitor and control multiple IDEs simultaneously — VS Code, Cursor, Windsurf, and more."},{icon:"⚡",title:"Extension agents",desc:"Manage extension-based agents like Cline and Roo Code alongside native IDE agents."}],kI=[{icon:"🌍",title:"Access from anywhere",desc:"Control your agents from any device, any network. No VPN or port forwarding needed."},{icon:"🔗",title:"WebRTC P2P streaming",desc:"End-to-end encrypted peer-to-peer connection for zero-latency remote screenshots and control."},{icon:"📱",title:"Mobile notifications",desc:"Get push notifications when agents need approval. Quick approve/reject from your phone."},{icon:"📡",title:"REST API access",desc:"Integrate with Slack, CI/CD pipelines, or custom tools. Scoped API keys with granular permissions."},{icon:"👥",title:"Team dashboard",desc:"Share a unified view across your team. See who's running what, where, in real time."},{icon:"🔐",title:"Enterprise security",desc:"SSO, RBAC, audit logs, and SLA guarantees for production teams."}],CI=[{feature:"Agent chat relay",selfhost:!0,cloud:!0},{feature:"Live IDE screenshots",selfhost:!0,cloud:!0},{feature:"Remote IDE control",selfhost:!0,cloud:!0},{feature:"Multi-IDE monitoring",selfhost:!0,cloud:!0},{feature:"Extension agent support",selfhost:!0,cloud:!0},{feature:"CLI agent support",selfhost:!0,cloud:!0},{feature:"Access from any network",selfhost:!1,cloud:!0},{feature:"WebRTC P2P streaming",selfhost:!1,cloud:!0},{feature:"Mobile push notifications",selfhost:!1,cloud:!0},{feature:"REST API & webhooks",selfhost:!1,cloud:!0},{feature:"Team collaboration",selfhost:!1,cloud:!0},{feature:"Multi-machine (Burrows)",selfhost:!1,cloud:!0},{feature:"SSO / RBAC / Audit logs",selfhost:!1,cloud:!0}],Wu={ides:["VS Code","Cursor","Antigravity","Windsurf","Trae","PearAI","Kiro","VSCodium","VS Code Insiders"],agents:["GitHub Copilot","Cline","Roo Code"],cli:["Gemini CLI","Claude Code","Codex CLI"]};function EI(){return u.jsxs("div",{className:"py-8 px-6 max-w-[860px] mx-auto text-text-primary",children:[u.jsxs("div",{className:"text-center mb-10",children:[u.jsx("img",{src:"/otter-logo.png",alt:"ADHDev",className:"w-14 h-14 mb-3 mx-auto"}),u.jsx("h1",{className:"text-[26px] font-extrabold mb-1.5 text-text-primary",children:"ADHDev"}),u.jsx("p",{className:"text-[13px] text-text-muted",children:"Agent Dashboard Hub for Dev — Self-hosted Edition"}),u.jsxs("div",{className:"inline-block mt-3 px-3 py-1 text-[11px] font-semibold tracking-wide rounded-full bg-emerald-500/10 text-emerald-500 border border-emerald-500/20",children:["SELFHOST v","0.6.3"]})]}),u.jsxs("section",{className:"mb-10",children:[u.jsxs("h2",{className:"text-lg font-bold mb-4 flex items-center gap-2",children:[u.jsx("span",{className:"text-base",children:"✅"})," What's included"]}),u.jsx("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(250px,1fr))] gap-3",children:SI.map(e=>u.jsxs("div",{className:"bg-bg-glass border border-border-subtle rounded-xl px-4 py-4 transition-colors hover:border-border-default",children:[u.jsx("div",{className:"text-xl mb-1.5",children:e.icon}),u.jsx("div",{className:"font-semibold text-[13px] mb-1",children:e.title}),u.jsx("div",{className:"text-[12px] text-text-muted leading-relaxed",children:e.desc})]},e.title))})]}),u.jsxs("section",{className:"mb-10",children:[u.jsx("h2",{className:"text-lg font-bold mb-4",children:"Compatible with"}),u.jsx("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(180px,1fr))] gap-5",children:[{label:"IDEs",items:Wu.ides},{label:"Extension agents",items:Wu.agents},{label:"CLI agents",items:Wu.cli}].map(e=>u.jsxs("div",{children:[u.jsx("div",{className:"text-[10px] font-bold tracking-wider text-text-muted mb-2 uppercase",children:e.label}),u.jsx("div",{className:"flex flex-col gap-1",children:e.items.map(t=>u.jsx("div",{className:"text-[12px] px-2.5 py-1.5 bg-bg-glass rounded-md border border-border-subtle",children:t},t))})]},e.label))})]}),u.jsxs("section",{className:"mb-10",children:[u.jsxs("h2",{className:"text-lg font-bold mb-4 flex items-center gap-2",children:[u.jsx("span",{className:"text-base",children:"⚖️"})," Self-hosted vs Cloud"]}),u.jsx("div",{className:"rounded-xl border border-border-subtle overflow-hidden",children:u.jsxs("table",{className:"w-full text-[13px]",children:[u.jsx("thead",{children:u.jsxs("tr",{className:"bg-bg-secondary",children:[u.jsx("th",{className:"text-left px-4 py-2.5 font-semibold text-text-muted text-[11px] uppercase tracking-wider",children:"Feature"}),u.jsx("th",{className:"text-center px-4 py-2.5 font-semibold text-text-muted text-[11px] uppercase tracking-wider w-[100px]",children:"Selfhost"}),u.jsx("th",{className:"text-center px-4 py-2.5 font-semibold text-[11px] uppercase tracking-wider w-[100px] text-violet-500",children:"Cloud"})]})}),u.jsx("tbody",{children:CI.map((e,t)=>u.jsxs("tr",{className:t%2===0?"bg-bg-glass":"",children:[u.jsx("td",{className:"px-4 py-2 text-text-secondary",children:e.feature}),u.jsx("td",{className:"text-center px-4 py-2",children:e.selfhost?u.jsx("span",{className:"text-emerald-500",children:"✓"}):u.jsx("span",{className:"text-text-muted opacity-40",children:"—"})}),u.jsx("td",{className:"text-center px-4 py-2",children:u.jsx("span",{className:"text-emerald-500",children:"✓"})})]},e.feature))})]})})]}),u.jsx("section",{className:"mb-10",children:u.jsx("div",{className:"rounded-2xl border border-violet-500/20 bg-violet-500/[0.04] px-6 py-6",children:u.jsxs("div",{className:"flex items-start gap-4",children:[u.jsx("div",{className:"text-3xl shrink-0",children:"🚀"}),u.jsxs("div",{className:"flex-1",children:[u.jsx("h3",{className:"font-bold text-[15px] mb-1.5",children:"Unlock more with ADHDev Cloud"}),u.jsx("p",{className:"text-[13px] text-text-muted leading-relaxed mb-4",children:"Access your agents from anywhere — your phone, another laptop, or a coffee shop. Cloud adds WebRTC P2P streaming, mobile push notifications, REST API, team collaboration, and multi-machine support. Your local setup stays exactly the same."}),u.jsx("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(220px,1fr))] gap-2.5 mb-5",children:kI.map(e=>u.jsxs("div",{className:"flex gap-2.5 items-start",children:[u.jsx("span",{className:"text-base shrink-0 mt-0.5",children:e.icon}),u.jsxs("div",{children:[u.jsx("div",{className:"font-semibold text-[12px]",children:e.title}),u.jsx("div",{className:"text-[11px] text-text-muted leading-snug",children:e.desc})]})]},e.title))}),u.jsxs("div",{className:"flex gap-3 flex-wrap",children:[u.jsx("a",{href:"https://adhf.dev",target:"_blank",rel:"noopener noreferrer",className:"btn btn-primary btn-sm inline-flex items-center gap-1.5 no-underline",children:"Try ADHDev Cloud →"}),u.jsx("a",{href:"https://github.com/vilmire/adhdev",target:"_blank",rel:"noopener noreferrer",className:"btn btn-secondary btn-sm inline-flex items-center gap-1.5 no-underline",children:"GitHub"}),u.jsx("a",{href:"https://discord.gg/WJD3tCfBzk",target:"_blank",rel:"noopener noreferrer",className:"btn btn-secondary btn-sm inline-flex items-center gap-1.5 no-underline",children:"Discord"})]})]})]})})}),u.jsxs("div",{className:"text-center text-xs text-text-muted pt-4 border-t border-border-subtle",children:[u.jsx("p",{children:"© 2026 RacoLab · ADHDev, Your AI sidekick otter 🦦"}),u.jsx("p",{className:"mt-1 opacity-60",children:"Self-hosted edition — all data stays on your machine"})]})]})}function NI(){const{ides:e}=Ko(),t=e.find(h=>h.type==="adhdev-daemon"),r=(t==null?void 0:t.detectedIdes)||[],{sendCommand:n}=ui(),{userName:i}=Ko(),[s,o]=x.useState(i||"");x.useEffect(()=>{i!==void 0&&o(i)},[i]);const l=h=>{const f=h.target.value.trim();t!=null&&t.id&&f!==i&&n(t.id,"set_user_name",{userName:f}).catch(console.error)},[a,c]=x.useState(()=>{try{return localStorage.getItem("adhdev_sound")!=="0"}catch{return!0}}),d=h=>{c(h);try{localStorage.setItem("adhdev_sound",h?"1":"0")}catch{}};return u.jsxs("div",{className:"flex flex-col h-full",children:[u.jsx(N4,{icon:"⚙️",title:"Settings",subtitle:"Local daemon configuration & preferences"}),u.jsxs("div",{className:"page-content",children:[u.jsx(Qi,{title:"Daemon",className:"mb-4",children:u.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-x-4 gap-y-2.5 text-sm",children:[u.jsx("span",{className:"text-text-muted",children:"Version"}),u.jsxs("span",{className:"font-mono text-xs",children:["v","0.6.3"]}),u.jsx("span",{className:"text-text-muted",children:"Status"}),u.jsx("span",{className:t?"text-green-400":"text-yellow-400",children:t?"● Running":"○ Not connected"}),u.jsx("span",{className:"text-text-muted",children:"WebSocket"}),u.jsx("span",{className:"font-mono text-xs",children:"ws://localhost:19222"}),u.jsx("span",{className:"text-text-muted",children:"HTTP"}),u.jsx("span",{className:"font-mono text-xs",children:"http://localhost:19280"})]})}),u.jsx(Qi,{title:"Detected IDEs",className:"mb-4",children:r.length===0?u.jsx("p",{className:"text-sm text-text-muted",children:"No IDEs detected. Start an IDE to see it here."}):u.jsx("div",{className:"flex flex-col gap-1.5",children:r.map(h=>u.jsxs("div",{className:"flex justify-between items-center bg-bg-glass rounded-lg px-3.5 py-2.5",children:[u.jsxs("div",{className:"flex items-center gap-2.5",children:[u.jsx("span",{className:`w-2 h-2 rounded-full ${h.running?"bg-green-400":"bg-text-muted/30"}`}),u.jsx("span",{className:"text-sm font-medium",children:h.name})]}),u.jsx("span",{className:"text-[11px] text-text-muted font-mono",children:h.type})]},h.type))})}),u.jsx(Qi,{title:"Machine",className:"mb-4",children:u.jsx(D4,{ides:e,emptyMessage:"Daemon not connected. Run 'adhdev-standalone' to start."})}),u.jsx(Qi,{title:"Theme",className:"mb-4",children:u.jsxs("div",{className:"flex flex-col gap-4",children:[u.jsxs("div",{children:[u.jsx("div",{className:"text-xs text-text-muted mb-2 font-medium",children:"Site theme"}),u.jsx($4,{})]}),u.jsxs("div",{className:"border-t border-border-subtle pt-4",children:[u.jsx("div",{className:"text-xs text-text-muted mb-2 font-medium",children:"Chat theme"}),u.jsx(V4,{})]}),u.jsxs("div",{className:"border-t border-border-subtle pt-4",children:[u.jsx("div",{className:"text-xs text-text-muted mb-2 font-medium",children:"Accent color"}),u.jsx(J4,{})]})]})}),u.jsx(Qi,{title:"Notifications",className:"mb-4",children:u.jsxs("div",{className:"flex flex-col gap-3",children:[u.jsx(j4,{}),u.jsx(Zi,{label:"🔊 Sound Effects",description:"Play a sound when agent completes or needs approval",checked:a,onChange:d})]})}),u.jsx(Qi,{title:"Preferences",className:"mb-4",children:u.jsx("div",{className:"flex flex-col gap-3",children:u.jsxs("div",{className:"flex items-center justify-between px-3.5 py-4 bg-bg-glass rounded-xl border border-border-subtle hover:border-border-hover transition-colors",children:[u.jsxs("div",{className:"flex flex-col gap-1 pr-4 max-w-[500px]",children:[u.jsx("span",{className:"text-sm font-semibold flex items-center gap-2",children:"👤 Display Name"}),u.jsx("span",{className:"text-[12px] text-text-muted leading-relaxed",children:"Your name shown in chat threads and on the team dashboard."})]}),u.jsx("input",{type:"text",className:"bg-bg-primary border border-border-strong rounded-lg px-3 py-1.5 text-sm w-48 text-right focus:border-accent-primary focus:outline-none transition-colors",placeholder:"Anonymous",value:s,onChange:h=>o(h.target.value),onBlur:l,onKeyDown:h=>{h.key==="Enter"&&h.currentTarget.blur()}})]})})})]})]})}U4();function q_(){const{ides:e}=Ko(),t=e.find(r=>{var n;return r.daemonMode||((n=r.id)==null?void 0:n.startsWith("standalone"))});return t?u.jsx(sa,{to:`/machines/${t.id}`,replace:!0}):e.length>0?u.jsx(sa,{to:`/machines/${e[0].id}`,replace:!0}):u.jsx(sa,{to:"/dashboard",replace:!0})}function TI(){return u.jsx(Tk,{children:u.jsx(yI,{children:u.jsx(jk,{value:{sendCommand:va,sendData:()=>!1},children:u.jsx(wI,{children:u.jsxs(kk,{children:[u.jsx(dn,{path:"/dashboard",element:u.jsx(nI,{})}),u.jsx(dn,{path:"/ide/:id",element:u.jsx(sI,{})}),u.jsx(dn,{path:"/machine",element:u.jsx(q_,{})}),u.jsx(dn,{path:"/machines/:id",element:u.jsx(fI,{})}),u.jsx(dn,{path:"/machines",element:u.jsx(q_,{})}),u.jsx(dn,{path:"/about",element:u.jsx(EI,{})}),u.jsx(dn,{path:"/settings",element:u.jsx(NI,{})}),u.jsx(dn,{path:"*",element:u.jsx(sa,{to:"/dashboard",replace:!0})})]})})})})})}hy(document.getElementById("root")).render(u.jsx(x.StrictMode,{children:u.jsx(TI,{})}));
|
|
202
|
+
This will disconnect CDP and optionally kill the process.`))try{const I=await t(X.daemonId,"stop_ide",{ideType:X.type,killProcess:!0});I!=null&&I.success?D("info",`${Ir(X.type)} stopped`):D("error",`Stop failed: ${(I==null?void 0:I.error)||"Unknown error"}`)}catch(I){D("error",`Stop failed: ${I.message}`)}},[D,t]),O=x.useCallback(async()=>{if(e)try{const X=await t(e,"detect_ides",{});D("info",`Found ${((X==null?void 0:X.result)||[]).length} IDE(s)`)}catch(X){D("error",`Detection failed: ${X.message}`)}},[e,D,t]),U=x.useCallback(async()=>{if(e){a(!0);try{const X=await t(e,"get_recent_workspaces",{});X!=null&&X.success&&Array.isArray(X==null?void 0:X.result)&&b(X.result)}catch(X){D("error",`Failed: ${X.message}`)}finally{a(!1)}}},[e,D,t]),L=x.useCallback(async X=>{if(!(!e||!X.trim())){d(!0);try{const I=await t(e,"workspace_add",{path:X.trim()});I!=null&&I.success?D("info",`Workspace added: ${X.trim()}`):D("error",(I==null?void 0:I.error)||"workspace_add failed")}catch(I){D("error",I.message)}finally{d(!1)}return!0}},[e,D,t]),$=x.useCallback(async X=>{if(!(!e||!window.confirm("Remove this workspace from the list?"))){d(!0);try{const I=await t(e,"workspace_remove",{id:X});I!=null&&I.success?D("info","Workspace removed"):D("error",(I==null?void 0:I.error)||"workspace_remove failed")}catch(I){D("error",I.message)}finally{d(!1)}}},[e,D,t]),w=x.useCallback(async X=>{var I;if(e){d(!0);try{const F=await t(e,"workspace_set_default",X===null?{clear:!0}:{id:X});if(F!=null&&F.success){D("info",X?"Default workspace updated":"Default workspace cleared");const G=typeof F.defaultWorkspacePath=="string"?F.defaultWorkspacePath:"";G&&((I=P.current)==null||I.call(P,G))}else D("error",(F==null?void 0:F.error)||"workspace_set_default failed")}catch(F){D("error",F.message)}finally{d(!1)}}},[e,D,t]),ee=x.useCallback(async X=>{var F;if(!e||!X.trim())return;const I=X.trim();d(!0);try{const G=await t(e,"workspace_set_default",{path:I});G!=null&&G.success?(D("info","Default workspace set from history"),(F=P.current)==null||F.call(P,I)):D("error",(G==null?void 0:G.error)||"Could not set default (path missing on disk?)")}catch(G){D("error",G.message)}finally{d(!1)}},[e,D,t]),ne=x.useCallback(async()=>{var X;if(e){f(!0);try{const I=await t(e,"get_cli_history",{}),F=(I==null?void 0:I.history)??((X=I==null?void 0:I.result)==null?void 0:X.history);I!=null&&I.success&&Array.isArray(F)&&m(F)}catch{}f(!1)}},[e,t]),T=x.useCallback(async()=>{if(e)try{await t(e,"set_machine_nickname",{nickname:R}),D("info",`Nickname set to "${R||"(cleared)"}"`),S(!1)}catch(X){D("error",`Failed: ${X.message}`)}},[e,R,D,t]);return{logs:n,launchingIde:s,loadingWorkspaces:l,workspaceBusy:c,loadingHistory:h,cliHistory:p,recentWorkspaces:_,launchPick:g,setLaunchPick:v,editingNickname:y,setEditingNickname:S,nicknameInput:R,setNicknameInput:E,addLog:D,handleLaunchIde:k,runLaunchCliCore:B,handleLaunchCli:j,handleStopCli:M,handleRestartIde:C,handleStopIde:A,handleDetectIdes:O,handleLoadRecentWorkspaces:U,handleWorkspaceAdd:L,handleWorkspaceRemove:$,handleWorkspaceSetDefault:w,handleWorkspaceResumePath:ee,loadCliHistory:ne,handleSaveNickname:T,setOnDefaultWorkspaceChanged:N}}function lI(e){const t=Math.floor((Date.now()-e)/1e3);return t<45?"just now":t<3600?`${Math.floor(t/60)}m ago`:t<86400?`${Math.floor(t/3600)}h ago`:`${Math.floor(t/86400)}d ago`}function aI({machine:e,managedIdes:t,managedClis:r,managedAcps:n,providers:i,getIcon:s,actions:o,setActiveTab:l}){const a=En(),{cliHistory:c,loadCliHistory:d,workspaceBusy:h,handleWorkspaceAdd:f,handleWorkspaceRemove:p,handleWorkspaceSetDefault:m,handleWorkspaceResumePath:_,runLaunchCliCore:b}=o,[g,v]=x.useState("");x.useEffect(()=>(o.setOnDefaultWorkspaceChanged(()=>{}),()=>o.setOnDefaultWorkspaceChanged(null)),[o]),x.useEffect(()=>{d()},[d]);const y=e.availableMem??e.freeMem,S=e.totalMem>0?Math.min(100,Math.max(0,Math.round((e.totalMem-y)/e.totalMem*100))):0,R=e.loadavg[0]||0,E=P=>{const N=i.find(D=>D.type===P);(N==null?void 0:N.category)==="acp"?l("acps"):l("clis")};return u.jsxs("div",{children:[u.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-2.5 mb-5",children:[u.jsx(Hl,{icon:u.jsx(Mg,{size:16}),label:"Uptime",value:xL(e.uptime)}),u.jsx(Hl,{icon:u.jsx(ul,{size:16}),label:"IDEs",value:`${t.length}`}),u.jsx(Hl,{icon:u.jsx(O0,{size:16}),label:"CLIs",value:`${r.length}`}),u.jsx(Hl,{icon:u.jsx(z0,{size:16}),label:"ACPs",value:`${n.length}`})]}),u.jsxs("div",{className:"px-5 py-4 rounded-xl mb-5 bg-bg-secondary border border-border-subtle",children:[u.jsx("div",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider mb-3",children:"Resource Usage"}),u.jsxs("div",{className:"flex gap-6",children:[u.jsx(N_,{value:Math.min(Math.round(R/e.cpus*100),100),max:100,label:"CPU Load",color:"#8b5cf6",detail:`${R.toFixed(2)} avg / ${e.cpus} cores`}),u.jsx(N_,{value:S,max:100,label:"Memory",color:"#3b82f6",detail:`${P_(e.totalMem-y)} / ${P_(e.totalMem)}${e.platform==="darwin"?" (approx.)":""}`})]})]}),u.jsxs("div",{className:"px-5 py-4 rounded-xl mb-5 bg-bg-secondary border border-border-subtle",children:[u.jsx("div",{className:"flex flex-wrap items-center justify-between gap-2 mb-3",children:u.jsxs("div",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider flex items-center gap-1.5",children:[u.jsx(Xa,{size:14})," Workspaces"]})}),u.jsxs("p",{className:"text-[10px] text-text-muted m-0 mb-3",children:["One list for IDE, CLI, and ACP: saved paths below, and a single ",u.jsx("strong",{className:"text-text-secondary font-medium",children:"default"}),'. The default opens in the IDE when you launch it, pre-fills CLI/ACP directories, and is what "Default" launch uses.']}),u.jsxs("div",{className:"flex flex-wrap gap-2 items-center mb-3",children:[u.jsx("span",{className:"text-[10px] text-text-muted",children:"Default:"}),u.jsxs("select",{className:"text-xs bg-bg-primary border border-border-subtle rounded-lg px-2 py-1 max-w-[min(100%,420px)]",disabled:h,value:e.defaultWorkspaceId||"",onChange:P=>void m(P.target.value===""?null:P.target.value),children:[u.jsx("option",{value:"",children:"(none — set a default to align IDE folder + CLI/ACP fields)"}),(e.workspaces||[]).map(P=>u.jsx("option",{value:P.id,children:P.label||P.path},P.id))]}),e.defaultWorkspacePath&&u.jsx("span",{className:"text-[10px] text-text-muted font-mono truncate max-w-[min(100%,360px)]",title:e.defaultWorkspacePath,children:e.defaultWorkspacePath})]}),u.jsxs("div",{className:"flex flex-wrap gap-2 items-end",children:[u.jsx("input",{className:"flex-1 min-w-[200px] text-xs bg-bg-primary border border-border-subtle rounded-lg px-2.5 py-1.5",placeholder:"Absolute workspace path to add…",value:g,disabled:h,onChange:P=>v(P.target.value),onKeyDown:P=>P.key==="Enter"&&void(async()=>{await f(g)&&v("")})()}),u.jsx("button",{type:"button",className:"machine-btn text-xs px-3 py-1.5",disabled:h,onClick:async()=>{await f(g)&&v("")},children:"Add"})]}),(e.workspaces||[]).length>0&&u.jsx("ul",{className:"mt-3 space-y-1 max-h-32 overflow-y-auto",children:(e.workspaces||[]).map(P=>u.jsxs("li",{className:"flex items-center gap-2 text-[11px] text-text-muted",children:[u.jsx("span",{className:"font-mono truncate flex-1",title:P.path,children:P.path}),u.jsx("button",{type:"button",className:"text-[10px] text-red-400/90 hover:underline",disabled:h,onClick:()=>void p(P.id),children:"Remove"})]},P.id))})]}),u.jsxs("div",{className:"px-5 py-4 rounded-xl mb-5 bg-bg-secondary border border-border-subtle border-violet-500/15",children:[u.jsxs("div",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider mb-1 flex items-center gap-1.5",children:[u.jsx(Mg,{size:14})," Pick up where you left off"]}),u.jsx("p",{className:"text-[10px] text-text-muted m-0 mb-3",children:"Same workspaces as above. Re-run CLI/ACP, or open CLIs/ACP tab with a path filled; IDE launch uses the default automatically when set."}),u.jsx("div",{className:"text-[10px] font-semibold text-text-muted uppercase tracking-wide mb-2",children:"Recent CLI / ACP launches"}),c.length>0?u.jsx("div",{className:"flex flex-col gap-1.5 mb-4",children:c.slice(0,10).map((P,N)=>{const D=P.label||`${P.cliType} · ${(P.dir||"").split("/").filter(Boolean).pop()||P.dir||"?"}`;return u.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-[11px] rounded-lg px-2.5 py-1.5 bg-bg-primary/80 border border-border-subtle",children:[u.jsxs("span",{className:"font-medium text-text-primary truncate max-w-[min(100%,240px)]",title:P.dir,children:[s(P.cliType)," ",D]}),u.jsx("span",{className:"text-[9px] text-text-muted font-mono truncate max-w-[min(100%,200px)]",title:P.dir,children:P.dir}),u.jsxs("span",{className:"flex flex-wrap gap-1.5 ml-auto",children:[u.jsx("button",{type:"button",className:"machine-btn text-[10px] px-2 py-0.5",onClick:()=>void b({cliType:P.cliType,dir:P.dir,argsStr:(P.cliArgs||[]).join(" ")}),children:"Run again"}),u.jsx("button",{type:"button",className:"machine-btn text-[10px] px-2 py-0.5",onClick:()=>E(P.cliType),children:"Open tab…"})]})]},`${P.cliType}-${P.dir}-${P.timestamp}-${N}`)})}):u.jsx("p",{className:"text-[11px] text-text-muted mb-4",children:"No launch history yet — start a CLI or ACP from the tabs below, then return here."}),(e.workspaceActivity||[]).length>0&&u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"text-[10px] font-semibold text-text-muted uppercase tracking-wide mb-2",children:"Recent workspace paths"}),u.jsx("div",{className:"flex flex-col gap-1.5",children:(e.workspaceActivity||[]).slice(0,12).map(P=>{const N=P.path.split("/").filter(Boolean).pop()||P.path,D=P.kind==="ide"?"IDE":P.kind==="cli"?"CLI":P.kind==="acp"?"ACP":P.kind==="default"||P.kind==="active"?"●":"",k=(P.kind==="cli"||P.kind==="acp")&&!!P.agentType;return u.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-[11px] rounded-lg px-2.5 py-1.5 bg-bg-primary/80 border border-border-subtle",children:[u.jsx("span",{className:"font-medium text-text-primary truncate max-w-[min(100%,200px)]",title:P.path,children:N}),D&&u.jsx("span",{className:"text-[9px] px-1.5 py-px rounded bg-violet-500/15 text-violet-400",children:D}),P.agentType&&u.jsx("span",{className:"text-[9px] text-text-muted font-mono",children:P.agentType}),u.jsx("span",{className:"text-[9px] text-text-muted",children:lI(P.lastUsedAt)}),u.jsxs("span",{className:"flex flex-wrap gap-1.5 ml-auto",children:[k&&u.jsx("button",{type:"button",className:"machine-btn text-[10px] px-2 py-0.5",onClick:()=>void b({cliType:P.agentType,dir:P.path}),children:"Run again"}),u.jsx("button",{type:"button",className:"machine-btn text-[10px] px-2 py-0.5",onClick:()=>l("clis"),children:"CLIs tab"}),u.jsx("button",{type:"button",className:"machine-btn text-[10px] px-2 py-0.5",onClick:()=>l("acps"),children:"ACP tab"}),u.jsx("button",{type:"button",className:"machine-btn text-[10px] px-2 py-0.5",disabled:h,onClick:()=>void _(P.path),children:"Set default"})]})]},`${P.path}-${P.lastUsedAt}`)})})]})]}),u.jsxs("div",{className:"grid grid-cols-[repeat(auto-fit,minmax(200px,1fr))] gap-3",children:[u.jsxs("div",{className:"px-5 py-4 rounded-xl bg-bg-secondary border border-border-subtle",children:[u.jsxs("div",{className:"flex justify-between items-center mb-2.5",children:[u.jsx("span",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider",children:"IDEs"}),u.jsx("button",{onClick:()=>l("ides"),className:"machine-btn text-[10px]",children:"View All →"})]}),t.length===0?u.jsx("div",{className:"text-xs text-text-muted italic",children:"No IDEs running"}):u.jsx("div",{className:"flex flex-col gap-1.5",children:t.map(P=>{var D;const N=(P.agentStreams||[]).some(k=>k.status==="generating"||k.status==="streaming")||((D=P.activeChat)==null?void 0:D.status)==="generating";return u.jsxs("div",{onClick:()=>a(`/ide/${P.id}`),className:`flex items-center gap-2 px-2.5 py-1.5 rounded-lg cursor-pointer transition-[background] duration-150 ${N?"bg-orange-500/[0.04] border border-orange-500/10":"bg-bg-glass border border-transparent"}`,children:[u.jsx("span",{children:s(P.type)}),u.jsx("span",{className:"text-xs text-text-primary font-medium",children:Ir(P.type)}),u.jsx("span",{className:"text-[10px] text-text-muted overflow-hidden text-ellipsis whitespace-nowrap",children:P.workspace||""}),N&&u.jsx("span",{className:"text-[10px] text-orange-400 font-semibold ml-auto",children:"⚡ Working"}),u.jsx("span",{className:`${N?"ml-1.5":"ml-auto"} w-1.5 h-1.5 rounded-full`,style:{background:N?"#fb923c":"#22c55e",boxShadow:N?"0 0 8px rgba(249,115,22,0.4)":"none",animation:N?"pulse-dot 1.5s infinite":"none"}})]},P.id)})})]}),u.jsxs("div",{className:"px-5 py-4 rounded-xl bg-bg-secondary border border-border-subtle",children:[u.jsxs("div",{className:"flex justify-between items-center mb-2.5",children:[u.jsx("span",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider",children:"CLIs"}),u.jsx("button",{onClick:()=>l("clis"),className:"machine-btn text-[10px]",children:"View All →"})]}),r.length===0?u.jsx("div",{className:"text-xs text-text-muted italic",children:"No CLIs running"}):u.jsx("div",{className:"flex flex-col gap-1.5",children:r.map(P=>u.jsxs("div",{className:"flex items-center gap-2 px-2.5 py-1.5 rounded-lg bg-bg-glass",children:[u.jsx("span",{children:s(P.type)}),u.jsx("span",{className:"text-xs text-text-primary font-medium",children:P.cliName}),u.jsx("span",{className:"text-[10px] text-text-muted overflow-hidden text-ellipsis whitespace-nowrap",children:P.workspace.split("/").pop()}),u.jsx("span",{className:"ml-auto w-1.5 h-1.5 rounded-full",style:{background:P.status==="stopped"?"#ef4444":"#22c55e"}})]},P.id))})]})]}),e.detectedIdes.length>0&&u.jsxs("div",{className:"mt-4 px-4.5 py-3.5 rounded-xl bg-bg-secondary border border-border-subtle",children:[u.jsx("div",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider mb-2",children:"Detected on this machine"}),u.jsx("div",{className:"flex flex-wrap gap-1.5",children:e.detectedIdes.map(P=>u.jsxs("div",{className:`px-2.5 py-1 rounded-md text-[11px] flex items-center gap-1 ${P.running?"bg-green-500/[0.06] border border-green-500/[0.12] text-green-300":"bg-bg-glass border border-border-subtle text-text-muted"}`,children:[u.jsx("span",{children:s(P.type)}),P.name||P.type,u.jsx("span",{className:"w-1 h-1 rounded-full",style:{background:P.running?"#22c55e":"#475569"}})]},P.type))})]})]})}function cI({machine:e,machineId:t,managedIdes:r,getIcon:n,actions:i,sendDaemonCommand:s}){const o=En(),{launchingIde:l,handleLaunchIde:a,handleRestartIde:c,handleStopIde:d,handleDetectIdes:h}=i,[f,p]=x.useState({}),[m,_]=x.useState(null),b=e.detectedIdes||[];return x.useEffect(()=>{if(!t)return;(async()=>{try{const v=await s(t,"get_ide_extensions",{}),y=(v==null?void 0:v.result)||v;y!=null&&y.success&&(y!=null&&y.ides)&&p(y.ides)}catch{}})()},[t,s]),u.jsxs("div",{children:[u.jsxs("div",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider mb-2.5",children:["Running (",r.length,")"]}),r.length===0?u.jsx("div",{className:"py-10 px-5 text-center rounded-xl bg-bg-secondary border border-dashed border-border-subtle text-text-muted text-[13px] mb-5",children:"No IDEs currently running. Launch one below."}):u.jsx("div",{className:"flex flex-col gap-2.5 mb-5",children:r.map(g=>u.jsxs("div",{className:"px-4.5 py-3.5 rounded-xl bg-bg-secondary border border-border-subtle",children:[u.jsxs("div",{className:"flex justify-between items-center mb-2.5",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("span",{className:"text-lg",children:n(g.type)}),u.jsx("span",{className:"font-semibold text-sm text-text-primary",children:Ir(g.type)}),g.version&&u.jsxs("span",{className:"text-[10px] text-text-muted",children:["v",g.version]}),u.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-green-500 shadow-[0_0_6px_rgba(34,197,94,0.3)]"})]}),u.jsxs("div",{className:"flex gap-1.5",children:[u.jsxs("button",{onClick:()=>o(`/ide/${g.id}`),className:"machine-btn flex items-center gap-1",children:[u.jsx(ul,{size:13})," Control"]}),u.jsx("button",{onClick:()=>c(g),className:"machine-btn text-amber-500 border-amber-500/30",children:"↻ Restart"}),u.jsx("button",{onClick:()=>d(g),className:"machine-btn text-red-400 border-red-500/30",children:"■ Stop"})]})]}),u.jsxs("div",{className:"text-xs text-text-secondary mb-2",children:[u.jsx("span",{className:"text-text-muted",children:"Workspace:"})," ",g.workspace||"—"]}),g.aiAgents.length>0&&u.jsx("div",{className:"flex gap-1 mb-2 flex-wrap",children:g.aiAgents.map(v=>u.jsxs("span",{className:`px-2 py-0.5 rounded-md text-[10px] ${v.status==="generating"||v.status==="streaming"?"bg-orange-500/[0.08] text-orange-400":"bg-indigo-500/[0.06] text-indigo-400"}`,children:[v.name," · ",v.status]},v.id))}),(f[g.type]||[]).length>0&&u.jsxs("div",{className:"mt-2 pt-2 border-t border-border-subtle",children:[u.jsx("div",{className:"text-[10px] text-text-muted font-semibold uppercase tracking-wider mb-1.5",children:"Extensions"}),u.jsx("div",{className:"flex flex-wrap gap-2",children:(f[g.type]||[]).map(v=>u.jsxs("button",{disabled:m===`${g.type}.${v.type}`,onClick:async()=>{const y=`${g.type}.${v.type}`;_(y);try{await s(t,"set_ide_extension",{ideType:g.type,extensionType:v.type,enabled:!v.enabled}),p(S=>({...S,[g.type]:(S[g.type]||[]).map(R=>R.type===v.type?{...R,enabled:!R.enabled}:R)}))}catch(S){console.error("Extension toggle failed:",S)}finally{_(null)}},className:`flex items-center gap-1.5 px-2.5 py-1 rounded-lg text-[11px] font-medium border transition-colors duration-150 cursor-pointer ${v.enabled?"bg-violet-500/[0.08] border-violet-500/20 text-violet-400":"bg-bg-glass border-border-subtle text-text-muted"}`,children:[u.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${v.enabled?"bg-violet-400 shadow-[0_0_4px_rgba(139,92,246,0.4)]":"bg-zinc-600"}`}),v.name,u.jsx("span",{className:"text-[9px] font-normal",children:v.enabled?"ON":"OFF"})]},v.type))})]})]},g.id))}),u.jsxs("div",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider mb-1",children:["Available to Launch (",b.length,")"]}),u.jsxs("p",{className:"text-[10px] text-text-muted m-0 mb-2.5",children:[e.defaultWorkspacePath?`Opens in default workspace: ${e.defaultWorkspacePath.split("/").filter(Boolean).pop()||e.defaultWorkspacePath}`:"No default workspace — IDE opens without a project folder from ADHDev (set one on Overview)."," ","Multi-window supported — running IDEs can be launched again as a new window."]}),u.jsxs("div",{className:"flex flex-wrap gap-2",children:[b.map(g=>{const v=g.running||r.some(y=>(y.type||"").toLowerCase()===(g.type||"").toLowerCase());return u.jsxs("button",{onClick:()=>a(g.type||g.id||""),disabled:!!l,className:`machine-btn-primary flex items-center gap-1.5 ${v?"!border-green-500/30":""}`,style:{opacity:l&&l!==g.type?.4:1},children:[u.jsx("span",{children:n(g.type)}),v&&u.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-green-500 shadow-[0_0_4px_rgba(34,197,94,0.4)]"}),l===g.type?"⏳ Launching...":`▶ ${g.name||Ir(g.type)}`,v&&u.jsx("span",{className:"text-[9px] text-green-400 font-normal",children:"+ window"})]},g.type)}),b.length===0&&u.jsxs("div",{className:"text-xs text-text-muted italic",children:["No IDEs detected.",u.jsxs("button",{onClick:h,className:"machine-btn ml-2 flex items-center gap-1",children:[u.jsx(AP,{size:12})," Scan"]})]})]})]})}function U_({category:e,machine:t,providers:r,managedEntries:n,getIcon:i,actions:s}){const o=En(),{handleLaunchCli:l,handleStopCli:a,runLaunchCliCore:c,handleLoadRecentWorkspaces:d,loadingWorkspaces:h,recentWorkspaces:f,cliHistory:p,loadingHistory:m,loadCliHistory:_}=s,b=e==="cli",g=b?"border-violet-500/[0.12]":"border-emerald-500/[0.12]",v=b?"CLI":"ACP Agent",y=r.filter(M=>M.category===e),[S,R]=x.useState(""),[E,P]=x.useState(""),[N,D]=x.useState(""),[k,B]=x.useState("");x.useEffect(()=>{!S&&y.length>0&&R(y[0].type)},[S,y.length]),x.useEffect(()=>{t.defaultWorkspacePath&&!E&&P(t.defaultWorkspacePath)},[t.defaultWorkspacePath]);const j=M=>b?M.cliName:M.acpName;return u.jsxs("div",{children:[u.jsxs("div",{className:`px-5 py-4 rounded-xl mb-5 bg-bg-secondary border ${g}`,children:[u.jsxs("div",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider mb-1",children:["Launch New ",v]}),u.jsx("p",{className:"text-[10px] text-text-muted m-0 mb-2.5",children:"Same workspaces and default as Overview — use path, Default, or Home explicitly."}),u.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[u.jsx("select",{value:S,onChange:M=>R(M.target.value),className:"machine-input",children:y.length>0?y.map(M=>u.jsxs("option",{value:M.type,children:[M.icon," ",M.displayName]},M.type)):u.jsxs("option",{value:"",disabled:!0,children:["No ",e.toUpperCase()," providers available"]})}),u.jsx("input",{type:"text",placeholder:"Working directory (or use Launch picker / Default / Home)",value:E,onChange:M=>P(M.target.value),className:"machine-input flex-1 min-w-[200px]"}),!b&&u.jsx("input",{type:"text",placeholder:"Model (default)",value:k,onChange:M=>B(M.target.value),className:"machine-input min-w-[120px]"}),u.jsx("input",{type:"text",placeholder:"Args (optional)",value:N,onChange:M=>D(M.target.value),className:"machine-input min-w-[120px]"}),u.jsx("button",{onClick:()=>l(S,E,N||void 0,b?void 0:k||void 0),className:"machine-btn-primary",children:"▶ Launch"}),u.jsx("button",{type:"button",disabled:!(t!=null&&t.defaultWorkspacePath),title:t!=null&&t.defaultWorkspacePath?void 0:"Set a default workspace in Overview first",onClick:()=>void c({cliType:S,useDefaultWorkspace:!0,argsStr:N||void 0,model:b?void 0:k||void 0}),className:"machine-btn text-[10px]",children:"Default"}),u.jsx("button",{type:"button",onClick:()=>void c({cliType:S,useHome:!0,argsStr:N||void 0,model:b?void 0:k||void 0}),className:"machine-btn text-[10px]",children:"Home"})]})]}),u.jsxs("div",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider mb-2.5",children:["Running (",n.length,")"]}),n.length===0?u.jsxs("div",{className:"py-7.5 px-5 text-center rounded-xl bg-bg-secondary border border-dashed border-border-subtle text-text-muted text-[13px] mb-5",children:["No ",b?"CLIs":"ACP agents"," running"]}):u.jsx("div",{className:"flex flex-col gap-2 mb-5",children:n.map(M=>{const C=b?null:M;return u.jsxs("div",{className:"px-4 py-3 rounded-[10px] bg-bg-secondary border border-border-subtle flex items-center justify-between",children:[u.jsxs("div",{className:"flex items-center gap-2.5",children:[u.jsx("span",{className:"text-lg",children:i(M.type)}),u.jsxs("div",{children:[u.jsx("div",{className:"font-semibold text-[13px] text-text-primary",children:j(M)}),u.jsxs("div",{className:"text-[11px] text-text-muted flex gap-2",children:[u.jsx("span",{children:M.workspace}),(C==null?void 0:C.currentModel)&&u.jsxs("span",{className:"text-cyan-500",children:["🤖 ",C.currentModel]}),(C==null?void 0:C.currentPlan)&&u.jsxs("span",{className:"text-amber-500",children:["📋 ",C.currentPlan]})]})]})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("span",{className:`px-2 py-0.5 rounded-md text-[10px] font-semibold ${M.status==="stopped"?"bg-red-500/[0.08] text-red-500":M.status==="generating"?"bg-orange-500/[0.08] text-orange-400":"bg-green-500/[0.08] text-green-500"}`,children:M.status}),!b&&u.jsx("button",{onClick:()=>o(`/ide/${M.id}`),className:"machine-btn",title:"View chat",children:u.jsx(Ya,{size:14})}),M.status==="stopped"?u.jsx("button",{onClick:()=>l(M.type,M.workspace),className:"machine-btn text-green-500 border-green-500/30",children:"▶"}):u.jsx("button",{onClick:()=>a(M.type,M.workspace,M.id),className:"machine-btn text-red-500 border-red-500/30",children:"■"})]})]},M.id)})}),u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"flex items-center gap-2 mb-2.5",children:[u.jsx("span",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider",children:"History"}),u.jsx("button",{onClick:_,disabled:m,className:"machine-btn",children:m?"⏳":"↻ Load"})]}),(()=>{const M=new Set(y.map(A=>A.type)),C=p.filter(A=>M.has(A.cliType));return C.length>0?u.jsx("div",{className:"flex flex-col gap-1 max-h-[200px] overflow-y-auto",children:C.map((A,O)=>{var U,L;return u.jsxs("div",{onClick:()=>{R(A.cliType),P(A.dir),D((A.cliArgs||[]).join(" "))},className:"flex justify-between items-center px-2.5 py-1.5 rounded-md cursor-pointer bg-bg-glass border border-border-subtle text-xs transition-colors duration-150 hover:bg-bg-glass-hover",children:[u.jsxs("div",{className:"flex gap-1.5 items-center text-text-secondary",children:[u.jsx("span",{children:i(A.cliType)}),u.jsx("span",{children:((U=A.dir)==null?void 0:U.split("/").filter(Boolean).pop())||"root"}),((L=A.cliArgs)==null?void 0:L.length)>0&&u.jsx("span",{className:"text-text-muted text-[10px]",children:A.cliArgs.join(" ")})]}),u.jsx("span",{className:"text-text-muted text-[10px]",children:A.timestamp?new Date(A.timestamp).toLocaleDateString():""})]},O)})}):u.jsxs("div",{className:"text-[11px] text-text-muted italic mb-2",children:["No ",b?"CLI":"ACP"," launch history yet."]})})()]}),u.jsxs("div",{className:"mt-5",children:[u.jsxs("div",{className:"flex items-center gap-2 mb-2.5",children:[u.jsx("span",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider",children:"Recent Workspaces"}),u.jsx("button",{onClick:d,disabled:h,className:"machine-btn",children:h?"⏳":"↻ Load"})]}),f.length>0&&u.jsx("div",{className:"flex flex-wrap gap-1.5",children:f.map((M,C)=>u.jsx("button",{onClick:()=>P(M),className:"machine-btn max-w-[200px] overflow-hidden text-ellipsis whitespace-nowrap",title:M,children:u.jsxs("span",{className:"flex items-center gap-1",children:[u.jsx(Xa,{size:12})," ",M.split("/").filter(Boolean).pop()||M]})},C))})]})]})}function uI({machineId:e,providers:t,sendDaemonCommand:r}){const[n,i]=x.useState([]),[s,o]=x.useState(!1),[l,a]=x.useState(null),[c,d]=x.useState("all"),h=x.useCallback(async()=>{var p;if(e){o(!0);try{const m=await r(e,"get_provider_settings",{}),_=(m==null?void 0:m.result)||m;if(m!=null&&m.success&&(_!=null&&_.settings)){const b=[];for(const[g,v]of Object.entries(_.settings)){const y=t.find(S=>S.type===g);b.push({type:g,displayName:(y==null?void 0:y.displayName)||g,icon:(y==null?void 0:y.icon)||"",category:(y==null?void 0:y.category)||"unknown",schema:v,values:((p=_.values)==null?void 0:p[g])||{}})}b.sort((g,v)=>g.category.localeCompare(v.category)||g.displayName.localeCompare(v.displayName)),i(b)}}catch{}o(!1)}},[e,t,r]);x.useEffect(()=>{n.length===0&&h()},[]);const f=async(p,m,_)=>{a(`${p}.${m}`),i(b=>b.map(g=>g.type===p?{...g,values:{...g.values,[m]:_}}:g));try{const b=await r(e,"set_provider_setting",{providerType:p,key:m,value:_});b!=null&&b.success||h()}catch{h()}a(null)};return u.jsxs("div",{children:[u.jsxs("div",{className:"flex justify-between items-center mb-4",children:[u.jsxs("div",{className:"flex gap-1 items-center",children:[u.jsx("span",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider mr-2",children:"Filter"}),["all","acp","cli","ide","extension"].map(p=>u.jsx("button",{onClick:()=>d(p),className:`machine-btn text-[10px] px-2 py-0.5 ${c===p?"bg-violet-500/15 border-violet-500/40 text-violet-400":""}`,children:p.toUpperCase()},p))]}),u.jsx("button",{onClick:h,disabled:s,className:"machine-btn",children:s?"⏳ Loading...":"↻ Refresh"})]}),c!=="all"&&n.filter(p=>p.category===c).length>1&&(()=>{const p=n.filter(g=>g.category===c),m=new Map;for(const g of p)for(const v of g.schema){if(v.type!=="boolean")continue;const y=m.get(v.key),S=!!(g.values[v.key]??v.default);y?(y.onCount+=S?1:0,y.total+=1):m.set(v.key,{label:v.label||v.key,onCount:S?1:0,total:1})}const _=[...m.entries()].filter(([,g])=>g.total===p.length);if(_.length===0)return null;const b=async(g,v)=>{for(const y of p)await f(y.type,g,v)};return u.jsxs("div",{className:"px-4 py-3 rounded-xl bg-violet-500/[0.04] border border-violet-500/10 mb-4",children:[u.jsxs("div",{className:"text-[10px] text-violet-400 font-semibold uppercase tracking-wider mb-2",children:["Bulk — Apply to all ",c.toUpperCase()," providers (",p.length,")"]}),u.jsx("div",{className:"flex flex-wrap gap-2",children:_.map(([g,v])=>{const y=v.onCount===v.total,S=v.onCount===0;return u.jsxs("div",{className:"flex items-center gap-1.5 text-[11px]",children:[u.jsx("span",{className:"text-text-secondary font-medium",children:v.label}),u.jsxs("span",{className:"text-[9px] text-text-muted",children:["(",v.onCount,"/",v.total,")"]}),u.jsx("button",{onClick:()=>void b(g,!0),disabled:y,className:`machine-btn text-[9px] px-1.5 py-px ${y?"opacity-40":"text-green-400 border-green-500/30"}`,children:"All ON"}),u.jsx("button",{onClick:()=>void b(g,!1),disabled:S,className:`machine-btn text-[9px] px-1.5 py-px ${S?"opacity-40":"text-red-400 border-red-500/30"}`,children:"All OFF"})]},g)})})]})})(),s&&n.length===0?u.jsx("div",{className:"p-10 text-center text-text-muted",children:"Loading provider settings..."}):u.jsx("div",{className:"flex flex-col gap-2",children:n.filter(p=>c==="all"||p.category===c).map(p=>u.jsxs("div",{className:"px-4.5 py-3.5 rounded-xl bg-bg-secondary border border-border-subtle",children:[u.jsxs("div",{className:"flex items-center gap-2 mb-2.5",children:[u.jsx("span",{className:"text-lg",children:p.icon}),u.jsx("span",{className:"font-semibold text-[13px] text-text-primary",children:p.displayName}),u.jsx("span",{className:"px-1.5 py-px rounded text-[9px] font-semibold",style:{background:p.category==="acp"?"rgba(139,92,246,0.08)":p.category==="cli"?"rgba(59,130,246,0.08)":p.category==="ide"?"rgba(34,197,94,0.08)":"rgba(245,158,11,0.08)",color:p.category==="acp"?"#a78bfa":p.category==="cli"?"#60a5fa":p.category==="ide"?"#86efac":"#fbbf24"},children:p.category})]}),u.jsx("div",{className:"flex flex-col gap-2",children:p.schema.map(m=>u.jsxs("div",{className:"flex items-center justify-between gap-3",children:[u.jsxs("div",{className:"flex-1 min-w-0",children:[u.jsxs("div",{className:"text-xs font-medium text-text-primary",children:[m.label||m.key,l===`${p.type}.${m.key}`&&u.jsx("span",{className:"ml-1.5 text-[9px] text-violet-500",children:"saving..."})]}),m.description&&u.jsx("div",{className:"text-[10px] text-text-muted mt-px",children:m.description})]}),u.jsx("div",{className:"shrink-0",children:m.type==="boolean"?u.jsx("button",{onClick:()=>f(p.type,m.key,!(p.values[m.key]??m.default)),className:"w-10 h-[22px] rounded-[11px] border-none relative cursor-pointer transition-colors duration-200",style:{background:p.values[m.key]??m.default?"#8b5cf6":"var(--border-subtle)"},children:u.jsx("div",{className:"w-4 h-4 rounded-full bg-white absolute top-[3px] transition-[left] duration-200 shadow-[0_1px_3px_rgba(0,0,0,0.3)]",style:{left:p.values[m.key]??m.default?21:3}})}):m.type==="number"?u.jsx("input",{type:"number",value:p.values[m.key]??m.default??0,min:m.min,max:m.max,onChange:_=>{const b=parseInt(_.target.value)||0;m.min!==void 0&&b<m.min||m.max!==void 0&&b>m.max||f(p.type,m.key,b)},className:"machine-input w-20 text-center text-[11px]"}):m.type==="select"&&m.options?u.jsx("select",{value:p.values[m.key]??m.default??"",onChange:_=>f(p.type,m.key,_.target.value),className:"machine-input text-[11px]",children:m.options.map(_=>u.jsx("option",{value:_,children:_},_))}):u.jsx("input",{type:"text",value:p.values[m.key]??m.default??"",onBlur:_=>f(p.type,m.key,_.target.value),className:"machine-input w-[120px] text-[11px]"})})]},m.key))})]},p.type))})]})}function hI({machineId:e,sendDaemonCommand:t}){const[r,n]=x.useState([]),[i,s]=x.useState(0),[o,l]=x.useState(!0),[a,c]=x.useState("debug"),d=x.useRef(null),h=x.useRef(!1);return x.useEffect(()=>{if(!e||!o)return;const f=async()=>{try{const m=await t(e,"get_logs",{count:200,minLevel:a,since:i}),_=(m==null?void 0:m.result)||m;if(m!=null&&m.success&&Array.isArray(_==null?void 0:_.logs)&&_.logs.length>0){n(g=>[...g,..._.logs.map(y=>({timestamp:y.ts,level:y.level,message:`[${y.category}] ${y.message}`}))].slice(-300));const b=Math.max(..._.logs.map(g=>g.ts));s(b)}}catch{}};f();const p=setInterval(f,3e3);return()=>clearInterval(p)},[e,o,i,a,t]),x.useEffect(()=>{if(o&&r.length>0){const f=h.current?"smooth":"instant";setTimeout(()=>{var p;(p=d.current)==null||p.scrollIntoView({behavior:f}),h.current=!0},50)}},[r.length,o]),u.jsxs("div",{children:[u.jsxs("div",{className:"flex justify-between items-center mb-3",children:[u.jsxs("div",{className:"flex gap-1 items-center",children:[u.jsx("span",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider mr-2",children:"Level"}),["debug","info","warn","error"].map(f=>u.jsx("button",{onClick:()=>{c(f),n([]),s(0)},className:`machine-btn text-[10px] px-2 py-0.5 ${a===f?"bg-violet-500/15 border-violet-500/40 text-violet-400":""}`,children:f.toUpperCase()},f))]}),u.jsxs("div",{className:"flex gap-1.5 items-center",children:[u.jsxs("span",{className:"text-[10px] text-text-muted",children:[r.length," entries"]}),u.jsx("button",{onClick:()=>l(!o),className:`machine-btn ${o?"text-green-500 border-green-500/30":""}`,children:o?"⏸ Pause":"▶ Resume"}),u.jsx("button",{onClick:()=>{n([]),s(0)},className:"machine-btn",children:"Clear"})]})]}),u.jsxs("div",{className:"bg-bg-secondary border border-border-subtle rounded-xl p-3 min-h-[200px] max-h-[500px] overflow-y-auto font-mono text-[11px] leading-relaxed",children:[r.length===0&&u.jsx("div",{className:"p-10 text-center text-text-muted",children:"Loading daemon logs..."}),r.map((f,p)=>u.jsxs("div",{className:"flex gap-2 py-px",style:{color:f.level==="error"?"#ef4444":f.level==="warn"?"#f59e0b":f.level==="debug"?"#64748b":"#94a3b8"},children:[u.jsx("span",{className:"text-text-muted min-w-[75px] shrink-0",children:new Date(f.timestamp).toLocaleTimeString()}),u.jsx("span",{className:"font-semibold min-w-[32px] shrink-0 text-[9px]",style:{color:f.level==="error"?"#ef4444":f.level==="warn"?"#f59e0b":f.level==="debug"?"#475569":"#8b5cf6"},children:f.level==="error"?"ERR":f.level==="warn"?"WRN":f.level==="debug"?"DBG":"INF"}),u.jsx("span",{children:f.message})]},p)),u.jsx("div",{ref:d})]})]})}function dI({machine:e,launchPick:t,actions:r}){const{runLaunchCliCore:n,setLaunchPick:i}=r;return u.jsx("div",{className:"fixed inset-0 z-[100] flex items-center justify-center p-4 bg-black/55 backdrop-blur-[2px]",role:"dialog","aria-modal":"true","aria-labelledby":"launch-pick-title",children:u.jsxs("div",{className:"w-full max-w-md rounded-xl border border-border-subtle bg-bg-secondary shadow-xl p-5",children:[u.jsx("h2",{id:"launch-pick-title",className:"text-sm font-semibold text-text-primary m-0 mb-1",children:"Where should this run?"}),u.jsx("p",{className:"text-[11px] text-text-muted m-0 mb-4",children:"Nothing is assumed. Pick a saved workspace, your default workspace, or home — or cancel and type a path."}),u.jsx("div",{className:"flex flex-col gap-2 mb-4 max-h-48 overflow-y-auto",children:(e.workspaces||[]).length===0?u.jsx("span",{className:"text-[11px] text-text-muted",children:"No saved workspaces yet. Add one in Overview or type a path above."}):(e.workspaces||[]).map(s=>u.jsxs("button",{type:"button",className:"text-left text-xs px-3 py-2 rounded-lg border border-border-subtle bg-bg-primary hover:bg-violet-500/10 transition-colors",onClick:()=>{i(null),n({cliType:t.cliType,workspaceId:s.id,argsStr:t.argsStr,model:t.model})},children:[u.jsx("span",{className:"font-medium text-text-primary block truncate",children:s.label||s.path}),u.jsx("span",{className:"text-[10px] text-text-muted font-mono truncate block",children:s.path})]},s.id))}),u.jsxs("div",{className:"flex flex-wrap gap-2",children:[u.jsx("button",{type:"button",className:"machine-btn text-[11px] flex-1 min-w-[120px]",disabled:!e.defaultWorkspacePath,onClick:()=>{i(null),n({cliType:t.cliType,useDefaultWorkspace:!0,argsStr:t.argsStr,model:t.model})},children:"Default workspace"}),u.jsx("button",{type:"button",className:"machine-btn text-[11px] flex-1 min-w-[120px]",onClick:()=>{i(null),n({cliType:t.cliType,useHome:!0,argsStr:t.argsStr,model:t.model})},children:"Home directory"}),u.jsx("button",{type:"button",className:"machine-btn text-[11px] flex-1 min-w-[80px]",onClick:()=>i(null),children:"Cancel"})]})]})})}function fI(){var S,R,E,P,N,D,k,B,j,M;const{id:e}=by(),t=En(),{sendCommand:r}=ui(),n=Lc(),i=n.ides||[],s=n.initialLoaded??!0,[o,l]=x.useState("overview"),a=x.useRef(null),c=oI({machineId:e,sendDaemonCommand:r,logsEndRef:a}),d=i.find(C=>C.id===e&&C.daemonMode),h=((d==null?void 0:d.availableProviders)||[]).map(C=>({type:C.type,displayName:C.displayName,icon:C.icon,category:C.category})),f={};for(const C of h)f[C.type]=C.icon;const p=C=>f[C]||"",m=d?{id:d.id,hostname:((S=d.machine)==null?void 0:S.hostname)||d.id,platform:((R=d.machine)==null?void 0:R.platform)||"unknown",arch:((E=d.machine)==null?void 0:E.arch)||"",cpus:((P=d.machine)==null?void 0:P.cpus)||0,totalMem:((N=d.machine)==null?void 0:N.totalMem)||0,freeMem:((D=d.machine)==null?void 0:D.freeMem)||0,availableMem:(k=d.machine)==null?void 0:k.availableMem,loadavg:((B=d.machine)==null?void 0:B.loadavg)||[],uptime:((j=d.machine)==null?void 0:j.uptime)||0,release:((M=d.machine)==null?void 0:M.release)||"",cdpConnected:!!(d.ides||[]).some(C=>C.cdpConnected),machineNickname:d.machineNickname||null,p2p:d.p2p||{available:!1,state:"unavailable",peers:0,screenshotActive:!1},detectedIdes:d.detectedIdes||[],managedIdeIds:d.managedIdeIds||[],managedCliIds:d.managedCliIds||[],workspaces:d.workspaces||[],defaultWorkspaceId:d.defaultWorkspaceId??d.activeWorkspaceId??null,defaultWorkspacePath:d.defaultWorkspacePath??d.activeWorkspacePath??null,workspaceActivity:d.workspaceActivity||[]}:null,_=i.filter(C=>C.daemonId===e&&!C.daemonMode).filter(C=>!R_(C)&&!M_(C)).map(C=>({id:C.id,type:C.type,version:C.version||"",instanceId:C.instanceId||"",status:C.status,workspace:C.workspace||null,terminals:C.terminals||0,aiAgents:yL(C.aiAgents||C.agents||[]),activeChat:C.activeChat||null,chats:C.chats||[],agentStreams:C.agentStreams||[],cdpConnected:C.cdpConnected||!1,daemonId:e})),b=i.filter(C=>C.daemonId===e&&R_(C)).map(C=>({id:C.id,type:C.type,cliName:C.cliName||C.type,status:C.status,workspace:C.workspace||"",activeChat:C.activeChat||null,daemonId:e})),g=i.filter(C=>C.daemonId===e&&M_(C)).map(C=>({id:C.id,type:C.type,acpName:C.cliName||C.type,status:C.status,workspace:C.workspace||"",activeChat:C.activeChat||null,currentModel:C.currentModel,currentPlan:C.currentPlan,daemonId:e}));if(!m)return s?u.jsxs("div",{className:"p-10 text-center text-text-muted",children:[u.jsx("h2",{className:"text-text-primary",children:"Machine not found"}),u.jsx("p",{className:"mt-3",children:"The machine may be offline or not yet connected."}),u.jsx("button",{onClick:()=>t("/machines"),className:"machine-btn-back",children:"← Back to Burrows"})]}):u.jsx("div",{className:"p-10 text-center text-text-muted",children:u.jsx("p",{children:"⏳ Loading machine..."})});const v=m.machineNickname||m.hostname,y=[{id:"overview",label:u.jsxs("span",{className:"flex items-center gap-1.5",children:[u.jsx(zP,{size:14})," Overview"]})},{id:"ides",label:u.jsxs("span",{className:"flex items-center gap-1.5",children:[u.jsx(ul,{size:14})," IDEs"]}),count:_.length},{id:"clis",label:u.jsxs("span",{className:"flex items-center gap-1.5",children:[u.jsx(B0,{size:14})," CLIs"]}),count:b.length},{id:"acps",label:u.jsxs("span",{className:"flex items-center gap-1.5",children:[u.jsx(z0,{size:14})," ACP Agents"]}),count:g.length},{id:"providers",label:u.jsxs("span",{className:"flex items-center gap-1.5",children:[u.jsx(D0,{size:14})," Providers"]})},{id:"logs",label:u.jsxs("span",{className:"flex items-center gap-1.5",children:[u.jsx(IP,{size:14})," Logs"]})}];return u.jsxs("div",{className:"flex flex-col h-full",children:[u.jsxs("div",{className:"dashboard-header !flex-col !items-stretch",children:[u.jsx("div",{className:"flex items-center justify-between w-full",children:u.jsxs("div",{className:"flex items-center gap-2 md:gap-3.5 w-full min-w-0",children:[u.jsx("button",{onClick:()=>t("/machines"),className:"machine-btn-back flex shrink-0",children:"←"}),u.jsxs("div",{className:"min-w-0",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[c.editingNickname?u.jsxs("div",{className:"flex gap-1.5 items-center",children:[u.jsx("input",{autoFocus:!0,value:c.nicknameInput,onChange:C=>c.setNicknameInput(C.target.value),onKeyDown:C=>{C.key==="Enter"&&c.handleSaveNickname(),C.key==="Escape"&&c.setEditingNickname(!1)},placeholder:"Machine nickname...",className:"px-2.5 py-1 rounded-md border border-violet-500/30 bg-bg-secondary text-text-primary text-sm font-semibold w-[140px] md:w-[200px]"}),u.jsx("button",{onClick:c.handleSaveNickname,className:"machine-btn text-green-500 border-green-500/30 shrink-0",children:"✓"}),u.jsx("button",{onClick:()=>c.setEditingNickname(!1),className:"machine-btn shrink-0",children:"✕"})]}):u.jsx("h1",{className:"header-title cursor-pointer truncate",onClick:()=>{c.setEditingNickname(!0),c.setNicknameInput(m.machineNickname||"")},title:"Click to set nickname",children:v}),u.jsx("span",{className:"status-dot-md online shrink-0"})]}),u.jsxs("div",{className:"header-subtitle mt-1 flex-wrap gap-1 md:gap-2 items-center display-none-mobile",children:[u.jsxs("span",{children:[m.platform," · ",m.arch," · ",m.cpus," cores"]}),m.p2p.available&&u.jsxs("span",{className:"px-1.5 py-px rounded text-[9px] font-semibold",style:{background:m.p2p.state==="connected"?"rgba(34,197,94,0.08)":"rgba(234,179,8,0.08)",color:m.p2p.state==="connected"?"#22c55e":"#eab308"},children:["P2P ",m.p2p.state==="connected"?`● ${m.p2p.peers}`:"○"]}),m.cdpConnected&&u.jsx("span",{className:"px-1.5 py-px rounded text-[9px] font-semibold bg-green-500/[0.08] text-green-500 shrink-0",children:"CDP ●"}),m.machineNickname&&u.jsxs("span",{className:"text-text-muted opacity-80 shrink-0",children:["(",m.hostname,")"]})]})]})]})}),u.jsx("div",{className:"machine-tabs w-full overflow-x-auto overflow-y-hidden pb-1 -mb-1 mt-2",children:y.map(C=>u.jsxs("button",{onClick:()=>l(C.id),className:`machine-tab shrink-0${o===C.id?" active":""}`,children:[C.label,C.count!==void 0&&u.jsx("span",{className:"tab-count",children:C.count})]},C.id))})]}),u.jsxs("div",{className:"page-content",children:[o==="overview"&&u.jsx(aI,{machine:m,managedIdes:_,managedClis:b,managedAcps:g,providers:h,getIcon:p,actions:c,setActiveTab:C=>l(C)}),o==="ides"&&u.jsx(cI,{machine:m,machineId:e,managedIdes:_,getIcon:p,actions:c,sendDaemonCommand:r}),o==="clis"&&u.jsx(U_,{category:"cli",machine:m,providers:h,managedEntries:b,getIcon:p,actions:c}),o==="acps"&&u.jsx(U_,{category:"acp",machine:m,providers:h,managedEntries:g,getIcon:p,actions:c}),o==="providers"&&u.jsx(uI,{machineId:e,providers:h,sendDaemonCommand:r}),o==="logs"&&u.jsx(hI,{machineId:e,sendDaemonCommand:r})]}),c.launchPick&&m&&u.jsx(dI,{machine:m,launchPick:c.launchPick,actions:c})]})}function pI(){if(typeof window>"u")return"ws://localhost:3847/ws";const t=`${window.location.protocol==="https:"?"wss":"ws"}://${window.location.host}/ws`,n=new URLSearchParams(window.location.search).get("token");return n?`${t}?token=${encodeURIComponent(n)}`:t}const K_=pI(),V_=3e3,mI=3e4;let mn=null,gI=0;const nc=new Map,zd=new Set;let vi=null;async function va(e,t,r){const n=mn;if(n&&n.readyState===WebSocket.OPEN){const s=`req_${++gI}_${Date.now()}`;return new Promise((o,l)=>{const a=setTimeout(()=>{nc.delete(s),l(new Error(`WS command timeout: ${t}`))},3e4);nc.set(s,{resolve:c=>{clearTimeout(a),o(c)},reject:c=>{clearTimeout(a),l(c)}}),n.send(JSON.stringify({type:"command",requestId:s,data:{type:t,payload:r||{},target:e}}))})}const i=await fetch("/api/v1/command",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:t,payload:r||{},target:e})});if(!i.ok)throw new Error(`HTTP ${i.status}`);return i.json()}class _I{constructor(t){Yt(this,"daemonId");Yt(this,"screenshotIdeType",null);this.daemonId=t}get hasCommandChannel(){return(mn==null?void 0:mn.readyState)===WebSocket.OPEN}get connectionState(){return(mn==null?void 0:mn.readyState)===WebSocket.OPEN?"connected":"disconnected"}async sendCommand(t,r){return va(this.daemonId,t,r)}async sendInput(t,r){const n=this.screenshotIdeType?`${this.daemonId}:ide:${this.screenshotIdeType}`:this.daemonId;return va(n,"cdp_remote_action",{action:t,params:r})}startScreenshots(t){this.screenshotIdeType=t||null,vi&&(clearInterval(vi),vi=null);const r=async()=>{if(this.hasCommandChannel)try{const n=this.screenshotIdeType?`${this.daemonId}:ide:${this.screenshotIdeType}`:this.daemonId,i=await va(n,"screenshot",{width:1280});if(i!=null&&i.success&&(i!=null&&i.base64)){const s=await fetch(`data:image/jpeg;base64,${i.base64}`).then(o=>o.blob());zd.forEach(o=>o(this.daemonId,s))}}catch{}};r(),vi=setInterval(r,2e3)}stopScreenshots(t){vi&&(clearInterval(vi),vi=null)}}let xi=null;function vI(e){(!xi||xi.daemonId!==e)&&(xi=new _I(e));const t=vr._originalGet||vr.get.bind(vr);vr._originalGet=t,vr.get=r=>r===e||r.startsWith("standalone")?xi:t(r),vr.getState=r=>(r===e||r.startsWith("standalone"))&&(xi==null?void 0:xi.connectionState)||"disconnected",vr.onScreenshot=(r,n)=>(zd.add(n),()=>{zd.delete(n)})}function xI({children:e}){const t=x.useRef(Im()),r=Im();t.current=r;const{setUserName:n}=Ko(),i=x.useRef(n);i.current=n;const[,s]=x.useState("disconnected"),o=x.useRef(null),l=x.useRef(),a=x.useRef(V_),c=x.useRef(!0);return x.useEffect(()=>{c.current=!0;function d(){var p,m;if(!c.current||((p=o.current)==null?void 0:p.readyState)===WebSocket.OPEN||((m=o.current)==null?void 0:m.readyState)===WebSocket.CONNECTING)return;s("connecting"),console.log(`[Standalone WS] Connecting to ${K_}...`);let f;try{f=new WebSocket(K_)}catch(_){console.error("[Standalone WS] Failed to create WebSocket:",_),h();return}o.current=f,f.onopen=()=>{if(!c.current){f.close();return}s("connected"),a.current=V_,console.log("[Standalone WS] Connected")},mn=f,f.onmessage=_=>{var b;try{const g=JSON.parse(_.data);if((g.type==="command_result"||g.type==="error")&&g.requestId){const v=nc.get(g.requestId);v&&(nc.delete(g.requestId),g.type==="error"?v.reject(new Error(((b=g.data)==null?void 0:b.message)||"Command failed")):v.resolve(g.data));return}if(g.type==="status"||g.type==="initial_state"){const v=g.data;if(!v)return;const{injectEntries:y,markLoaded:S}=t.current,R=v.id||"standalone";vI(R);const E=EL(v,{daemonId:R});E.length>0&&y(E),S(),v.userName&&i.current&&i.current(v.userName)}}catch(g){console.error("[Standalone WS] Parse error:",g)}},f.onclose=()=>{c.current&&(s("disconnected"),o.current=null,h())},f.onerror=_=>{console.warn("[Standalone WS] Error, will reconnect:",_)}}function h(){if(!c.current)return;clearTimeout(l.current);const f=a.current;console.log(`[Standalone WS] Reconnecting in ${f}ms...`),l.current=setTimeout(()=>{a.current=Math.min(a.current*1.5,mI),d()},f)}return d(),()=>{c.current=!1,clearTimeout(l.current),o.current&&(o.current.onclose=null,o.current.close(),o.current=null,mn=null)}},[]),u.jsx(u.Fragment,{children:e})}function yI({children:e}){return u.jsx(Rk,{children:u.jsx(xI,{children:e})})}const bI=[{id:"dashboard",path:"/dashboard",icon:u.jsx(MP,{}),label:"Dashboard"},{id:"machine",path:"/machines",icon:u.jsx(LP,{}),label:"Burrow"},{id:"settings",path:"/settings",icon:u.jsx(D0,{}),label:"Settings"}];function wI({children:e}){const t=En(),r=ol(),[n,i]=x.useState(!1),[s,o]=x.useState(()=>{try{return localStorage.getItem("sidebar-collapsed")==="1"}catch{return!1}}),l=d=>{t(d),i(!1)},a=()=>{o(d=>{const h=!d;try{localStorage.setItem("sidebar-collapsed",h?"1":"0")}catch{}return h})},c=d=>`nav-item${r.pathname.startsWith(d)?" active":""} cursor-pointer ${s?"justify-center py-2.5 px-0":""}`;return u.jsxs("div",{className:`app-layout${n?" mobile-menu-open":""}${s?" sidebar-collapsed":""}`,children:[u.jsxs("button",{type:"button",className:"mobile-menu-btn","aria-label":"Open menu",onClick:()=>i(!0),children:[u.jsx("span",{className:"mobile-menu-icon"}),u.jsx("span",{className:"mobile-menu-icon"}),u.jsx("span",{className:"mobile-menu-icon"})]}),n&&u.jsx("div",{className:"sidebar-overlay",role:"button",tabIndex:0,"aria-label":"Close menu",onClick:()=>i(!1),onKeyDown:d=>d.key==="Escape"&&i(!1)}),u.jsxs("aside",{className:`sidebar ${n?"sidebar-open":""}`,children:[u.jsxs("div",{className:"sidebar-header",children:[u.jsxs("div",{className:`sidebar-logo ${s?"justify-center gap-0":""}`,children:[u.jsx("img",{src:"/otter-logo.png",alt:"ADHDev",className:"w-7 h-7"}),!s&&u.jsx("span",{children:"ADHDev"})]}),u.jsx("button",{type:"button",className:"sidebar-close-btn","aria-label":"Close menu",onClick:()=>i(!1),children:"✕"})]}),u.jsx("nav",{className:"sidebar-nav",children:bI.map(d=>u.jsxs("div",{className:c(d.path),id:`nav-${d.id}`,onClick:()=>l(d.path),title:s?d.label:void 0,children:[u.jsx("span",{className:"nav-icon",children:d.icon}),!s&&d.label]},d.id))}),u.jsxs("div",{className:"border-t border-border-subtle pt-4 mt-2",children:[u.jsxs("div",{className:`nav-item cursor-pointer${r.pathname==="/about"?" active":""} ${s?"justify-center py-2.5 px-0":""}`,id:"nav-about",onClick:()=>t("/about"),title:s?"About":void 0,children:[u.jsx("span",{className:"nav-icon",children:u.jsx(jP,{})}),!s&&"About"]}),!s&&u.jsxs("div",{className:"px-3 py-2 text-xs text-text-muted",children:["Selfhost v","0.6.5"]}),u.jsxs("div",{className:`nav-item cursor-pointer ${s?"justify-center py-2.5 px-0":"mt-1"}`,onClick:a,title:s?"Expand sidebar":"Collapse sidebar",children:[u.jsx("span",{className:"nav-icon text-base",children:s?"›":"‹"}),!s&&u.jsx("span",{className:"text-xs",children:"Collapse"})]})]})]}),u.jsx("main",{className:"main-content relative",children:u.jsx("div",{className:"main-content-inner",children:e})})]})}const SI=[{icon:"🏠",title:"Local-first",desc:"Everything runs on your machine. No data leaves your network. Full privacy by design."},{icon:"💬",title:"Agent chat relay",desc:"Read and respond to AI conversations in real-time across all connected IDEs."},{icon:"📸",title:"Live screenshots",desc:"View your IDE screens directly in the browser via local WebSocket streaming."},{icon:"🎛️",title:"Remote control",desc:"Click, type, and interact with your IDE from the dashboard — no window switching."},{icon:"🔌",title:"Multi-IDE support",desc:"Monitor and control multiple IDEs simultaneously — VS Code, Cursor, Windsurf, and more."},{icon:"⚡",title:"Extension agents",desc:"Manage extension-based agents like Cline and Roo Code alongside native IDE agents."}],kI=[{icon:"🌍",title:"Access from anywhere",desc:"Control your agents from any device, any network. No VPN or port forwarding needed."},{icon:"🔗",title:"WebRTC P2P streaming",desc:"End-to-end encrypted peer-to-peer connection for zero-latency remote screenshots and control."},{icon:"📱",title:"Mobile notifications",desc:"Get push notifications when agents need approval. Quick approve/reject from your phone."},{icon:"📡",title:"REST API access",desc:"Integrate with Slack, CI/CD pipelines, or custom tools. Scoped API keys with granular permissions."},{icon:"👥",title:"Team dashboard",desc:"Share a unified view across your team. See who's running what, where, in real time."},{icon:"🔐",title:"Enterprise security",desc:"SSO, RBAC, audit logs, and SLA guarantees for production teams."}],CI=[{feature:"Agent chat relay",selfhost:!0,cloud:!0},{feature:"Live IDE screenshots",selfhost:!0,cloud:!0},{feature:"Remote IDE control",selfhost:!0,cloud:!0},{feature:"Multi-IDE monitoring",selfhost:!0,cloud:!0},{feature:"Extension agent support",selfhost:!0,cloud:!0},{feature:"CLI agent support",selfhost:!0,cloud:!0},{feature:"Access from any network",selfhost:!1,cloud:!0},{feature:"WebRTC P2P streaming",selfhost:!1,cloud:!0},{feature:"Mobile push notifications",selfhost:!1,cloud:!0},{feature:"REST API & webhooks",selfhost:!1,cloud:!0},{feature:"Team collaboration",selfhost:!1,cloud:!0},{feature:"Multi-machine (Burrows)",selfhost:!1,cloud:!0},{feature:"SSO / RBAC / Audit logs",selfhost:!1,cloud:!0}],Wu={ides:["VS Code","Cursor","Antigravity","Windsurf","Trae","PearAI","Kiro","VSCodium","VS Code Insiders"],agents:["GitHub Copilot","Cline","Roo Code"],cli:["Gemini CLI","Claude Code","Codex CLI"]};function EI(){return u.jsxs("div",{className:"py-8 px-6 max-w-[860px] mx-auto text-text-primary",children:[u.jsxs("div",{className:"text-center mb-10",children:[u.jsx("img",{src:"/otter-logo.png",alt:"ADHDev",className:"w-14 h-14 mb-3 mx-auto"}),u.jsx("h1",{className:"text-[26px] font-extrabold mb-1.5 text-text-primary",children:"ADHDev"}),u.jsx("p",{className:"text-[13px] text-text-muted",children:"Agent Dashboard Hub for Dev — Self-hosted Edition"}),u.jsxs("div",{className:"inline-block mt-3 px-3 py-1 text-[11px] font-semibold tracking-wide rounded-full bg-emerald-500/10 text-emerald-500 border border-emerald-500/20",children:["SELFHOST v","0.6.5"]})]}),u.jsxs("section",{className:"mb-10",children:[u.jsxs("h2",{className:"text-lg font-bold mb-4 flex items-center gap-2",children:[u.jsx("span",{className:"text-base",children:"✅"})," What's included"]}),u.jsx("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(250px,1fr))] gap-3",children:SI.map(e=>u.jsxs("div",{className:"bg-bg-glass border border-border-subtle rounded-xl px-4 py-4 transition-colors hover:border-border-default",children:[u.jsx("div",{className:"text-xl mb-1.5",children:e.icon}),u.jsx("div",{className:"font-semibold text-[13px] mb-1",children:e.title}),u.jsx("div",{className:"text-[12px] text-text-muted leading-relaxed",children:e.desc})]},e.title))})]}),u.jsxs("section",{className:"mb-10",children:[u.jsx("h2",{className:"text-lg font-bold mb-4",children:"Compatible with"}),u.jsx("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(180px,1fr))] gap-5",children:[{label:"IDEs",items:Wu.ides},{label:"Extension agents",items:Wu.agents},{label:"CLI agents",items:Wu.cli}].map(e=>u.jsxs("div",{children:[u.jsx("div",{className:"text-[10px] font-bold tracking-wider text-text-muted mb-2 uppercase",children:e.label}),u.jsx("div",{className:"flex flex-col gap-1",children:e.items.map(t=>u.jsx("div",{className:"text-[12px] px-2.5 py-1.5 bg-bg-glass rounded-md border border-border-subtle",children:t},t))})]},e.label))})]}),u.jsxs("section",{className:"mb-10",children:[u.jsxs("h2",{className:"text-lg font-bold mb-4 flex items-center gap-2",children:[u.jsx("span",{className:"text-base",children:"⚖️"})," Self-hosted vs Cloud"]}),u.jsx("div",{className:"rounded-xl border border-border-subtle overflow-hidden",children:u.jsxs("table",{className:"w-full text-[13px]",children:[u.jsx("thead",{children:u.jsxs("tr",{className:"bg-bg-secondary",children:[u.jsx("th",{className:"text-left px-4 py-2.5 font-semibold text-text-muted text-[11px] uppercase tracking-wider",children:"Feature"}),u.jsx("th",{className:"text-center px-4 py-2.5 font-semibold text-text-muted text-[11px] uppercase tracking-wider w-[100px]",children:"Selfhost"}),u.jsx("th",{className:"text-center px-4 py-2.5 font-semibold text-[11px] uppercase tracking-wider w-[100px] text-violet-500",children:"Cloud"})]})}),u.jsx("tbody",{children:CI.map((e,t)=>u.jsxs("tr",{className:t%2===0?"bg-bg-glass":"",children:[u.jsx("td",{className:"px-4 py-2 text-text-secondary",children:e.feature}),u.jsx("td",{className:"text-center px-4 py-2",children:e.selfhost?u.jsx("span",{className:"text-emerald-500",children:"✓"}):u.jsx("span",{className:"text-text-muted opacity-40",children:"—"})}),u.jsx("td",{className:"text-center px-4 py-2",children:u.jsx("span",{className:"text-emerald-500",children:"✓"})})]},e.feature))})]})})]}),u.jsx("section",{className:"mb-10",children:u.jsx("div",{className:"rounded-2xl border border-violet-500/20 bg-violet-500/[0.04] px-6 py-6",children:u.jsxs("div",{className:"flex items-start gap-4",children:[u.jsx("div",{className:"text-3xl shrink-0",children:"🚀"}),u.jsxs("div",{className:"flex-1",children:[u.jsx("h3",{className:"font-bold text-[15px] mb-1.5",children:"Unlock more with ADHDev Cloud"}),u.jsx("p",{className:"text-[13px] text-text-muted leading-relaxed mb-4",children:"Access your agents from anywhere — your phone, another laptop, or a coffee shop. Cloud adds WebRTC P2P streaming, mobile push notifications, REST API, team collaboration, and multi-machine support. Your local setup stays exactly the same."}),u.jsx("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(220px,1fr))] gap-2.5 mb-5",children:kI.map(e=>u.jsxs("div",{className:"flex gap-2.5 items-start",children:[u.jsx("span",{className:"text-base shrink-0 mt-0.5",children:e.icon}),u.jsxs("div",{children:[u.jsx("div",{className:"font-semibold text-[12px]",children:e.title}),u.jsx("div",{className:"text-[11px] text-text-muted leading-snug",children:e.desc})]})]},e.title))}),u.jsxs("div",{className:"flex gap-3 flex-wrap",children:[u.jsx("a",{href:"https://adhf.dev",target:"_blank",rel:"noopener noreferrer",className:"btn btn-primary btn-sm inline-flex items-center gap-1.5 no-underline",children:"Try ADHDev Cloud →"}),u.jsx("a",{href:"https://github.com/vilmire/adhdev",target:"_blank",rel:"noopener noreferrer",className:"btn btn-secondary btn-sm inline-flex items-center gap-1.5 no-underline",children:"GitHub"}),u.jsx("a",{href:"https://discord.gg/WJD3tCfBzk",target:"_blank",rel:"noopener noreferrer",className:"btn btn-secondary btn-sm inline-flex items-center gap-1.5 no-underline",children:"Discord"})]})]})]})})}),u.jsxs("div",{className:"text-center text-xs text-text-muted pt-4 border-t border-border-subtle",children:[u.jsx("p",{children:"© 2026 RacoLab · ADHDev, Your AI sidekick otter 🦦"}),u.jsx("p",{className:"mt-1 opacity-60",children:"Self-hosted edition — all data stays on your machine"})]})]})}function NI(){const{ides:e}=Ko(),t=e.find(h=>h.type==="adhdev-daemon"),r=(t==null?void 0:t.detectedIdes)||[],{sendCommand:n}=ui(),{userName:i}=Ko(),[s,o]=x.useState(i||"");x.useEffect(()=>{i!==void 0&&o(i)},[i]);const l=h=>{const f=h.target.value.trim();t!=null&&t.id&&f!==i&&n(t.id,"set_user_name",{userName:f}).catch(console.error)},[a,c]=x.useState(()=>{try{return localStorage.getItem("adhdev_sound")!=="0"}catch{return!0}}),d=h=>{c(h);try{localStorage.setItem("adhdev_sound",h?"1":"0")}catch{}};return u.jsxs("div",{className:"flex flex-col h-full",children:[u.jsx(N4,{icon:"⚙️",title:"Settings",subtitle:"Local daemon configuration & preferences"}),u.jsxs("div",{className:"page-content",children:[u.jsx(Qi,{title:"Daemon",className:"mb-4",children:u.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-x-4 gap-y-2.5 text-sm",children:[u.jsx("span",{className:"text-text-muted",children:"Version"}),u.jsxs("span",{className:"font-mono text-xs",children:["v","0.6.5"]}),u.jsx("span",{className:"text-text-muted",children:"Status"}),u.jsx("span",{className:t?"text-green-400":"text-yellow-400",children:t?"● Running":"○ Not connected"}),u.jsx("span",{className:"text-text-muted",children:"WebSocket"}),u.jsx("span",{className:"font-mono text-xs",children:"ws://localhost:19222"}),u.jsx("span",{className:"text-text-muted",children:"HTTP"}),u.jsx("span",{className:"font-mono text-xs",children:"http://localhost:19280"})]})}),u.jsx(Qi,{title:"Detected IDEs",className:"mb-4",children:r.length===0?u.jsx("p",{className:"text-sm text-text-muted",children:"No IDEs detected. Start an IDE to see it here."}):u.jsx("div",{className:"flex flex-col gap-1.5",children:r.map(h=>u.jsxs("div",{className:"flex justify-between items-center bg-bg-glass rounded-lg px-3.5 py-2.5",children:[u.jsxs("div",{className:"flex items-center gap-2.5",children:[u.jsx("span",{className:`w-2 h-2 rounded-full ${h.running?"bg-green-400":"bg-text-muted/30"}`}),u.jsx("span",{className:"text-sm font-medium",children:h.name})]}),u.jsx("span",{className:"text-[11px] text-text-muted font-mono",children:h.type})]},h.type))})}),u.jsx(Qi,{title:"Machine",className:"mb-4",children:u.jsx(D4,{ides:e,emptyMessage:"Daemon not connected. Run 'adhdev-standalone' to start."})}),u.jsx(Qi,{title:"Theme",className:"mb-4",children:u.jsxs("div",{className:"flex flex-col gap-4",children:[u.jsxs("div",{children:[u.jsx("div",{className:"text-xs text-text-muted mb-2 font-medium",children:"Site theme"}),u.jsx($4,{})]}),u.jsxs("div",{className:"border-t border-border-subtle pt-4",children:[u.jsx("div",{className:"text-xs text-text-muted mb-2 font-medium",children:"Chat theme"}),u.jsx(V4,{})]}),u.jsxs("div",{className:"border-t border-border-subtle pt-4",children:[u.jsx("div",{className:"text-xs text-text-muted mb-2 font-medium",children:"Accent color"}),u.jsx(J4,{})]})]})}),u.jsx(Qi,{title:"Notifications",className:"mb-4",children:u.jsxs("div",{className:"flex flex-col gap-3",children:[u.jsx(j4,{}),u.jsx(Zi,{label:"🔊 Sound Effects",description:"Play a sound when agent completes or needs approval",checked:a,onChange:d})]})}),u.jsx(Qi,{title:"Preferences",className:"mb-4",children:u.jsx("div",{className:"flex flex-col gap-3",children:u.jsxs("div",{className:"flex items-center justify-between px-3.5 py-4 bg-bg-glass rounded-xl border border-border-subtle hover:border-border-default transition-colors",children:[u.jsxs("div",{className:"flex flex-col gap-1 pr-4 max-w-[500px]",children:[u.jsx("span",{className:"text-sm font-semibold flex items-center gap-2",children:"👤 Display Name"}),u.jsx("span",{className:"text-[12px] text-text-muted leading-relaxed",children:"Your name shown in chat threads and on the team dashboard."})]}),u.jsx("input",{type:"text",className:"bg-bg-primary border border-border-strong rounded-lg px-3 py-1.5 text-sm w-48 text-right focus:border-accent-primary focus:outline-none transition-colors",placeholder:"Anonymous",value:s,onChange:h=>o(h.target.value),onBlur:l,onKeyDown:h=>{h.key==="Enter"&&h.currentTarget.blur()}})]})})})]})]})}U4();function q_(){const{ides:e}=Ko(),t=e.find(r=>{var n;return r.daemonMode||((n=r.id)==null?void 0:n.startsWith("standalone"))});return t?u.jsx(sa,{to:`/machines/${t.id}`,replace:!0}):e.length>0?u.jsx(sa,{to:`/machines/${e[0].id}`,replace:!0}):u.jsx(sa,{to:"/dashboard",replace:!0})}function TI(){return u.jsx(Tk,{children:u.jsx(yI,{children:u.jsx(jk,{value:{sendCommand:va,sendData:()=>!1},children:u.jsx(wI,{children:u.jsxs(kk,{children:[u.jsx(dn,{path:"/dashboard",element:u.jsx(nI,{})}),u.jsx(dn,{path:"/ide/:id",element:u.jsx(sI,{})}),u.jsx(dn,{path:"/machine",element:u.jsx(q_,{})}),u.jsx(dn,{path:"/machines/:id",element:u.jsx(fI,{})}),u.jsx(dn,{path:"/machines",element:u.jsx(q_,{})}),u.jsx(dn,{path:"/about",element:u.jsx(EI,{})}),u.jsx(dn,{path:"/settings",element:u.jsx(NI,{})}),u.jsx(dn,{path:"*",element:u.jsx(sa,{to:"/dashboard",replace:!0})})]})})})})})}hy(document.getElementById("root")).render(u.jsx(x.StrictMode,{children:u.jsx(TI,{})}));
|