New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ray-streaming

Package Overview
Dependencies
Maintainers
3
Versions
115
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ray-streaming - npm Package Compare versions

Comparing version 2.0.0-beta.0 to 2.0.0

5

package.json
{
"name": "ray-streaming",
"license": "MIT",
"version": "2.0.0-beta.0",
"version": "2.0.0",
"author": "Kitsch <xc648593557@gmail.com>",

@@ -16,2 +16,5 @@ "description": "RayStreaming WebRTC implement",

},
"devDependencies": {
"@types/dom-mediacapture-record": "^1.0.11"
},
"keywords": [

@@ -18,0 +21,0 @@ "WebRTC",

2

ray-streaming.cjs.js

@@ -1,1 +0,1 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("webrtc-adapter"),t=require("rxjs"),n=require("rxjs/webSocket"),i=require("rxjs/operators"),o=require("resize-observer-polyfill");function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var s=r(e),a=r(o),u=function(){return u=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},u.apply(this,arguments)};function c(e,t,n,i){return new(n||(n=Promise))((function(o,r){function s(e){try{u(i.next(e))}catch(e){r(e)}}function a(e){try{u(i.throw(e))}catch(e){r(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}u((i=i.apply(e,t||[])).next())}))}function h(e,t){var n,i,o,r,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return r={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(r[Symbol.iterator]=function(){return this}),r;function a(r){return function(a){return function(r){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,i&&(o=2&r[0]?i.return:r[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,r[1])).done)return o;switch(i=0,o&&(r=[2&r[0],o.value]),r[0]){case 0:case 1:o=r;break;case 4:return s.label++,{value:r[1],done:!1};case 5:s.label++,i=r[1],r=[0];continue;case 7:r=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==r[0]&&2!==r[0])){s=0;continue}if(3===r[0]&&(!o||r[1]>o[0]&&r[1]<o[3])){s.label=r[1];break}if(6===r[0]&&s.label<o[1]){s.label=o[1],o=r;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(r);break}o[2]&&s.ops.pop(),s.trys.pop();continue}r=t.call(e,s)}catch(e){r=[6,e],i=0}finally{n=o=0}if(5&r[0])throw r[1];return{value:r[0]?r[1]:void 0,done:!0}}([r,a])}}}var p=Object.freeze({EnableLog:!0,AFKTimerGap:1e4});function l(e){return Object.keys(Array.from({length:e})).map((function(e){return Number(e)}))}var d=function(e){return new DataView(e).getUint8(0)};function f(e,t,n){void 0===t&&(t=1),void 0===n&&(n="");var i=new DataView(e);return l(e.byteLength-t).map((function(e){return String.fromCharCode(i.getUint8(e+t))})).join(n)}function m(e,t){void 0===t&&(t=!1);var n=e.target,i=n.getBoundingClientRect(),o=i.left,r=i.top,s=e.clientX,a=e.clientY,u=e.movementY,c=e.movementX,h=n.clientHeight,p=n.clientWidth,l=n.videoHeight,d=n.videoWidth;return{x:(t?d:65535)/p*(s-o),y:(t?l:65535)/h*(a-r),dx:c*((t?d:32767)/p),dy:u*((t?l:32767)/h)}}var v=function(){function e(e,t){this.x=e,this.y=t}return e.fromTouch=function(t){return new e(t.pageX,t.pageY)},e}();function y(e,t){return Math.hypot(t.x-e.x,t.y-e.y)}function w(e){var t=Array.from(e[0].targetTouches),n=t[0],i=t[1],o=Array.from(e[1].targetTouches),r=o[0],s=o[1];return y(v.fromTouch(r),v.fromTouch(s))-y(v.fromTouch(n),v.fromTouch(i))}function g(e){var t=e[0],n=e[1],i=n.targetTouches[0].clientX-t.targetTouches[0].clientX,o=n.targetTouches[0].clientY-t.targetTouches[0].clientY;return{target:t.target,clientX:t.targetTouches[0].clientX,clientY:t.targetTouches[0].clientY,movementX:i,movementY:o}}function b(e,t){var n="AS";return"firefox"===s.default.browserDetails.browser&&(t=1e3*(t>>>0),n="TIAS"),e=-1===e.indexOf("b="+n+":")?e.replace(/c=IN (.*)\r\n/,"c=IN $1\r\nb="+n+":"+t+"\r\n"):e.replace(new RegExp("b="+n+":.*\r\n"),"b="+n+":"+t+"\r\n")}var x,E,T,k,M,D,B=new(function(){function e(){this.APINameMap="exitFullscreen"in document?{requestFullscreen:"requestFullscreen",exitFullscreen:"exitFullscreen",fullscreenElement:"fullscreenElement",fullscreenEnabled:"fullscreenEnabled",fullscreenchange:"fullscreenchange"}:"webkitExitFullscreen"in document?{requestFullscreen:"webkitRequestFullscreen",exitFullscreen:"webkitExitFullscreen",fullscreenElement:"webkitFullscreenElement",fullscreenEnabled:"webkitFullscreenEnabled",fullscreenchange:"webkitfullscreenchange"}:{requestFullscreen:"mozRequestFullScreen",exitFullscreen:"mozCancelFullScreen",fullscreenElement:"mozFullScreenElement",fullscreenEnabled:"mozFullScreenEnabled",fullscreenchange:"mozfullscreenchange"}}return Object.defineProperty(e.prototype,"isFullscreen",{get:function(){return Boolean(document[this.APINameMap.fullscreenElement])},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"element",{get:function(){return document[this.APINameMap.fullscreenElement]},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isEnabled",{get:function(){return Boolean(document[this.APINameMap.fullscreenEnabled])},enumerable:!1,configurable:!0}),e.prototype.request=function(e,t){var n=this;return new Promise((function(i,o){var r=function(){screen.orientation.lock("landscape-primary"),document.removeEventListener(n.APINameMap.fullscreenchange,r),n.off(r),i()};n.on(r);var s=(e||document.documentElement)[n.APINameMap.requestFullscreen](t);s instanceof Promise&&s.then(r).catch(o)}))},e.prototype.exit=function(){var e=this;return new Promise((function(t,n){if(e.isFullscreen){var i=function(){e.off(i),t()};e.on(i);var o=document[e.APINameMap.exitFullscreen]();o instanceof Promise&&o.then(i).catch(n)}else t()}))},e.prototype.toggle=function(e,t){return this.isFullscreen?this.exit():this.request(e,t)},e.prototype.on=function(e){document.addEventListener(this.APINameMap.fullscreenchange,e)},e.prototype.off=function(e){document.removeEventListener(this.APINameMap.fullscreenchange,e)},e}()),L=function(){function e(){this.timer=NaN,this.idleTime=0}return e.prototype.reset=function(){this.idleTime=0},e.prototype.start=function(){var e=this;this.timer=window.setInterval((function(){e.idleTime+=1e3}),1e3)},e.prototype.clear=function(){window.clearInterval(this.timer)},e}(),C=function(){var e=this;this.promise=new Promise((function(t,n){e.resolve=t,e.reject=n}))},S=function(){function e(e){this.base64="",this.show=!1,this.x=0,this.y=0,this.parseCursorInfo(e)}return e.prototype.parseCursorInfo=function(t){var n=new DataView(t),i=[[1,4],[5,8],[9,12],[13,16],[17,20],[21,24],[25,28],[29,29]].reduce((function(t,i){return t.push(e.getImageInfo(n,i[0],i[1])),t}),[]),o=i[0],r=i[1],s=i[2],a=i[3],u=i[4],c=i[5],h=i[6],p=i[7];this.base64=e.arrayBuffer2base64(l(h).map((function(e){return n.getUint8(30+e)})),s,a,u,c),this.show=!!p,this.x=-o,this.y=-r},e.getImageInfo=function(e,t,n){return l(30).filter((function(e){return e>=t&&e<=n})).map((function(t){return e.getUint8(t)})).reduce((function(e,t,n){return e+=t*Math.pow(256,3-n)}),0)},e.arrayBuffer2base64=function(e,t,n,i,o){if(0===t||0===n)return"";if(1===i&&4===o)return"";var r=new Uint8Array(e),s=document.createElement("canvas");s.width=t,s.height=n;var a=s.getContext("2d"),u=null==a?void 0:a.createImageData(t,n);return null==u||u.data.set(r),u&&(null==a||a.putImageData(u,0,0)),s.toDataURL()},e}(),P=function(){var e=this;this.listeners=[],this.listenersOncer=[],this.on=function(t){return e.listeners.push(t),{dispose:function(){return e.off(t)}}},this.once=function(t){e.listenersOncer.push(t)},this.off=function(t){var n=e.listeners.indexOf(t);n>-1&&e.listeners.splice(n,1)},this.offAll=function(){e.listenersOncer=[],e.listeners=[]},this.emit=function(t){e.listeners.forEach((function(e){return e(t)})),e.listenersOncer.forEach((function(e){return e(t)})),e.listenersOncer=[]},this.pipe=function(t){return e.on((function(e){return t.emit(e)}))}},A=function(){function e(){this.currentID=0,this.executeMap=new Map}return e.prototype.obtainID=function(){return this.currentID>=65535?this.currentID=0:++this.currentID},e.prototype.trigger=function(e,t){this.executeMap.has(e)&&(this.executeMap.get(e).resolve(t),this.executeMap.delete(e))},e.prototype.order=function(e){var t=this.obtainID();return this.executeMap.set(t,e),t},e}(),I=function(){function e(e){this.element=e,this.movementX=0,this.movementY=0,this.onLockingChange=function(){},this.attachPointLockEvent()}return e.prototype.request=function(){this.isPointerLocking||this.requestPointerLock()},e.prototype.exit=function(){this.isPointerLocking&&this.exitPointerLock()},e.prototype.exitPointerLock=function(){document.exitPointerLock=document.exitPointerLock||document.mozExitPointerLock||document.webkitExitPointerLock,document.exitPointerLock()},e.prototype.requestPointerLock=function(){this.element.requestPointerLock=this.element.requestPointerLock||this.element.mozRequestPointerLock||this.element.webkitRequestPointerLock,this.element.requestPointerLock()},e.prototype.attachPointLockEvent=function(){var e=this,t=function(){e.requestPointerLock()},n=function(){document.addEventListener("click",t,{once:!0})},i=function(){e.isPointerLocking?(e.element.addEventListener("mousemove",e.mousemove),e.emit(!0),document.removeEventListener("click",t)):(e.element.removeEventListener("mousemove",e.mousemove),e.emit(!1))};document.addEventListener("pointerlockchange",i),document.addEventListener("mozpointerlockchange",i),document.addEventListener("webkitpointerlockchange",i),document.addEventListener("pointerlockerror",n),document.addEventListener("mozpointerlockerror",n)},e.prototype.on=function(e){this.onLockingChange=e},e.prototype.emit=function(e){this.onLockingChange(e)},e.prototype.mousemove=function(e){this.movementX=e.movementX,this.movementY=e.movementY},Object.defineProperty(e.prototype,"isPointerLocking",{get:function(){return(document.pointerLockElement||document.mozPointerLockElement||document.webkitPointerLockElement)===this.element},enumerable:!1,configurable:!0}),e}();exports.EventType=void 0,(x=exports.EventType||(exports.EventType={}))[x.MouseMoveStandardization=0]="MouseMoveStandardization",x[x.MouseButton=1]="MouseButton",x[x.WheelScroll=2]="WheelScroll",x[x.Keyboard=3]="Keyboard",x[x.WinTouch=4]="WinTouch",x[x.MobileTouch=5]="MobileTouch",x[x.MobileCustom=6]="MobileCustom",x[x.URLIntercept=7]="URLIntercept",x[x.CaretVisible=8]="CaretVisible",x[x.TextInput=9]="TextInput",x[x.MobileKeys=10]="MobileKeys",x[x.Gamepad=11]="Gamepad",x[x.CursorData=12]="CursorData",x[x.MouseMoveNormalization=13]="MouseMoveNormalization",x[x.EventDelay=14]="EventDelay",x[x.EchoData=15]="EchoData",x[x.KickOutController=16]="KickOutController",x[x.WebRTCPluginsMSG=125]="WebRTCPluginsMSG",x[x.WebRTCForwardRSP=126]="WebRTCForwardRSP",x[x.WebRTCForwardREQ=127]="WebRTCForwardREQ",exports.MouseButtonType=void 0,(E=exports.MouseButtonType||(exports.MouseButtonType={}))[E.ButtonLeft=1]="ButtonLeft",E[E.ButtonMiddle=2]="ButtonMiddle",E[E.ButtonRight=3]="ButtonRight",E[E.ButtonX1=4]="ButtonX1",E[E.ButtonX2=5]="ButtonX2",exports.TouchType=void 0,(T=exports.TouchType||(exports.TouchType={}))[T.TouchDown=0]="TouchDown",T[T.TouchUpdate=1]="TouchUpdate",T[T.TouchUp=2]="TouchUp",exports.MoveType=void 0,(k=exports.MoveType||(exports.MoveType={}))[k.Absolute=0]="Absolute",k[k.Relative=1]="Relative",k[k.Passive=2]="Passive",k[k.Unknow=3]="Unknow",exports.GamepadType=void 0,(M=exports.GamepadType||(exports.GamepadType={}))[M.GamepadXbox=0]="GamepadXbox",exports.GamepadXboxButton=void 0,(D=exports.GamepadXboxButton||(exports.GamepadXboxButton={}))[D.GamepadXboxButtonDpadUp=1]="GamepadXboxButtonDpadUp",D[D.GamepadXboxButtonDpadDown=2]="GamepadXboxButtonDpadDown",D[D.GamepadXboxButtonDpadLeft=4]="GamepadXboxButtonDpadLeft",D[D.GamepadXboxButtonDpadRight=8]="GamepadXboxButtonDpadRight",D[D.GamepadXboxButtonStart=16]="GamepadXboxButtonStart",D[D.GamepadXboxButtonBack=32]="GamepadXboxButtonBack",D[D.GamepadXboxButtonLeftThumb=64]="GamepadXboxButtonLeftThumb",D[D.GamepadXboxButtonRightThumb=128]="GamepadXboxButtonRightThumb",D[D.GamepadXboxButtonLeftShoulder=256]="GamepadXboxButtonLeftShoulder",D[D.GamepadXboxButtonRightShoulder=512]="GamepadXboxButtonRightShoulder",D[D.GamepadXboxButtonA=4096]="GamepadXboxButtonA",D[D.GamepadXboxButtonB=8192]="GamepadXboxButtonB",D[D.GamepadXboxButtonX=16384]="GamepadXboxButtonX",D[D.GamepadXboxButtonY=32768]="GamepadXboxButtonY";var R=new Map([[0,exports.MouseButtonType.ButtonLeft],[1,exports.MouseButtonType.ButtonMiddle],[2,exports.MouseButtonType.ButtonRight],[3,exports.MouseButtonType.ButtonX1],[4,exports.MouseButtonType.ButtonX2]]),X=function(){function e(e,t){void 0===t&&(t=0),this.data=e,this.id=t}return e.prototype.dumps=function(){var e=new DataView(new ArrayBuffer(3+this.data.length)),t=0;e.setUint8(t,exports.EventType.WebRTCForwardREQ),t++,e.setUint16(t,this.id),t+=2;for(var n=0;n<this.data.length;n++)e.setUint8(t,this.data.charCodeAt(n)),t+=1;return e.buffer},e}(),z=function(){function e(e,t){void 0===t&&(t=0),this.timestamp=e,this.stack=t}return e.prototype.dumps=function(){var e=new DataView(new ArrayBuffer(13));return e.setUint8(0,exports.EventType.EventDelay),e.setBigUint64(1,this.timestamp),e.setUint32(8,this.stack),e.buffer},e.decode=function(t){var n=new DataView(t);return new e(n.getBigUint64(1),n.getUint32(8))},e}(),U=function(){function e(e,t,n,i,o,r){void 0===o&&(o=exports.MoveType.Unknow),void 0===r&&(r=exports.EventType.MouseMoveStandardization),this.x=e,this.y=t,this.dx=n,this.dy=i,this.move=o,this.eventType=r}return e.prototype.dumps=function(){p.EnableLog;var e=new ArrayBuffer(10),t=new DataView(e);return t.setUint8(0,this.eventType),t.setUint8(1,+this.move),t.setUint16(2,this.x),t.setUint16(4,this.y),t.setUint16(6,this.dx),t.setUint16(8,this.dy),e},e}(),G=function(){function e(e,t){this.mouseButtonType=e,this.down=t}return e.prototype.dumps=function(){p.EnableLog;var e=new ArrayBuffer(3),t=new DataView(e);return t.setUint8(0,exports.EventType.MouseButton),t.setUint8(1,+this.down),t.setUint8(2,this.mouseButtonType),e},e.formMouseEvent=function(t,n){if(!R.has(t.button))throw new Error("[Event] unsupport button type");return new e(R.get(t.button),n)},e}(),O=function(){function e(e,t){this.step=e,this.forward=t}return e.prototype.dumps=function(){p.EnableLog;var e=new ArrayBuffer(4),t=new DataView(e);return t.setUint8(0,exports.EventType.WheelScroll),t.setUint8(1,+this.forward),t.setUint16(2,this.step),e},e.fromPinchZoom=function(t){return new e(Math.abs(t),1===Math.sign(t))},e.fromWheelEvent=function(t){var n=Math.abs(t.deltaX),i=Math.abs(t.deltaY),o=!!i,r=-1===Math.sign(o?t.deltaY:t.deltaX);return new e(o?Math.sign(i):Math.sign(n),r)},e.fromTouchDeltaY=function(t){return new e(1,t<0)},e}(),j=function(){function e(e,t,n,i,o,r,s,a){this.keycode=e,this.alt=t,this.shift=n,this.ctrl=i,this.nlock=o,this.clock=r,this.slock=s,this.down=a}return e.prototype.dumps=function(){p.EnableLog;var e=new ArrayBuffer(9),t=new DataView(e);return t.setUint8(0,exports.EventType.Keyboard),t.setUint8(1,+this.down),t.setUint8(2,+this.nlock),t.setUint8(3,+this.clock),t.setUint8(4,+this.slock),t.setUint8(5,+this.shift),t.setUint8(6,+this.ctrl),t.setUint8(7,+this.alt),t.setUint8(8,+this.keycode),e},e.fromKeyboardEvent=function(t,n){return new e(t.keyCode,t.altKey,t.shiftKey,t.ctrlKey,t.getModifierState("NumLock"),t.getModifierState("CapsLock"),t.getModifierState("ScrollLock"),n)},e}(),Q=function(){function e(e,t){this.touchType=e,this.touchList=t}return e.prototype.dumps=function(){p.EnableLog;var e=new ArrayBuffer(4+8*this.touchList.length),t=new DataView(e);t.setUint8(0,exports.EventType.WinTouch),t.setUint8(1,this.touchType),t.setUint16(2,this.touchList.length);var n=4;return this.touchList.forEach((function(e){t.setUint16(n,e.x),n+=2,t.setUint16(n,e.y),n+=2,t.setUint32(n,e.id),n+=4})),e},e}(),H=function(){function e(e,t){this.id=e,this.success=t}return e.fromDataChannel=function(t){var n=new DataView(t);return new e(n.getUint16(1),!!n.getUint8(3))},e}(),Z=function(){function e(e,t){void 0===t&&(t=!1),this.payload=e,this.reserve=t}return e.prototype.dumps=function(){p.EnableLog;var e=function(e){for(var t,n=new Array,i=0;i<e.length;i++)(t=e.charCodeAt(i))>=65536&&t<=1114111?(n.push(t>>18&7|240),n.push(t>>12&63|128),n.push(t>>6&63|128),n.push(63&t|128)):t>=2048&&t<=65535?(n.push(t>>12&15|224),n.push(t>>6&63|128),n.push(63&t|128)):t>=128&&t<=2047?(n.push(t>>6&31|192),n.push(63&t|128)):n.push(255&t);return n}(this.payload),t=new DataView(new ArrayBuffer(4+e.length));return t.setUint8(0,exports.EventType.TextInput),t.setUint8(1,+this.reserve),t.setUint16(2,e.length),e.forEach((function(e,n){return t.setUint8(n+4,e)})),t.buffer},e}(),F=function(){function e(e,t,n,i,o,r,s,a,u){void 0===e&&(e=exports.GamepadType.GamepadXbox),void 0===t&&(t=0),this.gamepadType=e,this.gamepadUser=t,this.buttons=n,this.leftTrigger=i,this.rightTrigger=o,this.leftThumbX=r,this.leftThumbY=s,this.rightThumbX=a,this.rightThumbY=u}return e.prototype.dumps=function(){var e=new DataView(new ArrayBuffer(16));return e.setUint8(0,exports.EventType.Gamepad),e.setUint8(1,this.gamepadType),e.setUint16(2,this.gamepadUser),e.setUint16(4,this.buttons),e.setUint8(6,this.leftTrigger),e.setUint8(7,this.rightTrigger),e.setInt16(8,this.leftThumbX),e.setInt16(10,this.leftThumbY),e.setInt16(12,this.rightThumbX),e.setInt16(14,this.rightThumbY),e.buffer},e}(),W=function(){function e(e,t,i,o,r,s,a){var u=this;void 0===i&&(i="all"),void 0===o&&(o=2e3),void 0===r&&(r=5e3),void 0===s&&(s=4e3),void 0===a&&(a=!0),this.url=e,this.iceServers=t,this.iceTransportPolicy=i,this.minBitrate=o,this.maxBitrate=r,this.startBitrate=s,this.enableAFK=a,this.event={connect:new P,afk:new P,open:new P,close:new P,queue:new P,ready:new P,cursor:new P,disconnect:new P,receivedLink:new P,receivedVideo:new P,dataChannelConnected:new P,interaction:new P,occupy:new P,kick:new P,networkChanged:new P,echo:new P,kickOut:new P},this.fps=0,this.bitrate=0,this.packetLossRate=0,this.token="",this.afk=new L,this.tan=new A,this.ready=!1,this.token=e.split("/").pop(),this.pc=new RTCPeerConnection({iceServers:t,iceTransportPolicy:i}),this.setupPeerConnection(),this.dc=this.pc.createDataChannel("sendChannel"),this.dc.binaryType="arraybuffer",this.setupDataChannel(),this.subject=n.webSocket({url:e,closeObserver:{next:function(e){return u.event.close.emit(e)}},openObserver:{next:function(e){return u.event.open.emit(e)}}}),this.setupSigning(),this.gatherStatistics()}return e.prototype.setupSigning=function(){var e=this;this.subject.subscribe({next:function(t){switch(t.action){case"connect":e.event.connect.emit(t);break;case"sdpOffer":e.pc.setRemoteDescription(new RTCSessionDescription(t.data)),e.pc.createAnswer().then((function(t){e.pc.setLocalDescription(t),e.subject.next({action:"sdpAnswer",data:t})}));break;case"candidate":e.pc.addIceCandidate(new RTCIceCandidate(t.data));break;case"sdpAnswer":e.pc.setRemoteDescription(new RTCSessionDescription(t.data));break;case"ready":e.ready||(e.ready=!0,e.linkStart(),e.event.ready.emit(t));break;case"queue":e.event.queue.emit(t.data.queueNum);break;case"peerDisconnected":e.event.disconnect.emit(t.message);break;case"operateOverTime":e.event.afk.emit(e.afk.idleTime);break;case"unready":try{e.subject.next({action:"verify",data:{token:e.token}})}catch(e){}break;case"hangUp":e.hangUp();break;case"occupy":e.event.occupy.emit("connection occupied!");break;case"kick":e.event.kick.emit(t.message),e.destory()}},error:function(t){e.event.disconnect.emit(t)},complete:function(){}})},e.prototype.setupPeerConnection=function(){var e=this;this.pc.onicecandidate=function(t){t.candidate&&e.subject.next({action:"candidate",data:t.candidate})},this.pc.ontrack=function(t){e.event.receivedVideo.emit(t.streams[0])},this.pc.oniceconnectionstatechange=function(){"disconnected"===e.pc.iceConnectionState&&e.event.networkChanged.emit(e.url)}},e.prototype.setupDataChannel=function(){var e=this;this.dc.onopen=function(n){t.interval(3e4).subscribe((function(t){return e.subject.next({action:"heartbeat"})}));var i=e;e.enableAFK&&(e.afk.start(),setTimeout((function e(){i.subject.next({action:"afk",data:{idleTime:i.afk.idleTime}}),i.subject.closed||setTimeout(e,p.AFKTimerGap)}),p.AFKTimerGap)),e.event.dataChannelConnected.emit(n)};var n=t.fromEvent(this.dc,"message").pipe(i.tap((function(e){})),i.map((function(e){return e.data})),i.share());n.pipe(i.filter((function(e){return d(e)===exports.EventType.CursorData})),i.map((function(e){return new S(e)}))).subscribe((function(t){return e.event.cursor.emit(t)})),n.pipe(i.filter((function(e){return d(e)===exports.EventType.KickOutController})),i.map(f)).subscribe((function(t){return e.event.kickOut.emit(t)})),n.pipe(i.filter((function(e){return d(e)===exports.EventType.URLIntercept})),i.map((function(e){return f(e,8)}))).subscribe((function(t){return e.event.receivedLink.emit(t)})),n.pipe(i.filter((function(e){return d(e)===exports.EventType.WebRTCForwardREQ})),i.map(f)).subscribe((function(t){return e.event.interaction.emit(t)})),n.pipe(i.filter((function(e){return d(e)===exports.EventType.WebRTCForwardRSP})),i.map((function(e){return H.fromDataChannel(e)}))).subscribe((function(t){return e.tan.trigger(t.id,t.success)})),n.pipe(i.filter((function(e){return[exports.EventType.EchoData,exports.EventType.EventDelay].includes(d(e))})),i.map((function(e){return z.decode(e)}))).subscribe((function(t){var n=t.timestamp,i=t.stack;return e.event.echo.emit({stack:i,latency:(new Date).getTime()-Number(n)-1e3*i})})),this.dc.onerror=function(e){},this.dc.onclose=function(e){}},e.prototype.linkStart=function(){var e=this;this.pc.createOffer({offerToReceiveAudio:!0,offerToReceiveVideo:!0}).then((function(t){e.pc.setLocalDescription(t),t.sdp=t.sdp.replace(/(a=fmtp:\d+ .*level-asymmetry-allowed=.*)\r\n/gm,"$1;x-google-start-bitrate=".concat(e.startBitrate,";x-google-max-bitrate=").concat(e.maxBitrate,";x-google-min-bitrate=").concat(e.minBitrate,"\r\n")),e.subject.next({action:"sdpOffer",data:t})}))},e.prototype.gatherStatistics=function(){var e=this;t.interval(1e3).pipe(i.mergeMap((function(){return t.from(e.pc.getStats())})),i.mergeMap((function(e){return Array.from(e.values())})),i.filter((function(e){return"inbound-rtp"===e.type&&"video"===e.mediaType})),i.pairwise(),i.map((function(e){var t=e[0],n=e[1],i=Math.floor(8*(n.bytesReceived-t.bytesReceived)/(n.timestamp-t.timestamp)),o=n.packetsLost/(n.packetsLost+n.packetsReceived);return{fps:n.framesPerSecond,bitrate:i,packetLossRate:o}}))).subscribe((function(t){var n=t.bitrate,i=t.fps,o=t.packetLossRate;e.bitrate=n,e.fps=i||0,e.packetLossRate=o}))},e.prototype.hangUp=function(){this.ready=!1,this.dc.close(),this.pc.close(),this.afk.clear(),this.pc=new RTCPeerConnection({iceServers:this.iceServers,iceTransportPolicy:this.iceTransportPolicy}),this.setupPeerConnection(),this.dc=this.pc.createDataChannel("sendChannel"),this.setupDataChannel(),this.setupSigning(),this.gatherStatistics()},e.prototype.changeBitrate=function(e){return c(this,void 0,void 0,(function(){return h(this,(function(t){return this.subject.next({action:"setBitrate",data:{value:e}}),[2]}))}))},e.prototype.changeBandwidth=function(e){var t=this;if(("chrome"===s.default.browserDetails.browser||"safari"===s.default.browserDetails.browser||"firefox"===s.default.browserDetails.browser&&s.default.browserDetails.version>=64)&&"RTCRtpSender"in window&&"setParameters"in window.RTCRtpSender.prototype){var n=this.pc.getSenders()[0],i=n.getParameters();return i.encodings||(i.encodings=[{}]),e?i.encodings[0].maxBitrate=1e3*e:delete i.encodings[0].maxBitrate,void n.setParameters(i)}this.pc.createOffer().then((function(e){return t.pc.setLocalDescription(e)})).then((function(){var n,i={type:t.pc.remoteDescription.type,sdp:e?b(t.pc.remoteDescription.sdp,e):(n=t.pc.remoteDescription.sdp,n.replace(/b=AS:.*\r\n/,"").replace(/b=TIAS:.*\r\n/,""))};return t.pc.setRemoteDescription(i)}))},e.prototype.getRTT=function(){return c(this,void 0,void 0,(function(){return h(this,(function(e){try{return[2,this.pc.getStats().then((function(e){return Array.from(e.values()).find((function(e){return"candidate-pair"===e.type}))})).then((function(e){return e.totalRoundTripTime/e.responsesReceived*1e3}))]}catch(e){return[2,Promise.resolve(0)]}return[2]}))}))},e.prototype.exit=function(){this.subject.closed||this.subject.next({action:"exit"})},e.prototype.emitUIInteraction=function(e){var t=new C,n=this.tan.order(t);return this.send(new X(e,n).dumps()),t.promise},e.prototype.echo=function(){this.send(new z(BigInt((new Date).getTime())).dumps())},e.prototype.send=function(e){if("open"!==this.dc.readyState)throw new Error("send message before DataChannel open");this.enableAFK&&this.afk.reset(),"string"==typeof e||e instanceof Blob||ArrayBuffer,this.dc.send(e)},e.prototype.destory=function(){this.dc.close(),this.pc.close(),this.afk.clear(),this.subject.unsubscribe(),Object.entries(this.event).forEach((function(e){return e[1].offAll()}))},e}(),Y=function(){function e(e,t,n){var i=this;void 0===t&&(t=function(){}),void 0===n&&(n=!0),this.hostElement=e,this.canResize=!1,this.top=0,this.left=0,this.width=0,this.height=0,this.intervalID=NaN,this.pointLockChange=new P,this.onPlayHandler=[],this.resizePlayer=function(){i.canResize&&(i.hostElement.clientWidth<i.videoElement.videoWidth||i.hostElement.clientHeight<i.videoElement.videoHeight?i.resizePlayerStyleToFillWindow():i.resizePlayerStyleToActualSize())},this.onPlayHandler.push(t),this.overlayElement=document.createElement("div"),this.overlayElement.style.cssText="\n color: white;\n font-size: 1.8em;\n width: 100%;\n height: 100%;\n display: flex;\n position: absolute;\n background-color: rgba(51, 51, 51, 0.7);\n justify-content: center;\n align-items: center;\n ",this.playerElement=document.createElement("div"),this.playerElement.style.cssText="\n width: 100%;\n height: 100%;\n position: relative;\n background-color: black;\n ",this.videoElement=document.createElement("video"),this.videoElement.style.cssText="\n width: 100%;\n height: 100%;\n position: absolute;\n touch-action: none;\n ",this.videoElement.muted=!0,this.videoElement.playsInline=!0,this.videoElement.addEventListener("loadedmetadata",(function(e){i.intervalID=window.setInterval((function(){i.isBlackScreen()||(i.canResize=!0,i.hidePlayOverlay(),i.resizePlayer(),window.clearInterval(i.intervalID),i.onPlayHandler.forEach((function(e){return e()})))}),500),i.videoElement.play().catch((function(){return i.showPlayOverlay()}))})),this.playerElement.appendChild(this.videoElement),this.playerElement.appendChild(this.overlayElement),e.appendChild(this.playerElement),new a.default(this.resizePlayer).observe(e);var o=this;n&&(document.body.addEventListener("mousedown",(function e(){o.videoElement.muted=!1,document.body.removeEventListener("mousedown",e)})),window.navigator.userAgent.indexOf("Chrome")>-1?document.body.addEventListener("touchend",(function e(){o.videoElement.muted=!1,document.body.removeEventListener("touchend",e)})):document.body.addEventListener("touchstart",(function e(){o.videoElement.muted=!1,document.body.removeEventListener("touchstart",e)}))),this.pointerLock=new I(this.videoElement)}return Object.defineProperty(e.prototype,"videoAspectRatio",{get:function(){return this.videoElement.videoHeight/this.videoElement.videoWidth},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hostAspectRatio",{get:function(){return this.hostElement.clientHeight/this.hostElement.clientWidth},enumerable:!1,configurable:!0}),e.prototype.registerOnPlay=function(e){this.onPlayHandler.push(e)},e.prototype.isBlackScreen=function(){var e,t=document.createElement("canvas"),n=t.getContext("2d");return t.width=this.videoElement.videoWidth/100,t.height=this.videoElement.videoHeight/100,n.drawImage(this.videoElement,0,0,t.width,t.height),!t.width||(null===(e=n.getImageData(0,0,t.width,t.height))||void 0===e?void 0:e.data).every((function(e){return 0===e||1===e||255===e}))},e.prototype.resizePlayerStyleToFillWindow=function(){this.videoAspectRatio?this.hostAspectRatio<this.videoAspectRatio?(this.height=this.hostElement.clientHeight,this.width=Math.floor(this.height/this.videoAspectRatio),this.left=Math.floor(.5*(this.hostElement.clientWidth-this.width)),this.top=0):(this.width=this.hostElement.clientWidth,this.height=Math.floor(this.width*this.videoAspectRatio),this.top=Math.floor(.5*(this.hostElement.clientHeight-this.height)),this.left=0):(this.width=this.hostElement.clientWidth,this.height=this.hostElement.clientHeight,this.top=0,this.left=0),this.applyStyleToPlayer()},e.prototype.resizePlayerStyleToActualSize=function(){this.width=this.videoElement.videoWidth,this.height=this.videoElement.videoHeight,this.top=Math.floor(.5*(this.hostElement.clientHeight-this.height)),this.left=Math.floor(.5*(this.hostElement.clientWidth-this.width)),this.applyStyleToPlayer()},e.prototype.applyStyleToPlayer=function(){this.playerElement.style.top="".concat(this.top,"px"),this.playerElement.style.left="".concat(this.left,"px"),this.playerElement.style.width="".concat(this.width,"px"),this.playerElement.style.height="".concat(this.height,"px")},e.prototype.destory=function(){var e;this.intervalID&&window.clearInterval(this.intervalID),this.playerElement.contains(this.videoElement)&&this.playerElement.removeChild(this.videoElement),this.playerElement.contains(this.overlayElement)&&this.playerElement.removeChild(this.overlayElement),null===(e=this.playerElement.parentNode)||void 0===e||e.removeChild(this.playerElement)},e.prototype.showTextOverlay=function(e){var t=document.createElement("div");t.innerHTML=e,this.setOverlay(t)},e.prototype.setCursor=function(e,t,n,i){var o=this;if(this.pointerLock.on((function(e){o.pointLockChange.emit(e)})),e){var r=document.createElement("img");r.src=e,r.onload=function(){if(r.width>32||r.height>32){var i=function(e){var t=document.createElement("canvas"),n=e.width>32?32:e.width,i=e.height>32?32:e.height;t.width=n,t.height=i;var o=t.getContext("2d");return null==o||o.drawImage(e,0,0,n,i),t.toDataURL()}(r);o.videoElement.style.cursor="url(".concat(i,") ").concat(t," ").concat(n,", auto")}else o.videoElement.style.cursor="url(".concat(e,") ").concat(t," ").concat(n,", auto")}}i?this.pointerLock.exit():this.pointerLock.request()},e.prototype.showPlayOverlay=function(){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FOOHNzzNtPhf3REdekSZRQjqVTJtzguSNeD4eWH5dRJoGAZ0a4rvxm3ghrkCnzSJNhpBWIc7/plpgwpudRZ7dLNIGCOvtJbwX42G4uPxIRNoAoU2d3iNxUflPItIaNtnk/wEGBoMdpECGHAAAAABJRU5ErkJggg==",t.alt="Start Streaming",this.setOverlay(t,(function(){e.hidePlayOverlay()}))},e.prototype.hidePlayOverlay=function(){this.clearOverlay(),this.overlayElement.style.display="none"},e.prototype.clearOverlay=function(){for(;this.overlayElement.lastChild;)this.overlayElement.removeChild(this.overlayElement.lastChild)},e.prototype.setOverlay=function(e,t){if(this.clearOverlay(),this.overlayElement.appendChild(e),this.overlayElement.style.display="flex",t){var n=this;this.overlayElement.addEventListener("click",(function e(i){t(i),n.overlayElement.removeEventListener("click",e)}))}},e}(),N=function(){function e(){}return e.createDefaultEventStream=function(e,n){e.addEventListener("contextmenu",(function(e){return e.preventDefault()}));var o=t.fromEvent(e,"mousedown").pipe(i.tap((function(e){return e.preventDefault()})),i.map((function(e){return G.formMouseEvent(e,!0).dumps()}))),r=t.fromEvent(e,"mouseup").pipe(i.tap((function(e){return e.preventDefault()})),i.map((function(e){return G.formMouseEvent(e,!1).dumps()}))),s=t.fromEvent(e,"mousemove").pipe(i.tap((function(e){return e.preventDefault()})),i.map((function(e){return m(e,n.mouseNormalizeType===exports.EventType.MouseMoveStandardization)})),i.map((function(e){var t=e.x,i=e.y,o=e.dx,r=e.dy;return new U(t,i,o,r,n.mouseMoveType,n.mouseNormalizeType).dumps()}))),a=t.fromEvent(e,"wheel",{passive:!1}).pipe(i.tap((function(e){return e.preventDefault()})),i.map((function(e){return O.fromWheelEvent(e).dumps()}))),c=t.fromEvent(document,"keydown").pipe(i.map((function(e){return j.fromKeyboardEvent(e,!0).dumps()}))),h=t.fromEvent(document,"keyup").pipe(i.map((function(e){return j.fromKeyboardEvent(e,!1).dumps()})));function p(e,t){var n=t===exports.TouchType.TouchUpdate?"touches":"changedTouches";return new Q(t,function(e,t){var n=e.target,i=n.videoWidth,o=n.videoHeight,r=n.clientHeight,s=n.clientWidth,a=n.getBoundingClientRect(),u=a.left,c=a.top;return t.map((function(e){var t=e.clientX,n=e.clientY;return{x:i/s*(t-u),y:o/r*(n-c),id:e.identifier}}))}(e,Array.from(e[n]))).dumps()}var l=t.fromEvent(e,"touchend"),d=t.fromEvent(e,"touchmove",{passive:!1}),f=t.fromEvent(e,"touchstart",{passive:!1}),v=t.fromEvent(e,"touchcancel"),y=d.pipe(i.tap((function(e){return e.preventDefault()})),i.takeUntil(t.merge(l,v)),i.throttleTime(100),i.filter((function(e){return 2===e.targetTouches.length})),i.pairwise(),i.map(w),i.map((function(e){return O.fromPinchZoom(e/10).dumps()})),i.repeat()),b=t.iif((function(){return n.fakeMouseWithTouch}),f.pipe(i.tap((function(e){return e.preventDefault()})),i.concatMap((function(e){return t.of((i=m({target:e.target,clientX:e.targetTouches[0].clientX,clientY:e.targetTouches[0].clientY,movementX:0,movementY:0},n.mouseNormalizeType===exports.EventType.MouseMoveStandardization),o=i.x,r=i.y,s=i.dx,a=i.dy,new U(o,r,s,a,n.mouseMoveType,n.mouseNormalizeType).dumps()),new G(3===e.targetTouches.length?exports.MouseButtonType.ButtonMiddle:n.fakeTouchType,!0).dumps());var i,o,r,s,a}))),f.pipe(i.tap((function(e){return e.preventDefault()})),i.map((function(e){return p(e,exports.TouchType.TouchDown)})))),x=t.iif((function(){return n.fakeMouseWithTouch}),d.pipe(i.tap((function(e){return e.preventDefault()})),i.takeUntil(t.merge(l,v)),i.filter((function(e){return 1===e.targetTouches.length||3===e.targetTouches.length})),i.pairwise(),i.map(g),i.map((function(e){return function(e,t,n){var i=e.movementX,o=e.movementY;return u(u({},e),{movementX:i*t,movementY:o*n})}(e,n.touchDeltaXSensitivity,n.touchDeltaYSensitivity)})),i.map((function(e){return m(e,n.mouseNormalizeType===exports.EventType.MouseMoveStandardization)})),i.map((function(e){var t=e.x,i=e.y,o=e.dx,r=e.dy;return new U(t,i,o,r,n.mouseMoveType,n.mouseNormalizeType).dumps()})),i.repeat()),d.pipe(i.tap((function(e){return e.preventDefault()})),i.map((function(e){return p(e,exports.TouchType.TouchUpdate)})))),E=t.iif((function(){return n.fakeMouseWithTouch}),t.merge(l,v).pipe(i.tap((function(e){return e.preventDefault()})),i.mapTo(new G(n.fakeTouchType,!1).dumps())),t.merge(l,v).pipe(i.tap((function(e){return e.preventDefault()})),i.map((function(e){return p(e,exports.TouchType.TouchUp)}))));return t.interval(0,t.animationFrameScheduler).pipe(i.map((function(e){return navigator.getGamepads()[0]})),i.filter((function(e){return!!e})),i.map((function(e){var t=e.axes.map((function(e){return 32767*e})),n=t[0],i=t[1],o=t[2],r=t[3],s=255*e.buttons[6].value,a=255*e.buttons[7].value;return new F(exports.GamepadType.GamepadXbox,0,0,s,a,n,-i,o,-r).dumps()}))),{wheelStream:a,keydownStream:c,keyupStream:h,mouseupStream:r,mousedownStream:o,mousemoveStream:s,zoomStream:y,startBufferStream:b,moveBufferStream:x,endBufferStream:E}},e.attachListener=function(e,n,o){var r=this.createDefaultEventStream(e,n),s=r.wheelStream,a=r.keydownStream,u=r.keyupStream,c=r.mouseupStream,h=r.mousedownStream,p=r.mousemoveStream,l=r.zoomStream,d=r.startBufferStream,f=r.moveBufferStream,m=r.endBufferStream;t.merge(s,a,u,c,h,p,l,d,f,m).pipe(i.takeUntil(t.fromEvent(o.dc,"close"))).subscribe((function(e){return o.send(e)}))},e}(),J=function(e,t,n,i,o,r){void 0===e&&(e=exports.EventType.MouseMoveStandardization),void 0===t&&(t=exports.MoveType.Unknow),void 0===n&&(n=exports.MouseButtonType.ButtonLeft),void 0===i&&(i=!0),void 0===o&&(o=1),void 0===r&&(r=1),this.mouseNormalizeType=e,this.mouseMoveType=t,this.fakeTouchType=n,this.fakeMouseWithTouch=i,this.touchDeltaXSensitivity=o,this.touchDeltaYSensitivity=r};exports.Connection=W,exports.EventDelay=z,exports.Gamepad=F,exports.Helper=N,exports.Keyboard=j,exports.MouseButton=G,exports.MouseMove=U,exports.Player=Y,exports.RunningState=J,exports.TextInput=Z,exports.TouchSet=Q,exports.UIInteraction=X,exports.UIInteractionResponse=H,exports.WheelScroll=O,exports.screenfull=B;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("webrtc-adapter"),t=require("rxjs"),n=require("rxjs/webSocket"),i=require("rxjs/operators"),o=require("resize-observer-polyfill");function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=r(e),s=r(o),u=function(){return u=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},u.apply(this,arguments)};function c(e,t,n,i){return new(n||(n=Promise))((function(o,r){function a(e){try{u(i.next(e))}catch(e){r(e)}}function s(e){try{u(i.throw(e))}catch(e){r(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}u((i=i.apply(e,t||[])).next())}))}function h(e,t){var n,i,o,r,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return r={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(r[Symbol.iterator]=function(){return this}),r;function s(r){return function(s){return function(r){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,i&&(o=2&r[0]?i.return:r[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,r[1])).done)return o;switch(i=0,o&&(r=[2&r[0],o.value]),r[0]){case 0:case 1:o=r;break;case 4:return a.label++,{value:r[1],done:!1};case 5:a.label++,i=r[1],r=[0];continue;case 7:r=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==r[0]&&2!==r[0])){a=0;continue}if(3===r[0]&&(!o||r[1]>o[0]&&r[1]<o[3])){a.label=r[1];break}if(6===r[0]&&a.label<o[1]){a.label=o[1],o=r;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(r);break}o[2]&&a.ops.pop(),a.trys.pop();continue}r=t.call(e,a)}catch(e){r=[6,e],i=0}finally{n=o=0}if(5&r[0])throw r[1];return{value:r[0]?r[1]:void 0,done:!0}}([r,s])}}}var p=Object.freeze({EnableLog:!0,AFKTimerGap:1e4});var l=function(e){return new DataView(e).getUint8(0)};function d(e,t,n){void 0===t&&(t=1),void 0===n&&(n="");var i,o=new DataView(e);return(i=e.byteLength-t,Object.keys(Array.from({length:i})).map((function(e){return Number(e)}))).map((function(e){return String.fromCharCode(o.getUint8(e+t))})).join(n)}function f(e,t){void 0===t&&(t=!1);var n=e.target,i=n.getBoundingClientRect(),o=i.left,r=i.top,a=e.clientX,s=e.clientY,u=e.movementY,c=e.movementX,h=n.clientHeight,p=n.clientWidth,l=n.videoHeight,d=n.videoWidth;return{x:Math.min(Math.max(a-o,0),p)*((t?d:65535)/p),y:Math.min(Math.max(s-r,0),h)*((t?l:65535)/h),dx:c*((t?d:32767)/p),dy:u*((t?l:32767)/h)}}var m=function(){function e(e,t){this.x=e,this.y=t}return e.fromTouch=function(t){return new e(t.pageX,t.pageY)},e}();function v(e,t){return Math.hypot(t.x-e.x,t.y-e.y)}function y(e){var t=Array.from(e[0].targetTouches),n=t[0],i=t[1],o=Array.from(e[1].targetTouches),r=o[0],a=o[1];return v(m.fromTouch(r),m.fromTouch(a))-v(m.fromTouch(n),m.fromTouch(i))}function g(e){var t=e[0],n=e[1],i=n.targetTouches[0].clientX-t.targetTouches[0].clientX,o=n.targetTouches[0].clientY-t.targetTouches[0].clientY;return{target:t.target,clientX:t.targetTouches[0].clientX,clientY:t.targetTouches[0].clientY,movementX:i,movementY:o}}function w(e){var t=e.target.getBoundingClientRect(),n=t.left,i=t.top,o=t.right,r=t.bottom,a=e.clientY,s=e.clientX,u=Math.abs(i-a),c=Math.abs(r-a),h=Math.abs(n-s),p=Math.abs(o-s);switch(Math.min(u,c,h,p)){case h:return{target:e.target,clientX:0,clientY:a,movementY:0,movementX:0};case u:return{target:e.target,clientX:s,clientY:0,movementY:0,movementX:0};default:return{target:e.target,clientX:s,clientY:a,movementY:0,movementX:0}}}function b(e,t){var n="AS";return"firefox"===a.default.browserDetails.browser&&(t=1e3*(t>>>0),n="TIAS"),e=-1===e.indexOf("b="+n+":")?e.replace(/c=IN (.*)\r\n/,"c=IN $1\r\nb="+n+":"+t+"\r\n"):e.replace(new RegExp("b="+n+":.*\r\n"),"b="+n+":"+t+"\r\n")}var x,E,T,k,M,D,B=new(function(){function e(){this.APINameMap="exitFullscreen"in document?{requestFullscreen:"requestFullscreen",exitFullscreen:"exitFullscreen",fullscreenElement:"fullscreenElement",fullscreenEnabled:"fullscreenEnabled",fullscreenchange:"fullscreenchange"}:"webkitExitFullscreen"in document?{requestFullscreen:"webkitRequestFullscreen",exitFullscreen:"webkitExitFullscreen",fullscreenElement:"webkitFullscreenElement",fullscreenEnabled:"webkitFullscreenEnabled",fullscreenchange:"webkitfullscreenchange"}:{requestFullscreen:"mozRequestFullScreen",exitFullscreen:"mozCancelFullScreen",fullscreenElement:"mozFullScreenElement",fullscreenEnabled:"mozFullScreenEnabled",fullscreenchange:"mozfullscreenchange"}}return Object.defineProperty(e.prototype,"isFullscreen",{get:function(){return Boolean(document[this.APINameMap.fullscreenElement])},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"element",{get:function(){return document[this.APINameMap.fullscreenElement]},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isEnabled",{get:function(){return Boolean(document[this.APINameMap.fullscreenEnabled])},enumerable:!1,configurable:!0}),e.prototype.request=function(e,t){var n=this;return new Promise((function(i,o){var r=function(){screen.orientation.lock("landscape-primary"),document.removeEventListener(n.APINameMap.fullscreenchange,r),n.off(r),"keyboard"in navigator&&"lock"in navigator.keyboard&&navigator.keyboard.lock(["KeyW","Escape","KeyN","KeyT","MetaLeft"]),i()};n.on(r);var a=(e||document.documentElement)[n.APINameMap.requestFullscreen](t);a instanceof Promise&&a.then(r).catch(o)}))},e.prototype.exit=function(){var e=this;return new Promise((function(t,n){if(e.isFullscreen){var i=function(){e.off(i),t()};e.on(i);var o=document[e.APINameMap.exitFullscreen]();o instanceof Promise&&o.then(i).catch(n)}else t()}))},e.prototype.toggle=function(e,t){return this.isFullscreen?this.exit():this.request(e,t)},e.prototype.on=function(e){document.addEventListener(this.APINameMap.fullscreenchange,e)},e.prototype.off=function(e){document.removeEventListener(this.APINameMap.fullscreenchange,e)},e}()),S=function(){function e(){this.timer=NaN,this.idleTime=0}return e.prototype.reset=function(){this.idleTime=0},e.prototype.start=function(){var e=this;this.timer=window.setInterval((function(){e.idleTime+=1e3}),1e3)},e.prototype.clear=function(){window.clearInterval(this.timer)},e}(),C=function(){var e=this;this.promise=new Promise((function(t,n){e.resolve=t,e.reject=n}))},L=function(){function e(e,t,n,i){void 0===e&&(e=""),void 0===t&&(t=!1),void 0===n&&(n=0),void 0===i&&(i=0),this.base64=e,this.show=t,this.x=n,this.y=i}return e.parse=function(t){var n=new DataView(t),i=n.getUint32(1),o=n.getUint32(5),r=n.getUint32(9),a=n.getUint32(13),s=n.getUint32(17),u=n.getUint32(21),c=n.getUint8(29);if(0===r||0===a)return new e("",!!c,-i,-o);if(1===s&&4===u)return new e("",!!c,-i,-o);var h=document.createElement("canvas"),p=h.getContext("2d");h.width=r,h.height=a;var l=p.createImageData(r,a),d=l.data;d.set(new Uint8ClampedArray(t,30));for(var f=0;f<d.length;f+=4){var m=d[f];d[f]=d[f+2],d[f+2]=m}return p.putImageData(l,0,0),new e(h.toDataURL(),!!c,i,o)},e}(),P=function(){var e=this;this.listeners=[],this.listenersOncer=[],this.on=function(t){return e.listeners.push(t),{dispose:function(){return e.off(t)}}},this.once=function(t){e.listenersOncer.push(t)},this.off=function(t){var n=e.listeners.indexOf(t);n>-1&&e.listeners.splice(n,1)},this.offAll=function(){e.listenersOncer=[],e.listeners=[]},this.emit=function(t){e.listeners.forEach((function(e){return e(t)})),e.listenersOncer.forEach((function(e){return e(t)})),e.listenersOncer=[]},this.pipe=function(t){return e.on((function(e){return t.emit(e)}))}},A=function(){function e(){this.currentID=0,this.executeMap=new Map}return e.prototype.obtainID=function(){return this.currentID>=65535?this.currentID=0:++this.currentID},e.prototype.trigger=function(e,t){this.executeMap.has(e)&&(this.executeMap.get(e).resolve(t),this.executeMap.delete(e))},e.prototype.order=function(e){var t=this.obtainID();return this.executeMap.set(t,e),t},e}(),X=function(){function e(e,t){var n=this;void 0===t&&(t=function(){}),this.target=e,this.onExit=t,this.cursor=new L,this.handleVisibilityChange=function(){"visible"!==document.visibilityState||n.cursor.show||n.target.requestPointerLock()},this.handlePointerLockError=function(){document.addEventListener("click",(function(){n.cursor.show||n.target.requestPointerLock()}),{once:!0})},this.handlePointerLockChange=function(){n.isPointerLocking||n.cursor.show||B.isFullscreen||n.onExit()},e.requestPointerLock=e.requestPointerLock||e.mozRequestPointerLock||e.webkitRequestPointerLock,document.exitPointerLock=document.exitPointerLock||document.mozExitPointerLock||document.webkitExitPointerLock,document.addEventListener("pointerlockchange",this.handlePointerLockChange),document.addEventListener("pointerlockerror",this.handlePointerLockError),document.addEventListener("visibilitychange",this.handleVisibilityChange)}return e.prototype.destory=function(){document.removeEventListener("pointerlockerror",this.handlePointerLockChange),document.removeEventListener("pointerlockchange",this.handlePointerLockError),document.removeEventListener("visibilitychange",this.handleVisibilityChange)},e.prototype.setCursor=function(e){var t=this;if(this.cursor=e,e.show?document.exitPointerLock():this.target.requestPointerLock(),e.base64){var n=document.createElement("img");n.src=e.base64,n.onload=function(){if(n.width>32||n.height>32){var i=function(e){var t=document.createElement("canvas"),n=e.width>32?32:e.width,i=e.height>32?32:e.height;t.width=n,t.height=i;var o=t.getContext("2d");return null==o||o.drawImage(e,0,0,n,i),t.toDataURL()}(n);t.target.style.cursor="url(".concat(i,") ").concat(e.x," ").concat(e.y,", auto")}else t.target.style.cursor="url(".concat(e.base64,") ").concat(e.x," ").concat(e.y,", auto")}}else this.target.style.cursor="none"},Object.defineProperty(e.prototype,"isPointerLocking",{get:function(){return(document.pointerLockElement||document.mozPointerLockElement||document.webkitPointerLockElement)===this.target},enumerable:!1,configurable:!0}),e}();exports.EventType=void 0,(x=exports.EventType||(exports.EventType={}))[x.MouseMoveStandardization=0]="MouseMoveStandardization",x[x.MouseButton=1]="MouseButton",x[x.WheelScroll=2]="WheelScroll",x[x.Keyboard=3]="Keyboard",x[x.WinTouch=4]="WinTouch",x[x.MobileTouch=5]="MobileTouch",x[x.MobileCustom=6]="MobileCustom",x[x.URLIntercept=7]="URLIntercept",x[x.CaretVisible=8]="CaretVisible",x[x.TextInput=9]="TextInput",x[x.MobileKeys=10]="MobileKeys",x[x.Gamepad=11]="Gamepad",x[x.CursorData=12]="CursorData",x[x.MouseMoveNormalization=13]="MouseMoveNormalization",x[x.EventDelay=14]="EventDelay",x[x.EchoData=15]="EchoData",x[x.KickOutController=16]="KickOutController",x[x.WebRTCPluginsMSG=125]="WebRTCPluginsMSG",x[x.WebRTCForwardRSP=126]="WebRTCForwardRSP",x[x.WebRTCForwardREQ=127]="WebRTCForwardREQ",exports.MouseButtonType=void 0,(E=exports.MouseButtonType||(exports.MouseButtonType={}))[E.ButtonLeft=1]="ButtonLeft",E[E.ButtonMiddle=2]="ButtonMiddle",E[E.ButtonRight=3]="ButtonRight",E[E.ButtonX1=4]="ButtonX1",E[E.ButtonX2=5]="ButtonX2",exports.TouchType=void 0,(T=exports.TouchType||(exports.TouchType={}))[T.TouchDown=0]="TouchDown",T[T.TouchUpdate=1]="TouchUpdate",T[T.TouchUp=2]="TouchUp",exports.MoveType=void 0,(k=exports.MoveType||(exports.MoveType={}))[k.Absolute=0]="Absolute",k[k.Relative=1]="Relative",k[k.Passive=2]="Passive",k[k.Unknow=3]="Unknow",exports.GamepadType=void 0,(M=exports.GamepadType||(exports.GamepadType={}))[M.GamepadXbox=0]="GamepadXbox",exports.GamepadXboxButton=void 0,(D=exports.GamepadXboxButton||(exports.GamepadXboxButton={}))[D.GamepadXboxButtonDpadUp=1]="GamepadXboxButtonDpadUp",D[D.GamepadXboxButtonDpadDown=2]="GamepadXboxButtonDpadDown",D[D.GamepadXboxButtonDpadLeft=4]="GamepadXboxButtonDpadLeft",D[D.GamepadXboxButtonDpadRight=8]="GamepadXboxButtonDpadRight",D[D.GamepadXboxButtonStart=16]="GamepadXboxButtonStart",D[D.GamepadXboxButtonBack=32]="GamepadXboxButtonBack",D[D.GamepadXboxButtonLeftThumb=64]="GamepadXboxButtonLeftThumb",D[D.GamepadXboxButtonRightThumb=128]="GamepadXboxButtonRightThumb",D[D.GamepadXboxButtonLeftShoulder=256]="GamepadXboxButtonLeftShoulder",D[D.GamepadXboxButtonRightShoulder=512]="GamepadXboxButtonRightShoulder",D[D.GamepadXboxButtonA=4096]="GamepadXboxButtonA",D[D.GamepadXboxButtonB=8192]="GamepadXboxButtonB",D[D.GamepadXboxButtonX=16384]="GamepadXboxButtonX",D[D.GamepadXboxButtonY=32768]="GamepadXboxButtonY";var R=new Map([[0,exports.MouseButtonType.ButtonLeft],[1,exports.MouseButtonType.ButtonMiddle],[2,exports.MouseButtonType.ButtonRight],[3,exports.MouseButtonType.ButtonX1],[4,exports.MouseButtonType.ButtonX2]]),I=function(){function e(e,t){void 0===t&&(t=0),this.data=e,this.id=t}return e.prototype.dumps=function(){var e=new DataView(new ArrayBuffer(3+this.data.length)),t=0;e.setUint8(t,exports.EventType.WebRTCForwardREQ),t++,e.setUint16(t,this.id),t+=2;for(var n=0;n<this.data.length;n++)e.setUint8(t,this.data.charCodeAt(n)),t+=1;return e.buffer},e}(),z=function(){function e(e,t){void 0===t&&(t=0),this.timestamp=e,this.stack=t}return e.prototype.dumps=function(){var e=new DataView(new ArrayBuffer(13));return e.setUint8(0,exports.EventType.EventDelay),e.setBigUint64(1,this.timestamp),e.setUint32(8,this.stack),e.buffer},e.decode=function(t){var n=new DataView(t);return new e(n.getBigUint64(1),n.getUint32(8))},e}(),U=function(){function e(e,t,n,i,o,r){void 0===o&&(o=exports.MoveType.Passive),void 0===r&&(r=exports.EventType.MouseMoveStandardization),this.x=e,this.y=t,this.dx=n,this.dy=i,this.move=o,this.eventType=r}return e.prototype.dumps=function(){p.EnableLog;var e=new ArrayBuffer(10),t=new DataView(e);return t.setUint8(0,this.eventType),t.setUint8(1,+this.move),t.setUint16(2,this.x),t.setUint16(4,this.y),t.setUint16(6,this.dx),t.setUint16(8,this.dy),e},e}(),G=function(){function e(e,t){this.mouseButtonType=e,this.down=t}return e.prototype.dumps=function(){p.EnableLog;var e=new ArrayBuffer(3),t=new DataView(e);return t.setUint8(0,exports.EventType.MouseButton),t.setUint8(1,+this.down),t.setUint8(2,this.mouseButtonType),e},e.formMouseEvent=function(t,n){if(!R.has(t.button))throw new Error("[Event] unsupport button type");return new e(R.get(t.button),n)},e}(),O=function(){function e(e,t){this.step=e,this.forward=t}return e.prototype.dumps=function(){p.EnableLog;var e=new ArrayBuffer(4),t=new DataView(e);return t.setUint8(0,exports.EventType.WheelScroll),t.setUint8(1,+this.forward),t.setUint16(2,this.step),e},e.fromPinchZoom=function(t){return new e(Math.abs(t),1===Math.sign(t))},e.fromWheelEvent=function(t){var n=Math.abs(t.deltaX),i=Math.abs(t.deltaY),o=!!i,r=-1===Math.sign(o?t.deltaY:t.deltaX);return new e(o?Math.sign(i):Math.sign(n),r)},e.fromTouchDeltaY=function(t){return new e(1,t<0)},e}(),j=function(){function e(e,t,n,i,o,r,a,s){this.keycode=e,this.alt=t,this.shift=n,this.ctrl=i,this.nlock=o,this.clock=r,this.slock=a,this.down=s}return e.prototype.dumps=function(){p.EnableLog;var e=new ArrayBuffer(9),t=new DataView(e);return t.setUint8(0,exports.EventType.Keyboard),t.setUint8(1,+this.down),t.setUint8(2,+this.nlock),t.setUint8(3,+this.clock),t.setUint8(4,+this.slock),t.setUint8(5,+this.shift),t.setUint8(6,+this.ctrl),t.setUint8(7,+this.alt),t.setUint8(8,+this.keycode),e},e.fromKeyboardEvent=function(t,n){return new e(t.keyCode,t.altKey,t.shiftKey,t.ctrlKey,t.getModifierState("NumLock"),t.getModifierState("CapsLock"),t.getModifierState("ScrollLock"),n)},e}(),Q=function(){function e(e,t){this.touchType=e,this.touchList=t}return e.prototype.dumps=function(){p.EnableLog;var e=new ArrayBuffer(4+8*this.touchList.length),t=new DataView(e);t.setUint8(0,exports.EventType.WinTouch),t.setUint8(1,this.touchType),t.setUint16(2,this.touchList.length);var n=4;return this.touchList.forEach((function(e){t.setUint16(n,e.x),n+=2,t.setUint16(n,e.y),n+=2,t.setUint32(n,e.id),n+=4})),e},e}(),H=function(){function e(e,t){this.id=e,this.success=t}return e.fromDataChannel=function(t){var n=new DataView(t);return new e(n.getUint16(1),!!n.getUint8(3))},e}(),Z=function(){function e(e,t){void 0===t&&(t=!1),this.payload=e,this.reserve=t}return e.prototype.dumps=function(){p.EnableLog;var e=function(e){for(var t,n=new Array,i=0;i<e.length;i++)(t=e.charCodeAt(i))>=65536&&t<=1114111?(n.push(t>>18&7|240),n.push(t>>12&63|128),n.push(t>>6&63|128),n.push(63&t|128)):t>=2048&&t<=65535?(n.push(t>>12&15|224),n.push(t>>6&63|128),n.push(63&t|128)):t>=128&&t<=2047?(n.push(t>>6&31|192),n.push(63&t|128)):n.push(255&t);return n}(this.payload),t=new DataView(new ArrayBuffer(4+e.length));return t.setUint8(0,exports.EventType.TextInput),t.setUint8(1,+this.reserve),t.setUint16(2,e.length),e.forEach((function(e,n){return t.setUint8(n+4,e)})),t.buffer},e}(),F=function(){function e(e,t,n,i,o,r,a,s,u){void 0===e&&(e=exports.GamepadType.GamepadXbox),void 0===t&&(t=0),this.gamepadType=e,this.gamepadUser=t,this.buttons=n,this.leftTrigger=i,this.rightTrigger=o,this.leftThumbX=r,this.leftThumbY=a,this.rightThumbX=s,this.rightThumbY=u}return e.prototype.dumps=function(){var e=new DataView(new ArrayBuffer(16));return e.setUint8(0,exports.EventType.Gamepad),e.setUint8(1,this.gamepadType),e.setUint16(2,this.gamepadUser),e.setUint16(4,this.buttons),e.setUint8(6,this.leftTrigger),e.setUint8(7,this.rightTrigger),e.setInt16(8,this.leftThumbX),e.setInt16(10,this.leftThumbY),e.setInt16(12,this.rightThumbX),e.setInt16(14,this.rightThumbY),e.buffer},e}(),Y=function(){function e(e,t,i,o,r,a,s){var u=this;void 0===i&&(i="all"),void 0===o&&(o=2e3),void 0===r&&(r=5e3),void 0===a&&(a=4e3),void 0===s&&(s=!0),this.url=e,this.iceServers=t,this.iceTransportPolicy=i,this.minBitrate=o,this.maxBitrate=r,this.startBitrate=a,this.enableAFK=s,this.event={connect:new P,afk:new P,open:new P,close:new P,queue:new P,ready:new P,cursor:new P,disconnect:new P,receivedLink:new P,receivedVideo:new P,dataChannelConnected:new P,interaction:new P,occupy:new P,kick:new P,networkChanged:new P,echo:new P,kickOut:new P},this.fps=0,this.bitrate=0,this.packetLossRate=0,this.token="",this.afk=new S,this.tan=new A,this.ready=!1,this.token=e.split("/").pop(),this.pc=new RTCPeerConnection({iceServers:t,iceTransportPolicy:i}),this.setupPeerConnection(),this.dc=this.pc.createDataChannel("sendChannel"),this.dc.binaryType="arraybuffer",this.setupDataChannel(),this.subject=n.webSocket({url:e,closeObserver:{next:function(e){return u.event.close.emit(e)}},openObserver:{next:function(e){return u.event.open.emit(e)}}}),this.setupSigning(),this.gatherStatistics()}return e.prototype.setupSigning=function(){var e=this;this.subject.subscribe({next:function(t){switch(t.action){case"connect":e.event.connect.emit(t);break;case"sdpOffer":e.pc.setRemoteDescription(new RTCSessionDescription(t.data)),e.pc.createAnswer().then((function(t){e.pc.setLocalDescription(t),e.subject.next({action:"sdpAnswer",data:t})}));break;case"candidate":e.pc.addIceCandidate(new RTCIceCandidate(t.data));break;case"sdpAnswer":e.pc.setRemoteDescription(new RTCSessionDescription(t.data));break;case"ready":e.ready||(e.ready=!0,e.linkStart(),e.event.ready.emit(t));break;case"queue":e.event.queue.emit(t.data.queueNum);break;case"peerDisconnected":e.event.disconnect.emit(t.message);break;case"operateOverTime":e.event.afk.emit(e.afk.idleTime);break;case"unready":try{e.subject.next({action:"verify",data:{token:e.token}})}catch(e){}break;case"hangUp":e.hangUp();break;case"occupy":e.event.occupy.emit("connection occupied!");break;case"kick":e.event.kick.emit(t.message),e.destory()}},error:function(t){e.event.disconnect.emit(t)},complete:function(){}})},e.prototype.setupPeerConnection=function(){var e=this;this.pc.onicecandidate=function(t){t.candidate&&e.subject.next({action:"candidate",data:t.candidate})},this.pc.ontrack=function(t){e.event.receivedVideo.emit(t.streams[0])},this.pc.oniceconnectionstatechange=function(){"disconnected"===e.pc.iceConnectionState&&e.event.networkChanged.emit(e.url)}},e.prototype.setupDataChannel=function(){var e=this;this.dc.onopen=function(n){t.interval(3e4).subscribe((function(t){return e.subject.next({action:"heartbeat"})}));var i=e;e.enableAFK&&(e.afk.start(),setTimeout((function e(){i.subject.next({action:"afk",data:{idleTime:i.afk.idleTime}}),i.subject.closed||setTimeout(e,p.AFKTimerGap)}),p.AFKTimerGap)),e.event.dataChannelConnected.emit(n)};var n=t.fromEvent(this.dc,"message").pipe(i.tap((function(e){})),i.map((function(e){return e.data})),i.share());n.pipe(i.filter((function(e){return l(e)===exports.EventType.CursorData})),i.map((function(e){return L.parse(e)}))).subscribe((function(t){return e.event.cursor.emit(t)})),n.pipe(i.filter((function(e){return l(e)===exports.EventType.KickOutController})),i.map(d)).subscribe((function(t){return e.event.kickOut.emit(t)})),n.pipe(i.filter((function(e){return l(e)===exports.EventType.URLIntercept})),i.map((function(e){return d(e,8)}))).subscribe((function(t){return e.event.receivedLink.emit(t)})),n.pipe(i.filter((function(e){return l(e)===exports.EventType.WebRTCForwardREQ})),i.map(d)).subscribe((function(t){return e.event.interaction.emit(t)})),n.pipe(i.filter((function(e){return l(e)===exports.EventType.WebRTCForwardRSP})),i.map((function(e){return H.fromDataChannel(e)}))).subscribe((function(t){return e.tan.trigger(t.id,t.success)})),n.pipe(i.filter((function(e){return[exports.EventType.EchoData,exports.EventType.EventDelay].includes(l(e))})),i.map((function(e){return z.decode(e)}))).subscribe((function(t){var n=t.timestamp,i=t.stack;return e.event.echo.emit({stack:i,latency:(new Date).getTime()-Number(n)-1e3*i})})),this.dc.onerror=function(e){},this.dc.onclose=function(e){}},e.prototype.linkStart=function(){var e=this;this.pc.createOffer({offerToReceiveAudio:!0,offerToReceiveVideo:!0}).then((function(t){e.pc.setLocalDescription(t),t.sdp=t.sdp.replace(/(a=fmtp:\d+ .*level-asymmetry-allowed=.*)\r\n/gm,"$1;x-google-start-bitrate=".concat(e.startBitrate,";x-google-max-bitrate=").concat(e.maxBitrate,";x-google-min-bitrate=").concat(e.minBitrate,"\r\n")),e.subject.next({action:"sdpOffer",data:t})}))},e.prototype.gatherStatistics=function(){var e=this;t.interval(1e3).pipe(i.mergeMap((function(){return t.from(e.pc.getStats())})),i.mergeMap((function(e){return Array.from(e.values())})),i.filter((function(e){return"inbound-rtp"===e.type&&"video"===e.mediaType})),i.pairwise(),i.map((function(e){var t=e[0],n=e[1],i=Math.floor(8*(n.bytesReceived-t.bytesReceived)/(n.timestamp-t.timestamp)),o=n.packetsLost/(n.packetsLost+n.packetsReceived);return{fps:n.framesPerSecond,bitrate:i,packetLossRate:o}}))).subscribe((function(t){var n=t.bitrate,i=t.fps,o=t.packetLossRate;e.bitrate=n,e.fps=i||0,e.packetLossRate=o}))},e.prototype.hangUp=function(){this.ready=!1,this.dc.close(),this.pc.close(),this.afk.clear(),this.pc=new RTCPeerConnection({iceServers:this.iceServers,iceTransportPolicy:this.iceTransportPolicy}),this.setupPeerConnection(),this.dc=this.pc.createDataChannel("sendChannel"),this.setupDataChannel(),this.setupSigning(),this.gatherStatistics()},e.prototype.changeBitrate=function(e){return c(this,void 0,void 0,(function(){return h(this,(function(t){return this.subject.next({action:"setBitrate",data:{value:e}}),[2]}))}))},e.prototype.changeBandwidth=function(e){var t=this;if(("chrome"===a.default.browserDetails.browser||"safari"===a.default.browserDetails.browser||"firefox"===a.default.browserDetails.browser&&a.default.browserDetails.version>=64)&&"RTCRtpSender"in window&&"setParameters"in window.RTCRtpSender.prototype){var n=this.pc.getSenders()[0],i=n.getParameters();return i.encodings||(i.encodings=[{}]),e?i.encodings[0].maxBitrate=1e3*e:delete i.encodings[0].maxBitrate,void n.setParameters(i)}this.pc.createOffer().then((function(e){return t.pc.setLocalDescription(e)})).then((function(){var n,i={type:t.pc.remoteDescription.type,sdp:e?b(t.pc.remoteDescription.sdp,e):(n=t.pc.remoteDescription.sdp,n.replace(/b=AS:.*\r\n/,"").replace(/b=TIAS:.*\r\n/,""))};return t.pc.setRemoteDescription(i)}))},e.prototype.getRTT=function(){return c(this,void 0,void 0,(function(){return h(this,(function(e){try{return[2,this.pc.getStats().then((function(e){return Array.from(e.values()).find((function(e){return"candidate-pair"===e.type}))})).then((function(e){return e.totalRoundTripTime/e.responsesReceived*1e3}))]}catch(e){return[2,Promise.resolve(0)]}return[2]}))}))},e.prototype.exit=function(){this.subject.closed||this.subject.next({action:"exit"})},e.prototype.emitUIInteraction=function(e){var t=new C,n=this.tan.order(t);return this.send(new I(e,n).dumps()),t.promise},e.prototype.echo=function(){this.send(new z(BigInt((new Date).getTime())).dumps())},e.prototype.send=function(e){if("open"!==this.dc.readyState)throw new Error("send message before DataChannel open");this.enableAFK&&this.afk.reset(),"string"==typeof e||e instanceof Blob||ArrayBuffer,this.dc.send(e)},e.prototype.destory=function(){this.dc.close(),this.pc.close(),this.afk.clear(),this.subject.unsubscribe(),Object.entries(this.event).forEach((function(e){return e[1].offAll()}))},e}(),W=function(){function e(e,t,n){var i=this;void 0===t&&(t=function(){}),void 0===n&&(n=!0),this.hostElement=e,this.canResize=!1,this.top=0,this.left=0,this.width=0,this.height=0,this.intervalID=NaN,this.onPlayHandler=[],this.resizePlayer=function(){i.canResize&&(i.hostElement.clientWidth<i.videoElement.videoWidth||i.hostElement.clientHeight<i.videoElement.videoHeight?i.resizePlayerStyleToFillWindow():i.resizePlayerStyleToActualSize())},this.onPlayHandler.push(t),this.overlayElement=document.createElement("div"),this.overlayElement.style.cssText="\n color: white;\n font-size: 1.8em;\n width: 100%;\n height: 100%;\n display: flex;\n position: absolute;\n background-color: rgba(51, 51, 51, 0.7);\n justify-content: center;\n align-items: center;\n ",this.playerElement=document.createElement("div"),this.playerElement.style.cssText="\n width: 100%;\n height: 100%;\n position: relative;\n background-color: black;\n ",this.videoElement=document.createElement("video"),this.videoElement.style.cssText="\n width: 100%;\n height: 100%;\n position: absolute;\n touch-action: none;\n ",this.videoElement.muted=!0,this.videoElement.playsInline=!0,this.videoElement.addEventListener("loadedmetadata",(function(e){i.intervalID=window.setInterval((function(){i.isBlackScreen()||(i.canResize=!0,i.hidePlayOverlay(),i.resizePlayer(),window.clearInterval(i.intervalID),i.onPlayHandler.forEach((function(e){return e()})))}),500),i.videoElement.play().catch((function(){return i.showPlayOverlay()}))})),this.playerElement.appendChild(this.videoElement),this.playerElement.appendChild(this.overlayElement),e.appendChild(this.playerElement),new s.default(this.resizePlayer).observe(e);var o=this;n&&(document.body.addEventListener("mousedown",(function e(){o.videoElement.muted=!1,document.body.removeEventListener("mousedown",e)})),window.navigator.userAgent.indexOf("Chrome")>-1?document.body.addEventListener("touchend",(function e(){o.videoElement.muted=!1,document.body.removeEventListener("touchend",e)})):document.body.addEventListener("touchstart",(function e(){o.videoElement.muted=!1,document.body.removeEventListener("touchstart",e)})))}return Object.defineProperty(e.prototype,"videoAspectRatio",{get:function(){return this.videoElement.videoHeight/this.videoElement.videoWidth},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hostAspectRatio",{get:function(){return this.hostElement.clientHeight/this.hostElement.clientWidth},enumerable:!1,configurable:!0}),e.prototype.registerOnPlay=function(e){this.onPlayHandler.push(e)},e.prototype.isBlackScreen=function(){var e,t=document.createElement("canvas"),n=t.getContext("2d");return t.width=this.videoElement.videoWidth/100,t.height=this.videoElement.videoHeight/100,n.drawImage(this.videoElement,0,0,t.width,t.height),!t.width||(null===(e=n.getImageData(0,0,t.width,t.height))||void 0===e?void 0:e.data).every((function(e){return 0===e||1===e||255===e}))},e.prototype.resizePlayerStyleToFillWindow=function(){this.videoAspectRatio?this.hostAspectRatio<this.videoAspectRatio?(this.height=this.hostElement.clientHeight,this.width=Math.floor(this.height/this.videoAspectRatio),this.left=Math.floor(.5*(this.hostElement.clientWidth-this.width)),this.top=0):(this.width=this.hostElement.clientWidth,this.height=Math.floor(this.width*this.videoAspectRatio),this.top=Math.floor(.5*(this.hostElement.clientHeight-this.height)),this.left=0):(this.width=this.hostElement.clientWidth,this.height=this.hostElement.clientHeight,this.top=0,this.left=0),this.applyStyleToPlayer()},e.prototype.resizePlayerStyleToActualSize=function(){this.width=this.videoElement.videoWidth,this.height=this.videoElement.videoHeight,this.top=Math.floor(.5*(this.hostElement.clientHeight-this.height)),this.left=Math.floor(.5*(this.hostElement.clientWidth-this.width)),this.applyStyleToPlayer()},e.prototype.applyStyleToPlayer=function(){this.playerElement.style.top="".concat(this.top,"px"),this.playerElement.style.left="".concat(this.left,"px"),this.playerElement.style.width="".concat(this.width,"px"),this.playerElement.style.height="".concat(this.height,"px")},e.prototype.destory=function(){var e;this.intervalID&&window.clearInterval(this.intervalID),this.playerElement.contains(this.videoElement)&&this.playerElement.removeChild(this.videoElement),this.playerElement.contains(this.overlayElement)&&this.playerElement.removeChild(this.overlayElement),null===(e=this.playerElement.parentNode)||void 0===e||e.removeChild(this.playerElement)},e.prototype.showTextOverlay=function(e){var t=document.createElement("div");t.innerHTML=e,this.setOverlay(t)},e.prototype.showPlayOverlay=function(){var e=this,t=document.createElement("img");t.id="play-button",t.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAPEAAAD5CAYAAAD2mNNkAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAZdEVYdFNvZnR3YXJlAHBhaW50Lm5ldCA0LjAuMjHxIGmVAAASgklEQVR4Xu2dC7BdVX2HqUCCIRASCPjAFIQREBRBBSRYbFOt8lIrFUWRFqXWsT5wbItUqFWs0KqIMPKoYEWpRS06KD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nlBaTqRZlA6qTyQhDdrm1fhBXgwGl5pJnROQ7yW6jlvwvtefAZuXppKpJmUTitrp80p9Zn1zQ8uTSTSbOisfQ9xps2pkJ/wPhe3K00j0g7otH0N8f34dXwfHo0W2ZZ2QuftY4izPDKnabwIH4Ee/yrthQ7clxBnldUP8BJ8MSa87uuV9kNH7nqIc4ZVwvshfCkuQ8Mr3YEO3dUQZ4nkD/HDmFKfe5SPLNIt6NxdDHHC+xF8BabsiSOvdBc6eJdCfBtehglvimz7rFe6Dx29CyHOQo0r8NWYOr0W2Zb+QIdva4izRDLPeldi6vSm1OfC8rFE+gMdv40hznu+GlMhfz/cEj0OR/oJnb9NIc57vQZPxCehI69ICUbTydnN1+LJmPAuKW9fRAhEk0OcZ73XYw6hOwg9v1lkKgSjqSHO5oRT8TdwKbq+WWQ6CEeTQpw7zlmocTqmTm/Ob7bomMiGICRNCHGmzT/BszClPjPyuspKZDYQlkmH+Mf4t7gct0enzSJzgdBMKsQJ70X4VHTkFRkUwlN3iFM54YN4KG6LHkQnMgyEqK4Q51nvpZjwZuQ1vCKjgDDVEeIr8XBMeL3bLDJKCNW4QpyR9zo8ArdBb1iJjAPCNeoQJ7ypFngszkc3JoiME0I2qhDnWW8Kjv0xujFBpC4I3DAhzgqrHESXUp/Z0/uQ8rIiUhcEb5AQJ7z34TfwJNy5vJyI1A0BnG2IE9yYsiffwTfizuh3XpFJQghnE+J83014v4upkL8r+qhIpAkQxg2FOOHNzzNtPhf3REdekSZRQjqVTJtzguSNeD4eWH5dRJoGAZ0a4rvxm3ghrkCnzSJNhpBWIc7/plpgwpudRZ7dLNIGCOvtJbwX42G4uPxIRNoAoU2d3iNxUflPItIaNtnk/wEGBoMdpECGHAAAAABJRU5ErkJggg==",t.alt="Start Streaming",this.setOverlay(t,(function(){e.hidePlayOverlay()}))},e.prototype.hidePlayOverlay=function(){this.clearOverlay(),this.overlayElement.style.display="none"},e.prototype.clearOverlay=function(){for(;this.overlayElement.lastChild;)this.overlayElement.removeChild(this.overlayElement.lastChild)},e.prototype.setOverlay=function(e,t){if(this.clearOverlay(),this.overlayElement.appendChild(e),this.overlayElement.style.display="flex",t){var n=this;this.overlayElement.addEventListener("click",(function e(i){t(i),n.overlayElement.removeEventListener("click",e)}))}},e}(),N=function(){function e(){}return e.createDefaultEventStream=function(e,n){e.addEventListener("contextmenu",(function(e){return e.preventDefault()}));var o=t.fromEvent(e,"mousedown").pipe(i.tap((function(e){return e.preventDefault()})),i.map((function(e){return G.formMouseEvent(e,!0).dumps()}))),r=t.fromEvent(e,"mouseup").pipe(i.tap((function(e){return e.preventDefault()})),i.map((function(e){return G.formMouseEvent(e,!1).dumps()}))),a=t.fromEvent(e,"mousemove").pipe(i.tap((function(e){return e.preventDefault()})),i.map((function(e){return f(e,n.mouseNormalizeType===exports.EventType.MouseMoveStandardization)})),i.map((function(e){var t=e.x,i=e.y,o=e.dx,r=e.dy;return new U(t,i,o,r,n.mouseMoveType,n.mouseNormalizeType).dumps()}))),s=t.fromEvent(e,"mouseleave").pipe(i.map(w),i.map((function(e){return f(e,n.mouseNormalizeType===exports.EventType.MouseMoveStandardization)})),i.map((function(e){var t=e.x,i=e.y,o=e.dx,r=e.dy;return new U(t,i,o,r,n.mouseMoveType,n.mouseNormalizeType).dumps()}))),c=t.fromEvent(e,"wheel",{passive:!1}).pipe(i.tap((function(e){return e.preventDefault()})),i.map((function(e){return O.fromWheelEvent(e).dumps()}))),h=t.fromEvent(document,"keydown").pipe(i.tap((function(e){return e.preventDefault()})),i.map((function(e){return j.fromKeyboardEvent(e,!0).dumps()}))),p=t.fromEvent(document,"keyup").pipe(i.tap((function(e){return e.preventDefault()})),i.map((function(e){return j.fromKeyboardEvent(e,!1).dumps()})));function l(e,t){var n=t===exports.TouchType.TouchUpdate?"touches":"changedTouches";return new Q(t,function(e,t){var n=e.target,i=n.videoWidth,o=n.videoHeight,r=n.clientHeight,a=n.clientWidth,s=n.getBoundingClientRect(),u=s.left,c=s.top;return t.map((function(e){var t=e.clientX,n=e.clientY;return{x:i/a*(t-u),y:o/r*(n-c),id:e.identifier}}))}(e,Array.from(e[n]))).dumps()}var d=t.fromEvent(e,"touchend"),m=t.fromEvent(e,"touchmove",{passive:!1}),v=t.fromEvent(e,"touchstart",{passive:!1}),b=t.fromEvent(e,"touchcancel"),x=m.pipe(i.tap((function(e){return e.preventDefault()})),i.takeUntil(t.merge(d,b)),i.throttleTime(100),i.filter((function(e){return 2===e.targetTouches.length})),i.pairwise(),i.map(y),i.map((function(e){return O.fromPinchZoom(e/10).dumps()})),i.repeat()),E=t.iif((function(){return n.fakeMouseWithTouch}),v.pipe(i.tap((function(e){return e.preventDefault()})),i.concatMap((function(e){return t.of((i=f({target:e.target,clientX:e.targetTouches[0].clientX,clientY:e.targetTouches[0].clientY,movementX:0,movementY:0},n.mouseNormalizeType===exports.EventType.MouseMoveStandardization),o=i.x,r=i.y,a=i.dx,s=i.dy,new U(o,r,a,s,n.mouseMoveType,n.mouseNormalizeType).dumps()),new G(3===e.targetTouches.length?exports.MouseButtonType.ButtonMiddle:n.fakeTouchType,!0).dumps());var i,o,r,a,s}))),v.pipe(i.tap((function(e){return e.preventDefault()})),i.map((function(e){return l(e,exports.TouchType.TouchDown)})))),T=t.iif((function(){return n.fakeMouseWithTouch}),m.pipe(i.tap((function(e){return e.preventDefault()})),i.takeUntil(t.merge(d,b)),i.filter((function(e){return 1===e.targetTouches.length||3===e.targetTouches.length})),i.pairwise(),i.map(g),i.map((function(e){return function(e,t,n){var i=e.movementX,o=e.movementY;return u(u({},e),{movementX:i*t,movementY:o*n})}(e,n.touchDeltaXSensitivity,n.touchDeltaYSensitivity)})),i.map((function(e){return f(e,n.mouseNormalizeType===exports.EventType.MouseMoveStandardization)})),i.map((function(e){var t=e.x,i=e.y,o=e.dx,r=e.dy;return new U(t,i,o,r,n.mouseMoveType,n.mouseNormalizeType).dumps()})),i.repeat()),m.pipe(i.tap((function(e){return e.preventDefault()})),i.map((function(e){return l(e,exports.TouchType.TouchUpdate)})))),k=t.iif((function(){return n.fakeMouseWithTouch}),t.merge(d,b).pipe(i.tap((function(e){return e.preventDefault()})),i.mapTo(new G(n.fakeTouchType,!1).dumps())),t.merge(d,b).pipe(i.tap((function(e){return e.preventDefault()})),i.map((function(e){return l(e,exports.TouchType.TouchUp)}))));return t.interval(0,t.animationFrameScheduler).pipe(i.map((function(e){return navigator.getGamepads()[0]})),i.filter((function(e){return!!e})),i.map((function(e){var t=e.axes.map((function(e){return 32767*e})),n=t[0],i=t[1],o=t[2],r=t[3],a=255*e.buttons[6].value,s=255*e.buttons[7].value;return new F(exports.GamepadType.GamepadXbox,0,0,a,s,n,-i,o,-r).dumps()}))),{wheelStream:c,keydownStream:h,keyupStream:p,mouseupStream:r,mousedownStream:o,mousemoveStream:a,zoomStream:x,startBufferStream:E,moveBufferStream:T,endBufferStream:k,leaveStream:s}},e.attachListener=function(e,n,o){var r=this.createDefaultEventStream(e,n),a=r.wheelStream,s=r.keydownStream,u=r.keyupStream,c=r.mouseupStream,h=r.mousedownStream,p=r.mousemoveStream,l=r.zoomStream,d=r.startBufferStream,f=r.moveBufferStream,m=r.endBufferStream,v=r.leaveStream;t.merge(a,s,u,c,h,p,l,d,f,m,v).pipe(i.takeUntil(t.fromEvent(o.dc,"close"))).subscribe((function(e){return o.send(e)}))},e}(),J=function(e,t,n,i,o,r){void 0===e&&(e=exports.EventType.MouseMoveStandardization),void 0===t&&(t=exports.MoveType.Passive),void 0===n&&(n=exports.MouseButtonType.ButtonLeft),void 0===i&&(i=!0),void 0===o&&(o=1),void 0===r&&(r=1),this.mouseNormalizeType=e,this.mouseMoveType=t,this.fakeTouchType=n,this.fakeMouseWithTouch=i,this.touchDeltaXSensitivity=o,this.touchDeltaYSensitivity=r};exports.Connection=Y,exports.EventDelay=z,exports.Gamepad=F,exports.Helper=N,exports.Keyboard=j,exports.MouseButton=G,exports.MouseMove=U,exports.Player=W,exports.PointerManager=X,exports.RunningState=J,exports.TextInput=Z,exports.TouchSet=Q,exports.UIInteraction=I,exports.UIInteractionResponse=H,exports.WheelScroll=O,exports.screenfull=B;

@@ -1,2 +0,2 @@

import e from"webrtc-adapter";import{interval as t,fromEvent as n,from as i,merge as o,iif as r,of as s,animationFrameScheduler as a}from"rxjs";import{webSocket as c}from"rxjs/webSocket";import{tap as u,map as h,share as l,filter as p,mergeMap as d,pairwise as f,takeUntil as m,throttleTime as v,repeat as y,concatMap as w,mapTo as g}from"rxjs/operators";import b from"resize-observer-polyfill";
import e from"webrtc-adapter";import{interval as t,fromEvent as n,from as i,merge as o,iif as r,of as a,animationFrameScheduler as s}from"rxjs";import{webSocket as c}from"rxjs/webSocket";import{tap as u,map as h,share as l,filter as d,mergeMap as p,pairwise as f,takeUntil as m,throttleTime as v,repeat as y,concatMap as w,mapTo as g}from"rxjs/operators";import b from"resize-observer-polyfill";
/*! *****************************************************************************

@@ -15,2 +15,2 @@ Copyright (c) Microsoft Corporation.

PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */var E=function(){return E=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},E.apply(this,arguments)};function k(e,t,n,i){return new(n||(n=Promise))((function(o,r){function s(e){try{c(i.next(e))}catch(e){r(e)}}function a(e){try{c(i.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((i=i.apply(e,t||[])).next())}))}function T(e,t){var n,i,o,r,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return r={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(r[Symbol.iterator]=function(){return this}),r;function a(r){return function(a){return function(r){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,i&&(o=2&r[0]?i.return:r[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,r[1])).done)return o;switch(i=0,o&&(r=[2&r[0],o.value]),r[0]){case 0:case 1:o=r;break;case 4:return s.label++,{value:r[1],done:!1};case 5:s.label++,i=r[1],r=[0];continue;case 7:r=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==r[0]&&2!==r[0])){s=0;continue}if(3===r[0]&&(!o||r[1]>o[0]&&r[1]<o[3])){s.label=r[1];break}if(6===r[0]&&s.label<o[1]){s.label=o[1],o=r;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(r);break}o[2]&&s.ops.pop(),s.trys.pop();continue}r=t.call(e,s)}catch(e){r=[6,e],i=0}finally{n=o=0}if(5&r[0])throw r[1];return{value:r[0]?r[1]:void 0,done:!0}}([r,a])}}}var x=Object.freeze({EnableLog:!0,AFKTimerGap:1e4});function D(e){return Object.keys(Array.from({length:e})).map((function(e){return Number(e)}))}var L=function(e){return new DataView(e).getUint8(0)};function M(e,t,n){void 0===t&&(t=1),void 0===n&&(n="");var i=new DataView(e);return D(e.byteLength-t).map((function(e){return String.fromCharCode(i.getUint8(e+t))})).join(n)}function B(e,t){void 0===t&&(t=!1);var n=e.target,i=n.getBoundingClientRect(),o=i.left,r=i.top,s=e.clientX,a=e.clientY,c=e.movementY,u=e.movementX,h=n.clientHeight,l=n.clientWidth,p=n.videoHeight,d=n.videoWidth;return{x:(t?d:65535)/l*(s-o),y:(t?p:65535)/h*(a-r),dx:u*((t?d:32767)/l),dy:c*((t?p:32767)/h)}}var C=function(){function e(e,t){this.x=e,this.y=t}return e.fromTouch=function(t){return new e(t.pageX,t.pageY)},e}();function S(e,t){return Math.hypot(t.x-e.x,t.y-e.y)}function P(e){var t=Array.from(e[0].targetTouches),n=t[0],i=t[1],o=Array.from(e[1].targetTouches),r=o[0],s=o[1];return S(C.fromTouch(r),C.fromTouch(s))-S(C.fromTouch(n),C.fromTouch(i))}function A(e){var t=e[0],n=e[1],i=n.targetTouches[0].clientX-t.targetTouches[0].clientX,o=n.targetTouches[0].clientY-t.targetTouches[0].clientY;return{target:t.target,clientX:t.targetTouches[0].clientX,clientY:t.targetTouches[0].clientY,movementX:i,movementY:o}}function I(t,n){var i="AS";return"firefox"===e.browserDetails.browser&&(n=1e3*(n>>>0),i="TIAS"),t=-1===t.indexOf("b="+i+":")?t.replace(/c=IN (.*)\r\n/,"c=IN $1\r\nb="+i+":"+n+"\r\n"):t.replace(new RegExp("b="+i+":.*\r\n"),"b="+i+":"+n+"\r\n")}var R,X,z,U,G,O,j=new(function(){function e(){this.APINameMap="exitFullscreen"in document?{requestFullscreen:"requestFullscreen",exitFullscreen:"exitFullscreen",fullscreenElement:"fullscreenElement",fullscreenEnabled:"fullscreenEnabled",fullscreenchange:"fullscreenchange"}:"webkitExitFullscreen"in document?{requestFullscreen:"webkitRequestFullscreen",exitFullscreen:"webkitExitFullscreen",fullscreenElement:"webkitFullscreenElement",fullscreenEnabled:"webkitFullscreenEnabled",fullscreenchange:"webkitfullscreenchange"}:{requestFullscreen:"mozRequestFullScreen",exitFullscreen:"mozCancelFullScreen",fullscreenElement:"mozFullScreenElement",fullscreenEnabled:"mozFullScreenEnabled",fullscreenchange:"mozfullscreenchange"}}return Object.defineProperty(e.prototype,"isFullscreen",{get:function(){return Boolean(document[this.APINameMap.fullscreenElement])},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"element",{get:function(){return document[this.APINameMap.fullscreenElement]},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isEnabled",{get:function(){return Boolean(document[this.APINameMap.fullscreenEnabled])},enumerable:!1,configurable:!0}),e.prototype.request=function(e,t){var n=this;return new Promise((function(i,o){var r=function(){screen.orientation.lock("landscape-primary"),document.removeEventListener(n.APINameMap.fullscreenchange,r),n.off(r),i()};n.on(r);var s=(e||document.documentElement)[n.APINameMap.requestFullscreen](t);s instanceof Promise&&s.then(r).catch(o)}))},e.prototype.exit=function(){var e=this;return new Promise((function(t,n){if(e.isFullscreen){var i=function(){e.off(i),t()};e.on(i);var o=document[e.APINameMap.exitFullscreen]();o instanceof Promise&&o.then(i).catch(n)}else t()}))},e.prototype.toggle=function(e,t){return this.isFullscreen?this.exit():this.request(e,t)},e.prototype.on=function(e){document.addEventListener(this.APINameMap.fullscreenchange,e)},e.prototype.off=function(e){document.removeEventListener(this.APINameMap.fullscreenchange,e)},e}()),Q=function(){function e(){this.timer=NaN,this.idleTime=0}return e.prototype.reset=function(){this.idleTime=0},e.prototype.start=function(){var e=this;this.timer=window.setInterval((function(){e.idleTime+=1e3}),1e3)},e.prototype.clear=function(){window.clearInterval(this.timer)},e}(),Z=function(){var e=this;this.promise=new Promise((function(t,n){e.resolve=t,e.reject=n}))},H=function(){function e(e){this.base64="",this.show=!1,this.x=0,this.y=0,this.parseCursorInfo(e)}return e.prototype.parseCursorInfo=function(t){var n=new DataView(t),i=[[1,4],[5,8],[9,12],[13,16],[17,20],[21,24],[25,28],[29,29]].reduce((function(t,i){return t.push(e.getImageInfo(n,i[0],i[1])),t}),[]),o=i[0],r=i[1],s=i[2],a=i[3],c=i[4],u=i[5],h=i[6],l=i[7];this.base64=e.arrayBuffer2base64(D(h).map((function(e){return n.getUint8(30+e)})),s,a,c,u),this.show=!!l,this.x=-o,this.y=-r},e.getImageInfo=function(e,t,n){return D(30).filter((function(e){return e>=t&&e<=n})).map((function(t){return e.getUint8(t)})).reduce((function(e,t,n){return e+=t*Math.pow(256,3-n)}),0)},e.arrayBuffer2base64=function(e,t,n,i,o){if(0===t||0===n)return"";if(1===i&&4===o)return"";var r=new Uint8Array(e),s=document.createElement("canvas");s.width=t,s.height=n;var a=s.getContext("2d"),c=null==a?void 0:a.createImageData(t,n);return null==c||c.data.set(r),c&&(null==a||a.putImageData(c,0,0)),s.toDataURL()},e}(),F=function(){var e=this;this.listeners=[],this.listenersOncer=[],this.on=function(t){return e.listeners.push(t),{dispose:function(){return e.off(t)}}},this.once=function(t){e.listenersOncer.push(t)},this.off=function(t){var n=e.listeners.indexOf(t);n>-1&&e.listeners.splice(n,1)},this.offAll=function(){e.listenersOncer=[],e.listeners=[]},this.emit=function(t){e.listeners.forEach((function(e){return e(t)})),e.listenersOncer.forEach((function(e){return e(t)})),e.listenersOncer=[]},this.pipe=function(t){return e.on((function(e){return t.emit(e)}))}},W=function(){function e(){this.currentID=0,this.executeMap=new Map}return e.prototype.obtainID=function(){return this.currentID>=65535?this.currentID=0:++this.currentID},e.prototype.trigger=function(e,t){this.executeMap.has(e)&&(this.executeMap.get(e).resolve(t),this.executeMap.delete(e))},e.prototype.order=function(e){var t=this.obtainID();return this.executeMap.set(t,e),t},e}(),Y=function(){function e(e){this.element=e,this.movementX=0,this.movementY=0,this.onLockingChange=function(){},this.attachPointLockEvent()}return e.prototype.request=function(){this.isPointerLocking||this.requestPointerLock()},e.prototype.exit=function(){this.isPointerLocking&&this.exitPointerLock()},e.prototype.exitPointerLock=function(){document.exitPointerLock=document.exitPointerLock||document.mozExitPointerLock||document.webkitExitPointerLock,document.exitPointerLock()},e.prototype.requestPointerLock=function(){this.element.requestPointerLock=this.element.requestPointerLock||this.element.mozRequestPointerLock||this.element.webkitRequestPointerLock,this.element.requestPointerLock()},e.prototype.attachPointLockEvent=function(){var e=this,t=function(){e.requestPointerLock()},n=function(){document.addEventListener("click",t,{once:!0})},i=function(){e.isPointerLocking?(e.element.addEventListener("mousemove",e.mousemove),e.emit(!0),document.removeEventListener("click",t)):(e.element.removeEventListener("mousemove",e.mousemove),e.emit(!1))};document.addEventListener("pointerlockchange",i),document.addEventListener("mozpointerlockchange",i),document.addEventListener("webkitpointerlockchange",i),document.addEventListener("pointerlockerror",n),document.addEventListener("mozpointerlockerror",n)},e.prototype.on=function(e){this.onLockingChange=e},e.prototype.emit=function(e){this.onLockingChange(e)},e.prototype.mousemove=function(e){this.movementX=e.movementX,this.movementY=e.movementY},Object.defineProperty(e.prototype,"isPointerLocking",{get:function(){return(document.pointerLockElement||document.mozPointerLockElement||document.webkitPointerLockElement)===this.element},enumerable:!1,configurable:!0}),e}();!function(e){e[e.MouseMoveStandardization=0]="MouseMoveStandardization",e[e.MouseButton=1]="MouseButton",e[e.WheelScroll=2]="WheelScroll",e[e.Keyboard=3]="Keyboard",e[e.WinTouch=4]="WinTouch",e[e.MobileTouch=5]="MobileTouch",e[e.MobileCustom=6]="MobileCustom",e[e.URLIntercept=7]="URLIntercept",e[e.CaretVisible=8]="CaretVisible",e[e.TextInput=9]="TextInput",e[e.MobileKeys=10]="MobileKeys",e[e.Gamepad=11]="Gamepad",e[e.CursorData=12]="CursorData",e[e.MouseMoveNormalization=13]="MouseMoveNormalization",e[e.EventDelay=14]="EventDelay",e[e.EchoData=15]="EchoData",e[e.KickOutController=16]="KickOutController",e[e.WebRTCPluginsMSG=125]="WebRTCPluginsMSG",e[e.WebRTCForwardRSP=126]="WebRTCForwardRSP",e[e.WebRTCForwardREQ=127]="WebRTCForwardREQ"}(R||(R={})),function(e){e[e.ButtonLeft=1]="ButtonLeft",e[e.ButtonMiddle=2]="ButtonMiddle",e[e.ButtonRight=3]="ButtonRight",e[e.ButtonX1=4]="ButtonX1",e[e.ButtonX2=5]="ButtonX2"}(X||(X={})),function(e){e[e.TouchDown=0]="TouchDown",e[e.TouchUpdate=1]="TouchUpdate",e[e.TouchUp=2]="TouchUp"}(z||(z={})),function(e){e[e.Absolute=0]="Absolute",e[e.Relative=1]="Relative",e[e.Passive=2]="Passive",e[e.Unknow=3]="Unknow"}(U||(U={})),function(e){e[e.GamepadXbox=0]="GamepadXbox"}(G||(G={})),function(e){e[e.GamepadXboxButtonDpadUp=1]="GamepadXboxButtonDpadUp",e[e.GamepadXboxButtonDpadDown=2]="GamepadXboxButtonDpadDown",e[e.GamepadXboxButtonDpadLeft=4]="GamepadXboxButtonDpadLeft",e[e.GamepadXboxButtonDpadRight=8]="GamepadXboxButtonDpadRight",e[e.GamepadXboxButtonStart=16]="GamepadXboxButtonStart",e[e.GamepadXboxButtonBack=32]="GamepadXboxButtonBack",e[e.GamepadXboxButtonLeftThumb=64]="GamepadXboxButtonLeftThumb",e[e.GamepadXboxButtonRightThumb=128]="GamepadXboxButtonRightThumb",e[e.GamepadXboxButtonLeftShoulder=256]="GamepadXboxButtonLeftShoulder",e[e.GamepadXboxButtonRightShoulder=512]="GamepadXboxButtonRightShoulder",e[e.GamepadXboxButtonA=4096]="GamepadXboxButtonA",e[e.GamepadXboxButtonB=8192]="GamepadXboxButtonB",e[e.GamepadXboxButtonX=16384]="GamepadXboxButtonX",e[e.GamepadXboxButtonY=32768]="GamepadXboxButtonY"}(O||(O={}));var N=new Map([[0,X.ButtonLeft],[1,X.ButtonMiddle],[2,X.ButtonRight],[3,X.ButtonX1],[4,X.ButtonX2]]),J=function(){function e(e,t){void 0===t&&(t=0),this.data=e,this.id=t}return e.prototype.dumps=function(){var e=new DataView(new ArrayBuffer(3+this.data.length)),t=0;e.setUint8(t,R.WebRTCForwardREQ),t++,e.setUint16(t,this.id),t+=2;for(var n=0;n<this.data.length;n++)e.setUint8(t,this.data.charCodeAt(n)),t+=1;return e.buffer},e}(),q=function(){function e(e,t){void 0===t&&(t=0),this.timestamp=e,this.stack=t}return e.prototype.dumps=function(){var e=new DataView(new ArrayBuffer(13));return e.setUint8(0,R.EventDelay),e.setBigUint64(1,this.timestamp),e.setUint32(8,this.stack),e.buffer},e.decode=function(t){var n=new DataView(t);return new e(n.getBigUint64(1),n.getUint32(8))},e}(),K=function(){function e(e,t,n,i,o,r){void 0===o&&(o=U.Unknow),void 0===r&&(r=R.MouseMoveStandardization),this.x=e,this.y=t,this.dx=n,this.dy=i,this.move=o,this.eventType=r}return e.prototype.dumps=function(){x.EnableLog;var e=new ArrayBuffer(10),t=new DataView(e);return t.setUint8(0,this.eventType),t.setUint8(1,+this.move),t.setUint16(2,this.x),t.setUint16(4,this.y),t.setUint16(6,this.dx),t.setUint16(8,this.dy),e},e}(),V=function(){function e(e,t){this.mouseButtonType=e,this.down=t}return e.prototype.dumps=function(){x.EnableLog;var e=new ArrayBuffer(3),t=new DataView(e);return t.setUint8(0,R.MouseButton),t.setUint8(1,+this.down),t.setUint8(2,this.mouseButtonType),e},e.formMouseEvent=function(t,n){if(!N.has(t.button))throw new Error("[Event] unsupport button type");return new e(N.get(t.button),n)},e}(),$=function(){function e(e,t){this.step=e,this.forward=t}return e.prototype.dumps=function(){x.EnableLog;var e=new ArrayBuffer(4),t=new DataView(e);return t.setUint8(0,R.WheelScroll),t.setUint8(1,+this.forward),t.setUint16(2,this.step),e},e.fromPinchZoom=function(t){return new e(Math.abs(t),1===Math.sign(t))},e.fromWheelEvent=function(t){var n=Math.abs(t.deltaX),i=Math.abs(t.deltaY),o=!!i,r=-1===Math.sign(o?t.deltaY:t.deltaX);return new e(o?Math.sign(i):Math.sign(n),r)},e.fromTouchDeltaY=function(t){return new e(1,t<0)},e}(),_=function(){function e(e,t,n,i,o,r,s,a){this.keycode=e,this.alt=t,this.shift=n,this.ctrl=i,this.nlock=o,this.clock=r,this.slock=s,this.down=a}return e.prototype.dumps=function(){x.EnableLog;var e=new ArrayBuffer(9),t=new DataView(e);return t.setUint8(0,R.Keyboard),t.setUint8(1,+this.down),t.setUint8(2,+this.nlock),t.setUint8(3,+this.clock),t.setUint8(4,+this.slock),t.setUint8(5,+this.shift),t.setUint8(6,+this.ctrl),t.setUint8(7,+this.alt),t.setUint8(8,+this.keycode),e},e.fromKeyboardEvent=function(t,n){return new e(t.keyCode,t.altKey,t.shiftKey,t.ctrlKey,t.getModifierState("NumLock"),t.getModifierState("CapsLock"),t.getModifierState("ScrollLock"),n)},e}(),ee=function(){function e(e,t){this.touchType=e,this.touchList=t}return e.prototype.dumps=function(){x.EnableLog;var e=new ArrayBuffer(4+8*this.touchList.length),t=new DataView(e);t.setUint8(0,R.WinTouch),t.setUint8(1,this.touchType),t.setUint16(2,this.touchList.length);var n=4;return this.touchList.forEach((function(e){t.setUint16(n,e.x),n+=2,t.setUint16(n,e.y),n+=2,t.setUint32(n,e.id),n+=4})),e},e}(),te=function(){function e(e,t){this.id=e,this.success=t}return e.fromDataChannel=function(t){var n=new DataView(t);return new e(n.getUint16(1),!!n.getUint8(3))},e}(),ne=function(){function e(e,t){void 0===t&&(t=!1),this.payload=e,this.reserve=t}return e.prototype.dumps=function(){x.EnableLog;var e=function(e){for(var t,n=new Array,i=0;i<e.length;i++)(t=e.charCodeAt(i))>=65536&&t<=1114111?(n.push(t>>18&7|240),n.push(t>>12&63|128),n.push(t>>6&63|128),n.push(63&t|128)):t>=2048&&t<=65535?(n.push(t>>12&15|224),n.push(t>>6&63|128),n.push(63&t|128)):t>=128&&t<=2047?(n.push(t>>6&31|192),n.push(63&t|128)):n.push(255&t);return n}(this.payload),t=new DataView(new ArrayBuffer(4+e.length));return t.setUint8(0,R.TextInput),t.setUint8(1,+this.reserve),t.setUint16(2,e.length),e.forEach((function(e,n){return t.setUint8(n+4,e)})),t.buffer},e}(),ie=function(){function e(e,t,n,i,o,r,s,a,c){void 0===e&&(e=G.GamepadXbox),void 0===t&&(t=0),this.gamepadType=e,this.gamepadUser=t,this.buttons=n,this.leftTrigger=i,this.rightTrigger=o,this.leftThumbX=r,this.leftThumbY=s,this.rightThumbX=a,this.rightThumbY=c}return e.prototype.dumps=function(){var e=new DataView(new ArrayBuffer(16));return e.setUint8(0,R.Gamepad),e.setUint8(1,this.gamepadType),e.setUint16(2,this.gamepadUser),e.setUint16(4,this.buttons),e.setUint8(6,this.leftTrigger),e.setUint8(7,this.rightTrigger),e.setInt16(8,this.leftThumbX),e.setInt16(10,this.leftThumbY),e.setInt16(12,this.rightThumbX),e.setInt16(14,this.rightThumbY),e.buffer},e}(),oe=function(){function o(e,t,n,i,o,r,s){var a=this;void 0===n&&(n="all"),void 0===i&&(i=2e3),void 0===o&&(o=5e3),void 0===r&&(r=4e3),void 0===s&&(s=!0),this.url=e,this.iceServers=t,this.iceTransportPolicy=n,this.minBitrate=i,this.maxBitrate=o,this.startBitrate=r,this.enableAFK=s,this.event={connect:new F,afk:new F,open:new F,close:new F,queue:new F,ready:new F,cursor:new F,disconnect:new F,receivedLink:new F,receivedVideo:new F,dataChannelConnected:new F,interaction:new F,occupy:new F,kick:new F,networkChanged:new F,echo:new F,kickOut:new F},this.fps=0,this.bitrate=0,this.packetLossRate=0,this.token="",this.afk=new Q,this.tan=new W,this.ready=!1,this.token=e.split("/").pop(),this.pc=new RTCPeerConnection({iceServers:t,iceTransportPolicy:n}),this.setupPeerConnection(),this.dc=this.pc.createDataChannel("sendChannel"),this.dc.binaryType="arraybuffer",this.setupDataChannel(),this.subject=c({url:e,closeObserver:{next:function(e){return a.event.close.emit(e)}},openObserver:{next:function(e){return a.event.open.emit(e)}}}),this.setupSigning(),this.gatherStatistics()}return o.prototype.setupSigning=function(){var e=this;this.subject.subscribe({next:function(t){switch(t.action){case"connect":e.event.connect.emit(t);break;case"sdpOffer":e.pc.setRemoteDescription(new RTCSessionDescription(t.data)),e.pc.createAnswer().then((function(t){e.pc.setLocalDescription(t),e.subject.next({action:"sdpAnswer",data:t})}));break;case"candidate":e.pc.addIceCandidate(new RTCIceCandidate(t.data));break;case"sdpAnswer":e.pc.setRemoteDescription(new RTCSessionDescription(t.data));break;case"ready":e.ready||(e.ready=!0,e.linkStart(),e.event.ready.emit(t));break;case"queue":e.event.queue.emit(t.data.queueNum);break;case"peerDisconnected":e.event.disconnect.emit(t.message);break;case"operateOverTime":e.event.afk.emit(e.afk.idleTime);break;case"unready":try{e.subject.next({action:"verify",data:{token:e.token}})}catch(e){}break;case"hangUp":e.hangUp();break;case"occupy":e.event.occupy.emit("connection occupied!");break;case"kick":e.event.kick.emit(t.message),e.destory()}},error:function(t){e.event.disconnect.emit(t)},complete:function(){}})},o.prototype.setupPeerConnection=function(){var e=this;this.pc.onicecandidate=function(t){t.candidate&&e.subject.next({action:"candidate",data:t.candidate})},this.pc.ontrack=function(t){e.event.receivedVideo.emit(t.streams[0])},this.pc.oniceconnectionstatechange=function(){"disconnected"===e.pc.iceConnectionState&&e.event.networkChanged.emit(e.url)}},o.prototype.setupDataChannel=function(){var e=this;this.dc.onopen=function(n){t(3e4).subscribe((function(t){return e.subject.next({action:"heartbeat"})}));var i=e;e.enableAFK&&(e.afk.start(),setTimeout((function e(){i.subject.next({action:"afk",data:{idleTime:i.afk.idleTime}}),i.subject.closed||setTimeout(e,x.AFKTimerGap)}),x.AFKTimerGap)),e.event.dataChannelConnected.emit(n)};var i=n(this.dc,"message").pipe(u((function(e){})),h((function(e){return e.data})),l());i.pipe(p((function(e){return L(e)===R.CursorData})),h((function(e){return new H(e)}))).subscribe((function(t){return e.event.cursor.emit(t)})),i.pipe(p((function(e){return L(e)===R.KickOutController})),h(M)).subscribe((function(t){return e.event.kickOut.emit(t)})),i.pipe(p((function(e){return L(e)===R.URLIntercept})),h((function(e){return M(e,8)}))).subscribe((function(t){return e.event.receivedLink.emit(t)})),i.pipe(p((function(e){return L(e)===R.WebRTCForwardREQ})),h(M)).subscribe((function(t){return e.event.interaction.emit(t)})),i.pipe(p((function(e){return L(e)===R.WebRTCForwardRSP})),h((function(e){return te.fromDataChannel(e)}))).subscribe((function(t){return e.tan.trigger(t.id,t.success)})),i.pipe(p((function(e){return[R.EchoData,R.EventDelay].includes(L(e))})),h((function(e){return q.decode(e)}))).subscribe((function(t){var n=t.timestamp,i=t.stack;return e.event.echo.emit({stack:i,latency:(new Date).getTime()-Number(n)-1e3*i})})),this.dc.onerror=function(e){},this.dc.onclose=function(e){}},o.prototype.linkStart=function(){var e=this;this.pc.createOffer({offerToReceiveAudio:!0,offerToReceiveVideo:!0}).then((function(t){e.pc.setLocalDescription(t),t.sdp=t.sdp.replace(/(a=fmtp:\d+ .*level-asymmetry-allowed=.*)\r\n/gm,"$1;x-google-start-bitrate=".concat(e.startBitrate,";x-google-max-bitrate=").concat(e.maxBitrate,";x-google-min-bitrate=").concat(e.minBitrate,"\r\n")),e.subject.next({action:"sdpOffer",data:t})}))},o.prototype.gatherStatistics=function(){var e=this;t(1e3).pipe(d((function(){return i(e.pc.getStats())})),d((function(e){return Array.from(e.values())})),p((function(e){return"inbound-rtp"===e.type&&"video"===e.mediaType})),f(),h((function(e){var t=e[0],n=e[1],i=Math.floor(8*(n.bytesReceived-t.bytesReceived)/(n.timestamp-t.timestamp)),o=n.packetsLost/(n.packetsLost+n.packetsReceived);return{fps:n.framesPerSecond,bitrate:i,packetLossRate:o}}))).subscribe((function(t){var n=t.bitrate,i=t.fps,o=t.packetLossRate;e.bitrate=n,e.fps=i||0,e.packetLossRate=o}))},o.prototype.hangUp=function(){this.ready=!1,this.dc.close(),this.pc.close(),this.afk.clear(),this.pc=new RTCPeerConnection({iceServers:this.iceServers,iceTransportPolicy:this.iceTransportPolicy}),this.setupPeerConnection(),this.dc=this.pc.createDataChannel("sendChannel"),this.setupDataChannel(),this.setupSigning(),this.gatherStatistics()},o.prototype.changeBitrate=function(e){return k(this,void 0,void 0,(function(){return T(this,(function(t){return this.subject.next({action:"setBitrate",data:{value:e}}),[2]}))}))},o.prototype.changeBandwidth=function(t){var n=this;if(("chrome"===e.browserDetails.browser||"safari"===e.browserDetails.browser||"firefox"===e.browserDetails.browser&&e.browserDetails.version>=64)&&"RTCRtpSender"in window&&"setParameters"in window.RTCRtpSender.prototype){var i=this.pc.getSenders()[0],o=i.getParameters();return o.encodings||(o.encodings=[{}]),t?o.encodings[0].maxBitrate=1e3*t:delete o.encodings[0].maxBitrate,void i.setParameters(o)}this.pc.createOffer().then((function(e){return n.pc.setLocalDescription(e)})).then((function(){var e,i={type:n.pc.remoteDescription.type,sdp:t?I(n.pc.remoteDescription.sdp,t):(e=n.pc.remoteDescription.sdp,e.replace(/b=AS:.*\r\n/,"").replace(/b=TIAS:.*\r\n/,""))};return n.pc.setRemoteDescription(i)}))},o.prototype.getRTT=function(){return k(this,void 0,void 0,(function(){return T(this,(function(e){try{return[2,this.pc.getStats().then((function(e){return Array.from(e.values()).find((function(e){return"candidate-pair"===e.type}))})).then((function(e){return e.totalRoundTripTime/e.responsesReceived*1e3}))]}catch(e){return[2,Promise.resolve(0)]}return[2]}))}))},o.prototype.exit=function(){this.subject.closed||this.subject.next({action:"exit"})},o.prototype.emitUIInteraction=function(e){var t=new Z,n=this.tan.order(t);return this.send(new J(e,n).dumps()),t.promise},o.prototype.echo=function(){this.send(new q(BigInt((new Date).getTime())).dumps())},o.prototype.send=function(e){if("open"!==this.dc.readyState)throw new Error("send message before DataChannel open");this.enableAFK&&this.afk.reset(),"string"==typeof e||e instanceof Blob||ArrayBuffer,this.dc.send(e)},o.prototype.destory=function(){this.dc.close(),this.pc.close(),this.afk.clear(),this.subject.unsubscribe(),Object.entries(this.event).forEach((function(e){return e[1].offAll()}))},o}(),re=function(){function e(e,t,n){var i=this;void 0===t&&(t=function(){}),void 0===n&&(n=!0),this.hostElement=e,this.canResize=!1,this.top=0,this.left=0,this.width=0,this.height=0,this.intervalID=NaN,this.pointLockChange=new F,this.onPlayHandler=[],this.resizePlayer=function(){i.canResize&&(i.hostElement.clientWidth<i.videoElement.videoWidth||i.hostElement.clientHeight<i.videoElement.videoHeight?i.resizePlayerStyleToFillWindow():i.resizePlayerStyleToActualSize())},this.onPlayHandler.push(t),this.overlayElement=document.createElement("div"),this.overlayElement.style.cssText="\n color: white;\n font-size: 1.8em;\n width: 100%;\n height: 100%;\n display: flex;\n position: absolute;\n background-color: rgba(51, 51, 51, 0.7);\n justify-content: center;\n align-items: center;\n ",this.playerElement=document.createElement("div"),this.playerElement.style.cssText="\n width: 100%;\n height: 100%;\n position: relative;\n background-color: black;\n ",this.videoElement=document.createElement("video"),this.videoElement.style.cssText="\n width: 100%;\n height: 100%;\n position: absolute;\n touch-action: none;\n ",this.videoElement.muted=!0,this.videoElement.playsInline=!0,this.videoElement.addEventListener("loadedmetadata",(function(e){i.intervalID=window.setInterval((function(){i.isBlackScreen()||(i.canResize=!0,i.hidePlayOverlay(),i.resizePlayer(),window.clearInterval(i.intervalID),i.onPlayHandler.forEach((function(e){return e()})))}),500),i.videoElement.play().catch((function(){return i.showPlayOverlay()}))})),this.playerElement.appendChild(this.videoElement),this.playerElement.appendChild(this.overlayElement),e.appendChild(this.playerElement),new b(this.resizePlayer).observe(e);var o=this;n&&(document.body.addEventListener("mousedown",(function e(){o.videoElement.muted=!1,document.body.removeEventListener("mousedown",e)})),window.navigator.userAgent.indexOf("Chrome")>-1?document.body.addEventListener("touchend",(function e(){o.videoElement.muted=!1,document.body.removeEventListener("touchend",e)})):document.body.addEventListener("touchstart",(function e(){o.videoElement.muted=!1,document.body.removeEventListener("touchstart",e)}))),this.pointerLock=new Y(this.videoElement)}return Object.defineProperty(e.prototype,"videoAspectRatio",{get:function(){return this.videoElement.videoHeight/this.videoElement.videoWidth},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hostAspectRatio",{get:function(){return this.hostElement.clientHeight/this.hostElement.clientWidth},enumerable:!1,configurable:!0}),e.prototype.registerOnPlay=function(e){this.onPlayHandler.push(e)},e.prototype.isBlackScreen=function(){var e,t=document.createElement("canvas"),n=t.getContext("2d");return t.width=this.videoElement.videoWidth/100,t.height=this.videoElement.videoHeight/100,n.drawImage(this.videoElement,0,0,t.width,t.height),!t.width||(null===(e=n.getImageData(0,0,t.width,t.height))||void 0===e?void 0:e.data).every((function(e){return 0===e||1===e||255===e}))},e.prototype.resizePlayerStyleToFillWindow=function(){this.videoAspectRatio?this.hostAspectRatio<this.videoAspectRatio?(this.height=this.hostElement.clientHeight,this.width=Math.floor(this.height/this.videoAspectRatio),this.left=Math.floor(.5*(this.hostElement.clientWidth-this.width)),this.top=0):(this.width=this.hostElement.clientWidth,this.height=Math.floor(this.width*this.videoAspectRatio),this.top=Math.floor(.5*(this.hostElement.clientHeight-this.height)),this.left=0):(this.width=this.hostElement.clientWidth,this.height=this.hostElement.clientHeight,this.top=0,this.left=0),this.applyStyleToPlayer()},e.prototype.resizePlayerStyleToActualSize=function(){this.width=this.videoElement.videoWidth,this.height=this.videoElement.videoHeight,this.top=Math.floor(.5*(this.hostElement.clientHeight-this.height)),this.left=Math.floor(.5*(this.hostElement.clientWidth-this.width)),this.applyStyleToPlayer()},e.prototype.applyStyleToPlayer=function(){this.playerElement.style.top="".concat(this.top,"px"),this.playerElement.style.left="".concat(this.left,"px"),this.playerElement.style.width="".concat(this.width,"px"),this.playerElement.style.height="".concat(this.height,"px")},e.prototype.destory=function(){var e;this.intervalID&&window.clearInterval(this.intervalID),this.playerElement.contains(this.videoElement)&&this.playerElement.removeChild(this.videoElement),this.playerElement.contains(this.overlayElement)&&this.playerElement.removeChild(this.overlayElement),null===(e=this.playerElement.parentNode)||void 0===e||e.removeChild(this.playerElement)},e.prototype.showTextOverlay=function(e){var t=document.createElement("div");t.innerHTML=e,this.setOverlay(t)},e.prototype.setCursor=function(e,t,n,i){var o=this;if(this.pointerLock.on((function(e){o.pointLockChange.emit(e)})),e){var r=document.createElement("img");r.src=e,r.onload=function(){if(r.width>32||r.height>32){var i=function(e){var t=document.createElement("canvas"),n=e.width>32?32:e.width,i=e.height>32?32:e.height;t.width=n,t.height=i;var o=t.getContext("2d");return null==o||o.drawImage(e,0,0,n,i),t.toDataURL()}(r);o.videoElement.style.cursor="url(".concat(i,") ").concat(t," ").concat(n,", auto")}else o.videoElement.style.cursor="url(".concat(e,") ").concat(t," ").concat(n,", auto")}}i?this.pointerLock.exit():this.pointerLock.request()},e.prototype.showPlayOverlay=function(){var e=this,t=document.createElement("img");t.id="play-button",t.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAPEAAAD5CAYAAAD2mNNkAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAZdEVYdFNvZnR3YXJlAHBhaW50Lm5ldCA0LjAuMjHxIGmVAAASgklEQVR4Xu2dC7BdVX2HqUCCIRASCPjAFIQREBRBBSRYbFOt8lIrFUWRFqXWsT5wbItUqFWs0KqIMPKoYEWpRS06KDjS1BeVFkVQbCw+wCfiAwGhCKWP9PuZtU24uTe59zz22Y/vm/nGkXtz7jlrr9+sdfZea/03Wb169QtxGW62iYi0D8L7NbwYj8EdcdPyIxFpA4T2P/F/8Ua8C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Ho0W2ZZ2QuftY4izPDKnabwIH4Ee/yrthQ7clxBnldUP8BJ8MSa87uuV9kNH7nqIc4ZVwvshfCkuQ8Mr3YEO3dUQZ4nkD/HDmFKfe5SPLNIt6NxdDHHC+xF8BabsiSOvdBc6eJdCfBtehglvimz7rFe6Dx29CyHOQo0r8NWYOr0W2Zb+QIdva4izRDLPeldi6vSm1OfC8rFE+gMdv40hznu+GlMhfz/cEj0OR/oJnb9NIc57vQZPxCehI69ICUbTydnN1+LJmPAuKW9fRAhEk0OcZ73XYw6hOwg9v1lkKgSjqSHO5oRT8TdwKbq+WWQ6CEeTQpw7zlmocTqmTm/Ob7bomMiGICRNCHGmzT/BszClPjPyuspKZDYQlkmH+Mf4t7gct0enzSJzgdBMKsQJ70X4VHTkFRkUwlN3iFM54YN4KG6LHkQnMgyEqK4Q51nvpZjwZuQ1vCKjgDDVEeIr8XBMeL3bLDJKCNW4QpyR9zo8ArdBb1iJjAPCNeoQJ7ypFngszkc3JoiME0I2qhDnWW8Kjv0xujFBpC4I3DAhzgqrHESXUp/Z0/uQ8rIiUhcEb5AQJ7z34TfwJNy5vJyI1A0BnG2IE9yYsiffwTfizuh3XpFJQghnE+J83014v4upkL8r+qhIpAkQxg2FOOHNzzNtPhf3REdekSZRQjqVTJtzguSNeD4eWH5dRJoGAZ0a4rvxm3ghrkCnzSJNhpBWIc7/plpgwpudRZ7dLNIGCOvtJbwX42G4uPxIRNoAoU2d3iNxUflPItIaNtnk/wEGBoMdpECGHAAAAABJRU5ErkJggg==",t.alt="Start Streaming",this.setOverlay(t,(function(){e.hidePlayOverlay()}))},e.prototype.hidePlayOverlay=function(){this.clearOverlay(),this.overlayElement.style.display="none"},e.prototype.clearOverlay=function(){for(;this.overlayElement.lastChild;)this.overlayElement.removeChild(this.overlayElement.lastChild)},e.prototype.setOverlay=function(e,t){if(this.clearOverlay(),this.overlayElement.appendChild(e),this.overlayElement.style.display="flex",t){var n=this;this.overlayElement.addEventListener("click",(function e(i){t(i),n.overlayElement.removeEventListener("click",e)}))}},e}(),se=function(){function e(){}return e.createDefaultEventStream=function(e,i){e.addEventListener("contextmenu",(function(e){return e.preventDefault()}));var c=n(e,"mousedown").pipe(u((function(e){return e.preventDefault()})),h((function(e){return V.formMouseEvent(e,!0).dumps()}))),l=n(e,"mouseup").pipe(u((function(e){return e.preventDefault()})),h((function(e){return V.formMouseEvent(e,!1).dumps()}))),d=n(e,"mousemove").pipe(u((function(e){return e.preventDefault()})),h((function(e){return B(e,i.mouseNormalizeType===R.MouseMoveStandardization)})),h((function(e){var t=e.x,n=e.y,o=e.dx,r=e.dy;return new K(t,n,o,r,i.mouseMoveType,i.mouseNormalizeType).dumps()}))),b=n(e,"wheel",{passive:!1}).pipe(u((function(e){return e.preventDefault()})),h((function(e){return $.fromWheelEvent(e).dumps()}))),k=n(document,"keydown").pipe(h((function(e){return _.fromKeyboardEvent(e,!0).dumps()}))),T=n(document,"keyup").pipe(h((function(e){return _.fromKeyboardEvent(e,!1).dumps()})));function x(e,t){var n=t===z.TouchUpdate?"touches":"changedTouches";return new ee(t,function(e,t){var n=e.target,i=n.videoWidth,o=n.videoHeight,r=n.clientHeight,s=n.clientWidth,a=n.getBoundingClientRect(),c=a.left,u=a.top;return t.map((function(e){var t=e.clientX,n=e.clientY;return{x:i/s*(t-c),y:o/r*(n-u),id:e.identifier}}))}(e,Array.from(e[n]))).dumps()}var D=n(e,"touchend"),L=n(e,"touchmove",{passive:!1}),M=n(e,"touchstart",{passive:!1}),C=n(e,"touchcancel"),S=L.pipe(u((function(e){return e.preventDefault()})),m(o(D,C)),v(100),p((function(e){return 2===e.targetTouches.length})),f(),h(P),h((function(e){return $.fromPinchZoom(e/10).dumps()})),y()),I=r((function(){return i.fakeMouseWithTouch}),M.pipe(u((function(e){return e.preventDefault()})),w((function(e){return s((t=B({target:e.target,clientX:e.targetTouches[0].clientX,clientY:e.targetTouches[0].clientY,movementX:0,movementY:0},i.mouseNormalizeType===R.MouseMoveStandardization),n=t.x,o=t.y,r=t.dx,a=t.dy,new K(n,o,r,a,i.mouseMoveType,i.mouseNormalizeType).dumps()),new V(3===e.targetTouches.length?X.ButtonMiddle:i.fakeTouchType,!0).dumps());var t,n,o,r,a}))),M.pipe(u((function(e){return e.preventDefault()})),h((function(e){return x(e,z.TouchDown)})))),U=r((function(){return i.fakeMouseWithTouch}),L.pipe(u((function(e){return e.preventDefault()})),m(o(D,C)),p((function(e){return 1===e.targetTouches.length||3===e.targetTouches.length})),f(),h(A),h((function(e){return function(e,t,n){var i=e.movementX,o=e.movementY;return E(E({},e),{movementX:i*t,movementY:o*n})}(e,i.touchDeltaXSensitivity,i.touchDeltaYSensitivity)})),h((function(e){return B(e,i.mouseNormalizeType===R.MouseMoveStandardization)})),h((function(e){var t=e.x,n=e.y,o=e.dx,r=e.dy;return new K(t,n,o,r,i.mouseMoveType,i.mouseNormalizeType).dumps()})),y()),L.pipe(u((function(e){return e.preventDefault()})),h((function(e){return x(e,z.TouchUpdate)})))),O=r((function(){return i.fakeMouseWithTouch}),o(D,C).pipe(u((function(e){return e.preventDefault()})),g(new V(i.fakeTouchType,!1).dumps())),o(D,C).pipe(u((function(e){return e.preventDefault()})),h((function(e){return x(e,z.TouchUp)}))));return t(0,a).pipe(h((function(e){return navigator.getGamepads()[0]})),p((function(e){return!!e})),h((function(e){var t=e.axes.map((function(e){return 32767*e})),n=t[0],i=t[1],o=t[2],r=t[3],s=255*e.buttons[6].value,a=255*e.buttons[7].value;return new ie(G.GamepadXbox,0,0,s,a,n,-i,o,-r).dumps()}))),{wheelStream:b,keydownStream:k,keyupStream:T,mouseupStream:l,mousedownStream:c,mousemoveStream:d,zoomStream:S,startBufferStream:I,moveBufferStream:U,endBufferStream:O}},e.attachListener=function(e,t,i){var r=this.createDefaultEventStream(e,t),s=r.wheelStream,a=r.keydownStream,c=r.keyupStream,u=r.mouseupStream,h=r.mousedownStream,l=r.mousemoveStream,p=r.zoomStream,d=r.startBufferStream,f=r.moveBufferStream,v=r.endBufferStream;o(s,a,c,u,h,l,p,d,f,v).pipe(m(n(i.dc,"close"))).subscribe((function(e){return i.send(e)}))},e}(),ae=function(e,t,n,i,o,r){void 0===e&&(e=R.MouseMoveStandardization),void 0===t&&(t=U.Unknow),void 0===n&&(n=X.ButtonLeft),void 0===i&&(i=!0),void 0===o&&(o=1),void 0===r&&(r=1),this.mouseNormalizeType=e,this.mouseMoveType=t,this.fakeTouchType=n,this.fakeMouseWithTouch=i,this.touchDeltaXSensitivity=o,this.touchDeltaYSensitivity=r};export{oe as Connection,q as EventDelay,R as EventType,ie as Gamepad,G as GamepadType,O as GamepadXboxButton,se as Helper,_ as Keyboard,V as MouseButton,X as MouseButtonType,K as MouseMove,U as MoveType,re as Player,ae as RunningState,ne as TextInput,ee as TouchSet,z as TouchType,J as UIInteraction,te as UIInteractionResponse,$ as WheelScroll,j as screenfull};
***************************************************************************** */var E=function(){return E=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},E.apply(this,arguments)};function k(e,t,n,i){return new(n||(n=Promise))((function(o,r){function a(e){try{c(i.next(e))}catch(e){r(e)}}function s(e){try{c(i.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}c((i=i.apply(e,t||[])).next())}))}function T(e,t){var n,i,o,r,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return r={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(r[Symbol.iterator]=function(){return this}),r;function s(r){return function(s){return function(r){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,i&&(o=2&r[0]?i.return:r[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,r[1])).done)return o;switch(i=0,o&&(r=[2&r[0],o.value]),r[0]){case 0:case 1:o=r;break;case 4:return a.label++,{value:r[1],done:!1};case 5:a.label++,i=r[1],r=[0];continue;case 7:r=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==r[0]&&2!==r[0])){a=0;continue}if(3===r[0]&&(!o||r[1]>o[0]&&r[1]<o[3])){a.label=r[1];break}if(6===r[0]&&a.label<o[1]){a.label=o[1],o=r;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(r);break}o[2]&&a.ops.pop(),a.trys.pop();continue}r=t.call(e,a)}catch(e){r=[6,e],i=0}finally{n=o=0}if(5&r[0])throw r[1];return{value:r[0]?r[1]:void 0,done:!0}}([r,s])}}}var x=Object.freeze({EnableLog:!0,AFKTimerGap:1e4});var D=function(e){return new DataView(e).getUint8(0)};function M(e,t,n){void 0===t&&(t=1),void 0===n&&(n="");var i,o=new DataView(e);return(i=e.byteLength-t,Object.keys(Array.from({length:i})).map((function(e){return Number(e)}))).map((function(e){return String.fromCharCode(o.getUint8(e+t))})).join(n)}function B(e,t){void 0===t&&(t=!1);var n=e.target,i=n.getBoundingClientRect(),o=i.left,r=i.top,a=e.clientX,s=e.clientY,c=e.movementY,u=e.movementX,h=n.clientHeight,l=n.clientWidth,d=n.videoHeight,p=n.videoWidth;return{x:Math.min(Math.max(a-o,0),l)*((t?p:65535)/l),y:Math.min(Math.max(s-r,0),h)*((t?d:65535)/h),dx:u*((t?p:32767)/l),dy:c*((t?d:32767)/h)}}var C=function(){function e(e,t){this.x=e,this.y=t}return e.fromTouch=function(t){return new e(t.pageX,t.pageY)},e}();function L(e,t){return Math.hypot(t.x-e.x,t.y-e.y)}function S(e){var t=Array.from(e[0].targetTouches),n=t[0],i=t[1],o=Array.from(e[1].targetTouches),r=o[0],a=o[1];return L(C.fromTouch(r),C.fromTouch(a))-L(C.fromTouch(n),C.fromTouch(i))}function P(e){var t=e[0],n=e[1],i=n.targetTouches[0].clientX-t.targetTouches[0].clientX,o=n.targetTouches[0].clientY-t.targetTouches[0].clientY;return{target:t.target,clientX:t.targetTouches[0].clientX,clientY:t.targetTouches[0].clientY,movementX:i,movementY:o}}function A(e){var t=e.target.getBoundingClientRect(),n=t.left,i=t.top,o=t.right,r=t.bottom,a=e.clientY,s=e.clientX,c=Math.abs(i-a),u=Math.abs(r-a),h=Math.abs(n-s),l=Math.abs(o-s);switch(Math.min(c,u,h,l)){case h:return{target:e.target,clientX:0,clientY:a,movementY:0,movementX:0};case c:return{target:e.target,clientX:s,clientY:0,movementY:0,movementX:0};default:return{target:e.target,clientX:s,clientY:a,movementY:0,movementX:0}}}function X(t,n){var i="AS";return"firefox"===e.browserDetails.browser&&(n=1e3*(n>>>0),i="TIAS"),t=-1===t.indexOf("b="+i+":")?t.replace(/c=IN (.*)\r\n/,"c=IN $1\r\nb="+i+":"+n+"\r\n"):t.replace(new RegExp("b="+i+":.*\r\n"),"b="+i+":"+n+"\r\n")}var R,I,z,U,G,O,j=new(function(){function e(){this.APINameMap="exitFullscreen"in document?{requestFullscreen:"requestFullscreen",exitFullscreen:"exitFullscreen",fullscreenElement:"fullscreenElement",fullscreenEnabled:"fullscreenEnabled",fullscreenchange:"fullscreenchange"}:"webkitExitFullscreen"in document?{requestFullscreen:"webkitRequestFullscreen",exitFullscreen:"webkitExitFullscreen",fullscreenElement:"webkitFullscreenElement",fullscreenEnabled:"webkitFullscreenEnabled",fullscreenchange:"webkitfullscreenchange"}:{requestFullscreen:"mozRequestFullScreen",exitFullscreen:"mozCancelFullScreen",fullscreenElement:"mozFullScreenElement",fullscreenEnabled:"mozFullScreenEnabled",fullscreenchange:"mozfullscreenchange"}}return Object.defineProperty(e.prototype,"isFullscreen",{get:function(){return Boolean(document[this.APINameMap.fullscreenElement])},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"element",{get:function(){return document[this.APINameMap.fullscreenElement]},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isEnabled",{get:function(){return Boolean(document[this.APINameMap.fullscreenEnabled])},enumerable:!1,configurable:!0}),e.prototype.request=function(e,t){var n=this;return new Promise((function(i,o){var r=function(){screen.orientation.lock("landscape-primary"),document.removeEventListener(n.APINameMap.fullscreenchange,r),n.off(r),"keyboard"in navigator&&"lock"in navigator.keyboard&&navigator.keyboard.lock(["KeyW","Escape","KeyN","KeyT","MetaLeft"]),i()};n.on(r);var a=(e||document.documentElement)[n.APINameMap.requestFullscreen](t);a instanceof Promise&&a.then(r).catch(o)}))},e.prototype.exit=function(){var e=this;return new Promise((function(t,n){if(e.isFullscreen){var i=function(){e.off(i),t()};e.on(i);var o=document[e.APINameMap.exitFullscreen]();o instanceof Promise&&o.then(i).catch(n)}else t()}))},e.prototype.toggle=function(e,t){return this.isFullscreen?this.exit():this.request(e,t)},e.prototype.on=function(e){document.addEventListener(this.APINameMap.fullscreenchange,e)},e.prototype.off=function(e){document.removeEventListener(this.APINameMap.fullscreenchange,e)},e}()),Q=function(){function e(){this.timer=NaN,this.idleTime=0}return e.prototype.reset=function(){this.idleTime=0},e.prototype.start=function(){var e=this;this.timer=window.setInterval((function(){e.idleTime+=1e3}),1e3)},e.prototype.clear=function(){window.clearInterval(this.timer)},e}(),Z=function(){var e=this;this.promise=new Promise((function(t,n){e.resolve=t,e.reject=n}))},H=function(){function e(e,t,n,i){void 0===e&&(e=""),void 0===t&&(t=!1),void 0===n&&(n=0),void 0===i&&(i=0),this.base64=e,this.show=t,this.x=n,this.y=i}return e.parse=function(t){var n=new DataView(t),i=n.getUint32(1),o=n.getUint32(5),r=n.getUint32(9),a=n.getUint32(13),s=n.getUint32(17),c=n.getUint32(21),u=n.getUint8(29);if(0===r||0===a)return new e("",!!u,-i,-o);if(1===s&&4===c)return new e("",!!u,-i,-o);var h=document.createElement("canvas"),l=h.getContext("2d");h.width=r,h.height=a;var d=l.createImageData(r,a),p=d.data;p.set(new Uint8ClampedArray(t,30));for(var f=0;f<p.length;f+=4){var m=p[f];p[f]=p[f+2],p[f+2]=m}return l.putImageData(d,0,0),new e(h.toDataURL(),!!u,i,o)},e}(),F=function(){var e=this;this.listeners=[],this.listenersOncer=[],this.on=function(t){return e.listeners.push(t),{dispose:function(){return e.off(t)}}},this.once=function(t){e.listenersOncer.push(t)},this.off=function(t){var n=e.listeners.indexOf(t);n>-1&&e.listeners.splice(n,1)},this.offAll=function(){e.listenersOncer=[],e.listeners=[]},this.emit=function(t){e.listeners.forEach((function(e){return e(t)})),e.listenersOncer.forEach((function(e){return e(t)})),e.listenersOncer=[]},this.pipe=function(t){return e.on((function(e){return t.emit(e)}))}},Y=function(){function e(){this.currentID=0,this.executeMap=new Map}return e.prototype.obtainID=function(){return this.currentID>=65535?this.currentID=0:++this.currentID},e.prototype.trigger=function(e,t){this.executeMap.has(e)&&(this.executeMap.get(e).resolve(t),this.executeMap.delete(e))},e.prototype.order=function(e){var t=this.obtainID();return this.executeMap.set(t,e),t},e}(),W=function(){function e(e,t){var n=this;void 0===t&&(t=function(){}),this.target=e,this.onExit=t,this.cursor=new H,this.handleVisibilityChange=function(){"visible"!==document.visibilityState||n.cursor.show||n.target.requestPointerLock()},this.handlePointerLockError=function(){document.addEventListener("click",(function(){n.cursor.show||n.target.requestPointerLock()}),{once:!0})},this.handlePointerLockChange=function(){n.isPointerLocking||n.cursor.show||j.isFullscreen||n.onExit()},e.requestPointerLock=e.requestPointerLock||e.mozRequestPointerLock||e.webkitRequestPointerLock,document.exitPointerLock=document.exitPointerLock||document.mozExitPointerLock||document.webkitExitPointerLock,document.addEventListener("pointerlockchange",this.handlePointerLockChange),document.addEventListener("pointerlockerror",this.handlePointerLockError),document.addEventListener("visibilitychange",this.handleVisibilityChange)}return e.prototype.destory=function(){document.removeEventListener("pointerlockerror",this.handlePointerLockChange),document.removeEventListener("pointerlockchange",this.handlePointerLockError),document.removeEventListener("visibilitychange",this.handleVisibilityChange)},e.prototype.setCursor=function(e){var t=this;if(this.cursor=e,e.show?document.exitPointerLock():this.target.requestPointerLock(),e.base64){var n=document.createElement("img");n.src=e.base64,n.onload=function(){if(n.width>32||n.height>32){var i=function(e){var t=document.createElement("canvas"),n=e.width>32?32:e.width,i=e.height>32?32:e.height;t.width=n,t.height=i;var o=t.getContext("2d");return null==o||o.drawImage(e,0,0,n,i),t.toDataURL()}(n);t.target.style.cursor="url(".concat(i,") ").concat(e.x," ").concat(e.y,", auto")}else t.target.style.cursor="url(".concat(e.base64,") ").concat(e.x," ").concat(e.y,", auto")}}else this.target.style.cursor="none"},Object.defineProperty(e.prototype,"isPointerLocking",{get:function(){return(document.pointerLockElement||document.mozPointerLockElement||document.webkitPointerLockElement)===this.target},enumerable:!1,configurable:!0}),e}();!function(e){e[e.MouseMoveStandardization=0]="MouseMoveStandardization",e[e.MouseButton=1]="MouseButton",e[e.WheelScroll=2]="WheelScroll",e[e.Keyboard=3]="Keyboard",e[e.WinTouch=4]="WinTouch",e[e.MobileTouch=5]="MobileTouch",e[e.MobileCustom=6]="MobileCustom",e[e.URLIntercept=7]="URLIntercept",e[e.CaretVisible=8]="CaretVisible",e[e.TextInput=9]="TextInput",e[e.MobileKeys=10]="MobileKeys",e[e.Gamepad=11]="Gamepad",e[e.CursorData=12]="CursorData",e[e.MouseMoveNormalization=13]="MouseMoveNormalization",e[e.EventDelay=14]="EventDelay",e[e.EchoData=15]="EchoData",e[e.KickOutController=16]="KickOutController",e[e.WebRTCPluginsMSG=125]="WebRTCPluginsMSG",e[e.WebRTCForwardRSP=126]="WebRTCForwardRSP",e[e.WebRTCForwardREQ=127]="WebRTCForwardREQ"}(R||(R={})),function(e){e[e.ButtonLeft=1]="ButtonLeft",e[e.ButtonMiddle=2]="ButtonMiddle",e[e.ButtonRight=3]="ButtonRight",e[e.ButtonX1=4]="ButtonX1",e[e.ButtonX2=5]="ButtonX2"}(I||(I={})),function(e){e[e.TouchDown=0]="TouchDown",e[e.TouchUpdate=1]="TouchUpdate",e[e.TouchUp=2]="TouchUp"}(z||(z={})),function(e){e[e.Absolute=0]="Absolute",e[e.Relative=1]="Relative",e[e.Passive=2]="Passive",e[e.Unknow=3]="Unknow"}(U||(U={})),function(e){e[e.GamepadXbox=0]="GamepadXbox"}(G||(G={})),function(e){e[e.GamepadXboxButtonDpadUp=1]="GamepadXboxButtonDpadUp",e[e.GamepadXboxButtonDpadDown=2]="GamepadXboxButtonDpadDown",e[e.GamepadXboxButtonDpadLeft=4]="GamepadXboxButtonDpadLeft",e[e.GamepadXboxButtonDpadRight=8]="GamepadXboxButtonDpadRight",e[e.GamepadXboxButtonStart=16]="GamepadXboxButtonStart",e[e.GamepadXboxButtonBack=32]="GamepadXboxButtonBack",e[e.GamepadXboxButtonLeftThumb=64]="GamepadXboxButtonLeftThumb",e[e.GamepadXboxButtonRightThumb=128]="GamepadXboxButtonRightThumb",e[e.GamepadXboxButtonLeftShoulder=256]="GamepadXboxButtonLeftShoulder",e[e.GamepadXboxButtonRightShoulder=512]="GamepadXboxButtonRightShoulder",e[e.GamepadXboxButtonA=4096]="GamepadXboxButtonA",e[e.GamepadXboxButtonB=8192]="GamepadXboxButtonB",e[e.GamepadXboxButtonX=16384]="GamepadXboxButtonX",e[e.GamepadXboxButtonY=32768]="GamepadXboxButtonY"}(O||(O={}));var N=new Map([[0,I.ButtonLeft],[1,I.ButtonMiddle],[2,I.ButtonRight],[3,I.ButtonX1],[4,I.ButtonX2]]),J=function(){function e(e,t){void 0===t&&(t=0),this.data=e,this.id=t}return e.prototype.dumps=function(){var e=new DataView(new ArrayBuffer(3+this.data.length)),t=0;e.setUint8(t,R.WebRTCForwardREQ),t++,e.setUint16(t,this.id),t+=2;for(var n=0;n<this.data.length;n++)e.setUint8(t,this.data.charCodeAt(n)),t+=1;return e.buffer},e}(),K=function(){function e(e,t){void 0===t&&(t=0),this.timestamp=e,this.stack=t}return e.prototype.dumps=function(){var e=new DataView(new ArrayBuffer(13));return e.setUint8(0,R.EventDelay),e.setBigUint64(1,this.timestamp),e.setUint32(8,this.stack),e.buffer},e.decode=function(t){var n=new DataView(t);return new e(n.getBigUint64(1),n.getUint32(8))},e}(),q=function(){function e(e,t,n,i,o,r){void 0===o&&(o=U.Passive),void 0===r&&(r=R.MouseMoveStandardization),this.x=e,this.y=t,this.dx=n,this.dy=i,this.move=o,this.eventType=r}return e.prototype.dumps=function(){x.EnableLog;var e=new ArrayBuffer(10),t=new DataView(e);return t.setUint8(0,this.eventType),t.setUint8(1,+this.move),t.setUint16(2,this.x),t.setUint16(4,this.y),t.setUint16(6,this.dx),t.setUint16(8,this.dy),e},e}(),V=function(){function e(e,t){this.mouseButtonType=e,this.down=t}return e.prototype.dumps=function(){x.EnableLog;var e=new ArrayBuffer(3),t=new DataView(e);return t.setUint8(0,R.MouseButton),t.setUint8(1,+this.down),t.setUint8(2,this.mouseButtonType),e},e.formMouseEvent=function(t,n){if(!N.has(t.button))throw new Error("[Event] unsupport button type");return new e(N.get(t.button),n)},e}(),$=function(){function e(e,t){this.step=e,this.forward=t}return e.prototype.dumps=function(){x.EnableLog;var e=new ArrayBuffer(4),t=new DataView(e);return t.setUint8(0,R.WheelScroll),t.setUint8(1,+this.forward),t.setUint16(2,this.step),e},e.fromPinchZoom=function(t){return new e(Math.abs(t),1===Math.sign(t))},e.fromWheelEvent=function(t){var n=Math.abs(t.deltaX),i=Math.abs(t.deltaY),o=!!i,r=-1===Math.sign(o?t.deltaY:t.deltaX);return new e(o?Math.sign(i):Math.sign(n),r)},e.fromTouchDeltaY=function(t){return new e(1,t<0)},e}(),_=function(){function e(e,t,n,i,o,r,a,s){this.keycode=e,this.alt=t,this.shift=n,this.ctrl=i,this.nlock=o,this.clock=r,this.slock=a,this.down=s}return e.prototype.dumps=function(){x.EnableLog;var e=new ArrayBuffer(9),t=new DataView(e);return t.setUint8(0,R.Keyboard),t.setUint8(1,+this.down),t.setUint8(2,+this.nlock),t.setUint8(3,+this.clock),t.setUint8(4,+this.slock),t.setUint8(5,+this.shift),t.setUint8(6,+this.ctrl),t.setUint8(7,+this.alt),t.setUint8(8,+this.keycode),e},e.fromKeyboardEvent=function(t,n){return new e(t.keyCode,t.altKey,t.shiftKey,t.ctrlKey,t.getModifierState("NumLock"),t.getModifierState("CapsLock"),t.getModifierState("ScrollLock"),n)},e}(),ee=function(){function e(e,t){this.touchType=e,this.touchList=t}return e.prototype.dumps=function(){x.EnableLog;var e=new ArrayBuffer(4+8*this.touchList.length),t=new DataView(e);t.setUint8(0,R.WinTouch),t.setUint8(1,this.touchType),t.setUint16(2,this.touchList.length);var n=4;return this.touchList.forEach((function(e){t.setUint16(n,e.x),n+=2,t.setUint16(n,e.y),n+=2,t.setUint32(n,e.id),n+=4})),e},e}(),te=function(){function e(e,t){this.id=e,this.success=t}return e.fromDataChannel=function(t){var n=new DataView(t);return new e(n.getUint16(1),!!n.getUint8(3))},e}(),ne=function(){function e(e,t){void 0===t&&(t=!1),this.payload=e,this.reserve=t}return e.prototype.dumps=function(){x.EnableLog;var e=function(e){for(var t,n=new Array,i=0;i<e.length;i++)(t=e.charCodeAt(i))>=65536&&t<=1114111?(n.push(t>>18&7|240),n.push(t>>12&63|128),n.push(t>>6&63|128),n.push(63&t|128)):t>=2048&&t<=65535?(n.push(t>>12&15|224),n.push(t>>6&63|128),n.push(63&t|128)):t>=128&&t<=2047?(n.push(t>>6&31|192),n.push(63&t|128)):n.push(255&t);return n}(this.payload),t=new DataView(new ArrayBuffer(4+e.length));return t.setUint8(0,R.TextInput),t.setUint8(1,+this.reserve),t.setUint16(2,e.length),e.forEach((function(e,n){return t.setUint8(n+4,e)})),t.buffer},e}(),ie=function(){function e(e,t,n,i,o,r,a,s,c){void 0===e&&(e=G.GamepadXbox),void 0===t&&(t=0),this.gamepadType=e,this.gamepadUser=t,this.buttons=n,this.leftTrigger=i,this.rightTrigger=o,this.leftThumbX=r,this.leftThumbY=a,this.rightThumbX=s,this.rightThumbY=c}return e.prototype.dumps=function(){var e=new DataView(new ArrayBuffer(16));return e.setUint8(0,R.Gamepad),e.setUint8(1,this.gamepadType),e.setUint16(2,this.gamepadUser),e.setUint16(4,this.buttons),e.setUint8(6,this.leftTrigger),e.setUint8(7,this.rightTrigger),e.setInt16(8,this.leftThumbX),e.setInt16(10,this.leftThumbY),e.setInt16(12,this.rightThumbX),e.setInt16(14,this.rightThumbY),e.buffer},e}(),oe=function(){function o(e,t,n,i,o,r,a){var s=this;void 0===n&&(n="all"),void 0===i&&(i=2e3),void 0===o&&(o=5e3),void 0===r&&(r=4e3),void 0===a&&(a=!0),this.url=e,this.iceServers=t,this.iceTransportPolicy=n,this.minBitrate=i,this.maxBitrate=o,this.startBitrate=r,this.enableAFK=a,this.event={connect:new F,afk:new F,open:new F,close:new F,queue:new F,ready:new F,cursor:new F,disconnect:new F,receivedLink:new F,receivedVideo:new F,dataChannelConnected:new F,interaction:new F,occupy:new F,kick:new F,networkChanged:new F,echo:new F,kickOut:new F},this.fps=0,this.bitrate=0,this.packetLossRate=0,this.token="",this.afk=new Q,this.tan=new Y,this.ready=!1,this.token=e.split("/").pop(),this.pc=new RTCPeerConnection({iceServers:t,iceTransportPolicy:n}),this.setupPeerConnection(),this.dc=this.pc.createDataChannel("sendChannel"),this.dc.binaryType="arraybuffer",this.setupDataChannel(),this.subject=c({url:e,closeObserver:{next:function(e){return s.event.close.emit(e)}},openObserver:{next:function(e){return s.event.open.emit(e)}}}),this.setupSigning(),this.gatherStatistics()}return o.prototype.setupSigning=function(){var e=this;this.subject.subscribe({next:function(t){switch(t.action){case"connect":e.event.connect.emit(t);break;case"sdpOffer":e.pc.setRemoteDescription(new RTCSessionDescription(t.data)),e.pc.createAnswer().then((function(t){e.pc.setLocalDescription(t),e.subject.next({action:"sdpAnswer",data:t})}));break;case"candidate":e.pc.addIceCandidate(new RTCIceCandidate(t.data));break;case"sdpAnswer":e.pc.setRemoteDescription(new RTCSessionDescription(t.data));break;case"ready":e.ready||(e.ready=!0,e.linkStart(),e.event.ready.emit(t));break;case"queue":e.event.queue.emit(t.data.queueNum);break;case"peerDisconnected":e.event.disconnect.emit(t.message);break;case"operateOverTime":e.event.afk.emit(e.afk.idleTime);break;case"unready":try{e.subject.next({action:"verify",data:{token:e.token}})}catch(e){}break;case"hangUp":e.hangUp();break;case"occupy":e.event.occupy.emit("connection occupied!");break;case"kick":e.event.kick.emit(t.message),e.destory()}},error:function(t){e.event.disconnect.emit(t)},complete:function(){}})},o.prototype.setupPeerConnection=function(){var e=this;this.pc.onicecandidate=function(t){t.candidate&&e.subject.next({action:"candidate",data:t.candidate})},this.pc.ontrack=function(t){e.event.receivedVideo.emit(t.streams[0])},this.pc.oniceconnectionstatechange=function(){"disconnected"===e.pc.iceConnectionState&&e.event.networkChanged.emit(e.url)}},o.prototype.setupDataChannel=function(){var e=this;this.dc.onopen=function(n){t(3e4).subscribe((function(t){return e.subject.next({action:"heartbeat"})}));var i=e;e.enableAFK&&(e.afk.start(),setTimeout((function e(){i.subject.next({action:"afk",data:{idleTime:i.afk.idleTime}}),i.subject.closed||setTimeout(e,x.AFKTimerGap)}),x.AFKTimerGap)),e.event.dataChannelConnected.emit(n)};var i=n(this.dc,"message").pipe(u((function(e){})),h((function(e){return e.data})),l());i.pipe(d((function(e){return D(e)===R.CursorData})),h((function(e){return H.parse(e)}))).subscribe((function(t){return e.event.cursor.emit(t)})),i.pipe(d((function(e){return D(e)===R.KickOutController})),h(M)).subscribe((function(t){return e.event.kickOut.emit(t)})),i.pipe(d((function(e){return D(e)===R.URLIntercept})),h((function(e){return M(e,8)}))).subscribe((function(t){return e.event.receivedLink.emit(t)})),i.pipe(d((function(e){return D(e)===R.WebRTCForwardREQ})),h(M)).subscribe((function(t){return e.event.interaction.emit(t)})),i.pipe(d((function(e){return D(e)===R.WebRTCForwardRSP})),h((function(e){return te.fromDataChannel(e)}))).subscribe((function(t){return e.tan.trigger(t.id,t.success)})),i.pipe(d((function(e){return[R.EchoData,R.EventDelay].includes(D(e))})),h((function(e){return K.decode(e)}))).subscribe((function(t){var n=t.timestamp,i=t.stack;return e.event.echo.emit({stack:i,latency:(new Date).getTime()-Number(n)-1e3*i})})),this.dc.onerror=function(e){},this.dc.onclose=function(e){}},o.prototype.linkStart=function(){var e=this;this.pc.createOffer({offerToReceiveAudio:!0,offerToReceiveVideo:!0}).then((function(t){e.pc.setLocalDescription(t),t.sdp=t.sdp.replace(/(a=fmtp:\d+ .*level-asymmetry-allowed=.*)\r\n/gm,"$1;x-google-start-bitrate=".concat(e.startBitrate,";x-google-max-bitrate=").concat(e.maxBitrate,";x-google-min-bitrate=").concat(e.minBitrate,"\r\n")),e.subject.next({action:"sdpOffer",data:t})}))},o.prototype.gatherStatistics=function(){var e=this;t(1e3).pipe(p((function(){return i(e.pc.getStats())})),p((function(e){return Array.from(e.values())})),d((function(e){return"inbound-rtp"===e.type&&"video"===e.mediaType})),f(),h((function(e){var t=e[0],n=e[1],i=Math.floor(8*(n.bytesReceived-t.bytesReceived)/(n.timestamp-t.timestamp)),o=n.packetsLost/(n.packetsLost+n.packetsReceived);return{fps:n.framesPerSecond,bitrate:i,packetLossRate:o}}))).subscribe((function(t){var n=t.bitrate,i=t.fps,o=t.packetLossRate;e.bitrate=n,e.fps=i||0,e.packetLossRate=o}))},o.prototype.hangUp=function(){this.ready=!1,this.dc.close(),this.pc.close(),this.afk.clear(),this.pc=new RTCPeerConnection({iceServers:this.iceServers,iceTransportPolicy:this.iceTransportPolicy}),this.setupPeerConnection(),this.dc=this.pc.createDataChannel("sendChannel"),this.setupDataChannel(),this.setupSigning(),this.gatherStatistics()},o.prototype.changeBitrate=function(e){return k(this,void 0,void 0,(function(){return T(this,(function(t){return this.subject.next({action:"setBitrate",data:{value:e}}),[2]}))}))},o.prototype.changeBandwidth=function(t){var n=this;if(("chrome"===e.browserDetails.browser||"safari"===e.browserDetails.browser||"firefox"===e.browserDetails.browser&&e.browserDetails.version>=64)&&"RTCRtpSender"in window&&"setParameters"in window.RTCRtpSender.prototype){var i=this.pc.getSenders()[0],o=i.getParameters();return o.encodings||(o.encodings=[{}]),t?o.encodings[0].maxBitrate=1e3*t:delete o.encodings[0].maxBitrate,void i.setParameters(o)}this.pc.createOffer().then((function(e){return n.pc.setLocalDescription(e)})).then((function(){var e,i={type:n.pc.remoteDescription.type,sdp:t?X(n.pc.remoteDescription.sdp,t):(e=n.pc.remoteDescription.sdp,e.replace(/b=AS:.*\r\n/,"").replace(/b=TIAS:.*\r\n/,""))};return n.pc.setRemoteDescription(i)}))},o.prototype.getRTT=function(){return k(this,void 0,void 0,(function(){return T(this,(function(e){try{return[2,this.pc.getStats().then((function(e){return Array.from(e.values()).find((function(e){return"candidate-pair"===e.type}))})).then((function(e){return e.totalRoundTripTime/e.responsesReceived*1e3}))]}catch(e){return[2,Promise.resolve(0)]}return[2]}))}))},o.prototype.exit=function(){this.subject.closed||this.subject.next({action:"exit"})},o.prototype.emitUIInteraction=function(e){var t=new Z,n=this.tan.order(t);return this.send(new J(e,n).dumps()),t.promise},o.prototype.echo=function(){this.send(new K(BigInt((new Date).getTime())).dumps())},o.prototype.send=function(e){if("open"!==this.dc.readyState)throw new Error("send message before DataChannel open");this.enableAFK&&this.afk.reset(),"string"==typeof e||e instanceof Blob||ArrayBuffer,this.dc.send(e)},o.prototype.destory=function(){this.dc.close(),this.pc.close(),this.afk.clear(),this.subject.unsubscribe(),Object.entries(this.event).forEach((function(e){return e[1].offAll()}))},o}(),re=function(){function e(e,t,n){var i=this;void 0===t&&(t=function(){}),void 0===n&&(n=!0),this.hostElement=e,this.canResize=!1,this.top=0,this.left=0,this.width=0,this.height=0,this.intervalID=NaN,this.onPlayHandler=[],this.resizePlayer=function(){i.canResize&&(i.hostElement.clientWidth<i.videoElement.videoWidth||i.hostElement.clientHeight<i.videoElement.videoHeight?i.resizePlayerStyleToFillWindow():i.resizePlayerStyleToActualSize())},this.onPlayHandler.push(t),this.overlayElement=document.createElement("div"),this.overlayElement.style.cssText="\n color: white;\n font-size: 1.8em;\n width: 100%;\n height: 100%;\n display: flex;\n position: absolute;\n background-color: rgba(51, 51, 51, 0.7);\n justify-content: center;\n align-items: center;\n ",this.playerElement=document.createElement("div"),this.playerElement.style.cssText="\n width: 100%;\n height: 100%;\n position: relative;\n background-color: black;\n ",this.videoElement=document.createElement("video"),this.videoElement.style.cssText="\n width: 100%;\n height: 100%;\n position: absolute;\n touch-action: none;\n ",this.videoElement.muted=!0,this.videoElement.playsInline=!0,this.videoElement.addEventListener("loadedmetadata",(function(e){i.intervalID=window.setInterval((function(){i.isBlackScreen()||(i.canResize=!0,i.hidePlayOverlay(),i.resizePlayer(),window.clearInterval(i.intervalID),i.onPlayHandler.forEach((function(e){return e()})))}),500),i.videoElement.play().catch((function(){return i.showPlayOverlay()}))})),this.playerElement.appendChild(this.videoElement),this.playerElement.appendChild(this.overlayElement),e.appendChild(this.playerElement),new b(this.resizePlayer).observe(e);var o=this;n&&(document.body.addEventListener("mousedown",(function e(){o.videoElement.muted=!1,document.body.removeEventListener("mousedown",e)})),window.navigator.userAgent.indexOf("Chrome")>-1?document.body.addEventListener("touchend",(function e(){o.videoElement.muted=!1,document.body.removeEventListener("touchend",e)})):document.body.addEventListener("touchstart",(function e(){o.videoElement.muted=!1,document.body.removeEventListener("touchstart",e)})))}return Object.defineProperty(e.prototype,"videoAspectRatio",{get:function(){return this.videoElement.videoHeight/this.videoElement.videoWidth},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hostAspectRatio",{get:function(){return this.hostElement.clientHeight/this.hostElement.clientWidth},enumerable:!1,configurable:!0}),e.prototype.registerOnPlay=function(e){this.onPlayHandler.push(e)},e.prototype.isBlackScreen=function(){var e,t=document.createElement("canvas"),n=t.getContext("2d");return t.width=this.videoElement.videoWidth/100,t.height=this.videoElement.videoHeight/100,n.drawImage(this.videoElement,0,0,t.width,t.height),!t.width||(null===(e=n.getImageData(0,0,t.width,t.height))||void 0===e?void 0:e.data).every((function(e){return 0===e||1===e||255===e}))},e.prototype.resizePlayerStyleToFillWindow=function(){this.videoAspectRatio?this.hostAspectRatio<this.videoAspectRatio?(this.height=this.hostElement.clientHeight,this.width=Math.floor(this.height/this.videoAspectRatio),this.left=Math.floor(.5*(this.hostElement.clientWidth-this.width)),this.top=0):(this.width=this.hostElement.clientWidth,this.height=Math.floor(this.width*this.videoAspectRatio),this.top=Math.floor(.5*(this.hostElement.clientHeight-this.height)),this.left=0):(this.width=this.hostElement.clientWidth,this.height=this.hostElement.clientHeight,this.top=0,this.left=0),this.applyStyleToPlayer()},e.prototype.resizePlayerStyleToActualSize=function(){this.width=this.videoElement.videoWidth,this.height=this.videoElement.videoHeight,this.top=Math.floor(.5*(this.hostElement.clientHeight-this.height)),this.left=Math.floor(.5*(this.hostElement.clientWidth-this.width)),this.applyStyleToPlayer()},e.prototype.applyStyleToPlayer=function(){this.playerElement.style.top="".concat(this.top,"px"),this.playerElement.style.left="".concat(this.left,"px"),this.playerElement.style.width="".concat(this.width,"px"),this.playerElement.style.height="".concat(this.height,"px")},e.prototype.destory=function(){var e;this.intervalID&&window.clearInterval(this.intervalID),this.playerElement.contains(this.videoElement)&&this.playerElement.removeChild(this.videoElement),this.playerElement.contains(this.overlayElement)&&this.playerElement.removeChild(this.overlayElement),null===(e=this.playerElement.parentNode)||void 0===e||e.removeChild(this.playerElement)},e.prototype.showTextOverlay=function(e){var t=document.createElement("div");t.innerHTML=e,this.setOverlay(t)},e.prototype.showPlayOverlay=function(){var e=this,t=document.createElement("img");t.id="play-button",t.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAPEAAAD5CAYAAAD2mNNkAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAZdEVYdFNvZnR3YXJlAHBhaW50Lm5ldCA0LjAuMjHxIGmVAAASgklEQVR4Xu2dC7BdVX2HqUCCIRASCPjAFIQREBRBBSRYbFOt8lIrFUWRFqXWsT5wbItUqFWs0KqIMPKoYEWpRS06KDjS1BeVFkVQbCw+wCfiAwGhCKWP9PuZtU24uTe59zz22Y/vm/nGkXtz7jlrr9+sdfZea/03Wb169QtxGW62iYi0D8L7NbwYj8EdcdPyIxFpA4T2P/F/8Ua8CI/GhPnXyq+ISJMhrAlxxX9hRuYL8Sh8SPk1EWkqBHXdEFfcg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a87uuV9kNH7nqIc4ZVwvshfCkuQ8Mr3YEO3dUQZ4nkD/HDmFKfe5SPLNIt6NxdDHHC+xF8BabsiSOvdBc6eJdCfBtehglvimz7rFe6Dx29CyHOQo0r8NWYOr0W2Zb+QIdva4izRDLPeldi6vSm1OfC8rFE+gMdv40hznu+GlMhfz/cEj0OR/oJnb9NIc57vQZPxCehI69ICUbTydnN1+LJmPAuKW9fRAhEk0OcZ73XYw6hOwg9v1lkKgSjqSHO5oRT8TdwKbq+WWQ6CEeTQpw7zlmocTqmTm/Ob7bomMiGICRNCHGmzT/BszClPjPyuspKZDYQlkmH+Mf4t7gct0enzSJzgdBMKsQJ70X4VHTkFRkUwlN3iFM54YN4KG6LHkQnMgyEqK4Q51nvpZjwZuQ1vCKjgDDVEeIr8XBMeL3bLDJKCNW4QpyR9zo8ArdBb1iJjAPCNeoQJ7ypFngszkc3JoiME0I2qhDnWW8Kjv0xujFBpC4I3DAhzgqrHESXUp/Z0/uQ8rIiUhcEb5AQJ7z34TfwJNy5vJyI1A0BnG2IE9yYsiffwTfizuh3XpFJQghnE+J83014v4upkL8r+qhIpAkQxg2FOOHNzzNtPhf3REdekSZRQjqVTJtzguSNeD4eWH5dRJoGAZ0a4rvxm3ghrkCnzSJNhpBWIc7/plpgwpudRZ7dLNIGCOvtJbwX42G4uPxIRNoAoU2d3iNxUflPItIaNtnk/wEGBoMdpECGHAAAAABJRU5ErkJggg==",t.alt="Start Streaming",this.setOverlay(t,(function(){e.hidePlayOverlay()}))},e.prototype.hidePlayOverlay=function(){this.clearOverlay(),this.overlayElement.style.display="none"},e.prototype.clearOverlay=function(){for(;this.overlayElement.lastChild;)this.overlayElement.removeChild(this.overlayElement.lastChild)},e.prototype.setOverlay=function(e,t){if(this.clearOverlay(),this.overlayElement.appendChild(e),this.overlayElement.style.display="flex",t){var n=this;this.overlayElement.addEventListener("click",(function e(i){t(i),n.overlayElement.removeEventListener("click",e)}))}},e}(),ae=function(){function e(){}return e.createDefaultEventStream=function(e,i){e.addEventListener("contextmenu",(function(e){return e.preventDefault()}));var c=n(e,"mousedown").pipe(u((function(e){return e.preventDefault()})),h((function(e){return V.formMouseEvent(e,!0).dumps()}))),l=n(e,"mouseup").pipe(u((function(e){return e.preventDefault()})),h((function(e){return V.formMouseEvent(e,!1).dumps()}))),p=n(e,"mousemove").pipe(u((function(e){return e.preventDefault()})),h((function(e){return B(e,i.mouseNormalizeType===R.MouseMoveStandardization)})),h((function(e){var t=e.x,n=e.y,o=e.dx,r=e.dy;return new q(t,n,o,r,i.mouseMoveType,i.mouseNormalizeType).dumps()}))),b=n(e,"mouseleave").pipe(h(A),h((function(e){return B(e,i.mouseNormalizeType===R.MouseMoveStandardization)})),h((function(e){var t=e.x,n=e.y,o=e.dx,r=e.dy;return new q(t,n,o,r,i.mouseMoveType,i.mouseNormalizeType).dumps()}))),k=n(e,"wheel",{passive:!1}).pipe(u((function(e){return e.preventDefault()})),h((function(e){return $.fromWheelEvent(e).dumps()}))),T=n(document,"keydown").pipe(u((function(e){return e.preventDefault()})),h((function(e){return _.fromKeyboardEvent(e,!0).dumps()}))),x=n(document,"keyup").pipe(u((function(e){return e.preventDefault()})),h((function(e){return _.fromKeyboardEvent(e,!1).dumps()})));function D(e,t){var n=t===z.TouchUpdate?"touches":"changedTouches";return new ee(t,function(e,t){var n=e.target,i=n.videoWidth,o=n.videoHeight,r=n.clientHeight,a=n.clientWidth,s=n.getBoundingClientRect(),c=s.left,u=s.top;return t.map((function(e){var t=e.clientX,n=e.clientY;return{x:i/a*(t-c),y:o/r*(n-u),id:e.identifier}}))}(e,Array.from(e[n]))).dumps()}var M=n(e,"touchend"),C=n(e,"touchmove",{passive:!1}),L=n(e,"touchstart",{passive:!1}),X=n(e,"touchcancel"),U=C.pipe(u((function(e){return e.preventDefault()})),m(o(M,X)),v(100),d((function(e){return 2===e.targetTouches.length})),f(),h(S),h((function(e){return $.fromPinchZoom(e/10).dumps()})),y()),O=r((function(){return i.fakeMouseWithTouch}),L.pipe(u((function(e){return e.preventDefault()})),w((function(e){return a((t=B({target:e.target,clientX:e.targetTouches[0].clientX,clientY:e.targetTouches[0].clientY,movementX:0,movementY:0},i.mouseNormalizeType===R.MouseMoveStandardization),n=t.x,o=t.y,r=t.dx,s=t.dy,new q(n,o,r,s,i.mouseMoveType,i.mouseNormalizeType).dumps()),new V(3===e.targetTouches.length?I.ButtonMiddle:i.fakeTouchType,!0).dumps());var t,n,o,r,s}))),L.pipe(u((function(e){return e.preventDefault()})),h((function(e){return D(e,z.TouchDown)})))),j=r((function(){return i.fakeMouseWithTouch}),C.pipe(u((function(e){return e.preventDefault()})),m(o(M,X)),d((function(e){return 1===e.targetTouches.length||3===e.targetTouches.length})),f(),h(P),h((function(e){return function(e,t,n){var i=e.movementX,o=e.movementY;return E(E({},e),{movementX:i*t,movementY:o*n})}(e,i.touchDeltaXSensitivity,i.touchDeltaYSensitivity)})),h((function(e){return B(e,i.mouseNormalizeType===R.MouseMoveStandardization)})),h((function(e){var t=e.x,n=e.y,o=e.dx,r=e.dy;return new q(t,n,o,r,i.mouseMoveType,i.mouseNormalizeType).dumps()})),y()),C.pipe(u((function(e){return e.preventDefault()})),h((function(e){return D(e,z.TouchUpdate)})))),Q=r((function(){return i.fakeMouseWithTouch}),o(M,X).pipe(u((function(e){return e.preventDefault()})),g(new V(i.fakeTouchType,!1).dumps())),o(M,X).pipe(u((function(e){return e.preventDefault()})),h((function(e){return D(e,z.TouchUp)}))));return t(0,s).pipe(h((function(e){return navigator.getGamepads()[0]})),d((function(e){return!!e})),h((function(e){var t=e.axes.map((function(e){return 32767*e})),n=t[0],i=t[1],o=t[2],r=t[3],a=255*e.buttons[6].value,s=255*e.buttons[7].value;return new ie(G.GamepadXbox,0,0,a,s,n,-i,o,-r).dumps()}))),{wheelStream:k,keydownStream:T,keyupStream:x,mouseupStream:l,mousedownStream:c,mousemoveStream:p,zoomStream:U,startBufferStream:O,moveBufferStream:j,endBufferStream:Q,leaveStream:b}},e.attachListener=function(e,t,i){var r=this.createDefaultEventStream(e,t),a=r.wheelStream,s=r.keydownStream,c=r.keyupStream,u=r.mouseupStream,h=r.mousedownStream,l=r.mousemoveStream,d=r.zoomStream,p=r.startBufferStream,f=r.moveBufferStream,v=r.endBufferStream,y=r.leaveStream;o(a,s,c,u,h,l,d,p,f,v,y).pipe(m(n(i.dc,"close"))).subscribe((function(e){return i.send(e)}))},e}(),se=function(e,t,n,i,o,r){void 0===e&&(e=R.MouseMoveStandardization),void 0===t&&(t=U.Passive),void 0===n&&(n=I.ButtonLeft),void 0===i&&(i=!0),void 0===o&&(o=1),void 0===r&&(r=1),this.mouseNormalizeType=e,this.mouseMoveType=t,this.fakeTouchType=n,this.fakeMouseWithTouch=i,this.touchDeltaXSensitivity=o,this.touchDeltaYSensitivity=r};export{oe as Connection,K as EventDelay,R as EventType,ie as Gamepad,G as GamepadType,O as GamepadXboxButton,ae as Helper,_ as Keyboard,V as MouseButton,I as MouseButtonType,q as MouseMove,U as MoveType,re as Player,W as PointerManager,se as RunningState,ne as TextInput,ee as TouchSet,z as TouchType,J as UIInteraction,te as UIInteractionResponse,$ as WheelScroll,j as screenfull};

@@ -1,3 +0,113 @@

# RayStreaming beta ver.
# ray-streaming
RayStreaming WebRTC implement
RayStreaming SDK for Web
### Guides
##### Quick start
see [live-cat](https://www.npmjs.com/package/live-cat) or [live-dragon](https://www.npmjs.com/package/live-dragon)
##### API reference
###### `Connection`
Manage the Signaling and PeerConnection connection with node machine
```typescript
new Connection(url, iceServers[, iceTransportPolicy][, minBitrate][, maxBitrate][, startBitrate][, enableAFK]))
```
- `url`\<string\> signaling endpoint
- `iceServers` \<RTCIceServer\[\]\> [RTCIceServer](https://developer.mozilla.org/en-US/docs/Web/API/RTCIceServer)
- `iceTransportPolicy` \<RTCIceTransportPolicy\> [iceTransportPolicy](https://developer.mozilla.org/en-US/docs/Web/API/RTCConfiguration/iceTransportPolicy) Default: `'all'`
- `minBitrate` \<number\> append x-google-min-bitrate in creact offer Default: 2000
- `maxBitrate` \<number\> x-google-max-bitrate Default: 5000
- `startBitrate` \<number\> x-google-start-bitrate Default: 4000
- `enableAFK` \<boolean\> disconnect when detecting afk Default: true
`connection.emitUIInteraction(msg)`
- `msg` \<string\>
Send UI interaction message to remote application
```typescript
connection.emitUIInteraction(JSON.stringify({ eventName: 'A' })).then((result) => {
if (result) {
console.log('execute success') // NOTE: only promise send to appliction
}
})
```
`connection.changeBitrate(bandwidth)`
- `bandwidth` \<number\> kbps
`connection.destory()`
Close all connect, off event listener
###### `Player`
Provide the container to play the remote stream,
```typescript
new Player(hostElement[, onPlay][, voicedAtPlay])
```
- `hostElement` \<HTMLElement\> any block element with fixed size
- `onPlay` \<\(\) => void\> invoke when video play
- `voicedAtPlay` \<boolean\> remove muted attribute when play if set true Default: `true`
`player.resizePlayer()`
Resize player style to fill host element if host element size is smaller than player or resize player style to actual size
`player.showTextOverlay(text)`
- `text` \<string\>
Show prompt with specify text and mask video stream
`player.destory()`
Remove created elements
###### `RunningState`
State of the remote node or front-end widget, manager by laucher or execution context
```typescript
// NOTE: Usually do not need to be modified
const runningInfo = new RunningState()
```
###### `Helper`
`Helper.createDefaultEventStream(target, runningInfo)`
- `target` \<HTMLVideoElement\> the video element
- `runningInfo` \<RunningState\> RunningState instance
Create default stream for basic interaction, transform to ArrayBuffer from the event-adapter definition
`Helper.attachListener(target, runningInfo, connection)`
- target \<HTMLVideoElement\>
- runningInfo \<RunningState\>
- connection \<Connection\>
the default behavior for consuming the event stream
### Caveat
- Need to initialize `Player` after `WeixinJSBridgeReady` event fired if use in WeChat web-view
```javascript
if (navigator.userAgent.includes('miniProgram') || navigator.userAgent.includes('MicroMessenger')) {
document.addEventListener('WeixinJSBridgeReady', () => {
// initialize here
})
}
```

@@ -21,2 +21,3 @@ import { Connection } from './connection';

endBufferStream: import("rxjs").Observable<ArrayBuffer>;
leaveStream: import("rxjs").Observable<ArrayBuffer>;
};

@@ -23,0 +24,0 @@ /**

@@ -1,5 +0,3 @@

import { TypedEvent } from '../utils';
export declare class Player {
hostElement: HTMLElement;
private pointerLock;
/**

@@ -22,3 +20,2 @@ * set true after loadedmetadata event fired

private get hostAspectRatio();
pointLockChange: TypedEvent<boolean>;
private onPlayHandler;

@@ -47,3 +44,2 @@ /**

showTextOverlay(text: string): void;
setCursor(base64: string, x: number, y: number, show: boolean): void;
private showPlayOverlay;

@@ -50,0 +46,0 @@ private hidePlayOverlay;

@@ -15,3 +15,3 @@ import { MouseButtonType, MoveType, MouseMoveEventType } from './event-adapter';

constructor(mouseNormalizeType?: MouseMoveEventType, // retome node state: EventType.MouseMoveStandardization: normalize by front-end, use (video size/client size) as ratio; EventType.MouseMoveNormalization: normalize by remote node, use (65545/ client size) as ratio
mouseMoveType?: MoveType, // remote node state: MoveType.Unknow: auto; MoveType.Passive: lock pointer
mouseMoveType?: MoveType, // remote node state: MoveType.Unknow: auto; MoveType.Passive: detected by node
fakeTouchType?: MouseButtonType, // player -> virtual-control state

@@ -18,0 +18,0 @@ fakeMouseWithTouch?: boolean, // true: transform touch evnet to mouse event; false: transform touch evnet to TouchSet

@@ -7,1 +7,2 @@ export { Connection } from './core/connection';

export { screenfull } from './utils/screenfull';
export { PointerManager } from './utils/pointer-lock';

@@ -6,6 +6,4 @@ export declare class Cursor {

y: number;
constructor(data: ArrayBuffer);
private parseCursorInfo;
static getImageInfo(dv: DataView, startIndex: number, endIndex: number): number;
static arrayBuffer2base64(arr: number[], width: number, height: number, depth: number, pitch: number): string;
constructor(base64?: string, show?: boolean, x?: number, y?: number);
static parse(ab: ArrayBuffer): Cursor;
}

@@ -22,2 +22,3 @@ declare type MouseEventLike = {

export declare function moveBooster(e: MouseEventLike, xRatio: number, yRatio: number): MouseEventLike;
export declare function stickedEdge(e: MouseEvent): MouseEventLike;
export {};

@@ -13,2 +13,2 @@ export * from './helper';

export { TakeANumber } from './take-a-number';
export { PointerLock } from './pointer-lock';
export { PointerManager } from './pointer-lock';

@@ -1,16 +0,13 @@

export declare class PointerLock {
private element;
movementX: number;
movementY: number;
onLockingChange: (isLocking: boolean) => void;
constructor(element: HTMLElement);
request(): void;
exit(): void;
private exitPointerLock;
private requestPointerLock;
private attachPointLockEvent;
on(cb: (isLocking: boolean) => void): void;
private emit;
private mousemove;
import { Cursor } from './cursor';
export declare class PointerManager {
private target;
private onExit;
cursor: Cursor;
constructor(target: HTMLElement, onExit?: () => void);
destory(): void;
private handleVisibilityChange;
private handlePointerLockError;
private handlePointerLockChange;
setCursor(cursor: Cursor): void;
private get isPointerLocking();
}

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc