From 51b249b90a25d9e7dac4d4d3899be8a7cb70e7d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Padez?= Date: Sat, 1 Aug 2026 20:52:50 +0000 Subject: [PATCH] desktop: load noVNC as one bundle instead of 42 modules MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit public/novnc is unbundled noVNC source. The dynamic import pointed at rfb.js, so the browser walked the module graph natively: fetch a file, parse it, discover its imports, fetch those, repeat. The graph is 42 modules and six levels deep, so opening the desktop cost six SEQUENTIAL round trips and 42 requests before the VNC handshake could even start — and a hard refresh pays it in full every time. Over the tailnet that is the "takes a long time to load", not the pixels. Bundled with bun: 52 modules to one 190 KB file, 56 KB gzipped, one request. The regeneration command is in a comment next to the constant so a future noVNC bump does not silently keep serving a stale bundle. The source tree stays: it is what gets bundled, and keeping it makes the diff of a version bump readable. Co-Authored-By: Claude Opus 5 (1M context) --- public/novnc/rfb.bundle.js | 5 +++++ .../officerdev/src/apps/Desktop/DesktopView.tsx | 10 +++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 public/novnc/rfb.bundle.js diff --git a/public/novnc/rfb.bundle.js b/public/novnc/rfb.bundle.js new file mode 100644 index 00000000..564b48c8 --- /dev/null +++ b/public/novnc/rfb.bundle.js @@ -0,0 +1,5 @@ +function i6(Q){return Q>>>0}function Q0(Q){return Q|0}var r6="warn",w=()=>{},r=()=>{},l=()=>{},p=()=>{};function l8(Q){if(typeof Q>"u")Q=r6;else r6=Q;if(w=r=l=p=()=>{},typeof window.console<"u")switch(Q){case"debug":w=console.debug.bind(window.console);case"info":r=console.info.bind(window.console);case"warn":l=console.warn.bind(window.console);case"error":p=console.error.bind(window.console);case"none":break;default:throw new window.Error("invalid logging type '"+Q+"'")}}l8();function B0(Q,$=!1){try{return decodeURIComponent(escape(Q))}catch(V){if(V instanceof URIError){if($)return Q}throw V}}function q1(Q){return unescape(encodeURIComponent(Q))}var f1={toBase64Table:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".split(""),base64Pad:"=",encode(Q){let $="",V=Q.length,J=V%3;for(let G=0;G>2],$+=this.toBase64Table[((Q[G]&3)<<4)+(Q[G+1]>>4)],$+=this.toBase64Table[((Q[G+1]&15)<<2)+(Q[G+2]>>6)],$+=this.toBase64Table[Q[G+2]&63];let W=V-J;if(J===2)$+=this.toBase64Table[Q[W]>>2],$+=this.toBase64Table[((Q[W]&3)<<4)+(Q[W+1]>>4)],$+=this.toBase64Table[(Q[W+1]&15)<<2],$+=this.toBase64Table[64];else if(J===1)$+=this.toBase64Table[Q[W]>>2],$+=this.toBase64Table[(Q[W]&3)<<4],$+=this.toBase64Table[64],$+=this.toBase64Table[64];return $},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(Q,$=0){let V=Q.indexOf("=")-$;if(V<0)V=Q.length-$;let J=(V>>2)*3+Math.floor(V%4/1.5),W=Array(J),G=0,q=0;for(let U=0,Z=$;Z=8){if(G-=8,!X)W[U++]=q>>G&255;q&=(1<0||navigator.msMaxTouchPoints>0;window.addEventListener("touchstart",function Q(){Y6=!0,window.removeEventListener("touchstart",Q,!1)},!1);var V0=10*(window.devicePixelRatio||1),l6=!1;try{let Q=document.createElement("canvas");if(Q.style.cursor='url("data:image/x-icon;base64,AAACAAEACAgAAAIAAgA4AQAAFgAAACgAAAAIAAAAEAAAAAEAIAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////AAAAAAAAAAAAAAAAAAAAAA==") 2 2, default',Q.style.cursor.indexOf("url")===0)r("Data URI scheme cursor supported"),l6=!0;else l("Data URI scheme cursor not supported")}catch(Q){p("Data URI scheme cursor test exception: "+Q)}var o6=l6,o8=!0;try{let Q=document.createElement("div");Q.style.visibility="hidden",Q.style.overflow="scroll",document.body.appendChild(Q);let $=document.createElement("div");Q.appendChild($);let V=Q.offsetWidth-$.offsetWidth;Q.parentNode.removeChild(Q),o8=V!=0}catch(Q){p("Scrollbar test exception: "+Q)}var X6=!1;async function d8(){if(!("VideoDecoder"in window))return!1;let Q={codec:"avc1.42401f",codedWidth:1920,codedHeight:1080,optimizeForLatency:!0};if(!(await VideoDecoder.isConfigSupported(Q)).supported)return!1;let V=new Uint8Array(f1.decode("AAAAAWdCwBTZnpuAgICgAAADACAAAAZB4oVNAAAAAWjJYyyAAAABBgX//4HcRem95tlIt5Ys2CDZI+7veDI2NCAtIGNvcmUgMTY0IHIzMTA4IDMxZTE5ZjkgLSBILjI2NC9NUEVHLTQgQVZDIGNvZGVjIC0gQ29weWxlZnQgMjAwMy0yMDIzIC0gaHR0cDovL3d3dy52aWRlb2xhbi5vcmcveDI2NC5odG1sIC0gb3B0aW9uczogY2FiYWM9MCByZWY9NSBkZWJsb2NrPTE6MDowIGFuYWx5c2U9MHgxOjB4MTExIG1lPWhleCBzdWJtZT04IHBzeT0xIHBzeV9yZD0xLjAwOjAuMDAgbWl4ZWRfcmVmPTEgbWVfcmFuZ2U9MTYgY2hyb21hX21lPTEgdHJlbGxpcz0yIDh4OGRjdD0wIGNxbT0wIGRlYWR6b25lPTIxLDExIGZhc3RfcHNraXA9MSBjaHJvbWFfcXBfb2Zmc2V0PS0yIHRocmVhZHM9MSBsb29rYWhlYWRfdGhyZWFkcz0xIHNsaWNlZF90aHJlYWRzPTAgbnI9MCBkZWNpbWF0ZT0xIGludGVybGFjZWQ9MCBibHVyYXlfY29tcGF0PTAgY29uc3RyYWluZWRfaW50cmE9MCBiZnJhbWVzPTAgd2VpZ2h0cD0wIGtleWludD1pbmZpbml0ZSBrZXlpbnRfbWluPTI1IHNjZW5lY3V0PTQwIGludHJhX3JlZnJlc2g9MCByY19sb29rYWhlYWQ9NTAgcmM9YWJyIG1idHJlZT0xIGJpdHJhdGU9NDAwIHJhdGV0b2w9MS4wIHFjb21wPTAuNjAgcXBtaW49MCBxcG1heD02OSBxcHN0ZXA9NCBpcF9yYXRpbz0xLjQwIGFxPTE6MS4wMACAAAABZYiEBrxmKAAPVccAAS044AA5DRJMnkycJk4TPw==")),J=!1,W=null,G=new VideoDecoder({output:(U)=>{J=!0},error:(U)=>{W=U}}),q=new EncodedVideoChunk({timestamp:0,type:"key",data:V});G.configure(Q),G.decode(q);try{await G.flush()}catch(U){W=U}if(!J)return!1;if(W!==null)return!1;return!0}X6=await d8();function I1(){return!!/mac/i.exec(navigator.platform)}function u1(){return!!/win/i.exec(navigator.platform)}function _1(){return!!/ipad/i.exec(navigator.platform)||!!/iphone/i.exec(navigator.platform)||!!/ipod/i.exec(navigator.platform)}function y1(Q,$,V){let J=V.getBoundingClientRect(),W={x:0,y:0};if(Q=J.right)W.x=J.width-1;else W.x=Q-J.left;if($=J.bottom)W.y=J.height-1;else W.y=$-J.top;return W}function K1(Q){Q.stopPropagation(),Q.preventDefault()}var Z6=!1,a6=null;document.captureElement=null;function R1(Q){if(Z6)return;let $=new Q.constructor(Q.type,Q);if(Z6=!0,document.captureElement)document.captureElement.dispatchEvent($);else a6.dispatchEvent($);if(Z6=!1,Q.stopPropagation(),$.defaultPrevented)Q.preventDefault();if(Q.type==="mouseup")Q2()}function t6(){let Q=document.getElementById("noVNC_mouse_capture_elem");Q.style.cursor=window.getComputedStyle(document.captureElement).cursor}var s6=new MutationObserver(t6);function e6(Q){if(Q.setCapture)Q.setCapture(),document.captureElement=Q;else{Q2();let $=document.getElementById("noVNC_mouse_capture_elem");if($===null)$=document.createElement("div"),$.id="noVNC_mouse_capture_elem",$.style.position="fixed",$.style.top="0px",$.style.left="0px",$.style.width="100%",$.style.height="100%",$.style.zIndex=1e4,$.style.display="none",document.body.appendChild($),$.addEventListener("contextmenu",R1),$.addEventListener("mousemove",R1),$.addEventListener("mouseup",R1);document.captureElement=Q,s6.observe(Q,{attributes:!0}),t6(),$.style.display="",window.addEventListener("mousemove",R1),window.addEventListener("mouseup",R1)}}function Q2(){if(document.releaseCapture)document.releaseCapture(),document.captureElement=null;else{if(!document.captureElement)return;a6=document.captureElement,document.captureElement=null,s6.disconnect();let Q=document.getElementById("noVNC_mouse_capture_elem");Q.style.display="none",window.removeEventListener("mousemove",R1),window.removeEventListener("mouseup",R1)}}class h1{constructor(){this._listeners=new Map}addEventListener(Q,$){if(!this._listeners.has(Q))this._listeners.set(Q,new Set);this._listeners.get(Q).add($)}removeEventListener(Q,$){if(this._listeners.has(Q))this._listeners.get(Q).delete($)}dispatchEvent(Q){if(!this._listeners.has(Q.type))return!0;return this._listeners.get(Q.type).forEach(($)=>$.call(this,Q)),!Q.defaultPrevented}}class N0{constructor(Q){if(this._drawCtx=null,this._renderQ=[],this._flushPromise=null,this._fbWidth=0,this._fbHeight=0,this._prevDrawStyle="",w(">> Display.constructor"),this._target=Q,!this._target)throw Error("Target must be set");if(typeof this._target==="string")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},w("User Agent: "+navigator.userAgent),w("<< Display.constructor"),this._scale=1,this._clipViewport=!1}get scale(){return this._scale}set scale(Q){this._rescale(Q)}get clipViewport(){return this._clipViewport}set clipViewport(Q){this._clipViewport=Q;let $=this._viewportLoc;this.viewportChangeSize($.w,$.h),this.viewportChangePos(0,0)}get width(){return this._fbWidth}get height(){return this._fbHeight}viewportChangePos(Q,$){let V=this._viewportLoc;if(Q=Math.floor(Q),$=Math.floor($),!this._clipViewport)Q=-V.w,$=-V.h;let J=V.x+V.w-1,W=V.y+V.h-1;if(Q<0&&V.x+Q<0)Q=-V.x;if(J+Q>=this._fbWidth)Q-=J+Q-this._fbWidth+1;if(V.y+$<0)$=-V.y;if(W+$>=this._fbHeight)$-=W+$-this._fbHeight+1;if(Q===0&&$===0)return;w("viewportChange deltaX: "+Q+", deltaY: "+$),V.x+=Q,V.y+=$,this._damage(V.x,V.y,V.w,V.h),this.flip()}viewportChangeSize(Q,$){if(!this._clipViewport||typeof Q>"u"||typeof $>"u")w("Setting viewport to full display region"),Q=this._fbWidth,$=this._fbHeight;if(Q=Math.floor(Q),$=Math.floor($),Q>this._fbWidth)Q=this._fbWidth;if($>this._fbHeight)$=this._fbHeight;let V=this._viewportLoc;if(V.w!==Q||V.h!==$){V.w=Q,V.h=$;let J=this._target;J.width=Q,J.height=$,this.viewportChangePos(0,0),this._damage(V.x,V.y,V.w,V.h),this.flip(),this._rescale(this._scale)}}absX(Q){if(this._scale===0)return 0;return Q0(Q/this._scale+this._viewportLoc.x)}absY(Q){if(this._scale===0)return 0;return Q0(Q/this._scale+this._viewportLoc.y)}resize(Q,$){this._prevDrawStyle="",this._fbWidth=Q,this._fbHeight=$;let V=this._backbuffer;if(V.width!==Q||V.height!==$){let W=null;if(V.width>0&&V.height>0)W=this._drawCtx.getImageData(0,0,V.width,V.height);if(V.width!==Q)V.width=Q;if(V.height!==$)V.height=$;if(W)this._drawCtx.putImageData(W,0,0)}let J=this._viewportLoc;this.viewportChangeSize(J.w,J.h),this.viewportChangePos(0,0)}getImageData(){return this._drawCtx.getImageData(0,0,this.width,this.height)}toDataURL(Q,$){return this._backbuffer.toDataURL(Q,$)}toBlob(Q,$,V){return this._backbuffer.toBlob(Q,$,V)}_damage(Q,$,V,J){if(Qthis._damageBounds.right)this._damageBounds.right=Q+V;if($+J>this._damageBounds.bottom)this._damageBounds.bottom=$+J}flip(Q){if(this._renderQ.length!==0&&!Q)this._renderQPush({type:"flip"});else{let $=this._damageBounds.left,V=this._damageBounds.top,J=this._damageBounds.right-$,W=this._damageBounds.bottom-V,G=$-this._viewportLoc.x,q=V-this._viewportLoc.y;if(G<0)J+=G,$-=G,G=0;if(q<0)W+=q,V-=q,q=0;if(G+J>this._viewportLoc.w)J=this._viewportLoc.w-G;if(q+W>this._viewportLoc.h)W=this._viewportLoc.h-q;if(J>0&&W>0)this._targetCtx.drawImage(this._backbuffer,$,V,J,W,G,q,J,W);this._damageBounds.left=this._damageBounds.top=65535,this._damageBounds.right=this._damageBounds.bottom=0}}pending(){return this._renderQ.length>0}flush(){if(this._renderQ.length===0)return Promise.resolve();else{if(this._flushPromise===null)this._flushPromise=new Promise((Q)=>{this._flushResolve=Q});return this._flushPromise}}fillRect(Q,$,V,J,W,G){if(this._renderQ.length!==0&&!G)this._renderQPush({type:"fill",x:Q,y:$,width:V,height:J,color:W});else this._setFillColor(W),this._drawCtx.fillRect(Q,$,V,J),this._damage(Q,$,V,J)}copyImage(Q,$,V,J,W,G,q){if(this._renderQ.length!==0&&!q)this._renderQPush({type:"copy",oldX:Q,oldY:$,x:V,y:J,width:W,height:G});else this._drawCtx.mozImageSmoothingEnabled=!1,this._drawCtx.webkitImageSmoothingEnabled=!1,this._drawCtx.msImageSmoothingEnabled=!1,this._drawCtx.imageSmoothingEnabled=!1,this._drawCtx.drawImage(this._backbuffer,Q,$,W,G,V,J,W,G),this._damage(V,J,W,G)}imageRect(Q,$,V,J,W,G){if(V===0||J===0)return;let q=new Image;q.src="data: "+W+";base64,"+f1.encode(G),this._renderQPush({type:"img",img:q,x:Q,y:$,width:V,height:J})}videoFrame(Q,$,V,J,W){this._renderQPush({type:"frame",frame:W,x:Q,y:$,width:V,height:J})}blitImage(Q,$,V,J,W,G,q){if(this._renderQ.length!==0&&!q){let U=new Uint8Array(V*J*4);U.set(new Uint8Array(W.buffer,0,U.length)),this._renderQPush({type:"blit",data:U,x:Q,y:$,width:V,height:J})}else{let U=new Uint8ClampedArray(W.buffer,W.byteOffset+G,V*J*4),Z=new ImageData(U,V,J);this._drawCtx.putImageData(Z,Q,$),this._damage(Q,$,V,J)}}drawImage(Q,...$){if(this._drawCtx.drawImage(Q,...$),$.length<=4){let[V,J]=$;this._damage(V,J,Q.width,Q.height)}else{let[,,V,J,W,G]=$;this._damage(W,G,V,J)}}autoscale(Q,$){let V;if(Q===0||$===0)V=0;else{let J=this._viewportLoc,W=Q/$;if(J.w/J.h>=W)V=Q/J.w;else V=$/J.h}this._rescale(V)}_rescale(Q){this._scale=Q;let $=this._viewportLoc,V=Q*$.w+"px",J=Q*$.h+"px";if(this._target.style.width!==V||this._target.style.height!==J)this._target.style.width=V,this._target.style.height=J}_setFillColor(Q){let $="rgb("+Q[0]+","+Q[1]+","+Q[2]+")";if($!==this._prevDrawStyle)this._drawCtx.fillStyle=$,this._prevDrawStyle=$}_renderQPush(Q){if(this._renderQ.push(Q),this._renderQ.length===1)this._scanRenderQ()}_resumeRenderQ(){this.removeEventListener("load",this._noVNCDisplay._resumeRenderQ),this._noVNCDisplay._scanRenderQ()}_scanRenderQ(){let Q=!0;while(Q&&this._renderQ.length>0){let $=this._renderQ[0];switch($.type){case"flip":this.flip(!0);break;case"copy":this.copyImage($.oldX,$.oldY,$.x,$.y,$.width,$.height,!0);break;case"fill":this.fillRect($.x,$.y,$.width,$.height,$.color,!0);break;case"blit":this.blitImage($.x,$.y,$.width,$.height,$.data,0,!0);break;case"img":if($.img.complete){if($.img.width!==$.width||$.img.height!==$.height){p("Decoded image has incorrect dimensions. Got "+$.img.width+"x"+$.img.height+". Expected "+$.width+"x"+$.height+".");return}this.drawImage($.img,$.x,$.y)}else $.img._noVNCDisplay=this,$.img.addEventListener("load",this._resumeRenderQ),Q=!1;break;case"frame":if($.frame.ready){let V=$.frame.frame;if(V.codedWidth<$.width||V.codedHeight<$.height)l("Decoded video frame does not cover its full rectangle area. Expecting at least "+$.width+"x"+$.height+" but got "+V.codedWidth+"x"+V.codedHeight);let J=0,W=0,G=$.width,q=$.height,U=$.x,Z=$.y,Y=G,X=q;this.drawImage(V,J,W,G,q,U,Z,Y,X),V.close()}else{let V=this;$.frame.promise.then(()=>{V._scanRenderQ()}),Q=!1}break}if(Q)this._renderQ.shift()}if(this._renderQ.length===0&&this._flushPromise!==null)this._flushResolve(),this._flushPromise=null,this._flushResolve=null}}function G1(Q,$,V,J,W){if($.subarray&&Q.subarray){Q.set($.subarray(V,V+J),W);return}for(var G=0;G>>16&65535|0,q=0;while(V!==0){q=V>2000?2000:V,V-=q;do W=W+$[J++]|0,G=G+W|0;while(--q);W%=65521,G%=65521}return W|G<<16|0}function i(){var Q,$=[];for(var V=0;V<256;V++){Q=V;for(var J=0;J<8;J++)Q=Q&1?3988292384^Q>>>1:Q>>>1;$[V]=Q}return $}var v4=i();var O0=30,a8=12;function z6(Q,$){var V,J,W,G,q,U,Z,Y,X,I,j,P,O,k,E,D,S,R,A,v,b,K,x,f,g;V=Q.state,J=Q.next_in,f=Q.input,W=J+(Q.avail_in-5),G=Q.next_out,g=Q.output,q=G-($-Q.avail_out),U=G+(Q.avail_out-257),Z=V.dmax,Y=V.wsize,X=V.whave,I=V.wnext,j=V.window,P=V.hold,O=V.bits,k=V.lencode,E=V.distcode,D=(1<>>24,P>>>=A,O-=A,A=R>>>16&255,A===0)g[G++]=R&65535;else if(A&16){if(v=R&65535,A&=15,A){if(O>>=A,O-=A}if(O<15)P+=f[J++]<>>24,P>>>=A,O-=A,A=R>>>16&255,A&16){if(b=R&65535,A&=15,OZ){Q.msg="invalid distance too far back",V.mode=O0;break Q}if(P>>>=A,O-=A,A=G-q,b>A){if(A=b-A,A>X){if(V.sane){Q.msg="invalid distance too far back",V.mode=O0;break Q}}if(K=0,x=j,I===0){if(K+=Y-A,A2)g[G++]=x[K++],g[G++]=x[K++],g[G++]=x[K++],v-=3;if(v){if(g[G++]=x[K++],v>1)g[G++]=x[K++]}}else{K=G-b;do g[G++]=g[K++],g[G++]=g[K++],g[G++]=g[K++],v-=3;while(v>2);if(v){if(g[G++]=g[K++],v>1)g[G++]=g[K++]}}}else if((A&64)===0){R=E[(R&65535)+(P&(1<>3,J-=v,O-=v<<3,P&=(1<=1;j--)if(m[j]!==0)break;if(P>j)P=j;if(j===0)return W[G++]=20971520,W[G++]=20971520,U.bits=1,0;for(I=1;I0&&(Q===J2||j!==1))return-1;P1[1]=0;for(Y=1;YV2||Q===W2&&D>$2)return 1;for(;;){if(C1=Y-k,q[X]g)o=J1[D1+q[X]],I0=x[f+q[X]];else o=96,I0=0;R=1<>k)+A]=C1<<24|o<<16|I0|0;while(A!==0);R=1<>=1;if(R!==0)S&=R-1,S+=R;else S=0;if(X++,--m[Y]===0){if(Y===j)break;Y=$[V+q[X]]}if(Y>P&&(S&b)!==v){if(k===0)k=P;K+=I,O=Y-k,E=1<V2||Q===W2&&D>$2)return 1;v=S&b,W[v]=P<<24|O<<16|K-G|0}}if(S!==0)W[K+S]=Y-k<<24|4194304|0;return U.bits=P,0}var V5=0,k2=1,x2=2,G2=4,$5=5,A0=6,K0=0,J5=1,W5=2,w1=-2,G5=-3,q2=-4,q5=-5,U2=8,f2=1,Y2=2,X2=3,Z2=4,z2=5,P2=6,j2=7,H2=8,L2=9,F2=10,C2=11,H1=12,j6=13,I2=14,H6=15,B2=16,N2=17,M2=18,O2=19,D0=20,R0=21,A2=22,D2=23,R2=24,K2=25,E2=26,L6=27,w2=28,S2=29,c=30,T2=31,U5=32,Y5=852,X5=592,Z5=15,z5=Z5;function v2(Q){return(Q>>>24&255)+(Q>>>8&65280)+((Q&65280)<<8)+((Q&255)<<24)}function P5(){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 V1(320),this.work=new V1(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function j5(Q){var $;if(!Q||!Q.state)return w1;if($=Q.state,Q.total_in=Q.total_out=$.total=0,Q.msg="",$.wrap)Q.adler=$.wrap&1;return $.mode=f2,$.last=0,$.havedict=0,$.dmax=32768,$.head=null,$.hold=0,$.bits=0,$.lencode=$.lendyn=new $0(Y5),$.distcode=$.distdyn=new $0(X5),$.sane=1,$.back=-1,K0}function I6(Q){var $;if(!Q||!Q.state)return w1;return $=Q.state,$.wsize=0,$.whave=0,$.wnext=0,j5(Q)}function H5(Q,$){var V,J;if(!Q||!Q.state)return w1;if(J=Q.state,$<0)V=0,$=-$;else if(V=($>>4)+1,$<48)$&=15;if($&&($<8||$>15))return w1;if(J.window!==null&&J.wbits!==$)J.window=null;return J.wrap=V,J.wbits=$,I6(Q)}function L5(Q,$){var V,J;if(!Q)return w1;if(J=new P5,Q.state=J,J.window=null,V=H5(Q,$),V!==K0)Q.state=null;return V}function u2(Q){return L5(Q,z5)}var g2=!0,F6,C6;function F5(Q){if(g2){var $;F6=new $0(512),C6=new $0(32),$=0;while($<144)Q.lens[$++]=8;while($<256)Q.lens[$++]=9;while($<280)Q.lens[$++]=7;while($<288)Q.lens[$++]=8;E1(k2,Q.lens,0,288,F6,0,Q.work,{bits:9}),$=0;while($<32)Q.lens[$++]=5;E1(x2,Q.lens,0,32,C6,0,Q.work,{bits:5}),g2=!1}Q.lencode=F6,Q.lenbits=9,Q.distcode=C6,Q.distbits=5}function C5(Q,$,V,J){var W,G=Q.state;if(G.window===null)G.wsize=1<=G.wsize)G1(G.window,$,V-G.wsize,G.wsize,0),G.wnext=0,G.whave=G.wsize;else{if(W=G.wsize-G.wnext,W>J)W=J;if(G1(G.window,$,V-J,W,G.wnext),J-=W,J)G1(G.window,$,V-J,J,0),G.wnext=J,G.whave=G.wsize;else{if(G.wnext+=W,G.wnext===G.wsize)G.wnext=0;if(G.whave>>8&255,V.check=i(V.check,f,2,0),Y=0,X=0,V.mode=Y2;break}if(V.flags=0,V.head)V.head.done=!1;if(!(V.wrap&1)||(((Y&255)<<8)+(Y>>8))%31){Q.msg="incorrect header check",V.mode=c;break}if((Y&15)!==U2){Q.msg="unknown compression method",V.mode=c;break}if(Y>>>=4,X-=4,K=(Y&15)+8,V.wbits===0)V.wbits=K;else if(K>V.wbits){Q.msg="invalid window size",V.mode=c;break}V.dmax=1<>8&1;if(V.flags&512)f[0]=Y&255,f[1]=Y>>>8&255,V.check=i(V.check,f,2,0);Y=0,X=0,V.mode=X2;case X2:while(X<32){if(U===0)break Q;U--,Y+=J[G++]<>>8&255,f[2]=Y>>>16&255,f[3]=Y>>>24&255,V.check=i(V.check,f,4,0);Y=0,X=0,V.mode=Z2;case Z2:while(X<16){if(U===0)break Q;U--,Y+=J[G++]<>8;if(V.flags&512)f[0]=Y&255,f[1]=Y>>>8&255,V.check=i(V.check,f,2,0);Y=0,X=0,V.mode=z2;case z2:if(V.flags&1024){while(X<16){if(U===0)break Q;U--,Y+=J[G++]<>>8&255,V.check=i(V.check,f,2,0);Y=0,X=0}else if(V.head)V.head.extra=null;V.mode=P2;case P2:if(V.flags&1024){if(P=V.length,P>U)P=U;if(P){if(V.head){if(K=V.head.extra_len-V.length,!V.head.extra)V.head.extra=Array(V.head.extra_len);G1(V.head.extra,J,G,P,K)}if(V.flags&512)V.check=i(V.check,J,P,G);U-=P,G+=P,V.length-=P}if(V.length)break Q}V.length=0,V.mode=j2;case j2:if(V.flags&2048){if(U===0)break Q;P=0;do if(K=J[G+P++],V.head&&K&&V.length<65536)V.head.name+=String.fromCharCode(K);while(K&&P>9&1,V.head.done=!0;Q.adler=V.check=0,V.mode=H1;break;case F2:while(X<32){if(U===0)break Q;U--,Y+=J[G++]<>>=X&7,X-=X&7,V.mode=L6;break}while(X<3){if(U===0)break Q;U--,Y+=J[G++]<>>=1,X-=1,Y&3){case 0:V.mode=I2;break;case 1:if(F5(V),V.mode=D0,$===A0){Y>>>=2,X-=2;break Q}break;case 2:V.mode=N2;break;case 3:Q.msg="invalid block type",V.mode=c}Y>>>=2,X-=2;break;case I2:Y>>>=X&7,X-=X&7;while(X<32){if(U===0)break Q;U--,Y+=J[G++]<>>16^65535)){Q.msg="invalid stored block lengths",V.mode=c;break}if(V.length=Y&65535,Y=0,X=0,V.mode=H6,$===A0)break Q;case H6:V.mode=B2;case B2:if(P=V.length,P){if(P>U)P=U;if(P>Z)P=Z;if(P===0)break Q;G1(W,J,G,P,q),U-=P,G+=P,Z-=P,q+=P,V.length-=P;break}V.mode=H1;break;case N2:while(X<14){if(U===0)break Q;U--,Y+=J[G++]<>>=5,X-=5,V.ndist=(Y&31)+1,Y>>>=5,X-=5,V.ncode=(Y&15)+4,Y>>>=4,X-=4,V.nlen>286||V.ndist>30){Q.msg="too many length or distance symbols",V.mode=c;break}V.have=0,V.mode=M2;case M2:while(V.have>>=3,X-=3}while(V.have<19)V.lens[P1[V.have++]]=0;if(V.lencode=V.lendyn,V.lenbits=7,g={bits:V.lenbits},x=E1(V5,V.lens,0,19,V.lencode,0,V.work,g),V.lenbits=g.bits,x){Q.msg="invalid code lengths set",V.mode=c;break}V.have=0,V.mode=O2;case O2:while(V.have>>24,S=E>>>16&255,R=E&65535,D<=X)break;if(U===0)break Q;U--,Y+=J[G++]<>>=D,X-=D,V.lens[V.have++]=R;else{if(R===16){m=D+2;while(X>>=D,X-=D,V.have===0){Q.msg="invalid bit length repeat",V.mode=c;break}K=V.lens[V.have-1],P=3+(Y&3),Y>>>=2,X-=2}else if(R===17){m=D+3;while(X>>=D,X-=D,K=0,P=3+(Y&7),Y>>>=3,X-=3}else{m=D+7;while(X>>=D,X-=D,K=0,P=11+(Y&127),Y>>>=7,X-=7}if(V.have+P>V.nlen+V.ndist){Q.msg="invalid bit length repeat",V.mode=c;break}while(P--)V.lens[V.have++]=K}}if(V.mode===c)break;if(V.lens[256]===0){Q.msg="invalid code -- missing end-of-block",V.mode=c;break}if(V.lenbits=9,g={bits:V.lenbits},x=E1(k2,V.lens,0,V.nlen,V.lencode,0,V.work,g),V.lenbits=g.bits,x){Q.msg="invalid literal/lengths set",V.mode=c;break}if(V.distbits=6,V.distcode=V.distdyn,g={bits:V.distbits},x=E1(x2,V.lens,V.nlen,V.ndist,V.distcode,0,V.work,g),V.distbits=g.bits,x){Q.msg="invalid distances set",V.mode=c;break}if(V.mode=D0,$===A0)break Q;case D0:V.mode=R0;case R0:if(U>=6&&Z>=258){if(Q.next_out=q,Q.avail_out=Z,Q.next_in=G,Q.avail_in=U,V.hold=Y,V.bits=X,z6(Q,j),q=Q.next_out,W=Q.output,Z=Q.avail_out,G=Q.next_in,J=Q.input,U=Q.avail_in,Y=V.hold,X=V.bits,V.mode===H1)V.back=-1;break}V.back=0;for(;;){if(E=V.lencode[Y&(1<>>24,S=E>>>16&255,R=E&65535,D<=X)break;if(U===0)break Q;U--,Y+=J[G++]<>A)],D=E>>>24,S=E>>>16&255,R=E&65535,A+D<=X)break;if(U===0)break Q;U--,Y+=J[G++]<>>=A,X-=A,V.back+=A}if(Y>>>=D,X-=D,V.back+=D,V.length=R,S===0){V.mode=E2;break}if(S&32){V.back=-1,V.mode=H1;break}if(S&64){Q.msg="invalid literal/length code",V.mode=c;break}V.extra=S&15,V.mode=A2;case A2:if(V.extra){m=V.extra;while(X>>=V.extra,X-=V.extra,V.back+=V.extra}V.was=V.length,V.mode=D2;case D2:for(;;){if(E=V.distcode[Y&(1<>>24,S=E>>>16&255,R=E&65535,D<=X)break;if(U===0)break Q;U--,Y+=J[G++]<>A)],D=E>>>24,S=E>>>16&255,R=E&65535,A+D<=X)break;if(U===0)break Q;U--,Y+=J[G++]<>>=A,X-=A,V.back+=A}if(Y>>>=D,X-=D,V.back+=D,S&64){Q.msg="invalid distance code",V.mode=c;break}V.offset=R,V.extra=S&15,V.mode=R2;case R2:if(V.extra){m=V.extra;while(X>>=V.extra,X-=V.extra,V.back+=V.extra}if(V.offset>V.dmax){Q.msg="invalid distance too far back",V.mode=c;break}V.mode=K2;case K2:if(Z===0)break Q;if(P=j-Z,V.offset>P){if(P=V.offset-P,P>V.whave){if(V.sane){Q.msg="invalid distance too far back",V.mode=c;break}}if(P>V.wnext)P-=V.wnext,O=V.wsize-P;else O=V.wnext-P;if(P>V.length)P=V.length;k=V.window}else k=W,O=q-V.offset,P=V.length;if(P>Z)P=Z;Z-=P,V.length-=P;do W[q++]=k[O++];while(--P);if(V.length===0)V.mode=R0;break;case E2:if(Z===0)break Q;W[q++]=V.length,Z--,V.mode=R0;break;case L6:if(V.wrap){while(X<32){if(U===0)break Q;U--,Y|=J[G++]<this.chunkSize)this.chunkSize=Q,this.strm.output=new Uint8Array(this.chunkSize);if(this.strm.next_out=0,this.strm.avail_out=Q,_2(this.strm,0)<0)throw Error("zlib inflate failed");if(this.strm.next_out!=Q)throw Error("Incomplete zlib block");return new Uint8Array(this.strm.output.buffer,0,this.strm.next_out)}reset(){I6(this.strm)}}var I5=4,y2=0,h2=1,B5=2;function n1(Q){var $=Q.length;while(--$>=0)Q[$]=0}var N5=0,i2=1,M5=2,O5=3,A5=258,R6=29,X0=256,G0=X0+1+R6,c1=30,K6=19,r2=2*G0+1,S1=15,B6=16,D5=7,E6=256,l2=16,o2=17,d2=18,A6=[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],E0=[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],R5=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],a2=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],K5=512,L1=Array((G0+2)*2);n1(L1);var W0=Array(c1*2);n1(W0);var q0=Array(K5);n1(q0);var U0=Array(A5-O5+1);n1(U0);var w6=Array(R6);n1(w6);var w0=Array(c1);n1(w0);function N6(Q,$,V,J,W){this.static_tree=Q,this.extra_bits=$,this.extra_base=V,this.elems=J,this.max_length=W,this.has_stree=Q&&Q.length}var t2,s2,e2;function M6(Q,$){this.dyn_tree=Q,this.max_code=0,this.stat_desc=$}function Q8(Q){return Q<256?q0[Q]:q0[256+(Q>>>7)]}function Y0(Q,$){Q.pending_buf[Q.pending++]=$&255,Q.pending_buf[Q.pending++]=$>>>8&255}function $1(Q,$,V){if(Q.bi_valid>B6-V)Q.bi_buf|=$<>B6-Q.bi_valid,Q.bi_valid+=V-B6;else Q.bi_buf|=$<>>=1,V<<=1;while(--$>0);return V>>>1}function E5(Q){if(Q.bi_valid===16)Y0(Q,Q.bi_buf),Q.bi_buf=0,Q.bi_valid=0;else if(Q.bi_valid>=8)Q.pending_buf[Q.pending++]=Q.bi_buf&255,Q.bi_buf>>=8,Q.bi_valid-=8}function w5(Q,$){var{dyn_tree:V,max_code:J}=$,W=$.stat_desc.static_tree,G=$.stat_desc.has_stree,q=$.stat_desc.extra_bits,U=$.stat_desc.extra_base,Z=$.stat_desc.max_length,Y,X,I,j,P,O,k=0;for(j=0;j<=S1;j++)Q.bl_count[j]=0;V[Q.heap[Q.heap_max]*2+1]=0;for(Y=Q.heap_max+1;YZ)j=Z,k++;if(V[X*2+1]=j,X>J)continue;if(Q.bl_count[j]++,P=0,X>=U)P=q[X-U];if(O=V[X*2],Q.opt_len+=O*(j+P),G)Q.static_len+=O*(W[X*2+1]+P)}if(k===0)return;do{j=Z-1;while(Q.bl_count[j]===0)j--;Q.bl_count[j]--,Q.bl_count[j+1]+=2,Q.bl_count[Z]--,k-=2}while(k>0);for(j=Z;j!==0;j--){X=Q.bl_count[j];while(X!==0){if(I=Q.heap[--Y],I>J)continue;if(V[I*2+1]!==j)Q.opt_len+=(j-V[I*2+1])*V[I*2],V[I*2+1]=j;X--}}}function $8(Q,$,V){var J=Array(S1+1),W=0,G,q;for(G=1;G<=S1;G++)J[G]=W=W+V[G-1]<<1;for(q=0;q<=$;q++){var U=Q[q*2+1];if(U===0)continue;Q[q*2]=V8(J[U]++,U)}}function S5(){var Q,$,V,J,W,G=Array(S1+1);V=0;for(J=0;J>=7;for(;J8)Y0(Q,Q.bi_buf);else if(Q.bi_valid>0)Q.pending_buf[Q.pending++]=Q.bi_buf;Q.bi_buf=0,Q.bi_valid=0}function T5(Q,$,V,J){if(W8(Q),J)Y0(Q,V),Y0(Q,~V);G1(Q.pending_buf,Q.window,$,V,Q.pending),Q.pending+=V}function p2(Q,$,V,J){var W=$*2,G=V*2;return Q[W]>1;q>=1;q--)O6(Q,V,q);Y=G;do q=Q.heap[1],Q.heap[1]=Q.heap[Q.heap_len--],O6(Q,V,1),U=Q.heap[1],Q.heap[--Q.heap_max]=q,Q.heap[--Q.heap_max]=U,V[Y*2]=V[q*2]+V[U*2],Q.depth[Y]=(Q.depth[q]>=Q.depth[U]?Q.depth[q]:Q.depth[U])+1,V[q*2+1]=V[U*2+1]=Y,Q.heap[1]=Y++,O6(Q,V,1);while(Q.heap_len>=2);Q.heap[--Q.heap_max]=Q.heap[1],w5(Q,$),$8(V,Z,Q.bl_count)}function b2(Q,$,V){var J,W=-1,G,q=$[1],U=0,Z=7,Y=4;if(q===0)Z=138,Y=3;$[(V+1)*2+1]=65535;for(J=0;J<=V;J++){if(G=q,q=$[(J+1)*2+1],++U=3;$--)if(Q.bl_tree[a2[$]*2+1]!==0)break;return Q.opt_len+=3*($+1)+5+5+4,$}function g5(Q,$,V,J){var W;$1(Q,$-257,5),$1(Q,V-1,5),$1(Q,J-4,4);for(W=0;W>>=1)if($&1&&Q.dyn_ltree[V*2]!==0)return y2;if(Q.dyn_ltree[18]!==0||Q.dyn_ltree[20]!==0||Q.dyn_ltree[26]!==0)return h2;for(V=32;V0){if(Q.strm.data_type===B5)Q.strm.data_type=k5(Q);if(D6(Q,Q.l_desc),D6(Q,Q.d_desc),q=v5(Q),W=Q.opt_len+3+7>>>3,G=Q.static_len+3+7>>>3,G<=W)W=G}else W=G=V+5;if(V+4<=W&&$!==-1)S6(Q,$,V,J);else if(Q.strategy===I5||G===W)$1(Q,(i2<<1)+(J?1:0),3),m2(Q,L1,W0);else $1(Q,(M5<<1)+(J?1:0),3),g5(Q,Q.l_desc.max_code+1,Q.d_desc.max_code+1,q+1),m2(Q,Q.dyn_ltree,Q.dyn_dtree);if(J8(Q),J)W8(Q)}function F1(Q,$,V){if(Q.pending_buf[Q.d_buf+Q.last_lit*2]=$>>>8&255,Q.pending_buf[Q.d_buf+Q.last_lit*2+1]=$&255,Q.pending_buf[Q.l_buf+Q.last_lit]=V&255,Q.last_lit++,$===0)Q.dyn_ltree[V*2]++;else Q.matches++,$--,Q.dyn_ltree[(U0[V]+X0+1)*2]++,Q.dyn_dtree[Q8($)*2]++;return Q.last_lit===Q.lit_bufsize-1}var Y8={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"};var k1=0,f5=1,v0=3,M1=4,X8=5,T1=0,Z8=1,o1=-2;var T6=-5,u6=-1,u5=1,S0=2,_5=3,y5=4,h5=0,p5=2,g0=8,m5=9,b5=15,c5=8,n5=29,i5=256,f6=i5+1+n5,r5=30,l5=19,o5=2*f6+1,d5=15,y=3,N1=258,U1=N1+y+1,a5=32,j8=42,z8=69,v6=73,g6=91,k6=103,z0=113,T0=666,d=1,P0=2,g1=3,d1=4,t5=3;function r1(Q,$){return Q.msg=Y8[$],$}function P8(Q){return(Q<<1)-(Q>4?9:0)}function v1(Q){var $=Q.length;while(--$>=0)Q[$]=0}function B1(Q){var $=Q.state,V=$.pending;if(V>Q.avail_out)V=Q.avail_out;if(V===0)return;if(G1(Q.output,$.pending_buf,$.pending_out,V,Q.next_out),Q.next_out+=V,$.pending_out+=V,Q.total_out+=V,Q.avail_out-=V,$.pending-=V,$.pending===0)$.pending_out=0}function a(Q,$){U8(Q,Q.block_start>=0?Q.block_start:-1,Q.strstart-Q.block_start,$),Q.block_start=Q.strstart,B1(Q.strm)}function _(Q,$){Q.pending_buf[Q.pending++]=$}function Z0(Q,$){Q.pending_buf[Q.pending++]=$>>>8&255,Q.pending_buf[Q.pending++]=$&255}function s5(Q,$,V,J){var W=Q.avail_in;if(W>J)W=J;if(W===0)return 0;if(Q.avail_in-=W,G1($,Q.input,Q.next_in,W,V),Q.state.wrap===1)Q.adler=m1(Q.adler,$,W,V);else if(Q.state.wrap===2)Q.adler=i(Q.adler,$,W,V);return Q.next_in+=W,Q.total_in+=W,W}function H8(Q,$){var{max_chain_length:V,strstart:J}=Q,W,G,q=Q.prev_length,U=Q.nice_match,Z=Q.strstart>Q.w_size-U1?Q.strstart-(Q.w_size-U1):0,Y=Q.window,X=Q.w_mask,I=Q.prev,j=Q.strstart+N1,P=Y[J+q-1],O=Y[J+q];if(Q.prev_length>=Q.good_match)V>>=2;if(U>Q.lookahead)U=Q.lookahead;do{if(W=$,Y[W+q]!==O||Y[W+q-1]!==P||Y[W]!==Y[J]||Y[++W]!==Y[J+1])continue;J+=2,W++;do;while(Y[++J]===Y[++W]&&Y[++J]===Y[++W]&&Y[++J]===Y[++W]&&Y[++J]===Y[++W]&&Y[++J]===Y[++W]&&Y[++J]===Y[++W]&&Y[++J]===Y[++W]&&Y[++J]===Y[++W]&&Jq){if(Q.match_start=$,q=G,G>=U)break;P=Y[J+q-1],O=Y[J+q]}}while(($=I[$&X])>Z&&--V!==0);if(q<=Q.lookahead)return q;return Q.lookahead}function j0(Q){var $=Q.w_size,V,J,W,G,q;do{if(G=Q.window_size-Q.lookahead-Q.strstart,Q.strstart>=$+($-U1)){G1(Q.window,Q.window,$,$,0),Q.match_start-=$,Q.strstart-=$,Q.block_start-=$,J=Q.hash_size,V=J;do W=Q.head[--V],Q.head[V]=W>=$?W-$:0;while(--J);J=$,V=J;do W=Q.prev[--V],Q.prev[V]=W>=$?W-$:0;while(--J);G+=$}if(Q.strm.avail_in===0)break;if(J=s5(Q.strm,Q.window,Q.strstart+Q.lookahead,G),Q.lookahead+=J,Q.lookahead+Q.insert>=y){q=Q.strstart-Q.insert,Q.ins_h=Q.window[q],Q.ins_h=(Q.ins_h<Q.pending_buf_size-5)V=Q.pending_buf_size-5;for(;;){if(Q.lookahead<=1){if(j0(Q),Q.lookahead===0&&$===k1)return d;if(Q.lookahead===0)break}Q.strstart+=Q.lookahead,Q.lookahead=0;var J=Q.block_start+V;if(Q.strstart===0||Q.strstart>=J){if(Q.lookahead=Q.strstart-J,Q.strstart=J,a(Q,!1),Q.strm.avail_out===0)return d}if(Q.strstart-Q.block_start>=Q.w_size-U1){if(a(Q,!1),Q.strm.avail_out===0)return d}}if(Q.insert=0,$===M1){if(a(Q,!0),Q.strm.avail_out===0)return g1;return d1}if(Q.strstart>Q.block_start){if(a(Q,!1),Q.strm.avail_out===0)return d}return d}function x6(Q,$){var V,J;for(;;){if(Q.lookahead=y)Q.ins_h=(Q.ins_h<=y)if(J=F1(Q,Q.strstart-Q.match_start,Q.match_length-y),Q.lookahead-=Q.match_length,Q.match_length<=Q.max_lazy_match&&Q.lookahead>=y){Q.match_length--;do Q.strstart++,Q.ins_h=(Q.ins_h<=y)Q.ins_h=(Q.ins_h<4096))Q.match_length=y-1}if(Q.prev_length>=y&&Q.match_length<=Q.prev_length){W=Q.strstart+Q.lookahead-y,J=F1(Q,Q.strstart-1-Q.prev_match,Q.prev_length-y),Q.lookahead-=Q.prev_length-1,Q.prev_length-=2;do if(++Q.strstart<=W)Q.ins_h=(Q.ins_h<=y&&Q.strstart>0){if(W=Q.strstart-1,J=q[W],J===q[++W]&&J===q[++W]&&J===q[++W]){G=Q.strstart+N1;do;while(J===q[++W]&&J===q[++W]&&J===q[++W]&&J===q[++W]&&J===q[++W]&&J===q[++W]&&J===q[++W]&&J===q[++W]&&WQ.lookahead)Q.match_length=Q.lookahead}}if(Q.match_length>=y)V=F1(Q,1,Q.match_length-y),Q.lookahead-=Q.match_length,Q.strstart+=Q.match_length,Q.match_length=0;else V=F1(Q,0,Q.window[Q.strstart]),Q.lookahead--,Q.strstart++;if(V){if(a(Q,!1),Q.strm.avail_out===0)return d}}if(Q.insert=0,$===M1){if(a(Q,!0),Q.strm.avail_out===0)return g1;return d1}if(Q.last_lit){if(a(Q,!1),Q.strm.avail_out===0)return d}return P0}function V4(Q,$){var V;for(;;){if(Q.lookahead===0){if(j0(Q),Q.lookahead===0){if($===k1)return d;break}}if(Q.match_length=0,V=F1(Q,0,Q.window[Q.strstart]),Q.lookahead--,Q.strstart++,V){if(a(Q,!1),Q.strm.avail_out===0)return d}}if(Q.insert=0,$===M1){if(a(Q,!0),Q.strm.avail_out===0)return g1;return d1}if(Q.last_lit){if(a(Q,!1),Q.strm.avail_out===0)return d}return P0}function Z1(Q,$,V,J,W){this.good_length=Q,this.max_lazy=$,this.nice_length=V,this.max_chain=J,this.func=W}var l1;l1=[new Z1(0,0,0,0,e5),new Z1(4,4,8,4,x6),new Z1(4,5,16,8,x6),new Z1(4,6,32,32,x6),new Z1(4,4,16,16,i1),new Z1(8,16,32,32,i1),new Z1(8,16,128,128,i1),new Z1(8,32,128,256,i1),new Z1(32,128,258,1024,i1),new Z1(32,258,258,4096,i1)];function $4(Q){Q.window_size=2*Q.w_size,v1(Q.head),Q.max_lazy_match=l1[Q.level].max_lazy,Q.good_match=l1[Q.level].good_length,Q.nice_match=l1[Q.level].nice_length,Q.max_chain_length=l1[Q.level].max_chain,Q.strstart=0,Q.block_start=0,Q.lookahead=0,Q.insert=0,Q.match_length=Q.prev_length=y-1,Q.match_available=0,Q.ins_h=0}function J4(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=g0,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new V1(o5*2),this.dyn_dtree=new V1((2*r5+1)*2),this.bl_tree=new V1((2*l5+1)*2),v1(this.dyn_ltree),v1(this.dyn_dtree),v1(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new V1(d5+1),this.heap=new V1(2*f6+1),v1(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new V1(2*f6+1),v1(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function W4(Q){var $;if(!Q||!Q.state)return r1(Q,o1);if(Q.total_in=Q.total_out=0,Q.data_type=p5,$=Q.state,$.pending=0,$.pending_out=0,$.wrap<0)$.wrap=-$.wrap;return $.status=$.wrap?j8:z0,Q.adler=$.wrap===2?0:1,$.last_flush=k1,G8($),T1}function G4(Q){var $=W4(Q);if($===T1)$4(Q.state);return $}function q4(Q,$,V,J,W,G){if(!Q)return o1;var q=1;if($===u6)$=6;if(J<0)q=0,J=-J;else if(J>15)q=2,J-=16;if(W<1||W>m5||V!==g0||J<8||J>15||$<0||$>9||G<0||G>y5)return r1(Q,o1);if(J===8)J=9;var U=new J4;return Q.state=U,U.strm=Q,U.wrap=q,U.gzhead=null,U.w_bits=J,U.w_size=1<X8||$<0)return Q?r1(Q,o1):o1;if(J=Q.state,!Q.output||!Q.input&&Q.avail_in!==0||J.status===T0&&$!==M1)return r1(Q,Q.avail_out===0?T6:o1);if(J.strm=Q,V=J.last_flush,J.last_flush=$,J.status===j8)if(J.wrap===2)if(Q.adler=0,_(J,31),_(J,139),_(J,8),!J.gzhead)_(J,0),_(J,0),_(J,0),_(J,0),_(J,0),_(J,J.level===9?2:J.strategy>=S0||J.level<2?4:0),_(J,t5),J.status=z0;else{if(_(J,(J.gzhead.text?1:0)+(J.gzhead.hcrc?2:0)+(!J.gzhead.extra?0:4)+(!J.gzhead.name?0:8)+(!J.gzhead.comment?0:16)),_(J,J.gzhead.time&255),_(J,J.gzhead.time>>8&255),_(J,J.gzhead.time>>16&255),_(J,J.gzhead.time>>24&255),_(J,J.level===9?2:J.strategy>=S0||J.level<2?4:0),_(J,J.gzhead.os&255),J.gzhead.extra&&J.gzhead.extra.length)_(J,J.gzhead.extra.length&255),_(J,J.gzhead.extra.length>>8&255);if(J.gzhead.hcrc)Q.adler=i(Q.adler,J.pending_buf,J.pending,0);J.gzindex=0,J.status=z8}else{var q=g0+(J.w_bits-8<<4)<<8,U=-1;if(J.strategy>=S0||J.level<2)U=0;else if(J.level<6)U=1;else if(J.level===6)U=2;else U=3;if(q|=U<<6,J.strstart!==0)q|=a5;if(q+=31-q%31,J.status=z0,Z0(J,q),J.strstart!==0)Z0(J,Q.adler>>>16),Z0(J,Q.adler&65535);Q.adler=1}if(J.status===z8)if(J.gzhead.extra){W=J.pending;while(J.gzindex<(J.gzhead.extra.length&65535)){if(J.pending===J.pending_buf_size){if(J.gzhead.hcrc&&J.pending>W)Q.adler=i(Q.adler,J.pending_buf,J.pending-W,W);if(B1(Q),W=J.pending,J.pending===J.pending_buf_size)break}_(J,J.gzhead.extra[J.gzindex]&255),J.gzindex++}if(J.gzhead.hcrc&&J.pending>W)Q.adler=i(Q.adler,J.pending_buf,J.pending-W,W);if(J.gzindex===J.gzhead.extra.length)J.gzindex=0,J.status=v6}else J.status=v6;if(J.status===v6)if(J.gzhead.name){W=J.pending;do{if(J.pending===J.pending_buf_size){if(J.gzhead.hcrc&&J.pending>W)Q.adler=i(Q.adler,J.pending_buf,J.pending-W,W);if(B1(Q),W=J.pending,J.pending===J.pending_buf_size){G=1;break}}if(J.gzindexW)Q.adler=i(Q.adler,J.pending_buf,J.pending-W,W);if(G===0)J.gzindex=0,J.status=g6}else J.status=g6;if(J.status===g6)if(J.gzhead.comment){W=J.pending;do{if(J.pending===J.pending_buf_size){if(J.gzhead.hcrc&&J.pending>W)Q.adler=i(Q.adler,J.pending_buf,J.pending-W,W);if(B1(Q),W=J.pending,J.pending===J.pending_buf_size){G=1;break}}if(J.gzindexW)Q.adler=i(Q.adler,J.pending_buf,J.pending-W,W);if(G===0)J.status=k6}else J.status=k6;if(J.status===k6)if(J.gzhead.hcrc){if(J.pending+2>J.pending_buf_size)B1(Q);if(J.pending+2<=J.pending_buf_size)_(J,Q.adler&255),_(J,Q.adler>>8&255),Q.adler=0,J.status=z0}else J.status=z0;if(J.pending!==0){if(B1(Q),Q.avail_out===0)return J.last_flush=-1,T1}else if(Q.avail_in===0&&P8($)<=P8(V)&&$!==M1)return r1(Q,T6);if(J.status===T0&&Q.avail_in!==0)return r1(Q,T6);if(Q.avail_in!==0||J.lookahead!==0||$!==k1&&J.status!==T0){var Z=J.strategy===S0?V4(J,$):J.strategy===_5?Q4(J,$):l1[J.level].func(J,$);if(Z===g1||Z===d1)J.status=T0;if(Z===d||Z===g1){if(Q.avail_out===0)J.last_flush=-1;return T1}if(Z===P0){if($===f5)q8(J);else if($!==X8){if(S6(J,0,0,!1),$===v0){if(v1(J.head),J.lookahead===0)J.strstart=0,J.block_start=0,J.insert=0}}if(B1(Q),Q.avail_out===0)return J.last_flush=-1,T1}}if($!==M1)return T1;if(J.wrap<=0)return Z8;if(J.wrap===2)_(J,Q.adler&255),_(J,Q.adler>>8&255),_(J,Q.adler>>16&255),_(J,Q.adler>>24&255),_(J,Q.total_in&255),_(J,Q.total_in>>8&255),_(J,Q.total_in>>16&255),_(J,Q.total_in>>24&255);else Z0(J,Q.adler>>>16),Z0(J,Q.adler&65535);if(B1(Q),J.wrap>0)J.wrap=-J.wrap;return J.pending!==0?T1:Z8}class k0{constructor(){this.strm=new J0,this.chunkSize=102400,this.outputBuffer=new Uint8Array(this.chunkSize),L8(this.strm,u6)}deflate(Q){this.strm.input=Q,this.strm.avail_in=this.strm.input.length,this.strm.next_in=0,this.strm.output=this.outputBuffer,this.strm.avail_out=this.chunkSize,this.strm.next_out=0;let $=_6(this.strm,v0),V=new Uint8Array(this.strm.output.buffer,0,this.strm.next_out);if($<0)throw Error("zlib deflate failed");if(this.strm.avail_in>0){let J=[V],W=V.length;do{if(this.strm.output=new Uint8Array(this.chunkSize),this.strm.next_out=0,this.strm.avail_out=this.chunkSize,$=_6(this.strm,v0),$<0)throw Error("zlib deflate failed");let U=new Uint8Array(this.strm.output.buffer,0,this.strm.next_out);W+=U.length,J.push(U)}while(this.strm.avail_in>0);let G=new Uint8Array(W),q=0;for(let U=0;U=32&&Q<=255)return Q;let $=U4[Q];if($!==void 0)return $;return 16777216|Q}};var y6={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"};var h6={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"};var x1={};function B(Q,$){if($===void 0)throw Error('Undefined keysym for key "'+Q+'"');if(Q in x1)throw Error('Duplicate entry for key "'+Q+'"');x1[Q]=[$,$,$,$]}function x0(Q,$,V){if($===void 0)throw Error('Undefined keysym for key "'+Q+'"');if(V===void 0)throw Error('Undefined keysym for key "'+Q+'"');if(Q in x1)throw Error('Duplicate entry for key "'+Q+'"');x1[Q]=[$,$,V,$]}function h(Q,$,V){if($===void 0)throw Error('Undefined keysym for key "'+Q+'"');if(V===void 0)throw Error('Undefined keysym for key "'+Q+'"');if(Q in x1)throw Error('Duplicate entry for key "'+Q+'"');x1[Q]=[$,$,$,V]}x0("Alt",z.XK_Alt_L,z.XK_Alt_R);B("AltGraph",z.XK_ISO_Level3_Shift);B("CapsLock",z.XK_Caps_Lock);x0("Control",z.XK_Control_L,z.XK_Control_R);x0("Meta",z.XK_Super_L,z.XK_Super_R);B("NumLock",z.XK_Num_Lock);B("ScrollLock",z.XK_Scroll_Lock);x0("Shift",z.XK_Shift_L,z.XK_Shift_R);h("Enter",z.XK_Return,z.XK_KP_Enter);B("Tab",z.XK_Tab);h(" ",z.XK_space,z.XK_KP_Space);h("ArrowDown",z.XK_Down,z.XK_KP_Down);h("ArrowLeft",z.XK_Left,z.XK_KP_Left);h("ArrowRight",z.XK_Right,z.XK_KP_Right);h("ArrowUp",z.XK_Up,z.XK_KP_Up);h("End",z.XK_End,z.XK_KP_End);h("Home",z.XK_Home,z.XK_KP_Home);h("PageDown",z.XK_Next,z.XK_KP_Next);h("PageUp",z.XK_Prior,z.XK_KP_Prior);B("Backspace",z.XK_BackSpace);h("Clear",z.XK_Clear,z.XK_KP_Begin);B("Copy",z.XF86XK_Copy);B("Cut",z.XF86XK_Cut);h("Delete",z.XK_Delete,z.XK_KP_Delete);h("Insert",z.XK_Insert,z.XK_KP_Insert);B("Paste",z.XF86XK_Paste);B("Redo",z.XK_Redo);B("Undo",z.XK_Undo);B("Cancel",z.XK_Cancel);B("ContextMenu",z.XK_Menu);B("Escape",z.XK_Escape);B("Execute",z.XK_Execute);B("Find",z.XK_Find);B("Help",z.XK_Help);B("Pause",z.XK_Pause);B("Select",z.XK_Select);B("ZoomIn",z.XF86XK_ZoomIn);B("ZoomOut",z.XF86XK_ZoomOut);B("BrightnessDown",z.XF86XK_MonBrightnessDown);B("BrightnessUp",z.XF86XK_MonBrightnessUp);B("Eject",z.XF86XK_Eject);B("LogOff",z.XF86XK_LogOff);B("Power",z.XF86XK_PowerOff);B("PowerOff",z.XF86XK_PowerDown);B("PrintScreen",z.XK_Print);B("Hibernate",z.XF86XK_Hibernate);B("Standby",z.XF86XK_Standby);B("WakeUp",z.XF86XK_WakeUp);B("AllCandidates",z.XK_MultipleCandidate);B("Alphanumeric",z.XK_Eisu_toggle);B("CodeInput",z.XK_Codeinput);B("Compose",z.XK_Multi_key);B("Convert",z.XK_Henkan);B("GroupFirst",z.XK_ISO_First_Group);B("GroupLast",z.XK_ISO_Last_Group);B("GroupNext",z.XK_ISO_Next_Group);B("GroupPrevious",z.XK_ISO_Prev_Group);B("NonConvert",z.XK_Muhenkan);B("PreviousCandidate",z.XK_PreviousCandidate);B("SingleCandidate",z.XK_SingleCandidate);B("HangulMode",z.XK_Hangul);B("HanjaMode",z.XK_Hangul_Hanja);B("JunjaMode",z.XK_Hangul_Jeonja);B("Eisu",z.XK_Eisu_toggle);B("Hankaku",z.XK_Hankaku);B("Hiragana",z.XK_Hiragana);B("HiraganaKatakana",z.XK_Hiragana_Katakana);B("KanaMode",z.XK_Kana_Shift);B("KanjiMode",z.XK_Kanji);B("Katakana",z.XK_Katakana);B("Romaji",z.XK_Romaji);B("Zenkaku",z.XK_Zenkaku);B("ZenkakuHankaku",z.XK_Zenkaku_Hankaku);B("F1",z.XK_F1);B("F2",z.XK_F2);B("F3",z.XK_F3);B("F4",z.XK_F4);B("F5",z.XK_F5);B("F6",z.XK_F6);B("F7",z.XK_F7);B("F8",z.XK_F8);B("F9",z.XK_F9);B("F10",z.XK_F10);B("F11",z.XK_F11);B("F12",z.XK_F12);B("F13",z.XK_F13);B("F14",z.XK_F14);B("F15",z.XK_F15);B("F16",z.XK_F16);B("F17",z.XK_F17);B("F18",z.XK_F18);B("F19",z.XK_F19);B("F20",z.XK_F20);B("F21",z.XK_F21);B("F22",z.XK_F22);B("F23",z.XK_F23);B("F24",z.XK_F24);B("F25",z.XK_F25);B("F26",z.XK_F26);B("F27",z.XK_F27);B("F28",z.XK_F28);B("F29",z.XK_F29);B("F30",z.XK_F30);B("F31",z.XK_F31);B("F32",z.XK_F32);B("F33",z.XK_F33);B("F34",z.XK_F34);B("F35",z.XK_F35);B("Close",z.XF86XK_Close);B("MailForward",z.XF86XK_MailForward);B("MailReply",z.XF86XK_Reply);B("MailSend",z.XF86XK_Send);B("MediaFastForward",z.XF86XK_AudioForward);B("MediaPause",z.XF86XK_AudioPause);B("MediaPlay",z.XF86XK_AudioPlay);B("MediaRecord",z.XF86XK_AudioRecord);B("MediaRewind",z.XF86XK_AudioRewind);B("MediaStop",z.XF86XK_AudioStop);B("MediaTrackNext",z.XF86XK_AudioNext);B("MediaTrackPrevious",z.XF86XK_AudioPrev);B("New",z.XF86XK_New);B("Open",z.XF86XK_Open);B("Print",z.XK_Print);B("Save",z.XF86XK_Save);B("SpellCheck",z.XF86XK_Spell);B("AudioVolumeDown",z.XF86XK_AudioLowerVolume);B("AudioVolumeUp",z.XF86XK_AudioRaiseVolume);B("AudioVolumeMute",z.XF86XK_AudioMute);B("MicrophoneVolumeMute",z.XF86XK_AudioMicMute);B("LaunchApplication1",z.XF86XK_MyComputer);B("LaunchApplication2",z.XF86XK_Calculator);B("LaunchCalendar",z.XF86XK_Calendar);B("LaunchMail",z.XF86XK_Mail);B("LaunchMediaPlayer",z.XF86XK_AudioMedia);B("LaunchMusicPlayer",z.XF86XK_Music);B("LaunchPhone",z.XF86XK_Phone);B("LaunchScreenSaver",z.XF86XK_ScreenSaver);B("LaunchSpreadsheet",z.XF86XK_Excel);B("LaunchWebBrowser",z.XF86XK_WWW);B("LaunchWebCam",z.XF86XK_WebCam);B("LaunchWordProcessor",z.XF86XK_Word);B("BrowserBack",z.XF86XK_Back);B("BrowserFavorites",z.XF86XK_Favorites);B("BrowserForward",z.XF86XK_Forward);B("BrowserHome",z.XF86XK_HomePage);B("BrowserRefresh",z.XF86XK_Refresh);B("BrowserSearch",z.XF86XK_Search);B("BrowserStop",z.XF86XK_Stop);B("Dimmer",z.XF86XK_BrightnessAdjust);B("MediaAudioTrack",z.XF86XK_AudioCycleTrack);B("RandomToggle",z.XF86XK_AudioRandomPlay);B("SplitScreenToggle",z.XF86XK_SplitScreen);B("Subtitle",z.XF86XK_Subtitle);B("VideoModeNext",z.XF86XK_Next_VMode);h("=",z.XK_equal,z.XK_KP_Equal);h("+",z.XK_plus,z.XK_KP_Add);h("-",z.XK_minus,z.XK_KP_Subtract);h("*",z.XK_asterisk,z.XK_KP_Multiply);h("/",z.XK_slash,z.XK_KP_Divide);h(".",z.XK_period,z.XK_KP_Decimal);h(",",z.XK_comma,z.XK_KP_Separator);h("0",z.XK_0,z.XK_KP_0);h("1",z.XK_1,z.XK_KP_1);h("2",z.XK_2,z.XK_KP_2);h("3",z.XK_3,z.XK_KP_3);h("4",z.XK_4,z.XK_KP_4);h("5",z.XK_5,z.XK_KP_5);h("6",z.XK_6,z.XK_KP_6);h("7",z.XK_7,z.XK_KP_7);h("8",z.XK_8,z.XK_KP_8);h("9",z.XK_9,z.XK_KP_9);var p6=x1;function a1(Q){if(Q.code){switch(Q.code){case"OSLeft":return"MetaLeft";case"OSRight":return"MetaRight"}return Q.code}if(Q.keyCode in y6){let $=y6[Q.keyCode];if(I1()&&$==="ContextMenu")$="MetaRight";if(Q.location===2)switch($){case"ShiftLeft":return"ShiftRight";case"ControlLeft":return"ControlRight";case"AltLeft":return"AltRight"}if(Q.location===3)switch($){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 $}return"Unidentified"}function Y4(Q){if(Q.key!==void 0&&Q.key!=="Unidentified"){switch(Q.key){case"OS":return"Meta";case"LaunchMyComputer":return"LaunchApplication1";case"LaunchCalculator":return"LaunchApplication2"}switch(Q.key){case"UIKeyInputUpArrow":return"ArrowUp";case"UIKeyInputDownArrow":return"ArrowDown";case"UIKeyInputLeftArrow":return"ArrowLeft";case"UIKeyInputRightArrow":return"ArrowRight";case"UIKeyInputEscape":return"Escape"}if(Q.key==="\x00"&&Q.code==="NumpadDecimal")return"Delete";return Q.key}let $=a1(Q);if($ in h6)return h6[$];if(Q.charCode)return String.fromCharCode(Q.charCode);return"Unidentified"}function C8(Q){let $=Y4(Q);if($==="Unidentified")return null;if($ in p6){let J=Q.location;if($==="Meta"&&J===0)J=2;if($==="Clear"&&J===3){if(a1(Q)==="NumLock")J=0}if(J===void 0||J>3)J=0;if($==="Meta"){let W=a1(Q);if(W==="AltLeft")return z.XK_Meta_L;else if(W==="AltRight")return z.XK_Meta_R}if($==="Clear"){if(a1(Q)==="NumLock")return z.XK_Num_Lock}if(u1())switch($){case"Zenkaku":case"Hankaku":return z.XK_Zenkaku_Hankaku;case"Romaji":case"KanaMode":return z.XK_Romaji}return p6[$][J]}if($.length!==1)return null;let V=$.charCodeAt();if(V)return F8.lookup(V);return null}class f0{constructor(Q){this._target=Q||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(Q,$,V,J=null,W=null){if(V)this._keyDownList[$]=Q;else{if(!($ in this._keyDownList))return;delete this._keyDownList[$]}w("onkeyevent "+(V?"down":"up")+", keysym: "+Q,", code: "+$+", numlock: "+J+", capslock: "+W),this.onkeyevent(Q,$,V,J,W)}_getKeyCode(Q){let $=a1(Q);if($!=="Unidentified")return $;if(Q.keyCode){if(Q.keyCode!==229)return"Platform"+Q.keyCode}if(Q.keyIdentifier){if(Q.keyIdentifier.substr(0,2)!=="U+")return Q.keyIdentifier;let V=parseInt(Q.keyIdentifier.substr(2),16);return"Platform"+String.fromCharCode(V).toUpperCase().charCodeAt()}return"Unidentified"}_handleKeyDown(Q){let $=this._getKeyCode(Q),V=C8(Q),J=Q.getModifierState("NumLock"),W=Q.getModifierState("CapsLock");if(I1()||_1())J=null;if(this._altGrArmed)if(this._altGrArmed=!1,clearTimeout(this._altGrTimeout),$==="AltRight"&&Q.timeStamp-this._altGrCtrlTime<50)V=z.XK_ISO_Level3_Shift;else this._sendKeyEvent(z.XK_Control_L,"ControlLeft",!0,J,W);if($==="Unidentified"){if(V)this._sendKeyEvent(V,$,!0,J,W),this._sendKeyEvent(V,$,!1,J,W);K1(Q);return}if(I1()||_1())switch(V){case z.XK_Super_L:V=z.XK_Alt_L;break;case z.XK_Super_R:V=z.XK_Super_L;break;case z.XK_Alt_L:V=z.XK_Mode_switch;break;case z.XK_Alt_R:V=z.XK_ISO_Level3_Shift;break}if($ in this._keyDownList)V=this._keyDownList[$];if((I1()||_1())&&(Q.metaKey&&$!=="MetaLeft"&&$!=="MetaRight")){this._sendKeyEvent(V,$,!0,J,W),this._sendKeyEvent(V,$,!1,J,W),K1(Q);return}if((I1()||_1())&&$==="CapsLock"){this._sendKeyEvent(z.XK_Caps_Lock,"CapsLock",!0,J,W),this._sendKeyEvent(z.XK_Caps_Lock,"CapsLock",!1,J,W),K1(Q);return}let G=[z.XK_Zenkaku_Hankaku,z.XK_Eisu_toggle,z.XK_Katakana,z.XK_Hiragana,z.XK_Romaji];if(u1()&&G.includes(V)){this._sendKeyEvent(V,$,!0,J,W),this._sendKeyEvent(V,$,!1,J,W),K1(Q);return}if(K1(Q),$==="ControlLeft"&&u1()&&!("ControlLeft"in this._keyDownList)){this._altGrArmed=!0,this._altGrTimeout=setTimeout(this._interruptAltGrSequence.bind(this),100),this._altGrCtrlTime=Q.timeStamp;return}this._sendKeyEvent(V,$,!0,J,W)}_handleKeyUp(Q){K1(Q);let $=this._getKeyCode(Q);if(this._interruptAltGrSequence(),(I1()||_1())&&$==="CapsLock"){this._sendKeyEvent(z.XK_Caps_Lock,"CapsLock",!0),this._sendKeyEvent(z.XK_Caps_Lock,"CapsLock",!1);return}if(this._sendKeyEvent(this._keyDownList[$],$,!1),u1()&&($==="ShiftLeft"||$==="ShiftRight")){if("ShiftRight"in this._keyDownList)this._sendKeyEvent(this._keyDownList.ShiftRight,"ShiftRight",!1);if("ShiftLeft"in this._keyDownList)this._sendKeyEvent(this._keyDownList.ShiftLeft,"ShiftLeft",!1)}}_interruptAltGrSequence(){if(this._altGrArmed)this._altGrArmed=!1,clearTimeout(this._altGrTimeout),this._sendKeyEvent(z.XK_Control_L,"ControlLeft",!0)}_allKeysUp(){w(">> Keyboard.allKeysUp"),this._interruptAltGrSequence();for(let Q in this._keyDownList)this._sendKeyEvent(this._keyDownList[Q],Q,!1);w("<< Keyboard.allKeysUp")}grab(){this._target.addEventListener("keydown",this._eventHandlers.keydown),this._target.addEventListener("keyup",this._eventHandlers.keyup),window.addEventListener("blur",this._eventHandlers.blur)}ungrab(){this._target.removeEventListener("keydown",this._eventHandlers.keydown),this._target.removeEventListener("keyup",this._eventHandlers.keyup),window.removeEventListener("blur",this._eventHandlers.blur),this._allKeysUp()}}class u0{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(Q){this.detach(),this._target=Q,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(){if(!this._target)return;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(Q){let $;switch(Q.stopPropagation(),Q.preventDefault(),Q.type){case"touchstart":$=this._touchStart;break;case"touchmove":$=this._touchMove;break;case"touchend":case"touchcancel":$=this._touchEnd;break}for(let V=0;V0&&Date.now()-this._tracked[0].started>250){this._state=0,this._ignored.push(Q);return}if(this._waitingRelease){this._state=0,this._ignored.push(Q);return}switch(this._tracked.push({id:Q,started:Date.now(),active:!0,firstX:$,firstY:V,lastX:$,lastY:V,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(Q,$,V){let J=this._tracked.find((q)=>q.id===Q);if(J===void 0)return;J.lastX=$,J.lastY=V;let W=$-J.firstX,G=V-J.firstY;if(J.firstX!==J.lastX||J.firstY!==J.lastY)J.angle=Math.atan2(G,W)*180/Math.PI;if(!this._hasDetectedGesture()){if(Math.hypot(W,G)<50)return;if(this._state&=-24,this._stopLongpressTimeout(),this._tracked.length!==1)this._state&=-9;if(this._tracked.length!==2)this._state&=-97;if(this._tracked.length===2){let q=this._tracked.find((Z)=>Z.id!==Q);if(Math.hypot(q.firstX-q.lastX,q.firstY-q.lastY)>50){let Z=Math.abs(J.angle-q.angle);if(Z=Math.abs((Z+180)%360-180),Z>90)this._state&=-33;else this._state&=-65;if(this._isTwoTouchTimeoutRunning())this._stopTwoTouchTimeout()}else if(!this._isTwoTouchTimeoutRunning())this._startTwoTouchTimeout()}if(!this._hasDetectedGesture())return;this._pushEvent("gesturestart")}this._pushEvent("gesturemove")}_touchEnd(Q,$,V){if(this._ignored.indexOf(Q)!==-1){if(this._ignored.splice(this._ignored.indexOf(Q),1),this._ignored.length===0&&this._tracked.length===0)this._state=127,this._waitingRelease=!1;return}if(!this._hasDetectedGesture()&&this._isTwoTouchTimeoutRunning())this._stopTwoTouchTimeout(),this._state=0;if(!this._hasDetectedGesture()){if(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;break}}if(this._waitingRelease){if(Date.now()-this._releaseStart>250)this._state=0;if(this._tracked.some((W)=>Date.now()-W.started>1000))this._state=0;let J=this._tracked.find((W)=>W.id===Q);if(J.active=!1,this._hasDetectedGesture())this._pushEvent("gesturestart");else if(this._state!==0)return}if(this._hasDetectedGesture())this._pushEvent("gestureend");for(let J=0;JQ.active))return!1}return!0}_startLongpressTimeout(){this._stopLongpressTimeout(),this._longpressTimeoutId=setTimeout(()=>this._longpressTimeout(),1000)}_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 this._twoTouchTimeoutId!==null}_twoTouchTimeout(){if(this._tracked.length===0)throw Error("A pinch or two drag gesture failed, no tracked touches");let Q=this._getAverageMovement(),$=Math.abs(Q.x),V=Math.abs(Q.y),J=this._getAverageDistance(),W=Math.abs(Math.hypot(J.first.x,J.first.y)-Math.hypot(J.last.x,J.last.y));if(V{if(!this._target)return;$=document.elementFromPoint(Q.clientX,Q.clientY),this._updateVisibility($)},0)}_showCursor(){if(this._canvas.style.visibility==="hidden")this._canvas.style.visibility=""}_hideCursor(){if(this._canvas.style.visibility!=="hidden")this._canvas.style.visibility="hidden"}_shouldShowCursor(Q){if(!Q)return!1;if(Q===this._target)return!0;if(!this._target.contains(Q))return!1;if(window.getComputedStyle(Q).cursor!=="none")return!1;return!0}_updateVisibility(Q){if(this._captureIsActive())Q=document.captureElement;if(this._shouldShowCursor(Q))this._showCursor();else 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)}}var m6=41943040,y0={CONNECTING:"connecting",OPEN:"open",CLOSING:"closing",CLOSED:"closed"},h0={CONNECTING:[WebSocket.CONNECTING,y0.CONNECTING],OPEN:[WebSocket.OPEN,y0.OPEN],CLOSING:[WebSocket.CLOSING,y0.CLOSING],CLOSED:[WebSocket.CLOSED,y0.CLOSED]},I8=["send","close","binaryType","onerror","onmessage","onopen","protocol","readyState"];class p0{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 Q;if(this._websocket===null)return"unused";if(Q=this._websocket.readyState,h0.CONNECTING.includes(Q))return"connecting";else if(h0.OPEN.includes(Q))return"open";else if(h0.CLOSING.includes(Q))return"closing";else if(h0.CLOSED.includes(Q))return"closed";return"unknown"}rQpeek8(){return this._rQ[this._rQi]}rQskipBytes(Q){this._rQi+=Q}rQshift8(){return this._rQshift(1)}rQshift16(){return this._rQshift(2)}rQshift32(){return this._rQshift(4)}_rQshift(Q){let $=0;for(let V=Q-1;V>=0;V--)$+=this._rQ[this._rQi++]<>>0}rQshiftStr(Q){let $="";for(let V=0;V>8&255,this._sQ[this._sQlen++]=Q>>0&255}sQpush32(Q){this._sQensureSpace(4),this._sQ[this._sQlen++]=Q>>24&255,this._sQ[this._sQlen++]=Q>>16&255,this._sQ[this._sQlen++]=Q>>8&255,this._sQ[this._sQlen++]=Q>>0&255}sQpushString(Q){let $=Q.split("").map((V)=>V.charCodeAt(0));this.sQpushBytes(new Uint8Array($))}sQpushBytes(Q){for(let $=0;$Q.length-$)V=Q.length-$;this._sQ.set(Q.subarray($,$+V),this._sQlen),this._sQlen+=V,$+=V}}flush(){if(this._sQlen>0&&this.readyState==="open")this._websocket.send(new Uint8Array(this._sQ.buffer,0,this._sQlen)),this._sQlen=0}_sQensureSpace(Q){if(this._sQbufferSize-this._sQlen{}}on(Q,$){this._eventHandlers[Q]=$}_allocateBuffers(){this._rQ=new Uint8Array(this._rQbufferSize),this._sQ=new Uint8Array(this._sQbufferSize)}init(){this._allocateBuffers(),this._rQi=0,this._websocket=null}open(Q,$){this.attach(new WebSocket(Q,$))}attach(Q){this.init();let $=[...Object.keys(Q),...Object.getOwnPropertyNames(Object.getPrototypeOf(Q))];for(let V=0;V{if(w(">> WebSock.onopen"),this._websocket.protocol)r("Server choose sub-protocol: "+this._websocket.protocol);this._eventHandlers.open(),w("<< WebSock.onopen")},this._websocket.onclose=(V)=>{w(">> WebSock.onclose"),this._eventHandlers.close(V),w("<< WebSock.onclose")},this._websocket.onerror=(V)=>{w(">> WebSock.onerror: "+V),this._eventHandlers.error(V),w("<< WebSock.onerror: "+V)}}close(){if(this._websocket){if(this.readyState==="connecting"||this.readyState==="open")r("Closing WebSocket connection"),this._websocket.close();this._websocket.onmessage=()=>{}}}_expandCompactRQ(Q){let $=(this._rQlen-this._rQi+Q)*8,V=this._rQbufferSize<$;if(V)this._rQbufferSize=Math.max(this._rQbufferSize*2,$);if(this._rQbufferSize>m6){if(this._rQbufferSize=m6,this._rQbufferSize-(this._rQlen-this._rQi)this._rQbufferSize-this._rQlen)this._expandCompactRQ($.length);if(this._rQ.set($,this._rQlen),this._rQlen+=$.length,this._rQlen-this._rQi>0)this._eventHandlers.message();else w("Ignoring empty message")}}var B8={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};var T={encodingRaw:0,encodingCopyRect:1,encodingRRE:2,encodingHextile:5,encodingZlib:6,encodingTight:7,encodingZRLE:16,encodingTightPNG:-260,encodingJPEG:21,encodingH264:50,pseudoEncodingQualityLevel9:-23,pseudoEncodingQualityLevel0:-32,pseudoEncodingDesktopSize:-223,pseudoEncodingLastRect:-224,pseudoEncodingCursor:-239,pseudoEncodingQEMUExtendedKeyEvent:-258,pseudoEncodingQEMULedEvent:-261,pseudoEncodingDesktopName:-307,pseudoEncodingExtendedDesktopSize:-308,pseudoEncodingXvp:-309,pseudoEncodingFence:-312,pseudoEncodingContinuousUpdates:-313,pseudoEncodingExtendedMouseButtons:-316,pseudoEncodingCompressLevel9:-247,pseudoEncodingCompressLevel0:-256,pseudoEncodingVMwareCursor:1464686180,pseudoEncodingExtendedClipboard:3231835598};class m0{constructor(){this._key=null}get algorithm(){return{name:"AES-ECB"}}static async importKey(Q,$,V,J){let W=new m0;return await W._importKey(Q,V,J),W}async _importKey(Q,$,V){this._key=await window.crypto.subtle.importKey("raw",Q,{name:"AES-CBC"},$,V)}async encrypt(Q,$){let V=new Uint8Array($);if(V.length%16!==0||this._key===null)return null;let J=V.length/16;for(let W=0;W>>6;for(let W=0;W<15;W++)$[W]=Q[W+1]>>6|Q[W]<<2,Q[W]=Q[W+1]>>7|Q[W]<<1;let J=[0,135,14,137];$[14]^=V>>>1,$[15]=Q[15]<<2^J[V],Q[15]=Q[15]<<1^J[V>>1],this._k1=Q,this._k2=$}async _encryptCTR(Q,$){let V=await window.crypto.subtle.encrypt({name:"AES-CTR",counter:$,length:128},this._ctrKey,Q);return new Uint8Array(V)}async _decryptCTR(Q,$){let V=await window.crypto.subtle.decrypt({name:"AES-CTR",counter:$,length:128},this._ctrKey,Q);return new Uint8Array(V)}async _computeCMAC(Q,$){if($.length!==16)return null;let V=Math.floor(Q.length/16),J=Math.ceil(Q.length/16),W=Q.length-V*16,G=new Uint8Array((J+1)*16);if(G.set($),G.set(Q,16),W===0)for(let Z=0;Z<16;Z++)G[V*16+Z]^=this._k1[Z];else{G[(V+1)*16+W]=128;for(let Z=0;Z<16;Z++)G[(V+1)*16+Z]^=this._k2[Z]}let q=await window.crypto.subtle.encrypt({name:"AES-CBC",iv:this._zeroBlock},this._cbcKey,G);return q=new Uint8Array(q),q.slice(q.length-32,q.length-16)}static async importKey(Q,$,V,J){let W=new b0;return await W._importKey(Q),W}async _importKey(Q){this._rawKey=Q,this._ctrKey=await window.crypto.subtle.importKey("raw",Q,{name:"AES-CTR"},!1,["encrypt","decrypt"]),this._cbcKey=await window.crypto.subtle.importKey("raw",Q,{name:"AES-CBC"},!1,["encrypt"]),await this._initCMAC()}async encrypt(Q,$){let{additionalData:V,iv:J}=Q,W=await this._computeCMAC(J,this._prefixBlock0),G=await this._encryptCTR($,W),q=await this._computeCMAC(V,this._prefixBlock1),U=await this._computeCMAC(G,this._prefixBlock2);for(let Y=0;Y<16;Y++)U[Y]^=W[Y]^q[Y];let Z=new Uint8Array(16+G.length);return Z.set(G),Z.set(U,G.length),Z}async decrypt(Q,$){let V=$.slice(0,$.length-16),J=Q.additionalData,W=Q.iv,G=$.slice($.length-16),q=await this._computeCMAC(W,this._prefixBlock0),U=await this._computeCMAC(J,this._prefixBlock1),Z=await this._computeCMAC(V,this._prefixBlock2);for(let X=0;X<16;X++)Z[X]^=q[X]^U[X];if(Z.length!==G.length)return null;for(let X=0;X>>3]&1<>>10,this.keys[q]|=(Z&4032)>>>6,++q,this.keys[q]=(U&258048)<<12,this.keys[q]|=(U&63)<<16,this.keys[q]|=(Z&258048)>>>4,this.keys[q]|=Z&63,++q}}enc8(Q){let $=Q.slice(),V=0,J,W,G;J=$[V++]<<24|$[V++]<<16|$[V++]<<8|$[V++],W=$[V++]<<24|$[V++]<<16|$[V++]<<8|$[V++],G=(J>>>4^W)&252645135,W^=G,J^=G<<4,G=(J>>>16^W)&65535,W^=G,J^=G<<16,G=(W>>>2^J)&858993459,J^=G,W^=G<<2,G=(W>>>8^J)&16711935,J^=G,W^=G<<8,W=W<<1|W>>>31&1,G=(J^W)&2863311530,J^=G,W^=G,J=J<<1|J>>>31&1;for(let q=0,U=0;q<8;++q){G=W<<28|W>>>4,G^=this.keys[U++];let Z=E8[G&63];Z|=R8[G>>>8&63],Z|=A8[G>>>16&63],Z|=M8[G>>>24&63],G=W^this.keys[U++],Z|=w8[G&63],Z|=K8[G>>>8&63],Z|=D8[G>>>16&63],Z|=O8[G>>>24&63],J^=Z,G=J<<28|J>>>4,G^=this.keys[U++],Z=E8[G&63],Z|=R8[G>>>8&63],Z|=A8[G>>>16&63],Z|=M8[G>>>24&63],G=J^this.keys[U++],Z|=w8[G&63],Z|=K8[G>>>8&63],Z|=D8[G>>>16&63],Z|=O8[G>>>24&63],W^=Z}W=W<<31|W>>>1,G=(J^W)&2863311530,J^=G,W^=G,J=J<<31|J>>>1,G=(J>>>8^W)&16711935,W^=G,J^=G<<8,G=(J>>>2^W)&858993459,W^=G,J^=G<<2,G=(W>>>16^J)&65535,J^=G,W^=G<<16,G=(W>>>4^J)&252645135,J^=G,W^=G<<4,G=[W,J];for(V=0;V<8;V++)if($[V]=(G[V>>>2]>>>8*(3-V%4))%256,$[V]<0)$[V]+=256;return $}}class c0{constructor(){this._cipher=null}get algorithm(){return{name:"DES-ECB"}}static importKey(Q,$,V,J){let W=new c0;return W._importKey(Q),W}_importKey(Q,$,V){this._cipher=new b6(Q)}encrypt(Q,$){let V=new Uint8Array($);if(V.length%8!==0||this._cipher===null)return null;let J=V.length/8;for(let W=0;W0n){if(($&1n)===1n)J=J*Q%V;$=$>>1n,Q=Q*Q%V}return J}function s1(Q,$=0){let V=Q.toString(16);if($===0)$=Math.ceil(V.length/2);V=V.padStart($*2,"0");let J=V.length/2,W=new Uint8Array(J);for(let G=0;Gthis._keyBytes-11)return null;let V=new Uint8Array(this._keyBytes-$.length-3);window.crypto.getRandomValues(V);for(let q=0;qthis._keyBytes?V:this._keyBytes,G=t1(W1(J),this._privateKeyBigInt,this._pBigInt);return s1(G,W).slice(0,W)}}async function T8(Q){let $="";for(let V=0;V>2);for(let V=0;V<$.length;V++)$[V]=0;for(let V=0;V<8*Q.length;V+=8)$[V>>5]|=(255&Q.charCodeAt(V/8))<>5]>>>V%32&255);return $}function H4(Q,$){Q[$>>5]|=128<<$%32,Q[14+($+64>>>9<<4)]=$;let V=1732584193,J=-271733879,W=-1732584194,G=271733878;for(let q=0;q>16)+($>>16)+(V>>16)<<16|65535&V}function L4(Q,$){return Q<<$|Q>>>32-$}class v8{constructor(){this._algorithms={"AES-ECB":m0,"AES-EAX":b0,"DES-ECB":c0,"DES-CBC":n0,"RSA-PKCS1-v1_5":L0,DH:i0,MD5:T8}}encrypt(Q,$,V){if($.algorithm.name!==Q.name)throw Error("algorithm does not match");if(typeof $.encrypt!=="function")throw Error("key does not support encryption");return $.encrypt(Q,V)}decrypt(Q,$,V){if($.algorithm.name!==Q.name)throw Error("algorithm does not match");if(typeof $.decrypt!=="function")throw Error("key does not support encryption");return $.decrypt(Q,V)}importKey(Q,$,V,J,W){if(Q!=="raw")throw Error("key format is not supported");let G=this._algorithms[V.name];if(typeof G>"u"||typeof G.importKey!=="function")throw Error("algorithm is not supported");return G.importKey($,V,J,W)}generateKey(Q,$,V){let J=this._algorithms[Q.name];if(typeof J>"u"||typeof J.generateKey!=="function")throw Error("algorithm is not supported");return J.generateKey(Q,$,V)}exportKey(Q,$){if(Q!=="raw")throw Error("key format is not supported");if(typeof $.exportKey!=="function")throw Error("key does not support exportKey");return $.exportKey()}digest(Q,$){let V=this._algorithms[Q];if(typeof V!=="function")throw Error("algorithm is not supported");return V($)}deriveBits(Q,$,V){if($.algorithm.name!==Q.name)throw Error("algorithm does not match");if(typeof $.deriveBits!=="function")throw Error("key does not support deriveBits");return $.deriveBits(Q,V)}}var n=new v8;class c6{constructor(){this._cipher=null,this._counter=new Uint8Array(16)}async setKey(Q){this._cipher=await n.importKey("raw",Q,{name:"AES-EAX"},!1,["encrypt, decrypt"])}async makeMessage(Q){let $=new Uint8Array([(Q.length&65280)>>>8,Q.length&255]),V=await n.encrypt({name:"AES-EAX",iv:this._counter,additionalData:$},this._cipher,Q);for(let W=0;W<16&&this._counter[W]++===255;W++);let J=new Uint8Array(Q.length+2+16);return J.set($),J.set(V,2),J}async receiveMessage(Q,$){let V=new Uint8Array([(Q&65280)>>>8,Q&255]),J=await n.decrypt({name:"AES-EAX",iv:this._counter,additionalData:V},this._cipher,$);for(let W=0;W<16&&this._counter[W]++===255;W++);return J}}class l0 extends h1{constructor(Q,$){super();this._hasStarted=!1,this._checkSock=null,this._checkCredentials=null,this._approveServerResolve=null,this._sockReject=null,this._credentialsReject=null,this._approveServerReject=null,this._sock=Q,this._getCredentials=$}_waitSockAsync(Q){return new Promise(($,V)=>{let J=()=>!this._sock.rQwait("RA2",Q);if(J())$();else this._checkSock=()=>{if(J())$(),this._checkSock=null,this._sockReject=null},this._sockReject=V})}_waitApproveKeyAsync(){return new Promise((Q,$)=>{this._approveServerResolve=Q,this._approveServerReject=$})}_waitCredentialsAsync(Q){let $=()=>{if(Q===1&&this._getCredentials().username!==void 0&&this._getCredentials().password!==void 0)return!0;else if(Q===2&&this._getCredentials().password!==void 0)return!0;return!1};return new Promise((V,J)=>{if($())V();else this._checkCredentials=()=>{if($())V(),this._checkCredentials=null,this._credentialsReject=null},this._credentialsReject=J})}checkInternalEvents(){if(this._checkSock!==null)this._checkSock();if(this._checkCredentials!==null)this._checkCredentials()}approveServer(){if(this._approveServerResolve!==null)this._approveServerResolve(),this._approveServerResolve=null}disconnect(){if(this._sockReject!==null)this._sockReject(Error("disconnect normally")),this._sockReject=null;if(this._credentialsReject!==null)this._credentialsReject(Error("disconnect normally")),this._credentialsReject=null;if(this._approveServerReject!==null)this._approveServerReject(Error("disconnect normally")),this._approveServerReject=null}async negotiateRA2neAuthAsync(){this._hasStarted=!0,await this._waitSockAsync(4);let Q=this._sock.rQpeekBytes(4),$=this._sock.rQshift32();if($<1024)throw Error("RA2: server public key is too short: "+$);else if($>8192)throw Error("RA2: server public key is too long: "+$);let V=Math.ceil($/8);await this._waitSockAsync(V*2);let J=this._sock.rQshiftBytes(V),W=this._sock.rQshiftBytes(V),G=await n.importKey("raw",{n:J,e:W},{name:"RSA-PKCS1-v1_5"},!1,["encrypt"]),q=new Uint8Array(4+V*2);q.set(Q),q.set(J,4),q.set(W,4+V);let U=this._waitApproveKeyAsync();this.dispatchEvent(new CustomEvent("serververification",{detail:{type:"RSA",publickey:q}})),await U;let Z=2048,Y=Math.ceil(Z/8),X=(await n.generateKey({name:"RSA-PKCS1-v1_5",modulusLength:Z,publicExponent:new Uint8Array([1,0,1])},!0,["encrypt"])).privateKey,I=await n.exportKey("raw",X),j=I.n,P=I.e,O=new Uint8Array(4+Y*2);O[0]=(Z&4278190080)>>>24,O[1]=(Z&16711680)>>>16,O[2]=(Z&65280)>>>8,O[3]=Z&255,O.set(j,4),O.set(P,4+Y),this._sock.sQpushBytes(O),this._sock.flush();let k=new Uint8Array(16);window.crypto.getRandomValues(k);let E=await n.encrypt({name:"RSA-PKCS1-v1_5"},G,k),D=new Uint8Array(2+V);if(D[0]=(V&65280)>>>8,D[1]=V&255,D.set(E,2),this._sock.sQpushBytes(D),this._sock.flush(),await this._waitSockAsync(2),this._sock.rQshift16()!==Y)throw Error("RA2: wrong encrypted message length");let S=this._sock.rQshiftBytes(Y),R=await n.decrypt({name:"RSA-PKCS1-v1_5"},X,S);if(R===null||R.length!==16)throw Error("RA2: corrupted server encrypted random");let A=new Uint8Array(32),v=new Uint8Array(32);A.set(R),A.set(k,16),v.set(k),v.set(R,16),A=await window.crypto.subtle.digest("SHA-1",A),A=new Uint8Array(A).slice(0,16),v=await window.crypto.subtle.digest("SHA-1",v),v=new Uint8Array(v).slice(0,16);let b=new c6;await b.setKey(A);let K=new c6;await K.setKey(v);let x=new Uint8Array(8+V*2+Y*2),f=new Uint8Array(8+V*2+Y*2);if(x.set(q),x.set(O,4+V*2),f.set(O),f.set(q,4+Y*2),x=await window.crypto.subtle.digest("SHA-1",x),f=await window.crypto.subtle.digest("SHA-1",f),x=new Uint8Array(x),f=new Uint8Array(f),this._sock.sQpushBytes(await b.makeMessage(f)),this._sock.flush(),await this._waitSockAsync(38),this._sock.rQshift16()!==20)throw Error("RA2: wrong server hash");let g=await K.receiveMessage(20,this._sock.rQshiftBytes(36));if(g===null)throw Error("RA2: failed to authenticate the message");for(let o=0;o<20;o++)if(g[o]!==x[o])throw Error("RA2: wrong server hash");if(await this._waitSockAsync(19),this._sock.rQshift16()!==1)throw Error("RA2: wrong subtype");let m=await K.receiveMessage(1,this._sock.rQshiftBytes(17));if(m===null)throw Error("RA2: failed to authenticate the message");m=m[0];let P1=this._waitCredentialsAsync(m);if(m===1){if(this._getCredentials().username===void 0||this._getCredentials().password===void 0)this.dispatchEvent(new CustomEvent("credentialsrequired",{detail:{types:["username","password"]}}))}else if(m===2){if(this._getCredentials().password===void 0)this.dispatchEvent(new CustomEvent("credentialsrequired",{detail:{types:["password"]}}))}else throw Error("RA2: wrong subtype");await P1;let J1;if(m===1)J1=q1(this._getCredentials().username).slice(0,255);else J1="";let D1=q1(this._getCredentials().password).slice(0,255),C1=new Uint8Array(J1.length+D1.length+2);C1[0]=J1.length,C1[J1.length+1]=D1.length;for(let o=0;o0){if(W.rQwait("RAW",Z))return!1;let Y=$+(J-this._lines),X=W.rQshiftBytes(Z,!1);if(q==8){let I=new Uint8Array(V*4);for(let j=0;j>0&3)*255/3,I[j*4+1]=(X[j]>>2&3)*255/3,I[j*4+2]=(X[j]>>4&3)*255/3,I[j*4+3]=255;X=I}for(let I=0;I0){if(W.rQwait("RRE",12))return!1;let U=W.rQshiftBytes(4),Z=W.rQshift16(),Y=W.rQshift16(),X=W.rQshift16(),I=W.rQshift16();G.fillRect(Q+Z,$+Y,X,I,U),this._subrects--}return!0}}class t0{constructor(){this._tiles=0,this._lastsubencoding=0,this._tileBuffer=new Uint8Array(1024)}decodeRect(Q,$,V,J,W,G,q){if(this._tiles===0)this._tilesX=Math.ceil(V/16),this._tilesY=Math.ceil(J/16),this._totalTiles=this._tilesX*this._tilesY,this._tiles=this._totalTiles;while(this._tiles>0){let U=1;if(W.rQwait("HEXTILE",U))return!1;let Z=W.rQpeek8();if(Z>30)throw Error("Illegal hextile subencoding (subencoding: "+Z+")");let Y=this._totalTiles-this._tiles,X=Y%this._tilesX,I=Math.floor(Y/this._tilesX),j=Q+X*16,P=$+I*16,O=Math.min(16,Q+V-j),k=Math.min(16,$+J-P);if(Z&1)U+=O*k*4;else{if(Z&2)U+=4;if(Z&4)U+=4;if(Z&8){if(U++,W.rQwait("HEXTILE",U))return!1;let E=W.rQpeekBytes(U).at(-1);if(Z&16)U+=E*6;else U+=E*2}}if(W.rQwait("HEXTILE",U))return!1;if(W.rQshift8(),Z===0)if(this._lastsubencoding&1)w(" Ignoring blank after RAW");else G.fillRect(j,P,O,k,this._background);else if(Z&1){let E=O*k,D=W.rQshiftBytes(E*4,!1);for(let S=0;S>4,v=R&15,b=W.rQshift8(),K=(b>>4)+1,x=(b&15)+1;this._subTile(A,v,K,x,S)}}this._finishTile(G)}this._lastsubencoding=Z,this._tiles--}return!0}_startTile(Q,$,V,J,W){this._tileX=Q,this._tileY=$,this._tileW=V,this._tileH=J;let G=W[0],q=W[1],U=W[2],Z=this._tileBuffer;for(let Y=0;Y>Z&1)this._zlibs[Z].reset(),r("Reset zlib stream "+Z);this._ctl=this._ctl>>4}let U;if(this._ctl===8)U=this._fillRect(Q,$,V,J,W,G,q);else if(this._ctl===9)U=this._jpegRect(Q,$,V,J,W,G,q);else if(this._ctl===10)U=this._pngRect(Q,$,V,J,W,G,q);else if((this._ctl&8)==0)U=this._basicRect(this._ctl,Q,$,V,J,W,G,q);else throw Error("Illegal tight compression received (ctl: "+this._ctl+")");if(U)this._ctl=null;return U}_fillRect(Q,$,V,J,W,G,q){if(W.rQwait("TIGHT",3))return!1;let U=W.rQshiftBytes(3);return G.fillRect(Q,$,V,J,U,!1),!0}_jpegRect(Q,$,V,J,W,G,q){let U=this._readData(W);if(U===null)return!1;return G.imageRect(Q,$,V,J,"image/jpeg",U),!0}_pngRect(Q,$,V,J,W,G,q){throw Error("PNG received in standard Tight rect")}_basicRect(Q,$,V,J,W,G,q,U){if(this._filter===null)if(Q&4){if(G.rQwait("TIGHT",1))return!1;this._filter=G.rQshift8()}else this._filter=0;let Z=Q&3,Y;switch(this._filter){case 0:Y=this._copyFilter(Z,$,V,J,W,G,q,U);break;case 1:Y=this._paletteFilter(Z,$,V,J,W,G,q,U);break;case 2:Y=this._gradientFilter(Z,$,V,J,W,G,q,U);break;default:throw Error("Illegal tight filter received (ctl: "+this._filter+")")}if(Y)this._filter=null;return Y}_copyFilter(Q,$,V,J,W,G,q,U){let Z=J*W*3,Y;if(Z===0)return!0;if(Z<12){if(G.rQwait("TIGHT",Z))return!1;Y=G.rQshiftBytes(Z)}else{if(Y=this._readData(G),Y===null)return!1;this._zlibs[Q].setInput(Y),Y=this._zlibs[Q].inflate(Z),this._zlibs[Q].setInput(null)}let X=new Uint8Array(J*W*4);for(let I=0,j=0;I=0;O--)I=(X*V+P*8+7-O)*4,j=(W[X*Z+P]>>O&1)*3,U[I]=G[j],U[I+1]=G[j+1],U[I+2]=G[j+2],U[I+3]=255;for(let O=7;O>=8-V%8;O--)I=(X*V+P*8+7-O)*4,j=(W[X*Z+P]>>O&1)*3,U[I]=G[j],U[I+1]=G[j+1],U[I+2]=G[j+2],U[I+3]=255}q.blitImage(Q,$,V,J,U,0,!1)}_paletteRect(Q,$,V,J,W,G,q){let U=this._getScratchBuffer(V*J*4),Z=V*J*4;for(let Y=0,X=0;Y255)A=255;let v=Y[j++]+A;X[I++]=v,E[R]=k[R],P[R]=v}X[I++]=255,O++}}return q.blitImage($,V,J,W,X,0,!1),!0}_readData(Q){if(this._len===0){if(Q.rQwait("TIGHT",3))return null;let V;if(V=Q.rQshift8(),this._len=V&127,V&128){if(V=Q.rQshift8(),this._len|=(V&127)<<7,V&128)V=Q.rQshift8(),this._len|=V<<14}}if(Q.rQwait("TIGHT",this._len))return null;let $=Q.rQshiftBytes(this._len,!1);return this._len=0,$}_getScratchBuffer(Q){if(!this._scratchBuffer||this._scratchBuffer.length=2&&P<=16){let O=this._decodePaletteTile(P,j,I,Y);G.blitImage(X,Z,I,Y,O,0,!1)}else if(P===128){let O=this._decodeRLETile(j);G.blitImage(X,Z,I,Y,O,0,!1)}else if(P>=130&&P<=255){let O=this._decodeRLEPaletteTile(P-128,j);G.blitImage(X,Z,I,Y,O,0,!1)}else throw Error("Unknown subencoding: "+P)}}return this._length=0,!0}_getBitsPerPixelInPalette(Q){if(Q<=2)return 1;else if(Q<=4)return 2;else if(Q<=16)return 4}_readPixels(Q){let $=this._pixelBuffer,V=this._inflator.inflate(3*Q);for(let J=0,W=0;J>I&U;W[Z]=G[P*4],W[Z+1]=G[P*4+1],W[Z+2]=G[P*4+2],W[Z+3]=G[P*4+3],Z+=4,I-=q}if(I<8-q&&X=128)G-=128,q=this._readRLELength();if(G>Q)throw Error("Too big index in palette: "+G+", palette size: "+Q);if(W+q>$)throw Error("Too big rle length in palette mode: "+q+", allowed length is: "+($-W));for(let U=0;Uj[1]==192||j[1]==194);if(Y==-1)throw Error("Illegal JPEG image without SOF");if(Z.length===0)this._segments.splice(Y+1,0,...this._cachedQuantTables);if(U.length===0)this._segments.splice(Y+1,0,...this._cachedHuffmanTables);let X=0;for(let j of this._segments)X+=j.length;let I=new Uint8Array(X);X=0;for(let j of this._segments)I.set(j,X),X+=j.length;if(G.imageRect(Q,$,V,J,"image/jpeg",I),U.length!==0)this._cachedHuffmanTables=U;if(Z.length!==0)this._cachedQuantTables=Z;return this._segments=[],!0}_readSegment(Q){if(Q.rQwait("JPEG",2))return null;let $=Q.rQshift8();if($!=255)throw Error("Illegal JPEG marker received (byte: "+$+")");let V=Q.rQshift8();if(V>=208&&V<=217||V==1)return new Uint8Array([$,V]);if(Q.rQwait("JPEG",2,2))return null;let J=Q.rQshift16();if(J<2)throw Error("Illegal JPEG length received (length: "+J+")");if(Q.rQwait("JPEG",J-2,4))return null;let W=0;if(V===218){W+=2;while(!0){if(Q.rQwait("JPEG",J-2+W,4))return null;let q=Q.rQpeekBytes(J-2+W,!1);if(q.at(-2)===255&&q.at(-1)!==0&&!(q.at(-1)>=208&&q.at(-1)<=215)){W-=2;break}W++}}let G=new Uint8Array(2+J+W);return G[0]=$,G[1]=V,G[2]=J>>8,G[3]=J,G.set(Q.rQshiftBytes(J-2+W,!1),4),G}}class g8{constructor(Q){this._data=Q,this._index=0,this.profileIdc=null,this.constraintSet=null,this.levelIdc=null}_getStartSequenceLen(Q){let $=this._data;if($[Q+0]==0&&$[Q+1]==0&&$[Q+2]==0&&$[Q+3]==1)return 4;if($[Q+0]==0&&$[Q+1]==0&&$[Q+2]==1)return 3;return 0}_indexOfNextNalUnit(Q){let $=this._data;for(let V=Q;V<$.length;++V)if(this._getStartSequenceLen(V)!=0)return V;return-1}_parseSps(Q){this.profileIdc=this._data[Q],this.constraintSet=this._data[Q+1],this.levelIdc=this._data[Q+2]}_parseNalUnit(Q){let $=this._data[Q];if($&128)throw Error("H264 parsing sanity check failed, forbidden zero bit is set");let V=$&31;switch(V){case 1:return{slice:!0};case 5:return{slice:!0,key:!0};case 6:return{};case 7:return this._parseSps(Q+1),{};case 8:return{};default:l("Unhandled unit type: ",V);break}return{}}parse(){let Q=this._index,$=!1;while(this._indexthis._handleFrame(W),error:(W)=>this._handleError(W)});let J="avc1."+Q.toString(16).padStart(2,"0")+$.toString(16).padStart(2,"0")+V.toString(16).padStart(2,"0");this._decoder.configure({codec:J,codedWidth:this._width,codedHeight:this._height,optimizeForLatency:!0})}_preparePendingFrame(Q){let $={timestamp:Q,promise:null,resolve:null,frame:null,ready:!1,keep:!1};return $.promise=new Promise((V)=>{$.resolve=V}),this._pendingFrames.push($),$}decode(Q){let $=new g8(Q),V=null,J=Math.round(window.performance.now()*1000);while(!0){let W=$.parse();if(W===null)break;if($.profileIdc!==null)self._profileIdc=$.profileIdc,self._constraintSet=$.constraintSet,self._levelIdc=$.levelIdc;if(this._decoder===null||this._decoder.state!=="configured"){if(!W.key){l("Missing key frame. Can't decode until one arrives");continue}if(self._profileIdc===null){l("Cannot config decoder. Have not received SPS and PPS yet.");continue}this._configureDecoder(self._profileIdc,self._constraintSet,self._levelIdc)}V=this._preparePendingFrame(J);let G=new EncodedVideoChunk({timestamp:J,type:W.key?"key":"delta",data:W.frame});try{this._decoder.decode(G)}catch(q){l("Failed to decode:",q)}}if(V!==null)V.keep=!0;return V}}class W6{constructor(){this._tick=0,this._contexts={}}_contextId(Q,$,V,J){return[Q,$,V,J].join(",")}_findOldestContextId(){let Q=Number.MAX_VALUE,$=void 0;for(let[V,J]of Object.entries(this._contexts))if(J.lastUsed=64){let q=this._findOldestContextId();delete this._contexts[q]}let G=new k8(V,J);return this._contexts[this._contextId(Q,$,V,J)]=G,G}_getContext(Q,$,V,J){let W=this._contexts[this._contextId(Q,$,V,J)];return W!==void 0?W:this._createContext(Q,$,V,J)}_resetContext(Q,$,V,J){delete this._contexts[this._contextId(Q,$,V,J)]}_resetAllContexts(){this._contexts={}}decodeRect(Q,$,V,J,W,G,q){if(W.rQwait("h264 header",8))return!1;let Y=W.rQshift32(),X=W.rQshift32();if(W.rQwait("h264 payload",Y,8))return!1;if(X&2)this._resetAllContexts();else if(X&1)this._resetContext(Q,$,V,J);let I=this._getContext(Q,$,V,J);if(I.lastUsed=this._tick++,Y!==0){let j=W.rQshiftBytes(Y,!1),P=I.decode(j);if(P!==null)G.videoFrame(Q,$,V,J,P)}return!0}}var F4=3,C4="rgb(40, 40, 40)",x8=17,f8=50,u8=19,F0=75,A1=50,I4=1000,B4=50,_8=1,G6=2,y8=6,h8=16,n6=19,p8=22,m8=30,b8=113,c8=129,n8=256,z1=1;var i8=16777216,q6=33554432,r8=67108864,C0=134217728,U6=268435456;class u extends h1{constructor(Q,$,V){if(!Q)throw Error("Must specify target");if(!$)throw Error("Must specify URL, WebSocket or RTCDataChannel");if(!window.isSecureContext)p("noVNC requires a secure context (TLS). Expect crashes!");super();if(this._target=Q,typeof $==="string")this._url=$;else this._url=null,this._rawChannel=$;V=V||{},this._rfbCredentials=V.credentials||{},this._shared="shared"in V?!!V.shared:!0,this._repeaterID=V.repeaterID||"",this._wsProtocols=V.wsProtocols||[],this._rfbConnectionState="",this._rfbInitState="",this._rfbAuthScheme=-1,this._rfbCleanDisconnect=!0,this._rfbRSAAESAuthenticationState=null,this._rfbVersion=0,this._rfbMaxVersion=3.8,this._rfbTightVNC=!1,this._rfbVeNCryptState=0,this._rfbXvpVer=0,this._fbWidth=0,this._fbHeight=0,this._fbName="",this._capabilities={power:!1},this._supportsFence=!1,this._supportsContinuousUpdates=!1,this._enabledContinuousUpdates=!1,this._supportsSetDesktopSize=!1,this._screenID=0,this._screenFlags=0,this._pendingRemoteResize=!1,this._lastResize=0,this._qemuExtKeyEventSupported=!1,this._extendedPointerEventSupported=!1,this._clipboardText=null,this._clipboardServerCapabilitiesActions={},this._clipboardServerCapabilitiesFormats={},this._sock=null,this._display=null,this._flushing=!1,this._keyboard=null,this._gestures=null,this._resizeObserver=null,this._disconnTimer=null,this._resizeTimeout=null,this._mouseMoveTimer=null,this._decoders={},this._FBU={rects:0,x:0,y:0,width:0,height:0,encoding:null},this._mousePos={},this._mouseButtonMask=0,this._mouseLastMoveTime=0,this._viewportDragging=!1,this._viewportDragPos={},this._viewportHasMoved=!1,this._accumulatedWheelDeltaX=0,this._accumulatedWheelDeltaY=0,this._gestureLastTapTime=null,this._gestureFirstDoubleTapEv=null,this._gestureLastMagnitudeX=0,this._gestureLastMagnitudeY=0,this._eventHandlers={focusCanvas:this._focusCanvas.bind(this),handleResize:this._handleResize.bind(this),handleMouse:this._handleMouse.bind(this),handleWheel:this._handleWheel.bind(this),handleGesture:this._handleGesture.bind(this),handleRSAAESCredentialsRequired:this._handleRSAAESCredentialsRequired.bind(this),handleRSAAESServerVerification:this._handleRSAAESServerVerification.bind(this)},w(">> 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=C4,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 _0,this._cursorImage=u.cursors.none,this._decoders[T.encodingRaw]=new o0,this._decoders[T.encodingCopyRect]=new d0,this._decoders[T.encodingRRE]=new a0,this._decoders[T.encodingHextile]=new t0,this._decoders[T.encodingZlib]=new s0,this._decoders[T.encodingTight]=new e1,this._decoders[T.encodingTightPNG]=new e0,this._decoders[T.encodingZRLE]=new $6,this._decoders[T.encodingJPEG]=new J6,this._decoders[T.encodingH264]=new W6;try{this._display=new N0(this._canvas)}catch(J){throw p("Display exception: "+J),J}if(this._keyboard=new f0(this._canvas),this._keyboard.onkeyevent=this._handleKeyEvent.bind(this),this._remoteCapsLock=null,this._remoteNumLock=null,this._gestures=new u0,this._sock=new p0,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._expectedClientWidth=null,this._expectedClientHeight=null,this._resizeObserver=new ResizeObserver(this._eventHandlers.handleResize),this._updateConnectionState("connecting"),w("<< RFB.constructor"),this.dragViewport=!1,this.focusOnClick=!0,this._viewOnly=!1,this._clipViewport=!1,this._clippingViewport=!1,this._scaleViewport=!1,this._resizeSession=!1,this._showDotCursor=!1,V.showDotCursor!==void 0)l("Specifying showDotCursor as a RFB constructor argument is deprecated"),this._showDotCursor=V.showDotCursor;this._qualityLevel=6,this._compressionLevel=2}get viewOnly(){return this._viewOnly}set viewOnly(Q){if(this._viewOnly=Q,this._rfbConnectionState==="connecting"||this._rfbConnectionState==="connected")if(Q)this._keyboard.ungrab();else this._keyboard.grab()}get capabilities(){return this._capabilities}get clippingViewport(){return this._clippingViewport}_setClippingViewport(Q){if(Q===this._clippingViewport)return;this._clippingViewport=Q,this.dispatchEvent(new CustomEvent("clippingviewport",{detail:this._clippingViewport}))}get touchButton(){return 0}set touchButton(Q){l("Using old API!")}get clipViewport(){return this._clipViewport}set clipViewport(Q){this._clipViewport=Q,this._updateClip()}get scaleViewport(){return this._scaleViewport}set scaleViewport(Q){if(this._scaleViewport=Q,Q&&this._clipViewport)this._updateClip();if(this._updateScale(),!Q&&this._clipViewport)this._updateClip()}get resizeSession(){return this._resizeSession}set resizeSession(Q){if(this._resizeSession=Q,Q)this._requestRemoteResize()}get showDotCursor(){return this._showDotCursor}set showDotCursor(Q){this._showDotCursor=Q,this._refreshCursor()}get background(){return this._screen.style.background}set background(Q){this._screen.style.background=Q}get qualityLevel(){return this._qualityLevel}set qualityLevel(Q){if(!Number.isInteger(Q)||Q<0||Q>9){p("qualityLevel must be an integer between 0 and 9");return}if(this._qualityLevel===Q)return;if(this._qualityLevel=Q,this._rfbConnectionState==="connected")this._sendEncodings()}get compressionLevel(){return this._compressionLevel}set compressionLevel(Q){if(!Number.isInteger(Q)||Q<0||Q>9){p("compressionLevel must be an integer between 0 and 9");return}if(this._compressionLevel===Q)return;if(this._compressionLevel=Q,this._rfbConnectionState==="connected")this._sendEncodings()}disconnect(){if(this._updateConnectionState("disconnecting"),this._sock.off("error"),this._sock.off("message"),this._sock.off("open"),this._rfbRSAAESAuthenticationState!==null)this._rfbRSAAESAuthenticationState.disconnect()}approveServer(){if(this._rfbRSAAESAuthenticationState!==null)this._rfbRSAAESAuthenticationState.approveServer()}sendCredentials(Q){this._rfbCredentials=Q,this._resumeAuthentication()}sendCtrlAltDel(){if(this._rfbConnectionState!=="connected"||this._viewOnly)return;r("Sending Ctrl-Alt-Del"),this.sendKey(z.XK_Control_L,"ControlLeft",!0),this.sendKey(z.XK_Alt_L,"AltLeft",!0),this.sendKey(z.XK_Delete,"Delete",!0),this.sendKey(z.XK_Delete,"Delete",!1),this.sendKey(z.XK_Alt_L,"AltLeft",!1),this.sendKey(z.XK_Control_L,"ControlLeft",!1)}machineShutdown(){this._xvpOp(1,2)}machineReboot(){this._xvpOp(1,3)}machineReset(){this._xvpOp(1,4)}sendKey(Q,$,V){if(this._rfbConnectionState!=="connected"||this._viewOnly)return;if(V===void 0){this.sendKey(Q,$,!0),this.sendKey(Q,$,!1);return}let J=B8[$];if(this._qemuExtKeyEventSupported&&J)Q=Q||0,r("Sending key ("+(V?"down":"up")+"): keysym "+Q+", scancode "+J),u.messages.QEMUExtendedKeyEvent(this._sock,Q,V,J);else{if(!Q)return;r("Sending keysym ("+(V?"down":"up")+"): "+Q),u.messages.keyEvent(this._sock,Q,V?1:0)}}focus(Q){this._canvas.focus(Q)}blur(){this._canvas.blur()}clipboardPasteFrom(Q){if(this._rfbConnectionState!=="connected"||this._viewOnly)return;if(this._clipboardServerCapabilitiesFormats[z1]&&this._clipboardServerCapabilitiesActions[C0])this._clipboardText=Q,u.messages.extendedClipboardNotify(this._sock,[z1]);else{let $,V,J;$=0;for(let W of Q)$++;J=new Uint8Array($),V=0;for(let W of Q){let G=W.codePointAt(0);if(G>255)G=63;J[V++]=G}u.messages.clientCutText(this._sock,J)}}getImageData(){return this._display.getImageData()}toDataURL(Q,$){return this._display.toDataURL(Q,$)}toBlob(Q,$,V){return this._display.toBlob(Q,$,V)}_connect(){if(w(">> RFB.connect"),this._url)r(`connecting to ${this._url}`),this._sock.open(this._url,this._wsProtocols);else{if(r(`attaching ${this._rawChannel} to Websock`),this._sock.attach(this._rawChannel),this._sock.readyState==="closed")throw Error("Cannot use already closed WebSocket/RTCDataChannel");if(this._sock.readyState==="open")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),w("<< RFB.connect")}_disconnect(){w(">> 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(Q){if(Q.name==="NotFoundError");else throw Q}clearTimeout(this._resizeTimeout),clearTimeout(this._mouseMoveTimer),w("<< RFB.disconnect")}_socketOpen(){if(this._rfbConnectionState==="connecting"&&this._rfbInitState==="")this._rfbInitState="ProtocolVersion",w("Starting VNC handshake");else this._fail("Unexpected server connection while "+this._rfbConnectionState)}_socketClose(Q){w("WebSocket on-close event");let $="";if(Q.code){if($="(code: "+Q.code,Q.reason)$+=", reason: "+Q.reason;$+=")"}switch(this._rfbConnectionState){case"connecting":this._fail("Connection closed "+$);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 "+$);break;default:this._fail("Unexpected server disconnect before connecting "+$);break}this._sock.off("close"),this._rawChannel=null}_socketError(Q){l("WebSocket on-error event")}_focusCanvas(Q){if(!this.focusOnClick)return;this.focus({preventScroll:!0})}_setDesktopName(Q){this._fbName=Q,this.dispatchEvent(new CustomEvent("desktopname",{detail:{name:this._fbName}}))}_saveExpectedClientSize(){this._expectedClientWidth=this._screen.clientWidth,this._expectedClientHeight=this._screen.clientHeight}_currentClientSize(){return[this._screen.clientWidth,this._screen.clientHeight]}_clientHasExpectedSize(){let[Q,$]=this._currentClientSize();return Q==this._expectedClientWidth&&$==this._expectedClientHeight}_handleResize(){if(this._clientHasExpectedSize())return;window.requestAnimationFrame(()=>{this._updateClip(),this._updateScale(),this._saveExpectedClientSize()}),this._requestRemoteResize()}_updateClip(){let Q=this._display.clipViewport,$=this._clipViewport;if(this._scaleViewport)$=!1;if(Q!==$)this._display.clipViewport=$;if($){let V=this._screenSize();this._display.viewportChangeSize(V.w,V.h),this._fixScrollbars(),this._setClippingViewport(V.w{p("Disconnection timed out."),this._updateConnectionState("disconnected")},F4*1000);break;case"disconnected":this.dispatchEvent(new CustomEvent("disconnect",{detail:{clean:this._rfbCleanDisconnect}}));break}}_fail(Q){switch(this._rfbConnectionState){case"disconnecting":p("Failed when disconnecting: "+Q);break;case"connected":p("Failed while connected: "+Q);break;case"connecting":p("Failed when connecting: "+Q);break;default:p("RFB failure: "+Q);break}return this._rfbCleanDisconnect=!1,this._updateConnectionState("disconnecting"),this._updateConnectionState("disconnected"),!1}_setCapability(Q,$){this._capabilities[Q]=$,this.dispatchEvent(new CustomEvent("capabilities",{detail:{capabilities:this._capabilities}}))}_handleMessage(){if(this._sock.rQwait("message",1)){l("handleMessage called on an empty receive queue");return}switch(this._rfbConnectionState){case"disconnected":p("Got data while disconnected");break;case"connected":while(!0){if(this._flushing)break;if(!this._normalMsg())break;if(this._sock.rQwait("message",1))break}break;case"connecting":while(this._rfbConnectionState==="connecting")if(!this._initMsg())break;break;default:p("Got data while in an invalid state");break}}_handleKeyEvent(Q,$,V,J,W){if($=="CapsLock"&&V)this._remoteCapsLock=null;if(this._remoteCapsLock!==null&&W!==null&&this._remoteCapsLock!==W&&V)w("Fixing remote caps lock"),this.sendKey(z.XK_Caps_Lock,"CapsLock",!0),this.sendKey(z.XK_Caps_Lock,"CapsLock",!1),this._remoteCapsLock=null;if($=="NumLock"&&V)this._remoteNumLock=null;if(this._remoteNumLock!==null&&J!==null&&this._remoteNumLock!==J&&V)w("Fixing remote num lock"),this.sendKey(z.XK_Num_Lock,"NumLock",!0),this.sendKey(z.XK_Num_Lock,"NumLock",!1),this._remoteNumLock=null;this.sendKey(Q,$,V)}static _convertButtonMask(Q){let $={0:1,1:4,2:2,3:128,4:256},V=0;for(let J=0;J<5;J++)if(Q&1<V0||Math.abs(G)>V0))this._viewportHasMoved=!0,this._viewportDragPos={x:$.x,y:$.y},this._display.viewportChangePos(W,G);break}this._handleMouseMove($.x,$.y);break}}_handleMouseButton(Q,$,V){this._flushMouseMoveTimer(Q,$),this._mouseButtonMask=V,this._sendMouse(Q,$,this._mouseButtonMask)}_handleMouseMove(Q,$){if(this._mousePos={x:Q,y:$},this._mouseMoveTimer==null){let V=Date.now()-this._mouseLastMoveTime;if(V>x8)this._sendMouse(Q,$,this._mouseButtonMask),this._mouseLastMoveTime=Date.now();else this._mouseMoveTimer=setTimeout(()=>{this._handleDelayedMouseMove()},x8-V)}}_handleDelayedMouseMove(){this._mouseMoveTimer=null,this._sendMouse(this._mousePos.x,this._mousePos.y,this._mouseButtonMask),this._mouseLastMoveTime=Date.now()}_sendMouse(Q,$,V){if(this._rfbConnectionState!=="connected")return;if(this._viewOnly)return;if(V&32768)throw Error("Illegal mouse button mask (mask: "+V+")");let J=V&32640;if(this._extendedPointerEventSupported&&J)u.messages.extendedPointerEvent(this._sock,this._display.absX(Q),this._display.absY($),V);else u.messages.pointerEvent(this._sock,this._display.absX(Q),this._display.absY($),V)}_handleWheel(Q){if(this._rfbConnectionState!=="connected")return;if(this._viewOnly)return;Q.stopPropagation(),Q.preventDefault();let $=y1(Q.clientX,Q.clientY,this._canvas),V=u._convertButtonMask(Q.buttons),J=Q.deltaX,W=Q.deltaY;if(Q.deltaMode!==0)J*=u8,W*=u8;if(this._accumulatedWheelDeltaX+=J,this._accumulatedWheelDeltaY+=W,Math.abs(this._accumulatedWheelDeltaX)>=f8){if(this._accumulatedWheelDeltaX<0)this._handleMouseButton($.x,$.y,V|32),this._handleMouseButton($.x,$.y,V);else if(this._accumulatedWheelDeltaX>0)this._handleMouseButton($.x,$.y,V|64),this._handleMouseButton($.x,$.y,V);this._accumulatedWheelDeltaX=0}if(Math.abs(this._accumulatedWheelDeltaY)>=f8){if(this._accumulatedWheelDeltaY<0)this._handleMouseButton($.x,$.y,V|8),this._handleMouseButton($.x,$.y,V);else if(this._accumulatedWheelDeltaY>0)this._handleMouseButton($.x,$.y,V|16),this._handleMouseButton($.x,$.y,V);this._accumulatedWheelDeltaY=0}}_fakeMouseMove(Q,$,V){this._handleMouseMove($,V),this._cursor.move(Q.detail.clientX,Q.detail.clientY)}_handleTapEvent(Q,$){let V=y1(Q.detail.clientX,Q.detail.clientY,this._canvas);if(this._gestureLastTapTime!==null&&Date.now()-this._gestureLastTapTimeV0||Math.abs(W)>V0))this._viewportHasMoved=!0,this._viewportDragPos={x:V.x,y:V.y},this._display.viewportChangePos(J,W)}else this._fakeMouseMove(Q,V.x,V.y);break;case"twodrag":this._fakeMouseMove(Q,V.x,V.y);while(Q.detail.magnitudeY-this._gestureLastMagnitudeY>A1)this._handleMouseButton(V.x,V.y,8),this._handleMouseButton(V.x,V.y,0),this._gestureLastMagnitudeY+=A1;while(Q.detail.magnitudeY-this._gestureLastMagnitudeY<-A1)this._handleMouseButton(V.x,V.y,16),this._handleMouseButton(V.x,V.y,0),this._gestureLastMagnitudeY-=A1;while(Q.detail.magnitudeX-this._gestureLastMagnitudeX>A1)this._handleMouseButton(V.x,V.y,32),this._handleMouseButton(V.x,V.y,0),this._gestureLastMagnitudeX+=A1;while(Q.detail.magnitudeX-this._gestureLastMagnitudeX<-A1)this._handleMouseButton(V.x,V.y,64),this._handleMouseButton(V.x,V.y,0),this._gestureLastMagnitudeX-=A1;break;case"pinch":if(this._fakeMouseMove(Q,V.x,V.y),$=Math.hypot(Q.detail.magnitudeX,Q.detail.magnitudeY),Math.abs($-this._gestureLastMagnitudeX)>F0){this._handleKeyEvent(z.XK_Control_L,"ControlLeft",!0);while($-this._gestureLastMagnitudeX>F0)this._handleMouseButton(V.x,V.y,8),this._handleMouseButton(V.x,V.y,0),this._gestureLastMagnitudeX+=F0;while($-this._gestureLastMagnitudeX<-F0)this._handleMouseButton(V.x,V.y,16),this._handleMouseButton(V.x,V.y,0),this._gestureLastMagnitudeX-=F0}this._handleKeyEvent(z.XK_Control_L,"ControlLeft",!1);break}break;case"gestureend":switch(Q.detail.type){case"onetap":case"twotap":case"threetap":case"pinch":case"twodrag":break;case"drag":if(this.dragViewport)this._viewportDragging=!1;else this._fakeMouseMove(Q,V.x,V.y),this._handleMouseButton(V.x,V.y,0);break;case"longpress":if(this._viewportHasMoved)break;if(this.dragViewport&&!this._viewportHasMoved)this._fakeMouseMove(Q,V.x,V.y),this._handleMouseButton(V.x,V.y,4),this._handleMouseButton(V.x,V.y,0),this._viewportDragging=!1;else this._fakeMouseMove(Q,V.x,V.y),this._handleMouseButton(V.x,V.y,0);break}break}}_flushMouseMoveTimer(Q,$){if(this._mouseMoveTimer!==null)clearTimeout(this._mouseMoveTimer),this._mouseMoveTimer=null,this._sendMouse(Q,$,this._mouseButtonMask)}_negotiateProtocolVersion(){if(this._sock.rQwait("version",12))return!1;let Q=this._sock.rQshiftStr(12).substr(4,7);r("Server ProtocolVersion: "+Q);let $=0;switch(Q){case"000.000":$=1;break;case"003.003":case"003.006":this._rfbVersion=3.3;break;case"003.007":this._rfbVersion=3.7;break;case"003.008":case"003.889":case"004.000":case"004.001":case"005.000":this._rfbVersion=3.8;break;default:return this._fail("Invalid server version "+Q)}if($){let J="ID:"+this._repeaterID;while(J.length<250)J+="\x00";return this._sock.sQpushString(J),this._sock.flush(),!0}if(this._rfbVersion>this._rfbMaxVersion)this._rfbVersion=this._rfbMaxVersion;let V="00"+parseInt(this._rfbVersion,10)+".00"+this._rfbVersion*10%10;this._sock.sQpushString("RFB "+V+` +`),this._sock.flush(),w("Sent ProtocolVersion: "+V),this._rfbInitState="Security"}_isSupportedSecurityType(Q){return[_8,G6,y8,h8,n6,p8,m8,b8,n8].includes(Q)}_negotiateSecurity(){if(this._rfbVersion>=3.7){let Q=this._sock.rQshift8();if(this._sock.rQwait("security type",Q,1))return!1;if(Q===0)return this._rfbInitState="SecurityReason",this._securityContext="no security types",this._securityStatus=1,!0;let $=this._sock.rQshiftBytes(Q);w("Server security types: "+$),this._rfbAuthScheme=-1;for(let V of $)if(this._isSupportedSecurityType(V)){this._rfbAuthScheme=V;break}if(this._rfbAuthScheme===-1)return this._fail("Unsupported security types (types: "+$+")");this._sock.sQpush8(this._rfbAuthScheme),this._sock.flush()}else{if(this._sock.rQwait("security scheme",4))return!1;if(this._rfbAuthScheme=this._sock.rQshift32(),this._rfbAuthScheme==0)return this._rfbInitState="SecurityReason",this._securityContext="authentication scheme",this._securityStatus=1,!0}return this._rfbInitState="Authentication",w("Authenticating using scheme: "+this._rfbAuthScheme),!0}_handleSecurityReason(){if(this._sock.rQwait("reason length",4))return!1;let Q=this._sock.rQshift32(),$="";if(Q>0){if(this._sock.rQwait("reason",Q,4))return!1;$=this._sock.rQshiftStr(Q)}if($!=="")return this.dispatchEvent(new CustomEvent("securityfailure",{detail:{status:this._securityStatus,reason:$}})),this._fail("Security negotiation failed on "+this._securityContext+" (reason: "+$+")");else return this.dispatchEvent(new CustomEvent("securityfailure",{detail:{status:this._securityStatus}})),this._fail("Security negotiation failed on "+this._securityContext)}_negotiateXvpAuth(){if(this._rfbCredentials.username===void 0||this._rfbCredentials.password===void 0||this._rfbCredentials.target===void 0)return this.dispatchEvent(new CustomEvent("credentialsrequired",{detail:{types:["username","password","target"]}})),!1;return this._sock.sQpush8(this._rfbCredentials.username.length),this._sock.sQpush8(this._rfbCredentials.target.length),this._sock.sQpushString(this._rfbCredentials.username),this._sock.sQpushString(this._rfbCredentials.target),this._sock.flush(),this._rfbAuthScheme=G6,this._negotiateAuthentication()}_negotiateVeNCryptAuth(){if(this._rfbVeNCryptState==0){if(this._sock.rQwait("vencrypt version",2))return!1;let Q=this._sock.rQshift8(),$=this._sock.rQshift8();if(!(Q==0&&$==2))return this._fail("Unsupported VeNCrypt version "+Q+"."+$);this._sock.sQpush8(0),this._sock.sQpush8(2),this._sock.flush(),this._rfbVeNCryptState=1}if(this._rfbVeNCryptState==1){if(this._sock.rQwait("vencrypt ack",1))return!1;let Q=this._sock.rQshift8();if(Q!=0)return this._fail("VeNCrypt failure "+Q);this._rfbVeNCryptState=2}if(this._rfbVeNCryptState==2){if(this._sock.rQwait("vencrypt subtypes length",1))return!1;let Q=this._sock.rQshift8();if(Q<1)return this._fail("VeNCrypt subtypes empty");this._rfbVeNCryptSubtypesLength=Q,this._rfbVeNCryptState=3}if(this._rfbVeNCryptState==3){if(this._sock.rQwait("vencrypt subtypes",4*this._rfbVeNCryptSubtypesLength))return!1;let Q=[];for(let $=0;$0&&this._sock.rQwait("tunnel capabilities",16*J,4))return!1;if(this._rfbTightVNC=!0,J>0)return this._negotiateTightTunnels(J),!1}if(this._sock.rQwait("sub auth count",4))return!1;let Q=this._sock.rQshift32();if(Q===0)return this._rfbInitState="SecurityResult",!0;if(this._sock.rQwait("sub auth capabilities",16*Q,4))return!1;let $={STDVNOAUTH__:1,STDVVNCAUTH_:2,TGHTULGNAUTH:129},V=[];for(let J=0;Jthis._rfbCredentials),this._rfbRSAAESAuthenticationState.addEventListener("serververification",this._eventHandlers.handleRSAAESServerVerification),this._rfbRSAAESAuthenticationState.addEventListener("credentialsrequired",this._eventHandlers.handleRSAAESCredentialsRequired);if(this._rfbRSAAESAuthenticationState.checkInternalEvents(),!this._rfbRSAAESAuthenticationState.hasStarted)this._rfbRSAAESAuthenticationState.negotiateRA2neAuthAsync().catch((Q)=>{if(Q.message!=="disconnect normally")this._fail(Q.message)}).then(()=>{return this._rfbInitState="SecurityResult",!0}).finally(()=>{this._rfbRSAAESAuthenticationState.removeEventListener("serververification",this._eventHandlers.handleRSAAESServerVerification),this._rfbRSAAESAuthenticationState.removeEventListener("credentialsrequired",this._eventHandlers.handleRSAAESCredentialsRequired),this._rfbRSAAESAuthenticationState=null});return!1}_negotiateMSLogonIIAuth(){if(this._sock.rQwait("mslogonii dh param",24))return!1;if(this._rfbCredentials.username===void 0||this._rfbCredentials.password===void 0)return this.dispatchEvent(new CustomEvent("credentialsrequired",{detail:{types:["username","password"]}})),!1;let Q=this._sock.rQshiftBytes(8),$=this._sock.rQshiftBytes(8),V=this._sock.rQshiftBytes(8),J=n.generateKey({name:"DH",g:Q,p:$},!0,["deriveBits"]),W=n.exportKey("raw",J.publicKey),G=n.deriveBits({name:"DH",public:V},J.privateKey,64),q=n.importKey("raw",G,{name:"DES-CBC"},!1,["encrypt"]),U=q1(this._rfbCredentials.username).substring(0,255),Z=q1(this._rfbCredentials.password).substring(0,63),Y=new Uint8Array(256),X=new Uint8Array(64);window.crypto.getRandomValues(Y),window.crypto.getRandomValues(X);for(let I=0;I=3.8)this._rfbInitState="SecurityResult";else this._rfbInitState="ClientInitialisation";return!0;case p8:return this._negotiateXvpAuth();case m8:return this._negotiateARDAuth();case G6:return this._negotiateStdVNCAuth();case h8:return this._negotiateTightAuth();case n6:return this._negotiateVeNCryptAuth();case n8:return this._negotiatePlainAuth();case c8:return this._negotiateTightUnixAuth();case y8:return this._negotiateRA2neAuth();case b8:return this._negotiateMSLogonIIAuth();default:return this._fail("Unsupported auth scheme (scheme: "+this._rfbAuthScheme+")")}}_handleSecurityResult(){if(this._sock.rQwait("VNC auth response ",4))return!1;let Q=this._sock.rQshift32();if(Q===0)return this._rfbInitState="ClientInitialisation",w("Authentication OK"),!0;else if(this._rfbVersion>=3.8)return this._rfbInitState="SecurityReason",this._securityContext="security result",this._securityStatus=Q,!0;else return this.dispatchEvent(new CustomEvent("securityfailure",{detail:{status:Q}})),this._fail("Security handshake failed")}_negotiateServerInit(){if(this._sock.rQwait("server initialization",24))return!1;let Q=this._sock.rQshift16(),$=this._sock.rQshift16(),V=this._sock.rQshift8(),J=this._sock.rQshift8(),W=this._sock.rQshift8(),G=this._sock.rQshift8(),q=this._sock.rQshift16(),U=this._sock.rQshift16(),Z=this._sock.rQshift16(),Y=this._sock.rQshift8(),X=this._sock.rQshift8(),I=this._sock.rQshift8();this._sock.rQskipBytes(3);let j=this._sock.rQshift32();if(this._sock.rQwait("server init name",j,24))return!1;let P=this._sock.rQshiftStr(j);if(P=B0(P,!0),this._rfbTightVNC){if(this._sock.rQwait("TightVNC extended server init header",8,24+j))return!1;let O=this._sock.rQshift16(),k=this._sock.rQshift16(),E=this._sock.rQshift16();this._sock.rQskipBytes(2);let D=(O+k+E)*16;if(this._sock.rQwait("TightVNC extended server init header",D,32+j))return!1;this._sock.rQskipBytes(16*O),this._sock.rQskipBytes(16*k),this._sock.rQskipBytes(16*E)}if(r("Screen: "+Q+"x"+$+", bpp: "+V+", depth: "+J+", bigEndian: "+W+", trueColor: "+G+", redMax: "+q+", greenMax: "+U+", blueMax: "+Z+", redShift: "+Y+", greenShift: "+X+", blueShift: "+I),this._setDesktopName(P),this._resize(Q,$),!this._viewOnly)this._keyboard.grab();if(this._fbDepth=24,this._fbName==="Intel(r) AMT KVM")l("Intel AMT KVM only supports 8/16 bit depths. Using low color mode."),this._fbDepth=8;return u.messages.pixelFormat(this._sock,this._fbDepth,!0),this._sendEncodings(),u.messages.fbUpdateRequest(this._sock,!1,0,0,this._fbWidth,this._fbHeight),this._updateConnectionState("connected"),!0}_sendEncodings(){let Q=[];if(Q.push(T.encodingCopyRect),this._fbDepth==24){if(X6)Q.push(T.encodingH264);Q.push(T.encodingTight),Q.push(T.encodingTightPNG),Q.push(T.encodingZRLE),Q.push(T.encodingJPEG),Q.push(T.encodingHextile),Q.push(T.encodingRRE),Q.push(T.encodingZlib)}if(Q.push(T.encodingRaw),Q.push(T.pseudoEncodingQualityLevel0+this._qualityLevel),Q.push(T.pseudoEncodingCompressLevel0+this._compressionLevel),Q.push(T.pseudoEncodingDesktopSize),Q.push(T.pseudoEncodingLastRect),Q.push(T.pseudoEncodingQEMUExtendedKeyEvent),Q.push(T.pseudoEncodingQEMULedEvent),Q.push(T.pseudoEncodingExtendedDesktopSize),Q.push(T.pseudoEncodingXvp),Q.push(T.pseudoEncodingFence),Q.push(T.pseudoEncodingContinuousUpdates),Q.push(T.pseudoEncodingDesktopName),Q.push(T.pseudoEncodingExtendedClipboard),Q.push(T.pseudoEncodingExtendedMouseButtons),this._fbDepth==24)Q.push(T.pseudoEncodingVMwareCursor),Q.push(T.pseudoEncodingCursor);u.messages.clientEncodings(this._sock,Q)}_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.sQpush8(this._shared?1:0),this._sock.flush(),this._rfbInitState="ServerInitialisation",!0;case"ServerInitialisation":return this._negotiateServerInit();default:return this._fail("Unknown init state (state: "+this._rfbInitState+")")}}_resumeAuthentication(){setTimeout(this._initMsg.bind(this),0)}_handleSetColourMapMsg(){return w("SetColorMapEntries"),this._fail("Unexpected SetColorMapEntries message")}_handleServerCutText(){if(w("ServerCutText"),this._sock.rQwait("ServerCutText header",7,1))return!1;this._sock.rQskipBytes(3);let Q=this._sock.rQshift32();if(Q=Q0(Q),this._sock.rQwait("ServerCutText content",Math.abs(Q),8))return!1;if(Q>=0){let $=this._sock.rQshiftStr(Q);if(this._viewOnly)return!0;this.dispatchEvent(new CustomEvent("clipboard",{detail:{text:$}}))}else{Q=Math.abs(Q);let $=this._sock.rQshift32(),V=$&65535,J=$&4278190080;if(!!(J&i8)){this._clipboardServerCapabilitiesFormats={},this._clipboardServerCapabilitiesActions={};for(let q=0;q<=15;q++){let U=1<0&&U.charAt(U.length-1)==="\x00")U=U.slice(0,-1);U=U.replaceAll(`\r +`,` +`),this.dispatchEvent(new CustomEvent("clipboard",{detail:{text:U}}))}}else return this._fail("Unexpected action in extended clipboard message: "+J)}return!0}_handleServerFenceMsg(){if(this._sock.rQwait("ServerFence header",8,1))return!1;this._sock.rQskipBytes(3);let Q=this._sock.rQshift32(),$=this._sock.rQshift8();if(this._sock.rQwait("ServerFence payload",$,9))return!1;if($>64)l("Bad payload length ("+$+") in fence response"),$=64;let V=this._sock.rQshiftStr($);if(this._supportsFence=!0,!(Q&-2147483648))return this._fail("Unexpected fence response");return Q&=3,u.messages.clientFence(this._sock,Q,V),!0}_handleXvpMsg(){if(this._sock.rQwait("XVP version and message",3,1))return!1;this._sock.rQskipBytes(1);let Q=this._sock.rQshift8(),$=this._sock.rQshift8();switch($){case 0:p("XVP operation failed");break;case 1:this._rfbXvpVer=Q,r("XVP extensions enabled (version "+this._rfbXvpVer+")"),this._setCapability("power",!0);break;default:this._fail("Illegal server XVP message (msg: "+$+")");break}return!0}_normalMsg(){let Q;if(this._FBU.rects>0)Q=0;else Q=this._sock.rQshift8();let $,V;switch(Q){case 0:if(V=this._framebufferUpdate(),V&&!this._enabledContinuousUpdates)u.messages.fbUpdateRequest(this._sock,!0,0,0,this._fbWidth,this._fbHeight);return V;case 1:return this._handleSetColourMapMsg();case 2:return w("Bell"),this.dispatchEvent(new CustomEvent("bell",{detail:{}})),!0;case 3:return this._handleServerCutText();case 150:if($=!this._supportsContinuousUpdates,this._supportsContinuousUpdates=!0,this._enabledContinuousUpdates=!1,$)this._enabledContinuousUpdates=!0,this._updateContinuousUpdates(),r("Enabling continuous updates.");return!0;case 248:return this._handleServerFenceMsg();case 250:return this._handleXvpMsg();default:return this._fail("Unexpected server message (type "+Q+")"),w("sock.rQpeekBytes(30): "+this._sock.rQpeekBytes(30)),!0}}_framebufferUpdate(){if(this._FBU.rects===0){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().then(()=>{if(this._flushing=!1,!this._sock.rQwait("message",1))this._handleMessage()}),!1}while(this._FBU.rects>0){if(this._FBU.encoding===null){if(this._sock.rQwait("rect header",12))return!1;this._FBU.x=this._sock.rQshift16(),this._FBU.y=this._sock.rQshift16(),this._FBU.width=this._sock.rQshift16(),this._FBU.height=this._sock.rQshift16(),this._FBU.encoding=this._sock.rQshift32(),this._FBU.encoding>>=0}if(!this._handleRect())return!1;this._FBU.rects--,this._FBU.encoding=null}return this._display.flip(),!0}_handleRect(){switch(this._FBU.encoding){case T.pseudoEncodingLastRect:return this._FBU.rects=1,!0;case T.pseudoEncodingVMwareCursor:return this._handleVMwareCursor();case T.pseudoEncodingCursor:return this._handleCursor();case T.pseudoEncodingQEMUExtendedKeyEvent:return this._qemuExtKeyEventSupported=!0,!0;case T.pseudoEncodingDesktopName:return this._handleDesktopName();case T.pseudoEncodingDesktopSize:return this._resize(this._FBU.width,this._FBU.height),!0;case T.pseudoEncodingExtendedDesktopSize:return this._handleExtendedDesktopSize();case T.pseudoEncodingExtendedMouseButtons:return this._extendedPointerEventSupported=!0,!0;case T.pseudoEncodingQEMULedEvent:return this._handleLedEvent();default:return this._handleDataRect()}}_handleVMwareCursor(){let Q=this._FBU.x,$=this._FBU.y,V=this._FBU.width,J=this._FBU.height;if(this._sock.rQwait("VMware cursor encoding",1))return!1;let W=this._sock.rQshift8();this._sock.rQshift8();let G,q=4;if(W==0){if(G=Array(V*J*q),this._sock.rQwait("VMware cursor classic encoding",V*J*q*2,2))return!1;let Z=Array(V*J);for(let X=0;X>8&255,P=I>>16&255,O=I>>24&255;G[X*q]=j,G[X*q+1]=P,G[X*q+2]=O,G[X*q+3]=255}else if((Z[X]&-256)==-256)if(Y[X]==0)G[X*q]=0,G[X*q+1]=0,G[X*q+2]=0,G[X*q+3]=0;else if((Y[X]&-256)==-256)G[X*q]=0,G[X*q+1]=0,G[X*q+2]=0,G[X*q+3]=255;else G[X*q]=0,G[X*q+1]=0,G[X*q+2]=0,G[X*q+3]=255;else G[X*q]=0,G[X*q+1]=0,G[X*q+2]=0,G[X*q+3]=255}else if(W==1){if(this._sock.rQwait("VMware cursor alpha encoding",V*J*4,2))return!1;G=Array(V*J*q);for(let U=0;U>24&255,G[U*4+1]=Z>>16&255,G[U*4+2]=Z>>8&255,G[U*4+3]=Z&255}}else return l("The given cursor type is not supported: "+W+" given."),!1;return this._updateCursor(G,Q,$,V,J),!0}_handleCursor(){let Q=this._FBU.x,$=this._FBU.y,V=this._FBU.width,J=this._FBU.height,W=V*J*4,G=Math.ceil(V/8)*J,q=W+G;if(this._sock.rQwait("cursor encoding",q))return!1;let U=this._sock.rQshiftBytes(W),Z=this._sock.rQshiftBytes(G),Y=new Uint8Array(V*J*4),X=0;for(let I=0;IW.charCodeAt(0)),J=n.importKey("raw",V,{name:"DES-ECB"},!1,["encrypt"]);return n.encrypt({name:"DES-ECB"},J,$)}}u.messages={keyEvent(Q,$,V){Q.sQpush8(4),Q.sQpush8(V),Q.sQpush16(0),Q.sQpush32($),Q.flush()},QEMUExtendedKeyEvent(Q,$,V,J){function W(q){let U=J>>8,Z=J&255;if(U===224&&Z<127)return Z|128;return q}Q.sQpush8(255),Q.sQpush8(0),Q.sQpush16(V),Q.sQpush32($);let G=W(J);Q.sQpush32(G),Q.flush()},pointerEvent(Q,$,V,J){Q.sQpush8(5),J=J&127,Q.sQpush8(J),Q.sQpush16($),Q.sQpush16(V),Q.flush()},extendedPointerEvent(Q,$,V,J){Q.sQpush8(5);let W=J>>7&255;if(W&252)throw Error("Invalid mouse button mask: "+J);let G=J&127;G|=128,Q.sQpush8(G),Q.sQpush16($),Q.sQpush16(V),Q.sQpush8(W),Q.flush()},_buildExtendedClipboardFlags(Q,$){let V=new Uint8Array(4),J=0,W=0;for(let G=0;G>24,V[1]=0,V[2]=0,V[3]=J,V},extendedClipboardProvide(Q,$,V){let J=new k0,W=[];for(let U=0;U<$.length;U++){if($[U]!=z1)throw Error("Unsupported extended clipboard format for Provide message.");V[U]=V[U].replace(/\r\n|\r|\n/gm,`\r +`);let Z=q1(V[U]+"\x00");W.push(Z.length>>24&255,Z.length>>16&255,Z.length>>8&255,Z.length&255);for(let Y=0;YparseInt(q)),J.sort((q,U)=>q-U),W.set(u.messages._buildExtendedClipboardFlags($,[]));let G=4;for(let q=0;q>24,W[G+1]=V[J[q]]>>16,W[G+2]=V[J[q]]>>8,W[G+3]=V[J[q]]>>0,G+=4,W[3]|=1<16)J=32;else if($>8)J=16;else J=8;let W=Math.floor($/3);Q.sQpush8(0),Q.sQpush8(0),Q.sQpush8(0),Q.sQpush8(0),Q.sQpush8(J),Q.sQpush8($),Q.sQpush8(0),Q.sQpush8(V?1:0),Q.sQpush16((1<"u")V=0;if(typeof J>"u")J=0;Q.sQpush8(3),Q.sQpush8($?1:0),Q.sQpush16(V),Q.sQpush16(J),Q.sQpush16(W),Q.sQpush16(G),Q.flush()},xvpOp(Q,$,V){Q.sQpush8(250),Q.sQpush8(0),Q.sQpush8($),Q.sQpush8(V),Q.flush()}};u.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}};export{u as default}; diff --git a/src/workspaces/officerdev/src/apps/Desktop/DesktopView.tsx b/src/workspaces/officerdev/src/apps/Desktop/DesktopView.tsx index 625030f7..202eaacc 100644 --- a/src/workspaces/officerdev/src/apps/Desktop/DesktopView.tsx +++ b/src/workspaces/officerdev/src/apps/Desktop/DesktopView.tsx @@ -8,7 +8,15 @@ export type DesktopViewProps = { style?: CSSProperties; }; -const NOVNC_URL = '/novnc/rfb.js'; +// The BUNDLE, not public/novnc/rfb.js. That entry is unbundled noVNC source: 42 ES modules whose +// imports nest six levels deep, so a native dynamic import made the browser walk the graph — fetch, +// parse, discover the next level, fetch again. Six sequential round trips and 42 requests before the +// desktop could even begin connecting, which over the tailnet is seconds, and a hard refresh pays it +// every time. One file is one round trip. +// +// Regenerate after updating vendored noVNC: +// bun build public/novnc/rfb.js --outfile=public/novnc/rfb.bundle.js --format=esm --minify --target=browser +const NOVNC_URL = '/novnc/rfb.bundle.js'; const buildWsUrl = () => { const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';