webcom-reach
Version:
Create apps using WebRTC with Webcom
59 lines • 149 kB
JavaScript
/*!
* The MIT License (MIT)
*
* Copyright (c) 2015-2016 Webcom
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* The externally maintained libraries used by Reach are:
*
* - webrtc-adpater, licensed as follows:
*
* > Copyright (c) 2014, The WebRTC project authors. All rights reserved.
* >
* > Redistribution and use in source and binary forms, with or without
* > modification, are permitted provided that the following conditions are
* > met:
* >
* > * Redistributions of source code must retain the above copyright
* > notice, this list of conditions and the following disclaimer.
* >
* > * Redistributions in binary form must reproduce the above copyright
* > notice, this list of conditions and the following disclaimer in
* > the documentation and/or other materials provided with the
* > distribution.
* >
* > * Neither the name of Google nor the names of its contributors may
* > be used to endorse or promote products derived from this software
* > without specific prior written permission.
* >
* >THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* >"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* >LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* >A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* >HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* >SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* >LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* >DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* >THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* >(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* >OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("webcom/webcom")):"function"==typeof define&&define.amd?define(["webcom/webcom"],t):"object"==typeof exports?exports.Reach=t(require("webcom/webcom")):e.Reach=t(e.Webcom)}(this,function(e){return function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,t),i.l=!0,i.exports}var n={};return t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=58)}([function(e,t,n){"use strict";t.__esModule=!0,t.default=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}},function(e,t,n){"use strict";t.__esModule=!0;var r=n(100),i=function(e){return e&&e.__esModule?e:{default:e}}(r);t.default=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),(0,i.default)(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}()},function(e,t){var n=e.exports={version:"2.5.3"};"number"==typeof __e&&(__e=n)},function(e,t){var n=e.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=n)},function(e,t,n){var r=n(46)("wks"),i=n(37),o=n(3).Symbol,a="function"==typeof o;(e.exports=function(e){return r[e]||(r[e]=a&&o[e]||(a?o:i)("Symbol."+e))}).store=r},function(e,t,n){"use strict";(function(e){function r(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0}),t.r=t.e=t.w=t.i=t.d=void 0;var i=n(8),o=r(i),a=n(104),s=r(a),c=n(6),u=r(c),d=["DEBUG","INFO","WARN","ERROR"],f=function(e){return d.indexOf(e.toUpperCase())>=d.indexOf(u.default.logLevel.toUpperCase())},l=e.console,p=function(e,t){for(var n=arguments.length,r=Array(n>2?n-2:0),i=2;i<n;i++)r[i-2]=arguments[i];f(t)&&l[e.toLowerCase()].bind(l).apply(void 0,r)},h=function(e,t){for(var n=arguments.length,r=Array(n>2?n-2:0),i=2;i<n;i++)r[i-2]=arguments[i];if(r.length>0){p.bind(void 0,l.group?"group":e,e)("string"==typeof t?t:"");var o=("string"!=typeof t?[t]:[]).concat(r);1===r.length&&r[0]instanceof Array&&void 0!==(0,s.default)(r[0].length)&&(o=r[0]),o.forEach(function(t){return p.bind(void 0,e,e)(t)}),l.groupEnd&&l.groupEnd()}else p.bind(void 0,e,e,t)},v=t.d=h.bind(void 0,d[0]);t.i=h.bind(void 0,d[1]),t.w=h.bind(void 0,d[2]),t.e=l.error.bind(l),t.r=function(e){return function(t){return v(e,t),o.default.reject(t||e)}}}).call(t,n(90))},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var i=n(0),o=r(i),a=n(1),s=r(a),c=n(93),u=r(c),d=n(95),f=r(d),l=n(97),p=r(l),h=n(31),v=r(h),m=null,g=function(){function e(){return(0,o.default)(this,e),m||(m=this),m}return(0,s.default)(e,[{key:"base",set:function(e){this._base=e instanceof v.default?e:new v.default(e)},get:function(){return this._base}},{key:"config",set:function(e){this._config?this._config.assign(e):this._config=new u.default(e)},get:function(){return this._config||(this._config=new u.default),this._config}},{key:"user",set:function(e){this._user=e},get:function(){return this._user}},{key:"device",set:function(e){this._device=e},get:function(){return this._device}},{key:"logLevel",set:function(e){if(/^DEBUG|INFO|WARN|ERROR$/i.test(e))this._logLevel=e;else if(e)throw new Error("Unsupported log level (DEBUG, INFO, WARN, ERROR)")},get:function(){return this._logLevel||"ERROR"}},{key:"streams",get:function(){return this._streams||(this._streams=new f.default),this._streams}},{key:"peerConnections",get:function(){return this._peerConnections||(this._peerConnections=new p.default),this._peerConnections}}]),e}(),y=new g;t.default=y},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0}),t.ts=t.onDisconnect=t.off=t.on=t.list=t.get=t.once=t.remove=t.update=t.push=t.set=t.eventType=void 0;var i=n(8),o=r(i),a=n(6),s=r(a),c=t.eventType=function(e){var t=void 0;return/_ADDED$/i.test(e)||/_PUBLISHED$/.test(e)?t="added":/_CHANGED$/.test(e)||/_REFRESHED$/.test(e)?t="changed":(/_REMOVED$/.test(e)||/_UNPUBLISHED$/.test(e))&&(t="removed"),t?"child_"+t:e},u=function(e,t,n){return new o.default(function(r,i){s.default.base.child(t)[e](n,function(e){return e?i(e):r()})})},d=(t.set=u.bind(void 0,"set"),t.push=function(e,t){return new o.default(function(n,r){var i=s.default.base.child(e).push(t,function(e){return e?r(e):n(i)})})},t.update=u.bind(void 0,"update"),t.remove=function(e){return new o.default(function(t,n){s.default.base.child(e).remove(function(e){return e?n(e):t()})})},t.once=function(e,t){return new o.default(function(n,r){s.default.base.child(e).once(c(t),n,r)})}),f=t.get=function(e){return d(e,"value")};t.list=function(e,t){for(var n=arguments.length,r=Array(n>2?n-2:0),i=2;i<n;i++)r[i-2]=arguments[i];return f(e).then(function(e){if(e){var n=[];return e.forEach(function(e){n.push(new(Function.prototype.bind.apply(t,[null].concat([e],r))))}),n}})},t.on=function(e,t,n,r){s.default.base.child(e).on(c(t),n,r)},t.off=function(e,t,n){s.default.base.child(e).off(c(t),n)},t.onDisconnect=function(e){return s.default.base.child(e).onDisconnect()},t.ts=function(){return Date.now()}},function(e,t,n){e.exports={default:n(111),__esModule:!0}},function(e,t,n){e.exports={default:n(107),__esModule:!0}},function(e,t,n){var r=n(3),i=n(2),o=n(23),a=n(16),s=function(e,t,n){var c,u,d,f=e&s.F,l=e&s.G,p=e&s.S,h=e&s.P,v=e&s.B,m=e&s.W,g=l?i:i[t]||(i[t]={}),y=g.prototype,C=l?r:p?r[t]:(r[t]||{}).prototype;l&&(n=t);for(c in n)(u=!f&&C&&void 0!==C[c])&&c in g||(d=u?C[c]:n[c],g[c]=l&&"function"!=typeof C[c]?n[c]:v&&u?o(d,r):m&&C[c]==d?function(e){var t=function(t,n,r){if(this instanceof e){switch(arguments.length){case 0:return new e;case 1:return new e(t);case 2:return new e(t,n)}return new e(t,n,r)}return e.apply(this,arguments)};return t.prototype=e.prototype,t}(d):h&&"function"==typeof d?o(Function.call,d):d,h&&((g.virtual||(g.virtual={}))[c]=d,e&s.R&&y&&!y[c]&&a(y,c,d)))};s.F=1,s.G=2,s.S=4,s.P=8,s.B=16,s.W=32,s.U=64,s.R=128,e.exports=s},function(e,t,n){var r=n(12),i=n(66),o=n(49),a=Object.defineProperty;t.f=n(13)?Object.defineProperty:function(e,t,n){if(r(e),t=o(t,!0),r(n),i)try{return a(e,t,n)}catch(e){}if("get"in n||"set"in n)throw TypeError("Accessors not supported!");return"value"in n&&(e[t]=n.value),e}},function(e,t,n){var r=n(17);e.exports=function(e){if(!r(e))throw TypeError(e+" is not an object!");return e}},function(e,t,n){e.exports=!n(21)(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a})},function(e,t,n){e.exports={default:n(110),__esModule:!0}},function(e,t){var n={}.hasOwnProperty;e.exports=function(e,t){return n.call(e,t)}},function(e,t,n){var r=n(11),i=n(26);e.exports=n(13)?function(e,t,n){return r.f(e,t,i(1,n))}:function(e,t,n){return e[t]=n,e}},function(e,t){e.exports=function(e){return"object"==typeof e?null!==e:"function"==typeof e}},function(e,t,n){var r=n(67),i=n(40);e.exports=function(e){return r(i(e))}},function(e,t,n){"use strict";var r=!0,i=!0,o={disableLog:function(e){return"boolean"!=typeof e?new Error("Argument type: "+typeof e+". Please use a boolean."):(r=e,e?"adapter.js logging disabled":"adapter.js logging enabled")},disableWarnings:function(e){return"boolean"!=typeof e?new Error("Argument type: "+typeof e+". Please use a boolean."):(i=!e,"adapter.js deprecation warnings "+(e?"disabled":"enabled"))},log:function(){if("object"==typeof window){if(r)return;"undefined"!=typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)}},deprecated:function(e,t){i&&console.warn(e+" is deprecated, please use "+t+" instead.")},extractVersion:function(e,t,n){var r=e.match(t);return r&&r.length>=n&&parseInt(r[n],10)},detectBrowser:function(e){var t=e&&e.navigator,n={};if(n.browser=null,n.version=null,void 0===e||!e.navigator)return n.browser="Not a browser.",n;if(t.mozGetUserMedia)n.browser="firefox",n.version=this.extractVersion(t.userAgent,/Firefox\/(\d+)\./,1);else if(t.webkitGetUserMedia)if(e.webkitRTCPeerConnection)n.browser="chrome",n.version=this.extractVersion(t.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else{if(!t.userAgent.match(/Version\/(\d+).(\d+)/))return n.browser="Unsupported webkit-based browser with GUM support but no WebRTC support.",n;n.browser="safari",n.version=this.extractVersion(t.userAgent,/AppleWebKit\/(\d+)\./,1)}else if(t.mediaDevices&&t.userAgent.match(/Edge\/(\d+).(\d+)$/))n.browser="edge",n.version=this.extractVersion(t.userAgent,/Edge\/(\d+).(\d+)$/,2);else{if(!t.mediaDevices||!t.userAgent.match(/AppleWebKit\/(\d+)\./))return n.browser="Not a supported browser.",n;n.browser="safari",n.version=this.extractVersion(t.userAgent,/AppleWebKit\/(\d+)\./,1)}return n},shimCreateObjectURL:function(e){var t=e&&e.URL;if("object"==typeof e&&e.HTMLMediaElement&&"srcObject"in e.HTMLMediaElement.prototype){var n=t.createObjectURL.bind(t),r=t.revokeObjectURL.bind(t),i=new Map,a=0;t.createObjectURL=function(e){if("getTracks"in e){var t="polyblob:"+ ++a;return i.set(t,e),o.deprecated("URL.createObjectURL(stream)","elem.srcObject = stream"),t}return n(e)},t.revokeObjectURL=function(e){r(e),i.delete(e)};var s=Object.getOwnPropertyDescriptor(e.HTMLMediaElement.prototype,"src");Object.defineProperty(e.HTMLMediaElement.prototype,"src",{get:function(){return s.get.apply(this)},set:function(e){return this.srcObject=i.get(e)||null,s.set.apply(this,[e])}});var c=e.HTMLMediaElement.prototype.setAttribute;e.HTMLMediaElement.prototype.setAttribute=function(){return 2===arguments.length&&"src"===(""+arguments[0]).toLowerCase()&&(this.srcObject=i.get(arguments[1])||null),c.apply(this,arguments)}}}};e.exports={log:o.log,deprecated:o.deprecated,disableLog:o.disableLog,disableWarnings:o.disableWarnings,extractVersion:o.extractVersion,shimCreateObjectURL:o.shimCreateObjectURL,detectBrowser:o.detectBrowser.bind(o)}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.OPENED="OPENED",t.CLOSED="CLOSED",t.CLOSING="CLOSING",t.CONNECTED="CONNECTED",t.NOT_CONNECTED="NOT_CONNECTED",t.WAS_CONNECTED="WAS_CONNECTED",t.OWNER="OWNER",t.MODERATOR="MODERATOR",t.PARTICIPANT="PARTICIPANT",t.NONE="NONE",t.ONGOING="ONGOING",t.ACCEPTED="ACCEPTED",t.REJECTED="REJECTED",t.CANCELED="CANCELED"},function(e,t){e.exports=function(e){try{return!!e()}catch(e){return!0}}},function(e,t){var n={}.toString;e.exports=function(e){return n.call(e).slice(8,-1)}},function(e,t,n){var r=n(32);e.exports=function(e,t,n){if(r(e),void 0===t)return e;switch(n){case 1:return function(n){return e.call(t,n)};case 2:return function(n,r){return e.call(t,n,r)};case 3:return function(n,r,i){return e.call(t,n,r,i)}}return function(){return e.apply(t,arguments)}}},function(e,t){e.exports={}},function(e,t,n){var r=n(75),i=n(42);e.exports=Object.keys||function(e){return r(e,i)}},function(e,t){e.exports=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}}},function(e,t){var n=e.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=n)},function(e,t,n){"use strict";function r(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}function i(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var o=n(14),a=i(o),s=n(8),c=i(s),u=n(9),d=i(u),f=n(0),l=i(f),p=n(1),h=i(p),v=n(20),m=n(7),g=r(m),y=n(6),C=i(y),b=n(61),_=i(b),S=n(60),E=i(S),T=n(94),w=i(T),P=n(39),k=i(P),O=n(30),R=r(O),x=n(5),D=r(x),M=function(e,t){var n={status:v.CONNECTED,userAgent:C.default.userAgent,_joined:g.ts()};return t&&(n.role=t),D.w("Room#join",[n,"_/rooms/"+e.uid+"/participants/"+C.default.user.uid]),g.update("_/rooms/"+e.uid+"/participants/"+C.default.user.uid,n).then(function(){return g.onDisconnect("_/rooms/"+e.uid+"/participants/"+C.default.user.uid+"/status").set(v.WAS_CONNECTED),e})},j=function(){function e(t){(0,l.default)(this,e);var n=t;t&&t.val&&"function"==typeof t.val&&(n=(0,d.default)({},t.val(),{uid:t.name()})),this.uid=n.uid,this.name=n.name,this.localStream={},this.owner=n.owner,this.status=n.status,this._public=!!n._public,this.extra=n.extra,this._callbacks={}}return(0,h.default)(e,[{key:"participants",value:function(){return g.list("_/rooms/"+this.uid+"/participants",_.default,this.uid)}},{key:"messages",value:function(){return g.list("_/rooms/"+this.uid+"/messages",E.default,this.uid)}},{key:"_streams",value:function(e){var t=this;return C.default.user?g.get("_/rooms/"+this.uid+"/streams").then(function(e){var n=e.val();return D.d("Rooms~_streams",n),n?(0,a.default)(n).map(function(e){return(0,d.default)({uid:e,roomId:t.uid},n[e])}):[]}).then(function(t){return t.filter(function(t){return e===(t.device===C.default.device&&t.from===C.default.user.uid)})}).then(function(t){return t.map(C.default.streams["get"+(e?"Shared":"Remote")].bind(C.default.streams))}).then(function(e){return e.filter(function(e){return null!==e})}):c.default.reject(new Error("Only an authenticated user can list a Room's streams."))}},{key:"localStreams",value:function(){return this._streams(!0).catch(D.r("Room~localStreams"))}},{key:"remoteStreams",value:function(){return this._streams(!1).catch(D.r("Room~remoteStreams"))}},{key:"invite",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:v.NONE,r=arguments[2],i=function(e){return"_/rooms/"+t.uid+"/participants/"+e.uid},o={status:v.NOT_CONNECTED,role:n||v.NONE};return c.default.all(e.map(function(e){return g.set(i(e),o)})).then(function(){return c.default.all(e.map(function(e){return k.default.send(e,t,r)}))}).then(function(e){var n=function(e){return g.remove("_/rooms/"+e.room+"/participants/"+e.to)};return e.forEach(function(e){e.on(v.REJECTED,n),e.on(v.CANCELED,n)}),{room:t,invites:e}}).catch(function(n){return D.e("Room~invite",n),e.forEach(function(e){return g.remove("_/rooms/"+t.uid+"/participants/"+e.uid)}),c.default.reject(n)})}},{key:"on",value:function(e,t,n){var r=this,i=R.room.toPath(e)(this),o=R.room.toClass(e);if(i&&o){var a=function(n){if(/^STREAM_/i.test(e)&&n){if(C.default.user){var i=(0,d.default)({uid:n.name(),roomId:r.uid},n.val());if(i.from!==C.default.user.uid||i.device!==C.default.device){var a=C.default.streams.getRemote(i);D.i("Room~on("+e+")",a),t(a)}}}else D.i("Room~on("+e+")",n?new o(n):null),t(n?new o(n):null)};g.on(i,e,a,n),this._callbacks[e]||(this._callbacks[e]=[]),this._callbacks[e].push(a)}}},{key:"sendMessage",value:function(e){return E.default.send(this,e)}},{key:"share",value:function(e,t,n){return D.i("Room~share",{type:e,localStreamContainer:t,constraints:n}),w.default.share(this.uid,e,t,n)}},{key:"getLocalVideo",value:function(e,t,n){var r=this;return D.i("Room~getLocalVideo",{type:e,localStreamContainer:t,constraints:n}),w.default.getLocalVideo(this.uid,e,t,n).then(function(e){return r.localStream=e,e})}},{key:"publish",value:function(){return D.i("Room~publish Local"),w.default.publish(this.localStream)}},{key:"join",value:function(){return D.i("Room~join",this),C.default.user?M(this).catch(D.r("Room~join")):c.default.reject(new Error("Only an authenticated user can join a Room."))}},{key:"leave",value:function(){var e=this;return C.default.user?(D.i("Room~leave",this),g.onDisconnect("_/rooms/"+this.uid+"/participants/"+C.default.user.uid+"/status").cancel(),(0,a.default)(this._callbacks).forEach(function(t){g.off(R.room.toPath(t)(e),t)}),this.localStreams().then(function(e){e.forEach(function(e){return e.close()})}),this.localStream&&this.localStream.close(),this.remoteStreams().then(function(e){return e.forEach(function(e){return e.unSubscribe()})}),g.set("_/rooms/"+this.uid+"/participants/"+C.default.user.uid+"/status",v.WAS_CONNECTED).catch(D.r("Room~leave"))):c.default.reject(new Error("Only an authenticated user can leave a Room."))}},{key:"close",value:function(){var e=this;return D.i("Room~close",this),this.leave().then(function(){return g.update("rooms/"+e.uid,{status:v.CLOSED,_closed:g.ts()})}).then(function(){return g.remove("_/rooms/"+e.uid)}).catch(D.r("Room~close"))}}],[{key:"create",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(!C.default.user)return c.default.reject(new Error("Only an authenticated user can create a Room."));var i={owner:C.default.user.uid,_public:r,name:t||C.default.user.name+"-"+Date.now()},o=(0,d.default)({status:v.OPENED,_created:g.ts(),extra:n},i),a=null;return g.push("rooms",o).then(function(t){return a=new e((0,d.default)({uid:t.name()},o)),g.update("_/rooms/"+a.uid+"/meta",i)}).then(function(){return M(a,v.OWNER)}).catch(D.r("Room#create"))}},{key:"get",value:function(t){return g.get("rooms/"+t).then(function(t){if(t.val())return new e(t)})}}]),e}();t.default=j},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var i=n(0),o=r(i),a=n(1),s=r(a),c=n(9),u=r(c),d=n(5),f=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}(d),l=n(58),p=r(l),h={UHD:{w:3840,h:2160,min:"HD"},FHD:{w:1920,h:1080,min:"HD",max:"UHD"},HD:{w:1280,h:720,min:"SD",max:"FHD"},SVGA:{w:800,h:600,min:"VGA",max:"HD"},SD:{w:720,h:576,min:"VGA",max:"HD"},VGA:{w:640,h:480,max:"SVGA"}},v=function(e,t){return e&&t?(0,u.default)(/^((user)|(environment))$/i.test(t)?{facingMode:t}:{deviceId:t},!0===e?{}:e):e},m=function(){function e(){(0,o.default)(this,e)}return(0,s.default)(e,null,[{key:"constraints",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"HD",t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"ideal",r=arguments[3],i=arguments[4],o=e;if("string"==typeof e){if(!h[e.toUpperCase()])throw new Error("Unknown Video Resolution preset (UHD, FHD, HD, SVGA, SD, VGA)");var a=h[e.toUpperCase()],s=function(e){if(/^(min|max|exact)$/.test(n)){var t={};return t[n]=a[e],t}return{min:a.min?h[a.min][e]:a[e],ideal:a[e],max:a.max?h[a.max][e]:a[e]}};o={width:s("w"),height:s("h")}}o=v(o,r);var c=v(t,i);return f.d("Media#constraints",{video:o,audio:c}),{video:o,audio:c}}},{key:"attachStream",value:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:.7,i="";if(e.getVideoTracks().length>0?i="video":e.getAudioTracks().length>0&&(i="audio"),f.d("Media#attachStream",e,i),i.length>0){var o=n;return o&&o.tagName.toLowerCase()===i||(o=document.createElement(i),o.autoplay=!0,"safari"===p.default.browser.browser&&(o.setAttribute("playsinline",!0),o.setAttribute("muted",!0)),o.style.borderRadius="1px"),t&&(n&&n!==o?t.replaceChild(o,n):n||t.appendChild(o)),o.srcObject=e,o.addEventListener("play",function(e){f.d("video.onplay = "+e.type),o.srcObject.onaddtrack=function(e){f.d("[Local] listener: video.onaddtrack = "+e.label)},o.srcObject.onremovetrack=function(e){f.d("[Local] listener: video.onremovetrack = "+e.label)},o.srcObject.oninactive=function(){f.d("[Local] listener: video.oninactive")},o.srcObject.onplaying=function(e){console.debug("[Local] listener: video.onplaying = "+e.type)},o.srcObject.onstalled=function(e){console.debug("[Local] listener: video.onstalled = "+e.type)},o.srcObject.onsuspend=function(e){console.debug("[Local] listener: video.onsuspend = "+e.type),console.debug(e),console.debug("on passe là")}}),o.onsuspend=function(e){console.debug("[Local] listener: video.onsuspend = "+e),console.debug(e)},o.addEventListener("loadeddata",function(){return f.d("on a chargé les données")}),o.addEventListener("error",function(e){return f.d("on a une erreur "+e)}),o.volume=r,o}return n}},{key:"devices",value:function(){return navigator.mediaDevices.enumerateDevices().then(function(e){var t={};return e.forEach(function(e){t[e.kind]||(t[e.kind]=[]),t[e.kind].push(e)}),f.d("Media#devices",t),t}).catch(f.r("Media#devices"))}},{key:"facingMode",get:function(){return{USER:"user",ENVIRONMENT:"environment"}}}]),e}();t.default=m},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0}),t.invite=t.stream=t.room=t.reach=void 0;var i=n(14),o=r(i),a=n(99),s=r(a),c=n(0),u=r(c),d=n(1),f=r(d),l=n(56),p=r(l),h=n(28),v=r(h),m=n(39),g=r(m),y=n(61),C=r(y),b=n(60),_=r(b),S=n(62),E=r(S),T=n(20),w={USER:function(){return"users"},ROOM:function(){return"rooms"},INVITE:function(e){if(!e)throw new Error("You must be authenticated to list the invites");return"_/invites/"+e.uid},PARTICIPANT:function(e){return"_/rooms/"+e.uid+"/participants"},MESSAGE:function(e){return"_/rooms/"+e.uid+"/messages"},STREAM:function(e){return"_/rooms/"+e.uid+"/streams"}},P={USER:p.default,ROOM:v.default,INVITE:g.default,PARTICIPANT:C.default,MESSAGE:_.default,STREAM:E.default},k=function(){function e(t){var n=this;(0,u.default)(this,e),t.forEach(function(e){n[e]=e})}return(0,f.default)(e,[{key:"supports",value:function(e){if(!e||"string"!=typeof e||this[e]!==e.toUpperCase())throw new Error("Unsupported event. Use one of the following: "+(0,s.default)((0,o.default)(this)));return!0}},{key:"toPath",value:function(e){if(this.supports(e))return w[e.toUpperCase().replace(/_.*$/,"")]||function(){return null}}},{key:"toClass",value:function(e){if(this.supports(e))return P[e.toUpperCase().replace(/_.*$/,"")]}}]),e}();t.reach=new k(["USER_ADDED","USER_CHANGED","USER_REMOVED","ROOM_ADDED","ROOM_CHANGED","ROOM_REMOVED","INVITE_ADDED","INVITE_CHANGED"]),t.room=new k(["MESSAGE_ADDED","MESSAGE_CHANGED","MESSAGE_REMOVED","PARTICIPANT_ADDED","PARTICIPANT_CHANGED","PARTICIPANT_REMOVED","STREAM_PUBLISHED","STREAM_UNPUBLISHED"]),t.stream=new k(["MUTE","SIZE"]),t.invite=new k([T.ACCEPTED,T.REJECTED,T.CANCELED])},function(t,n){t.exports=e},function(e,t){e.exports=function(e){if("function"!=typeof e)throw TypeError(e+" is not a function!");return e}},function(e,t){e.exports=!0},function(e,t){t.f={}.propertyIsEnumerable},function(e,t,n){var r=n(11).f,i=n(15),o=n(4)("toStringTag");e.exports=function(e,t,n){e&&!i(e=n?e:e.prototype,o)&&r(e,o,{configurable:!0,value:t})}},function(e,t,n){var r=n(40);e.exports=function(e){return Object(r(e))}},function(e,t){var n=0,r=Math.random();e.exports=function(e){return"Symbol(".concat(void 0===e?"":e,")_",(++n+r).toString(36))}},function(e,t){e.exports=function(e){return"object"==typeof e?null!==e:"function"==typeof e}},function(e,t,n){"use strict";function r(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}function i(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var o=n(9),a=i(o),s=n(0),c=i(s),u=n(1),d=i(u),f=n(14),l=i(f),p=n(8),h=i(p),v=n(20),m=n(7),g=r(m),y=n(5),C=r(y),b=n(6),_=i(b),S=n(28),E=i(S),T=n(30),w=r(T),P=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i={status:t,reason:n,_ended:r};return e.status!==v.ONGOING?h.default.reject(new Error("This invitation has already been answered")):g.update("_/invites/"+e.to+"/"+e.uid,i).then(function(){return(0,l.default)(i).forEach(function(t){e[t]=i[t]}),E.default.get(e.room)}).then(function(t){return{room:t,invite:e}}).catch(C.r("Invite_update"))},k=function(){function e(t){(0,c.default)(this,e);var n=t;t&&t.val&&"function"==typeof t.val&&(n=(0,a.default)({},t.val(),{uid:t.name(),to:t.ref().parent().name()})),this.uid=n.uid,this.from=n.from,this.to=n.to,this.room=n.room,this.status=n.status,this.topic=n.topic,this._created=n._created,this._ended=n._ended,this._callbacks={}}return(0,d.default)(e,[{key:"cancel",value:function(e){return P(this,v.CANCELED,e,g.ts())}},{key:"reject",value:function(e){return P(this,v.REJECTED,e,g.ts())}},{key:"accept",value:function(){return P(this,v.ACCEPTED)}},{key:"on",value:function(e,t){var n=this;w.invite.supports(e)&&(this._callbacks[e]||(this._callbacks[e]=[]),this._callbacks[e].push(t),this._listener||(this._listener=function(e){var t=e.val();null!==t&&t!==n.status&&(n.status=t,(n._callbacks[t]||[]).forEach(function(e){e(n)}))},g.on("_/invites/"+this.to+"/"+this.uid+"/status","value",this._listener.bind(this))))}},{key:"onStatusChange",value:function(e){var t=this;[v.ACCEPTED,v.REJECTED,v.CANCELED].forEach(function(n){t.on(n,e)})}},{key:"off",value:function(e,t){var n=this;if(e){if(this._callbacks[e])if(t){var r=this._callbacks[e].findIndex(function(e){return e===t});r>=0&&this._callbacks.splice(r,1)}else this._callbacks[e]=[]}else this._callbacks={};[v.CANCELED,v.ACCEPTED,v.REJECTED].some(function(e){return n._callbacks[e]&&n._callbacks[e].length>0})||g.off("_/invites/"+this.to+"/"+this.uid+"/status","value")}},{key:"offStatusChange",value:function(e){var t=this;e?[v.ACCEPTED,v.REJECTED,v.CANCELED].forEach(function(n){t.off(n,e)}):this.off()}},{key:"isOnGoing",get:function(){return this.status===v.ONGOING}},{key:"isRejected",get:function(){return this.status===v.REJECTED}},{key:"isAccepted",get:function(){return this.status===v.ACCEPTED}},{key:"isCanceled",get:function(){return this.status===v.CANCELED}}],[{key:"send",value:function(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;if(!_.default.user)return h.default.reject(new Error("Only an authenticated user can send an invite."));var i={from:_.default.user.uid,room:n.uid,status:v.ONGOING,_created:g.ts(),topic:r};return g.push("_/invites/"+t.uid,i).then(function(n){var r=n.name();return new e((0,a.default)({uid:r,to:t.uid},i))}).catch(C.r("Invite#send"))}}]),e}();t.default=k},function(e,t){e.exports=function(e){if(void 0==e)throw TypeError("Can't call method on "+e);return e}},function(e,t,n){var r=n(17),i=n(3).document,o=r(i)&&r(i.createElement);e.exports=function(e){return o?i.createElement(e):{}}},function(e,t){e.exports="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(",")},function(e,t,n){"use strict";function r(e){var t,n;this.promise=new e(function(e,r){if(void 0!==t||void 0!==n)throw TypeError("Bad Promise constructor");t=e,n=r}),this.resolve=i(t),this.reject=i(n)}var i=n(32);e.exports.f=function(e){return new r(e)}},function(e,t){t.f=Object.getOwnPropertySymbols},function(e,t,n){var r=n(46)("keys"),i=n(37);e.exports=function(e){return r[e]||(r[e]=i(e))}},function(e,t,n){var r=n(3),i=r["__core-js_shared__"]||(r["__core-js_shared__"]={});e.exports=function(e){return i[e]||(i[e]={})}},function(e,t){var n=Math.ceil,r=Math.floor;e.exports=function(e){return isNaN(e=+e)?0:(e>0?r:n)(e)}},function(e,t,n){var r=n(47),i=Math.min;e.exports=function(e){return e>0?i(r(e),9007199254740991):0}},function(e,t,n){var r=n(17);e.exports=function(e,t){if(!r(e))return e;var n,i;if(t&&"function"==typeof(n=e.toString)&&!r(i=n.call(e)))return i;if("function"==typeof(n=e.valueOf)&&!r(i=n.call(e)))return i;if(!t&&"function"==typeof(n=e.toString)&&!r(i=n.call(e)))return i;throw TypeError("Can't convert object to primitive value")}},function(e,t,n){var r=n(3),i=n(2),o=n(33),a=n(51),s=n(11).f;e.exports=function(e){var t=i.Symbol||(i.Symbol=o?{}:r.Symbol||{});"_"==e.charAt(0)||e in t||s(t,e,{value:a.f(e)})}},function(e,t,n){t.f=n(4)},function(e,t,n){"use strict";var r=n(132)(!0);n(70)(String,"String",function(e){this._t=String(e),this._i=0},function(){var e,t=this._t,n=this._i;return n>=t.length?{value:void 0,done:!0}:(e=r(t,n),this._i+=e.length,{value:e,done:!1})})},function(e,t){var n=e.exports={version:"2.4.0"};"number"==typeof __e&&(__e=n)},function(e,t,n){e.exports=!n(87)(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a})},function(e,t,n){var r=n(160),i=n(161);e.exports=n(54)?function(e,t,n){return r.f(e,t,i(1,n))}:function(e,t,n){return e[t]=n,e}},function(e,t,n){"use strict";function r(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}function i(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var o=n(8),a=i(o),s=n(9),c=i(s),u=n(0),d=i(u),f=n(1),l=i(f),p=n(7),h=r(p),v=n(6),m=i(v),g=n(5),y=r(g),C=n(28),b=i(C),_=n(59),S=i(_),E=n(20),T=n(31),w=i(T),P=!1,k=function(){function e(t){(0,d.default)(this,e);var n=(0,c.default)({},t.val());this.uid=t.name(),this.name=n.name,this.status=n.status,this.lastSeen=n.lastSeen,this.anonymous=/^anonymous/.test(n.provider)}return(0,l.default)(e,[{key:"invite",value:function(e){var t=this;return m.default.user?b.default.create(m.default.user.uid+"-"+this.uid).then(function(n){return n.invite([t],null,e)}).then(function(e){return{room:e.room,invite:e.invites[0]}}).catch(y.r("User~invite")):a.default.reject(new Error("Only an authenticated user can invite another User."))}},{key:"devices",value:function(){return h.list("_/devices/"+this.uid,S.default)}}],[{key:"init",value:function(t,n){var r=t.uid;if(!P){P=!0;var i={status:E.CONNECTED,lastSeen:h.ts(),provider:t.provider};n&&(0,c.default)(i,{name:n});var o=w.default.INTERNAL.PersistentStorage.get(r);return h.update("users/"+r,i).then(function(){var e={status:E.CONNECTED,sdk:{reach:"2.10.0-beta.10",webcom:w.default.SDK_VERSION},userAgent:navigator.userAgent};return m.default.userAgent=e.userAgent,o?h.update("_/devices/"+r+"/"+o,e):h.push("_/devices/"+r,e)}).then(function(e){o||(o=e.name(),w.default.INTERNAL.PersistentStorage.set(r,o)),m.default.device=o}).then(function(){h.onDisconnect("_/devices/"+r+"/"+o+"/status").set(E.NOT_CONNECTED),h.onDisconnect("users/"+r).update({status:E.NOT_CONNECTED,lastSeen:h.ts()})}).then(function(){return e.get(r)}).then(function(e){return P=!1,e}).catch(function(e){return y.e(e),P=!1,a.default.reject(e)})}return e.get(r)}},{key:"disconnect",value:function(e){return h.onDisconnect("_/devices/"+e.uid+"/"+m.default.device+"/status").cancel(),h.onDisconnect("users/"+e.uid).cancel(),e.anonymous?h.remove("_/devices/"+e.uid).then(function(){return h.get("_/invites/"+e.uid)}).then(function(t){var n=[];return t.forEach(function(e){n.push(e.name())}),a.default.all(n.map(function(t){return h.remove("_/invites/"+e.uid+"/"+t)}))}).then(function(){return h.remove("users/"+e.uid)}).then(function(){w.default.INTERNAL.PersistentStorage.remove(e.uid)}).catch(y.r("User#anonymous_disconnect")):h.set("_/devices/"+e.uid+"/"+m.default.device+"/status",E.NOT_CONNECTED).then(function(){return h.get("_/devices/"+e.uid)}).then(function(t){return!!t.forEach(function(e){return new RegExp("^"+E.CONNECTED+"$").test(e.val().status)})||h.update("users/"+e.uid,{status:E.NOT_CONNECTED})}).catch(y.r("User#disconnect"))}},{key:"get",value:function(t){return h.get("users/"+t).then(function(t){return t?new e(t):null}).catch(y.r("User#get"))}}]),e}();t.default=k},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=t.AUDIO="audio",i=t.VIDEO="video",o=t.AUDIO_VIDEO="audio-video",a=t.SCREEN_SHARING="screen-sharing";t.default={AUDIO:r,VIDEO:i,AUDIO_VIDEO:o,SCREEN_SHARING:a}},function(e,t,n){"use strict";function r(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}function i(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var o=n(14),a=i(o),s=n(8),c=i(s),u=n(0),d=i(u),f=n(1),l=i(f),p=n(91),h=n(57),v=i(h),m=n(30),g=r(m),y=n(92),C=n(56),b=i(C),_=n(28),S=i(_),E=n(39),T=i(E),w=n(7),P=r(w),k=n(6),O=i(k),R=n(5),x=r(R),D=n(29),M=i(D),j=n(31),I=i(j),A=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;(0,d.default)(this,e),O.default.base=t,O.default.config=n,this._callbacks={}}return(0,l.default)(e,[{key:"register",value:function(e,t,n,r){var i=this;return O.default.base.createUser(e,t).then(function(o){if(o)return i.login(e,t,n||e,r)}).catch(x.r("Reach~register"))}},{key:"login",value:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]&&arguments[3],i=c.default.resolve();return this.current&&this.current.email!==e&&(i=this.logout()),i.then(function(){return O.default.base.authWithPassword({email:e,password:t,rememberMe:r})}).then(function(e){return b.default.init(e,n)}).then(function(e){return O.default.user=e,e}).catch(x.r("Reach~login"))}},{key:"resume",value:function(){var e=this;return new c.default(function(t,n){I.default.INTERNAL.PersistentStorage.get("session")?O.default.base.resume(function(r,i){i&&!e.current&&b.default.init(i).then(function(e){O.default.user=e,t(e)},n)}):n(new Error("No session to resume"))})}},{key:"anonymous",value:function(e){var t=c.default.resolve();return!this.current||this.current.anonymous&&this.current.name===e||(t=this.logout()),t.then(function(){return O.default.base.authAnonymously()}).then(function(t){return b.default.init(t,e)}).then(function(e){return O.default.user=e,e}).catch(x.r("Reach~anonymous"))}},{key:"logout",value:function(){var e=this;return new c.default(function(t,n){var r=c.default.resolve();null!=e.current&&(r=b.default.disconnect(e.current)),r.then(function(){(0,a.default)(e._callbacks).forEach(function(e){return P.off(g.reach.toPath(e)(O.default.user),e)}),O.default.base.logout(function(){O.default.user=null,t()})}).catch(function(e){x.e(e),n(e)})})}},{key:"users",value:function(e){var t=this;return P.list("users",b.default).then(function(n){return!e&&n&&t.current?n.filter(function(e){return e.uid!==t.current.uid}):n}).catch(x.r("Reach~users"))}},{key:"rooms",value:function(){return P.list("rooms",S.default).catch(x.r("Reach~rooms"))}},{key:"invites",value:function(){return this.current?P.list("_/invites/"+this.current.uid,T.default).catch(x.r("Reach~invites")):c.default.reject(new Error("Cannot list invites without a User being logged in."))}},{key:"on",value:function(e,t,n){var r=g.reach.toPath(e)(O.default.user);if(r){var i=g.reach.toClass(e),o=function(n){var r=i?new i(n):null;x.i("Reach~on("+e+")",r),t(r)};P.on(r,e,o,n),this._callbacks[e]||(this._callbacks[e]=[]),this._callbacks[e].push(o)}}},{key:"createRoom",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return this.current?S.default.create(e,t,n):c.default.reject(new Error("Cannot create a Room without a User being logged in."))}},{key:"getRoom",value:function(e){return S.default.get(e)}},{key:"getUser",value:function(e){return b.default.get(e)}},{key:"base",get:function(){return O.default.base}},{key:"config",get:function(){return O.default.config}},{key:"current",get:function(){return O.default.user}},{key:"peerConnections",get:function(){return O.default.peerConnections.stacks}}],[{key:"version",get:function(){return{sdk:"2.10.0-beta.10",schema:"draft-00"}}},{key:"types",get:function(){return v.default}},{key:"events",get:function(){return{room:g.room,reach:g.reach,stream:g.stream,invite:g.invite}}},{key:"browser",get:function(){return p.browser}},{key:"media",get:function(){return M.default}},{key:"codecs",get:function(){return{audio:y.audio,video:y.video}}}]),e}();t.default=A,e.exports=A},function(e,t,n){"use strict";function r(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}function i(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var o=n(9),a=i(o),s=n(0),c=i(s),u=n(1),d=i(u),f=n(7),l=r(f),p=n(5),h=r(p),v=function(){function e(t){(0,c.default)(this,e);var n=(0,a.default)({},t.val());this.uid=t.name(),this.os=n.os,this.userAgent=n.userAgent,this.status=n.status,this.sdk=n.sdk}return(0,d.default)(e,null,[{key:"get",value:function(t,n){return l.get("_/devices/"+t+"/"+n).then(function(t){return t?new e(t):null}).catch(h.r("Device#get"))}}]),e}();t.default=v},function(e,t,n){"use strict";function r(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}function i(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var o=n(8),a=i(o),s=n(9),c=i(s),u=n(0),d=i(u),f=n(1),l=i(f),p=n(7),h=r(p),v=n(5),m=r(v),g=n(6),y=i(g),C=function(){function e(t,n){(0,d.default)(this,e);var r=(0,c.default)({},t.val());this.uid=t.name(),this.roomId=n,this.text=r.text,this.from=r.from,this._created=r._created}return(0,l.default)(e,[{key:"edit",value:function(e){var t=this;return h.update("/rooms/"+this.roomId+"/messages/"+this.uid,{text:e}).then(function(){return t.text=e,t}).catch(m.r("Message~edit"))}},{key:"remove",value:function(){return h.remove("/rooms/"+this.roomId+"/messages/"+this.uid).catch(m.r("Message~remove"))}}],[{key:"send",value:function(t,n){if(!y.default.user)return a.default.reject(new Error("Cannot send a message to the Room without a User being logged in."));var r={from:y.default.user.uid,_created:h.ts(),text:n};return h.push("_/rooms/"+t.uid+"/messages",r).then(function(e){return h.get("_/rooms/"+t.uid+"/messages/"+e.name())}).then(function(n){return new e(n,t.uid)}).catch(m.r("Message#send"))}}]),e}();t.default=C},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var i=n(9),o=r(i),a=n(0),s=r(a),c=function e(t){(0,s.default)(this,e);var n=(0,o.default)({},t.val());this.uid=t.name(),this.role=n.role,this.status=n.status,this._joined=n._joined,this.userAgent=n.userAgent};t.default=c},function(e,t,n){"use strict";function r(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}function i(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var o=n(14),a=i(o),s=n(8),c=i(s),u=n(9),d=i(u),f=n(0),l=i(f),p=n(1),h=i(p),v=n(6),m=i(v),g=n(7),y=r(g),C=n(5),b=r(C),_=n(30),S=r(_),E=function(){function e(t){(0,l.default)(this,e),b.d("Remote~new",t),this.roomId=t.roomId,this.uid=t.uid,this.from=t.from,this.type=t.type,this.device=t.device,this.userAgent=t.userAgent,this.height=t.height,this.width=t.width,this.container=m.default.config.remoteStreamContainer,this.muted=(0,d.default)({audio:!1,video:!1},t.muted),this._callbacks={},this.peerConnection=null}return(0,h.default)(e,[{key:"subscribe",value:function(e){var t=this;return m.default.user?(this.container=e||m.default.config.remoteStreamContainer,b.d("Remote~subscribe",this.container),m.default.peerConnections.answer(this,this.container).then(function(e){t.peerConnection=e}).then(function(){return y.update("_/rooms/"+t.roomId+"/subscribers/"+t.uid+"/"+m.default.device,{to:m.default.user.uid,_created:y.ts()})}).then(function(){y.onDisconnect("_/rooms/"+t.roomId+"/subscribers/"+t.uid+"/"+m.default.device).remove();var e=!1;y.on("_/rooms/"+t.roomId+"/streams/"+t.uid,"value",function(n){var r=n.val();if(b.d("Remote~updated",r),r){t.type=r.type;var i=r.height,o=r.width;!i&&!o||i===t.height&&o===t.height||(t.height=r.height,t.width=r.width,b.w(t._callbacks[S.stream.SIZE]),(t._callbacks[S.stream.SIZE]||[]).forEach(function(e){return e(t.height,t.width)}));var a=r.muted;!a||a.audio===t.muted.audio&&a.video===t.muted.video||(t.muted=a,b.w(t._callbacks[S.stream.MUTE]),(t._callbacks[S.stream.MUTE]||[]).forEach(function(e){return e(t.muted)})),e=!0}else e&&(b.i("Remote#removed",t),t._close(!0))})}).catch(b.r("Remote~subscribe"))):c.default.reject(new Error("Only an authenticated user can subscribe to a Room's stream."))}},{key:"unSubscribe",value:function(){return this._close(!1)}},{key:"_close",value:function(e){return y.onDisconnect("_/rooms/"+this.roomId+"/subscribers/"+this.uid+"/"+m.default.device).cancel(),y.off("_/rooms/"+this.roomId+"/streams/"+this.uid,"value"),!e&&y.remove("_/rooms/"+this.roomId+"/subscribers/"+this.uid+"/"+m.default.device),c.default.resolve(m.default.peerConnections.close(this.uid,this.device))}},{key:"on",value:function(e,t){S.stream.supports(e)&&(this._callbacks[e]||(this._callbacks[e]=[]),this._callbacks[e].push(t))}},{key:"off",value:function(e,t){e?S.stream.supports(e)&&(this._callbacks[e]=t?this._callbacks[e].filter(function(e){return e!==t}):[]):this._callbacks={}}},{key:"update",value:function(e){var t=this;(0,a.default)(e).forEach(function(n){t[n]=e[n]})}},{key:"node",get:function(){return this.peerConnection?this.peerConnection.node:null}}]),e}();t.default=E},function(e,t,n){"use strict";t.__esModule=!0;var r=n(98),i=function(e){return e&&e.__esModule?e:{default:e}}(r);t.default=function(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return(0,i.default)(e)}},function(e,t,n){var r=n(22),i=n(4)("toStringTag"),o="Arguments"==r(function(){return arguments}()),a=function(e,t){try{return e[t]}catch(e){}};e.exports=function(e){var t,n,s;return void 0===e?"Undefined":null===e?"Null":"string"==typeof(n=a(t=Object(e),i))?n:o?r(t):"Object"==(s=r(t))&&"function"==typeof t.callee?"Arguments":s}},function(e,t,n){var r=n(3).document;e.exports=r&&r.documentElement},function(e,t,n){e.exports=!n(13)&&!n(21)(function(){return 7!=Object.defineProperty(n(41)("div"),"a",{get:function(){return 7}}).a})},function(e,t,n){var r=n(22);e.exports=Object("z").propertyIsEnumerable(0)?Object:function(e){return"String"==r(e)?e.split(""):Object(e)}},function(e,t,n){var r=n(24),i=n(4)("iterator"),o=Array.prototype;e.exports=function(e){return void 0!==e&&(r.Array===e||o[i]===e)}},function(e,t,n){var r=n(12);e.exports=function(e,t,n,i){try{return i?t(r(n)[0],n[1]):t(n)}catch(t){var o=e.return;throw void 0!==o&&r(o.call(e)),t}}},function(e,t,n){"use strict";var r=n(33),i=n(10),o=n(79),a=n(16),s=n(15),c=n(24),u=n(122),d=n(35),f=n(129),l=n(4)("iterator"),p=!([].keys&&"next"in[].keys()),h=function(){return this};e.exports=function(e,t,n,v,m,g,y){u(n,t,v);var C,b,_,S=function(e){if(!p&&e in P)return P[e];switch(e){case"keys":case"values":return function(){return new n(this,e)}}return function(){return new n(this,e)}},E=t+" Iterator",T="values"==m,w=!1,P=e.prototype,k=P[l]||P["@@iterator"]||m&&P[m],O=!p&&k||S(m),R=m?T?S("entries"):O:void 0,x="Array"==t?P.entries||k:k;if(x&&(_=f(x.call(new e)))!==Object.prototype&&_.next&&(d(_,E,!0),r||s(_,l)||a(_,l,h)),T&&k&&"values"!==k.name&&(w=!0,O=function(){return k.call(this)}),r&&!y||!p&&!w&&P[l]||a(P,l,O),c[t]=O,c[E]=h,m)if(C={values:T?O:S("values"),keys:g?O:S("keys"),entries:R},y)for(b in C)b in P||o(P,b,C[b]);else i(i.P+i.F*(p||w),t,C);return C}},function(e,t,n){var r=n(4)("iterator"),i=!1;try{var o=[7][r]();o.return=function(){i=!0},Array.from(o,function(){throw 2})}catch(e){}e.exports=function(e,t){if(!t&&!i)return!1;var n=!1;try{var o=[7],a=o[r]();a.next=function(){return{done:n=!0}},o[r]=function(){return a},e(o)}catch(e){}return n}},function(e,t,n){var r=n(12),i=n(127),o=n(42),a=n(45)("IE_PROTO"),s=function(){},c=function(){var e,t=n(41)("iframe"),r=o.length;for(t.style.display="none",n(65).appendChild(t),t.src="javascript:",e=t.contentWindow.document,e.open(),e.write("<script>document.F=Object<\/script>"),e.close(),c=e.F;r--;)delete c.prototype[o[r]];return c()};e.exports=Object.create||function(e,t){var n;return null!==e?(s.prototype=r(e),n=new s,s.prototype=null,n[a]=e):n=c(),void 0===t?n:i(n,t)}},function(e,t,n){var r=n(34),i=n(26),o=n(18),a=n(49),s=n(15),c=n(66),u=Object.getOwnPropertyDescriptor;t.f=n(13)?u:function(e,t){if(e=o(e),t=a(t,!0),c)try{return u(e,t)}catch(e){}if(s(e,t))return i(!r.f.call(e,t),e[t])}},function(e,t,n){var r=n(75),i=n(42).concat("length","prototype");t.f=Object.getOwnPropertyNames||function(e){return r(e,i)}},function(e,t,n){var r=n(15),i=n(18),o=n(116)(!1),a=n(45)("IE_PROTO");e.exports=function(e,t){var n,s=i(e),c=0,u=[];for(n in s)n!=a&&r(s,n)&&u.push(n);for(;t.length>c;)r(s,n=t[c++])&&(~o(u,n)||u.push(n));return u}},function(e,t,n){var r=n(10),i=n(2),o=n(21);e.exports=function(e,t){var n=(i.Object||{})[e]||Object[e],a={};a[e]=t(n),r(r.S+r.F*o(function(){n(1)}),"Object",a)}},function(e,t){e.exports=function(e){try{return{e:!1,v:e()}}catch(e){return{e:!0,v:e}}}},function(e,t,n){var r=n(12),i=n(17),o=n(43);e.exports=function(e,t){if(r(e),i(t)&&t.constructor===e)return t;var n=o.f(e);return(0,n.resolve)(t),n.promise}},function(e,t,n){e.exports=n(16)},function(e,t,n){var r=n(12),i=n(32),o=n(4)("species");e.exports=function(e,t){var n,a=r(e).constructor;return void 0===a||void 0==(n=r(a)[o])?t:i(n)}},function(e,t,n){var r,i,o,a=n(23),s=n(120),c=n(65),u=n(41),d=n(3),f=d.process,l=d.setImmediate,p=d.clearImmediate,h=d.MessageChannel,v=d.Dispatch,m=0,g={},y=function(){var e=+this;if(g.hasOwnProperty(e)){var t=g[e];delete g[e],t()}},C=function(e){y.call(e.data)};l&&p||(l=function(e){for(var t=[],n=1;arguments.length>n;)t.push(arguments[n++]);return g[++m]=function(){s("function"==typeof e?e:Function(e),t)},r(m),m},p=function(e){delete g[e]},"process"==n(22)(f)?r=function(e){f.nextTick(a(y,e,1))}:v&&v.now?r=function(e){v.now(a(y,e,1))}:h?(i=new h,o=i.port2,i.port1.onmessage=C,r=a(o.postMessage,o,1)):d.addEventListener&&"function"==typeof postMessage&&!d.importScripts?(r=function(e){d.postMessage(e+"","*")},d.addEventListener("message",C,!1)):r="onreadystatechange"in u("script")?function(e){c.appendChild(u("script")).onreadystatechange=function(){c.removeChild(this),y.call(e)}}:function(e){setTimeout(a(y,e,1),0)}),e.exports={set:l,clear:p}},function(e,t,n){var r=n(64),i=n(4)("iterator"),o=n(24);e.exports=n(2).getIteratorMethod=function(e){if(void 0!=e)return e[i]||e["@@iterator"]||o[r(e)]}},function(e,t){},function(e,t,n){n(135);for(var r=n(3),i=n(16),o=n(24),a=n(4)("toStringTag"),s="CSSRuleList,CSSStyleDeclaration,CSSValueList,ClientRectList,DOMRectList,DOMStringList,DOMTokenList,DataTransferItemList,FileList,HTMLAllCollection,HTMLCollection,HTMLFormElement,HTMLSelectElement,MediaList,MimeTypeArray,NamedNodeMap,NodeList,PaintRequestList,Plugin,PluginArray,SVGLengthList,SVGNumberList,SVGPathSegList,SVGPointList,SVGStringList,SVGTransformList,SourceBufferList,StyleSheetList,TextTrackCueList,TextTrackList,TouchList".split(","),c=0;c<s.length;c++){var u=s[c],d=r[u],f=d&&d.prototype;f&&!f[a]&&i(f,a,u),o[u]=o.Array}},function(e,t){var n={}.toString;e.exports=function(e){return n.call(e).slice(8,-1)}},function(e,t,n){var r=n(147);e.exports=function(e,t,n){if(r(e),void 0===t)return e;switch(n){case 1:return function(n){return e.call(t,n)};case 2:return function(n,r){return e.call(t,n,r)};case 3:return function(n,r,i){return e.call(t,n,r,i)}}return function(){return e.apply(t,arguments)}}},function(e,t){e.exports=function(e){try{return!!e()}catch(e){return!0}}},function(e,t){var n=0,r=Math.random();e.exports=function(e){return"Symbol(".concat(void 0===e?"":e,")_",(++n+r).toString(36))}},function(e,t,n){var r=n(163)("wks"),i=n(88),o=n(27).Symbol,a="function"==typeof o;(e.exports=function(e){return r[e]||(r[e]=a&&o[e]||(a?o:i)("Symbol."+e))}).store=r},function(e,t){var n;n=function(){return this}();try{n=n||Function("return this")()||(0,eval)("this")}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0}),t.browser=void 0;var i,o=n(63),a=r(o),s=n(9),c=r(s),u=n(170),d=n(31),f=r(d),l=t.browser=(0,c.default)({compatible:!/\s/.test(u.browserDetails.browser)&&(!u.browserDetails.minVersion||u.browserDetails.version>=u.browserDetails.minVersion)},u.browserDetails),p="Reach v2.10.0-beta.10 | Schema draft-00 | Webcom v"+f.default.SDK_VERSION,h="";null===l.version?h="Unsupported browser: browser must support WebRTC Peer-to-peer connections to use Reach":l.minVersion&&l.minVersion>l.version?h="Unsupported browser: browser is outdated, update to latest version ("+l.minVersion+"+)":u.browserShim||(h="No shim for your browser. There might a problem with your package.");var v=[p+" "+h];/^(chrome|firefox)$/.test(l.browser)&&(v=["%c "+p+" %c "+h,"background: "+(l.compatible?"#f50":"red")+"; color: #fff; font-weight: bold","color: "+(l.compatible?"inherit":"red")]),(i=console).log.apply(i,(0,a.default)(v))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.video={VP8:/^vp8/i,VP9:/^vp9/i,VP10:/^vp10/i,H264:/^h264/i,H265:/^h265/i},t.audio={OPUS:/^opus/i,G722:/^g722/i,G711:/^g711/i,ISAC:/^isac/i,ISAC_16:/^isac\/16000/i,ISAC_32:/^isac\/32000/i,LSAC:/^lsac/i}},function(e,t,n){"use strict";function r(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}function i(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var o=n(14),a=i(o),s=n(0),c=i(s),u=n(1),d=i(u),f=n(63),l=i(f),p=n(29),h=i(p),v=n(7),m=r(v),g=n(5),y=r(g),C=n(6),b=i(C),_=function(e){var t,n=e.map(function(e){var t=e.username,n=e.credential,r=e.urls,i=e.url,o=r||i;return"string"!=typeof o?o.map(function(e){return{username:t,credential:n,urls:e}}):[e]});return(t=[]).concat.apply(t,(0,l.default)(n))},S=function(){function e(t){var n=this;(0,c.default)(this,e),this.constraints=null,this.localStreamContainer=null,this.remoteStreamContainer=null,this.preferredVideoCodec=null,this.preferredAudioCodec=null,this.reset(),this.assign(t),m.get("_/ice").then(function(e){e&&(n.iceServers=e.val(),y.i("ICEServers",n.iceServers.length>0?n.iceServers:"None"))},function(e){return y.d("ICEServers",e)})}return(0,d.default)(e,[{key:"assign",value:function(e){var t=this;(0,a.default)(e||{}).forEach(function(n){t[n]=e[n]})}},{key:"reset",value:function(){this.assign({constraints:h.default.constraints(),logLevel:"ERROR"})}},{key:"logLevel",set:function(e){b.default.logLevel=e},get:function(){return b.default.logLevel}},{key:"iceServers",set:function(e){if(y.d("Config~set~iceServers",e),e)if(this._iceServers){var t=_(this._iceServers),n=_(e);n.forEach(function(e){t.some(function(t){return t.urls===e.urls&&t.username===e.username&&t.credential===e.credential})||t.push(e)}),this._iceServers=t.reduce(function(e,t){var n=t.username,r=t.credential,i=t.urls,o=e.findIndex(function(e){return e.username===n&&e.credential===r});return o>=0?e[o].urls.push(i):e.push({username:n,credential:r,urls:[i]}),e},[])}else this._iceServers=[].concat(e||[])},get:function(){return this._iceServers||[{username:"admin",credential:"webcom1234",urls:["turns:turn1.webcom.orange.com:443","turn:turn1.webcom.orange.com:443?transport=tcp","turn:turn1.webcom.orange.com:3478?transport=tcp"]}]}}]),e}();t.default=S},function(e,t,n){"use strict";function r(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}function i(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var o=n(14),a=i(o),s=n(8),c=i(s),u=n(9),d=i(u),f=n(0),l=i(f),p=n(1),h=i(p),v=n(57),m=i(v),g=n(5),y=r(g),C=n(6),b=i(C),_=n(7),S=r(_),E=n(29),T=i(E),w=n(20),P=[T.default.facingMode.USER,T.default.facingMode.ENVIRONMENT],k=function(e,t){return e[t].exact||e[t].ideal||e[t]},O=function(e,t,n,r){e[t]={exact:r},delete e[n]},R=function(){function e(t){(0,l.default)(this,e),this.roomId=t.roomId,this.uid=t.uid,this.type=t.type,this.muted=(0,d.default)({audio:!1,video:!1},t.muted),this.container=t.container||b.default.config.localStreamContainer,this.node=null,this.peerConnections=[],this.status=w.NONE,this.isVideoLoaded=!1,this._inputs={},this.constraints=t.constraints}return(0,h.default)(e,[{key:"updateConstraints",value:function(e){var t=this;return y.d("Local~updateConstraints",e),this.constraints=e,navigator.mediaDevices.getUserMedia(this.constraints).then(function(e){["audio","video"].forEach(function(e){var n=t.constraints[e];n&&(n.deviceId||n.facingMode)&&(t._inputs[e]=k(n,n.facingMode?"facingMode":"deviceId"))}),t.media=e})}},{key:"mute",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:m.default.AUDIO,t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];y.d("mute",e,t);var n=this.muted.audio,r=this.muted.video,i=void 0;switch(e){case m.default.AUDIO:n=t,i=this.media.getAudioTracks();break;case m.default.VIDEO:case m.default.SCREEN_SHARING:r=t,i=this.media.getVideoTracks();break;case m.default.AUDIO_VIDEO:n=t,r=t,i=this.media.getTracks()}i.forEach(function(e){e.enabled=!t}),this.muted={audio:n,video:r},S.set("_/rooms/"+this.roomId+"/streams/"+this.uid+"/muted",this.muted)}},{key:"unMute",value:function(e){this.mute(e,!1)}},{key:"close",value:function(){if(!~[w.CLOSED,w.CLOSING].indexOf(this.status)){this.status=w.CLOSING;var e="_/rooms/"+this.roomId+"/subscribers/"+this.uid;S.off(e,"child_added"),S.off(e,"child_removed"),S.onDisconnect("_/rooms/"+this.roomId+"/streams/"+this.uid).cancel(),S.onDisconnect("_/rooms/"+this.roomId+"/subscribers/"+this.uid).cancel(),S.remove(e),S.remove("_/rooms/"+this.roomId+"/streams/"+this.uid),this.media=null,this.status=w.CLOSED}return c.default.resolve(this.status)}},{key:"switchCamera",value:function(e){return this._switchDevice(m.default.VIDEO,e)}},{key:"switchMicrophone",value:function(e){return this._switchDevice(m.default.AUDIO,e)}},{key:"_switchDevice",value:function(e,t){var n=this;if(y.d("Local~_switchDevice",e,t),this.media.getTracks().some(function(t){return t.kind===e})){var r=c.default.resolve(t),i=P.indexOf(this._inputs[e]);return r=!t&&~i?c.default.resolve(P[(i+1)%P.length]):~P.indexOf(t)?c.default.resolve(t):T.default.devices().then(function(r){var i=r[e+"input"].map(function(e){return e.deviceId});i.sort();var o=t;if(t&&!i.some(function(e){return e===t}))return c.default.reject(new Error("Unknown "+e+" device"));if(!t&&i.length>1){var a=n._inputs[e]?i.findIndex(function(t){return t===n._inputs[e]},n):0;o=i[++a%i.length]}return o}),r.then(function(t){if(n._inputs[e]!==t){n._inputs[e]=t,n.media.getTracks().forEach(function(e){return e.stop()});var r=(0,d.default)({},n.constraints),i=["facingMode","deviceId"];return~P.indexOf(t)||(i=i.reverse()),O(r[e],i[0],i[1],t),y.d("Local~_switchDevice",e,r),n.updateConstraints(r)}}).then(function(){return n})}return c.default.reject(new Error("Current stream does not contain a "+e+" track"))}},{key:"constraints",set:function(e){var t=this,n=e||b.default.config.constraints,r=T.default.constraints();["audio","video"].forEach(function(e){~t.type.indexOf(e)?n[e]||(n[e]=r[e]):n[e]=!1,(n[e].deviceId||n[e].facingMode)&&(t._inputs[e]=k(n[e],n[e].facingMode?"facingMode":"deviceId"))}),y.d("Local~set#contraints",n),this._constraints=n},get:function(){return this._constraints}},{key:"media",set:function(e){var t=this;if(e){if(!(e instanceof MediaStream))throw new Error("The media MUST be a MediaStream");var n={};e.getTracks().forEach(function(e){e.enabled=!t.muted[e.kind],t._inputs[e.kind]||(n[e.kind]=e.label)}),(0,a.default)(n).length&&T.default.devices().then(function(e){(0,a.default)(n).forEach(function(r){if(e[r+"input"]){var i=e[r+"input"].filter(function(e){return e.label.length&&e.label===n[r]});1!==i.length||t._inputs[r]||(t._inputs[r]=i[0].deviceId),0!==i.length||""!==e[r+"input"][0].label||t._inputs[r]||(t._inputs[r]=e[r+"input"][0].deviceId)}})}),this.node=T.default.attachStream(e,this.container,this.node,0),this.node.onloadeddata=function(){t.isVideoLoaded=!0},this.status=w.CONNECTED,y.d("Local~set media",{mediaStream:e},this.node),this.peerConnections.forEach(function(n){return n.renegotiate(t._media,e)})}else this.media&&!e&&(this.node.srcObject=null,this.container.removeChild(this.node),this.node=null,this.media.getTracks().forEach(function(e){return e.stop()}),this.peerConnections.forEach(function(e){return e.close()}));this._media=e},get:function(){return this._media}}],[{key:"share",value:function(t,n,r,i){if(!b.default.user)return c.default.reject(new Error("Only an authenticated user can share a stream."));var o={from:b.default.user.uid,device:b.default.device,type:n},a=new e((0,d.default)({roomId:t,constraints:i,container:r},o));return y.d("Local~share",{sharedStream:a}),navigator.mediaDevices.getUserMedia(a.constraints).then(function(e){a.media=e}).then(function(){return S.push("_/rooms/"+t+"/streams",o)}).then(function(e){if(a.uid=e.name(),a.isVideoLoaded){var n={height:a.node.videoHeight,width:a.node.videoWidth};e.update(n)}else a.node.onloadeddata=function(){var t={height:a.node.videoHeight,width:a.node.videoWidth};e.update(t)};window.addEventListener("resize",function(){if(null!=a.node){var t={height:a.node.videoHeight,width:a.node.videoWidth};e.update(t)}}),b.default.streams.shared[a.uid]=a,S.onDisconnect("_/rooms/"+t+"/streams/"+a.uid).remove(),S.onDisconnect("_/rooms/"+t+"/subscribers/"+a.uid).remove();var r="_/rooms/"+a.roomId+"/subscribers/"+a.uid,i=function(e){return(0,d.default)({device:e.name()},e.val()||{})};return S.on(r,"child_added",function(e){var t=i(e);y.d("Local~subscribed",t),b.default.peerConnections.offer(a,t).then(function(e){return a.peerConnections.push(e)})},y.e.bind(y)),S.on(r,"child_removed",function(e){var t=i(e);y.d("Local~un-subscribed",t);var n=b.default.peerConnections.close(a.uid,t.device);a.peerConnections=a.peerConnections.filter(function(e){return e!==n})},y.e.bind(y)),y.d("Local~shared",{sharedStream:a}),a})}},{key:"getLocalVideo",value:function(t,n,r,i){if(!b.default.user)return c.default.reject(new Error("Only an authenticated user can share a stream."));var o={from:b.default.user.uid,device:b.default.device,userAgent:b.default.userAgent,type:n},a=new e((0,d.default)({roomId:t,constraints:i,container:r},o));return a.streamMetaData=o,y.d("Local~share",{sharedStream:a}),navigator.mediaDevices.getUserMedia(a.constraints).then(function(e){return a.media=e,a})}},{key:"publish",value:function(e){y.d("Local~publish");var t=e.roomId;return S.push("_/rooms/"+t+"/streams",e.streamMetaData).then(function(n){if(e.uid=n.name(),e.isVideoLoaded){var r={height:e.node.videoHeight,width:e.node.videoWidth};n.update(r)}else e.node.onloadeddata=function(){var t={height:e.node.videoHeight,width:e.node.videoWidth};n.update(t)};window.addEventListener("resize",function(){if(null!=e.node){var t={height:e.node.videoHeight,width:e.node.videoWidth};n.update(t)}}),b.default.streams.shared[e.uid]=e,S.onDisconnect("_/rooms/"+t+"/streams/"+e.uid).remove(),S.onDisconnect("_/rooms/"+t+"/subscribers/"+e.uid).remove();var i="_/rooms/"+e.roomId+"/subscribers/"+e.uid,o=function(e){return(0,d.default)({device:e.name()},e.val()||{})};return S.on(i,"child_added",function(t){var n=o(t);y.d("Local~subscribed",n),b.default.peerConnections.offer(e,n).then(function(t){return e.peerConnections.push(t)})},y.e.bind(y)),S.on(i,"child_removed",function(t){var n=o(t);y.d("Local~un-subscribed",n);var r=b.default.peerConnections.close(e.uid,n.device);e.peerConnections=e.peerConnections.filter(function(e){return e!==r})},y.e.bind(y)),y.d("Local~shared",{sharedStream:e}),e})}}]),e}();t.default=R},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var i=n(0),o=r(i),a=n(1),s=r(a),c=n(62),u=r(c),d=function(){function e(){(0,o.default)(this,e),this.shared={},this.remote={}}return(0,s.default)(e,[{key:"getRemote",value:function(e){var t=this.remote[e.uid];return t?t.update(e):this.remote[e.uid]=t=new u.default(e),t}},{key:"getShared",value:function(e){return this.shared[e.uid]}}]),e}();t.default=d},function(e,t,n){"use strict";function r(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}function i(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var o=n(8),a=i(o),s=n(101),c=i(s),u=n(0),d=i(u),f=n(1),l=i(f),p=n(6),h=i(p),v=n(5),m=r(v),g=n(29),y=i(g),C=n(59),b=i(C),_=n(7),S=r(_),E=n(20);n(146);var T={DtlsSrtpKeyAgreement:!0},w=function(e){return{OfferToReceiveAudio:e,OfferToReceiveVideo:e}},P="disconnected",k="connected",O="completed",R="checking",x="closed",D="failed",M=function(e){return e.toJSON&&"function"==typeof e.toJSON?e.toJSON():e},j=function(){function e(t,n,r,i){var o=this;(0,d.default)(this,e),this.stackId=t,this.streamId=n,this.remote=r,this.publish=i,this._localPath="_/webrtc/"+this.stackId+"/"+this.streamId+"/"+h.default.device,this._remotePath="_/webrtc/"+this.stackId+"/"+this.streamId+"/"+this.remote.device,this.negotiated=!1,this.node=null,this.container=null,this.pc=new RTCPeerConnection({iceServers:h.default.config.iceServers},{optional:[T],mandatory:w(!i)}),this.pc.onicecandidate=function(e){!o.negotiated&&e.candidate&&(m.d("PeerConnection~onicecandidate",e.candidate),S.push(o._localPath+"/ice",M(e.candidate)))},this.pc.oniceconnectionstatechange=function(){switch(m.d("PeerConnection~oniceconnectionstatechange",o.pc),o.pc.iceConnectionState){case R:break;case k:o._attachStream(),o._remoteICECandidates(!1);break;case O:o._remoteICECandidates(!1);break;case P:case D:m.e("PeerConnection~stateDisconnected","Disconnect PeerConnection");break;case x:m.d("PeerConnection~stateclosed","Close PeerConnection"),o.close()}o.negotiated=o.negotiated||o.isConnected},this.pc.onicegatheringstatechange=function(){m.d("PeerConnection~onicegatheringstatechange",o.pc.iceGatheringState)},this._status=E.OPENED}return(0,l.default)(e,[{key:"_remoteICECandidates",value:function(e){var t=this,n=this._remotePath+"/ice";e?S.on(n,"child_added",function(e){var n=e.val();m.d("PeerConnection~addIceCandidate",n),t.pc.addIceCandidate(new RTCIceCandidate(n))}):S.off(n,"child_added")}},{key:"_attachStream",value:function(){this.remoteStream&&this.isConnected&&(this.node=y.default.attachStream(this.remoteStream,this.container,this.node),this.node.muted=!1)}},{key:"answer",value:function(e){var t=this;return m.i("PeerConnection~answer",{htmlElement:e,peerConnection:this}),this.container=e,(0,c.default)(RTCPeerConnection.prototype,"ontrack")?this.pc.ontrack=function(e){m.d("PeerConnection~ontrack",e.streams[0]),t.remoteStream=e.streams[0]}:this.pc.onaddstream=function(e){m.d("PeerConnection~onaddstream",e.stream),t.remoteStream=e.stream},S.on(this._remotePath+"/sdp","value",function(e){var n=e.val();null!=n&&t.pc.setRemoteDescription(n).then(function(){return m.d("PeerConnection~answer#remoteDescription",t.pc.remoteDescription.sdp)}).then(function(){return/^offer$/.test(t.pc.remoteDescription.type)?t.pc.createAnswer():a.default.reject(new Error("SDP is not an offer"))}).then(function(e){return t._setPreferredCodecs(e)}).then(function(e){return t.pc.setLocalDescription(e)}).then(function(){m.d("PeerConnection~answer#localSDP",t.pc.localDescription.sdp),t._remoteICECandidates(!0)}).then(function(){return t._sendSdpToRemote()}).catch(m.r("PeerConnection~answser#error"))}),a.default.resolve(this)}},{key:"offer",value:function(e){var t=this;m.i("PeerConnection~offer",{stream:e,peerConnection:this});var n=void 0;return new a.default(function(r,i){t.pc.onnegotiationneeded=function(){m.d("PeerConnection~onnegotiationneeded"),n&&(clearTimeout(n),n=null),n=setTimeout(function(){n=null,t._sendOffer().then(function(){r(t)}).catch(function(e){m.d("PeerConnection~offer",e),i(e)})},20)},S.on(t._remotePath+"/sdp","value",function(e){var n=e.val();null!=n&&t.pc.setRemoteDescription(n).then(function(){m.d("PeerConnection~offer#remoteDescription",t.pc.remoteDescription.sdp),t._remoteICECandidates(!0)}).catch(m.e.bind(m,"PeerConnection~offer#remoteDescription"))}),t._alterStream(e,"add")})}},{key:"_sendSdpToRemote",value:function(){var e=this,t=this.remote.to?this.remote.to:this.remote.from;b.default.get(t,this.remote.device).then(function(t){var n=e.pc.localDescription.sdp,r=n;-1!==navigator.userAgent.indexOf("Chrome")&&-1!==navigator.userAgent.indexOf("Android")&&-1!==t.userAgent.indexOf("Safari")&&(r=r.replace("42001f","42e01f")),-1!==navigator.userAgent.indexOf("Safari")&&-1!==t.userAgent.indexOf("Chrome")&&-1!==t.userAgent.indexOf("Android")&&(r=r.replace("42e01f","42001f")),m.d("PeerConnection~_sendSdpToRemote#SDP sent to remote",r);var i={sdp:r,type:e.pc.localDescription.type};S.update(e._localPath+"/sdp",M(i))})}},{key:"_sendOffer",value:function(){var e=this;return m.d("PeerConnection~_sendOffer"),this.pc.createOffer().then(function(t){return e._setPreferredCodecs(t)}).then(function(t){return e.pc.setLocalDescription(t)}).then(function(){return m.d("PeerConnection~_sendOffer#localDescription",e.pc.localDescription.sdp)}).then(function(){return e._sendSdpToRemote()})}},{key:"_alterStream",value:function(e,t){var n=this;(0,c.default)(RTCPeerConnection.prototype,t+"Track")?"add"===t?e.getTracks().forEach(function(r){return n.pc[t+"Track"](r,e)},this):this.pc.getSenders().forEach(function(e){return n.pc[t+"Track"](e)},this):this.pc[t+"Stream"](e)}},{key:"renegotiate",value:function(e,t){m.d("PeerConnection~renegotiate"),(0,c.default)(RTCPeerConnection.prototype,"getSenders")&&"RTCRtpSender"in window&&(0,c.default)(RTCRtpSender.prototype,"replaceTrack")?(this.pc.getSenders().forEach(function(e){var n=void 0;switch(e.track.kind){case"audio":n=t.getAudioTracks();break;case"video":n=t.getVideoTracks();break;default:n=[]}n.length&&e.replaceTrack(n[0])}),this._sendOffer().catch(function(e){m.d("PeerConnection~renegotiate",e)})):(this._alterStream(e,"remove"),this._alterStream(t,"add"))}},{key:"close",value:function(){var e=this;this._status===E.OPENED&&(this._status=E.CLOSING,this.node&&(this.node.stop&&this.node.stop(),this.node.srcObject=null,this.container.removeChild(this.node),this.node=null),this._remoteICECandidates(!1),S.off(this._remotePath+"/sdp","value"),S.remove(this._localPath),this.pc&&"closed"!==this.pc.signalingState?(this.pc.onsignalingstatechange=function(){"closed"!==e.pc.signalingState&&(e._status=E.CLOSED)},this.pc.close()):this._status=E.CLOSED)}},{key:"_setPreferredCodecs",value:function(e){if(h.default.config.preferredVideoCodec||h.default.config.preferredAudioCodec){m.d("PeerConnection~_setPreferredCodecs",{description:e,config:h.default.config});var t=e.sdp.split(/\r?\n/),n={audio:[],video:[]},r=null;t.forEach(function(e,t){if(/^m=/.test(e)){var i=/^m=(\w+)\s[0-9\/]+\s[A-Za-z0-9\/]+\s([0-9\s]+)/.exec(e);r={fmt:i[2].split(/\s/),index:t,codecs:[]},n[i[1]].push(r)}else if(r&&/^a=rtpmap:/.test(e)){var o=/^a=rtpmap:(\d+)\s([a-zA-Z0-9\-\/]+)/.exec(e);o&&r.codecs.push({id:o[1],name:o[2],index:t})}}),m.d("PeerConnection~_setPreferredCodecs",n);var i=!1,o=function(e,n){e.forEach(function(e){var r=e.codecs.find(function(e){return n.test(e.name)});if(r){var o=[r.id].concat(e.fmt.filter(function(e){return e!==r.id}));t[e.index]=t[e.index].replace(e.fmt.join(" "),o.join(" ")),i=!0}})};if(h.default.config.preferredVideoCodec&&o(n.video,h.default.config.preferredVideoCodec),h.default.config.preferredAudioCodec&&o(n.audio,h.default.config.preferredAudioCodec),i)return m.d("PeerConnection~_setPreferredCodecs",t.join("\r\n")),{sdp:t.join("\r\n"),type:e.type}}return e}},{key:"remoteStream",set:function(e){this._remoteStream=e,this._attachStream()},get:function(){return this._remoteStream}},{key:"isConnected",get:function(){return this.pc&&!!~[k,O,"other"].indexOf(this.pc.iceConnectionState)}}]),e}();t.default=j},function(e,t,n){"use strict";function r(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}function i(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var o=n(8),a=i(o),s=n(0),c=i(s),u=n(1),d=i(u),f=n(96),l=i(f),p=n(6),h=i(p),v=n(5),m=r(v),g=n(7),y=r(g),C=function(e,t){return e.localeCompare(t,"en-us")>0?e+"-"+t:t+"-"+e},b=function(){function e(){(0,c.default)(this,e),this.stacks={}}return(0,d.default)(e,[{key:"getPeerConnection",value:function(e,t,n){var r=this;if(!h.default.user)return a.default.reject(new Error("Only an authenticated user can get a PeerConnection's object."));var i=C(t.device,h.default.device);if(this.stacks[i]&&this.stacks[i][e.uid])return a.default.resolve(this.stacks[i][e.uid]);this.stacks[i]||(this.stacks[i]={});var o={};return o[h.default.user.uid]=!0,o[t.from||t.to]=!0,y.update("_/webrtc/"+i,o).then(function(){return new l.default(i,e.uid,t,n)}).then(function(t){return m.d("PeerConnectionManager~getPeerConnection",{stackId:i,streamId:e.uid,pc:t}),r.stacks[i][e.uid]=t,t}).catch(m.r("PeerConnectionManager~getPeerConnection"))}},{key:"offer",value:function(e,t){return m.d("PeerConnectionManager~offer",{localStream:e,subscriber:t}),this.getPeerConnection(e,t,!0).then(function(t){return t.offer(e.media)})}},{key:"answer",value:function(e,t){return m.d("PeerConnectionManager~answer",{remoteStream:e,htmlElement:t}),this.getPeerConnection(e,e,!1).then(function(e){return e.answer(t)})}},{key:"close",value:function(e,t){var n=C(t,h.default.device),r=this.stacks[n]?this.stacks[n][e]:null;return!!r&&(r.close(),this.stacks[n][e]=null,delete this.stacks[n][e],r)}}]),e}();t.default=b},function(e,t,n){e.exports={default:n(105),__esModule:!0}},function(e,t,n){e.exports={default:n(106),__esModule:!0}},function(e,t,n){e.exports={default:n(108),__esModule:!0}},function(e,t,n){e.exports={default:n(109),__esModule:!0}},function(e,t,n){e.exports={default:n(112),__esModule:!0}},function(e,t,n){e.exports={default:n(113),__esModule:!0}},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}t.__esModule=!0;var i=n(103),o=r(i),a=n(102),s=r(a),c="function"==typeof s.default&&"symbol"==typeof o.default?function(e){return typeof e}:function(e){return e&&"function"==typeof s.default&&e.constructor===s.default&&e!==s.default.prototype?"symbol":typeof e};t.default="function"==typeof s.default&&"symbol"===c(o.default)?function(e){return void 0===e?"undefined":c(e)}:function(e){return e&&"function"==typeof s.default&&e.constructor===s.default&&e!==s.default.prototype?"symbol":void 0===e?"undefined":c(e)}},function(e,t,n){n(52),n(134),e.exports=n(2).Array.from},function(e,t,n){var r=n(2),i=r.JSON||(r.JSON={stringify:JSON.stringify});e.exports=function(e){return i.stringify.apply(i,arguments)}},function(e,t,n){n(136),e.exports=n(2).Object.assign},function(e,t,n){n(137);var r=n(2).Object;e.exports=function(e,t,n){return r.defineProperty(e,t,n)}},function(e,t,n){n(138);var r=n(2).Object;e.exports=function(e,t){return r.getOwnPropertyDescriptor(e,t)}},function(e,t,n){n(139),e.exports=n(2).Object.keys},function(e,t,n){n(83),n(52),n(84),n(140),n(142),n(143),e.exports=n(2).Promise},function(e,t,n){n(141),n(83),n(144),n(145),e.exports=n(2).Symbol},function(e,t,n){n(52),n(84),e.exports=n(51).f("iterator")},function(e,t){e.exports=function(){}},function(e,t){e.exports=function(e,t,n,r){if(!(e instanceof t)||void 0!==r&&r in e)throw TypeError(n+": incorrect invocation!");return e}},function(e,t,n){var r=n(18),i=n(48),o=n(133);e.exports=function(e){return function(t,n,a){var s,c=r(t),u=i(c.length),d=o(a,u);if(e&&n!=n){for(;u>d;)if((s=c[d++])!=s)return!0}else for(;u>d;d++)if((e||d in c)&&c[d]===n)return e||d||0;return!e&&-1}}},function(e,t,n){"use strict";var r=n(11),i=n(26);e.exports=function(e,t,n){t in e?r.f(e,t,i(0,n)):e[t]=n}},function(e,t,n){var r=n(25),i=n(44),o=n(34);e.exports=function(e){var t=r(e),n=i.f;if(n)for(var a,s=n(e),c=o.f,u=0;s.length>u;)c.call(e,a=s[u++])&&t.push(a);return t}},function(e,t,n){var r=n(23),i=n(69),o=n(68),a=n(12),s=n(48),c=n(82),u={},d={},t=e.exports=function(e,t,n,f,l){var p,h,v,m,g=l?function(){return e}:c(e),y=r(n,f,t?2:1),C=0;if("function"!=typeof g)throw TypeError(e+" is not iterable!");if(o(g)){for(p=s(e.length);p>C;C++)if((m=t?y(a(h=e[C])[0],h[1]):y(e[C]))===u||m===d)return m}else for(v=g.call(e);!(h=v.next()).done;)if((m=i(v,y,h.value,t))===u||m===d)return m};t.BREAK=u,t.RETURN=d},function(e,t){e.exports=function(e,t,n){var r=void 0===n;switch(t.length){case 0:return r?e():e.call(n);case 1:return r?e(t[0]):e.call(n,t[0]);case 2:return r?e(t[0],t[1]):e.call(n,t[0],t[1]);case 3:return r?e(t[0],t[1],t[2]):e.call(n,t[0],t[1],t[2]);case 4:return r?e(t[0],t[1],t[2],t[3]):e.call(n,t[0],t[1],t[2],t[3])}return e.apply(n,t)}},function(e,t,n){var r=n(22);e.exports=Array.isArray||function(e){return"Array"==r(e)}},function(e,t,n){"use strict";var r=n(72),i=n(26),o=n(35),a={};n(16)(a,n(4)("iterator"),function(){return this}),e.exports=function(e,t,n){e.prototype=r(a,{next:i(1,n)}),o(e,t+" Iterator")}},function(e,t){e.exports=function(e,t){return{value:t,done:!!e}}},function(e,t,n){var r=n(37)("meta"),i=n(17),o=n(15),a=n(11).f,s=0,c=Object.isExtensible||function(){return!0},u=!n(21)(function(){return c(Object.preventExtensions({}))}),d=function(e){a(e,r,{value:{i:"O"+ ++s,w:{}}})},f=function(e,t){if(!i(e))return"symbol"==typeof e?e:("string"==typeof e?"S":"P")+e;if(!o(e,r)){if(!c(e))return"F";if(!t)return"E";d(e)}return e[r].i},l=function(e,t){if(!o(e,r)){if(!c(e))return!0;if(!t)return!1;d(e)}return e[r].w},p=function(e){return u&&h.NEED&&c(e)&&!o(e,r)&&d(e),e},h=e.exports={KEY:r,NEED:!1,fastKey:f,getWeak:l,onFreeze:p}},function(e,t,n){var r=n(3),i=n(81).set,o=r.MutationObserver||r.WebKitMutationObserver,a=r.process,s=r.Promise,c="process"==n(22)(a);e.exports=function(){var e,t,n,u=function(){var r,i;for(c&&(r=a.domain)&&r.exit();e;){i=e.fn,e=e.next;try{i()}catch(r){throw e?n():t=void 0,r}}t=void 0,r&&r.enter()};if(c)n=function(){a.nextTick(u)};else if(!o||r.navigator&&r.navigator.standalone)if(s&&s.resolve){var d=s.resolve();n=function(){d.then(u)}}else n=function(){i.call(r,u)};else{var f=!0,l=document.createTextNode("");new o(u).observe(l,{characterData:!0}),n=function(){l.data=f=!f}}return function(r){var i={fn:r,next:void 0};t&&(t.next=i),e||(e=i,n()),t=i}}},function(e,t,n){"use strict";var r=n(25),i=n(44),o=n(34),a=n(36),s=n(67),c=Object.assign;e.exports=!c||n(21)(function(){var e={},t={},n=Symbol(),r="abcdefghijklmnopqrst";return e[n]=7,r.split("").forEach(function(e){t[e]=e}),7!=c({},e)[n]||Object.keys(c({},t)).join("")!=r})?function(e,t){for(var n=a(e),c=arguments.length,u=1,d=i.f,f=o.f;c>u;)for(var l,p=s(arguments[u++]),h=d?r(p).concat(d(p)):r(p),v=h.length,m=0;v>m;)f.call(p,l=h[m++])&&(n[l]=p[l]);return n}:c},function(e,t,n){var r=n(11),i=n(12),o=n(25);e.exports=n(13)?Object.defineProperties:function(e,t){i(e);for(var n,a=o(t),s=a.length,c=0;s>c;)r.f(e,n=a[c++],t[n]);return e}},function(e,t,n){var r=n(18),i=n(74).f,o={}.toString,a="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[],s=function(e){try{return i(e)}catch(e){return a.slice()}};e.exports.f=function(e){return a&&"[object Window]"==o.call(e)?s(e):i(r(e))}},function(e,t,n){var r=n(15),i=n(36),o=n(45)("IE_PROTO"),a=Object.prototype;e.exports=Object.getPrototypeOf||function(e){return e=i(e),r(e,o)?e[o]:"function"==typeof e.constructor&&e instanceof e.constructor?e.constructor.prototype:e instanceof Object?a:null}},function(e,t,n){var r=n(16);e.exports=function(e,t,n){for(var i in t)n&&e[i]?e[i]=t[i]:r(e,i,t[i]);return e}},function(e,t,n){"use strict";var r=n(3),i=n(2),o=n(11),a=n(13),s=n(4)("species");e.exports=function(e){var t="function"==typeof i[e]?i[e]:r[e];a&&t&&!t[s]&&o.f(t,s,{configurable:!0,get:function(){return this}})}},function(e,t,n){var r=n(47),i=n(40);e.exports=function(e){return function(t,n){var o,a,s=String(i(t)),c=r(n),u=s.length;return c<0||c>=u?e?"":void 0:(o=s.charCodeAt(c),o<55296||o>56319||c+1===u||(a=s.charCodeAt(c+1))<56320||a>57343?e?s.charAt(c):o:e?s.slice(c,c+2):a-56320+(o-55296<<10)+65536)}}},function(e,t,n){var r=n(47),i=Math.max,o=Math.min;e.exports=function(e,t){return e=r(e),e<0?i(e+t,0):o(e,t)}},function(e,t,n){"use strict";var r=n(23),i=n(10),o=n(36),a=n(69),s=n(68),c=n(48),u=n(117),d=n(82);i(i.S+i.F*!n(71)(function(e){Array.from(e)}),"Array",{from:function(e){var t,n,i,f,l=o(e),p="function"==typeof this?this:Array,h=arguments.length,v=h>1?arguments[1]:void 0,m=void 0!==v,g=0,y=d(l);if(m&&(v=r(v,h>2?arguments[2]:void 0,2)),void 0==y||p==Array&&s(y))for(t=c(l.length),n=new p(t);t>g;g++)u(n,g,m?v(l[g],g):l[g]);else for(f=y.call(l),n=new p;!(i=f.next()).done;g++)u(n,g,m?a(f,v,[i.value,g],!0):i.value);return n.length=g,n}})},function(e,t,n){"use strict";var r=n(114),i=n(123),o=n(24),a=n(18);e.exports=n(70)(Array,"Array",function(e,t){this._t=a(e),this._i=0,this._k=t},function(){var e=this._t,t=this._k,n=this._i++;return!e||n>=e.length?(this._t=void 0,i(1)):"keys"==t?i(0,n):"values"==t?i(0,e[n]):i(0,[n,e[n]])},"values"),o.Arguments=o.Array,r("keys"),r("values"),r("entries")},function(e,t,n){var r=n(10);r(r.S+r.F,"Object",{assign:n(126)})},function(e,t,n){var r=n(10);r(r.S+r.F*!n(13),"Object",{defineProperty:n(11).f})},function(e,t,n){var r=n(18),i=n(73).f;n(76)("getOwnPropertyDescriptor",function(){return function(e,t){return i(r(e),t)}})},function(e,t,n){var r=n(36),i=n(25);n(76)("keys",function(){return function(e){return i(r(e))}})},function(e,t,n){"use strict";var r,i,o,a,s=n(33),c=n(3),u=n(23),d=n(64),f=n(10),l=n(17),p=n(32),h=n(115),v=n(119),m=n(80),g=n(81).set,y=n(125)(),C=n(43),b=n(77),_=n(78),S=c.TypeError,E=c.process,T=c.Promise,w="process"==d(E),P=function(){},k=i=C.f,O=!!function(){try{var e=T.resolve(1),t=(e.constructor={})[n(4)("species")]=function(e){e(P,P)};return(w||"function"==typeof PromiseRejectionEvent)&&e.then(P)instanceof t}catch(e){}}(),R=function(e){var t;return!(!l(e)||"function"!=typeof(t=e.then))&&t},x=function(e,t){if(!e._n){e._n=!0;var n=e._c;y(function(){for(var r=e._v,i=1==e._s,o=0;n.length>o;)!function(t){var n,o,a=i?t.ok:t.fail,s=t.resolve,c=t.reject,u=t.domain;try{a?(i||(2==e._h&&j(e),e._h=1),!0===a?n=r:(u&&u.enter(),n=a(r),u&&u.exit()),n===t.promise?c(S("Promise-chain cycle")):(o=R(n))?o.call(n,s,c):s(n)):c(r)}catch(e){c(e)}}(n[o++]);e._c=[],e._n=!1,t&&!e._h&&D(e)})}},D=function(e){g.call(c,function(){var t,n,r,i=e._v,o=M(e);if(o&&(t=b(function(){w?E.emit("unhandledRejection",i,e):(n=c.onunhandledrejection)?n({promise:e,reason:i}):(r=c.console)&&r.error&&r.error("Unhandled promise rejection",i)}),e._h=w||M(e)?2:1),e._a=void 0,o&&t.e)throw t.v})},M=function(e){return 1!==e._h&&0===(e._a||e._c).length},j=function(e){g.call(c,function(){var t;w?E.emit("rejectionHandled",e):(t=c.onrejectionhandled)&&t({promise:e,reason:e._v})})},I=function(e){var t=this;t._d||(t._d=!0,t=t._w||t,t._v=e,t._s=2,t._a||(t._a=t._c.slice()),x(t,!0))},A=function(e){var t,n=this;if(!n._d){n._d=!0,n=n._w||n;try{if(n===e)throw S("Promise can't be resolved itself");(t=R(e))?y(function(){var r={_w:n,_d:!1};try{t.call(e,u(A,r,1),u(I,r,1))}catch(e){I.call(r,e)}}):(n._v=e,n._s=1,x(n,!1))}catch(e){I.call({_w:n,_d:!1},e)}}};O||(T=function(e){h(this,T,"Promise","_h"),p(e),r.call(this);try{e(u(A,this,1),u(I,this,1))}catch(e){I.call(this,e)}},r=function(e){this._c=[],this._a=void 0,this._s=0,this._d=!1,this._v=void 0,this._h=0,this._n=!1},r.prototype=n(130)(T.prototype,{then:function(e,t){var n=k(m(this,T));return n.ok="function"!=typeof e||e,n.fail="function"==typeof t&&t,n.domain=w?E.domain:void 0,this._c.push(n),this._a&&this._a.push(n),this._s&&x(this,!1),n.promise},catch:function(e){return this.then(void 0,e)}}),o=function(){var e=new r;this.promise=e,this.resolve=u(A,e,1),this.reject=u(I,e,1)},C.f=k=function(e){return e===T||e===a?new o(e):i(e)}),f(f.G+f.W+f.F*!O,{Promise:T}),n(35)(T,"Promise"),n(131)("Promise"),a=n(2).Promise,f(f.S+f.F*!O,"Promise",{reject:function(e){var t=k(this);return(0,t.reject)(e),t.promise}}),f(f.S+f.F*(s||!O),"Promise",{resolve:function(e){return _(s&&this===a?T:this,e)}}),f(f.S+f.F*!(O&&n(71)(function(e){T.all(e).catch(P)})),"Promise",{all:function(e){var t=this,n=k(t),r=n.resolve,i=n.reject,o=b(function(){var n=[],o=0,a=1;v(e,!1,function(e){var s=o++,c=!1;n.push(void 0),a++,t.resolve(e).then(function(e){c||(c=!0,n[s]=e,--a||r(n))},i)}),--a||r(n)});return o.e&&i(o.v),n.promise},race:function(e){var t=this,n=k(t),r=n.reject,i=b(function(){v(e,!1,function(e){t.resolve(e).then(n.resolve,r)})});return i.e&&r(i.v),n.promise}})},function(e,t,n){"use strict";var r=n(3),i=n(15),o=n(13),a=n(10),s=n(79),c=n(124).KEY,u=n(21),d=n(46),f=n(35),l=n(37),p=n(4),h=n(51),v=n(50),m=n(118),g=n(121),y=n(12),C=n(17),b=n(18),_=n(49),S=n(26),E=n(72),T=n(128),w=n(73),P=n(11),k=n(25),O=w.f,R=P.f,x=T.f,D=r.Symbol,M=r.JSON,j=M&&M.stringify,I=p("_hidden"),A=p("toPrimitive"),N={}.propertyIsEnumerable,L=d("symbol-registry"),U=d("symbols"),G=d("op-symbols"),F=Object.prototype,V="function"==typeof D,H=r.QObject,B=!H||!H.prototype||!H.prototype.findChild,J=o&&u(function(){return 7!=E(R({},"a",{get:function(){return R(this,"a",{value:7}).a}})).a})?function(e,t,n){var r=O(F,t);r&&delete F[t],R(e,t,n),r&&e!==F&&R(F,t,r)}:R,W=function(e){var t=U[e]=E(D.prototype);return t._k=e,t},z=V&&"symbol"==typeof D.iterator?function(e){return"symbol"==typeof e}:function(e){return e instanceof D},$=function(e,t,n){return e===F&&$(G,t,n),y(e),t=_(t,!0),y(n),i(U,t)?(n.enumerable?(i(e,I)&&e[I][t]&&(e[I][t]=!1),n=E(n,{enumerable:S(0,!1)})):(i(e,I)||R(e,I,S(1,{})),e[I][t]=!0),J(e,t,n)):R(e,t,n)},K=function(e,t){y(e);for(var n,r=m(t=b(t)),i=0,o=r.length;o>i;)$(e,n=r[i++],t[n]);return e},q=function(e,t){return void 0===t?E(e):K(E(e),t)},Z=function(e){var t=N.call(this,e=_(e,!0));return!(this===F&&i(U,e)&&!i(G,e))&&(!(t||!i(this,e)||!i(U,e)||i(this,I)&&this[I][e])||t)},Y=function(e,t){if(e=b(e),t=_(t,!0),e!==F||!i(U,t)||i(G,t)){var n=O(e,t);return!n||!i(U,t)||i(e,I)&&e[I][t]||(n.enumerable=!0),n}},Q=function(e){for(var t,n=x(b(e)),r=[],o=0;n.length>o;)i(U,t=n[o++])||t==I||t==c||r.push(t);return r},X=function(e){for(var t,n=e===F,r=x(n?G:b(e)),o=[],a=0;r.length>a;)!i(U,t=r[a++])||n&&!i(F,t)||o.push(U[t]);return o};V||(D=function(){if(this instanceof D)throw TypeError("Symbol is not a constructor!");var e=l(arguments.length>0?arguments[0]:void 0),t=function(n){this===F&&t.call(G,n),i(this,I)&&i(this[I],e)&&(this[I][e]=!1),J(this,e,S(1,n))};return o&&B&&J(F,e,{configurable:!0,set:t}),W(e)},s(D.prototype,"toString",function(){return this._k}),w.f=Y,P.f=$,n(74).f=T.f=Q,n(34).f=Z,n(44).f=X,o&&!n(33)&&s(F,"propertyIsEnumerable",Z,!0),h.f=function(e){return W(p(e))}),a(a.G+a.W+a.F*!V,{Symbol:D});for(var ee="hasInstance,isConcatSpreadable,iterator,match,replace,search,species,split,toPrimitive,toStringTag,unscopables".split(","),te=0;ee.length>te;)p(ee[te++]);for(var ne=k(p.store),re=0;ne.length>re;)v(ne[re++]);a(a.S+a.F*!V,"Symbol",{for:function(e){return i(L,e+="")?L[e]:L[e]=D(e)},keyFor:function(e){if(!z(e))throw TypeError(e+" is not a symbol!");for(var t in L)if(L[t]===e)return t},useSetter:function(){B=!0},useSimple:function(){B=!1}}),a(a.S+a.F*!V,"Object",{create:q,defineProperty:$,defineProperties:K,getOwnPropertyDescriptor:Y,getOwnPropertyNames:Q,getOwnPropertySymbols:X}),M&&a(a.S+a.F*(!V||u(function(){var e=D();return"[null]"!=j([e])||"{}"!=j({a:e})||"{}"!=j(Object(e))})),"JSON",{stringify:function(e){for(var t,n,r=[e],i=1;arguments.length>i;)r.push(arguments[i++]);if(n=t=r[1],(C(t)||void 0!==e)&&!z(e))return g(t)||(t=function(e,t){if("function"==typeof n&&(t=n.call(this,e,t)),!z(t))return t}),r[1]=t,j.apply(M,r)}}),D.prototype[A]||n(16)(D.prototype,A,D.prototype.valueOf),f(D,"Symbol"),f(Math,"Math",!0),f(r.JSON,"JSON",!0)},function(e,t,n){"use strict";var r=n(10),i=n(2),o=n(3),a=n(80),s=n(78);r(r.P+r.R,"Promise",{finally:function(e){var t=a(this,i.Promise||o.Promise),n="function"==typeof e;return this.then(n?function(n){return s(t,e()).then(function(){return n})}:e,n?function(n){return s(t,e()).then(function(){throw n})}:e)}})},function(e,t,n){"use strict";var r=n(10),i=n(43),o=n(77);r(r.S,"Promise",{try:function(e){var t=i.f(this),n=o(e);return(n.e?t.reject:t.resolve)(n.v),t.promise}})},function(e,t,n){n(50)("asyncIterator")},function(e,t,n){n(50)("observable")},function(e,t,n){n(168),e.exports=n(53).Array.find},function(e,t){e.exports=function(e){if("function"!=typeof e)throw TypeError(e+" is not a function!");return e}},function(e,t,n){var r=n(89)("unscopables"),i=Array.prototype;void 0==i[r]&&n(55)(i,r,{}),e.exports=function(e){i[r][e]=!0}},function(e,t,n){var r=n(38);e.exports=function(e){if(!r(e))throw TypeError(e+" is not an object!");return e}},function(e,t,n){var r=n(86),i=n(158),o=n(166),a=n(165),s=n(152);e.exports=function(e,t){var n=1==e,c=2==e,u=3==e,d=4==e,f=6==e,l=5==e||f,p=t||s;return function(t,s,h){for(var v,m,g=o(t),y=i(g),C=r(s,h,3),b=a(y.length),_=0,S=n?p(t,b):c?p(t,0):void 0;b>_;_++)if((l||_ in y)&&(v=y[_],m=C(v,_,g),e))if(n)S[_]=m;else if(m)switch(e){case 3:return!0;case 5:return v;case 6:return _;case 2:S.push(v)}else if(d)return!1;return f?-1:u||d?d:S}}},function(e,t,n){var r=n(38),i=n(159),o=n(89)("species");e.exports=function(e){var t;return i(e)&&(t=e.constructor,"function"!=typeof t||t!==Array&&!i(t.prototype)||(t=void 0),r(t)&&null===(t=t[o])&&(t=void 0)),void 0===t?Array:t}},function(e,t,n){var r=n(151);e.exports=function(e,t){return new(r(e))(t)}},function(e,t){e.exports=function(e){if(void 0==e)throw TypeError("Can't call method on "+e);return e}},function(e,t,n){var r=n(38),i=n(27).document,o=r(i)&&r(i.createElement);e.exports=function(e){return o?i.createElement(e):{}}},function(e,t,n){var r=n(27),i=n(53),o=n(55),a=n(162),s=n(86),c=function(e,t,n){var u,d,f,l,p=e&c.F,h=e&c.G,v=e&c.S,m=e&c.P,g=e&c.B,y=h?r:v?r[t]||(r[t]={}):(r[t]||{}).prototype,C=h?i:i[t]||(i[t]={}),b=C.prototype||(C.prototype={});h&&(n=t);for(u in n)d=!p&&y&&void 0!==y[u],f=(d?y:n)[u],l=g&&d?s(f,r):m&&"function"==typeof f?s(Function.call,f):f,y&&a(y,u,f,e&c.U),C[u]!=f&&o(C,u,l),m&&b[u]!=f&&(b[u]=f)};r.core=i,c.F=1,c.G=2,c.S=4,c.P=8,c.B=16,c.W=32,c.U=64,c.R=128,e.exports=c},function(e,t){var n={}.hasOwnProperty;e.exports=function(e,t){return n.call(e,t)}},function(e,t,n){e.exports=!n(54)&&!n(87)(function(){return 7!=Object.defineProperty(n(154)("div"),"a",{get:function(){return 7}}).a})},function(e,t,n){var r=n(85);e.exports=Object("z").propertyIsEnumerable(0)?Object:function(e){return"String"==r(e)?e.split(""):Object(e)}},function(e,t,n){var r=n(85);e.exports=Array.isArray||function(e){return"Array"==r(e)}},function(e,t,n){var r=n(149),i=n(157),o=n(167),a=Object.defineProperty;t.f=n(54)?Object.defineProperty:function(e,t,n){if(r(e),t=o(t,!0),r(n),i)try{return a(e,t,n)}catch(e){}if("get"in n||"set"in n)throw TypeError("Accessors not supported!");return"value"in n&&(e[t]=n.value),e}},function(e,t){e.exports=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}}},function(e,t,n){var r=n(27),i=n(55),o=n(156),a=n(88)("src"),s=Function.toString,c=(""+s).split("toString");n(53).inspectSource=function(e){return s.call(e)},(e.exports=function(e,t,n,s){var u="function"==typeof n;u&&(o(n,"name")||i(n,"name",t)),e[t]!==n&&(u&&(o(n,a)||i(n,a,e[t]?""+e[t]:c.join(String(t)))),e===r?e[t]=n:s?e[t]?e[t]=n:i(e,t,n):(delete e[t],i(e,t,n)))})(Function.prototype,"toString",function(){return"function"==typeof this&&this[a]||s.call(this)})},function(e,t,n){var r=n(27),i=r["__core-js_shared__"]||(r["__core-js_shared__"]={});e.exports=function(e){return i[e]||(i[e]={})}},function(e,t){var n=Math.ceil,r=Math.floor;e.exports=function(e){return isNaN(e=+e)?0:(e>0?r:n)(e)}},function(e,t,n){var r=n(164),i=Math.min;e.exports=function(e){return e>0?i(r(e),9007199254740991):0}},function(e,t,n){var r=n(153);e.exports=function(e){return Object(r(e))}},function(e,t,n){var r=n(38);e.exports=function(e,t){if(!r(e))return e;var n,i;if(t&&"function"==typeof(n=e.toString)&&!r(i=n.call(e)))return i;if("function"==typeof(n=e.valueOf)&&!r(i=n.call(e)))return i;if(!t&&"function"==typeof(n=e.toString)&&!r(i=n.call(e)))return i;throw TypeError("Can't convert object to primitive value")}},function(e,t,n){"use strict";var r=n(155),i=n(150)(5),o=!0;"find"in[]&&Array(1).find(function(){o=!1}),r(r.P+r.F*o,"Array",{find:function(e){return i(this,e,arguments.length>1?arguments[1]:void 0)}}),n(148)("find")},function(e,t,n){"use strict";var r={};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){return e.split("\nm=").map(function(e,t){return(t>0?"m="+e:e).trim()+"\r\n"})},r.matchPrefix=function(e,t){return r.splitLines(e).filter(function(e){return 0===e.indexOf(t)})},r.parseCandidate=function(e){var t;t=0===e.indexOf("a=candidate:")?e.substring(12).split(" "):e.substring(10).split(" ");for(var n={foundation:t[0],component:parseInt(t[1],10),protocol:t[2].toLowerCase(),priority:parseInt(t[3],10),ip:t[4],port:parseInt(t[5],10),type:t[7]},r=8;r<t.length;r+=2)switch(t[r]){case"raddr":n.relatedAddress=t[r+1];break;case"rport":n.relatedPort=parseInt(t[r+1],10);break;case"tcptype":n.tcpType=t[r+1];break;case"ufrag":n.ufrag=t[r+1],n.usernameFragment=t[r+1];break;default:n[t[r]]=t[r+1]}return n},r.writeCandidate=function(e){var t=[];t.push(e.foundation),t.push(e.component),t.push(e.protocol.toUpperCase()),t.push(e.priority),t.push(e.ip),t.push(e.port);var n=e.type;return t.push("typ"),t.push(n),"host"!==n&&e.relatedAddress&&e.relatedPort&&(t.push("raddr"),t.push(e.relatedAddress),t.push("rport"),t.push(e.relatedPort)),e.tcpType&&"tcp"===e.protocol.toLowerCase()&&(t.push("tcptype"),t.push(e.tcpType)),e.ufrag&&(t.push("ufrag"),t.push(e.ufrag)),"candidate:"+t.join(" ")},r.parseIceOptions=function(e){return e.substr(14).split(" ")},r.parseRtpMap=function(e){var t=e.substr(9).split(" "),n={payloadType:parseInt(t.shift(),10)};return t=t[0].split("/"),n.name=t[0],n.clockRate=parseInt(t[1],10),n.numChannels=3===t.length?parseInt(t[2],10):1,n},r.writeRtpMap=function(e){var t=e.payloadType;return void 0!==e.preferredPayloadType&&(t=e.preferredPayloadType),"a=rtpmap:"+t+" "+e.name+"/"+e.clockRate+(1!==e.numChannels?"/"+e.numChannels:"")+"\r\n"},r.parseExtmap=function(e){var t=e.substr(9).split(" ");return{id:parseInt(t[0],10),direction:t[0].indexOf("/")>0?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,n={},r=e.substr(e.indexOf(" ")+1).split(";"),i=0;i<r.length;i++)t=r[i].trim().split("="),n[t[0].trim()]=t[1];return n},r.writeFmtp=function(e){var t="",n=e.payloadType;if(void 0!==e.preferredPayloadType&&(n=e.preferredPayloadType),e.parameters&&Object.keys(e.parameters).length){var r=[];Object.keys(e.parameters).forEach(function(t){r.push(t+"="+e.parameters[t])}),t+="a=fmtp:"+n+" "+r.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="",n=e.payloadType;return void 0!==e.preferredPayloadType&&(n=e.preferredPayloadType),e.rtcpFeedback&&e.rtcpFeedback.length&&e.rtcpFeedback.forEach(function(e){t+="a=rtcp-fb:"+n+" "+e.type+(e.parameter&&e.parameter.length?" "+e.parameter:"")+"\r\n"}),t},r.parseSsrcMedia=function(e){var t=e.indexOf(" "),n={ssrc:parseInt(e.substr(7,t-7),10)},r=e.indexOf(":",t);return r>-1?(n.attribute=e.substr(t+1,r-t-1),n.value=e.substr(r+1)):n.attribute=e.substr(t+1),n},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){return{role:"auto",fingerprints:r.matchPrefix(e+t,"a=fingerprint:").map(r.parseFingerprint)}},r.writeDtlsParameters=function(e,t){var n="a=setup:"+t+"\r\n";return e.fingerprints.forEach(function(e){n+="a=fingerprint:"+e.algorithm+" "+e.value+"\r\n"}),n},r.getIceParameters=function(e,t){var n=r.splitLines(e);return n=n.concat(r.splitLines(t)),{usernameFragment:n.filter(function(e){return 0===e.indexOf("a=ice-ufrag:")})[0].substr(12),password:n.filter(function(e){return 0===e.indexOf("a=ice-pwd:")})[0].substr(10)}},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:[]},n=r.splitLines(e),i=n[0].split(" "),o=3;o<i.length;o++){var a=i[o],s=r.matchPrefix(e,"a=rtpmap:"+a+" ")[0];if(s){var c=r.parseRtpMap(s),u=r.matchPrefix(e,"a=fmtp:"+a+" ");switch(c.parameters=u.length?r.parseFmtp(u[0]):{},c.rtcpFeedback=r.matchPrefix(e,"a=rtcp-fb:"+a+" ").map(r.parseRtcpFb),t.codecs.push(c),c.name.toUpperCase()){case"RED":case"ULPFEC":t.fecMechanisms.push(c.name.toUpperCase())}}}return r.matchPrefix(e,"a=extmap:").forEach(function(e){t.headerExtensions.push(r.parseExtmap(e))}),t},r.writeRtpDescription=function(e,t){var n="";n+="m="+e+" ",n+=t.codecs.length>0?"9":"0",n+=" UDP/TLS/RTP/SAVPF ",n+=t.codecs.map(function(e){return void 0!==e.preferredPayloadType?e.preferredPayloadType:e.payloadType}).join(" ")+"\r\n",n+="c=IN IP4 0.0.0.0\r\n",n+="a=rtcp:9 IN IP4 0.0.0.0\r\n",t.codecs.forEach(function(e){n+=r.writeRtpMap(e),n+=r.writeFmtp(e),n+=r.writeRtcpFb(e)});var i=0;return t.codecs.forEach(function(e){e.maxptime>i&&(i=e.maxptime)}),i>0&&(n+="a=maxptime:"+i+"\r\n"),n+="a=rtcp-mux\r\n",t.headerExtensions.forEach(function(e){n+=r.writeExtmap(e)}),n},r.parseRtpEncodingParameters=function(e){var t,n=[],i=r.parseRtpParameters(e),o=-1!==i.fecMechanisms.indexOf("RED"),a=-1!==i.fecMechanisms.indexOf("ULPFEC"),s=r.matchPrefix(e,"a=ssrc:").map(function(e){return r.parseSsrcMedia(e)}).filter(function(e){return"cname"===e.attribute}),c=s.length>0&&s[0].ssrc,u=r.matchPrefix(e,"a=ssrc-group:FID").map(function(e){var t=e.split(" ");return t.shift(),t.map(function(e){return parseInt(e,10)})});u.length>0&&u[0].length>1&&u[0][0]===c&&(t=u[0][1]),i.codecs.forEach(function(e){if("RTX"===e.name.toUpperCase()&&e.parameters.apt){var r={ssrc:c,codecPayloadType:parseInt(e.parameters.apt,10),rtx:{ssrc:t}};n.push(r),o&&(r=JSON.parse(JSON.stringify(r)),r.fec={ssrc:t,mechanism:a?"red+ulpfec":"red"},n.push(r))}}),0===n.length&&c&&n.push({ssrc:c});var d=r.matchPrefix(e,"b=");return d.length&&(d=0===d[0].indexOf("b=TIAS:")?parseInt(d[0].substr(7),10):0===d[0].indexOf("b=AS:")?1e3*parseInt(d[0].substr(5),10)*.95-16e3:void 0,n.forEach(function(e){e.maxBitrate=d})),n},r.parseRtcpParameters=function(e){var t={},n=r.matchPrefix(e,"a=ssrc:").map(function(e){return r.parseSsrcMedia(e)}).filter(function(e){return"cname"===e.attribute})[0];n&&(t.cname=n.value,t.ssrc=n.ssrc);var i=r.matchPrefix(e,"a=rtcp-rsize");t.reducedSize=i.length>0,t.compound=0===i.length;var o=r.matchPrefix(e,"a=rtcp-mux");return t.mux=o.length>0,t},r.parseMsid=function(e){var t,n=r.matchPrefix(e,"a=msid:");if(1===n.length)return t=n[0].substr(7).split(" "),{stream:t[0],track:t[1]};var i=r.matchPrefix(e,"a=ssrc:").map(function(e){return r.parseSsrcMedia(e)}).filter(function(e){return"msid"===e.attribute});return i.length>0?(t=i[0].value.split(" "),{stream:t[0],track:t[1]}):void 0},r.generateSessionId=function(){return Math.random().toString().substr(2,21)},r.writeSessionBoilerplate=function(e,t){var n=void 0!==t?t:2;return"v=0\r\no=thisisadapterortc "+(e||r.generateSessionId())+" "+n+" IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\n"},r.writeMediaSection=function(e,t,n,i){var o=r.writeRtpDescription(e.kind,t);if(o+=r.writeIceParameters(e.iceGatherer.getLocalParameters()),o+=r.writeDtlsParameters(e.dtlsTransport.getLocalParameters(),"offer"===n?"actpass":"active"),o+="a=mid:"+e.mid+"\r\n",e.direction?o+="a="+e.direction+"\r\n":e.rtpSender&&e.rtpReceiver?o+="a=sendrecv\r\n":e.rtpSender?o+="a=sendonly\r\n":e.rtpReceiver?o+="a=recvonly\r\n":o+="a=inactive\r\n",e.rtpSender){var a="msid:"+i.id+" "+e.rtpSender.track.id+"\r\n";o+="a="+a,o+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" "+a,e.sendEncodingParameters[0].rtx&&(o+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" "+a,o+="a=ssrc-group:FID "+e.sendEncodingParameters[0].ssrc+" "+e.sendEncodingParameters[0].rtx.ssrc+"\r\n")}return o+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" cname:"+r.localCName+"\r\n",e.rtpSender&&e.sendEncodingParameters[0].rtx&&(o+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" cname:"+r.localCName+"\r\n"),o},r.getDirection=function(e,t){for(var n=r.splitLines(e),i=0;i<n.length;i++)switch(n[i]){case"a=sendrecv":case"a=sendonly":case"a=recvonly":case"a=inactive":return n[i].substr(2)}return t?r.getDirection(t):"sendrecv"},r.getKind=function(e){return r.splitLines(e)[0].split(" ")[0].substr(2)},r.isRejected=function(e){return"0"===e.split(" ",2)[1]},r.parseMLine=function(e){var t=r.splitLines(e),n=t[0].split(" ");return{kind:n[0].substr(2),port:parseInt(n[1],10),protocol:n[2],fmt:n.slice(3).join(" ")}},e.exports=r},function(e,t,n){"use strict";(function(t){var r=n(171);e.exports=r({window:t.window})}).call(t,n(90))},function(e,t,n){"use strict";e.exports=function(e,t){var r=e&&e.window,i={shimChrome:!0,shimFirefox:!0,shimEdge:!0,shimSafari:!0};for(var o in t)hasOwnProperty.call(t,o)&&(i[o]=t[o]);var a=n(19),s=a.log,c=a.detectBrowser(r),u={browserDetails:c,extractVersion:a.extractVersion,disableLog:a.disableLog,disableWarnings:a.disableWarnings},d=n(172)||null,f=n(174)||null,l=n(177)||null,p=n(179)||null;switch(c.browser){case"chrome":if(!d||!d.shimPeerConnection||!i.shimChrome)return s("Chrome shim is not included in this adapter release."),u;s("adapter.js shimming chrome."),u.browserShim=d,d.shimGetUserMedia(r),d.shimMediaStream(r),a.shimCreateObjectURL(r),d.shimSourceObject(r),d.shimPeerConnection(r),d.shimOnTrack(r),d.shimAddTrackRemoveTrack(r),d.shimGetSendersWithDtmf(r);break;case"firefox":if(!l||!l.shimPeerConnection||!i.shimFirefox)return s("Firefox shim is not included in this adapter release."),u;s("adapter.js shimming firefox."),u.browserShim=l,l.shimGetUserMedia(r),a.shimCreateObjectURL(r),l.shimSourceObject(r),l.shimPeerConnection(r),l.shimOnTrack(r);break;case"edge":if(!f||!f.shimPeerConnection||!i.shimEdge)return s("MS edge shim is not included in this adapter release."),u;s("adapter.js shimming edge."),u.browserShim=f,f.shimGetUserMedia(r),a.shimCreateObjectURL(r),f.shimPeerConnection(r),f.shimReplaceTrack(r);break;case"safari":if(!p||!i.shimSafari)return s("Safari shim is not included in this adapter release."),u;s("adapter.js shimming safari."),u.browserShim=p,a.shimCreateObjectURL(r),p.shimRTCIceServerUrls(r),p.shimCallbacksAPI(r),p.shimLocalStreamsAPI(r),p.shimRemoteStreamsAPI(r),p.shimGetUserMedia(r);break;default:s("Unsupported browser!")}return u}},function(e,t,n){"use strict";var r=n(19),i=r.log,o={shimMediaStream:function(e){e.MediaStream=e.MediaStream||e.webkitMediaStream},shimOnTrack:function(e){if("object"==typeof e&&e.RTCPeerConnection&&!("ontrack"in e.RTCPeerConnection.prototype)){Object.defineProperty(e.RTCPeerConnection.prototype,"ontrack",{get:function(){return this._ontrack},set:function(e){this._ontrack&&this.removeEventListener("track",this._ontrack),this.addEventListener("track",this._ontrack=e)}});var t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){var n=this;return n._ontrackpoly||(n._ontrackpoly=function(t){t.stream.addEventListener("addtrack",function(r){var i;i=e.RTCPeerConnection.prototype.getReceivers?n.getReceivers().find(function(e){return e.track&&e.track.id===r.track.id}):{track:r.track};var o=new Event("track");o.track=r.track,o.receiver=i,o.streams=[t.stream],n.dispatchEvent(o)}),t.stream.getTracks().forEach(function(r){var i;i=e.RTCPeerConnection.prototype.getReceivers?n.getReceivers().find(function(e){return e.track&&e.track.id===r.id}):{track:r};var o=new Event("track");o.track=r,o.receiver=i,o.streams=[t.stream],n.dispatchEvent(o)})},n.addEventListener("addstream",n._ontrackpoly)),t.apply(n,arguments)}}},shimGetSendersWithDtmf:function(e){if("object"==typeof e&&e.RTCPeerConnection&&!("getSenders"in e.RTCPeerConnection.prototype)&&"createDTMFSender"in e.RTCPeerConnection.prototype){var t=function(e,t){return{track:t,get dtmf(){return void 0===this._dtmf&&("audio"===t.kind?this._dtmf=e.createDTMFSender(t):this._dtmf=null),this._dtmf},_pc:e}};if(!e.RTCPeerConnection.prototype.getSenders){e.RTCPeerConnection.prototype.getSenders=function(){return this._senders=this._senders||[],this._senders.slice()};var n=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,r){var i=this,o=n.apply(i,arguments);return o||(o=t(i,e),i._senders.push(o)),o};var r=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){var t=this;r.apply(t,arguments);var n=t._senders.indexOf(e);-1!==n&&t._senders.splice(n,1)}}var i=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){var n=this;n._senders=n._senders||[],i.apply(n,[e]),e.getTracks().forEach(function(e){n._senders.push(t(n,e))})};var o=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){var t=this;t._senders=t._senders||[],o.apply(t,[t._streams[e.id]||e]),e.getTracks().forEach(function(e){var n=t._senders.find(function(t){return t.track===e});n&&t._senders.splice(t._senders.indexOf(n),1)})}}else if("object"==typeof e&&e.RTCPeerConnection&&"getSenders"in e.RTCPeerConnection.prototype&&"createDTMFSender"in e.RTCPeerConnection.prototype&&e.RTCRtpSender&&!("dtmf"in e.RTCRtpSender.prototype)){var a=e.RTCPeerConnection.prototype.getSenders;e.RTCPeerConnection.prototype.getSenders=function(){var e=this,t=a.apply(e,[]);return t.forEach(function(t){t._pc=e}),t},Object.defineProperty(e.RTCRtpSender.prototype,"dtmf",{get:function(){return void 0===this._dtmf&&("audio"===this.track.kind?this._dtmf=this._pc.createDTMFSender(this.track):this._dtmf=null),this._dtmf}})}},shimSourceObject:function(e){var t=e&&e.URL;"object"==typeof e&&(!e.HTMLMediaElement||"srcObject"in e.HTMLMediaElement.prototype||Object.defineProperty(e.HTMLMediaElement.prototype,"srcObject",{get:function(){return this._srcObject},set:function(e){var n=this;if(this._srcObject=e,this.src&&t.revokeObjectURL(this.src),!e)return void(this.src="");this.src=t.createObjectURL(e),e.addEventListener("addtrack",function(){n.src&&t.revokeObjectURL(n.src),n.src=t.createObjectURL(e)}),e.addEventListener("removetrack",function(){n.src&&t.revokeObjectURL(n.src),n.src=t.createObjectURL(e)})}}))},shimAddTrackRemoveTrack:function(e){if(!e.RTCPeerConnection.prototype.addTrack){var t=e.RTCPeerConnection.prototype.getLocalStreams;e.RTCPeerConnection.prototype.getLocalStreams=function(){var e=this,n=t.apply(this);return e._reverseStreams=e._reverseStreams||{},n.map(function(t){return e._reverseStreams[t.id]})};var n=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(t){var r=this;if(r._streams=r._streams||{},r._reverseStreams=r._reverseStreams||{},t.getTracks().forEach(function(e){if(r.getSenders().find(function(t){return t.track===e}))throw new DOMException("Track already exists.","InvalidAccessError")}),!r._reverseStreams[t.id]){var i=new e.MediaStream(t.getTracks());r._streams[t.id]=i,r._reverseStreams[i.id]=t,t=i}n.apply(r,[t])};var r=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){var t=this;t._streams=t._streams||{},t._reverseStreams=t._reverseStreams||{},r.apply(t,[t._streams[e.id]||e]),delete t._reverseStreams[t._streams[e.id]?t._streams[e.id].id:e.id],delete t._streams[e.id]},e.RTCPeerConnection.prototype.addTrack=function(t,n){var r=this;if("closed"===r.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===t}))throw new DOMException("The adapter.js addTrack polyfill only supports a single stream which is associated with the specified track.","NotSupportedError");if(r.getSenders().find(function(e){return e.track===t}))throw new DOMException("Track already exists.","InvalidAccessError");r._streams=r._streams||{},r._reverseStreams=r._reverseStreams||{};var o=r._streams[n.id];if(o)o.addTrack(t),r.dispatchEvent(new Event("negotiationneeded"));else{var a=new e.MediaStream([t]);r._streams[n.id]=a,r._reverseStreams[a.id]=n,r.addStream(a)}return r.getSenders().find(function(e){return e.track===t})},e.RTCPeerConnection.prototype.removeTrack=function(e){var t=this;if("closed"===t.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");if(!e._pc)throw new DOMException("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.","TypeError");if(e._pc!==t)throw new DOMException("Sender was not created by this connection.","InvalidAccessError");t._streams=t._streams||{};var n;Object.keys(t._streams).forEach(function(r){t._streams[r].getTracks().find(function(t){return e.track===t})&&(n=t._streams[r])}),n&&(1===n.getTracks().length?t.removeStream(n):n.removeTrack(e.track),t.dispatchEvent(new Event("negotiationneeded")))}}},shimPeerConnection:function(e){var t=r.detectBrowser(e);if(e.RTCPeerConnection){var n=e.RTCPeerConnection;e.RTCPeerConnection=function(e,t){if(e&&e.iceServers){for(var i=[],o=0;o<e.iceServers.length;o++){var a=e.iceServers[o];!a.hasOwnProperty("urls")&&a.hasOwnProperty("url")?(r.deprecated("RTCIceServer.url","RTCIceServer.urls"),a=JSON.parse(JSON.stringify(a)),a.urls=a.url,i.push(a)):i.push(e.iceServers[o])}e.iceServers=i}return new n(e,t)},e.RTCPeerConnection.prototype=n.prototype,Object.defineProperty(e.RTCPeerConnection,"generateCertificate",{get:function(){return n.generateCertificate}})}else e.RTCPeerConnection=function(t,n){return i("PeerConnection"),t&&t.iceTransportPolicy&&(t.iceTransports=t.iceTransportPolicy),new e.webkitRTCPeerConnection(t,n)},e.RTCPeerConnection.prototype=e.webkitRTCPeerConnection.prototype,e.webkitRTCPeerConnection.generateCertificate&&Object.defineProperty(e.RTCPeerConnection,"generateCertificate",{get:function(){return e.webkitRTCPeerConnection.generateCertificate}});var o=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(e,t,n){var r=this,i=arguments;if(arguments.length>0&&"function"==typeof e)return o.apply(this,arguments);if(0===o.length&&(0===arguments.length||"function"!=typeof arguments[0]))return o.apply(this,[]);var a=function(e){var t={};return e.result().forEach(function(e){var n={id:e.id,timestamp:e.timestamp,type:{localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[e.type]||e.type};e.names().forEach(function(t){n[t]=e.stat(t)}),t[n.id]=n}),t},s=function(e){return new Map(Object.keys(e).map(function(t){return[t,e[t]]}))};if(arguments.length>=2){var c=function(e){i[1](s(a(e)))};return o.apply(this,[c,arguments[0]])}return new Promise(function(e,t){o.apply(r,[function(t){e(s(a(t)))},t])}).then(t,n)},t.version<51&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(t){var n=e.RTCPeerConnection.prototype[t];e.RTCPeerConnection.prototype[t]=function(){var e=arguments,t=this,r=new Promise(function(r,i){n.apply(t,[e[0],r,i])});return e.length<2?r:r.then(function(){e[1].apply(null,[])},function(t){e.length>=3&&e[2].apply(null,[t])})}}),t.version<52&&["createOffer","createAnswer"].forEach(function(t){var n=e.RTCPeerConnection.prototype[t];e.RTCPeerConnection.prototype[t]=function(){var e=this;if(arguments.length<1||1===arguments.length&&"object"==typeof arguments[0]){var t=1===arguments.length?arguments[0]:void 0;return new Promise(function(r,i){n.apply(e,[r,i,t])})}return n.apply(this,arguments)}}),["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(t){var n=e.RTCPeerConnection.prototype[t];e.RTCPeerConnection.prototype[t]=function(){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),n.apply(this,arguments)}});var a=e.RTCPeerConnection.prototype.addIceCandidate;e.RTCPeerConnection.prototype.addIceCandidate=function(){return arguments[0]?a.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())}}};e.exports={shimMediaStream:o.shimMediaStream,shimOnTrack:o.shimOnTrack,shimAddTrackRemoveTrack:o.shimAddTrackRemoveTrack,shimGetSendersWithDtmf:o.shimGetSendersWithDtmf,shimSourceObject:o.shimSourceObject,shimPeerConnection:o.shimPeerConnection,shimGetUserMedia:n(173)}},function(e,t,n){"use strict";var r=n(19),i=r.log;e.exports=function(e){var t=r.detectBrowser(e),n=e&&e.navigator,o=function(e){if("object"!=typeof e||e.mandatory||e.optional)return e;var t={};return Object.keys(e).forEach(function(n){if("require"!==n&&"advanced"!==n&&"mediaSource"!==n){var r="object"==typeof e[n]?e[n]:{ideal:e[n]};void 0!==r.exact&&"number"==typeof r.exact&&(r.min=r.max=r.exact);var i=function(e,t){return e?e+t.charAt(0).toUpperCase()+t.slice(1):"deviceId"===t?"sourceId":t};if(void 0!==r.ideal){t.optional=t.optional||[];var o={};"number"==typeof r.ideal?(o[i("min",n)]=r.ideal,t.optional.push(o),o={},o[i("max",n)]=r.ideal,t.optional.push(o)):(o[i("",n)]=r.ideal,t.optional.push(o))}void 0!==r.exact&&"number"!=typeof r.exact?(t.mandatory=t.mandatory||{},t.mandatory[i("",n)]=r.exact):["min","max"].forEach(function(e){void 0!==r[e]&&(t.mandatory=t.mandatory||{},t.mandatory[i(e,n)]=r[e])})}}),e.advanced&&(t.optional=(t.optional||[]).concat(e.advanced)),t},a=function(e,r){if((e=JSON.parse(JSON.stringify(e)))&&"object"==typeof e.audio){var a=function(e,t,n){t in e&&!(n in e)&&(e[n]=e[t],delete e[t])};e=JSON.parse(JSON.stringify(e)),a(e.audio,"autoGainControl","googAutoGainControl"),a(e.audio,"noiseSuppression","googNoiseSuppression"),e.audio=o(e.audio)}if(e&&"object"==typeof e.video){var s=e.video.facingMode;s=s&&("object"==typeof s?s:{ideal:s});var c=t.version<61;if(s&&("user"===s.exact||"environment"===s.exact||"user"===s.ideal||"environment"===s.ideal)&&(!n.mediaDevices.getSupportedConstraints||!n.mediaDevices.getSupportedConstraints().facingMode||c)){delete e.video.facingMode;var u;if("environment"===s.exact||"environment"===s.ideal?u=["back","rear"]:"user"!==s.exact&&"user"!==s.ideal||(u=["front"]),u)return n.mediaDevices.enumerateDevices().then(function(t){t=t.filter(function(e){return"videoinput"===e.kind});var n=t.find(function(e){return u.some(function(t){return-1!==e.label.toLowerCase().indexOf(t)})});return!n&&t.length&&-1!==u.indexOf("back")&&(n=t[t.length-1]),n&&(e.video.deviceId=s.exact?{exact:n.deviceId}:{ideal:n.deviceId}),e.video=o(e.video),i("chrome: "+JSON.stringify(e)),r(e)})}e.video=o(e.video)}return i("chrome: "+JSON.stringify(e)),r(e)},s=function(e){return{name:{PermissionDeniedError:"NotAllowedError",InvalidStateError:"NotReadableError",DevicesNotFoundError:"NotFoundError",ConstraintNotSatisfiedError:"OverconstrainedError",TrackStartError:"NotReadableError",MediaDeviceFailedDueToShutdown:"NotReadableError",MediaDeviceKillSwitchOn:"NotReadableError"}[e.name]||e.name,message:e.message,constraint:e.constraintName,toString:function(){return this.name+(this.message&&": ")+this.message}}},c=function(e,t,r){a(e,function(e){n.webkitGetUserMedia(e,t,function(e){r(s(e))})})};n.getUserMedia=c;var u=function(e){return new Promise(function(t,r){n.getUserMedia(e,t,r)})};if(n.mediaDevices||(n.mediaDevices={getUserMedia:u,enumerateDevices:function(){return new Promise(function(t){var n={audio:"audioinput",video:"videoinput"};return e.MediaStreamTrack.getSources(function(e){t(e.map(function(e){return{label:e.label,kind:n[e.kind],deviceId:e.id,groupId:""}}))})})},getSupportedConstraints:function(){return{deviceId:!0,echoCancellation:!0,facingMode:!0,frameRate:!0,height:!0,width:!0}}}),n.mediaDevices.getUserMedia){var d=n.mediaDevices.getUserMedia.bind(n.mediaDevices);n.mediaDevices.getUserMedia=function(e){return a(e,function(e){return d(e).then(function(t){if(e.audio&&!t.getAudioTracks().length||e.video&&!t.getVideoTracks().length)throw t.getTracks().forEach(function(e){e.stop()}),new DOMException("","NotFoundError");return t},function(e){return Promise.reject(s(e))})})}}else n.mediaDevices.getUserMedia=function(e){return u(e)};void 0===n.mediaDevices.addEventListener&&(n.mediaDevices.addEventListener=function(){i("Dummy mediaDevices.addEventListener called.")}),void 0===n.mediaDevices.removeEventListener&&(n.mediaDevices.removeEventListener=function(){i("Dummy mediaDevices.removeEventListener called.")})}},function(e,t,n){"use strict";var r=n(19),i=n(176);e.exports={shimGetUserMedia:n(175),shimPeerConnection:function(e){var t=r.detectBrowser(e);if(e.RTCIceGatherer&&(e.RTCIceCandidate||(e.RTCIceCandidate=function(e){return e}),e.RTCSessionDescription||(e.RTCSessionDescription=function(e){return e}),t.version<15025)){var n=Object.getOwnPropertyDescriptor(e.MediaStreamTrack.prototype,"enabled");Object.defineProperty(e.MediaStreamTrack.prototype,"enabled",{set:function(e){n.set.call(this,e);var t=new Event("enabled");t.enabled=e,this.dispatchEvent(t)}})}!e.RTCRtpSender||"dtmf"in e.RTCRtpSender.prototype||Object.defineProperty(e.RTCRtpSender.prototype,"dtmf",{get:function(){return void 0===this._dtmf&&("audio"===this.track.kind?this._dtmf=new e.RTCDtmfSender(this):"video"===this.track.kind&&(this._dtmf=null)),this._dtmf}}),e.RTCPeerConnection=i(e,t.version)},shimReplaceTrack:function(e){!e.RTCRtpSender||"replaceTrack"in e.RTCRtpSender.prototype||(e.RTCRtpSender.prototype.replaceTrack=e.RTCRtpSender.prototype.setTrack)}}},function(e,t,n){"use strict";e.exports=function(e){var t=e&&e.navigator,n=function(e){return{name:{PermissionDeniedError:"NotAllowedError"}[e.name]||e.name,message:e.message,constraint:e.constraint,toString:function(){return this.name}}},r=t.mediaDevices.getUserMedia.bind(t.mediaDevices);t.mediaDevices.getUserMedia=function(e){return r(e).catch(function(e){return Promise.reject(n(e))})}}},function(e,t,n){"use strict";function r(e){var t=e.filter(function(e){return"audio"===e.kind}),n=e.filter(function(e){return"video"===e.kind});for(e=[];t.length||n.length;)t.length&&e.push(t.shift()),n.length&&e.push(n.shift());return e}function i(e,t){var n=!1;return e=JSON.parse(JSON.stringify(e)),e.filter(function(e){if(e&&(e.urls||e.url)){var r=e.urls||e.url;e.url&&!e.urls&&console.warn("RTCIceServer.url is deprecated! Use urls instead.");var i="string"==typeof r;return i&&(r=[r]),r=r.filter(function(e){return 0!==e.indexOf("turn:")||-1===e.indexOf("transport=udp")||-1!==e.indexOf("turn:[")||n?0===e.indexOf("stun:")&&t>=14393:(n=!0,!0)}),delete e.url,e.urls=i?r[0]:r,!!r.length}return!1})}function o(e,t){var n={codecs:[],headerExtensions:[],fecMechanisms:[]},r=function(e,t){e=parseInt(e,10);for(var n=0;n<t.length;n++)if(t[n].payloadType===e||t[n].preferredPayloadType===e)return t[n]},i=function(e,t,n,i){var o=r(e.parameters.apt,n),a=r(t.parameters.apt,i);return o&&a&&o.name.toLowerCase()===a.name.toLowerCase()};return e.codecs.forEach(function(r){for(var o=0;o<t.codecs.length;o++){var a=t.codecs[o];if(r.name.toLowerCase()===a.name.toLowerCase()&&r.clockRate===a.clockRate){if("rtx"===r.name.toLowerCase()&&r.parameters&&a.parameters.apt&&!i(r,a,e.codecs,t.codecs))continue;a=JSON.parse(JSON.stringify(a)),a.numChannels=Math.min(r.numChannels,a.numChannels),n.codecs.push(a),a.rtcpFeedback=a.rtcpFeedback.filter(function(e){for(var t=0;t<r.rtcpFeedback.length;t++)if(r.rtcpFeedback[t].type===e.type&&r.rtcpFeedback[t].parameter===e.parameter)return!0;return!1});break}}}),e.headerExtensions.forEach(function(e){for(var r=0;r<t.headerExtensions.length;r++){var i=t.headerExtensions[r];if(e.uri===i.uri){n.headerExtensions.push(i);break}}}),n}function a(e,t,n){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(n)}var s=n(169);e.exports=function(e,t){var n=function(n){var r=this,o=document.createDocumentFragment();if(["addEventListener","removeEventListener","dispatchEvent"].forEach(function(e){r[e]=o[e].bind(o)}),this.needNegotiation=!1,this.onicecandidate=null,this.onaddstream=null,this.ontrack=null,this.onremovestream=null,this.onsignalingstatechange=null,this.oniceconnectionstatechange=null,this.onicegatheringstatechange=null,this.onnegotiationneeded=null,this.ondatachannel=null,this.canTrickleIceCandidates=null,this.localStreams=[],this.remoteStreams=[],this.getLocalStreams=function(){return r.localStreams},this.getRemoteStreams=function(){return r.remoteStreams},this.localDescription=new e.RTCSessionDescription({type:"",sdp:""}),this.remoteDescription=new e.RTCSessionDescription({type:"",sdp:""}),this.signalingState="stable",this.iceConnectionState="new",this.iceGatheringState="new",this.iceOptions={gatherPolicy:"all",iceServers:[]},n&&n.iceTransportPolicy)switch(n.iceTransportPolicy){case"all":case"relay":this.iceOptions.gatherPolicy=n.iceTransportPolicy}this.usingBundle=n&&"max-bundle"===n.bundlePolicy,n&&n.iceServers&&(this.iceOptions.iceServers=i(n.iceServers,t)),this._config=n||{},this.transceivers=[],this._localIceCandidatesBuffer=[],this._sdpSessionId=s.generateSessionId()};return n.prototype._emitGatheringStateChange=function(){var e=new Event("icegatheringstatechange");this.dispatchEvent(e),null!==this.onicegatheringstatechange&&this.onicegatheringstatechange(e)},n.prototype._emitBufferedCandidates=function(){var e=this,t=s.splitSections(e.localDescription.sdp);this._localIceCandidatesBuffer.forEach(function(n){if(n.candidate&&0!==Object.keys(n.candidate).length)t[n.candidate.sdpMLineIndex+1]+="a="+n.candidate.candidate+"\r\n";else for(var r=1;r<t.length;r++)-1===t[r].indexOf("\r\na=end-of-candidates\r\n")&&(t[r]+="a=end-of-candidates\r\n");if(e.localDescription.sdp=t.join(""),e.dispatchEvent(n),null!==e.onicecandidate&&e.onicecandidate(n),!n.candidate&&"complete"!==e.iceGatheringState){e.transceivers.every(function(e){return e.iceGatherer&&"completed"===e.iceGatherer.state})&&"complete"!==e.iceGatheringStateChange&&(e.iceGatheringState="complete",e._emitGatheringStateChange())}}),this._localIceCandidatesBuffer=[]},n.prototype.getConfiguration=function(){return this._config},n.prototype._createTransceiver=function(e){var t=this.transceivers.length>0,n={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,wantReceive:!0};if(this.usingBundle&&t)n.iceTransport=this.transceivers[0].iceTransport,n.dtlsTransport=this.transceivers[0].dtlsTransport;else{var r=this._createIceAndDtlsTransports();n.iceTransport=r.iceTransport,n.dtlsTransport=r.dtlsTransport}return this.transceivers.push(n),n},n.prototype.addTrack=function(t,n){for(var r,i=0;i<this.transceivers.length;i++)this.transceivers[i].track||this.transceivers[i].kind!==t.kind||(r=this.transceivers[i]);return r||(r=this._createTransceiver(t.kind)),r.track=t,r.stream=n,r.rtpSender=new e.RTCRtpSender(t,r.dtlsTransport),this._maybeFireNegotiationNeeded(),r.rtpSender},n.prototype.addStream=function(e){var n=this;if(t>=15025)this.localStreams.push(e),e.getTracks().forEach(function(t){n.addTrack(t,e)});else{var r=e.clone();e.getTracks().forEach(function(e,t){var n=r.getTracks()[t];e.addEventListener("enabled",function(e){n.enabled=e.enabled})}),r.getTracks().forEach(function(e){n.addTrack(e,r)}),this.localStreams.push(r)}this._maybeFireNegotiationNeeded()},n.prototype.removeStream=function(e){var t=this.localStreams.indexOf(e);t>-1&&(this.localStreams.splice(t,1),this._maybeFireNegotiationNeeded())},n.prototype.getSenders=function(){return this.transceivers.filter(function(e){return!!e.rtpSender}).map(function(e){return e.rtpSender})},n.prototype.getReceivers=function(){return this.transceivers.filter(function(e){return!!e.rtpReceiver}).map(function(e){return e.rtpReceiver})},n.prototype._createIceGatherer=function(t,n){var r=this,i=new e.RTCIceGatherer(r.iceOptions);return i.onlocalcandidate=function(e){var o=new Event("icecandidate");o.candidate={sdpMid:t,sdpMLineIndex:n};var a=e.candidate,c=!a||0===Object.keys(a).length;c?void 0===i.state&&(i.state="completed"):(a.component=1,o.candidate.candidate=s.writeCandidate(a));var u=s.splitSections(r.localDescription.sdp);u[o.candidate.sdpMLineIndex+1]+=c?"a=end-of-candidates\r\n":"a="+o.candidate.candidate+"\r\n",r.localDescription.sdp=u.join("");var d=r._pendingOffer?r._pendingOffer:r.transceivers,f=d.every(function(e){return e.iceGatherer&&"completed"===e.iceGatherer.state});switch(r.iceGatheringState){case"new":c||r._localIceCandidatesBuffer.push(o),c&&f&&r._localIceCandidatesBuffer.push(new Event("icecandidate"));break;case"gathering":r._emitBufferedCandidates(),c||(r.dispatchEvent(o),null!==r.onicecandidate&&r.onicecandidate(o)),f&&(r.dispatchEvent(new Event("icecandidate")),null!==r.onicecandidate&&r.onicecandidate(new Event("icecandidate")),r.iceGatheringState="complete",r._emitGatheringStateChange())}},i},n.prototype._createIceAndDtlsTransports=function(){var t=this,n=new e.RTCIceTransport(null);n.onicestatechange=function(){t._updateConnectionState()};var r=new e.RTCDtlsTransport(n);return r.ondtlsstatechange=function(){t._updateConnectionState()},r.onerror=function(){Object.defineProperty(r,"state",{value:"failed",writable:!0}),t._updateConnectionState()},{iceTransport:n,dtlsTransport:r}},n.prototype._disposeIceAndDtlsTransports=function(e){var t=this.transceivers[e].iceGatherer;t&&(delete t.onlocalcandidate,delete this.transceivers[e].iceGatherer);var n=this.transceivers[e].iceTransport;n&&(delete n.onicestatechange,delete this.transceivers[e].iceTransport);var r=this.transceivers[e].dtlsTransport;r&&(delete r.ondtlsstatechange,delete r.onerror,delete this.transceivers[e].dtlsTransport)},n.prototype._transceive=function(e,n,r){var i=o(e.localCapabilities,e.remoteCapabilities);n&&e.rtpSender&&(i.encodings=e.sendEncodingParameters,i.rtcp={cname:s.localCName,compound:e.rtcpParameters.compound},e.recvEncodingParameters.length&&(i.rtcp.ssrc=e.recvEncodingParameters[0].ssrc),e.rtpSender.send(i)),r&&e.rtpReceiver&&("video"===e.kind&&e.recvEncodingParameters&&t<15019&&e.recvEncodingParameters.forEach(function(e){delete e.rtx}),i.encodings=e.recvEncodingParameters,i.rtcp={cname:e.rtcpParameters.cname,compound:e.rtcpParameters.compound},e.sendEncodingParameters.length&&(i.rtcp.ssrc=e.sendEncodingParameters[0].ssrc),e.rtpReceiver.receive(i))},n.prototype.setLocalDescription=function(t){var n=this;if(!a("setLocalDescription",t.type,this.signalingState)){var r=new Error("Can not set local "+t.type+" in state "+this.signalingState);return r.name="InvalidStateError",arguments.length>2&&"function"==typeof arguments[2]&&e.setTimeout(arguments[2],0,r),Promise.reject(r)}var i,c;if("offer"===t.type)this._pendingOffer&&(i=s.splitSections(t.sdp),c=i.shift(),i.forEach(function(e,t){var r=s.parseRtpParameters(e);n._pendingOffer[t].localCapabilities=r}),this.transceivers=this._pendingOffer,delete this._pendingOffer);else if("answer"===t.type){i=s.splitSections(n.remoteDescription.sdp),c=i.shift();var u=s.matchPrefix(c,"a=ice-lite").length>0;i.forEach(function(e,t){var r=n.transceivers[t],i=r.iceGatherer,a=r.iceTransport,d=r.dtlsTransport,f=r.localCapabilities,l=r.remoteCapabilities;if(!s.isRejected(e)&&!r.isDatachannel){var p=s.getIceParameters(e,c),h=s.getDtlsParameters(e,c);u&&(h.role="server"),n.usingBundle&&0!==t||(a.start(i,p,u?"controlling":"controlled"),d.start(h));var v=o(f,l);n._transceive(r,v.codecs.length>0,!1)}})}switch(this.localDescription={type:t.type,sdp:t.sdp},t.type){case"offer":this._updateSignalingState("have-local-offer");break;case"answer":this._updateSignalingState("stable");break;default:throw new TypeError('unsupported type "'+t.type+'"')}var d=arguments.length>1&&"function"==typeof arguments[1];if(d){var f=arguments[1];e.setTimeout(function(){f(),"new"===n.iceGatheringState&&(n.iceGatheringState="gathering",n._emitGatheringStateChange()),n._emitBufferedCandidates()},0)}var l=Promise.resolve();return l.then(function(){d||("new"===n.iceGatheringState&&(n.iceGatheringState="gathering",n._emitGatheringStateChange()),e.setTimeout(n._emitBufferedCandidates.bind(n),500))}),l},n.prototype.setRemoteDescription=function(n){var r=this;if(!a("setRemoteDescription",n.type,this.signalingState)){var i=new Error("Can not set remote "+n.type+" in state "+this.signalingState);return i.name="InvalidStateError",arguments.length>2&&"function"==typeof arguments[2]&&e.setTimeout(arguments[2],0,i),Promise.reject(i)}var o={},c=[],u=s.splitSections(n.sdp),d=u.shift(),f=s.matchPrefix(d,"a=ice-lite").length>0,l=s.matchPrefix(d,"a=group:BUNDLE ").length>0;this.usingBundle=l;var p=s.matchPrefix(d,"a=ice-options:")[0];switch(this.canTrickleIceCandidates=!!p&&p.substr(14).split(" ").indexOf("trickle")>=0,u.forEach(function(i,a){var u=s.splitLines(i),p=s.getKind(i),h=s.isRejected(i),v=u[0].substr(2).split(" ")[2],m=s.getDirection(i,d),g=s.parseMsid(i),y=s.getMid(i)||s.generateIdentifier();if("application"===p&&"DTLS/SCTP"===v)return void(r.transceivers[a]={mid:y,isDatachannel:!0});var C,b,_,S,E,T,w,P,k,O,R,x=s.parseRtpParameters(i);h||(O=s.getIceParameters(i,d),R=s.getDtlsParameters(i,d),R.role="client"),w=s.parseRtpEncodingParameters(i);var D=s.parseRtcpParameters(i),M=s.matchPrefix(i,"a=end-of-candidates",d).length>0,j=s.matchPrefix(i,"a=candidate:").map(function(e){return s.parseCandidate(e)}).filter(function(e){return"1"===e.component||1===e.component});("offer"===n.type||"answer"===n.type)&&!h&&l&&a>0&&r.transceivers[a]&&(r._disposeIceAndDtlsTransports(a),r.transceivers[a].iceGatherer=r.transceivers[0].iceGatherer,r.transceivers[a].iceTransport=r.transceivers[0].iceTransport,r.transceivers[a].dtlsTransport=r.transceivers[0].dtlsTransport,r.transceivers[a].rtpSender&&r.transceivers[a].rtpSender.setTransport(r.transceivers[0].dtlsTransport),r.transceivers[a].rtpReceiver&&r.transceivers[a].rtpReceiver.setTransport(r.transceivers[0].dtlsTransport)),"offer"!==n.type||h?"answer"!==n.type||h||(C=r.transceivers[a],b=C.iceGatherer,_=C.iceTransport,S=C.dtlsTransport,E=C.rtpReceiver,T=C.sendEncodingParameters,P=C.localCapabilities,r.transceivers[a].recvEncodingParameters=w,r.transceivers[a].remoteCapabilities=x,r.transceivers[a].rtcpParameters=D,l&&0!==a||((f||M)&&j.length&&_.setRemoteCandidates(j),_.start(b,O,"controlling"),S.start(R)),r._transceive(C,"sendrecv"===m||"recvonly"===m,"sendrecv"===m||"sendonly"===m),!E||"sendrecv"!==m&&"sendonly"!==m?delete C.rtpReceiver:(k=E.track,g?(o[g.stream]||(o[g.stream]=new e.MediaStream),o[g.stream].addTrack(k),c.push([k,E,o[g.stream]])):(o.default||(o.default=new e.MediaStream),o.default.addTrack(k),c.push([k,E,o.default])))):(C=r.transceivers[a]||r._createTransceiver(p),C.mid=y,C.iceGatherer||(C.iceGatherer=l&&a>0?r.transceivers[0].iceGatherer:r._createIceGatherer(y,a)),!M||!j.length||l&&0!==a||C.iceTransport.setRemoteCandidates(j),P=e.RTCRtpReceiver.getCapabilities(p),t<15019&&(P.codecs=P.codecs.filter(function(e){return"rtx"!==e.name})),T=[{ssrc:1001*(2*a+2)}],"sendrecv"!==m&&"sendonly"!==m||(E=new e.RTCRtpReceiver(C.dtlsTransport,p),k=E.track,g?(o[g.stream]||(o[g.stream]=new e.MediaStream,Object.defineProperty(o[g.stream],"id",{get:function(){return g.stream}})),Object.defineProperty(k,"id",{get:function(){return g.track}}),o[g.stream].addTrack(k),c.push([k,E,o[g.stream]])):(o.default||(o.default=new e.MediaStream),o.default.addTrack(k),c.push([k,E,o.default]))),C.localCapabilities=P,C.remoteCapabilities=x,C.rtpReceiver=E,C.rtcpParameters=D,C.sendEncodingParameters=T,C.recvEncodingParameters=w,r._transceive(r.transceivers[a],!1,"sendrecv"===m||"sendonly"===m))}),this.remoteDescription={type:n.type,sdp:n.sdp},n.type){case"offer":this._updateSignalingState("have-remote-offer");break;case"answer":this._updateSignalingState("stable");break;default:throw new TypeError('unsupported type "'+n.type+'"')}return Object.keys(o).forEach(function(t){var n=o[t];if(n.getTracks().length){r.remoteStreams.push(n);var i=new Event("addstream");i.stream=n,r.dispatchEvent(i),null!==r.onaddstream&&e.setTimeout(function(){r.onaddstream(i)},0),c.forEach(function(t){var i=t[0],o=t[1];if(n.id===t[2].id){var a=new Event("track");a.track=i,a.receiver=o,a.streams=[n],r.dispatchEvent(a),null!==r.ontrack&&e.setTimeout(function(){r.ontrack(a)},0)}})}}),e.setTimeout(function(){r&&r.transceivers&&r.transceivers.forEach(function(e){e.iceTransport&&"new"===e.iceTransport.state&&e.iceTransport.getRemoteCandidates().length>0&&(console.warn("Timeout for addRemoteCandidate. Consider sending an end-of-candidates notification"),e.iceTransport.addRemoteCandidate({}))})},4e3),arguments.length>1&&"function"==typeof arguments[1]&&e.setTimeout(arguments[1],0),Promise.resolve()},n.prototype.close=function(){this.transceivers.forEach(function(e){e.iceTransport&&e.iceTransport.stop(),e.dtlsTransport&&e.dtlsTransport.stop(),e.rtpSender&&e.rtpSender.stop(),e.rtpReceiver&&e.rtpReceiver.stop()}),this._updateSignalingState("closed")},n.prototype._updateSignalingState=function(e){this.signalingState=e;var t=new Event("signalingstatechange");this.dispatchEvent(t),null!==this.onsignalingstatechange&&this.onsignalingstatechange(t)},n.prototype._maybeFireNegotiationNeeded=function(){var t=this;"stable"===this.signalingState&&!0!==this.needNegotiation&&(this.needNegotiation=!0,e.setTimeout(function(){if(!1!==t.needNegotiation){t.needNegotiation=!1;var e=new Event("negotiationneeded");t.dispatchEvent(e),null!==t.onnegotiationneeded&&t.onnegotiationneeded(e)}},0))},n.prototype._updateConnectionState=function(){var e,t=this,n={new:0,closed:0,connecting:0,checking:0,connected:0,completed:0,disconnected:0,failed:0};if(this.transceivers.forEach(function(e){n[e.iceTransport.state]++,n[e.dtlsTransport.state]++}),n.connected+=n.completed,e="new",n.failed>0?e="failed":n.connecting>0||n.checking>0?e="connecting":n.disconnected>0?e="disconnected":n.new>0?e="new":(n.connected>0||n.completed>0)&&(e="connected"),e!==t.iceConnectionState){t.iceConnectionState=e;var r=new Event("iceconnectionstatechange");this.dispatchEvent(r),null!==this.oniceconnectionstatechange&&this.oniceconnectionstatechange(r)}},n.prototype.createOffer=function(){var n=this;if(this._pendingOffer)throw new Error("createOffer called while there is a pending offer.");var i;1===arguments.length&&"function"!=typeof arguments[0]?i=arguments[0]:3===arguments.length&&(i=arguments[2]);var o=this.transceivers.filter(function(e){return"audio"===e.kind}).length,a=this.transceivers.filter(function(e){return"video"===e.kind}).length;if(i){if(i.mandatory||i.optional)throw new TypeError("Legacy mandatory/optional constraints not supported.");void 0!==i.offerToReceiveAudio&&(o=!0===i.offerToReceiveAudio?1:!1===i.offerToReceiveAudio?0:i.offerToReceiveAudio),void 0!==i.offerToReceiveVideo&&(a=!0===i.offerToReceiveVideo?1:!1===i.offerToReceiveVideo?0:i.offerToReceiveVideo)}for(this.transceivers.forEach(function(e){"audio"===e.kind?--o<0&&(e.wantReceive=!1):"video"===e.kind&&--a<0&&(e.wantReceive=!1)});o>0||a>0;)o>0&&(this._createTransceiver("audio"),o--),a>0&&(this._createTransceiver("video"),a--);var c=r(this.transceivers),u=s.writeSessionBoilerplate(this._sdpSessionId);c.forEach(function(r,i){var o=r.track,a=r.kind,u=s.generateIdentifier();r.mid=u,r.iceGatherer||(r.iceGatherer=n.usingBundle&&i>0?c[0].iceGatherer:n._createIceGatherer(u,i));var d=e.RTCRtpSender.getCapabilities(a);t<15019&&(d.codecs=d.codecs.filter(function(e){return"rtx"!==e.name})),d.codecs.forEach(function(e){"H264"===e.name&&void 0===e.parameters["level-asymmetry-allowed"]&&(e.parameters["level-asymmetry-allowed"]="1")});var f=[{ssrc:1001*(2*i+1)}];o&&t>=15019&&"video"===a&&(f[0].rtx={ssrc:1001*(2*i+1)+1}),r.wantReceive&&(r.rtpReceiver=new e.RTCRtpReceiver(r.dtlsTransport,a)),r.localCapabilities=d,r.sendEncodingParameters=f}),"max-compat"!==this._config.bundlePolicy&&(u+="a=group:BUNDLE "+c.map(function(e){return e.mid}).join(" ")+"\r\n"),u+="a=ice-options:trickle\r\n",c.forEach(function(e,t){u+=s.writeMediaSection(e,e.localCapabilities,"offer",e.stream),u+="a=rtcp-rsize\r\n"}),this._pendingOffer=c;var d=new e.RTCSessionDescription({type:"offer",sdp:u});return arguments.length&&"function"==typeof arguments[0]&&e.setTimeout(arguments[0],0,d),Promise.resolve(d)},n.prototype.createAnswer=function(){var n=s.writeSessionBoilerplate(this._sdpSessionId);this.usingBundle&&(n+="a=group:BUNDLE "+this.transceivers.map(function(e){return e.mid}).join(" ")+"\r\n"),this.transceivers.forEach(function(e,r){if(e.isDatachannel)return void(n+="m=application 0 DTLS/SCTP 5000\r\nc=IN IP4 0.0.0.0\r\na=mid:"+e.mid+"\r\n");if(e.stream){var i;"audio"===e.kind?i=e.stream.getAudioTracks()[0]:"video"===e.kind&&(i=e.stream.getVideoTracks()[0]),i&&t>=15019&&"video"===e.kind&&(e.sendEncodingParameters[0].rtx={ssrc:1001*(2*r+2)+1})}var a=o(e.localCapabilities,e.remoteCapabilities);!a.codecs.filter(function(e){return"rtx"===e.name.toLowerCase()}).length&&e.sendEncodingParameters[0].rtx&&delete e.sendEncodingParameters[0].rtx,n+=s.writeMediaSection(e,a,"answer",e.stream),e.rtcpParameters&&e.rtcpParameters.reducedSize&&(n+="a=rtcp-rsize\r\n")});var r=new e.RTCSessionDescription({type:"answer",sdp:n});return arguments.length&&"function"==typeof arguments[0]&&e.setTimeout(arguments[0],0,r),Promise.resolve(r)},n.prototype.addIceCandidate=function(t){if(t){var n=t.sdpMLineIndex;if(t.sdpMid)for(var r=0;r<this.transceivers.length;r++)if(this.transceivers[r].mid===t.sdpMid){n=r;break}var i=this.transceivers[n];if(i){var o=Object.keys(t.candidate).length>0?s.parseCandidate(t.candidate):{};if("tcp"===o.protocol&&(0===o.port||9===o.port))return Promise.resolve();if(o.component&&"1"!==o.component&&1!==o.component)return Promise.resolve();i.iceTransport.addRemoteCandidate(o);var a=s.splitSections(this.remoteDescription.sdp);a[n+1]+=(o.type?t.candidate.trim():"a=end-of-candidates")+"\r\n",this.remoteDescription.sdp=a.join("")}}else for(var c=0;c<this.transceivers.length;c++)if(this.transceivers[c].iceTransport.addRemoteCandidate({}),this.usingBundle)return Promise.resolve();return arguments.length>1&&"function"==typeof arguments[1]&&e.setTimeout(arguments[1],0),Promise.resolve()},n.prototype.getStats=function(){var t=[];this.transceivers.forEach(function(e){["rtpSender","rtpReceiver","iceGatherer","iceTransport","dtlsTransport"].forEach(function(n){e[n]&&t.push(e[n].getStats())})});var n=arguments.length>1&&"function"==typeof arguments[1]&&arguments[1],r=function(e){return{inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[e.type]||e.type};return new Promise(function(i){var o=new Map;Promise.all(t).then(function(t){t.forEach(function(e){Object.keys(e).forEach(function(t){e[t].type=r(e[t]),o.set(t,e[t])})}),n&&e.setTimeout(n,0,o),i(o)})})},n}},function(e,t,n){"use strict";var r=n(19),i={shimOnTrack:function(e){"object"!=typeof e||!e.RTCPeerConnection||"ontrack"in e.RTCPeerConnection.prototype||Object.defineProperty(e.RTCPeerConnection.prototype,"ontrack",{get:function(){return this._ontrack},set:function(e){this._ontrack&&(this.removeEventListener("track",this._ontrack),this.removeEventListener("addstream",this._ontrackpoly)),this.addEventListener("track",this._ontrack=e),this.addEventListener("addstream",this._ontrackpoly=function(e){e.stream.getTracks().forEach(function(t){var n=new Event("track");n.track=t,n.receiver={track:t},n.streams=[e.stream],this.dispatchEvent(n)}.bind(this))}.bind(this))}})},shimSourceObject:function(e){"object"==typeof e&&(!e.HTMLMediaElement||"srcObject"in e.HTMLMediaElement.prototype||Object.defineProperty(e.HTMLMediaElement.prototype,"srcObject",{get:function(){return this.mozSrcObject},set:function(e){this.mozSrcObject=e}}))},shimPeerConnection:function(e){var t=r.detectBrowser(e);if("object"==typeof e&&(e.RTCPeerConnection||e.mozRTCPeerConnection)){e.RTCPeerConnection||(e.RTCPeerConnection=function(n,r){if(t.version<38&&n&&n.iceServers){for(var i=[],o=0;o<n.iceServers.length;o++){var a=n.iceServers[o];if(a.hasOwnProperty("urls"))for(var s=0;s<a.urls.length;s++){var c={url:a.urls[s]};0===a.urls[s].indexOf("turn")&&(c.username=a.username,c.credential=a.credential),i.push(c)}else i.push(n.iceServers[o])}n.iceServers=i}return new e.mozRTCPeerConnection(n,r)},e.RTCPeerConnection.prototype=e.mozRTCPeerConnection.prototype,e.mozRTCPeerConnection.generateCertificate&&Object.defineProperty(e.RTCPeerConnection,"generateCertificate",{get:function(){return e.mozRTCPeerConnection.generateCertificate}}),e.RTCSessionDescription=e.mozRTCSessionDescription,e.RTCIceCandidate=e.mozRTCIceCandidate),["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(t){var n=e.RTCPeerConnection.prototype[t];e.RTCPeerConnection.prototype[t]=function(){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),n.apply(this,arguments)}});var n=e.RTCPeerConnection.prototype.addIceCandidate;e.RTCPeerConnection.prototype.addIceCandidate=function(){return arguments[0]?n.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())};var i=function(e){var t=new Map;return Object.keys(e).forEach(function(n){t.set(n,e[n]),t[n]=e[n]}),t},o={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"},a=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(e,n,r){return a.apply(this,[e||null]).then(function(e){if(t.version<48&&(e=i(e)),t.version<53&&!n)try{e.forEach(function(e){e.type=o[e.type]||e.type})}catch(t){if("TypeError"!==t.name)throw t;e.forEach(function(t,n){e.set(n,Object.assign({},t,{type:o[t.type]||t.type}))})}return e}).then(n,r)}}}};e.exports={shimOnTrack:i.shimOnTrack,shimSourceObject:i.shimSourceObject,shimPeerConnection:i.shimPeerConnection,shimGetUserMedia:n(178)}},function(e,t,n){"use strict";var r=n(19),i=r.log;e.exports=function(e){var t=r.detectBrowser(e),n=e&&e.navigator,o=e&&e.MediaStreamTrack,a=function(e){return{name:{InternalError:"NotReadableError",NotSupportedError:"TypeError",PermissionDeniedError:"NotAllowedError",SecurityError:"NotAllowedError"}[e.name]||e.name,message:{"The operation is insecure.":"The request is not allowed by the user agent or the platform in the current context."}[e.message]||e.message,constraint:e.constraint,toString:function(){return this.name+(this.message&&": ")+this.message}}},s=function(e,r,o){var s=function(e){if("object"!=typeof e||e.require)return e;var t=[];return Object.keys(e).forEach(function(n){if("require"!==n&&"advanced"!==n&&"mediaSource"!==n){var r=e[n]="object"==typeof e[n]?e[n]:{ideal:e[n]};if(void 0===r.min&&void 0===r.max&&void 0===r.exact||t.push(n),void 0!==r.exact&&("number"==typeof r.exact?r.min=r.max=r.exact:e[n]=r.exact,delete r.exact),void 0!==r.ideal){e.advanced=e.advanced||[];var i={};"number"==typeof r.ideal?i[n]={min:r.ideal,max:r.ideal}:i[n]=r.ideal,e.advanced.push(i),delete r.ideal,Object.keys(r).length||delete e[n]}}}),t.length&&(e.require=t),e};return e=JSON.parse(JSON.stringify(e)),t.version<38&&(i("spec: "+JSON.stringify(e)),e.audio&&(e.audio=s(e.audio)),e.video&&(e.video=s(e.video)),i("ff37: "+JSON.stringify(e))),n.mozGetUserMedia(e,r,function(e){o(a(e))})},c=function(e){return new Promise(function(t,n){s(e,t,n)})};if(n.mediaDevices||(n.mediaDevices={getUserMedia:c,addEventListener:function(){},removeEventListener:function(){}}),n.mediaDevices.enumerateDevices=n.mediaDevices.enumerateDevices||function(){return new Promise(function(e){e([{kind:"audioinput",deviceId:"default",label:"",groupId:""},{kind:"videoinput",deviceId:"default",label:"",groupId:""}])})},t.version<41){var u=n.mediaDevices.enumerateDevices.bind(n.mediaDevices);n.mediaDevices.enumerateDevices=function(){return u().then(void 0,function(e){if("NotFoundError"===e.name)return[];throw e})}}if(t.version<49){var d=n.mediaDevices.getUserMedia.bind(n.mediaDevices);n.mediaDevices.getUserMedia=function(e){return d(e).then(function(t){if(e.audio&&!t.getAudioTracks().length||e.video&&!t.getVideoTracks().length)throw t.getTracks().forEach(function(e){e.stop()}),new DOMException("The object can not be found here.","NotFoundError");return t},function(e){return Promise.reject(a(e))})}}if(!(t.version>55&&"autoGainControl"in n.mediaDevices.getSupportedConstraints())){var f=function(e,t,n){t in e&&!(n in e)&&(e[n]=e[t],delete e[t])},l=n.mediaDevices.getUserMedia.bind(n.mediaDevices);if(n.mediaDevices.getUserMedia=function(e){return"object"==typeof e&&"object"==typeof e.audio&&(e=JSON.parse(JSON.stringify(e)),f(e.audio,"autoGainControl","mozAutoGainControl"),f(e.audio,"noiseSuppression","mozNoiseSuppression")),l(e)},o&&o.prototype.getSettings){var p=o.prototype.getSettings;o.prototype.getSettings=function(){var e=p.apply(this,arguments);return f(e,"mozAutoGainControl","autoGainControl"),f(e,"mozNoiseSuppression","noiseSuppression"),e}}if(o&&o.prototype.applyConstraints){var h=o.prototype.applyConstraints;o.prototype.applyConstraints=function(e){return"audio"===this.kind&&"object"==typeof e&&(e=JSON.parse(JSON.stringify(e)),f(e,"autoGainControl","mozAutoGainControl"),f(e,"noiseSuppression","mozNoiseSuppression")),h.apply(this,[e])}}}n.getUserMedia=function(e,i,o){if(t.version<44)return s(e,i,o);r.deprecated("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),n.mediaDevices.getUserMedia(e).then(i,o)}}},function(e,t,n){"use strict";var r=n(19),i={shimLocalStreamsAPI:function(e){if("object"==typeof e&&e.RTCPeerConnection){if("getLocalStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getLocalStreams=function(){return this._localStreams||(this._localStreams=[]),this._localStreams}),"getStreamById"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getStreamById=function(e){var t=null;return this._localStreams&&this._localStreams.forEach(function(n){n.id===e&&(t=n)}),this._remoteStreams&&this._remoteStreams.forEach(function(n){n.id===e&&(t=n)}),t}),!("addStream"in e.RTCPeerConnection.prototype)){var t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addStream=function(e){this._localStreams||(this._localStreams=[]),-1===this._localStreams.indexOf(e)&&this._localStreams.push(e);var n=this;e.getTracks().forEach(function(r){t.call(n,r,e)})},e.RTCPeerConnection.prototype.addTrack=function(e,n){n&&(this._localStreams?-1===this._localStreams.indexOf(n)&&this._localStreams.push(n):this._localStreams=[n]),t.call(this,e,n)}}"removeStream"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.removeStream=function(e){this._localStreams||(this._localStreams=[]);var t=this._localStreams.indexOf(e);if(-1!==t){this._localStreams.splice(t,1);var n=this,r=e.getTracks();this.getSenders().forEach(function(e){-1!==r.indexOf(e.track)&&n.removeTrack(e)})}})}},shimRemoteStreamsAPI:function(e){"object"==typeof e&&e.RTCPeerConnection&&("getRemoteStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getRemoteStreams=function(){return this._remoteStreams?this._remoteStreams:[]}),"onaddstream"in e.RTCPeerConnection.prototype||Object.defineProperty(e.RTCPeerConnection.prototype,"onaddstream",{get:function(){return this._onaddstream},set:function(e){this._onaddstream&&(this.removeEventListener("addstream",this._onaddstream),this.removeEventListener("track",this._onaddstreampoly)),this.addEventListener("addstream",this._onaddstream=e),this.addEventListener("track",this._onaddstreampoly=function(e){var t=e.streams[0];if(this._remoteStreams||(this._remoteStreams=[]),!(this._remoteStreams.indexOf(t)>=0)){this._remoteStreams.push(t);var n=new Event("addstream");n.stream=e.streams[0],this.dispatchEvent(n)}}.bind(this))}}))},shimCallbacksAPI:function(e){if("object"==typeof e&&e.RTCPeerConnection){var t=e.RTCPeerConnection.prototype,n=t.createOffer,r=t.createAnswer,i=t.setLocalDescription,o=t.setRemoteDescription,a=t.addIceCandidate;t.createOffer=function(e,t){var r=arguments.length>=2?arguments[2]:arguments[0],i=n.apply(this,[r]);return t?(i.then(e,t),Promise.resolve()):i},t.createAnswer=function(e,t){var n=arguments.length>=2?arguments[2]:arguments[0],i=r.apply(this,[n]);return t?(i.then(e,t),Promise.resolve()):i};var s=function(e,t,n){var r=i.apply(this,[e]);return n?(r.then(t,n),Promise.resolve()):r};t.setLocalDescription=s,s=function(e,t,n){var r=o.apply(this,[e]);return n?(r.then(t,n),Promise.resolve()):r},t.setRemoteDescription=s,s=function(e,t,n){var r=a.apply(this,[e]);return n?(r.then(t,n),Promise.resolve()):r},t.addIceCandidate=s}},shimGetUserMedia:function(e){var t=e&&e.navigator;t.getUserMedia||(t.webkitGetUserMedia?t.getUserMedia=t.webkitGetUserMedia.bind(t):t.mediaDevices&&t.mediaDevices.getUserMedia&&(t.getUserMedia=function(e,n,r){t.mediaDevices.getUserMedia(e).then(n,r)}.bind(t)))},shimRTCIceServerUrls:function(e){var t=e.RTCPeerConnection;e.RTCPeerConnection=function(e,n){if(e&&e.iceServers){for(var i=[],o=0;o<e.iceServers.length;o++){var a=e.iceServers[o];!a.hasOwnProperty("urls")&&a.hasOwnProperty("url")?(r.deprecated("RTCIceServer.url","RTCIceServer.urls"),a=JSON.parse(JSON.stringify(a)),a.urls=a.url,delete a.url,i.push(a)):i.push(e.iceServers[o])}e.iceServers=i}return new t(e,n)},e.RTCPeerConnection.prototype=t.prototype,Object.defineProperty(e.RTCPeerConnection,"generateCertificate",{get:function(){return t.generateCertificate}})}};e.exports={shimCallbacksAPI:i.shimCallbacksAPI,shimLocalStreamsAPI:i.shimLocalStreamsAPI,shimRemoteStreamsAPI:i.shimRemoteStreamsAPI,shimGetUserMedia:i.shimGetUserMedia,shimRTCIceServerUrls:i.shimRTCIceServerUrls}}])});