Local modifications to ClusterLabs/Anvil by Alteeve
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

1 lines
144 KiB

"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[460],{94460:function(e,t,s){let i,a,r,n,o,h;s.d(t,{Z:function(){return RFB}});let d="warn",Debug=()=>{},Info=()=>{},Warn=()=>{},logging_Error=()=>{};function decodeUTF8(e,t=!1){try{return decodeURIComponent(escape(e))}catch(s){if(s instanceof URIError&&t)return e;throw s}}function encodeUTF8(e){return unescape(encodeURIComponent(e))}!function(e){if(void 0===e?e=d:d=e,Debug=Info=Warn=logging_Error=()=>{},void 0!==window.console)switch(e){case"debug":Debug=console.debug.bind(window.console);case"info":Info=console.info.bind(window.console);case"warn":Warn=console.warn.bind(window.console);case"error":logging_Error=console.error.bind(window.console);case"none":break;default:throw new window.Error("invalid logging type '"+e+"'")}}();let l="ontouchstart"in document.documentElement||void 0!==document.ontouchstart||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0;window.addEventListener("touchstart",function onFirstTouch(){l=!0,window.removeEventListener("touchstart",onFirstTouch,!1)},!1);let _=10*(window.devicePixelRatio||1),u=!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")?(Info("Data URI scheme cursor supported"),u=!0):Warn("Data URI scheme cursor not supported")}catch(e){logging_Error("Data URI scheme cursor test exception: "+e)}let c=u;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){logging_Error("Scrollbar test exception: "+e)}function isMac(){return navigator&&!!/mac/i.exec(navigator.platform)}function isWindows(){return navigator&&!!/win/i.exec(navigator.platform)}function isIOS(){return navigator&&(!!/ipad/i.exec(navigator.platform)||!!/iphone/i.exec(navigator.platform)||!!/ipod/i.exec(navigator.platform))}function clientToElement(e,t,s){let i=s.getBoundingClientRect(),a={x:0,y:0};return e<i.left?a.x=0:e>=i.right?a.x=i.width-1:a.x=e-i.left,t<i.top?a.y=0:t>=i.bottom?a.y=i.height-1:a.y=t-i.top,a}function stopEvent(e){e.stopPropagation(),e.preventDefault()}let f=!1,p=null;function _captureProxy(e){if(f)return;let t=new e.constructor(e.type,e);f=!0,document.captureElement?document.captureElement.dispatchEvent(t):p.dispatchEvent(t),f=!1,e.stopPropagation(),t.defaultPrevented&&e.preventDefault(),"mouseup"===e.type&&releaseCapture()}function _capturedElemChanged(){let e=document.getElementById("noVNC_mouse_capture_elem");e.style.cursor=window.getComputedStyle(document.captureElement).cursor}document.captureElement=null;let g=new MutationObserver(_capturedElemChanged);function releaseCapture(){if(document.releaseCapture)document.releaseCapture(),document.captureElement=null;else{if(!document.captureElement)return;p=document.captureElement,document.captureElement=null,g.disconnect();let e=document.getElementById("noVNC_mouse_capture_elem");e.style.display="none",window.removeEventListener("mousemove",_captureProxy),window.removeEventListener("mouseup",_captureProxy)}}let EventTargetMixin=class EventTargetMixin{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 m,b,w,v,k,y,X={toBase64Table:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".split(""),base64Pad:"=",encode(e){let t="",s=e.length,i=s%3;for(let i=0;i<s-2;i+=3)t+=this.toBase64Table[e[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 a=s-i;return 2===i?t+=this.toBase64Table[e[a]>>2]+this.toBase64Table[((3&e[a])<<4)+(e[a+1]>>4)]+this.toBase64Table[(15&e[a+1])<<2]+this.toBase64Table[64]:1===i&&(t+=this.toBase64Table[e[a]>>2]+this.toBase64Table[(3&e[a])<<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=(s>>2)*3+Math.floor(s%4/1.5),a=Array(i),r=0,n=0;for(let s=0,i=t;i<e.length;i++){let t=this.toBinaryTable[127&e.charCodeAt(i)],o=e.charAt(i)===this.base64Pad;if(-1===t){logging_Error("Illegal character code "+e.charCodeAt(i)+" at position "+i);continue}n=n<<6|t,(r+=6)>=8&&(r-=8,o||(a[s++]=n>>r&255),n&=(1<<r)-1)}if(r){let e=Error("Corrupted base64 string");throw e.name="Base64-Error",e}return a}};let Display=class Display{constructor(e){if(this._drawCtx=null,this._renderQ=[],this._flushing=!1,this._fbWidth=0,this._fbHeight=0,this._prevDrawStyle="",Debug(">> 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},Debug("User Agent: "+navigator.userAgent),Debug("<< 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,a=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),a+t>=this._fbHeight&&(t-=a+t-this._fbHeight+1),(0!==e||0!==t)&&(Debug("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||(Debug("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){e<this._damageBounds.left&&(this._damageBounds.left=e),t<this._damageBounds.top&&(this._damageBounds.top=t),e+s>this._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,a=e-this._viewportLoc.x,r=t-this._viewportLoc.y;a<0&&(s+=a,e-=a,a=0),r<0&&(i+=r,t-=r,r=0),a+s>this._viewportLoc.w&&(s=this._viewportLoc.w-a),r+i>this._viewportLoc.h&&(i=this._viewportLoc.h-r),s>0&&i>0&&this._targetCtx.drawImage(this._backbuffer,e,t,s,i,a,r,s,i),this._damageBounds.left=this._damageBounds.top=65535,this._damageBounds.right=this._damageBounds.bottom=0}else this._renderQPush({type:"flip"})}pending(){return this._renderQ.length>0}flush(){0===this._renderQ.length?this.onflush():this._flushing=!0}fillRect(e,t,s,i,a,r){0===this._renderQ.length||r?(this._setFillColor(a),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:a})}copyImage(e,t,s,i,a,r,n){0===this._renderQ.length||n?(this._drawCtx.mozImageSmoothingEnabled=!1,this._drawCtx.webkitImageSmoothingEnabled=!1,this._drawCtx.msImageSmoothingEnabled=!1,this._drawCtx.imageSmoothingEnabled=!1,this._drawCtx.drawImage(this._backbuffer,e,t,a,r,s,i,a,r),this._damage(s,i,a,r)):this._renderQPush({type:"copy",oldX:e,oldY:t,x:s,y:i,width:a,height:r})}imageRect(e,t,s,i,a,r){if(0===s||0===i)return;let n=new Image;n.src="data: "+a+";base64,"+X.encode(r),this._renderQPush({type:"img",img:n,x:e,y:t,width:s,height:i})}blitImage(e,t,s,i,a,r,n){if(0===this._renderQ.length||n){let n=new Uint8ClampedArray(a.buffer,a.byteOffset+r,s*i*4),o=new ImageData(n,s,i);this._drawCtx.putImageData(o,e,t),this._damage(e,t,s,i)}else{let r=new Uint8Array(s*i*4);r.set(new Uint8Array(a.buffer,0,r.length)),this._renderQPush({type:"blit",data:r,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,a=i.w/i.h;s=a>=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){logging_Error("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 arraySet(e,t,s,i,a){if(t.subarray&&e.subarray){e.set(t.subarray(s,s+i),a);return}for(var r=0;r<i;r++)e[a+r]=t[s+r]}var S=Uint8Array,K=Uint16Array,C=Int32Array;function adler32_adler32(e,t,s,i){for(var a=65535&e|0,r=e>>>16&65535|0,n=0;0!==s;){n=s>2e3?2e3:s,s-=n;do r=r+(a=a+t[i++]|0)|0;while(--n);a%=65521,r%=65521}return a|r<<16|0}function makeTable(){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}makeTable();var F=[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],x=[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],E=[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],M=[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 inflate_table(e,t,s,i,a,r,n,o){var h,d,l,_,u,c,f,p,g,m=o.bits,b=0,w=0,v=0,k=0,y=0,X=0,S=0,C=0,A=0,T=0,Q=null,D=0,L=new K(16),B=new K(16),R=null,P=0;for(b=0;b<=15;b++)L[b]=0;for(w=0;w<i;w++)L[t[s+w]]++;for(k=15,y=m;k>=1&&0===L[k];k--);if(y>k&&(y=k),0===k)return a[r++]=20971520,a[r++]=20971520,o.bits=1,0;for(v=1;v<k&&0===L[v];v++);for(y<v&&(y=v),C=1,b=1;b<=15;b++)if(C<<=1,(C-=L[b])<0)return -1;if(C>0&&(0===e||1!==k))return -1;for(b=1,B[1]=0;b<15;b++)B[b+1]=B[b]+L[b];for(w=0;w<i;w++)0!==t[s+w]&&(n[B[t[s+w]]++]=w);if(0===e?(Q=R=n,c=19):1===e?(Q=F,D-=257,R=x,P-=257,c=256):(Q=E,R=M,c=-1),T=0,w=0,b=v,u=r,X=y,S=0,l=-1,_=(A=1<<y)-1,1===e&&A>852||2===e&&A>592)return 1;for(;;){f=b-S,n[w]<c?(p=0,g=n[w]):n[w]>c?(p=R[P+n[w]],g=Q[D+n[w]]):(p=96,g=0),h=1<<b-S,v=d=1<<X;do a[u+(T>>S)+(d-=h)]=f<<24|p<<16|g|0;while(0!==d);for(h=1<<b-1;T&h;)h>>=1;if(0!==h?(T&=h-1,T+=h):T=0,w++,0==--L[b]){if(b===k)break;b=t[s+n[w]]}if(b>y&&(T&_)!==l){for(0===S&&(S=y),u+=v,C=1<<(X=b-S);X+S<k&&!((C-=L[X+S])<=0);)X++,C<<=1;if(A+=1<<X,1===e&&A>852||2===e&&A>592)return 1;a[l=T&_]=y<<24|X<<16|u-r|0}}return 0!==T&&(a[u+T]=b-S<<24|4194304),o.bits=y,0}function zswap32(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function InflateState(){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 K(320),this.work=new K(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function inflateReset(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 C(852),s.distcode=s.distdyn=new C(592),s.sane=1,s.back=-1,0):-2):-2}var A=!0;function ZStream(){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}let Inflate=class Inflate{constructor(){var e,t,s,i,a,r,n;this.strm=new ZStream,this.chunkSize=102400,this.strm.output=new Uint8Array(this.chunkSize),this.windowBits=5,e=this.strm,this.windowBits,s=0,!(t=e)||(i=new InflateState,t.state=i,i.window=null,a=15,0===(t&&t.state?(n=t.state,a<0?(r=0,a=-a):(r=(a>>4)+1,a<48&&(a&=15)),a&&(a<8||a>15))?-2:(null!==n.window&&n.wbits!==a&&(n.window=null),n.wrap=r,n.wbits=a,inflateReset(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,a,r,n,o,h,d,l,_,u,c,f,p,g,w,v,k,y,X,K,F,x,E,M,T,Q,D,L,B=0,R=new S(4),P=[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),_=e.next_out,d=e.output,c=e.avail_out,l=e.next_in,h=e.input,u=e.avail_in,f=o.hold,p=o.bits,g=u,w=c,Q=0;e:for(;;)switch(o.mode){case 1:if(0===o.wrap){o.mode=13;break}for(;p<16;){if(0===u)break e;u--,f+=h[l++]<<p,p+=8}if(2&o.wrap&&35615===f){o.check=0,R[0]=255&f,R[1]=f>>>8&255,o.check=makeTable(o.check,R,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,T=(15&f)+8,0===o.wbits)o.wbits=T;else if(T>o.wbits){e.msg="invalid window size",o.mode=30;break}o.dmax=1<<T,e.adler=o.check=1,o.mode=512&f?10:12,f=0,p=0;break;case 2:for(;p<16;){if(0===u)break e;u--,f+=h[l++]<<p,p+=8}if(o.flags=f,(255&o.flags)!=8){e.msg="unknown compression method",o.mode=30;break}if(57344&o.flags){e.msg="unknown header flags set",o.mode=30;break}o.head&&(o.head.text=f>>8&1),512&o.flags&&(R[0]=255&f,R[1]=f>>>8&255,o.check=makeTable(o.check,R,2,0)),f=0,p=0,o.mode=3;case 3:for(;p<32;){if(0===u)break e;u--,f+=h[l++]<<p,p+=8}o.head&&(o.head.time=f),512&o.flags&&(R[0]=255&f,R[1]=f>>>8&255,R[2]=f>>>16&255,R[3]=f>>>24&255,o.check=makeTable(o.check,R,4,0)),f=0,p=0,o.mode=4;case 4:for(;p<16;){if(0===u)break e;u--,f+=h[l++]<<p,p+=8}o.head&&(o.head.xflags=255&f,o.head.os=f>>8),512&o.flags&&(R[0]=255&f,R[1]=f>>>8&255,o.check=makeTable(o.check,R,2,0)),f=0,p=0,o.mode=5;case 5:if(1024&o.flags){for(;p<16;){if(0===u)break e;u--,f+=h[l++]<<p,p+=8}o.length=f,o.head&&(o.head.extra_len=f),512&o.flags&&(R[0]=255&f,R[1]=f>>>8&255,o.check=makeTable(o.check,R,2,0)),f=0,p=0}else o.head&&(o.head.extra=null);o.mode=6;case 6:if(1024&o.flags&&((v=o.length)>u&&(v=u),v&&(o.head&&(T=o.head.extra_len-o.length,o.head.extra||(o.head.extra=Array(o.head.extra_len)),arraySet(o.head.extra,h,l,v,T)),512&o.flags&&(o.check=makeTable(o.check,h,v,l)),u-=v,l+=v,o.length-=v),o.length))break e;o.length=0,o.mode=7;case 7:if(2048&o.flags){if(0===u)break e;v=0;do T=h[l+v++],o.head&&T&&o.length<65536&&(o.head.name+=String.fromCharCode(T));while(T&&v<u);if(512&o.flags&&(o.check=makeTable(o.check,h,v,l)),u-=v,l+=v,T)break e}else o.head&&(o.head.name=null);o.length=0,o.mode=8;case 8:if(4096&o.flags){if(0===u)break e;v=0;do T=h[l+v++],o.head&&T&&o.length<65536&&(o.head.comment+=String.fromCharCode(T));while(T&&v<u);if(512&o.flags&&(o.check=makeTable(o.check,h,v,l)),u-=v,l+=v,T)break e}else o.head&&(o.head.comment=null);o.mode=9;case 9:if(512&o.flags){for(;p<16;){if(0===u)break e;u--,f+=h[l++]<<p,p+=8}if(f!==(65535&o.check)){e.msg="header crc mismatch",o.mode=30;break}f=0,p=0}o.head&&(o.head.hcrc=o.flags>>9&1,o.head.done=!0),e.adler=o.check=0,o.mode=12;break;case 10:for(;p<32;){if(0===u)break e;u--,f+=h[l++]<<p,p+=8}e.adler=o.check=zswap32(f),f=0,p=0,o.mode=11;case 11:if(0===o.havedict)return e.next_out=_,e.avail_out=c,e.next_in=l,e.avail_in=u,o.hold=f,o.bits=p,2;e.adler=o.check=1,o.mode=12;case 12:if(5===t||6===t)break e;case 13:if(o.last){f>>>=7&p,p-=7&p,o.mode=27;break}for(;p<3;){if(0===u)break e;u--,f+=h[l++]<<p,p+=8}switch(o.last=1&f,p-=1,3&(f>>>=1)){case 0:o.mode=14;break;case 1:if(function(e){if(A){var t;for(m=new C(512),b=new C(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(inflate_table(1,e.lens,0,288,m,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;inflate_table(2,e.lens,0,32,b,0,e.work,{bits:5}),A=!1}e.lencode=m,e.lenbits=9,e.distcode=b,e.distbits=5}(o),o.mode=20,6===t){f>>>=2,p-=2;break e}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===u)break e;u--,f+=h[l++]<<p,p+=8}if((65535&f)!=(f>>>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(v=o.length){if(v>u&&(v=u),v>c&&(v=c),0===v)break e;arraySet(d,h,l,v,_),u-=v,l+=v,c-=v,_+=v,o.length-=v;break}o.mode=12;break;case 17:for(;p<14;){if(0===u)break e;u--,f+=h[l++]<<p,p+=8}if(o.nlen=(31&f)+257,f>>>=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<o.ncode;){for(;p<3;){if(0===u)break e;u--,f+=h[l++]<<p,p+=8}o.lens[P[o.have++]]=7&f,f>>>=3,p-=3}for(;o.have<19;)o.lens[P[o.have++]]=0;if(o.lencode=o.lendyn,o.lenbits=7,D={bits:o.lenbits},Q=inflate_table(0,o.lens,0,19,o.lencode,0,o.work,D),o.lenbits=D.bits,Q){e.msg="invalid code lengths set",o.mode=30;break}o.have=0,o.mode=19;case 19:for(;o.have<o.nlen+o.ndist;){for(;X=(B=o.lencode[f&(1<<o.lenbits)-1])>>>24,K=B>>>16&255,F=65535&B,!(X<=p);){if(0===u)break e;u--,f+=h[l++]<<p,p+=8}if(F<16)f>>>=X,p-=X,o.lens[o.have++]=F;else{if(16===F){for(L=X+2;p<L;){if(0===u)break e;u--,f+=h[l++]<<p,p+=8}if(f>>>=X,p-=X,0===o.have){e.msg="invalid bit length repeat",o.mode=30;break}T=o.lens[o.have-1],v=3+(3&f),f>>>=2,p-=2}else if(17===F){for(L=X+3;p<L;){if(0===u)break e;u--,f+=h[l++]<<p,p+=8}f>>>=X,p-=X,T=0,v=3+(7&f),f>>>=3,p-=3}else{for(L=X+7;p<L;){if(0===u)break e;u--,f+=h[l++]<<p,p+=8}f>>>=X,p-=X,T=0,v=11+(127&f),f>>>=7,p-=7}if(o.have+v>o.nlen+o.ndist){e.msg="invalid bit length repeat",o.mode=30;break}for(;v--;)o.lens[o.have++]=T}}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,D={bits:o.lenbits},Q=inflate_table(1,o.lens,0,o.nlen,o.lencode,0,o.work,D),o.lenbits=D.bits,Q){e.msg="invalid literal/lengths set",o.mode=30;break}if(o.distbits=6,o.distcode=o.distdyn,D={bits:o.distbits},Q=inflate_table(2,o.lens,o.nlen,o.ndist,o.distcode,0,o.work,D),o.distbits=D.bits,Q){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(u>=6&&c>=258){e.next_out=_,e.avail_out=c,e.next_in=l,e.avail_in=u,o.hold=f,o.bits=p,function(e,t){var s,i,a,r,n,o,h,d,l,_,u,c,f,p,g,m,b,w,v,k,y,X,S,K,C;s=e.state,i=e.next_in,K=e.input,a=i+(e.avail_in-5),r=e.next_out,C=e.output,n=r-(t-e.avail_out),o=r+(e.avail_out-257),h=s.dmax,d=s.wsize,l=s.whave,_=s.wnext,u=s.window,c=s.hold,f=s.bits,p=s.lencode,g=s.distcode,m=(1<<s.lenbits)-1,b=(1<<s.distbits)-1;t:do for(f<15&&(c+=K[i++]<<f,f+=8,c+=K[i++]<<f,f+=8),w=p[c&m];;){if(c>>>=v=w>>>24,f-=v,0==(v=w>>>16&255))C[r++]=65535&w;else if(16&v)for(k=65535&w,(v&=15)&&(f<v&&(c+=K[i++]<<f,f+=8),k+=c&(1<<v)-1,c>>>=v,f-=v),f<15&&(c+=K[i++]<<f,f+=8,c+=K[i++]<<f,f+=8),w=g[c&b];;){if(c>>>=v=w>>>24,f-=v,16&(v=w>>>16&255)){if(y=65535&w,f<(v&=15)&&(c+=K[i++]<<f,(f+=8)<v&&(c+=K[i++]<<f,f+=8)),(y+=c&(1<<v)-1)>h){e.msg="invalid distance too far back",s.mode=30;break t}if(c>>>=v,f-=v,y>(v=r-n)){if((v=y-v)>l&&s.sane){e.msg="invalid distance too far back",s.mode=30;break t}if(X=0,S=u,0===_){if(X+=d-v,v<k){k-=v;do C[r++]=u[X++];while(--v);X=r-y,S=C}}else if(_<v){if(X+=d+_-v,(v-=_)<k){k-=v;do C[r++]=u[X++];while(--v);if(X=0,_<k){k-=v=_;do C[r++]=u[X++];while(--v);X=r-y,S=C}}}else if(X+=_-v,v<k){k-=v;do C[r++]=u[X++];while(--v);X=r-y,S=C}for(;k>2;)C[r++]=S[X++],C[r++]=S[X++],C[r++]=S[X++],k-=3;k&&(C[r++]=S[X++],k>1&&(C[r++]=S[X++]))}else{X=r-y;do C[r++]=C[X++],C[r++]=C[X++],C[r++]=C[X++],k-=3;while(k>2);k&&(C[r++]=C[X++],k>1&&(C[r++]=C[X++]))}}else if((64&v)==0){w=g[(65535&w)+(c&(1<<v)-1)];continue}else{e.msg="invalid distance code",s.mode=30;break t}break}else if((64&v)==0){w=p[(65535&w)+(c&(1<<v)-1)];continue}else if(32&v){s.mode=12;break t}else{e.msg="invalid literal/length code",s.mode=30;break t}break}while(i<a&&r<o);i-=k=f>>3,f-=k<<3,c&=(1<<f)-1,e.next_in=i,e.next_out=r,e.avail_in=i<a?5+(a-i):5-(i-a),e.avail_out=r<o?257+(o-r):257-(r-o),s.hold=c,s.bits=f}(e,w),_=e.next_out,d=e.output,c=e.avail_out,l=e.next_in,h=e.input,u=e.avail_in,f=o.hold,p=o.bits,12===o.mode&&(o.back=-1);break}for(o.back=0;X=(B=o.lencode[f&(1<<o.lenbits)-1])>>>24,K=B>>>16&255,F=65535&B,!(X<=p);){if(0===u)break e;u--,f+=h[l++]<<p,p+=8}if(K&&(240&K)==0){for(x=X,E=K,M=F;X=(B=o.lencode[M+((f&(1<<x+E)-1)>>x)])>>>24,K=B>>>16&255,F=65535&B,!(x+X<=p);){if(0===u)break e;u--,f+=h[l++]<<p,p+=8}f>>>=x,p-=x,o.back+=x}if(f>>>=X,p-=X,o.back+=X,o.length=F,0===K){o.mode=26;break}if(32&K){o.back=-1,o.mode=12;break}if(64&K){e.msg="invalid literal/length code",o.mode=30;break}o.extra=15&K,o.mode=22;case 22:if(o.extra){for(L=o.extra;p<L;){if(0===u)break e;u--,f+=h[l++]<<p,p+=8}o.length+=f&(1<<o.extra)-1,f>>>=o.extra,p-=o.extra,o.back+=o.extra}o.was=o.length,o.mode=23;case 23:for(;X=(B=o.distcode[f&(1<<o.distbits)-1])>>>24,K=B>>>16&255,F=65535&B,!(X<=p);){if(0===u)break e;u--,f+=h[l++]<<p,p+=8}if((240&K)==0){for(x=X,E=K,M=F;X=(B=o.distcode[M+((f&(1<<x+E)-1)>>x)])>>>24,K=B>>>16&255,F=65535&B,!(x+X<=p);){if(0===u)break e;u--,f+=h[l++]<<p,p+=8}f>>>=x,p-=x,o.back+=x}if(f>>>=X,p-=X,o.back+=X,64&K){e.msg="invalid distance code",o.mode=30;break}o.offset=F,o.extra=15&K,o.mode=24;case 24:if(o.extra){for(L=o.extra;p<L;){if(0===u)break e;u--,f+=h[l++]<<p,p+=8}o.offset+=f&(1<<o.extra)-1,f>>>=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===c)break e;if(v=w-c,o.offset>v){if((v=o.offset-v)>o.whave&&o.sane){e.msg="invalid distance too far back",o.mode=30;break}v>o.wnext?(v-=o.wnext,k=o.wsize-v):k=o.wnext-v,v>o.length&&(v=o.length),y=o.window}else y=d,k=_-o.offset,v=o.length;v>c&&(v=c),c-=v,o.length-=v;do d[_++]=y[k++];while(--v);0===o.length&&(o.mode=21);break;case 26:if(0===c)break e;d[_++]=o.length,c--,o.mode=21;break;case 27:if(o.wrap){for(;p<32;){if(0===u)break e;u--,f|=h[l++]<<p,p+=8}if(w-=c,e.total_out+=w,o.total+=w,w&&(e.adler=o.check=o.flags?makeTable(o.check,d,w,_-w):adler32_adler32(o.check,d,w,_-w)),w=c,(o.flags?f:zswap32(f))!==o.check){e.msg="incorrect data check",o.mode=30;break}f=0,p=0}o.mode=28;case 28:if(o.wrap&&o.flags){for(;p<32;){if(0===u)break e;u--,f+=h[l++]<<p,p+=8}if(f!==(4294967295&o.total)){e.msg="incorrect length check",o.mode=30;break}f=0,p=0}o.mode=29;case 29:Q=1;break e;case 30:Q=-3;break e;case 31:return -4;default:return -2}return e.next_out=_,e.avail_out=c,e.next_in=l,e.avail_in=u,o.hold=f,o.bits=p,(o.wsize||w!==e.avail_out&&o.mode<30&&(o.mode<27||4!==t))&&(s=e.output,i=e.next_out,a=w-e.avail_out,null===(n=e.state).window&&(n.wsize=1<<n.wbits,n.wnext=0,n.whave=0,n.window=new S(n.wsize)),a>=n.wsize?(arraySet(n.window,s,i-n.wsize,n.wsize,0),n.wnext=0,n.whave=n.wsize):((r=n.wsize-n.wnext)>a&&(r=a),arraySet(n.window,s,i-a,r,n.wnext),(a-=r)?(arraySet(n.window,s,i-a,a,0),n.wnext=a,n.whave=n.wsize):(n.wnext+=r,n.wnext===n.wsize&&(n.wnext=0),n.whave<n.wsize&&(n.whave+=r)))),g-=e.avail_in,w-=e.avail_out,e.total_in+=g,e.total_out+=w,o.total+=w,o.wrap&&w&&(e.adler=o.check=o.flags?makeTable(o.check,d,w,e.next_out-w):adler32_adler32(o.check,d,w,e.next_out-w)),e.data_type=o.bits+(o.last?64:0)+(12===o.mode?128:0)+(20===o.mode||15===o.mode?256:0),(0===g&&0===w||4===t)&&0===Q&&(Q=-5),Q}(this.strm,0))throw Error("zlib inflate failed");if(this.strm.next_out!=e)throw Error("Incomplete zlib block");return new Uint8Array(this.strm.output.buffer,0,this.strm.next_out)}reset(){inflateReset(this.strm)}};function zero(e){for(var t=e.length;--t>=0;)e[t]=0}var T=[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],Q=[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],D=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],L=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],B=Array(576);zero(B);var R=Array(60);zero(R);var P=Array(512);zero(P);var N=Array(256);zero(N);var z=Array(29);zero(z);var I=Array(30);function StaticTreeDesc(e,t,s,i,a){this.static_tree=e,this.extra_bits=t,this.extra_base=s,this.elems=i,this.max_length=a,this.has_stree=e&&e.length}function TreeDesc(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}function d_code(e){return e<256?P[e]:P[256+(e>>>7)]}function put_short(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255}function send_bits(e,t,s){e.bi_valid>16-s?(e.bi_buf|=t<<e.bi_valid&65535,put_short(e,e.bi_buf),e.bi_buf=t>>16-e.bi_valid,e.bi_valid+=s-16):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=s)}function send_code(e,t,s){send_bits(e,s[2*t],s[2*t+1])}function bi_reverse(e,t){var s=0;do s|=1&e,e>>>=1,s<<=1;while(--t>0);return s>>>1}function gen_codes(e,t,s){var i,a,r=Array(16),n=0;for(i=1;i<=15;i++)r[i]=n=n+s[i-1]<<1;for(a=0;a<=t;a++){var o=e[2*a+1];0!==o&&(e[2*a]=bi_reverse(r[o]++,o))}}function init_block(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 bi_windup(e){e.bi_valid>8?put_short(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 smaller(e,t,s,i){var a=2*t,r=2*s;return e[a]<e[r]||e[a]===e[r]&&i[t]<=i[s]}function pqdownheap(e,t,s){for(var i=e.heap[s],a=s<<1;a<=e.heap_len&&(a<e.heap_len&&smaller(t,e.heap[a+1],e.heap[a],e.depth)&&a++,!smaller(t,i,e.heap[a],e.depth));)e.heap[s]=e.heap[a],s=a,a<<=1;e.heap[s]=i}function compress_block(e,t,s){var i,a,r,n,o=0;if(0!==e.last_lit)do i=e.pending_buf[e.d_buf+2*o]<<8|e.pending_buf[e.d_buf+2*o+1],a=e.pending_buf[e.l_buf+o],o++,0===i?send_code(e,a,t):(send_code(e,(r=N[a])+256+1,t),0!==(n=T[r])&&send_bits(e,a-=z[r],n),send_code(e,r=d_code(--i),s),0!==(n=Q[r])&&send_bits(e,i-=I[r],n));while(o<e.last_lit);send_code(e,256,t)}function build_tree(e,t){var s,i,a,r=t.dyn_tree,n=t.stat_desc.static_tree,o=t.stat_desc.has_stree,h=t.stat_desc.elems,d=-1;for(s=0,e.heap_len=0,e.heap_max=573;s<h;s++)0!==r[2*s]?(e.heap[++e.heap_len]=d=s,e.depth[s]=0):r[2*s+1]=0;for(;e.heap_len<2;)r[2*(a=e.heap[++e.heap_len]=d<2?++d:0)]=1,e.depth[a]=0,e.opt_len--,o&&(e.static_len-=n[2*a+1]);for(t.max_code=d,s=e.heap_len>>1;s>=1;s--)pqdownheap(e,r,s);a=h;do s=e.heap[1],e.heap[1]=e.heap[e.heap_len--],pqdownheap(e,r,1),i=e.heap[1],e.heap[--e.heap_max]=s,e.heap[--e.heap_max]=i,r[2*a]=r[2*s]+r[2*i],e.depth[a]=(e.depth[s]>=e.depth[i]?e.depth[s]:e.depth[i])+1,r[2*s+1]=r[2*i+1]=a,e.heap[1]=a++,pqdownheap(e,r,1);while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],function(e,t){var s,i,a,r,n,o,h=t.dyn_tree,d=t.max_code,l=t.stat_desc.static_tree,_=t.stat_desc.has_stree,u=t.stat_desc.extra_bits,c=t.stat_desc.extra_base,f=t.stat_desc.max_length,p=0;for(r=0;r<=15;r++)e.bl_count[r]=0;for(h[2*e.heap[e.heap_max]+1]=0,s=e.heap_max+1;s<573;s++)(r=h[2*h[2*(i=e.heap[s])+1]+1]+1)>f&&(r=f,p++),h[2*i+1]=r,!(i>d)&&(e.bl_count[r]++,n=0,i>=c&&(n=u[i-c]),o=h[2*i],e.opt_len+=o*(r+n),_&&(e.static_len+=o*(l[2*i+1]+n)));if(0!==p){do{for(r=f-1;0===e.bl_count[r];)r--;e.bl_count[r]--,e.bl_count[r+1]+=2,e.bl_count[f]--,p-=2}while(p>0);for(r=f;0!==r;r--)for(i=e.bl_count[r];0!==i;)!((a=e.heap[--s])>d)&&(h[2*a+1]!==r&&(e.opt_len+=(r-h[2*a+1])*h[2*a],h[2*a+1]=r),i--)}}(e,t),gen_codes(r,d,e.bl_count)}function scan_tree(e,t,s){var i,a,r=-1,n=t[1],o=0,h=7,d=4;for(0===n&&(h=138,d=3),t[(s+1)*2+1]=65535,i=0;i<=s;i++)a=n,n=t[(i+1)*2+1],++o<h&&a===n||(o<d?e.bl_tree[2*a]+=o:0!==a?(a!==r&&e.bl_tree[2*a]++,e.bl_tree[32]++):o<=10?e.bl_tree[34]++:e.bl_tree[36]++,o=0,r=a,0===n?(h=138,d=3):a===n?(h=6,d=3):(h=7,d=4))}function send_tree(e,t,s){var i,a,r=-1,n=t[1],o=0,h=7,d=4;for(0===n&&(h=138,d=3),i=0;i<=s;i++)if(a=n,n=t[(i+1)*2+1],!(++o<h)||a!==n){if(o<d)do send_code(e,a,e.bl_tree);while(0!=--o);else 0!==a?(a!==r&&(send_code(e,a,e.bl_tree),o--),send_code(e,16,e.bl_tree),send_bits(e,o-3,2)):o<=10?(send_code(e,17,e.bl_tree),send_bits(e,o-3,3)):(send_code(e,18,e.bl_tree),send_bits(e,o-11,7));o=0,r=a,0===n?(h=138,d=3):a===n?(h=6,d=3):(h=7,d=4)}}zero(I);var U=!1;function _tr_stored_block(e,t,s,i){send_bits(e,0+(i?1:0),3),bi_windup(e),put_short(e,s),put_short(e,~s),arraySet(e.pending_buf,e.window,t,s,e.pending),e.pending+=s}function _tr_tally(e,t,s){return e.pending_buf[e.d_buf+2*e.last_lit]=t>>>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[(N[s]+256+1)*2]++,e.dyn_dtree[2*d_code(t)]++),e.last_lit===e.lit_bufsize-1}var H={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 err(e,t){return e.msg=H[t],t}function rank(e){return(e<<1)-(e>4?9:0)}function deflate_zero(e){for(var t=e.length;--t>=0;)e[t]=0}function flush_pending(e){var t=e.state,s=t.pending;s>e.avail_out&&(s=e.avail_out),0!==s&&(arraySet(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 flush_block_only(e,t){var s,i,a,r,n;s=e.block_start>=0?e.block_start:-1,i=e.strstart-e.block_start,n=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)),build_tree(e,e.l_desc),build_tree(e,e.d_desc),n=function(e){var t;for(scan_tree(e,e.dyn_ltree,e.l_desc.max_code),scan_tree(e,e.dyn_dtree,e.d_desc.max_code),build_tree(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*L[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t}(e),a=e.opt_len+3+7>>>3,(r=e.static_len+3+7>>>3)<=a&&(a=r)):a=r=i+5,i+4<=a&&-1!==s?_tr_stored_block(e,s,i,t):4===e.strategy||r===a?(send_bits(e,2+(t?1:0),3),compress_block(e,B,R)):(send_bits(e,4+(t?1:0),3),function(e,t,s,i){var a;for(send_bits(e,t-257,5),send_bits(e,s-1,5),send_bits(e,i-4,4),a=0;a<i;a++)send_bits(e,e.bl_tree[2*L[a]+1],3);send_tree(e,e.dyn_ltree,t-1),send_tree(e,e.dyn_dtree,s-1)}(e,e.l_desc.max_code+1,e.d_desc.max_code+1,n+1),compress_block(e,e.dyn_ltree,e.dyn_dtree)),init_block(e),t&&bi_windup(e),e.block_start=e.strstart,flush_pending(e.strm)}function put_byte(e,t){e.pending_buf[e.pending++]=t}function putShortMSB(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t}function longest_match(e,t){var s,i,a=e.max_chain_length,r=e.strstart,n=e.prev_length,o=e.nice_match,h=e.strstart>e.w_size-262?e.strstart-(e.w_size-262):0,d=e.window,l=e.w_mask,_=e.prev,u=e.strstart+258,c=d[r+n-1],f=d[r+n];e.prev_length>=e.good_match&&(a>>=2),o>e.lookahead&&(o=e.lookahead);do{if(d[(s=t)+n]!==f||d[s+n-1]!==c||d[s]!==d[r]||d[++s]!==d[r+1])continue;r+=2,s++;do;while(d[++r]===d[++s]&&d[++r]===d[++s]&&d[++r]===d[++s]&&d[++r]===d[++s]&&d[++r]===d[++s]&&d[++r]===d[++s]&&d[++r]===d[++s]&&d[++r]===d[++s]&&r<u);if(i=258-(u-r),r=u-258,i>n){if(e.match_start=t,n=i,i>=o)break;c=d[r+n-1],f=d[r+n]}}while((t=_[t&l])>h&&0!=--a);return n<=e.lookahead?n:e.lookahead}function fill_window(e){var t,s,i,a,r,n=e.w_size;do{if(a=e.window_size-e.lookahead-e.strstart,e.strstart>=n+(n-262)){arraySet(e.window,e.window,n,n,0),e.match_start-=n,e.strstart-=n,e.block_start-=n,t=s=e.hash_size;do i=e.head[--t],e.head[t]=i>=n?i-n:0;while(--s);t=s=n;do i=e.prev[--t],e.prev[t]=i>=n?i-n:0;while(--s);a+=n}if(0===e.strm.avail_in)break;if(s=function(e,t,s,i){var a=e.avail_in;return(a>i&&(a=i),0===a)?0:(e.avail_in-=a,arraySet(t,e.input,e.next_in,a,s),1===e.state.wrap?e.adler=adler32_adler32(e.adler,t,a,s):2===e.state.wrap&&(e.adler=makeTable(e.adler,t,a,s)),e.next_in+=a,e.total_in+=a,a)}(e.strm,e.window,e.strstart+e.lookahead,a),e.lookahead+=s,e.lookahead+e.insert>=3)for(r=e.strstart-e.insert,e.ins_h=e.window[r],e.ins_h=(e.ins_h<<e.hash_shift^e.window[r+1])&e.hash_mask;e.insert&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[r+3-1])&e.hash_mask,e.prev[r&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=r,r++,e.insert--,!(e.lookahead+e.insert<3)););}while(e.lookahead<262&&0!==e.strm.avail_in)}function deflate_fast(e,t){for(var s,i;;){if(e.lookahead<262){if(fill_window(e),e.lookahead<262&&0===t)return 1;if(0===e.lookahead)break}if(s=0,e.lookahead>=3&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,s=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==s&&e.strstart-s<=e.w_size-262&&(e.match_length=longest_match(e,s)),e.match_length>=3){if(i=_tr_tally(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<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,s=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart;while(0!=--e.match_length);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+1])&e.hash_mask}else i=_tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(i&&(flush_block_only(e,!1),0===e.strm.avail_out))return 1}return(e.insert=e.strstart<2?e.strstart:2,4===t)?(flush_block_only(e,!0),0===e.strm.avail_out)?3:4:e.last_lit&&(flush_block_only(e,!1),0===e.strm.avail_out)?1:2}function deflate_slow(e,t){for(var s,i,a;;){if(e.lookahead<262){if(fill_window(e),e.lookahead<262&&0===t)return 1;if(0===e.lookahead)break}if(s=0,e.lookahead>=3&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,s=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=2,0!==s&&e.prev_length<e.max_lazy_match&&e.strstart-s<=e.w_size-262&&(e.match_length=longest_match(e,s),e.match_length<=5&&(1===e.strategy||3===e.match_length&&e.strstart-e.match_start>4096)&&(e.match_length=2)),e.prev_length>=3&&e.match_length<=e.prev_length){a=e.strstart+e.lookahead-3,i=_tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;do++e.strstart<=a&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,s=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart);while(0!=--e.prev_length);if(e.match_available=0,e.match_length=2,e.strstart++,i&&(flush_block_only(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if((i=_tr_tally(e,0,e.window[e.strstart-1]))&&flush_block_only(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return 1}else e.match_available=1,e.strstart++,e.lookahead--}return(e.match_available&&(i=_tr_tally(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,4===t)?(flush_block_only(e,!0),0===e.strm.avail_out)?3:4:e.last_lit&&(flush_block_only(e,!1),0===e.strm.avail_out)?1:2}function Config(e,t,s,i,a){this.good_length=e,this.max_lazy=t,this.nice_length=s,this.max_chain=i,this.func=a}function DeflateState(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=8,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new K(1146),this.dyn_dtree=new K(122),this.bl_tree=new K(78),deflate_zero(this.dyn_ltree),deflate_zero(this.dyn_dtree),deflate_zero(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new K(16),this.heap=new K(573),deflate_zero(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new K(573),deflate_zero(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function deflate(e,t){if(!e||!e.state||t>5||t<0)return e?err(e,-2):-2;if(i=e.state,!e.output||!e.input&&0!==e.avail_in||666===i.status&&4!==t)return err(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,put_byte(i,31),put_byte(i,139),put_byte(i,8),i.gzhead?(put_byte(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)),put_byte(i,255&i.gzhead.time),put_byte(i,i.gzhead.time>>8&255),put_byte(i,i.gzhead.time>>16&255),put_byte(i,i.gzhead.time>>24&255),put_byte(i,9===i.level?2:i.strategy>=2||i.level<2?4:0),put_byte(i,255&i.gzhead.os),i.gzhead.extra&&i.gzhead.extra.length&&(put_byte(i,255&i.gzhead.extra.length),put_byte(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(e.adler=makeTable(e.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=69):(put_byte(i,0),put_byte(i,0),put_byte(i,0),put_byte(i,0),put_byte(i,0),put_byte(i,9===i.level?2:i.strategy>=2||i.level<2?4:0),put_byte(i,3),i.status=113);else{var s,i,a,r,n=8+(i.w_bits-8<<4)<<8;n|=(i.strategy>=2||i.level<2?0:i.level<6?1:6===i.level?2:3)<<6,0!==i.strstart&&(n|=32),n+=31-n%31,i.status=113,putShortMSB(i,n),0!==i.strstart&&(putShortMSB(i,e.adler>>>16),putShortMSB(i,65535&e.adler)),e.adler=1}}if(69===i.status){if(i.gzhead.extra){for(a=i.pending;i.gzindex<(65535&i.gzhead.extra.length)&&(i.pending!==i.pending_buf_size||(i.gzhead.hcrc&&i.pending>a&&(e.adler=makeTable(e.adler,i.pending_buf,i.pending-a,a)),flush_pending(e),a=i.pending,i.pending!==i.pending_buf_size));)put_byte(i,255&i.gzhead.extra[i.gzindex]),i.gzindex++;i.gzhead.hcrc&&i.pending>a&&(e.adler=makeTable(e.adler,i.pending_buf,i.pending-a,a)),i.gzindex===i.gzhead.extra.length&&(i.gzindex=0,i.status=73)}else i.status=73}if(73===i.status){if(i.gzhead.name){a=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>a&&(e.adler=makeTable(e.adler,i.pending_buf,i.pending-a,a)),flush_pending(e),a=i.pending,i.pending===i.pending_buf_size)){r=1;break}r=i.gzindex<i.gzhead.name.length?255&i.gzhead.name.charCodeAt(i.gzindex++):0,put_byte(i,r)}while(0!==r);i.gzhead.hcrc&&i.pending>a&&(e.adler=makeTable(e.adler,i.pending_buf,i.pending-a,a)),0===r&&(i.gzindex=0,i.status=91)}else i.status=91}if(91===i.status){if(i.gzhead.comment){a=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>a&&(e.adler=makeTable(e.adler,i.pending_buf,i.pending-a,a)),flush_pending(e),a=i.pending,i.pending===i.pending_buf_size)){r=1;break}r=i.gzindex<i.gzhead.comment.length?255&i.gzhead.comment.charCodeAt(i.gzindex++):0,put_byte(i,r)}while(0!==r);i.gzhead.hcrc&&i.pending>a&&(e.adler=makeTable(e.adler,i.pending_buf,i.pending-a,a)),0===r&&(i.status=103)}else i.status=103}if(103===i.status&&(i.gzhead.hcrc?(i.pending+2>i.pending_buf_size&&flush_pending(e),i.pending+2<=i.pending_buf_size&&(put_byte(i,255&e.adler),put_byte(i,e.adler>>8&255),e.adler=0,i.status=113)):i.status=113),0!==i.pending){if(flush_pending(e),0===e.avail_out)return i.last_flush=-1,0}else if(0===e.avail_in&&rank(t)<=rank(s)&&4!==t)return err(e,-5);if(666===i.status&&0!==e.avail_in)return err(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&&(fill_window(e),0===e.lookahead)){if(0===t)return 1;break}if(e.match_length=0,s=_tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,s&&(flush_block_only(e,!1),0===e.strm.avail_out))return 1}return(e.insert=0,4===t)?(flush_block_only(e,!0),0===e.strm.avail_out)?3:4:e.last_lit&&(flush_block_only(e,!1),0===e.strm.avail_out)?1:2}(i,t):3===i.strategy?function(e,t){for(var s,i,a,r,n=e.window;;){if(e.lookahead<=258){if(fill_window(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=n[a=e.strstart-1])===n[++a]&&i===n[++a]&&i===n[++a]){r=e.strstart+258;do;while(i===n[++a]&&i===n[++a]&&i===n[++a]&&i===n[++a]&&i===n[++a]&&i===n[++a]&&i===n[++a]&&i===n[++a]&&a<r);e.match_length=258-(r-a),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(s=_tr_tally(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(s=_tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),s&&(flush_block_only(e,!1),0===e.strm.avail_out))return 1}return(e.insert=0,4===t)?(flush_block_only(e,!0),0===e.strm.avail_out)?3:4:e.last_lit&&(flush_block_only(e,!1),0===e.strm.avail_out)?1:2}(i,t):y[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?(send_bits(i,2,3),send_code(i,256,B),16===i.bi_valid?(put_short(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&&(_tr_stored_block(i,0,0,!1),3===t&&(deflate_zero(i.head),0===i.lookahead&&(i.strstart=0,i.block_start=0,i.insert=0))),flush_pending(e),0===e.avail_out))return i.last_flush=-1,0}return 4!==t?0:i.wrap<=0?1:(2===i.wrap?(put_byte(i,255&e.adler),put_byte(i,e.adler>>8&255),put_byte(i,e.adler>>16&255),put_byte(i,e.adler>>24&255),put_byte(i,255&e.total_in),put_byte(i,e.total_in>>8&255),put_byte(i,e.total_in>>16&255),put_byte(i,e.total_in>>24&255)):(putShortMSB(i,e.adler>>>16),putShortMSB(i,65535&e.adler)),flush_pending(e),i.wrap>0&&(i.wrap=-i.wrap),0!==i.pending?0:1)}y=[new Config(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(fill_window(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,flush_block_only(e,!1),0===e.strm.avail_out)||e.strstart-e.block_start>=e.w_size-262&&(flush_block_only(e,!1),0===e.strm.avail_out))return 1}return(e.insert=0,4===t)?(flush_block_only(e,!0),0===e.strm.avail_out)?3:4:(e.strstart>e.block_start&&(flush_block_only(e,!1),e.strm.avail_out),1)}),new Config(4,4,8,4,deflate_fast),new Config(4,5,16,8,deflate_fast),new Config(4,6,32,32,deflate_fast),new Config(4,4,16,16,deflate_slow),new Config(8,16,32,32,deflate_slow),new Config(8,16,128,128,deflate_slow),new Config(8,32,128,256,deflate_slow),new Config(32,128,258,1024,deflate_slow),new Config(32,258,258,4096,deflate_slow)];let Deflator=class Deflator{constructor(){this.strm=new ZStream,this.chunkSize=102400,this.outputBuffer=new Uint8Array(this.chunkSize),this.windowBits=5,function(e,t,s,i,a,r){if(e){var n,o,h,d=1;if(-1===t&&(t=6),i<0?(d=0,i=-i):i>15&&(d=2,i-=16),a<1||a>9||8!==s||i<8||i>15||t<0||t>9||r<0||r>4)return err(e,-2);8===i&&(i=9);var l=new DeflateState;e.state=l,l.strm=e,l.wrap=d,l.gzhead=null,l.w_bits=i,l.w_size=1<<l.w_bits,l.w_mask=l.w_size-1,l.hash_bits=a+7,l.hash_size=1<<l.hash_bits,l.hash_mask=l.hash_size-1,l.hash_shift=~~((l.hash_bits+3-1)/3),l.window=new S(2*l.w_size),l.head=new K(l.hash_size),l.prev=new K(l.w_size),l.lit_bufsize=1<<a+6,l.pending_buf_size=4*l.lit_bufsize,l.pending_buf=new S(l.pending_buf_size),l.d_buf=1*l.lit_bufsize,l.l_buf=3*l.lit_bufsize,l.level=t,l.strategy=r,l.method=s,0===((n=e)&&n.state?(n.total_in=n.total_out=0,n.data_type=2,(o=n.state).pending=0,o.pending_out=0,o.wrap<0&&(o.wrap=-o.wrap),o.status=o.wrap?42:113,n.adler=2===o.wrap?0:1,o.last_flush=0,U||(function(){var e,t,s,i,a,r=Array(16);for(i=0,s=0;i<28;i++)for(e=0,z[i]=s;e<1<<T[i];e++)N[s++]=i;for(N[s-1]=i,a=0,i=0;i<16;i++)for(e=0,I[i]=a;e<1<<Q[i];e++)P[a++]=i;for(a>>=7;i<30;i++)for(e=0,I[i]=a<<7;e<1<<Q[i]-7;e++)P[256+a++]=i;for(t=0;t<=15;t++)r[t]=0;for(e=0;e<=143;)B[2*e+1]=8,e++,r[8]++;for(;e<=255;)B[2*e+1]=9,e++,r[9]++;for(;e<=279;)B[2*e+1]=7,e++,r[7]++;for(;e<=287;)B[2*e+1]=8,e++,r[8]++;for(gen_codes(B,287,r),e=0;e<30;e++)R[2*e+1]=5,R[2*e]=bi_reverse(e,5);w=new StaticTreeDesc(B,T,257,286,15),v=new StaticTreeDesc(R,Q,0,30,15),k=new StaticTreeDesc([],D,0,19,7)}(),U=!0),o.l_desc=new TreeDesc(o.dyn_ltree,w),o.d_desc=new TreeDesc(o.dyn_dtree,v),o.bl_desc=new TreeDesc(o.bl_tree,k),o.bi_buf=0,o.bi_valid=0,init_block(o),0):err(n,-2))&&((h=e.state).window_size=2*h.w_size,deflate_zero(h.head),h.max_lazy_match=y[h.level].max_lazy,h.good_match=y[h.level].good_length,h.nice_match=y[h.level].nice_length,h.max_chain_length=y[h.level].max_chain,h.strstart=0,h.block_start=0,h.lookahead=0,h.insert=0,h.match_length=h.prev_length=2,h.match_available=0,h.ins_h=0)}}(this.strm,this.windowBits,8,15,8,0)}deflate(e){this.strm.input=e,this.strm.avail_in=this.strm.input.length,this.strm.next_in=0,this.strm.output=this.outputBuffer,this.strm.avail_out=this.chunkSize,this.strm.next_out=0;let t=deflate(this.strm,3),s=new Uint8Array(this.strm.output.buffer,0,this.strm.next_out);if(t<0)throw Error("zlib deflate failed");if(this.strm.avail_in>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=deflate(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 a=new Uint8Array(i),r=0;for(let t=0;t<e.length;t++)a.set(e[t],r),r+=e[t].length;s=a}return this.strm.input=null,this.strm.avail_in=0,this.strm.next_in=0,s}};var V={XK_BackSpace:65288,XK_Tab:65289,XK_Clear:65291,XK_Return:65293,XK_Pause:65299,XK_Scroll_Lock:65300,XK_Escape:65307,XK_Delete:65535,XK_Multi_key:65312,XK_Codeinput:65335,XK_SingleCandidate:65340,XK_MultipleCandidate:65341,XK_PreviousCandidate:65342,XK_Kanji:65313,XK_Muhenkan:65314,XK_Henkan:65315,XK_Romaji:65316,XK_Hiragana:65317,XK_Katakana:65318,XK_Hiragana_Katakana:65319,XK_Zenkaku:65320,XK_Hankaku:65321,XK_Zenkaku_Hankaku:65322,XK_Kana_Shift:65326,XK_Eisu_toggle:65328,XK_Home:65360,XK_Left:65361,XK_Up:65362,XK_Right:65363,XK_Down:65364,XK_Prior:65365,XK_Next:65366,XK_End:65367,XK_Select:65376,XK_Print:65377,XK_Execute:65378,XK_Insert:65379,XK_Undo:65381,XK_Redo:65382,XK_Menu:65383,XK_Find:65384,XK_Cancel:65385,XK_Help:65386,XK_Mode_switch:65406,XK_Num_Lock:65407,XK_KP_Space:65408,XK_KP_Enter:65421,XK_KP_Home:65429,XK_KP_Left:65430,XK_KP_Up:65431,XK_KP_Right:65432,XK_KP_Down:65433,XK_KP_Prior:65434,XK_KP_Next:65435,XK_KP_End:65436,XK_KP_Begin:65437,XK_KP_Insert:65438,XK_KP_Delete:65439,XK_KP_Equal:65469,XK_KP_Multiply:65450,XK_KP_Add:65451,XK_KP_Separator:65452,XK_KP_Subtract:65453,XK_KP_Decimal:65454,XK_KP_Divide:65455,XK_KP_0:65456,XK_KP_1:65457,XK_KP_2:65458,XK_KP_3:65459,XK_KP_4:65460,XK_KP_5:65461,XK_KP_6:65462,XK_KP_7:65463,XK_KP_8:65464,XK_KP_9:65465,XK_F1:65470,XK_F2:65471,XK_F3:65472,XK_F4:65473,XK_F5:65474,XK_F6:65475,XK_F7:65476,XK_F8:65477,XK_F9:65478,XK_F10:65479,XK_F11:65480,XK_F12:65481,XK_F13:65482,XK_F14:65483,XK_F15:65484,XK_F16:65485,XK_F17:65486,XK_F18:65487,XK_F19:65488,XK_F20:65489,XK_F21:65490,XK_F22:65491,XK_F23:65492,XK_F24:65493,XK_F25:65494,XK_F26:65495,XK_F27:65496,XK_F28:65497,XK_F29:65498,XK_F30:65499,XK_F31:65500,XK_F32:65501,XK_F33:65502,XK_F34:65503,XK_F35:65504,XK_Shift_L:65505,XK_Shift_R:65506,XK_Control_L:65507,XK_Control_R:65508,XK_Caps_Lock:65509,XK_Meta_L:65511,XK_Meta_R:65512,XK_Alt_L:65513,XK_Alt_R:65514,XK_Super_L:65515,XK_Super_R:65516,XK_ISO_Level3_Shift:65027,XK_ISO_Next_Group:65032,XK_ISO_Prev_Group:65034,XK_ISO_First_Group:65036,XK_ISO_Last_Group:65038,XK_space:32,XK_asterisk:42,XK_plus:43,XK_comma:44,XK_minus:45,XK_period:46,XK_slash:47,XK_0:48,XK_1:49,XK_2:50,XK_3:51,XK_4:52,XK_5:53,XK_6:54,XK_7:55,XK_8:56,XK_9:57,XK_equal:61,XK_Hangul:65329,XK_Hangul_Hanja:65332,XK_Hangul_Jeonja:65336,XF86XK_MonBrightnessUp:269025026,XF86XK_MonBrightnessDown:269025027,XF86XK_Standby:269025040,XF86XK_AudioLowerVolume:269025041,XF86XK_AudioMute:269025042,XF86XK_AudioRaiseVolume:269025043,XF86XK_AudioPlay:269025044,XF86XK_AudioStop:269025045,XF86XK_AudioPrev:269025046,XF86XK_AudioNext:269025047,XF86XK_HomePage:269025048,XF86XK_Mail:269025049,XF86XK_Search:269025051,XF86XK_AudioRecord:269025052,XF86XK_Calculator:269025053,XF86XK_Calendar:269025056,XF86XK_PowerDown:269025057,XF86XK_Back:269025062,XF86XK_Forward:269025063,XF86XK_Stop:269025064,XF86XK_Refresh:269025065,XF86XK_PowerOff:269025066,XF86XK_WakeUp:269025067,XF86XK_Eject:269025068,XF86XK_ScreenSaver:269025069,XF86XK_WWW:269025070,XF86XK_Favorites:269025072,XF86XK_AudioPause:269025073,XF86XK_AudioMedia:269025074,XF86XK_MyComputer:269025075,XF86XK_BrightnessAdjust:269025083,XF86XK_AudioRewind:269025086,XF86XK_Close:269025110,XF86XK_Copy:269025111,XF86XK_Cut:269025112,XF86XK_Excel:269025116,XF86XK_LogOff:269025121,XF86XK_New:269025128,XF86XK_Open:269025131,XF86XK_Paste:269025133,XF86XK_Phone:269025134,XF86XK_Reply:269025138,XF86XK_Save:269025143,XF86XK_Send:269025147,XF86XK_Spell:269025148,XF86XK_SplitScreen:269025149,XF86XK_Word:269025161,XF86XK_ZoomIn:269025163,XF86XK_ZoomOut:269025164,XF86XK_WebCam:269025167,XF86XK_MailForward:269025168,XF86XK_Music:269025170,XF86XK_AudioForward:269025175,XF86XK_AudioRandomPlay:269025177,XF86XK_Subtitle:269025178,XF86XK_AudioCycleTrack:269025179,XF86XK_Hibernate:269025192,XF86XK_AudioMicMute:269025202,XF86XK_Next_VMode:269024802};let O={256:960,257:992,258:451,259:483,260:417,261:433,262:454,263:486,264:710,265:742,266:709,267:741,268:456,269:488,270:463,271:495,272:464,273:496,274:938,275:954,278:972,279:1004,280:458,281:490,282:460,283:492,284:728,285:760,286:683,287:699,288:725,289:757,290:939,291:955,292:678,293:694,294:673,295:689,296:933,297:949,298:975,299:1007,302:967,303:999,304:681,305:697,308:684,309:700,310:979,311:1011,312:930,313:453,314:485,315:934,316:950,317:421,318:437,321:419,322:435,323:465,324:497,325:977,326:1009,327:466,328:498,330:957,331:959,332:978,333:1010,336:469,337:501,338:5052,339:5053,340:448,341:480,342:931,343:947,344:472,345:504,346:422,347:438,348:734,349:766,350:426,351:442,352:425,353:441,354:478,355:510,356:427,357:443,358:940,359:956,360:989,361:1021,362:990,363:1022,364:733,365:765,366:473,367:505,368:475,369:507,370:985,371:1017,376:5054,377:428,378:444,379:431,380:447,381:430,382:446,402:2294,466:16777681,711:439,728:418,729:511,731:434,733:445,901:1966,902:1953,904:1954,905:1955,906:1956,908:1959,910:1960,911:1963,912:1974,913:1985,914:1986,915:1987,916:1988,917:1989,918:1990,919:1991,920:1992,921:1993,922:1994,923:1995,924:1996,925:1997,926:1998,927:1999,928:2e3,929:2001,931:2002,932:2004,933:2005,934:2006,935:2007,936:2008,937:2009,938:1957,939:1961,940:1969,941:1970,942:1971,943:1972,944:1978,945:2017,946:2018,947:2019,948:2020,949:2021,950:2022,951:2023,952:2024,953:2025,954:2026,955:2027,956:2028,957:2029,958:2030,959:2031,960:2032,961:2033,962:2035,963:2034,964:2036,965:2037,966:2038,967:2039,968:2040,969:2041,970:1973,971:1977,972:1975,973:1976,974:1979,1025:1715,1026:1713,1027:1714,1028:1716,1029:1717,1030:1718,1031:1719,1032:1720,1033:1721,1034:1722,1035:1723,1036:1724,1038:1726,1039:1727,1040:1761,1041:1762,1042:1783,1043:1767,1044:1764,1045:1765,1046:1782,1047:1786,1048:1769,1049:1770,1050:1771,1051:1772,1052:1773,1053:1774,1054:1775,1055:1776,1056:1778,1057:1779,1058:1780,1059:1781,1060:1766,1061:1768,1062:1763,1063:1790,1064:1787,1065:1789,1066:1791,1067:1785,1068:1784,1069:1788,1070:1760,1071:1777,1072:1729,1073:1730,1074:1751,1075:1735,1076:1732,1077:1733,1078:1750,1079:1754,1080:1737,1081:1738,1082:1739,1083:1740,1084:1741,1085:1742,1086:1743,1087:1744,1088:1746,1089:1747,1090:1748,1091:1749,1092:1734,1093:1736,1094:1731,1095:1758,1096:1755,1097:1757,1098:1759,1099:1753,1100:1752,1101:1756,1102:1728,1103:1745,1105:1699,1106:1697,1107:1698,1108:1700,1109:1701,1110:1702,1111:1703,1112:1704,1113:1705,1114:1706,1115:1707,1116:1708,1118:1710,1119:1711,1168:1725,1169:1709,1488:3296,1489:3297,1490:3298,1491:3299,1492:3300,1493:3301,1494:3302,1495:3303,1496:3304,1497:3305,1498:3306,1499:3307,1500:3308,1501:3309,1502:3310,1503:3311,1504:3312,1505:3313,1506:3314,1507:3315,1508:3316,1509:3317,1510:3318,1511:3319,1512:3320,1513:3321,1514:3322,1548:1452,1563:1467,1567:1471,1569:1473,1570:1474,1571:1475,1572:1476,1573:1477,1574:1478,1575:1479,1576:1480,1577:1481,1578:1482,1579:1483,1580:1484,1581:1485,1582:1486,1583:1487,1584:1488,1585:1489,1586:1490,1587:1491,1588:1492,1589:1493,1590:1494,1591:1495,1592:1496,1593:1497,1594:1498,1600:1504,1601:1505,1602:1506,1603:1507,1604:1508,1605:1509,1606:1510,1607:1511,1608:1512,1609:1513,1610:1514,1611:1515,1612:1516,1613:1517,1614:1518,1615:1519,1616:1520,1617:1521,1618:1522,3585:3489,3586:3490,3587:3491,3588:3492,3589:3493,3590:3494,3591:3495,3592:3496,3593:3497,3594:3498,3595:3499,3596:3500,3597:3501,3598:3502,3599:3503,3600:3504,3601:3505,3602:3506,3603:3507,3604:3508,3605:3509,3606:3510,3607:3511,3608:3512,3609:3513,3610:3514,3611:3515,3612:3516,3613:3517,3614:3518,3615:3519,3616:3520,3617:3521,3618:3522,3619:3523,3620:3524,3621:3525,3622:3526,3623:3527,3624:3528,3625:3529,3626:3530,3627:3531,3628:3532,3629:3533,3630:3534,3631:3535,3632:3536,3633:3537,3634:3538,3635:3539,3636:3540,3637:3541,3638:3542,3639:3543,3640:3544,3641:3545,3642:3546,3647:3551,3648:3552,3649:3553,3650:3554,3651:3555,3652:3556,3653:3557,3654:3558,3655:3559,3656:3560,3657:3561,3658:3562,3659:3563,3660:3564,3661:3565,3664:3568,3665:3569,3666:3570,3667:3571,3668:3572,3669:3573,3670:3574,3671:3575,3672:3576,3673:3577,8194:2722,8195:2721,8196:2723,8197:2724,8199:2725,8200:2726,8201:2727,8202:2728,8210:2747,8211:2730,8212:2729,8213:1967,8215:3295,8216:2768,8217:2769,8218:2813,8220:2770,8221:2771,8222:2814,8224:2801,8225:2802,8226:2790,8229:2735,8230:2734,8240:2773,8242:2774,8243:2775,8248:2812,8254:1150,8361:3839,8364:8364,8453:2744,8470:1712,8471:2811,8478:2772,8482:2761,8531:2736,8532:2737,8533:2738,8534:2739,8535:2740,8536:2741,8537:2742,8538:2743,8539:2755,8540:2756,8541:2757,8542:2758,8592:2299,8593:2300,8594:2301,8595:2302,8658:2254,8660:2253,8706:2287,8711:2245,8728:3018,8730:2262,8733:2241,8734:2242,8743:2270,8744:2271,8745:2268,8746:2269,8747:2239,8756:2240,8764:2248,8771:2249,8773:16785992,8800:2237,8801:2255,8804:2236,8805:2238,8834:2266,8835:2267,8866:3068,8867:3036,8868:3010,8869:3022,8968:3027,8970:3012,8981:2810,8992:2212,8993:2213,9109:3020,9115:2219,9117:2220,9118:2221,9120:2222,9121:2215,9123:2216,9124:2217,9126:2218,9128:2223,9132:2224,9143:2209,9146:2543,9147:2544,9148:2546,9149:2547,9225:2530,9226:2533,9227:2537,9228:2531,9229:2532,9251:2732,9252:2536,9472:2211,9474:2214,9484:2210,9488:2539,9492:2541,9496:2538,9500:2548,9508:2549,9516:2551,9524:2550,9532:2542,9618:2529,9642:2791,9643:2785,9644:2779,9645:2786,9646:2783,9647:2767,9650:2792,9651:2787,9654:2781,9655:2765,9660:2793,9661:2788,9664:2780,9665:2764,9670:2528,9675:2766,9679:2782,9702:2784,9734:2789,9742:2809,9747:2762,9756:2794,9758:2795,9792:2808,9794:2807,9827:2796,9829:2798,9830:2797,9837:2806,9839:2805,10003:2803,10007:2804,10013:2777,10016:2800,10216:2748,10217:2750,12289:1188,12290:1185,12300:1186,12301:1187,12443:1246,12444:1247,12449:1191,12450:1201,12451:1192,12452:1202,12453:1193,12454:1203,12455:1194,12456:1204,12457:1195,12458:1205,12459:1206,12461:1207,12463:1208,12465:1209,12467:1210,12469:1211,12471:1212,12473:1213,12475:1214,12477:1215,12479:1216,12481:1217,12483:1199,12484:1218,12486:1219,12488:1220,12490:1221,12491:1222,12492:1223,12493:1224,12494:1225,12495:1226,12498:1227,12501:1228,12504:1229,12507:1230,12510:1231,12511:1232,12512:1233,12513:1234,12514:1235,12515:1196,12516:1236,12517:1197,12518:1237,12519:1198,12520:1238,12521:1239,12522:1240,12523:1241,12524:1242,12525:1243,12527:1244,12530:1190,12531:1245,12539:1189,12540:1200};var W={lookup(e){if(e>=32&&e<=255)return e;let t=O[e];return void 0!==t?t:16777216|e}},G={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"},Y={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 q={};function addStandard(e,t){if(void 0===t)throw Error('Undefined keysym for key "'+e+'"');if(e in q)throw Error('Duplicate entry for key "'+e+'"');q[e]=[t,t,t,t]}function addLeftRight(e,t,s){if(void 0===t||void 0===s)throw Error('Undefined keysym for key "'+e+'"');if(e in q)throw Error('Duplicate entry for key "'+e+'"');q[e]=[t,t,s,t]}function addNumpad(e,t,s){if(void 0===t||void 0===s)throw Error('Undefined keysym for key "'+e+'"');if(e in q)throw Error('Duplicate entry for key "'+e+'"');q[e]=[t,t,t,s]}function getKeycode(e){if(e.code){switch(e.code){case"OSLeft":return"MetaLeft";case"OSRight":return"MetaRight"}return e.code}if(e.keyCode in G){let t=G[e.keyCode];if(isMac()&&"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"}addLeftRight("Alt",V.XK_Alt_L,V.XK_Alt_R),addStandard("AltGraph",V.XK_ISO_Level3_Shift),addStandard("CapsLock",V.XK_Caps_Lock),addLeftRight("Control",V.XK_Control_L,V.XK_Control_R),addLeftRight("Meta",V.XK_Super_L,V.XK_Super_R),addStandard("NumLock",V.XK_Num_Lock),addStandard("ScrollLock",V.XK_Scroll_Lock),addLeftRight("Shift",V.XK_Shift_L,V.XK_Shift_R),addNumpad("Enter",V.XK_Return,V.XK_KP_Enter),addStandard("Tab",V.XK_Tab),addNumpad(" ",V.XK_space,V.XK_KP_Space),addNumpad("ArrowDown",V.XK_Down,V.XK_KP_Down),addNumpad("ArrowLeft",V.XK_Left,V.XK_KP_Left),addNumpad("ArrowRight",V.XK_Right,V.XK_KP_Right),addNumpad("ArrowUp",V.XK_Up,V.XK_KP_Up),addNumpad("End",V.XK_End,V.XK_KP_End),addNumpad("Home",V.XK_Home,V.XK_KP_Home),addNumpad("PageDown",V.XK_Next,V.XK_KP_Next),addNumpad("PageUp",V.XK_Prior,V.XK_KP_Prior),addStandard("Backspace",V.XK_BackSpace),addNumpad("Clear",V.XK_Clear,V.XK_KP_Begin),addStandard("Copy",V.XF86XK_Copy),addStandard("Cut",V.XF86XK_Cut),addNumpad("Delete",V.XK_Delete,V.XK_KP_Delete),addNumpad("Insert",V.XK_Insert,V.XK_KP_Insert),addStandard("Paste",V.XF86XK_Paste),addStandard("Redo",V.XK_Redo),addStandard("Undo",V.XK_Undo),addStandard("Cancel",V.XK_Cancel),addStandard("ContextMenu",V.XK_Menu),addStandard("Escape",V.XK_Escape),addStandard("Execute",V.XK_Execute),addStandard("Find",V.XK_Find),addStandard("Help",V.XK_Help),addStandard("Pause",V.XK_Pause),addStandard("Select",V.XK_Select),addStandard("ZoomIn",V.XF86XK_ZoomIn),addStandard("ZoomOut",V.XF86XK_ZoomOut),addStandard("BrightnessDown",V.XF86XK_MonBrightnessDown),addStandard("BrightnessUp",V.XF86XK_MonBrightnessUp),addStandard("Eject",V.XF86XK_Eject),addStandard("LogOff",V.XF86XK_LogOff),addStandard("Power",V.XF86XK_PowerOff),addStandard("PowerOff",V.XF86XK_PowerDown),addStandard("PrintScreen",V.XK_Print),addStandard("Hibernate",V.XF86XK_Hibernate),addStandard("Standby",V.XF86XK_Standby),addStandard("WakeUp",V.XF86XK_WakeUp),addStandard("AllCandidates",V.XK_MultipleCandidate),addStandard("Alphanumeric",V.XK_Eisu_toggle),addStandard("CodeInput",V.XK_Codeinput),addStandard("Compose",V.XK_Multi_key),addStandard("Convert",V.XK_Henkan),addStandard("GroupFirst",V.XK_ISO_First_Group),addStandard("GroupLast",V.XK_ISO_Last_Group),addStandard("GroupNext",V.XK_ISO_Next_Group),addStandard("GroupPrevious",V.XK_ISO_Prev_Group),addStandard("NonConvert",V.XK_Muhenkan),addStandard("PreviousCandidate",V.XK_PreviousCandidate),addStandard("SingleCandidate",V.XK_SingleCandidate),addStandard("HangulMode",V.XK_Hangul),addStandard("HanjaMode",V.XK_Hangul_Hanja),addStandard("JunjaMode",V.XK_Hangul_Jeonja),addStandard("Eisu",V.XK_Eisu_toggle),addStandard("Hankaku",V.XK_Hankaku),addStandard("Hiragana",V.XK_Hiragana),addStandard("HiraganaKatakana",V.XK_Hiragana_Katakana),addStandard("KanaMode",V.XK_Kana_Shift),addStandard("KanjiMode",V.XK_Kanji),addStandard("Katakana",V.XK_Katakana),addStandard("Romaji",V.XK_Romaji),addStandard("Zenkaku",V.XK_Zenkaku),addStandard("ZenkakuHankaku",V.XK_Zenkaku_Hankaku),addStandard("F1",V.XK_F1),addStandard("F2",V.XK_F2),addStandard("F3",V.XK_F3),addStandard("F4",V.XK_F4),addStandard("F5",V.XK_F5),addStandard("F6",V.XK_F6),addStandard("F7",V.XK_F7),addStandard("F8",V.XK_F8),addStandard("F9",V.XK_F9),addStandard("F10",V.XK_F10),addStandard("F11",V.XK_F11),addStandard("F12",V.XK_F12),addStandard("F13",V.XK_F13),addStandard("F14",V.XK_F14),addStandard("F15",V.XK_F15),addStandard("F16",V.XK_F16),addStandard("F17",V.XK_F17),addStandard("F18",V.XK_F18),addStandard("F19",V.XK_F19),addStandard("F20",V.XK_F20),addStandard("F21",V.XK_F21),addStandard("F22",V.XK_F22),addStandard("F23",V.XK_F23),addStandard("F24",V.XK_F24),addStandard("F25",V.XK_F25),addStandard("F26",V.XK_F26),addStandard("F27",V.XK_F27),addStandard("F28",V.XK_F28),addStandard("F29",V.XK_F29),addStandard("F30",V.XK_F30),addStandard("F31",V.XK_F31),addStandard("F32",V.XK_F32),addStandard("F33",V.XK_F33),addStandard("F34",V.XK_F34),addStandard("F35",V.XK_F35),addStandard("Close",V.XF86XK_Close),addStandard("MailForward",V.XF86XK_MailForward),addStandard("MailReply",V.XF86XK_Reply),addStandard("MailSend",V.XF86XK_Send),addStandard("MediaFastForward",V.XF86XK_AudioForward),addStandard("MediaPause",V.XF86XK_AudioPause),addStandard("MediaPlay",V.XF86XK_AudioPlay),addStandard("MediaRecord",V.XF86XK_AudioRecord),addStandard("MediaRewind",V.XF86XK_AudioRewind),addStandard("MediaStop",V.XF86XK_AudioStop),addStandard("MediaTrackNext",V.XF86XK_AudioNext),addStandard("MediaTrackPrevious",V.XF86XK_AudioPrev),addStandard("New",V.XF86XK_New),addStandard("Open",V.XF86XK_Open),addStandard("Print",V.XK_Print),addStandard("Save",V.XF86XK_Save),addStandard("SpellCheck",V.XF86XK_Spell),addStandard("AudioVolumeDown",V.XF86XK_AudioLowerVolume),addStandard("AudioVolumeUp",V.XF86XK_AudioRaiseVolume),addStandard("AudioVolumeMute",V.XF86XK_AudioMute),addStandard("MicrophoneVolumeMute",V.XF86XK_AudioMicMute),addStandard("LaunchApplication1",V.XF86XK_MyComputer),addStandard("LaunchApplication2",V.XF86XK_Calculator),addStandard("LaunchCalendar",V.XF86XK_Calendar),addStandard("LaunchMail",V.XF86XK_Mail),addStandard("LaunchMediaPlayer",V.XF86XK_AudioMedia),addStandard("LaunchMusicPlayer",V.XF86XK_Music),addStandard("LaunchPhone",V.XF86XK_Phone),addStandard("LaunchScreenSaver",V.XF86XK_ScreenSaver),addStandard("LaunchSpreadsheet",V.XF86XK_Excel),addStandard("LaunchWebBrowser",V.XF86XK_WWW),addStandard("LaunchWebCam",V.XF86XK_WebCam),addStandard("LaunchWordProcessor",V.XF86XK_Word),addStandard("BrowserBack",V.XF86XK_Back),addStandard("BrowserFavorites",V.XF86XK_Favorites),addStandard("BrowserForward",V.XF86XK_Forward),addStandard("BrowserHome",V.XF86XK_HomePage),addStandard("BrowserRefresh",V.XF86XK_Refresh),addStandard("BrowserSearch",V.XF86XK_Search),addStandard("BrowserStop",V.XF86XK_Stop),addStandard("Dimmer",V.XF86XK_BrightnessAdjust),addStandard("MediaAudioTrack",V.XF86XK_AudioCycleTrack),addStandard("RandomToggle",V.XF86XK_AudioRandomPlay),addStandard("SplitScreenToggle",V.XF86XK_SplitScreen),addStandard("Subtitle",V.XF86XK_Subtitle),addStandard("VideoModeNext",V.XF86XK_Next_VMode),addNumpad("=",V.XK_equal,V.XK_KP_Equal),addNumpad("+",V.XK_plus,V.XK_KP_Add),addNumpad("-",V.XK_minus,V.XK_KP_Subtract),addNumpad("*",V.XK_asterisk,V.XK_KP_Multiply),addNumpad("/",V.XK_slash,V.XK_KP_Divide),addNumpad(".",V.XK_period,V.XK_KP_Decimal),addNumpad(",",V.XK_comma,V.XK_KP_Separator),addNumpad("0",V.XK_0,V.XK_KP_0),addNumpad("1",V.XK_1,V.XK_KP_1),addNumpad("2",V.XK_2,V.XK_KP_2),addNumpad("3",V.XK_3,V.XK_KP_3),addNumpad("4",V.XK_4,V.XK_KP_4),addNumpad("5",V.XK_5,V.XK_KP_5),addNumpad("6",V.XK_6,V.XK_KP_6),addNumpad("7",V.XK_7,V.XK_KP_7),addNumpad("8",V.XK_8,V.XK_KP_8),addNumpad("9",V.XK_9,V.XK_KP_9);let Keyboard=class Keyboard{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]}Debug("onkeyevent "+(s?"down":"up")+", keysym: "+e,", code: "+t),this.onkeyevent(e,t,s)}_getKeyCode(e){let t=getKeycode(e);if("Unidentified"!==t)return t;if(e.keyCode&&229!==e.keyCode)return"Platform"+e.keyCode;if(e.keyIdentifier){if("U+"!==e.keyIdentifier.substr(0,2))return e.keyIdentifier;let t=parseInt(e.keyIdentifier.substr(2),16),s=String.fromCharCode(t).toUpperCase();return"Platform"+s.charCodeAt()}return"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"\x00"===e.key&&"NumpadDecimal"===e.code?"Delete":e.key}let t=getKeycode(e);return t in Y?Y[t]:e.charCode?String.fromCharCode(e.charCode):"Unidentified"}(e);if("Unidentified"===t)return null;if(t in q){let s=e.location;if("Meta"===t&&0===s&&(s=2),"Clear"===t&&3===s&&"NumLock"===getKeycode(e)&&(s=0),(void 0===s||s>3)&&(s=0),"Meta"===t){let t=getKeycode(e);if("AltLeft"===t)return V.XK_Meta_L;if("AltRight"===t)return V.XK_Meta_R}if("Clear"===t&&"NumLock"===getKeycode(e))return V.XK_Num_Lock;if(isWindows())switch(t){case"Zenkaku":case"Hankaku":return V.XK_Zenkaku_Hankaku;case"Romaji":case"KanaMode":return V.XK_Romaji}return q[t][s]}if(1!==t.length)return null;let s=t.charCodeAt();return s?W.lookup(s):null}(e);if(this._altGrArmed&&(this._altGrArmed=!1,clearTimeout(this._altGrTimeout),"AltRight"===t&&e.timeStamp-this._altGrCtrlTime<50?s=V.XK_ISO_Level3_Shift:this._sendKeyEvent(V.XK_Control_L,"ControlLeft",!0)),"Unidentified"===t){s&&(this._sendKeyEvent(s,t,!0),this._sendKeyEvent(s,t,!1)),stopEvent(e);return}if(isMac()||isIOS())switch(s){case V.XK_Super_L:s=V.XK_Alt_L;break;case V.XK_Super_R:s=V.XK_Super_L;break;case V.XK_Alt_L:s=V.XK_Mode_switch;break;case V.XK_Alt_R:s=V.XK_ISO_Level3_Shift}if(t in this._keyDownList&&(s=this._keyDownList[t]),(isMac()||isIOS())&&"CapsLock"===t){this._sendKeyEvent(V.XK_Caps_Lock,"CapsLock",!0),this._sendKeyEvent(V.XK_Caps_Lock,"CapsLock",!1),stopEvent(e);return}let i=[V.XK_Zenkaku_Hankaku,V.XK_Eisu_toggle,V.XK_Katakana,V.XK_Hiragana,V.XK_Romaji];if(isWindows()&&i.includes(s)){this._sendKeyEvent(s,t,!0),this._sendKeyEvent(s,t,!1),stopEvent(e);return}if(stopEvent(e),"ControlLeft"===t&&isWindows()&&!("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){stopEvent(e);let t=this._getKeyCode(e);if(this._altGrArmed&&(this._altGrArmed=!1,clearTimeout(this._altGrTimeout),this._sendKeyEvent(V.XK_Control_L,"ControlLeft",!0)),(isMac()||isIOS())&&"CapsLock"===t){this._sendKeyEvent(V.XK_Caps_Lock,"CapsLock",!0),this._sendKeyEvent(V.XK_Caps_Lock,"CapsLock",!1);return}this._sendKeyEvent(this._keyDownList[t],t,!1),isWindows()&&("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(V.XK_Control_L,"ControlLeft",!0)}_allKeysUp(){for(let e in Debug(">> Keyboard.allKeysUp"),this._keyDownList)this._sendKeyEvent(this._keyDownList[e],e,!1);Debug("<< 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()}};let GestureHandler=class GestureHandler{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;s<e.changedTouches.length;s++){let i=e.changedTouches[s];t.call(this,i.identifier,i.clientX,i.clientY)}}_touchStart(e,t,s){if(this._hasDetectedGesture()||0===this._state){this._ignored.push(e);return}if(this._tracked.length>0&&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 a=t-i.firstX,r=s-i.firstY;if((i.firstX!==i.lastX||i.firstY!==i.lastY)&&(i.angle=180*Math.atan2(r,a)/Math.PI),!this._hasDetectedGesture()){if(50>Math.hypot(a,r))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;e<this._tracked.length;e++)this._tracked[e].active&&this._ignored.push(this._tracked[e].id);this._tracked=[],this._state=0,-1!==this._ignored.indexOf(e)&&this._ignored.splice(this._ignored.indexOf(e),1),0===this._ignored.length&&(this._state=127,this._waitingRelease=!1)}_hasDetectedGesture(){return!(0===this._state||this._state&this._state-1||7&this._state&&this._tracked.some(e=>e.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(),a=Math.abs(Math.hypot(i.first.x,i.first.y)-Math.hypot(i.last.x,i.last.y));s<a&&t<a?this._state=64:this._state=32,this._pushEvent("gesturestart"),this._pushEvent("gesturemove")}_pushEvent(e){let t={type:this._stateToGesture(this._state)},s=this._getPosition(),i=s.last;switch("gesturestart"===e&&(i=s.first),this._state){case 32:case 64:i=s.first}if(t.clientX=i.x,t.clientY=i.y,64===this._state){let s=this._getAverageDistance();"gesturestart"===e?(t.magnitudeX=s.first.x,t.magnitudeY=s.first.y):(t.magnitudeX=s.last.x,t.magnitudeY=s.last.y)}else if(32===this._state){if("gesturestart"===e)t.magnitudeX=0,t.magnitudeY=0;else{let e=this._getAverageMovement();t.magnitudeX=e.x,t.magnitudeY=e.y}}let a=new CustomEvent(e,{detail:t});this._target.dispatchEvent(a)}_stateToGesture(e){switch(e){case 1:return"onetap";case 2:return"twotap";case 4:return"threetap";case 8:return"drag";case 16:return"longpress";case 32:return"twodrag";case 64:return"pinch"}throw Error("Unknown gesture state: "+e)}_getPosition(){if(0===this._tracked.length)throw Error("Failed to get gesture position, no tracked touches");let e=this._tracked.length,t=0,s=0,i=0,a=0;for(let e=0;e<this._tracked.length;e++)t+=this._tracked[e].firstX,s+=this._tracked[e].firstY,i+=this._tracked[e].lastX,a+=this._tracked[e].lastY;return{first:{x:t/e,y:s/e},last:{x:i/e,y:a/e}}}_getAverageMovement(){let e,t;if(0===this._tracked.length)throw Error("Failed to get gesture movement, no tracked touches");e=t=0;let s=this._tracked.length;for(let s=0;s<this._tracked.length;s++)e+=this._tracked[s].lastX-this._tracked[s].firstX,t+=this._tracked[s].lastY-this._tracked[s].firstY;return{x:e/s,y:t/s}}_getAverageDistance(){if(0===this._tracked.length)throw Error("Failed to get gesture distance, no tracked touches");let e=this._tracked[0],t=this._tracked[this._tracked.length-1];return{first:{x:Math.abs(t.firstX-e.firstX),y:Math.abs(t.firstY-e.firstY)},last:{x:Math.abs(t.lastX-e.lastX),y:Math.abs(t.lastY-e.lastY)}}}};let j=!c||l;let Cursor=class Cursor{constructor(){this._target=null,this._canvas=document.createElement("canvas"),j&&(this._canvas.style.position="fixed",this._canvas.style.zIndex="65535",this._canvas.style.pointerEvents="none",this._canvas.style.visibility="hidden"),this._position={x:0,y:0},this._hotSpot={x:0,y:0},this._eventHandlers={mouseover:this._handleMouseOver.bind(this),mouseleave:this._handleMouseLeave.bind(this),mousemove:this._handleMouseMove.bind(this),mouseup:this._handleMouseUp.bind(this)}}attach(e){if(this._target&&this.detach(),this._target=e,j){document.body.appendChild(this._canvas);let e={capture:!0,passive:!0};this._target.addEventListener("mouseover",this._eventHandlers.mouseover,e),this._target.addEventListener("mouseleave",this._eventHandlers.mouseleave,e),this._target.addEventListener("mousemove",this._eventHandlers.mousemove,e),this._target.addEventListener("mouseup",this._eventHandlers.mouseup,e)}this.clear()}detach(){if(this._target){if(j){let e={capture:!0,passive:!0};this._target.removeEventListener("mouseover",this._eventHandlers.mouseover,e),this._target.removeEventListener("mouseleave",this._eventHandlers.mouseleave,e),this._target.removeEventListener("mousemove",this._eventHandlers.mousemove,e),this._target.removeEventListener("mouseup",this._eventHandlers.mouseup,e),document.body.removeChild(this._canvas)}this._target=null}}change(e,t,s,i,a){if(0===i||0===a){this.clear();return}this._position.x=this._position.x+this._hotSpot.x-t,this._position.y=this._position.y+this._hotSpot.y-s,this._hotSpot.x=t,this._hotSpot.y=s;let r=this._canvas.getContext("2d");this._canvas.width=i,this._canvas.height=a;let n=new ImageData(new Uint8ClampedArray(e),i,a);if(r.clearRect(0,0,i,a),r.putImageData(n,0,0),j)this._updatePosition();else{let e=this._canvas.toDataURL();this._target.style.cursor="url("+e+")"+t+" "+s+", default"}}clear(){this._target.style.cursor="none",this._canvas.width=0,this._canvas.height=0,this._position.x=this._position.x+this._hotSpot.x,this._position.y=this._position.y+this._hotSpot.y,this._hotSpot.x=0,this._hotSpot.y=0}move(e,t){if(!j)return;window.visualViewport?(this._position.x=e+window.visualViewport.offsetLeft,this._position.y=t+window.visualViewport.offsetTop):(this._position.x=e,this._position.y=t),this._updatePosition();let s=document.elementFromPoint(e,t);this._updateVisibility(s)}_handleMouseOver(e){this._handleMouseMove(e)}_handleMouseLeave(e){this._updateVisibility(e.relatedTarget)}_handleMouseMove(e){this._updateVisibility(e.target),this._position.x=e.clientX-this._hotSpot.x,this._position.y=e.clientY-this._hotSpot.y,this._updatePosition()}_handleMouseUp(e){let t=document.elementFromPoint(e.clientX,e.clientY);this._updateVisibility(t),this._captureIsActive()&&window.setTimeout(()=>{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 Z={CONNECTING:"connecting",OPEN:"open",CLOSING:"closing",CLOSED:"closed"},J={CONNECTING:[WebSocket.CONNECTING,Z.CONNECTING],OPEN:[WebSocket.OPEN,Z.OPEN],CLOSING:[WebSocket.CLOSING,Z.CLOSING],CLOSED:[WebSocket.CLOSED,Z.CLOSED]},$=["send","close","binaryType","onerror","onmessage","onopen","protocol","readyState"];let Websock=class Websock{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,J.CONNECTING.includes(e))?"connecting":J.OPEN.includes(e)?"open":J.CLOSING.includes(e)?"closing":J.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;s<e;s+=4096){let i=this.rQshiftBytes(Math.min(4096,e-s));t+=String.fromCharCode.apply(null,i)}return t}rQshiftBytes(e){return void 0===e&&(e=this.rQlen),this._rQi+=e,new Uint8Array(this._rQ.buffer,this._rQi-e,e)}rQshiftTo(e,t){void 0===t&&(t=this.rQlen),e.set(new Uint8Array(this._rQ.buffer,this._rQi,t)),this._rQi+=t}rQslice(e,t=this.rQlen){return new Uint8Array(this._rQ.buffer,this._rQi+e,t-e)}rQwait(e,t,s){if(this.rQlen<t){if(s){if(this._rQi<s)throw Error("rQwait cannot backup "+s+" bytes");this._rQi-=s}return!0}return!1}flush(){this._sQlen>0&&"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;e<$.length;e++){let s=$[e];if(0>t.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=()=>{Debug(">> WebSock.onopen"),this._websocket.protocol&&Info("Server choose sub-protocol: "+this._websocket.protocol),this._eventHandlers.open(),Debug("<< WebSock.onopen")},this._websocket.onclose=e=>{Debug(">> WebSock.onclose"),this._eventHandlers.close(e),Debug("<< WebSock.onclose")},this._websocket.onerror=e=>{Debug(">> WebSock.onerror: "+e),this._eventHandlers.error(e),Debug("<< WebSock.onerror: "+e)}}close(){this._websocket&&(("connecting"===this.readyState||"open"===this.readyState)&&(Info("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._rQbufferSize<t;if(s&&(this._rQbufferSize=Math.max(2*this._rQbufferSize,t)),this._rQbufferSize>41943040&&(this._rQbufferSize=41943040,this._rQbufferSize-this.rQlen<e))throw Error("Receive Queue buffer exceeded 41943040 bytes, and the new message could not fit");if(s){let e=this._rQ.buffer;this._rQ=new Uint8Array(this._rQbufferSize),this._rQ.set(new Uint8Array(e,this._rQi,this._rQlen-this._rQi))}else this._rQ.copyWithin(0,this._rQi,this._rQlen);this._rQlen=this._rQlen-this._rQi,this._rQi=0}_DecodeMessage(e){let t=new Uint8Array(e);t.length>this._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)):Debug("Ignoring empty message")}};let ee=[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],et=[1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28];r=(i=65536)|(a=16777216),h=(n=4)|(o=1024);let es=[r|o,0,0|i,r|h,r|n,i|h,0|n,0|i,0|o,r|o,r|h,0|o,a|h,r|n,0|a,0|n,0|h,a|o,a|o,i|o,i|o,0|r,0|r,a|h,i|n,a|n,a|n,i|n,0,0|h,i|h,0|a,0|i,r|h,0|n,0|r,r|o,0|a,0|a,0|o,r|n,0|i,i|o,a|n,0|o,0|n,a|h,i|h,r|h,i|n,0|r,a|h,a|n,0|h,i|h,r|o,0|h,a|o,a|o,0,i|n,i|o,0,r|n];r=(i=1048576)|(a=-2147483648),h=(n=32)|(o=32768);let ei=[r|h,a|o,0|o,i|h,0|i,0|n,r|n,a|h,a|n,r|h,r|o,0|a,a|o,0|i,0|n,r|n,i|o,i|n,a|h,0,0|a,0|o,i|h,0|r,i|n,a|n,0,i|o,0|h,r|o,0|r,0|h,0,i|h,r|n,0|i,a|h,0|r,r|o,0|o,0|r,a|o,0|n,r|h,i|h,0|n,0|o,0|a,0|h,r|o,0|i,a|n,i|n,a|h,a|n,i|n,i|o,0,a|o,0|h,0|a,r|n,r|h,i|o];r=(i=131072)|(a=134217728),h=(n=8)|(o=512);let ea=[0|h,r|o,0,r|n,a|o,0,i|h,a|o,i|n,a|n,a|n,0|i,r|h,i|n,0|r,0|h,0|a,0|n,r|o,0|o,i|o,0|r,r|n,i|h,a|h,i|o,0|i,a|h,0|n,r|h,0|o,0|a,r|o,0|a,i|n,0|h,0|i,r|o,a|o,0,0|o,i|n,r|h,a|o,a|n,0|o,0,r|n,a|h,0|i,0|a,r|h,0|n,i|h,i|o,a|n,0|r,a|h,0|h,0|r,i|h,0|n,r|n,i|o];r=(i=8192)|(a=8388608),h=(n=1)|(o=128);let er=[r|n,i|h,i|h,0|o,r|o,a|h,a|n,i|n,0,0|r,0|r,r|h,0|h,0,a|o,a|n,0|n,0|i,0|a,r|n,0|o,0|a,i|n,i|o,a|h,0|n,i|o,a|o,0|i,r|o,r|h,0|h,a|o,a|n,0|r,r|h,0|h,0,0,0|r,i|o,a|o,a|h,0|n,r|n,i|h,i|h,0|o,r|h,0|h,0|n,0|i,a|n,i|n,r|o,a|h,i|n,i|o,0|a,r|n,0|o,0|a,0|i,r|o];r=(i=33554432)|(a=1073741824),h=(n=256)|(o=524288);let en=[0|n,i|h,i|o,r|n,0|o,0|n,0|a,i|o,a|h,0|o,i|n,a|h,r|n,r|o,0|h,0|a,0|i,a|o,a|o,0,a|n,r|h,r|h,i|n,r|o,a|n,0,0|r,i|h,0|i,0|r,0|h,0|o,r|n,0|n,0|i,0|a,i|o,r|n,a|h,i|n,0|a,r|o,i|h,a|h,0|n,0|i,r|o,r|h,0|h,0|r,r|h,i|o,0,a|o,0|r,0|h,i|n,a|n,0|o,0,a|o,i|h,a|n];r=(i=4194304)|(a=536870912),h=(n=16)|(o=16384);let eo=[a|n,0|r,0|o,r|h,0|r,0|n,r|h,0|i,a|o,i|h,0|i,a|n,i|n,a|o,0|a,0|h,0,i|n,a|h,0|o,i|o,a|h,0|n,r|n,r|n,0,i|h,r|o,0|h,i|o,r|o,0|a,a|o,0|n,r|n,i|o,r|h,0|i,0|h,a|n,0|i,a|o,0|a,0|h,a|n,r|h,i|o,0|r,i|h,r|o,0,r|n,0|n,0|o,0|r,i|h,0|o,i|n,a|h,0,r|o,0|a,i|n,a|h];r=(i=2097152)|(a=67108864),h=(n=2)|(o=2048);let eh=[0|i,r|n,a|h,0,0|o,a|h,i|h,r|o,r|h,0|i,0,a|n,0|n,0|a,r|n,0|h,a|o,i|h,i|n,a|o,a|n,0|r,r|o,i|n,0|r,0|o,0|h,r|h,i|o,0|n,0|a,i|o,0|a,i|o,0|i,a|h,a|h,r|n,r|n,0|n,i|n,0|a,a|o,0|i,r|o,0|h,i|h,r|o,0|h,a|n,r|h,0|r,i|o,0,0|n,r|h,0,i|h,0|r,0|o,a|n,a|o,0|o,i|n];r=(i=262144)|(a=268435456),h=(n=64)|(o=4096);let ed=[a|h,0|o,0|i,r|h,0|a,a|h,0|n,0|a,i|n,0|r,r|h,i|o,r|o,i|h,0|o,0|n,0|r,a|n,a|o,0|h,i|o,i|n,r|n,r|o,0|h,0,0,r|n,a|n,a|o,i|h,0|i,i|h,0|i,r|o,0|o,0|n,r|n,0|o,i|h,a|o,0|n,a|n,0|r,r|n,0|a,0|i,a|h,0,r|h,i|n,a|n,0|r,a|o,a|h,0,r|h,i|o,i|o,0|h,0|h,i|n,0|a,r|o];let DES=class DES{constructor(e){this.keys=[];let t=[],s=[],i=[];for(let s=0,i=56;s<56;++s,i-=8){i+=i<-5?65:i<-3?31:i<-1?63:27===i?35:0;let a=7&i;t[s]=(e[i>>>3]&1<<a)!=0?1:0}for(let e=0;e<16;++e){let a=e<<1,r=a+1;i[a]=i[r]=0;for(let i=28;i<59;i+=28)for(let a=i-28;a<i;++a){let r=a+et[e];s[a]=r<i?t[r]:t[r-28]}for(let e=0;e<24;++e)0!==s[ee[e]]&&(i[a]|=1<<23-e),0!==s[ee[e+24]]&&(i[r]|=1<<23-e)}for(let e=0,t=0,s=0;e<16;++e){let e=i[t++],a=i[t++];this.keys[s]=(16515072&e)<<6,this.keys[s]|=(4032&e)<<10,this.keys[s]|=(16515072&a)>>>10,this.keys[s]|=(4032&a)>>>6,++s,this.keys[s]=(258048&e)<<12,this.keys[s]|=(63&e)<<16,this.keys[s]|=(258048&a)>>>4,this.keys[s]|=63&a,++s}}enc8(e){let t=e.slice(),s=0,i,a,r;r=((i=t[s++]<<24|t[s++]<<16|t[s++]<<8|t[s++])>>>4^(a=t[s++]<<24|t[s++]<<16|t[s++]<<8|t[s++]))&252645135,a^=r,i^=r<<4,r=(i>>>16^a)&65535,a^=r,i^=r<<16,r=(a>>>2^i)&858993459,i^=r,a^=r<<2,r=(a>>>8^i)&16711935,i^=r,a^=r<<8,r=(i^(a=a<<1|a>>>31&1))&2863311530,i^=r,a^=r,i=i<<1|i>>>31&1;for(let e=0,t=0;e<8;++e){let e=eh[63&(r=(a<<28|a>>>4)^this.keys[t++])];e|=en[r>>>8&63],e|=ea[r>>>16&63],e|=es[r>>>24&63],e|=ed[63&(r=a^this.keys[t++])],e|=eo[r>>>8&63],e|=er[r>>>16&63],e|=ei[r>>>24&63],i^=e,a^=e=eh[63&(r=(i<<28|i>>>4)^this.keys[t++])]|en[r>>>8&63]|ea[r>>>16&63]|es[r>>>24&63]|ed[63&(r=i^this.keys[t++])]|eo[r>>>8&63]|er[r>>>16&63]|ei[r>>>24&63]}for(r=(i^(a=a<<31|a>>>1))&2863311530,i^=r,a^=r,r=((i=i<<31|i>>>1)>>>8^a)&16711935,a^=r,i^=r<<8,r=(i>>>2^a)&858993459,a^=r,i^=r<<2,r=(a>>>16^i)&65535,i^=r,a^=r<<16,r=(a>>>4^i)&252645135,i^=r,a^=r<<4,r=[a,i],s=0;s<8;s++)t[s]=(r[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 el={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 e_={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};let RawDecoder=class RawDecoder{constructor(){this._lines=0}decodeRect(e,t,s,i,a,r,n){if(0===s||0===i)return!0;0===this._lines&&(this._lines=i);let o=s*(8==n?1:4);if(a.rQwait("RAW",o))return!1;let h=t+(i-this._lines),d=Math.min(this._lines,Math.floor(a.rQlen/o)),l=s*d,_=a.rQ,u=a.rQi;if(8==n){let e=new Uint8Array(4*l);for(let t=0;t<l;t++)e[4*t+0]=(_[u+t]>>0&3)*255/3,e[4*t+1]=(_[u+t]>>2&3)*255/3,e[4*t+2]=(_[u+t]>>4&3)*255/3,e[4*t+3]=255;_=e,u=0}for(let e=0;e<l;e++)_[4*e+3]=255;return r.blitImage(e,h,s,d,_,u),a.rQskipBytes(d*o),this._lines-=d,!(this._lines>0)}};let CopyRectDecoder=class CopyRectDecoder{decodeRect(e,t,s,i,a,r,n){if(a.rQwait("COPYRECT",4))return!1;let o=a.rQshift16(),h=a.rQshift16();return 0===s||0===i||(r.copyImage(o,h,e,t,s,i),!0)}};let RREDecoder=class RREDecoder{constructor(){this._subrects=0}decodeRect(e,t,s,i,a,r,n){if(0===this._subrects){if(a.rQwait("RRE",8))return!1;this._subrects=a.rQshift32();let n=a.rQshiftBytes(4);r.fillRect(e,t,s,i,n)}for(;this._subrects>0;){if(a.rQwait("RRE",12))return!1;let s=a.rQshiftBytes(4),i=a.rQshift16(),n=a.rQshift16(),o=a.rQshift16(),h=a.rQshift16();r.fillRect(e+i,t+n,o,h,s),this._subrects--}return!0}};let HextileDecoder=class HextileDecoder{constructor(){this._tiles=0,this._lastsubencoding=0,this._tileBuffer=new Uint8Array(1024)}decodeRect(e,t,s,i,a,r,n){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 n=1;if(a.rQwait("HEXTILE",n))return!1;let o=a.rQ,h=a.rQi,d=o[h];if(d>30)throw Error("Illegal hextile subencoding (subencoding: "+d+")");let l=this._totalTiles-this._tiles,_=l%this._tilesX,u=Math.floor(l/this._tilesX),c=e+16*_,f=t+16*u,p=Math.min(16,e+s-c),g=Math.min(16,t+i-f);if(1&d)n+=p*g*4;else if(2&d&&(n+=4),4&d&&(n+=4),8&d){if(n++,a.rQwait("HEXTILE",n))return!1;let e=o[h+n-1];16&d?n+=6*e:n+=2*e}if(a.rQwait("HEXTILE",n))return!1;if(h++,0===d)1&this._lastsubencoding?Debug(" Ignoring blank after RAW"):r.fillRect(c,f,p,g,this._background);else if(1&d){let e=p*g;for(let t=0;t<e;t++)o[h+4*t+3]=255;r.blitImage(c,f,p,g,o,h),h+=n-1}else{if(2&d&&(this._background=[o[h],o[h+1],o[h+2],o[h+3]],h+=4),4&d&&(this._foreground=[o[h],o[h+1],o[h+2],o[h+3]],h+=4),this._startTile(c,f,p,g,this._background),8&d){let e=o[h];h++;for(let t=0;t<e;t++){let e;16&d?(e=[o[h],o[h+1],o[h+2],o[h+3]],h+=4):e=this._foreground;let t=o[h];h++;let s=t>>4,i=15&t,a=o[h];h++;let r=(a>>4)+1,n=(15&a)+1;this._subTile(s,i,r,n,e)}}this._finishTile(r)}a.rQi=h,this._lastsubencoding=d,this._tiles--}return!0}_startTile(e,t,s,i,a){this._tileX=e,this._tileY=t,this._tileW=s,this._tileH=i;let r=a[0],n=a[1],o=a[2],h=this._tileBuffer;for(let e=0;e<s*i*4;e+=4)h[e]=r,h[e+1]=n,h[e+2]=o,h[e+3]=255}_subTile(e,t,s,i,a){let r=a[0],n=a[1],o=a[2],h=e+s,d=t+i,l=this._tileBuffer,_=this._tileW;for(let s=t;s<d;s++)for(let t=e;t<h;t++){let e=(t+s*_)*4;l[e]=r,l[e+1]=n,l[e+2]=o,l[e+3]=255}}_finishTile(e){e.blitImage(this._tileX,this._tileY,this._tileW,this._tileH,this._tileBuffer,0)}};let TightDecoder=class TightDecoder{constructor(){this._ctl=null,this._filter=null,this._numColors=0,this._palette=new Uint8Array(1024),this._len=0,this._zlibs=[];for(let e=0;e<4;e++)this._zlibs[e]=new Inflate}decodeRect(e,t,s,i,a,r,n){let o;if(null===this._ctl){if(a.rQwait("TIGHT compression-control",1))return!1;this._ctl=a.rQshift8();for(let e=0;e<4;e++)this._ctl>>e&1&&(this._zlibs[e].reset(),Info("Reset zlib stream "+e));this._ctl=this._ctl>>4}if(8===this._ctl)o=this._fillRect(e,t,s,i,a,r,n);else if(9===this._ctl)o=this._jpegRect(e,t,s,i,a,r,n);else if(10===this._ctl)o=this._pngRect(e,t,s,i,a,r,n);else if((8&this._ctl)==0)o=this._basicRect(this._ctl,e,t,s,i,a,r,n);else throw Error("Illegal tight compression received (ctl: "+this._ctl+")");return o&&(this._ctl=null),o}_fillRect(e,t,s,i,a,r,n){if(a.rQwait("TIGHT",3))return!1;let o=a.rQi,h=a.rQ;return r.fillRect(e,t,s,i,[h[o],h[o+1],h[o+2]],!1),a.rQskipBytes(3),!0}_jpegRect(e,t,s,i,a,r,n){let o=this._readData(a);return null!==o&&(r.imageRect(e,t,s,i,"image/jpeg",o),!0)}_pngRect(e,t,s,i,a,r,n){throw Error("PNG received in standard Tight rect")}_basicRect(e,t,s,i,a,r,n,o){let h;if(null===this._filter){if(4&e){if(r.rQwait("TIGHT",1))return!1;this._filter=r.rQshift8()}else this._filter=0}let d=3&e;switch(this._filter){case 0:h=this._copyFilter(d,t,s,i,a,r,n,o);break;case 1:h=this._paletteFilter(d,t,s,i,a,r,n,o);break;case 2:h=this._gradientFilter(d,t,s,i,a,r,n,o);break;default:throw Error("Illegal tight filter received (ctl: "+this._filter+")")}return h&&(this._filter=null),h}_copyFilter(e,t,s,i,a,r,n,o){let h;let d=i*a*3;if(0===d)return!0;if(d<12){if(r.rQwait("TIGHT",d))return!1;h=r.rQshiftBytes(d)}else{if(null===(h=this._readData(r)))return!1;this._zlibs[e].setInput(h),h=this._zlibs[e].inflate(d),this._zlibs[e].setInput(null)}let l=new Uint8Array(i*a*4);for(let e=0,t=0;e<i*a*4;e+=4,t+=3)l[e]=h[t],l[e+1]=h[t+1],l[e+2]=h[t+2],l[e+3]=255;return n.blitImage(t,s,i,a,l,0,!1),!0}_paletteFilter(e,t,s,i,a,r,n,o){let h;if(0===this._numColors){if(r.rQwait("TIGHT palette",1))return!1;let e=r.rQpeek8()+1,t=3*e;if(r.rQwait("TIGHT palette",1+t))return!1;this._numColors=e,r.rQskipBytes(1),r.rQshiftTo(this._palette,t)}let d=this._numColors<=2?1:8,l=Math.floor((i*d+7)/8),_=l*a;if(0===_)return!0;if(_<12){if(r.rQwait("TIGHT",_))return!1;h=r.rQshiftBytes(_)}else{if(null===(h=this._readData(r)))return!1;this._zlibs[e].setInput(h),h=this._zlibs[e].inflate(_),this._zlibs[e].setInput(null)}return 2==this._numColors?this._monoRect(t,s,i,a,h,this._palette,n):this._paletteRect(t,s,i,a,h,this._palette,n),this._numColors=0,!0}_monoRect(e,t,s,i,a,r,n){let o=this._getScratchBuffer(s*i*4),h=Math.floor((s+7)/8),d=Math.floor(s/8);for(let e=0;e<i;e++){let t,i,n;for(n=0;n<d;n++)for(let d=7;d>=0;d--)t=(e*s+8*n+7-d)*4,i=(a[e*h+n]>>d&1)*3,o[t]=r[i],o[t+1]=r[i+1],o[t+2]=r[i+2],o[t+3]=255;for(let d=7;d>=8-s%8;d--)t=(e*s+8*n+7-d)*4,i=(a[e*h+n]>>d&1)*3,o[t]=r[i],o[t+1]=r[i+1],o[t+2]=r[i+2],o[t+3]=255}n.blitImage(e,t,s,i,o,0,!1)}_paletteRect(e,t,s,i,a,r,n){let o=this._getScratchBuffer(s*i*4),h=s*i*4;for(let e=0,t=0;e<h;e+=4,t++){let s=3*a[t];o[e]=r[s],o[e+1]=r[s+1],o[e+2]=r[s+2],o[e+3]=255}n.blitImage(e,t,s,i,o,0,!1)}_gradientFilter(e,t,s,i,a,r,n,o){throw Error("Gradient filter not implemented")}_readData(e){if(0===this._len){let t;if(e.rQwait("TIGHT",3))return null;t=e.rQshift8(),this._len=127&t,128&t&&(t=e.rQshift8(),this._len|=(127&t)<<7,128&t&&(t=e.rQshift8(),this._len|=t<<14))}if(e.rQwait("TIGHT",this._len))return null;let t=e.rQshiftBytes(this._len);return this._len=0,t}_getScratchBuffer(e){return(!this._scratchBuffer||this._scratchBuffer.length<e)&&(this._scratchBuffer=new Uint8Array(e)),this._scratchBuffer}};let TightPNGDecoder=class TightPNGDecoder extends TightDecoder{_pngRect(e,t,s,i,a,r,n){let o=this._readData(a);return null!==o&&(r.imageRect(e,t,s,i,"image/png",o),!0)}_basicRect(e,t,s,i,a,r,n,o){throw Error("BasicCompression received in TightPNG rect")}};let RFB=class RFB extends EventTargetMixin{constructor(e,t,s){if(!e)throw Error("Must specify target");if(!t)throw Error("Must specify URL, WebSocket or RTCDataChannel");super(),this._target=e,"string"==typeof t?this._url=t:(this._url=null,this._rawChannel=t),s=s||{},this._rfbCredentials=s.credentials||{},this._shared=!("shared"in s)||!!s.shared,this._repeaterID=s.repeaterID||"",this._wsProtocols=s.wsProtocols||[],this._rfbConnectionState="",this._rfbInitState="",this._rfbAuthScheme=-1,this._rfbCleanDisconnect=!0,this._rfbVersion=0,this._rfbMaxVersion=3.8,this._rfbTightVNC=!1,this._rfbVeNCryptState=0,this._rfbXvpVer=0,this._fbWidth=0,this._fbHeight=0,this._fbName="",this._capabilities={power:!1},this._supportsFence=!1,this._supportsContinuousUpdates=!1,this._enabledContinuousUpdates=!1,this._supportsSetDesktopSize=!1,this._screenID=0,this._screenFlags=0,this._qemuExtKeyEventSupported=!1,this._clipboardText=null,this._clipboardServerCapabilitiesActions={},this._clipboardServerCapabilitiesFormats={},this._sock=null,this._display=null,this._flushing=!1,this._keyboard=null,this._gestures=null,this._resizeObserver=null,this._disconnTimer=null,this._resizeTimeout=null,this._mouseMoveTimer=null,this._decoders={},this._FBU={rects:0,x:0,y:0,width:0,height:0,encoding:null},this._mousePos={},this._mouseButtonMask=0,this._mouseLastMoveTime=0,this._viewportDragging=!1,this._viewportDragPos={},this._viewportHasMoved=!1,this._accumulatedWheelDeltaX=0,this._accumulatedWheelDeltaY=0,this._gestureLastTapTime=null,this._gestureFirstDoubleTapEv=null,this._gestureLastMagnitudeX=0,this._gestureLastMagnitudeY=0,this._eventHandlers={focusCanvas:this._focusCanvas.bind(this),handleResize:this._handleResize.bind(this),handleMouse:this._handleMouse.bind(this),handleWheel:this._handleWheel.bind(this),handleGesture:this._handleGesture.bind(this)},Debug(">> 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 Cursor,this._cursorImage=RFB.cursors.none,this._decoders[e_.encodingRaw]=new RawDecoder,this._decoders[e_.encodingCopyRect]=new CopyRectDecoder,this._decoders[e_.encodingRRE]=new RREDecoder,this._decoders[e_.encodingHextile]=new HextileDecoder,this._decoders[e_.encodingTight]=new TightDecoder,this._decoders[e_.encodingTightPNG]=new TightPNGDecoder;try{this._display=new Display(this._canvas)}catch(e){throw logging_Error("Display exception: "+e),e}this._display.onflush=this._onFlush.bind(this),this._keyboard=new Keyboard(this._canvas),this._keyboard.onkeyevent=this._handleKeyEvent.bind(this),this._gestures=new GestureHandler,this._sock=new Websock,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"),Debug("<< 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&&(Warn("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){Warn("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){logging_Error("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){logging_Error("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||(Info("Sending Ctrl-Alt-Del"),this.sendKey(V.XK_Control_L,"ControlLeft",!0),this.sendKey(V.XK_Alt_L,"AltLeft",!0),this.sendKey(V.XK_Delete,"Delete",!0),this.sendKey(V.XK_Delete,"Delete",!1),this.sendKey(V.XK_Alt_L,"AltLeft",!1),this.sendKey(V.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=el[t];if(this._qemuExtKeyEventSupported&&i)Info("Sending key ("+(s?"down":"up")+"): keysym "+(e=e||0)+", scancode "+i),RFB.messages.QEMUExtendedKeyEvent(this._sock,e,s,i);else{if(!e)return;Info("Sending keysym ("+(s?"down":"up")+"): "+e),RFB.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,RFB.messages.extendedClipboardNotify(this._sock,[1]);else{let t=new Uint8Array(e.length);for(let s=0;s<e.length;s++)t[s]=e.charCodeAt(s);RFB.messages.clientCutText(this._sock,t)}}}_connect(){if(Debug(">> RFB.connect"),this._url)Info(`connecting to ${this._url}`),this._sock.open(this._url,this._wsProtocols);else{if(Info(`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),Debug("<< RFB.connect")}_disconnect(){Debug(">> 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),Debug("<< RFB.disconnect")}_socketOpen(){"connecting"===this._rfbConnectionState&&""===this._rfbInitState?(this._rfbInitState="ProtocolVersion",Debug("Starting VNC handshake")):this._fail("Unexpected server connection while "+this._rfbConnectionState)}_socketClose(e){Debug("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){Warn("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();RFB.messages.setDesktopSize(this._sock,Math.floor(e.w),Math.floor(e.h),this._screenID,this._screenFlags),Debug("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){Debug("Already in state '"+e+"', ignoring");return}if("disconnected"===t){logging_Error("Tried changing state of a disconnected RFB object");return}switch(e){case"connected":if("connecting"!==t){logging_Error("Bad transition to connected state, previous connection state: "+t);return}break;case"disconnected":if("disconnecting"!==t){logging_Error("Bad transition to disconnected state, previous connection state: "+t);return}break;case"connecting":if(""!==t){logging_Error("Bad transition to connecting state, previous connection state: "+t);return}break;case"disconnecting":if("connected"!==t&&"connecting"!==t){logging_Error("Bad transition to disconnecting state, previous connection state: "+t);return}break;default:logging_Error("Unknown connection state: "+e);return}switch(this._rfbConnectionState=e,Debug("New state '"+e+"', was '"+t+"'."),this._disconnTimer&&"disconnecting"!==e&&(Debug("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(()=>{logging_Error("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":logging_Error("Failed when disconnecting: "+e);break;case"connected":logging_Error("Failed while connected: "+e);break;case"connecting":logging_Error("Failed when connecting: "+e);break;default:logging_Error("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){Warn("handleMessage called on an empty receive queue");return}switch(this._rfbConnectionState){case"disconnected":logging_Error("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=clientToElement(e.clientX,e.clientY,this._canvas);switch(e.type){case"mousedown":!function(e){if(e.setCapture)e.setCapture(),document.captureElement=e;else{releaseCapture();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",_captureProxy),t.addEventListener("mousemove",_captureProxy),t.addEventListener("mouseup",_captureProxy)),document.captureElement=e,g.observe(e,{attributes:!0}),_capturedElemChanged(),t.style.display="",window.addEventListener("mousemove",_captureProxy),window.addEventListener("mouseup",_captureProxy)}}(this._canvas),this._handleMouseButton(t.x,t.y,!0,1<<e.button);break;case"mouseup":this._handleMouseButton(t.x,t.y,!1,1<<e.button);break;case"mousemove":this._handleMouseMove(t.x,t.y)}}_handleMouseButton(e,t,s,i){if(this.dragViewport){if(s&&!this._viewportDragging){this._viewportDragging=!0,this._viewportDragPos={x:e,y:t},this._viewportHasMoved=!1;return}if(this._viewportDragging=!1,this._viewportHasMoved)return;this._sendMouse(e,t,i)}null!==this._mouseMoveTimer&&(clearTimeout(this._mouseMoveTimer),this._mouseMoveTimer=null,this._sendMouse(e,t,this._mouseButtonMask)),s?this._mouseButtonMask|=i:this._mouseButtonMask&=~i,this._sendMouse(e,t,this._mouseButtonMask)}_handleMouseMove(e,t){if(this._viewportDragging){let s=this._viewportDragPos.x-e,i=this._viewportDragPos.y-t;(this._viewportHasMoved||Math.abs(s)>_||Math.abs(i)>_)&&(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||RFB.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=clientToElement(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=clientToElement(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=clientToElement(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=clientToElement(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(V.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(V.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);Info("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+="\x00";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"),Debug("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(Debug("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",Debug("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<this._rfbVeNCryptSubtypesLength;t++)e.push(this._sock.rQshift32());if(-1==e.indexOf(256))return this._fail("VeNCrypt Plain subtype not offered by server");this._sock.send([0,0,1,0]),this._rfbVeNCryptState=4}if(4==this._rfbVeNCryptState){if(void 0===this._rfbCredentials.username||void 0===this._rfbCredentials.password)return this.dispatchEvent(new CustomEvent("credentialsrequired",{detail:{types:["username","password"]}})),!1;let e=encodeUTF8(this._rfbCredentials.username),t=encodeUTF8(this._rfbCredentials.password);return this._sock.send([e.length>>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=RFB.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;t<e;t++){let e=this._sock.rQshift32(),t=this._sock.rQshiftStr(4),i=this._sock.rQshiftStr(8);s[e]={vendor:t,signature:i}}return(Debug("Server Tight tunnel types: "+s),s[1]&&"SICR"===s[1].vendor&&"SCHANNEL"===s[1].signature&&(Debug("Detected Siemens server. Assuming NOTUNNEL support."),s[0]={vendor:"TGHT",signature:"NOTUNNEL"}),s[0])?s[0].vendor!=t[0].vendor||s[0].signature!=t[0].signature?this._fail("Client's tunnel type had the incorrect vendor or signature"):(Debug("Selected tunnel type: "+t[0]),this._sock.send([0,0,0,0]),!1):this._fail("Server wanted tunnels, but doesn't support the notunnel type")}_negotiateTightAuth(){if(!this._rfbTightVNC){if(this._sock.rQwait("num tunnels",4))return!1;let e=this._sock.rQshift32();if(e>0&&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<e;t++){this._sock.rQshift32();let e=this._sock.rQshiftStr(12);s.push(e)}for(let e in Debug("Server Tight authentication types: "+s),t)if(-1!=s.indexOf(e))switch(this._sock.send([0,0,0,t[e]]),Debug("Selected authentication type: "+e),e){case"STDVNOAUTH__":return this._rfbInitState="SecurityResult",!0;case"STDVVNCAUTH_":return this._rfbAuthScheme=2,this._initMsg();case"TGHTULGNAUTH":return this._rfbAuthScheme=129,this._initMsg();default:return this._fail("Unsupported tiny auth scheme (scheme: "+e+")")}return this._fail("No supported sub-auth types!")}_negotiateAuthentication(){switch(this._rfbAuthScheme){case 1:if(this._rfbVersion>=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",Debug("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(),a=this._sock.rQshift8(),r=this._sock.rQshift8(),n=this._sock.rQshift16(),o=this._sock.rQshift16(),h=this._sock.rQshift16(),d=this._sock.rQshift8(),l=this._sock.rQshift8(),_=this._sock.rQshift8();this._sock.rQskipBytes(3);let u=this._sock.rQshift32();if(this._sock.rQwait("server init name",u,24))return!1;let c=this._sock.rQshiftStr(u);if(c=decodeUTF8(c,!0),this._rfbTightVNC){if(this._sock.rQwait("TightVNC extended server init header",8,24+u))return!1;let e=this._sock.rQshift16(),t=this._sock.rQshift16(),s=this._sock.rQshift16();this._sock.rQskipBytes(2);let i=(e+t+s)*16;if(this._sock.rQwait("TightVNC extended server init header",i,32+u))return!1;this._sock.rQskipBytes(16*e),this._sock.rQskipBytes(16*t),this._sock.rQskipBytes(16*s)}return Info("Screen: "+e+"x"+t+", bpp: "+s+", depth: "+i+", bigEndian: "+a+", trueColor: "+r+", redMax: "+n+", greenMax: "+o+", blueMax: "+h+", redShift: "+d+", greenShift: "+l+", blueShift: "+_),this._setDesktopName(c),this._resize(e,t),this._viewOnly||this._keyboard.grab(),this._fbDepth=24,"Intel(r) AMT KVM"===this._fbName&&(Warn("Intel AMT KVM only supports 8/16 bit depths. Using low color mode."),this._fbDepth=8),RFB.messages.pixelFormat(this._sock,this._fbDepth,!0),this._sendEncodings(),RFB.messages.fbUpdateRequest(this._sock,!1,0,0,this._fbWidth,this._fbHeight),this._updateConnectionState("connected"),!0}_sendEncodings(){let e=[];e.push(e_.encodingCopyRect),24==this._fbDepth&&(e.push(e_.encodingTight),e.push(e_.encodingTightPNG),e.push(e_.encodingHextile),e.push(e_.encodingRRE)),e.push(e_.encodingRaw),e.push(e_.pseudoEncodingQualityLevel0+this._qualityLevel),e.push(e_.pseudoEncodingCompressLevel0+this._compressionLevel),e.push(e_.pseudoEncodingDesktopSize),e.push(e_.pseudoEncodingLastRect),e.push(e_.pseudoEncodingQEMUExtendedKeyEvent),e.push(e_.pseudoEncodingExtendedDesktopSize),e.push(e_.pseudoEncodingXvp),e.push(e_.pseudoEncodingFence),e.push(e_.pseudoEncodingContinuousUpdates),e.push(e_.pseudoEncodingDesktopName),e.push(e_.pseudoEncodingExtendedClipboard),24==this._fbDepth&&(e.push(e_.pseudoEncodingVMwareCursor),e.push(e_.pseudoEncodingCursor)),RFB.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 Debug("SetColorMapEntries"),this._fail("Unexpected SetColorMapEntries message")}_handleServerCutText(){if(Debug("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<<e;s&t&&(this._clipboardServerCapabilitiesFormats[t]=!0,this._sock.rQshift32())}for(let e=24;e<=31;e++){let t=1<<e;this._clipboardServerCapabilitiesActions[t]=!!(i&t)}RFB.messages.extendedClipboardCaps(this._sock,[16777216,33554432,67108864,134217728,268435456],{extendedClipboardFormatText:0})}else if(33554432===i){if(this._viewOnly)return!0;null!=this._clipboardText&&this._clipboardServerCapabilitiesActions[268435456]&&1&s&&RFB.messages.extendedClipboardProvide(this._sock,[1],[this._clipboardText])}else if(67108864===i){if(this._viewOnly)return!0;this._clipboardServerCapabilitiesActions[134217728]&&(null!=this._clipboardText?RFB.messages.extendedClipboardNotify(this._sock,[1]):RFB.messages.extendedClipboardNotify(this._sock,[]))}else if(134217728===i){if(this._viewOnly)return!0;this._clipboardServerCapabilitiesActions[33554432]&&1&s&&RFB.messages.extendedClipboardRequest(this._sock,[1])}else{if(268435456!==i)return this._fail("Unexpected action in extended clipboard message: "+i);if(this._viewOnly||!(1&s))return!0;this._clipboardText=null;let t=this._sock.rQshiftBytes(e-4),a=new Inflate,r=null;a.setInput(t);for(let e=0;e<=15;e++){let t=1<<e;if(s&t){let e=0,s=a.inflate(4);e|=s[0]<<24,e|=s[1]<<16,e|=s[2]<<8,e|=s[3];let i=a.inflate(e);1===t&&(r=i)}}if(a.setInput(null),null!==r){let e="";for(let t=0;t<r.length;t++)e+=String.fromCharCode(r[t]);(r=decodeUTF8(r=e)).length>0&&"\x00"===r.charAt(r.length-1)&&(r=r.slice(0,-1)),r=r.replace("\r\n","\n"),this.dispatchEvent(new CustomEvent("clipboard",{detail:{text:r}}))}}}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&&(Warn("Bad payload length ("+t+") in fence response"),t=64);let s=this._sock.rQshiftStr(t);return(this._supportsFence=!0,-2147483648&e)?(e&=3,RFB.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:logging_Error("XVP Operation Failed");break;case 1:this._rfbXvpVer=e,Info("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&&RFB.messages.fbUpdateRequest(this._sock,!0,0,0,this._fbWidth,this._fbHeight),s;case 1:return this._handleSetColourMapMsg();case 2:return Debug("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(),Info("Enabling continuous updates.")),!0;case 248:return this._handleServerFenceMsg();case 250:return this._handleXvpMsg();default:return this._fail("Unexpected server message (type "+e+")"),Debug("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 e_.pseudoEncodingLastRect:return this._FBU.rects=1,!0;case e_.pseudoEncodingVMwareCursor:return this._handleVMwareCursor();case e_.pseudoEncodingCursor:return this._handleCursor();case e_.pseudoEncodingQEMUExtendedKeyEvent:return this._qemuExtKeyEventSupported=!0,!0;case e_.pseudoEncodingDesktopName:return this._handleDesktopName();case e_.pseudoEncodingDesktopSize:return this._resize(this._FBU.width,this._FBU.height),!0;case e_.pseudoEncodingExtendedDesktopSize:return this._handleExtendedDesktopSize();default:return this._handleDataRect()}}_handleVMwareCursor(){let e;let t=this._FBU.x,s=this._FBU.y,i=this._FBU.width,a=this._FBU.height;if(this._sock.rQwait("VMware cursor encoding",1))return!1;let r=this._sock.rQshift8();if(this._sock.rQshift8(),0==r){if(e=Array(i*a*4),this._sock.rQwait("VMware cursor classic encoding",i*a*8,2))return!1;let t=Array(i*a);for(let e=0;e<i*a;e++)t[e]=this._sock.rQshift32();let s=Array(i*a);for(let e=0;e<i*a;e++)s[e]=this._sock.rQshift32();for(let r=0;r<i*a;r++)if(0==t[r]){let t=s[r],i=t>>8&255,a=t>>16&255,n=t>>24&255;e[4*r]=i,e[4*r+1]=a,e[4*r+2]=n,e[4*r+3]=255}else(-256&t[r])==-256?0==s[r]?(e[4*r]=0,e[4*r+1]=0,e[4*r+2]=0,e[4*r+3]=0):(s[r],e[4*r]=0,e[4*r+1]=0,e[4*r+2]=0,e[4*r+3]=255):(e[4*r]=0,e[4*r+1]=0,e[4*r+2]=0,e[4*r+3]=255)}else{if(1!=r)return Warn("The given cursor type is not supported: "+r+" given."),!1;if(this._sock.rQwait("VMware cursor alpha encoding",i*a*4,2))return!1;e=Array(i*a*4);for(let t=0;t<i*a;t++){let s=this._sock.rQshift32();e[4*t]=s>>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,a),!0}_handleCursor(){let e=this._FBU.x,t=this._FBU.y,s=this._FBU.width,i=this._FBU.height,a=s*i*4,r=Math.ceil(s/8)*i,n=a+r;if(this._sock.rQwait("cursor encoding",n))return!1;let o=this._sock.rQshiftBytes(a),h=this._sock.rQshiftBytes(r),d=new Uint8Array(s*i*4),l=0;for(let e=0;e<i;e++)for(let t=0;t<s;t++){let i=h[e*Math.ceil(s/8)+Math.floor(t/8)]<<t%8&128?255:0;d[l]=o[l+2],d[l+1]=o[l+1],d[l+2]=o[l],d[l+3]=i,l+=4}return this._updateCursor(d,e,t,s,i),!0}_handleDesktopName(){if(this._sock.rQwait("DesktopName",4))return!1;let e=this._sock.rQshift32();if(this._sock.rQwait("DesktopName",e,4))return!1;let t=this._sock.rQshiftStr(e);return t=decodeUTF8(t,!0),this._setDesktopName(t),!0}_handleExtendedDesktopSize(){if(this._sock.rQwait("ExtendedDesktopSize",4))return!1;let e=this._sock.rQpeek8();if(this._sock.rQwait("ExtendedDesktopSize",4+16*e))return!1;let t=!this._supportsSetDesktopSize;this._supportsSetDesktopSize=!0,t&&this._requestRemoteResize(),this._sock.rQskipBytes(1),this._sock.rQskipBytes(3);for(let t=0;t<e;t+=1)0===t?(this._screenID=this._sock.rQshiftBytes(4),this._sock.rQskipBytes(2),this._sock.rQskipBytes(2),this._sock.rQskipBytes(2),this._sock.rQskipBytes(2),this._screenFlags=this._sock.rQshiftBytes(4)):this._sock.rQskipBytes(16);if(1===this._FBU.x&&0!==this._FBU.y){let e="";switch(this._FBU.y){case 1:e="Resize is administratively prohibited";break;case 2:e="Out of resources";break;case 3:e="Invalid screen layout";break;default:e="Unknown reason"}Warn("Server did not accept the resize request: "+e)}else this._resize(this._FBU.width,this._FBU.height);return!0}_handleDataRect(){let e=this._decoders[this._FBU.encoding];if(!e)return this._fail("Unsupported encoding (encoding: "+this._FBU.encoding+")"),!1;try{return e.decodeRect(this._FBU.x,this._FBU.y,this._FBU.width,this._FBU.height,this._sock,this._display,this._fbDepth)}catch(e){return this._fail("Error decoding rect: "+e),!1}}_updateContinuousUpdates(){this._enabledContinuousUpdates&&RFB.messages.enableContinuousUpdates(this._sock,!0,0,0,this._fbWidth,this._fbHeight)}_resize(e,t){this._fbWidth=e,this._fbHeight=t,this._display.resize(this._fbWidth,this._fbHeight),this._updateClip(),this._updateScale(),this._updateContinuousUpdates()}_xvpOp(e,t){this._rfbXvpVer<e||(Info("Sending XVP operation "+t+" (version "+e+")"),RFB.messages.xvpOp(this._sock,e,t))}_updateCursor(e,t,s,i,a){this._cursorImage={rgbaPixels:e,hotx:t,hoty:s,w:i,h:a},this._refreshCursor()}_shouldShowDotCursor(){if(!this._showDotCursor)return!1;for(let e=3;e<this._cursorImage.rgbaPixels.length;e+=4)if(this._cursorImage.rgbaPixels[e])return!1;return!0}_refreshCursor(){if("connecting"!==this._rfbConnectionState&&"connected"!==this._rfbConnectionState)return;let e=this._shouldShowDotCursor()?RFB.cursors.dot:this._cursorImage;this._cursor.change(e.rgbaPixels,e.hotx,e.hoty,e.w,e.h)}static genDES(e,t){let s=e.split("").map(e=>e.charCodeAt(0));return new DES(s).encrypt(t)}};RFB.messages={keyEvent(e,t,s){let i=e._sQ,a=e._sQlen;i[a]=4,i[a+1]=s,i[a+2]=0,i[a+3]=0,i[a+4]=t>>24,i[a+5]=t>>16,i[a+6]=t>>8,i[a+7]=t,e._sQlen+=8,e.flush()},QEMUExtendedKeyEvent(e,t,s,i){let a=e._sQ,r=e._sQlen;a[r]=255,a[r+1]=0,a[r+2]=s>>8,a[r+3]=s,a[r+4]=t>>24,a[r+5]=t>>16,a[r+6]=t>>8,a[r+7]=t;let n=function(e){let t=i>>8,s=255&i;return 224===t&&s<127?128|s:e}(i);a[r+8]=n>>24,a[r+9]=n>>16,a[r+10]=n>>8,a[r+11]=n,e._sQlen+=12,e.flush()},pointerEvent(e,t,s,i){let a=e._sQ,r=e._sQlen;a[r]=5,a[r+1]=i,a[r+2]=t>>8,a[r+3]=t,a[r+4]=s>>8,a[r+5]=s,e._sQlen+=6,e.flush()},_buildExtendedClipboardFlags(e,t){let s=new Uint8Array(4),i=0,a=0;for(let t=0;t<e.length;t++)a|=e[t];for(let e=0;e<t.length;e++)i|=t[e];return s[0]=a>>24,s[1]=0,s[2]=0,s[3]=i,s},extendedClipboardProvide(e,t,s){let i=new Deflator,a=[];for(let e=0;e<t.length;e++){if(1!=t[e])throw Error("Unsupported extended clipboard format for Provide message.");s[e]=s[e].replace(/\r\n|\r|\n/gm,"\r\n");let i=encodeUTF8(s[e]+"\x00");a.push(i.length>>24&255,i.length>>16&255,i.length>>8&255,255&i.length);for(let e=0;e<i.length;e++)a.push(i.charCodeAt(e))}let r=i.deflate(new Uint8Array(a)),n=new Uint8Array(4+r.length);n.set(RFB.messages._buildExtendedClipboardFlags([268435456],t)),n.set(r,4),RFB.messages.clientCutText(e,n,!0)},extendedClipboardNotify(e,t){let s=RFB.messages._buildExtendedClipboardFlags([134217728],t);RFB.messages.clientCutText(e,s,!0)},extendedClipboardRequest(e,t){let s=RFB.messages._buildExtendedClipboardFlags([33554432],t);RFB.messages.clientCutText(e,s,!0)},extendedClipboardCaps(e,t,s){let i=Object.keys(s),a=new Uint8Array(4+4*i.length);i.map(e=>parseInt(e)),i.sort((e,t)=>e-t),a.set(RFB.messages._buildExtendedClipboardFlags(t,[]));let r=4;for(let e=0;e<i.length;e++)a[r]=s[i[e]]>>24,a[r+1]=s[i[e]]>>16,a[r+2]=s[i[e]]>>8,a[r+3]=s[i[e]]>>0,r+=4,a[3]|=1<<i[e];RFB.messages.clientCutText(e,a,!0)},clientCutText(e,t,s=!1){let i;let a=e._sQ,r=e._sQlen;a[r]=6,a[r+1]=0,a[r+2]=0,a[r+3]=0,i=s?-t.length>>>0:t.length,a[r+4]=i>>24,a[r+5]=i>>16,a[r+6]=i>>8,a[r+7]=i,e._sQlen+=8;let n=0,o=t.length;for(;o>0;){let s=Math.min(o,e._sQbufferSize-e._sQlen);for(let i=0;i<s;i++)a[e._sQlen+i]=t[n+i];e._sQlen+=s,e.flush(),o-=s,n+=s}},setDesktopSize(e,t,s,i,a){let r=e._sQ,n=e._sQlen;r[n]=251,r[n+1]=0,r[n+2]=t>>8,r[n+3]=t,r[n+4]=s>>8,r[n+5]=s,r[n+6]=1,r[n+7]=0,r[n+8]=i>>24,r[n+9]=i>>16,r[n+10]=i>>8,r[n+11]=i,r[n+12]=0,r[n+13]=0,r[n+14]=0,r[n+15]=0,r[n+16]=t>>8,r[n+17]=t,r[n+18]=s>>8,r[n+19]=s,r[n+20]=a>>24,r[n+21]=a>>16,r[n+22]=a>>8,r[n+23]=a,e._sQlen+=24,e.flush()},clientFence(e,t,s){let i=e._sQ,a=e._sQlen;i[a]=248,i[a+1]=0,i[a+2]=0,i[a+3]=0,i[a+4]=t>>24,i[a+5]=t>>16,i[a+6]=t>>8,i[a+7]=t;let r=s.length;i[a+8]=r;for(let e=0;e<r;e++)i[a+9+e]=s.charCodeAt(e);e._sQlen+=9+r,e.flush()},enableContinuousUpdates(e,t,s,i,a,r){let n=e._sQ,o=e._sQlen;n[o]=150,n[o+1]=t,n[o+2]=s>>8,n[o+3]=s,n[o+4]=i>>8,n[o+5]=i,n[o+6]=a>>8,n[o+7]=a,n[o+8]=r>>8,n[o+9]=r,e._sQlen+=10,e.flush()},pixelFormat(e,t,s){let i;let a=e._sQ,r=e._sQlen;i=t>16?32:t>8?16:8;let n=Math.floor(t/3);a[r]=0,a[r+1]=0,a[r+2]=0,a[r+3]=0,a[r+4]=i,a[r+5]=t,a[r+6]=0,a[r+7]=s?1:0,a[r+8]=0,a[r+9]=(1<<n)-1,a[r+10]=0,a[r+11]=(1<<n)-1,a[r+12]=0,a[r+13]=(1<<n)-1,a[r+14]=0*n,a[r+15]=1*n,a[r+16]=2*n,a[r+17]=0,a[r+18]=0,a[r+19]=0,e._sQlen+=20,e.flush()},clientEncodings(e,t){let s=e._sQ,i=e._sQlen;s[i]=2,s[i+1]=0,s[i+2]=t.length>>8,s[i+3]=t.length;let a=i+4;for(let e=0;e<t.length;e++){let i=t[e];s[a]=i>>24,s[a+1]=i>>16,s[a+2]=i>>8,s[a+3]=i,a+=4}e._sQlen+=a-i,e.flush()},fbUpdateRequest(e,t,s,i,a,r){let n=e._sQ,o=e._sQlen;void 0===s&&(s=0),void 0===i&&(i=0),n[o]=3,n[o+1]=t?1:0,n[o+2]=s>>8&255,n[o+3]=255&s,n[o+4]=i>>8&255,n[o+5]=255&i,n[o+6]=a>>8&255,n[o+7]=255&a,n[o+8]=r>>8&255,n[o+9]=255&r,e._sQlen+=10,e.flush()},xvpOp(e,t,s){let i=e._sQ,a=e._sQlen;i[a]=250,i[a+1]=0,i[a+2]=t,i[a+3]=s,e._sQlen+=4,e.flush()}},RFB.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}}}}]);