diff --git a/example/lib/examples/advanced/screen_sharing.dart b/example/lib/examples/advanced/screen_sharing.dart index 94c679a3c..5649a08e8 100644 --- a/example/lib/examples/advanced/screen_sharing.dart +++ b/example/lib/examples/advanced/screen_sharing.dart @@ -42,7 +42,11 @@ class _State extends State { _addListeners(); () async { await _engine.enableVideo(); - await _engine.startPreview(); + if (kIsWeb) { + await _engine.startScreenCapture(0); + } else { + await _engine.startPreview(); + } await _engine.setChannelProfile(ChannelProfile.LiveBroadcasting); await _engine.setClientRole(ClientRole.Broadcaster); setState(() { @@ -179,18 +183,21 @@ class _State extends State { _renderVideo(), ], ), - Align( - alignment: Alignment.bottomRight, - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - ElevatedButton( - onPressed: screenSharing ? _stopScreenShare : _startScreenShare, - child: Text('${screenSharing ? 'Stop' : 'Start'} screen share'), - ), - ], - ), - ) + if (!kIsWeb) + Align( + alignment: Alignment.bottomRight, + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + ElevatedButton( + onPressed: + screenSharing ? _stopScreenShare : _startScreenShare, + child: + Text('${screenSharing ? 'Stop' : 'Start'} screen share'), + ), + ], + ), + ) ], ); } @@ -201,11 +208,12 @@ class _State extends State { children: [ Row( children: [ - Expanded( - flex: 1, - child: kIsWeb - ? RtcLocalView.SurfaceView() - : RtcLocalView.TextureView()), + if (startPreview) + Expanded( + flex: 1, + child: kIsWeb + ? RtcLocalView.SurfaceView() + : RtcLocalView.TextureView()), if (screenSharing) Expanded(flex: 1, child: RtcLocalView.TextureView.screenShare()), ], diff --git a/example/lib/examples/basic/join_channel_audio.dart b/example/lib/examples/basic/join_channel_audio.dart index 4afe2d2cd..12810ac3b 100644 --- a/example/lib/examples/basic/join_channel_audio.dart +++ b/example/lib/examples/basic/join_channel_audio.dart @@ -188,10 +188,11 @@ class _State extends State { child: Text(enableSpeakerphone ? 'Speakerphone' : 'Earpiece'), ), - ElevatedButton( - onPressed: this._switchEffect, - child: Text('${playEffect ? 'Stop' : 'Play'} effect'), - ), + if (!kIsWeb) + ElevatedButton( + onPressed: this._switchEffect, + child: Text('${playEffect ? 'Stop' : 'Play'} effect'), + ), Row( mainAxisAlignment: MainAxisAlignment.end, children: [ diff --git a/example/web/AgoraRtcWrapper.bundle.js b/example/web/AgoraRtcWrapper.bundle.js index 31e4f08ec..c6e078e4f 100644 --- a/example/web/AgoraRtcWrapper.bundle.js +++ b/example/web/AgoraRtcWrapper.bundle.js @@ -1,2 +1,2 @@ /*! For license information please see AgoraRtcWrapper.bundle.js.LICENSE.txt */ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.IrisRtcEngine=t():e.IrisRtcEngine=t()}(self,(function(){return(()=>{"use strict";var e={424:function(e,t,i){e.exports=function(){function e(e,t,i){return e(i={path:t,exports:{},require:function(e,t){throw Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}},i.exports),i.exports}function t(e,t,i){return(e=e.match(t))&&e.length>=i&&io(e[i],10)}function n(e,t,i){if(e.RTCPeerConnection){var n=(e=e.RTCPeerConnection.prototype).addEventListener;e.addEventListener=function(e,r){if(e!==t)return n.apply(this,arguments);let a=e=>{(e=i(e))&&r(e)};return this._eventMap=this._eventMap||{},this._eventMap[r]=a,n.apply(this,[e,a])};var r=e.removeEventListener;e.removeEventListener=function(e,i){if(e!==t||!this._eventMap||!this._eventMap[i])return r.apply(this,arguments);let n=this._eventMap[i];return delete this._eventMap[i],r.apply(this,[e,n])},Ja(e,"on"+t,{get(){return this["_on"+t]},set(e){this["_on"+t]&&(this.removeEventListener(t,this["_on"+t]),delete this["_on"+t]),e&&this.addEventListener(t,this["_on"+t]=e)},enumerable:!0,configurable:!0})}}function r(e){return"boolean"!=typeof e?Error("Argument type: "+typeof e+". Please use a boolean."):(no=e,e?"adapter.js logging disabled":"adapter.js logging enabled")}function a(e){return"boolean"!=typeof e?Error("Argument type: "+typeof e+". Please use a boolean."):(ro=!e,"adapter.js deprecation warnings "+(e?"disabled":"enabled"))}function o(){"object"!=typeof window||no||"undefined"!=typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)}function s(e,t){ro&&console.warn(e+" is deprecated, please use "+t+" instead.")}function c(e){let{navigator:i}=e,n={browser:null,version:null};if(void 0===e||!e.navigator)return n.browser="Not a browser.",n;if(i.mozGetUserMedia)n.browser="firefox",n.version=t(i.userAgent,/Firefox\/(\d+)\./,1);else if(i.webkitGetUserMedia||!1===e.isSecureContext&&e.webkitRTCPeerConnection&&!e.RTCIceGatherer)n.browser="chrome",n.version=t(i.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else if(i.mediaDevices&&i.userAgent.match(/Edge\/(\d+).(\d+)$/))n.browser="edge",n.version=t(i.userAgent,/Edge\/(\d+).(\d+)$/,2);else{if(!e.RTCPeerConnection||!i.userAgent.match(/AppleWebKit\/(\d+)\./))return n.browser="Not a supported browser.",n;n.browser="safari",n.version=t(i.userAgent,/AppleWebKit\/(\d+)\./,1),n.supportsUnifiedPlan=e.RTCRtpTransceiver&&"currentDirection"in e.RTCRtpTransceiver.prototype}return n}function E(e){var t;return"[object Object]"===Object.prototype.toString.call(e)?Ka(t=xa(e)).call(t,(function(t,i){var n="[object Object]"===Object.prototype.toString.call(e[i]);let r=n?E(e[i]):e[i];return n=n&&!xa(r).length,void 0===r||n?t:Ba(t,{[i]:r})}),{}):e}function _(e,t,i){let n=i?"outbound-rtp":"inbound-rtp",r=new Ia;if(null===t)return r;let a=[];return wa(e).call(e,(e=>{"track"===e.type&&e.trackIdentifier===t.id&&a.push(e)})),wa(a).call(a,(t=>{wa(e).call(e,(i=>{i.type===n&&i.trackId===t.id&&function e(t,i,n){var r;i&&!n.has(i.id)&&(n.set(i.id,i),wa(r=xa(i)).call(r,(r=>{if(La(r).call(r,"Id"))e(t,t.get(i[r]),n);else if(La(r).call(r,"Ids")){var a;wa(a=i[r]).call(a,(i=>{e(t,t.get(i),n)}))}})))}(e,i,r)}))})),r}function d(e){let t=e&&e.navigator;if(t.mediaDevices){var i=c(e),n=function(e){var t;if("object"!=typeof e||e.mandatory||e.optional)return e;const i={};var n;return wa(t=xa(e)).call(t,(t=>{if("require"!==t&&"advanced"!==t&&"mediaSource"!==t){var n="object"==typeof e[t]?e[t]:{ideal:e[t]};void 0!==n.exact&&"number"==typeof n.exact&&(n.min=n.max=n.exact);var r,a=function(e,t){return e?e+t.charAt(0).toUpperCase()+dc(t).call(t,1):"deviceId"===t?"sourceId":t};if(void 0!==n.ideal){i.optional=i.optional||[];let e={};"number"==typeof n.ideal?(e[a("min",t)]=n.ideal,i.optional.push(e),e={},e[a("max",t)]=n.ideal,i.optional.push(e)):(e[a("",t)]=n.ideal,i.optional.push(e))}void 0!==n.exact&&"number"!=typeof n.exact?(i.mandatory=i.mandatory||{},i.mandatory[a("",t)]=n.exact):wa(r=["min","max"]).call(r,(e=>{void 0!==n[e]&&(i.mandatory=i.mandatory||{},i.mandatory[a(e,t)]=n[e])}))}})),e.advanced&&(i.optional=fo(n=i.optional||[]).call(n,e.advanced)),i},r=function(e,r){if(61<=i.version)return r(e);if((e=JSON.parse(_n(e)))&&"object"==typeof e.audio){var a=function(e,t,i){t in e&&!(i in e)&&(e[i]=e[t],delete e[t])};a((e=JSON.parse(_n(e))).audio,"autoGainControl","googAutoGainControl"),a(e.audio,"noiseSuppression","googNoiseSuppression"),e.audio=n(e.audio)}if(e&&"object"==typeof e.video){let o=e.video.facingMode;if(o=o&&("object"==typeof o?o:{ideal:o}),a=66>i.version,!(!o||"user"!==o.exact&&"environment"!==o.exact&&"user"!==o.ideal&&"environment"!==o.ideal||t.mediaDevices.getSupportedConstraints&&t.mediaDevices.getSupportedConstraints().facingMode&&!a)){let i;if(delete e.video.facingMode,"environment"===o.exact||"environment"===o.ideal?i=["back","rear"]:"user"!==o.exact&&"user"!==o.ideal||(i=["front"]),i)return t.mediaDevices.enumerateDevices().then((t=>{t=vo(t).call(t,(e=>"videoinput"===e.kind));let a=Rc(t).call(t,(e=>Dc(i).call(i,(t=>{var i;return Cc(i=e.label.toLowerCase()).call(i,t)}))));return!a&&t.length&&Cc(i).call(i,"back")&&(a=t[t.length-1]),a&&(e.video.deviceId=o.exact?{exact:a.deviceId}:{ideal:a.deviceId}),e.video=n(e.video),Lc("chrome: "+_n(e)),r(e)}))}e.video=n(e.video)}return Lc("chrome: "+_n(e)),r(e)},a=function(e){return 64<=i.version?e:{name:{PermissionDeniedError:"NotAllowedError",PermissionDismissedError:"NotAllowedError",InvalidStateError:"NotAllowedError",DevicesNotFoundError:"NotFoundError",ConstraintNotSatisfiedError:"OverconstrainedError",TrackStartError:"NotReadableError",MediaDeviceFailedDueToShutdown:"NotAllowedError",MediaDeviceKillSwitchOn:"NotAllowedError",TabCaptureError:"AbortError",ScreenCaptureError:"AbortError",DeviceCaptureError:"AbortError"}[e.name]||e.name,message:e.message,constraint:e.constraint||e.constraintName,toString(){return this.name+(this.message&&": ")+this.message}}};if(e=function(e,i,n){r(e,(e=>{t.webkitGetUserMedia(e,i,(e=>{n&&n(a(e))}))}))},t.getUserMedia=Sc(e).call(e,t),t.mediaDevices.getUserMedia){var o;let e=Sc(o=t.mediaDevices.getUserMedia).call(o,t.mediaDevices);t.mediaDevices.getUserMedia=function(t){return r(t,(t=>e(t).then((e=>{var i;if(t.audio&&!e.getAudioTracks().length||t.video&&!e.getVideoTracks().length)throw wa(i=e.getTracks()).call(i,(e=>{e.stop()})),new DOMException("","NotFoundError");return e}),(e=>js.reject(a(e))))))}}}}function l(e){e.MediaStream=e.MediaStream||e.webkitMediaStream}function u(e){if("object"!=typeof e||!e.RTCPeerConnection||"ontrack"in e.RTCPeerConnection.prototype)n(e,"track",(e=>(e.transceiver||Ja(e,"transceiver",{value:{receiver:e.receiver}}),e)));else{Ja(e.RTCPeerConnection.prototype,"ontrack",{get(){return this._ontrack},set(e){this._ontrack&&this.removeEventListener("track",this._ontrack),this.addEventListener("track",this._ontrack=e)},enumerable:!0,configurable:!0});let t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){return this._ontrackpoly||(this._ontrackpoly=t=>{var i;t.stream.addEventListener("addtrack",(i=>{let n;var r;n=e.RTCPeerConnection.prototype.getReceivers?Rc(r=this.getReceivers()).call(r,(e=>e.track&&e.track.id===i.track.id)):{track:i.track},(r=new Event("track")).track=i.track,r.receiver=n,r.transceiver={receiver:n},r.streams=[t.stream],this.dispatchEvent(r)})),wa(i=t.stream.getTracks()).call(i,(i=>{let n;var r;n=e.RTCPeerConnection.prototype.getReceivers?Rc(r=this.getReceivers()).call(r,(e=>e.track&&e.track.id===i.id)):{track:i},(r=new Event("track")).track=i,r.receiver=n,r.transceiver={receiver:n},r.streams=[t.stream],this.dispatchEvent(r)}))},this.addEventListener("addstream",this._ontrackpoly)),t.apply(this,arguments)}}}function h(e){if("object"==typeof e&&e.RTCPeerConnection&&!("getSenders"in e.RTCPeerConnection.prototype)&&"createDTMFSender"in e.RTCPeerConnection.prototype){let t=function(e,t){return{track:t,get dtmf(){return void 0===this._dtmf&&("audio"===t.kind?this._dtmf=e.createDTMFSender(t):this._dtmf=null),this._dtmf},_pc:e}};if(!e.RTCPeerConnection.prototype.getSenders){e.RTCPeerConnection.prototype.getSenders=function(){var e;return this._senders=this._senders||[],dc(e=this._senders).call(e)};let i=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,n){let r=i.apply(this,arguments);return r||(r=t(this,e),this._senders.push(r)),r};let n=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){var t;n.apply(this,arguments);let i=ac(t=this._senders).call(t,e);var r;-1!==i&&$s(r=this._senders).call(r,i,1)}}let i=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){var n;this._senders=this._senders||[],i.apply(this,[e]),wa(n=e.getTracks()).call(n,(e=>{this._senders.push(t(this,e))}))};let n=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){var t;this._senders=this._senders||[],n.apply(this,[e]),wa(t=e.getTracks()).call(t,(e=>{var t;let i=Rc(t=this._senders).call(t,(t=>t.track===e));var n,r;i&&$s(n=this._senders).call(n,ac(r=this._senders).call(r,i),1)}))}}else if("object"==typeof e&&e.RTCPeerConnection&&"getSenders"in e.RTCPeerConnection.prototype&&"createDTMFSender"in e.RTCPeerConnection.prototype&&e.RTCRtpSender&&!("dtmf"in e.RTCRtpSender.prototype)){let t=e.RTCPeerConnection.prototype.getSenders;e.RTCPeerConnection.prototype.getSenders=function(){let e=t.apply(this,[]);return wa(e).call(e,(e=>e._pc=this)),e},Ja(e.RTCRtpSender.prototype,"dtmf",{get(){return void 0===this._dtmf&&("audio"===this.track.kind?this._dtmf=this._pc.createDTMFSender(this.track):this._dtmf=null),this._dtmf}})}}function R(e){if(e.RTCPeerConnection){var t=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){let[e,i,n]=arguments;if(0{var i;const n={id:e.id,timestamp:e.timestamp,type:{localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[e.type]||e.type};wa(i=e.names()).call(i,(t=>{n[t]=e.stat(t)})),t[n.id]=n})),t},a=function(e){var t;return new Ia(Js(t=xa(e)).call(t,(t=>[t,e[t]])))};return 2<=arguments.length?t.apply(this,[function(e){i(a(r(e)))},e]):new js(((e,i)=>{t.apply(this,[function(t){e(a(r(t)))},i])})).then(i,n)}}}function T(e){if("object"==typeof e&&e.RTCPeerConnection&&e.RTCRtpSender&&e.RTCRtpReceiver){if(!("getStats"in e.RTCRtpSender.prototype)){let t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){let e=t.apply(this,[]);return wa(e).call(e,(e=>e._pc=this)),e});let i=e.RTCPeerConnection.prototype.addTrack;i&&(e.RTCPeerConnection.prototype.addTrack=function(){let e=i.apply(this,arguments);return e._pc=this,e}),e.RTCRtpSender.prototype.getStats=function(){let e=this;return this._pc.getStats().then((t=>_(t,e.track,!0)))}}if(!("getStats"in e.RTCRtpReceiver.prototype)){let t=e.RTCPeerConnection.prototype.getReceivers;t&&(e.RTCPeerConnection.prototype.getReceivers=function(){let e=t.apply(this,[]);return wa(e).call(e,(e=>e._pc=this)),e}),n(e,"track",(e=>(e.receiver._pc=e.srcElement,e))),e.RTCRtpReceiver.prototype.getStats=function(){let e=this;return this._pc.getStats().then((t=>_(t,e.track,!1)))}}if("getStats"in e.RTCRtpSender.prototype&&"getStats"in e.RTCRtpReceiver.prototype){var t=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){if(0{t.track===a&&(e?r=!0:e=t)})),wa(n=this.getReceivers()).call(n,(e=>(e.track===a&&(t?r=!0:t=e),e.track===a))),r||e&&t?js.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):e?e.getStats():t?t.getStats():js.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return t.apply(this,arguments)}}}}function A(e){e.RTCPeerConnection.prototype.getLocalStreams=function(){var e;return this._shimmedLocalStreams=this._shimmedLocalStreams||{},Js(e=xa(this._shimmedLocalStreams)).call(e,(e=>this._shimmedLocalStreams[e][0]))};let t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,i){var n;if(!i)return t.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};let r=t.apply(this,arguments);return this._shimmedLocalStreams[i.id]?-1===ac(n=this._shimmedLocalStreams[i.id]).call(n,r)&&this._shimmedLocalStreams[i.id].push(r):this._shimmedLocalStreams[i.id]=[i,r],r};let i=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){var t,n,r;this._shimmedLocalStreams=this._shimmedLocalStreams||{},wa(t=e.getTracks()).call(t,(e=>{var t;if(Rc(t=this.getSenders()).call(t,(t=>t.track===e)))throw new DOMException("Track already exists.","InvalidAccessError")}));let a=this.getSenders();i.apply(this,arguments),t=vo(n=this.getSenders()).call(n,(e=>-1===ac(a).call(a,e))),this._shimmedLocalStreams[e.id]=fo(r=[e]).call(r,t)};let n=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},delete this._shimmedLocalStreams[e.id],n.apply(this,arguments)};let r=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){var t;return this._shimmedLocalStreams=this._shimmedLocalStreams||{},e&&wa(t=xa(this._shimmedLocalStreams)).call(t,(t=>{var i;let n=ac(i=this._shimmedLocalStreams[t]).call(i,e);var r;-1!==n&&$s(r=this._shimmedLocalStreams[t]).call(r,n,1),1===this._shimmedLocalStreams[t].length&&delete this._shimmedLocalStreams[t]})),r.apply(this,arguments)}}function I(e){function t(e,t){var i;let n=t.sdp;return wa(i=xa(e._reverseStreams||[])).call(i,(t=>{t=e._reverseStreams[t],n=n.replace(new RegExp(e._streams[t.id].id,"g"),t.id)})),new RTCSessionDescription({type:t.type,sdp:n})}function i(e,t){var i;let n=t.sdp;return wa(i=xa(e._reverseStreams||[])).call(i,(t=>{t=e._reverseStreams[t],n=n.replace(new RegExp(t.id,"g"),e._streams[t.id].id)})),new RTCSessionDescription({type:t.type,sdp:n})}var n;if(e.RTCPeerConnection){var r=c(e);if(e.RTCPeerConnection.prototype.addTrack&&65<=r.version)return A(e);var a=e.RTCPeerConnection.prototype.getLocalStreams;e.RTCPeerConnection.prototype.getLocalStreams=function(){let e=a.apply(this);return this._reverseStreams=this._reverseStreams||{},Js(e).call(e,(e=>this._reverseStreams[e.id]))};var o=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(t){var i;this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},wa(i=t.getTracks()).call(i,(e=>{var t;if(Rc(t=this.getSenders()).call(t,(t=>t.track===e)))throw new DOMException("Track already exists.","InvalidAccessError")})),this._reverseStreams[t.id]||(i=new e.MediaStream(t.getTracks()),this._streams[t.id]=i,this._reverseStreams[i.id]=t,t=i),o.apply(this,[t])};var s=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},s.apply(this,[this._streams[e.id]||e]),delete this._reverseStreams[this._streams[e.id]?this._streams[e.id].id:e.id],delete this._streams[e.id]},e.RTCPeerConnection.prototype.addTrack=function(t,i){var n,r,a;if("closed"===this.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");let o=dc([]).call(arguments,1);if(1!==o.length||!Rc(n=o[0].getTracks()).call(n,(e=>e===t)))throw new DOMException("The adapter.js addTrack polyfill only supports a single stream which is associated with the specified track.","NotSupportedError");if(Rc(r=this.getSenders()).call(r,(e=>e.track===t)))throw new DOMException("Track already exists.","InvalidAccessError");return this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},(n=this._streams[i.id])?(n.addTrack(t),js.resolve().then((()=>{this.dispatchEvent(new Event("negotiationneeded"))}))):(n=new e.MediaStream([t]),this._streams[i.id]=n,this._reverseStreams[n.id]=i,this.addStream(n)),Rc(a=this.getSenders()).call(a,(e=>e.track===t))},wa(n=["createOffer","createAnswer"]).call(n,(function(i){let n=e.RTCPeerConnection.prototype[i];e.RTCPeerConnection.prototype[i]={[i](){const e=arguments;return arguments.length&&"function"==typeof arguments[0]?n.apply(this,[i=>{i=t(this,i),e[0].apply(null,[i])},t=>{e[1]&&e[1].apply(null,t)},arguments[2]]):n.apply(this,arguments).then((e=>t(this,e)))}}[i]}));var E=e.RTCPeerConnection.prototype.setLocalDescription;e.RTCPeerConnection.prototype.setLocalDescription=function(){return arguments.length&&arguments[0].type?(arguments[0]=i(this,arguments[0]),E.apply(this,arguments)):E.apply(this,arguments)};var _=Eo(e.RTCPeerConnection.prototype,"localDescription");Ja(e.RTCPeerConnection.prototype,"localDescription",{get(){let e=_.get.apply(this);return""===e.type?e:t(this,e)}}),e.RTCPeerConnection.prototype.removeTrack=function(e){var t;if("closed"===this.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");if(!e._pc)throw new DOMException("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.","TypeError");if(e._pc!==this)throw new DOMException("Sender was not created by this connection.","InvalidAccessError");let i;this._streams=this._streams||{},wa(t=xa(this._streams)).call(t,(t=>{var n;Rc(n=this._streams[t].getTracks()).call(n,(t=>e.track===t))&&(i=this._streams[t])})),i&&(1===i.getTracks().length?this.removeStream(this._reverseStreams[i.id]):i.removeTrack(e.track),this.dispatchEvent(new Event("negotiationneeded")))}}}function p(e){let t=c(e);if(!e.RTCPeerConnection&&e.webkitRTCPeerConnection&&(e.RTCPeerConnection=e.webkitRTCPeerConnection),e.RTCPeerConnection){var i;53>t.version&&wa(i=["setLocalDescription","setRemoteDescription","addIceCandidate"]).call(i,(function(t){let i=e.RTCPeerConnection.prototype[t];e.RTCPeerConnection.prototype[t]={[t](){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),i.apply(this,arguments)}}[t]}));var n=e.RTCPeerConnection.prototype.addIceCandidate;e.RTCPeerConnection.prototype.addIceCandidate=function(){return arguments[0]?78>t.version&&arguments[0]&&""===arguments[0].candidate?js.resolve():n.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),js.resolve())}}}function S(e){n(e,"negotiationneeded",(e=>{if("stable"===e.target.signalingState)return e}))}function O(e,t,i,n,r){return t=Wc.writeRtpDescription(e.kind,t),t+=Wc.writeIceParameters(e.iceGatherer.getLocalParameters()),t+=Wc.writeDtlsParameters(e.dtlsTransport.getLocalParameters(),"offer"===i?"actpass":r||"active"),t+="a=mid:"+e.mid+"\r\n",e.rtpSender&&e.rtpReceiver?t+="a=sendrecv\r\n":e.rtpSender?t+="a=sendonly\r\n":e.rtpReceiver?t+="a=recvonly\r\n":t+="a=inactive\r\n",e.rtpSender&&(i=e.rtpSender._initialTrackId||e.rtpSender.track.id,e.rtpSender._initialTrackId=i,t=t+"a="+(n="msid:"+(n?n.id:"-")+" "+i+"\r\n")+"a=ssrc:"+e.sendEncodingParameters[0].ssrc+" "+n,e.sendEncodingParameters[0].rtx&&(t+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" "+n,t+="a=ssrc-group:FID "+e.sendEncodingParameters[0].ssrc+" "+e.sendEncodingParameters[0].rtx.ssrc+"\r\n")),t+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" cname:"+Wc.localCName+"\r\n",e.rtpSender&&e.sendEncodingParameters[0].rtx&&(t+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" cname:"+Wc.localCName+"\r\n"),t}function N(e,t){var i={codecs:[],headerExtensions:[],fecMechanisms:[]},n=function(e,t){e=parseInt(e,10);for(var i=0;ijs.reject(function(e){return{name:{PermissionDeniedError:"NotAllowedError"}[e.name]||e.name,message:e.message,constraint:e.constraint,toString(){return this.name}}}(e))))}}function v(e){var t;"getDisplayMedia"in e.navigator&&e.navigator.mediaDevices&&(e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||(e.navigator.mediaDevices.getDisplayMedia=Sc(t=e.navigator.getDisplayMedia).call(t,e.navigator)))}function D(e){let t=c(e);if(e.RTCIceGatherer&&(e.RTCIceCandidate||(e.RTCIceCandidate=function(e){return e}),e.RTCSessionDescription||(e.RTCSessionDescription=function(e){return e}),15025>t.version)){let t=Eo(e.MediaStreamTrack.prototype,"enabled");Ja(e.MediaStreamTrack.prototype,"enabled",{set(e){t.set.call(this,e);let i=new Event("enabled");i.enabled=e,this.dispatchEvent(i)}})}!e.RTCRtpSender||"dtmf"in e.RTCRtpSender.prototype||Ja(e.RTCRtpSender.prototype,"dtmf",{get(){return void 0===this._dtmf&&("audio"===this.track.kind?this._dtmf=new e.RTCDtmfSender(this):"video"===this.track.kind&&(this._dtmf=null)),this._dtmf}}),e.RTCDtmfSender&&!e.RTCDTMFSender&&(e.RTCDTMFSender=e.RTCDtmfSender);let i=Yc(e,t.version);e.RTCPeerConnection=function(e){return e&&e.iceServers&&(e.iceServers=function(e,t){let i=!1;return e=JSON.parse(_n(e)),vo(e).call(e,(e=>{if(e&&(e.urls||e.url)){var t=e.urls||e.url;e.url&&!e.urls&&s("RTCIceServer.url","RTCIceServer.urls");let n="string"==typeof t;return n&&(t=[t]),t=vo(t).call(t,(e=>0!==ac(e).call(e,"stun:")&&((e=bc(e).call(e,"turn")&&!bc(e).call(e,"turn:[")&&Cc(e).call(e,"transport=udp"))&&!i?(i=!0,!0):e&&!i))),delete e.url,e.urls=n?t[0]:t,!!t.length}}))}(e.iceServers,t.version),o("ICE servers after filtering:",e.iceServers)),new i(e)},e.RTCPeerConnection.prototype=i.prototype}function L(e){!e.RTCRtpSender||"replaceTrack"in e.RTCRtpSender.prototype||(e.RTCRtpSender.prototype.replaceTrack=e.RTCRtpSender.prototype.setTrack)}function P(e){let t=c(e),i=e&&e.navigator;if(e=e&&e.MediaStreamTrack,i.getUserMedia=function(e,t,n){s("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),i.mediaDevices.getUserMedia(e).then(t,n)},!(55t.version&&wa(i=["setLocalDescription","setRemoteDescription","addIceCandidate"]).call(i,(function(t){let i=e.RTCPeerConnection.prototype[t];e.RTCPeerConnection.prototype[t]={[t](){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),i.apply(this,arguments)}}[t]}));var n=e.RTCPeerConnection.prototype.addIceCandidate;e.RTCPeerConnection.prototype.addIceCandidate=function(){return arguments[0]?68>t.version&&arguments[0]&&""===arguments[0].candidate?js.resolve():n.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),js.resolve())};var r={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"},a=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){let[e,i,n]=arguments;return a.apply(this,[e||null]).then((e=>{if(53>t.version&&!i)try{wa(e).call(e,(e=>{e.type=r[e.type]||e.type}))}catch(t){if("TypeError"!==t.name)throw t;wa(e).call(e,((t,i)=>{e.set(i,Ba({},t,{type:r[t.type]||t.type}))}))}return e})).then(i,n)}}}function k(e){if("object"==typeof e&&e.RTCPeerConnection&&e.RTCRtpSender&&(!e.RTCRtpSender||!("getStats"in e.RTCRtpSender.prototype))){var t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){let e=t.apply(this,[]);return wa(e).call(e,(e=>e._pc=this)),e});var i=e.RTCPeerConnection.prototype.addTrack;i&&(e.RTCPeerConnection.prototype.addTrack=function(){let e=i.apply(this,arguments);return e._pc=this,e}),e.RTCRtpSender.prototype.getStats=function(){return this.track?this._pc.getStats(this.track):js.resolve(new Ia)}}}function U(e){if("object"==typeof e&&e.RTCPeerConnection&&e.RTCRtpSender&&(!e.RTCRtpSender||!("getStats"in e.RTCRtpReceiver.prototype))){var t=e.RTCPeerConnection.prototype.getReceivers;t&&(e.RTCPeerConnection.prototype.getReceivers=function(){let e=t.apply(this,[]);return wa(e).call(e,(e=>e._pc=this)),e}),n(e,"track",(e=>(e.receiver._pc=e.srcElement,e))),e.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}}function w(e){!e.RTCPeerConnection||"removeStream"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.removeStream=function(e){var t;s("removeStream","removeTrack"),wa(t=this.getSenders()).call(t,(t=>{var i;t.track&&Cc(i=e.getTracks()).call(i,t.track)&&this.removeTrack(t)}))})}function b(e){e.DataChannel&&!e.RTCDataChannel&&(e.RTCDataChannel=e.DataChannel)}function V(e){if("object"==typeof e&&e.RTCPeerConnection){if("getLocalStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getLocalStreams=function(){return this._localStreams||(this._localStreams=[]),this._localStreams}),!("addStream"in e.RTCPeerConnection.prototype)){let t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addStream=function(e){var i,n,r;this._localStreams||(this._localStreams=[]),Cc(i=this._localStreams).call(i,e)||this._localStreams.push(e),wa(n=e.getAudioTracks()).call(n,(i=>t.call(this,i,e))),wa(r=e.getVideoTracks()).call(r,(i=>t.call(this,i,e)))},e.RTCPeerConnection.prototype.addTrack=function(e,i){var n;return i&&(this._localStreams?Cc(n=this._localStreams).call(n,i)||this._localStreams.push(i):this._localStreams=[i]),t.call(this,e,i)}}"removeStream"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.removeStream=function(e){var t,i,n;this._localStreams||(this._localStreams=[]);let r=ac(t=this._localStreams).call(t,e);if(-1!==r){$s(i=this._localStreams).call(i,r,1);var a=e.getTracks();wa(n=this.getSenders()).call(n,(e=>{Cc(a).call(a,e.track)&&this.removeTrack(e)}))}})}}function F(e){if("object"==typeof e&&e.RTCPeerConnection&&("getRemoteStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getRemoteStreams=function(){return this._remoteStreams?this._remoteStreams:[]}),!("onaddstream"in e.RTCPeerConnection.prototype))){Ja(e.RTCPeerConnection.prototype,"onaddstream",{get(){return this._onaddstream},set(e){this._onaddstream&&(this.removeEventListener("addstream",this._onaddstream),this.removeEventListener("track",this._onaddstreampoly)),this.addEventListener("addstream",this._onaddstream=e),this.addEventListener("track",this._onaddstreampoly=e=>{var t;wa(t=e.streams).call(t,(e=>{var t;this._remoteStreams||(this._remoteStreams=[]),Cc(t=this._remoteStreams).call(t,e)||(this._remoteStreams.push(e),(t=new Event("addstream")).stream=e,this.dispatchEvent(t))}))})}});let t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){let e=this;return this._onaddstreampoly||this.addEventListener("track",this._onaddstreampoly=function(t){var i;wa(i=t.streams).call(i,(t=>{var i;e._remoteStreams||(e._remoteStreams=[]),0<=ac(i=e._remoteStreams).call(i,t)||(e._remoteStreams.push(t),(i=new Event("addstream")).stream=t,e.dispatchEvent(i))}))}),t.apply(e,arguments)}}}function B(e){if("object"==typeof e&&e.RTCPeerConnection){var t=(e=e.RTCPeerConnection.prototype).createOffer,i=e.createAnswer,n=e.setLocalDescription,r=e.setRemoteDescription,a=e.addIceCandidate;e.createOffer=function(e,i){let n=t.apply(this,[2<=arguments.length?arguments[2]:arguments[0]]);return i?(n.then(e,i),js.resolve()):n},e.createAnswer=function(e,t){let n=i.apply(this,[2<=arguments.length?arguments[2]:arguments[0]]);return t?(n.then(e,t),js.resolve()):n};var o=function(e,t,i){return e=n.apply(this,[e]),i?(e.then(t,i),js.resolve()):e};e.setLocalDescription=o,o=function(e,t,i){return e=r.apply(this,[e]),i?(e.then(t,i),js.resolve()):e},e.setRemoteDescription=o,o=function(e,t,i){return e=a.apply(this,[e]),i?(e.then(t,i),js.resolve()):e},e.addIceCandidate=o}}function G(e){let t=e&&e.navigator;if(t.mediaDevices&&t.mediaDevices.getUserMedia){var i;e=t.mediaDevices;let n=Sc(i=e.getUserMedia).call(i,e);t.mediaDevices.getUserMedia=e=>n(x(e))}var n;!t.getUserMedia&&t.mediaDevices&&t.mediaDevices.getUserMedia&&(t.getUserMedia=Sc(n=function(e,i,n){t.mediaDevices.getUserMedia(e).then(i,n)}).call(n,t))}function x(e){return e&&void 0!==e.video?Ba({},e,{video:E(e.video)}):e}function H(e){let t=e.RTCPeerConnection;e.RTCPeerConnection=function(e,i){if(e&&e.iceServers){let t=[];for(let i=0;it.generateCertificate})}function W(e){"object"==typeof e&&e.RTCPeerConnection&&"receiver"in e.RTCTrackEvent.prototype&&!e.RTCTransceiver&&Ja(e.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function Y(e){let t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(e){if(e){var i,n;void 0!==e.offerToReceiveAudio&&(e.offerToReceiveAudio=!!e.offerToReceiveAudio);let t=Rc(i=this.getTransceivers()).call(i,(e=>"audio"===e.receiver.track.kind));!1===e.offerToReceiveAudio&&t?"sendrecv"===t.direction?t.setDirection?t.setDirection("sendonly"):t.direction="sendonly":"recvonly"===t.direction&&(t.setDirection?t.setDirection("inactive"):t.direction="inactive"):!0!==e.offerToReceiveAudio||t||this.addTransceiver("audio"),void 0!==e.offerToReceiveVideo&&(e.offerToReceiveVideo=!!e.offerToReceiveVideo),i=Rc(n=this.getTransceivers()).call(n,(e=>"video"===e.receiver.track.kind)),!1===e.offerToReceiveVideo&&i?"sendrecv"===i.direction?i.setDirection?i.setDirection("sendonly"):i.direction="sendonly":"recvonly"===i.direction&&(i.setDirection?i.setDirection("inactive"):i.direction="inactive"):!0!==e.offerToReceiveVideo||i||this.addTransceiver("video")}return t.apply(this,arguments)}}function j(e){if(e.RTCIceCandidate&&(!e.RTCIceCandidate||!("foundation"in e.RTCIceCandidate.prototype))){var t=e.RTCIceCandidate;e.RTCIceCandidate=function(e){var i;if("object"==typeof e&&e.candidate&&0===ac(i=e.candidate).call(i,"a=")&&((e=JSON.parse(_n(e))).candidate=e.candidate.substr(2)),e.candidate&&e.candidate.length){i=new t(e),e=Wc.parseCandidate(e.candidate);let n=Ba(i,e);return n.toJSON=function(){return{candidate:n.candidate,sdpMid:n.sdpMid,sdpMLineIndex:n.sdpMLineIndex,usernameFragment:n.usernameFragment}},n}return new t(e)},e.RTCIceCandidate.prototype=t.prototype,n(e,"icecandidate",(t=>(t.candidate&&Ja(t,"candidate",{value:new e.RTCIceCandidate(t.candidate),writable:"false"}),t)))}}function K(e){if(e.RTCPeerConnection){var t=c(e);"sctp"in e.RTCPeerConnection.prototype||Ja(e.RTCPeerConnection.prototype,"sctp",{get(){return void 0===this._sctp?null:this._sctp}});var i=function(e){return!(!e||!e.sdp)&&((e=Wc.splitSections(e.sdp)).shift(),Dc(e).call(e,(e=>{var t;return(e=Wc.parseMLine(e))&&"application"===e.kind&&-1!==ac(t=e.protocol).call(t,"SCTP")})))},n=function(e){return null===(e=e.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/))||2>e.length||(e=io(e[1],10))!=e?-1:e},r=function(e){let i=65536;return"firefox"===t.browser&&(i=57>t.version?-1===e?16384:2147483637:60>t.version?57===t.version?65535:65536:2147483637),i},a=function(e,i){let n=65536;return"firefox"===t.browser&&57===t.version&&(n=65535),0<(e=Wc.matchPrefix(e.sdp,"a=max-message-size:")).length?n=io(e[0].substr(19),10):"firefox"===t.browser&&-1!==i&&(n=2147483637),n},o=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){if(this._sctp=null,"chrome"===t.browser&&76<=t.version){var{sdpSemantics:e}=this.getConfiguration();"plan-b"===e&&Ja(this,"sctp",{get(){return void 0===this._sctp?null:this._sctp},enumerable:!0,configurable:!0})}if(i(arguments[0])){var s=n(arguments[0]);let t;e=r(s),s=a(arguments[0],s),t=0===e&&0===s?Number.POSITIVE_INFINITY:0===e||0===s?Math.max(e,s):Math.min(e,s),Ja(e={},"maxMessageSize",{get:()=>t}),this._sctp=e}return o.apply(this,arguments)}}}function X(e){function t(e,t){let i=e.send;e.send=function(){var n=arguments[0];if(n=n.length||n.size||n.byteLength,"open"===e.readyState&&t.sctp&&n>t.sctp.maxMessageSize)throw new TypeError("Message too large (can send a maximum of "+t.sctp.maxMessageSize+" bytes)");return i.apply(e,arguments)}}if(e.RTCPeerConnection&&"createDataChannel"in e.RTCPeerConnection.prototype){var i=e.RTCPeerConnection.prototype.createDataChannel;e.RTCPeerConnection.prototype.createDataChannel=function(){let e=i.apply(this,arguments);return t(e,this),e},n(e,"datachannel",(e=>(t(e.channel,e.target),e)))}}function J(e){var t;if(e.RTCPeerConnection&&!("connectionState"in e.RTCPeerConnection.prototype)){var i=e.RTCPeerConnection.prototype;Ja(i,"connectionState",{get(){return{completed:"connected",checking:"connecting"}[this.iceConnectionState]||this.iceConnectionState},enumerable:!0,configurable:!0}),Ja(i,"onconnectionstatechange",{get(){return this._onconnectionstatechange||null},set(e){this._onconnectionstatechange&&(this.removeEventListener("connectionstatechange",this._onconnectionstatechange),delete this._onconnectionstatechange),e&&this.addEventListener("connectionstatechange",this._onconnectionstatechange=e)},enumerable:!0,configurable:!0}),wa(t=["setLocalDescription","setRemoteDescription"]).call(t,(e=>{let t=i[e];i[e]=function(){return this._connectionstatechangepoly||(this._connectionstatechangepoly=e=>{let t=e.target;if(t._lastConnectionState!==t.connectionState){t._lastConnectionState=t.connectionState;let i=new Event("connectionstatechange",e);t.dispatchEvent(i)}return e},this.addEventListener("iceconnectionstatechange",this._connectionstatechangepoly)),t.apply(this,arguments)}}))}}function Q(e){if(e.RTCPeerConnection){var t=c(e);if(!("chrome"===t.browser&&71<=t.version)){var i=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(e){var t,n;return e&&e.sdp&&-1!==ac(t=e.sdp).call(t,"\na=extmap-allow-mixed")&&(e.sdp=vo(n=e.sdp.split("\n")).call(n,(e=>"a=extmap-allow-mixed"!==Hc(e).call(e))).join("\n")),i.apply(this,arguments)}}}}function q(e){return"string"==typeof e?Ba({},$c[e]):e}function z(e){return"string"==typeof e?Ba({},eE[e]):e}function Z(e){return"string"==typeof e?Ba({},tE[e]):e}function $(e){return"string"==typeof e?Ba({},iE[e]):e}function ee(e,t){var i;Cc(i=xa(nE)).call(i,e)&&(nE[e]=t)}function te(e,t,i){return{sampleRate:e,stereo:t,bitrate:i}}function ie(e,t,i,n,r){return{width:e,height:t,frameRate:i,bitrateMin:n,bitrateMax:r}}function ne(e,t,i,n,r){return{width:{max:e},height:{max:t},frameRate:i,bitrateMin:n,bitrateMax:r}}function re(e,t){return{numSpatialLayers:e,numTemporalLayers:t}}function ae(e){return"[object Array]"===AE.call(e)}function oe(e){return null!==e&&"object"==typeof e}function se(e){return"[object Function]"===AE.call(e)}function ce(e,t){if(null!=e)if("object"!=typeof e&&(e=[e]),ae(e))for(var i=0,n=e.length;in||r&&("number"!=typeof e||0!=e%1))throw new GE(hE.INVALID_PARAMS,fo(a=fo(o="invalid ".concat(t,": the value range is [")).call(o,i,", ")).call(a,n,"]. integer only"))}function Se(e,t,i=1,n=255,r=!0){if(null==e)throw new GE(hE.INVALID_PARAMS,"".concat(t||"param"," cannot be empty"));var a,o,s;if(!fe(e,i,n,r))throw new GE(hE.INVALID_PARAMS,fo(a=fo(o=fo(s="Invalid ".concat(t||"string param",": Length of the string: [")).call(s,i,",")).call(o,n,"].")).call(a,r?" ASCII characters only.":""))}function Oe(e,t){if(!RE(e))throw new GE(hE.INVALID_PARAMS,"".concat(t," should be an array"))}function Ne(e){if("string"!=typeof e||!/^[a-zA-Z0-9 !#\$%&\(\)\+\-:;<=\.>\?@\[\]\^_\{\}\|~,]{1,64}$/.test(e))throw BE.error("Invalid Channel Name ".concat(e)),new GE(hE.INVALID_PARAMS,"The length must be within 64 bytes. The supported characters: a-z,A-Z,0-9,space,!, #, $, %, &, (, ), +, -, :, ;, <, =, ., >, ?, @, [, ], ^, _, {, }, |, ~, ,")}function me(e){var t;if(!("number"==typeof e&&Math.floor(e)===e&&0<=e&&4294967295>=e||fe(e,1,255)))throw BE.error(fo(t="Invalid UID ".concat(e," ")).call(t,typeof e)),new GE(hE.INVALID_PARAMS,"[String uid] Length of the string: [1,255]. ASCII characters only. [Number uid] The value range is [0,10000]")}function fe(e,t=1,i=255,n=!0){if(t="string"==typeof e&&e.length<=i&&e.length>=t){if(!(n=!n))e:if("string"!=typeof e)n=!1;else{for(n=0;n(t=e.charCodeAt(n))||255e.length)return!1;try{wa(e).call(e,(e=>{if(!e.urls)throw Error()}))}catch(e){return!1}return!0}function De(e){return Se(e.turnServerURL,"turnServerURL"),Se(e.username,"username"),Se(e.password,"password"),e.udpport&&pe(e.udpport,"udpport",1,99999,!0),e.forceturn&&Ae(e.forceturn,"forceturn"),e.security&&Ae(e.security,"security"),e.tcpport&&pe(e.tcpport,"tcpport",1,99999,!0),!0}function Le(e){return void 0!==e.level&&Ie(e.level,"level",[1,2]),!0}function Pe(e,t){Se(e.url,"".concat(t,".url"),1,1e3,!1),null==e.x||pe(e.x,"".concat(t,".x"),0,1e4),null==e.y||pe(e.y,"".concat(t,".y"),0,1e4),null==e.width||pe(e.width,"".concat(t,".width"),0,1e4),null==e.height||pe(e.height,"".concat(t,".height"),0,1e4),null==e.zOrder||pe(e.zOrder,"".concat(t,".zOrder"),0,255),null==e.alpha||pe(e.alpha,"".concat(t,".alpha"),0,1,!1)}function Me(e){if(!e.channelName)throw new GE(hE.INVALID_PARAMS,"invalid channelName in info");if(!e.uid||"number"!=typeof e.uid)throw new GE(hE.INVALID_PARAMS,"invalid uid in info, uid must be a number");return e.token&&Se(e.token,"info.token",1,2047),me(e.uid),Ne(e.channelName),!0}function ye(e){return Ie(e,"mediaSource",["screen","window","application"]),!0}function ke(e){var t,i,n,r;let a=(e=e||navigator.userAgent).match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i)||[];if("Chrome"===a[1]){var o=e.match(/(OPR(?=\/))\/?(\d+)/i);null!==o&&(a=o)}"Safari"===a[1]&&null!==(o=e.match(/version\/(\d+)/i))&&(a[2]=o[1]),-1!==ac(t=e.toLowerCase()).call(t,"qqbrowser")&&null!==(t=e.match(/(qqbrowser(?=\/))\/?(\d+)/i))&&(a=t),-1!==ac(i=e.toLowerCase()).call(i,"micromessenger")&&null!==(i=e.match(/(micromessenger(?=\/))\/?(\d+)/i))&&(a=i),-1!==ac(n=e.toLowerCase()).call(n,"edge")&&null!==(n=e.match(/(edge(?=\/))\/?(\d+)/i))&&(a=n),-1!==ac(r=e.toLowerCase()).call(r,"trident")&&null!==(r=/\brv[ :]+(\d+)/g.exec(e)||[])&&(a=["","IE",r[1]]),r=null,n=[{s:Vc.WIN_10,r:/(Windows 10.0|Windows NT 10.0)/},{s:Vc.WIN_81,r:/(Windows 8.1|Windows NT 6.3)/},{s:Vc.WIN_8,r:/(Windows 8|Windows NT 6.2)/},{s:Vc.WIN_7,r:/(Windows 7|Windows NT 6.1)/},{s:Vc.WIN_VISTA,r:/Windows NT 6.0/},{s:Vc.WIN_SERVER_2003,r:/Windows NT 5.2/},{s:Vc.WIN_XP,r:/(Windows NT 5.1|Windows XP)/},{s:Vc.WIN_2000,r:/(Windows NT 5.0|Windows 2000)/},{s:Vc.ANDROID,r:/Android/},{s:Vc.OPEN_BSD,r:/OpenBSD/},{s:Vc.SUN_OS,r:/SunOS/},{s:Vc.LINUX,r:/(Linux|X11)/},{s:Vc.IOS,r:/(iPhone|iPad|iPod)/},{s:Vc.MAC_OS_X,r:/Mac OS X/},{s:Vc.MAC_OS,r:/(MacPPC|MacIntel|Mac_PowerPC|Macintosh)/},{s:Vc.QNX,r:/QNX/},{s:Vc.UNIX,r:/UNIX/},{s:Vc.BEOS,r:/BeOS/},{s:Vc.OS_2,r:/OS\/2/},{s:Vc.SEARCH_BOT,r:/(nuhk|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask Jeeves\/Teoma|ia_archiver)/}];for(let t in n)if((i=n[t]).r.test(e)){r=i.s;break}return{name:a[1],version:a[2],os:r}}function Ue(){return ke().name===Fc.CHROME}function we(){return ke().name===Fc.FIREFOX}function be(){return window.navigator.appVersion&&null!==window.navigator.appVersion.match(/Chrome\/([\w\W]*?)\./)&&35>=window.navigator.appVersion.match(/Chrome\/([\w\W]*?)\./)[1]}function Ve(){let e=ke();return e.name!==Fc.EDGE&&e.name!==Fc.SAFARI&&!!navigator.userAgent.toLocaleLowerCase().match(/chrome\/[\d]./i)}function Fe(e,t){var i=xa(e);if(Nd){var n=Nd(e);t&&(n=vo(n).call(n,(function(t){return Eo(e,t).enumerable}))),i.push.apply(i,n)}return i}function Be(e){for(var t=1;te?1:.17<=e&&.36>e?2:.36<=e&&.59>e?3:.59<=e&&1>=e?4:1{window.setTimeout(t,e)}))}function Qe(e){let t=new GE(hE.TIMEOUT,"timeout");return new js(((i,n)=>{window.setTimeout((()=>n(t)),e)}))}function qe(e=7,t){var i,n;let r=Math.random().toString(16).substr(2,e).toLowerCase();return r.length===e?fo(i="".concat(t)).call(i,r):fo(n="".concat(t)).call(n,r)+qe(e-r.length,"")}function ze(e){return new js(((t,i)=>{let n=document.createElement("video");n.setAttribute("autoplay",""),n.setAttribute("muted",""),n.muted=!0,n.autoplay=!0,n.setAttribute("playsinline",""),n.setAttribute("style","position: absolute; top: 0; left: 0; width: 1px; height: 1px"),document.body.appendChild(n),n.addEventListener("playing",(()=>{!n.videoWidth&&we()||(document.body.removeChild(n),t([n.videoWidth,n.videoHeight]))})),n.srcObject=new MediaStream([e])}))}function Ze(e){return js.all(Js(e).call(e,(e=>e.then((e=>{throw e}),(e=>e))))).then((e=>{throw e}),(e=>e))}function $e(e,t,...i){return 0===e.getListeners(t).length?js.reject(new GE(hE.UNEXPECTED_ERROR,"can not emit promise")):new js(((n,r)=>{e.emit(t,...i,n,r)}))}function et(e,t,...i){return 0===e.getListeners(t).length?js.resolve():$e(e,t,...i)}function tt(e,t,...i){return 0===e.getListeners(t).length?null:it(e,t,...i)}function it(e,t,...i){let n=null,r=null;if(e.emit(t,...i,(e=>{n=e}),(e=>{r=e})),null!==r)throw r;if(null===n)throw new GE(hE.UNEXPECTED_ERROR,"handler is not sync");return n}function nt(e,t){-1!==(t=ac(e).call(e,t))&&$s(e).call(e,t,1)}function rt(e){let t=[];return wa(e).call(e,(e=>{-1===ac(t).call(t,e)&&t.push(e)})),t}function at(e){js.resolve().then(e)}function ot(e,t){Vd[t]||(Vd[t]=!0,e())}function st(e){e=window.atob(e);let t=new Uint8Array(new ArrayBuffer(e.length));for(let i=0;ie?"number"!=typeof e?e.max||e.exact||e.ideal||e.min||t:e:t;return e={audio:!1,video:{mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:e,maxHeight:i(t.height,1080),maxWidth:i(t.width,1920)}}},t.frameRate&&"number"!=typeof t.frameRate?(e.video.mandatory.maxFrameRate=t.frameRate.max,e.video.mandatory.minFrameRate=t.frameRate.min):"number"==typeof t.frameRate&&(e.video.mandatory.maxFrameRate=t.frameRate),await navigator.mediaDevices.getUserMedia(e)}async function _t(e){let t=["window","screen"];"application"!==e&&"window"!==e||(t=["window"]),"screen"===e&&(t=["screen"]);let i=dt();if(!i)throw new GE(hE.ELECTRON_IS_NULL);e=null;try{e=i.desktopCapturer.getSources({types:t})}catch(t){e=null}e&&e.then||(e=new js(((e,n)=>{i.desktopCapturer.getSources({types:t},((t,i)=>{t?n(t):e(i)}))})));try{return await e}catch(e){throw new GE(hE.ELECTRON_DESKTOP_CAPTURER_GET_SOURCES_ERROR,e.toString())}}function dt(){if(xd)return xd;try{return xd=window.require("electron"),xd}catch(e){return null}}async function lt(e,t){let i=0,n=null;for(;2>i;)try{n=await ut(e,t,0{const n=document.createElement("div");n.innerText="share screen",n.setAttribute("style","text-align: center; height: 25px; line-height: 25px; border-radius: 4px 4px 0 0; background: #D4D2D4; border-bottom: solid 1px #B9B8B9;");const r=document.createElement("div");r.setAttribute("style","width: 100%; height: 500px; padding: 15px 25px ; box-sizing: border-box;");const a=document.createElement("div");a.innerText="Agora Web Screensharing wants to share the contents of your screen with webdemo.agorabeckon.com. Choose what you'd like to share.",a.setAttribute("style","height: 12%;");const o=document.createElement("div");o.setAttribute("style","width: 100%; height: 80%; background: #FFF; border: solid 1px #CBCBCB; display: flex; flex-wrap: wrap; justify-content: space-around; overflow-y: scroll; padding: 0 15px; box-sizing: border-box;");const s=document.createElement("div");s.setAttribute("style","text-align: right; padding: 16px 0;");const c=document.createElement("button");c.innerHTML="cancel",c.setAttribute("style","width: 85px;"),c.onclick=()=>{document.body.removeChild(E);const e=Error("NotAllowedError");e.name="NotAllowedError",t(e)},s.appendChild(c),r.appendChild(a),r.appendChild(o),r.appendChild(s);const E=document.createElement("div");E.setAttribute("style","position: fixed; z-index: 99999999; top: 50%; left: 50%; width: 620px; height: 525px; background: #ECECEC; border-radius: 4px; -webkit-transform: translate(-50%,-50%); transform: translate(-50%,-50%);"),E.appendChild(n),E.appendChild(r),document.body.appendChild(E),Js(i).call(i,(t=>{if(t.id){const i=document.createElement("div");i.setAttribute("style","width: 30%; height: 160px; padding: 20px 0; text-align: center;box-sizing: content-box;");let n=t.thumbnail;const{width:r}=n.getSize();1920'+t.name.replace(/[\u00A0-\u9999<>&]/g,(function(e){return"&#"+e.charCodeAt(0)+";"}))+"",i.onclick=()=>{document.body.removeChild(E),e(t.id)},o.appendChild(i)}}))})));var i;return await Et(t,e)}(e.screen));else if(Ue()&&e.screen.extensionId&&e.screen.mandatory){if(!a.getStreamFromExtension)throw new GE(hE.NOT_SUPPORTED,"This browser does not support screen sharing");BE.debug("[".concat(t,'] Screen access on chrome stable, looking for extension"'));var o=await(n=e.screen.extensionId,r=t,new js(((e,t)=>{try{chrome.runtime.sendMessage(n,{getStream:!0},(i=>{if(!i||!i.streamId)return BE.error("[".concat(r,"] No response from Chrome Plugin. Plugin not installed properly"),i),void t(new GE(hE.CHROME_PLUGIN_NO_RESPONSE,"No response from Chrome Plugin. Plugin not installed properly"));e(i.streamId)}))}catch(e){var i;BE.error(fo(i="[".concat(r,"] AgoraRTC screensharing plugin is not accessible(")).call(i,n,")"),e.toString()),t(new GE(hE.CHROME_PLUGIN_NOT_INSTALL))}})));e.screen.mandatory.chromeMediaSourceId=o,Rt(i,await navigator.mediaDevices.getUserMedia({video:{mandatory:e.screen.mandatory}}))}else if(a.getDisplayMedia)e.screen.mediaSource&&ye(e.screen.mediaSource),o={width:e.screen.width,height:e.screen.height,frameRate:e.screen.frameRate,displaySurface:"screen"===e.screen.mediaSource?"monitor":e.screen.mediaSource},BE.debug("[".concat(t,"] getDisplayMedia:"),_n({video:o,audio:!!e.screenAudio})),Rt(i,await navigator.mediaDevices.getDisplayMedia({video:o,audio:!!e.screenAudio}));else{if(!we())throw BE.error("[".concat(t,"] This browser does not support screenSharing")),new GE(hE.NOT_SUPPORTED,"This browser does not support screen sharing");e.screen.mediaSource&&ye(e.screen.mediaSource),a={video:{mediaSource:e.screen.mediaSource,width:e.screen.width,height:e.screen.height,frameRate:e.screen.frameRate}},BE.debug(fo(o="[".concat(t,"] getUserMedia: ")).call(o,_n(a))),Rt(i,await navigator.mediaDevices.getUserMedia(a))}if(!e.video&&!e.audio)return i;let s;e={video:e.video,audio:e.audio},BE.debug("[".concat(t,"] GetUserMedia"),_n(e)),o=null,(t=ke()).name!==Fc.SAFARI&&t.os!==Vc.IOS||(o=await Yd.lock());try{s=await navigator.mediaDevices.getUserMedia(e)}catch(e){throw o&&o(),e}return e.audio&&(jd=!0),e.video&&(Kd=!0),Rt(i,s),o&&o(),i}function ht(e,t){switch(e){case"Starting video failed":case"OverconstrainedError":case"TrackStartError":var i;return new GE(hE.MEDIA_OPTION_INVALID,fo(i="".concat(e,": ")).call(i,t));case"NotFoundError":case"DevicesNotFoundError":var n;return new GE(hE.DEVICE_NOT_FOUND,fo(n="".concat(e,": ")).call(n,t));case"NotSupportedError":var r;return new GE(hE.NOT_SUPPORTED,fo(r="".concat(e,": ")).call(r,t));case"NotReadableError":var a;return new GE(hE.NOT_READABLE,fo(a="".concat(e,": ")).call(a,t));case"InvalidStateError":case"NotAllowedError":case"PERMISSION_DENIED":case"PermissionDeniedError":var o;return new GE(hE.PERMISSION_DENIED,fo(o="".concat(e,": ")).call(o,t));case"ConstraintNotSatisfiedError":var s;return new GE(hE.CONSTRAINT_NOT_SATISFIED,fo(s="".concat(e,": ")).call(s,t));default:var c;return BE.error("getUserMedia unexpected error",e),new GE(hE.UNEXPECTED_ERROR,fo(c="".concat(e,": ")).call(c,t))}}function Rt(e,t){let i=e.getVideoTracks()[0],n=e.getAudioTracks()[0],r=t.getVideoTracks()[0];(t=t.getAudioTracks()[0])&&(n&&e.removeTrack(n),e.addTrack(t)),r&&(i&&e.removeTrack(i),e.addTrack(r))}function Tt(e,t){var i=xa(e);if(Nd){var n=Nd(e);t&&(n=vo(n).call(n,(function(t){return Eo(e,t).enumerable}))),i.push.apply(i,n)}return i}function At(e,t,i){return new js(((n,r)=>{t.timeout=t.timeout||nE.HTTP_CONNECT_TIMEOUT,t.responseType=t.responseType||"json",t.data&&!i?(t.data=_n(t.data),Zd+=Xe(t.data)):i&&(Zd+=t.data.size),t.headers=t.headers||{},t.headers["Content-Type"]=t.headers["Content-Type"]||"application/json",t.method="POST",t.url=e,bE.request(t).then((e=>{"string"==typeof e.data?$d+=Xe(e.data):e.data instanceof ArrayBuffer||e.data instanceof Uint8Array?$d+=e.data.byteLength:$d+=Xe(_n(e.data)),n(e.data)})).catch((e=>{bE.isCancel(e)?r(new GE(hE.OPERATION_ABORTED,"cancel token canceled")):"ECONNABORTED"===e.code?r(new GE(hE.NETWORK_TIMEOUT,e.message)):e.response?r(new GE(hE.NETWORK_RESPONSE_ERROR,e.response.status)):r(new GE(hE.NETWORK_ERROR,e.message))}))}))}async function It(e,t){let i=new Blob([t.data],{type:"buffer"});return await At(e,function(e){for(var t=1;t{await Je(a),a*=r.timeoutFactor,a=Math.min(r.maxRetryTimeout,a)},s=!1;return(n=new js((async(n,a)=>{t=t||(()=>!1),i=i||(()=>!0);for(let c=0;cs=!0,n}function Ct(){if(!_l&&(El?(BE.info("create audio context"),_l=new El,_l.onstatechange=()=>{dl.emit("state-change")},function(e){function t(t){"running"===e.state?i(!1):"closed"!==e.state&&(i(!0),t?e.resume().then(n,n):i(!1))}function i(e){if(o!==e){o=e;for(let t=0,i=a;t{var a;return e._inputNodes||(e._inputNodes=[]),Cc(a=e._inputNodes).call(a,i)||(i instanceof AudioNode?(e._inputNodes.push(i),t.call(e,i,n,r)):t.call(e,i,n)),e},e.disconnect=(n,r,a)=>{i.call(e),n?nt(e._inputNodes,n):e._inputNodes=[];for(let i of e._inputNodes)t.call(e,i)}}}function vt(e,t){let i=1/t,n=Ct(),r=n.createGain();r.gain.value=0,r.connect(n.destination);let a=!1,o=()=>{if(a)return void(r=null);const t=n.createOscillator();t.onended=o,t.connect(r),t.start(0),t.stop(n.currentTime+i),e(n.currentTime)};return o(),()=>{a=!0}}function Dt(e,t){var i=xa(e);if(Nd){var n=Nd(e);t&&(n=vo(n).call(n,(function(t){return Eo(e,t).enumerable}))),i.push.apply(i,n)}return i}function Lt(e){for(var t=1;t{let t=await At(e+"".concat(-1===ac(e).call(e,"?")?"?":"&","action=wrtc_gateway"),{data:o,cancelToken:n,headers:{"X-Packet-Service-Type":0,"X-Packet-URI":69}});if(t.addresses&&0===t.addresses.length&&0===t.code)throw new GE(hE.VOID_GATEWAY_ADDRESS,"",{retry:!0,csIp:t.detail&&t.detail[502]});if(nE.GATEWAY_ADDRESS&&0({ip:e.ip,port:e.port,ticket:t.addresses[0]&&t.addresses[0].ticket})));t.addresses=e}return function(e,t){var i;let n=[".agora.io",".sd-rtn.com"],r=n[1]&&-1!==ac(t).call(t,n[1])?1:0;return e.addresses=e.addresses||[],{gatewayAddrs:Js(i=e.addresses).call(i,(e=>{var t,i,a;return e.ip.match(/^[\.:\d]+$/)?fo(t=fo(i="".concat(e.ip.replace(/[^\d]/g,"-"),".edge")).call(i,n[r++%n.length],":")).call(t,e.port):(BE.info("Cannot recognized as IP address ".concat(e.ip,". Used As Host instead")),fo(a="".concat(e.ip,":")).call(a,e.port))})),uid:e.uid,cid:e.cid,vid:e.detail&&e.detail[8],uni_lbs_ip:e.detail&&e.detail[1],res:e,csIp:e.detail&&e.detail[502]}}(t,e)}),(t=>{if(0===t.res.code)return el.joinChooseServer(i.sid,{lts:a,succ:!0,csAddr:e,serverList:t.gatewayAddrs,ec:null,cid:t.res.cid.toString(),uid:t.res.uid.toString(),csIp:t.csIp}),!1;let n=Nt(t.res.code);throw new GE(hE.CAN_NOT_GET_GATEWAY_SERVER,n.desc,{retry:n.retry,csIp:t.csIp})}),(t=>{return t.code!==hE.OPERATION_ABORTED&&(t.code===hE.CAN_NOT_GET_GATEWAY_SERVER||t.code===hE.VOID_GATEWAY_ADDRESS?(el.joinChooseServer(i.sid,{lts:a,succ:!1,csAddr:e,serverList:null,ec:t.message,csIp:t.data&&t.data.csIp}),BE.warning(fo(n=fo(r=fo(o="[".concat(i.clientId,"] Choose server ")).call(o,e," failed, message: ")).call(r,t.message,", retry: ")).call(n,t.data.retry)),t.data.retry):(el.joinChooseServer(i.sid,{lts:a,succ:!1,csAddr:e,serverList:null,ec:t.code,csIp:t.data&&t.data.csIp}),BE.warning("[".concat(i.clientId,"] Choose server network error, retry"),t),!0));var n,r,o}),r)}async function Ut(e,t,i){return{gatewayInfo:await async function(e,t,i){var n,r;const a=Js(n=dc(r=nE.WEBCS_DOMAIN).call(r,0,nE.AJAX_REQUEST_CONCURRENT)).call(n,(t=>{var i;return{url:e.proxyServer?fo(i="https://".concat(e.proxyServer,"/ap/?url=")).call(i,t+"/api/v1"):"https://".concat(t,"/api/v1"),areaCode:fl()}}));let o=null;return o=await Ze([(async()=>await Gd({fragementLength:nE.FRAGEMENT_LENGTH,referenceList:a,asyncMapHandler:n=>(BE.debug("[".concat(e.clientId,"] Connect to choose_server:"),n.url),kt(n,e,t,i)),allFailedhandler:e=>{throw e[0]}}))(),(async()=>{var n;if(await Je(1e3),null!==o)return o;const r=Js(n=nE.WEBCS_DOMAIN_BACKUP_LIST).call(n,(t=>{var i;return{url:e.proxyServer?fo(i="https://".concat(e.proxyServer,"/ap/?url=")).call(i,t+"/api/v1"):"https://".concat(t,"/api/v1"),areaCode:fl()}}));return await Gd({fragementLength:nE.FRAGEMENT_LENGTH,referenceList:r,asyncMapHandler:n=>(BE.debug("[".concat(e.clientId,"] Connect to backup choose_server:"),n.url),kt(n,e,t,i)),allFailedhandler:e=>{throw e[0]}})})()]),o}(e,t,i)}}async function wt(e,t,i,n){var r;let a=dc(r=nE.ACCOUNT_REGISTER).call(r,0,nE.AJAX_REQUEST_CONCURRENT);return r=[],r=t.proxyServer?Js(a).call(a,(e=>{var i;return fo(i="https://".concat(t.proxyServer,"/ap/?url=")).call(i,e+"/api/v1")})):Js(a).call(a,(e=>"https://".concat(e,"/api/v1"))),(await async function(e,t,i,n,r){let a=Pd(),o={sid:i.sid,opid:10,appid:i.appId,string_uid:t},s=e[0];if(0!==(i=await ft((()=>At(s+"".concat(-1===ac(s).call(s,"?")?"?":"&","action=stringuid"),{data:o,cancelToken:n,headers:{"X-Packet-Service-Type":0,"X-Packet-URI":72}})),((i,n)=>{if(0===i.code){var r;if(0>=i.uid||i.uid>=Math.pow(2,32))throw BE.error(fo(r="Invalid Uint Uid ".concat(t," => ")).call(r,i.uid),i),el.reqUserAccount(o.sid,{lts:a,success:!1,serverAddr:s,stringUid:o.string_uid,uid:i.uid,errorCode:hE.INVALID_UINT_UID_FROM_STRING_UID,extend:o}),new GE(hE.INVALID_UINT_UID_FROM_STRING_UID);return el.reqUserAccount(o.sid,{lts:a,success:!0,serverAddr:s,stringUid:o.string_uid,uid:i.uid,errorCode:null,extend:o}),!1}return(r=Nt(i.code)).retry&&(s=e[(n+1)%e.length]),el.reqUserAccount(o.sid,{lts:a,success:!1,serverAddr:s,stringUid:o.string_uid,uid:i.uid,errorCode:r.desc,extend:o}),r.retry}),((t,i)=>t.code!==hE.OPERATION_ABORTED&&(el.reqUserAccount(o.sid,{lts:a,success:!1,serverAddr:s,stringUid:o.string_uid,uid:null,errorCode:t.code,extend:o}),s=e[(i+1)%e.length],!0)),r)).code)throw i=Nt(i.code),new GE(hE.UNEXPECTED_RESPONSE,i.desc);return i}(r,e,t,i,n)).uid}async function bt(e,t,i,n){var r,a;let o=Js(r=dc(a=nE.UAP_AP).call(a,0,nE.AJAX_REQUEST_CONCURRENT)).call(r,(e=>{var i;return t.proxyServer?fo(i="https://".concat(t.proxyServer,"/ap/?url=")).call(i,e+"/api/v1?action=uap"):"https://".concat(e,"/api/v1?action=uap")}));return await function(e,t,i,n,r){Nl+=1;let a,o,s={sid:i.sid,command:"convergeAllocateEdge",uid:"666",appId:i.appId,ts:Math.floor(Pd()/1e3),seq:Nl,requestId:Nl,version:Qc,cname:i.cname},c={service_name:t,json_body:_n(s)},E=e[0];return ft((async()=>{a=Pd();var e=await At(E,{data:c,cancelToken:n,headers:{"X-Packet-Service-Type":"0","X-Packet-URI":"61"}});if(o=Pd()-a,0!==e.code){var i=new GE(hE.UNEXPECTED_RESPONSE,"live streaming ap error, code"+e.code,{retry:!0,responseTime:o});throw BE.error(i.toString()),i}if(200!==(e=JSON.parse(e.json_body)).code)throw e=new GE(hE.UNEXPECTED_RESPONSE,fo(i="live streaming app center error, code: ".concat(e.code,", reason: ")).call(i,e.reason),{code:e.code,responseTime:o}),BE.error(e.toString()),e;if(!e.servers||0===e.servers.length)throw i=new GE(hE.UNEXPECTED_RESPONSE,"live streaming app center empty server",{code:e.code,responseTime:o}),BE.error(i.toString()),i;return i=function(e,t){var i;return{addressList:Js(i=e.servers).call(i,(e=>{var i,n;return fo(i=fo(n="wss://".concat(e.address.replace(/\./g,"-"),".edge.agora.io:")).call(n,e.wss,"?serviceName=")).call(i,encodeURIComponent(t))})),workerToken:e.workerToken,vid:e.vid}}(e,t),nE.LIVE_STREAMING_ADDRESS&&(i.addressList=nE.LIVE_STREAMING_ADDRESS instanceof Array?nE.LIVE_STREAMING_ADDRESS:[nE.LIVE_STREAMING_ADDRESS]),function(e){for(var t=1;t(el.apworkerEvent(i.sid,{success:!0,sc:200,serviceName:t,responseDetail:_n(n.addressList),firstSuccess:0===r,responseTime:o,serverIp:e[r%e.length]}),!1)),((n,r)=>(el.apworkerEvent(i.sid,{success:!1,sc:n.data&&n.data.code||200,serviceName:t,responseTime:o,serverIp:e[r%e.length]}),!!(n.code!==hE.OPERATION_ABORTED&&n.code!==hE.UNEXPECTED_RESPONSE||n.data&&n.data.retry)&&(E=e[(r+1)%e.length],!0))),r)}(o,e,t,i,n)}function Vt(e,t){var i=xa(e);if(Nd){var n=Nd(e);t&&(n=vo(n).call(n,(function(t){return Eo(e,t).enumerable}))),i.push.apply(i,n)}return i}function Ft(e){if(Array.isArray(e))return e.map((function(e){return e}));if(!Bt(e))return e;var t,i={};for(t in e)Bt(e[t])||Array.isArray(e[t])?i[t]=Ft(e[t]):i[t]=e[t];return i}function Bt(e){return!("object"!=typeof e||Array.isArray(e)||!e)}function Gt(e,t){function i(){this.constructor=e}Ml(e,t),e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)}function xt(e,t,i,n){return new(i||(i=Promise))((function(r,a){function o(e){try{c(n.next(e))}catch(e){a(e)}}function s(e){try{c(n.throw(e))}catch(e){a(e)}}function c(e){e.done?r(e.value):new i((function(t){t(e.value)})).then(o,s)}c((n=n.apply(e,t||[])).next())}))}function Ht(e,t){function i(i){return function(o){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(a=2&i[0]?r.return:i[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,i[1])).done)return a;switch(r=0,a&&(i=[2&i[0],a.value]),i[0]){case 0:case 1:a=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((a=0<(a=s.trys).length&&a[a.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!a||i[1]>a[0]&&i[1]o;o++)a[o]=o;o=0;for(var s=0;256>s;s++)o=(o+a[s]+t[s%i])%256,[a[s],a[o]]=[a[o],a[s]];for(o=i=0,s=0;s<0+n;s++)o=(o+a[i=(i+1)%256])%256,[a[i],a[o]]=[a[o],a[i]],t=a[(a[i]+a[o])%256],0<=s&&(r[s-0]=e[s-0]^t);return e=String.fromCharCode.apply(null,Ld(r)),Function("var winSize = 5; return `"+e+"`")()}function jt(e){let t={};return e.facingMode&&(t.facingMode=e.facingMode),e.cameraId&&(t.deviceId={exact:e.cameraId}),e.encoderConfig?(e=q(e.encoderConfig),t.width=e.width,t.height=e.height,!be()&&e.frameRate&&(t.frameRate=e.frameRate),ke().name===Fc.EDGE&&"object"==typeof t.frameRate&&(t.frameRate.max=60),we()&&(t.frameRate={ideal:30,max:30}),t):t}function Kt(e){let t={};if(be()||(void 0!==e.AGC&&(t.autoGainControl=e.AGC,Ue()&&(t.googAutoGainControl=e.AGC,t.googAutoGainControl2=e.AGC)),void 0!==e.AEC&&(t.echoCancellation=e.AEC),void 0!==e.ANS&&(t.noiseSuppression=e.ANS,Ue()&&(t.googNoiseSuppression=e.ANS))),e.encoderConfig){let i=$(e.encoderConfig);t.channelCount=i.stereo?2:1,t.sampleRate=i.sampleRate,t.sampleSize=i.sampleSize}return e.microphoneId&&(t.deviceId={exact:e.microphoneId}),Ue()&&2===t.channelCount&&(t.googAutoGainControl=!1,t.googAutoGainControl2=!1,t.echoCancellation=!1,t.googNoiseSuppression=!1),t}function Xt(e,t){var i=xa(e);if(Nd){var n=Nd(e);t&&(n=vo(n).call(n,(function(t){return Eo(e,t).enumerable}))),i.push.apply(i,n)}return i}function Jt(e){for(var t=1;tS?(t=fo(t).call(t,a),t=fo(t).call(t,r)):(t=fo(t).call(t,r),t=fo(t).call(t,a)),e=t.join("\r\n")+"\r\n"}return e}function $t(e,t){let i=(e,t)=>{const r=Ou(e,t);return r?i(n(e,r),t):e},n=(e,t)=>{var i,n;const r=Sc(i=RegExp.prototype.test).call(i,/^([a-z])=(.*)/),a=["a=rtpmap:".concat(t),"a=rtcp-fb:".concat(t),"a=fmtp:".concat(t)],o=vo(n=e.split(/(\r\n|\r|\n)/)).call(n,r),s=[];if(wa(o).call(o,((e,t)=>{wa(a).call(a,(i=>{Cc(e).call(e,i)&&s.push(t)}))})),e=Su(o).call(o,(e=>Cc(e).call(e,"apt=".concat(t))))){s.push(e,e-1);var c=(c=o[e-1].match(/a=rtpmap:(\d+) rtx.*/))&&c[1]}return wa(s).call(s,(e=>{o[e]=""})),e=Su(o).call(o,(e=>Cc(e).call(e,"m=video"))),o[e]=o[e].replace(" ".concat(t),""),c&&(o[e]=o[e].replace(" ".concat(c),"")),vo(o).call(o,(e=>!!e)).join("\r\n")+"\r\n"};return wa(t).call(t,(t=>{e=i(e,t)})),e}function ei(e,t){let i=document.createElement("video"),n=document.createElement("canvas");i.setAttribute("style","display:none"),n.setAttribute("style","display:none"),i.setAttribute("muted",""),i.muted=!0,i.setAttribute("autoplay",""),i.autoplay=!0,i.setAttribute("playsinline",""),n.width=xe(t.width),n.height=xe(t.height),t=xe(t.framerate||15),document.body.append(i),document.body.append(n);let r=e._mediaStreamTrack;i.srcObject=new MediaStream([r]),i.play();let a=n.getContext("2d");if(!a)throw new GE(hE.UNEXPECTED_ERROR,"can not get canvas context");let o=n.captureStream(b_.supportRequestFrame?0:t).getVideoTracks()[0],s=vt((()=>{if(i.paused&&i.play(),2 ")).call(s,n.width,"x")).call(t,e)),n.height=e)}a.drawImage(i,0,0,n.width,n.height),o.requestFrame&&o.requestFrame(),r!==e._mediaStreamTrack&&(r=e._mediaStreamTrack,i.srcObject=new MediaStream([r]))}),t),c=o.stop;return o.stop=()=>{c.call(o),s(),i.remove(),n.width=0,n.remove(),i=n=null,BE.debug("clean low stream renderer")},o}function ti(e,t){var i=xa(e);if(Nd){var n=Nd(e);t&&(n=vo(n).call(n,(function(t){return Eo(e,t).enumerable}))),i.push.apply(i,n)}return i}function ii(e){for(var t=1;targuments.length?tn(ji[e])||tn(Ai[e]):ji[e]&&ji[e][t]||Ai[e]&&Ai[e][t]},rn=nn("JSON","stringify"),an=/[\uD800-\uDFFF]/g,on=/^[\uD800-\uDBFF]$/,sn=/^[\uDC00-\uDFFF]$/,cn=function(e,t,i){var n=i.charAt(t-1);return t=i.charAt(t+1),on.test(e)&&!sn.test(t)||sn.test(e)&&!on.test(n)?"\\u"+e.charCodeAt(0).toString(16):e},En=Ii((function(){return'"\\udf06\\ud834"'!==rn("\udf06\ud834")||'"\\udead"'!==rn("\udead")}));rn&&en({target:"JSON",stat:!0,forced:En},{stringify:function(e,t,i){var n=rn.apply(null,arguments);return"string"==typeof n?n.replace(an,cn):n}}),ji.JSON||(ji.JSON={stringify:JSON.stringify});var _n=function(e,t,i){return ji.JSON.stringify.apply(null,arguments)},dn={},ln=0,un=Math.random(),hn=function(e){return"Symbol("+String(void 0===e?"":e)+")_"+(++ln+un).toString(36)},Rn=!Ii((function(){return Object.isExtensible(Object.preventExtensions({}))})),Tn=e((function(e){var t=qi.f,i=hn("meta"),n=0,r=Object.isExtensible||function(){return!0},a=function(e){t(e,i,{value:{objectID:"O"+ ++n,weakData:{}}})},o=e.exports={REQUIRED:!1,fastKey:function(e,t){if(!Pi(e))return"symbol"==typeof e?e:("string"==typeof e?"S":"P")+e;if(!ki(e,i)){if(!r(e))return"F";if(!t)return"E";a(e)}return e[i].objectID},getWeakData:function(e,t){if(!ki(e,i)){if(!r(e))return!0;if(!t)return!1;a(e)}return e[i].weakData},onFreeze:function(e){return Rn&&o.REQUIRED&&r(e)&&!ki(e,i)&&a(e),e}};dn[i]=!0})),An=Ai["__core-js_shared__"]||function(e,t){try{zi(Ai,e,t)}catch(i){Ai[e]=t}return t}("__core-js_shared__",{}),In=e((function(e){(e.exports=function(e,t){return An[e]||(An[e]=void 0!==t?t:{})})("versions",[]).push({version:"3.4.3",mode:"pure",copyright:"© 2019 Denis Pushkarev (zloirock.ru)"})})),pn=!!Object.getOwnPropertySymbols&&!Ii((function(){return!String(Symbol())})),Sn=pn&&!Symbol.sham&&"symbol"==typeof Symbol(),On=In("wks"),Nn=Ai.Symbol,mn=Sn?Nn:hn,fn=function(e){return ki(On,e)||(pn&&ki(Nn,e)?On[e]=Nn[e]:On[e]=mn("Symbol."+e)),On[e]},Cn={},gn=fn("iterator"),vn=Array.prototype,Dn=function(e){return void 0!==e&&(Cn.Array===e||vn[gn]===e)},Ln=Math.ceil,Pn=Math.floor,Mn=function(e){return isNaN(e=+e)?0:(0a;a++)if((o=r?i(Ji(s=e[a])[0],s[1]):i(e[a]))&&o instanceof t)return o;return new t(!1)}e=a.call(e)}for(a=e.next;!(s=a.call(e)).done;)if("object"==typeof(o=xn(e,i,s.value,r))&&o&&o instanceof t)return o;return new t(!1)}).stop=function(e){return new t(!0,e)}})),Wn=function(e,t,i){if(!(e instanceof t))throw TypeError("Incorrect "+(i?i+" ":"")+"invocation");return e},Yn=wn?{}.toString:function(){return"[object "+Fn(this)+"]"},jn=qi.f,Kn=fn("toStringTag"),Xn=function(e,t,i,n){e&&(e=i?e:e.prototype,ki(e,Kn)||jn(e,Kn,{configurable:!0,value:t}),n&&!wn&&zi(e,"toString",Yn))},Jn=function(e){return Object(Di(e))},Qn=Array.isArray||function(e){return"Array"==Ci(e)},qn=fn("species"),zn=function(e,t){var i;return Qn(e)&&("function"!=typeof(i=e.constructor)||i!==Array&&!Qn(i.prototype)?Pi(i)&&null===(i=i[qn])&&(i=void 0):i=void 0),new(void 0===i?Array:i)(0===t?0:t)},Zn=[].push,$n=function(e){var t=1==e,i=2==e,n=3==e,r=4==e,a=6==e,o=5==e||a;return function(s,c,E,_){var d,l,u=Jn(s),h=vi(u);c=Xi(c,E,3),E=kn(h.length);var R=0;for(_=_||zn,s=t?_(s,E):i?_(s,0):void 0;E>R;R++)if((o||R in h)&&(l=c(d=h[R],R,u),e))if(t)s[R]=l;else if(l)switch(e){case 3:return!0;case 5:return d;case 6:return R;case 2:Zn.call(s,d)}else if(r)return!1;return a?-1:n||r?r:s}},er=$n(0),tr=$n(1),ir=$n(2),nr=$n(3);$n(4);var rr=$n(5),ar=$n(6),or=In("native-function-to-string",Function.toString),sr=Ai.WeakMap,cr="function"==typeof sr&&/native code/.test(or.call(sr)),Er=In("keys"),_r=function(e){return Er[e]||(Er[e]=hn(e))},dr=Ai.WeakMap;if(cr)var lr=new dr,ur=lr.get,hr=lr.has,Rr=lr.set,Tr=function(e,t){return Rr.call(lr,e,t),t},Ar=function(e){return ur.call(lr,e)||{}},Ir=function(e){return hr.call(lr,e)};else{var pr=_r("state");dn[pr]=!0,Tr=function(e,t){return zi(e,pr,t),t},Ar=function(e){return ki(e,pr)?e[pr]:{}},Ir=function(e){return ki(e,pr)}}var Sr={set:Tr,get:Ar,has:Ir,enforce:function(e){return Ir(e)?Ar(e):Tr(e,{})},getterFor:function(e){return function(t){var i;if(!Pi(t)||(i=Ar(t)).type!==e)throw TypeError("Incompatible receiver, "+e+" required");return i}}},Or=qi.f,Nr=Sr.set,mr=Sr.getterFor,fr=Math.max,Cr=Math.min,gr=function(e,t){return 0>(e=Mn(e))?fr(e+t,0):Cr(e,t)},vr=function(e){return function(t,i,n){var r;t=Li(t);var a=kn(t.length);if(n=gr(n,a),e&&i!=i){for(;a>n;)if((r=t[n++])!=r)return!0}else for(;a>n;n++)if((e||n in t)&&t[n]===i)return e||n||0;return!e&&-1}},Dr=vr(!0),Lr=vr(!1),Pr=function(e,t){var i;e=Li(e);var n=0,r=[];for(i in e)!ki(dn,i)&&ki(e,i)&&r.push(i);for(;t.length>n;)ki(e,i=t[n++])&&(~Lr(r,i)||r.push(i));return r},Mr="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),yr=Object.keys||function(e){return Pr(e,Mr)},kr=pi?Object.defineProperties:function(e,t){Ji(e);for(var i,n=yr(t),r=n.length,a=0;r>a;)qi.f(e,i=n[a++],t[i]);return e},Ur=nn("document","documentElement"),wr=_r("IE_PROTO"),br=function(){},Vr=function(){var e=wi?Ui.createElement("iframe"):{},t=Mr.length;for(e.style.display="none",Ur.appendChild(e),e.src="javascript:",(e=e.contentWindow.document).open(),e.write("