"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[460],{4460:function(t,e,s){function i(t){return 0|t}s.d(e,{Z:function(){return Sa}});let n="warn",r=()=>{},a=()=>{},o=()=>{},h=()=>{};function l(t,e=!1){try{return decodeURIComponent(escape(t))}catch(Ur){if(Ur instanceof URIError&&e)return t;throw Ur}}function c(t){return unescape(encodeURIComponent(t))}!function(t){if("undefined"===typeof t?t=n:n=t,r=a=o=h=()=>{},"undefined"!==typeof window.console)switch(t){case"debug":r=console.debug.bind(window.console);case"info":a=console.info.bind(window.console);case"warn":o=console.warn.bind(window.console);case"error":h=console.error.bind(window.console);case"none":break;default:throw new window.Error("invalid logging type '"+t+"'")}}();let d="ontouchstart"in document.documentElement||void 0!==document.ontouchstart||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0;window.addEventListener("touchstart",(function t(){d=!0,window.removeEventListener("touchstart",t,!1)}),!1);let _=10*(window.devicePixelRatio||1),u=!1;try{const t=document.createElement("canvas");t.style.cursor='url("data:image/x-icon;base64,AAACAAEACAgAAAIAAgA4AQAAFgAAACgAAAAIAAAAEAAAAAEAIAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////AAAAAAAAAAAAAAAAAAAAAA==") 2 2, default',0===t.style.cursor.indexOf("url")?(a("Data URI scheme cursor supported"),u=!0):o("Data URI scheme cursor not supported")}catch(Qa){h("Data URI scheme cursor test exception: "+Qa)}const f=u;let p=!0;try{const t=document.createElement("div");t.style.visibility="hidden",t.style.overflow="scroll",document.body.appendChild(t);const e=document.createElement("div");t.appendChild(e);const s=t.offsetWidth-e.offsetWidth;t.parentNode.removeChild(t),p=0!=s}catch(Qa){h("Scrollbar test exception: "+Qa)}function g(){return navigator&&!!/mac/i.exec(navigator.platform)}function m(){return navigator&&!!/win/i.exec(navigator.platform)}function w(){return navigator&&(!!/ipad/i.exec(navigator.platform)||!!/iphone/i.exec(navigator.platform)||!!/ipod/i.exec(navigator.platform))}function b(t,e,s){const i=s.getBoundingClientRect();let n={x:0,y:0};return t=i.right?n.x=i.width-1:n.x=t-i.left,e=i.bottom?n.y=i.height-1:n.y=e-i.top,n}function v(t){t.stopPropagation(),t.preventDefault()}let k=!1,y=null;function C(t){if(k)return;const e=new t.constructor(t.type,t);k=!0,document.captureElement?document.captureElement.dispatchEvent(e):y.dispatchEvent(e),k=!1,t.stopPropagation(),e.defaultPrevented&&t.preventDefault(),"mouseup"===t.type&&Q()}function x(){document.getElementById("noVNC_mouse_capture_elem").style.cursor=window.getComputedStyle(document.captureElement).cursor}document.captureElement=null;const S=new MutationObserver(x);function Q(){if(document.releaseCapture)document.releaseCapture(),document.captureElement=null;else{if(!document.captureElement)return;y=document.captureElement,document.captureElement=null,S.disconnect();document.getElementById("noVNC_mouse_capture_elem").style.display="none",window.removeEventListener("mousemove",C),window.removeEventListener("mouseup",C)}}var M={toBase64Table:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".split(""),base64Pad:"=",encode(t){let e="";const s=t.length,i=s%3;for(let r=0;r>2],e+=this.toBase64Table[((3&t[r])<<4)+(t[r+1]>>4)],e+=this.toBase64Table[((15&t[r+1])<<2)+(t[r+2]>>6)],e+=this.toBase64Table[63&t[r+2]];const n=s-i;return 2===i?(e+=this.toBase64Table[t[n]>>2],e+=this.toBase64Table[((3&t[n])<<4)+(t[n+1]>>4)],e+=this.toBase64Table[(15&t[n+1])<<2],e+=this.toBase64Table[64]):1===i&&(e+=this.toBase64Table[t[n]>>2],e+=this.toBase64Table[(3&t[n])<<4],e+=this.toBase64Table[64],e+=this.toBase64Table[64]),e},toBinaryTable:[-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,62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,0,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,-1,-1,-1,-1,-1],decode(t,e=0){let s=t.indexOf("=")-e;s<0&&(s=t.length-e);const i=3*(s>>2)+Math.floor(s%4/1.5),n=new Array(i);let r=0,a=0;for(let o=0,l=e;l=8&&(r-=8,s||(n[o++]=a>>r&255),a&=(1<> Display.constructor"),this._target=t,!this._target)throw new Error("Target must be set");if("string"===typeof this._target)throw new Error("target must be a DOM element");if(!this._target.getContext)throw new Error("no getContext method");this._targetCtx=this._target.getContext("2d"),this._viewportLoc={x:0,y:0,w:this._target.width,h:this._target.height},this._backbuffer=document.createElement("canvas"),this._drawCtx=this._backbuffer.getContext("2d"),this._damageBounds={left:0,top:0,right:this._backbuffer.width,bottom:this._backbuffer.height},r("User Agent: "+navigator.userAgent),r("<< Display.constructor"),this._scale=1,this._clipViewport=!1,this.onflush=()=>{}}get scale(){return this._scale}set scale(t){this._rescale(t)}get clipViewport(){return this._clipViewport}set clipViewport(t){this._clipViewport=t;const e=this._viewportLoc;this.viewportChangeSize(e.w,e.h),this.viewportChangePos(0,0)}get width(){return this._fbWidth}get height(){return this._fbHeight}viewportChangePos(t,e){const s=this._viewportLoc;t=Math.floor(t),e=Math.floor(e),this._clipViewport||(t=-s.w,e=-s.h);const i=s.x+s.w-1,n=s.y+s.h-1;t<0&&s.x+t<0&&(t=-s.x),i+t>=this._fbWidth&&(t-=i+t-this._fbWidth+1),s.y+e<0&&(e=-s.y),n+e>=this._fbHeight&&(e-=n+e-this._fbHeight+1),0===t&&0===e||(r("viewportChange deltaX: "+t+", deltaY: "+e),s.x+=t,s.y+=e,this._damage(s.x,s.y,s.w,s.h),this.flip())}viewportChangeSize(t,e){this._clipViewport&&"undefined"!==typeof t&&"undefined"!==typeof e||(r("Setting viewport to full display region"),t=this._fbWidth,e=this._fbHeight),t=Math.floor(t),e=Math.floor(e),t>this._fbWidth&&(t=this._fbWidth),e>this._fbHeight&&(e=this._fbHeight);const s=this._viewportLoc;if(s.w!==t||s.h!==e){s.w=t,s.h=e;const i=this._target;i.width=t,i.height=e,this.viewportChangePos(0,0),this._damage(s.x,s.y,s.w,s.h),this.flip(),this._rescale(this._scale)}}absX(t){return 0===this._scale?0:i(t/this._scale+this._viewportLoc.x)}absY(t){return 0===this._scale?0:i(t/this._scale+this._viewportLoc.y)}resize(t,e){this._prevDrawStyle="",this._fbWidth=t,this._fbHeight=e;const s=this._backbuffer;if(s.width!==t||s.height!==e){let i=null;s.width>0&&s.height>0&&(i=this._drawCtx.getImageData(0,0,s.width,s.height)),s.width!==t&&(s.width=t),s.height!==e&&(s.height=e),i&&this._drawCtx.putImageData(i,0,0)}const i=this._viewportLoc;this.viewportChangeSize(i.w,i.h),this.viewportChangePos(0,0)}_damage(t,e,s,i){tthis._damageBounds.right&&(this._damageBounds.right=t+s),e+i>this._damageBounds.bottom&&(this._damageBounds.bottom=e+i)}flip(t){if(0===this._renderQ.length||t){let t=this._damageBounds.left,e=this._damageBounds.top,s=this._damageBounds.right-t,i=this._damageBounds.bottom-e,n=t-this._viewportLoc.x,r=e-this._viewportLoc.y;n<0&&(s+=n,t-=n,n=0),r<0&&(i+=r,e-=r,r=0),n+s>this._viewportLoc.w&&(s=this._viewportLoc.w-n),r+i>this._viewportLoc.h&&(i=this._viewportLoc.h-r),s>0&&i>0&&this._targetCtx.drawImage(this._backbuffer,t,e,s,i,n,r,s,i),this._damageBounds.left=this._damageBounds.top=65535,this._damageBounds.right=this._damageBounds.bottom=0}else this._renderQPush({type:"flip"})}pending(){return this._renderQ.length>0}flush(){0===this._renderQ.length?this.onflush():this._flushing=!0}fillRect(t,e,s,i,n,r){0===this._renderQ.length||r?(this._setFillColor(n),this._drawCtx.fillRect(t,e,s,i),this._damage(t,e,s,i)):this._renderQPush({type:"fill",x:t,y:e,width:s,height:i,color:n})}copyImage(t,e,s,i,n,r,a){0===this._renderQ.length||a?(this._drawCtx.mozImageSmoothingEnabled=!1,this._drawCtx.webkitImageSmoothingEnabled=!1,this._drawCtx.msImageSmoothingEnabled=!1,this._drawCtx.imageSmoothingEnabled=!1,this._drawCtx.drawImage(this._backbuffer,t,e,n,r,s,i,n,r),this._damage(s,i,n,r)):this._renderQPush({type:"copy",oldX:t,oldY:e,x:s,y:i,width:n,height:r})}imageRect(t,e,s,i,n,r){if(0===s||0===i)return;const a=new Image;a.src="data: "+n+";base64,"+M.encode(r),this._renderQPush({type:"img",img:a,x:t,y:e,width:s,height:i})}blitImage(t,e,s,i,n,r,a){if(0===this._renderQ.length||a){let a=new Uint8ClampedArray(n.buffer,n.byteOffset+r,s*i*4),o=new ImageData(a,s,i);this._drawCtx.putImageData(o,t,e),this._damage(t,e,s,i)}else{const r=new Uint8Array(s*i*4);r.set(new Uint8Array(n.buffer,0,r.length)),this._renderQPush({type:"blit",data:r,x:t,y:e,width:s,height:i})}}drawImage(t,e,s){this._drawCtx.drawImage(t,e,s),this._damage(e,s,t.width,t.height)}autoscale(t,e){let s;if(0===t||0===e)s=0;else{const i=this._viewportLoc,n=t/e;s=i.w/i.h>=n?t/i.w:e/i.h}this._rescale(s)}_rescale(t){this._scale=t;const e=this._viewportLoc,s=t*e.w+"px",i=t*e.h+"px";this._target.style.width===s&&this._target.style.height===i||(this._target.style.width=s,this._target.style.height=i)}_setFillColor(t){const e="rgb("+t[0]+","+t[1]+","+t[2]+")";e!==this._prevDrawStyle&&(this._drawCtx.fillStyle=e,this._prevDrawStyle=e)}_renderQPush(t){this._renderQ.push(t),1===this._renderQ.length&&this._scanRenderQ()}_resumeRenderQ(){this.removeEventListener("load",this._noVNCDisplay._resumeRenderQ),this._noVNCDisplay._scanRenderQ()}_scanRenderQ(){let t=!0;for(;t&&this._renderQ.length>0;){const e=this._renderQ[0];switch(e.type){case"flip":this.flip(!0);break;case"copy":this.copyImage(e.oldX,e.oldY,e.x,e.y,e.width,e.height,!0);break;case"fill":this.fillRect(e.x,e.y,e.width,e.height,e.color,!0);break;case"blit":this.blitImage(e.x,e.y,e.width,e.height,e.data,0,!0);break;case"img":if(e.img.complete){if(e.img.width!==e.width||e.img.height!==e.height)return void h("Decoded image has incorrect dimensions. Got "+e.img.width+"x"+e.img.height+". Expected "+e.width+"x"+e.height+".");this.drawImage(e.img,e.x,e.y)}else e.img._noVNCDisplay=this,e.img.addEventListener("load",this._resumeRenderQ),t=!1}t&&this._renderQ.shift()}0===this._renderQ.length&&this._flushing&&(this._flushing=!1,this.onflush())}}function A(t,e,s,i,n){if(e.subarray&&t.subarray)t.set(e.subarray(s,s+i),n);else for(var r=0;r>>16&65535|0,a=0;0!==s;){s-=a=s>2e3?2e3:s;do{r=r+(n=n+e[i++]|0)|0}while(--a);n%=65521,r%=65521}return n|r<<16|0}function D(){for(var t,e=[],s=0;s<256;s++){t=s;for(var i=0;i<8;i++)t=1&t?3988292384^t>>>1:t>>>1;e[s]=t}return e}D();function z(t,e){var s,i,n,r,a,o,h,l,c,d,_,u,f,p,g,m,w,b,v,k,y,C,x,S,Q;s=t.state,i=t.next_in,S=t.input,n=i+(t.avail_in-5),r=t.next_out,Q=t.output,a=r-(e-t.avail_out),o=r+(t.avail_out-257),h=s.dmax,l=s.wsize,c=s.whave,d=s.wnext,_=s.window,u=s.hold,f=s.bits,p=s.lencode,g=s.distcode,m=(1<>>=v=b>>>24,f-=v,0===(v=b>>>16&255))Q[r++]=65535&b;else{if(!(16&v)){if(0===(64&v)){b=p[(65535&b)+(u&(1<>>=v,f-=v),f<15&&(u+=S[i++]<>>=v=b>>>24,f-=v,!(16&(v=b>>>16&255))){if(0===(64&v)){b=g[(65535&b)+(u&(1<h){t.msg="invalid distance too far back",s.mode=30;break t}if(u>>>=v,f-=v,y>(v=r-a)){if((v=y-v)>c&&s.sane){t.msg="invalid distance too far back",s.mode=30;break t}if(C=0,x=_,0===d){if(C+=l-v,v2;)Q[r++]=x[C++],Q[r++]=x[C++],Q[r++]=x[C++],k-=3;k&&(Q[r++]=x[C++],k>1&&(Q[r++]=x[C++]))}else{C=r-y;do{Q[r++]=Q[C++],Q[r++]=Q[C++],Q[r++]=Q[C++],k-=3}while(k>2);k&&(Q[r++]=Q[C++],k>1&&(Q[r++]=Q[C++]))}break}}break}}while(i>3,u&=(1<<(f-=k<<3))-1,t.next_in=i,t.next_out=r,t.avail_in=i=1&&0===T[k];k--);if(y>k&&(y=k),0===k)return n[r++]=20971520,n[r++]=20971520,o.bits=1,0;for(v=1;v0&&(0===t||1!==k))return-1;for(L[1]=0,w=1;w852||2===t&&Q>592)return 1;for(;;){f=w-x,a[b]u?(p=B[D+a[b]],g=E[A+a[b]]):(p=96,g=0),h=1<>x)+(l-=h)]=f<<24|p<<16|g|0}while(0!==l);for(h=1<>=1;if(0!==h?(M&=h-1,M+=h):M=0,b++,0===--T[w]){if(w===k)break;w=e[s+a[b]]}if(w>y&&(M&d)!==c){for(0===x&&(x=y),_+=v,S=1<<(C=w-x);C+x852||2===t&&Q>592)return 1;n[c=M&d]=y<<24|C<<16|_-r|0}}return 0!==M&&(n[_+M]=w-x<<24|64<<16|0),o.bits=y,0}const H=-2;var K=12,X=30;function O(t){return(t>>>24&255)+(t>>>8&65280)+((65280&t)<<8)+((255&t)<<24)}function G(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new F(320),this.work=new F(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function W(t){var e;return t&&t.state?((e=t.state).wsize=0,e.whave=0,e.wnext=0,function(t){var e;return t&&t.state?(e=t.state,t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=1&e.wrap),e.mode=1,e.last=0,e.havedict=0,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new L(852),e.distcode=e.distdyn=new L(592),e.sane=1,e.back=-1,0):H}(t)):H}function Y(t,e){var s,i;return t?(i=new G,t.state=i,i.window=null,s=function(t,e){var s,i;return t&&t.state?(i=t.state,e<0?(s=0,e=-e):(s=1+(e>>4),e<48&&(e&=15)),e&&(e<8||e>15)?H:(null!==i.window&&i.wbits!==e&&(i.window=null),i.wrap=s,i.wbits=e,W(t))):H}(t,e),0!==s&&(t.state=null),s):H}var q,j,Z=!0;function J(t){if(Z){var e;for(q=new L(512),j=new L(32),e=0;e<144;)t.lens[e++]=8;for(;e<256;)t.lens[e++]=9;for(;e<280;)t.lens[e++]=7;for(;e<288;)t.lens[e++]=8;for(V(1,t.lens,0,288,q,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;V(2,t.lens,0,32,j,0,t.work,{bits:5}),Z=!1}t.lencode=q,t.lenbits=9,t.distcode=j,t.distbits=5}function $(t,e,s,i){var n,r=t.state;return null===r.window&&(r.wsize=1<=r.wsize?(A(r.window,e,s-r.wsize,r.wsize,0),r.wnext=0,r.whave=r.wsize):((n=r.wsize-r.wnext)>i&&(n=i),A(r.window,e,s-i,n,r.wnext),(i-=n)?(A(r.window,e,s-i,i,0),r.wnext=i,r.whave=r.wsize):(r.wnext+=n,r.wnext===r.wsize&&(r.wnext=0),r.whavethis.chunkSize&&(this.chunkSize=t,this.strm.output=new Uint8Array(this.chunkSize)),this.strm.next_out=0,this.strm.avail_out=t,function(t,e){var s,i,n,r,a,o,h,l,c,d,_,u,f,p,g,m,w,b,v,k,y,C,x,S,Q=0,M=new T(4),E=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!t||!t.state||!t.output||!t.input&&0!==t.avail_in)return H;(s=t.state).mode===K&&(s.mode=13),a=t.next_out,n=t.output,h=t.avail_out,r=t.next_in,i=t.input,o=t.avail_in,l=s.hold,c=s.bits,d=o,_=h,C=0;t:for(;;)switch(s.mode){case 1:if(0===s.wrap){s.mode=13;break}for(;c<16;){if(0===o)break t;o--,l+=i[r++]<>>8&255,s.check=D(s.check),l=0,c=0,s.mode=2;break}if(s.flags=0,s.head&&(s.head.done=!1),!(1&s.wrap)||(((255&l)<<8)+(l>>8))%31){t.msg="incorrect header check",s.mode=X;break}if(8!==(15&l)){t.msg="unknown compression method",s.mode=X;break}if(c-=4,y=8+(15&(l>>>=4)),0===s.wbits)s.wbits=y;else if(y>s.wbits){t.msg="invalid window size",s.mode=X;break}s.dmax=1<>8&1),512&s.flags&&(M[0]=255&l,M[1]=l>>>8&255,s.check=D(s.check)),l=0,c=0,s.mode=3;case 3:for(;c<32;){if(0===o)break t;o--,l+=i[r++]<>>8&255,M[2]=l>>>16&255,M[3]=l>>>24&255,s.check=D(s.check)),l=0,c=0,s.mode=4;case 4:for(;c<16;){if(0===o)break t;o--,l+=i[r++]<>8),512&s.flags&&(M[0]=255&l,M[1]=l>>>8&255,s.check=D(s.check)),l=0,c=0,s.mode=5;case 5:if(1024&s.flags){for(;c<16;){if(0===o)break t;o--,l+=i[r++]<>>8&255,s.check=D(s.check)),l=0,c=0}else s.head&&(s.head.extra=null);s.mode=6;case 6:if(1024&s.flags&&((u=s.length)>o&&(u=o),u&&(s.head&&(y=s.head.extra_len-s.length,s.head.extra||(s.head.extra=new Array(s.head.extra_len)),A(s.head.extra,i,r,u,y)),512&s.flags&&(s.check=D(s.check)),o-=u,r+=u,s.length-=u),s.length))break t;s.length=0,s.mode=7;case 7:if(2048&s.flags){if(0===o)break t;u=0;do{y=i[r+u++],s.head&&y&&s.length<65536&&(s.head.name+=String.fromCharCode(y))}while(y&&u>9&1,s.head.done=!0),t.adler=s.check=0,s.mode=K;break;case 10:for(;c<32;){if(0===o)break t;o--,l+=i[r++]<>>=7&c,c-=7&c,s.mode=27;break}for(;c<3;){if(0===o)break t;o--,l+=i[r++]<>>=1)){case 0:s.mode=14;break;case 1:if(J(s),s.mode=20,6===e){l>>>=2,c-=2;break t}break;case 2:s.mode=17;break;case 3:t.msg="invalid block type",s.mode=X}l>>>=2,c-=2;break;case 14:for(l>>>=7&c,c-=7&c;c<32;){if(0===o)break t;o--,l+=i[r++]<>>16^65535)){t.msg="invalid stored block lengths",s.mode=X;break}if(s.length=65535&l,l=0,c=0,s.mode=15,6===e)break t;case 15:s.mode=16;case 16:if(u=s.length){if(u>o&&(u=o),u>h&&(u=h),0===u)break t;A(n,i,r,u,a),o-=u,r+=u,h-=u,a+=u,s.length-=u;break}s.mode=K;break;case 17:for(;c<14;){if(0===o)break t;o--,l+=i[r++]<>>=5,c-=5,s.ndist=1+(31&l),l>>>=5,c-=5,s.ncode=4+(15&l),l>>>=4,c-=4,s.nlen>286||s.ndist>30){t.msg="too many length or distance symbols",s.mode=X;break}s.have=0,s.mode=18;case 18:for(;s.have>>=3,c-=3}for(;s.have<19;)s.lens[E[s.have++]]=0;if(s.lencode=s.lendyn,s.lenbits=7,x={bits:s.lenbits},C=V(0,s.lens,0,19,s.lencode,0,s.work,x),s.lenbits=x.bits,C){t.msg="invalid code lengths set",s.mode=X;break}s.have=0,s.mode=19;case 19:for(;s.have>>16&255,w=65535&Q,!((g=Q>>>24)<=c);){if(0===o)break t;o--,l+=i[r++]<>>=g,c-=g,s.lens[s.have++]=w;else{if(16===w){for(S=g+2;c>>=g,c-=g,0===s.have){t.msg="invalid bit length repeat",s.mode=X;break}y=s.lens[s.have-1],u=3+(3&l),l>>>=2,c-=2}else if(17===w){for(S=g+3;c>>=g)),l>>>=3,c-=3}else{for(S=g+7;c>>=g)),l>>>=7,c-=7}if(s.have+u>s.nlen+s.ndist){t.msg="invalid bit length repeat",s.mode=X;break}for(;u--;)s.lens[s.have++]=y}}if(s.mode===X)break;if(0===s.lens[256]){t.msg="invalid code -- missing end-of-block",s.mode=X;break}if(s.lenbits=9,x={bits:s.lenbits},C=V(1,s.lens,0,s.nlen,s.lencode,0,s.work,x),s.lenbits=x.bits,C){t.msg="invalid literal/lengths set",s.mode=X;break}if(s.distbits=6,s.distcode=s.distdyn,x={bits:s.distbits},C=V(2,s.lens,s.nlen,s.ndist,s.distcode,0,s.work,x),s.distbits=x.bits,C){t.msg="invalid distances set",s.mode=X;break}if(s.mode=20,6===e)break t;case 20:s.mode=21;case 21:if(o>=6&&h>=258){t.next_out=a,t.avail_out=h,t.next_in=r,t.avail_in=o,s.hold=l,s.bits=c,z(t,_),a=t.next_out,n=t.output,h=t.avail_out,r=t.next_in,i=t.input,o=t.avail_in,l=s.hold,c=s.bits,s.mode===K&&(s.back=-1);break}for(s.back=0;m=(Q=s.lencode[l&(1<>>16&255,w=65535&Q,!((g=Q>>>24)<=c);){if(0===o)break t;o--,l+=i[r++]<>b)])>>>16&255,w=65535&Q,!(b+(g=Q>>>24)<=c);){if(0===o)break t;o--,l+=i[r++]<>>=b,c-=b,s.back+=b}if(l>>>=g,c-=g,s.back+=g,s.length=w,0===m){s.mode=26;break}if(32&m){s.back=-1,s.mode=K;break}if(64&m){t.msg="invalid literal/length code",s.mode=X;break}s.extra=15&m,s.mode=22;case 22:if(s.extra){for(S=s.extra;c>>=s.extra,c-=s.extra,s.back+=s.extra}s.was=s.length,s.mode=23;case 23:for(;m=(Q=s.distcode[l&(1<>>16&255,w=65535&Q,!((g=Q>>>24)<=c);){if(0===o)break t;o--,l+=i[r++]<>b)])>>>16&255,w=65535&Q,!(b+(g=Q>>>24)<=c);){if(0===o)break t;o--,l+=i[r++]<>>=b,c-=b,s.back+=b}if(l>>>=g,c-=g,s.back+=g,64&m){t.msg="invalid distance code",s.mode=X;break}s.offset=w,s.extra=15&m,s.mode=24;case 24:if(s.extra){for(S=s.extra;c>>=s.extra,c-=s.extra,s.back+=s.extra}if(s.offset>s.dmax){t.msg="invalid distance too far back",s.mode=X;break}s.mode=25;case 25:if(0===h)break t;if(u=_-h,s.offset>u){if((u=s.offset-u)>s.whave&&s.sane){t.msg="invalid distance too far back",s.mode=X;break}u>s.wnext?(u-=s.wnext,f=s.wsize-u):f=s.wnext-u,u>s.length&&(u=s.length),p=s.window}else p=n,f=a-s.offset,u=s.length;u>h&&(u=h),h-=u,s.length-=u;do{n[a++]=p[f++]}while(--u);0===s.length&&(s.mode=21);break;case 26:if(0===h)break t;n[a++]=s.length,h--,s.mode=21;break;case 27:if(s.wrap){for(;c<32;){if(0===o)break t;o--,l|=i[r++]<=0;)t[e]=0}var it=256,nt=286,rt=30,at=15,ot=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],ht=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],lt=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],ct=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],dt=new Array(576);st(dt);var _t=new Array(60);st(_t);var ut=new Array(512);st(ut);var ft=new Array(256);st(ft);var pt=new Array(29);st(pt);var gt,mt,wt,bt=new Array(rt);function vt(t,e,s,i,n){this.static_tree=t,this.extra_bits=e,this.extra_base=s,this.elems=i,this.max_length=n,this.has_stree=t&&t.length}function kt(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e}function yt(t){return t<256?ut[t]:ut[256+(t>>>7)]}function Ct(t,e){t.pending_buf[t.pending++]=255&e,t.pending_buf[t.pending++]=e>>>8&255}function xt(t,e,s){t.bi_valid>16-s?(t.bi_buf|=e<>16-t.bi_valid,t.bi_valid+=s-16):(t.bi_buf|=e<>>=1,s<<=1}while(--e>0);return s>>>1}function Mt(t,e,s){var i,n,r=new Array(16),a=0;for(i=1;i<=at;i++)r[i]=a=a+s[i-1]<<1;for(n=0;n<=e;n++){var o=t[2*n+1];0!==o&&(t[2*n]=Qt(r[o]++,o))}}function Et(t){var e;for(e=0;e8?Ct(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0}function Tt(t,e,s,i){var n=2*e,r=2*s;return t[n]>1;s>=1;s--)Ft(t,r,s);n=h;do{s=t.heap[1],t.heap[1]=t.heap[t.heap_len--],Ft(t,r,1),i=t.heap[1],t.heap[--t.heap_max]=s,t.heap[--t.heap_max]=i,r[2*n]=r[2*s]+r[2*i],t.depth[n]=(t.depth[s]>=t.depth[i]?t.depth[s]:t.depth[i])+1,r[2*s+1]=r[2*i+1]=n,t.heap[1]=n++,Ft(t,r,1)}while(t.heap_len>=2);t.heap[--t.heap_max]=t.heap[1],function(t,e){var s,i,n,r,a,o,h=e.dyn_tree,l=e.max_code,c=e.stat_desc.static_tree,d=e.stat_desc.has_stree,_=e.stat_desc.extra_bits,u=e.stat_desc.extra_base,f=e.stat_desc.max_length,p=0;for(r=0;r<=at;r++)t.bl_count[r]=0;for(h[2*t.heap[t.heap_max]+1]=0,s=t.heap_max+1;s<573;s++)(r=h[2*h[2*(i=t.heap[s])+1]+1]+1)>f&&(r=f,p++),h[2*i+1]=r,i>l||(t.bl_count[r]++,a=0,i>=u&&(a=_[i-u]),o=h[2*i],t.opt_len+=o*(r+a),d&&(t.static_len+=o*(c[2*i+1]+a)));if(0!==p){do{for(r=f-1;0===t.bl_count[r];)r--;t.bl_count[r]--,t.bl_count[r+1]+=2,t.bl_count[f]--,p-=2}while(p>0);for(r=f;0!==r;r--)for(i=t.bl_count[r];0!==i;)(n=t.heap[--s])>l||(h[2*n+1]!==r&&(t.opt_len+=(r-h[2*n+1])*h[2*n],h[2*n+1]=r),i--)}}(t,e),Mt(r,l,t.bl_count)}function Dt(t,e,s){var i,n,r=-1,a=e[1],o=0,h=7,l=4;for(0===a&&(h=138,l=3),e[2*(s+1)+1]=65535,i=0;i<=s;i++)n=a,a=e[2*(i+1)+1],++o>=7;i=8&&(t.pending_buf[t.pending++]=255&t.bi_buf,t.bi_buf>>=8,t.bi_valid-=8)}(t)}function Pt(t,e,s,i){var n,r,a=0;t.level>0?(2===t.strm.data_type&&(t.strm.data_type=function(t){var e,s=4093624447;for(e=0;e<=31;e++,s>>>=1)if(1&s&&0!==t.dyn_ltree[2*e])return 0;if(0!==t.dyn_ltree[18]||0!==t.dyn_ltree[20]||0!==t.dyn_ltree[26])return 1;for(e=32;e=3&&0===t.bl_tree[2*ct[e]+1];e--);return t.opt_len+=3*(e+1)+5+5+4,e}(t),n=t.opt_len+3+7>>>3,(r=t.static_len+3+7>>>3)<=n&&(n=r)):n=r=s+5,s+4<=n&&-1!==e?It(t,e,s,i):4===t.strategy||r===n?(xt(t,2+(i?1:0),3),Lt(t,dt,_t)):(xt(t,4+(i?1:0),3),function(t,e,s,i){var n;for(xt(t,e-257,5),xt(t,s-1,5),xt(t,i-4,4),n=0;n>>8&255,t.pending_buf[t.d_buf+2*t.last_lit+1]=255&e,t.pending_buf[t.l_buf+t.last_lit]=255&s,t.last_lit++,0===e?t.dyn_ltree[2*s]++:(t.matches++,e--,t.dyn_ltree[2*(ft[s]+it+1)]++,t.dyn_dtree[2*yt(e)]++),t.last_lit===t.lit_bufsize-1}var Ht={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"};const Kt=-2;var Xt,Ot=258,Gt=262,Wt=103,Yt=113,qt=666;function jt(t,e){return t.msg=Ht[e],e}function Zt(t){return(t<<1)-(t>4?9:0)}function Jt(t){for(var e=t.length;--e>=0;)t[e]=0}function $t(t){var e=t.state,s=e.pending;s>t.avail_out&&(s=t.avail_out),0!==s&&(A(t.output,e.pending_buf,e.pending_out,s,t.next_out),t.next_out+=s,e.pending_out+=s,t.total_out+=s,t.avail_out-=s,e.pending-=s,0===e.pending&&(e.pending_out=0))}function te(t,e){Pt(t,t.block_start>=0?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,$t(t.strm)}function ee(t,e){t.pending_buf[t.pending++]=e}function se(t,e){t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=255&e}function ie(t,e,s,i){var n=t.avail_in;return n>i&&(n=i),0===n?0:(t.avail_in-=n,A(e,t.input,t.next_in,n,s),1===t.state.wrap?t.adler=B(t.adler,e,n,s):2===t.state.wrap&&(t.adler=D(t.adler)),t.next_in+=n,t.total_in+=n,n)}function ne(t,e){var s,i,n=t.max_chain_length,r=t.strstart,a=t.prev_length,o=t.nice_match,h=t.strstart>t.w_size-Gt?t.strstart-(t.w_size-Gt):0,l=t.window,c=t.w_mask,d=t.prev,_=t.strstart+Ot,u=l[r+a-1],f=l[r+a];t.prev_length>=t.good_match&&(n>>=2),o>t.lookahead&&(o=t.lookahead);do{if(l[(s=e)+a]===f&&l[s+a-1]===u&&l[s]===l[r]&&l[++s]===l[r+1]){r+=2,s++;do{}while(l[++r]===l[++s]&&l[++r]===l[++s]&&l[++r]===l[++s]&&l[++r]===l[++s]&&l[++r]===l[++s]&&l[++r]===l[++s]&&l[++r]===l[++s]&&l[++r]===l[++s]&&r<_);if(i=Ot-(_-r),r=_-Ot,i>a){if(t.match_start=e,a=i,i>=o)break;u=l[r+a-1],f=l[r+a]}}}while((e=d[e&c])>h&&0!==--n);return a<=t.lookahead?a:t.lookahead}function re(t){var e,s,i,n,r,a=t.w_size;do{if(n=t.window_size-t.lookahead-t.strstart,t.strstart>=a+(a-Gt)){A(t.window,t.window,a,a,0),t.match_start-=a,t.strstart-=a,t.block_start-=a,e=s=t.hash_size;do{i=t.head[--e],t.head[e]=i>=a?i-a:0}while(--s);e=s=a;do{i=t.prev[--e],t.prev[e]=i>=a?i-a:0}while(--s);n+=a}if(0===t.strm.avail_in)break;if(s=ie(t.strm,t.window,t.strstart+t.lookahead,n),t.lookahead+=s,t.lookahead+t.insert>=3)for(r=t.strstart-t.insert,t.ins_h=t.window[r],t.ins_h=(t.ins_h<=3&&(t.ins_h=(t.ins_h<=3)if(i=Vt(t,t.strstart-t.match_start,t.match_length-3),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=3){t.match_length--;do{t.strstart++,t.ins_h=(t.ins_h<=3&&(t.ins_h=(t.ins_h<4096)&&(t.match_length=2)),t.prev_length>=3&&t.match_length<=t.prev_length){n=t.strstart+t.lookahead-3,i=Vt(t,t.strstart-1-t.prev_match,t.prev_length-3),t.lookahead-=t.prev_length-1,t.prev_length-=2;do{++t.strstart<=n&&(t.ins_h=(t.ins_h<15&&(a=2,i-=16),n<1||n>9||8!==s||i<8||i>15||e<0||e>9||r<0||r>4)return jt(t,Kt);8===i&&(i=9);var o=new le;return t.state=o,o.strm=t,o.wrap=a,o.gzhead=null,o.w_bits=i,o.w_size=1<5||e<0)return t?jt(t,Kt):Kt;if(i=t.state,!t.output||!t.input&&0!==t.avail_in||i.status===qt&&4!==e)return jt(t,0===t.avail_out?-5:Kt);if(i.strm=t,s=i.last_flush,i.last_flush=e,42===i.status)if(2===i.wrap)t.adler=0,ee(i,31),ee(i,139),ee(i,8),i.gzhead?(ee(i,(i.gzhead.text?1:0)+(i.gzhead.hcrc?2:0)+(i.gzhead.extra?4:0)+(i.gzhead.name?8:0)+(i.gzhead.comment?16:0)),ee(i,255&i.gzhead.time),ee(i,i.gzhead.time>>8&255),ee(i,i.gzhead.time>>16&255),ee(i,i.gzhead.time>>24&255),ee(i,9===i.level?2:i.strategy>=2||i.level<2?4:0),ee(i,255&i.gzhead.os),i.gzhead.extra&&i.gzhead.extra.length&&(ee(i,255&i.gzhead.extra.length),ee(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(t.adler=D(t.adler,i.pending_buf,i.pending)),i.gzindex=0,i.status=69):(ee(i,0),ee(i,0),ee(i,0),ee(i,0),ee(i,0),ee(i,9===i.level?2:i.strategy>=2||i.level<2?4:0),ee(i,3),i.status=Yt);else{var a=8+(i.w_bits-8<<4)<<8;a|=(i.strategy>=2||i.level<2?0:i.level<6?1:6===i.level?2:3)<<6,0!==i.strstart&&(a|=32),a+=31-a%31,i.status=Yt,se(i,a),0!==i.strstart&&(se(i,t.adler>>>16),se(i,65535&t.adler)),t.adler=1}if(69===i.status)if(i.gzhead.extra){for(n=i.pending;i.gzindex<(65535&i.gzhead.extra.length)&&(i.pending!==i.pending_buf_size||(i.gzhead.hcrc&&i.pending>n&&(t.adler=D(t.adler,i.pending_buf,i.pending)),$t(t),n=i.pending,i.pending!==i.pending_buf_size));)ee(i,255&i.gzhead.extra[i.gzindex]),i.gzindex++;i.gzhead.hcrc&&i.pending>n&&(t.adler=D(t.adler,i.pending_buf,i.pending)),i.gzindex===i.gzhead.extra.length&&(i.gzindex=0,i.status=73)}else i.status=73;if(73===i.status)if(i.gzhead.name){n=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>n&&(t.adler=D(t.adler,i.pending_buf,i.pending)),$t(t),n=i.pending,i.pending===i.pending_buf_size)){r=1;break}r=i.gzindexn&&(t.adler=D(t.adler,i.pending_buf,i.pending)),0===r&&(i.gzindex=0,i.status=91)}else i.status=91;if(91===i.status)if(i.gzhead.comment){n=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>n&&(t.adler=D(t.adler,i.pending_buf,i.pending)),$t(t),n=i.pending,i.pending===i.pending_buf_size)){r=1;break}r=i.gzindexn&&(t.adler=D(t.adler,i.pending_buf,i.pending)),0===r&&(i.status=Wt)}else i.status=Wt;if(i.status===Wt&&(i.gzhead.hcrc?(i.pending+2>i.pending_buf_size&&$t(t),i.pending+2<=i.pending_buf_size&&(ee(i,255&t.adler),ee(i,t.adler>>8&255),t.adler=0,i.status=Yt)):i.status=Yt),0!==i.pending){if($t(t),0===t.avail_out)return i.last_flush=-1,0}else if(0===t.avail_in&&Zt(e)<=Zt(s)&&4!==e)return jt(t,-5);if(i.status===qt&&0!==t.avail_in)return jt(t,-5);if(0!==t.avail_in||0!==i.lookahead||0!==e&&i.status!==qt){var o=2===i.strategy?function(t,e){for(var s;;){if(0===t.lookahead&&(re(t),0===t.lookahead)){if(0===e)return 1;break}if(t.match_length=0,s=Vt(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,s&&(te(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,4===e?(te(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(te(t,!1),0===t.strm.avail_out)?1:2}(i,e):3===i.strategy?function(t,e){for(var s,i,n,r,a=t.window;;){if(t.lookahead<=Ot){if(re(t),t.lookahead<=Ot&&0===e)return 1;if(0===t.lookahead)break}if(t.match_length=0,t.lookahead>=3&&t.strstart>0&&(i=a[n=t.strstart-1])===a[++n]&&i===a[++n]&&i===a[++n]){r=t.strstart+Ot;do{}while(i===a[++n]&&i===a[++n]&&i===a[++n]&&i===a[++n]&&i===a[++n]&&i===a[++n]&&i===a[++n]&&i===a[++n]&&nt.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=3?(s=Vt(t,1,t.match_length-3),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(s=Vt(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),s&&(te(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,4===e?(te(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(te(t,!1),0===t.strm.avail_out)?1:2}(i,e):Xt[i.level].func(i,e);if(3!==o&&4!==o||(i.status=qt),1===o||3===o)return 0===t.avail_out&&(i.last_flush=-1),0;if(2===o&&(1===e?Nt(i):5!==e&&(It(i,0,0,!1),3===e&&(Jt(i.head),0===i.lookahead&&(i.strstart=0,i.block_start=0,i.insert=0))),$t(t),0===t.avail_out))return i.last_flush=-1,0}return 4!==e?0:i.wrap<=0?1:(2===i.wrap?(ee(i,255&t.adler),ee(i,t.adler>>8&255),ee(i,t.adler>>16&255),ee(i,t.adler>>24&255),ee(i,255&t.total_in),ee(i,t.total_in>>8&255),ee(i,t.total_in>>16&255),ee(i,t.total_in>>24&255)):(se(i,t.adler>>>16),se(i,65535&t.adler)),$t(t),i.wrap>0&&(i.wrap=-i.wrap),0!==i.pending?0:1)}Xt=[new he(0,0,0,0,(function(t,e){var s=65535;for(s>t.pending_buf_size-5&&(s=t.pending_buf_size-5);;){if(t.lookahead<=1){if(re(t),0===t.lookahead&&0===e)return 1;if(0===t.lookahead)break}t.strstart+=t.lookahead,t.lookahead=0;var i=t.block_start+s;if((0===t.strstart||t.strstart>=i)&&(t.lookahead=t.strstart-i,t.strstart=i,te(t,!1),0===t.strm.avail_out))return 1;if(t.strstart-t.block_start>=t.w_size-Gt&&(te(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,4===e?(te(t,!0),0===t.strm.avail_out?3:4):(t.strstart>t.block_start&&(te(t,!1),t.strm.avail_out),1)})),new he(4,4,8,4,ae),new he(4,5,16,8,ae),new he(4,6,32,32,ae),new he(4,4,16,16,oe),new he(8,16,32,32,oe),new he(8,16,128,128,oe),new he(8,32,128,256,oe),new he(32,128,258,1024,oe),new he(32,258,258,4096,oe)];class ue{constructor(){this.strm=new tt,this.chunkSize=102400,this.outputBuffer=new Uint8Array(this.chunkSize),this.windowBits=5,de(this.strm,this.windowBits)}deflate(t){this.strm.input=t,this.strm.avail_in=this.strm.input.length,this.strm.next_in=0,this.strm.output=this.outputBuffer,this.strm.avail_out=this.chunkSize,this.strm.next_out=0;let e=_e(this.strm,3),s=new Uint8Array(this.strm.output.buffer,0,this.strm.next_out);if(e<0)throw new Error("zlib deflate failed");if(this.strm.avail_in>0){let t=[s],i=s.length;do{if(this.strm.output=new Uint8Array(this.chunkSize),this.strm.next_out=0,this.strm.avail_out=this.chunkSize,e=_e(this.strm,3),e<0)throw new Error("zlib deflate failed");let s=new Uint8Array(this.strm.output.buffer,0,this.strm.next_out);i+=s.length,t.push(s)}while(this.strm.avail_in>0);let n=new Uint8Array(i),r=0;for(let e=0;e=32&&t<=255)return t;const e=rr[t];return void 0!==e?e:16777216|t}},or={8:"Backspace",9:"Tab",10:"NumpadClear",13:"Enter",16:"ShiftLeft",17:"ControlLeft",18:"AltLeft",19:"Pause",20:"CapsLock",21:"Lang1",25:"Lang2",27:"Escape",28:"Convert",29:"NonConvert",32:"Space",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",41:"Select",44:"PrintScreen",45:"Insert",46:"Delete",47:"Help",48:"Digit0",49:"Digit1",50:"Digit2",51:"Digit3",52:"Digit4",53:"Digit5",54:"Digit6",55:"Digit7",56:"Digit8",57:"Digit9",91:"MetaLeft",92:"MetaRight",93:"ContextMenu",95:"Sleep",96:"Numpad0",97:"Numpad1",98:"Numpad2",99:"Numpad3",100:"Numpad4",101:"Numpad5",102:"Numpad6",103:"Numpad7",104:"Numpad8",105:"Numpad9",106:"NumpadMultiply",107:"NumpadAdd",108:"NumpadDecimal",109:"NumpadSubtract",110:"NumpadDecimal",111:"NumpadDivide",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",124:"F13",125:"F14",126:"F15",127:"F16",128:"F17",129:"F18",130:"F19",131:"F20",132:"F21",133:"F22",134:"F23",135:"F24",144:"NumLock",145:"ScrollLock",166:"BrowserBack",167:"BrowserForward",168:"BrowserRefresh",169:"BrowserStop",170:"BrowserSearch",171:"BrowserFavorites",172:"BrowserHome",173:"AudioVolumeMute",174:"AudioVolumeDown",175:"AudioVolumeUp",176:"MediaTrackNext",177:"MediaTrackPrevious",178:"MediaStop",179:"MediaPlayPause",180:"LaunchMail",181:"MediaSelect",182:"LaunchApp1",183:"LaunchApp2",225:"AltRight"},hr={Backspace:"Backspace",AltLeft:"Alt",AltRight:"Alt",CapsLock:"CapsLock",ContextMenu:"ContextMenu",ControlLeft:"Control",ControlRight:"Control",Enter:"Enter",MetaLeft:"Meta",MetaRight:"Meta",ShiftLeft:"Shift",ShiftRight:"Shift",Tab:"Tab",Delete:"Delete",End:"End",Help:"Help",Home:"Home",Insert:"Insert",PageDown:"PageDown",PageUp:"PageUp",ArrowDown:"ArrowDown",ArrowLeft:"ArrowLeft",ArrowRight:"ArrowRight",ArrowUp:"ArrowUp",NumLock:"NumLock",NumpadBackspace:"Backspace",NumpadClear:"Clear",Escape:"Escape",F1:"F1",F2:"F2",F3:"F3",F4:"F4",F5:"F5",F6:"F6",F7:"F7",F8:"F8",F9:"F9",F10:"F10",F11:"F11",F12:"F12",F13:"F13",F14:"F14",F15:"F15",F16:"F16",F17:"F17",F18:"F18",F19:"F19",F20:"F20",F21:"F21",F22:"F22",F23:"F23",F24:"F24",F25:"F25",F26:"F26",F27:"F27",F28:"F28",F29:"F29",F30:"F30",F31:"F31",F32:"F32",F33:"F33",F34:"F34",F35:"F35",PrintScreen:"PrintScreen",ScrollLock:"ScrollLock",Pause:"Pause",BrowserBack:"BrowserBack",BrowserFavorites:"BrowserFavorites",BrowserForward:"BrowserForward",BrowserHome:"BrowserHome",BrowserRefresh:"BrowserRefresh",BrowserSearch:"BrowserSearch",BrowserStop:"BrowserStop",Eject:"Eject",LaunchApp1:"LaunchMyComputer",LaunchApp2:"LaunchCalendar",LaunchMail:"LaunchMail",MediaPlayPause:"MediaPlay",MediaStop:"MediaStop",MediaTrackNext:"MediaTrackNext",MediaTrackPrevious:"MediaTrackPrevious",Power:"Power",Sleep:"Sleep",AudioVolumeDown:"AudioVolumeDown",AudioVolumeMute:"AudioVolumeMute",AudioVolumeUp:"AudioVolumeUp",WakeUp:"WakeUp"};const lr={};function cr(t,e){if(void 0===e)throw new Error('Undefined keysym for key "'+t+'"');if(t in lr)throw new Error('Duplicate entry for key "'+t+'"');lr[t]=[e,e,e,e]}function dr(t,e,s){if(void 0===e)throw new Error('Undefined keysym for key "'+t+'"');if(void 0===s)throw new Error('Undefined keysym for key "'+t+'"');if(t in lr)throw new Error('Duplicate entry for key "'+t+'"');lr[t]=[e,e,s,e]}function _r(t,e,s){if(void 0===e)throw new Error('Undefined keysym for key "'+t+'"');if(void 0===s)throw new Error('Undefined keysym for key "'+t+'"');if(t in lr)throw new Error('Duplicate entry for key "'+t+'"');lr[t]=[e,e,e,s]}dr("Alt",Ci,xi),cr("AltGraph",Mi),cr("CapsLock",vi),dr("Control",wi,bi),dr("Meta",Si,Qi),cr("NumLock",ns),cr("ScrollLock",be),dr("Shift",gi,mi),_r("Enter",me,as),cr("Tab",pe),_r(" ",Li,rs),_r("ArrowDown",Ke,ds),_r("ArrowLeft",Pe,hs),_r("ArrowRight",He,cs),_r("ArrowUp",Ve,ls),_r("End",Ge,fs),_r("Home",Ne,os),_r("PageDown",Oe,us),_r("PageUp",Xe,_s),cr("Backspace",fe),_r("Clear",ge,ps),cr("Copy",Bn),cr("Cut",Dn),_r("Delete",ke,ms),_r("Insert",je,gs),cr("Paste",Nn),cr("Redo",Je),cr("Undo",Ze),cr("Cancel",es),cr("ContextMenu",$e),cr("Escape",ve),cr("Execute",qe),cr("Find",ts),cr("Help",ss),cr("Pause",we),cr("Select",We),cr("ZoomIn",Wn),cr("ZoomOut",Yn),cr("BrightnessDown",tn),cr("BrightnessUp",$i),cr("Eject",Cn),cr("LogOff",Un),cr("Power",kn),cr("PowerOff",gn),cr("PrintScreen",Ye),cr("Hibernate",sr),cr("Standby",en),cr("WakeUp",yn),cr("AllCandidates",Se),cr("Alphanumeric",Ie),cr("CodeInput",Ce),cr("Compose",ye),cr("Convert",Ae),cr("GroupFirst",Ti),cr("GroupLast",Fi),cr("GroupNext",Ei),cr("GroupPrevious",Ai),cr("NonConvert",Ee),cr("PreviousCandidate",Qe),cr("SingleCandidate",xe),cr("HangulMode",ji),cr("HanjaMode",Zi),cr("JunjaMode",Ji),cr("Eisu",Ie),cr("Hankaku",ze),cr("Hiragana",Fe),cr("HiraganaKatakana",Be),cr("KanaMode",Re),cr("KanjiMode",Me),cr("Katakana",Le),cr("Romaji",Te),cr("Zenkaku",De),cr("ZenkakuHankaku",Ue),cr("F1",zs),cr("F2",Us),cr("F3",Rs),cr("F4",Is),cr("F5",Ns),cr("F6",Ps),cr("F7",Vs),cr("F8",Hs),cr("F9",Ks),cr("F10",Xs),cr("F11",Os),cr("F12",Gs),cr("F13",Ws),cr("F14",Ys),cr("F15",qs),cr("F16",js),cr("F17",Zs),cr("F18",Js),cr("F19",$s),cr("F20",ti),cr("F21",ei),cr("F22",si),cr("F23",ii),cr("F24",ni),cr("F25",ri),cr("F26",ai),cr("F27",oi),cr("F28",hi),cr("F29",li),cr("F30",ci),cr("F31",di),cr("F32",_i),cr("F33",ui),cr("F34",fi),cr("F35",pi),cr("Close",Ln),cr("MailForward",jn),cr("MailReply",Vn),cr("MailSend",Kn),cr("MediaFastForward",Jn),cr("MediaPause",Mn),cr("MediaPlay",an),cr("MediaRecord",un),cr("MediaRewind",Fn),cr("MediaStop",on),cr("MediaTrackNext",ln),cr("MediaTrackPrevious",hn),cr("New",Rn),cr("Open",In),cr("Print",Ye),cr("Save",Hn),cr("SpellCheck",Xn),cr("AudioVolumeDown",sn),cr("AudioVolumeUp",rn),cr("AudioVolumeMute",nn),cr("MicrophoneVolumeMute",ir),cr("LaunchApplication1",An),cr("LaunchApplication2",fn),cr("LaunchCalendar",pn),cr("LaunchMail",dn),cr("LaunchMediaPlayer",En),cr("LaunchMusicPlayer",Zn),cr("LaunchPhone",Pn),cr("LaunchScreenSaver",xn),cr("LaunchSpreadsheet",zn),cr("LaunchWebBrowser",Sn),cr("LaunchWebCam",qn),cr("LaunchWordProcessor",Gn),cr("BrowserBack",mn),cr("BrowserFavorites",Qn),cr("BrowserForward",wn),cr("BrowserHome",cn),cr("BrowserRefresh",vn),cr("BrowserSearch",_n),cr("BrowserStop",bn),cr("Dimmer",Tn),cr("MediaAudioTrack",er),cr("RandomToggle",$n),cr("SplitScreenToggle",On),cr("Subtitle",tr),cr("VideoModeNext",nr),_r("=",qi,ws),_r("+",Di,vs),_r("-",Ui,ys),_r("*",Bi,bs),_r("/",Ii,xs),_r(".",Ri,Cs),_r(",",zi,ks),_r("0",Ni,Ss),_r("1",Pi,Qs),_r("2",Vi,Ms),_r("3",Hi,Es),_r("4",Ki,As),_r("5",Xi,Ts),_r("6",Oi,Fs),_r("7",Gi,Ls),_r("8",Wi,Bs),_r("9",Yi,Ds);var ur=lr;function fr(t){if(t.code){switch(t.code){case"OSLeft":return"MetaLeft";case"OSRight":return"MetaRight"}return t.code}if(t.keyCode in or){let e=or[t.keyCode];if(g()&&"ContextMenu"===e&&(e="MetaRight"),2===t.location)switch(e){case"ShiftLeft":return"ShiftRight";case"ControlLeft":return"ControlRight";case"AltLeft":return"AltRight"}if(3===t.location)switch(e){case"Delete":return"NumpadDecimal";case"Insert":return"Numpad0";case"End":return"Numpad1";case"ArrowDown":return"Numpad2";case"PageDown":return"Numpad3";case"ArrowLeft":return"Numpad4";case"ArrowRight":return"Numpad6";case"Home":return"Numpad7";case"ArrowUp":return"Numpad8";case"PageUp":return"Numpad9";case"Enter":return"NumpadEnter"}return e}return"Unidentified"}function pr(t){const e=function(t){if(void 0!==t.key){switch(t.key){case"OS":return"Meta";case"LaunchMyComputer":return"LaunchApplication1";case"LaunchCalculator":return"LaunchApplication2"}switch(t.key){case"UIKeyInputUpArrow":return"ArrowUp";case"UIKeyInputDownArrow":return"ArrowDown";case"UIKeyInputLeftArrow":return"ArrowLeft";case"UIKeyInputRightArrow":return"ArrowRight";case"UIKeyInputEscape":return"Escape"}return"\0"===t.key&&"NumpadDecimal"===t.code?"Delete":t.key}const e=fr(t);return e in hr?hr[e]:t.charCode?String.fromCharCode(t.charCode):"Unidentified"}(t);if("Unidentified"===e)return null;if(e in ur){let s=t.location;if("Meta"===e&&0===s&&(s=2),"Clear"===e&&3===s){"NumLock"===fr(t)&&(s=0)}if((void 0===s||s>3)&&(s=0),"Meta"===e){let e=fr(t);if("AltLeft"===e)return ki;if("AltRight"===e)return yi}if("Clear"===e){if("NumLock"===fr(t))return ns}if(m())switch(e){case"Zenkaku":case"Hankaku":return Ue;case"Romaji":case"KanaMode":return Te}return ur[e][s]}if(1!==e.length)return null;const s=e.charCodeAt();return s?ar.lookup(s):null}class gr{constructor(t){this._target=t||null,this._keyDownList={},this._altGrArmed=!1,this._eventHandlers={keyup:this._handleKeyUp.bind(this),keydown:this._handleKeyDown.bind(this),blur:this._allKeysUp.bind(this)},this.onkeyevent=()=>{}}_sendKeyEvent(t,e,s){if(s)this._keyDownList[e]=t;else{if(!(e in this._keyDownList))return;delete this._keyDownList[e]}r("onkeyevent "+(s?"down":"up")+", keysym: "+t,", code: "+e),this.onkeyevent(t,e,s)}_getKeyCode(t){const e=fr(t);if("Unidentified"!==e)return e;if(t.keyCode&&229!==t.keyCode)return"Platform"+t.keyCode;if(t.keyIdentifier){if("U+"!==t.keyIdentifier.substr(0,2))return t.keyIdentifier;const e=parseInt(t.keyIdentifier.substr(2),16);return"Platform"+String.fromCharCode(e).toUpperCase().charCodeAt()}return"Unidentified"}_handleKeyDown(t){const e=this._getKeyCode(t);let s=pr(t);if(this._altGrArmed&&(this._altGrArmed=!1,clearTimeout(this._altGrTimeout),"AltRight"===e&&t.timeStamp-this._altGrCtrlTime<50?s=Mi:this._sendKeyEvent(wi,"ControlLeft",!0)),"Unidentified"===e)return s&&(this._sendKeyEvent(s,e,!0),this._sendKeyEvent(s,e,!1)),void v(t);if(g()||w())switch(s){case Si:s=Ci;break;case Qi:s=Si;break;case Ci:s=is;break;case xi:s=Mi}if(e in this._keyDownList&&(s=this._keyDownList[e]),(g()||w())&&"CapsLock"===e)return this._sendKeyEvent(vi,"CapsLock",!0),this._sendKeyEvent(vi,"CapsLock",!1),void v(t);const i=[Ue,Ie,Le,Fe,Te];return m()&&i.includes(s)?(this._sendKeyEvent(s,e,!0),this._sendKeyEvent(s,e,!1),void v(t)):(v(t),"ControlLeft"===e&&m()&&!("ControlLeft"in this._keyDownList)?(this._altGrArmed=!0,this._altGrTimeout=setTimeout(this._handleAltGrTimeout.bind(this),100),void(this._altGrCtrlTime=t.timeStamp)):void this._sendKeyEvent(s,e,!0))}_handleKeyUp(t){v(t);const e=this._getKeyCode(t);if(this._altGrArmed&&(this._altGrArmed=!1,clearTimeout(this._altGrTimeout),this._sendKeyEvent(wi,"ControlLeft",!0)),(g()||w())&&"CapsLock"===e)return this._sendKeyEvent(vi,"CapsLock",!0),void this._sendKeyEvent(vi,"CapsLock",!1);this._sendKeyEvent(this._keyDownList[e],e,!1),!m()||"ShiftLeft"!==e&&"ShiftRight"!==e||("ShiftRight"in this._keyDownList&&this._sendKeyEvent(this._keyDownList.ShiftRight,"ShiftRight",!1),"ShiftLeft"in this._keyDownList&&this._sendKeyEvent(this._keyDownList.ShiftLeft,"ShiftLeft",!1))}_handleAltGrTimeout(){this._altGrArmed=!1,clearTimeout(this._altGrTimeout),this._sendKeyEvent(wi,"ControlLeft",!0)}_allKeysUp(){r(">> Keyboard.allKeysUp");for(let t in this._keyDownList)this._sendKeyEvent(this._keyDownList[t],t,!1);r("<< Keyboard.allKeysUp")}grab(){this._target.addEventListener("keydown",this._eventHandlers.keydown),this._target.addEventListener("keyup",this._eventHandlers.keyup),window.addEventListener("blur",this._eventHandlers.blur)}ungrab(){this._target.removeEventListener("keydown",this._eventHandlers.keydown),this._target.removeEventListener("keyup",this._eventHandlers.keyup),window.removeEventListener("blur",this._eventHandlers.blur),this._allKeysUp()}}const mr=32,wr=64;class br{constructor(){this._target=null,this._state=127,this._tracked=[],this._ignored=[],this._waitingRelease=!1,this._releaseStart=0,this._longpressTimeoutId=null,this._twoTouchTimeoutId=null,this._boundEventHandler=this._eventHandler.bind(this)}attach(t){this.detach(),this._target=t,this._target.addEventListener("touchstart",this._boundEventHandler),this._target.addEventListener("touchmove",this._boundEventHandler),this._target.addEventListener("touchend",this._boundEventHandler),this._target.addEventListener("touchcancel",this._boundEventHandler)}detach(){this._target&&(this._stopLongpressTimeout(),this._stopTwoTouchTimeout(),this._target.removeEventListener("touchstart",this._boundEventHandler),this._target.removeEventListener("touchmove",this._boundEventHandler),this._target.removeEventListener("touchend",this._boundEventHandler),this._target.removeEventListener("touchcancel",this._boundEventHandler),this._target=null)}_eventHandler(t){let e;switch(t.stopPropagation(),t.preventDefault(),t.type){case"touchstart":e=this._touchStart;break;case"touchmove":e=this._touchMove;break;case"touchend":case"touchcancel":e=this._touchEnd}for(let s=0;s0&&Date.now()-this._tracked[0].started>250)return this._state=0,void this._ignored.push(t);if(this._waitingRelease)return this._state=0,void this._ignored.push(t);switch(this._tracked.push({id:t,started:Date.now(),active:!0,firstX:e,firstY:s,lastX:e,lastY:s,angle:0}),this._tracked.length){case 1:this._startLongpressTimeout();break;case 2:this._state&=-26,this._stopLongpressTimeout();break;case 3:this._state&=-99;break;default:this._state=0}}}_touchMove(t,e,s){let i=this._tracked.find((e=>e.id===t));if(void 0===i)return;i.lastX=e,i.lastY=s;let n=e-i.firstX,r=s-i.firstY;if(i.firstX===i.lastX&&i.firstY===i.lastY||(i.angle=180*Math.atan2(r,n)/Math.PI),!this._hasDetectedGesture()){if(Math.hypot(n,r)<50)return;if(this._state&=-24,this._stopLongpressTimeout(),1!==this._tracked.length&&(this._state&=-9),2!==this._tracked.length&&(this._state&=-97),2===this._tracked.length){let e=this._tracked.find((e=>e.id!==t));if(Math.hypot(e.firstX-e.lastX,e.firstY-e.lastY)>50){let t=Math.abs(i.angle-e.angle);t=Math.abs((t+180)%360-180),this._state&=t>90?-33:-65,this._isTwoTouchTimeoutRunning()&&this._stopTwoTouchTimeout()}else this._isTwoTouchTimeoutRunning()||this._startTwoTouchTimeout()}if(!this._hasDetectedGesture())return;this._pushEvent("gesturestart")}this._pushEvent("gesturemove")}_touchEnd(t,e,s){if(-1!==this._ignored.indexOf(t))return this._ignored.splice(this._ignored.indexOf(t),1),void(0===this._ignored.length&&0===this._tracked.length&&(this._state=127,this._waitingRelease=!1));if(!this._hasDetectedGesture()&&this._isTwoTouchTimeoutRunning()&&(this._stopTwoTouchTimeout(),this._state=0),!this._hasDetectedGesture()&&(this._state&=-105,this._state&=-17,this._stopLongpressTimeout(),!this._waitingRelease))switch(this._releaseStart=Date.now(),this._waitingRelease=!0,this._tracked.length){case 1:this._state&=-7;break;case 2:this._state&=-6}if(this._waitingRelease){if(Date.now()-this._releaseStart>250&&(this._state=0),this._tracked.some((t=>Date.now()-t.started>1e3))&&(this._state=0),this._tracked.find((e=>e.id===t)).active=!1,this._hasDetectedGesture())this._pushEvent("gesturestart");else if(0!==this._state)return}this._hasDetectedGesture()&&this._pushEvent("gestureend");for(let i=0;it.active))))}_startLongpressTimeout(){this._stopLongpressTimeout(),this._longpressTimeoutId=setTimeout((()=>this._longpressTimeout()),1e3)}_stopLongpressTimeout(){clearTimeout(this._longpressTimeoutId),this._longpressTimeoutId=null}_longpressTimeout(){if(this._hasDetectedGesture())throw new Error("A longpress gesture failed, conflict with a different gesture");this._state=16,this._pushEvent("gesturestart")}_startTwoTouchTimeout(){this._stopTwoTouchTimeout(),this._twoTouchTimeoutId=setTimeout((()=>this._twoTouchTimeout()),50)}_stopTwoTouchTimeout(){clearTimeout(this._twoTouchTimeoutId),this._twoTouchTimeoutId=null}_isTwoTouchTimeoutRunning(){return null!==this._twoTouchTimeoutId}_twoTouchTimeout(){if(0===this._tracked.length)throw new Error("A pinch or two drag gesture failed, no tracked touches");let t=this._getAverageMovement(),e=Math.abs(t.x),s=Math.abs(t.y),i=this._getAverageDistance(),n=Math.abs(Math.hypot(i.first.x,i.first.y)-Math.hypot(i.last.x,i.last.y));this._state=s{this._target&&(e=document.elementFromPoint(t.clientX,t.clientY),this._updateVisibility(e))}),0)}_showCursor(){"hidden"===this._canvas.style.visibility&&(this._canvas.style.visibility="")}_hideCursor(){"hidden"!==this._canvas.style.visibility&&(this._canvas.style.visibility="hidden")}_shouldShowCursor(t){return!!t&&(t===this._target||!!this._target.contains(t)&&"none"===window.getComputedStyle(t).cursor)}_updateVisibility(t){this._captureIsActive()&&(t=document.captureElement),this._shouldShowCursor(t)?this._showCursor():this._hideCursor()}_updatePosition(){this._canvas.style.left=this._position.x+"px",this._canvas.style.top=this._position.y+"px"}_captureIsActive(){return document.captureElement&&document.documentElement.contains(document.captureElement)}}const yr=41943040,Cr="connecting",xr="open",Sr="closing",Qr="closed",Mr={CONNECTING:[WebSocket.CONNECTING,Cr],OPEN:[WebSocket.OPEN,xr],CLOSING:[WebSocket.CLOSING,Sr],CLOSED:[WebSocket.CLOSED,Qr]},Er=["send","close","binaryType","onerror","onmessage","onopen","protocol","readyState"];class Ar{constructor(){this._websocket=null,this._rQi=0,this._rQlen=0,this._rQbufferSize=4194304,this._rQ=null,this._sQbufferSize=10240,this._sQlen=0,this._sQ=null,this._eventHandlers={message:()=>{},open:()=>{},close:()=>{},error:()=>{}}}get readyState(){let t;return null===this._websocket?"unused":(t=this._websocket.readyState,Mr.CONNECTING.includes(t)?"connecting":Mr.OPEN.includes(t)?"open":Mr.CLOSING.includes(t)?"closing":Mr.CLOSED.includes(t)?"closed":"unknown")}get sQ(){return this._sQ}get rQ(){return this._rQ}get rQi(){return this._rQi}set rQi(t){this._rQi=t}get rQlen(){return this._rQlen-this._rQi}rQpeek8(){return this._rQ[this._rQi]}rQskipBytes(t){this._rQi+=t}rQshift8(){return this._rQshift(1)}rQshift16(){return this._rQshift(2)}rQshift32(){return this._rQshift(4)}_rQshift(t){let e=0;for(let s=t-1;s>=0;s--)e+=this._rQ[this._rQi++]<<8*s;return e}rQshiftStr(t){"undefined"===typeof t&&(t=this.rQlen);let e="";for(let s=0;s0&&"open"===this.readyState&&(this._websocket.send(this._encodeMessage()),this._sQlen=0)}send(t){this._sQ.set(t,this._sQlen),this._sQlen+=t.length,this.flush()}sendString(t){this.send(t.split("").map((t=>t.charCodeAt(0))))}off(t){this._eventHandlers[t]=()=>{}}on(t,e){this._eventHandlers[t]=e}_allocateBuffers(){this._rQ=new Uint8Array(this._rQbufferSize),this._sQ=new Uint8Array(this._sQbufferSize)}init(){this._allocateBuffers(),this._rQi=0,this._websocket=null}open(t,e){this.attach(new WebSocket(t,e))}attach(t){this.init();const e=[...Object.keys(t),...Object.getOwnPropertyNames(Object.getPrototypeOf(t))];for(let s=0;s{r(">> WebSock.onopen"),this._websocket.protocol&&a("Server choose sub-protocol: "+this._websocket.protocol),this._eventHandlers.open(),r("<< WebSock.onopen")},this._websocket.onclose=t=>{r(">> WebSock.onclose"),this._eventHandlers.close(t),r("<< WebSock.onclose")},this._websocket.onerror=t=>{r(">> WebSock.onerror: "+t),this._eventHandlers.error(t),r("<< WebSock.onerror: "+t)}}close(){this._websocket&&("connecting"!==this.readyState&&"open"!==this.readyState||(a("Closing WebSocket connection"),this._websocket.close()),this._websocket.onmessage=()=>{})}_encodeMessage(){return new Uint8Array(this._sQ.buffer,0,this._sQlen)}_expandCompactRQ(t){const e=8*(this._rQlen-this._rQi+t),s=this._rQbufferSizeyr&&(this._rQbufferSize=yr,this._rQbufferSize-this.rQlenthis._rQbufferSize-this._rQlen&&this._expandCompactRQ(e.length),this._rQ.set(e,this._rQlen),this._rQlen+=e.length}_recvMessage(t){this._DecodeMessage(t.data),this.rQlen>0?(this._eventHandlers.message(),this._rQlen==this._rQi&&(this._rQlen=0,this._rQi=0)):r("Ignoring empty message")}}const Tr=[13,16,10,23,0,4,2,27,14,5,20,9,22,18,11,3,25,7,15,6,26,19,12,1,40,51,30,36,46,54,29,39,50,44,32,47,43,48,38,55,33,52,45,41,49,35,28,31],Fr=[1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28];let Lr,Br,Dr,zr,Ur,Rr;Lr=65536,Br=1<<24,Dr=Lr|Br,zr=4,Ur=1024,Rr=zr|Ur;const Ir=[Dr|Ur,0,0|Lr,Dr|Rr,Dr|zr,Lr|Rr,0|zr,0|Lr,0|Ur,Dr|Ur,Dr|Rr,0|Ur,Br|Rr,Dr|zr,0|Br,0|zr,0|Rr,Br|Ur,Br|Ur,Lr|Ur,Lr|Ur,0|Dr,0|Dr,Br|Rr,Lr|zr,Br|zr,Br|zr,Lr|zr,0,0|Rr,Lr|Rr,0|Br,0|Lr,Dr|Rr,0|zr,0|Dr,Dr|Ur,0|Br,0|Br,0|Ur,Dr|zr,0|Lr,Lr|Ur,Br|zr,0|Ur,0|zr,Br|Rr,Lr|Rr,Dr|Rr,Lr|zr,0|Dr,Br|Rr,Br|zr,0|Rr,Lr|Rr,Dr|Ur,0|Rr,Br|Ur,Br|Ur,0,Lr|zr,Lr|Ur,0,Dr|zr];Lr=1<<20,Br=1<<31,Dr=Lr|Br,zr=32,Ur=32768,Rr=zr|Ur;const Nr=[Dr|Rr,Br|Ur,0|Ur,Lr|Rr,0|Lr,0|zr,Dr|zr,Br|Rr,Br|zr,Dr|Rr,Dr|Ur,0|Br,Br|Ur,0|Lr,0|zr,Dr|zr,Lr|Ur,Lr|zr,Br|Rr,0,0|Br,0|Ur,Lr|Rr,0|Dr,Lr|zr,Br|zr,0,Lr|Ur,0|Rr,Dr|Ur,0|Dr,0|Rr,0,Lr|Rr,Dr|zr,0|Lr,Br|Rr,0|Dr,Dr|Ur,0|Ur,0|Dr,Br|Ur,0|zr,Dr|Rr,Lr|Rr,0|zr,0|Ur,0|Br,0|Rr,Dr|Ur,0|Lr,Br|zr,Lr|zr,Br|Rr,Br|zr,Lr|zr,Lr|Ur,0,Br|Ur,0|Rr,0|Br,Dr|zr,Dr|Rr,Lr|Ur];Lr=1<<17,Br=1<<27,Dr=Lr|Br,zr=8,Ur=512,Rr=zr|Ur;const Pr=[0|Rr,Dr|Ur,0,Dr|zr,Br|Ur,0,Lr|Rr,Br|Ur,Lr|zr,Br|zr,Br|zr,0|Lr,Dr|Rr,Lr|zr,0|Dr,0|Rr,0|Br,0|zr,Dr|Ur,0|Ur,Lr|Ur,0|Dr,Dr|zr,Lr|Rr,Br|Rr,Lr|Ur,0|Lr,Br|Rr,0|zr,Dr|Rr,0|Ur,0|Br,Dr|Ur,0|Br,Lr|zr,0|Rr,0|Lr,Dr|Ur,Br|Ur,0,0|Ur,Lr|zr,Dr|Rr,Br|Ur,Br|zr,0|Ur,0,Dr|zr,Br|Rr,0|Lr,0|Br,Dr|Rr,0|zr,Lr|Rr,Lr|Ur,Br|zr,0|Dr,Br|Rr,0|Rr,0|Dr,Lr|Rr,0|zr,Dr|zr,Lr|Ur];Lr=8192,Br=1<<23,Dr=Lr|Br,zr=1,Ur=128,Rr=zr|Ur;const Vr=[Dr|zr,Lr|Rr,Lr|Rr,0|Ur,Dr|Ur,Br|Rr,Br|zr,Lr|zr,0,0|Dr,0|Dr,Dr|Rr,0|Rr,0,Br|Ur,Br|zr,0|zr,0|Lr,0|Br,Dr|zr,0|Ur,0|Br,Lr|zr,Lr|Ur,Br|Rr,0|zr,Lr|Ur,Br|Ur,0|Lr,Dr|Ur,Dr|Rr,0|Rr,Br|Ur,Br|zr,0|Dr,Dr|Rr,0|Rr,0,0,0|Dr,Lr|Ur,Br|Ur,Br|Rr,0|zr,Dr|zr,Lr|Rr,Lr|Rr,0|Ur,Dr|Rr,0|Rr,0|zr,0|Lr,Br|zr,Lr|zr,Dr|Ur,Br|Rr,Lr|zr,Lr|Ur,0|Br,Dr|zr,0|Ur,0|Br,0|Lr,Dr|Ur];Lr=1<<25,Br=1<<30,Dr=Lr|Br,zr=256,Ur=1<<19,Rr=zr|Ur;const Hr=[0|zr,Lr|Rr,Lr|Ur,Dr|zr,0|Ur,0|zr,0|Br,Lr|Ur,Br|Rr,0|Ur,Lr|zr,Br|Rr,Dr|zr,Dr|Ur,0|Rr,0|Br,0|Lr,Br|Ur,Br|Ur,0,Br|zr,Dr|Rr,Dr|Rr,Lr|zr,Dr|Ur,Br|zr,0,0|Dr,Lr|Rr,0|Lr,0|Dr,0|Rr,0|Ur,Dr|zr,0|zr,0|Lr,0|Br,Lr|Ur,Dr|zr,Br|Rr,Lr|zr,0|Br,Dr|Ur,Lr|Rr,Br|Rr,0|zr,0|Lr,Dr|Ur,Dr|Rr,0|Rr,0|Dr,Dr|Rr,Lr|Ur,0,Br|Ur,0|Dr,0|Rr,Lr|zr,Br|zr,0|Ur,0,Br|Ur,Lr|Rr,Br|zr];Lr=1<<22,Br=1<<29,Dr=Lr|Br,zr=16,Ur=16384,Rr=zr|Ur;const Kr=[Br|zr,0|Dr,0|Ur,Dr|Rr,0|Dr,0|zr,Dr|Rr,0|Lr,Br|Ur,Lr|Rr,0|Lr,Br|zr,Lr|zr,Br|Ur,0|Br,0|Rr,0,Lr|zr,Br|Rr,0|Ur,Lr|Ur,Br|Rr,0|zr,Dr|zr,Dr|zr,0,Lr|Rr,Dr|Ur,0|Rr,Lr|Ur,Dr|Ur,0|Br,Br|Ur,0|zr,Dr|zr,Lr|Ur,Dr|Rr,0|Lr,0|Rr,Br|zr,0|Lr,Br|Ur,0|Br,0|Rr,Br|zr,Dr|Rr,Lr|Ur,0|Dr,Lr|Rr,Dr|Ur,0,Dr|zr,0|zr,0|Ur,0|Dr,Lr|Rr,0|Ur,Lr|zr,Br|Rr,0,Dr|Ur,0|Br,Lr|zr,Br|Rr];Lr=1<<21,Br=1<<26,Dr=Lr|Br,zr=2,Ur=2048,Rr=zr|Ur;const Xr=[0|Lr,Dr|zr,Br|Rr,0,0|Ur,Br|Rr,Lr|Rr,Dr|Ur,Dr|Rr,0|Lr,0,Br|zr,0|zr,0|Br,Dr|zr,0|Rr,Br|Ur,Lr|Rr,Lr|zr,Br|Ur,Br|zr,0|Dr,Dr|Ur,Lr|zr,0|Dr,0|Ur,0|Rr,Dr|Rr,Lr|Ur,0|zr,0|Br,Lr|Ur,0|Br,Lr|Ur,0|Lr,Br|Rr,Br|Rr,Dr|zr,Dr|zr,0|zr,Lr|zr,0|Br,Br|Ur,0|Lr,Dr|Ur,0|Rr,Lr|Rr,Dr|Ur,0|Rr,Br|zr,Dr|Rr,0|Dr,Lr|Ur,0,0|zr,Dr|Rr,0,Lr|Rr,0|Dr,0|Ur,Br|zr,Br|Ur,0|Ur,Lr|zr];Lr=1<<18,Br=1<<28,Dr=Lr|Br,zr=64,Ur=4096,Rr=zr|Ur;const Or=[Br|Rr,0|Ur,0|Lr,Dr|Rr,0|Br,Br|Rr,0|zr,0|Br,Lr|zr,0|Dr,Dr|Rr,Lr|Ur,Dr|Ur,Lr|Rr,0|Ur,0|zr,0|Dr,Br|zr,Br|Ur,0|Rr,Lr|Ur,Lr|zr,Dr|zr,Dr|Ur,0|Rr,0,0,Dr|zr,Br|zr,Br|Ur,Lr|Rr,0|Lr,Lr|Rr,0|Lr,Dr|Ur,0|Ur,0|zr,Dr|zr,0|Ur,Lr|Rr,Br|Ur,0|zr,Br|zr,0|Dr,Dr|zr,0|Br,0|Lr,Br|Rr,0,Dr|Rr,Lr|zr,Br|zr,0|Dr,Br|Ur,Br|Rr,0,Dr|Rr,Lr|Ur,Lr|Ur,0|Rr,0|Rr,Lr|zr,0|Br,Dr|Ur];class Gr{constructor(t){this.keys=[];const e=[],s=[],i=[];for(let n=0,r=56;n<56;++n,r-=8){r+=r<-5?65:r<-3?31:r<-1?63:27===r?35:0;const s=7&r;e[n]=0!==(t[r>>>3]&1<>>10,this.keys[a]|=(4032&e)>>>6,++a,this.keys[a]=(258048&t)<<12,this.keys[a]|=(63&t)<<16,this.keys[a]|=(258048&e)>>>4,this.keys[a]|=63&e,++a}}enc8(t){const e=t.slice();let s,i,n,r=0;s=e[r++]<<24|e[r++]<<16|e[r++]<<8|e[r++],i=e[r++]<<24|e[r++]<<16|e[r++]<<8|e[r++],n=252645135&(s>>>4^i),i^=n,s^=n<<4,n=65535&(s>>>16^i),i^=n,s^=n<<16,n=858993459&(i>>>2^s),s^=n,i^=n<<2,n=16711935&(i>>>8^s),s^=n,i^=n<<8,i=i<<1|i>>>31&1,n=2863311530&(s^i),s^=n,i^=n,s=s<<1|s>>>31&1;for(let a=0,o=0;a<8;++a){n=i<<28|i>>>4,n^=this.keys[o++];let t=Xr[63&n];t|=Hr[n>>>8&63],t|=Pr[n>>>16&63],t|=Ir[n>>>24&63],n=i^this.keys[o++],t|=Or[63&n],t|=Kr[n>>>8&63],t|=Vr[n>>>16&63],t|=Nr[n>>>24&63],s^=t,n=s<<28|s>>>4,n^=this.keys[o++],t=Xr[63&n],t|=Hr[n>>>8&63],t|=Pr[n>>>16&63],t|=Ir[n>>>24&63],n=s^this.keys[o++],t|=Or[63&n],t|=Kr[n>>>8&63],t|=Vr[n>>>16&63],t|=Nr[n>>>24&63],i^=t}for(i=i<<31|i>>>1,n=2863311530&(s^i),s^=n,i^=n,s=s<<31|s>>>1,n=16711935&(s>>>8^i),i^=n,s^=n<<8,n=858993459&(s>>>2^i),i^=n,s^=n<<2,n=65535&(i>>>16^s),s^=n,i^=n<<16,n=252645135&(i>>>4^s),s^=n,i^=n<<4,n=[i,s],r=0;r<8;r++)e[r]=(n[r>>>2]>>>8*(3-r%4))%256,e[r]<0&&(e[r]+=256);return e}encrypt(t){return this.enc8(t.slice(0,8)).concat(this.enc8(t.slice(8,16)))}}var Wr={Again:57349,AltLeft:56,AltRight:57400,ArrowDown:57424,ArrowLeft:57419,ArrowRight:57421,ArrowUp:57416,AudioVolumeDown:57390,AudioVolumeMute:57376,AudioVolumeUp:57392,Backquote:41,Backslash:43,Backspace:14,BracketLeft:26,BracketRight:27,BrowserBack:57450,BrowserFavorites:57446,BrowserForward:57449,BrowserHome:57394,BrowserRefresh:57447,BrowserSearch:57445,BrowserStop:57448,CapsLock:58,Comma:51,ContextMenu:57437,ControlLeft:29,ControlRight:57373,Convert:121,Copy:57464,Cut:57404,Delete:57427,Digit0:11,Digit1:2,Digit2:3,Digit3:4,Digit4:5,Digit5:6,Digit6:7,Digit7:8,Digit8:9,Digit9:10,Eject:57469,End:57423,Enter:28,Equal:13,Escape:1,F1:59,F10:68,F11:87,F12:88,F13:93,F14:94,F15:95,F16:85,F17:57347,F18:57463,F19:57348,F2:60,F20:90,F21:116,F22:57465,F23:109,F24:111,F3:61,F4:62,F5:63,F6:64,F7:65,F8:66,F9:67,Find:57409,Help:57461,Hiragana:119,Home:57415,Insert:57426,IntlBackslash:86,IntlRo:115,IntlYen:125,KanaMode:112,Katakana:120,KeyA:30,KeyB:48,KeyC:46,KeyD:32,KeyE:18,KeyF:33,KeyG:34,KeyH:35,KeyI:23,KeyJ:36,KeyK:37,KeyL:38,KeyM:50,KeyN:49,KeyO:24,KeyP:25,KeyQ:16,KeyR:19,KeyS:31,KeyT:20,KeyU:22,KeyV:47,KeyW:17,KeyX:45,KeyY:21,KeyZ:44,Lang1:114,Lang2:113,Lang3:120,Lang4:119,Lang5:118,LaunchApp1:57451,LaunchApp2:57377,LaunchMail:57452,MediaPlayPause:57378,MediaSelect:57453,MediaStop:57380,MediaTrackNext:57369,MediaTrackPrevious:57360,MetaLeft:57435,MetaRight:57436,Minus:12,NonConvert:123,NumLock:69,Numpad0:82,Numpad1:79,Numpad2:80,Numpad3:81,Numpad4:75,Numpad5:76,Numpad6:77,Numpad7:71,Numpad8:72,Numpad9:73,NumpadAdd:78,NumpadComma:126,NumpadDecimal:83,NumpadDivide:57397,NumpadEnter:57372,NumpadEqual:89,NumpadMultiply:55,NumpadParenLeft:57462,NumpadParenRight:57467,NumpadSubtract:74,Open:100,PageDown:57425,PageUp:57417,Paste:101,Pause:57414,Period:52,Power:57438,PrintScreen:84,Props:57350,Quote:40,ScrollLock:70,Semicolon:39,ShiftLeft:42,ShiftRight:54,Slash:53,Sleep:57439,Space:57,Suspend:57381,Tab:15,Undo:57351,WakeUp:57443};const Yr=0,qr=1,jr=2,Zr=5,Jr=7,$r=-260,ta=-32,ea=-223,sa=-224,ia=-239,na=-258,ra=-307,aa=-308,oa=-309,ha=-312,la=-313,ca=-256,da=1464686180,_a=3231835598;class ua{constructor(){this._lines=0}decodeRect(t,e,s,i,n,r,a){if(0===s||0===i)return!0;0===this._lines&&(this._lines=i);const o=s*(8==a?1:4);if(n.rQwait("RAW",o))return!1;const h=e+(i-this._lines),l=Math.min(this._lines,Math.floor(n.rQlen/o)),c=s*l;let d=n.rQ,_=n.rQi;if(8==a){const t=new Uint8Array(4*c);for(let e=0;e>0&3)/3,t[4*e+1]=255*(d[_+e]>>2&3)/3,t[4*e+2]=255*(d[_+e]>>4&3)/3,t[4*e+3]=255;d=t,_=0}for(let u=0;u0)}}class fa{decodeRect(t,e,s,i,n,r,a){if(n.rQwait("COPYRECT",4))return!1;let o=n.rQshift16(),h=n.rQshift16();return 0===s||0===i||r.copyImage(o,h,t,e,s,i),!0}}class pa{constructor(){this._subrects=0}decodeRect(t,e,s,i,n,r,a){if(0===this._subrects){if(n.rQwait("RRE",8))return!1;this._subrects=n.rQshift32();let a=n.rQshiftBytes(4);r.fillRect(t,e,s,i,a)}for(;this._subrects>0;){if(n.rQwait("RRE",12))return!1;let s=n.rQshiftBytes(4),i=n.rQshift16(),a=n.rQshift16(),o=n.rQshift16(),h=n.rQshift16();r.fillRect(t+i,e+a,o,h,s),this._subrects--}return!0}}class ga{constructor(){this._tiles=0,this._lastsubencoding=0,this._tileBuffer=new Uint8Array(1024)}decodeRect(t,e,s,i,n,a,o){for(0===this._tiles&&(this._tilesX=Math.ceil(s/16),this._tilesY=Math.ceil(i/16),this._totalTiles=this._tilesX*this._tilesY,this._tiles=this._totalTiles);this._tiles>0;){let o=1;if(n.rQwait("HEXTILE",o))return!1;let h=n.rQ,l=n.rQi,c=h[l];if(c>30)throw new Error("Illegal hextile subencoding (subencoding: "+c+")");const d=this._totalTiles-this._tiles,_=t+16*(d%this._tilesX),u=e+16*Math.floor(d/this._tilesX),f=Math.min(16,t+s-_),p=Math.min(16,e+i-u);if(1&c)o+=f*p*4;else if(2&c&&(o+=4),4&c&&(o+=4),8&c){if(o++,n.rQwait("HEXTILE",o))return!1;let t=h[l+o-1];o+=16&c?6*t:2*t}if(n.rQwait("HEXTILE",o))return!1;if(l++,0===c)1&this._lastsubencoding?r(" Ignoring blank after RAW"):a.fillRect(_,u,f,p,this._background);else if(1&c){let t=f*p;for(let e=0;e>4,i=15&e,n=h[l];l++;const r=1+(n>>4),a=1+(15&n);this._subTile(s,i,r,a,t)}}this._finishTile(a)}n.rQi=l,this._lastsubencoding=c,this._tiles--}return!0}_startTile(t,e,s,i,n){this._tileX=t,this._tileY=e,this._tileW=s,this._tileH=i;const r=n[0],a=n[1],o=n[2],h=this._tileBuffer;for(let l=0;l>t&1&&(this._zlibs[t].reset(),a("Reset zlib stream "+t));this._ctl=this._ctl>>4}let h;if(8===this._ctl)h=this._fillRect(t,e,s,i,n,r,o);else if(9===this._ctl)h=this._jpegRect(t,e,s,i,n,r,o);else if(10===this._ctl)h=this._pngRect(t,e,s,i,n,r,o);else{if(0!=(8&this._ctl))throw new Error("Illegal tight compression received (ctl: "+this._ctl+")");h=this._basicRect(this._ctl,t,e,s,i,n,r,o)}return h&&(this._ctl=null),h}_fillRect(t,e,s,i,n,r,a){if(n.rQwait("TIGHT",3))return!1;const o=n.rQi,h=n.rQ;return r.fillRect(t,e,s,i,[h[o],h[o+1],h[o+2]],!1),n.rQskipBytes(3),!0}_jpegRect(t,e,s,i,n,r,a){let o=this._readData(n);return null!==o&&(r.imageRect(t,e,s,i,"image/jpeg",o),!0)}_pngRect(t,e,s,i,n,r,a){throw new Error("PNG received in standard Tight rect")}_basicRect(t,e,s,i,n,r,a,o){if(null===this._filter)if(4&t){if(r.rQwait("TIGHT",1))return!1;this._filter=r.rQshift8()}else this._filter=0;let h,l=3&t;switch(this._filter){case 0:h=this._copyFilter(l,e,s,i,n,r,a,o);break;case 1:h=this._paletteFilter(l,e,s,i,n,r,a,o);break;case 2:h=this._gradientFilter(l,e,s,i,n,r,a,o);break;default:throw new Error("Illegal tight filter received (ctl: "+this._filter+")")}return h&&(this._filter=null),h}_copyFilter(t,e,s,i,n,r,a,o){const h=i*n*3;let l;if(0===h)return!0;if(h<12){if(r.rQwait("TIGHT",h))return!1;l=r.rQshiftBytes(h)}else{if(l=this._readData(r),null===l)return!1;this._zlibs[t].setInput(l),l=this._zlibs[t].inflate(h),this._zlibs[t].setInput(null)}let c=new Uint8Array(i*n*4);for(let d=0,_=0;d=0;a--)t=4*(c*s+8*i+7-a),e=3*(n[c*h+i]>>a&1),o[t]=r[e],o[t+1]=r[e+1],o[t+2]=r[e+2],o[t+3]=255;for(let a=7;a>=8-s%8;a--)t=4*(c*s+8*i+7-a),e=3*(n[c*h+i]>>a&1),o[t]=r[e],o[t+1]=r[e+1],o[t+2]=r[e+2],o[t+3]=255}a.blitImage(t,e,s,i,o,0,!1)}_paletteRect(t,e,s,i,n,r,a){const o=this._getScratchBuffer(s*i*4),h=s*i*4;for(let l=0,c=0;le.call(this,t))),!t.defaultPrevented)}}{constructor(t,e,s){if(!t)throw new Error("Must specify target");if(!e)throw new Error("Must specify URL, WebSocket or RTCDataChannel");super(),this._target=t,"string"===typeof e?this._url=e:(this._url=null,this._rawChannel=e),s=s||{},this._rfbCredentials=s.credentials||{},this._shared=!("shared"in s)||!!s.shared,this._repeaterID=s.repeaterID||"",this._wsProtocols=s.wsProtocols||[],this._rfbConnectionState="",this._rfbInitState="",this._rfbAuthScheme=-1,this._rfbCleanDisconnect=!0,this._rfbVersion=0,this._rfbMaxVersion=3.8,this._rfbTightVNC=!1,this._rfbVeNCryptState=0,this._rfbXvpVer=0,this._fbWidth=0,this._fbHeight=0,this._fbName="",this._capabilities={power:!1},this._supportsFence=!1,this._supportsContinuousUpdates=!1,this._enabledContinuousUpdates=!1,this._supportsSetDesktopSize=!1,this._screenID=0,this._screenFlags=0,this._qemuExtKeyEventSupported=!1,this._clipboardText=null,this._clipboardServerCapabilitiesActions={},this._clipboardServerCapabilitiesFormats={},this._sock=null,this._display=null,this._flushing=!1,this._keyboard=null,this._gestures=null,this._resizeObserver=null,this._disconnTimer=null,this._resizeTimeout=null,this._mouseMoveTimer=null,this._decoders={},this._FBU={rects:0,x:0,y:0,width:0,height:0,encoding:null},this._mousePos={},this._mouseButtonMask=0,this._mouseLastMoveTime=0,this._viewportDragging=!1,this._viewportDragPos={},this._viewportHasMoved=!1,this._accumulatedWheelDeltaX=0,this._accumulatedWheelDeltaY=0,this._gestureLastTapTime=null,this._gestureFirstDoubleTapEv=null,this._gestureLastMagnitudeX=0,this._gestureLastMagnitudeY=0,this._eventHandlers={focusCanvas:this._focusCanvas.bind(this),handleResize:this._handleResize.bind(this),handleMouse:this._handleMouse.bind(this),handleWheel:this._handleWheel.bind(this),handleGesture:this._handleGesture.bind(this)},r(">> RFB.constructor"),this._screen=document.createElement("div"),this._screen.style.display="flex",this._screen.style.width="100%",this._screen.style.height="100%",this._screen.style.overflow="auto",this._screen.style.background="rgb(40, 40, 40)",this._canvas=document.createElement("canvas"),this._canvas.style.margin="auto",this._canvas.style.outline="none",this._canvas.width=0,this._canvas.height=0,this._canvas.tabIndex=-1,this._screen.appendChild(this._canvas),this._cursor=new kr,this._cursorImage=Sa.cursors.none,this._decoders[Yr]=new ua,this._decoders[qr]=new fa,this._decoders[jr]=new pa,this._decoders[Zr]=new ga,this._decoders[Jr]=new ma,this._decoders[$r]=new wa;try{this._display=new E(this._canvas)}catch(Qa){throw h("Display exception: "+Qa),Qa}this._display.onflush=this._onFlush.bind(this),this._keyboard=new gr(this._canvas),this._keyboard.onkeyevent=this._handleKeyEvent.bind(this),this._gestures=new br,this._sock=new Ar,this._sock.on("open",this._socketOpen.bind(this)),this._sock.on("close",this._socketClose.bind(this)),this._sock.on("message",this._handleMessage.bind(this)),this._sock.on("error",this._socketError.bind(this)),this._resizeObserver=new ResizeObserver(this._eventHandlers.handleResize),this._updateConnectionState("connecting"),r("<< RFB.constructor"),this.dragViewport=!1,this.focusOnClick=!0,this._viewOnly=!1,this._clipViewport=!1,this._scaleViewport=!1,this._resizeSession=!1,this._showDotCursor=!1,void 0!==s.showDotCursor&&(o("Specifying showDotCursor as a RFB constructor argument is deprecated"),this._showDotCursor=s.showDotCursor),this._qualityLevel=6,this._compressionLevel=2}get viewOnly(){return this._viewOnly}set viewOnly(t){this._viewOnly=t,"connecting"!==this._rfbConnectionState&&"connected"!==this._rfbConnectionState||(t?this._keyboard.ungrab():this._keyboard.grab())}get capabilities(){return this._capabilities}get touchButton(){return 0}set touchButton(t){o("Using old API!")}get clipViewport(){return this._clipViewport}set clipViewport(t){this._clipViewport=t,this._updateClip()}get scaleViewport(){return this._scaleViewport}set scaleViewport(t){this._scaleViewport=t,t&&this._clipViewport&&this._updateClip(),this._updateScale(),!t&&this._clipViewport&&this._updateClip()}get resizeSession(){return this._resizeSession}set resizeSession(t){this._resizeSession=t,t&&this._requestRemoteResize()}get showDotCursor(){return this._showDotCursor}set showDotCursor(t){this._showDotCursor=t,this._refreshCursor()}get background(){return this._screen.style.background}set background(t){this._screen.style.background=t}get qualityLevel(){return this._qualityLevel}set qualityLevel(t){!Number.isInteger(t)||t<0||t>9?h("qualityLevel must be an integer between 0 and 9"):this._qualityLevel!==t&&(this._qualityLevel=t,"connected"===this._rfbConnectionState&&this._sendEncodings())}get compressionLevel(){return this._compressionLevel}set compressionLevel(t){!Number.isInteger(t)||t<0||t>9?h("compressionLevel must be an integer between 0 and 9"):this._compressionLevel!==t&&(this._compressionLevel=t,"connected"===this._rfbConnectionState&&this._sendEncodings())}disconnect(){this._updateConnectionState("disconnecting"),this._sock.off("error"),this._sock.off("message"),this._sock.off("open")}sendCredentials(t){this._rfbCredentials=t,setTimeout(this._initMsg.bind(this),0)}sendCtrlAltDel(){"connected"!==this._rfbConnectionState||this._viewOnly||(a("Sending Ctrl-Alt-Del"),this.sendKey(wi,"ControlLeft",!0),this.sendKey(Ci,"AltLeft",!0),this.sendKey(ke,"Delete",!0),this.sendKey(ke,"Delete",!1),this.sendKey(Ci,"AltLeft",!1),this.sendKey(wi,"ControlLeft",!1))}machineShutdown(){this._xvpOp(1,2)}machineReboot(){this._xvpOp(1,3)}machineReset(){this._xvpOp(1,4)}sendKey(t,e,s){if("connected"!==this._rfbConnectionState||this._viewOnly)return;if(void 0===s)return this.sendKey(t,e,!0),void this.sendKey(t,e,!1);const i=Wr[e];if(this._qemuExtKeyEventSupported&&i)a("Sending key ("+(s?"down":"up")+"): keysym "+(t=t||0)+", scancode "+i),Sa.messages.QEMUExtendedKeyEvent(this._sock,t,s,i);else{if(!t)return;a("Sending keysym ("+(s?"down":"up")+"): "+t),Sa.messages.keyEvent(this._sock,t,s?1:0)}}focus(){this._canvas.focus()}blur(){this._canvas.blur()}clipboardPasteFrom(t){if("connected"===this._rfbConnectionState&&!this._viewOnly)if(this._clipboardServerCapabilitiesFormats[1]&&this._clipboardServerCapabilitiesActions[134217728])this._clipboardText=t,Sa.messages.extendedClipboardNotify(this._sock,[1]);else{let e=new Uint8Array(t.length);for(let s=0;s> RFB.connect"),this._url)a(`connecting to ${this._url}`),this._sock.open(this._url,this._wsProtocols);else{if(a(`attaching ${this._rawChannel} to Websock`),this._sock.attach(this._rawChannel),"closed"===this._sock.readyState)throw Error("Cannot use already closed WebSocket/RTCDataChannel");"open"===this._sock.readyState&&this._socketOpen()}this._target.appendChild(this._screen),this._gestures.attach(this._canvas),this._cursor.attach(this._canvas),this._refreshCursor(),this._resizeObserver.observe(this._screen),this._canvas.addEventListener("mousedown",this._eventHandlers.focusCanvas),this._canvas.addEventListener("touchstart",this._eventHandlers.focusCanvas),this._canvas.addEventListener("mousedown",this._eventHandlers.handleMouse),this._canvas.addEventListener("mouseup",this._eventHandlers.handleMouse),this._canvas.addEventListener("mousemove",this._eventHandlers.handleMouse),this._canvas.addEventListener("click",this._eventHandlers.handleMouse),this._canvas.addEventListener("contextmenu",this._eventHandlers.handleMouse),this._canvas.addEventListener("wheel",this._eventHandlers.handleWheel),this._canvas.addEventListener("gesturestart",this._eventHandlers.handleGesture),this._canvas.addEventListener("gesturemove",this._eventHandlers.handleGesture),this._canvas.addEventListener("gestureend",this._eventHandlers.handleGesture),r("<< RFB.connect")}_disconnect(){r(">> RFB.disconnect"),this._cursor.detach(),this._canvas.removeEventListener("gesturestart",this._eventHandlers.handleGesture),this._canvas.removeEventListener("gesturemove",this._eventHandlers.handleGesture),this._canvas.removeEventListener("gestureend",this._eventHandlers.handleGesture),this._canvas.removeEventListener("wheel",this._eventHandlers.handleWheel),this._canvas.removeEventListener("mousedown",this._eventHandlers.handleMouse),this._canvas.removeEventListener("mouseup",this._eventHandlers.handleMouse),this._canvas.removeEventListener("mousemove",this._eventHandlers.handleMouse),this._canvas.removeEventListener("click",this._eventHandlers.handleMouse),this._canvas.removeEventListener("contextmenu",this._eventHandlers.handleMouse),this._canvas.removeEventListener("mousedown",this._eventHandlers.focusCanvas),this._canvas.removeEventListener("touchstart",this._eventHandlers.focusCanvas),this._resizeObserver.disconnect(),this._keyboard.ungrab(),this._gestures.detach(),this._sock.close();try{this._target.removeChild(this._screen)}catch(Ur){if("NotFoundError"!==Ur.name)throw Ur}clearTimeout(this._resizeTimeout),clearTimeout(this._mouseMoveTimer),r("<< RFB.disconnect")}_socketOpen(){"connecting"===this._rfbConnectionState&&""===this._rfbInitState?(this._rfbInitState="ProtocolVersion",r("Starting VNC handshake")):this._fail("Unexpected server connection while "+this._rfbConnectionState)}_socketClose(t){r("WebSocket on-close event");let e="";switch(t.code&&(e="(code: "+t.code,t.reason&&(e+=", reason: "+t.reason),e+=")"),this._rfbConnectionState){case"connecting":this._fail("Connection closed "+e);break;case"connected":this._updateConnectionState("disconnecting"),this._updateConnectionState("disconnected");break;case"disconnecting":this._updateConnectionState("disconnected");break;case"disconnected":this._fail("Unexpected server disconnect when already disconnected "+e);break;default:this._fail("Unexpected server disconnect before connecting "+e)}this._sock.off("close"),this._rawChannel=null}_socketError(t){o("WebSocket on-error event")}_focusCanvas(t){this.focusOnClick&&this.focus()}_setDesktopName(t){this._fbName=t,this.dispatchEvent(new CustomEvent("desktopname",{detail:{name:this._fbName}}))}_handleResize(){window.requestAnimationFrame((()=>{this._updateClip(),this._updateScale()})),this._resizeSession&&(clearTimeout(this._resizeTimeout),this._resizeTimeout=setTimeout(this._requestRemoteResize.bind(this),500))}_updateClip(){const t=this._display.clipViewport;let e=this._clipViewport;if(this._scaleViewport&&(e=!1),t!==e&&(this._display.clipViewport=e),e){const t=this._screenSize();this._display.viewportChangeSize(t.w,t.h),this._fixScrollbars()}}_updateScale(){if(this._scaleViewport){const t=this._screenSize();this._display.autoscale(t.w,t.h)}else this._display.scale=1;this._fixScrollbars()}_requestRemoteResize(){if(clearTimeout(this._resizeTimeout),this._resizeTimeout=null,!this._resizeSession||this._viewOnly||!this._supportsSetDesktopSize)return;const t=this._screenSize();Sa.messages.setDesktopSize(this._sock,Math.floor(t.w),Math.floor(t.h),this._screenID,this._screenFlags),r("Requested new desktop size: "+t.w+"x"+t.h)}_screenSize(){let t=this._screen.getBoundingClientRect();return{w:t.width,h:t.height}}_fixScrollbars(){const t=this._screen.style.overflow;this._screen.style.overflow="hidden",this._screen.getBoundingClientRect(),this._screen.style.overflow=t}_updateConnectionState(t){const e=this._rfbConnectionState;if(t!==e)if("disconnected"!==e){switch(t){case"connected":if("connecting"!==e)return void h("Bad transition to connected state, previous connection state: "+e);break;case"disconnected":if("disconnecting"!==e)return void h("Bad transition to disconnected state, previous connection state: "+e);break;case"connecting":if(""!==e)return void h("Bad transition to connecting state, previous connection state: "+e);break;case"disconnecting":if("connected"!==e&&"connecting"!==e)return void h("Bad transition to disconnecting state, previous connection state: "+e);break;default:return void h("Unknown connection state: "+t)}switch(this._rfbConnectionState=t,r("New state '"+t+"', was '"+e+"'."),this._disconnTimer&&"disconnecting"!==t&&(r("Clearing disconnect timer"),clearTimeout(this._disconnTimer),this._disconnTimer=null,this._sock.off("close")),t){case"connecting":this._connect();break;case"connected":this.dispatchEvent(new CustomEvent("connect",{detail:{}}));break;case"disconnecting":this._disconnect(),this._disconnTimer=setTimeout((()=>{h("Disconnection timed out."),this._updateConnectionState("disconnected")}),3e3);break;case"disconnected":this.dispatchEvent(new CustomEvent("disconnect",{detail:{clean:this._rfbCleanDisconnect}}))}}else h("Tried changing state of a disconnected RFB object");else r("Already in state '"+t+"', ignoring")}_fail(t){switch(this._rfbConnectionState){case"disconnecting":h("Failed when disconnecting: "+t);break;case"connected":h("Failed while connected: "+t);break;case"connecting":h("Failed when connecting: "+t);break;default:h("RFB failure: "+t)}return this._rfbCleanDisconnect=!1,this._updateConnectionState("disconnecting"),this._updateConnectionState("disconnected"),!1}_setCapability(t,e){this._capabilities[t]=e,this.dispatchEvent(new CustomEvent("capabilities",{detail:{capabilities:this._capabilities}}))}_handleMessage(){if(0!==this._sock.rQlen)switch(this._rfbConnectionState){case"disconnected":h("Got data while disconnected");break;case"connected":for(;!this._flushing&&this._normalMsg()&&0!==this._sock.rQlen;);break;default:this._initMsg()}else o("handleMessage called on an empty receive queue")}_handleKeyEvent(t,e,s){this.sendKey(t,e,s)}_handleMouse(t){if("click"===t.type&&t.target!==this._canvas)return;if(t.stopPropagation(),t.preventDefault(),"click"===t.type||"contextmenu"===t.type)return;let e=b(t.clientX,t.clientY,this._canvas);switch(t.type){case"mousedown":!function(t){if(t.setCapture)t.setCapture(),document.captureElement=t;else{Q();let e=document.getElementById("noVNC_mouse_capture_elem");null===e&&(e=document.createElement("div"),e.id="noVNC_mouse_capture_elem",e.style.position="fixed",e.style.top="0px",e.style.left="0px",e.style.width="100%",e.style.height="100%",e.style.zIndex=1e4,e.style.display="none",document.body.appendChild(e),e.addEventListener("contextmenu",C),e.addEventListener("mousemove",C),e.addEventListener("mouseup",C)),document.captureElement=t,S.observe(t,{attributes:!0}),x(),e.style.display="",window.addEventListener("mousemove",C),window.addEventListener("mouseup",C)}}(this._canvas),this._handleMouseButton(e.x,e.y,!0,1<_||Math.abs(i)>_)&&(this._viewportHasMoved=!0,this._viewportDragPos={x:t,y:e},this._display.viewportChangePos(s,i))}else if(this._mousePos={x:t,y:e},null==this._mouseMoveTimer){const s=Date.now()-this._mouseLastMoveTime;s>17?(this._sendMouse(t,e,this._mouseButtonMask),this._mouseLastMoveTime=Date.now()):this._mouseMoveTimer=setTimeout((()=>{this._handleDelayedMouseMove()}),17-s)}}_handleDelayedMouseMove(){this._mouseMoveTimer=null,this._sendMouse(this._mousePos.x,this._mousePos.y,this._mouseButtonMask),this._mouseLastMoveTime=Date.now()}_sendMouse(t,e,s){"connected"===this._rfbConnectionState&&(this._viewOnly||Sa.messages.pointerEvent(this._sock,this._display.absX(t),this._display.absY(e),s))}_handleWheel(t){if("connected"!==this._rfbConnectionState)return;if(this._viewOnly)return;t.stopPropagation(),t.preventDefault();let e=b(t.clientX,t.clientY,this._canvas),s=t.deltaX,i=t.deltaY;0!==t.deltaMode&&(s*=19,i*=19),this._accumulatedWheelDeltaX+=s,this._accumulatedWheelDeltaY+=i,Math.abs(this._accumulatedWheelDeltaX)>=50&&(this._accumulatedWheelDeltaX<0?(this._handleMouseButton(e.x,e.y,!0,32),this._handleMouseButton(e.x,e.y,!1,32)):this._accumulatedWheelDeltaX>0&&(this._handleMouseButton(e.x,e.y,!0,64),this._handleMouseButton(e.x,e.y,!1,64)),this._accumulatedWheelDeltaX=0),Math.abs(this._accumulatedWheelDeltaY)>=50&&(this._accumulatedWheelDeltaY<0?(this._handleMouseButton(e.x,e.y,!0,8),this._handleMouseButton(e.x,e.y,!1,8)):this._accumulatedWheelDeltaY>0&&(this._handleMouseButton(e.x,e.y,!0,16),this._handleMouseButton(e.x,e.y,!1,16)),this._accumulatedWheelDeltaY=0)}_fakeMouseMove(t,e,s){this._handleMouseMove(e,s),this._cursor.move(t.detail.clientX,t.detail.clientY)}_handleTapEvent(t,e){let s=b(t.detail.clientX,t.detail.clientY,this._canvas);if(null!==this._gestureLastTapTime&&Date.now()-this._gestureLastTapTime<1e3&&this._gestureFirstDoubleTapEv.detail.type===t.detail.type){let e=this._gestureFirstDoubleTapEv.detail.clientX-t.detail.clientX,i=this._gestureFirstDoubleTapEv.detail.clientY-t.detail.clientY;Math.hypot(e,i)<50?s=b(this._gestureFirstDoubleTapEv.detail.clientX,this._gestureFirstDoubleTapEv.detail.clientY,this._canvas):this._gestureFirstDoubleTapEv=t}else this._gestureFirstDoubleTapEv=t;this._gestureLastTapTime=Date.now(),this._fakeMouseMove(this._gestureFirstDoubleTapEv,s.x,s.y),this._handleMouseButton(s.x,s.y,!0,e),this._handleMouseButton(s.x,s.y,!1,e)}_handleGesture(t){let e,s=b(t.detail.clientX,t.detail.clientY,this._canvas);switch(t.type){case"gesturestart":switch(t.detail.type){case"onetap":this._handleTapEvent(t,1);break;case"twotap":this._handleTapEvent(t,4);break;case"threetap":this._handleTapEvent(t,2);break;case"drag":this._fakeMouseMove(t,s.x,s.y),this._handleMouseButton(s.x,s.y,!0,1);break;case"longpress":this._fakeMouseMove(t,s.x,s.y),this._handleMouseButton(s.x,s.y,!0,4);break;case"twodrag":this._gestureLastMagnitudeX=t.detail.magnitudeX,this._gestureLastMagnitudeY=t.detail.magnitudeY,this._fakeMouseMove(t,s.x,s.y);break;case"pinch":this._gestureLastMagnitudeX=Math.hypot(t.detail.magnitudeX,t.detail.magnitudeY),this._fakeMouseMove(t,s.x,s.y)}break;case"gesturemove":switch(t.detail.type){case"onetap":case"twotap":case"threetap":break;case"drag":case"longpress":this._fakeMouseMove(t,s.x,s.y);break;case"twodrag":for(this._fakeMouseMove(t,s.x,s.y);t.detail.magnitudeY-this._gestureLastMagnitudeY>ba;)this._handleMouseButton(s.x,s.y,!0,8),this._handleMouseButton(s.x,s.y,!1,8),this._gestureLastMagnitudeY+=ba;for(;t.detail.magnitudeY-this._gestureLastMagnitudeY<-50;)this._handleMouseButton(s.x,s.y,!0,16),this._handleMouseButton(s.x,s.y,!1,16),this._gestureLastMagnitudeY-=ba;for(;t.detail.magnitudeX-this._gestureLastMagnitudeX>ba;)this._handleMouseButton(s.x,s.y,!0,32),this._handleMouseButton(s.x,s.y,!1,32),this._gestureLastMagnitudeX+=ba;for(;t.detail.magnitudeX-this._gestureLastMagnitudeX<-50;)this._handleMouseButton(s.x,s.y,!0,64),this._handleMouseButton(s.x,s.y,!1,64),this._gestureLastMagnitudeX-=ba;break;case"pinch":if(this._fakeMouseMove(t,s.x,s.y),e=Math.hypot(t.detail.magnitudeX,t.detail.magnitudeY),Math.abs(e-this._gestureLastMagnitudeX)>75){for(this._handleKeyEvent(wi,"ControlLeft",!0);e-this._gestureLastMagnitudeX>75;)this._handleMouseButton(s.x,s.y,!0,8),this._handleMouseButton(s.x,s.y,!1,8),this._gestureLastMagnitudeX+=75;for(;e-this._gestureLastMagnitudeX<-75;)this._handleMouseButton(s.x,s.y,!0,16),this._handleMouseButton(s.x,s.y,!1,16),this._gestureLastMagnitudeX-=75}this._handleKeyEvent(wi,"ControlLeft",!1)}break;case"gestureend":switch(t.detail.type){case"onetap":case"twotap":case"threetap":case"pinch":case"twodrag":break;case"drag":this._fakeMouseMove(t,s.x,s.y),this._handleMouseButton(s.x,s.y,!1,1);break;case"longpress":this._fakeMouseMove(t,s.x,s.y),this._handleMouseButton(s.x,s.y,!1,4)}}}_negotiateProtocolVersion(){if(this._sock.rQwait("version",12))return!1;const t=this._sock.rQshiftStr(12).substr(4,7);a("Server ProtocolVersion: "+t);let e=0;switch(t){case"000.000":e=1;break;case"003.003":case"003.006":case"003.889":this._rfbVersion=3.3;break;case"003.007":this._rfbVersion=3.7;break;case"003.008":case"004.000":case"004.001":case"005.000":this._rfbVersion=3.8;break;default:return this._fail("Invalid server version "+t)}if(e){let t="ID:"+this._repeaterID;for(;t.length<250;)t+="\0";return this._sock.sendString(t),!0}this._rfbVersion>this._rfbMaxVersion&&(this._rfbVersion=this._rfbMaxVersion);const s="00"+parseInt(this._rfbVersion,10)+".00"+10*this._rfbVersion%10;this._sock.sendString("RFB "+s+"\n"),r("Sent ProtocolVersion: "+s),this._rfbInitState="Security"}_negotiateSecurity(){if(this._rfbVersion>=3.7){const t=this._sock.rQshift8();if(this._sock.rQwait("security type",t,1))return!1;if(0===t)return this._rfbInitState="SecurityReason",this._securityContext="no security types",this._securityStatus=1,this._initMsg();const e=this._sock.rQshiftBytes(t);if(r("Server security types: "+e),e.includes(1))this._rfbAuthScheme=1;else if(e.includes(22))this._rfbAuthScheme=22;else if(e.includes(16))this._rfbAuthScheme=16;else if(e.includes(2))this._rfbAuthScheme=2;else{if(!e.includes(19))return this._fail("Unsupported security types (types: "+e+")");this._rfbAuthScheme=19}this._sock.send([this._rfbAuthScheme])}else{if(this._sock.rQwait("security scheme",4))return!1;if(this._rfbAuthScheme=this._sock.rQshift32(),0==this._rfbAuthScheme)return this._rfbInitState="SecurityReason",this._securityContext="authentication scheme",this._securityStatus=1,this._initMsg()}return this._rfbInitState="Authentication",r("Authenticating using scheme: "+this._rfbAuthScheme),this._initMsg()}_handleSecurityReason(){if(this._sock.rQwait("reason length",4))return!1;const t=this._sock.rQshift32();let e="";if(t>0){if(this._sock.rQwait("reason",t,4))return!1;e=this._sock.rQshiftStr(t)}return""!==e?(this.dispatchEvent(new CustomEvent("securityfailure",{detail:{status:this._securityStatus,reason:e}})),this._fail("Security negotiation failed on "+this._securityContext+" (reason: "+e+")")):(this.dispatchEvent(new CustomEvent("securityfailure",{detail:{status:this._securityStatus}})),this._fail("Security negotiation failed on "+this._securityContext))}_negotiateXvpAuth(){if(void 0===this._rfbCredentials.username||void 0===this._rfbCredentials.password||void 0===this._rfbCredentials.target)return this.dispatchEvent(new CustomEvent("credentialsrequired",{detail:{types:["username","password","target"]}})),!1;const t=String.fromCharCode(this._rfbCredentials.username.length)+String.fromCharCode(this._rfbCredentials.target.length)+this._rfbCredentials.username+this._rfbCredentials.target;return this._sock.sendString(t),this._rfbAuthScheme=2,this._negotiateAuthentication()}_negotiateVeNCryptAuth(){if(0==this._rfbVeNCryptState){if(this._sock.rQwait("vencrypt version",2))return!1;const t=this._sock.rQshift8(),e=this._sock.rQshift8();if(0!=t||2!=e)return this._fail("Unsupported VeNCrypt version "+t+"."+e);this._sock.send([0,2]),this._rfbVeNCryptState=1}if(1==this._rfbVeNCryptState){if(this._sock.rQwait("vencrypt ack",1))return!1;const t=this._sock.rQshift8();if(0!=t)return this._fail("VeNCrypt failure "+t);this._rfbVeNCryptState=2}if(2==this._rfbVeNCryptState){if(this._sock.rQwait("vencrypt subtypes length",1))return!1;const t=this._sock.rQshift8();if(t<1)return this._fail("VeNCrypt subtypes empty");this._rfbVeNCryptSubtypesLength=t,this._rfbVeNCryptState=3}if(3==this._rfbVeNCryptState){if(this._sock.rQwait("vencrypt subtypes",4*this._rfbVeNCryptSubtypesLength))return!1;const t=[];for(let e=0;e>24&255,t.length>>16&255,t.length>>8&255,255&t.length]),this._sock.send([e.length>>24&255,e.length>>16&255,e.length>>8&255,255&e.length]),this._sock.sendString(t),this._sock.sendString(e),this._rfbInitState="SecurityResult",!0}}_negotiateStdVNCAuth(){if(this._sock.rQwait("auth challenge",16))return!1;if(void 0===this._rfbCredentials.password)return this.dispatchEvent(new CustomEvent("credentialsrequired",{detail:{types:["password"]}})),!1;const t=Array.prototype.slice.call(this._sock.rQshiftBytes(16)),e=Sa.genDES(this._rfbCredentials.password,t);return this._sock.send(e),this._rfbInitState="SecurityResult",!0}_negotiateTightUnixAuth(){return void 0===this._rfbCredentials.username||void 0===this._rfbCredentials.password?(this.dispatchEvent(new CustomEvent("credentialsrequired",{detail:{types:["username","password"]}})),!1):(this._sock.send([0,0,0,this._rfbCredentials.username.length]),this._sock.send([0,0,0,this._rfbCredentials.password.length]),this._sock.sendString(this._rfbCredentials.username),this._sock.sendString(this._rfbCredentials.password),this._rfbInitState="SecurityResult",!0)}_negotiateTightTunnels(t){const e={vendor:"TGHT",signature:"NOTUNNEL"},s={};for(let i=0;i0&&this._sock.rQwait("tunnel capabilities",16*t,4))return!1;if(this._rfbTightVNC=!0,t>0)return this._negotiateTightTunnels(t),!1}if(this._sock.rQwait("sub auth count",4))return!1;const t=this._sock.rQshift32();if(0===t)return this._rfbInitState="SecurityResult",!0;if(this._sock.rQwait("sub auth capabilities",16*t,4))return!1;const e={STDVNOAUTH__:1,STDVVNCAUTH_:2,TGHTULGNAUTH:129},s=[];for(let i=0;i=3.8?(this._rfbInitState="SecurityResult",!0):(this._rfbInitState="ClientInitialisation",this._initMsg());case 22:return this._negotiateXvpAuth();case 2:return this._negotiateStdVNCAuth();case 16:return this._negotiateTightAuth();case 19:return this._negotiateVeNCryptAuth();case 129:return this._negotiateTightUnixAuth();default:return this._fail("Unsupported auth scheme (scheme: "+this._rfbAuthScheme+")")}}_handleSecurityResult(){if(this._sock.rQwait("VNC auth response ",4))return!1;const t=this._sock.rQshift32();return 0===t?(this._rfbInitState="ClientInitialisation",r("Authentication OK"),this._initMsg()):this._rfbVersion>=3.8?(this._rfbInitState="SecurityReason",this._securityContext="security result",this._securityStatus=t,this._initMsg()):(this.dispatchEvent(new CustomEvent("securityfailure",{detail:{status:t}})),this._fail("Security handshake failed"))}_negotiateServerInit(){if(this._sock.rQwait("server initialization",24))return!1;const t=this._sock.rQshift16(),e=this._sock.rQshift16(),s=this._sock.rQshift8(),i=this._sock.rQshift8(),n=this._sock.rQshift8(),r=this._sock.rQshift8(),h=this._sock.rQshift16(),c=this._sock.rQshift16(),d=this._sock.rQshift16(),_=this._sock.rQshift8(),u=this._sock.rQshift8(),f=this._sock.rQshift8();this._sock.rQskipBytes(3);const p=this._sock.rQshift32();if(this._sock.rQwait("server init name",p,24))return!1;let g=this._sock.rQshiftStr(p);if(g=l(g,!0),this._rfbTightVNC){if(this._sock.rQwait("TightVNC extended server init header",8,24+p))return!1;const t=this._sock.rQshift16(),e=this._sock.rQshift16(),s=this._sock.rQshift16();this._sock.rQskipBytes(2);const i=16*(t+e+s);if(this._sock.rQwait("TightVNC extended server init header",i,32+p))return!1;this._sock.rQskipBytes(16*t),this._sock.rQskipBytes(16*e),this._sock.rQskipBytes(16*s)}return a("Screen: "+t+"x"+e+", bpp: "+s+", depth: "+i+", bigEndian: "+n+", trueColor: "+r+", redMax: "+h+", greenMax: "+c+", blueMax: "+d+", redShift: "+_+", greenShift: "+u+", blueShift: "+f),this._setDesktopName(g),this._resize(t,e),this._viewOnly||this._keyboard.grab(),this._fbDepth=24,"Intel(r) AMT KVM"===this._fbName&&(o("Intel AMT KVM only supports 8/16 bit depths. Using low color mode."),this._fbDepth=8),Sa.messages.pixelFormat(this._sock,this._fbDepth,!0),this._sendEncodings(),Sa.messages.fbUpdateRequest(this._sock,!1,0,0,this._fbWidth,this._fbHeight),this._updateConnectionState("connected"),!0}_sendEncodings(){const t=[];t.push(qr),24==this._fbDepth&&(t.push(Jr),t.push($r),t.push(Zr),t.push(jr)),t.push(Yr),t.push(ta+this._qualityLevel),t.push(ca+this._compressionLevel),t.push(ea),t.push(sa),t.push(na),t.push(aa),t.push(oa),t.push(ha),t.push(la),t.push(ra),t.push(_a),24==this._fbDepth&&(t.push(da),t.push(ia)),Sa.messages.clientEncodings(this._sock,t)}_initMsg(){switch(this._rfbInitState){case"ProtocolVersion":return this._negotiateProtocolVersion();case"Security":return this._negotiateSecurity();case"Authentication":return this._negotiateAuthentication();case"SecurityResult":return this._handleSecurityResult();case"SecurityReason":return this._handleSecurityReason();case"ClientInitialisation":return this._sock.send([this._shared?1:0]),this._rfbInitState="ServerInitialisation",!0;case"ServerInitialisation":return this._negotiateServerInit();default:return this._fail("Unknown init state (state: "+this._rfbInitState+")")}}_handleSetColourMapMsg(){return r("SetColorMapEntries"),this._fail("Unexpected SetColorMapEntries message")}_handleServerCutText(){if(r("ServerCutText"),this._sock.rQwait("ServerCutText header",7,1))return!1;this._sock.rQskipBytes(3);let t=this._sock.rQshift32();if(t=i(t),this._sock.rQwait("ServerCutText content",Math.abs(t),8))return!1;if(t>=0){const e=this._sock.rQshiftStr(t);if(this._viewOnly)return!0;this.dispatchEvent(new CustomEvent("clipboard",{detail:{text:e}}))}else{t=Math.abs(t);const e=this._sock.rQshift32();let s=65535&e,i=4278190080&e;if(!!(i&va)){this._clipboardServerCapabilitiesFormats={},this._clipboardServerCapabilitiesActions={};for(let e=0;e<=15;e++){let t=1<0&&"\0"===n.charAt(n.length-1)&&(n=n.slice(0,-1)),n=n.replace("\r\n","\n"),this.dispatchEvent(new CustomEvent("clipboard",{detail:{text:n}}))}}}}return!0}_handleServerFenceMsg(){if(this._sock.rQwait("ServerFence header",8,1))return!1;this._sock.rQskipBytes(3);let t=this._sock.rQshift32(),e=this._sock.rQshift8();if(this._sock.rQwait("ServerFence payload",e,9))return!1;e>64&&(o("Bad payload length ("+e+") in fence response"),e=64);const s=this._sock.rQshiftStr(e);return this._supportsFence=!0,t&1<<31?(t&=3,Sa.messages.clientFence(this._sock,t,s),!0):this._fail("Unexpected fence response")}_handleXvpMsg(){if(this._sock.rQwait("XVP version and message",3,1))return!1;this._sock.rQskipBytes(1);const t=this._sock.rQshift8(),e=this._sock.rQshift8();switch(e){case 0:h("XVP Operation Failed");break;case 1:this._rfbXvpVer=t,a("XVP extensions enabled (version "+this._rfbXvpVer+")"),this._setCapability("power",!0);break;default:this._fail("Illegal server XVP message (msg: "+e+")")}return!0}_normalMsg(){let t,e,s;switch(t=this._FBU.rects>0?0:this._sock.rQshift8(),t){case 0:return s=this._framebufferUpdate(),s&&!this._enabledContinuousUpdates&&Sa.messages.fbUpdateRequest(this._sock,!0,0,0,this._fbWidth,this._fbHeight),s;case 1:return this._handleSetColourMapMsg();case 2:return r("Bell"),this.dispatchEvent(new CustomEvent("bell",{detail:{}})),!0;case 3:return this._handleServerCutText();case 150:return e=!this._supportsContinuousUpdates,this._supportsContinuousUpdates=!0,this._enabledContinuousUpdates=!1,e&&(this._enabledContinuousUpdates=!0,this._updateContinuousUpdates(),a("Enabling continuous updates.")),!0;case 248:return this._handleServerFenceMsg();case 250:return this._handleXvpMsg();default:return this._fail("Unexpected server message (type "+t+")"),r("sock.rQslice(0, 30): "+this._sock.rQslice(0,30)),!0}}_onFlush(){this._flushing=!1,this._sock.rQlen>0&&this._handleMessage()}_framebufferUpdate(){if(0===this._FBU.rects){if(this._sock.rQwait("FBU header",3,1))return!1;if(this._sock.rQskipBytes(1),this._FBU.rects=this._sock.rQshift16(),this._display.pending())return this._flushing=!0,this._display.flush(),!1}for(;this._FBU.rects>0;){if(null===this._FBU.encoding){if(this._sock.rQwait("rect header",12))return!1;const t=this._sock.rQshiftBytes(12);this._FBU.x=(t[0]<<8)+t[1],this._FBU.y=(t[2]<<8)+t[3],this._FBU.width=(t[4]<<8)+t[5],this._FBU.height=(t[6]<<8)+t[7],this._FBU.encoding=parseInt((t[8]<<24)+(t[9]<<16)+(t[10]<<8)+t[11],10)}if(!this._handleRect())return!1;this._FBU.rects--,this._FBU.encoding=null}return this._display.flip(),!0}_handleRect(){switch(this._FBU.encoding){case sa:return this._FBU.rects=1,!0;case da:return this._handleVMwareCursor();case ia:return this._handleCursor();case na:return this._qemuExtKeyEventSupported=!0,!0;case ra:return this._handleDesktopName();case ea:return this._resize(this._FBU.width,this._FBU.height),!0;case aa:return this._handleExtendedDesktopSize();default:return this._handleDataRect()}}_handleVMwareCursor(){const t=this._FBU.x,e=this._FBU.y,s=this._FBU.width,i=this._FBU.height;if(this._sock.rQwait("VMware cursor encoding",1))return!1;const n=this._sock.rQshift8();let r;this._sock.rQshift8();if(0==n){const t=-256;if(r=new Array(s*i*4),this._sock.rQwait("VMware cursor classic encoding",s*i*4*2,2))return!1;let e=new Array(s*i);for(let r=0;r>8&255,s=t>>16&255,i=t>>24&255;r[4*a]=e,r[4*a+1]=s,r[4*a+2]=i,r[4*a+3]=255}else(e[a]&t)==t?0==n[a]?(r[4*a]=0,r[4*a+1]=0,r[4*a+2]=0,r[4*a+3]=0):(n[a],r[4*a]=0,r[4*a+1]=0,r[4*a+2]=0,r[4*a+3]=255):(r[4*a]=0,r[4*a+1]=0,r[4*a+2]=0,r[4*a+3]=255)}else{if(1!=n)return o("The given cursor type is not supported: "+n+" given."),!1;if(this._sock.rQwait("VMware cursor alpha encoding",s*i*4,2))return!1;r=new Array(s*i*4);for(let t=0;t>24&255,r[4*t+1]=e>>16&255,r[4*t+2]=e>>8&255,r[4*t+3]=255&e}}return this._updateCursor(r,t,e,s,i),!0}_handleCursor(){const t=this._FBU.x,e=this._FBU.y,s=this._FBU.width,i=this._FBU.height,n=s*i*4,r=Math.ceil(s/8)*i;let a=n+r;if(this._sock.rQwait("cursor encoding",a))return!1;const o=this._sock.rQshiftBytes(n),h=this._sock.rQshiftBytes(r);let l=new Uint8Array(s*i*4),c=0;for(let d=0;dt.charCodeAt(0)));return new Gr(s).encrypt(e)}}Sa.messages={keyEvent(t,e,s){const i=t._sQ,n=t._sQlen;i[n]=4,i[n+1]=s,i[n+2]=0,i[n+3]=0,i[n+4]=e>>24,i[n+5]=e>>16,i[n+6]=e>>8,i[n+7]=e,t._sQlen+=8,t.flush()},QEMUExtendedKeyEvent(t,e,s,i){const n=t._sQ,r=t._sQlen;n[r]=255,n[r+1]=0,n[r+2]=s>>8,n[r+3]=s,n[r+4]=e>>24,n[r+5]=e>>16,n[r+6]=e>>8,n[r+7]=e;const a=function(t){const e=255&i;return 224===i>>8&&e<127?128|e:t}(i);n[r+8]=a>>24,n[r+9]=a>>16,n[r+10]=a>>8,n[r+11]=a,t._sQlen+=12,t.flush()},pointerEvent(t,e,s,i){const n=t._sQ,r=t._sQlen;n[r]=5,n[r+1]=i,n[r+2]=e>>8,n[r+3]=e,n[r+4]=s>>8,n[r+5]=s,t._sQlen+=6,t.flush()},_buildExtendedClipboardFlags(t,e){let s=new Uint8Array(4),i=0,n=0;for(let r=0;r>24,s[1]=0,s[2]=0,s[3]=i,s},extendedClipboardProvide(t,e,s){let i=new ue,n=[];for(let o=0;o>24&255,t.length>>16&255,t.length>>8&255,255&t.length);for(let e=0;eparseInt(t))),i.sort(((t,e)=>t-e)),n.set(Sa.messages._buildExtendedClipboardFlags(e,[]));let r=4;for(let a=0;a>24,n[r+1]=s[i[a]]>>16,n[r+2]=s[i[a]]>>8,n[r+3]=s[i[a]]>>0,r+=4,n[3]|=1<>>0:e.length,i[n+4]=r>>24,i[n+5]=r>>16,i[n+6]=r>>8,i[n+7]=r,t._sQlen+=8;let a=0,o=e.length;for(;o>0;){let s=Math.min(o,t._sQbufferSize-t._sQlen);for(let n=0;n>8,r[a+3]=e,r[a+4]=s>>8,r[a+5]=s,r[a+6]=1,r[a+7]=0,r[a+8]=i>>24,r[a+9]=i>>16,r[a+10]=i>>8,r[a+11]=i,r[a+12]=0,r[a+13]=0,r[a+14]=0,r[a+15]=0,r[a+16]=e>>8,r[a+17]=e,r[a+18]=s>>8,r[a+19]=s,r[a+20]=n>>24,r[a+21]=n>>16,r[a+22]=n>>8,r[a+23]=n,t._sQlen+=24,t.flush()},clientFence(t,e,s){const i=t._sQ,n=t._sQlen;i[n]=248,i[n+1]=0,i[n+2]=0,i[n+3]=0,i[n+4]=e>>24,i[n+5]=e>>16,i[n+6]=e>>8,i[n+7]=e;const r=s.length;i[n+8]=r;for(let a=0;a>8,a[o+3]=s,a[o+4]=i>>8,a[o+5]=i,a[o+6]=n>>8,a[o+7]=n,a[o+8]=r>>8,a[o+9]=r,t._sQlen+=10,t.flush()},pixelFormat(t,e,s){const i=t._sQ,n=t._sQlen;let r;r=e>16?32:e>8?16:8;const a=Math.floor(e/3);i[n]=0,i[n+1]=0,i[n+2]=0,i[n+3]=0,i[n+4]=r,i[n+5]=e,i[n+6]=0,i[n+7]=s?1:0,i[n+8]=0,i[n+9]=(1<>8,s[i+3]=e.length;let n=i+4;for(let r=0;r>24,s[n+1]=t>>16,s[n+2]=t>>8,s[n+3]=t,n+=4}t._sQlen+=n-i,t.flush()},fbUpdateRequest(t,e,s,i,n,r){const a=t._sQ,o=t._sQlen;"undefined"===typeof s&&(s=0),"undefined"===typeof i&&(i=0),a[o]=3,a[o+1]=e?1:0,a[o+2]=s>>8&255,a[o+3]=255&s,a[o+4]=i>>8&255,a[o+5]=255&i,a[o+6]=n>>8&255,a[o+7]=255&n,a[o+8]=r>>8&255,a[o+9]=255&r,t._sQlen+=10,t.flush()},xvpOp(t,e,s){const i=t._sQ,n=t._sQlen;i[n]=250,i[n+1]=0,i[n+2]=e,i[n+3]=s,t._sQlen+=4,t.flush()}},Sa.cursors={none:{rgbaPixels:new Uint8Array,w:0,h:0,hotx:0,hoty:0},dot:{rgbaPixels:new Uint8Array([255,255,255,255,0,0,0,255,255,255,255,255,0,0,0,255,0,0,0,0,0,0,0,255,255,255,255,255,0,0,0,255,255,255,255,255]),w:3,h:3,hotx:1,hoty:1}}}}]);