/
proc
/
1387183
/
root
/
snap
/
lxd
/
current
/
share
/
lxd-ui
/
assets
/
File Upload :
llllll
Current File: //proc/1387183/root/snap/lxd/current/share/lxd-ui/assets/InstanceDetail-DN8FhiWk.js
import{O as er,j as d,R as je,d as O,ap as lo,r as Z,u as uo,b as Ks,e as ts,aq as _o,ar as mi,ao as wt,T as ht,f as Xe,as as gi,ac as fo,g as Ve,i as Ne,o as tt,at as tr,au as xt,B as Pt,av as po,aw as vi,ax as Si,ay as mo,Y as go,s as Ee,l as Be,az as Ts,aA as vo,aB as sr,q as Ce,U as ue,al as Lt,ak as Ge,aC as ir,an as rr,L as Gs,D as Ys,aD as Dt,aE as nr,m as ot,H as zs,aF as or,t as Ze,ah as St,aj as So,aG as bo,n as ar,F as cr,aH as hr,G as lr,aI as Co,z as ur,c as Mt,V as pe,Q as bi,P as Ci,aJ as ss,k as Eo,aK as yo,C as wo,aL as xo,x as Io,aM as Ao,J as Po}from"./index-dL2n30-Z.js";import{i as Lo}from"./instanceOptions-D4bz_1Ev.js";import{g as Ei,u as Do,a as Mo,I as To,b as yi,c as wi,d as Oe,i as is,e as dr,C as Ro,f as ko,h as Bo}from"./instanceDelete-Q6wsh0Vh.js";import{M as Oo}from"./Meter-BBGrNnHA.js";import{N as No,D as Uo}from"./NetworkListTable-CiRLc8LA.js";import{a as jo,c as _r,b as Ft,d as Fo,f as Ho,e as Ko,g as fr,h as Go,i as Yo,m as zo,j as Wo,r as $o}from"./instances-DpqZE1nw.js";import{S as pr}from"./SnapshotForm-DR60de46.js";import{t as Vo,a as qo,b as Xo,g as mr,i as Qo}from"./snapshots-AS6hXv2C.js";import{C as gr}from"./ClusterMemberSelector-CzVwwYbB.js";import{u as vr,a as Zo}from"./useInstances-1KVpwndK.js";import{I as Jo}from"./ItemName-BzCTqTL3.js";import{S as ea}from"./SelectableMainTable-DeGTWeiA.js";import{B as ta}from"./BulkDeleteButton-DzyTAjHk.js";import{S as Ws}from"./ScrollableTable-CQDmfMtz.js";import{S as sa}from"./SelectedTableNotification-BHmDbErh.js";import{h as Sr,i as at,j as Ht,I as br,r as ia,E as ra,R as na,a as oa,M as aa,B as ca,C as ha,Y as la,k as ua}from"./FormMenuItem-DRePjRCl.js";import{u as da}from"./useSortTableData-8PACcjA7.js";import{C as _a}from"./CustomIsoModal-b8-wZHV7.js";import{y as fa,Y as bt,I as pa,M as Es,D as ma,N as ga,G as va,P as Sa,O as ba,R as Ca,S as Ea,a as ya,b as wa,B as xa,C as Ia,c as Aa,o as Pa}from"./YamlSwitch-BRMLXARm.js";import{D as La,N as Da,G as Ma,P as Ta,O as Ra}from"./ProxyDeviceForm-sOuk1c-t.js";import{F as ka}from"./FormFooterLayout-Bmq4RXkd.js";import{Y as Ba}from"./YamlNotification-BqA1Vb41.js";import{F as Oa}from"./FormSubmitBtn-D3jUuO6-.js";import{R as Na}from"./RenameHeader-BZc6vaTG.js";import{F as ys,B as Ua}from"./FormLink-jsAVvDgu.js";import{S as ja}from"./StoragePoolSelectTable-OnqfmjE1.js";import{S as Fa}from"./StoragePoolSelector-BbIrdWMX.js";import{T as Ha}from"./TabLinks-BqmE_r1L.js";import"./ExpandableList-Cjp4v1_P.js";import"./useNetworks-FA5tQKQK.js";import"./networks-DWdMsnuF.js";import"./limits-CLEFMbq-.js";import"./AutoExpandingTextArea-CQuEMXHF.js";import"./scroll-Dmr9Jl9h.js";import"./ConfigFieldDescription-B5-bOr1x.js";import"./UploadCustomIso-CDeVprqC.js";import"./ProgressBar-BDA2xlPC.js";import"./storage-volumes-DY5ibnP4.js";import"./useVolumes-DkjZCOr_.js";import"./images-BNK9xDRN.js";import"./DiskSizeSelector-DZsA03GF.js";import"./StorageVolumeForm-BktJTI1i.js";import"./NetworkSelector-C6jsH-fc.js";import"./ScrollableContainer-ceiHesUW.js";import"./StoragePoolSize-BwIynhzl.js";import"./StoragePoolClusterMember-CcrqLmFp.js";const Ka=({instance:t,onFailure:e})=>{const{data:s=[],error:a,isLoading:g}=er(t.project);a&&e("Loading profiles failed",a);const w=[{content:"Name",sortKey:"name",className:"u-text--muted"},{content:"Description",sortKey:"description",className:"u-text--muted"}],y=t.profiles.map(r=>{const n=s.find(m=>m.name===r),u=(n==null?void 0:n.description)??"";return{key:r,columns:[{content:d.jsx(je,{type:"profile",value:r,to:n?`/ui/project/${encodeURIComponent(t.project)}/profile/${encodeURIComponent(r)}`:""}),role:"rowheader","aria-label":"Name"},{content:u,role:"cell",title:`Description ${u}`,"aria-label":"Description"}],sortData:{name:r.toLowerCase(),description:u.toLowerCase()}}});return g?d.jsx(O.Spinner,{className:"u-loader",text:"Loading profiles..."}):d.jsx(O.MainTable,{headers:w,rows:y,sortable:!0})},Ga=({instance:t})=>{const{getMetricHistory:e}=lo(),s=e(),[a,g]=Z.useState(15);Z.useEffect(()=>{const r=setInterval(()=>{g(n=>n-1)},1e3);return()=>{clearInterval(r)}},[]);const y=(()=>{if(s.length===0)return null;const r=s.length-1,n=Ei(s[r],t);if(!n)return null;let u=null;for(let i=s.length-2;i>=0&&(u=Ei(s[i],t),(u==null?void 0:u.cpuSecondsTotal)==n.cpuSecondsTotal);i--);if(!u)return null;const m=()=>{const i=n.cpuSecondsTotal-n.cpuSecondsIdle,o=u.cpuSecondsTotal-u.cpuSecondsIdle;return i-o},l=()=>{if(n.coreCount>0)return n.coreCount;const i=t.expanded_config["limits.cpu"];if(i){const o=parseInt(i);return o>0?o:1}return 1},p=m(),C=l(),S=(n.time-u.time)*C,_=100*p/S;return _<0?null:Math.min(_,100)})();return y===null?d.jsxs("div",{className:"u-text--muted p-text--small",children:["loading",a>0?`, ${a} seconds remaining to first CPU snapshot`:" takes longer than expected"]},a>0?a:"long"):d.jsx("div",{children:d.jsx(Oo,{percentage:y,text:`${Math.round(y*100)/100}%`})})},Ya=({instance:t,onFailure:e})=>{var m;const{isRestricted:s}=uo(),[a,g]=Z.useState(!1),{data:w=[],error:y,isLoading:r}=Do(t.location);y&&e("Loading metrics failed",y);const n=Mo(w,t);if(s)return d.jsx("div",{className:"u-text--muted",children:"Details are not available for restricted users"});const u=n.otherFilesystems.length>0;return d.jsx(d.Fragment,{children:r?d.jsx(O.Spinner,{className:"u-loader",text:"Loading metrics..."}):d.jsx("table",{children:d.jsxs("tbody",{children:[d.jsxs("tr",{className:"metric-row",children:[d.jsx("th",{className:"u-text--muted",children:"Memory"}),d.jsx("td",{children:n.memory?d.jsx(To,{memory:n.memory}):"-"})]}),d.jsxs("tr",{className:"metric-row",children:[d.jsx("th",{className:"u-text--muted",children:"Root filesystem"}),d.jsx("td",{children:n.rootFilesystem?d.jsx(yi,{filesystem:n.rootFilesystem}):"-"})]}),a&&n.otherFilesystems.map(l=>d.jsxs("tr",{className:"metric-row",children:[d.jsx("th",{className:"u-text--muted",children:l.device}),d.jsx("td",{children:d.jsx(yi,{filesystem:l})})]},l.device)),u&&d.jsxs("tr",{className:"metric-row",children:[d.jsx("th",{}),d.jsx("td",{children:d.jsx(O.Button,{appearance:"link",className:"u-no-margin--bottom",onClick:()=>{g(!a)},children:a?"Hide other filesystems":"Show other filesystems"})})]}),d.jsxs("tr",{className:"metric-row",children:[d.jsx("th",{className:"u-text--muted",children:"CPU"}),d.jsx("td",{children:n.memory?d.jsx(Ga,{instance:t}):"-"},(m=n.memory)==null?void 0:m.free)]})]})})})},za=({instance:t})=>{var y,r;const e=O.useNotify(),{data:s}=Ks(),a=(n,u)=>{e.failure(n,u)},g=()=>{ht("instance-overview-tab")};Z.useEffect(g,[(y=e.notification)==null?void 0:y.message]),O.useListener(window,g,"resize",!0);const w=!t.state||t.state.pid===0?"-":t.state.pid;return d.jsxs("div",{className:"instance-overview-tab",children:[d.jsx(ts,{}),d.jsxs(O.Row,{className:"general",children:[d.jsx(O.Col,{size:3,children:d.jsx("h2",{className:"p-heading--5",children:"General"})}),d.jsx(O.Col,{size:7,children:d.jsx("table",{children:d.jsxs("tbody",{children:[d.jsxs("tr",{children:[d.jsx("th",{className:"u-text--muted",children:"Base image"}),d.jsx("td",{children:_o(t)})]}),d.jsxs("tr",{children:[d.jsx("th",{className:"u-text--muted",children:"Description"}),d.jsx("td",{children:t.description?t.description:"-"})]}),d.jsxs("tr",{children:[d.jsx("th",{className:"u-text--muted",children:"Type"}),d.jsx("td",{children:Lo.filter(n=>n.value===t.type)[0].label})]}),d.jsxs("tr",{children:[d.jsx("th",{className:"u-text--muted",children:"IPv4"}),d.jsx("td",{children:d.jsx(wi,{instance:t,family:"inet"})},mi(t,"inet").length)]}),d.jsxs("tr",{children:[d.jsx("th",{className:"u-text--muted",children:"IPv6"}),d.jsx("td",{children:d.jsx(wi,{instance:t,family:"inet6"})},mi(t,"inet6").length)]}),d.jsxs("tr",{children:[d.jsx("th",{className:"u-text--muted",children:"Architecture"}),d.jsx("td",{children:t.architecture})]}),d.jsxs("tr",{children:[d.jsx("th",{className:"u-text--muted",children:"Cluster member"}),d.jsx("td",{children:(r=s==null?void 0:s.environment)!=null&&r.server_clustered&&t.location?d.jsx(je,{type:"cluster-member",value:t.location,to:`/ui/cluster/member/${encodeURIComponent(t.location)}`}):"-"})]}),d.jsxs("tr",{children:[d.jsx("th",{className:"u-text--muted",children:"PID"}),d.jsx("td",{children:w})]}),d.jsxs("tr",{children:[d.jsx("th",{className:"u-text--muted",children:"Date created"}),d.jsx("td",{children:wt(t.created_at)})]}),d.jsxs("tr",{children:[d.jsx("th",{className:"u-text--muted",children:"Last used"}),d.jsx("td",{children:wt(t.last_used_at)})]})]})})})]}),d.jsxs(O.Row,{className:"usage",children:[d.jsx(O.Col,{size:3,children:d.jsx("h2",{className:"p-heading--5",children:"Usage"})}),d.jsx(O.Col,{size:7,children:d.jsx(Ya,{instance:t,onFailure:a})})]}),d.jsxs(O.Row,{className:"networks",children:[d.jsx(O.Col,{size:3,children:d.jsx("h2",{className:"p-heading--5",children:"Networks"})}),d.jsx(O.Col,{size:7,children:d.jsx(No,{devices:t.expanded_devices,instance:t,onFailure:a})})]}),d.jsxs(O.Row,{className:"networks",children:[d.jsx(O.Col,{size:3,children:d.jsx("h2",{className:"p-heading--5",children:"Devices"})}),d.jsx(O.Col,{size:7,children:d.jsx(Uo,{configBaseURL:`/ui/project/${encodeURIComponent(t.project)}/instance/${encodeURIComponent(t.name)}/configuration`,devices:t.expanded_devices})})]}),d.jsxs(O.Row,{className:"profiles",children:[d.jsx(O.Col,{size:3,children:d.jsx("h2",{className:"p-heading--5",children:"Profiles"})}),d.jsx(O.Col,{size:7,children:d.jsx(Ka,{instance:t,onFailure:a})})]})]})};var ws={exports:{}},xi;function Wa(){return xi||(xi=1,function(t,e){(function(s,a){t.exports=a()})(self,()=>(()=>{var s={};return(()=>{var a=s;Object.defineProperty(a,"__esModule",{value:!0}),a.FitAddon=void 0,a.FitAddon=class{activate(g){this._terminal=g}dispose(){}fit(){const g=this.proposeDimensions();if(!g||!this._terminal||isNaN(g.cols)||isNaN(g.rows))return;const w=this._terminal._core;this._terminal.rows===g.rows&&this._terminal.cols===g.cols||(w._renderService.clear(),this._terminal.resize(g.cols,g.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;const g=this._terminal._core,w=g._renderService.dimensions;if(w.css.cell.width===0||w.css.cell.height===0)return;const y=this._terminal.options.scrollback===0?0:g.viewport.scrollBarWidth,r=window.getComputedStyle(this._terminal.element.parentElement),n=parseInt(r.getPropertyValue("height")),u=Math.max(0,parseInt(r.getPropertyValue("width"))),m=window.getComputedStyle(this._terminal.element),l=n-(parseInt(m.getPropertyValue("padding-top"))+parseInt(m.getPropertyValue("padding-bottom"))),p=u-(parseInt(m.getPropertyValue("padding-right"))+parseInt(m.getPropertyValue("padding-left")))-y;return{cols:Math.max(2,Math.floor(p/w.css.cell.width)),rows:Math.max(1,Math.floor(l/w.css.cell.height))}}}})(),s})())}(ws)),ws.exports}var Cr=Wa();const $a=({payload:t,close:e,reconnect:s})=>{const a=Z.useRef(null),g=Xe().shape({command:Ve().required("This field is required"),environment:fo().of(Xe().shape({key:Ve(),value:Ve()})),user:gi(),group:gi()}),w=Ne({initialValues:t,validationSchema:g,onSubmit:s}),y=()=>{const m=[...w.values.environment];m.push({key:"",value:""}),w.setFieldValue("environment",m)},r=m=>{const l=[...w.values.environment];l.splice(m,1),w.setFieldValue("environment",l)},n=m=>{m.key==="Escape"&&e()},u=()=>{ht("content-wrapper","p-modal__footer",64,"max-height")};return O.useListener(window,u,"resize",!0),Z.useEffect(u,[]),Z.useEffect(()=>{var m;(m=a.current)==null||m.scrollIntoView({behavior:"smooth",block:"end",inline:"start"}),window.dispatchEvent(new Event("resize"))},[w.values.environment]),d.jsx(O.Modal,{close:e,title:"Reconnect terminal",buttonRow:d.jsxs(d.Fragment,{children:[d.jsx(O.Button,{appearance:"base",className:"u-no-margin--bottom",type:"button","aria-label":"cancel reconnect",onClick:e,children:"Cancel"}),d.jsx(O.ActionButton,{className:"u-no-margin--bottom",appearance:"positive","aria-label":"submit reconnect",onClick:()=>void w.submitForm(),children:"Reconnect"})]}),onKeyDown:n,children:d.jsxs(O.Form,{onSubmit:w.handleSubmit,children:[d.jsx(O.Input,{type:"submit",hidden:!0,value:"Hidden input"}),d.jsxs("div",{className:"content-wrapper",children:[d.jsx(O.Input,{id:"command",name:"command",label:"Command",labelClassName:"u-no-margin--bottom",type:"text",required:!0,onBlur:w.handleBlur,onChange:w.handleChange,error:w.touched.command?w.errors.command:null,value:w.values.command}),d.jsx(O.Input,{id:"user",name:"user",label:"User ID",labelClassName:"u-no-margin--bottom",type:"number",onBlur:w.handleBlur,onChange:w.handleChange,value:w.values.user}),d.jsx(O.Input,{id:"group",name:"group",label:"Group ID",labelClassName:"u-no-margin--bottom",type:"number",onBlur:w.handleBlur,onChange:w.handleChange,value:w.values.group}),d.jsx("p",{className:"u-no-margin--bottom p-form__label",children:"Environment variables"}),w.values.environment.map((m,l)=>d.jsxs("div",{className:"env-variables",children:[d.jsx(O.Input,{type:"text",placeholder:"Key",labelClassName:"u-off-screen",label:`Key of variable ${l}`,id:`environment.${l}.key`,name:`environment.${l}.key`,onBlur:w.handleBlur,onChange:w.handleChange,value:w.values.environment[l].key}),d.jsx(O.Input,{type:"text",placeholder:"Value",labelClassName:"u-off-screen",label:`Value of variable ${l}`,id:`environment.${l}.value`,name:`environment.${l}.value`,onBlur:w.handleBlur,onChange:w.handleChange,value:w.values.environment[l].value}),d.jsx(O.Button,{"aria-label":`remove variable ${l}`,onClick:()=>{r(l)},type:"button",hasIcon:!0,children:d.jsx(O.Icon,{name:"delete"})})]},l)),d.jsx("div",{ref:a,children:d.jsx(O.Button,{"aria-label":"add variable",onClick:y,type:"button",children:d.jsx("span",{children:"Add variable"})})})]})]})})},Va=({payload:t,reconnect:e})=>{const[s,a]=Z.useState(!1),g=()=>{a(!1)},w=()=>{a(!0)},y=r=>{g(),e(r)};return d.jsxs(d.Fragment,{children:[s&&d.jsx($a,{close:g,reconnect:y,payload:t}),d.jsxs(O.Button,{className:"u-no-margin--bottom",hasIcon:!0,onClick:w,children:[d.jsx(O.Icon,{name:"connected"}),d.jsx("span",{children:"Reconnect"})]})]})};var xs={exports:{}},Ii;function qa(){return Ii||(Ii=1,function(t,e){(function(s,a){t.exports=a()})(self,()=>(()=>{var s={4567:function(y,r,n){var u=this&&this.__decorate||function(h,f,b,E){var I,v=arguments.length,x=v<3?f:E===null?E=Object.getOwnPropertyDescriptor(f,b):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")x=Reflect.decorate(h,f,b,E);else for(var L=h.length-1;L>=0;L--)(I=h[L])&&(x=(v<3?I(x):v>3?I(f,b,x):I(f,b))||x);return v>3&&x&&Object.defineProperty(f,b,x),x},m=this&&this.__param||function(h,f){return function(b,E){f(b,E,h)}};Object.defineProperty(r,"__esModule",{value:!0}),r.AccessibilityManager=void 0;const l=n(9042),p=n(6114),C=n(9924),S=n(844),_=n(5596),i=n(4725),o=n(3656);let c=r.AccessibilityManager=class extends S.Disposable{constructor(h,f){super(),this._terminal=h,this._renderService=f,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="",this._accessibilityContainer=document.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=document.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let b=0;b<this._terminal.rows;b++)this._rowElements[b]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[b]);if(this._topBoundaryFocusListener=b=>this._handleBoundaryFocus(b,0),this._bottomBoundaryFocusListener=b=>this._handleBoundaryFocus(b,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions(),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=document.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this.register(new C.TimeBasedDebouncer(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(b=>this._handleResize(b.rows))),this.register(this._terminal.onRender(b=>this._refreshRows(b.start,b.end))),this.register(this._terminal.onScroll(()=>this._refreshRows())),this.register(this._terminal.onA11yChar(b=>this._handleChar(b))),this.register(this._terminal.onLineFeed(()=>this._handleChar(` `))),this.register(this._terminal.onA11yTab(b=>this._handleTab(b))),this.register(this._terminal.onKey(b=>this._handleKey(b.key))),this.register(this._terminal.onBlur(()=>this._clearLiveRegion())),this.register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._screenDprMonitor=new _.ScreenDprMonitor(window),this.register(this._screenDprMonitor),this._screenDprMonitor.setListener(()=>this._refreshRowsDimensions()),this.register((0,o.addDisposableDomListener)(window,"resize",()=>this._refreshRowsDimensions())),this._refreshRows(),this.register((0,S.toDisposable)(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(h){for(let f=0;f<h;f++)this._handleChar(" ")}_handleChar(h){this._liveRegionLineCount<21&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==h&&(this._charsToAnnounce+=h):this._charsToAnnounce+=h,h===` `&&(this._liveRegionLineCount++,this._liveRegionLineCount===21&&(this._liveRegion.textContent+=l.tooMuchOutput)),p.isMac&&this._liveRegion.textContent&&this._liveRegion.textContent.length>0&&!this._liveRegion.parentNode&&setTimeout(()=>{this._accessibilityContainer.appendChild(this._liveRegion)},0))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0,p.isMac&&this._liveRegion.remove()}_handleKey(h){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(h)||this._charsToConsume.push(h)}_refreshRows(h,f){this._liveRegionDebouncer.refresh(h,f,this._terminal.rows)}_renderRows(h,f){const b=this._terminal.buffer,E=b.lines.length.toString();for(let I=h;I<=f;I++){const v=b.translateBufferLineToString(b.ydisp+I,!0),x=(b.ydisp+I+1).toString(),L=this._rowElements[I];L&&(v.length===0?L.innerText=" ":L.textContent=v,L.setAttribute("aria-posinset",x),L.setAttribute("aria-setsize",E))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(h,f){const b=h.target,E=this._rowElements[f===0?1:this._rowElements.length-2];if(b.getAttribute("aria-posinset")===(f===0?"1":`${this._terminal.buffer.lines.length}`)||h.relatedTarget!==E)return;let I,v;if(f===0?(I=b,v=this._rowElements.pop(),this._rowContainer.removeChild(v)):(I=this._rowElements.shift(),v=b,this._rowContainer.removeChild(I)),I.removeEventListener("focus",this._topBoundaryFocusListener),v.removeEventListener("focus",this._bottomBoundaryFocusListener),f===0){const x=this._createAccessibilityTreeNode();this._rowElements.unshift(x),this._rowContainer.insertAdjacentElement("afterbegin",x)}else{const x=this._createAccessibilityTreeNode();this._rowElements.push(x),this._rowContainer.appendChild(x)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(f===0?-1:1),this._rowElements[f===0?1:this._rowElements.length-2].focus(),h.preventDefault(),h.stopImmediatePropagation()}_handleResize(h){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let f=this._rowContainer.children.length;f<this._terminal.rows;f++)this._rowElements[f]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[f]);for(;this._rowElements.length>h;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){const h=document.createElement("div");return h.setAttribute("role","listitem"),h.tabIndex=-1,this._refreshRowDimensions(h),h}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){this._accessibilityContainer.style.width=`${this._renderService.dimensions.css.canvas.width}px`,this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let h=0;h<this._terminal.rows;h++)this._refreshRowDimensions(this._rowElements[h])}}_refreshRowDimensions(h){h.style.height=`${this._renderService.dimensions.css.cell.height}px`}};r.AccessibilityManager=c=u([m(1,i.IRenderService)],c)},3614:(y,r)=>{function n(p){return p.replace(/\r?\n/g,"\r")}function u(p,C){return C?"\x1B[200~"+p+"\x1B[201~":p}function m(p,C,S,_){p=u(p=n(p),S.decPrivateModes.bracketedPasteMode&&_.rawOptions.ignoreBracketedPasteMode!==!0),S.triggerDataEvent(p,!0),C.value=""}function l(p,C,S){const _=S.getBoundingClientRect(),i=p.clientX-_.left-10,o=p.clientY-_.top-10;C.style.width="20px",C.style.height="20px",C.style.left=`${i}px`,C.style.top=`${o}px`,C.style.zIndex="1000",C.focus()}Object.defineProperty(r,"__esModule",{value:!0}),r.rightClickHandler=r.moveTextAreaUnderMouseCursor=r.paste=r.handlePasteEvent=r.copyHandler=r.bracketTextForPaste=r.prepareTextForTerminal=void 0,r.prepareTextForTerminal=n,r.bracketTextForPaste=u,r.copyHandler=function(p,C){p.clipboardData&&p.clipboardData.setData("text/plain",C.selectionText),p.preventDefault()},r.handlePasteEvent=function(p,C,S,_){p.stopPropagation(),p.clipboardData&&m(p.clipboardData.getData("text/plain"),C,S,_)},r.paste=m,r.moveTextAreaUnderMouseCursor=l,r.rightClickHandler=function(p,C,S,_,i){l(p,C,S),i&&_.rightClickSelect(p),C.value=_.selectionText,C.select()}},7239:(y,r,n)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.ColorContrastCache=void 0;const u=n(1505);r.ColorContrastCache=class{constructor(){this._color=new u.TwoKeyMap,this._css=new u.TwoKeyMap}setCss(m,l,p){this._css.set(m,l,p)}getCss(m,l){return this._css.get(m,l)}setColor(m,l,p){this._color.set(m,l,p)}getColor(m,l){return this._color.get(m,l)}clear(){this._color.clear(),this._css.clear()}}},3656:(y,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.addDisposableDomListener=void 0,r.addDisposableDomListener=function(n,u,m,l){n.addEventListener(u,m,l);let p=!1;return{dispose:()=>{p||(p=!0,n.removeEventListener(u,m,l))}}}},6465:function(y,r,n){var u=this&&this.__decorate||function(i,o,c,h){var f,b=arguments.length,E=b<3?o:h===null?h=Object.getOwnPropertyDescriptor(o,c):h;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(i,o,c,h);else for(var I=i.length-1;I>=0;I--)(f=i[I])&&(E=(b<3?f(E):b>3?f(o,c,E):f(o,c))||E);return b>3&&E&&Object.defineProperty(o,c,E),E},m=this&&this.__param||function(i,o){return function(c,h){o(c,h,i)}};Object.defineProperty(r,"__esModule",{value:!0}),r.Linkifier2=void 0;const l=n(3656),p=n(8460),C=n(844),S=n(2585);let _=r.Linkifier2=class extends C.Disposable{get currentLink(){return this._currentLink}constructor(i){super(),this._bufferService=i,this._linkProviders=[],this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this.register(new p.EventEmitter),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this.register(new p.EventEmitter),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this.register((0,C.getDisposeArrayDisposable)(this._linkCacheDisposables)),this.register((0,C.toDisposable)(()=>{this._lastMouseEvent=void 0})),this.register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0}))}registerLinkProvider(i){return this._linkProviders.push(i),{dispose:()=>{const o=this._linkProviders.indexOf(i);o!==-1&&this._linkProviders.splice(o,1)}}}attachToDom(i,o,c){this._element=i,this._mouseService=o,this._renderService=c,this.register((0,l.addDisposableDomListener)(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this.register((0,l.addDisposableDomListener)(this._element,"mousemove",this._handleMouseMove.bind(this))),this.register((0,l.addDisposableDomListener)(this._element,"mousedown",this._handleMouseDown.bind(this))),this.register((0,l.addDisposableDomListener)(this._element,"mouseup",this._handleMouseUp.bind(this)))}_handleMouseMove(i){if(this._lastMouseEvent=i,!this._element||!this._mouseService)return;const o=this._positionFromMouseEvent(i,this._element,this._mouseService);if(!o)return;this._isMouseOut=!1;const c=i.composedPath();for(let h=0;h<c.length;h++){const f=c[h];if(f.classList.contains("xterm"))break;if(f.classList.contains("xterm-hover"))return}this._lastBufferCell&&o.x===this._lastBufferCell.x&&o.y===this._lastBufferCell.y||(this._handleHover(o),this._lastBufferCell=o)}_handleHover(i){if(this._activeLine!==i.y||this._wasResized)return this._clearCurrentLink(),this._askForLink(i,!1),void(this._wasResized=!1);this._currentLink&&this._linkAtPosition(this._currentLink.link,i)||(this._clearCurrentLink(),this._askForLink(i,!0))}_askForLink(i,o){var c,h;this._activeProviderReplies&&o||((c=this._activeProviderReplies)===null||c===void 0||c.forEach(b=>{b==null||b.forEach(E=>{E.link.dispose&&E.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=i.y);let f=!1;for(const[b,E]of this._linkProviders.entries())o?!((h=this._activeProviderReplies)===null||h===void 0)&&h.get(b)&&(f=this._checkLinkProviderResult(b,i,f)):E.provideLinks(i.y,I=>{var v,x;if(this._isMouseOut)return;const L=I==null?void 0:I.map(k=>({link:k}));(v=this._activeProviderReplies)===null||v===void 0||v.set(b,L),f=this._checkLinkProviderResult(b,i,f),((x=this._activeProviderReplies)===null||x===void 0?void 0:x.size)===this._linkProviders.length&&this._removeIntersectingLinks(i.y,this._activeProviderReplies)})}_removeIntersectingLinks(i,o){const c=new Set;for(let h=0;h<o.size;h++){const f=o.get(h);if(f)for(let b=0;b<f.length;b++){const E=f[b],I=E.link.range.start.y<i?0:E.link.range.start.x,v=E.link.range.end.y>i?this._bufferService.cols:E.link.range.end.x;for(let x=I;x<=v;x++){if(c.has(x)){f.splice(b--,1);break}c.add(x)}}}}_checkLinkProviderResult(i,o,c){var h;if(!this._activeProviderReplies)return c;const f=this._activeProviderReplies.get(i);let b=!1;for(let E=0;E<i;E++)this._activeProviderReplies.has(E)&&!this._activeProviderReplies.get(E)||(b=!0);if(!b&&f){const E=f.find(I=>this._linkAtPosition(I.link,o));E&&(c=!0,this._handleNewLink(E))}if(this._activeProviderReplies.size===this._linkProviders.length&&!c)for(let E=0;E<this._activeProviderReplies.size;E++){const I=(h=this._activeProviderReplies.get(E))===null||h===void 0?void 0:h.find(v=>this._linkAtPosition(v.link,o));if(I){c=!0,this._handleNewLink(I);break}}return c}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(i){if(!this._element||!this._mouseService||!this._currentLink)return;const o=this._positionFromMouseEvent(i,this._element,this._mouseService);o&&this._mouseDownLink===this._currentLink&&this._linkAtPosition(this._currentLink.link,o)&&this._currentLink.link.activate(i,this._currentLink.link.text)}_clearCurrentLink(i,o){this._element&&this._currentLink&&this._lastMouseEvent&&(!i||!o||this._currentLink.link.range.start.y>=i&&this._currentLink.link.range.end.y<=o)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,(0,C.disposeArray)(this._linkCacheDisposables))}_handleNewLink(i){if(!this._element||!this._lastMouseEvent||!this._mouseService)return;const o=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);o&&this._linkAtPosition(i.link,o)&&(this._currentLink=i,this._currentLink.state={decorations:{underline:i.link.decorations===void 0||i.link.decorations.underline,pointerCursor:i.link.decorations===void 0||i.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,i.link,this._lastMouseEvent),i.link.decorations={},Object.defineProperties(i.link.decorations,{pointerCursor:{get:()=>{var c,h;return(h=(c=this._currentLink)===null||c===void 0?void 0:c.state)===null||h===void 0?void 0:h.decorations.pointerCursor},set:c=>{var h,f;!((h=this._currentLink)===null||h===void 0)&&h.state&&this._currentLink.state.decorations.pointerCursor!==c&&(this._currentLink.state.decorations.pointerCursor=c,this._currentLink.state.isHovered&&((f=this._element)===null||f===void 0||f.classList.toggle("xterm-cursor-pointer",c)))}},underline:{get:()=>{var c,h;return(h=(c=this._currentLink)===null||c===void 0?void 0:c.state)===null||h===void 0?void 0:h.decorations.underline},set:c=>{var h,f,b;!((h=this._currentLink)===null||h===void 0)&&h.state&&((b=(f=this._currentLink)===null||f===void 0?void 0:f.state)===null||b===void 0?void 0:b.decorations.underline)!==c&&(this._currentLink.state.decorations.underline=c,this._currentLink.state.isHovered&&this._fireUnderlineEvent(i.link,c))}}}),this._renderService&&this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(c=>{if(!this._currentLink)return;const h=c.start===0?0:c.start+1+this._bufferService.buffer.ydisp,f=this._bufferService.buffer.ydisp+1+c.end;if(this._currentLink.link.range.start.y>=h&&this._currentLink.link.range.end.y<=f&&(this._clearCurrentLink(h,f),this._lastMouseEvent&&this._element)){const b=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);b&&this._askForLink(b,!1)}})))}_linkHover(i,o,c){var h;!((h=this._currentLink)===null||h===void 0)&&h.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(o,!0),this._currentLink.state.decorations.pointerCursor&&i.classList.add("xterm-cursor-pointer")),o.hover&&o.hover(c,o.text)}_fireUnderlineEvent(i,o){const c=i.range,h=this._bufferService.buffer.ydisp,f=this._createLinkUnderlineEvent(c.start.x-1,c.start.y-h-1,c.end.x,c.end.y-h-1,void 0);(o?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(f)}_linkLeave(i,o,c){var h;!((h=this._currentLink)===null||h===void 0)&&h.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(o,!1),this._currentLink.state.decorations.pointerCursor&&i.classList.remove("xterm-cursor-pointer")),o.leave&&o.leave(c,o.text)}_linkAtPosition(i,o){const c=i.range.start.y*this._bufferService.cols+i.range.start.x,h=i.range.end.y*this._bufferService.cols+i.range.end.x,f=o.y*this._bufferService.cols+o.x;return c<=f&&f<=h}_positionFromMouseEvent(i,o,c){const h=c.getCoords(i,o,this._bufferService.cols,this._bufferService.rows);if(h)return{x:h[0],y:h[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(i,o,c,h,f){return{x1:i,y1:o,x2:c,y2:h,cols:this._bufferService.cols,fg:f}}};r.Linkifier2=_=u([m(0,S.IBufferService)],_)},9042:(y,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.tooMuchOutput=r.promptLabel=void 0,r.promptLabel="Terminal input",r.tooMuchOutput="Too much output to announce, navigate to rows manually to read"},3730:function(y,r,n){var u=this&&this.__decorate||function(_,i,o,c){var h,f=arguments.length,b=f<3?i:c===null?c=Object.getOwnPropertyDescriptor(i,o):c;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")b=Reflect.decorate(_,i,o,c);else for(var E=_.length-1;E>=0;E--)(h=_[E])&&(b=(f<3?h(b):f>3?h(i,o,b):h(i,o))||b);return f>3&&b&&Object.defineProperty(i,o,b),b},m=this&&this.__param||function(_,i){return function(o,c){i(o,c,_)}};Object.defineProperty(r,"__esModule",{value:!0}),r.OscLinkProvider=void 0;const l=n(511),p=n(2585);let C=r.OscLinkProvider=class{constructor(_,i,o){this._bufferService=_,this._optionsService=i,this._oscLinkService=o}provideLinks(_,i){var o;const c=this._bufferService.buffer.lines.get(_-1);if(!c)return void i(void 0);const h=[],f=this._optionsService.rawOptions.linkHandler,b=new l.CellData,E=c.getTrimmedLength();let I=-1,v=-1,x=!1;for(let L=0;L<E;L++)if(v!==-1||c.hasContent(L)){if(c.loadCell(L,b),b.hasExtendedAttrs()&&b.extended.urlId){if(v===-1){v=L,I=b.extended.urlId;continue}x=b.extended.urlId!==I}else v!==-1&&(x=!0);if(x||v!==-1&&L===E-1){const k=(o=this._oscLinkService.getLinkData(I))===null||o===void 0?void 0:o.uri;if(k){const D={start:{x:v+1,y:_},end:{x:L+(x||L!==E-1?0:1),y:_}};let B=!1;if(!(f!=null&&f.allowNonHttpProtocols))try{const F=new URL(k);["http:","https:"].includes(F.protocol)||(B=!0)}catch{B=!0}B||h.push({text:k,range:D,activate:(F,Y)=>f?f.activate(F,Y,D):S(0,Y),hover:(F,Y)=>{var $;return($=f==null?void 0:f.hover)===null||$===void 0?void 0:$.call(f,F,Y,D)},leave:(F,Y)=>{var $;return($=f==null?void 0:f.leave)===null||$===void 0?void 0:$.call(f,F,Y,D)}})}x=!1,b.hasExtendedAttrs()&&b.extended.urlId?(v=L,I=b.extended.urlId):(v=-1,I=-1)}}i(h)}};function S(_,i){if(confirm(`Do you want to navigate to ${i}? WARNING: This link could potentially be dangerous`)){const o=window.open();if(o){try{o.opener=null}catch{}o.location.href=i}else console.warn("Opening link blocked as opener could not be cleared")}}r.OscLinkProvider=C=u([m(0,p.IBufferService),m(1,p.IOptionsService),m(2,p.IOscLinkService)],C)},6193:(y,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.RenderDebouncer=void 0,r.RenderDebouncer=class{constructor(n,u){this._parentWindow=n,this._renderCallback=u,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._parentWindow.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(n){return this._refreshCallbacks.push(n),this._animationFrame||(this._animationFrame=this._parentWindow.requestAnimationFrame(()=>this._innerRefresh())),this._animationFrame}refresh(n,u,m){this._rowCount=m,n=n!==void 0?n:0,u=u!==void 0?u:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,n):n,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,u):u,this._animationFrame||(this._animationFrame=this._parentWindow.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return void this._runRefreshCallbacks();const n=Math.max(this._rowStart,0),u=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(n,u),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(const n of this._refreshCallbacks)n(0);this._refreshCallbacks=[]}}},5596:(y,r,n)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.ScreenDprMonitor=void 0;const u=n(844);class m extends u.Disposable{constructor(p){super(),this._parentWindow=p,this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this.register((0,u.toDisposable)(()=>{this.clearListener()}))}setListener(p){this._listener&&this.clearListener(),this._listener=p,this._outerListener=()=>{this._listener&&(this._listener(this._parentWindow.devicePixelRatio,this._currentDevicePixelRatio),this._updateDpr())},this._updateDpr()}_updateDpr(){var p;this._outerListener&&((p=this._resolutionMediaMatchList)===null||p===void 0||p.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._listener&&this._outerListener&&(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._listener=void 0,this._outerListener=void 0)}}r.ScreenDprMonitor=m},3236:(y,r,n)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.Terminal=void 0;const u=n(3614),m=n(3656),l=n(6465),p=n(9042),C=n(3730),S=n(1680),_=n(3107),i=n(5744),o=n(2950),c=n(1296),h=n(428),f=n(4269),b=n(5114),E=n(8934),I=n(3230),v=n(9312),x=n(4725),L=n(6731),k=n(8055),D=n(8969),B=n(8460),F=n(844),Y=n(6114),$=n(8437),z=n(2584),A=n(7399),M=n(5941),T=n(9074),N=n(2585),V=n(5435),q=n(4567),J=typeof window<"u"?window.document:null;class X extends D.CoreTerminal{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}constructor(P={}){super(P),this.browser=Y,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this.register(new F.MutableDisposable),this._onCursorMove=this.register(new B.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onKey=this.register(new B.EventEmitter),this.onKey=this._onKey.event,this._onRender=this.register(new B.EventEmitter),this.onRender=this._onRender.event,this._onSelectionChange=this.register(new B.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this.register(new B.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onBell=this.register(new B.EventEmitter),this.onBell=this._onBell.event,this._onFocus=this.register(new B.EventEmitter),this._onBlur=this.register(new B.EventEmitter),this._onA11yCharEmitter=this.register(new B.EventEmitter),this._onA11yTabEmitter=this.register(new B.EventEmitter),this._onWillOpen=this.register(new B.EventEmitter),this._setup(),this.linkifier2=this.register(this._instantiationService.createInstance(l.Linkifier2)),this.linkifier2.registerLinkProvider(this._instantiationService.createInstance(C.OscLinkProvider)),this._decorationService=this._instantiationService.createInstance(T.DecorationService),this._instantiationService.setService(N.IDecorationService,this._decorationService),this.register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this.register(this._inputHandler.onRequestRefreshRows((U,G)=>this.refresh(U,G))),this.register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this.register(this._inputHandler.onRequestReset(()=>this.reset())),this.register(this._inputHandler.onRequestWindowsOptionsReport(U=>this._reportWindowsOptions(U))),this.register(this._inputHandler.onColor(U=>this._handleColorEvent(U))),this.register((0,B.forwardEvent)(this._inputHandler.onCursorMove,this._onCursorMove)),this.register((0,B.forwardEvent)(this._inputHandler.onTitleChange,this._onTitleChange)),this.register((0,B.forwardEvent)(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this.register((0,B.forwardEvent)(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this.register(this._bufferService.onResize(U=>this._afterResize(U.cols,U.rows))),this.register((0,F.toDisposable)(()=>{var U,G;this._customKeyEventHandler=void 0,(G=(U=this.element)===null||U===void 0?void 0:U.parentNode)===null||G===void 0||G.removeChild(this.element)}))}_handleColorEvent(P){if(this._themeService)for(const U of P){let G,K="";switch(U.index){case 256:G="foreground",K="10";break;case 257:G="background",K="11";break;case 258:G="cursor",K="12";break;default:G="ansi",K="4;"+U.index}switch(U.type){case 0:const se=k.color.toColorRGB(G==="ansi"?this._themeService.colors.ansi[U.index]:this._themeService.colors[G]);this.coreService.triggerDataEvent(`${z.C0.ESC}]${K};${(0,M.toRgbString)(se)}${z.C1_ESCAPED.ST}`);break;case 1:if(G==="ansi")this._themeService.modifyColors(Q=>Q.ansi[U.index]=k.rgba.toColor(...U.color));else{const Q=G;this._themeService.modifyColors(oe=>oe[Q]=k.rgba.toColor(...U.color))}break;case 2:this._themeService.restoreColor(U.index)}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(P){P?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(q.AccessibilityManager,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(P){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(z.C0.ESC+"[I"),this.updateCursorStyle(P),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){var P;return(P=this.textarea)===null||P===void 0?void 0:P.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(z.C0.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;const P=this.buffer.ybase+this.buffer.y,U=this.buffer.lines.get(P);if(!U)return;const G=Math.min(this.buffer.x,this.cols-1),K=this._renderService.dimensions.css.cell.height,se=U.getWidth(G),Q=this._renderService.dimensions.css.cell.width*se,oe=this.buffer.y*this._renderService.dimensions.css.cell.height,ge=G*this._renderService.dimensions.css.cell.width;this.textarea.style.left=ge+"px",this.textarea.style.top=oe+"px",this.textarea.style.width=Q+"px",this.textarea.style.height=K+"px",this.textarea.style.lineHeight=K+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this.register((0,m.addDisposableDomListener)(this.element,"copy",U=>{this.hasSelection()&&(0,u.copyHandler)(U,this._selectionService)}));const P=U=>(0,u.handlePasteEvent)(U,this.textarea,this.coreService,this.optionsService);this.register((0,m.addDisposableDomListener)(this.textarea,"paste",P)),this.register((0,m.addDisposableDomListener)(this.element,"paste",P)),Y.isFirefox?this.register((0,m.addDisposableDomListener)(this.element,"mousedown",U=>{U.button===2&&(0,u.rightClickHandler)(U,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this.register((0,m.addDisposableDomListener)(this.element,"contextmenu",U=>{(0,u.rightClickHandler)(U,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),Y.isLinux&&this.register((0,m.addDisposableDomListener)(this.element,"auxclick",U=>{U.button===1&&(0,u.moveTextAreaUnderMouseCursor)(U,this.textarea,this.screenElement)}))}_bindKeys(){this.register((0,m.addDisposableDomListener)(this.textarea,"keyup",P=>this._keyUp(P),!0)),this.register((0,m.addDisposableDomListener)(this.textarea,"keydown",P=>this._keyDown(P),!0)),this.register((0,m.addDisposableDomListener)(this.textarea,"keypress",P=>this._keyPress(P),!0)),this.register((0,m.addDisposableDomListener)(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this.register((0,m.addDisposableDomListener)(this.textarea,"compositionupdate",P=>this._compositionHelper.compositionupdate(P))),this.register((0,m.addDisposableDomListener)(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this.register((0,m.addDisposableDomListener)(this.textarea,"input",P=>this._inputEvent(P),!0)),this.register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(P){var U;if(!P)throw new Error("Terminal requires a parent element.");P.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),this._document=P.ownerDocument,this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),P.appendChild(this.element);const G=J.createDocumentFragment();this._viewportElement=J.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),G.appendChild(this._viewportElement),this._viewportScrollArea=J.createElement("div"),this._viewportScrollArea.classList.add("xterm-scroll-area"),this._viewportElement.appendChild(this._viewportScrollArea),this.screenElement=J.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._helperContainer=J.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),G.appendChild(this.screenElement),this.textarea=J.createElement("textarea"),this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",p.promptLabel),Y.isChromeOS||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._coreBrowserService=this._instantiationService.createInstance(b.CoreBrowserService,this.textarea,(U=this._document.defaultView)!==null&&U!==void 0?U:window),this._instantiationService.setService(x.ICoreBrowserService,this._coreBrowserService),this.register((0,m.addDisposableDomListener)(this.textarea,"focus",K=>this._handleTextAreaFocus(K))),this.register((0,m.addDisposableDomListener)(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(h.CharSizeService,this._document,this._helperContainer),this._instantiationService.setService(x.ICharSizeService,this._charSizeService),this._themeService=this._instantiationService.createInstance(L.ThemeService),this._instantiationService.setService(x.IThemeService,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(f.CharacterJoinerService),this._instantiationService.setService(x.ICharacterJoinerService,this._characterJoinerService),this._renderService=this.register(this._instantiationService.createInstance(I.RenderService,this.rows,this.screenElement)),this._instantiationService.setService(x.IRenderService,this._renderService),this.register(this._renderService.onRenderedViewportChange(K=>this._onRender.fire(K))),this.onResize(K=>this._renderService.resize(K.cols,K.rows)),this._compositionView=J.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(o.CompositionHelper,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this.element.appendChild(G);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._mouseService=this._instantiationService.createInstance(E.MouseService),this._instantiationService.setService(x.IMouseService,this._mouseService),this.viewport=this._instantiationService.createInstance(S.Viewport,this._viewportElement,this._viewportScrollArea),this.viewport.onRequestScrollLines(K=>this.scrollLines(K.amount,K.suppressScrollEvent,1)),this.register(this._inputHandler.onRequestSyncScrollBar(()=>this.viewport.syncScrollArea())),this.register(this.viewport),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.register(this._renderService.onDimensionsChange(()=>this.viewport.syncScrollArea())),this._selectionService=this.register(this._instantiationService.createInstance(v.SelectionService,this.element,this.screenElement,this.linkifier2)),this._instantiationService.setService(x.ISelectionService,this._selectionService),this.register(this._selectionService.onRequestScrollLines(K=>this.scrollLines(K.amount,K.suppressScrollEvent))),this.register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this.register(this._selectionService.onRequestRedraw(K=>this._renderService.handleSelectionChanged(K.start,K.end,K.columnSelectMode))),this.register(this._selectionService.onLinuxMouseSelection(K=>{this.textarea.value=K,this.textarea.focus(),this.textarea.select()})),this.register(this._onScroll.event(K=>{this.viewport.syncScrollArea(),this._selectionService.refresh()})),this.register((0,m.addDisposableDomListener)(this._viewportElement,"scroll",()=>this._selectionService.refresh())),this.linkifier2.attachToDom(this.screenElement,this._mouseService,this._renderService),this.register(this._instantiationService.createInstance(_.BufferDecorationRenderer,this.screenElement)),this.register((0,m.addDisposableDomListener)(this.element,"mousedown",K=>this._selectionService.handleMouseDown(K))),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(q.AccessibilityManager,this)),this.register(this.optionsService.onSpecificOptionChange("screenReaderMode",K=>this._handleScreenReaderModeOptionChange(K))),this.options.overviewRulerWidth&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(i.OverviewRulerRenderer,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRulerWidth",K=>{!this._overviewRulerRenderer&&K&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(i.OverviewRulerRenderer,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(c.DomRenderer,this.element,this.screenElement,this._viewportElement,this.linkifier2)}bindMouse(){const P=this,U=this.element;function G(Q){const oe=P._mouseService.getMouseReportCoords(Q,P.screenElement);if(!oe)return!1;let ge,xe;switch(Q.overrideType||Q.type){case"mousemove":xe=32,Q.buttons===void 0?(ge=3,Q.button!==void 0&&(ge=Q.button<3?Q.button:3)):ge=1&Q.buttons?0:4&Q.buttons?1:2&Q.buttons?2:3;break;case"mouseup":xe=0,ge=Q.button<3?Q.button:3;break;case"mousedown":xe=1,ge=Q.button<3?Q.button:3;break;case"wheel":if(P.viewport.getLinesScrolled(Q)===0)return!1;xe=Q.deltaY<0?0:1,ge=4;break;default:return!1}return!(xe===void 0||ge===void 0||ge>4)&&P.coreMouseService.triggerMouseEvent({col:oe.col,row:oe.row,x:oe.x,y:oe.y,button:ge,action:xe,ctrl:Q.ctrlKey,alt:Q.altKey,shift:Q.shiftKey})}const K={mouseup:null,wheel:null,mousedrag:null,mousemove:null},se={mouseup:Q=>(G(Q),Q.buttons||(this._document.removeEventListener("mouseup",K.mouseup),K.mousedrag&&this._document.removeEventListener("mousemove",K.mousedrag)),this.cancel(Q)),wheel:Q=>(G(Q),this.cancel(Q,!0)),mousedrag:Q=>{Q.buttons&&G(Q)},mousemove:Q=>{Q.buttons||G(Q)}};this.register(this.coreMouseService.onProtocolChange(Q=>{Q?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(Q)),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()),8&Q?K.mousemove||(U.addEventListener("mousemove",se.mousemove),K.mousemove=se.mousemove):(U.removeEventListener("mousemove",K.mousemove),K.mousemove=null),16&Q?K.wheel||(U.addEventListener("wheel",se.wheel,{passive:!1}),K.wheel=se.wheel):(U.removeEventListener("wheel",K.wheel),K.wheel=null),2&Q?K.mouseup||(U.addEventListener("mouseup",se.mouseup),K.mouseup=se.mouseup):(this._document.removeEventListener("mouseup",K.mouseup),U.removeEventListener("mouseup",K.mouseup),K.mouseup=null),4&Q?K.mousedrag||(K.mousedrag=se.mousedrag):(this._document.removeEventListener("mousemove",K.mousedrag),K.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this.register((0,m.addDisposableDomListener)(U,"mousedown",Q=>{if(Q.preventDefault(),this.focus(),this.coreMouseService.areMouseEventsActive&&!this._selectionService.shouldForceSelection(Q))return G(Q),K.mouseup&&this._document.addEventListener("mouseup",K.mouseup),K.mousedrag&&this._document.addEventListener("mousemove",K.mousedrag),this.cancel(Q)})),this.register((0,m.addDisposableDomListener)(U,"wheel",Q=>{if(!K.wheel){if(!this.buffer.hasScrollback){const oe=this.viewport.getLinesScrolled(Q);if(oe===0)return;const ge=z.C0.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(Q.deltaY<0?"A":"B");let xe="";for(let rt=0;rt<Math.abs(oe);rt++)xe+=ge;return this.coreService.triggerDataEvent(xe,!0),this.cancel(Q,!0)}return this.viewport.handleWheel(Q)?this.cancel(Q):void 0}},{passive:!1})),this.register((0,m.addDisposableDomListener)(U,"touchstart",Q=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchStart(Q),this.cancel(Q)},{passive:!0})),this.register((0,m.addDisposableDomListener)(U,"touchmove",Q=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchMove(Q)?void 0:this.cancel(Q)},{passive:!1}))}refresh(P,U){var G;(G=this._renderService)===null||G===void 0||G.refreshRows(P,U)}updateCursorStyle(P){var U;!((U=this._selectionService)===null||U===void 0)&&U.shouldColumnSelect(P)?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(P,U,G=0){var K;G===1?(super.scrollLines(P,U,G),this.refresh(0,this.rows-1)):(K=this.viewport)===null||K===void 0||K.scrollLines(P)}paste(P){(0,u.paste)(P,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(P){this._customKeyEventHandler=P}registerLinkProvider(P){return this.linkifier2.registerLinkProvider(P)}registerCharacterJoiner(P){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");const U=this._characterJoinerService.register(P);return this.refresh(0,this.rows-1),U}deregisterCharacterJoiner(P){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(P)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(P){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+P)}registerDecoration(P){return this._decorationService.registerDecoration(P)}hasSelection(){return!!this._selectionService&&this._selectionService.hasSelection}select(P,U,G){this._selectionService.setSelection(P,U,G)}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 P;(P=this._selectionService)===null||P===void 0||P.clearSelection()}selectAll(){var P;(P=this._selectionService)===null||P===void 0||P.selectAll()}selectLines(P,U){var G;(G=this._selectionService)===null||G===void 0||G.selectLines(P,U)}_keyDown(P){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(P)===!1)return!1;const U=this.browser.isMac&&this.options.macOptionIsMeta&&P.altKey;if(!U&&!this._compositionHelper.keydown(P))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(),!1;U||P.key!=="Dead"&&P.key!=="AltGraph"||(this._unprocessedDeadKey=!0);const G=(0,A.evaluateKeyboardEvent)(P,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(P),G.type===3||G.type===2){const K=this.rows-1;return this.scrollLines(G.type===2?-K:K),this.cancel(P,!0)}return G.type===1&&this.selectAll(),!!this._isThirdLevelShift(this.browser,P)||(G.cancel&&this.cancel(P,!0),!G.key||!!(P.key&&!P.ctrlKey&&!P.altKey&&!P.metaKey&&P.key.length===1&&P.key.charCodeAt(0)>=65&&P.key.charCodeAt(0)<=90)||(this._unprocessedDeadKey?(this._unprocessedDeadKey=!1,!0):(G.key!==z.C0.ETX&&G.key!==z.C0.CR||(this.textarea.value=""),this._onKey.fire({key:G.key,domEvent:P}),this._showCursor(),this.coreService.triggerDataEvent(G.key,!0),!this.optionsService.rawOptions.screenReaderMode||P.altKey||P.ctrlKey?this.cancel(P,!0):void(this._keyDownHandled=!0))))}_isThirdLevelShift(P,U){const G=P.isMac&&!this.options.macOptionIsMeta&&U.altKey&&!U.ctrlKey&&!U.metaKey||P.isWindows&&U.altKey&&U.ctrlKey&&!U.metaKey||P.isWindows&&U.getModifierState("AltGraph");return U.type==="keypress"?G:G&&(!U.keyCode||U.keyCode>47)}_keyUp(P){this._keyDownSeen=!1,this._customKeyEventHandler&&this._customKeyEventHandler(P)===!1||(function(U){return U.keyCode===16||U.keyCode===17||U.keyCode===18}(P)||this.focus(),this.updateCursorStyle(P),this._keyPressHandled=!1)}_keyPress(P){let U;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(P)===!1)return!1;if(this.cancel(P),P.charCode)U=P.charCode;else if(P.which===null||P.which===void 0)U=P.keyCode;else{if(P.which===0||P.charCode===0)return!1;U=P.which}return!(!U||(P.altKey||P.ctrlKey||P.metaKey)&&!this._isThirdLevelShift(this.browser,P)||(U=String.fromCharCode(U),this._onKey.fire({key:U,domEvent:P}),this._showCursor(),this.coreService.triggerDataEvent(U,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,0))}_inputEvent(P){if(P.data&&P.inputType==="insertText"&&(!P.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;const U=P.data;return this.coreService.triggerDataEvent(U,!0),this.cancel(P),!0}return!1}resize(P,U){P!==this.cols||U!==this.rows?super.resize(P,U):this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure()}_afterResize(P,U){var G,K;(G=this._charSizeService)===null||G===void 0||G.measure(),(K=this.viewport)===null||K===void 0||K.syncScrollArea(!0)}clear(){var P;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 U=1;U<this.rows;U++)this.buffer.lines.push(this.buffer.getBlankLine($.DEFAULT_ATTR_DATA));this._onScroll.fire({position:this.buffer.ydisp,source:0}),(P=this.viewport)===null||P===void 0||P.reset(),this.refresh(0,this.rows-1)}}reset(){var P,U;this.options.rows=this.rows,this.options.cols=this.cols;const G=this._customKeyEventHandler;this._setup(),super.reset(),(P=this._selectionService)===null||P===void 0||P.reset(),this._decorationService.reset(),(U=this.viewport)===null||U===void 0||U.reset(),this._customKeyEventHandler=G,this.refresh(0,this.rows-1)}clearTextureAtlas(){var P;(P=this._renderService)===null||P===void 0||P.clearTextureAtlas()}_reportFocus(){var P;!((P=this.element)===null||P===void 0)&&P.classList.contains("focus")?this.coreService.triggerDataEvent(z.C0.ESC+"[I"):this.coreService.triggerDataEvent(z.C0.ESC+"[O")}_reportWindowsOptions(P){if(this._renderService)switch(P){case V.WindowsOptionsReportType.GET_WIN_SIZE_PIXELS:const U=this._renderService.dimensions.css.canvas.width.toFixed(0),G=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${z.C0.ESC}[4;${G};${U}t`);break;case V.WindowsOptionsReportType.GET_CELL_SIZE_PIXELS:const K=this._renderService.dimensions.css.cell.width.toFixed(0),se=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${z.C0.ESC}[6;${se};${K}t`)}}cancel(P,U){if(this.options.cancelEvents||U)return P.preventDefault(),P.stopPropagation(),!1}}r.Terminal=X},9924:(y,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.TimeBasedDebouncer=void 0,r.TimeBasedDebouncer=class{constructor(n,u=1e3){this._renderCallback=n,this._debounceThresholdMS=u,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(n,u,m){this._rowCount=m,n=n!==void 0?n:0,u=u!==void 0?u:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,n):n,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,u):u;const l=Date.now();if(l-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=l,this._innerRefresh();else if(!this._additionalRefreshRequested){const p=l-this._lastRefreshMs,C=this._debounceThresholdMS-p;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=Date.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},C)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;const n=Math.max(this._rowStart,0),u=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(n,u)}}},1680:function(y,r,n){var u=this&&this.__decorate||function(o,c,h,f){var b,E=arguments.length,I=E<3?c:f===null?f=Object.getOwnPropertyDescriptor(c,h):f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")I=Reflect.decorate(o,c,h,f);else for(var v=o.length-1;v>=0;v--)(b=o[v])&&(I=(E<3?b(I):E>3?b(c,h,I):b(c,h))||I);return E>3&&I&&Object.defineProperty(c,h,I),I},m=this&&this.__param||function(o,c){return function(h,f){c(h,f,o)}};Object.defineProperty(r,"__esModule",{value:!0}),r.Viewport=void 0;const l=n(3656),p=n(4725),C=n(8460),S=n(844),_=n(2585);let i=r.Viewport=class extends S.Disposable{constructor(o,c,h,f,b,E,I,v){super(),this._viewportElement=o,this._scrollArea=c,this._bufferService=h,this._optionsService=f,this._charSizeService=b,this._renderService=E,this._coreBrowserService=I,this.scrollBarWidth=0,this._currentRowHeight=0,this._currentDeviceCellHeight=0,this._lastRecordedBufferLength=0,this._lastRecordedViewportHeight=0,this._lastRecordedBufferHeight=0,this._lastTouchY=0,this._lastScrollTop=0,this._wheelPartialScroll=0,this._refreshAnimationFrame=null,this._ignoreNextScrollEvent=!1,this._smoothScrollState={startTime:0,origin:-1,target:-1},this._onRequestScrollLines=this.register(new C.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this.scrollBarWidth=this._viewportElement.offsetWidth-this._scrollArea.offsetWidth||15,this.register((0,l.addDisposableDomListener)(this._viewportElement,"scroll",this._handleScroll.bind(this))),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate(x=>this._activeBuffer=x.activeBuffer)),this._renderDimensions=this._renderService.dimensions,this.register(this._renderService.onDimensionsChange(x=>this._renderDimensions=x)),this._handleThemeChange(v.colors),this.register(v.onChangeColors(x=>this._handleThemeChange(x))),this.register(this._optionsService.onSpecificOptionChange("scrollback",()=>this.syncScrollArea())),setTimeout(()=>this.syncScrollArea())}_handleThemeChange(o){this._viewportElement.style.backgroundColor=o.background.css}reset(){this._currentRowHeight=0,this._currentDeviceCellHeight=0,this._lastRecordedBufferLength=0,this._lastRecordedViewportHeight=0,this._lastRecordedBufferHeight=0,this._lastTouchY=0,this._lastScrollTop=0,this._coreBrowserService.window.requestAnimationFrame(()=>this.syncScrollArea())}_refresh(o){if(o)return this._innerRefresh(),void(this._refreshAnimationFrame!==null&&this._coreBrowserService.window.cancelAnimationFrame(this._refreshAnimationFrame));this._refreshAnimationFrame===null&&(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._charSizeService.height>0){this._currentRowHeight=this._renderService.dimensions.device.cell.height/this._coreBrowserService.dpr,this._currentDeviceCellHeight=this._renderService.dimensions.device.cell.height,this._lastRecordedViewportHeight=this._viewportElement.offsetHeight;const c=Math.round(this._currentRowHeight*this._lastRecordedBufferLength)+(this._lastRecordedViewportHeight-this._renderService.dimensions.css.canvas.height);this._lastRecordedBufferHeight!==c&&(this._lastRecordedBufferHeight=c,this._scrollArea.style.height=this._lastRecordedBufferHeight+"px")}const o=this._bufferService.buffer.ydisp*this._currentRowHeight;this._viewportElement.scrollTop!==o&&(this._ignoreNextScrollEvent=!0,this._viewportElement.scrollTop=o),this._refreshAnimationFrame=null}syncScrollArea(o=!1){if(this._lastRecordedBufferLength!==this._bufferService.buffer.lines.length)return this._lastRecordedBufferLength=this._bufferService.buffer.lines.length,void this._refresh(o);this._lastRecordedViewportHeight===this._renderService.dimensions.css.canvas.height&&this._lastScrollTop===this._activeBuffer.ydisp*this._currentRowHeight&&this._renderDimensions.device.cell.height===this._currentDeviceCellHeight||this._refresh(o)}_handleScroll(o){if(this._lastScrollTop=this._viewportElement.scrollTop,!this._viewportElement.offsetParent)return;if(this._ignoreNextScrollEvent)return this._ignoreNextScrollEvent=!1,void this._onRequestScrollLines.fire({amount:0,suppressScrollEvent:!0});const c=Math.round(this._lastScrollTop/this._currentRowHeight)-this._bufferService.buffer.ydisp;this._onRequestScrollLines.fire({amount:c,suppressScrollEvent:!0})}_smoothScroll(){if(this._isDisposed||this._smoothScrollState.origin===-1||this._smoothScrollState.target===-1)return;const o=this._smoothScrollPercent();this._viewportElement.scrollTop=this._smoothScrollState.origin+Math.round(o*(this._smoothScrollState.target-this._smoothScrollState.origin)),o<1?this._coreBrowserService.window.requestAnimationFrame(()=>this._smoothScroll()):this._clearSmoothScrollState()}_smoothScrollPercent(){return this._optionsService.rawOptions.smoothScrollDuration&&this._smoothScrollState.startTime?Math.max(Math.min((Date.now()-this._smoothScrollState.startTime)/this._optionsService.rawOptions.smoothScrollDuration,1),0):1}_clearSmoothScrollState(){this._smoothScrollState.startTime=0,this._smoothScrollState.origin=-1,this._smoothScrollState.target=-1}_bubbleScroll(o,c){const h=this._viewportElement.scrollTop+this._lastRecordedViewportHeight;return!(c<0&&this._viewportElement.scrollTop!==0||c>0&&h<this._lastRecordedBufferHeight)||(o.cancelable&&o.preventDefault(),!1)}handleWheel(o){const c=this._getPixelsScrolled(o);return c!==0&&(this._optionsService.rawOptions.smoothScrollDuration?(this._smoothScrollState.startTime=Date.now(),this._smoothScrollPercent()<1?(this._smoothScrollState.origin=this._viewportElement.scrollTop,this._smoothScrollState.target===-1?this._smoothScrollState.target=this._viewportElement.scrollTop+c:this._smoothScrollState.target+=c,this._smoothScrollState.target=Math.max(Math.min(this._smoothScrollState.target,this._viewportElement.scrollHeight),0),this._smoothScroll()):this._clearSmoothScrollState()):this._viewportElement.scrollTop+=c,this._bubbleScroll(o,c))}scrollLines(o){if(o!==0)if(this._optionsService.rawOptions.smoothScrollDuration){const c=o*this._currentRowHeight;this._smoothScrollState.startTime=Date.now(),this._smoothScrollPercent()<1?(this._smoothScrollState.origin=this._viewportElement.scrollTop,this._smoothScrollState.target=this._smoothScrollState.origin+c,this._smoothScrollState.target=Math.max(Math.min(this._smoothScrollState.target,this._viewportElement.scrollHeight),0),this._smoothScroll()):this._clearSmoothScrollState()}else this._onRequestScrollLines.fire({amount:o,suppressScrollEvent:!1})}_getPixelsScrolled(o){if(o.deltaY===0||o.shiftKey)return 0;let c=this._applyScrollModifier(o.deltaY,o);return o.deltaMode===WheelEvent.DOM_DELTA_LINE?c*=this._currentRowHeight:o.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(c*=this._currentRowHeight*this._bufferService.rows),c}getBufferElements(o,c){var h;let f,b="";const E=[],I=c??this._bufferService.buffer.lines.length,v=this._bufferService.buffer.lines;for(let x=o;x<I;x++){const L=v.get(x);if(!L)continue;const k=(h=v.get(x+1))===null||h===void 0?void 0:h.isWrapped;if(b+=L.translateToString(!k),!k||x===v.length-1){const D=document.createElement("div");D.textContent=b,E.push(D),b.length>0&&(f=D),b=""}}return{bufferElements:E,cursorElement:f}}getLinesScrolled(o){if(o.deltaY===0||o.shiftKey)return 0;let c=this._applyScrollModifier(o.deltaY,o);return o.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(c/=this._currentRowHeight+0,this._wheelPartialScroll+=c,c=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):o.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(c*=this._bufferService.rows),c}_applyScrollModifier(o,c){const h=this._optionsService.rawOptions.fastScrollModifier;return h==="alt"&&c.altKey||h==="ctrl"&&c.ctrlKey||h==="shift"&&c.shiftKey?o*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:o*this._optionsService.rawOptions.scrollSensitivity}handleTouchStart(o){this._lastTouchY=o.touches[0].pageY}handleTouchMove(o){const c=this._lastTouchY-o.touches[0].pageY;return this._lastTouchY=o.touches[0].pageY,c!==0&&(this._viewportElement.scrollTop+=c,this._bubbleScroll(o,c))}};r.Viewport=i=u([m(2,_.IBufferService),m(3,_.IOptionsService),m(4,p.ICharSizeService),m(5,p.IRenderService),m(6,p.ICoreBrowserService),m(7,p.IThemeService)],i)},3107:function(y,r,n){var u=this&&this.__decorate||function(i,o,c,h){var f,b=arguments.length,E=b<3?o:h===null?h=Object.getOwnPropertyDescriptor(o,c):h;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(i,o,c,h);else for(var I=i.length-1;I>=0;I--)(f=i[I])&&(E=(b<3?f(E):b>3?f(o,c,E):f(o,c))||E);return b>3&&E&&Object.defineProperty(o,c,E),E},m=this&&this.__param||function(i,o){return function(c,h){o(c,h,i)}};Object.defineProperty(r,"__esModule",{value:!0}),r.BufferDecorationRenderer=void 0;const l=n(3656),p=n(4725),C=n(844),S=n(2585);let _=r.BufferDecorationRenderer=class extends C.Disposable{constructor(i,o,c,h){super(),this._screenElement=i,this._bufferService=o,this._decorationService=c,this._renderService=h,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((0,l.addDisposableDomListener)(window,"resize",()=>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(f=>this._removeDecoration(f))),this.register((0,C.toDisposable)(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(const i of this._decorationService.decorations)this._renderDecoration(i);this._dimensionsChanged=!1}_renderDecoration(i){this._refreshStyle(i),this._dimensionsChanged&&this._refreshXPosition(i)}_createElement(i){var o,c;const h=document.createElement("div");h.classList.add("xterm-decoration"),h.classList.toggle("xterm-decoration-top-layer",((o=i==null?void 0:i.options)===null||o===void 0?void 0:o.layer)==="top"),h.style.width=`${Math.round((i.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,h.style.height=(i.options.height||1)*this._renderService.dimensions.css.cell.height+"px",h.style.top=(i.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height+"px",h.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;const f=(c=i.options.x)!==null&&c!==void 0?c:0;return f&&f>this._bufferService.cols&&(h.style.display="none"),this._refreshXPosition(i,h),h}_refreshStyle(i){const o=i.marker.line-this._bufferService.buffers.active.ydisp;if(o<0||o>=this._bufferService.rows)i.element&&(i.element.style.display="none",i.onRenderEmitter.fire(i.element));else{let c=this._decorationElements.get(i);c||(c=this._createElement(i),i.element=c,this._decorationElements.set(i,c),this._container.appendChild(c),i.onDispose(()=>{this._decorationElements.delete(i),c.remove()})),c.style.top=o*this._renderService.dimensions.css.cell.height+"px",c.style.display=this._altBufferIsActive?"none":"block",i.onRenderEmitter.fire(c)}}_refreshXPosition(i,o=i.element){var c;if(!o)return;const h=(c=i.options.x)!==null&&c!==void 0?c:0;(i.options.anchor||"left")==="right"?o.style.right=h?h*this._renderService.dimensions.css.cell.width+"px":"":o.style.left=h?h*this._renderService.dimensions.css.cell.width+"px":""}_removeDecoration(i){var o;(o=this._decorationElements.get(i))===null||o===void 0||o.remove(),this._decorationElements.delete(i),i.dispose()}};r.BufferDecorationRenderer=_=u([m(1,S.IBufferService),m(2,S.IDecorationService),m(3,p.IRenderService)],_)},5871:(y,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.ColorZoneStore=void 0,r.ColorZoneStore=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(n){if(n.options.overviewRulerOptions){for(const u of this._zones)if(u.color===n.options.overviewRulerOptions.color&&u.position===n.options.overviewRulerOptions.position){if(this._lineIntersectsZone(u,n.marker.line))return;if(this._lineAdjacentToZone(u,n.marker.line,n.options.overviewRulerOptions.position))return void this._addLineToZone(u,n.marker.line)}if(this._zonePoolIndex<this._zonePool.length)return this._zonePool[this._zonePoolIndex].color=n.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=n.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=n.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=n.marker.line,void this._zones.push(this._zonePool[this._zonePoolIndex++]);this._zones.push({color:n.options.overviewRulerOptions.color,position:n.options.overviewRulerOptions.position,startBufferLine:n.marker.line,endBufferLine:n.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(n){this._linePadding=n}_lineIntersectsZone(n,u){return u>=n.startBufferLine&&u<=n.endBufferLine}_lineAdjacentToZone(n,u,m){return u>=n.startBufferLine-this._linePadding[m||"full"]&&u<=n.endBufferLine+this._linePadding[m||"full"]}_addLineToZone(n,u){n.startBufferLine=Math.min(n.startBufferLine,u),n.endBufferLine=Math.max(n.endBufferLine,u)}}},5744:function(y,r,n){var u=this&&this.__decorate||function(f,b,E,I){var v,x=arguments.length,L=x<3?b:I===null?I=Object.getOwnPropertyDescriptor(b,E):I;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")L=Reflect.decorate(f,b,E,I);else for(var k=f.length-1;k>=0;k--)(v=f[k])&&(L=(x<3?v(L):x>3?v(b,E,L):v(b,E))||L);return x>3&&L&&Object.defineProperty(b,E,L),L},m=this&&this.__param||function(f,b){return function(E,I){b(E,I,f)}};Object.defineProperty(r,"__esModule",{value:!0}),r.OverviewRulerRenderer=void 0;const l=n(5871),p=n(3656),C=n(4725),S=n(844),_=n(2585),i={full:0,left:0,center:0,right:0},o={full:0,left:0,center:0,right:0},c={full:0,left:0,center:0,right:0};let h=r.OverviewRulerRenderer=class extends S.Disposable{get _width(){return this._optionsService.options.overviewRulerWidth||0}constructor(f,b,E,I,v,x,L){var k;super(),this._viewportElement=f,this._screenElement=b,this._bufferService=E,this._decorationService=I,this._renderService=v,this._optionsService=x,this._coreBrowseService=L,this._colorZoneStore=new l.ColorZoneStore,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=document.createElement("canvas"),this._canvas.classList.add("xterm-decoration-overview-ruler"),this._refreshCanvasDimensions(),(k=this._viewportElement.parentElement)===null||k===void 0||k.insertBefore(this._canvas,this._viewportElement);const D=this._canvas.getContext("2d");if(!D)throw new Error("Ctx cannot be null");this._ctx=D,this._registerDecorationListeners(),this._registerBufferChangeListeners(),this._registerDimensionChangeListeners(),this.register((0,S.toDisposable)(()=>{var B;(B=this._canvas)===null||B===void 0||B.remove()}))}_registerDecorationListeners(){this.register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh(void 0,!0))),this.register(this._decorationService.onDecorationRemoved(()=>this._queueRefresh(void 0,!0)))}_registerBufferChangeListeners(){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())}))}_registerDimensionChangeListeners(){this.register(this._renderService.onRender(()=>{this._containerHeight&&this._containerHeight===this._screenElement.clientHeight||(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)})),this.register(this._optionsService.onSpecificOptionChange("overviewRulerWidth",()=>this._queueRefresh(!0))),this.register((0,p.addDisposableDomListener)(this._coreBrowseService.window,"resize",()=>this._queueRefresh(!0))),this._queueRefresh(!0)}_refreshDrawConstants(){const f=Math.floor(this._canvas.width/3),b=Math.ceil(this._canvas.width/3);o.full=this._canvas.width,o.left=f,o.center=b,o.right=f,this._refreshDrawHeightConstants(),c.full=0,c.left=0,c.center=o.left,c.right=o.left+o.center}_refreshDrawHeightConstants(){i.full=Math.round(2*this._coreBrowseService.dpr);const f=this._canvas.height/this._bufferService.buffer.lines.length,b=Math.round(Math.max(Math.min(f,12),6)*this._coreBrowseService.dpr);i.left=b,i.center=b,i.right=b}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*i.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*i.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*i.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*i.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._coreBrowseService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowseService.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(const b of this._decorationService.decorations)this._colorZoneStore.addDecoration(b);this._ctx.lineWidth=1;const f=this._colorZoneStore.zones;for(const b of f)b.position!=="full"&&this._renderColorZone(b);for(const b of f)b.position==="full"&&this._renderColorZone(b);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderColorZone(f){this._ctx.fillStyle=f.color,this._ctx.fillRect(c[f.position||"full"],Math.round((this._canvas.height-1)*(f.startBufferLine/this._bufferService.buffers.active.lines.length)-i[f.position||"full"]/2),o[f.position||"full"],Math.round((this._canvas.height-1)*((f.endBufferLine-f.startBufferLine)/this._bufferService.buffers.active.lines.length)+i[f.position||"full"]))}_queueRefresh(f,b){this._shouldUpdateDimensions=f||this._shouldUpdateDimensions,this._shouldUpdateAnchor=b||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowseService.window.requestAnimationFrame(()=>{this._refreshDecorations(),this._animationFrame=void 0}))}};r.OverviewRulerRenderer=h=u([m(2,_.IBufferService),m(3,_.IDecorationService),m(4,C.IRenderService),m(5,_.IOptionsService),m(6,C.ICoreBrowserService)],h)},2950:function(y,r,n){var u=this&&this.__decorate||function(_,i,o,c){var h,f=arguments.length,b=f<3?i:c===null?c=Object.getOwnPropertyDescriptor(i,o):c;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")b=Reflect.decorate(_,i,o,c);else for(var E=_.length-1;E>=0;E--)(h=_[E])&&(b=(f<3?h(b):f>3?h(i,o,b):h(i,o))||b);return f>3&&b&&Object.defineProperty(i,o,b),b},m=this&&this.__param||function(_,i){return function(o,c){i(o,c,_)}};Object.defineProperty(r,"__esModule",{value:!0}),r.CompositionHelper=void 0;const l=n(4725),p=n(2585),C=n(2584);let S=r.CompositionHelper=class{get isComposing(){return this._isComposing}constructor(_,i,o,c,h,f){this._textarea=_,this._compositionView=i,this._bufferService=o,this._optionsService=c,this._coreService=h,this._renderService=f,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(_){this._compositionView.textContent=_.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(_){if(this._isComposing||this._isSendingComposition){if(_.keyCode===229||_.keyCode===16||_.keyCode===17||_.keyCode===18)return!1;this._finalizeComposition(!1)}return _.keyCode!==229||(this._handleAnyTextareaChanges(),!1)}_finalizeComposition(_){if(this._compositionView.classList.remove("active"),this._isComposing=!1,_){const i={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){let o;this._isSendingComposition=!1,i.start+=this._dataAlreadySent.length,o=this._isComposing?this._textarea.value.substring(i.start,i.end):this._textarea.value.substring(i.start),o.length>0&&this._coreService.triggerDataEvent(o,!0)}},0)}else{this._isSendingComposition=!1;const i=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(i,!0)}}_handleAnyTextareaChanges(){const _=this._textarea.value;setTimeout(()=>{if(!this._isComposing){const i=this._textarea.value,o=i.replace(_,"");this._dataAlreadySent=o,i.length>_.length?this._coreService.triggerDataEvent(o,!0):i.length<_.length?this._coreService.triggerDataEvent(`${C.C0.DEL}`,!0):i.length===_.length&&i!==_&&this._coreService.triggerDataEvent(i,!0)}},0)}updateCompositionElements(_){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){const i=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),o=this._renderService.dimensions.css.cell.height,c=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,h=i*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=h+"px",this._compositionView.style.top=c+"px",this._compositionView.style.height=o+"px",this._compositionView.style.lineHeight=o+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";const f=this._compositionView.getBoundingClientRect();this._textarea.style.left=h+"px",this._textarea.style.top=c+"px",this._textarea.style.width=Math.max(f.width,1)+"px",this._textarea.style.height=Math.max(f.height,1)+"px",this._textarea.style.lineHeight=f.height+"px"}_||setTimeout(()=>this.updateCompositionElements(!0),0)}}};r.CompositionHelper=S=u([m(2,p.IBufferService),m(3,p.IOptionsService),m(4,p.ICoreService),m(5,l.IRenderService)],S)},9806:(y,r)=>{function n(u,m,l){const p=l.getBoundingClientRect(),C=u.getComputedStyle(l),S=parseInt(C.getPropertyValue("padding-left")),_=parseInt(C.getPropertyValue("padding-top"));return[m.clientX-p.left-S,m.clientY-p.top-_]}Object.defineProperty(r,"__esModule",{value:!0}),r.getCoords=r.getCoordsRelativeToElement=void 0,r.getCoordsRelativeToElement=n,r.getCoords=function(u,m,l,p,C,S,_,i,o){if(!S)return;const c=n(u,m,l);return c?(c[0]=Math.ceil((c[0]+(o?_/2:0))/_),c[1]=Math.ceil(c[1]/i),c[0]=Math.min(Math.max(c[0],1),p+(o?1:0)),c[1]=Math.min(Math.max(c[1],1),C),c):void 0}},9504:(y,r,n)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.moveToCellSequence=void 0;const u=n(2584);function m(i,o,c,h){const f=i-l(i,c),b=o-l(o,c),E=Math.abs(f-b)-function(I,v,x){let L=0;const k=I-l(I,x),D=v-l(v,x);for(let B=0;B<Math.abs(k-D);B++){const F=p(I,v)==="A"?-1:1,Y=x.buffer.lines.get(k+F*B);Y!=null&&Y.isWrapped&&L++}return L}(i,o,c);return _(E,S(p(i,o),h))}function l(i,o){let c=0,h=o.buffer.lines.get(i),f=h==null?void 0:h.isWrapped;for(;f&&i>=0&&i<o.rows;)c++,h=o.buffer.lines.get(--i),f=h==null?void 0:h.isWrapped;return c}function p(i,o){return i>o?"A":"B"}function C(i,o,c,h,f,b){let E=i,I=o,v="";for(;E!==c||I!==h;)E+=f?1:-1,f&&E>b.cols-1?(v+=b.buffer.translateBufferLineToString(I,!1,i,E),E=0,i=0,I++):!f&&E<0&&(v+=b.buffer.translateBufferLineToString(I,!1,0,i+1),E=b.cols-1,i=E,I--);return v+b.buffer.translateBufferLineToString(I,!1,i,E)}function S(i,o){const c=o?"O":"[";return u.C0.ESC+c+i}function _(i,o){i=Math.floor(i);let c="";for(let h=0;h<i;h++)c+=o;return c}r.moveToCellSequence=function(i,o,c,h){const f=c.buffer.x,b=c.buffer.y;if(!c.buffer.hasScrollback)return function(v,x,L,k,D,B){return m(x,k,D,B).length===0?"":_(C(v,x,v,x-l(x,D),!1,D).length,S("D",B))}(f,b,0,o,c,h)+m(b,o,c,h)+function(v,x,L,k,D,B){let F;F=m(x,k,D,B).length>0?k-l(k,D):x;const Y=k,$=function(z,A,M,T,N,V){let q;return q=m(M,T,N,V).length>0?T-l(T,N):A,z<M&&q<=T||z>=M&&q<T?"C":"D"}(v,x,L,k,D,B);return _(C(v,F,L,Y,$==="C",D).length,S($,B))}(f,b,i,o,c,h);let E;if(b===o)return E=f>i?"D":"C",_(Math.abs(f-i),S(E,h));E=b>o?"D":"C";const I=Math.abs(b-o);return _(function(v,x){return x.cols-v}(b>o?i:f,c)+(I-1)*c.cols+1+((b>o?f:i)-1),S(E,h))}},1296:function(y,r,n){var u=this&&this.__decorate||function(D,B,F,Y){var $,z=arguments.length,A=z<3?B:Y===null?Y=Object.getOwnPropertyDescriptor(B,F):Y;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")A=Reflect.decorate(D,B,F,Y);else for(var M=D.length-1;M>=0;M--)($=D[M])&&(A=(z<3?$(A):z>3?$(B,F,A):$(B,F))||A);return z>3&&A&&Object.defineProperty(B,F,A),A},m=this&&this.__param||function(D,B){return function(F,Y){B(F,Y,D)}};Object.defineProperty(r,"__esModule",{value:!0}),r.DomRenderer=void 0;const l=n(3787),p=n(2550),C=n(2223),S=n(6171),_=n(4725),i=n(8055),o=n(8460),c=n(844),h=n(2585),f="xterm-dom-renderer-owner-",b="xterm-rows",E="xterm-fg-",I="xterm-bg-",v="xterm-focus",x="xterm-selection";let L=1,k=r.DomRenderer=class extends c.Disposable{constructor(D,B,F,Y,$,z,A,M,T,N){super(),this._element=D,this._screenElement=B,this._viewportElement=F,this._linkifier2=Y,this._charSizeService=z,this._optionsService=A,this._bufferService=M,this._coreBrowserService=T,this._themeService=N,this._terminalClass=L++,this._rowElements=[],this.onRequestRedraw=this.register(new o.EventEmitter).event,this._rowContainer=document.createElement("div"),this._rowContainer.classList.add(b),this._rowContainer.style.lineHeight="normal",this._rowContainer.setAttribute("aria-hidden","true"),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=document.createElement("div"),this._selectionContainer.classList.add(x),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=(0,S.createRenderDimensions)(),this._updateDimensions(),this.register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this.register(this._themeService.onChangeColors(V=>this._injectCss(V))),this._injectCss(this._themeService.colors),this._rowFactory=$.createInstance(l.DomRendererRowFactory,document),this._element.classList.add(f+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this.register(this._linkifier2.onShowLinkUnderline(V=>this._handleLinkHover(V))),this.register(this._linkifier2.onHideLinkUnderline(V=>this._handleLinkLeave(V))),this.register((0,c.toDisposable)(()=>{this._element.classList.remove(f+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new p.WidthCache(document),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){const D=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*D,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*D),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/D),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/D),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(const F of this._rowElements)F.style.width=`${this.dimensions.css.canvas.width}px`,F.style.height=`${this.dimensions.css.cell.height}px`,F.style.lineHeight=`${this.dimensions.css.cell.height}px`,F.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));const B=`${this._terminalSelector} .${b} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=B,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(D){this._themeStyleElement||(this._themeStyleElement=document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let B=`${this._terminalSelector} .${b} { color: ${D.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;B+=`${this._terminalSelector} .${b} .xterm-dim { color: ${i.color.multiplyOpacity(D.foreground,.5).css};}`,B+=`${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;}`,B+="@keyframes blink_box_shadow_"+this._terminalClass+" { 50% { border-bottom-style: hidden; }}",B+="@keyframes blink_block_"+this._terminalClass+` { 0% { background-color: ${D.cursor.css}; color: ${D.cursorAccent.css}; } 50% { background-color: inherit; color: ${D.cursor.css}; }}`,B+=`${this._terminalSelector} .${b}.${v} .xterm-cursor.xterm-cursor-blink:not(.xterm-cursor-block) { animation: blink_box_shadow_`+this._terminalClass+` 1s step-end infinite;}${this._terminalSelector} .${b}.${v} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: blink_block_`+this._terminalClass+` 1s step-end infinite;}${this._terminalSelector} .${b} .xterm-cursor.xterm-cursor-block { background-color: ${D.cursor.css}; color: ${D.cursorAccent.css};}${this._terminalSelector} .${b} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${D.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${b} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${D.cursor.css} inset;}${this._terminalSelector} .${b} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${D.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,B+=`${this._terminalSelector} .${x} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${x} div { position: absolute; background-color: ${D.selectionBackgroundOpaque.css};}${this._terminalSelector} .${x} div { position: absolute; background-color: ${D.selectionInactiveBackgroundOpaque.css};}`;for(const[F,Y]of D.ansi.entries())B+=`${this._terminalSelector} .${E}${F} { color: ${Y.css}; }${this._terminalSelector} .${E}${F}.xterm-dim { color: ${i.color.multiplyOpacity(Y,.5).css}; }${this._terminalSelector} .${I}${F} { background-color: ${Y.css}; }`;B+=`${this._terminalSelector} .${E}${C.INVERTED_DEFAULT_COLOR} { color: ${i.color.opaque(D.background).css}; }${this._terminalSelector} .${E}${C.INVERTED_DEFAULT_COLOR}.xterm-dim { color: ${i.color.multiplyOpacity(i.color.opaque(D.background),.5).css}; }${this._terminalSelector} .${I}${C.INVERTED_DEFAULT_COLOR} { background-color: ${D.foreground.css}; }`,this._themeStyleElement.textContent=B}_setDefaultSpacing(){const D=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${D}px`,this._rowFactory.defaultSpacing=D}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(D,B){for(let F=this._rowElements.length;F<=B;F++){const Y=document.createElement("div");this._rowContainer.appendChild(Y),this._rowElements.push(Y)}for(;this._rowElements.length>B;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(D,B){this._refreshRowElements(D,B),this._updateDimensions()}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(v)}handleFocus(){this._rowContainer.classList.add(v),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(D,B,F){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(D,B,F),this.renderRows(0,this._bufferService.rows-1),!D||!B)return;const Y=D[1]-this._bufferService.buffer.ydisp,$=B[1]-this._bufferService.buffer.ydisp,z=Math.max(Y,0),A=Math.min($,this._bufferService.rows-1);if(z>=this._bufferService.rows||A<0)return;const M=document.createDocumentFragment();if(F){const T=D[0]>B[0];M.appendChild(this._createSelectionElement(z,T?B[0]:D[0],T?D[0]:B[0],A-z+1))}else{const T=Y===z?D[0]:0,N=z===$?B[0]:this._bufferService.cols;M.appendChild(this._createSelectionElement(z,T,N));const V=A-z-1;if(M.appendChild(this._createSelectionElement(z+1,0,this._bufferService.cols,V)),z!==A){const q=$===A?B[0]:this._bufferService.cols;M.appendChild(this._createSelectionElement(A,0,q))}}this._selectionContainer.appendChild(M)}_createSelectionElement(D,B,F,Y=1){const $=document.createElement("div");return $.style.height=Y*this.dimensions.css.cell.height+"px",$.style.top=D*this.dimensions.css.cell.height+"px",$.style.left=B*this.dimensions.css.cell.width+"px",$.style.width=this.dimensions.css.cell.width*(F-B)+"px",$}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(const D of this._rowElements)D.replaceChildren()}renderRows(D,B){const F=this._bufferService.buffer,Y=F.ybase+F.y,$=Math.min(F.x,this._bufferService.cols-1),z=this._optionsService.rawOptions.cursorBlink,A=this._optionsService.rawOptions.cursorStyle,M=this._optionsService.rawOptions.cursorInactiveStyle;for(let T=D;T<=B;T++){const N=T+F.ydisp,V=this._rowElements[T],q=F.lines.get(N);if(!V||!q)break;V.replaceChildren(...this._rowFactory.createRow(q,N,N===Y,A,M,$,z,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${f}${this._terminalClass}`}_handleLinkHover(D){this._setCellUnderline(D.x1,D.x2,D.y1,D.y2,D.cols,!0)}_handleLinkLeave(D){this._setCellUnderline(D.x1,D.x2,D.y1,D.y2,D.cols,!1)}_setCellUnderline(D,B,F,Y,$,z){F<0&&(D=0),Y<0&&(B=0);const A=this._bufferService.rows-1;F=Math.max(Math.min(F,A),0),Y=Math.max(Math.min(Y,A),0),$=Math.min($,this._bufferService.cols);const M=this._bufferService.buffer,T=M.ybase+M.y,N=Math.min(M.x,$-1),V=this._optionsService.rawOptions.cursorBlink,q=this._optionsService.rawOptions.cursorStyle,J=this._optionsService.rawOptions.cursorInactiveStyle;for(let X=F;X<=Y;++X){const ce=X+M.ydisp,P=this._rowElements[X],U=M.lines.get(ce);if(!P||!U)break;P.replaceChildren(...this._rowFactory.createRow(U,ce,ce===T,q,J,N,V,this.dimensions.css.cell.width,this._widthCache,z?X===F?D:0:-1,z?(X===Y?B:$)-1:-1))}}};r.DomRenderer=k=u([m(4,h.IInstantiationService),m(5,_.ICharSizeService),m(6,h.IOptionsService),m(7,h.IBufferService),m(8,_.ICoreBrowserService),m(9,_.IThemeService)],k)},3787:function(y,r,n){var u=this&&this.__decorate||function(E,I,v,x){var L,k=arguments.length,D=k<3?I:x===null?x=Object.getOwnPropertyDescriptor(I,v):x;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")D=Reflect.decorate(E,I,v,x);else for(var B=E.length-1;B>=0;B--)(L=E[B])&&(D=(k<3?L(D):k>3?L(I,v,D):L(I,v))||D);return k>3&&D&&Object.defineProperty(I,v,D),D},m=this&&this.__param||function(E,I){return function(v,x){I(v,x,E)}};Object.defineProperty(r,"__esModule",{value:!0}),r.DomRendererRowFactory=void 0;const l=n(2223),p=n(643),C=n(511),S=n(2585),_=n(8055),i=n(4725),o=n(4269),c=n(6171),h=n(3734);let f=r.DomRendererRowFactory=class{constructor(E,I,v,x,L,k,D){this._document=E,this._characterJoinerService=I,this._optionsService=v,this._coreBrowserService=x,this._coreService=L,this._decorationService=k,this._themeService=D,this._workCell=new C.CellData,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(E,I,v){this._selectionStart=E,this._selectionEnd=I,this._columnSelectMode=v}createRow(E,I,v,x,L,k,D,B,F,Y,$){const z=[],A=this._characterJoinerService.getJoinedCharacters(I),M=this._themeService.colors;let T,N=E.getNoBgTrimmedLength();v&&N<k+1&&(N=k+1);let V=0,q="",J=0,X=0,ce=0,P=!1,U=0,G=!1,K=0;const se=[],Q=Y!==-1&&$!==-1;for(let oe=0;oe<N;oe++){E.loadCell(oe,this._workCell);let ge=this._workCell.getWidth();if(ge===0)continue;let xe=!1,rt=oe,ie=this._workCell;if(A.length>0&&oe===A[0][0]){xe=!0;const he=A.shift();ie=new o.JoinedCellData(this._workCell,E.translateToString(!0,he[0],he[1]),he[1]-he[0]),rt=he[1]-1,ge=ie.getWidth()}const pt=this._isCellInSelection(oe,I),gs=v&&oe===k,vs=Q&&oe>=Y&&oe<=$;let Ss=!1;this._decorationService.forEachDecorationAtCell(oe,I,void 0,he=>{Ss=!0});let kt=ie.getChars()||p.WHITESPACE_CELL_CHAR;if(kt===" "&&(ie.isUnderline()||ie.isOverline())&&(kt=" "),K=ge*B-F.get(kt,ie.isBold(),ie.isItalic()),T){if(V&&(pt&&G||!pt&&!G&&ie.bg===J)&&(pt&&G&&M.selectionForeground||ie.fg===X)&&ie.extended.ext===ce&&vs===P&&K===U&&!gs&&!xe&&!Ss){q+=kt,V++;continue}V&&(T.textContent=q),T=this._document.createElement("span"),V=0,q=""}else T=this._document.createElement("span");if(J=ie.bg,X=ie.fg,ce=ie.extended.ext,P=vs,U=K,G=pt,xe&&k>=oe&&k<=rt&&(k=oe),!this._coreService.isCursorHidden&&gs){if(se.push("xterm-cursor"),this._coreBrowserService.isFocused)D&&se.push("xterm-cursor-blink"),se.push(x==="bar"?"xterm-cursor-bar":x==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(L)switch(L){case"outline":se.push("xterm-cursor-outline");break;case"block":se.push("xterm-cursor-block");break;case"bar":se.push("xterm-cursor-bar");break;case"underline":se.push("xterm-cursor-underline")}}if(ie.isBold()&&se.push("xterm-bold"),ie.isItalic()&&se.push("xterm-italic"),ie.isDim()&&se.push("xterm-dim"),q=ie.isInvisible()?p.WHITESPACE_CELL_CHAR:ie.getChars()||p.WHITESPACE_CELL_CHAR,ie.isUnderline()&&(se.push(`xterm-underline-${ie.extended.underlineStyle}`),q===" "&&(q=" "),!ie.isUnderlineColorDefault()))if(ie.isUnderlineColorRGB())T.style.textDecorationColor=`rgb(${h.AttributeData.toColorRGB(ie.getUnderlineColor()).join(",")})`;else{let he=ie.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&ie.isBold()&&he<8&&(he+=8),T.style.textDecorationColor=M.ansi[he].css}ie.isOverline()&&(se.push("xterm-overline"),q===" "&&(q=" ")),ie.isStrikethrough()&&se.push("xterm-strikethrough"),vs&&(T.style.textDecoration="underline");let Ae=ie.getFgColor(),mt=ie.getFgColorMode(),Ue=ie.getBgColor(),gt=ie.getBgColorMode();const bs=!!ie.isInverse();if(bs){const he=Ae;Ae=Ue,Ue=he;const ho=mt;mt=gt,gt=ho}let ze,Cs,We,vt=!1;switch(this._decorationService.forEachDecorationAtCell(oe,I,void 0,he=>{he.options.layer!=="top"&&vt||(he.backgroundColorRGB&&(gt=50331648,Ue=he.backgroundColorRGB.rgba>>8&16777215,ze=he.backgroundColorRGB),he.foregroundColorRGB&&(mt=50331648,Ae=he.foregroundColorRGB.rgba>>8&16777215,Cs=he.foregroundColorRGB),vt=he.options.layer==="top")}),!vt&&pt&&(ze=this._coreBrowserService.isFocused?M.selectionBackgroundOpaque:M.selectionInactiveBackgroundOpaque,Ue=ze.rgba>>8&16777215,gt=50331648,vt=!0,M.selectionForeground&&(mt=50331648,Ae=M.selectionForeground.rgba>>8&16777215,Cs=M.selectionForeground)),vt&&se.push("xterm-decoration-top"),gt){case 16777216:case 33554432:We=M.ansi[Ue],se.push(`xterm-bg-${Ue}`);break;case 50331648:We=_.rgba.toColor(Ue>>16,Ue>>8&255,255&Ue),this._addStyle(T,`background-color:#${b((Ue>>>0).toString(16),"0",6)}`);break;default:bs?(We=M.foreground,se.push(`xterm-bg-${l.INVERTED_DEFAULT_COLOR}`)):We=M.background}switch(ze||ie.isDim()&&(ze=_.color.multiplyOpacity(We,.5)),mt){case 16777216:case 33554432:ie.isBold()&&Ae<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(Ae+=8),this._applyMinimumContrast(T,We,M.ansi[Ae],ie,ze,void 0)||se.push(`xterm-fg-${Ae}`);break;case 50331648:const he=_.rgba.toColor(Ae>>16&255,Ae>>8&255,255&Ae);this._applyMinimumContrast(T,We,he,ie,ze,Cs)||this._addStyle(T,`color:#${b(Ae.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(T,We,M.foreground,ie,ze,void 0)||bs&&se.push(`xterm-fg-${l.INVERTED_DEFAULT_COLOR}`)}se.length&&(T.className=se.join(" "),se.length=0),gs||xe||Ss?T.textContent=q:V++,K!==this.defaultSpacing&&(T.style.letterSpacing=`${K}px`),z.push(T),oe=rt}return T&&V&&(T.textContent=q),z}_applyMinimumContrast(E,I,v,x,L,k){if(this._optionsService.rawOptions.minimumContrastRatio===1||(0,c.excludeFromContrastRatioDemands)(x.getCode()))return!1;const D=this._getContrastCache(x);let B;if(L||k||(B=D.getColor(I.rgba,v.rgba)),B===void 0){const F=this._optionsService.rawOptions.minimumContrastRatio/(x.isDim()?2:1);B=_.color.ensureContrastRatio(L||I,k||v,F),D.setColor((L||I).rgba,(k||v).rgba,B??null)}return!!B&&(this._addStyle(E,`color:${B.css}`),!0)}_getContrastCache(E){return E.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(E,I){E.setAttribute("style",`${E.getAttribute("style")||""}${I};`)}_isCellInSelection(E,I){const v=this._selectionStart,x=this._selectionEnd;return!(!v||!x)&&(this._columnSelectMode?v[0]<=x[0]?E>=v[0]&&I>=v[1]&&E<x[0]&&I<=x[1]:E<v[0]&&I>=v[1]&&E>=x[0]&&I<=x[1]:I>v[1]&&I<x[1]||v[1]===x[1]&&I===v[1]&&E>=v[0]&&E<x[0]||v[1]<x[1]&&I===x[1]&&E<x[0]||v[1]<x[1]&&I===v[1]&&E>=v[0])}};function b(E,I,v){for(;E.length<v;)E=I+E;return E}r.DomRendererRowFactory=f=u([m(1,i.ICharacterJoinerService),m(2,S.IOptionsService),m(3,i.ICoreBrowserService),m(4,S.ICoreService),m(5,S.IDecorationService),m(6,i.IThemeService)],f)},2550:(y,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.WidthCache=void 0,r.WidthCache=class{constructor(n){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=n.createElement("div"),this._container.style.position="absolute",this._container.style.top="-50000px",this._container.style.width="50000px",this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";const u=n.createElement("span"),m=n.createElement("span");m.style.fontWeight="bold";const l=n.createElement("span");l.style.fontStyle="italic";const p=n.createElement("span");p.style.fontWeight="bold",p.style.fontStyle="italic",this._measureElements=[u,m,l,p],this._container.appendChild(u),this._container.appendChild(m),this._container.appendChild(l),this._container.appendChild(p),n.body.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(n,u,m,l){n===this._font&&u===this._fontSize&&m===this._weight&&l===this._weightBold||(this._font=n,this._fontSize=u,this._weight=m,this._weightBold=l,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${m}`,this._measureElements[1].style.fontWeight=`${l}`,this._measureElements[2].style.fontWeight=`${m}`,this._measureElements[3].style.fontWeight=`${l}`,this.clear())}get(n,u,m){let l=0;if(!u&&!m&&n.length===1&&(l=n.charCodeAt(0))<256)return this._flat[l]!==-9999?this._flat[l]:this._flat[l]=this._measure(n,0);let p=n;u&&(p+="B"),m&&(p+="I");let C=this._holey.get(p);if(C===void 0){let S=0;u&&(S|=1),m&&(S|=2),C=this._measure(n,S),this._holey.set(p,C)}return C}_measure(n,u){const m=this._measureElements[u];return m.textContent=n.repeat(32),m.offsetWidth/32}}},2223:(y,r,n)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.TEXT_BASELINE=r.DIM_OPACITY=r.INVERTED_DEFAULT_COLOR=void 0;const u=n(6114);r.INVERTED_DEFAULT_COLOR=257,r.DIM_OPACITY=.5,r.TEXT_BASELINE=u.isFirefox||u.isLegacyEdge?"bottom":"ideographic"},6171:(y,r)=>{function n(u){return 57508<=u&&u<=57558}Object.defineProperty(r,"__esModule",{value:!0}),r.createRenderDimensions=r.excludeFromContrastRatioDemands=r.isRestrictedPowerlineGlyph=r.isPowerlineGlyph=r.throwIfFalsy=void 0,r.throwIfFalsy=function(u){if(!u)throw new Error("value must not be falsy");return u},r.isPowerlineGlyph=n,r.isRestrictedPowerlineGlyph=function(u){return 57520<=u&&u<=57527},r.excludeFromContrastRatioDemands=function(u){return n(u)||function(m){return 9472<=m&&m<=9631}(u)},r.createRenderDimensions=function(){return{css:{canvas:{width:0,height:0},cell:{width:0,height:0}},device:{canvas:{width:0,height:0},cell:{width:0,height:0},char:{width:0,height:0,left:0,top:0}}}}},456:(y,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.SelectionModel=void 0,r.SelectionModel=class{constructor(n){this._bufferService=n,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.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()){const n=this.selectionStart[0]+this.selectionStartLength;return n>this._bufferService.cols?n%this._bufferService.cols==0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(n/this._bufferService.cols)-1]:[n%this._bufferService.cols,this.selectionStart[1]+Math.floor(n/this._bufferService.cols)]:[n,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){const n=this.selectionStart[0]+this.selectionStartLength;return n>this._bufferService.cols?[n%this._bufferService.cols,this.selectionStart[1]+Math.floor(n/this._bufferService.cols)]:[Math.max(n,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){const n=this.selectionStart,u=this.selectionEnd;return!(!n||!u)&&(n[1]>u[1]||n[1]===u[1]&&n[0]>u[0])}handleTrim(n){return this.selectionStart&&(this.selectionStart[1]-=n),this.selectionEnd&&(this.selectionEnd[1]-=n),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}}},428:function(y,r,n){var u=this&&this.__decorate||function(i,o,c,h){var f,b=arguments.length,E=b<3?o:h===null?h=Object.getOwnPropertyDescriptor(o,c):h;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(i,o,c,h);else for(var I=i.length-1;I>=0;I--)(f=i[I])&&(E=(b<3?f(E):b>3?f(o,c,E):f(o,c))||E);return b>3&&E&&Object.defineProperty(o,c,E),E},m=this&&this.__param||function(i,o){return function(c,h){o(c,h,i)}};Object.defineProperty(r,"__esModule",{value:!0}),r.CharSizeService=void 0;const l=n(2585),p=n(8460),C=n(844);let S=r.CharSizeService=class extends C.Disposable{get hasValidSize(){return this.width>0&&this.height>0}constructor(i,o,c){super(),this._optionsService=c,this.width=0,this.height=0,this._onCharSizeChange=this.register(new p.EventEmitter),this.onCharSizeChange=this._onCharSizeChange.event,this._measureStrategy=new _(i,o,this._optionsService),this.register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],()=>this.measure()))}measure(){const i=this._measureStrategy.measure();i.width===this.width&&i.height===this.height||(this.width=i.width,this.height=i.height,this._onCharSizeChange.fire())}};r.CharSizeService=S=u([m(2,l.IOptionsService)],S);class _{constructor(o,c,h){this._document=o,this._parentElement=c,this._optionsService=h,this._result={width:0,height:0},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(){this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`;const o={height:Number(this._measureElement.offsetHeight),width:Number(this._measureElement.offsetWidth)};return o.width!==0&&o.height!==0&&(this._result.width=o.width/32,this._result.height=Math.ceil(o.height)),this._result}}},4269:function(y,r,n){var u=this&&this.__decorate||function(o,c,h,f){var b,E=arguments.length,I=E<3?c:f===null?f=Object.getOwnPropertyDescriptor(c,h):f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")I=Reflect.decorate(o,c,h,f);else for(var v=o.length-1;v>=0;v--)(b=o[v])&&(I=(E<3?b(I):E>3?b(c,h,I):b(c,h))||I);return E>3&&I&&Object.defineProperty(c,h,I),I},m=this&&this.__param||function(o,c){return function(h,f){c(h,f,o)}};Object.defineProperty(r,"__esModule",{value:!0}),r.CharacterJoinerService=r.JoinedCellData=void 0;const l=n(3734),p=n(643),C=n(511),S=n(2585);class _ extends l.AttributeData{constructor(c,h,f){super(),this.content=0,this.combinedData="",this.fg=c.fg,this.bg=c.bg,this.combinedData=h,this._width=f}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(c){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}r.JoinedCellData=_;let i=r.CharacterJoinerService=class Er{constructor(c){this._bufferService=c,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new C.CellData}register(c){const h={id:this._nextCharacterJoinerId++,handler:c};return this._characterJoiners.push(h),h.id}deregister(c){for(let h=0;h<this._characterJoiners.length;h++)if(this._characterJoiners[h].id===c)return this._characterJoiners.splice(h,1),!0;return!1}getJoinedCharacters(c){if(this._characterJoiners.length===0)return[];const h=this._bufferService.buffer.lines.get(c);if(!h||h.length===0)return[];const f=[],b=h.translateToString(!0);let E=0,I=0,v=0,x=h.getFg(0),L=h.getBg(0);for(let k=0;k<h.getTrimmedLength();k++)if(h.loadCell(k,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==x||this._workCell.bg!==L){if(k-E>1){const D=this._getJoinedRanges(b,v,I,h,E);for(let B=0;B<D.length;B++)f.push(D[B])}E=k,v=I,x=this._workCell.fg,L=this._workCell.bg}I+=this._workCell.getChars().length||p.WHITESPACE_CELL_CHAR.length}if(this._bufferService.cols-E>1){const k=this._getJoinedRanges(b,v,I,h,E);for(let D=0;D<k.length;D++)f.push(k[D])}return f}_getJoinedRanges(c,h,f,b,E){const I=c.substring(h,f);let v=[];try{v=this._characterJoiners[0].handler(I)}catch(x){console.error(x)}for(let x=1;x<this._characterJoiners.length;x++)try{const L=this._characterJoiners[x].handler(I);for(let k=0;k<L.length;k++)Er._mergeRanges(v,L[k])}catch(L){console.error(L)}return this._stringRangesToCellRanges(v,b,E),v}_stringRangesToCellRanges(c,h,f){let b=0,E=!1,I=0,v=c[b];if(v){for(let x=f;x<this._bufferService.cols;x++){const L=h.getWidth(x),k=h.getString(x).length||p.WHITESPACE_CELL_CHAR.length;if(L!==0){if(!E&&v[0]<=I&&(v[0]=x,E=!0),v[1]<=I){if(v[1]=x,v=c[++b],!v)break;v[0]<=I?(v[0]=x,E=!0):E=!1}I+=k}}v&&(v[1]=this._bufferService.cols)}}static _mergeRanges(c,h){let f=!1;for(let b=0;b<c.length;b++){const E=c[b];if(f){if(h[1]<=E[0])return c[b-1][1]=h[1],c;if(h[1]<=E[1])return c[b-1][1]=Math.max(h[1],E[1]),c.splice(b,1),c;c.splice(b,1),b--}else{if(h[1]<=E[0])return c.splice(b,0,h),c;if(h[1]<=E[1])return E[0]=Math.min(h[0],E[0]),c;h[0]<E[1]&&(E[0]=Math.min(h[0],E[0]),f=!0)}}return f?c[c.length-1][1]=h[1]:c.push(h),c}};r.CharacterJoinerService=i=u([m(0,S.IBufferService)],i)},5114:(y,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.CoreBrowserService=void 0,r.CoreBrowserService=class{constructor(n,u){this._textarea=n,this.window=u,this._isFocused=!1,this._cachedIsFocused=void 0,this._textarea.addEventListener("focus",()=>this._isFocused=!0),this._textarea.addEventListener("blur",()=>this._isFocused=!1)}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}}},8934:function(y,r,n){var u=this&&this.__decorate||function(S,_,i,o){var c,h=arguments.length,f=h<3?_:o===null?o=Object.getOwnPropertyDescriptor(_,i):o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")f=Reflect.decorate(S,_,i,o);else for(var b=S.length-1;b>=0;b--)(c=S[b])&&(f=(h<3?c(f):h>3?c(_,i,f):c(_,i))||f);return h>3&&f&&Object.defineProperty(_,i,f),f},m=this&&this.__param||function(S,_){return function(i,o){_(i,o,S)}};Object.defineProperty(r,"__esModule",{value:!0}),r.MouseService=void 0;const l=n(4725),p=n(9806);let C=r.MouseService=class{constructor(S,_){this._renderService=S,this._charSizeService=_}getCoords(S,_,i,o,c){return(0,p.getCoords)(window,S,_,i,o,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,c)}getMouseReportCoords(S,_){const i=(0,p.getCoordsRelativeToElement)(window,S,_);if(this._charSizeService.hasValidSize)return i[0]=Math.min(Math.max(i[0],0),this._renderService.dimensions.css.canvas.width-1),i[1]=Math.min(Math.max(i[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(i[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(i[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(i[0]),y:Math.floor(i[1])}}};r.MouseService=C=u([m(0,l.IRenderService),m(1,l.ICharSizeService)],C)},3230:function(y,r,n){var u=this&&this.__decorate||function(f,b,E,I){var v,x=arguments.length,L=x<3?b:I===null?I=Object.getOwnPropertyDescriptor(b,E):I;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")L=Reflect.decorate(f,b,E,I);else for(var k=f.length-1;k>=0;k--)(v=f[k])&&(L=(x<3?v(L):x>3?v(b,E,L):v(b,E))||L);return x>3&&L&&Object.defineProperty(b,E,L),L},m=this&&this.__param||function(f,b){return function(E,I){b(E,I,f)}};Object.defineProperty(r,"__esModule",{value:!0}),r.RenderService=void 0;const l=n(3656),p=n(6193),C=n(5596),S=n(4725),_=n(8460),i=n(844),o=n(7226),c=n(2585);let h=r.RenderService=class extends i.Disposable{get dimensions(){return this._renderer.value.dimensions}constructor(f,b,E,I,v,x,L,k){if(super(),this._rowCount=f,this._charSizeService=I,this._renderer=this.register(new i.MutableDisposable),this._pausedResizeTask=new o.DebouncedIdleTask,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 _.EventEmitter),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this.register(new _.EventEmitter),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this.register(new _.EventEmitter),this.onRender=this._onRender.event,this._onRefreshRequest=this.register(new _.EventEmitter),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new p.RenderDebouncer(L.window,(D,B)=>this._renderRows(D,B)),this.register(this._renderDebouncer),this._screenDprMonitor=new C.ScreenDprMonitor(L.window),this._screenDprMonitor.setListener(()=>this.handleDevicePixelRatioChange()),this.register(this._screenDprMonitor),this.register(x.onResize(()=>this._fullRefresh())),this.register(x.buffers.onBufferActivate(()=>{var D;return(D=this._renderer.value)===null||D===void 0?void 0:D.clear()})),this.register(E.onOptionChange(()=>this._handleOptionsChanged())),this.register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this.register(v.onDecorationRegistered(()=>this._fullRefresh())),this.register(v.onDecorationRemoved(()=>this._fullRefresh())),this.register(E.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio"],()=>{this.clear(),this.handleResize(x.cols,x.rows),this._fullRefresh()})),this.register(E.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(x.buffer.y,x.buffer.y,!0))),this.register((0,l.addDisposableDomListener)(L.window,"resize",()=>this.handleDevicePixelRatioChange())),this.register(k.onChangeColors(()=>this._fullRefresh())),"IntersectionObserver"in L.window){const D=new L.window.IntersectionObserver(B=>this._handleIntersectionChange(B[B.length-1]),{threshold:0});D.observe(b),this.register({dispose:()=>D.disconnect()})}}_handleIntersectionChange(f){this._isPaused=f.isIntersecting===void 0?f.intersectionRatio===0:!f.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(f,b,E=!1){this._isPaused?this._needsFullRefresh=!0:(E||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(f,b,this._rowCount))}_renderRows(f,b){this._renderer.value&&(f=Math.min(f,this._rowCount-1),b=Math.min(b,this._rowCount-1),this._renderer.value.renderRows(f,b),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:f,end:b}),this._onRender.fire({start:f,end:b}),this._isNextRenderRedrawOnly=!0)}resize(f,b){this._rowCount=b,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(f){this._renderer.value=f,this._renderer.value.onRequestRedraw(b=>this.refreshRows(b.start,b.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh()}addRefreshCallback(f){return this._renderDebouncer.addRefreshCallback(f)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){var f,b;this._renderer.value&&((b=(f=this._renderer.value).clearTextureAtlas)===null||b===void 0||b.call(f),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(f,b){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>this._renderer.value.handleResize(f,b)):this._renderer.value.handleResize(f,b),this._fullRefresh())}handleCharSizeChanged(){var f;(f=this._renderer.value)===null||f===void 0||f.handleCharSizeChanged()}handleBlur(){var f;(f=this._renderer.value)===null||f===void 0||f.handleBlur()}handleFocus(){var f;(f=this._renderer.value)===null||f===void 0||f.handleFocus()}handleSelectionChanged(f,b,E){var I;this._selectionState.start=f,this._selectionState.end=b,this._selectionState.columnSelectMode=E,(I=this._renderer.value)===null||I===void 0||I.handleSelectionChanged(f,b,E)}handleCursorMove(){var f;(f=this._renderer.value)===null||f===void 0||f.handleCursorMove()}clear(){var f;(f=this._renderer.value)===null||f===void 0||f.clear()}};r.RenderService=h=u([m(2,c.IOptionsService),m(3,S.ICharSizeService),m(4,c.IDecorationService),m(5,c.IBufferService),m(6,S.ICoreBrowserService),m(7,S.IThemeService)],h)},9312:function(y,r,n){var u=this&&this.__decorate||function(v,x,L,k){var D,B=arguments.length,F=B<3?x:k===null?k=Object.getOwnPropertyDescriptor(x,L):k;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")F=Reflect.decorate(v,x,L,k);else for(var Y=v.length-1;Y>=0;Y--)(D=v[Y])&&(F=(B<3?D(F):B>3?D(x,L,F):D(x,L))||F);return B>3&&F&&Object.defineProperty(x,L,F),F},m=this&&this.__param||function(v,x){return function(L,k){x(L,k,v)}};Object.defineProperty(r,"__esModule",{value:!0}),r.SelectionService=void 0;const l=n(9806),p=n(9504),C=n(456),S=n(4725),_=n(8460),i=n(844),o=n(6114),c=n(4841),h=n(511),f=n(2585),b=" ",E=new RegExp(b,"g");let I=r.SelectionService=class extends i.Disposable{constructor(v,x,L,k,D,B,F,Y,$){super(),this._element=v,this._screenElement=x,this._linkifier=L,this._bufferService=k,this._coreService=D,this._mouseService=B,this._optionsService=F,this._renderService=Y,this._coreBrowserService=$,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new h.CellData,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this.register(new _.EventEmitter),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this.register(new _.EventEmitter),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this.register(new _.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this.register(new _.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=z=>this._handleMouseMove(z),this._mouseUpListener=z=>this._handleMouseUp(z),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(z=>this._handleTrim(z)),this.register(this._bufferService.buffers.onBufferActivate(z=>this._handleBufferActivate(z))),this.enable(),this._model=new C.SelectionModel(this._bufferService),this._activeSelectionMode=0,this.register((0,i.toDisposable)(()=>{this._removeMouseDownListeners()}))}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(){const v=this._model.finalSelectionStart,x=this._model.finalSelectionEnd;return!(!v||!x||v[0]===x[0]&&v[1]===x[1])}get selectionText(){const v=this._model.finalSelectionStart,x=this._model.finalSelectionEnd;if(!v||!x)return"";const L=this._bufferService.buffer,k=[];if(this._activeSelectionMode===3){if(v[0]===x[0])return"";const D=v[0]<x[0]?v[0]:x[0],B=v[0]<x[0]?x[0]:v[0];for(let F=v[1];F<=x[1];F++){const Y=L.translateBufferLineToString(F,!0,D,B);k.push(Y)}}else{const D=v[1]===x[1]?x[0]:void 0;k.push(L.translateBufferLineToString(v[1],!0,v[0],D));for(let B=v[1]+1;B<=x[1]-1;B++){const F=L.lines.get(B),Y=L.translateBufferLineToString(B,!0);F!=null&&F.isWrapped?k[k.length-1]+=Y:k.push(Y)}if(v[1]!==x[1]){const B=L.lines.get(x[1]),F=L.translateBufferLineToString(x[1],!0,0,x[0]);B&&B.isWrapped?k[k.length-1]+=F:k.push(F)}}return k.map(D=>D.replace(E," ")).join(o.isWindows?`\r `:` `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(v){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),o.isLinux&&v&&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(v){const x=this._getMouseBufferCoords(v),L=this._model.finalSelectionStart,k=this._model.finalSelectionEnd;return!!(L&&k&&x)&&this._areCoordsInSelection(x,L,k)}isCellInSelection(v,x){const L=this._model.finalSelectionStart,k=this._model.finalSelectionEnd;return!(!L||!k)&&this._areCoordsInSelection([v,x],L,k)}_areCoordsInSelection(v,x,L){return v[1]>x[1]&&v[1]<L[1]||x[1]===L[1]&&v[1]===x[1]&&v[0]>=x[0]&&v[0]<L[0]||x[1]<L[1]&&v[1]===L[1]&&v[0]<L[0]||x[1]<L[1]&&v[1]===x[1]&&v[0]>=x[0]}_selectWordAtCursor(v,x){var L,k;const D=(k=(L=this._linkifier.currentLink)===null||L===void 0?void 0:L.link)===null||k===void 0?void 0:k.range;if(D)return this._model.selectionStart=[D.start.x-1,D.start.y-1],this._model.selectionStartLength=(0,c.getRangeLength)(D,this._bufferService.cols),this._model.selectionEnd=void 0,!0;const B=this._getMouseBufferCoords(v);return!!B&&(this._selectWordAt(B,x),this._model.selectionEnd=void 0,!0)}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(v,x){this._model.clearSelection(),v=Math.max(v,0),x=Math.min(x,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,v],this._model.selectionEnd=[this._bufferService.cols,x],this.refresh(),this._onSelectionChange.fire()}_handleTrim(v){this._model.handleTrim(v)&&this.refresh()}_getMouseBufferCoords(v){const x=this._mouseService.getCoords(v,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(x)return x[0]--,x[1]--,x[1]+=this._bufferService.buffer.ydisp,x}_getMouseEventScrollAmount(v){let x=(0,l.getCoordsRelativeToElement)(this._coreBrowserService.window,v,this._screenElement)[1];const L=this._renderService.dimensions.css.canvas.height;return x>=0&&x<=L?0:(x>L&&(x-=L),x=Math.min(Math.max(x,-50),50),x/=50,x/Math.abs(x)+Math.round(14*x))}shouldForceSelection(v){return o.isMac?v.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:v.shiftKey}handleMouseDown(v){if(this._mouseDownTimeStamp=v.timeStamp,(v.button!==2||!this.hasSelection)&&v.button===0){if(!this._enabled){if(!this.shouldForceSelection(v))return;v.stopPropagation()}v.preventDefault(),this._dragScrollAmount=0,this._enabled&&v.shiftKey?this._handleIncrementalClick(v):v.detail===1?this._handleSingleClick(v):v.detail===2?this._handleDoubleClick(v):v.detail===3&&this._handleTripleClick(v),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(),50)}_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(v){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(v))}_handleSingleClick(v){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(v)?3:0,this._model.selectionStart=this._getMouseBufferCoords(v),!this._model.selectionStart)return;this._model.selectionEnd=void 0;const x=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);x&&x.length!==this._model.selectionStart[0]&&x.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(v){this._selectWordAtCursor(v,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(v){const x=this._getMouseBufferCoords(v);x&&(this._activeSelectionMode=2,this._selectLineAt(x[1]))}shouldColumnSelect(v){return v.altKey&&!(o.isMac&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(v){if(v.stopImmediatePropagation(),!this._model.selectionStart)return;const x=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(v),!this._model.selectionEnd)return void this.refresh(!0);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(v),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));const L=this._bufferService.buffer;if(this._model.selectionEnd[1]<L.lines.length){const k=L.lines.get(this._model.selectionEnd[1]);k&&k.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]++}x&&x[0]===this._model.selectionEnd[0]&&x[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});const v=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(v.ydisp+this._bufferService.rows,v.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=v.ydisp),this.refresh()}}_handleMouseUp(v){const x=v.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&x<500&&v.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){const L=this._mouseService.getCoords(v,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(L&&L[0]!==void 0&&L[1]!==void 0){const k=(0,p.moveToCellSequence)(L[0]-1,L[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(k,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){const v=this._model.finalSelectionStart,x=this._model.finalSelectionEnd,L=!(!v||!x||v[0]===x[0]&&v[1]===x[1]);L?v&&x&&(this._oldSelectionStart&&this._oldSelectionEnd&&v[0]===this._oldSelectionStart[0]&&v[1]===this._oldSelectionStart[1]&&x[0]===this._oldSelectionEnd[0]&&x[1]===this._oldSelectionEnd[1]||this._fireOnSelectionChange(v,x,L)):this._oldHasSelection&&this._fireOnSelectionChange(v,x,L)}_fireOnSelectionChange(v,x,L){this._oldSelectionStart=v,this._oldSelectionEnd=x,this._oldHasSelection=L,this._onSelectionChange.fire()}_handleBufferActivate(v){this.clearSelection(),this._trimListener.dispose(),this._trimListener=v.activeBuffer.lines.onTrim(x=>this._handleTrim(x))}_convertViewportColToCharacterIndex(v,x){let L=x;for(let k=0;x>=k;k++){const D=v.loadCell(k,this._workCell).getChars().length;this._workCell.getWidth()===0?L--:D>1&&x!==k&&(L+=D-1)}return L}setSelection(v,x,L){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[v,x],this._model.selectionStartLength=L,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(v){this._isClickInSelection(v)||(this._selectWordAtCursor(v,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(v,x,L=!0,k=!0){if(v[0]>=this._bufferService.cols)return;const D=this._bufferService.buffer,B=D.lines.get(v[1]);if(!B)return;const F=D.translateBufferLineToString(v[1],!1);let Y=this._convertViewportColToCharacterIndex(B,v[0]),$=Y;const z=v[0]-Y;let A=0,M=0,T=0,N=0;if(F.charAt(Y)===" "){for(;Y>0&&F.charAt(Y-1)===" ";)Y--;for(;$<F.length&&F.charAt($+1)===" ";)$++}else{let J=v[0],X=v[0];B.getWidth(J)===0&&(A++,J--),B.getWidth(X)===2&&(M++,X++);const ce=B.getString(X).length;for(ce>1&&(N+=ce-1,$+=ce-1);J>0&&Y>0&&!this._isCharWordSeparator(B.loadCell(J-1,this._workCell));){B.loadCell(J-1,this._workCell);const P=this._workCell.getChars().length;this._workCell.getWidth()===0?(A++,J--):P>1&&(T+=P-1,Y-=P-1),Y--,J--}for(;X<B.length&&$+1<F.length&&!this._isCharWordSeparator(B.loadCell(X+1,this._workCell));){B.loadCell(X+1,this._workCell);const P=this._workCell.getChars().length;this._workCell.getWidth()===2?(M++,X++):P>1&&(N+=P-1,$+=P-1),$++,X++}}$++;let V=Y+z-A+T,q=Math.min(this._bufferService.cols,$-Y+A+M-T-N);if(x||F.slice(Y,$).trim()!==""){if(L&&V===0&&B.getCodePoint(0)!==32){const J=D.lines.get(v[1]-1);if(J&&B.isWrapped&&J.getCodePoint(this._bufferService.cols-1)!==32){const X=this._getWordAt([this._bufferService.cols-1,v[1]-1],!1,!0,!1);if(X){const ce=this._bufferService.cols-X.start;V-=ce,q+=ce}}}if(k&&V+q===this._bufferService.cols&&B.getCodePoint(this._bufferService.cols-1)!==32){const J=D.lines.get(v[1]+1);if(J!=null&&J.isWrapped&&J.getCodePoint(0)!==32){const X=this._getWordAt([0,v[1]+1],!1,!1,!0);X&&(q+=X.length)}}return{start:V,length:q}}}_selectWordAt(v,x){const L=this._getWordAt(v,x);if(L){for(;L.start<0;)L.start+=this._bufferService.cols,v[1]--;this._model.selectionStart=[L.start,v[1]],this._model.selectionStartLength=L.length}}_selectToWordAt(v){const x=this._getWordAt(v,!0);if(x){let L=v[1];for(;x.start<0;)x.start+=this._bufferService.cols,L--;if(!this._model.areSelectionValuesReversed())for(;x.start+x.length>this._bufferService.cols;)x.length-=this._bufferService.cols,L++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?x.start:x.start+x.length,L]}}_isCharWordSeparator(v){return v.getWidth()!==0&&this._optionsService.rawOptions.wordSeparator.indexOf(v.getChars())>=0}_selectLineAt(v){const x=this._bufferService.buffer.getWrappedRangeForLine(v),L={start:{x:0,y:x.first},end:{x:this._bufferService.cols-1,y:x.last}};this._model.selectionStart=[0,x.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=(0,c.getRangeLength)(L,this._bufferService.cols)}};r.SelectionService=I=u([m(3,f.IBufferService),m(4,f.ICoreService),m(5,S.IMouseService),m(6,f.IOptionsService),m(7,S.IRenderService),m(8,S.ICoreBrowserService)],I)},4725:(y,r,n)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.IThemeService=r.ICharacterJoinerService=r.ISelectionService=r.IRenderService=r.IMouseService=r.ICoreBrowserService=r.ICharSizeService=void 0;const u=n(8343);r.ICharSizeService=(0,u.createDecorator)("CharSizeService"),r.ICoreBrowserService=(0,u.createDecorator)("CoreBrowserService"),r.IMouseService=(0,u.createDecorator)("MouseService"),r.IRenderService=(0,u.createDecorator)("RenderService"),r.ISelectionService=(0,u.createDecorator)("SelectionService"),r.ICharacterJoinerService=(0,u.createDecorator)("CharacterJoinerService"),r.IThemeService=(0,u.createDecorator)("ThemeService")},6731:function(y,r,n){var u=this&&this.__decorate||function(I,v,x,L){var k,D=arguments.length,B=D<3?v:L===null?L=Object.getOwnPropertyDescriptor(v,x):L;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")B=Reflect.decorate(I,v,x,L);else for(var F=I.length-1;F>=0;F--)(k=I[F])&&(B=(D<3?k(B):D>3?k(v,x,B):k(v,x))||B);return D>3&&B&&Object.defineProperty(v,x,B),B},m=this&&this.__param||function(I,v){return function(x,L){v(x,L,I)}};Object.defineProperty(r,"__esModule",{value:!0}),r.ThemeService=r.DEFAULT_ANSI_COLORS=void 0;const l=n(7239),p=n(8055),C=n(8460),S=n(844),_=n(2585),i=p.css.toColor("#ffffff"),o=p.css.toColor("#000000"),c=p.css.toColor("#ffffff"),h=p.css.toColor("#000000"),f={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117};r.DEFAULT_ANSI_COLORS=Object.freeze((()=>{const I=[p.css.toColor("#2e3436"),p.css.toColor("#cc0000"),p.css.toColor("#4e9a06"),p.css.toColor("#c4a000"),p.css.toColor("#3465a4"),p.css.toColor("#75507b"),p.css.toColor("#06989a"),p.css.toColor("#d3d7cf"),p.css.toColor("#555753"),p.css.toColor("#ef2929"),p.css.toColor("#8ae234"),p.css.toColor("#fce94f"),p.css.toColor("#729fcf"),p.css.toColor("#ad7fa8"),p.css.toColor("#34e2e2"),p.css.toColor("#eeeeec")],v=[0,95,135,175,215,255];for(let x=0;x<216;x++){const L=v[x/36%6|0],k=v[x/6%6|0],D=v[x%6];I.push({css:p.channels.toCss(L,k,D),rgba:p.channels.toRgba(L,k,D)})}for(let x=0;x<24;x++){const L=8+10*x;I.push({css:p.channels.toCss(L,L,L),rgba:p.channels.toRgba(L,L,L)})}return I})());let b=r.ThemeService=class extends S.Disposable{get colors(){return this._colors}constructor(I){super(),this._optionsService=I,this._contrastCache=new l.ColorContrastCache,this._halfContrastCache=new l.ColorContrastCache,this._onChangeColors=this.register(new C.EventEmitter),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:i,background:o,cursor:c,cursorAccent:h,selectionForeground:void 0,selectionBackgroundTransparent:f,selectionBackgroundOpaque:p.color.blend(o,f),selectionInactiveBackgroundTransparent:f,selectionInactiveBackgroundOpaque:p.color.blend(o,f),ansi:r.DEFAULT_ANSI_COLORS.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)))}_setTheme(I={}){const v=this._colors;if(v.foreground=E(I.foreground,i),v.background=E(I.background,o),v.cursor=E(I.cursor,c),v.cursorAccent=E(I.cursorAccent,h),v.selectionBackgroundTransparent=E(I.selectionBackground,f),v.selectionBackgroundOpaque=p.color.blend(v.background,v.selectionBackgroundTransparent),v.selectionInactiveBackgroundTransparent=E(I.selectionInactiveBackground,v.selectionBackgroundTransparent),v.selectionInactiveBackgroundOpaque=p.color.blend(v.background,v.selectionInactiveBackgroundTransparent),v.selectionForeground=I.selectionForeground?E(I.selectionForeground,p.NULL_COLOR):void 0,v.selectionForeground===p.NULL_COLOR&&(v.selectionForeground=void 0),p.color.isOpaque(v.selectionBackgroundTransparent)&&(v.selectionBackgroundTransparent=p.color.opacity(v.selectionBackgroundTransparent,.3)),p.color.isOpaque(v.selectionInactiveBackgroundTransparent)&&(v.selectionInactiveBackgroundTransparent=p.color.opacity(v.selectionInactiveBackgroundTransparent,.3)),v.ansi=r.DEFAULT_ANSI_COLORS.slice(),v.ansi[0]=E(I.black,r.DEFAULT_ANSI_COLORS[0]),v.ansi[1]=E(I.red,r.DEFAULT_ANSI_COLORS[1]),v.ansi[2]=E(I.green,r.DEFAULT_ANSI_COLORS[2]),v.ansi[3]=E(I.yellow,r.DEFAULT_ANSI_COLORS[3]),v.ansi[4]=E(I.blue,r.DEFAULT_ANSI_COLORS[4]),v.ansi[5]=E(I.magenta,r.DEFAULT_ANSI_COLORS[5]),v.ansi[6]=E(I.cyan,r.DEFAULT_ANSI_COLORS[6]),v.ansi[7]=E(I.white,r.DEFAULT_ANSI_COLORS[7]),v.ansi[8]=E(I.brightBlack,r.DEFAULT_ANSI_COLORS[8]),v.ansi[9]=E(I.brightRed,r.DEFAULT_ANSI_COLORS[9]),v.ansi[10]=E(I.brightGreen,r.DEFAULT_ANSI_COLORS[10]),v.ansi[11]=E(I.brightYellow,r.DEFAULT_ANSI_COLORS[11]),v.ansi[12]=E(I.brightBlue,r.DEFAULT_ANSI_COLORS[12]),v.ansi[13]=E(I.brightMagenta,r.DEFAULT_ANSI_COLORS[13]),v.ansi[14]=E(I.brightCyan,r.DEFAULT_ANSI_COLORS[14]),v.ansi[15]=E(I.brightWhite,r.DEFAULT_ANSI_COLORS[15]),I.extendedAnsi){const x=Math.min(v.ansi.length-16,I.extendedAnsi.length);for(let L=0;L<x;L++)v.ansi[L+16]=E(I.extendedAnsi[L],r.DEFAULT_ANSI_COLORS[L+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(I){this._restoreColor(I),this._onChangeColors.fire(this.colors)}_restoreColor(I){if(I!==void 0)switch(I){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[I]=this._restoreColors.ansi[I]}else for(let v=0;v<this._restoreColors.ansi.length;++v)this._colors.ansi[v]=this._restoreColors.ansi[v]}modifyColors(I){I(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()}}};function E(I,v){if(I!==void 0)try{return p.css.toColor(I)}catch{}return v}r.ThemeService=b=u([m(0,_.IOptionsService)],b)},6349:(y,r,n)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.CircularList=void 0;const u=n(8460),m=n(844);class l extends m.Disposable{constructor(C){super(),this._maxLength=C,this.onDeleteEmitter=this.register(new u.EventEmitter),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this.register(new u.EventEmitter),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this.register(new u.EventEmitter),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(C){if(this._maxLength===C)return;const S=new Array(C);for(let _=0;_<Math.min(C,this.length);_++)S[_]=this._array[this._getCyclicIndex(_)];this._array=S,this._maxLength=C,this._startIndex=0}get length(){return this._length}set length(C){if(C>this._length)for(let S=this._length;S<C;S++)this._array[S]=void 0;this._length=C}get(C){return this._array[this._getCyclicIndex(C)]}set(C,S){this._array[this._getCyclicIndex(C)]=S}push(C){this._array[this._getCyclicIndex(this._length)]=C,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(C,S,..._){if(S){for(let i=C;i<this._length-S;i++)this._array[this._getCyclicIndex(i)]=this._array[this._getCyclicIndex(i+S)];this._length-=S,this.onDeleteEmitter.fire({index:C,amount:S})}for(let i=this._length-1;i>=C;i--)this._array[this._getCyclicIndex(i+_.length)]=this._array[this._getCyclicIndex(i)];for(let i=0;i<_.length;i++)this._array[this._getCyclicIndex(C+i)]=_[i];if(_.length&&this.onInsertEmitter.fire({index:C,amount:_.length}),this._length+_.length>this._maxLength){const i=this._length+_.length-this._maxLength;this._startIndex+=i,this._length=this._maxLength,this.onTrimEmitter.fire(i)}else this._length+=_.length}trimStart(C){C>this._length&&(C=this._length),this._startIndex+=C,this._length-=C,this.onTrimEmitter.fire(C)}shiftElements(C,S,_){if(!(S<=0)){if(C<0||C>=this._length)throw new Error("start argument out of range");if(C+_<0)throw new Error("Cannot shift elements in list beyond index 0");if(_>0){for(let o=S-1;o>=0;o--)this.set(C+o+_,this.get(C+o));const i=C+S+_-this._length;if(i>0)for(this._length+=i;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let i=0;i<S;i++)this.set(C+i+_,this.get(C+i))}}_getCyclicIndex(C){return(this._startIndex+C)%this._maxLength}}r.CircularList=l},1439:(y,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.clone=void 0,r.clone=function n(u,m=5){if(typeof u!="object")return u;const l=Array.isArray(u)?[]:{};for(const p in u)l[p]=m<=1?u[p]:u[p]&&n(u[p],m-1);return l}},8055:(y,r,n)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.contrastRatio=r.toPaddedHex=r.rgba=r.rgb=r.css=r.color=r.channels=r.NULL_COLOR=void 0;const u=n(6114);let m=0,l=0,p=0,C=0;var S,_,i,o,c;function h(b){const E=b.toString(16);return E.length<2?"0"+E:E}function f(b,E){return b<E?(E+.05)/(b+.05):(b+.05)/(E+.05)}r.NULL_COLOR={css:"#00000000",rgba:0},function(b){b.toCss=function(E,I,v,x){return x!==void 0?`#${h(E)}${h(I)}${h(v)}${h(x)}`:`#${h(E)}${h(I)}${h(v)}`},b.toRgba=function(E,I,v,x=255){return(E<<24|I<<16|v<<8|x)>>>0}}(S||(r.channels=S={})),function(b){function E(I,v){return C=Math.round(255*v),[m,l,p]=c.toChannels(I.rgba),{css:S.toCss(m,l,p,C),rgba:S.toRgba(m,l,p,C)}}b.blend=function(I,v){if(C=(255&v.rgba)/255,C===1)return{css:v.css,rgba:v.rgba};const x=v.rgba>>24&255,L=v.rgba>>16&255,k=v.rgba>>8&255,D=I.rgba>>24&255,B=I.rgba>>16&255,F=I.rgba>>8&255;return m=D+Math.round((x-D)*C),l=B+Math.round((L-B)*C),p=F+Math.round((k-F)*C),{css:S.toCss(m,l,p),rgba:S.toRgba(m,l,p)}},b.isOpaque=function(I){return(255&I.rgba)==255},b.ensureContrastRatio=function(I,v,x){const L=c.ensureContrastRatio(I.rgba,v.rgba,x);if(L)return c.toColor(L>>24&255,L>>16&255,L>>8&255)},b.opaque=function(I){const v=(255|I.rgba)>>>0;return[m,l,p]=c.toChannels(v),{css:S.toCss(m,l,p),rgba:v}},b.opacity=E,b.multiplyOpacity=function(I,v){return C=255&I.rgba,E(I,C*v/255)},b.toColorRGB=function(I){return[I.rgba>>24&255,I.rgba>>16&255,I.rgba>>8&255]}}(_||(r.color=_={})),function(b){let E,I;if(!u.isNode){const v=document.createElement("canvas");v.width=1,v.height=1;const x=v.getContext("2d",{willReadFrequently:!0});x&&(E=x,E.globalCompositeOperation="copy",I=E.createLinearGradient(0,0,1,1))}b.toColor=function(v){if(v.match(/#[\da-f]{3,8}/i))switch(v.length){case 4:return m=parseInt(v.slice(1,2).repeat(2),16),l=parseInt(v.slice(2,3).repeat(2),16),p=parseInt(v.slice(3,4).repeat(2),16),c.toColor(m,l,p);case 5:return m=parseInt(v.slice(1,2).repeat(2),16),l=parseInt(v.slice(2,3).repeat(2),16),p=parseInt(v.slice(3,4).repeat(2),16),C=parseInt(v.slice(4,5).repeat(2),16),c.toColor(m,l,p,C);case 7:return{css:v,rgba:(parseInt(v.slice(1),16)<<8|255)>>>0};case 9:return{css:v,rgba:parseInt(v.slice(1),16)>>>0}}const x=v.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(x)return m=parseInt(x[1]),l=parseInt(x[2]),p=parseInt(x[3]),C=Math.round(255*(x[5]===void 0?1:parseFloat(x[5]))),c.toColor(m,l,p,C);if(!E||!I)throw new Error("css.toColor: Unsupported css format");if(E.fillStyle=I,E.fillStyle=v,typeof E.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(E.fillRect(0,0,1,1),[m,l,p,C]=E.getImageData(0,0,1,1).data,C!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:S.toRgba(m,l,p,C),css:v}}}(i||(r.css=i={})),function(b){function E(I,v,x){const L=I/255,k=v/255,D=x/255;return .2126*(L<=.03928?L/12.92:Math.pow((L+.055)/1.055,2.4))+.7152*(k<=.03928?k/12.92:Math.pow((k+.055)/1.055,2.4))+.0722*(D<=.03928?D/12.92:Math.pow((D+.055)/1.055,2.4))}b.relativeLuminance=function(I){return E(I>>16&255,I>>8&255,255&I)},b.relativeLuminance2=E}(o||(r.rgb=o={})),function(b){function E(v,x,L){const k=v>>24&255,D=v>>16&255,B=v>>8&255;let F=x>>24&255,Y=x>>16&255,$=x>>8&255,z=f(o.relativeLuminance2(F,Y,$),o.relativeLuminance2(k,D,B));for(;z<L&&(F>0||Y>0||$>0);)F-=Math.max(0,Math.ceil(.1*F)),Y-=Math.max(0,Math.ceil(.1*Y)),$-=Math.max(0,Math.ceil(.1*$)),z=f(o.relativeLuminance2(F,Y,$),o.relativeLuminance2(k,D,B));return(F<<24|Y<<16|$<<8|255)>>>0}function I(v,x,L){const k=v>>24&255,D=v>>16&255,B=v>>8&255;let F=x>>24&255,Y=x>>16&255,$=x>>8&255,z=f(o.relativeLuminance2(F,Y,$),o.relativeLuminance2(k,D,B));for(;z<L&&(F<255||Y<255||$<255);)F=Math.min(255,F+Math.ceil(.1*(255-F))),Y=Math.min(255,Y+Math.ceil(.1*(255-Y))),$=Math.min(255,$+Math.ceil(.1*(255-$))),z=f(o.relativeLuminance2(F,Y,$),o.relativeLuminance2(k,D,B));return(F<<24|Y<<16|$<<8|255)>>>0}b.ensureContrastRatio=function(v,x,L){const k=o.relativeLuminance(v>>8),D=o.relativeLuminance(x>>8);if(f(k,D)<L){if(D<k){const Y=E(v,x,L),$=f(k,o.relativeLuminance(Y>>8));if($<L){const z=I(v,x,L);return $>f(k,o.relativeLuminance(z>>8))?Y:z}return Y}const B=I(v,x,L),F=f(k,o.relativeLuminance(B>>8));if(F<L){const Y=E(v,x,L);return F>f(k,o.relativeLuminance(Y>>8))?B:Y}return B}},b.reduceLuminance=E,b.increaseLuminance=I,b.toChannels=function(v){return[v>>24&255,v>>16&255,v>>8&255,255&v]},b.toColor=function(v,x,L,k){return{css:S.toCss(v,x,L,k),rgba:S.toRgba(v,x,L,k)}}}(c||(r.rgba=c={})),r.toPaddedHex=h,r.contrastRatio=f},8969:(y,r,n)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.CoreTerminal=void 0;const u=n(844),m=n(2585),l=n(4348),p=n(7866),C=n(744),S=n(7302),_=n(6975),i=n(8460),o=n(1753),c=n(1480),h=n(7994),f=n(9282),b=n(5435),E=n(5981),I=n(2660);let v=!1;class x extends u.Disposable{get onScroll(){return this._onScrollApi||(this._onScrollApi=this.register(new i.EventEmitter),this._onScroll.event(k=>{var D;(D=this._onScrollApi)===null||D===void 0||D.fire(k.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(k){for(const D in k)this.optionsService.options[D]=k[D]}constructor(k){super(),this._windowsWrappingHeuristics=this.register(new u.MutableDisposable),this._onBinary=this.register(new i.EventEmitter),this.onBinary=this._onBinary.event,this._onData=this.register(new i.EventEmitter),this.onData=this._onData.event,this._onLineFeed=this.register(new i.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onResize=this.register(new i.EventEmitter),this.onResize=this._onResize.event,this._onWriteParsed=this.register(new i.EventEmitter),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this.register(new i.EventEmitter),this._instantiationService=new l.InstantiationService,this.optionsService=this.register(new S.OptionsService(k)),this._instantiationService.setService(m.IOptionsService,this.optionsService),this._bufferService=this.register(this._instantiationService.createInstance(C.BufferService)),this._instantiationService.setService(m.IBufferService,this._bufferService),this._logService=this.register(this._instantiationService.createInstance(p.LogService)),this._instantiationService.setService(m.ILogService,this._logService),this.coreService=this.register(this._instantiationService.createInstance(_.CoreService)),this._instantiationService.setService(m.ICoreService,this.coreService),this.coreMouseService=this.register(this._instantiationService.createInstance(o.CoreMouseService)),this._instantiationService.setService(m.ICoreMouseService,this.coreMouseService),this.unicodeService=this.register(this._instantiationService.createInstance(c.UnicodeService)),this._instantiationService.setService(m.IUnicodeService,this.unicodeService),this._charsetService=this._instantiationService.createInstance(h.CharsetService),this._instantiationService.setService(m.ICharsetService,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(I.OscLinkService),this._instantiationService.setService(m.IOscLinkService,this._oscLinkService),this._inputHandler=this.register(new b.InputHandler(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this.register((0,i.forwardEvent)(this._inputHandler.onLineFeed,this._onLineFeed)),this.register(this._inputHandler),this.register((0,i.forwardEvent)(this._bufferService.onResize,this._onResize)),this.register((0,i.forwardEvent)(this.coreService.onData,this._onData)),this.register((0,i.forwardEvent)(this.coreService.onBinary,this._onBinary)),this.register(this.coreService.onRequestScrollToBottom(()=>this.scrollToBottom())),this.register(this.coreService.onUserInput(()=>this._writeBuffer.handleUserInput())),this.register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],()=>this._handleWindowsPtyOptionChange())),this.register(this._bufferService.onScroll(D=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp,source:0}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)})),this.register(this._inputHandler.onScroll(D=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp,source:0}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)})),this._writeBuffer=this.register(new E.WriteBuffer((D,B)=>this._inputHandler.parse(D,B))),this.register((0,i.forwardEvent)(this._writeBuffer.onWriteParsed,this._onWriteParsed))}write(k,D){this._writeBuffer.write(k,D)}writeSync(k,D){this._logService.logLevel<=m.LogLevelEnum.WARN&&!v&&(this._logService.warn("writeSync is unreliable and will be removed soon."),v=!0),this._writeBuffer.writeSync(k,D)}resize(k,D){isNaN(k)||isNaN(D)||(k=Math.max(k,C.MINIMUM_COLS),D=Math.max(D,C.MINIMUM_ROWS),this._bufferService.resize(k,D))}scroll(k,D=!1){this._bufferService.scroll(k,D)}scrollLines(k,D,B){this._bufferService.scrollLines(k,D,B)}scrollPages(k){this.scrollLines(k*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(k){const D=k-this._bufferService.buffer.ydisp;D!==0&&this.scrollLines(D)}registerEscHandler(k,D){return this._inputHandler.registerEscHandler(k,D)}registerDcsHandler(k,D){return this._inputHandler.registerDcsHandler(k,D)}registerCsiHandler(k,D){return this._inputHandler.registerCsiHandler(k,D)}registerOscHandler(k,D){return this._inputHandler.registerOscHandler(k,D)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let k=!1;const D=this.optionsService.rawOptions.windowsPty;D&&D.buildNumber!==void 0&&D.buildNumber!==void 0?k=D.backend==="conpty"&&D.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(k=!0),k?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){const k=[];k.push(this.onLineFeed(f.updateWindowsModeWrappedState.bind(null,this._bufferService))),k.push(this.registerCsiHandler({final:"H"},()=>((0,f.updateWindowsModeWrappedState)(this._bufferService),!1))),this._windowsWrappingHeuristics.value=(0,u.toDisposable)(()=>{for(const D of k)D.dispose()})}}}r.CoreTerminal=x},8460:(y,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.forwardEvent=r.EventEmitter=void 0,r.EventEmitter=class{constructor(){this._listeners=[],this._disposed=!1}get event(){return this._event||(this._event=n=>(this._listeners.push(n),{dispose:()=>{if(!this._disposed){for(let u=0;u<this._listeners.length;u++)if(this._listeners[u]===n)return void this._listeners.splice(u,1)}}})),this._event}fire(n,u){const m=[];for(let l=0;l<this._listeners.length;l++)m.push(this._listeners[l]);for(let l=0;l<m.length;l++)m[l].call(void 0,n,u)}dispose(){this.clearListeners(),this._disposed=!0}clearListeners(){this._listeners&&(this._listeners.length=0)}},r.forwardEvent=function(n,u){return n(m=>u.fire(m))}},5435:function(y,r,n){var u=this&&this.__decorate||function(z,A,M,T){var N,V=arguments.length,q=V<3?A:T===null?T=Object.getOwnPropertyDescriptor(A,M):T;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")q=Reflect.decorate(z,A,M,T);else for(var J=z.length-1;J>=0;J--)(N=z[J])&&(q=(V<3?N(q):V>3?N(A,M,q):N(A,M))||q);return V>3&&q&&Object.defineProperty(A,M,q),q},m=this&&this.__param||function(z,A){return function(M,T){A(M,T,z)}};Object.defineProperty(r,"__esModule",{value:!0}),r.InputHandler=r.WindowsOptionsReportType=void 0;const l=n(2584),p=n(7116),C=n(2015),S=n(844),_=n(482),i=n(8437),o=n(8460),c=n(643),h=n(511),f=n(3734),b=n(2585),E=n(6242),I=n(6351),v=n(5941),x={"(":0,")":1,"*":2,"+":3,"-":1,".":2},L=131072;function k(z,A){if(z>24)return A.setWinLines||!1;switch(z){case 1:return!!A.restoreWin;case 2:return!!A.minimizeWin;case 3:return!!A.setWinPosition;case 4:return!!A.setWinSizePixels;case 5:return!!A.raiseWin;case 6:return!!A.lowerWin;case 7:return!!A.refreshWin;case 8:return!!A.setWinSizeChars;case 9:return!!A.maximizeWin;case 10:return!!A.fullscreenWin;case 11:return!!A.getWinState;case 13:return!!A.getWinPosition;case 14:return!!A.getWinSizePixels;case 15:return!!A.getScreenSizePixels;case 16:return!!A.getCellSizePixels;case 18:return!!A.getWinSizeChars;case 19:return!!A.getScreenSizeChars;case 20:return!!A.getIconTitle;case 21:return!!A.getWinTitle;case 22:return!!A.pushTitle;case 23:return!!A.popTitle;case 24:return!!A.setWinLines}return!1}var D;(function(z){z[z.GET_WIN_SIZE_PIXELS=0]="GET_WIN_SIZE_PIXELS",z[z.GET_CELL_SIZE_PIXELS=1]="GET_CELL_SIZE_PIXELS"})(D||(r.WindowsOptionsReportType=D={}));let B=0;class F extends S.Disposable{getAttrData(){return this._curAttrData}constructor(A,M,T,N,V,q,J,X,ce=new C.EscapeSequenceParser){super(),this._bufferService=A,this._charsetService=M,this._coreService=T,this._logService=N,this._optionsService=V,this._oscLinkService=q,this._coreMouseService=J,this._unicodeService=X,this._parser=ce,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new _.StringToUtf32,this._utf8Decoder=new _.Utf8ToUtf32,this._workCell=new h.CellData,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=i.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=i.DEFAULT_ATTR_DATA.clone(),this._onRequestBell=this.register(new o.EventEmitter),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this.register(new o.EventEmitter),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this.register(new o.EventEmitter),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this.register(new o.EventEmitter),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this.register(new o.EventEmitter),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this.register(new o.EventEmitter),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this.register(new o.EventEmitter),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this.register(new o.EventEmitter),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this.register(new o.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this.register(new o.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onScroll=this.register(new o.EventEmitter),this.onScroll=this._onScroll.event,this._onTitleChange=this.register(new o.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onColor=this.register(new o.EventEmitter),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 Y(this._bufferService),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate(P=>this._activeBuffer=P.activeBuffer)),this._parser.setCsiHandlerFallback((P,U)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(P),params:U.toArray()})}),this._parser.setEscHandlerFallback(P=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(P)})}),this._parser.setExecuteHandlerFallback(P=>{this._logService.debug("Unknown EXECUTE code: ",{code:P})}),this._parser.setOscHandlerFallback((P,U,G)=>{this._logService.debug("Unknown OSC code: ",{identifier:P,action:U,data:G})}),this._parser.setDcsHandlerFallback((P,U,G)=>{U==="HOOK"&&(G=G.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(P),action:U,payload:G})}),this._parser.setPrintHandler((P,U,G)=>this.print(P,U,G)),this._parser.registerCsiHandler({final:"@"},P=>this.insertChars(P)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},P=>this.scrollLeft(P)),this._parser.registerCsiHandler({final:"A"},P=>this.cursorUp(P)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},P=>this.scrollRight(P)),this._parser.registerCsiHandler({final:"B"},P=>this.cursorDown(P)),this._parser.registerCsiHandler({final:"C"},P=>this.cursorForward(P)),this._parser.registerCsiHandler({final:"D"},P=>this.cursorBackward(P)),this._parser.registerCsiHandler({final:"E"},P=>this.cursorNextLine(P)),this._parser.registerCsiHandler({final:"F"},P=>this.cursorPrecedingLine(P)),this._parser.registerCsiHandler({final:"G"},P=>this.cursorCharAbsolute(P)),this._parser.registerCsiHandler({final:"H"},P=>this.cursorPosition(P)),this._parser.registerCsiHandler({final:"I"},P=>this.cursorForwardTab(P)),this._parser.registerCsiHandler({final:"J"},P=>this.eraseInDisplay(P,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},P=>this.eraseInDisplay(P,!0)),this._parser.registerCsiHandler({final:"K"},P=>this.eraseInLine(P,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},P=>this.eraseInLine(P,!0)),this._parser.registerCsiHandler({final:"L"},P=>this.insertLines(P)),this._parser.registerCsiHandler({final:"M"},P=>this.deleteLines(P)),this._parser.registerCsiHandler({final:"P"},P=>this.deleteChars(P)),this._parser.registerCsiHandler({final:"S"},P=>this.scrollUp(P)),this._parser.registerCsiHandler({final:"T"},P=>this.scrollDown(P)),this._parser.registerCsiHandler({final:"X"},P=>this.eraseChars(P)),this._parser.registerCsiHandler({final:"Z"},P=>this.cursorBackwardTab(P)),this._parser.registerCsiHandler({final:"`"},P=>this.charPosAbsolute(P)),this._parser.registerCsiHandler({final:"a"},P=>this.hPositionRelative(P)),this._parser.registerCsiHandler({final:"b"},P=>this.repeatPrecedingCharacter(P)),this._parser.registerCsiHandler({final:"c"},P=>this.sendDeviceAttributesPrimary(P)),this._parser.registerCsiHandler({prefix:">",final:"c"},P=>this.sendDeviceAttributesSecondary(P)),this._parser.registerCsiHandler({final:"d"},P=>this.linePosAbsolute(P)),this._parser.registerCsiHandler({final:"e"},P=>this.vPositionRelative(P)),this._parser.registerCsiHandler({final:"f"},P=>this.hVPosition(P)),this._parser.registerCsiHandler({final:"g"},P=>this.tabClear(P)),this._parser.registerCsiHandler({final:"h"},P=>this.setMode(P)),this._parser.registerCsiHandler({prefix:"?",final:"h"},P=>this.setModePrivate(P)),this._parser.registerCsiHandler({final:"l"},P=>this.resetMode(P)),this._parser.registerCsiHandler({prefix:"?",final:"l"},P=>this.resetModePrivate(P)),this._parser.registerCsiHandler({final:"m"},P=>this.charAttributes(P)),this._parser.registerCsiHandler({final:"n"},P=>this.deviceStatus(P)),this._parser.registerCsiHandler({prefix:"?",final:"n"},P=>this.deviceStatusPrivate(P)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},P=>this.softReset(P)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},P=>this.setCursorStyle(P)),this._parser.registerCsiHandler({final:"r"},P=>this.setScrollRegion(P)),this._parser.registerCsiHandler({final:"s"},P=>this.saveCursor(P)),this._parser.registerCsiHandler({final:"t"},P=>this.windowOptions(P)),this._parser.registerCsiHandler({final:"u"},P=>this.restoreCursor(P)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},P=>this.insertColumns(P)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},P=>this.deleteColumns(P)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},P=>this.selectProtected(P)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},P=>this.requestMode(P,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},P=>this.requestMode(P,!1)),this._parser.setExecuteHandler(l.C0.BEL,()=>this.bell()),this._parser.setExecuteHandler(l.C0.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(l.C0.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(l.C0.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(l.C0.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(l.C0.BS,()=>this.backspace()),this._parser.setExecuteHandler(l.C0.HT,()=>this.tab()),this._parser.setExecuteHandler(l.C0.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(l.C0.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(l.C1.IND,()=>this.index()),this._parser.setExecuteHandler(l.C1.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(l.C1.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new E.OscHandler(P=>(this.setTitle(P),this.setIconName(P),!0))),this._parser.registerOscHandler(1,new E.OscHandler(P=>this.setIconName(P))),this._parser.registerOscHandler(2,new E.OscHandler(P=>this.setTitle(P))),this._parser.registerOscHandler(4,new E.OscHandler(P=>this.setOrReportIndexedColor(P))),this._parser.registerOscHandler(8,new E.OscHandler(P=>this.setHyperlink(P))),this._parser.registerOscHandler(10,new E.OscHandler(P=>this.setOrReportFgColor(P))),this._parser.registerOscHandler(11,new E.OscHandler(P=>this.setOrReportBgColor(P))),this._parser.registerOscHandler(12,new E.OscHandler(P=>this.setOrReportCursorColor(P))),this._parser.registerOscHandler(104,new E.OscHandler(P=>this.restoreIndexedColor(P))),this._parser.registerOscHandler(110,new E.OscHandler(P=>this.restoreFgColor(P))),this._parser.registerOscHandler(111,new E.OscHandler(P=>this.restoreBgColor(P))),this._parser.registerOscHandler(112,new E.OscHandler(P=>this.restoreCursorColor(P))),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(const P in p.CHARSETS)this._parser.registerEscHandler({intermediates:"(",final:P},()=>this.selectCharset("("+P)),this._parser.registerEscHandler({intermediates:")",final:P},()=>this.selectCharset(")"+P)),this._parser.registerEscHandler({intermediates:"*",final:P},()=>this.selectCharset("*"+P)),this._parser.registerEscHandler({intermediates:"+",final:P},()=>this.selectCharset("+"+P)),this._parser.registerEscHandler({intermediates:"-",final:P},()=>this.selectCharset("-"+P)),this._parser.registerEscHandler({intermediates:".",final:P},()=>this.selectCharset("."+P)),this._parser.registerEscHandler({intermediates:"/",final:P},()=>this.selectCharset("/"+P));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(P=>(this._logService.error("Parsing error: ",P),P)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new I.DcsHandler((P,U)=>this.requestStatusString(P,U)))}_preserveStack(A,M,T,N){this._parseStack.paused=!0,this._parseStack.cursorStartX=A,this._parseStack.cursorStartY=M,this._parseStack.decodedLength=T,this._parseStack.position=N}_logSlowResolvingAsync(A){this._logService.logLevel<=b.LogLevelEnum.WARN&&Promise.race([A,new Promise((M,T)=>setTimeout(()=>T("#SLOW_TIMEOUT"),5e3))]).catch(M=>{if(M!=="#SLOW_TIMEOUT")throw M;console.warn("async parser handler taking longer than 5000 ms")})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(A,M){let T,N=this._activeBuffer.x,V=this._activeBuffer.y,q=0;const J=this._parseStack.paused;if(J){if(T=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,M))return this._logSlowResolvingAsync(T),T;N=this._parseStack.cursorStartX,V=this._parseStack.cursorStartY,this._parseStack.paused=!1,A.length>L&&(q=this._parseStack.position+L)}if(this._logService.logLevel<=b.LogLevelEnum.DEBUG&&this._logService.debug("parsing data"+(typeof A=="string"?` "${A}"`:` "${Array.prototype.map.call(A,X=>String.fromCharCode(X)).join("")}"`),typeof A=="string"?A.split("").map(X=>X.charCodeAt(0)):A),this._parseBuffer.length<A.length&&this._parseBuffer.length<L&&(this._parseBuffer=new Uint32Array(Math.min(A.length,L))),J||this._dirtyRowTracker.clearRange(),A.length>L)for(let X=q;X<A.length;X+=L){const ce=X+L<A.length?X+L:A.length,P=typeof A=="string"?this._stringDecoder.decode(A.substring(X,ce),this._parseBuffer):this._utf8Decoder.decode(A.subarray(X,ce),this._parseBuffer);if(T=this._parser.parse(this._parseBuffer,P))return this._preserveStack(N,V,P,X),this._logSlowResolvingAsync(T),T}else if(!J){const X=typeof A=="string"?this._stringDecoder.decode(A,this._parseBuffer):this._utf8Decoder.decode(A,this._parseBuffer);if(T=this._parser.parse(this._parseBuffer,X))return this._preserveStack(N,V,X,0),this._logSlowResolvingAsync(T),T}this._activeBuffer.x===N&&this._activeBuffer.y===V||this._onCursorMove.fire(),this._onRequestRefreshRows.fire(this._dirtyRowTracker.start,this._dirtyRowTracker.end)}print(A,M,T){let N,V;const q=this._charsetService.charset,J=this._optionsService.rawOptions.screenReaderMode,X=this._bufferService.cols,ce=this._coreService.decPrivateModes.wraparound,P=this._coreService.modes.insertMode,U=this._curAttrData;let G=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&T-M>0&&G.getWidth(this._activeBuffer.x-1)===2&&G.setCellFromCodePoint(this._activeBuffer.x-1,0,1,U.fg,U.bg,U.extended);for(let K=M;K<T;++K){if(N=A[K],V=this._unicodeService.wcwidth(N),N<127&&q){const se=q[String.fromCharCode(N)];se&&(N=se.charCodeAt(0))}if(J&&this._onA11yChar.fire((0,_.stringFromCodePoint)(N)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),V||!this._activeBuffer.x){if(this._activeBuffer.x+V-1>=X){if(ce){for(;this._activeBuffer.x<X;)G.setCellFromCodePoint(this._activeBuffer.x++,0,1,U.fg,U.bg,U.extended);this._activeBuffer.x=0,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),G=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)}else if(this._activeBuffer.x=X-1,V===2)continue}if(P&&(G.insertCells(this._activeBuffer.x,V,this._activeBuffer.getNullCell(U),U),G.getWidth(X-1)===2&&G.setCellFromCodePoint(X-1,c.NULL_CELL_CODE,c.NULL_CELL_WIDTH,U.fg,U.bg,U.extended)),G.setCellFromCodePoint(this._activeBuffer.x++,N,V,U.fg,U.bg,U.extended),V>0)for(;--V;)G.setCellFromCodePoint(this._activeBuffer.x++,0,0,U.fg,U.bg,U.extended)}else G.getWidth(this._activeBuffer.x-1)?G.addCodepointToCell(this._activeBuffer.x-1,N):G.addCodepointToCell(this._activeBuffer.x-2,N)}T-M>0&&(G.loadCell(this._activeBuffer.x-1,this._workCell),this._workCell.getWidth()===2||this._workCell.getCode()>65535?this._parser.precedingCodepoint=0:this._workCell.isCombined()?this._parser.precedingCodepoint=this._workCell.getChars().charCodeAt(0):this._parser.precedingCodepoint=this._workCell.content),this._activeBuffer.x<X&&T-M>0&&G.getWidth(this._activeBuffer.x)===0&&!G.hasContent(this._activeBuffer.x)&&G.setCellFromCodePoint(this._activeBuffer.x,0,1,U.fg,U.bg,U.extended),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(A,M){return A.final!=="t"||A.prefix||A.intermediates?this._parser.registerCsiHandler(A,M):this._parser.registerCsiHandler(A,T=>!k(T.params[0],this._optionsService.rawOptions.windowOptions)||M(T))}registerDcsHandler(A,M){return this._parser.registerDcsHandler(A,new I.DcsHandler(M))}registerEscHandler(A,M){return this._parser.registerEscHandler(A,M)}registerOscHandler(A,M){return this._parser.registerOscHandler(A,new E.OscHandler(M))}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 A;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&&(!((A=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))===null||A===void 0)&&A.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;const M=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);M.hasWidth(this._activeBuffer.x)&&!M.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;const A=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-A),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(A=this._bufferService.cols-1){this._activeBuffer.x=Math.min(A,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(A,M){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=A,this._activeBuffer.y=this._activeBuffer.scrollTop+M):(this._activeBuffer.x=A,this._activeBuffer.y=M),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(A,M){this._restrictCursor(),this._setCursor(this._activeBuffer.x+A,this._activeBuffer.y+M)}cursorUp(A){const M=this._activeBuffer.y-this._activeBuffer.scrollTop;return M>=0?this._moveCursor(0,-Math.min(M,A.params[0]||1)):this._moveCursor(0,-(A.params[0]||1)),!0}cursorDown(A){const M=this._activeBuffer.scrollBottom-this._activeBuffer.y;return M>=0?this._moveCursor(0,Math.min(M,A.params[0]||1)):this._moveCursor(0,A.params[0]||1),!0}cursorForward(A){return this._moveCursor(A.params[0]||1,0),!0}cursorBackward(A){return this._moveCursor(-(A.params[0]||1),0),!0}cursorNextLine(A){return this.cursorDown(A),this._activeBuffer.x=0,!0}cursorPrecedingLine(A){return this.cursorUp(A),this._activeBuffer.x=0,!0}cursorCharAbsolute(A){return this._setCursor((A.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(A){return this._setCursor(A.length>=2?(A.params[1]||1)-1:0,(A.params[0]||1)-1),!0}charPosAbsolute(A){return this._setCursor((A.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(A){return this._moveCursor(A.params[0]||1,0),!0}linePosAbsolute(A){return this._setCursor(this._activeBuffer.x,(A.params[0]||1)-1),!0}vPositionRelative(A){return this._moveCursor(0,A.params[0]||1),!0}hVPosition(A){return this.cursorPosition(A),!0}tabClear(A){const M=A.params[0];return M===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:M===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(A){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let M=A.params[0]||1;for(;M--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(A){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let M=A.params[0]||1;for(;M--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(A){const M=A.params[0];return M===1&&(this._curAttrData.bg|=536870912),M!==2&&M!==0||(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(A,M,T,N=!1,V=!1){const q=this._activeBuffer.lines.get(this._activeBuffer.ybase+A);q.replaceCells(M,T,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData(),V),N&&(q.isWrapped=!1)}_resetBufferLine(A,M=!1){const T=this._activeBuffer.lines.get(this._activeBuffer.ybase+A);T&&(T.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),M),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+A),T.isWrapped=!1)}eraseInDisplay(A,M=!1){let T;switch(this._restrictCursor(this._bufferService.cols),A.params[0]){case 0:for(T=this._activeBuffer.y,this._dirtyRowTracker.markDirty(T),this._eraseInBufferLine(T++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,M);T<this._bufferService.rows;T++)this._resetBufferLine(T,M);this._dirtyRowTracker.markDirty(T);break;case 1:for(T=this._activeBuffer.y,this._dirtyRowTracker.markDirty(T),this._eraseInBufferLine(T,0,this._activeBuffer.x+1,!0,M),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(T+1).isWrapped=!1);T--;)this._resetBufferLine(T,M);this._dirtyRowTracker.markDirty(0);break;case 2:for(T=this._bufferService.rows,this._dirtyRowTracker.markDirty(T-1);T--;)this._resetBufferLine(T,M);this._dirtyRowTracker.markDirty(0);break;case 3:const N=this._activeBuffer.lines.length-this._bufferService.rows;N>0&&(this._activeBuffer.lines.trimStart(N),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-N,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-N,0),this._onScroll.fire(0))}return!0}eraseInLine(A,M=!1){switch(this._restrictCursor(this._bufferService.cols),A.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,M);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,M);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,M)}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(A){this._restrictCursor();let M=A.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const T=this._activeBuffer.ybase+this._activeBuffer.y,N=this._bufferService.rows-1-this._activeBuffer.scrollBottom,V=this._bufferService.rows-1+this._activeBuffer.ybase-N+1;for(;M--;)this._activeBuffer.lines.splice(V-1,1),this._activeBuffer.lines.splice(T,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(A){this._restrictCursor();let M=A.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const T=this._activeBuffer.ybase+this._activeBuffer.y;let N;for(N=this._bufferService.rows-1-this._activeBuffer.scrollBottom,N=this._bufferService.rows-1+this._activeBuffer.ybase-N;M--;)this._activeBuffer.lines.splice(T,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(A){this._restrictCursor();const M=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return M&&(M.insertCells(this._activeBuffer.x,A.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(A){this._restrictCursor();const M=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return M&&(M.deleteCells(this._activeBuffer.x,A.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(A){let M=A.params[0]||1;for(;M--;)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(A){let M=A.params[0]||1;for(;M--;)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(i.DEFAULT_ATTR_DATA));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(A){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const M=A.params[0]||1;for(let T=this._activeBuffer.scrollTop;T<=this._activeBuffer.scrollBottom;++T){const N=this._activeBuffer.lines.get(this._activeBuffer.ybase+T);N.deleteCells(0,M,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),N.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(A){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const M=A.params[0]||1;for(let T=this._activeBuffer.scrollTop;T<=this._activeBuffer.scrollBottom;++T){const N=this._activeBuffer.lines.get(this._activeBuffer.ybase+T);N.insertCells(0,M,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),N.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(A){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const M=A.params[0]||1;for(let T=this._activeBuffer.scrollTop;T<=this._activeBuffer.scrollBottom;++T){const N=this._activeBuffer.lines.get(this._activeBuffer.ybase+T);N.insertCells(this._activeBuffer.x,M,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),N.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(A){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const M=A.params[0]||1;for(let T=this._activeBuffer.scrollTop;T<=this._activeBuffer.scrollBottom;++T){const N=this._activeBuffer.lines.get(this._activeBuffer.ybase+T);N.deleteCells(this._activeBuffer.x,M,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),N.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(A){this._restrictCursor();const M=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return M&&(M.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(A.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(A){if(!this._parser.precedingCodepoint)return!0;const M=A.params[0]||1,T=new Uint32Array(M);for(let N=0;N<M;++N)T[N]=this._parser.precedingCodepoint;return this.print(T,0,T.length),!0}sendDeviceAttributesPrimary(A){return A.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(l.C0.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(l.C0.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(A){return A.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(l.C0.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(l.C0.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(A.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(l.C0.ESC+"[>83;40003;0c")),!0}_is(A){return(this._optionsService.rawOptions.termName+"").indexOf(A)===0}setMode(A){for(let M=0;M<A.length;M++)switch(A.params[M]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0}return!0}setModePrivate(A){for(let M=0;M<A.length;M++)switch(A.params[M]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,p.DEFAULT_CHARSET),this._charsetService.setgCharset(1,p.DEFAULT_CHARSET),this._charsetService.setgCharset(2,p.DEFAULT_CHARSET),this._charsetService.setgCharset(3,p.DEFAULT_CHARSET);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(0,this._bufferService.rows-1),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0}return!0}resetMode(A){for(let M=0;M<A.length;M++)switch(A.params[M]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1}return!0}resetModePrivate(A){for(let M=0;M<A.length;M++)switch(A.params[M]){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:case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),A.params[M]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(0,this._bufferService.rows-1),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1}return!0}requestMode(A,M){const T=this._coreService.decPrivateModes,{activeProtocol:N,activeEncoding:V}=this._coreMouseService,q=this._coreService,{buffers:J,cols:X}=this._bufferService,{active:ce,alt:P}=J,U=this._optionsService.rawOptions,G=oe=>oe?1:2,K=A.params[0];return se=K,Q=M?K===2?4:K===4?G(q.modes.insertMode):K===12?3:K===20?G(U.convertEol):0:K===1?G(T.applicationCursorKeys):K===3?U.windowOptions.setWinLines?X===80?2:X===132?1:0:0:K===6?G(T.origin):K===7?G(T.wraparound):K===8?3:K===9?G(N==="X10"):K===12?G(U.cursorBlink):K===25?G(!q.isCursorHidden):K===45?G(T.reverseWraparound):K===66?G(T.applicationKeypad):K===67?4:K===1e3?G(N==="VT200"):K===1002?G(N==="DRAG"):K===1003?G(N==="ANY"):K===1004?G(T.sendFocus):K===1005?4:K===1006?G(V==="SGR"):K===1015?4:K===1016?G(V==="SGR_PIXELS"):K===1048?1:K===47||K===1047||K===1049?G(ce===P):K===2004?G(T.bracketedPasteMode):0,q.triggerDataEvent(`${l.C0.ESC}[${M?"":"?"}${se};${Q}$y`),!0;var se,Q}_updateAttrColor(A,M,T,N,V){return M===2?(A|=50331648,A&=-16777216,A|=f.AttributeData.fromColorRGB([T,N,V])):M===5&&(A&=-50331904,A|=33554432|255&T),A}_extractColor(A,M,T){const N=[0,0,-1,0,0,0];let V=0,q=0;do{if(N[q+V]=A.params[M+q],A.hasSubParams(M+q)){const J=A.getSubParams(M+q);let X=0;do N[1]===5&&(V=1),N[q+X+1+V]=J[X];while(++X<J.length&&X+q+1+V<N.length);break}if(N[1]===5&&q+V>=2||N[1]===2&&q+V>=5)break;N[1]&&(V=1)}while(++q+M<A.length&&q+V<N.length);for(let J=2;J<N.length;++J)N[J]===-1&&(N[J]=0);switch(N[0]){case 38:T.fg=this._updateAttrColor(T.fg,N[1],N[3],N[4],N[5]);break;case 48:T.bg=this._updateAttrColor(T.bg,N[1],N[3],N[4],N[5]);break;case 58:T.extended=T.extended.clone(),T.extended.underlineColor=this._updateAttrColor(T.extended.underlineColor,N[1],N[3],N[4],N[5])}return q}_processUnderline(A,M){M.extended=M.extended.clone(),(!~A||A>5)&&(A=1),M.extended.underlineStyle=A,M.fg|=268435456,A===0&&(M.fg&=-268435457),M.updateExtended()}_processSGR0(A){A.fg=i.DEFAULT_ATTR_DATA.fg,A.bg=i.DEFAULT_ATTR_DATA.bg,A.extended=A.extended.clone(),A.extended.underlineStyle=0,A.extended.underlineColor&=-67108864,A.updateExtended()}charAttributes(A){if(A.length===1&&A.params[0]===0)return this._processSGR0(this._curAttrData),!0;const M=A.length;let T;const N=this._curAttrData;for(let V=0;V<M;V++)T=A.params[V],T>=30&&T<=37?(N.fg&=-50331904,N.fg|=16777216|T-30):T>=40&&T<=47?(N.bg&=-50331904,N.bg|=16777216|T-40):T>=90&&T<=97?(N.fg&=-50331904,N.fg|=16777224|T-90):T>=100&&T<=107?(N.bg&=-50331904,N.bg|=16777224|T-100):T===0?this._processSGR0(N):T===1?N.fg|=134217728:T===3?N.bg|=67108864:T===4?(N.fg|=268435456,this._processUnderline(A.hasSubParams(V)?A.getSubParams(V)[0]:1,N)):T===5?N.fg|=536870912:T===7?N.fg|=67108864:T===8?N.fg|=1073741824:T===9?N.fg|=2147483648:T===2?N.bg|=134217728:T===21?this._processUnderline(2,N):T===22?(N.fg&=-134217729,N.bg&=-134217729):T===23?N.bg&=-67108865:T===24?(N.fg&=-268435457,this._processUnderline(0,N)):T===25?N.fg&=-536870913:T===27?N.fg&=-67108865:T===28?N.fg&=-1073741825:T===29?N.fg&=2147483647:T===39?(N.fg&=-67108864,N.fg|=16777215&i.DEFAULT_ATTR_DATA.fg):T===49?(N.bg&=-67108864,N.bg|=16777215&i.DEFAULT_ATTR_DATA.bg):T===38||T===48||T===58?V+=this._extractColor(A,V,N):T===53?N.bg|=1073741824:T===55?N.bg&=-1073741825:T===59?(N.extended=N.extended.clone(),N.extended.underlineColor=-1,N.updateExtended()):T===100?(N.fg&=-67108864,N.fg|=16777215&i.DEFAULT_ATTR_DATA.fg,N.bg&=-67108864,N.bg|=16777215&i.DEFAULT_ATTR_DATA.bg):this._logService.debug("Unknown SGR attribute: %d.",T);return!0}deviceStatus(A){switch(A.params[0]){case 5:this._coreService.triggerDataEvent(`${l.C0.ESC}[0n`);break;case 6:const M=this._activeBuffer.y+1,T=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${l.C0.ESC}[${M};${T}R`)}return!0}deviceStatusPrivate(A){if(A.params[0]===6){const M=this._activeBuffer.y+1,T=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${l.C0.ESC}[?${M};${T}R`)}return!0}softReset(A){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=i.DEFAULT_ATTR_DATA.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(A){const M=A.params[0]||1;switch(M){case 1:case 2:this._optionsService.options.cursorStyle="block";break;case 3:case 4:this._optionsService.options.cursorStyle="underline";break;case 5:case 6:this._optionsService.options.cursorStyle="bar"}const T=M%2==1;return this._optionsService.options.cursorBlink=T,!0}setScrollRegion(A){const M=A.params[0]||1;let T;return(A.length<2||(T=A.params[1])>this._bufferService.rows||T===0)&&(T=this._bufferService.rows),T>M&&(this._activeBuffer.scrollTop=M-1,this._activeBuffer.scrollBottom=T-1,this._setCursor(0,0)),!0}windowOptions(A){if(!k(A.params[0],this._optionsService.rawOptions.windowOptions))return!0;const M=A.length>1?A.params[1]:0;switch(A.params[0]){case 14:M!==2&&this._onRequestWindowsOptionsReport.fire(D.GET_WIN_SIZE_PIXELS);break;case 16:this._onRequestWindowsOptionsReport.fire(D.GET_CELL_SIZE_PIXELS);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${l.C0.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:M!==0&&M!==2||(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>10&&this._windowTitleStack.shift()),M!==0&&M!==1||(this._iconNameStack.push(this._iconName),this._iconNameStack.length>10&&this._iconNameStack.shift());break;case 23:M!==0&&M!==2||this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),M!==0&&M!==1||this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop())}return!0}saveCursor(A){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(A){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(A){return this._windowTitle=A,this._onTitleChange.fire(A),!0}setIconName(A){return this._iconName=A,!0}setOrReportIndexedColor(A){const M=[],T=A.split(";");for(;T.length>1;){const N=T.shift(),V=T.shift();if(/^\d+$/.exec(N)){const q=parseInt(N);if($(q))if(V==="?")M.push({type:0,index:q});else{const J=(0,v.parseColor)(V);J&&M.push({type:1,index:q,color:J})}}}return M.length&&this._onColor.fire(M),!0}setHyperlink(A){const M=A.split(";");return!(M.length<2)&&(M[1]?this._createHyperlink(M[0],M[1]):!M[0]&&this._finishHyperlink())}_createHyperlink(A,M){this._getCurrentLinkId()&&this._finishHyperlink();const T=A.split(":");let N;const V=T.findIndex(q=>q.startsWith("id="));return V!==-1&&(N=T[V].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:N,uri:M}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(A,M){const T=A.split(";");for(let N=0;N<T.length&&!(M>=this._specialColors.length);++N,++M)if(T[N]==="?")this._onColor.fire([{type:0,index:this._specialColors[M]}]);else{const V=(0,v.parseColor)(T[N]);V&&this._onColor.fire([{type:1,index:this._specialColors[M],color:V}])}return!0}setOrReportFgColor(A){return this._setOrReportSpecialColor(A,0)}setOrReportBgColor(A){return this._setOrReportSpecialColor(A,1)}setOrReportCursorColor(A){return this._setOrReportSpecialColor(A,2)}restoreIndexedColor(A){if(!A)return this._onColor.fire([{type:2}]),!0;const M=[],T=A.split(";");for(let N=0;N<T.length;++N)if(/^\d+$/.exec(T[N])){const V=parseInt(T[N]);$(V)&&M.push({type:2,index:V})}return M.length&&this._onColor.fire(M),!0}restoreFgColor(A){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(A){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(A){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,p.DEFAULT_CHARSET),!0}selectCharset(A){return A.length!==2?(this.selectDefaultCharset(),!0):(A[0]==="/"||this._charsetService.setgCharset(x[A[0]],p.CHARSETS[A[1]]||p.DEFAULT_CHARSET),!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){const A=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,A,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=i.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=i.DEFAULT_ATTR_DATA.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=67108863&this._curAttrData.bg,this._eraseAttrDataInternal}setgLevel(A){return this._charsetService.setgLevel(A),!0}screenAlignmentPattern(){const A=new h.CellData;A.content=4194373,A.fg=this._curAttrData.fg,A.bg=this._curAttrData.bg,this._setCursor(0,0);for(let M=0;M<this._bufferService.rows;++M){const T=this._activeBuffer.ybase+this._activeBuffer.y+M,N=this._activeBuffer.lines.get(T);N&&(N.fill(A),N.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(A,M){const T=this._bufferService.buffer,N=this._optionsService.rawOptions;return(V=>(this._coreService.triggerDataEvent(`${l.C0.ESC}${V}${l.C0.ESC}\\`),!0))(A==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:A==='"p'?'P1$r61;1"p':A==="r"?`P1$r${T.scrollTop+1};${T.scrollBottom+1}r`:A==="m"?"P1$r0m":A===" q"?`P1$r${{block:2,underline:4,bar:6}[N.cursorStyle]-(N.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(A,M){this._dirtyRowTracker.markRangeDirty(A,M)}}r.InputHandler=F;let Y=class{constructor(z){this._bufferService=z,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(z){z<this.start?this.start=z:z>this.end&&(this.end=z)}markRangeDirty(z,A){z>A&&(B=z,z=A,A=B),z<this.start&&(this.start=z),A>this.end&&(this.end=A)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};function $(z){return 0<=z&&z<256}Y=u([m(0,b.IBufferService)],Y)},844:(y,r)=>{function n(u){for(const m of u)m.dispose();u.length=0}Object.defineProperty(r,"__esModule",{value:!0}),r.getDisposeArrayDisposable=r.disposeArray=r.toDisposable=r.MutableDisposable=r.Disposable=void 0,r.Disposable=class{constructor(){this._disposables=[],this._isDisposed=!1}dispose(){this._isDisposed=!0;for(const u of this._disposables)u.dispose();this._disposables.length=0}register(u){return this._disposables.push(u),u}unregister(u){const m=this._disposables.indexOf(u);m!==-1&&this._disposables.splice(m,1)}},r.MutableDisposable=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(u){var m;this._isDisposed||u===this._value||((m=this._value)===null||m===void 0||m.dispose(),this._value=u)}clear(){this.value=void 0}dispose(){var u;this._isDisposed=!0,(u=this._value)===null||u===void 0||u.dispose(),this._value=void 0}},r.toDisposable=function(u){return{dispose:u}},r.disposeArray=n,r.getDisposeArrayDisposable=function(u){return{dispose:()=>n(u)}}},1505:(y,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.FourKeyMap=r.TwoKeyMap=void 0;class n{constructor(){this._data={}}set(m,l,p){this._data[m]||(this._data[m]={}),this._data[m][l]=p}get(m,l){return this._data[m]?this._data[m][l]:void 0}clear(){this._data={}}}r.TwoKeyMap=n,r.FourKeyMap=class{constructor(){this._data=new n}set(u,m,l,p,C){this._data.get(u,m)||this._data.set(u,m,new n),this._data.get(u,m).set(l,p,C)}get(u,m,l,p){var C;return(C=this._data.get(u,m))===null||C===void 0?void 0:C.get(l,p)}clear(){this._data.clear()}}},6114:(y,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.isChromeOS=r.isLinux=r.isWindows=r.isIphone=r.isIpad=r.isMac=r.getSafariVersion=r.isSafari=r.isLegacyEdge=r.isFirefox=r.isNode=void 0,r.isNode=typeof navigator>"u";const n=r.isNode?"node":navigator.userAgent,u=r.isNode?"node":navigator.platform;r.isFirefox=n.includes("Firefox"),r.isLegacyEdge=n.includes("Edge"),r.isSafari=/^((?!chrome|android).)*safari/i.test(n),r.getSafariVersion=function(){if(!r.isSafari)return 0;const m=n.match(/Version\/(\d+)/);return m===null||m.length<2?0:parseInt(m[1])},r.isMac=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(u),r.isIpad=u==="iPad",r.isIphone=u==="iPhone",r.isWindows=["Windows","Win16","Win32","WinCE"].includes(u),r.isLinux=u.indexOf("Linux")>=0,r.isChromeOS=/\bCrOS\b/.test(n)},6106:(y,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.SortedList=void 0;let n=0;r.SortedList=class{constructor(u){this._getKey=u,this._array=[]}clear(){this._array.length=0}insert(u){this._array.length!==0?(n=this._search(this._getKey(u)),this._array.splice(n,0,u)):this._array.push(u)}delete(u){if(this._array.length===0)return!1;const m=this._getKey(u);if(m===void 0||(n=this._search(m),n===-1)||this._getKey(this._array[n])!==m)return!1;do if(this._array[n]===u)return this._array.splice(n,1),!0;while(++n<this._array.length&&this._getKey(this._array[n])===m);return!1}*getKeyIterator(u){if(this._array.length!==0&&(n=this._search(u),!(n<0||n>=this._array.length)&&this._getKey(this._array[n])===u))do yield this._array[n];while(++n<this._array.length&&this._getKey(this._array[n])===u)}forEachByKey(u,m){if(this._array.length!==0&&(n=this._search(u),!(n<0||n>=this._array.length)&&this._getKey(this._array[n])===u))do m(this._array[n]);while(++n<this._array.length&&this._getKey(this._array[n])===u)}values(){return[...this._array].values()}_search(u){let m=0,l=this._array.length-1;for(;l>=m;){let p=m+l>>1;const C=this._getKey(this._array[p]);if(C>u)l=p-1;else{if(!(C<u)){for(;p>0&&this._getKey(this._array[p-1])===u;)p--;return p}m=p+1}}return m}}},7226:(y,r,n)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.DebouncedIdleTask=r.IdleTaskQueue=r.PriorityTaskQueue=void 0;const u=n(6114);class m{constructor(){this._tasks=[],this._i=0}enqueue(C){this._tasks.push(C),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(C){this._idleCallback=void 0;let S=0,_=0,i=C.timeRemaining(),o=0;for(;this._i<this._tasks.length;){if(S=Date.now(),this._tasks[this._i]()||this._i++,S=Math.max(1,Date.now()-S),_=Math.max(S,_),o=C.timeRemaining(),1.5*_>o)return i-S<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(i-S))}ms`),void this._start();i=o}this.clear()}}class l extends m{_requestCallback(C){return setTimeout(()=>C(this._createDeadline(16)))}_cancelCallback(C){clearTimeout(C)}_createDeadline(C){const S=Date.now()+C;return{timeRemaining:()=>Math.max(0,S-Date.now())}}}r.PriorityTaskQueue=l,r.IdleTaskQueue=!u.isNode&&"requestIdleCallback"in window?class extends m{_requestCallback(p){return requestIdleCallback(p)}_cancelCallback(p){cancelIdleCallback(p)}}:l,r.DebouncedIdleTask=class{constructor(){this._queue=new r.IdleTaskQueue}set(p){this._queue.clear(),this._queue.enqueue(p)}flush(){this._queue.flush()}}},9282:(y,r,n)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.updateWindowsModeWrappedState=void 0;const u=n(643);r.updateWindowsModeWrappedState=function(m){const l=m.buffer.lines.get(m.buffer.ybase+m.buffer.y-1),p=l==null?void 0:l.get(m.cols-1),C=m.buffer.lines.get(m.buffer.ybase+m.buffer.y);C&&p&&(C.isWrapped=p[u.CHAR_DATA_CODE_INDEX]!==u.NULL_CELL_CODE&&p[u.CHAR_DATA_CODE_INDEX]!==u.WHITESPACE_CELL_CODE)}},3734:(y,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.ExtendedAttrs=r.AttributeData=void 0;class n{constructor(){this.fg=0,this.bg=0,this.extended=new u}static toColorRGB(l){return[l>>>16&255,l>>>8&255,255&l]}static fromColorRGB(l){return(255&l[0])<<16|(255&l[1])<<8|255&l[2]}clone(){const l=new n;return l.fg=this.fg,l.bg=this.bg,l.extended=this.extended.clone(),l}isInverse(){return 67108864&this.fg}isBold(){return 134217728&this.fg}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:268435456&this.fg}isBlink(){return 536870912&this.fg}isInvisible(){return 1073741824&this.fg}isItalic(){return 67108864&this.bg}isDim(){return 134217728&this.bg}isStrikethrough(){return 2147483648&this.fg}isProtected(){return 536870912&this.bg}isOverline(){return 1073741824&this.bg}getFgColorMode(){return 50331648&this.fg}getBgColorMode(){return 50331648&this.bg}isFgRGB(){return(50331648&this.fg)==50331648}isBgRGB(){return(50331648&this.bg)==50331648}isFgPalette(){return(50331648&this.fg)==16777216||(50331648&this.fg)==33554432}isBgPalette(){return(50331648&this.bg)==16777216||(50331648&this.bg)==33554432}isFgDefault(){return(50331648&this.fg)==0}isBgDefault(){return(50331648&this.bg)==0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(50331648&this.fg){case 16777216:case 33554432:return 255&this.fg;case 50331648:return 16777215&this.fg;default:return-1}}getBgColor(){switch(50331648&this.bg){case 16777216:case 33554432:return 255&this.bg;case 50331648:return 16777215&this.bg;default:return-1}}hasExtendedAttrs(){return 268435456&this.bg}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(268435456&this.bg&&~this.extended.underlineColor)switch(50331648&this.extended.underlineColor){case 16777216:case 33554432:return 255&this.extended.underlineColor;case 50331648:return 16777215&this.extended.underlineColor;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return 268435456&this.bg&&~this.extended.underlineColor?50331648&this.extended.underlineColor:this.getFgColorMode()}isUnderlineColorRGB(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==16777216||(50331648&this.extended.underlineColor)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==0:this.isFgDefault()}getUnderlineStyle(){return 268435456&this.fg?268435456&this.bg?this.extended.underlineStyle:1:0}}r.AttributeData=n;class u{get ext(){return this._urlId?-469762049&this._ext|this.underlineStyle<<26:this._ext}set ext(l){this._ext=l}get underlineStyle(){return this._urlId?5:(469762048&this._ext)>>26}set underlineStyle(l){this._ext&=-469762049,this._ext|=l<<26&469762048}get underlineColor(){return 67108863&this._ext}set underlineColor(l){this._ext&=-67108864,this._ext|=67108863&l}get urlId(){return this._urlId}set urlId(l){this._urlId=l}constructor(l=0,p=0){this._ext=0,this._urlId=0,this._ext=l,this._urlId=p}clone(){return new u(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}}r.ExtendedAttrs=u},9092:(y,r,n)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.Buffer=r.MAX_BUFFER_SIZE=void 0;const u=n(6349),m=n(7226),l=n(3734),p=n(8437),C=n(4634),S=n(511),_=n(643),i=n(4863),o=n(7116);r.MAX_BUFFER_SIZE=4294967295,r.Buffer=class{constructor(c,h,f){this._hasScrollback=c,this._optionsService=h,this._bufferService=f,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=p.DEFAULT_ATTR_DATA.clone(),this.savedCharset=o.DEFAULT_CHARSET,this.markers=[],this._nullCell=S.CellData.fromCharData([0,_.NULL_CELL_CHAR,_.NULL_CELL_WIDTH,_.NULL_CELL_CODE]),this._whitespaceCell=S.CellData.fromCharData([0,_.WHITESPACE_CELL_CHAR,_.WHITESPACE_CELL_WIDTH,_.WHITESPACE_CELL_CODE]),this._isClearing=!1,this._memoryCleanupQueue=new m.IdleTaskQueue,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new u.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(c){return c?(this._nullCell.fg=c.fg,this._nullCell.bg=c.bg,this._nullCell.extended=c.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new l.ExtendedAttrs),this._nullCell}getWhitespaceCell(c){return c?(this._whitespaceCell.fg=c.fg,this._whitespaceCell.bg=c.bg,this._whitespaceCell.extended=c.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new l.ExtendedAttrs),this._whitespaceCell}getBlankLine(c,h){return new p.BufferLine(this._bufferService.cols,this.getNullCell(c),h)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){const c=this.ybase+this.y-this.ydisp;return c>=0&&c<this._rows}_getCorrectBufferLength(c){if(!this._hasScrollback)return c;const h=c+this._optionsService.rawOptions.scrollback;return h>r.MAX_BUFFER_SIZE?r.MAX_BUFFER_SIZE:h}fillViewportRows(c){if(this.lines.length===0){c===void 0&&(c=p.DEFAULT_ATTR_DATA);let h=this._rows;for(;h--;)this.lines.push(this.getBlankLine(c))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new u.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(c,h){const f=this.getNullCell(p.DEFAULT_ATTR_DATA);let b=0;const E=this._getCorrectBufferLength(h);if(E>this.lines.maxLength&&(this.lines.maxLength=E),this.lines.length>0){if(this._cols<c)for(let v=0;v<this.lines.length;v++)b+=+this.lines.get(v).resize(c,f);let I=0;if(this._rows<h)for(let v=this._rows;v<h;v++)this.lines.length<h+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new p.BufferLine(c,f)):this.ybase>0&&this.lines.length<=this.ybase+this.y+I+1?(this.ybase--,I++,this.ydisp>0&&this.ydisp--):this.lines.push(new p.BufferLine(c,f)));else for(let v=this._rows;v>h;v--)this.lines.length>h+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(E<this.lines.maxLength){const v=this.lines.length-E;v>0&&(this.lines.trimStart(v),this.ybase=Math.max(this.ybase-v,0),this.ydisp=Math.max(this.ydisp-v,0),this.savedY=Math.max(this.savedY-v,0)),this.lines.maxLength=E}this.x=Math.min(this.x,c-1),this.y=Math.min(this.y,h-1),I&&(this.y+=I),this.savedX=Math.min(this.savedX,c-1),this.scrollTop=0}if(this.scrollBottom=h-1,this._isReflowEnabled&&(this._reflow(c,h),this._cols>c))for(let I=0;I<this.lines.length;I++)b+=+this.lines.get(I).resize(c,f);this._cols=c,this._rows=h,this._memoryCleanupQueue.clear(),b>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let c=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,c=!1);let h=0;for(;this._memoryCleanupPosition<this.lines.length;)if(h+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),h>100)return!0;return c}get _isReflowEnabled(){const c=this._optionsService.rawOptions.windowsPty;return c&&c.buildNumber?this._hasScrollback&&c.backend==="conpty"&&c.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(c,h){this._cols!==c&&(c>this._cols?this._reflowLarger(c,h):this._reflowSmaller(c,h))}_reflowLarger(c,h){const f=(0,C.reflowLargerGetLinesToRemove)(this.lines,this._cols,c,this.ybase+this.y,this.getNullCell(p.DEFAULT_ATTR_DATA));if(f.length>0){const b=(0,C.reflowLargerCreateNewLayout)(this.lines,f);(0,C.reflowLargerApplyNewLayout)(this.lines,b.layout),this._reflowLargerAdjustViewport(c,h,b.countRemoved)}}_reflowLargerAdjustViewport(c,h,f){const b=this.getNullCell(p.DEFAULT_ATTR_DATA);let E=f;for(;E-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<h&&this.lines.push(new p.BufferLine(c,b))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-f,0)}_reflowSmaller(c,h){const f=this.getNullCell(p.DEFAULT_ATTR_DATA),b=[];let E=0;for(let I=this.lines.length-1;I>=0;I--){let v=this.lines.get(I);if(!v||!v.isWrapped&&v.getTrimmedLength()<=c)continue;const x=[v];for(;v.isWrapped&&I>0;)v=this.lines.get(--I),x.unshift(v);const L=this.ybase+this.y;if(L>=I&&L<I+x.length)continue;const k=x[x.length-1].getTrimmedLength(),D=(0,C.reflowSmallerGetNewLineLengths)(x,this._cols,c),B=D.length-x.length;let F;F=this.ybase===0&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+B):Math.max(0,this.lines.length-this.lines.maxLength+B);const Y=[];for(let N=0;N<B;N++){const V=this.getBlankLine(p.DEFAULT_ATTR_DATA,!0);Y.push(V)}Y.length>0&&(b.push({start:I+x.length+E,newLines:Y}),E+=Y.length),x.push(...Y);let $=D.length-1,z=D[$];z===0&&($--,z=D[$]);let A=x.length-B-1,M=k;for(;A>=0;){const N=Math.min(M,z);if(x[$]===void 0)break;if(x[$].copyCellsFrom(x[A],M-N,z-N,N,!0),z-=N,z===0&&($--,z=D[$]),M-=N,M===0){A--;const V=Math.max(A,0);M=(0,C.getWrappedLineTrimmedLength)(x,V,this._cols)}}for(let N=0;N<x.length;N++)D[N]<c&&x[N].setCell(D[N],f);let T=B-F;for(;T-- >0;)this.ybase===0?this.y<h-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+E)-h&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+B,this.ybase+h-1)}if(b.length>0){const I=[],v=[];for(let $=0;$<this.lines.length;$++)v.push(this.lines.get($));const x=this.lines.length;let L=x-1,k=0,D=b[k];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+E);let B=0;for(let $=Math.min(this.lines.maxLength-1,x+E-1);$>=0;$--)if(D&&D.start>L+B){for(let z=D.newLines.length-1;z>=0;z--)this.lines.set($--,D.newLines[z]);$++,I.push({index:L+1,amount:D.newLines.length}),B+=D.newLines.length,D=b[++k]}else this.lines.set($,v[L--]);let F=0;for(let $=I.length-1;$>=0;$--)I[$].index+=F,this.lines.onInsertEmitter.fire(I[$]),F+=I[$].amount;const Y=Math.max(0,x+E-this.lines.maxLength);Y>0&&this.lines.onTrimEmitter.fire(Y)}}translateBufferLineToString(c,h,f=0,b){const E=this.lines.get(c);return E?E.translateToString(h,f,b):""}getWrappedRangeForLine(c){let h=c,f=c;for(;h>0&&this.lines.get(h).isWrapped;)h--;for(;f+1<this.lines.length&&this.lines.get(f+1).isWrapped;)f++;return{first:h,last:f}}setupTabStops(c){for(c!=null?this.tabs[c]||(c=this.prevStop(c)):(this.tabs={},c=0);c<this._cols;c+=this._optionsService.rawOptions.tabStopWidth)this.tabs[c]=!0}prevStop(c){for(c==null&&(c=this.x);!this.tabs[--c]&&c>0;);return c>=this._cols?this._cols-1:c<0?0:c}nextStop(c){for(c==null&&(c=this.x);!this.tabs[++c]&&c<this._cols;);return c>=this._cols?this._cols-1:c<0?0:c}clearMarkers(c){this._isClearing=!0;for(let h=0;h<this.markers.length;h++)this.markers[h].line===c&&(this.markers[h].dispose(),this.markers.splice(h--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let c=0;c<this.markers.length;c++)this.markers[c].dispose(),this.markers.splice(c--,1);this._isClearing=!1}addMarker(c){const h=new i.Marker(c);return this.markers.push(h),h.register(this.lines.onTrim(f=>{h.line-=f,h.line<0&&h.dispose()})),h.register(this.lines.onInsert(f=>{h.line>=f.index&&(h.line+=f.amount)})),h.register(this.lines.onDelete(f=>{h.line>=f.index&&h.line<f.index+f.amount&&h.dispose(),h.line>f.index&&(h.line-=f.amount)})),h.register(h.onDispose(()=>this._removeMarker(h))),h}_removeMarker(c){this._isClearing||this.markers.splice(this.markers.indexOf(c),1)}}},8437:(y,r,n)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.BufferLine=r.DEFAULT_ATTR_DATA=void 0;const u=n(3734),m=n(511),l=n(643),p=n(482);r.DEFAULT_ATTR_DATA=Object.freeze(new u.AttributeData);let C=0;class S{constructor(i,o,c=!1){this.isWrapped=c,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(3*i);const h=o||m.CellData.fromCharData([0,l.NULL_CELL_CHAR,l.NULL_CELL_WIDTH,l.NULL_CELL_CODE]);for(let f=0;f<i;++f)this.setCell(f,h);this.length=i}get(i){const o=this._data[3*i+0],c=2097151&o;return[this._data[3*i+1],2097152&o?this._combined[i]:c?(0,p.stringFromCodePoint)(c):"",o>>22,2097152&o?this._combined[i].charCodeAt(this._combined[i].length-1):c]}set(i,o){this._data[3*i+1]=o[l.CHAR_DATA_ATTR_INDEX],o[l.CHAR_DATA_CHAR_INDEX].length>1?(this._combined[i]=o[1],this._data[3*i+0]=2097152|i|o[l.CHAR_DATA_WIDTH_INDEX]<<22):this._data[3*i+0]=o[l.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|o[l.CHAR_DATA_WIDTH_INDEX]<<22}getWidth(i){return this._data[3*i+0]>>22}hasWidth(i){return 12582912&this._data[3*i+0]}getFg(i){return this._data[3*i+1]}getBg(i){return this._data[3*i+2]}hasContent(i){return 4194303&this._data[3*i+0]}getCodePoint(i){const o=this._data[3*i+0];return 2097152&o?this._combined[i].charCodeAt(this._combined[i].length-1):2097151&o}isCombined(i){return 2097152&this._data[3*i+0]}getString(i){const o=this._data[3*i+0];return 2097152&o?this._combined[i]:2097151&o?(0,p.stringFromCodePoint)(2097151&o):""}isProtected(i){return 536870912&this._data[3*i+2]}loadCell(i,o){return C=3*i,o.content=this._data[C+0],o.fg=this._data[C+1],o.bg=this._data[C+2],2097152&o.content&&(o.combinedData=this._combined[i]),268435456&o.bg&&(o.extended=this._extendedAttrs[i]),o}setCell(i,o){2097152&o.content&&(this._combined[i]=o.combinedData),268435456&o.bg&&(this._extendedAttrs[i]=o.extended),this._data[3*i+0]=o.content,this._data[3*i+1]=o.fg,this._data[3*i+2]=o.bg}setCellFromCodePoint(i,o,c,h,f,b){268435456&f&&(this._extendedAttrs[i]=b),this._data[3*i+0]=o|c<<22,this._data[3*i+1]=h,this._data[3*i+2]=f}addCodepointToCell(i,o){let c=this._data[3*i+0];2097152&c?this._combined[i]+=(0,p.stringFromCodePoint)(o):(2097151&c?(this._combined[i]=(0,p.stringFromCodePoint)(2097151&c)+(0,p.stringFromCodePoint)(o),c&=-2097152,c|=2097152):c=o|4194304,this._data[3*i+0]=c)}insertCells(i,o,c,h){if((i%=this.length)&&this.getWidth(i-1)===2&&this.setCellFromCodePoint(i-1,0,1,(h==null?void 0:h.fg)||0,(h==null?void 0:h.bg)||0,(h==null?void 0:h.extended)||new u.ExtendedAttrs),o<this.length-i){const f=new m.CellData;for(let b=this.length-i-o-1;b>=0;--b)this.setCell(i+o+b,this.loadCell(i+b,f));for(let b=0;b<o;++b)this.setCell(i+b,c)}else for(let f=i;f<this.length;++f)this.setCell(f,c);this.getWidth(this.length-1)===2&&this.setCellFromCodePoint(this.length-1,0,1,(h==null?void 0:h.fg)||0,(h==null?void 0:h.bg)||0,(h==null?void 0:h.extended)||new u.ExtendedAttrs)}deleteCells(i,o,c,h){if(i%=this.length,o<this.length-i){const f=new m.CellData;for(let b=0;b<this.length-i-o;++b)this.setCell(i+b,this.loadCell(i+o+b,f));for(let b=this.length-o;b<this.length;++b)this.setCell(b,c)}else for(let f=i;f<this.length;++f)this.setCell(f,c);i&&this.getWidth(i-1)===2&&this.setCellFromCodePoint(i-1,0,1,(h==null?void 0:h.fg)||0,(h==null?void 0:h.bg)||0,(h==null?void 0:h.extended)||new u.ExtendedAttrs),this.getWidth(i)!==0||this.hasContent(i)||this.setCellFromCodePoint(i,0,1,(h==null?void 0:h.fg)||0,(h==null?void 0:h.bg)||0,(h==null?void 0:h.extended)||new u.ExtendedAttrs)}replaceCells(i,o,c,h,f=!1){if(f)for(i&&this.getWidth(i-1)===2&&!this.isProtected(i-1)&&this.setCellFromCodePoint(i-1,0,1,(h==null?void 0:h.fg)||0,(h==null?void 0:h.bg)||0,(h==null?void 0:h.extended)||new u.ExtendedAttrs),o<this.length&&this.getWidth(o-1)===2&&!this.isProtected(o)&&this.setCellFromCodePoint(o,0,1,(h==null?void 0:h.fg)||0,(h==null?void 0:h.bg)||0,(h==null?void 0:h.extended)||new u.ExtendedAttrs);i<o&&i<this.length;)this.isProtected(i)||this.setCell(i,c),i++;else for(i&&this.getWidth(i-1)===2&&this.setCellFromCodePoint(i-1,0,1,(h==null?void 0:h.fg)||0,(h==null?void 0:h.bg)||0,(h==null?void 0:h.extended)||new u.ExtendedAttrs),o<this.length&&this.getWidth(o-1)===2&&this.setCellFromCodePoint(o,0,1,(h==null?void 0:h.fg)||0,(h==null?void 0:h.bg)||0,(h==null?void 0:h.extended)||new u.ExtendedAttrs);i<o&&i<this.length;)this.setCell(i++,c)}resize(i,o){if(i===this.length)return 4*this._data.length*2<this._data.buffer.byteLength;const c=3*i;if(i>this.length){if(this._data.buffer.byteLength>=4*c)this._data=new Uint32Array(this._data.buffer,0,c);else{const h=new Uint32Array(c);h.set(this._data),this._data=h}for(let h=this.length;h<i;++h)this.setCell(h,o)}else{this._data=this._data.subarray(0,c);const h=Object.keys(this._combined);for(let b=0;b<h.length;b++){const E=parseInt(h[b],10);E>=i&&delete this._combined[E]}const f=Object.keys(this._extendedAttrs);for(let b=0;b<f.length;b++){const E=parseInt(f[b],10);E>=i&&delete this._extendedAttrs[E]}}return this.length=i,4*c*2<this._data.buffer.byteLength}cleanupMemory(){if(4*this._data.length*2<this._data.buffer.byteLength){const i=new Uint32Array(this._data.length);return i.set(this._data),this._data=i,1}return 0}fill(i,o=!1){if(o)for(let c=0;c<this.length;++c)this.isProtected(c)||this.setCell(c,i);else{this._combined={},this._extendedAttrs={};for(let c=0;c<this.length;++c)this.setCell(c,i)}}copyFrom(i){this.length!==i.length?this._data=new Uint32Array(i._data):this._data.set(i._data),this.length=i.length,this._combined={};for(const o in i._combined)this._combined[o]=i._combined[o];this._extendedAttrs={};for(const o in i._extendedAttrs)this._extendedAttrs[o]=i._extendedAttrs[o];this.isWrapped=i.isWrapped}clone(){const i=new S(0);i._data=new Uint32Array(this._data),i.length=this.length;for(const o in this._combined)i._combined[o]=this._combined[o];for(const o in this._extendedAttrs)i._extendedAttrs[o]=this._extendedAttrs[o];return i.isWrapped=this.isWrapped,i}getTrimmedLength(){for(let i=this.length-1;i>=0;--i)if(4194303&this._data[3*i+0])return i+(this._data[3*i+0]>>22);return 0}getNoBgTrimmedLength(){for(let i=this.length-1;i>=0;--i)if(4194303&this._data[3*i+0]||50331648&this._data[3*i+2])return i+(this._data[3*i+0]>>22);return 0}copyCellsFrom(i,o,c,h,f){const b=i._data;if(f)for(let I=h-1;I>=0;I--){for(let v=0;v<3;v++)this._data[3*(c+I)+v]=b[3*(o+I)+v];268435456&b[3*(o+I)+2]&&(this._extendedAttrs[c+I]=i._extendedAttrs[o+I])}else for(let I=0;I<h;I++){for(let v=0;v<3;v++)this._data[3*(c+I)+v]=b[3*(o+I)+v];268435456&b[3*(o+I)+2]&&(this._extendedAttrs[c+I]=i._extendedAttrs[o+I])}const E=Object.keys(i._combined);for(let I=0;I<E.length;I++){const v=parseInt(E[I],10);v>=o&&(this._combined[v-o+c]=i._combined[v])}}translateToString(i=!1,o=0,c=this.length){i&&(c=Math.min(c,this.getTrimmedLength()));let h="";for(;o<c;){const f=this._data[3*o+0],b=2097151&f;h+=2097152&f?this._combined[o]:b?(0,p.stringFromCodePoint)(b):l.WHITESPACE_CELL_CHAR,o+=f>>22||1}return h}}r.BufferLine=S},4841:(y,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.getRangeLength=void 0,r.getRangeLength=function(n,u){if(n.start.y>n.end.y)throw new Error(`Buffer range end (${n.end.x}, ${n.end.y}) cannot be before start (${n.start.x}, ${n.start.y})`);return u*(n.end.y-n.start.y)+(n.end.x-n.start.x+1)}},4634:(y,r)=>{function n(u,m,l){if(m===u.length-1)return u[m].getTrimmedLength();const p=!u[m].hasContent(l-1)&&u[m].getWidth(l-1)===1,C=u[m+1].getWidth(0)===2;return p&&C?l-1:l}Object.defineProperty(r,"__esModule",{value:!0}),r.getWrappedLineTrimmedLength=r.reflowSmallerGetNewLineLengths=r.reflowLargerApplyNewLayout=r.reflowLargerCreateNewLayout=r.reflowLargerGetLinesToRemove=void 0,r.reflowLargerGetLinesToRemove=function(u,m,l,p,C){const S=[];for(let _=0;_<u.length-1;_++){let i=_,o=u.get(++i);if(!o.isWrapped)continue;const c=[u.get(_)];for(;i<u.length&&o.isWrapped;)c.push(o),o=u.get(++i);if(p>=_&&p<i){_+=c.length-1;continue}let h=0,f=n(c,h,m),b=1,E=0;for(;b<c.length;){const v=n(c,b,m),x=v-E,L=l-f,k=Math.min(x,L);c[h].copyCellsFrom(c[b],E,f,k,!1),f+=k,f===l&&(h++,f=0),E+=k,E===v&&(b++,E=0),f===0&&h!==0&&c[h-1].getWidth(l-1)===2&&(c[h].copyCellsFrom(c[h-1],l-1,f++,1,!1),c[h-1].setCell(l-1,C))}c[h].replaceCells(f,l,C);let I=0;for(let v=c.length-1;v>0&&(v>h||c[v].getTrimmedLength()===0);v--)I++;I>0&&(S.push(_+c.length-I),S.push(I)),_+=c.length-1}return S},r.reflowLargerCreateNewLayout=function(u,m){const l=[];let p=0,C=m[p],S=0;for(let _=0;_<u.length;_++)if(C===_){const i=m[++p];u.onDeleteEmitter.fire({index:_-S,amount:i}),_+=i-1,S+=i,C=m[++p]}else l.push(_);return{layout:l,countRemoved:S}},r.reflowLargerApplyNewLayout=function(u,m){const l=[];for(let p=0;p<m.length;p++)l.push(u.get(m[p]));for(let p=0;p<l.length;p++)u.set(p,l[p]);u.length=m.length},r.reflowSmallerGetNewLineLengths=function(u,m,l){const p=[],C=u.map((o,c)=>n(u,c,m)).reduce((o,c)=>o+c);let S=0,_=0,i=0;for(;i<C;){if(C-i<l){p.push(C-i);break}S+=l;const o=n(u,_,m);S>o&&(S-=o,_++);const c=u[_].getWidth(S-1)===2;c&&S--;const h=c?l-1:l;p.push(h),i+=h}return p},r.getWrappedLineTrimmedLength=n},5295:(y,r,n)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.BufferSet=void 0;const u=n(8460),m=n(844),l=n(9092);class p extends m.Disposable{constructor(S,_){super(),this._optionsService=S,this._bufferService=_,this._onBufferActivate=this.register(new u.EventEmitter),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 l.Buffer(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new l.Buffer(!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(S){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(S),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(S,_){this._normal.resize(S,_),this._alt.resize(S,_),this.setupTabStops(S)}setupTabStops(S){this._normal.setupTabStops(S),this._alt.setupTabStops(S)}}r.BufferSet=p},511:(y,r,n)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.CellData=void 0;const u=n(482),m=n(643),l=n(3734);class p extends l.AttributeData{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new l.ExtendedAttrs,this.combinedData=""}static fromCharData(S){const _=new p;return _.setFromCharData(S),_}isCombined(){return 2097152&this.content}getWidth(){return this.content>>22}getChars(){return 2097152&this.content?this.combinedData:2097151&this.content?(0,u.stringFromCodePoint)(2097151&this.content):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):2097151&this.content}setFromCharData(S){this.fg=S[m.CHAR_DATA_ATTR_INDEX],this.bg=0;let _=!1;if(S[m.CHAR_DATA_CHAR_INDEX].length>2)_=!0;else if(S[m.CHAR_DATA_CHAR_INDEX].length===2){const i=S[m.CHAR_DATA_CHAR_INDEX].charCodeAt(0);if(55296<=i&&i<=56319){const o=S[m.CHAR_DATA_CHAR_INDEX].charCodeAt(1);56320<=o&&o<=57343?this.content=1024*(i-55296)+o-56320+65536|S[m.CHAR_DATA_WIDTH_INDEX]<<22:_=!0}else _=!0}else this.content=S[m.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|S[m.CHAR_DATA_WIDTH_INDEX]<<22;_&&(this.combinedData=S[m.CHAR_DATA_CHAR_INDEX],this.content=2097152|S[m.CHAR_DATA_WIDTH_INDEX]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}r.CellData=p},643:(y,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.WHITESPACE_CELL_CODE=r.WHITESPACE_CELL_WIDTH=r.WHITESPACE_CELL_CHAR=r.NULL_CELL_CODE=r.NULL_CELL_WIDTH=r.NULL_CELL_CHAR=r.CHAR_DATA_CODE_INDEX=r.CHAR_DATA_WIDTH_INDEX=r.CHAR_DATA_CHAR_INDEX=r.CHAR_DATA_ATTR_INDEX=r.DEFAULT_EXT=r.DEFAULT_ATTR=r.DEFAULT_COLOR=void 0,r.DEFAULT_COLOR=0,r.DEFAULT_ATTR=256|r.DEFAULT_COLOR<<9,r.DEFAULT_EXT=0,r.CHAR_DATA_ATTR_INDEX=0,r.CHAR_DATA_CHAR_INDEX=1,r.CHAR_DATA_WIDTH_INDEX=2,r.CHAR_DATA_CODE_INDEX=3,r.NULL_CELL_CHAR="",r.NULL_CELL_WIDTH=1,r.NULL_CELL_CODE=0,r.WHITESPACE_CELL_CHAR=" ",r.WHITESPACE_CELL_WIDTH=1,r.WHITESPACE_CELL_CODE=32},4863:(y,r,n)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.Marker=void 0;const u=n(8460),m=n(844);class l{get id(){return this._id}constructor(C){this.line=C,this.isDisposed=!1,this._disposables=[],this._id=l._nextId++,this._onDispose=this.register(new u.EventEmitter),this.onDispose=this._onDispose.event}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),(0,m.disposeArray)(this._disposables),this._disposables.length=0)}register(C){return this._disposables.push(C),C}}r.Marker=l,l._nextId=1},7116:(y,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.DEFAULT_CHARSET=r.CHARSETS=void 0,r.CHARSETS={},r.DEFAULT_CHARSET=r.CHARSETS.B,r.CHARSETS[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:"≥","{":"π","|":"≠","}":"£","~":"·"},r.CHARSETS.A={"#":"£"},r.CHARSETS.B=void 0,r.CHARSETS[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"},r.CHARSETS.C=r.CHARSETS[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},r.CHARSETS.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"},r.CHARSETS.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"},r.CHARSETS.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"},r.CHARSETS.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"},r.CHARSETS.E=r.CHARSETS[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"},r.CHARSETS.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"},r.CHARSETS.H=r.CHARSETS[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},r.CHARSETS["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"}},2584:(y,r)=>{var n,u,m;Object.defineProperty(r,"__esModule",{value:!0}),r.C1_ESCAPED=r.C1=r.C0=void 0,function(l){l.NUL="\0",l.SOH="",l.STX="",l.ETX="",l.EOT="",l.ENQ="",l.ACK="",l.BEL="\x07",l.BS="\b",l.HT=" ",l.LF=` `,l.VT="\v",l.FF="\f",l.CR="\r",l.SO="",l.SI="",l.DLE="",l.DC1="",l.DC2="",l.DC3="",l.DC4="",l.NAK="",l.SYN="",l.ETB="",l.CAN="",l.EM="",l.SUB="",l.ESC="\x1B",l.FS="",l.GS="",l.RS="",l.US="",l.SP=" ",l.DEL=""}(n||(r.C0=n={})),function(l){l.PAD="",l.HOP="",l.BPH="",l.NBH="",l.IND="",l.NEL=" ",l.SSA="",l.ESA="",l.HTS="",l.HTJ="",l.VTS="",l.PLD="",l.PLU="",l.RI="",l.SS2="",l.SS3="",l.DCS="",l.PU1="",l.PU2="",l.STS="",l.CCH="",l.MW="",l.SPA="",l.EPA="",l.SOS="",l.SGCI="",l.SCI="",l.CSI="",l.ST="",l.OSC="",l.PM="",l.APC=""}(u||(r.C1=u={})),function(l){l.ST=`${n.ESC}\\`}(m||(r.C1_ESCAPED=m={}))},7399:(y,r,n)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.evaluateKeyboardEvent=void 0;const u=n(2584),m={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:["'",'"']};r.evaluateKeyboardEvent=function(l,p,C,S){const _={type:0,cancel:!1,key:void 0},i=(l.shiftKey?1:0)|(l.altKey?2:0)|(l.ctrlKey?4:0)|(l.metaKey?8:0);switch(l.keyCode){case 0:l.key==="UIKeyInputUpArrow"?_.key=p?u.C0.ESC+"OA":u.C0.ESC+"[A":l.key==="UIKeyInputLeftArrow"?_.key=p?u.C0.ESC+"OD":u.C0.ESC+"[D":l.key==="UIKeyInputRightArrow"?_.key=p?u.C0.ESC+"OC":u.C0.ESC+"[C":l.key==="UIKeyInputDownArrow"&&(_.key=p?u.C0.ESC+"OB":u.C0.ESC+"[B");break;case 8:if(l.altKey){_.key=u.C0.ESC+u.C0.DEL;break}_.key=u.C0.DEL;break;case 9:if(l.shiftKey){_.key=u.C0.ESC+"[Z";break}_.key=u.C0.HT,_.cancel=!0;break;case 13:_.key=l.altKey?u.C0.ESC+u.C0.CR:u.C0.CR,_.cancel=!0;break;case 27:_.key=u.C0.ESC,l.altKey&&(_.key=u.C0.ESC+u.C0.ESC),_.cancel=!0;break;case 37:if(l.metaKey)break;i?(_.key=u.C0.ESC+"[1;"+(i+1)+"D",_.key===u.C0.ESC+"[1;3D"&&(_.key=u.C0.ESC+(C?"b":"[1;5D"))):_.key=p?u.C0.ESC+"OD":u.C0.ESC+"[D";break;case 39:if(l.metaKey)break;i?(_.key=u.C0.ESC+"[1;"+(i+1)+"C",_.key===u.C0.ESC+"[1;3C"&&(_.key=u.C0.ESC+(C?"f":"[1;5C"))):_.key=p?u.C0.ESC+"OC":u.C0.ESC+"[C";break;case 38:if(l.metaKey)break;i?(_.key=u.C0.ESC+"[1;"+(i+1)+"A",C||_.key!==u.C0.ESC+"[1;3A"||(_.key=u.C0.ESC+"[1;5A")):_.key=p?u.C0.ESC+"OA":u.C0.ESC+"[A";break;case 40:if(l.metaKey)break;i?(_.key=u.C0.ESC+"[1;"+(i+1)+"B",C||_.key!==u.C0.ESC+"[1;3B"||(_.key=u.C0.ESC+"[1;5B")):_.key=p?u.C0.ESC+"OB":u.C0.ESC+"[B";break;case 45:l.shiftKey||l.ctrlKey||(_.key=u.C0.ESC+"[2~");break;case 46:_.key=i?u.C0.ESC+"[3;"+(i+1)+"~":u.C0.ESC+"[3~";break;case 36:_.key=i?u.C0.ESC+"[1;"+(i+1)+"H":p?u.C0.ESC+"OH":u.C0.ESC+"[H";break;case 35:_.key=i?u.C0.ESC+"[1;"+(i+1)+"F":p?u.C0.ESC+"OF":u.C0.ESC+"[F";break;case 33:l.shiftKey?_.type=2:l.ctrlKey?_.key=u.C0.ESC+"[5;"+(i+1)+"~":_.key=u.C0.ESC+"[5~";break;case 34:l.shiftKey?_.type=3:l.ctrlKey?_.key=u.C0.ESC+"[6;"+(i+1)+"~":_.key=u.C0.ESC+"[6~";break;case 112:_.key=i?u.C0.ESC+"[1;"+(i+1)+"P":u.C0.ESC+"OP";break;case 113:_.key=i?u.C0.ESC+"[1;"+(i+1)+"Q":u.C0.ESC+"OQ";break;case 114:_.key=i?u.C0.ESC+"[1;"+(i+1)+"R":u.C0.ESC+"OR";break;case 115:_.key=i?u.C0.ESC+"[1;"+(i+1)+"S":u.C0.ESC+"OS";break;case 116:_.key=i?u.C0.ESC+"[15;"+(i+1)+"~":u.C0.ESC+"[15~";break;case 117:_.key=i?u.C0.ESC+"[17;"+(i+1)+"~":u.C0.ESC+"[17~";break;case 118:_.key=i?u.C0.ESC+"[18;"+(i+1)+"~":u.C0.ESC+"[18~";break;case 119:_.key=i?u.C0.ESC+"[19;"+(i+1)+"~":u.C0.ESC+"[19~";break;case 120:_.key=i?u.C0.ESC+"[20;"+(i+1)+"~":u.C0.ESC+"[20~";break;case 121:_.key=i?u.C0.ESC+"[21;"+(i+1)+"~":u.C0.ESC+"[21~";break;case 122:_.key=i?u.C0.ESC+"[23;"+(i+1)+"~":u.C0.ESC+"[23~";break;case 123:_.key=i?u.C0.ESC+"[24;"+(i+1)+"~":u.C0.ESC+"[24~";break;default:if(!l.ctrlKey||l.shiftKey||l.altKey||l.metaKey)if(C&&!S||!l.altKey||l.metaKey)!C||l.altKey||l.ctrlKey||l.shiftKey||!l.metaKey?l.key&&!l.ctrlKey&&!l.altKey&&!l.metaKey&&l.keyCode>=48&&l.key.length===1?_.key=l.key:l.key&&l.ctrlKey&&(l.key==="_"&&(_.key=u.C0.US),l.key==="@"&&(_.key=u.C0.NUL)):l.keyCode===65&&(_.type=1);else{const o=m[l.keyCode],c=o==null?void 0:o[l.shiftKey?1:0];if(c)_.key=u.C0.ESC+c;else if(l.keyCode>=65&&l.keyCode<=90){const h=l.ctrlKey?l.keyCode-64:l.keyCode+32;let f=String.fromCharCode(h);l.shiftKey&&(f=f.toUpperCase()),_.key=u.C0.ESC+f}else if(l.keyCode===32)_.key=u.C0.ESC+(l.ctrlKey?u.C0.NUL:" ");else if(l.key==="Dead"&&l.code.startsWith("Key")){let h=l.code.slice(3,4);l.shiftKey||(h=h.toLowerCase()),_.key=u.C0.ESC+h,_.cancel=!0}}else l.keyCode>=65&&l.keyCode<=90?_.key=String.fromCharCode(l.keyCode-64):l.keyCode===32?_.key=u.C0.NUL:l.keyCode>=51&&l.keyCode<=55?_.key=String.fromCharCode(l.keyCode-51+27):l.keyCode===56?_.key=u.C0.DEL:l.keyCode===219?_.key=u.C0.ESC:l.keyCode===220?_.key=u.C0.FS:l.keyCode===221&&(_.key=u.C0.GS)}return _}},482:(y,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.Utf8ToUtf32=r.StringToUtf32=r.utf32ToString=r.stringFromCodePoint=void 0,r.stringFromCodePoint=function(n){return n>65535?(n-=65536,String.fromCharCode(55296+(n>>10))+String.fromCharCode(n%1024+56320)):String.fromCharCode(n)},r.utf32ToString=function(n,u=0,m=n.length){let l="";for(let p=u;p<m;++p){let C=n[p];C>65535?(C-=65536,l+=String.fromCharCode(55296+(C>>10))+String.fromCharCode(C%1024+56320)):l+=String.fromCharCode(C)}return l},r.StringToUtf32=class{constructor(){this._interim=0}clear(){this._interim=0}decode(n,u){const m=n.length;if(!m)return 0;let l=0,p=0;if(this._interim){const C=n.charCodeAt(p++);56320<=C&&C<=57343?u[l++]=1024*(this._interim-55296)+C-56320+65536:(u[l++]=this._interim,u[l++]=C),this._interim=0}for(let C=p;C<m;++C){const S=n.charCodeAt(C);if(55296<=S&&S<=56319){if(++C>=m)return this._interim=S,l;const _=n.charCodeAt(C);56320<=_&&_<=57343?u[l++]=1024*(S-55296)+_-56320+65536:(u[l++]=S,u[l++]=_)}else S!==65279&&(u[l++]=S)}return l}},r.Utf8ToUtf32=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(n,u){const m=n.length;if(!m)return 0;let l,p,C,S,_=0,i=0,o=0;if(this.interim[0]){let f=!1,b=this.interim[0];b&=(224&b)==192?31:(240&b)==224?15:7;let E,I=0;for(;(E=63&this.interim[++I])&&I<4;)b<<=6,b|=E;const v=(224&this.interim[0])==192?2:(240&this.interim[0])==224?3:4,x=v-I;for(;o<x;){if(o>=m)return 0;if(E=n[o++],(192&E)!=128){o--,f=!0;break}this.interim[I++]=E,b<<=6,b|=63&E}f||(v===2?b<128?o--:u[_++]=b:v===3?b<2048||b>=55296&&b<=57343||b===65279||(u[_++]=b):b<65536||b>1114111||(u[_++]=b)),this.interim.fill(0)}const c=m-4;let h=o;for(;h<m;){for(;!(!(h<c)||128&(l=n[h])||128&(p=n[h+1])||128&(C=n[h+2])||128&(S=n[h+3]));)u[_++]=l,u[_++]=p,u[_++]=C,u[_++]=S,h+=4;if(l=n[h++],l<128)u[_++]=l;else if((224&l)==192){if(h>=m)return this.interim[0]=l,_;if(p=n[h++],(192&p)!=128){h--;continue}if(i=(31&l)<<6|63&p,i<128){h--;continue}u[_++]=i}else if((240&l)==224){if(h>=m)return this.interim[0]=l,_;if(p=n[h++],(192&p)!=128){h--;continue}if(h>=m)return this.interim[0]=l,this.interim[1]=p,_;if(C=n[h++],(192&C)!=128){h--;continue}if(i=(15&l)<<12|(63&p)<<6|63&C,i<2048||i>=55296&&i<=57343||i===65279)continue;u[_++]=i}else if((248&l)==240){if(h>=m)return this.interim[0]=l,_;if(p=n[h++],(192&p)!=128){h--;continue}if(h>=m)return this.interim[0]=l,this.interim[1]=p,_;if(C=n[h++],(192&C)!=128){h--;continue}if(h>=m)return this.interim[0]=l,this.interim[1]=p,this.interim[2]=C,_;if(S=n[h++],(192&S)!=128){h--;continue}if(i=(7&l)<<18|(63&p)<<12|(63&C)<<6|63&S,i<65536||i>1114111)continue;u[_++]=i}}return _}}},225:(y,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.UnicodeV6=void 0;const n=[[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]],u=[[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]];let m;r.UnicodeV6=class{constructor(){if(this.version="6",!m){m=new Uint8Array(65536),m.fill(1),m[0]=0,m.fill(0,1,32),m.fill(0,127,160),m.fill(2,4352,4448),m[9001]=2,m[9002]=2,m.fill(2,11904,42192),m[12351]=1,m.fill(2,44032,55204),m.fill(2,63744,64256),m.fill(2,65040,65050),m.fill(2,65072,65136),m.fill(2,65280,65377),m.fill(2,65504,65511);for(let l=0;l<n.length;++l)m.fill(0,n[l][0],n[l][1]+1)}}wcwidth(l){return l<32?0:l<127?1:l<65536?m[l]:function(p,C){let S,_=0,i=C.length-1;if(p<C[0][0]||p>C[i][1])return!1;for(;i>=_;)if(S=_+i>>1,p>C[S][1])_=S+1;else{if(!(p<C[S][0]))return!0;i=S-1}return!1}(l,u)?0:l>=131072&&l<=196605||l>=196608&&l<=262141?2:1}}},5981:(y,r,n)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.WriteBuffer=void 0;const u=n(8460),m=n(844);class l extends m.Disposable{constructor(C){super(),this._action=C,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this.register(new u.EventEmitter),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(C,S){if(S!==void 0&&this._syncCalls>S)return void(this._syncCalls=0);if(this._pendingData+=C.length,this._writeBuffer.push(C),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;let _;for(this._isSyncWriting=!0;_=this._writeBuffer.shift();){this._action(_);const i=this._callbacks.shift();i&&i()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(C,S){if(this._pendingData>5e7)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput)return this._didUserInput=!1,this._pendingData+=C.length,this._writeBuffer.push(C),this._callbacks.push(S),void this._innerWrite();setTimeout(()=>this._innerWrite())}this._pendingData+=C.length,this._writeBuffer.push(C),this._callbacks.push(S)}_innerWrite(C=0,S=!0){const _=C||Date.now();for(;this._writeBuffer.length>this._bufferOffset;){const i=this._writeBuffer[this._bufferOffset],o=this._action(i,S);if(o){const h=f=>Date.now()-_>=12?setTimeout(()=>this._innerWrite(0,f)):this._innerWrite(_,f);return void o.catch(f=>(queueMicrotask(()=>{throw f}),Promise.resolve(!1))).then(h)}const c=this._callbacks[this._bufferOffset];if(c&&c(),this._bufferOffset++,this._pendingData-=i.length,Date.now()-_>=12)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>50&&(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()}}r.WriteBuffer=l},5941:(y,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.toRgbString=r.parseColor=void 0;const n=/^([\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})$/,u=/^[\da-f]+$/;function m(l,p){const C=l.toString(16),S=C.length<2?"0"+C:C;switch(p){case 4:return C[0];case 8:return S;case 12:return(S+S).slice(0,3);default:return S+S}}r.parseColor=function(l){if(!l)return;let p=l.toLowerCase();if(p.indexOf("rgb:")===0){p=p.slice(4);const C=n.exec(p);if(C){const S=C[1]?15:C[4]?255:C[7]?4095:65535;return[Math.round(parseInt(C[1]||C[4]||C[7]||C[10],16)/S*255),Math.round(parseInt(C[2]||C[5]||C[8]||C[11],16)/S*255),Math.round(parseInt(C[3]||C[6]||C[9]||C[12],16)/S*255)]}}else if(p.indexOf("#")===0&&(p=p.slice(1),u.exec(p)&&[3,6,9,12].includes(p.length))){const C=p.length/3,S=[0,0,0];for(let _=0;_<3;++_){const i=parseInt(p.slice(C*_,C*_+C),16);S[_]=C===1?i<<4:C===2?i:C===3?i>>4:i>>8}return S}},r.toRgbString=function(l,p=16){const[C,S,_]=l;return`rgb:${m(C,p)}/${m(S,p)}/${m(_,p)}`}},5770:(y,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.PAYLOAD_LIMIT=void 0,r.PAYLOAD_LIMIT=1e7},6351:(y,r,n)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.DcsHandler=r.DcsParser=void 0;const u=n(482),m=n(8742),l=n(5770),p=[];r.DcsParser=class{constructor(){this._handlers=Object.create(null),this._active=p,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=p}registerHandler(S,_){this._handlers[S]===void 0&&(this._handlers[S]=[]);const i=this._handlers[S];return i.push(_),{dispose:()=>{const o=i.indexOf(_);o!==-1&&i.splice(o,1)}}}clearHandler(S){this._handlers[S]&&delete this._handlers[S]}setHandlerFallback(S){this._handlerFb=S}reset(){if(this._active.length)for(let S=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;S>=0;--S)this._active[S].unhook(!1);this._stack.paused=!1,this._active=p,this._ident=0}hook(S,_){if(this.reset(),this._ident=S,this._active=this._handlers[S]||p,this._active.length)for(let i=this._active.length-1;i>=0;i--)this._active[i].hook(_);else this._handlerFb(this._ident,"HOOK",_)}put(S,_,i){if(this._active.length)for(let o=this._active.length-1;o>=0;o--)this._active[o].put(S,_,i);else this._handlerFb(this._ident,"PUT",(0,u.utf32ToString)(S,_,i))}unhook(S,_=!0){if(this._active.length){let i=!1,o=this._active.length-1,c=!1;if(this._stack.paused&&(o=this._stack.loopPosition-1,i=_,c=this._stack.fallThrough,this._stack.paused=!1),!c&&i===!1){for(;o>=0&&(i=this._active[o].unhook(S),i!==!0);o--)if(i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=o,this._stack.fallThrough=!1,i;o--}for(;o>=0;o--)if(i=this._active[o].unhook(!1),i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=o,this._stack.fallThrough=!0,i}else this._handlerFb(this._ident,"UNHOOK",S);this._active=p,this._ident=0}};const C=new m.Params;C.addParam(0),r.DcsHandler=class{constructor(S){this._handler=S,this._data="",this._params=C,this._hitLimit=!1}hook(S){this._params=S.length>1||S.params[0]?S.clone():C,this._data="",this._hitLimit=!1}put(S,_,i){this._hitLimit||(this._data+=(0,u.utf32ToString)(S,_,i),this._data.length>l.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}unhook(S){let _=!1;if(this._hitLimit)_=!1;else if(S&&(_=this._handler(this._data,this._params),_ instanceof Promise))return _.then(i=>(this._params=C,this._data="",this._hitLimit=!1,i));return this._params=C,this._data="",this._hitLimit=!1,_}}},2015:(y,r,n)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.EscapeSequenceParser=r.VT500_TRANSITION_TABLE=r.TransitionTable=void 0;const u=n(844),m=n(8742),l=n(6242),p=n(6351);class C{constructor(o){this.table=new Uint8Array(o)}setDefault(o,c){this.table.fill(o<<4|c)}add(o,c,h,f){this.table[c<<8|o]=h<<4|f}addMany(o,c,h,f){for(let b=0;b<o.length;b++)this.table[c<<8|o[b]]=h<<4|f}}r.TransitionTable=C;const S=160;r.VT500_TRANSITION_TABLE=function(){const i=new C(4095),o=Array.apply(null,Array(256)).map((I,v)=>v),c=(I,v)=>o.slice(I,v),h=c(32,127),f=c(0,24);f.push(25),f.push.apply(f,c(28,32));const b=c(0,14);let E;for(E in i.setDefault(1,0),i.addMany(h,0,2,0),b)i.addMany([24,26,153,154],E,3,0),i.addMany(c(128,144),E,3,0),i.addMany(c(144,152),E,3,0),i.add(156,E,0,0),i.add(27,E,11,1),i.add(157,E,4,8),i.addMany([152,158,159],E,0,7),i.add(155,E,11,3),i.add(144,E,11,9);return i.addMany(f,0,3,0),i.addMany(f,1,3,1),i.add(127,1,0,1),i.addMany(f,8,0,8),i.addMany(f,3,3,3),i.add(127,3,0,3),i.addMany(f,4,3,4),i.add(127,4,0,4),i.addMany(f,6,3,6),i.addMany(f,5,3,5),i.add(127,5,0,5),i.addMany(f,2,3,2),i.add(127,2,0,2),i.add(93,1,4,8),i.addMany(h,8,5,8),i.add(127,8,5,8),i.addMany([156,27,24,26,7],8,6,0),i.addMany(c(28,32),8,0,8),i.addMany([88,94,95],1,0,7),i.addMany(h,7,0,7),i.addMany(f,7,0,7),i.add(156,7,0,0),i.add(127,7,0,7),i.add(91,1,11,3),i.addMany(c(64,127),3,7,0),i.addMany(c(48,60),3,8,4),i.addMany([60,61,62,63],3,9,4),i.addMany(c(48,60),4,8,4),i.addMany(c(64,127),4,7,0),i.addMany([60,61,62,63],4,0,6),i.addMany(c(32,64),6,0,6),i.add(127,6,0,6),i.addMany(c(64,127),6,0,0),i.addMany(c(32,48),3,9,5),i.addMany(c(32,48),5,9,5),i.addMany(c(48,64),5,0,6),i.addMany(c(64,127),5,7,0),i.addMany(c(32,48),4,9,5),i.addMany(c(32,48),1,9,2),i.addMany(c(32,48),2,9,2),i.addMany(c(48,127),2,10,0),i.addMany(c(48,80),1,10,0),i.addMany(c(81,88),1,10,0),i.addMany([89,90,92],1,10,0),i.addMany(c(96,127),1,10,0),i.add(80,1,11,9),i.addMany(f,9,0,9),i.add(127,9,0,9),i.addMany(c(28,32),9,0,9),i.addMany(c(32,48),9,9,12),i.addMany(c(48,60),9,8,10),i.addMany([60,61,62,63],9,9,10),i.addMany(f,11,0,11),i.addMany(c(32,128),11,0,11),i.addMany(c(28,32),11,0,11),i.addMany(f,10,0,10),i.add(127,10,0,10),i.addMany(c(28,32),10,0,10),i.addMany(c(48,60),10,8,10),i.addMany([60,61,62,63],10,0,11),i.addMany(c(32,48),10,9,12),i.addMany(f,12,0,12),i.add(127,12,0,12),i.addMany(c(28,32),12,0,12),i.addMany(c(32,48),12,9,12),i.addMany(c(48,64),12,0,11),i.addMany(c(64,127),12,12,13),i.addMany(c(64,127),10,12,13),i.addMany(c(64,127),9,12,13),i.addMany(f,13,13,13),i.addMany(h,13,13,13),i.add(127,13,0,13),i.addMany([27,156,24,26],13,14,0),i.add(S,0,2,0),i.add(S,8,5,8),i.add(S,6,0,6),i.add(S,11,0,11),i.add(S,13,13,13),i}();class _ extends u.Disposable{constructor(o=r.VT500_TRANSITION_TABLE){super(),this._transitions=o,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new m.Params,this._params.addParam(0),this._collect=0,this.precedingCodepoint=0,this._printHandlerFb=(c,h,f)=>{},this._executeHandlerFb=c=>{},this._csiHandlerFb=(c,h)=>{},this._escHandlerFb=c=>{},this._errorHandlerFb=c=>c,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this.register((0,u.toDisposable)(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this.register(new l.OscParser),this._dcsParser=this.register(new p.DcsParser),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(o,c=[64,126]){let h=0;if(o.prefix){if(o.prefix.length>1)throw new Error("only one byte as prefix supported");if(h=o.prefix.charCodeAt(0),h&&60>h||h>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(o.intermediates){if(o.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let b=0;b<o.intermediates.length;++b){const E=o.intermediates.charCodeAt(b);if(32>E||E>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");h<<=8,h|=E}}if(o.final.length!==1)throw new Error("final must be a single byte");const f=o.final.charCodeAt(0);if(c[0]>f||f>c[1])throw new Error(`final must be in range ${c[0]} .. ${c[1]}`);return h<<=8,h|=f,h}identToString(o){const c=[];for(;o;)c.push(String.fromCharCode(255&o)),o>>=8;return c.reverse().join("")}setPrintHandler(o){this._printHandler=o}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(o,c){const h=this._identifier(o,[48,126]);this._escHandlers[h]===void 0&&(this._escHandlers[h]=[]);const f=this._escHandlers[h];return f.push(c),{dispose:()=>{const b=f.indexOf(c);b!==-1&&f.splice(b,1)}}}clearEscHandler(o){this._escHandlers[this._identifier(o,[48,126])]&&delete this._escHandlers[this._identifier(o,[48,126])]}setEscHandlerFallback(o){this._escHandlerFb=o}setExecuteHandler(o,c){this._executeHandlers[o.charCodeAt(0)]=c}clearExecuteHandler(o){this._executeHandlers[o.charCodeAt(0)]&&delete this._executeHandlers[o.charCodeAt(0)]}setExecuteHandlerFallback(o){this._executeHandlerFb=o}registerCsiHandler(o,c){const h=this._identifier(o);this._csiHandlers[h]===void 0&&(this._csiHandlers[h]=[]);const f=this._csiHandlers[h];return f.push(c),{dispose:()=>{const b=f.indexOf(c);b!==-1&&f.splice(b,1)}}}clearCsiHandler(o){this._csiHandlers[this._identifier(o)]&&delete this._csiHandlers[this._identifier(o)]}setCsiHandlerFallback(o){this._csiHandlerFb=o}registerDcsHandler(o,c){return this._dcsParser.registerHandler(this._identifier(o),c)}clearDcsHandler(o){this._dcsParser.clearHandler(this._identifier(o))}setDcsHandlerFallback(o){this._dcsParser.setHandlerFallback(o)}registerOscHandler(o,c){return this._oscParser.registerHandler(o,c)}clearOscHandler(o){this._oscParser.clearHandler(o)}setOscHandlerFallback(o){this._oscParser.setHandlerFallback(o)}setErrorHandler(o){this._errorHandler=o}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.precedingCodepoint=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(o,c,h,f,b){this._parseStack.state=o,this._parseStack.handlers=c,this._parseStack.handlerPos=h,this._parseStack.transition=f,this._parseStack.chunkPos=b}parse(o,c,h){let f,b=0,E=0,I=0;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,I=this._parseStack.chunkPos+1;else{if(h===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");const v=this._parseStack.handlers;let x=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(h===!1&&x>-1){for(;x>=0&&(f=v[x](this._params),f!==!0);x--)if(f instanceof Promise)return this._parseStack.handlerPos=x,f}this._parseStack.handlers=[];break;case 4:if(h===!1&&x>-1){for(;x>=0&&(f=v[x](),f!==!0);x--)if(f instanceof Promise)return this._parseStack.handlerPos=x,f}this._parseStack.handlers=[];break;case 6:if(b=o[this._parseStack.chunkPos],f=this._dcsParser.unhook(b!==24&&b!==26,h),f)return f;b===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(b=o[this._parseStack.chunkPos],f=this._oscParser.end(b!==24&&b!==26,h),f)return f;b===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0}this._parseStack.state=0,I=this._parseStack.chunkPos+1,this.precedingCodepoint=0,this.currentState=15&this._parseStack.transition}for(let v=I;v<c;++v){switch(b=o[v],E=this._transitions.table[this.currentState<<8|(b<160?b:S)],E>>4){case 2:for(let B=v+1;;++B){if(B>=c||(b=o[B])<32||b>126&&b<S){this._printHandler(o,v,B),v=B-1;break}if(++B>=c||(b=o[B])<32||b>126&&b<S){this._printHandler(o,v,B),v=B-1;break}if(++B>=c||(b=o[B])<32||b>126&&b<S){this._printHandler(o,v,B),v=B-1;break}if(++B>=c||(b=o[B])<32||b>126&&b<S){this._printHandler(o,v,B),v=B-1;break}}break;case 3:this._executeHandlers[b]?this._executeHandlers[b]():this._executeHandlerFb(b),this.precedingCodepoint=0;break;case 0:break;case 1:if(this._errorHandler({position:v,code:b,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:const x=this._csiHandlers[this._collect<<8|b];let L=x?x.length-1:-1;for(;L>=0&&(f=x[L](this._params),f!==!0);L--)if(f instanceof Promise)return this._preserveStack(3,x,L,E,v),f;L<0&&this._csiHandlerFb(this._collect<<8|b,this._params),this.precedingCodepoint=0;break;case 8:do switch(b){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(b-48)}while(++v<c&&(b=o[v])>47&&b<60);v--;break;case 9:this._collect<<=8,this._collect|=b;break;case 10:const k=this._escHandlers[this._collect<<8|b];let D=k?k.length-1:-1;for(;D>=0&&(f=k[D](),f!==!0);D--)if(f instanceof Promise)return this._preserveStack(4,k,D,E,v),f;D<0&&this._escHandlerFb(this._collect<<8|b),this.precedingCodepoint=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|b,this._params);break;case 13:for(let B=v+1;;++B)if(B>=c||(b=o[B])===24||b===26||b===27||b>127&&b<S){this._dcsParser.put(o,v,B),v=B-1;break}break;case 14:if(f=this._dcsParser.unhook(b!==24&&b!==26),f)return this._preserveStack(6,[],0,E,v),f;b===27&&(E|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingCodepoint=0;break;case 4:this._oscParser.start();break;case 5:for(let B=v+1;;B++)if(B>=c||(b=o[B])<32||b>127&&b<S){this._oscParser.put(o,v,B),v=B-1;break}break;case 6:if(f=this._oscParser.end(b!==24&&b!==26),f)return this._preserveStack(5,[],0,E,v),f;b===27&&(E|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingCodepoint=0}this.currentState=15&E}}}r.EscapeSequenceParser=_},6242:(y,r,n)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.OscHandler=r.OscParser=void 0;const u=n(5770),m=n(482),l=[];r.OscParser=class{constructor(){this._state=0,this._active=l,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(p,C){this._handlers[p]===void 0&&(this._handlers[p]=[]);const S=this._handlers[p];return S.push(C),{dispose:()=>{const _=S.indexOf(C);_!==-1&&S.splice(_,1)}}}clearHandler(p){this._handlers[p]&&delete this._handlers[p]}setHandlerFallback(p){this._handlerFb=p}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=l}reset(){if(this._state===2)for(let p=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;p>=0;--p)this._active[p].end(!1);this._stack.paused=!1,this._active=l,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||l,this._active.length)for(let p=this._active.length-1;p>=0;p--)this._active[p].start();else this._handlerFb(this._id,"START")}_put(p,C,S){if(this._active.length)for(let _=this._active.length-1;_>=0;_--)this._active[_].put(p,C,S);else this._handlerFb(this._id,"PUT",(0,m.utf32ToString)(p,C,S))}start(){this.reset(),this._state=1}put(p,C,S){if(this._state!==3){if(this._state===1)for(;C<S;){const _=p[C++];if(_===59){this._state=2,this._start();break}if(_<48||57<_)return void(this._state=3);this._id===-1&&(this._id=0),this._id=10*this._id+_-48}this._state===2&&S-C>0&&this._put(p,C,S)}}end(p,C=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),this._active.length){let S=!1,_=this._active.length-1,i=!1;if(this._stack.paused&&(_=this._stack.loopPosition-1,S=C,i=this._stack.fallThrough,this._stack.paused=!1),!i&&S===!1){for(;_>=0&&(S=this._active[_].end(p),S!==!0);_--)if(S instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=_,this._stack.fallThrough=!1,S;_--}for(;_>=0;_--)if(S=this._active[_].end(!1),S instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=_,this._stack.fallThrough=!0,S}else this._handlerFb(this._id,"END",p);this._active=l,this._id=-1,this._state=0}}},r.OscHandler=class{constructor(p){this._handler=p,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(p,C,S){this._hitLimit||(this._data+=(0,m.utf32ToString)(p,C,S),this._data.length>u.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}end(p){let C=!1;if(this._hitLimit)C=!1;else if(p&&(C=this._handler(this._data),C instanceof Promise))return C.then(S=>(this._data="",this._hitLimit=!1,S));return this._data="",this._hitLimit=!1,C}}},8742:(y,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.Params=void 0;const n=2147483647;class u{static fromArray(l){const p=new u;if(!l.length)return p;for(let C=Array.isArray(l[0])?1:0;C<l.length;++C){const S=l[C];if(Array.isArray(S))for(let _=0;_<S.length;++_)p.addSubParam(S[_]);else p.addParam(S)}return p}constructor(l=32,p=32){if(this.maxLength=l,this.maxSubParamsLength=p,p>256)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(l),this.length=0,this._subParams=new Int32Array(p),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(l),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}clone(){const l=new u(this.maxLength,this.maxSubParamsLength);return l.params.set(this.params),l.length=this.length,l._subParams.set(this._subParams),l._subParamsLength=this._subParamsLength,l._subParamsIdx.set(this._subParamsIdx),l._rejectDigits=this._rejectDigits,l._rejectSubDigits=this._rejectSubDigits,l._digitIsSub=this._digitIsSub,l}toArray(){const l=[];for(let p=0;p<this.length;++p){l.push(this.params[p]);const C=this._subParamsIdx[p]>>8,S=255&this._subParamsIdx[p];S-C>0&&l.push(Array.prototype.slice.call(this._subParams,C,S))}return l}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(l){if(this._digitIsSub=!1,this.length>=this.maxLength)this._rejectDigits=!0;else{if(l<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=l>n?n:l}}addSubParam(l){if(this._digitIsSub=!0,this.length)if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength)this._rejectSubDigits=!0;else{if(l<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=l>n?n:l,this._subParamsIdx[this.length-1]++}}hasSubParams(l){return(255&this._subParamsIdx[l])-(this._subParamsIdx[l]>>8)>0}getSubParams(l){const p=this._subParamsIdx[l]>>8,C=255&this._subParamsIdx[l];return C-p>0?this._subParams.subarray(p,C):null}getSubParamsAll(){const l={};for(let p=0;p<this.length;++p){const C=this._subParamsIdx[p]>>8,S=255&this._subParamsIdx[p];S-C>0&&(l[p]=this._subParams.slice(C,S))}return l}addDigit(l){let p;if(this._rejectDigits||!(p=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;const C=this._digitIsSub?this._subParams:this.params,S=C[p-1];C[p-1]=~S?Math.min(10*S+l,n):l}}r.Params=u},5741:(y,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.AddonManager=void 0,r.AddonManager=class{constructor(){this._addons=[]}dispose(){for(let n=this._addons.length-1;n>=0;n--)this._addons[n].instance.dispose()}loadAddon(n,u){const m={instance:u,dispose:u.dispose,isDisposed:!1};this._addons.push(m),u.dispose=()=>this._wrappedAddonDispose(m),u.activate(n)}_wrappedAddonDispose(n){if(n.isDisposed)return;let u=-1;for(let m=0;m<this._addons.length;m++)if(this._addons[m]===n){u=m;break}if(u===-1)throw new Error("Could not dispose an addon that has not been loaded");n.isDisposed=!0,n.dispose.apply(n.instance),this._addons.splice(u,1)}}},8771:(y,r,n)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.BufferApiView=void 0;const u=n(3785),m=n(511);r.BufferApiView=class{constructor(l,p){this._buffer=l,this.type=p}init(l){return this._buffer=l,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(l){const p=this._buffer.lines.get(l);if(p)return new u.BufferLineApiView(p)}getNullCell(){return new m.CellData}}},3785:(y,r,n)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.BufferLineApiView=void 0;const u=n(511);r.BufferLineApiView=class{constructor(m){this._line=m}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(m,l){if(!(m<0||m>=this._line.length))return l?(this._line.loadCell(m,l),l):this._line.loadCell(m,new u.CellData)}translateToString(m,l,p){return this._line.translateToString(m,l,p)}}},8285:(y,r,n)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.BufferNamespaceApi=void 0;const u=n(8771),m=n(8460),l=n(844);class p extends l.Disposable{constructor(S){super(),this._core=S,this._onBufferChange=this.register(new m.EventEmitter),this.onBufferChange=this._onBufferChange.event,this._normal=new u.BufferApiView(this._core.buffers.normal,"normal"),this._alternate=new u.BufferApiView(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)}}r.BufferNamespaceApi=p},7975:(y,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.ParserApi=void 0,r.ParserApi=class{constructor(n){this._core=n}registerCsiHandler(n,u){return this._core.registerCsiHandler(n,m=>u(m.toArray()))}addCsiHandler(n,u){return this.registerCsiHandler(n,u)}registerDcsHandler(n,u){return this._core.registerDcsHandler(n,(m,l)=>u(m,l.toArray()))}addDcsHandler(n,u){return this.registerDcsHandler(n,u)}registerEscHandler(n,u){return this._core.registerEscHandler(n,u)}addEscHandler(n,u){return this.registerEscHandler(n,u)}registerOscHandler(n,u){return this._core.registerOscHandler(n,u)}addOscHandler(n,u){return this.registerOscHandler(n,u)}}},7090:(y,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.UnicodeApi=void 0,r.UnicodeApi=class{constructor(n){this._core=n}register(n){this._core.unicodeService.register(n)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(n){this._core.unicodeService.activeVersion=n}}},744:function(y,r,n){var u=this&&this.__decorate||function(i,o,c,h){var f,b=arguments.length,E=b<3?o:h===null?h=Object.getOwnPropertyDescriptor(o,c):h;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(i,o,c,h);else for(var I=i.length-1;I>=0;I--)(f=i[I])&&(E=(b<3?f(E):b>3?f(o,c,E):f(o,c))||E);return b>3&&E&&Object.defineProperty(o,c,E),E},m=this&&this.__param||function(i,o){return function(c,h){o(c,h,i)}};Object.defineProperty(r,"__esModule",{value:!0}),r.BufferService=r.MINIMUM_ROWS=r.MINIMUM_COLS=void 0;const l=n(8460),p=n(844),C=n(5295),S=n(2585);r.MINIMUM_COLS=2,r.MINIMUM_ROWS=1;let _=r.BufferService=class extends p.Disposable{get buffer(){return this.buffers.active}constructor(i){super(),this.isUserScrolling=!1,this._onResize=this.register(new l.EventEmitter),this.onResize=this._onResize.event,this._onScroll=this.register(new l.EventEmitter),this.onScroll=this._onScroll.event,this.cols=Math.max(i.rawOptions.cols||0,r.MINIMUM_COLS),this.rows=Math.max(i.rawOptions.rows||0,r.MINIMUM_ROWS),this.buffers=this.register(new C.BufferSet(i,this))}resize(i,o){this.cols=i,this.rows=o,this.buffers.resize(i,o),this._onResize.fire({cols:i,rows:o})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(i,o=!1){const c=this.buffer;let h;h=this._cachedBlankLine,h&&h.length===this.cols&&h.getFg(0)===i.fg&&h.getBg(0)===i.bg||(h=c.getBlankLine(i,o),this._cachedBlankLine=h),h.isWrapped=o;const f=c.ybase+c.scrollTop,b=c.ybase+c.scrollBottom;if(c.scrollTop===0){const E=c.lines.isFull;b===c.lines.length-1?E?c.lines.recycle().copyFrom(h):c.lines.push(h.clone()):c.lines.splice(b+1,0,h.clone()),E?this.isUserScrolling&&(c.ydisp=Math.max(c.ydisp-1,0)):(c.ybase++,this.isUserScrolling||c.ydisp++)}else{const E=b-f+1;c.lines.shiftElements(f+1,E-1,-1),c.lines.set(b,h.clone())}this.isUserScrolling||(c.ydisp=c.ybase),this._onScroll.fire(c.ydisp)}scrollLines(i,o,c){const h=this.buffer;if(i<0){if(h.ydisp===0)return;this.isUserScrolling=!0}else i+h.ydisp>=h.ybase&&(this.isUserScrolling=!1);const f=h.ydisp;h.ydisp=Math.max(Math.min(h.ydisp+i,h.ybase),0),f!==h.ydisp&&(o||this._onScroll.fire(h.ydisp))}};r.BufferService=_=u([m(0,S.IOptionsService)],_)},7994:(y,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.CharsetService=void 0,r.CharsetService=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(n){this.glevel=n,this.charset=this._charsets[n]}setgCharset(n,u){this._charsets[n]=u,this.glevel===n&&(this.charset=u)}}},1753:function(y,r,n){var u=this&&this.__decorate||function(h,f,b,E){var I,v=arguments.length,x=v<3?f:E===null?E=Object.getOwnPropertyDescriptor(f,b):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")x=Reflect.decorate(h,f,b,E);else for(var L=h.length-1;L>=0;L--)(I=h[L])&&(x=(v<3?I(x):v>3?I(f,b,x):I(f,b))||x);return v>3&&x&&Object.defineProperty(f,b,x),x},m=this&&this.__param||function(h,f){return function(b,E){f(b,E,h)}};Object.defineProperty(r,"__esModule",{value:!0}),r.CoreMouseService=void 0;const l=n(2585),p=n(8460),C=n(844),S={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:h=>h.button!==4&&h.action===1&&(h.ctrl=!1,h.alt=!1,h.shift=!1,!0)},VT200:{events:19,restrict:h=>h.action!==32},DRAG:{events:23,restrict:h=>h.action!==32||h.button!==3},ANY:{events:31,restrict:h=>!0}};function _(h,f){let b=(h.ctrl?16:0)|(h.shift?4:0)|(h.alt?8:0);return h.button===4?(b|=64,b|=h.action):(b|=3&h.button,4&h.button&&(b|=64),8&h.button&&(b|=128),h.action===32?b|=32:h.action!==0||f||(b|=3)),b}const i=String.fromCharCode,o={DEFAULT:h=>{const f=[_(h,!1)+32,h.col+32,h.row+32];return f[0]>255||f[1]>255||f[2]>255?"":`\x1B[M${i(f[0])}${i(f[1])}${i(f[2])}`},SGR:h=>{const f=h.action===0&&h.button!==4?"m":"M";return`\x1B[<${_(h,!0)};${h.col};${h.row}${f}`},SGR_PIXELS:h=>{const f=h.action===0&&h.button!==4?"m":"M";return`\x1B[<${_(h,!0)};${h.x};${h.y}${f}`}};let c=r.CoreMouseService=class extends C.Disposable{constructor(h,f){super(),this._bufferService=h,this._coreService=f,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._onProtocolChange=this.register(new p.EventEmitter),this.onProtocolChange=this._onProtocolChange.event;for(const b of Object.keys(S))this.addProtocol(b,S[b]);for(const b of Object.keys(o))this.addEncoding(b,o[b]);this.reset()}addProtocol(h,f){this._protocols[h]=f}addEncoding(h,f){this._encodings[h]=f}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(h){if(!this._protocols[h])throw new Error(`unknown protocol "${h}"`);this._activeProtocol=h,this._onProtocolChange.fire(this._protocols[h].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(h){if(!this._encodings[h])throw new Error(`unknown encoding "${h}"`);this._activeEncoding=h}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null}triggerMouseEvent(h){if(h.col<0||h.col>=this._bufferService.cols||h.row<0||h.row>=this._bufferService.rows||h.button===4&&h.action===32||h.button===3&&h.action!==32||h.button!==4&&(h.action===2||h.action===3)||(h.col++,h.row++,h.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,h,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(h))return!1;const f=this._encodings[this._activeEncoding](h);return f&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(f):this._coreService.triggerDataEvent(f,!0)),this._lastEvent=h,!0}explainEvents(h){return{down:!!(1&h),up:!!(2&h),drag:!!(4&h),move:!!(8&h),wheel:!!(16&h)}}_equalEvents(h,f,b){if(b){if(h.x!==f.x||h.y!==f.y)return!1}else if(h.col!==f.col||h.row!==f.row)return!1;return h.button===f.button&&h.action===f.action&&h.ctrl===f.ctrl&&h.alt===f.alt&&h.shift===f.shift}};r.CoreMouseService=c=u([m(0,l.IBufferService),m(1,l.ICoreService)],c)},6975:function(y,r,n){var u=this&&this.__decorate||function(c,h,f,b){var E,I=arguments.length,v=I<3?h:b===null?b=Object.getOwnPropertyDescriptor(h,f):b;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")v=Reflect.decorate(c,h,f,b);else for(var x=c.length-1;x>=0;x--)(E=c[x])&&(v=(I<3?E(v):I>3?E(h,f,v):E(h,f))||v);return I>3&&v&&Object.defineProperty(h,f,v),v},m=this&&this.__param||function(c,h){return function(f,b){h(f,b,c)}};Object.defineProperty(r,"__esModule",{value:!0}),r.CoreService=void 0;const l=n(1439),p=n(8460),C=n(844),S=n(2585),_=Object.freeze({insertMode:!1}),i=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,origin:!1,reverseWraparound:!1,sendFocus:!1,wraparound:!0});let o=r.CoreService=class extends C.Disposable{constructor(c,h,f){super(),this._bufferService=c,this._logService=h,this._optionsService=f,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this.register(new p.EventEmitter),this.onData=this._onData.event,this._onUserInput=this.register(new p.EventEmitter),this.onUserInput=this._onUserInput.event,this._onBinary=this.register(new p.EventEmitter),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this.register(new p.EventEmitter),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=(0,l.clone)(_),this.decPrivateModes=(0,l.clone)(i)}reset(){this.modes=(0,l.clone)(_),this.decPrivateModes=(0,l.clone)(i)}triggerDataEvent(c,h=!1){if(this._optionsService.rawOptions.disableStdin)return;const f=this._bufferService.buffer;h&&this._optionsService.rawOptions.scrollOnUserInput&&f.ybase!==f.ydisp&&this._onRequestScrollToBottom.fire(),h&&this._onUserInput.fire(),this._logService.debug(`sending data "${c}"`,()=>c.split("").map(b=>b.charCodeAt(0))),this._onData.fire(c)}triggerBinaryEvent(c){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${c}"`,()=>c.split("").map(h=>h.charCodeAt(0))),this._onBinary.fire(c))}};r.CoreService=o=u([m(0,S.IBufferService),m(1,S.ILogService),m(2,S.IOptionsService)],o)},9074:(y,r,n)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.DecorationService=void 0;const u=n(8055),m=n(8460),l=n(844),p=n(6106);let C=0,S=0;class _ extends l.Disposable{get decorations(){return this._decorations.values()}constructor(){super(),this._decorations=new p.SortedList(c=>c==null?void 0:c.marker.line),this._onDecorationRegistered=this.register(new m.EventEmitter),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this.register(new m.EventEmitter),this.onDecorationRemoved=this._onDecorationRemoved.event,this.register((0,l.toDisposable)(()=>this.reset()))}registerDecoration(c){if(c.marker.isDisposed)return;const h=new i(c);if(h){const f=h.marker.onDispose(()=>h.dispose());h.onDispose(()=>{h&&(this._decorations.delete(h)&&this._onDecorationRemoved.fire(h),f.dispose())}),this._decorations.insert(h),this._onDecorationRegistered.fire(h)}return h}reset(){for(const c of this._decorations.values())c.dispose();this._decorations.clear()}*getDecorationsAtCell(c,h,f){var b,E,I;let v=0,x=0;for(const L of this._decorations.getKeyIterator(h))v=(b=L.options.x)!==null&&b!==void 0?b:0,x=v+((E=L.options.width)!==null&&E!==void 0?E:1),c>=v&&c<x&&(!f||((I=L.options.layer)!==null&&I!==void 0?I:"bottom")===f)&&(yield L)}forEachDecorationAtCell(c,h,f,b){this._decorations.forEachByKey(h,E=>{var I,v,x;C=(I=E.options.x)!==null&&I!==void 0?I:0,S=C+((v=E.options.width)!==null&&v!==void 0?v:1),c>=C&&c<S&&(!f||((x=E.options.layer)!==null&&x!==void 0?x:"bottom")===f)&&b(E)})}}r.DecorationService=_;class i extends l.Disposable{get isDisposed(){return this._isDisposed}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=u.css.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=u.css.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}constructor(c){super(),this.options=c,this.onRenderEmitter=this.register(new m.EventEmitter),this.onRender=this.onRenderEmitter.event,this._onDispose=this.register(new m.EventEmitter),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=c.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}dispose(){this._onDispose.fire(),super.dispose()}}},4348:(y,r,n)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.InstantiationService=r.ServiceCollection=void 0;const u=n(2585),m=n(8343);class l{constructor(...C){this._entries=new Map;for(const[S,_]of C)this.set(S,_)}set(C,S){const _=this._entries.get(C);return this._entries.set(C,S),_}forEach(C){for(const[S,_]of this._entries.entries())C(S,_)}has(C){return this._entries.has(C)}get(C){return this._entries.get(C)}}r.ServiceCollection=l,r.InstantiationService=class{constructor(){this._services=new l,this._services.set(u.IInstantiationService,this)}setService(p,C){this._services.set(p,C)}getService(p){return this._services.get(p)}createInstance(p,...C){const S=(0,m.getServiceDependencies)(p).sort((o,c)=>o.index-c.index),_=[];for(const o of S){const c=this._services.get(o.id);if(!c)throw new Error(`[createInstance] ${p.name} depends on UNKNOWN service ${o.id}.`);_.push(c)}const i=S.length>0?S[0].index:C.length;if(C.length!==i)throw new Error(`[createInstance] First service dependency of ${p.name} at position ${i+1} conflicts with ${C.length} static arguments`);return new p(...C,..._)}}},7866:function(y,r,n){var u=this&&this.__decorate||function(i,o,c,h){var f,b=arguments.length,E=b<3?o:h===null?h=Object.getOwnPropertyDescriptor(o,c):h;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(i,o,c,h);else for(var I=i.length-1;I>=0;I--)(f=i[I])&&(E=(b<3?f(E):b>3?f(o,c,E):f(o,c))||E);return b>3&&E&&Object.defineProperty(o,c,E),E},m=this&&this.__param||function(i,o){return function(c,h){o(c,h,i)}};Object.defineProperty(r,"__esModule",{value:!0}),r.traceCall=r.setTraceLogger=r.LogService=void 0;const l=n(844),p=n(2585),C={trace:p.LogLevelEnum.TRACE,debug:p.LogLevelEnum.DEBUG,info:p.LogLevelEnum.INFO,warn:p.LogLevelEnum.WARN,error:p.LogLevelEnum.ERROR,off:p.LogLevelEnum.OFF};let S,_=r.LogService=class extends l.Disposable{get logLevel(){return this._logLevel}constructor(i){super(),this._optionsService=i,this._logLevel=p.LogLevelEnum.OFF,this._updateLogLevel(),this.register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel())),S=this}_updateLogLevel(){this._logLevel=C[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(i){for(let o=0;o<i.length;o++)typeof i[o]=="function"&&(i[o]=i[o]())}_log(i,o,c){this._evalLazyOptionalParams(c),i.call(console,(this._optionsService.options.logger?"":"xterm.js: ")+o,...c)}trace(i,...o){var c,h;this._logLevel<=p.LogLevelEnum.TRACE&&this._log((h=(c=this._optionsService.options.logger)===null||c===void 0?void 0:c.trace.bind(this._optionsService.options.logger))!==null&&h!==void 0?h:console.log,i,o)}debug(i,...o){var c,h;this._logLevel<=p.LogLevelEnum.DEBUG&&this._log((h=(c=this._optionsService.options.logger)===null||c===void 0?void 0:c.debug.bind(this._optionsService.options.logger))!==null&&h!==void 0?h:console.log,i,o)}info(i,...o){var c,h;this._logLevel<=p.LogLevelEnum.INFO&&this._log((h=(c=this._optionsService.options.logger)===null||c===void 0?void 0:c.info.bind(this._optionsService.options.logger))!==null&&h!==void 0?h:console.info,i,o)}warn(i,...o){var c,h;this._logLevel<=p.LogLevelEnum.WARN&&this._log((h=(c=this._optionsService.options.logger)===null||c===void 0?void 0:c.warn.bind(this._optionsService.options.logger))!==null&&h!==void 0?h:console.warn,i,o)}error(i,...o){var c,h;this._logLevel<=p.LogLevelEnum.ERROR&&this._log((h=(c=this._optionsService.options.logger)===null||c===void 0?void 0:c.error.bind(this._optionsService.options.logger))!==null&&h!==void 0?h:console.error,i,o)}};r.LogService=_=u([m(0,p.IOptionsService)],_),r.setTraceLogger=function(i){S=i},r.traceCall=function(i,o,c){if(typeof c.value!="function")throw new Error("not supported");const h=c.value;c.value=function(...f){if(S.logLevel!==p.LogLevelEnum.TRACE)return h.apply(this,f);S.trace(`GlyphRenderer#${h.name}(${f.map(E=>JSON.stringify(E)).join(", ")})`);const b=h.apply(this,f);return S.trace(`GlyphRenderer#${h.name} return`,b),b}}},7302:(y,r,n)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.OptionsService=r.DEFAULT_OPTIONS=void 0;const u=n(8460),m=n(844),l=n(6114);r.DEFAULT_OPTIONS={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"courier-new, courier, monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1e3,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},rightClickSelectsWord:l.isMac,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRulerWidth:0};const p=["normal","bold","100","200","300","400","500","600","700","800","900"];class C extends m.Disposable{constructor(_){super(),this._onOptionChange=this.register(new u.EventEmitter),this.onOptionChange=this._onOptionChange.event;const i=Object.assign({},r.DEFAULT_OPTIONS);for(const o in _)if(o in i)try{const c=_[o];i[o]=this._sanitizeAndValidateOption(o,c)}catch(c){console.error(c)}this.rawOptions=i,this.options=Object.assign({},i),this._setupOptions()}onSpecificOptionChange(_,i){return this.onOptionChange(o=>{o===_&&i(this.rawOptions[_])})}onMultipleOptionChange(_,i){return this.onOptionChange(o=>{_.indexOf(o)!==-1&&i()})}_setupOptions(){const _=o=>{if(!(o in r.DEFAULT_OPTIONS))throw new Error(`No option with key "${o}"`);return this.rawOptions[o]},i=(o,c)=>{if(!(o in r.DEFAULT_OPTIONS))throw new Error(`No option with key "${o}"`);c=this._sanitizeAndValidateOption(o,c),this.rawOptions[o]!==c&&(this.rawOptions[o]=c,this._onOptionChange.fire(o))};for(const o in this.rawOptions){const c={get:_.bind(this,o),set:i.bind(this,o)};Object.defineProperty(this.options,o,c)}}_sanitizeAndValidateOption(_,i){switch(_){case"cursorStyle":if(i||(i=r.DEFAULT_OPTIONS[_]),!function(o){return o==="block"||o==="underline"||o==="bar"}(i))throw new Error(`"${i}" is not a valid value for ${_}`);break;case"wordSeparator":i||(i=r.DEFAULT_OPTIONS[_]);break;case"fontWeight":case"fontWeightBold":if(typeof i=="number"&&1<=i&&i<=1e3)break;i=p.includes(i)?i:r.DEFAULT_OPTIONS[_];break;case"cursorWidth":i=Math.floor(i);case"lineHeight":case"tabStopWidth":if(i<1)throw new Error(`${_} cannot be less than 1, value: ${i}`);break;case"minimumContrastRatio":i=Math.max(1,Math.min(21,Math.round(10*i)/10));break;case"scrollback":if((i=Math.min(i,4294967295))<0)throw new Error(`${_} cannot be less than 0, value: ${i}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(i<=0)throw new Error(`${_} cannot be less than or equal to 0, value: ${i}`);break;case"rows":case"cols":if(!i&&i!==0)throw new Error(`${_} must be numeric, value: ${i}`);break;case"windowsPty":i=i??{}}return i}}r.OptionsService=C},2660:function(y,r,n){var u=this&&this.__decorate||function(C,S,_,i){var o,c=arguments.length,h=c<3?S:i===null?i=Object.getOwnPropertyDescriptor(S,_):i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")h=Reflect.decorate(C,S,_,i);else for(var f=C.length-1;f>=0;f--)(o=C[f])&&(h=(c<3?o(h):c>3?o(S,_,h):o(S,_))||h);return c>3&&h&&Object.defineProperty(S,_,h),h},m=this&&this.__param||function(C,S){return function(_,i){S(_,i,C)}};Object.defineProperty(r,"__esModule",{value:!0}),r.OscLinkService=void 0;const l=n(2585);let p=r.OscLinkService=class{constructor(C){this._bufferService=C,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(C){const S=this._bufferService.buffer;if(C.id===void 0){const f=S.addMarker(S.ybase+S.y),b={data:C,id:this._nextId++,lines:[f]};return f.onDispose(()=>this._removeMarkerFromLink(b,f)),this._dataByLinkId.set(b.id,b),b.id}const _=C,i=this._getEntryIdKey(_),o=this._entriesWithId.get(i);if(o)return this.addLineToLink(o.id,S.ybase+S.y),o.id;const c=S.addMarker(S.ybase+S.y),h={id:this._nextId++,key:this._getEntryIdKey(_),data:_,lines:[c]};return c.onDispose(()=>this._removeMarkerFromLink(h,c)),this._entriesWithId.set(h.key,h),this._dataByLinkId.set(h.id,h),h.id}addLineToLink(C,S){const _=this._dataByLinkId.get(C);if(_&&_.lines.every(i=>i.line!==S)){const i=this._bufferService.buffer.addMarker(S);_.lines.push(i),i.onDispose(()=>this._removeMarkerFromLink(_,i))}}getLinkData(C){var S;return(S=this._dataByLinkId.get(C))===null||S===void 0?void 0:S.data}_getEntryIdKey(C){return`${C.id};;${C.uri}`}_removeMarkerFromLink(C,S){const _=C.lines.indexOf(S);_!==-1&&(C.lines.splice(_,1),C.lines.length===0&&(C.data.id!==void 0&&this._entriesWithId.delete(C.key),this._dataByLinkId.delete(C.id)))}};r.OscLinkService=p=u([m(0,l.IBufferService)],p)},8343:(y,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.createDecorator=r.getServiceDependencies=r.serviceRegistry=void 0;const n="di$target",u="di$dependencies";r.serviceRegistry=new Map,r.getServiceDependencies=function(m){return m[u]||[]},r.createDecorator=function(m){if(r.serviceRegistry.has(m))return r.serviceRegistry.get(m);const l=function(p,C,S){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");(function(_,i,o){i[n]===i?i[u].push({id:_,index:o}):(i[u]=[{id:_,index:o}],i[n]=i)})(l,p,S)};return l.toString=()=>m,r.serviceRegistry.set(m,l),l}},2585:(y,r,n)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.IDecorationService=r.IUnicodeService=r.IOscLinkService=r.IOptionsService=r.ILogService=r.LogLevelEnum=r.IInstantiationService=r.ICharsetService=r.ICoreService=r.ICoreMouseService=r.IBufferService=void 0;const u=n(8343);var m;r.IBufferService=(0,u.createDecorator)("BufferService"),r.ICoreMouseService=(0,u.createDecorator)("CoreMouseService"),r.ICoreService=(0,u.createDecorator)("CoreService"),r.ICharsetService=(0,u.createDecorator)("CharsetService"),r.IInstantiationService=(0,u.createDecorator)("InstantiationService"),function(l){l[l.TRACE=0]="TRACE",l[l.DEBUG=1]="DEBUG",l[l.INFO=2]="INFO",l[l.WARN=3]="WARN",l[l.ERROR=4]="ERROR",l[l.OFF=5]="OFF"}(m||(r.LogLevelEnum=m={})),r.ILogService=(0,u.createDecorator)("LogService"),r.IOptionsService=(0,u.createDecorator)("OptionsService"),r.IOscLinkService=(0,u.createDecorator)("OscLinkService"),r.IUnicodeService=(0,u.createDecorator)("UnicodeService"),r.IDecorationService=(0,u.createDecorator)("DecorationService")},1480:(y,r,n)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.UnicodeService=void 0;const u=n(8460),m=n(225);r.UnicodeService=class{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new u.EventEmitter,this.onChange=this._onChange.event;const l=new m.UnicodeV6;this.register(l),this._active=l.version,this._activeProvider=l}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(l){if(!this._providers[l])throw new Error(`unknown Unicode version "${l}"`);this._active=l,this._activeProvider=this._providers[l],this._onChange.fire(l)}register(l){this._providers[l.version]=l}wcwidth(l){return this._activeProvider.wcwidth(l)}getStringCellWidth(l){let p=0;const C=l.length;for(let S=0;S<C;++S){let _=l.charCodeAt(S);if(55296<=_&&_<=56319){if(++S>=C)return p+this.wcwidth(_);const i=l.charCodeAt(S);56320<=i&&i<=57343?_=1024*(_-55296)+i-56320+65536:p+=this.wcwidth(i)}p+=this.wcwidth(_)}return p}}}},a={};function g(y){var r=a[y];if(r!==void 0)return r.exports;var n=a[y]={exports:{}};return s[y].call(n.exports,n,n.exports,g),n.exports}var w={};return(()=>{var y=w;Object.defineProperty(y,"__esModule",{value:!0}),y.Terminal=void 0;const r=g(9042),n=g(3236),u=g(844),m=g(5741),l=g(8285),p=g(7975),C=g(7090),S=["cols","rows"];class _ extends u.Disposable{constructor(o){super(),this._core=this.register(new n.Terminal(o)),this._addonManager=this.register(new m.AddonManager),this._publicOptions=Object.assign({},this._core.options);const c=f=>this._core.options[f],h=(f,b)=>{this._checkReadonlyOptions(f),this._core.options[f]=b};for(const f in this._core.options){const b={get:c.bind(this,f),set:h.bind(this,f)};Object.defineProperty(this._publicOptions,f,b)}}_checkReadonlyOptions(o){if(S.includes(o))throw new Error(`Option "${o}" 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 p.ParserApi(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new C.UnicodeApi(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 l.BufferNamespaceApi(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){const o=this._core.coreService.decPrivateModes;let c="none";switch(this._core.coreMouseService.activeProtocol){case"X10":c="x10";break;case"VT200":c="vt200";break;case"DRAG":c="drag";break;case"ANY":c="any"}return{applicationCursorKeysMode:o.applicationCursorKeys,applicationKeypadMode:o.applicationKeypad,bracketedPasteMode:o.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:c,originMode:o.origin,reverseWraparoundMode:o.reverseWraparound,sendFocusMode:o.sendFocus,wraparoundMode:o.wraparound}}get options(){return this._publicOptions}set options(o){for(const c in o)this._publicOptions[c]=o[c]}blur(){this._core.blur()}focus(){this._core.focus()}resize(o,c){this._verifyIntegers(o,c),this._core.resize(o,c)}open(o){this._core.open(o)}attachCustomKeyEventHandler(o){this._core.attachCustomKeyEventHandler(o)}registerLinkProvider(o){return this._core.registerLinkProvider(o)}registerCharacterJoiner(o){return this._checkProposedApi(),this._core.registerCharacterJoiner(o)}deregisterCharacterJoiner(o){this._checkProposedApi(),this._core.deregisterCharacterJoiner(o)}registerMarker(o=0){return this._verifyIntegers(o),this._core.registerMarker(o)}registerDecoration(o){var c,h,f;return this._checkProposedApi(),this._verifyPositiveIntegers((c=o.x)!==null&&c!==void 0?c:0,(h=o.width)!==null&&h!==void 0?h:0,(f=o.height)!==null&&f!==void 0?f:0),this._core.registerDecoration(o)}hasSelection(){return this._core.hasSelection()}select(o,c,h){this._verifyIntegers(o,c,h),this._core.select(o,c,h)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(o,c){this._verifyIntegers(o,c),this._core.selectLines(o,c)}dispose(){super.dispose()}scrollLines(o){this._verifyIntegers(o),this._core.scrollLines(o)}scrollPages(o){this._verifyIntegers(o),this._core.scrollPages(o)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(o){this._verifyIntegers(o),this._core.scrollToLine(o)}clear(){this._core.clear()}write(o,c){this._core.write(o,c)}writeln(o,c){this._core.write(o),this._core.write(`\r `,c)}paste(o){this._core.paste(o)}refresh(o,c){this._verifyIntegers(o,c),this._core.refresh(o,c)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(o){this._addonManager.loadAddon(this,o)}static get strings(){return r}_verifyIntegers(...o){for(const c of o)if(c===1/0||isNaN(c)||c%1!=0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...o){for(const c of o)if(c&&(c===1/0||isNaN(c)||c%1!=0||c<0))throw new Error("This API only accepts positive integers")}}y.Terminal=_})(),w})())}(xs)),xs.exports}var Xa=qa();const yr=Z.forwardRef(function({options:e={},addons:s,className:a,onBinary:g,onCursorMove:w,onData:y,onKey:r,onLineFeed:n,onScroll:u,onSelectionChange:m,onRender:l,onResize:p,onTitleChange:C,customKeyEventHandler:S,onOpen:_},i){const[o,c]=Z.useState(!1),h=Z.useRef(null),f=Z.useRef(new Xa.Terminal(e));Z.useImperativeHandle(i,()=>f.current);const b=()=>{s&&s.forEach(E=>{var I;(I=f.current)==null||I.loadAddon(E)}),g&&f.current.onBinary(g),w&&f.current.onCursorMove(w),y&&f.current.onData(y),r&&f.current.onKey(r),n&&f.current.onLineFeed(n),u&&f.current.onScroll(u),m&&f.current.onSelectionChange(m),l&&f.current.onRender(l),p&&f.current.onResize(p),C&&f.current.onTitleChange(C),S&&f.current.attachCustomKeyEventHandler(S)};return Z.useEffect(()=>{var I;const E=h.current;return E&&(b(),(I=f.current)==null||I.open(E),c(!0)),()=>{var v;(v=f.current)==null||v.dispose()}},[]),Z.useLayoutEffect(()=>{o&&_&&_()},[o]),d.jsx("div",{className:a,ref:h})}),Qa={theme:{background:"#292c2f"}},Za={command:"su -l",environment:[{key:"TERM",value:"xterm-256color"},{key:"HOME",value:"/root"},{key:"PATH",value:"/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin:/run/current-system/sw/bin"},{key:"LANG",value:"C.UTF-8"},{key:"USER",value:"root"}],user:0,group:0},Ja=({instance:t,refreshInstance:e})=>{var z;const{name:s,project:a}=tt(),g=new TextEncoder,w=O.useNotify(),[y,r]=Z.useState(!1),[n,u]=Z.useState(null),[m,l]=Z.useState(null),[p,C]=Z.useState(Za),[S]=Z.useState(new Cr.FitAddon),[_,i]=Z.useState(!1),o=Z.useRef(null),c=Z.useRef(null),[h,f]=Z.useState(0),{canUpdateInstanceState:b,canExecInstance:E}=Oe();tr({when:_,message:"Are you sure you want to leave this page?"});const I=A=>{_&&(A.returnValue="Are you sure you want to leave this page?")};O.useListener(window,I,"beforeunload");const v=async A=>{if(!s){w.failure("Missing name",new Error);return}if(!a){w.failure("Missing project",new Error);return}r(!0);const M=await jo(s,a,A).catch(X=>{r(!1),w.failure("Connection failed",X)});if(!M)return;const T=M.operation.split("?")[0],N=`wss://${location.host}${T}/websocket?secret=${M.metadata.metadata.fds[0]}`,V=`wss://${location.host}${T}/websocket?secret=${M.metadata.metadata.fds.control}`,q=new WebSocket(N),J=new WebSocket(V);return J.onopen=()=>{r(!1),l(J)},J.onerror=X=>{w.failure("Error",X)},J.onclose=X=>{X.code!==1005&&w.failure("Error",X.reason,xt(X.code)),l(null)},q.onopen=()=>{u(q)},q.onerror=X=>{w.failure("Error",X)},q.onclose=X=>{X.code!==1005&&w.failure("Error",X.reason,xt(X.code)),u(null),i(!1)},q.binaryType="arraybuffer",q.onmessage=X=>{var ce;(ce=o.current)==null||ce.write(new Uint8Array(X.data))},[q,J]},x=is(t),L=x&&(((z=t.state)==null?void 0:z.processes)??0)<1,k=x&&!L,D=E(t);Z.useEffect(()=>{if(L&&c.current===null){const T=setTimeout(()=>{e(),c.current=null,f(N=>N+1)},1e3);return c.current=T,()=>{clearTimeout(T)}}else return()=>{}},[L,h]),Z.useEffect(()=>{var A;if((A=o.current)==null||A.clear(),w.clear(),k&&D){const M=v(p);return()=>{M.then(T=>{T==null||T.map(N=>{N.close()})})}}else return()=>{}},[p,t.status,k,D]);const B=()=>{var M,T;if((m==null?void 0:m.readyState)===WebSocket.CLOSED)return;ht("p-terminal",void 0,10),(T=(M=o.current)==null?void 0:M.element)==null||T.style.setProperty("padding","1rem"),S.fit();const A=S.proposeDimensions();m==null||m.send(g.encode(JSON.stringify({command:"window-resize",args:{height:A==null?void 0:A.rows.toString(),width:A==null?void 0:A.cols.toString()}})))};O.useListener(window,()=>{B(),setTimeout(B,500)},"resize",!0);const F=()=>{var A;B(),(A=o.current)==null||A.focus()},{handleStart:Y,isLoading:$}=dr(t);return D?d.jsxs("div",{className:"instance-terminal-tab",children:[k&&d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"p-panel__controls",children:d.jsx(Va,{reconnect:C,payload:p})}),d.jsx(ts,{}),y&&d.jsx(O.Spinner,{className:"u-loader",text:"Loading terminal session..."}),m&&d.jsx(yr,{ref:o,addons:[S],options:Qa,onData:A=>{i(!0),n==null||n.send(g.encode(A))},onOpen:F,className:"p-terminal"})]}),!k&&d.jsxs(O.EmptyState,{className:"empty-state",image:d.jsx(O.Icon,{name:"pods",className:"empty-state-icon"}),title:L?"Instance starting":"Instance stopped",children:[d.jsx("p",{children:L?"Terminal will be ready once the instance is finished booting.":"Start the instance to access the terminal."}),d.jsx(O.ActionButton,{appearance:"positive",loading:$||L,onClick:Y,disabled:!b(t),title:b(t)?"":"You do not have permission to start this instance.",children:"Start instance"})]})]}):d.jsx(O.Notification,{severity:"caution",title:"Restricted permissions",children:"You do not have permission to use the terminal for this instance."})},ec=async(t,e,s,a)=>{const g=new URLSearchParams;return g.set("project",t.project),fetch(`/1.0/instances/${encodeURIComponent(t.name)}/snapshots?${g.toString()}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e,expires_at:s,stateful:a})}).then(Pt).then(w=>w)},wr=async(t,e)=>{const s=new URLSearchParams;return s.set("project",t.project),fetch(`/1.0/instances/${encodeURIComponent(t.name)}/snapshots/${encodeURIComponent(e.name)}?${s.toString()}`,{method:"DELETE"}).then(Pt).then(a=>a)},tc=async(t,e,s)=>{const a=[];return new Promise((g,w)=>{Promise.allSettled(e.map(async y=>{await wr(t,{name:y}).then(r=>{s.set(r.metadata.id,()=>{po(a)},n=>{vi(a,n)},()=>{Si(a,e.length,g)})}).catch(r=>{vi(a,r instanceof Error?r.message:""),Si(a,e.length,g)})})).catch(w)})},sc=async(t,e,s)=>{const a=new URLSearchParams;return a.set("project",t.project),fetch(`/1.0/instances/${encodeURIComponent(t.name)}?${a.toString()}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({restore:e.name,stateful:e.stateful?s:!1})}).then(Pt).then(g=>g)},ic=async(t,e,s)=>{const a=new URLSearchParams;return a.set("project",t.project),fetch(`/1.0/instances/${encodeURIComponent(t.name)}/snapshots/${encodeURIComponent(e.name)}?${a.toString()}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:s})}).then(Pt).then(g=>g)},rc=async(t,e,s)=>{const a=new URLSearchParams;return a.set("project",t.project),fetch(`/1.0/instances/${encodeURIComponent(t.name)}/snapshots/${encodeURIComponent(e.name)}?${a.toString()}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({expires_at:s})}).then(Pt).then(g=>g)},nc=t=>!!t.config["migration.stateful"],oc=(t,e,s)=>["deduplicate","Snapshot name already in use",async a=>s&&a===s||go(a,t.project,e,`instances/${encodeURIComponent(t.name)}/snapshots`)],xr=(t,e,s)=>Xe().shape({name:Ve().test(...oc(t,e,s)).matches(/^[A-Za-z0-9-_.:]+$/,{message:"Only alphanumeric characters, underscores, periods, hyphens, and colons are allowed in this field"}),expirationDate:Ve().nullable().optional().test(...qo()).test(...Xo()),expirationTime:Ve().nullable().optional().test(...Vo()),stateful:mo()}),It=({name:t,instance:e})=>d.jsx(je,{type:"snapshot",value:t,to:`/ui/project/${encodeURIComponent(e.project)}/instance/${encodeURIComponent(e.name)}/snapshots`}),ac=({instance:t,snapshot:e,close:s,onSuccess:a})=>{const g=Ee(),w=O.useToastNotification(),y=Be(),r=Z.useState(null),n=S=>{y.invalidateQueries({predicate:_=>_.queryKey[0]===Ce.instances}),a(d.jsxs(d.Fragment,{children:["Snapshot ",d.jsx(It,{name:S,instance:t})," ","saved for instance ",d.jsx(ue,{instance:t}),"."]})),s()},u=(S,_)=>{const i=_?{name:_}:e,o=d.jsx(ue,{instance:t});rc(t,i,S).then(c=>{g.set(c.metadata.id,()=>{n(_??e.name)},h=>{w.failure(`Snapshot update failed for instance ${t.name}`,new Error(h),o),C.setSubmitting(!1)})}).catch(c=>{w.failure(`Snapshot update failed for instance ${t.name}`,c,o),C.setSubmitting(!1)})},m=(S,_)=>{const i=d.jsx(It,{name:e.name,instance:t});ic(t,e,S).then(o=>{g.set(o.metadata.id,()=>{_?u(_,S):n(S)},c=>{w.failure(`Snapshot rename failed for ${e.name}`,new Error(c),i),C.setSubmitting(!1)})}).catch(o=>{w.failure(`Snapshot rename failed for ${e.name}`,o,i),C.setSubmitting(!1)})},[l,p]=e.expires_at===Ts?[null,null]:vo(new Date(e.expires_at)).slice(0,16).split(" "),C=Ne({initialValues:{name:e.name,stateful:e.stateful,expirationDate:l,expirationTime:p},validateOnMount:!0,validationSchema:xr(t,r,e.name),onSubmit:S=>{const _=S.name,i=S.expirationDate&&S.expirationTime?sr(mr(S.expirationDate,S.expirationTime)):Ts,o=_!==e.name,c=i!==e.expires_at;o&&c?m(_,i):o?m(_):u(i)}});return d.jsx(pr,{isEdit:!0,formik:C,close:s})},cc=({instance:t,snapshot:e,onSuccess:s,isDeleting:a,isRestoring:g,disabledReason:w})=>{const{openPortal:y,closePortal:r,isOpen:n,Portal:u}=O.usePortal();return d.jsxs(d.Fragment,{children:[n&&d.jsx(u,{children:d.jsx(ac,{close:r,instance:t,onSuccess:s,snapshot:e})}),d.jsx(O.Button,{appearance:"base",hasIcon:!0,dense:!0,disabled:a||g||!!w,onClick:y,type:"button","aria-label":"Edit snapshot",title:w??"Edit",children:d.jsx(O.Icon,{name:"edit"})})]})},hc=({instance:t,snapshot:e,close:s})=>{const a=Ee(),g=O.useToastNotification(),w=Be(),y=d.jsx(It,{name:e.name,instance:t}),{data:r}=Lt(t.project),{canCreateImageAliases:n}=Ge(),u=()=>{const C=d.jsx(Gs,{to:`/ui/project/${encodeURIComponent(t.project)}/images`,children:"created"});g.success(d.jsxs(d.Fragment,{children:["Image ",C," from snapshot ",y,"."]}))},m=()=>{w.invalidateQueries({predicate:C=>C.queryKey[0]===Ce.images})},l=(C,S,_)=>JSON.stringify({public:_,source:{type:"snapshot",name:`${C.name}/${S.name}`}}),p=Ne({initialValues:{alias:"",isPublic:!1},validationSchema:Xe().shape({alias:Ve()}),onSubmit:C=>{const S=C.alias;ir(l(t,e,C.isPublic),t).then(_=>{g.info(d.jsxs(d.Fragment,{children:["Creation of image from snapshot ",y," started."]})),a.set(_.metadata.id,i=>{var o;if(S){const c=((o=i.metadata.metadata)==null?void 0:o.fingerprint)??"";rr(c,S,t.project).then(m).then(u).catch(h=>{g.failure(`Image creation from snapshot "${e.name}" succeeded. Failed to create an alias.`,h)})}else m(),u()},i=>{g.failure(`Image creation from snapshot "${e.name}" failed.`,new Error(i),y)})}).catch(_=>{g.failure(`Image creation from snapshot "${e.name}" failed.`,_,y)}).finally(()=>{s()})}});return d.jsx(O.Modal,{close:s,title:"Create image from instance snapshot",buttonRow:d.jsxs(d.Fragment,{children:[d.jsx(O.Button,{appearance:"base",className:"u-no-margin--bottom",type:"button",onClick:s,children:"Cancel"}),d.jsx(O.ActionButton,{appearance:"positive",className:"u-no-margin--bottom",loading:p.isSubmitting,disabled:!p.isValid||p.isSubmitting,onClick:()=>void p.submitForm(),children:"Create image"})]}),children:d.jsxs(O.Form,{onSubmit:p.handleSubmit,children:[d.jsx(O.Input,{type:"text",label:"Instance",value:t.name,disabled:!0}),d.jsx(O.Input,{type:"text",label:"Snapshot",value:e.name,disabled:!0}),d.jsx(O.Input,{...p.getFieldProps("alias"),type:"text",label:"Alias",error:p.touched.alias?p.errors.alias:null,disabled:!n(r),title:n(r)?"":"You do not have permission to create image aliases in this project"}),d.jsx(O.Input,{...p.getFieldProps("isPublic"),type:"checkbox",label:"Make the image publicly available",error:p.touched.isPublic?p.errors.isPublic:null}),d.jsx(O.Input,{type:"submit",hidden:!0,value:"Hidden input"})]})})},lc=({instance:t,snapshot:e,isDeleting:s,isRestoring:a})=>{const{openPortal:g,closePortal:w,isOpen:y,Portal:r}=O.usePortal(),{data:n}=Lt(t.project),{canCreateImages:u}=Ge();return d.jsxs(d.Fragment,{children:[y&&d.jsx(r,{children:d.jsx(hc,{close:w,instance:t,snapshot:e})}),d.jsx(O.Button,{appearance:"base",hasIcon:!0,dense:!0,disabled:s||a||!u(n),onClick:g,type:"button","aria-label":"Create image",title:u(n)?"Create image":"You do not have permission to create images in this project",children:d.jsx(O.Icon,{name:"export"})})]})},uc=(t,e,s)=>{const a={name:t.instanceName,description:e.description,architecture:e.architecture,ephemeral:s.ephemeral,mode:"pull",devices:{...e.devices,root:{path:"/",type:"disk",pool:t.targetStoragePool}}},g={project:e.project,type:"copy",source:`${e.name}/${s.name}`,base_image:s.config["volatile.base_image"]??""};return s.stateful&&t.stateful&&(a.stateful=!0,g.live=!1),{...a,source:g}},dc=({instance:t,snapshot:e,close:s})=>{var h,f,b;const a=O.useToastNotification(),g=Ys(),w=Z.useState(null),y=Ee(),{data:r=[],isLoading:n}=Dt(),{canCreateInstances:u}=Ge(),{data:m=[],isLoading:l}=nr(),{data:p=[]}=vr(t.project),C=(E,I,v)=>{const x=d.jsx(ue,{instance:{name:E,project:I,type:v}}),L=d.jsxs(d.Fragment,{children:["Created instance ",x,"."]});a.success(L)},S=E=>{const I=p.map(x=>x.name),v=or(E.name,`-${e.name}-copy`);if(I.includes(v)){let x=1;for(;I.includes(`${v}-${x}`);)x++;return`${v}-${x}`}return v},_=E=>{const I={};return E.stateful&&(E.targetProject===t.project&&(I.targetProject="Stateful instance snapshot duplication must be in a different project"),E.instanceName!==t.name&&(I.instanceName="Instance name must be the same for stateful duplication")),I},i=r.filter(u),o=i.some(E=>E.name===t.project),c=Ne({initialValues:{instanceName:S(t),targetProject:o?t.project:(h=i[0])==null?void 0:h.name,stateful:!1,targetClusterMember:g?t.location:"",targetStoragePool:((f=t.devices.root)==null?void 0:f.pool)??((b=m[0])==null?void 0:b.name)},enableReinitialize:!0,validate:_,validationSchema:Xe().shape({instanceName:zs(t.project,w).required()}),onSubmit:E=>{const I=d.jsx(ue,{instance:t});_r(JSON.stringify(uc(E,t,e)),E.targetProject,E.targetClusterMember).then(v=>{a.info(d.jsxs(d.Fragment,{children:["Instance creation started for"," ",d.jsx(ot,{bold:!0,type:t.type,value:E.instanceName}),"."]})),y.set(v.metadata.id,()=>{C(E.instanceName,E.targetProject,t.type)},x=>a.failure("Instance creation failed.",new Error(x),I))}).catch(v=>{a.failure("Instance creation failed.",v,I)}).finally(()=>{s()})}});return d.jsx(O.Modal,{close:s,className:"create-instance-from-snapshot-modal",title:"Create instance from snapshot",buttonRow:d.jsxs(d.Fragment,{children:[d.jsx(O.Button,{appearance:"base",className:"u-no-margin--bottom",type:"button",onClick:s,children:"Cancel"}),d.jsx(O.ActionButton,{appearance:"positive",className:"u-no-margin--bottom",loading:c.isSubmitting,disabled:!c.isValid||c.isSubmitting||l||n,onClick:()=>void c.submitForm(),children:"Create"})]}),children:d.jsxs(O.Form,{onSubmit:c.handleSubmit,children:[d.jsx(O.Input,{type:"text",label:"Snapshot name",disabled:!0,value:e.name}),d.jsx(O.Input,{...c.getFieldProps("instanceName"),type:"text",label:"New instance name",error:c.errors.instanceName}),d.jsx(gr,{...c.getFieldProps("targetClusterMember"),id:"targetClusterMember",label:"Target cluster member"}),d.jsx(O.Select,{...c.getFieldProps("targetStoragePool"),id:"storagePool",label:"Storage pool",options:m.map(E=>({label:E.name,value:E.name}))}),d.jsx(O.Select,{...c.getFieldProps("targetProject"),id:"project",label:"Target project",options:i.map(E=>({label:E.name,value:E.name})),error:c.errors.targetProject}),e.stateful&&d.jsx(O.Input,{...c.getFieldProps("stateful"),type:"checkbox",label:"Copy stateful"}),d.jsx(O.Input,{type:"submit",hidden:!0,value:"Hidden input"})]})})},_c=({instance:t,snapshot:e,isDeleting:s,isRestoring:a})=>{const{openPortal:g,closePortal:w,isOpen:y,Portal:r}=O.usePortal(),{data:n=[]}=Dt(),{canCreateInstances:u}=Ge(),m=n.filter(u);return d.jsxs(d.Fragment,{children:[y&&d.jsx(r,{children:d.jsx(dc,{close:w,instance:t,snapshot:e})}),d.jsx(O.Button,{appearance:"base",hasIcon:!0,dense:!0,"aria-label":"Create instance",disabled:s||a||!m.length,onClick:g,title:m.length>0?"Create instance":"You do not have permission to create instances",children:d.jsx(O.Icon,{name:"plus"})})]})},fc=({instance:t,snapshot:e,onSuccess:s,onFailure:a})=>{const g=Ee(),[w,y]=Z.useState(!1),[r,n]=Z.useState(!1),[u,m]=Z.useState(!0),l=Be(),{canManageInstanceSnapshots:p}=Oe(),C=p(t)?void 0:"You do not have permission to manage snapshots for this instance",S=()=>{y(!0),wr(t,e).then(i=>{g.set(i.metadata.id,()=>{s(d.jsxs(d.Fragment,{children:["Snapshot"," ",d.jsx(ot,{bold:!0,type:"snapshot",value:e.name})," ","deleted for instance ",d.jsx(ue,{instance:t}),"."]}))},o=>{a("Snapshot deletion failed",new Error(o))},()=>{y(!1),l.invalidateQueries({predicate:o=>o.queryKey[0]===Ce.instances})})}).catch(i=>{a("Snapshot deletion failed",i),y(!1)})},_=()=>{n(!0),sc(t,e,u).then(i=>{g.set(i.metadata.id,()=>{s(d.jsxs(d.Fragment,{children:["Snapshot"," ",d.jsx(It,{name:e.name,instance:t})," ","restored for instance ",d.jsx(ue,{instance:t}),"."]}))},o=>{a("Snapshot restore failed",new Error(o))},()=>{n(!1),l.invalidateQueries({predicate:o=>o.queryKey[0]===Ce.instances})})}).catch(i=>{a("Snapshot restore failed",i),n(!1)})};return d.jsx(d.Fragment,{children:d.jsx(O.List,{inline:!0,className:Ze("u-no-margin--bottom","actions-list",{"u-snapshot-actions":!w&&!r}),items:[d.jsx(cc,{instance:t,snapshot:e,onSuccess:s,isDeleting:w,isRestoring:r,disabledReason:C},"edit"),d.jsx(O.ConfirmationButton,{appearance:"base",loading:r,className:"has-icon is-dense",title:"Confirm restore",confirmationModalProps:{title:"Confirm restore",children:d.jsxs("p",{children:["This will restore snapshot"," ",d.jsx(ot,{type:"snapshot",value:e.name,bold:!0}),".",d.jsx("br",{}),"This action cannot be undone, and can result in data loss."]}),confirmExtra:e.stateful?d.jsx(Ro,{label:"Restore the instance state",force:[u,m]}):void 0,confirmButtonLabel:C??"Restore snapshot",confirmButtonAppearance:"positive",close:()=>{m(!0)},onConfirm:_},disabled:w||r||!!C,shiftClickEnabled:!0,showShiftClickHint:!0,children:d.jsx(O.Icon,{name:"change-version"})},"restore"),d.jsx(lc,{instance:t,snapshot:e,isRestoring:r,isDeleting:w},"publish"),d.jsx(_c,{instance:t,snapshot:e,isDeleting:w,isRestoring:r},"duplicate"),d.jsx(O.ConfirmationButton,{appearance:"base",loading:w,className:"has-icon is-dense",confirmationModalProps:{title:"Confirm delete",children:d.jsxs("p",{children:["This will permanently delete snapshot"," ",d.jsx(ot,{type:"snapshot",value:e.name,bold:!0}),".",d.jsx("br",{}),"This action cannot be undone, and can result in data loss."]}),confirmButtonLabel:C??"Delete snapshot",onConfirm:S},disabled:w||r||!!C,shiftClickEnabled:!0,showShiftClickHint:!0,children:d.jsx(O.Icon,{name:"delete"})},"delete")]})})},pc=({instance:t,snapshotNames:e,onStart:s,onFinish:a,onSuccess:g,onFailure:w})=>{const y=Ee(),[r,n]=Z.useState(!1),u=Be(),{canManageInstanceSnapshots:m}=Oe(),l=e.length,p=()=>{n(!0),s(),tc(t,e,y).then(C=>{const{fulfilledCount:S,rejectedCount:_}=So(C);S===l?g(d.jsxs(d.Fragment,{children:[d.jsx("b",{children:e.length})," ",St("snapshot",e.length)," deleted."]})):_===l?w("Snapshot bulk deletion failed",void 0,d.jsxs(d.Fragment,{children:[d.jsx("b",{children:l})," ",St("snapshot",l)," could not be deleted."]})):w("Snapshot bulk deletion partially failed",void 0,d.jsxs(d.Fragment,{children:[d.jsx("b",{children:S})," ",St("snapshot",S)," ","deleted.",d.jsx("br",{}),d.jsx("b",{children:_})," ",St("snapshot",_)," ","could not be deleted."]})),u.invalidateQueries({predicate:i=>i.queryKey[0]===Ce.instances}),n(!1),a()}).catch(C=>{w("Snapshot bulk deletion failed",C),n(!1)})};return d.jsx(ta,{confirmationButtonProps:{loading:r,disabled:r||!m(t),appearance:""},onDelete:p,entityType:"snapshot",entities:e,deletableEntities:e,disabledReason:m(t)?void 0:"You do not have permission to manage snapshots for this instance",buttonLabel:`Delete ${St("snapshot",e.length)}`})},mc=({instance:t,close:e,onSuccess:s,onFailure:a})=>{const g=Ee(),{project:w}=tt(),y=Be(),r=Ne({initialValues:at(t),validationSchema:Sr,onSubmit:u=>{const m=Ht(t,u);Ft(m,w??"").then(l=>{g.set(l.metadata.id,()=>{s("Configuration updated.")},p=>{a("Configuration update failed",new Error(p))},()=>{e(),y.invalidateQueries({queryKey:[Ce.instances]})})}).catch(l=>{a("Configuration update failed",l)})}}),n=u=>{u.key==="Escape"&&e()};return d.jsx(O.Modal,{close:e,className:"edit-snapshot-config",title:"Snapshot configuration",buttonRow:r.values.readOnly?d.jsx(O.Button,{className:"u-no-margin--bottom u-no-margin--right",onClick:e,children:"Close"}):d.jsxs(d.Fragment,{children:[d.jsx(O.Button,{appearance:"base",className:"u-no-margin--bottom",type:"button",onClick:e,children:"Cancel"}),d.jsx(O.ActionButton,{appearance:"positive",className:"u-no-margin--bottom",loading:r.isSubmitting,disabled:r.isSubmitting,onClick:()=>void r.submitForm(),children:"Save"})]}),onKeyDown:n,children:d.jsx(br,{formik:r})})},Ai=({instance:t,onSuccess:e,onFailure:s,isDisabled:a,className:g})=>{const{openPortal:w,closePortal:y,isOpen:r,Portal:n}=O.usePortal(),{canEditInstance:u}=Oe();return d.jsxs(d.Fragment,{children:[r&&d.jsx(n,{children:d.jsx("div",{className:"snapshot-list",children:d.jsx(mc,{close:y,instance:t,onSuccess:e,onFailure:s})})}),d.jsx(O.Button,{onClick:w,className:g,disabled:a||!u(t),title:u()?"":"You do not have permission to configure this instance",children:"See configuration"})]})},gc=150,vc=({close:t,instance:e,onSuccess:s})=>{const a=Ee(),g=O.useNotify(),w=O.useToastNotification(),y=Be(),r=Z.useState(null),n=Ne({initialValues:{name:"",stateful:!1,expirationDate:null,expirationTime:null},validateOnMount:!0,validationSchema:xr(e,r),onSubmit:(C,{resetForm:S})=>{g.clear();const _=C.expirationDate&&C.expirationTime?sr(mr(C.expirationDate,C.expirationTime)):Ts,i=d.jsx(ue,{instance:e});ec(e,C.name,_,C.stateful||!1).then(o=>{a.set(o.metadata.id,()=>{y.invalidateQueries({predicate:c=>c.queryKey[0]===Ce.instances}),s(d.jsxs(d.Fragment,{children:["Snapshot"," ",d.jsx(It,{name:bo(o.metadata),instance:e})," ","created for instance ",i,"."]})),S(),t()},c=>{w.failure(`Snapshot creation failed for instance ${e.name}`,new Error(c),i),n.setSubmitting(!1),t()})}).catch(o=>{g.failure("Snapshot creation failed",o,i),n.setSubmitting(!1),t()})}});let u=d.jsxs(d.Fragment,{children:[`To create a stateful snapshot, the instance needs `,"the ",d.jsx("code",{children:"migration.stateful"})," config set to true"]});const m=nc(e),l=e.status==="Running";m&&(u=`To create a stateful snapshot, the instance must be running`),m&&l&&(u="");const p=d.jsx(O.List,{inline:!0,items:[d.jsx(O.Input,{id:"stateful",name:"stateful",type:"checkbox",label:"Stateful",wrapperClassName:"u-inline-block",disabled:!m||!l,onChange:n.handleChange,onBlur:n.handleBlur,defaultChecked:n.values.stateful},"stateful"),...u?[d.jsx(O.Tooltip,{position:"btm-left",message:u,zIndex:gc,children:d.jsx(O.Icon,{name:"information"})},"stateful-info")]:[]]});return d.jsx(pr,{isEdit:!1,formik:n,close:t,additionalFormInput:p})},Pi=({instance:t,onSuccess:e,isDisabled:s,className:a})=>{const{openPortal:g,closePortal:w,isOpen:y,Portal:r}=O.usePortal(),{canManageInstanceSnapshots:n}=Oe();return d.jsxs(d.Fragment,{children:[y&&d.jsx(r,{children:d.jsx(vc,{close:w,instance:t,onSuccess:e})}),d.jsx(O.Button,{appearance:"positive",className:a,onClick:g,disabled:s||!n(t),title:n(t)?"":"You do not have permission to create snapshots for this instance",children:s?d.jsx(O.Tooltip,{message:`Snapshot creation has been disabled for instances in the project ${t.project}`,children:"Create snapshot"}):"Create snapshot"})]})},Sc=1250,Li=()=>window.innerWidth<=Sc,bc=t=>{var v,x;const{instance:e}=t,s=ar(),[a,g]=Z.useState(""),w=O.useNotify(),y=O.useToastNotification(),[r,n]=Z.useState([]),[u,m]=Z.useState([]),[l,p]=Z.useState(Li()),{project:C}=cr(),S=Qo(C),_=L=>{y.success(L)},i=(L,k,D)=>{w.failure(L,k,D)};Z.useEffect(()=>{var D;const L=new Set((D=e.snapshots)==null?void 0:D.map(B=>B.name)),k=r.filter(B=>L.has(B));k.length!==r.length&&n(k)},[e.snapshots]);const o=((v=e.snapshots)==null?void 0:v.filter(L=>!(a&&!L.name.toLowerCase().includes(a.toLowerCase()))))??[],c=e.snapshots&&e.snapshots.length>0,h=[{content:l?d.jsxs(d.Fragment,{children:["Name",d.jsx("br",{}),d.jsx("div",{className:"header-second-row",children:"Date created"})]}):"Name",sortKey:l?"created_at":"name",className:"name"},...l?[]:[{content:"Date created",sortKey:"created_at",className:"created"}],{content:"Expiry date",sortKey:"expires_at",className:"expiration"},{content:"Stateful",sortKey:"stateful",className:"stateful"},{"aria-label":"Actions",className:"actions"}],f=o.map(L=>{const k=d.jsx(fc,{instance:e,snapshot:L,onSuccess:_,onFailure:i});return{key:L.name,className:"u-row",name:L.name,columns:[{content:d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"u-truncate",title:`Snapshot ${L.name}`,children:d.jsx(Jo,{item:L})}),l&&d.jsx("div",{className:"u-text--muted",children:wt(L.created_at)})]}),role:"rowheader","aria-label":"Name",className:"name"},...l?[]:[{content:wt(L.created_at),role:"cell","aria-label":"Created at",className:"created"}],{content:wt(L.expires_at),role:"cell","aria-label":"Expires at",className:"expiration"},{content:L.stateful?"Yes":"No",role:"cell","aria-label":"Stateful",className:"stateful"},{content:k,role:"cell","aria-label":"Actions",className:"u-align--right actions"}],sortData:{name:L.name.toLowerCase(),created_at:L.created_at,expires_at:L.expires_at,stateful:L.stateful}}}),{rows:b,updateSort:E}=da({rows:f,defaultSort:"created_at",defaultSortDirection:"descending"}),I=()=>{p(Li())};return O.useListener(window,I,"resize",!0),d.jsxs("div",{className:"snapshot-list",children:[c&&d.jsx("div",{className:"upper-controls-bar",children:r.length===0?d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"search-box-wrapper",children:d.jsx(O.SearchBox,{name:"search-snapshot",className:"search-box margin-right",type:"text",onChange:L=>{g(L)},placeholder:"Search for snapshots",value:a,"aria-label":"Search for snapshots"})}),d.jsx(Ai,{instance:e,className:"u-no-margin--right",onFailure:i,onSuccess:_}),d.jsx(Pi,{instance:e,onSuccess:_,onFailure:i,className:"u-float-right",isDisabled:S})]}):d.jsx("div",{className:"p-panel__controls",children:d.jsx(pc,{instance:e,snapshotNames:r,onStart:()=>{m(r)},onFinish:()=>{m([])},onSuccess:_,onFailure:i})})}),d.jsx(ts,{}),c?d.jsx(d.Fragment,{children:d.jsx(Ws,{dependencies:[o,w.notification],tableId:"instance-snapshot-table",belowIds:["status-bar"],children:d.jsx(O.TablePagination,{data:b,id:"pagination",itemName:"snapshot",className:"u-no-margin--top","aria-label":"Table pagination control",description:r.length>0&&d.jsx(sa,{totalCount:((x=e.snapshots)==null?void 0:x.length)??0,itemName:"snapshot",parentName:"instance",selectedNames:r,setSelectedNames:n,filteredNames:o.map(L=>L.name)}),children:d.jsx(ea,{id:"instance-snapshot-table",headers:h,rows:b,sortable:!0,emptyStateMsg:"No snapshot found matching this search",itemName:"snapshot",parentName:"instance",selectedNames:r,setSelectedNames:n,disabledNames:u,filteredNames:o.map(L=>L.name),onUpdateSort:E,defaultSort:"created_at",defaultSortDirection:"descending"})})})}):d.jsxs(O.EmptyState,{className:"empty-state",image:d.jsx(O.Icon,{name:"snapshot",className:"empty-state-icon"}),title:"No snapshots found",children:[d.jsx("p",{children:C&&S?d.jsxs(d.Fragment,{children:["Snapshots are disabled for project"," ",d.jsx(je,{type:"project",value:C.name,to:`/ui/project/${C.name}/configuration`}),"."]}):"There are no snapshots of this instance."}),d.jsx("p",{children:d.jsxs("a",{href:`${s}/howto/storage_backup_volume/#storage-backup-snapshots`,target:"_blank",rel:"noopener noreferrer",children:["Learn more about snapshots",d.jsx(O.Icon,{className:"external-link-icon",name:"external-link"})]})}),d.jsx(Ai,{instance:e,onFailure:i,onSuccess:_,isDisabled:S}),d.jsx(Pi,{instance:e,onSuccess:_,onFailure:i,className:"empty-state-button",isDisabled:S})]})]})};var R={SPICE_MAGIC:"REDQ",SPICE_VERSION_MAJOR:2,SPICE_VERSION_MINOR:2,SPICE_CONNECT_TIMEOUT:30*1e3,SPICE_COMMON_CAP_PROTOCOL_AUTH_SELECTION:0,SPICE_COMMON_CAP_AUTH_SPICE:1,SPICE_COMMON_CAP_MINI_HEADER:3,SPICE_TICKET_KEY_PAIR_LENGTH:1024,SPICE_TICKET_PUBKEY_BYTES:1024/8+34,SPICE_LINK_ERR_OK:0,SPICE_LINK_ERR_PERMISSION_DENIED:7,SPICE_MSG_SET_ACK:3,SPICE_MSG_PING:4,SPICE_MSG_NOTIFY:7,SPICE_MSG_MAIN_MIGRATE_BEGIN:101,SPICE_MSG_MAIN_MIGRATE_CANCEL:102,SPICE_MSG_MAIN_INIT:103,SPICE_MSG_MAIN_CHANNELS_LIST:104,SPICE_MSG_MAIN_MOUSE_MODE:105,SPICE_MSG_MAIN_MULTI_MEDIA_TIME:106,SPICE_MSG_MAIN_AGENT_CONNECTED:107,SPICE_MSG_MAIN_AGENT_DISCONNECTED:108,SPICE_MSG_MAIN_AGENT_DATA:109,SPICE_MSG_MAIN_AGENT_TOKEN:110,SPICE_MSG_MAIN_MIGRATE_SWITCH_HOST:111,SPICE_MSG_MAIN_MIGRATE_END:112,SPICE_MSG_MAIN_NAME:113,SPICE_MSG_MAIN_UUID:114,SPICE_MSG_MAIN_AGENT_CONNECTED_TOKENS:115,SPICE_MSG_MAIN_MIGRATE_BEGIN_SEAMLESS:116,SPICE_MSG_MAIN_MIGRATE_DST_SEAMLESS_ACK:117,SPICE_MSG_MAIN_MIGRATE_DST_SEAMLESS_NACK:118,SPICE_MSGC_ACK_SYNC:1,SPICE_MSGC_ACK:2,SPICE_MSGC_PONG:3,SPICE_MSGC_MAIN_ATTACH_CHANNELS:104,SPICE_MSGC_MAIN_MOUSE_MODE_REQUEST:105,SPICE_MSGC_MAIN_AGENT_START:106,SPICE_MSGC_MAIN_AGENT_DATA:107,SPICE_MSG_DISPLAY_MODE:101,SPICE_MSG_DISPLAY_MARK:102,SPICE_MSG_DISPLAY_RESET:103,SPICE_MSG_DISPLAY_COPY_BITS:104,SPICE_MSG_DISPLAY_INVAL_LIST:105,SPICE_MSG_DISPLAY_INVAL_ALL_PIXMAPS:106,SPICE_MSG_DISPLAY_INVAL_PALETTE:107,SPICE_MSG_DISPLAY_INVAL_ALL_PALETTES:108,SPICE_MSG_DISPLAY_STREAM_CREATE:122,SPICE_MSG_DISPLAY_STREAM_DATA:123,SPICE_MSG_DISPLAY_STREAM_CLIP:124,SPICE_MSG_DISPLAY_STREAM_DESTROY:125,SPICE_MSG_DISPLAY_STREAM_DESTROY_ALL:126,SPICE_MSG_DISPLAY_DRAW_FILL:302,SPICE_MSG_DISPLAY_DRAW_OPAQUE:303,SPICE_MSG_DISPLAY_DRAW_COPY:304,SPICE_MSG_DISPLAY_DRAW_BLEND:305,SPICE_MSG_DISPLAY_DRAW_BLACKNESS:306,SPICE_MSG_DISPLAY_DRAW_WHITENESS:307,SPICE_MSG_DISPLAY_DRAW_INVERS:308,SPICE_MSG_DISPLAY_DRAW_ROP3:309,SPICE_MSG_DISPLAY_DRAW_STROKE:310,SPICE_MSG_DISPLAY_DRAW_TRANSPARENT:312,SPICE_MSG_DISPLAY_DRAW_ALPHA_BLEND:313,SPICE_MSG_DISPLAY_SURFACE_CREATE:314,SPICE_MSG_DISPLAY_SURFACE_DESTROY:315,SPICE_MSG_DISPLAY_STREAM_DATA_SIZED:316,SPICE_MSG_DISPLAY_MONITORS_CONFIG:317,SPICE_MSG_DISPLAY_DRAW_COMPOSITE:318,SPICE_MSG_DISPLAY_STREAM_ACTIVATE_REPORT:319,SPICE_MSGC_DISPLAY_INIT:101,SPICE_MSGC_DISPLAY_STREAM_REPORT:102,SPICE_MSG_INPUTS_INIT:101,SPICE_MSG_INPUTS_KEY_MODIFIERS:102,SPICE_MSG_INPUTS_MOUSE_MOTION_ACK:111,SPICE_MSGC_INPUTS_KEY_DOWN:101,SPICE_MSGC_INPUTS_KEY_UP:102,SPICE_MSGC_INPUTS_MOUSE_MOTION:111,SPICE_MSGC_INPUTS_MOUSE_POSITION:112,SPICE_MSGC_INPUTS_MOUSE_PRESS:113,SPICE_MSGC_INPUTS_MOUSE_RELEASE:114,SPICE_MSG_CURSOR_INIT:101,SPICE_MSG_CURSOR_RESET:102,SPICE_MSG_CURSOR_SET:103,SPICE_MSG_CURSOR_MOVE:104,SPICE_MSG_CURSOR_HIDE:105,SPICE_MSG_CURSOR_TRAIL:106,SPICE_MSG_CURSOR_INVAL_ONE:107,SPICE_MSG_CURSOR_INVAL_ALL:108,SPICE_MSG_PLAYBACK_DATA:101,SPICE_MSG_PLAYBACK_MODE:102,SPICE_MSG_PLAYBACK_START:103,SPICE_MSG_PLAYBACK_STOP:104,SPICE_MSG_PLAYBACK_VOLUME:105,SPICE_MSG_PLAYBACK_MUTE:106,SPICE_MSG_PLAYBACK_LATENCY:107,SPICE_MSG_SPICEVMC_DATA:101,SPICE_MSG_PORT_INIT:201,SPICE_MSG_PORT_EVENT:202,SPICE_PLAYBACK_CAP_OPUS:3,SPICE_MAIN_CAP_AGENT_CONNECTED_TOKENS:2,SPICE_DISPLAY_CAP_SIZED_STREAM:0,SPICE_DISPLAY_CAP_STREAM_REPORT:4,SPICE_DISPLAY_CAP_MULTI_CODEC:8,SPICE_DISPLAY_CAP_CODEC_MJPEG:9,SPICE_DISPLAY_CAP_CODEC_VP8:10,SPICE_AUDIO_DATA_MODE_OPUS:3,SPICE_AUDIO_FMT_S16:1,SPICE_CHANNEL_MAIN:1,SPICE_CHANNEL_DISPLAY:2,SPICE_CHANNEL_INPUTS:3,SPICE_CHANNEL_CURSOR:4,SPICE_CHANNEL_PLAYBACK:5,SPICE_CHANNEL_RECORD:6,SPICE_CHANNEL_TUNNEL:7,SPICE_CHANNEL_SMARTCARD:8,SPICE_CHANNEL_USBREDIR:9,SPICE_CHANNEL_PORT:10,SPICE_CHANNEL_WEBDAV:11,SPICE_SURFACE_FLAGS_PRIMARY:1,SPICE_NOTIFY_SEVERITY_WARN:1,SPICE_NOTIFY_SEVERITY_ERROR:2,SPICE_MOUSE_MODE_SERVER:1,SPICE_MOUSE_MODE_CLIENT:2,SPICE_CLIP_TYPE_NONE:0,SPICE_CLIP_TYPE_RECTS:1,SPICE_IMAGE_TYPE_BITMAP:0,SPICE_IMAGE_TYPE_QUIC:1,SPICE_IMAGE_TYPE_LZ_RGB:101,SPICE_IMAGE_TYPE_FROM_CACHE:103,SPICE_IMAGE_TYPE_SURFACE:104,SPICE_IMAGE_TYPE_JPEG:105,SPICE_IMAGE_TYPE_FROM_CACHE_LOSSLESS:106,SPICE_IMAGE_TYPE_JPEG_ALPHA:108,SPICE_IMAGE_FLAGS_CACHE_ME:1,SPICE_IMAGE_FLAGS_HIGH_BITS_SET:2,SPICE_BITMAP_FLAGS_PAL_FROM_CACHE:2,SPICE_BITMAP_FLAGS_TOP_DOWN:4,SPICE_BITMAP_FMT_32BIT:8,SPICE_BITMAP_FMT_RGBA:9,SPICE_CURSOR_FLAGS_NONE:1,SPICE_MOUSE_BUTTON_MASK_LEFT:1,SPICE_MOUSE_BUTTON_LEFT:1,SPICE_MOUSE_BUTTON_UP:4,SPICE_MOUSE_BUTTON_DOWN:5,SPICE_BRUSH_TYPE_SOLID:1,SPICE_BRUSH_TYPE_PATTERN:2,SPICE_SURFACE_FMT_32_xRGB:32,SPICE_SURFACE_FMT_32_ARGB:96,SPICE_ROPD_OP_PUT:8,LZ_IMAGE_TYPE_RGB32:8,LZ_IMAGE_TYPE_RGBA:9,LZ_IMAGE_TYPE_XXXA:10,SPICE_INPUT_MOTION_ACK_BUNCH:4,SPICE_CURSOR_TYPE_ALPHA:0,SPICE_VIDEO_CODEC_TYPE_MJPEG:1,SPICE_VIDEO_CODEC_TYPE_VP8:2,VD_AGENT_PROTOCOL:1,VD_AGENT_MAX_DATA_SIZE:2048,VD_AGENT_MONITORS_CONFIG:2,VD_AGENT_ANNOUNCE_CAPABILITIES:6,VD_AGENT_FILE_XFER_START:10,VD_AGENT_FILE_XFER_STATUS:11,VD_AGENT_FILE_XFER_DATA:12,VD_AGENT_CAP_MOUSE_STATE:0,VD_AGENT_CAP_MONITORS_CONFIG:1,VD_AGENT_CAP_REPLY:2,VD_AGENT_FILE_XFER_STATUS_CAN_SEND_DATA:0,VD_AGENT_FILE_XFER_STATUS_CANCELLED:1,VD_AGENT_FILE_XFER_STATUS_ERROR:2,VD_AGENT_FILE_XFER_STATUS_SUCCESS:3};function ee(t,e,s){e!==void 0?s!==void 0?this.u8=new Uint8Array(t,e,s):this.u8=new Uint8Array(t,e):this.u8=new Uint8Array(t)}ee.prototype={getUint8:function(t){return this.u8[t]},getUint16:function(t,e){var s=1,a=0;return e&&(s=0,a=1),this.u8[t+a]<<8|this.u8[t+s]},getUint32:function(t,e){var s=2,a=0;return e&&(s=0,a=2),this.getUint16(t+a,e)<<16|this.getUint16(t+s,e)},getUint64:function(t,e){var s=4,a=0;return e&&(s=0,a=4),this.getUint32(t+a,e)<<32|this.getUint32(t+s,e)},setUint8:function(t,e){this.u8[t]=e&255},setUint16:function(t,e,s){var a=1,g=0;s&&(a=0,g=1),this.u8[t+g]=(e&65535)>>8,this.u8[t+a]=e&255},setUint32:function(t,e,s){var a=2,g=0;s&&(a=0,g=2),this.setUint16(t+g,(e&4294967295)>>16,s),this.setUint16(t+a,e&65535,s)},setUint64:function(t,e,s){var a=4,g=0;s&&(a=0,g=4),this.setUint32(t+g,(e&18446744073709552e3)>>32,s),this.setUint32(t+a,e&4294967295,s)}};var qe;function te(t,e,s){t!=null&&(typeof t=="number"?this.fromNumber(t,e,s):e==null&&typeof t!="string"?this.fromString(t,256):this.fromString(t,e))}function Fe(){return new te(null)}function Cc(t,e,s,a,g,w){for(;--w>=0;){var y=e*this[t++]+s[a]+g;g=Math.floor(y/67108864),s[a++]=y&67108863}return g}function Ec(t,e,s,a,g,w){for(var y=e&32767,r=e>>15;--w>=0;){var n=this[t]&32767,u=this[t++]>>15,m=r*n+u*y;n=y*n+((m&32767)<<15)+s[a]+(g&1073741823),g=(n>>>30)+(m>>>15)+r*u+(g>>>30),s[a++]=n&1073741823}return g}function yc(t,e,s,a,g,w){for(var y=e&16383,r=e>>14;--w>=0;){var n=this[t]&16383,u=this[t++]>>14,m=r*n+u*y;n=y*n+((m&16383)<<14)+s[a]+g,g=(n>>28)+(m>>14)+r*u,s[a++]=n&268435455}return g}navigator.appName=="Microsoft Internet Explorer"?(te.prototype.am=Ec,qe=30):navigator.appName!="Netscape"?(te.prototype.am=Cc,qe=26):(te.prototype.am=yc,qe=28);te.prototype.DB=qe;te.prototype.DM=(1<<qe)-1;te.prototype.DV=1<<qe;var $s=52;te.prototype.FV=Math.pow(2,$s);te.prototype.F1=$s-qe;te.prototype.F2=2*qe-$s;var wc="0123456789abcdefghijklmnopqrstuvwxyz",rs=new Array,lt,Te;lt=48;for(Te=0;Te<=9;++Te)rs[lt++]=Te;lt=97;for(Te=10;Te<36;++Te)rs[lt++]=Te;lt=65;for(Te=10;Te<36;++Te)rs[lt++]=Te;function Di(t){return wc.charAt(t)}function xc(t,e){var s=rs[t.charCodeAt(e)];return s??-1}function Ic(t){for(var e=this.t-1;e>=0;--e)t[e]=this[e];t.t=this.t,t.s=this.s}function Ac(t){this.t=1,this.s=t<0?-1:0,t>0?this[0]=t:t<-1?this[0]=t+DV:this.t=0}function Ir(t){var e=Fe();return e.fromInt(t),e}function Pc(t,e){var s;if(e==16)s=4;else if(e==8)s=3;else if(e==256)s=8;else if(e==2)s=1;else if(e==32)s=5;else if(e==4)s=2;else{this.fromRadix(t,e);return}this.t=0,this.s=0;for(var a=t.length,g=!1,w=0;--a>=0;){var y=s==8?t[a]&255:xc(t,a);if(y<0){t.charAt(a)=="-"&&(g=!0);continue}g=!1,w==0?this[this.t++]=y:w+s>this.DB?(this[this.t-1]|=(y&(1<<this.DB-w)-1)<<w,this[this.t++]=y>>this.DB-w):this[this.t-1]|=y<<w,w+=s,w>=this.DB&&(w-=this.DB)}s==8&&(t[0]&128)!=0&&(this.s=-1,w>0&&(this[this.t-1]|=(1<<this.DB-w)-1<<w)),this.clamp(),g&&te.ZERO.subTo(this,this)}function Lc(){for(var t=this.s&this.DM;this.t>0&&this[this.t-1]==t;)--this.t}function Dc(t){if(this.s<0)return"-"+this.negate().toString(t);var e;if(t==16)e=4;else if(t==8)e=3;else if(t==2)e=1;else if(t==32)e=5;else if(t==4)e=2;else return this.toRadix(t);var s=(1<<e)-1,a,g=!1,w="",y=this.t,r=this.DB-y*this.DB%e;if(y-- >0)for(r<this.DB&&(a=this[y]>>r)>0&&(g=!0,w=Di(a));y>=0;)r<e?(a=(this[y]&(1<<r)-1)<<e-r,a|=this[--y]>>(r+=this.DB-e)):(a=this[y]>>(r-=e)&s,r<=0&&(r+=this.DB,--y)),a>0&&(g=!0),g&&(w+=Di(a));return g?w:"0"}function Mc(){var t=Fe();return te.ZERO.subTo(this,t),t}function Tc(){return this.s<0?this.negate():this}function Rc(t){var e=this.s-t.s;if(e!=0)return e;var s=this.t;if(e=s-t.t,e!=0)return e;for(;--s>=0;)if((e=this[s]-t[s])!=0)return e;return 0}function Vs(t){var e=1,s;return(s=t>>>16)!=0&&(t=s,e+=16),(s=t>>8)!=0&&(t=s,e+=8),(s=t>>4)!=0&&(t=s,e+=4),(s=t>>2)!=0&&(t=s,e+=2),(s=t>>1)!=0&&(t=s,e+=1),e}function kc(){return this.t<=0?0:this.DB*(this.t-1)+Vs(this[this.t-1]^this.s&this.DM)}function Bc(t,e){var s;for(s=this.t-1;s>=0;--s)e[s+t]=this[s];for(s=t-1;s>=0;--s)e[s]=0;e.t=this.t+t,e.s=this.s}function Oc(t,e){for(var s=t;s<this.t;++s)e[s-t]=this[s];e.t=Math.max(this.t-t,0),e.s=this.s}function Nc(t,e){var s=t%this.DB,a=this.DB-s,g=(1<<a)-1,w=Math.floor(t/this.DB),y=this.s<<s&this.DM,r;for(r=this.t-1;r>=0;--r)e[r+w+1]=this[r]>>a|y,y=(this[r]&g)<<s;for(r=w-1;r>=0;--r)e[r]=0;e[w]=y,e.t=this.t+w+1,e.s=this.s,e.clamp()}function Uc(t,e){e.s=this.s;var s=Math.floor(t/this.DB);if(s>=this.t){e.t=0;return}var a=t%this.DB,g=this.DB-a,w=(1<<a)-1;e[0]=this[s]>>a;for(var y=s+1;y<this.t;++y)e[y-s-1]|=(this[y]&w)<<g,e[y-s]=this[y]>>a;a>0&&(e[this.t-s-1]|=(this.s&w)<<g),e.t=this.t-s,e.clamp()}function jc(t,e){for(var s=0,a=0,g=Math.min(t.t,this.t);s<g;)a+=this[s]-t[s],e[s++]=a&this.DM,a>>=this.DB;if(t.t<this.t){for(a-=t.s;s<this.t;)a+=this[s],e[s++]=a&this.DM,a>>=this.DB;a+=this.s}else{for(a+=this.s;s<t.t;)a-=t[s],e[s++]=a&this.DM,a>>=this.DB;a-=t.s}e.s=a<0?-1:0,a<-1?e[s++]=this.DV+a:a>0&&(e[s++]=a),e.t=s,e.clamp()}function Fc(t,e){var s=this.abs(),a=t.abs(),g=s.t;for(e.t=g+a.t;--g>=0;)e[g]=0;for(g=0;g<a.t;++g)e[g+s.t]=s.am(0,a[g],e,g,0,s.t);e.s=0,e.clamp(),this.s!=t.s&&te.ZERO.subTo(e,e)}function Hc(t){for(var e=this.abs(),s=t.t=2*e.t;--s>=0;)t[s]=0;for(s=0;s<e.t-1;++s){var a=e.am(s,e[s],t,2*s,0,1);(t[s+e.t]+=e.am(s+1,2*e[s],t,2*s+1,a,e.t-s-1))>=e.DV&&(t[s+e.t]-=e.DV,t[s+e.t+1]=1)}t.t>0&&(t[t.t-1]+=e.am(s,e[s],t,2*s,0,1)),t.s=0,t.clamp()}function Kc(t,e,s){var a=t.abs();if(!(a.t<=0)){var g=this.abs();if(g.t<a.t){e!=null&&e.fromInt(0),s!=null&&this.copyTo(s);return}s==null&&(s=Fe());var w=Fe(),y=this.s,r=t.s,n=this.DB-Vs(a[a.t-1]);n>0?(a.lShiftTo(n,w),g.lShiftTo(n,s)):(a.copyTo(w),g.copyTo(s));var u=w.t,m=w[u-1];if(m!=0){var l=m*(1<<this.F1)+(u>1?w[u-2]>>this.F2:0),p=this.FV/l,C=(1<<this.F1)/l,S=1<<this.F2,_=s.t,i=_-u,o=e??Fe();for(w.dlShiftTo(i,o),s.compareTo(o)>=0&&(s[s.t++]=1,s.subTo(o,s)),te.ONE.dlShiftTo(u,o),o.subTo(w,w);w.t<u;)w[w.t++]=0;for(;--i>=0;){var c=s[--_]==m?this.DM:Math.floor(s[_]*p+(s[_-1]+S)*C);if((s[_]+=w.am(0,c,s,i,0,u))<c)for(w.dlShiftTo(i,o),s.subTo(o,s);s[_]<--c;)s.subTo(o,s)}e!=null&&(s.drShiftTo(u,e),y!=r&&te.ZERO.subTo(e,e)),s.t=u,s.clamp(),n>0&&s.rShiftTo(n,s),y<0&&te.ZERO.subTo(s,s)}}}function Gc(t){var e=Fe();return this.abs().divRemTo(t,null,e),this.s<0&&e.compareTo(te.ZERO)>0&&t.subTo(e,e),e}function ut(t){this.m=t}function Yc(t){return t.s<0||t.compareTo(this.m)>=0?t.mod(this.m):t}function zc(t){return t}function Wc(t){t.divRemTo(this.m,null,t)}function $c(t,e,s){t.multiplyTo(e,s),this.reduce(s)}function Vc(t,e){t.squareTo(e),this.reduce(e)}ut.prototype.convert=Yc;ut.prototype.revert=zc;ut.prototype.reduce=Wc;ut.prototype.mulTo=$c;ut.prototype.sqrTo=Vc;function qc(){if(this.t<1)return 0;var t=this[0];if((t&1)==0)return 0;var e=t&3;return e=e*(2-(t&15)*e)&15,e=e*(2-(t&255)*e)&255,e=e*(2-((t&65535)*e&65535))&65535,e=e*(2-t*e%this.DV)%this.DV,e>0?this.DV-e:-e}function dt(t){this.m=t,this.mp=t.invDigit(),this.mpl=this.mp&32767,this.mph=this.mp>>15,this.um=(1<<t.DB-15)-1,this.mt2=2*t.t}function Xc(t){var e=Fe();return t.abs().dlShiftTo(this.m.t,e),e.divRemTo(this.m,null,e),t.s<0&&e.compareTo(te.ZERO)>0&&this.m.subTo(e,e),e}function Qc(t){var e=Fe();return t.copyTo(e),this.reduce(e),e}function Zc(t){for(;t.t<=this.mt2;)t[t.t++]=0;for(var e=0;e<this.m.t;++e){var s=t[e]&32767,a=s*this.mpl+((s*this.mph+(t[e]>>15)*this.mpl&this.um)<<15)&t.DM;for(s=e+this.m.t,t[s]+=this.m.am(0,a,t,e,0,this.m.t);t[s]>=t.DV;)t[s]-=t.DV,t[++s]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)}function Jc(t,e){t.squareTo(e),this.reduce(e)}function eh(t,e,s){t.multiplyTo(e,s),this.reduce(s)}dt.prototype.convert=Xc;dt.prototype.revert=Qc;dt.prototype.reduce=Zc;dt.prototype.mulTo=eh;dt.prototype.sqrTo=Jc;function th(){return(this.t>0?this[0]&1:this.s)==0}function sh(t,e){if(t>4294967295||t<1)return te.ONE;var s=Fe(),a=Fe(),g=e.convert(this),w=Vs(t)-1;for(g.copyTo(s);--w>=0;)if(e.sqrTo(s,a),(t&1<<w)>0)e.mulTo(a,g,s);else{var y=s;s=a,a=y}return e.revert(s)}function ih(t,e){var s;return t<256||e.isEven()?s=new ut(e):s=new dt(e),this.exp(t,s)}te.prototype.copyTo=Ic;te.prototype.fromInt=Ac;te.prototype.fromString=Pc;te.prototype.clamp=Lc;te.prototype.dlShiftTo=Bc;te.prototype.drShiftTo=Oc;te.prototype.lShiftTo=Nc;te.prototype.rShiftTo=Uc;te.prototype.subTo=jc;te.prototype.multiplyTo=Fc;te.prototype.squareTo=Hc;te.prototype.divRemTo=Kc;te.prototype.invDigit=qc;te.prototype.isEven=th;te.prototype.exp=sh;te.prototype.toString=Dc;te.prototype.negate=Mc;te.prototype.abs=Tc;te.prototype.compareTo=Rc;te.prototype.bitLength=kc;te.prototype.mod=Gc;te.prototype.modPowInt=ih;te.ZERO=Ir(0);te.ONE=Ir(1);function qs(){this.i=0,this.j=0,this.S=new Array}function rh(t){var e,s,a;for(e=0;e<256;++e)this.S[e]=e;for(s=0,e=0;e<256;++e)s=s+this.S[e]+t[e%t.length]&255,a=this.S[e],this.S[e]=this.S[s],this.S[s]=a;this.i=0,this.j=0}function nh(){var t;return this.i=this.i+1&255,this.j=this.j+this.S[this.i]&255,t=this.S[this.i],this.S[this.i]=this.S[this.j],this.S[this.j]=t,this.S[t+this.S[this.i]&255]}qs.prototype.init=rh;qs.prototype.next=nh;function oh(){return new qs}var Rs=256,Bt,Me,Se;function ah(t){Me[Se++]^=t&255,Me[Se++]^=t>>8&255,Me[Se++]^=t>>16&255,Me[Se++]^=t>>24&255,Se>=Rs&&(Se-=Rs)}function Ar(){ah(new Date().getTime())}if(Me==null){Me=new Array,Se=0;var Je;if(navigator.appName=="Netscape"&&navigator.appVersion<"5"&&window.crypto){var Mi=window.crypto.random(32);for(Je=0;Je<Mi.length;++Je)Me[Se++]=Mi.charCodeAt(Je)&255}for(;Se<Rs;)Je=Math.floor(65536*Math.random()),Me[Se++]=Je>>>8,Me[Se++]=Je&255;Se=0,Ar()}function ch(){if(Bt==null){for(Ar(),Bt=oh(),Bt.init(Me),Se=0;Se<Me.length;++Se)Me[Se]=0;Se=0}return Bt.next()}function hh(t){var e;for(e=0;e<t.length;++e)t[e]=ch()}function Xs(){}Xs.prototype.nextBytes=hh;function lh(t,e){return new te(t,e)}function uh(t,e){if(e<t.length+11)return alert("Message too long for RSA"),null;for(var s=new Array,a=t.length-1;a>=0&&e>0;){var g=t.charCodeAt(a--);g<128?s[--e]=g:g>127&&g<2048?(s[--e]=g&63|128,s[--e]=g>>6|192):(s[--e]=g&63|128,s[--e]=g>>6&63|128,s[--e]=g>>12|224)}s[--e]=0;for(var w=new Xs,y=new Array;e>2;){for(y[0]=0;y[0]==0;)w.nextBytes(y);s[--e]=y[0]}return s[--e]=2,s[--e]=0,new te(s)}function ns(){this.n=null,this.e=0,this.d=null,this.p=null,this.q=null,this.dmp1=null,this.dmq1=null,this.coeff=null}function dh(t,e){t!=null&&e!=null&&t.length>0&&e.length>0?(this.n=lh(t,16),this.e=parseInt(e,16)):alert("Invalid RSA public key")}function _h(t){return t.modPowInt(this.e,this.n)}function fh(t){var e=uh(t,this.n.bitLength()+7>>3);if(e==null)return null;var s=this.doPublic(e);if(s==null)return null;var a=s.toString(16);return(a.length&1)==0?a:"0"+a}ns.prototype.doPublic=_h;ns.prototype.setPublic=dh;ns.prototype.encrypt=fh;var Ti=0;function ph(t){return mh(Qs(gh(t)))}function Qs(t){return Sh(bh(vh(t),t.length*8))}function mh(t){for(var e=Ti?"0123456789ABCDEF":"0123456789abcdef",s="",a,g=0;g<t.length;g++)a=t.charCodeAt(g),s+=e.charAt(a>>>4&15)+e.charAt(a&15);return s}function gh(t){for(var e="",s=-1,a,g;++s<t.length;)a=t.charCodeAt(s),g=s+1<t.length?t.charCodeAt(s+1):0,55296<=a&&a<=56319&&56320<=g&&g<=57343&&(a=65536+((a&1023)<<10)+(g&1023),s++),a<=127?e+=String.fromCharCode(a):a<=2047?e+=String.fromCharCode(192|a>>>6&31,128|a&63):a<=65535?e+=String.fromCharCode(224|a>>>12&15,128|a>>>6&63,128|a&63):a<=2097151&&(e+=String.fromCharCode(240|a>>>18&7,128|a>>>12&63,128|a>>>6&63,128|a&63));return e}function vh(t){for(var e=Array(t.length>>2),s=0;s<e.length;s++)e[s]=0;for(var s=0;s<t.length*8;s+=8)e[s>>5]|=(t.charCodeAt(s/8)&255)<<24-s%32;return e}function Sh(t){for(var e="",s=0;s<t.length*32;s+=8)e+=String.fromCharCode(t[s>>5]>>>24-s%32&255);return e}function bh(t,e){t[e>>5]|=128<<24-e%32,t[(e+64>>9<<4)+15]=e;for(var s=Array(80),a=1732584193,g=-271733879,w=-1732584194,y=271733878,r=-1009589776,n=0;n<t.length;n+=16){for(var u=a,m=g,l=w,p=y,C=r,S=0;S<80;S++){S<16?s[S]=t[n+S]:s[S]=Is(s[S-3]^s[S-8]^s[S-14]^s[S-16],1);var _=Ke(Ke(Is(a,5),Ch(S,g,w,y)),Ke(Ke(r,s[S]),Eh(S)));r=y,y=w,w=Is(g,30),g=a,a=_}a=Ke(a,u),g=Ke(g,m),w=Ke(w,l),y=Ke(y,p),r=Ke(r,C)}return Array(a,g,w,y,r)}function Ch(t,e,s,a){return t<20?e&s|~e&a:t<40?e^s^a:t<60?e&s|e&a|s&a:e^s^a}function Eh(t){return t<20?1518500249:t<40?1859775393:t<60?-1894007588:-899497514}function Ke(t,e){var s=(t&65535)+(e&65535),a=(t>>16)+(e>>16)+(s>>16);return a<<16|s&65535}function Is(t,e){return t<<e|t>>>32-e}var As=20;function Ri(t,e){var s,a,g;for(s=0,g=0;g<t.length;s++){var w=new String;for(a=0;a<e.length;a++)w+=String.fromCharCode(e[a]);w+=String.fromCharCode(s>>24&255),w+=String.fromCharCode(s>>16&255),w+=String.fromCharCode(s>>8&255),w+=String.fromCharCode(s&255);var y=Qs(w);for(a=0;a<y.length&&g<t.length;a++,g++)t[g]=y.charCodeAt(a)}}function yh(t,e,s){var a=new Array(As),g=new Xs;g.nextBytes(a);var w=t-1-a.length,y=new Array(w),r=w-e.length-1,n;if(s===void 0&&(s=""),r<As)return console.log("Error - data too large for key size."),null;for(n=0;n<r;n++)y[n]=0;var u=Qs(s);for(n=0;n<u.length;n++)y[n]=u.charCodeAt(n);for(y[r]=1,n=0;n<e.length;n++)y[n+r+1]=e.charCodeAt(n);var m=new Array(w);if(Ri(m,a)<0)return null;for(n=0;n<m.length;n++)y[n]^=m[n];var l=Array(As);if(Ri(l,y)<0)return null;for(n=0;n<l.length;n++)a[n]^=l[n];var p=new String;for(p+="\0",n=0;n<a.length;n++)p+=String.fromCharCode(a[n]);for(n=0;n<y.length;n++)p+=String.fromCharCode(y[n]);return p}function jt(t,e){var s=t[e++];if(s>128){if(s!=129)return console.log("Error: we lazily don't support keys bigger than 255 bytes. It'd be easy to fix."),null;s=t[e++]}return[e,s]}function Ps(t,e){var s;return e=e||0,t[e++]!=48?(console.log("Error: public key should start with a sequence flag."),null):(s=jt(t,e),s||null)}function wh(t,e){var s=new Uint8Array(t),a,g,w,y,r;if(g=Ps(s,e),!g||(e=g[0],g=Ps(s,e),!g))return null;if(e=g[0]+g[1],s[e++]!=3)return console.log("Error: expecting bit string next."),null;if(a=jt(s,e),!a)return null;if(e=a[0],s[e]!=0&&s[e+1]!=48)return console.log("Error: unexpected values in bit string."),null;if(g=Ps(s,e+1),!g)return null;if(e=g[0],s[e++]!=2)return console.log("Error: expecting integer n next."),null;if(a=jt(s,e),!a)return null;for(e=a[0],w=new Array(a[1]),y=0;y<a[1];y++)w[y]=s[e+y];if(r=new ns,r.n=new te(w),e+=a[1],s[e++]!=2)return console.log("Error: expecting integer e next."),null;if(a=jt(s,e),!a)return null;for(e=a[0],r.e=s[e++],y=1;y<a[1];y++)r.e<<=8,r.e|=s[e++];return r}function xh(t,e){var s,a=[],g=yh(t.n.bitLength()+7>>3,e);if(!g)return null;var w=new Array(g.length);for(s=0;s<g.length;s++)w[s]=g.charCodeAt(s);var y=new te(w),r=t.doPublic(y),n=r.toString(16);for((n.length&1)!=0&&(n="0"+n),s=0;s<n.length;s+=2)a[s/2]=parseInt(n.substring(s,s+2),16);return a}var $e,be={QUIC_IMAGE_TYPE_INVALID:0,QUIC_IMAGE_TYPE_GRAY:1,QUIC_IMAGE_TYPE_RGB16:2,QUIC_IMAGE_TYPE_RGB24:3,QUIC_IMAGE_TYPE_RGB32:4,QUIC_IMAGE_TYPE_RGBA:5},Ih=3,Ah=6,Ph=2048,ki=!0,Bi=26,Pr=Ih,Qe=Ah,ct=Ph,Lh={nGRcodewords:[0,0,0,0,0,0,0,0],notGRcwlen:[0,0,0,0,0,0,0,0],notGRprefixmask:[0,0,0,0,0,0,0,0],notGRsuffixlen:[0,0,0,0,0,0,0,0],xlatU2L:[0,0,0,0,0,0,0,0],xlatL2U:[0,0,0,0,0,0,0,0]},_e={nGRcodewords:[0,0,0,0,0,0,0,0],notGRcwlen:[0,0,0,0,0,0,0,0],notGRprefixmask:[0,0,0,0,0,0,0,0],notGRsuffixlen:[0,0,0,0,0,0,0,0],xlatU2L:[0,0,0,0,0,0,0,0],xlatL2U:[0,0,0,0,0,0,0,0]},Ie=[0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535,131071,262143,524287,1048575,2097151,4194303,8388607,16777215,33554431,67108863,134217727,268435455,536870911,1073741823,2147483647,4294967295],Lr=[],Dh=[[550,900,800,700,500,350,300,200,180,180,160],[110,550,900,800,550,400,350,250,140,160,140],[100,120,550,900,700,500,400,300,220,250,160]],ks=[0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,5,5,6,6,7,7,8,9,10,11,12,13,14,15],Ot=[8,7,6,6,5,5,5,5,4,4,4,4,4,4,4,4,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],Mh=[46495042,893548311,794435923,2453991765,2077388039,894197842,1462934312,697534094,1826128012,343623392,2581292719,3811265708,459739748,2638427270,1654964626,101227083,2654850628,3668700691,572794346,2758751005,3445133904,2344099199,3367450297,898927923,3618406352,1606297603,754696453,20823118,2050458127,972590750,3990194068,3305596553,4239238564,1690498157,3015324227,2306127097,1510321853,548392192,971157512,2292288069,1611390505,4086766286,4084927083,1883326811,1891043243,113180603,1107690783,3778825955,3248980775,2443839100,2190866218,1932072870,495393613,1078522166,4051963518,1784694977,1768732442,2146763203,264646923,1474361405,2361552500,296035746,2489922759,2094565616,2409465348,1334241083,72483606,3740181004,4057920662,1734898312,4114662834,574624900,880305546,3258472262,26713132,1571648456,52557195,4043234286,2458021343,676064371,1528437109,64953873,546717185,2709319979,1947039598,2812723004,28691684,286829174,4235176970,3465707163,12526951,2154766700,3165032534,2036061161,3386656087,2301212354,2023576300,1061142336,3105452904,2743866805,3283373992,3397596080,3085489552,3196092395,3210707808,3651022684,925444321,2088074316,230011220,3223248386,533229176,523863486,3028311159,13140218,2538347282,900399636,3000796173,1526771255,3541282854,2992674461,2135722105,389334227,1225164337,3119947809,1803959919,3471171263,704170491,1407019136,1924534819,526887421,168782227,333811993,298623278,4268451686,381087740,2542899140,3266880867,2498950977,200969370,3511909096,3252303004,2268881098,2499828613,2606499854,3163208665,3790254546,1840025712,1319758833,3771674836,519421307,3512796222,1563402978,4284300462,2263719815,715250337,3178437172,2660191010,2982332026,3256309961,2709659997,3434092872,2367065591,69438718,915160508,183164069,3134331940,175242981,2680543346,1421955782,4231173251,1736652874,3990568476,1710820912,2286604440,3464587098,1261907837,1757387321,1128554270,1090050251,2429922486,1288729218,882830086,211637042,1376462063,2147615815,1737974929,798170275,4271572277,4241687072,1638524620,2760366295,1065115089,2097227717,1224023317,1625204849,3383303351,1488272307,2640186157,1649047732,819719707,2615091943,502645401,760628135,4108137983,63606742,1404337880,1865161130,4272996852,1239761976,790984678,3213322601,1917062825,4195069880,1962259360,2111002573,2311983960,1861406170,511141875,2797510619,1331661048,3130608186,147483493,3767089176,2650841450,4096523407,2574446300,1956416337,851468126,3607527519,1811658703,3642821136,832691095,2453312857,933732854,94341217,3393797730,1695907457,2405722077,2877685663,2469507058,2249636341,3988608661,4001245617,825934927,3103985967,1127151177,3691656896,1640967098,2168932645,2830550957,3998822878,3002602893,1509651465,775813869,2599574079,3791574229],re=3,Pe=2,Le=1,De=0,ne=4;function Oi(t){if(t===1)return 0;var e=1;for(t-=1;t=t>>>1;)e++;return e}function Ni(t,e,s){var a;for(a=0;a<e;a++){var g,w;g=s-e,g>Ie[e-a]&&(g=Ie[e-a]),w=Ie[e]+1-(g<<a),t.nGRcodewords[a]=g<<a,t.notGRcwlen[a]=g+Oi(w),t.notGRprefixmask[a]=Ie[32-g]>>>0,t.notGRsuffixlen[a]=Oi(w)}var y=Ie[e],r=y>>>1,n;for(n=0;n<=y;n++)n<=r?t.xlatU2L[n]=n<<1:t.xlatU2L[n]=(y-n<<1)+1;for(n=0;n<=y;n++)n&1?t.xlatL2U[n]=y-(n>>>1):t.xlatL2U[n]=n>>>1}function Th(t){switch(t){case be.QUIC_IMAGE_TYPE_GRAY:return 8;case be.QUIC_IMAGE_TYPE_RGB16:return 5;case be.QUIC_IMAGE_TYPE_RGB24:return 8;case be.QUIC_IMAGE_TYPE_RGB32:return 8;case be.QUIC_IMAGE_TYPE_RGBA:return 8;case be.QUIC_IMAGE_TYPE_INVALID:default:return console.log(`quic: bad image type `),0}}function Rh(t){return t&4286578688?Ot[t>>>24]:t&4294934528?8+Ot[t>>>16&255]:t&4294967168?16+Ot[t>>>8&255]:24+Ot[t&255]}function ke(t,e){var s,a;if(e<0||e>_e.notGRprefixmask[t]){var g=Rh(e);a=g+1+t,s=g<<t|e>>32-a&Ie[t]}else a=_e.notGRcwlen[t],s=_e.nGRcodewords[t]+(e>>32-a&Ie[_e.notGRsuffixlen[t]]);return{codewordlen:a,rc:s}}function Ui(t,e){return t<_e.nGRcodewords[e]?(t>>>e)+1+e:_e.notGRcwlen[e]}function Bs(t){var e,s=0;switch(this.levels=1<<t,this.n_buckets_ptrs=0,Pr){case 1:this.repfirst=3,this.firstsize=1,this.repnext=2,this.mulsize=2;break;case 3:this.repfirst=1,this.firstsize=1,this.repnext=1,this.mulsize=2;break;case 5:this.repfirst=1,this.firstsize=1,this.repnext=1,this.mulsize=4;break;case 0:case 2:case 4:console.log(`quic: findmodelparams(): evol value obsolete!!! `);break;default:console.log(`quic: findmodelparams(): evol out of range!!! `)}this.n_buckets=0;var a=this.repfirst+1,g=this.firstsize;do this.n_buckets?e=s+1:e=0,--a||(a=this.repnext,g*=this.mulsize),s=e+g-1,s+g>=this.levels&&(s=this.levels-1),this.n_buckets_ptrs||(this.n_buckets_ptrs=this.levels),this.n_buckets++;while(s<this.levels-1)}Bs.prototype={n_buckets:0,n_buckets_ptrs:0,repfirst:0,firstsize:0,repnext:0,mulsize:0,levels:0};function Dr(){this.counters=[0,0,0,0,0,0,0,0]}Dr.prototype={bestcode:0,reste:function(t){this.bestcode=t,this.counters=[0,0,0,0,0,0,0,0]},update_model_8bpc:function(t,e,s){var a,g=s-1,w=this.counters[g]+=Ui(e,g);for(a=s-2;a>=0;a--){var y=this.counters[a]+=Ui(e,a);y<w&&(g=a,w=y)}if(this.bestcode=g,w>t.wm_trigger)for(a=0;a<s;a++)this.counters[a]=this.counters[a]>>>1}};function Os(){this.buckets_ptrs=[],this.buckets_buf=[]}Os.prototype={fill_model_structures:function(t){var e,s=0,a=0,g=t.repfirst+1,w=t.firstsize;do{a?e=s+1:e=0,--g||(g=t.repnext,w*=t.mulsize),s=e+w-1,s+w>=t.levels&&(s=t.levels-1),this.buckets_buf[a]=new Dr;var y;for(y=e;y<=s;y++)this.buckets_ptrs[y]=this.buckets_buf[a];a++}while(s<t.levels-1);return!0}};function Mr(t,e){this.state=new Zs,this.family_stat_8bpc=new Os,this.family_stat_5bpc=new Os,this.correlate_row={zero:0,row:[]},this.model_8bpc=t,this.model_5bpc=e,this.buckets_ptrs=[],this.family_stat_8bpc.fill_model_structures(this.model_8bpc)&&this.family_stat_5bpc.fill_model_structures(this.model_5bpc)}Mr.prototype={reste:function(t){var e;if(this.correlate_row={zero:0,row:[]},t==8){for(e=0;e<this.model_8bpc.n_buckets;e++)this.family_stat_8bpc.buckets_buf[e].reste(7);this.buckets_ptrs=this.family_stat_8bpc.buckets_ptrs}else if(t==5){for(e=0;e<this.model_5bpc.n_buckets;e++)this.family_stat_8bpc.buckets_buf[e].reste(4);this.buckets_ptrs=this.family_stat_5bpc.buckets_ptrs}else return console.log(`quic: %s: bad bpc %d `,__FUNCTION__,t),!1;return this.state.reste(),!0}};function Zs(){}Zs.prototype={waitcnt:0,tabrand_seed:255,wm_trigger:0,wmidx:0,wmileft:ct,melcstate:0,melclen:0,melcorder:0,set_wm_trigger:function(){var t=this.wmidx;t>10&&(t=10),this.wm_trigger=Dh[Math.floor(Pr/2)][t]},reste:function(){this.waitcnt=0,this.tabrand_seed=255,this.wmidx=0,this.wmileft=ct,this.set_wm_trigger(),this.melcstate=0,this.melclen=ks[0],this.melcorder=1<<this.melclen},tabrand:function(){return this.tabrand_seed++,Mh[this.tabrand_seed&255]}};function fe(){this.rgb_state=new Zs,this.model_8bpc=new Bs(8),this.model_5bpc=new Bs(5),this.channels=[];var t;for(t=0;t<4;t++)if(this.channels[t]=new Mr(this.model_8bpc,this.model_5bpc),!this.channels[t]){console.log("quic: failed to create channel");return}}fe.prototype={type:0,width:0,height:0,io_idx:0,io_available_bits:0,io_word:0,io_next_word:0,io_now:0,io_end:0,rows_completed:0};fe.prototype.reste=function(t){return this.rgb_state.reste(),this.io_now=t,this.io_end=this.io_now.length,this.io_idx=0,this.rows_completed=0,!0};fe.prototype.read_io_word=function(){if(this.io_idx>=this.io_end)throw"quic: out of data";this.io_next_word=this.io_now[this.io_idx++]|this.io_now[this.io_idx++]<<8|this.io_now[this.io_idx++]<<16|this.io_now[this.io_idx++]<<24};fe.prototype.decode_eatbits=function(t){this.io_word=this.io_word<<t;var e=this.io_available_bits-t;e>=0?(this.io_available_bits=e,this.io_word|=this.io_next_word>>>this.io_available_bits):(e=-1*e,this.io_word|=this.io_next_word<<e,this.read_io_word(),this.io_available_bits=32-e,this.io_word|=this.io_next_word>>>this.io_available_bits)};fe.prototype.decode_eat32bits=function(){this.decode_eatbits(16),this.decode_eatbits(16)};fe.prototype.reste_channels=function(t){var e;for(e=0;e<4;e++)if(!this.channels[e].reste(t))return!1;return!0};fe.prototype.quic_decode_begin=function(t){if(!this.reste(t))return!1;this.io_idx=0,this.io_next_word=this.io_now[this.io_idx++]|this.io_now[this.io_idx++]<<8|this.io_now[this.io_idx++]<<16|this.io_now[this.io_idx++]<<24,this.io_word=this.io_next_word,this.io_available_bits=0;var e=this.io_word;if(this.decode_eat32bits(),e!=1128879441)return console.log("quic: bad magic "+e.toString(16)),!1;var s=this.io_word;if(this.decode_eat32bits(),s!=0)return console.log("quic: bad version "+s.toString(16)),!1;this.type=this.io_word,this.decode_eat32bits(),this.width=this.io_word,this.decode_eat32bits(),this.height=this.io_word,this.decode_eat32bits();var a=Th(this.type);return!!this.reste_channels(a)};fe.prototype.quic_rgb32_uncompress_row0_seg=function(t,e,s,a,g,w){var y,r=3,n,u;if(t)y=t+this.rgb_state.waitcnt;else{e[re]=0,n=0;do u=ke(this.channels[n].buckets_ptrs[this.channels[n].correlate_row.zero].bestcode,this.io_word),this.channels[n].correlate_row.row[0]=u.rc,e[2-n]=_e.xlatL2U[u.rc]&255,this.decode_eatbits(u.codewordlen);while(++n<r);if(this.rgb_state.waitcnt)--this.rgb_state.waitcnt;else{this.rgb_state.waitcnt=this.rgb_state.tabrand()&a,n=0;do this.channels[n].buckets_ptrs[this.channels[n].correlate_row.zero].update_model_8bpc(this.rgb_state,this.channels[n].correlate_row.row[0],g);while(++n<r)}y=++t+this.rgb_state.waitcnt}for(;y<s;){for(;t<=y;t++){e[t*ne+re]=0,n=0;do u=ke(this.channels[n].buckets_ptrs[this.channels[n].correlate_row.row[t-1]].bestcode,this.io_word),this.channels[n].correlate_row.row[t]=u.rc,e[t*ne+(2-n)]=_e.xlatL2U[u.rc]+e[(t-1)*ne+(2-n)]&w,this.decode_eatbits(u.codewordlen);while(++n<r)}n=0;do this.channels[n].buckets_ptrs[this.channels[n].correlate_row.row[y-1]].update_model_8bpc(this.rgb_state,this.channels[n].correlate_row.row[y],g);while(++n<r);y=t+(this.rgb_state.tabrand()&a)}for(;t<s;t++){e[t*ne+re]=0,n=0;do u=ke(this.channels[n].buckets_ptrs[this.channels[n].correlate_row.row[t-1]].bestcode,this.io_word),this.channels[n].correlate_row.row[t]=u.rc,e[t*ne+(2-n)]=_e.xlatL2U[u.rc]+e[(t-1)*ne+(2-n)]&w,this.decode_eatbits(u.codewordlen);while(++n<r)}this.rgb_state.waitcnt=y-s};fe.prototype.quic_rgb32_uncompress_row0=function(t){for(var e=8,s=255,a=0,g=this.width;Qe>this.rgb_state.wmidx&&this.rgb_state.wmileft<=g;)this.rgb_state.wmileft&&(this.quic_rgb32_uncompress_row0_seg(a,t,a+this.rgb_state.wmileft,Ie[this.rgb_state.wmidx],e,s),a+=this.rgb_state.wmileft,g-=this.rgb_state.wmileft),this.rgb_state.wmidx++,this.rgb_state.set_wm_trigger(),this.rgb_state.wmileft=ct;g&&(this.quic_rgb32_uncompress_row0_seg(a,t,a+g,Ie[this.rgb_state.wmidx],e,s),Qe>this.rgb_state.wmidx&&(this.rgb_state.wmileft-=g))};fe.prototype.quic_rgb32_uncompress_row_seg=function(t,e,s,a,g,w){var y=3,r=Ie[this.rgb_state.wmidx],n,u=0,m=0,l=0,p;if(s)m=s+this.rgb_state.waitcnt;else{e[re]=0,p=0;do n=ke(this.channels[p].buckets_ptrs[this.channels[p].correlate_row.zero].bestcode,this.io_word),this.channels[p].correlate_row.row[0]=n.rc,e[2-p]=_e.xlatL2U[this.channels[p].correlate_row.row[0]]+t[2-p]&w,this.decode_eatbits(n.codewordlen);while(++p<y);if(this.rgb_state.waitcnt)--this.rgb_state.waitcnt;else{this.rgb_state.waitcnt=this.rgb_state.tabrand()&r,p=0;do this.channels[p].buckets_ptrs[this.channels[p].correlate_row.zero].update_model_8bpc(this.rgb_state,this.channels[p].correlate_row.row[0],g);while(++p<y)}m=++s+this.rgb_state.waitcnt}for(;;){for(var C=0;m<a&&!C;){for(;s<=m&&!C;s++){var S=s*ne,_=(s-1)*ne,i=(s-2)*ne;if(t[_+Pe]==t[S+Pe]&&t[_+Le]==t[S+Le]&&t[_+De]==t[S+De]&&u!=s&&s>2&&e[_+Pe]==e[i+Pe]&&e[_+Le]==e[i+Le]&&e[_+De]==e[i+De]){for(this.rgb_state.waitcnt=m-s,u=s,l=s+this.decode_run(this.rgb_state);s<l;s++){var S=s*ne,_=(s-1)*ne;e[S+re]=0,e[S+Pe]=e[_+Pe],e[S+Le]=e[_+Le],e[S+De]=e[_+De]}if(s==a)return;m=s+this.rgb_state.waitcnt,C=1;break}p=0,e[S+re]=0;do{var o=this.channels[p],c=o.correlate_row;n=ke(o.buckets_ptrs[c.row[s-1]].bestcode,this.io_word),c.row[s]=n.rc,e[S+(2-p)]=_e.xlatL2U[n.rc]+(e[_+(2-p)]+t[S+(2-p)]>>1)&w,this.decode_eatbits(n.codewordlen)}while(++p<y)}if(C)break;p=0;do this.channels[p].buckets_ptrs[this.channels[p].correlate_row.row[m-1]].update_model_8bpc(this.rgb_state,this.channels[p].correlate_row.row[m],g);while(++p<y);m=s+(this.rgb_state.tabrand()&r)}for(;s<a&&!C;s++){var S=s*ne,_=(s-1)*ne,i=(s-2)*ne;if(t[_+Pe]==t[S+Pe]&&t[_+Le]==t[S+Le]&&t[_+De]==t[S+De]&&u!=s&&s>2&&e[_+Pe]==e[i+Pe]&&e[_+Le]==e[i+Le]&&e[_+De]==e[i+De]){for(this.rgb_state.waitcnt=m-s,u=s,l=s+this.decode_run(this.rgb_state);s<l;s++){var S=s*ne,_=(s-1)*ne;e[S+re]=0,e[S+Pe]=e[_+Pe],e[S+Le]=e[_+Le],e[S+De]=e[_+De]}if(s==a)return;m=s+this.rgb_state.waitcnt,C=1;break}e[S+re]=0,p=0;do n=ke(this.channels[p].buckets_ptrs[this.channels[p].correlate_row.row[s-1]].bestcode,this.io_word),this.channels[p].correlate_row.row[s]=n.rc,e[S+(2-p)]=_e.xlatL2U[n.rc]+(e[_+(2-p)]+t[S+(2-p)]>>1)&w,this.decode_eatbits(n.codewordlen);while(++p<y)}if(!C){this.rgb_state.waitcnt=m-a;return}}};fe.prototype.decode_run=function(t){var e=0;do{var s,a=~(this.io_word>>>24)>>>0&255,g=Lr[a];for(s=1;s<=g;s++)e+=t.melcorder,t.melcstate<32&&(t.melclen=ks[++t.melcstate],t.melcorder=1<<t.melclen);if(g!=8){this.decode_eatbits(g+1);break}this.decode_eatbits(8)}while(!0);return t.melclen&&(e+=this.io_word>>>32-t.melclen,this.decode_eatbits(t.melclen)),t.melcstate&&(t.melclen=ks[--t.melcstate],t.melcorder=1<<t.melclen),e};fe.prototype.quic_rgb32_uncompress_row=function(t,e){for(var s=8,a=255,g=0,w=this.width;Qe>this.rgb_state.wmidx&&this.rgb_state.wmileft<=w;)this.rgb_state.wmileft&&(this.quic_rgb32_uncompress_row_seg(t,e,g,g+this.rgb_state.wmileft,s,a),g+=this.rgb_state.wmileft,w-=this.rgb_state.wmileft),this.rgb_state.wmidx++,this.rgb_state.set_wm_trigger(),this.rgb_state.wmileft=ct;w&&(this.quic_rgb32_uncompress_row_seg(t,e,g,g+w,s,a),Qe>this.rgb_state.wmidx&&(this.rgb_state.wmileft-=w))};fe.prototype.quic_four_uncompress_row0_seg=function(t,e,s,a,g,w,y,r){var n,u;for(e==0?(u=ke(t.buckets_ptrs[s.zero].bestcode,this.io_word),s.row[0]=u.rc,a[re]=_e.xlatL2U[u.rc],this.decode_eatbits(u.codewordlen),t.state.waitcnt?--t.state.waitcnt:(t.state.waitcnt=t.state.tabrand()&w,t.buckets_ptrs[s.zero].update_model_8bpc(t.state,s.row[0],y)),n=++e+t.state.waitcnt):n=e+t.state.waitcnt;n<g;){for(var m;e<=n;e++)m=t.buckets_ptrs[s.row[e-1]],u=ke(m.bestcode,this.io_word),s.row[e]=u.rc,a[e*ne+re]=_e.xlatL2U[u.rc]+a[(e-1)*ne+re]&r,this.decode_eatbits(u.codewordlen);m.update_model_8bpc(t.state,s.row[n],y),n=e+(t.state.tabrand()&w)}for(;e<g;e++)u=ke(t.buckets_ptrs[s.row[e-1]].bestcode,this.io_word),s.row[e]=u.rc,a[e*ne+re]=_e.xlatL2U[u.rc]+a[(e-1)*ne+re]&r,this.decode_eatbits(u.codewordlen);t.state.waitcnt=n-g};fe.prototype.quic_four_uncompress_row0=function(t,e){for(var s=8,a=255,g=t.correlate_row,w=0,y=this.width;Qe>t.state.wmidx&&t.state.wmileft<=y;)t.state.wmileft&&(this.quic_four_uncompress_row0_seg(t,w,g,e,w+t.state.wmileft,Ie[t.state.wmidx],s,a),w+=t.state.wmileft,y-=t.state.wmileft),t.state.wmidx++,t.state.set_wm_trigger(),t.state.wmileft=ct;y&&(this.quic_four_uncompress_row0_seg(t,w,g,e,w+y,Ie[t.state.wmidx],s,a),Qe>t.state.wmidx&&(t.state.wmileft-=y))};fe.prototype.quic_four_uncompress_row_seg=function(t,e,s,a,g,w,y,r){var n=Ie[t.state.wmidx],u,m=0,l,p;for(g==0?(p=ke(t.buckets_ptrs[e.zero].bestcode,this.io_word),e.row[0]=p.rc,a[re]=_e.xlatL2U[p.rc]+s[re]&r,this.decode_eatbits(p.codewordlen),t.state.waitcnt?--t.state.waitcnt:(t.state.waitcnt=t.state.tabrand()&n,t.buckets_ptrs[e.zero].update_model_8bpc(t.state,e.row[0],y)),u=++g+t.state.waitcnt):u=g+t.state.waitcnt;;){for(var C=0;u<w&&!C;){for(var S;g<=u&&!C;g++){var _=g*ne,i=(g-1)*ne,o=(g-2)*ne;if(s[i+re]==s[_+re]&&m!=g&&g>2&&a[i+re]==a[o+re]){for(t.state.waitcnt=u-g,m=g,l=g+this.decode_run(t.state);g<l;g++){var _=g*ne,i=(g-1)*ne;a[_+re]=a[i+re]}if(g==w)return;u=g+t.state.waitcnt,C=1;break}S=t.buckets_ptrs[e.row[g-1]],p=ke(S.bestcode,this.io_word),e.row[g]=p.rc,a[_+re]=_e.xlatL2U[p.rc]+(a[i+re]+s[_+re]>>1)&r,this.decode_eatbits(p.codewordlen)}if(C)break;S.update_model_8bpc(t.state,e.row[u],y),u=g+(t.state.tabrand()&n)}for(;g<w&&!C;g++){var _=g*ne,i=(g-1)*ne,o=(g-2)*ne;if(s[i+re]==s[_+re]&&m!=g&&g>2&&a[i+re]==a[o+re]){for(t.state.waitcnt=u-g,m=g,l=g+this.decode_run(t.state);g<l;g++){var _=g*ne,i=(g-1)*ne;a[_+re]=a[i+re]}if(g==w)return;u=g+t.state.waitcnt,C=1;break}p=ke(t.buckets_ptrs[e.row[g-1]].bestcode,this.io_word),e.row[g]=p.rc,a[_+re]=_e.xlatL2U[p.rc]+(a[i+re]+s[_+re]>>1)&r,this.decode_eatbits(p.codewordlen)}if(!C){t.state.waitcnt=u-w;return}}};fe.prototype.quic_four_uncompress_row=function(t,e,s){for(var a=8,g=255,w=t.correlate_row,y=0,r=this.width;Qe>t.state.wmidx&&t.state.wmileft<=r;)t.state.wmileft&&(this.quic_four_uncompress_row_seg(t,w,e,s,y,y+t.state.wmileft,a,g),y+=t.state.wmileft,r-=t.state.wmileft),t.state.wmidx++,t.state.set_wm_trigger(),t.state.wmileft=ct;r&&(this.quic_four_uncompress_row_seg(t,w,e,s,y,y+r,a,g),Qe>t.state.wmidx&&(t.state.wmileft-=r))};fe.prototype.quic_decode=function(t,e){var s;switch(this.type){case be.QUIC_IMAGE_TYPE_RGB32:case be.QUIC_IMAGE_TYPE_RGB24:for(this.channels[0].correlate_row.zero=0,this.channels[1].correlate_row.zero=0,this.channels[2].correlate_row.zero=0,this.quic_rgb32_uncompress_row0(t),this.rows_completed++,s=1;s<this.height;s++){var a=t;t=a.subarray(e),this.channels[0].correlate_row.zero=this.channels[0].correlate_row.row[0],this.channels[1].correlate_row.zero=this.channels[1].correlate_row.row[0],this.channels[2].correlate_row.zero=this.channels[2].correlate_row.row[0],this.quic_rgb32_uncompress_row(a,t),this.rows_completed++}break;case be.QUIC_IMAGE_TYPE_RGB16:return console.log(`quic: unsupported output format `),!1;case be.QUIC_IMAGE_TYPE_RGBA:for(this.channels[0].correlate_row.zero=0,this.channels[1].correlate_row.zero=0,this.channels[2].correlate_row.zero=0,this.quic_rgb32_uncompress_row0(t),this.channels[3].correlate_row.zero=0,this.quic_four_uncompress_row0(this.channels[3],t),this.rows_completed++,s=1;s<this.height;s++){var a=t;t=a.subarray(e),this.channels[0].correlate_row.zero=this.channels[0].correlate_row.row[0],this.channels[1].correlate_row.zero=this.channels[1].correlate_row.row[0],this.channels[2].correlate_row.zero=this.channels[2].correlate_row.row[0],this.quic_rgb32_uncompress_row(a,t),this.channels[3].correlate_row.zero=this.channels[3].correlate_row.row[0],this.quic_four_uncompress_row($e.channels[3],a,t),this.rows_completed++}break;case be.QUIC_IMAGE_TYPE_GRAY:return console.log(`quic: unsupported output format `),!1;case be.QUIC_IMAGE_TYPE_INVALID:default:return console.log(`quic: bad image type `),!1}return!0};fe.prototype.simple_quic_decode=function(t){var e=4;if(this.quic_decode_begin(t)&&!(this.type!=be.QUIC_IMAGE_TYPE_RGB32&&this.type!=be.QUIC_IMAGE_TYPE_RGB24&&this.type!=be.QUIC_IMAGE_TYPE_RGBA)){var s=new Uint8Array(this.width*this.height*4);if(s[0]=69,this.quic_decode(s,this.width*e))return s}};function Tr(){}Tr.prototype={from_dv:function(t,e,s){if(!$e)throw"quic: no quic encoder";this.data_size=t.getUint32(e,!0),e+=4;var a=new Uint8Array(s.slice(e));return this.outptr=$e.simple_quic_decode(a),this.outptr&&(this.type=$e.type,this.width=$e.width,this.height=$e.height),e+=a.length,e}};function kh(t,e){var s=t.createImageData(e.width,e.height),a;for(a=0;a<s.width*s.height*4;a+=4)s.data[a+0]=e.outptr[a+2],s.data[a+1]=e.outptr[a+1],s.data[a+2]=e.outptr[a+0],e.type!==be.QUIC_IMAGE_TYPE_RGBA?s.data[a+3]=255:s.data[a+3]=255-e.outptr[a+3];return s}if(ki){ki=!1,Ni(_e,8,Bi),Ni(Lh,5,Bi);var Nt,Ls,Ut,Ds;for(Ls=Ut=1,Ds=8,Nt=0;Nt<256;++Nt)Lr[Nt]=Ds,--Ut,Ut==0&&(Ut=Ls,--Ds,Ls*=2);if($e=new fe,!$e)throw"quic: failed to create encoder"}function Rr(){}Rr.prototype={from_dv:function(t,e,s){return this.type=t.getUint8(e,!0),e++,this.id=t.getUint8(e,!0),e++,e}};function st(){}st.prototype={from_dv:function(t,e,s){return this.top=t.getUint32(e,!0),e+=4,this.left=t.getUint32(e,!0),e+=4,this.bottom=t.getUint32(e,!0),e+=4,this.right=t.getUint32(e,!0),e+=4,e},is_same_size:function(t){return this.bottom-this.top==t.bottom-t.top&&this.right-this.left==t.right-t.left}};function kr(){}kr.prototype={from_dv:function(t,e,s){var a;for(this.num_rects=t.getUint32(e,!0),e+=4,this.num_rects>0&&(this.rects=[]),a=0;a<this.num_rects;a++)this.rects[a]=new st,e=this.rects[a].from_dv(t,e,s);return e}};function os(){}os.prototype={from_dv:function(t,e,s){return this.type=t.getUint8(e,!0),e++,this.type==R.SPICE_CLIP_TYPE_RECTS&&(this.rects=new kr,e=this.rects.from_dv(t,e,s)),e}};function Br(){}Br.prototype={from_dv:function(t,e,s){return this.id=t.getUint64(e,!0),e+=8,this.type=t.getUint8(e,!0),e++,this.flags=t.getUint8(e,!0),e++,this.width=t.getUint32(e,!0),e+=4,this.height=t.getUint32(e,!0),e+=4,e}};function Or(){}Or.prototype={from_dv:function(t,e,s){var a;for(this.unique=t.getUint64(e,!0),e+=8,this.num_ents=t.getUint16(e,!0),e+=2,this.ents=[],a=0;a<this.num_ents;a++)this.ents[a]=t.getUint32(e,!0),e+=4;return e}};function Nr(){}Nr.prototype={from_dv:function(t,e,s){if(this.format=t.getUint8(e,!0),e++,this.flags=t.getUint8(e,!0),e++,this.x=t.getUint32(e,!0),e+=4,this.y=t.getUint32(e,!0),e+=4,this.stride=t.getUint32(e,!0),e+=4,this.flags&R.SPICE_BITMAP_FLAGS_PAL_FROM_CACHE)this.palette_id=t.getUint64(e,!0),e+=8;else{var a=t.getUint32(e,!0);e+=4,a==0?this.palette=null:(this.palette=new Or,this.palette.from_dv(t,a,s))}return this.data=s.slice(e),e+=this.data.byteLength,e}};function as(){}as.prototype={from_dv:function(t,e,s){if(this.descriptor=new Br,e=this.descriptor.from_dv(t,e,s),this.descriptor.type==R.SPICE_IMAGE_TYPE_LZ_RGB){this.lz_rgb=new Object,this.lz_rgb.length=t.getUint32(e,!0),e+=4;var a=e;this.lz_rgb.magic="";for(var g=3;g>=0;g--)this.lz_rgb.magic+=String.fromCharCode(t.getUint8(e+g));e+=4,this.lz_rgb.version=t.getUint32(e),e+=4,this.lz_rgb.type=t.getUint32(e),e+=4,this.lz_rgb.width=t.getUint32(e),e+=4,this.lz_rgb.height=t.getUint32(e),e+=4,this.lz_rgb.stride=t.getUint32(e),e+=4,this.lz_rgb.top_down=t.getUint32(e),e+=4;var w=e-a;this.lz_rgb.data=s.slice(e,this.lz_rgb.length+e-w),e+=this.lz_rgb.data.byteLength}if(this.descriptor.type==R.SPICE_IMAGE_TYPE_BITMAP&&(this.bitmap=new Nr,e=this.bitmap.from_dv(t,e,s)),this.descriptor.type==R.SPICE_IMAGE_TYPE_SURFACE&&(this.surface_id=t.getUint32(e,!0),e+=4),this.descriptor.type==R.SPICE_IMAGE_TYPE_JPEG&&(this.jpeg=new Object,this.jpeg.data_size=t.getUint32(e,!0),e+=4,this.jpeg.data=s.slice(e),e+=this.jpeg.data.byteLength),this.descriptor.type==R.SPICE_IMAGE_TYPE_JPEG_ALPHA){this.jpeg_alpha=new Object,this.jpeg_alpha.flags=t.getUint8(e,!0),e+=1,this.jpeg_alpha.jpeg_size=t.getUint32(e,!0),e+=4,this.jpeg_alpha.data_size=t.getUint32(e,!0),e+=4,this.jpeg_alpha.data=s.slice(e,this.jpeg_alpha.jpeg_size+e),e+=this.jpeg_alpha.data.byteLength,this.jpeg_alpha.alpha=new Object,this.jpeg_alpha.alpha.length=this.jpeg_alpha.data_size-this.jpeg_alpha.jpeg_size;var a=e;this.jpeg_alpha.alpha.magic="";for(var g=3;g>=0;g--)this.jpeg_alpha.alpha.magic+=String.fromCharCode(t.getUint8(e+g));e+=4,this.jpeg_alpha.alpha.version=t.getUint32(e),e+=4,this.jpeg_alpha.alpha.type=t.getUint32(e),e+=4,this.jpeg_alpha.alpha.width=t.getUint32(e),e+=4,this.jpeg_alpha.alpha.height=t.getUint32(e),e+=4,this.jpeg_alpha.alpha.stride=t.getUint32(e),e+=4,this.jpeg_alpha.alpha.top_down=t.getUint32(e),e+=4;var w=e-a;this.jpeg_alpha.alpha.data=s.slice(e,this.jpeg_alpha.alpha.length+e-w),e+=this.jpeg_alpha.alpha.data.byteLength}return this.descriptor.type==R.SPICE_IMAGE_TYPE_QUIC&&(this.quic=new Tr,e=this.quic.from_dv(t,e,s)),e}};function Js(){}Js.prototype={from_dv:function(t,e,s){this.flags=t.getUint8(e,!0),e++,this.pos=new cs,e=this.pos.from_dv(t,e,s);var a=t.getUint32(e,!0);return e+=4,a==0?(this.bitmap=null,e):(this.bitmap=new as,this.bitmap.from_dv(t,a,s))}};function Ur(){}Ur.prototype={from_dv:function(t,e,s){var a=t.getUint32(e,!0);return e+=4,a==0?this.pat=null:(this.pat=new as,this.pat.from_dv(t,a,s)),this.pos=new cs,this.pos.from_dv(t,e,s)}};function jr(){}jr.prototype={from_dv:function(t,e,s){return this.type=t.getUint8(e,!0),e++,this.type==R.SPICE_BRUSH_TYPE_SOLID?(this.color=t.getUint32(e,!0),e+=4):this.type==R.SPICE_BRUSH_TYPE_PATTERN&&(this.pattern=new Ur,e=this.pattern.from_dv(t,e,s)),e}};function Fr(){}Fr.prototype={from_dv:function(t,e,s){return this.brush=new jr,e=this.brush.from_dv(t,e,s),this.rop_descriptor=t.getUint16(e,!0),e+=2,this.mask=new Js,this.mask.from_dv(t,e,s)}};function Hr(){}Hr.prototype={from_dv:function(t,e,s){var a=t.getUint32(e,!0);return e+=4,a==0?this.src_bitmap=null:(this.src_bitmap=new as,this.src_bitmap.from_dv(t,a,s)),this.src_area=new st,e=this.src_area.from_dv(t,e,s),this.rop_descriptor=t.getUint16(e,!0),e+=2,this.scale_mode=t.getUint8(e,!0),e++,this.mask=new Js,this.mask.from_dv(t,e,s)}};function ei(){}ei.prototype={from_dv:function(t,e,s){return this.x=t.getUint16(e,!0),e+=2,this.y=t.getUint16(e,!0),e+=2,e}};function cs(){}cs.prototype={from_dv:function(t,e,s){return this.x=t.getUint32(e,!0),e+=4,this.y=t.getUint32(e,!0),e+=4,e}};function Kr(){}Kr.prototype={from_dv:function(t,e,s){return this.unique=t.getUint64(e,!0),e+=8,this.type=t.getUint8(e,!0),e++,this.width=t.getUint16(e,!0),e+=2,this.height=t.getUint16(e,!0),e+=2,this.hot_spot_x=t.getUint16(e,!0),e+=2,this.hot_spot_y=t.getUint16(e,!0),e+=2,e}};function ti(){}ti.prototype={from_dv:function(t,e,s){return this.flags=t.getUint16(e,!0),e+=2,this.flags&R.SPICE_CURSOR_FLAGS_NONE?this.header=null:(this.header=new Kr,e=this.header.from_dv(t,e,s),this.data=s.slice(e),e+=this.data.byteLength),e}};function Gr(){}Gr.prototype={from_dv:function(t,e,s){return this.surface_id=t.getUint32(e,!0),e+=4,this.width=t.getUint32(e,!0),e+=4,this.height=t.getUint32(e,!0),e+=4,this.format=t.getUint32(e,!0),e+=4,this.flags=t.getUint32(e,!0),e+=4,e}};var H={KEY_Escape:1,KEY_1:2,KEY_2:3,KEY_3:4,KEY_4:5,KEY_5:6,KEY_6:7,KEY_7:8,KEY_8:9,KEY_9:10,KEY_0:11,KEY_Minus:12,KEY_Equal:13,KEY_BackSpace:14,KEY_Tab:15,KEY_Q:16,KEY_W:17,KEY_E:18,KEY_R:19,KEY_T:20,KEY_Y:21,KEY_U:22,KEY_I:23,KEY_O:24,KEY_P:25,KEY_LBrace:26,KEY_RBrace:27,KEY_Enter:28,KEY_LCtrl:29,KEY_A:30,KEY_S:31,KEY_D:32,KEY_F:33,KEY_G:34,KEY_H:35,KEY_J:36,KEY_K:37,KEY_L:38,KEY_SemiColon:39,KEY_Quote:40,KEY_Tilde:41,KEY_ShiftL:42,KEY_BSlash:43,KEY_Z:44,KEY_X:45,KEY_C:46,KEY_V:47,KEY_B:48,KEY_N:49,KEY_M:50,KEY_Comma:51,KEY_Period:52,KEY_Slash:53,KEY_KP_Multiply:55,KEY_Alt:56,KEY_Space:57,KEY_CapsLock:58,KEY_F1:59,KEY_F2:60,KEY_F3:61,KEY_F4:62,KEY_F5:63,KEY_F6:64,KEY_F7:65,KEY_F8:66,KEY_F9:67,KEY_F10:68,KEY_NumLock:69,KEY_ScrollLock:70,KEY_KP_7:71,KEY_KP_8:72,KEY_KP_9:73,KEY_KP_4:75,KEY_KP_5:76,KEY_KP_6:77,KEY_KP_Plus:78,KEY_KP_1:79,KEY_KP_2:80,KEY_KP_3:81,KEY_KP_0:82,KEY_KP_Decimal:83,KEY_F11:87,KEY_F12:88};const j=[];j.Escape=1;j.Digit1=2;j.Digit2=3;j.Digit3=4;j.Digit4=5;j.Digit5=6;j.Digit6=7;j.Digit7=8;j.Digit8=9;j.Digit9=10;j.Digit0=11;j.Minus=12;j.Equal=13;j.Backspace=14;j.Tab=15;j.KeyQ=16;j.KeyW=17;j.KeyE=18;j.KeyR=19;j.KeyT=20;j.KeyY=21;j.KeyU=22;j.KeyI=23;j.KeyO=24;j.KeyP=25;j.BracketLeft=26;j.BracketRight=27;j.Enter=28;j.ControlLeft=29;j.KeyA=30;j.KeyS=31;j.KeyD=32;j.KeyF=33;j.KeyG=34;j.KeyH=35;j.KeyJ=36;j.KeyK=37;j.KeyL=38;j.Semicolon=39;j.Quote=40;j.Backquote=41;j.ShiftLeft=42;j.Backslash=43;j.KeyZ=44;j.KeyX=45;j.KeyC=46;j.KeyV=47;j.KeyB=48;j.KeyN=49;j.KeyM=50;j.Comma=51;j.Period=52;j.Slash=53;j.ShiftRight=54;j.NumpadMultiply=55;j.AltLeft=56;j.Space=57;j.CapsLock=58;j.F1=59;j.F2=60;j.F3=61;j.F4=62;j.F5=63;j.F6=64;j.F7=65;j.F8=66;j.F9=67;j.F10=68;j.Pause=69;j.ScrollLock=70;j.Numpad7=71;j.Numpad8=72;j.Numpad9=73;j.NumpadSubtract=74;j.Numpad4=75;j.Numpad5=76;j.Numpad6=77;j.NumpadAdd=78;j.Numpad1=79;j.Numpad2=80;j.Numpad3=81;j.Numpad0=82;j.NumpadDecimal=83;j.PrintScreen=84;j.IntlBackslash=86;j.F11=87;j.F12=88;j.NumpadEqual=89;j.F13=100;j.F14=101;j.F15=102;j.F16=103;j.F17=104;j.F18=105;j.F19=106;j.F20=107;j.F21=108;j.F22=109;j.F23=110;j.KanaMode=112;j.IntlRo=115;j.F24=118;j.Convert=121;j.NonConvert=123;j.IntlYen=125;j.NumpadComma=126;j.MediaTrackPrevious=4320;j.MediaTrackNext=6624;j.NumpadEnter=7392;j.ControlRight=7648;j.AudioVolumeMute=8416;j.LaunchApp2=8672;j.MediaPlayPause=8928;j.MediaStop=9440;j.VolumeDown=12e3;j.VolumeUp=12512;j.BrowserHome=13024;j.NumpadDivide=13792;j.PrintScreen=14304;j.AltRight=14560;j.NumLock=17888;j.Pause=18144;j.Home=18400;j.ArrowUp=18656;j.PageUp=18912;j.ArrowLeft=19424;j.ArrowRight=19936;j.End=20448;j.ArrowDown=20704;j.PageDown=20960;j.Insert=21216;j.Delete=21472;j.MetaLeft=23520;j.MetaRight=23776;j.ContextMenu=24032;j.Power=24288;j.BrowserSearch=26080;j.BrowserFavorites=26336;j.BrowserRefresh=26592;j.BrowserStop=26848;j.BrowserForward=27104;j.BrowserBack=27360;j.LaunchApp1=27616;j.LaunchMail=27872;j.MediaSelect=28128;var Bh=0,Oh="data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=";function Nh(t){return String.fromCharCode.apply(null,new Uint16Array(t))}var W=[];W[49]=H.KEY_1;W[50]=H.KEY_2;W[51]=H.KEY_3;W[52]=H.KEY_4;W[53]=H.KEY_5;W[54]=H.KEY_6;W[55]=H.KEY_7;W[56]=H.KEY_8;W[57]=H.KEY_9;W[48]=H.KEY_0;W[145]=H.KEY_ScrollLock;W[103]=H.KEY_KP_7;W[104]=H.KEY_KP_8;W[105]=H.KEY_KP_9;W[100]=H.KEY_KP_4;W[101]=H.KEY_KP_5;W[102]=H.KEY_KP_6;W[107]=H.KEY_KP_Plus;W[97]=H.KEY_KP_1;W[98]=H.KEY_KP_2;W[99]=H.KEY_KP_3;W[96]=H.KEY_KP_0;W[109]=H.KEY_Minus;W[110]=H.KEY_KP_Decimal;W[191]=H.KEY_Slash;W[190]=H.KEY_Period;W[188]=H.KEY_Comma;W[220]=H.KEY_BSlash;W[192]=H.KEY_Tilde;W[222]=H.KEY_Quote;W[219]=H.KEY_LBrace;W[221]=H.KEY_RBrace;W[81]=H.KEY_Q;W[87]=H.KEY_W;W[69]=H.KEY_E;W[82]=H.KEY_R;W[84]=H.KEY_T;W[89]=H.KEY_Y;W[85]=H.KEY_U;W[73]=H.KEY_I;W[79]=H.KEY_O;W[80]=H.KEY_P;W[65]=H.KEY_A;W[83]=H.KEY_S;W[68]=H.KEY_D;W[70]=H.KEY_F;W[71]=H.KEY_G;W[72]=H.KEY_H;W[74]=H.KEY_J;W[75]=H.KEY_K;W[76]=H.KEY_L;W[90]=H.KEY_Z;W[88]=H.KEY_X;W[67]=H.KEY_C;W[86]=H.KEY_V;W[66]=H.KEY_B;W[78]=H.KEY_N;W[77]=H.KEY_M;W[32]=H.KEY_Space;W[13]=H.KEY_Enter;W[27]=H.KEY_Escape;W[8]=H.KEY_BackSpace;W[9]=H.KEY_Tab;W[16]=H.KEY_ShiftL;W[17]=H.KEY_LCtrl;W[18]=H.KEY_Alt;W[20]=H.KEY_CapsLock;W[44]=H.KEY_SysReqest;W[144]=H.KEY_NumLock;W[112]=H.KEY_F1;W[113]=H.KEY_F2;W[114]=H.KEY_F3;W[115]=H.KEY_F4;W[116]=H.KEY_F5;W[117]=H.KEY_F6;W[118]=H.KEY_F7;W[119]=H.KEY_F8;W[120]=H.KEY_F9;W[121]=H.KEY_F10;W[122]=H.KEY_F11;W[123]=H.KEY_F12;W[42]=99;W[19]=101;W[111]=224|H.KEY_Slash<<8;W[106]=224|H.KEY_KP_Multiply<<8;W[36]=224|H.KEY_KP_7<<8;W[38]=224|H.KEY_KP_8<<8;W[33]=224|H.KEY_KP_9<<8;W[37]=224|H.KEY_KP_4<<8;W[39]=224|H.KEY_KP_6<<8;W[35]=224|H.KEY_KP_1<<8;W[40]=224|H.KEY_KP_2<<8;W[34]=224|H.KEY_KP_3<<8;W[45]=224|H.KEY_KP_0<<8;W[46]=224|H.KEY_KP_Decimal<<8;W[91]=23520;W[92]=23776;W[93]=24032;var hs=[];hs[173]=H.KEY_Minus;hs[61]=H.KEY_Equal;hs[59]=H.KEY_SemiColon;var ls=[];ls[189]=H.KEY_Minus;ls[187]=H.KEY_Equal;ls[186]=H.KEY_SemiColon;function Yr(t,e){return j[e]!==void 0?j[e]:W[t]===void 0?navigator.userAgent.indexOf("Firefox")!=-1?hs[t]:ls[t]:W[t]}function Uh(t,e){var s=Yr(t,e);return s===void 0?(alert("no map for "+t),0):s}function jh(t,e){var s=Yr(t,e);return s===void 0?0:s<256?s|128:s|32768}function zr(t){var e="[networkState "+t.networkState+"|readyState "+t.readyState+"|error "+t.error+"|seeking "+t.seeking+"|duration "+t.duration+"|paused "+t.paused+"|ended "+t.error+"|buffered "+Fh(t.buffered)+"]";return e}function Fh(t){var e;if(t){var s=t.length;e="{len "+s,s>0&&(e+="; start "+t.start(0)+"; end "+t.end(s-1)),e+="}"}else e="N/A";return e}function Kt(t,e){this.magic=R.SPICE_MAGIC,this.major_version=R.SPICE_VERSION_MAJOR,this.minor_version=R.SPICE_VERSION_MINOR,this.size=0,t!==void 0&&this.from_buffer(t,e)}Kt.prototype={from_buffer:function(t,e){e=e||0;var s=new ee(t);this.magic="";for(var a=0;a<4;a++)this.magic+=String.fromCharCode(s.getUint8(e+a));e+=4,this.major_version=s.getUint32(e,!0),e+=4,this.minor_version=s.getUint32(e,!0),e+=4,this.size=s.getUint32(e,!0),e+=4},to_buffer:function(t,e){e=e||0;for(var s=new ee(t),a=0;a<4;a++)s.setUint8(e+a,this.magic.charCodeAt(a));e+=4,s.setUint32(e,this.major_version,!0),e+=4,s.setUint32(e,this.minor_version,!0),e+=4,s.setUint32(e,this.size,!0),e+=4},buffer_size:function(){return 16}};function Wr(t,e){this.connection_id=0,this.channel_type=0,this.channel_id=0,this.common_caps=[],this.channel_caps=[],t!==void 0&&this.from_buffer(t,e)}Wr.prototype={from_buffer:function(t,e){e=e||0;var s,a=e,g=new ee(t);this.connection_id=g.getUint32(e,!0),e+=4,this.channel_type=g.getUint8(e,!0),e++,this.channel_id=g.getUint8(e,!0),e++;var w=g.getUint32(e,!0);e+=4;var y=g.getUint32(e,!0);e+=4;var r=g.getUint32(e,!0);for(e+=4,e=a+r,this.common_caps=[],s=0;s<w;s++)this.common_caps.unshift(g.getUint32(e,!0)),e+=4;for(this.channel_caps=[],s=0;s<y;s++)this.channel_caps.unshift(g.getUint32(e,!0)),e+=4},to_buffer:function(t,e){e=e||0;var s=e,a,g=new ee(t);for(g.setUint32(e,this.connection_id,!0),e+=4,g.setUint8(e,this.channel_type,!0),e++,g.setUint8(e,this.channel_id,!0),e++,g.setUint32(e,this.common_caps.length,!0),e+=4,g.setUint32(e,this.channel_caps.length,!0),e+=4,g.setUint32(e,e-s+4,!0),e+=4,a=0;a<this.common_caps.length;a++)g.setUint32(e,this.common_caps[a],!0),e+=4;for(a=0;a<this.channel_caps.length;a++)g.setUint32(e,this.channel_caps[a],!0),e+=4},buffer_size:function(){return 18+4*this.common_caps.length+4*this.channel_caps.length}};function $r(t,e){this.error=0,this.pub_key=void 0,this.common_caps=[],this.channel_caps=[],t!==void 0&&this.from_buffer(t,e)}$r.prototype={from_buffer:function(t,e){e=e||0;var s,a=e,g=new ee(t);this.error=g.getUint32(e,!0),e+=4,this.pub_key=wh(t,e),e+=R.SPICE_TICKET_PUBKEY_BYTES;var w=g.getUint32(e,!0);e+=4;var y=g.getUint32(e,!0);e+=4;var r=g.getUint32(e,!0);for(e+=4,e=a+r,this.common_caps=[],s=0;s<w;s++)this.common_caps.unshift(g.getUint32(e,!0)),e+=4;for(this.channel_caps=[],s=0;s<y;s++)this.channel_caps.unshift(g.getUint32(e,!0)),e+=4}};function Vr(t,e){this.auth_mechanism=0,this.encrypted_data=void 0}Vr.prototype={to_buffer:function(t,e){e=e||0;var s,a=new ee(t);for(a.setUint32(e,this.auth_mechanism,!0),e+=4,s=0;s<R.SPICE_TICKET_KEY_PAIR_LENGTH/8;s++)this.encrypted_data&&s<this.encrypted_data.length?a.setUint8(e,this.encrypted_data[s],!0):a.setUint8(e,0,!0),e++},buffer_size:function(){return 4+R.SPICE_TICKET_KEY_PAIR_LENGTH/8}};function Ns(t,e){this.auth_code=0,t!==void 0&&this.from_buffer(t,e)}Ns.prototype={from_buffer:function(t,e){e=e||0;var s=new ee(t);this.auth_code=s.getUint32(e,!0),e+=4},buffer_size:function(){return 4}};function le(t,e){this.type=0,this.size=0,this.data=void 0,t!==void 0&&this.from_buffer(t,e)}le.prototype={from_buffer:function(t,e){e=e||0;var s=new ee(t);this.type=s.getUint16(e,!0),e+=2,this.size=s.getUint32(e,!0),e+=4,t.byteLength>e&&(this.data=t.slice(e),e+=this.data.byteLength)},to_buffer:function(t,e){e=e||0;var s,a=new ee(t);if(a.setUint16(e,this.type,!0),e+=2,a.setUint32(e,this.data?this.data.byteLength:0,!0),e+=4,this.data&&this.data.byteLength>0){var g=new Uint8Array(this.data);for(s=0;s<g.length;s++,e++)a.setUint8(e,g[s],!0)}},build_msg:function(t,e){this.type=t,this.size=e.buffer_size(),this.data=new ArrayBuffer(this.size),e.to_buffer(this.data)},buffer_size:function(){return this.data?6+this.data.byteLength:6}};function qr(t,e){this.num_of_channels=0,this.channels=[],t!==void 0&&this.from_buffer(t,e)}qr.prototype={from_buffer:function(t,e){e=e||0;var s,a=new ee(t);for(this.num_of_channels=a.getUint32(e,!0),e+=4,s=0;s<this.num_of_channels;s++){var g=new Rr;e=g.from_dv(a,e,t),this.channels.push(g)}}};function Xr(t,e){this.from_buffer(t,e)}Xr.prototype={from_buffer:function(t,e){e=e||0;var s=new ee(t);this.session_id=s.getUint32(e,!0),e+=4,this.display_channels_hint=s.getUint32(e,!0),e+=4,this.supported_mouse_modes=s.getUint32(e,!0),e+=4,this.current_mouse_mode=s.getUint32(e,!0),e+=4,this.agent_connected=s.getUint32(e,!0),e+=4,this.agent_tokens=s.getUint32(e,!0),e+=4,this.multi_media_time=s.getUint32(e,!0),e+=4,this.ram_hint=s.getUint32(e,!0),e+=4}};function Qr(t,e){this.from_buffer(t,e)}Qr.prototype={from_buffer:function(t,e){e=e||0;var s=new ee(t);this.supported_modes=s.getUint16(e,!0),e+=2,this.current_mode=s.getUint16(e,!0),e+=2}};function Zr(t,e){this.from_buffer(t,e)}Zr.prototype={from_buffer:function(t,e){e=e||0;var s=new ee(t);this.protocol=s.getUint32(e,!0),e+=4,this.type=s.getUint32(e,!0),e+=4,this.opaque=s.getUint64(e,!0),e+=8,this.size=s.getUint32(e,!0),e+=4,t.byteLength>e&&(this.data=t.slice(e),e+=this.data.byteLength)}};function Us(t,e){this.from_buffer(t,e)}Us.prototype={from_buffer:function(t,e){e=e||0;var s=new ee(t);this.num_tokens=s.getUint32(e,!0),e+=4}};function Jr(t,e){this.from_buffer(t,e)}Jr.prototype={from_buffer:function(t,e){e=e||0;var s=new ee(t);this.generation=s.getUint32(e,!0),e+=4,this.window=s.getUint32(e,!0),e+=4}};function en(t){this.generation=t.generation}en.prototype={to_buffer:function(t,e){e=e||0;var s=new ee(t);s.setUint32(e,this.generation,!0),e+=4},buffer_size:function(){return 4}};function tn(t){this.mode=t}tn.prototype={to_buffer:function(t,e){e=e||0;var s=new ee(t);s.setUint16(e,this.mode,!0),e+=2},buffer_size:function(){return 2}};function sn(t){this.num_tokens=t}sn.prototype={to_buffer:function(t,e){e=e||0;var s=new ee(t);s.setUint32(e,this.num_tokens,!0),e+=4},buffer_size:function(){return 4}};function rn(t,e){this.protocol=R.VD_AGENT_PROTOCOL,this.type=t,this.opaque=0,this.size=e.buffer_size(),this.data=e}rn.prototype={to_buffer:function(t,e){e=e||0;var s=new ee(t);s.setUint32(e,this.protocol,!0),e+=4,s.setUint32(e,this.type,!0),e+=4,s.setUint64(e,this.opaque,!0),e+=8,s.setUint32(e,this.size,!0),e+=4,this.data.to_buffer(t,e)},buffer_size:function(){return 20+this.data.buffer_size()}};function si(t,e){e?(this.request=t,this.caps=e):this.from_buffer(t)}si.prototype={to_buffer:function(t,e){e=e||0;var s=new ee(t);s.setUint32(e,this.request,!0),e+=4,s.setUint32(e,this.caps,!0),e+=4},from_buffer:function(t,e){e=e||0;var s=new ee(t);return this.request=s.getUint32(e,!0),e+=4,this.caps=s.getUint32(e,!0),e+=4,e},buffer_size:function(){return 8}};function nn(t,e,s,a,g,w){this.num_mon=1,this.flags=t,this.width=e,this.height=s,this.depth=a,this.x=g,this.y=w}nn.prototype={to_buffer:function(t,e){e=e||0;var s=new ee(t);s.setUint32(e,this.num_mon,!0),e+=4,s.setUint32(e,this.flags,!0),e+=4,s.setUint32(e,this.height,!0),e+=4,s.setUint32(e,this.width,!0),e+=4,s.setUint32(e,this.depth,!0),e+=4,s.setUint32(e,this.x,!0),e+=4,s.setUint32(e,this.y,!0),e+=4},buffer_size:function(){return 28}};function ii(t,e){e?(this.id=t,this.result=e):this.from_buffer(t)}ii.prototype={to_buffer:function(t,e){e=e||0;var s=new ee(t);s.setUint32(e,this.id,!0),e+=4,s.setUint32(e,this.result,!0),e+=4},from_buffer:function(t,e){e=e||0;var s=new ee(t);return this.id=s.getUint32(e,!0),e+=4,this.result=s.getUint32(e,!0),e+=4,e},buffer_size:function(){return 8}};function on(t,e,s){this.id=t,this.string=`[vdagent-file-xfer] name=`+e+` size=`+s+` `}on.prototype={to_buffer:function(t,e){e=e||0;var s=new ee(t);s.setUint32(e,this.id,!0),e+=4;for(var a=0;a<this.string.length;a++,e++)s.setUint8(e,this.string.charCodeAt(a))},buffer_size:function(){return 4+this.string.length+1}};function an(t,e,s){this.id=t,this.size=e,this.data=s}an.prototype={to_buffer:function(t,e){e=e||0;var s=new ee(t);if(s.setUint32(e,this.id,!0),e+=4,s.setUint64(e,this.size,!0),e+=8,this.data&&this.data.byteLength>0)for(var a=new Uint8Array(this.data),g=0;g<a.length;g++,e++)s.setUint8(e,a[g])},buffer_size:function(){return 12+this.size}};function cn(t,e){this.from_buffer(t,e)}cn.prototype={from_buffer:function(t,e){e=e||0;var s,a=new ee(t);for(this.time_stamp=a.getUint64(e,!0),e+=8,this.severity=a.getUint32(e,!0),e+=4,this.visibility=a.getUint32(e,!0),e+=4,this.what=a.getUint32(e,!0),e+=4,this.message_len=a.getUint32(e,!0),e+=4,this.message="",s=0;s<this.message_len;s++){var g=a.getUint8(e,!0);e++,this.message+=String.fromCharCode(g)}}};function hn(){this.pixmap_cache_id=1,this.glz_dictionary_id=0,this.pixmap_cache_size=10*1024*1024,this.glz_dictionary_window_size=0}hn.prototype={to_buffer:function(t,e){e=e||0;var s=new ee(t);s.setUint8(e,this.pixmap_cache_id,!0),e++,s.setUint64(e,this.pixmap_cache_size,!0),e+=8,s.setUint8(e,this.glz_dictionary_id,!0),e++,s.setUint32(e,this.glz_dictionary_window_size,!0),e+=4},buffer_size:function(){return 14}};function Tt(){}Tt.prototype={from_dv:function(t,e,s){return this.surface_id=t.getUint32(e,!0),e+=4,this.box=new st,e=this.box.from_dv(t,e,s),this.clip=new os,this.clip.from_dv(t,e,s)}};function ln(t,e){this.from_buffer(t,e)}ln.prototype={from_buffer:function(t,e){e=e||0;var s=new ee(t);return this.base=new Tt,e=this.base.from_dv(s,e,t),this.data=new Hr,this.data.from_dv(s,e,t)}};function un(t,e){this.from_buffer(t,e)}un.prototype={from_buffer:function(t,e){e=e||0;var s=new ee(t);return this.base=new Tt,e=this.base.from_dv(s,e,t),this.data=new Fr,this.data.from_dv(s,e,t)}};function dn(t,e){this.from_buffer(t,e)}dn.prototype={from_buffer:function(t,e){e=e||0;var s=new ee(t);return this.base=new Tt,e=this.base.from_dv(s,e,t),this.src_pos=new cs,this.src_pos.from_dv(s,e,t)}};function _n(t,e){this.from_buffer(t,e)}_n.prototype={from_buffer:function(t,e){e=e||0;var s=new ee(t);return this.surface=new Gr,this.surface.from_dv(s,e,t)}};function fn(t,e){this.from_buffer(t,e)}fn.prototype={from_buffer:function(t,e){e=e||0;var s=new ee(t);this.surface_id=s.getUint32(e,!0),e+=4}};function pn(t,e){this.from_buffer(t,e)}pn.prototype={from_buffer:function(t,e){e=e||0;var s=new ee(t);return this.keyboard_modifiers=s.getUint16(e,!0),e+=2,e}};function mn(t,e){this.from_buffer(t,e)}mn.prototype={from_buffer:function(t,e){e=e||0;var s=new ee(t);return this.keyboard_modifiers=s.getUint16(e,!0),e+=2,e}};function gn(t,e){this.from_buffer(t,e)}gn.prototype={from_buffer:function(t,e,s){e=e||0;var a=new ee(t);return this.position=new ei,e=this.position.from_dv(a,e,s),this.trail_length=a.getUint16(e,!0),e+=2,this.trail_frequency=a.getUint16(e,!0),e+=2,this.visible=a.getUint8(e,!0),e++,this.cursor=new ti,this.cursor.from_dv(a,e,t)}};function vn(t,e){this.from_buffer(t,e)}vn.prototype={from_buffer:function(t,e,s){e=e||0;var a=new ee(t);return this.time=a.getUint32(e,!0),e+=4,t.byteLength>e&&(this.data=t.slice(e),e+=this.data.byteLength),e}};function Sn(t,e){this.from_buffer(t,e)}Sn.prototype={from_buffer:function(t,e,s){e=e||0;var a=new ee(t);return this.time=a.getUint32(e,!0),e+=4,this.mode=a.getUint16(e,!0),e+=2,t.byteLength>e&&(this.data=t.slice(e),e+=this.data.byteLength),e}};function bn(t,e){this.from_buffer(t,e)}bn.prototype={from_buffer:function(t,e,s){e=e||0;var a=new ee(t);return this.channels=a.getUint32(e,!0),e+=4,this.format=a.getUint16(e,!0),e+=2,this.frequency=a.getUint32(e,!0),e+=4,this.time=a.getUint32(e,!0),e+=4,e}};function Cn(t,e){this.from_buffer(t,e)}Cn.prototype={from_buffer:function(t,e,s){e=e||0;var a=new ee(t);return this.position=new ei,e=this.position.from_dv(a,e,s),this.visible=a.getUint8(e,!0),e++,this.cursor=new ti,this.cursor.from_dv(a,e,t)}};function En(t){const e=document.getElementById(t.screen_id),s=e==null?void 0:e.clientWidth,a=e==null?void 0:e.firstChild.width;return!a||!s?1:s>0&&a>s?a/s:1}function us(t,e){if(this.display_id=0,this.buttons_state=t.buttons_state,e){const s=En(t);this.x=e.offsetX*s,this.y=e.offsetY*s,t.mousex=e.offsetX*s,t.mousey=e.offsetY*s}else this.x=this.y=this.buttons_state=0}us.prototype={to_buffer:function(t,e){e=e||0;var s=new ee(t);return s.setUint32(e,this.x,!0),e+=4,s.setUint32(e,this.y,!0),e+=4,s.setUint16(e,this.buttons_state,!0),e+=2,s.setUint8(e,this.display_id,!0),e+=1,e},buffer_size:function(){return 11}};function ri(t,e){if(this.display_id=0,this.buttons_state=t.buttons_state,e){const s=En(t);this.x=e.offsetX*s,this.y=e.offsetY*s,t.mousex!==void 0&&(this.x-=t.mousex*s,this.y-=t.mousey*s),t.mousex=e.offsetX*s,t.mousey=e.offsetY*s}else this.x=this.y=this.buttons_state=0}ri.prototype.to_buffer=us.prototype.to_buffer;ri.prototype.buffer_size=us.prototype.buffer_size;function Rt(t,e){e?(this.button=e.button+1,this.buttons_state=1<<e.button,t.buttons_state=this.buttons_state):(this.button=R.SPICE_MOUSE_BUTTON_LEFT,this.buttons_state=R.SPICE_MOUSE_BUTTON_MASK_LEFT)}Rt.prototype={to_buffer:function(t,e){e=e||0;var s=new ee(t);return s.setUint8(e,this.button,!0),e++,s.setUint16(e,this.buttons_state,!0),e+=2,e},buffer_size:function(){return 3}};function ds(t,e){e?(this.button=e.button+1,this.buttons_state=0,t.buttons_state=this.buttons_state):(this.button=R.SPICE_MOUSE_BUTTON_LEFT,this.buttons_state=0)}ds.prototype.to_buffer=Rt.prototype.to_buffer;ds.prototype.buffer_size=Rt.prototype.buffer_size;function _t(t){t?this.code=Uh(t.keyCode,t.code):this.code=0}_t.prototype={to_buffer:function(t,e){e=e||0;var s=new ee(t);return s.setUint32(e,this.code,!0),e+=4,e},buffer_size:function(){return 4}};function _s(t){t?this.code=jh(t.keyCode,t.code):this.code=0}_s.prototype.to_buffer=_t.prototype.to_buffer;_s.prototype.buffer_size=_t.prototype.buffer_size;function yn(t,e){this.from_buffer(t,e)}yn.prototype={from_buffer:function(t,e){e=e||0;var s=new ee(t);this.surface_id=s.getUint32(e,!0),e+=4,this.id=s.getUint32(e,!0),e+=4,this.flags=s.getUint8(e,!0),e+=1,this.codec_type=s.getUint8(e,!0),e+=1,this.stamp=s.getUint64(e,!0),e+=8,this.stream_width=s.getUint32(e,!0),e+=4,this.stream_height=s.getUint32(e,!0),e+=4,this.src_width=s.getUint32(e,!0),e+=4,this.src_height=s.getUint32(e,!0),e+=4,this.dest=new st,e=this.dest.from_dv(s,e,t),this.clip=new os,this.clip.from_dv(s,e,t)}};function ni(t,e){}ni.prototype={from_dv:function(t,e,s){return this.id=t.getUint32(e,!0),e+=4,this.multi_media_time=t.getUint32(e,!0),e+=4,e}};function wn(t,e){this.from_buffer(t,e)}wn.prototype={from_buffer:function(t,e){e=e||0;var s=new ee(t);this.base=new ni,e=this.base.from_dv(s,e,t),this.data_size=s.getUint32(e,!0),e+=4,this.data=s.u8.subarray(e,e+this.data_size)}};function xn(t,e){this.from_buffer(t,e)}xn.prototype={from_buffer:function(t,e){e=e||0;var s=new ee(t);this.base=new ni,e=this.base.from_dv(s,e,t),this.width=s.getUint32(e,!0),e+=4,this.height=s.getUint32(e,!0),e+=4,this.dest=new st,e=this.dest.from_dv(s,e,t),this.data_size=s.getUint32(e,!0),e+=4,this.data=s.u8.subarray(e,e+this.data_size)}};function In(t,e){this.from_buffer(t,e)}In.prototype={from_buffer:function(t,e){e=e||0;var s=new ee(t);this.id=s.getUint32(e,!0),e+=4,this.clip=new os,this.clip.from_dv(s,e,t)}};function An(t,e){this.from_buffer(t,e)}An.prototype={from_buffer:function(t,e){e=e||0;var s=new ee(t);this.id=s.getUint32(e,!0),e+=4}};function Pn(t,e){this.from_buffer(t,e)}Pn.prototype={from_buffer:function(t,e){e=e||0;var s=new ee(t);this.stream_id=s.getUint32(e,!0),e+=4,this.unique_id=s.getUint32(e,!0),e+=4,this.max_window_size=s.getUint32(e,!0),e+=4,this.timeout_ms=s.getUint32(e,!0),e+=4}};function Ln(t,e){this.stream_id=t,this.unique_id=e,this.start_frame_mm_time=0,this.end_frame_mm_time=0,this.num_frames=0,this.num_drops=0,this.last_frame_delay=0,this.audio_delay=-1}Ln.prototype={to_buffer:function(t,e){e=e||0;var s=new ee(t);return s.setUint32(e,this.stream_id,!0),e+=4,s.setUint32(e,this.unique_id,!0),e+=4,s.setUint32(e,this.start_frame_mm_time,!0),e+=4,s.setUint32(e,this.end_frame_mm_time,!0),e+=4,s.setUint32(e,this.num_frames,!0),e+=4,s.setUint32(e,this.num_drops,!0),e+=4,s.setUint32(e,this.last_frame_delay,!0),e+=4,s.setUint32(e,this.audio_delay,!0),e+=4,e},buffer_size:function(){return 8*4}};function Dn(t,e){this.count=0,this.resources=[],this.from_buffer(t,e)}Dn.prototype={from_buffer:function(t,e){var s;e=e||0;var a=new ee(t);for(this.count=a.getUint16(e,!0),e+=2,s=0;s<this.count;s++)this.resources[s]={},this.resources[s].type=a.getUint8(e,!0),e++,this.resources[s].id=a.getUint64(e,!0),e+=8}};function Mn(t,e){this.from_buffer(t,e)}Mn.prototype={from_buffer:function(t,e){e=e||0;var s=new ee(t),a=s.getUint32(e,!0);e+=4;var g=s.getUint32(e,!0);e+=4,this.opened=s.getUint8(e,!0),e+=1,this.name=t.slice(g,g+a-1)}};var Tn=Array(256),Rn=0;function Hh(){var t,e,s;for(e=0;e<256;e++){for(t=e,s=0;s<8;s++)t&1?t=(3988292384^t>>>1)>>>0&4294967295:t=t>>>1;Tn[e]=t}Rn=1}function Kh(t,e,s,a){var g=t,w;for(Rn||Hh(),w=0;w<a;w++)g=Tn[(g^e[s+w])&255]^g>>>8;return g}function Gh(t,e,s){return Kh(4294967295,t,e,s)^4294967295}function oi(t,e,s){var a=new Uint8Array(t);return Gh(a,e,s)}function kn(t,e){this.width=t,this.height=e,this.depth=8,this.type=6,this.compression=0,this.filter=0,this.interlace=0}kn.prototype={to_buffer:function(t,e){e=e||0;var s=e,a=new ee(t);return a.setUint32(e,this.buffer_size()-12),e+=4,a.setUint8(e,73),e++,a.setUint8(e,72),e++,a.setUint8(e,68),e++,a.setUint8(e,82),e++,a.setUint32(e,this.width),e+=4,a.setUint32(e,this.height),e+=4,a.setUint8(e,this.depth),e++,a.setUint8(e,this.type),e++,a.setUint8(e,this.compression),e++,a.setUint8(e,this.filter),e++,a.setUint8(e,this.interlace),e++,a.setUint32(e,oi(t,s+4,this.buffer_size()-8)),e+=4,e},buffer_size:function(){return 25}};function Bn(){this.s1=1,this.s2=0}Bn.prototype.update=function(t){this.s1+=t,this.s1%=65521,this.s2+=this.s1,this.s2%=65521};function On(t,e,s){if(s.byteLength>65535)throw new Error("Cannot handle more than 64K");this.data=s,this.width=t,this.height=e}On.prototype={to_buffer:function(t,e){e=e||0;var s=e,a,g,w,y=new ee(t),r=new Bn;y.setUint32(e,this.buffer_size()-12),e+=4,y.setUint8(e,73),e++,y.setUint8(e,68),e++,y.setUint8(e,65),e++,y.setUint8(e,84),e++,y.setUint8(e,120),e++,y.setUint8(e,1),e++,y.setUint8(e,128),e++,y.setUint16(e,this.data.byteLength+this.height),e+=2,y.setUint16(e,~(this.data.byteLength+this.height)),e+=2;var n=new Uint8Array(this.data);for(w=0,g=0;g<this.height;g++)for(y.setUint8(e,0),e++,r.update(0),a=0;a<this.width&&w<this.data.byteLength;a++)r.update(n[w]),y.setUint8(e,n[w++]),e++,r.update(n[w]),y.setUint8(e,n[w++]),e++,r.update(n[w]),y.setUint8(e,n[w++]),e++,r.update(n[w]),y.setUint8(e,n[w++]),e++;return y.setUint16(e,r.s2),e+=2,y.setUint16(e,r.s1),e+=2,y.setUint32(e,oi(t,s+4,this.buffer_size()-8)),e+=4,e},buffer_size:function(){return 12+this.data.byteLength+this.height+4+2+1+2+2}};function Nn(){}Nn.prototype={to_buffer:function(t,e){e=e||0;var s=e,a=new ee(t);return a.setUint32(e,this.buffer_size()-12),e+=4,a.setUint8(e,73),e++,a.setUint8(e,69),e++,a.setUint8(e,78),e++,a.setUint8(e,68),e++,a.setUint32(e,oi(t,s+4,this.buffer_size()-8)),e+=4,e},buffer_size:function(){return 12}};function Yh(t,e,s){var a,g=new kn(t,e),w=new On(t,e,s),y=new Nn,r=new ArrayBuffer(g.buffer_size()+w.buffer_size()+y.buffer_size()),n=g.to_buffer(r);n=w.to_buffer(r,n),n=y.to_buffer(r,n);var u=new Uint8Array(r),m="";for(a=0;a<n;a++)m+="%",u[a]<16&&(m+="0"),m+=u[a].toString(16);return"%89PNG%0D%0A%1A%0A"+m}var ve={cursors:new Array,unknown_cursors:new Array,warned:!1,add_cursor:function(t,e){ve.cursors[t]=e},unknown_cursor:function(t,e){ve.warned||(ve.warned=!0,alert(`Internet Explorer does not support dynamic cursors. This page will now simulate cursors with images, which will be imperfect. We recommend using Chrome or Firefox instead. If you need to use Internet Explorer, you can create a static cursor file for each cursor your application uses. View the console log for more information on creating static cursors for your environment.`)),ve.unknown_cursors[t]||(ve.unknown_cursors[t]=e,console.log("Unknown cursor. Simulation required. To avoid simulation for this cursor, create and include a custom javascript file, and add the following line:"),console.log('SpiceCursorSimulator.add_cursor("'+t+'"), "<your filename here>.cur");'),console.log("And then run following command, redirecting output into <your filename here>.cur:"),console.log(`php -r "echo urldecode('`+e+`');"`))},simulate_cursor:function(t,e,s,a){var g=ph(a+" "+e.header.hot_spot_x+" "+e.header.hot_spot_y);if(typeof ve.cursors<"u"&&typeof ve.cursors[g]<"u"){var w="url("+ve.cursors[g]+"), default";s.style.cursor=w}window.getComputedStyle(s,null).cursor=="auto"?(ve.unknown_cursor(g,ve.create_icondir(e.header.width,e.header.height,e.data.byteLength,e.header.hot_spot_x,e.header.hot_spot_y)+a),document.getElementById(t.parent.screen_id).style.cursor="none",t.spice_simulated_cursor||(t.spice_simulated_cursor=document.createElement("img"),t.spice_simulated_cursor.style.position="absolute",t.spice_simulated_cursor.style.display="none",t.spice_simulated_cursor.style.overflow="hidden",t.spice_simulated_cursor.spice_screen=document.getElementById(t.parent.screen_id),t.spice_simulated_cursor.addEventListener("mousemove",ve.handle_sim_mousemove),t.spice_simulated_cursor.spice_screen.appendChild(t.spice_simulated_cursor)),t.spice_simulated_cursor.src="data:image/png,"+a,t.spice_simulated_cursor.spice_hot_x=e.header.hot_spot_x,t.spice_simulated_cursor.spice_hot_y=e.header.hot_spot_y,t.spice_simulated_cursor.style.pointerEvents="none"):t.spice_simulated_cursor&&(t.spice_simulated_cursor.spice_screen.removeChild(t.spice_simulated_cursor),delete t.spice_simulated_cursor)},handle_sim_mousemove:function(t){var e=ve.duplicate_mouse_event(t,this.spice_screen);return this.spice_screen.dispatchEvent(e)},duplicate_mouse_event:function(t,e){var s=document.createEvent("mouseevent");return s.initMouseEvent(t.type,!0,!0,t.view,t.detail,t.screenX,t.screenY,t.clientX,t.clientY,t.ctrlKey,t.altKey,t.shiftKey,t.metaKey,t.button,t.relatedTarget),s},ICONDIR:function(){},ICONDIRENTRY:function(t,e,s,a,g){this.width=t,this.height=e,this.bytes=s,this.hot_x=a,this.hot_y=g},create_icondir:function(t,e,s,a,g){var w,y=new ve.ICONDIR,r=new ve.ICONDIRENTRY(t,e,s,a,g),n=new ArrayBuffer(y.buffer_size()+r.buffer_size()),u=y.to_buffer(n);u=r.to_buffer(n,u);var m=new Uint8Array(n),l="";for(w=0;w<u;w++)l+="%",m[w]<16&&(l+="0"),l+=m[w].toString(16);return l}};ve.ICONDIR.prototype={to_buffer:function(t,e){e=e||0;var s=new ee(t);return s.setUint16(e,0,!0),e+=2,s.setUint16(e,2,!0),e+=2,s.setUint16(e,1,!0),e+=2,e},buffer_size:function(){return 6}};ve.ICONDIRENTRY.prototype={to_buffer:function(t,e){e=e||0;var s=new ee(t);return s.setUint8(e,this.width),e++,s.setUint8(e,this.height),e++,s.setUint8(e,0),e++,s.setUint8(e,0),e++,s.setUint16(e,this.hot_x,!0),e+=2,s.setUint16(e,this.hot_y,!0),e+=2,s.setUint32(e,this.bytes,!0),e+=4,s.setUint32(e,e+4,!0),e+=4,e},buffer_size:function(){return 16}};function ai(t,e){this.sc=t,this.callback=e,this.needed=0,this.size=0,this.buffers=[],this.sc.ws.wire_reader=this,this.sc.ws.binaryType="arraybuffer",this.sc.ws.addEventListener("message",zh)}ai.prototype={inbound:function(t){if(this.needed==0){this.buffers.push(t),this.size+=t.byteLength;return}for(this.buffers.length==0&&t.byteLength>=this.needed?(t.byteLength>this.needed&&(this.size=t.byteLength-this.needed,this.buffers.push(t.slice(this.needed)),t=t.slice(0,this.needed)),this.callback.call(this.sc,t,this.saved_msg_header||void 0)):(this.buffers.push(t),this.size+=t.byteLength);this.size>=this.needed;){for(var e=0,s=new ArrayBuffer(this.needed),a=new Uint8Array(s);e<s.byteLength&&this.buffers.length>0;){var g=this.buffers.shift();if(!g)return;var w=new Uint8Array(g),y=s.byteLength-e;if(w.length<=y)a.set(w,e),e+=w.length,this.size-=w.length;else{var r=w.slice(0,y);a.set(r,e),e+=r.length,this.size-=r.length,this.buffers.unshift(w.slice(y))}}this.callback.call(this.sc,s,this.saved_msg_header||void 0)}},request:function(t){this.needed=t},save_header:function(t){this.saved_msg_header=t},clear_header:function(){this.saved_msg_header=void 0}};function zh(t){ai.prototype.inbound.call(this.wire_reader,t.data)}var Wh=[26,69,223,163],$h=[66,134],Vh=[66,247],qh=[66,242],Xh=[66,243],Qh=[66,130],Zh=[66,135],Jh=[66,133],el=[24,83,128,103],Un=[21,73,169,102],ji=[42,215,177],Fi=[77,128],Hi=[87,65],tl=[17,77,155,116],sl=[77,187],Ki=[83,171],Gi=[83,172],jn=[22,84,174,107],Fn=[174],Gt=[215],Yt=[115,197],zt=[131],Wt=[185],$t=[136],Vt=[85,170],qt=[156],Xt=[109,231],Qt=[85,238],Zt=[170],Jt=[86,187],Yi=[86,170],zi=[99,162],es=[134],il=[224],Wi=[154],$i=[176],Vi=[186],rl=[225],qi=[181],Xi=[159],nl=[31,67,182,117],Qi=[231],ol=[163],de={CLUSTER_SIMPLEBLOCK_FLAG_KEYFRAME:128,OPUS_FREQUENCY:48e3,OPUS_CHANNELS:2,SPICE_PLAYBACK_CODEC:'audio/webm; codecs="opus"',MAX_CLUSTER_TIME:1e3,EXPECTED_PACKET_DURATION:10,GAP_DETECTION_THRESHOLD:50,SPICE_VP8_CODEC:'video/webm; codecs="vp8"'};function it(t,e,s){var a=128|t;return e.setUint8(s,a),s+1}function ae(t,e,s,a){return a=me(t,s,a),a=it(1,s,a),s.setUint8(a,e),a+1}function At(t,e,s,a){return a=me(t,s,a),a=it(4,s,a),s.setUint32(a,e),a+4}function js(t,e,s,a){return a=me(t,s,a),a=it(2,s,a),s.setUint16(a,e),a+2}function al(t,e,s,a){return a=me(t,s,a),a=it(4,s,a),s.setFloat32(a,e),a+4}function He(t,e,s){e.setUint8(s++,1),e.setUint8(s++,0),e.setUint8(s++,0),e.setUint8(s++,0);for(var a=t&4294967295,g=24;g>=0;g-=8)e.setUint8(s++,a>>g);return s}function me(t,e,s){for(var a=0;a<t.length;a++)e.setUint8(s+a,t[a]);return s+t.length}function cl(t,e,s){for(var a=0;a<t.length;a++)e.setUint8(s+a,t.charCodeAt(a));return s+t.length}function et(t,e,s,a){return a=me(t,s,a),e.length<127?a=it(e.length,s,a):a=He(e.length,s,a),typeof e=="string"?a=cl(e,s,a):a=me(e,s,a),a}function Hn(){this.id=Wh,this.Version=1,this.ReadVersion=1,this.MaxIDLength=4,this.MaxSizeLength=8,this.DocType="webm",this.DocTypeVersion=2,this.DocTypeReadVersion=2}Hn.prototype={to_buffer:function(t,e){e=e||0;var s=new DataView(t);return e=me(this.id,s,e),e=He(31,s,e),e=ae($h,this.Version,s,e),e=ae(Vh,this.ReadVersion,s,e),e=ae(qh,this.MaxIDLength,s,e),e=ae(Xh,this.MaxSizeLength,s,e),e=et(Qh,this.DocType,s,e),e=ae(Zh,this.DocTypeVersion,s,e),e=ae(Jh,this.DocTypeReadVersion,s,e),e},buffer_size:function(){return 39+this.id.length}};function Kn(){this.id=el}Kn.prototype={to_buffer:function(t,e){e=e||0;var s=new DataView(t);return e=me(this.id,s,e),s.setUint8(e++,255),e},buffer_size:function(){return this.id.length+1}};function Gn(){this.id=Un,this.timecode_scale=1e6,this.muxing_app="spice",this.writing_app="spice-html5"}Gn.prototype={to_buffer:function(t,e){e=e||0;var s=new DataView(t);return e=me(this.id,s,e),e=He(this.buffer_size()-8-this.id.length,s,e),e=At(ji,this.timecode_scale,s,e),e=et(Fi,this.muxing_app,s,e),e=et(Hi,this.writing_app,s,e),e},buffer_size:function(){return this.id.length+8+ji.length+1+4+Fi.length+1+this.muxing_app.length+Hi.length+1+this.writing_app.length}};function Yn(t){this.id=rl,this.sampling_frequency=t,this.channels=de.OPUS_CHANNELS}Yn.prototype={to_buffer:function(t,e){e=e||0;var s=new DataView(t);return e=me(this.id,s,e),e=He(this.buffer_size()-8-this.id.length,s,e),e=ae(Xi,this.channels,s,e),e=al(qi,this.sampling_frequency,s,e),e},buffer_size:function(){return this.id.length+8+qi.length+1+4+Xi.length+1+1}};function zn(t,e){this.id=il,this.flag_interlaced=0,this.width=t,this.height=e}zn.prototype={to_buffer:function(t,e){e=e||0;var s=new DataView(t);return e=me(this.id,s,e),e=He(this.buffer_size()-8-this.id.length,s,e),e=ae(Wi,this.flag_interlaced,s,e),e=js($i,this.width,s,e),e=js(Vi,this.height,s,e),e},buffer_size:function(){return this.id.length+8+Wi.length+1+1+$i.length+1+2+Vi.length+1+2}};function Fs(t,e){this.id=sl,this.pos=e,this.seekid=t}Fs.prototype={to_buffer:function(t,e){e=e||0;var s=new DataView(t);return e=me(this.id,s,e),e=it(this.buffer_size()-1-this.id.length,s,e),e=et(Ki,this.seekid,s,e),e=js(Gi,this.pos,s,e),e},buffer_size:function(){return this.id.length+1+Ki.length+1+this.seekid.length+Gi.length+1+2}};function Wn(t,e){this.id=tl,this.info=new Fs(Un,t),this.track=new Fs(jn,e)}Wn.prototype={to_buffer:function(t,e){e=e||0;var s=new DataView(t);return e=me(this.id,s,e),e=He(this.buffer_size()-8-this.id.length,s,e),e=this.info.to_buffer(t,e),e=this.track.to_buffer(t,e),e},buffer_size:function(){return this.id.length+8+this.info.buffer_size()+this.track.buffer_size()}};function $n(){this.id=Fn,this.number=1,this.uid=2,this.type=2,this.flag_enabled=1,this.flag_default=1,this.flag_forced=1,this.flag_lacing=0,this.min_cache=0,this.max_block_addition_id=0,this.codec_decode_all=0,this.seek_pre_roll=0,this.codec_delay=8e7,this.codec_id="A_OPUS",this.audio=new Yn(de.OPUS_FREQUENCY),this.codec_private=[79,112,117,115,72,101,97,100,1,de.OPUS_CHANNELS,0,15,128,187,0,0,0,0,0]}$n.prototype={to_buffer:function(t,e){e=e||0;var s=new DataView(t);return e=me(this.id,s,e),e=He(this.buffer_size()-8-this.id.length,s,e),e=ae(Gt,this.number,s,e),e=ae(Yt,this.uid,s,e),e=ae(Wt,this.flag_enabled,s,e),e=ae($t,this.flag_default,s,e),e=ae(Vt,this.flag_forced,s,e),e=ae(qt,this.flag_lacing,s,e),e=et(es,this.codec_id,s,e),e=ae(Xt,this.min_cache,s,e),e=ae(Qt,this.max_block_addition_id,s,e),e=ae(Zt,this.codec_decode_all,s,e),e=At(Yi,this.codec_delay,s,e),e=At(Jt,this.seek_pre_roll,s,e),e=ae(zt,this.type,s,e),e=et(zi,this.codec_private,s,e),e=this.audio.to_buffer(t,e),e},buffer_size:function(){return this.id.length+8+Gt.length+1+1+Yt.length+1+1+zt.length+1+1+Wt.length+1+1+$t.length+1+1+Vt.length+1+1+qt.length+1+1+Xt.length+1+1+Qt.length+1+1+Zt.length+1+1+Jt.length+1+4+Yi.length+1+4+es.length+this.codec_id.length+1+zi.length+1+this.codec_private.length+this.audio.buffer_size()}};function Vn(t,e){this.id=Fn,this.number=1,this.uid=1,this.type=1,this.flag_enabled=1,this.flag_default=1,this.flag_forced=1,this.flag_lacing=1,this.min_cache=0,this.max_block_addition_id=0,this.codec_id="V_VP8",this.codec_decode_all=1,this.seek_pre_roll=0,this.video=new zn(t,e)}Vn.prototype={to_buffer:function(t,e){e=e||0;var s=new DataView(t);return e=me(this.id,s,e),e=He(this.buffer_size()-8-this.id.length,s,e),e=ae(Gt,this.number,s,e),e=ae(Yt,this.uid,s,e),e=ae(Wt,this.flag_enabled,s,e),e=ae($t,this.flag_default,s,e),e=ae(Vt,this.flag_forced,s,e),e=ae(qt,this.flag_lacing,s,e),e=et(es,this.codec_id,s,e),e=ae(Xt,this.min_cache,s,e),e=ae(Qt,this.max_block_addition_id,s,e),e=ae(Zt,this.codec_decode_all,s,e),e=At(Jt,this.seek_pre_roll,s,e),e=ae(zt,this.type,s,e),e=this.video.to_buffer(t,e),e},buffer_size:function(){return this.id.length+8+Gt.length+1+1+Yt.length+1+1+Wt.length+1+1+$t.length+1+1+Vt.length+1+1+qt.length+1+1+es.length+this.codec_id.length+1+Xt.length+1+1+Qt.length+1+1+Zt.length+1+1+Jt.length+1+4+zt.length+1+1+this.video.buffer_size()}};function ci(t){this.id=jn,this.track_entry=t}ci.prototype={to_buffer:function(t,e){e=e||0;var s=new DataView(t);return e=me(this.id,s,e),e=He(this.buffer_size()-8-this.id.length,s,e),e=this.track_entry.to_buffer(t,e),e},buffer_size:function(){return this.id.length+8+this.track_entry.buffer_size()}};function hi(t,e){this.id=nl,this.timecode=t,this.data=e}hi.prototype={to_buffer:function(t,e){e=e||0;var s=new DataView(t);return e=me(this.id,s,e),s.setUint8(e++,255),e=At(Qi,this.timecode,s,e),e},buffer_size:function(){return this.id.length+1+Qi.length+1+4}};function li(t,e,s){this.id=ol,this.timecode=t,this.data=e,this.keyframe=s}li.prototype={to_buffer:function(t,e){e=e||0;var s=new DataView(t);e=me(this.id,s,e),e=He(this.data.byteLength+4,s,e),e=it(1,s,e),s.setUint16(e,this.timecode),e+=2,s.setUint8(e,this.keyframe?de.CLUSTER_SIMPLEBLOCK_FLAG_KEYFRAME:0),e+=1;for(var a=new Uint8Array(this.data),g=0;g<this.data.byteLength;g++)s.setUint8(e++,a[g]);return e},buffer_size:function(){return this.id.length+8+1+2+1+this.data.byteLength}};function ui(){this.ebml=new Hn,this.segment=new Kn,this.seek_head=new Wn(0,0),this.seek_head.info.pos=this.segment.buffer_size()+this.seek_head.buffer_size(),this.info=new Gn,this.seek_head.track.pos=this.seek_head.info.pos+this.info.buffer_size()}ui.prototype={to_buffer:function(t,e){return e=e||0,e=this.ebml.to_buffer(t,e),e=this.segment.to_buffer(t,e),e=this.info.to_buffer(t,e),e},buffer_size:function(){return this.ebml.buffer_size()+this.segment.buffer_size()+this.info.buffer_size()}};function ye(t){if(t===void 0||t.uri===void 0||!t.uri)throw new Error("You must specify a uri");if(this.ws=new WebSocket(t.uri),!this.ws.binaryType)throw new Error("WebSocket doesn't support binaryType. Try a different browser.");if(this.connection_id=t.connection_id!==void 0?t.connection_id:0,this.type=t.type!==void 0?t.type:R.SPICE_CHANNEL_MAIN,this.chan_id=t.chan_id!==void 0?t.chan_id:0,t.parent!==void 0&&(this.parent=t.parent,this.message_id=t.parent.message_id,this.password=t.parent.password),t.screen_id!==void 0&&(this.screen_id=t.screen_id),t.dump_id!==void 0&&(this.dump_id=t.dump_id),t.message_id!==void 0&&(this.message_id=t.message_id),t.password!==void 0&&(this.password=t.password),t.onerror!==void 0&&(this.onerror=t.onerror),t.onsuccess!==void 0&&(this.onsuccess=t.onsuccess),t.onagent!==void 0&&(this.onagent=t.onagent),this.state="connecting",this.ws.parent=this,this.wire_reader=new ai(this,this.process_inbound),this.messages_sent=0,this.warnings=[],this.ws.addEventListener("open",function(e){this.parent.send_hdr(),this.parent.wire_reader.request(Kt.prototype.buffer_size()),this.parent.state="start"}),this.ws.addEventListener("error",function(e){"url"in e.target&&this.parent.log_err("WebSocket error: Can't connect to websocket on URL: "+e.target.url),this.parent.report_error(e)}),this.ws.addEventListener("close",function(e){if(this.parent.state!="closing"&&this.parent.state!="error"&&this.parent.onerror!==void 0){var e;this.parent.state=="connecting"?e=new Error("Connection refused."):this.parent.state=="start"||this.parent.state=="link"?e=new Error("Unexpected protocol mismatch."):this.parent.state=="ticket"?e=new Error("Bad password."):e=new Error("Unexpected close while "+this.parent.state),this.parent.onerror(e),this.parent.log_err(e.toString())}}),this.ws.readyState==2||this.ws.readyState==3)throw new Error("Unable to connect to "+t.uri);this.timeout=window.setTimeout(hl,R.SPICE_CONNECT_TIMEOUT,this)}ye.prototype={send_hdr:function(){var t=new Kt,e=new Wr;if(e.connection_id=this.connection_id,e.channel_type=this.type,e.channel_id=this.chan_id,e.common_caps.push(1<<R.SPICE_COMMON_CAP_PROTOCOL_AUTH_SELECTION|1<<R.SPICE_COMMON_CAP_MINI_HEADER),e.channel_type==R.SPICE_CHANNEL_PLAYBACK){var s=0;"MediaSource"in window&&MediaSource.isTypeSupported(de.SPICE_PLAYBACK_CODEC)&&(s|=1<<R.SPICE_PLAYBACK_CAP_OPUS),e.channel_caps.push(s)}else if(e.channel_type==R.SPICE_CHANNEL_MAIN)e.channel_caps.push(1<<R.SPICE_MAIN_CAP_AGENT_CONNECTED_TOKENS);else if(e.channel_type==R.SPICE_CHANNEL_DISPLAY){var s=1<<R.SPICE_DISPLAY_CAP_SIZED_STREAM|1<<R.SPICE_DISPLAY_CAP_STREAM_REPORT|1<<R.SPICE_DISPLAY_CAP_MULTI_CODEC|1<<R.SPICE_DISPLAY_CAP_CODEC_MJPEG;"MediaSource"in window&&MediaSource.isTypeSupported(de.SPICE_VP8_CODEC)&&(s|=1<<R.SPICE_DISPLAY_CAP_CODEC_VP8),e.channel_caps.push(s)}t.size=e.buffer_size();var a=new ArrayBuffer(t.buffer_size()+e.buffer_size());t.to_buffer(a),e.to_buffer(a,t.buffer_size()),this.ws.send(a)},send_ticket:function(t){var e=new Vr;e.auth_mechanism=R.SPICE_COMMON_CAP_AUTH_SPICE,e.encrypted_data=t;var s=new ArrayBuffer(e.buffer_size());e.to_buffer(s),this.ws.send(s)},send_msg:function(t){var e=new ArrayBuffer(t.buffer_size());t.to_buffer(e),this.messages_sent++,this.ws.send(e)},process_inbound:function(t,e){if(this.state=="ready")if(e==null){var s=new le(t);s.type>500,s.size==0?(this.process_message(s),this.wire_reader.request(le.prototype.buffer_size())):(this.wire_reader.request(s.size),this.wire_reader.save_header(s))}else e.data=t,this.process_message(e),this.wire_reader.request(le.prototype.buffer_size()),this.wire_reader.save_header(void 0);else if(this.state=="start")if(this.reply_hdr=new Kt(t),this.reply_hdr.magic!=R.SPICE_MAGIC){this.state="error";var a=new Error("Error: magic mismatch: "+this.reply_hdr.magic);this.report_error(a)}else this.wire_reader.request(this.reply_hdr.size),this.state="link";else if(this.state=="link")if(this.reply_link=new $r(t),this.reply_link.error){this.state="error";var a=new Error("Error: reply link error "+this.reply_link.error);this.report_error(a)}else this.send_ticket(xh(this.reply_link.pub_key,this.password+"\0")),this.state="ticket",this.wire_reader.request(Ns.prototype.buffer_size());else if(this.state=="ticket")if(this.auth_reply=new Ns(t),this.auth_reply.auth_code==R.SPICE_LINK_ERR_OK){if(this.type==R.SPICE_CHANNEL_DISPLAY){var g=new hn,w=new le;w.build_msg(R.SPICE_MSGC_DISPLAY_INIT,g),this.send_msg(w)}this.state="ready",this.wire_reader.request(le.prototype.buffer_size()),this.timeout&&(window.clearTimeout(this.timeout),delete this.timeout)}else{if(this.state="error",this.auth_reply.auth_code==R.SPICE_LINK_ERR_PERMISSION_DENIED)var a=new Error("Permission denied.");else var a=new Error("Unexpected link error "+this.auth_reply.auth_code);this.report_error(a)}},process_common_messages:function(t){if(t.type==R.SPICE_MSG_SET_ACK){var e=new Jr(t.data);this.ack_window=e.window,this.msgs_until_ack=this.ack_window;var s=new en(e),a=new le;return a.build_msg(R.SPICE_MSGC_ACK_SYNC,s),this.send_msg(a),!0}if(t.type==R.SPICE_MSG_PING){var g=new le;return g.type=R.SPICE_MSGC_PONG,t.data&&(g.data=t.data.slice(0,12)),g.size=g.buffer_size(),this.send_msg(g),!0}if(t.type==R.SPICE_MSG_NOTIFY){var w=new cn(t.data);return w.severity==R.SPICE_NOTIFY_SEVERITY_ERROR?this.log_err(w.message):w.severity==R.SPICE_NOTIFY_SEVERITY_WARN?this.log_warn(w.message):this.log_info(w.message),!0}return!1},process_message:function(t){var e,s=Date.now();if(e=this.process_common_messages(t),e||(this.process_channel_message?(e=this.process_channel_message(t),e||this.log_warn(this.channel_type()+": Unknown message type "+t.type+"!")):this.log_err(this.channel_type()+": No message handlers for this channel; message "+t.type)),this.msgs_until_ack!==void 0&&this.ack_window&&(this.msgs_until_ack--,this.msgs_until_ack<=0)){this.msgs_until_ack=this.ack_window;var a=new le;a.type=R.SPICE_MSGC_ACK,this.send_msg(a)}var g=Date.now()-s;return g>de.GAP_DETECTION_THRESHOLD&&console.log("delta "+this.channel_type()+":"+t.type+" "+g),e},channel_type:function(){return this.type==R.SPICE_CHANNEL_MAIN?"main":this.type==R.SPICE_CHANNEL_DISPLAY?"display":this.type==R.SPICE_CHANNEL_INPUTS?"inputs":this.type==R.SPICE_CHANNEL_CURSOR?"cursor":this.type==R.SPICE_CHANNEL_PLAYBACK?"playback":this.type==R.SPICE_CHANNEL_RECORD?"record":this.type==R.SPICE_CHANNEL_TUNNEL?"tunnel":this.type==R.SPICE_CHANNEL_SMARTCARD?"smartcard":this.type==R.SPICE_CHANNEL_USBREDIR?"Fusbredir":this.type==R.SPICE_CHANNEL_PORT?"port":this.type==R.SPICE_CHANNEL_WEBDAV?"webdav":"unknown-"+this.type},log_info:function(){var t=Array.prototype.join.call(arguments," ");if(console.log(t),this.message_id){var e=document.createElement("p");e.appendChild(document.createTextNode(t)),e.className+="spice-message-info",document.getElementById(this.message_id).appendChild(e)}},log_warn:function(){var t=Array.prototype.join.call(arguments," ");if(console.log("WARNING: "+t),this.message_id){var e=document.createElement("p");e.appendChild(document.createTextNode(t)),e.className+="spice-message-warning",document.getElementById(this.message_id).appendChild(e)}},log_err:function(){var t=Array.prototype.join.call(arguments," ");if(console.log("ERROR: "+t),this.message_id){var e=document.createElement("p");e.appendChild(document.createTextNode(t)),e.className+="spice-message-error",document.getElementById(this.message_id).appendChild(e)}},known_unimplemented:function(t,e){if(!this.warnings[t]||Bh>1){var s="";s=" [ further notices suppressed ]",this.log_warn("Unimplemented function "+t+"("+e+")"+s),this.warnings[t]=!0}},report_error:function(t){if(this.log_err(t.toString()),this.onerror!=null)this.onerror(t);else throw t},report_success:function(t){this.onsuccess!=null&&this.onsuccess(t)},cleanup:function(){this.timeout&&(window.clearTimeout(this.timeout),delete this.timeout),this.ws&&(this.ws.close(),this.ws=void 0)},handle_timeout:function(){var t=new Error("Connection timed out.");this.report_error(t)}};function hl(t){ye.prototype.handle_timeout.call(t)}function fs(){ye.apply(this,arguments)}fs.prototype=Object.create(ye.prototype);fs.prototype.process_channel_message=function(t){if(t.type==R.SPICE_MSG_CURSOR_INIT){var e=new gn(t.data);return this.parent&&this.parent.inputs&&this.parent.inputs.mouse_mode==R.SPICE_MOUSE_MODE_SERVER&&(this.parent.inputs.mousex=e.position.x,this.parent.inputs.mousey=e.position.y),!0}if(t.type==R.SPICE_MSG_CURSOR_SET){var s=new Cn(t.data);return s.flags&R.SPICE_CURSOR_FLAGS_NONE?(document.getElementById(this.parent.screen_id).style.cursor="none",!0):(s.flags>0&&this.log_warn("FIXME: No support for cursor flags "+s.flags),s.cursor.header.type!=R.SPICE_CURSOR_TYPE_ALPHA?(this.log_warn("FIXME: No support for cursor type "+s.cursor.header.type),!1):(this.set_cursor(s.cursor),!0))}return t.type==R.SPICE_MSG_CURSOR_MOVE?(this.known_unimplemented(t.type,"Cursor Move"),!0):t.type==R.SPICE_MSG_CURSOR_HIDE?(document.getElementById(this.parent.screen_id).style.cursor="none",!0):t.type==R.SPICE_MSG_CURSOR_TRAIL?(this.known_unimplemented(t.type,"Cursor Trail"),!0):t.type==R.SPICE_MSG_CURSOR_RESET?(document.getElementById(this.parent.screen_id).style.cursor="auto",!0):t.type==R.SPICE_MSG_CURSOR_INVAL_ONE?(this.known_unimplemented(t.type,"Cursor Inval One"),!0):t.type==R.SPICE_MSG_CURSOR_INVAL_ALL};fs.prototype.set_cursor=function(t){var e=Yh(t.header.width,t.header.height,t.data),s="url(data:image/png,"+e+") "+t.header.hot_spot_x+" "+t.header.hot_spot_y+", default",a=document.getElementById(this.parent.screen_id);a.style.cursor="auto",a.style.cursor=s,window.getComputedStyle(a,null).cursor=="auto"&&ve.simulate_cursor(this,t,a,e)};function ps(t,e){this.id=t,this.file=e}ps.prototype.create_progressbar=function(){var t=this,e=document.createElement("input");this.progressbar_container=document.createElement("div"),this.progressbar=document.createElement("progress"),e.type="button",e.value="Cancel",e.style.float="right",e.onclick=function(){t.cancelled=!0,t.remove_progressbar()},this.progressbar.setAttribute("max",this.file.size),this.progressbar.setAttribute("value",0),this.progressbar.style.width="100%",this.progressbar.style.margin="4px auto",this.progressbar.style.display="inline-block",this.progressbar_container.style.width="90%",this.progressbar_container.style.margin="auto",this.progressbar_container.style.padding="4px",this.progressbar_container.textContent=this.file.name,this.progressbar_container.appendChild(e),this.progressbar_container.appendChild(this.progressbar),document.getElementById("spice-xfer-area").appendChild(this.progressbar_container)};ps.prototype.update_progressbar=function(t){this.progressbar.setAttribute("value",t)};ps.prototype.remove_progressbar=function(){this.progressbar_container&&this.progressbar_container.parentNode&&this.progressbar_container.parentNode.removeChild(this.progressbar_container)};var nt=-1,Ct=-1,Et=-1,yt=-1;function di(){ye.apply(this,arguments),this.mousex=void 0,this.mousey=void 0,this.button_state=0,this.waiting_for_ack=0}di.prototype=Object.create(ye.prototype);di.prototype.process_channel_message=function(t){if(t.type==R.SPICE_MSG_INPUTS_INIT){var e=new pn(t.data);return this.keyboard_modifiers=e.keyboard_modifiers,!0}if(t.type==R.SPICE_MSG_INPUTS_KEY_MODIFIERS){var s=new mn(t.data);return this.keyboard_modifiers=s.keyboard_modifiers,!0}return t.type==R.SPICE_MSG_INPUTS_MOUSE_MOTION_ACK?(this.waiting_for_ack-=R.SPICE_INPUT_MOTION_ACK_BUNCH,!0):!1};function qn(t){var e=new le,s;this.sc.mouse_mode==R.SPICE_MOUSE_MODE_CLIENT?(s=new us(this.sc,t),e.build_msg(R.SPICE_MSGC_INPUTS_MOUSE_POSITION,s)):(s=new ri(this.sc,t),e.build_msg(R.SPICE_MSGC_INPUTS_MOUSE_MOTION,s)),this.sc&&this.sc.inputs&&this.sc.inputs.state==="ready"&&this.sc.inputs.waiting_for_ack<2*R.SPICE_INPUT_MOTION_ACK_BUNCH&&(this.sc.inputs.send_msg(e),this.sc.inputs.waiting_for_ack++),this.sc&&this.sc.cursor&&this.sc.cursor.spice_simulated_cursor&&(this.sc.cursor.spice_simulated_cursor.style.display="block",this.sc.cursor.spice_simulated_cursor.style.left=t.pageX-this.sc.cursor.spice_simulated_cursor.spice_hot_x+"px",this.sc.cursor.spice_simulated_cursor.style.top=t.pageY-this.sc.cursor.spice_simulated_cursor.spice_hot_y+"px",t.preventDefault())}function Xn(t){var e=new Rt(this.sc,t),s=new le;s.build_msg(R.SPICE_MSGC_INPUTS_MOUSE_PRESS,e),this.sc&&this.sc.inputs&&this.sc.inputs.state==="ready"&&this.sc.inputs.send_msg(s),t.preventDefault()}function Qn(t){return t.preventDefault(),!1}function Zn(t){var e=new ds(this.sc,t),s=new le;s.build_msg(R.SPICE_MSGC_INPUTS_MOUSE_RELEASE,e),this.sc&&this.sc.inputs&&this.sc.inputs.state==="ready"&&this.sc.inputs.send_msg(s),t.preventDefault()}function Jn(t){var e=new Rt,s=new ds;t.deltaY<0?e.button=s.button=R.SPICE_MOUSE_BUTTON_UP:e.button=s.button=R.SPICE_MOUSE_BUTTON_DOWN,e.buttons_state=0,s.buttons_state=0;var a=new le;a.build_msg(R.SPICE_MSGC_INPUTS_MOUSE_PRESS,e),this.sc&&this.sc.inputs&&this.sc.inputs.state==="ready"&&this.sc.inputs.send_msg(a),a.build_msg(R.SPICE_MSGC_INPUTS_MOUSE_RELEASE,s),this.sc&&this.sc.inputs&&this.sc.inputs.state==="ready"&&this.sc.inputs.send_msg(a),t.preventDefault(),window.dispatchEvent(new CustomEvent("spice-wheel",{detail:{wheelEvent:t}}))}function eo(t){var e=new _t(t),s=new le;so(t,e.code,this.sc),s.build_msg(R.SPICE_MSGC_INPUTS_KEY_DOWN,e),this.sc&&this.sc.inputs&&this.sc.inputs.state==="ready"&&this.sc.inputs.send_msg(s),t.preventDefault()}function to(t){var e=new _s(t),s=new le;so(t,e.code,this.sc),s.build_msg(R.SPICE_MSGC_INPUTS_KEY_UP,e),this.sc&&this.sc.inputs&&this.sc.inputs.state==="ready"&&this.sc.inputs.send_msg(s),t.preventDefault()}function _i(t,e){var s=new le,a=new _t;a.code=e,s.build_msg(R.SPICE_MSGC_INPUTS_KEY_DOWN,a),t.inputs.send_msg(s),a.code=128|e,s.build_msg(R.SPICE_MSGC_INPUTS_KEY_UP,a),t.inputs.send_msg(s)}function ll(t){t&&t.inputs&&t.inputs.state==="ready"&&(Re(!0,H.KEY_LCtrl,t),Re(!0,H.KEY_Alt,t),_i(t,H.KEY_KP_Decimal),setTimeout(()=>{Re(!1,H.KEY_LCtrl,t),Re(!1,H.KEY_Alt,t)},100))}function ul(t){t&&t.inputs&&t.inputs.state==="ready"&&(Re(!0,H.KEY_Alt,t),_i(t,H.KEY_F4),setTimeout(()=>{Re(!1,H.KEY_Alt,t)},100))}function dl(t){t&&t.inputs&&t.inputs.state==="ready"&&(Re(!0,H.KEY_Alt,t),_i(t,H.KEY_Tab),setTimeout(()=>{Re(!1,H.KEY_Alt,t)},100))}function Re(t,e,s){var a=new le;if(t){var g=new _t;g.code=e,a.build_msg(R.SPICE_MSGC_INPUTS_KEY_DOWN,g)}else{var g=new _s;g.code=128|e,a.build_msg(R.SPICE_MSGC_INPUTS_KEY_UP,g)}s.inputs.send_msg(a)}function so(t,e,s){nt===-1&&(nt=t.shiftKey,Ct=t.ctrlKey,Et=t.altKey,yt=t.metaKey),e===H.KEY_ShiftL?nt=!0:e===H.KEY_Alt?Et=!0:e===H.KEY_LCtrl?Ct=!0:e===57525?yt=!0:e===(128|H.KEY_ShiftL)?nt=!1:e===(128|H.KEY_Alt)?Et=!1:e===(128|H.KEY_LCtrl)?Ct=!1:e===57525&&(yt=!1),s&&s.inputs&&s.inputs.state==="ready"&&(nt!=t.shiftKey&&(console.log("Shift state out of sync"),Re(t.shiftKey,H.KEY_ShiftL,s),nt=t.shiftKey),Et!=t.altKey&&(console.log("Alt state out of sync"),Re(t.altKey,H.KEY_Alt,s),Et=t.altKey),Ct!=t.ctrlKey&&(console.log("Ctrl state out of sync"),Re(t.ctrlKey,H.KEY_LCtrl,s),Ct=t.ctrlKey),yt!=t.metaKey&&(console.log("Meta state out of sync"),Re(t.metaKey,57525,s),yt=t.metaKey))}function Ms(t,e,s,a,g){var w=e,y=0,r,n=0;for(r=t[w++];y*4<s.length;r=t[w++]){var u=y,m=r>>5,l=(r&31)<<8;if(r>=32){var p;if(m--,m==6)do p=t[w++],m+=p;while(p==255);if(p=t[w++],l+=p,p==255&&l-p==7936&&(l=t[w++]<<8,l+=t[w++],l+=8191),m+=1,a==R.LZ_IMAGE_TYPE_RGBA&&(m+=2),l+=1,u-=l,u==y-1)for(var C=u;m;--m){if(a==R.LZ_IMAGE_TYPE_RGBA)s[y*4+3]=s[C*4+3];else for(n=0;n<4;n++)s[y*4+n]=s[C*4+n];y++}else for(;m;--m){if(a==R.LZ_IMAGE_TYPE_RGBA)s[y*4+3]=s[u*4+3];else for(n=0;n<4;n++)s[y*4+n]=s[u*4+n];y++,u++}}else for(r++,a==R.LZ_IMAGE_TYPE_RGBA?s[y*4+3]=t[w++]:(s[y*4+0]=t[w+2],s[y*4+1]=t[w+1],s[y*4+2]=t[w+0],g&&(s[y*4+3]=255),w+=3),y++,--r;r;r--)a==R.LZ_IMAGE_TYPE_RGBA?s[y*4+3]=t[w++]:(s[y*4+0]=t[w+2],s[y*4+1]=t[w+1],s[y*4+2]=t[w+0],g&&(s[y*4+3]=255),w+=3),y++}return w-1}function _l(t){for(var e=t.width*4,s=t.height,a=s,g=new Uint8Array(t.width*t.height*4);a--;)g.set(t.data.subarray(a*e,(a+1)*e),(s-a-1)*e);t.data.set(g)}function Zi(t,e){var s;if(e.type===R.LZ_IMAGE_TYPE_RGB32||e.type===R.LZ_IMAGE_TYPE_RGBA){var a=new Uint8Array(e.data),g=t.createImageData(e.width,e.height);s=Ms(a,0,g.data,R.LZ_IMAGE_TYPE_RGB32,e.type!=R.LZ_IMAGE_TYPE_RGBA),e.top_down||_l(g),e.type==R.LZ_IMAGE_TYPE_RGBA&&Ms(a,s,g.data,R.LZ_IMAGE_TYPE_RGBA,!1)}else if(e.type===R.LZ_IMAGE_TYPE_XXXA){var a=new Uint8Array(e.data),g=t.createImageData(e.width,e.height);Ms(a,0,g.data,R.LZ_IMAGE_TYPE_RGBA,!1)}else return;return g}function fl(t,e){var s,a,g,w=0,y=0,r=new Uint8Array(e.data);if(!(e.format!=R.SPICE_BITMAP_FMT_32BIT&&e.format!=R.SPICE_BITMAP_FMT_RGBA)){for(e.flags&R.SPICE_BITMAP_FLAGS_TOP_DOWN||(w=(e.y-1)*e.stride,y=2*e.stride),s=t.createImageData(e.x,e.y),a=0;a<e.y*e.stride;w-=y)for(g=0;g<e.x;g++,a+=4,w+=4)s.data[a+0]=r[w+2],s.data[a+1]=r[w+1],s.data[a+2]=r[w+0],e.format==R.SPICE_BITMAP_FMT_32BIT?s.data[a+3]=255:s.data[a+3]=r[w];return s}}function io(t,e,s,a){var g=document.createElement("canvas"),w=g.getContext("2d");g.setAttribute("width",e.width),g.setAttribute("height",e.height),w.putImageData(e,0,0),t.drawImage(g,s,a,e.width,e.height)}function pl(t){var e;for(e=0;e<t.width*t.height*4;e+=4)t.data[e+3]=255}function Ye(){ye.apply(this,arguments)}Ye.prototype=Object.create(ye.prototype);Ye.prototype.process_channel_message=function(t){if(t.type==R.SPICE_MSG_DISPLAY_MODE)return this.known_unimplemented(t.type,"Display Mode"),!0;if(t.type==R.SPICE_MSG_DISPLAY_MARK)return this.known_unimplemented(t.type,"Display Mark"),!0;if(t.type==R.SPICE_MSG_DISPLAY_RESET)return this.surfaces[this.primary_surface].canvas.context.restore(),!0;if(t.type==R.SPICE_MSG_DISPLAY_DRAW_COPY){var e=new ln(t.data);if(e.base.box.is_same_size(e.data.src_area)||this.log_warn("FIXME: DrawCopy src_area is a different size than base.box; we do not handle that yet."),e.base.clip.type!=R.SPICE_CLIP_TYPE_NONE&&this.log_warn("FIXME: DrawCopy we don't handle clipping yet"),e.data.rop_descriptor!=R.SPICE_ROPD_OP_PUT&&this.log_warn("FIXME: DrawCopy we don't handle ropd type: "+e.data.rop_descriptor),e.data.mask.flags&&this.log_warn("FIXME: DrawCopy we don't handle mask flag: "+e.data.mask.flags),e.data.mask.bitmap&&this.log_warn("FIXME: DrawCopy we don't handle mask"),e.data&&e.data.src_bitmap)if(e.data.src_bitmap.descriptor.flags&&e.data.src_bitmap.descriptor.flags!=R.SPICE_IMAGE_FLAGS_CACHE_ME&&e.data.src_bitmap.descriptor.flags!=R.SPICE_IMAGE_FLAGS_HIGH_BITS_SET&&(this.log_warn("FIXME: DrawCopy unhandled image flags: "+e.data.src_bitmap.descriptor.flags),this.log_draw("DrawCopy",e)),e.data.src_bitmap.descriptor.type==R.SPICE_IMAGE_TYPE_QUIC){var s=this.surfaces[e.base.surface_id].canvas;if(!e.data.src_bitmap.quic)return this.log_warn("FIXME: DrawCopy could not handle this QUIC file."),!1;var a=kh(s.context,e.data.src_bitmap.quic);return this.draw_copy_helper({base:e.base,src_area:e.data.src_area,image_data:a,tag:"copyquic."+e.data.src_bitmap.quic.type,has_alpha:e.data.src_bitmap.quic.type==be.QUIC_IMAGE_TYPE_RGBA,descriptor:e.data.src_bitmap.descriptor})}else{if(e.data.src_bitmap.descriptor.type==R.SPICE_IMAGE_TYPE_FROM_CACHE||e.data.src_bitmap.descriptor.type==R.SPICE_IMAGE_TYPE_FROM_CACHE_LOSSLESS)return!this.cache||!this.cache[e.data.src_bitmap.descriptor.id]?(this.log_warn("FIXME: DrawCopy did not find image id "+e.data.src_bitmap.descriptor.id+" in cache."),!1):this.draw_copy_helper({base:e.base,src_area:e.data.src_area,image_data:this.cache[e.data.src_bitmap.descriptor.id],tag:"copycache."+e.data.src_bitmap.descriptor.id,has_alpha:!0,descriptor:e.data.src_bitmap.descriptor});if(e.data.src_bitmap.descriptor.type==R.SPICE_IMAGE_TYPE_SURFACE){var g=this.surfaces[e.data.src_bitmap.surface_id].canvas.context;this.surfaces[e.base.surface_id].canvas.context;var a=g.getImageData(e.data.src_area.left,e.data.src_area.top,e.data.src_area.right-e.data.src_area.left,e.data.src_area.bottom-e.data.src_area.top),w=new st;return w.top=w.left=0,w.right=a.width,w.bottom=a.height,this.draw_copy_helper({base:e.base,src_area:w,image_data:a,tag:"copysurf."+e.data.src_bitmap.surface_id,has_alpha:this.surfaces[e.data.src_bitmap.surface_id].format!=R.SPICE_SURFACE_FMT_32_xRGB,descriptor:e.data.src_bitmap.descriptor})}else if(e.data.src_bitmap.descriptor.type==R.SPICE_IMAGE_TYPE_JPEG){if(!e.data.src_bitmap.jpeg)return this.log_warn("FIXME: DrawCopy could not handle this JPEG file."),!1;var y="data:image/jpeg,",r=new Image,n,u=new Uint8Array(e.data.src_bitmap.jpeg.data);for(n=0;n<u.length;n++)y+="%",u[n]<16&&(y+="0"),y+=u[n].toString(16);return r.o={base:e.base,tag:"jpeg."+e.data.src_bitmap.surface_id,descriptor:e.data.src_bitmap.descriptor,sc:this},r.onload=Hs,r.src=y,!0}else if(e.data.src_bitmap.descriptor.type==R.SPICE_IMAGE_TYPE_JPEG_ALPHA){if(!e.data.src_bitmap.jpeg_alpha)return this.log_warn("FIXME: DrawCopy could not handle this JPEG ALPHA file."),!1;var y="data:image/jpeg,",r=new Image,n,u=new Uint8Array(e.data.src_bitmap.jpeg_alpha.data);for(n=0;n<u.length;n++)y+="%",u[n]<16&&(y+="0"),y+=u[n].toString(16);if(r.o={base:e.base,tag:"jpeg."+e.data.src_bitmap.surface_id,descriptor:e.data.src_bitmap.descriptor,sc:this},this.surfaces[e.base.surface_id].format==R.SPICE_SURFACE_FMT_32_ARGB){var s=this.surfaces[e.base.surface_id].canvas;r.alpha_img=Zi(s.context,e.data.src_bitmap.jpeg_alpha.alpha)}return r.onload=Hs,r.src=y,!0}else if(e.data.src_bitmap.descriptor.type==R.SPICE_IMAGE_TYPE_BITMAP){var s=this.surfaces[e.base.surface_id].canvas;if(!e.data.src_bitmap.bitmap)return this.log_err("null bitmap"),!1;var a=fl(s.context,e.data.src_bitmap.bitmap);return a?this.draw_copy_helper({base:e.base,src_area:e.data.src_area,image_data:a,tag:"bitmap."+e.data.src_bitmap.bitmap.format,has_alpha:e.data.src_bitmap.bitmap!=R.SPICE_BITMAP_FMT_32BIT,descriptor:e.data.src_bitmap.descriptor}):(this.log_warn("FIXME: Unable to interpret bitmap of format: "+e.data.src_bitmap.bitmap.format),!1)}else if(e.data.src_bitmap.descriptor.type==R.SPICE_IMAGE_TYPE_LZ_RGB){var s=this.surfaces[e.base.surface_id].canvas;if(!e.data.src_bitmap.lz_rgb)return this.log_err("null lz_rgb "),!1;var a=Zi(s.context,e.data.src_bitmap.lz_rgb);return a?this.draw_copy_helper({base:e.base,src_area:e.data.src_area,image_data:a,tag:"lz_rgb."+e.data.src_bitmap.lz_rgb.type,has_alpha:e.data.src_bitmap.lz_rgb.type==R.LZ_IMAGE_TYPE_RGBA,descriptor:e.data.src_bitmap.descriptor}):(this.log_warn("FIXME: Unable to interpret bitmap of type: "+e.data.src_bitmap.lz_rgb.type),!1)}else return this.log_warn("FIXME: DrawCopy unhandled image type: "+e.data.src_bitmap.descriptor.type),this.log_draw("DrawCopy",e),!1}return this.log_warn("FIXME: DrawCopy no src_bitmap."),!1}if(t.type==R.SPICE_MSG_DISPLAY_DRAW_FILL){var m=new un(t.data);if(m.data.rop_descriptor!=R.SPICE_ROPD_OP_PUT&&this.log_warn("FIXME: DrawFill we don't handle ropd type: "+m.data.rop_descriptor),m.data.mask.flags&&this.log_warn("FIXME: DrawFill we don't handle mask flag: "+m.data.mask.flags),m.data.mask.bitmap&&this.log_warn("FIXME: DrawFill we don't handle mask"),m.data.brush.type==R.SPICE_BRUSH_TYPE_SOLID){var l=m.data.brush.color&16777215,p="rgb("+(l>>16)+", "+(l>>8&255)+", "+(l&255)+")";this.surfaces[m.base.surface_id].canvas.context.fillStyle=p,this.surfaces[m.base.surface_id].canvas.context.fillRect(m.base.box.left,m.base.box.top,m.base.box.right-m.base.box.left,m.base.box.bottom-m.base.box.top),this.surfaces[m.base.surface_id].draw_count++}else this.log_warn("FIXME: DrawFill can't handle brush type: "+m.data.brush.type);return!0}if(t.type==R.SPICE_MSG_DISPLAY_DRAW_OPAQUE)return this.known_unimplemented(t.type,"Display Draw Opaque"),!0;if(t.type==R.SPICE_MSG_DISPLAY_DRAW_BLEND)return this.known_unimplemented(t.type,"Display Draw Blend"),!0;if(t.type==R.SPICE_MSG_DISPLAY_DRAW_BLACKNESS)return this.known_unimplemented(t.type,"Display Draw Blackness"),!0;if(t.type==R.SPICE_MSG_DISPLAY_DRAW_WHITENESS)return this.known_unimplemented(t.type,"Display Draw Whiteness"),!0;if(t.type==R.SPICE_MSG_DISPLAY_DRAW_INVERS)return this.known_unimplemented(t.type,"Display Draw Invers"),!0;if(t.type==R.SPICE_MSG_DISPLAY_DRAW_ROP3)return this.known_unimplemented(t.type,"Display Draw ROP3"),!0;if(t.type==R.SPICE_MSG_DISPLAY_DRAW_STROKE)return this.known_unimplemented(t.type,"Display Draw Stroke"),!0;if(t.type==R.SPICE_MSG_DISPLAY_DRAW_TRANSPARENT)return this.known_unimplemented(t.type,"Display Draw Transparent"),!0;if(t.type==R.SPICE_MSG_DISPLAY_DRAW_ALPHA_BLEND)return this.known_unimplemented(t.type,"Display Draw Alpha Blend"),!0;if(t.type==R.SPICE_MSG_DISPLAY_COPY_BITS){var C=new dn(t.data),S=this.surfaces[C.base.surface_id].canvas,g=S.context,_=S.width-C.src_pos.x,i=S.height-C.src_pos.y;_>C.base.box.right-C.base.box.left&&(_=C.base.box.right-C.base.box.left),i>C.base.box.bottom-C.base.box.top&&(i=C.base.box.bottom-C.base.box.top);var a=g.getImageData(C.src_pos.x,C.src_pos.y,_,i);return io(g,a,C.base.box.left,C.base.box.top),this.surfaces[C.base.surface_id].draw_count++,!0}if(t.type==R.SPICE_MSG_DISPLAY_INVAL_ALL_PIXMAPS)return this.known_unimplemented(t.type,"Display Inval All Pixmaps"),!0;if(t.type==R.SPICE_MSG_DISPLAY_INVAL_PALETTE)return this.known_unimplemented(t.type,"Display Inval Palette"),!0;if(t.type==R.SPICE_MSG_DISPLAY_INVAL_ALL_PALETTES)return this.known_unimplemented(t.type,"Inval All Palettes"),!0;if(t.type==R.SPICE_MSG_DISPLAY_SURFACE_CREATE){"surfaces"in this||(this.surfaces=[]);var o=new _n(t.data);if(o.surface.format!=R.SPICE_SURFACE_FMT_32_xRGB&&o.surface.format!=R.SPICE_SURFACE_FMT_32_ARGB)return this.log_warn("FIXME: cannot handle surface format "+o.surface.format+" yet."),!1;var s=document.createElement("canvas");return s.setAttribute("width",o.surface.width),s.setAttribute("height",o.surface.height),s.setAttribute("id","spice_surface_"+o.surface.surface_id),s.setAttribute("tabindex",o.surface.surface_id),s.context=s.getContext("2d"),o.surface.canvas=s,o.surface.draw_count=0,this.surfaces[o.surface.surface_id]=o.surface,o.surface.flags&R.SPICE_SURFACE_FLAGS_PRIMARY&&(this.primary_surface=o.surface.surface_id,s.context.save(),document.getElementById(this.parent.screen_id).appendChild(s),document.getElementById(this.parent.screen_id).style.height=o.surface.height+"px",this.hook_events()),!0}if(t.type==R.SPICE_MSG_DISPLAY_SURFACE_DESTROY){var o=new fn(t.data);return this.delete_surface(o.surface_id),!0}if(t.type==R.SPICE_MSG_DISPLAY_STREAM_CREATE){var o=new yn(t.data);if(this.streams||(this.streams=new Array),this.streams[o.id]?console.log("Stream "+o.id+" already exists"):this.streams[o.id]=o,o.codec_type==R.SPICE_VIDEO_CODEC_TYPE_VP8){var c=new MediaSource,h=document.createElement("video");h.src=window.URL.createObjectURL(c),h.setAttribute("muted",!0),h.setAttribute("autoplay",!0),h.setAttribute("width",o.stream_width),h.setAttribute("height",o.stream_height);var f=o.dest.left,b=o.dest.top;this.surfaces[o.surface_id]!==void 0&&(f+=this.surfaces[o.surface_id].canvas.offsetLeft,b+=this.surfaces[o.surface_id].canvas.offsetTop),document.getElementById(this.parent.screen_id).appendChild(h),h.setAttribute("style","pointer-events:none; position: absolute; top:"+b+"px; left:"+f+"px;"),c.addEventListener("sourceopen",gl,!1),c.addEventListener("sourceended",vl,!1),c.addEventListener("sourceclosed",Sl,!1);var E=this.streams[o.id];E.video=h,E.media=c,E.queue=new Array,E.start_time=0,E.cluster_time=0,E.append_okay=!1,c.stream=E,c.spiceconn=this,h.spice_stream=E}else o.codec_type==R.SPICE_VIDEO_CODEC_TYPE_MJPEG?this.streams[o.id].frames_loading=0:console.log("Unhandled stream codec: "+o.codec_type);return!0}if(t.type==R.SPICE_MSG_DISPLAY_STREAM_DATA||t.type==R.SPICE_MSG_DISPLAY_STREAM_DATA_SIZED){var o;if(t.type==R.SPICE_MSG_DISPLAY_STREAM_DATA_SIZED?o=new xn(t.data):o=new wn(t.data),!this.streams[o.base.id])return console.log("no stream for data"),!1;var I=o.base.multi_media_time-this.parent.relative_now();return this.streams[o.base.id].codec_type===R.SPICE_VIDEO_CODEC_TYPE_MJPEG&&ml(this,o,I),this.streams[o.base.id].codec_type===R.SPICE_VIDEO_CODEC_TYPE_VP8&&El(this.streams[o.base.id],o),!0}if(t.type==R.SPICE_MSG_DISPLAY_STREAM_ACTIVATE_REPORT){var o=new Pn(t.data),v=new Ln(o.stream_id,o.unique_id);return this.streams[o.stream_id]&&(this.streams[o.stream_id].report=v,this.streams[o.stream_id].max_window_size=o.max_window_size,this.streams[o.stream_id].timeout_ms=o.timeout_ms),!0}if(t.type==R.SPICE_MSG_DISPLAY_STREAM_CLIP){var o=new In(t.data);return this.streams[o.id].clip=o.clip,!0}if(t.type==R.SPICE_MSG_DISPLAY_STREAM_DESTROY){var o=new An(t.data);return this.streams[o.id].codec_type==R.SPICE_VIDEO_CODEC_TYPE_VP8&&(document.getElementById(this.parent.screen_id).removeChild(this.streams[o.id].video),this.streams[o.id].source_buffer=null,this.streams[o.id].media=null,this.streams[o.id].video=null),this.streams[o.id]=void 0,!0}if(t.type==R.SPICE_MSG_DISPLAY_STREAM_DESTROY_ALL)return this.known_unimplemented(t.type,"Display Stream Destroy All"),!0;if(t.type==R.SPICE_MSG_DISPLAY_INVAL_LIST){var o=new Dn(t.data),n;for(n=0;n<o.count;n++)this.cache[o.resources[n].id]!=null&&delete this.cache[o.resources[n].id];return!0}return t.type==R.SPICE_MSG_DISPLAY_MONITORS_CONFIG?(this.known_unimplemented(t.type,"Display Monitors Config"),!0):t.type==R.SPICE_MSG_DISPLAY_DRAW_COMPOSITE?(this.known_unimplemented(t.type,"Display Draw Composite"),!0):!1};Ye.prototype.delete_surface=function(t){var s;var e=document.getElementById("spice_surface_"+t);this.primary_surface==t&&(this.unhook_events(),this.primary_surface=void 0,(s=document.getElementById(this.parent.screen_id))==null||s.removeChild(e)),delete this.surfaces[t]};Ye.prototype.draw_copy_helper=function(t){var e=this.surfaces[t.base.surface_id].canvas;return t.has_alpha?this.surfaces[t.base.surface_id].format==R.SPICE_SURFACE_FMT_32_xRGB?(pl(t.image_data),e.context.putImageData(t.image_data,t.base.box.left,t.base.box.top)):io(e.context,t.image_data,t.base.box.left,t.base.box.top):e.context.putImageData(t.image_data,t.base.box.left,t.base.box.top),(t.src_area.left>0||t.src_area.top>0)&&this.log_warn("FIXME: DrawCopy not shifting draw copies just yet..."),t.descriptor&&t.descriptor.flags&R.SPICE_IMAGE_FLAGS_CACHE_ME&&("cache"in this||(this.cache={}),this.cache[t.descriptor.id]=t.image_data),this.surfaces[t.base.surface_id].draw_count++,!0};Ye.prototype.log_draw=function(t,e){var s=t+"."+e.base.surface_id+"."+this.surfaces[e.base.surface_id].draw_count+": ";s+="base.box "+e.base.box.left+", "+e.base.box.top+" to "+e.base.box.right+", "+e.base.box.bottom,s+="; clip.type "+e.base.clip.type,e.data&&(e.data.src_area&&(s+="; src_area "+e.data.src_area.left+", "+e.data.src_area.top+" to "+e.data.src_area.right+", "+e.data.src_area.bottom),e.data.src_bitmap&&e.data.src_bitmap!=null?(s+="; src_bitmap id: "+e.data.src_bitmap.descriptor.id,s+="; src_bitmap width "+e.data.src_bitmap.descriptor.width+", height "+e.data.src_bitmap.descriptor.height,s+="; src_bitmap type "+e.data.src_bitmap.descriptor.type+", flags "+e.data.src_bitmap.descriptor.flags,e.data.src_bitmap.surface_id!==void 0&&(s+="; src_bitmap surface_id "+e.data.src_bitmap.surface_id),e.data.src_bitmap.bitmap&&(s+="; BITMAP format "+e.data.src_bitmap.bitmap.format+"; flags "+e.data.src_bitmap.bitmap.flags+"; x "+e.data.src_bitmap.bitmap.x+"; y "+e.data.src_bitmap.bitmap.y+"; stride "+e.data.src_bitmap.bitmap.stride),e.data.src_bitmap.quic&&(s+="; QUIC type "+e.data.src_bitmap.quic.type+"; width "+e.data.src_bitmap.quic.width+"; height "+e.data.src_bitmap.quic.height),e.data.src_bitmap.lz_rgb&&(s+="; LZ_RGB length "+e.data.src_bitmap.lz_rgb.length+"; magic "+e.data.src_bitmap.lz_rgb.magic+"; version 0x"+e.data.src_bitmap.lz_rgb.version.toString(16)+"; type "+e.data.src_bitmap.lz_rgb.type+"; width "+e.data.src_bitmap.lz_rgb.width+"; height "+e.data.src_bitmap.lz_rgb.height+"; stride "+e.data.src_bitmap.lz_rgb.stride+"; top down "+e.data.src_bitmap.lz_rgb.top_down)):s+="; src_bitmap is null",e.data.brush&&(e.data.brush.type==R.SPICE_BRUSH_TYPE_SOLID&&(s+="; brush.color 0x"+e.data.brush.color.toString(16)),e.data.brush.type==R.SPICE_BRUSH_TYPE_PATTERN&&(s+="; brush.pat ",e.data.brush.pattern.pat!=null?s+="[SpiceImage]":s+="[null]",s+=" at "+e.data.brush.pattern.pos.x+", "+e.data.brush.pattern.pos.y)),s+="; rop_descriptor "+e.data.rop_descriptor,e.data.scale_mode!==void 0&&(s+="; scale_mode "+e.data.scale_mode),s+="; mask.flags "+e.data.mask.flags,s+="; mask.pos "+e.data.mask.pos.x+", "+e.data.mask.pos.y,e.data.mask.bitmap!=null?(s+="; mask.bitmap width "+e.data.mask.bitmap.descriptor.width+", height "+e.data.mask.bitmap.descriptor.height,s+="; mask.bitmap type "+e.data.mask.bitmap.descriptor.type+", flags "+e.data.mask.bitmap.descriptor.flags):s+="; mask.bitmap is null"),console.log(s)};Ye.prototype.hook_events=function(){if(this.primary_surface!==void 0){var t=this.surfaces[this.primary_surface].canvas;t.sc=this.parent,t.addEventListener("mousemove",qn),t.addEventListener("mousedown",Xn),t.addEventListener("contextmenu",Qn),t.addEventListener("mouseup",Zn),t.addEventListener("keydown",eo),t.addEventListener("keyup",to),t.addEventListener("mouseout",no),t.addEventListener("mouseover",ro),t.addEventListener("wheel",Jn),t.focus()}};Ye.prototype.unhook_events=function(){if(this.primary_surface!==void 0){var t=this.surfaces[this.primary_surface].canvas;t.removeEventListener("mousemove",qn),t.removeEventListener("mousedown",Xn),t.removeEventListener("contextmenu",Qn),t.removeEventListener("mouseup",Zn),t.removeEventListener("keydown",eo),t.removeEventListener("keyup",to),t.removeEventListener("mouseout",no),t.removeEventListener("mouseover",ro),t.removeEventListener("wheel",Jn)}};Ye.prototype.destroy_surfaces=function(){for(var t in this.surfaces)this.delete_surface(this.surfaces[t].surface_id);this.surfaces=void 0};function ro(t){this.focus()}function no(t){this.sc&&this.sc.cursor&&this.sc.cursor.spice_simulated_cursor&&(this.sc.cursor.spice_simulated_cursor.style.display="none"),this.blur()}function Hs(){var t=null,e;if("streams"in this.o.sc&&this.o.sc.streams[this.o.id]&&this.o.sc.streams[this.o.id].frames_loading--,this.o.sc.surfaces[this.o.base.surface_id]===void 0?(t=document.createElement("canvas"),t.setAttribute("width",this.o.base.box.right),t.setAttribute("height",this.o.base.box.bottom),e=t.getContext("2d")):e=this.o.sc.surfaces[this.o.base.surface_id].canvas.context,this.alpha_img){var s=document.createElement("canvas"),a=s.getContext("2d");s.setAttribute("width",this.alpha_img.width),s.setAttribute("height",this.alpha_img.height),a.putImageData(this.alpha_img,0,0),a.globalCompositeOperation="source-in",a.drawImage(this,0,0),e.drawImage(s,this.o.base.box.left,this.o.base.box.top),this.o.descriptor&&this.o.descriptor.flags&R.SPICE_IMAGE_FLAGS_CACHE_ME&&("cache"in this.o.sc||(this.o.sc.cache={}),this.o.sc.cache[this.o.descriptor.id]=a.getImageData(0,0,this.alpha_img.width,this.alpha_img.height))}else e.drawImage(this,this.o.base.box.left,this.o.base.box.top),this.onload=void 0,this.src=Oh,this.o.descriptor&&this.o.descriptor.flags&R.SPICE_IMAGE_FLAGS_CACHE_ME&&("cache"in this.o.sc||(this.o.sc.cache={}),this.o.sc.cache[this.o.descriptor.id]=e.getImageData(this.o.base.box.left,this.o.base.box.top,this.o.base.box.right-this.o.base.box.left,this.o.base.box.bottom-this.o.base.box.top));t==null&&this.o.sc.surfaces[this.o.base.surface_id].draw_count++,this.o.sc.streams[this.o.id]&&"report"in this.o.sc.streams[this.o.id]&&oo(this.o.sc,this.o.id,this.o.msg_mmtime,this.o.msg_mmtime-this.o.sc.parent.relative_now())}function ml(t,e,s){if(s<0&&t.streams[e.base.id].frames_loading>0){"report"in t.streams[e.base.id]&&t.streams[e.base.id].report.num_drops++;return}var a="data:image/jpeg,",g=new Image,w;for(w=0;w<e.data.length;w++)a+="%",e.data[w]<16&&(a+="0"),a+=e.data[w].toString(16);var y=new Tt;y.surface_id=t.streams[e.base.id].surface_id,y.box=e.dest||t.streams[e.base.id].dest,y.clip=t.streams[e.base.id].clip,g.o={base:y,tag:"mjpeg."+e.base.id,descriptor:null,sc:t,id:e.base.id,msg_mmtime:e.base.multi_media_time},g.onload=Hs,g.src=a,t.streams[e.base.id].frames_loading++}function oo(t,e,s,a){if(t.streams[e].report.num_frames++,t.streams[e].report.start_frame_mm_time==0&&(t.streams[e].report.start_frame_mm_time=s),t.streams[e].report.num_frames>t.streams[e].max_window_size||s-t.streams[e].report.start_frame_mm_time>t.streams[e].timeout_ms){t.streams[e].report.end_frame_mm_time=s,t.streams[e].report.last_frame_delay=a;var g=new le;g.build_msg(R.SPICE_MSGC_DISPLAY_STREAM_REPORT,t.streams[e].report),t.send_msg(g),t.streams[e].report.start_frame_mm_time=0,t.streams[e].report.num_frames=0,t.streams[e].report.num_drops=0}}function gl(t){var e=this.stream,s=this.spiceconn;if(!e.source_buffer){var a=this.addSourceBuffer(de.SPICE_VP8_CODEC);if(!a){s.log_err("Codec "+de.SPICE_VP8_CODEC+" not available.");return}e.source_buffer=a,a.spiceconn=s,a.stream=e,xl(e);var g=new ui,w=new Vn(this.stream.stream_width,this.stream.stream_height),y=new ci(w),r=new ArrayBuffer(g.buffer_size()+y.buffer_size()),n=g.to_buffer(r);y.to_buffer(r,n),a.addEventListener("error",Cl,!1),a.addEventListener("updateend",bl,!1),fi(a,r)}}function vl(t){var e=this.spiceconn;e.log_err("Video source unexpectedly ended.")}function Sl(t){var e=this.spiceconn;e.log_err("Video source unexpectedly closed.")}function fi(t,e){try{t.stream.append_okay=!1,t.appendBuffer(e)}catch(a){var s=t.spiceconn;s.log_err("Error invoking appendBuffer: "+a.message)}}function bl(t){var e=this.stream;if(e.current_frame&&"report"in e){var s=this.stream.media.spiceconn,a=this.stream.current_frame.msg_mmtime;oo(s,e.id,a,a-s.parent.relative_now())}if(e.queue.length>0?(e.current_frame=e.queue.shift(),fi(e.source_buffer,e.current_frame.mb)):e.append_okay=!0,!!e.video&&(e.video.buffered.length>0&&e.video.currentTime<e.video.buffered.start(e.video.buffered.length-1)&&(console.log("Video appears to have fallen behind; advancing to "+e.video.buffered.start(e.video.buffered.length-1)),e.video.currentTime=e.video.buffered.start(e.video.buffered.length-1)),this.stream.video.paused&&this.stream.video.readyState>=2))var g=this.stream.video.play()}function Cl(t){var e=this.spiceconn;e.log_err("source_buffer error "+t.message)}function ao(t,e,s){var a={msg_mmtime:e.base.multi_media_time};t.append_okay?(t.current_frame=a,fi(t.source_buffer,s)):(a.mb=s,t.queue.push(a))}function co(t,e,s){var a=new li(e.base.multi_media_time-t.cluster_time,e.data,s),g=new ArrayBuffer(a.buffer_size());a.to_buffer(g),ao(t,e,g)}function Ji(t,e){t.cluster_time=e.base.multi_media_time;var s=new hi(t.cluster_time-t.start_time,e.data),a=new ArrayBuffer(s.buffer_size());s.to_buffer(a),ao(t,e,a),co(t,e,!0)}function El(t,e){t.start_time==0?(t.start_time=e.base.multi_media_time,Ji(t,e)):e.base.multi_media_time-t.cluster_time>=de.MAX_CLUSTER_TIME?Ji(t,e):co(t,e,!1)}function yl(t){var e=this.spice_stream;e.video&&e.video.buffered.len>1&&console.log(e.video.currentTime+":id "+e.id+" event "+t.type+zr(e.video)),e.queue.length>1&&console.log(" queue len "+e.queue.length+"; append_okay: "+e.append_okay)}function wl(t){this.addEventListener(t,yl)}function xl(t){var e=["abort","error"];e.forEach(wl,t.video)}function ft(){ye.apply(this,arguments),this.queue=new Array,this.append_okay=!1,this.start_time=0}ft.prototype=Object.create(ye.prototype);ft.prototype.process_channel_message=function(t){if(!window.MediaSource)return this.log_err("MediaSource API is not available"),!1;if(t.type==R.SPICE_MSG_PLAYBACK_START){var e=new bn(t.data);if(e.frequency!=de.OPUS_FREQUENCY)return this.log_err("This player cannot handle frequency "+e.frequency),!1;if(e.channels!=de.OPUS_CHANNELS)return this.log_err("This player cannot handle "+e.channels+" channels"),!1;if(e.format!=R.SPICE_AUDIO_FMT_S16)return this.log_err("This player cannot format "+e.format),!1;if(!this.source_buffer)return this.media_source=new MediaSource,this.media_source.spiceconn=this,this.audio=document.createElement("audio"),this.audio.spiceconn=this,this.audio.setAttribute("autoplay",!0),this.audio.src=window.URL.createObjectURL(this.media_source),document.getElementById(this.parent.screen_id).appendChild(this.audio),this.media_source.addEventListener("sourceopen",Il,!1),this.media_source.addEventListener("sourceended",Al,!1),this.media_source.addEventListener("sourceclosed",Pl,!1),this.bytes_written=0,!0}if(t.type==R.SPICE_MSG_PLAYBACK_DATA){var s=new vn(t.data);return this.source_buffer&&(this.audio.readyState>=3&&this.audio.buffered.length>1&&this.audio.currentTime==this.audio.buffered.end(0)&&this.audio.currentTime<this.audio.buffered.start(this.audio.buffered.length-1)&&(console.log("Audio underrun: we appear to have fallen behind; advancing to "+this.audio.buffered.start(this.audio.buffered.length-1)),this.audio.currentTime=this.audio.buffered.start(this.audio.buffered.length-1)),this.start_time!=0&&s.time!=this.last_data_time+de.EXPECTED_PACKET_DURATION&&Math.abs(s.time-(de.EXPECTED_PACKET_DURATION+this.last_data_time))<de.MAX_CLUSTER_TIME&&(s.time=this.last_data_time+de.EXPECTED_PACKET_DURATION),this.last_data_time=s.time,this.start_time==0?this.start_playback(s):s.time-this.cluster_time>=de.MAX_CLUSTER_TIME?this.new_cluster(s):this.simple_block(s,!1)),!0}if(t.type==R.SPICE_MSG_PLAYBACK_MODE){var a=new Sn(t.data);return a.mode!=R.SPICE_AUDIO_DATA_MODE_OPUS&&(this.log_err("This player cannot handle mode "+a.mode),delete this.source_buffer),!0}return t.type==R.SPICE_MSG_PLAYBACK_STOP&&this.source_buffer?(document.getElementById(this.parent.screen_id).removeChild(this.audio),window.URL.revokeObjectURL(this.audio.src),delete this.source_buffer,delete this.media_source,delete this.audio,this.append_okay=!1,this.queue=new Array,this.start_time=0,!0):t.type==R.SPICE_MSG_PLAYBACK_VOLUME?(this.known_unimplemented(t.type,"Playback Volume"),!0):t.type==R.SPICE_MSG_PLAYBACK_MUTE?(this.known_unimplemented(t.type,"Playback Mute"),!0):t.type==R.SPICE_MSG_PLAYBACK_LATENCY?(this.known_unimplemented(t.type,"Playback Latency"),!0):!1};ft.prototype.start_playback=function(t){this.start_time=t.time;var e=new ui,s=new $n,a=new ci(s),g=new ArrayBuffer(e.buffer_size()+a.buffer_size());this.bytes_written=e.to_buffer(g),this.bytes_written=a.to_buffer(g,this.bytes_written),this.source_buffer.addEventListener("error",Ml,!1),this.source_buffer.addEventListener("updateend",Dl,!1),ms(this,g),this.new_cluster(t)};ft.prototype.new_cluster=function(t){this.cluster_time=t.time;var e=new hi(t.time-this.start_time),s=new ArrayBuffer(e.buffer_size());this.bytes_written+=e.to_buffer(s),this.append_okay?ms(this,s):this.queue.push(s),this.simple_block(t,!0)};ft.prototype.simple_block=function(t,e){var s=new li(t.time-this.cluster_time,t.data,e),a=new ArrayBuffer(s.buffer_size());this.bytes_written+=s.to_buffer(a),this.append_okay?ms(this,a):this.queue.push(a)};function Il(t){var e=this.spiceconn;if(!e.source_buffer){if(e.source_buffer=this.addSourceBuffer(de.SPICE_PLAYBACK_CODEC),!e.source_buffer){e.log_err("Codec "+de.SPICE_PLAYBACK_CODEC+" not available.");return}kl(e),e.source_buffer.spiceconn=e,e.source_buffer.mode="segments"}}function Al(t){var e=this.spiceconn;e.log_err("Audio source unexpectedly ended.")}function Pl(t){var e=this.spiceconn;e.log_err("Audio source unexpectedly closed.")}function Ll(t){if(t.length==1)return t.shift();var e=0,s=0;for(s=0;s<t.length;s++)e+=t[s].byteLength;var a=new ArrayBuffer(e),g=new Uint8Array(a);for(e=0,s=0;s<t.length;s++)g.set(new Uint8Array(t[s]),e),e+=t[s].byteLength;return t.length=0,a}function Dl(t){var e=this.spiceconn;if(e.queue.length>0){var s=Ll(e.queue);ms(e,s)}else e.append_okay=!0}function Ml(t){var e=this.spiceconn;e.log_err("source_buffer error "+t.message)}function ms(t,e){try{t.source_buffer.appendBuffer(e),t.append_okay=!1}catch(s){t.log_err("Error invoking appendBuffer: "+s.message)}}function Tl(t){var e=this.spiceconn;e.audio&&e.audio.buffered.len>1&&console.log(e.audio.currentTime+": event "+t.type+zr(e.audio)),e.queue.length>1&&console.log(" queue len "+e.queue.length+"; append_okay: "+e.append_okay)}function Rl(t){this.addEventListener(t,Tl)}function kl(t){var e=["abort","error"];e.forEach(Rl,t.audio)}function pi(){ye.apply(this,arguments),this.port_name=null}pi.prototype=Object.create(ye.prototype);pi.prototype.process_channel_message=function(t){if(t.type==R.SPICE_MSG_PORT_INIT){if(this.port_name===null){var e=new Mn(t.data);return this.portName=Nh(new Uint8Array(e.name)),this.portOpened=e.opened,!0}}else if(t.type==R.SPICE_MSG_PORT_EVENT){var s=new CustomEvent("spice-port-event",{detail:{channel:this,spiceEvent:new Uint8Array(t.data)},bubbles:!0,cancelable:!0});return window.dispatchEvent(s),!0}else if(t.type==R.SPICE_MSG_SPICEVMC_DATA){var s=new CustomEvent("spice-port-data",{detail:{channel:this,data:t.data},bubbles:!0,cancelable:!0});return window.dispatchEvent(s),!0}return!1};function Bl(t){if(t){var e=document.getElementById(t.screen_id).clientWidth,s=document.getElementById("spice-area"),a=document.isFullScreen||document.fullscreenElement||document.webkitIsFullScreen||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement,g=window.innerHeight-s.getBoundingClientRect().top;a||(g=g-65),g<200&&(g=200),g%8>0&&(g-=g%8),e%8>0&&(e-=e%8),t.resize_window(0,e,g,32,0,0),t.spice_resize_timer=void 0}}function Ol(t){var e=window.spice_connection;e&&(e.spice_resize_timer&&(window.clearTimeout(e.spice_resize_timer),e.spice_resize_timer=void 0),e.spice_resize_timer=window.setTimeout(Bl,200,e))}function we(){if(typeof WebSocket>"u")throw new Error("WebSocket unavailable. You need to use a different browser.");ye.apply(this,arguments),this.agent_msg_queue=[],this.file_xfer_tasks={},this.file_xfer_task_id=0,this.file_xfer_read_queue=[],this.ports=[]}we.prototype=Object.create(ye.prototype);we.prototype.process_channel_message=function(t){if(t.type==R.SPICE_MSG_MAIN_MIGRATE_BEGIN)return this.known_unimplemented(t.type,"Main Migrate Begin"),!0;if(t.type==R.SPICE_MSG_MAIN_MIGRATE_CANCEL)return this.known_unimplemented(t.type,"Main Migrate Cancel"),!0;if(t.type==R.SPICE_MSG_MAIN_INIT){this.log_info("Connected to "+this.ws.url),this.report_success("Connected"),this.main_init=new Xr(t.data),this.connection_id=this.main_init.session_id,this.agent_tokens=this.main_init.agent_tokens,this.our_mm_time=Date.now(),this.mm_time=this.main_init.multi_media_time,this.handle_mouse_mode(this.main_init.current_mouse_mode,this.main_init.supported_mouse_modes),this.main_init.agent_connected&&this.connect_agent();var e=new le;return e.type=R.SPICE_MSGC_MAIN_ATTACH_CHANNELS,e.size=e.buffer_size(),this.send_msg(e),!0}if(t.type==R.SPICE_MSG_MAIN_MOUSE_MODE){var s=new Qr(t.data);return this.handle_mouse_mode(s.current_mode,s.supported_modes),!0}if(t.type==R.SPICE_MSG_MAIN_MULTI_MEDIA_TIME)return this.known_unimplemented(t.type,"Main Multi Media Time"),!0;if(t.type==R.SPICE_MSG_MAIN_CHANNELS_LIST){var a,g;for(g=new qr(t.data),a=0;a<g.channels.length;a++){var w={uri:this.ws.url,parent:this,connection_id:this.connection_id,type:g.channels[a].type,chan_id:g.channels[a].id};g.channels[a].type==R.SPICE_CHANNEL_DISPLAY?g.channels[a].id==0?this.display=new Ye(w):this.log_warn("The spice-html5 client does not handle multiple heads."):g.channels[a].type==R.SPICE_CHANNEL_INPUTS?(this.inputs=new di(w),this.inputs.mouse_mode=this.mouse_mode):g.channels[a].type==R.SPICE_CHANNEL_CURSOR?this.cursor=new fs(w):g.channels[a].type==R.SPICE_CHANNEL_PLAYBACK?this.cursor=new ft(w):g.channels[a].type==R.SPICE_CHANNEL_PORT?this.ports.push(new pi(w)):("extra_channels"in this||(this.extra_channels=[]),this.extra_channels[a]=new ye(w),this.log_err("Channel type "+this.extra_channels[a].channel_type()+" not implemented"))}return!0}if(t.type==R.SPICE_MSG_MAIN_AGENT_CONNECTED)return this.connect_agent(),!0;if(t.type==R.SPICE_MSG_MAIN_AGENT_CONNECTED_TOKENS){var y=new Us(t.data);return this.agent_tokens=y.num_tokens,this.connect_agent(),!0}if(t.type==R.SPICE_MSG_MAIN_AGENT_TOKEN){var r,n=new Us(t.data);for(this.agent_tokens+=n.num_tokens,this.send_agent_message_queue(),r=this.agent_tokens;r>0&&this.file_xfer_read_queue.length>0;){var u=this.file_xfer_read_queue.shift();this.file_xfer_read(u,u.read_bytes),r--}return!0}if(t.type==R.SPICE_MSG_MAIN_AGENT_DISCONNECTED)return this.agent_connected=!1,!0;if(t.type==R.SPICE_MSG_MAIN_AGENT_DATA){var m=new Zr(t.data);if(m.type==R.VD_AGENT_ANNOUNCE_CAPABILITIES){var l=new si(m.data);return l.request&&this.announce_agent_capabilities(0),!0}else if(m.type==R.VD_AGENT_FILE_XFER_STATUS)return this.handle_file_xfer_status(new ii(m.data)),!0;return!1}return t.type==R.SPICE_MSG_MAIN_MIGRATE_SWITCH_HOST?(this.known_unimplemented(t.type,"Main Migrate Switch Host"),!0):t.type==R.SPICE_MSG_MAIN_MIGRATE_END?(this.known_unimplemented(t.type,"Main Migrate End"),!0):t.type==R.SPICE_MSG_MAIN_NAME?(this.known_unimplemented(t.type,"Main Name"),!0):t.type==R.SPICE_MSG_MAIN_UUID?(this.known_unimplemented(t.type,"Main UUID"),!0):t.type==R.SPICE_MSG_MAIN_MIGRATE_BEGIN_SEAMLESS?(this.known_unimplemented(t.type,"Main Migrate Begin Seamless"),!0):t.type==R.SPICE_MSG_MAIN_MIGRATE_DST_SEAMLESS_ACK?(this.known_unimplemented(t.type,"Main Migrate Dst Seamless ACK"),!0):t.type==R.SPICE_MSG_MAIN_MIGRATE_DST_SEAMLESS_NACK?(this.known_unimplemented(t.type,"Main Migrate Dst Seamless NACK"),!0):!1};we.prototype.stop=function(t){if(this.state="closing",this.inputs&&(this.inputs.cleanup(),this.inputs=void 0),this.cursor&&(this.cursor.cleanup(),this.cursor=void 0),this.display&&(this.display.cleanup(),this.display.destroy_surfaces(),this.display=void 0),this.cleanup(),"extra_channels"in this)for(var e in this.extra_channels)this.extra_channels[e].cleanup();this.extra_channels=void 0};we.prototype.send_agent_message_queue=function(t){if(this.agent_connected)for(t&&this.agent_msg_queue.push(t);this.agent_tokens>0&&this.agent_msg_queue.length>0;){var e=this.agent_msg_queue.shift();this.send_msg(e),this.agent_tokens--}};we.prototype.send_agent_message=function(t,e){var s=new rn(t,e),a=0,g=R.VD_AGENT_MAX_DATA_SIZE-le.prototype.buffer_size(),w=new ArrayBuffer(s.buffer_size());for(s.to_buffer(w);a<s.buffer_size();){var y=Math.min(a+g,s.buffer_size()),r=new le;r.type=R.SPICE_MSGC_MAIN_AGENT_DATA,r.size=y-a,r.data=w.slice(a,y),this.send_agent_message_queue(r),a=y}};we.prototype.announce_agent_capabilities=function(t){var e=new si(t,1<<R.VD_AGENT_CAP_MOUSE_STATE|1<<R.VD_AGENT_CAP_MONITORS_CONFIG|1<<R.VD_AGENT_CAP_REPLY);this.send_agent_message(R.VD_AGENT_ANNOUNCE_CAPABILITIES,e)};we.prototype.resize_window=function(t,e,s,a,g,w){var y=new nn(t,e,s,a,g,w);this.send_agent_message(R.VD_AGENT_MONITORS_CONFIG,y)};we.prototype.file_xfer_start=function(t){var e,s,a;e=this.file_xfer_task_id++,a=new ps(e,t),a.create_progressbar(),this.file_xfer_tasks[e]=a,s=new on(e,t.name,t.size),this.send_agent_message(R.VD_AGENT_FILE_XFER_START,s)};we.prototype.handle_file_xfer_status=function(t){var e,s;if(this.file_xfer_tasks[t.id]){switch(s=this.file_xfer_tasks[t.id],t.result){case R.VD_AGENT_FILE_XFER_STATUS_CAN_SEND_DATA:this.file_xfer_read(s);return;case R.VD_AGENT_FILE_XFER_STATUS_CANCELLED:e="transfer is cancelled by spice agent";break;case R.VD_AGENT_FILE_XFER_STATUS_ERROR:e="some errors occurred in the spice agent";break;case R.VD_AGENT_FILE_XFER_STATUS_SUCCESS:break;default:e="unhandled status type: "+t.result;break}this.file_xfer_completed(s,e)}};we.prototype.file_xfer_read=function(t,e){var s=32*R.VD_AGENT_MAX_DATA_SIZE,a=this,g,w,y,r;if(!(!t||!this.file_xfer_tasks[t.id]||e>0&&e==t.file.size)){if(t.cancelled){var n=new ii(t.id,R.VD_AGENT_FILE_XFER_STATUS_CANCELLED);this.send_agent_message(R.VD_AGENT_FILE_XFER_STATUS,n),delete this.file_xfer_tasks[t.id];return}if(g=e||0,w=Math.min(g+s,t.file.size),!this.agent_tokens){t.read_bytes=g,this.file_xfer_read_queue.push(t);return}r=new FileReader,r.onload=function(u){var m=new an(t.id,u.target.result.byteLength,u.target.result);a.send_agent_message(R.VD_AGENT_FILE_XFER_DATA,m),a.file_xfer_read(t,w),t.update_progressbar(w)},y=t.file.slice(g,w),r.readAsArrayBuffer(y)}};we.prototype.file_xfer_completed=function(t,e){e?this.log_err(e):this.log_info("transfer of '"+t.file.name+"' was successful"),t.remove_progressbar(),delete this.file_xfer_tasks[t.id]};we.prototype.connect_agent=function(){this.agent_connected=!0;var t=new sn(-1),e=new le;e.build_msg(R.SPICE_MSGC_MAIN_AGENT_START,t),this.send_msg(e),this.announce_agent_capabilities(1),this.onagent!==void 0&&this.onagent(this)};we.prototype.handle_mouse_mode=function(t,e){if(this.mouse_mode=t,t!=R.SPICE_MOUSE_MODE_CLIENT&&e&R.SPICE_MOUSE_MODE_CLIENT){var s=new tn(R.SPICE_MOUSE_MODE_CLIENT),a=new le;a.build_msg(R.SPICE_MSGC_MAIN_MOUSE_MODE_REQUEST,s),this.send_msg(a)}this.inputs&&(this.inputs.mouse_mode=t)};we.prototype.relative_now=function(){var t=Date.now()-this.our_mm_time+this.mm_time;return t};const Nl=({instance:t,onMount:e,onFailure:s})=>{var S;const{name:a,project:g}=tt(),w=O.useNotify(),y=Z.useRef(null),[r,n]=Z.useState(!1),u=is(t),m=_=>{s("Error",_)},l=()=>{ht("spice-wrapper"),Ol()},p=async()=>{if(!a){s("Missing name",new Error);return}if(!g){s("Missing project",new Error);return}n(!0);const _=await Fo(a,g).catch(f=>{n(!1),u&&s("Connection failed",f)});if(!_)return;const i=_.operation.split("?")[0],o=`wss://${location.host}${i}/websocket?secret=${_.metadata.metadata.fds[0]}`,c=`wss://${location.host}${i}/websocket?secret=${_.metadata.metadata.fds.control}`,h=new WebSocket(c);h.onerror=m,h.onclose=f=>{f.code!==1005&&s("Error",f.reason,xt(f.code))},h.onmessage=f=>{console.log("control message",f)};try{window.spice_connection=new we({uri:o,screen_id:"spice-screen",onerror:m,onsuccess:()=>{n(!1),l()},onagent:l})}catch(f){u&&s("Connection failed",f)}return h};return O.useListener(window,l,"resize",!0),Z.useEffect(l,[(S=w.notification)==null?void 0:S.message]),O.useListener(window,_=>{var o;if(!((o=y.current)!=null&&o.parentElement)||!("detail"in _))return;const i=_.detail.wheelEvent;y.current.parentElement.scrollBy(i.deltaX,i.deltaY)},"spice-wheel"),Z.useEffect(()=>{w.clear();const _=p();return()=>{var i;try{(i=window.spice_connection)==null||i.stop()}catch(o){console.error(o)}_.then(o=>o==null?void 0:o.close())}},[t.status]),e(()=>{const _=y.current;_&&_.requestFullscreen().then(l).catch(i=>{s("Failed to enter full-screen mode",i)})}),d.jsx(d.Fragment,{children:r?d.jsx(O.Spinner,{className:"u-loader",text:"Loading VGA session..."}):d.jsx("div",{id:"spice-area",ref:y,children:d.jsx("div",{id:"spice-screen",className:"spice-screen"})})})},Ul=({instance:t,onFailure:e,showNotRunningInfo:s})=>{const{name:a,project:g}=tt(),w=new TextEncoder,[y,r]=Z.useState(!1),[n,u]=Z.useState(""),[m,l]=Z.useState(null),[p]=Z.useState(new Cr.FitAddon),[C,S]=Z.useState(!1),_=Z.useRef(null),i=O.useNotify();tr({when:C,message:"Are you sure you want to leave this page?"});const o=E=>{C&&(E.returnValue="Are you sure you want to leave this page?")};O.useListener(window,o,"beforeunload");const c=is(t),h=E=>{e("Error",E)},f=async()=>{if(!a){e("Missing name",new Error);return}if(!g){e("Missing project",new Error);return}r(!0),Ho(a,g).then(u).catch(console.error);const E=await Ko(a,g).catch(D=>{r(!1),c?e("Connection failed",D):s()});if(!E)return;const I=E.operation.split("?")[0],v=`wss://${location.host}${I}/websocket?secret=${E.metadata.metadata.fds[0]}`,x=`wss://${location.host}${I}/websocket?secret=${E.metadata.metadata.fds.control}`,L=new WebSocket(v),k=new WebSocket(x);return k.onopen=()=>{r(!1)},k.onerror=h,k.onclose=D=>{D.code!==1005&&e("Error",D.reason,xt(D.code))},L.onopen=()=>{l(L)},L.onerror=h,L.onclose=D=>{D.code!==1005&&e("Error",D.reason,xt(D.code)),l(null),S(!1)},L.binaryType="arraybuffer",L.onmessage=D=>{var B;(B=_.current)==null||B.write(new Uint8Array(D.data))},[L,k]};Z.useEffect(()=>{var E;c&&((E=_.current)==null||E.focus())},[c]),Z.useEffect(()=>{if(m)return;i.clear();const E=f();return()=>{E.then(I=>{I==null||I.map(v=>{v.close()})})}},[p,t.status]),Z.useEffect(()=>{!n||!_.current||y||(_.current.write(n),u(""))},[n,y]);const b=()=>{var E,I;ht("p-terminal",void 0,10),(I=(E=_.current)==null?void 0:E.element)==null||I.style.setProperty("padding","1rem"),p.fit()};return O.useListener(window,()=>{b(),setTimeout(b,500)},"resize",!0),d.jsx(d.Fragment,{children:y?d.jsx(O.Spinner,{className:"u-loader",text:"Loading text console..."}):d.jsx(yr,{ref:_,addons:[p],onData:E=>{S(!0),m==null||m.send(w.encode(E))},className:"p-terminal",onOpen:b})})},jl=({instance:t})=>{const e=Ee(),{project:s}=tt(),a=O.useToastNotification(),g=Be(),{openPortal:w,closePortal:y,isOpen:r,Portal:n}=O.usePortal(),[u,m]=Z.useState(!1),{canEditInstance:l}=Oe(),p=t.devices["iso-volume"],C=()=>{m(!0);const i=at(t);i.devices=i.devices.filter(h=>h.name!=="iso-volume");const o=Ht(t,i),c=d.jsx(ue,{instance:t});Ft(o,s??"").then(h=>{e.set(h.metadata.id,()=>a.success(d.jsxs(d.Fragment,{children:["ISO"," ",d.jsx(je,{to:`/ui/project/${encodeURIComponent(s??"")}/storage/custom-isos`,type:"iso-volume",value:(p==null?void 0:p.source)??""})," ","detached from ",c]})),f=>a.failure("Detaching ISO failed.",new Error(f),c),()=>{g.invalidateQueries({queryKey:[Ce.instances,t.name,s]}),m(!1)})}).catch(h=>{m(!1),a.failure("Detaching ISO failed.",h,c)})},S=i=>{m(!0),y();const o=at(t),c=ia(i);o.devices.push(c);const h=Ht(t,o);Ft(h,s??"").then(f=>{const b=hr({operation:f,project:s,instanceType:t.type});e.set(f.metadata.id,()=>a.success(d.jsxs(d.Fragment,{children:["ISO"," ",d.jsx(je,{to:`/ui/project/${encodeURIComponent(s??"")}/storage/custom-isos`,type:"iso-volume",value:i.aliases})," ","attached to ",b]})),E=>a.failure("Attaching ISO failed.",new Error(E),b),()=>{g.invalidateQueries({queryKey:[Ce.instances,t.name,s]}),m(!1)})}).catch(f=>{m(!1),a.failure("Attaching ISO failed.",f)})},_=l(t)?void 0:"You do not have permission to edit this instance.";return p?d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"u-text--muted margin-right",children:p.source}),d.jsx(O.ActionButton,{loading:u,onClick:C,className:"u-no-margin--bottom",disabled:!!_||u,title:_,children:"Detach ISO"})]}):d.jsxs(d.Fragment,{children:[d.jsx(O.ActionButton,{loading:u,onClick:w,className:"u-no-margin--bottom",disabled:!!_||u,title:_,children:"Attach ISO"}),r&&d.jsx(n,{children:d.jsx(_a,{onClose:y,onSelect:S})})]})},Fl=({instance:t})=>{const e=O.useNotify(),s=t.type==="virtual-machine",[a,g]=Z.useState(s),{hasCustomVolumeIso:w}=lr(),{canUpdateInstanceState:y,canAccessInstanceConsole:r}=Oe(),n=is(t),u=(i,o,c)=>{e.failure(i,o,c)},m=()=>{e.info("Start the instance to interact with the text console.","Instance not running")};let l=()=>{};const p=i=>{l=i},C=i=>{e.clear(),g(i)},{handleStart:S,isLoading:_}=dr(t);return r(t)?d.jsxs("div",{className:"instance-console-tab",children:[s&&d.jsxs("div",{className:"p-panel__controls",children:[d.jsxs("div",{className:"console-radio-wrapper",children:[d.jsx(O.RadioInput,{labelClassName:"right-margin",label:"Graphic",checked:a,onChange:()=>{C(!0)}}),d.jsx(O.RadioInput,{label:"Text console",checked:!a,onChange:()=>{C(!1)}})]}),a&&n&&d.jsxs("div",{children:[w&&d.jsx(jl,{instance:t}),d.jsx(O.Button,{className:"u-no-margin--bottom",onClick:()=>{l()},children:d.jsx("span",{children:"Fullscreen"})}),d.jsx(O.ContextualMenu,{hasToggleIcon:!0,toggleLabel:"Shortcuts",toggleClassName:"u-no-margin--bottom",links:[{children:"Send Ctrl + Alt + Del",onClick:()=>{ll(window.spice_connection)}},{children:"Send Alt + TAB",onClick:()=>{dl(window.spice_connection)}},{children:"Send Alt + F4",onClick:()=>{ul(window.spice_connection)}}]})]})]}),d.jsx(ts,{}),a&&!n&&d.jsxs(O.EmptyState,{className:"empty-state",image:d.jsx(O.Icon,{name:"pods",className:"empty-state-icon"}),title:"Instance stopped",children:[d.jsx("p",{children:"Start the instance to access the graphic console."}),d.jsx(O.ActionButton,{appearance:"positive",loading:_,"aria-disabled":_,onClick:S,disabled:!y(t),title:y(t)?"":"You do not have permission to start this instance.",children:"Start instance"})]}),a&&n&&d.jsx("div",{className:"spice-wrapper",children:d.jsx(Nl,{instance:t,onMount:p,onFailure:u})}),!a&&d.jsx(Ul,{instance:t,onFailure:u,showNotRunningInfo:m})]}):d.jsx(O.Notification,{severity:"caution",title:"Restricted permissions",children:"You do not have permission to access the console for this instance."})},Hl=({instance:t,content:e,fileName:s})=>{const a=Z.useRef(null),g=(y,r)=>{const n=document.createElement("a");return n.setAttribute("href",r),n.setAttribute("target","_blank"),n.setAttribute("download",s),n.setAttribute("id",y),n.style.display="none",n},w=async()=>{var p;const y=`link-${s.toLowerCase().replace(" ","-")}`,r=document.getElementById(y);if(r){r.click();return}const n=e||await fr(t.name,t.project,s),u=new Blob([n],{type:"text/plain"}),m=URL.createObjectURL(u),l=g(y,m);(p=a.current)==null||p.appendChild(l),l.click()};return d.jsx(O.Button,{appearance:"base",className:"u-no-margin--bottom",onClick:()=>void w(),title:`Download ${s}`,"aria-label":`Download ${s} file`,hasIcon:!0,dense:!0,ref:a,children:d.jsx(O.Icon,{name:"begin-downloading",alt:"download"})})},Kl=({instance:t,path:e})=>{const s=e.split("/").at(-1)??"",a=`/ui/project/${encodeURIComponent(t.project)}/instance/${encodeURIComponent(t.name)}/logs/?file=${encodeURIComponent(s)}`,[g,w]=Z.useState(Co("file")===s),{data:y,isLoading:r,isSuccess:n}=ur({queryKey:[Ce.logs,t.name,t.project,s],queryFn:async()=>fr(t.name,t.project,s),enabled:g}),u=()=>{w(m=>!m)};return d.jsxs("div",{className:"p-code-snippet file-row",children:[d.jsxs("div",{className:"p-code-snippet__header file-row-header",children:[d.jsxs(O.Button,{appearance:"base",hasIcon:!0,className:"u-no-margin--bottom file-row-toggle","aria-label":`Toggle ${s} visibility`,"aria-controls":s,"aria-hidden":!g,onClick:u,children:[d.jsx(O.Icon,{name:g?"chevron-up":"chevron-down"}),d.jsx("h2",{className:"p-code-snippet__title file-row-title",children:s})]}),d.jsx("a",{href:a,"aria-label":`File ${s} URL`,className:"p-button--base u-no-margin--bottom",children:d.jsx(O.Icon,{name:"get-link",alt:"link"})}),d.jsx(Hl,{fileName:s,instance:t,content:y??""})]}),g&&d.jsx("pre",{id:s,className:"p-code-snippet__block","aria-hidden":!g,children:d.jsxs("code",{children:[r&&d.jsx(d.Fragment,{children:"Downloading file content..."}),n&&!y&&d.jsx(d.Fragment,{children:"This file is empty."}),n&&y&&d.jsx(d.Fragment,{children:y})]})})]})},Gl=({instance:t})=>{const{data:e=[],isLoading:s}=ur({queryKey:[Ce.logs,t.name,t.project],queryFn:async()=>Go(t.name,t.project)});return d.jsxs(d.Fragment,{children:[s&&d.jsx(O.Spinner,{className:"u-loader",text:"Loading logs..."}),!s&&e.length===0&&d.jsx("div",{className:"u-align-text--center",children:"There are no log files for this instance."}),!s&&e.length>0&&e.map(a=>d.jsx(Kl,{instance:t,path:a},a))]})},Yl=({instanceProfiles:t,profiles:e})=>t.some(a=>!(e!=null&&e.find(g=>g.name===a)))?d.jsx(O.Notification,{severity:"caution",title:"Restricted permissions",children:"You do not have permission to view all profiles applied to this instance. This may cause inherited configuration values to be displayed incorrectly."}):null,zl=({instance:t})=>{const e=ar(),s=Ee(),a=O.useToastNotification(),{project:g,section:w}=tt(),y=Be(),r=Mt(),[n,u]=Z.useState(0),{canEditInstance:m}=Oe();if(!g)return d.jsx(d.Fragment,{children:"Missing project"});const{data:l=[]}=er(g),p=()=>{ht("form-contents","p-bottom-controls")};Z.useEffect(p,[w]),O.useListener(window,p,"resize",!0);const C=m(t)?void 0:"You do not have permission to edit this instance",S=Ne({initialValues:at(t,C),validationSchema:Sr,enableReinitialize:!0,onSubmit:h=>{const f=h.yaml?fa(h.yaml):Ht(t,h);f.etag=t.etag;const b=d.jsx(ue,{instance:t});Ft(f,g).then(E=>{s.set(E.metadata.id,()=>{a.success(d.jsxs(d.Fragment,{children:["Instance ",b," updated."]})),S.setValues(at(f))},I=>a.failure("Instance update failed.",new Error(I),b),()=>{S.setSubmitting(!1),y.invalidateQueries({queryKey:[Ce.instances]})})}).catch(E=>{S.setSubmitting(!1),a.failure("Instance update failed.",E,b)})}}),_=`/ui/project/${encodeURIComponent(g)}/instance/${encodeURIComponent(t.name)}/configuration`,i=h=>{S.values.yaml&&h!==bt&&S.setFieldValue("yaml",void 0),r(h===Es?_:`${_}/${pe(h)}`)},o=()=>{const h=new Set(["backups","snapshots","state","expanded_config","expanded_devices","etag"]),f=Object.fromEntries(Object.entries(t).filter(b=>!h.has(b[0])));return Pa(f)},c=S.values.readOnly;return d.jsxs("div",{className:"edit-instance",children:[d.jsxs(O.Form,{onSubmit:S.handleSubmit,className:"form",children:[w!==pe(bt)&&d.jsx(pa,{active:w??pe(Es),setActive:i,isDisabled:!1,hasDiskError:Ci(S),hasNetworkError:bi(S)}),d.jsx(O.Row,{className:"form-contents",children:d.jsxs(O.Col,{size:12,children:[w!==pe(bt)&&d.jsx(Yl,{instanceProfiles:t.profiles,profiles:l}),(w===pe(Es)||!w)&&d.jsx(ra,{formik:S,project:g}),w===pe(ma)&&d.jsx(La,{formik:S,project:g}),w===pe(ga)&&d.jsx(Da,{formik:S,project:g}),w===pe(va)&&d.jsx(Ma,{formik:S,project:g}),w===pe(Sa)&&d.jsx(Ta,{formik:S,project:g}),w===pe(ba)&&d.jsx(Ra,{formik:S,project:g}),w===pe(Ca)&&d.jsx(na,{formik:S}),w===pe(Ea)&&d.jsx(oa,{formik:S}),w===pe(ya)&&d.jsx(br,{formik:S}),w===pe(wa)&&d.jsx(aa,{formik:S}),w===pe(xa)&&d.jsx(ca,{formik:S}),w===pe(Ia)&&d.jsx(ha,{formik:S},`yaml-form-${n}`),w===pe(bt)&&d.jsx(la,{yaml:o(),setYaml:h=>{ua(S),S.setFieldValue("yaml",h)},readOnly:!!S.values.editRestriction,readOnlyMessage:S.values.editRestriction,children:d.jsx(Ba,{entity:"instance",href:`${e}/instances`})},`yaml-form-${n}`)]})},w)]}),d.jsxs(ka,{children:[d.jsx(Aa,{formik:S,section:w,setSection:i}),c?null:d.jsxs(d.Fragment,{children:[d.jsx(O.Button,{appearance:"base",onClick:()=>{S.setValues(at(t)),u(h=>h+1)},children:"Cancel"}),d.jsx(Oa,{formik:S,baseUrl:_,isYaml:w===pe(bt),disabled:Ci(S)||bi(S)})]})]})]})},Wl=({instance:t,classname:e,onClose:s})=>{const a=Ee(),g=O.useToastNotification(),w=Be(),y=ss(),[r,n]=Z.useState(!1),u=Mt(),{canDeleteInstance:m}=Oe(),l=()=>{n(!0);const _=d.jsx(ue,{instance:t});Yo(t).then(i=>{a.set(i.metadata.id,()=>{w.invalidateQueries({queryKey:[Ce.projects,t.project]}),u(`/ui/project/${encodeURIComponent(t.project)}/instances`),g.success(d.jsxs(d.Fragment,{children:["Instance"," ",d.jsx(ot,{bold:!0,type:t.type,value:t.name})," ","deleted."]}))},o=>g.failure("Instance deletion failed",new Error(o),_),()=>{n(!1)})}).catch(i=>{g.failure("Instance deletion failed",i,_),n(!1)})},p=ko.includes(t.status),C=r||!p||y.getType(t)==="Migrating"||!m(t),S=()=>m(t)?p?"Delete instance":"Stop the instance to delete it":"You do not have permission to delete this instance";return d.jsxs(O.ConfirmationButton,{onHoverText:S(),appearance:"default",className:Ze("u-no-margin--bottom has-icon",e),loading:r,confirmationModalProps:{close:s,title:"Confirm delete",children:d.jsxs("p",{children:["This will permanently delete instance"," ",d.jsx(ot,{type:t.type,value:t.name,bold:!0}),".",d.jsx("br",{}),"This action cannot be undone, and can result in data loss."]}),onConfirm:l,confirmButtonLabel:"Delete"},disabled:C||r,shiftClickEnabled:!0,showShiftClickHint:!0,children:[d.jsx(O.Icon,{name:"delete"}),d.jsx("span",{children:"Delete"})]})},$l=({onSelect:t,disableMember:e})=>{const{data:s=[],isLoading:a}=Eo(),g=[{content:"Name",sortKey:"name"},{content:"Roles",sortKey:"roles"},{content:"Architecture",sortKey:"architecture"},{content:"Status",sortKey:"status"},{"aria-label":"Actions",className:"actions"}],w=s.map(y=>{const r=(e==null?void 0:e.name)===y.server_name?e==null?void 0:e.reason:null,n=()=>{r||t(y.server_name)};return{key:y.server_name,className:Ze("u-row",{"u-text--muted":r,"u-row--disabled":r}),columns:[{content:d.jsx("div",{className:"u-truncate migrate-instance-name",title:y.server_name,children:y.server_name}),role:"rowheader","aria-label":"Name",onClick:n},{content:y.roles.join(", "),role:"cell","aria-label":"Roles",onClick:n},{content:y.architecture,role:"cell","aria-label":"Architecture",onClick:n},{content:y.status,role:"cell","aria-label":"Status",onClick:n},{content:d.jsx(O.Button,{onClick:n,dense:!0,title:r,disabled:!!r,children:"Select"}),role:"cell","aria-label":"Actions",className:"u-align--right",onClick:n}],sortData:{name:y.server_name.toLowerCase(),roles:y.roles.join(", ").toLowerCase(),architecture:y.architecture.toLowerCase(),status:y.status.toLowerCase()}}});return d.jsx("div",{className:"migrate-instance-table u-selectable-table-rows",children:d.jsx(Ws,{dependencies:[s],tableId:"migrate-instance-table",belowIds:["status-bar","migrate-instance-actions"],children:d.jsx(O.MainTable,{id:"migrate-instance-table",headers:g,rows:w,sortable:!0,className:"u-table-layout--auto",emptyStateMsg:a?"Loading cluster members...":"No cluster members available"})})})},Vl=({instance:t,onSelect:e,targetMember:s,onCancel:a,migrate:g})=>{const w=d.jsx("div",{className:"migrate-instance-summary",children:d.jsxs("p",{children:["This will migrate instance ",d.jsx("strong",{children:t.name})," to cluster member ",d.jsx("b",{children:s}),"."]})});return d.jsxs(d.Fragment,{children:[s&&w,!s&&d.jsx($l,{onSelect:e,disableMember:{name:t.location,reason:"Instance already on this member"}}),d.jsxs("footer",{id:"migrate-instance-actions",className:"p-modal__footer",children:[d.jsx(O.Button,{className:"u-no-margin--bottom",type:"button","aria-label":"cancel migrate",appearance:"base",onClick:a,children:"Cancel"}),d.jsx(O.ActionButton,{appearance:"positive",className:"u-no-margin--bottom",onClick:()=>{g(s)},disabled:!s,children:"Migrate"})]})]})},ql=({instance:t,onSelect:e,targetPool:s,onCancel:a,migrate:g})=>{const w=d.jsx("div",{className:"migrate-instance-summary",children:d.jsxs("p",{children:["This will migrate the instance ",d.jsx("strong",{children:t.name})," root storage to pool ",d.jsx("b",{children:s}),"."]})});return d.jsxs(d.Fragment,{children:[s&&w,!s&&d.jsx(ja,{onSelect:e,disablePool:{name:yo(t),reason:"Instance root storage already in this pool"}}),d.jsxs("footer",{id:"migrate-instance-actions",className:"p-modal__footer",children:[d.jsx(O.Button,{className:"u-no-margin--bottom",type:"button","aria-label":"cancel migrate",appearance:"base",onClick:a,children:"Cancel"}),d.jsx(O.ActionButton,{appearance:"positive",className:"u-no-margin--bottom",onClick:()=>{g(s)},disabled:!s,children:"Migrate"})]})]})},Xl=({instance:t,close:e,type:s,target:a})=>{const g=O.useToastNotification(),w=ss(),y=Ee(),r=Be(),n=Mt(),u=()=>{let S="";if(s==="cluster member"&&(S=d.jsxs(d.Fragment,{children:["Instance ",d.jsx(ue,{instance:t})," successfully migrated to cluster member"," ",d.jsx(je,{type:"cluster-member",value:a,to:`/ui/cluster/member/${encodeURIComponent(a)}`})]})),s==="root storage pool"&&(S=d.jsxs(d.Fragment,{children:["Instance ",d.jsx(ue,{instance:t})," root storage successfully moved to pool"," ",d.jsx(je,{type:"pool",value:a,to:`/ui/project/${encodeURIComponent(t.project)}/storage/pool/${encodeURIComponent(a)}`})]})),s==="project"){S=d.jsxs(d.Fragment,{children:["Instance"," ",d.jsx(ue,{instance:{...t,project:a}}),"successfully moved to project"," ",d.jsx(je,{type:"project",value:a,to:`/ui/project/${encodeURIComponent(a)}`})]});const _=window.location.pathname,i=_.replace(`/project/${t.project}/instance/${t.name}`,`/project/${a}/instance/${t.name}`);_!==i&&n(i)}g.success(S)},m=S=>{let _="";s==="cluster member"&&(_=`Cluster member migration failed for instance ${t.name}`),s==="root storage pool"&&(_=`Root storage move failed for instance ${t.name}`),s==="project"&&(_=`Project move failed for instance ${t.name}`),w.setFinish(t),g.failure(_,S,d.jsx(ue,{instance:t}))},l=S=>{m(new Error(S))},p=()=>{r.invalidateQueries({queryKey:[Ce.instances,t.name,t.project]}),w.setFinish(t)};return{handleMigrate:()=>{w.setLoading(t,"Migrating");const S=s==="cluster member"?a:void 0,_=s==="root storage pool"?a:void 0,i=s==="project"?a:void 0;zo(t.name,t.project,S,_,i).then(o=>{y.set(o.metadata.id,u,c=>{l(c)},p),g.info(d.jsxs(d.Fragment,{children:[wo(s)," migration started for"," ",d.jsx(ue,{instance:t}),"."]})),r.invalidateQueries({queryKey:[Ce.instances,t.name,t.project]})}).catch(o=>{m(o)}).finally(()=>{e()})}}},Ql=({onSelect:t,disableProject:e})=>{const{data:s=[]}=Dt(),{canCreateInstances:a}=Ge(),g=[{content:"Name",sortKey:"name"},{"aria-label":"Actions",className:"actions"}],w=s.map(y=>{const r=()=>a(y)?(e==null?void 0:e.name)===y.name?e==null?void 0:e.reason:null:"You do not have permission to create instances in this project",n=()=>{r()||t(y.name)};return{key:y.name,className:Ze("u-row",{"u-text--muted":!!r(),"u-row--disabled":!!r()}),columns:[{content:d.jsx("div",{className:"u-truncate migrate-instance-name",title:y.name,children:y.name}),role:"rowheader","aria-label":"Name",onClick:n},{content:d.jsx(O.Button,{onClick:n,dense:!0,title:r(),disabled:!!r(),children:"Select"}),role:"cell","aria-label":"Actions",className:"u-align--right",onClick:n}],sortData:{name:y.name.toLowerCase()}}});return d.jsx("div",{className:"migrate-instance-table u-selectable-table-rows",children:d.jsx(Ws,{dependencies:[s],tableId:"migrate-instance-table",belowIds:["status-bar","migrate-instance-actions"],children:d.jsx(O.MainTable,{id:"migrate-instance-table",headers:g,rows:w,sortable:!0,className:"u-table-layout--auto"})})})},Zl=({instance:t,onSelect:e,targetProject:s,onCancel:a,migrate:g})=>{const w=d.jsx("div",{className:"migrate-instance-summary",children:d.jsxs("p",{children:["This will migrate the instance ",d.jsx("strong",{children:t.name})," to the project ",d.jsx("b",{children:s}),"."]})});return d.jsxs(d.Fragment,{children:[s&&w,!s&&d.jsx(Ql,{onSelect:e,disableProject:{name:t.project,reason:"Instance already in this project"}}),d.jsxs("footer",{id:"migrate-instance-actions",className:"p-modal__footer",children:[d.jsx(O.Button,{className:"u-no-margin--bottom",type:"button","aria-label":"cancel migrate",appearance:"base",onClick:a,children:"Cancel"}),d.jsx(O.ActionButton,{appearance:"positive",className:"u-no-margin--bottom",onClick:()=>{g(s)},disabled:!s,children:"Migrate"})]})]})},Jl=({close:t,instance:e})=>{const s=Ys(),[a,g]=Z.useState(""),[w,y]=Z.useState(""),{handleMigrate:r}=Xl({close:t,instance:e,type:a,target:w}),n=p=>{p.key==="Escape"&&t()},u=()=>{if(w){y("");return}if(a){g("");return}},m=d.jsxs(d.Fragment,{children:["Choose ",a," for instance ",d.jsx("strong",{children:e.name})]}),l=a?d.jsx(Ua,{title:w?"Confirm migration":m,onClick:u,linkText:w?`Choose ${a}`:"Choose migration method"}):"Choose migration method";return d.jsxs(O.Modal,{close:t,className:"migrate-instance-modal",onKeyDown:n,"aria-labelledby":"migrate-title",children:[d.jsxs("header",{className:"p-modal__header",children:[d.jsx("h2",{className:"p-modal__title",id:"migrate-title",children:l},a?w?"confirm":"select":"start"),d.jsx("button",{className:"p-modal__close","aria-label":"Close active modal",onClick:t,children:"Close"})]}),!a&&d.jsxs("div",{className:"choose-migration-type",children:[s&&d.jsx(ys,{icon:"cluster-host",title:"Migrate instance to a different cluster member",onClick:()=>{g("cluster member")}}),d.jsx(ys,{icon:"switcher-dashboard",title:"Move instance root storage to a different pool",onClick:()=>{g("root storage pool")}}),d.jsx(ys,{icon:"folder",title:"Move instance to a different project",onClick:()=>{g("project")}})]}),a==="cluster member"&&d.jsx(Vl,{instance:e,onSelect:y,targetMember:w,onCancel:u,migrate:r}),a==="root storage pool"&&d.jsx(ql,{instance:e,onSelect:y,targetPool:w,onCancel:u,migrate:r}),a==="project"&&d.jsx(Zl,{instance:e,onSelect:y,targetProject:w,onCancel:u,migrate:r})]})},eu=({instance:t,classname:e})=>{const{openPortal:s,closePortal:a,isOpen:g,Portal:w}=O.usePortal(),{canEditInstance:y}=Oe(),r=ss(),n=r.getType(t)==="Migrating"||t.status==="Migrating",u=n||!!r.getType(t);return d.jsxs(d.Fragment,{children:[g&&d.jsx(w,{children:d.jsx(Jl,{close:a,instance:t})}),d.jsxs(O.ActionButton,{onClick:s,type:"button",className:Ze("u-no-margin--bottom has-icon",e),loading:n,disabled:u||!y(t)||n,title:y()?"Migrate instance":"You do not have permission to migrate this instance",children:[d.jsx(O.Icon,{name:"machines"}),d.jsx("span",{children:"Migrate"})]})]})},tu=({instance:t,close:e})=>{const s=Ee(),a=O.useToastNotification(),g=Be(),w=d.jsx(ue,{instance:t}),{data:y}=Lt(t.project),{canCreateImageAliases:r}=Ge(),n=()=>{const p=d.jsx(Gs,{to:`/ui/project/${encodeURIComponent(t.project)}/images`,children:"created"});a.success(d.jsxs(d.Fragment,{children:["Image ",p," from instance ",w,"."]}))},u=()=>{g.invalidateQueries({predicate:p=>p.queryKey[0]===Ce.images})},m=(p,C)=>JSON.stringify({public:C,source:{name:p.name,type:"instance"}}),l=Ne({initialValues:{alias:r(y)?`from-instance-${t.name}`:"",isPublic:!1},validationSchema:Xe().shape({alias:Ve()}),onSubmit:p=>{const C=p.alias;ir(m(t,p.isPublic),t).then(S=>{a.info(d.jsxs(d.Fragment,{children:["Creation of image from instance ",w," started."]})),s.set(S.metadata.id,_=>{var i;if(C){const o=((i=_.metadata.metadata)==null?void 0:i.fingerprint)??"";rr(o,C,t.project).then(u).then(n).catch(c=>{a.failure(`Image creation from instance "${t.name}" succeeded. Failed to create an alias.`,c)})}else u(),n()},_=>{a.failure(`Image creation from instance "${t.name}" failed.`,new Error(_),w)})}).catch(S=>{a.failure(`Image creation from instance "${t.name}" failed.`,S,w)}).finally(()=>{e()})}});return d.jsx(O.Modal,{close:e,className:"create-image-from-instance-modal",title:"Create image from instance",buttonRow:d.jsxs(d.Fragment,{children:[d.jsx(O.Button,{appearance:"base",className:"u-no-margin--bottom",type:"button",onClick:e,children:"Cancel"}),d.jsx(O.ActionButton,{appearance:"positive",className:"u-no-margin--bottom",loading:l.isSubmitting,disabled:!l.isValid||l.isSubmitting,onClick:()=>void l.submitForm(),children:"Create image"})]}),children:d.jsxs(O.Form,{onSubmit:l.handleSubmit,children:[d.jsx(O.Input,{type:"text",label:"Instance",value:t.name,disabled:!0}),d.jsx(O.Input,{...l.getFieldProps("alias"),type:"text",label:"Alias",error:l.touched.alias?l.errors.alias:null,disabled:!r(y),title:r(y)?"":"You do not have permission to create image aliases in this project"}),d.jsx(O.Input,{...l.getFieldProps("isPublic"),type:"checkbox",label:"Make the image publicly available",error:l.touched.isPublic?l.errors.isPublic:null}),d.jsx(O.Input,{type:"submit",hidden:!0,value:"Hidden input"})]})})},su=({instance:t,classname:e,onClose:s})=>{const{openPortal:a,closePortal:g,isOpen:w,Portal:y}=O.usePortal(),{data:r}=Lt(t.project),{canCreateImages:n}=Ge(),u=ss(),m=["Error","Frozen","Running"],l=()=>{g(),s==null||s()},p=()=>n(r)?m.includes(t==null?void 0:t.status)||!!u.getType(t)?"Stop the instance to create an image":"":"You do not have permission to create images in this project";return d.jsxs(d.Fragment,{children:[w&&d.jsx(y,{children:d.jsx(tu,{close:l,instance:t})}),d.jsxs(O.ActionButton,{appearance:"default",className:Ze("u-no-margin--bottom has-icon",e),onClick:a,"aria-label":"Create image",title:p()||"Create image",disabled:!!p(),children:[d.jsx(O.Icon,{name:"plus"}),d.jsx("span",{children:"Create Image"})]})]})},iu=({instance:t,close:e})=>{var i,o;const s=O.useToastNotification(),a=Ys(),g=Z.useState(null),w=Mt(),y=Ee(),{data:r=[],isLoading:n}=Dt(),{canCreateInstances:u}=Ge(),{data:m=[],isLoading:l}=nr(),{data:p=[]}=vr(t.project),C=(c,h,f)=>{const b=`/ui/project/${encodeURIComponent(h)}/instance/${encodeURIComponent(c)}`,E=d.jsxs(d.Fragment,{children:["Created instance"," ",d.jsx(je,{type:f,value:c,to:b}),"."]}),I=[{label:"Configure",onClick:async()=>w(`${b}/configuration`)}];s.success(E,I)},_=Ne({initialValues:{instanceName:(c=>{const h=or(c.name,"-copy");return xo(h,p)})(t),targetProject:t.project,allowInconsistent:!1,instanceOnly:!1,targetClusterMember:a?t.location:"",targetStoragePool:((i=t.devices.root)==null?void 0:i.pool)??((o=m[0])==null?void 0:o.name)},enableReinitialize:!0,validationSchema:Xe().shape({instanceName:zs(t.project,g).required()}),onSubmit:c=>{const h=d.jsx(ue,{instance:t});_r(JSON.stringify({description:t.description,name:c.instanceName,architecture:t.architecture,source:{allow_inconsistent:c.allowInconsistent,instance_only:c.instanceOnly,source:t.name,type:"copy",project:t.project},devices:{...t.devices,root:{path:"/",type:"disk",pool:c.targetStoragePool}}}),c.targetProject,c.targetClusterMember).then(f=>{s.info(d.jsxs(d.Fragment,{children:["Copy of instance ",h," started."]})),y.set(f.metadata.id,()=>{C(c.instanceName,c.targetProject,t.type)},b=>s.failure("Instance copy failed.",new Error(b),h))}).catch(f=>{s.failure("Instance copy failed.",f,h)}).finally(()=>{e()})}});return d.jsx(O.Modal,{close:e,className:"copy-instances-modal",title:"Copy Instance",buttonRow:d.jsxs(d.Fragment,{children:[d.jsx(O.Button,{appearance:"base",className:"u-no-margin--bottom",type:"button",onClick:e,children:"Cancel"}),d.jsx(O.ActionButton,{appearance:"positive",className:"u-no-margin--bottom",loading:_.isSubmitting,disabled:!_.isValid||_.isSubmitting||l||n,onClick:()=>void _.submitForm(),children:"Copy"})]}),children:d.jsxs(O.Form,{onSubmit:_.handleSubmit,children:[d.jsx(O.Input,{..._.getFieldProps("instanceName"),type:"text",label:"New instance name",error:_.touched.instanceName?_.errors.instanceName:null}),d.jsx(gr,{..._.getFieldProps("targetClusterMember"),id:"targetClusterMember",label:"Target cluster member"}),d.jsx(Fa,{..._.getFieldProps("targetStoragePool"),setValue:c=>void _.setFieldValue("targetStoragePool",c),selectProps:{id:"storagePool",label:"Storage pool"}}),d.jsx(O.Select,{..._.getFieldProps("targetProject"),id:"project",label:"Target project",options:r.filter(u).map(c=>({label:c.name,value:c.name}))}),d.jsx(O.Input,{..._.getFieldProps("allowInconsistent"),type:"checkbox",label:"Ignore copy errors for volatile files",error:_.touched.allowInconsistent?_.errors.allowInconsistent:null}),d.jsx(O.Input,{..._.getFieldProps("instanceOnly"),type:"checkbox",label:"Copy without instance snapshots",error:_.touched.instanceOnly?_.errors.instanceOnly:null}),d.jsx(O.Input,{type:"submit",hidden:!0,value:"Hidden input"})]})})},ru=({instance:t,isLoading:e,classname:s,onClose:a})=>{const{openPortal:g,closePortal:w,isOpen:y,Portal:r}=O.usePortal(),{data:n}=Lt(t.project),{data:u}=Dt(),{canCreateInstances:m}=Ge(),l=()=>{w(),a==null||a()},p=()=>{const C=u==null?void 0:u.filter(m);return!m(n)||!(C!=null&&C.length)?"You do not have permission to copy instances":e?"Loading...":""};return d.jsxs(d.Fragment,{children:[y&&d.jsx(r,{children:d.jsx(iu,{close:l,instance:t})}),d.jsxs(O.Button,{appearance:"default","aria-label":"Copy instance",className:Ze("u-no-margin--bottom has-icon",s),disabled:!!p(),onClick:g,title:p()||"Copy instance",children:[d.jsx(O.Icon,{name:"canvas"}),d.jsx("span",{children:"Copy"})]})]})},nu=({instance:t,close:e})=>{var C;const s=Ee(),a=O.useToastNotification(),g=d.jsx(ue,{instance:t}),{hasBackupMetadataVersion:w}=lr(),y=Be(),{data:r}=Ks(),n=((C=r==null?void 0:r.environment)==null?void 0:C.backup_metadata_version_range)??[],u=S=>{const _=`/1.0/instances/${encodeURIComponent(t.name)}/backups/${encodeURIComponent(S)}/export?project=${encodeURIComponent(t.project)}`,i=document.createElement("a");i.href=_,i.download=S,i.click(),window.URL.revokeObjectURL(_),a.success(d.jsxs(d.Fragment,{children:["Instance ",g," download started:",d.jsx("br",{}),d.jsx("a",{href:_,children:S})]}))},m=S=>{const _=new Date;return _.setHours(_.getHours()+S),_},l=S=>{const _=new Date().toISOString().replaceAll(":","-").split(".")[0],i=`${t.name}-${_}.tar${S.compression==="gzip"?".gz":""}`,o=JSON.stringify({name:i,expires_at:m(S.expirationHours).toISOString(),compression_algorithm:S.compression,instance_only:S.instanceOnly,optimized_storage:S.optimizedStorage,version:w?Number(S.exportVersion):void 0});Wo(t.name,t.project,o).then(c=>{a.info(d.jsxs(d.Fragment,{children:["Backing up instance ",g,".",d.jsx("br",{}),"Download will start, when the export is ready."]})),s.set(c.metadata.id,()=>{u(i)},h=>a.failure(`Could not download instance ${t.name}`,new Error(h),g))}).catch(c=>a.failure(`Could not download instance ${t.name}`,c,g)).finally(()=>{y.invalidateQueries({queryKey:[Ce.operations]}),e()})},p=Ne({initialValues:{compression:"gzip",exportVersion:"2",expirationHours:6,instanceOnly:!1,optimizedStorage:!0},onSubmit:S=>{l(S)}});return d.jsx(O.Modal,{close:e,className:"export-instance-modal",title:"Export Instance",buttonRow:d.jsxs(d.Fragment,{children:[d.jsx(O.Button,{appearance:"base",className:"u-no-margin--bottom",type:"button",onClick:e,children:"Cancel"}),d.jsx(O.ActionButton,{appearance:"positive",className:"u-no-margin--bottom",loading:p.isSubmitting,disabled:p.isSubmitting,onClick:()=>void p.submitForm(),children:"Export instance"})]}),children:d.jsxs(O.Form,{onSubmit:p.handleSubmit,children:[d.jsx(O.Select,{...p.getFieldProps("compression"),id:"project",label:"Compression",help:"No compression will be faster, but larger",options:[{value:"gzip",label:"Gzip"},{value:"none",label:"None"}]}),d.jsx(O.Select,{...p.getFieldProps("expirationHours"),id:"project",label:"Expiration",help:"Duration that the backup remains on the server",options:[{value:1,label:"1 hour"},{value:6,label:"6 hours"},{value:12,label:"12 hours"},{value:24,label:"1 day"},{value:72,label:"3 days"},{value:168,label:"7 days"}]}),w&&d.jsx(O.Select,{...p.getFieldProps("exportVersion"),id:"exportVersion",label:"Export version",help:"Lower versions allow imports on older LXD versions",options:n.map(S=>({value:S.toString(),label:S.toString()}))}),d.jsx(O.Input,{...p.getFieldProps("optimizedStorage"),type:"checkbox",label:"Use storage driver optimized format",help:"Can only be restored on a similar pool",checked:p.values.optimizedStorage}),d.jsx(O.Input,{...p.getFieldProps("instanceOnly"),type:"checkbox",label:"Export without instance snapshots",error:p.touched.instanceOnly?p.errors.instanceOnly:null,checked:p.values.instanceOnly}),d.jsx(O.Input,{type:"submit",hidden:!0,value:"Hidden input"})]})})},ou=({instance:t,classname:e,onClose:s})=>{const{openPortal:a,closePortal:g,isOpen:w,Portal:y}=O.usePortal(),{canManageInstanceBackups:r}=Oe(),n=()=>{g(),s==null||s()};return d.jsxs(d.Fragment,{children:[w&&d.jsx(y,{children:d.jsx(nu,{close:n,instance:t})}),d.jsxs(O.Button,{appearance:"default",className:Ze("u-no-margin--bottom has-icon",e),onClick:a,title:r(t)?"Export instance":"You do not have permission to export this instance.",disabled:!r(t),children:[d.jsx(O.Icon,{name:"export"}),d.jsx("span",{children:"Export"})]})]})},au=({instance:t,project:e,isLoading:s})=>{const a=Io(Ao),g=a?"p-contextual-menu__link":"p-segmented-control__button",w=[d.jsx(eu,{instance:t,project:e,classname:g},"migrate"),d.jsx(su,{instance:t,classname:g},"publish"),d.jsx(ru,{instance:t,isLoading:s,classname:g},"copy"),d.jsx(ou,{instance:t,classname:g},"export"),d.jsx(Wl,{instance:t,classname:g},"delete")];return d.jsx(d.Fragment,{children:a?d.jsx(O.ContextualMenu,{closeOnOutsideClick:!1,toggleLabel:"Actions",position:"left",hasToggleIcon:!0,title:"actions",children:y=>d.jsx("span",{children:[...w].map(r=>Z.cloneElement(r,{onClose:y}))})}):d.jsx("div",{className:"p-segmented-control",children:d.jsx("div",{className:"p-segmented-control__list",children:w})})})},cu=({name:t,instance:e,project:s,isLoading:a})=>{const g=Ee(),w=Mt(),y=O.useToastNotification(),{canEditInstance:r}=Oe(),n=Z.useState(null),{canViewProject:u}=cr(),m=Xe().shape({name:zs(s,n,t).required("Instance name is required")}),l=Ne({initialValues:{name:t,isRenaming:!1},validationSchema:m,onSubmit:C=>{if(t===C.name){l.setFieldValue("isRenaming",!1),l.setSubmitting(!1);return}$o(t,C.name,s).then(S=>{const _=d.jsx(ue,{instance:{name:C.name,project:s,type:(e==null?void 0:e.type)||"instance"}});g.set(S.metadata.id,()=>{w(`/ui/project/${encodeURIComponent(s)}/instance/${encodeURIComponent(C.name)}`),y.success(d.jsxs(d.Fragment,{children:["Instance"," ",d.jsx("strong",{children:Po(S.metadata)})," renamed to ",_,"."]})),l.setFieldValue("isRenaming",!1)},i=>y.failure("Renaming instance failed.",new Error(i),hr({operation:S,project:s,instanceType:(e==null?void 0:e.type)||"instance"})),()=>{l.setSubmitting(!1)})}).catch(S=>{l.setSubmitting(!1),y.failure("Renaming instance failed.",S,e&&d.jsx(ue,{instance:e}))})}}),p=()=>{if(!r(e))return"You do not have permission to rename this instance";if(!e)return"Invalid Instance: Cannot be renamed";if(e.status!=="Stopped")return"Stop the instance to rename"};return!a&&d.jsx(Na,{name:t,titleClassName:"instance-detail-title",parentItems:[d.jsx(Gs,{to:u?`/ui/project/${encodeURIComponent(s)}/instances`:"/ui/all-projects/instances",children:"Instances"},1)],renameDisabledReason:p(),centerControls:e?d.jsxs("div",{children:[d.jsx("i",{className:"status u-text--muted",children:e.status}),d.jsx(Bo,{instance:e},"state")]}):null,controls:e?d.jsx(au,{instance:e,project:s,isLoading:a}):null,isLoaded:!!e,formik:l})},hu=(t,e,s)=>{var w,y;const a=((w=s==null?void 0:s.config)==null?void 0:w["user.ui_grafana_base_url"])??((y=s==null?void 0:s.config)==null?void 0:y["user.grafana_base_url"])??"";return a?(a.includes("{instance}")?a:`${a}&var-job=lxd&var-project={project}&var-name={instance}&var-top=5`).replace("{instance}",encodeURIComponent(t)).replace("{project}",encodeURIComponent(e)):""},lu=["Overview","Configuration","Snapshots","Terminal","Console","Logs"],id=()=>{const{data:t}=Ks(),{name:e,project:s,activeTab:a}=tt();if(!e)return d.jsx(d.Fragment,{children:"Missing name"});if(!s)return d.jsx(d.Fragment,{children:"Missing project"});const{data:g,error:w,refetch:y,isLoading:r}=Zo(e,s),n=[...lu],u=hu(e,s,t);return u&&n.push({label:d.jsxs("div",{children:[d.jsx(O.Icon,{name:"external-link"})," Metrics"]}),href:u,target:"_blank",rel:"noopener noreferrer"}),d.jsxs(O.CustomLayout,{header:d.jsx(cu,{name:e,instance:g,project:s,isLoading:r}),contentClassName:"detail-page",children:[r&&d.jsx(O.Spinner,{className:"u-loader",text:"Loading instance details..."}),!r&&!g&&!w&&d.jsx(d.Fragment,{children:"Loading instance failed"}),w&&d.jsx(O.Strip,{children:d.jsx(O.Notification,{severity:"negative",title:"Error",children:w.message})}),!r&&g&&d.jsxs(O.Row,{children:[d.jsx(Ha,{tabs:n,activeTab:a,tabUrl:`/ui/project/${encodeURIComponent(s)}/instance/${encodeURIComponent(e)}`}),!a&&d.jsx("div",{role:"tabpanel","aria-labelledby":"overview",children:d.jsx(za,{instance:g})}),a==="configuration"&&d.jsx("div",{role:"tabpanel","aria-labelledby":"configuration",children:d.jsx(zl,{instance:g})}),a==="snapshots"&&d.jsx("div",{role:"tabpanel","aria-labelledby":"snapshots",children:d.jsx(bc,{instance:g})}),a==="terminal"&&d.jsx("div",{role:"tabpanel","aria-labelledby":"terminal",children:d.jsx(Ja,{instance:g,refreshInstance:y})}),a==="console"&&d.jsx("div",{role:"tabpanel","aria-labelledby":"console",children:d.jsx(Fl,{instance:g})}),a==="logs"&&d.jsx("div",{role:"tabpanel","aria-labelledby":"logs",children:d.jsx(Gl,{instance:g})})]})]})};export{id as default};
Copyright ©2k19 -
Hexid
|
Tex7ure