"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.right?a.x=i.width-1:a.x=e-i.left,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>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=8&&(r-=8,o||(a[s++]=n>>r&255),n&=(1<> Display.constructor"),this._target=e,!this._target)throw Error("Target must be set");if("string"==typeof this._target)throw Error("target must be a DOM element");if(!this._target.getContext)throw Error("no getContext method");this._targetCtx=this._target.getContext("2d"),this._viewportLoc={x:0,y:0,w:this._target.width,h:this._target.height},this._backbuffer=document.createElement("canvas"),this._drawCtx=this._backbuffer.getContext("2d"),this._damageBounds={left:0,top:0,right:this._backbuffer.width,bottom:this._backbuffer.height},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){ethis._damageBounds.right&&(this._damageBounds.right=e+s),t+i>this._damageBounds.bottom&&(this._damageBounds.bottom=t+i)}flip(e){if(0===this._renderQ.length||e){let e=this._damageBounds.left,t=this._damageBounds.top,s=this._damageBounds.right-e,i=this._damageBounds.bottom-t,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>>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=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;v0&&(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;w852||2===e&&A>592)return 1;for(;;){f=b-S,n[w]c?(p=R[P+n[w]],g=Q[D+n[w]]):(p=96,g=0),h=1<>S)+(d-=h)]=f<<24|p<<16|g|0;while(0!==d);for(h=1<>=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+S852||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++]<>>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<>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++]<>>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++]<>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++]<>>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>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++]<>>=7&p,p-=7&p,o.mode=27;break}for(;p<3;){if(0===u)break e;u--,f+=h[l++]<>>=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++]<>>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++]<>>=5,p-=5,o.ndist=(31&f)+1,f>>>=5,p-=5,o.ncode=(15&f)+4,f>>>=4,p-=4,o.nlen>286||o.ndist>30){e.msg="too many length or distance symbols",o.mode=30;break}o.have=0,o.mode=18;case 18:for(;o.have>>=3,p-=3}for(;o.have<19;)o.lens[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>>24,K=B>>>16&255,F=65535&B,!(X<=p);){if(0===u)break e;u--,f+=h[l++]<>>=X,p-=X,o.lens[o.have++]=F;else{if(16===F){for(L=X+2;p>>=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>>=X,p-=X,T=0,v=3+(7&f),f>>>=3,p-=3}else{for(L=X+7;p>>=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<>>=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,f-=v),f<15&&(c+=K[i++]<>>=v=w>>>24,f-=v,16&(v=w>>>16&255)){if(y=65535&w,f<(v&=15)&&(c+=K[i++]<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,v2;)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<>3,f-=k<<3,c&=(1<>>24,K=B>>>16&255,F=65535&B,!(X<=p);){if(0===u)break e;u--,f+=h[l++]<>x)])>>>24,K=B>>>16&255,F=65535&B,!(x+X<=p);){if(0===u)break e;u--,f+=h[l++]<>>=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>>=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<>>24,K=B>>>16&255,F=65535&B,!(X<=p);){if(0===u)break e;u--,f+=h[l++]<>x)])>>>24,K=B>>>16&255,F=65535&B,!(x+X<=p);){if(0===u)break e;u--,f+=h[l++]<>>=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>>=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++]<=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=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<>16-e.bi_valid,e.bi_valid+=s-16):(e.bi_buf|=t<>>=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]>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>>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>>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]&&rn){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<=3&&(e.ins_h=(e.ins_h<=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<=3&&(e.ins_h=(e.ins_h<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<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.gzindexa&&(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.gzindexa&&(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]&&ae.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<>=7;i<30;i++)for(e=0,I[i]=a<<7;e<1<0){let e=[s],i=s.length;do{if(this.strm.output=new Uint8Array(this.chunkSize),this.strm.next_out=0,this.strm.avail_out=this.chunkSize,(t=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=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;s0&&Date.now()-this._tracked[0].started>250||this._waitingRelease){this._state=0,this._ignored.push(e);return}switch(this._tracked.push({id:e,started:Date.now(),active:!0,firstX:t,firstY:s,lastX:t,lastY:s,angle:0}),this._tracked.length){case 1:this._startLongpressTimeout();break;case 2:this._state&=-26,this._stopLongpressTimeout();break;case 3:this._state&=-99;break;default:this._state=0}}_touchMove(e,t,s){let i=this._tracked.find(t=>t.id===e);if(void 0===i)return;i.lastX=t,i.lastY=s;let 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;ee.active))}_startLongpressTimeout(){this._stopLongpressTimeout(),this._longpressTimeoutId=setTimeout(()=>this._longpressTimeout(),1e3)}_stopLongpressTimeout(){clearTimeout(this._longpressTimeoutId),this._longpressTimeoutId=null}_longpressTimeout(){if(this._hasDetectedGesture())throw Error("A longpress gesture failed, conflict with a different gesture");this._state=16,this._pushEvent("gesturestart")}_startTwoTouchTimeout(){this._stopTwoTouchTimeout(),this._twoTouchTimeoutId=setTimeout(()=>this._twoTouchTimeout(),50)}_stopTwoTouchTimeout(){clearTimeout(this._twoTouchTimeoutId),this._twoTouchTimeoutId=null}_isTwoTouchTimeoutRunning(){return null!==this._twoTouchTimeoutId}_twoTouchTimeout(){if(0===this._tracked.length)throw Error("A pinch or two drag gesture failed, no tracked touches");let e=this._getAverageMovement(),t=Math.abs(e.x),s=Math.abs(e.y),i=this._getAverageDistance(),a=Math.abs(Math.hypot(i.first.x,i.first.y)-Math.hypot(i.last.x,i.last.y));s{this._target&&(t=document.elementFromPoint(e.clientX,e.clientY),this._updateVisibility(t))},0)}_showCursor(){"hidden"===this._canvas.style.visibility&&(this._canvas.style.visibility="")}_hideCursor(){"hidden"!==this._canvas.style.visibility&&(this._canvas.style.visibility="hidden")}_shouldShowCursor(e){return!!e&&(e===this._target||!!this._target.contains(e)&&"none"===window.getComputedStyle(e).cursor)}_updateVisibility(e){this._captureIsActive()&&(e=document.captureElement),this._shouldShowCursor(e)?this._showCursor():this._hideCursor()}_updatePosition(){this._canvas.style.left=this._position.x+"px",this._canvas.style.top=this._position.y+"px"}_captureIsActive(){return document.captureElement&&document.documentElement.contains(document.captureElement)}};let 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;s0&&"open"===this.readyState&&(this._websocket.send(this._encodeMessage()),this._sQlen=0)}send(e){this._sQ.set(e,this._sQlen),this._sQlen+=e.length,this.flush()}sendString(e){this.send(e.split("").map(e=>e.charCodeAt(0)))}off(e){this._eventHandlers[e]=()=>{}}on(e,t){this._eventHandlers[e]=t}_allocateBuffers(){this._rQ=new Uint8Array(this._rQbufferSize),this._sQ=new Uint8Array(this._sQbufferSize)}init(){this._allocateBuffers(),this._rQi=0,this._websocket=null}open(e,t){this.attach(new WebSocket(e,t))}attach(e){this.init();let t=[...Object.keys(e),...Object.getOwnPropertyNames(Object.getPrototypeOf(e))];for(let e=0;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._rQbufferSize41943040&&(this._rQbufferSize=41943040,this._rQbufferSize-this.rQlenthis._rQbufferSize-this._rQlen&&this._expandCompactRQ(t.length),this._rQ.set(t,this._rQlen),this._rQlen+=t.length}_recvMessage(e){this._DecodeMessage(e.data),this.rQlen>0?(this._eventHandlers.message(),this._rQlen==this._rQi&&(this._rQlen=0,this._rQi=0)):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<>>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>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;e0)}};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>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>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=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> 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> 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<_||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>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;t0&&this._sock.rQwait("tunnel capabilities",16*e,4))return!1;if(this._rfbTightVNC=!0,e>0)return this._negotiateTightTunnels(e),!1}if(this._sock.rQwait("sub auth count",4))return!1;let e=this._sock.rQshift32();if(0===e)return this._rfbInitState="SecurityResult",!0;if(this._sock.rQwait("sub auth capabilities",16*e,4))return!1;let t={STDVNOAUTH__:1,STDVVNCAUTH_:2,TGHTULGNAUTH:129},s=[];for(let t=0;t=3.8)return this._rfbInitState="SecurityResult",!0;return this._rfbInitState="ClientInitialisation",this._initMsg();case 22:return this._negotiateXvpAuth();case 2:return this._negotiateStdVNCAuth();case 16:return this._negotiateTightAuth();case 19:return this._negotiateVeNCryptAuth();case 129:return this._negotiateTightUnixAuth();default:return this._fail("Unsupported auth scheme (scheme: "+this._rfbAuthScheme+")")}}_handleSecurityResult(){if(this._sock.rQwait("VNC auth response ",4))return!1;let e=this._sock.rQshift32();return 0===e?(this._rfbInitState="ClientInitialisation",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<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>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>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;ee.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>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>24&255,i.length>>16&255,i.length>>8&255,255&i.length);for(let e=0;eparseInt(e)),i.sort((e,t)=>e-t),a.set(RFB.messages._buildExtendedClipboardFlags(t,[]));let r=4;for(let e=0;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<>>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>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>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<>8,s[i+3]=t.length;let a=i+4;for(let e=0;e>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}}}}]);