Your IP : 192.168.165.1


Current Path : C:/Users/Mahmood/Desktop/moodle/lib/amd/build/
Upload File :
Current File : C:/Users/Mahmood/Desktop/moodle/lib/amd/build/adapter.min.js

function _typeof2(e){"@babel/helpers - typeof";if("function"==typeof Symbol&&"symbol"==typeof Symbol.iterator){_typeof2=function(e){return typeof e}}else{_typeof2=function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e}}return _typeof2(e)}define ("core/adapter",[],function(){return function d(c,e,t){function r(i,o){if(!e[i]){if(!c[i]){var s="function"==typeof require&&require;if(!o&&s)return s(i,!0);if(n)return n(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=e[i]={exports:{}};c[i][0].call(p.exports,function(t){var e=c[i][1][t];return r(e?e:t)},p,p.exports,d,c,e,t)}return e[i].exports}for(var n="function"==typeof require&&require,a=0;a<t.length;a++){r(t[a])}return r}({1:[function(e,t){'use strict';var r=e("./adapter_factory.js"),a=(0,r.adapterFactory)({window:window});t.exports=a},{"./adapter_factory.js":2}],2:[function(e,t,r){'use strict';Object.defineProperty(r,"__esModule",{value:!0});r.adapterFactory=function(){var e=0<arguments.length&&arguments[0]!==void 0?arguments[0]:{},t=e.window,r=1<arguments.length&&arguments[1]!==void 0?arguments[1]:{shimChrome:!0,shimFirefox:!0,shimEdge:!0,shimSafari:!0},a=i.log,n=i.detectBrowser(t),o={browserDetails:n,commonShim:g,extractVersion:i.extractVersion,disableLog:i.disableLog,disableWarnings:i.disableWarnings};switch(n.browser){case"chrome":if(!s||!s.shimPeerConnection||!r.shimChrome){a("Chrome shim is not included in this adapter release.");return o}a("adapter.js shimming chrome.");o.browserShim=s;s.shimGetUserMedia(t);s.shimMediaStream(t);s.shimPeerConnection(t);s.shimOnTrack(t);s.shimAddTrackRemoveTrack(t);s.shimGetSendersWithDtmf(t);s.shimGetStats(t);s.shimSenderReceiverGetStats(t);s.fixNegotiationNeeded(t);g.shimRTCIceCandidate(t);g.shimConnectionState(t);g.shimMaxMessageSize(t);g.shimSendThrowTypeError(t);g.removeAllowExtmapMixed(t);break;case"firefox":if(!l||!l.shimPeerConnection||!r.shimFirefox){a("Firefox shim is not included in this adapter release.");return o}a("adapter.js shimming firefox.");o.browserShim=l;l.shimGetUserMedia(t);l.shimPeerConnection(t);l.shimOnTrack(t);l.shimRemoveStream(t);l.shimSenderGetStats(t);l.shimReceiverGetStats(t);l.shimRTCDataChannel(t);l.shimAddTransceiver(t);l.shimCreateOffer(t);l.shimCreateAnswer(t);g.shimRTCIceCandidate(t);g.shimConnectionState(t);g.shimMaxMessageSize(t);g.shimSendThrowTypeError(t);break;case"edge":if(!c||!c.shimPeerConnection||!r.shimEdge){a("MS edge shim is not included in this adapter release.");return o}a("adapter.js shimming edge.");o.browserShim=c;c.shimGetUserMedia(t);c.shimGetDisplayMedia(t);c.shimPeerConnection(t);c.shimReplaceTrack(t);g.shimMaxMessageSize(t);g.shimSendThrowTypeError(t);break;case"safari":if(!f||!r.shimSafari){a("Safari shim is not included in this adapter release.");return o}a("adapter.js shimming safari.");o.browserShim=f;f.shimRTCIceServerUrls(t);f.shimCreateOfferLegacy(t);f.shimCallbacksAPI(t);f.shimLocalStreamsAPI(t);f.shimRemoteStreamsAPI(t);f.shimTrackEventTransceiver(t);f.shimGetUserMedia(t);g.shimRTCIceCandidate(t);g.shimMaxMessageSize(t);g.shimSendThrowTypeError(t);g.removeAllowExtmapMixed(t);break;default:a("Unsupported browser!");break;}return o};var n=e("./utils"),i=a(n),o=e("./chrome/chrome_shim"),s=a(o),d=e("./edge/edge_shim"),c=a(d),p=e("./firefox/firefox_shim"),l=a(p),m=e("./safari/safari_shim"),f=a(m),h=e("./common_shim"),g=a(h);function a(e){if(e&&e.__esModule){return e}else{var t={};if(null!=e){for(var r in e){if(Object.prototype.hasOwnProperty.call(e,r))t[r]=e[r]}}t.default=e;return t}}},{"./chrome/chrome_shim":3,"./common_shim":6,"./edge/edge_shim":7,"./firefox/firefox_shim":11,"./safari/safari_shim":14,"./utils":15}],3:[function(e,t,r){'use strict';Object.defineProperty(r,"__esModule",{value:!0});r.shimGetDisplayMedia=r.shimGetUserMedia=void 0;var d="function"==typeof Symbol&&"symbol"===_typeof2(Symbol.iterator)?function(e){return _typeof2(e)}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":_typeof2(e)},c=e("./getusermedia");Object.defineProperty(r,"shimGetUserMedia",{enumerable:!0,get:function(){return c.shimGetUserMedia}});var p=e("./getdisplaymedia");Object.defineProperty(r,"shimGetDisplayMedia",{enumerable:!0,get:function(){return p.shimGetDisplayMedia}});r.shimMediaStream=function(e){e.MediaStream=e.MediaStream||e.webkitMediaStream};r.shimOnTrack=n;r.shimGetSendersWithDtmf=i;r.shimGetStats=function(e){if(!e.RTCPeerConnection){return}var t=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){var e=this,r=Array.prototype.slice.call(arguments),a=r[0],n=r[1],i=r[2];if(0<arguments.length&&"function"==typeof a){return t.apply(this,arguments)}if(0===t.length&&(0===arguments.length||"function"!=typeof a)){return t.apply(this,[])}var o=function(e){var t={},r=e.result();r.forEach(function(e){var r={id:e.id,timestamp:e.timestamp,type:{localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[e.type]||e.type};e.names().forEach(function(t){r[t]=e.stat(t)});t[r.id]=r});return t},s=function(e){return new Map(Object.keys(e).map(function(t){return[t,e[t]]}))};if(2<=arguments.length){var d=function(e){n(s(o(e)))};return t.apply(this,[d,a])}return new Promise(function(r,a){t.apply(e,[function(e){r(s(o(e)))},a])}).then(n,i)}};r.shimSenderReceiverGetStats=o;r.shimAddTrackRemoveTrackWithNative=s;r.shimAddTrackRemoveTrack=function(e){if(!e.RTCPeerConnection){return}var n=m.detectBrowser(e);if(e.RTCPeerConnection.prototype.addTrack&&65<=n.version){return s(e)}var i=e.RTCPeerConnection.prototype.getLocalStreams;e.RTCPeerConnection.prototype.getLocalStreams=function(){var e=this,t=i.apply(this);this._reverseStreams=this._reverseStreams||{};return t.map(function(t){return e._reverseStreams[t.id]})};var o=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(t){var r=this;this._streams=this._streams||{};this._reverseStreams=this._reverseStreams||{};t.getTracks().forEach(function(e){var t=r.getSenders().find(function(t){return t.track===e});if(t){throw new DOMException("Track already exists.","InvalidAccessError")}});if(!this._reverseStreams[t.id]){var a=new e.MediaStream(t.getTracks());this._streams[t.id]=a;this._reverseStreams[a.id]=t;t=a}o.apply(this,[t])};var d=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){this._streams=this._streams||{};this._reverseStreams=this._reverseStreams||{};d.apply(this,[this._streams[e.id]||e]);delete this._reverseStreams[this._streams[e.id]?this._streams[e.id].id:e.id];delete this._streams[e.id]};e.RTCPeerConnection.prototype.addTrack=function(r,a){var n=this;if("closed"===this.signalingState){throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError")}var i=[].slice.call(arguments,1);if(1!==i.length||!i[0].getTracks().find(function(e){return e===r})){throw new DOMException("The adapter.js addTrack polyfill only supports a single  stream which is associated with the specified track.","NotSupportedError")}var o=this.getSenders().find(function(e){return e.track===r});if(o){throw new DOMException("Track already exists.","InvalidAccessError")}this._streams=this._streams||{};this._reverseStreams=this._reverseStreams||{};var s=this._streams[a.id];if(s){s.addTrack(r);Promise.resolve().then(function(){n.dispatchEvent(new Event("negotiationneeded"))})}else{var d=new e.MediaStream([r]);this._streams[a.id]=d;this._reverseStreams[d.id]=a;this.addStream(d)}return this.getSenders().find(function(e){return e.track===r})};function t(e,t){var r=t.sdp;Object.keys(e._reverseStreams||[]).forEach(function(t){var a=e._reverseStreams[t],n=e._streams[a.id];r=r.replace(new RegExp(n.id,"g"),a.id)});return new RTCSessionDescription({type:t.type,sdp:r})}function r(e,t){var r=t.sdp;Object.keys(e._reverseStreams||[]).forEach(function(t){var a=e._reverseStreams[t],n=e._streams[a.id];r=r.replace(new RegExp(a.id,"g"),n.id)});return new RTCSessionDescription({type:t.type,sdp:r})}["createOffer","createAnswer"].forEach(function(r){var n=e.RTCPeerConnection.prototype[r],i=a({},r,function(){var e=this,r=arguments,a=arguments.length&&"function"==typeof arguments[0];if(a){return n.apply(this,[function(a){var n=t(e,a);r[0].apply(null,[n])},function(e){if(r[1]){r[1].apply(null,e)}},arguments[2]])}return n.apply(this,arguments).then(function(r){return t(e,r)})});e.RTCPeerConnection.prototype[r]=i[r]});var c=e.RTCPeerConnection.prototype.setLocalDescription;e.RTCPeerConnection.prototype.setLocalDescription=function(){if(!arguments.length||!arguments[0].type){return c.apply(this,arguments)}arguments[0]=r(this,arguments[0]);return c.apply(this,arguments)};var p=Object.getOwnPropertyDescriptor(e.RTCPeerConnection.prototype,"localDescription");Object.defineProperty(e.RTCPeerConnection.prototype,"localDescription",{get:function(){var e=p.get.apply(this);if(""===e.type){return e}return t(this,e)}});e.RTCPeerConnection.prototype.removeTrack=function(e){var t=this;if("closed"===this.signalingState){throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError")}if(!e._pc){throw new DOMException("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.","TypeError")}var r=e._pc===this;if(!r){throw new DOMException("Sender was not created by this connection.","InvalidAccessError")}this._streams=this._streams||{};var a;Object.keys(this._streams).forEach(function(r){var n=t._streams[r].getTracks().find(function(t){return e.track===t});if(n){a=t._streams[r]}});if(a){if(1===a.getTracks().length){this.removeStream(this._reverseStreams[a.id])}else{a.removeTrack(e.track)}this.dispatchEvent(new Event("negotiationneeded"))}}};r.shimPeerConnection=function(e){var t=m.detectBrowser(e);if(!e.RTCPeerConnection&&e.webkitRTCPeerConnection){e.RTCPeerConnection=e.webkitRTCPeerConnection}if(!e.RTCPeerConnection){return}if(53>t.version){["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(t){var r=e.RTCPeerConnection.prototype[t],n=a({},t,function(){arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]);return r.apply(this,arguments)});e.RTCPeerConnection.prototype[t]=n[t]})}var r=e.RTCPeerConnection.prototype.addIceCandidate;e.RTCPeerConnection.prototype.addIceCandidate=function(){if(!arguments[0]){if(arguments[1]){arguments[1].apply(null)}return Promise.resolve()}if(78>t.version&&arguments[0]&&""===arguments[0].candidate){return Promise.resolve()}return r.apply(this,arguments)}};r.fixNegotiationNeeded=function(e){m.wrapPeerConnectionEvent(e,"negotiationneeded",function(t){var e=t.target;if("stable"!==e.signalingState){return}return t})};var l=e("../utils.js"),m=function(e){if(e&&e.__esModule){return e}else{var t={};if(null!=e){for(var r in e){if(Object.prototype.hasOwnProperty.call(e,r))t[r]=e[r]}}t.default=e;return t}}(l);function a(e,t,r){if(t in e){Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0})}else{e[t]=r}return e}function n(t){if("object"===("undefined"==typeof t?"undefined":d(t))&&t.RTCPeerConnection&&!("ontrack"in t.RTCPeerConnection.prototype)){Object.defineProperty(t.RTCPeerConnection.prototype,"ontrack",{get:function(){return this._ontrack},set:function(e){if(this._ontrack){this.removeEventListener("track",this._ontrack)}this.addEventListener("track",this._ontrack=e)},enumerable:!0,configurable:!0});var r=t.RTCPeerConnection.prototype.setRemoteDescription;t.RTCPeerConnection.prototype.setRemoteDescription=function(){var a=this;if(!this._ontrackpoly){this._ontrackpoly=function(r){r.stream.addEventListener("addtrack",function(e){var n;if(t.RTCPeerConnection.prototype.getReceivers){n=a.getReceivers().find(function(t){return t.track&&t.track.id===e.track.id})}else{n={track:e.track}}var i=new Event("track");i.track=e.track;i.receiver=n;i.transceiver={receiver:n};i.streams=[r.stream];a.dispatchEvent(i)});r.stream.getTracks().forEach(function(e){var n;if(t.RTCPeerConnection.prototype.getReceivers){n=a.getReceivers().find(function(t){return t.track&&t.track.id===e.id})}else{n={track:e}}var i=new Event("track");i.track=e;i.receiver=n;i.transceiver={receiver:n};i.streams=[r.stream];a.dispatchEvent(i)})};this.addEventListener("addstream",this._ontrackpoly)}return r.apply(this,arguments)}}else{m.wrapPeerConnectionEvent(t,"track",function(t){if(!t.transceiver){Object.defineProperty(t,"transceiver",{value:{receiver:t.receiver}})}return t})}}function i(e){if("object"===("undefined"==typeof e?"undefined":d(e))&&e.RTCPeerConnection&&!("getSenders"in e.RTCPeerConnection.prototype)&&"createDTMFSender"in e.RTCPeerConnection.prototype){var t=function(e,t){return{track:t,get dtmf(){if(this._dtmf===void 0){if("audio"===t.kind){this._dtmf=e.createDTMFSender(t)}else{this._dtmf=null}}return this._dtmf},_pc:e}};if(!e.RTCPeerConnection.prototype.getSenders){e.RTCPeerConnection.prototype.getSenders=function(){this._senders=this._senders||[];return this._senders.slice()};var r=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e){var a=r.apply(this,arguments);if(!a){a=t(this,e);this._senders.push(a)}return a};var a=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){a.apply(this,arguments);var t=this._senders.indexOf(e);if(-1!==t){this._senders.splice(t,1)}}}var n=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){var r=this;this._senders=this._senders||[];n.apply(this,[e]);e.getTracks().forEach(function(e){r._senders.push(t(r,e))})};var i=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){var t=this;this._senders=this._senders||[];i.apply(this,[e]);e.getTracks().forEach(function(e){var r=t._senders.find(function(t){return t.track===e});if(r){t._senders.splice(t._senders.indexOf(r),1)}})}}else if("object"===("undefined"==typeof e?"undefined":d(e))&&e.RTCPeerConnection&&"getSenders"in e.RTCPeerConnection.prototype&&"createDTMFSender"in e.RTCPeerConnection.prototype&&e.RTCRtpSender&&!("dtmf"in e.RTCRtpSender.prototype)){var o=e.RTCPeerConnection.prototype.getSenders;e.RTCPeerConnection.prototype.getSenders=function(){var e=this,t=o.apply(this,[]);t.forEach(function(t){return t._pc=e});return t};Object.defineProperty(e.RTCRtpSender.prototype,"dtmf",{get:function(){if(this._dtmf===void 0){if("audio"===this.track.kind){this._dtmf=this._pc.createDTMFSender(this.track)}else{this._dtmf=null}}return this._dtmf}})}}function o(e){if(!("object"===("undefined"==typeof e?"undefined":d(e))&&e.RTCPeerConnection&&e.RTCRtpSender&&e.RTCRtpReceiver)){return}if(!("getStats"in e.RTCRtpSender.prototype)){var t=e.RTCPeerConnection.prototype.getSenders;if(t){e.RTCPeerConnection.prototype.getSenders=function(){var e=this,r=t.apply(this,[]);r.forEach(function(t){return t._pc=e});return r}}var r=e.RTCPeerConnection.prototype.addTrack;if(r){e.RTCPeerConnection.prototype.addTrack=function(){var e=r.apply(this,arguments);e._pc=this;return e}}e.RTCRtpSender.prototype.getStats=function(){var e=this;return this._pc.getStats().then(function(t){return m.filterStats(t,e.track,!0)})}}if(!("getStats"in e.RTCRtpReceiver.prototype)){var a=e.RTCPeerConnection.prototype.getReceivers;if(a){e.RTCPeerConnection.prototype.getReceivers=function(){var e=this,t=a.apply(this,[]);t.forEach(function(t){return t._pc=e});return t}}m.wrapPeerConnectionEvent(e,"track",function(t){t.receiver._pc=t.srcElement;return t});e.RTCRtpReceiver.prototype.getStats=function(){var e=this;return this._pc.getStats().then(function(t){return m.filterStats(t,e.track,!1)})}}if(!("getStats"in e.RTCRtpSender.prototype&&"getStats"in e.RTCRtpReceiver.prototype)){return}var n=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){if(0<arguments.length&&arguments[0]instanceof e.MediaStreamTrack){var t=arguments[0],r=void 0,a=void 0,i=void 0;this.getSenders().forEach(function(e){if(e.track===t){if(r){i=!0}else{r=e}}});this.getReceivers().forEach(function(e){if(e.track===t){if(a){i=!0}else{a=e}}return e.track===t});if(i||r&&a){return Promise.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError"))}else if(r){return r.getStats()}else if(a){return a.getStats()}return Promise.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return n.apply(this,arguments)}}function s(e){e.RTCPeerConnection.prototype.getLocalStreams=function(){var e=this;this._shimmedLocalStreams=this._shimmedLocalStreams||{};return Object.keys(this._shimmedLocalStreams).map(function(t){return e._shimmedLocalStreams[t][0]})};var t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,r){if(!r){return t.apply(this,arguments)}this._shimmedLocalStreams=this._shimmedLocalStreams||{};var a=t.apply(this,arguments);if(!this._shimmedLocalStreams[r.id]){this._shimmedLocalStreams[r.id]=[r,a]}else if(-1===this._shimmedLocalStreams[r.id].indexOf(a)){this._shimmedLocalStreams[r.id].push(a)}return a};var r=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){var t=this;this._shimmedLocalStreams=this._shimmedLocalStreams||{};e.getTracks().forEach(function(e){var r=t.getSenders().find(function(t){return t.track===e});if(r){throw new DOMException("Track already exists.","InvalidAccessError")}});var a=this.getSenders();r.apply(this,arguments);var n=this.getSenders().filter(function(e){return-1===a.indexOf(e)});this._shimmedLocalStreams[e.id]=[e].concat(n)};var a=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){this._shimmedLocalStreams=this._shimmedLocalStreams||{};delete this._shimmedLocalStreams[e.id];return a.apply(this,arguments)};var n=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){var t=this;this._shimmedLocalStreams=this._shimmedLocalStreams||{};if(e){Object.keys(this._shimmedLocalStreams).forEach(function(r){var a=t._shimmedLocalStreams[r].indexOf(e);if(-1!==a){t._shimmedLocalStreams[r].splice(a,1)}if(1===t._shimmedLocalStreams[r].length){delete t._shimmedLocalStreams[r]}})}return n.apply(this,arguments)}}},{"../utils.js":15,"./getdisplaymedia":4,"./getusermedia":5}],4:[function(e,t,r){'use strict';Object.defineProperty(r,"__esModule",{value:!0});r.shimGetDisplayMedia=a;function a(e,t){if(e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices){return}if(!e.navigator.mediaDevices){return}if("function"!=typeof t){console.error("shimGetDisplayMedia: getSourceId argument is not a function");return}e.navigator.mediaDevices.getDisplayMedia=function(r){return t(r).then(function(t){var a=r.video&&r.video.width,n=r.video&&r.video.height,i=r.video&&r.video.frameRate;r.video={mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:t,maxFrameRate:i||3}};if(a){r.video.mandatory.maxWidth=a}if(n){r.video.mandatory.maxHeight=n}return e.navigator.mediaDevices.getUserMedia(r)})}}},{}],5:[function(e,t,r){'use strict';Object.defineProperty(r,"__esModule",{value:!0});var a="function"==typeof Symbol&&"symbol"===_typeof2(Symbol.iterator)?function(e){return _typeof2(e)}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":_typeof2(e)};r.shimGetUserMedia=function(e){var t=e&&e.navigator;if(!t.mediaDevices){return}var r=i.detectBrowser(e),n=function(e){if("object"!==("undefined"==typeof e?"undefined":a(e))||e.mandatory||e.optional){return e}var t={};Object.keys(e).forEach(function(n){if("require"===n||"advanced"===n||"mediaSource"===n){return}var i="object"===a(e[n])?e[n]:{ideal:e[n]};if(i.exact!==void 0&&"number"==typeof i.exact){i.min=i.max=i.exact}var r=function(e,t){if(e){return e+t.charAt(0).toUpperCase()+t.slice(1)}return"deviceId"===t?"sourceId":t};if(i.ideal!==void 0){t.optional=t.optional||[];var o={};if("number"==typeof i.ideal){o[r("min",n)]=i.ideal;t.optional.push(o);o={};o[r("max",n)]=i.ideal;t.optional.push(o)}else{o[r("",n)]=i.ideal;t.optional.push(o)}}if(i.exact!==void 0&&"number"!=typeof i.exact){t.mandatory=t.mandatory||{};t.mandatory[r("",n)]=i.exact}else{["min","max"].forEach(function(e){if(i[e]!==void 0){t.mandatory=t.mandatory||{};t.mandatory[r(e,n)]=i[e]}})}});if(e.advanced){t.optional=(t.optional||[]).concat(e.advanced)}return t},s=function(e,i){if(61<=r.version){return i(e)}e=JSON.parse(JSON.stringify(e));if(e&&"object"===a(e.audio)){var s=function(e,t,r){if(t in e&&!(r in e)){e[r]=e[t];delete e[t]}};e=JSON.parse(JSON.stringify(e));s(e.audio,"autoGainControl","googAutoGainControl");s(e.audio,"noiseSuppression","googNoiseSuppression");e.audio=n(e.audio)}if(e&&"object"===a(e.video)){var d=e.video.facingMode;d=d&&("object"===("undefined"==typeof d?"undefined":a(d))?d:{ideal:d});var c=66>r.version;if(d&&("user"===d.exact||"environment"===d.exact||"user"===d.ideal||"environment"===d.ideal)&&!(t.mediaDevices.getSupportedConstraints&&t.mediaDevices.getSupportedConstraints().facingMode&&!c)){delete e.video.facingMode;var p;if("environment"===d.exact||"environment"===d.ideal){p=["back","rear"]}else if("user"===d.exact||"user"===d.ideal){p=["front"]}if(p){return t.mediaDevices.enumerateDevices().then(function(t){t=t.filter(function(e){return"videoinput"===e.kind});var r=t.find(function(e){return p.some(function(t){return e.label.toLowerCase().includes(t)})});if(!r&&t.length&&p.includes("back")){r=t[t.length-1]}if(r){e.video.deviceId=d.exact?{exact:r.deviceId}:{ideal:r.deviceId}}e.video=n(e.video);o("chrome: "+JSON.stringify(e));return i(e)})}}e.video=n(e.video)}o("chrome: "+JSON.stringify(e));return i(e)},d=function(t){if(64<=r.version){return t}return{name:{PermissionDeniedError:"NotAllowedError",PermissionDismissedError:"NotAllowedError",InvalidStateError:"NotAllowedError",DevicesNotFoundError:"NotFoundError",ConstraintNotSatisfiedError:"OverconstrainedError",TrackStartError:"NotReadableError",MediaDeviceFailedDueToShutdown:"NotAllowedError",MediaDeviceKillSwitchOn:"NotAllowedError",TabCaptureError:"AbortError",ScreenCaptureError:"AbortError",DeviceCaptureError:"AbortError"}[t.name]||t.name,message:t.message,constraint:t.constraint||t.constraintName,toString:function(){return this.name+(this.message&&": ")+this.message}}};t.getUserMedia=function(e,r,a){s(e,function(e){t.webkitGetUserMedia(e,r,function(t){if(a){a(d(t))}})})}.bind(t);if(t.mediaDevices.getUserMedia){var p=t.mediaDevices.getUserMedia.bind(t.mediaDevices);t.mediaDevices.getUserMedia=function(e){return s(e,function(e){return p(e).then(function(t){if(e.audio&&!t.getAudioTracks().length||e.video&&!t.getVideoTracks().length){t.getTracks().forEach(function(e){e.stop()});throw new DOMException("","NotFoundError")}return t},function(t){return Promise.reject(d(t))})})}}};var n=e("../utils.js"),i=function(e){if(e&&e.__esModule){return e}else{var t={};if(null!=e){for(var r in e){if(Object.prototype.hasOwnProperty.call(e,r))t[r]=e[r]}}t.default=e;return t}}(n);var o=i.log},{"../utils.js":15}],6:[function(e,t,r){'use strict';Object.defineProperty(r,"__esModule",{value:!0});var s="function"==typeof Symbol&&"symbol"===_typeof2(Symbol.iterator)?function(e){return _typeof2(e)}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":_typeof2(e)};r.shimRTCIceCandidate=a;r.shimMaxMessageSize=n;r.shimSendThrowTypeError=i;r.shimConnectionState=o;r.removeAllowExtmapMixed=function(e){if(!e.RTCPeerConnection){return}var t=l.detectBrowser(e);if("chrome"===t.browser&&71<=t.version){return}var r=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(e){if(e&&e.sdp&&-1!==e.sdp.indexOf("\na=extmap-allow-mixed")){e.sdp=e.sdp.split("\n").filter(function(e){return"a=extmap-allow-mixed"!==e.trim()}).join("\n")}return r.apply(this,arguments)}};var d=e("sdp"),c=function(e){return e&&e.__esModule?e:{default:e}}(d),p=e("./utils"),l=function(e){if(e&&e.__esModule){return e}else{var t={};if(null!=e){for(var r in e){if(Object.prototype.hasOwnProperty.call(e,r))t[r]=e[r]}}t.default=e;return t}}(p);function a(t){if(!t.RTCIceCandidate||t.RTCIceCandidate&&"foundation"in t.RTCIceCandidate.prototype){return}var r=t.RTCIceCandidate;t.RTCIceCandidate=function(e){if("object"===("undefined"==typeof e?"undefined":s(e))&&e.candidate&&0===e.candidate.indexOf("a=")){e=JSON.parse(JSON.stringify(e));e.candidate=e.candidate.substr(2)}if(e.candidate&&e.candidate.length){var t=new r(e),a=c.default.parseCandidate(e.candidate),n=Object.assign(t,a);n.toJSON=function(){return{candidate:n.candidate,sdpMid:n.sdpMid,sdpMLineIndex:n.sdpMLineIndex,usernameFragment:n.usernameFragment}};return n}return new r(e)};t.RTCIceCandidate.prototype=r.prototype;l.wrapPeerConnectionEvent(t,"icecandidate",function(r){if(r.candidate){Object.defineProperty(r,"candidate",{value:new t.RTCIceCandidate(r.candidate),writable:"false"})}return r})}function n(e){if(!e.RTCPeerConnection){return}var t=l.detectBrowser(e);if(!("sctp"in e.RTCPeerConnection.prototype)){Object.defineProperty(e.RTCPeerConnection.prototype,"sctp",{get:function(){return"undefined"==typeof this._sctp?null:this._sctp}})}var r=function(e){if(!e||!e.sdp){return!1}var t=c.default.splitSections(e.sdp);t.shift();return t.some(function(e){var t=c.default.parseMLine(e);return t&&"application"===t.kind&&-1!==t.protocol.indexOf("SCTP")})},a=function(e){var t=e.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);if(null===t||2>t.length){return-1}var r=parseInt(t[1],10);return r!==r?-1:r},n=function(e){var r=65536;if("firefox"===t.browser){if(57>t.version){if(-1===e){r=16384}else{r=2147483637}}else if(60>t.version){r=57===t.version?65535:65536}else{r=2147483637}}return r},i=function(e,r){var a=65536;if("firefox"===t.browser&&57===t.version){a=65535}var n=c.default.matchPrefix(e.sdp,"a=max-message-size:");if(0<n.length){a=parseInt(n[0].substr(19),10)}else if("firefox"===t.browser&&-1!==r){a=2147483637}return a},o=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){this._sctp=null;if("chrome"===t.browser&&76<=t.version){var e=this.getConfiguration(),s=e.sdpSemantics;if("plan-b"===s){Object.defineProperty(this,"sctp",{get:function(){return"undefined"==typeof this._sctp?null:this._sctp},enumerable:!0,configurable:!0})}}if(r(arguments[0])){var d=a(arguments[0]),c=n(d),p=i(arguments[0],d),l=void 0;if(0===c&&0===p){l=Number.POSITIVE_INFINITY}else if(0===c||0===p){l=Math.max(c,p)}else{l=Math.min(c,p)}var m={};Object.defineProperty(m,"maxMessageSize",{get:function(){return l}});this._sctp=m}return o.apply(this,arguments)}}function i(e){if(!(e.RTCPeerConnection&&"createDataChannel"in e.RTCPeerConnection.prototype)){return}function t(e,t){var r=e.send;e.send=function(){var a=arguments[0],n=a.length||a.size||a.byteLength;if("open"===e.readyState&&t.sctp&&n>t.sctp.maxMessageSize){throw new TypeError("Message too large (can send a maximum of "+t.sctp.maxMessageSize+" bytes)")}return r.apply(e,arguments)}}var r=e.RTCPeerConnection.prototype.createDataChannel;e.RTCPeerConnection.prototype.createDataChannel=function(){var e=r.apply(this,arguments);t(e,this);return e};l.wrapPeerConnectionEvent(e,"datachannel",function(r){t(r.channel,r.target);return r})}function o(e){if(!e.RTCPeerConnection||"connectionState"in e.RTCPeerConnection.prototype){return}var t=e.RTCPeerConnection.prototype;Object.defineProperty(t,"connectionState",{get:function(){return{completed:"connected",checking:"connecting"}[this.iceConnectionState]||this.iceConnectionState},enumerable:!0,configurable:!0});Object.defineProperty(t,"onconnectionstatechange",{get:function(){return this._onconnectionstatechange||null},set:function(e){if(this._onconnectionstatechange){this.removeEventListener("connectionstatechange",this._onconnectionstatechange);delete this._onconnectionstatechange}if(e){this.addEventListener("connectionstatechange",this._onconnectionstatechange=e)}},enumerable:!0,configurable:!0});["setLocalDescription","setRemoteDescription"].forEach(function(e){var r=t[e];t[e]=function(){if(!this._connectionstatechangepoly){this._connectionstatechangepoly=function(t){var e=t.target;if(e._lastConnectionState!==e.connectionState){e._lastConnectionState=e.connectionState;var r=new Event("connectionstatechange",t);e.dispatchEvent(r)}return t};this.addEventListener("iceconnectionstatechange",this._connectionstatechangepoly)}return r.apply(this,arguments)}})}},{"./utils":15,sdp:17}],7:[function(e,t,r){'use strict';Object.defineProperty(r,"__esModule",{value:!0});r.shimGetDisplayMedia=r.shimGetUserMedia=void 0;var i=e("./getusermedia");Object.defineProperty(r,"shimGetUserMedia",{enumerable:!0,get:function(){return i.shimGetUserMedia}});var o=e("./getdisplaymedia");Object.defineProperty(r,"shimGetDisplayMedia",{enumerable:!0,get:function(){return o.shimGetDisplayMedia}});r.shimPeerConnection=a;r.shimReplaceTrack=n;var s=e("../utils"),d=function(e){if(e&&e.__esModule){return e}else{var t={};if(null!=e){for(var r in e){if(Object.prototype.hasOwnProperty.call(e,r))t[r]=e[r]}}t.default=e;return t}}(s),c=e("./filtericeservers"),p=e("rtcpeerconnection-shim"),l=function(e){return e&&e.__esModule?e:{default:e}}(p);function a(e){var t=d.detectBrowser(e);if(e.RTCIceGatherer){if(!e.RTCIceCandidate){e.RTCIceCandidate=function(e){return e}}if(!e.RTCSessionDescription){e.RTCSessionDescription=function(e){return e}}if(15025>t.version){var r=Object.getOwnPropertyDescriptor(e.MediaStreamTrack.prototype,"enabled");Object.defineProperty(e.MediaStreamTrack.prototype,"enabled",{set:function(e){r.set.call(this,e);var t=new Event("enabled");t.enabled=e;this.dispatchEvent(t)}})}}if(e.RTCRtpSender&&!("dtmf"in e.RTCRtpSender.prototype)){Object.defineProperty(e.RTCRtpSender.prototype,"dtmf",{get:function(){if(this._dtmf===void 0){if("audio"===this.track.kind){this._dtmf=new e.RTCDtmfSender(this)}else if("video"===this.track.kind){this._dtmf=null}}return this._dtmf}})}if(e.RTCDtmfSender&&!e.RTCDTMFSender){e.RTCDTMFSender=e.RTCDtmfSender}var a=(0,l.default)(e,t.version);e.RTCPeerConnection=function(e){if(e&&e.iceServers){e.iceServers=(0,c.filterIceServers)(e.iceServers,t.version);d.log("ICE servers after filtering:",e.iceServers)}return new a(e)};e.RTCPeerConnection.prototype=a.prototype}function n(e){if(e.RTCRtpSender&&!("replaceTrack"in e.RTCRtpSender.prototype)){e.RTCRtpSender.prototype.replaceTrack=e.RTCRtpSender.prototype.setTrack}}},{"../utils":15,"./filtericeservers":8,"./getdisplaymedia":9,"./getusermedia":10,"rtcpeerconnection-shim":16}],8:[function(e,t,r){'use strict';Object.defineProperty(r,"__esModule",{value:!0});r.filterIceServers=function(e){var t=!1;e=JSON.parse(JSON.stringify(e));return e.filter(function(e){if(e&&(e.urls||e.url)){var r=e.urls||e.url;if(e.url&&!e.urls){n.deprecated("RTCIceServer.url","RTCIceServer.urls")}var a="string"==typeof r;if(a){r=[r]}r=r.filter(function(e){if(0===e.indexOf("stun:")){return!1}var r=e.startsWith("turn")&&!e.startsWith("turn:[")&&e.includes("transport=udp");if(r&&!t){t=!0;return!0}return r&&!t});delete e.url;e.urls=a?r[0]:r;return!!r.length}})};var a=e("../utils"),n=function(e){if(e&&e.__esModule){return e}else{var t={};if(null!=e){for(var r in e){if(Object.prototype.hasOwnProperty.call(e,r))t[r]=e[r]}}t.default=e;return t}}(a)},{"../utils":15}],9:[function(e,t,r){'use strict';Object.defineProperty(r,"__esModule",{value:!0});r.shimGetDisplayMedia=a;function a(e){if(!("getDisplayMedia"in e.navigator)){return}if(!e.navigator.mediaDevices){return}if(e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices){return}e.navigator.mediaDevices.getDisplayMedia=e.navigator.getDisplayMedia.bind(e.navigator)}},{}],10:[function(e,t,r){'use strict';Object.defineProperty(r,"__esModule",{value:!0});r.shimGetUserMedia=function(e){var t=e&&e.navigator,r=function(t){return{name:{PermissionDeniedError:"NotAllowedError"}[t.name]||t.name,message:t.message,constraint:t.constraint,toString:function(){return this.name}}},a=t.mediaDevices.getUserMedia.bind(t.mediaDevices);t.mediaDevices.getUserMedia=function(e){return a(e).catch(function(t){return Promise.reject(r(t))})}}},{}],11:[function(e,t,r){'use strict';Object.defineProperty(r,"__esModule",{value:!0});r.shimGetDisplayMedia=r.shimGetUserMedia=void 0;var d="function"==typeof Symbol&&"symbol"===_typeof2(Symbol.iterator)?function(e){return _typeof2(e)}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":_typeof2(e)},c=e("./getusermedia");Object.defineProperty(r,"shimGetUserMedia",{enumerable:!0,get:function(){return c.shimGetUserMedia}});var p=e("./getdisplaymedia");Object.defineProperty(r,"shimGetDisplayMedia",{enumerable:!0,get:function(){return p.shimGetDisplayMedia}});r.shimOnTrack=n;r.shimPeerConnection=function(e){var t=m.detectBrowser(e);if("object"!==("undefined"==typeof e?"undefined":d(e))||!(e.RTCPeerConnection||e.mozRTCPeerConnection)){return}if(!e.RTCPeerConnection&&e.mozRTCPeerConnection){e.RTCPeerConnection=e.mozRTCPeerConnection}if(53>t.version){["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(t){var r=e.RTCPeerConnection.prototype[t],n=a({},t,function(){arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]);return r.apply(this,arguments)});e.RTCPeerConnection.prototype[t]=n[t]})}if(68>t.version){var r=e.RTCPeerConnection.prototype.addIceCandidate;e.RTCPeerConnection.prototype.addIceCandidate=function(){if(!arguments[0]){if(arguments[1]){arguments[1].apply(null)}return Promise.resolve()}if(arguments[0]&&""===arguments[0].candidate){return Promise.resolve()}return r.apply(this,arguments)}}var n={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"},i=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){var e=Array.prototype.slice.call(arguments),r=e[0],a=e[1],o=e[2];return i.apply(this,[r||null]).then(function(r){if(53>t.version&&!a){try{r.forEach(function(e){e.type=n[e.type]||e.type})}catch(t){if("TypeError"!==t.name){throw t}r.forEach(function(e,t){r.set(t,Object.assign({},e,{type:n[e.type]||e.type}))})}}return r}).then(a,o)}};r.shimSenderGetStats=i;r.shimReceiverGetStats=o;r.shimRemoveStream=s;r.shimRTCDataChannel=function(e){if(e.DataChannel&&!e.RTCDataChannel){e.RTCDataChannel=e.DataChannel}};r.shimAddTransceiver=function(e){if(!("object"===("undefined"==typeof e?"undefined":d(e))&&e.RTCPeerConnection)){return}var t=e.RTCPeerConnection.prototype.addTransceiver;if(t){e.RTCPeerConnection.prototype.addTransceiver=function(){this.setParametersPromises=[];var e=arguments[1],r=e&&"sendEncodings"in e;if(r){e.sendEncodings.forEach(function(e){if("rid"in e){if(!/^[a-z0-9]{0,16}$/i.test(e.rid)){throw new TypeError("Invalid RID value provided.")}}if("scaleResolutionDownBy"in e){if(!(1<=parseFloat(e.scaleResolutionDownBy))){throw new RangeError("scale_resolution_down_by must be >= 1.0")}}if("maxFramerate"in e){if(!(0<=parseFloat(e.maxFramerate))){throw new RangeError("max_framerate must be >= 0.0")}}})}var a=t.apply(this,arguments);if(r){var n=a.sender,i=n.getParameters();if(!("encodings"in i)){i.encodings=e.sendEncodings;this.setParametersPromises.push(n.setParameters(i).catch(function(){}))}}return a}}};r.shimCreateOffer=function(e){if(!("object"===("undefined"==typeof e?"undefined":d(e))&&e.RTCPeerConnection)){return}var t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(){var e=this,r=arguments;if(this.setParametersPromises&&this.setParametersPromises.length){return Promise.all(this.setParametersPromises).then(function(){return t.apply(e,r)}).finally(function(){e.setParametersPromises=[]})}return t.apply(this,arguments)}};r.shimCreateAnswer=function(e){if(!("object"===("undefined"==typeof e?"undefined":d(e))&&e.RTCPeerConnection)){return}var t=e.RTCPeerConnection.prototype.createAnswer;e.RTCPeerConnection.prototype.createAnswer=function(){var e=this,r=arguments;if(this.setParametersPromises&&this.setParametersPromises.length){return Promise.all(this.setParametersPromises).then(function(){return t.apply(e,r)}).finally(function(){e.setParametersPromises=[]})}return t.apply(this,arguments)}};var l=e("../utils"),m=function(e){if(e&&e.__esModule){return e}else{var t={};if(null!=e){for(var r in e){if(Object.prototype.hasOwnProperty.call(e,r))t[r]=e[r]}}t.default=e;return t}}(l);function a(e,t,r){if(t in e){Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0})}else{e[t]=r}return e}function n(e){if("object"===("undefined"==typeof e?"undefined":d(e))&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)){Object.defineProperty(e.RTCTrackEvent.prototype,"transceiver",{get:function(){return{receiver:this.receiver}}})}}function i(e){if(!("object"===("undefined"==typeof e?"undefined":d(e))&&e.RTCPeerConnection&&e.RTCRtpSender)){return}if(e.RTCRtpSender&&"getStats"in e.RTCRtpSender.prototype){return}var t=e.RTCPeerConnection.prototype.getSenders;if(t){e.RTCPeerConnection.prototype.getSenders=function(){var e=this,r=t.apply(this,[]);r.forEach(function(t){return t._pc=e});return r}}var r=e.RTCPeerConnection.prototype.addTrack;if(r){e.RTCPeerConnection.prototype.addTrack=function(){var e=r.apply(this,arguments);e._pc=this;return e}}e.RTCRtpSender.prototype.getStats=function(){return this.track?this._pc.getStats(this.track):Promise.resolve(new Map)}}function o(e){if(!("object"===("undefined"==typeof e?"undefined":d(e))&&e.RTCPeerConnection&&e.RTCRtpSender)){return}if(e.RTCRtpSender&&"getStats"in e.RTCRtpReceiver.prototype){return}var t=e.RTCPeerConnection.prototype.getReceivers;if(t){e.RTCPeerConnection.prototype.getReceivers=function(){var e=this,r=t.apply(this,[]);r.forEach(function(t){return t._pc=e});return r}}m.wrapPeerConnectionEvent(e,"track",function(t){t.receiver._pc=t.srcElement;return t});e.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}function s(e){if(!e.RTCPeerConnection||"removeStream"in e.RTCPeerConnection.prototype){return}e.RTCPeerConnection.prototype.removeStream=function(e){var t=this;m.deprecated("removeStream","removeTrack");this.getSenders().forEach(function(r){if(r.track&&e.getTracks().includes(r.track)){t.removeTrack(r)}})}}},{"../utils":15,"./getdisplaymedia":12,"./getusermedia":13}],12:[function(e,t,r){'use strict';Object.defineProperty(r,"__esModule",{value:!0});r.shimGetDisplayMedia=a;function a(e,t){if(e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices){return}if(!e.navigator.mediaDevices){return}e.navigator.mediaDevices.getDisplayMedia=function(r){if(!(r&&r.video)){var a=new DOMException("getDisplayMedia without video constraints is undefined");a.name="NotFoundError";a.code=8;return Promise.reject(a)}if(!0===r.video){r.video={mediaSource:t}}else{r.video.mediaSource=t}return e.navigator.mediaDevices.getUserMedia(r)}}},{}],13:[function(e,t,r){'use strict';Object.defineProperty(r,"__esModule",{value:!0});var n="function"==typeof Symbol&&"symbol"===_typeof2(Symbol.iterator)?function(e){return _typeof2(e)}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":_typeof2(e)};r.shimGetUserMedia=a;var i=e("../utils"),o=function(e){if(e&&e.__esModule){return e}else{var t={};if(null!=e){for(var r in e){if(Object.prototype.hasOwnProperty.call(e,r))t[r]=e[r]}}t.default=e;return t}}(i);function a(e){var t=o.detectBrowser(e),r=e&&e.navigator,a=e&&e.MediaStreamTrack;r.getUserMedia=function(e,t,a){o.deprecated("navigator.getUserMedia","navigator.mediaDevices.getUserMedia");r.mediaDevices.getUserMedia(e).then(t,a)};if(!(55<t.version&&"autoGainControl"in r.mediaDevices.getSupportedConstraints())){var i=function(e,t,r){if(t in e&&!(r in e)){e[r]=e[t];delete e[t]}},s=r.mediaDevices.getUserMedia.bind(r.mediaDevices);r.mediaDevices.getUserMedia=function(e){if("object"===("undefined"==typeof e?"undefined":n(e))&&"object"===n(e.audio)){e=JSON.parse(JSON.stringify(e));i(e.audio,"autoGainControl","mozAutoGainControl");i(e.audio,"noiseSuppression","mozNoiseSuppression")}return s(e)};if(a&&a.prototype.getSettings){var d=a.prototype.getSettings;a.prototype.getSettings=function(){var e=d.apply(this,arguments);i(e,"mozAutoGainControl","autoGainControl");i(e,"mozNoiseSuppression","noiseSuppression");return e}}if(a&&a.prototype.applyConstraints){var p=a.prototype.applyConstraints;a.prototype.applyConstraints=function(e){if("audio"===this.kind&&"object"===("undefined"==typeof e?"undefined":n(e))){e=JSON.parse(JSON.stringify(e));i(e,"autoGainControl","mozAutoGainControl");i(e,"noiseSuppression","mozNoiseSuppression")}return p.apply(this,[e])}}}}},{"../utils":15}],14:[function(e,t,r){'use strict';Object.defineProperty(r,"__esModule",{value:!0});var d="function"==typeof Symbol&&"symbol"===_typeof2(Symbol.iterator)?function(e){return _typeof2(e)}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":_typeof2(e)};r.shimLocalStreamsAPI=a;r.shimRemoteStreamsAPI=n;r.shimCallbacksAPI=function(e){if("object"!==("undefined"==typeof e?"undefined":d(e))||!e.RTCPeerConnection){return}var t=e.RTCPeerConnection.prototype,r=t.createOffer,a=t.createAnswer,n=t.setLocalDescription,i=t.setRemoteDescription,o=t.addIceCandidate;t.createOffer=function(e,t){var a=2<=arguments.length?arguments[2]:arguments[0],n=r.apply(this,[a]);if(!t){return n}n.then(e,t);return Promise.resolve()};t.createAnswer=function(e,t){var r=2<=arguments.length?arguments[2]:arguments[0],n=a.apply(this,[r]);if(!t){return n}n.then(e,t);return Promise.resolve()};var s=function(e,t,r){var a=n.apply(this,[e]);if(!r){return a}a.then(t,r);return Promise.resolve()};t.setLocalDescription=s;s=function(e,t,r){var a=i.apply(this,[e]);if(!r){return a}a.then(t,r);return Promise.resolve()};t.setRemoteDescription=s;s=function(e,t,r){var a=o.apply(this,[e]);if(!r){return a}a.then(t,r);return Promise.resolve()};t.addIceCandidate=s};r.shimGetUserMedia=function(e){var t=e&&e.navigator;if(t.mediaDevices&&t.mediaDevices.getUserMedia){var r=t.mediaDevices,a=r.getUserMedia.bind(r);t.mediaDevices.getUserMedia=function(e){return a(i(e))}}if(!t.getUserMedia&&t.mediaDevices&&t.mediaDevices.getUserMedia){t.getUserMedia=function(e,r,a){t.mediaDevices.getUserMedia(e).then(r,a)}.bind(t)}};r.shimConstraints=i;r.shimRTCIceServerUrls=o;r.shimTrackEventTransceiver=s;r.shimCreateOfferLegacy=function(e){var t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(e){if(e){if("undefined"!=typeof e.offerToReceiveAudio){e.offerToReceiveAudio=!!e.offerToReceiveAudio}var r=this.getTransceivers().find(function(e){return"audio"===e.receiver.track.kind});if(!1===e.offerToReceiveAudio&&r){if("sendrecv"===r.direction){if(r.setDirection){r.setDirection("sendonly")}else{r.direction="sendonly"}}else if("recvonly"===r.direction){if(r.setDirection){r.setDirection("inactive")}else{r.direction="inactive"}}}else if(!0===e.offerToReceiveAudio&&!r){this.addTransceiver("audio")}if("undefined"!=typeof e.offerToReceiveVideo){e.offerToReceiveVideo=!!e.offerToReceiveVideo}var a=this.getTransceivers().find(function(e){return"video"===e.receiver.track.kind});if(!1===e.offerToReceiveVideo&&a){if("sendrecv"===a.direction){if(a.setDirection){a.setDirection("sendonly")}else{a.direction="sendonly"}}else if("recvonly"===a.direction){if(a.setDirection){a.setDirection("inactive")}else{a.direction="inactive"}}}else if(!0===e.offerToReceiveVideo&&!a){this.addTransceiver("video")}}return t.apply(this,arguments)}};var c=e("../utils"),p=function(e){if(e&&e.__esModule){return e}else{var t={};if(null!=e){for(var r in e){if(Object.prototype.hasOwnProperty.call(e,r))t[r]=e[r]}}t.default=e;return t}}(c);function a(e){if("object"!==("undefined"==typeof e?"undefined":d(e))||!e.RTCPeerConnection){return}if(!("getLocalStreams"in e.RTCPeerConnection.prototype)){e.RTCPeerConnection.prototype.getLocalStreams=function(){if(!this._localStreams){this._localStreams=[]}return this._localStreams}}if(!("addStream"in e.RTCPeerConnection.prototype)){var t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addStream=function(e){var r=this;if(!this._localStreams){this._localStreams=[]}if(!this._localStreams.includes(e)){this._localStreams.push(e)}e.getAudioTracks().forEach(function(a){return t.call(r,a,e)});e.getVideoTracks().forEach(function(a){return t.call(r,a,e)})};e.RTCPeerConnection.prototype.addTrack=function(){var e=arguments[1];if(e){if(!this._localStreams){this._localStreams=[e]}else if(!this._localStreams.includes(e)){this._localStreams.push(e)}}return t.apply(this,arguments)}}if(!("removeStream"in e.RTCPeerConnection.prototype)){e.RTCPeerConnection.prototype.removeStream=function(e){var t=this;if(!this._localStreams){this._localStreams=[]}var r=this._localStreams.indexOf(e);if(-1===r){return}this._localStreams.splice(r,1);var a=e.getTracks();this.getSenders().forEach(function(e){if(a.includes(e.track)){t.removeTrack(e)}})}}}function n(e){if("object"!==("undefined"==typeof e?"undefined":d(e))||!e.RTCPeerConnection){return}if(!("getRemoteStreams"in e.RTCPeerConnection.prototype)){e.RTCPeerConnection.prototype.getRemoteStreams=function(){return this._remoteStreams?this._remoteStreams:[]}}if(!("onaddstream"in e.RTCPeerConnection.prototype)){Object.defineProperty(e.RTCPeerConnection.prototype,"onaddstream",{get:function(){return this._onaddstream},set:function(e){var t=this;if(this._onaddstream){this.removeEventListener("addstream",this._onaddstream);this.removeEventListener("track",this._onaddstreampoly)}this.addEventListener("addstream",this._onaddstream=e);this.addEventListener("track",this._onaddstreampoly=function(r){r.streams.forEach(function(e){if(!t._remoteStreams){t._remoteStreams=[]}if(t._remoteStreams.includes(e)){return}t._remoteStreams.push(e);var r=new Event("addstream");r.stream=e;t.dispatchEvent(r)})})}});var t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){var e=this;if(!this._onaddstreampoly){this.addEventListener("track",this._onaddstreampoly=function(t){t.streams.forEach(function(t){if(!e._remoteStreams){e._remoteStreams=[]}if(0<=e._remoteStreams.indexOf(t)){return}e._remoteStreams.push(t);var r=new Event("addstream");r.stream=t;e.dispatchEvent(r)})})}return t.apply(e,arguments)}}}function i(e){if(e&&e.video!==void 0){return Object.assign({},e,{video:p.compactObject(e.video)})}return e}function o(e){var t=e.RTCPeerConnection;e.RTCPeerConnection=function(e,r){if(e&&e.iceServers){for(var a=[],n=0,o;n<e.iceServers.length;n++){o=e.iceServers[n];if(!o.hasOwnProperty("urls")&&o.hasOwnProperty("url")){p.deprecated("RTCIceServer.url","RTCIceServer.urls");o=JSON.parse(JSON.stringify(o));o.urls=o.url;delete o.url;a.push(o)}else{a.push(e.iceServers[n])}}e.iceServers=a}return new t(e,r)};e.RTCPeerConnection.prototype=t.prototype;if("generateCertificate"in e.RTCPeerConnection){Object.defineProperty(e.RTCPeerConnection,"generateCertificate",{get:function(){return t.generateCertificate}})}}function s(e){if("object"===("undefined"==typeof e?"undefined":d(e))&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)){Object.defineProperty(e.RTCTrackEvent.prototype,"transceiver",{get:function(){return{receiver:this.receiver}}})}}},{"../utils":15}],15:[function(e,t,r){'use strict';Object.defineProperty(r,"__esModule",{value:!0});var l="function"==typeof Symbol&&"symbol"===_typeof2(Symbol.iterator)?function(e){return _typeof2(e)}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":_typeof2(e)};r.extractVersion=n;r.wrapPeerConnectionEvent=function(e,t,r){if(!e.RTCPeerConnection){return}var a=e.RTCPeerConnection.prototype,n=a.addEventListener;a.addEventListener=function(e,a){if(e!==t){return n.apply(this,arguments)}var i=function(t){var e=r(t);if(e){a(e)}};this._eventMap=this._eventMap||{};this._eventMap[a]=i;return n.apply(this,[e,i])};var i=a.removeEventListener;a.removeEventListener=function(e,r){if(e!==t||!this._eventMap||!this._eventMap[r]){return i.apply(this,arguments)}var a=this._eventMap[r];delete this._eventMap[r];return i.apply(this,[e,a])};Object.defineProperty(a,"on"+t,{get:function(){return this["_on"+t]},set:function(e){if(this["_on"+t]){this.removeEventListener(t,this["_on"+t]);delete this["_on"+t]}if(e){this.addEventListener(t,this["_on"+t]=e)}},enumerable:!0,configurable:!0})};r.disableLog=function(e){if("boolean"!=typeof e){return new Error("Argument type: "+("undefined"==typeof e?"undefined":l(e))+". Please use a boolean.")}m=e;return e?"adapter.js logging disabled":"adapter.js logging enabled"};r.disableWarnings=function(e){if("boolean"!=typeof e){return new Error("Argument type: "+("undefined"==typeof e?"undefined":l(e))+". Please use a boolean.")}f=!e;return"adapter.js deprecation warnings "+(e?"disabled":"enabled")};r.log=i;r.deprecated=o;r.detectBrowser=s;r.compactObject=c;r.walkStats=p;r.filterStats=function(e,t,r){var a=r?"outbound-rtp":"inbound-rtp",n=new Map;if(null===t){return n}var i=[];e.forEach(function(e){if("track"===e.type&&e.trackIdentifier===t.id){i.push(e)}});i.forEach(function(t){e.forEach(function(r){if(r.type===a&&r.trackId===t.id){p(e,r,n)}})});return n};function a(e,t,r){if(t in e){Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0})}else{e[t]=r}return e}var m=!0,f=!0;function n(e,t,r){var a=e.match(t);return a&&a.length>=r&&parseInt(a[r],10)}function i(){if("object"===("undefined"==typeof window?"undefined":l(window))){if(m){return}if("undefined"!=typeof console&&"function"==typeof console.log){console.log.apply(console,arguments)}}}function o(e,t){if(!f){return}console.warn(e+" is deprecated, please use "+t+" instead.")}function s(e){var t=e.navigator,r={browser:null,version:null};if("undefined"==typeof e||!e.navigator){r.browser="Not a browser.";return r}if(t.mozGetUserMedia){r.browser="firefox";r.version=n(t.userAgent,/Firefox\/(\d+)\./,1)}else if(t.webkitGetUserMedia||!1===e.isSecureContext&&e.webkitRTCPeerConnection&&!e.RTCIceGatherer){r.browser="chrome";r.version=n(t.userAgent,/Chrom(e|ium)\/(\d+)\./,2)}else if(t.mediaDevices&&t.userAgent.match(/Edge\/(\d+).(\d+)$/)){r.browser="edge";r.version=n(t.userAgent,/Edge\/(\d+).(\d+)$/,2)}else if(e.RTCPeerConnection&&t.userAgent.match(/AppleWebKit\/(\d+)\./)){r.browser="safari";r.version=n(t.userAgent,/AppleWebKit\/(\d+)\./,1);r.supportsUnifiedPlan=e.RTCRtpTransceiver&&"currentDirection"in e.RTCRtpTransceiver.prototype}else{r.browser="Not a supported browser.";return r}return r}function d(e){return"[object Object]"===Object.prototype.toString.call(e)}function c(e){if(!d(e)){return e}return Object.keys(e).reduce(function(t,r){var n=d(e[r]),i=n?c(e[r]):e[r],o=n&&!Object.keys(i).length;if(i===void 0||o){return t}return Object.assign(t,a({},r,i))},{})}function p(e,t,r){if(!t||r.has(t.id)){return}r.set(t.id,t);Object.keys(t).forEach(function(a){if(a.endsWith("Id")){p(e,e.get(t[a]),r)}else if(a.endsWith("Ids")){t[a].forEach(function(t){p(e,e.get(t),r)})}})}},{}],16:[function(e,t){'use strict';var c=e("sdp");function r(e){return{inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[e.type]||e.type}function a(e,t,r,a,n){var i=c.writeRtpDescription(e.kind,t);i+=c.writeIceParameters(e.iceGatherer.getLocalParameters());i+=c.writeDtlsParameters(e.dtlsTransport.getLocalParameters(),"offer"===r?"actpass":n||"active");i+="a=mid:"+e.mid+"\r\n";if(e.rtpSender&&e.rtpReceiver){i+="a=sendrecv\r\n"}else if(e.rtpSender){i+="a=sendonly\r\n"}else if(e.rtpReceiver){i+="a=recvonly\r\n"}else{i+="a=inactive\r\n"}if(e.rtpSender){var o=e.rtpSender._initialTrackId||e.rtpSender.track.id;e.rtpSender._initialTrackId=o;var s="msid:"+(a?a.id:"-")+" "+o+"\r\n";i+="a="+s;i+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" "+s;if(e.sendEncodingParameters[0].rtx){i+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" "+s;i+="a=ssrc-group:FID "+e.sendEncodingParameters[0].ssrc+" "+e.sendEncodingParameters[0].rtx.ssrc+"\r\n"}}i+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" cname:"+c.localCName+"\r\n";if(e.rtpSender&&e.sendEncodingParameters[0].rtx){i+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" cname:"+c.localCName+"\r\n"}return i}function n(e,t){var r=!1;e=JSON.parse(JSON.stringify(e));return e.filter(function(e){if(e&&(e.urls||e.url)){var a=e.urls||e.url;if(e.url&&!e.urls){console.warn("RTCIceServer.url is deprecated! Use urls instead.")}var n="string"==typeof a;if(n){a=[a]}a=a.filter(function(e){var a=0===e.indexOf("turn:")&&-1!==e.indexOf("transport=udp")&&-1===e.indexOf("turn:[")&&!r;if(a){r=!0;return!0}return 0===e.indexOf("stun:")&&14393<=t&&-1===e.indexOf("?transport=udp")});delete e.url;e.urls=n?a[0]:a;return!!a.length}})}function i(e,t){var r={codecs:[],headerExtensions:[],fecMechanisms:[]},a=function(e,t){e=parseInt(e,10);for(var r=0;r<t.length;r++){if(t[r].payloadType===e||t[r].preferredPayloadType===e){return t[r]}}},n=function(e,t,r,n){var i=a(e.parameters.apt,r),o=a(t.parameters.apt,n);return i&&o&&i.name.toLowerCase()===o.name.toLowerCase()};e.codecs.forEach(function(a){for(var o=0,s;o<t.codecs.length;o++){s=t.codecs[o];if(a.name.toLowerCase()===s.name.toLowerCase()&&a.clockRate===s.clockRate){if("rtx"===a.name.toLowerCase()&&a.parameters&&s.parameters.apt){if(!n(a,s,e.codecs,t.codecs)){continue}}s=JSON.parse(JSON.stringify(s));s.numChannels=Math.min(a.numChannels,s.numChannels);r.codecs.push(s);s.rtcpFeedback=s.rtcpFeedback.filter(function(e){for(var t=0;t<a.rtcpFeedback.length;t++){if(a.rtcpFeedback[t].type===e.type&&a.rtcpFeedback[t].parameter===e.parameter){return!0}}return!1});break}}});e.headerExtensions.forEach(function(e){for(var a=0,n;a<t.headerExtensions.length;a++){n=t.headerExtensions[a];if(e.uri===n.uri){r.headerExtensions.push(n);break}}});return r}function o(e,t,r){return-1!=={offer:{setLocalDescription:["stable","have-local-offer"],setRemoteDescription:["stable","have-remote-offer"]},answer:{setLocalDescription:["have-remote-offer","have-local-pranswer"],setRemoteDescription:["have-local-offer","have-remote-pranswer"]}}[t][e].indexOf(r)}function s(e,t){var r=e.getRemoteCandidates().find(function(e){return t.foundation===e.foundation&&t.ip===e.ip&&t.port===e.port&&t.priority===e.priority&&t.protocol===e.protocol&&t.type===e.type});if(!r){e.addRemoteCandidate(t)}return!r}function d(t,r){var a=new Error(r);a.name=t;a.code={NotSupportedError:9,InvalidStateError:11,InvalidAccessError:15,TypeError:void 0,OperationError:void 0}[t];return a}t.exports=function(e,t){function p(t,r){r.addTrack(t);r.dispatchEvent(new e.MediaStreamTrackEvent("addtrack",{track:t}))}function l(t,r){r.removeTrack(t);r.dispatchEvent(new e.MediaStreamTrackEvent("removetrack",{track:t}))}function m(t,r,a,n){var i=new Event("track");i.track=r;i.receiver=a;i.transceiver={receiver:a};i.streams=n;e.setTimeout(function(){t._dispatchEvent("track",i)})}var f=function(r){var a=this,o=document.createDocumentFragment();["addEventListener","removeEventListener","dispatchEvent"].forEach(function(e){a[e]=o[e].bind(o)});this.canTrickleIceCandidates=null;this.needNegotiation=!1;this.localStreams=[];this.remoteStreams=[];this._localDescription=null;this._remoteDescription=null;this.signalingState="stable";this.iceConnectionState="new";this.connectionState="new";this.iceGatheringState="new";r=JSON.parse(JSON.stringify(r||{}));this.usingBundle="max-bundle"===r.bundlePolicy;if("negotiate"===r.rtcpMuxPolicy){throw d("NotSupportedError","rtcpMuxPolicy 'negotiate' is not supported")}else if(!r.rtcpMuxPolicy){r.rtcpMuxPolicy="require"}switch(r.iceTransportPolicy){case"all":case"relay":break;default:r.iceTransportPolicy="all";break;}switch(r.bundlePolicy){case"balanced":case"max-compat":case"max-bundle":break;default:r.bundlePolicy="balanced";break;}r.iceServers=n(r.iceServers||[],t);this._iceGatherers=[];if(r.iceCandidatePoolSize){for(var s=r.iceCandidatePoolSize;0<s;s--){this._iceGatherers.push(new e.RTCIceGatherer({iceServers:r.iceServers,gatherPolicy:r.iceTransportPolicy}))}}else{r.iceCandidatePoolSize=0}this._config=r;this.transceivers=[];this._sdpSessionId=c.generateSessionId();this._sdpSessionVersion=0;this._dtlsRole=void 0;this._isClosed=!1};Object.defineProperty(f.prototype,"localDescription",{configurable:!0,get:function get(){return this._localDescription}});Object.defineProperty(f.prototype,"remoteDescription",{configurable:!0,get:function get(){return this._remoteDescription}});f.prototype.onicecandidate=null;f.prototype.onaddstream=null;f.prototype.ontrack=null;f.prototype.onremovestream=null;f.prototype.onsignalingstatechange=null;f.prototype.oniceconnectionstatechange=null;f.prototype.onconnectionstatechange=null;f.prototype.onicegatheringstatechange=null;f.prototype.onnegotiationneeded=null;f.prototype.ondatachannel=null;f.prototype._dispatchEvent=function(e,t){if(this._isClosed){return}this.dispatchEvent(t);if("function"==typeof this["on"+e]){this["on"+e](t)}};f.prototype._emitGatheringStateChange=function(){var e=new Event("icegatheringstatechange");this._dispatchEvent("icegatheringstatechange",e)};f.prototype.getConfiguration=function(){return this._config};f.prototype.getLocalStreams=function(){return this.localStreams};f.prototype.getRemoteStreams=function(){return this.remoteStreams};f.prototype._createTransceiver=function(e,t){var r=0<this.transceivers.length,a={track:null,iceGatherer:null,iceTransport:null,dtlsTransport:null,localCapabilities:null,remoteCapabilities:null,rtpSender:null,rtpReceiver:null,kind:e,mid:null,sendEncodingParameters:null,recvEncodingParameters:null,stream:null,associatedRemoteMediaStreams:[],wantReceive:!0};if(this.usingBundle&&r){a.iceTransport=this.transceivers[0].iceTransport;a.dtlsTransport=this.transceivers[0].dtlsTransport}else{var n=this._createIceAndDtlsTransports();a.iceTransport=n.iceTransport;a.dtlsTransport=n.dtlsTransport}if(!t){this.transceivers.push(a)}return a};f.prototype.addTrack=function(t,r){if(this._isClosed){throw d("InvalidStateError","Attempted to call addTrack on a closed peerconnection.")}var a=this.transceivers.find(function(e){return e.track===t});if(a){throw d("InvalidAccessError","Track already exists.")}for(var n,o=0;o<this.transceivers.length;o++){if(!this.transceivers[o].track&&this.transceivers[o].kind===t.kind){n=this.transceivers[o]}}if(!n){n=this._createTransceiver(t.kind)}this._maybeFireNegotiationNeeded();if(-1===this.localStreams.indexOf(r)){this.localStreams.push(r)}n.track=t;n.stream=r;n.rtpSender=new e.RTCRtpSender(t,n.dtlsTransport);return n.rtpSender};f.prototype.addStream=function(e){var r=this;if(15025<=t){e.getTracks().forEach(function(t){r.addTrack(t,e)})}else{var a=e.clone();e.getTracks().forEach(function(e,t){var r=a.getTracks()[t];e.addEventListener("enabled",function(e){r.enabled=e.enabled})});a.getTracks().forEach(function(e){r.addTrack(e,a)})}};f.prototype.removeTrack=function(r){if(this._isClosed){throw d("InvalidStateError","Attempted to call removeTrack on a closed peerconnection.")}if(!(r instanceof e.RTCRtpSender)){throw new TypeError("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.")}var a=this.transceivers.find(function(e){return e.rtpSender===r});if(!a){throw d("InvalidAccessError","Sender was not created by this connection.")}var n=a.stream;a.rtpSender.stop();a.rtpSender=null;a.track=null;a.stream=null;var i=this.transceivers.map(function(e){return e.stream});if(-1===i.indexOf(n)&&-1<this.localStreams.indexOf(n)){this.localStreams.splice(this.localStreams.indexOf(n),1)}this._maybeFireNegotiationNeeded()};f.prototype.removeStream=function(e){var t=this;e.getTracks().forEach(function(e){var r=t.getSenders().find(function(t){return t.track===e});if(r){t.removeTrack(r)}})};f.prototype.getSenders=function(){return this.transceivers.filter(function(e){return!!e.rtpSender}).map(function(e){return e.rtpSender})};f.prototype.getReceivers=function(){return this.transceivers.filter(function(e){return!!e.rtpReceiver}).map(function(e){return e.rtpReceiver})};f.prototype._createIceGatherer=function(t,r){var a=this;if(r&&0<t){return this.transceivers[0].iceGatherer}else if(this._iceGatherers.length){return this._iceGatherers.shift()}var n=new e.RTCIceGatherer({iceServers:this._config.iceServers,gatherPolicy:this._config.iceTransportPolicy});Object.defineProperty(n,"state",{value:"new",writable:!0});this.transceivers[t].bufferedCandidateEvents=[];this.transceivers[t].bufferCandidates=function(e){var r=!e.candidate||0===Object.keys(e.candidate).length;n.state=r?"completed":"gathering";if(null!==a.transceivers[t].bufferedCandidateEvents){a.transceivers[t].bufferedCandidateEvents.push(e)}};n.addEventListener("localcandidate",this.transceivers[t].bufferCandidates);return n};f.prototype._gather=function(t,r){var a=this,n=this.transceivers[r].iceGatherer;if(n.onlocalcandidate){return}var i=this.transceivers[r].bufferedCandidateEvents;this.transceivers[r].bufferedCandidateEvents=null;n.removeEventListener("localcandidate",this.transceivers[r].bufferCandidates);n.onlocalcandidate=function(e){if(a.usingBundle&&0<r){return}var i=new Event("icecandidate");i.candidate={sdpMid:t,sdpMLineIndex:r};var o=e.candidate,s=!o||0===Object.keys(o).length;if(s){if("new"===n.state||"gathering"===n.state){n.state="completed"}}else{if("new"===n.state){n.state="gathering"}o.component=1;o.ufrag=n.getLocalParameters().usernameFragment;var d=c.writeCandidate(o);i.candidate=Object.assign(i.candidate,c.parseCandidate(d));i.candidate.candidate=d;i.candidate.toJSON=function(){return{candidate:i.candidate.candidate,sdpMid:i.candidate.sdpMid,sdpMLineIndex:i.candidate.sdpMLineIndex,usernameFragment:i.candidate.usernameFragment}}}var p=c.getMediaSections(a._localDescription.sdp);if(!s){p[i.candidate.sdpMLineIndex]+="a="+i.candidate.candidate+"\r\n"}else{p[i.candidate.sdpMLineIndex]+="a=end-of-candidates\r\n"}a._localDescription.sdp=c.getDescription(a._localDescription.sdp)+p.join("");var l=a.transceivers.every(function(e){return e.iceGatherer&&"completed"===e.iceGatherer.state});if("gathering"!==a.iceGatheringState){a.iceGatheringState="gathering";a._emitGatheringStateChange()}if(!s){a._dispatchEvent("icecandidate",i)}if(l){a._dispatchEvent("icecandidate",new Event("icecandidate"));a.iceGatheringState="complete";a._emitGatheringStateChange()}};e.setTimeout(function(){i.forEach(function(t){n.onlocalcandidate(t)})},0)};f.prototype._createIceAndDtlsTransports=function(){var t=this,r=new e.RTCIceTransport(null);r.onicestatechange=function(){t._updateIceConnectionState();t._updateConnectionState()};var a=new e.RTCDtlsTransport(r);a.ondtlsstatechange=function(){t._updateConnectionState()};a.onerror=function(){Object.defineProperty(a,"state",{value:"failed",writable:!0});t._updateConnectionState()};return{iceTransport:r,dtlsTransport:a}};f.prototype._disposeIceAndDtlsTransports=function(e){var t=this.transceivers[e].iceGatherer;if(t){delete t.onlocalcandidate;delete this.transceivers[e].iceGatherer}var r=this.transceivers[e].iceTransport;if(r){delete r.onicestatechange;delete this.transceivers[e].iceTransport}var a=this.transceivers[e].dtlsTransport;if(a){delete a.ondtlsstatechange;delete a.onerror;delete this.transceivers[e].dtlsTransport}};f.prototype._transceive=function(e,r,a){var n=i(e.localCapabilities,e.remoteCapabilities);if(r&&e.rtpSender){n.encodings=e.sendEncodingParameters;n.rtcp={cname:c.localCName,compound:e.rtcpParameters.compound};if(e.recvEncodingParameters.length){n.rtcp.ssrc=e.recvEncodingParameters[0].ssrc}e.rtpSender.send(n)}if(a&&e.rtpReceiver&&0<n.codecs.length){if("video"===e.kind&&e.recvEncodingParameters&&15019>t){e.recvEncodingParameters.forEach(function(e){delete e.rtx})}if(e.recvEncodingParameters.length){n.encodings=e.recvEncodingParameters}else{n.encodings=[{}]}n.rtcp={compound:e.rtcpParameters.compound};if(e.rtcpParameters.cname){n.rtcp.cname=e.rtcpParameters.cname}if(e.sendEncodingParameters.length){n.rtcp.ssrc=e.sendEncodingParameters[0].ssrc}e.rtpReceiver.receive(n)}};f.prototype.setLocalDescription=function(e){var t=this;if(-1===["offer","answer"].indexOf(e.type)){return Promise.reject(d("TypeError","Unsupported type \""+e.type+"\""))}if(!o("setLocalDescription",e.type,t.signalingState)||t._isClosed){return Promise.reject(d("InvalidStateError","Can not set local "+e.type+" in state "+t.signalingState))}var r,a;if("offer"===e.type){r=c.splitSections(e.sdp);a=r.shift();r.forEach(function(e,r){var a=c.parseRtpParameters(e);t.transceivers[r].localCapabilities=a});t.transceivers.forEach(function(e,r){t._gather(e.mid,r)})}else if("answer"===e.type){r=c.splitSections(t._remoteDescription.sdp);a=r.shift();var n=0<c.matchPrefix(a,"a=ice-lite").length;r.forEach(function(e,r){var o=t.transceivers[r],s=o.iceGatherer,d=o.iceTransport,p=o.dtlsTransport,l=o.localCapabilities,m=o.remoteCapabilities,f=c.isRejected(e)&&0===c.matchPrefix(e,"a=bundle-only").length;if(!f&&!o.rejected){var h=c.getIceParameters(e,a),g=c.getDtlsParameters(e,a);if(n){g.role="server"}if(!t.usingBundle||0===r){t._gather(o.mid,r);if("new"===d.state){d.start(s,h,n?"controlling":"controlled")}if("new"===p.state){p.start(g)}}var u=i(l,m);t._transceive(o,0<u.codecs.length,!1)}})}t._localDescription={type:e.type,sdp:e.sdp};if("offer"===e.type){t._updateSignalingState("have-local-offer")}else{t._updateSignalingState("stable")}return Promise.resolve()};f.prototype.setRemoteDescription=function(r){var a=this;if(-1===["offer","answer"].indexOf(r.type)){return Promise.reject(d("TypeError","Unsupported type \""+r.type+"\""))}if(!o("setRemoteDescription",r.type,a.signalingState)||a._isClosed){return Promise.reject(d("InvalidStateError","Can not set remote "+r.type+" in state "+a.signalingState))}var n={};a.remoteStreams.forEach(function(e){n[e.id]=e});var f=[],h=c.splitSections(r.sdp),g=h.shift(),u=0<c.matchPrefix(g,"a=ice-lite").length,y=0<c.matchPrefix(g,"a=group:BUNDLE ").length;a.usingBundle=y;var v=c.matchPrefix(g,"a=ice-options:")[0];if(v){a.canTrickleIceCandidates=0<=v.substr(14).split(" ").indexOf("trickle")}else{a.canTrickleIceCandidates=!1}h.forEach(function(o,d){var m=c.splitLines(o),h=c.getKind(o),v=c.isRejected(o)&&0===c.matchPrefix(o,"a=bundle-only").length,C=m[0].substr(2).split(" ")[2],T=c.getDirection(o,g),S=c.parseMsid(o),R=c.getMid(o)||c.generateIdentifier();if(v||"application"===h&&("DTLS/SCTP"===C||"UDP/DTLS/SCTP"===C)){a.transceivers[d]={mid:R,kind:h,protocol:C,rejected:!0};return}if(!v&&a.transceivers[d]&&a.transceivers[d].rejected){a.transceivers[d]=a._createTransceiver(h,!0)}var P,_,E,k,b,x,M,D,I,w=c.parseRtpParameters(o),L,G;if(!v){L=c.getIceParameters(o,g);G=c.getDtlsParameters(o,g);G.role="client"}M=c.parseRtpEncodingParameters(o);var j=c.parseRtcpParameters(o),O=0<c.matchPrefix(o,"a=end-of-candidates",g).length,A=c.matchPrefix(o,"a=candidate:").map(function(e){return c.parseCandidate(e)}).filter(function(e){return 1===e.component});if(("offer"===r.type||"answer"===r.type)&&!v&&y&&0<d&&a.transceivers[d]){a._disposeIceAndDtlsTransports(d);a.transceivers[d].iceGatherer=a.transceivers[0].iceGatherer;a.transceivers[d].iceTransport=a.transceivers[0].iceTransport;a.transceivers[d].dtlsTransport=a.transceivers[0].dtlsTransport;if(a.transceivers[d].rtpSender){a.transceivers[d].rtpSender.setTransport(a.transceivers[0].dtlsTransport)}if(a.transceivers[d].rtpReceiver){a.transceivers[d].rtpReceiver.setTransport(a.transceivers[0].dtlsTransport)}}if("offer"===r.type&&!v){P=a.transceivers[d]||a._createTransceiver(h);P.mid=R;if(!P.iceGatherer){P.iceGatherer=a._createIceGatherer(d,y)}if(A.length&&"new"===P.iceTransport.state){if(O&&(!y||0===d)){P.iceTransport.setRemoteCandidates(A)}else{A.forEach(function(e){s(P.iceTransport,e)})}}D=e.RTCRtpReceiver.getCapabilities(h);if(15019>t){D.codecs=D.codecs.filter(function(e){return"rtx"!==e.name})}x=P.sendEncodingParameters||[{ssrc:1001*(2*d+2)}];var U=!1;if("sendrecv"===T||"sendonly"===T){U=!P.rtpReceiver;b=P.rtpReceiver||new e.RTCRtpReceiver(P.dtlsTransport,h);if(U){var F;I=b.track;if(S&&"-"===S.stream){}else if(S){if(!n[S.stream]){n[S.stream]=new e.MediaStream;Object.defineProperty(n[S.stream],"id",{get:function get(){return S.stream}})}Object.defineProperty(I,"id",{get:function get(){return S.track}});F=n[S.stream]}else{if(!n.default){n.default=new e.MediaStream}F=n.default}if(F){p(I,F);P.associatedRemoteMediaStreams.push(F)}f.push([I,b,F])}}else if(P.rtpReceiver&&P.rtpReceiver.track){P.associatedRemoteMediaStreams.forEach(function(e){var t=e.getTracks().find(function(e){return e.id===P.rtpReceiver.track.id});if(t){l(t,e)}});P.associatedRemoteMediaStreams=[]}P.localCapabilities=D;P.remoteCapabilities=w;P.rtpReceiver=b;P.rtcpParameters=j;P.sendEncodingParameters=x;P.recvEncodingParameters=M;a._transceive(a.transceivers[d],!1,U)}else if("answer"===r.type&&!v){P=a.transceivers[d];_=P.iceGatherer;E=P.iceTransport;k=P.dtlsTransport;b=P.rtpReceiver;x=P.sendEncodingParameters;D=P.localCapabilities;a.transceivers[d].recvEncodingParameters=M;a.transceivers[d].remoteCapabilities=w;a.transceivers[d].rtcpParameters=j;if(A.length&&"new"===E.state){if((u||O)&&(!y||0===d)){E.setRemoteCandidates(A)}else{A.forEach(function(e){s(P.iceTransport,e)})}}if(!y||0===d){if("new"===E.state){E.start(_,L,"controlling")}if("new"===k.state){k.start(G)}}var N=i(P.localCapabilities,P.remoteCapabilities),z=N.codecs.filter(function(e){return"rtx"===e.name.toLowerCase()}).length;if(!z&&P.sendEncodingParameters[0].rtx){delete P.sendEncodingParameters[0].rtx}a._transceive(P,"sendrecv"===T||"recvonly"===T,"sendrecv"===T||"sendonly"===T);if(b&&("sendrecv"===T||"sendonly"===T)){I=b.track;if(S){if(!n[S.stream]){n[S.stream]=new e.MediaStream}p(I,n[S.stream]);f.push([I,b,n[S.stream]])}else{if(!n.default){n.default=new e.MediaStream}p(I,n.default);f.push([I,b,n.default])}}else{delete P.rtpReceiver}}});if(a._dtlsRole===void 0){a._dtlsRole="offer"===r.type?"active":"passive"}a._remoteDescription={type:r.type,sdp:r.sdp};if("offer"===r.type){a._updateSignalingState("have-remote-offer")}else{a._updateSignalingState("stable")}Object.keys(n).forEach(function(t){var r=n[t];if(r.getTracks().length){if(-1===a.remoteStreams.indexOf(r)){a.remoteStreams.push(r);var i=new Event("addstream");i.stream=r;e.setTimeout(function(){a._dispatchEvent("addstream",i)})}f.forEach(function(e){var t=e[0],n=e[1];if(r.id!==e[2].id){return}m(a,t,n,[r])})}});f.forEach(function(e){if(e[2]){return}m(a,e[0],e[1],[])});e.setTimeout(function(){if(!(a&&a.transceivers)){return}a.transceivers.forEach(function(e){if(e.iceTransport&&"new"===e.iceTransport.state&&0<e.iceTransport.getRemoteCandidates().length){console.warn("Timeout for addRemoteCandidate. Consider sending an end-of-candidates notification");e.iceTransport.addRemoteCandidate({})}})},4e3);return Promise.resolve()};f.prototype.close=function(){this.transceivers.forEach(function(e){if(e.iceTransport){e.iceTransport.stop()}if(e.dtlsTransport){e.dtlsTransport.stop()}if(e.rtpSender){e.rtpSender.stop()}if(e.rtpReceiver){e.rtpReceiver.stop()}});this._isClosed=!0;this._updateSignalingState("closed")};f.prototype._updateSignalingState=function(e){this.signalingState=e;var t=new Event("signalingstatechange");this._dispatchEvent("signalingstatechange",t)};f.prototype._maybeFireNegotiationNeeded=function(){var t=this;if("stable"!==this.signalingState||!0===this.needNegotiation){return}this.needNegotiation=!0;e.setTimeout(function(){if(t.needNegotiation){t.needNegotiation=!1;var e=new Event("negotiationneeded");t._dispatchEvent("negotiationneeded",e)}},0)};f.prototype._updateIceConnectionState=function(){var e,t={new:0,closed:0,checking:0,connected:0,completed:0,disconnected:0,failed:0};this.transceivers.forEach(function(e){if(e.iceTransport&&!e.rejected){t[e.iceTransport.state]++}});e="new";if(0<t.failed){e="failed"}else if(0<t.checking){e="checking"}else if(0<t.disconnected){e="disconnected"}else if(0<t.new){e="new"}else if(0<t.connected){e="connected"}else if(0<t.completed){e="completed"}if(e!==this.iceConnectionState){this.iceConnectionState=e;var r=new Event("iceconnectionstatechange");this._dispatchEvent("iceconnectionstatechange",r)}};f.prototype._updateConnectionState=function(){var e,t={new:0,closed:0,connecting:0,connected:0,completed:0,disconnected:0,failed:0};this.transceivers.forEach(function(e){if(e.iceTransport&&e.dtlsTransport&&!e.rejected){t[e.iceTransport.state]++;t[e.dtlsTransport.state]++}});t.connected+=t.completed;e="new";if(0<t.failed){e="failed"}else if(0<t.connecting){e="connecting"}else if(0<t.disconnected){e="disconnected"}else if(0<t.new){e="new"}else if(0<t.connected){e="connected"}if(e!==this.connectionState){this.connectionState=e;var r=new Event("connectionstatechange");this._dispatchEvent("connectionstatechange",r)}};f.prototype.createOffer=function(){var r=this;if(r._isClosed){return Promise.reject(d("InvalidStateError","Can not call createOffer after close"))}var n=r.transceivers.filter(function(e){return"audio"===e.kind}).length,i=r.transceivers.filter(function(e){return"video"===e.kind}).length,o=arguments[0];if(o){if(o.mandatory||o.optional){throw new TypeError("Legacy mandatory/optional constraints not supported.")}if(o.offerToReceiveAudio!==void 0){if(!0===o.offerToReceiveAudio){n=1}else if(!1===o.offerToReceiveAudio){n=0}else{n=o.offerToReceiveAudio}}if(o.offerToReceiveVideo!==void 0){if(!0===o.offerToReceiveVideo){i=1}else if(!1===o.offerToReceiveVideo){i=0}else{i=o.offerToReceiveVideo}}}r.transceivers.forEach(function(e){if("audio"===e.kind){n--;if(0>n){e.wantReceive=!1}}else if("video"===e.kind){i--;if(0>i){e.wantReceive=!1}}});while(0<n||0<i){if(0<n){r._createTransceiver("audio");n--}if(0<i){r._createTransceiver("video");i--}}var s=c.writeSessionBoilerplate(r._sdpSessionId,r._sdpSessionVersion++);r.transceivers.forEach(function(a,n){var i=a.track,o=a.kind,s=a.mid||c.generateIdentifier();a.mid=s;if(!a.iceGatherer){a.iceGatherer=r._createIceGatherer(n,r.usingBundle)}var d=e.RTCRtpSender.getCapabilities(o);if(15019>t){d.codecs=d.codecs.filter(function(e){return"rtx"!==e.name})}d.codecs.forEach(function(e){if("H264"===e.name&&e.parameters["level-asymmetry-allowed"]===void 0){e.parameters["level-asymmetry-allowed"]="1"}if(a.remoteCapabilities&&a.remoteCapabilities.codecs){a.remoteCapabilities.codecs.forEach(function(t){if(e.name.toLowerCase()===t.name.toLowerCase()&&e.clockRate===t.clockRate){e.preferredPayloadType=t.payloadType}})}});d.headerExtensions.forEach(function(e){var t=a.remoteCapabilities&&a.remoteCapabilities.headerExtensions||[];t.forEach(function(t){if(e.uri===t.uri){e.id=t.id}})});var p=a.sendEncodingParameters||[{ssrc:1001*(2*n+1)}];if(i){if(15019<=t&&"video"===o&&!p[0].rtx){p[0].rtx={ssrc:p[0].ssrc+1}}}if(a.wantReceive){a.rtpReceiver=new e.RTCRtpReceiver(a.dtlsTransport,o)}a.localCapabilities=d;a.sendEncodingParameters=p});if("max-compat"!==r._config.bundlePolicy){s+="a=group:BUNDLE "+r.transceivers.map(function(e){return e.mid}).join(" ")+"\r\n"}s+="a=ice-options:trickle\r\n";r.transceivers.forEach(function(e,t){s+=a(e,e.localCapabilities,"offer",e.stream,r._dtlsRole);s+="a=rtcp-rsize\r\n";if(e.iceGatherer&&"new"!==r.iceGatheringState&&(0===t||!r.usingBundle)){e.iceGatherer.getLocalCandidates().forEach(function(e){e.component=1;s+="a="+c.writeCandidate(e)+"\r\n"});if("completed"===e.iceGatherer.state){s+="a=end-of-candidates\r\n"}}});var p=new e.RTCSessionDescription({type:"offer",sdp:s});return Promise.resolve(p)};f.prototype.createAnswer=function(){var r=this;if(r._isClosed){return Promise.reject(d("InvalidStateError","Can not call createAnswer after close"))}if(!("have-remote-offer"===r.signalingState||"have-local-pranswer"===r.signalingState)){return Promise.reject(d("InvalidStateError","Can not call createAnswer in signalingState "+r.signalingState))}var n=c.writeSessionBoilerplate(r._sdpSessionId,r._sdpSessionVersion++);if(r.usingBundle){n+="a=group:BUNDLE "+r.transceivers.map(function(e){return e.mid}).join(" ")+"\r\n"}n+="a=ice-options:trickle\r\n";var o=c.getMediaSections(r._remoteDescription.sdp).length;r.transceivers.forEach(function(e,s){if(s+1>o){return}if(e.rejected){if("application"===e.kind){if("DTLS/SCTP"===e.protocol){n+="m=application 0 DTLS/SCTP 5000\r\n"}else{n+="m=application 0 "+e.protocol+" webrtc-datachannel\r\n"}}else if("audio"===e.kind){n+="m=audio 0 UDP/TLS/RTP/SAVPF 0\r\na=rtpmap:0 PCMU/8000\r\n"}else if("video"===e.kind){n+="m=video 0 UDP/TLS/RTP/SAVPF 120\r\na=rtpmap:120 VP8/90000\r\n"}n+="c=IN IP4 0.0.0.0\r\na=inactive\r\na=mid:"+e.mid+"\r\n";return}if(e.stream){var d;if("audio"===e.kind){d=e.stream.getAudioTracks()[0]}else if("video"===e.kind){d=e.stream.getVideoTracks()[0]}if(d){if(15019<=t&&"video"===e.kind&&!e.sendEncodingParameters[0].rtx){e.sendEncodingParameters[0].rtx={ssrc:e.sendEncodingParameters[0].ssrc+1}}}}var c=i(e.localCapabilities,e.remoteCapabilities),p=c.codecs.filter(function(e){return"rtx"===e.name.toLowerCase()}).length;if(!p&&e.sendEncodingParameters[0].rtx){delete e.sendEncodingParameters[0].rtx}n+=a(e,c,"answer",e.stream,r._dtlsRole);if(e.rtcpParameters&&e.rtcpParameters.reducedSize){n+="a=rtcp-rsize\r\n"}});var s=new e.RTCSessionDescription({type:"answer",sdp:n});return Promise.resolve(s)};f.prototype.addIceCandidate=function(e){var t=this,r;if(e&&!(e.sdpMLineIndex!==void 0||e.sdpMid)){return Promise.reject(new TypeError("sdpMLineIndex or sdpMid required"))}return new Promise(function(a,n){if(!t._remoteDescription){return n(d("InvalidStateError","Can not add ICE candidate without a remote description"))}else if(!e||""===e.candidate){for(var o=0;o<t.transceivers.length;o++){if(t.transceivers[o].rejected){continue}t.transceivers[o].iceTransport.addRemoteCandidate({});r=c.getMediaSections(t._remoteDescription.sdp);r[o]+="a=end-of-candidates\r\n";t._remoteDescription.sdp=c.getDescription(t._remoteDescription.sdp)+r.join("");if(t.usingBundle){break}}}else{var p=e.sdpMLineIndex;if(e.sdpMid){for(var l=0;l<t.transceivers.length;l++){if(t.transceivers[l].mid===e.sdpMid){p=l;break}}}var m=t.transceivers[p];if(m){if(m.rejected){return a()}var f=0<Object.keys(e.candidate).length?c.parseCandidate(e.candidate):{};if("tcp"===f.protocol&&(0===f.port||9===f.port)){return a()}if(f.component&&1!==f.component){return a()}if(0===p||0<p&&m.iceTransport!==t.transceivers[0].iceTransport){if(!s(m.iceTransport,f)){return n(d("OperationError","Can not add ICE candidate"))}}var h=e.candidate.trim();if(0===h.indexOf("a=")){h=h.substr(2)}r=c.getMediaSections(t._remoteDescription.sdp);r[p]+="a="+(f.type?h:"end-of-candidates")+"\r\n";t._remoteDescription.sdp=c.getDescription(t._remoteDescription.sdp)+r.join("")}else{return n(d("OperationError","Can not add ICE candidate"))}}a()})};f.prototype.getStats=function(t){if(t&&t instanceof e.MediaStreamTrack){var r=null;this.transceivers.forEach(function(e){if(e.rtpSender&&e.rtpSender.track===t){r=e.rtpSender}else if(e.rtpReceiver&&e.rtpReceiver.track===t){r=e.rtpReceiver}});if(!r){throw d("InvalidAccessError","Invalid selector.")}return r.getStats()}var a=[];this.transceivers.forEach(function(e){["rtpSender","rtpReceiver","iceGatherer","iceTransport","dtlsTransport"].forEach(function(t){if(e[t]){a.push(e[t].getStats())}})});return Promise.all(a).then(function(e){var t=new Map;e.forEach(function(e){e.forEach(function(e){t.set(e.id,e)})});return t})};["RTCRtpSender","RTCRtpReceiver","RTCIceGatherer","RTCIceTransport","RTCDtlsTransport"].forEach(function(t){var a=e[t];if(a&&a.prototype&&a.prototype.getStats){var n=a.prototype.getStats;a.prototype.getStats=function(){return n.apply(this).then(function(e){var t=new Map;Object.keys(e).forEach(function(a){e[a].type=r(e[a]);t.set(a,e[a])});return t})}}});var h=["createOffer","createAnswer"];h.forEach(function(e){var t=f.prototype[e];f.prototype[e]=function(){var e=arguments;if("function"==typeof e[0]||"function"==typeof e[1]){return t.apply(this,[arguments[2]]).then(function(t){if("function"==typeof e[0]){e[0].apply(null,[t])}},function(t){if("function"==typeof e[1]){e[1].apply(null,[t])}})}return t.apply(this,arguments)}});h=["setLocalDescription","setRemoteDescription","addIceCandidate"];h.forEach(function(e){var t=f.prototype[e];f.prototype[e]=function(){var e=arguments;if("function"==typeof e[1]||"function"==typeof e[2]){return t.apply(this,arguments).then(function(){if("function"==typeof e[1]){e[1].apply(null)}},function(t){if("function"==typeof e[2]){e[2].apply(null,[t])}})}return t.apply(this,arguments)}});["getStats"].forEach(function(e){var t=f.prototype[e];f.prototype[e]=function(){var e=arguments;if("function"==typeof e[1]){return t.apply(this,arguments).then(function(){if("function"==typeof e[1]){e[1].apply(null)}})}return t.apply(this,arguments)}});return f}},{sdp:17}],17:[function(e,t){'use strict';var r={generateIdentifier:function(){return Math.random().toString(36).substr(2,10)}};r.localCName=r.generateIdentifier();r.splitLines=function(e){return e.trim().split("\n").map(function(e){return e.trim()})};r.splitSections=function(e){var t=e.split("\nm=");return t.map(function(e,t){return(0<t?"m="+e:e).trim()+"\r\n"})};r.getDescription=function(e){var t=r.splitSections(e);return t&&t[0]};r.getMediaSections=function(e){var t=r.splitSections(e);t.shift();return t};r.matchPrefix=function(e,t){return r.splitLines(e).filter(function(e){return 0===e.indexOf(t)})};r.parseCandidate=function(e){var t;if(0===e.indexOf("a=candidate:")){t=e.substring(12).split(" ")}else{t=e.substring(10).split(" ")}for(var r={foundation:t[0],component:parseInt(t[1],10),protocol:t[2].toLowerCase(),priority:parseInt(t[3],10),ip:t[4],address:t[4],port:parseInt(t[5],10),type:t[7]},a=8;a<t.length;a+=2){switch(t[a]){case"raddr":r.relatedAddress=t[a+1];break;case"rport":r.relatedPort=parseInt(t[a+1],10);break;case"tcptype":r.tcpType=t[a+1];break;case"ufrag":r.ufrag=t[a+1];r.usernameFragment=t[a+1];break;default:r[t[a]]=t[a+1];break;}}return r};r.writeCandidate=function(e){var t=[e.foundation,e.component,e.protocol.toUpperCase(),e.priority,e.address||e.ip,e.port],r=e.type;t.push("typ");t.push(r);if("host"!==r&&e.relatedAddress&&e.relatedPort){t.push("raddr");t.push(e.relatedAddress);t.push("rport");t.push(e.relatedPort)}if(e.tcpType&&"tcp"===e.protocol.toLowerCase()){t.push("tcptype");t.push(e.tcpType)}if(e.usernameFragment||e.ufrag){t.push("ufrag");t.push(e.usernameFragment||e.ufrag)}return"candidate:"+t.join(" ")};r.parseIceOptions=function(e){return e.substr(14).split(" ")};r.parseRtpMap=function(e){var t=e.substr(9).split(" "),r={payloadType:parseInt(t.shift(),10)};t=t[0].split("/");r.name=t[0];r.clockRate=parseInt(t[1],10);r.channels=3===t.length?parseInt(t[2],10):1;r.numChannels=r.channels;return r};r.writeRtpMap=function(e){var t=e.payloadType;if(e.preferredPayloadType!==void 0){t=e.preferredPayloadType}var r=e.channels||e.numChannels||1;return"a=rtpmap:"+t+" "+e.name+"/"+e.clockRate+(1!==r?"/"+r:"")+"\r\n"};r.parseExtmap=function(e){var t=e.substr(9).split(" ");return{id:parseInt(t[0],10),direction:0<t[0].indexOf("/")?t[0].split("/")[1]:"sendrecv",uri:t[1]}};r.writeExtmap=function(e){return"a=extmap:"+(e.id||e.preferredId)+(e.direction&&"sendrecv"!==e.direction?"/"+e.direction:"")+" "+e.uri+"\r\n"};r.parseFmtp=function(e){for(var t={},r,a=e.substr(e.indexOf(" ")+1).split(";"),n=0;n<a.length;n++){r=a[n].trim().split("=");t[r[0].trim()]=r[1]}return t};r.writeFmtp=function(e){var t="",r=e.payloadType;if(e.preferredPayloadType!==void 0){r=e.preferredPayloadType}if(e.parameters&&Object.keys(e.parameters).length){var a=[];Object.keys(e.parameters).forEach(function(t){if(e.parameters[t]){a.push(t+"="+e.parameters[t])}else{a.push(t)}});t+="a=fmtp:"+r+" "+a.join(";")+"\r\n"}return t};r.parseRtcpFb=function(e){var t=e.substr(e.indexOf(" ")+1).split(" ");return{type:t.shift(),parameter:t.join(" ")}};r.writeRtcpFb=function(e){var t="",r=e.payloadType;if(e.preferredPayloadType!==void 0){r=e.preferredPayloadType}if(e.rtcpFeedback&&e.rtcpFeedback.length){e.rtcpFeedback.forEach(function(e){t+="a=rtcp-fb:"+r+" "+e.type+(e.parameter&&e.parameter.length?" "+e.parameter:"")+"\r\n"})}return t};r.parseSsrcMedia=function(e){var t=e.indexOf(" "),r={ssrc:parseInt(e.substr(7,t-7),10)},a=e.indexOf(":",t);if(-1<a){r.attribute=e.substr(t+1,a-t-1);r.value=e.substr(a+1)}else{r.attribute=e.substr(t+1)}return r};r.parseSsrcGroup=function(e){var t=e.substr(13).split(" ");return{semantics:t.shift(),ssrcs:t.map(function(e){return parseInt(e,10)})}};r.getMid=function(e){var t=r.matchPrefix(e,"a=mid:")[0];if(t){return t.substr(6)}};r.parseFingerprint=function(e){var t=e.substr(14).split(" ");return{algorithm:t[0].toLowerCase(),value:t[1]}};r.getDtlsParameters=function(e,t){var a=r.matchPrefix(e+t,"a=fingerprint:");return{role:"auto",fingerprints:a.map(r.parseFingerprint)}};r.writeDtlsParameters=function(e,t){var r="a=setup:"+t+"\r\n";e.fingerprints.forEach(function(e){r+="a=fingerprint:"+e.algorithm+" "+e.value+"\r\n"});return r};r.getIceParameters=function(e,t){var a=r.splitLines(e);a=a.concat(r.splitLines(t));var n={usernameFragment:a.filter(function(e){return 0===e.indexOf("a=ice-ufrag:")})[0].substr(12),password:a.filter(function(e){return 0===e.indexOf("a=ice-pwd:")})[0].substr(10)};return n};r.writeIceParameters=function(e){return"a=ice-ufrag:"+e.usernameFragment+"\r\na=ice-pwd:"+e.password+"\r\n"};r.parseRtpParameters=function(e){for(var t={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},a=r.splitLines(e),n=a[0].split(" "),o=3;o<n.length;o++){var s=n[o],d=r.matchPrefix(e,"a=rtpmap:"+s+" ")[0];if(d){var c=r.parseRtpMap(d),p=r.matchPrefix(e,"a=fmtp:"+s+" ");c.parameters=p.length?r.parseFmtp(p[0]):{};c.rtcpFeedback=r.matchPrefix(e,"a=rtcp-fb:"+s+" ").map(r.parseRtcpFb);t.codecs.push(c);switch(c.name.toUpperCase()){case"RED":case"ULPFEC":t.fecMechanisms.push(c.name.toUpperCase());break;default:break;}}}r.matchPrefix(e,"a=extmap:").forEach(function(e){t.headerExtensions.push(r.parseExtmap(e))});return t};r.writeRtpDescription=function(e,t){var a="";a+="m="+e+" ";a+=0<t.codecs.length?"9":"0";a+=" UDP/TLS/RTP/SAVPF ";a+=t.codecs.map(function(e){if(e.preferredPayloadType!==void 0){return e.preferredPayloadType}return e.payloadType}).join(" ")+"\r\n";a+="c=IN IP4 0.0.0.0\r\n";a+="a=rtcp:9 IN IP4 0.0.0.0\r\n";t.codecs.forEach(function(e){a+=r.writeRtpMap(e);a+=r.writeFmtp(e);a+=r.writeRtcpFb(e)});var n=0;t.codecs.forEach(function(e){if(e.maxptime>n){n=e.maxptime}});if(0<n){a+="a=maxptime:"+n+"\r\n"}a+="a=rtcp-mux\r\n";if(t.headerExtensions){t.headerExtensions.forEach(function(e){a+=r.writeExtmap(e)})}return a};r.parseRtpEncodingParameters=function(e){var t=[],a=r.parseRtpParameters(e),n=-1!==a.fecMechanisms.indexOf("RED"),i=-1!==a.fecMechanisms.indexOf("ULPFEC"),o=r.matchPrefix(e,"a=ssrc:").map(function(e){return r.parseSsrcMedia(e)}).filter(function(e){return"cname"===e.attribute}),s=0<o.length&&o[0].ssrc,d,c=r.matchPrefix(e,"a=ssrc-group:FID").map(function(e){var t=e.substr(17).split(" ");return t.map(function(e){return parseInt(e,10)})});if(0<c.length&&1<c[0].length&&c[0][0]===s){d=c[0][1]}a.codecs.forEach(function(e){if("RTX"===e.name.toUpperCase()&&e.parameters.apt){var r={ssrc:s,codecPayloadType:parseInt(e.parameters.apt,10)};if(s&&d){r.rtx={ssrc:d}}t.push(r);if(n){r=JSON.parse(JSON.stringify(r));r.fec={ssrc:s,mechanism:i?"red+ulpfec":"red"};t.push(r)}}});if(0===t.length&&s){t.push({ssrc:s})}var p=r.matchPrefix(e,"b=");if(p.length){if(0===p[0].indexOf("b=TIAS:")){p=parseInt(p[0].substr(7),10)}else if(0===p[0].indexOf("b=AS:")){p=.95*(1e3*parseInt(p[0].substr(5),10))-16000}else{p=void 0}t.forEach(function(e){e.maxBitrate=p})}return t};r.parseRtcpParameters=function(e){var t={},a=r.matchPrefix(e,"a=ssrc:").map(function(e){return r.parseSsrcMedia(e)}).filter(function(e){return"cname"===e.attribute})[0];if(a){t.cname=a.value;t.ssrc=a.ssrc}var n=r.matchPrefix(e,"a=rtcp-rsize");t.reducedSize=0<n.length;t.compound=0===n.length;var i=r.matchPrefix(e,"a=rtcp-mux");t.mux=0<i.length;return t};r.parseMsid=function(e){var t,a=r.matchPrefix(e,"a=msid:");if(1===a.length){t=a[0].substr(7).split(" ");return{stream:t[0],track:t[1]}}var n=r.matchPrefix(e,"a=ssrc:").map(function(e){return r.parseSsrcMedia(e)}).filter(function(e){return"msid"===e.attribute});if(0<n.length){t=n[0].value.split(" ");return{stream:t[0],track:t[1]}}};r.parseSctpDescription=function(e){var t=r.parseMLine(e),a=r.matchPrefix(e,"a=max-message-size:"),n;if(0<a.length){n=parseInt(a[0].substr(19),10)}if(isNaN(n)){n=65536}var i=r.matchPrefix(e,"a=sctp-port:");if(0<i.length){return{port:parseInt(i[0].substr(12),10),protocol:t.fmt,maxMessageSize:n}}var o=r.matchPrefix(e,"a=sctpmap:");if(0<o.length){var s=r.matchPrefix(e,"a=sctpmap:")[0].substr(10).split(" ");return{port:parseInt(s[0],10),protocol:s[1],maxMessageSize:n}}};r.writeSctpDescription=function(e,t){var r=[];if("DTLS/SCTP"!==e.protocol){r=["m="+e.kind+" 9 "+e.protocol+" "+t.protocol+"\r\n","c=IN IP4 0.0.0.0\r\n","a=sctp-port:"+t.port+"\r\n"]}else{r=["m="+e.kind+" 9 "+e.protocol+" "+t.port+"\r\n","c=IN IP4 0.0.0.0\r\n","a=sctpmap:"+t.port+" "+t.protocol+" 65535\r\n"]}if(t.maxMessageSize!==void 0){r.push("a=max-message-size:"+t.maxMessageSize+"\r\n")}return r.join("")};r.generateSessionId=function(){return Math.random().toString().substr(2,21)};r.writeSessionBoilerplate=function(e,t,a){var n,i=t!==void 0?t:2;if(e){n=e}else{n=r.generateSessionId()}return"v=0\r\no="+(a||"thisisadapterortc")+" "+n+" "+i+" IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\n"};r.writeMediaSection=function(e,t,a,n){var i=r.writeRtpDescription(e.kind,t);i+=r.writeIceParameters(e.iceGatherer.getLocalParameters());i+=r.writeDtlsParameters(e.dtlsTransport.getLocalParameters(),"offer"===a?"actpass":"active");i+="a=mid:"+e.mid+"\r\n";if(e.direction){i+="a="+e.direction+"\r\n"}else if(e.rtpSender&&e.rtpReceiver){i+="a=sendrecv\r\n"}else if(e.rtpSender){i+="a=sendonly\r\n"}else if(e.rtpReceiver){i+="a=recvonly\r\n"}else{i+="a=inactive\r\n"}if(e.rtpSender){var o="msid:"+n.id+" "+e.rtpSender.track.id+"\r\n";i+="a="+o;i+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" "+o;if(e.sendEncodingParameters[0].rtx){i+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" "+o;i+="a=ssrc-group:FID "+e.sendEncodingParameters[0].ssrc+" "+e.sendEncodingParameters[0].rtx.ssrc+"\r\n"}}i+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" cname:"+r.localCName+"\r\n";if(e.rtpSender&&e.sendEncodingParameters[0].rtx){i+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" cname:"+r.localCName+"\r\n"}return i};r.getDirection=function(e,t){for(var a=r.splitLines(e),n=0;n<a.length;n++){switch(a[n]){case"a=sendrecv":case"a=sendonly":case"a=recvonly":case"a=inactive":return a[n].substr(2);default:}}if(t){return r.getDirection(t)}return"sendrecv"};r.getKind=function(e){var t=r.splitLines(e),a=t[0].split(" ");return a[0].substr(2)};r.isRejected=function(e){return"0"===e.split(" ",2)[1]};r.parseMLine=function(e){var t=r.splitLines(e),a=t[0].substr(2).split(" ");return{kind:a[0],port:parseInt(a[1],10),protocol:a[2],fmt:a.slice(3).join(" ")}};r.parseOLine=function(e){var t=r.matchPrefix(e,"o=")[0],a=t.substr(2).split(" ");return{username:a[0],sessionId:a[1],sessionVersion:parseInt(a[2],10),netType:a[3],addressType:a[4],address:a[5]}};r.isValidSDP=function(e){if("string"!=typeof e||0===e.length){return!1}for(var t=r.splitLines(e),a=0;a<t.length;a++){if(2>t[a].length||"="!==t[a].charAt(1)){return!1}}return!0};if("object"===_typeof2(t)){t.exports=r}},{}]},{},[1])(1)});
//# sourceMappingURL=adapter.min.js.map