UNPKG

guacamole-common-js-jumpserver

Version:
1 lines 66.6 kB
var Guacamole;(Guacamole=Guacamole||{}).ArrayBufferReader=function(e){var r=this;e.onblob=function(e){for(var t=window.atob(e),n=new ArrayBuffer(t.length),a=new Uint8Array(n),o=0;o<t.length;o++)a[o]=t.charCodeAt(o);r.ondata&&r.ondata(n)},e.onend=function(){r.onend&&r.onend()},this.ondata=null,this.onend=null},(Guacamole=Guacamole||{}).ArrayBufferWriter=function(a){var o=this;function r(e){for(var t="",n=0;n<e.byteLength;n++)t+=String.fromCharCode(e[n]);a.sendBlob(window.btoa(t))}a.onack=function(e){o.onack&&o.onack(e)},this.blobLength=Guacamole.ArrayBufferWriter.DEFAULT_BLOB_LENGTH,this.sendData=function(e){var t=new Uint8Array(e);if(t.length<=o.blobLength)r(t);else for(var n=0;n<t.length;n+=o.blobLength)r(t.subarray(n,n+o.blobLength))},this.sendEnd=function(){a.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){function o(){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 d(t);return e.forEach(function(e){a.set(e,n),n+=e.length}),a}(r);return e?e=(r=function(e){for(var t=Number.MAX_VALUE,n=e.length,a=Math.floor(e.length/u.channels),o=Math.floor(.02*u.rate),r=Math.max(u.channels*o,u.channels*(a-o));r<e.length;r+=u.channels){for(var i=0,s=0;s<u.channels;s++)i+=Math.abs(e[r+s]);i<=t&&(n=r+u.channels,t=i)}return n===e.length?[e]:[new d(e.buffer.slice(0,n*u.bytesPerSample)),new d(e.buffer.slice(n*u.bytesPerSample))]}(e)).shift():null}var u=Guacamole.RawAudioFormat.parse(t),c=Guacamole.AudioContextFactory.getAudioContext(),l=c.currentTime,n=new Guacamole.ArrayBufferReader(e),d=1===u.bytesPerSample?window.Int8Array:window.Int16Array,f=1===u.bytesPerSample?128:32768,r=[];n.ondata=function(e){!function(e){r.push(new d(e))}(new d(e));var t=o();if(t){var n=c.currentTime;l<n&&(l=n);var a=c.createBufferSource();a.connect(c.destination),a.start||(a.start=a.noteOn),a.buffer=function(e){var t=e.length/u.channels,n=c.currentTime;l<n&&(l=n);for(var a=c.createBuffer(u.channels,t,u.rate),o=0;o<u.channels;o++)for(var r=a.getChannelData(o),i=o,s=0;s<t;s++)r[s]=e[i]/f,i+=u.channels;return a}(t),a.start(l),l+=t.length/u.channels/u.rate}},this.sync=function(){var e=c.currentTime;l=Math.min(l,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,u=Guacamole.RawAudioFormat.parse(t),a=Guacamole.AudioContextFactory.getAudioContext();navigator.mediaDevices||(navigator.mediaDevices={}),navigator.mediaDevices.getUserMedia||(navigator.mediaDevices.getUserMedia=(navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia).bind(navigator));function c(e){if(0===e)return 1;var t=Math.PI*e;return Math.sin(t)/t}function l(e,t){for(var n,a,o=(e.length-1)*t,r=Math.floor(o)-3+1,i=Math.floor(o)+3,s=0,u=r;u<=i;u++)s+=(e[u]||0)*(-(a=3)<(n=o-u)&&n<a?c(n)*c(n/a):0);return s}function o(){navigator.mediaDevices.getUserMedia({audio:!0},function(e){(p=a.createScriptProcessor(2048,u.channels,u.channels)).connect(a.destination),p.onaudioprocess=function(e){r.sendData(function(e){var t=e.length;h+=t;var n=Math.round(h*u.rate/e.sampleRate)-m;m+=n;for(var a=new d(n*u.channels),o=0;o<u.channels;o++)for(var r=e.getChannelData(o),i=o,s=0;s<n;s++)a[i]=l(r,s/(n-1))*f,i+=u.channels;return a}(e.inputBuffer).buffer)},(s=a.createMediaStreamSource(e)).connect(p),i=e},function(){r.sendEnd(),n.onerror&&n.onerror()})}var r=new Guacamole.ArrayBufferWriter(e),d=1===u.bytesPerSample?window.Int8Array:window.Int16Array,f=1===u.bytesPerSample?128:32768,h=0,m=0,i=null,s=null,p=null;r.onack=function(e){e.code!==Guacamole.Status.Code.SUCCESS||i?(function(){if(s&&s.disconnect(),p&&p.disconnect(),i)for(var e=i.getTracks(),t=0;t<e.length;t++)e[t].stop();i=s=p=null,r.sendEnd()}(),r.onack=null,e.code===Guacamole.Status.Code.RESOURCE_CLOSED?n.onclose&&n.onclose():n.onerror&&n.onerror()):o()}},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(r,n){var i,s=this,u=0;i=window.BlobBuilder?new BlobBuilder:window.WebKitBlobBuilder?new WebKitBlobBuilder:window.MozBlobBuilder?new MozBlobBuilder:new function(){var t=[];this.append=function(e){t.push(new Blob([e],{type:n}))},this.getBlob=function(){return new Blob(t,{type:n})}},r.onblob=function(e){for(var t=window.atob(e),n=new ArrayBuffer(t.length),a=new Uint8Array(n),o=0;o<t.length;o++)a[o]=t.charCodeAt(o);i.append(n),u+=n.byteLength,s.onprogress&&s.onprogress(n.byteLength),r.sendAck("OK",0)},r.onend=function(){s.onend&&s.onend()},this.getLength=function(){return u},this.getBlob=function(){return i.getBlob()},this.onprogress=null,this.onend=null},(Guacamole=Guacamole||{}).BlobWriter=function(e){var r=this,i=new Guacamole.ArrayBufferWriter(e);i.onack=function(e){r.onack&&r.onack(e)};this.sendBlob=function(t){function n(){if(a>=t.size)r.oncomplete&&r.oncomplete(t);else{var e=function(e,t,n){var a=(e.slice||e.webkitSlice||e.mozSlice).bind(e),o=n-t;if(o!==n){var r=a(t,o);if(r.size===o)return r}return a(t,n)}(t,a,a+i.blobLength);a+=i.blobLength,o.readAsArrayBuffer(e)}}var a=0,o=new FileReader;o.onload=function(){i.sendData(o.result),i.onack=function(e){r.onack&&r.onack(e),e.isError()||(r.onprogress&&r.onprogress(t,a-i.blobLength),n())}},o.onerror=function(){r.onerror&&r.onerror(t,a,o.error)},n()},this.sendEnd=function(){i.sendEnd()},this.onack=null,this.onerror=null,this.onprogress=null,this.oncomplete=null},(Guacamole=Guacamole||{}).Client=function(o){var c=this,t=2,a=3,u=0,l=0,n=null,d={0:"butt",1:"round",2:"square"},f={0:"bevel",1:"miter",2:"round"},h=new Guacamole.Display,m={},r={},i={},s=[],p=[],g=[],v=new Guacamole.IntegerPool,y=[];function w(e){e!=u&&(u=e,c.onstatechange&&c.onstatechange(u))}function S(){return u==a||u==t}this.exportState=function(r){var i={currentState:u,currentTimestamp:l,layers:{}},s={};for(var e in m)s[e]=m[e];h.flush(function(){for(var e in s){var t=parseInt(e),n=s[e],a=n.toCanvas(),o={width:n.width,height:n.height};n.width&&n.height&&(o.url=a.toDataURL("image/png")),0<t&&(o.x=n.x,o.y=n.y,o.z=n.z,o.alpha=n.alpha,o.matrix=n.matrix,o.parent=b(n.parent)),i.layers[e]=o}r(i)})},this.importState=function(e,t){var n,a;for(n in u=e.currentState,l=e.currentTimestamp,m)0<(a=parseInt(n))&&h.dispose(m[n]);for(n in m={},e.layers){a=parseInt(n);var o=e.layers[n],r=T(a);if(h.resize(r,o.width,o.height),o.url&&(h.setChannelMask(r,Guacamole.Layer.SRC),h.draw(r,0,0,o.url)),0<a&&0<=o.parent){var i=T(o.parent);h.move(r,i,o.x,o.y,o.z),h.shade(r,o.alpha);var s=o.matrix;h.distort(r,s[0],s[1],s[2],s[3],s[4],s[5])}}h.flush(t)},this.getDisplay=function(){return h},this.sendSize=function(e,t){S()&&o.sendMessage("size",e,t)},this.sendKeyEvent=function(e,t){S()&&o.sendMessage("key",t,e)},this.sendMouseState=function(e){if(S()){h.moveCursor(Math.floor(e.x),Math.floor(e.y));var t=0;e.left&&(t|=1),e.middle&&(t|=2),e.right&&(t|=4),e.up&&(t|=8),e.down&&(t|=16),o.sendMessage("mouse",Math.floor(e.x),Math.floor(e.y),t)}},this.createOutputStream=function(){var e=v.next();return y[e]=new Guacamole.OutputStream(c,e)},this.createAudioStream=function(e){var t=c.createOutputStream();return o.sendMessage("audio",t.index,e),t},this.createFileStream=function(e,t){var n=c.createOutputStream();return o.sendMessage("file",n.index,e,t),n},this.createPipeStream=function(e,t){var n=c.createOutputStream();return o.sendMessage("pipe",n.index,e,t),n},this.createClipboardStream=function(e){var t=c.createOutputStream();return o.sendMessage("clipboard",t.index,e),t},this.createArgumentValueStream=function(e,t){var n=c.createOutputStream();return o.sendMessage("argv",n.index,e,t),n},this.createObjectOutputStream=function(e,t,n){var a=c.createOutputStream();return o.sendMessage("put",e,a.index,t,n),a},this.requestObjectInputStream=function(e,t){S()&&o.sendMessage("get",e,t)},this.sendAck=function(e,t,n){S()&&o.sendMessage("ack",e,t,n)},this.sendBlob=function(e,t){S()&&o.sendMessage("blob",e,t)},this.endStream=function(e){S()&&(o.sendMessage("end",e),y[e]&&(v.free(e),delete y[e]))},this.onstatechange=null,this.onname=null,this.onerror=null,this.onaudio=null,this.onvideo=null,this.onargv=null,this.onclipboard=null,this.onfile=null,this.onfilesystem=null,this.onpipe=null,this.onsync=null;var T=function(e){var t=m[e];return t||(t=0===e?h.getDefaultLayer():0<e?h.createLayer():h.createBuffer(),m[e]=t),t},b=function(e){if(!e)return null;for(var t in m)if(e===m[t])return parseInt(t);return null};var G={"miter-limit":function(e,t){h.setMiterLimit(e,parseFloat(t))}},I={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)),256<=a&&y[t]===o&&(v.free(t),delete y[t]))},arc:function(e){var t=T(parseInt(e[0])),n=parseInt(e[1]),a=parseInt(e[2]),o=parseInt(e[3]),r=parseFloat(e[4]),i=parseFloat(e[5]),s=parseInt(e[6]);h.arc(t,n,a,o,r,i,0!=s)},argv:function(e){var t=parseInt(e[0]),n=e[1],a=e[2];if(c.onargv){var o=p[t]=new Guacamole.InputStream(c,t);c.onargv(o,n,a)}else c.sendAck(t,"Receiving argument values unsupported",256)},audio:function(e){var t=parseInt(e[0]),n=e[1],a=p[t]=new Guacamole.InputStream(c,t),o=null;c.onaudio&&(o=c.onaudio(a,n)),(o=o||Guacamole.AudioPlayer.getInstance(a,n))?(r[t]=o,c.sendAck(t,"OK",0)):c.sendAck(t,"BAD TYPE",783)},blob:function(e){var t=parseInt(e[0]),n=e[1],a=p[t];a&&a.onblob&&a.onblob(n)},body:function(e){var t=parseInt(e[0]),n=g[t],a=parseInt(e[1]),o=e[2],r=e[3];if(n&&n.onbody){var i=p[a]=new Guacamole.InputStream(c,a);n.onbody(i,o,r)}else c.sendAck(a,"Receipt of body unsupported",256)},cfill:function(e){var t=parseInt(e[0]),n=T(parseInt(e[1])),a=parseInt(e[2]),o=parseInt(e[3]),r=parseInt(e[4]),i=parseInt(e[5]);h.setChannelMask(n,t),h.fillColor(n,a,o,r,i)},clip:function(e){var t=T(parseInt(e[0]));h.clip(t)},clipboard:function(e){var t=parseInt(e[0]),n=e[1];if(c.onclipboard){var a=p[t]=new Guacamole.InputStream(c,t);c.onclipboard(a,n)}else c.sendAck(t,"Clipboard unsupported",256)},close:function(e){var t=T(parseInt(e[0]));h.close(t)},copy:function(e){var t=T(parseInt(e[0])),n=parseInt(e[1]),a=parseInt(e[2]),o=parseInt(e[3]),r=parseInt(e[4]),i=parseInt(e[5]),s=T(parseInt(e[6])),u=parseInt(e[7]),c=parseInt(e[8]);h.setChannelMask(s,i),h.copy(t,n,a,o,r,s,u,c)},cstroke:function(e){var t=parseInt(e[0]),n=T(parseInt(e[1])),a=d[parseInt(e[2])],o=f[parseInt(e[3])],r=parseInt(e[4]),i=parseInt(e[5]),s=parseInt(e[6]),u=parseInt(e[7]),c=parseInt(e[8]);h.setChannelMask(n,t),h.strokeColor(n,a,o,r,i,s,u,c)},cursor:function(e){var t=parseInt(e[0]),n=parseInt(e[1]),a=T(parseInt(e[2])),o=parseInt(e[3]),r=parseInt(e[4]),i=parseInt(e[5]),s=parseInt(e[6]);h.setCursor(t,n,a,o,r,i,s)},curve:function(e){var t=T(parseInt(e[0])),n=parseInt(e[1]),a=parseInt(e[2]),o=parseInt(e[3]),r=parseInt(e[4]),i=parseInt(e[5]),s=parseInt(e[6]);h.curveTo(t,n,a,o,r,i,s)},disconnect:function(e){c.disconnect()},dispose:function(e){var t=parseInt(e[0]);if(0<t){var n=T(t);h.dispose(n),delete m[t]}else t<0&&delete m[t]},distort:function(e){var t=parseInt(e[0]),n=parseFloat(e[1]),a=parseFloat(e[2]),o=parseFloat(e[3]),r=parseFloat(e[4]),i=parseFloat(e[5]),s=parseFloat(e[6]);if(0<=t){var u=T(t);h.distort(u,n,a,o,r,i,s)}},error:function(e){var t=e[0],n=parseInt(e[1]);c.onerror&&c.onerror(new Guacamole.Status(n,t)),c.disconnect()},end:function(e){var t=parseInt(e[0]),n=p[t];n&&(n.onend&&n.onend(),delete p[t])},file:function(e){var t=parseInt(e[0]),n=e[1],a=e[2];if(c.onfile){var o=p[t]=new Guacamole.InputStream(c,t);c.onfile(o,n,a)}else c.sendAck(t,"File transfer unsupported",256)},filesystem:function(e){var t=parseInt(e[0]),n=e[1];if(c.onfilesystem){var a=g[t]=new Guacamole.Object(c,t);c.onfilesystem(a,n)}},identity:function(e){var t=T(parseInt(e[0]));h.setTransform(t,1,0,0,1,0,0)},img:function(e){var t=parseInt(e[0]),n=parseInt(e[1]),a=T(parseInt(e[2])),o=e[3],r=parseInt(e[4]),i=parseInt(e[5]),s=p[t]=new Guacamole.InputStream(c,t),u=new Guacamole.DataURIReader(s,o);u.onend=function(){h.setChannelMask(a,n),h.draw(a,r,i,u.getURI())}},jpeg:function(e){var t=parseInt(e[0]),n=T(parseInt(e[1])),a=parseInt(e[2]),o=parseInt(e[3]),r=e[4];h.setChannelMask(n,t),h.draw(n,a,o,"data:image/jpeg;base64,"+r)},lfill:function(e){var t=parseInt(e[0]),n=T(parseInt(e[1])),a=T(parseInt(e[2]));h.setChannelMask(n,t),h.fillLayer(n,a)},line:function(e){var t=T(parseInt(e[0])),n=parseInt(e[1]),a=parseInt(e[2]);h.lineTo(t,n,a)},lstroke:function(e){var t=parseInt(e[0]),n=T(parseInt(e[1])),a=T(parseInt(e[2]));h.setChannelMask(n,t),h.strokeLayer(n,a)},mouse:function(e){var t=parseInt(e[0]),n=parseInt(e[1]);h.showCursor(!0),h.moveCursor(t,n)},move:function(e){var t=parseInt(e[0]),n=parseInt(e[1]),a=parseInt(e[2]),o=parseInt(e[3]),r=parseInt(e[4]);if(0<t&&0<=n){var i=T(t),s=T(n);h.move(i,s,a,o,r)}},name:function(e){c.onname&&c.onname(e[0])},nest:function(e){(function(e){var t=s[e];return null==t&&((t=s[e]=new Guacamole.Parser).oninstruction=o.oninstruction),t})(parseInt(e[0])).receive(e[1])},pipe:function(e){var t=parseInt(e[0]),n=e[1],a=e[2];if(c.onpipe){var o=p[t]=new Guacamole.InputStream(c,t);c.onpipe(o,n,a)}else c.sendAck(t,"Named pipes unsupported",256)},png:function(e){var t=parseInt(e[0]),n=T(parseInt(e[1])),a=parseInt(e[2]),o=parseInt(e[3]),r=e[4];h.setChannelMask(n,t),h.draw(n,a,o,"data:image/png;base64,"+r)},pop:function(e){var t=T(parseInt(e[0]));h.pop(t)},push:function(e){var t=T(parseInt(e[0]));h.push(t)},rect:function(e){var t=T(parseInt(e[0])),n=parseInt(e[1]),a=parseInt(e[2]),o=parseInt(e[3]),r=parseInt(e[4]);h.rect(t,n,a,o,r)},reset:function(e){var t=T(parseInt(e[0]));h.reset(t)},set:function(e){var t=T(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(0<=t){var a=T(t);h.shade(a,n)}},size:function(e){var t=parseInt(e[0]),n=T(t),a=parseInt(e[1]),o=parseInt(e[2]);h.resize(n,a,o)},start:function(e){var t=T(parseInt(e[0])),n=parseInt(e[1]),a=parseInt(e[2]);h.moveTo(t,n,a)},sync:function(e){var n=parseInt(e[0]);h.flush(function(){for(var e in r){var t=r[e];t&&t.sync()}n!==l&&(o.sendMessage("sync",n),l=n)}),u===t&&w(a),c.onsync&&c.onsync(n)},transfer:function(e){var t=T(parseInt(e[0])),n=parseInt(e[1]),a=parseInt(e[2]),o=parseInt(e[3]),r=parseInt(e[4]),i=parseInt(e[5]),s=T(parseInt(e[6])),u=parseInt(e[7]),c=parseInt(e[8]);3===i?h.put(t,n,a,o,r,s,u,c):5!==i&&h.transfer(t,n,a,o,r,s,u,c,Guacamole.Client.DefaultTransferFunction[i])},transform:function(e){var t=T(parseInt(e[0])),n=parseFloat(e[1]),a=parseFloat(e[2]),o=parseFloat(e[3]),r=parseFloat(e[4]),i=parseFloat(e[5]),s=parseFloat(e[6]);h.transform(t,n,a,o,r,i,s)},undefine:function(e){var t=parseInt(e[0]),n=g[t];n&&n.onundefine&&n.onundefine()},video:function(e){var t=parseInt(e[0]),n=T(parseInt(e[1])),a=e[2],o=p[t]=new Guacamole.InputStream(c,t),r=null;c.onvideo&&(r=c.onvideo(o,n,a)),(r=r||Guacamole.VideoPlayer.getInstance(o,n,a))?(i[t]=r,c.sendAck(t,"OK",0)):c.sendAck(t,"BAD TYPE",783)}};o.oninstruction=function(e,t){var n=I[e];n&&n(t)},this.disconnect=function(){5!=u&&4!=u&&(w(4),n&&window.clearInterval(n),o.sendMessage("disconnect"),o.disconnect(),w(5))},this.connect=function(e){w(1);try{o.connect(e)}catch(e){throw w(0),e}n=window.setInterval(function(){o.sendMessage("nop")},5e3),w(t)}},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=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 s=this,a=0,o=0,r=1,i=document.createElement("div");i.style.position="relative",i.style.width=a+"px",i.style.height=o+"px",i.style.transformOrigin=i.style.webkitTransformOrigin=i.style.MozTransformOrigin=i.style.OTransformOrigin=i.style.msTransformOrigin="0 0";var c=new Guacamole.Display.VisibleLayer(a,o),u=new Guacamole.Display.VisibleLayer(0,0);u.setChannelMask(Guacamole.Layer.SRC),i.appendChild(c.getElement()),i.appendChild(u.getElement());var l=document.createElement("div");l.style.position="relative",l.style.width=a*r+"px",l.style.height=o*r+"px",l.appendChild(i),this.cursorHotspotX=0,this.cursorHotspotY=0,this.cursorX=0,this.cursorY=0,this.onresize=null,this.oncursor=null;var d=[],n=[];function f(){for(var e=0;e<n.length;){var t=n[e];if(!t.isReady())break;t.flush(),e++}n.splice(0,e)}function t(t,n){this.isReady=function(){for(var e=0;e<n.length;e++)if(n[e].blocked)return!1;return!0},this.flush=function(){for(var e=0;e<n.length;e++)n[e].execute();t&&t()}}function h(e,t){var n=this;this.blocked=t,this.unblock=function(){n.blocked&&(n.blocked=!1,f())},this.execute=function(){e&&e()}}function m(e,t){var n=new h(e,t);return d.push(n),n}this.getElement=function(){return l},this.getWidth=function(){return a},this.getHeight=function(){return o},this.getDefaultLayer=function(){return c},this.getCursorLayer=function(){return u},this.createLayer=function(){var e=new Guacamole.Display.VisibleLayer(a,o);return e.move(c,0,0,0),e},this.createBuffer=function(){var e=new Guacamole.Layer(0,0);return e.autosize=1,e},this.flush=function(e){n.push(new t(e,d)),d=[],f()},this.setCursor=function(e,t,n,a,o,r,i){m(function(){s.cursorHotspotX=e,s.cursorHotspotY=t,u.resize(r,i),u.copy(n,a,o,r,i,0,0),s.moveCursor(s.cursorX,s.cursorY),s.oncursor&&s.oncursor(u.toCanvas(),e,t)})},this.showCursor=function(e){var t=u.getElement(),n=t.parentNode;!1===e?n&&n.removeChild(t):n!==i&&i.appendChild(t)},this.moveCursor=function(e,t){u.translate(e-s.cursorHotspotX,t-s.cursorHotspotY),s.cursorX=e,s.cursorY=t},this.resize=function(e,t,n){m(function(){e.resize(t,n),e===c&&(a=t,o=n,i.style.width=a+"px",i.style.height=o+"px",l.style.width=a*r+"px",l.style.height=o*r+"px",s.onresize&&s.onresize(t,n))})},this.drawImage=function(e,t,n,a){m(function(){e.drawImage(t,n,a)})},this.drawBlob=function(e,t,n,a){var o=URL.createObjectURL(a),r=m(function(){i.width&&i.height&&e.drawImage(t,n,i),URL.revokeObjectURL(o)},!0),i=new Image;i.onload=r.unblock,i.onerror=r.unblock,i.src=o},this.draw=function(e,t,n,a){var o=m(function(){r.width&&r.height&&e.drawImage(t,n,r)},!0),r=new Image;r.onload=o.unblock,r.onerror=o.unblock,r.src=a},this.play=function(t,e,n,a){var o=document.createElement("video");o.type=e,o.src=a,o.addEventListener("play",function(){!function e(){t.drawImage(0,0,o),o.ended||window.setTimeout(e,20)}()},!1),m(o.play)},this.transfer=function(e,t,n,a,o,r,i,s,u){m(function(){r.transfer(e,t,n,a,o,i,s,u)})},this.put=function(e,t,n,a,o,r,i,s){m(function(){r.put(e,t,n,a,o,i,s)})},this.copy=function(e,t,n,a,o,r,i,s){m(function(){r.copy(e,t,n,a,o,i,s)})},this.moveTo=function(e,t,n){m(function(){e.moveTo(t,n)})},this.lineTo=function(e,t,n){m(function(){e.lineTo(t,n)})},this.arc=function(e,t,n,a,o,r,i){m(function(){e.arc(t,n,a,o,r,i)})},this.curveTo=function(e,t,n,a,o,r,i){m(function(){e.curveTo(t,n,a,o,r,i)})},this.close=function(e){m(function(){e.close()})},this.rect=function(e,t,n,a,o){m(function(){e.rect(t,n,a,o)})},this.clip=function(e){m(function(){e.clip()})},this.strokeColor=function(e,t,n,a,o,r,i,s){m(function(){e.strokeColor(t,n,a,o,r,i,s)})},this.fillColor=function(e,t,n,a,o){m(function(){e.fillColor(t,n,a,o)})},this.strokeLayer=function(e,t,n,a,o){m(function(){e.strokeLayer(t,n,a,o)})},this.fillLayer=function(e,t){m(function(){e.fillLayer(t)})},this.push=function(e){m(function(){e.push()})},this.pop=function(e){m(function(){e.pop()})},this.reset=function(e){m(function(){e.reset()})},this.setTransform=function(e,t,n,a,o,r,i){m(function(){e.setTransform(t,n,a,o,r,i)})},this.transform=function(e,t,n,a,o,r,i){m(function(){e.transform(t,n,a,o,r,i)})},this.setChannelMask=function(e,t){m(function(){e.setChannelMask(t)})},this.setMiterLimit=function(e,t){m(function(){e.setMiterLimit(t)})},this.dispose=function(e){m(function(){e.dispose()})},this.distort=function(e,t,n,a,o,r,i){m(function(){e.distort(t,n,a,o,r,i)})},this.move=function(e,t,n,a,o){m(function(){e.move(t,n,a,o)})},this.shade=function(e,t){m(function(){e.shade(t)})},this.scale=function(e){i.style.transform=i.style.WebkitTransform=i.style.MozTransform=i.style.OTransform=i.style.msTransform="scale("+e+","+e+")",r=e,l.style.width=a*r+"px",l.style.height=o*r+"px"},this.getScale=function(){return r},this.flatten=function(){var e=document.createElement("canvas");e.width=c.width,e.height=c.height;var u=e.getContext("2d");return function e(t,n,a){if(0<t.width&&0<t.height){var o=u.globalAlpha;u.globalAlpha*=t.alpha/255,u.drawImage(t.getCanvas(),n,a);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}(t),i=0;i<r.length;i++){var s=r[i];e(s,n+s.x,a+s.y)}u.globalAlpha=o}}(c,0,0),e}},Guacamole.Display.VisibleLayer=function(e,t){Guacamole.Layer.apply(this,[e,t]);var i=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 n=i.getCanvas();n.style.position="absolute",n.style.left="0px",n.style.top="0px";var s=document.createElement("div");s.appendChild(n),s.style.width=e+"px",s.style.height=t+"px",s.style.position="absolute",s.style.left="0px",s.style.top="0px",s.style.overflow="hidden";var a=this.resize;this.resize=function(e,t){s.style.width=e+"px",s.style.height=t+"px",a(e,t)},this.getElement=function(){return s};var u="translate(0px, 0px)",c="matrix(1, 0, 0, 1, 0, 0)";this.translate=function(e,t){i.x=e,i.y=t,u="translate("+e+"px,"+t+"px)",s.style.transform=s.style.WebkitTransform=s.style.MozTransform=s.style.OTransform=s.style.msTransform=u+" "+c},this.move=function(e,t,n,a){i.parent!==e&&(i.parent&&delete i.parent.children[i.__unique_id],(i.parent=e).children[i.__unique_id]=i,e.getElement().appendChild(s));i.translate(t,n),i.z=a,s.style.zIndex=a},this.shade=function(e){i.alpha=e,s.style.opacity=e/255},this.dispose=function(){i.parent&&(delete i.parent.children[i.__unique_id],i.parent=null),s.parentNode&&s.parentNode.removeChild(s)},this.distort=function(e,t,n,a,o,r){i.matrix=[e,t,n,a,o,r],c="matrix("+e+","+t+","+n+","+a+","+o+","+r+")",s.style.transform=s.style.WebkitTransform=s.style.MozTransform=s.style.OTransform=s.style.msTransform=u+" "+c}},Guacamole.Display.VisibleLayer.__next_id=0,(Guacamole=Guacamole||{}).InputSink=function(){var a=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(e){var t=document.activeElement;if(t&&t!==document.body){var n=t.getBoundingClientRect();if(0<n.left+n.width&&0<n.top+n.height)return}a.focus()},!0)},(Guacamole=Guacamole||{}).InputStream=function(n,e){var a=this;this.index=e,this.onblob=null,this.onend=null,this.sendAck=function(e,t){n.sendAck(a.index,e,t)}},(Guacamole=Guacamole||{}).IntegerPool=function(){var e=this,t=[];this.next_int=0,this.next=function(){return 0<t.length?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||{}).Keyboard=function(e){var i=this,t="_GUAC_KEYBOARD_HANDLED_BY_"+Guacamole.Keyboard._nextID++;this.onkeydown=null,this.onkeyup=null;var r={keyupUnreliable:!1,altIsTypableOnly:!1,capsLockKeyupUnreliable:!1};navigator&&navigator.platform&&(navigator.platform.match(/ipad|iphone|ipod/i)?r.keyupUnreliable=!0:navigator.platform.match(/^mac/i)&&(r.altIsTypableOnly=!0,r.capsLockKeyupUnreliable=!0));function s(){var e=this;this.timestamp=(new Date).getTime(),this.defaultPrevented=!1,this.keysym=null,this.reliable=!1,this.getAge=function(){return(new Date).getTime()-e.timestamp}}function u(e,t,n,a){s.apply(this),this.keyCode=e,this.keyIdentifier=t,this.key=n,this.location=a,this.keysym=w(n,a)||T(e,a),this.keyupReliable=!r.keyupUnreliable,this.keysym&&!y(this.keysym)&&(this.reliable=!0),!this.keysym&&b(e,t)&&(this.keysym=w(t,a,i.modifiers.shift)),i.modifiers.meta&&65511!==this.keysym&&65512!==this.keysym?this.keyupReliable=!1:65509===this.keysym&&r.capsLockKeyupUnreliable&&(this.keyupReliable=!1);var o=!i.modifiers.ctrl&&!r.altIsTypableOnly;(!i.modifiers.alt&&i.modifiers.ctrl||o&&i.modifiers.alt||i.modifiers.meta||i.modifiers.hyper)&&(this.reliable=!0),m[e]=this.keysym}u.prototype=new s;function c(e){s.apply(this),this.charCode=e,this.keysym=S(e),this.reliable=!0}c.prototype=new s;function l(e,t,n,a){s.apply(this),this.keyCode=e,this.keyIdentifier=t,this.key=n,this.location=a,this.keysym=T(e,a)||w(n,a),i.pressed[this.keysym]||(this.keysym=m[e]||this.keysym),this.reliable=!0}l.prototype=new s;var d=[],n={8:[65288],9:[65289],12:[65291,65291,65291,65461],13:[65293],16:[65505,65505,65506],17:[65507,65507,65508],18:[65513,65513,65027],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:[65515],92:[65383],93:null,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]},f={Again:[65382],AllCandidates:[65341],Alphanumeric:[65328],Alt:[65513,65513,65027],Attn:[64782],AltGraph:[65027],ArrowDown:[65364],ArrowLeft:[65361],ArrowRight:[65363],ArrowUp:[65362],Backspace:[65288],CapsLock:[65509],Cancel:[65385],Clear:[65291],Convert:[65313],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],NumLock:[65407],PageDown:[65366],PageUp:[65365],Pause:[65299],Play:[64790],PreviousCandidate:[65342],PrintScreen:[65377],Redo:[65382],Right:[65363],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:[65515],Zenkaku:[65320],ZenkakuHankaku:[65322]},a={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 h={},o={},m={},p=null,g=null,v=function(e,t){return e?e[t]||e[0]:null},y=function(e){return 0<=e&&e<=255||16777216==(4294901760&e)};function w(e,t,n){if(!e)return null;var a,o=e.indexOf("U+");if(0<=o){var r=e.substring(o+2);a=String.fromCharCode(parseInt(r,16))}else{if(1!==e.length||3===t)return v(f[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||127<=e&&e<=159}(e)?65280|e:0<=e&&e<=255?e:256<=e&&e<=1114111?16777216|e:null}function T(e,t){return v(n[e],t)}var b=function(e,t){if(!t)return!1;var n=t.indexOf("U+");return-1===n||(e!==parseInt(t.substring(n+2),16)||(65<=e&&e<=90||48<=e&&e<=57))};this.press=function(e){if(null!==e){if(i.pressed[e]||(i.pressed[e]=!0,!i.onkeydown))return o[e]||!1;var t=i.onkeydown(e);return o[e]=t,window.clearTimeout(p),window.clearInterval(g),a[e]||(p=window.setTimeout(function(){g=window.setInterval(function(){i.onkeyup(e),i.onkeydown(e)},50)},500)),t}},this.release=function(e){i.pressed[e]&&(delete i.pressed[e],delete h[e],window.clearTimeout(p),window.clearInterval(g),null!==e&&i.onkeyup&&i.onkeyup(e))},this.type=function(e){for(var t=0;t<e.length;t++){var n=S(e.codePointAt?e.codePointAt(t):e.charCodeAt(t));i.press(n),i.release(n)}},this.reset=function(){for(var e in i.pressed)i.release(parseInt(e));d=[]};function G(e,t,n,a){var o;if(-1===n.indexOf(a.keysym))if(e&&!1===t)for(o=0;o<n.length;o++)i.release(n[o]);else if(!e&&t){for(o=0;o<n.length;o++)if(i.pressed[n[o]])return;var r=n[0];a.keysym&&(h[r]=!0),i.press(r)}}function I(e,t){var n=Guacamole.Keyboard.ModifierState.fromKeyboardEvent(e);G(i.modifiers.alt,n.alt,[65513,65514,65027],t),G(i.modifiers.shift,n.shift,[65505,65506],t),G(i.modifiers.ctrl,n.ctrl,[65507,65508],t),G(i.modifiers.meta,n.meta,[65511,65512],t),G(i.modifiers.hyper,n.hyper,[65515,65516],t),i.modifiers=n}var C=function(){for(var e in i.pressed)if(!h[e])return!1;return!0};function E(){var e,t=L();if(!t)return!1;for(;e=t,null!==(t=L()););return C()&&i.reset(),e.defaultPrevented}function k(e){return"location"in e?e.location:"keyLocation"in e?e.keyLocation:0}function A(e){return!e[t]&&(e[t]=!0)}var L=function(){var e=d[0];if(!e)return null;if(!(e instanceof u))return e instanceof l&&!r.keyupUnreliable?(t=e.keysym)?(i.release(t),delete m[e.keyCode],e.defaultPrevented=!0,d.shift()):(i.reset(),e):d.shift();var t=null,n=[];if(e.reliable?(t=e.keysym,n=d.splice(0,1)):d[1]instanceof c?(t=d[1].keysym,n=d.splice(0,2)):d[1]&&(t=e.keysym,n=d.splice(0,1)),0<n.length){if(t){!function(e){i.modifiers.ctrl&&i.modifiers.alt&&(65<=e&&e<=90||97<=e&&e<=122||(e<=255||16777216==(4278190080&e))&&(i.release(65507),i.release(65508),i.release(65513),i.release(65514)))}(t);var a=!i.press(t);m[e.keyCode]=t,e.keyupReliable||i.release(t);for(var o=0;o<n.length;o++)n[o].defaultPrevented=a}return e}return null};this.listenTo=function(t){t.addEventListener("keydown",function(e){if(i.onkeydown&&A(e)){var t;window.event?t=window.event.keyCode:e.which&&(t=e.which);var n=new u(t,e.keyIdentifier,e.key,k(e));I(e,n),229!==t&&(d.push(n),E()&&e.preventDefault())}},!0),t.addEventListener("keypress",function(e){if((i.onkeydown||i.onkeyup)&&A(e)){var t;window.event?t=window.event.keyCode:e.which&&(t=e.which);var n=new c(t);I(e,n),d.push(n),E()&&e.preventDefault()}},!0),t.addEventListener("keyup",function(e){if(i.onkeyup&&A(e)){var t;e.preventDefault(),window.event?t=window.event.keyCode:e.which&&(t=e.which);var n=new l(t,e.keyIdentifier,e.key,k(e));I(e,n),d.push(n),E()}},!0);function n(e){(i.onkeydown||i.onkeyup)&&A(e)&&e.data&&!e.isComposing&&(t.removeEventListener("compositionend",a,!1),i.type(e.data))}var a=function(e){(i.onkeydown||i.onkeyup)&&A(e)&&e.data&&(t.removeEventListener("input",n,!1),i.type(e.data))};t.addEventListener("input",n,!1),t.addEventListener("compositionend",a,!1)},e&&i.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 m=this,i=document.createElement("canvas"),p=i.getContext("2d");p.save();function n(e,t){e=e||0,t=t||0;var n=64*Math.ceil(e/64),a=64*Math.ceil(t/64);if(i.width!==n||i.height!==a){var o=null;if(!g&&0!==i.width&&0!==i.height)(o=document.createElement("canvas")).width=Math.min(m.width,e),o.height=Math.min(m.height,t),o.getContext("2d").drawImage(i,0,0,o.width,o.height,0,0,o.width,o.height);var r=p.globalCompositeOperation;i.width=n,i.height=a,o&&p.drawImage(o,0,0,o.width,o.height,0,0,o.width,o.height),p.globalCompositeOperation=r,u=0,p.save()}else m.reset();m.width=e,m.height=t}var g=!0,s=!0,u=0,a={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"};function v(e,t,n,a){var o,r,i=n+e,s=a+t;o=i>m.width?i:m.width,r=s>m.height?s:m.height,m.resize(o,r)}this.autosize=!1,this.width=e,this.height=t,this.getCanvas=function(){return i},this.toCanvas=function(){var e=document.createElement("canvas");return e.width=m.width,e.height=m.height,e.getContext("2d").drawImage(m.getCanvas(),0,0),e},this.resize=function(e,t){e===m.width&&t===m.height||n(e,t)},this.drawImage=function(e,t,n){m.autosize&&v(e,t,n.width,n.height),p.drawImage(n,e,t),g=!1},this.transfer=function(e,t,n,a,o,r,i,s){var u=e.getCanvas();if(!(t>=u.width||n>=u.height)&&(t+a>u.width&&(a=u.width-t),n+o>u.height&&(o=u.height-n),0!==a&&0!==o)){m.autosize&&v(r,i,a,o);for(var c=e.getCanvas().getContext("2d").getImageData(t,n,a,o),l=p.getImageData(r,i,a,o),d=0;d<a*o*4;d+=4){var f=new Guacamole.Layer.Pixel(c.data[d],c.data[d+1],c.data[d+2],c.data[d+3]),h=new Guacamole.Layer.Pixel(l.data[d],l.data[d+1],l.data[d+2],l.data[d+3]);s(f,h),l.data[d]=h.red,l.data[d+1]=h.green,l.data[d+2]=h.blue,l.data[d+3]=h.alpha}p.putImageData(l,r,i),g=!1}},this.put=function(e,t,n,a,o,r,i){var s=e.getCanvas();if(!(t>=s.width||n>=s.height)&&(t+a>s.width&&(a=s.width-t),n+o>s.height&&(o=s.height-n),0!==a&&0!==o)){m.autosize&&v(r,i,a,o);var u=e.getCanvas().getContext("2d").getImageData(t,n,a,o);p.putImageData(u,r,i),g=!1}},this.copy=function(e,t,n,a,o,r,i){var s=e.getCanvas();t>=s.width||n>=s.height||(t+a>s.width&&(a=s.width-t),n+o>s.height&&(o=s.height-n),0!==a&&0!==o&&(m.autosize&&v(r,i,a,o),p.drawImage(s,t,n,a,o,r,i,a,o),g=!1))},this.moveTo=function(e,t){s&&(p.beginPath(),s=!1),m.autosize&&v(e,t,0,0),p.moveTo(e,t)},this.lineTo=function(e,t){s&&(p.beginPath(),s=!1),m.autosize&&v(e,t,0,0),p.lineTo(e,t)},this.arc=function(e,t,n,a,o,r){s&&(p.beginPath(),s=!1),m.autosize&&v(e,t,0,0),p.arc(e,t,n,a,o,r)},this.curveTo=function(e,t,n,a,o,r){s&&(p.beginPath(),s=!1),m.autosize&&v(o,r,0,0),p.bezierCurveTo(e,t,n,a,o,r)},this.close=function(){p.closePath(),s=!0},this.rect=function(e,t,n,a){s&&(p.beginPath(),s=!1),m.autosize&&v(e,t,n,a),p.rect(e,t,n,a)},this.clip=function(){p.clip(),s=!0},this.strokeColor=function(e,t,n,a,o,r,i){p.lineCap=e,p.lineJoin=t,p.lineWidth=n,p.strokeStyle="rgba("+a+","+o+","+r+","+i/255+")",p.stroke(),s=!(g=!1)},this.fillColor=function(e,t,n,a){p.fillStyle="rgba("+e+","+t+","+n+","+a/255+")",p.fill(),s=!(g=!1)},this.strokeLayer=function(e,t,n,a){p.lineCap=e,p.lineJoin=t,p.lineWidth=n,p.strokeStyle=p.createPattern(a.getCanvas(),"repeat"),p.stroke(),s=!(g=!1)},this.fillLayer=function(e){p.fillStyle=p.createPattern(e.getCanvas(),"repeat"),p.fill(),s=!(g=!1)},this.push=function(){p.save(),u++},this.pop=function(){0<u&&(p.restore(),u--)},this.reset=function(){for(;0<u;)p.restore(),u--;p.restore(),p.save(),p.beginPath(),s=!1},this.setTransform=function(e,t,n,a,o,r){p.setTransform(e,t,n,a,o,r)},this.transform=function(e,t,n,a,o,r){p.transform(e,t,n,a,o,r)},this.setChannelMask=function(e){p.globalCompositeOperation=a[e]},this.setMiterLimit=function(e){p.miterLimit=e},n(e,t),i.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(o){var n=this;this.touchMouseThreshold=3,this.scrollThreshold=53,this.PIXELS_PER_LINE=18,this.PIXELS_PER_PAGE=16*this.PIXELS_PER_LINE,this.currentState=new Guacamole.Mouse.State(0,0,!1,!1,!1,!1,!1),this.onmousedown=null,this.onmouseup=null,this.onmousemove=null,this.onmouseout=null;var t=0,a=0;function r(e){e.stopPropagation(),e.preventDefault&&e.preventDefault(),e.returnValue=!1}function e(){t=n.touchMouseThreshold}function i(e){var t=e.deltaY||-e.wheelDeltaY||-e.wheelDelta;if(t?1===e.deltaMode?t=e.deltaY*n.PIXELS_PER_LINE:2===e.deltaMode&&(t=e.deltaY*n.PIXELS_PER_PAGE):t=e.detail*n.PIXELS_PER_LINE,(a+=t)<=-n.scrollThreshold){for(;n.onmousedown&&(n.currentState.up=!0,n.onmousedown(n.currentState)),n.onmouseup&&(n.currentState.up=!1,n.onmouseup(n.currentState)),(a+=n.scrollThreshold)<=-n.scrollThreshold;);a=0}if(a>=n.scrollThreshold){for(;n.onmousedown&&(n.currentState.down=!0,n.onmousedown(n.currentState)),n.onmouseup&&(n.currentState.down=!1,n.onmouseup(n.currentState)),(a-=n.scrollThreshold)>=n.scrollThreshold;);a=0}r(e)}o.addEventListener("contextmenu",function(e){r(e)},!1),o.addEventListener("mousemove",function(e){r(e),t?t--:(n.currentState.fromClientPosition(o,e.clientX,e.clientY),n.onmousemove&&n.onmousemove(n.currentState))},!1),o.addEventListener("mousedown",function(e){if(r(e),!t){switch(e.button){case 0:n.currentState.left=!0;break;case 1:n.currentState.middle=!0;break;case 2:n.currentState.right=!0}n.onmousedown&&n.onmousedown(n.currentState)}},!1),o.addEventListener("mouseup",function(e){if(r(e),!t){switch(e.button){case 0:n.currentState.left=!1;break;case 1:n.currentState.middle=!1;break;case 2:n.currentState.right=!1}n.onmouseup&&n.onmouseup(n.currentState)}},!1),o.addEventListener("mouseout",function(e){for(var t=(e=e||window.event).relatedTarget||e.toElement;t;){if(t===o)return;t=t.parentNode}r(e),(n.currentState.left||n.currentState.middle||n.currentState.right)&&(n.currentState.left=!1,n.currentState.middle=!1,n.currentState.right=!1,n.onmouseup&&n.onmouseup(n.currentState)),n.onmouseout&&n.onmouseout()},!1),o.addEventListener("selectstart",function(e){r(e)},!1),o.addEventListener("touchmove",e,!1),o.addEventListener("touchstart",e,!1),o.addEventListener("touchend",e,!1),o.addEventListener("DOMMouseScroll",i,!1),o.addEventListener("mousewheel",i,!1),o.addEventListener("wheel",i,!1);var s=function(){var e=document.createElement("div");if(!("cursor"in e.style))return!1;try{e.style.cursor="url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEX///+nxBvIAAAACklEQVQI12NgAAAAAgAB4iG8MwAAAABJRU5ErkJggg==) 0 0, auto"}catch(e){return!1}return/\burl\([^()]*\)\s+0\s+0\b/.test(e.style.cursor||"")}();this.setCursor=function(e,t,n){if(s){var a=e.toDataURL("image/png");return o.style.cursor="url("+a+") "+t+" "+n+", auto",!0}return!1}},Guacamole.Mouse.State=function(e,t,n,a,o,r,i){var s=this;this.x=e,this.y=t,this.left=n,this.middle=a,this.right=o,this.up=r,this.down=i,this.fromClientPosition=function(e,t,n){s.x=t-e.offsetLeft,s.y=n-e.offsetTop;for(var a=e.offsetParent;a&&a!==document.body;)s.x-=a.offsetLeft-a.scrollLeft,s.y-=a.offsetTop-a.scrollTop,a=a.offsetParent;if(a){var o=document.body.scrollLeft||document.documentElement.scrollLeft,r=document.body.scrollTop||document.documentElement.scrollTop;s.x-=a.offsetLeft-o,s.y-=a.offsetTop-r}}},Guacamole.Mouse.Touchpad=function(i){var s=this;this.scrollThreshold=20*(window.devicePixelRatio||1),this.clickTimingThreshold=250,this.clickMoveThreshold=10*(window.devicePixelRatio||1),this.currentState=new Guacamole.Mouse.State(0,0,!1,!1,!1,!1,!1),this.onmousedown=null,this.onmouseup=null,this.onmousemove=null;var u=0,c=0,l=0,d=0,f=0,a={1:"left",2:"right",3:"middle"},o=!1,r=null;i.addEventListener("touchend",function(e){if(e.preventDefault(),o&&0===e.touches.length){var t=(new Date).getTime(),n=a[u];s.currentState[n]&&(s.currentState[n]=!1,s.onmouseup&&s.onmouseup(s.currentState),r&&(window.clearTimeout(r),r=null)),t-d<=s.clickTimingThreshold&&f<s.clickMoveThreshold&&(s.currentState[n]=!0,s.onmousedown&&s.onmousedown(s.currentState),r=window.setTimeout(function(){s.currentState[n]=!1,s.onmouseup&&s.onmouseup(s.currentState),o=!1},s.clickTimingThreshold)),r||(o=!1)}},!1),i.addEventListener("touchstart",function(e){if(e.preventDefault(),u=Math.min(e.touches.length,3),r&&(window.clearTimeout(r),r=null),!o){o=!0;var t=e.touches[0];c=t.clientX,l=t.clientY,d=(new Date).getTime(),f=0}},!1),i.addEventListener("touchmove",function(e){e.preventDefault();var t=e.touches[0],n=t.clientX-c,a=t.clientY-l;if(f+=Math.abs(n)+Math.abs(a),1===u){var o=1+f/((new Date).getTime()-d);s.currentState.x+=n*o,s.currentState.y+=a*o,s.currentState.x<0?s.currentState.x=0:s.currentState.x>=i.offsetWidth&&(s.currentState.x=i.offsetWidth-1),s.currentState.y<0?s.currentState.y=0:s.currentState.y>=i.offsetHeight&&(s.currentState.y=i.offsetHeight-1),s.onmousemove&&s.onmousemove(s.currentState),c=t.clientX,l=t.clientY}else if(2===u){var r;if(Math.abs(a)>=s.scrollThreshold)r=0<a?"down":"up",s.currentState[r]=!0,s.onmousedown&&s.onmousedown(s.currentState),s.currentState[r]=!1,s.onmouseup&&s.onmouseup(s.currentState),c=t.clientX,l=t.clientY}},!1)},Guacamole.Mouse.Touchscreen=function(n){var o=this,a=!1,r=null,i=null,s=null,u=null;function c(e){o.currentState[e]||(o.currentState[e]=!0,o.onmousedown&&o.onmousedown(o.currentState))}function l(e){o.currentState[e]&&(o.currentState[e]=!1,o.onmouseup&&o.onmouseup(o.currentState))}function d(e,t){o.currentState.fromClientPosition(n,e,t),o.onmousemove&&o.onmousemove(o.currentState)}function f(e){var t=e.touches[0]||e.changedTouches[0],n=t.clientX-r,a=t.clientY-i;return Math.sqrt(n*n+a*a)>=o.clickMoveThreshold}function h(){window.clearTimeout(s),window.clearTimeout(u),a=!1}this.scrollThreshold=20*(window.devicePixelRatio||1),this.clickTimingThreshold=250,this.clickMoveThreshold=16*(window.devicePixelRatio||1),this.longPressThreshold=500,this.currentState=new Guacamole.Mouse.State(0,0,!1,!1,!1,!1,!1),this.onmousedown=null,this.onmouseup=null,this.onmousemove=null,n.addEventListener("touchend",function(e){if(a)if(0===e.touches.length&&1===e.changedTouches.length){if(window.clearTimeout(u),l("left"),!f(e)&&(e.preventDefault(),!o.currentState.left)){var t=e.changedTouches[0];d(t.clientX,t.clientY),c("left"),s=window.setTimeout(function(){l("left"),h()},o.clickTimingThreshold)}}else h()},!1),n.addEventListener("touchstart",function(t){1===t.touches.length?(t.preventDefault(),function(e){var t=e.touches[0];a=!0,r=t.clientX,i=t.clientY}(t),window.clearTimeout(s),u=window.setTimeout(function(){var e=t.touches[0];d(e.clientX,e.clientY),function(e){c(e),l(e)}("right"),h()},o.longPressThreshold)):h()},!1),n.addEventListener("touchmove",function(e){if(a)if(f(e)&&window.clearTimeout(u),1===e.touches.length){if(o.currentState.left){e.preventDefault();var t=e.touches[0];d(t.clientX,t.clientY)}}else h()},!1)},(Guacamole=(Guacamole=Guacamole||{})||{}).Object=function(n,e){var a=this,o={};this.index=e,this.onbody=function(e,t,n){var a=function(e){var t=o[e];if(!t)return null;var n=t.shift();return 0===t.length&&delete o[e],n}(n);a&&a(e,t)},this.onundefine=null,this.requestInputStream=function(e,t){t&&function(e,t){var n=o[e];n||(n=[],o[e]=n),n.push(t)}(e,t),n.requestObjectInputStream(a.index,e)},this.createOutputStream=function(e,t){return n.createObjectOutputStream(a.index,e,t)}},Guacamole.Object.ROOT_STREAM="/",Guacamole.Object.STREAM_INDEX_MIMETYPE="application/vnd.glyptodon.guacamole.stream-index+json",(Guacamole=Guacamole||{}).OnScreenKeyboard=function(a){function p(e,t){e.classList?e.classList.add(t):e.className+=" "+t}function r(e,n){e.classList?e.classList.remove(n):e.className=e.className.replace(/([^ ]+)[ ]*/g,function(e,t){return t===n?"":e})}function g(t,n,a,o){this.width=n,this.height=a,this.scale=function(e){t.style.width=n*e+"px",t.style.height=a*e+"px",o&&(t.style.lineHeight=a*e+"px",t.style.fontSize=e+"px")}}function o(e){for(var t=0;t<e.length;t++){if(!(e[t]in s))return!1}return!0}function i(e){var t=w.keys[e];if(!t)return null;for(var n=t.length-1;0<=n;n--){var a=t[n];if(o(a.requires))return a}return null}function v(e,t){if(!u[e]){p(t,"guac-keyboard-pressed");var n=i(e);if(n.modifier){var a="guac-keyboard-modifier-"+b(n.modifier),o=s[n.modifier];o?(r(c,a),delete s[n.modifier],w.onkeyup&&w.onkeyup(o)):(p(c,a),s[n.modifier]=n.keysym,w.onkeydown&&w.onkeydown(n.keysym))}else w.onkeydown&&w.onkeydown(n.keysym);u[e]=!0}}function y(e,t){if(u[e]){r(t,"guac-keyboard-pressed");var n=i(e);!n.modifier&&w.onkeyup&&w.onkeyup(n.keysym),u[e]=!1}}var w=this,s={},u={},S=[],T=0,c=document.createElement("div");c.className="guac-keyboard",c.onselectstart=c.onmousemove=c.onmouseup=c.onmousedown=function(e){return T&&T--,e.stopPropagation(),!1},this.touchMouseThreshold=3,this.onkeydown=null,this.onkeyup=null,this.layout=new Guacamole.OnScreenKeyboard.Layout(a),this.getElement=function(){return c},this.resize=function(e){for(var t=Math.floor(10*e/w.layout.width)/10,n=0;n<S.length;n++){S[n].scale(t)}};function l(e,t){if(t instanceof Array){for(var n=[],a=0;a<t.length;a++)n.push(new Guacamole.OnScreenKeyboard.Key(t[a],e));return n}return"number"==typeof t?[new Guacamole.OnScreenKeyboard.Key({name:e,keysym:t})]:"string"==typeof t?[new Guacamole.OnScreenKeyboard.Key({name:e,title:t})]:[new Guacamole.OnScreenKeyboard.Key(t,e)]}this.keys=function(e){var t={};for(var n in a.keys)t[n]=l(n,e[n]);return t}(a.keys);var b=function(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[^A-Za-z0-9]+/g,"-").toLowerCase()};!function e(t,n,a){var o,r=document.createElement("div");if(a&&p(r,"guac-keyboard-"+b(a)),n instanceof Array)for(p(r,"guac-keyboard-group"),o=0;o<n.length;o++)e(r,n[o]);else if(n instanceof Object){p(r,"guac-keyboard-group");var i=Object.keys(n).sort();for(o=0;o<i.length;o++){a=i[o];e(r,n[a],a)}}else if("number"==typeof n)p(r,"guac-keyboard-gap"),S.push(new g(r,n,n));else if("string"==typeof n){var s=n;1===s.length&&(s="0x"+s.charCodeAt(0).toString(16)),p(r,"guac-keyboard-key-container")