Linux ip-172-26-2-223 5.4.0-1018-aws #18-Ubuntu SMP Wed Jun 24 01:15:00 UTC 2020 x86_64
Apache
: 172.26.2.223 | : 3.141.6.24
Cant Read [ /etc/named.conf ]
8.1.13
www
www.github.com/MadExploits
Terminal
AUTO ROOT
Adminer
Backdoor Destroyer
Linux Exploit
Lock Shell
Lock File
Create User
CREATE RDP
PHP Mailer
BACKCONNECT
UNLOCK SHELL
HASH IDENTIFIER
CPANEL RESET
CREATE WP USER
BLACK DEFEND!
README
+ Create Folder
+ Create File
/
snap /
lxd /
33246 /
share /
lxd-ui /
assets /
[ HOME SHELL ]
Name
Size
Permission
Action
font
[ DIR ]
drwxr-xr-x
img
[ DIR ]
drwxr-xr-x
js
[ DIR ]
drwxr-xr-x
scripts
[ DIR ]
drwxr-xr-x
AutoExpandingTextArea-BXFyAEiG...
151
B
-rw-r--r--
BaseLayout-CiF2D8RH.js
280
B
-rw-r--r--
BulkDeleteButton-B-fvVwh0.js
1.08
KB
-rw-r--r--
CancelOperationBtn-BW2TAzI_.js
1.08
KB
-rw-r--r--
CertificateAdd-BGVwf-VB.js
2.84
KB
-rw-r--r--
CertificateGenerate-bNGS6BFl.j...
9.87
KB
-rw-r--r--
ClusterGroupForm-BiXmM-NU.js
3.25
KB
-rw-r--r--
ClusterList-CZFDB46f.js
5.17
KB
-rw-r--r--
ClusterMemberSelector-B2lzDpCI...
3.71
KB
-rw-r--r--
ClusterSpecificInput-BdiLVA9B....
1.97
KB
-rw-r--r--
ClusterSpecificSelect-DrKUzNev...
2.2
KB
-rw-r--r--
ConfigFieldDescription-BnRkdbo...
335
B
-rw-r--r--
CreateClusterGroup-C6s3qbZf.js
463
B
-rw-r--r--
CreateInstance-BXX4Xa4W.js
27.97
KB
-rw-r--r--
CreateInstanceFromImageBtn-BiE...
527
B
-rw-r--r--
CreateNetwork-BQw2A27w.js
2.88
KB
-rw-r--r--
CreateNetworkForward-BgZF8duA....
1.71
KB
-rw-r--r--
CreateProfile-CCJYKSCK.js
4.04
KB
-rw-r--r--
CreateProject-DTBqJzUb.js
2.83
KB
-rw-r--r--
CreateStoragePool-CuOutvs3.js
2.46
KB
-rw-r--r--
CreateStorageVolume-B0HvyGnH.j...
2.47
KB
-rw-r--r--
CustomIsoList-CQVv4whx.js
5.48
KB
-rw-r--r--
DeleteStoragePoolBtn-BeXLuEnA....
1.62
KB
-rw-r--r--
DeleteStorageVolumeBtn-DIIVYGa...
1.88
KB
-rw-r--r--
DiskSizeSelector-IT5APek6.js
1010
B
-rw-r--r--
EditClusterGroup-DiNIL0Lx.js
761
B
-rw-r--r--
EditNetworkForward-DtcWepYC.js
1.99
KB
-rw-r--r--
ExpandableList-EDeaeb6c.js
323
B
-rw-r--r--
FormEditButton-Cs2eW7Js.js
278
B
-rw-r--r--
FormFooterLayout-B3kcadYt.js
738
B
-rw-r--r--
FormLink-BaU-zsbe.js
879
B
-rw-r--r--
FormMenuItem-ChXfQsFA.js
2.23
MB
-rw-r--r--
FormMenuItem-DyX1CsEw.css
66.66
KB
-rw-r--r--
GroupOrIdentityChangesTable-DQ...
5.11
KB
-rw-r--r--
GroupSelectionActions-Dq47oQd-...
3.18
KB
-rw-r--r--
HelpLink-4LTOsqZO.js
294
B
-rw-r--r--
ImageList-yKBGTFZU.js
11.7
KB
-rw-r--r--
InstanceDetail-BV9hr65t.js
481.49
KB
-rw-r--r--
InstanceDetail-Beg8tuEN.css
3.88
KB
-rw-r--r--
InstanceLinkChip-DfVC8U01.js
4.24
KB
-rw-r--r--
InstanceList-CTEYE5e7.js
24.67
KB
-rw-r--r--
ItemName-DSOx0T0r.js
185
B
-rw-r--r--
Login-CsUYa7ns.js
1.41
KB
-rw-r--r--
Meter-BsdJ73XW.js
487
B
-rw-r--r--
NetworkDetail-RgSS_6Vw.js
12.8
KB
-rw-r--r--
NetworkForwardForm-C18aehvo.js
6.49
KB
-rw-r--r--
NetworkList-B4gWmGGm.js
6.32
KB
-rw-r--r--
NetworkListTable-Ba2LzF-J.js
3.31
KB
-rw-r--r--
NotificationRow-CotZPNAQ.js
157
B
-rw-r--r--
OperationList-D4--05cO.js
3.35
KB
-rw-r--r--
PageHeader-CExPjRLH.js
549
B
-rw-r--r--
PermissionGroups-CkGxgQmn.js
30.89
KB
-rw-r--r--
PermissionIdentities-DDmb7V-C....
12.93
KB
-rw-r--r--
PermissionIdpGroups-yggiVbcG.j...
13.38
KB
-rw-r--r--
ProfileDetail-CQHhNWwW.js
10.94
KB
-rw-r--r--
ProfileDetailsForm-C-rMcUGO.js
2.45
KB
-rw-r--r--
ProfileInstances-DeravO8Q.js
1.46
KB
-rw-r--r--
ProfileList-C7yC3g6E.js
7.11
KB
-rw-r--r--
ProgressBar-CQ2HKUqQ.js
170
B
-rw-r--r--
ProjectConfiguration-rKP8dZtz....
9.04
KB
-rw-r--r--
ProjectForm-GhClr0iv.js
15.12
KB
-rw-r--r--
ProtectedRoute-DYKGChU3.js
214
B
-rw-r--r--
ProxyDeviceForm-B5UDgi1V.js
38.9
KB
-rw-r--r--
RenameHeader-fmgiouA6.js
13.29
KB
-rw-r--r--
ResourceIcon-DZQOrBLA.js
532
B
-rw-r--r--
ResourceLabel-PzB_6v5p.js
317
B
-rw-r--r--
ResourceLink-CS7mH0C3.js
302
B
-rw-r--r--
ScrollableContainer-MJpEXCww.j...
646
B
-rw-r--r--
ScrollableTable-DWT33Lms.js
561
B
-rw-r--r--
SelectableMainTable-C8l8QdDe.j...
2.21
KB
-rw-r--r--
SelectedTableNotification-2DZb...
974
B
-rw-r--r--
Settings-BYi8qROs.js
9.75
KB
-rw-r--r--
SidePanel-DNeaRMst.js
2.84
KB
-rw-r--r--
SnapshotForm-DF9sGEzn.js
1.49
KB
-rw-r--r--
StoragePoolDetail-DT58PBIr.js
6.45
KB
-rw-r--r--
StoragePoolForm-Z62B6Fuh.js
17.07
KB
-rw-r--r--
StoragePoolSelectTable-CXuxJSN...
1.61
KB
-rw-r--r--
StoragePoolSelector-DEvMjaMu.j...
1.48
KB
-rw-r--r--
StoragePoolSize-DyBNKBKy.js
467
B
-rw-r--r--
StoragePools-DK0Gkjq9.js
3.99
KB
-rw-r--r--
StorageUsedBy-sdKGRlgM.js
2.12
KB
-rw-r--r--
StorageVolumeDetail-fQzbPWNW.j...
24.87
KB
-rw-r--r--
StorageVolumeForm-ZPfwK39D.js
8.42
KB
-rw-r--r--
StorageVolumes-DPotlIN6.js
7.26
KB
-rw-r--r--
StorageVolumesFilter-B7pR3OeF....
1.01
KB
-rw-r--r--
TabLinks-BIG_Rdvk.js
360
B
-rw-r--r--
UploadCustomIso-DG12FhN0.js
2.83
KB
-rw-r--r--
UsedByItem-VHA3kVFG.js
945
B
-rw-r--r--
VolumeAddSnapshotBtn-8Qz9xFE-....
4.87
KB
-rw-r--r--
WarningList-DZNTQSpg.js
1.99
KB
-rw-r--r--
YamlNotification-BnmI52ws.js
634
B
-rw-r--r--
YamlSwitch-BXLuxWUh.js
40.62
KB
-rw-r--r--
certificate-kcThcTS9.js
279.99
KB
-rw-r--r--
clusterGroups-BWQNdGSD.js
3.63
KB
-rw-r--r--
images-Du2fhDUO.js
1.22
KB
-rw-r--r--
index-BeIaaTgz.css
661.94
KB
-rw-r--r--
index-BkTFFYvy.js
690.52
KB
-rw-r--r--
index-DW_MHI2K.js
34.19
KB
-rw-r--r--
index.esm-auJ3G_FM.js
38.36
KB
-rw-r--r--
instanceDelete-Bn3xn_NE.js
12.2
KB
-rw-r--r--
instanceOptions-BuFjjn-P.js
1.19
KB
-rw-r--r--
network-forwards-B-h1Yzp9.js
856
B
-rw-r--r--
operations-DIvBacJG.js
757
B
-rw-r--r--
projects-CvA2zMPN.js
789
B
-rw-r--r--
scroll-DPmbgfny.js
26.97
KB
-rw-r--r--
searchAndFilter-DtC_P-vv.js
361
B
-rw-r--r--
snapshots-CEDJtMaf.js
670
B
-rw-r--r--
storage-volumes-tfXkh9eB.js
2.46
KB
-rw-r--r--
useGroups-CCX3qCzO.js
2.91
KB
-rw-r--r--
useImages-LgCYWVgs.js
1.64
KB
-rw-r--r--
useNetworks-D3nHf8AE.js
3.63
KB
-rw-r--r--
useSmallScreen-BvsjT919.js
169
B
-rw-r--r--
useSortTableData-BoXaK1oA.js
393
B
-rw-r--r--
useVolumes-BvpfNVaA.js
1.27
KB
-rw-r--r--
Delete
Unzip
Zip
${this.title}
Close
Code Editor : InstanceDetail-BV9hr65t.js
import{D as ir,j as p,L as tt,d as N,b as co,p as Mt,r as Z,B as Ne,a8 as At,H as _t,c as Ke,o as nt,a9 as sr,aa as It,v as Tt,ab as ho,ac as bs,ad as Cs,M as lo,x as Ee,k as Ie,l as Ue,ae as Oi,af as uo,ag as rr,q as de,a7 as Rt,e as Wi,s as $i,ah as kt,ai as nr,y as it,a5 as yt,a6 as _o,n as or,w as fo,u as po,aj as mo,g as qi,f as Bt,I as me,F as Es,E as ys,ak as ni,t as go,al as vo,am as So,an as bo,ao as ws,C as Co}from"./index-BkTFFYvy.js";import{i as Eo}from"./instanceOptions-BuFjjn-P.js";import{R as Fe}from"./ResourceLink-CS7mH0C3.js";import{u as yo,g as wo,I as xo,a as Ao,b as xs,c as Oe,d as ar,e as cr,C as Io,f as Po,h as Do,i as Lo}from"./instanceDelete-Bn3xn_NE.js";import{N as oi}from"./NotificationRow-CotZPNAQ.js";import{N as Mo,D as To}from"./NetworkListTable-Ba2LzF-J.js";import{R as ai}from"./ResourceLabel-PzB_6v5p.js";import{u as Ro,e as hr,c as lr}from"./useImages-LgCYWVgs.js";import{a as ko,I as ue,c as ur,b as Yt,d as Bo,f as Oo,e as No,g as dr,h as Uo,i as jo,m as Fo,j as Ho,r as Ko}from"./InstanceLinkChip-DfVC8U01.js";import{c as Je,e as As,d as Go,a as Qe,f as Yo}from"./index.esm-auJ3G_FM.js";import{I as Pt}from"./ItemName-DSOx0T0r.js";import{S as _r}from"./SnapshotForm-DF9sGEzn.js";import{t as zo,a as Wo,b as $o,g as fr,i as qo}from"./snapshots-CEDJtMaf.js";import{u as ze}from"./projects-CvA2zMPN.js";import{i as Vi,a as pr,t as mr,C as Vo,b as gr}from"./ClusterMemberSelector-B2lzDpCI.js";import{S as Xo}from"./SelectableMainTable-C8l8QdDe.js";import{B as Qo}from"./BulkDeleteButton-B-fvVwh0.js";import{S as Xi}from"./ScrollableTable-DWT33Lms.js";import{S as Zo}from"./SelectedTableNotification-2DZbBMZx.js";import{e as vr,g as ut,h as zt,I as Sr,r as Jo,E as ea,R as ta,S as ia,M as sa,B as ra,C as na,Y as oa,i as aa}from"./FormMenuItem-ChXfQsFA.js";import{a as ca,g as ha}from"./operations-DIvBacJG.js";import{u as la}from"./useSortTableData-BoXaK1oA.js";import{y as ua,Y as wt,I as da,M as Ai,D as _a,N as fa,G as pa,P as ma,O as ga,R as va,S as Sa,a as ba,b as Ca,B as Ea,C as ya,c as wa,d as xa}from"./YamlSwitch-BXLuxWUh.js";import{D as Aa,N as Ia,G as Pa,P as Da,O as La}from"./ProxyDeviceForm-B5UDgi1V.js";import{F as Ma}from"./FormFooterLayout-B3kcadYt.js";import{Y as Ta}from"./YamlNotification-BnmI52ws.js";import{F as Ra,R as ka}from"./RenameHeader-fmgiouA6.js";import{F as Ii,B as Ba}from"./FormLink-BaU-zsbe.js";import{S as Oa}from"./StoragePoolSelectTable-CXuxJSN9.js";import{S as Na}from"./StoragePoolSelector-DEvMjaMu.js";import{T as Ua}from"./TabLinks-BIG_Rdvk.js";import"./ResourceIcon-DZQOrBLA.js";import"./Meter-BsdJ73XW.js";import"./ExpandableList-EDeaeb6c.js";import"./useNetworks-D3nHf8AE.js";import"./index-DW_MHI2K.js";import"./UploadCustomIso-DG12FhN0.js";import"./ProgressBar-CQ2HKUqQ.js";import"./storage-volumes-tfXkh9eB.js";import"./useVolumes-BvpfNVaA.js";import"./images-Du2fhDUO.js";import"./ConfigFieldDescription-BnRkdboG.js";import"./AutoExpandingTextArea-BXFyAEiG.js";import"./DiskSizeSelector-IT5APek6.js";import"./StorageVolumeForm-ZPfwK39D.js";import"./ScrollableContainer-MJpEXCww.js";import"./StoragePoolSize-DyBNKBKy.js";const ja=({instance:t,onFailure:e})=>{const{data:i=[],error:a,isLoading:g}=ir(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"}],E=t.profiles.map(r=>{const o=i.find(_=>_.name===r),u=(o==null?void 0:o.description)??"";return{key:r,columns:[{content:p.jsx(Fe,{type:"profile",value:r,to:o?`/ui/project/${t.project}/profile/${r}`:""}),role:"rowheader","aria-label":"Name"},{content:u,role:"rowheader",title:`Description ${u}`,"aria-label":"Description"}],sortData:{name:r.toLowerCase(),description:u.toLowerCase()}}});return g?p.jsx(tt,{text:"Loading profiles..."}):p.jsx(N.MainTable,{headers:w,rows:E,sortable:!0})},Fa=({instance:t,onFailure:e})=>{const{isRestricted:i}=co(),{data:a=[],error:g,isLoading:w}=yo(t.location);g&&e("Loading metrics failed",g);const E=wo(a,t);return i?p.jsx("div",{className:"u-text--muted",children:"Details are not available for restricted users"}):p.jsx(p.Fragment,{children:w?p.jsx(tt,{text:"Loading metrics..."}):p.jsx("table",{children:p.jsxs("tbody",{children:[p.jsxs("tr",{className:"metric-row",children:[p.jsx("th",{className:"u-text--muted",children:"Memory"}),p.jsx("td",{children:E.memory?p.jsx(xo,{instance:t}):"-"})]}),p.jsxs("tr",{className:"metric-row",children:[p.jsx("th",{className:"u-text--muted",children:"Disk"}),p.jsx("td",{children:E.disk?p.jsx(Ao,{instance:t}):"-"})]})]})})})},Ha=({instance:t})=>{var o,u;const e=N.useNotify(),{data:i}=Mt(),{data:a=[]}=Ro(t.project),g=(_,l)=>{e.failure(_,l)},w=()=>{_t("instance-overview-tab")};Z.useEffect(w,[(o=e.notification)==null?void 0:o.message]),Ne("resize",w);const E=!t.state||t.state.pid===0?"-":t.state.pid,r=()=>{const _=t.config["image.description"],l=a==null?void 0:a.some(f=>{var C;return((C=f.properties)==null?void 0:C.description)===_});return _?l?p.jsx(Fe,{type:"image",value:_,to:`/ui/project/${t.project}/images`}):p.jsx(ai,{type:"image",value:_}):"-"};return p.jsxs("div",{className:"instance-overview-tab",children:[p.jsx(oi,{}),p.jsxs(N.Row,{className:"general",children:[p.jsx(N.Col,{size:3,children:p.jsx("h2",{className:"p-heading--5",children:"General"})}),p.jsx(N.Col,{size:7,children:p.jsx("table",{children:p.jsxs("tbody",{children:[p.jsxs("tr",{children:[p.jsx("th",{className:"u-text--muted",children:"Base image"}),p.jsx("td",{children:r()})]}),p.jsxs("tr",{children:[p.jsx("th",{className:"u-text--muted",children:"Description"}),p.jsx("td",{children:t.description?t.description:"-"})]}),p.jsxs("tr",{children:[p.jsx("th",{className:"u-text--muted",children:"Type"}),p.jsx("td",{children:Eo.filter(_=>_.value===t.type)[0].label})]}),p.jsxs("tr",{children:[p.jsx("th",{className:"u-text--muted",children:"IPv4"}),p.jsx("td",{children:p.jsx(xs,{instance:t,family:"inet"})})]}),p.jsxs("tr",{children:[p.jsx("th",{className:"u-text--muted",children:"IPv6"}),p.jsx("td",{children:p.jsx(xs,{instance:t,family:"inet6"})})]}),p.jsxs("tr",{children:[p.jsx("th",{className:"u-text--muted",children:"Architecture"}),p.jsx("td",{children:t.architecture})]}),p.jsxs("tr",{children:[p.jsx("th",{className:"u-text--muted",children:"Cluster member"}),p.jsx("td",{children:(u=i==null?void 0:i.environment)!=null&&u.server_clustered&&t.location?p.jsx(Fe,{type:"cluster-member",value:t.location,to:"/ui/cluster"}):"-"})]}),p.jsxs("tr",{children:[p.jsx("th",{className:"u-text--muted",children:"PID"}),p.jsx("td",{children:E})]}),p.jsxs("tr",{children:[p.jsx("th",{className:"u-text--muted",children:"Date created"}),p.jsx("td",{children:At(t.created_at)})]}),p.jsxs("tr",{children:[p.jsx("th",{className:"u-text--muted",children:"Last used"}),p.jsx("td",{children:At(t.last_used_at)})]})]})})})]}),p.jsxs(N.Row,{className:"usage",children:[p.jsx(N.Col,{size:3,children:p.jsx("h2",{className:"p-heading--5",children:"Usage"})}),p.jsx(N.Col,{size:7,children:p.jsx(Fa,{instance:t,onFailure:g})})]}),p.jsxs(N.Row,{className:"networks",children:[p.jsx(N.Col,{size:3,children:p.jsx("h2",{className:"p-heading--5",children:"Networks"})}),p.jsx(N.Col,{size:7,children:p.jsx(Mo,{devices:t.expanded_devices,onFailure:g})})]}),p.jsxs(N.Row,{className:"networks",children:[p.jsx(N.Col,{size:3,children:p.jsx("h2",{className:"p-heading--5",children:"Devices"})}),p.jsx(N.Col,{size:7,children:p.jsx(To,{configBaseURL:`/ui/project/${t.project}/instance/${t.name}/configuration`,devices:t.expanded_devices})})]}),p.jsxs(N.Row,{className:"profiles",children:[p.jsx(N.Col,{size:3,children:p.jsx("h2",{className:"p-heading--5",children:"Profiles"})}),p.jsx(N.Col,{size:7,children:p.jsx(ja,{instance:t,onFailure:g})})]})]})};var Pi={exports:{}},Is;function Ka(){return Is||(Is=1,function(t,e){(function(i,a){t.exports=a()})(self,()=>(()=>{var i={};return(()=>{var a=i;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 E=this._terminal.options.scrollback===0?0:g.viewport.scrollBarWidth,r=window.getComputedStyle(this._terminal.element.parentElement),o=parseInt(r.getPropertyValue("height")),u=Math.max(0,parseInt(r.getPropertyValue("width"))),_=window.getComputedStyle(this._terminal.element),l=o-(parseInt(_.getPropertyValue("padding-top"))+parseInt(_.getPropertyValue("padding-bottom"))),f=u-(parseInt(_.getPropertyValue("padding-right"))+parseInt(_.getPropertyValue("padding-left")))-E;return{cols:Math.max(2,Math.floor(f/w.css.cell.width)),rows:Math.max(1,Math.floor(l/w.css.cell.height))}}}})(),i})())}(Pi)),Pi.exports}var br=Ka();const Ga=({payload:t,close:e,reconnect:i})=>{const a=Z.useRef(null),g=Je().shape({command:Qe().required("This field is required"),environment:Go().of(Je().shape({key:Qe(),value:Qe()})),user:As(),group:As()}),w=Ke({initialValues:t,validationSchema:g,onSubmit:i}),E=()=>{const _=[...w.values.environment];_.push({key:"",value:""}),w.setFieldValue("environment",_)},r=_=>{const l=[...w.values.environment];l.splice(_,1),w.setFieldValue("environment",l)},o=_=>{_.key==="Escape"&&e()},u=()=>{_t("content-wrapper","p-modal__footer",64,"max-height")};return Ne("resize",u),Z.useEffect(u,[]),Z.useEffect(()=>{var _;(_=a.current)==null||_.scrollIntoView({behavior:"smooth",block:"end",inline:"start"}),window.dispatchEvent(new Event("resize"))},[w.values.environment]),p.jsx(N.Modal,{close:e,title:"Reconnect terminal",buttonRow:p.jsxs(p.Fragment,{children:[p.jsx(N.Button,{appearance:"base",className:"u-no-margin--bottom",type:"button","aria-label":"cancel reconnect",onClick:e,children:"Cancel"}),p.jsx(N.ActionButton,{className:"u-no-margin--bottom",appearance:"positive","aria-label":"submit reconnect",onClick:()=>void w.submitForm(),children:"Reconnect"})]}),onKeyDown:o,children:p.jsxs(N.Form,{onSubmit:w.handleSubmit,children:[p.jsx(N.Input,{type:"submit",hidden:!0,value:"Hidden input"}),p.jsxs("div",{className:"content-wrapper",children:[p.jsx(N.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}),p.jsx(N.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}),p.jsx(N.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}),p.jsx("p",{className:"u-no-margin--bottom p-form__label",children:"Environment variables"}),w.values.environment.map((_,l)=>p.jsxs("div",{className:"env-variables",children:[p.jsx(N.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}),p.jsx(N.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}),p.jsx(N.Button,{"aria-label":`remove variable ${l}`,onClick:()=>{r(l)},type:"button",hasIcon:!0,children:p.jsx(N.Icon,{name:"delete"})})]},l)),p.jsx("div",{ref:a,children:p.jsx(N.Button,{"aria-label":"add variable",onClick:E,type:"button",children:p.jsx("span",{children:"Add variable"})})})]})]})})},Ya=({payload:t,reconnect:e})=>{const[i,a]=Z.useState(!1),g=()=>{a(!1)},w=()=>{a(!0)},E=r=>{g(),e(r)};return p.jsxs(p.Fragment,{children:[i&&p.jsx(Ga,{close:g,reconnect:E,payload:t}),p.jsxs(N.Button,{className:"u-no-margin--bottom",hasIcon:!0,onClick:w,children:[p.jsx(N.Icon,{name:"connected"}),p.jsx("span",{children:"Reconnect"})]})]})};var Di={exports:{}},Ps;function za(){return Ps||(Ps=1,function(t,e){(function(i,a){t.exports=a()})(self,()=>(()=>{var i={4567:function(E,r,o){var u=this&&this.__decorate||function(h,d,b,y){var A,v=arguments.length,x=v<3?d:y===null?y=Object.getOwnPropertyDescriptor(d,b):y;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")x=Reflect.decorate(h,d,b,y);else for(var D=h.length-1;D>=0;D--)(A=h[D])&&(x=(v<3?A(x):v>3?A(d,b,x):A(d,b))||x);return v>3&&x&&Object.defineProperty(d,b,x),x},_=this&&this.__param||function(h,d){return function(b,y){d(b,y,h)}};Object.defineProperty(r,"__esModule",{value:!0}),r.AccessibilityManager=void 0;const l=o(9042),f=o(6114),C=o(9924),S=o(844),m=o(5596),s=o(4725),n=o(3656);let c=r.AccessibilityManager=class extends S.Disposable{constructor(h,d){super(),this._terminal=h,this._renderService=d,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 m.ScreenDprMonitor(window),this.register(this._screenDprMonitor),this._screenDprMonitor.setListener(()=>this._refreshRowsDimensions()),this.register((0,n.addDisposableDomListener)(window,"resize",()=>this._refreshRowsDimensions())),this._refreshRows(),this.register((0,S.toDisposable)(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(h){for(let d=0;d<h;d++)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)),f.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,f.isMac&&this._liveRegion.remove()}_handleKey(h){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(h)||this._charsToConsume.push(h)}_refreshRows(h,d){this._liveRegionDebouncer.refresh(h,d,this._terminal.rows)}_renderRows(h,d){const b=this._terminal.buffer,y=b.lines.length.toString();for(let A=h;A<=d;A++){const v=b.translateBufferLineToString(b.ydisp+A,!0),x=(b.ydisp+A+1).toString(),D=this._rowElements[A];D&&(v.length===0?D.innerText=" ":D.textContent=v,D.setAttribute("aria-posinset",x),D.setAttribute("aria-setsize",y))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(h,d){const b=h.target,y=this._rowElements[d===0?1:this._rowElements.length-2];if(b.getAttribute("aria-posinset")===(d===0?"1":`${this._terminal.buffer.lines.length}`)||h.relatedTarget!==y)return;let A,v;if(d===0?(A=b,v=this._rowElements.pop(),this._rowContainer.removeChild(v)):(A=this._rowElements.shift(),v=b,this._rowContainer.removeChild(A)),A.removeEventListener("focus",this._topBoundaryFocusListener),v.removeEventListener("focus",this._bottomBoundaryFocusListener),d===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(d===0?-1:1),this._rowElements[d===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 d=this._rowContainer.children.length;d<this._terminal.rows;d++)this._rowElements[d]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[d]);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([_(1,s.IRenderService)],c)},3614:(E,r)=>{function o(f){return f.replace(/\r?\n/g,"\r")}function u(f,C){return C?"\x1B[200~"+f+"\x1B[201~":f}function _(f,C,S,m){f=u(f=o(f),S.decPrivateModes.bracketedPasteMode&&m.rawOptions.ignoreBracketedPasteMode!==!0),S.triggerDataEvent(f,!0),C.value=""}function l(f,C,S){const m=S.getBoundingClientRect(),s=f.clientX-m.left-10,n=f.clientY-m.top-10;C.style.width="20px",C.style.height="20px",C.style.left=`${s}px`,C.style.top=`${n}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=o,r.bracketTextForPaste=u,r.copyHandler=function(f,C){f.clipboardData&&f.clipboardData.setData("text/plain",C.selectionText),f.preventDefault()},r.handlePasteEvent=function(f,C,S,m){f.stopPropagation(),f.clipboardData&&_(f.clipboardData.getData("text/plain"),C,S,m)},r.paste=_,r.moveTextAreaUnderMouseCursor=l,r.rightClickHandler=function(f,C,S,m,s){l(f,C,S),s&&m.rightClickSelect(f),C.value=m.selectionText,C.select()}},7239:(E,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.ColorContrastCache=void 0;const u=o(1505);r.ColorContrastCache=class{constructor(){this._color=new u.TwoKeyMap,this._css=new u.TwoKeyMap}setCss(_,l,f){this._css.set(_,l,f)}getCss(_,l){return this._css.get(_,l)}setColor(_,l,f){this._color.set(_,l,f)}getColor(_,l){return this._color.get(_,l)}clear(){this._color.clear(),this._css.clear()}}},3656:(E,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.addDisposableDomListener=void 0,r.addDisposableDomListener=function(o,u,_,l){o.addEventListener(u,_,l);let f=!1;return{dispose:()=>{f||(f=!0,o.removeEventListener(u,_,l))}}}},6465:function(E,r,o){var u=this&&this.__decorate||function(s,n,c,h){var d,b=arguments.length,y=b<3?n:h===null?h=Object.getOwnPropertyDescriptor(n,c):h;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")y=Reflect.decorate(s,n,c,h);else for(var A=s.length-1;A>=0;A--)(d=s[A])&&(y=(b<3?d(y):b>3?d(n,c,y):d(n,c))||y);return b>3&&y&&Object.defineProperty(n,c,y),y},_=this&&this.__param||function(s,n){return function(c,h){n(c,h,s)}};Object.defineProperty(r,"__esModule",{value:!0}),r.Linkifier2=void 0;const l=o(3656),f=o(8460),C=o(844),S=o(2585);let m=r.Linkifier2=class extends C.Disposable{get currentLink(){return this._currentLink}constructor(s){super(),this._bufferService=s,this._linkProviders=[],this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this.register(new f.EventEmitter),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this.register(new f.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(s){return this._linkProviders.push(s),{dispose:()=>{const n=this._linkProviders.indexOf(s);n!==-1&&this._linkProviders.splice(n,1)}}}attachToDom(s,n,c){this._element=s,this._mouseService=n,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(s){if(this._lastMouseEvent=s,!this._element||!this._mouseService)return;const n=this._positionFromMouseEvent(s,this._element,this._mouseService);if(!n)return;this._isMouseOut=!1;const c=s.composedPath();for(let h=0;h<c.length;h++){const d=c[h];if(d.classList.contains("xterm"))break;if(d.classList.contains("xterm-hover"))return}this._lastBufferCell&&n.x===this._lastBufferCell.x&&n.y===this._lastBufferCell.y||(this._handleHover(n),this._lastBufferCell=n)}_handleHover(s){if(this._activeLine!==s.y||this._wasResized)return this._clearCurrentLink(),this._askForLink(s,!1),void(this._wasResized=!1);this._currentLink&&this._linkAtPosition(this._currentLink.link,s)||(this._clearCurrentLink(),this._askForLink(s,!0))}_askForLink(s,n){var c,h;this._activeProviderReplies&&n||((c=this._activeProviderReplies)===null||c===void 0||c.forEach(b=>{b==null||b.forEach(y=>{y.link.dispose&&y.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=s.y);let d=!1;for(const[b,y]of this._linkProviders.entries())n?!((h=this._activeProviderReplies)===null||h===void 0)&&h.get(b)&&(d=this._checkLinkProviderResult(b,s,d)):y.provideLinks(s.y,A=>{var v,x;if(this._isMouseOut)return;const D=A==null?void 0:A.map(T=>({link:T}));(v=this._activeProviderReplies)===null||v===void 0||v.set(b,D),d=this._checkLinkProviderResult(b,s,d),((x=this._activeProviderReplies)===null||x===void 0?void 0:x.size)===this._linkProviders.length&&this._removeIntersectingLinks(s.y,this._activeProviderReplies)})}_removeIntersectingLinks(s,n){const c=new Set;for(let h=0;h<n.size;h++){const d=n.get(h);if(d)for(let b=0;b<d.length;b++){const y=d[b],A=y.link.range.start.y<s?0:y.link.range.start.x,v=y.link.range.end.y>s?this._bufferService.cols:y.link.range.end.x;for(let x=A;x<=v;x++){if(c.has(x)){d.splice(b--,1);break}c.add(x)}}}}_checkLinkProviderResult(s,n,c){var h;if(!this._activeProviderReplies)return c;const d=this._activeProviderReplies.get(s);let b=!1;for(let y=0;y<s;y++)this._activeProviderReplies.has(y)&&!this._activeProviderReplies.get(y)||(b=!0);if(!b&&d){const y=d.find(A=>this._linkAtPosition(A.link,n));y&&(c=!0,this._handleNewLink(y))}if(this._activeProviderReplies.size===this._linkProviders.length&&!c)for(let y=0;y<this._activeProviderReplies.size;y++){const A=(h=this._activeProviderReplies.get(y))===null||h===void 0?void 0:h.find(v=>this._linkAtPosition(v.link,n));if(A){c=!0,this._handleNewLink(A);break}}return c}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(s){if(!this._element||!this._mouseService||!this._currentLink)return;const n=this._positionFromMouseEvent(s,this._element,this._mouseService);n&&this._mouseDownLink===this._currentLink&&this._linkAtPosition(this._currentLink.link,n)&&this._currentLink.link.activate(s,this._currentLink.link.text)}_clearCurrentLink(s,n){this._element&&this._currentLink&&this._lastMouseEvent&&(!s||!n||this._currentLink.link.range.start.y>=s&&this._currentLink.link.range.end.y<=n)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,(0,C.disposeArray)(this._linkCacheDisposables))}_handleNewLink(s){if(!this._element||!this._lastMouseEvent||!this._mouseService)return;const n=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);n&&this._linkAtPosition(s.link,n)&&(this._currentLink=s,this._currentLink.state={decorations:{underline:s.link.decorations===void 0||s.link.decorations.underline,pointerCursor:s.link.decorations===void 0||s.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,s.link,this._lastMouseEvent),s.link.decorations={},Object.defineProperties(s.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,d;!((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&&((d=this._element)===null||d===void 0||d.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,d,b;!((h=this._currentLink)===null||h===void 0)&&h.state&&((b=(d=this._currentLink)===null||d===void 0?void 0:d.state)===null||b===void 0?void 0:b.decorations.underline)!==c&&(this._currentLink.state.decorations.underline=c,this._currentLink.state.isHovered&&this._fireUnderlineEvent(s.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,d=this._bufferService.buffer.ydisp+1+c.end;if(this._currentLink.link.range.start.y>=h&&this._currentLink.link.range.end.y<=d&&(this._clearCurrentLink(h,d),this._lastMouseEvent&&this._element)){const b=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);b&&this._askForLink(b,!1)}})))}_linkHover(s,n,c){var h;!((h=this._currentLink)===null||h===void 0)&&h.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(n,!0),this._currentLink.state.decorations.pointerCursor&&s.classList.add("xterm-cursor-pointer")),n.hover&&n.hover(c,n.text)}_fireUnderlineEvent(s,n){const c=s.range,h=this._bufferService.buffer.ydisp,d=this._createLinkUnderlineEvent(c.start.x-1,c.start.y-h-1,c.end.x,c.end.y-h-1,void 0);(n?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(d)}_linkLeave(s,n,c){var h;!((h=this._currentLink)===null||h===void 0)&&h.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(n,!1),this._currentLink.state.decorations.pointerCursor&&s.classList.remove("xterm-cursor-pointer")),n.leave&&n.leave(c,n.text)}_linkAtPosition(s,n){const c=s.range.start.y*this._bufferService.cols+s.range.start.x,h=s.range.end.y*this._bufferService.cols+s.range.end.x,d=n.y*this._bufferService.cols+n.x;return c<=d&&d<=h}_positionFromMouseEvent(s,n,c){const h=c.getCoords(s,n,this._bufferService.cols,this._bufferService.rows);if(h)return{x:h[0],y:h[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(s,n,c,h,d){return{x1:s,y1:n,x2:c,y2:h,cols:this._bufferService.cols,fg:d}}};r.Linkifier2=m=u([_(0,S.IBufferService)],m)},9042:(E,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(E,r,o){var u=this&&this.__decorate||function(m,s,n,c){var h,d=arguments.length,b=d<3?s:c===null?c=Object.getOwnPropertyDescriptor(s,n):c;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")b=Reflect.decorate(m,s,n,c);else for(var y=m.length-1;y>=0;y--)(h=m[y])&&(b=(d<3?h(b):d>3?h(s,n,b):h(s,n))||b);return d>3&&b&&Object.defineProperty(s,n,b),b},_=this&&this.__param||function(m,s){return function(n,c){s(n,c,m)}};Object.defineProperty(r,"__esModule",{value:!0}),r.OscLinkProvider=void 0;const l=o(511),f=o(2585);let C=r.OscLinkProvider=class{constructor(m,s,n){this._bufferService=m,this._optionsService=s,this._oscLinkService=n}provideLinks(m,s){var n;const c=this._bufferService.buffer.lines.get(m-1);if(!c)return void s(void 0);const h=[],d=this._optionsService.rawOptions.linkHandler,b=new l.CellData,y=c.getTrimmedLength();let A=-1,v=-1,x=!1;for(let D=0;D<y;D++)if(v!==-1||c.hasContent(D)){if(c.loadCell(D,b),b.hasExtendedAttrs()&&b.extended.urlId){if(v===-1){v=D,A=b.extended.urlId;continue}x=b.extended.urlId!==A}else v!==-1&&(x=!0);if(x||v!==-1&&D===y-1){const T=(n=this._oscLinkService.getLinkData(A))===null||n===void 0?void 0:n.uri;if(T){const L={start:{x:v+1,y:m},end:{x:D+(x||D!==y-1?0:1),y:m}};let B=!1;if(!(d!=null&&d.allowNonHttpProtocols))try{const F=new URL(T);["http:","https:"].includes(F.protocol)||(B=!0)}catch{B=!0}B||h.push({text:T,range:L,activate:(F,Y)=>d?d.activate(F,Y,L):S(0,Y),hover:(F,Y)=>{var $;return($=d==null?void 0:d.hover)===null||$===void 0?void 0:$.call(d,F,Y,L)},leave:(F,Y)=>{var $;return($=d==null?void 0:d.leave)===null||$===void 0?void 0:$.call(d,F,Y,L)}})}x=!1,b.hasExtendedAttrs()&&b.extended.urlId?(v=D,A=b.extended.urlId):(v=-1,A=-1)}}s(h)}};function S(m,s){if(confirm(`Do you want to navigate to ${s}? WARNING: This link could potentially be dangerous`)){const n=window.open();if(n){try{n.opener=null}catch{}n.location.href=s}else console.warn("Opening link blocked as opener could not be cleared")}}r.OscLinkProvider=C=u([_(0,f.IBufferService),_(1,f.IOptionsService),_(2,f.IOscLinkService)],C)},6193:(E,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.RenderDebouncer=void 0,r.RenderDebouncer=class{constructor(o,u){this._parentWindow=o,this._renderCallback=u,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._parentWindow.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(o){return this._refreshCallbacks.push(o),this._animationFrame||(this._animationFrame=this._parentWindow.requestAnimationFrame(()=>this._innerRefresh())),this._animationFrame}refresh(o,u,_){this._rowCount=_,o=o!==void 0?o:0,u=u!==void 0?u:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,o):o,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 o=Math.max(this._rowStart,0),u=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(o,u),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(const o of this._refreshCallbacks)o(0);this._refreshCallbacks=[]}}},5596:(E,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.ScreenDprMonitor=void 0;const u=o(844);class _ extends u.Disposable{constructor(f){super(),this._parentWindow=f,this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this.register((0,u.toDisposable)(()=>{this.clearListener()}))}setListener(f){this._listener&&this.clearListener(),this._listener=f,this._outerListener=()=>{this._listener&&(this._listener(this._parentWindow.devicePixelRatio,this._currentDevicePixelRatio),this._updateDpr())},this._updateDpr()}_updateDpr(){var f;this._outerListener&&((f=this._resolutionMediaMatchList)===null||f===void 0||f.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=_},3236:(E,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.Terminal=void 0;const u=o(3614),_=o(3656),l=o(6465),f=o(9042),C=o(3730),S=o(1680),m=o(3107),s=o(5744),n=o(2950),c=o(1296),h=o(428),d=o(4269),b=o(5114),y=o(8934),A=o(3230),v=o(9312),x=o(4725),D=o(6731),T=o(8055),L=o(8969),B=o(8460),F=o(844),Y=o(6114),$=o(8437),z=o(2584),I=o(7399),M=o(5941),R=o(9074),O=o(2585),q=o(5435),V=o(4567),J=typeof window<"u"?window.document:null;class X extends L.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(R.DecorationService),this._instantiationService.setService(O.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 ie=T.color.toColorRGB(G==="ansi"?this._themeService.colors.ansi[U.index]:this._themeService.colors[G]);this.coreService.triggerDataEvent(`${z.C0.ESC}]${K};${(0,M.toRgbString)(ie)}${z.C1_ESCAPED.ST}`);break;case 1:if(G==="ansi")this._themeService.modifyColors(Q=>Q.ansi[U.index]=T.rgba.toColor(...U.color));else{const Q=G;this._themeService.modifyColors(oe=>oe[Q]=T.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(V.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,ie=U.getWidth(G),Q=this._renderService.dimensions.css.cell.width*ie,oe=this.buffer.y*this._renderService.dimensions.css.cell.height,ve=G*this._renderService.dimensions.css.cell.width;this.textarea.style.left=ve+"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,_.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,_.addDisposableDomListener)(this.textarea,"paste",P)),this.register((0,_.addDisposableDomListener)(this.element,"paste",P)),Y.isFirefox?this.register((0,_.addDisposableDomListener)(this.element,"mousedown",U=>{U.button===2&&(0,u.rightClickHandler)(U,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this.register((0,_.addDisposableDomListener)(this.element,"contextmenu",U=>{(0,u.rightClickHandler)(U,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),Y.isLinux&&this.register((0,_.addDisposableDomListener)(this.element,"auxclick",U=>{U.button===1&&(0,u.moveTextAreaUnderMouseCursor)(U,this.textarea,this.screenElement)}))}_bindKeys(){this.register((0,_.addDisposableDomListener)(this.textarea,"keyup",P=>this._keyUp(P),!0)),this.register((0,_.addDisposableDomListener)(this.textarea,"keydown",P=>this._keyDown(P),!0)),this.register((0,_.addDisposableDomListener)(this.textarea,"keypress",P=>this._keyPress(P),!0)),this.register((0,_.addDisposableDomListener)(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this.register((0,_.addDisposableDomListener)(this.textarea,"compositionupdate",P=>this._compositionHelper.compositionupdate(P))),this.register((0,_.addDisposableDomListener)(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this.register((0,_.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",f.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,_.addDisposableDomListener)(this.textarea,"focus",K=>this._handleTextAreaFocus(K))),this.register((0,_.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(D.ThemeService),this._instantiationService.setService(x.IThemeService,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(d.CharacterJoinerService),this._instantiationService.setService(x.ICharacterJoinerService,this._characterJoinerService),this._renderService=this.register(this._instantiationService.createInstance(A.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(n.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(y.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,_.addDisposableDomListener)(this._viewportElement,"scroll",()=>this._selectionService.refresh())),this.linkifier2.attachToDom(this.screenElement,this._mouseService,this._renderService),this.register(this._instantiationService.createInstance(m.BufferDecorationRenderer,this.screenElement)),this.register((0,_.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(V.AccessibilityManager,this)),this.register(this.optionsService.onSpecificOptionChange("screenReaderMode",K=>this._handleScreenReaderModeOptionChange(K))),this.options.overviewRulerWidth&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(s.OverviewRulerRenderer,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRulerWidth",K=>{!this._overviewRulerRenderer&&K&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(s.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 ve,xe;switch(Q.overrideType||Q.type){case"mousemove":xe=32,Q.buttons===void 0?(ve=3,Q.button!==void 0&&(ve=Q.button<3?Q.button:3)):ve=1&Q.buttons?0:4&Q.buttons?1:2&Q.buttons?2:3;break;case"mouseup":xe=0,ve=Q.button<3?Q.button:3;break;case"mousedown":xe=1,ve=Q.button<3?Q.button:3;break;case"wheel":if(P.viewport.getLinesScrolled(Q)===0)return!1;xe=Q.deltaY<0?0:1,ve=4;break;default:return!1}return!(xe===void 0||ve===void 0||ve>4)&&P.coreMouseService.triggerMouseEvent({col:oe.col,row:oe.row,x:oe.x,y:oe.y,button:ve,action:xe,ctrl:Q.ctrlKey,alt:Q.altKey,shift:Q.shiftKey})}const K={mouseup:null,wheel:null,mousedrag:null,mousemove:null},ie={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",ie.mousemove),K.mousemove=ie.mousemove):(U.removeEventListener("mousemove",K.mousemove),K.mousemove=null),16&Q?K.wheel||(U.addEventListener("wheel",ie.wheel,{passive:!1}),K.wheel=ie.wheel):(U.removeEventListener("wheel",K.wheel),K.wheel=null),2&Q?K.mouseup||(U.addEventListener("mouseup",ie.mouseup),K.mouseup=ie.mouseup):(this._document.removeEventListener("mouseup",K.mouseup),U.removeEventListener("mouseup",K.mouseup),K.mouseup=null),4&Q?K.mousedrag||(K.mousedrag=ie.mousedrag):(this._document.removeEventListener("mousemove",K.mousedrag),K.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this.register((0,_.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,_.addDisposableDomListener)(U,"wheel",Q=>{if(!K.wheel){if(!this.buffer.hasScrollback){const oe=this.viewport.getLinesScrolled(Q);if(oe===0)return;const ve=z.C0.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(Q.deltaY<0?"A":"B");let xe="";for(let ct=0;ct<Math.abs(oe);ct++)xe+=ve;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,_.addDisposableDomListener)(U,"touchstart",Q=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchStart(Q),this.cancel(Q)},{passive:!0})),this.register((0,_.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,I.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 q.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 q.WindowsOptionsReportType.GET_CELL_SIZE_PIXELS:const K=this._renderService.dimensions.css.cell.width.toFixed(0),ie=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${z.C0.ESC}[6;${ie};${K}t`)}}cancel(P,U){if(this.options.cancelEvents||U)return P.preventDefault(),P.stopPropagation(),!1}}r.Terminal=X},9924:(E,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.TimeBasedDebouncer=void 0,r.TimeBasedDebouncer=class{constructor(o,u=1e3){this._renderCallback=o,this._debounceThresholdMS=u,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(o,u,_){this._rowCount=_,o=o!==void 0?o:0,u=u!==void 0?u:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,o):o,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 f=l-this._lastRefreshMs,C=this._debounceThresholdMS-f;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 o=Math.max(this._rowStart,0),u=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(o,u)}}},1680:function(E,r,o){var u=this&&this.__decorate||function(n,c,h,d){var b,y=arguments.length,A=y<3?c:d===null?d=Object.getOwnPropertyDescriptor(c,h):d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")A=Reflect.decorate(n,c,h,d);else for(var v=n.length-1;v>=0;v--)(b=n[v])&&(A=(y<3?b(A):y>3?b(c,h,A):b(c,h))||A);return y>3&&A&&Object.defineProperty(c,h,A),A},_=this&&this.__param||function(n,c){return function(h,d){c(h,d,n)}};Object.defineProperty(r,"__esModule",{value:!0}),r.Viewport=void 0;const l=o(3656),f=o(4725),C=o(8460),S=o(844),m=o(2585);let s=r.Viewport=class extends S.Disposable{constructor(n,c,h,d,b,y,A,v){super(),this._viewportElement=n,this._scrollArea=c,this._bufferService=h,this._optionsService=d,this._charSizeService=b,this._renderService=y,this._coreBrowserService=A,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(n){this._viewportElement.style.backgroundColor=n.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(n){if(n)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 n=this._bufferService.buffer.ydisp*this._currentRowHeight;this._viewportElement.scrollTop!==n&&(this._ignoreNextScrollEvent=!0,this._viewportElement.scrollTop=n),this._refreshAnimationFrame=null}syncScrollArea(n=!1){if(this._lastRecordedBufferLength!==this._bufferService.buffer.lines.length)return this._lastRecordedBufferLength=this._bufferService.buffer.lines.length,void this._refresh(n);this._lastRecordedViewportHeight===this._renderService.dimensions.css.canvas.height&&this._lastScrollTop===this._activeBuffer.ydisp*this._currentRowHeight&&this._renderDimensions.device.cell.height===this._currentDeviceCellHeight||this._refresh(n)}_handleScroll(n){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 n=this._smoothScrollPercent();this._viewportElement.scrollTop=this._smoothScrollState.origin+Math.round(n*(this._smoothScrollState.target-this._smoothScrollState.origin)),n<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(n,c){const h=this._viewportElement.scrollTop+this._lastRecordedViewportHeight;return!(c<0&&this._viewportElement.scrollTop!==0||c>0&&h<this._lastRecordedBufferHeight)||(n.cancelable&&n.preventDefault(),!1)}handleWheel(n){const c=this._getPixelsScrolled(n);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(n,c))}scrollLines(n){if(n!==0)if(this._optionsService.rawOptions.smoothScrollDuration){const c=n*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:n,suppressScrollEvent:!1})}_getPixelsScrolled(n){if(n.deltaY===0||n.shiftKey)return 0;let c=this._applyScrollModifier(n.deltaY,n);return n.deltaMode===WheelEvent.DOM_DELTA_LINE?c*=this._currentRowHeight:n.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(c*=this._currentRowHeight*this._bufferService.rows),c}getBufferElements(n,c){var h;let d,b="";const y=[],A=c??this._bufferService.buffer.lines.length,v=this._bufferService.buffer.lines;for(let x=n;x<A;x++){const D=v.get(x);if(!D)continue;const T=(h=v.get(x+1))===null||h===void 0?void 0:h.isWrapped;if(b+=D.translateToString(!T),!T||x===v.length-1){const L=document.createElement("div");L.textContent=b,y.push(L),b.length>0&&(d=L),b=""}}return{bufferElements:y,cursorElement:d}}getLinesScrolled(n){if(n.deltaY===0||n.shiftKey)return 0;let c=this._applyScrollModifier(n.deltaY,n);return n.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):n.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(c*=this._bufferService.rows),c}_applyScrollModifier(n,c){const h=this._optionsService.rawOptions.fastScrollModifier;return h==="alt"&&c.altKey||h==="ctrl"&&c.ctrlKey||h==="shift"&&c.shiftKey?n*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:n*this._optionsService.rawOptions.scrollSensitivity}handleTouchStart(n){this._lastTouchY=n.touches[0].pageY}handleTouchMove(n){const c=this._lastTouchY-n.touches[0].pageY;return this._lastTouchY=n.touches[0].pageY,c!==0&&(this._viewportElement.scrollTop+=c,this._bubbleScroll(n,c))}};r.Viewport=s=u([_(2,m.IBufferService),_(3,m.IOptionsService),_(4,f.ICharSizeService),_(5,f.IRenderService),_(6,f.ICoreBrowserService),_(7,f.IThemeService)],s)},3107:function(E,r,o){var u=this&&this.__decorate||function(s,n,c,h){var d,b=arguments.length,y=b<3?n:h===null?h=Object.getOwnPropertyDescriptor(n,c):h;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")y=Reflect.decorate(s,n,c,h);else for(var A=s.length-1;A>=0;A--)(d=s[A])&&(y=(b<3?d(y):b>3?d(n,c,y):d(n,c))||y);return b>3&&y&&Object.defineProperty(n,c,y),y},_=this&&this.__param||function(s,n){return function(c,h){n(c,h,s)}};Object.defineProperty(r,"__esModule",{value:!0}),r.BufferDecorationRenderer=void 0;const l=o(3656),f=o(4725),C=o(844),S=o(2585);let m=r.BufferDecorationRenderer=class extends C.Disposable{constructor(s,n,c,h){super(),this._screenElement=s,this._bufferService=n,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(d=>this._removeDecoration(d))),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 s of this._decorationService.decorations)this._renderDecoration(s);this._dimensionsChanged=!1}_renderDecoration(s){this._refreshStyle(s),this._dimensionsChanged&&this._refreshXPosition(s)}_createElement(s){var n,c;const h=document.createElement("div");h.classList.add("xterm-decoration"),h.classList.toggle("xterm-decoration-top-layer",((n=s==null?void 0:s.options)===null||n===void 0?void 0:n.layer)==="top"),h.style.width=`${Math.round((s.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,h.style.height=(s.options.height||1)*this._renderService.dimensions.css.cell.height+"px",h.style.top=(s.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 d=(c=s.options.x)!==null&&c!==void 0?c:0;return d&&d>this._bufferService.cols&&(h.style.display="none"),this._refreshXPosition(s,h),h}_refreshStyle(s){const n=s.marker.line-this._bufferService.buffers.active.ydisp;if(n<0||n>=this._bufferService.rows)s.element&&(s.element.style.display="none",s.onRenderEmitter.fire(s.element));else{let c=this._decorationElements.get(s);c||(c=this._createElement(s),s.element=c,this._decorationElements.set(s,c),this._container.appendChild(c),s.onDispose(()=>{this._decorationElements.delete(s),c.remove()})),c.style.top=n*this._renderService.dimensions.css.cell.height+"px",c.style.display=this._altBufferIsActive?"none":"block",s.onRenderEmitter.fire(c)}}_refreshXPosition(s,n=s.element){var c;if(!n)return;const h=(c=s.options.x)!==null&&c!==void 0?c:0;(s.options.anchor||"left")==="right"?n.style.right=h?h*this._renderService.dimensions.css.cell.width+"px":"":n.style.left=h?h*this._renderService.dimensions.css.cell.width+"px":""}_removeDecoration(s){var n;(n=this._decorationElements.get(s))===null||n===void 0||n.remove(),this._decorationElements.delete(s),s.dispose()}};r.BufferDecorationRenderer=m=u([_(1,S.IBufferService),_(2,S.IDecorationService),_(3,f.IRenderService)],m)},5871:(E,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(o){if(o.options.overviewRulerOptions){for(const u of this._zones)if(u.color===o.options.overviewRulerOptions.color&&u.position===o.options.overviewRulerOptions.position){if(this._lineIntersectsZone(u,o.marker.line))return;if(this._lineAdjacentToZone(u,o.marker.line,o.options.overviewRulerOptions.position))return void this._addLineToZone(u,o.marker.line)}if(this._zonePoolIndex<this._zonePool.length)return this._zonePool[this._zonePoolIndex].color=o.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=o.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=o.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=o.marker.line,void this._zones.push(this._zonePool[this._zonePoolIndex++]);this._zones.push({color:o.options.overviewRulerOptions.color,position:o.options.overviewRulerOptions.position,startBufferLine:o.marker.line,endBufferLine:o.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(o){this._linePadding=o}_lineIntersectsZone(o,u){return u>=o.startBufferLine&&u<=o.endBufferLine}_lineAdjacentToZone(o,u,_){return u>=o.startBufferLine-this._linePadding[_||"full"]&&u<=o.endBufferLine+this._linePadding[_||"full"]}_addLineToZone(o,u){o.startBufferLine=Math.min(o.startBufferLine,u),o.endBufferLine=Math.max(o.endBufferLine,u)}}},5744:function(E,r,o){var u=this&&this.__decorate||function(d,b,y,A){var v,x=arguments.length,D=x<3?b:A===null?A=Object.getOwnPropertyDescriptor(b,y):A;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")D=Reflect.decorate(d,b,y,A);else for(var T=d.length-1;T>=0;T--)(v=d[T])&&(D=(x<3?v(D):x>3?v(b,y,D):v(b,y))||D);return x>3&&D&&Object.defineProperty(b,y,D),D},_=this&&this.__param||function(d,b){return function(y,A){b(y,A,d)}};Object.defineProperty(r,"__esModule",{value:!0}),r.OverviewRulerRenderer=void 0;const l=o(5871),f=o(3656),C=o(4725),S=o(844),m=o(2585),s={full:0,left:0,center:0,right:0},n={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(d,b,y,A,v,x,D){var T;super(),this._viewportElement=d,this._screenElement=b,this._bufferService=y,this._decorationService=A,this._renderService=v,this._optionsService=x,this._coreBrowseService=D,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(),(T=this._viewportElement.parentElement)===null||T===void 0||T.insertBefore(this._canvas,this._viewportElement);const L=this._canvas.getContext("2d");if(!L)throw new Error("Ctx cannot be null");this._ctx=L,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,f.addDisposableDomListener)(this._coreBrowseService.window,"resize",()=>this._queueRefresh(!0))),this._queueRefresh(!0)}_refreshDrawConstants(){const d=Math.floor(this._canvas.width/3),b=Math.ceil(this._canvas.width/3);n.full=this._canvas.width,n.left=d,n.center=b,n.right=d,this._refreshDrawHeightConstants(),c.full=0,c.left=0,c.center=n.left,c.right=n.left+n.center}_refreshDrawHeightConstants(){s.full=Math.round(2*this._coreBrowseService.dpr);const d=this._canvas.height/this._bufferService.buffer.lines.length,b=Math.round(Math.max(Math.min(d,12),6)*this._coreBrowseService.dpr);s.left=b,s.center=b,s.right=b}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*s.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*s.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*s.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*s.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 d=this._colorZoneStore.zones;for(const b of d)b.position!=="full"&&this._renderColorZone(b);for(const b of d)b.position==="full"&&this._renderColorZone(b);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderColorZone(d){this._ctx.fillStyle=d.color,this._ctx.fillRect(c[d.position||"full"],Math.round((this._canvas.height-1)*(d.startBufferLine/this._bufferService.buffers.active.lines.length)-s[d.position||"full"]/2),n[d.position||"full"],Math.round((this._canvas.height-1)*((d.endBufferLine-d.startBufferLine)/this._bufferService.buffers.active.lines.length)+s[d.position||"full"]))}_queueRefresh(d,b){this._shouldUpdateDimensions=d||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([_(2,m.IBufferService),_(3,m.IDecorationService),_(4,C.IRenderService),_(5,m.IOptionsService),_(6,C.ICoreBrowserService)],h)},2950:function(E,r,o){var u=this&&this.__decorate||function(m,s,n,c){var h,d=arguments.length,b=d<3?s:c===null?c=Object.getOwnPropertyDescriptor(s,n):c;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")b=Reflect.decorate(m,s,n,c);else for(var y=m.length-1;y>=0;y--)(h=m[y])&&(b=(d<3?h(b):d>3?h(s,n,b):h(s,n))||b);return d>3&&b&&Object.defineProperty(s,n,b),b},_=this&&this.__param||function(m,s){return function(n,c){s(n,c,m)}};Object.defineProperty(r,"__esModule",{value:!0}),r.CompositionHelper=void 0;const l=o(4725),f=o(2585),C=o(2584);let S=r.CompositionHelper=class{get isComposing(){return this._isComposing}constructor(m,s,n,c,h,d){this._textarea=m,this._compositionView=s,this._bufferService=n,this._optionsService=c,this._coreService=h,this._renderService=d,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(m){this._compositionView.textContent=m.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(m){if(this._isComposing||this._isSendingComposition){if(m.keyCode===229||m.keyCode===16||m.keyCode===17||m.keyCode===18)return!1;this._finalizeComposition(!1)}return m.keyCode!==229||(this._handleAnyTextareaChanges(),!1)}_finalizeComposition(m){if(this._compositionView.classList.remove("active"),this._isComposing=!1,m){const s={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){let n;this._isSendingComposition=!1,s.start+=this._dataAlreadySent.length,n=this._isComposing?this._textarea.value.substring(s.start,s.end):this._textarea.value.substring(s.start),n.length>0&&this._coreService.triggerDataEvent(n,!0)}},0)}else{this._isSendingComposition=!1;const s=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(s,!0)}}_handleAnyTextareaChanges(){const m=this._textarea.value;setTimeout(()=>{if(!this._isComposing){const s=this._textarea.value,n=s.replace(m,"");this._dataAlreadySent=n,s.length>m.length?this._coreService.triggerDataEvent(n,!0):s.length<m.length?this._coreService.triggerDataEvent(`${C.C0.DEL}`,!0):s.length===m.length&&s!==m&&this._coreService.triggerDataEvent(s,!0)}},0)}updateCompositionElements(m){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){const s=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),n=this._renderService.dimensions.css.cell.height,c=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,h=s*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=h+"px",this._compositionView.style.top=c+"px",this._compositionView.style.height=n+"px",this._compositionView.style.lineHeight=n+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";const d=this._compositionView.getBoundingClientRect();this._textarea.style.left=h+"px",this._textarea.style.top=c+"px",this._textarea.style.width=Math.max(d.width,1)+"px",this._textarea.style.height=Math.max(d.height,1)+"px",this._textarea.style.lineHeight=d.height+"px"}m||setTimeout(()=>this.updateCompositionElements(!0),0)}}};r.CompositionHelper=S=u([_(2,f.IBufferService),_(3,f.IOptionsService),_(4,f.ICoreService),_(5,l.IRenderService)],S)},9806:(E,r)=>{function o(u,_,l){const f=l.getBoundingClientRect(),C=u.getComputedStyle(l),S=parseInt(C.getPropertyValue("padding-left")),m=parseInt(C.getPropertyValue("padding-top"));return[_.clientX-f.left-S,_.clientY-f.top-m]}Object.defineProperty(r,"__esModule",{value:!0}),r.getCoords=r.getCoordsRelativeToElement=void 0,r.getCoordsRelativeToElement=o,r.getCoords=function(u,_,l,f,C,S,m,s,n){if(!S)return;const c=o(u,_,l);return c?(c[0]=Math.ceil((c[0]+(n?m/2:0))/m),c[1]=Math.ceil(c[1]/s),c[0]=Math.min(Math.max(c[0],1),f+(n?1:0)),c[1]=Math.min(Math.max(c[1],1),C),c):void 0}},9504:(E,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.moveToCellSequence=void 0;const u=o(2584);function _(s,n,c,h){const d=s-l(s,c),b=n-l(n,c),y=Math.abs(d-b)-function(A,v,x){let D=0;const T=A-l(A,x),L=v-l(v,x);for(let B=0;B<Math.abs(T-L);B++){const F=f(A,v)==="A"?-1:1,Y=x.buffer.lines.get(T+F*B);Y!=null&&Y.isWrapped&&D++}return D}(s,n,c);return m(y,S(f(s,n),h))}function l(s,n){let c=0,h=n.buffer.lines.get(s),d=h==null?void 0:h.isWrapped;for(;d&&s>=0&&s<n.rows;)c++,h=n.buffer.lines.get(--s),d=h==null?void 0:h.isWrapped;return c}function f(s,n){return s>n?"A":"B"}function C(s,n,c,h,d,b){let y=s,A=n,v="";for(;y!==c||A!==h;)y+=d?1:-1,d&&y>b.cols-1?(v+=b.buffer.translateBufferLineToString(A,!1,s,y),y=0,s=0,A++):!d&&y<0&&(v+=b.buffer.translateBufferLineToString(A,!1,0,s+1),y=b.cols-1,s=y,A--);return v+b.buffer.translateBufferLineToString(A,!1,s,y)}function S(s,n){const c=n?"O":"[";return u.C0.ESC+c+s}function m(s,n){s=Math.floor(s);let c="";for(let h=0;h<s;h++)c+=n;return c}r.moveToCellSequence=function(s,n,c,h){const d=c.buffer.x,b=c.buffer.y;if(!c.buffer.hasScrollback)return function(v,x,D,T,L,B){return _(x,T,L,B).length===0?"":m(C(v,x,v,x-l(x,L),!1,L).length,S("D",B))}(d,b,0,n,c,h)+_(b,n,c,h)+function(v,x,D,T,L,B){let F;F=_(x,T,L,B).length>0?T-l(T,L):x;const Y=T,$=function(z,I,M,R,O,q){let V;return V=_(M,R,O,q).length>0?R-l(R,O):I,z<M&&V<=R||z>=M&&V<R?"C":"D"}(v,x,D,T,L,B);return m(C(v,F,D,Y,$==="C",L).length,S($,B))}(d,b,s,n,c,h);let y;if(b===n)return y=d>s?"D":"C",m(Math.abs(d-s),S(y,h));y=b>n?"D":"C";const A=Math.abs(b-n);return m(function(v,x){return x.cols-v}(b>n?s:d,c)+(A-1)*c.cols+1+((b>n?d:s)-1),S(y,h))}},1296:function(E,r,o){var u=this&&this.__decorate||function(L,B,F,Y){var $,z=arguments.length,I=z<3?B:Y===null?Y=Object.getOwnPropertyDescriptor(B,F):Y;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")I=Reflect.decorate(L,B,F,Y);else for(var M=L.length-1;M>=0;M--)($=L[M])&&(I=(z<3?$(I):z>3?$(B,F,I):$(B,F))||I);return z>3&&I&&Object.defineProperty(B,F,I),I},_=this&&this.__param||function(L,B){return function(F,Y){B(F,Y,L)}};Object.defineProperty(r,"__esModule",{value:!0}),r.DomRenderer=void 0;const l=o(3787),f=o(2550),C=o(2223),S=o(6171),m=o(4725),s=o(8055),n=o(8460),c=o(844),h=o(2585),d="xterm-dom-renderer-owner-",b="xterm-rows",y="xterm-fg-",A="xterm-bg-",v="xterm-focus",x="xterm-selection";let D=1,T=r.DomRenderer=class extends c.Disposable{constructor(L,B,F,Y,$,z,I,M,R,O){super(),this._element=L,this._screenElement=B,this._viewportElement=F,this._linkifier2=Y,this._charSizeService=z,this._optionsService=I,this._bufferService=M,this._coreBrowserService=R,this._themeService=O,this._terminalClass=D++,this._rowElements=[],this.onRequestRedraw=this.register(new n.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(q=>this._injectCss(q))),this._injectCss(this._themeService.colors),this._rowFactory=$.createInstance(l.DomRendererRowFactory,document),this._element.classList.add(d+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this.register(this._linkifier2.onShowLinkUnderline(q=>this._handleLinkHover(q))),this.register(this._linkifier2.onHideLinkUnderline(q=>this._handleLinkLeave(q))),this.register((0,c.toDisposable)(()=>{this._element.classList.remove(d+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new f.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 L=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*L,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*L),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/L),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/L),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(L){this._themeStyleElement||(this._themeStyleElement=document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let B=`${this._terminalSelector} .${b} { color: ${L.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: ${s.color.multiplyOpacity(L.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: ${L.cursor.css}; color: ${L.cursorAccent.css}; } 50% { background-color: inherit; color: ${L.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: ${L.cursor.css}; color: ${L.cursorAccent.css};}${this._terminalSelector} .${b} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${L.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${b} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${L.cursor.css} inset;}${this._terminalSelector} .${b} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${L.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: ${L.selectionBackgroundOpaque.css};}${this._terminalSelector} .${x} div { position: absolute; background-color: ${L.selectionInactiveBackgroundOpaque.css};}`;for(const[F,Y]of L.ansi.entries())B+=`${this._terminalSelector} .${y}${F} { color: ${Y.css}; }${this._terminalSelector} .${y}${F}.xterm-dim { color: ${s.color.multiplyOpacity(Y,.5).css}; }${this._terminalSelector} .${A}${F} { background-color: ${Y.css}; }`;B+=`${this._terminalSelector} .${y}${C.INVERTED_DEFAULT_COLOR} { color: ${s.color.opaque(L.background).css}; }${this._terminalSelector} .${y}${C.INVERTED_DEFAULT_COLOR}.xterm-dim { color: ${s.color.multiplyOpacity(s.color.opaque(L.background),.5).css}; }${this._terminalSelector} .${A}${C.INVERTED_DEFAULT_COLOR} { background-color: ${L.foreground.css}; }`,this._themeStyleElement.textContent=B}_setDefaultSpacing(){const L=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${L}px`,this._rowFactory.defaultSpacing=L}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(L,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(L,B){this._refreshRowElements(L,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(L,B,F){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(L,B,F),this.renderRows(0,this._bufferService.rows-1),!L||!B)return;const Y=L[1]-this._bufferService.buffer.ydisp,$=B[1]-this._bufferService.buffer.ydisp,z=Math.max(Y,0),I=Math.min($,this._bufferService.rows-1);if(z>=this._bufferService.rows||I<0)return;const M=document.createDocumentFragment();if(F){const R=L[0]>B[0];M.appendChild(this._createSelectionElement(z,R?B[0]:L[0],R?L[0]:B[0],I-z+1))}else{const R=Y===z?L[0]:0,O=z===$?B[0]:this._bufferService.cols;M.appendChild(this._createSelectionElement(z,R,O));const q=I-z-1;if(M.appendChild(this._createSelectionElement(z+1,0,this._bufferService.cols,q)),z!==I){const V=$===I?B[0]:this._bufferService.cols;M.appendChild(this._createSelectionElement(I,0,V))}}this._selectionContainer.appendChild(M)}_createSelectionElement(L,B,F,Y=1){const $=document.createElement("div");return $.style.height=Y*this.dimensions.css.cell.height+"px",$.style.top=L*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 L of this._rowElements)L.replaceChildren()}renderRows(L,B){const F=this._bufferService.buffer,Y=F.ybase+F.y,$=Math.min(F.x,this._bufferService.cols-1),z=this._optionsService.rawOptions.cursorBlink,I=this._optionsService.rawOptions.cursorStyle,M=this._optionsService.rawOptions.cursorInactiveStyle;for(let R=L;R<=B;R++){const O=R+F.ydisp,q=this._rowElements[R],V=F.lines.get(O);if(!q||!V)break;q.replaceChildren(...this._rowFactory.createRow(V,O,O===Y,I,M,$,z,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${d}${this._terminalClass}`}_handleLinkHover(L){this._setCellUnderline(L.x1,L.x2,L.y1,L.y2,L.cols,!0)}_handleLinkLeave(L){this._setCellUnderline(L.x1,L.x2,L.y1,L.y2,L.cols,!1)}_setCellUnderline(L,B,F,Y,$,z){F<0&&(L=0),Y<0&&(B=0);const I=this._bufferService.rows-1;F=Math.max(Math.min(F,I),0),Y=Math.max(Math.min(Y,I),0),$=Math.min($,this._bufferService.cols);const M=this._bufferService.buffer,R=M.ybase+M.y,O=Math.min(M.x,$-1),q=this._optionsService.rawOptions.cursorBlink,V=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===R,V,J,O,q,this.dimensions.css.cell.width,this._widthCache,z?X===F?L:0:-1,z?(X===Y?B:$)-1:-1))}}};r.DomRenderer=T=u([_(4,h.IInstantiationService),_(5,m.ICharSizeService),_(6,h.IOptionsService),_(7,h.IBufferService),_(8,m.ICoreBrowserService),_(9,m.IThemeService)],T)},3787:function(E,r,o){var u=this&&this.__decorate||function(y,A,v,x){var D,T=arguments.length,L=T<3?A:x===null?x=Object.getOwnPropertyDescriptor(A,v):x;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")L=Reflect.decorate(y,A,v,x);else for(var B=y.length-1;B>=0;B--)(D=y[B])&&(L=(T<3?D(L):T>3?D(A,v,L):D(A,v))||L);return T>3&&L&&Object.defineProperty(A,v,L),L},_=this&&this.__param||function(y,A){return function(v,x){A(v,x,y)}};Object.defineProperty(r,"__esModule",{value:!0}),r.DomRendererRowFactory=void 0;const l=o(2223),f=o(643),C=o(511),S=o(2585),m=o(8055),s=o(4725),n=o(4269),c=o(6171),h=o(3734);let d=r.DomRendererRowFactory=class{constructor(y,A,v,x,D,T,L){this._document=y,this._characterJoinerService=A,this._optionsService=v,this._coreBrowserService=x,this._coreService=D,this._decorationService=T,this._themeService=L,this._workCell=new C.CellData,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(y,A,v){this._selectionStart=y,this._selectionEnd=A,this._columnSelectMode=v}createRow(y,A,v,x,D,T,L,B,F,Y,$){const z=[],I=this._characterJoinerService.getJoinedCharacters(A),M=this._themeService.colors;let R,O=y.getNoBgTrimmedLength();v&&O<T+1&&(O=T+1);let q=0,V="",J=0,X=0,ce=0,P=!1,U=0,G=!1,K=0;const ie=[],Q=Y!==-1&&$!==-1;for(let oe=0;oe<O;oe++){y.loadCell(oe,this._workCell);let ve=this._workCell.getWidth();if(ve===0)continue;let xe=!1,ct=oe,se=this._workCell;if(I.length>0&&oe===I[0][0]){xe=!0;const he=I.shift();se=new n.JoinedCellData(this._workCell,y.translateToString(!0,he[0],he[1]),he[1]-he[0]),ct=he[1]-1,ve=se.getWidth()}const St=this._isCellInSelection(oe,A),Ci=v&&oe===T,Ei=Q&&oe>=Y&&oe<=$;let yi=!1;this._decorationService.forEachDecorationAtCell(oe,A,void 0,he=>{yi=!0});let Ut=se.getChars()||f.WHITESPACE_CELL_CHAR;if(Ut===" "&&(se.isUnderline()||se.isOverline())&&(Ut=" "),K=ve*B-F.get(Ut,se.isBold(),se.isItalic()),R){if(q&&(St&&G||!St&&!G&&se.bg===J)&&(St&&G&&M.selectionForeground||se.fg===X)&&se.extended.ext===ce&&Ei===P&&K===U&&!Ci&&!xe&&!yi){V+=Ut,q++;continue}q&&(R.textContent=V),R=this._document.createElement("span"),q=0,V=""}else R=this._document.createElement("span");if(J=se.bg,X=se.fg,ce=se.extended.ext,P=Ei,U=K,G=St,xe&&T>=oe&&T<=ct&&(T=oe),!this._coreService.isCursorHidden&&Ci){if(ie.push("xterm-cursor"),this._coreBrowserService.isFocused)L&&ie.push("xterm-cursor-blink"),ie.push(x==="bar"?"xterm-cursor-bar":x==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(D)switch(D){case"outline":ie.push("xterm-cursor-outline");break;case"block":ie.push("xterm-cursor-block");break;case"bar":ie.push("xterm-cursor-bar");break;case"underline":ie.push("xterm-cursor-underline")}}if(se.isBold()&&ie.push("xterm-bold"),se.isItalic()&&ie.push("xterm-italic"),se.isDim()&&ie.push("xterm-dim"),V=se.isInvisible()?f.WHITESPACE_CELL_CHAR:se.getChars()||f.WHITESPACE_CELL_CHAR,se.isUnderline()&&(ie.push(`xterm-underline-${se.extended.underlineStyle}`),V===" "&&(V=" "),!se.isUnderlineColorDefault()))if(se.isUnderlineColorRGB())R.style.textDecorationColor=`rgb(${h.AttributeData.toColorRGB(se.getUnderlineColor()).join(",")})`;else{let he=se.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&se.isBold()&&he<8&&(he+=8),R.style.textDecorationColor=M.ansi[he].css}se.isOverline()&&(ie.push("xterm-overline"),V===" "&&(V=" ")),se.isStrikethrough()&&ie.push("xterm-strikethrough"),Ei&&(R.style.textDecoration="underline");let Pe=se.getFgColor(),bt=se.getFgColorMode(),je=se.getBgColor(),Ct=se.getBgColorMode();const wi=!!se.isInverse();if(wi){const he=Pe;Pe=je,je=he;const ao=bt;bt=Ct,Ct=ao}let $e,xi,qe,Et=!1;switch(this._decorationService.forEachDecorationAtCell(oe,A,void 0,he=>{he.options.layer!=="top"&&Et||(he.backgroundColorRGB&&(Ct=50331648,je=he.backgroundColorRGB.rgba>>8&16777215,$e=he.backgroundColorRGB),he.foregroundColorRGB&&(bt=50331648,Pe=he.foregroundColorRGB.rgba>>8&16777215,xi=he.foregroundColorRGB),Et=he.options.layer==="top")}),!Et&&St&&($e=this._coreBrowserService.isFocused?M.selectionBackgroundOpaque:M.selectionInactiveBackgroundOpaque,je=$e.rgba>>8&16777215,Ct=50331648,Et=!0,M.selectionForeground&&(bt=50331648,Pe=M.selectionForeground.rgba>>8&16777215,xi=M.selectionForeground)),Et&&ie.push("xterm-decoration-top"),Ct){case 16777216:case 33554432:qe=M.ansi[je],ie.push(`xterm-bg-${je}`);break;case 50331648:qe=m.rgba.toColor(je>>16,je>>8&255,255&je),this._addStyle(R,`background-color:#${b((je>>>0).toString(16),"0",6)}`);break;default:wi?(qe=M.foreground,ie.push(`xterm-bg-${l.INVERTED_DEFAULT_COLOR}`)):qe=M.background}switch($e||se.isDim()&&($e=m.color.multiplyOpacity(qe,.5)),bt){case 16777216:case 33554432:se.isBold()&&Pe<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(Pe+=8),this._applyMinimumContrast(R,qe,M.ansi[Pe],se,$e,void 0)||ie.push(`xterm-fg-${Pe}`);break;case 50331648:const he=m.rgba.toColor(Pe>>16&255,Pe>>8&255,255&Pe);this._applyMinimumContrast(R,qe,he,se,$e,xi)||this._addStyle(R,`color:#${b(Pe.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(R,qe,M.foreground,se,$e,void 0)||wi&&ie.push(`xterm-fg-${l.INVERTED_DEFAULT_COLOR}`)}ie.length&&(R.className=ie.join(" "),ie.length=0),Ci||xe||yi?R.textContent=V:q++,K!==this.defaultSpacing&&(R.style.letterSpacing=`${K}px`),z.push(R),oe=ct}return R&&q&&(R.textContent=V),z}_applyMinimumContrast(y,A,v,x,D,T){if(this._optionsService.rawOptions.minimumContrastRatio===1||(0,c.excludeFromContrastRatioDemands)(x.getCode()))return!1;const L=this._getContrastCache(x);let B;if(D||T||(B=L.getColor(A.rgba,v.rgba)),B===void 0){const F=this._optionsService.rawOptions.minimumContrastRatio/(x.isDim()?2:1);B=m.color.ensureContrastRatio(D||A,T||v,F),L.setColor((D||A).rgba,(T||v).rgba,B??null)}return!!B&&(this._addStyle(y,`color:${B.css}`),!0)}_getContrastCache(y){return y.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(y,A){y.setAttribute("style",`${y.getAttribute("style")||""}${A};`)}_isCellInSelection(y,A){const v=this._selectionStart,x=this._selectionEnd;return!(!v||!x)&&(this._columnSelectMode?v[0]<=x[0]?y>=v[0]&&A>=v[1]&&y<x[0]&&A<=x[1]:y<v[0]&&A>=v[1]&&y>=x[0]&&A<=x[1]:A>v[1]&&A<x[1]||v[1]===x[1]&&A===v[1]&&y>=v[0]&&y<x[0]||v[1]<x[1]&&A===x[1]&&y<x[0]||v[1]<x[1]&&A===v[1]&&y>=v[0])}};function b(y,A,v){for(;y.length<v;)y=A+y;return y}r.DomRendererRowFactory=d=u([_(1,s.ICharacterJoinerService),_(2,S.IOptionsService),_(3,s.ICoreBrowserService),_(4,S.ICoreService),_(5,S.IDecorationService),_(6,s.IThemeService)],d)},2550:(E,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.WidthCache=void 0,r.WidthCache=class{constructor(o){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=o.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=o.createElement("span"),_=o.createElement("span");_.style.fontWeight="bold";const l=o.createElement("span");l.style.fontStyle="italic";const f=o.createElement("span");f.style.fontWeight="bold",f.style.fontStyle="italic",this._measureElements=[u,_,l,f],this._container.appendChild(u),this._container.appendChild(_),this._container.appendChild(l),this._container.appendChild(f),o.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(o,u,_,l){o===this._font&&u===this._fontSize&&_===this._weight&&l===this._weightBold||(this._font=o,this._fontSize=u,this._weight=_,this._weightBold=l,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${_}`,this._measureElements[1].style.fontWeight=`${l}`,this._measureElements[2].style.fontWeight=`${_}`,this._measureElements[3].style.fontWeight=`${l}`,this.clear())}get(o,u,_){let l=0;if(!u&&!_&&o.length===1&&(l=o.charCodeAt(0))<256)return this._flat[l]!==-9999?this._flat[l]:this._flat[l]=this._measure(o,0);let f=o;u&&(f+="B"),_&&(f+="I");let C=this._holey.get(f);if(C===void 0){let S=0;u&&(S|=1),_&&(S|=2),C=this._measure(o,S),this._holey.set(f,C)}return C}_measure(o,u){const _=this._measureElements[u];return _.textContent=o.repeat(32),_.offsetWidth/32}}},2223:(E,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.TEXT_BASELINE=r.DIM_OPACITY=r.INVERTED_DEFAULT_COLOR=void 0;const u=o(6114);r.INVERTED_DEFAULT_COLOR=257,r.DIM_OPACITY=.5,r.TEXT_BASELINE=u.isFirefox||u.isLegacyEdge?"bottom":"ideographic"},6171:(E,r)=>{function o(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=o,r.isRestrictedPowerlineGlyph=function(u){return 57520<=u&&u<=57527},r.excludeFromContrastRatioDemands=function(u){return o(u)||function(_){return 9472<=_&&_<=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:(E,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.SelectionModel=void 0,r.SelectionModel=class{constructor(o){this._bufferService=o,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 o=this.selectionStart[0]+this.selectionStartLength;return o>this._bufferService.cols?o%this._bufferService.cols==0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(o/this._bufferService.cols)-1]:[o%this._bufferService.cols,this.selectionStart[1]+Math.floor(o/this._bufferService.cols)]:[o,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){const o=this.selectionStart[0]+this.selectionStartLength;return o>this._bufferService.cols?[o%this._bufferService.cols,this.selectionStart[1]+Math.floor(o/this._bufferService.cols)]:[Math.max(o,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){const o=this.selectionStart,u=this.selectionEnd;return!(!o||!u)&&(o[1]>u[1]||o[1]===u[1]&&o[0]>u[0])}handleTrim(o){return this.selectionStart&&(this.selectionStart[1]-=o),this.selectionEnd&&(this.selectionEnd[1]-=o),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}}},428:function(E,r,o){var u=this&&this.__decorate||function(s,n,c,h){var d,b=arguments.length,y=b<3?n:h===null?h=Object.getOwnPropertyDescriptor(n,c):h;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")y=Reflect.decorate(s,n,c,h);else for(var A=s.length-1;A>=0;A--)(d=s[A])&&(y=(b<3?d(y):b>3?d(n,c,y):d(n,c))||y);return b>3&&y&&Object.defineProperty(n,c,y),y},_=this&&this.__param||function(s,n){return function(c,h){n(c,h,s)}};Object.defineProperty(r,"__esModule",{value:!0}),r.CharSizeService=void 0;const l=o(2585),f=o(8460),C=o(844);let S=r.CharSizeService=class extends C.Disposable{get hasValidSize(){return this.width>0&&this.height>0}constructor(s,n,c){super(),this._optionsService=c,this.width=0,this.height=0,this._onCharSizeChange=this.register(new f.EventEmitter),this.onCharSizeChange=this._onCharSizeChange.event,this._measureStrategy=new m(s,n,this._optionsService),this.register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],()=>this.measure()))}measure(){const s=this._measureStrategy.measure();s.width===this.width&&s.height===this.height||(this.width=s.width,this.height=s.height,this._onCharSizeChange.fire())}};r.CharSizeService=S=u([_(2,l.IOptionsService)],S);class m{constructor(n,c,h){this._document=n,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 n={height:Number(this._measureElement.offsetHeight),width:Number(this._measureElement.offsetWidth)};return n.width!==0&&n.height!==0&&(this._result.width=n.width/32,this._result.height=Math.ceil(n.height)),this._result}}},4269:function(E,r,o){var u=this&&this.__decorate||function(n,c,h,d){var b,y=arguments.length,A=y<3?c:d===null?d=Object.getOwnPropertyDescriptor(c,h):d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")A=Reflect.decorate(n,c,h,d);else for(var v=n.length-1;v>=0;v--)(b=n[v])&&(A=(y<3?b(A):y>3?b(c,h,A):b(c,h))||A);return y>3&&A&&Object.defineProperty(c,h,A),A},_=this&&this.__param||function(n,c){return function(h,d){c(h,d,n)}};Object.defineProperty(r,"__esModule",{value:!0}),r.CharacterJoinerService=r.JoinedCellData=void 0;const l=o(3734),f=o(643),C=o(511),S=o(2585);class m extends l.AttributeData{constructor(c,h,d){super(),this.content=0,this.combinedData="",this.fg=c.fg,this.bg=c.bg,this.combinedData=h,this._width=d}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=m;let s=r.CharacterJoinerService=class Cr{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 d=[],b=h.translateToString(!0);let y=0,A=0,v=0,x=h.getFg(0),D=h.getBg(0);for(let T=0;T<h.getTrimmedLength();T++)if(h.loadCell(T,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==x||this._workCell.bg!==D){if(T-y>1){const L=this._getJoinedRanges(b,v,A,h,y);for(let B=0;B<L.length;B++)d.push(L[B])}y=T,v=A,x=this._workCell.fg,D=this._workCell.bg}A+=this._workCell.getChars().length||f.WHITESPACE_CELL_CHAR.length}if(this._bufferService.cols-y>1){const T=this._getJoinedRanges(b,v,A,h,y);for(let L=0;L<T.length;L++)d.push(T[L])}return d}_getJoinedRanges(c,h,d,b,y){const A=c.substring(h,d);let v=[];try{v=this._characterJoiners[0].handler(A)}catch(x){console.error(x)}for(let x=1;x<this._characterJoiners.length;x++)try{const D=this._characterJoiners[x].handler(A);for(let T=0;T<D.length;T++)Cr._mergeRanges(v,D[T])}catch(D){console.error(D)}return this._stringRangesToCellRanges(v,b,y),v}_stringRangesToCellRanges(c,h,d){let b=0,y=!1,A=0,v=c[b];if(v){for(let x=d;x<this._bufferService.cols;x++){const D=h.getWidth(x),T=h.getString(x).length||f.WHITESPACE_CELL_CHAR.length;if(D!==0){if(!y&&v[0]<=A&&(v[0]=x,y=!0),v[1]<=A){if(v[1]=x,v=c[++b],!v)break;v[0]<=A?(v[0]=x,y=!0):y=!1}A+=T}}v&&(v[1]=this._bufferService.cols)}}static _mergeRanges(c,h){let d=!1;for(let b=0;b<c.length;b++){const y=c[b];if(d){if(h[1]<=y[0])return c[b-1][1]=h[1],c;if(h[1]<=y[1])return c[b-1][1]=Math.max(h[1],y[1]),c.splice(b,1),c;c.splice(b,1),b--}else{if(h[1]<=y[0])return c.splice(b,0,h),c;if(h[1]<=y[1])return y[0]=Math.min(h[0],y[0]),c;h[0]<y[1]&&(y[0]=Math.min(h[0],y[0]),d=!0)}}return d?c[c.length-1][1]=h[1]:c.push(h),c}};r.CharacterJoinerService=s=u([_(0,S.IBufferService)],s)},5114:(E,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.CoreBrowserService=void 0,r.CoreBrowserService=class{constructor(o,u){this._textarea=o,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(E,r,o){var u=this&&this.__decorate||function(S,m,s,n){var c,h=arguments.length,d=h<3?m:n===null?n=Object.getOwnPropertyDescriptor(m,s):n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")d=Reflect.decorate(S,m,s,n);else for(var b=S.length-1;b>=0;b--)(c=S[b])&&(d=(h<3?c(d):h>3?c(m,s,d):c(m,s))||d);return h>3&&d&&Object.defineProperty(m,s,d),d},_=this&&this.__param||function(S,m){return function(s,n){m(s,n,S)}};Object.defineProperty(r,"__esModule",{value:!0}),r.MouseService=void 0;const l=o(4725),f=o(9806);let C=r.MouseService=class{constructor(S,m){this._renderService=S,this._charSizeService=m}getCoords(S,m,s,n,c){return(0,f.getCoords)(window,S,m,s,n,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,c)}getMouseReportCoords(S,m){const s=(0,f.getCoordsRelativeToElement)(window,S,m);if(this._charSizeService.hasValidSize)return s[0]=Math.min(Math.max(s[0],0),this._renderService.dimensions.css.canvas.width-1),s[1]=Math.min(Math.max(s[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(s[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(s[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(s[0]),y:Math.floor(s[1])}}};r.MouseService=C=u([_(0,l.IRenderService),_(1,l.ICharSizeService)],C)},3230:function(E,r,o){var u=this&&this.__decorate||function(d,b,y,A){var v,x=arguments.length,D=x<3?b:A===null?A=Object.getOwnPropertyDescriptor(b,y):A;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")D=Reflect.decorate(d,b,y,A);else for(var T=d.length-1;T>=0;T--)(v=d[T])&&(D=(x<3?v(D):x>3?v(b,y,D):v(b,y))||D);return x>3&&D&&Object.defineProperty(b,y,D),D},_=this&&this.__param||function(d,b){return function(y,A){b(y,A,d)}};Object.defineProperty(r,"__esModule",{value:!0}),r.RenderService=void 0;const l=o(3656),f=o(6193),C=o(5596),S=o(4725),m=o(8460),s=o(844),n=o(7226),c=o(2585);let h=r.RenderService=class extends s.Disposable{get dimensions(){return this._renderer.value.dimensions}constructor(d,b,y,A,v,x,D,T){if(super(),this._rowCount=d,this._charSizeService=A,this._renderer=this.register(new s.MutableDisposable),this._pausedResizeTask=new n.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 m.EventEmitter),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this.register(new m.EventEmitter),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this.register(new m.EventEmitter),this.onRender=this._onRender.event,this._onRefreshRequest=this.register(new m.EventEmitter),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new f.RenderDebouncer(D.window,(L,B)=>this._renderRows(L,B)),this.register(this._renderDebouncer),this._screenDprMonitor=new C.ScreenDprMonitor(D.window),this._screenDprMonitor.setListener(()=>this.handleDevicePixelRatioChange()),this.register(this._screenDprMonitor),this.register(x.onResize(()=>this._fullRefresh())),this.register(x.buffers.onBufferActivate(()=>{var L;return(L=this._renderer.value)===null||L===void 0?void 0:L.clear()})),this.register(y.onOptionChange(()=>this._handleOptionsChanged())),this.register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this.register(v.onDecorationRegistered(()=>this._fullRefresh())),this.register(v.onDecorationRemoved(()=>this._fullRefresh())),this.register(y.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio"],()=>{this.clear(),this.handleResize(x.cols,x.rows),this._fullRefresh()})),this.register(y.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(x.buffer.y,x.buffer.y,!0))),this.register((0,l.addDisposableDomListener)(D.window,"resize",()=>this.handleDevicePixelRatioChange())),this.register(T.onChangeColors(()=>this._fullRefresh())),"IntersectionObserver"in D.window){const L=new D.window.IntersectionObserver(B=>this._handleIntersectionChange(B[B.length-1]),{threshold:0});L.observe(b),this.register({dispose:()=>L.disconnect()})}}_handleIntersectionChange(d){this._isPaused=d.isIntersecting===void 0?d.intersectionRatio===0:!d.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(d,b,y=!1){this._isPaused?this._needsFullRefresh=!0:(y||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(d,b,this._rowCount))}_renderRows(d,b){this._renderer.value&&(d=Math.min(d,this._rowCount-1),b=Math.min(b,this._rowCount-1),this._renderer.value.renderRows(d,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:d,end:b}),this._onRender.fire({start:d,end:b}),this._isNextRenderRedrawOnly=!0)}resize(d,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(d){this._renderer.value=d,this._renderer.value.onRequestRedraw(b=>this.refreshRows(b.start,b.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh()}addRefreshCallback(d){return this._renderDebouncer.addRefreshCallback(d)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){var d,b;this._renderer.value&&((b=(d=this._renderer.value).clearTextureAtlas)===null||b===void 0||b.call(d),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(d,b){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>this._renderer.value.handleResize(d,b)):this._renderer.value.handleResize(d,b),this._fullRefresh())}handleCharSizeChanged(){var d;(d=this._renderer.value)===null||d===void 0||d.handleCharSizeChanged()}handleBlur(){var d;(d=this._renderer.value)===null||d===void 0||d.handleBlur()}handleFocus(){var d;(d=this._renderer.value)===null||d===void 0||d.handleFocus()}handleSelectionChanged(d,b,y){var A;this._selectionState.start=d,this._selectionState.end=b,this._selectionState.columnSelectMode=y,(A=this._renderer.value)===null||A===void 0||A.handleSelectionChanged(d,b,y)}handleCursorMove(){var d;(d=this._renderer.value)===null||d===void 0||d.handleCursorMove()}clear(){var d;(d=this._renderer.value)===null||d===void 0||d.clear()}};r.RenderService=h=u([_(2,c.IOptionsService),_(3,S.ICharSizeService),_(4,c.IDecorationService),_(5,c.IBufferService),_(6,S.ICoreBrowserService),_(7,S.IThemeService)],h)},9312:function(E,r,o){var u=this&&this.__decorate||function(v,x,D,T){var L,B=arguments.length,F=B<3?x:T===null?T=Object.getOwnPropertyDescriptor(x,D):T;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")F=Reflect.decorate(v,x,D,T);else for(var Y=v.length-1;Y>=0;Y--)(L=v[Y])&&(F=(B<3?L(F):B>3?L(x,D,F):L(x,D))||F);return B>3&&F&&Object.defineProperty(x,D,F),F},_=this&&this.__param||function(v,x){return function(D,T){x(D,T,v)}};Object.defineProperty(r,"__esModule",{value:!0}),r.SelectionService=void 0;const l=o(9806),f=o(9504),C=o(456),S=o(4725),m=o(8460),s=o(844),n=o(6114),c=o(4841),h=o(511),d=o(2585),b=" ",y=new RegExp(b,"g");let A=r.SelectionService=class extends s.Disposable{constructor(v,x,D,T,L,B,F,Y,$){super(),this._element=v,this._screenElement=x,this._linkifier=D,this._bufferService=T,this._coreService=L,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 m.EventEmitter),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this.register(new m.EventEmitter),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this.register(new m.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this.register(new m.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,s.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 D=this._bufferService.buffer,T=[];if(this._activeSelectionMode===3){if(v[0]===x[0])return"";const L=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=D.translateBufferLineToString(F,!0,L,B);T.push(Y)}}else{const L=v[1]===x[1]?x[0]:void 0;T.push(D.translateBufferLineToString(v[1],!0,v[0],L));for(let B=v[1]+1;B<=x[1]-1;B++){const F=D.lines.get(B),Y=D.translateBufferLineToString(B,!0);F!=null&&F.isWrapped?T[T.length-1]+=Y:T.push(Y)}if(v[1]!==x[1]){const B=D.lines.get(x[1]),F=D.translateBufferLineToString(x[1],!0,0,x[0]);B&&B.isWrapped?T[T.length-1]+=F:T.push(F)}}return T.map(L=>L.replace(y," ")).join(n.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())),n.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),D=this._model.finalSelectionStart,T=this._model.finalSelectionEnd;return!!(D&&T&&x)&&this._areCoordsInSelection(x,D,T)}isCellInSelection(v,x){const D=this._model.finalSelectionStart,T=this._model.finalSelectionEnd;return!(!D||!T)&&this._areCoordsInSelection([v,x],D,T)}_areCoordsInSelection(v,x,D){return v[1]>x[1]&&v[1]<D[1]||x[1]===D[1]&&v[1]===x[1]&&v[0]>=x[0]&&v[0]<D[0]||x[1]<D[1]&&v[1]===D[1]&&v[0]<D[0]||x[1]<D[1]&&v[1]===x[1]&&v[0]>=x[0]}_selectWordAtCursor(v,x){var D,T;const L=(T=(D=this._linkifier.currentLink)===null||D===void 0?void 0:D.link)===null||T===void 0?void 0:T.range;if(L)return this._model.selectionStart=[L.start.x-1,L.start.y-1],this._model.selectionStartLength=(0,c.getRangeLength)(L,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 D=this._renderService.dimensions.css.canvas.height;return x>=0&&x<=D?0:(x>D&&(x-=D),x=Math.min(Math.max(x,-50),50),x/=50,x/Math.abs(x)+Math.round(14*x))}shouldForceSelection(v){return n.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&&!(n.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 D=this._bufferService.buffer;if(this._model.selectionEnd[1]<D.lines.length){const T=D.lines.get(this._model.selectionEnd[1]);T&&T.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 D=this._mouseService.getCoords(v,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(D&&D[0]!==void 0&&D[1]!==void 0){const T=(0,f.moveToCellSequence)(D[0]-1,D[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(T,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){const v=this._model.finalSelectionStart,x=this._model.finalSelectionEnd,D=!(!v||!x||v[0]===x[0]&&v[1]===x[1]);D?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,D)):this._oldHasSelection&&this._fireOnSelectionChange(v,x,D)}_fireOnSelectionChange(v,x,D){this._oldSelectionStart=v,this._oldSelectionEnd=x,this._oldHasSelection=D,this._onSelectionChange.fire()}_handleBufferActivate(v){this.clearSelection(),this._trimListener.dispose(),this._trimListener=v.activeBuffer.lines.onTrim(x=>this._handleTrim(x))}_convertViewportColToCharacterIndex(v,x){let D=x;for(let T=0;x>=T;T++){const L=v.loadCell(T,this._workCell).getChars().length;this._workCell.getWidth()===0?D--:L>1&&x!==T&&(D+=L-1)}return D}setSelection(v,x,D){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[v,x],this._model.selectionStartLength=D,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(v){this._isClickInSelection(v)||(this._selectWordAtCursor(v,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(v,x,D=!0,T=!0){if(v[0]>=this._bufferService.cols)return;const L=this._bufferService.buffer,B=L.lines.get(v[1]);if(!B)return;const F=L.translateBufferLineToString(v[1],!1);let Y=this._convertViewportColToCharacterIndex(B,v[0]),$=Y;const z=v[0]-Y;let I=0,M=0,R=0,O=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&&(I++,J--),B.getWidth(X)===2&&(M++,X++);const ce=B.getString(X).length;for(ce>1&&(O+=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?(I++,J--):P>1&&(R+=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&&(O+=P-1,$+=P-1),$++,X++}}$++;let q=Y+z-I+R,V=Math.min(this._bufferService.cols,$-Y+I+M-R-O);if(x||F.slice(Y,$).trim()!==""){if(D&&q===0&&B.getCodePoint(0)!==32){const J=L.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;q-=ce,V+=ce}}}if(T&&q+V===this._bufferService.cols&&B.getCodePoint(this._bufferService.cols-1)!==32){const J=L.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&&(V+=X.length)}}return{start:q,length:V}}}_selectWordAt(v,x){const D=this._getWordAt(v,x);if(D){for(;D.start<0;)D.start+=this._bufferService.cols,v[1]--;this._model.selectionStart=[D.start,v[1]],this._model.selectionStartLength=D.length}}_selectToWordAt(v){const x=this._getWordAt(v,!0);if(x){let D=v[1];for(;x.start<0;)x.start+=this._bufferService.cols,D--;if(!this._model.areSelectionValuesReversed())for(;x.start+x.length>this._bufferService.cols;)x.length-=this._bufferService.cols,D++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?x.start:x.start+x.length,D]}}_isCharWordSeparator(v){return v.getWidth()!==0&&this._optionsService.rawOptions.wordSeparator.indexOf(v.getChars())>=0}_selectLineAt(v){const x=this._bufferService.buffer.getWrappedRangeForLine(v),D={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)(D,this._bufferService.cols)}};r.SelectionService=A=u([_(3,d.IBufferService),_(4,d.ICoreService),_(5,S.IMouseService),_(6,d.IOptionsService),_(7,S.IRenderService),_(8,S.ICoreBrowserService)],A)},4725:(E,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.IThemeService=r.ICharacterJoinerService=r.ISelectionService=r.IRenderService=r.IMouseService=r.ICoreBrowserService=r.ICharSizeService=void 0;const u=o(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(E,r,o){var u=this&&this.__decorate||function(A,v,x,D){var T,L=arguments.length,B=L<3?v:D===null?D=Object.getOwnPropertyDescriptor(v,x):D;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")B=Reflect.decorate(A,v,x,D);else for(var F=A.length-1;F>=0;F--)(T=A[F])&&(B=(L<3?T(B):L>3?T(v,x,B):T(v,x))||B);return L>3&&B&&Object.defineProperty(v,x,B),B},_=this&&this.__param||function(A,v){return function(x,D){v(x,D,A)}};Object.defineProperty(r,"__esModule",{value:!0}),r.ThemeService=r.DEFAULT_ANSI_COLORS=void 0;const l=o(7239),f=o(8055),C=o(8460),S=o(844),m=o(2585),s=f.css.toColor("#ffffff"),n=f.css.toColor("#000000"),c=f.css.toColor("#ffffff"),h=f.css.toColor("#000000"),d={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117};r.DEFAULT_ANSI_COLORS=Object.freeze((()=>{const A=[f.css.toColor("#2e3436"),f.css.toColor("#cc0000"),f.css.toColor("#4e9a06"),f.css.toColor("#c4a000"),f.css.toColor("#3465a4"),f.css.toColor("#75507b"),f.css.toColor("#06989a"),f.css.toColor("#d3d7cf"),f.css.toColor("#555753"),f.css.toColor("#ef2929"),f.css.toColor("#8ae234"),f.css.toColor("#fce94f"),f.css.toColor("#729fcf"),f.css.toColor("#ad7fa8"),f.css.toColor("#34e2e2"),f.css.toColor("#eeeeec")],v=[0,95,135,175,215,255];for(let x=0;x<216;x++){const D=v[x/36%6|0],T=v[x/6%6|0],L=v[x%6];A.push({css:f.channels.toCss(D,T,L),rgba:f.channels.toRgba(D,T,L)})}for(let x=0;x<24;x++){const D=8+10*x;A.push({css:f.channels.toCss(D,D,D),rgba:f.channels.toRgba(D,D,D)})}return A})());let b=r.ThemeService=class extends S.Disposable{get colors(){return this._colors}constructor(A){super(),this._optionsService=A,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:s,background:n,cursor:c,cursorAccent:h,selectionForeground:void 0,selectionBackgroundTransparent:d,selectionBackgroundOpaque:f.color.blend(n,d),selectionInactiveBackgroundTransparent:d,selectionInactiveBackgroundOpaque:f.color.blend(n,d),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(A={}){const v=this._colors;if(v.foreground=y(A.foreground,s),v.background=y(A.background,n),v.cursor=y(A.cursor,c),v.cursorAccent=y(A.cursorAccent,h),v.selectionBackgroundTransparent=y(A.selectionBackground,d),v.selectionBackgroundOpaque=f.color.blend(v.background,v.selectionBackgroundTransparent),v.selectionInactiveBackgroundTransparent=y(A.selectionInactiveBackground,v.selectionBackgroundTransparent),v.selectionInactiveBackgroundOpaque=f.color.blend(v.background,v.selectionInactiveBackgroundTransparent),v.selectionForeground=A.selectionForeground?y(A.selectionForeground,f.NULL_COLOR):void 0,v.selectionForeground===f.NULL_COLOR&&(v.selectionForeground=void 0),f.color.isOpaque(v.selectionBackgroundTransparent)&&(v.selectionBackgroundTransparent=f.color.opacity(v.selectionBackgroundTransparent,.3)),f.color.isOpaque(v.selectionInactiveBackgroundTransparent)&&(v.selectionInactiveBackgroundTransparent=f.color.opacity(v.selectionInactiveBackgroundTransparent,.3)),v.ansi=r.DEFAULT_ANSI_COLORS.slice(),v.ansi[0]=y(A.black,r.DEFAULT_ANSI_COLORS[0]),v.ansi[1]=y(A.red,r.DEFAULT_ANSI_COLORS[1]),v.ansi[2]=y(A.green,r.DEFAULT_ANSI_COLORS[2]),v.ansi[3]=y(A.yellow,r.DEFAULT_ANSI_COLORS[3]),v.ansi[4]=y(A.blue,r.DEFAULT_ANSI_COLORS[4]),v.ansi[5]=y(A.magenta,r.DEFAULT_ANSI_COLORS[5]),v.ansi[6]=y(A.cyan,r.DEFAULT_ANSI_COLORS[6]),v.ansi[7]=y(A.white,r.DEFAULT_ANSI_COLORS[7]),v.ansi[8]=y(A.brightBlack,r.DEFAULT_ANSI_COLORS[8]),v.ansi[9]=y(A.brightRed,r.DEFAULT_ANSI_COLORS[9]),v.ansi[10]=y(A.brightGreen,r.DEFAULT_ANSI_COLORS[10]),v.ansi[11]=y(A.brightYellow,r.DEFAULT_ANSI_COLORS[11]),v.ansi[12]=y(A.brightBlue,r.DEFAULT_ANSI_COLORS[12]),v.ansi[13]=y(A.brightMagenta,r.DEFAULT_ANSI_COLORS[13]),v.ansi[14]=y(A.brightCyan,r.DEFAULT_ANSI_COLORS[14]),v.ansi[15]=y(A.brightWhite,r.DEFAULT_ANSI_COLORS[15]),A.extendedAnsi){const x=Math.min(v.ansi.length-16,A.extendedAnsi.length);for(let D=0;D<x;D++)v.ansi[D+16]=y(A.extendedAnsi[D],r.DEFAULT_ANSI_COLORS[D+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(A){this._restoreColor(A),this._onChangeColors.fire(this.colors)}_restoreColor(A){if(A!==void 0)switch(A){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[A]=this._restoreColors.ansi[A]}else for(let v=0;v<this._restoreColors.ansi.length;++v)this._colors.ansi[v]=this._restoreColors.ansi[v]}modifyColors(A){A(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 y(A,v){if(A!==void 0)try{return f.css.toColor(A)}catch{}return v}r.ThemeService=b=u([_(0,m.IOptionsService)],b)},6349:(E,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.CircularList=void 0;const u=o(8460),_=o(844);class l extends _.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 m=0;m<Math.min(C,this.length);m++)S[m]=this._array[this._getCyclicIndex(m)];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,...m){if(S){for(let s=C;s<this._length-S;s++)this._array[this._getCyclicIndex(s)]=this._array[this._getCyclicIndex(s+S)];this._length-=S,this.onDeleteEmitter.fire({index:C,amount:S})}for(let s=this._length-1;s>=C;s--)this._array[this._getCyclicIndex(s+m.length)]=this._array[this._getCyclicIndex(s)];for(let s=0;s<m.length;s++)this._array[this._getCyclicIndex(C+s)]=m[s];if(m.length&&this.onInsertEmitter.fire({index:C,amount:m.length}),this._length+m.length>this._maxLength){const s=this._length+m.length-this._maxLength;this._startIndex+=s,this._length=this._maxLength,this.onTrimEmitter.fire(s)}else this._length+=m.length}trimStart(C){C>this._length&&(C=this._length),this._startIndex+=C,this._length-=C,this.onTrimEmitter.fire(C)}shiftElements(C,S,m){if(!(S<=0)){if(C<0||C>=this._length)throw new Error("start argument out of range");if(C+m<0)throw new Error("Cannot shift elements in list beyond index 0");if(m>0){for(let n=S-1;n>=0;n--)this.set(C+n+m,this.get(C+n));const s=C+S+m-this._length;if(s>0)for(this._length+=s;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let s=0;s<S;s++)this.set(C+s+m,this.get(C+s))}}_getCyclicIndex(C){return(this._startIndex+C)%this._maxLength}}r.CircularList=l},1439:(E,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.clone=void 0,r.clone=function o(u,_=5){if(typeof u!="object")return u;const l=Array.isArray(u)?[]:{};for(const f in u)l[f]=_<=1?u[f]:u[f]&&o(u[f],_-1);return l}},8055:(E,r,o)=>{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=o(6114);let _=0,l=0,f=0,C=0;var S,m,s,n,c;function h(b){const y=b.toString(16);return y.length<2?"0"+y:y}function d(b,y){return b<y?(y+.05)/(b+.05):(b+.05)/(y+.05)}r.NULL_COLOR={css:"#00000000",rgba:0},function(b){b.toCss=function(y,A,v,x){return x!==void 0?`#${h(y)}${h(A)}${h(v)}${h(x)}`:`#${h(y)}${h(A)}${h(v)}`},b.toRgba=function(y,A,v,x=255){return(y<<24|A<<16|v<<8|x)>>>0}}(S||(r.channels=S={})),function(b){function y(A,v){return C=Math.round(255*v),[_,l,f]=c.toChannels(A.rgba),{css:S.toCss(_,l,f,C),rgba:S.toRgba(_,l,f,C)}}b.blend=function(A,v){if(C=(255&v.rgba)/255,C===1)return{css:v.css,rgba:v.rgba};const x=v.rgba>>24&255,D=v.rgba>>16&255,T=v.rgba>>8&255,L=A.rgba>>24&255,B=A.rgba>>16&255,F=A.rgba>>8&255;return _=L+Math.round((x-L)*C),l=B+Math.round((D-B)*C),f=F+Math.round((T-F)*C),{css:S.toCss(_,l,f),rgba:S.toRgba(_,l,f)}},b.isOpaque=function(A){return(255&A.rgba)==255},b.ensureContrastRatio=function(A,v,x){const D=c.ensureContrastRatio(A.rgba,v.rgba,x);if(D)return c.toColor(D>>24&255,D>>16&255,D>>8&255)},b.opaque=function(A){const v=(255|A.rgba)>>>0;return[_,l,f]=c.toChannels(v),{css:S.toCss(_,l,f),rgba:v}},b.opacity=y,b.multiplyOpacity=function(A,v){return C=255&A.rgba,y(A,C*v/255)},b.toColorRGB=function(A){return[A.rgba>>24&255,A.rgba>>16&255,A.rgba>>8&255]}}(m||(r.color=m={})),function(b){let y,A;if(!u.isNode){const v=document.createElement("canvas");v.width=1,v.height=1;const x=v.getContext("2d",{willReadFrequently:!0});x&&(y=x,y.globalCompositeOperation="copy",A=y.createLinearGradient(0,0,1,1))}b.toColor=function(v){if(v.match(/#[\da-f]{3,8}/i))switch(v.length){case 4:return _=parseInt(v.slice(1,2).repeat(2),16),l=parseInt(v.slice(2,3).repeat(2),16),f=parseInt(v.slice(3,4).repeat(2),16),c.toColor(_,l,f);case 5:return _=parseInt(v.slice(1,2).repeat(2),16),l=parseInt(v.slice(2,3).repeat(2),16),f=parseInt(v.slice(3,4).repeat(2),16),C=parseInt(v.slice(4,5).repeat(2),16),c.toColor(_,l,f,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 _=parseInt(x[1]),l=parseInt(x[2]),f=parseInt(x[3]),C=Math.round(255*(x[5]===void 0?1:parseFloat(x[5]))),c.toColor(_,l,f,C);if(!y||!A)throw new Error("css.toColor: Unsupported css format");if(y.fillStyle=A,y.fillStyle=v,typeof y.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(y.fillRect(0,0,1,1),[_,l,f,C]=y.getImageData(0,0,1,1).data,C!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:S.toRgba(_,l,f,C),css:v}}}(s||(r.css=s={})),function(b){function y(A,v,x){const D=A/255,T=v/255,L=x/255;return .2126*(D<=.03928?D/12.92:Math.pow((D+.055)/1.055,2.4))+.7152*(T<=.03928?T/12.92:Math.pow((T+.055)/1.055,2.4))+.0722*(L<=.03928?L/12.92:Math.pow((L+.055)/1.055,2.4))}b.relativeLuminance=function(A){return y(A>>16&255,A>>8&255,255&A)},b.relativeLuminance2=y}(n||(r.rgb=n={})),function(b){function y(v,x,D){const T=v>>24&255,L=v>>16&255,B=v>>8&255;let F=x>>24&255,Y=x>>16&255,$=x>>8&255,z=d(n.relativeLuminance2(F,Y,$),n.relativeLuminance2(T,L,B));for(;z<D&&(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=d(n.relativeLuminance2(F,Y,$),n.relativeLuminance2(T,L,B));return(F<<24|Y<<16|$<<8|255)>>>0}function A(v,x,D){const T=v>>24&255,L=v>>16&255,B=v>>8&255;let F=x>>24&255,Y=x>>16&255,$=x>>8&255,z=d(n.relativeLuminance2(F,Y,$),n.relativeLuminance2(T,L,B));for(;z<D&&(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=d(n.relativeLuminance2(F,Y,$),n.relativeLuminance2(T,L,B));return(F<<24|Y<<16|$<<8|255)>>>0}b.ensureContrastRatio=function(v,x,D){const T=n.relativeLuminance(v>>8),L=n.relativeLuminance(x>>8);if(d(T,L)<D){if(L<T){const Y=y(v,x,D),$=d(T,n.relativeLuminance(Y>>8));if($<D){const z=A(v,x,D);return $>d(T,n.relativeLuminance(z>>8))?Y:z}return Y}const B=A(v,x,D),F=d(T,n.relativeLuminance(B>>8));if(F<D){const Y=y(v,x,D);return F>d(T,n.relativeLuminance(Y>>8))?B:Y}return B}},b.reduceLuminance=y,b.increaseLuminance=A,b.toChannels=function(v){return[v>>24&255,v>>16&255,v>>8&255,255&v]},b.toColor=function(v,x,D,T){return{css:S.toCss(v,x,D,T),rgba:S.toRgba(v,x,D,T)}}}(c||(r.rgba=c={})),r.toPaddedHex=h,r.contrastRatio=d},8969:(E,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.CoreTerminal=void 0;const u=o(844),_=o(2585),l=o(4348),f=o(7866),C=o(744),S=o(7302),m=o(6975),s=o(8460),n=o(1753),c=o(1480),h=o(7994),d=o(9282),b=o(5435),y=o(5981),A=o(2660);let v=!1;class x extends u.Disposable{get onScroll(){return this._onScrollApi||(this._onScrollApi=this.register(new s.EventEmitter),this._onScroll.event(T=>{var L;(L=this._onScrollApi)===null||L===void 0||L.fire(T.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(T){for(const L in T)this.optionsService.options[L]=T[L]}constructor(T){super(),this._windowsWrappingHeuristics=this.register(new u.MutableDisposable),this._onBinary=this.register(new s.EventEmitter),this.onBinary=this._onBinary.event,this._onData=this.register(new s.EventEmitter),this.onData=this._onData.event,this._onLineFeed=this.register(new s.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onResize=this.register(new s.EventEmitter),this.onResize=this._onResize.event,this._onWriteParsed=this.register(new s.EventEmitter),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this.register(new s.EventEmitter),this._instantiationService=new l.InstantiationService,this.optionsService=this.register(new S.OptionsService(T)),this._instantiationService.setService(_.IOptionsService,this.optionsService),this._bufferService=this.register(this._instantiationService.createInstance(C.BufferService)),this._instantiationService.setService(_.IBufferService,this._bufferService),this._logService=this.register(this._instantiationService.createInstance(f.LogService)),this._instantiationService.setService(_.ILogService,this._logService),this.coreService=this.register(this._instantiationService.createInstance(m.CoreService)),this._instantiationService.setService(_.ICoreService,this.coreService),this.coreMouseService=this.register(this._instantiationService.createInstance(n.CoreMouseService)),this._instantiationService.setService(_.ICoreMouseService,this.coreMouseService),this.unicodeService=this.register(this._instantiationService.createInstance(c.UnicodeService)),this._instantiationService.setService(_.IUnicodeService,this.unicodeService),this._charsetService=this._instantiationService.createInstance(h.CharsetService),this._instantiationService.setService(_.ICharsetService,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(A.OscLinkService),this._instantiationService.setService(_.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,s.forwardEvent)(this._inputHandler.onLineFeed,this._onLineFeed)),this.register(this._inputHandler),this.register((0,s.forwardEvent)(this._bufferService.onResize,this._onResize)),this.register((0,s.forwardEvent)(this.coreService.onData,this._onData)),this.register((0,s.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(L=>{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(L=>{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 y.WriteBuffer((L,B)=>this._inputHandler.parse(L,B))),this.register((0,s.forwardEvent)(this._writeBuffer.onWriteParsed,this._onWriteParsed))}write(T,L){this._writeBuffer.write(T,L)}writeSync(T,L){this._logService.logLevel<=_.LogLevelEnum.WARN&&!v&&(this._logService.warn("writeSync is unreliable and will be removed soon."),v=!0),this._writeBuffer.writeSync(T,L)}resize(T,L){isNaN(T)||isNaN(L)||(T=Math.max(T,C.MINIMUM_COLS),L=Math.max(L,C.MINIMUM_ROWS),this._bufferService.resize(T,L))}scroll(T,L=!1){this._bufferService.scroll(T,L)}scrollLines(T,L,B){this._bufferService.scrollLines(T,L,B)}scrollPages(T){this.scrollLines(T*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(T){const L=T-this._bufferService.buffer.ydisp;L!==0&&this.scrollLines(L)}registerEscHandler(T,L){return this._inputHandler.registerEscHandler(T,L)}registerDcsHandler(T,L){return this._inputHandler.registerDcsHandler(T,L)}registerCsiHandler(T,L){return this._inputHandler.registerCsiHandler(T,L)}registerOscHandler(T,L){return this._inputHandler.registerOscHandler(T,L)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let T=!1;const L=this.optionsService.rawOptions.windowsPty;L&&L.buildNumber!==void 0&&L.buildNumber!==void 0?T=L.backend==="conpty"&&L.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(T=!0),T?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){const T=[];T.push(this.onLineFeed(d.updateWindowsModeWrappedState.bind(null,this._bufferService))),T.push(this.registerCsiHandler({final:"H"},()=>((0,d.updateWindowsModeWrappedState)(this._bufferService),!1))),this._windowsWrappingHeuristics.value=(0,u.toDisposable)(()=>{for(const L of T)L.dispose()})}}}r.CoreTerminal=x},8460:(E,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=o=>(this._listeners.push(o),{dispose:()=>{if(!this._disposed){for(let u=0;u<this._listeners.length;u++)if(this._listeners[u]===o)return void this._listeners.splice(u,1)}}})),this._event}fire(o,u){const _=[];for(let l=0;l<this._listeners.length;l++)_.push(this._listeners[l]);for(let l=0;l<_.length;l++)_[l].call(void 0,o,u)}dispose(){this.clearListeners(),this._disposed=!0}clearListeners(){this._listeners&&(this._listeners.length=0)}},r.forwardEvent=function(o,u){return o(_=>u.fire(_))}},5435:function(E,r,o){var u=this&&this.__decorate||function(z,I,M,R){var O,q=arguments.length,V=q<3?I:R===null?R=Object.getOwnPropertyDescriptor(I,M):R;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")V=Reflect.decorate(z,I,M,R);else for(var J=z.length-1;J>=0;J--)(O=z[J])&&(V=(q<3?O(V):q>3?O(I,M,V):O(I,M))||V);return q>3&&V&&Object.defineProperty(I,M,V),V},_=this&&this.__param||function(z,I){return function(M,R){I(M,R,z)}};Object.defineProperty(r,"__esModule",{value:!0}),r.InputHandler=r.WindowsOptionsReportType=void 0;const l=o(2584),f=o(7116),C=o(2015),S=o(844),m=o(482),s=o(8437),n=o(8460),c=o(643),h=o(511),d=o(3734),b=o(2585),y=o(6242),A=o(6351),v=o(5941),x={"(":0,")":1,"*":2,"+":3,"-":1,".":2},D=131072;function T(z,I){if(z>24)return I.setWinLines||!1;switch(z){case 1:return!!I.restoreWin;case 2:return!!I.minimizeWin;case 3:return!!I.setWinPosition;case 4:return!!I.setWinSizePixels;case 5:return!!I.raiseWin;case 6:return!!I.lowerWin;case 7:return!!I.refreshWin;case 8:return!!I.setWinSizeChars;case 9:return!!I.maximizeWin;case 10:return!!I.fullscreenWin;case 11:return!!I.getWinState;case 13:return!!I.getWinPosition;case 14:return!!I.getWinSizePixels;case 15:return!!I.getScreenSizePixels;case 16:return!!I.getCellSizePixels;case 18:return!!I.getWinSizeChars;case 19:return!!I.getScreenSizeChars;case 20:return!!I.getIconTitle;case 21:return!!I.getWinTitle;case 22:return!!I.pushTitle;case 23:return!!I.popTitle;case 24:return!!I.setWinLines}return!1}var L;(function(z){z[z.GET_WIN_SIZE_PIXELS=0]="GET_WIN_SIZE_PIXELS",z[z.GET_CELL_SIZE_PIXELS=1]="GET_CELL_SIZE_PIXELS"})(L||(r.WindowsOptionsReportType=L={}));let B=0;class F extends S.Disposable{getAttrData(){return this._curAttrData}constructor(I,M,R,O,q,V,J,X,ce=new C.EscapeSequenceParser){super(),this._bufferService=I,this._charsetService=M,this._coreService=R,this._logService=O,this._optionsService=q,this._oscLinkService=V,this._coreMouseService=J,this._unicodeService=X,this._parser=ce,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new m.StringToUtf32,this._utf8Decoder=new m.Utf8ToUtf32,this._workCell=new h.CellData,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=s.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=s.DEFAULT_ATTR_DATA.clone(),this._onRequestBell=this.register(new n.EventEmitter),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this.register(new n.EventEmitter),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this.register(new n.EventEmitter),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this.register(new n.EventEmitter),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this.register(new n.EventEmitter),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this.register(new n.EventEmitter),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this.register(new n.EventEmitter),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this.register(new n.EventEmitter),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this.register(new n.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this.register(new n.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onScroll=this.register(new n.EventEmitter),this.onScroll=this._onScroll.event,this._onTitleChange=this.register(new n.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onColor=this.register(new n.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 y.OscHandler(P=>(this.setTitle(P),this.setIconName(P),!0))),this._parser.registerOscHandler(1,new y.OscHandler(P=>this.setIconName(P))),this._parser.registerOscHandler(2,new y.OscHandler(P=>this.setTitle(P))),this._parser.registerOscHandler(4,new y.OscHandler(P=>this.setOrReportIndexedColor(P))),this._parser.registerOscHandler(8,new y.OscHandler(P=>this.setHyperlink(P))),this._parser.registerOscHandler(10,new y.OscHandler(P=>this.setOrReportFgColor(P))),this._parser.registerOscHandler(11,new y.OscHandler(P=>this.setOrReportBgColor(P))),this._parser.registerOscHandler(12,new y.OscHandler(P=>this.setOrReportCursorColor(P))),this._parser.registerOscHandler(104,new y.OscHandler(P=>this.restoreIndexedColor(P))),this._parser.registerOscHandler(110,new y.OscHandler(P=>this.restoreFgColor(P))),this._parser.registerOscHandler(111,new y.OscHandler(P=>this.restoreBgColor(P))),this._parser.registerOscHandler(112,new y.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 f.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 A.DcsHandler((P,U)=>this.requestStatusString(P,U)))}_preserveStack(I,M,R,O){this._parseStack.paused=!0,this._parseStack.cursorStartX=I,this._parseStack.cursorStartY=M,this._parseStack.decodedLength=R,this._parseStack.position=O}_logSlowResolvingAsync(I){this._logService.logLevel<=b.LogLevelEnum.WARN&&Promise.race([I,new Promise((M,R)=>setTimeout(()=>R("#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(I,M){let R,O=this._activeBuffer.x,q=this._activeBuffer.y,V=0;const J=this._parseStack.paused;if(J){if(R=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,M))return this._logSlowResolvingAsync(R),R;O=this._parseStack.cursorStartX,q=this._parseStack.cursorStartY,this._parseStack.paused=!1,I.length>D&&(V=this._parseStack.position+D)}if(this._logService.logLevel<=b.LogLevelEnum.DEBUG&&this._logService.debug("parsing data"+(typeof I=="string"?` "${I}"`:` "${Array.prototype.map.call(I,X=>String.fromCharCode(X)).join("")}"`),typeof I=="string"?I.split("").map(X=>X.charCodeAt(0)):I),this._parseBuffer.length<I.length&&this._parseBuffer.length<D&&(this._parseBuffer=new Uint32Array(Math.min(I.length,D))),J||this._dirtyRowTracker.clearRange(),I.length>D)for(let X=V;X<I.length;X+=D){const ce=X+D<I.length?X+D:I.length,P=typeof I=="string"?this._stringDecoder.decode(I.substring(X,ce),this._parseBuffer):this._utf8Decoder.decode(I.subarray(X,ce),this._parseBuffer);if(R=this._parser.parse(this._parseBuffer,P))return this._preserveStack(O,q,P,X),this._logSlowResolvingAsync(R),R}else if(!J){const X=typeof I=="string"?this._stringDecoder.decode(I,this._parseBuffer):this._utf8Decoder.decode(I,this._parseBuffer);if(R=this._parser.parse(this._parseBuffer,X))return this._preserveStack(O,q,X,0),this._logSlowResolvingAsync(R),R}this._activeBuffer.x===O&&this._activeBuffer.y===q||this._onCursorMove.fire(),this._onRequestRefreshRows.fire(this._dirtyRowTracker.start,this._dirtyRowTracker.end)}print(I,M,R){let O,q;const V=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&&R-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<R;++K){if(O=I[K],q=this._unicodeService.wcwidth(O),O<127&&V){const ie=V[String.fromCharCode(O)];ie&&(O=ie.charCodeAt(0))}if(J&&this._onA11yChar.fire((0,m.stringFromCodePoint)(O)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),q||!this._activeBuffer.x){if(this._activeBuffer.x+q-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,q===2)continue}if(P&&(G.insertCells(this._activeBuffer.x,q,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++,O,q,U.fg,U.bg,U.extended),q>0)for(;--q;)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,O):G.addCodepointToCell(this._activeBuffer.x-2,O)}R-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&&R-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(I,M){return I.final!=="t"||I.prefix||I.intermediates?this._parser.registerCsiHandler(I,M):this._parser.registerCsiHandler(I,R=>!T(R.params[0],this._optionsService.rawOptions.windowOptions)||M(R))}registerDcsHandler(I,M){return this._parser.registerDcsHandler(I,new A.DcsHandler(M))}registerEscHandler(I,M){return this._parser.registerEscHandler(I,M)}registerOscHandler(I,M){return this._parser.registerOscHandler(I,new y.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 I;if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&(!((I=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))===null||I===void 0)&&I.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 I=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-I),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(I=this._bufferService.cols-1){this._activeBuffer.x=Math.min(I,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(I,M){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=I,this._activeBuffer.y=this._activeBuffer.scrollTop+M):(this._activeBuffer.x=I,this._activeBuffer.y=M),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(I,M){this._restrictCursor(),this._setCursor(this._activeBuffer.x+I,this._activeBuffer.y+M)}cursorUp(I){const M=this._activeBuffer.y-this._activeBuffer.scrollTop;return M>=0?this._moveCursor(0,-Math.min(M,I.params[0]||1)):this._moveCursor(0,-(I.params[0]||1)),!0}cursorDown(I){const M=this._activeBuffer.scrollBottom-this._activeBuffer.y;return M>=0?this._moveCursor(0,Math.min(M,I.params[0]||1)):this._moveCursor(0,I.params[0]||1),!0}cursorForward(I){return this._moveCursor(I.params[0]||1,0),!0}cursorBackward(I){return this._moveCursor(-(I.params[0]||1),0),!0}cursorNextLine(I){return this.cursorDown(I),this._activeBuffer.x=0,!0}cursorPrecedingLine(I){return this.cursorUp(I),this._activeBuffer.x=0,!0}cursorCharAbsolute(I){return this._setCursor((I.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(I){return this._setCursor(I.length>=2?(I.params[1]||1)-1:0,(I.params[0]||1)-1),!0}charPosAbsolute(I){return this._setCursor((I.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(I){return this._moveCursor(I.params[0]||1,0),!0}linePosAbsolute(I){return this._setCursor(this._activeBuffer.x,(I.params[0]||1)-1),!0}vPositionRelative(I){return this._moveCursor(0,I.params[0]||1),!0}hVPosition(I){return this.cursorPosition(I),!0}tabClear(I){const M=I.params[0];return M===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:M===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(I){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let M=I.params[0]||1;for(;M--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(I){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let M=I.params[0]||1;for(;M--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(I){const M=I.params[0];return M===1&&(this._curAttrData.bg|=536870912),M!==2&&M!==0||(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(I,M,R,O=!1,q=!1){const V=this._activeBuffer.lines.get(this._activeBuffer.ybase+I);V.replaceCells(M,R,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData(),q),O&&(V.isWrapped=!1)}_resetBufferLine(I,M=!1){const R=this._activeBuffer.lines.get(this._activeBuffer.ybase+I);R&&(R.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),M),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+I),R.isWrapped=!1)}eraseInDisplay(I,M=!1){let R;switch(this._restrictCursor(this._bufferService.cols),I.params[0]){case 0:for(R=this._activeBuffer.y,this._dirtyRowTracker.markDirty(R),this._eraseInBufferLine(R++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,M);R<this._bufferService.rows;R++)this._resetBufferLine(R,M);this._dirtyRowTracker.markDirty(R);break;case 1:for(R=this._activeBuffer.y,this._dirtyRowTracker.markDirty(R),this._eraseInBufferLine(R,0,this._activeBuffer.x+1,!0,M),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(R+1).isWrapped=!1);R--;)this._resetBufferLine(R,M);this._dirtyRowTracker.markDirty(0);break;case 2:for(R=this._bufferService.rows,this._dirtyRowTracker.markDirty(R-1);R--;)this._resetBufferLine(R,M);this._dirtyRowTracker.markDirty(0);break;case 3:const O=this._activeBuffer.lines.length-this._bufferService.rows;O>0&&(this._activeBuffer.lines.trimStart(O),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-O,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-O,0),this._onScroll.fire(0))}return!0}eraseInLine(I,M=!1){switch(this._restrictCursor(this._bufferService.cols),I.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,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(I){this._restrictCursor();let M=I.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const R=this._activeBuffer.ybase+this._activeBuffer.y,O=this._bufferService.rows-1-this._activeBuffer.scrollBottom,q=this._bufferService.rows-1+this._activeBuffer.ybase-O+1;for(;M--;)this._activeBuffer.lines.splice(q-1,1),this._activeBuffer.lines.splice(R,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(I){this._restrictCursor();let M=I.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const R=this._activeBuffer.ybase+this._activeBuffer.y;let O;for(O=this._bufferService.rows-1-this._activeBuffer.scrollBottom,O=this._bufferService.rows-1+this._activeBuffer.ybase-O;M--;)this._activeBuffer.lines.splice(R,1),this._activeBuffer.lines.splice(O,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(I){this._restrictCursor();const M=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return M&&(M.insertCells(this._activeBuffer.x,I.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(I){this._restrictCursor();const M=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return M&&(M.deleteCells(this._activeBuffer.x,I.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(I){let M=I.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(I){let M=I.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(s.DEFAULT_ATTR_DATA));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(I){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const M=I.params[0]||1;for(let R=this._activeBuffer.scrollTop;R<=this._activeBuffer.scrollBottom;++R){const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+R);O.deleteCells(0,M,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),O.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(I){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const M=I.params[0]||1;for(let R=this._activeBuffer.scrollTop;R<=this._activeBuffer.scrollBottom;++R){const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+R);O.insertCells(0,M,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),O.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(I){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const M=I.params[0]||1;for(let R=this._activeBuffer.scrollTop;R<=this._activeBuffer.scrollBottom;++R){const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+R);O.insertCells(this._activeBuffer.x,M,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),O.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(I){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const M=I.params[0]||1;for(let R=this._activeBuffer.scrollTop;R<=this._activeBuffer.scrollBottom;++R){const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+R);O.deleteCells(this._activeBuffer.x,M,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),O.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(I){this._restrictCursor();const M=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return M&&(M.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(I.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(I){if(!this._parser.precedingCodepoint)return!0;const M=I.params[0]||1,R=new Uint32Array(M);for(let O=0;O<M;++O)R[O]=this._parser.precedingCodepoint;return this.print(R,0,R.length),!0}sendDeviceAttributesPrimary(I){return I.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(I){return I.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(I.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(l.C0.ESC+"[>83;40003;0c")),!0}_is(I){return(this._optionsService.rawOptions.termName+"").indexOf(I)===0}setMode(I){for(let M=0;M<I.length;M++)switch(I.params[M]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0}return!0}setModePrivate(I){for(let M=0;M<I.length;M++)switch(I.params[M]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,f.DEFAULT_CHARSET),this._charsetService.setgCharset(1,f.DEFAULT_CHARSET),this._charsetService.setgCharset(2,f.DEFAULT_CHARSET),this._charsetService.setgCharset(3,f.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(I){for(let M=0;M<I.length;M++)switch(I.params[M]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1}return!0}resetModePrivate(I){for(let M=0;M<I.length;M++)switch(I.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(),I.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(I,M){const R=this._coreService.decPrivateModes,{activeProtocol:O,activeEncoding:q}=this._coreMouseService,V=this._coreService,{buffers:J,cols:X}=this._bufferService,{active:ce,alt:P}=J,U=this._optionsService.rawOptions,G=oe=>oe?1:2,K=I.params[0];return ie=K,Q=M?K===2?4:K===4?G(V.modes.insertMode):K===12?3:K===20?G(U.convertEol):0:K===1?G(R.applicationCursorKeys):K===3?U.windowOptions.setWinLines?X===80?2:X===132?1:0:0:K===6?G(R.origin):K===7?G(R.wraparound):K===8?3:K===9?G(O==="X10"):K===12?G(U.cursorBlink):K===25?G(!V.isCursorHidden):K===45?G(R.reverseWraparound):K===66?G(R.applicationKeypad):K===67?4:K===1e3?G(O==="VT200"):K===1002?G(O==="DRAG"):K===1003?G(O==="ANY"):K===1004?G(R.sendFocus):K===1005?4:K===1006?G(q==="SGR"):K===1015?4:K===1016?G(q==="SGR_PIXELS"):K===1048?1:K===47||K===1047||K===1049?G(ce===P):K===2004?G(R.bracketedPasteMode):0,V.triggerDataEvent(`${l.C0.ESC}[${M?"":"?"}${ie};${Q}$y`),!0;var ie,Q}_updateAttrColor(I,M,R,O,q){return M===2?(I|=50331648,I&=-16777216,I|=d.AttributeData.fromColorRGB([R,O,q])):M===5&&(I&=-50331904,I|=33554432|255&R),I}_extractColor(I,M,R){const O=[0,0,-1,0,0,0];let q=0,V=0;do{if(O[V+q]=I.params[M+V],I.hasSubParams(M+V)){const J=I.getSubParams(M+V);let X=0;do O[1]===5&&(q=1),O[V+X+1+q]=J[X];while(++X<J.length&&X+V+1+q<O.length);break}if(O[1]===5&&V+q>=2||O[1]===2&&V+q>=5)break;O[1]&&(q=1)}while(++V+M<I.length&&V+q<O.length);for(let J=2;J<O.length;++J)O[J]===-1&&(O[J]=0);switch(O[0]){case 38:R.fg=this._updateAttrColor(R.fg,O[1],O[3],O[4],O[5]);break;case 48:R.bg=this._updateAttrColor(R.bg,O[1],O[3],O[4],O[5]);break;case 58:R.extended=R.extended.clone(),R.extended.underlineColor=this._updateAttrColor(R.extended.underlineColor,O[1],O[3],O[4],O[5])}return V}_processUnderline(I,M){M.extended=M.extended.clone(),(!~I||I>5)&&(I=1),M.extended.underlineStyle=I,M.fg|=268435456,I===0&&(M.fg&=-268435457),M.updateExtended()}_processSGR0(I){I.fg=s.DEFAULT_ATTR_DATA.fg,I.bg=s.DEFAULT_ATTR_DATA.bg,I.extended=I.extended.clone(),I.extended.underlineStyle=0,I.extended.underlineColor&=-67108864,I.updateExtended()}charAttributes(I){if(I.length===1&&I.params[0]===0)return this._processSGR0(this._curAttrData),!0;const M=I.length;let R;const O=this._curAttrData;for(let q=0;q<M;q++)R=I.params[q],R>=30&&R<=37?(O.fg&=-50331904,O.fg|=16777216|R-30):R>=40&&R<=47?(O.bg&=-50331904,O.bg|=16777216|R-40):R>=90&&R<=97?(O.fg&=-50331904,O.fg|=16777224|R-90):R>=100&&R<=107?(O.bg&=-50331904,O.bg|=16777224|R-100):R===0?this._processSGR0(O):R===1?O.fg|=134217728:R===3?O.bg|=67108864:R===4?(O.fg|=268435456,this._processUnderline(I.hasSubParams(q)?I.getSubParams(q)[0]:1,O)):R===5?O.fg|=536870912:R===7?O.fg|=67108864:R===8?O.fg|=1073741824:R===9?O.fg|=2147483648:R===2?O.bg|=134217728:R===21?this._processUnderline(2,O):R===22?(O.fg&=-134217729,O.bg&=-134217729):R===23?O.bg&=-67108865:R===24?(O.fg&=-268435457,this._processUnderline(0,O)):R===25?O.fg&=-536870913:R===27?O.fg&=-67108865:R===28?O.fg&=-1073741825:R===29?O.fg&=2147483647:R===39?(O.fg&=-67108864,O.fg|=16777215&s.DEFAULT_ATTR_DATA.fg):R===49?(O.bg&=-67108864,O.bg|=16777215&s.DEFAULT_ATTR_DATA.bg):R===38||R===48||R===58?q+=this._extractColor(I,q,O):R===53?O.bg|=1073741824:R===55?O.bg&=-1073741825:R===59?(O.extended=O.extended.clone(),O.extended.underlineColor=-1,O.updateExtended()):R===100?(O.fg&=-67108864,O.fg|=16777215&s.DEFAULT_ATTR_DATA.fg,O.bg&=-67108864,O.bg|=16777215&s.DEFAULT_ATTR_DATA.bg):this._logService.debug("Unknown SGR attribute: %d.",R);return!0}deviceStatus(I){switch(I.params[0]){case 5:this._coreService.triggerDataEvent(`${l.C0.ESC}[0n`);break;case 6:const M=this._activeBuffer.y+1,R=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${l.C0.ESC}[${M};${R}R`)}return!0}deviceStatusPrivate(I){if(I.params[0]===6){const M=this._activeBuffer.y+1,R=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${l.C0.ESC}[?${M};${R}R`)}return!0}softReset(I){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=s.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(I){const M=I.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 R=M%2==1;return this._optionsService.options.cursorBlink=R,!0}setScrollRegion(I){const M=I.params[0]||1;let R;return(I.length<2||(R=I.params[1])>this._bufferService.rows||R===0)&&(R=this._bufferService.rows),R>M&&(this._activeBuffer.scrollTop=M-1,this._activeBuffer.scrollBottom=R-1,this._setCursor(0,0)),!0}windowOptions(I){if(!T(I.params[0],this._optionsService.rawOptions.windowOptions))return!0;const M=I.length>1?I.params[1]:0;switch(I.params[0]){case 14:M!==2&&this._onRequestWindowsOptionsReport.fire(L.GET_WIN_SIZE_PIXELS);break;case 16:this._onRequestWindowsOptionsReport.fire(L.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(I){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(I){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(I){return this._windowTitle=I,this._onTitleChange.fire(I),!0}setIconName(I){return this._iconName=I,!0}setOrReportIndexedColor(I){const M=[],R=I.split(";");for(;R.length>1;){const O=R.shift(),q=R.shift();if(/^\d+$/.exec(O)){const V=parseInt(O);if($(V))if(q==="?")M.push({type:0,index:V});else{const J=(0,v.parseColor)(q);J&&M.push({type:1,index:V,color:J})}}}return M.length&&this._onColor.fire(M),!0}setHyperlink(I){const M=I.split(";");return!(M.length<2)&&(M[1]?this._createHyperlink(M[0],M[1]):!M[0]&&this._finishHyperlink())}_createHyperlink(I,M){this._getCurrentLinkId()&&this._finishHyperlink();const R=I.split(":");let O;const q=R.findIndex(V=>V.startsWith("id="));return q!==-1&&(O=R[q].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:O,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(I,M){const R=I.split(";");for(let O=0;O<R.length&&!(M>=this._specialColors.length);++O,++M)if(R[O]==="?")this._onColor.fire([{type:0,index:this._specialColors[M]}]);else{const q=(0,v.parseColor)(R[O]);q&&this._onColor.fire([{type:1,index:this._specialColors[M],color:q}])}return!0}setOrReportFgColor(I){return this._setOrReportSpecialColor(I,0)}setOrReportBgColor(I){return this._setOrReportSpecialColor(I,1)}setOrReportCursorColor(I){return this._setOrReportSpecialColor(I,2)}restoreIndexedColor(I){if(!I)return this._onColor.fire([{type:2}]),!0;const M=[],R=I.split(";");for(let O=0;O<R.length;++O)if(/^\d+$/.exec(R[O])){const q=parseInt(R[O]);$(q)&&M.push({type:2,index:q})}return M.length&&this._onColor.fire(M),!0}restoreFgColor(I){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(I){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(I){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,f.DEFAULT_CHARSET),!0}selectCharset(I){return I.length!==2?(this.selectDefaultCharset(),!0):(I[0]==="/"||this._charsetService.setgCharset(x[I[0]],f.CHARSETS[I[1]]||f.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 I=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,I,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=s.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=s.DEFAULT_ATTR_DATA.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=67108863&this._curAttrData.bg,this._eraseAttrDataInternal}setgLevel(I){return this._charsetService.setgLevel(I),!0}screenAlignmentPattern(){const I=new h.CellData;I.content=4194373,I.fg=this._curAttrData.fg,I.bg=this._curAttrData.bg,this._setCursor(0,0);for(let M=0;M<this._bufferService.rows;++M){const R=this._activeBuffer.ybase+this._activeBuffer.y+M,O=this._activeBuffer.lines.get(R);O&&(O.fill(I),O.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(I,M){const R=this._bufferService.buffer,O=this._optionsService.rawOptions;return(q=>(this._coreService.triggerDataEvent(`${l.C0.ESC}${q}${l.C0.ESC}\\`),!0))(I==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:I==='"p'?'P1$r61;1"p':I==="r"?`P1$r${R.scrollTop+1};${R.scrollBottom+1}r`:I==="m"?"P1$r0m":I===" q"?`P1$r${{block:2,underline:4,bar:6}[O.cursorStyle]-(O.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(I,M){this._dirtyRowTracker.markRangeDirty(I,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,I){z>I&&(B=z,z=I,I=B),z<this.start&&(this.start=z),I>this.end&&(this.end=I)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};function $(z){return 0<=z&&z<256}Y=u([_(0,b.IBufferService)],Y)},844:(E,r)=>{function o(u){for(const _ of u)_.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 _=this._disposables.indexOf(u);_!==-1&&this._disposables.splice(_,1)}},r.MutableDisposable=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(u){var _;this._isDisposed||u===this._value||((_=this._value)===null||_===void 0||_.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=o,r.getDisposeArrayDisposable=function(u){return{dispose:()=>o(u)}}},1505:(E,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.FourKeyMap=r.TwoKeyMap=void 0;class o{constructor(){this._data={}}set(_,l,f){this._data[_]||(this._data[_]={}),this._data[_][l]=f}get(_,l){return this._data[_]?this._data[_][l]:void 0}clear(){this._data={}}}r.TwoKeyMap=o,r.FourKeyMap=class{constructor(){this._data=new o}set(u,_,l,f,C){this._data.get(u,_)||this._data.set(u,_,new o),this._data.get(u,_).set(l,f,C)}get(u,_,l,f){var C;return(C=this._data.get(u,_))===null||C===void 0?void 0:C.get(l,f)}clear(){this._data.clear()}}},6114:(E,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 o=r.isNode?"node":navigator.userAgent,u=r.isNode?"node":navigator.platform;r.isFirefox=o.includes("Firefox"),r.isLegacyEdge=o.includes("Edge"),r.isSafari=/^((?!chrome|android).)*safari/i.test(o),r.getSafariVersion=function(){if(!r.isSafari)return 0;const _=o.match(/Version\/(\d+)/);return _===null||_.length<2?0:parseInt(_[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(o)},6106:(E,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.SortedList=void 0;let o=0;r.SortedList=class{constructor(u){this._getKey=u,this._array=[]}clear(){this._array.length=0}insert(u){this._array.length!==0?(o=this._search(this._getKey(u)),this._array.splice(o,0,u)):this._array.push(u)}delete(u){if(this._array.length===0)return!1;const _=this._getKey(u);if(_===void 0||(o=this._search(_),o===-1)||this._getKey(this._array[o])!==_)return!1;do if(this._array[o]===u)return this._array.splice(o,1),!0;while(++o<this._array.length&&this._getKey(this._array[o])===_);return!1}*getKeyIterator(u){if(this._array.length!==0&&(o=this._search(u),!(o<0||o>=this._array.length)&&this._getKey(this._array[o])===u))do yield this._array[o];while(++o<this._array.length&&this._getKey(this._array[o])===u)}forEachByKey(u,_){if(this._array.length!==0&&(o=this._search(u),!(o<0||o>=this._array.length)&&this._getKey(this._array[o])===u))do _(this._array[o]);while(++o<this._array.length&&this._getKey(this._array[o])===u)}values(){return[...this._array].values()}_search(u){let _=0,l=this._array.length-1;for(;l>=_;){let f=_+l>>1;const C=this._getKey(this._array[f]);if(C>u)l=f-1;else{if(!(C<u)){for(;f>0&&this._getKey(this._array[f-1])===u;)f--;return f}_=f+1}}return _}}},7226:(E,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.DebouncedIdleTask=r.IdleTaskQueue=r.PriorityTaskQueue=void 0;const u=o(6114);class _{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,m=0,s=C.timeRemaining(),n=0;for(;this._i<this._tasks.length;){if(S=Date.now(),this._tasks[this._i]()||this._i++,S=Math.max(1,Date.now()-S),m=Math.max(S,m),n=C.timeRemaining(),1.5*m>n)return s-S<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(s-S))}ms`),void this._start();s=n}this.clear()}}class l extends _{_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 _{_requestCallback(f){return requestIdleCallback(f)}_cancelCallback(f){cancelIdleCallback(f)}}:l,r.DebouncedIdleTask=class{constructor(){this._queue=new r.IdleTaskQueue}set(f){this._queue.clear(),this._queue.enqueue(f)}flush(){this._queue.flush()}}},9282:(E,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.updateWindowsModeWrappedState=void 0;const u=o(643);r.updateWindowsModeWrappedState=function(_){const l=_.buffer.lines.get(_.buffer.ybase+_.buffer.y-1),f=l==null?void 0:l.get(_.cols-1),C=_.buffer.lines.get(_.buffer.ybase+_.buffer.y);C&&f&&(C.isWrapped=f[u.CHAR_DATA_CODE_INDEX]!==u.NULL_CELL_CODE&&f[u.CHAR_DATA_CODE_INDEX]!==u.WHITESPACE_CELL_CODE)}},3734:(E,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.ExtendedAttrs=r.AttributeData=void 0;class o{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 o;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=o;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,f=0){this._ext=0,this._urlId=0,this._ext=l,this._urlId=f}clone(){return new u(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}}r.ExtendedAttrs=u},9092:(E,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.Buffer=r.MAX_BUFFER_SIZE=void 0;const u=o(6349),_=o(7226),l=o(3734),f=o(8437),C=o(4634),S=o(511),m=o(643),s=o(4863),n=o(7116);r.MAX_BUFFER_SIZE=4294967295,r.Buffer=class{constructor(c,h,d){this._hasScrollback=c,this._optionsService=h,this._bufferService=d,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=f.DEFAULT_ATTR_DATA.clone(),this.savedCharset=n.DEFAULT_CHARSET,this.markers=[],this._nullCell=S.CellData.fromCharData([0,m.NULL_CELL_CHAR,m.NULL_CELL_WIDTH,m.NULL_CELL_CODE]),this._whitespaceCell=S.CellData.fromCharData([0,m.WHITESPACE_CELL_CHAR,m.WHITESPACE_CELL_WIDTH,m.WHITESPACE_CELL_CODE]),this._isClearing=!1,this._memoryCleanupQueue=new _.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 f.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=f.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 d=this.getNullCell(f.DEFAULT_ATTR_DATA);let b=0;const y=this._getCorrectBufferLength(h);if(y>this.lines.maxLength&&(this.lines.maxLength=y),this.lines.length>0){if(this._cols<c)for(let v=0;v<this.lines.length;v++)b+=+this.lines.get(v).resize(c,d);let A=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 f.BufferLine(c,d)):this.ybase>0&&this.lines.length<=this.ybase+this.y+A+1?(this.ybase--,A++,this.ydisp>0&&this.ydisp--):this.lines.push(new f.BufferLine(c,d)));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(y<this.lines.maxLength){const v=this.lines.length-y;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=y}this.x=Math.min(this.x,c-1),this.y=Math.min(this.y,h-1),A&&(this.y+=A),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 A=0;A<this.lines.length;A++)b+=+this.lines.get(A).resize(c,d);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 d=(0,C.reflowLargerGetLinesToRemove)(this.lines,this._cols,c,this.ybase+this.y,this.getNullCell(f.DEFAULT_ATTR_DATA));if(d.length>0){const b=(0,C.reflowLargerCreateNewLayout)(this.lines,d);(0,C.reflowLargerApplyNewLayout)(this.lines,b.layout),this._reflowLargerAdjustViewport(c,h,b.countRemoved)}}_reflowLargerAdjustViewport(c,h,d){const b=this.getNullCell(f.DEFAULT_ATTR_DATA);let y=d;for(;y-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<h&&this.lines.push(new f.BufferLine(c,b))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-d,0)}_reflowSmaller(c,h){const d=this.getNullCell(f.DEFAULT_ATTR_DATA),b=[];let y=0;for(let A=this.lines.length-1;A>=0;A--){let v=this.lines.get(A);if(!v||!v.isWrapped&&v.getTrimmedLength()<=c)continue;const x=[v];for(;v.isWrapped&&A>0;)v=this.lines.get(--A),x.unshift(v);const D=this.ybase+this.y;if(D>=A&&D<A+x.length)continue;const T=x[x.length-1].getTrimmedLength(),L=(0,C.reflowSmallerGetNewLineLengths)(x,this._cols,c),B=L.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 O=0;O<B;O++){const q=this.getBlankLine(f.DEFAULT_ATTR_DATA,!0);Y.push(q)}Y.length>0&&(b.push({start:A+x.length+y,newLines:Y}),y+=Y.length),x.push(...Y);let $=L.length-1,z=L[$];z===0&&($--,z=L[$]);let I=x.length-B-1,M=T;for(;I>=0;){const O=Math.min(M,z);if(x[$]===void 0)break;if(x[$].copyCellsFrom(x[I],M-O,z-O,O,!0),z-=O,z===0&&($--,z=L[$]),M-=O,M===0){I--;const q=Math.max(I,0);M=(0,C.getWrappedLineTrimmedLength)(x,q,this._cols)}}for(let O=0;O<x.length;O++)L[O]<c&&x[O].setCell(L[O],d);let R=B-F;for(;R-- >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+y)-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 A=[],v=[];for(let $=0;$<this.lines.length;$++)v.push(this.lines.get($));const x=this.lines.length;let D=x-1,T=0,L=b[T];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+y);let B=0;for(let $=Math.min(this.lines.maxLength-1,x+y-1);$>=0;$--)if(L&&L.start>D+B){for(let z=L.newLines.length-1;z>=0;z--)this.lines.set($--,L.newLines[z]);$++,A.push({index:D+1,amount:L.newLines.length}),B+=L.newLines.length,L=b[++T]}else this.lines.set($,v[D--]);let F=0;for(let $=A.length-1;$>=0;$--)A[$].index+=F,this.lines.onInsertEmitter.fire(A[$]),F+=A[$].amount;const Y=Math.max(0,x+y-this.lines.maxLength);Y>0&&this.lines.onTrimEmitter.fire(Y)}}translateBufferLineToString(c,h,d=0,b){const y=this.lines.get(c);return y?y.translateToString(h,d,b):""}getWrappedRangeForLine(c){let h=c,d=c;for(;h>0&&this.lines.get(h).isWrapped;)h--;for(;d+1<this.lines.length&&this.lines.get(d+1).isWrapped;)d++;return{first:h,last:d}}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 s.Marker(c);return this.markers.push(h),h.register(this.lines.onTrim(d=>{h.line-=d,h.line<0&&h.dispose()})),h.register(this.lines.onInsert(d=>{h.line>=d.index&&(h.line+=d.amount)})),h.register(this.lines.onDelete(d=>{h.line>=d.index&&h.line<d.index+d.amount&&h.dispose(),h.line>d.index&&(h.line-=d.amount)})),h.register(h.onDispose(()=>this._removeMarker(h))),h}_removeMarker(c){this._isClearing||this.markers.splice(this.markers.indexOf(c),1)}}},8437:(E,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.BufferLine=r.DEFAULT_ATTR_DATA=void 0;const u=o(3734),_=o(511),l=o(643),f=o(482);r.DEFAULT_ATTR_DATA=Object.freeze(new u.AttributeData);let C=0;class S{constructor(s,n,c=!1){this.isWrapped=c,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(3*s);const h=n||_.CellData.fromCharData([0,l.NULL_CELL_CHAR,l.NULL_CELL_WIDTH,l.NULL_CELL_CODE]);for(let d=0;d<s;++d)this.setCell(d,h);this.length=s}get(s){const n=this._data[3*s+0],c=2097151&n;return[this._data[3*s+1],2097152&n?this._combined[s]:c?(0,f.stringFromCodePoint)(c):"",n>>22,2097152&n?this._combined[s].charCodeAt(this._combined[s].length-1):c]}set(s,n){this._data[3*s+1]=n[l.CHAR_DATA_ATTR_INDEX],n[l.CHAR_DATA_CHAR_INDEX].length>1?(this._combined[s]=n[1],this._data[3*s+0]=2097152|s|n[l.CHAR_DATA_WIDTH_INDEX]<<22):this._data[3*s+0]=n[l.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|n[l.CHAR_DATA_WIDTH_INDEX]<<22}getWidth(s){return this._data[3*s+0]>>22}hasWidth(s){return 12582912&this._data[3*s+0]}getFg(s){return this._data[3*s+1]}getBg(s){return this._data[3*s+2]}hasContent(s){return 4194303&this._data[3*s+0]}getCodePoint(s){const n=this._data[3*s+0];return 2097152&n?this._combined[s].charCodeAt(this._combined[s].length-1):2097151&n}isCombined(s){return 2097152&this._data[3*s+0]}getString(s){const n=this._data[3*s+0];return 2097152&n?this._combined[s]:2097151&n?(0,f.stringFromCodePoint)(2097151&n):""}isProtected(s){return 536870912&this._data[3*s+2]}loadCell(s,n){return C=3*s,n.content=this._data[C+0],n.fg=this._data[C+1],n.bg=this._data[C+2],2097152&n.content&&(n.combinedData=this._combined[s]),268435456&n.bg&&(n.extended=this._extendedAttrs[s]),n}setCell(s,n){2097152&n.content&&(this._combined[s]=n.combinedData),268435456&n.bg&&(this._extendedAttrs[s]=n.extended),this._data[3*s+0]=n.content,this._data[3*s+1]=n.fg,this._data[3*s+2]=n.bg}setCellFromCodePoint(s,n,c,h,d,b){268435456&d&&(this._extendedAttrs[s]=b),this._data[3*s+0]=n|c<<22,this._data[3*s+1]=h,this._data[3*s+2]=d}addCodepointToCell(s,n){let c=this._data[3*s+0];2097152&c?this._combined[s]+=(0,f.stringFromCodePoint)(n):(2097151&c?(this._combined[s]=(0,f.stringFromCodePoint)(2097151&c)+(0,f.stringFromCodePoint)(n),c&=-2097152,c|=2097152):c=n|4194304,this._data[3*s+0]=c)}insertCells(s,n,c,h){if((s%=this.length)&&this.getWidth(s-1)===2&&this.setCellFromCodePoint(s-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),n<this.length-s){const d=new _.CellData;for(let b=this.length-s-n-1;b>=0;--b)this.setCell(s+n+b,this.loadCell(s+b,d));for(let b=0;b<n;++b)this.setCell(s+b,c)}else for(let d=s;d<this.length;++d)this.setCell(d,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(s,n,c,h){if(s%=this.length,n<this.length-s){const d=new _.CellData;for(let b=0;b<this.length-s-n;++b)this.setCell(s+b,this.loadCell(s+n+b,d));for(let b=this.length-n;b<this.length;++b)this.setCell(b,c)}else for(let d=s;d<this.length;++d)this.setCell(d,c);s&&this.getWidth(s-1)===2&&this.setCellFromCodePoint(s-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(s)!==0||this.hasContent(s)||this.setCellFromCodePoint(s,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(s,n,c,h,d=!1){if(d)for(s&&this.getWidth(s-1)===2&&!this.isProtected(s-1)&&this.setCellFromCodePoint(s-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),n<this.length&&this.getWidth(n-1)===2&&!this.isProtected(n)&&this.setCellFromCodePoint(n,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);s<n&&s<this.length;)this.isProtected(s)||this.setCell(s,c),s++;else for(s&&this.getWidth(s-1)===2&&this.setCellFromCodePoint(s-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),n<this.length&&this.getWidth(n-1)===2&&this.setCellFromCodePoint(n,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);s<n&&s<this.length;)this.setCell(s++,c)}resize(s,n){if(s===this.length)return 4*this._data.length*2<this._data.buffer.byteLength;const c=3*s;if(s>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<s;++h)this.setCell(h,n)}else{this._data=this._data.subarray(0,c);const h=Object.keys(this._combined);for(let b=0;b<h.length;b++){const y=parseInt(h[b],10);y>=s&&delete this._combined[y]}const d=Object.keys(this._extendedAttrs);for(let b=0;b<d.length;b++){const y=parseInt(d[b],10);y>=s&&delete this._extendedAttrs[y]}}return this.length=s,4*c*2<this._data.buffer.byteLength}cleanupMemory(){if(4*this._data.length*2<this._data.buffer.byteLength){const s=new Uint32Array(this._data.length);return s.set(this._data),this._data=s,1}return 0}fill(s,n=!1){if(n)for(let c=0;c<this.length;++c)this.isProtected(c)||this.setCell(c,s);else{this._combined={},this._extendedAttrs={};for(let c=0;c<this.length;++c)this.setCell(c,s)}}copyFrom(s){this.length!==s.length?this._data=new Uint32Array(s._data):this._data.set(s._data),this.length=s.length,this._combined={};for(const n in s._combined)this._combined[n]=s._combined[n];this._extendedAttrs={};for(const n in s._extendedAttrs)this._extendedAttrs[n]=s._extendedAttrs[n];this.isWrapped=s.isWrapped}clone(){const s=new S(0);s._data=new Uint32Array(this._data),s.length=this.length;for(const n in this._combined)s._combined[n]=this._combined[n];for(const n in this._extendedAttrs)s._extendedAttrs[n]=this._extendedAttrs[n];return s.isWrapped=this.isWrapped,s}getTrimmedLength(){for(let s=this.length-1;s>=0;--s)if(4194303&this._data[3*s+0])return s+(this._data[3*s+0]>>22);return 0}getNoBgTrimmedLength(){for(let s=this.length-1;s>=0;--s)if(4194303&this._data[3*s+0]||50331648&this._data[3*s+2])return s+(this._data[3*s+0]>>22);return 0}copyCellsFrom(s,n,c,h,d){const b=s._data;if(d)for(let A=h-1;A>=0;A--){for(let v=0;v<3;v++)this._data[3*(c+A)+v]=b[3*(n+A)+v];268435456&b[3*(n+A)+2]&&(this._extendedAttrs[c+A]=s._extendedAttrs[n+A])}else for(let A=0;A<h;A++){for(let v=0;v<3;v++)this._data[3*(c+A)+v]=b[3*(n+A)+v];268435456&b[3*(n+A)+2]&&(this._extendedAttrs[c+A]=s._extendedAttrs[n+A])}const y=Object.keys(s._combined);for(let A=0;A<y.length;A++){const v=parseInt(y[A],10);v>=n&&(this._combined[v-n+c]=s._combined[v])}}translateToString(s=!1,n=0,c=this.length){s&&(c=Math.min(c,this.getTrimmedLength()));let h="";for(;n<c;){const d=this._data[3*n+0],b=2097151&d;h+=2097152&d?this._combined[n]:b?(0,f.stringFromCodePoint)(b):l.WHITESPACE_CELL_CHAR,n+=d>>22||1}return h}}r.BufferLine=S},4841:(E,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.getRangeLength=void 0,r.getRangeLength=function(o,u){if(o.start.y>o.end.y)throw new Error(`Buffer range end (${o.end.x}, ${o.end.y}) cannot be before start (${o.start.x}, ${o.start.y})`);return u*(o.end.y-o.start.y)+(o.end.x-o.start.x+1)}},4634:(E,r)=>{function o(u,_,l){if(_===u.length-1)return u[_].getTrimmedLength();const f=!u[_].hasContent(l-1)&&u[_].getWidth(l-1)===1,C=u[_+1].getWidth(0)===2;return f&&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,_,l,f,C){const S=[];for(let m=0;m<u.length-1;m++){let s=m,n=u.get(++s);if(!n.isWrapped)continue;const c=[u.get(m)];for(;s<u.length&&n.isWrapped;)c.push(n),n=u.get(++s);if(f>=m&&f<s){m+=c.length-1;continue}let h=0,d=o(c,h,_),b=1,y=0;for(;b<c.length;){const v=o(c,b,_),x=v-y,D=l-d,T=Math.min(x,D);c[h].copyCellsFrom(c[b],y,d,T,!1),d+=T,d===l&&(h++,d=0),y+=T,y===v&&(b++,y=0),d===0&&h!==0&&c[h-1].getWidth(l-1)===2&&(c[h].copyCellsFrom(c[h-1],l-1,d++,1,!1),c[h-1].setCell(l-1,C))}c[h].replaceCells(d,l,C);let A=0;for(let v=c.length-1;v>0&&(v>h||c[v].getTrimmedLength()===0);v--)A++;A>0&&(S.push(m+c.length-A),S.push(A)),m+=c.length-1}return S},r.reflowLargerCreateNewLayout=function(u,_){const l=[];let f=0,C=_[f],S=0;for(let m=0;m<u.length;m++)if(C===m){const s=_[++f];u.onDeleteEmitter.fire({index:m-S,amount:s}),m+=s-1,S+=s,C=_[++f]}else l.push(m);return{layout:l,countRemoved:S}},r.reflowLargerApplyNewLayout=function(u,_){const l=[];for(let f=0;f<_.length;f++)l.push(u.get(_[f]));for(let f=0;f<l.length;f++)u.set(f,l[f]);u.length=_.length},r.reflowSmallerGetNewLineLengths=function(u,_,l){const f=[],C=u.map((n,c)=>o(u,c,_)).reduce((n,c)=>n+c);let S=0,m=0,s=0;for(;s<C;){if(C-s<l){f.push(C-s);break}S+=l;const n=o(u,m,_);S>n&&(S-=n,m++);const c=u[m].getWidth(S-1)===2;c&&S--;const h=c?l-1:l;f.push(h),s+=h}return f},r.getWrappedLineTrimmedLength=o},5295:(E,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.BufferSet=void 0;const u=o(8460),_=o(844),l=o(9092);class f extends _.Disposable{constructor(S,m){super(),this._optionsService=S,this._bufferService=m,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,m){this._normal.resize(S,m),this._alt.resize(S,m),this.setupTabStops(S)}setupTabStops(S){this._normal.setupTabStops(S),this._alt.setupTabStops(S)}}r.BufferSet=f},511:(E,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.CellData=void 0;const u=o(482),_=o(643),l=o(3734);class f 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 m=new f;return m.setFromCharData(S),m}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[_.CHAR_DATA_ATTR_INDEX],this.bg=0;let m=!1;if(S[_.CHAR_DATA_CHAR_INDEX].length>2)m=!0;else if(S[_.CHAR_DATA_CHAR_INDEX].length===2){const s=S[_.CHAR_DATA_CHAR_INDEX].charCodeAt(0);if(55296<=s&&s<=56319){const n=S[_.CHAR_DATA_CHAR_INDEX].charCodeAt(1);56320<=n&&n<=57343?this.content=1024*(s-55296)+n-56320+65536|S[_.CHAR_DATA_WIDTH_INDEX]<<22:m=!0}else m=!0}else this.content=S[_.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|S[_.CHAR_DATA_WIDTH_INDEX]<<22;m&&(this.combinedData=S[_.CHAR_DATA_CHAR_INDEX],this.content=2097152|S[_.CHAR_DATA_WIDTH_INDEX]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}r.CellData=f},643:(E,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:(E,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.Marker=void 0;const u=o(8460),_=o(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,_.disposeArray)(this._disposables),this._disposables.length=0)}register(C){return this._disposables.push(C),C}}r.Marker=l,l._nextId=1},7116:(E,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:(E,r)=>{var o,u,_;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=""}(o||(r.C0=o={})),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=`${o.ESC}\\`}(_||(r.C1_ESCAPED=_={}))},7399:(E,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.evaluateKeyboardEvent=void 0;const u=o(2584),_={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,f,C,S){const m={type:0,cancel:!1,key:void 0},s=(l.shiftKey?1:0)|(l.altKey?2:0)|(l.ctrlKey?4:0)|(l.metaKey?8:0);switch(l.keyCode){case 0:l.key==="UIKeyInputUpArrow"?m.key=f?u.C0.ESC+"OA":u.C0.ESC+"[A":l.key==="UIKeyInputLeftArrow"?m.key=f?u.C0.ESC+"OD":u.C0.ESC+"[D":l.key==="UIKeyInputRightArrow"?m.key=f?u.C0.ESC+"OC":u.C0.ESC+"[C":l.key==="UIKeyInputDownArrow"&&(m.key=f?u.C0.ESC+"OB":u.C0.ESC+"[B");break;case 8:if(l.altKey){m.key=u.C0.ESC+u.C0.DEL;break}m.key=u.C0.DEL;break;case 9:if(l.shiftKey){m.key=u.C0.ESC+"[Z";break}m.key=u.C0.HT,m.cancel=!0;break;case 13:m.key=l.altKey?u.C0.ESC+u.C0.CR:u.C0.CR,m.cancel=!0;break;case 27:m.key=u.C0.ESC,l.altKey&&(m.key=u.C0.ESC+u.C0.ESC),m.cancel=!0;break;case 37:if(l.metaKey)break;s?(m.key=u.C0.ESC+"[1;"+(s+1)+"D",m.key===u.C0.ESC+"[1;3D"&&(m.key=u.C0.ESC+(C?"b":"[1;5D"))):m.key=f?u.C0.ESC+"OD":u.C0.ESC+"[D";break;case 39:if(l.metaKey)break;s?(m.key=u.C0.ESC+"[1;"+(s+1)+"C",m.key===u.C0.ESC+"[1;3C"&&(m.key=u.C0.ESC+(C?"f":"[1;5C"))):m.key=f?u.C0.ESC+"OC":u.C0.ESC+"[C";break;case 38:if(l.metaKey)break;s?(m.key=u.C0.ESC+"[1;"+(s+1)+"A",C||m.key!==u.C0.ESC+"[1;3A"||(m.key=u.C0.ESC+"[1;5A")):m.key=f?u.C0.ESC+"OA":u.C0.ESC+"[A";break;case 40:if(l.metaKey)break;s?(m.key=u.C0.ESC+"[1;"+(s+1)+"B",C||m.key!==u.C0.ESC+"[1;3B"||(m.key=u.C0.ESC+"[1;5B")):m.key=f?u.C0.ESC+"OB":u.C0.ESC+"[B";break;case 45:l.shiftKey||l.ctrlKey||(m.key=u.C0.ESC+"[2~");break;case 46:m.key=s?u.C0.ESC+"[3;"+(s+1)+"~":u.C0.ESC+"[3~";break;case 36:m.key=s?u.C0.ESC+"[1;"+(s+1)+"H":f?u.C0.ESC+"OH":u.C0.ESC+"[H";break;case 35:m.key=s?u.C0.ESC+"[1;"+(s+1)+"F":f?u.C0.ESC+"OF":u.C0.ESC+"[F";break;case 33:l.shiftKey?m.type=2:l.ctrlKey?m.key=u.C0.ESC+"[5;"+(s+1)+"~":m.key=u.C0.ESC+"[5~";break;case 34:l.shiftKey?m.type=3:l.ctrlKey?m.key=u.C0.ESC+"[6;"+(s+1)+"~":m.key=u.C0.ESC+"[6~";break;case 112:m.key=s?u.C0.ESC+"[1;"+(s+1)+"P":u.C0.ESC+"OP";break;case 113:m.key=s?u.C0.ESC+"[1;"+(s+1)+"Q":u.C0.ESC+"OQ";break;case 114:m.key=s?u.C0.ESC+"[1;"+(s+1)+"R":u.C0.ESC+"OR";break;case 115:m.key=s?u.C0.ESC+"[1;"+(s+1)+"S":u.C0.ESC+"OS";break;case 116:m.key=s?u.C0.ESC+"[15;"+(s+1)+"~":u.C0.ESC+"[15~";break;case 117:m.key=s?u.C0.ESC+"[17;"+(s+1)+"~":u.C0.ESC+"[17~";break;case 118:m.key=s?u.C0.ESC+"[18;"+(s+1)+"~":u.C0.ESC+"[18~";break;case 119:m.key=s?u.C0.ESC+"[19;"+(s+1)+"~":u.C0.ESC+"[19~";break;case 120:m.key=s?u.C0.ESC+"[20;"+(s+1)+"~":u.C0.ESC+"[20~";break;case 121:m.key=s?u.C0.ESC+"[21;"+(s+1)+"~":u.C0.ESC+"[21~";break;case 122:m.key=s?u.C0.ESC+"[23;"+(s+1)+"~":u.C0.ESC+"[23~";break;case 123:m.key=s?u.C0.ESC+"[24;"+(s+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?m.key=l.key:l.key&&l.ctrlKey&&(l.key==="_"&&(m.key=u.C0.US),l.key==="@"&&(m.key=u.C0.NUL)):l.keyCode===65&&(m.type=1);else{const n=_[l.keyCode],c=n==null?void 0:n[l.shiftKey?1:0];if(c)m.key=u.C0.ESC+c;else if(l.keyCode>=65&&l.keyCode<=90){const h=l.ctrlKey?l.keyCode-64:l.keyCode+32;let d=String.fromCharCode(h);l.shiftKey&&(d=d.toUpperCase()),m.key=u.C0.ESC+d}else if(l.keyCode===32)m.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()),m.key=u.C0.ESC+h,m.cancel=!0}}else l.keyCode>=65&&l.keyCode<=90?m.key=String.fromCharCode(l.keyCode-64):l.keyCode===32?m.key=u.C0.NUL:l.keyCode>=51&&l.keyCode<=55?m.key=String.fromCharCode(l.keyCode-51+27):l.keyCode===56?m.key=u.C0.DEL:l.keyCode===219?m.key=u.C0.ESC:l.keyCode===220?m.key=u.C0.FS:l.keyCode===221&&(m.key=u.C0.GS)}return m}},482:(E,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.Utf8ToUtf32=r.StringToUtf32=r.utf32ToString=r.stringFromCodePoint=void 0,r.stringFromCodePoint=function(o){return o>65535?(o-=65536,String.fromCharCode(55296+(o>>10))+String.fromCharCode(o%1024+56320)):String.fromCharCode(o)},r.utf32ToString=function(o,u=0,_=o.length){let l="";for(let f=u;f<_;++f){let C=o[f];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(o,u){const _=o.length;if(!_)return 0;let l=0,f=0;if(this._interim){const C=o.charCodeAt(f++);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=f;C<_;++C){const S=o.charCodeAt(C);if(55296<=S&&S<=56319){if(++C>=_)return this._interim=S,l;const m=o.charCodeAt(C);56320<=m&&m<=57343?u[l++]=1024*(S-55296)+m-56320+65536:(u[l++]=S,u[l++]=m)}else S!==65279&&(u[l++]=S)}return l}},r.Utf8ToUtf32=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(o,u){const _=o.length;if(!_)return 0;let l,f,C,S,m=0,s=0,n=0;if(this.interim[0]){let d=!1,b=this.interim[0];b&=(224&b)==192?31:(240&b)==224?15:7;let y,A=0;for(;(y=63&this.interim[++A])&&A<4;)b<<=6,b|=y;const v=(224&this.interim[0])==192?2:(240&this.interim[0])==224?3:4,x=v-A;for(;n<x;){if(n>=_)return 0;if(y=o[n++],(192&y)!=128){n--,d=!0;break}this.interim[A++]=y,b<<=6,b|=63&y}d||(v===2?b<128?n--:u[m++]=b:v===3?b<2048||b>=55296&&b<=57343||b===65279||(u[m++]=b):b<65536||b>1114111||(u[m++]=b)),this.interim.fill(0)}const c=_-4;let h=n;for(;h<_;){for(;!(!(h<c)||128&(l=o[h])||128&(f=o[h+1])||128&(C=o[h+2])||128&(S=o[h+3]));)u[m++]=l,u[m++]=f,u[m++]=C,u[m++]=S,h+=4;if(l=o[h++],l<128)u[m++]=l;else if((224&l)==192){if(h>=_)return this.interim[0]=l,m;if(f=o[h++],(192&f)!=128){h--;continue}if(s=(31&l)<<6|63&f,s<128){h--;continue}u[m++]=s}else if((240&l)==224){if(h>=_)return this.interim[0]=l,m;if(f=o[h++],(192&f)!=128){h--;continue}if(h>=_)return this.interim[0]=l,this.interim[1]=f,m;if(C=o[h++],(192&C)!=128){h--;continue}if(s=(15&l)<<12|(63&f)<<6|63&C,s<2048||s>=55296&&s<=57343||s===65279)continue;u[m++]=s}else if((248&l)==240){if(h>=_)return this.interim[0]=l,m;if(f=o[h++],(192&f)!=128){h--;continue}if(h>=_)return this.interim[0]=l,this.interim[1]=f,m;if(C=o[h++],(192&C)!=128){h--;continue}if(h>=_)return this.interim[0]=l,this.interim[1]=f,this.interim[2]=C,m;if(S=o[h++],(192&S)!=128){h--;continue}if(s=(7&l)<<18|(63&f)<<12|(63&C)<<6|63&S,s<65536||s>1114111)continue;u[m++]=s}}return m}}},225:(E,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.UnicodeV6=void 0;const o=[[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 _;r.UnicodeV6=class{constructor(){if(this.version="6",!_){_=new Uint8Array(65536),_.fill(1),_[0]=0,_.fill(0,1,32),_.fill(0,127,160),_.fill(2,4352,4448),_[9001]=2,_[9002]=2,_.fill(2,11904,42192),_[12351]=1,_.fill(2,44032,55204),_.fill(2,63744,64256),_.fill(2,65040,65050),_.fill(2,65072,65136),_.fill(2,65280,65377),_.fill(2,65504,65511);for(let l=0;l<o.length;++l)_.fill(0,o[l][0],o[l][1]+1)}}wcwidth(l){return l<32?0:l<127?1:l<65536?_[l]:function(f,C){let S,m=0,s=C.length-1;if(f<C[0][0]||f>C[s][1])return!1;for(;s>=m;)if(S=m+s>>1,f>C[S][1])m=S+1;else{if(!(f<C[S][0]))return!0;s=S-1}return!1}(l,u)?0:l>=131072&&l<=196605||l>=196608&&l<=262141?2:1}}},5981:(E,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.WriteBuffer=void 0;const u=o(8460),_=o(844);class l extends _.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 m;for(this._isSyncWriting=!0;m=this._writeBuffer.shift();){this._action(m);const s=this._callbacks.shift();s&&s()}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 m=C||Date.now();for(;this._writeBuffer.length>this._bufferOffset;){const s=this._writeBuffer[this._bufferOffset],n=this._action(s,S);if(n){const h=d=>Date.now()-m>=12?setTimeout(()=>this._innerWrite(0,d)):this._innerWrite(m,d);return void n.catch(d=>(queueMicrotask(()=>{throw d}),Promise.resolve(!1))).then(h)}const c=this._callbacks[this._bufferOffset];if(c&&c(),this._bufferOffset++,this._pendingData-=s.length,Date.now()-m>=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:(E,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.toRgbString=r.parseColor=void 0;const o=/^([\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 _(l,f){const C=l.toString(16),S=C.length<2?"0"+C:C;switch(f){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 f=l.toLowerCase();if(f.indexOf("rgb:")===0){f=f.slice(4);const C=o.exec(f);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(f.indexOf("#")===0&&(f=f.slice(1),u.exec(f)&&[3,6,9,12].includes(f.length))){const C=f.length/3,S=[0,0,0];for(let m=0;m<3;++m){const s=parseInt(f.slice(C*m,C*m+C),16);S[m]=C===1?s<<4:C===2?s:C===3?s>>4:s>>8}return S}},r.toRgbString=function(l,f=16){const[C,S,m]=l;return`rgb:${_(C,f)}/${_(S,f)}/${_(m,f)}`}},5770:(E,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.PAYLOAD_LIMIT=void 0,r.PAYLOAD_LIMIT=1e7},6351:(E,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.DcsHandler=r.DcsParser=void 0;const u=o(482),_=o(8742),l=o(5770),f=[];r.DcsParser=class{constructor(){this._handlers=Object.create(null),this._active=f,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=f}registerHandler(S,m){this._handlers[S]===void 0&&(this._handlers[S]=[]);const s=this._handlers[S];return s.push(m),{dispose:()=>{const n=s.indexOf(m);n!==-1&&s.splice(n,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=f,this._ident=0}hook(S,m){if(this.reset(),this._ident=S,this._active=this._handlers[S]||f,this._active.length)for(let s=this._active.length-1;s>=0;s--)this._active[s].hook(m);else this._handlerFb(this._ident,"HOOK",m)}put(S,m,s){if(this._active.length)for(let n=this._active.length-1;n>=0;n--)this._active[n].put(S,m,s);else this._handlerFb(this._ident,"PUT",(0,u.utf32ToString)(S,m,s))}unhook(S,m=!0){if(this._active.length){let s=!1,n=this._active.length-1,c=!1;if(this._stack.paused&&(n=this._stack.loopPosition-1,s=m,c=this._stack.fallThrough,this._stack.paused=!1),!c&&s===!1){for(;n>=0&&(s=this._active[n].unhook(S),s!==!0);n--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=n,this._stack.fallThrough=!1,s;n--}for(;n>=0;n--)if(s=this._active[n].unhook(!1),s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=n,this._stack.fallThrough=!0,s}else this._handlerFb(this._ident,"UNHOOK",S);this._active=f,this._ident=0}};const C=new _.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,m,s){this._hitLimit||(this._data+=(0,u.utf32ToString)(S,m,s),this._data.length>l.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}unhook(S){let m=!1;if(this._hitLimit)m=!1;else if(S&&(m=this._handler(this._data,this._params),m instanceof Promise))return m.then(s=>(this._params=C,this._data="",this._hitLimit=!1,s));return this._params=C,this._data="",this._hitLimit=!1,m}}},2015:(E,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.EscapeSequenceParser=r.VT500_TRANSITION_TABLE=r.TransitionTable=void 0;const u=o(844),_=o(8742),l=o(6242),f=o(6351);class C{constructor(n){this.table=new Uint8Array(n)}setDefault(n,c){this.table.fill(n<<4|c)}add(n,c,h,d){this.table[c<<8|n]=h<<4|d}addMany(n,c,h,d){for(let b=0;b<n.length;b++)this.table[c<<8|n[b]]=h<<4|d}}r.TransitionTable=C;const S=160;r.VT500_TRANSITION_TABLE=function(){const s=new C(4095),n=Array.apply(null,Array(256)).map((A,v)=>v),c=(A,v)=>n.slice(A,v),h=c(32,127),d=c(0,24);d.push(25),d.push.apply(d,c(28,32));const b=c(0,14);let y;for(y in s.setDefault(1,0),s.addMany(h,0,2,0),b)s.addMany([24,26,153,154],y,3,0),s.addMany(c(128,144),y,3,0),s.addMany(c(144,152),y,3,0),s.add(156,y,0,0),s.add(27,y,11,1),s.add(157,y,4,8),s.addMany([152,158,159],y,0,7),s.add(155,y,11,3),s.add(144,y,11,9);return s.addMany(d,0,3,0),s.addMany(d,1,3,1),s.add(127,1,0,1),s.addMany(d,8,0,8),s.addMany(d,3,3,3),s.add(127,3,0,3),s.addMany(d,4,3,4),s.add(127,4,0,4),s.addMany(d,6,3,6),s.addMany(d,5,3,5),s.add(127,5,0,5),s.addMany(d,2,3,2),s.add(127,2,0,2),s.add(93,1,4,8),s.addMany(h,8,5,8),s.add(127,8,5,8),s.addMany([156,27,24,26,7],8,6,0),s.addMany(c(28,32),8,0,8),s.addMany([88,94,95],1,0,7),s.addMany(h,7,0,7),s.addMany(d,7,0,7),s.add(156,7,0,0),s.add(127,7,0,7),s.add(91,1,11,3),s.addMany(c(64,127),3,7,0),s.addMany(c(48,60),3,8,4),s.addMany([60,61,62,63],3,9,4),s.addMany(c(48,60),4,8,4),s.addMany(c(64,127),4,7,0),s.addMany([60,61,62,63],4,0,6),s.addMany(c(32,64),6,0,6),s.add(127,6,0,6),s.addMany(c(64,127),6,0,0),s.addMany(c(32,48),3,9,5),s.addMany(c(32,48),5,9,5),s.addMany(c(48,64),5,0,6),s.addMany(c(64,127),5,7,0),s.addMany(c(32,48),4,9,5),s.addMany(c(32,48),1,9,2),s.addMany(c(32,48),2,9,2),s.addMany(c(48,127),2,10,0),s.addMany(c(48,80),1,10,0),s.addMany(c(81,88),1,10,0),s.addMany([89,90,92],1,10,0),s.addMany(c(96,127),1,10,0),s.add(80,1,11,9),s.addMany(d,9,0,9),s.add(127,9,0,9),s.addMany(c(28,32),9,0,9),s.addMany(c(32,48),9,9,12),s.addMany(c(48,60),9,8,10),s.addMany([60,61,62,63],9,9,10),s.addMany(d,11,0,11),s.addMany(c(32,128),11,0,11),s.addMany(c(28,32),11,0,11),s.addMany(d,10,0,10),s.add(127,10,0,10),s.addMany(c(28,32),10,0,10),s.addMany(c(48,60),10,8,10),s.addMany([60,61,62,63],10,0,11),s.addMany(c(32,48),10,9,12),s.addMany(d,12,0,12),s.add(127,12,0,12),s.addMany(c(28,32),12,0,12),s.addMany(c(32,48),12,9,12),s.addMany(c(48,64),12,0,11),s.addMany(c(64,127),12,12,13),s.addMany(c(64,127),10,12,13),s.addMany(c(64,127),9,12,13),s.addMany(d,13,13,13),s.addMany(h,13,13,13),s.add(127,13,0,13),s.addMany([27,156,24,26],13,14,0),s.add(S,0,2,0),s.add(S,8,5,8),s.add(S,6,0,6),s.add(S,11,0,11),s.add(S,13,13,13),s}();class m extends u.Disposable{constructor(n=r.VT500_TRANSITION_TABLE){super(),this._transitions=n,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new _.Params,this._params.addParam(0),this._collect=0,this.precedingCodepoint=0,this._printHandlerFb=(c,h,d)=>{},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 f.DcsParser),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(n,c=[64,126]){let h=0;if(n.prefix){if(n.prefix.length>1)throw new Error("only one byte as prefix supported");if(h=n.prefix.charCodeAt(0),h&&60>h||h>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(n.intermediates){if(n.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let b=0;b<n.intermediates.length;++b){const y=n.intermediates.charCodeAt(b);if(32>y||y>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");h<<=8,h|=y}}if(n.final.length!==1)throw new Error("final must be a single byte");const d=n.final.charCodeAt(0);if(c[0]>d||d>c[1])throw new Error(`final must be in range ${c[0]} .. ${c[1]}`);return h<<=8,h|=d,h}identToString(n){const c=[];for(;n;)c.push(String.fromCharCode(255&n)),n>>=8;return c.reverse().join("")}setPrintHandler(n){this._printHandler=n}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(n,c){const h=this._identifier(n,[48,126]);this._escHandlers[h]===void 0&&(this._escHandlers[h]=[]);const d=this._escHandlers[h];return d.push(c),{dispose:()=>{const b=d.indexOf(c);b!==-1&&d.splice(b,1)}}}clearEscHandler(n){this._escHandlers[this._identifier(n,[48,126])]&&delete this._escHandlers[this._identifier(n,[48,126])]}setEscHandlerFallback(n){this._escHandlerFb=n}setExecuteHandler(n,c){this._executeHandlers[n.charCodeAt(0)]=c}clearExecuteHandler(n){this._executeHandlers[n.charCodeAt(0)]&&delete this._executeHandlers[n.charCodeAt(0)]}setExecuteHandlerFallback(n){this._executeHandlerFb=n}registerCsiHandler(n,c){const h=this._identifier(n);this._csiHandlers[h]===void 0&&(this._csiHandlers[h]=[]);const d=this._csiHandlers[h];return d.push(c),{dispose:()=>{const b=d.indexOf(c);b!==-1&&d.splice(b,1)}}}clearCsiHandler(n){this._csiHandlers[this._identifier(n)]&&delete this._csiHandlers[this._identifier(n)]}setCsiHandlerFallback(n){this._csiHandlerFb=n}registerDcsHandler(n,c){return this._dcsParser.registerHandler(this._identifier(n),c)}clearDcsHandler(n){this._dcsParser.clearHandler(this._identifier(n))}setDcsHandlerFallback(n){this._dcsParser.setHandlerFallback(n)}registerOscHandler(n,c){return this._oscParser.registerHandler(n,c)}clearOscHandler(n){this._oscParser.clearHandler(n)}setOscHandlerFallback(n){this._oscParser.setHandlerFallback(n)}setErrorHandler(n){this._errorHandler=n}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(n,c,h,d,b){this._parseStack.state=n,this._parseStack.handlers=c,this._parseStack.handlerPos=h,this._parseStack.transition=d,this._parseStack.chunkPos=b}parse(n,c,h){let d,b=0,y=0,A=0;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,A=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&&(d=v[x](this._params),d!==!0);x--)if(d instanceof Promise)return this._parseStack.handlerPos=x,d}this._parseStack.handlers=[];break;case 4:if(h===!1&&x>-1){for(;x>=0&&(d=v[x](),d!==!0);x--)if(d instanceof Promise)return this._parseStack.handlerPos=x,d}this._parseStack.handlers=[];break;case 6:if(b=n[this._parseStack.chunkPos],d=this._dcsParser.unhook(b!==24&&b!==26,h),d)return d;b===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(b=n[this._parseStack.chunkPos],d=this._oscParser.end(b!==24&&b!==26,h),d)return d;b===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0}this._parseStack.state=0,A=this._parseStack.chunkPos+1,this.precedingCodepoint=0,this.currentState=15&this._parseStack.transition}for(let v=A;v<c;++v){switch(b=n[v],y=this._transitions.table[this.currentState<<8|(b<160?b:S)],y>>4){case 2:for(let B=v+1;;++B){if(B>=c||(b=n[B])<32||b>126&&b<S){this._printHandler(n,v,B),v=B-1;break}if(++B>=c||(b=n[B])<32||b>126&&b<S){this._printHandler(n,v,B),v=B-1;break}if(++B>=c||(b=n[B])<32||b>126&&b<S){this._printHandler(n,v,B),v=B-1;break}if(++B>=c||(b=n[B])<32||b>126&&b<S){this._printHandler(n,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 D=x?x.length-1:-1;for(;D>=0&&(d=x[D](this._params),d!==!0);D--)if(d instanceof Promise)return this._preserveStack(3,x,D,y,v),d;D<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=n[v])>47&&b<60);v--;break;case 9:this._collect<<=8,this._collect|=b;break;case 10:const T=this._escHandlers[this._collect<<8|b];let L=T?T.length-1:-1;for(;L>=0&&(d=T[L](),d!==!0);L--)if(d instanceof Promise)return this._preserveStack(4,T,L,y,v),d;L<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=n[B])===24||b===26||b===27||b>127&&b<S){this._dcsParser.put(n,v,B),v=B-1;break}break;case 14:if(d=this._dcsParser.unhook(b!==24&&b!==26),d)return this._preserveStack(6,[],0,y,v),d;b===27&&(y|=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=n[B])<32||b>127&&b<S){this._oscParser.put(n,v,B),v=B-1;break}break;case 6:if(d=this._oscParser.end(b!==24&&b!==26),d)return this._preserveStack(5,[],0,y,v),d;b===27&&(y|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingCodepoint=0}this.currentState=15&y}}}r.EscapeSequenceParser=m},6242:(E,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.OscHandler=r.OscParser=void 0;const u=o(5770),_=o(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(f,C){this._handlers[f]===void 0&&(this._handlers[f]=[]);const S=this._handlers[f];return S.push(C),{dispose:()=>{const m=S.indexOf(C);m!==-1&&S.splice(m,1)}}}clearHandler(f){this._handlers[f]&&delete this._handlers[f]}setHandlerFallback(f){this._handlerFb=f}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=l}reset(){if(this._state===2)for(let f=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;f>=0;--f)this._active[f].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 f=this._active.length-1;f>=0;f--)this._active[f].start();else this._handlerFb(this._id,"START")}_put(f,C,S){if(this._active.length)for(let m=this._active.length-1;m>=0;m--)this._active[m].put(f,C,S);else this._handlerFb(this._id,"PUT",(0,_.utf32ToString)(f,C,S))}start(){this.reset(),this._state=1}put(f,C,S){if(this._state!==3){if(this._state===1)for(;C<S;){const m=f[C++];if(m===59){this._state=2,this._start();break}if(m<48||57<m)return void(this._state=3);this._id===-1&&(this._id=0),this._id=10*this._id+m-48}this._state===2&&S-C>0&&this._put(f,C,S)}}end(f,C=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),this._active.length){let S=!1,m=this._active.length-1,s=!1;if(this._stack.paused&&(m=this._stack.loopPosition-1,S=C,s=this._stack.fallThrough,this._stack.paused=!1),!s&&S===!1){for(;m>=0&&(S=this._active[m].end(f),S!==!0);m--)if(S instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=m,this._stack.fallThrough=!1,S;m--}for(;m>=0;m--)if(S=this._active[m].end(!1),S instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=m,this._stack.fallThrough=!0,S}else this._handlerFb(this._id,"END",f);this._active=l,this._id=-1,this._state=0}}},r.OscHandler=class{constructor(f){this._handler=f,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(f,C,S){this._hitLimit||(this._data+=(0,_.utf32ToString)(f,C,S),this._data.length>u.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}end(f){let C=!1;if(this._hitLimit)C=!1;else if(f&&(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:(E,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.Params=void 0;const o=2147483647;class u{static fromArray(l){const f=new u;if(!l.length)return f;for(let C=Array.isArray(l[0])?1:0;C<l.length;++C){const S=l[C];if(Array.isArray(S))for(let m=0;m<S.length;++m)f.addSubParam(S[m]);else f.addParam(S)}return f}constructor(l=32,f=32){if(this.maxLength=l,this.maxSubParamsLength=f,f>256)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(l),this.length=0,this._subParams=new Int32Array(f),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 f=0;f<this.length;++f){l.push(this.params[f]);const C=this._subParamsIdx[f]>>8,S=255&this._subParamsIdx[f];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>o?o: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>o?o:l,this._subParamsIdx[this.length-1]++}}hasSubParams(l){return(255&this._subParamsIdx[l])-(this._subParamsIdx[l]>>8)>0}getSubParams(l){const f=this._subParamsIdx[l]>>8,C=255&this._subParamsIdx[l];return C-f>0?this._subParams.subarray(f,C):null}getSubParamsAll(){const l={};for(let f=0;f<this.length;++f){const C=this._subParamsIdx[f]>>8,S=255&this._subParamsIdx[f];S-C>0&&(l[f]=this._subParams.slice(C,S))}return l}addDigit(l){let f;if(this._rejectDigits||!(f=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;const C=this._digitIsSub?this._subParams:this.params,S=C[f-1];C[f-1]=~S?Math.min(10*S+l,o):l}}r.Params=u},5741:(E,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.AddonManager=void 0,r.AddonManager=class{constructor(){this._addons=[]}dispose(){for(let o=this._addons.length-1;o>=0;o--)this._addons[o].instance.dispose()}loadAddon(o,u){const _={instance:u,dispose:u.dispose,isDisposed:!1};this._addons.push(_),u.dispose=()=>this._wrappedAddonDispose(_),u.activate(o)}_wrappedAddonDispose(o){if(o.isDisposed)return;let u=-1;for(let _=0;_<this._addons.length;_++)if(this._addons[_]===o){u=_;break}if(u===-1)throw new Error("Could not dispose an addon that has not been loaded");o.isDisposed=!0,o.dispose.apply(o.instance),this._addons.splice(u,1)}}},8771:(E,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.BufferApiView=void 0;const u=o(3785),_=o(511);r.BufferApiView=class{constructor(l,f){this._buffer=l,this.type=f}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 f=this._buffer.lines.get(l);if(f)return new u.BufferLineApiView(f)}getNullCell(){return new _.CellData}}},3785:(E,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.BufferLineApiView=void 0;const u=o(511);r.BufferLineApiView=class{constructor(_){this._line=_}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(_,l){if(!(_<0||_>=this._line.length))return l?(this._line.loadCell(_,l),l):this._line.loadCell(_,new u.CellData)}translateToString(_,l,f){return this._line.translateToString(_,l,f)}}},8285:(E,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.BufferNamespaceApi=void 0;const u=o(8771),_=o(8460),l=o(844);class f extends l.Disposable{constructor(S){super(),this._core=S,this._onBufferChange=this.register(new _.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=f},7975:(E,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.ParserApi=void 0,r.ParserApi=class{constructor(o){this._core=o}registerCsiHandler(o,u){return this._core.registerCsiHandler(o,_=>u(_.toArray()))}addCsiHandler(o,u){return this.registerCsiHandler(o,u)}registerDcsHandler(o,u){return this._core.registerDcsHandler(o,(_,l)=>u(_,l.toArray()))}addDcsHandler(o,u){return this.registerDcsHandler(o,u)}registerEscHandler(o,u){return this._core.registerEscHandler(o,u)}addEscHandler(o,u){return this.registerEscHandler(o,u)}registerOscHandler(o,u){return this._core.registerOscHandler(o,u)}addOscHandler(o,u){return this.registerOscHandler(o,u)}}},7090:(E,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.UnicodeApi=void 0,r.UnicodeApi=class{constructor(o){this._core=o}register(o){this._core.unicodeService.register(o)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(o){this._core.unicodeService.activeVersion=o}}},744:function(E,r,o){var u=this&&this.__decorate||function(s,n,c,h){var d,b=arguments.length,y=b<3?n:h===null?h=Object.getOwnPropertyDescriptor(n,c):h;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")y=Reflect.decorate(s,n,c,h);else for(var A=s.length-1;A>=0;A--)(d=s[A])&&(y=(b<3?d(y):b>3?d(n,c,y):d(n,c))||y);return b>3&&y&&Object.defineProperty(n,c,y),y},_=this&&this.__param||function(s,n){return function(c,h){n(c,h,s)}};Object.defineProperty(r,"__esModule",{value:!0}),r.BufferService=r.MINIMUM_ROWS=r.MINIMUM_COLS=void 0;const l=o(8460),f=o(844),C=o(5295),S=o(2585);r.MINIMUM_COLS=2,r.MINIMUM_ROWS=1;let m=r.BufferService=class extends f.Disposable{get buffer(){return this.buffers.active}constructor(s){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(s.rawOptions.cols||0,r.MINIMUM_COLS),this.rows=Math.max(s.rawOptions.rows||0,r.MINIMUM_ROWS),this.buffers=this.register(new C.BufferSet(s,this))}resize(s,n){this.cols=s,this.rows=n,this.buffers.resize(s,n),this._onResize.fire({cols:s,rows:n})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(s,n=!1){const c=this.buffer;let h;h=this._cachedBlankLine,h&&h.length===this.cols&&h.getFg(0)===s.fg&&h.getBg(0)===s.bg||(h=c.getBlankLine(s,n),this._cachedBlankLine=h),h.isWrapped=n;const d=c.ybase+c.scrollTop,b=c.ybase+c.scrollBottom;if(c.scrollTop===0){const y=c.lines.isFull;b===c.lines.length-1?y?c.lines.recycle().copyFrom(h):c.lines.push(h.clone()):c.lines.splice(b+1,0,h.clone()),y?this.isUserScrolling&&(c.ydisp=Math.max(c.ydisp-1,0)):(c.ybase++,this.isUserScrolling||c.ydisp++)}else{const y=b-d+1;c.lines.shiftElements(d+1,y-1,-1),c.lines.set(b,h.clone())}this.isUserScrolling||(c.ydisp=c.ybase),this._onScroll.fire(c.ydisp)}scrollLines(s,n,c){const h=this.buffer;if(s<0){if(h.ydisp===0)return;this.isUserScrolling=!0}else s+h.ydisp>=h.ybase&&(this.isUserScrolling=!1);const d=h.ydisp;h.ydisp=Math.max(Math.min(h.ydisp+s,h.ybase),0),d!==h.ydisp&&(n||this._onScroll.fire(h.ydisp))}};r.BufferService=m=u([_(0,S.IOptionsService)],m)},7994:(E,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(o){this.glevel=o,this.charset=this._charsets[o]}setgCharset(o,u){this._charsets[o]=u,this.glevel===o&&(this.charset=u)}}},1753:function(E,r,o){var u=this&&this.__decorate||function(h,d,b,y){var A,v=arguments.length,x=v<3?d:y===null?y=Object.getOwnPropertyDescriptor(d,b):y;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")x=Reflect.decorate(h,d,b,y);else for(var D=h.length-1;D>=0;D--)(A=h[D])&&(x=(v<3?A(x):v>3?A(d,b,x):A(d,b))||x);return v>3&&x&&Object.defineProperty(d,b,x),x},_=this&&this.__param||function(h,d){return function(b,y){d(b,y,h)}};Object.defineProperty(r,"__esModule",{value:!0}),r.CoreMouseService=void 0;const l=o(2585),f=o(8460),C=o(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 m(h,d){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||d||(b|=3)),b}const s=String.fromCharCode,n={DEFAULT:h=>{const d=[m(h,!1)+32,h.col+32,h.row+32];return d[0]>255||d[1]>255||d[2]>255?"":`\x1B[M${s(d[0])}${s(d[1])}${s(d[2])}`},SGR:h=>{const d=h.action===0&&h.button!==4?"m":"M";return`\x1B[<${m(h,!0)};${h.col};${h.row}${d}`},SGR_PIXELS:h=>{const d=h.action===0&&h.button!==4?"m":"M";return`\x1B[<${m(h,!0)};${h.x};${h.y}${d}`}};let c=r.CoreMouseService=class extends C.Disposable{constructor(h,d){super(),this._bufferService=h,this._coreService=d,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._onProtocolChange=this.register(new f.EventEmitter),this.onProtocolChange=this._onProtocolChange.event;for(const b of Object.keys(S))this.addProtocol(b,S[b]);for(const b of Object.keys(n))this.addEncoding(b,n[b]);this.reset()}addProtocol(h,d){this._protocols[h]=d}addEncoding(h,d){this._encodings[h]=d}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 d=this._encodings[this._activeEncoding](h);return d&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(d):this._coreService.triggerDataEvent(d,!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,d,b){if(b){if(h.x!==d.x||h.y!==d.y)return!1}else if(h.col!==d.col||h.row!==d.row)return!1;return h.button===d.button&&h.action===d.action&&h.ctrl===d.ctrl&&h.alt===d.alt&&h.shift===d.shift}};r.CoreMouseService=c=u([_(0,l.IBufferService),_(1,l.ICoreService)],c)},6975:function(E,r,o){var u=this&&this.__decorate||function(c,h,d,b){var y,A=arguments.length,v=A<3?h:b===null?b=Object.getOwnPropertyDescriptor(h,d):b;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")v=Reflect.decorate(c,h,d,b);else for(var x=c.length-1;x>=0;x--)(y=c[x])&&(v=(A<3?y(v):A>3?y(h,d,v):y(h,d))||v);return A>3&&v&&Object.defineProperty(h,d,v),v},_=this&&this.__param||function(c,h){return function(d,b){h(d,b,c)}};Object.defineProperty(r,"__esModule",{value:!0}),r.CoreService=void 0;const l=o(1439),f=o(8460),C=o(844),S=o(2585),m=Object.freeze({insertMode:!1}),s=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,origin:!1,reverseWraparound:!1,sendFocus:!1,wraparound:!0});let n=r.CoreService=class extends C.Disposable{constructor(c,h,d){super(),this._bufferService=c,this._logService=h,this._optionsService=d,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this.register(new f.EventEmitter),this.onData=this._onData.event,this._onUserInput=this.register(new f.EventEmitter),this.onUserInput=this._onUserInput.event,this._onBinary=this.register(new f.EventEmitter),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this.register(new f.EventEmitter),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=(0,l.clone)(m),this.decPrivateModes=(0,l.clone)(s)}reset(){this.modes=(0,l.clone)(m),this.decPrivateModes=(0,l.clone)(s)}triggerDataEvent(c,h=!1){if(this._optionsService.rawOptions.disableStdin)return;const d=this._bufferService.buffer;h&&this._optionsService.rawOptions.scrollOnUserInput&&d.ybase!==d.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=n=u([_(0,S.IBufferService),_(1,S.ILogService),_(2,S.IOptionsService)],n)},9074:(E,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.DecorationService=void 0;const u=o(8055),_=o(8460),l=o(844),f=o(6106);let C=0,S=0;class m extends l.Disposable{get decorations(){return this._decorations.values()}constructor(){super(),this._decorations=new f.SortedList(c=>c==null?void 0:c.marker.line),this._onDecorationRegistered=this.register(new _.EventEmitter),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this.register(new _.EventEmitter),this.onDecorationRemoved=this._onDecorationRemoved.event,this.register((0,l.toDisposable)(()=>this.reset()))}registerDecoration(c){if(c.marker.isDisposed)return;const h=new s(c);if(h){const d=h.marker.onDispose(()=>h.dispose());h.onDispose(()=>{h&&(this._decorations.delete(h)&&this._onDecorationRemoved.fire(h),d.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,d){var b,y,A;let v=0,x=0;for(const D of this._decorations.getKeyIterator(h))v=(b=D.options.x)!==null&&b!==void 0?b:0,x=v+((y=D.options.width)!==null&&y!==void 0?y:1),c>=v&&c<x&&(!d||((A=D.options.layer)!==null&&A!==void 0?A:"bottom")===d)&&(yield D)}forEachDecorationAtCell(c,h,d,b){this._decorations.forEachByKey(h,y=>{var A,v,x;C=(A=y.options.x)!==null&&A!==void 0?A:0,S=C+((v=y.options.width)!==null&&v!==void 0?v:1),c>=C&&c<S&&(!d||((x=y.options.layer)!==null&&x!==void 0?x:"bottom")===d)&&b(y)})}}r.DecorationService=m;class s 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 _.EventEmitter),this.onRender=this.onRenderEmitter.event,this._onDispose=this.register(new _.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:(E,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.InstantiationService=r.ServiceCollection=void 0;const u=o(2585),_=o(8343);class l{constructor(...C){this._entries=new Map;for(const[S,m]of C)this.set(S,m)}set(C,S){const m=this._entries.get(C);return this._entries.set(C,S),m}forEach(C){for(const[S,m]of this._entries.entries())C(S,m)}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(f,C){this._services.set(f,C)}getService(f){return this._services.get(f)}createInstance(f,...C){const S=(0,_.getServiceDependencies)(f).sort((n,c)=>n.index-c.index),m=[];for(const n of S){const c=this._services.get(n.id);if(!c)throw new Error(`[createInstance] ${f.name} depends on UNKNOWN service ${n.id}.`);m.push(c)}const s=S.length>0?S[0].index:C.length;if(C.length!==s)throw new Error(`[createInstance] First service dependency of ${f.name} at position ${s+1} conflicts with ${C.length} static arguments`);return new f(...C,...m)}}},7866:function(E,r,o){var u=this&&this.__decorate||function(s,n,c,h){var d,b=arguments.length,y=b<3?n:h===null?h=Object.getOwnPropertyDescriptor(n,c):h;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")y=Reflect.decorate(s,n,c,h);else for(var A=s.length-1;A>=0;A--)(d=s[A])&&(y=(b<3?d(y):b>3?d(n,c,y):d(n,c))||y);return b>3&&y&&Object.defineProperty(n,c,y),y},_=this&&this.__param||function(s,n){return function(c,h){n(c,h,s)}};Object.defineProperty(r,"__esModule",{value:!0}),r.traceCall=r.setTraceLogger=r.LogService=void 0;const l=o(844),f=o(2585),C={trace:f.LogLevelEnum.TRACE,debug:f.LogLevelEnum.DEBUG,info:f.LogLevelEnum.INFO,warn:f.LogLevelEnum.WARN,error:f.LogLevelEnum.ERROR,off:f.LogLevelEnum.OFF};let S,m=r.LogService=class extends l.Disposable{get logLevel(){return this._logLevel}constructor(s){super(),this._optionsService=s,this._logLevel=f.LogLevelEnum.OFF,this._updateLogLevel(),this.register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel())),S=this}_updateLogLevel(){this._logLevel=C[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(s){for(let n=0;n<s.length;n++)typeof s[n]=="function"&&(s[n]=s[n]())}_log(s,n,c){this._evalLazyOptionalParams(c),s.call(console,(this._optionsService.options.logger?"":"xterm.js: ")+n,...c)}trace(s,...n){var c,h;this._logLevel<=f.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,s,n)}debug(s,...n){var c,h;this._logLevel<=f.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,s,n)}info(s,...n){var c,h;this._logLevel<=f.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,s,n)}warn(s,...n){var c,h;this._logLevel<=f.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,s,n)}error(s,...n){var c,h;this._logLevel<=f.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,s,n)}};r.LogService=m=u([_(0,f.IOptionsService)],m),r.setTraceLogger=function(s){S=s},r.traceCall=function(s,n,c){if(typeof c.value!="function")throw new Error("not supported");const h=c.value;c.value=function(...d){if(S.logLevel!==f.LogLevelEnum.TRACE)return h.apply(this,d);S.trace(`GlyphRenderer#${h.name}(${d.map(y=>JSON.stringify(y)).join(", ")})`);const b=h.apply(this,d);return S.trace(`GlyphRenderer#${h.name} return`,b),b}}},7302:(E,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.OptionsService=r.DEFAULT_OPTIONS=void 0;const u=o(8460),_=o(844),l=o(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 f=["normal","bold","100","200","300","400","500","600","700","800","900"];class C extends _.Disposable{constructor(m){super(),this._onOptionChange=this.register(new u.EventEmitter),this.onOptionChange=this._onOptionChange.event;const s=Object.assign({},r.DEFAULT_OPTIONS);for(const n in m)if(n in s)try{const c=m[n];s[n]=this._sanitizeAndValidateOption(n,c)}catch(c){console.error(c)}this.rawOptions=s,this.options=Object.assign({},s),this._setupOptions()}onSpecificOptionChange(m,s){return this.onOptionChange(n=>{n===m&&s(this.rawOptions[m])})}onMultipleOptionChange(m,s){return this.onOptionChange(n=>{m.indexOf(n)!==-1&&s()})}_setupOptions(){const m=n=>{if(!(n in r.DEFAULT_OPTIONS))throw new Error(`No option with key "${n}"`);return this.rawOptions[n]},s=(n,c)=>{if(!(n in r.DEFAULT_OPTIONS))throw new Error(`No option with key "${n}"`);c=this._sanitizeAndValidateOption(n,c),this.rawOptions[n]!==c&&(this.rawOptions[n]=c,this._onOptionChange.fire(n))};for(const n in this.rawOptions){const c={get:m.bind(this,n),set:s.bind(this,n)};Object.defineProperty(this.options,n,c)}}_sanitizeAndValidateOption(m,s){switch(m){case"cursorStyle":if(s||(s=r.DEFAULT_OPTIONS[m]),!function(n){return n==="block"||n==="underline"||n==="bar"}(s))throw new Error(`"${s}" is not a valid value for ${m}`);break;case"wordSeparator":s||(s=r.DEFAULT_OPTIONS[m]);break;case"fontWeight":case"fontWeightBold":if(typeof s=="number"&&1<=s&&s<=1e3)break;s=f.includes(s)?s:r.DEFAULT_OPTIONS[m];break;case"cursorWidth":s=Math.floor(s);case"lineHeight":case"tabStopWidth":if(s<1)throw new Error(`${m} cannot be less than 1, value: ${s}`);break;case"minimumContrastRatio":s=Math.max(1,Math.min(21,Math.round(10*s)/10));break;case"scrollback":if((s=Math.min(s,4294967295))<0)throw new Error(`${m} cannot be less than 0, value: ${s}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(s<=0)throw new Error(`${m} cannot be less than or equal to 0, value: ${s}`);break;case"rows":case"cols":if(!s&&s!==0)throw new Error(`${m} must be numeric, value: ${s}`);break;case"windowsPty":s=s??{}}return s}}r.OptionsService=C},2660:function(E,r,o){var u=this&&this.__decorate||function(C,S,m,s){var n,c=arguments.length,h=c<3?S:s===null?s=Object.getOwnPropertyDescriptor(S,m):s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")h=Reflect.decorate(C,S,m,s);else for(var d=C.length-1;d>=0;d--)(n=C[d])&&(h=(c<3?n(h):c>3?n(S,m,h):n(S,m))||h);return c>3&&h&&Object.defineProperty(S,m,h),h},_=this&&this.__param||function(C,S){return function(m,s){S(m,s,C)}};Object.defineProperty(r,"__esModule",{value:!0}),r.OscLinkService=void 0;const l=o(2585);let f=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 d=S.addMarker(S.ybase+S.y),b={data:C,id:this._nextId++,lines:[d]};return d.onDispose(()=>this._removeMarkerFromLink(b,d)),this._dataByLinkId.set(b.id,b),b.id}const m=C,s=this._getEntryIdKey(m),n=this._entriesWithId.get(s);if(n)return this.addLineToLink(n.id,S.ybase+S.y),n.id;const c=S.addMarker(S.ybase+S.y),h={id:this._nextId++,key:this._getEntryIdKey(m),data:m,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 m=this._dataByLinkId.get(C);if(m&&m.lines.every(s=>s.line!==S)){const s=this._bufferService.buffer.addMarker(S);m.lines.push(s),s.onDispose(()=>this._removeMarkerFromLink(m,s))}}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 m=C.lines.indexOf(S);m!==-1&&(C.lines.splice(m,1),C.lines.length===0&&(C.data.id!==void 0&&this._entriesWithId.delete(C.key),this._dataByLinkId.delete(C.id)))}};r.OscLinkService=f=u([_(0,l.IBufferService)],f)},8343:(E,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.createDecorator=r.getServiceDependencies=r.serviceRegistry=void 0;const o="di$target",u="di$dependencies";r.serviceRegistry=new Map,r.getServiceDependencies=function(_){return _[u]||[]},r.createDecorator=function(_){if(r.serviceRegistry.has(_))return r.serviceRegistry.get(_);const l=function(f,C,S){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");(function(m,s,n){s[o]===s?s[u].push({id:m,index:n}):(s[u]=[{id:m,index:n}],s[o]=s)})(l,f,S)};return l.toString=()=>_,r.serviceRegistry.set(_,l),l}},2585:(E,r,o)=>{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=o(8343);var _;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"}(_||(r.LogLevelEnum=_={})),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:(E,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.UnicodeService=void 0;const u=o(8460),_=o(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 _.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 f=0;const C=l.length;for(let S=0;S<C;++S){let m=l.charCodeAt(S);if(55296<=m&&m<=56319){if(++S>=C)return f+this.wcwidth(m);const s=l.charCodeAt(S);56320<=s&&s<=57343?m=1024*(m-55296)+s-56320+65536:f+=this.wcwidth(s)}f+=this.wcwidth(m)}return f}}}},a={};function g(E){var r=a[E];if(r!==void 0)return r.exports;var o=a[E]={exports:{}};return i[E].call(o.exports,o,o.exports,g),o.exports}var w={};return(()=>{var E=w;Object.defineProperty(E,"__esModule",{value:!0}),E.Terminal=void 0;const r=g(9042),o=g(3236),u=g(844),_=g(5741),l=g(8285),f=g(7975),C=g(7090),S=["cols","rows"];class m extends u.Disposable{constructor(n){super(),this._core=this.register(new o.Terminal(n)),this._addonManager=this.register(new _.AddonManager),this._publicOptions=Object.assign({},this._core.options);const c=d=>this._core.options[d],h=(d,b)=>{this._checkReadonlyOptions(d),this._core.options[d]=b};for(const d in this._core.options){const b={get:c.bind(this,d),set:h.bind(this,d)};Object.defineProperty(this._publicOptions,d,b)}}_checkReadonlyOptions(n){if(S.includes(n))throw new Error(`Option "${n}" 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 f.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 n=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:n.applicationCursorKeys,applicationKeypadMode:n.applicationKeypad,bracketedPasteMode:n.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:c,originMode:n.origin,reverseWraparoundMode:n.reverseWraparound,sendFocusMode:n.sendFocus,wraparoundMode:n.wraparound}}get options(){return this._publicOptions}set options(n){for(const c in n)this._publicOptions[c]=n[c]}blur(){this._core.blur()}focus(){this._core.focus()}resize(n,c){this._verifyIntegers(n,c),this._core.resize(n,c)}open(n){this._core.open(n)}attachCustomKeyEventHandler(n){this._core.attachCustomKeyEventHandler(n)}registerLinkProvider(n){return this._core.registerLinkProvider(n)}registerCharacterJoiner(n){return this._checkProposedApi(),this._core.registerCharacterJoiner(n)}deregisterCharacterJoiner(n){this._checkProposedApi(),this._core.deregisterCharacterJoiner(n)}registerMarker(n=0){return this._verifyIntegers(n),this._core.registerMarker(n)}registerDecoration(n){var c,h,d;return this._checkProposedApi(),this._verifyPositiveIntegers((c=n.x)!==null&&c!==void 0?c:0,(h=n.width)!==null&&h!==void 0?h:0,(d=n.height)!==null&&d!==void 0?d:0),this._core.registerDecoration(n)}hasSelection(){return this._core.hasSelection()}select(n,c,h){this._verifyIntegers(n,c,h),this._core.select(n,c,h)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(n,c){this._verifyIntegers(n,c),this._core.selectLines(n,c)}dispose(){super.dispose()}scrollLines(n){this._verifyIntegers(n),this._core.scrollLines(n)}scrollPages(n){this._verifyIntegers(n),this._core.scrollPages(n)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(n){this._verifyIntegers(n),this._core.scrollToLine(n)}clear(){this._core.clear()}write(n,c){this._core.write(n,c)}writeln(n,c){this._core.write(n),this._core.write(`\r `,c)}paste(n){this._core.paste(n)}refresh(n,c){this._verifyIntegers(n,c),this._core.refresh(n,c)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(n){this._addonManager.loadAddon(this,n)}static get strings(){return r}_verifyIntegers(...n){for(const c of n)if(c===1/0||isNaN(c)||c%1!=0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...n){for(const c of n)if(c&&(c===1/0||isNaN(c)||c%1!=0||c<0))throw new Error("This API only accepts positive integers")}}E.Terminal=m})(),w})())}(Di)),Di.exports}var Wa=za();const Er=Z.forwardRef(function({options:e={},addons:i,className:a,onBinary:g,onCursorMove:w,onData:E,onKey:r,onLineFeed:o,onScroll:u,onSelectionChange:_,onRender:l,onResize:f,onTitleChange:C,customKeyEventHandler:S,onOpen:m},s){const[n,c]=Z.useState(!1),h=Z.useRef(null),d=Z.useRef(new Wa.Terminal(e));Z.useImperativeHandle(s,()=>d.current);const b=()=>{i&&i.forEach(y=>{var A;(A=d.current)==null||A.loadAddon(y)}),g&&d.current.onBinary(g),w&&d.current.onCursorMove(w),E&&d.current.onData(E),r&&d.current.onKey(r),o&&d.current.onLineFeed(o),u&&d.current.onScroll(u),_&&d.current.onSelectionChange(_),l&&d.current.onRender(l),f&&d.current.onResize(f),C&&d.current.onTitleChange(C),S&&d.current.attachCustomKeyEventHandler(S)};return Z.useEffect(()=>{var A;const y=h.current;return y&&(b(),(A=d.current)==null||A.open(y),c(!0)),()=>{var v;(v=d.current)==null||v.dispose()}},[]),Z.useLayoutEffect(()=>{n&&m&&m()},[n]),p.jsx("div",{className:a,ref:h})}),$a={theme:{background:"#292c2f"}},qa={command:"bash",environment:[{key:"TERM",value:"xterm-256color"},{key:"HOME",value:"/root"}],user:0,group:0},Va=({instance:t,refreshInstance:e})=>{var z;const{name:i,project:a}=nt(),g=new TextEncoder,w=N.useNotify(),[E,r]=Z.useState(!1),[o,u]=Z.useState(null),[_,l]=Z.useState(null),[f,C]=Z.useState(qa),[S]=Z.useState(new br.FitAddon),[m,s]=Z.useState(!1),n=Z.useRef(null),c=Z.useRef(null),[h,d]=Z.useState(0),{canUpdateInstanceState:b,canExecInstance:y}=Oe();sr({when:m,message:"Are you sure you want to leave this page?"}),Ne("beforeunload",I=>{m&&(I.returnValue="Are you sure you want to leave this page?")});const v=async I=>{if(!i){w.failure("Missing name",new Error);return}if(!a){w.failure("Missing project",new Error);return}r(!0);const M=await ko(i,a,I).catch(X=>{r(!1),w.failure("Connection failed",X)});if(!M)return;const R=M.operation.split("?")[0],O=`wss://${location.host}${R}/websocket?secret=${M.metadata.metadata.fds[0]}`,q=`wss://${location.host}${R}/websocket?secret=${M.metadata.metadata.fds.control}`,V=new WebSocket(O),J=new WebSocket(q);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,It(X.code)),l(null)},V.onopen=()=>{u(V)},V.onerror=X=>{w.failure("Error",X)},V.onclose=X=>{X.code!==1005&&w.failure("Error",X.reason,It(X.code)),u(null),s(!1)},V.binaryType="arraybuffer",V.onmessage=X=>{var ce;(ce=n.current)==null||ce.write(new Uint8Array(X.data))},[V,J]},x=t.status==="Running",D=x&&(((z=t.state)==null?void 0:z.processes)??0)<1,T=x&&!D,L=y(t);Z.useEffect(()=>{if(D&&c.current===null){const R=setTimeout(()=>{e(),c.current=null,d(O=>O+1)},1e3);return c.current=R,()=>{clearTimeout(R)}}},[D,h]),Z.useEffect(()=>{var I;if((I=n.current)==null||I.clear(),w.clear(),T&&L){const M=v(f);return()=>{M.then(R=>{R==null||R.map(O=>{O.close()})})}}},[f,t.status,T,L]);const B=()=>{var M,R;if((_==null?void 0:_.readyState)===WebSocket.CLOSED)return;_t("p-terminal",void 0,10),(R=(M=n.current)==null?void 0:M.element)==null||R.style.setProperty("padding","1rem"),S.fit();const I=S.proposeDimensions();_==null||_.send(g.encode(JSON.stringify({command:"window-resize",args:{height:I==null?void 0:I.rows.toString(),width:I==null?void 0:I.cols.toString()}})))};Ne("resize",()=>{B(),setTimeout(B,500)});const F=()=>{var I;B(),(I=n.current)==null||I.focus()},{handleStart:Y,isLoading:$}=ar(t);return L?p.jsxs("div",{className:"instance-terminal-tab",children:[T&&p.jsxs(p.Fragment,{children:[p.jsx("div",{className:"p-panel__controls",children:p.jsx(Ya,{reconnect:C,payload:f})}),p.jsx(oi,{}),E&&p.jsx(tt,{text:"Loading terminal session..."}),_&&p.jsx(Er,{ref:n,addons:[S],options:$a,onData:I=>{s(!0),o==null||o.send(g.encode(I))},onOpen:F,className:"p-terminal"})]}),!T&&p.jsxs(N.EmptyState,{className:"empty-state",image:p.jsx(N.Icon,{name:"pods",className:"empty-state-icon"}),title:D?"Instance starting":"Instance stopped",children:[p.jsx("p",{children:D?"Terminal will be ready once the instance is finished booting.":"Start the instance to access the terminal."}),p.jsx(N.ActionButton,{appearance:"positive",loading:$||D,onClick:Y,disabled:!b(t),title:b(t)?"":"You do not have permission to start this instance.",children:"Start instance"})]})]}):p.jsx(N.Notification,{severity:"caution",title:"Restricted permissions",children:"You do not have permission to use the terminal for this instance."})},Xa=async(t,e,i,a)=>new Promise((g,w)=>{fetch(`/1.0/instances/${t.name}/snapshots?project=${t.project}`,{method:"POST",body:JSON.stringify({name:e,expires_at:i,stateful:a})}).then(Tt).then(g).catch(w)}),yr=async(t,e)=>new Promise((i,a)=>{fetch(`/1.0/instances/${t.name}/snapshots/${e.name}?project=${t.project}`,{method:"DELETE"}).then(Tt).then(i).catch(a)}),Qa=async(t,e,i)=>{const a=[];return new Promise((g,w)=>{Promise.allSettled(e.map(async E=>{await yr(t,{name:E}).then(r=>{i.set(r.metadata.id,()=>{ho(a)},o=>{bs(a,o)},()=>{Cs(a,e.length,g)})}).catch(r=>{bs(a,r instanceof Error?r.message:""),Cs(a,e.length,g)})})).catch(w)})},Za=async(t,e,i)=>new Promise((a,g)=>{fetch(`/1.0/instances/${t.name}?project=${t.project}`,{method:"PUT",body:JSON.stringify({restore:e.name,stateful:e.stateful?i:!1})}).then(Tt).then(a).catch(g)}),Ja=async(t,e,i)=>new Promise((a,g)=>{fetch(`/1.0/instances/${t.name}/snapshots/${e.name}?project=${t.project}`,{method:"POST",body:JSON.stringify({name:i})}).then(Tt).then(a).catch(g)}),ec=async(t,e,i)=>new Promise((a,g)=>{fetch(`/1.0/instances/${t.name}/snapshots/${e.name}?project=${t.project}`,{method:"PUT",body:JSON.stringify({expires_at:i})}).then(Tt).then(a).catch(g)}),tc=t=>!!t.config["migration.stateful"],ic=(t,e,i)=>["deduplicate","Snapshot name already in use",async a=>i&&a===i||lo(a,t.project,e,`instances/${t.name}/snapshots`)],wr=(t,e,i)=>Je().shape({name:Qe().test(...ic(t,e,i)).matches(/^[A-Za-z0-9-_.:]+$/,{message:"Only alphanumeric characters, underscores, periods, hyphens, and colons are allowed in this field"}),expirationDate:Qe().nullable().optional().test(...Wo()).test(...$o()),expirationTime:Qe().nullable().optional().test(...zo()),stateful:Yo()}),Dt=({name:t,instance:e})=>p.jsx(Fe,{type:"snapshot",value:t,to:`/ui/project/${e.project}/instance/${e.name}/snapshots`}),sc=({instance:t,snapshot:e,close:i,onSuccess:a})=>{const g=Ee(),w=Ie(),E=Ue(),r=Z.useState(null),o=S=>{E.invalidateQueries({predicate:m=>m.queryKey[0]===de.instances}),a(p.jsxs(p.Fragment,{children:["Snapshot ",p.jsx(Dt,{name:S,instance:t})," ","saved for instance ",p.jsx(ue,{instance:t}),"."]})),i()},u=(S,m)=>{const s=m?{name:m}:e,n=p.jsx(ue,{instance:t});ec(t,s,S).then(c=>{g.set(c.metadata.id,()=>{o(m??e.name)},h=>{w.failure(`Snapshot update failed for instance ${t.name}`,new Error(h),n),C.setSubmitting(!1)})}).catch(c=>{w.failure(`Snapshot update failed for instance ${t.name}`,c,n),C.setSubmitting(!1)})},_=(S,m)=>{const s=p.jsx(Dt,{name:e.name,instance:t});Ja(t,e,S).then(n=>{g.set(n.metadata.id,()=>{m?u(m,S):o(S)},c=>{w.failure(`Snapshot rename failed for ${e.name}`,new Error(c),s),C.setSubmitting(!1)})}).catch(n=>{w.failure(`Snapshot rename failed for ${e.name}`,n,s),C.setSubmitting(!1)})},[l,f]=e.expires_at===Oi?[null,null]:uo(new Date(e.expires_at)).slice(0,16).split(" "),C=Ke({initialValues:{name:e.name,stateful:e.stateful,expirationDate:l,expirationTime:f},validateOnMount:!0,validationSchema:wr(t,r,e.name),onSubmit:S=>{const m=S.name,s=S.expirationDate&&S.expirationTime?rr(fr(S.expirationDate,S.expirationTime)):Oi,n=m!==e.name,c=s!==e.expires_at;n&&c?_(m,s):n?_(m):u(s)}});return p.jsx(_r,{isEdit:!0,formik:C,close:i})},rc=({instance:t,snapshot:e,onSuccess:i,isDeleting:a,isRestoring:g,disabledReason:w})=>{const{openPortal:E,closePortal:r,isOpen:o,Portal:u}=N.usePortal();return p.jsxs(p.Fragment,{children:[o&&p.jsx(u,{children:p.jsx(sc,{close:r,instance:t,onSuccess:i,snapshot:e})}),p.jsx(N.Button,{appearance:"base",hasIcon:!0,dense:!0,disabled:a||g||!!w,onClick:E,type:"button","aria-label":"Edit snapshot",title:w??"Edit",children:p.jsx(N.Icon,{name:"edit"})})]})},nc=({instance:t,snapshot:e,close:i})=>{const a=Ee(),g=Ie(),w=Ue(),E=p.jsx(Dt,{name:e.name,instance:t}),{data:r}=Rt(t.project),{canCreateImageAliases:o}=ze(),u=()=>{const C=p.jsx(Wi,{to:`/ui/project/${t.project}/images`,children:"created"});g.success(p.jsxs(p.Fragment,{children:["Image ",C," from snapshot ",E,"."]}))},_=()=>{w.invalidateQueries({predicate:C=>C.queryKey[0]===de.images})},l=(C,S,m)=>JSON.stringify({public:m,source:{type:"snapshot",name:`${C.name}/${S.name}`}}),f=Ke({initialValues:{alias:"",isPublic:!1},validationSchema:Je().shape({alias:Qe()}),onSubmit:C=>{const S=C.alias;hr(l(t,e,C.isPublic),t).then(m=>{g.info(p.jsxs(p.Fragment,{children:["Creation of image from snapshot ",E," started."]})),i(),a.set(m.metadata.id,s=>{var n;if(S){const c=((n=s.metadata.metadata)==null?void 0:n.fingerprint)??"";lr(c,S,t.project).then(_).then(u).catch(h=>{g.failure(`Image creation from snapshot "${e.name}" succeeded. Failed to create an alias.`,h)})}else _(),u()},s=>{g.failure(`Image creation from snapshot "${e.name}" failed.`,new Error(s),E)})}).catch(m=>{g.failure(`Image creation from snapshot "${e.name}" failed.`,m,E)})}});return p.jsx(N.Modal,{close:i,title:"Create image from instance snapshot",buttonRow:p.jsxs(p.Fragment,{children:[p.jsx(N.Button,{appearance:"base",className:"u-no-margin--bottom",type:"button",onClick:i,children:"Cancel"}),p.jsx(N.ActionButton,{appearance:"positive",className:"u-no-margin--bottom",loading:f.isSubmitting,disabled:!f.isValid,onClick:()=>void f.submitForm(),children:"Create image"})]}),children:p.jsxs(N.Form,{onSubmit:f.handleSubmit,children:[p.jsx(N.Input,{type:"text",label:"Instance",value:t.name,disabled:!0}),p.jsx(N.Input,{type:"text",label:"Snapshot",value:e.name,disabled:!0}),p.jsx(N.Input,{...f.getFieldProps("alias"),type:"text",label:"Alias",error:f.touched.alias?f.errors.alias:null,disabled:!o(r),title:o(r)?"":"You do not have permission to create image aliases in this project"}),p.jsx(N.Input,{...f.getFieldProps("isPublic"),type:"checkbox",label:"Make the image publicly available",error:f.touched.isPublic?f.errors.isPublic:null}),p.jsx(N.Input,{type:"submit",hidden:!0,value:"Hidden input"})]})})},oc=({instance:t,snapshot:e,isDeleting:i,isRestoring:a})=>{const{openPortal:g,closePortal:w,isOpen:E,Portal:r}=N.usePortal(),{data:o}=Rt(t.project),{canCreateImages:u}=ze();return p.jsxs(p.Fragment,{children:[E&&p.jsx(r,{children:p.jsx(nc,{close:w,instance:t,snapshot:e})}),p.jsx(N.Button,{appearance:"base",hasIcon:!0,dense:!0,disabled:i||a||!u(o),onClick:g,type:"button","aria-label":"Create image",title:u(o)?"Create image":"You do not have permission to create images in this project",children:p.jsx(N.Icon,{name:"export"})})]})},ac=(t,e,i)=>{const a={name:t.instanceName,description:e.description,architecture:e.architecture,ephemeral:i.ephemeral,mode:"pull",devices:{...e.devices,root:{path:"/",type:"disk",pool:t.targetStoragePool}}},g={project:e.project,type:"copy",source:`${e.name}/${i.name}`,base_image:i.config["volatile.base_image"]??""};return i.stateful&&t.stateful&&(a.stateful=!0,g.live=!1),{...a,source:g}},cc=({instance:t,snapshot:e,close:i})=>{var d,b,y;const a=Ie(),{data:g}=Mt(),w=$i(g),E=Z.useState(null),r=Ee(),{data:o=[],isLoading:u}=kt(),{canCreateInstances:_}=ze(),{data:l=[],isLoading:f}=nr(),{data:C=[]}=cr(t.project),S=(A,v,x)=>{const D=p.jsx(ue,{instance:{name:A,project:v,type:x}}),T=p.jsxs(p.Fragment,{children:["Created instance ",D,"."]});a.success(T)},m=A=>{const v=C.map(D=>D.name),x=mr(A.name,`-${e.name}-copy`);if(v.includes(x)){let D=1;for(;v.includes(`${x}-${D}`);)D++;return`${x}-${D}`}return x},s=A=>{const v={};return A.stateful&&(A.targetProject===t.project&&(v.targetProject="Stateful instance snapshot duplication must be in a different project"),A.instanceName!==t.name&&(v.instanceName="Instance name must be the same for stateful duplication")),v},n=o.filter(_),c=n.some(A=>A.name===t.project),h=Ke({initialValues:{instanceName:m(t),targetProject:c?t.project:(d=n[0])==null?void 0:d.name,stateful:!1,targetClusterMember:w?t.location:"",targetStoragePool:((b=t.devices.root)==null?void 0:b.pool)??((y=l[0])==null?void 0:y.name)},enableReinitialize:!0,validate:s,validationSchema:Je().shape({instanceName:Vi(t.project,E,t.name).required()}),onSubmit:A=>{const v=p.jsx(ue,{instance:t});ur(JSON.stringify(ac(A,t,e)),A.targetProject,A.targetClusterMember).then(x=>{a.info(p.jsxs(p.Fragment,{children:["Instance creation started for"," ",p.jsx(ai,{bold:!0,type:t.type,value:A.instanceName}),"."]})),r.set(x.metadata.id,()=>{S(A.instanceName,A.targetProject,t.type)},D=>a.failure("Instance creation failed.",new Error(D),v))}).catch(x=>{a.failure("Instance creation failed.",x,v)}).finally(()=>{i()})}});return p.jsx(N.Modal,{close:i,className:"create-instance-from-snapshot-modal",title:"Create instance from snapshot",buttonRow:p.jsxs(p.Fragment,{children:[p.jsx(N.Button,{appearance:"base",className:"u-no-margin--bottom",type:"button",onClick:i,children:"Cancel"}),p.jsx(N.ActionButton,{appearance:"positive",className:"u-no-margin--bottom",loading:h.isSubmitting,disabled:!h.isValid||f||u,onClick:()=>void h.submitForm(),children:"Create"})]}),children:p.jsxs(N.Form,{onSubmit:h.handleSubmit,children:[p.jsx(N.Input,{type:"text",label:"Snapshot name",disabled:!0,value:e.name}),p.jsx(N.Input,{...h.getFieldProps("instanceName"),type:"text",label:"New instance name",error:h.errors.instanceName}),p.jsx(pr,{...h.getFieldProps("targetClusterMember"),id:"targetClusterMember",label:"Target cluster member"}),p.jsx(N.Select,{...h.getFieldProps("targetStoragePool"),id:"storagePool",label:"Storage pool",options:l.map(A=>({label:A.name,value:A.name}))}),p.jsx(N.Select,{...h.getFieldProps("targetProject"),id:"project",label:"Target project",options:n.map(A=>({label:A.name,value:A.name})),error:h.errors.targetProject}),e.stateful&&p.jsx(N.Input,{...h.getFieldProps("stateful"),type:"checkbox",label:"Copy stateful"}),p.jsx(N.Input,{type:"submit",hidden:!0,value:"Hidden input"})]})})},hc=({instance:t,snapshot:e,isDeleting:i,isRestoring:a})=>{const{openPortal:g,closePortal:w,isOpen:E,Portal:r}=N.usePortal(),{data:o=[]}=kt(),{canCreateInstances:u}=ze(),_=o.filter(u);return p.jsxs(p.Fragment,{children:[E&&p.jsx(r,{children:p.jsx(cc,{close:w,instance:t,snapshot:e})}),p.jsx(N.Button,{appearance:"base",hasIcon:!0,dense:!0,"aria-label":"Create instance",disabled:i||a||!_.length,onClick:g,title:_.length>0?"Create instance":"You do not have permission to create instances",children:p.jsx(N.Icon,{name:"plus"})})]})},lc=({instance:t,snapshot:e,onSuccess:i,onFailure:a})=>{const g=Ee(),[w,E]=Z.useState(!1),[r,o]=Z.useState(!1),[u,_]=Z.useState(!0),l=Ue(),{canManageInstanceSnapshots:f}=Oe(),C=f(t)?void 0:"You do not have permission to manage snapshots for this instance",S=()=>{E(!0),yr(t,e).then(s=>{g.set(s.metadata.id,()=>{i(p.jsxs(p.Fragment,{children:["Snapshot"," ",p.jsx(ai,{bold:!0,type:"snapshot",value:e.name})," ","deleted for instance ",p.jsx(ue,{instance:t}),"."]}))},n=>{a("Snapshot deletion failed",new Error(n))},()=>{E(!1),l.invalidateQueries({predicate:n=>n.queryKey[0]===de.instances})})}).catch(s=>{a("Snapshot deletion failed",s),E(!1)})},m=()=>{o(!0),Za(t,e,u).then(s=>{g.set(s.metadata.id,()=>{i(p.jsxs(p.Fragment,{children:["Snapshot"," ",p.jsx(Dt,{name:e.name,instance:t})," ","restored for instance ",p.jsx(ue,{instance:t}),"."]}))},n=>{a("Snapshot restore failed",new Error(n))},()=>{o(!1),l.invalidateQueries({predicate:n=>n.queryKey[0]===de.instances})})}).catch(s=>{a("Snapshot restore failed",s),o(!1)})};return p.jsx(p.Fragment,{children:p.jsx(N.List,{inline:!0,className:it("u-no-margin--bottom","actions-list",{"u-snapshot-actions":!w&&!r}),items:[p.jsx(rc,{instance:t,snapshot:e,onSuccess:i,isDeleting:w,isRestoring:r,disabledReason:C},"edit"),p.jsx(N.ConfirmationButton,{appearance:"base",loading:r,className:"has-icon is-dense",title:"Confirm restore",confirmationModalProps:{title:"Confirm restore",children:p.jsxs("p",{children:["This will restore snapshot ",p.jsx(Pt,{item:e,bold:!0}),".",p.jsx("br",{}),"This action cannot be undone, and can result in data loss."]}),confirmExtra:e.stateful?p.jsx(Io,{label:"Restore the instance state",force:[u,_]}):void 0,confirmButtonLabel:C??"Restore snapshot",confirmButtonAppearance:"positive",close:()=>{_(!0)},onConfirm:m},disabled:w||r||!!C,shiftClickEnabled:!0,showShiftClickHint:!0,children:p.jsx(N.Icon,{name:"change-version"})},"restore"),p.jsx(oc,{instance:t,snapshot:e,isRestoring:r,isDeleting:w},"publish"),p.jsx(hc,{instance:t,snapshot:e,isDeleting:w,isRestoring:r},"duplicate"),p.jsx(N.ConfirmationButton,{appearance:"base",loading:w,className:"has-icon is-dense",confirmationModalProps:{title:"Confirm delete",children:p.jsxs("p",{children:["This will permanently delete snapshot"," ",p.jsx(Pt,{item:e,bold:!0}),".",p.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:p.jsx(N.Icon,{name:"delete"})},"delete")]})})},uc=({instance:t,snapshotNames:e,onStart:i,onFinish:a,onSuccess:g,onFailure:w})=>{const E=Ee(),[r,o]=Z.useState(!1),u=Ue(),{canManageInstanceSnapshots:_}=Oe(),l=e.length,f=()=>{o(!0),i(),Qa(t,e,E).then(C=>{const{fulfilledCount:S,rejectedCount:m}=_o(C);S===l?g(p.jsxs(p.Fragment,{children:[p.jsx("b",{children:e.length})," ",yt("snapshot",e.length)," deleted."]})):m===l?w("Snapshot bulk deletion failed",void 0,p.jsxs(p.Fragment,{children:[p.jsx("b",{children:l})," ",yt("snapshot",l)," could not be deleted."]})):w("Snapshot bulk deletion partially failed",void 0,p.jsxs(p.Fragment,{children:[p.jsx("b",{children:S})," ",yt("snapshot",S)," ","deleted.",p.jsx("br",{}),p.jsx("b",{children:m})," ",yt("snapshot",m)," ","could not be deleted."]})),u.invalidateQueries({predicate:s=>s.queryKey[0]===de.instances}),o(!1),a()}).catch(C=>{w("Snapshot bulk deletion failed",C),o(!1)})};return p.jsx(Qo,{confirmationButtonProps:{loading:r,disabled:r||!_(t),appearance:""},onDelete:f,entityType:"snapshot",entities:e,deletableEntities:e,disabledReason:_(t)?void 0:"You do not have permission to manage snapshots for this instance",buttonLabel:`Delete ${yt("snapshot",e.length)}`})},dc=({instance:t,close:e,onSuccess:i,onFailure:a})=>{const g=Ee(),{project:w}=nt(),E=Ue(),r=Ke({initialValues:ut(t),validationSchema:vr,onSubmit:u=>{const _=zt(t,u);Yt(_,w??"").then(l=>{g.set(l.metadata.id,()=>{i("Configuration updated.")},f=>{a("Configuration update failed",new Error(f))},()=>{e(),E.invalidateQueries({queryKey:[de.instances]})})}).catch(l=>{a("Configuration update failed",l)})}}),o=u=>{u.key==="Escape"&&e()};return p.jsx(N.Modal,{close:e,className:"edit-snapshot-config",title:"Snapshot configuration",buttonRow:r.values.readOnly?p.jsxs("div",{className:"u-space-between u-flex-row-reverse",children:[p.jsx(N.Button,{className:"u-no-margin--bottom u-no-margin--right",onClick:e,children:"Close"}),p.jsx(N.Button,{className:"u-no-margin--bottom",type:"button",onClick:async()=>r.setFieldValue("readOnly",!1),children:"Edit configuration"})]}):p.jsxs(p.Fragment,{children:[p.jsx(N.Button,{appearance:"base",className:"u-no-margin--bottom",type:"button",onClick:e,children:"Cancel"}),p.jsx(N.ActionButton,{appearance:"positive",className:"u-no-margin--bottom",loading:r.isSubmitting,disabled:r.isSubmitting,onClick:()=>void r.submitForm(),children:"Save"})]}),onKeyDown:o,children:p.jsx(Sr,{formik:r})})},Ds=({instance:t,onSuccess:e,onFailure:i,isDisabled:a,className:g})=>{const{openPortal:w,closePortal:E,isOpen:r,Portal:o}=N.usePortal(),{canEditInstance:u}=Oe();return p.jsxs(p.Fragment,{children:[r&&p.jsx(o,{children:p.jsx("div",{className:"snapshot-list",children:p.jsx(dc,{close:E,instance:t,onSuccess:e,onFailure:i})})}),p.jsx(N.Button,{onClick:w,className:g,disabled:a||!u(t),title:u()?"":"You do not have permission to configure this instance",children:"See configuration"})]})},_c=150,fc=({close:t,instance:e,onSuccess:i})=>{const a=Ee(),g=N.useNotify(),w=Ie(),E=Ue(),r=Z.useState(null),o=Ke({initialValues:{name:"",stateful:!1,expirationDate:null,expirationTime:null},validateOnMount:!0,validationSchema:wr(e,r),onSubmit:(C,{resetForm:S})=>{g.clear();const m=C.expirationDate&&C.expirationTime?rr(fr(C.expirationDate,C.expirationTime)):Oi,s=p.jsx(ue,{instance:e});Xa(e,C.name,m,C.stateful||!1).then(n=>{a.set(n.metadata.id,()=>{E.invalidateQueries({predicate:c=>c.queryKey[0]===de.instances}),i(p.jsxs(p.Fragment,{children:["Snapshot"," ",p.jsx(Dt,{name:ca(n.metadata),instance:e})," ","created for instance ",s,"."]})),S(),t()},c=>{w.failure(`Snapshot creation failed for instance ${e.name}`,new Error(c),s),o.setSubmitting(!1),t()})}).catch(n=>{g.failure("Snapshot creation failed",n,s),o.setSubmitting(!1),t()})}});let u=p.jsxs(p.Fragment,{children:[`To create a stateful snapshot, the instance needs `,"the ",p.jsx("code",{children:"migration.stateful"})," config set to true"]});const _=tc(e),l=e.status==="Running";_&&(u=`To create a stateful snapshot, the instance must be running`),_&&l&&(u="");const f=p.jsx(N.List,{inline:!0,items:[p.jsx(N.Input,{id:"stateful",name:"stateful",type:"checkbox",label:"Stateful",wrapperClassName:"u-inline-block",disabled:!_||!l,onChange:o.handleChange,onBlur:o.handleBlur,defaultChecked:o.values.stateful},"stateful"),...u?[p.jsx(N.Tooltip,{position:"btm-left",message:u,zIndex:_c,children:p.jsx(N.Icon,{name:"information"})},"stateful-info")]:[]]});return p.jsx(_r,{isEdit:!1,formik:o,close:t,additionalFormInput:f})},Ls=({instance:t,onSuccess:e,isDisabled:i,className:a})=>{const{openPortal:g,closePortal:w,isOpen:E,Portal:r}=N.usePortal(),{canManageInstanceSnapshots:o}=Oe();return p.jsxs(p.Fragment,{children:[E&&p.jsx(r,{children:p.jsx(fc,{close:w,instance:t,onSuccess:e})}),p.jsx(N.Button,{appearance:"positive",className:a,onClick:g,disabled:i||!o(t),title:o(t)?"":"You do not have permission to create snapshots for this instance",children:i?p.jsx(N.Tooltip,{message:`Snapshot creation has been disabled for instances in the project ${t.project}`,children:"Create snapshot"}):"Create snapshot"})]})},pc=1250,Ms=()=>window.innerWidth<=pc,mc=t=>{var x,D;const{instance:e}=t,i=or(),[a,g]=Z.useState(""),w=N.useNotify(),E=Ie(),[r,o]=Z.useState([]),[u,_]=Z.useState([]),[l,f]=Z.useState(Ms()),C=T=>{E.success(T)},S=(T,L,B)=>{w.failure(T,L,B)},{project:m,isLoading:s}=fo(),n=qo(m);Z.useEffect(()=>{var B;const T=new Set((B=e.snapshots)==null?void 0:B.map(F=>F.name)),L=r.filter(F=>T.has(F));L.length!==r.length&&o(L)},[e.snapshots]);const c=((x=e.snapshots)==null?void 0:x.filter(T=>!(a&&!T.name.toLowerCase().includes(a.toLowerCase()))))??[],h=e.snapshots&&e.snapshots.length>0,d=[{content:l?p.jsxs(p.Fragment,{children:["Name",p.jsx("br",{}),p.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"}],b=c.map(T=>{const L=p.jsx(lc,{instance:e,snapshot:T,onSuccess:C,onFailure:S});return{key:T.name,className:"u-row",name:T.name,columns:[{content:p.jsxs(p.Fragment,{children:[p.jsx("div",{className:"u-truncate",title:`Snapshot ${T.name}`,children:p.jsx(Pt,{item:T})}),l&&p.jsx("div",{className:"u-text--muted",children:At(T.created_at)})]}),role:"rowheader","aria-label":"Name",className:"name"},...l?[]:[{content:At(T.created_at),role:"rowheader","aria-label":"Created at",className:"created"}],{content:At(T.expires_at),role:"rowheader","aria-label":"Expires at",className:"expiration"},{content:T.stateful?"Yes":"No",role:"rowheader","aria-label":"Stateful",className:"stateful"},{content:L,role:"rowheader","aria-label":"Actions",className:"u-align--right actions"}],sortData:{name:T.name.toLowerCase(),created_at:T.created_at,expires_at:T.expires_at,stateful:T.stateful}}}),{rows:y,updateSort:A}=la({rows:b,defaultSort:"created_at",defaultSortDirection:"descending"});return Ne("resize",()=>{f(Ms())}),s?p.jsx(tt,{}):p.jsxs("div",{className:"snapshot-list",children:[h&&p.jsx("div",{className:"upper-controls-bar",children:r.length===0?p.jsxs(p.Fragment,{children:[p.jsx("div",{className:"search-box-wrapper",children:p.jsx(N.SearchBox,{name:"search-snapshot",className:"search-box margin-right",type:"text",onChange:T=>{g(T)},placeholder:"Search for snapshots",value:a,"aria-label":"Search for snapshots"})}),p.jsx(Ds,{instance:e,className:"u-no-margin--right",onFailure:S,onSuccess:C}),p.jsx(Ls,{instance:e,onSuccess:C,onFailure:S,className:"u-float-right",isDisabled:n})]}):p.jsx("div",{className:"p-panel__controls",children:p.jsx(uc,{instance:e,snapshotNames:r,onStart:()=>{_(r)},onFinish:()=>{_([])},onSuccess:C,onFailure:S})})}),p.jsx(oi,{}),h?p.jsx(p.Fragment,{children:p.jsx(Xi,{dependencies:[c,w.notification],tableId:"instance-snapshot-table",belowIds:["status-bar"],children:p.jsx(N.TablePagination,{data:y,id:"pagination",itemName:"snapshot",className:"u-no-margin--top","aria-label":"Table pagination control",description:r.length>0&&p.jsx(Zo,{totalCount:((D=e.snapshots)==null?void 0:D.length)??0,itemName:"snapshot",parentName:"instance",selectedNames:r,setSelectedNames:o,filteredNames:c.map(T=>T.name)}),children:p.jsx(Xo,{id:"instance-snapshot-table",headers:d,rows:y,sortable:!0,emptyStateMsg:"No snapshot found matching this search",itemName:"snapshot",parentName:"instance",selectedNames:r,setSelectedNames:o,disabledNames:u,filteredNames:c.map(T=>T.name),onUpdateSort:A,defaultSort:"created_at",defaultSortDirection:"descending"})})})}):p.jsxs(N.EmptyState,{className:"empty-state",image:p.jsx(N.Icon,{name:"snapshot",className:"empty-state-icon"}),title:"No snapshots found",children:[p.jsx("p",{children:m&&n?p.jsxs(p.Fragment,{children:["Snapshots are disabled for project"," ",p.jsx(Pt,{item:m,bold:!0}),"."]}):"There are no snapshots of this instance."}),p.jsx("p",{children:p.jsxs("a",{href:`${i}/howto/storage_backup_volume/#storage-backup-snapshots`,target:"_blank",rel:"noopener noreferrer",children:["Learn more about snapshots",p.jsx(N.Icon,{className:"external-link-icon",name:"external-link"})]})}),p.jsx(Ds,{instance:e,onFailure:S,onSuccess:C,isDisabled:n}),p.jsx(Ls,{instance:e,onSuccess:C,onFailure:S,className:"empty-state-button",isDisabled:n})]})]})};var k={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,i){e!==void 0?i!==void 0?this.u8=new Uint8Array(t,e,i):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 i=1,a=0;return e&&(i=0,a=1),this.u8[t+a]<<8|this.u8[t+i]},getUint32:function(t,e){var i=2,a=0;return e&&(i=0,a=2),this.getUint16(t+a,e)<<16|this.getUint16(t+i,e)},getUint64:function(t,e){var i=4,a=0;return e&&(i=0,a=4),this.getUint32(t+a,e)<<32|this.getUint32(t+i,e)},setUint8:function(t,e){this.u8[t]=e&255},setUint16:function(t,e,i){var a=1,g=0;i&&(a=0,g=1),this.u8[t+g]=(e&65535)>>8,this.u8[t+a]=e&255},setUint32:function(t,e,i){var a=2,g=0;i&&(a=0,g=2),this.setUint16(t+g,(e&4294967295)>>16,i),this.setUint16(t+a,e&65535,i)},setUint64:function(t,e,i){var a=4,g=0;i&&(a=0,g=4),this.setUint32(t+g,(e&18446744073709552e3)>>32,i),this.setUint32(t+a,e&4294967295,i)}};var Ze;function te(t,e,i){t!=null&&(typeof t=="number"?this.fromNumber(t,e,i):e==null&&typeof t!="string"?this.fromString(t,256):this.fromString(t,e))}function He(){return new te(null)}function gc(t,e,i,a,g,w){for(;--w>=0;){var E=e*this[t++]+i[a]+g;g=Math.floor(E/67108864),i[a++]=E&67108863}return g}function vc(t,e,i,a,g,w){for(var E=e&32767,r=e>>15;--w>=0;){var o=this[t]&32767,u=this[t++]>>15,_=r*o+u*E;o=E*o+((_&32767)<<15)+i[a]+(g&1073741823),g=(o>>>30)+(_>>>15)+r*u+(g>>>30),i[a++]=o&1073741823}return g}function Sc(t,e,i,a,g,w){for(var E=e&16383,r=e>>14;--w>=0;){var o=this[t]&16383,u=this[t++]>>14,_=r*o+u*E;o=E*o+((_&16383)<<14)+i[a]+g,g=(o>>28)+(_>>14)+r*u,i[a++]=o&268435455}return g}navigator.appName=="Microsoft Internet Explorer"?(te.prototype.am=vc,Ze=30):navigator.appName!="Netscape"?(te.prototype.am=gc,Ze=26):(te.prototype.am=Sc,Ze=28);te.prototype.DB=Ze;te.prototype.DM=(1<<Ze)-1;te.prototype.DV=1<<Ze;var Qi=52;te.prototype.FV=Math.pow(2,Qi);te.prototype.F1=Qi-Ze;te.prototype.F2=2*Ze-Qi;var bc="0123456789abcdefghijklmnopqrstuvwxyz",ci=new Array,ft,Re;ft=48;for(Re=0;Re<=9;++Re)ci[ft++]=Re;ft=97;for(Re=10;Re<36;++Re)ci[ft++]=Re;ft=65;for(Re=10;Re<36;++Re)ci[ft++]=Re;function Ts(t){return bc.charAt(t)}function Cc(t,e){var i=ci[t.charCodeAt(e)];return i??-1}function Ec(t){for(var e=this.t-1;e>=0;--e)t[e]=this[e];t.t=this.t,t.s=this.s}function yc(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 xr(t){var e=He();return e.fromInt(t),e}function wc(t,e){var i;if(e==16)i=4;else if(e==8)i=3;else if(e==256)i=8;else if(e==2)i=1;else if(e==32)i=5;else if(e==4)i=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 E=i==8?t[a]&255:Cc(t,a);if(E<0){t.charAt(a)=="-"&&(g=!0);continue}g=!1,w==0?this[this.t++]=E:w+i>this.DB?(this[this.t-1]|=(E&(1<<this.DB-w)-1)<<w,this[this.t++]=E>>this.DB-w):this[this.t-1]|=E<<w,w+=i,w>=this.DB&&(w-=this.DB)}i==8&&t[0]&128&&(this.s=-1,w>0&&(this[this.t-1]|=(1<<this.DB-w)-1<<w)),this.clamp(),g&&te.ZERO.subTo(this,this)}function xc(){for(var t=this.s&this.DM;this.t>0&&this[this.t-1]==t;)--this.t}function Ac(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 i=(1<<e)-1,a,g=!1,w="",E=this.t,r=this.DB-E*this.DB%e;if(E-- >0)for(r<this.DB&&(a=this[E]>>r)>0&&(g=!0,w=Ts(a));E>=0;)r<e?(a=(this[E]&(1<<r)-1)<<e-r,a|=this[--E]>>(r+=this.DB-e)):(a=this[E]>>(r-=e)&i,r<=0&&(r+=this.DB,--E)),a>0&&(g=!0),g&&(w+=Ts(a));return g?w:"0"}function Ic(){var t=He();return te.ZERO.subTo(this,t),t}function Pc(){return this.s<0?this.negate():this}function Dc(t){var e=this.s-t.s;if(e!=0)return e;var i=this.t;if(e=i-t.t,e!=0)return e;for(;--i>=0;)if((e=this[i]-t[i])!=0)return e;return 0}function Zi(t){var e=1,i;return(i=t>>>16)!=0&&(t=i,e+=16),(i=t>>8)!=0&&(t=i,e+=8),(i=t>>4)!=0&&(t=i,e+=4),(i=t>>2)!=0&&(t=i,e+=2),(i=t>>1)!=0&&(t=i,e+=1),e}function Lc(){return this.t<=0?0:this.DB*(this.t-1)+Zi(this[this.t-1]^this.s&this.DM)}function Mc(t,e){var i;for(i=this.t-1;i>=0;--i)e[i+t]=this[i];for(i=t-1;i>=0;--i)e[i]=0;e.t=this.t+t,e.s=this.s}function Tc(t,e){for(var i=t;i<this.t;++i)e[i-t]=this[i];e.t=Math.max(this.t-t,0),e.s=this.s}function Rc(t,e){var i=t%this.DB,a=this.DB-i,g=(1<<a)-1,w=Math.floor(t/this.DB),E=this.s<<i&this.DM,r;for(r=this.t-1;r>=0;--r)e[r+w+1]=this[r]>>a|E,E=(this[r]&g)<<i;for(r=w-1;r>=0;--r)e[r]=0;e[w]=E,e.t=this.t+w+1,e.s=this.s,e.clamp()}function kc(t,e){e.s=this.s;var i=Math.floor(t/this.DB);if(i>=this.t){e.t=0;return}var a=t%this.DB,g=this.DB-a,w=(1<<a)-1;e[0]=this[i]>>a;for(var E=i+1;E<this.t;++E)e[E-i-1]|=(this[E]&w)<<g,e[E-i]=this[E]>>a;a>0&&(e[this.t-i-1]|=(this.s&w)<<g),e.t=this.t-i,e.clamp()}function Bc(t,e){for(var i=0,a=0,g=Math.min(t.t,this.t);i<g;)a+=this[i]-t[i],e[i++]=a&this.DM,a>>=this.DB;if(t.t<this.t){for(a-=t.s;i<this.t;)a+=this[i],e[i++]=a&this.DM,a>>=this.DB;a+=this.s}else{for(a+=this.s;i<t.t;)a-=t[i],e[i++]=a&this.DM,a>>=this.DB;a-=t.s}e.s=a<0?-1:0,a<-1?e[i++]=this.DV+a:a>0&&(e[i++]=a),e.t=i,e.clamp()}function Oc(t,e){var i=this.abs(),a=t.abs(),g=i.t;for(e.t=g+a.t;--g>=0;)e[g]=0;for(g=0;g<a.t;++g)e[g+i.t]=i.am(0,a[g],e,g,0,i.t);e.s=0,e.clamp(),this.s!=t.s&&te.ZERO.subTo(e,e)}function Nc(t){for(var e=this.abs(),i=t.t=2*e.t;--i>=0;)t[i]=0;for(i=0;i<e.t-1;++i){var a=e.am(i,e[i],t,2*i,0,1);(t[i+e.t]+=e.am(i+1,2*e[i],t,2*i+1,a,e.t-i-1))>=e.DV&&(t[i+e.t]-=e.DV,t[i+e.t+1]=1)}t.t>0&&(t[t.t-1]+=e.am(i,e[i],t,2*i,0,1)),t.s=0,t.clamp()}function Uc(t,e,i){var a=t.abs();if(!(a.t<=0)){var g=this.abs();if(g.t<a.t){e!=null&&e.fromInt(0),i!=null&&this.copyTo(i);return}i==null&&(i=He());var w=He(),E=this.s,r=t.s,o=this.DB-Zi(a[a.t-1]);o>0?(a.lShiftTo(o,w),g.lShiftTo(o,i)):(a.copyTo(w),g.copyTo(i));var u=w.t,_=w[u-1];if(_!=0){var l=_*(1<<this.F1)+(u>1?w[u-2]>>this.F2:0),f=this.FV/l,C=(1<<this.F1)/l,S=1<<this.F2,m=i.t,s=m-u,n=e??He();for(w.dlShiftTo(s,n),i.compareTo(n)>=0&&(i[i.t++]=1,i.subTo(n,i)),te.ONE.dlShiftTo(u,n),n.subTo(w,w);w.t<u;)w[w.t++]=0;for(;--s>=0;){var c=i[--m]==_?this.DM:Math.floor(i[m]*f+(i[m-1]+S)*C);if((i[m]+=w.am(0,c,i,s,0,u))<c)for(w.dlShiftTo(s,n),i.subTo(n,i);i[m]<--c;)i.subTo(n,i)}e!=null&&(i.drShiftTo(u,e),E!=r&&te.ZERO.subTo(e,e)),i.t=u,i.clamp(),o>0&&i.rShiftTo(o,i),E<0&&te.ZERO.subTo(i,i)}}}function jc(t){var e=He();return this.abs().divRemTo(t,null,e),this.s<0&&e.compareTo(te.ZERO)>0&&t.subTo(e,e),e}function pt(t){this.m=t}function Fc(t){return t.s<0||t.compareTo(this.m)>=0?t.mod(this.m):t}function Hc(t){return t}function Kc(t){t.divRemTo(this.m,null,t)}function Gc(t,e,i){t.multiplyTo(e,i),this.reduce(i)}function Yc(t,e){t.squareTo(e),this.reduce(e)}pt.prototype.convert=Fc;pt.prototype.revert=Hc;pt.prototype.reduce=Kc;pt.prototype.mulTo=Gc;pt.prototype.sqrTo=Yc;function zc(){if(this.t<1)return 0;var t=this[0];if(!(t&1))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 mt(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 Wc(t){var e=He();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 $c(t){var e=He();return t.copyTo(e),this.reduce(e),e}function qc(t){for(;t.t<=this.mt2;)t[t.t++]=0;for(var e=0;e<this.m.t;++e){var i=t[e]&32767,a=i*this.mpl+((i*this.mph+(t[e]>>15)*this.mpl&this.um)<<15)&t.DM;for(i=e+this.m.t,t[i]+=this.m.am(0,a,t,e,0,this.m.t);t[i]>=t.DV;)t[i]-=t.DV,t[++i]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)}function Vc(t,e){t.squareTo(e),this.reduce(e)}function Xc(t,e,i){t.multiplyTo(e,i),this.reduce(i)}mt.prototype.convert=Wc;mt.prototype.revert=$c;mt.prototype.reduce=qc;mt.prototype.mulTo=Xc;mt.prototype.sqrTo=Vc;function Qc(){return(this.t>0?this[0]&1:this.s)==0}function Zc(t,e){if(t>4294967295||t<1)return te.ONE;var i=He(),a=He(),g=e.convert(this),w=Zi(t)-1;for(g.copyTo(i);--w>=0;)if(e.sqrTo(i,a),(t&1<<w)>0)e.mulTo(a,g,i);else{var E=i;i=a,a=E}return e.revert(i)}function Jc(t,e){var i;return t<256||e.isEven()?i=new pt(e):i=new mt(e),this.exp(t,i)}te.prototype.copyTo=Ec;te.prototype.fromInt=yc;te.prototype.fromString=wc;te.prototype.clamp=xc;te.prototype.dlShiftTo=Mc;te.prototype.drShiftTo=Tc;te.prototype.lShiftTo=Rc;te.prototype.rShiftTo=kc;te.prototype.subTo=Bc;te.prototype.multiplyTo=Oc;te.prototype.squareTo=Nc;te.prototype.divRemTo=Uc;te.prototype.invDigit=zc;te.prototype.isEven=Qc;te.prototype.exp=Zc;te.prototype.toString=Ac;te.prototype.negate=Ic;te.prototype.abs=Pc;te.prototype.compareTo=Dc;te.prototype.bitLength=Lc;te.prototype.mod=jc;te.prototype.modPowInt=Jc;te.ZERO=xr(0);te.ONE=xr(1);function Ji(){this.i=0,this.j=0,this.S=new Array}function eh(t){var e,i,a;for(e=0;e<256;++e)this.S[e]=e;for(i=0,e=0;e<256;++e)i=i+this.S[e]+t[e%t.length]&255,a=this.S[e],this.S[e]=this.S[i],this.S[i]=a;this.i=0,this.j=0}function th(){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]}Ji.prototype.init=eh;Ji.prototype.next=th;function ih(){return new Ji}var Ni=256,jt,Te,be;function sh(t){Te[be++]^=t&255,Te[be++]^=t>>8&255,Te[be++]^=t>>16&255,Te[be++]^=t>>24&255,be>=Ni&&(be-=Ni)}function Ar(){sh(new Date().getTime())}if(Te==null){Te=new Array,be=0;var st;if(navigator.appName=="Netscape"&&navigator.appVersion<"5"&&window.crypto){var Rs=window.crypto.random(32);for(st=0;st<Rs.length;++st)Te[be++]=Rs.charCodeAt(st)&255}for(;be<Ni;)st=Math.floor(65536*Math.random()),Te[be++]=st>>>8,Te[be++]=st&255;be=0,Ar()}function rh(){if(jt==null){for(Ar(),jt=ih(),jt.init(Te),be=0;be<Te.length;++be)Te[be]=0;be=0}return jt.next()}function nh(t){var e;for(e=0;e<t.length;++e)t[e]=rh()}function es(){}es.prototype.nextBytes=nh;function oh(t,e){return new te(t,e)}function ah(t,e){if(e<t.length+11)return alert("Message too long for RSA"),null;for(var i=new Array,a=t.length-1;a>=0&&e>0;){var g=t.charCodeAt(a--);g<128?i[--e]=g:g>127&&g<2048?(i[--e]=g&63|128,i[--e]=g>>6|192):(i[--e]=g&63|128,i[--e]=g>>6&63|128,i[--e]=g>>12|224)}i[--e]=0;for(var w=new es,E=new Array;e>2;){for(E[0]=0;E[0]==0;)w.nextBytes(E);i[--e]=E[0]}return i[--e]=2,i[--e]=0,new te(i)}function hi(){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 ch(t,e){t!=null&&e!=null&&t.length>0&&e.length>0?(this.n=oh(t,16),this.e=parseInt(e,16)):alert("Invalid RSA public key")}function hh(t){return t.modPowInt(this.e,this.n)}function lh(t){var e=ah(t,this.n.bitLength()+7>>3);if(e==null)return null;var i=this.doPublic(e);if(i==null)return null;var a=i.toString(16);return a.length&1?"0"+a:a}hi.prototype.doPublic=hh;hi.prototype.setPublic=ch;hi.prototype.encrypt=lh;var ks=0;function uh(t){return dh(ts(_h(t)))}function ts(t){return ph(mh(fh(t),t.length*8))}function dh(t){for(var e=ks?"0123456789ABCDEF":"0123456789abcdef",i="",a,g=0;g<t.length;g++)a=t.charCodeAt(g),i+=e.charAt(a>>>4&15)+e.charAt(a&15);return i}function _h(t){for(var e="",i=-1,a,g;++i<t.length;)a=t.charCodeAt(i),g=i+1<t.length?t.charCodeAt(i+1):0,55296<=a&&a<=56319&&56320<=g&&g<=57343&&(a=65536+((a&1023)<<10)+(g&1023),i++),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 fh(t){for(var e=Array(t.length>>2),i=0;i<e.length;i++)e[i]=0;for(var i=0;i<t.length*8;i+=8)e[i>>5]|=(t.charCodeAt(i/8)&255)<<24-i%32;return e}function ph(t){for(var e="",i=0;i<t.length*32;i+=8)e+=String.fromCharCode(t[i>>5]>>>24-i%32&255);return e}function mh(t,e){t[e>>5]|=128<<24-e%32,t[(e+64>>9<<4)+15]=e;for(var i=Array(80),a=1732584193,g=-271733879,w=-1732584194,E=271733878,r=-1009589776,o=0;o<t.length;o+=16){for(var u=a,_=g,l=w,f=E,C=r,S=0;S<80;S++){S<16?i[S]=t[o+S]:i[S]=Li(i[S-3]^i[S-8]^i[S-14]^i[S-16],1);var m=Ye(Ye(Li(a,5),gh(S,g,w,E)),Ye(Ye(r,i[S]),vh(S)));r=E,E=w,w=Li(g,30),g=a,a=m}a=Ye(a,u),g=Ye(g,_),w=Ye(w,l),E=Ye(E,f),r=Ye(r,C)}return Array(a,g,w,E,r)}function gh(t,e,i,a){return t<20?e&i|~e&a:t<40?e^i^a:t<60?e&i|e&a|i&a:e^i^a}function vh(t){return t<20?1518500249:t<40?1859775393:t<60?-1894007588:-899497514}function Ye(t,e){var i=(t&65535)+(e&65535),a=(t>>16)+(e>>16)+(i>>16);return a<<16|i&65535}function Li(t,e){return t<<e|t>>>32-e}var Mi=20;function Bs(t,e){var i,a,g;for(i=0,g=0;g<t.length;i++){var w=new String;for(a=0;a<e.length;a++)w+=String.fromCharCode(e[a]);w+=String.fromCharCode(i>>24&255),w+=String.fromCharCode(i>>16&255),w+=String.fromCharCode(i>>8&255),w+=String.fromCharCode(i&255);var E=ts(w);for(a=0;a<E.length&&g<t.length;a++,g++)t[g]=E.charCodeAt(a)}}function Sh(t,e,i){var a=new Array(Mi),g=new es;g.nextBytes(a);var w=t-1-a.length,E=new Array(w),r=w-e.length-1,o;if(i===void 0&&(i=""),r<Mi)return console.log("Error - data too large for key size."),null;for(o=0;o<r;o++)E[o]=0;var u=ts(i);for(o=0;o<u.length;o++)E[o]=u.charCodeAt(o);for(E[r]=1,o=0;o<e.length;o++)E[o+r+1]=e.charCodeAt(o);var _=new Array(w);if(Bs(_,a)<0)return null;for(o=0;o<_.length;o++)E[o]^=_[o];var l=Array(Mi);if(Bs(l,E)<0)return null;for(o=0;o<l.length;o++)a[o]^=l[o];var f=new String;for(f+="\0",o=0;o<a.length;o++)f+=String.fromCharCode(a[o]);for(o=0;o<E.length;o++)f+=String.fromCharCode(E[o]);return f}function Gt(t,e){var i=t[e++];if(i>128){if(i!=129)return console.log("Error: we lazily don't support keys bigger than 255 bytes. It'd be easy to fix."),null;i=t[e++]}return[e,i]}function Ti(t,e){var i;return e=e||0,t[e++]!=48?(console.log("Error: public key should start with a sequence flag."),null):(i=Gt(t,e),i||null)}function bh(t,e){var i=new Uint8Array(t),a,g,w,E,r;if(g=Ti(i,e),!g||(e=g[0],g=Ti(i,e),!g))return null;if(e=g[0]+g[1],i[e++]!=3)return console.log("Error: expecting bit string next."),null;if(a=Gt(i,e),!a)return null;if(e=a[0],i[e]!=0&&i[e+1]!=48)return console.log("Error: unexpected values in bit string."),null;if(g=Ti(i,e+1),!g)return null;if(e=g[0],i[e++]!=2)return console.log("Error: expecting integer n next."),null;if(a=Gt(i,e),!a)return null;for(e=a[0],w=new Array(a[1]),E=0;E<a[1];E++)w[E]=i[e+E];if(r=new hi,r.n=new te(w),e+=a[1],i[e++]!=2)return console.log("Error: expecting integer e next."),null;if(a=Gt(i,e),!a)return null;for(e=a[0],r.e=i[e++],E=1;E<a[1];E++)r.e<<=8,r.e|=i[e++];return r}function Ch(t,e){var i,a=[],g=Sh(t.n.bitLength()+7>>3,e);if(!g)return null;var w=new Array(g.length);for(i=0;i<g.length;i++)w[i]=g.charCodeAt(i);var E=new te(w),r=t.doPublic(E),o=r.toString(16);for(o.length&1&&(o="0"+o),i=0;i<o.length;i+=2)a[i/2]=parseInt(o.substring(i,i+2),16);return a}var Ve,Ce={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},Eh=3,yh=6,wh=2048,Os=!0,Ns=26,Ir=Eh,et=yh,dt=wh,xh={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]},fe={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]},Ae=[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],Pr=[],Ah=[[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]],Ui=[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],Ft=[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],Ih=[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,De=2,Le=1,Me=0,ne=4;function Us(t){if(t===1)return 0;var e=1;for(t-=1;t=t>>>1;)e++;return e}function js(t,e,i){var a;for(a=0;a<e;a++){var g,w;g=i-e,g>Ae[e-a]&&(g=Ae[e-a]),w=Ae[e]+1-(g<<a),t.nGRcodewords[a]=g<<a,t.notGRcwlen[a]=g+Us(w),t.notGRprefixmask[a]=Ae[32-g]>>>0,t.notGRsuffixlen[a]=Us(w)}var E=Ae[e],r=E>>>1,o;for(o=0;o<=E;o++)o<=r?t.xlatU2L[o]=o<<1:t.xlatU2L[o]=(E-o<<1)+1;for(o=0;o<=E;o++)o&1?t.xlatL2U[o]=E-(o>>>1):t.xlatL2U[o]=o>>>1}function Ph(t){switch(t){case Ce.QUIC_IMAGE_TYPE_GRAY:return 8;case Ce.QUIC_IMAGE_TYPE_RGB16:return 5;case Ce.QUIC_IMAGE_TYPE_RGB24:return 8;case Ce.QUIC_IMAGE_TYPE_RGB32:return 8;case Ce.QUIC_IMAGE_TYPE_RGBA:return 8;case Ce.QUIC_IMAGE_TYPE_INVALID:default:return console.log(`quic: bad image type `),0}}function Dh(t){return t&4286578688?Ft[t>>>24]:t&4294934528?8+Ft[t>>>16&255]:t&4294967168?16+Ft[t>>>8&255]:24+Ft[t&255]}function Be(t,e){var i,a;if(e<0||e>fe.notGRprefixmask[t]){var g=Dh(e);a=g+1+t,i=g<<t|e>>32-a&Ae[t]}else a=fe.notGRcwlen[t],i=fe.nGRcodewords[t]+(e>>32-a&Ae[fe.notGRsuffixlen[t]]);return{codewordlen:a,rc:i}}function Fs(t,e){return t<fe.nGRcodewords[e]?(t>>>e)+1+e:fe.notGRcwlen[e]}function ji(t){var e,i=0;switch(this.levels=1<<t,this.n_buckets_ptrs=0,Ir){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=i+1:e=0,--a||(a=this.repnext,g*=this.mulsize),i=e+g-1,i+g>=this.levels&&(i=this.levels-1),this.n_buckets_ptrs||(this.n_buckets_ptrs=this.levels),this.n_buckets++;while(i<this.levels-1)}ji.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,i){var a,g=i-1,w=this.counters[g]+=Fs(e,g);for(a=i-2;a>=0;a--){var E=this.counters[a]+=Fs(e,a);E<w&&(g=a,w=E)}if(this.bestcode=g,w>t.wm_trigger)for(a=0;a<i;a++)this.counters[a]=this.counters[a]>>>1}};function Fi(){this.buckets_ptrs=[],this.buckets_buf=[]}Fi.prototype={fill_model_structures:function(t){var e,i=0,a=0,g=t.repfirst+1,w=t.firstsize;do{a?e=i+1:e=0,--g||(g=t.repnext,w*=t.mulsize),i=e+w-1,i+w>=t.levels&&(i=t.levels-1),this.buckets_buf[a]=new Dr;var E;for(E=e;E<=i;E++)this.buckets_ptrs[E]=this.buckets_buf[a];a++}while(i<t.levels-1);return!0}};function Lr(t,e){this.state=new is,this.family_stat_8bpc=new Fi,this.family_stat_5bpc=new Fi,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)}Lr.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 is(){}is.prototype={waitcnt:0,tabrand_seed:255,wm_trigger:0,wmidx:0,wmileft:dt,melcstate:0,melclen:0,melcorder:0,set_wm_trigger:function(){var t=this.wmidx;t>10&&(t=10),this.wm_trigger=Ah[Math.floor(Ir/2)][t]},reste:function(){this.waitcnt=0,this.tabrand_seed=255,this.wmidx=0,this.wmileft=dt,this.set_wm_trigger(),this.melcstate=0,this.melclen=Ui[0],this.melcorder=1<<this.melclen},tabrand:function(){return this.tabrand_seed++,Ih[this.tabrand_seed&255]}};function pe(){this.rgb_state=new is,this.model_8bpc=new ji(8),this.model_5bpc=new ji(5),this.channels=[];var t;for(t=0;t<4;t++)if(this.channels[t]=new Lr(this.model_8bpc,this.model_5bpc),!this.channels[t]){console.log("quic: failed to create channel");return}}pe.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};pe.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};pe.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};pe.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)};pe.prototype.decode_eat32bits=function(){this.decode_eatbits(16),this.decode_eatbits(16)};pe.prototype.reste_channels=function(t){var e;for(e=0;e<4;e++)if(!this.channels[e].reste(t))return!1;return!0};pe.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 i=this.io_word;if(this.decode_eat32bits(),i!=0)return console.log("quic: bad version "+i.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=Ph(this.type);return!!this.reste_channels(a)};pe.prototype.quic_rgb32_uncompress_row0_seg=function(t,e,i,a,g,w){var E,r=3,o,u;if(t)E=t+this.rgb_state.waitcnt;else{e[re]=0,o=0;do u=Be(this.channels[o].buckets_ptrs[this.channels[o].correlate_row.zero].bestcode,this.io_word),this.channels[o].correlate_row.row[0]=u.rc,e[2-o]=fe.xlatL2U[u.rc]&255,this.decode_eatbits(u.codewordlen);while(++o<r);if(this.rgb_state.waitcnt)--this.rgb_state.waitcnt;else{this.rgb_state.waitcnt=this.rgb_state.tabrand()&a,o=0;do this.channels[o].buckets_ptrs[this.channels[o].correlate_row.zero].update_model_8bpc(this.rgb_state,this.channels[o].correlate_row.row[0],g);while(++o<r)}E=++t+this.rgb_state.waitcnt}for(;E<i;){for(;t<=E;t++){e[t*ne+re]=0,o=0;do u=Be(this.channels[o].buckets_ptrs[this.channels[o].correlate_row.row[t-1]].bestcode,this.io_word),this.channels[o].correlate_row.row[t]=u.rc,e[t*ne+(2-o)]=fe.xlatL2U[u.rc]+e[(t-1)*ne+(2-o)]&w,this.decode_eatbits(u.codewordlen);while(++o<r)}o=0;do this.channels[o].buckets_ptrs[this.channels[o].correlate_row.row[E-1]].update_model_8bpc(this.rgb_state,this.channels[o].correlate_row.row[E],g);while(++o<r);E=t+(this.rgb_state.tabrand()&a)}for(;t<i;t++){e[t*ne+re]=0,o=0;do u=Be(this.channels[o].buckets_ptrs[this.channels[o].correlate_row.row[t-1]].bestcode,this.io_word),this.channels[o].correlate_row.row[t]=u.rc,e[t*ne+(2-o)]=fe.xlatL2U[u.rc]+e[(t-1)*ne+(2-o)]&w,this.decode_eatbits(u.codewordlen);while(++o<r)}this.rgb_state.waitcnt=E-i};pe.prototype.quic_rgb32_uncompress_row0=function(t){for(var e=8,i=255,a=0,g=this.width;et>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,Ae[this.rgb_state.wmidx],e,i),a+=this.rgb_state.wmileft,g-=this.rgb_state.wmileft),this.rgb_state.wmidx++,this.rgb_state.set_wm_trigger(),this.rgb_state.wmileft=dt;g&&(this.quic_rgb32_uncompress_row0_seg(a,t,a+g,Ae[this.rgb_state.wmidx],e,i),et>this.rgb_state.wmidx&&(this.rgb_state.wmileft-=g))};pe.prototype.quic_rgb32_uncompress_row_seg=function(t,e,i,a,g,w){var E=3,r=Ae[this.rgb_state.wmidx],o,u=0,_=0,l=0,f;if(i)_=i+this.rgb_state.waitcnt;else{e[re]=0,f=0;do o=Be(this.channels[f].buckets_ptrs[this.channels[f].correlate_row.zero].bestcode,this.io_word),this.channels[f].correlate_row.row[0]=o.rc,e[2-f]=fe.xlatL2U[this.channels[f].correlate_row.row[0]]+t[2-f]&w,this.decode_eatbits(o.codewordlen);while(++f<E);if(this.rgb_state.waitcnt)--this.rgb_state.waitcnt;else{this.rgb_state.waitcnt=this.rgb_state.tabrand()&r,f=0;do this.channels[f].buckets_ptrs[this.channels[f].correlate_row.zero].update_model_8bpc(this.rgb_state,this.channels[f].correlate_row.row[0],g);while(++f<E)}_=++i+this.rgb_state.waitcnt}for(;;){for(var C=0;_<a&&!C;){for(;i<=_&&!C;i++){var S=i*ne,m=(i-1)*ne,s=(i-2)*ne;if(t[m+De]==t[S+De]&&t[m+Le]==t[S+Le]&&t[m+Me]==t[S+Me]&&u!=i&&i>2&&e[m+De]==e[s+De]&&e[m+Le]==e[s+Le]&&e[m+Me]==e[s+Me]){for(this.rgb_state.waitcnt=_-i,u=i,l=i+this.decode_run(this.rgb_state);i<l;i++){var S=i*ne,m=(i-1)*ne;e[S+re]=0,e[S+De]=e[m+De],e[S+Le]=e[m+Le],e[S+Me]=e[m+Me]}if(i==a)return;_=i+this.rgb_state.waitcnt,C=1;break}f=0,e[S+re]=0;do{var n=this.channels[f],c=n.correlate_row;o=Be(n.buckets_ptrs[c.row[i-1]].bestcode,this.io_word),c.row[i]=o.rc,e[S+(2-f)]=fe.xlatL2U[o.rc]+(e[m+(2-f)]+t[S+(2-f)]>>1)&w,this.decode_eatbits(o.codewordlen)}while(++f<E)}if(C)break;f=0;do this.channels[f].buckets_ptrs[this.channels[f].correlate_row.row[_-1]].update_model_8bpc(this.rgb_state,this.channels[f].correlate_row.row[_],g);while(++f<E);_=i+(this.rgb_state.tabrand()&r)}for(;i<a&&!C;i++){var S=i*ne,m=(i-1)*ne,s=(i-2)*ne;if(t[m+De]==t[S+De]&&t[m+Le]==t[S+Le]&&t[m+Me]==t[S+Me]&&u!=i&&i>2&&e[m+De]==e[s+De]&&e[m+Le]==e[s+Le]&&e[m+Me]==e[s+Me]){for(this.rgb_state.waitcnt=_-i,u=i,l=i+this.decode_run(this.rgb_state);i<l;i++){var S=i*ne,m=(i-1)*ne;e[S+re]=0,e[S+De]=e[m+De],e[S+Le]=e[m+Le],e[S+Me]=e[m+Me]}if(i==a)return;_=i+this.rgb_state.waitcnt,C=1;break}e[S+re]=0,f=0;do o=Be(this.channels[f].buckets_ptrs[this.channels[f].correlate_row.row[i-1]].bestcode,this.io_word),this.channels[f].correlate_row.row[i]=o.rc,e[S+(2-f)]=fe.xlatL2U[o.rc]+(e[m+(2-f)]+t[S+(2-f)]>>1)&w,this.decode_eatbits(o.codewordlen);while(++f<E)}if(!C){this.rgb_state.waitcnt=_-a;return}}};pe.prototype.decode_run=function(t){var e=0;do{var i,a=~(this.io_word>>>24)>>>0&255,g=Pr[a];for(i=1;i<=g;i++)e+=t.melcorder,t.melcstate<32&&(t.melclen=Ui[++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=Ui[--t.melcstate],t.melcorder=1<<t.melclen),e};pe.prototype.quic_rgb32_uncompress_row=function(t,e){for(var i=8,a=255,g=0,w=this.width;et>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,i,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=dt;w&&(this.quic_rgb32_uncompress_row_seg(t,e,g,g+w,i,a),et>this.rgb_state.wmidx&&(this.rgb_state.wmileft-=w))};pe.prototype.quic_four_uncompress_row0_seg=function(t,e,i,a,g,w,E,r){var o,u;for(e==0?(u=Be(t.buckets_ptrs[i.zero].bestcode,this.io_word),i.row[0]=u.rc,a[re]=fe.xlatL2U[u.rc],this.decode_eatbits(u.codewordlen),t.state.waitcnt?--t.state.waitcnt:(t.state.waitcnt=t.state.tabrand()&w,t.buckets_ptrs[i.zero].update_model_8bpc(t.state,i.row[0],E)),o=++e+t.state.waitcnt):o=e+t.state.waitcnt;o<g;){for(var _;e<=o;e++)_=t.buckets_ptrs[i.row[e-1]],u=Be(_.bestcode,this.io_word),i.row[e]=u.rc,a[e*ne+re]=fe.xlatL2U[u.rc]+a[(e-1)*ne+re]&r,this.decode_eatbits(u.codewordlen);_.update_model_8bpc(t.state,i.row[o],E),o=e+(t.state.tabrand()&w)}for(;e<g;e++)u=Be(t.buckets_ptrs[i.row[e-1]].bestcode,this.io_word),i.row[e]=u.rc,a[e*ne+re]=fe.xlatL2U[u.rc]+a[(e-1)*ne+re]&r,this.decode_eatbits(u.codewordlen);t.state.waitcnt=o-g};pe.prototype.quic_four_uncompress_row0=function(t,e){for(var i=8,a=255,g=t.correlate_row,w=0,E=this.width;et>t.state.wmidx&&t.state.wmileft<=E;)t.state.wmileft&&(this.quic_four_uncompress_row0_seg(t,w,g,e,w+t.state.wmileft,Ae[t.state.wmidx],i,a),w+=t.state.wmileft,E-=t.state.wmileft),t.state.wmidx++,t.state.set_wm_trigger(),t.state.wmileft=dt;E&&(this.quic_four_uncompress_row0_seg(t,w,g,e,w+E,Ae[t.state.wmidx],i,a),et>t.state.wmidx&&(t.state.wmileft-=E))};pe.prototype.quic_four_uncompress_row_seg=function(t,e,i,a,g,w,E,r){var o=Ae[t.state.wmidx],u,_=0,l,f;for(g==0?(f=Be(t.buckets_ptrs[e.zero].bestcode,this.io_word),e.row[0]=f.rc,a[re]=fe.xlatL2U[f.rc]+i[re]&r,this.decode_eatbits(f.codewordlen),t.state.waitcnt?--t.state.waitcnt:(t.state.waitcnt=t.state.tabrand()&o,t.buckets_ptrs[e.zero].update_model_8bpc(t.state,e.row[0],E)),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 m=g*ne,s=(g-1)*ne,n=(g-2)*ne;if(i[s+re]==i[m+re]&&_!=g&&g>2&&a[s+re]==a[n+re]){for(t.state.waitcnt=u-g,_=g,l=g+this.decode_run(t.state);g<l;g++){var m=g*ne,s=(g-1)*ne;a[m+re]=a[s+re]}if(g==w)return;u=g+t.state.waitcnt,C=1;break}S=t.buckets_ptrs[e.row[g-1]],f=Be(S.bestcode,this.io_word),e.row[g]=f.rc,a[m+re]=fe.xlatL2U[f.rc]+(a[s+re]+i[m+re]>>1)&r,this.decode_eatbits(f.codewordlen)}if(C)break;S.update_model_8bpc(t.state,e.row[u],E),u=g+(t.state.tabrand()&o)}for(;g<w&&!C;g++){var m=g*ne,s=(g-1)*ne,n=(g-2)*ne;if(i[s+re]==i[m+re]&&_!=g&&g>2&&a[s+re]==a[n+re]){for(t.state.waitcnt=u-g,_=g,l=g+this.decode_run(t.state);g<l;g++){var m=g*ne,s=(g-1)*ne;a[m+re]=a[s+re]}if(g==w)return;u=g+t.state.waitcnt,C=1;break}f=Be(t.buckets_ptrs[e.row[g-1]].bestcode,this.io_word),e.row[g]=f.rc,a[m+re]=fe.xlatL2U[f.rc]+(a[s+re]+i[m+re]>>1)&r,this.decode_eatbits(f.codewordlen)}if(!C){t.state.waitcnt=u-w;return}}};pe.prototype.quic_four_uncompress_row=function(t,e,i){for(var a=8,g=255,w=t.correlate_row,E=0,r=this.width;et>t.state.wmidx&&t.state.wmileft<=r;)t.state.wmileft&&(this.quic_four_uncompress_row_seg(t,w,e,i,E,E+t.state.wmileft,a,g),E+=t.state.wmileft,r-=t.state.wmileft),t.state.wmidx++,t.state.set_wm_trigger(),t.state.wmileft=dt;r&&(this.quic_four_uncompress_row_seg(t,w,e,i,E,E+r,a,g),et>t.state.wmidx&&(t.state.wmileft-=r))};pe.prototype.quic_decode=function(t,e){var i;switch(this.type){case Ce.QUIC_IMAGE_TYPE_RGB32:case Ce.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++,i=1;i<this.height;i++){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 Ce.QUIC_IMAGE_TYPE_RGB16:return console.log(`quic: unsupported output format `),!1;case Ce.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++,i=1;i<this.height;i++){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(Ve.channels[3],a,t),this.rows_completed++}break;case Ce.QUIC_IMAGE_TYPE_GRAY:return console.log(`quic: unsupported output format `),!1;case Ce.QUIC_IMAGE_TYPE_INVALID:default:return console.log(`quic: bad image type `),!1}return!0};pe.prototype.simple_quic_decode=function(t){var e=4;if(this.quic_decode_begin(t)&&!(this.type!=Ce.QUIC_IMAGE_TYPE_RGB32&&this.type!=Ce.QUIC_IMAGE_TYPE_RGB24&&this.type!=Ce.QUIC_IMAGE_TYPE_RGBA)){var i=new Uint8Array(this.width*this.height*4);if(i[0]=69,this.quic_decode(i,this.width*e))return i}};function Mr(){}Mr.prototype={from_dv:function(t,e,i){if(!Ve)throw"quic: no quic encoder";this.data_size=t.getUint32(e,!0),e+=4;var a=new Uint8Array(i.slice(e));return this.outptr=Ve.simple_quic_decode(a),this.outptr&&(this.type=Ve.type,this.width=Ve.width,this.height=Ve.height),e+=a.length,e}};function Lh(t,e){var i=t.createImageData(e.width,e.height),a;for(a=0;a<i.width*i.height*4;a+=4)i.data[a+0]=e.outptr[a+2],i.data[a+1]=e.outptr[a+1],i.data[a+2]=e.outptr[a+0],e.type!==Ce.QUIC_IMAGE_TYPE_RGBA?i.data[a+3]=255:i.data[a+3]=255-e.outptr[a+3];return i}if(Os){Os=!1,js(fe,8,Ns),js(xh,5,Ns);var Ht,Ri,Kt,ki;for(Ri=Kt=1,ki=8,Ht=0;Ht<256;++Ht)Pr[Ht]=ki,--Kt,Kt==0&&(Kt=Ri,--ki,Ri*=2);if(Ve=new pe,!Ve)throw"quic: failed to create encoder"}function Tr(){}Tr.prototype={from_dv:function(t,e,i){return this.type=t.getUint8(e,!0),e++,this.id=t.getUint8(e,!0),e++,e}};function ot(){}ot.prototype={from_dv:function(t,e,i){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 Rr(){}Rr.prototype={from_dv:function(t,e,i){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 ot,e=this.rects[a].from_dv(t,e,i);return e}};function li(){}li.prototype={from_dv:function(t,e,i){return this.type=t.getUint8(e,!0),e++,this.type==k.SPICE_CLIP_TYPE_RECTS&&(this.rects=new Rr,e=this.rects.from_dv(t,e,i)),e}};function kr(){}kr.prototype={from_dv:function(t,e,i){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 Br(){}Br.prototype={from_dv:function(t,e,i){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 Or(){}Or.prototype={from_dv:function(t,e,i){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&k.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 Br,this.palette.from_dv(t,a,i))}return this.data=i.slice(e),e+=this.data.byteLength,e}};function ui(){}ui.prototype={from_dv:function(t,e,i){if(this.descriptor=new kr,e=this.descriptor.from_dv(t,e,i),this.descriptor.type==k.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=i.slice(e,this.lz_rgb.length+e-w),e+=this.lz_rgb.data.byteLength}if(this.descriptor.type==k.SPICE_IMAGE_TYPE_BITMAP&&(this.bitmap=new Or,e=this.bitmap.from_dv(t,e,i)),this.descriptor.type==k.SPICE_IMAGE_TYPE_SURFACE&&(this.surface_id=t.getUint32(e,!0),e+=4),this.descriptor.type==k.SPICE_IMAGE_TYPE_JPEG&&(this.jpeg=new Object,this.jpeg.data_size=t.getUint32(e,!0),e+=4,this.jpeg.data=i.slice(e),e+=this.jpeg.data.byteLength),this.descriptor.type==k.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=i.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=i.slice(e,this.jpeg_alpha.alpha.length+e-w),e+=this.jpeg_alpha.alpha.data.byteLength}return this.descriptor.type==k.SPICE_IMAGE_TYPE_QUIC&&(this.quic=new Mr,e=this.quic.from_dv(t,e,i)),e}};function ss(){}ss.prototype={from_dv:function(t,e,i){this.flags=t.getUint8(e,!0),e++,this.pos=new di,e=this.pos.from_dv(t,e,i);var a=t.getUint32(e,!0);return e+=4,a==0?(this.bitmap=null,e):(this.bitmap=new ui,this.bitmap.from_dv(t,a,i))}};function Nr(){}Nr.prototype={from_dv:function(t,e,i){var a=t.getUint32(e,!0);return e+=4,a==0?this.pat=null:(this.pat=new ui,this.pat.from_dv(t,a,i)),this.pos=new di,this.pos.from_dv(t,e,i)}};function Ur(){}Ur.prototype={from_dv:function(t,e,i){return this.type=t.getUint8(e,!0),e++,this.type==k.SPICE_BRUSH_TYPE_SOLID?(this.color=t.getUint32(e,!0),e+=4):this.type==k.SPICE_BRUSH_TYPE_PATTERN&&(this.pattern=new Nr,e=this.pattern.from_dv(t,e,i)),e}};function jr(){}jr.prototype={from_dv:function(t,e,i){return this.brush=new Ur,e=this.brush.from_dv(t,e,i),this.rop_descriptor=t.getUint16(e,!0),e+=2,this.mask=new ss,this.mask.from_dv(t,e,i)}};function Fr(){}Fr.prototype={from_dv:function(t,e,i){var a=t.getUint32(e,!0);return e+=4,a==0?this.src_bitmap=null:(this.src_bitmap=new ui,this.src_bitmap.from_dv(t,a,i)),this.src_area=new ot,e=this.src_area.from_dv(t,e,i),this.rop_descriptor=t.getUint16(e,!0),e+=2,this.scale_mode=t.getUint8(e,!0),e++,this.mask=new ss,this.mask.from_dv(t,e,i)}};function rs(){}rs.prototype={from_dv:function(t,e,i){return this.x=t.getUint16(e,!0),e+=2,this.y=t.getUint16(e,!0),e+=2,e}};function di(){}di.prototype={from_dv:function(t,e,i){return this.x=t.getUint32(e,!0),e+=4,this.y=t.getUint32(e,!0),e+=4,e}};function Hr(){}Hr.prototype={from_dv:function(t,e,i){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 ns(){}ns.prototype={from_dv:function(t,e,i){return this.flags=t.getUint16(e,!0),e+=2,this.flags&k.SPICE_CURSOR_FLAGS_NONE?this.header=null:(this.header=new Hr,e=this.header.from_dv(t,e,i),this.data=i.slice(e),e+=this.data.byteLength),e}};function Kr(){}Kr.prototype={from_dv:function(t,e,i){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 Mh=0,Th="data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=";function Rh(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 _i=[];_i[173]=H.KEY_Minus;_i[61]=H.KEY_Equal;_i[59]=H.KEY_SemiColon;var fi=[];fi[189]=H.KEY_Minus;fi[187]=H.KEY_Equal;fi[186]=H.KEY_SemiColon;function Gr(t,e){return j[e]!==void 0?j[e]:W[t]===void 0?navigator.userAgent.indexOf("Firefox")!=-1?_i[t]:fi[t]:W[t]}function kh(t,e){var i=Gr(t,e);return i===void 0?(alert("no map for "+t),0):i}function Bh(t,e){var i=Gr(t,e);return i===void 0?0:i<256?i|128:i|32768}function Yr(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 "+Oh(t.buffered)+"]";return e}function Oh(t){var e;if(t){var i=t.length;e="{len "+i,i>0&&(e+="; start "+t.start(0)+"; end "+t.end(i-1)),e+="}"}else e="N/A";return e}function Wt(t,e){this.magic=k.SPICE_MAGIC,this.major_version=k.SPICE_VERSION_MAJOR,this.minor_version=k.SPICE_VERSION_MINOR,this.size=0,t!==void 0&&this.from_buffer(t,e)}Wt.prototype={from_buffer:function(t,e){e=e||0;var i=new ee(t);this.magic="";for(var a=0;a<4;a++)this.magic+=String.fromCharCode(i.getUint8(e+a));e+=4,this.major_version=i.getUint32(e,!0),e+=4,this.minor_version=i.getUint32(e,!0),e+=4,this.size=i.getUint32(e,!0),e+=4},to_buffer:function(t,e){e=e||0;for(var i=new ee(t),a=0;a<4;a++)i.setUint8(e+a,this.magic.charCodeAt(a));e+=4,i.setUint32(e,this.major_version,!0),e+=4,i.setUint32(e,this.minor_version,!0),e+=4,i.setUint32(e,this.size,!0),e+=4},buffer_size:function(){return 16}};function zr(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)}zr.prototype={from_buffer:function(t,e){e=e||0;var i,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 E=g.getUint32(e,!0);e+=4;var r=g.getUint32(e,!0);for(e+=4,e=a+r,this.common_caps=[],i=0;i<w;i++)this.common_caps.unshift(g.getUint32(e,!0)),e+=4;for(this.channel_caps=[],i=0;i<E;i++)this.channel_caps.unshift(g.getUint32(e,!0)),e+=4},to_buffer:function(t,e){e=e||0;var i=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-i+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 Wr(t,e){this.error=0,this.pub_key=void 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 i,a=e,g=new ee(t);this.error=g.getUint32(e,!0),e+=4,this.pub_key=bh(t,e),e+=k.SPICE_TICKET_PUBKEY_BYTES;var w=g.getUint32(e,!0);e+=4;var E=g.getUint32(e,!0);e+=4;var r=g.getUint32(e,!0);for(e+=4,e=a+r,this.common_caps=[],i=0;i<w;i++)this.common_caps.unshift(g.getUint32(e,!0)),e+=4;for(this.channel_caps=[],i=0;i<E;i++)this.channel_caps.unshift(g.getUint32(e,!0)),e+=4}};function $r(t,e){this.auth_mechanism=0,this.encrypted_data=void 0}$r.prototype={to_buffer:function(t,e){e=e||0;var i,a=new ee(t);for(a.setUint32(e,this.auth_mechanism,!0),e+=4,i=0;i<k.SPICE_TICKET_KEY_PAIR_LENGTH/8;i++)this.encrypted_data&&i<this.encrypted_data.length?a.setUint8(e,this.encrypted_data[i],!0):a.setUint8(e,0,!0),e++},buffer_size:function(){return 4+k.SPICE_TICKET_KEY_PAIR_LENGTH/8}};function Hi(t,e){this.auth_code=0,t!==void 0&&this.from_buffer(t,e)}Hi.prototype={from_buffer:function(t,e){e=e||0;var i=new ee(t);this.auth_code=i.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 i=new ee(t);this.type=i.getUint16(e,!0),e+=2,this.size=i.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 i,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(i=0;i<g.length;i++,e++)a.setUint8(e,g[i],!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 i,a=new ee(t);for(this.num_of_channels=a.getUint32(e,!0),e+=4,i=0;i<this.num_of_channels;i++){var g=new Tr;e=g.from_dv(a,e,t),this.channels.push(g)}}};function Vr(t,e){this.from_buffer(t,e)}Vr.prototype={from_buffer:function(t,e){e=e||0;var i=new ee(t);this.session_id=i.getUint32(e,!0),e+=4,this.display_channels_hint=i.getUint32(e,!0),e+=4,this.supported_mouse_modes=i.getUint32(e,!0),e+=4,this.current_mouse_mode=i.getUint32(e,!0),e+=4,this.agent_connected=i.getUint32(e,!0),e+=4,this.agent_tokens=i.getUint32(e,!0),e+=4,this.multi_media_time=i.getUint32(e,!0),e+=4,this.ram_hint=i.getUint32(e,!0),e+=4}};function Xr(t,e){this.from_buffer(t,e)}Xr.prototype={from_buffer:function(t,e){e=e||0;var i=new ee(t);this.supported_modes=i.getUint16(e,!0),e+=2,this.current_mode=i.getUint16(e,!0),e+=2}};function Qr(t,e){this.from_buffer(t,e)}Qr.prototype={from_buffer:function(t,e){e=e||0;var i=new ee(t);this.protocol=i.getUint32(e,!0),e+=4,this.type=i.getUint32(e,!0),e+=4,this.opaque=i.getUint64(e,!0),e+=8,this.size=i.getUint32(e,!0),e+=4,t.byteLength>e&&(this.data=t.slice(e),e+=this.data.byteLength)}};function Ki(t,e){this.from_buffer(t,e)}Ki.prototype={from_buffer:function(t,e){e=e||0;var i=new ee(t);this.num_tokens=i.getUint32(e,!0),e+=4}};function Zr(t,e){this.from_buffer(t,e)}Zr.prototype={from_buffer:function(t,e){e=e||0;var i=new ee(t);this.generation=i.getUint32(e,!0),e+=4,this.window=i.getUint32(e,!0),e+=4}};function Jr(t){this.generation=t.generation}Jr.prototype={to_buffer:function(t,e){e=e||0;var i=new ee(t);i.setUint32(e,this.generation,!0),e+=4},buffer_size:function(){return 4}};function en(t){this.mode=t}en.prototype={to_buffer:function(t,e){e=e||0;var i=new ee(t);i.setUint16(e,this.mode,!0),e+=2},buffer_size:function(){return 2}};function tn(t){this.num_tokens=t}tn.prototype={to_buffer:function(t,e){e=e||0;var i=new ee(t);i.setUint32(e,this.num_tokens,!0),e+=4},buffer_size:function(){return 4}};function sn(t,e){this.protocol=k.VD_AGENT_PROTOCOL,this.type=t,this.opaque=0,this.size=e.buffer_size(),this.data=e}sn.prototype={to_buffer:function(t,e){e=e||0;var i=new ee(t);i.setUint32(e,this.protocol,!0),e+=4,i.setUint32(e,this.type,!0),e+=4,i.setUint64(e,this.opaque,!0),e+=8,i.setUint32(e,this.size,!0),e+=4,this.data.to_buffer(t,e)},buffer_size:function(){return 20+this.data.buffer_size()}};function os(t,e){e?(this.request=t,this.caps=e):this.from_buffer(t)}os.prototype={to_buffer:function(t,e){e=e||0;var i=new ee(t);i.setUint32(e,this.request,!0),e+=4,i.setUint32(e,this.caps,!0),e+=4},from_buffer:function(t,e){e=e||0;var i=new ee(t);return this.request=i.getUint32(e,!0),e+=4,this.caps=i.getUint32(e,!0),e+=4,e},buffer_size:function(){return 8}};function rn(t,e,i,a,g,w){this.num_mon=1,this.flags=t,this.width=e,this.height=i,this.depth=a,this.x=g,this.y=w}rn.prototype={to_buffer:function(t,e){e=e||0;var i=new ee(t);i.setUint32(e,this.num_mon,!0),e+=4,i.setUint32(e,this.flags,!0),e+=4,i.setUint32(e,this.height,!0),e+=4,i.setUint32(e,this.width,!0),e+=4,i.setUint32(e,this.depth,!0),e+=4,i.setUint32(e,this.x,!0),e+=4,i.setUint32(e,this.y,!0),e+=4},buffer_size:function(){return 28}};function as(t,e){e?(this.id=t,this.result=e):this.from_buffer(t)}as.prototype={to_buffer:function(t,e){e=e||0;var i=new ee(t);i.setUint32(e,this.id,!0),e+=4,i.setUint32(e,this.result,!0),e+=4},from_buffer:function(t,e){e=e||0;var i=new ee(t);return this.id=i.getUint32(e,!0),e+=4,this.result=i.getUint32(e,!0),e+=4,e},buffer_size:function(){return 8}};function nn(t,e,i){this.id=t,this.string=`[vdagent-file-xfer] name=`+e+` size=`+i+` `}nn.prototype={to_buffer:function(t,e){e=e||0;var i=new ee(t);i.setUint32(e,this.id,!0),e+=4;for(var a=0;a<this.string.length;a++,e++)i.setUint8(e,this.string.charCodeAt(a))},buffer_size:function(){return 4+this.string.length+1}};function on(t,e,i){this.id=t,this.size=e,this.data=i}on.prototype={to_buffer:function(t,e){e=e||0;var i=new ee(t);if(i.setUint32(e,this.id,!0),e+=4,i.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++)i.setUint8(e,a[g])},buffer_size:function(){return 12+this.size}};function an(t,e){this.from_buffer(t,e)}an.prototype={from_buffer:function(t,e){e=e||0;var i,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="",i=0;i<this.message_len;i++){var g=a.getUint8(e,!0);e++,this.message+=String.fromCharCode(g)}}};function cn(){this.pixmap_cache_id=1,this.glz_dictionary_id=0,this.pixmap_cache_size=10*1024*1024,this.glz_dictionary_window_size=0}cn.prototype={to_buffer:function(t,e){e=e||0;var i=new ee(t);i.setUint8(e,this.pixmap_cache_id,!0),e++,i.setUint64(e,this.pixmap_cache_size,!0),e+=8,i.setUint8(e,this.glz_dictionary_id,!0),e++,i.setUint32(e,this.glz_dictionary_window_size,!0),e+=4},buffer_size:function(){return 14}};function Ot(){}Ot.prototype={from_dv:function(t,e,i){return this.surface_id=t.getUint32(e,!0),e+=4,this.box=new ot,e=this.box.from_dv(t,e,i),this.clip=new li,this.clip.from_dv(t,e,i)}};function hn(t,e){this.from_buffer(t,e)}hn.prototype={from_buffer:function(t,e){e=e||0;var i=new ee(t);return this.base=new Ot,e=this.base.from_dv(i,e,t),this.data=new Fr,this.data.from_dv(i,e,t)}};function ln(t,e){this.from_buffer(t,e)}ln.prototype={from_buffer:function(t,e){e=e||0;var i=new ee(t);return this.base=new Ot,e=this.base.from_dv(i,e,t),this.data=new jr,this.data.from_dv(i,e,t)}};function un(t,e){this.from_buffer(t,e)}un.prototype={from_buffer:function(t,e){e=e||0;var i=new ee(t);return this.base=new Ot,e=this.base.from_dv(i,e,t),this.src_pos=new di,this.src_pos.from_dv(i,e,t)}};function dn(t,e){this.from_buffer(t,e)}dn.prototype={from_buffer:function(t,e){e=e||0;var i=new ee(t);return this.surface=new Kr,this.surface.from_dv(i,e,t)}};function _n(t,e){this.from_buffer(t,e)}_n.prototype={from_buffer:function(t,e){e=e||0;var i=new ee(t);this.surface_id=i.getUint32(e,!0),e+=4}};function fn(t,e){this.from_buffer(t,e)}fn.prototype={from_buffer:function(t,e){e=e||0;var i=new ee(t);return this.keyboard_modifiers=i.getUint16(e,!0),e+=2,e}};function pn(t,e){this.from_buffer(t,e)}pn.prototype={from_buffer:function(t,e){e=e||0;var i=new ee(t);return this.keyboard_modifiers=i.getUint16(e,!0),e+=2,e}};function mn(t,e){this.from_buffer(t,e)}mn.prototype={from_buffer:function(t,e,i){e=e||0;var a=new ee(t);return this.position=new rs,e=this.position.from_dv(a,e,i),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 ns,this.cursor.from_dv(a,e,t)}};function gn(t,e){this.from_buffer(t,e)}gn.prototype={from_buffer:function(t,e,i){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 vn(t,e){this.from_buffer(t,e)}vn.prototype={from_buffer:function(t,e,i){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 Sn(t,e){this.from_buffer(t,e)}Sn.prototype={from_buffer:function(t,e,i){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 bn(t,e){this.from_buffer(t,e)}bn.prototype={from_buffer:function(t,e,i){e=e||0;var a=new ee(t);return this.position=new rs,e=this.position.from_dv(a,e,i),this.visible=a.getUint8(e,!0),e++,this.cursor=new ns,this.cursor.from_dv(a,e,t)}};function pi(t,e){this.display_id=0,this.buttons_state=t.buttons_state,e?(this.x=e.offsetX,this.y=e.offsetY,t.mousex=e.offsetX,t.mousey=e.offsetY):this.x=this.y=this.buttons_state=0}pi.prototype={to_buffer:function(t,e){e=e||0;var i=new ee(t);return i.setUint32(e,this.x,!0),e+=4,i.setUint32(e,this.y,!0),e+=4,i.setUint16(e,this.buttons_state,!0),e+=2,i.setUint8(e,this.display_id,!0),e+=1,e},buffer_size:function(){return 11}};function cs(t,e){this.display_id=0,this.buttons_state=t.buttons_state,e?(this.x=e.offsetX,this.y=e.offsetY,t.mousex!==void 0&&(this.x-=t.mousex,this.y-=t.mousey),t.mousex=e.offsetX,t.mousey=e.offsetY):this.x=this.y=this.buttons_state=0}cs.prototype.to_buffer=pi.prototype.to_buffer;cs.prototype.buffer_size=pi.prototype.buffer_size;function Nt(t,e){e?(this.button=e.button+1,this.buttons_state=1<<e.button,t.buttons_state=this.buttons_state):(this.button=k.SPICE_MOUSE_BUTTON_LEFT,this.buttons_state=k.SPICE_MOUSE_BUTTON_MASK_LEFT)}Nt.prototype={to_buffer:function(t,e){e=e||0;var i=new ee(t);return i.setUint8(e,this.button,!0),e++,i.setUint16(e,this.buttons_state,!0),e+=2,e},buffer_size:function(){return 3}};function mi(t,e){e?(this.button=e.button+1,this.buttons_state=0,t.buttons_state=this.buttons_state):(this.button=k.SPICE_MOUSE_BUTTON_LEFT,this.buttons_state=0)}mi.prototype.to_buffer=Nt.prototype.to_buffer;mi.prototype.buffer_size=Nt.prototype.buffer_size;function gt(t){t?this.code=kh(t.keyCode,t.code):this.code=0}gt.prototype={to_buffer:function(t,e){e=e||0;var i=new ee(t);return i.setUint32(e,this.code,!0),e+=4,e},buffer_size:function(){return 4}};function gi(t){t?this.code=Bh(t.keyCode,t.code):this.code=0}gi.prototype.to_buffer=gt.prototype.to_buffer;gi.prototype.buffer_size=gt.prototype.buffer_size;function Cn(t,e){this.from_buffer(t,e)}Cn.prototype={from_buffer:function(t,e){e=e||0;var i=new ee(t);this.surface_id=i.getUint32(e,!0),e+=4,this.id=i.getUint32(e,!0),e+=4,this.flags=i.getUint8(e,!0),e+=1,this.codec_type=i.getUint8(e,!0),e+=1,this.stamp=i.getUint64(e,!0),e+=8,this.stream_width=i.getUint32(e,!0),e+=4,this.stream_height=i.getUint32(e,!0),e+=4,this.src_width=i.getUint32(e,!0),e+=4,this.src_height=i.getUint32(e,!0),e+=4,this.dest=new ot,e=this.dest.from_dv(i,e,t),this.clip=new li,this.clip.from_dv(i,e,t)}};function hs(t,e){}hs.prototype={from_dv:function(t,e,i){return this.id=t.getUint32(e,!0),e+=4,this.multi_media_time=t.getUint32(e,!0),e+=4,e}};function En(t,e){this.from_buffer(t,e)}En.prototype={from_buffer:function(t,e){e=e||0;var i=new ee(t);this.base=new hs,e=this.base.from_dv(i,e,t),this.data_size=i.getUint32(e,!0),e+=4,this.data=i.u8.subarray(e,e+this.data_size)}};function yn(t,e){this.from_buffer(t,e)}yn.prototype={from_buffer:function(t,e){e=e||0;var i=new ee(t);this.base=new hs,e=this.base.from_dv(i,e,t),this.width=i.getUint32(e,!0),e+=4,this.height=i.getUint32(e,!0),e+=4,this.dest=new ot,e=this.dest.from_dv(i,e,t),this.data_size=i.getUint32(e,!0),e+=4,this.data=i.u8.subarray(e,e+this.data_size)}};function wn(t,e){this.from_buffer(t,e)}wn.prototype={from_buffer:function(t,e){e=e||0;var i=new ee(t);this.id=i.getUint32(e,!0),e+=4,this.clip=new li,this.clip.from_dv(i,e,t)}};function xn(t,e){this.from_buffer(t,e)}xn.prototype={from_buffer:function(t,e){e=e||0;var i=new ee(t);this.id=i.getUint32(e,!0),e+=4}};function An(t,e){this.from_buffer(t,e)}An.prototype={from_buffer:function(t,e){e=e||0;var i=new ee(t);this.stream_id=i.getUint32(e,!0),e+=4,this.unique_id=i.getUint32(e,!0),e+=4,this.max_window_size=i.getUint32(e,!0),e+=4,this.timeout_ms=i.getUint32(e,!0),e+=4}};function In(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}In.prototype={to_buffer:function(t,e){e=e||0;var i=new ee(t);return i.setUint32(e,this.stream_id,!0),e+=4,i.setUint32(e,this.unique_id,!0),e+=4,i.setUint32(e,this.start_frame_mm_time,!0),e+=4,i.setUint32(e,this.end_frame_mm_time,!0),e+=4,i.setUint32(e,this.num_frames,!0),e+=4,i.setUint32(e,this.num_drops,!0),e+=4,i.setUint32(e,this.last_frame_delay,!0),e+=4,i.setUint32(e,this.audio_delay,!0),e+=4,e},buffer_size:function(){return 8*4}};function Pn(t,e){this.count=0,this.resources=[],this.from_buffer(t,e)}Pn.prototype={from_buffer:function(t,e){var i;e=e||0;var a=new ee(t);for(this.count=a.getUint16(e,!0),e+=2,i=0;i<this.count;i++)this.resources[i]={},this.resources[i].type=a.getUint8(e,!0),e++,this.resources[i].id=a.getUint64(e,!0),e+=8}};function Dn(t,e){this.from_buffer(t,e)}Dn.prototype={from_buffer:function(t,e){e=e||0;var i=new ee(t),a=i.getUint32(e,!0);e+=4;var g=i.getUint32(e,!0);e+=4,this.opened=i.getUint8(e,!0),e+=1,this.name=t.slice(g,g+a-1)}};var Ln=Array(256),Mn=0;function Nh(){var t,e,i;for(e=0;e<256;e++){for(t=e,i=0;i<8;i++)t&1?t=(3988292384^t>>>1)>>>0&4294967295:t=t>>>1;Ln[e]=t}Mn=1}function Uh(t,e,i,a){var g=t,w;for(Mn||Nh(),w=0;w<a;w++)g=Ln[(g^e[i+w])&255]^g>>>8;return g}function jh(t,e,i){return Uh(4294967295,t,e,i)^4294967295}function ls(t,e,i){var a=new Uint8Array(t);return jh(a,e,i)}function Tn(t,e){this.width=t,this.height=e,this.depth=8,this.type=6,this.compression=0,this.filter=0,this.interlace=0}Tn.prototype={to_buffer:function(t,e){e=e||0;var i=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,ls(t,i+4,this.buffer_size()-8)),e+=4,e},buffer_size:function(){return 25}};function Rn(){this.s1=1,this.s2=0}Rn.prototype.update=function(t){this.s1+=t,this.s1%=65521,this.s2+=this.s1,this.s2%=65521};function kn(t,e,i){if(i.byteLength>65535)throw new Error("Cannot handle more than 64K");this.data=i,this.width=t,this.height=e}kn.prototype={to_buffer:function(t,e){e=e||0;var i=e,a,g,w,E=new ee(t),r=new Rn;E.setUint32(e,this.buffer_size()-12),e+=4,E.setUint8(e,73),e++,E.setUint8(e,68),e++,E.setUint8(e,65),e++,E.setUint8(e,84),e++,E.setUint8(e,120),e++,E.setUint8(e,1),e++,E.setUint8(e,128),e++,E.setUint16(e,this.data.byteLength+this.height),e+=2,E.setUint16(e,~(this.data.byteLength+this.height)),e+=2;var o=new Uint8Array(this.data);for(w=0,g=0;g<this.height;g++)for(E.setUint8(e,0),e++,r.update(0),a=0;a<this.width&&w<this.data.byteLength;a++)r.update(o[w]),E.setUint8(e,o[w++]),e++,r.update(o[w]),E.setUint8(e,o[w++]),e++,r.update(o[w]),E.setUint8(e,o[w++]),e++,r.update(o[w]),E.setUint8(e,o[w++]),e++;return E.setUint16(e,r.s2),e+=2,E.setUint16(e,r.s1),e+=2,E.setUint32(e,ls(t,i+4,this.buffer_size()-8)),e+=4,e},buffer_size:function(){return 12+this.data.byteLength+this.height+4+2+1+2+2}};function Bn(){}Bn.prototype={to_buffer:function(t,e){e=e||0;var i=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,ls(t,i+4,this.buffer_size()-8)),e+=4,e},buffer_size:function(){return 12}};function Fh(t,e,i){var a,g=new Tn(t,e),w=new kn(t,e,i),E=new Bn,r=new ArrayBuffer(g.buffer_size()+w.buffer_size()+E.buffer_size()),o=g.to_buffer(r);o=w.to_buffer(r,o),o=E.to_buffer(r,o);var u=new Uint8Array(r),_="";for(a=0;a<o;a++)_+="%",u[a]<16&&(_+="0"),_+=u[a].toString(16);return"%89PNG%0D%0A%1A%0A"+_}var Se={cursors:new Array,unknown_cursors:new Array,warned:!1,add_cursor:function(t,e){Se.cursors[t]=e},unknown_cursor:function(t,e){Se.warned||(Se.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.`)),Se.unknown_cursors[t]||(Se.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,i,a){var g=uh(a+" "+e.header.hot_spot_x+" "+e.header.hot_spot_y);if(typeof Se.cursors<"u"&&typeof Se.cursors[g]<"u"){var w="url("+Se.cursors[g]+"), default";i.style.cursor=w}window.getComputedStyle(i,null).cursor=="auto"?(Se.unknown_cursor(g,Se.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",Se.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=Se.duplicate_mouse_event(t,this.spice_screen);return this.spice_screen.dispatchEvent(e)},duplicate_mouse_event:function(t,e){var i=document.createEvent("mouseevent");return i.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),i},ICONDIR:function(){},ICONDIRENTRY:function(t,e,i,a,g){this.width=t,this.height=e,this.bytes=i,this.hot_x=a,this.hot_y=g},create_icondir:function(t,e,i,a,g){var w,E=new Se.ICONDIR,r=new Se.ICONDIRENTRY(t,e,i,a,g),o=new ArrayBuffer(E.buffer_size()+r.buffer_size()),u=E.to_buffer(o);u=r.to_buffer(o,u);var _=new Uint8Array(o),l="";for(w=0;w<u;w++)l+="%",_[w]<16&&(l+="0"),l+=_[w].toString(16);return l}};Se.ICONDIR.prototype={to_buffer:function(t,e){e=e||0;var i=new ee(t);return i.setUint16(e,0,!0),e+=2,i.setUint16(e,2,!0),e+=2,i.setUint16(e,1,!0),e+=2,e},buffer_size:function(){return 6}};Se.ICONDIRENTRY.prototype={to_buffer:function(t,e){e=e||0;var i=new ee(t);return i.setUint8(e,this.width),e++,i.setUint8(e,this.height),e++,i.setUint8(e,0),e++,i.setUint8(e,0),e++,i.setUint16(e,this.hot_x,!0),e+=2,i.setUint16(e,this.hot_y,!0),e+=2,i.setUint32(e,this.bytes,!0),e+=4,i.setUint32(e,e+4,!0),e+=4,e},buffer_size:function(){return 16}};function us(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",Hh)}us.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,i=new ArrayBuffer(this.needed),a=new Uint8Array(i);e<i.byteLength&&this.buffers.length>0;){var g=this.buffers.shift();if(!g)return;var w=new Uint8Array(g),E=i.byteLength-e;if(w.length<=E)a.set(w,e),e+=w.length,this.size-=w.length;else{var r=w.slice(0,E);a.set(r,e),e+=r.length,this.size-=r.length,this.buffers.unshift(w.slice(E))}}this.callback.call(this.sc,i,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 Hh(t){us.prototype.inbound.call(this.wire_reader,t.data)}var Kh=[26,69,223,163],Gh=[66,134],Yh=[66,247],zh=[66,242],Wh=[66,243],$h=[66,130],qh=[66,135],Vh=[66,133],Xh=[24,83,128,103],On=[21,73,169,102],Hs=[42,215,177],Ks=[77,128],Gs=[87,65],Qh=[17,77,155,116],Zh=[77,187],Ys=[83,171],zs=[83,172],Nn=[22,84,174,107],Un=[174],$t=[215],qt=[115,197],Vt=[131],Xt=[185],Qt=[136],Zt=[85,170],Jt=[156],ei=[109,231],ti=[85,238],ii=[170],si=[86,187],Ws=[86,170],$s=[99,162],ri=[134],Jh=[224],qs=[154],Vs=[176],Xs=[186],el=[225],Qs=[181],Zs=[159],tl=[31,67,182,117],Js=[231],il=[163],_e={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 at(t,e,i){var a=128|t;return e.setUint8(i,a),i+1}function ae(t,e,i,a){return a=ge(t,i,a),a=at(1,i,a),i.setUint8(a,e),a+1}function Lt(t,e,i,a){return a=ge(t,i,a),a=at(4,i,a),i.setUint32(a,e),a+4}function Gi(t,e,i,a){return a=ge(t,i,a),a=at(2,i,a),i.setUint16(a,e),a+2}function sl(t,e,i,a){return a=ge(t,i,a),a=at(4,i,a),i.setFloat32(a,e),a+4}function Ge(t,e,i){e.setUint8(i++,1),e.setUint8(i++,0),e.setUint8(i++,0),e.setUint8(i++,0);for(var a=t&4294967295,g=24;g>=0;g-=8)e.setUint8(i++,a>>g);return i}function ge(t,e,i){for(var a=0;a<t.length;a++)e.setUint8(i+a,t[a]);return i+t.length}function rl(t,e,i){for(var a=0;a<t.length;a++)e.setUint8(i+a,t.charCodeAt(a));return i+t.length}function rt(t,e,i,a){return a=ge(t,i,a),e.length<127?a=at(e.length,i,a):a=Ge(e.length,i,a),typeof e=="string"?a=rl(e,i,a):a=ge(e,i,a),a}function jn(){this.id=Kh,this.Version=1,this.ReadVersion=1,this.MaxIDLength=4,this.MaxSizeLength=8,this.DocType="webm",this.DocTypeVersion=2,this.DocTypeReadVersion=2}jn.prototype={to_buffer:function(t,e){e=e||0;var i=new DataView(t);return e=ge(this.id,i,e),e=Ge(31,i,e),e=ae(Gh,this.Version,i,e),e=ae(Yh,this.ReadVersion,i,e),e=ae(zh,this.MaxIDLength,i,e),e=ae(Wh,this.MaxSizeLength,i,e),e=rt($h,this.DocType,i,e),e=ae(qh,this.DocTypeVersion,i,e),e=ae(Vh,this.DocTypeReadVersion,i,e),e},buffer_size:function(){return 39+this.id.length}};function Fn(){this.id=Xh}Fn.prototype={to_buffer:function(t,e){e=e||0;var i=new DataView(t);return e=ge(this.id,i,e),i.setUint8(e++,255),e},buffer_size:function(){return this.id.length+1}};function Hn(){this.id=On,this.timecode_scale=1e6,this.muxing_app="spice",this.writing_app="spice-html5"}Hn.prototype={to_buffer:function(t,e){e=e||0;var i=new DataView(t);return e=ge(this.id,i,e),e=Ge(this.buffer_size()-8-this.id.length,i,e),e=Lt(Hs,this.timecode_scale,i,e),e=rt(Ks,this.muxing_app,i,e),e=rt(Gs,this.writing_app,i,e),e},buffer_size:function(){return this.id.length+8+Hs.length+1+4+Ks.length+1+this.muxing_app.length+Gs.length+1+this.writing_app.length}};function Kn(t){this.id=el,this.sampling_frequency=t,this.channels=_e.OPUS_CHANNELS}Kn.prototype={to_buffer:function(t,e){e=e||0;var i=new DataView(t);return e=ge(this.id,i,e),e=Ge(this.buffer_size()-8-this.id.length,i,e),e=ae(Zs,this.channels,i,e),e=sl(Qs,this.sampling_frequency,i,e),e},buffer_size:function(){return this.id.length+8+Qs.length+1+4+Zs.length+1+1}};function Gn(t,e){this.id=Jh,this.flag_interlaced=0,this.width=t,this.height=e}Gn.prototype={to_buffer:function(t,e){e=e||0;var i=new DataView(t);return e=ge(this.id,i,e),e=Ge(this.buffer_size()-8-this.id.length,i,e),e=ae(qs,this.flag_interlaced,i,e),e=Gi(Vs,this.width,i,e),e=Gi(Xs,this.height,i,e),e},buffer_size:function(){return this.id.length+8+qs.length+1+1+Vs.length+1+2+Xs.length+1+2}};function Yi(t,e){this.id=Zh,this.pos=e,this.seekid=t}Yi.prototype={to_buffer:function(t,e){e=e||0;var i=new DataView(t);return e=ge(this.id,i,e),e=at(this.buffer_size()-1-this.id.length,i,e),e=rt(Ys,this.seekid,i,e),e=Gi(zs,this.pos,i,e),e},buffer_size:function(){return this.id.length+1+Ys.length+1+this.seekid.length+zs.length+1+2}};function Yn(t,e){this.id=Qh,this.info=new Yi(On,t),this.track=new Yi(Nn,e)}Yn.prototype={to_buffer:function(t,e){e=e||0;var i=new DataView(t);return e=ge(this.id,i,e),e=Ge(this.buffer_size()-8-this.id.length,i,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 zn(){this.id=Un,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 Kn(_e.OPUS_FREQUENCY),this.codec_private=[79,112,117,115,72,101,97,100,1,_e.OPUS_CHANNELS,0,15,128,187,0,0,0,0,0]}zn.prototype={to_buffer:function(t,e){e=e||0;var i=new DataView(t);return e=ge(this.id,i,e),e=Ge(this.buffer_size()-8-this.id.length,i,e),e=ae($t,this.number,i,e),e=ae(qt,this.uid,i,e),e=ae(Xt,this.flag_enabled,i,e),e=ae(Qt,this.flag_default,i,e),e=ae(Zt,this.flag_forced,i,e),e=ae(Jt,this.flag_lacing,i,e),e=rt(ri,this.codec_id,i,e),e=ae(ei,this.min_cache,i,e),e=ae(ti,this.max_block_addition_id,i,e),e=ae(ii,this.codec_decode_all,i,e),e=Lt(Ws,this.codec_delay,i,e),e=Lt(si,this.seek_pre_roll,i,e),e=ae(Vt,this.type,i,e),e=rt($s,this.codec_private,i,e),e=this.audio.to_buffer(t,e),e},buffer_size:function(){return this.id.length+8+$t.length+1+1+qt.length+1+1+Vt.length+1+1+Xt.length+1+1+Qt.length+1+1+Zt.length+1+1+Jt.length+1+1+ei.length+1+1+ti.length+1+1+ii.length+1+1+si.length+1+4+Ws.length+1+4+ri.length+this.codec_id.length+1+$s.length+1+this.codec_private.length+this.audio.buffer_size()}};function Wn(t,e){this.id=Un,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 Gn(t,e)}Wn.prototype={to_buffer:function(t,e){e=e||0;var i=new DataView(t);return e=ge(this.id,i,e),e=Ge(this.buffer_size()-8-this.id.length,i,e),e=ae($t,this.number,i,e),e=ae(qt,this.uid,i,e),e=ae(Xt,this.flag_enabled,i,e),e=ae(Qt,this.flag_default,i,e),e=ae(Zt,this.flag_forced,i,e),e=ae(Jt,this.flag_lacing,i,e),e=rt(ri,this.codec_id,i,e),e=ae(ei,this.min_cache,i,e),e=ae(ti,this.max_block_addition_id,i,e),e=ae(ii,this.codec_decode_all,i,e),e=Lt(si,this.seek_pre_roll,i,e),e=ae(Vt,this.type,i,e),e=this.video.to_buffer(t,e),e},buffer_size:function(){return this.id.length+8+$t.length+1+1+qt.length+1+1+Xt.length+1+1+Qt.length+1+1+Zt.length+1+1+Jt.length+1+1+ri.length+this.codec_id.length+1+ei.length+1+1+ti.length+1+1+ii.length+1+1+si.length+1+4+Vt.length+1+1+this.video.buffer_size()}};function ds(t){this.id=Nn,this.track_entry=t}ds.prototype={to_buffer:function(t,e){e=e||0;var i=new DataView(t);return e=ge(this.id,i,e),e=Ge(this.buffer_size()-8-this.id.length,i,e),e=this.track_entry.to_buffer(t,e),e},buffer_size:function(){return this.id.length+8+this.track_entry.buffer_size()}};function _s(t,e){this.id=tl,this.timecode=t,this.data=e}_s.prototype={to_buffer:function(t,e){e=e||0;var i=new DataView(t);return e=ge(this.id,i,e),i.setUint8(e++,255),e=Lt(Js,this.timecode,i,e),e},buffer_size:function(){return this.id.length+1+Js.length+1+4}};function fs(t,e,i){this.id=il,this.timecode=t,this.data=e,this.keyframe=i}fs.prototype={to_buffer:function(t,e){e=e||0;var i=new DataView(t);e=ge(this.id,i,e),e=Ge(this.data.byteLength+4,i,e),e=at(1,i,e),i.setUint16(e,this.timecode),e+=2,i.setUint8(e,this.keyframe?_e.CLUSTER_SIMPLEBLOCK_FLAG_KEYFRAME:0),e+=1;for(var a=new Uint8Array(this.data),g=0;g<this.data.byteLength;g++)i.setUint8(e++,a[g]);return e},buffer_size:function(){return this.id.length+8+1+2+1+this.data.byteLength}};function ps(){this.ebml=new jn,this.segment=new Fn,this.seek_head=new Yn(0,0),this.seek_head.info.pos=this.segment.buffer_size()+this.seek_head.buffer_size(),this.info=new Hn,this.seek_head.track.pos=this.seek_head.info.pos+this.info.buffer_size()}ps.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:k.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 us(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(Wt.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(nl,k.SPICE_CONNECT_TIMEOUT,this)}ye.prototype={send_hdr:function(){var t=new Wt,e=new zr;if(e.connection_id=this.connection_id,e.channel_type=this.type,e.channel_id=this.chan_id,e.common_caps.push(1<<k.SPICE_COMMON_CAP_PROTOCOL_AUTH_SELECTION|1<<k.SPICE_COMMON_CAP_MINI_HEADER),e.channel_type==k.SPICE_CHANNEL_PLAYBACK){var i=0;"MediaSource"in window&&MediaSource.isTypeSupported(_e.SPICE_PLAYBACK_CODEC)&&(i|=1<<k.SPICE_PLAYBACK_CAP_OPUS),e.channel_caps.push(i)}else if(e.channel_type==k.SPICE_CHANNEL_MAIN)e.channel_caps.push(1<<k.SPICE_MAIN_CAP_AGENT_CONNECTED_TOKENS);else if(e.channel_type==k.SPICE_CHANNEL_DISPLAY){var i=1<<k.SPICE_DISPLAY_CAP_SIZED_STREAM|1<<k.SPICE_DISPLAY_CAP_STREAM_REPORT|1<<k.SPICE_DISPLAY_CAP_MULTI_CODEC|1<<k.SPICE_DISPLAY_CAP_CODEC_MJPEG;"MediaSource"in window&&MediaSource.isTypeSupported(_e.SPICE_VP8_CODEC)&&(i|=1<<k.SPICE_DISPLAY_CAP_CODEC_VP8),e.channel_caps.push(i)}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 $r;e.auth_mechanism=k.SPICE_COMMON_CAP_AUTH_SPICE,e.encrypted_data=t;var i=new ArrayBuffer(e.buffer_size());e.to_buffer(i),this.ws.send(i)},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 i=new le(t);i.type>500,i.size==0?(this.process_message(i),this.wire_reader.request(le.prototype.buffer_size())):(this.wire_reader.request(i.size),this.wire_reader.save_header(i))}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 Wt(t),this.reply_hdr.magic!=k.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 Wr(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(Ch(this.reply_link.pub_key,this.password+"\0")),this.state="ticket",this.wire_reader.request(Hi.prototype.buffer_size());else if(this.state=="ticket")if(this.auth_reply=new Hi(t),this.auth_reply.auth_code==k.SPICE_LINK_ERR_OK){if(this.type==k.SPICE_CHANNEL_DISPLAY){var g=new cn,w=new le;w.build_msg(k.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==k.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==k.SPICE_MSG_SET_ACK){var e=new Zr(t.data);this.ack_window=e.window,this.msgs_until_ack=this.ack_window;var i=new Jr(e),a=new le;return a.build_msg(k.SPICE_MSGC_ACK_SYNC,i),this.send_msg(a),!0}if(t.type==k.SPICE_MSG_PING){var g=new le;return g.type=k.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==k.SPICE_MSG_NOTIFY){var w=new an(t.data);return w.severity==k.SPICE_NOTIFY_SEVERITY_ERROR?this.log_err(w.message):w.severity==k.SPICE_NOTIFY_SEVERITY_WARN?this.log_warn(w.message):this.log_info(w.message),!0}return!1},process_message:function(t){var e,i=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=k.SPICE_MSGC_ACK,this.send_msg(a)}var g=Date.now()-i;return g>_e.GAP_DETECTION_THRESHOLD&&console.log("delta "+this.channel_type()+":"+t.type+" "+g),e},channel_type:function(){return this.type==k.SPICE_CHANNEL_MAIN?"main":this.type==k.SPICE_CHANNEL_DISPLAY?"display":this.type==k.SPICE_CHANNEL_INPUTS?"inputs":this.type==k.SPICE_CHANNEL_CURSOR?"cursor":this.type==k.SPICE_CHANNEL_PLAYBACK?"playback":this.type==k.SPICE_CHANNEL_RECORD?"record":this.type==k.SPICE_CHANNEL_TUNNEL?"tunnel":this.type==k.SPICE_CHANNEL_SMARTCARD?"smartcard":this.type==k.SPICE_CHANNEL_USBREDIR?"Fusbredir":this.type==k.SPICE_CHANNEL_PORT?"port":this.type==k.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]||Mh>1){var i="";i=" [ further notices suppressed ]",this.log_warn("Unimplemented function "+t+"("+e+")"+i),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 nl(t){ye.prototype.handle_timeout.call(t)}function vi(){ye.apply(this,arguments)}vi.prototype=Object.create(ye.prototype);vi.prototype.process_channel_message=function(t){if(t.type==k.SPICE_MSG_CURSOR_INIT){var e=new mn(t.data);return this.parent&&this.parent.inputs&&this.parent.inputs.mouse_mode==k.SPICE_MOUSE_MODE_SERVER&&(this.parent.inputs.mousex=e.position.x,this.parent.inputs.mousey=e.position.y),!0}if(t.type==k.SPICE_MSG_CURSOR_SET){var i=new bn(t.data);return i.flags&k.SPICE_CURSOR_FLAGS_NONE?(document.getElementById(this.parent.screen_id).style.cursor="none",!0):(i.flags>0&&this.log_warn("FIXME: No support for cursor flags "+i.flags),i.cursor.header.type!=k.SPICE_CURSOR_TYPE_ALPHA?(this.log_warn("FIXME: No support for cursor type "+i.cursor.header.type),!1):(this.set_cursor(i.cursor),!0))}return t.type==k.SPICE_MSG_CURSOR_MOVE?(this.known_unimplemented(t.type,"Cursor Move"),!0):t.type==k.SPICE_MSG_CURSOR_HIDE?(document.getElementById(this.parent.screen_id).style.cursor="none",!0):t.type==k.SPICE_MSG_CURSOR_TRAIL?(this.known_unimplemented(t.type,"Cursor Trail"),!0):t.type==k.SPICE_MSG_CURSOR_RESET?(document.getElementById(this.parent.screen_id).style.cursor="auto",!0):t.type==k.SPICE_MSG_CURSOR_INVAL_ONE?(this.known_unimplemented(t.type,"Cursor Inval One"),!0):t.type==k.SPICE_MSG_CURSOR_INVAL_ALL};vi.prototype.set_cursor=function(t){var e=Fh(t.header.width,t.header.height,t.data),i="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=i,window.getComputedStyle(a,null).cursor=="auto"&&Se.simulate_cursor(this,t,a,e)};function Si(t,e){this.id=t,this.file=e}Si.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)};Si.prototype.update_progressbar=function(t){this.progressbar.setAttribute("value",t)};Si.prototype.remove_progressbar=function(){this.progressbar_container&&this.progressbar_container.parentNode&&this.progressbar_container.parentNode.removeChild(this.progressbar_container)};var ht=-1,lt=-1,Xe=-1,xt=-1;function ms(){ye.apply(this,arguments),this.mousex=void 0,this.mousey=void 0,this.button_state=0,this.waiting_for_ack=0}ms.prototype=Object.create(ye.prototype);ms.prototype.process_channel_message=function(t){if(t.type==k.SPICE_MSG_INPUTS_INIT){var e=new fn(t.data);return this.keyboard_modifiers=e.keyboard_modifiers,!0}if(t.type==k.SPICE_MSG_INPUTS_KEY_MODIFIERS){var i=new pn(t.data);return this.keyboard_modifiers=i.keyboard_modifiers,!0}return t.type==k.SPICE_MSG_INPUTS_MOUSE_MOTION_ACK?(this.waiting_for_ack-=k.SPICE_INPUT_MOTION_ACK_BUNCH,!0):!1};function $n(t){var e=new le,i;this.sc.mouse_mode==k.SPICE_MOUSE_MODE_CLIENT?(i=new pi(this.sc,t),e.build_msg(k.SPICE_MSGC_INPUTS_MOUSE_POSITION,i)):(i=new cs(this.sc,t),e.build_msg(k.SPICE_MSGC_INPUTS_MOUSE_MOTION,i)),this.sc&&this.sc.inputs&&this.sc.inputs.state==="ready"&&this.sc.inputs.waiting_for_ack<2*k.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 qn(t){var e=new Nt(this.sc,t),i=new le;i.build_msg(k.SPICE_MSGC_INPUTS_MOUSE_PRESS,e),this.sc&&this.sc.inputs&&this.sc.inputs.state==="ready"&&this.sc.inputs.send_msg(i),t.preventDefault()}function Vn(t){return t.preventDefault(),!1}function Xn(t){var e=new mi(this.sc,t),i=new le;i.build_msg(k.SPICE_MSGC_INPUTS_MOUSE_RELEASE,e),this.sc&&this.sc.inputs&&this.sc.inputs.state==="ready"&&this.sc.inputs.send_msg(i),t.preventDefault()}function Qn(t){var e=new Nt,i=new mi;t.deltaY<0?e.button=i.button=k.SPICE_MOUSE_BUTTON_UP:e.button=i.button=k.SPICE_MOUSE_BUTTON_DOWN,e.buttons_state=0,i.buttons_state=0;var a=new le;a.build_msg(k.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(k.SPICE_MSGC_INPUTS_MOUSE_RELEASE,i),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 Zn(t){var e=new gt(t),i=new le;eo(t,e.code,this.sc),i.build_msg(k.SPICE_MSGC_INPUTS_KEY_DOWN,e),this.sc&&this.sc.inputs&&this.sc.inputs.state==="ready"&&this.sc.inputs.send_msg(i),t.preventDefault()}function Jn(t){var e=new gi(t),i=new le;eo(t,e.code,this.sc),i.build_msg(k.SPICE_MSGC_INPUTS_KEY_UP,e),this.sc&&this.sc.inputs&&this.sc.inputs.state==="ready"&&this.sc.inputs.send_msg(i),t.preventDefault()}function gs(t,e){var i=new le,a=new gt;a.code=e,i.build_msg(k.SPICE_MSGC_INPUTS_KEY_DOWN,a),t.inputs.send_msg(i),a.code=128|e,i.build_msg(k.SPICE_MSGC_INPUTS_KEY_UP,a),t.inputs.send_msg(i)}function ol(t){t&&t.inputs&&t.inputs.state==="ready"&&(ke(!0,H.KEY_LCtrl,t),ke(!0,H.KEY_Alt,t),gs(t,H.KEY_KP_Decimal),lt==!1&&ke(!1,H.KEY_LCtrl,t),Xe==!1&&ke(!1,H.KEY_Alt,t))}function al(t){t&&t.inputs&&t.inputs.state==="ready"&&(ke(!0,H.KEY_Alt,t),gs(t,H.KEY_F4),Xe==!1&&ke(!1,H.KEY_Alt,t))}function cl(t){t&&t.inputs&&t.inputs.state==="ready"&&(ke(!0,H.KEY_Alt,t),gs(t,H.KEY_Tab),Xe==!1&&ke(!1,H.KEY_Alt,t))}function ke(t,e,i){var a=new le;if(t){var g=new gt;g.code=e,a.build_msg(k.SPICE_MSGC_INPUTS_KEY_DOWN,g)}else{var g=new gi;g.code=128|e,a.build_msg(k.SPICE_MSGC_INPUTS_KEY_UP,g)}i.inputs.send_msg(a)}function eo(t,e,i){ht===-1&&(ht=t.shiftKey,lt=t.ctrlKey,Xe=t.altKey,xt=t.metaKey),e===H.KEY_ShiftL?ht=!0:e===H.KEY_Alt?Xe=!0:e===H.KEY_LCtrl?lt=!0:e===57525?xt=!0:e===(128|H.KEY_ShiftL)?ht=!1:e===(128|H.KEY_Alt)?Xe=!1:e===(128|H.KEY_LCtrl)?lt=!1:e===57525&&(xt=!1),i&&i.inputs&&i.inputs.state==="ready"&&(ht!=t.shiftKey&&(console.log("Shift state out of sync"),ke(t.shiftKey,H.KEY_ShiftL,i),ht=t.shiftKey),Xe!=t.altKey&&(console.log("Alt state out of sync"),ke(t.altKey,H.KEY_Alt,i),Xe=t.altKey),lt!=t.ctrlKey&&(console.log("Ctrl state out of sync"),ke(t.ctrlKey,H.KEY_LCtrl,i),lt=t.ctrlKey),xt!=t.metaKey&&(console.log("Meta state out of sync"),ke(t.metaKey,57525,i),xt=t.metaKey))}function Bi(t,e,i,a,g){var w=e,E=0,r,o=0;for(r=t[w++];E*4<i.length;r=t[w++]){var u=E,_=r>>5,l=(r&31)<<8;if(r>=32){var f;if(_--,_==6)do f=t[w++],_+=f;while(f==255);if(f=t[w++],l+=f,f==255&&l-f==7936&&(l=t[w++]<<8,l+=t[w++],l+=8191),_+=1,a==k.LZ_IMAGE_TYPE_RGBA&&(_+=2),l+=1,u-=l,u==E-1)for(var C=u;_;--_){if(a==k.LZ_IMAGE_TYPE_RGBA)i[E*4+3]=i[C*4+3];else for(o=0;o<4;o++)i[E*4+o]=i[C*4+o];E++}else for(;_;--_){if(a==k.LZ_IMAGE_TYPE_RGBA)i[E*4+3]=i[u*4+3];else for(o=0;o<4;o++)i[E*4+o]=i[u*4+o];E++,u++}}else for(r++,a==k.LZ_IMAGE_TYPE_RGBA?i[E*4+3]=t[w++]:(i[E*4+0]=t[w+2],i[E*4+1]=t[w+1],i[E*4+2]=t[w+0],g&&(i[E*4+3]=255),w+=3),E++,--r;r;r--)a==k.LZ_IMAGE_TYPE_RGBA?i[E*4+3]=t[w++]:(i[E*4+0]=t[w+2],i[E*4+1]=t[w+1],i[E*4+2]=t[w+0],g&&(i[E*4+3]=255),w+=3),E++}return w-1}function hl(t){for(var e=t.width*4,i=t.height,a=i,g=new Uint8Array(t.width*t.height*4);a--;)g.set(t.data.subarray(a*e,(a+1)*e),(i-a-1)*e);t.data.set(g)}function er(t,e){var i;if(e.type===k.LZ_IMAGE_TYPE_RGB32||e.type===k.LZ_IMAGE_TYPE_RGBA){var a=new Uint8Array(e.data),g=t.createImageData(e.width,e.height);i=Bi(a,0,g.data,k.LZ_IMAGE_TYPE_RGB32,e.type!=k.LZ_IMAGE_TYPE_RGBA),e.top_down||hl(g),e.type==k.LZ_IMAGE_TYPE_RGBA&&Bi(a,i,g.data,k.LZ_IMAGE_TYPE_RGBA,!1)}else if(e.type===k.LZ_IMAGE_TYPE_XXXA){var a=new Uint8Array(e.data),g=t.createImageData(e.width,e.height);Bi(a,0,g.data,k.LZ_IMAGE_TYPE_RGBA,!1)}else return;return g}function ll(t,e){var i,a,g,w=0,E=0,r=new Uint8Array(e.data);if(!(e.format!=k.SPICE_BITMAP_FMT_32BIT&&e.format!=k.SPICE_BITMAP_FMT_RGBA)){for(e.flags&k.SPICE_BITMAP_FLAGS_TOP_DOWN||(w=(e.y-1)*e.stride,E=2*e.stride),i=t.createImageData(e.x,e.y),a=0;a<e.y*e.stride;w-=E)for(g=0;g<e.x;g++,a+=4,w+=4)i.data[a+0]=r[w+2],i.data[a+1]=r[w+1],i.data[a+2]=r[w+0],e.format==k.SPICE_BITMAP_FMT_32BIT?i.data[a+3]=255:i.data[a+3]=r[w];return i}}function to(t,e,i,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,i,a,e.width,e.height)}function ul(t){var e;for(e=0;e<t.width*t.height*4;e+=4)t.data[e+3]=255}function We(){ye.apply(this,arguments)}We.prototype=Object.create(ye.prototype);We.prototype.process_channel_message=function(t){if(t.type==k.SPICE_MSG_DISPLAY_MODE)return this.known_unimplemented(t.type,"Display Mode"),!0;if(t.type==k.SPICE_MSG_DISPLAY_MARK)return this.known_unimplemented(t.type,"Display Mark"),!0;if(t.type==k.SPICE_MSG_DISPLAY_RESET)return this.surfaces[this.primary_surface].canvas.context.restore(),!0;if(t.type==k.SPICE_MSG_DISPLAY_DRAW_COPY){var e=new hn(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!=k.SPICE_CLIP_TYPE_NONE&&this.log_warn("FIXME: DrawCopy we don't handle clipping yet"),e.data.rop_descriptor!=k.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!=k.SPICE_IMAGE_FLAGS_CACHE_ME&&e.data.src_bitmap.descriptor.flags!=k.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==k.SPICE_IMAGE_TYPE_QUIC){var i=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=Lh(i.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==Ce.QUIC_IMAGE_TYPE_RGBA,descriptor:e.data.src_bitmap.descriptor})}else{if(e.data.src_bitmap.descriptor.type==k.SPICE_IMAGE_TYPE_FROM_CACHE||e.data.src_bitmap.descriptor.type==k.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==k.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 ot;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!=k.SPICE_SURFACE_FMT_32_xRGB,descriptor:e.data.src_bitmap.descriptor})}else if(e.data.src_bitmap.descriptor.type==k.SPICE_IMAGE_TYPE_JPEG){if(!e.data.src_bitmap.jpeg)return this.log_warn("FIXME: DrawCopy could not handle this JPEG file."),!1;var E="data:image/jpeg,",r=new Image,o,u=new Uint8Array(e.data.src_bitmap.jpeg.data);for(o=0;o<u.length;o++)E+="%",u[o]<16&&(E+="0"),E+=u[o].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=zi,r.src=E,!0}else if(e.data.src_bitmap.descriptor.type==k.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 E="data:image/jpeg,",r=new Image,o,u=new Uint8Array(e.data.src_bitmap.jpeg_alpha.data);for(o=0;o<u.length;o++)E+="%",u[o]<16&&(E+="0"),E+=u[o].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==k.SPICE_SURFACE_FMT_32_ARGB){var i=this.surfaces[e.base.surface_id].canvas;r.alpha_img=er(i.context,e.data.src_bitmap.jpeg_alpha.alpha)}return r.onload=zi,r.src=E,!0}else if(e.data.src_bitmap.descriptor.type==k.SPICE_IMAGE_TYPE_BITMAP){var i=this.surfaces[e.base.surface_id].canvas;if(!e.data.src_bitmap.bitmap)return this.log_err("null bitmap"),!1;var a=ll(i.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!=k.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==k.SPICE_IMAGE_TYPE_LZ_RGB){var i=this.surfaces[e.base.surface_id].canvas;if(!e.data.src_bitmap.lz_rgb)return this.log_err("null lz_rgb "),!1;var a=er(i.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==k.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==k.SPICE_MSG_DISPLAY_DRAW_FILL){var _=new ln(t.data);if(_.data.rop_descriptor!=k.SPICE_ROPD_OP_PUT&&this.log_warn("FIXME: DrawFill we don't handle ropd type: "+_.data.rop_descriptor),_.data.mask.flags&&this.log_warn("FIXME: DrawFill we don't handle mask flag: "+_.data.mask.flags),_.data.mask.bitmap&&this.log_warn("FIXME: DrawFill we don't handle mask"),_.data.brush.type==k.SPICE_BRUSH_TYPE_SOLID){var l=_.data.brush.color&16777215,f="rgb("+(l>>16)+", "+(l>>8&255)+", "+(l&255)+")";this.surfaces[_.base.surface_id].canvas.context.fillStyle=f,this.surfaces[_.base.surface_id].canvas.context.fillRect(_.base.box.left,_.base.box.top,_.base.box.right-_.base.box.left,_.base.box.bottom-_.base.box.top),this.surfaces[_.base.surface_id].draw_count++}else this.log_warn("FIXME: DrawFill can't handle brush type: "+_.data.brush.type);return!0}if(t.type==k.SPICE_MSG_DISPLAY_DRAW_OPAQUE)return this.known_unimplemented(t.type,"Display Draw Opaque"),!0;if(t.type==k.SPICE_MSG_DISPLAY_DRAW_BLEND)return this.known_unimplemented(t.type,"Display Draw Blend"),!0;if(t.type==k.SPICE_MSG_DISPLAY_DRAW_BLACKNESS)return this.known_unimplemented(t.type,"Display Draw Blackness"),!0;if(t.type==k.SPICE_MSG_DISPLAY_DRAW_WHITENESS)return this.known_unimplemented(t.type,"Display Draw Whiteness"),!0;if(t.type==k.SPICE_MSG_DISPLAY_DRAW_INVERS)return this.known_unimplemented(t.type,"Display Draw Invers"),!0;if(t.type==k.SPICE_MSG_DISPLAY_DRAW_ROP3)return this.known_unimplemented(t.type,"Display Draw ROP3"),!0;if(t.type==k.SPICE_MSG_DISPLAY_DRAW_STROKE)return this.known_unimplemented(t.type,"Display Draw Stroke"),!0;if(t.type==k.SPICE_MSG_DISPLAY_DRAW_TRANSPARENT)return this.known_unimplemented(t.type,"Display Draw Transparent"),!0;if(t.type==k.SPICE_MSG_DISPLAY_DRAW_ALPHA_BLEND)return this.known_unimplemented(t.type,"Display Draw Alpha Blend"),!0;if(t.type==k.SPICE_MSG_DISPLAY_COPY_BITS){var C=new un(t.data),S=this.surfaces[C.base.surface_id].canvas,g=S.context,m=S.width-C.src_pos.x,s=S.height-C.src_pos.y;m>C.base.box.right-C.base.box.left&&(m=C.base.box.right-C.base.box.left),s>C.base.box.bottom-C.base.box.top&&(s=C.base.box.bottom-C.base.box.top);var a=g.getImageData(C.src_pos.x,C.src_pos.y,m,s);return to(g,a,C.base.box.left,C.base.box.top),this.surfaces[C.base.surface_id].draw_count++,!0}if(t.type==k.SPICE_MSG_DISPLAY_INVAL_ALL_PIXMAPS)return this.known_unimplemented(t.type,"Display Inval All Pixmaps"),!0;if(t.type==k.SPICE_MSG_DISPLAY_INVAL_PALETTE)return this.known_unimplemented(t.type,"Display Inval Palette"),!0;if(t.type==k.SPICE_MSG_DISPLAY_INVAL_ALL_PALETTES)return this.known_unimplemented(t.type,"Inval All Palettes"),!0;if(t.type==k.SPICE_MSG_DISPLAY_SURFACE_CREATE){"surfaces"in this||(this.surfaces=[]);var n=new dn(t.data);if(n.surface.format!=k.SPICE_SURFACE_FMT_32_xRGB&&n.surface.format!=k.SPICE_SURFACE_FMT_32_ARGB)return this.log_warn("FIXME: cannot handle surface format "+n.surface.format+" yet."),!1;var i=document.createElement("canvas");return i.setAttribute("width",n.surface.width),i.setAttribute("height",n.surface.height),i.setAttribute("id","spice_surface_"+n.surface.surface_id),i.setAttribute("tabindex",n.surface.surface_id),i.context=i.getContext("2d"),n.surface.canvas=i,n.surface.draw_count=0,this.surfaces[n.surface.surface_id]=n.surface,n.surface.flags&k.SPICE_SURFACE_FLAGS_PRIMARY&&(this.primary_surface=n.surface.surface_id,i.context.save(),document.getElementById(this.parent.screen_id).appendChild(i),document.getElementById(this.parent.screen_id).style.height=n.surface.height+"px",this.hook_events()),!0}if(t.type==k.SPICE_MSG_DISPLAY_SURFACE_DESTROY){var n=new _n(t.data);return this.delete_surface(n.surface_id),!0}if(t.type==k.SPICE_MSG_DISPLAY_STREAM_CREATE){var n=new Cn(t.data);if(this.streams||(this.streams=new Array),this.streams[n.id]?console.log("Stream "+n.id+" already exists"):this.streams[n.id]=n,n.codec_type==k.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",n.stream_width),h.setAttribute("height",n.stream_height);var d=n.dest.left,b=n.dest.top;this.surfaces[n.surface_id]!==void 0&&(d+=this.surfaces[n.surface_id].canvas.offsetLeft,b+=this.surfaces[n.surface_id].canvas.offsetTop),document.getElementById(this.parent.screen_id).appendChild(h),h.setAttribute("style","pointer-events:none; position: absolute; top:"+b+"px; left:"+d+"px;"),c.addEventListener("sourceopen",_l,!1),c.addEventListener("sourceended",fl,!1),c.addEventListener("sourceclosed",pl,!1);var y=this.streams[n.id];y.video=h,y.media=c,y.queue=new Array,y.start_time=0,y.cluster_time=0,y.append_okay=!1,c.stream=y,c.spiceconn=this,h.spice_stream=y}else n.codec_type==k.SPICE_VIDEO_CODEC_TYPE_MJPEG?this.streams[n.id].frames_loading=0:console.log("Unhandled stream codec: "+n.codec_type);return!0}if(t.type==k.SPICE_MSG_DISPLAY_STREAM_DATA||t.type==k.SPICE_MSG_DISPLAY_STREAM_DATA_SIZED){var n;if(t.type==k.SPICE_MSG_DISPLAY_STREAM_DATA_SIZED?n=new yn(t.data):n=new En(t.data),!this.streams[n.base.id])return console.log("no stream for data"),!1;var A=n.base.multi_media_time-this.parent.relative_now();return this.streams[n.base.id].codec_type===k.SPICE_VIDEO_CODEC_TYPE_MJPEG&&dl(this,n,A),this.streams[n.base.id].codec_type===k.SPICE_VIDEO_CODEC_TYPE_VP8&&vl(this.streams[n.base.id],n),!0}if(t.type==k.SPICE_MSG_DISPLAY_STREAM_ACTIVATE_REPORT){var n=new An(t.data),v=new In(n.stream_id,n.unique_id);return this.streams[n.stream_id]&&(this.streams[n.stream_id].report=v,this.streams[n.stream_id].max_window_size=n.max_window_size,this.streams[n.stream_id].timeout_ms=n.timeout_ms),!0}if(t.type==k.SPICE_MSG_DISPLAY_STREAM_CLIP){var n=new wn(t.data);return this.streams[n.id].clip=n.clip,!0}if(t.type==k.SPICE_MSG_DISPLAY_STREAM_DESTROY){var n=new xn(t.data);return this.streams[n.id].codec_type==k.SPICE_VIDEO_CODEC_TYPE_VP8&&(document.getElementById(this.parent.screen_id).removeChild(this.streams[n.id].video),this.streams[n.id].source_buffer=null,this.streams[n.id].media=null,this.streams[n.id].video=null),this.streams[n.id]=void 0,!0}if(t.type==k.SPICE_MSG_DISPLAY_STREAM_DESTROY_ALL)return this.known_unimplemented(t.type,"Display Stream Destroy All"),!0;if(t.type==k.SPICE_MSG_DISPLAY_INVAL_LIST){var n=new Pn(t.data),o;for(o=0;o<n.count;o++)this.cache[n.resources[o].id]!=null&&delete this.cache[n.resources[o].id];return!0}return t.type==k.SPICE_MSG_DISPLAY_MONITORS_CONFIG?(this.known_unimplemented(t.type,"Display Monitors Config"),!0):t.type==k.SPICE_MSG_DISPLAY_DRAW_COMPOSITE?(this.known_unimplemented(t.type,"Display Draw Composite"),!0):!1};We.prototype.delete_surface=function(t){var i;var e=document.getElementById("spice_surface_"+t);this.primary_surface==t&&(this.unhook_events(),this.primary_surface=void 0,(i=document.getElementById(this.parent.screen_id))==null||i.removeChild(e)),delete this.surfaces[t]};We.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==k.SPICE_SURFACE_FMT_32_xRGB?(ul(t.image_data),e.context.putImageData(t.image_data,t.base.box.left,t.base.box.top)):to(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&k.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};We.prototype.log_draw=function(t,e){var i=t+"."+e.base.surface_id+"."+this.surfaces[e.base.surface_id].draw_count+": ";i+="base.box "+e.base.box.left+", "+e.base.box.top+" to "+e.base.box.right+", "+e.base.box.bottom,i+="; clip.type "+e.base.clip.type,e.data&&(e.data.src_area&&(i+="; 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?(i+="; src_bitmap id: "+e.data.src_bitmap.descriptor.id,i+="; src_bitmap width "+e.data.src_bitmap.descriptor.width+", height "+e.data.src_bitmap.descriptor.height,i+="; src_bitmap type "+e.data.src_bitmap.descriptor.type+", flags "+e.data.src_bitmap.descriptor.flags,e.data.src_bitmap.surface_id!==void 0&&(i+="; src_bitmap surface_id "+e.data.src_bitmap.surface_id),e.data.src_bitmap.bitmap&&(i+="; 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&&(i+="; 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&&(i+="; 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)):i+="; src_bitmap is null",e.data.brush&&(e.data.brush.type==k.SPICE_BRUSH_TYPE_SOLID&&(i+="; brush.color 0x"+e.data.brush.color.toString(16)),e.data.brush.type==k.SPICE_BRUSH_TYPE_PATTERN&&(i+="; brush.pat ",e.data.brush.pattern.pat!=null?i+="[SpiceImage]":i+="[null]",i+=" at "+e.data.brush.pattern.pos.x+", "+e.data.brush.pattern.pos.y)),i+="; rop_descriptor "+e.data.rop_descriptor,e.data.scale_mode!==void 0&&(i+="; scale_mode "+e.data.scale_mode),i+="; mask.flags "+e.data.mask.flags,i+="; mask.pos "+e.data.mask.pos.x+", "+e.data.mask.pos.y,e.data.mask.bitmap!=null?(i+="; mask.bitmap width "+e.data.mask.bitmap.descriptor.width+", height "+e.data.mask.bitmap.descriptor.height,i+="; mask.bitmap type "+e.data.mask.bitmap.descriptor.type+", flags "+e.data.mask.bitmap.descriptor.flags):i+="; mask.bitmap is null"),console.log(i)};We.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",$n),t.addEventListener("mousedown",qn),t.addEventListener("contextmenu",Vn),t.addEventListener("mouseup",Xn),t.addEventListener("keydown",Zn),t.addEventListener("keyup",Jn),t.addEventListener("mouseout",so),t.addEventListener("mouseover",io),t.addEventListener("wheel",Qn),t.focus()}};We.prototype.unhook_events=function(){if(this.primary_surface!==void 0){var t=this.surfaces[this.primary_surface].canvas;t.removeEventListener("mousemove",$n),t.removeEventListener("mousedown",qn),t.removeEventListener("contextmenu",Vn),t.removeEventListener("mouseup",Xn),t.removeEventListener("keydown",Zn),t.removeEventListener("keyup",Jn),t.removeEventListener("mouseout",so),t.removeEventListener("mouseover",io),t.removeEventListener("wheel",Qn)}};We.prototype.destroy_surfaces=function(){for(var t in this.surfaces)this.delete_surface(this.surfaces[t].surface_id);this.surfaces=void 0};function io(t){this.focus()}function so(t){this.sc&&this.sc.cursor&&this.sc.cursor.spice_simulated_cursor&&(this.sc.cursor.spice_simulated_cursor.style.display="none"),this.blur()}function zi(){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 i=document.createElement("canvas"),a=i.getContext("2d");i.setAttribute("width",this.alpha_img.width),i.setAttribute("height",this.alpha_img.height),a.putImageData(this.alpha_img,0,0),a.globalCompositeOperation="source-in",a.drawImage(this,0,0),e.drawImage(i,this.o.base.box.left,this.o.base.box.top),this.o.descriptor&&this.o.descriptor.flags&k.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=Th,this.o.descriptor&&this.o.descriptor.flags&k.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]&&ro(this.o.sc,this.o.id,this.o.msg_mmtime,this.o.msg_mmtime-this.o.sc.parent.relative_now())}function dl(t,e,i){if(i<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 E=new Ot;E.surface_id=t.streams[e.base.id].surface_id,E.box=e.dest||t.streams[e.base.id].dest,E.clip=t.streams[e.base.id].clip,g.o={base:E,tag:"mjpeg."+e.base.id,descriptor:null,sc:t,id:e.base.id,msg_mmtime:e.base.multi_media_time},g.onload=zi,g.src=a,t.streams[e.base.id].frames_loading++}function ro(t,e,i,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=i),t.streams[e].report.num_frames>t.streams[e].max_window_size||i-t.streams[e].report.start_frame_mm_time>t.streams[e].timeout_ms){t.streams[e].report.end_frame_mm_time=i,t.streams[e].report.last_frame_delay=a;var g=new le;g.build_msg(k.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 _l(t){var e=this.stream,i=this.spiceconn;if(!e.source_buffer){var a=this.addSourceBuffer(_e.SPICE_VP8_CODEC);if(!a){i.log_err("Codec "+_e.SPICE_VP8_CODEC+" not available.");return}e.source_buffer=a,a.spiceconn=i,a.stream=e,Cl(e);var g=new ps,w=new Wn(this.stream.stream_width,this.stream.stream_height),E=new ds(w),r=new ArrayBuffer(g.buffer_size()+E.buffer_size()),o=g.to_buffer(r);E.to_buffer(r,o),a.addEventListener("error",gl,!1),a.addEventListener("updateend",ml,!1),vs(a,r)}}function fl(t){var e=this.spiceconn;e.log_err("Video source unexpectedly ended.")}function pl(t){var e=this.spiceconn;e.log_err("Video source unexpectedly closed.")}function vs(t,e){try{t.stream.append_okay=!1,t.appendBuffer(e)}catch(a){var i=t.spiceconn;i.log_err("Error invoking appendBuffer: "+a.message)}}function ml(t){var e=this.stream;if(e.current_frame&&"report"in e){var i=this.stream.media.spiceconn,a=this.stream.current_frame.msg_mmtime;ro(i,e.id,a,a-i.parent.relative_now())}if(e.queue.length>0?(e.current_frame=e.queue.shift(),vs(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 gl(t){var e=this.spiceconn;e.log_err("source_buffer error "+t.message)}function no(t,e,i){var a={msg_mmtime:e.base.multi_media_time};t.append_okay?(t.current_frame=a,vs(t.source_buffer,i)):(a.mb=i,t.queue.push(a))}function oo(t,e,i){var a=new fs(e.base.multi_media_time-t.cluster_time,e.data,i),g=new ArrayBuffer(a.buffer_size());a.to_buffer(g),no(t,e,g)}function tr(t,e){t.cluster_time=e.base.multi_media_time;var i=new _s(t.cluster_time-t.start_time,e.data),a=new ArrayBuffer(i.buffer_size());i.to_buffer(a),no(t,e,a),oo(t,e,!0)}function vl(t,e){t.start_time==0?(t.start_time=e.base.multi_media_time,tr(t,e)):e.base.multi_media_time-t.cluster_time>=_e.MAX_CLUSTER_TIME?tr(t,e):oo(t,e,!1)}function Sl(t){var e=this.spice_stream;e.video&&e.video.buffered.len>1&&console.log(e.video.currentTime+":id "+e.id+" event "+t.type+Yr(e.video)),e.queue.length>1&&console.log(" queue len "+e.queue.length+"; append_okay: "+e.append_okay)}function bl(t){this.addEventListener(t,Sl)}function Cl(t){var e=["abort","error"];e.forEach(bl,t.video)}function vt(){ye.apply(this,arguments),this.queue=new Array,this.append_okay=!1,this.start_time=0}vt.prototype=Object.create(ye.prototype);vt.prototype.process_channel_message=function(t){if(!window.MediaSource)return this.log_err("MediaSource API is not available"),!1;if(t.type==k.SPICE_MSG_PLAYBACK_START){var e=new Sn(t.data);if(e.frequency!=_e.OPUS_FREQUENCY)return this.log_err("This player cannot handle frequency "+e.frequency),!1;if(e.channels!=_e.OPUS_CHANNELS)return this.log_err("This player cannot handle "+e.channels+" channels"),!1;if(e.format!=k.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",El,!1),this.media_source.addEventListener("sourceended",yl,!1),this.media_source.addEventListener("sourceclosed",wl,!1),this.bytes_written=0,!0}if(t.type==k.SPICE_MSG_PLAYBACK_DATA){var i=new gn(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&&i.time!=this.last_data_time+_e.EXPECTED_PACKET_DURATION&&Math.abs(i.time-(_e.EXPECTED_PACKET_DURATION+this.last_data_time))<_e.MAX_CLUSTER_TIME&&(i.time=this.last_data_time+_e.EXPECTED_PACKET_DURATION),this.last_data_time=i.time,this.start_time==0?this.start_playback(i):i.time-this.cluster_time>=_e.MAX_CLUSTER_TIME?this.new_cluster(i):this.simple_block(i,!1)),!0}if(t.type==k.SPICE_MSG_PLAYBACK_MODE){var a=new vn(t.data);return a.mode!=k.SPICE_AUDIO_DATA_MODE_OPUS&&(this.log_err("This player cannot handle mode "+a.mode),delete this.source_buffer),!0}return t.type==k.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==k.SPICE_MSG_PLAYBACK_VOLUME?(this.known_unimplemented(t.type,"Playback Volume"),!0):t.type==k.SPICE_MSG_PLAYBACK_MUTE?(this.known_unimplemented(t.type,"Playback Mute"),!0):t.type==k.SPICE_MSG_PLAYBACK_LATENCY?(this.known_unimplemented(t.type,"Playback Latency"),!0):!1};vt.prototype.start_playback=function(t){this.start_time=t.time;var e=new ps,i=new zn,a=new ds(i),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",Il,!1),this.source_buffer.addEventListener("updateend",Al,!1),bi(this,g),this.new_cluster(t)};vt.prototype.new_cluster=function(t){this.cluster_time=t.time;var e=new _s(t.time-this.start_time),i=new ArrayBuffer(e.buffer_size());this.bytes_written+=e.to_buffer(i),this.append_okay?bi(this,i):this.queue.push(i),this.simple_block(t,!0)};vt.prototype.simple_block=function(t,e){var i=new fs(t.time-this.cluster_time,t.data,e),a=new ArrayBuffer(i.buffer_size());this.bytes_written+=i.to_buffer(a),this.append_okay?bi(this,a):this.queue.push(a)};function El(t){var e=this.spiceconn;if(!e.source_buffer){if(e.source_buffer=this.addSourceBuffer(_e.SPICE_PLAYBACK_CODEC),!e.source_buffer){e.log_err("Codec "+_e.SPICE_PLAYBACK_CODEC+" not available.");return}Ll(e),e.source_buffer.spiceconn=e,e.source_buffer.mode="segments"}}function yl(t){var e=this.spiceconn;e.log_err("Audio source unexpectedly ended.")}function wl(t){var e=this.spiceconn;e.log_err("Audio source unexpectedly closed.")}function xl(t){if(t.length==1)return t.shift();var e=0,i=0;for(i=0;i<t.length;i++)e+=t[i].byteLength;var a=new ArrayBuffer(e),g=new Uint8Array(a);for(e=0,i=0;i<t.length;i++)g.set(new Uint8Array(t[i]),e),e+=t[i].byteLength;return t.length=0,a}function Al(t){var e=this.spiceconn;if(e.queue.length>0){var i=xl(e.queue);bi(e,i)}else e.append_okay=!0}function Il(t){var e=this.spiceconn;e.log_err("source_buffer error "+t.message)}function bi(t,e){try{t.source_buffer.appendBuffer(e),t.append_okay=!1}catch(i){t.log_err("Error invoking appendBuffer: "+i.message)}}function Pl(t){var e=this.spiceconn;e.audio&&e.audio.buffered.len>1&&console.log(e.audio.currentTime+": event "+t.type+Yr(e.audio)),e.queue.length>1&&console.log(" queue len "+e.queue.length+"; append_okay: "+e.append_okay)}function Dl(t){this.addEventListener(t,Pl)}function Ll(t){var e=["abort","error"];e.forEach(Dl,t.audio)}function Ss(){ye.apply(this,arguments),this.port_name=null}Ss.prototype=Object.create(ye.prototype);Ss.prototype.process_channel_message=function(t){if(t.type==k.SPICE_MSG_PORT_INIT){if(this.port_name===null){var e=new Dn(t.data);return this.portName=Rh(new Uint8Array(e.name)),this.portOpened=e.opened,!0}}else if(t.type==k.SPICE_MSG_PORT_EVENT){var i=new CustomEvent("spice-port-event",{detail:{channel:this,spiceEvent:new Uint8Array(t.data)},bubbles:!0,cancelable:!0});return window.dispatchEvent(i),!0}else if(t.type==k.SPICE_MSG_SPICEVMC_DATA){var i=new CustomEvent("spice-port-data",{detail:{channel:this,data:t.data},bubbles:!0,cancelable:!0});return window.dispatchEvent(i),!0}return!1};function Ml(t){if(t){var e=document.getElementById(t.screen_id).clientWidth,i=document.getElementById("spice-area"),a=document.isFullScreen||document.fullscreenElement||document.webkitIsFullScreen||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement,g=window.innerHeight-i.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 Tl(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(Ml,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==k.SPICE_MSG_MAIN_MIGRATE_BEGIN)return this.known_unimplemented(t.type,"Main Migrate Begin"),!0;if(t.type==k.SPICE_MSG_MAIN_MIGRATE_CANCEL)return this.known_unimplemented(t.type,"Main Migrate Cancel"),!0;if(t.type==k.SPICE_MSG_MAIN_INIT){this.log_info("Connected to "+this.ws.url),this.report_success("Connected"),this.main_init=new Vr(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=k.SPICE_MSGC_MAIN_ATTACH_CHANNELS,e.size=e.buffer_size(),this.send_msg(e),!0}if(t.type==k.SPICE_MSG_MAIN_MOUSE_MODE){var i=new Xr(t.data);return this.handle_mouse_mode(i.current_mode,i.supported_modes),!0}if(t.type==k.SPICE_MSG_MAIN_MULTI_MEDIA_TIME)return this.known_unimplemented(t.type,"Main Multi Media Time"),!0;if(t.type==k.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==k.SPICE_CHANNEL_DISPLAY?g.channels[a].id==0?this.display=new We(w):this.log_warn("The spice-html5 client does not handle multiple heads."):g.channels[a].type==k.SPICE_CHANNEL_INPUTS?(this.inputs=new ms(w),this.inputs.mouse_mode=this.mouse_mode):g.channels[a].type==k.SPICE_CHANNEL_CURSOR?this.cursor=new vi(w):g.channels[a].type==k.SPICE_CHANNEL_PLAYBACK?this.cursor=new vt(w):g.channels[a].type==k.SPICE_CHANNEL_PORT?this.ports.push(new Ss(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==k.SPICE_MSG_MAIN_AGENT_CONNECTED)return this.connect_agent(),!0;if(t.type==k.SPICE_MSG_MAIN_AGENT_CONNECTED_TOKENS){var E=new Ki(t.data);return this.agent_tokens=E.num_tokens,this.connect_agent(),!0}if(t.type==k.SPICE_MSG_MAIN_AGENT_TOKEN){var r,o=new Ki(t.data);for(this.agent_tokens+=o.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==k.SPICE_MSG_MAIN_AGENT_DISCONNECTED)return this.agent_connected=!1,!0;if(t.type==k.SPICE_MSG_MAIN_AGENT_DATA){var _=new Qr(t.data);if(_.type==k.VD_AGENT_ANNOUNCE_CAPABILITIES){var l=new os(_.data);return l.request&&this.announce_agent_capabilities(0),!0}else if(_.type==k.VD_AGENT_FILE_XFER_STATUS)return this.handle_file_xfer_status(new as(_.data)),!0;return!1}return t.type==k.SPICE_MSG_MAIN_MIGRATE_SWITCH_HOST?(this.known_unimplemented(t.type,"Main Migrate Switch Host"),!0):t.type==k.SPICE_MSG_MAIN_MIGRATE_END?(this.known_unimplemented(t.type,"Main Migrate End"),!0):t.type==k.SPICE_MSG_MAIN_NAME?(this.known_unimplemented(t.type,"Main Name"),!0):t.type==k.SPICE_MSG_MAIN_UUID?(this.known_unimplemented(t.type,"Main UUID"),!0):t.type==k.SPICE_MSG_MAIN_MIGRATE_BEGIN_SEAMLESS?(this.known_unimplemented(t.type,"Main Migrate Begin Seamless"),!0):t.type==k.SPICE_MSG_MAIN_MIGRATE_DST_SEAMLESS_ACK?(this.known_unimplemented(t.type,"Main Migrate Dst Seamless ACK"),!0):t.type==k.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 i=new sn(t,e),a=0,g=k.VD_AGENT_MAX_DATA_SIZE-le.prototype.buffer_size(),w=new ArrayBuffer(i.buffer_size());for(i.to_buffer(w);a<i.buffer_size();){var E=Math.min(a+g,i.buffer_size()),r=new le;r.type=k.SPICE_MSGC_MAIN_AGENT_DATA,r.size=E-a,r.data=w.slice(a,E),this.send_agent_message_queue(r),a=E}};we.prototype.announce_agent_capabilities=function(t){var e=new os(t,1<<k.VD_AGENT_CAP_MOUSE_STATE|1<<k.VD_AGENT_CAP_MONITORS_CONFIG|1<<k.VD_AGENT_CAP_REPLY);this.send_agent_message(k.VD_AGENT_ANNOUNCE_CAPABILITIES,e)};we.prototype.resize_window=function(t,e,i,a,g,w){var E=new rn(t,e,i,a,g,w);this.send_agent_message(k.VD_AGENT_MONITORS_CONFIG,E)};we.prototype.file_xfer_start=function(t){var e,i,a;e=this.file_xfer_task_id++,a=new Si(e,t),a.create_progressbar(),this.file_xfer_tasks[e]=a,i=new nn(e,t.name,t.size),this.send_agent_message(k.VD_AGENT_FILE_XFER_START,i)};we.prototype.handle_file_xfer_status=function(t){var e,i;if(this.file_xfer_tasks[t.id]){switch(i=this.file_xfer_tasks[t.id],t.result){case k.VD_AGENT_FILE_XFER_STATUS_CAN_SEND_DATA:this.file_xfer_read(i);return;case k.VD_AGENT_FILE_XFER_STATUS_CANCELLED:e="transfer is cancelled by spice agent";break;case k.VD_AGENT_FILE_XFER_STATUS_ERROR:e="some errors occurred in the spice agent";break;case k.VD_AGENT_FILE_XFER_STATUS_SUCCESS:break;default:e="unhandled status type: "+t.result;break}this.file_xfer_completed(i,e)}};we.prototype.file_xfer_read=function(t,e){var i=32*k.VD_AGENT_MAX_DATA_SIZE,a=this,g,w,E,r;if(!(!t||!this.file_xfer_tasks[t.id]||e>0&&e==t.file.size)){if(t.cancelled){var o=new as(t.id,k.VD_AGENT_FILE_XFER_STATUS_CANCELLED);this.send_agent_message(k.VD_AGENT_FILE_XFER_STATUS,o),delete this.file_xfer_tasks[t.id];return}if(g=e||0,w=Math.min(g+i,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 _=new on(t.id,u.target.result.byteLength,u.target.result);a.send_agent_message(k.VD_AGENT_FILE_XFER_DATA,_),a.file_xfer_read(t,w),t.update_progressbar(w)},E=t.file.slice(g,w),r.readAsArrayBuffer(E)}};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 tn(-1),e=new le;e.build_msg(k.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!=k.SPICE_MOUSE_MODE_CLIENT&&e&k.SPICE_MOUSE_MODE_CLIENT){var i=new en(k.SPICE_MOUSE_MODE_CLIENT),a=new le;a.build_msg(k.SPICE_MSGC_MAIN_MOUSE_MODE_REQUEST,i),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 Rl=({instance:t,onMount:e,onFailure:i})=>{var S;const{name:a,project:g}=nt(),w=N.useNotify(),E=Z.useRef(null),[r,o]=Z.useState(!1),u=t.status==="Running",_=m=>{i("Error",m)},l=()=>{_t("spice-wrapper"),Tl()},f=async()=>{if(!a){i("Missing name",new Error);return}if(!g){i("Missing project",new Error);return}o(!0);const m=await Bo(a,g).catch(d=>{o(!1),u&&i("Connection failed",d)});if(!m)return;const s=m.operation.split("?")[0],n=`wss://${location.host}${s}/websocket?secret=${m.metadata.metadata.fds[0]}`,c=`wss://${location.host}${s}/websocket?secret=${m.metadata.metadata.fds.control}`,h=new WebSocket(c);h.onerror=_,h.onclose=d=>{d.code!==1005&&i("Error",d.reason,It(d.code))},h.onmessage=d=>{console.log("control message",d)};try{window.spice_connection=new we({uri:n,screen_id:"spice-screen",onerror:_,onsuccess:()=>{o(!1),l()},onagent:l})}catch(d){u&&i("Connection failed",d)}return h};return Ne("resize",l),Z.useEffect(l,[(S=w.notification)==null?void 0:S.message]),Ne("spice-wheel",m=>{var n;if(!((n=E.current)!=null&&n.parentElement)||!("detail"in m))return;const s=m.detail.wheelEvent;E.current.parentElement.scrollBy(s.deltaX,s.deltaY)}),Z.useEffect(()=>{w.clear();const m=f();return()=>{var s;try{(s=window.spice_connection)==null||s.stop()}catch(n){console.error(n)}m.then(n=>n==null?void 0:n.close())}},[t.status]),e(()=>{const m=E.current;m&&m.requestFullscreen().then(l).catch(s=>{i("Failed to enter full-screen mode",s)})}),p.jsx(p.Fragment,{children:r?p.jsx(tt,{text:"Loading VGA session..."}):p.jsx("div",{id:"spice-area",ref:E,children:p.jsx("div",{id:"spice-screen",className:"spice-screen"})})})},kl=({instance:t,onFailure:e,showNotRunningInfo:i})=>{const{name:a,project:g}=nt(),w=new TextEncoder,[E,r]=Z.useState(!1),[o,u]=Z.useState(""),[_,l]=Z.useState(null),[f]=Z.useState(new br.FitAddon),[C,S]=Z.useState(!1),m=Z.useRef(null),s=N.useNotify();sr({when:C,message:"Are you sure you want to leave this page?"}),Ne("beforeunload",y=>{C&&(y.returnValue="Are you sure you want to leave this page?")});const c=t.status==="Running",h=y=>{e("Error",y)},d=async()=>{if(!a){e("Missing name",new Error);return}if(!g){e("Missing project",new Error);return}r(!0),Oo(a,g).then(u).catch(console.error);const y=await No(a,g).catch(L=>{r(!1),c?e("Connection failed",L):i()});if(!y)return;const A=y.operation.split("?")[0],v=`wss://${location.host}${A}/websocket?secret=${y.metadata.metadata.fds[0]}`,x=`wss://${location.host}${A}/websocket?secret=${y.metadata.metadata.fds.control}`,D=new WebSocket(v),T=new WebSocket(x);return T.onopen=()=>{r(!1)},T.onerror=h,T.onclose=L=>{L.code!==1005&&e("Error",L.reason,It(L.code))},D.onopen=()=>{l(D)},D.onerror=h,D.onclose=L=>{L.code!==1005&&e("Error",L.reason,It(L.code)),l(null),S(!1)},D.binaryType="arraybuffer",D.onmessage=L=>{var B;(B=m.current)==null||B.write(new Uint8Array(L.data))},[D,T]};Z.useEffect(()=>{var y;c&&((y=m.current)==null||y.focus())},[c]),Z.useEffect(()=>{if(_)return;s.clear();const y=d();return()=>{y.then(A=>{A==null||A.map(v=>{v.close()})})}},[f,t.status]),Z.useEffect(()=>{!o||!m.current||E||(m.current.write(o),u(""))},[o,E]);const b=()=>{var y,A;_t("p-terminal",void 0,10),(A=(y=m.current)==null?void 0:y.element)==null||A.style.setProperty("padding","1rem"),f.fit()};return Ne("resize",()=>{b(),setTimeout(b,500)}),p.jsx(p.Fragment,{children:E?p.jsx(tt,{text:"Loading text console..."}):p.jsx(Er,{ref:m,addons:[f],onData:y=>{S(!0),_==null||_.send(w.encode(y))},className:"p-terminal",onOpen:b})})},Bl=({instance:t})=>{const e=Ee(),{project:i}=nt(),a=Ie(),g=Ue(),{openPortal:w,closePortal:E,isOpen:r,Portal:o}=N.usePortal(),[u,_]=Z.useState(!1),{canEditInstance:l}=Oe(),f=t.devices["iso-volume"],C=()=>{_(!0);const s=ut(t);s.devices=s.devices.filter(h=>h.name!=="iso-volume");const n=zt(t,s),c=p.jsx(ue,{instance:t});Yt(n,i??"").then(h=>{e.set(h.metadata.id,()=>a.success(p.jsxs(p.Fragment,{children:["ISO"," ",p.jsx(Fe,{to:`/ui/project/${i}/storage/custom-isos`,type:"iso-volume",value:(f==null?void 0:f.source)??""})," ","detached from ",c]})),d=>a.failure("Detaching ISO failed.",new Error(d),c),()=>{g.invalidateQueries({queryKey:[de.instances,t.name,i]}),_(!1)})}).catch(h=>{_(!1),a.failure("Detaching ISO failed.",h,c)})},S=s=>{_(!0),E();const n=ut(t),c=Jo(s);n.devices.push(c);const h=zt(t,n);Yt(h,i??"").then(d=>{const b=gr({operation:d,project:i,instanceType:t.type});e.set(d.metadata.id,()=>a.success(p.jsxs(p.Fragment,{children:["ISO"," ",p.jsx(Fe,{to:`/ui/project/${i}/storage/custom-isos`,type:"iso-volume",value:s.aliases})," ","attached to ",b]})),y=>a.failure("Attaching ISO failed.",new Error(y),b),()=>{g.invalidateQueries({queryKey:[de.instances,t.name,i]}),_(!1)})}).catch(d=>{_(!1),a.failure("Attaching ISO failed.",d)})},m=l(t)?void 0:"You do not have permission to edit this instance.";return f?p.jsxs(p.Fragment,{children:[p.jsx("span",{className:"u-text--muted margin-right",children:f.source}),p.jsx(N.ActionButton,{loading:u,onClick:C,className:"u-no-margin--bottom",disabled:!!m,title:m,children:"Detach ISO"})]}):p.jsxs(p.Fragment,{children:[p.jsx(N.ActionButton,{loading:u,onClick:w,className:"u-no-margin--bottom",disabled:!!m,title:m,children:"Attach ISO"}),r&&p.jsx(o,{children:p.jsx(Vo,{onClose:E,onSelect:S})})]})},Ol=({instance:t})=>{const e=N.useNotify(),i=t.type==="virtual-machine",[a,g]=Z.useState(i),{hasCustomVolumeIso:w}=po(),{canUpdateInstanceState:E,canAccessInstanceConsole:r}=Oe(),o=t.status==="Running",u=(s,n,c)=>{e.failure(s,n,c)},_=()=>{e.info("Start the instance to interact with the text console.","Instance not running")};let l=()=>{};const f=s=>{l=s},C=s=>{e.clear(),g(s)},{handleStart:S,isLoading:m}=ar(t);return r(t)?p.jsxs("div",{className:"instance-console-tab",children:[i&&p.jsxs("div",{className:"p-panel__controls",children:[p.jsxs("div",{className:"console-radio-wrapper",children:[p.jsx(N.RadioInput,{labelClassName:"right-margin",label:"Graphic",checked:a,onChange:()=>{C(!0)}}),p.jsx(N.RadioInput,{label:"Text console",checked:!a,onChange:()=>{C(!1)}})]}),a&&o&&p.jsxs("div",{children:[w&&p.jsx(Bl,{instance:t}),p.jsx(N.Button,{className:"u-no-margin--bottom",onClick:()=>{l()},children:p.jsx("span",{children:"Fullscreen"})}),p.jsx(N.ContextualMenu,{hasToggleIcon:!0,toggleLabel:"Shortcuts",toggleClassName:"u-no-margin--bottom",links:[{children:"Send Ctrl + Alt + Del",onClick:()=>{ol(window.spice_connection)}},{children:"Send Alt + TAB",onClick:()=>{cl(window.spice_connection)}},{children:"Send Alt + F4",onClick:()=>{al(window.spice_connection)}}]})]})]}),p.jsx(oi,{}),a&&!o&&p.jsxs(N.EmptyState,{className:"empty-state",image:p.jsx(N.Icon,{name:"pods",className:"empty-state-icon"}),title:"Instance stopped",children:[p.jsx("p",{children:"Start the instance to access the graphic console."}),p.jsx(N.ActionButton,{appearance:"positive",loading:m,onClick:S,disabled:!E(t),title:E(t)?"":"You do not have permission to start this instance.",children:"Start instance"})]}),a&&o&&p.jsx("div",{className:"spice-wrapper",children:p.jsx(Rl,{instance:t,onMount:f,onFailure:u})}),!a&&p.jsx(kl,{instance:t,onFailure:u,showNotRunningInfo:_})]}):p.jsx(N.Notification,{severity:"caution",title:"Restricted permissions",children:"You do not have permission to access the console for this instance."})},Nl=({instance:t,content:e,fileName:i})=>{const a=Z.useRef(null),g=(E,r)=>{const o=document.createElement("a");return o.setAttribute("href",r),o.setAttribute("target","_blank"),o.setAttribute("download",i),o.setAttribute("id",E),o.style.display="none",o},w=async()=>{var f;const E=`link-${i.toLowerCase().replace(" ","-")}`,r=document.getElementById(E);if(r){r.click();return}const o=e||await dr(t.name,t.project,i),u=new Blob([o],{type:"text/plain"}),_=URL.createObjectURL(u),l=g(E,_);(f=a.current)==null||f.appendChild(l),l.click()};return p.jsx(N.Button,{appearance:"base",className:"u-no-margin--bottom",onClick:()=>void w(),title:`Download ${i}`,"aria-label":`Download ${i} file`,hasIcon:!0,dense:!0,ref:a,children:p.jsx(N.Icon,{name:"begin-downloading",alt:"download"})})},Ul=({instance:t,path:e})=>{const i=e.split("/").at(-1)??"",a=`/ui/project/${t.project}/instance/${t.name}/logs/?file=${i}`,[g,w]=Z.useState(mo("file")===i),{data:E,isLoading:r,isSuccess:o}=qi({queryKey:[de.instances,t.name,t.project,de.logs,i],queryFn:async()=>dr(t.name,t.project,i),enabled:g}),u=()=>{w(_=>!_)};return p.jsxs("div",{className:"p-code-snippet file-row",children:[p.jsxs("div",{className:"p-code-snippet__header file-row-header",children:[p.jsxs(N.Button,{appearance:"base",hasIcon:!0,className:"u-no-margin--bottom file-row-toggle","aria-label":`Toggle ${i} visibility`,"aria-controls":i,"aria-hidden":!g,onClick:u,children:[p.jsx(N.Icon,{name:g?"chevron-up":"chevron-down"}),p.jsx("h2",{className:"p-code-snippet__title file-row-title",children:i})]}),p.jsx("a",{href:a,"aria-label":`File ${i} URL`,className:"p-button--base u-no-margin--bottom",children:p.jsx(N.Icon,{name:"get-link",alt:"link"})}),p.jsx(Nl,{fileName:i,instance:t,content:E??""})]}),g&&p.jsx("pre",{id:i,className:"p-code-snippet__block","aria-hidden":!g,children:p.jsxs("code",{children:[r&&p.jsx(p.Fragment,{children:"Downloading file content..."}),o&&!E&&p.jsx(p.Fragment,{children:"This file is empty."}),o&&E&&p.jsx(p.Fragment,{children:E})]})})]})},jl=({instance:t})=>{const{data:e=[],isLoading:i}=qi({queryKey:[de.instances,t.name,t.project,de.logs],queryFn:async()=>Uo(t.name,t.project)});return p.jsxs(p.Fragment,{children:[i&&p.jsx(tt,{text:"Loading logs..."}),!i&&e.length===0&&p.jsx("div",{className:"u-align-text--center",children:"There are no log files for this instance."}),!i&&e.length>0&&e.map(a=>p.jsx(Ul,{instance:t,path:a},a))]})},Fl=({instanceProfiles:t,profiles:e})=>t.some(a=>!(e!=null&&e.find(g=>g.name===a)))?p.jsx(N.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,Hl=({instance:t})=>{const e=or(),i=Ee(),a=Ie(),{project:g,section:w}=nt(),E=Ue(),r=Bt(),[o,u]=Z.useState(0),{canEditInstance:_}=Oe();if(!g)return p.jsx(p.Fragment,{children:"Missing project"});const{data:l=[]}=ir(g),f=()=>{_t("form-contents","p-bottom-controls")};Z.useEffect(f,[w]),Ne("resize",f);const C=_(t)?void 0:"You do not have permission to edit this instance",S=Ke({initialValues:ut(t,C),validationSchema:vr,enableReinitialize:!0,onSubmit:c=>{const h=c.yaml?ua(c.yaml):zt(t,c);h.etag=t.etag;const d=p.jsx(ue,{instance:t});Yt(h,g).then(b=>{i.set(b.metadata.id,()=>{a.success(p.jsxs(p.Fragment,{children:["Instance ",d," updated."]})),S.setValues(ut(h))},y=>a.failure("Instance update failed.",new Error(y),d),()=>{S.setSubmitting(!1),E.invalidateQueries({queryKey:[de.instances]})})}).catch(b=>{S.setSubmitting(!1),a.failure("Instance update failed.",b,d)})}}),m=c=>{S.values.yaml&&c!==wt&&S.setFieldValue("yaml",void 0);const h=`/ui/project/${g}/instance/${t.name}/configuration`;r(c===Ai?h:`${h}/${me(c)}`)},s=()=>{const c=new Set(["backups","snapshots","state","expanded_config","expanded_devices","etag"]),h=Object.fromEntries(Object.entries(t).filter(d=>!c.has(d[0])));return xa(h)},n=S.values.readOnly;return p.jsxs("div",{className:"edit-instance",children:[p.jsxs(N.Form,{onSubmit:S.handleSubmit,className:"form",children:[w!==me(wt)&&p.jsx(da,{active:w??me(Ai),setActive:m,isDisabled:!1,hasDiskError:ys(S),hasNetworkError:Es(S)}),p.jsx(N.Row,{className:"form-contents",children:p.jsxs(N.Col,{size:12,children:[w!==me(wt)&&p.jsx(Fl,{instanceProfiles:t.profiles,profiles:l}),(w===me(Ai)||!w)&&p.jsx(ea,{formik:S,project:g}),w===me(_a)&&p.jsx(Aa,{formik:S,project:g}),w===me(fa)&&p.jsx(Ia,{formik:S,project:g}),w===me(pa)&&p.jsx(Pa,{formik:S,project:g}),w===me(ma)&&p.jsx(Da,{formik:S,project:g}),w===me(ga)&&p.jsx(La,{formik:S,project:g}),w===me(va)&&p.jsx(ta,{formik:S}),w===me(Sa)&&p.jsx(ia,{formik:S}),w===me(ba)&&p.jsx(Sr,{formik:S}),w===me(Ca)&&p.jsx(sa,{formik:S}),w===me(Ea)&&p.jsx(ra,{formik:S}),w===me(ya)&&p.jsx(na,{formik:S},`yaml-form-${o}`),w===me(wt)&&p.jsx(oa,{yaml:s(),setYaml:c=>{aa(S),S.setFieldValue("yaml",c)},readOnly:!!S.values.editRestriction,readOnlyMessage:S.values.editRestriction,children:p.jsx(Ta,{entity:"instance",href:`${e}/instances`})},`yaml-form-${o}`)]})},w)]}),p.jsxs(Ma,{children:[p.jsx(wa,{formik:S,section:w,setSection:m}),n?null:p.jsxs(p.Fragment,{children:[p.jsx(N.Button,{appearance:"base",onClick:()=>{S.setValues(ut(t)),u(c=>c+1)},children:"Cancel"}),p.jsx(Ra,{formik:S,isYaml:w===me(wt),disabled:ys(S)||Es(S)})]})]})]})},Kl=({instance:t,classname:e,onClose:i})=>{const a=Ee(),g=Ie(),w=Ue(),E=ni(),[r,o]=Z.useState(!1),u=Bt(),{canDeleteInstance:_}=Oe(),l=()=>{o(!0);const m=p.jsx(ue,{instance:t});jo(t).then(s=>{a.set(s.metadata.id,()=>{w.invalidateQueries({queryKey:[de.projects,t.project]}),u(`/ui/project/${t.project}/instances`),g.success(p.jsxs(p.Fragment,{children:["Instance"," ",p.jsx(ai,{bold:!0,type:t.type,value:t.name})," ","deleted."]}))},n=>g.failure("Instance deletion failed",new Error(n),m),()=>{o(!1)})}).catch(s=>{g.failure("Instance deletion failed",s,m),o(!1)})},f=Po.includes(t.status),C=r||!f||E.getType(t)==="Migrating"||!_(t),S=()=>_(t)?f?"Delete instance":"Stop the instance to delete it":"You do not have permission to delete this instance";return p.jsxs(N.ConfirmationButton,{onHoverText:S(),appearance:"default",className:it("u-no-margin--bottom has-icon",e),loading:r,confirmationModalProps:{close:i,title:"Confirm delete",children:p.jsxs("p",{children:["This will permanently delete instance"," ",p.jsx(Pt,{item:t,bold:!0}),".",p.jsx("br",{}),"This action cannot be undone, and can result in data loss."]}),onConfirm:l,confirmButtonLabel:"Delete"},disabled:C,shiftClickEnabled:!0,showShiftClickHint:!0,children:[p.jsx(N.Icon,{name:"delete"}),p.jsx("span",{children:"Delete"})]})},Gl=({onSelect:t,disableMember:e})=>{const{data:i=[],isLoading:a}=qi({queryKey:[de.cluster,de.members],queryFn:go}),g=[{content:"Name",sortKey:"name"},{content:"Roles",sortKey:"roles"},{content:"Architecture",sortKey:"architecture"},{content:"Status",sortKey:"status"},{"aria-label":"Actions",className:"actions"}],w=i.map(E=>{const r=(e==null?void 0:e.name)===E.server_name?e==null?void 0:e.reason:null,o=()=>{r||t(E.server_name)};return{key:E.server_name,className:it("u-row",{"u-text--muted":r,"u-row--disabled":r}),columns:[{content:p.jsx("div",{className:"u-truncate migrate-instance-name",title:E.server_name,children:E.server_name}),role:"cell","aria-label":"Name",onClick:o},{content:E.roles.join(", "),role:"cell","aria-label":"Roles",onClick:o},{content:E.architecture,role:"cell","aria-label":"Architecture",onClick:o},{content:E.status,role:"cell","aria-label":"Status",onClick:o},{content:p.jsx(N.Button,{onClick:o,dense:!0,title:r,disabled:!!r,children:"Select"}),role:"cell","aria-label":"Actions",className:"u-align--right",onClick:o}],sortData:{name:E.server_name.toLowerCase(),roles:E.roles.join(", ").toLowerCase(),architecture:E.architecture.toLowerCase(),status:E.status.toLowerCase()}}});return p.jsx("div",{className:"migrate-instance-table u-selectable-table-rows",children:p.jsx(Xi,{dependencies:[i],tableId:"migrate-instance-table",belowIds:["status-bar","migrate-instance-actions"],children:p.jsx(N.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"})})})},Yl=({instance:t,onSelect:e,targetMember:i,onCancel:a,migrate:g})=>{const w=p.jsx("div",{className:"migrate-instance-summary",children:p.jsxs("p",{children:["This will migrate instance ",p.jsx("strong",{children:t.name})," to cluster member ",p.jsx("b",{children:i}),"."]})});return p.jsxs(p.Fragment,{children:[i&&w,!i&&p.jsx(Gl,{onSelect:e,disableMember:{name:t.location,reason:"Instance already on this member"}}),p.jsxs("footer",{id:"migrate-instance-actions",className:"p-modal__footer",children:[p.jsx(N.Button,{className:"u-no-margin--bottom",type:"button","aria-label":"cancel migrate",appearance:"base",onClick:a,children:"Cancel"}),p.jsx(N.ActionButton,{appearance:"positive",className:"u-no-margin--bottom",onClick:()=>{g(i)},disabled:!i,children:"Migrate"})]})]})},zl=({instance:t,onSelect:e,targetPool:i,onCancel:a,migrate:g})=>{const w=p.jsx("div",{className:"migrate-instance-summary",children:p.jsxs("p",{children:["This will migrate the instance ",p.jsx("strong",{children:t.name})," root storage to pool ",p.jsx("b",{children:i}),"."]})});return p.jsxs(p.Fragment,{children:[i&&w,!i&&p.jsx(Oa,{onSelect:e,disablePool:{name:vo(t),reason:"Instance root storage already in this pool"}}),p.jsxs("footer",{id:"migrate-instance-actions",className:"p-modal__footer",children:[p.jsx(N.Button,{className:"u-no-margin--bottom",type:"button","aria-label":"cancel migrate",appearance:"base",onClick:a,children:"Cancel"}),p.jsx(N.ActionButton,{appearance:"positive",className:"u-no-margin--bottom",onClick:()=>{g(i)},disabled:!i,children:"Migrate"})]})]})},Wl=({instance:t,onSuccess:e,type:i,target:a})=>{const g=Ie(),w=ni(),E=Ee(),r=Ue(),o=Bt(),u=()=>{let S="";if(i==="cluster member"&&(S=p.jsxs(p.Fragment,{children:["Instance ",p.jsx(ue,{instance:t})," successfully migrated to cluster member"," ",p.jsx(Fe,{type:"cluster-member",value:a,to:"/ui/cluster"})]})),i==="root storage pool"&&(S=p.jsxs(p.Fragment,{children:["Instance ",p.jsx(ue,{instance:t})," root storage successfully migrated to pool"," ",p.jsx(Fe,{type:"pool",value:a,to:`/ui/project/${t.project}/storage/pool/${a}`})]})),i==="project"){S=p.jsxs(p.Fragment,{children:["Instance"," ",p.jsx(ue,{instance:{...t,project:a}}),"successfully migrated to project"," ",p.jsx(Fe,{type:"project",value:a,to:`/ui/project/${a}`})]});const m=window.location.pathname,s=m.replace(`/project/${t.project}/instance/${t.name}`,`/project/${a}/instance/${t.name}`);m!==s&&o(s)}g.success(S)},_=S=>{let m="";i==="cluster member"&&(m=`Cluster member migration failed for instance ${t.name}`),i==="root storage pool"&&(m=`Root storage migration failed for instance ${t.name}`),i==="project"&&(m=`Project migration failed for instance ${t.name}`),w.setFinish(t),g.failure(m,S,p.jsx(ue,{instance:t}))},l=S=>{_(new Error(S))},f=()=>{r.invalidateQueries({queryKey:[de.instances,t.name]}),w.setFinish(t)};return{handleMigrate:()=>{w.setLoading(t,"Migrating");const S=i==="cluster member"?a:void 0,m=i==="root storage pool"?a:void 0,s=i==="project"?a:void 0;Fo(t.name,t.project,S,m,s).then(n=>{E.set(n.metadata.id,u,c=>{l(c)},f),g.info(p.jsxs(p.Fragment,{children:[So(i)," migration started for"," ",p.jsx(ue,{instance:t}),"."]})),r.invalidateQueries({queryKey:[de.instances,t.name,t.project]}),e()}).catch(n=>{_(n)})}}},$l=({onSelect:t,disableProject:e})=>{const{data:i=[]}=kt(),{canCreateInstances:a}=ze(),g=[{content:"Name",sortKey:"name"},{"aria-label":"Actions",className:"actions"}],w=i.map(E=>{const r=()=>a(E)?(e==null?void 0:e.name)===E.name?e==null?void 0:e.reason:null:"You do not have permission to create instances in this project",o=()=>{r()||t(E.name)};return{key:E.name,className:it("u-row",{"u-text--muted":!!r(),"u-row--disabled":!!r()}),columns:[{content:p.jsx("div",{className:"u-truncate migrate-instance-name",title:E.name,children:E.name}),role:"cell","aria-label":"Name",onClick:o},{content:p.jsx(N.Button,{onClick:o,dense:!0,title:r(),disabled:!!r(),children:"Select"}),role:"cell","aria-label":"Actions",className:"u-align--right",onClick:o}],sortData:{name:E.name.toLowerCase()}}});return p.jsx("div",{className:"migrate-instance-table u-selectable-table-rows",children:p.jsx(Xi,{dependencies:[i],tableId:"migrate-instance-table",belowIds:["status-bar","migrate-instance-actions"],children:p.jsx(N.MainTable,{id:"migrate-instance-table",headers:g,rows:w,sortable:!0,className:"u-table-layout--auto"})})})},ql=({instance:t,onSelect:e,targetProject:i,onCancel:a,migrate:g})=>{const w=p.jsx("div",{className:"migrate-instance-summary",children:p.jsxs("p",{children:["This will migrate the instance ",p.jsx("strong",{children:t.name})," to the project ",p.jsx("b",{children:i}),"."]})});return p.jsxs(p.Fragment,{children:[i&&w,!i&&p.jsx($l,{onSelect:e,disableProject:{name:t.project,reason:"Instance already in this project"}}),p.jsxs("footer",{id:"migrate-instance-actions",className:"p-modal__footer",children:[p.jsx(N.Button,{className:"u-no-margin--bottom",type:"button","aria-label":"cancel migrate",appearance:"base",onClick:a,children:"Cancel"}),p.jsx(N.ActionButton,{appearance:"positive",className:"u-no-margin--bottom",onClick:()=>{g(i)},disabled:!i,children:"Migrate"})]})]})},Vl=({close:t,instance:e})=>{const{data:i}=Mt(),a=$i(i),[g,w]=Z.useState(""),[E,r]=Z.useState(""),{handleMigrate:o}=Wl({onSuccess:t,instance:e,type:g,target:E}),u=C=>{C.key==="Escape"&&t()},_=()=>{if(E){r("");return}if(g){w("");return}},l=p.jsxs(p.Fragment,{children:["Choose ",g," for instance ",p.jsx("strong",{children:e.name})]}),f=g?p.jsx(Ba,{title:E?"Confirm migration":l,onClick:_,linkText:E?`Choose ${g}`:"Choose migration method"}):"Choose migration method";return p.jsxs(N.Modal,{close:t,className:"migrate-instance-modal",title:f,onKeyDown:u,children:[!g&&p.jsxs("div",{className:"choose-migration-type",children:[a&&p.jsx(Ii,{icon:"cluster-host",title:"Migrate instance to a different cluster member",onClick:()=>{w("cluster member")}}),p.jsx(Ii,{icon:"switcher-dashboard",title:"Migrate instance root storage to a different pool",onClick:()=>{w("root storage pool")}}),p.jsx(Ii,{icon:"folder",title:"Migrate instance to a different project",onClick:()=>{w("project")}})]}),g==="cluster member"&&p.jsx(Yl,{instance:e,onSelect:r,targetMember:E,onCancel:_,migrate:o}),g==="root storage pool"&&p.jsx(zl,{instance:e,onSelect:r,targetPool:E,onCancel:_,migrate:o}),g==="project"&&p.jsx(ql,{instance:e,onSelect:r,targetProject:E,onCancel:_,migrate:o})]})},Xl=({instance:t,classname:e})=>{const{openPortal:i,closePortal:a,isOpen:g,Portal:w}=N.usePortal(),{canEditInstance:E}=Oe(),r=ni(),o=r.getType(t)==="Migrating"||t.status==="Migrating",u=o||!!r.getType(t);return p.jsxs(p.Fragment,{children:[g&&p.jsx(w,{children:p.jsx(Vl,{close:a,instance:t})}),p.jsxs(N.ActionButton,{onClick:i,type:"button",className:it("u-no-margin--bottom has-icon",e),loading:o,disabled:u||!E(t),title:E()?"Migrate instance":"You do not have permission to migrate this instance",children:[p.jsx(N.Icon,{name:"machines"}),p.jsx("span",{children:"Migrate"})]})]})},Ql=({instance:t,close:e})=>{const i=Ee(),a=Ie(),g=Ue(),w=p.jsx(ue,{instance:t}),{data:E}=Rt(t.project),{canCreateImageAliases:r}=ze(),o=()=>{const f=p.jsx(Wi,{to:`/ui/project/${t.project}/images`,children:"created"});a.success(p.jsxs(p.Fragment,{children:["Image ",f," from instance ",w,"."]}))},u=()=>{g.invalidateQueries({predicate:f=>f.queryKey[0]===de.images})},_=(f,C)=>JSON.stringify({public:C,source:{name:f.name,type:"instance"}}),l=Ke({initialValues:{alias:r(E)?`from-instance-${t.name}`:"",isPublic:!1},validationSchema:Je().shape({alias:Qe()}),onSubmit:f=>{const C=f.alias;hr(_(t,f.isPublic),t).then(S=>{a.info(p.jsxs(p.Fragment,{children:["Creation of image from instance ",w," started."]})),e(),i.set(S.metadata.id,m=>{var s;if(C){const n=((s=m.metadata.metadata)==null?void 0:s.fingerprint)??"";lr(n,C,t.project).then(u).then(o).catch(c=>{a.failure(`Image creation from instance "${t.name}" succeeded. Failed to create an alias.`,c)})}else u(),o()},m=>{a.failure(`Image creation from instance "${t.name}" failed.`,new Error(m),w)})}).catch(S=>{a.failure(`Image creation from instance "${t.name}" failed.`,S,w)})}});return p.jsx(N.Modal,{close:e,className:"create-image-from-instance-modal",title:"Create image from instance",buttonRow:p.jsxs(p.Fragment,{children:[p.jsx(N.Button,{appearance:"base",className:"u-no-margin--bottom",type:"button",onClick:e,children:"Cancel"}),p.jsx(N.ActionButton,{appearance:"positive",className:"u-no-margin--bottom",loading:l.isSubmitting,disabled:!l.isValid,onClick:()=>void l.submitForm(),children:"Create image"})]}),children:p.jsxs(N.Form,{onSubmit:l.handleSubmit,children:[p.jsx(N.Input,{type:"text",label:"Instance",value:t.name,disabled:!0}),p.jsx(N.Input,{...l.getFieldProps("alias"),type:"text",label:"Alias",error:l.touched.alias?l.errors.alias:null,disabled:!r(E),title:r(E)?"":"You do not have permission to create image aliases in this project"}),p.jsx(N.Input,{...l.getFieldProps("isPublic"),type:"checkbox",label:"Make the image publicly available",error:l.touched.isPublic?l.errors.isPublic:null}),p.jsx(N.Input,{type:"submit",hidden:!0,value:"Hidden input"})]})})},Zl=({instance:t,classname:e,onClose:i})=>{const{openPortal:a,closePortal:g,isOpen:w,Portal:E}=N.usePortal(),{data:r}=Rt(t.project),{canCreateImages:o}=ze(),u=ni(),_=["Error","Frozen","Running"],l=()=>{g(),i==null||i()},f=()=>o(r)?_.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 p.jsxs(p.Fragment,{children:[w&&p.jsx(E,{children:p.jsx(Ql,{close:l,instance:t})}),p.jsxs(N.ActionButton,{appearance:"default",className:it("u-no-margin--bottom has-icon",e),onClick:a,"aria-label":"Create image",title:f()||"Create image",disabled:!!f(),children:[p.jsx(N.Icon,{name:"plus"}),p.jsx("span",{children:"Create Image"})]})]})},Jl=({instance:t,close:e})=>{var n,c;const i=Ie(),{data:a}=Mt(),g=$i(a),w=Z.useState(null),E=Bt(),r=Ee(),{data:o=[],isLoading:u}=kt(),{canCreateInstances:_}=ze(),{data:l=[],isLoading:f}=nr(),{data:C=[]}=cr(t.project),S=(h,d,b)=>{const y=`/ui/project/${d}/instance/${h}`,A=p.jsxs(p.Fragment,{children:["Created instance"," ",p.jsx(Fe,{type:b,value:h,to:y}),"."]}),v=[{label:"Configure",onClick:async()=>E(`${y}/configuration`)}];i.success(A,v)},s=Ke({initialValues:{instanceName:(h=>{const d=mr(h.name,"-duplicate");return bo(d,C)})(t),targetProject:t.project,allowInconsistent:!1,instanceOnly:!1,stateful:!1,targetClusterMember:g?t.location:"",targetStoragePool:((n=t.devices.root)==null?void 0:n.pool)??((c=l[0])==null?void 0:c.name)},enableReinitialize:!0,validationSchema:Je().shape({instanceName:Vi(t.project,w).required()}),onSubmit:h=>{const d=p.jsx(ue,{instance:t});ur(JSON.stringify({description:t.description,name:h.instanceName,architecture:t.architecture,source:{allow_inconsistent:h.allowInconsistent,instance_only:h.instanceOnly,source:t.name,type:"copy",project:t.project},stateful:h.stateful,devices:{...t.devices,root:{path:"/",type:"disk",pool:h.targetStoragePool}}}),h.targetProject,h.targetClusterMember).then(b=>{i.info(p.jsxs(p.Fragment,{children:["Duplication of instance ",d," started."]})),r.set(b.metadata.id,()=>{S(h.instanceName,h.targetProject,t.type)},y=>i.failure("Instance duplication failed.",new Error(y),d))}).catch(b=>{i.failure("Instance duplication failed.",b,d)}).finally(()=>{e()})}});return p.jsx(N.Modal,{close:e,className:"duplicate-instances-modal",title:"Duplicate Instance",buttonRow:p.jsxs(p.Fragment,{children:[p.jsx(N.Button,{appearance:"base",className:"u-no-margin--bottom",type:"button",onClick:e,children:"Cancel"}),p.jsx(N.ActionButton,{appearance:"positive",className:"u-no-margin--bottom",loading:s.isSubmitting,disabled:!s.isValid||f||u,onClick:()=>void s.submitForm(),children:"Duplicate"})]}),children:p.jsxs(N.Form,{onSubmit:s.handleSubmit,children:[p.jsx(N.Input,{...s.getFieldProps("instanceName"),type:"text",label:"New instance name",error:s.touched.instanceName?s.errors.instanceName:null}),p.jsx(pr,{...s.getFieldProps("targetClusterMember"),id:"targetClusterMember",label:"Target cluster member"}),p.jsx(Na,{...s.getFieldProps("targetStoragePool"),setValue:h=>void s.setFieldValue("targetStoragePool",h),selectProps:{id:"storagePool",label:"Storage pool"}}),p.jsx(N.Select,{...s.getFieldProps("targetProject"),id:"project",label:"Target project",options:o.filter(_).map(h=>({label:h.name,value:h.name}))}),p.jsx(N.Input,{...s.getFieldProps("allowInconsistent"),type:"checkbox",label:"Ignore copy errors for volatile files",error:s.touched.allowInconsistent?s.errors.allowInconsistent:null}),p.jsx(N.Input,{...s.getFieldProps("instanceOnly"),type:"checkbox",label:"Copy without instance snapshots",error:s.touched.instanceOnly?s.errors.instanceOnly:null}),p.jsx(N.Input,{...s.getFieldProps("stateful"),type:"checkbox",label:"Copy stateful",error:s.touched.stateful?s.errors.stateful:null}),p.jsx(N.Input,{type:"submit",hidden:!0,value:"Hidden input"})]})})},eu=({instance:t,isLoading:e,classname:i,onClose:a})=>{const{openPortal:g,closePortal:w,isOpen:E,Portal:r}=N.usePortal(),{data:o}=Rt(t.project),{data:u}=kt(),{canCreateInstances:_}=ze(),l=()=>{w(),a==null||a()},f=()=>{const C=u==null?void 0:u.filter(_);return!_(o)||!(C!=null&&C.length)?"You do not have permission to duplicate instances":e?"Loading...":""};return p.jsxs(p.Fragment,{children:[E&&p.jsx(r,{children:p.jsx(Jl,{close:l,instance:t})}),p.jsxs(N.Button,{appearance:"default","aria-label":"Duplicate instance",className:it("u-no-margin--bottom has-icon",i),disabled:!!f(),onClick:g,title:f()||"Duplicate instance",children:[p.jsx(N.Icon,{name:"canvas"}),p.jsx("span",{children:"Duplicate"})]})]})},tu=({instance:t,classname:e,onClose:i})=>{const a=Ee(),g=Ie(),{canManageInstanceBackups:w}=Oe(),E=p.jsx(ue,{instance:t}),r=_=>{const l=`/1.0/instances/${t.name}/backups/${_}/export?project=${t.project}`,f=document.createElement("a");f.href=l,f.download=_,f.click(),window.URL.revokeObjectURL(l),g.success(p.jsxs(p.Fragment,{children:["Instance ",E," download started:",p.jsx("br",{}),_]}))},o=()=>{const _=new Date;return _.setHours(_.getHours()+24),_},u=()=>{const l=o().toISOString(),f=new Date().toISOString().replaceAll(":","-").split(".")[0],C=`${t.name}-${f}.tar.gz`;g.info(p.jsxs(p.Fragment,{children:["Backing up instance ",E,".",p.jsx("br",{}),"Download will start, when the export is ready."]})),Ho(t.name,t.project,l,C).then(S=>{a.set(S.metadata.id,()=>{r(C)},m=>g.failure(`Could not download instance ${t.name}`,new Error(m),E))}).catch(S=>g.failure(`Could not download instance ${t.name}`,S,E)).finally(()=>{i==null||i()})};return p.jsxs(N.Button,{appearance:"default",className:it("u-no-margin--bottom has-icon",e),onClick:u,title:w(t)?"Export instance":"You do not have permission to export this instance.",disabled:!w(t),children:[p.jsx(N.Icon,{name:"export"}),p.jsx("span",{children:"Export"})]})},iu=({instance:t,project:e,isLoading:i})=>{const[a,g]=Z.useState(ws(1200));Ne("resize",()=>{g(ws(1200))});const w=a?"p-contextual-menu__link":"p-segmented-control__button",E=[p.jsx(Xl,{instance:t,project:e,classname:w},"migrate"),p.jsx(Zl,{instance:t,classname:w},"publish"),p.jsx(eu,{instance:t,isLoading:i,classname:w},"duplicate"),p.jsx(tu,{instance:t,classname:w},"export"),p.jsx(Kl,{instance:t,classname:w},"delete")];return p.jsx(p.Fragment,{children:a?p.jsx(N.ContextualMenu,{closeOnOutsideClick:!1,toggleLabel:"Actions",position:"left",hasToggleIcon:!0,title:"actions",children:r=>p.jsx("span",{children:[...E].map(o=>Z.cloneElement(o,{onClose:r}))})}):p.jsx("div",{className:"p-segmented-control",children:p.jsx("div",{className:"p-segmented-control__list",children:E})})})},su=({name:t,instance:e,project:i,isLoading:a})=>{const g=Ee(),w=Bt(),E=Ie(),{canEditInstance:r}=Oe(),o=Z.useState(null),u=Je().shape({name:Vi(i,o,t).required("Instance name is required")}),_=Ke({initialValues:{name:t,isRenaming:!1},validationSchema:u,onSubmit:f=>{if(t===f.name){_.setFieldValue("isRenaming",!1),_.setSubmitting(!1);return}Ko(t,f.name,i).then(C=>{const S=p.jsx(ue,{instance:{name:f.name,project:i,type:(e==null?void 0:e.type)||"instance"}});g.set(C.metadata.id,()=>{w(`/ui/project/${i}/instance/${f.name}`),E.success(p.jsxs(p.Fragment,{children:["Instance"," ",p.jsx("strong",{children:ha(C.metadata)})," renamed to ",S,"."]})),_.setFieldValue("isRenaming",!1)},m=>E.failure("Renaming instance failed.",new Error(m),gr({operation:C,project:i,instanceType:(e==null?void 0:e.type)||"instance"})),()=>{_.setSubmitting(!1)})}).catch(C=>{_.setSubmitting(!1),E.failure("Renaming instance failed.",C,e&&p.jsx(ue,{instance:e}))})}}),l=()=>{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&&p.jsx(ka,{name:t,titleClassName:"instance-detail-title",parentItems:[p.jsx(Wi,{to:`/ui/project/${i}/instances`,children:"Instances"},1)],renameDisabledReason:l(),centerControls:e?p.jsxs("div",{children:[p.jsx("i",{className:"status u-text--muted",children:e.status}),p.jsx(Do,{instance:e},"state")]}):null,controls:e?p.jsx(iu,{instance:e,project:i,isLoading:a}):null,isLoaded:!!e,formik:_})},ru=["Overview","Configuration","Snapshots","Terminal","Console","Logs"],Zu=()=>{var _;const{data:t}=Mt(),{name:e,project:i,activeTab:a}=nt();if(!e)return p.jsx(p.Fragment,{children:"Missing name"});if(!i)return p.jsx(p.Fragment,{children:"Missing project"});const{data:g,error:w,refetch:E,isLoading:r}=Lo(e,i),o=[...ru],u=((_=t==null?void 0:t.config)==null?void 0:_["user.grafana_base_url"])??"";return u&&o.push({label:p.jsxs("div",{children:[p.jsx(N.Icon,{name:"external-link"})," Metrics"]}),href:`${u}&var-job=lxd&var-project=${i}&var-name=${g==null?void 0:g.name}&var-top=5`,target:"_blank",rel:"noopener noreferrer"}),p.jsxs(Co,{header:p.jsx(su,{name:e,instance:g,project:i,isLoading:r}),contentClassName:"detail-page",children:[r&&p.jsx(tt,{text:"Loading instance details..."}),!r&&!g&&!w&&p.jsx(p.Fragment,{children:"Loading instance failed"}),w&&p.jsx(N.Strip,{children:p.jsx(N.Notification,{severity:"negative",title:"Error",children:w.message})}),!r&&g&&p.jsxs(N.Row,{children:[p.jsx(Ua,{tabs:o,activeTab:a,tabUrl:`/ui/project/${i}/instance/${e}`}),!a&&p.jsx("div",{role:"tabpanel","aria-labelledby":"overview",children:p.jsx(Ha,{instance:g})}),a==="configuration"&&p.jsx("div",{role:"tabpanel","aria-labelledby":"configuration",children:p.jsx(Hl,{instance:g})}),a==="snapshots"&&p.jsx("div",{role:"tabpanel","aria-labelledby":"snapshots",children:p.jsx(mc,{instance:g})}),a==="terminal"&&p.jsx("div",{role:"tabpanel","aria-labelledby":"terminal",children:p.jsx(Va,{instance:g,refreshInstance:E})}),a==="console"&&p.jsx("div",{role:"tabpanel","aria-labelledby":"console",children:p.jsx(Ol,{instance:g})}),a==="logs"&&p.jsx("div",{role:"tabpanel","aria-labelledby":"logs",children:p.jsx(jl,{instance:g})})]})]})};export{Zu as default};
Close