@glokon/guacamole-common-js
Version:
Guacamole common js with typescript type definitions
1 lines • 79.5 kB
JavaScript
var Guacamole;(Guacamole=Guacamole||{}).ArrayBufferReader=function(e){var t=this;e.onblob=function(e){for(var n=window.atob(e),a=new ArrayBuffer(n.length),o=new Uint8Array(a),i=0;i<n.length;i++)o[i]=n.charCodeAt(i);t.ondata&&t.ondata(a)},e.onend=function(){t.onend&&t.onend()},this.ondata=null,this.onend=null},(Guacamole=Guacamole||{}).ArrayBufferWriter=function(e){var t=this;function n(t){for(var n="",a=0;a<t.byteLength;a++)n+=String.fromCharCode(t[a]);e.sendBlob(window.btoa(n))}e.onack=function(e){t.onack&&t.onack(e)},this.blobLength=Guacamole.ArrayBufferWriter.DEFAULT_BLOB_LENGTH,this.sendData=function(e){var a=new Uint8Array(e);if(a.length<=t.blobLength)n(a);else for(var o=0;o<a.length;o+=t.blobLength)n(a.subarray(o,o+t.blobLength))},this.sendEnd=function(){e.sendEnd()},this.onack=null},Guacamole.ArrayBufferWriter.DEFAULT_BLOB_LENGTH=6048,(Guacamole=Guacamole||{}).AudioContextFactory={singleton:null,getAudioContext:function(){var e=window.AudioContext||window.webkitAudioContext;if(e)try{return Guacamole.AudioContextFactory.singleton||(Guacamole.AudioContextFactory.singleton=new e),Guacamole.AudioContextFactory.singleton}catch(e){}return null}},(Guacamole=Guacamole||{}).AudioPlayer=function(){this.sync=function(){}},Guacamole.AudioPlayer.isSupportedType=function(e){return Guacamole.RawAudioPlayer.isSupportedType(e)},Guacamole.AudioPlayer.getSupportedTypes=function(){return Guacamole.RawAudioPlayer.getSupportedTypes()},Guacamole.AudioPlayer.getInstance=function(e,t){return Guacamole.RawAudioPlayer.isSupportedType(t)?new Guacamole.RawAudioPlayer(e,t):null},Guacamole.RawAudioPlayer=function(e,t){var n=Guacamole.RawAudioFormat.parse(t),a=Guacamole.AudioContextFactory.getAudioContext(),o=a.currentTime,i=new Guacamole.ArrayBufferReader(e),r=1===n.bytesPerSample?window.Int8Array:window.Int16Array,s=1===n.bytesPerSample?128:32768,u=[],l=function(){var e=function(e){if(e.length<=1)return e[0];var t=0;e.forEach((function(e){t+=e.length}));var n=0,a=new r(t);return e.forEach((function(e){a.set(e,n),n+=e.length})),a}(u);return e?(u=function(e){for(var t=Number.MAX_VALUE,a=e.length,o=Math.floor(e.length/n.channels),i=Math.floor(.02*n.rate),s=Math.max(n.channels*i,n.channels*(o-i));s<e.length;s+=n.channels){for(var u=0,l=0;l<n.channels;l++)u+=Math.abs(e[s+l]);u<=t&&(a=s+n.channels,t=u)}return a===e.length?[e]:[new r(e.buffer.slice(0,a*n.bytesPerSample)),new r(e.buffer.slice(a*n.bytesPerSample))]}(e),e=u.shift()):null};i.ondata=function(e){!function(e){u.push(new r(e))}(new r(e));var t=l();if(t){var i=a.currentTime;o<i&&(o=i);var c=a.createBufferSource();c.connect(a.destination),c.start||(c.start=c.noteOn),c.buffer=function(e){var t=e.length/n.channels,i=a.currentTime;o<i&&(o=i);for(var r=a.createBuffer(n.channels,t,n.rate),u=0;u<n.channels;u++)for(var l=r.getChannelData(u),c=u,h=0;h<t;h++)l[h]=e[c]/s,c+=n.channels;return r}(t),c.start(o),o+=t.length/n.channels/n.rate}},this.sync=function(){var e=a.currentTime;o=Math.min(o,e+.3)}},Guacamole.RawAudioPlayer.prototype=new Guacamole.AudioPlayer,Guacamole.RawAudioPlayer.isSupportedType=function(e){return!!Guacamole.AudioContextFactory.getAudioContext()&&null!==Guacamole.RawAudioFormat.parse(e)},Guacamole.RawAudioPlayer.getSupportedTypes=function(){return Guacamole.AudioContextFactory.getAudioContext()?["audio/L8","audio/L16"]:[]},(Guacamole=Guacamole||{}).AudioRecorder=function(){this.onclose=null,this.onerror=null},Guacamole.AudioRecorder.isSupportedType=function(e){return Guacamole.RawAudioRecorder.isSupportedType(e)},Guacamole.AudioRecorder.getSupportedTypes=function(){return Guacamole.RawAudioRecorder.getSupportedTypes()},Guacamole.AudioRecorder.getInstance=function(e,t){return Guacamole.RawAudioRecorder.isSupportedType(t)?new Guacamole.RawAudioRecorder(e,t):null},Guacamole.RawAudioRecorder=function(e,t){var n=this,a=Guacamole.RawAudioFormat.parse(t),o=Guacamole.AudioContextFactory.getAudioContext();navigator.mediaDevices||(navigator.mediaDevices={}),navigator.mediaDevices.getUserMedia||(navigator.mediaDevices.getUserMedia=(navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia).bind(navigator));var i=new Guacamole.ArrayBufferWriter(e),r=1===a.bytesPerSample?window.Int8Array:window.Int16Array,s=1===a.bytesPerSample?128:32768,u=0,l=0,c=null,h=null,d=null,f=function(e){if(0===e)return 1;var t=Math.PI*e;return Math.sin(t)/t},m=function(e,t){for(var n,a,o=(e.length-1)*t,i=Math.floor(o)-3+1,r=Math.floor(o)+3,s=0,u=i;u<=r;u++)s+=(e[u]||0)*(-(a=3)<(n=o-u)&&n<a?f(n)*f(n/a):0);return s},p=function(e){(d=o.createScriptProcessor(2048,a.channels,a.channels)).connect(o.destination),d.onaudioprocess=function(e){i.sendData(function(e){var t=e.length;u+=t;var n=Math.round(u*a.rate/e.sampleRate)-l;l+=n;for(var o=new r(n*a.channels),i=0;i<a.channels;i++)for(var c=e.getChannelData(i),h=i,d=0;d<n;d++)o[h]=m(c,d/(n-1))*s,h+=a.channels;return o}(e.inputBuffer).buffer)},(h=o.createMediaStreamSource(e)).connect(d),"suspended"===o.state&&o.resume(),c=e},y=function(){i.sendEnd(),n.onerror&&n.onerror()};i.onack=function(e){var t;e.code!==Guacamole.Status.Code.SUCCESS||c?(!function(){if(h&&h.disconnect(),d&&d.disconnect(),c)for(var e=c.getTracks(),t=0;t<e.length;t++)e[t].stop();d=null,h=null,c=null,i.sendEnd()}(),i.onack=null,e.code===Guacamole.Status.Code.RESOURCE_CLOSED?n.onclose&&n.onclose():n.onerror&&n.onerror()):(t=navigator.mediaDevices.getUserMedia({audio:!0},p,y))&&t.then&&t.then(p,y)}},Guacamole.RawAudioRecorder.prototype=new Guacamole.AudioRecorder,Guacamole.RawAudioRecorder.isSupportedType=function(e){return!!Guacamole.AudioContextFactory.getAudioContext()&&null!==Guacamole.RawAudioFormat.parse(e)},Guacamole.RawAudioRecorder.getSupportedTypes=function(){return Guacamole.AudioContextFactory.getAudioContext()?["audio/L8","audio/L16"]:[]},(Guacamole=Guacamole||{}).BlobReader=function(e,t){var n,a=this,o=0;n=window.BlobBuilder?new BlobBuilder:window.WebKitBlobBuilder?new WebKitBlobBuilder:window.MozBlobBuilder?new MozBlobBuilder:new function(){var e=[];this.append=function(n){e.push(new Blob([n],{type:t}))},this.getBlob=function(){return new Blob(e,{type:t})}},e.onblob=function(t){for(var i=window.atob(t),r=new ArrayBuffer(i.length),s=new Uint8Array(r),u=0;u<i.length;u++)s[u]=i.charCodeAt(u);n.append(r),o+=r.byteLength,a.onprogress&&a.onprogress(r.byteLength),e.sendAck("OK",0)},e.onend=function(){a.onend&&a.onend()},this.getLength=function(){return o},this.getBlob=function(){return n.getBlob()},this.onprogress=null,this.onend=null},(Guacamole=Guacamole||{}).BlobWriter=function(e){var t=this,n=new Guacamole.ArrayBufferWriter(e);n.onack=function(e){t.onack&&t.onack(e)};this.sendBlob=function(e){var a=0,o=new FileReader,i=function(){if(a>=e.size)t.oncomplete&&t.oncomplete(e);else{var i=function(e,t,n){var a=(e.slice||e.webkitSlice||e.mozSlice).bind(e),o=n-t;if(o!==n){var i=a(t,o);if(i.size===o)return i}return a(t,n)}(e,a,a+n.blobLength);a+=n.blobLength,o.readAsArrayBuffer(i)}};o.onload=function(){n.sendData(o.result),n.onack=function(o){t.onack&&t.onack(o),o.isError()||(t.onprogress&&t.onprogress(e,a-n.blobLength),i())}},o.onerror=function(){t.onerror&&t.onerror(e,a,o.error)},i()},this.sendEnd=function(){n.sendEnd()},this.onack=null,this.onerror=null,this.onprogress=null,this.oncomplete=null},(Guacamole=Guacamole||{}).Client=function(e){var t=this,n=Guacamole.Client.State.IDLE,a=0,o=null,i=0,r={0:"butt",1:"round",2:"square"},s={0:"bevel",1:"miter",2:"round"},u=new Guacamole.Display,l={},c={},h={},d=[],f=[],m=[],p=new Guacamole.IntegerPool,y=[];function v(e){e!=n&&(n=e,t.onstatechange&&t.onstatechange(n))}function g(){return n==Guacamole.Client.State.CONNECTED||n==Guacamole.Client.State.WAITING}this.exportState=function(e){var t={currentState:n,currentTimestamp:a,layers:{}},o={};for(var i in l)o[i]=l[i];u.flush((function(){for(var n in o){var a=parseInt(n),i=o[n],r={width:i.width,height:i.height};if(i.width&&i.height){var s=i.toCanvas();r.url=s.toDataURL("image/png")}a>0&&(r.x=i.x,r.y=i.y,r.z=i.z,r.alpha=i.alpha,r.matrix=i.matrix,r.parent=S(i.parent)),t.layers[n]=r}e(t)}))},this.importState=function(e,t){var o,i;for(o in n=e.currentState,a=e.currentTimestamp,u.cancel(),l)(i=parseInt(o))>0&&l[o].dispose();for(o in l={},e.layers){i=parseInt(o);var r=e.layers[o],s=w(i);if(u.resize(s,r.width,r.height),r.url&&(u.setChannelMask(s,Guacamole.Layer.SRC),u.draw(s,0,0,r.url)),i>0&&r.parent>=0){var c=w(r.parent);u.move(s,c,r.x,r.y,r.z),u.shade(s,r.alpha);var h=r.matrix;u.distort(s,h[0],h[1],h[2],h[3],h[4],h[5])}}u.flush(t)},this.getDisplay=function(){return u},this.sendSize=function(t,n){g()&&e.sendMessage("size",t,n)},this.sendKeyEvent=function(t,n){g()&&e.sendMessage("key",n,t)},this.sendMouseState=function(t,n){if(g()){var a=t.x,o=t.y;n&&(a/=u.getScale(),o/=u.getScale()),u.moveCursor(Math.floor(a),Math.floor(o));var i=0;t.left&&(i|=1),t.middle&&(i|=2),t.right&&(i|=4),t.up&&(i|=8),t.down&&(i|=16),e.sendMessage("mouse",Math.floor(a),Math.floor(o),i)}},this.sendTouchState=function(t,n){if(g()){var a=t.x,o=t.y;n&&(a/=u.getScale(),o/=u.getScale()),e.sendMessage("touch",t.id,Math.floor(a),Math.floor(o),Math.floor(t.radiusX),Math.floor(t.radiusY),t.angle,t.force)}},this.createOutputStream=function(){var e=p.next();return y[e]=new Guacamole.OutputStream(t,e)},this.createAudioStream=function(n){var a=t.createOutputStream();return e.sendMessage("audio",a.index,n),a},this.createFileStream=function(n,a){var o=t.createOutputStream();return e.sendMessage("file",o.index,n,a),o},this.createPipeStream=function(n,a){var o=t.createOutputStream();return e.sendMessage("pipe",o.index,n,a),o},this.createClipboardStream=function(n){var a=t.createOutputStream();return e.sendMessage("clipboard",a.index,n),a},this.createArgumentValueStream=function(n,a){var o=t.createOutputStream();return e.sendMessage("argv",o.index,n,a),o},this.createObjectOutputStream=function(n,a,o){var i=t.createOutputStream();return e.sendMessage("put",n,i.index,a,o),i},this.requestObjectInputStream=function(t,n){g()&&e.sendMessage("get",t,n)},this.sendAck=function(t,n,a){g()&&e.sendMessage("ack",t,n,a)},this.sendBlob=function(t,n){g()&&e.sendMessage("blob",t,n)},this.endStream=function(t){g()&&(e.sendMessage("end",t),y[t]&&(p.free(t),delete y[t]))},this.onstatechange=null,this.onname=null,this.onerror=null,this.onmsg=null,this.onjoin=null,this.onleave=null,this.onaudio=null,this.onvideo=null,this.onmultitouch=null,this.onargv=null,this.onclipboard=null,this.onfile=null,this.onfilesystem=null,this.onpipe=null,this.onrequired=null,this.onsync=null;var w=function(e){var t=l[e];return t||(t=0===e?u.getDefaultLayer():e>0?u.createLayer():u.createBuffer(),l[e]=t),t},S=function(e){if(!e)return null;for(var t in l)if(e===l[t])return parseInt(t);return null};var G={"miter-limit":function(e,t){u.setMiterLimit(e,parseFloat(t))},"multi-touch":function(e,n){t.onmultitouch&&e instanceof Guacamole.Display.VisibleLayer&&t.onmultitouch(e,parseInt(n))}},T={ack:function(e){var t=parseInt(e[0]),n=e[1],a=parseInt(e[2]),o=y[t];o&&(o.onack&&o.onack(new Guacamole.Status(a,n)),a>=256&&y[t]===o&&(p.free(t),delete y[t]))},arc:function(e){var t=w(parseInt(e[0])),n=parseInt(e[1]),a=parseInt(e[2]),o=parseInt(e[3]),i=parseFloat(e[4]),r=parseFloat(e[5]),s=parseInt(e[6]);u.arc(t,n,a,o,i,r,0!=s)},argv:function(e){var n=parseInt(e[0]),a=e[1],o=e[2];if(t.onargv){var i=f[n]=new Guacamole.InputStream(t,n);t.onargv(i,a,o)}else t.sendAck(n,"Receiving argument values unsupported",256)},audio:function(e){var n=parseInt(e[0]),a=e[1],o=f[n]=new Guacamole.InputStream(t,n),i=null;t.onaudio&&(i=t.onaudio(o,a)),i||(i=Guacamole.AudioPlayer.getInstance(o,a)),i?(c[n]=i,t.sendAck(n,"OK",0)):t.sendAck(n,"BAD TYPE",783)},blob:function(e){var t=parseInt(e[0]),n=e[1],a=f[t];a&&a.onblob&&a.onblob(n)},body:function(e){var n=parseInt(e[0]),a=m[n],o=parseInt(e[1]),i=e[2],r=e[3];if(a&&a.onbody){var s=f[o]=new Guacamole.InputStream(t,o);a.onbody(s,i,r)}else t.sendAck(o,"Receipt of body unsupported",256)},cfill:function(e){var t=parseInt(e[0]),n=w(parseInt(e[1])),a=parseInt(e[2]),o=parseInt(e[3]),i=parseInt(e[4]),r=parseInt(e[5]);u.setChannelMask(n,t),u.fillColor(n,a,o,i,r)},clip:function(e){var t=w(parseInt(e[0]));u.clip(t)},clipboard:function(e){var n=parseInt(e[0]),a=e[1];if(t.onclipboard){var o=f[n]=new Guacamole.InputStream(t,n);t.onclipboard(o,a)}else t.sendAck(n,"Clipboard unsupported",256)},close:function(e){var t=w(parseInt(e[0]));u.close(t)},copy:function(e){var t=w(parseInt(e[0])),n=parseInt(e[1]),a=parseInt(e[2]),o=parseInt(e[3]),i=parseInt(e[4]),r=parseInt(e[5]),s=w(parseInt(e[6])),l=parseInt(e[7]),c=parseInt(e[8]);u.setChannelMask(s,r),u.copy(t,n,a,o,i,s,l,c)},cstroke:function(e){var t=parseInt(e[0]),n=w(parseInt(e[1])),a=r[parseInt(e[2])],o=s[parseInt(e[3])],i=parseInt(e[4]),l=parseInt(e[5]),c=parseInt(e[6]),h=parseInt(e[7]),d=parseInt(e[8]);u.setChannelMask(n,t),u.strokeColor(n,a,o,i,l,c,h,d)},cursor:function(e){var t=parseInt(e[0]),n=parseInt(e[1]),a=w(parseInt(e[2])),o=parseInt(e[3]),i=parseInt(e[4]),r=parseInt(e[5]),s=parseInt(e[6]);u.setCursor(t,n,a,o,i,r,s)},curve:function(e){var t=w(parseInt(e[0])),n=parseInt(e[1]),a=parseInt(e[2]),o=parseInt(e[3]),i=parseInt(e[4]),r=parseInt(e[5]),s=parseInt(e[6]);u.curveTo(t,n,a,o,i,r,s)},disconnect:function(e){t.disconnect()},dispose:function(e){var t=parseInt(e[0]);if(t>0){var n=w(t);u.dispose(n),delete l[t]}else t<0&&delete l[t]},distort:function(e){var t=parseInt(e[0]),n=parseFloat(e[1]),a=parseFloat(e[2]),o=parseFloat(e[3]),i=parseFloat(e[4]),r=parseFloat(e[5]),s=parseFloat(e[6]);if(t>=0){var l=w(t);u.distort(l,n,a,o,i,r,s)}},error:function(e){var n=e[0],a=parseInt(e[1]);t.onerror&&t.onerror(new Guacamole.Status(a,n)),t.disconnect()},end:function(e){var t=parseInt(e[0]),n=f[t];n&&(n.onend&&n.onend(),delete f[t])},file:function(e){var n=parseInt(e[0]),a=e[1],o=e[2];if(t.onfile){var i=f[n]=new Guacamole.InputStream(t,n);t.onfile(i,a,o)}else t.sendAck(n,"File transfer unsupported",256)},filesystem:function(e){var n=parseInt(e[0]),a=e[1];if(t.onfilesystem){var o=m[n]=new Guacamole.Object(t,n);t.onfilesystem(o,a)}},identity:function(e){var t=w(parseInt(e[0]));u.setTransform(t,1,0,0,1,0,0)},img:function(e){var n=parseInt(e[0]),a=parseInt(e[1]),o=w(parseInt(e[2])),i=e[3],r=parseInt(e[4]),s=parseInt(e[5]),l=f[n]=new Guacamole.InputStream(t,n);u.setChannelMask(o,a),u.drawStream(o,r,s,l,i)},jpeg:function(e){var t=parseInt(e[0]),n=w(parseInt(e[1])),a=parseInt(e[2]),o=parseInt(e[3]),i=e[4];u.setChannelMask(n,t),u.draw(n,a,o,"data:image/jpeg;base64,"+i)},lfill:function(e){var t=parseInt(e[0]),n=w(parseInt(e[1])),a=w(parseInt(e[2]));u.setChannelMask(n,t),u.fillLayer(n,a)},line:function(e){var t=w(parseInt(e[0])),n=parseInt(e[1]),a=parseInt(e[2]);u.lineTo(t,n,a)},lstroke:function(e){var t=parseInt(e[0]),n=w(parseInt(e[1])),a=w(parseInt(e[2]));u.setChannelMask(n,t),u.strokeLayer(n,a)},mouse:function(e){var t=parseInt(e[0]),n=parseInt(e[1]);u.showCursor(!0),u.moveCursor(t,n)},move:function(e){var t=parseInt(e[0]),n=parseInt(e[1]),a=parseInt(e[2]),o=parseInt(e[3]),i=parseInt(e[4]);if(t>0&&n>=0){var r=w(t),s=w(n);u.move(r,s,a,o,i)}},msg:function(e){var n,a,o=!0,i=parseInt(e[0]);if(t.onmsg&&void 0===(o=t.onmsg(i,e.slice(1)))&&(o=!0),o)switch(i){case Guacamole.Client.Message.USER_JOINED:n=e[1],a=e[2],t.onjoin&&t.onjoin(n,a);break;case Guacamole.Client.Message.USER_LEFT:n=e[1],a=e[2],t.onleave&&t.onleave(n,a)}},name:function(e){t.onname&&t.onname(e[0])},nest:function(t){(function(t){var n=d[t];return null==n&&((n=d[t]=new Guacamole.Parser).oninstruction=e.oninstruction),n})(parseInt(t[0])).receive(t[1])},pipe:function(e){var n=parseInt(e[0]),a=e[1],o=e[2];if(t.onpipe){var i=f[n]=new Guacamole.InputStream(t,n);t.onpipe(i,a,o)}else t.sendAck(n,"Named pipes unsupported",256)},png:function(e){var t=parseInt(e[0]),n=w(parseInt(e[1])),a=parseInt(e[2]),o=parseInt(e[3]),i=e[4];u.setChannelMask(n,t),u.draw(n,a,o,"data:image/png;base64,"+i)},pop:function(e){var t=w(parseInt(e[0]));u.pop(t)},push:function(e){var t=w(parseInt(e[0]));u.push(t)},rect:function(e){var t=w(parseInt(e[0])),n=parseInt(e[1]),a=parseInt(e[2]),o=parseInt(e[3]),i=parseInt(e[4]);u.rect(t,n,a,o,i)},required:function(e){t.onrequired&&t.onrequired(e)},reset:function(e){var t=w(parseInt(e[0]));u.reset(t)},set:function(e){var t=w(parseInt(e[0])),n=e[1],a=e[2],o=G[n];o&&o(t,a)},shade:function(e){var t=parseInt(e[0]),n=parseInt(e[1]);if(t>=0){var a=w(t);u.shade(a,n)}},size:function(e){var t=parseInt(e[0]),n=w(t),a=parseInt(e[1]),o=parseInt(e[2]);u.resize(n,a,o)},start:function(e){var t=w(parseInt(e[0])),n=parseInt(e[1]),a=parseInt(e[2]);u.moveTo(t,n,a)},sync:function(o){var i=parseInt(o[0]),r=o[1]?parseInt(o[1]):0;u.flush((function(){for(var t in c){var n=c[t];n&&n.sync()}i!==a&&(e.sendMessage("sync",i),a=i)}),i,r),n===Guacamole.Client.State.WAITING&&v(Guacamole.Client.State.CONNECTED),t.onsync&&t.onsync(i,r)},transfer:function(e){var t=w(parseInt(e[0])),n=parseInt(e[1]),a=parseInt(e[2]),o=parseInt(e[3]),i=parseInt(e[4]),r=parseInt(e[5]),s=w(parseInt(e[6])),l=parseInt(e[7]),c=parseInt(e[8]);3===r?u.put(t,n,a,o,i,s,l,c):5!==r&&u.transfer(t,n,a,o,i,s,l,c,Guacamole.Client.DefaultTransferFunction[r])},transform:function(e){var t=w(parseInt(e[0])),n=parseFloat(e[1]),a=parseFloat(e[2]),o=parseFloat(e[3]),i=parseFloat(e[4]),r=parseFloat(e[5]),s=parseFloat(e[6]);u.transform(t,n,a,o,i,r,s)},undefine:function(e){var t=parseInt(e[0]),n=m[t];n&&n.onundefine&&n.onundefine()},video:function(e){var n=parseInt(e[0]),a=w(parseInt(e[1])),o=e[2],i=f[n]=new Guacamole.InputStream(t,n),r=null;t.onvideo&&(r=t.onvideo(i,a,o)),r||(r=Guacamole.VideoPlayer.getInstance(i,a,o)),r?(h[n]=r,t.sendAck(n,"OK",0)):t.sendAck(n,"BAD TYPE",783)}},E=function(){e.sendMessage("nop"),i=(new Date).getTime()},k=function(){window.clearTimeout(o);var e=(new Date).getTime(),t=Math.max(i+5e3-e,0);t>0?o=window.setTimeout(E,t):E()};e.oninstruction=function(e,t){var n=T[e];n&&n(t),k()},this.disconnect=function(){n!=Guacamole.Client.State.DISCONNECTED&&n!=Guacamole.Client.State.DISCONNECTING&&(v(Guacamole.Client.State.DISCONNECTING),window.clearTimeout(o),e.sendMessage("disconnect"),e.disconnect(),v(Guacamole.Client.State.DISCONNECTED))},this.connect=function(t){v(Guacamole.Client.State.CONNECTING);try{e.connect(t)}catch(e){throw v(Guacamole.Client.State.IDLE),e}k(),v(Guacamole.Client.State.WAITING)}},Guacamole.Client.State={IDLE:0,CONNECTING:1,WAITING:2,CONNECTED:3,DISCONNECTING:4,DISCONNECTED:5},Guacamole.Client.DefaultTransferFunction={0:function(e,t){t.red=t.green=t.blue=0},15:function(e,t){t.red=t.green=t.blue=255},3:function(e,t){t.red=e.red,t.green=e.green,t.blue=e.blue,t.alpha=e.alpha},5:function(e,t){},12:function(e,t){t.red=255&~e.red,t.green=255&~e.green,t.blue=255&~e.blue,t.alpha=e.alpha},10:function(e,t){t.red=255&~t.red,t.green=255&~t.green,t.blue=255&~t.blue},1:function(e,t){t.red=e.red&t.red,t.green=e.green&t.green,t.blue=e.blue&t.blue},14:function(e,t){t.red=255&~(e.red&t.red),t.green=255&~(e.green&t.green),t.blue=255&~(e.blue&t.blue)},7:function(e,t){t.red=e.red|t.red,t.green=e.green|t.green,t.blue=e.blue|t.blue},8:function(e,t){t.red=255&~(e.red|t.red),t.green=255&~(e.green|t.green),t.blue=255&~(e.blue|t.blue)},6:function(e,t){t.red=e.red^t.red,t.green=e.green^t.green,t.blue=e.blue^t.blue},9:function(e,t){t.red=255&~(e.red^t.red),t.green=255&~(e.green^t.green),t.blue=255&~(e.blue^t.blue)},4:function(e,t){t.red=~e.red&t.red&255,t.green=~e.green&t.green&255,t.blue=~e.blue&t.blue&255},13:function(e,t){t.red=255&(~e.red|t.red),t.green=255&(~e.green|t.green),t.blue=255&(~e.blue|t.blue)},2:function(e,t){t.red=e.red&~t.red&255,t.green=e.green&~t.green&255,t.blue=e.blue&~t.blue&255},11:function(e,t){t.red=255&(e.red|~t.red),t.green=255&(e.green|~t.green),t.blue=255&(e.blue|~t.blue)}},Guacamole.Client.Message={USER_JOINED:1,USER_LEFT:2},(Guacamole=Guacamole||{}).DataURIReader=function(e,t){var n=this,a="data:"+t+";base64,";e.onblob=function(e){a+=e},e.onend=function(){n.onend&&n.onend()},this.getURI=function(){return a},this.onend=null},(Guacamole=Guacamole||{}).Display=function(){var e=this,t=0,n=0,a=1,o=document.createElement("div");o.style.position="relative",o.style.width=t+"px",o.style.height=n+"px",o.style.transformOrigin=o.style.webkitTransformOrigin=o.style.MozTransformOrigin=o.style.OTransformOrigin=o.style.msTransformOrigin="0 0";var i=new Guacamole.Display.VisibleLayer(t,n),r=new Guacamole.Display.VisibleLayer(0,0);r.setChannelMask(Guacamole.Layer.SRC),o.appendChild(i.getElement()),o.appendChild(r.getElement());var s=document.createElement("div");s.style.position="relative",s.style.width=t*a+"px",s.style.height=n*a+"px",s.appendChild(o),this.cursorHotspotX=0,this.cursorHotspotY=0,this.cursorX=0,this.cursorY=0,this.statisticWindow=0,this.onresize=null,this.oncursor=null,this.onstatistics=null;var u=[],l=[],c=null,h=function(){for(var e=0,t=0,n=0,a=0;a<l.length;){var o=l[a];if(!o.isReady())break;o.flush(),e=o.localTimestamp,t=o.remoteTimestamp,n+=o.logicalFrames,a++}l.splice(0,a),a&&m(e,t,n)},d=function(){c||(c=window.requestAnimationFrame((function e(){if(c=null,l.length){if(l[0].isReady()){var t=l.shift();t.flush(),m(t.localTimestamp,t.remoteTimestamp,t.logicalFrames)}l.length&&(c=window.requestAnimationFrame(e))}})))},f=[],m=function(t,n,a){if(e.statisticWindow){for(var o=(new Date).getTime(),i=0;i<f.length&&!(o-f[i].timestamp<=e.statisticWindow);i++);f.splice(0,i-1),f.push({localTimestamp:t,remoteTimestamp:n,timestamp:o,frames:a});var r=(f[f.length-1].timestamp-f[0].timestamp)/1e3,s=(f[f.length-1].remoteTimestamp-f[0].remoteTimestamp)/1e3,u=f.length,l=f.reduce((function(e,t){return e+t.frames}),0),c=f.reduce((function(e,t){return e+Math.max(0,t.frames-1)}),0),h=new Guacamole.Display.Statistics({processingLag:o-t,desktopFps:s&&l?l/s:null,clientFps:r?u/r:null,serverFps:s?u/s:null,dropRate:s?c/s:null});e.onstatistics&&e.onstatistics(h)}};function p(){window.requestAnimationFrame&&document.hasFocus()?d():h()}window.addEventListener("blur",(function(){c&&!document.hasFocus()&&(window.cancelAnimationFrame(c),c=null,h())}),!0);var y=function(e,t,n,a){this.localTimestamp=(new Date).getTime(),this.remoteTimestamp=n||this.localTimestamp,this.logicalFrames=a||0,this.cancel=function(){e=null,t.forEach((function(e){e.cancel()})),t=[]},this.isReady=function(){for(var e=0;e<t.length;e++)if(t[e].blocked)return!1;return!0},this.flush=function(){for(var n=0;n<t.length;n++)t[n].execute();e&&e()}};function v(e,t){var n=this;this.blocked=t,this.cancel=function(){n.blocked=!1,e=null},this.unblock=function(){n.blocked&&(n.blocked=!1,p())},this.execute=function(){e&&e()}}function g(e,t){var n=new v(e,t);return u.push(n),n}this.getElement=function(){return s},this.getWidth=function(){return t},this.getHeight=function(){return n},this.getDefaultLayer=function(){return i},this.getCursorLayer=function(){return r},this.createLayer=function(){var e=new Guacamole.Display.VisibleLayer(t,n);return e.move(i,0,0,0),e},this.createBuffer=function(){var e=new Guacamole.Layer(0,0);return e.autosize=1,e},this.flush=function(e,t,n){l.push(new y(e,u,t,n)),u=[],p()},this.cancel=function(){l.forEach((function(e){e.cancel()})),l=[],u.forEach((function(e){e.cancel()})),u=[]},this.setCursor=function(t,n,a,o,i,s,u){g((function(){e.cursorHotspotX=t,e.cursorHotspotY=n,r.resize(s,u),r.copy(a,o,i,s,u,0,0),e.moveCursor(e.cursorX,e.cursorY),e.oncursor&&e.oncursor(r.toCanvas(),t,n)}))},this.showCursor=function(e){var t=r.getElement(),n=t.parentNode;!1===e?n&&n.removeChild(t):n!==o&&o.appendChild(t)},this.moveCursor=function(t,n){r.translate(t-e.cursorHotspotX,n-e.cursorHotspotY),e.cursorX=t,e.cursorY=n},this.resize=function(r,u,l){g((function(){r.resize(u,l),r===i&&(t=u,n=l,o.style.width=t+"px",o.style.height=n+"px",s.style.width=t*a+"px",s.style.height=n*a+"px",e.onresize&&e.onresize(u,l))}))},this.drawImage=function(e,t,n,a){g((function(){e.drawImage(t,n,a)}))},this.drawBlob=function(e,t,n,a){var o;if(window.createImageBitmap){var i;o=g((function(){e.drawImage(t,n,i)}),!0),window.createImageBitmap(a).then((function(e){i=e,o.unblock()}))}else{var r=URL.createObjectURL(a);o=g((function(){s.width&&s.height&&e.drawImage(t,n,s),URL.revokeObjectURL(r)}),!0);var s=new Image;s.onload=o.unblock,s.onerror=o.unblock,s.src=r}},this.drawStream=function(t,n,a,o,i){var r;window.createImageBitmap?(r=new Guacamole.BlobReader(o,i)).onend=function(){e.drawBlob(t,n,a,r.getBlob())}:(r=new Guacamole.DataURIReader(o,i)).onend=function(){e.draw(t,n,a,r.getURI())}},this.draw=function(e,t,n,a){var o=g((function(){i.width&&i.height&&e.drawImage(t,n,i)}),!0),i=new Image;i.onload=o.unblock,i.onerror=o.unblock,i.src=a},this.play=function(e,t,n,a){var o=document.createElement("video");o.type=t,o.src=a,o.addEventListener("play",(function(){!function t(){e.drawImage(0,0,o),o.ended||window.setTimeout(t,20)}()}),!1),g(o.play)},this.transfer=function(e,t,n,a,o,i,r,s,u){g((function(){i.transfer(e,t,n,a,o,r,s,u)}))},this.put=function(e,t,n,a,o,i,r,s){g((function(){i.put(e,t,n,a,o,r,s)}))},this.copy=function(e,t,n,a,o,i,r,s){g((function(){i.copy(e,t,n,a,o,r,s)}))},this.moveTo=function(e,t,n){g((function(){e.moveTo(t,n)}))},this.lineTo=function(e,t,n){g((function(){e.lineTo(t,n)}))},this.arc=function(e,t,n,a,o,i,r){g((function(){e.arc(t,n,a,o,i,r)}))},this.curveTo=function(e,t,n,a,o,i,r){g((function(){e.curveTo(t,n,a,o,i,r)}))},this.close=function(e){g((function(){e.close()}))},this.rect=function(e,t,n,a,o){g((function(){e.rect(t,n,a,o)}))},this.clip=function(e){g((function(){e.clip()}))},this.strokeColor=function(e,t,n,a,o,i,r,s){g((function(){e.strokeColor(t,n,a,o,i,r,s)}))},this.fillColor=function(e,t,n,a,o){g((function(){e.fillColor(t,n,a,o)}))},this.strokeLayer=function(e,t,n,a,o){g((function(){e.strokeLayer(t,n,a,o)}))},this.fillLayer=function(e,t){g((function(){e.fillLayer(t)}))},this.push=function(e){g((function(){e.push()}))},this.pop=function(e){g((function(){e.pop()}))},this.reset=function(e){g((function(){e.reset()}))},this.setTransform=function(e,t,n,a,o,i,r){g((function(){e.setTransform(t,n,a,o,i,r)}))},this.transform=function(e,t,n,a,o,i,r){g((function(){e.transform(t,n,a,o,i,r)}))},this.setChannelMask=function(e,t){g((function(){e.setChannelMask(t)}))},this.setMiterLimit=function(e,t){g((function(){e.setMiterLimit(t)}))},this.dispose=function(e){g((function(){e.dispose()}))},this.distort=function(e,t,n,a,o,i,r){g((function(){e.distort(t,n,a,o,i,r)}))},this.move=function(e,t,n,a,o){g((function(){e.move(t,n,a,o)}))},this.shade=function(e,t){g((function(){e.shade(t)}))},this.scale=function(e){o.style.transform=o.style.WebkitTransform=o.style.MozTransform=o.style.OTransform=o.style.msTransform="scale("+e+","+e+")",a=e,s.style.width=t*a+"px",s.style.height=n*a+"px"},this.getScale=function(){return a},this.flatten=function(){var e=document.createElement("canvas");e.width=i.width,e.height=i.height;var t=e.getContext("2d");return function e(n,a,o){if(n.width>0&&n.height>0){var i=t.globalAlpha;t.globalAlpha*=n.alpha/255,t.drawImage(n.getCanvas(),a,o);for(var r=function(e){var t=[];for(var n in e.children)t.push(e.children[n]);return t.sort((function(e,t){var n=e.z-t.z;if(0!==n)return n;var a=e.getElement(),o=t.getElement().compareDocumentPosition(a);return o&Node.DOCUMENT_POSITION_PRECEDING?-1:o&Node.DOCUMENT_POSITION_FOLLOWING?1:0})),t}(n),s=0;s<r.length;s++){var u=r[s];e(u,a+u.x,o+u.y)}t.globalAlpha=i}}(i,0,0),e}},Guacamole.Display.VisibleLayer=function(e,t){Guacamole.Layer.apply(this,[e,t]);var n=this;this.__unique_id=Guacamole.Display.VisibleLayer.__next_id++,this.alpha=255,this.x=0,this.y=0,this.z=0,this.matrix=[1,0,0,1,0,0],this.parent=null,this.children={};var a=n.getCanvas();a.style.position="absolute",a.style.left="0px",a.style.top="0px";var o=document.createElement("div");o.appendChild(a),o.style.width=e+"px",o.style.height=t+"px",o.style.position="absolute",o.style.left="0px",o.style.top="0px",o.style.overflow="hidden";var i=this.resize;this.resize=function(e,t){o.style.width=e+"px",o.style.height=t+"px",i(e,t)},this.getElement=function(){return o};var r="translate(0px, 0px)",s="matrix(1, 0, 0, 1, 0, 0)";this.translate=function(e,t){n.x=e,n.y=t,r="translate("+e+"px,"+t+"px)",o.style.transform=o.style.WebkitTransform=o.style.MozTransform=o.style.OTransform=o.style.msTransform=r+" "+s},this.move=function(e,t,a,i){n.parent!==e&&(n.parent&&delete n.parent.children[n.__unique_id],n.parent=e,e.children[n.__unique_id]=n,e.getElement().appendChild(o));n.translate(t,a),n.z=i,o.style.zIndex=i},this.shade=function(e){n.alpha=e,o.style.opacity=e/255},this.dispose=function(){n.parent&&(delete n.parent.children[n.__unique_id],n.parent=null),o.parentNode&&o.parentNode.removeChild(o)},this.distort=function(e,t,a,i,u,l){n.matrix=[e,t,a,i,u,l],s="matrix("+e+","+t+","+a+","+i+","+u+","+l+")",o.style.transform=o.style.WebkitTransform=o.style.MozTransform=o.style.OTransform=o.style.msTransform=r+" "+s}},Guacamole.Display.VisibleLayer.__next_id=0,Guacamole.Display.Statistics=function(e){e=e||{},this.processingLag=e.processingLag,this.desktopFps=e.desktopFps,this.serverFps=e.serverFps,this.clientFps=e.clientFps,this.dropRate=e.dropRate},(Guacamole=Guacamole||{}).Event=function(e){this.type=e,this.timestamp=(new Date).getTime(),this.getAge=function(){return(new Date).getTime()-this.timestamp},this.invokeLegacyHandler=function(e){}},Guacamole.Event.DOMEvent=function(e,t){Guacamole.Event.call(this,e),t=t||[],Array.isArray(t)||(t=[t]),this.preventDefault=function(){t.forEach((function(e){e.preventDefault&&e.preventDefault(),e.returnValue=!1}))},this.stopPropagation=function(){t.forEach((function(e){e.stopPropagation()}))}},Guacamole.Event.DOMEvent.cancelEvent=function(e){e.stopPropagation(),e.preventDefault&&e.preventDefault(),e.returnValue=!1},Guacamole.Event.Target=function(){var e={};this.on=function(t,n){var a=e[t];a||(e[t]=a=[]),a.push(n)},this.onEach=function(e,t){e.forEach((function(e){this.on(e,t)}),this)},this.dispatch=function(t){t.invokeLegacyHandler(this);var n=e[t.type];if(n)for(var a=0;a<n.length;a++)n[a](t,this)},this.off=function(t,n){var a=e[t];if(!a)return!1;for(var o=0;o<a.length;o++)if(a[o]===n)return a.splice(o,1),!0;return!1},this.offEach=function(e,t){var n=!1;return e.forEach((function(e){n|=this.off(e,t)}),this),n}},(Guacamole=Guacamole||{}).InputSink=function(){var e=this,t=document.createElement("textarea");t.style.position="fixed",t.style.outline="none",t.style.border="none",t.style.margin="0",t.style.padding="0",t.style.height="0",t.style.width="0",t.style.left="0",t.style.bottom="0",t.style.resize="none",t.style.background="transparent",t.style.color="transparent",t.addEventListener("keypress",(function(e){t.value=""}),!1),t.addEventListener("compositionend",(function(e){e.data&&(t.value="")}),!1),t.addEventListener("input",(function(e){e.data&&!e.isComposing&&(t.value="")}),!1),t.addEventListener("focus",(function(){window.setTimeout((function(){t.click(),t.select()}),0)}),!0),this.focus=function(){window.setTimeout((function(){t.focus()}),0)},this.getElement=function(){return t},document.addEventListener("keydown",(function(t){var n=document.activeElement;if(n&&n!==document.body){var a=n.getBoundingClientRect();if(a.left+a.width>0&&a.top+a.height>0)return}e.focus()}),!0)},(Guacamole=Guacamole||{}).InputStream=function(e,t){var n=this;this.index=t,this.onblob=null,this.onend=null,this.sendAck=function(t,a){e.sendAck(n.index,t,a)}},(Guacamole=Guacamole||{}).IntegerPool=function(){var e=this,t=[];this.next_int=0,this.next=function(){return t.length>0?t.shift():e.next_int++},this.free=function(e){t.push(e)}},(Guacamole=Guacamole||{}).JSONReader=function(e){var t=this,n=new Guacamole.StringReader(e),a="";this.getLength=function(){return a.length},this.getJSON=function(){return JSON.parse(a)},n.ontext=function(e){a+=e,t.onprogress&&t.onprogress(e.length)},n.onend=function(){t.onend&&t.onend()},this.onprogress=null,this.onend=null},(Guacamole=Guacamole||{}).KeyEventInterpreter=function(e){null==e&&(e=0);var t={};[{keysym:65027,name:"AltGr"},{keysym:65288,name:"Backspace"},{keysym:65289,name:"Tab"},{keysym:65291,name:"Clear"},{keysym:65293,name:"Return",value:"\n"},{keysym:65299,name:"Pause"},{keysym:65300,name:"Scroll"},{keysym:65301,name:"SysReq"},{keysym:65307,name:"Escape"},{keysym:65360,name:"Home"},{keysym:65361,name:"Left"},{keysym:65362,name:"Up"},{keysym:65363,name:"Right"},{keysym:65364,name:"Down"},{keysym:65365,name:"Page Up"},{keysym:65366,name:"Page Down"},{keysym:65367,name:"End"},{keysym:65379,name:"Insert"},{keysym:65381,name:"Undo"},{keysym:65386,name:"Help"},{keysym:65407,name:"Num"},{keysym:65408,name:"Space",value:" "},{keysym:65421,name:"Enter",value:"\n"},{keysym:65429,name:"Home"},{keysym:65430,name:"Left"},{keysym:65431,name:"Up"},{keysym:65432,name:"Right"},{keysym:65433,name:"Down"},{keysym:65434,name:"Page Up"},{keysym:65435,name:"Page Down"},{keysym:65436,name:"End"},{keysym:65438,name:"Insert"},{keysym:65450,name:"*",value:"*"},{keysym:65451,name:"+",value:"+"},{keysym:65453,name:"-",value:"-"},{keysym:65454,name:".",value:"."},{keysym:65455,name:"/",value:"/"},{keysym:65456,name:"0",value:"0"},{keysym:65457,name:"1",value:"1"},{keysym:65458,name:"2",value:"2"},{keysym:65459,name:"3",value:"3"},{keysym:65460,name:"4",value:"4"},{keysym:65461,name:"5",value:"5"},{keysym:65462,name:"6",value:"6"},{keysym:65463,name:"7",value:"7"},{keysym:65464,name:"8",value:"8"},{keysym:65465,name:"9",value:"9"},{keysym:65470,name:"F1"},{keysym:65471,name:"F2"},{keysym:65472,name:"F3"},{keysym:65473,name:"F4"},{keysym:65474,name:"F5"},{keysym:65475,name:"F6"},{keysym:65476,name:"F7"},{keysym:65477,name:"F8"},{keysym:65478,name:"F9"},{keysym:65479,name:"F10"},{keysym:65480,name:"F11"},{keysym:65481,name:"F12"},{keysym:65482,name:"F13"},{keysym:65483,name:"F14"},{keysym:65484,name:"F15"},{keysym:65485,name:"F16"},{keysym:65486,name:"F17"},{keysym:65487,name:"F18"},{keysym:65488,name:"F19"},{keysym:65489,name:"F20"},{keysym:65490,name:"F21"},{keysym:65491,name:"F22"},{keysym:65492,name:"F23"},{keysym:65493,name:"F24"},{keysym:65505,name:"Shift"},{keysym:65506,name:"Shift"},{keysym:65507,name:"Ctrl"},{keysym:65508,name:"Ctrl"},{keysym:65509,name:"Caps"},{keysym:65511,name:"Meta"},{keysym:65512,name:"Meta"},{keysym:65513,name:"Alt"},{keysym:65514,name:"Alt"},{keysym:65515,name:"Super"},{keysym:65516,name:"Super"},{keysym:65517,name:"Hyper"},{keysym:65518,name:"Hyper"},{keysym:65535,name:"Delete"}].forEach((function(e){t[e.keysym]=new Guacamole.KeyEventInterpreter.KeyDefinition(e)}));var n=[];function a(e){if(e in t)return t[e];var n=function(e){if(e<0||e>255&&16842751!=(65535|e))return null;var t=65535&e,n=String.fromCharCode(t);return new Guacamole.KeyEventInterpreter.KeyDefinition({keysym:e,name:n,value:n})}(e);return null!=n?n:new Guacamole.KeyEventInterpreter.KeyDefinition({keysym:e,name:"0x"+String(e.toString(16))})}this.handleKeyEvent=function(t){var o=parseInt(t[0]),i=parseInt(t[1]),r=parseInt(t[2])-e,s=a(o);n.push(new Guacamole.KeyEventInterpreter.KeyEvent({definition:s,pressed:i,timestamp:r}))},this.getEvents=function(){return n}},Guacamole.KeyEventInterpreter.KeyDefinition=function(e){e=e||{},this.keysym=parseInt(e.keysym),this.name=e.name,this.value=e.value},Guacamole.KeyEventInterpreter.KeyEvent=function(e){e=e||{},this.definition=e.definition,this.pressed=!!e.pressed,this.timestamp=e.timestamp},(Guacamole=Guacamole||{}).Keyboard=function(e){var t=this,n="_GUAC_KEYBOARD_HANDLED_BY_"+Guacamole.Keyboard._nextID++;this.onkeydown=null,this.onkeyup=null;var a={keyupUnreliable:!1,altIsTypableOnly:!1,capsLockKeyupUnreliable:!1};navigator&&navigator.platform&&(navigator.platform.match(/ipad|iphone|ipod/i)?a.keyupUnreliable=!0:navigator.platform.match(/^mac/i)&&(a.altIsTypableOnly=!0,a.capsLockKeyupUnreliable=!0));var o=function(e){var t=this;this.keyCode=e?e.which||e.keyCode:0,this.keyIdentifier=e&&e.keyIdentifier,this.key=e&&e.key,this.location=e?b(e):0,this.modifiers=e?Guacamole.Keyboard.ModifierState.fromKeyboardEvent(e):new Guacamole.Keyboard.ModifierState,this.timestamp=(new Date).getTime(),this.defaultPrevented=!1,this.keysym=null,this.reliable=!1,this.getAge=function(){return(new Date).getTime()-t.timestamp}},i=function(e){o.call(this,e),this.keysym=w(this.key,this.location)||G(this.keyCode,this.location),this.keyupReliable=!a.keyupUnreliable,this.keysym&&!g(this.keysym)&&(this.reliable=!0),!this.keysym&&T(this.keyCode,this.keyIdentifier)&&(this.keysym=w(this.keyIdentifier,this.location,this.modifiers.shift)),(this.modifiers.meta&&65511!==this.keysym&&65512!==this.keysym||65509===this.keysym&&a.capsLockKeyupUnreliable)&&(this.keyupReliable=!1);var t=!this.modifiers.ctrl&&!a.altIsTypableOnly;!a.altIsTypableOnly||65513!==this.keysym&&65514!==this.keysym||(this.keysym=65027),(!this.modifiers.alt&&this.modifiers.ctrl||t&&this.modifiers.alt||this.modifiers.meta||this.modifiers.hyper)&&(this.reliable=!0),m[this.keyCode]=this.keysym};i.prototype=new o;var r=function(e){o.call(this,e),this.keysym=S(this.keyCode),this.reliable=!0};r.prototype=new o;var s=function(e){o.call(this,e),this.keysym=G(this.keyCode,this.location)||w(this.key,this.location),t.pressed[this.keysym]||(this.keysym=m[this.keyCode]||this.keysym),this.reliable=!0};s.prototype=new o;var u=[],l={8:[65288],9:[65289],12:[65291,65291,65291,65461],13:[65293],16:[65505,65505,65506],17:[65507,65507,65508],18:[65513,65513,65514],19:[65299],20:[65509],27:[65307],32:[32],33:[65365,65365,65365,65465],34:[65366,65366,65366,65459],35:[65367,65367,65367,65457],36:[65360,65360,65360,65463],37:[65361,65361,65361,65460],38:[65362,65362,65362,65464],39:[65363,65363,65363,65462],40:[65364,65364,65364,65458],45:[65379,65379,65379,65456],46:[65535,65535,65535,65454],91:[65511],92:[65512],93:[65383],96:[65456],97:[65457],98:[65458],99:[65459],100:[65460],101:[65461],102:[65462],103:[65463],104:[65464],105:[65465],106:[65450],107:[65451],109:[65453],110:[65454],111:[65455],112:[65470],113:[65471],114:[65472],115:[65473],116:[65474],117:[65475],118:[65476],119:[65477],120:[65478],121:[65479],122:[65480],123:[65481],144:[65407],145:[65300],225:[65027]},c={Again:[65382],AllCandidates:[65341],Alphanumeric:[65328],Alt:[65513,65513,65514],Attn:[64782],AltGraph:[65027],ArrowDown:[65364],ArrowLeft:[65361],ArrowRight:[65363],ArrowUp:[65362],Backspace:[65288],CapsLock:[65509],Cancel:[65385],Clear:[65291],Convert:[65315],Copy:[64789],Crsel:[64796],CrSel:[64796],CodeInput:[65335],Compose:[65312],Control:[65507,65507,65508],ContextMenu:[65383],Delete:[65535],Down:[65364],End:[65367],Enter:[65293],EraseEof:[64774],Escape:[65307],Execute:[65378],Exsel:[64797],ExSel:[64797],F1:[65470],F2:[65471],F3:[65472],F4:[65473],F5:[65474],F6:[65475],F7:[65476],F8:[65477],F9:[65478],F10:[65479],F11:[65480],F12:[65481],F13:[65482],F14:[65483],F15:[65484],F16:[65485],F17:[65486],F18:[65487],F19:[65488],F20:[65489],F21:[65490],F22:[65491],F23:[65492],F24:[65493],Find:[65384],GroupFirst:[65036],GroupLast:[65038],GroupNext:[65032],GroupPrevious:[65034],FullWidth:null,HalfWidth:null,HangulMode:[65329],Hankaku:[65321],HanjaMode:[65332],Help:[65386],Hiragana:[65317],HiraganaKatakana:[65319],Home:[65360],Hyper:[65517,65517,65518],Insert:[65379],JapaneseHiragana:[65317],JapaneseKatakana:[65318],JapaneseRomaji:[65316],JunjaMode:[65336],KanaMode:[65325],KanjiMode:[65313],Katakana:[65318],Left:[65361],Meta:[65511,65511,65512],ModeChange:[65406],NonConvert:[65314],NumLock:[65407],PageDown:[65366],PageUp:[65365],Pause:[65299],Play:[64790],PreviousCandidate:[65342],PrintScreen:[65377],Redo:[65382],Right:[65363],Romaji:[65316],RomanCharacters:null,Scroll:[65300],Select:[65376],Separator:[65452],Shift:[65505,65505,65506],SingleCandidate:[65340],Super:[65515,65515,65516],Tab:[65289],UIKeyInputDownArrow:[65364],UIKeyInputEscape:[65307],UIKeyInputLeftArrow:[65361],UIKeyInputRightArrow:[65363],UIKeyInputUpArrow:[65362],Up:[65362],Undo:[65381],Win:[65511,65511,65512],Zenkaku:[65320],ZenkakuHankaku:[65322]},h={65027:!0,65505:!0,65506:!0,65507:!0,65508:!0,65509:!0,65511:!0,65512:!0,65513:!0,65514:!0,65515:!0,65516:!0};this.modifiers=new Guacamole.Keyboard.ModifierState,this.pressed={};var d={},f={},m={},p=null,y=null,v=function(e,t){return e?e[t]||e[0]:null},g=function(e){return e>=0&&e<=255||16777216==(4294901760&e)};function w(e,t,n){if(!e)return null;var a,o=e.indexOf("U+");if(o>=0){var i=e.substring(o+2);a=String.fromCharCode(parseInt(i,16))}else{if(1!==e.length||3===t)return v(c[e],t);a=e}return!0===n?a=a.toUpperCase():!1===n&&(a=a.toLowerCase()),S(a.charCodeAt(0))}function S(e){return function(e){return e<=31||e>=127&&e<=159}(e)?65280|e:e>=0&&e<=255?e:e>=256&&e<=1114111?16777216|e:null}function G(e,t){return v(l[e],t)}var T=function(e,t){if(!t)return!1;var n=t.indexOf("U+");return-1===n||(e!==parseInt(t.substring(n+2),16)||(e>=65&&e<=90||e>=48&&e<=57))};this.press=function(e){if(null!==e){if(!t.pressed[e]&&(t.pressed[e]=!0,t.onkeydown)){var n=t.onkeydown(e);return f[e]=n,window.clearTimeout(p),window.clearInterval(y),h[e]||(p=window.setTimeout((function(){y=window.setInterval((function(){t.onkeyup(e),t.onkeydown(e)}),50)}),500)),n}return f[e]||!1}},this.release=function(e){t.pressed[e]&&(delete t.pressed[e],delete d[e],window.clearTimeout(p),window.clearInterval(y),null!==e&&t.onkeyup&&t.onkeyup(e))},this.type=function(e){for(var n=0;n<e.length;n++){var a=S(e.codePointAt?e.codePointAt(n):e.charCodeAt(n));t.press(a),t.release(a)}},this.reset=function(){for(var e in t.pressed)t.release(parseInt(e));u=[]};var E=function(e,n,a){var o,i=a.modifiers[e],r=t.modifiers[e];if(-1===n.indexOf(a.keysym))if(r&&!1===i)for(o=0;o<n.length;o++)t.release(n[o]);else if(!r&&i){for(o=0;o<n.length;o++)if(t.pressed[n[o]])return;var s=n[0];a.keysym&&(d[s]=!0),t.press(s)}},k=function(e){E("alt",[65513,65514,65027],e),E("shift",[65505,65506],e),E("ctrl",[65507,65508],e),E("meta",[65511,65512],e),E("hyper",[65515,65516],e),t.modifiers=e.modifiers};function I(){var e,n=C();if(!n)return!1;do{e=n,n=C()}while(null!==n);return function(){for(var e in t.pressed)if(!d[e])return!1;return!0}()&&t.reset(),e.defaultPrevented}var C=function(){var e=u[0];if(!e)return null;if(!(e instanceof i))return e instanceof s&&!a.keyupUnreliable?(n=e.keysym)?(t.release(n),delete m[e.keyCode],e.defaultPrevented=!0,k(e),u.shift()):(t.reset(),e):u.shift();var n=null,o=[];if(65511===e.keysym||65512===e.keysym){if(1===u.length)return null;if(u[1].keysym!==e.keysym){if(!u[1].modifiers.meta)return u.shift()}else if(u[1]instanceof i)return u.shift()}if(e.reliable?(n=e.keysym,o=u.splice(0,1)):u[1]instanceof r?(n=u[1].keysym,o=u.splice(0,2)):u[1]&&(n=e.keysym,o=u.splice(0,1)),o.length>0){if(k(e),n){!function(e){t.modifiers.ctrl&&t.modifiers.alt&&(e>=65&&e<=90||e>=97&&e<=122||(e<=255||16777216==(4278190080&e))&&(t.release(65507),t.release(65508),t.release(65513),t.release(65514)))}(n);var l=!t.press(n);m[e.keyCode]=n,e.keyupReliable||t.release(n);for(var c=0;c<o.length;c++)o[c].defaultPrevented=l}return e}return null},b=function(e){return"location"in e?e.location:"keyLocation"in e?e.keyLocation:0},A=function(e){return!e[n]&&(e[n]=!0,!0)};this.listenTo=function(e){e.addEventListener("keydown",(function(e){if(t.onkeydown&&A(e)){var n=new i(e);e.isComposing||229===n.keyCode||(u.push(n),I()&&e.preventDefault())}}),!0),e.addEventListener("keypress",(function(e){(t.onkeydown||t.onkeyup)&&A(e)&&(u.push(new r(e)),I()&&e.preventDefault())}),!0),e.addEventListener("keyup",(function(e){t.onkeyup&&A(e)&&(e.preventDefault(),u.push(new s(e)),I())}),!0);var n=function(e){(t.onkeydown||t.onkeyup)&&A(e)&&e.data&&!e.isComposing&&t.type(e.data)};e.addEventListener("input",n,!1),e.addEventListener("compositionend",(function(e){(t.onkeydown||t.onkeyup)&&A(e)&&e.data&&t.type(e.data)}),!1),e.addEventListener("compositionstart",(function(t){e.removeEventListener("input",n,!1)}),!1)},e&&t.listenTo(e)},Guacamole.Keyboard._nextID=0,Guacamole.Keyboard.ModifierState=function(){this.shift=!1,this.ctrl=!1,this.alt=!1,this.meta=!1,this.hyper=!1},Guacamole.Keyboard.ModifierState.fromKeyboardEvent=function(e){var t=new Guacamole.Keyboard.ModifierState;return t.shift=e.shiftKey,t.ctrl=e.ctrlKey,t.alt=e.altKey,t.meta=e.metaKey,e.getModifierState&&(t.hyper=e.getModifierState("OS")||e.getModifierState("Super")||e.getModifierState("Hyper")||e.getModifierState("Win")),t},(Guacamole=Guacamole||{}).Layer=function(e,t){var n=this,a=document.createElement("canvas"),o=a.getContext("2d");o.save();var i=!0,r=!0,s=0,u={1:"destination-in",2:"destination-out",4:"source-in",6:"source-atop",8:"source-out",9:"destination-atop",10:"xor",11:"destination-over",12:"copy",14:"source-over",15:"lighter"},l=function(e,t){e=e||0,t=t||0;var r=64*Math.ceil(e/64),u=64*Math.ceil(t/64);if(a.width!==r||a.height!==u){var l=null;if(!i&&0!==a.width&&0!==a.height)(l=document.createElement("canvas")).width=Math.min(n.width,e),l.height=Math.min(n.height,t),l.getContext("2d").drawImage(a,0,0,l.width,l.height,0,0,l.width,l.height);var c=o.globalCompositeOperation;a.width=r,a.height=u,l&&o.drawImage(l,0,0,l.width,l.height,0,0,l.width,l.height),o.globalCompositeOperation=c,s=0,o.save()}else n.reset();n.width=e,n.height=t};function c(e,t,a,o){var i,r,s=a+e,u=o+t;i=s>n.width?s:n.width,r=u>n.height?u:n.height,n.resize(i,r)}this.autosize=!1,this.width=e,this.height=t,this.getCanvas=function(){return a},this.toCanvas=function(){var e=document.createElement("canvas");return e.width=n.width,e.height=n.height,e.getContext("2d").drawImage(n.getCanvas(),0,0),e},this.resize=function(e,t){e===n.width&&t===n.height||l(e,t)},this.drawImage=function(e,t,a){n.autosize&&c(e,t,a.width,a.height),o.drawImage(a,e,t),i=!1},this.transfer=function(e,t,a,r,s,u,l,h){var d=e.getCanvas();if(!(t>=d.width||a>=d.height)&&(t+r>d.width&&(r=d.width-t),a+s>d.height&&(s=d.height-a),0!==r&&0!==s)){n.autosize&&c(u,l,r,s);for(var f=e.getCanvas().getContext("2d").getImageData(t,a,r,s),m=o.getImageData(u,l,r,s),p=0;p<r*s*4;p+=4){var y=new Guacamole.Layer.Pixel(f.data[p],f.data[p+1],f.data[p+2],f.data[p+3]),v=new Guacamole.Layer.Pixel(m.data[p],m.data[p+1],m.data[p+2],m.data[p+3]);h(y,v),m.data[p]=v.red,m.data[p+1]=v.green,m.data[p+2]=v.blue,m.data[p+3]=v.alpha}o.putImageData(m,u,l),i=!1}},this.put=function(e,t,a,r,s,u,l){var h=e.getCanvas();if(!(t>=h.width||a>=h.height)&&(t+r>h.width&&(r=h.width-t),a+s>h.height&&(s=h.height-a),0!==r&&0!==s)){n.autosize&&c(u,l,r,s);var d=e.getCanvas().getContext("2d").getImageData(t,a,r,s);o.putImageData(d,u,l),i=!1}},this.copy=function(e,t,a,r,s,u,l){var h=e.getCanvas();t>=h.width||a>=h.height||(t+r>h.width&&(r=h.width-t),a+s>h.height&&(s=h.height-a),0!==r&&0!==s&&(n.autosize&&c(u,l,r,s),o.drawImage(h,t,a,r,s,u,l,r,s),i=!1))},this.moveTo=function(e,t){r&&(o.beginPath(),r=!1),n.autosize&&c(e,t,0,0),o.moveTo(e,t)},this.lineTo=function(e,t){r&&(o.beginPath(),r=!1),n.autosize&&c(e,t,0,0),o.lineTo(e,t)},this.arc=function(e,t,a,i,s,u){r&&(o.beginPath(),r=!1),n.autosize&&c(e,t,0,0),o.arc(e,t,a,i,s,u)},this.curveTo=function(e,t,a,i,s,u){r&&(o.beginPath(),r=!1),n.autosize&&c(s,u,0,0),o.bezierCurveTo(e,t,a,i,s,u)},this.close=function(){o.closePath(),r=!0},this.rect=function(e,t,a,i){r&&(o.beginPath(),r=!1),n.autosize&&c(e,t,a,i),o.rect(e,t,a,i)},this.clip=function(){o.clip(),r=!0},this.strokeColor=function(e,t,n,a,s,u,l){o.lineCap=e,o.lineJoin=t,o.lineWidth=n,o.strokeStyle="rgba("+a+","+s+","+u+","+l/255+")",o.stroke(),i=!1,r=!0},this.fillColor=function(e,t,n,a){o.fillStyle="rgba("+e+","+t+","+n+","+a/255+")",o.fill(),i=!1,r=!0},this.strokeLayer=function(e,t,n,a){o.lineCap=e,o.lineJoin=t,o.lineWidth=n,o.strokeStyle=o.createPattern(a.getCanvas(),"repeat"),o.stroke(),i=!1,r=!0},this.fillLayer=function(e){o.fillStyle=o.createPattern(e.getCanvas(),"repeat"),o.fill(),i=!1,r=!0},this.push=function(){o.save(),s++},this.pop=function(){s>0&&(o.restore(),s--)},this.reset=function(){for(;s>0;)o.restore(),s--;o.restore(),o.save(),o.beginPath(),r=!1},this.setTransform=function(e,t,n,a,i,r){o.setTransform(e,t,n,a,i,r)},this.transform=function(e,t,n,a,i,r){o.transform(e,t,n,a,i,r)},this.setChannelMask=function(e){o.globalCompositeOperation=u[e]},this.setMiterLimit=function(e){o.miterLimit=e},l(e,t),a.style.zIndex=-1},Guacamole.Layer.ROUT=2,Guacamole.Layer.ATOP=6,Guacamole.Layer.XOR=10,Guacamole.Layer.ROVER=11,Guacamole.Layer.OVER=14,Guacamole.Layer.PLUS=15,Guacamole.Layer.RIN=1,Guacamole.Layer.IN=4,Guacamole.Layer.OUT=8,Guacamole.Layer.RATOP=9,Guacamole.Layer.SRC=12,Guacamole.Layer.Pixel=function(e,t,n,a){this.red=e,this.green=t,this.blue=n,this.alpha=a},(Guacamole=Guacamole||{}).Mouse=function(e){Guacamole.Mouse.Event.Target.call(this);var t=this;this.touchMouseThreshold=3,this.scrollThreshold=53,this.PIXELS_PER_LINE=18,this.PIXELS_PER_PAGE=16*this.PIXELS_PER_LINE;var n=[Guacamole.Mouse.State.Buttons.LEFT,Guacamole.Mouse.State.Buttons.MIDDLE,Guacamole.Mouse.State.Buttons.RIGHT],a=0,o=0;function i(){a=t.touchMouseThreshold}function r(e){var n=e.deltaY||-e.wheelDeltaY||-e.wheelDelta;if(n?1===e.deltaMode?n=e.deltaY*t.PIXELS_PER_LINE:2===e.deltaMode&&(n=e.deltaY*t.PIXELS_PER_PAGE):n=e.detail*t.PIXELS_PER_LINE,(o+=n)<=-t.scrollThreshold){do{t.click(Guacamole.Mouse.State.Buttons.UP),o+=t.scrollThreshold}while(o<=-t.scrollThreshold);o=0}if(o>=t.scrollThreshold){do{t.click(Guacamole.Mouse.State.Buttons.DOWN),o-=t.scrollThreshold}while(o>=t.scrollThreshold);o=0}Guacamole.Event.DOMEvent.cancelEvent(e)}e.addEventListener("contextmenu",(function(e){Guacamole.Event.DOMEvent.cancelEvent(e)}),!1),e.addEventListener("mousemove",(function(n){if(a)return Guacamole.Event.DOMEvent.cancelEvent(n),void a--;t.move(Guacamole.Position.fromClientPosition(e,n.clientX,n.clientY),n)}),!1),e.addEventListener("mousedown",(function(e){if(a)Guacamole.Event.DOMEvent.cancelEvent(e);else{var o=n[e.button];o&&t.press(o,e)}}),!1),e.addEventListener("mouseup",(function(e){if(a)Guacamole.Event.DOMEvent.cancelEvent(e);else{var o=n[e.button];o&&t.release(o,e)}}),!1),e.addEventListener("mouseout",(function(n){n||(n=window.event);for(var a=n.relatedTarget||n.toElement;a;){if(a===e)return;a=a.parentNode}t