"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[460],{94460:function(e,t,s){let i,r,n,a,o,h;s.d(t,{Z:function(){return tk}});let l="warn",_=()=>{},d=()=>{},c=()=>{},u=()=>{};function f(e,t=!1){try{return decodeURIComponent(escape(e))}catch(s){if(s instanceof URIError&&t)return e;throw s}}function p(e){return unescape(encodeURIComponent(e))}!function(e){if(void 0===e?e=l:l=e,_=d=c=u=()=>{},void 0!==window.console)switch(e){case"debug":_=console.debug.bind(window.console);case"info":d=console.info.bind(window.console);case"warn":c=console.warn.bind(window.console);case"error":u=console.error.bind(window.console);case"none":break;default:throw new window.Error("invalid logging type '"+e+"'")}}();let g="ontouchstart"in document.documentElement||void 0!==document.ontouchstart||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0;window.addEventListener("touchstart",function e(){g=!0,window.removeEventListener("touchstart",e,!1)},!1);let m=10*(window.devicePixelRatio||1),w=!1;try{let e=document.createElement("canvas");e.style.cursor='url("data:image/x-icon;base64,AAACAAEACAgAAAIAAgA4AQAAFgAAACgAAAAIAAAAEAAAAAEAIAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////AAAAAAAAAAAAAAAAAAAAAA==") 2 2, default',0===e.style.cursor.indexOf("url")?(d("Data URI scheme cursor supported"),w=!0):c("Data URI scheme cursor not supported")}catch(e){u("Data URI scheme cursor test exception: "+e)}let b=w;try{let e=document.createElement("div");e.style.visibility="hidden",e.style.overflow="scroll",document.body.appendChild(e);let t=document.createElement("div");e.appendChild(t),e.offsetWidth,t.offsetWidth,e.parentNode.removeChild(e)}catch(e){u("Scrollbar test exception: "+e)}function v(){return navigator&&!!/mac/i.exec(navigator.platform)}function k(){return navigator&&!!/win/i.exec(navigator.platform)}function y(){return navigator&&(!!/ipad/i.exec(navigator.platform)||!!/iphone/i.exec(navigator.platform)||!!/ipod/i.exec(navigator.platform))}function X(e,t,s){let i=s.getBoundingClientRect(),r={x:0,y:0};return e=i.right?r.x=i.width-1:r.x=e-i.left,t=i.bottom?r.y=i.height-1:r.y=t-i.top,r}function K(e){e.stopPropagation(),e.preventDefault()}let C=!1,F=null;function S(e){if(C)return;let t=new e.constructor(e.type,e);C=!0,document.captureElement?document.captureElement.dispatchEvent(t):F.dispatchEvent(t),C=!1,e.stopPropagation(),t.defaultPrevented&&e.preventDefault(),"mouseup"===e.type&&M()}function x(){document.getElementById("noVNC_mouse_capture_elem").style.cursor=window.getComputedStyle(document.captureElement).cursor}document.captureElement=null;let E=new MutationObserver(x);function M(){if(document.releaseCapture)document.releaseCapture(),document.captureElement=null;else{if(!document.captureElement)return;F=document.captureElement,document.captureElement=null,E.disconnect(),document.getElementById("noVNC_mouse_capture_elem").style.display="none",window.removeEventListener("mousemove",S),window.removeEventListener("mouseup",S)}}class A{constructor(){this._listeners=new Map}addEventListener(e,t){this._listeners.has(e)||this._listeners.set(e,new Set),this._listeners.get(e).add(t)}removeEventListener(e,t){this._listeners.has(e)&&this._listeners.get(e).delete(t)}dispatchEvent(e){return!this._listeners.has(e.type)||(this._listeners.get(e.type).forEach(t=>t.call(this,e)),!e.defaultPrevented)}}var Q,L,T,D,B,P,R={toBase64Table:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".split(""),base64Pad:"=",encode(e){let t="",s=e.length,i=s%3;for(let i=0;i>2]+this.toBase64Table[((3&e[i])<<4)+(e[i+1]>>4)]+this.toBase64Table[((15&e[i+1])<<2)+(e[i+2]>>6)]+this.toBase64Table[63&e[i+2]];let r=s-i;return 2===i?t+=this.toBase64Table[e[r]>>2]+this.toBase64Table[((3&e[r])<<4)+(e[r+1]>>4)]+this.toBase64Table[(15&e[r+1])<<2]+this.toBase64Table[64]:1===i&&(t+=this.toBase64Table[e[r]>>2]+this.toBase64Table[(3&e[r])<<4]+this.toBase64Table[64]+this.toBase64Table[64]),t},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(e,t=0){let s=e.indexOf("=")-t;s<0&&(s=e.length-t);let i=Array((s>>2)*3+Math.floor(s%4/1.5)),r=0,n=0;for(let s=0,a=t;a=8&&(r-=8,o||(i[s++]=n>>r&255),n&=(1<> Display.constructor"),this._target=e,!this._target)throw Error("Target must be set");if("string"==typeof this._target)throw Error("target must be a DOM element");if(!this._target.getContext)throw 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},_("User Agent: "+navigator.userAgent),_("<< Display.constructor"),this._scale=1,this._clipViewport=!1,this.onflush=()=>{}}get scale(){return this._scale}set scale(e){this._rescale(e)}get clipViewport(){return this._clipViewport}set clipViewport(e){this._clipViewport=e;let t=this._viewportLoc;this.viewportChangeSize(t.w,t.h),this.viewportChangePos(0,0)}get width(){return this._fbWidth}get height(){return this._fbHeight}viewportChangePos(e,t){let s=this._viewportLoc;e=Math.floor(e),t=Math.floor(t),this._clipViewport||(e=-s.w,t=-s.h);let i=s.x+s.w-1,r=s.y+s.h-1;e<0&&s.x+e<0&&(e=-s.x),i+e>=this._fbWidth&&(e-=i+e-this._fbWidth+1),s.y+t<0&&(t=-s.y),r+t>=this._fbHeight&&(t-=r+t-this._fbHeight+1),(0!==e||0!==t)&&(_("viewportChange deltaX: "+e+", deltaY: "+t),s.x+=e,s.y+=t,this._damage(s.x,s.y,s.w,s.h),this.flip())}viewportChangeSize(e,t){this._clipViewport&&void 0!==e&&void 0!==t||(_("Setting viewport to full display region"),e=this._fbWidth,t=this._fbHeight),e=Math.floor(e),t=Math.floor(t),e>this._fbWidth&&(e=this._fbWidth),t>this._fbHeight&&(t=this._fbHeight);let s=this._viewportLoc;if(s.w!==e||s.h!==t){s.w=e,s.h=t;let i=this._target;i.width=e,i.height=t,this.viewportChangePos(0,0),this._damage(s.x,s.y,s.w,s.h),this.flip(),this._rescale(this._scale)}}absX(e){return 0===this._scale?0:0|e/this._scale+this._viewportLoc.x}absY(e){return 0===this._scale?0:0|e/this._scale+this._viewportLoc.y}resize(e,t){this._prevDrawStyle="",this._fbWidth=e,this._fbHeight=t;let s=this._backbuffer;if(s.width!==e||s.height!==t){let i=null;s.width>0&&s.height>0&&(i=this._drawCtx.getImageData(0,0,s.width,s.height)),s.width!==e&&(s.width=e),s.height!==t&&(s.height=t),i&&this._drawCtx.putImageData(i,0,0)}let i=this._viewportLoc;this.viewportChangeSize(i.w,i.h),this.viewportChangePos(0,0)}_damage(e,t,s,i){ethis._damageBounds.right&&(this._damageBounds.right=e+s),t+i>this._damageBounds.bottom&&(this._damageBounds.bottom=t+i)}flip(e){if(0===this._renderQ.length||e){let e=this._damageBounds.left,t=this._damageBounds.top,s=this._damageBounds.right-e,i=this._damageBounds.bottom-t,r=e-this._viewportLoc.x,n=t-this._viewportLoc.y;r<0&&(s+=r,e-=r,r=0),n<0&&(i+=n,t-=n,n=0),r+s>this._viewportLoc.w&&(s=this._viewportLoc.w-r),n+i>this._viewportLoc.h&&(i=this._viewportLoc.h-n),s>0&&i>0&&this._targetCtx.drawImage(this._backbuffer,e,t,s,i,r,n,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(e,t,s,i,r,n){0===this._renderQ.length||n?(this._setFillColor(r),this._drawCtx.fillRect(e,t,s,i),this._damage(e,t,s,i)):this._renderQPush({type:"fill",x:e,y:t,width:s,height:i,color:r})}copyImage(e,t,s,i,r,n,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,e,t,r,n,s,i,r,n),this._damage(s,i,r,n)):this._renderQPush({type:"copy",oldX:e,oldY:t,x:s,y:i,width:r,height:n})}imageRect(e,t,s,i,r,n){if(0===s||0===i)return;let a=new Image;a.src="data: "+r+";base64,"+R.encode(n),this._renderQPush({type:"img",img:a,x:e,y:t,width:s,height:i})}blitImage(e,t,s,i,r,n,a){if(0===this._renderQ.length||a){let a=new ImageData(new Uint8ClampedArray(r.buffer,r.byteOffset+n,s*i*4),s,i);this._drawCtx.putImageData(a,e,t),this._damage(e,t,s,i)}else{let n=new Uint8Array(s*i*4);n.set(new Uint8Array(r.buffer,0,n.length)),this._renderQPush({type:"blit",data:n,x:e,y:t,width:s,height:i})}}drawImage(e,t,s){this._drawCtx.drawImage(e,t,s),this._damage(t,s,e.width,e.height)}autoscale(e,t){let s;if(0===e||0===t)s=0;else{let i=this._viewportLoc;s=i.w/i.h>=e/t?e/i.w:t/i.h}this._rescale(s)}_rescale(e){this._scale=e;let t=this._viewportLoc,s=e*t.w+"px",i=e*t.h+"px";(this._target.style.width!==s||this._target.style.height!==i)&&(this._target.style.width=s,this._target.style.height=i)}_setFillColor(e){let t="rgb("+e[0]+","+e[1]+","+e[2]+")";t!==this._prevDrawStyle&&(this._drawCtx.fillStyle=t,this._prevDrawStyle=t)}_renderQPush(e){this._renderQ.push(e),1===this._renderQ.length&&this._scanRenderQ()}_resumeRenderQ(){this.removeEventListener("load",this._noVNCDisplay._resumeRenderQ),this._noVNCDisplay._scanRenderQ()}_scanRenderQ(){let e=!0;for(;e&&this._renderQ.length>0;){let t=this._renderQ[0];switch(t.type){case"flip":this.flip(!0);break;case"copy":this.copyImage(t.oldX,t.oldY,t.x,t.y,t.width,t.height,!0);break;case"fill":this.fillRect(t.x,t.y,t.width,t.height,t.color,!0);break;case"blit":this.blitImage(t.x,t.y,t.width,t.height,t.data,0,!0);break;case"img":if(t.img.complete){if(t.img.width!==t.width||t.img.height!==t.height){u("Decoded image has incorrect dimensions. Got "+t.img.width+"x"+t.img.height+". Expected "+t.width+"x"+t.height+".");return}this.drawImage(t.img,t.x,t.y)}else t.img._noVNCDisplay=this,t.img.addEventListener("load",this._resumeRenderQ),e=!1}e&&this._renderQ.shift()}0===this._renderQ.length&&this._flushing&&(this._flushing=!1,this.onflush())}}function U(e,t,s,i,r){if(t.subarray&&e.subarray){e.set(t.subarray(s,s+i),r);return}for(var n=0;n>>16&65535|0,a=0;0!==s;){a=s>2e3?2e3:s,s-=a;do n=n+(r=r+t[i++]|0)|0;while(--a);r%=65521,n%=65521}return r|n<<16|0}function O(){for(var e,t=[],s=0;s<256;s++){e=s;for(var i=0;i<8;i++)e=1&e?3988292384^e>>>1:e>>>1;t[s]=e}return t}O();var G=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],W=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],Y=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],q=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];function j(e,t,s,i,r,n,a,o){var h,l,_,d,c,u,f,p,g,m=o.bits,w=0,b=0,v=0,k=0,y=0,X=0,K=0,C=0,F=0,S=0,x=null,E=0,M=new I(16),A=new I(16),Q=null,L=0;for(w=0;w<=15;w++)M[w]=0;for(b=0;b=1&&0===M[k];k--);if(y>k&&(y=k),0===k)return r[n++]=20971520,r[n++]=20971520,o.bits=1,0;for(v=1;v0&&(0===e||1!==k))return -1;for(w=1,A[1]=0;w<15;w++)A[w+1]=A[w]+M[w];for(b=0;b852||2===e&&F>592)return 1;for(;;){f=w-K,a[b]u?(p=Q[L+a[b]],g=x[E+a[b]]):(p=96,g=0),h=1<>K)+(l-=h)]=f<<24|p<<16|g|0;while(0!==l);for(h=1<>=1;if(0!==h?(S&=h-1,S+=h):S=0,b++,0==--M[w]){if(w===k)break;w=t[s+a[b]]}if(w>y&&(S&d)!==_){for(0===K&&(K=y),c+=v,C=1<<(X=w-K);X+K852||2===e&&F>592)return 1;r[_=S&d]=y<<24|X<<16|c-n|0}}return 0!==S&&(r[c+S]=w-K<<24|4194304),o.bits=y,0}function Z(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function J(){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 I(320),this.work=new I(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function $(e){var t,s;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,e&&e.state?(s=e.state,e.total_in=e.total_out=s.total=0,e.msg="",s.wrap&&(e.adler=1&s.wrap),s.mode=1,s.last=0,s.havedict=0,s.dmax=32768,s.head=null,s.hold=0,s.bits=0,s.lencode=s.lendyn=new H(852),s.distcode=s.distdyn=new H(592),s.sane=1,s.back=-1,0):-2):-2}var ee=!0;function et(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}class es{constructor(){var e,t,s,i,r,n,a;this.strm=new et,this.chunkSize=102400,this.strm.output=new Uint8Array(this.chunkSize),this.windowBits=5,e=this.strm,this.windowBits,s=0,!(t=e)||(i=new J,t.state=i,i.window=null,r=15,0===(t&&t.state?(a=t.state,r<0?(n=0,r=-r):(n=(r>>4)+1,r<48&&(r&=15)),r&&(r<8||r>15))?-2:(null!==a.window&&a.wbits!==r&&(a.window=null),a.wrap=n,a.wbits=r,$(t)):-2)||(t.state=null))}setInput(e){e?(this.strm.input=e,this.strm.avail_in=this.strm.input.length):(this.strm.input=null,this.strm.avail_in=0),this.strm.next_in=0}inflate(e){if(e>this.chunkSize&&(this.chunkSize=e,this.strm.output=new Uint8Array(this.chunkSize)),this.strm.next_out=0,this.strm.avail_out=e,0>function(e,t){var s,i,r,n,a,o,h,l,_,d,c,u,f,p,g,m,w,b,v,k,y,X,K,C,F,S,x,E,M,A=0,T=new N(4),D=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!e||!e.state||!e.output||!e.input&&0!==e.avail_in)return -2;12===(o=e.state).mode&&(o.mode=13),d=e.next_out,l=e.output,u=e.avail_out,_=e.next_in,h=e.input,c=e.avail_in,f=o.hold,p=o.bits,g=c,m=u,x=0;e:for(;;)switch(o.mode){case 1:if(0===o.wrap){o.mode=13;break}for(;p<16;){if(0===c)break e;c--,f+=h[_++]<>>8&255,o.check=O(o.check,T,2,0),f=0,p=0,o.mode=2;break}if(o.flags=0,o.head&&(o.head.done=!1),!(1&o.wrap)||(((255&f)<<8)+(f>>8))%31){e.msg="incorrect header check",o.mode=30;break}if((15&f)!=8){e.msg="unknown compression method",o.mode=30;break}if(f>>>=4,p-=4,S=(15&f)+8,0===o.wbits)o.wbits=S;else if(S>o.wbits){e.msg="invalid window size",o.mode=30;break}o.dmax=1<>8&1),512&o.flags&&(T[0]=255&f,T[1]=f>>>8&255,o.check=O(o.check,T,2,0)),f=0,p=0,o.mode=3;case 3:for(;p<32;){if(0===c)break e;c--,f+=h[_++]<>>8&255,T[2]=f>>>16&255,T[3]=f>>>24&255,o.check=O(o.check,T,4,0)),f=0,p=0,o.mode=4;case 4:for(;p<16;){if(0===c)break e;c--,f+=h[_++]<>8),512&o.flags&&(T[0]=255&f,T[1]=f>>>8&255,o.check=O(o.check,T,2,0)),f=0,p=0,o.mode=5;case 5:if(1024&o.flags){for(;p<16;){if(0===c)break e;c--,f+=h[_++]<>>8&255,o.check=O(o.check,T,2,0)),f=0,p=0}else o.head&&(o.head.extra=null);o.mode=6;case 6:if(1024&o.flags&&((w=o.length)>c&&(w=c),w&&(o.head&&(S=o.head.extra_len-o.length,o.head.extra||(o.head.extra=Array(o.head.extra_len)),U(o.head.extra,h,_,w,S)),512&o.flags&&(o.check=O(o.check,h,w,_)),c-=w,_+=w,o.length-=w),o.length))break e;o.length=0,o.mode=7;case 7:if(2048&o.flags){if(0===c)break e;w=0;do S=h[_+w++],o.head&&S&&o.length<65536&&(o.head.name+=String.fromCharCode(S));while(S&&w>9&1,o.head.done=!0),e.adler=o.check=0,o.mode=12;break;case 10:for(;p<32;){if(0===c)break e;c--,f+=h[_++]<>>=7&p,p-=7&p,o.mode=27;break}for(;p<3;){if(0===c)break e;c--,f+=h[_++]<>>=1)){case 0:o.mode=14;break;case 1:(function(e){if(ee){var t;for(Q=new H(512),L=new H(32),t=0;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(j(1,e.lens,0,288,Q,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;j(2,e.lens,0,32,L,0,e.work,{bits:5}),ee=!1}e.lencode=Q,e.lenbits=9,e.distcode=L,e.distbits=5})(o),o.mode=20;break;case 2:o.mode=17;break;case 3:e.msg="invalid block type",o.mode=30}f>>>=2,p-=2;break;case 14:for(f>>>=7&p,p-=7&p;p<32;){if(0===c)break e;c--,f+=h[_++]<>>16^65535)){e.msg="invalid stored block lengths",o.mode=30;break}if(o.length=65535&f,f=0,p=0,o.mode=15,6===t)break e;case 15:o.mode=16;case 16:if(w=o.length){if(w>c&&(w=c),w>u&&(w=u),0===w)break e;U(l,h,_,w,d),c-=w,_+=w,u-=w,d+=w,o.length-=w;break}o.mode=12;break;case 17:for(;p<14;){if(0===c)break e;c--,f+=h[_++]<>>=5,p-=5,o.ndist=(31&f)+1,f>>>=5,p-=5,o.ncode=(15&f)+4,f>>>=4,p-=4,o.nlen>286||o.ndist>30){e.msg="too many length or distance symbols",o.mode=30;break}o.have=0,o.mode=18;case 18:for(;o.have>>=3,p-=3}for(;o.have<19;)o.lens[D[o.have++]]=0;if(o.lencode=o.lendyn,o.lenbits=7,E={bits:o.lenbits},x=j(0,o.lens,0,19,o.lencode,0,o.work,E),o.lenbits=E.bits,x){e.msg="invalid code lengths set",o.mode=30;break}o.have=0,o.mode=19;case 19:for(;o.have>>24,y=A>>>16&255,X=65535&A,!(k<=p);){if(0===c)break e;c--,f+=h[_++]<>>=k,p-=k,o.lens[o.have++]=X;else{if(16===X){for(M=k+2;p>>=k,p-=k,0===o.have){e.msg="invalid bit length repeat",o.mode=30;break}S=o.lens[o.have-1],w=3+(3&f),f>>>=2,p-=2}else if(17===X){for(M=k+3;p>>=k,p-=k,S=0,w=3+(7&f),f>>>=3,p-=3}else{for(M=k+7;p>>=k,p-=k,S=0,w=11+(127&f),f>>>=7,p-=7}if(o.have+w>o.nlen+o.ndist){e.msg="invalid bit length repeat",o.mode=30;break}for(;w--;)o.lens[o.have++]=S}}if(30===o.mode)break;if(0===o.lens[256]){e.msg="invalid code -- missing end-of-block",o.mode=30;break}if(o.lenbits=9,E={bits:o.lenbits},x=j(1,o.lens,0,o.nlen,o.lencode,0,o.work,E),o.lenbits=E.bits,x){e.msg="invalid literal/lengths set",o.mode=30;break}if(o.distbits=6,o.distcode=o.distdyn,E={bits:o.distbits},x=j(2,o.lens,o.nlen,o.ndist,o.distcode,0,o.work,E),o.distbits=E.bits,x){e.msg="invalid distances set",o.mode=30;break}if(o.mode=20,6===t)break e;case 20:o.mode=21;case 21:if(c>=6&&u>=258){e.next_out=d,e.avail_out=u,e.next_in=_,e.avail_in=c,o.hold=f,o.bits=p,function(e,t){var s,i,r,n,a,o,h,l,_,d,c,u,f,p,g,m,w,b,v,k,y,X,K,C,F;s=e.state,i=e.next_in,C=e.input,r=i+(e.avail_in-5),n=e.next_out,F=e.output,a=n-(t-e.avail_out),o=n+(e.avail_out-257),h=s.dmax,l=s.wsize,_=s.whave,d=s.wnext,c=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))F[n++]=65535&b;else if(16&v)for(k=65535&b,(v&=15)&&(f>>=v,f-=v),f<15&&(u+=C[i++]<>>=v=b>>>24,f-=v,16&(v=b>>>16&255)){if(y=65535&b,f<(v&=15)&&(u+=C[i++]<h){e.msg="invalid distance too far back",s.mode=30;break t}if(u>>>=v,f-=v,y>(v=n-a)){if((v=y-v)>_&&s.sane){e.msg="invalid distance too far back",s.mode=30;break t}if(X=0,K=c,0===d){if(X+=l-v,v2;)F[n++]=K[X++],F[n++]=K[X++],F[n++]=K[X++],k-=3;k&&(F[n++]=K[X++],k>1&&(F[n++]=K[X++]))}else{X=n-y;do F[n++]=F[X++],F[n++]=F[X++],F[n++]=F[X++],k-=3;while(k>2);k&&(F[n++]=F[X++],k>1&&(F[n++]=F[X++]))}}else if((64&v)==0){b=g[(65535&b)+(u&(1<>3,f-=k<<3,u&=(1<>>24,y=A>>>16&255,X=65535&A,!(k<=p);){if(0===c)break e;c--,f+=h[_++]<>K)])>>>24,y=A>>>16&255,X=65535&A,!(K+k<=p);){if(0===c)break e;c--,f+=h[_++]<>>=K,p-=K,o.back+=K}if(f>>>=k,p-=k,o.back+=k,o.length=X,0===y){o.mode=26;break}if(32&y){o.back=-1,o.mode=12;break}if(64&y){e.msg="invalid literal/length code",o.mode=30;break}o.extra=15&y,o.mode=22;case 22:if(o.extra){for(M=o.extra;p>>=o.extra,p-=o.extra,o.back+=o.extra}o.was=o.length,o.mode=23;case 23:for(;k=(A=o.distcode[f&(1<>>24,y=A>>>16&255,X=65535&A,!(k<=p);){if(0===c)break e;c--,f+=h[_++]<>K)])>>>24,y=A>>>16&255,X=65535&A,!(K+k<=p);){if(0===c)break e;c--,f+=h[_++]<>>=K,p-=K,o.back+=K}if(f>>>=k,p-=k,o.back+=k,64&y){e.msg="invalid distance code",o.mode=30;break}o.offset=X,o.extra=15&y,o.mode=24;case 24:if(o.extra){for(M=o.extra;p>>=o.extra,p-=o.extra,o.back+=o.extra}if(o.offset>o.dmax){e.msg="invalid distance too far back",o.mode=30;break}o.mode=25;case 25:if(0===u)break e;if(w=m-u,o.offset>w){if((w=o.offset-w)>o.whave&&o.sane){e.msg="invalid distance too far back",o.mode=30;break}w>o.wnext?(w-=o.wnext,b=o.wsize-w):b=o.wnext-w,w>o.length&&(w=o.length),v=o.window}else v=l,b=d-o.offset,w=o.length;w>u&&(w=u),u-=w,o.length-=w;do l[d++]=v[b++];while(--w);0===o.length&&(o.mode=21);break;case 26:if(0===u)break e;l[d++]=o.length,u--,o.mode=21;break;case 27:if(o.wrap){for(;p<32;){if(0===c)break e;c--,f|=h[_++]<=a.wsize?(U(a.window,s,i-a.wsize,a.wsize,0),a.wnext=0,a.whave=a.wsize):((n=a.wsize-a.wnext)>r&&(n=r),U(a.window,s,i-r,n,a.wnext),(r-=n)?(U(a.window,s,i-r,r,0),a.wnext=r,a.whave=a.wsize):(a.wnext+=n,a.wnext===a.wsize&&(a.wnext=0),a.whave=0;)e[t]=0}var er=[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],en=[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],ea=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],eo=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],eh=Array(576);ei(eh);var el=Array(60);ei(el);var e_=Array(512);ei(e_);var ed=Array(256);ei(ed);var ec=Array(29);ei(ec);var eu=Array(30);function ef(e,t,s,i,r){this.static_tree=e,this.extra_bits=t,this.extra_base=s,this.elems=i,this.max_length=r,this.has_stree=e&&e.length}function ep(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}function eg(e){return e<256?e_[e]:e_[256+(e>>>7)]}function em(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255}function ew(e,t,s){e.bi_valid>16-s?(e.bi_buf|=t<>16-e.bi_valid,e.bi_valid+=s-16):(e.bi_buf|=t<>>=1,s<<=1;while(--t>0);return s>>>1}function ek(e,t,s){var i,r,n=Array(16),a=0;for(i=1;i<=15;i++)n[i]=a=a+s[i-1]<<1;for(r=0;r<=t;r++){var o=e[2*r+1];0!==o&&(e[2*r]=ev(n[o]++,o))}}function ey(e){var t;for(t=0;t<286;t++)e.dyn_ltree[2*t]=0;for(t=0;t<30;t++)e.dyn_dtree[2*t]=0;for(t=0;t<19;t++)e.bl_tree[2*t]=0;e.dyn_ltree[512]=1,e.opt_len=e.static_len=0,e.last_lit=e.matches=0}function eX(e){e.bi_valid>8?em(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0}function eK(e,t,s,i){var r=2*t,n=2*s;return e[r]>1;s>=1;s--)eC(e,n,s);r=h;do s=e.heap[1],e.heap[1]=e.heap[e.heap_len--],eC(e,n,1),i=e.heap[1],e.heap[--e.heap_max]=s,e.heap[--e.heap_max]=i,n[2*r]=n[2*s]+n[2*i],e.depth[r]=(e.depth[s]>=e.depth[i]?e.depth[s]:e.depth[i])+1,n[2*s+1]=n[2*i+1]=r,e.heap[1]=r++,eC(e,n,1);while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],function(e,t){var s,i,r,n,a,o,h=t.dyn_tree,l=t.max_code,_=t.stat_desc.static_tree,d=t.stat_desc.has_stree,c=t.stat_desc.extra_bits,u=t.stat_desc.extra_base,f=t.stat_desc.max_length,p=0;for(n=0;n<=15;n++)e.bl_count[n]=0;for(h[2*e.heap[e.heap_max]+1]=0,s=e.heap_max+1;s<573;s++)(n=h[2*h[2*(i=e.heap[s])+1]+1]+1)>f&&(n=f,p++),h[2*i+1]=n,!(i>l)&&(e.bl_count[n]++,a=0,i>=u&&(a=c[i-u]),o=h[2*i],e.opt_len+=o*(n+a),d&&(e.static_len+=o*(_[2*i+1]+a)));if(0!==p){do{for(n=f-1;0===e.bl_count[n];)n--;e.bl_count[n]--,e.bl_count[n+1]+=2,e.bl_count[f]--,p-=2}while(p>0);for(n=f;0!==n;n--)for(i=e.bl_count[n];0!==i;)!((r=e.heap[--s])>l)&&(h[2*r+1]!==n&&(e.opt_len+=(n-h[2*r+1])*h[2*r],h[2*r+1]=n),i--)}}(e,t),ek(n,l,e.bl_count)}function ex(e,t,s){var i,r,n=-1,a=t[1],o=0,h=7,l=4;for(0===a&&(h=138,l=3),t[(s+1)*2+1]=65535,i=0;i<=s;i++)r=a,a=t[(i+1)*2+1],++o>>8&255,e.pending_buf[e.d_buf+2*e.last_lit+1]=255&t,e.pending_buf[e.l_buf+e.last_lit]=255&s,e.last_lit++,0===t?e.dyn_ltree[2*s]++:(e.matches++,t--,e.dyn_ltree[(ed[s]+256+1)*2]++,e.dyn_dtree[2*eg(t)]++),e.last_lit===e.lit_bufsize-1}var eL={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"};function eT(e,t){return e.msg=eL[t],t}function eD(e){return(e<<1)-(e>4?9:0)}function eB(e){for(var t=e.length;--t>=0;)e[t]=0}function eP(e){var t=e.state,s=t.pending;s>e.avail_out&&(s=e.avail_out),0!==s&&(U(e.output,t.pending_buf,t.pending_out,s,e.next_out),e.next_out+=s,t.pending_out+=s,e.total_out+=s,e.avail_out-=s,t.pending-=s,0===t.pending&&(t.pending_out=0))}function eR(e,t){var s,i,r,n,a;s=e.block_start>=0?e.block_start:-1,i=e.strstart-e.block_start,a=0,e.level>0?(2===e.strm.data_type&&(e.strm.data_type=function(e){var t,s=4093624447;for(t=0;t<=31;t++,s>>>=1)if(1&s&&0!==e.dyn_ltree[2*t])return 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(t=32;t<256;t++)if(0!==e.dyn_ltree[2*t])return 1;return 0}(e)),eS(e,e.l_desc),eS(e,e.d_desc),a=function(e){var t;for(ex(e,e.dyn_ltree,e.l_desc.max_code),ex(e,e.dyn_dtree,e.d_desc.max_code),eS(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*eo[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t}(e),r=e.opt_len+3+7>>>3,(n=e.static_len+3+7>>>3)<=r&&(r=n)):r=n=i+5,i+4<=r&&-1!==s?eA(e,s,i,t):4===e.strategy||n===r?(ew(e,2+(t?1:0),3),eF(e,eh,el)):(ew(e,4+(t?1:0),3),function(e,t,s,i){var r;for(ew(e,t-257,5),ew(e,s-1,5),ew(e,i-4,4),r=0;r>>8&255,e.pending_buf[e.pending++]=255&t}function eN(e,t){var s,i,r=e.max_chain_length,n=e.strstart,a=e.prev_length,o=e.nice_match,h=e.strstart>e.w_size-262?e.strstart-(e.w_size-262):0,l=e.window,_=e.w_mask,d=e.prev,c=e.strstart+258,u=l[n+a-1],f=l[n+a];e.prev_length>=e.good_match&&(r>>=2),o>e.lookahead&&(o=e.lookahead);do{if(l[(s=t)+a]!==f||l[s+a-1]!==u||l[s]!==l[n]||l[++s]!==l[n+1])continue;n+=2,s++;do;while(l[++n]===l[++s]&&l[++n]===l[++s]&&l[++n]===l[++s]&&l[++n]===l[++s]&&l[++n]===l[++s]&&l[++n]===l[++s]&&l[++n]===l[++s]&&l[++n]===l[++s]&&na){if(e.match_start=t,a=i,i>=o)break;u=l[n+a-1],f=l[n+a]}}while((t=d[t&_])>h&&0!=--r);return a<=e.lookahead?a:e.lookahead}function eI(e){var t,s,i,r,n,a=e.w_size;do{if(r=e.window_size-e.lookahead-e.strstart,e.strstart>=a+(a-262)){U(e.window,e.window,a,a,0),e.match_start-=a,e.strstart-=a,e.block_start-=a,t=s=e.hash_size;do i=e.head[--t],e.head[t]=i>=a?i-a:0;while(--s);t=s=a;do i=e.prev[--t],e.prev[t]=i>=a?i-a:0;while(--s);r+=a}if(0===e.strm.avail_in)break;if(s=function(e,t,s,i){var r=e.avail_in;return(r>i&&(r=i),0===r)?0:(e.avail_in-=r,U(t,e.input,e.next_in,r,s),1===e.state.wrap?e.adler=V(e.adler,t,r,s):2===e.state.wrap&&(e.adler=O(e.adler,t,r,s)),e.next_in+=r,e.total_in+=r,r)}(e.strm,e.window,e.strstart+e.lookahead,r),e.lookahead+=s,e.lookahead+e.insert>=3)for(n=e.strstart-e.insert,e.ins_h=e.window[n],e.ins_h=(e.ins_h<=3&&(e.ins_h=(e.ins_h<=3){if(i=eQ(e,e.strstart-e.match_start,e.match_length-3),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=3){e.match_length--;do e.strstart++,e.ins_h=(e.ins_h<=3&&(e.ins_h=(e.ins_h<4096)&&(e.match_length=2)),e.prev_length>=3&&e.match_length<=e.prev_length){r=e.strstart+e.lookahead-3,i=eQ(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;do++e.strstart<=r&&(e.ins_h=(e.ins_h<5||t<0)return e?eT(e,-2):-2;if(i=e.state,!e.output||!e.input&&0!==e.avail_in||666===i.status&&4!==t)return eT(e,0===e.avail_out?-5:-2);if(i.strm=e,s=i.last_flush,i.last_flush=t,42===i.status){if(2===i.wrap)e.adler=0,ez(i,31),ez(i,139),ez(i,8),i.gzhead?(ez(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)),ez(i,255&i.gzhead.time),ez(i,i.gzhead.time>>8&255),ez(i,i.gzhead.time>>16&255),ez(i,i.gzhead.time>>24&255),ez(i,9===i.level?2:i.strategy>=2||i.level<2?4:0),ez(i,255&i.gzhead.os),i.gzhead.extra&&i.gzhead.extra.length&&(ez(i,255&i.gzhead.extra.length),ez(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(e.adler=O(e.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=69):(ez(i,0),ez(i,0),ez(i,0),ez(i,0),ez(i,0),ez(i,9===i.level?2:i.strategy>=2||i.level<2?4:0),ez(i,3),i.status=113);else{var s,i,r,n,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=113,eU(i,a),0!==i.strstart&&(eU(i,e.adler>>>16),eU(i,65535&e.adler)),e.adler=1}}if(69===i.status){if(i.gzhead.extra){for(r=i.pending;i.gzindex<(65535&i.gzhead.extra.length)&&(i.pending!==i.pending_buf_size||(i.gzhead.hcrc&&i.pending>r&&(e.adler=O(e.adler,i.pending_buf,i.pending-r,r)),eP(e),r=i.pending,i.pending!==i.pending_buf_size));)ez(i,255&i.gzhead.extra[i.gzindex]),i.gzindex++;i.gzhead.hcrc&&i.pending>r&&(e.adler=O(e.adler,i.pending_buf,i.pending-r,r)),i.gzindex===i.gzhead.extra.length&&(i.gzindex=0,i.status=73)}else i.status=73}if(73===i.status){if(i.gzhead.name){r=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>r&&(e.adler=O(e.adler,i.pending_buf,i.pending-r,r)),eP(e),r=i.pending,i.pending===i.pending_buf_size)){n=1;break}n=i.gzindexr&&(e.adler=O(e.adler,i.pending_buf,i.pending-r,r)),0===n&&(i.gzindex=0,i.status=91)}else i.status=91}if(91===i.status){if(i.gzhead.comment){r=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>r&&(e.adler=O(e.adler,i.pending_buf,i.pending-r,r)),eP(e),r=i.pending,i.pending===i.pending_buf_size)){n=1;break}n=i.gzindexr&&(e.adler=O(e.adler,i.pending_buf,i.pending-r,r)),0===n&&(i.status=103)}else i.status=103}if(103===i.status&&(i.gzhead.hcrc?(i.pending+2>i.pending_buf_size&&eP(e),i.pending+2<=i.pending_buf_size&&(ez(i,255&e.adler),ez(i,e.adler>>8&255),e.adler=0,i.status=113)):i.status=113),0!==i.pending){if(eP(e),0===e.avail_out)return i.last_flush=-1,0}else if(0===e.avail_in&&eD(t)<=eD(s)&&4!==t)return eT(e,-5);if(666===i.status&&0!==e.avail_in)return eT(e,-5);if(0!==e.avail_in||0!==i.lookahead||0!==t&&666!==i.status){var o=2===i.strategy?function(e,t){for(var s;;){if(0===e.lookahead&&(eI(e),0===e.lookahead)){if(0===t)return 1;break}if(e.match_length=0,s=eQ(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,s&&(eR(e,!1),0===e.strm.avail_out))return 1}return(e.insert=0,4===t)?(eR(e,!0),0===e.strm.avail_out)?3:4:e.last_lit&&(eR(e,!1),0===e.strm.avail_out)?1:2}(i,t):3===i.strategy?function(e,t){for(var s,i,r,n,a=e.window;;){if(e.lookahead<=258){if(eI(e),e.lookahead<=258&&0===t)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&e.strstart>0&&(i=a[r=e.strstart-1])===a[++r]&&i===a[++r]&&i===a[++r]){n=e.strstart+258;do;while(i===a[++r]&&i===a[++r]&&i===a[++r]&&i===a[++r]&&i===a[++r]&&i===a[++r]&&i===a[++r]&&i===a[++r]&&re.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(s=eQ(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(s=eQ(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),s&&(eR(e,!1),0===e.strm.avail_out))return 1}return(e.insert=0,4===t)?(eR(e,!0),0===e.strm.avail_out)?3:4:e.last_lit&&(eR(e,!1),0===e.strm.avail_out)?1:2}(i,t):P[i.level].func(i,t);if((3===o||4===o)&&(i.status=666),1===o||3===o)return 0===e.avail_out&&(i.last_flush=-1),0;if(2===o&&(1===t?(ew(i,2,3),eb(i,256,eh),16===i.bi_valid?(em(i,i.bi_buf),i.bi_buf=0,i.bi_valid=0):i.bi_valid>=8&&(i.pending_buf[i.pending++]=255&i.bi_buf,i.bi_buf>>=8,i.bi_valid-=8)):5!==t&&(eA(i,0,0,!1),3===t&&(eB(i.head),0===i.lookahead&&(i.strstart=0,i.block_start=0,i.insert=0))),eP(e),0===e.avail_out))return i.last_flush=-1,0}return 4!==t?0:i.wrap<=0?1:(2===i.wrap?(ez(i,255&e.adler),ez(i,e.adler>>8&255),ez(i,e.adler>>16&255),ez(i,e.adler>>24&255),ez(i,255&e.total_in),ez(i,e.total_in>>8&255),ez(i,e.total_in>>16&255),ez(i,e.total_in>>24&255)):(eU(i,e.adler>>>16),eU(i,65535&e.adler)),eP(e),i.wrap>0&&(i.wrap=-i.wrap),0!==i.pending?0:1)}P=[new eO(0,0,0,0,function(e,t){var s=65535;for(65535>e.pending_buf_size-5&&(s=e.pending_buf_size-5);;){if(e.lookahead<=1){if(eI(e),0===e.lookahead&&0===t)return 1;if(0===e.lookahead)break}e.strstart+=e.lookahead,e.lookahead=0;var i=e.block_start+s;if((0===e.strstart||e.strstart>=i)&&(e.lookahead=e.strstart-i,e.strstart=i,eR(e,!1),0===e.strm.avail_out)||e.strstart-e.block_start>=e.w_size-262&&(eR(e,!1),0===e.strm.avail_out))return 1}return(e.insert=0,4===t)?(eR(e,!0),0===e.strm.avail_out)?3:4:(e.strstart>e.block_start&&(eR(e,!1),e.strm.avail_out),1)}),new eO(4,4,8,4,eH),new eO(4,5,16,8,eH),new eO(4,6,32,32,eH),new eO(4,4,16,16,eV),new eO(8,16,32,32,eV),new eO(8,16,128,128,eV),new eO(8,32,128,256,eV),new eO(32,128,258,1024,eV),new eO(32,258,258,4096,eV)];class eY{constructor(){this.strm=new et,this.chunkSize=102400,this.outputBuffer=new Uint8Array(this.chunkSize),this.windowBits=5,function(e,t,s,i,r,n){if(e){var a,o,h,l=1;if(-1===t&&(t=6),i<0?(l=0,i=-i):i>15&&(l=2,i-=16),i<8||i>15||t<0||t>9)return eT(e,-2);8===i&&(i=9);var _=new eG;e.state=_,_.strm=e,_.wrap=l,_.gzhead=null,_.w_bits=i,_.w_size=1<<_.w_bits,_.w_mask=_.w_size-1,_.hash_bits=15,_.hash_size=1<<_.hash_bits,_.hash_mask=_.hash_size-1,_.hash_shift=~~((_.hash_bits+3-1)/3),_.window=new N(2*_.w_size),_.head=new I(_.hash_size),_.prev=new I(_.w_size),_.lit_bufsize=1<>=7;i<30;i++)for(e=0,eu[i]=r<<7;e<1<0){let e=[s],i=s.length;do{if(this.strm.output=new Uint8Array(this.chunkSize),this.strm.next_out=0,this.strm.avail_out=this.chunkSize,(t=eW(this.strm,3))<0)throw Error("zlib deflate failed");let s=new Uint8Array(this.strm.output.buffer,0,this.strm.next_out);i+=s.length,e.push(s)}while(this.strm.avail_in>0);let r=new Uint8Array(i),n=0;for(let t=0;t=32&&e<=255)return e;let t=ej[e];return void 0!==t?t:16777216|e}},eJ={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"},e$={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"};let e1={};function e0(e,t){if(void 0===t)throw Error('Undefined keysym for key "'+e+'"');if(e in e1)throw Error('Duplicate entry for key "'+e+'"');e1[e]=[t,t,t,t]}function e2(e,t,s){if(void 0===t||void 0===s)throw Error('Undefined keysym for key "'+e+'"');if(e in e1)throw Error('Duplicate entry for key "'+e+'"');e1[e]=[t,t,s,t]}function e5(e,t,s){if(void 0===t||void 0===s)throw Error('Undefined keysym for key "'+e+'"');if(e in e1)throw Error('Duplicate entry for key "'+e+'"');e1[e]=[t,t,t,s]}function e3(e){if(e.code){switch(e.code){case"OSLeft":return"MetaLeft";case"OSRight":return"MetaRight"}return e.code}if(e.keyCode in eJ){let t=eJ[e.keyCode];if(v()&&"ContextMenu"===t&&(t="MetaRight"),2===e.location)switch(t){case"ShiftLeft":return"ShiftRight";case"ControlLeft":return"ControlRight";case"AltLeft":return"AltRight"}if(3===e.location)switch(t){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 t}return"Unidentified"}e2("Alt",eq.XK_Alt_L,eq.XK_Alt_R),e0("AltGraph",eq.XK_ISO_Level3_Shift),e0("CapsLock",eq.XK_Caps_Lock),e2("Control",eq.XK_Control_L,eq.XK_Control_R),e2("Meta",eq.XK_Super_L,eq.XK_Super_R),e0("NumLock",eq.XK_Num_Lock),e0("ScrollLock",eq.XK_Scroll_Lock),e2("Shift",eq.XK_Shift_L,eq.XK_Shift_R),e5("Enter",eq.XK_Return,eq.XK_KP_Enter),e0("Tab",eq.XK_Tab),e5(" ",eq.XK_space,eq.XK_KP_Space),e5("ArrowDown",eq.XK_Down,eq.XK_KP_Down),e5("ArrowLeft",eq.XK_Left,eq.XK_KP_Left),e5("ArrowRight",eq.XK_Right,eq.XK_KP_Right),e5("ArrowUp",eq.XK_Up,eq.XK_KP_Up),e5("End",eq.XK_End,eq.XK_KP_End),e5("Home",eq.XK_Home,eq.XK_KP_Home),e5("PageDown",eq.XK_Next,eq.XK_KP_Next),e5("PageUp",eq.XK_Prior,eq.XK_KP_Prior),e0("Backspace",eq.XK_BackSpace),e5("Clear",eq.XK_Clear,eq.XK_KP_Begin),e0("Copy",eq.XF86XK_Copy),e0("Cut",eq.XF86XK_Cut),e5("Delete",eq.XK_Delete,eq.XK_KP_Delete),e5("Insert",eq.XK_Insert,eq.XK_KP_Insert),e0("Paste",eq.XF86XK_Paste),e0("Redo",eq.XK_Redo),e0("Undo",eq.XK_Undo),e0("Cancel",eq.XK_Cancel),e0("ContextMenu",eq.XK_Menu),e0("Escape",eq.XK_Escape),e0("Execute",eq.XK_Execute),e0("Find",eq.XK_Find),e0("Help",eq.XK_Help),e0("Pause",eq.XK_Pause),e0("Select",eq.XK_Select),e0("ZoomIn",eq.XF86XK_ZoomIn),e0("ZoomOut",eq.XF86XK_ZoomOut),e0("BrightnessDown",eq.XF86XK_MonBrightnessDown),e0("BrightnessUp",eq.XF86XK_MonBrightnessUp),e0("Eject",eq.XF86XK_Eject),e0("LogOff",eq.XF86XK_LogOff),e0("Power",eq.XF86XK_PowerOff),e0("PowerOff",eq.XF86XK_PowerDown),e0("PrintScreen",eq.XK_Print),e0("Hibernate",eq.XF86XK_Hibernate),e0("Standby",eq.XF86XK_Standby),e0("WakeUp",eq.XF86XK_WakeUp),e0("AllCandidates",eq.XK_MultipleCandidate),e0("Alphanumeric",eq.XK_Eisu_toggle),e0("CodeInput",eq.XK_Codeinput),e0("Compose",eq.XK_Multi_key),e0("Convert",eq.XK_Henkan),e0("GroupFirst",eq.XK_ISO_First_Group),e0("GroupLast",eq.XK_ISO_Last_Group),e0("GroupNext",eq.XK_ISO_Next_Group),e0("GroupPrevious",eq.XK_ISO_Prev_Group),e0("NonConvert",eq.XK_Muhenkan),e0("PreviousCandidate",eq.XK_PreviousCandidate),e0("SingleCandidate",eq.XK_SingleCandidate),e0("HangulMode",eq.XK_Hangul),e0("HanjaMode",eq.XK_Hangul_Hanja),e0("JunjaMode",eq.XK_Hangul_Jeonja),e0("Eisu",eq.XK_Eisu_toggle),e0("Hankaku",eq.XK_Hankaku),e0("Hiragana",eq.XK_Hiragana),e0("HiraganaKatakana",eq.XK_Hiragana_Katakana),e0("KanaMode",eq.XK_Kana_Shift),e0("KanjiMode",eq.XK_Kanji),e0("Katakana",eq.XK_Katakana),e0("Romaji",eq.XK_Romaji),e0("Zenkaku",eq.XK_Zenkaku),e0("ZenkakuHankaku",eq.XK_Zenkaku_Hankaku),e0("F1",eq.XK_F1),e0("F2",eq.XK_F2),e0("F3",eq.XK_F3),e0("F4",eq.XK_F4),e0("F5",eq.XK_F5),e0("F6",eq.XK_F6),e0("F7",eq.XK_F7),e0("F8",eq.XK_F8),e0("F9",eq.XK_F9),e0("F10",eq.XK_F10),e0("F11",eq.XK_F11),e0("F12",eq.XK_F12),e0("F13",eq.XK_F13),e0("F14",eq.XK_F14),e0("F15",eq.XK_F15),e0("F16",eq.XK_F16),e0("F17",eq.XK_F17),e0("F18",eq.XK_F18),e0("F19",eq.XK_F19),e0("F20",eq.XK_F20),e0("F21",eq.XK_F21),e0("F22",eq.XK_F22),e0("F23",eq.XK_F23),e0("F24",eq.XK_F24),e0("F25",eq.XK_F25),e0("F26",eq.XK_F26),e0("F27",eq.XK_F27),e0("F28",eq.XK_F28),e0("F29",eq.XK_F29),e0("F30",eq.XK_F30),e0("F31",eq.XK_F31),e0("F32",eq.XK_F32),e0("F33",eq.XK_F33),e0("F34",eq.XK_F34),e0("F35",eq.XK_F35),e0("Close",eq.XF86XK_Close),e0("MailForward",eq.XF86XK_MailForward),e0("MailReply",eq.XF86XK_Reply),e0("MailSend",eq.XF86XK_Send),e0("MediaFastForward",eq.XF86XK_AudioForward),e0("MediaPause",eq.XF86XK_AudioPause),e0("MediaPlay",eq.XF86XK_AudioPlay),e0("MediaRecord",eq.XF86XK_AudioRecord),e0("MediaRewind",eq.XF86XK_AudioRewind),e0("MediaStop",eq.XF86XK_AudioStop),e0("MediaTrackNext",eq.XF86XK_AudioNext),e0("MediaTrackPrevious",eq.XF86XK_AudioPrev),e0("New",eq.XF86XK_New),e0("Open",eq.XF86XK_Open),e0("Print",eq.XK_Print),e0("Save",eq.XF86XK_Save),e0("SpellCheck",eq.XF86XK_Spell),e0("AudioVolumeDown",eq.XF86XK_AudioLowerVolume),e0("AudioVolumeUp",eq.XF86XK_AudioRaiseVolume),e0("AudioVolumeMute",eq.XF86XK_AudioMute),e0("MicrophoneVolumeMute",eq.XF86XK_AudioMicMute),e0("LaunchApplication1",eq.XF86XK_MyComputer),e0("LaunchApplication2",eq.XF86XK_Calculator),e0("LaunchCalendar",eq.XF86XK_Calendar),e0("LaunchMail",eq.XF86XK_Mail),e0("LaunchMediaPlayer",eq.XF86XK_AudioMedia),e0("LaunchMusicPlayer",eq.XF86XK_Music),e0("LaunchPhone",eq.XF86XK_Phone),e0("LaunchScreenSaver",eq.XF86XK_ScreenSaver),e0("LaunchSpreadsheet",eq.XF86XK_Excel),e0("LaunchWebBrowser",eq.XF86XK_WWW),e0("LaunchWebCam",eq.XF86XK_WebCam),e0("LaunchWordProcessor",eq.XF86XK_Word),e0("BrowserBack",eq.XF86XK_Back),e0("BrowserFavorites",eq.XF86XK_Favorites),e0("BrowserForward",eq.XF86XK_Forward),e0("BrowserHome",eq.XF86XK_HomePage),e0("BrowserRefresh",eq.XF86XK_Refresh),e0("BrowserSearch",eq.XF86XK_Search),e0("BrowserStop",eq.XF86XK_Stop),e0("Dimmer",eq.XF86XK_BrightnessAdjust),e0("MediaAudioTrack",eq.XF86XK_AudioCycleTrack),e0("RandomToggle",eq.XF86XK_AudioRandomPlay),e0("SplitScreenToggle",eq.XF86XK_SplitScreen),e0("Subtitle",eq.XF86XK_Subtitle),e0("VideoModeNext",eq.XF86XK_Next_VMode),e5("=",eq.XK_equal,eq.XK_KP_Equal),e5("+",eq.XK_plus,eq.XK_KP_Add),e5("-",eq.XK_minus,eq.XK_KP_Subtract),e5("*",eq.XK_asterisk,eq.XK_KP_Multiply),e5("/",eq.XK_slash,eq.XK_KP_Divide),e5(".",eq.XK_period,eq.XK_KP_Decimal),e5(",",eq.XK_comma,eq.XK_KP_Separator),e5("0",eq.XK_0,eq.XK_KP_0),e5("1",eq.XK_1,eq.XK_KP_1),e5("2",eq.XK_2,eq.XK_KP_2),e5("3",eq.XK_3,eq.XK_KP_3),e5("4",eq.XK_4,eq.XK_KP_4),e5("5",eq.XK_5,eq.XK_KP_5),e5("6",eq.XK_6,eq.XK_KP_6),e5("7",eq.XK_7,eq.XK_KP_7),e5("8",eq.XK_8,eq.XK_KP_8),e5("9",eq.XK_9,eq.XK_KP_9);class e6{constructor(e){this._target=e||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(e,t,s){if(s)this._keyDownList[t]=e;else{if(!(t in this._keyDownList))return;delete this._keyDownList[t]}_("onkeyevent "+(s?"down":"up")+", keysym: "+e,", code: "+t),this.onkeyevent(e,t,s)}_getKeyCode(e){let t=e3(e);return"Unidentified"!==t?t:e.keyCode&&229!==e.keyCode?"Platform"+e.keyCode:e.keyIdentifier?"U+"!==e.keyIdentifier.substr(0,2)?e.keyIdentifier:"Platform"+String.fromCharCode(parseInt(e.keyIdentifier.substr(2),16)).toUpperCase().charCodeAt():"Unidentified"}_handleKeyDown(e){let t=this._getKeyCode(e),s=function(e){let t=function(e){if(void 0!==e.key){switch(e.key){case"OS":return"Meta";case"LaunchMyComputer":return"LaunchApplication1";case"LaunchCalculator":return"LaunchApplication2"}switch(e.key){case"UIKeyInputUpArrow":return"ArrowUp";case"UIKeyInputDownArrow":return"ArrowDown";case"UIKeyInputLeftArrow":return"ArrowLeft";case"UIKeyInputRightArrow":return"ArrowRight";case"UIKeyInputEscape":return"Escape"}return"\0"===e.key&&"NumpadDecimal"===e.code?"Delete":e.key}let t=e3(e);return t in e$?e$[t]:e.charCode?String.fromCharCode(e.charCode):"Unidentified"}(e);if("Unidentified"===t)return null;if(t in e1){let s=e.location;if("Meta"===t&&0===s&&(s=2),"Clear"===t&&3===s&&"NumLock"===e3(e)&&(s=0),(void 0===s||s>3)&&(s=0),"Meta"===t){let t=e3(e);if("AltLeft"===t)return eq.XK_Meta_L;if("AltRight"===t)return eq.XK_Meta_R}if("Clear"===t&&"NumLock"===e3(e))return eq.XK_Num_Lock;if(k())switch(t){case"Zenkaku":case"Hankaku":return eq.XK_Zenkaku_Hankaku;case"Romaji":case"KanaMode":return eq.XK_Romaji}return e1[t][s]}if(1!==t.length)return null;let s=t.charCodeAt();return s?eZ.lookup(s):null}(e);if(this._altGrArmed&&(this._altGrArmed=!1,clearTimeout(this._altGrTimeout),"AltRight"===t&&e.timeStamp-this._altGrCtrlTime<50?s=eq.XK_ISO_Level3_Shift:this._sendKeyEvent(eq.XK_Control_L,"ControlLeft",!0)),"Unidentified"===t){s&&(this._sendKeyEvent(s,t,!0),this._sendKeyEvent(s,t,!1)),K(e);return}if(v()||y())switch(s){case eq.XK_Super_L:s=eq.XK_Alt_L;break;case eq.XK_Super_R:s=eq.XK_Super_L;break;case eq.XK_Alt_L:s=eq.XK_Mode_switch;break;case eq.XK_Alt_R:s=eq.XK_ISO_Level3_Shift}if(t in this._keyDownList&&(s=this._keyDownList[t]),(v()||y())&&"CapsLock"===t){this._sendKeyEvent(eq.XK_Caps_Lock,"CapsLock",!0),this._sendKeyEvent(eq.XK_Caps_Lock,"CapsLock",!1),K(e);return}let i=[eq.XK_Zenkaku_Hankaku,eq.XK_Eisu_toggle,eq.XK_Katakana,eq.XK_Hiragana,eq.XK_Romaji];if(k()&&i.includes(s)){this._sendKeyEvent(s,t,!0),this._sendKeyEvent(s,t,!1),K(e);return}if(K(e),"ControlLeft"===t&&k()&&!("ControlLeft"in this._keyDownList)){this._altGrArmed=!0,this._altGrTimeout=setTimeout(this._handleAltGrTimeout.bind(this),100),this._altGrCtrlTime=e.timeStamp;return}this._sendKeyEvent(s,t,!0)}_handleKeyUp(e){K(e);let t=this._getKeyCode(e);if(this._altGrArmed&&(this._altGrArmed=!1,clearTimeout(this._altGrTimeout),this._sendKeyEvent(eq.XK_Control_L,"ControlLeft",!0)),(v()||y())&&"CapsLock"===t){this._sendKeyEvent(eq.XK_Caps_Lock,"CapsLock",!0),this._sendKeyEvent(eq.XK_Caps_Lock,"CapsLock",!1);return}this._sendKeyEvent(this._keyDownList[t],t,!1),k()&&("ShiftLeft"===t||"ShiftRight"===t)&&("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(eq.XK_Control_L,"ControlLeft",!0)}_allKeysUp(){for(let e in _(">> Keyboard.allKeysUp"),this._keyDownList)this._sendKeyEvent(this._keyDownList[e],e,!1);_("<< 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()}}class e4{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(e){this.detach(),this._target=e,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(e){let t;switch(e.stopPropagation(),e.preventDefault(),e.type){case"touchstart":t=this._touchStart;break;case"touchmove":t=this._touchMove;break;case"touchend":case"touchcancel":t=this._touchEnd}for(let s=0;s0&&Date.now()-this._tracked[0].started>250||this._waitingRelease){this._state=0,this._ignored.push(e);return}switch(this._tracked.push({id:e,started:Date.now(),active:!0,firstX:t,firstY:s,lastX:t,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(e,t,s){let i=this._tracked.find(t=>t.id===e);if(void 0===i)return;i.lastX=t,i.lastY=s;let r=t-i.firstX,n=s-i.firstY;if((i.firstX!==i.lastX||i.firstY!==i.lastY)&&(i.angle=180*Math.atan2(n,r)/Math.PI),!this._hasDetectedGesture()){if(50>Math.hypot(r,n))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 t=this._tracked.find(t=>t.id!==e);if(Math.hypot(t.firstX-t.lastX,t.firstY-t.lastY)>50){let e=Math.abs(i.angle-t.angle);(e=Math.abs((e+180)%360-180))>90?this._state&=-33:this._state&=-65,this._isTwoTouchTimeoutRunning()&&this._stopTwoTouchTimeout()}else this._isTwoTouchTimeoutRunning()||this._startTwoTouchTimeout()}if(!this._hasDetectedGesture())return;this._pushEvent("gesturestart")}this._pushEvent("gesturemove")}_touchEnd(e,t,s){if(-1!==this._ignored.indexOf(e)){this._ignored.splice(this._ignored.indexOf(e),1),0===this._ignored.length&&0===this._tracked.length&&(this._state=127,this._waitingRelease=!1);return}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(e=>Date.now()-e.started>1e3)&&(this._state=0),this._tracked.find(t=>t.id===e).active=!1,this._hasDetectedGesture())this._pushEvent("gesturestart");else if(0!==this._state)return}this._hasDetectedGesture()&&this._pushEvent("gestureend");for(let e=0;ee.active))}_startLongpressTimeout(){this._stopLongpressTimeout(),this._longpressTimeoutId=setTimeout(()=>this._longpressTimeout(),1e3)}_stopLongpressTimeout(){clearTimeout(this._longpressTimeoutId),this._longpressTimeoutId=null}_longpressTimeout(){if(this._hasDetectedGesture())throw 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 Error("A pinch or two drag gesture failed, no tracked touches");let e=this._getAverageMovement(),t=Math.abs(e.x),s=Math.abs(e.y),i=this._getAverageDistance(),r=Math.abs(Math.hypot(i.first.x,i.first.y)-Math.hypot(i.last.x,i.last.y));s{this._target&&(t=document.elementFromPoint(e.clientX,e.clientY),this._updateVisibility(t))},0)}_showCursor(){"hidden"===this._canvas.style.visibility&&(this._canvas.style.visibility="")}_hideCursor(){"hidden"!==this._canvas.style.visibility&&(this._canvas.style.visibility="hidden")}_shouldShowCursor(e){return!!e&&(e===this._target||!!this._target.contains(e)&&"none"===window.getComputedStyle(e).cursor)}_updateVisibility(e){this._captureIsActive()&&(e=document.captureElement),this._shouldShowCursor(e)?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)}}let e9={CONNECTING:[WebSocket.CONNECTING,"connecting"],OPEN:[WebSocket.OPEN,"open"],CLOSING:[WebSocket.CLOSING,"closing"],CLOSED:[WebSocket.CLOSED,"closed"]},te=["send","close","binaryType","onerror","onmessage","onopen","protocol","readyState"];class tt{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 e;return null===this._websocket?"unused":(e=this._websocket.readyState,e9.CONNECTING.includes(e))?"connecting":e9.OPEN.includes(e)?"open":e9.CLOSING.includes(e)?"closing":e9.CLOSED.includes(e)?"closed":"unknown"}get sQ(){return this._sQ}get rQ(){return this._rQ}get rQi(){return this._rQi}set rQi(e){this._rQi=e}get rQlen(){return this._rQlen-this._rQi}rQpeek8(){return this._rQ[this._rQi]}rQskipBytes(e){this._rQi+=e}rQshift8(){return this._rQshift(1)}rQshift16(){return this._rQshift(2)}rQshift32(){return this._rQshift(4)}_rQshift(e){let t=0;for(let s=e-1;s>=0;s--)t+=this._rQ[this._rQi++]<<8*s;return t}rQshiftStr(e){void 0===e&&(e=this.rQlen);let t="";for(let s=0;s0&&"open"===this.readyState&&(this._websocket.send(this._encodeMessage()),this._sQlen=0)}send(e){this._sQ.set(e,this._sQlen),this._sQlen+=e.length,this.flush()}sendString(e){this.send(e.split("").map(e=>e.charCodeAt(0)))}off(e){this._eventHandlers[e]=()=>{}}on(e,t){this._eventHandlers[e]=t}_allocateBuffers(){this._rQ=new Uint8Array(this._rQbufferSize),this._sQ=new Uint8Array(this._sQbufferSize)}init(){this._allocateBuffers(),this._rQi=0,this._websocket=null}open(e,t){this.attach(new WebSocket(e,t))}attach(e){this.init();let t=[...Object.keys(e),...Object.getOwnPropertyNames(Object.getPrototypeOf(e))];for(let e=0;et.indexOf(s))throw Error("Raw channel missing property: "+s)}this._websocket=e,this._websocket.binaryType="arraybuffer",this._websocket.onmessage=this._recvMessage.bind(this),this._websocket.onopen=()=>{_(">> WebSock.onopen"),this._websocket.protocol&&d("Server choose sub-protocol: "+this._websocket.protocol),this._eventHandlers.open(),_("<< WebSock.onopen")},this._websocket.onclose=e=>{_(">> WebSock.onclose"),this._eventHandlers.close(e),_("<< WebSock.onclose")},this._websocket.onerror=e=>{_(">> WebSock.onerror: "+e),this._eventHandlers.error(e),_("<< WebSock.onerror: "+e)}}close(){this._websocket&&(("connecting"===this.readyState||"open"===this.readyState)&&(d("Closing WebSocket connection"),this._websocket.close()),this._websocket.onmessage=()=>{})}_encodeMessage(){return new Uint8Array(this._sQ.buffer,0,this._sQlen)}_expandCompactRQ(e){let t=(this._rQlen-this._rQi+e)*8,s=this._rQbufferSize41943040&&(this._rQbufferSize=41943040,this._rQbufferSize-this.rQlenthis._rQbufferSize-this._rQlen&&this._expandCompactRQ(t.length),this._rQ.set(t,this._rQlen),this._rQlen+=t.length}_recvMessage(e){this._DecodeMessage(e.data),this.rQlen>0?(this._eventHandlers.message(),this._rQlen==this._rQi&&(this._rQlen=0,this._rQi=0)):_("Ignoring empty message")}}let ts=[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],ti=[1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28];n=(i=65536)|(r=16777216),h=(a=4)|(o=1024);let tr=[n|o,0,0|i,n|h,n|a,i|h,0|a,0|i,0|o,n|o,n|h,0|o,r|h,n|a,0|r,0|a,0|h,r|o,r|o,i|o,i|o,0|n,0|n,r|h,i|a,r|a,r|a,i|a,0,0|h,i|h,0|r,0|i,n|h,0|a,0|n,n|o,0|r,0|r,0|o,n|a,0|i,i|o,r|a,0|o,0|a,r|h,i|h,n|h,i|a,0|n,r|h,r|a,0|h,i|h,n|o,0|h,r|o,r|o,0,i|a,i|o,0,n|a],tn=[(n=(i=1048576)|(r=-2147483648))|(h=(a=32)|(o=32768)),r|o,0|o,i|h,0|i,0|a,n|a,r|h,r|a,n|h,n|o,0|r,r|o,0|i,0|a,n|a,i|o,i|a,r|h,0,0|r,0|o,i|h,0|n,i|a,r|a,0,i|o,0|h,n|o,0|n,0|h,0,i|h,n|a,0|i,r|h,0|n,n|o,0|o,0|n,r|o,0|a,n|h,i|h,0|a,0|o,0|r,0|h,n|o,0|i,r|a,i|a,r|h,r|a,i|a,i|o,0,r|o,0|h,0|r,n|a,n|h,i|o];n=(i=131072)|(r=134217728);let ta=[0|(h=(a=8)|(o=512)),n|o,0,n|a,r|o,0,i|h,r|o,i|a,r|a,r|a,0|i,n|h,i|a,0|n,0|h,0|r,0|a,n|o,0|o,i|o,0|n,n|a,i|h,r|h,i|o,0|i,r|h,0|a,n|h,0|o,0|r,n|o,0|r,i|a,0|h,0|i,n|o,r|o,0,0|o,i|a,n|h,r|o,r|a,0|o,0,n|a,r|h,0|i,0|r,n|h,0|a,i|h,i|o,r|a,0|n,r|h,0|h,0|n,i|h,0|a,n|a,i|o];n=(i=8192)|(r=8388608),h=(a=1)|(o=128);let to=[n|a,i|h,i|h,0|o,n|o,r|h,r|a,i|a,0,0|n,0|n,n|h,0|h,0,r|o,r|a,0|a,0|i,0|r,n|a,0|o,0|r,i|a,i|o,r|h,0|a,i|o,r|o,0|i,n|o,n|h,0|h,r|o,r|a,0|n,n|h,0|h,0,0,0|n,i|o,r|o,r|h,0|a,n|a,i|h,i|h,0|o,n|h,0|h,0|a,0|i,r|a,i|a,n|o,r|h,i|a,i|o,0|r,n|a,0|o,0|r,0|i,n|o];n=(i=33554432)|(r=1073741824),h=(a=256)|(o=524288);let th=[0|a,i|h,i|o,n|a,0|o,0|a,0|r,i|o,r|h,0|o,i|a,r|h,n|a,n|o,0|h,0|r,0|i,r|o,r|o,0,r|a,n|h,n|h,i|a,n|o,r|a,0,0|n,i|h,0|i,0|n,0|h,0|o,n|a,0|a,0|i,0|r,i|o,n|a,r|h,i|a,0|r,n|o,i|h,r|h,0|a,0|i,n|o,n|h,0|h,0|n,n|h,i|o,0,r|o,0|n,0|h,i|a,r|a,0|o,0,r|o,i|h,r|a];n=(i=4194304)|(r=536870912),h=(a=16)|(o=16384);let tl=[r|a,0|n,0|o,n|h,0|n,0|a,n|h,0|i,r|o,i|h,0|i,r|a,i|a,r|o,0|r,0|h,0,i|a,r|h,0|o,i|o,r|h,0|a,n|a,n|a,0,i|h,n|o,0|h,i|o,n|o,0|r,r|o,0|a,n|a,i|o,n|h,0|i,0|h,r|a,0|i,r|o,0|r,0|h,r|a,n|h,i|o,0|n,i|h,n|o,0,n|a,0|a,0|o,0|n,i|h,0|o,i|a,r|h,0,n|o,0|r,i|a,r|h];n=(i=2097152)|(r=67108864),h=(a=2)|(o=2048);let t_=[0|i,n|a,r|h,0,0|o,r|h,i|h,n|o,n|h,0|i,0,r|a,0|a,0|r,n|a,0|h,r|o,i|h,i|a,r|o,r|a,0|n,n|o,i|a,0|n,0|o,0|h,n|h,i|o,0|a,0|r,i|o,0|r,i|o,0|i,r|h,r|h,n|a,n|a,0|a,i|a,0|r,r|o,0|i,n|o,0|h,i|h,n|o,0|h,r|a,n|h,0|n,i|o,0,0|a,n|h,0,i|h,0|n,0|o,r|a,r|o,0|o,i|a];n=(i=262144)|(r=268435456);let td=[r|(h=(a=64)|(o=4096)),0|o,0|i,n|h,0|r,r|h,0|a,0|r,i|a,0|n,n|h,i|o,n|o,i|h,0|o,0|a,0|n,r|a,r|o,0|h,i|o,i|a,n|a,n|o,0|h,0,0,n|a,r|a,r|o,i|h,0|i,i|h,0|i,n|o,0|o,0|a,n|a,0|o,i|h,r|o,0|a,r|a,0|n,n|a,0|r,0|i,r|h,0,n|h,i|a,r|a,0|n,r|o,r|h,0,n|h,i|o,i|o,0|h,0|h,i|a,0|r,n|o];class tc{constructor(e){this.keys=[];let t=[],s=[],i=[];for(let s=0,i=56;s<56;++s,i-=8){let r=7&(i+=i<-5?65:i<-3?31:i<-1?63:27===i?35:0);t[s]=(e[i>>>3]&1<>>10,this.keys[s]|=(4032&r)>>>6,++s,this.keys[s]=(258048&e)<<12,this.keys[s]|=(63&e)<<16,this.keys[s]|=(258048&r)>>>4,this.keys[s]|=63&r,++s}}enc8(e){let t=e.slice(),s=0,i,r,n;n=((i=t[s++]<<24|t[s++]<<16|t[s++]<<8|t[s++])>>>4^(r=t[s++]<<24|t[s++]<<16|t[s++]<<8|t[s++]))&252645135,r^=n,i^=n<<4,n=(i>>>16^r)&65535,r^=n,i^=n<<16,n=(r>>>2^i)&858993459,i^=n,r^=n<<2,n=(r>>>8^i)&16711935,i^=n,r^=n<<8,n=(i^(r=r<<1|r>>>31&1))&2863311530,i^=n,r^=n,i=i<<1|i>>>31&1;for(let e=0,t=0;e<8;++e){let e=t_[63&(n=(r<<28|r>>>4)^this.keys[t++])];e|=th[n>>>8&63],e|=ta[n>>>16&63],e|=tr[n>>>24&63],e|=td[63&(n=r^this.keys[t++])],e|=tl[n>>>8&63],e|=to[n>>>16&63],e|=tn[n>>>24&63],i^=e,r^=e=t_[63&(n=(i<<28|i>>>4)^this.keys[t++])]|th[n>>>8&63]|ta[n>>>16&63]|tr[n>>>24&63]|td[63&(n=i^this.keys[t++])]|tl[n>>>8&63]|to[n>>>16&63]|tn[n>>>24&63]}for(n=(i^(r=r<<31|r>>>1))&2863311530,i^=n,r^=n,n=((i=i<<31|i>>>1)>>>8^r)&16711935,r^=n,i^=n<<8,n=(i>>>2^r)&858993459,r^=n,i^=n<<2,n=(r>>>16^i)&65535,i^=n,r^=n<<16,n=(r>>>4^i)&252645135,i^=n,r^=n<<4,n=[r,i],s=0;s<8;s++)t[s]=(n[s>>>2]>>>8*(3-s%4))%256,t[s]<0&&(t[s]+=256);return t}encrypt(e){return this.enc8(e.slice(0,8)).concat(this.enc8(e.slice(8,16)))}}var tu={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};let tf={encodingRaw:0,encodingCopyRect:1,encodingRRE:2,encodingHextile:5,encodingTight:7,encodingTightPNG:-260,pseudoEncodingQualityLevel0:-32,pseudoEncodingDesktopSize:-223,pseudoEncodingLastRect:-224,pseudoEncodingCursor:-239,pseudoEncodingQEMUExtendedKeyEvent:-258,pseudoEncodingDesktopName:-307,pseudoEncodingExtendedDesktopSize:-308,pseudoEncodingXvp:-309,pseudoEncodingFence:-312,pseudoEncodingContinuousUpdates:-313,pseudoEncodingCompressLevel0:-256,pseudoEncodingVMwareCursor:1464686180,pseudoEncodingExtendedClipboard:3231835598};class tp{constructor(){this._lines=0}decodeRect(e,t,s,i,r,n,a){if(0===s||0===i)return!0;0===this._lines&&(this._lines=i);let o=s*(8==a?1:4);if(r.rQwait("RAW",o))return!1;let h=t+(i-this._lines),l=Math.min(this._lines,Math.floor(r.rQlen/o)),_=s*l,d=r.rQ,c=r.rQi;if(8==a){let e=new Uint8Array(4*_);for(let t=0;t<_;t++)e[4*t+0]=(d[c+t]>>0&3)*255/3,e[4*t+1]=(d[c+t]>>2&3)*255/3,e[4*t+2]=(d[c+t]>>4&3)*255/3,e[4*t+3]=255;d=e,c=0}for(let e=0;e<_;e++)d[4*e+3]=255;return n.blitImage(e,h,s,l,d,c),r.rQskipBytes(l*o),this._lines-=l,!(this._lines>0)}}class tg{decodeRect(e,t,s,i,r,n,a){if(r.rQwait("COPYRECT",4))return!1;let o=r.rQshift16(),h=r.rQshift16();return 0===s||0===i||(n.copyImage(o,h,e,t,s,i),!0)}}class tm{constructor(){this._subrects=0}decodeRect(e,t,s,i,r,n,a){if(0===this._subrects){if(r.rQwait("RRE",8))return!1;this._subrects=r.rQshift32();let a=r.rQshiftBytes(4);n.fillRect(e,t,s,i,a)}for(;this._subrects>0;){if(r.rQwait("RRE",12))return!1;let s=r.rQshiftBytes(4),i=r.rQshift16(),a=r.rQshift16(),o=r.rQshift16(),h=r.rQshift16();n.fillRect(e+i,t+a,o,h,s),this._subrects--}return!0}}class tw{constructor(){this._tiles=0,this._lastsubencoding=0,this._tileBuffer=new Uint8Array(1024)}decodeRect(e,t,s,i,r,n,a){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 a=1;if(r.rQwait("HEXTILE",a))return!1;let o=r.rQ,h=r.rQi,l=o[h];if(l>30)throw Error("Illegal hextile subencoding (subencoding: "+l+")");let d=this._totalTiles-this._tiles,c=d%this._tilesX,u=Math.floor(d/this._tilesX),f=e+16*c,p=t+16*u,g=Math.min(16,e+s-f),m=Math.min(16,t+i-p);if(1&l)a+=g*m*4;else if(2&l&&(a+=4),4&l&&(a+=4),8&l){if(a++,r.rQwait("HEXTILE",a))return!1;let e=o[h+a-1];16&l?a+=6*e:a+=2*e}if(r.rQwait("HEXTILE",a))return!1;if(h++,0===l)1&this._lastsubencoding?_(" Ignoring blank after RAW"):n.fillRect(f,p,g,m,this._background);else if(1&l){let e=g*m;for(let t=0;t>4,i=15&t,r=o[++h];h++;let n=(r>>4)+1,a=(15&r)+1;this._subTile(s,i,n,a,e)}}this._finishTile(n)}r.rQi=h,this._lastsubencoding=l,this._tiles--}return!0}_startTile(e,t,s,i,r){this._tileX=e,this._tileY=t,this._tileW=s,this._tileH=i;let n=r[0],a=r[1],o=r[2],h=this._tileBuffer;for(let e=0;e>e&1&&(this._zlibs[e].reset(),d("Reset zlib stream "+e));this._ctl=this._ctl>>4}if(8===this._ctl)o=this._fillRect(e,t,s,i,r,n,a);else if(9===this._ctl)o=this._jpegRect(e,t,s,i,r,n,a);else if(10===this._ctl)o=this._pngRect(e,t,s,i,r,n,a);else if((8&this._ctl)==0)o=this._basicRect(this._ctl,e,t,s,i,r,n,a);else throw Error("Illegal tight compression received (ctl: "+this._ctl+")");return o&&(this._ctl=null),o}_fillRect(e,t,s,i,r,n,a){if(r.rQwait("TIGHT",3))return!1;let o=r.rQi,h=r.rQ;return n.fillRect(e,t,s,i,[h[o],h[o+1],h[o+2]],!1),r.rQskipBytes(3),!0}_jpegRect(e,t,s,i,r,n,a){let o=this._readData(r);return null!==o&&(n.imageRect(e,t,s,i,"image/jpeg",o),!0)}_pngRect(e,t,s,i,r,n,a){throw Error("PNG received in standard Tight rect")}_basicRect(e,t,s,i,r,n,a,o){let h;if(null===this._filter){if(4&e){if(n.rQwait("TIGHT",1))return!1;this._filter=n.rQshift8()}else this._filter=0}let l=3&e;switch(this._filter){case 0:h=this._copyFilter(l,t,s,i,r,n,a,o);break;case 1:h=this._paletteFilter(l,t,s,i,r,n,a,o);break;case 2:h=this._gradientFilter(l,t,s,i,r,n,a,o);break;default:throw Error("Illegal tight filter received (ctl: "+this._filter+")")}return h&&(this._filter=null),h}_copyFilter(e,t,s,i,r,n,a,o){let h;let l=i*r*3;if(0===l)return!0;if(l<12){if(n.rQwait("TIGHT",l))return!1;h=n.rQshiftBytes(l)}else{if(null===(h=this._readData(n)))return!1;this._zlibs[e].setInput(h),h=this._zlibs[e].inflate(l),this._zlibs[e].setInput(null)}let _=new Uint8Array(i*r*4);for(let e=0,t=0;e=0;l--)t=(e*s+8*a+7-l)*4,i=(r[e*h+a]>>l&1)*3,o[t]=n[i],o[t+1]=n[i+1],o[t+2]=n[i+2],o[t+3]=255;for(let l=7;l>=8-s%8;l--)t=(e*s+8*a+7-l)*4,i=(r[e*h+a]>>l&1)*3,o[t]=n[i],o[t+1]=n[i+1],o[t+2]=n[i+2],o[t+3]=255}a.blitImage(e,t,s,i,o,0,!1)}_paletteRect(e,t,s,i,r,n,a){let o=this._getScratchBuffer(s*i*4),h=s*i*4;for(let e=0,t=0;e> 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 e7,this._cursorImage=tk.cursors.none,this._decoders[tf.encodingRaw]=new tp,this._decoders[tf.encodingCopyRect]=new tg,this._decoders[tf.encodingRRE]=new tm,this._decoders[tf.encodingHextile]=new tw,this._decoders[tf.encodingTight]=new tb,this._decoders[tf.encodingTightPNG]=new tv;try{this._display=new z(this._canvas)}catch(e){throw u("Display exception: "+e),e}this._display.onflush=this._onFlush.bind(this),this._keyboard=new e6(this._canvas),this._keyboard.onkeyevent=this._handleKeyEvent.bind(this),this._gestures=new e4,this._sock=new tt,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"),_("<< 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&&(c("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(e){this._viewOnly=e,("connecting"===this._rfbConnectionState||"connected"===this._rfbConnectionState)&&(e?this._keyboard.ungrab():this._keyboard.grab())}get capabilities(){return this._capabilities}get touchButton(){return 0}set touchButton(e){c("Using old API!")}get clipViewport(){return this._clipViewport}set clipViewport(e){this._clipViewport=e,this._updateClip()}get scaleViewport(){return this._scaleViewport}set scaleViewport(e){this._scaleViewport=e,e&&this._clipViewport&&this._updateClip(),this._updateScale(),!e&&this._clipViewport&&this._updateClip()}get resizeSession(){return this._resizeSession}set resizeSession(e){this._resizeSession=e,e&&this._requestRemoteResize()}get showDotCursor(){return this._showDotCursor}set showDotCursor(e){this._showDotCursor=e,this._refreshCursor()}get background(){return this._screen.style.background}set background(e){this._screen.style.background=e}get qualityLevel(){return this._qualityLevel}set qualityLevel(e){if(!Number.isInteger(e)||e<0||e>9){u("qualityLevel must be an integer between 0 and 9");return}this._qualityLevel!==e&&(this._qualityLevel=e,"connected"===this._rfbConnectionState&&this._sendEncodings())}get compressionLevel(){return this._compressionLevel}set compressionLevel(e){if(!Number.isInteger(e)||e<0||e>9){u("compressionLevel must be an integer between 0 and 9");return}this._compressionLevel!==e&&(this._compressionLevel=e,"connected"===this._rfbConnectionState&&this._sendEncodings())}disconnect(){this._updateConnectionState("disconnecting"),this._sock.off("error"),this._sock.off("message"),this._sock.off("open")}sendCredentials(e){this._rfbCredentials=e,setTimeout(this._initMsg.bind(this),0)}sendCtrlAltDel(){"connected"!==this._rfbConnectionState||this._viewOnly||(d("Sending Ctrl-Alt-Del"),this.sendKey(eq.XK_Control_L,"ControlLeft",!0),this.sendKey(eq.XK_Alt_L,"AltLeft",!0),this.sendKey(eq.XK_Delete,"Delete",!0),this.sendKey(eq.XK_Delete,"Delete",!1),this.sendKey(eq.XK_Alt_L,"AltLeft",!1),this.sendKey(eq.XK_Control_L,"ControlLeft",!1))}machineShutdown(){this._xvpOp(1,2)}machineReboot(){this._xvpOp(1,3)}machineReset(){this._xvpOp(1,4)}sendKey(e,t,s){if("connected"!==this._rfbConnectionState||this._viewOnly)return;if(void 0===s){this.sendKey(e,t,!0),this.sendKey(e,t,!1);return}let i=tu[t];if(this._qemuExtKeyEventSupported&&i)d("Sending key ("+(s?"down":"up")+"): keysym "+(e=e||0)+", scancode "+i),tk.messages.QEMUExtendedKeyEvent(this._sock,e,s,i);else{if(!e)return;d("Sending keysym ("+(s?"down":"up")+"): "+e),tk.messages.keyEvent(this._sock,e,s?1:0)}}focus(){this._canvas.focus()}blur(){this._canvas.blur()}clipboardPasteFrom(e){if("connected"===this._rfbConnectionState&&!this._viewOnly){if(this._clipboardServerCapabilitiesFormats[1]&&this._clipboardServerCapabilitiesActions[134217728])this._clipboardText=e,tk.messages.extendedClipboardNotify(this._sock,[1]);else{let t=new Uint8Array(e.length);for(let s=0;s> RFB.connect"),this._url)d(`connecting to ${this._url}`),this._sock.open(this._url,this._wsProtocols);else{if(d(`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),_("<< RFB.connect")}_disconnect(){_(">> 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(e){if("NotFoundError"===e.name);else throw e}clearTimeout(this._resizeTimeout),clearTimeout(this._mouseMoveTimer),_("<< RFB.disconnect")}_socketOpen(){"connecting"===this._rfbConnectionState&&""===this._rfbInitState?(this._rfbInitState="ProtocolVersion",_("Starting VNC handshake")):this._fail("Unexpected server connection while "+this._rfbConnectionState)}_socketClose(e){_("WebSocket on-close event");let t="";switch(e.code&&(t="(code: "+e.code,e.reason&&(t+=", reason: "+e.reason),t+=")"),this._rfbConnectionState){case"connecting":this._fail("Connection closed "+t);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 "+t);break;default:this._fail("Unexpected server disconnect before connecting "+t)}this._sock.off("close"),this._rawChannel=null}_socketError(e){c("WebSocket on-error event")}_focusCanvas(e){this.focusOnClick&&this.focus()}_setDesktopName(e){this._fbName=e,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(){let e=this._display.clipViewport,t=this._clipViewport;if(this._scaleViewport&&(t=!1),e!==t&&(this._display.clipViewport=t),t){let e=this._screenSize();this._display.viewportChangeSize(e.w,e.h),this._fixScrollbars()}}_updateScale(){if(this._scaleViewport){let e=this._screenSize();this._display.autoscale(e.w,e.h)}else this._display.scale=1;this._fixScrollbars()}_requestRemoteResize(){if(clearTimeout(this._resizeTimeout),this._resizeTimeout=null,!this._resizeSession||this._viewOnly||!this._supportsSetDesktopSize)return;let e=this._screenSize();tk.messages.setDesktopSize(this._sock,Math.floor(e.w),Math.floor(e.h),this._screenID,this._screenFlags),_("Requested new desktop size: "+e.w+"x"+e.h)}_screenSize(){let e=this._screen.getBoundingClientRect();return{w:e.width,h:e.height}}_fixScrollbars(){let e=this._screen.style.overflow;this._screen.style.overflow="hidden",this._screen.getBoundingClientRect(),this._screen.style.overflow=e}_updateConnectionState(e){let t=this._rfbConnectionState;if(e===t){_("Already in state '"+e+"', ignoring");return}if("disconnected"===t){u("Tried changing state of a disconnected RFB object");return}switch(e){case"connected":if("connecting"!==t){u("Bad transition to connected state, previous connection state: "+t);return}break;case"disconnected":if("disconnecting"!==t){u("Bad transition to disconnected state, previous connection state: "+t);return}break;case"connecting":if(""!==t){u("Bad transition to connecting state, previous connection state: "+t);return}break;case"disconnecting":if("connected"!==t&&"connecting"!==t){u("Bad transition to disconnecting state, previous connection state: "+t);return}break;default:u("Unknown connection state: "+e);return}switch(this._rfbConnectionState=e,_("New state '"+e+"', was '"+t+"'."),this._disconnTimer&&"disconnecting"!==e&&(_("Clearing disconnect timer"),clearTimeout(this._disconnTimer),this._disconnTimer=null,this._sock.off("close")),e){case"connecting":this._connect();break;case"connected":this.dispatchEvent(new CustomEvent("connect",{detail:{}}));break;case"disconnecting":this._disconnect(),this._disconnTimer=setTimeout(()=>{u("Disconnection timed out."),this._updateConnectionState("disconnected")},3e3);break;case"disconnected":this.dispatchEvent(new CustomEvent("disconnect",{detail:{clean:this._rfbCleanDisconnect}}))}}_fail(e){switch(this._rfbConnectionState){case"disconnecting":u("Failed when disconnecting: "+e);break;case"connected":u("Failed while connected: "+e);break;case"connecting":u("Failed when connecting: "+e);break;default:u("RFB failure: "+e)}return this._rfbCleanDisconnect=!1,this._updateConnectionState("disconnecting"),this._updateConnectionState("disconnected"),!1}_setCapability(e,t){this._capabilities[e]=t,this.dispatchEvent(new CustomEvent("capabilities",{detail:{capabilities:this._capabilities}}))}_handleMessage(){if(0===this._sock.rQlen){c("handleMessage called on an empty receive queue");return}switch(this._rfbConnectionState){case"disconnected":u("Got data while disconnected");break;case"connected":for(;!this._flushing&&this._normalMsg()&&0!==this._sock.rQlen;);break;default:this._initMsg()}}_handleKeyEvent(e,t,s){this.sendKey(e,t,s)}_handleMouse(e){if("click"===e.type&&e.target!==this._canvas||(e.stopPropagation(),e.preventDefault(),"click"===e.type||"contextmenu"===e.type))return;let t=X(e.clientX,e.clientY,this._canvas);switch(e.type){case"mousedown":!function(e){if(e.setCapture)e.setCapture(),document.captureElement=e;else{M();let t=document.getElementById("noVNC_mouse_capture_elem");null===t&&((t=document.createElement("div")).id="noVNC_mouse_capture_elem",t.style.position="fixed",t.style.top="0px",t.style.left="0px",t.style.width="100%",t.style.height="100%",t.style.zIndex=1e4,t.style.display="none",document.body.appendChild(t),t.addEventListener("contextmenu",S),t.addEventListener("mousemove",S),t.addEventListener("mouseup",S)),document.captureElement=e,E.observe(e,{attributes:!0}),x(),t.style.display="",window.addEventListener("mousemove",S),window.addEventListener("mouseup",S)}}(this._canvas),this._handleMouseButton(t.x,t.y,!0,1<m||Math.abs(i)>m)&&(this._viewportHasMoved=!0,this._viewportDragPos={x:e,y:t},this._display.viewportChangePos(s,i));return}if(this._mousePos={x:e,y:t},null==this._mouseMoveTimer){let s=Date.now()-this._mouseLastMoveTime;s>17?(this._sendMouse(e,t,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(e,t,s){"connected"!==this._rfbConnectionState||this._viewOnly||tk.messages.pointerEvent(this._sock,this._display.absX(e),this._display.absY(t),s)}_handleWheel(e){if("connected"!==this._rfbConnectionState||this._viewOnly)return;e.stopPropagation(),e.preventDefault();let t=X(e.clientX,e.clientY,this._canvas),s=e.deltaX,i=e.deltaY;0!==e.deltaMode&&(s*=19,i*=19),this._accumulatedWheelDeltaX+=s,this._accumulatedWheelDeltaY+=i,Math.abs(this._accumulatedWheelDeltaX)>=50&&(this._accumulatedWheelDeltaX<0?(this._handleMouseButton(t.x,t.y,!0,32),this._handleMouseButton(t.x,t.y,!1,32)):this._accumulatedWheelDeltaX>0&&(this._handleMouseButton(t.x,t.y,!0,64),this._handleMouseButton(t.x,t.y,!1,64)),this._accumulatedWheelDeltaX=0),Math.abs(this._accumulatedWheelDeltaY)>=50&&(this._accumulatedWheelDeltaY<0?(this._handleMouseButton(t.x,t.y,!0,8),this._handleMouseButton(t.x,t.y,!1,8)):this._accumulatedWheelDeltaY>0&&(this._handleMouseButton(t.x,t.y,!0,16),this._handleMouseButton(t.x,t.y,!1,16)),this._accumulatedWheelDeltaY=0)}_fakeMouseMove(e,t,s){this._handleMouseMove(t,s),this._cursor.move(e.detail.clientX,e.detail.clientY)}_handleTapEvent(e,t){let s=X(e.detail.clientX,e.detail.clientY,this._canvas);null!==this._gestureLastTapTime&&Date.now()-this._gestureLastTapTime<1e3&&this._gestureFirstDoubleTapEv.detail.type===e.detail.type&&50>Math.hypot(this._gestureFirstDoubleTapEv.detail.clientX-e.detail.clientX,this._gestureFirstDoubleTapEv.detail.clientY-e.detail.clientY)?s=X(this._gestureFirstDoubleTapEv.detail.clientX,this._gestureFirstDoubleTapEv.detail.clientY,this._canvas):this._gestureFirstDoubleTapEv=e,this._gestureLastTapTime=Date.now(),this._fakeMouseMove(this._gestureFirstDoubleTapEv,s.x,s.y),this._handleMouseButton(s.x,s.y,!0,t),this._handleMouseButton(s.x,s.y,!1,t)}_handleGesture(e){let t;let s=X(e.detail.clientX,e.detail.clientY,this._canvas);switch(e.type){case"gesturestart":switch(e.detail.type){case"onetap":this._handleTapEvent(e,1);break;case"twotap":this._handleTapEvent(e,4);break;case"threetap":this._handleTapEvent(e,2);break;case"drag":this._fakeMouseMove(e,s.x,s.y),this._handleMouseButton(s.x,s.y,!0,1);break;case"longpress":this._fakeMouseMove(e,s.x,s.y),this._handleMouseButton(s.x,s.y,!0,4);break;case"twodrag":this._gestureLastMagnitudeX=e.detail.magnitudeX,this._gestureLastMagnitudeY=e.detail.magnitudeY,this._fakeMouseMove(e,s.x,s.y);break;case"pinch":this._gestureLastMagnitudeX=Math.hypot(e.detail.magnitudeX,e.detail.magnitudeY),this._fakeMouseMove(e,s.x,s.y)}break;case"gesturemove":switch(e.detail.type){case"onetap":case"twotap":case"threetap":break;case"drag":case"longpress":this._fakeMouseMove(e,s.x,s.y);break;case"twodrag":for(this._fakeMouseMove(e,s.x,s.y);e.detail.magnitudeY-this._gestureLastMagnitudeY>50;)this._handleMouseButton(s.x,s.y,!0,8),this._handleMouseButton(s.x,s.y,!1,8),this._gestureLastMagnitudeY+=50;for(;e.detail.magnitudeY-this._gestureLastMagnitudeY<-50;)this._handleMouseButton(s.x,s.y,!0,16),this._handleMouseButton(s.x,s.y,!1,16),this._gestureLastMagnitudeY-=50;for(;e.detail.magnitudeX-this._gestureLastMagnitudeX>50;)this._handleMouseButton(s.x,s.y,!0,32),this._handleMouseButton(s.x,s.y,!1,32),this._gestureLastMagnitudeX+=50;for(;e.detail.magnitudeX-this._gestureLastMagnitudeX<-50;)this._handleMouseButton(s.x,s.y,!0,64),this._handleMouseButton(s.x,s.y,!1,64),this._gestureLastMagnitudeX-=50;break;case"pinch":if(this._fakeMouseMove(e,s.x,s.y),Math.abs((t=Math.hypot(e.detail.magnitudeX,e.detail.magnitudeY))-this._gestureLastMagnitudeX)>75){for(this._handleKeyEvent(eq.XK_Control_L,"ControlLeft",!0);t-this._gestureLastMagnitudeX>75;)this._handleMouseButton(s.x,s.y,!0,8),this._handleMouseButton(s.x,s.y,!1,8),this._gestureLastMagnitudeX+=75;for(;t-this._gestureLastMagnitudeX<-75;)this._handleMouseButton(s.x,s.y,!0,16),this._handleMouseButton(s.x,s.y,!1,16),this._gestureLastMagnitudeX-=75}this._handleKeyEvent(eq.XK_Control_L,"ControlLeft",!1)}break;case"gestureend":switch(e.detail.type){case"onetap":case"twotap":case"threetap":case"pinch":case"twodrag":break;case"drag":this._fakeMouseMove(e,s.x,s.y),this._handleMouseButton(s.x,s.y,!1,1);break;case"longpress":this._fakeMouseMove(e,s.x,s.y),this._handleMouseButton(s.x,s.y,!1,4)}}}_negotiateProtocolVersion(){if(this._sock.rQwait("version",12))return!1;let e=this._sock.rQshiftStr(12).substr(4,7);d("Server ProtocolVersion: "+e);let t=0;switch(e){case"000.000":t=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 "+e)}if(t){let e="ID:"+this._repeaterID;for(;e.length<250;)e+="\0";return this._sock.sendString(e),!0}this._rfbVersion>this._rfbMaxVersion&&(this._rfbVersion=this._rfbMaxVersion);let s="00"+parseInt(this._rfbVersion,10)+".00"+10*this._rfbVersion%10;this._sock.sendString("RFB "+s+"\n"),_("Sent ProtocolVersion: "+s),this._rfbInitState="Security"}_negotiateSecurity(){if(this._rfbVersion>=3.7){let e=this._sock.rQshift8();if(this._sock.rQwait("security type",e,1))return!1;if(0===e)return this._rfbInitState="SecurityReason",this._securityContext="no security types",this._securityStatus=1,this._initMsg();let t=this._sock.rQshiftBytes(e);if(_("Server security types: "+t),t.includes(1))this._rfbAuthScheme=1;else if(t.includes(22))this._rfbAuthScheme=22;else if(t.includes(16))this._rfbAuthScheme=16;else if(t.includes(2))this._rfbAuthScheme=2;else{if(!t.includes(19))return this._fail("Unsupported security types (types: "+t+")");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",_("Authenticating using scheme: "+this._rfbAuthScheme),this._initMsg()}_handleSecurityReason(){if(this._sock.rQwait("reason length",4))return!1;let e=this._sock.rQshift32(),t="";if(e>0){if(this._sock.rQwait("reason",e,4))return!1;t=this._sock.rQshiftStr(e)}return""!==t?(this.dispatchEvent(new CustomEvent("securityfailure",{detail:{status:this._securityStatus,reason:t}})),this._fail("Security negotiation failed on "+this._securityContext+" (reason: "+t+")")):(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;let e=String.fromCharCode(this._rfbCredentials.username.length)+String.fromCharCode(this._rfbCredentials.target.length)+this._rfbCredentials.username+this._rfbCredentials.target;return this._sock.sendString(e),this._rfbAuthScheme=2,this._negotiateAuthentication()}_negotiateVeNCryptAuth(){if(0==this._rfbVeNCryptState){if(this._sock.rQwait("vencrypt version",2))return!1;let e=this._sock.rQshift8(),t=this._sock.rQshift8();if(!(0==e&&2==t))return this._fail("Unsupported VeNCrypt version "+e+"."+t);this._sock.send([0,2]),this._rfbVeNCryptState=1}if(1==this._rfbVeNCryptState){if(this._sock.rQwait("vencrypt ack",1))return!1;let e=this._sock.rQshift8();if(0!=e)return this._fail("VeNCrypt failure "+e);this._rfbVeNCryptState=2}if(2==this._rfbVeNCryptState){if(this._sock.rQwait("vencrypt subtypes length",1))return!1;let e=this._sock.rQshift8();if(e<1)return this._fail("VeNCrypt subtypes empty");this._rfbVeNCryptSubtypesLength=e,this._rfbVeNCryptState=3}if(3==this._rfbVeNCryptState){if(this._sock.rQwait("vencrypt subtypes",4*this._rfbVeNCryptSubtypesLength))return!1;let e=[];for(let t=0;t>24&255,e.length>>16&255,e.length>>8&255,255&e.length]),this._sock.send([t.length>>24&255,t.length>>16&255,t.length>>8&255,255&t.length]),this._sock.sendString(e),this._sock.sendString(t),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;let e=Array.prototype.slice.call(this._sock.rQshiftBytes(16)),t=tk.genDES(this._rfbCredentials.password,e);return this._sock.send(t),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(e){let t={0:{vendor:"TGHT",signature:"NOTUNNEL"}},s={};for(let t=0;t0&&this._sock.rQwait("tunnel capabilities",16*e,4))return!1;if(this._rfbTightVNC=!0,e>0)return this._negotiateTightTunnels(e),!1}if(this._sock.rQwait("sub auth count",4))return!1;let e=this._sock.rQshift32();if(0===e)return this._rfbInitState="SecurityResult",!0;if(this._sock.rQwait("sub auth capabilities",16*e,4))return!1;let t={STDVNOAUTH__:1,STDVVNCAUTH_:2,TGHTULGNAUTH:129},s=[];for(let t=0;t=3.8)return this._rfbInitState="SecurityResult",!0;return 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;let e=this._sock.rQshift32();return 0===e?(this._rfbInitState="ClientInitialisation",_("Authentication OK"),this._initMsg()):this._rfbVersion>=3.8?(this._rfbInitState="SecurityReason",this._securityContext="security result",this._securityStatus=e,this._initMsg()):(this.dispatchEvent(new CustomEvent("securityfailure",{detail:{status:e}})),this._fail("Security handshake failed"))}_negotiateServerInit(){if(this._sock.rQwait("server initialization",24))return!1;let e=this._sock.rQshift16(),t=this._sock.rQshift16(),s=this._sock.rQshift8(),i=this._sock.rQshift8(),r=this._sock.rQshift8(),n=this._sock.rQshift8(),a=this._sock.rQshift16(),o=this._sock.rQshift16(),h=this._sock.rQshift16(),l=this._sock.rQshift8(),_=this._sock.rQshift8(),u=this._sock.rQshift8();this._sock.rQskipBytes(3);let p=this._sock.rQshift32();if(this._sock.rQwait("server init name",p,24))return!1;let g=this._sock.rQshiftStr(p);if(g=f(g,!0),this._rfbTightVNC){if(this._sock.rQwait("TightVNC extended server init header",8,24+p))return!1;let e=this._sock.rQshift16(),t=this._sock.rQshift16(),s=this._sock.rQshift16();if(this._sock.rQskipBytes(2),this._sock.rQwait("TightVNC extended server init header",(e+t+s)*16,32+p))return!1;this._sock.rQskipBytes(16*e),this._sock.rQskipBytes(16*t),this._sock.rQskipBytes(16*s)}return d("Screen: "+e+"x"+t+", bpp: "+s+", depth: "+i+", bigEndian: "+r+", trueColor: "+n+", redMax: "+a+", greenMax: "+o+", blueMax: "+h+", redShift: "+l+", greenShift: "+_+", blueShift: "+u),this._setDesktopName(g),this._resize(e,t),this._viewOnly||this._keyboard.grab(),this._fbDepth=24,"Intel(r) AMT KVM"===this._fbName&&(c("Intel AMT KVM only supports 8/16 bit depths. Using low color mode."),this._fbDepth=8),tk.messages.pixelFormat(this._sock,this._fbDepth,!0),this._sendEncodings(),tk.messages.fbUpdateRequest(this._sock,!1,0,0,this._fbWidth,this._fbHeight),this._updateConnectionState("connected"),!0}_sendEncodings(){let e=[];e.push(tf.encodingCopyRect),24==this._fbDepth&&(e.push(tf.encodingTight),e.push(tf.encodingTightPNG),e.push(tf.encodingHextile),e.push(tf.encodingRRE)),e.push(tf.encodingRaw),e.push(tf.pseudoEncodingQualityLevel0+this._qualityLevel),e.push(tf.pseudoEncodingCompressLevel0+this._compressionLevel),e.push(tf.pseudoEncodingDesktopSize),e.push(tf.pseudoEncodingLastRect),e.push(tf.pseudoEncodingQEMUExtendedKeyEvent),e.push(tf.pseudoEncodingExtendedDesktopSize),e.push(tf.pseudoEncodingXvp),e.push(tf.pseudoEncodingFence),e.push(tf.pseudoEncodingContinuousUpdates),e.push(tf.pseudoEncodingDesktopName),e.push(tf.pseudoEncodingExtendedClipboard),24==this._fbDepth&&(e.push(tf.pseudoEncodingVMwareCursor),e.push(tf.pseudoEncodingCursor)),tk.messages.clientEncodings(this._sock,e)}_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 _("SetColorMapEntries"),this._fail("Unexpected SetColorMapEntries message")}_handleServerCutText(){if(_("ServerCutText"),this._sock.rQwait("ServerCutText header",7,1))return!1;this._sock.rQskipBytes(3);let e=this._sock.rQshift32();if(e|=0,this._sock.rQwait("ServerCutText content",Math.abs(e),8))return!1;if(e>=0){let t=this._sock.rQshiftStr(e);if(this._viewOnly)return!0;this.dispatchEvent(new CustomEvent("clipboard",{detail:{text:t}}))}else{e=Math.abs(e);let t=this._sock.rQshift32(),s=65535&t,i=4278190080&t;if(16777216&i){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 e=this._sock.rQshift32(),t=this._sock.rQshift8();if(this._sock.rQwait("ServerFence payload",t,9))return!1;t>64&&(c("Bad payload length ("+t+") in fence response"),t=64);let s=this._sock.rQshiftStr(t);return(this._supportsFence=!0,-2147483648&e)?(e&=3,tk.messages.clientFence(this._sock,e,s),!0):this._fail("Unexpected fence response")}_handleXvpMsg(){if(this._sock.rQwait("XVP version and message",3,1))return!1;this._sock.rQskipBytes(1);let e=this._sock.rQshift8(),t=this._sock.rQshift8();switch(t){case 0:u("XVP Operation Failed");break;case 1:this._rfbXvpVer=e,d("XVP extensions enabled (version "+this._rfbXvpVer+")"),this._setCapability("power",!0);break;default:this._fail("Illegal server XVP message (msg: "+t+")")}return!0}_normalMsg(){let e,t,s;switch(e=this._FBU.rects>0?0:this._sock.rQshift8()){case 0:return(s=this._framebufferUpdate())&&!this._enabledContinuousUpdates&&tk.messages.fbUpdateRequest(this._sock,!0,0,0,this._fbWidth,this._fbHeight),s;case 1:return this._handleSetColourMapMsg();case 2:return _("Bell"),this.dispatchEvent(new CustomEvent("bell",{detail:{}})),!0;case 3:return this._handleServerCutText();case 150:return t=!this._supportsContinuousUpdates,this._supportsContinuousUpdates=!0,this._enabledContinuousUpdates=!1,t&&(this._enabledContinuousUpdates=!0,this._updateContinuousUpdates(),d("Enabling continuous updates.")),!0;case 248:return this._handleServerFenceMsg();case 250:return this._handleXvpMsg();default:return this._fail("Unexpected server message (type "+e+")"),_("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;let e=this._sock.rQshiftBytes(12);this._FBU.x=(e[0]<<8)+e[1],this._FBU.y=(e[2]<<8)+e[3],this._FBU.width=(e[4]<<8)+e[5],this._FBU.height=(e[6]<<8)+e[7],this._FBU.encoding=parseInt((e[8]<<24)+(e[9]<<16)+(e[10]<<8)+e[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 tf.pseudoEncodingLastRect:return this._FBU.rects=1,!0;case tf.pseudoEncodingVMwareCursor:return this._handleVMwareCursor();case tf.pseudoEncodingCursor:return this._handleCursor();case tf.pseudoEncodingQEMUExtendedKeyEvent:return this._qemuExtKeyEventSupported=!0,!0;case tf.pseudoEncodingDesktopName:return this._handleDesktopName();case tf.pseudoEncodingDesktopSize:return this._resize(this._FBU.width,this._FBU.height),!0;case tf.pseudoEncodingExtendedDesktopSize:return this._handleExtendedDesktopSize();default:return this._handleDataRect()}}_handleVMwareCursor(){let e;let t=this._FBU.x,s=this._FBU.y,i=this._FBU.width,r=this._FBU.height;if(this._sock.rQwait("VMware cursor encoding",1))return!1;let n=this._sock.rQshift8();if(this._sock.rQshift8(),0==n){if(e=Array(i*r*4),this._sock.rQwait("VMware cursor classic encoding",i*r*8,2))return!1;let t=Array(i*r);for(let e=0;e>8&255,r=t>>16&255,a=t>>24&255;e[4*n]=i,e[4*n+1]=r,e[4*n+2]=a,e[4*n+3]=255}else(-256&t[n])==-256?0==s[n]?(e[4*n]=0,e[4*n+1]=0,e[4*n+2]=0,e[4*n+3]=0):(s[n],e[4*n]=0,e[4*n+1]=0,e[4*n+2]=0,e[4*n+3]=255):(e[4*n]=0,e[4*n+1]=0,e[4*n+2]=0,e[4*n+3]=255)}else{if(1!=n)return c("The given cursor type is not supported: "+n+" given."),!1;if(this._sock.rQwait("VMware cursor alpha encoding",i*r*4,2))return!1;e=Array(i*r*4);for(let t=0;t>24&255,e[4*t+1]=s>>16&255,e[4*t+2]=s>>8&255,e[4*t+3]=255&s}}return this._updateCursor(e,t,s,i,r),!0}_handleCursor(){let e=this._FBU.x,t=this._FBU.y,s=this._FBU.width,i=this._FBU.height,r=s*i*4,n=Math.ceil(s/8)*i;if(this._sock.rQwait("cursor encoding",r+n))return!1;let a=this._sock.rQshiftBytes(r),o=this._sock.rQshiftBytes(n),h=new Uint8Array(s*i*4),l=0;for(let e=0;ee.charCodeAt(0))).encrypt(t)}}tk.messages={keyEvent(e,t,s){let i=e._sQ,r=e._sQlen;i[r]=4,i[r+1]=s,i[r+2]=0,i[r+3]=0,i[r+4]=t>>24,i[r+5]=t>>16,i[r+6]=t>>8,i[r+7]=t,e._sQlen+=8,e.flush()},QEMUExtendedKeyEvent(e,t,s,i){let r=e._sQ,n=e._sQlen;r[n]=255,r[n+1]=0,r[n+2]=s>>8,r[n+3]=s,r[n+4]=t>>24,r[n+5]=t>>16,r[n+6]=t>>8,r[n+7]=t;let a=function(e){let t=i>>8,s=255&i;return 224===t&&s<127?128|s:e}(i);r[n+8]=a>>24,r[n+9]=a>>16,r[n+10]=a>>8,r[n+11]=a,e._sQlen+=12,e.flush()},pointerEvent(e,t,s,i){let r=e._sQ,n=e._sQlen;r[n]=5,r[n+1]=i,r[n+2]=t>>8,r[n+3]=t,r[n+4]=s>>8,r[n+5]=s,e._sQlen+=6,e.flush()},_buildExtendedClipboardFlags(e,t){let s=new Uint8Array(4),i=0,r=0;for(let t=0;t>24,s[1]=0,s[2]=0,s[3]=i,s},extendedClipboardProvide(e,t,s){let i=new eY,r=[];for(let e=0;e>24&255,i.length>>16&255,i.length>>8&255,255&i.length);for(let e=0;eparseInt(e)),i.sort((e,t)=>e-t),r.set(tk.messages._buildExtendedClipboardFlags(t,[]));let n=4;for(let e=0;e>24,r[n+1]=s[i[e]]>>16,r[n+2]=s[i[e]]>>8,r[n+3]=s[i[e]]>>0,n+=4,r[3]|=1<>>0:t.length,r[n+4]=i>>24,r[n+5]=i>>16,r[n+6]=i>>8,r[n+7]=i,e._sQlen+=8;let a=0,o=t.length;for(;o>0;){let s=Math.min(o,e._sQbufferSize-e._sQlen);for(let i=0;i>8,n[a+3]=t,n[a+4]=s>>8,n[a+5]=s,n[a+6]=1,n[a+7]=0,n[a+8]=i>>24,n[a+9]=i>>16,n[a+10]=i>>8,n[a+11]=i,n[a+12]=0,n[a+13]=0,n[a+14]=0,n[a+15]=0,n[a+16]=t>>8,n[a+17]=t,n[a+18]=s>>8,n[a+19]=s,n[a+20]=r>>24,n[a+21]=r>>16,n[a+22]=r>>8,n[a+23]=r,e._sQlen+=24,e.flush()},clientFence(e,t,s){let i=e._sQ,r=e._sQlen;i[r]=248,i[r+1]=0,i[r+2]=0,i[r+3]=0,i[r+4]=t>>24,i[r+5]=t>>16,i[r+6]=t>>8,i[r+7]=t;let n=s.length;i[r+8]=n;for(let e=0;e>8,a[o+3]=s,a[o+4]=i>>8,a[o+5]=i,a[o+6]=r>>8,a[o+7]=r,a[o+8]=n>>8,a[o+9]=n,e._sQlen+=10,e.flush()},pixelFormat(e,t,s){let i;let r=e._sQ,n=e._sQlen;i=t>16?32:t>8?16:8;let a=Math.floor(t/3);r[n]=0,r[n+1]=0,r[n+2]=0,r[n+3]=0,r[n+4]=i,r[n+5]=t,r[n+6]=0,r[n+7]=s?1:0,r[n+8]=0,r[n+9]=(1<>8,s[i+3]=t.length;let r=i+4;for(let e=0;e>24,s[r+1]=i>>16,s[r+2]=i>>8,s[r+3]=i,r+=4}e._sQlen+=r-i,e.flush()},fbUpdateRequest(e,t,s,i,r,n){let a=e._sQ,o=e._sQlen;void 0===s&&(s=0),void 0===i&&(i=0),a[o]=3,a[o+1]=t?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]=r>>8&255,a[o+7]=255&r,a[o+8]=n>>8&255,a[o+9]=255&n,e._sQlen+=10,e.flush()},xvpOp(e,t,s){let i=e._sQ,r=e._sQlen;i[r]=250,i[r+1]=0,i[r+2]=t,i[r+3]=s,e._sQlen+=4,e.flush()}},tk.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}}}}]);