-
-
-
-
-
- `),document.getElementById("".concat(M.id,"-wrap")).appendChild(f),document.getElementById("".concat(this.jSPlugin.id,"-ez-ptz-container")).onmousedown=function(w){w.preventDefault(),console.log("触摸开始"),d._handlePtzTouch(w,"start")},document.getElementById("".concat(this.jSPlugin.id,"-ez-ptz-container")).onmouseup=function(w){w.preventDefault(),console.log("触摸结束"),d._handlePtzTouch(w,"stop")},document.getElementById("".concat(this.jSPlugin.id,"-ez-ptz-container")).ontouchstart=function(w){w.preventDefault(),console.log("触摸开始"),d._handlePtzTouch(w,"start")},document.getElementById("".concat(this.jSPlugin.id,"-ez-ptz-container")).ontouchend=function(w){w.preventDefault(),console.log("触摸结束",w),d._handlePtzTouch(w,"stop")}}return r(R,[{key:"show",value:function(){document.getElementById("".concat(this.jSPlugin.id,"-ez-ptz-item")).style="display: inline-block"}},{key:"hide",value:function(){document.getElementById("".concat(this.jSPlugin.id,"-ez-ptz-item")).style="display: none"}},{key:"_handlePtzTouch",value:function(d,f){var y=this,w=document.getElementById("".concat(this.jSPlugin.id,"-ez-ptz-container")).getBoundingClientRect(),_=w.left+41,E=w.top+41,r2=d.x||d.changedTouches[0].clientX,n2=d.y||d.changedTouches[0].clientY,o2=r2-_,t2=n2-E,X=0,R2=this.jSPlugin.env.domain+"/api/lapp/device/ptz/start";if(Math.abs(o2)>Math.abs(t2)?o2>0?X=3:X=2:t2>0?X=1:X=0,/^rotate\(90/.test(document.getElementById("".concat(this.jSPlugin.id,"-wrap")).style.transform))switch(X){case 0:X=2;break;case 1:X=3;break;case 2:X=1;break;case 3:X=0;break}document.getElementById("".concat(this.jSPlugin.id,"-ez-ptz-container")).style="background-image:linear-gradient(".concat(X===0?180:X===1?0:X===2?90:270,"deg, #1d8dd8 0%, rgba(100,143,252,0.00) 30%)"),f==="stop"&&(R2=this.jSPlugin.env.domain+"/api/lapp/device/ptz/stop",document.getElementById("".concat(this.jSPlugin.id,"-ez-ptz-container")).style="");var y2=new FormData;y2.append("deviceSerial",v2(this.jSPlugin.url).deviceSerial),y2.append("channelNo",v2(this.jSPlugin.url).channelNo),y2.append("speed",1),y2.append("direction",X),y2.append("accessToken",this.jSPlugin.accessToken),fetch(R2,{method:"POST",body:y2}).then(function(d2){return d2.json()}).then(function(d2){d2.code==200||(console.log(d2.code,y.codeHandler.matchInfo(d2.code,f==="start"?"ptzStart":"ptzStop")),y.pluginStatus.loadingSetText({text:y.codeHandler.matchInfo(d2.code,f==="start"?"ptzStart":"ptzStop").msg,color:"red",delayClear:2e3}),(d2.code==60005||d2.code==60002||d2.code==60003||d2.code==60004)&&(document.getElementById("".concat(y.jSPlugin.id,"-ez-ptz-container")).style="background-image:linear-gradient(".concat(X===0?180:X===1?0:X===2?90:270,"deg, #f45656 0%, rgba(100,143,252,0.00) 30%)")))}).catch(function(d2){console.log("云台调用异常",d2)})}}]),R}();(function(R){if(n(e)==="object")t.exports=R();else{var M;typeof window!="undefined"?M=window:typeof ai!="undefined"?M=ai:typeof self!="undefined"?M=self:M=this,M.adapter=R()}})(function(){return function(){function R(M,d,f){function y(E,r2){if(!d[E]){if(!M[E]){var n2=typeof ii=="function"&ⅈif(!r2&&n2)return n2(E,!0);if(w)return w(E,!0);var o2=new Error("Cannot find module '"+E+"'");throw o2.code="MODULE_NOT_FOUND",o2}var t2=d[E]={exports:{}};M[E][0].call(t2.exports,function(X){var R2=M[E][1][X];return y(R2||X)},t2,t2.exports,R,M,d,f)}return d[E].exports}for(var w=typeof ii=="function"&&ii,_=0;_
0&&arguments[0]!==void 0?arguments[0]:{},u2=B2.window,A=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{shimChrome:!0,shimFirefox:!0,shimEdge:!0,shimSafari:!0},V=y.log,Z=y.detectBrowser(u2),P2={browserDetails:Z,commonShim:y2,extractVersion:y.extractVersion,disableLog:y.disableLog,disableWarnings:y.disableWarnings};switch(Z.browser){case"chrome":if(!_||!_.shimPeerConnection||!A.shimChrome)return V("Chrome shim is not included in this adapter release."),P2;V("adapter.js shimming chrome."),P2.browserShim=_,_.shimGetUserMedia(u2),_.shimMediaStream(u2),_.shimPeerConnection(u2),_.shimOnTrack(u2),_.shimAddTrackRemoveTrack(u2),_.shimGetSendersWithDtmf(u2),_.shimGetStats(u2),_.shimSenderReceiverGetStats(u2),_.fixNegotiationNeeded(u2),y2.shimRTCIceCandidate(u2),y2.shimConnectionState(u2),y2.shimMaxMessageSize(u2),y2.shimSendThrowTypeError(u2),y2.removeAllowExtmapMixed(u2);break;case"firefox":if(!o2||!o2.shimPeerConnection||!A.shimFirefox)return V("Firefox shim is not included in this adapter release."),P2;V("adapter.js shimming firefox."),P2.browserShim=o2,o2.shimGetUserMedia(u2),o2.shimPeerConnection(u2),o2.shimOnTrack(u2),o2.shimRemoveStream(u2),o2.shimSenderGetStats(u2),o2.shimReceiverGetStats(u2),o2.shimRTCDataChannel(u2),o2.shimAddTransceiver(u2),o2.shimCreateOffer(u2),o2.shimCreateAnswer(u2),y2.shimRTCIceCandidate(u2),y2.shimConnectionState(u2),y2.shimMaxMessageSize(u2),y2.shimSendThrowTypeError(u2);break;case"edge":if(!r2||!r2.shimPeerConnection||!A.shimEdge)return V("MS edge shim is not included in this adapter release."),P2;V("adapter.js shimming edge."),P2.browserShim=r2,r2.shimGetUserMedia(u2),r2.shimGetDisplayMedia(u2),r2.shimPeerConnection(u2),r2.shimReplaceTrack(u2),y2.shimMaxMessageSize(u2),y2.shimSendThrowTypeError(u2);break;case"safari":if(!X||!A.shimSafari)return V("Safari shim is not included in this adapter release."),P2;V("adapter.js shimming safari."),P2.browserShim=X,X.shimRTCIceServerUrls(u2),X.shimCreateOfferLegacy(u2),X.shimCallbacksAPI(u2),X.shimLocalStreamsAPI(u2),X.shimRemoteStreamsAPI(u2),X.shimTrackEventTransceiver(u2),X.shimGetUserMedia(u2),y2.shimRTCIceCandidate(u2),y2.shimMaxMessageSize(u2),y2.shimSendThrowTypeError(u2),y2.removeAllowExtmapMixed(u2);break;default:V("Unsupported browser!");break}return P2}},{"./chrome/chrome_shim":3,"./common_shim":6,"./edge/edge_shim":7,"./firefox/firefox_shim":11,"./safari/safari_shim":14,"./utils":15}],3:[function(R,M,d){Object.defineProperty(d,"__esModule",{value:!0}),d.shimGetDisplayMedia=d.shimGetUserMedia=void 0;var f=typeof Symbol=="function"&&n(Symbol.iterator)==="symbol"?function(A){return n(A)}:function(A){return A&&typeof Symbol=="function"&&A.constructor===Symbol&&A!==Symbol.prototype?"symbol":n(A)},y=R("./getusermedia");Object.defineProperty(d,"shimGetUserMedia",{enumerable:!0,get:function(){return y.shimGetUserMedia}});var w=R("./getdisplaymedia");Object.defineProperty(d,"shimGetDisplayMedia",{enumerable:!0,get:function(){return w.shimGetDisplayMedia}}),d.shimMediaStream=o2,d.shimOnTrack=t2,d.shimGetSendersWithDtmf=X,d.shimGetStats=R2,d.shimSenderReceiverGetStats=y2,d.shimAddTrackRemoveTrackWithNative=d2,d.shimAddTrackRemoveTrack=h2,d.shimPeerConnection=B2,d.fixNegotiationNeeded=u2;var _=R("../utils.js"),E=r2(_);function r2(A){if(A&&A.__esModule)return A;var V={};if(A!=null)for(var Z in A)Object.prototype.hasOwnProperty.call(A,Z)&&(V[Z]=A[Z]);return V.default=A,V}function n2(A,V,Z){return V in A?Object.defineProperty(A,V,{value:Z,enumerable:!0,configurable:!0,writable:!0}):A[V]=Z,A}function o2(A){A.MediaStream=A.MediaStream||A.webkitMediaStream}function t2(A){if((typeof A=="undefined"?"undefined":f(A))==="object"&&A.RTCPeerConnection&&!("ontrack"in A.RTCPeerConnection.prototype)){Object.defineProperty(A.RTCPeerConnection.prototype,"ontrack",{get:function(){return this._ontrack},set:function(P2){this._ontrack&&this.removeEventListener("track",this._ontrack),this.addEventListener("track",this._ontrack=P2)},enumerable:!0,configurable:!0});var V=A.RTCPeerConnection.prototype.setRemoteDescription;A.RTCPeerConnection.prototype.setRemoteDescription=function(){var P2=this;return this._ontrackpoly||(this._ontrackpoly=function(I2){I2.stream.addEventListener("addtrack",function(W2){var V2=void 0;A.RTCPeerConnection.prototype.getReceivers?V2=P2.getReceivers().find(function(x3){return x3.track&&x3.track.id===W2.track.id}):V2={track:W2.track};var l3=new Event("track");l3.track=W2.track,l3.receiver=V2,l3.transceiver={receiver:V2},l3.streams=[I2.stream],P2.dispatchEvent(l3)}),I2.stream.getTracks().forEach(function(W2){var V2=void 0;A.RTCPeerConnection.prototype.getReceivers?V2=P2.getReceivers().find(function(x3){return x3.track&&x3.track.id===W2.id}):V2={track:W2};var l3=new Event("track");l3.track=W2,l3.receiver=V2,l3.transceiver={receiver:V2},l3.streams=[I2.stream],P2.dispatchEvent(l3)})},this.addEventListener("addstream",this._ontrackpoly)),V.apply(this,arguments)}}else E.wrapPeerConnectionEvent(A,"track",function(Z){return Z.transceiver||Object.defineProperty(Z,"transceiver",{value:{receiver:Z.receiver}}),Z})}function X(A){if((typeof A=="undefined"?"undefined":f(A))==="object"&&A.RTCPeerConnection&&!("getSenders"in A.RTCPeerConnection.prototype)&&"createDTMFSender"in A.RTCPeerConnection.prototype){var V=function(x3,E3){return{track:E3,get dtmf(){return this._dtmf===void 0&&(E3.kind==="audio"?this._dtmf=x3.createDTMFSender(E3):this._dtmf=null),this._dtmf},_pc:x3}};if(!A.RTCPeerConnection.prototype.getSenders){A.RTCPeerConnection.prototype.getSenders=function(){return this._senders=this._senders||[],this._senders.slice()};var Z=A.RTCPeerConnection.prototype.addTrack;A.RTCPeerConnection.prototype.addTrack=function(x3,E3){var T3=Z.apply(this,arguments);return T3||(T3=V(this,x3),this._senders.push(T3)),T3};var P2=A.RTCPeerConnection.prototype.removeTrack;A.RTCPeerConnection.prototype.removeTrack=function(x3){P2.apply(this,arguments);var E3=this._senders.indexOf(x3);E3!==-1&&this._senders.splice(E3,1)}}var I2=A.RTCPeerConnection.prototype.addStream;A.RTCPeerConnection.prototype.addStream=function(x3){var E3=this;this._senders=this._senders||[],I2.apply(this,[x3]),x3.getTracks().forEach(function(T3){E3._senders.push(V(E3,T3))})};var W2=A.RTCPeerConnection.prototype.removeStream;A.RTCPeerConnection.prototype.removeStream=function(x3){var E3=this;this._senders=this._senders||[],W2.apply(this,[x3]),x3.getTracks().forEach(function(T3){var m1=E3._senders.find(function(T1){return T1.track===T3});m1&&E3._senders.splice(E3._senders.indexOf(m1),1)})}}else if((typeof A=="undefined"?"undefined":f(A))==="object"&&A.RTCPeerConnection&&"getSenders"in A.RTCPeerConnection.prototype&&"createDTMFSender"in A.RTCPeerConnection.prototype&&A.RTCRtpSender&&!("dtmf"in A.RTCRtpSender.prototype)){var V2=A.RTCPeerConnection.prototype.getSenders;A.RTCPeerConnection.prototype.getSenders=function(){var x3=this,E3=V2.apply(this,[]);return E3.forEach(function(T3){return T3._pc=x3}),E3},Object.defineProperty(A.RTCRtpSender.prototype,"dtmf",{get:function(){return this._dtmf===void 0&&(this.track.kind==="audio"?this._dtmf=this._pc.createDTMFSender(this.track):this._dtmf=null),this._dtmf}})}}function R2(A){if(A.RTCPeerConnection){var V=A.RTCPeerConnection.prototype.getStats;A.RTCPeerConnection.prototype.getStats=function(){var P2=this,I2=Array.prototype.slice.call(arguments),W2=I2[0],V2=I2[1],l3=I2[2];if(arguments.length>0&&typeof W2=="function")return V.apply(this,arguments);if(V.length===0&&(arguments.length===0||typeof W2!="function"))return V.apply(this,[]);var x3=function(T1){var x1={},B1=T1.result();return B1.forEach(function(v1){var Y1={id:v1.id,timestamp:v1.timestamp,type:{localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[v1.type]||v1.type};v1.names().forEach(function(g0){Y1[g0]=v1.stat(g0)}),x1[Y1.id]=Y1}),x1},E3=function(T1){return new Map(Object.keys(T1).map(function(x1){return[x1,T1[x1]]}))};if(arguments.length>=2){var T3=function(T1){V2(E3(x3(T1)))};return V.apply(this,[T3,W2])}return new Promise(function(m1,T1){V.apply(P2,[function(x1){m1(E3(x3(x1)))},T1])}).then(V2,l3)}}}function y2(A){if((typeof A=="undefined"?"undefined":f(A))==="object"&&A.RTCPeerConnection&&A.RTCRtpSender&&A.RTCRtpReceiver){if(!("getStats"in A.RTCRtpSender.prototype)){var V=A.RTCPeerConnection.prototype.getSenders;V&&(A.RTCPeerConnection.prototype.getSenders=function(){var V2=this,l3=V.apply(this,[]);return l3.forEach(function(x3){return x3._pc=V2}),l3});var Z=A.RTCPeerConnection.prototype.addTrack;Z&&(A.RTCPeerConnection.prototype.addTrack=function(){var V2=Z.apply(this,arguments);return V2._pc=this,V2}),A.RTCRtpSender.prototype.getStats=function(){var V2=this;return this._pc.getStats().then(function(l3){return E.filterStats(l3,V2.track,!0)})}}if(!("getStats"in A.RTCRtpReceiver.prototype)){var P2=A.RTCPeerConnection.prototype.getReceivers;P2&&(A.RTCPeerConnection.prototype.getReceivers=function(){var V2=this,l3=P2.apply(this,[]);return l3.forEach(function(x3){return x3._pc=V2}),l3}),E.wrapPeerConnectionEvent(A,"track",function(W2){return W2.receiver._pc=W2.srcElement,W2}),A.RTCRtpReceiver.prototype.getStats=function(){var V2=this;return this._pc.getStats().then(function(l3){return E.filterStats(l3,V2.track,!1)})}}if("getStats"in A.RTCRtpSender.prototype&&"getStats"in A.RTCRtpReceiver.prototype){var I2=A.RTCPeerConnection.prototype.getStats;A.RTCPeerConnection.prototype.getStats=function(){if(arguments.length>0&&arguments[0]instanceof A.MediaStreamTrack){var V2=arguments[0],l3=void 0,x3=void 0,E3=void 0;return this.getSenders().forEach(function(T3){T3.track===V2&&(l3?E3=!0:l3=T3)}),this.getReceivers().forEach(function(T3){return T3.track===V2&&(x3?E3=!0:x3=T3),T3.track===V2}),E3||l3&&x3?Promise.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):l3?l3.getStats():x3?x3.getStats():Promise.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return I2.apply(this,arguments)}}}}function d2(A){A.RTCPeerConnection.prototype.getLocalStreams=function(){var V2=this;return this._shimmedLocalStreams=this._shimmedLocalStreams||{},Object.keys(this._shimmedLocalStreams).map(function(l3){return V2._shimmedLocalStreams[l3][0]})};var V=A.RTCPeerConnection.prototype.addTrack;A.RTCPeerConnection.prototype.addTrack=function(V2,l3){if(!l3)return V.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};var x3=V.apply(this,arguments);return this._shimmedLocalStreams[l3.id]?this._shimmedLocalStreams[l3.id].indexOf(x3)===-1&&this._shimmedLocalStreams[l3.id].push(x3):this._shimmedLocalStreams[l3.id]=[l3,x3],x3};var Z=A.RTCPeerConnection.prototype.addStream;A.RTCPeerConnection.prototype.addStream=function(V2){var l3=this;this._shimmedLocalStreams=this._shimmedLocalStreams||{},V2.getTracks().forEach(function(T3){var m1=l3.getSenders().find(function(T1){return T1.track===T3});if(m1)throw new DOMException("Track already exists.","InvalidAccessError")});var x3=this.getSenders();Z.apply(this,arguments);var E3=this.getSenders().filter(function(T3){return x3.indexOf(T3)===-1});this._shimmedLocalStreams[V2.id]=[V2].concat(E3)};var P2=A.RTCPeerConnection.prototype.removeStream;A.RTCPeerConnection.prototype.removeStream=function(V2){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},delete this._shimmedLocalStreams[V2.id],P2.apply(this,arguments)};var I2=A.RTCPeerConnection.prototype.removeTrack;A.RTCPeerConnection.prototype.removeTrack=function(V2){var l3=this;return this._shimmedLocalStreams=this._shimmedLocalStreams||{},V2&&Object.keys(this._shimmedLocalStreams).forEach(function(x3){var E3=l3._shimmedLocalStreams[x3].indexOf(V2);E3!==-1&&l3._shimmedLocalStreams[x3].splice(E3,1),l3._shimmedLocalStreams[x3].length===1&&delete l3._shimmedLocalStreams[x3]}),I2.apply(this,arguments)}}function h2(A){if(!A.RTCPeerConnection)return;var V=E.detectBrowser(A);if(A.RTCPeerConnection.prototype.addTrack&&V.version>=65)return d2(A);var Z=A.RTCPeerConnection.prototype.getLocalStreams;A.RTCPeerConnection.prototype.getLocalStreams=function(){var T3=this,m1=Z.apply(this);return this._reverseStreams=this._reverseStreams||{},m1.map(function(T1){return T3._reverseStreams[T1.id]})};var P2=A.RTCPeerConnection.prototype.addStream;A.RTCPeerConnection.prototype.addStream=function(T3){var m1=this;if(this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},T3.getTracks().forEach(function(x1){var B1=m1.getSenders().find(function(v1){return v1.track===x1});if(B1)throw new DOMException("Track already exists.","InvalidAccessError")}),!this._reverseStreams[T3.id]){var T1=new A.MediaStream(T3.getTracks());this._streams[T3.id]=T1,this._reverseStreams[T1.id]=T3,T3=T1}P2.apply(this,[T3])};var I2=A.RTCPeerConnection.prototype.removeStream;A.RTCPeerConnection.prototype.removeStream=function(T3){this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},I2.apply(this,[this._streams[T3.id]||T3]),delete this._reverseStreams[this._streams[T3.id]?this._streams[T3.id].id:T3.id],delete this._streams[T3.id]},A.RTCPeerConnection.prototype.addTrack=function(T3,m1){var T1=this;if(this.signalingState==="closed")throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");var x1=[].slice.call(arguments,1);if(x1.length!==1||!x1[0].getTracks().find(function(g0){return g0===T3}))throw new DOMException("The adapter.js addTrack polyfill only supports a single stream which is associated with the specified track.","NotSupportedError");var B1=this.getSenders().find(function(g0){return g0.track===T3});if(B1)throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};var v1=this._streams[m1.id];if(v1)v1.addTrack(T3),Promise.resolve().then(function(){T1.dispatchEvent(new Event("negotiationneeded"))});else{var Y1=new A.MediaStream([T3]);this._streams[m1.id]=Y1,this._reverseStreams[Y1.id]=m1,this.addStream(Y1)}return this.getSenders().find(function(g0){return g0.track===T3})};function W2(E3,T3){var m1=T3.sdp;return Object.keys(E3._reverseStreams||[]).forEach(function(T1){var x1=E3._reverseStreams[T1],B1=E3._streams[x1.id];m1=m1.replace(new RegExp(B1.id,"g"),x1.id)}),new RTCSessionDescription({type:T3.type,sdp:m1})}function V2(E3,T3){var m1=T3.sdp;return Object.keys(E3._reverseStreams||[]).forEach(function(T1){var x1=E3._reverseStreams[T1],B1=E3._streams[x1.id];m1=m1.replace(new RegExp(x1.id,"g"),B1.id)}),new RTCSessionDescription({type:T3.type,sdp:m1})}["createOffer","createAnswer"].forEach(function(E3){var T3=A.RTCPeerConnection.prototype[E3],m1=n2({},E3,function(){var T1=this,x1=arguments,B1=arguments.length&&typeof arguments[0]=="function";return B1?T3.apply(this,[function(v1){var Y1=W2(T1,v1);x1[0].apply(null,[Y1])},function(v1){x1[1]&&x1[1].apply(null,v1)},arguments[2]]):T3.apply(this,arguments).then(function(v1){return W2(T1,v1)})});A.RTCPeerConnection.prototype[E3]=m1[E3]});var l3=A.RTCPeerConnection.prototype.setLocalDescription;A.RTCPeerConnection.prototype.setLocalDescription=function(){return!arguments.length||!arguments[0].type?l3.apply(this,arguments):(arguments[0]=V2(this,arguments[0]),l3.apply(this,arguments))};var x3=Object.getOwnPropertyDescriptor(A.RTCPeerConnection.prototype,"localDescription");Object.defineProperty(A.RTCPeerConnection.prototype,"localDescription",{get:function(){var T3=x3.get.apply(this);return T3.type===""?T3:W2(this,T3)}}),A.RTCPeerConnection.prototype.removeTrack=function(T3){var m1=this;if(this.signalingState==="closed")throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");if(!T3._pc)throw new DOMException("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.","TypeError");var T1=T3._pc===this;if(!T1)throw new DOMException("Sender was not created by this connection.","InvalidAccessError");this._streams=this._streams||{};var x1=void 0;Object.keys(this._streams).forEach(function(B1){var v1=m1._streams[B1].getTracks().find(function(Y1){return T3.track===Y1});v1&&(x1=m1._streams[B1])}),x1&&(x1.getTracks().length===1?this.removeStream(this._reverseStreams[x1.id]):x1.removeTrack(T3.track),this.dispatchEvent(new Event("negotiationneeded")))}}function B2(A){var V=E.detectBrowser(A);if(!A.RTCPeerConnection&&A.webkitRTCPeerConnection&&(A.RTCPeerConnection=A.webkitRTCPeerConnection),!!A.RTCPeerConnection){V.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(P2){var I2=A.RTCPeerConnection.prototype[P2],W2=n2({},P2,function(){return arguments[0]=new(P2==="addIceCandidate"?A.RTCIceCandidate:A.RTCSessionDescription)(arguments[0]),I2.apply(this,arguments)});A.RTCPeerConnection.prototype[P2]=W2[P2]});var Z=A.RTCPeerConnection.prototype.addIceCandidate;A.RTCPeerConnection.prototype.addIceCandidate=function(){return arguments[0]?V.version<78&&arguments[0]&&arguments[0].candidate===""?Promise.resolve():Z.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())}}}function u2(A){E.wrapPeerConnectionEvent(A,"negotiationneeded",function(V){var Z=V.target;if(Z.signalingState==="stable")return V})}},{"../utils.js":15,"./getdisplaymedia":4,"./getusermedia":5}],4:[function(R,M,d){Object.defineProperty(d,"__esModule",{value:!0}),d.shimGetDisplayMedia=f;function f(y,w){if(!(y.navigator.mediaDevices&&"getDisplayMedia"in y.navigator.mediaDevices)&&y.navigator.mediaDevices){if(typeof w!="function"){console.error("shimGetDisplayMedia: getSourceId argument is not a function");return}y.navigator.mediaDevices.getDisplayMedia=function(E){return w(E).then(function(r2){var n2=E.video&&E.video.width,o2=E.video&&E.video.height,t2=E.video&&E.video.frameRate;return E.video={mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:r2,maxFrameRate:t2||3}},n2&&(E.video.mandatory.maxWidth=n2),o2&&(E.video.mandatory.maxHeight=o2),y.navigator.mediaDevices.getUserMedia(E)})}}}},{}],5:[function(R,M,d){Object.defineProperty(d,"__esModule",{value:!0});var f=typeof Symbol=="function"&&n(Symbol.iterator)==="symbol"?function(n2){return n(n2)}:function(n2){return n2&&typeof Symbol=="function"&&n2.constructor===Symbol&&n2!==Symbol.prototype?"symbol":n(n2)};d.shimGetUserMedia=r2;var y=R("../utils.js"),w=_(y);function _(n2){if(n2&&n2.__esModule)return n2;var o2={};if(n2!=null)for(var t2 in n2)Object.prototype.hasOwnProperty.call(n2,t2)&&(o2[t2]=n2[t2]);return o2.default=n2,o2}var E=w.log;function r2(n2){var o2=n2&&n2.navigator;if(o2.mediaDevices){var t2=w.detectBrowser(n2),X=function(u2){if((typeof u2=="undefined"?"undefined":f(u2))!=="object"||u2.mandatory||u2.optional)return u2;var A={};return Object.keys(u2).forEach(function(V){if(!(V==="require"||V==="advanced"||V==="mediaSource")){var Z=f(u2[V])==="object"?u2[V]:{ideal:u2[V]};Z.exact!==void 0&&typeof Z.exact=="number"&&(Z.min=Z.max=Z.exact);var P2=function(V2,l3){return V2?V2+l3.charAt(0).toUpperCase()+l3.slice(1):l3==="deviceId"?"sourceId":l3};if(Z.ideal!==void 0){A.optional=A.optional||[];var I2={};typeof Z.ideal=="number"?(I2[P2("min",V)]=Z.ideal,A.optional.push(I2),I2={},I2[P2("max",V)]=Z.ideal,A.optional.push(I2)):(I2[P2("",V)]=Z.ideal,A.optional.push(I2))}Z.exact!==void 0&&typeof Z.exact!="number"?(A.mandatory=A.mandatory||{},A.mandatory[P2("",V)]=Z.exact):["min","max"].forEach(function(W2){Z[W2]!==void 0&&(A.mandatory=A.mandatory||{},A.mandatory[P2(W2,V)]=Z[W2])})}}),u2.advanced&&(A.optional=(A.optional||[]).concat(u2.advanced)),A},R2=function(u2,A){if(t2.version>=61)return A(u2);if(u2=JSON.parse(JSON.stringify(u2)),u2&&f(u2.audio)==="object"){var V=function(V2,l3,x3){l3 in V2&&!(x3 in V2)&&(V2[x3]=V2[l3],delete V2[l3])};u2=JSON.parse(JSON.stringify(u2)),V(u2.audio,"autoGainControl","googAutoGainControl"),V(u2.audio,"noiseSuppression","googNoiseSuppression"),u2.audio=X(u2.audio)}if(u2&&f(u2.video)==="object"){var Z=u2.video.facingMode;Z=Z&&((typeof Z=="undefined"?"undefined":f(Z))==="object"?Z:{ideal:Z});var P2=t2.version<66;if(Z&&(Z.exact==="user"||Z.exact==="environment"||Z.ideal==="user"||Z.ideal==="environment")&&!(o2.mediaDevices.getSupportedConstraints&&o2.mediaDevices.getSupportedConstraints().facingMode&&!P2)){delete u2.video.facingMode;var I2=void 0;if(Z.exact==="environment"||Z.ideal==="environment"?I2=["back","rear"]:(Z.exact==="user"||Z.ideal==="user")&&(I2=["front"]),I2)return o2.mediaDevices.enumerateDevices().then(function(W2){W2=W2.filter(function(l3){return l3.kind==="videoinput"});var V2=W2.find(function(l3){return I2.some(function(x3){return l3.label.toLowerCase().includes(x3)})});return!V2&&W2.length&&I2.includes("back")&&(V2=W2[W2.length-1]),V2&&(u2.video.deviceId=Z.exact?{exact:V2.deviceId}:{ideal:V2.deviceId}),u2.video=X(u2.video),E("chrome: "+JSON.stringify(u2)),A(u2)})}u2.video=X(u2.video)}return E("chrome: "+JSON.stringify(u2)),A(u2)},y2=function(u2){return t2.version>=64?u2:{name:{PermissionDeniedError:"NotAllowedError",PermissionDismissedError:"NotAllowedError",InvalidStateError:"NotAllowedError",DevicesNotFoundError:"NotFoundError",ConstraintNotSatisfiedError:"OverconstrainedError",TrackStartError:"NotReadableError",MediaDeviceFailedDueToShutdown:"NotAllowedError",MediaDeviceKillSwitchOn:"NotAllowedError",TabCaptureError:"AbortError",ScreenCaptureError:"AbortError",DeviceCaptureError:"AbortError"}[u2.name]||u2.name,message:u2.message,constraint:u2.constraint||u2.constraintName,toString:function(){return this.name+(this.message&&": ")+this.message}}},d2=function(u2,A,V){R2(u2,function(Z){o2.webkitGetUserMedia(Z,A,function(P2){V&&V(y2(P2))})})};if(o2.getUserMedia=d2.bind(o2),o2.mediaDevices.getUserMedia){var h2=o2.mediaDevices.getUserMedia.bind(o2.mediaDevices);o2.mediaDevices.getUserMedia=function(B2){return R2(B2,function(u2){return h2(u2).then(function(A){if(u2.audio&&!A.getAudioTracks().length||u2.video&&!A.getVideoTracks().length)throw A.getTracks().forEach(function(V){V.stop()}),new DOMException("","NotFoundError");return A},function(A){return Promise.reject(y2(A))})})}}}}},{"../utils.js":15}],6:[function(R,M,d){Object.defineProperty(d,"__esModule",{value:!0});var f=typeof Symbol=="function"&&n(Symbol.iterator)==="symbol"?function(d2){return n(d2)}:function(d2){return d2&&typeof Symbol=="function"&&d2.constructor===Symbol&&d2!==Symbol.prototype?"symbol":n(d2)};d.shimRTCIceCandidate=o2,d.shimMaxMessageSize=t2,d.shimSendThrowTypeError=X,d.shimConnectionState=R2,d.removeAllowExtmapMixed=y2;var y=R("sdp"),w=n2(y),_=R("./utils"),E=r2(_);function r2(d2){if(d2&&d2.__esModule)return d2;var h2={};if(d2!=null)for(var B2 in d2)Object.prototype.hasOwnProperty.call(d2,B2)&&(h2[B2]=d2[B2]);return h2.default=d2,h2}function n2(d2){return d2&&d2.__esModule?d2:{default:d2}}function o2(d2){if(!(!d2.RTCIceCandidate||d2.RTCIceCandidate&&"foundation"in d2.RTCIceCandidate.prototype)){var h2=d2.RTCIceCandidate;d2.RTCIceCandidate=function(u2){if((typeof u2=="undefined"?"undefined":f(u2))==="object"&&u2.candidate&&u2.candidate.indexOf("a=")===0&&(u2=JSON.parse(JSON.stringify(u2)),u2.candidate=u2.candidate.substr(2)),u2.candidate&&u2.candidate.length){var A=new h2(u2),V=w.default.parseCandidate(u2.candidate),Z=Object.assign(A,V);return Z.toJSON=function(){return{candidate:Z.candidate,sdpMid:Z.sdpMid,sdpMLineIndex:Z.sdpMLineIndex,usernameFragment:Z.usernameFragment}},Z}return new h2(u2)},d2.RTCIceCandidate.prototype=h2.prototype,E.wrapPeerConnectionEvent(d2,"icecandidate",function(B2){return B2.candidate&&Object.defineProperty(B2,"candidate",{value:new d2.RTCIceCandidate(B2.candidate),writable:"false"}),B2})}}function t2(d2){if(d2.RTCPeerConnection){var h2=E.detectBrowser(d2);"sctp"in d2.RTCPeerConnection.prototype||Object.defineProperty(d2.RTCPeerConnection.prototype,"sctp",{get:function(){return typeof this._sctp=="undefined"?null:this._sctp}});var B2=function(I2){if(!I2||!I2.sdp)return!1;var W2=w.default.splitSections(I2.sdp);return W2.shift(),W2.some(function(V2){var l3=w.default.parseMLine(V2);return l3&&l3.kind==="application"&&l3.protocol.indexOf("SCTP")!==-1})},u2=function(I2){var W2=I2.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);if(W2===null||W2.length<2)return-1;var V2=parseInt(W2[1],10);return V2!==V2?-1:V2},A=function(I2){var W2=65536;return h2.browser==="firefox"&&(h2.version<57?I2===-1?W2=16384:W2=2147483637:h2.version<60?W2=h2.version===57?65535:65536:W2=2147483637),W2},V=function(I2,W2){var V2=65536;h2.browser==="firefox"&&h2.version===57&&(V2=65535);var l3=w.default.matchPrefix(I2.sdp,"a=max-message-size:");return l3.length>0?V2=parseInt(l3[0].substr(19),10):h2.browser==="firefox"&&W2!==-1&&(V2=2147483637),V2},Z=d2.RTCPeerConnection.prototype.setRemoteDescription;d2.RTCPeerConnection.prototype.setRemoteDescription=function(){if(this._sctp=null,h2.browser==="chrome"&&h2.version>=76){var I2=this.getConfiguration(),W2=I2.sdpSemantics;W2==="plan-b"&&Object.defineProperty(this,"sctp",{get:function(){return typeof this._sctp=="undefined"?null:this._sctp},enumerable:!0,configurable:!0})}if(B2(arguments[0])){var V2=u2(arguments[0]),l3=A(V2),x3=V(arguments[0],V2),E3=void 0;l3===0&&x3===0?E3=Number.POSITIVE_INFINITY:l3===0||x3===0?E3=Math.max(l3,x3):E3=Math.min(l3,x3);var T3={};Object.defineProperty(T3,"maxMessageSize",{get:function(){return E3}}),this._sctp=T3}return Z.apply(this,arguments)}}}function X(d2){if(!(d2.RTCPeerConnection&&"createDataChannel"in d2.RTCPeerConnection.prototype))return;function h2(u2,A){var V=u2.send;u2.send=function(){var P2=arguments[0],I2=P2.length||P2.size||P2.byteLength;if(u2.readyState==="open"&&A.sctp&&I2>A.sctp.maxMessageSize)throw new TypeError("Message too large (can send a maximum of "+A.sctp.maxMessageSize+" bytes)");return V.apply(u2,arguments)}}var B2=d2.RTCPeerConnection.prototype.createDataChannel;d2.RTCPeerConnection.prototype.createDataChannel=function(){var A=B2.apply(this,arguments);return h2(A,this),A},E.wrapPeerConnectionEvent(d2,"datachannel",function(u2){return h2(u2.channel,u2.target),u2})}function R2(d2){if(!(!d2.RTCPeerConnection||"connectionState"in d2.RTCPeerConnection.prototype)){var h2=d2.RTCPeerConnection.prototype;Object.defineProperty(h2,"connectionState",{get:function(){return{completed:"connected",checking:"connecting"}[this.iceConnectionState]||this.iceConnectionState},enumerable:!0,configurable:!0}),Object.defineProperty(h2,"onconnectionstatechange",{get:function(){return this._onconnectionstatechange||null},set:function(u2){this._onconnectionstatechange&&(this.removeEventListener("connectionstatechange",this._onconnectionstatechange),delete this._onconnectionstatechange),u2&&this.addEventListener("connectionstatechange",this._onconnectionstatechange=u2)},enumerable:!0,configurable:!0}),["setLocalDescription","setRemoteDescription"].forEach(function(B2){var u2=h2[B2];h2[B2]=function(){return this._connectionstatechangepoly||(this._connectionstatechangepoly=function(A){var V=A.target;if(V._lastConnectionState!==V.connectionState){V._lastConnectionState=V.connectionState;var Z=new Event("connectionstatechange",A);V.dispatchEvent(Z)}return A},this.addEventListener("iceconnectionstatechange",this._connectionstatechangepoly)),u2.apply(this,arguments)}})}}function y2(d2){if(d2.RTCPeerConnection){var h2=E.detectBrowser(d2);if(!(h2.browser==="chrome"&&h2.version>=71)){var B2=d2.RTCPeerConnection.prototype.setRemoteDescription;d2.RTCPeerConnection.prototype.setRemoteDescription=function(A){return A&&A.sdp&&A.sdp.indexOf(`
-a=extmap-allow-mixed`)!==-1&&(A.sdp=A.sdp.split(`
-`).filter(function(V){return V.trim()!=="a=extmap-allow-mixed"}).join(`
-`)),B2.apply(this,arguments)}}}}},{"./utils":15,sdp:17}],7:[function(R,M,d){Object.defineProperty(d,"__esModule",{value:!0}),d.shimGetDisplayMedia=d.shimGetUserMedia=void 0;var f=R("./getusermedia");Object.defineProperty(d,"shimGetUserMedia",{enumerable:!0,get:function(){return f.shimGetUserMedia}});var y=R("./getdisplaymedia");Object.defineProperty(d,"shimGetDisplayMedia",{enumerable:!0,get:function(){return y.shimGetDisplayMedia}}),d.shimPeerConnection=X,d.shimReplaceTrack=R2;var w=R("../utils"),_=t2(w),E=R("./filtericeservers"),r2=R("rtcpeerconnection-shim"),n2=o2(r2);function o2(y2){return y2&&y2.__esModule?y2:{default:y2}}function t2(y2){if(y2&&y2.__esModule)return y2;var d2={};if(y2!=null)for(var h2 in y2)Object.prototype.hasOwnProperty.call(y2,h2)&&(d2[h2]=y2[h2]);return d2.default=y2,d2}function X(y2){var d2=_.detectBrowser(y2);if(y2.RTCIceGatherer&&(y2.RTCIceCandidate||(y2.RTCIceCandidate=function(A){return A}),y2.RTCSessionDescription||(y2.RTCSessionDescription=function(A){return A}),d2.version<15025)){var h2=Object.getOwnPropertyDescriptor(y2.MediaStreamTrack.prototype,"enabled");Object.defineProperty(y2.MediaStreamTrack.prototype,"enabled",{set:function(A){h2.set.call(this,A);var V=new Event("enabled");V.enabled=A,this.dispatchEvent(V)}})}y2.RTCRtpSender&&!("dtmf"in y2.RTCRtpSender.prototype)&&Object.defineProperty(y2.RTCRtpSender.prototype,"dtmf",{get:function(){return this._dtmf===void 0&&(this.track.kind==="audio"?this._dtmf=new y2.RTCDtmfSender(this):this.track.kind==="video"&&(this._dtmf=null)),this._dtmf}}),y2.RTCDtmfSender&&!y2.RTCDTMFSender&&(y2.RTCDTMFSender=y2.RTCDtmfSender);var B2=(0,n2.default)(y2,d2.version);y2.RTCPeerConnection=function(A){return A&&A.iceServers&&(A.iceServers=(0,E.filterIceServers)(A.iceServers,d2.version),_.log("ICE servers after filtering:",A.iceServers)),new B2(A)},y2.RTCPeerConnection.prototype=B2.prototype}function R2(y2){y2.RTCRtpSender&&!("replaceTrack"in y2.RTCRtpSender.prototype)&&(y2.RTCRtpSender.prototype.replaceTrack=y2.RTCRtpSender.prototype.setTrack)}},{"../utils":15,"./filtericeservers":8,"./getdisplaymedia":9,"./getusermedia":10,"rtcpeerconnection-shim":16}],8:[function(R,M,d){Object.defineProperty(d,"__esModule",{value:!0}),d.filterIceServers=_;var f=R("../utils"),y=w(f);function w(E){if(E&&E.__esModule)return E;var r2={};if(E!=null)for(var n2 in E)Object.prototype.hasOwnProperty.call(E,n2)&&(r2[n2]=E[n2]);return r2.default=E,r2}function _(E,r2){var n2=!1;return E=JSON.parse(JSON.stringify(E)),E.filter(function(o2){if(o2&&(o2.urls||o2.url)){var t2=o2.urls||o2.url;o2.url&&!o2.urls&&y.deprecated("RTCIceServer.url","RTCIceServer.urls");var X=typeof t2=="string";return X&&(t2=[t2]),t2=t2.filter(function(R2){if(R2.indexOf("stun:")===0)return!1;var y2=R2.startsWith("turn")&&!R2.startsWith("turn:[")&&R2.includes("transport=udp");return y2&&!n2?(n2=!0,!0):y2&&!n2}),delete o2.url,o2.urls=X?t2[0]:t2,!!t2.length}})}},{"../utils":15}],9:[function(R,M,d){Object.defineProperty(d,"__esModule",{value:!0}),d.shimGetDisplayMedia=f;function f(y){"getDisplayMedia"in y.navigator&&y.navigator.mediaDevices&&(y.navigator.mediaDevices&&"getDisplayMedia"in y.navigator.mediaDevices||(y.navigator.mediaDevices.getDisplayMedia=y.navigator.getDisplayMedia.bind(y.navigator)))}},{}],10:[function(R,M,d){Object.defineProperty(d,"__esModule",{value:!0}),d.shimGetUserMedia=f;function f(y){var w=y&&y.navigator,_=function(n2){return{name:{PermissionDeniedError:"NotAllowedError"}[n2.name]||n2.name,message:n2.message,constraint:n2.constraint,toString:function(){return this.name}}},E=w.mediaDevices.getUserMedia.bind(w.mediaDevices);w.mediaDevices.getUserMedia=function(r2){return E(r2).catch(function(n2){return Promise.reject(_(n2))})}}},{}],11:[function(R,M,d){Object.defineProperty(d,"__esModule",{value:!0}),d.shimGetDisplayMedia=d.shimGetUserMedia=void 0;var f=typeof Symbol=="function"&&n(Symbol.iterator)==="symbol"?function(A){return n(A)}:function(A){return A&&typeof Symbol=="function"&&A.constructor===Symbol&&A!==Symbol.prototype?"symbol":n(A)},y=R("./getusermedia");Object.defineProperty(d,"shimGetUserMedia",{enumerable:!0,get:function(){return y.shimGetUserMedia}});var w=R("./getdisplaymedia");Object.defineProperty(d,"shimGetDisplayMedia",{enumerable:!0,get:function(){return w.shimGetDisplayMedia}}),d.shimOnTrack=o2,d.shimPeerConnection=t2,d.shimSenderGetStats=X,d.shimReceiverGetStats=R2,d.shimRemoveStream=y2,d.shimRTCDataChannel=d2,d.shimAddTransceiver=h2,d.shimCreateOffer=B2,d.shimCreateAnswer=u2;var _=R("../utils"),E=r2(_);function r2(A){if(A&&A.__esModule)return A;var V={};if(A!=null)for(var Z in A)Object.prototype.hasOwnProperty.call(A,Z)&&(V[Z]=A[Z]);return V.default=A,V}function n2(A,V,Z){return V in A?Object.defineProperty(A,V,{value:Z,enumerable:!0,configurable:!0,writable:!0}):A[V]=Z,A}function o2(A){(typeof A=="undefined"?"undefined":f(A))==="object"&&A.RTCTrackEvent&&"receiver"in A.RTCTrackEvent.prototype&&!("transceiver"in A.RTCTrackEvent.prototype)&&Object.defineProperty(A.RTCTrackEvent.prototype,"transceiver",{get:function(){return{receiver:this.receiver}}})}function t2(A){var V=E.detectBrowser(A);if(!((typeof A=="undefined"?"undefined":f(A))!=="object"||!(A.RTCPeerConnection||A.mozRTCPeerConnection))){if(!A.RTCPeerConnection&&A.mozRTCPeerConnection&&(A.RTCPeerConnection=A.mozRTCPeerConnection),V.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(W2){var V2=A.RTCPeerConnection.prototype[W2],l3=n2({},W2,function(){return arguments[0]=new(W2==="addIceCandidate"?A.RTCIceCandidate:A.RTCSessionDescription)(arguments[0]),V2.apply(this,arguments)});A.RTCPeerConnection.prototype[W2]=l3[W2]}),V.version<68){var Z=A.RTCPeerConnection.prototype.addIceCandidate;A.RTCPeerConnection.prototype.addIceCandidate=function(){return arguments[0]?arguments[0]&&arguments[0].candidate===""?Promise.resolve():Z.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())}}var P2={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"},I2=A.RTCPeerConnection.prototype.getStats;A.RTCPeerConnection.prototype.getStats=function(){var V2=Array.prototype.slice.call(arguments),l3=V2[0],x3=V2[1],E3=V2[2];return I2.apply(this,[l3||null]).then(function(T3){if(V.version<53&&!x3)try{T3.forEach(function(m1){m1.type=P2[m1.type]||m1.type})}catch(m1){if(m1.name!=="TypeError")throw m1;T3.forEach(function(T1,x1){T3.set(x1,Object.assign({},T1,{type:P2[T1.type]||T1.type}))})}return T3}).then(x3,E3)}}}function X(A){if((typeof A=="undefined"?"undefined":f(A))==="object"&&A.RTCPeerConnection&&A.RTCRtpSender&&!(A.RTCRtpSender&&"getStats"in A.RTCRtpSender.prototype)){var V=A.RTCPeerConnection.prototype.getSenders;V&&(A.RTCPeerConnection.prototype.getSenders=function(){var I2=this,W2=V.apply(this,[]);return W2.forEach(function(V2){return V2._pc=I2}),W2});var Z=A.RTCPeerConnection.prototype.addTrack;Z&&(A.RTCPeerConnection.prototype.addTrack=function(){var I2=Z.apply(this,arguments);return I2._pc=this,I2}),A.RTCRtpSender.prototype.getStats=function(){return this.track?this._pc.getStats(this.track):Promise.resolve(new Map)}}}function R2(A){if((typeof A=="undefined"?"undefined":f(A))==="object"&&A.RTCPeerConnection&&A.RTCRtpSender&&!(A.RTCRtpSender&&"getStats"in A.RTCRtpReceiver.prototype)){var V=A.RTCPeerConnection.prototype.getReceivers;V&&(A.RTCPeerConnection.prototype.getReceivers=function(){var P2=this,I2=V.apply(this,[]);return I2.forEach(function(W2){return W2._pc=P2}),I2}),E.wrapPeerConnectionEvent(A,"track",function(Z){return Z.receiver._pc=Z.srcElement,Z}),A.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}}function y2(A){!A.RTCPeerConnection||"removeStream"in A.RTCPeerConnection.prototype||(A.RTCPeerConnection.prototype.removeStream=function(Z){var P2=this;E.deprecated("removeStream","removeTrack"),this.getSenders().forEach(function(I2){I2.track&&Z.getTracks().includes(I2.track)&&P2.removeTrack(I2)})})}function d2(A){A.DataChannel&&!A.RTCDataChannel&&(A.RTCDataChannel=A.DataChannel)}function h2(A){if((typeof A=="undefined"?"undefined":f(A))==="object"&&A.RTCPeerConnection){var V=A.RTCPeerConnection.prototype.addTransceiver;V&&(A.RTCPeerConnection.prototype.addTransceiver=function(){this.setParametersPromises=[];var P2=arguments[1],I2=P2&&"sendEncodings"in P2;I2&&P2.sendEncodings.forEach(function(x3){if("rid"in x3){var E3=/^[a-z0-9]{0,16}$/i;if(!E3.test(x3.rid))throw new TypeError("Invalid RID value provided.")}if("scaleResolutionDownBy"in x3&&!(parseFloat(x3.scaleResolutionDownBy)>=1))throw new RangeError("scale_resolution_down_by must be >= 1.0");if("maxFramerate"in x3&&!(parseFloat(x3.maxFramerate)>=0))throw new RangeError("max_framerate must be >= 0.0")});var W2=V.apply(this,arguments);if(I2){var V2=W2.sender,l3=V2.getParameters();"encodings"in l3||(l3.encodings=P2.sendEncodings,this.setParametersPromises.push(V2.setParameters(l3).catch(function(){})))}return W2})}}function B2(A){if((typeof A=="undefined"?"undefined":f(A))==="object"&&A.RTCPeerConnection){var V=A.RTCPeerConnection.prototype.createOffer;A.RTCPeerConnection.prototype.createOffer=function(){var P2=this,I2=arguments;return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(function(){return V.apply(P2,I2)}).finally(function(){P2.setParametersPromises=[]}):V.apply(this,arguments)}}}function u2(A){if((typeof A=="undefined"?"undefined":f(A))==="object"&&A.RTCPeerConnection){var V=A.RTCPeerConnection.prototype.createAnswer;A.RTCPeerConnection.prototype.createAnswer=function(){var P2=this,I2=arguments;return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(function(){return V.apply(P2,I2)}).finally(function(){P2.setParametersPromises=[]}):V.apply(this,arguments)}}}},{"../utils":15,"./getdisplaymedia":12,"./getusermedia":13}],12:[function(R,M,d){Object.defineProperty(d,"__esModule",{value:!0}),d.shimGetDisplayMedia=f;function f(y,w){y.navigator.mediaDevices&&"getDisplayMedia"in y.navigator.mediaDevices||y.navigator.mediaDevices&&(y.navigator.mediaDevices.getDisplayMedia=function(E){if(!(E&&E.video)){var r2=new DOMException("getDisplayMedia without video constraints is undefined");return r2.name="NotFoundError",r2.code=8,Promise.reject(r2)}return E.video===!0?E.video={mediaSource:w}:E.video.mediaSource=w,y.navigator.mediaDevices.getUserMedia(E)})}},{}],13:[function(R,M,d){Object.defineProperty(d,"__esModule",{value:!0});var f=typeof Symbol=="function"&&n(Symbol.iterator)==="symbol"?function(r2){return n(r2)}:function(r2){return r2&&typeof Symbol=="function"&&r2.constructor===Symbol&&r2!==Symbol.prototype?"symbol":n(r2)};d.shimGetUserMedia=E;var y=R("../utils"),w=_(y);function _(r2){if(r2&&r2.__esModule)return r2;var n2={};if(r2!=null)for(var o2 in r2)Object.prototype.hasOwnProperty.call(r2,o2)&&(n2[o2]=r2[o2]);return n2.default=r2,n2}function E(r2){var n2=w.detectBrowser(r2),o2=r2&&r2.navigator,t2=r2&&r2.MediaStreamTrack;if(o2.getUserMedia=function(h2,B2,u2){w.deprecated("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),o2.mediaDevices.getUserMedia(h2).then(B2,u2)},!(n2.version>55&&"autoGainControl"in o2.mediaDevices.getSupportedConstraints())){var X=function(B2,u2,A){u2 in B2&&!(A in B2)&&(B2[A]=B2[u2],delete B2[u2])},R2=o2.mediaDevices.getUserMedia.bind(o2.mediaDevices);if(o2.mediaDevices.getUserMedia=function(h2){return(typeof h2=="undefined"?"undefined":f(h2))==="object"&&f(h2.audio)==="object"&&(h2=JSON.parse(JSON.stringify(h2)),X(h2.audio,"autoGainControl","mozAutoGainControl"),X(h2.audio,"noiseSuppression","mozNoiseSuppression")),R2(h2)},t2&&t2.prototype.getSettings){var y2=t2.prototype.getSettings;t2.prototype.getSettings=function(){var h2=y2.apply(this,arguments);return X(h2,"mozAutoGainControl","autoGainControl"),X(h2,"mozNoiseSuppression","noiseSuppression"),h2}}if(t2&&t2.prototype.applyConstraints){var d2=t2.prototype.applyConstraints;t2.prototype.applyConstraints=function(h2){return this.kind==="audio"&&(typeof h2=="undefined"?"undefined":f(h2))==="object"&&(h2=JSON.parse(JSON.stringify(h2)),X(h2,"autoGainControl","mozAutoGainControl"),X(h2,"noiseSuppression","mozNoiseSuppression")),d2.apply(this,[h2])}}}}},{"../utils":15}],14:[function(R,M,d){Object.defineProperty(d,"__esModule",{value:!0});var f=typeof Symbol=="function"&&n(Symbol.iterator)==="symbol"?function(d2){return n(d2)}:function(d2){return d2&&typeof Symbol=="function"&&d2.constructor===Symbol&&d2!==Symbol.prototype?"symbol":n(d2)};d.shimLocalStreamsAPI=E,d.shimRemoteStreamsAPI=r2,d.shimCallbacksAPI=n2,d.shimGetUserMedia=o2,d.shimConstraints=t2,d.shimRTCIceServerUrls=X,d.shimTrackEventTransceiver=R2,d.shimCreateOfferLegacy=y2;var y=R("../utils"),w=_(y);function _(d2){if(d2&&d2.__esModule)return d2;var h2={};if(d2!=null)for(var B2 in d2)Object.prototype.hasOwnProperty.call(d2,B2)&&(h2[B2]=d2[B2]);return h2.default=d2,h2}function E(d2){if(!((typeof d2=="undefined"?"undefined":f(d2))!=="object"||!d2.RTCPeerConnection)){if("getLocalStreams"in d2.RTCPeerConnection.prototype||(d2.RTCPeerConnection.prototype.getLocalStreams=function(){return this._localStreams||(this._localStreams=[]),this._localStreams}),!("addStream"in d2.RTCPeerConnection.prototype)){var h2=d2.RTCPeerConnection.prototype.addTrack;d2.RTCPeerConnection.prototype.addStream=function(u2){var A=this;this._localStreams||(this._localStreams=[]),this._localStreams.includes(u2)||this._localStreams.push(u2),u2.getAudioTracks().forEach(function(V){return h2.call(A,V,u2)}),u2.getVideoTracks().forEach(function(V){return h2.call(A,V,u2)})},d2.RTCPeerConnection.prototype.addTrack=function(u2){var A=arguments[1];return A&&(this._localStreams?this._localStreams.includes(A)||this._localStreams.push(A):this._localStreams=[A]),h2.apply(this,arguments)}}"removeStream"in d2.RTCPeerConnection.prototype||(d2.RTCPeerConnection.prototype.removeStream=function(u2){var A=this;this._localStreams||(this._localStreams=[]);var V=this._localStreams.indexOf(u2);if(V!==-1){this._localStreams.splice(V,1);var Z=u2.getTracks();this.getSenders().forEach(function(P2){Z.includes(P2.track)&&A.removeTrack(P2)})}})}}function r2(d2){if(!((typeof d2=="undefined"?"undefined":f(d2))!=="object"||!d2.RTCPeerConnection)&&("getRemoteStreams"in d2.RTCPeerConnection.prototype||(d2.RTCPeerConnection.prototype.getRemoteStreams=function(){return this._remoteStreams?this._remoteStreams:[]}),!("onaddstream"in d2.RTCPeerConnection.prototype))){Object.defineProperty(d2.RTCPeerConnection.prototype,"onaddstream",{get:function(){return this._onaddstream},set:function(u2){var A=this;this._onaddstream&&(this.removeEventListener("addstream",this._onaddstream),this.removeEventListener("track",this._onaddstreampoly)),this.addEventListener("addstream",this._onaddstream=u2),this.addEventListener("track",this._onaddstreampoly=function(V){V.streams.forEach(function(Z){if(A._remoteStreams||(A._remoteStreams=[]),!A._remoteStreams.includes(Z)){A._remoteStreams.push(Z);var P2=new Event("addstream");P2.stream=Z,A.dispatchEvent(P2)}})})}});var h2=d2.RTCPeerConnection.prototype.setRemoteDescription;d2.RTCPeerConnection.prototype.setRemoteDescription=function(){var u2=this;return this._onaddstreampoly||this.addEventListener("track",this._onaddstreampoly=function(A){A.streams.forEach(function(V){if(u2._remoteStreams||(u2._remoteStreams=[]),!(u2._remoteStreams.indexOf(V)>=0)){u2._remoteStreams.push(V);var Z=new Event("addstream");Z.stream=V,u2.dispatchEvent(Z)}})}),h2.apply(u2,arguments)}}}function n2(d2){if(!((typeof d2=="undefined"?"undefined":f(d2))!=="object"||!d2.RTCPeerConnection)){var h2=d2.RTCPeerConnection.prototype,B2=h2.createOffer,u2=h2.createAnswer,A=h2.setLocalDescription,V=h2.setRemoteDescription,Z=h2.addIceCandidate;h2.createOffer=function(W2,V2){var l3=arguments.length>=2?arguments[2]:arguments[0],x3=B2.apply(this,[l3]);return V2?(x3.then(W2,V2),Promise.resolve()):x3},h2.createAnswer=function(W2,V2){var l3=arguments.length>=2?arguments[2]:arguments[0],x3=u2.apply(this,[l3]);return V2?(x3.then(W2,V2),Promise.resolve()):x3};var P2=function(W2,V2,l3){var x3=A.apply(this,[W2]);return l3?(x3.then(V2,l3),Promise.resolve()):x3};h2.setLocalDescription=P2,P2=function(W2,V2,l3){var x3=V.apply(this,[W2]);return l3?(x3.then(V2,l3),Promise.resolve()):x3},h2.setRemoteDescription=P2,P2=function(W2,V2,l3){var x3=Z.apply(this,[W2]);return l3?(x3.then(V2,l3),Promise.resolve()):x3},h2.addIceCandidate=P2}}function o2(d2){var h2=d2&&d2.navigator;if(h2.mediaDevices&&h2.mediaDevices.getUserMedia){var B2=h2.mediaDevices,u2=B2.getUserMedia.bind(B2);h2.mediaDevices.getUserMedia=function(A){return u2(t2(A))}}!h2.getUserMedia&&h2.mediaDevices&&h2.mediaDevices.getUserMedia&&(h2.getUserMedia=function(V,Z,P2){h2.mediaDevices.getUserMedia(V).then(Z,P2)}.bind(h2))}function t2(d2){return d2&&d2.video!==void 0?Object.assign({},d2,{video:w.compactObject(d2.video)}):d2}function X(d2){var h2=d2.RTCPeerConnection;d2.RTCPeerConnection=function(u2,A){if(u2&&u2.iceServers){for(var V=[],Z=0;Z=V&&parseInt(Z[V],10)}function r2(u2,A,V){if(u2.RTCPeerConnection){var Z=u2.RTCPeerConnection.prototype,P2=Z.addEventListener;Z.addEventListener=function(W2,V2){if(W2!==A)return P2.apply(this,arguments);var l3=function(E3){var T3=V(E3);T3&&V2(T3)};return this._eventMap=this._eventMap||{},this._eventMap[V2]=l3,P2.apply(this,[W2,l3])};var I2=Z.removeEventListener;Z.removeEventListener=function(W2,V2){if(W2!==A||!this._eventMap||!this._eventMap[V2])return I2.apply(this,arguments);var l3=this._eventMap[V2];return delete this._eventMap[V2],I2.apply(this,[W2,l3])},Object.defineProperty(Z,"on"+A,{get:function(){return this["_on"+A]},set:function(V2){this["_on"+A]&&(this.removeEventListener(A,this["_on"+A]),delete this["_on"+A]),V2&&this.addEventListener(A,this["_on"+A]=V2)},enumerable:!0,configurable:!0})}}function n2(u2){return typeof u2!="boolean"?new Error("Argument type: "+(typeof u2=="undefined"?"undefined":f(u2))+". Please use a boolean."):(w=u2,u2?"adapter.js logging disabled":"adapter.js logging enabled")}function o2(u2){return typeof u2!="boolean"?new Error("Argument type: "+(typeof u2=="undefined"?"undefined":f(u2))+". Please use a boolean."):(_=!u2,"adapter.js deprecation warnings "+(u2?"disabled":"enabled"))}function t2(){if((typeof window=="undefined"?"undefined":f(window))==="object"){if(w)return;typeof console!="undefined"&&typeof console.log=="function"&&console.log.apply(console,arguments)}}function X(u2,A){_&&console.warn(u2+" is deprecated, please use "+A+" instead.")}function R2(u2){var A=u2.navigator,V={browser:null,version:null};if(typeof u2=="undefined"||!u2.navigator)return V.browser="Not a browser.",V;if(A.mozGetUserMedia)V.browser="firefox",V.version=E(A.userAgent,/Firefox\/(\d+)\./,1);else if(A.webkitGetUserMedia||u2.isSecureContext===!1&&u2.webkitRTCPeerConnection&&!u2.RTCIceGatherer)V.browser="chrome",V.version=E(A.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else if(A.mediaDevices&&A.userAgent.match(/Edge\/(\d+).(\d+)$/))V.browser="edge",V.version=E(A.userAgent,/Edge\/(\d+).(\d+)$/,2);else if(u2.RTCPeerConnection&&A.userAgent.match(/AppleWebKit\/(\d+)\./))V.browser="safari",V.version=E(A.userAgent,/AppleWebKit\/(\d+)\./,1),V.supportsUnifiedPlan=u2.RTCRtpTransceiver&&"currentDirection"in u2.RTCRtpTransceiver.prototype;else return V.browser="Not a supported browser.",V;return V}function y2(u2){return Object.prototype.toString.call(u2)==="[object Object]"}function d2(u2){return y2(u2)?Object.keys(u2).reduce(function(A,V){var Z=y2(u2[V]),P2=Z?d2(u2[V]):u2[V],I2=Z&&!Object.keys(P2).length;return P2===void 0||I2?A:Object.assign(A,y({},V,P2))},{}):u2}function h2(u2,A,V){!A||V.has(A.id)||(V.set(A.id,A),Object.keys(A).forEach(function(Z){Z.endsWith("Id")?h2(u2,u2.get(A[Z]),V):Z.endsWith("Ids")&&A[Z].forEach(function(P2){h2(u2,u2.get(P2),V)})}))}function B2(u2,A,V){var Z=V?"outbound-rtp":"inbound-rtp",P2=new Map;if(A===null)return P2;var I2=[];return u2.forEach(function(W2){W2.type==="track"&&W2.trackIdentifier===A.id&&I2.push(W2)}),I2.forEach(function(W2){u2.forEach(function(V2){V2.type===Z&&V2.trackId===W2.id&&h2(u2,V2,P2)})}),P2}},{}],16:[function(R,M,d){var f=R("sdp");function y(t2){return{inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[t2.type]||t2.type}function w(t2,X,R2,y2,d2){var h2=f.writeRtpDescription(t2.kind,X);if(h2+=f.writeIceParameters(t2.iceGatherer.getLocalParameters()),h2+=f.writeDtlsParameters(t2.dtlsTransport.getLocalParameters(),R2==="offer"?"actpass":d2||"active"),h2+="a=mid:"+t2.mid+`\r
-`,t2.rtpSender&&t2.rtpReceiver?h2+=`a=sendrecv\r
-`:t2.rtpSender?h2+=`a=sendonly\r
-`:t2.rtpReceiver?h2+=`a=recvonly\r
-`:h2+=`a=inactive\r
-`,t2.rtpSender){var B2=t2.rtpSender._initialTrackId||t2.rtpSender.track.id;t2.rtpSender._initialTrackId=B2;var u2="msid:"+(y2?y2.id:"-")+" "+B2+`\r
-`;h2+="a="+u2,h2+="a=ssrc:"+t2.sendEncodingParameters[0].ssrc+" "+u2,t2.sendEncodingParameters[0].rtx&&(h2+="a=ssrc:"+t2.sendEncodingParameters[0].rtx.ssrc+" "+u2,h2+="a=ssrc-group:FID "+t2.sendEncodingParameters[0].ssrc+" "+t2.sendEncodingParameters[0].rtx.ssrc+`\r
-`)}return h2+="a=ssrc:"+t2.sendEncodingParameters[0].ssrc+" cname:"+f.localCName+`\r
-`,t2.rtpSender&&t2.sendEncodingParameters[0].rtx&&(h2+="a=ssrc:"+t2.sendEncodingParameters[0].rtx.ssrc+" cname:"+f.localCName+`\r
-`),h2}function _(t2,X){var R2=!1;return t2=JSON.parse(JSON.stringify(t2)),t2.filter(function(y2){if(y2&&(y2.urls||y2.url)){var d2=y2.urls||y2.url;y2.url&&!y2.urls&&console.warn("RTCIceServer.url is deprecated! Use urls instead.");var h2=typeof d2=="string";return h2&&(d2=[d2]),d2=d2.filter(function(B2){var u2=B2.indexOf("turn:")===0&&B2.indexOf("transport=udp")!==-1&&B2.indexOf("turn:[")===-1&&!R2;return u2?(R2=!0,!0):B2.indexOf("stun:")===0&&X>=14393&&B2.indexOf("?transport=udp")===-1}),delete y2.url,y2.urls=h2?d2[0]:d2,!!d2.length}})}function E(t2,X){var R2={codecs:[],headerExtensions:[],fecMechanisms:[]},y2=function(B2,u2){B2=parseInt(B2,10);for(var A=0;A0;I2--)this._iceGatherers.push(new t2.RTCIceGatherer({iceServers:V.iceServers,gatherPolicy:V.iceTransportPolicy}));else V.iceCandidatePoolSize=0;this._config=V,this.transceivers=[],this._sdpSessionId=f.generateSessionId(),this._sdpSessionVersion=0,this._dtlsRole=void 0,this._isClosed=!1};Object.defineProperty(h2.prototype,"localDescription",{configurable:!0,get:function(){return this._localDescription}}),Object.defineProperty(h2.prototype,"remoteDescription",{configurable:!0,get:function(){return this._remoteDescription}}),h2.prototype.onicecandidate=null,h2.prototype.onaddstream=null,h2.prototype.ontrack=null,h2.prototype.onremovestream=null,h2.prototype.onsignalingstatechange=null,h2.prototype.oniceconnectionstatechange=null,h2.prototype.onconnectionstatechange=null,h2.prototype.onicegatheringstatechange=null,h2.prototype.onnegotiationneeded=null,h2.prototype.ondatachannel=null,h2.prototype._dispatchEvent=function(A,V){this._isClosed||(this.dispatchEvent(V),typeof this["on"+A]=="function"&&this["on"+A](V))},h2.prototype._emitGatheringStateChange=function(){var A=new Event("icegatheringstatechange");this._dispatchEvent("icegatheringstatechange",A)},h2.prototype.getConfiguration=function(){return this._config},h2.prototype.getLocalStreams=function(){return this.localStreams},h2.prototype.getRemoteStreams=function(){return this.remoteStreams},h2.prototype._createTransceiver=function(A,V){var Z=this.transceivers.length>0,P2={track:null,iceGatherer:null,iceTransport:null,dtlsTransport:null,localCapabilities:null,remoteCapabilities:null,rtpSender:null,rtpReceiver:null,kind:A,mid:null,sendEncodingParameters:null,recvEncodingParameters:null,stream:null,associatedRemoteMediaStreams:[],wantReceive:!0};if(this.usingBundle&&Z)P2.iceTransport=this.transceivers[0].iceTransport,P2.dtlsTransport=this.transceivers[0].dtlsTransport;else{var I2=this._createIceAndDtlsTransports();P2.iceTransport=I2.iceTransport,P2.dtlsTransport=I2.dtlsTransport}return V||this.transceivers.push(P2),P2},h2.prototype.addTrack=function(A,V){if(this._isClosed)throw o2("InvalidStateError","Attempted to call addTrack on a closed peerconnection.");var Z=this.transceivers.find(function(W2){return W2.track===A});if(Z)throw o2("InvalidAccessError","Track already exists.");for(var P2,I2=0;I2=15025)A.getTracks().forEach(function(P2){V.addTrack(P2,A)});else{var Z=A.clone();A.getTracks().forEach(function(P2,I2){var W2=Z.getTracks()[I2];P2.addEventListener("enabled",function(V2){W2.enabled=V2.enabled})}),Z.getTracks().forEach(function(P2){V.addTrack(P2,Z)})}},h2.prototype.removeTrack=function(A){if(this._isClosed)throw o2("InvalidStateError","Attempted to call removeTrack on a closed peerconnection.");if(!(A instanceof t2.RTCRtpSender))throw new TypeError("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.");var V=this.transceivers.find(function(I2){return I2.rtpSender===A});if(!V)throw o2("InvalidAccessError","Sender was not created by this connection.");var Z=V.stream;V.rtpSender.stop(),V.rtpSender=null,V.track=null,V.stream=null;var P2=this.transceivers.map(function(I2){return I2.stream});P2.indexOf(Z)===-1&&this.localStreams.indexOf(Z)>-1&&this.localStreams.splice(this.localStreams.indexOf(Z),1),this._maybeFireNegotiationNeeded()},h2.prototype.removeStream=function(A){var V=this;A.getTracks().forEach(function(Z){var P2=V.getSenders().find(function(I2){return I2.track===Z});P2&&V.removeTrack(P2)})},h2.prototype.getSenders=function(){return this.transceivers.filter(function(A){return!!A.rtpSender}).map(function(A){return A.rtpSender})},h2.prototype.getReceivers=function(){return this.transceivers.filter(function(A){return!!A.rtpReceiver}).map(function(A){return A.rtpReceiver})},h2.prototype._createIceGatherer=function(A,V){var Z=this;if(V&&A>0)return this.transceivers[0].iceGatherer;if(this._iceGatherers.length)return this._iceGatherers.shift();var P2=new t2.RTCIceGatherer({iceServers:this._config.iceServers,gatherPolicy:this._config.iceTransportPolicy});return Object.defineProperty(P2,"state",{value:"new",writable:!0}),this.transceivers[A].bufferedCandidateEvents=[],this.transceivers[A].bufferCandidates=function(I2){var W2=!I2.candidate||Object.keys(I2.candidate).length===0;P2.state=W2?"completed":"gathering",Z.transceivers[A].bufferedCandidateEvents!==null&&Z.transceivers[A].bufferedCandidateEvents.push(I2)},P2.addEventListener("localcandidate",this.transceivers[A].bufferCandidates),P2},h2.prototype._gather=function(A,V){var Z=this,P2=this.transceivers[V].iceGatherer;if(!P2.onlocalcandidate){var I2=this.transceivers[V].bufferedCandidateEvents;this.transceivers[V].bufferedCandidateEvents=null,P2.removeEventListener("localcandidate",this.transceivers[V].bufferCandidates),P2.onlocalcandidate=function(W2){if(!(Z.usingBundle&&V>0)){var V2=new Event("icecandidate");V2.candidate={sdpMid:A,sdpMLineIndex:V};var l3=W2.candidate,x3=!l3||Object.keys(l3).length===0;if(x3)(P2.state==="new"||P2.state==="gathering")&&(P2.state="completed");else{P2.state==="new"&&(P2.state="gathering"),l3.component=1,l3.ufrag=P2.getLocalParameters().usernameFragment;var E3=f.writeCandidate(l3);V2.candidate=Object.assign(V2.candidate,f.parseCandidate(E3)),V2.candidate.candidate=E3,V2.candidate.toJSON=function(){return{candidate:V2.candidate.candidate,sdpMid:V2.candidate.sdpMid,sdpMLineIndex:V2.candidate.sdpMLineIndex,usernameFragment:V2.candidate.usernameFragment}}}var T3=f.getMediaSections(Z._localDescription.sdp);x3?T3[V2.candidate.sdpMLineIndex]+=`a=end-of-candidates\r
-`:T3[V2.candidate.sdpMLineIndex]+="a="+V2.candidate.candidate+`\r
-`,Z._localDescription.sdp=f.getDescription(Z._localDescription.sdp)+T3.join("");var m1=Z.transceivers.every(function(T1){return T1.iceGatherer&&T1.iceGatherer.state==="completed"});Z.iceGatheringState!=="gathering"&&(Z.iceGatheringState="gathering",Z._emitGatheringStateChange()),x3||Z._dispatchEvent("icecandidate",V2),m1&&(Z._dispatchEvent("icecandidate",new Event("icecandidate")),Z.iceGatheringState="complete",Z._emitGatheringStateChange())}},t2.setTimeout(function(){I2.forEach(function(W2){P2.onlocalcandidate(W2)})},0)}},h2.prototype._createIceAndDtlsTransports=function(){var A=this,V=new t2.RTCIceTransport(null);V.onicestatechange=function(){A._updateIceConnectionState(),A._updateConnectionState()};var Z=new t2.RTCDtlsTransport(V);return Z.ondtlsstatechange=function(){A._updateConnectionState()},Z.onerror=function(){Object.defineProperty(Z,"state",{value:"failed",writable:!0}),A._updateConnectionState()},{iceTransport:V,dtlsTransport:Z}},h2.prototype._disposeIceAndDtlsTransports=function(A){var V=this.transceivers[A].iceGatherer;V&&(delete V.onlocalcandidate,delete this.transceivers[A].iceGatherer);var Z=this.transceivers[A].iceTransport;Z&&(delete Z.onicestatechange,delete this.transceivers[A].iceTransport);var P2=this.transceivers[A].dtlsTransport;P2&&(delete P2.ondtlsstatechange,delete P2.onerror,delete this.transceivers[A].dtlsTransport)},h2.prototype._transceive=function(A,V,Z){var P2=E(A.localCapabilities,A.remoteCapabilities);V&&A.rtpSender&&(P2.encodings=A.sendEncodingParameters,P2.rtcp={cname:f.localCName,compound:A.rtcpParameters.compound},A.recvEncodingParameters.length&&(P2.rtcp.ssrc=A.recvEncodingParameters[0].ssrc),A.rtpSender.send(P2)),Z&&A.rtpReceiver&&P2.codecs.length>0&&(A.kind==="video"&&A.recvEncodingParameters&&X<15019&&A.recvEncodingParameters.forEach(function(I2){delete I2.rtx}),A.recvEncodingParameters.length?P2.encodings=A.recvEncodingParameters:P2.encodings=[{}],P2.rtcp={compound:A.rtcpParameters.compound},A.rtcpParameters.cname&&(P2.rtcp.cname=A.rtcpParameters.cname),A.sendEncodingParameters.length&&(P2.rtcp.ssrc=A.sendEncodingParameters[0].ssrc),A.rtpReceiver.receive(P2))},h2.prototype.setLocalDescription=function(A){var V=this;if(["offer","answer"].indexOf(A.type)===-1)return Promise.reject(o2("TypeError",'Unsupported type "'+A.type+'"'));if(!r2("setLocalDescription",A.type,V.signalingState)||V._isClosed)return Promise.reject(o2("InvalidStateError","Can not set local "+A.type+" in state "+V.signalingState));var Z,P2;if(A.type==="offer")Z=f.splitSections(A.sdp),P2=Z.shift(),Z.forEach(function(W2,V2){var l3=f.parseRtpParameters(W2);V.transceivers[V2].localCapabilities=l3}),V.transceivers.forEach(function(W2,V2){V._gather(W2.mid,V2)});else if(A.type==="answer"){Z=f.splitSections(V._remoteDescription.sdp),P2=Z.shift();var I2=f.matchPrefix(P2,"a=ice-lite").length>0;Z.forEach(function(W2,V2){var l3=V.transceivers[V2],x3=l3.iceGatherer,E3=l3.iceTransport,T3=l3.dtlsTransport,m1=l3.localCapabilities,T1=l3.remoteCapabilities,x1=f.isRejected(W2)&&f.matchPrefix(W2,"a=bundle-only").length===0;if(!x1&&!l3.rejected){var B1=f.getIceParameters(W2,P2),v1=f.getDtlsParameters(W2,P2);I2&&(v1.role="server"),(!V.usingBundle||V2===0)&&(V._gather(l3.mid,V2),E3.state==="new"&&E3.start(x3,B1,I2?"controlling":"controlled"),T3.state==="new"&&T3.start(v1));var Y1=E(m1,T1);V._transceive(l3,Y1.codecs.length>0,!1)}})}return V._localDescription={type:A.type,sdp:A.sdp},A.type==="offer"?V._updateSignalingState("have-local-offer"):V._updateSignalingState("stable"),Promise.resolve()},h2.prototype.setRemoteDescription=function(A){var V=this;if(["offer","answer"].indexOf(A.type)===-1)return Promise.reject(o2("TypeError",'Unsupported type "'+A.type+'"'));if(!r2("setRemoteDescription",A.type,V.signalingState)||V._isClosed)return Promise.reject(o2("InvalidStateError","Can not set remote "+A.type+" in state "+V.signalingState));var Z={};V.remoteStreams.forEach(function(E3){Z[E3.id]=E3});var P2=[],I2=f.splitSections(A.sdp),W2=I2.shift(),V2=f.matchPrefix(W2,"a=ice-lite").length>0,l3=f.matchPrefix(W2,"a=group:BUNDLE ").length>0;V.usingBundle=l3;var x3=f.matchPrefix(W2,"a=ice-options:")[0];return x3?V.canTrickleIceCandidates=x3.substr(14).split(" ").indexOf("trickle")>=0:V.canTrickleIceCandidates=!1,I2.forEach(function(E3,T3){var m1=f.splitLines(E3),T1=f.getKind(E3),x1=f.isRejected(E3)&&f.matchPrefix(E3,"a=bundle-only").length===0,B1=m1[0].substr(2).split(" ")[2],v1=f.getDirection(E3,W2),Y1=f.parseMsid(E3),g0=f.getMid(E3)||f.generateIdentifier();if(x1||T1==="application"&&(B1==="DTLS/SCTP"||B1==="UDP/DTLS/SCTP")){V.transceivers[T3]={mid:g0,kind:T1,protocol:B1,rejected:!0};return}!x1&&V.transceivers[T3]&&V.transceivers[T3].rejected&&(V.transceivers[T3]=V._createTransceiver(T1,!0));var E2,f3,g3,V3,h1,L1,D1,n0,C0,Pe=f.parseRtpParameters(E3),ke,le;x1||(ke=f.getIceParameters(E3,W2),le=f.getDtlsParameters(E3,W2),le.role="client"),D1=f.parseRtpEncodingParameters(E3);var ie=f.parseRtcpParameters(E3),M1=f.matchPrefix(E3,"a=end-of-candidates",W2).length>0,B=f.matchPrefix(E3,"a=candidate:").map(function(R3){return f.parseCandidate(R3)}).filter(function(R3){return R3.component===1});if((A.type==="offer"||A.type==="answer")&&!x1&&l3&&T3>0&&V.transceivers[T3]&&(V._disposeIceAndDtlsTransports(T3),V.transceivers[T3].iceGatherer=V.transceivers[0].iceGatherer,V.transceivers[T3].iceTransport=V.transceivers[0].iceTransport,V.transceivers[T3].dtlsTransport=V.transceivers[0].dtlsTransport,V.transceivers[T3].rtpSender&&V.transceivers[T3].rtpSender.setTransport(V.transceivers[0].dtlsTransport),V.transceivers[T3].rtpReceiver&&V.transceivers[T3].rtpReceiver.setTransport(V.transceivers[0].dtlsTransport)),A.type==="offer"&&!x1){E2=V.transceivers[T3]||V._createTransceiver(T1),E2.mid=g0,E2.iceGatherer||(E2.iceGatherer=V._createIceGatherer(T3,l3)),B.length&&E2.iceTransport.state==="new"&&(M1&&(!l3||T3===0)?E2.iceTransport.setRemoteCandidates(B):B.forEach(function(R3){n2(E2.iceTransport,R3)})),n0=t2.RTCRtpReceiver.getCapabilities(T1),X<15019&&(n0.codecs=n0.codecs.filter(function(R3){return R3.name!=="rtx"})),L1=E2.sendEncodingParameters||[{ssrc:(2*T3+2)*1001}];var f2=!1;if(v1==="sendrecv"||v1==="sendonly"){if(f2=!E2.rtpReceiver,h1=E2.rtpReceiver||new t2.RTCRtpReceiver(E2.dtlsTransport,T1),f2){var G2;C0=h1.track,Y1&&Y1.stream==="-"||(Y1?(Z[Y1.stream]||(Z[Y1.stream]=new t2.MediaStream,Object.defineProperty(Z[Y1.stream],"id",{get:function(){return Y1.stream}})),Object.defineProperty(C0,"id",{get:function(){return Y1.track}}),G2=Z[Y1.stream]):(Z.default||(Z.default=new t2.MediaStream),G2=Z.default)),G2&&(R2(C0,G2),E2.associatedRemoteMediaStreams.push(G2)),P2.push([C0,h1,G2])}}else E2.rtpReceiver&&E2.rtpReceiver.track&&(E2.associatedRemoteMediaStreams.forEach(function(R3){var C=R3.getTracks().find(function(j){return j.id===E2.rtpReceiver.track.id});C&&y2(C,R3)}),E2.associatedRemoteMediaStreams=[]);E2.localCapabilities=n0,E2.remoteCapabilities=Pe,E2.rtpReceiver=h1,E2.rtcpParameters=ie,E2.sendEncodingParameters=L1,E2.recvEncodingParameters=D1,V._transceive(V.transceivers[T3],!1,f2)}else if(A.type==="answer"&&!x1){E2=V.transceivers[T3],f3=E2.iceGatherer,g3=E2.iceTransport,V3=E2.dtlsTransport,h1=E2.rtpReceiver,L1=E2.sendEncodingParameters,n0=E2.localCapabilities,V.transceivers[T3].recvEncodingParameters=D1,V.transceivers[T3].remoteCapabilities=Pe,V.transceivers[T3].rtcpParameters=ie,B.length&&g3.state==="new"&&((V2||M1)&&(!l3||T3===0)?g3.setRemoteCandidates(B):B.forEach(function(R3){n2(E2.iceTransport,R3)})),(!l3||T3===0)&&(g3.state==="new"&&g3.start(f3,ke,"controlling"),V3.state==="new"&&V3.start(le));var J3=E(E2.localCapabilities,E2.remoteCapabilities),$3=J3.codecs.filter(function(R3){return R3.name.toLowerCase()==="rtx"}).length;!$3&&E2.sendEncodingParameters[0].rtx&&delete E2.sendEncodingParameters[0].rtx,V._transceive(E2,v1==="sendrecv"||v1==="recvonly",v1==="sendrecv"||v1==="sendonly"),h1&&(v1==="sendrecv"||v1==="sendonly")?(C0=h1.track,Y1?(Z[Y1.stream]||(Z[Y1.stream]=new t2.MediaStream),R2(C0,Z[Y1.stream]),P2.push([C0,h1,Z[Y1.stream]])):(Z.default||(Z.default=new t2.MediaStream),R2(C0,Z.default),P2.push([C0,h1,Z.default]))):delete E2.rtpReceiver}}),V._dtlsRole===void 0&&(V._dtlsRole=A.type==="offer"?"active":"passive"),V._remoteDescription={type:A.type,sdp:A.sdp},A.type==="offer"?V._updateSignalingState("have-remote-offer"):V._updateSignalingState("stable"),Object.keys(Z).forEach(function(E3){var T3=Z[E3];if(T3.getTracks().length){if(V.remoteStreams.indexOf(T3)===-1){V.remoteStreams.push(T3);var m1=new Event("addstream");m1.stream=T3,t2.setTimeout(function(){V._dispatchEvent("addstream",m1)})}P2.forEach(function(T1){var x1=T1[0],B1=T1[1];T3.id===T1[2].id&&d2(V,x1,B1,[T3])})}}),P2.forEach(function(E3){E3[2]||d2(V,E3[0],E3[1],[])}),t2.setTimeout(function(){V&&V.transceivers&&V.transceivers.forEach(function(E3){E3.iceTransport&&E3.iceTransport.state==="new"&&E3.iceTransport.getRemoteCandidates().length>0&&(console.warn("Timeout for addRemoteCandidate. Consider sending an end-of-candidates notification"),E3.iceTransport.addRemoteCandidate({}))})},4e3),Promise.resolve()},h2.prototype.close=function(){this.transceivers.forEach(function(A){A.iceTransport&&A.iceTransport.stop(),A.dtlsTransport&&A.dtlsTransport.stop(),A.rtpSender&&A.rtpSender.stop(),A.rtpReceiver&&A.rtpReceiver.stop()}),this._isClosed=!0,this._updateSignalingState("closed")},h2.prototype._updateSignalingState=function(A){this.signalingState=A;var V=new Event("signalingstatechange");this._dispatchEvent("signalingstatechange",V)},h2.prototype._maybeFireNegotiationNeeded=function(){var A=this;this.signalingState!=="stable"||this.needNegotiation===!0||(this.needNegotiation=!0,t2.setTimeout(function(){if(A.needNegotiation){A.needNegotiation=!1;var V=new Event("negotiationneeded");A._dispatchEvent("negotiationneeded",V)}},0))},h2.prototype._updateIceConnectionState=function(){var A,V={new:0,closed:0,checking:0,connected:0,completed:0,disconnected:0,failed:0};if(this.transceivers.forEach(function(P2){P2.iceTransport&&!P2.rejected&&V[P2.iceTransport.state]++}),A="new",V.failed>0?A="failed":V.checking>0?A="checking":V.disconnected>0?A="disconnected":V.new>0?A="new":V.connected>0?A="connected":V.completed>0&&(A="completed"),A!==this.iceConnectionState){this.iceConnectionState=A;var Z=new Event("iceconnectionstatechange");this._dispatchEvent("iceconnectionstatechange",Z)}},h2.prototype._updateConnectionState=function(){var A,V={new:0,closed:0,connecting:0,connected:0,completed:0,disconnected:0,failed:0};if(this.transceivers.forEach(function(P2){P2.iceTransport&&P2.dtlsTransport&&!P2.rejected&&(V[P2.iceTransport.state]++,V[P2.dtlsTransport.state]++)}),V.connected+=V.completed,A="new",V.failed>0?A="failed":V.connecting>0?A="connecting":V.disconnected>0?A="disconnected":V.new>0?A="new":V.connected>0&&(A="connected"),A!==this.connectionState){this.connectionState=A;var Z=new Event("connectionstatechange");this._dispatchEvent("connectionstatechange",Z)}},h2.prototype.createOffer=function(){var A=this;if(A._isClosed)return Promise.reject(o2("InvalidStateError","Can not call createOffer after close"));var V=A.transceivers.filter(function(V2){return V2.kind==="audio"}).length,Z=A.transceivers.filter(function(V2){return V2.kind==="video"}).length,P2=arguments[0];if(P2){if(P2.mandatory||P2.optional)throw new TypeError("Legacy mandatory/optional constraints not supported.");P2.offerToReceiveAudio!==void 0&&(P2.offerToReceiveAudio===!0?V=1:P2.offerToReceiveAudio===!1?V=0:V=P2.offerToReceiveAudio),P2.offerToReceiveVideo!==void 0&&(P2.offerToReceiveVideo===!0?Z=1:P2.offerToReceiveVideo===!1?Z=0:Z=P2.offerToReceiveVideo)}for(A.transceivers.forEach(function(V2){V2.kind==="audio"?(V--,V<0&&(V2.wantReceive=!1)):V2.kind==="video"&&(Z--,Z<0&&(V2.wantReceive=!1))});V>0||Z>0;)V>0&&(A._createTransceiver("audio"),V--),Z>0&&(A._createTransceiver("video"),Z--);var I2=f.writeSessionBoilerplate(A._sdpSessionId,A._sdpSessionVersion++);A.transceivers.forEach(function(V2,l3){var x3=V2.track,E3=V2.kind,T3=V2.mid||f.generateIdentifier();V2.mid=T3,V2.iceGatherer||(V2.iceGatherer=A._createIceGatherer(l3,A.usingBundle));var m1=t2.RTCRtpSender.getCapabilities(E3);X<15019&&(m1.codecs=m1.codecs.filter(function(x1){return x1.name!=="rtx"})),m1.codecs.forEach(function(x1){x1.name==="H264"&&x1.parameters["level-asymmetry-allowed"]===void 0&&(x1.parameters["level-asymmetry-allowed"]="1"),V2.remoteCapabilities&&V2.remoteCapabilities.codecs&&V2.remoteCapabilities.codecs.forEach(function(B1){x1.name.toLowerCase()===B1.name.toLowerCase()&&x1.clockRate===B1.clockRate&&(x1.preferredPayloadType=B1.payloadType)})}),m1.headerExtensions.forEach(function(x1){var B1=V2.remoteCapabilities&&V2.remoteCapabilities.headerExtensions||[];B1.forEach(function(v1){x1.uri===v1.uri&&(x1.id=v1.id)})});var T1=V2.sendEncodingParameters||[{ssrc:(2*l3+1)*1001}];x3&&X>=15019&&E3==="video"&&!T1[0].rtx&&(T1[0].rtx={ssrc:T1[0].ssrc+1}),V2.wantReceive&&(V2.rtpReceiver=new t2.RTCRtpReceiver(V2.dtlsTransport,E3)),V2.localCapabilities=m1,V2.sendEncodingParameters=T1}),A._config.bundlePolicy!=="max-compat"&&(I2+="a=group:BUNDLE "+A.transceivers.map(function(V2){return V2.mid}).join(" ")+`\r
-`),I2+=`a=ice-options:trickle\r
-`,A.transceivers.forEach(function(V2,l3){I2+=w(V2,V2.localCapabilities,"offer",V2.stream,A._dtlsRole),I2+=`a=rtcp-rsize\r
-`,V2.iceGatherer&&A.iceGatheringState!=="new"&&(l3===0||!A.usingBundle)&&(V2.iceGatherer.getLocalCandidates().forEach(function(x3){x3.component=1,I2+="a="+f.writeCandidate(x3)+`\r
-`}),V2.iceGatherer.state==="completed"&&(I2+=`a=end-of-candidates\r
-`))});var W2=new t2.RTCSessionDescription({type:"offer",sdp:I2});return Promise.resolve(W2)},h2.prototype.createAnswer=function(){var A=this;if(A._isClosed)return Promise.reject(o2("InvalidStateError","Can not call createAnswer after close"));if(!(A.signalingState==="have-remote-offer"||A.signalingState==="have-local-pranswer"))return Promise.reject(o2("InvalidStateError","Can not call createAnswer in signalingState "+A.signalingState));var V=f.writeSessionBoilerplate(A._sdpSessionId,A._sdpSessionVersion++);A.usingBundle&&(V+="a=group:BUNDLE "+A.transceivers.map(function(I2){return I2.mid}).join(" ")+`\r
-`),V+=`a=ice-options:trickle\r
-`;var Z=f.getMediaSections(A._remoteDescription.sdp).length;A.transceivers.forEach(function(I2,W2){if(!(W2+1>Z)){if(I2.rejected){I2.kind==="application"?I2.protocol==="DTLS/SCTP"?V+=`m=application 0 DTLS/SCTP 5000\r
-`:V+="m=application 0 "+I2.protocol+` webrtc-datachannel\r
-`:I2.kind==="audio"?V+=`m=audio 0 UDP/TLS/RTP/SAVPF 0\r
-a=rtpmap:0 PCMU/8000\r
-`:I2.kind==="video"&&(V+=`m=video 0 UDP/TLS/RTP/SAVPF 120\r
-a=rtpmap:120 VP8/90000\r
-`),V+=`c=IN IP4 0.0.0.0\r
-a=inactive\r
-a=mid:`+I2.mid+`\r
-`;return}if(I2.stream){var V2;I2.kind==="audio"?V2=I2.stream.getAudioTracks()[0]:I2.kind==="video"&&(V2=I2.stream.getVideoTracks()[0]),V2&&X>=15019&&I2.kind==="video"&&!I2.sendEncodingParameters[0].rtx&&(I2.sendEncodingParameters[0].rtx={ssrc:I2.sendEncodingParameters[0].ssrc+1})}var l3=E(I2.localCapabilities,I2.remoteCapabilities),x3=l3.codecs.filter(function(E3){return E3.name.toLowerCase()==="rtx"}).length;!x3&&I2.sendEncodingParameters[0].rtx&&delete I2.sendEncodingParameters[0].rtx,V+=w(I2,l3,"answer",I2.stream,A._dtlsRole),I2.rtcpParameters&&I2.rtcpParameters.reducedSize&&(V+=`a=rtcp-rsize\r
-`)}});var P2=new t2.RTCSessionDescription({type:"answer",sdp:V});return Promise.resolve(P2)},h2.prototype.addIceCandidate=function(A){var V=this,Z;return A&&!(A.sdpMLineIndex!==void 0||A.sdpMid)?Promise.reject(new TypeError("sdpMLineIndex or sdpMid required")):new Promise(function(P2,I2){if(V._remoteDescription)if(!A||A.candidate==="")for(var W2=0;W20?f.parseCandidate(A.candidate):{};if(E3.protocol==="tcp"&&(E3.port===0||E3.port===9)||E3.component&&E3.component!==1)return P2();if((V2===0||V2>0&&x3.iceTransport!==V.transceivers[0].iceTransport)&&!n2(x3.iceTransport,E3))return I2(o2("OperationError","Can not add ICE candidate"));var T3=A.candidate.trim();T3.indexOf("a=")===0&&(T3=T3.substr(2)),Z=f.getMediaSections(V._remoteDescription.sdp),Z[V2]+="a="+(E3.type?T3:"end-of-candidates")+`\r
-`,V._remoteDescription.sdp=f.getDescription(V._remoteDescription.sdp)+Z.join("")}else return I2(o2("OperationError","Can not add ICE candidate"))}else return I2(o2("InvalidStateError","Can not add ICE candidate without a remote description"));P2()})},h2.prototype.getStats=function(A){if(A&&A instanceof t2.MediaStreamTrack){var V=null;if(this.transceivers.forEach(function(P2){P2.rtpSender&&P2.rtpSender.track===A?V=P2.rtpSender:P2.rtpReceiver&&P2.rtpReceiver.track===A&&(V=P2.rtpReceiver)}),!V)throw o2("InvalidAccessError","Invalid selector.");return V.getStats()}var Z=[];return this.transceivers.forEach(function(P2){["rtpSender","rtpReceiver","iceGatherer","iceTransport","dtlsTransport"].forEach(function(I2){P2[I2]&&Z.push(P2[I2].getStats())})}),Promise.all(Z).then(function(P2){var I2=new Map;return P2.forEach(function(W2){W2.forEach(function(V2){I2.set(V2.id,V2)})}),I2})};var B2=["RTCRtpSender","RTCRtpReceiver","RTCIceGatherer","RTCIceTransport","RTCDtlsTransport"];B2.forEach(function(A){var V=t2[A];if(V&&V.prototype&&V.prototype.getStats){var Z=V.prototype.getStats;V.prototype.getStats=function(){return Z.apply(this).then(function(P2){var I2=new Map;return Object.keys(P2).forEach(function(W2){P2[W2].type=y(P2[W2]),I2.set(W2,P2[W2])}),I2})}}});var u2=["createOffer","createAnswer"];return u2.forEach(function(A){var V=h2.prototype[A];h2.prototype[A]=function(){var Z=arguments;return typeof Z[0]=="function"||typeof Z[1]=="function"?V.apply(this,[arguments[2]]).then(function(P2){typeof Z[0]=="function"&&Z[0].apply(null,[P2])},function(P2){typeof Z[1]=="function"&&Z[1].apply(null,[P2])}):V.apply(this,arguments)}}),u2=["setLocalDescription","setRemoteDescription","addIceCandidate"],u2.forEach(function(A){var V=h2.prototype[A];h2.prototype[A]=function(){var Z=arguments;return typeof Z[1]=="function"||typeof Z[2]=="function"?V.apply(this,arguments).then(function(){typeof Z[1]=="function"&&Z[1].apply(null)},function(P2){typeof Z[2]=="function"&&Z[2].apply(null,[P2])}):V.apply(this,arguments)}}),["getStats"].forEach(function(A){var V=h2.prototype[A];h2.prototype[A]=function(){var Z=arguments;return typeof Z[1]=="function"?V.apply(this,arguments).then(function(){typeof Z[1]=="function"&&Z[1].apply(null)}):V.apply(this,arguments)}}),h2}},{sdp:17}],17:[function(R,M,d){var f={};f.generateIdentifier=function(){return Math.random().toString(36).substr(2,10)},f.localCName=f.generateIdentifier(),f.splitLines=function(y){return y.trim().split(`
-`).map(function(w){return w.trim()})},f.splitSections=function(y){var w=y.split(`
-m=`);return w.map(function(_,E){return(E>0?"m="+_:_).trim()+`\r
-`})},f.getDescription=function(y){var w=f.splitSections(y);return w&&w[0]},f.getMediaSections=function(y){var w=f.splitSections(y);return w.shift(),w},f.matchPrefix=function(y,w){return f.splitLines(y).filter(function(_){return _.indexOf(w)===0})},f.parseCandidate=function(y){var w;y.indexOf("a=candidate:")===0?w=y.substring(12).split(" "):w=y.substring(10).split(" ");for(var _={foundation:w[0],component:parseInt(w[1],10),protocol:w[2].toLowerCase(),priority:parseInt(w[3],10),ip:w[4],address:w[4],port:parseInt(w[5],10),type:w[7]},E=8;E0?w[0].split("/")[1]:"sendrecv",uri:w[1]}},f.writeExtmap=function(y){return"a=extmap:"+(y.id||y.preferredId)+(y.direction&&y.direction!=="sendrecv"?"/"+y.direction:"")+" "+y.uri+`\r
-`},f.parseFmtp=function(y){for(var w={},_,E=y.substr(y.indexOf(" ")+1).split(";"),r2=0;r2-1?(_.attribute=y.substr(w+1,E-w-1),_.value=y.substr(E+1)):_.attribute=y.substr(w+1),_},f.parseSsrcGroup=function(y){var w=y.substr(13).split(" ");return{semantics:w.shift(),ssrcs:w.map(function(_){return parseInt(_,10)})}},f.getMid=function(y){var w=f.matchPrefix(y,"a=mid:")[0];if(w)return w.substr(6)},f.parseFingerprint=function(y){var w=y.substr(14).split(" ");return{algorithm:w[0].toLowerCase(),value:w[1]}},f.getDtlsParameters=function(y,w){var _=f.matchPrefix(y+w,"a=fingerprint:");return{role:"auto",fingerprints:_.map(f.parseFingerprint)}},f.writeDtlsParameters=function(y,w){var _="a=setup:"+w+`\r
-`;return y.fingerprints.forEach(function(E){_+="a=fingerprint:"+E.algorithm+" "+E.value+`\r
-`}),_},f.getIceParameters=function(y,w){var _=f.splitLines(y);_=_.concat(f.splitLines(w));var E={usernameFragment:_.filter(function(r2){return r2.indexOf("a=ice-ufrag:")===0})[0].substr(12),password:_.filter(function(r2){return r2.indexOf("a=ice-pwd:")===0})[0].substr(10)};return E},f.writeIceParameters=function(y){return"a=ice-ufrag:"+y.usernameFragment+`\r
-a=ice-pwd:`+y.password+`\r
-`},f.parseRtpParameters=function(y){for(var w={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},_=f.splitLines(y),E=_[0].split(" "),r2=3;r20?"9":"0",_+=" UDP/TLS/RTP/SAVPF ",_+=w.codecs.map(function(r2){return r2.preferredPayloadType!==void 0?r2.preferredPayloadType:r2.payloadType}).join(" ")+`\r
-`,_+=`c=IN IP4 0.0.0.0\r
-`,_+=`a=rtcp:9 IN IP4 0.0.0.0\r
-`,w.codecs.forEach(function(r2){_+=f.writeRtpMap(r2),_+=f.writeFmtp(r2),_+=f.writeRtcpFb(r2)});var E=0;return w.codecs.forEach(function(r2){r2.maxptime>E&&(E=r2.maxptime)}),E>0&&(_+="a=maxptime:"+E+`\r
-`),_+=`a=rtcp-mux\r
-`,w.headerExtensions&&w.headerExtensions.forEach(function(r2){_+=f.writeExtmap(r2)}),_},f.parseRtpEncodingParameters=function(y){var w=[],_=f.parseRtpParameters(y),E=_.fecMechanisms.indexOf("RED")!==-1,r2=_.fecMechanisms.indexOf("ULPFEC")!==-1,n2=f.matchPrefix(y,"a=ssrc:").map(function(y2){return f.parseSsrcMedia(y2)}).filter(function(y2){return y2.attribute==="cname"}),o2=n2.length>0&&n2[0].ssrc,t2,X=f.matchPrefix(y,"a=ssrc-group:FID").map(function(y2){var d2=y2.substr(17).split(" ");return d2.map(function(h2){return parseInt(h2,10)})});X.length>0&&X[0].length>1&&X[0][0]===o2&&(t2=X[0][1]),_.codecs.forEach(function(y2){if(y2.name.toUpperCase()==="RTX"&&y2.parameters.apt){var d2={ssrc:o2,codecPayloadType:parseInt(y2.parameters.apt,10)};o2&&t2&&(d2.rtx={ssrc:t2}),w.push(d2),E&&(d2=JSON.parse(JSON.stringify(d2)),d2.fec={ssrc:o2,mechanism:r2?"red+ulpfec":"red"},w.push(d2))}}),w.length===0&&o2&&w.push({ssrc:o2});var R2=f.matchPrefix(y,"b=");return R2.length&&(R2[0].indexOf("b=TIAS:")===0?R2=parseInt(R2[0].substr(7),10):R2[0].indexOf("b=AS:")===0?R2=parseInt(R2[0].substr(5),10)*1e3*.95-50*40*8:R2=void 0,w.forEach(function(y2){y2.maxBitrate=R2})),w},f.parseRtcpParameters=function(y){var w={},_=f.matchPrefix(y,"a=ssrc:").map(function(n2){return f.parseSsrcMedia(n2)}).filter(function(n2){return n2.attribute==="cname"})[0];_&&(w.cname=_.value,w.ssrc=_.ssrc);var E=f.matchPrefix(y,"a=rtcp-rsize");w.reducedSize=E.length>0,w.compound=E.length===0;var r2=f.matchPrefix(y,"a=rtcp-mux");return w.mux=r2.length>0,w},f.parseMsid=function(y){var w,_=f.matchPrefix(y,"a=msid:");if(_.length===1)return w=_[0].substr(7).split(" "),{stream:w[0],track:w[1]};var E=f.matchPrefix(y,"a=ssrc:").map(function(r2){return f.parseSsrcMedia(r2)}).filter(function(r2){return r2.attribute==="msid"});if(E.length>0)return w=E[0].value.split(" "),{stream:w[0],track:w[1]}},f.parseSctpDescription=function(y){var w=f.parseMLine(y),_=f.matchPrefix(y,"a=max-message-size:"),E;_.length>0&&(E=parseInt(_[0].substr(19),10)),isNaN(E)&&(E=65536);var r2=f.matchPrefix(y,"a=sctp-port:");if(r2.length>0)return{port:parseInt(r2[0].substr(12),10),protocol:w.fmt,maxMessageSize:E};var n2=f.matchPrefix(y,"a=sctpmap:");if(n2.length>0){var o2=f.matchPrefix(y,"a=sctpmap:")[0].substr(10).split(" ");return{port:parseInt(o2[0],10),protocol:o2[1],maxMessageSize:E}}},f.writeSctpDescription=function(y,w){var _=[];return y.protocol!=="DTLS/SCTP"?_=["m="+y.kind+" 9 "+y.protocol+" "+w.protocol+`\r
-`,`c=IN IP4 0.0.0.0\r
-`,"a=sctp-port:"+w.port+`\r
-`]:_=["m="+y.kind+" 9 "+y.protocol+" "+w.port+`\r
-`,`c=IN IP4 0.0.0.0\r
-`,"a=sctpmap:"+w.port+" "+w.protocol+` 65535\r
-`],w.maxMessageSize!==void 0&&_.push("a=max-message-size:"+w.maxMessageSize+`\r
-`),_.join("")},f.generateSessionId=function(){return Math.random().toString().substr(2,21)},f.writeSessionBoilerplate=function(y,w,_){var E,r2=w!==void 0?w:2;y?E=y:E=f.generateSessionId();var n2=_||"thisisadapterortc";return`v=0\r
-o=`+n2+" "+E+" "+r2+` IN IP4 127.0.0.1\r
-s=-\r
-t=0 0\r
-`},f.writeMediaSection=function(y,w,_,E){var r2=f.writeRtpDescription(y.kind,w);if(r2+=f.writeIceParameters(y.iceGatherer.getLocalParameters()),r2+=f.writeDtlsParameters(y.dtlsTransport.getLocalParameters(),_==="offer"?"actpass":"active"),r2+="a=mid:"+y.mid+`\r
-`,y.direction?r2+="a="+y.direction+`\r
-`:y.rtpSender&&y.rtpReceiver?r2+=`a=sendrecv\r
-`:y.rtpSender?r2+=`a=sendonly\r
-`:y.rtpReceiver?r2+=`a=recvonly\r
-`:r2+=`a=inactive\r
-`,y.rtpSender){var n2="msid:"+E.id+" "+y.rtpSender.track.id+`\r
-`;r2+="a="+n2,r2+="a=ssrc:"+y.sendEncodingParameters[0].ssrc+" "+n2,y.sendEncodingParameters[0].rtx&&(r2+="a=ssrc:"+y.sendEncodingParameters[0].rtx.ssrc+" "+n2,r2+="a=ssrc-group:FID "+y.sendEncodingParameters[0].ssrc+" "+y.sendEncodingParameters[0].rtx.ssrc+`\r
-`)}return r2+="a=ssrc:"+y.sendEncodingParameters[0].ssrc+" cname:"+f.localCName+`\r
-`,y.rtpSender&&y.sendEncodingParameters[0].rtx&&(r2+="a=ssrc:"+y.sendEncodingParameters[0].rtx.ssrc+" cname:"+f.localCName+`\r
-`),r2},f.getDirection=function(y,w){for(var _=f.splitLines(y),E=0;E<_.length;E++)switch(_[E]){case"a=sendrecv":case"a=sendonly":case"a=recvonly":case"a=inactive":return _[E].substr(2)}return w?f.getDirection(w):"sendrecv"},f.getKind=function(y){var w=f.splitLines(y),_=w[0].split(" ");return _[0].substr(2)},f.isRejected=function(y){return y.split(" ",2)[1]==="0"},f.parseMLine=function(y){var w=f.splitLines(y),_=w[0].substr(2).split(" ");return{kind:_[0],port:parseInt(_[1],10),protocol:_[2],fmt:_.slice(3).join(" ")}},f.parseOLine=function(y){var w=f.matchPrefix(y,"o=")[0],_=w.substr(2).split(" ");return{username:_[0],sessionId:_[1],sessionVersion:parseInt(_[2],10),netType:_[3],addressType:_[4],address:_[5]}},f.isValidSDP=function(y){if(typeof y!="string"||y.length===0)return!1;for(var w=f.splitLines(y),_=0;_=26&&R<=M?!0:O.extension.isInstalled()}else return!0};var U1={extensionId:"hapfgfdkleiggjjpfpenajgdnfckjpaj",isInstalled:function(){return document.querySelector("#janus-extension-installed")!==null},getScreen:function(M){var d=window.setTimeout(function(){var f=new Error("NavigatorUserMediaError");return f.name='The required Chrome extension is not installed: click here to install it. (NOTE: this will need you to refresh the page)',M(f)},1e3);this.cache[d]=M,window.postMessage({type:"janusGetScreen",id:d},"*")},init:function(){var M={};this.cache=M,window.addEventListener("message",function(d){if(d.origin==window.location.origin)if(d.data.type=="janusGotScreen"&&M[d.data.id]){var f=M[d.data.id];if(delete M[d.data.id],d.data.sourceId===""){var y=new Error("NavigatorUserMediaError");y.name="You cancelled the request for permission, giving up...",f(y)}else f(null,d.data.sourceId)}else d.data.type=="janusGetScreenPending"&&(console.log("clearing ",d.data.id),window.clearTimeout(d.data.id))})}};O.useDefaultDependencies=function(R){var M=R&&R.fetch||fetch,d=R&&R.Promise||Promise,f=R&&R.WebSocket||WebSocket;return{newWebSocket:function(w,_){return new f(w,_)},extension:R&&R.extension||U1,isArray:function(w){return Array.isArray(w)},webRTCAdapter:R&&R.adapter||window.adapter,httpAPICall:function(w,_){var E={method:_.verb,headers:{Accept:"application/json, text/plain, */*"},cache:"no-cache"};_.verb==="POST"&&(E.headers["Content-Type"]="application/json"),_.withCredentials!==void 0&&(E.credentials=_.withCredentials===!0?"include":_.withCredentials?_.withCredentials:"omit"),_.body!==void 0&&(E.body=JSON.stringify(_.body));var r2=M(w,E).catch(function(o2){return d.reject({message:"Probably a network error, is the server down?",error:o2})});if(_.timeout!==void 0){var n2=new d(function(o2,t2){var X=setTimeout(function(){return clearTimeout(X),t2({message:"Request timed out",timeout:_.timeout})},_.timeout)});r2=d.race([r2,n2])}return r2.then(function(o2){if(o2.ok){if(n(_.success)===n(O.noop))return o2.json().then(function(t2){_.success(t2)}).catch(function(t2){return d.reject({message:"Failed to parse response body",error:t2,response:o2})})}else return d.reject({message:"API call failed",response:o2})}).catch(function(o2){n(_.error)===n(O.noop)&&_.error(o2.message||"<< internal error >>",o2)}),r2}}},O.useOldDependencies=function(R){var M=R&&R.jQuery||jQuery,d=R&&R.WebSocket||WebSocket;return{newWebSocket:function(y,w){return new d(y,w)},isArray:function(y){return M.isArray(y)},extension:R&&R.extension||U1,webRTCAdapter:R&&R.adapter||adapter,httpAPICall:function(y,w){var _=w.body!==void 0?{contentType:"application/json",data:JSON.stringify(w.body)}:{},E=w.withCredentials!==void 0?{xhrFields:{withCredentials:w.withCredentials}}:{};return M.ajax(M.extend(_,E,{url:y,type:w.verb,cache:!1,dataType:"json",async:w.async,timeout:w.timeout,success:function(n2){n(w.success)===n(O.noop)&&w.success(n2)},error:function(n2,o2,t2){n(w.error)===n(O.noop)&&w.error(o2,t2)}}))}}},O.noop=function(){},O.dataChanDefaultLabel="JanusDataChannel",O.endOfCandidates=null,O.init=function(R){if(R=R||{},R.callback=typeof R.callback=="function"?R.callback:O.noop,O.initDone===!0)R.callback();else{if((typeof console=="undefined"||typeof console.log=="undefined")&&(console={log:function(){}}),O.trace=O.noop,O.debug=O.noop,O.vdebug=O.noop,O.log=O.noop,O.warn=O.noop,O.error=O.noop,R.debug===!0||R.debug==="all")O.trace=console.trace.bind(console),O.debug=console.debug.bind(console),O.vdebug=console.debug.bind(console),O.log=console.log.bind(console),O.warn=console.warn.bind(console),O.error=console.error.bind(console);else if(Array.isArray(R.debug))for(var M in R.debug){var d=R.debug[M];switch(d){case"trace":O.trace=console.trace.bind(console);break;case"debug":O.debug=console.debug.bind(console);break;case"vdebug":O.vdebug=console.debug.bind(console);break;case"log":O.log=console.log.bind(console);break;case"warn":O.warn=console.warn.bind(console);break;case"error":O.error=console.error.bind(console);break;default:console.error("Unknown debugging option '"+d+"' (supported: 'trace', 'debug', 'vdebug', 'log', warn', 'error')");break}}O.log("Initializing library");var f=R.dependencies||O.useDefaultDependencies();O.isArray=f.isArray,O.webRTCAdapter=f.webRTCAdapter,O.httpAPICall=f.httpAPICall,O.newWebSocket=f.newWebSocket,O.extension=f.extension,O.extension.init(),O.listDevices=function(o2,t2){o2=typeof o2=="function"?o2:O.noop,t2==null&&(t2={audio:!0,video:!0}),O.isGetUserMediaAvailable()?navigator.mediaDevices.getUserMedia(t2).then(function(X){navigator.mediaDevices.enumerateDevices().then(function(R2){O.debug(R2),o2(R2);try{var y2=X.getTracks();for(var d2 in y2){var h2=y2[d2];h2!=null&&h2.stop()}}catch(B2){}})}).catch(function(X){O.error(X),o2([])}):(O.warn("navigator.mediaDevices unavailable"),o2([]))},O.attachMediaStream=function(o2,t2){if(O.webRTCAdapter.browserDetails.browser==="chrome"){var X=O.webRTCAdapter.browserDetails.version;X>=52?o2.srcObject=t2:O.error("Error attaching stream to element")}else o2.srcObject=t2},O.reattachMediaStream=function(o2,t2){if(O.webRTCAdapter.browserDetails.browser==="chrome"){var X=O.webRTCAdapter.browserDetails.version;X>=52?o2.srcObject=t2.srcObject:typeof o2.src!="undefined"?o2.src=t2.src:O.error("Error reattaching stream to element")}else o2.srcObject=t2.srcObject};var y=["iPad","iPhone","iPod"].indexOf(navigator.platform)>=0,w=y?"pagehide":"beforeunload",_=window["on"+w];if(window.addEventListener(w,function(o2){O.log("Closing window");for(var t2 in O.sessions)O.sessions[t2]!==null&&O.sessions[t2]!==void 0&&O.sessions[t2].destroyOnUnload&&(O.log("Destroying session "+t2),O.sessions[t2].destroy({asyncRequest:!1,notifyDestroyed:!1}));_&&typeof _=="function"&&_()}),O.safariVp8=!1,O.webRTCAdapter.browserDetails.browser==="safari"&&O.webRTCAdapter.browserDetails.version>=605)if(RTCRtpSender&&RTCRtpSender.getCapabilities&&RTCRtpSender.getCapabilities("video")&&RTCRtpSender.getCapabilities("video").codecs&&RTCRtpSender.getCapabilities("video").codecs.length){for(var M in RTCRtpSender.getCapabilities("video").codecs){var E=RTCRtpSender.getCapabilities("video").codecs[M];if(E&&E.mimeType&&E.mimeType.toLowerCase()==="video/vp8"){O.safariVp8=!0;break}}O.safariVp8?O.log("This version of Safari supports VP8"):O.warn("This version of Safari does NOT support VP8: if you're using a Technology Preview, try enabling the 'WebRTC VP8 codec' setting in the 'Experimental Features' Develop menu")}else{var r2=new RTCPeerConnection({},{});r2.createOffer({offerToReceiveVideo:!0}).then(function(o2){O.safariVp8=o2.sdp.indexOf("VP8")!==-1,O.safariVp8?O.log("This version of Safari supports VP8"):O.warn("This version of Safari does NOT support VP8: if you're using a Technology Preview, try enabling the 'WebRTC VP8 codec' setting in the 'Experimental Features' Develop menu"),r2.close(),r2=null})}if(O.unifiedPlan=!1,O.webRTCAdapter.browserDetails.browser==="firefox"&&O.webRTCAdapter.browserDetails.version>=59)O.unifiedPlan=!0;else if(O.webRTCAdapter.browserDetails.browser==="chrome"&&O.webRTCAdapter.browserDetails.version<72)O.unifiedPlan=!1;else if(typeof RTCRtpTransceiver!="undefined"&&!("currentDirection"in RTCRtpTransceiver.prototype))O.unifiedPlan=!1;else{var n2=new RTCPeerConnection;try{n2.addTransceiver("audio"),O.unifiedPlan=!0}catch(o2){}n2.close()}O.initDone=!0,R.callback()}},O.isWebrtcSupported=function(){return window.RTCPeerConnection!==void 0&&window.RTCPeerConnection!==null},O.isGetUserMediaAvailable=function(){return navigator.mediaDevices!==void 0&&navigator.mediaDevices!==null&&navigator.mediaDevices.getUserMedia!==void 0&&navigator.mediaDevices.getUserMedia!==null},O.randomString=function(R){for(var M="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",d="",f=0;f3){A=!1,R.error("Lost connection to the server (is it down?)");return}V2()}})}}function l3(T,D){if(I2=0,!M&&V!==void 0&&V!==null&&D!==!0&&V2(),!M&&O.isArray(T)){for(var W=0;W data channel: "+b2),b2==="open"){if(S2.dataChannel[U].pending&&S2.dataChannel[U].pending.length>0){O.log("Sending pending messages on <"+U+">:",S2.dataChannel[U].pending.length);for(var o3 in S2.dataChannel[U].pending){var Z2=S2.dataChannel[U].pending[o3];O.log("Sending string on data channel <"+U+">: "+Z2),S2.dataChannel[U].send(Z2)}S2.dataChannel[U].pending=[]}Y.ondataopen(U)}},r3=function(N){O.error("Got error on data channel:",N)};W?S2.dataChannel[D]=W:S2.dataChannel[D]=S2.pc.createDataChannel(D,{ordered:!1}),S2.dataChannel[D].onmessage=C2,S2.dataChannel[D].onopen=U2,S2.dataChannel[D].onclose=U2,S2.dataChannel[D].onerror=r3,S2.dataChannel[D].pending=[],G&&S2.dataChannel[D].pending.push(G)}function v1(T,D){D=D||{},D.success=typeof D.success=="function"?D.success:O.noop,D.error=typeof D.error=="function"?D.error:O.noop;var W=Z[T];if(W==null||W.webrtcStuff===null||W.webrtcStuff===void 0){O.warn("Invalid handle"),D.error("Invalid handle");return}var G=W.webrtcStuff,Y=D.text;if(Y==null){O.warn("Invalid text"),D.error("Invalid text");return}var S2=D.label?D.label:O.dataChanDefaultLabel;if(!G.dataChannel[S2]){B1(T,S2,!1,Y),D.success();return}if(G.dataChannel[S2].readyState!=="open"){G.dataChannel[S2].pending.push(Y),D.success();return}O.log("Sending string on data channel <"+S2+">: "+Y),G.dataChannel[S2].send(Y),D.success()}function Y1(T,D){D=D||{},D.success=typeof D.success=="function"?D.success:O.noop,D.error=typeof D.error=="function"?D.error:O.noop;var W=Z[T];if(W==null||W.webrtcStuff===null||W.webrtcStuff===void 0){O.warn("Invalid handle"),D.error("Invalid handle");return}var G=W.webrtcStuff;if(G.dtmfSender===null||G.dtmfSender===void 0){if(G.pc!==void 0&&G.pc!==null){var Y=G.pc.getSenders(),S2=Y.find(function(N){return N.track&&N.track.kind==="audio"});if(!S2){O.warn("Invalid DTMF configuration (no audio track)"),D.error("Invalid DTMF configuration (no audio track)");return}G.dtmfSender=S2.dtmf,G.dtmfSender&&(O.log("Created DTMF Sender"),G.dtmfSender.ontonechange=function(N){O.debug("Sent DTMF tone: "+N.tone)})}if(G.dtmfSender===null||G.dtmfSender===void 0){O.warn("Invalid DTMF configuration"),D.error("Invalid DTMF configuration");return}}var C2=D.dtmf;if(C2==null){O.warn("Invalid DTMF parameters"),D.error("Invalid DTMF parameters");return}var U2=C2.tones;if(U2==null){O.warn("Invalid DTMF string"),D.error("Invalid DTMF string");return}var r3=C2.duration;r3==null&&(r3=500);var P=C2.gap;P==null&&(P=50),O.debug("Sending DTMF string "+U2+" (duration "+r3+"ms, gap "+P+"ms)"),G.dtmfSender.insertDTMF(U2,r3,P),D.success()}function g0(T,D){D=D||{},D.success=typeof D.success=="function"?D.success:O.noop,D.error=typeof D.error=="function"?D.error:O.noop;var W=!0;D.asyncRequest!==void 0&&D.asyncRequest!==null&&(W=D.asyncRequest===!0);var G=!0;D.noRequest!==void 0&&D.noRequest!==null&&(G=D.noRequest===!0),O.log("Destroying handle "+T+" (async="+W+")"),le(T);var Y=Z[T];if(Y==null||Y.detached){delete Z[T],D.success();return}if(G){delete Z[T],D.success();return}if(!A){O.warn("Is the server down? (connected=false)"),D.error("Is the server down? (connected=false)");return}var S2={rtcgw:"detach",transaction:O.randomString(12)};if(Y.token!==null&&Y.token!==void 0&&(S2.token=Y.token),d2!=null&&(S2.apisecret=d2),M){S2.session_id=V,S2.handle_id=T,d.send(JSON.stringify(S2)),delete Z[T],D.success();return}O.httpAPICall(E+"/"+V+"/"+T,{verb:"POST",async:W,withCredentials:X,body:S2,success:function(U2){O.log("Destroyed handle:"),O.debug(U2),U2.rtcgw!=="success"&&O.error("Ooops: "+U2.error.code+" "+U2.error.reason),delete Z[T],D.success()},error:function(U2,r3){O.error(U2+":",r3),delete Z[T],D.success()}})}function E2(T,D,W,G,Y){var S2=Z[T];if(S2==null||S2.webrtcStuff===null||S2.webrtcStuff===void 0){O.warn("Invalid handle"),G.error("Invalid handle");return}var C2=S2.webrtcStuff;O.debug("streamsDone:",Y),Y&&(O.debug(" -- Audio tracks:",Y.getAudioTracks()),O.debug(" -- Video tracks:",Y.getVideoTracks()));var U2=!1;if(!C2.myStream||!W.update||C2.streamExternal)C2.myStream=Y,U2=!0;else{if((!W.update&&M1(W)||W.update&&(W.addAudio||W.replaceAudio))&&Y.getAudioTracks()&&Y.getAudioTracks().length)if(C2.myStream.addTrack(Y.getAudioTracks()[0]),O.unifiedPlan){O.log((W.replaceAudio?"Replacing":"Adding")+" audio track:",Y.getAudioTracks()[0]);var r3=null,P=C2.pc.getTransceivers();if(P&&P.length>0)for(var N in P){var U=P[N];if(U.sender&&U.sender.track&&U.sender.track.kind==="audio"||U.receiver&&U.receiver.track&&U.receiver.track.kind==="audio"){r3=U;break}}r3&&r3.sender?r3.sender.replaceTrack(Y.getAudioTracks()[0]):C2.pc.addTrack(Y.getAudioTracks()[0],Y)}else O.log((W.replaceAudio?"Replacing":"Adding")+" audio track:",Y.getAudioTracks()[0]),C2.pc.addTrack(Y.getAudioTracks()[0],Y);if((!W.update&&G2(W)||W.update&&(W.addVideo||W.replaceVideo))&&Y.getVideoTracks()&&Y.getVideoTracks().length)if(C2.myStream.addTrack(Y.getVideoTracks()[0]),O.unifiedPlan){O.log((W.replaceVideo?"Replacing":"Adding")+" video track:",Y.getVideoTracks()[0]);var b2=null,P=C2.pc.getTransceivers();if(P&&P.length>0)for(var N in P){var U=P[N];if(U.sender&&U.sender.track&&U.sender.track.kind==="video"||U.receiver&&U.receiver.track&&U.receiver.track.kind==="video"){b2=U;break}}b2&&b2.sender?b2.sender.replaceTrack(Y.getVideoTracks()[0]):C2.pc.addTrack(Y.getVideoTracks()[0],Y)}else O.log((W.replaceVideo?"Replacing":"Adding")+" video track:",Y.getVideoTracks()[0]),C2.pc.addTrack(Y.getVideoTracks()[0],Y)}if(!C2.pc){var o3={iceServers:r2,iceTransportPolicy:n2,bundlePolicy:o2};O.webRTCAdapter.browserDetails.browser==="chrome"&&(o3.sdpSemantics=O.webRTCAdapter.browserDetails.version<72?"plan-b":"unified-plan");var Z2={optional:[{DtlsSrtpKeyAgreement:!0}]};if(t2===!0&&Z2.optional.push({googIPv6:!0}),G.rtcConstraints&&n(G.rtcConstraints)==="object"){O.debug("Adding custom PeerConnection constraints:",G.rtcConstraints);for(var N in G.rtcConstraints)Z2.optional.push(G.rtcConstraints[N])}O.webRTCAdapter.browserDetails.browser==="edge"&&(o3.bundlePolicy="max-bundle"),O.log("Creating PeerConnection"),O.debug(Z2),C2.pc=new RTCPeerConnection(o3,Z2),O.debug(C2.pc),C2.pc.getStats&&(C2.volume={},C2.bitrate.value="0 kbits/sec"),O.log("Preparing local SDP and gathering candidates (trickle="+C2.trickle+")"),C2.pc.oniceconnectionstatechange=function(X2){C2.pc&&S2.iceState(C2.pc.iceConnectionState)},C2.pc.onicecandidate=function(X2){if(X2.candidate==null||O.webRTCAdapter.browserDetails.browser==="edge"&&X2.candidate.candidate.indexOf("endOfCandidates")>0)O.log("End of candidates."),C2.iceDone=!0,C2.trickle===!0?x1(T,{completed:!0}):L1(T,G);else{var e1={candidate:X2.candidate.candidate,sdpMid:X2.candidate.sdpMid,sdpMLineIndex:X2.candidate.sdpMLineIndex};C2.trickle===!0&&x1(T,e1)}},C2.pc.ontrack=function(X2){O.log("Handling Remote Track"),O.debug(X2),X2.streams&&(C2.remoteStream=X2.streams[0],S2.onremotestream(C2.remoteStream),!X2.track.onended&&(O.log("Adding onended callback to track:",X2.track),X2.track.onended=function(e1){O.log("Remote track muted/removed:",e1),C2.remoteStream&&(C2.remoteStream.removeTrack(e1.target),S2.onremotestream(C2.remoteStream))},X2.track.onmute=X2.track.onended,X2.track.onunmute=function(e1){O.log("Remote track flowing again:",e1);try{C2.remoteStream.addTrack(e1.target),S2.onremotestream(C2.remoteStream)}catch(i0){O.error(i0)}}))}}if(U2&&Y!==null&&Y!==void 0){O.log("Adding local stream");var J=G.simulcast2===!0;Y.getTracks().forEach(function(X2){if(O.log("Adding local track:",X2),!J)C2.pc.addTrack(X2,Y);else if(X2.kind==="audio")C2.pc.addTrack(X2,Y);else{O.log("Enabling rid-based simulcasting:",X2);var e1=u2(G.simulcastMaxBitrates);C2.pc.addTransceiver(X2,{direction:"sendrecv",streams:[Y],sendEncodings:[{rid:"h",active:!0,maxBitrate:e1.high},{rid:"m",active:!0,maxBitrate:e1.medium,scaleResolutionDownBy:2},{rid:"l",active:!0,maxBitrate:e1.low,scaleResolutionDownBy:4}]})}})}C(W)&&!C2.dataChannel[O.dataChanDefaultLabel]&&(O.log("Creating data channel"),B1(T,O.dataChanDefaultLabel,!1),C2.pc.ondatachannel=function(X2){O.log("Data channel created by Janus:",X2),B1(T,X2.channel.label,X2.channel)}),C2.myStream&&S2.onlocalstream(C2.myStream),D==null?V3(T,W,G):C2.pc.setRemoteDescription(D).then(function(){if(O.log("Remote description accepted!"),C2.remoteSdp=D.sdp,C2.candidates&&C2.candidates.length>0){for(var X2=0;X2=26&&it<=Sn?(J={video:{mandatory:{googLeakyBucket:!0,maxWidth:window.screen.width,maxHeight:window.screen.height,minFrameRate:Y.screenshareFrameRate,maxFrameRate:Y.screenshareFrameRate,chromeMediaSource:"screen"}},audio:M1(Y)&&!Y.keepAudio},gt(J,me)):O.extension.getScreen(function(s2,x2){if(s2)return S2.consentDialog(!1),W.error(s2);J={audio:!1,video:{mandatory:{chromeMediaSource:"desktop",maxWidth:window.screen.width,maxHeight:window.screen.height,minFrameRate:Y.screenshareFrameRate,maxFrameRate:Y.screenshareFrameRate},optional:[{googLeakyBucket:!0},{googTemporalLayeredScreencast:!0}]}},J.video.mandatory.chromeMediaSourceId=x2,gt(J,me,M1(Y)&&!Y.keepAudio)})}else if(O.webRTCAdapter.browserDetails.browser==="firefox")if(O.webRTCAdapter.browserDetails.version>=33)J={video:{mozMediaSource:Y.video,mediaSource:Y.video},audio:M1(Y)&&!Y.keepAudio},gt(J,function(s2,x2){if(me(s2,x2),!s2)var z2=x2.currentTime,M3=window.setInterval(function(){x2||window.clearInterval(M3),x2.currentTime==z2&&(window.clearInterval(M3),x2.onended&&x2.onended()),z2=x2.currentTime},500)});else{var q=new Error("NavigatorUserMediaError");q.name="Your version of Firefox does not support screen sharing, please install Firefox 33 (or more recent versions)",S2.consentDialog(!1),W.error(q);return}return}}(Y==null||Y.video!=="screen")&&navigator.mediaDevices.enumerateDevices().then(function(s2){var x2=s2.some(function(K1){return K1.kind==="audioinput"}),z2=R3(Y)||s2.some(function(K1){return K1.kind==="videoinput"}),M3=M1(Y),t1=G2(Y),b1=B(Y),p1=J3(Y);if(M3||t1||b1||p1){var H1=M3?x2:!1,A0=t1?z2:!1;if(!H1&&!A0)return S2.consentDialog(!1),W.error("No capture device found"),!1;if(!H1&&b1)return S2.consentDialog(!1),W.error("Audio capture is required, but no capture device found"),!1;if(!A0&&p1)return S2.consentDialog(!1),W.error("Video capture is required, but no capture device found"),!1}var v0={audio:x2&&!Y.keepAudio?X2:!1,video:z2&&!Y.keepVideo?e1:!1};O.debug("getUserMedia constraints",v0),!v0.audio&&!v0.video?(S2.consentDialog(!1),E2(T,G,Y,W,U)):navigator.mediaDevices.getUserMedia(v0).then(function(K1){S2.consentDialog(!1),E2(T,G,Y,W,K1)}).catch(function(K1){S2.consentDialog(!1),W.error({code:K1.code,name:K1.name,message:K1.message})})}).catch(function(s2){S2.consentDialog(!1),W.error("enumerateDevices error",s2)})}else E2(T,G,Y,W)}function g3(T,D){D=D||{},D.success=typeof D.success=="function"?D.success:O.noop,D.error=typeof D.error=="function"?D.error:ke;var W=D.jsep,G=Z[T];if(G==null||G.webrtcStuff===null||G.webrtcStuff===void 0){O.warn("Invalid handle"),D.error("Invalid handle");return}var Y=G.webrtcStuff;if(W!=null){if(Y.pc===null){O.warn("Wait, no PeerConnection?? if this is an answer, use createAnswer and not handleRemoteJsep"),D.error("No PeerConnection: if this is an answer, use createAnswer and not handleRemoteJsep");return}Y.pc.setRemoteDescription(W).then(function(){if(O.log("Remote description accepted!"),Y.remoteSdp=W.sdp,Y.candidates&&Y.candidates.length>0){for(var S2=0;S20)for(var N in P){var U=P[N];if(U.sender&&U.sender.track&&U.sender.track.kind==="audio"||U.receiver&&U.receiver.track&&U.receiver.track.kind==="audio"){U2||(U2=U);continue}if(U.sender&&U.sender.track&&U.sender.track.kind==="video"||U.receiver&&U.receiver.track&&U.receiver.track.kind==="video"){r3||(r3=U);continue}}var b2=M1(D),o3=f2(D);!b2&&!o3?D.removeAudio&&U2&&(U2.setDirection?U2.setDirection("inactive"):U2.direction="inactive",O.log("Setting audio transceiver to inactive:",U2)):b2&&o3?U2&&(U2.setDirection?U2.setDirection("sendrecv"):U2.direction="sendrecv",O.log("Setting audio transceiver to sendrecv:",U2)):b2&&!o3?U2&&(U2.setDirection?U2.setDirection("sendonly"):U2.direction="sendonly",O.log("Setting audio transceiver to sendonly:",U2)):!b2&&o3&&(U2?(U2.setDirection?U2.setDirection("recvonly"):U2.direction="recvonly",O.log("Setting audio transceiver to recvonly:",U2)):(U2=Y.pc.addTransceiver("audio",{direction:"recvonly"}),O.log("Adding recvonly audio transceiver:",U2)));var Z2=G2(D),J=$3(D);!Z2&&!J?D.removeVideo&&r3&&(r3.setDirection?r3.setDirection("inactive"):r3.direction="inactive",O.log("Setting video transceiver to inactive:",r3)):Z2&&J?r3&&(r3.setDirection?r3.setDirection("sendrecv"):r3.direction="sendrecv",O.log("Setting video transceiver to sendrecv:",r3)):Z2&&!J?r3&&(r3.setDirection?r3.setDirection("sendonly"):r3.direction="sendonly",O.log("Setting video transceiver to sendonly:",r3)):!Z2&&J&&(r3?(r3.setDirection?r3.setDirection("recvonly"):r3.direction="recvonly",O.log("Setting video transceiver to recvonly:",r3)):(r3=Y.pc.addTransceiver("video",{direction:"recvonly"}),O.log("Adding recvonly video transceiver:",r3)))}else C2.offerToReceiveAudio=f2(D),C2.offerToReceiveVideo=$3(D);var X2=W.iceRestart===!0;X2&&(C2.iceRestart=!0),O.debug(C2);var e1=G2(D);if(e1&&S2&&O.webRTCAdapter.browserDetails.browser==="firefox"){O.log("Enabling Simulcasting for Firefox (RID)");var i0=Y.pc.getSenders().find(function(y0){return y0.track.kind=="video"});if(i0){var I1=i0.getParameters();I1||(I1={});var V1=u2(W.simulcastMaxBitrates);I1.encodings=[{rid:"h",active:!0,maxBitrate:V1.high},{rid:"m",active:!0,maxBitrate:V1.medium,scaleResolutionDownBy:2},{rid:"l",active:!0,maxBitrate:V1.low,scaleResolutionDownBy:4}],i0.setParameters(I1)}}Y.pc.createOffer(C2).then(function(y0){O.debug(y0);var me={type:y0.type,sdp:y0.sdp};if(W.customizeSdp(me),y0.sdp=me.sdp,O.log("Setting local description"),e1&&S2&&(O.webRTCAdapter.browserDetails.browser==="chrome"||O.webRTCAdapter.browserDetails.browser==="safari"?(O.log("Enabling Simulcasting for Chrome (SDP munging)"),y0.sdp=ie(y0.sdp)):O.webRTCAdapter.browserDetails.browser!=="firefox"&&O.warn("simulcast=true, but this is not Chrome nor Firefox, ignoring")),Y.mySdp=y0.sdp,Y.pc.setLocalDescription(y0).catch(W.error),Y.mediaConstraints=C2,!Y.iceDone&&!Y.trickle){O.log("Waiting for all candidates...");return}O.log("Offer ready"),O.debug(W),W.success(y0)},W.error)}function h1(T,D,W){W=W||{},W.success=typeof W.success=="function"?W.success:O.noop,W.error=typeof W.error=="function"?W.error:O.noop,W.customizeSdp=typeof W.customizeSdp=="function"?W.customizeSdp:O.noop;var G=Z[T];if(G==null||G.webrtcStuff===null||G.webrtcStuff===void 0){O.warn("Invalid handle"),W.error("Invalid handle");return}var Y=G.webrtcStuff,S2=W.simulcast===!0;S2?O.log("Creating answer (iceDone="+Y.iceDone+", simulcast="+S2+")"):O.log("Creating answer (iceDone="+Y.iceDone+")");var C2=null;if(O.unifiedPlan){C2={};var U2=null,r3=null,P=Y.pc.getTransceivers();if(P&&P.length>0)for(var N in P){var U=P[N];if(U.sender&&U.sender.track&&U.sender.track.kind==="audio"||U.receiver&&U.receiver.track&&U.receiver.track.kind==="audio"){U2||(U2=U);continue}if(U.sender&&U.sender.track&&U.sender.track.kind==="video"||U.receiver&&U.receiver.track&&U.receiver.track.kind==="video"){r3||(r3=U);continue}}var b2=M1(D),o3=f2(D);if(!b2&&!o3){if(D.removeAudio&&U2)try{U2.setDirection?U2.setDirection("inactive"):U2.direction="inactive",O.log("Setting audio transceiver to inactive:",U2)}catch(V1){O.error(V1)}}else if(b2&&o3){if(U2)try{U2.setDirection?U2.setDirection("sendrecv"):U2.direction="sendrecv",O.log("Setting audio transceiver to sendrecv:",U2)}catch(V1){O.error(V1)}}else if(b2&&!o3)try{U2&&(U2.setDirection?U2.setDirection("sendonly"):U2.direction="sendonly",O.log("Setting audio transceiver to sendonly:",U2))}catch(V1){O.error(V1)}else if(!b2&&o3)if(U2)try{U2.setDirection?U2.setDirection("recvonly"):U2.direction="recvonly",O.log("Setting audio transceiver to recvonly:",U2)}catch(V1){O.error(V1)}else U2=Y.pc.addTransceiver("audio",{direction:"recvonly"}),O.log("Adding recvonly audio transceiver:",U2);var Z2=G2(D),J=$3(D);if(!Z2&&!J){if(D.removeVideo&&r3)try{r3.setDirection?r3.setDirection("inactive"):r3.direction="inactive",O.log("Setting video transceiver to inactive:",r3)}catch(V1){O.error(V1)}}else if(Z2&&J){if(r3)try{r3.setDirection?r3.setDirection("sendrecv"):r3.direction="sendrecv",O.log("Setting video transceiver to sendrecv:",r3)}catch(V1){O.error(V1)}}else if(Z2&&!J){if(r3)try{r3.setDirection?r3.setDirection("sendonly"):r3.direction="sendonly",O.log("Setting video transceiver to sendonly:",r3)}catch(V1){O.error(V1)}}else if(!Z2&&J)if(r3)try{r3.setDirection?r3.setDirection("recvonly"):r3.direction="recvonly",O.log("Setting video transceiver to recvonly:",r3)}catch(V1){O.error(V1)}else r3=Y.pc.addTransceiver("video",{direction:"recvonly"}),O.log("Adding recvonly video transceiver:",r3)}else O.webRTCAdapter.browserDetails.browser=="firefox"||O.webRTCAdapter.browserDetails.browser=="edge"?C2={offerToReceiveAudio:f2(D),offerToReceiveVideo:$3(D)}:C2={mandatory:{OfferToReceiveAudio:f2(D),OfferToReceiveVideo:$3(D)}};O.debug(C2);var X2=G2(D);if(X2&&S2&&O.webRTCAdapter.browserDetails.browser==="firefox"){O.log("Enabling Simulcasting for Firefox (RID)");var e1=Y.pc.getSenders()[1];O.log(e1);var i0=e1.getParameters();O.log(i0);var I1=u2(W.simulcastMaxBitrates);e1.setParameters({encodings:[{rid:"high",active:!0,priority:"high",maxBitrate:I1.high},{rid:"medium",active:!0,priority:"medium",maxBitrate:I1.medium},{rid:"low",active:!0,priority:"low",maxBitrate:I1.low}]})}Y.pc.createAnswer(C2).then(function(V1){O.debug(V1);var y0={type:V1.type,sdp:V1.sdp};if(W.customizeSdp(y0),V1.sdp=y0.sdp,O.log("Setting local description"),X2&&S2&&(O.webRTCAdapter.browserDetails.browser==="chrome"?O.warn("simulcast=true, but this is an answer, and video breaks in Chrome if we enable it"):O.webRTCAdapter.browserDetails.browser!=="firefox"&&O.warn("simulcast=true, but this is not Chrome nor Firefox, ignoring")),Y.mySdp=V1.sdp,Y.pc.setLocalDescription(V1).catch(W.error),Y.mediaConstraints=C2,!Y.iceDone&&!Y.trickle){O.log("Waiting for all candidates...");return}W.success(V1)},W.error)}function L1(T,D){D=D||{},D.success=typeof D.success=="function"?D.success:O.noop,D.error=typeof D.error=="function"?D.error:O.noop;var W=Z[T];if(W==null||W.webrtcStuff===null||W.webrtcStuff===void 0){O.warn("Invalid handle, not sending anything");return}var G=W.webrtcStuff;if(O.log("Sending offer/answer SDP..."),G.mySdp===null||G.mySdp===void 0){O.warn("Local SDP instance is invalid, not sending anything...");return}G.mySdp={type:G.pc.localDescription.type,sdp:G.pc.localDescription.sdp},G.trickle===!1&&(G.mySdp.trickle=!1),O.debug(D),G.sdpSent=!0,D.success(G.mySdp)}function D1(T,D){var W=Z[T];if(W==null||W.webrtcStuff===null||W.webrtcStuff===void 0)return O.warn("Invalid handle"),0;var G=D?"remote":"local",Y=W.webrtcStuff;return Y.volume[G]||(Y.volume[G]={value:0}),Y.pc.getStats&&O.webRTCAdapter.browserDetails.browser==="chrome"?D&&(Y.remoteStream===null||Y.remoteStream===void 0)?(O.warn("Remote stream unavailable"),0):!D&&(Y.myStream===null||Y.myStream===void 0)?(O.warn("Local stream unavailable"),0):Y.volume[G].timer===null||Y.volume[G].timer===void 0?(O.log("Starting "+G+" volume monitor"),Y.volume[G].timer=setInterval(function(){Y.pc.getStats(function(S2){for(var C2=S2.result(),U2=0;U2-1)&&Y.type==="inbound-rtp"&&Y.id.indexOf("rtcp")<0||Y.type=="ssrc"&&Y.bytesReceived&&(Y.googCodecName==="VP8"||Y.googCodecName===""))&&(S2=!0),S2)if(W.bitrate.bsnow=Y.bytesReceived,W.bitrate.tsnow=Y.timestamp,W.bitrate.bsbefore===null||W.bitrate.tsbefore===null)W.bitrate.bsbefore=W.bitrate.bsnow,W.bitrate.tsbefore=W.bitrate.tsnow;else{var C2=W.bitrate.tsnow-W.bitrate.tsbefore;O.webRTCAdapter.browserDetails.browser=="safari"&&(C2=C2/1e3);var U2=Math.round((W.bitrate.bsnow-W.bitrate.bsbefore)*8/C2);O.webRTCAdapter.browserDetails.browser==="safari"&&(U2=parseInt(U2/1e3)),W.bitrate.value=U2+" kbits/sec",W.bitrate.bsbefore=W.bitrate.bsnow,W.bitrate.tsbefore=W.bitrate.tsnow}}})})},1e3),"0 kbits/sec"):W.bitrate.value:(O.warn("Getting the video bitrate unsupported by browser"),"Feature unsupported by browser")}function ke(T){O.error("WebRTC error:",T)}function le(T,D){O.log("Cleaning WebRTC stuff");var W=Z[T];if(W!=null){var G=W.webrtcStuff;if(G!=null){if(D===!0){var Y={rtcgw:"hangup",transaction:O.randomString(12)};W.token!==null&&W.token!==void 0&&(Y.token=W.token),d2!=null&&(Y.apisecret=d2),O.debug("Sending hangup request (handle="+T+"):"),O.debug(Y),M?(Y.session_id=V,Y.handle_id=T,d.send(JSON.stringify(Y))):O.httpAPICall(E+"/"+V+"/"+T,{verb:"POST",withCredentials:X,body:Y})}G.remoteStream=null,G.volume&&(G.volume.local&&G.volume.local.timer&&clearInterval(G.volume.local.timer),G.volume.remote&&G.volume.remote.timer&&clearInterval(G.volume.remote.timer)),G.volume={},G.bitrate.timer&&clearInterval(G.bitrate.timer),G.bitrate.timer=null,G.bitrate.bsnow=null,G.bitrate.bsbefore=null,G.bitrate.tsnow=null,G.bitrate.tsbefore=null,G.bitrate.value=null;try{if(!G.streamExternal&&G.myStream!==null&&G.myStream!==void 0){O.log("Stopping local stream tracks");var S2=G.myStream.getTracks();for(var C2 in S2){var U2=S2[C2];O.log(U2),U2!=null&&U2.stop()}}}catch(r3){}G.streamExternal=!1,G.myStream=null;try{G.pc.close()}catch(r3){}G.pc=null,G.candidates=null,G.mySdp=null,G.remoteSdp=null,G.iceDone=!1,G.dataChannel={},G.dtmfSender=null}W.oncleanup()}}function ie(T){for(var D=T.split(`\r
-`),W=!1,G=[-1],Y=[-1],S2=null,C2=null,U2=null,r3=null,P=-1,N=0;N-1){P=N;break}continue}if(W){var o3=D[N].match(/a=ssrc-group:FID (\d+) (\d+)/);if(o3){G[0]=o3[1],Y[0]=o3[2],D.splice(N,1),N--;continue}if(G[0]){var Z2=D[N].match("a=ssrc:"+G[0]+" cname:(.+)");if(Z2&&(S2=Z2[1]),Z2=D[N].match("a=ssrc:"+G[0]+" msid:(.+)"),Z2&&(C2=Z2[1]),Z2=D[N].match("a=ssrc:"+G[0]+" mslabel:(.+)"),Z2&&(U2=Z2[1]),Z2=D[N].match("a=ssrc:"+G[0]+" label:(.+)"),Z2&&(r3=Z2[1]),D[N].indexOf("a=ssrc:"+Y[0])===0){D.splice(N,1),N--;continue}if(D[N].indexOf("a=ssrc:"+G[0])===0){D.splice(N,1),N--;continue}}if(D[N].length==0){D.splice(N,1),N--;continue}}}if(G[0]<0){P=-1,W=!1;for(var N=0;N-1){P=N;break}continue}if(W){if(G[0]<0){var J=D[N].match(/a=ssrc:(\d+)/);if(J){G[0]=J[1],D.splice(N,1),N--;continue}}else{var Z2=D[N].match("a=ssrc:"+G[0]+" cname:(.+)");if(Z2&&(S2=Z2[1]),Z2=D[N].match("a=ssrc:"+G[0]+" msid:(.+)"),Z2&&(C2=Z2[1]),Z2=D[N].match("a=ssrc:"+G[0]+" mslabel:(.+)"),Z2&&(U2=Z2[1]),Z2=D[N].match("a=ssrc:"+G[0]+" label:(.+)"),Z2&&(r3=Z2[1]),D[N].indexOf("a=ssrc:"+Y[0])===0){D.splice(N,1),N--;continue}if(D[N].indexOf("a=ssrc:"+G[0])===0){D.splice(N,1),N--;continue}}if(D[N].length==0){D.splice(N,1),N--;continue}}}}if(G[0]<0)return O.warn("Couldn't find the video SSRC, simulcasting NOT enabled"),T;P<0&&(P=D.length),G[1]=Math.floor(Math.random()*4294967295),G[2]=Math.floor(Math.random()*4294967295),Y[1]=Math.floor(Math.random()*4294967295),Y[2]=Math.floor(Math.random()*4294967295);for(var N=0;N
-
-
-
-
-
-
- `,document.getElementById("mobile-ez-ptz-item")||y.appendChild(E),g(y,document.getElementById("".concat(this.jSPlugin.id,"-wrap"))),document.getElementById("mobile-ez-ptz-item").ontouchstart=function(r2){r2.preventDefault(),console.log("触摸开始"),d._handlePtzTouch(r2,"start")},document.getElementById("mobile-ez-ptz-item").ontouchend=function(r2){r2.preventDefault(),console.log("触摸结束",r2),d._handlePtzTouch(r2,"stop")},document.getElementById("mobile-ez-ptz-item").onmousedown=function(r2){r2.preventDefault(),console.log("触摸开始"),d._handlePtzTouch(r2,"start")},document.getElementById("mobile-ez-ptz-item").onmouseup=function(r2){r2.preventDefault(),console.log("触摸结束",r2),d._handlePtzTouch(r2,"stop")}}return r(R,[{key:"show",value:function(){document.getElementById("mobile-ez-ptz-item").style="display: inline-block"}},{key:"hide",value:function(){document.getElementById("mobile-ez-ptz-item").style="display: none"}},{key:"_handlePtzTouch",value:function(d,f){var y=document.getElementById("mobile-ez-ptz-item").getBoundingClientRect(),w=y.left+130,_=y.top+130,E=d.x||d.changedTouches[0].clientX,r2=d.y||d.changedTouches[0].clientY,n2=E-w,o2=r2-_,t2=0,X=this.jSPlugin.env.domain+"/api/lapp/device/ptz/start";Math.abs(n2)>Math.abs(o2)?n2>0?(t2=3,document.getElementsByClassName("mobile-ez-ptz-icon")[3].className=document.getElementsByClassName("mobile-ez-ptz-icon")[3].className.replace("default","active")):(t2=2,document.getElementsByClassName("mobile-ez-ptz-icon")[1].className=document.getElementsByClassName("mobile-ez-ptz-icon")[1].className.replace("default","active")):o2>0?(t2=1,document.getElementsByClassName("mobile-ez-ptz-icon")[2].className=document.getElementsByClassName("mobile-ez-ptz-icon")[2].className.replace("default","active")):(t2=0,document.getElementsByClassName("mobile-ez-ptz-icon")[0].className=document.getElementsByClassName("mobile-ez-ptz-icon")[0].className.replace("default","active")),document.getElementById("mobile-ez-ptz-item").style="background-image:linear-gradient(".concat(t2===0?180:t2===1?0:t2===2?90:270,"deg, #c0ddf1 0%, rgba(100,143,252,0.00) 50%)"),f==="stop"&&(X=this.jSPlugin.env.domain+"/api/lapp/device/ptz/stop",document.getElementById("mobile-ez-ptz-item").style="",document.getElementsByClassName("mobile-ez-ptz-icon")[3].className=document.getElementsByClassName("mobile-ez-ptz-icon")[3].className.replace("active","default"),document.getElementsByClassName("mobile-ez-ptz-icon")[1].className=document.getElementsByClassName("mobile-ez-ptz-icon")[1].className.replace("active","default"),document.getElementsByClassName("mobile-ez-ptz-icon")[2].className=document.getElementsByClassName("mobile-ez-ptz-icon")[2].className.replace("active","default"),document.getElementsByClassName("mobile-ez-ptz-icon")[0].className=document.getElementsByClassName("mobile-ez-ptz-icon")[0].className.replace("active","default"));var R2=new FormData;R2.append("deviceSerial",v2(this.jSPlugin.url).deviceSerial),R2.append("channelNo",v2(this.jSPlugin.url).channelNo),R2.append("speed",1),R2.append("direction",t2),R2.append("accessToken",this.jSPlugin.accessToken),fetch(X,{method:"POST",body:R2}).then(function(y2){return y2.json()}).then(function(y2){y2.code==200||(y2.code==60005||y2.code==60002||y2.code==60003||y2.code==60004)&&(document.getElementById("mobile-ez-ptz-item").style="background-image:linear-gradient(".concat(t2===0?180:t2===1?0:t2===2?90:270,"deg, #f45656 0%, rgba(100,143,252,0.00) 50%)"))}).catch(function(y2){console.log("云台调用异常",y2)})}}]),R}(),e0=0,O2="成功",Y2={header:{color:"#FFFFFF",backgroundColor:"#000000",activeColor:"#1890FF",btnList:[{btnKey:"c1cbc1d4e86d49a0981f54beea95280a-f7896c8942c9476fb439370dd974f1c0-header-0",iconId:"deviceID",part:"left",defaultActive:0,isrender:0,themeId:"f7896c8942c9476fb439370dd974f1c0"},{btnKey:"c1cbc1d4e86d49a0981f54beea95280a-f7896c8942c9476fb439370dd974f1c0-header-1",iconId:"deviceName",part:"left",defaultActive:0,isrender:0,themeId:"f7896c8942c9476fb439370dd974f1c0"},{btnKey:"c1cbc1d4e86d49a0981f54beea95280a-f7896c8942c9476fb439370dd974f1c0-header-2",iconId:"cloudRec",part:"right",defaultActive:0,isrender:0,themeId:"f7896c8942c9476fb439370dd974f1c0"},{btnKey:"c1cbc1d4e86d49a0981f54beea95280a-f7896c8942c9476fb439370dd974f1c0-header-3",iconId:"rec",part:"right",defaultActive:0,isrender:0,themeId:"f7896c8942c9476fb439370dd974f1c0"}]},footer:{color:"#FFFFFF",backgroundColor:"rgb(0 0 0 / 0%)",activeColor:"#1890FF",btnList:[{btnKey:"c1cbc1d4e86d49a0981f54beea95280a-f7896c8942c9476fb439370dd974f1c0-footer-0",iconId:"play",part:"left",defaultActive:1,isrender:0,themeId:"f7896c8942c9476fb439370dd974f1c0"},{btnKey:"c1cbc1d4e86d49a0981f54beea95280a-f7896c8942c9476fb439370dd974f1c0-footer-1",iconId:"capturePicture",part:"left",defaultActive:0,isrender:0,themeId:"f7896c8942c9476fb439370dd974f1c0"},{btnKey:"c1cbc1d4e86d49a0981f54beea95280a-f7896c8942c9476fb439370dd974f1c0-footer-2",iconId:"sound",part:"left",defaultActive:0,isrender:0,themeId:"f7896c8942c9476fb439370dd974f1c0"},{btnKey:"c1cbc1d4e86d49a0981f54beea95280a-f7896c8942c9476fb439370dd974f1c0-footer-3",iconId:"pantile",part:"left",defaultActive:0,isrender:0,themeId:"f7896c8942c9476fb439370dd974f1c0"},{btnKey:"c1cbc1d4e86d49a0981f54beea95280a-f7896c8942c9476fb439370dd974f1c0-footer-4",iconId:"recordvideo",part:"left",defaultActive:0,isrender:0,themeId:"f7896c8942c9476fb439370dd974f1c0"},{btnKey:"c1cbc1d4e86d49a0981f54beea95280a-f7896c8942c9476fb439370dd974f1c0-footer-5",iconId:"talk",part:"left",defaultActive:0,isrender:0,themeId:"f7896c8942c9476fb439370dd974f1c0"},{btnKey:"c1cbc1d4e86d49a0981f54beea95280a-f7896c8942c9476fb439370dd974f1c0-footer-6",iconId:"hd",part:"right",defaultActive:0,isrender:0,themeId:"f7896c8942c9476fb439370dd974f1c0"},{btnKey:"c1cbc1d4e86d49a0981f54beea95280a-f7896c8942c9476fb439370dd974f1c0-footer-7",iconId:"webExpend",part:"right",defaultActive:0,isrender:0,themeId:"f7896c8942c9476fb439370dd974f1c0"},{btnKey:"c1cbc1d4e86d49a0981f54beea95280a-f7896c8942c9476fb439370dd974f1c0-footer-8",iconId:"expend",part:"right",defaultActive:0,isrender:0,themeId:"f7896c8942c9476fb439370dd974f1c0"}]}},s3={retcode:e0,msg:O2,data:Y2},G3={header:{color:"#FFFFFF",backgroundColor:"#000000",activeColor:"#1890FF",btnList:[{iconId:"deviceID",part:"left",defaultActive:0,isrender:1},{iconId:"deviceName",part:"left",defaultActive:0,isrender:1},{iconId:"cloudRec",part:"right",defaultActive:0,isrender:0},{iconId:"rec",part:"right",defaultActive:0,isrender:0}]},footer:{color:"#FFFFFF",backgroundColor:"#00000080",activeColor:"#1890FF",btnList:[{iconId:"play",part:"left",defaultActive:1,isrender:1},{iconId:"capturePicture",part:"left",defaultActive:0,isrender:0},{iconId:"sound",part:"left",defaultActive:1,isrender:1},{iconId:"pantile",part:"left",defaultActive:0,isrender:1},{iconId:"recordvideo",part:"left",defaultActive:0,isrender:0},{iconId:"talk",part:"left",defaultActive:0,isrender:1},{iconId:"zoom",part:"left",defaultActive:0,isrender:1},{iconId:"hd",part:"right",defaultActive:0,isrender:1},{iconId:"webExpend",part:"right",defaultActive:0,isrender:0},{iconId:"expend",part:"right",defaultActive:0,isrender:1}]}},i1={data:G3},N1={header:{color:"#FFFFFF",backgroundColor:"#000000",activeColor:"#1890FF",btnList:[{iconId:"deviceID",part:"left",defaultActive:0,isrender:1},{iconId:"deviceName",part:"left",defaultActive:0,isrender:1},{iconId:"cloudRec",part:"right",defaultActive:0,isrender:1},{iconId:"rec",part:"right",defaultActive:0,isrender:1}]},footer:{color:"#FFFFFF",backgroundColor:"#00000080",activeColor:"#1890FF",btnList:[{iconId:"play",part:"left",defaultActive:1,isrender:1},{iconId:"capturePicture",part:"left",defaultActive:0,isrender:0},{iconId:"sound",part:"left",defaultActive:1,isrender:1},{iconId:"pantile",part:"left",defaultActive:0,isrender:0},{iconId:"recordvideo",part:"left",defaultActive:0,isrender:0},{iconId:"talk",part:"left",defaultActive:0,isrender:0},{iconId:"zoom",part:"left",defaultActive:0,isrender:1},{iconId:"speed",part:"right",defaultActive:0,isrender:1},{iconId:"hd",part:"right",defaultActive:0,isrender:0},{iconId:"webExpend",part:"right",defaultActive:0,isrender:0},{iconId:"expend",part:"right",defaultActive:0,isrender:1}]}},q1={data:N1},Y3={header:{color:"#FFFFFF",backgroundColor:"#000000",activeColor:"#1890FF",btnList:[{btnKey:"c1cbc1d4e86d49a0981f54beea95280a-f7896c8942c9476fb439370dd974f1c0-header-0",iconId:"deviceID",part:"left",defaultActive:0,isrender:1},{btnKey:"c1cbc1d4e86d49a0981f54beea95280a-f7896c8942c9476fb439370dd974f1c0-header-1",iconId:"deviceName",part:"left",defaultActive:0,isrender:1},{btnKey:"c1cbc1d4e86d49a0981f54beea95280a-f7896c8942c9476fb439370dd974f1c0-header-2",iconId:"cloudRec",part:"right",defaultActive:0,isrender:0},{btnKey:"c1cbc1d4e86d49a0981f54beea95280a-f7896c8942c9476fb439370dd974f1c0-header-3",iconId:"rec",part:"right",defaultActive:0,isrender:0}]},footer:{color:"#FFFFFF",backgroundColor:"#00000080",activeColor:"#1890FF",btnList:[{iconId:"play",part:"left",defaultActive:1,isrender:1},{iconId:"capturePicture",part:"left",defaultActive:0,isrender:1},{iconId:"sound",part:"left",defaultActive:1,isrender:1},{iconId:"pantile",part:"left",defaultActive:0,isrender:1},{iconId:"recordvideo",part:"left",defaultActive:0,isrender:1},{iconId:"talk",part:"left",defaultActive:0,isrender:1},{iconId:"zoom",part:"left",defaultActive:0,isrender:1},{iconId:"speed",part:"right",defaultActive:0,isrender:0},{iconId:"hd",part:"right",defaultActive:0,isrender:1},{iconId:"webExpend",part:"right",defaultActive:0,isrender:1},{iconId:"expend",part:"right",defaultActive:0,isrender:1}]}},r1={data:Y3},K3={header:{color:"#FFFFFF",backgroundColor:"#000000",activeColor:"#1890FF",btnList:[{btnKey:"c1cbc1d4e86d49a0981f54beea95280a-f7896c8942c9476fb439370dd974f1c0-header-0",iconId:"deviceID",part:"left",defaultActive:0,isrender:1},{btnKey:"c1cbc1d4e86d49a0981f54beea95280a-f7896c8942c9476fb439370dd974f1c0-header-1",iconId:"deviceName",part:"left",defaultActive:0,isrender:1},{btnKey:"c1cbc1d4e86d49a0981f54beea95280a-f7896c8942c9476fb439370dd974f1c0-header-2",iconId:"cloudRec",part:"right",defaultActive:0,isrender:0},{btnKey:"c1cbc1d4e86d49a0981f54beea95280a-f7896c8942c9476fb439370dd974f1c0-header-3",iconId:"rec",part:"right",defaultActive:0,isrender:0}]},footer:{color:"#FFFFFF",backgroundColor:"#00000080",activeColor:"#1890FF",btnList:[{iconId:"play",part:"left",defaultActive:1,isrender:1},{iconId:"talk",part:"left",defaultActive:0,isrender:1},{iconId:"sound",part:"left",defaultActive:1,isrender:1},{iconId:"capturePicture",part:"left",defaultActive:0,isrender:1},{iconId:"recordvideo",part:"left",defaultActive:0,isrender:1},{iconId:"pantile",part:"left",defaultActive:0,isrender:0},{iconId:"zoom",part:"left",defaultActive:0,isrender:1},{iconId:"hd",part:"right",defaultActive:0,isrender:1},{iconId:"webExpend",part:"right",defaultActive:0,isrender:0},{iconId:"expend",part:"right",defaultActive:0,isrender:1}]}},f1={data:K3},W1={header:{color:"#FFFFFF",backgroundColor:"#000000",activeColor:"#1890FF",btnList:[{iconId:"deviceID",part:"left",defaultActive:0,isrender:0},{iconId:"deviceName",part:"left",defaultActive:0,isrender:0},{iconId:"cloudRec",part:"right",defaultActive:0,isrender:0},{iconId:"rec",part:"right",defaultActive:0,isrender:0}]},footer:{color:"#FFFFFF",backgroundColor:"#000000",activeColor:"#1890FF",btnList:[{iconId:"play",part:"left",defaultActive:1,isrender:0},{iconId:"capturePicture",part:"left",defaultActive:0,isrender:0},{iconId:"sound",part:"left",defaultActive:1,isrender:0},{iconId:"pantile",part:"left",defaultActive:0,isrender:0},{iconId:"recordvideo",part:"left",defaultActive:0,isrender:0},{iconId:"talk",part:"left",defaultActive:0,isrender:0},{iconId:"zoom",part:"left",defaultActive:0,isrender:0},{iconId:"hd",part:"right",defaultActive:0,isrender:0},{iconId:"webExpend",part:"right",defaultActive:0,isrender:0},{iconId:"expend",part:"right",defaultActive:0,isrender:0}]}},T0={data:W1},O0={header:{color:"#FFFFFF",backgroundColor:"#000000",activeColor:"#1890FF",btnList:[{iconId:"deviceID",part:"left",defaultActive:0,isrender:1},{iconId:"deviceName",part:"left",defaultActive:0,isrender:1},{iconId:"cloudRec",part:"right",defaultActive:0,isrender:0},{iconId:"rec",part:"right",defaultActive:0,isrender:0}]},footer:{color:"#FFFFFF",backgroundColor:"#00000080",activeColor:"#1890FF",btnList:[{iconId:"play",part:"left",defaultActive:1,isrender:1},{iconId:"capturePicture",part:"left",defaultActive:0,isrender:0},{iconId:"talk",part:"left",defaultActive:0,isrender:1},{iconId:"sound",part:"left",defaultActive:1,isrender:1},{iconId:"pantile",part:"left",defaultActive:0,isrender:0},{iconId:"recordvideo",part:"left",defaultActive:0,isrender:0},{iconId:"hd",part:"right",defaultActive:0,isrender:0},{iconId:"zoom",part:"left",defaultActive:0,isrender:0},{iconId:"webExpend",part:"right",defaultActive:0,isrender:0},{iconId:"expend",part:"right",defaultActive:0,isrender:1}]}},D0={data:O0},k0={header:{color:"#FFFFFF",backgroundColor:"#000000",activeColor:"#1890FF",btnList:[{iconId:"deviceID",part:"left",defaultActive:0,isrender:1},{iconId:"deviceName",part:"left",defaultActive:0,isrender:1},{iconId:"cloudRec",part:"right",defaultActive:0,isrender:1},{iconId:"rec",part:"right",defaultActive:0,isrender:1}]},footer:{color:"#FFFFFF",backgroundColor:"#00000080",activeColor:"#1890FF",btnList:[{iconId:"play",part:"left",defaultActive:1,isrender:1},{iconId:"capturePicture",part:"left",defaultActive:0,isrender:1},{iconId:"sound",part:"left",defaultActive:1,isrender:1},{iconId:"pantile",part:"left",defaultActive:0,isrender:0},{iconId:"recordvideo",part:"left",defaultActive:0,isrender:1},{iconId:"zoom",part:"left",defaultActive:0,isrender:1},{iconId:"speed",part:"right",defaultActive:0,isrender:1},{iconId:"hd",part:"right",defaultActive:0,isrender:0},{iconId:"webExpend",part:"right",defaultActive:0,isrender:1},{iconId:"expend",part:"right",defaultActive:0,isrender:1}]}},ye={data:k0},Q0=[{autoFocus:5,createTime:"2021-06-14T08:04:37.000Z",themeId:"pcLive",themeIntro:"PC直播全量版",themeName:"PC直播全量版",themeType:"webLive",updateTime:"2021-06-14T08:04:37.000Z",label:"官方",labelPic:"https://resource.eziot.com/group1/M00/00/8A/CtwQEmLr_DmANlElAAA-xyivSaw030.png",poster:"https://resource.eziot.com/group1/M00/00/89/CtwQEmLl8r-AZU7wAAETKlvgerU237.png",header:r1.data.header,footer:r1.data.footer},{autoFocus:5,createTime:"2021-06-14T08:04:37.000Z",themeId:"security",themeIntro:"PC直播安防版",themeName:"PC直播安防版",themeType:"webLive",updateTime:"2021-06-14T08:04:37.000Z",label:"官方",labelPic:"https://resource.eziot.com/group1/M00/00/8A/CtwQEmLr_DmANlElAAA-xyivSaw030.png",poster:"https://resource.eziot.com/group1/M00/00/89/CtwQEmLl8r-AZU7wAAETKlvgerU237.png",header:f1.data.header,footer:f1.data.footer},{autoFocus:5,createTime:"2021-06-14T08:04:37.000Z",themeId:"voice",themeIntro:"PC直播语音版",themeName:"PC直播语音版",themeType:"webLive",updateTime:"2021-06-14T08:04:37.000Z",label:"官方",labelPic:"https://resource.eziot.com/group1/M00/00/8A/CtwQEmLr_DmANlElAAA-xyivSaw030.png",poster:"https://resource.eziot.com/group1/M00/00/89/CtwQEmLl8r-AZU7wAAETKlvgerU237.png",header:D0.data.header,footer:D0.data.footer},{autoFocus:5,createTime:"2021-06-14T08:04:37.000Z",themeId:"simple",themeIntro:"PC直播极简版",themeName:"PC直播极简版",themeType:"webLive",updateTime:"2021-06-14T08:04:37.000Z",label:"官方",labelPic:"https://resource.eziot.com/group1/M00/00/8A/CtwQEmLr_DmANlElAAA-xyivSaw030.png",poster:"",header:T0.data.header,footer:T0.data.footer},{autoFocus:5,createTime:"2021-06-14T08:04:37.000Z",themeId:"pcRec",themeIntro:"PC回放全量版",themeName:"PC回放全量版",themeType:"webRec",updateTime:"2021-06-14T08:04:37.000Z",label:"官方",labelPic:"https://resource.eziot.com/group1/M00/00/8A/CtwQEmLr_DmANlElAAA-xyivSaw030.png",poster:"https://resource.eziot.com/group1/M00/00/89/CtwQEmLl8r-AZU7wAAETKlvgerU237.png",header:ye.data.header,footer:ye.data.footer},{autoFocus:5,createTime:"2021-06-14T08:04:37.000Z",themeId:"mobileLive",themeIntro:"Mobile直播全量版",themeName:"Mobile直播全量版",themeType:"mobileLive",updateTime:"2021-06-14T08:04:37.000Z",label:"官方",labelPic:"https://resource.eziot.com/group1/M00/00/8A/CtwQEmLr_GmAL5IhAABZs1vUK0s564.png",poster:"https://resource.eziot.com/group1/M00/00/89/CtwQEmLl8r-AZU7wAAETKlvgerU237.png",header:i1.data.header,footer:i1.data.footer},{autoFocus:5,createTime:"2021-06-14T08:04:37.000Z",themeId:"mobileRec",themeIntro:"Mobile回放全量版",themeName:"Mobile回放全量版",themeType:"mobileRec",updateTime:"2021-06-14T08:04:37.000Z",label:"官方",labelPic:"https://resource.eziot.com/group1/M00/00/8A/CtwQEmLr_GmAL5IhAABZs1vUK0s564.png",poster:"https://resource.eziot.com/group1/M00/00/89/CtwQEmLl8r-AZU7wAAETKlvgerU237.png",header:q1.data.header,footer:q1.data.footer}],Le=function(){function R(M){var d=this;a(this,R),this.jSPlugin=M,this.enableZoom=!1,this.isMouseDown=!1,this.videoWidth=1920,this.videoHeight=1080,this.currentScale=1,this.currentPosition={x:0,y:0,xPercent:.1,yPercent:.1,xCurrentVideo:0,yCurrentVideo:0,left:0,top:0,right:1920,bottom:1080},this.DOM=document.getElementById(M.id),this.clientRect=document.getElementById(M.id).getBoundingClientRect();var f=document.createElement("div");f.id="".concat(M.id,"-zoom-container"),f.style=`position: absolute;
- display:none;
- left: 12px;
- bottom: 80px;`;var y=`
-