From 0bc9a3bcc2c204a2b0e58cba5b8f6945e5dcd582 Mon Sep 17 00:00:00 2001 From: poplark Date: Wed, 4 Aug 2021 16:31:50 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=89=88=E6=9C=AC=E5=88=B0?= =?UTF-8?q?=201.6.29?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ChangeLog 1. 将请求网关超时时间设为 5 秒,增一次超时重试,以提高加入房间的成功率 2. 增加错误日志的上报 --- lib/index.d.ts | 4 ++-- lib/index.js | 6 +++--- package.json | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/index.d.ts b/lib/index.d.ts index 02314dd..f32107e 100644 --- a/lib/index.d.ts +++ b/lib/index.d.ts @@ -298,7 +298,7 @@ declare module '__urtc-sdk/resolutions' { } declare module '__urtc-sdk/version' { - export const version = "1.6.28"; + export const version = "1.6.29"; } declare module '__urtc-sdk/token' { @@ -314,7 +314,7 @@ declare module '__urtc-sdk/token' { } declare module '__urtc-sdk/types' { - export type VideoCodec = 'vp8' | 'h264'; + export type VideoCodec = 'vp8' | 'h264' | 'h265'; export type AudioCodec = 'opus'; export type RoomType = 'rtc' | 'live'; export type UserRole = 'pull' | 'push' | 'push-and-pull'; diff --git a/lib/index.js b/lib/index.js index 9768f72..290318b 100644 --- a/lib/index.js +++ b/lib/index.js @@ -13,7 +13,7 @@ MERCHANTABLITY OR NON-INFRINGEMENT. See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ -var n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)};function i(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var o=function(){return(o=Object.assign||function(e){for(var t,r=1,n=arguments.length;r=0;s--)(i=e[s])&&(a=(o<3?i(a):o>3?i(t,r,a):i(t,r))||a);return o>3&&a&&Object.defineProperty(t,r,a),a}function c(e,t){return function(r,n){t(r,n,e)}}function u(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function d(e,t,r,n){return new(r||(r=Promise))((function(i,o){function a(e){try{c(n.next(e))}catch(e){o(e)}}function s(e){try{c(n.throw(e))}catch(e){o(e)}}function c(e){e.done?i(e.value):new r((function(t){t(e.value)})).then(a,s)}c((n=n.apply(e,t||[])).next())}))}function f(e,t){var r,n,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,n=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}}}function m(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,o=r.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(n=o.next()).done;)a.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return a}function h(){for(var e=[],t=0;t1||s(e,t)}))})}function s(e,t){try{(r=i[e](t)).value instanceof g?Promise.resolve(r.value.v).then(c,u):d(o[0][2],r)}catch(e){d(o[0][3],e)}var r}function c(e){s("next",e)}function u(e){s("throw",e)}function d(e,t){e(t),o.shift(),o.length&&s(o[0][0],o[0][1])}}function E(e){var t,r;return t={},n("next"),n("throw",(function(e){throw e})),n("return"),t[Symbol.iterator]=function(){return this},t;function n(n,i){t[n]=e[n]?function(t){return(r=!r)?{value:g(e[n](t)),done:"return"===n}:i?i(t):t}:i}}function b(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,r=e[Symbol.asyncIterator];return r?r.call(e):(e=l(e),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(r){t[r]=e[r]&&function(t){return new Promise((function(n,i){(function(e,t,r,n){Promise.resolve(n).then((function(t){e({value:t,done:r})}),t)})(n,i,(t=e[r](t)).done,t.value)}))}}}function _(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}function S(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}function T(e){return e&&e.__esModule?e:{default:e}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(74);t.ErrorCodes=n.ErrorCodes,t.InnerErrorCodes=n.InnerErrorCodes,t.createError=function(e,t){var r,n=e;t&&"[object Error]"===Object.prototype.toString.call(t)?(r=t.message,n="Error"===t.name?e:t.name):r="string"==typeof t?t:"null";var i=new Error(r);return i.name=n,i}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(75).getParser(window.navigator.userAgent);function i(){var e=n.getBrowser(),t=n.getPlatform(),r=n.getEngine();return{name:e.name||"unknown",version:e.version||"unknown",isMobile:"mobile"===t.type,engineName:r.name,engineVersion:r.version}}function o(){var e=n.getOS();return{name:e.name||"unknown",version:e.version||"unknown",versionName:e.versionName||"unknown"}}t.isMobile=function(){return"mobile"===n.getPlatformType()},t.getPlatformVender=function(){return n.getPlatform().vendor||""},t.getBrowserInfo=i,t.getSystemInfo=o,t.getDeviceInfo=function(){var e=n.getOS(),t=n.getBrowser();return{vendor:e.name||"unknown",brand:t.name||"unknown",model:t.version||"unknown"}},t.getNetworkInfo=function(){return{network:""}},t.getCPUInfo=function(){return{brand:"",model:"",core:void 0!==window.navigator.hardwareConcurrency?window.navigator.hardwareConcurrency:0}},t.getMemInfo=function(){return{capacity:void 0!==window.navigator.deviceMemory?window.navigator.deviceMemory:0}};var a={isSafari:function(){return"safari"===i().name.toLowerCase()},isChrome:function(){return"chrome"===i().name.toLowerCase()},isFirefox:function(){return"firefox"===i().name.toLowerCase()},isEdge:function(){return"microsoft edge"===i().name.toLowerCase()},isOldEdge:function(){var e,t=i();return"microsoft edge"===t.name.toLowerCase()&&"blink"!==(null===(e=t.engineName)||void 0===e?void 0:e.toLocaleLowerCase())},isIOS:function(){return"ios"===o().name.toLowerCase()},isMacOS:function(){return"macos"===o().name.toLowerCase()},isWeChat:function(){return"wechat"===i().name.toLowerCase()}};t.default=a},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e){e[e.pushStream=0]="pushStream",e[e.pullStream=1]="pullStream",e[e.allStream=2]="allStream"}(t.ENUM_ROLE_TYPE||(t.ENUM_ROLE_TYPE={})),function(e){e[e.rtc=0]="rtc",e[e.live=1]="live"}(t.ENUM_ROOM_TYPE||(t.ENUM_ROOM_TYPE={})),function(e){e[e.default=1]="default",e[e.reconnect=2]="reconnect",e[e.switch=3]="switch",e[e.refresh=4]="refresh"}(t.ENUM_JOIN_ROOM_TYPE||(t.ENUM_JOIN_ROOM_TYPE={})),function(e){e[e.quit=0]="quit",e[e.reconnect=1]="reconnect",e[e.switch=2]="switch",e[e.refresh=3]="refresh"}(t.ENUM_LOGOFF_TYPE||(t.ENUM_LOGOFF_TYPE={})),function(e){e[e.publish=1]="publish",e[e.subscribe=2]="subscribe"}(t.ENUM_STREAM_TYPE||(t.ENUM_STREAM_TYPE={})),function(e){e[e.none=0]="none",e[e.sd=1]="sd",e[e.hd=2]="hd",e[e.hdp=3]="hdp"}(t.ENUM_VP_LEVEL||(t.ENUM_VP_LEVEL={})),function(e){e[e.camera=1]="camera",e[e.desktop=2]="desktop"}(t.ENUM_MEDIA_TYPE||(t.ENUM_MEDIA_TYPE={})),function(e){e[e.userJoin=1]="userJoin",e[e.userLeave=2]="userLeave"}(t.ENUM_USER_CMD_TYPE||(t.ENUM_USER_CMD_TYPE={})),function(e){e[e.add=1]="add",e[e.remove=2]="remove"}(t.ENUM_STREAM_CMD_TYPE||(t.ENUM_STREAM_CMD_TYPE={})),function(e){e[e.audio=1]="audio",e[e.video=2]="video",e[e.data=3]="data"}(t.ENUM_TRACK_TYPE||(t.ENUM_TRACK_TYPE={})),function(e){e[e.audio=1]="audio",e[e.video=2]="video",e[e.audioVideo=3]="audioVideo"}(t.ENUM_RECORD_MIME||(t.ENUM_RECORD_MIME={})),function(e){e[e.lt=1]="lt",e[e.lb=2]="lb",e[e.rt=3]="rt",e[e.rb=4]="rb"}(t.ENUM_WATER_MARK_POS||(t.ENUM_WATER_MARK_POS={})),function(e){e[e.none=0]="none",e[e.time=1]="time",e[e.image=2]="image",e[e.text=3]="text"}(t.ENUM_WATER_MARK_TYPE||(t.ENUM_WATER_MARK_TYPE={})),function(e){e[e.unjoin=1]="unjoin",e[e.joining=2]="joining",e[e.leaving=3]="leaving",e[e.joined=4]="joined",e[e.rejoining=5]="rejoining"}(t.ENUM_ROOM_STATUS||(t.ENUM_ROOM_STATUS={})),function(e){e[e.unpublish=1]="unpublish",e[e.publishing=2]="publishing",e[e.unpublishing=3]="unpublishing",e[e.published=4]="published",e[e.republishing=5]="republishing"}(t.ENUM_PUBLISH_STATUS||(t.ENUM_PUBLISH_STATUS={})),function(e){e[e.unsubscribe=1]="unsubscribe",e[e.subscribing=2]="subscribing",e[e.unsubscribing=3]="unsubscribing",e[e.subscribed=4]="subscribed",e[e.resubscribing=5]="resubscribing"}(t.ENUM_SUBSCRIBE_STATUS||(t.ENUM_SUBSCRIBE_STATUS={})),function(e){e[e.unrecord=1]="unrecord",e[e.starting=2]="starting",e[e.stopping=3]="stopping",e[e.recording=4]="recording"}(t.ENUM_RECORD_STATUS||(t.ENUM_RECORD_STATUS={})),function(e){e[e.relay=1]="relay",e[e.record=2]="record",e[e.relayRecord=3]="relayRecord",e[e.update=4]="update"}(t.ENUM_MIX_TYPE||(t.ENUM_MIX_TYPE={})),function(e){e[e.flow=1]="flow",e[e.main=2]="main",e[e.custom=3]="custom",e[e.customMain=4]="customMain",e[e.customFlow=5]="customFlow",e[e.single=6]="single"}(t.ENUM_MIX_LAYOUT||(t.ENUM_MIX_LAYOUT={})),function(e){e[e.audioVideo=0]="audioVideo",e[e.audio=1]="audio"}(t.ENUM_MIX_OUTPUT_MODE||(t.ENUM_MIX_OUTPUT_MODE={})),function(e){e[e.auto=1]="auto",e[e.manual=2]="manual"}(t.ENUM_MIX_STREAM_ADD_MODE||(t.ENUM_MIX_STREAM_ADD_MODE={}))},function(e,t,r){"use strict";var n,i="object"==typeof Reflect?Reflect:null,o=i&&"function"==typeof i.apply?i.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};n=i&&"function"==typeof i.ownKeys?i.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var a=Number.isNaN||function(e){return e!=e};function s(){s.init.call(this)}e.exports=s,s.EventEmitter=s,s.prototype._events=void 0,s.prototype._eventsCount=0,s.prototype._maxListeners=void 0;var c=10;function u(e){return void 0===e._maxListeners?s.defaultMaxListeners:e._maxListeners}function d(e,t,r,n){var i,o,a,s;if("function"!=typeof r)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof r);if(void 0===(o=e._events)?(o=e._events=Object.create(null),e._eventsCount=0):(void 0!==o.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),o=e._events),a=o[t]),void 0===a)a=o[t]=r,++e._eventsCount;else if("function"==typeof a?a=o[t]=n?[r,a]:[a,r]:n?a.unshift(r):a.push(r),(i=u(e))>0&&a.length>i&&!a.warned){a.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=e,c.type=t,c.count=a.length,s=c,console&&console.warn&&console.warn(s)}return e}function f(){for(var e=[],t=0;t0&&(a=t[0]),a instanceof Error)throw a;var s=new Error("Unhandled error."+(a?" ("+a.message+")":""));throw s.context=a,s}var c=i[e];if(void 0===c)return!1;if("function"==typeof c)o(c,this,t);else{var u=c.length,d=h(c,u);for(r=0;r=0;o--)if(r[o]===t||r[o].listener===t){a=r[o].listener,i=o;break}if(i<0)return this;0===i?r.shift():function(e,t){for(;t+1=0;n--)this.removeListener(e,t[n]);return this},s.prototype.listeners=function(e){return l(this,e,!0)},s.prototype.rawListeners=function(e){return l(this,e,!1)},s.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):m.call(e,t)},s.prototype.listenerCount=m,s.prototype.eventNames=function(){return this._eventsCount>0?n(this._events):[]}},function(e,t,r){"use strict";var n={generateIdentifier:function(){return Math.random().toString(36).substr(2,10)}};n.localCName=n.generateIdentifier(),n.splitLines=function(e){return e.trim().split("\n").map((function(e){return e.trim()}))},n.splitSections=function(e){return e.split("\nm=").map((function(e,t){return(t>0?"m="+e:e).trim()+"\r\n"}))},n.getDescription=function(e){var t=n.splitSections(e);return t&&t[0]},n.getMediaSections=function(e){var t=n.splitSections(e);return t.shift(),t},n.matchPrefix=function(e,t){return n.splitLines(e).filter((function(e){return 0===e.indexOf(t)}))},n.parseCandidate=function(e){for(var t,r={foundation:(t=0===e.indexOf("a=candidate:")?e.substring(12).split(" "):e.substring(10).split(" "))[0],component:parseInt(t[1],10),protocol:t[2].toLowerCase(),priority:parseInt(t[3],10),ip:t[4],address:t[4],port:parseInt(t[5],10),type:t[7]},n=8;n0?t[0].split("/")[1]:"sendrecv",uri:t[1]}},n.writeExtmap=function(e){return"a=extmap:"+(e.id||e.preferredId)+(e.direction&&"sendrecv"!==e.direction?"/"+e.direction:"")+" "+e.uri+"\r\n"},n.parseFmtp=function(e){for(var t,r={},n=e.substr(e.indexOf(" ")+1).split(";"),i=0;i-1?(r.attribute=e.substr(t+1,n-t-1),r.value=e.substr(n+1)):r.attribute=e.substr(t+1),r},n.parseSsrcGroup=function(e){var t=e.substr(13).split(" ");return{semantics:t.shift(),ssrcs:t.map((function(e){return parseInt(e,10)}))}},n.getMid=function(e){var t=n.matchPrefix(e,"a=mid:")[0];if(t)return t.substr(6)},n.parseFingerprint=function(e){var t=e.substr(14).split(" ");return{algorithm:t[0].toLowerCase(),value:t[1]}},n.getDtlsParameters=function(e,t){return{role:"auto",fingerprints:n.matchPrefix(e+t,"a=fingerprint:").map(n.parseFingerprint)}},n.writeDtlsParameters=function(e,t){var r="a=setup:"+t+"\r\n";return e.fingerprints.forEach((function(e){r+="a=fingerprint:"+e.algorithm+" "+e.value+"\r\n"})),r},n.parseCryptoLine=function(e){var t=e.substr(9).split(" ");return{tag:parseInt(t[0],10),cryptoSuite:t[1],keyParams:t[2],sessionParams:t.slice(3)}},n.writeCryptoLine=function(e){return"a=crypto:"+e.tag+" "+e.cryptoSuite+" "+("object"==typeof e.keyParams?n.writeCryptoKeyParams(e.keyParams):e.keyParams)+(e.sessionParams?" "+e.sessionParams.join(" "):"")+"\r\n"},n.parseCryptoKeyParams=function(e){if(0!==e.indexOf("inline:"))return null;var t=e.substr(7).split("|");return{keyMethod:"inline",keySalt:t[0],lifeTime:t[1],mkiValue:t[2]?t[2].split(":")[0]:void 0,mkiLength:t[2]?t[2].split(":")[1]:void 0}},n.writeCryptoKeyParams=function(e){return e.keyMethod+":"+e.keySalt+(e.lifeTime?"|"+e.lifeTime:"")+(e.mkiValue&&e.mkiLength?"|"+e.mkiValue+":"+e.mkiLength:"")},n.getCryptoParameters=function(e,t){return n.matchPrefix(e+t,"a=crypto:").map(n.parseCryptoLine)},n.getIceParameters=function(e,t){var r=n.matchPrefix(e+t,"a=ice-ufrag:")[0],i=n.matchPrefix(e+t,"a=ice-pwd:")[0];return r&&i?{usernameFragment:r.substr(12),password:i.substr(10)}:null},n.writeIceParameters=function(e){return"a=ice-ufrag:"+e.usernameFragment+"\r\na=ice-pwd:"+e.password+"\r\n"},n.parseRtpParameters=function(e){for(var t={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},r=n.splitLines(e)[0].split(" "),i=3;i0?"9":"0",r+=" UDP/TLS/RTP/SAVPF ",r+=t.codecs.map((function(e){return void 0!==e.preferredPayloadType?e.preferredPayloadType:e.payloadType})).join(" ")+"\r\n",r+="c=IN IP4 0.0.0.0\r\n",r+="a=rtcp:9 IN IP4 0.0.0.0\r\n",t.codecs.forEach((function(e){r+=n.writeRtpMap(e),r+=n.writeFmtp(e),r+=n.writeRtcpFb(e)}));var i=0;return t.codecs.forEach((function(e){e.maxptime>i&&(i=e.maxptime)})),i>0&&(r+="a=maxptime:"+i+"\r\n"),r+="a=rtcp-mux\r\n",t.headerExtensions&&t.headerExtensions.forEach((function(e){r+=n.writeExtmap(e)})),r},n.parseRtpEncodingParameters=function(e){var t,r=[],i=n.parseRtpParameters(e),o=-1!==i.fecMechanisms.indexOf("RED"),a=-1!==i.fecMechanisms.indexOf("ULPFEC"),s=n.matchPrefix(e,"a=ssrc:").map((function(e){return n.parseSsrcMedia(e)})).filter((function(e){return"cname"===e.attribute})),c=s.length>0&&s[0].ssrc,u=n.matchPrefix(e,"a=ssrc-group:FID").map((function(e){return e.substr(17).split(" ").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 n={ssrc:c,codecPayloadType:parseInt(e.parameters.apt,10)};c&&t&&(n.rtx={ssrc:t}),r.push(n),o&&((n=JSON.parse(JSON.stringify(n))).fec={ssrc:c,mechanism:a?"red+ulpfec":"red"},r.push(n))}})),0===r.length&&c&&r.push({ssrc:c});var d=n.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,r.forEach((function(e){e.maxBitrate=d}))),r},n.parseRtcpParameters=function(e){var t={},r=n.matchPrefix(e,"a=ssrc:").map((function(e){return n.parseSsrcMedia(e)})).filter((function(e){return"cname"===e.attribute}))[0];r&&(t.cname=r.value,t.ssrc=r.ssrc);var i=n.matchPrefix(e,"a=rtcp-rsize");t.reducedSize=i.length>0,t.compound=0===i.length;var o=n.matchPrefix(e,"a=rtcp-mux");return t.mux=o.length>0,t},n.parseMsid=function(e){var t,r=n.matchPrefix(e,"a=msid:");if(1===r.length)return{stream:(t=r[0].substr(7).split(" "))[0],track:t[1]};var i=n.matchPrefix(e,"a=ssrc:").map((function(e){return n.parseSsrcMedia(e)})).filter((function(e){return"msid"===e.attribute}));return i.length>0?{stream:(t=i[0].value.split(" "))[0],track:t[1]}:void 0},n.parseSctpDescription=function(e){var t,r=n.parseMLine(e),i=n.matchPrefix(e,"a=max-message-size:");i.length>0&&(t=parseInt(i[0].substr(19),10)),isNaN(t)&&(t=65536);var o=n.matchPrefix(e,"a=sctp-port:");if(o.length>0)return{port:parseInt(o[0].substr(12),10),protocol:r.fmt,maxMessageSize:t};if(n.matchPrefix(e,"a=sctpmap:").length>0){var a=n.matchPrefix(e,"a=sctpmap:")[0].substr(10).split(" ");return{port:parseInt(a[0],10),protocol:a[1],maxMessageSize:t}}},n.writeSctpDescription=function(e,t){var r=[];return r="DTLS/SCTP"!==e.protocol?["m="+e.kind+" 9 "+e.protocol+" "+t.protocol+"\r\n","c=IN IP4 0.0.0.0\r\n","a=sctp-port:"+t.port+"\r\n"]:["m="+e.kind+" 9 "+e.protocol+" "+t.port+"\r\n","c=IN IP4 0.0.0.0\r\n","a=sctpmap:"+t.port+" "+t.protocol+" 65535\r\n"],void 0!==t.maxMessageSize&&r.push("a=max-message-size:"+t.maxMessageSize+"\r\n"),r.join("")},n.generateSessionId=function(){return Math.random().toString().substr(2,21)},n.writeSessionBoilerplate=function(e,t,r){var i=void 0!==t?t:2;return"v=0\r\no="+(r||"thisisadapterortc")+" "+(e||n.generateSessionId())+" "+i+" IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\n"},n.writeMediaSection=function(e,t,r,i){var o=n.writeRtpDescription(e.kind,t);if(o+=n.writeIceParameters(e.iceGatherer.getLocalParameters()),o+=n.writeDtlsParameters(e.dtlsTransport.getLocalParameters(),"offer"===r?"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:"+n.localCName+"\r\n",e.rtpSender&&e.sendEncodingParameters[0].rtx&&(o+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" cname:"+n.localCName+"\r\n"),o},n.getDirection=function(e,t){for(var r=n.splitLines(e),i=0;i921600?u.ENUM_VP_LEVEL.hdp:t>230400?u.ENUM_VP_LEVEL.hd:u.ENUM_VP_LEVEL.sd}t.getVP=m;var h=!1;window.process&&window.process.versions&&void 0!==window.process.versions.electron&&null!==window.process.versions.electron&&(h=!0);var v=function(e){function t(t,r,n){var i=e.call(this,n)||this;return i.status=u.ENUM_PUBLISH_STATUS.unpublish,i.audioType=f.ENUM_AUDIO_TYPE.none,i.videoType=f.ENUM_VIDEO_TYPE.none,i.vp=u.ENUM_VP_LEVEL.none,i.userId=t,i.streamType=u.ENUM_STREAM_TYPE.publish,i.mediaType=r.mediaType,i.muteaudio=!1,i.mutevideo=!1,i.audioMuted=!1,i.videoMuted=!1,i.config=r,r.audio&&(i.audioType=f.ENUM_AUDIO_TYPE.microphone),r.video&&(i.videoType=f.ENUM_VIDEO_TYPE.camera),r.screen&&!r.audio&&r.screenAudio&&(i.audioType=f.ENUM_AUDIO_TYPE.screen),r.screen&&!r.video&&(i.videoType=f.ENUM_VIDEO_TYPE.screen),i}return n.__extends(t,e),Object.defineProperty(t.prototype,"audio",{get:function(){return this.config.audio||this.audioType!==f.ENUM_AUDIO_TYPE.none},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"video",{get:function(){return this.config.video||this.videoType!==f.ENUM_VIDEO_TYPE.none},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isPreview",{get:function(){return!!this.previewId&&this.previewId===this.streamId},enumerable:!0,configurable:!0}),t.prototype.hasAudio=function(){var e;return!!(this.audioHelper&&(null===(e=this.audioHelper)||void 0===e?void 0:e.srcAudioTrack))},t.prototype.hasVideo=function(){var e;return!!(this.videoHelper&&(null===(e=this.videoHelper)||void 0===e?void 0:e.srcVideoTrack))},t.prototype.updateVP=function(){this.vp=m(this.resolution.attributes)},Object.defineProperty(t.prototype,"canUnPublish",{get:function(){var e=!0;switch(this.status){case u.ENUM_PUBLISH_STATUS.unpublish:case u.ENUM_PUBLISH_STATUS.publishing:case u.ENUM_PUBLISH_STATUS.unpublishing:case u.ENUM_PUBLISH_STATUS.republishing:e=!1;break;case u.ENUM_PUBLISH_STATUS.published:default:e=!0}return e},enumerable:!0,configurable:!0}),t.prototype.applyResolution=function(e){return n.__awaiter(this,void 0,void 0,(function(){var t,r,i,o,a,s;return n.__generator(this,(function(n){if(!(t=this.getVideoTrack()))throw l.createError(l.ErrorCodes.OTHERS,"no video track found");if(this.imageStream){if(r=this.imageStream,i=e.attributes,o=this.imageStream.clone(i.videoWidth,i.videoHeight,i.maxFrameRate),!(a=o.mediaStream)||!a.getVideoTracks()[0])throw o.destroy(),l.createError(l.ErrorCodes.OTHERS,"cannot create media stream by image");s=a.getVideoTracks()[0];try{this.replaceVideoTrack(s,!0)}catch(e){throw o.destroy(),e}this.imageStream=o,r.destroy()}else t.applyConstraints(e.video);return[2]}))}))},t.prototype.getScreenMediaStream=function(e){return n.__awaiter(this,void 0,void 0,(function(){var t,r,i,a,s,c,u,f,p,m;return n.__generator(this,(function(n){switch(n.label){case 0:if(t=e.width,r=e.height,i=e.frameRate,a=this.config,!d.default.isChrome()||!a.extensionId)return[3,5];n.label=1;case 1:return n.trys.push([1,3,,4]),[4,new Promise((function(e,n){window.chrome.runtime.sendMessage(a.extensionId,{},(function(a){if(o.default.debug("local stream (chrome extension) response ",a),!a){var s=l.createError(l.ErrorCodes.OTHERS,"chrome extension - no response");return n(s)}if("success"!==a.type){s=l.createError(l.ErrorCodes.OTHERS,"chrome extension - response error");return n(s)}var c=a.options,u={audio:!!(void 0===c?{canRequestAudioTrack:!1}:c).canRequestAudioTrack&&{mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:a.streamId}},video:{mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:a.streamId,maxWidth:t,maxHeight:r,maxFrameRate:i}}};if(navigator.mediaDevices.getUserMedia)navigator.mediaDevices.getUserMedia(u).then(e).catch(n);else if(navigator.webkitGetUserMedia)navigator.webkitGetUserMedia(u,e,n);else{s=l.createError(l.ErrorCodes.NOT_SUPPORT,"browser no support screen share");n(s)}}))}))];case 2:return s=n.sent(),o.default.debug("local stream (chrome extension) - ",s),[3,4];case 3:throw c=n.sent(),o.default.warn("chrome extend stream - get screen "+c),c;case 4:return[3,17];case 5:if(!navigator.mediaDevices.getDisplayMedia)return[3,16];n.label=6;case 6:return n.trys.push([6,8,,15]),f={video:{width:{ideal:t},height:{ideal:r},frameRate:i}},this.config.screenAudio&&(f.audio=!0),[4,navigator.mediaDevices.getDisplayMedia(f)];case 7:return s=n.sent(),o.default.debug("local stream - ",s),[3,15];case 8:if(u=n.sent(),o.default.warn("local stream - get screen with video constraints "+u),!(u.message.indexOf("Audio only requests are not supported")>=0))return[3,13];n.label=9;case 9:return n.trys.push([9,11,,12]),f={video:!0},this.config.screenAudio&&(f.audio=!0),[4,navigator.mediaDevices.getDisplayMedia(f)];case 10:return s=n.sent(),[3,12];case 11:throw p=n.sent(),o.default.warn("local stream - get screen without video constraints "+p),u;case 12:return[3,14];case 13:throw u;case 14:return[3,15];case 15:return[3,17];case 16:throw m=l.createError(l.ErrorCodes.NOT_SUPPORT,"browser no support screen share"),o.default.warn("local stream - get screen "+m),m;case 17:return[2,s]}}))}))},t.prototype.getElectronScreenMediaStream=function(e){return n.__awaiter(this,void 0,void 0,(function(){var t,r;return n.__generator(this,(function(n){switch(n.label){case 0:return(t=this.config).screenAudio&&d.default.isMacOS()&&o.default.warn("cannot get screen audio source when share screen in MacOS"),r={audio:!d.default.isMacOS()&&(t.screenAudio&&{mandatory:{chromeMediaSource:"desktop"}}),video:{mandatory:{chromeMediaSource:"desktop",maxWidth:e.width,maxHeight:e.height,maxFrameRate:e.frameRate}}},[4,navigator.mediaDevices.getUserMedia(r)];case 1:return[2,n.sent()]}}))}))},t.prototype.addTracks2MediaStream=function(){var e,t;return n.__awaiter(this,void 0,void 0,(function(){var r,i,u,d,p,l,m,v,g,y,E,b,_,S,T,w,R,M,C,P,O,I=this;return n.__generator(this,(function(n){switch(n.label){case 0:if(r=this.config,i={audio:!1},u={video:!1},r.audio&&r.microphoneId?i.audio={deviceId:{exact:r.microphoneId}}:r.audio&&(i.audio=!0),d=this.resolution,p=d.video,l=d.attributes,r.video&&r.cameraId?u.video={deviceId:r.cameraId,width:p.width,height:p.height,frameRate:p.frameRate}:r.video&&(u.video={width:p.width,height:p.height,frameRate:p.frameRate},r.facingMode&&(u.video.facingMode={exact:r.facingMode})),i.audio&&u.video||!r.screen)return[3,7];n.label=1;case 1:return n.trys.push([1,6,,7]),h?[4,this.getElectronScreenMediaStream({width:l.videoWidth,height:l.videoHeight,frameRate:l.maxFrameRate})]:[3,3];case 2:return m=n.sent(),[3,5];case 3:return[4,this.getScreenMediaStream({width:l.videoWidth,height:l.videoHeight,frameRate:l.maxFrameRate})];case 4:m=n.sent(),n.label=5;case 5:return m.getTracks().forEach((function(e){o.default.debug("local stream - add screen track ",e);var t=I;if(e.onended=function(e){o.default.debug("screen track ended ",this.readyState,e),"video"===this.kind&&t.getVideoTrack()===this&&t.emitter&&t.emitter.emit("screen-track-ended",t)},"audio"===e.kind&&!r.audio){I.audioHelper=new a.AudioHelper(e);var n=I.getAudioTrack();n&&I.mediaStream.addTrack(n),I.audioType=f.ENUM_AUDIO_TYPE.screen}"video"!==e.kind||r.video||(I.videoHelper=new s.VideoHelper(e,I.resolution.attributes),I.mediaStream.addTrack(e),I.videoType=f.ENUM_VIDEO_TYPE.screen)})),[3,7];case 6:throw v=n.sent(),o.default.error("local stream - get screen "+v),v;case 7:if(g=new MediaStream,!i.audio||!u.video)return[3,21];n.label=8;case 8:return n.trys.push([8,10,,20]),y=Object.assign({},i,u),[4,navigator.mediaDevices.getUserMedia(y)];case 9:return g=n.sent(),[3,20];case 10:if(E=n.sent(),!["AbortError","NotAllowedError","NotFoundError","NotReadableError","OverConstrainedError"].includes(E.name))return[3,18];b=void 0,_=void 0,S=navigator.mediaDevices.getUserMedia(i),T=navigator.mediaDevices.getUserMedia(u),w=void 0,R=void 0,n.label=11;case 11:return n.trys.push([11,13,,14]),[4,S];case 12:return w=n.sent().getTracks(),[3,14];case 13:return M=n.sent(),b=M,[3,14];case 14:return n.trys.push([14,16,,17]),[4,T];case 15:return R=n.sent().getTracks(),[3,17];case 16:return C=n.sent(),_=C,[3,17];case 17:if(null===(e=w)||void 0===e||e.forEach((function(e){return g.addTrack(e)})),null===(t=R)||void 0===t||t.forEach((function(e){return g.addTrack(e)})),b&&_)throw o.default.warn("local stream - retry get media "+E),this.logReporter&&this.logReporter.reportExceptionLog(c.ENUM_LOG_EXCEPTION_TYPE.getMicrophones,{msg:""+b}),this.logReporter&&this.logReporter.reportExceptionLog(c.ENUM_LOG_EXCEPTION_TYPE.getCameras,{msg:""+_}),E;return b?(o.default.warn("get media stream from microphone error, audio will not be published, "+b),o.default.report("get media stream from microphone error, audio will not be published, "+b)):_&&(o.default.warn("get media stream from camera error, video will not be published, "+_),o.default.report("get media stream from camera error, video will not be published, "+_)),[3,19];case 18:throw o.default.warn("local stream - get media "+E),this.logReporter&&this.logReporter.reportExceptionLog(c.ENUM_LOG_EXCEPTION_TYPE.getMicrophones,{msg:""+E}),this.logReporter&&this.logReporter.reportExceptionLog(c.ENUM_LOG_EXCEPTION_TYPE.getCameras,{msg:""+E}),E;case 19:return[3,20];case 20:return[3,30];case 21:if(!i.audio)return[3,26];n.label=22;case 22:return n.trys.push([22,24,,25]),[4,navigator.mediaDevices.getUserMedia(i)];case 23:return g=n.sent(),[3,25];case 24:if(P=n.sent(),!["AbortError","NotAllowedError","NotFoundError","NotReadableError","OverConstrainedError"].includes(P.name)||!this.config.screen)throw o.default.warn("local stream - get media "+P),this.logReporter&&this.logReporter.reportExceptionLog(c.ENUM_LOG_EXCEPTION_TYPE.getMicrophones,{msg:""+P}),P;return o.default.warn("get media stream from microphone error, audio will not be published, "+P),o.default.report("get media stream from microphone error, audio will not be published, "+P),[3,25];case 25:return[3,30];case 26:if(!u.video)return[3,30];n.label=27;case 27:return n.trys.push([27,29,,30]),[4,navigator.mediaDevices.getUserMedia(u)];case 28:return g=n.sent(),[3,30];case 29:throw O=n.sent(),o.default.warn("local stream - get media "+O),this.logReporter&&this.logReporter.reportExceptionLog(c.ENUM_LOG_EXCEPTION_TYPE.getCameras,{msg:""+O}),O;case 30:return g.getTracks().forEach((function(e){if(o.default.debug("local stream - add track ",e),"audio"===e.kind){I.audioHelper=new a.AudioHelper(e);var t=I.getAudioTrack();t&&I.mediaStream.addTrack(t),I.audioType=f.ENUM_AUDIO_TYPE.microphone}"video"===e.kind&&(I.videoHelper=new s.VideoHelper(e,I.resolution.attributes),I.mediaStream.addTrack(e),I.videoType=f.ENUM_VIDEO_TYPE.camera)})),[2]}}))}))},t.prototype.addTracks2MediaStream2=function(e){var t=this;return new Promise((function(r){e.getTracks().forEach((function(e){if(o.default.debug("local stream - add track ",e),"audio"===e.kind){t.audioHelper=new a.AudioHelper(e);var r=t.getAudioTrack();r&&t.mediaStream.addTrack(r),t.audioType=f.ENUM_AUDIO_TYPE.custom}"video"===e.kind&&(t.videoHelper=new s.VideoHelper(e,t.resolution.attributes),t.mediaStream.addTrack(e),t.videoType=f.ENUM_VIDEO_TYPE.custom)})),r()}))},t.prototype.addTracks2MediaStream3=function(e){return n.__awaiter(this,void 0,void 0,(function(){var t,r,i,u,d,p,m,h,v,g,y=this;return n.__generator(this,(function(n){switch(n.label){case 0:if(t=this.config,r={audio:!1,video:!1},t.audio&&t.microphoneId?r.audio={deviceId:{exact:t.microphoneId}}:t.audio&&(r.audio=!0),!r.audio)return[3,4];n.label=1;case 1:return n.trys.push([1,3,,4]),[4,navigator.mediaDevices.getUserMedia(r)];case 2:return(v=n.sent()).getTracks().forEach((function(e){if(o.default.debug("local stream - add track ",e),"audio"===e.kind){y.audioHelper=new a.AudioHelper(e);var t=y.getAudioTrack();t&&y.mediaStream.addTrack(t),y.audioType=f.ENUM_AUDIO_TYPE.microphone}})),[3,4];case 3:throw i=n.sent(),r.audio&&this.logReporter&&this.logReporter.reportExceptionLog(c.ENUM_LOG_EXCEPTION_TYPE.getMicrophones,{msg:""+i}),o.default.warn("local stream - get image stream "+i),i;case 4:return n.trys.push([4,6,,7]),u=this.resolution.attributes,d=u.videoWidth,p=u.videoHeight,m=u.maxFrameRate,h=this,[4,s.VideoHelper.createImageStream(e,d,p,m)];case 5:if(h.imageStream=n.sent(),!(v=this.imageStream.mediaStream)||!v.getVideoTracks()[0])throw this.destroyImageStream(),l.createError(l.ErrorCodes.CREATE_STREAM,"cannot create media stream by image");return this.videoHelper=new s.VideoHelper(v.getVideoTracks()[0],this.resolution.attributes),this.mediaStream.addTrack(v.getVideoTracks()[0]),this.videoType=f.ENUM_VIDEO_TYPE.image,[3,7];case 6:throw g=n.sent(),o.default.error("local stream - get image stream "+g),g;case 7:return[2]}}))}))},t.prototype.addTracks2MediaStream4=function(e){var t=this;return new Promise((function(r){e.audioHelper&&(t.audioHelper=e.audioHelper,(n=e.getAudioTrack())&&t.mediaStream.addTrack(n),t.audioType=e.audioType);if(e.videoHelper){var n;if(t.videoHelper=e.videoHelper,n=e.getVideoTrack()){if(e.videoType===f.ENUM_VIDEO_TYPE.screen){var i=t;n.onended=function(e){o.default.debug("screen track ended ",this.readyState,e),"video"===this.kind&&i.getVideoTrack()===this&&i.emitter&&i.emitter.emit("screen-track-ended",i)}}t.mediaStream.addTrack(n)}t.videoType=e.videoType}e.imageStream&&(t.imageStream=e.imageStream),t.resolution=e.resolution,r()}))},t.prototype.init=function(e,t){var r=this;return new Promise((function(i,o){return n.__awaiter(r,void 0,void 0,(function(){var r;return n.__generator(this,(function(n){switch(n.label){case 0:this.isPreview||this.initConnection(),this.initMediaStream(),n.label=1;case 1:return n.trys.push([1,10,,11]),t?(this.previewId=t.previewId,this.muteaudio=t.muteaudio,this.mutevideo=t.mutevideo,this.audioMuted=t.audioMuted,this.videoMuted=t.videoMuted,[4,this.addTracks2MediaStream4(t)]):[3,3];case 2:return n.sent(),[3,9];case 3:return e.mediaStream?[4,this.addTracks2MediaStream2(e.mediaStream)]:[3,5];case 4:return n.sent(),[3,9];case 5:return e.file||e.filePath?[4,this.addTracks2MediaStream3(e.file||e.filePath)]:[3,7];case 6:return n.sent(),[3,9];case 7:return[4,this.addTracks2MediaStream()];case 8:n.sent(),n.label=9;case 9:return[3,11];case 10:return r=n.sent(),[2,o(r)];case 11:return this.isPreview||this.addTracks2PeerConnection(),i(this.mediaStream),[2]}}))}))}))},t.prototype.initMediaStream=function(){var e,t=new MediaStream;this.audioHelper&&((e=this.getAudioTrack())&&t.addTrack(e));this.videoHelper&&((e=this.videoHelper.dstVideoTrack)&&t.addTrack(e));this.mediaStream=t},t.prototype.addTracks2PeerConnection=function(){var e,t=new MediaStream;this.audioHelper&&((e=this.getAudioTrack())&&(t.addTrack(e),this.peerConnection&&this.peerConnection.addTrack(e,t)));this.videoHelper&&((e=this.videoHelper.dstVideoTrack)&&(t.addTrack(e),this.peerConnection&&this.peerConnection.addTrack(e,t)))},t.prototype.connect=function(e){return n.__awaiter(this,void 0,void 0,(function(){var t,r,i;return n.__generator(this,(function(n){switch(n.label){case 0:this.streamId=e,n.label=1;case 1:if(n.trys.push([1,4,,5]),!this.peerConnection)throw l.createError(l.ErrorCodes.OTHERS,"no peerconnection");if(!this.videoCodec)throw l.createError(l.ErrorCodes.OTHERS,"no video codec settings");return[4,this.peerConnection.createOffer({offerToReceiveAudio:this.audio,offerToReceiveVideo:this.video})];case 2:return t=n.sent(),r=this.resolution.attributes,t.sdp&&this.video&&(t.sdp=p.replaceSDPVideoBW(t.sdp,this.videoCodec,r),t.sdp=p.replaceSDPH264Part(t.sdp,this.videoCodec)),t.sdp&&this.video&&this.videoCodec&&(t.sdp=p.handleSDPVideoCodec(t.sdp,this.videoCodec)),t.sdp&&this.audio&&(t.sdp=p.handleSDPAudioCodec(t.sdp)),[4,this.peerConnection.setLocalDescription(t)];case 3:return n.sent(),[2,t];case 4:throw i=n.sent(),o.default.error("peerconnection create offer error "+i),i;case 5:return[2]}}))}))},t.prototype.setStatusAsDone=function(){this.status=u.ENUM_PUBLISH_STATUS.published},t.prototype.close=function(e){this.destroyImageStream(e),this._close(e),this.status=u.ENUM_PUBLISH_STATUS.unpublish},t.prototype.destroyImageStream=function(e){this.imageStream&&!e&&this.imageStream.destroy(),this.imageStream=void 0},t.prototype.switchMicrophone=function(e){var t;return n.__awaiter(this,void 0,void 0,(function(){var r,i,a,s,c;return n.__generator(this,(function(n){switch(n.label){case 0:if(!this.audio)throw a="stream does not include audio track, cannot switch microphone",o.default.warn("switch microphone - ",a),l.createError(l.ErrorCodes.OTHERS,a);if(this.status!==u.ENUM_PUBLISH_STATUS.unpublish&&!this.hasAudio())throw l.createError(l.ErrorCodes.AUDIO_TRACK_NOT_EXISTS,"cannot find audio track to be replaced");if(!(null===(t=this.audioHelper)||void 0===t?void 0:t.canSwitchMicrophone()))throw l.createError(l.ErrorCodes.NOT_SUPPORT,"cannot switch microphone when effect is playing");n.label=1;case 1:return n.trys.push([1,3,,4]),[4,navigator.mediaDevices.getUserMedia({audio:{deviceId:{exact:e}}})];case 2:if(r=n.sent(),!(i=r.getAudioTracks()[0]))throw a="no audio track, cannot switch microphone",o.default.warn("switch microphone - ",a),l.createError(l.ErrorCodes.OTHERS,a);return(s=this.audioHelper&&this.audioHelper.updateAudioSourceTrack(i))&&s.stop(),this.config.microphoneId=e,this.audioType=f.ENUM_AUDIO_TYPE.microphone,[3,4];case 3:throw c=n.sent(),o.default.error("switch microphone - "+c),c;case 4:return[2]}}))}))},t.prototype.switchCamera=function(e){var t;return n.__awaiter(this,void 0,void 0,(function(){var r,i,a,s,c,d,p,m;return n.__generator(this,(function(n){switch(n.label){case 0:if(!this.video)throw r="stream does not include video track, cannot switch camera",o.default.warn("switch camera - ",r),l.createError(l.ErrorCodes.OTHERS,r);if(this.status!==u.ENUM_PUBLISH_STATUS.unpublish&&!this.hasVideo())throw l.createError(l.ErrorCodes.VIDEO_TRACK_NOT_EXISTS,"cannot find video track to be replaced");if(this.mediaType!==u.ENUM_MEDIA_TYPE.camera)throw r="the mediaType of current stream isnot camera, cannot switch",o.default.warn("switch camera - ",r),l.createError(l.ErrorCodes.OTHERS,r);n.label=1;case 1:n.trys.push([1,11,,12]),i=this.resolution.video,a={video:{deviceId:{exact:e},width:i.width,height:i.height,frameRate:i.frameRate}},s=void 0,n.label=2;case 2:return n.trys.push([2,4,,10]),[4,navigator.mediaDevices.getUserMedia(a)];case 3:return d=n.sent(),s=d.getVideoTracks()[0],[3,10];case 4:return"OverConstrainedError"!==(c=n.sent()).name?[3,6]:(o.default.warn("switch camera - ",c," try to use unstrict deviceId"),a.video.deviceId=e,[4,navigator.mediaDevices.getUserMedia(a)]);case 5:return d=n.sent(),s=d.getVideoTracks()[0],[3,9];case 6:return"NotReadableError"!==c.name?[3,8]:[4,this.forceSwitchCamera(e)];case 7:return m=n.sent(),e=m[0],s=m[1],[3,9];case 8:throw c;case 9:return[3,10];case 10:this.destroyImageStream();try{this.replaceVideoTrack(s)}catch(e){throw null===(t=s)||void 0===t||t.stop(),e}return this.config.cameraId=e,this.videoType=f.ENUM_VIDEO_TYPE.camera,[3,12];case 11:throw p=n.sent(),o.default.error("switch camera - "+p),p;case 12:return[2]}}))}))},t.prototype.forceSwitchCamera=function(e){return n.__awaiter(this,void 0,void 0,(function(){var t,r,i,a,s,c;return n.__generator(this,(function(n){switch(n.label){case 0:t=this.resolution.video,r={video:{deviceId:{exact:e},width:t.width,height:t.height,frameRate:t.frameRate}},i=this.getVideoTrack(),a=i.getSettings().deviceId,i.stop(),n.label=1;case 1:return n.trys.push([1,3,,5]),[4,navigator.mediaDevices.getUserMedia(r)];case 2:return s=n.sent(),[3,5];case 3:return c=n.sent(),o.default.error("force switch camera - ",c),r.video.deviceId=a,e=a,[4,navigator.mediaDevices.getUserMedia(r)];case 4:return s=n.sent(),[3,5];case 5:return[2,[e,s.getVideoTracks()[0]]]}}))}))},t.prototype.switchScreen=function(){return n.__awaiter(this,void 0,void 0,(function(){var e,t,r,i,a=this;return n.__generator(this,(function(n){switch(n.label){case 0:if(!this.video)throw e="stream does not include video track, cannot switch screen",o.default.warn("switch screen - ",e),l.createError(l.ErrorCodes.OTHERS,e);if(this.status!==u.ENUM_PUBLISH_STATUS.unpublish&&!this.hasVideo())throw l.createError(l.ErrorCodes.VIDEO_TRACK_NOT_EXISTS,"cannot find video track to be replaced");if(this.mediaType!==u.ENUM_MEDIA_TYPE.desktop)throw e="the mediaType of current stream isnot screen, cannot switch",o.default.warn("switch screen - ",e),l.createError(l.ErrorCodes.OTHERS,e);t=this.resolution.attributes,n.label=1;case 1:return n.trys.push([1,6,,7]),h?[4,this.getElectronScreenMediaStream({width:t.videoWidth,height:t.videoHeight,frameRate:t.maxFrameRate})]:[3,3];case 2:return r=n.sent(),[3,5];case 3:return[4,this.getScreenMediaStream({width:t.videoWidth,height:t.videoHeight,frameRate:t.maxFrameRate})];case 4:r=n.sent(),n.label=5;case 5:return r.getTracks().forEach((function(e){var t;o.default.debug("local stream - add screen track ",e);var r=a;if(e.onended=function(e){o.default.debug("screen track ended ",this.readyState,e),"video"===this.kind&&r.getVideoTrack()===this&&r.emitter&&r.emitter.emit("screen-track-ended",r)},"audio"===e.kind&&a.audio&&a.audioHelper){var n=a.audioHelper.updateAudioSourceTrack(e);n&&n.stop(),a.audioType=f.ENUM_AUDIO_TYPE.screen}if("video"===e.kind&&a.video){a.destroyImageStream();try{a.replaceVideoTrack(e)}catch(r){throw null===(t=e)||void 0===t||t.stop(),o.default.warn("switch screen - "+r),l.createError(l.ErrorCodes.STREAM_NOT_EXISTS,"stream may not exists")}a.videoType=f.ENUM_VIDEO_TYPE.screen}})),[3,7];case 6:throw i=n.sent(),o.default.error("switch screen - "+i),i;case 7:return[2]}}))}))},t.prototype.switchImage=function(e){var t;return n.__awaiter(this,void 0,void 0,(function(){var r,i,a,s,c,d;return n.__generator(this,(function(n){switch(n.label){case 0:if(!this.video)throw s="stream does not include video track, cannot switch image",o.default.warn("switch image - ",s),l.createError(l.ErrorCodes.OTHERS,s);if(this.status!==u.ENUM_PUBLISH_STATUS.unpublish&&!this.hasVideo())throw l.createError(l.ErrorCodes.VIDEO_TRACK_NOT_EXISTS,"cannot find video track to be replaced");n.label=1;case 1:if(n.trys.push([1,3,,4]),!this.videoHelper)throw s="the stream has no video",o.default.warn("switch image - ",s),l.createError(l.ErrorCodes.OTHERS,s);return r=this.imageStream,[4,this.videoHelper.createImageStream(e)];case 2:if(i=n.sent(),!(a=i.mediaStream)||!a.getVideoTracks()[0])throw i.destroy(),s=l.createError(l.ErrorCodes.OTHERS,"cannot create media stream by image");c=a.getVideoTracks()[0];try{this.replaceVideoTrack(c,!0)}catch(e){throw i.destroy(),e}return this.imageStream=i,null===(t=r)||void 0===t||t.destroy(),this.videoType=f.ENUM_VIDEO_TYPE.image,[3,4];case 3:throw d=n.sent(),o.default.error("switch image - "+d),d;case 4:return[2]}}))}))},t.prototype.replaceAudioTrack=function(e,t){var r,n=this,i=this.audioHelper&&this.audioHelper.srcAudioTrack;return this.audioHelper&&!this.audioHelper.isTrickMode?this.audioHelper&&this.audioHelper.updateAudioSourceTrack(e):this.peerConnection?this.peerConnection.getSenders().forEach((function(r){var o;r.track&&"audio"===r.track.kind&&(r.replaceTrack(e),i&&n.mediaStream.removeTrack(i),n.mediaStream.addTrack(e),n.audioHelper&&n.audioHelper.updateAudioSourceTrack(e),null===(o=n.player)||void 0===o||o.updateAudioTrack(e),!t&&i&&i.stop())})):(i&&this.mediaStream.removeTrack(i),this.mediaStream.addTrack(e),this.audioHelper&&this.audioHelper.updateAudioSourceTrack(e),null===(r=this.player)||void 0===r||r.updateAudioTrack(e),!t&&i&&i.stop()),i},t.prototype.replaceVideoTrack=function(e,t){var r,n=this,i=this.getVideoTrack();return this.peerConnection?this.peerConnection.getSenders().forEach((function(r){var o;r.track&&"video"===r.track.kind&&(r.replaceTrack(e),i&&n.mediaStream.removeTrack(i),n.mediaStream.addTrack(e),n.videoHelper&&n.videoHelper.updateVideoSourceTrack(e),null===(o=n.player)||void 0===o||o.updateVideoTrack(e),!t&&i&&i.stop())})):(i&&this.mediaStream.removeTrack(i),this.mediaStream.addTrack(e),this.videoHelper&&this.videoHelper.updateVideoSourceTrack(e),null===(r=this.player)||void 0===r||r.updateVideoTrack(e),!t&&i&&i.stop()),i},t.prototype.replaceTrack=function(e,t){try{var r=void 0;if(e&&"audio"===e.kind)r=this.replaceAudioTrack(e,t);else{if(!e||"video"!==e.kind)throw l.createError(l.ErrorCodes.INVALID_PARAMETER,"unsupported track");r=this.replaceVideoTrack(e,t)}return r}catch(e){throw e}},t.prototype.convertToOuterStream=function(){var e;switch(this.mediaType){case u.ENUM_MEDIA_TYPE.desktop:e="screen";break;case u.ENUM_MEDIA_TYPE.camera:default:e="camera"}var t=this.isPreview||this.status!==u.ENUM_PUBLISH_STATUS.unpublish&&this.status!==u.ENUM_PUBLISH_STATUS.unpublishing,r={sid:this.streamId,uid:this.userId,type:"publish",mediaType:e,audio:this.audio,video:this.video,muteAudio:this.muteaudio,muteVideo:this.mutevideo,mediaStream:t?this.mediaStream:void 0,audioMuted:this.audioMuted,videoMuted:this.videoMuted};return this.previewId&&(r.previewId=this.previewId,r.mediaStream=this.mediaStream),r},t.prototype.playEffect=function(e,t,r){var n=this;if(this.audioHelper)if(this.audioHelper.isTrickMode){var i=this.audioHelper.srcAudioTrack;this.audioHelper.once("audio-source-stop",(function(){i&&n.replaceAudioTrack(i)})),this.audioHelper.playAudioSource(e,t).then((function(e){n.replaceAudioTrack(e,!0),r()})).catch((function(e){r(e)}))}else this.audioHelper.playAudioBuffer(e,t).then((function(){r()})).catch((function(e){r(e)}));else{var o=l.createError(l.ErrorCodes.OTHERS,"the stream cannot play audio");r(o)}},t.prototype.pauseEffect=function(e,t){if(this.audioHelper){if(this.audioHelper.isTrickMode){var r=l.createError(l.ErrorCodes.NOT_SUPPORT,"current environemnt not support pause effect");return o.default.warn("pause effect - "+r),this.logReporter&&this.logReporter.reportExceptionLog(c.ENUM_LOG_EXCEPTION_TYPE.others,{msg:""+r}),t(r)}this.audioHelper.pauseEffect(e).then((function(){t()})).catch((function(e){t(e)}))}else{r=l.createError(l.ErrorCodes.OTHERS,"the stream cannot play audio");t(r)}},t.prototype.resumeEffect=function(e,t,r){if(this.audioHelper){if(this.audioHelper.isTrickMode){var n=l.createError(l.ErrorCodes.NOT_SUPPORT,"current environemnt not support resume effect");return o.default.warn("resume effect - "+n),this.logReporter&&this.logReporter.reportExceptionLog(c.ENUM_LOG_EXCEPTION_TYPE.others,{msg:""+n}),r(n)}this.audioHelper.resumeEffect(e,t).then((function(){r()})).catch((function(e){r(e)}))}else{n=l.createError(l.ErrorCodes.OTHERS,"the stream cannot play audio");r(n)}},t.prototype.stopEffect=function(e,t){if(this.audioHelper)this.audioHelper.stopEffect(e).then((function(){t()})).catch((function(e){t(e)}));else{var r=l.createError(l.ErrorCodes.OTHERS,"the stream cannot play audio");t(r)}},t.prototype.setEffectVolume=function(e,t,r){if(this.audioHelper)this.audioHelper.setEffectVolume(e,t).then((function(){r()})).catch((function(e){r(e)}));else{var n=l.createError(l.ErrorCodes.OTHERS,"the stream cannot play audio");r(n)}},t}(i.RTCStream);t.LocalStream=v},function(e,t){var r,n,i=e.exports={};function o(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function s(e){if(r===setTimeout)return setTimeout(e,0);if((r===o||!r)&&setTimeout)return r=setTimeout,setTimeout(e,0);try{return r(e,0)}catch(t){try{return r.call(null,e,0)}catch(t){return r.call(this,e,0)}}}!function(){try{r="function"==typeof setTimeout?setTimeout:o}catch(e){r=o}try{n="function"==typeof clearTimeout?clearTimeout:a}catch(e){n=a}}();var c,u=[],d=!1,f=-1;function p(){d&&c&&(d=!1,c.length?u=c.concat(u):f=-1,u.length&&l())}function l(){if(!d){var e=s(p);d=!0;for(var t=u.length;t;){for(c=u,u=[];++f1)for(var r=1;r=80&&(t={sdpSemantics:"unified-plan"}),this.peerConnection=new RTCPeerConnection(t)}else if(a.default.isSafari()||a.default.isOldEdge()){t={bundlePolicy:"max-bundle"};this.peerConnection=new RTCPeerConnection(t)}else this.peerConnection=new RTCPeerConnection;var r=this;this.peerConnection.addEventListener("iceconnectionstatechange",(function(e){var t,n;switch(o.default.debug("iceconnectionstatechange event ",this.iceConnectionState,e,null===(t=r.peerConnection)||void 0===t?void 0:t.iceConnectionState),this.iceConnectionState||(null===(n=r.peerConnection)||void 0===n?void 0:n.iceConnectionState)){case"new":case"connecting":case"checking":case"connected":case"completed":break;case"disconnected":o.default.warn("peerconnection ice disconnected");break;case"failed":o.default.warn("peerconnection ice failed")}})),this.peerConnection.addEventListener("connectionstatechange",(function(e){var t,n;switch(o.default.debug("connectionstatechange event",this.connectionState,e,null===(t=r.peerConnection)||void 0===t?void 0:t.connectionState),this.connectionState||(null===(n=r.peerConnection)||void 0===n?void 0:n.connectionState)){case"new":case"connecting":break;case"connected":r.isEmitted?(r.lastEmitTime=Date.now(),r.emitter&&r.emitter.emit("stream-reconnected",r)):(r.isEmitted=!0,r.lastEmitTime=Date.now(),r.setStatusAsDone(),r.emitter&&r.emitter.emit("stream-connected",r)),r._connectionState=c.ENUM_STREAM_CONNECTION_STATE.connected,r.reconnectTimes=0,r.startUploadStats();break;case"disconnected":o.default.warn("peerconnection disconnected"),r.emitter&&r.emitter.emit("stream-disconnected",r),r.stopUploadStats();break;case"failed":o.default.warn("peerconnection failed"),r.isEmitted||(r.isEmitted=!0,r.lastEmitTime=Date.now(),r.setStatusAsDone(),r.emitter&&r.emitter.emit("stream-connected",r)),r._connectionState=c.ENUM_STREAM_CONNECTION_STATE.disconnected,r.emitter&&r.emitter.emit("stream-failed",r),o.default.debug("peerconnection failed ",r.reconnectTimes,3);break;case"closed":r.stopUploadStats()}}))},Object.defineProperty(e.prototype,"lastOuterStream",{get:function(){return this._lastOuterStream?this._lastOuterStream:this.convertToOuterStream()},enumerable:!0,configurable:!0}),e.prototype.destroyConnection=function(){if(this._lastOuterStream=this.convertToOuterStream(),this.stopUploadStats(),this.peerConnection){var e=this.peerConnection;this.peerConnection=void 0,e.close()}},e.prototype.setResolution=function(e){var t;this.resolution=e,null===(t=this.videoHelper)||void 0===t||t.updateResolutionAttributes(this.resolution.attributes)},Object.defineProperty(e.prototype,"videoTrackSettings",{get:function(){var e=this.getVideoTrack();if(e)return e.getSettings();var t=this.resolution.attributes;return{width:t.videoWidth,height:t.videoHeight}},enumerable:!0,configurable:!0}),e.prototype.restart=function(){return n.__awaiter(this,void 0,void 0,(function(){var e,t;return n.__generator(this,(function(r){switch(r.label){case 0:return this.peerConnection?[4,this.peerConnection.createOffer({iceRestart:!0,offerToReceiveAudio:this.audio,offerToReceiveVideo:this.video})]:[2];case 1:return e=r.sent(),this.isSubscriber||(t=this.resolution.attributes,e.sdp&&this.video&&this.videoCodec&&(e.sdp=u.replaceSDPVideoBW(e.sdp,this.videoCodec,t),e.sdp=u.replaceSDPH264Part(e.sdp,this.videoCodec))),e.sdp&&this.video&&this.videoCodec&&(e.sdp=u.handleSDPVideoCodec(e.sdp,this.videoCodec)),e.sdp&&this.audio&&(e.sdp=u.handleSDPAudioCodec(e.sdp)),o.default.debug("restart sdp ",e.sdp),[4,this.peerConnection.setLocalDescription(e)];case 2:return r.sent(),[2]}}))}))},e.prototype.answer=function(e){return n.__awaiter(this,void 0,void 0,(function(){var t,r;return n.__generator(this,(function(n){return o.default.debug("stream manager answer: ",e),t=u.handleAnswerSDP(e.sdpcontent),r=new RTCSessionDescription({type:e.type,sdp:t}),this.peerConnection?[2,this.peerConnection.setRemoteDescription(r)]:[2,Promise.reject(d.createError(d.ErrorCodes.OTHERS,"no peerconnection"))]}))}))},e.prototype.getAudioTrack=function(){return this.isSubscriber?this.audioHelper&&this.audioHelper.srcAudioTrack:this.audioHelper&&(this.audioHelper.dstAudioTrack||this.audioHelper.srcAudioTrack)},e.prototype.getVideoTrack=function(){return this.mediaStream.getVideoTracks()[0]},e.prototype.muteVideo=function(e){var t=this;this.mutevideo=!0;var r=this.getVideoTrack();if(r){e||(this.videoMuted=!0);var n=function(){var e;t.isSubscriber?(r.enabled=!1,null===(e=t.player)||void 0===e||e.playVideo().catch((function(e){return o.default.warn("mute video - play "+e)})),r.enabled=!0):r.enabled=!1,t.emitter&&t.emitter.emit("video-muted",t)},i=300-(Date.now()-this.lastEmitTime);return!this.isSubscriber&&i>0?setTimeout(n,i):n(),!0}return!1},e.prototype.unmuteVideo=function(e){this.mutevideo=!1;var t=this.getVideoTrack();return!!t&&(e||(this.videoMuted=!1),this.isSubscriber||(t.enabled=!0),this.emitter&&this.emitter.emit("video-unmuted",this),!0)},e.prototype.muteAudio=function(e){this.muteaudio=!0;var t=this.getAudioTrack();return!!t&&(e||(this.audioMuted=!0),this.isSubscriber||(t.enabled=!1),!0)},e.prototype.unmuteAudio=function(e){this.muteaudio=!1;var t=this.getAudioTrack();return!!t&&(e||(this.audioMuted=!1),this.isSubscriber||(t.enabled=!0),!0)},e.prototype.getAudioVolume=function(){return this.audioHelper?this.audioHelper.getVolume():(o.default.warn("No audio track or cannot get volume"),0)},e.prototype.setAudioVolume=function(e){if(this.audioHelper)return this.audioHelper.setVolume(e);return Promise.reject(d.createError(d.ErrorCodes.NOT_SUPPORT,"the stream doesnot contain audio or cannot set volume"))},e.prototype.getMediaStream=function(){return this.mediaStream},e.prototype.destroyMediaStream=function(e){var t=this;this.mediaStream.getTracks().forEach((function(e){t.mediaStream.removeTrack(e)})),this.audioHelper&&(e||this.audioHelper.destroy(),this.audioHelper=void 0),this.videoHelper&&(e||this.videoHelper.destroy(),this.videoHelper=void 0)},e.prototype._close=function(e){this.emitter&&this.emitter.emit("stream-close",this),this.destroyMediaStream(e),this.isEmitted=!1,this.reconnectTimes=0,this._connectionState=c.ENUM_STREAM_CONNECTION_STATE.closed,this.destroyConnection()},e.prototype.updateStatsReports2=function(){return n.__awaiter(this,void 0,void 0,(function(){var e,t,r,i;return n.__generator(this,(function(n){switch(n.label){case 0:if(Date.now()-this.currentStatsReports2.timestamp<500)return[2,{last:this.lastStatsReports2,current:this.currentStatsReports2}];if(!this.peerConnection)return[3,5];n.label=1;case 1:return n.trys.push([1,3,,4]),[4,f.getStats(this.peerConnection)];case 2:return e=n.sent(),t=this.currentStatsReports2,this.currentStatsReports2=new s.StatsReports2(e),this.currentStatsReports2.timestamp-t.timestamp>500&&(this.lastStatsReports2=t),[3,4];case 3:throw r=n.sent(),o.default.error("update stats reports - "+r),r;case 4:return[2,{last:this.lastStatsReports2,current:this.currentStatsReports2}];case 5:throw i="no peerconnection",o.default.warn(i),d.createError(d.ErrorCodes.OTHERS,i)}}))}))},e.prototype.getStats2=function(){return n.__awaiter(this,void 0,void 0,(function(){var e,t,r,i,o,a,s,c,u,f,p,l,m,h,v;return n.__generator(this,(function(n){switch(n.label){case 0:return[4,this.updateStatsReports2()];case 1:if(e=n.sent(),t=e.last,r=e.current,i=(i=Math.round((r.timestamp-t.timestamp)/1e3))>0?i:1,!this.audioCodec)throw o="no audio codec settings",d.createError(d.ErrorCodes.OTHERS,o);if(!this.videoCodec)throw o="no video codec settings",d.createError(d.ErrorCodes.OTHERS,o);return a={br:-1,lostpre:-1,vol:-1,mime:this.audioCodec},this.isSubscriber?(c=r.audioInputReports.bytesReceived-t.audioInputReports.bytesReceived,u=r.audioInputReports.packetsReceived-t.audioInputReports.packetsReceived,m=r.audioInputReports.packetsLost-t.audioInputReports.packetsLost,a.br=(c>=0?Math.round(8*c/i):0)||-1,a.lostpre=m>=0&&u>0?Math.round(m/(u+m)*100):0,a.vol=r.audioInputReports.audioLevel>=0?Math.round(100*r.audioInputReports.audioLevel):0):(p=r.audioOutputReports.bytesSent-t.audioOutputReports.bytesSent,l=r.audioOutputReports.packetsSent-t.audioOutputReports.packetsSent,m=r.audioOutputReports.packetsLost-t.audioOutputReports.packetsLost,a.br=(p>=0?Math.round(8*p/i):0)||-1,a.lostpre=m>=0&&l>0?Math.round(m/(l+m)*100):0,a.vol=r.audioOutputReports.audioLevel>=0?Math.round(100*r.audioOutputReports.audioLevel):0),s={br:-1,lostpre:-1,frt:-1,w:-1,h:-1,mime:this.videoCodec},this.isSubscriber?(c=r.videoInputReports.bytesReceived-t.videoInputReports.bytesReceived,u=r.videoInputReports.packetsReceived-t.videoInputReports.packetsReceived,m=r.videoInputReports.packetsLost-t.videoInputReports.packetsLost,f=r.videoInputReports.framesReceived-t.videoInputReports.framesReceived,s.br=(c>=0?Math.round(8*c/i):0)||-1,s.lostpre=m>=0&&u>0?Math.round(m/(u+m)*100):0,s.frt=(f>=0?Math.round(f/i):0)||-1,s.w=r.videoInputReports.frameWidth,s.h=r.videoInputReports.frameHeight):(p=r.videoOutputReports.bytesSent-t.videoOutputReports.bytesSent,l=r.videoOutputReports.packetsSent-t.videoOutputReports.packetsSent,m=r.videoOutputReports.packetsLost-t.videoOutputReports.packetsLost,h=r.videoOutputReports.framesSent-t.videoOutputReports.framesSent,s.br=(p>=0?Math.round(8*p/i):0)||-1,s.lostpre=m>=0&&l>0?Math.round(m/(l+m)*100):0,s.frt=(h>=0?Math.round(h/i):0)||-1,s.w=r.videoOutputReports.frameWidth,s.h=r.videoOutputReports.frameHeight),v={rtt:-1,delay:-1},this.isSubscriber?r.candidatePairReports.currentRoundTripTime>=0&&(v.delay=Math.round(1e3*r.candidatePairReports.currentRoundTripTime)||0):r.candidatePairReports.currentRoundTripTime>=0&&(v.rtt=Math.round(1e3*r.candidatePairReports.currentRoundTripTime)||0),[2,{audio:a,video:s,connection:v}]}}))}))},e.prototype.getLastPeerConnectionStats=function(){return this.lastStatsReports2},e.prototype.getCurrentPeerConnectionStats=function(){return this.currentStatsReports2},e.prototype.startUploadStats=function(){var e=this;this.timer||(this.timer=window.setInterval((function(){return n.__awaiter(e,void 0,void 0,(function(){var e,t;return n.__generator(this,(function(r){switch(r.label){case 0:return r.trys.push([0,3,,4]),[4,this.updateStatsReports2()];case 1:return r.sent(),[4,this.getStats2()];case 2:if(e=r.sent(),this.isSubscriber){if(!this.streamSubId)return[2];1e3*this.times>=3e3?(this.logReporter&&this.logReporter.reportSubscribeStatusLog(this.streamSubId,this.streamId,this.userId,this.mediaType,{delay:e.connection.delay,rtt:-1,audio:e.audio,video:e.video,cpu:0,memory:0}),this.times=0):this.times+=1}else 1e3*this.times>=3e3?(this.logReporter&&this.logReporter.reportPublishStatusLog(this.streamId,this.mediaType,{delay:-1,rtt:e.connection.rtt,audio:e.audio,video:e.video,cpu:0,memory:0}),this.times=0):this.times+=1;return[3,4];case 3:return t=r.sent(),o.default.warn("upload stats ",t),[3,4];case 4:return[2]}}))}))}),1e3))},e.prototype.stopUploadStats=function(){this.timer&&(window.clearInterval(this.timer),this.timer=0)},e.prototype.snapshot=function(e){if(this.videoHelper)return this.videoHelper.snapshot(e);var t=d.createError(d.ErrorCodes.VIDEO_TRACK_NOT_EXISTS,"stream has no video");return Promise.reject(t)},e.prototype.play=function(e,t){var r=this;return this.player&&this.destroyPlayer(),this.player=new p.Player(this,e,t),this.player.on("paused",(function(){var e;null===(e=r.emitter)||void 0===e||e.emit("stream-paused",r)})),this.player.on("playing",(function(){var e;null===(e=r.emitter)||void 0===e||e.emit("stream-playing",r)})),this.player.on("audio-playing",(function(){var e;null===(e=r.emitter)||void 0===e||e.emit("player-status-change",{type:"audio",status:"playing",stream:r.convertToOuterStream()})})),this.player.on("audio-paused",(function(){var e;null===(e=r.emitter)||void 0===e||e.emit("player-status-change",{type:"audio",status:"paused",stream:r.convertToOuterStream()})})),this.player.on("video-playing",(function(){var e;null===(e=r.emitter)||void 0===e||e.emit("player-status-change",{type:"video",status:"playing",stream:r.convertToOuterStream()})})),this.player.on("video-paused",(function(){var e;null===(e=r.emitter)||void 0===e||e.emit("player-status-change",{type:"video",status:"paused",stream:r.convertToOuterStream()})})),this.player.play()},e.prototype.resume=function(){return this.resumeAudio().catch((function(e){o.default.warn("resume audio faild "+e)})),this.player?this.player.resume():Promise.reject(d.createError(d.ErrorCodes.OTHERS,"stream isn't playing"))},e.prototype.stop=function(){return this.player?(this.player.stop(),Promise.resolve()):Promise.reject(d.createError(d.ErrorCodes.OTHERS,"stream isn't playing"))},e.prototype.destroyPlayer=function(){var e;null===(e=this.player)||void 0===e||e.destroy(),this.player=void 0},e}();t.RTCStream=l},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e){e[e.none=0]="none",e[e.microphone=1]="microphone",e[e.screen=2]="screen",e[e.custom=3]="custom"}(t.ENUM_AUDIO_TYPE||(t.ENUM_AUDIO_TYPE={})),function(e){e[e.none=0]="none",e[e.camera=1]="camera",e[e.screen=2]="screen",e[e.custom=3]="custom",e[e.image=4]="image"}(t.ENUM_VIDEO_TYPE||(t.ENUM_VIDEO_TYPE={})),function(e){e[e.closed=0]="closed",e[e.connecting=1]="connecting",e[e.connected=2]="connected",e[e.reconnecting=3]="reconnecting",e[e.disconnected=4]="disconnected"}(t.ENUM_STREAM_CONNECTION_STATE||(t.ENUM_STREAM_CONNECTION_STATE={}))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(4);t.replaceSDPVideoBW=function(e,t,r){var n,i=e.match(/m=video.*\r\n/);if(i){n=i[0]+"b=AS:2500\r\n";var o=void 0,a=void 0;"h264"===t?(o=e.search(/a=rtpmap:(\d+) H264\/90000\r\n/),a=e.search(/H264\/90000\r\n/)):"vp8"===t&&(o=e.search(/a=rtpmap:(\d+) VP8\/90000\r\n/),a=e.search(/VP8\/90000\r\n/)),o&&a&&a-o>10&&(n=n+"a=fmtp:"+e.slice(o+9,a-1)+" x-google-min-bitrate="+r.minVideoBW+"\r\n"),e=e.replace(i[0],n)}return e},t.handleSDPVideoCodec=function(e,t){var r,n,i=/m=video \d+ .*\r\n/.exec(e);if("h264"===t)r=/a=rtpmap:\d+ H264\/90000\r\n/,n=/H264\/90000\r\n/;else{if("vp8"!==t)return e;r=/a=rtpmap:\d+ VP8\/90000\r\n/,n=/VP8\/90000\r\n/}if(i){var o=void 0,a=e.search(r),s=e.search(n);if(a&&s&&s-a>10&&(o=e.slice(a+9,s-1)),!o)return e;var c=i[0],u=/(\d+ *)+\r\n$/.exec(c);if(u){var d=u[0],f=d.split(" "),p=f.indexOf(o);p>0&&(f.splice(p,1),f.unshift(o));var l=c.replace(d,f.join(" "));e=e.replace(c,l)}}return e},t.handleSDPAudioCodec=function(e){var t=/m=audio \d+ .*\r\n/.exec(e);if(t){var r=void 0,n=e.search(/a=rtpmap:\d+ opus\/48000\/2\r\n/),i=e.search(/opus\/48000\/2\r\n/);if(n&&i&&i-n>10&&(r=e.slice(n+9,i-1)),!r)return e;var o=t[0],a=/(\d+ *)+\r\n$/.exec(o);if(a){var s=a[0],c=s.split(" "),u=c.indexOf(r);u>0&&(c.splice(u,1),c.unshift(r));var d=o.replace(s,c.join(" "));e=e.replace(o,d)}}return e},t.replaceSDPH264Part=function(e,t){return"h264"===t&&n.default.isSafari(),e},t.handleAnswerSDP=function(e){var t=e.match(/a=x-google-flag:conference\r\n/);return t&&(e=e.replace(t[0],"")),e}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n,i=r(2),o=r(21),a=r(3),s=r(0),c=r(4),u=r(6),d=o.default.create({responseType:"arraybuffer"}),f=o.default.create({responseType:"blob"}),p=window.AudioContext||window.webkitAudioContext||window.mozAudioContext||window.msAudioContext||window.oAudioContext,l=c.getSystemInfo(),m=c.getBrowserInfo(),h="ios"===l.name.toLowerCase()&&l.version.indexOf("14.2")>=0,v="macos"===l.name.toLowerCase()&&"safari"===m.name.toLowerCase()&&"14.0.1"===m.version,g="huawei"===c.getPlatformVender().toLocaleLowerCase()&&c.isMobile()&&c.default.isWeChat();!function(e){e[e.init=1]="init",e[e.play=2]="play",e[e.pause=3]="pause"}(n||(n={}));var y=function(e){this.state=n.init,this.startedAt=-1,this.pausedAt=-1,this.config=e},E=function(){};t.CachedAudioBuffer=E;var b=function(){};t.CachedAudioSource=b;var _=function(e){function t(r){var n,i=e.call(this)||this;if(i.effects=new Map,i.isTrickMode=!1,i.mediaStream=new MediaStream,i.mediaStream.addTrack(r),t.shouldUseTrickMode())return i.isTrickMode=!0,i;if(i.audioContext=new p,!i.audioContext)return s.default.error("cannot create audioContext"),i;c.default.isSafari()&&(i.audioContext.onstatechange=function(){var e,t;"interrupted"===(null===(e=i.audioContext)||void 0===e?void 0:e.state)&&(null===(t=i.audioContext)||void 0===t||t.resume())}),i.sourceNode=i.audioContext.createMediaStreamSource(i.mediaStream),"function"==typeof i.audioContext.createMediaStreamDestination?(i.gainNode=i.audioContext.createGain(),i.destinationNode=i.audioContext.createMediaStreamDestination(),i.sourceNode.connect(i.gainNode),i.gainNode.connect(i.destinationNode),n=i.destinationNode.stream):n=i.mediaStream;var o=i.audioContext.createMediaStreamSource(n);return i.analyser=i.audioContext.createAnalyser(),i.timeDomainData=new Uint8Array(i.analyser.frequencyBinCount),o.connect(i.analyser),i}return i.__extends(t,e),Object.defineProperty(t.prototype,"srcAudioTrack",{get:function(){return this.mediaStream.getAudioTracks()[0]},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"dstAudioTrack",{get:function(){return this.destinationNode?this.destinationNode.stream.getAudioTracks()[0]:this.mediaStream.getAudioTracks()[0]},enumerable:!0,configurable:!0}),t.prototype.resume=function(){return this.audioContext?this.audioContext.resume():Promise.resolve()},t.prototype.destroy=function(){var e;this.effects.forEach((function(e){var t;null===(t=e.bufferSourceNode)||void 0===t||t.stop()})),this.mediaStream.getAudioTracks().forEach((function(e){e.stop()})),null===(e=this.audioContext)||void 0===e||e.close()},t.prototype.updateAudioSourceTrack=function(e){var t,r,n=this.srcAudioTrack;n&&e?(this.mediaStream.removeTrack(n),this.mediaStream.addTrack(e)):e&&this.mediaStream.addTrack(e);var i=null===(t=this.audioContext)||void 0===t?void 0:t.createMediaStreamSource(this.mediaStream);return this.gainNode&&i?(null===(r=this.sourceNode)||void 0===r||r.disconnect(this.gainNode),this.sourceNode=i,this.sourceNode.connect(this.gainNode)):this.sourceNode=i,n},t.prototype.getVolume=function(){var e=0;return this.analyser&&(this.analyser.getByteTimeDomainData(this.timeDomainData),this.timeDomainData.forEach((function(t){e=Math.max(e,Math.abs(t-128))}))),e/128},t.prototype.setVolume=function(e){if(this.gainNode)return this.gainNode.gain.value=e/100,Promise.resolve();var t=a.createError(a.ErrorCodes.OTHERS,"cannot find gain node");return Promise.reject(t)},t.shouldUseTrickMode=function(){return h||v?(s.default.warn("iOS 14.2 and macOS with Safari 14.0.1 has bug on AudioContext, getAudioVolume, setAudioVolume... cannot be used."),s.default.report("iOS 14.2 and macOS with Safari 14.0.1 has bug on AudioContext, getAudioVolume, setAudioVolume... cannot be used."),!0):!!g&&(s.default.warn("Huawei wechat has bug on AudioContext, getAudioVolume, setAudioVolume... cannot be used."),s.default.report("Huawei wechat has bug on AudioContext, getAudioVolume, setAudioVolume... cannot be used."),!0)},t.getTrackFromAudioElement=function(e){return Audio.prototype.captureStream?e.captureStream().getAudioTracks()[0]:Audio.prototype.mozCaptureStream?e.mozCaptureStream().getAudioTracks()[0]:c.default.isSafari()||c.default.isOldEdge()?e.audioTracks[0]:void 0},t.loadAudioBuffer=function(e,t,r){var n=this,o=e.get(t);return o?Promise.resolve(o):new Promise((function(o,u){var f=new p;if(!f){var l=a.createError(a.ErrorCodes.NOT_SUPPORT,"cannot create audioContext");return s.default.error("loadAudioBuffer - ",l),void u(l)}d.get(r).then((function(a){return i.__awaiter(n,void 0,void 0,(function(){var n,s;return i.__generator(this,(function(i){switch(i.label){case 0:return c.default.isIOS()||c.default.isSafari()?[4,new Promise((function(e,t){f.decodeAudioData(a.data,e,t)}))]:[3,2];case 1:return n=i.sent(),[3,4];case 2:return[4,f.decodeAudioData(a.data)];case 3:n=i.sent(),i.label=4;case 4:return s={filePath:r,audioBuffer:n},e.set(t,s),o(s),[2]}}))}))})).catch((function(e){s.default.warn("loadAudioBuffer - ",e),s.default.report("loadAudioBuffer - ",e),u(e)})).finally((function(){var e;null===(e=f)||void 0===e||e.close()}))}))},t.loadAudioSource=function(e,t,r){var n=e.get(t);return n?Promise.resolve(n):new Promise((function(n,i){f.get(r).then((function(i){var o=window.URL.createObjectURL(i.data),a={filePath:r,audioSource:o};e.set(t,a),n(a)})).catch((function(e){s.default.warn("loadAudioSource - ",e),s.default.report("loadAudioSource - ",e),i(e)}))}))},t.prototype.playAudioBuffer=function(e,t){var r=this;return new Promise((function(o,c){return i.__awaiter(r,void 0,void 0,(function(){var r,u,d,f,p=this;return i.__generator(this,(function(i){if(!this.destinationNode)return d=a.createError(a.ErrorCodes.NOT_SUPPORT,"this browser not support the API"),[2,c(d)];if(r=this.effects.get(t.effectId),u=e.audioBuffer,r)switch(d=void 0,r.state){case n.pause:break;case n.play:return d=a.createError(a.ErrorCodes.OTHERS,"the effect is playing"),[2,c(d)];case n.init:default:return d=a.createError(a.ErrorCodes.OTHERS,"the effect is initing"),[2,c(d)]}if(t.filePath&&t.filePath!==e.filePath)return d=a.createError(a.ErrorCodes.INVALID_PARAMETER,"wrong effectId or filepath, the effect "+t.effectId+" cached filepath is "+e.filePath),[2,c(d)];r=new y(Object.assign({loop:!1,playTime:0},t,{filePath:e.filePath}));try{if(!this.audioContext)return d=a.createError(a.ErrorCodes.NOT_SUPPORT,"no audio context"),s.default.error("playAudioBuffer - ",d),[2,c(d)];r.bufferSourceNode=this.audioContext.createBufferSource(),r.bufferSourceNode.buffer=u,r.gainNode=this.audioContext.createGain(),r.bufferSourceNode.connect(r.gainNode),r.gainNode.connect(this.destinationNode),r.bufferSourceNode.loop=r.config.loop,this.effects.set(r.config.effectId,r),r.bufferSourceNode.addEventListener("ended",(function(){try{"function"==typeof t.onEnd&&t.onEnd()}catch(e){s.default.warn("play effect end and invoke onEnd error ",e)}r&&r.state!==n.pause&&p.effects.delete(r.config.effectId)}),{once:!0}),r.config.replace&&this.gainNode&&(null===(f=this.sourceNode)||void 0===f||f.disconnect(this.gainNode)),r.bufferSourceNode.start(0,r.config.playTime%u.duration),r.startedAt=Date.now(),r.state=n.play}catch(e){return s.default.error("playAudioBuffer - ",e),[2,c(e)]}return o(),[2]}))}))}))},t.prototype.pauseAudioBuffer=function(e){var t=this;return new Promise((function(r,i){var o,s=t.effects.get(e);if(!s)return i(a.createError(a.ErrorCodes.OTHERS,"cannot find effect "+e));switch(s.state){case n.play:return s.state=n.pause,null===(o=s.bufferSourceNode)||void 0===o||o.stop(),s.pausedAt=Date.now(),r();case n.pause:return i(a.createError(a.ErrorCodes.OTHERS,"the effect is paused"));case n.init:default:return i(a.createError(a.ErrorCodes.OTHERS,"the effect is initing"))}}))},t.prototype.resumeAudioBuffer=function(e,t){var r=this;return new Promise((function(i,o){var s=r.effects.get(t);if(!s)return o(a.createError(a.ErrorCodes.OTHERS,"cannot find effect "+t));switch(s.state){case n.play:return o(a.createError(a.ErrorCodes.OTHERS,"the effect is playing"));case n.pause:var c=Object.assign({},s.config,{playTime:s.config.playTime+(s.pausedAt-s.startedAt)/1e3});r.playAudioBuffer(e,c).then(i).catch(o);break;case n.init:default:return o(a.createError(a.ErrorCodes.OTHERS,"the effect is initing"))}}))},t.prototype.stopAudioBuffer=function(e){var t=this;return new Promise((function(r,i){var o,s=t.effects.get(e);if(s){switch(s.state){case n.pause:t.effects.delete(e);break;case n.play:null===(o=s.bufferSourceNode)||void 0===o||o.stop();break;case n.init:default:return i(a.createError(a.ErrorCodes.OTHERS,"the effect is initing"))}r()}else{i(a.createError(a.ErrorCodes.OTHERS,"cannot find effect "+e))}}))},t.prototype.setGainNodeVolume=function(e,t){var r=this;return new Promise((function(i,o){var s=r.effects.get(e);if(s){switch(s.state){case n.play:return s.gainNode.gain.value=t/100,i();case n.pause:return o(a.createError(a.ErrorCodes.OTHERS,"the effect is paused"));case n.init:default:return o(a.createError(a.ErrorCodes.OTHERS,"the effect is initing"))}}else{o(a.createError(a.ErrorCodes.OTHERS,"cannot find effect "+e))}}))},t.prototype.playAudioSource=function(e,r){var i=this;return new Promise((function(o,c){var u=i.effects,d=u.get(r.effectId);if(d){var f=void 0;switch(d.state){case n.pause:break;case n.play:return f=a.createError(a.ErrorCodes.OTHERS,"the effect is playing"),c(f);case n.init:default:return f=a.createError(a.ErrorCodes.OTHERS,"the effect is initing"),c(f)}}if(r.filePath&&r.filePath!==e.filePath){f=a.createError(a.ErrorCodes.INVALID_PARAMETER,"wrong effectId or filepath, the effect "+r.effectId+" cached filepath is "+e.filePath);return c(f)}(d=new y(Object.assign({loop:!1,playTime:0},r,{filePath:e.filePath}))).audio||(d.audio=new Audio(e.audioSource),d.audio.volume=1e-5),u.set(d.config.effectId,d),d.audio.addEventListener("ended",(function(){var e=d;try{"function"==typeof r.onEnd&&r.onEnd(),i.emit("audio-source-stop",i)}catch(e){s.default.warn("play effect end and invoke onEnd error ",e)}e.state!==n.pause&&u.delete(e.config.effectId)}),{once:!0}),d.audio.addEventListener("loadeddata",(function(){var e=d.audio,r=t.getTrackFromAudioElement(e),n=e.duration||0;if(e.currentTime=d.config.playTime%n,d.startedAt=Date.now(),r)o(r);else{var i=a.createError(a.ErrorCodes.NOT_SUPPORT,"cannot get audio track");s.default.warn(i),s.default.report(i),c(i)}})),d.audio.addEventListener("playing",(function(){d.state=n.play})),d.audio.addEventListener("pause",(function(){d.state=n.pause,i.emit("audio-source-stop",i)})),d.audio.play().catch((function(e){s.default.warn("playAudioSource - ",e),s.default.report("playAudioSource - ",e),c(e)}))}))},t.prototype.pauseAudioSource=function(e){var t=this;return new Promise((function(r,n){if(!t.effects.get(e))return n(a.createError(a.ErrorCodes.OTHERS,"cannot find effect "+e));r()}))},t.prototype.resumeAudioSource=function(e){return new Promise((function(){s.default.debug(e)}))},t.prototype.stopAudioSource=function(e){var t=this;return new Promise((function(r,i){var o,s=t.effects.get(e);if(!s)return i(a.createError(a.ErrorCodes.OTHERS,"cannot find effect "+e));switch(s.state){case n.play:null===(o=s.audio)||void 0===o||o.pause(),r();break;case n.pause:case n.init:default:return i(a.createError(a.ErrorCodes.OTHERS,"the effect is initing"))}}))},t.prototype.pauseEffect=function(e){return this.isTrickMode?this.pauseAudioSource(e):this.pauseAudioBuffer(e)},t.prototype.resumeEffect=function(e,t){return this.isTrickMode?this.resumeAudioSource(t):this.resumeAudioBuffer(e,t)},t.prototype.stopEffect=function(e){return this.isTrickMode?this.stopAudioSource(e):this.stopAudioBuffer(e)},t.prototype.setEffectVolume=function(e,t){return this.isTrickMode?Promise.reject(a.createError(a.ErrorCodes.NOT_SUPPORT,"current environemnt not support this API")):this.setGainNodeVolume(e,t)},t.prototype.canSwitchMicrophone=function(){var e=!0;return this.isTrickMode&&this.effects.forEach((function(t){t.state===n.play&&(e=!1)})),e},t}(u.EventEmitter);t.AudioHelper=_},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.version="1.6.28"},function(e,t,r){(function(e){var n=void 0!==e&&e||"undefined"!=typeof self&&self||window,i=Function.prototype.apply;function o(e,t){this._id=e,this._clearFn=t}t.setTimeout=function(){return new o(i.call(setTimeout,n,arguments),clearTimeout)},t.setInterval=function(){return new o(i.call(setInterval,n,arguments),clearInterval)},t.clearTimeout=t.clearInterval=function(e){e&&e.close()},o.prototype.unref=o.prototype.ref=function(){},o.prototype.close=function(){this._clearFn.call(n,this._id)},t.enroll=function(e,t){clearTimeout(e._idleTimeoutId),e._idleTimeout=t},t.unenroll=function(e){clearTimeout(e._idleTimeoutId),e._idleTimeout=-1},t._unrefActive=t.active=function(e){clearTimeout(e._idleTimeoutId);var t=e._idleTimeout;t>=0&&(e._idleTimeoutId=setTimeout((function(){e._onTimeout&&e._onTimeout()}),t))},r(44),t.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==e&&e.setImmediate||this&&this.setImmediate,t.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==e&&e.clearImmediate||this&&this.clearImmediate}).call(this,r(8))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(21),i=r(64),o=r(30),a=r(10),s=function(e){return new o(e).origin!==window.location.origin};function c(e){var t=e.url,r=void 0===t?a.SERVER_CONFIG.api+"/uteach":t,c=e.method,u=void 0===c?"GET":c,d=e.responseType,f=void 0===d?"json":d,p=e.data,l=void 0===p?{}:p,m=e.crossOrigin,h=void 0!==m&&m,v=e.needVerifyResponse,g=void 0===v||v;return new Promise((function(e,t){!h&&s(r)?i(r,{param:o.qs.stringify(l)+"&callback",timeout:5e3},(function(r,n){return r?t(r):g&&0!==n.err?t(n.msg):void e(n)})):n.default.request({url:r,method:u,responseType:f,data:l}).then((function(r){var n=r.data;if(g&&0!==n.err)return t(n.msg);e(n)})).catch((function(e){t(e)}))}))}t.query=c,t.get=function(e){return c(Object.assign(e,{method:"GET"}))},t.post=function(e){return c(Object.assign(e,{method:"POST"}))}},function(e,t,r){e.exports=r(48)},function(e,t,r){"use strict";e.exports=function(e,t){return function(){for(var r=new Array(arguments.length),n=0;n=200&&e<300}};c.headers={common:{Accept:"application/json, text/plain, */*"}},n.forEach(["delete","get","head"],(function(e){c.headers[e]={}})),n.forEach(["post","put","patch"],(function(e){c.headers[e]=n.merge(o)})),e.exports=c}).call(this,r(12))},function(e,t,r){"use strict";var n=r(1),i=r(55),o=r(23),a=r(57),s=r(58),c=r(27);e.exports=function(e){return new Promise((function(t,u){var d=e.data,f=e.headers;n.isFormData(d)&&delete f["Content-Type"];var p=new XMLHttpRequest;if(e.auth){var l=e.auth.username||"",m=e.auth.password||"";f.Authorization="Basic "+btoa(l+":"+m)}if(p.open(e.method.toUpperCase(),o(e.url,e.params,e.paramsSerializer),!0),p.timeout=e.timeout,p.onreadystatechange=function(){if(p&&4===p.readyState&&(0!==p.status||p.responseURL&&0===p.responseURL.indexOf("file:"))){var r="getAllResponseHeaders"in p?a(p.getAllResponseHeaders()):null,n={data:e.responseType&&"text"!==e.responseType?p.response:p.responseText,status:p.status,statusText:p.statusText,headers:r,config:e,request:p};i(t,u,n),p=null}},p.onabort=function(){p&&(u(c("Request aborted",e,"ECONNABORTED",p)),p=null)},p.onerror=function(){u(c("Network Error",e,null,p)),p=null},p.ontimeout=function(){u(c("timeout of "+e.timeout+"ms exceeded",e,"ECONNABORTED",p)),p=null},n.isStandardBrowserEnv()){var h=r(59),v=(e.withCredentials||s(e.url))&&e.xsrfCookieName?h.read(e.xsrfCookieName):void 0;v&&(f[e.xsrfHeaderName]=v)}if("setRequestHeader"in p&&n.forEach(f,(function(e,t){void 0===d&&"content-type"===t.toLowerCase()?delete f[t]:p.setRequestHeader(t,e)})),e.withCredentials&&(p.withCredentials=!0),e.responseType)try{p.responseType=e.responseType}catch(t){if("json"!==e.responseType)throw t}"function"==typeof e.onDownloadProgress&&p.addEventListener("progress",e.onDownloadProgress),"function"==typeof e.onUploadProgress&&p.upload&&p.upload.addEventListener("progress",e.onUploadProgress),e.cancelToken&&e.cancelToken.promise.then((function(e){p&&(p.abort(),u(e),p=null)})),void 0===d&&(d=null),p.send(d)}))}},function(e,t,r){"use strict";var n=r(56);e.exports=function(e,t,r,i,o){var a=new Error(e);return n(a,t,r,i,o)}},function(e,t,r){"use strict";var n=r(1);e.exports=function(e,t){t=t||{};var r={};return n.forEach(["url","method","params","data"],(function(e){void 0!==t[e]&&(r[e]=t[e])})),n.forEach(["headers","auth","proxy"],(function(i){n.isObject(t[i])?r[i]=n.deepMerge(e[i],t[i]):void 0!==t[i]?r[i]=t[i]:n.isObject(e[i])?r[i]=n.deepMerge(e[i]):void 0!==e[i]&&(r[i]=e[i])})),n.forEach(["baseURL","transformRequest","transformResponse","paramsSerializer","timeout","withCredentials","adapter","responseType","xsrfCookieName","xsrfHeaderName","onUploadProgress","onDownloadProgress","maxContentLength","validateStatus","maxRedirects","httpAgent","httpsAgent","cancelToken","socketPath"],(function(n){void 0!==t[n]?r[n]=t[n]:void 0!==e[n]&&(r[n]=e[n])})),r}},function(e,t,r){"use strict";function n(e){this.message=e}n.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},n.prototype.__CANCEL__=!0,e.exports=n},function(e,t,r){"use strict";(function(t){var n=r(68),i=r(69),o=/^[A-Za-z][A-Za-z0-9+-.]*:\/\//,a=/^([a-z][a-z0-9.+-]*:)?(\/\/)?([\S\s]*)/i,s=new RegExp("^[\\x09\\x0A\\x0B\\x0C\\x0D\\x20\\xA0\\u1680\\u180E\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200A\\u202F\\u205F\\u3000\\u2028\\u2029\\uFEFF]+");function c(e){return(e||"").toString().replace(s,"")}var u=[["#","hash"],["?","query"],function(e){return e.replace("\\","/")},["/","pathname"],["@","auth",1],[NaN,"host",void 0,1,1],[/:(\d+)$/,"port",void 0,1],[NaN,"hostname",void 0,1,1]],d={hash:1,query:1};function f(e){var r,n=("undefined"!=typeof window?window:void 0!==t?t:"undefined"!=typeof self?self:{}).location||{},i={},a=typeof(e=e||n);if("blob:"===e.protocol)i=new l(unescape(e.pathname),{});else if("string"===a)for(r in i=new l(e,{}),d)delete i[r];else if("object"===a){for(r in e)r in d||(i[r]=e[r]);void 0===i.slashes&&(i.slashes=o.test(e.href))}return i}function p(e){e=c(e);var t=a.exec(e);return{protocol:t[1]?t[1].toLowerCase():"",slashes:!!t[2],rest:t[3]}}function l(e,t,r){if(e=c(e),!(this instanceof l))return new l(e,t,r);var o,a,s,d,m,h,v=u.slice(),g=typeof t,y=this,E=0;for("object"!==g&&"string"!==g&&(r=t,t=null),r&&"function"!=typeof r&&(r=i.parse),t=f(t),o=!(a=p(e||"")).protocol&&!a.slashes,y.slashes=a.slashes||o&&t.slashes,y.protocol=a.protocol||t.protocol||"",e=a.rest,a.slashes||(v[3]=[/(.*)/,"pathname"]);E80&&e<=100?s.G1:e>60&&e<=80?s.G2:e>40&&e<=60?s.G3:s.G4},t.prototype.judge=function(e,t){var r=this,n=this.getLevel(e),i=this.getLevel(t);if(n!==i&&n0){var i=this._signal.grade,o=this.getLevel(i),s=void 0;if(s=e?t?this.signals.find((function(e){return e.wss===t})):this._signal:this.signals.find((function(e){return e!==r._signal&&r.getLevel(e.grade)<=o}))){a.default.debug("change signal "+(s&&s.wss)+"}"),s!==this._signal&&(this._signal.grade=0);var c=this._signal;this._signal=s,this.emit("change-signal",c,this._signal)}}},t.prototype.award=function(e){var t;if(this._signal&&this._signal.status===n.connected&&this._signal.grade<100){var r=this._signal.grade,i=void 0;i="number"==typeof e?e:(10*this._signal.grade+10)/10,this._signal.grade=i,a.default.debug("signal "+(null===(t=this._signal)||void 0===t?void 0:t.url)+" "+r+" -> "+i)}},t.prototype.punish=function(e){var t;if(this._signal&&this._signal.status===n.connected&&this._signal.grade>0){var r=this._signal.grade,i=void 0;"number"==typeof e?i=e:(i=(10*this._signal.grade-10)/10)<0&&(i=0),this._signal.grade=i,a.default.debug("signal "+(null===(t=this._signal)||void 0===t?void 0:t.url)+" "+r+" -> "+i),this.judge(r,i)}},t.prototype.add=function(e){this.signals.push(e),this._signal||(this._signal=e)},t.prototype.remove=function(e){var t=this.signals.findIndex((function(t){return t===e}));t>=0&&this.signals.splice(t,1)},t.prototype.destroy=function(){this.signals=[],this._signal=void 0},t.prototype.reconnect=function(){this.switch(!0)},t.prototype.refresh=function(e){var t=this;if(e.length>0){var r=this._signal;this.signals=[],e.forEach((function(e){t.signals.push(e)})),this._signal=this.signals[0],this.emit("change-signal",r,this._signal)}},t}(o.EventEmitter);t.SignalManager=u},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(33),i=function(){this.bytesReceived=0,this.jitter=0,this.packetsLost=0,this.packetsReceived=0,this.audioLevel=0},o=function(){this.bytesReceived=0,this.packetsLost=0,this.packetsReceived=0,this.firCount=0,this.nackCount=0,this.pliCount=0,this.framesDecoded=0,this.frameHeight=0,this.frameWidth=0,this.framesDropped=0,this.framesReceived=0},a=function(){this.bytesSent=0,this.packetsSent=0,this.retransmittedBytesSent=0,this.retransmittedPacketsSent=0,this.audioLevel=0,this.jitter=0,this.roundTripTime=0,this.packetsLost=0},s=function(){this.bytesSent=0,this.packetsSent=0,this.firCount=0,this.nackCount=0,this.pliCount=0,this.framesEncoded=0,this.frameHeight=0,this.frameWidth=0,this.framesSent=0,this.height=0,this.width=0,this.framesPerSecond=0,this.jitter=0,this.roundTripTime=0,this.packetsLost=0},c=function(){this.availableIncomingBitrate=0,this.availableOutgoingBitrate=0,this.bytesReceived=0,this.bytesSent=0,this.currentRoundTripTime=0,this.totalRoundTripTime=0},u=function(){this.ip="",this.port=0,this.networkType="",this.protocol="udp"},d=function(){this.ip="",this.port=0,this.protocol="udp"},f=function(){this.bytesReceived=0,this.bytesSent=0,this.dtlsState=""},p=function(){this.inAudioReport=new i,this.inVideoReport=new o,this.outAudioReport=new a,this.outVideoReport=new s,this.candidatePairReport=new c,this.localCandidateReport=new u,this.remoteCandidateReport=new d,this.transportReport=new f,this.timestamp=Date.now(),this.original=[]};t.StatsReports=p;var l=function(e){this.timestamp=Date.now(),this.reports=new n.Reports(e),this.audioInputReports=new n.AudioInputReports(e),this.audioOutputReports=new n.AudioOutputReports(e),this.videoInputReports=new n.VideoInputReports(e),this.videoOutputReports=new n.VideoOutputReports(e),this.candidatePairReports=new n.CandidatePairReports(e)};t.StatsReports2=l},function(e,t,r){ +var n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)};function i(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var o=function(){return(o=Object.assign||function(e){for(var t,r=1,n=arguments.length;r=0;s--)(i=e[s])&&(a=(o<3?i(a):o>3?i(t,r,a):i(t,r))||a);return o>3&&a&&Object.defineProperty(t,r,a),a}function c(e,t){return function(r,n){t(r,n,e)}}function u(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function d(e,t,r,n){return new(r||(r=Promise))((function(i,o){function a(e){try{c(n.next(e))}catch(e){o(e)}}function s(e){try{c(n.throw(e))}catch(e){o(e)}}function c(e){e.done?i(e.value):new r((function(t){t(e.value)})).then(a,s)}c((n=n.apply(e,t||[])).next())}))}function f(e,t){var r,n,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,n=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}}}function m(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,o=r.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(n=o.next()).done;)a.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return a}function h(){for(var e=[],t=0;t1||s(e,t)}))})}function s(e,t){try{(r=i[e](t)).value instanceof g?Promise.resolve(r.value.v).then(c,u):d(o[0][2],r)}catch(e){d(o[0][3],e)}var r}function c(e){s("next",e)}function u(e){s("throw",e)}function d(e,t){e(t),o.shift(),o.length&&s(o[0][0],o[0][1])}}function E(e){var t,r;return t={},n("next"),n("throw",(function(e){throw e})),n("return"),t[Symbol.iterator]=function(){return this},t;function n(n,i){t[n]=e[n]?function(t){return(r=!r)?{value:g(e[n](t)),done:"return"===n}:i?i(t):t}:i}}function b(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,r=e[Symbol.asyncIterator];return r?r.call(e):(e=l(e),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(r){t[r]=e[r]&&function(t){return new Promise((function(n,i){(function(e,t,r,n){Promise.resolve(n).then((function(t){e({value:t,done:r})}),t)})(n,i,(t=e[r](t)).done,t.value)}))}}}function _(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}function S(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}function T(e){return e&&e.__esModule?e:{default:e}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(74);t.ErrorCodes=n.ErrorCodes,t.InnerErrorCodes=n.InnerErrorCodes,t.createError=function(e,t){var r,n=e;t&&"[object Error]"===Object.prototype.toString.call(t)?(r=t.message,n="Error"===t.name?e:t.name):r="string"==typeof t?t:"null";var i=new Error(r);return i.name=n,i}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(75).getParser(window.navigator.userAgent);function i(){var e=n.getBrowser(),t=n.getPlatform(),r=n.getEngine();return{name:e.name||"unknown",version:e.version||"unknown",isMobile:"mobile"===t.type,engineName:r.name,engineVersion:r.version}}function o(){var e=n.getOS();return{name:e.name||"unknown",version:e.version||"unknown",versionName:e.versionName||"unknown"}}t.isMobile=function(){return"mobile"===n.getPlatformType()},t.getPlatformVender=function(){return n.getPlatform().vendor||""},t.getBrowserInfo=i,t.getSystemInfo=o,t.getDeviceInfo=function(){var e=n.getOS(),t=n.getBrowser();return{vendor:e.name||"unknown",brand:t.name||"unknown",model:t.version||"unknown"}},t.getNetworkInfo=function(){return{network:""}},t.getCPUInfo=function(){return{brand:"",model:"",core:void 0!==window.navigator.hardwareConcurrency?window.navigator.hardwareConcurrency:0}},t.getMemInfo=function(){return{capacity:void 0!==window.navigator.deviceMemory?window.navigator.deviceMemory:0}};var a={isSafari:function(){return"safari"===i().name.toLowerCase()},isChrome:function(){return"chrome"===i().name.toLowerCase()},isFirefox:function(){return"firefox"===i().name.toLowerCase()},isEdge:function(){return"microsoft edge"===i().name.toLowerCase()},isOldEdge:function(){var e,t=i();return"microsoft edge"===t.name.toLowerCase()&&"blink"!==(null===(e=t.engineName)||void 0===e?void 0:e.toLocaleLowerCase())},isIOS:function(){return"ios"===o().name.toLowerCase()},isMacOS:function(){return"macos"===o().name.toLowerCase()},isWeChat:function(){return"wechat"===i().name.toLowerCase()}};t.default=a},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e){e[e.pushStream=0]="pushStream",e[e.pullStream=1]="pullStream",e[e.allStream=2]="allStream"}(t.ENUM_ROLE_TYPE||(t.ENUM_ROLE_TYPE={})),function(e){e[e.rtc=0]="rtc",e[e.live=1]="live"}(t.ENUM_ROOM_TYPE||(t.ENUM_ROOM_TYPE={})),function(e){e[e.default=1]="default",e[e.reconnect=2]="reconnect",e[e.switch=3]="switch",e[e.refresh=4]="refresh"}(t.ENUM_JOIN_ROOM_TYPE||(t.ENUM_JOIN_ROOM_TYPE={})),function(e){e[e.quit=0]="quit",e[e.reconnect=1]="reconnect",e[e.switch=2]="switch",e[e.refresh=3]="refresh"}(t.ENUM_LOGOFF_TYPE||(t.ENUM_LOGOFF_TYPE={})),function(e){e[e.publish=1]="publish",e[e.subscribe=2]="subscribe"}(t.ENUM_STREAM_TYPE||(t.ENUM_STREAM_TYPE={})),function(e){e[e.none=0]="none",e[e.sd=1]="sd",e[e.hd=2]="hd",e[e.hdp=3]="hdp"}(t.ENUM_VP_LEVEL||(t.ENUM_VP_LEVEL={})),function(e){e[e.camera=1]="camera",e[e.desktop=2]="desktop"}(t.ENUM_MEDIA_TYPE||(t.ENUM_MEDIA_TYPE={})),function(e){e[e.userJoin=1]="userJoin",e[e.userLeave=2]="userLeave"}(t.ENUM_USER_CMD_TYPE||(t.ENUM_USER_CMD_TYPE={})),function(e){e[e.add=1]="add",e[e.remove=2]="remove"}(t.ENUM_STREAM_CMD_TYPE||(t.ENUM_STREAM_CMD_TYPE={})),function(e){e[e.audio=1]="audio",e[e.video=2]="video",e[e.data=3]="data"}(t.ENUM_TRACK_TYPE||(t.ENUM_TRACK_TYPE={})),function(e){e[e.audio=1]="audio",e[e.video=2]="video",e[e.audioVideo=3]="audioVideo"}(t.ENUM_RECORD_MIME||(t.ENUM_RECORD_MIME={})),function(e){e[e.lt=1]="lt",e[e.lb=2]="lb",e[e.rt=3]="rt",e[e.rb=4]="rb"}(t.ENUM_WATER_MARK_POS||(t.ENUM_WATER_MARK_POS={})),function(e){e[e.none=0]="none",e[e.time=1]="time",e[e.image=2]="image",e[e.text=3]="text"}(t.ENUM_WATER_MARK_TYPE||(t.ENUM_WATER_MARK_TYPE={})),function(e){e[e.unjoin=1]="unjoin",e[e.joining=2]="joining",e[e.leaving=3]="leaving",e[e.joined=4]="joined",e[e.rejoining=5]="rejoining"}(t.ENUM_ROOM_STATUS||(t.ENUM_ROOM_STATUS={})),function(e){e[e.unpublish=1]="unpublish",e[e.publishing=2]="publishing",e[e.unpublishing=3]="unpublishing",e[e.published=4]="published",e[e.republishing=5]="republishing"}(t.ENUM_PUBLISH_STATUS||(t.ENUM_PUBLISH_STATUS={})),function(e){e[e.unsubscribe=1]="unsubscribe",e[e.subscribing=2]="subscribing",e[e.unsubscribing=3]="unsubscribing",e[e.subscribed=4]="subscribed",e[e.resubscribing=5]="resubscribing"}(t.ENUM_SUBSCRIBE_STATUS||(t.ENUM_SUBSCRIBE_STATUS={})),function(e){e[e.unrecord=1]="unrecord",e[e.starting=2]="starting",e[e.stopping=3]="stopping",e[e.recording=4]="recording"}(t.ENUM_RECORD_STATUS||(t.ENUM_RECORD_STATUS={})),function(e){e[e.relay=1]="relay",e[e.record=2]="record",e[e.relayRecord=3]="relayRecord",e[e.update=4]="update"}(t.ENUM_MIX_TYPE||(t.ENUM_MIX_TYPE={})),function(e){e[e.flow=1]="flow",e[e.main=2]="main",e[e.custom=3]="custom",e[e.customMain=4]="customMain",e[e.customFlow=5]="customFlow",e[e.single=6]="single"}(t.ENUM_MIX_LAYOUT||(t.ENUM_MIX_LAYOUT={})),function(e){e[e.audioVideo=0]="audioVideo",e[e.audio=1]="audio"}(t.ENUM_MIX_OUTPUT_MODE||(t.ENUM_MIX_OUTPUT_MODE={})),function(e){e[e.auto=1]="auto",e[e.manual=2]="manual"}(t.ENUM_MIX_STREAM_ADD_MODE||(t.ENUM_MIX_STREAM_ADD_MODE={}))},function(e,t,r){"use strict";var n,i="object"==typeof Reflect?Reflect:null,o=i&&"function"==typeof i.apply?i.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};n=i&&"function"==typeof i.ownKeys?i.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var a=Number.isNaN||function(e){return e!=e};function s(){s.init.call(this)}e.exports=s,s.EventEmitter=s,s.prototype._events=void 0,s.prototype._eventsCount=0,s.prototype._maxListeners=void 0;var c=10;function u(e){return void 0===e._maxListeners?s.defaultMaxListeners:e._maxListeners}function d(e,t,r,n){var i,o,a,s;if("function"!=typeof r)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof r);if(void 0===(o=e._events)?(o=e._events=Object.create(null),e._eventsCount=0):(void 0!==o.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),o=e._events),a=o[t]),void 0===a)a=o[t]=r,++e._eventsCount;else if("function"==typeof a?a=o[t]=n?[r,a]:[a,r]:n?a.unshift(r):a.push(r),(i=u(e))>0&&a.length>i&&!a.warned){a.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=e,c.type=t,c.count=a.length,s=c,console&&console.warn&&console.warn(s)}return e}function f(){for(var e=[],t=0;t0&&(a=t[0]),a instanceof Error)throw a;var s=new Error("Unhandled error."+(a?" ("+a.message+")":""));throw s.context=a,s}var c=i[e];if(void 0===c)return!1;if("function"==typeof c)o(c,this,t);else{var u=c.length,d=h(c,u);for(r=0;r=0;o--)if(r[o]===t||r[o].listener===t){a=r[o].listener,i=o;break}if(i<0)return this;0===i?r.shift():function(e,t){for(;t+1=0;n--)this.removeListener(e,t[n]);return this},s.prototype.listeners=function(e){return l(this,e,!0)},s.prototype.rawListeners=function(e){return l(this,e,!1)},s.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):m.call(e,t)},s.prototype.listenerCount=m,s.prototype.eventNames=function(){return this._eventsCount>0?n(this._events):[]}},function(e,t,r){"use strict";var n={generateIdentifier:function(){return Math.random().toString(36).substr(2,10)}};n.localCName=n.generateIdentifier(),n.splitLines=function(e){return e.trim().split("\n").map((function(e){return e.trim()}))},n.splitSections=function(e){return e.split("\nm=").map((function(e,t){return(t>0?"m="+e:e).trim()+"\r\n"}))},n.getDescription=function(e){var t=n.splitSections(e);return t&&t[0]},n.getMediaSections=function(e){var t=n.splitSections(e);return t.shift(),t},n.matchPrefix=function(e,t){return n.splitLines(e).filter((function(e){return 0===e.indexOf(t)}))},n.parseCandidate=function(e){for(var t,r={foundation:(t=0===e.indexOf("a=candidate:")?e.substring(12).split(" "):e.substring(10).split(" "))[0],component:parseInt(t[1],10),protocol:t[2].toLowerCase(),priority:parseInt(t[3],10),ip:t[4],address:t[4],port:parseInt(t[5],10),type:t[7]},n=8;n0?t[0].split("/")[1]:"sendrecv",uri:t[1]}},n.writeExtmap=function(e){return"a=extmap:"+(e.id||e.preferredId)+(e.direction&&"sendrecv"!==e.direction?"/"+e.direction:"")+" "+e.uri+"\r\n"},n.parseFmtp=function(e){for(var t,r={},n=e.substr(e.indexOf(" ")+1).split(";"),i=0;i-1?(r.attribute=e.substr(t+1,n-t-1),r.value=e.substr(n+1)):r.attribute=e.substr(t+1),r},n.parseSsrcGroup=function(e){var t=e.substr(13).split(" ");return{semantics:t.shift(),ssrcs:t.map((function(e){return parseInt(e,10)}))}},n.getMid=function(e){var t=n.matchPrefix(e,"a=mid:")[0];if(t)return t.substr(6)},n.parseFingerprint=function(e){var t=e.substr(14).split(" ");return{algorithm:t[0].toLowerCase(),value:t[1]}},n.getDtlsParameters=function(e,t){return{role:"auto",fingerprints:n.matchPrefix(e+t,"a=fingerprint:").map(n.parseFingerprint)}},n.writeDtlsParameters=function(e,t){var r="a=setup:"+t+"\r\n";return e.fingerprints.forEach((function(e){r+="a=fingerprint:"+e.algorithm+" "+e.value+"\r\n"})),r},n.parseCryptoLine=function(e){var t=e.substr(9).split(" ");return{tag:parseInt(t[0],10),cryptoSuite:t[1],keyParams:t[2],sessionParams:t.slice(3)}},n.writeCryptoLine=function(e){return"a=crypto:"+e.tag+" "+e.cryptoSuite+" "+("object"==typeof e.keyParams?n.writeCryptoKeyParams(e.keyParams):e.keyParams)+(e.sessionParams?" "+e.sessionParams.join(" "):"")+"\r\n"},n.parseCryptoKeyParams=function(e){if(0!==e.indexOf("inline:"))return null;var t=e.substr(7).split("|");return{keyMethod:"inline",keySalt:t[0],lifeTime:t[1],mkiValue:t[2]?t[2].split(":")[0]:void 0,mkiLength:t[2]?t[2].split(":")[1]:void 0}},n.writeCryptoKeyParams=function(e){return e.keyMethod+":"+e.keySalt+(e.lifeTime?"|"+e.lifeTime:"")+(e.mkiValue&&e.mkiLength?"|"+e.mkiValue+":"+e.mkiLength:"")},n.getCryptoParameters=function(e,t){return n.matchPrefix(e+t,"a=crypto:").map(n.parseCryptoLine)},n.getIceParameters=function(e,t){var r=n.matchPrefix(e+t,"a=ice-ufrag:")[0],i=n.matchPrefix(e+t,"a=ice-pwd:")[0];return r&&i?{usernameFragment:r.substr(12),password:i.substr(10)}:null},n.writeIceParameters=function(e){return"a=ice-ufrag:"+e.usernameFragment+"\r\na=ice-pwd:"+e.password+"\r\n"},n.parseRtpParameters=function(e){for(var t={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},r=n.splitLines(e)[0].split(" "),i=3;i0?"9":"0",r+=" UDP/TLS/RTP/SAVPF ",r+=t.codecs.map((function(e){return void 0!==e.preferredPayloadType?e.preferredPayloadType:e.payloadType})).join(" ")+"\r\n",r+="c=IN IP4 0.0.0.0\r\n",r+="a=rtcp:9 IN IP4 0.0.0.0\r\n",t.codecs.forEach((function(e){r+=n.writeRtpMap(e),r+=n.writeFmtp(e),r+=n.writeRtcpFb(e)}));var i=0;return t.codecs.forEach((function(e){e.maxptime>i&&(i=e.maxptime)})),i>0&&(r+="a=maxptime:"+i+"\r\n"),r+="a=rtcp-mux\r\n",t.headerExtensions&&t.headerExtensions.forEach((function(e){r+=n.writeExtmap(e)})),r},n.parseRtpEncodingParameters=function(e){var t,r=[],i=n.parseRtpParameters(e),o=-1!==i.fecMechanisms.indexOf("RED"),a=-1!==i.fecMechanisms.indexOf("ULPFEC"),s=n.matchPrefix(e,"a=ssrc:").map((function(e){return n.parseSsrcMedia(e)})).filter((function(e){return"cname"===e.attribute})),c=s.length>0&&s[0].ssrc,u=n.matchPrefix(e,"a=ssrc-group:FID").map((function(e){return e.substr(17).split(" ").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 n={ssrc:c,codecPayloadType:parseInt(e.parameters.apt,10)};c&&t&&(n.rtx={ssrc:t}),r.push(n),o&&((n=JSON.parse(JSON.stringify(n))).fec={ssrc:c,mechanism:a?"red+ulpfec":"red"},r.push(n))}})),0===r.length&&c&&r.push({ssrc:c});var d=n.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,r.forEach((function(e){e.maxBitrate=d}))),r},n.parseRtcpParameters=function(e){var t={},r=n.matchPrefix(e,"a=ssrc:").map((function(e){return n.parseSsrcMedia(e)})).filter((function(e){return"cname"===e.attribute}))[0];r&&(t.cname=r.value,t.ssrc=r.ssrc);var i=n.matchPrefix(e,"a=rtcp-rsize");t.reducedSize=i.length>0,t.compound=0===i.length;var o=n.matchPrefix(e,"a=rtcp-mux");return t.mux=o.length>0,t},n.parseMsid=function(e){var t,r=n.matchPrefix(e,"a=msid:");if(1===r.length)return{stream:(t=r[0].substr(7).split(" "))[0],track:t[1]};var i=n.matchPrefix(e,"a=ssrc:").map((function(e){return n.parseSsrcMedia(e)})).filter((function(e){return"msid"===e.attribute}));return i.length>0?{stream:(t=i[0].value.split(" "))[0],track:t[1]}:void 0},n.parseSctpDescription=function(e){var t,r=n.parseMLine(e),i=n.matchPrefix(e,"a=max-message-size:");i.length>0&&(t=parseInt(i[0].substr(19),10)),isNaN(t)&&(t=65536);var o=n.matchPrefix(e,"a=sctp-port:");if(o.length>0)return{port:parseInt(o[0].substr(12),10),protocol:r.fmt,maxMessageSize:t};if(n.matchPrefix(e,"a=sctpmap:").length>0){var a=n.matchPrefix(e,"a=sctpmap:")[0].substr(10).split(" ");return{port:parseInt(a[0],10),protocol:a[1],maxMessageSize:t}}},n.writeSctpDescription=function(e,t){var r=[];return r="DTLS/SCTP"!==e.protocol?["m="+e.kind+" 9 "+e.protocol+" "+t.protocol+"\r\n","c=IN IP4 0.0.0.0\r\n","a=sctp-port:"+t.port+"\r\n"]:["m="+e.kind+" 9 "+e.protocol+" "+t.port+"\r\n","c=IN IP4 0.0.0.0\r\n","a=sctpmap:"+t.port+" "+t.protocol+" 65535\r\n"],void 0!==t.maxMessageSize&&r.push("a=max-message-size:"+t.maxMessageSize+"\r\n"),r.join("")},n.generateSessionId=function(){return Math.random().toString().substr(2,21)},n.writeSessionBoilerplate=function(e,t,r){var i=void 0!==t?t:2;return"v=0\r\no="+(r||"thisisadapterortc")+" "+(e||n.generateSessionId())+" "+i+" IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\n"},n.writeMediaSection=function(e,t,r,i){var o=n.writeRtpDescription(e.kind,t);if(o+=n.writeIceParameters(e.iceGatherer.getLocalParameters()),o+=n.writeDtlsParameters(e.dtlsTransport.getLocalParameters(),"offer"===r?"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:"+n.localCName+"\r\n",e.rtpSender&&e.sendEncodingParameters[0].rtx&&(o+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" cname:"+n.localCName+"\r\n"),o},n.getDirection=function(e,t){for(var r=n.splitLines(e),i=0;i921600?u.ENUM_VP_LEVEL.hdp:t>230400?u.ENUM_VP_LEVEL.hd:u.ENUM_VP_LEVEL.sd}t.getVP=m;var h=!1;window.process&&window.process.versions&&void 0!==window.process.versions.electron&&null!==window.process.versions.electron&&(h=!0);var v=function(e){function t(t,r,n){var i=e.call(this,n)||this;return i.status=u.ENUM_PUBLISH_STATUS.unpublish,i.audioType=f.ENUM_AUDIO_TYPE.none,i.videoType=f.ENUM_VIDEO_TYPE.none,i.vp=u.ENUM_VP_LEVEL.none,i.userId=t,i.streamType=u.ENUM_STREAM_TYPE.publish,i.mediaType=r.mediaType,i.muteaudio=!1,i.mutevideo=!1,i.audioMuted=!1,i.videoMuted=!1,i.config=r,r.audio&&(i.audioType=f.ENUM_AUDIO_TYPE.microphone),r.video&&(i.videoType=f.ENUM_VIDEO_TYPE.camera),r.screen&&!r.audio&&r.screenAudio&&(i.audioType=f.ENUM_AUDIO_TYPE.screen),r.screen&&!r.video&&(i.videoType=f.ENUM_VIDEO_TYPE.screen),i}return n.__extends(t,e),Object.defineProperty(t.prototype,"audio",{get:function(){return this.config.audio||this.audioType!==f.ENUM_AUDIO_TYPE.none},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"video",{get:function(){return this.config.video||this.videoType!==f.ENUM_VIDEO_TYPE.none},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isPreview",{get:function(){return!!this.previewId&&this.previewId===this.streamId},enumerable:!0,configurable:!0}),t.prototype.hasAudio=function(){var e;return!!(this.audioHelper&&(null===(e=this.audioHelper)||void 0===e?void 0:e.srcAudioTrack))},t.prototype.hasVideo=function(){var e;return!!(this.videoHelper&&(null===(e=this.videoHelper)||void 0===e?void 0:e.srcVideoTrack))},t.prototype.updateVP=function(){this.vp=m(this.resolution.attributes)},Object.defineProperty(t.prototype,"canUnPublish",{get:function(){var e=!0;switch(this.status){case u.ENUM_PUBLISH_STATUS.unpublish:case u.ENUM_PUBLISH_STATUS.publishing:case u.ENUM_PUBLISH_STATUS.unpublishing:case u.ENUM_PUBLISH_STATUS.republishing:e=!1;break;case u.ENUM_PUBLISH_STATUS.published:default:e=!0}return e},enumerable:!0,configurable:!0}),t.prototype.applyResolution=function(e){return n.__awaiter(this,void 0,void 0,(function(){var t,r,i,o,a,s;return n.__generator(this,(function(n){if(!(t=this.getVideoTrack()))throw l.createError(l.ErrorCodes.OTHERS,"no video track found");if(this.imageStream){if(r=this.imageStream,i=e.attributes,o=this.imageStream.clone(i.videoWidth,i.videoHeight,i.maxFrameRate),!(a=o.mediaStream)||!a.getVideoTracks()[0])throw o.destroy(),l.createError(l.ErrorCodes.OTHERS,"cannot create media stream by image");s=a.getVideoTracks()[0];try{this.replaceVideoTrack(s,!0)}catch(e){throw o.destroy(),e}this.imageStream=o,r.destroy()}else t.applyConstraints(e.video);return[2]}))}))},t.prototype.getScreenMediaStream=function(e){return n.__awaiter(this,void 0,void 0,(function(){var t,r,i,a,s,c,u,f,p,m;return n.__generator(this,(function(n){switch(n.label){case 0:if(t=e.width,r=e.height,i=e.frameRate,a=this.config,!d.default.isChrome()||!a.extensionId)return[3,5];n.label=1;case 1:return n.trys.push([1,3,,4]),[4,new Promise((function(e,n){window.chrome.runtime.sendMessage(a.extensionId,{},(function(a){if(o.default.debug("local stream (chrome extension) response ",a),!a){var s=l.createError(l.ErrorCodes.OTHERS,"chrome extension - no response");return n(s)}if("success"!==a.type){s=l.createError(l.ErrorCodes.OTHERS,"chrome extension - response error");return n(s)}var c=a.options,u={audio:!!(void 0===c?{canRequestAudioTrack:!1}:c).canRequestAudioTrack&&{mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:a.streamId}},video:{mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:a.streamId,maxWidth:t,maxHeight:r,maxFrameRate:i}}};if(navigator.mediaDevices.getUserMedia)navigator.mediaDevices.getUserMedia(u).then(e).catch(n);else if(navigator.webkitGetUserMedia)navigator.webkitGetUserMedia(u,e,n);else{s=l.createError(l.ErrorCodes.NOT_SUPPORT,"browser no support screen share");n(s)}}))}))];case 2:return s=n.sent(),o.default.debug("local stream (chrome extension) - ",s),[3,4];case 3:throw c=n.sent(),o.default.warn("chrome extend stream - get screen "+c),c;case 4:return[3,17];case 5:if(!navigator.mediaDevices.getDisplayMedia)return[3,16];n.label=6;case 6:return n.trys.push([6,8,,15]),f={video:{width:{ideal:t},height:{ideal:r},frameRate:i}},this.config.screenAudio&&(f.audio=!0),[4,navigator.mediaDevices.getDisplayMedia(f)];case 7:return s=n.sent(),o.default.debug("local stream - ",s),[3,15];case 8:if(u=n.sent(),o.default.warn("local stream - get screen with video constraints "+u),!(u.message.indexOf("Audio only requests are not supported")>=0))return[3,13];n.label=9;case 9:return n.trys.push([9,11,,12]),f={video:!0},this.config.screenAudio&&(f.audio=!0),[4,navigator.mediaDevices.getDisplayMedia(f)];case 10:return s=n.sent(),[3,12];case 11:throw p=n.sent(),o.default.warn("local stream - get screen without video constraints "+p),u;case 12:return[3,14];case 13:throw u;case 14:return[3,15];case 15:return[3,17];case 16:throw m=l.createError(l.ErrorCodes.NOT_SUPPORT,"browser no support screen share"),o.default.warn("local stream - get screen "+m),m;case 17:return[2,s]}}))}))},t.prototype.getElectronScreenMediaStream=function(e){return n.__awaiter(this,void 0,void 0,(function(){var t,r;return n.__generator(this,(function(n){switch(n.label){case 0:return(t=this.config).screenAudio&&d.default.isMacOS()&&o.default.warn("cannot get screen audio source when share screen in MacOS"),r={audio:!d.default.isMacOS()&&(t.screenAudio&&{mandatory:{chromeMediaSource:"desktop"}}),video:{mandatory:{chromeMediaSource:"desktop",maxWidth:e.width,maxHeight:e.height,maxFrameRate:e.frameRate}}},[4,navigator.mediaDevices.getUserMedia(r)];case 1:return[2,n.sent()]}}))}))},t.prototype.addTracks2MediaStream=function(){var e,t;return n.__awaiter(this,void 0,void 0,(function(){var r,i,u,d,p,l,m,v,g,y,E,b,_,S,T,w,R,M,C,P,O,I=this;return n.__generator(this,(function(n){switch(n.label){case 0:if(r=this.config,i={audio:!1},u={video:!1},r.audio&&r.microphoneId?i.audio={deviceId:{exact:r.microphoneId}}:r.audio&&(i.audio=!0),d=this.resolution,p=d.video,l=d.attributes,r.video&&r.cameraId?u.video={deviceId:r.cameraId,width:p.width,height:p.height,frameRate:p.frameRate}:r.video&&(u.video={width:p.width,height:p.height,frameRate:p.frameRate},r.facingMode&&(u.video.facingMode={exact:r.facingMode})),i.audio&&u.video||!r.screen)return[3,7];n.label=1;case 1:return n.trys.push([1,6,,7]),h?[4,this.getElectronScreenMediaStream({width:l.videoWidth,height:l.videoHeight,frameRate:l.maxFrameRate})]:[3,3];case 2:return m=n.sent(),[3,5];case 3:return[4,this.getScreenMediaStream({width:l.videoWidth,height:l.videoHeight,frameRate:l.maxFrameRate})];case 4:m=n.sent(),n.label=5;case 5:return m.getTracks().forEach((function(e){o.default.debug("local stream - add screen track ",e);var t=I;if(e.onended=function(e){o.default.debug("screen track ended ",this.readyState,e),"video"===this.kind&&t.getVideoTrack()===this&&t.emitter&&t.emitter.emit("screen-track-ended",t)},"audio"===e.kind&&!r.audio){I.audioHelper=new a.AudioHelper(e);var n=I.getAudioTrack();n&&I.mediaStream.addTrack(n),I.audioType=f.ENUM_AUDIO_TYPE.screen}"video"!==e.kind||r.video||(I.videoHelper=new s.VideoHelper(e,I.resolution.attributes),I.mediaStream.addTrack(e),I.videoType=f.ENUM_VIDEO_TYPE.screen)})),[3,7];case 6:throw v=n.sent(),o.default.error("local stream - get screen "+v),v;case 7:if(g=new MediaStream,!i.audio||!u.video)return[3,21];n.label=8;case 8:return n.trys.push([8,10,,20]),y=Object.assign({},i,u),[4,navigator.mediaDevices.getUserMedia(y)];case 9:return g=n.sent(),[3,20];case 10:if(E=n.sent(),!["AbortError","NotAllowedError","NotFoundError","NotReadableError","OverConstrainedError"].includes(E.name))return[3,18];b=void 0,_=void 0,S=navigator.mediaDevices.getUserMedia(i),T=navigator.mediaDevices.getUserMedia(u),w=void 0,R=void 0,n.label=11;case 11:return n.trys.push([11,13,,14]),[4,S];case 12:return w=n.sent().getTracks(),[3,14];case 13:return M=n.sent(),b=M,[3,14];case 14:return n.trys.push([14,16,,17]),[4,T];case 15:return R=n.sent().getTracks(),[3,17];case 16:return C=n.sent(),_=C,[3,17];case 17:if(null===(e=w)||void 0===e||e.forEach((function(e){return g.addTrack(e)})),null===(t=R)||void 0===t||t.forEach((function(e){return g.addTrack(e)})),b&&_)throw o.default.warn("local stream - retry get media "+E),this.logReporter&&this.logReporter.reportExceptionLog(c.ENUM_LOG_EXCEPTION_TYPE.getMicrophones,{msg:""+b}),this.logReporter&&this.logReporter.reportExceptionLog(c.ENUM_LOG_EXCEPTION_TYPE.getCameras,{msg:""+_}),E;return b?(o.default.warn("get media stream from microphone error, audio will not be published, "+b),o.default.report("get media stream from microphone error, audio will not be published, "+b)):_&&(o.default.warn("get media stream from camera error, video will not be published, "+_),o.default.report("get media stream from camera error, video will not be published, "+_)),[3,19];case 18:throw o.default.warn("local stream - get media "+E),this.logReporter&&this.logReporter.reportExceptionLog(c.ENUM_LOG_EXCEPTION_TYPE.getMicrophones,{msg:""+E}),this.logReporter&&this.logReporter.reportExceptionLog(c.ENUM_LOG_EXCEPTION_TYPE.getCameras,{msg:""+E}),E;case 19:return[3,20];case 20:return[3,30];case 21:if(!i.audio)return[3,26];n.label=22;case 22:return n.trys.push([22,24,,25]),[4,navigator.mediaDevices.getUserMedia(i)];case 23:return g=n.sent(),[3,25];case 24:if(P=n.sent(),!["AbortError","NotAllowedError","NotFoundError","NotReadableError","OverConstrainedError"].includes(P.name)||!this.config.screen)throw o.default.warn("local stream - get media "+P),this.logReporter&&this.logReporter.reportExceptionLog(c.ENUM_LOG_EXCEPTION_TYPE.getMicrophones,{msg:""+P}),P;return o.default.warn("get media stream from microphone error, audio will not be published, "+P),o.default.report("get media stream from microphone error, audio will not be published, "+P),[3,25];case 25:return[3,30];case 26:if(!u.video)return[3,30];n.label=27;case 27:return n.trys.push([27,29,,30]),[4,navigator.mediaDevices.getUserMedia(u)];case 28:return g=n.sent(),[3,30];case 29:throw O=n.sent(),o.default.warn("local stream - get media "+O),this.logReporter&&this.logReporter.reportExceptionLog(c.ENUM_LOG_EXCEPTION_TYPE.getCameras,{msg:""+O}),O;case 30:return g.getTracks().forEach((function(e){if(o.default.debug("local stream - add track ",e),"audio"===e.kind){I.audioHelper=new a.AudioHelper(e);var t=I.getAudioTrack();t&&I.mediaStream.addTrack(t),I.audioType=f.ENUM_AUDIO_TYPE.microphone}"video"===e.kind&&(I.videoHelper=new s.VideoHelper(e,I.resolution.attributes),I.mediaStream.addTrack(e),I.videoType=f.ENUM_VIDEO_TYPE.camera)})),[2]}}))}))},t.prototype.addTracks2MediaStream2=function(e){var t=this;return new Promise((function(r){e.getTracks().forEach((function(e){if(o.default.debug("local stream - add track ",e),"audio"===e.kind){t.audioHelper=new a.AudioHelper(e);var r=t.getAudioTrack();r&&t.mediaStream.addTrack(r),t.audioType=f.ENUM_AUDIO_TYPE.custom}"video"===e.kind&&(t.videoHelper=new s.VideoHelper(e,t.resolution.attributes),t.mediaStream.addTrack(e),t.videoType=f.ENUM_VIDEO_TYPE.custom)})),r()}))},t.prototype.addTracks2MediaStream3=function(e){return n.__awaiter(this,void 0,void 0,(function(){var t,r,i,u,d,p,m,h,v,g,y=this;return n.__generator(this,(function(n){switch(n.label){case 0:if(t=this.config,r={audio:!1,video:!1},t.audio&&t.microphoneId?r.audio={deviceId:{exact:t.microphoneId}}:t.audio&&(r.audio=!0),!r.audio)return[3,4];n.label=1;case 1:return n.trys.push([1,3,,4]),[4,navigator.mediaDevices.getUserMedia(r)];case 2:return(v=n.sent()).getTracks().forEach((function(e){if(o.default.debug("local stream - add track ",e),"audio"===e.kind){y.audioHelper=new a.AudioHelper(e);var t=y.getAudioTrack();t&&y.mediaStream.addTrack(t),y.audioType=f.ENUM_AUDIO_TYPE.microphone}})),[3,4];case 3:throw i=n.sent(),r.audio&&this.logReporter&&this.logReporter.reportExceptionLog(c.ENUM_LOG_EXCEPTION_TYPE.getMicrophones,{msg:""+i}),o.default.warn("local stream - get image stream "+i),i;case 4:return n.trys.push([4,6,,7]),u=this.resolution.attributes,d=u.videoWidth,p=u.videoHeight,m=u.maxFrameRate,h=this,[4,s.VideoHelper.createImageStream(e,d,p,m)];case 5:if(h.imageStream=n.sent(),!(v=this.imageStream.mediaStream)||!v.getVideoTracks()[0])throw this.destroyImageStream(),l.createError(l.ErrorCodes.CREATE_STREAM,"cannot create media stream by image");return this.videoHelper=new s.VideoHelper(v.getVideoTracks()[0],this.resolution.attributes),this.mediaStream.addTrack(v.getVideoTracks()[0]),this.videoType=f.ENUM_VIDEO_TYPE.image,[3,7];case 6:throw g=n.sent(),o.default.error("local stream - get image stream "+g),g;case 7:return[2]}}))}))},t.prototype.addTracks2MediaStream4=function(e){var t=this;return new Promise((function(r){e.audioHelper&&(t.audioHelper=e.audioHelper,(n=e.getAudioTrack())&&t.mediaStream.addTrack(n),t.audioType=e.audioType);if(e.videoHelper){var n;if(t.videoHelper=e.videoHelper,n=e.getVideoTrack()){if(e.videoType===f.ENUM_VIDEO_TYPE.screen){var i=t;n.onended=function(e){o.default.debug("screen track ended ",this.readyState,e),"video"===this.kind&&i.getVideoTrack()===this&&i.emitter&&i.emitter.emit("screen-track-ended",i)}}t.mediaStream.addTrack(n)}t.videoType=e.videoType}e.imageStream&&(t.imageStream=e.imageStream),t.resolution=e.resolution,r()}))},t.prototype.init=function(e,t){var r=this;return new Promise((function(i,o){return n.__awaiter(r,void 0,void 0,(function(){var r;return n.__generator(this,(function(n){switch(n.label){case 0:this.isPreview||this.initConnection(),this.initMediaStream(),n.label=1;case 1:return n.trys.push([1,10,,11]),t?(this.previewId=t.previewId,this.muteaudio=t.muteaudio,this.mutevideo=t.mutevideo,this.audioMuted=t.audioMuted,this.videoMuted=t.videoMuted,[4,this.addTracks2MediaStream4(t)]):[3,3];case 2:return n.sent(),[3,9];case 3:return e.mediaStream?[4,this.addTracks2MediaStream2(e.mediaStream)]:[3,5];case 4:return n.sent(),[3,9];case 5:return e.file||e.filePath?[4,this.addTracks2MediaStream3(e.file||e.filePath)]:[3,7];case 6:return n.sent(),[3,9];case 7:return[4,this.addTracks2MediaStream()];case 8:n.sent(),n.label=9;case 9:return[3,11];case 10:return r=n.sent(),[2,o(r)];case 11:return this.isPreview||this.addTracks2PeerConnection(),i(this.mediaStream),[2]}}))}))}))},t.prototype.initMediaStream=function(){var e,t=new MediaStream;this.audioHelper&&((e=this.getAudioTrack())&&t.addTrack(e));this.videoHelper&&((e=this.videoHelper.dstVideoTrack)&&t.addTrack(e));this.mediaStream=t},t.prototype.addTracks2PeerConnection=function(){var e,t=new MediaStream;this.audioHelper&&((e=this.getAudioTrack())&&(t.addTrack(e),this.peerConnection&&this.peerConnection.addTrack(e,t)));this.videoHelper&&((e=this.videoHelper.dstVideoTrack)&&(t.addTrack(e),this.peerConnection&&this.peerConnection.addTrack(e,t)))},t.prototype.connect=function(e){return n.__awaiter(this,void 0,void 0,(function(){var t,r,i;return n.__generator(this,(function(n){switch(n.label){case 0:this.streamId=e,n.label=1;case 1:if(n.trys.push([1,4,,5]),!this.peerConnection)throw l.createError(l.ErrorCodes.OTHERS,"no peerconnection");if(!this.videoCodec)throw l.createError(l.ErrorCodes.OTHERS,"no video codec settings");return[4,this.peerConnection.createOffer({offerToReceiveAudio:this.audio,offerToReceiveVideo:this.video})];case 2:return t=n.sent(),r=this.resolution.attributes,t.sdp&&this.video&&(t.sdp=p.replaceSDPVideoBW(t.sdp,this.videoCodec,r),t.sdp=p.replaceSDPH264Part(t.sdp,this.videoCodec)),t.sdp&&this.video&&this.videoCodec&&(t.sdp=p.handleSDPVideoCodec(t.sdp,this.videoCodec)),t.sdp&&this.audio&&(t.sdp=p.handleSDPAudioCodec(t.sdp)),[4,this.peerConnection.setLocalDescription(t)];case 3:return n.sent(),[2,t];case 4:throw i=n.sent(),o.default.error("peerconnection create offer error "+i),i;case 5:return[2]}}))}))},t.prototype.setStatusAsDone=function(){this.status=u.ENUM_PUBLISH_STATUS.published},t.prototype.close=function(e){this.destroyImageStream(e),this._close(e),this.status=u.ENUM_PUBLISH_STATUS.unpublish},t.prototype.destroyImageStream=function(e){this.imageStream&&!e&&this.imageStream.destroy(),this.imageStream=void 0},t.prototype.switchMicrophone=function(e){var t;return n.__awaiter(this,void 0,void 0,(function(){var r,i,a,s,c;return n.__generator(this,(function(n){switch(n.label){case 0:if(!this.audio)throw a="stream does not include audio track, cannot switch microphone",o.default.warn("switch microphone - ",a),l.createError(l.ErrorCodes.OTHERS,a);if(this.status!==u.ENUM_PUBLISH_STATUS.unpublish&&!this.hasAudio())throw l.createError(l.ErrorCodes.AUDIO_TRACK_NOT_EXISTS,"cannot find audio track to be replaced");if(!(null===(t=this.audioHelper)||void 0===t?void 0:t.canSwitchMicrophone()))throw l.createError(l.ErrorCodes.NOT_SUPPORT,"cannot switch microphone when effect is playing");n.label=1;case 1:return n.trys.push([1,3,,4]),[4,navigator.mediaDevices.getUserMedia({audio:{deviceId:{exact:e}}})];case 2:if(r=n.sent(),!(i=r.getAudioTracks()[0]))throw a="no audio track, cannot switch microphone",o.default.warn("switch microphone - ",a),l.createError(l.ErrorCodes.OTHERS,a);return(s=this.audioHelper&&this.audioHelper.updateAudioSourceTrack(i))&&s.stop(),this.config.microphoneId=e,this.audioType=f.ENUM_AUDIO_TYPE.microphone,[3,4];case 3:throw c=n.sent(),o.default.error("switch microphone - "+c),c;case 4:return[2]}}))}))},t.prototype.switchCamera=function(e){var t;return n.__awaiter(this,void 0,void 0,(function(){var r,i,a,s,c,d,p,m;return n.__generator(this,(function(n){switch(n.label){case 0:if(!this.video)throw r="stream does not include video track, cannot switch camera",o.default.warn("switch camera - ",r),l.createError(l.ErrorCodes.OTHERS,r);if(this.status!==u.ENUM_PUBLISH_STATUS.unpublish&&!this.hasVideo())throw l.createError(l.ErrorCodes.VIDEO_TRACK_NOT_EXISTS,"cannot find video track to be replaced");if(this.mediaType!==u.ENUM_MEDIA_TYPE.camera)throw r="the mediaType of current stream isnot camera, cannot switch",o.default.warn("switch camera - ",r),l.createError(l.ErrorCodes.OTHERS,r);n.label=1;case 1:n.trys.push([1,11,,12]),i=this.resolution.video,a={video:{deviceId:{exact:e},width:i.width,height:i.height,frameRate:i.frameRate}},s=void 0,n.label=2;case 2:return n.trys.push([2,4,,10]),[4,navigator.mediaDevices.getUserMedia(a)];case 3:return d=n.sent(),s=d.getVideoTracks()[0],[3,10];case 4:return"OverConstrainedError"!==(c=n.sent()).name?[3,6]:(o.default.warn("switch camera - ",c," try to use unstrict deviceId"),a.video.deviceId=e,[4,navigator.mediaDevices.getUserMedia(a)]);case 5:return d=n.sent(),s=d.getVideoTracks()[0],[3,9];case 6:return"NotReadableError"!==c.name?[3,8]:[4,this.forceSwitchCamera(e)];case 7:return m=n.sent(),e=m[0],s=m[1],[3,9];case 8:throw c;case 9:return[3,10];case 10:this.destroyImageStream();try{this.replaceVideoTrack(s)}catch(e){throw null===(t=s)||void 0===t||t.stop(),e}return this.config.cameraId=e,this.videoType=f.ENUM_VIDEO_TYPE.camera,[3,12];case 11:throw p=n.sent(),o.default.error("switch camera - "+p),p;case 12:return[2]}}))}))},t.prototype.forceSwitchCamera=function(e){return n.__awaiter(this,void 0,void 0,(function(){var t,r,i,a,s,c;return n.__generator(this,(function(n){switch(n.label){case 0:t=this.resolution.video,r={video:{deviceId:{exact:e},width:t.width,height:t.height,frameRate:t.frameRate}},i=this.getVideoTrack(),a=i.getSettings().deviceId,i.stop(),n.label=1;case 1:return n.trys.push([1,3,,5]),[4,navigator.mediaDevices.getUserMedia(r)];case 2:return s=n.sent(),[3,5];case 3:return c=n.sent(),o.default.error("force switch camera - ",c),r.video.deviceId=a,e=a,[4,navigator.mediaDevices.getUserMedia(r)];case 4:return s=n.sent(),[3,5];case 5:return[2,[e,s.getVideoTracks()[0]]]}}))}))},t.prototype.switchScreen=function(){return n.__awaiter(this,void 0,void 0,(function(){var e,t,r,i,a=this;return n.__generator(this,(function(n){switch(n.label){case 0:if(!this.video)throw e="stream does not include video track, cannot switch screen",o.default.warn("switch screen - ",e),l.createError(l.ErrorCodes.OTHERS,e);if(this.status!==u.ENUM_PUBLISH_STATUS.unpublish&&!this.hasVideo())throw l.createError(l.ErrorCodes.VIDEO_TRACK_NOT_EXISTS,"cannot find video track to be replaced");if(this.mediaType!==u.ENUM_MEDIA_TYPE.desktop)throw e="the mediaType of current stream isnot screen, cannot switch",o.default.warn("switch screen - ",e),l.createError(l.ErrorCodes.OTHERS,e);t=this.resolution.attributes,n.label=1;case 1:return n.trys.push([1,6,,7]),h?[4,this.getElectronScreenMediaStream({width:t.videoWidth,height:t.videoHeight,frameRate:t.maxFrameRate})]:[3,3];case 2:return r=n.sent(),[3,5];case 3:return[4,this.getScreenMediaStream({width:t.videoWidth,height:t.videoHeight,frameRate:t.maxFrameRate})];case 4:r=n.sent(),n.label=5;case 5:return r.getTracks().forEach((function(e){var t;o.default.debug("local stream - add screen track ",e);var r=a;if(e.onended=function(e){o.default.debug("screen track ended ",this.readyState,e),"video"===this.kind&&r.getVideoTrack()===this&&r.emitter&&r.emitter.emit("screen-track-ended",r)},"audio"===e.kind&&a.audio&&a.audioHelper){var n=a.audioHelper.updateAudioSourceTrack(e);n&&n.stop(),a.audioType=f.ENUM_AUDIO_TYPE.screen}if("video"===e.kind&&a.video){a.destroyImageStream();try{a.replaceVideoTrack(e)}catch(r){throw null===(t=e)||void 0===t||t.stop(),o.default.warn("switch screen - "+r),l.createError(l.ErrorCodes.STREAM_NOT_EXISTS,"stream may not exists")}a.videoType=f.ENUM_VIDEO_TYPE.screen}})),[3,7];case 6:throw i=n.sent(),o.default.error("switch screen - "+i),i;case 7:return[2]}}))}))},t.prototype.switchImage=function(e){var t;return n.__awaiter(this,void 0,void 0,(function(){var r,i,a,s,c,d;return n.__generator(this,(function(n){switch(n.label){case 0:if(!this.video)throw s="stream does not include video track, cannot switch image",o.default.warn("switch image - ",s),l.createError(l.ErrorCodes.OTHERS,s);if(this.status!==u.ENUM_PUBLISH_STATUS.unpublish&&!this.hasVideo())throw l.createError(l.ErrorCodes.VIDEO_TRACK_NOT_EXISTS,"cannot find video track to be replaced");n.label=1;case 1:if(n.trys.push([1,3,,4]),!this.videoHelper)throw s="the stream has no video",o.default.warn("switch image - ",s),l.createError(l.ErrorCodes.OTHERS,s);return r=this.imageStream,[4,this.videoHelper.createImageStream(e)];case 2:if(i=n.sent(),!(a=i.mediaStream)||!a.getVideoTracks()[0])throw i.destroy(),s=l.createError(l.ErrorCodes.OTHERS,"cannot create media stream by image");c=a.getVideoTracks()[0];try{this.replaceVideoTrack(c,!0)}catch(e){throw i.destroy(),e}return this.imageStream=i,null===(t=r)||void 0===t||t.destroy(),this.videoType=f.ENUM_VIDEO_TYPE.image,[3,4];case 3:throw d=n.sent(),o.default.error("switch image - "+d),d;case 4:return[2]}}))}))},t.prototype.replaceAudioTrack=function(e,t){var r,n=this,i=this.audioHelper&&this.audioHelper.srcAudioTrack;return this.audioHelper&&!this.audioHelper.isTrickMode?this.audioHelper&&this.audioHelper.updateAudioSourceTrack(e):this.peerConnection?this.peerConnection.getSenders().forEach((function(r){var o;r.track&&"audio"===r.track.kind&&(r.replaceTrack(e),i&&n.mediaStream.removeTrack(i),n.mediaStream.addTrack(e),n.audioHelper&&n.audioHelper.updateAudioSourceTrack(e),null===(o=n.player)||void 0===o||o.updateAudioTrack(e),!t&&i&&i.stop())})):(i&&this.mediaStream.removeTrack(i),this.mediaStream.addTrack(e),this.audioHelper&&this.audioHelper.updateAudioSourceTrack(e),null===(r=this.player)||void 0===r||r.updateAudioTrack(e),!t&&i&&i.stop()),i},t.prototype.replaceVideoTrack=function(e,t){var r,n=this,i=this.getVideoTrack();return this.peerConnection?this.peerConnection.getSenders().forEach((function(r){var o;r.track&&"video"===r.track.kind&&(r.replaceTrack(e),i&&n.mediaStream.removeTrack(i),n.mediaStream.addTrack(e),n.videoHelper&&n.videoHelper.updateVideoSourceTrack(e),null===(o=n.player)||void 0===o||o.updateVideoTrack(e),!t&&i&&i.stop())})):(i&&this.mediaStream.removeTrack(i),this.mediaStream.addTrack(e),this.videoHelper&&this.videoHelper.updateVideoSourceTrack(e),null===(r=this.player)||void 0===r||r.updateVideoTrack(e),!t&&i&&i.stop()),i},t.prototype.replaceTrack=function(e,t){try{var r=void 0;if(e&&"audio"===e.kind)r=this.replaceAudioTrack(e,t);else{if(!e||"video"!==e.kind)throw l.createError(l.ErrorCodes.INVALID_PARAMETER,"unsupported track");r=this.replaceVideoTrack(e,t)}return r}catch(e){throw e}},t.prototype.convertToOuterStream=function(){var e;switch(this.mediaType){case u.ENUM_MEDIA_TYPE.desktop:e="screen";break;case u.ENUM_MEDIA_TYPE.camera:default:e="camera"}var t=this.isPreview||this.status!==u.ENUM_PUBLISH_STATUS.unpublish&&this.status!==u.ENUM_PUBLISH_STATUS.unpublishing,r={sid:this.streamId,uid:this.userId,type:"publish",mediaType:e,audio:this.audio,video:this.video,muteAudio:this.muteaudio,muteVideo:this.mutevideo,mediaStream:t?this.mediaStream:void 0,audioMuted:this.audioMuted,videoMuted:this.videoMuted};return this.previewId&&(r.previewId=this.previewId,r.mediaStream=this.mediaStream),r},t.prototype.playEffect=function(e,t,r){var n=this;if(this.audioHelper)if(this.audioHelper.isTrickMode){var i=this.audioHelper.srcAudioTrack;this.audioHelper.once("audio-source-stop",(function(){i&&n.replaceAudioTrack(i)})),this.audioHelper.playAudioSource(e,t).then((function(e){n.replaceAudioTrack(e,!0),r()})).catch((function(e){r(e)}))}else this.audioHelper.playAudioBuffer(e,t).then((function(){r()})).catch((function(e){r(e)}));else{var o=l.createError(l.ErrorCodes.OTHERS,"the stream cannot play audio");r(o)}},t.prototype.pauseEffect=function(e,t){if(this.audioHelper){if(this.audioHelper.isTrickMode){var r=l.createError(l.ErrorCodes.NOT_SUPPORT,"current environment not support pause effect");return o.default.warn("pause effect - "+r),this.logReporter&&this.logReporter.reportExceptionLog(c.ENUM_LOG_EXCEPTION_TYPE.others,{msg:""+r}),t(r)}this.audioHelper.pauseEffect(e).then((function(){t()})).catch((function(e){t(e)}))}else{r=l.createError(l.ErrorCodes.OTHERS,"the stream cannot play audio");t(r)}},t.prototype.resumeEffect=function(e,t,r){if(this.audioHelper){if(this.audioHelper.isTrickMode){var n=l.createError(l.ErrorCodes.NOT_SUPPORT,"current environment not support resume effect");return o.default.warn("resume effect - "+n),this.logReporter&&this.logReporter.reportExceptionLog(c.ENUM_LOG_EXCEPTION_TYPE.others,{msg:""+n}),r(n)}this.audioHelper.resumeEffect(e,t).then((function(){r()})).catch((function(e){r(e)}))}else{n=l.createError(l.ErrorCodes.OTHERS,"the stream cannot play audio");r(n)}},t.prototype.stopEffect=function(e,t){if(this.audioHelper)this.audioHelper.stopEffect(e).then((function(){t()})).catch((function(e){t(e)}));else{var r=l.createError(l.ErrorCodes.OTHERS,"the stream cannot play audio");t(r)}},t.prototype.setEffectVolume=function(e,t,r){if(this.audioHelper)this.audioHelper.setEffectVolume(e,t).then((function(){r()})).catch((function(e){r(e)}));else{var n=l.createError(l.ErrorCodes.OTHERS,"the stream cannot play audio");r(n)}},t}(i.RTCStream);t.LocalStream=v},function(e,t){var r,n,i=e.exports={};function o(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function s(e){if(r===setTimeout)return setTimeout(e,0);if((r===o||!r)&&setTimeout)return r=setTimeout,setTimeout(e,0);try{return r(e,0)}catch(t){try{return r.call(null,e,0)}catch(t){return r.call(this,e,0)}}}!function(){try{r="function"==typeof setTimeout?setTimeout:o}catch(e){r=o}try{n="function"==typeof clearTimeout?clearTimeout:a}catch(e){n=a}}();var c,u=[],d=!1,f=-1;function p(){d&&c&&(d=!1,c.length?u=c.concat(u):f=-1,u.length&&l())}function l(){if(!d){var e=s(p);d=!0;for(var t=u.length;t;){for(c=u,u=[];++f1)for(var r=1;r=80&&(t={sdpSemantics:"unified-plan"}),this.peerConnection=new RTCPeerConnection(t)}else if(a.default.isSafari()||a.default.isOldEdge()){t={bundlePolicy:"max-bundle"};this.peerConnection=new RTCPeerConnection(t)}else this.peerConnection=new RTCPeerConnection;var r=this;this.peerConnection.addEventListener("iceconnectionstatechange",(function(e){var t,n;switch(o.default.debug("iceconnectionstatechange event ",this.iceConnectionState,e,null===(t=r.peerConnection)||void 0===t?void 0:t.iceConnectionState),this.iceConnectionState||(null===(n=r.peerConnection)||void 0===n?void 0:n.iceConnectionState)){case"new":case"connecting":case"checking":case"connected":case"completed":break;case"disconnected":o.default.warn("peerconnection ice disconnected");break;case"failed":o.default.warn("peerconnection ice failed")}})),this.peerConnection.addEventListener("connectionstatechange",(function(e){var t,n;switch(o.default.debug("connectionstatechange event",this.connectionState,e,null===(t=r.peerConnection)||void 0===t?void 0:t.connectionState),this.connectionState||(null===(n=r.peerConnection)||void 0===n?void 0:n.connectionState)){case"new":case"connecting":break;case"connected":r.isEmitted?(r.lastEmitTime=Date.now(),r.emitter&&r.emitter.emit("stream-reconnected",r)):(r.isEmitted=!0,r.lastEmitTime=Date.now(),r.setStatusAsDone(),r.emitter&&r.emitter.emit("stream-connected",r)),r._connectionState=c.ENUM_STREAM_CONNECTION_STATE.connected,r.reconnectTimes=0,r.startUploadStats();break;case"disconnected":o.default.warn("peerconnection disconnected"),r.emitter&&r.emitter.emit("stream-disconnected",r),r.stopUploadStats();break;case"failed":o.default.warn("peerconnection failed"),r.isEmitted||(r.isEmitted=!0,r.lastEmitTime=Date.now(),r.setStatusAsDone(),r.emitter&&r.emitter.emit("stream-connected",r)),r._connectionState=c.ENUM_STREAM_CONNECTION_STATE.disconnected,r.emitter&&r.emitter.emit("stream-failed",r),o.default.debug("peerconnection failed ",r.reconnectTimes,3);break;case"closed":r.stopUploadStats()}}))},Object.defineProperty(e.prototype,"lastOuterStream",{get:function(){return this._lastOuterStream?this._lastOuterStream:this.convertToOuterStream()},enumerable:!0,configurable:!0}),e.prototype.destroyConnection=function(){if(this._lastOuterStream=this.convertToOuterStream(),this.stopUploadStats(),this.peerConnection){var e=this.peerConnection;this.peerConnection=void 0,e.close()}},e.prototype.setResolution=function(e){var t;this.resolution=e,null===(t=this.videoHelper)||void 0===t||t.updateResolutionAttributes(this.resolution.attributes)},Object.defineProperty(e.prototype,"videoTrackSettings",{get:function(){var e=this.getVideoTrack();if(e)return e.getSettings();var t=this.resolution.attributes;return{width:t.videoWidth,height:t.videoHeight}},enumerable:!0,configurable:!0}),e.prototype.restart=function(){return n.__awaiter(this,void 0,void 0,(function(){var e,t;return n.__generator(this,(function(r){switch(r.label){case 0:return this.peerConnection?[4,this.peerConnection.createOffer({iceRestart:!0,offerToReceiveAudio:this.audio,offerToReceiveVideo:this.video})]:[2];case 1:return e=r.sent(),this.isSubscriber||(t=this.resolution.attributes,e.sdp&&this.video&&this.videoCodec&&(e.sdp=u.replaceSDPVideoBW(e.sdp,this.videoCodec,t),e.sdp=u.replaceSDPH264Part(e.sdp,this.videoCodec))),e.sdp&&this.video&&this.videoCodec&&(e.sdp=u.handleSDPVideoCodec(e.sdp,this.videoCodec)),e.sdp&&this.audio&&(e.sdp=u.handleSDPAudioCodec(e.sdp)),o.default.debug("restart sdp ",e.sdp),[4,this.peerConnection.setLocalDescription(e)];case 2:return r.sent(),[2]}}))}))},e.prototype.answer=function(e){return n.__awaiter(this,void 0,void 0,(function(){var t,r;return n.__generator(this,(function(n){return o.default.debug("stream manager answer: ",e),t=u.handleAnswerSDP(e.sdpcontent),r=new RTCSessionDescription({type:e.type,sdp:t}),this.peerConnection?[2,this.peerConnection.setRemoteDescription(r)]:[2,Promise.reject(d.createError(d.ErrorCodes.OTHERS,"no peerconnection"))]}))}))},e.prototype.getAudioTrack=function(){return this.isSubscriber?this.audioHelper&&this.audioHelper.srcAudioTrack:this.audioHelper&&(this.audioHelper.dstAudioTrack||this.audioHelper.srcAudioTrack)},e.prototype.getVideoTrack=function(){return this.mediaStream.getVideoTracks()[0]},e.prototype.muteVideo=function(e){var t=this;this.mutevideo=!0;var r=this.getVideoTrack();if(r){e||(this.videoMuted=!0);var n=function(){var e;t.isSubscriber?(r.enabled=!1,null===(e=t.player)||void 0===e||e.playVideo().catch((function(e){return o.default.warn("mute video - play "+e)})),r.enabled=!0):r.enabled=!1,t.emitter&&t.emitter.emit("video-muted",t)},i=300-(Date.now()-this.lastEmitTime);return!this.isSubscriber&&i>0?setTimeout(n,i):n(),!0}return!1},e.prototype.unmuteVideo=function(e){this.mutevideo=!1;var t=this.getVideoTrack();return!!t&&(e||(this.videoMuted=!1),this.isSubscriber||(t.enabled=!0),this.emitter&&this.emitter.emit("video-unmuted",this),!0)},e.prototype.muteAudio=function(e){this.muteaudio=!0;var t=this.getAudioTrack();return!!t&&(e||(this.audioMuted=!0),this.isSubscriber||(t.enabled=!1),!0)},e.prototype.unmuteAudio=function(e){this.muteaudio=!1;var t=this.getAudioTrack();return!!t&&(e||(this.audioMuted=!1),this.isSubscriber||(t.enabled=!0),!0)},e.prototype.getAudioVolume=function(){var e=0;if(this.audioHelper){var t=this.currentStatsReports2;this.isSubscriber&&t?e=t.audioInputReports.audioLevel>=0?Math.round(100*t.audioInputReports.audioLevel)/100:0:t&&(e=t.audioOutputReports.audioLevel>=0?Math.round(100*t.audioOutputReports.audioLevel)/100:0),e=e||this.audioHelper.getVolume()}return e},e.prototype.setAudioVolume=function(e){if(this.audioHelper)return this.audioHelper.setVolume(e);return Promise.reject(d.createError(d.ErrorCodes.NOT_SUPPORT,"the stream doesnot contain audio or cannot set volume"))},e.prototype.getMediaStream=function(){return this.mediaStream},e.prototype.destroyMediaStream=function(e){var t=this;this.mediaStream.getTracks().forEach((function(e){t.mediaStream.removeTrack(e)})),this.audioHelper&&(e||this.audioHelper.destroy(),this.audioHelper=void 0),this.videoHelper&&(e||this.videoHelper.destroy(),this.videoHelper=void 0)},e.prototype._close=function(e){this.emitter&&this.emitter.emit("stream-close",this),this.destroyMediaStream(e),this.isEmitted=!1,this.reconnectTimes=0,this._connectionState=c.ENUM_STREAM_CONNECTION_STATE.closed,this.destroyConnection()},e.prototype.updateStatsReports2=function(){return n.__awaiter(this,void 0,void 0,(function(){var e,t,r,i;return n.__generator(this,(function(n){switch(n.label){case 0:if(Date.now()-this.currentStatsReports2.timestamp<500)return[2,{last:this.lastStatsReports2,current:this.currentStatsReports2}];if(!this.peerConnection)return[3,5];n.label=1;case 1:return n.trys.push([1,3,,4]),[4,f.getStats(this.peerConnection)];case 2:return e=n.sent(),t=this.currentStatsReports2,this.currentStatsReports2=new s.StatsReports2(e),this.currentStatsReports2.timestamp-t.timestamp>500&&(this.lastStatsReports2=t),[3,4];case 3:throw r=n.sent(),o.default.error("update stats reports - "+r),r;case 4:return[2,{last:this.lastStatsReports2,current:this.currentStatsReports2}];case 5:throw i="no peerconnection",o.default.warn(i),d.createError(d.ErrorCodes.OTHERS,i)}}))}))},e.prototype.getStats2=function(){return n.__awaiter(this,void 0,void 0,(function(){var e,t,r,i,o,a,s,c,u,f,p,l,m,h,v;return n.__generator(this,(function(n){switch(n.label){case 0:return[4,this.updateStatsReports2()];case 1:if(e=n.sent(),t=e.last,r=e.current,i=(i=Math.round((r.timestamp-t.timestamp)/1e3))>0?i:1,!this.audioCodec)throw o="no audio codec settings",d.createError(d.ErrorCodes.OTHERS,o);if(!this.videoCodec)throw o="no video codec settings",d.createError(d.ErrorCodes.OTHERS,o);return a={br:-1,lostpre:-1,vol:-1,mime:this.audioCodec},this.isSubscriber?(c=r.audioInputReports.bytesReceived-t.audioInputReports.bytesReceived,u=r.audioInputReports.packetsReceived-t.audioInputReports.packetsReceived,m=r.audioInputReports.packetsLost-t.audioInputReports.packetsLost,a.br=(c>=0?Math.round(8*c/i):0)||-1,a.lostpre=m>=0&&u>0?Math.round(m/(u+m)*100):0,a.vol=r.audioInputReports.audioLevel>=0?Math.round(100*r.audioInputReports.audioLevel):0):(p=r.audioOutputReports.bytesSent-t.audioOutputReports.bytesSent,l=r.audioOutputReports.packetsSent-t.audioOutputReports.packetsSent,m=r.audioOutputReports.packetsLost-t.audioOutputReports.packetsLost,a.br=(p>=0?Math.round(8*p/i):0)||-1,a.lostpre=m>=0&&l>0?Math.round(m/(l+m)*100):0,a.vol=r.audioOutputReports.audioLevel>=0?Math.round(100*r.audioOutputReports.audioLevel):0),s={br:-1,lostpre:-1,frt:-1,w:-1,h:-1,mime:this.videoCodec},this.isSubscriber?(c=r.videoInputReports.bytesReceived-t.videoInputReports.bytesReceived,u=r.videoInputReports.packetsReceived-t.videoInputReports.packetsReceived,m=r.videoInputReports.packetsLost-t.videoInputReports.packetsLost,f=r.videoInputReports.framesReceived-t.videoInputReports.framesReceived,s.br=(c>=0?Math.round(8*c/i):0)||-1,s.lostpre=m>=0&&u>0?Math.round(m/(u+m)*100):0,s.frt=(f>=0?Math.round(f/i):0)||-1,s.w=r.videoInputReports.frameWidth,s.h=r.videoInputReports.frameHeight):(p=r.videoOutputReports.bytesSent-t.videoOutputReports.bytesSent,l=r.videoOutputReports.packetsSent-t.videoOutputReports.packetsSent,m=r.videoOutputReports.packetsLost-t.videoOutputReports.packetsLost,h=r.videoOutputReports.framesSent-t.videoOutputReports.framesSent,s.br=(p>=0?Math.round(8*p/i):0)||-1,s.lostpre=m>=0&&l>0?Math.round(m/(l+m)*100):0,s.frt=(h>=0?Math.round(h/i):0)||-1,s.w=r.videoOutputReports.frameWidth,s.h=r.videoOutputReports.frameHeight),v={rtt:-1,delay:-1},this.isSubscriber?r.candidatePairReports.currentRoundTripTime>=0&&(v.delay=Math.round(1e3*r.candidatePairReports.currentRoundTripTime)||0):r.candidatePairReports.currentRoundTripTime>=0&&(v.rtt=Math.round(1e3*r.candidatePairReports.currentRoundTripTime)||0),[2,{audio:a,video:s,connection:v}]}}))}))},e.prototype.getLastPeerConnectionStats=function(){return this.lastStatsReports2},e.prototype.getCurrentPeerConnectionStats=function(){return this.currentStatsReports2},e.prototype.startUploadStats=function(){var e=this;this.timer||(this.timer=window.setInterval((function(){return n.__awaiter(e,void 0,void 0,(function(){var e,t;return n.__generator(this,(function(r){switch(r.label){case 0:return r.trys.push([0,3,,4]),[4,this.updateStatsReports2()];case 1:return r.sent(),[4,this.getStats2()];case 2:if(e=r.sent(),this.isSubscriber){if(!this.streamSubId)return[2];1e3*this.times>=3e3?(this.logReporter&&this.logReporter.reportSubscribeStatusLog(this.streamSubId,this.streamId,this.userId,this.mediaType,{delay:e.connection.delay,rtt:-1,audio:e.audio,video:e.video,cpu:0,memory:0}),this.times=0):this.times+=1}else 1e3*this.times>=3e3?(this.logReporter&&this.logReporter.reportPublishStatusLog(this.streamId,this.mediaType,{delay:-1,rtt:e.connection.rtt,audio:e.audio,video:e.video,cpu:0,memory:0}),this.times=0):this.times+=1;return[3,4];case 3:return t=r.sent(),o.default.warn("upload stats ",t),[3,4];case 4:return[2]}}))}))}),1e3))},e.prototype.stopUploadStats=function(){this.timer&&(window.clearInterval(this.timer),this.timer=0)},e.prototype.snapshot=function(e){if(this.videoHelper)return this.videoHelper.snapshot(e);var t=d.createError(d.ErrorCodes.VIDEO_TRACK_NOT_EXISTS,"stream has no video");return Promise.reject(t)},e.prototype.play=function(e,t){var r=this;return this.player&&this.destroyPlayer(),this.player=new p.Player(this,e,t),this.player.on("paused",(function(){var e;null===(e=r.emitter)||void 0===e||e.emit("stream-paused",r)})),this.player.on("playing",(function(){var e;null===(e=r.emitter)||void 0===e||e.emit("stream-playing",r)})),this.player.on("audio-playing",(function(){var e;null===(e=r.emitter)||void 0===e||e.emit("player-status-change",{type:"audio",status:"playing",stream:r.convertToOuterStream()})})),this.player.on("audio-paused",(function(){var e;null===(e=r.emitter)||void 0===e||e.emit("player-status-change",{type:"audio",status:"paused",stream:r.convertToOuterStream()})})),this.player.on("video-playing",(function(){var e;null===(e=r.emitter)||void 0===e||e.emit("player-status-change",{type:"video",status:"playing",stream:r.convertToOuterStream()})})),this.player.on("video-paused",(function(){var e;null===(e=r.emitter)||void 0===e||e.emit("player-status-change",{type:"video",status:"paused",stream:r.convertToOuterStream()})})),this.player.play()},e.prototype.resume=function(){return this.resumeAudio().catch((function(e){o.default.warn("resume audio failed "+e)})),this.player?this.player.resume():Promise.reject(d.createError(d.ErrorCodes.OTHERS,"stream isn't playing"))},e.prototype.stop=function(){return this.player?(this.player.stop(),Promise.resolve()):Promise.reject(d.createError(d.ErrorCodes.OTHERS,"stream isn't playing"))},e.prototype.destroyPlayer=function(){var e;null===(e=this.player)||void 0===e||e.destroy(),this.player=void 0},e}();t.RTCStream=l},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e){e[e.none=0]="none",e[e.microphone=1]="microphone",e[e.screen=2]="screen",e[e.custom=3]="custom"}(t.ENUM_AUDIO_TYPE||(t.ENUM_AUDIO_TYPE={})),function(e){e[e.none=0]="none",e[e.camera=1]="camera",e[e.screen=2]="screen",e[e.custom=3]="custom",e[e.image=4]="image"}(t.ENUM_VIDEO_TYPE||(t.ENUM_VIDEO_TYPE={})),function(e){e[e.closed=0]="closed",e[e.connecting=1]="connecting",e[e.connected=2]="connected",e[e.reconnecting=3]="reconnecting",e[e.disconnected=4]="disconnected"}(t.ENUM_STREAM_CONNECTION_STATE||(t.ENUM_STREAM_CONNECTION_STATE={}))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(4);t.replaceSDPVideoBW=function(e,t,r){var n,i=e.match(/m=video.*\r\n/);if(i){n=i[0]+"b=AS:2500\r\n";var o=void 0,a=void 0;"h264"===t?(o=e.search(/a=rtpmap:(\d+) H264\/90000\r\n/),a=e.search(/H264\/90000\r\n/)):"h265"===t?(o=e.search(/a=rtpmap:(\d+) H265\/90000\r\n/),a=e.search(/H265\/90000\r\n/)):"vp8"===t&&(o=e.search(/a=rtpmap:(\d+) VP8\/90000\r\n/),a=e.search(/VP8\/90000\r\n/)),o&&a&&a-o>10&&(n=n+"a=fmtp:"+e.slice(o+9,a-1)+" x-google-min-bitrate="+r.minVideoBW+"\r\n"),e=e.replace(i[0],n)}return e},t.handleSDPVideoCodec=function(e,t){var r,n,i=/m=video \d+ .*\r\n/.exec(e);if("h264"===t)r=/a=rtpmap:\d+ H264\/90000\r\n/,n=/H264\/90000\r\n/;else if("h265"===t)r=/a=rtpmap:\d+ H265\/90000\r\n/,n=/H265\/90000\r\n/;else{if("vp8"!==t)return e;r=/a=rtpmap:\d+ VP8\/90000\r\n/,n=/VP8\/90000\r\n/}if(i){var o=void 0,a=e.search(r),s=e.search(n);if(a&&s&&s-a>10&&(o=e.slice(a+9,s-1)),!o)return e;var c=i[0],u=/(\d+ *)+\r\n$/.exec(c);if(u){var d=u[0],f=d.split(" "),p=f.indexOf(o);p>0&&(f.splice(p,1),f.unshift(o));var l=c.replace(d,f.join(" "));e=e.replace(c,l)}}return e},t.handleSDPAudioCodec=function(e){var t=/m=audio \d+ .*\r\n/.exec(e);if(t){var r=void 0,n=e.search(/a=rtpmap:\d+ opus\/48000\/2\r\n/),i=e.search(/opus\/48000\/2\r\n/);if(n&&i&&i-n>10&&(r=e.slice(n+9,i-1)),!r)return e;var o=t[0],a=/(\d+ *)+\r\n$/.exec(o);if(a){var s=a[0],c=s.split(" "),u=c.indexOf(r);u>0&&(c.splice(u,1),c.unshift(r));var d=o.replace(s,c.join(" "));e=e.replace(o,d)}}return e},t.replaceSDPH264Part=function(e,t){return"h264"===t&&n.default.isSafari(),e},t.handleAnswerSDP=function(e){var t=e.match(/a=x-google-flag:conference\r\n/);return t&&(e=e.replace(t[0],"")),e}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n,i=r(2),o=r(21),a=r(3),s=r(0),c=r(4),u=r(6),d=o.default.create({responseType:"arraybuffer"}),f=o.default.create({responseType:"blob"}),p=window.AudioContext||window.webkitAudioContext||window.mozAudioContext||window.msAudioContext||window.oAudioContext,l=c.getSystemInfo(),m=c.getBrowserInfo(),h="ios"===l.name.toLowerCase()&&l.version.indexOf("14.2")>=0,v="macos"===l.name.toLowerCase()&&"safari"===m.name.toLowerCase()&&"14.0.1"===m.version,g="huawei"===c.getPlatformVender().toLocaleLowerCase()&&c.isMobile()&&c.default.isWeChat();!function(e){e[e.init=1]="init",e[e.play=2]="play",e[e.pause=3]="pause"}(n||(n={}));var y=function(e){this.state=n.init,this.startedAt=-1,this.pausedAt=-1,this.config=e},E=function(){};t.CachedAudioBuffer=E;var b=function(){};t.CachedAudioSource=b;var _=function(e){function t(r){var n,i=e.call(this)||this;if(i.effects=new Map,i.isTrickMode=!1,i.mediaStream=new MediaStream,i.mediaStream.addTrack(r),t.shouldUseTrickMode())return i.isTrickMode=!0,i;if(i.audioContext=new p,!i.audioContext)return s.default.error("cannot create audioContext"),i;c.default.isSafari()&&(i.audioContext.onstatechange=function(){var e,t;"interrupted"===(null===(e=i.audioContext)||void 0===e?void 0:e.state)&&(null===(t=i.audioContext)||void 0===t||t.resume().catch((function(e){s.default.report("audioContext resume failed ",e,navigator.userAgent)})))}),i.sourceNode=i.audioContext.createMediaStreamSource(i.mediaStream),"function"==typeof i.audioContext.createMediaStreamDestination?(i.gainNode=i.audioContext.createGain(),i.destinationNode=i.audioContext.createMediaStreamDestination(),i.sourceNode.connect(i.gainNode),i.gainNode.connect(i.destinationNode),n=i.destinationNode.stream):n=i.mediaStream;var o=i.audioContext.createMediaStreamSource(n);return i.analyser=i.audioContext.createAnalyser(),i.timeDomainData=new Uint8Array(i.analyser.frequencyBinCount),o.connect(i.analyser),i}return i.__extends(t,e),Object.defineProperty(t.prototype,"srcAudioTrack",{get:function(){return this.mediaStream.getAudioTracks()[0]},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"dstAudioTrack",{get:function(){return this.destinationNode?this.destinationNode.stream.getAudioTracks()[0]:this.mediaStream.getAudioTracks()[0]},enumerable:!0,configurable:!0}),t.prototype.resume=function(){return this.audioContext?this.audioContext.resume():Promise.resolve()},t.prototype.destroy=function(){var e;this.effects.forEach((function(e){var t;null===(t=e.bufferSourceNode)||void 0===t||t.stop()})),this.mediaStream.getAudioTracks().forEach((function(e){e.stop()})),null===(e=this.audioContext)||void 0===e||e.close()},t.prototype.updateAudioSourceTrack=function(e){var t,r,n=this.srcAudioTrack;n&&e?(this.mediaStream.removeTrack(n),this.mediaStream.addTrack(e)):e&&this.mediaStream.addTrack(e);var i=null===(t=this.audioContext)||void 0===t?void 0:t.createMediaStreamSource(this.mediaStream);return this.gainNode&&i?(null===(r=this.sourceNode)||void 0===r||r.disconnect(this.gainNode),this.sourceNode=i,this.sourceNode.connect(this.gainNode)):this.sourceNode=i,n},t.prototype.getVolume=function(){var e=0;return this.analyser&&(this.analyser.getByteTimeDomainData(this.timeDomainData),this.timeDomainData.forEach((function(t){e=Math.max(e,Math.abs(t-128))}))),e/128},t.prototype.setVolume=function(e){if(this.gainNode)return this.gainNode.gain.value=e/100,Promise.resolve();var t=a.createError(a.ErrorCodes.OTHERS,"cannot find gain node");return Promise.reject(t)},t.shouldUseTrickMode=function(){return h||v?(s.default.warn("iOS 14.2 and macOS with Safari 14.0.1 has bug on AudioContext, getAudioVolume, setAudioVolume... cannot be used."),s.default.report("iOS 14.2 and macOS with Safari 14.0.1 has bug on AudioContext, getAudioVolume, setAudioVolume... cannot be used."),!0):!!g&&(s.default.warn("Huawei wechat has bug on AudioContext, getAudioVolume, setAudioVolume... cannot be used."),s.default.report("Huawei wechat has bug on AudioContext, getAudioVolume, setAudioVolume... cannot be used."),!0)},t.getTrackFromAudioElement=function(e){return Audio.prototype.captureStream?e.captureStream().getAudioTracks()[0]:Audio.prototype.mozCaptureStream?e.mozCaptureStream().getAudioTracks()[0]:void s.default.warn("current browser is not support to get tracks from media element")},t.loadAudioBuffer=function(e,t,r){var n=this,o=e.get(t);return o?Promise.resolve(o):new Promise((function(o,u){var f=new p;if(!f){var l=a.createError(a.ErrorCodes.NOT_SUPPORT,"cannot create audioContext");return s.default.error("loadAudioBuffer - ",l),void u(l)}d.get(r).then((function(a){return i.__awaiter(n,void 0,void 0,(function(){var n,s;return i.__generator(this,(function(i){switch(i.label){case 0:return c.default.isIOS()||c.default.isSafari()?[4,new Promise((function(e,t){f.decodeAudioData(a.data,e,t)}))]:[3,2];case 1:return n=i.sent(),[3,4];case 2:return[4,f.decodeAudioData(a.data)];case 3:n=i.sent(),i.label=4;case 4:return s={filePath:r,audioBuffer:n},e.set(t,s),o(s),[2]}}))}))})).catch((function(e){s.default.warn("loadAudioBuffer - ",e),s.default.report("loadAudioBuffer - ",e),u(e)})).finally((function(){var e;null===(e=f)||void 0===e||e.close()}))}))},t.loadAudioSource=function(e,t,r){var n=e.get(t);return n?Promise.resolve(n):new Promise((function(n,i){f.get(r).then((function(i){var o=window.URL.createObjectURL(i.data),a={filePath:r,audioSource:o};e.set(t,a),n(a)})).catch((function(e){s.default.warn("loadAudioSource - ",e),s.default.report("loadAudioSource - ",e),i(e)}))}))},t.prototype.playAudioBuffer=function(e,t){var r=this;return new Promise((function(o,c){return i.__awaiter(r,void 0,void 0,(function(){var r,u,d,f,p=this;return i.__generator(this,(function(i){if(!this.destinationNode)return d=a.createError(a.ErrorCodes.NOT_SUPPORT,"this browser not support the API"),[2,c(d)];if(r=this.effects.get(t.effectId),u=e.audioBuffer,r)switch(d=void 0,r.state){case n.pause:break;case n.play:return d=a.createError(a.ErrorCodes.OTHERS,"the effect is playing"),[2,c(d)];case n.init:default:return d=a.createError(a.ErrorCodes.OTHERS,"the effect is initing"),[2,c(d)]}if(t.filePath&&t.filePath!==e.filePath)return d=a.createError(a.ErrorCodes.INVALID_PARAMETER,"wrong effectId or filepath, the effect "+t.effectId+" cached filepath is "+e.filePath),[2,c(d)];r=new y(Object.assign({loop:!1,playTime:0},t,{filePath:e.filePath}));try{if(!this.audioContext)return d=a.createError(a.ErrorCodes.NOT_SUPPORT,"no audio context"),s.default.error("playAudioBuffer - ",d),[2,c(d)];r.bufferSourceNode=this.audioContext.createBufferSource(),r.bufferSourceNode.buffer=u,r.gainNode=this.audioContext.createGain(),r.bufferSourceNode.connect(r.gainNode),r.gainNode.connect(this.destinationNode),r.bufferSourceNode.loop=r.config.loop,this.effects.set(r.config.effectId,r),r.bufferSourceNode.addEventListener("ended",(function(){try{"function"==typeof t.onEnd&&t.onEnd()}catch(e){s.default.warn("play effect end and invoke onEnd error ",e)}r&&r.state!==n.pause&&p.effects.delete(r.config.effectId)}),{once:!0}),r.config.replace&&this.gainNode&&(null===(f=this.sourceNode)||void 0===f||f.disconnect(this.gainNode)),r.bufferSourceNode.start(0,r.config.playTime%u.duration),r.startedAt=Date.now(),r.state=n.play}catch(e){return s.default.error("playAudioBuffer - ",e),[2,c(e)]}return o(),[2]}))}))}))},t.prototype.pauseAudioBuffer=function(e){var t=this;return new Promise((function(r,i){var o,s=t.effects.get(e);if(!s)return i(a.createError(a.ErrorCodes.OTHERS,"cannot find effect "+e));switch(s.state){case n.play:return s.state=n.pause,null===(o=s.bufferSourceNode)||void 0===o||o.stop(),s.pausedAt=Date.now(),r();case n.pause:return i(a.createError(a.ErrorCodes.OTHERS,"the effect is paused"));case n.init:default:return i(a.createError(a.ErrorCodes.OTHERS,"the effect is initing"))}}))},t.prototype.resumeAudioBuffer=function(e,t){var r=this;return new Promise((function(i,o){var s=r.effects.get(t);if(!s)return o(a.createError(a.ErrorCodes.OTHERS,"cannot find effect "+t));switch(s.state){case n.play:return o(a.createError(a.ErrorCodes.OTHERS,"the effect is playing"));case n.pause:var c=Object.assign({},s.config,{playTime:s.config.playTime+(s.pausedAt-s.startedAt)/1e3});r.playAudioBuffer(e,c).then(i).catch(o);break;case n.init:default:return o(a.createError(a.ErrorCodes.OTHERS,"the effect is initing"))}}))},t.prototype.stopAudioBuffer=function(e){var t=this;return new Promise((function(r,i){var o,s=t.effects.get(e);if(s){switch(s.state){case n.pause:t.effects.delete(e);break;case n.play:null===(o=s.bufferSourceNode)||void 0===o||o.stop();break;case n.init:default:return i(a.createError(a.ErrorCodes.OTHERS,"the effect is initing"))}r()}else{i(a.createError(a.ErrorCodes.OTHERS,"cannot find effect "+e))}}))},t.prototype.setGainNodeVolume=function(e,t){var r=this;return new Promise((function(i,o){var s=r.effects.get(e);if(s){switch(s.state){case n.play:return s.gainNode.gain.value=t/100,i();case n.pause:return o(a.createError(a.ErrorCodes.OTHERS,"the effect is paused"));case n.init:default:return o(a.createError(a.ErrorCodes.OTHERS,"the effect is initing"))}}else{o(a.createError(a.ErrorCodes.OTHERS,"cannot find effect "+e))}}))},t.prototype.playAudioSource=function(e,r){var i=this;return new Promise((function(o,u){var d=i.effects,f=d.get(r.effectId);if(f){var p=void 0;switch(f.state){case n.pause:break;case n.play:return p=a.createError(a.ErrorCodes.OTHERS,"the effect is playing"),u(p);case n.init:default:return p=a.createError(a.ErrorCodes.OTHERS,"the effect is initing"),u(p)}}if(r.filePath&&r.filePath!==e.filePath){p=a.createError(a.ErrorCodes.INVALID_PARAMETER,"wrong effectId or filepath, the effect "+r.effectId+" cached filepath is "+e.filePath);return u(p)}(f=new y(Object.assign({loop:!1,playTime:0},r,{filePath:e.filePath}))).audio||(f.audio=new Audio(e.audioSource),c.default.isChrome()?f.audio.volume=1e-5:c.default.isFirefox()&&(f.audio.volume=1)),d.set(f.config.effectId,f),f.audio.addEventListener("ended",(function(){var e=f;try{"function"==typeof r.onEnd&&r.onEnd(),i.emit("audio-source-stop",i)}catch(e){s.default.warn("play effect end and invoke onEnd error ",e)}e.state!==n.pause&&d.delete(e.config.effectId)}),{once:!0}),f.audio.addEventListener("loadeddata",(function(){var e=f.audio,r=t.getTrackFromAudioElement(e),n=e.duration||0;if(e.currentTime=f.config.playTime%n,f.startedAt=Date.now(),r)o(r);else{var i=a.createError(a.ErrorCodes.NOT_SUPPORT,"cannot get audio track");s.default.warn(i),s.default.report(i,navigator.userAgent),u(i)}})),f.audio.addEventListener("playing",(function(){f.state=n.play})),f.audio.addEventListener("pause",(function(){f.state=n.pause,i.emit("audio-source-stop",i)})),f.audio.play().catch((function(e){s.default.warn("playAudioSource - ",e),s.default.report("playAudioSource - ",e),u(e)}))}))},t.prototype.pauseAudioSource=function(e){var t=this;return new Promise((function(r,n){if(!t.effects.get(e))return n(a.createError(a.ErrorCodes.OTHERS,"cannot find effect "+e));r()}))},t.prototype.resumeAudioSource=function(e){return new Promise((function(){s.default.debug(e)}))},t.prototype.stopAudioSource=function(e){var t=this;return new Promise((function(r,i){var o,s=t.effects.get(e);if(!s)return i(a.createError(a.ErrorCodes.OTHERS,"cannot find effect "+e));switch(s.state){case n.play:null===(o=s.audio)||void 0===o||o.pause(),r();break;case n.pause:case n.init:default:return i(a.createError(a.ErrorCodes.OTHERS,"the effect is initing"))}}))},t.prototype.pauseEffect=function(e){return this.isTrickMode?this.pauseAudioSource(e):this.pauseAudioBuffer(e)},t.prototype.resumeEffect=function(e,t){return this.isTrickMode?this.resumeAudioSource(t):this.resumeAudioBuffer(e,t)},t.prototype.stopEffect=function(e){return this.isTrickMode?this.stopAudioSource(e):this.stopAudioBuffer(e)},t.prototype.setEffectVolume=function(e,t){return this.isTrickMode?Promise.reject(a.createError(a.ErrorCodes.NOT_SUPPORT,"current environment not support this API")):this.setGainNodeVolume(e,t)},t.prototype.canSwitchMicrophone=function(){var e=!0;return this.isTrickMode&&this.effects.forEach((function(t){t.state===n.play&&(e=!1)})),e},t}(u.EventEmitter);t.AudioHelper=_},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.version="1.6.29"},function(e,t,r){(function(e){var n=void 0!==e&&e||"undefined"!=typeof self&&self||window,i=Function.prototype.apply;function o(e,t){this._id=e,this._clearFn=t}t.setTimeout=function(){return new o(i.call(setTimeout,n,arguments),clearTimeout)},t.setInterval=function(){return new o(i.call(setInterval,n,arguments),clearInterval)},t.clearTimeout=t.clearInterval=function(e){e&&e.close()},o.prototype.unref=o.prototype.ref=function(){},o.prototype.close=function(){this._clearFn.call(n,this._id)},t.enroll=function(e,t){clearTimeout(e._idleTimeoutId),e._idleTimeout=t},t.unenroll=function(e){clearTimeout(e._idleTimeoutId),e._idleTimeout=-1},t._unrefActive=t.active=function(e){clearTimeout(e._idleTimeoutId);var t=e._idleTimeout;t>=0&&(e._idleTimeoutId=setTimeout((function(){e._onTimeout&&e._onTimeout()}),t))},r(44),t.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==e&&e.setImmediate||this&&this.setImmediate,t.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==e&&e.clearImmediate||this&&this.clearImmediate}).call(this,r(8))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(21),i=r(64),o=r(30),a=r(10),s=function(e){return new o(e).origin!==window.location.origin};function c(e){var t=e.url,r=void 0===t?a.SERVER_CONFIG.api+"/uteach":t,c=e.method,u=void 0===c?"GET":c,d=e.responseType,f=void 0===d?"json":d,p=e.data,l=void 0===p?{}:p,m=e.crossOrigin,h=void 0!==m&&m,v=e.needVerifyResponse,g=void 0===v||v;return new Promise((function(e,t){!h&&s(r)?i(r,{param:o.qs.stringify(l)+"&callback",timeout:5e3},(function(r,n){return r?t(r):g&&0!==n.err?t(n.msg):void e(n)})):n.default.request({url:r,method:u,responseType:f,data:l}).then((function(r){var n=r.data;if(g&&0!==n.err)return t(n.msg);e(n)})).catch((function(e){t(e)}))}))}t.query=c,t.get=function(e){return c(Object.assign(e,{method:"GET"}))},t.post=function(e){return c(Object.assign(e,{method:"POST"}))}},function(e,t,r){e.exports=r(48)},function(e,t,r){"use strict";e.exports=function(e,t){return function(){for(var r=new Array(arguments.length),n=0;n=200&&e<300}};c.headers={common:{Accept:"application/json, text/plain, */*"}},n.forEach(["delete","get","head"],(function(e){c.headers[e]={}})),n.forEach(["post","put","patch"],(function(e){c.headers[e]=n.merge(o)})),e.exports=c}).call(this,r(12))},function(e,t,r){"use strict";var n=r(1),i=r(55),o=r(23),a=r(57),s=r(58),c=r(27);e.exports=function(e){return new Promise((function(t,u){var d=e.data,f=e.headers;n.isFormData(d)&&delete f["Content-Type"];var p=new XMLHttpRequest;if(e.auth){var l=e.auth.username||"",m=e.auth.password||"";f.Authorization="Basic "+btoa(l+":"+m)}if(p.open(e.method.toUpperCase(),o(e.url,e.params,e.paramsSerializer),!0),p.timeout=e.timeout,p.onreadystatechange=function(){if(p&&4===p.readyState&&(0!==p.status||p.responseURL&&0===p.responseURL.indexOf("file:"))){var r="getAllResponseHeaders"in p?a(p.getAllResponseHeaders()):null,n={data:e.responseType&&"text"!==e.responseType?p.response:p.responseText,status:p.status,statusText:p.statusText,headers:r,config:e,request:p};i(t,u,n),p=null}},p.onabort=function(){p&&(u(c("Request aborted",e,"ECONNABORTED",p)),p=null)},p.onerror=function(){u(c("Network Error",e,null,p)),p=null},p.ontimeout=function(){u(c("timeout of "+e.timeout+"ms exceeded",e,"ECONNABORTED",p)),p=null},n.isStandardBrowserEnv()){var h=r(59),v=(e.withCredentials||s(e.url))&&e.xsrfCookieName?h.read(e.xsrfCookieName):void 0;v&&(f[e.xsrfHeaderName]=v)}if("setRequestHeader"in p&&n.forEach(f,(function(e,t){void 0===d&&"content-type"===t.toLowerCase()?delete f[t]:p.setRequestHeader(t,e)})),e.withCredentials&&(p.withCredentials=!0),e.responseType)try{p.responseType=e.responseType}catch(t){if("json"!==e.responseType)throw t}"function"==typeof e.onDownloadProgress&&p.addEventListener("progress",e.onDownloadProgress),"function"==typeof e.onUploadProgress&&p.upload&&p.upload.addEventListener("progress",e.onUploadProgress),e.cancelToken&&e.cancelToken.promise.then((function(e){p&&(p.abort(),u(e),p=null)})),void 0===d&&(d=null),p.send(d)}))}},function(e,t,r){"use strict";var n=r(56);e.exports=function(e,t,r,i,o){var a=new Error(e);return n(a,t,r,i,o)}},function(e,t,r){"use strict";var n=r(1);e.exports=function(e,t){t=t||{};var r={};return n.forEach(["url","method","params","data"],(function(e){void 0!==t[e]&&(r[e]=t[e])})),n.forEach(["headers","auth","proxy"],(function(i){n.isObject(t[i])?r[i]=n.deepMerge(e[i],t[i]):void 0!==t[i]?r[i]=t[i]:n.isObject(e[i])?r[i]=n.deepMerge(e[i]):void 0!==e[i]&&(r[i]=e[i])})),n.forEach(["baseURL","transformRequest","transformResponse","paramsSerializer","timeout","withCredentials","adapter","responseType","xsrfCookieName","xsrfHeaderName","onUploadProgress","onDownloadProgress","maxContentLength","validateStatus","maxRedirects","httpAgent","httpsAgent","cancelToken","socketPath"],(function(n){void 0!==t[n]?r[n]=t[n]:void 0!==e[n]&&(r[n]=e[n])})),r}},function(e,t,r){"use strict";function n(e){this.message=e}n.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},n.prototype.__CANCEL__=!0,e.exports=n},function(e,t,r){"use strict";(function(t){var n=r(68),i=r(69),o=/^[A-Za-z][A-Za-z0-9+-.]*:\/\//,a=/^([a-z][a-z0-9.+-]*:)?(\/\/)?([\S\s]*)/i,s=new RegExp("^[\\x09\\x0A\\x0B\\x0C\\x0D\\x20\\xA0\\u1680\\u180E\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200A\\u202F\\u205F\\u3000\\u2028\\u2029\\uFEFF]+");function c(e){return(e||"").toString().replace(s,"")}var u=[["#","hash"],["?","query"],function(e){return e.replace("\\","/")},["/","pathname"],["@","auth",1],[NaN,"host",void 0,1,1],[/:(\d+)$/,"port",void 0,1],[NaN,"hostname",void 0,1,1]],d={hash:1,query:1};function f(e){var r,n=("undefined"!=typeof window?window:void 0!==t?t:"undefined"!=typeof self?self:{}).location||{},i={},a=typeof(e=e||n);if("blob:"===e.protocol)i=new l(unescape(e.pathname),{});else if("string"===a)for(r in i=new l(e,{}),d)delete i[r];else if("object"===a){for(r in e)r in d||(i[r]=e[r]);void 0===i.slashes&&(i.slashes=o.test(e.href))}return i}function p(e){e=c(e);var t=a.exec(e);return{protocol:t[1]?t[1].toLowerCase():"",slashes:!!t[2],rest:t[3]}}function l(e,t,r){if(e=c(e),!(this instanceof l))return new l(e,t,r);var o,a,s,d,m,h,v=u.slice(),g=typeof t,y=this,E=0;for("object"!==g&&"string"!==g&&(r=t,t=null),r&&"function"!=typeof r&&(r=i.parse),t=f(t),o=!(a=p(e||"")).protocol&&!a.slashes,y.slashes=a.slashes||o&&t.slashes,y.protocol=a.protocol||t.protocol||"",e=a.rest,a.slashes||(v[3]=[/(.*)/,"pathname"]);E80&&e<=100?s.G1:e>60&&e<=80?s.G2:e>40&&e<=60?s.G3:s.G4},t.prototype.judge=function(e,t){var r=this,n=this.getLevel(e),i=this.getLevel(t);if(n!==i&&n0){var i=this._signal.grade,o=this.getLevel(i),s=void 0;if(s=e?t?this.signals.find((function(e){return e.wss===t})):this._signal:this.signals.find((function(e){return e!==r._signal&&r.getLevel(e.grade)<=o}))){a.default.debug("change signal "+(s&&s.wss)+"}"),s!==this._signal&&(this._signal.grade=0);var c=this._signal;this._signal=s,this.emit("change-signal",c,this._signal)}}},t.prototype.award=function(e){var t;if(this._signal&&this._signal.status===n.connected&&this._signal.grade<100){var r=this._signal.grade,i=void 0;i="number"==typeof e?e:(10*this._signal.grade+10)/10,this._signal.grade=i,a.default.debug("signal "+(null===(t=this._signal)||void 0===t?void 0:t.url)+" "+r+" -> "+i)}},t.prototype.punish=function(e){var t;if(this._signal&&this._signal.status===n.connected&&this._signal.grade>0){var r=this._signal.grade,i=void 0;"number"==typeof e?i=e:(i=(10*this._signal.grade-10)/10)<0&&(i=0),this._signal.grade=i,a.default.debug("signal "+(null===(t=this._signal)||void 0===t?void 0:t.url)+" "+r+" -> "+i),this.judge(r,i)}},t.prototype.add=function(e){this.signals.push(e),this._signal||(this._signal=e)},t.prototype.remove=function(e){var t=this.signals.findIndex((function(t){return t===e}));t>=0&&this.signals.splice(t,1)},t.prototype.destroy=function(){this.signals=[],this._signal=void 0},t.prototype.reconnect=function(){this.switch(!0)},t.prototype.refresh=function(e){var t=this;if(e.length>0){var r=this._signal;this.signals=[],e.forEach((function(e){t.signals.push(e)})),this._signal=this.signals[0],this.emit("change-signal",r,this._signal)}},t}(o.EventEmitter);t.SignalManager=u},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(33),i=function(){this.bytesReceived=0,this.jitter=0,this.packetsLost=0,this.packetsReceived=0,this.audioLevel=0},o=function(){this.bytesReceived=0,this.packetsLost=0,this.packetsReceived=0,this.firCount=0,this.nackCount=0,this.pliCount=0,this.framesDecoded=0,this.frameHeight=0,this.frameWidth=0,this.framesDropped=0,this.framesReceived=0},a=function(){this.bytesSent=0,this.packetsSent=0,this.retransmittedBytesSent=0,this.retransmittedPacketsSent=0,this.audioLevel=0,this.jitter=0,this.roundTripTime=0,this.packetsLost=0},s=function(){this.bytesSent=0,this.packetsSent=0,this.firCount=0,this.nackCount=0,this.pliCount=0,this.framesEncoded=0,this.frameHeight=0,this.frameWidth=0,this.framesSent=0,this.height=0,this.width=0,this.framesPerSecond=0,this.jitter=0,this.roundTripTime=0,this.packetsLost=0},c=function(){this.availableIncomingBitrate=0,this.availableOutgoingBitrate=0,this.bytesReceived=0,this.bytesSent=0,this.currentRoundTripTime=0,this.totalRoundTripTime=0},u=function(){this.ip="",this.port=0,this.networkType="",this.protocol="udp"},d=function(){this.ip="",this.port=0,this.protocol="udp"},f=function(){this.bytesReceived=0,this.bytesSent=0,this.dtlsState=""},p=function(){this.inAudioReport=new i,this.inVideoReport=new o,this.outAudioReport=new a,this.outVideoReport=new s,this.candidatePairReport=new c,this.localCandidateReport=new u,this.remoteCandidateReport=new d,this.transportReport=new f,this.timestamp=Date.now(),this.original=[]};t.StatsReports=p;var l=function(e){this.timestamp=Date.now(),this.reports=new n.Reports(e),this.audioInputReports=new n.AudioInputReports(e),this.audioOutputReports=new n.AudioOutputReports(e),this.videoInputReports=new n.VideoInputReports(e),this.videoOutputReports=new n.VideoOutputReports(e),this.candidatePairReports=new n.CandidatePairReports(e)};t.StatsReports2=l},function(e,t,r){ /*! * A getStats API of peerconnection with 'Standardized' and 'Legacy Non-Standard' reports. * @@ -35,11 +35,11 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */ -var n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)};function i(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var o=function(){return(o=Object.assign||function(e){for(var t,r=1,n=arguments.length;r=0;s--)(i=e[s])&&(a=(o<3?i(a):o>3?i(t,r,a):i(t,r))||a);return o>3&&a&&Object.defineProperty(t,r,a),a}function c(e,t){return function(r,n){t(r,n,e)}}function u(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function d(e,t,r,n){return new(r||(r=Promise))((function(i,o){function a(e){try{c(n.next(e))}catch(e){o(e)}}function s(e){try{c(n.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,s)}c((n=n.apply(e,t||[])).next())}))}function f(e,t){var r,n,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,n=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!((i=(i=a.trys).length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function h(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,o=r.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(n=o.next()).done;)a.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return a}function v(){for(var e=[],t=0;t1||s(e,t)}))})}function s(e,t){try{(r=i[e](t)).value instanceof y?Promise.resolve(r.value.v).then(c,u):d(o[0][2],r)}catch(e){d(o[0][3],e)}var r}function c(e){s("next",e)}function u(e){s("throw",e)}function d(e,t){e(t),o.shift(),o.length&&s(o[0][0],o[0][1])}}function b(e){var t,r;return t={},n("next"),n("throw",(function(e){throw e})),n("return"),t[Symbol.iterator]=function(){return this},t;function n(n,i){t[n]=e[n]?function(t){return(r=!r)?{value:y(e[n](t)),done:"return"===n}:i?i(t):t}:i}}function _(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,r=e[Symbol.asyncIterator];return r?r.call(e):(e=m(e),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(r){t[r]=e[r]&&function(t){return new Promise((function(n,i){!function(e,t,r,n){Promise.resolve(n).then((function(t){e({value:t,done:r})}),t)}(n,i,(t=e[r](t)).done,t.value)}))}}}function S(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}function T(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}function w(e){return e&&e.__esModule?e:{default:e}}function R(e,t){if(!t.has(e))throw new TypeError("attempted to get private field on non-instance");return t.get(e)}function M(e,t,r){if(!t.has(e))throw new TypeError("attempted to set private field on non-instance");return t.set(e,r),r}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getLegacyStats=t.getStats=t.CandidatePairLegacyReports=t.CandidatePairReports=t.VideoOutputLegacyReports=t.VideoInputLegacyReports=t.VideoOutputReports=t.VideoInputReports=t.AudioOutputLegacyReports=t.AudioInputLegacyReports=t.AudioOutputReports=t.AudioInputReports=t.Reports=void 0;var n=r(0),i=r(1);Object.defineProperty(t,"Reports",{enumerable:!0,get:function(){return i.Reports}});var o=r(8);Object.defineProperty(t,"AudioInputReports",{enumerable:!0,get:function(){return o.AudioInputReports}}),Object.defineProperty(t,"AudioOutputReports",{enumerable:!0,get:function(){return o.AudioOutputReports}}),Object.defineProperty(t,"AudioInputLegacyReports",{enumerable:!0,get:function(){return o.AudioInputLegacyReports}}),Object.defineProperty(t,"AudioOutputLegacyReports",{enumerable:!0,get:function(){return o.AudioOutputLegacyReports}});var a=r(9);Object.defineProperty(t,"VideoInputReports",{enumerable:!0,get:function(){return a.VideoInputReports}}),Object.defineProperty(t,"VideoOutputReports",{enumerable:!0,get:function(){return a.VideoOutputReports}}),Object.defineProperty(t,"VideoInputLegacyReports",{enumerable:!0,get:function(){return a.VideoInputLegacyReports}}),Object.defineProperty(t,"VideoOutputLegacyReports",{enumerable:!0,get:function(){return a.VideoOutputLegacyReports}});var s=r(10);function c(e){return e.getStats().then((function(e){var t=[];return e.forEach((function(e){var r=new Map;for(var n in e)r.set(n,e[n]);t.push(r)})),t}))}Object.defineProperty(t,"CandidatePairReports",{enumerable:!0,get:function(){return s.CandidatePairReports}}),Object.defineProperty(t,"CandidatePairLegacyReports",{enumerable:!0,get:function(){return s.CandidatePairLegacyReports}}),t.getStats=c,t.getLegacyStats=function(e){return"chrome"!==n.default.browser?Promise.reject(new Error("Only chrome/chromium style browsers can use this function")):new Promise((function(t,r){var n=[];e.getStats((function(e){e.result().forEach((function(e){var t=new Map;t.set("id",e.id),t.set("type",e.type),e.names().forEach((function(r){t.set(r,e.stat(r))})),n.push(t)})),t(n)})).catch(r)}))},t.default=c},function(e,t,r){"use strict";function n(e){return Object.prototype.toString.call(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.isNull=t.isUndefined=void 0,t.isUndefined=function(e){return"[object Undefined]"===n(e)},t.isNull=function(e){return"[object Null]"===n(e)}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parse=void 0;var n=r(6),i=r(7);t.parse=function(e){return e+="",i.isBoolean(e)?i.parseBoolean(e):n.isNumber(e)?n.parseNumber(e):e}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseNumber=t.isNumber=t.isFloat=t.isInt=void 0;var n=/^-?(?:0|[1-9][0-9]*)$/,i=/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/;function o(e){return e+="",n.test(e)}function a(e){return e+="",i.test(e)}t.isInt=o,t.isFloat=a,t.isNumber=function(e){return o(e+="")||a(e)},t.parseNumber=function(e){var t;if(o(e+=""))t=parseInt(e,10);else{if(!a(e))throw new Error("parameter invalid");t=parseFloat(e)}return t}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseBoolean=t.isBoolean=void 0;var n=/^true|false$/;function i(e){return e+="",n.test(e)}t.isBoolean=i,t.parseBoolean=function(e){if(!i(e+=""))throw new Error("parameter invalid");return"true"===e}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AudioOutputLegacyReports=t.AudioInputLegacyReports=t.AudioOutputReports=t.AudioInputReports=void 0;var n=r(2),i=r(0),o=r(1),a=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n.__extends(t,e),Object.defineProperty(t.prototype,"bytesReceived",{get:function(){return this._find("bytesReceived",{type:"inbound-rtp",mediaType:"audio"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"packetsReceived",{get:function(){return this._find("packetsReceived",{type:"inbound-rtp",mediaType:"audio"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"jitter",{get:function(){return this._find("jitter",{type:"inbound-rtp",mediaType:"audio"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"packetsLost",{get:function(){return this._find("packetsLost",{type:"inbound-rtp",mediaType:"audio"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"audioLevel",{get:function(){switch(i.default.browser){case"chrome":return this._find("audioLevel",{type:"track",kind:"audio"});case"safari":return this._find("audioLevel",{type:"track"});default:return this._find("audioLevel")}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"totalAudioEnergy",{get:function(){switch(i.default.browser){case"chrome":return this._find("totalAudioEnergy",{type:"track",kind:"audio"});default:return this._find("totalAudioEnergy")}},enumerable:!1,configurable:!0}),t}(o.Reports);t.AudioInputReports=a;var s=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n.__extends(t,e),Object.defineProperty(t.prototype,"bytesSent",{get:function(){return this._find("bytesSent",{type:"outbound-rtp",mediaType:"audio"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"packetsSent",{get:function(){return this._find("packetsSent",{type:"outbound-rtp",mediaType:"audio"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"jitter",{get:function(){switch(i.default.browser){case"chrome":case"firefox":return this._find("jitter",{type:"remote-inbound-rtp",kind:"audio"});default:return this._find("jitter",{mediaType:"audio"})}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"packetsLost",{get:function(){switch(i.default.browser){case"chrome":case"firefox":return this._find("packetsLost",{type:"remote-inbound-rtp",kind:"audio"});default:return this._find("packetsLost",{mediaType:"audio"})}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"roundTripTime",{get:function(){switch(i.default.browser){case"chrome":case"firefox":return this._find("roundTripTime",{type:"remote-inbound-rtp",kind:"audio"});default:return this._find("roundTripTime",{mediaType:"audio"})}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"audioLevel",{get:function(){switch(i.default.browser){case"chrome":return this._find("audioLevel",{type:"media-source",kind:"audio"});default:return this._find("audioLevel")}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"totalAudioEnergy",{get:function(){switch(i.default.browser){case"chrome":return this._find("totalAudioEnergy",{type:"media-source",kind:"audio"});default:return this._find("totalAudioEnergy")}},enumerable:!1,configurable:!0}),t}(o.Reports);t.AudioOutputReports=s;var c=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n.__extends(t,e),Object.defineProperty(t.prototype,"bytesReceived",{get:function(){return this._find("bytesReceived",{type:"ssrc",mediaType:"audio"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"packetsReceived",{get:function(){return this._find("packetsReceived",{type:"ssrc",mediaType:"audio"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"packetsLost",{get:function(){return this._find("packetsLost",{type:"ssrc",mediaType:"audio"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"audioLevel",{get:function(){return this._find("audioOutputLevel",{type:"ssrc",mediaType:"audio"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"totalAudioEnergy",{get:function(){return this._find("totalAudioEnergy",{type:"ssrc",mediaType:"audio"})},enumerable:!1,configurable:!0}),t}(o.Reports);t.AudioInputLegacyReports=c;var u=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n.__extends(t,e),Object.defineProperty(t.prototype,"bytesSent",{get:function(){return this._find("bytesSent",{type:"ssrc",mediaType:"audio"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"packetsSent",{get:function(){return this._find("packetsSent",{type:"ssrc",mediaType:"audio"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"packetsLost",{get:function(){return this._find("packetsLost",{type:"ssrc",mediaType:"audio"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"roundTripTime",{get:function(){return this._find("googRtt",{type:"ssrc",mediaType:"audio"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"audioLevel",{get:function(){return this._find("audioInputLevel",{type:"ssrc",mediaType:"audio"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"totalAudioEnergy",{get:function(){return this._find("totalAudioEnergy",{type:"ssrc",mediaType:"audio"})},enumerable:!1,configurable:!0}),t}(o.Reports);t.AudioOutputLegacyReports=u},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.VideoOutputLegacyReports=t.VideoInputLegacyReports=t.VideoOutputReports=t.VideoInputReports=void 0;var n=r(2),i=r(0),o=r(1),a=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n.__extends(t,e),Object.defineProperty(t.prototype,"frameWidth",{get:function(){switch(i.default.browser){case"chrome":return this._find("frameWidth",{type:"track",kind:"video"});case"safari":return this._find("frameWidth",{type:"track"});default:return this._find("frameWidth")}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"frameHeight",{get:function(){switch(i.default.browser){case"chrome":return this._find("frameHeight",{type:"track",kind:"video"});case"safari":return this._find("frameHeight",{type:"track"});default:return this._find("frameHeight")}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"framesReceived",{get:function(){switch(i.default.browser){case"chrome":return this._find("framesReceived",{type:"track",kind:"video"});case"safari":return this._find("framesReceived",{type:"track"});default:return this._find("framesReceived")}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"framesDropped",{get:function(){switch(i.default.browser){case"chrome":return this._find("framesDropped",{type:"track",kind:"video"});case"safari":return this._find("framesDropped",{type:"track"});default:return this._find("framesDropped")}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"bytesReceived",{get:function(){return this._find("bytesReceived",{type:"inbound-rtp",mediaType:"video"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"packetsReceived",{get:function(){return this._find("packetsReceived",{type:"inbound-rtp",mediaType:"video"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"packetsLost",{get:function(){return this._find("packetsLost",{type:"inbound-rtp",mediaType:"video"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"nackCount",{get:function(){return this._find("nackCount",{type:"inbound-rtp",mediaType:"video"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"pliCount",{get:function(){return this._find("pliCount",{type:"inbound-rtp",mediaType:"video"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"firCount",{get:function(){return this._find("firCount",{type:"inbound-rtp",mediaType:"video"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"framesDecoded",{get:function(){switch(i.default.browser){case"chrome":return this._find("framesDecoded",{type:"track",kind:"video"});case"firefox":return this._find("framesDecoded",{type:"inbound-rtp",kind:"video"});case"safari":return this._find("framesDecoded",{type:"track"});default:return this._find("framesDecoded")}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"jitter",{get:function(){switch(i.default.browser){case"firefox":return this._find("jitter",{type:"inbound-rtp",kind:"video"});default:return this._find("jitter",{mediaType:"video"})}},enumerable:!1,configurable:!0}),t}(o.Reports);t.VideoInputReports=a;var s=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n.__extends(t,e),Object.defineProperty(t.prototype,"frameWidth",{get:function(){switch(i.default.browser){case"chrome":return this._find("frameWidth",{type:"track",kind:"video"});case"safari":return this._find("frameWidth",{type:"track"});default:return this._find("frameWidth")}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"frameHeight",{get:function(){switch(i.default.browser){case"chrome":return this._find("frameHeight",{type:"track",kind:"video"});case"safari":return this._find("frameHeight",{type:"track"});default:return this._find("frameHeight")}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"bytesSent",{get:function(){return this._find("bytesSent",{type:"outbound-rtp",mediaType:"video"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"packetsSent",{get:function(){return this._find("packetsSent",{type:"outbound-rtp",mediaType:"video"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"nackCount",{get:function(){return this._find("nackCount",{type:"outbound-rtp",mediaType:"video"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"pliCount",{get:function(){return this._find("pliCount",{type:"outbound-rtp",mediaType:"video"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"firCount",{get:function(){return this._find("firCount",{type:"outbound-rtp",mediaType:"video"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"framesEncoded",{get:function(){return this._find("framesEncoded",{type:"outbound-rtp",mediaType:"video"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"packetsLost",{get:function(){switch(i.default.browser){case"chrome":case"firefox":return this._find("packetsLost",{type:"remote-inbound-rtp",kind:"video"});default:return this._find("packetsLost",{mediaType:"video"})}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"jitter",{get:function(){switch(i.default.browser){case"chrome":case"firefox":return this._find("jitter",{type:"remote-inbound-rtp",kind:"video"});default:return this._find("jitter",{mediaType:"video"})}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"roundTripTime",{get:function(){switch(i.default.browser){case"chrome":case"firefox":return this._find("roundTripTime",{type:"remote-inbound-rtp",kind:"video"});default:return this._find("roundTripTime",{mediaType:"video"})}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"framesSent",{get:function(){switch(i.default.browser){case"chrome":return this._find("framesSent",{type:"track",kind:"video"});case"safari":return this._find("framesSent",{type:"track"});default:return this._find("framesSent")}},enumerable:!1,configurable:!0}),t}(o.Reports);t.VideoOutputReports=s;var c=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n.__extends(t,e),Object.defineProperty(t.prototype,"frameWidth",{get:function(){return this._find("googFrameWidthReceived",{type:"ssrc",mediaType:"video"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"frameHeight",{get:function(){return this._find("googFrameHeightReceived",{type:"ssrc",mediaType:"video"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"bytesReceived",{get:function(){return this._find("bytesReceived",{type:"ssrc",mediaType:"video"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"packetsReceived",{get:function(){return this._find("packetsReceived",{type:"ssrc",mediaType:"video"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"packetsLost",{get:function(){return this._find("packetsLost",{type:"ssrc",mediaType:"video"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"nackCount",{get:function(){return this._find("googNacksSent",{type:"ssrc",mediaType:"video"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"pliCount",{get:function(){return this._find("googPlisSent",{type:"ssrc",mediaType:"video"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"firCount",{get:function(){return this._find("googFirsSent",{type:"ssrc",mediaType:"video"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"framesDecoded",{get:function(){return this._find("framesDecoded",{type:"ssrc",mediaType:"video"})},enumerable:!1,configurable:!0}),t}(o.Reports);t.VideoInputLegacyReports=c;var u=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n.__extends(t,e),Object.defineProperty(t.prototype,"frameWidth",{get:function(){return this._find("googFrameWidthSent",{type:"ssrc",mediaType:"video"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"frameHeight",{get:function(){return this._find("googFrameHeightSent",{type:"ssrc",mediaType:"video"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"bytesSent",{get:function(){return this._find("bytesSent",{type:"ssrc",mediaType:"video"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"packetsSent",{get:function(){return this._find("packetsSent",{type:"ssrc",mediaType:"video"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"nackCount",{get:function(){return this._find("googNacksReceived",{type:"ssrc",mediaType:"video"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"pliCount",{get:function(){return this._find("googPlisReceived",{type:"ssrc",mediaType:"video"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"firCount",{get:function(){return this._find("googFirsReceived",{type:"ssrc",mediaType:"video"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"framesEncoded",{get:function(){return this._find("framesEncoded",{type:"ssrc",mediaType:"video"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"packetsLost",{get:function(){return this._find("packetsLost",{type:"ssrc",mediaType:"video"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"roundTripTime",{get:function(){return this._find("googRtt",{type:"ssrc",mediaType:"video"})},enumerable:!1,configurable:!0}),t}(o.Reports);t.VideoOutputLegacyReports=u},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CandidatePairLegacyReports=t.CandidatePairReports=void 0;var n=r(2),i=r(0),o=r(1),a=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n.__extends(t,e),Object.defineProperty(t.prototype,"bytesSent",{get:function(){switch(i.default.browser){case"chrome":case"safari":return this._find("bytesSent",{type:"candidate-pair"});case"firefox":return this._find("bytesSent",{type:"candidate-pair",selected:!0});default:return this._find("bytesSent",{type:"candidate-pair"})}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"bytesReceived",{get:function(){switch(i.default.browser){case"chrome":case"safari":return this._find("bytesReceived",{type:"candidate-pair"});case"firefox":return this._find("bytesReceived",{type:"candidate-pair",selected:!0});default:return this._find("bytesReceived",{type:"candidate-pair"})}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"currentRoundTripTime",{get:function(){switch(i.default.browser){case"chrome":case"safari":default:return this._find("currentRoundTripTime",{type:"candidate-pair"})}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"totalRoundTripTime",{get:function(){switch(i.default.browser){case"chrome":case"safari":default:return this._find("totalRoundTripTime",{type:"candidate-pair"})}},enumerable:!1,configurable:!0}),t}(o.Reports);t.CandidatePairReports=a;var s=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n.__extends(t,e),Object.defineProperty(t.prototype,"bytesReceived",{get:function(){return this._find("bytesReceived",{type:"googCandidatePair"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"bytesSent",{get:function(){return this._find("bytesSent",{type:"googCandidatePair"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"packetsSent",{get:function(){return this._find("packetsSent",{type:"googCandidatePair"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"currentRoundTripTime",{get:function(){return this._find("googRtt",{type:"googCandidatePair"})},enumerable:!1,configurable:!0}),t}(o.Reports);t.CandidatePairLegacyReports=s}])},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(0),i=r(3),o=function(){function e(e,t,r,o){var a=this;void 0===t&&(t=640),void 0===r&&(r=480),void 0===o&&(o=20),this.width=640,this.height=480,this.frameRate=20,this.handleVisibilityChange=function(){document.hidden?(a.interval&&window.clearInterval(a.interval),a.interval=window.setInterval((function(){a.ctx.drawImage(a.image,0,0,a.width,a.height)}),200)):a.interval&&(window.clearInterval(a.interval),a.interval=0)},this.image=e,this.width=t,this.height=r,this.frameRate=o;var s=document.createElement("canvas");if(s.width=this.width,s.height=this.height,this.ctx=s.getContext("2d"),!this.ctx){var c=i.createError(i.ErrorCodes.NOT_SUPPORT,"cannot create canvas context");throw n.default.error(c),c}var u=function(){a.ctx.drawImage(a.image,0,0,a.width,a.height),a.drawTimer=window.requestAnimationFrame(u)};this.drawTimer=window.requestAnimationFrame(u),this.mediaStream=s.captureStream(this.frameRate),document.addEventListener("visibilitychange",this.handleVisibilityChange)}return e.prototype.destroy=function(){document.removeEventListener("visibilitychange",this.handleVisibilityChange),this.drawTimer&&window.cancelAnimationFrame(this.drawTimer),this.interval&&window.clearInterval(this.interval)},e.prototype.clone=function(t,r,n){return void 0===t&&(t=640),void 0===r&&(r=480),void 0===n&&(n=20),new e(this.image,t,r,n)},e}();t.ImageStream=o;var a=function(){function e(e,t){this.mediaStream=new MediaStream,this.mediaStream.addTrack(e),this.resolutionAttributes=t}return Object.defineProperty(e.prototype,"srcVideoTrack",{get:function(){return this.mediaStream.getVideoTracks()[0]},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"dstVideoTrack",{get:function(){return this.mediaStream.getVideoTracks()[0]},enumerable:!0,configurable:!0}),e.prototype.destroy=function(){this.mediaStream.getTracks().forEach((function(e){e.stop()}))},e.prototype.updateResolutionAttributes=function(e){this.resolutionAttributes=e},e.prototype.updateVideoSourceTrack=function(e){var t=this.srcVideoTrack;return t&&e?(this.mediaStream.removeTrack(t),this.mediaStream.addTrack(e)):e&&this.mediaStream.addTrack(e),t},e.prototype.createMediaStreamByImage=function(t){var r=this.srcVideoTrack;if(!r){var o=i.createError(i.ErrorCodes.OTHERS,"no video track");return n.default.error(o),Promise.reject(o)}var a=r.getSettings(),s=a.width||this.resolutionAttributes.videoWidth||640,c=a.height||this.resolutionAttributes.videoHeight||480;return e.createMediaStreamByImage(t,s,c)},e.prototype.createImageStream=function(t){if(!this.srcVideoTrack){var r=i.createError(i.ErrorCodes.OTHERS,"no video track");return Promise.reject(r)}var n=this.resolutionAttributes.videoWidth||640,o=this.resolutionAttributes.videoHeight||480,a=this.resolutionAttributes.maxFrameRate||20;return e.createImageStream(t,n,o,a)},e.getImageByFile=function(t){return new Promise((function(r,o){var a=new FileReader;a.addEventListener("load",(function(t){n.default.debug("file reader loaded ",t),e.getImageByURL(this.result).then(r).catch(o)})),a.addEventListener("error",(function(e){n.default.debug("file reader load error ",e);var t=i.createError(i.ErrorCodes.OTHERS,"file reader load error");o(t)})),a.readAsDataURL(t)}))},e.getImageByURL=function(e){return new Promise((function(t,r){var o=new Image;o.crossOrigin="anonymous",o.addEventListener("load",(function(e){n.default.debug("image loaded ",e),t(this)})),o.addEventListener("error",(function(e){n.default.debug("image load error ",e);var t=i.createError(i.ErrorCodes.OTHERS,"image load error");r(t)})),o.addEventListener("invalid",(function(e){n.default.debug("image load invalid ",e);var t=i.createError(i.ErrorCodes.OTHERS,"image invalid");r(t)})),o.src=e}))},e.createMediaStreamByImage=function(t,r,o){return void 0===r&&(r=640),void 0===o&&(o=480),new Promise((function(a,s){var c=document.createElement("canvas");c.width=r,c.height=o;var u=c.getContext("2d");if(!u){var d=i.createError(i.ErrorCodes.CREATE_STREAM,"cannot create canvas context");return n.default.error(d),void s(d)}if("string"==typeof t)e.getImageByURL(t).then((function(e){u.drawImage(e,0,0,c.width,c.height),a(c.captureStream())})).catch((function(e){s(e)}));else if(t instanceof File)e.getImageByFile(t).then((function(e){u.drawImage(e,0,0,c.width,c.height),a(c.captureStream())})).catch((function(e){s(e)}));else{d=i.createError(i.ErrorCodes.CREATE_STREAM,"file is invalid");s(d)}}))},e.createImageStream=function(t,r,n,a){if(void 0===r&&(r=640),void 0===n&&(n=480),void 0===a&&(a=20),"string"==typeof t)return e.getImageByURL(t).then((function(e){return new o(e,r,n,a)}));if(t instanceof File)return e.getImageByFile(t).then((function(e){return new o(e,r,n,a)}));var s=i.createError(i.ErrorCodes.CREATE_STREAM,"file is invalid");return Promise.reject(s)},e.prototype.snapshot=function(e){var t=this;return new Promise((function(r,o){var a=document.createElement("video");a.autoplay=!0,a.srcObject=t.mediaStream,a.onplay=function(){var t=document.createElement("canvas");t.width=a.videoWidth,t.height=a.videoHeight;var s=t.getContext("2d");if(!s){var c=i.createError(i.ErrorCodes.OTHERS,"cannot create canvas context");return n.default.warn(c),void o(c)}s.drawImage(a,0,0);var u=t.toDataURL("image");if(a.srcObject=null,a.onplay=null,""!==e){var d=document.createElement("a");d.download=e,d.href=u,d.click()}r(u)}}))},e}();t.VideoHelper=a},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n,i,o,a=r(30),s=r(10),c=r(20),u=r(0),d=r(5),f=r(18),p=r(36),l=r(4),m=r(77);!function(e){e[e.join=10]="join",e[e.stats=2]="stats",e[e.leave=3]="leave",e[e.exception=4]="exception",e[e.operation=5]="operation"}(n||(n={})),function(e){e[e.publish=1]="publish",e[e.subscribe=2]="subscribe",e[e.getCameras=3]="getCameras",e[e.getMicrophones=4]="getMicrophones",e[e.getLoudspeakers=5]="getLoudspeakers",e[e.highCPU=6]="highCPU",e[e.highLoss=7]="highLoss",e[e.highDelay=8]="highDelay",e[e.record=9]="record",e[e.storage=10]="storage",e[e.im=11]="im",e[e.whiteboard=12]="whiteboard",e[e.others=13]="others",e[e.joinRoom=14]="joinRoom",e[e.relay=15]="relay"}(i=t.ENUM_LOG_EXCEPTION_TYPE||(t.ENUM_LOG_EXCEPTION_TYPE={})),function(e){e[e.joinRoom=1]="joinRoom",e[e.leaveRoom=2]="leaveRoom",e[e.publish=3]="publish",e[e.unpublish=4]="unpublish",e[e.subscribe=5]="subscribe",e[e.unsubscribe=6]="unsubscribe",e[e.unmuteVideo=7]="unmuteVideo",e[e.muteVideo=8]="muteVideo",e[e.unmuteAudio=9]="unmuteAudio",e[e.muteAudio=10]="muteAudio",e[e.startRecord=11]="startRecord",e[e.stopRecord=12]="stopRecord",e[e.startRelay=13]="startRelay",e[e.stopRelay=14]="stopRelay",e[e.updateMix=15]="updateMix",e[e.updateVP=16]="updateVP"}(o=t.ENUM_LOG_OPERATION_TYPE||(t.ENUM_LOG_OPERATION_TYPE={}));var h=function(){function e(){}return e.prototype.init=function(e,t,r){var n=this;if(this.app_id=e,this.room_id=t,this.user_id=r,u.default.onReport=function(e){n.reportExceptionLog(i.others,{msg:""+e})},l.default.isFirefox()||l.default.isEdge())try{this.reportWorker=new m.InlineWorker((function(){var e=this;this.onmessage=function(t){var r=t.data;!function(t,r){var n=new XMLHttpRequest;n.open("post",t,!0),n.setRequestHeader("Content-Type","application/json;charset=utf-8"),n.setRequestHeader("Accept","application/json, text/plain, */*"),n.responseType="json",n.send(JSON.stringify(r)),n.onreadystatechange=function(){4===n.readyState&&200===n.status&&e.postMessage({response:n.response})}}(r.url,r.content)}})),this.reportWorker.onmessage=function(e){u.default.debug("report worker recive data ",e.data)}}catch(e){u.default.warn("browser not support web worker")}},e.prototype.destroy=function(){var e;this.app_id="",this.room_id="",this.user_id="",null===(e=this.reportWorker)||void 0===e||e.terminate(),u.default.onError=function(){}},Object.defineProperty(e.prototype,"isValid",{get:function(){return!!s.SERVER_CONFIG.log&&!!(this.app_id&&this.room_id&&this.user_id)},enumerable:!0,configurable:!0}),e.prototype.getCommonHeader=function(e,t){return{version:"1.0",method:"logup",rpc_id:p.getId(),type:e,ts:Math.round(Date.now()/1e3),aid:this.app_id,rid:this.room_id,sid:t&&t.sid||"",uid:this.user_id,streamid:t&&t.streamId||"",stype:t&&t.stype||0,mtype:t&&t.mtype||0}},e.prototype.reportJoinRoomLog=function(){if(this.isValid){var e=this.getCommonHeader(n.join),t=l.getDeviceInfo(),r=l.getSystemInfo(),i=l.getCPUInfo(),o={sdkv:f.version,agent:p.getAgent(),device:t.vendor+"_"+t.brand+"_"+t.model,system:""+r.name+r.version+"_"+r.versionName,network:""+l.getNetworkInfo().network,cpu:i.brand+"_"+i.model+"_"+i.core,mem:l.getMemInfo().capacity,micphone:1,speaker:1,video:1},c=new a(s.SERVER_CONFIG.log).set("pathname","api/rtcJoinLeaveClientLog"),u=Object.assign({},e,{data:o});this.report(c,u)}},e.prototype.reportLeaveRoomLog=function(){if(this.isValid){var e=this.getCommonHeader(n.leave),t=new a(s.SERVER_CONFIG.log).set("pathname","api/rtcJoinLeaveClientLog"),r=Object.assign({},e,{data:{sdkv:"",agent:"",device:"",system:"",network:"",cpu:"",mem:0,micphone:0,speaker:0,video:0}});this.report(t,r)}},e.prototype.reportPublishStatusLog=function(e,t,r){if(this.isValid){var i=this.getCommonHeader(n.stats,{streamId:e,stype:d.ENUM_STREAM_TYPE.publish,mtype:t}),o=new a(s.SERVER_CONFIG.log).set("pathname","api/rtcClinetLog"),c=Object.assign({userid:"",streamid:""},r),u=Object.assign({},i,{data:c});this.report(o,u)}},e.prototype.reportSubscribeStatusLog=function(e,t,r,i,o){if(this.isValid){var c=this.getCommonHeader(n.stats,{streamId:e,stype:d.ENUM_STREAM_TYPE.subscribe,mtype:i}),u=new a(s.SERVER_CONFIG.log).set("pathname","api/rtcClinetLog"),f=Object.assign({userid:r||"",streamid:t||""},o),p=Object.assign({},c,{data:f});this.report(u,p)}},e.prototype.reportExceptionLog=function(e,t){if(this.isValid){var r=this.getCommonHeader(n.exception,t),o=new a(s.SERVER_CONFIG.log).set("pathname","api/exceptionLog"),c=Object.assign({},r,{data:{errorType:e,userid:e===i.subscribe&&t&&t.userId||"",streamid:e===i.subscribe&&t&&t.streamId||"",msg:t&&t.msg||""}});this.report(o,c)}},e.prototype.reportOperationLog=function(e,t){if(this.isValid){var r=o,i=[r.subscribe,r.unsubscribe,r.unmuteVideo,r.muteVideo,r.unmuteAudio,r.muteAudio],c=[r.subscribe,r.unsubscribe,r.unmuteVideo,r.muteVideo,r.unmuteAudio,r.muteAudio],u=[r.startRecord,r.stopRecord],d=this.getCommonHeader(n.operation,t),f=new a(s.SERVER_CONFIG.log).set("pathname","api/opertionLog"),p={opertionType:e,userid:i.includes(e)&&t&&t.userId||"",streamid:c.includes(e)&&t&&t.streamId||"",recordid:u.includes(e)&&t&&t.recordId||""};t&&t.msg&&(p.msg=t.msg);var l=Object.assign({},d,{data:p});this.report(f,l)}},e.prototype.report=function(e,t){var r;this.reportWorker?null===(r=this.reportWorker)||void 0===r||r.postMessage({url:e.href,content:t}):c.post({url:e.href,data:t,crossOrigin:!0,needVerifyResponse:!1}).catch((function(e){u.default.warn("report log "+e)}))},e}();t.LogReporter=h},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(4),i=r(37),o=1e7,a="web_"+n.getBrowserInfo().name+n.getBrowserInfo().version,s=o,c=a;t.getAgent=function(){return c},t.setAgent=function(e){c=e},t.resetSeq=function(){s=o},t.getId=function(){return c+"_"+i.formatTime(new Date,"YYYYMMDDHHmmss")+"_"+s++}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.formatTime=function(e,t){void 0===t&&(t="YYYY/MM/DD HH:mm:ss");var r={"M+":e.getMonth()+1,"D+":e.getDate(),"H+":e.getHours(),"m+":e.getMinutes(),"s+":e.getSeconds(),"q+":Math.floor((e.getMonth()+3)/3),S:e.getMilliseconds()};for(var n in/(y+)/i.test(t)&&(t=t.replace(RegExp.$1,(e.getFullYear()+"").substr(4-RegExp.$1.length))),r)new RegExp("("+n+")").test(t)&&(t=t.replace(RegExp.$1,1==RegExp.$1.length?r[n]:("00"+r[n]).substr((""+r[n]).length)));return t}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(2),i=r(0),o=r(14),a=r(17),s=r(34),c=r(5),u=r(16),d=r(3),f=function(e){function t(t,r){var n=e.call(this,r)||this;return n.status=c.ENUM_SUBSCRIBE_STATUS.unsubscribe,n.isSubscriber=!0,n.userId=t.uid,n.streamId=t.sid,n.streamType=c.ENUM_STREAM_TYPE.subscribe,n.mediaType=t.media_type,n.audio=t.audio,n.video=t.video,n.data=t.data,n.muteaudio=t.muteaudio,n.mutevideo=t.mutevideo,n.sourceAudioMuted=t.muteaudio,n.sourceVideoMuted=t.mutevideo,n.audioMuted=!1,n.videoMuted=!1,n}return n.__extends(t,e),Object.defineProperty(t.prototype,"canSubscribe",{get:function(){var e=!0;switch(this.status){case c.ENUM_SUBSCRIBE_STATUS.subscribing:case c.ENUM_SUBSCRIBE_STATUS.unsubscribing:case c.ENUM_SUBSCRIBE_STATUS.subscribed:case c.ENUM_SUBSCRIBE_STATUS.resubscribing:e=!1;break;case c.ENUM_SUBSCRIBE_STATUS.unsubscribe:default:e=!0}return e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"canUnSubscribe",{get:function(){var e=!0;switch(this.status){case c.ENUM_SUBSCRIBE_STATUS.subscribing:case c.ENUM_SUBSCRIBE_STATUS.unsubscribing:case c.ENUM_SUBSCRIBE_STATUS.unsubscribe:case c.ENUM_SUBSCRIBE_STATUS.resubscribing:e=!1;break;case c.ENUM_SUBSCRIBE_STATUS.subscribed:default:e=!0}return e},enumerable:!0,configurable:!0}),t.prototype.initMediaStream=function(){this.mediaStream=new MediaStream},t.prototype.handlePeerConnectionTrackEvent=function(){var e=this;this.peerConnection&&this.peerConnection.addEventListener("track",(function(t){if(i.default.debug("remote - track event ",t),"audio"===t.track.kind){e.audioHelper=new a.AudioHelper(t.track);var r=e.getAudioTrack();r&&e.mediaStream.addTrack(r)}"video"===t.track.kind&&(e.videoHelper=new s.VideoHelper(t.track,e.resolution.attributes),e.mediaStream.addTrack(t.track))}))},t.prototype.connect=function(e){return n.__awaiter(this,void 0,void 0,(function(){var t,r;return n.__generator(this,(function(n){switch(n.label){case 0:this.streamSubId=e,n.label=1;case 1:if(n.trys.push([1,4,,5]),!this.peerConnection)throw new Error("no peerconnection");return[4,this.peerConnection.createOffer({offerToReceiveAudio:this.audio,offerToReceiveVideo:this.video})];case 2:return(t=n.sent()).sdp&&this.video&&this.videoCodec&&(t.sdp=u.handleSDPVideoCodec(t.sdp,this.videoCodec)),t.sdp&&this.audio&&(t.sdp=u.handleSDPAudioCodec(t.sdp)),[4,this.peerConnection.setLocalDescription(t)];case 3:return n.sent(),[2,t];case 4:throw r=n.sent(),i.default.error("peerconnection create offer error "+r),r;case 5:return[2]}}))}))},t.prototype.setStatusAsDone=function(){this.status=c.ENUM_SUBSCRIBE_STATUS.subscribed},t.prototype.close=function(){this.audioMuted=!1,this.videoMuted=!1,this._close(),this.status=c.ENUM_SUBSCRIBE_STATUS.unsubscribe},t.prototype.convertToOuterStream=function(){var e;switch(this.mediaType){case c.ENUM_MEDIA_TYPE.desktop:e="screen";break;case c.ENUM_MEDIA_TYPE.camera:default:e="camera"}return{sid:this.streamId,uid:this.userId,type:"subscribe",mediaType:e,audio:this.audio,video:this.video,muteAudio:this.muteaudio,muteVideo:this.mutevideo,mediaStream:this.status!==c.ENUM_SUBSCRIBE_STATUS.unsubscribe&&this.status!==c.ENUM_SUBSCRIBE_STATUS.unsubscribing?this.mediaStream:void 0,sourceAudioMuted:this.sourceAudioMuted,sourceVideoMuted:this.sourceVideoMuted,audioMuted:this.audioMuted,videoMuted:this.videoMuted}},t.prototype.convertToInnerStream=function(){return{uid:this.userId,sid:this.streamId,streamsub_id:this.streamSubId,stream_type:this.streamType,media_type:this.mediaType,audio:this.audio,video:this.video,data:this.data,muteaudio:this.muteaudio,mutevideo:this.mutevideo}},t.prototype.setAudioVolume=function(e){return this.player?(this.player.setAudioVolume(e),Promise.resolve()):Promise.reject(d.createError(d.ErrorCodes.OTHERS,"stream isn't playing"))},t}(o.RTCStream);t.RemoteStream=f},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(2),i=r(6),o=r(9),a=r(0),s=r(11),c=r(38),u=r(5),d=r(4),f=function(){function e(e,t){var r=this;this.localStreams=[],this.remoteStreams=[],this.innerEmitter=new i.EventEmitter,this.currentResolution=o.getResolution(""),this.audioCodec=e,this.videoCodec=t,this.innerEmitter.on("stream-connected",(function(e){a.default.debug("stream-connected ",e),e.isSubscriber?r._emitter.emit("mediaStreamSubscribed",e):r._emitter.emit("mediaStreamPublished",e)})),this.innerEmitter.on("stream-disconnected",(function(e){a.default.debug("stream-disconnected ",e),r._emitter.emit("streamConnectionDisconnected",e)})),this.innerEmitter.on("stream-reconnected",(function(e){a.default.debug("stream-reconnected ",e),r._emitter.emit("streamConnectionReconnected",e)})),this.innerEmitter.on("stream-failed",(function(e){a.default.debug("stream-failed ",e),r._emitter.emit("streamConnectionClosed",e)})),this.innerEmitter.on("stream-reconnecting",(function(e){a.default.debug("stream-reconnecting ",e),r._emitter.emit("streamConnectionReconnecting",e)})),this.innerEmitter.on("screen-track-ended",(function(e){a.default.debug("screen-track-ended",e),r._emitter.emit("screenMediaStreamEnded",e)})),this.innerEmitter.on("stream-close",(function(e){e.destroyPlayer()})),this.innerEmitter.on("video-muted",(function(e){a.default.debug("video track muted ",e)})),this.innerEmitter.on("video-unmuted",(function(e){a.default.debug("video track unmuted ",e)})),this.innerEmitter.on("stream-paused",(function(e){var t;a.default.debug("stream paused ",e),null===(t=r._emitter)||void 0===t||t.emit("stream-paused",e)})),this.innerEmitter.on("stream-playing",(function(e){var t;a.default.debug("stream playing ",e),null===(t=r._emitter)||void 0===t||t.emit("stream-playing",e)})),this.innerEmitter.on("player-status-change",(function(e){var t;a.default.debug("stream playing ",e),null===(t=r._emitter)||void 0===t||t.emit("player-status-change",e)}))}return Object.defineProperty(e.prototype,"emitter",{set:function(e){this._emitter=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"logReporter",{set:function(e){this._logReporter=e},enumerable:!0,configurable:!0}),e.generatePublishConfig=function(e){var t=e.audio,r=e.video,n=e.facingMode,i=e.screenAudio,o=e.screen,a=e.microphoneId,s=e.cameraId,c=e.extensionId,d={audio:!0,video:!0,screenAudio:!1,screen:!1,mediaType:u.ENUM_MEDIA_TYPE.camera,data:!1};return d.audio=t,d.video=r,n&&(d.facingMode=n),"boolean"==typeof i&&(d.screenAudio=i),d.screen=o,a&&(d.microphoneId=a),s&&(d.cameraId=s),o&&(d.mediaType=u.ENUM_MEDIA_TYPE.desktop),r&&(d.mediaType=u.ENUM_MEDIA_TYPE.camera),c&&(d.extensionId=c),d},e.prototype.getResolution=function(){return this.currentResolution},e.prototype.getLocalStream=function(e){return this.localStreams.find((function(t){return t.streamId===e||t.previewId===e}))},e.prototype.getLocalStreamByPreviewId=function(e){return this.localStreams.find((function(t){return t.previewId===e}))},e.prototype.getAllLocalStreams=function(){return this.localStreams},e.prototype.getRemoteStream=function(e){return this.remoteStreams.find((function(t){return t.streamId===e||t.streamSubId===e}))},e.prototype.getAllRemoteStreams=function(){return this.remoteStreams},e.prototype.getRemoteStreamsByUserId=function(e){return this.remoteStreams.filter((function(t){return t.userId===e}))},e.prototype.getStream=function(e){return this.getLocalStream(e)||this.getRemoteStream(e)},e.prototype.createLocalStream=function(e,t){a.default.debug("create local stream ",e,t);var r=new s.LocalStream(e,t,this.innerEmitter);return r.audioCodec=this.audioCodec,r.videoCodec=this.videoCodec,r.logReporter=this._logReporter,r.setResolution(this.currentResolution),r},e.prototype.addLocalStream=function(e){this.localStreams.push(e)},e.prototype.removeLocalStream=function(e,t){try{var r=this.localStreams.indexOf(e);r>=0&&(this.localStreams.splice(r,1),e.close(t))}catch(e){a.default.error("remove LocalStream failed "+e)}},e.prototype.removeAllLocalStreams=function(){try{this.localStreams.forEach((function(e){e.close()})),this.localStreams=[]}catch(e){a.default.error("clean local streams "+e)}},e.prototype.createRemoteStream=function(e){a.default.debug("create remote stream ",e);var t=this.getRemoteStream(e.sid);if(!t){(t=new c.RemoteStream(e,this.innerEmitter)).audioCodec=this.audioCodec;return/VP8/.test(e.sid)?t.videoCodec="vp8":/H264/.test(e.sid)?t.videoCodec="h264":t.videoCodec=this.videoCodec,t.logReporter=this._logReporter,t.setResolution(this.currentResolution),this.remoteStreams.push(t),t}a.default.error("create remote stream - ","remote stream exists")},e.prototype.removeRemoteStream=function(e){try{var t=this.remoteStreams.indexOf(e);t>=0&&(this.remoteStreams.splice(t,1),e.close())}catch(e){a.default.error("remove RemoteStream failed "+e)}},e.prototype.removeAllRemoteStreams=function(){try{this.remoteStreams.forEach((function(e){e.close()})),this.localStreams=[]}catch(e){a.default.error("clean remote streams "+e)}},e.prototype.setVideoProfile=function(e,t){return n.__awaiter(this,void 0,void 0,(function(){var r;return n.__generator(this,(function(n){switch(n.label){case 0:return r="object"==typeof e?o.getCustomResolution(e):o.getResolution(e),t?(t.setResolution(r),[4,t.applyResolution(r)]):[3,2];case 1:return n.sent(),[3,3];case 2:this.currentResolution=r,n.label=3;case 3:return[2]}}))}))},e.enumerateDevices=function(e,t,r){var i=this;new Promise((function(t,r){return n.__awaiter(i,void 0,void 0,(function(){var i,o,c,d,f,p,l;return n.__generator(this,(function(n){switch(n.label){case 0:return n.trys.push([0,5,,6]),[4,navigator.mediaDevices.enumerateDevices()];case 1:return 0===(i=n.sent()).length?(t(i),[2]):i[0].deviceId||!e.microphone&&!e.camera?[3,4]:(a.default.warn("get blank device information, please allow device permission to try again"),[4,(o=new s.LocalStream("get-devices",{audio:!!e.microphone,video:!!e.camera,screen:!1,mediaType:u.ENUM_MEDIA_TYPE.camera,data:!1})).init({audio:!!e.microphone,video:!!e.camera,screen:!1})]);case 2:return n.sent(),[4,navigator.mediaDevices.enumerateDevices()];case 3:i=n.sent(),o.close(),n.label=4;case 4:return c=0,d=0,f=0,p=i.map((function(e){if(e.label)return e;var t={};switch(["deviceId","groupId","kind"].forEach((function(r){t[r]=e[r]})),e.kind){case"audioinput":t.label="microphone_"+c++;break;case"audiooutput":t.label="speaker_"+d++;break;case"videoinput":t.label="camera_"+f++}return Object.freeze(t)})),t(p),[3,6];case 5:return l=n.sent(),r(l),[3,6];case 6:return[2]}}))}))})).then(t).catch(r)},e.deviceDetection=function(e){var t,r,i=this;if(e.audio){var o={audio:!0,video:!1,screen:!1,data:!1,mediaType:u.ENUM_MEDIA_TYPE.camera,microphoneId:e.microphoneId};t=new s.LocalStream("audioDetection",o)}if(e.video){o={audio:!1,video:!0,screen:!1,data:!1,mediaType:u.ENUM_MEDIA_TYPE.camera,cameraId:e.cameraId};r=new s.LocalStream("videoDetection",o)}return new Promise((function(e){return n.__awaiter(i,void 0,void 0,(function(){var i,o,s;return n.__generator(this,(function(n){switch(n.label){case 0:if(i={audio:!1,video:!1},!t)return[3,6];n.label=1;case 1:return n.trys.push([1,4,,5]),[4,t.initMediaStream()];case 2:return n.sent(),[4,t.addTracks2MediaStream()];case 3:return n.sent(),i.audio=!0,[3,5];case 4:return o=n.sent(),a.default.warn("audio input device invalid ",o),i.audioError=o.message,[3,5];case 5:try{t.close()}catch(e){a.default.warn("audio input device invalid ",e),i.audioError=e.message}n.label=6;case 6:if(!r)return[3,12];n.label=7;case 7:return n.trys.push([7,10,,11]),[4,r.initMediaStream()];case 8:return n.sent(),[4,r.addTracks2MediaStream()];case 9:return n.sent(),i.video=!0,[3,11];case 10:return s=n.sent(),a.default.warn("video input device invalid ",s),i.videoError=s.message,[3,11];case 11:try{r.close()}catch(e){a.default.warn("video input device invalid ",e),i.videoError=e.message}n.label=12;case 12:return e(i),[2]}}))}))}))},e.getSupportedCodec=function(){return n.__awaiter(this,void 0,void 0,(function(){var e,t,r,i,o;return n.__generator(this,(function(n){switch(n.label){case 0:t={video:[],audio:[]};try{if(d.default.isChrome()){r=80;try{r=parseInt(d.getBrowserInfo().version,10)}catch(e){r=79}i={sdpSemantics:"plan-b"},r>=80&&(i={sdpSemantics:"unified-plan"}),e=new RTCPeerConnection(i)}else d.default.isSafari()||d.default.isOldEdge()?(i={bundlePolicy:"max-bundle"},e=new RTCPeerConnection(i)):e=new RTCPeerConnection}catch(e){return a.default.error("get supported codec "+e),[2,t]}return[4,e.createOffer({offerToReceiveAudio:!0,offerToReceiveVideo:!0})];case 1:return o=n.sent(),e.close(),o.sdp&&(o.sdp.match(/ vp8/i)&&t.video.push("vp8"),o.sdp.match(/ h264/i)&&t.video.push("h264"),o.sdp.match(/ opus/i)&&t.audio.push("opus")),[2,t]}}))}))},e.isSupportWebRTC=function(){var e=d.getSystemInfo(),t=d.getBrowserInfo();if(/windows/i.test(e.name)&&/wechat/i.test(t.name))return!1;var r=window.RTCPeerConnection||window.mozRTCPeerConnection||window.webkitRTCPeerConnection,n=navigator&&(navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.msGetUserMedia||navigator.mozGetUserMedia||navigator.mediaDevices&&navigator.mediaDevices.getUserMedia),i=window.WebSocket;return!!r&&!!n&&!!i},e}();t.StreamManager=f},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(79),i=r(80),o=r(81);function a(e,t,r,a){var s=e,c=t,u=r,d=a,f=n.Base64.encode(JSON.stringify({user_id:d,room_id:u,app_id:s})),p=Math.round(Date.now()/1e3),l=o.randNum(8),m=d+s+p+l+u,h=new i("SHA-1","TEXT");return h.setHMACKey(c,"TEXT"),h.update(m),f+"."+h.getHMAC("HEX")+p+l}function s(e){return JSON.parse(n.Base64.decode(e))}function c(e){return n.Base64.encode(JSON.stringify(e))}t.genToken=a,t.decode=s,t.encode=c;var u={genToken:a,decode:s,encode:c};t.default=u},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.convertToOuterUser=function(e){return{uid:e.user_id}}},function(e,t,r){"use strict";var n=r(7);function i(e,t,r,i,o){var a=n.writeRtpDescription(e.kind,t);if(a+=n.writeIceParameters(e.iceGatherer.getLocalParameters()),a+=n.writeDtlsParameters(e.dtlsTransport.getLocalParameters(),"offer"===r?"actpass":o||"active"),a+="a=mid:"+e.mid+"\r\n",e.rtpSender&&e.rtpReceiver?a+="a=sendrecv\r\n":e.rtpSender?a+="a=sendonly\r\n":e.rtpReceiver?a+="a=recvonly\r\n":a+="a=inactive\r\n",e.rtpSender){var s=e.rtpSender._initialTrackId||e.rtpSender.track.id;e.rtpSender._initialTrackId=s;var c="msid:"+(i?i.id:"-")+" "+s+"\r\n";a+="a="+c,a+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" "+c,e.sendEncodingParameters[0].rtx&&(a+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" "+c,a+="a=ssrc-group:FID "+e.sendEncodingParameters[0].ssrc+" "+e.sendEncodingParameters[0].rtx.ssrc+"\r\n")}return a+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" cname:"+n.localCName+"\r\n",e.rtpSender&&e.sendEncodingParameters[0].rtx&&(a+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" cname:"+n.localCName+"\r\n"),a}function o(e,t){var r={codecs:[],headerExtensions:[],fecMechanisms:[]},n=function(e,t){e=parseInt(e,10);for(var r=0;r=14393&&-1===e.indexOf("?transport=udp")})),delete e.url,e.urls=i?n[0]:n,!!n.length}}))}(r.iceServers||[],t),this._iceGatherers=[],r.iceCandidatePoolSize)for(var a=r.iceCandidatePoolSize;a>0;a--)this._iceGatherers.push(new e.RTCIceGatherer({iceServers:r.iceServers,gatherPolicy:r.iceTransportPolicy}));else r.iceCandidatePoolSize=0;this._config=r,this.transceivers=[],this._sdpSessionId=n.generateSessionId(),this._sdpSessionVersion=0,this._dtlsRole=void 0,this._isClosed=!1};Object.defineProperty(d.prototype,"localDescription",{configurable:!0,get:function(){return this._localDescription}}),Object.defineProperty(d.prototype,"remoteDescription",{configurable:!0,get:function(){return this._remoteDescription}}),d.prototype.onicecandidate=null,d.prototype.onaddstream=null,d.prototype.ontrack=null,d.prototype.onremovestream=null,d.prototype.onsignalingstatechange=null,d.prototype.oniceconnectionstatechange=null,d.prototype.onconnectionstatechange=null,d.prototype.onicegatheringstatechange=null,d.prototype.onnegotiationneeded=null,d.prototype.ondatachannel=null,d.prototype._dispatchEvent=function(e,t){this._isClosed||(this.dispatchEvent(t),"function"==typeof this["on"+e]&&this["on"+e](t))},d.prototype._emitGatheringStateChange=function(){var e=new Event("icegatheringstatechange");this._dispatchEvent("icegatheringstatechange",e)},d.prototype.getConfiguration=function(){return this._config},d.prototype.getLocalStreams=function(){return this.localStreams},d.prototype.getRemoteStreams=function(){return this.remoteStreams},d.prototype._createTransceiver=function(e,t){var r=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,associatedRemoteMediaStreams:[],wantReceive:!0};if(this.usingBundle&&r)n.iceTransport=this.transceivers[0].iceTransport,n.dtlsTransport=this.transceivers[0].dtlsTransport;else{var i=this._createIceAndDtlsTransports();n.iceTransport=i.iceTransport,n.dtlsTransport=i.dtlsTransport}return t||this.transceivers.push(n),n},d.prototype.addTrack=function(t,r){if(this._isClosed)throw c("InvalidStateError","Attempted to call addTrack on a closed peerconnection.");var n;if(this.transceivers.find((function(e){return e.track===t})))throw c("InvalidAccessError","Track already exists.");for(var i=0;i=15025)e.getTracks().forEach((function(t){r.addTrack(t,e)}));else{var n=e.clone();e.getTracks().forEach((function(e,t){var r=n.getTracks()[t];e.addEventListener("enabled",(function(e){r.enabled=e.enabled}))})),n.getTracks().forEach((function(e){r.addTrack(e,n)}))}},d.prototype.removeTrack=function(t){if(this._isClosed)throw c("InvalidStateError","Attempted to call removeTrack on a closed peerconnection.");if(!(t instanceof e.RTCRtpSender))throw new TypeError("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.");var r=this.transceivers.find((function(e){return e.rtpSender===t}));if(!r)throw c("InvalidAccessError","Sender was not created by this connection.");var n=r.stream;r.rtpSender.stop(),r.rtpSender=null,r.track=null,r.stream=null,-1===this.transceivers.map((function(e){return e.stream})).indexOf(n)&&this.localStreams.indexOf(n)>-1&&this.localStreams.splice(this.localStreams.indexOf(n),1),this._maybeFireNegotiationNeeded()},d.prototype.removeStream=function(e){var t=this;e.getTracks().forEach((function(e){var r=t.getSenders().find((function(t){return t.track===e}));r&&t.removeTrack(r)}))},d.prototype.getSenders=function(){return this.transceivers.filter((function(e){return!!e.rtpSender})).map((function(e){return e.rtpSender}))},d.prototype.getReceivers=function(){return this.transceivers.filter((function(e){return!!e.rtpReceiver})).map((function(e){return e.rtpReceiver}))},d.prototype._createIceGatherer=function(t,r){var n=this;if(r&&t>0)return this.transceivers[0].iceGatherer;if(this._iceGatherers.length)return this._iceGatherers.shift();var i=new e.RTCIceGatherer({iceServers:this._config.iceServers,gatherPolicy:this._config.iceTransportPolicy});return Object.defineProperty(i,"state",{value:"new",writable:!0}),this.transceivers[t].bufferedCandidateEvents=[],this.transceivers[t].bufferCandidates=function(e){var r=!e.candidate||0===Object.keys(e.candidate).length;i.state=r?"completed":"gathering",null!==n.transceivers[t].bufferedCandidateEvents&&n.transceivers[t].bufferedCandidateEvents.push(e)},i.addEventListener("localcandidate",this.transceivers[t].bufferCandidates),i},d.prototype._gather=function(t,r){var i=this,o=this.transceivers[r].iceGatherer;if(!o.onlocalcandidate){var a=this.transceivers[r].bufferedCandidateEvents;this.transceivers[r].bufferedCandidateEvents=null,o.removeEventListener("localcandidate",this.transceivers[r].bufferCandidates),o.onlocalcandidate=function(e){if(!(i.usingBundle&&r>0)){var a=new Event("icecandidate");a.candidate={sdpMid:t,sdpMLineIndex:r};var s=e.candidate,c=!s||0===Object.keys(s).length;if(c)"new"!==o.state&&"gathering"!==o.state||(o.state="completed");else{"new"===o.state&&(o.state="gathering"),s.component=1,s.ufrag=o.getLocalParameters().usernameFragment;var u=n.writeCandidate(s);a.candidate=Object.assign(a.candidate,n.parseCandidate(u)),a.candidate.candidate=u,a.candidate.toJSON=function(){return{candidate:a.candidate.candidate,sdpMid:a.candidate.sdpMid,sdpMLineIndex:a.candidate.sdpMLineIndex,usernameFragment:a.candidate.usernameFragment}}}var d=n.getMediaSections(i._localDescription.sdp);d[a.candidate.sdpMLineIndex]+=c?"a=end-of-candidates\r\n":"a="+a.candidate.candidate+"\r\n",i._localDescription.sdp=n.getDescription(i._localDescription.sdp)+d.join("");var f=i.transceivers.every((function(e){return e.iceGatherer&&"completed"===e.iceGatherer.state}));"gathering"!==i.iceGatheringState&&(i.iceGatheringState="gathering",i._emitGatheringStateChange()),c||i._dispatchEvent("icecandidate",a),f&&(i._dispatchEvent("icecandidate",new Event("icecandidate")),i.iceGatheringState="complete",i._emitGatheringStateChange())}},e.setTimeout((function(){a.forEach((function(e){o.onlocalcandidate(e)}))}),0)}},d.prototype._createIceAndDtlsTransports=function(){var t=this,r=new e.RTCIceTransport(null);r.onicestatechange=function(){t._updateIceConnectionState(),t._updateConnectionState()};var n=new e.RTCDtlsTransport(r);return n.ondtlsstatechange=function(){t._updateConnectionState()},n.onerror=function(){Object.defineProperty(n,"state",{value:"failed",writable:!0}),t._updateConnectionState()},{iceTransport:r,dtlsTransport:n}},d.prototype._disposeIceAndDtlsTransports=function(e){var t=this.transceivers[e].iceGatherer;t&&(delete t.onlocalcandidate,delete this.transceivers[e].iceGatherer);var r=this.transceivers[e].iceTransport;r&&(delete r.onicestatechange,delete this.transceivers[e].iceTransport);var n=this.transceivers[e].dtlsTransport;n&&(delete n.ondtlsstatechange,delete n.onerror,delete this.transceivers[e].dtlsTransport)},d.prototype._transceive=function(e,r,i){var a=o(e.localCapabilities,e.remoteCapabilities);r&&e.rtpSender&&(a.encodings=e.sendEncodingParameters,a.rtcp={cname:n.localCName,compound:e.rtcpParameters.compound},e.recvEncodingParameters.length&&(a.rtcp.ssrc=e.recvEncodingParameters[0].ssrc),e.rtpSender.send(a)),i&&e.rtpReceiver&&a.codecs.length>0&&("video"===e.kind&&e.recvEncodingParameters&&t<15019&&e.recvEncodingParameters.forEach((function(e){delete e.rtx})),e.recvEncodingParameters.length?a.encodings=e.recvEncodingParameters:a.encodings=[{}],a.rtcp={compound:e.rtcpParameters.compound},e.rtcpParameters.cname&&(a.rtcp.cname=e.rtcpParameters.cname),e.sendEncodingParameters.length&&(a.rtcp.ssrc=e.sendEncodingParameters[0].ssrc),e.rtpReceiver.receive(a))},d.prototype.setLocalDescription=function(e){var t,r,i=this;if(-1===["offer","answer"].indexOf(e.type))return Promise.reject(c("TypeError",'Unsupported type "'+e.type+'"'));if(!a("setLocalDescription",e.type,i.signalingState)||i._isClosed)return Promise.reject(c("InvalidStateError","Can not set local "+e.type+" in state "+i.signalingState));if("offer"===e.type)t=n.splitSections(e.sdp),r=t.shift(),t.forEach((function(e,t){var r=n.parseRtpParameters(e);i.transceivers[t].localCapabilities=r})),i.transceivers.forEach((function(e,t){i._gather(e.mid,t)}));else if("answer"===e.type){t=n.splitSections(i._remoteDescription.sdp),r=t.shift();var s=n.matchPrefix(r,"a=ice-lite").length>0;t.forEach((function(e,t){var a=i.transceivers[t],c=a.iceGatherer,u=a.iceTransport,d=a.dtlsTransport,f=a.localCapabilities,p=a.remoteCapabilities;if(!(n.isRejected(e)&&0===n.matchPrefix(e,"a=bundle-only").length)&&!a.rejected){var l=n.getIceParameters(e,r),m=n.getDtlsParameters(e,r);s&&(m.role="server"),i.usingBundle&&0!==t||(i._gather(a.mid,t),"new"===u.state&&u.start(c,l,s?"controlling":"controlled"),"new"===d.state&&d.start(m));var h=o(f,p);i._transceive(a,h.codecs.length>0,!1)}}))}return i._localDescription={type:e.type,sdp:e.sdp},"offer"===e.type?i._updateSignalingState("have-local-offer"):i._updateSignalingState("stable"),Promise.resolve()},d.prototype.setRemoteDescription=function(i){var d=this;if(-1===["offer","answer"].indexOf(i.type))return Promise.reject(c("TypeError",'Unsupported type "'+i.type+'"'));if(!a("setRemoteDescription",i.type,d.signalingState)||d._isClosed)return Promise.reject(c("InvalidStateError","Can not set remote "+i.type+" in state "+d.signalingState));var f={};d.remoteStreams.forEach((function(e){f[e.id]=e}));var p=[],l=n.splitSections(i.sdp),m=l.shift(),h=n.matchPrefix(m,"a=ice-lite").length>0,v=n.matchPrefix(m,"a=group:BUNDLE ").length>0;d.usingBundle=v;var g=n.matchPrefix(m,"a=ice-options:")[0];return d.canTrickleIceCandidates=!!g&&g.substr(14).split(" ").indexOf("trickle")>=0,l.forEach((function(a,c){var u=n.splitLines(a),l=n.getKind(a),g=n.isRejected(a)&&0===n.matchPrefix(a,"a=bundle-only").length,y=u[0].substr(2).split(" ")[2],E=n.getDirection(a,m),b=n.parseMsid(a),_=n.getMid(a)||n.generateIdentifier();if(g||"application"===l&&("DTLS/SCTP"===y||"UDP/DTLS/SCTP"===y))d.transceivers[c]={mid:_,kind:l,protocol:y,rejected:!0};else{var S,T,w,R,M,C,P,O,I;!g&&d.transceivers[c]&&d.transceivers[c].rejected&&(d.transceivers[c]=d._createTransceiver(l,!0));var A,k,N=n.parseRtpParameters(a);g||(A=n.getIceParameters(a,m),(k=n.getDtlsParameters(a,m)).role="client"),P=n.parseRtpEncodingParameters(a);var U=n.parseRtcpParameters(a),L=n.matchPrefix(a,"a=end-of-candidates",m).length>0,x=n.matchPrefix(a,"a=candidate:").map((function(e){return n.parseCandidate(e)})).filter((function(e){return 1===e.component}));if(("offer"===i.type||"answer"===i.type)&&!g&&v&&c>0&&d.transceivers[c]&&(d._disposeIceAndDtlsTransports(c),d.transceivers[c].iceGatherer=d.transceivers[0].iceGatherer,d.transceivers[c].iceTransport=d.transceivers[0].iceTransport,d.transceivers[c].dtlsTransport=d.transceivers[0].dtlsTransport,d.transceivers[c].rtpSender&&d.transceivers[c].rtpSender.setTransport(d.transceivers[0].dtlsTransport),d.transceivers[c].rtpReceiver&&d.transceivers[c].rtpReceiver.setTransport(d.transceivers[0].dtlsTransport)),"offer"!==i.type||g){if("answer"===i.type&&!g){T=(S=d.transceivers[c]).iceGatherer,w=S.iceTransport,R=S.dtlsTransport,M=S.rtpReceiver,C=S.sendEncodingParameters,O=S.localCapabilities,d.transceivers[c].recvEncodingParameters=P,d.transceivers[c].remoteCapabilities=N,d.transceivers[c].rtcpParameters=U,x.length&&"new"===w.state&&(!h&&!L||v&&0!==c?x.forEach((function(e){s(S.iceTransport,e)})):w.setRemoteCandidates(x)),v&&0!==c||("new"===w.state&&w.start(T,A,"controlling"),"new"===R.state&&R.start(k)),!o(S.localCapabilities,S.remoteCapabilities).codecs.filter((function(e){return"rtx"===e.name.toLowerCase()})).length&&S.sendEncodingParameters[0].rtx&&delete S.sendEncodingParameters[0].rtx,d._transceive(S,"sendrecv"===E||"recvonly"===E,"sendrecv"===E||"sendonly"===E),!M||"sendrecv"!==E&&"sendonly"!==E?delete S.rtpReceiver:(I=M.track,b?(f[b.stream]||(f[b.stream]=new e.MediaStream),r(I,f[b.stream]),p.push([I,M,f[b.stream]])):(f.default||(f.default=new e.MediaStream),r(I,f.default),p.push([I,M,f.default])))}}else{(S=d.transceivers[c]||d._createTransceiver(l)).mid=_,S.iceGatherer||(S.iceGatherer=d._createIceGatherer(c,v)),x.length&&"new"===S.iceTransport.state&&(!L||v&&0!==c?x.forEach((function(e){s(S.iceTransport,e)})):S.iceTransport.setRemoteCandidates(x)),O=e.RTCRtpReceiver.getCapabilities(l),t<15019&&(O.codecs=O.codecs.filter((function(e){return"rtx"!==e.name}))),C=S.sendEncodingParameters||[{ssrc:1001*(2*c+2)}];var j,D=!1;if("sendrecv"===E||"sendonly"===E){if(D=!S.rtpReceiver,M=S.rtpReceiver||new e.RTCRtpReceiver(S.dtlsTransport,l),D)I=M.track,b&&"-"===b.stream||(b?(f[b.stream]||(f[b.stream]=new e.MediaStream,Object.defineProperty(f[b.stream],"id",{get:function(){return b.stream}})),Object.defineProperty(I,"id",{get:function(){return b.track}}),j=f[b.stream]):(f.default||(f.default=new e.MediaStream),j=f.default)),j&&(r(I,j),S.associatedRemoteMediaStreams.push(j)),p.push([I,M,j])}else S.rtpReceiver&&S.rtpReceiver.track&&(S.associatedRemoteMediaStreams.forEach((function(t){var r=t.getTracks().find((function(e){return e.id===S.rtpReceiver.track.id}));r&&function(t,r){r.removeTrack(t),r.dispatchEvent(new e.MediaStreamTrackEvent("removetrack",{track:t}))}(r,t)})),S.associatedRemoteMediaStreams=[]);S.localCapabilities=O,S.remoteCapabilities=N,S.rtpReceiver=M,S.rtcpParameters=U,S.sendEncodingParameters=C,S.recvEncodingParameters=P,d._transceive(d.transceivers[c],!1,D)}}})),void 0===d._dtlsRole&&(d._dtlsRole="offer"===i.type?"active":"passive"),d._remoteDescription={type:i.type,sdp:i.sdp},"offer"===i.type?d._updateSignalingState("have-remote-offer"):d._updateSignalingState("stable"),Object.keys(f).forEach((function(t){var r=f[t];if(r.getTracks().length){if(-1===d.remoteStreams.indexOf(r)){d.remoteStreams.push(r);var n=new Event("addstream");n.stream=r,e.setTimeout((function(){d._dispatchEvent("addstream",n)}))}p.forEach((function(e){var t=e[0],n=e[1];r.id===e[2].id&&u(d,t,n,[r])}))}})),p.forEach((function(e){e[2]||u(d,e[0],e[1],[])})),e.setTimeout((function(){d&&d.transceivers&&d.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),Promise.resolve()},d.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._isClosed=!0,this._updateSignalingState("closed")},d.prototype._updateSignalingState=function(e){this.signalingState=e;var t=new Event("signalingstatechange");this._dispatchEvent("signalingstatechange",t)},d.prototype._maybeFireNegotiationNeeded=function(){var t=this;"stable"===this.signalingState&&!0!==this.needNegotiation&&(this.needNegotiation=!0,e.setTimeout((function(){if(t.needNegotiation){t.needNegotiation=!1;var e=new Event("negotiationneeded");t._dispatchEvent("negotiationneeded",e)}}),0))},d.prototype._updateIceConnectionState=function(){var e,t={new:0,closed:0,checking:0,connected:0,completed:0,disconnected:0,failed:0};if(this.transceivers.forEach((function(e){e.iceTransport&&!e.rejected&&t[e.iceTransport.state]++})),e="new",t.failed>0?e="failed":t.checking>0?e="checking":t.disconnected>0?e="disconnected":t.new>0?e="new":t.connected>0?e="connected":t.completed>0&&(e="completed"),e!==this.iceConnectionState){this.iceConnectionState=e;var r=new Event("iceconnectionstatechange");this._dispatchEvent("iceconnectionstatechange",r)}},d.prototype._updateConnectionState=function(){var e,t={new:0,closed:0,connecting:0,connected:0,completed:0,disconnected:0,failed:0};if(this.transceivers.forEach((function(e){e.iceTransport&&e.dtlsTransport&&!e.rejected&&(t[e.iceTransport.state]++,t[e.dtlsTransport.state]++)})),t.connected+=t.completed,e="new",t.failed>0?e="failed":t.connecting>0?e="connecting":t.disconnected>0?e="disconnected":t.new>0?e="new":t.connected>0&&(e="connected"),e!==this.connectionState){this.connectionState=e;var r=new Event("connectionstatechange");this._dispatchEvent("connectionstatechange",r)}},d.prototype.createOffer=function(){var r=this;if(r._isClosed)return Promise.reject(c("InvalidStateError","Can not call createOffer after close"));var o=r.transceivers.filter((function(e){return"audio"===e.kind})).length,a=r.transceivers.filter((function(e){return"video"===e.kind})).length,s=arguments[0];if(s){if(s.mandatory||s.optional)throw new TypeError("Legacy mandatory/optional constraints not supported.");void 0!==s.offerToReceiveAudio&&(o=!0===s.offerToReceiveAudio?1:!1===s.offerToReceiveAudio?0:s.offerToReceiveAudio),void 0!==s.offerToReceiveVideo&&(a=!0===s.offerToReceiveVideo?1:!1===s.offerToReceiveVideo?0:s.offerToReceiveVideo)}for(r.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&&(r._createTransceiver("audio"),o--),a>0&&(r._createTransceiver("video"),a--);var u=n.writeSessionBoilerplate(r._sdpSessionId,r._sdpSessionVersion++);r.transceivers.forEach((function(i,o){var a=i.track,s=i.kind,c=i.mid||n.generateIdentifier();i.mid=c,i.iceGatherer||(i.iceGatherer=r._createIceGatherer(o,r.usingBundle));var u=e.RTCRtpSender.getCapabilities(s);t<15019&&(u.codecs=u.codecs.filter((function(e){return"rtx"!==e.name}))),u.codecs.forEach((function(e){"H264"===e.name&&void 0===e.parameters["level-asymmetry-allowed"]&&(e.parameters["level-asymmetry-allowed"]="1"),i.remoteCapabilities&&i.remoteCapabilities.codecs&&i.remoteCapabilities.codecs.forEach((function(t){e.name.toLowerCase()===t.name.toLowerCase()&&e.clockRate===t.clockRate&&(e.preferredPayloadType=t.payloadType)}))})),u.headerExtensions.forEach((function(e){(i.remoteCapabilities&&i.remoteCapabilities.headerExtensions||[]).forEach((function(t){e.uri===t.uri&&(e.id=t.id)}))}));var d=i.sendEncodingParameters||[{ssrc:1001*(2*o+1)}];a&&t>=15019&&"video"===s&&!d[0].rtx&&(d[0].rtx={ssrc:d[0].ssrc+1}),i.wantReceive&&(i.rtpReceiver=new e.RTCRtpReceiver(i.dtlsTransport,s)),i.localCapabilities=u,i.sendEncodingParameters=d})),"max-compat"!==r._config.bundlePolicy&&(u+="a=group:BUNDLE "+r.transceivers.map((function(e){return e.mid})).join(" ")+"\r\n"),u+="a=ice-options:trickle\r\n",r.transceivers.forEach((function(e,t){u+=i(e,e.localCapabilities,"offer",e.stream,r._dtlsRole),u+="a=rtcp-rsize\r\n",!e.iceGatherer||"new"===r.iceGatheringState||0!==t&&r.usingBundle||(e.iceGatherer.getLocalCandidates().forEach((function(e){e.component=1,u+="a="+n.writeCandidate(e)+"\r\n"})),"completed"===e.iceGatherer.state&&(u+="a=end-of-candidates\r\n"))}));var d=new e.RTCSessionDescription({type:"offer",sdp:u});return Promise.resolve(d)},d.prototype.createAnswer=function(){var r=this;if(r._isClosed)return Promise.reject(c("InvalidStateError","Can not call createAnswer after close"));if("have-remote-offer"!==r.signalingState&&"have-local-pranswer"!==r.signalingState)return Promise.reject(c("InvalidStateError","Can not call createAnswer in signalingState "+r.signalingState));var a=n.writeSessionBoilerplate(r._sdpSessionId,r._sdpSessionVersion++);r.usingBundle&&(a+="a=group:BUNDLE "+r.transceivers.map((function(e){return e.mid})).join(" ")+"\r\n"),a+="a=ice-options:trickle\r\n";var s=n.getMediaSections(r._remoteDescription.sdp).length;r.transceivers.forEach((function(e,n){if(!(n+1>s)){if(e.rejected)return"application"===e.kind?"DTLS/SCTP"===e.protocol?a+="m=application 0 DTLS/SCTP 5000\r\n":a+="m=application 0 "+e.protocol+" webrtc-datachannel\r\n":"audio"===e.kind?a+="m=audio 0 UDP/TLS/RTP/SAVPF 0\r\na=rtpmap:0 PCMU/8000\r\n":"video"===e.kind&&(a+="m=video 0 UDP/TLS/RTP/SAVPF 120\r\na=rtpmap:120 VP8/90000\r\n"),void(a+="c=IN IP4 0.0.0.0\r\na=inactive\r\na=mid:"+e.mid+"\r\n");var c;if(e.stream)"audio"===e.kind?c=e.stream.getAudioTracks()[0]:"video"===e.kind&&(c=e.stream.getVideoTracks()[0]),c&&t>=15019&&"video"===e.kind&&!e.sendEncodingParameters[0].rtx&&(e.sendEncodingParameters[0].rtx={ssrc:e.sendEncodingParameters[0].ssrc+1});var u=o(e.localCapabilities,e.remoteCapabilities);!u.codecs.filter((function(e){return"rtx"===e.name.toLowerCase()})).length&&e.sendEncodingParameters[0].rtx&&delete e.sendEncodingParameters[0].rtx,a+=i(e,u,"answer",e.stream,r._dtlsRole),e.rtcpParameters&&e.rtcpParameters.reducedSize&&(a+="a=rtcp-rsize\r\n")}}));var u=new e.RTCSessionDescription({type:"answer",sdp:a});return Promise.resolve(u)},d.prototype.addIceCandidate=function(e){var t,r=this;return e&&void 0===e.sdpMLineIndex&&!e.sdpMid?Promise.reject(new TypeError("sdpMLineIndex or sdpMid required")):new Promise((function(i,o){if(!r._remoteDescription)return o(c("InvalidStateError","Can not add ICE candidate without a remote description"));if(e&&""!==e.candidate){var a=e.sdpMLineIndex;if(e.sdpMid)for(var u=0;u0?n.parseCandidate(e.candidate):{};if("tcp"===f.protocol&&(0===f.port||9===f.port))return i();if(f.component&&1!==f.component)return i();if((0===a||a>0&&d.iceTransport!==r.transceivers[0].iceTransport)&&!s(d.iceTransport,f))return o(c("OperationError","Can not add ICE candidate"));var p=e.candidate.trim();0===p.indexOf("a=")&&(p=p.substr(2)),(t=n.getMediaSections(r._remoteDescription.sdp))[a]+="a="+(f.type?p:"end-of-candidates")+"\r\n",r._remoteDescription.sdp=n.getDescription(r._remoteDescription.sdp)+t.join("")}else for(var l=0;l=200&&o.enableAudioVolumeIndicator(o.audioVolumeIndicatorInterval)),r&&r(e,t)}),(function(e){o.sessionManager=void 0,n&&n(l.createError(l.ErrorCodes.OTHERS,e))}))}))},e.prototype.leaveRoom=function(e,t,r){var n,o=this;if("function"==typeof e?(r=t,t=e,n={keepRecording:!1}):n=e?{keepRecording:!!e.keepRecording}:{keepRecording:!1},"function"!=typeof t&&(t=function(){}),"function"!=typeof r&&(r=function(){}),!this.sessionManager){var a="please join room first";return i.default.warn(a),void r(l.createError(l.ErrorCodes.NOT_JOIN,a))}if(this.sessionManager.isDestroyed)return this.sessionManager=void 0,void t();this.sessionManager.leaveRoom(n,(function(e){i.default.debug(e," leave room"),o.sessionManager=void 0,t&&t()}),r)},e.prototype.publish=function(e,t){var r=this;if("function"!=typeof t&&(t=function(){}),!this.sessionManager){var n="please join room first";return i.default.warn(n),void t(l.createError(l.ErrorCodes.NOT_JOIN,n))}if(e&&f.streamValidator.isValidStreamId(e.previewId)){var o=e.previewId,a=this.previewStreamManager.getStream(o);if(!a){n="stream isnot found, maybe it has already been published or destroyed";return i.default.warn(n),void t(l.createError(l.ErrorCodes.STREAM_NOT_EXISTS,n))}this.sessionManager.publishStream(a,(function(){r.previewStreamManager.removeStream(o,!0).catch((function(e){i.default.error("publish stream failure when remove it "+e)}))}),t)}else{var s;if("function"==typeof e)t=e,s={audio:!0,video:!0,screen:!1};else if(e){if(e.screen&&e.video&&i.default.warn("both video and screen are true, only camera's video will be published"),e.screen&&e.audio&&i.default.warn("both audio and screen are true, only microphone's audio will be published"),e.audio&&e.video&&e.screen){n="audio, video and screen cannot be true at the same time";return i.default.warn(n),void("function"==typeof t&&t(l.createError(l.ErrorCodes.INVALID_PARAMETER,n)))}if(!(e.audio||e.video||e.screen||e.mediaStream)){n="audio, video and screen cannot be false at the same time";return i.default.warn(n),void("function"==typeof t&&t(l.createError(l.ErrorCodes.INVALID_PARAMETER,n)))}s={audio:!!e.audio,video:!!e.video,screen:!!e.screen,microphoneId:e.microphoneId,cameraId:e.cameraId,extensionId:e.extensionId,mediaStream:e.mediaStream,file:e.file,filePath:e.filePath},"boolean"==typeof e.screenAudio&&(s.screenAudio=e.screenAudio),e.facingMode&&y.includes(e.facingMode)&&(s.facingMode=e.facingMode)}else s={audio:!0,video:!0,screen:!1};if("function"!=typeof t&&(t=function(){}),!f.isValidString(s.microphoneId)){n="type error, the microphoneId is not blank or a valid string";return i.default.warn(n),void t(l.createError(l.ErrorCodes.INVALID_PARAMETER,n))}if(!f.isValidString(s.cameraId)){n="type error, the cameraId is not blank or a valid string";return i.default.warn(n),void t(l.createError(l.ErrorCodes.INVALID_PARAMETER,n))}if(s.mediaStream&&!(s.mediaStream instanceof MediaStream)){n="type error, the mediaStream is not a valid MediaStream";return i.default.warn(n),void t(l.createError(l.ErrorCodes.INVALID_PARAMETER,n))}if(!this.sessionManager){n="please join room first";return i.default.warn(n),void t(l.createError(l.ErrorCodes.NOT_JOIN,n))}this.sessionManager.publish(s,(function(){}),t)}},e.prototype.unpublish=function(e,t,r){var n;if("function"==typeof e){if(r=t,t=e,!(a=this.getStream())){var o="stream is not found";return i.default.warn(o),void(r&&r(l.createError(l.ErrorCodes.STREAM_NOT_EXISTS,o)))}n=a.sid}else{if(!f.isValidString(e)){o="the arguments are invalid";return i.default.warn(o),void(r&&r(l.createError(l.ErrorCodes.INVALID_PARAMETER,o)))}var a;if(!(a=this.getStream(e))){var o="stream is not found";return i.default.warn(o),void(r&&r(l.createError(l.ErrorCodes.STREAM_NOT_EXISTS,o)))}n=a.sid}if("function"!=typeof t&&(t=function(){}),"function"!=typeof r&&(r=function(){}),!this.sessionManager){o="please join room first";return i.default.warn(o),void r(l.createError(l.ErrorCodes.NOT_JOIN,o))}this.sessionManager.unpublish(n,t,r)},e.prototype.subscribe=function(e,t){if("function"!=typeof t&&(t=function(){}),!f.streamValidator.isValidStreamId(e)){var r="stream Id is invalid";return i.default.warn(r),void t(l.createError(l.ErrorCodes.INVALID_PARAMETER,r))}var n="vp8";if(n=/VP8/.exec(e)?"vp8":/H264/.exec(e)?"h264":"vp8",!this.supportedVideoCodecs.includes(n)){r="your browser can't decode the video of "+e+" stream";return i.default.warn(r),void t(l.createError(l.ErrorCodes.OTHERS,r))}if(!this.sessionManager){r="please join room first";return i.default.warn(r),void t(l.createError(l.ErrorCodes.NOT_JOIN,r))}this.sessionManager.subscribe(e,(function(){}),t)},e.prototype.unsubscribe=function(e,t,r){if("function"!=typeof t&&(t=function(){}),"function"!=typeof r&&(r=function(){}),!f.streamValidator.isValidStreamId(e)){var n="stream Id is invalid";return i.default.warn(n),void r(l.createError(l.ErrorCodes.INVALID_PARAMETER,n))}if(!this.sessionManager){n="please join room first";return i.default.warn(n),void r(l.createError(l.ErrorCodes.NOT_JOIN,n))}this.sessionManager.unsubscribe(e,t,r)},e.prototype.on=function(e,t){if(i.default.debug("Client on ",e),g.includes(e))this.eventManager.on(e,t);else{if("string"!=typeof e)throw l.createError(l.ErrorCodes.INVALID_PARAMETER,"not supported event type");i.default.warn(e+" is an invalid event type")}},e.prototype.off=function(e,t){if(i.default.debug("Client off ",e),g.includes(e))this.eventManager.off(e,t);else{if("string"!=typeof e)throw l.createError(l.ErrorCodes.INVALID_PARAMETER,"not supported event type");i.default.warn(e+" is an invalid event type")}},e.prototype.muteAudio=function(e){if(f.streamValidator.isValidStreamId(e)){var t=this.previewStreamManager.getStream(e);if(t)return t.muteAudio()}var r=this.getStream(e);return r?!!this.sessionManager&&this.sessionManager.muteAudio(r.sid,(function(){})):(i.default.warn("stream is not found"),!1)},e.prototype.unmuteAudio=function(e){if(f.streamValidator.isValidStreamId(e)){var t=this.previewStreamManager.getStream(e);if(t)return t.unmuteAudio()}var r=this.getStream(e);return r?!!this.sessionManager&&this.sessionManager.unmuteAudio(r.sid,(function(){})):(i.default.warn("stream is not found"),!1)},e.prototype.muteVideo=function(e){if(f.streamValidator.isValidStreamId(e)){var t=this.previewStreamManager.getStream(e);if(t)return t.muteVideo()}var r=this.getStream(e);return r?!!this.sessionManager&&this.sessionManager.muteVideo(r.sid,(function(){})):(i.default.warn("stream is not found"),!1)},e.prototype.unmuteVideo=function(e){if(f.streamValidator.isValidStreamId(e)){var t=this.previewStreamManager.getStream(e);if(t)return t.unmuteVideo()}var r=this.getStream(e);return r?!!this.sessionManager&&this.sessionManager.unmuteVideo(r.sid,(function(){})):(i.default.warn("stream is not found"),!1)},e.prototype.startRecording=function(e,t,r){e=e||{bucket:"",region:""};var n=this.getUser(),o=n&&n.uid||"",a=s.ENUM_MEDIA_TYPE.camera,c=1280,u=720,d=1,f=!0;if(e.mixStream&&"object"==typeof e.mixStream){switch(e.mixStream.uid&&"string"==typeof e.mixStream.uid&&(o=e.mixStream.uid),e.mixStream.type){case"desktop":case"screen":a=s.ENUM_MEDIA_TYPE.desktop;break;case"camera":default:a=s.ENUM_MEDIA_TYPE.camera}switch("number"==typeof e.mixStream.width&&e.mixStream.width>0&&(c=e.mixStream.width),"number"==typeof e.mixStream.height&&e.mixStream.height>0&&(u=e.mixStream.height),e.mixStream.template){case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 9:d=e.mixStream.template;break;default:d=1}"boolean"==typeof e.mixStream.isAverage&&(f=e.mixStream.isAverage)}if(e.uid&&"string"==typeof e.uid&&(o=e.uid),e.mainViewType&&"string"==typeof e.mainViewType)switch(e.mainViewType){case"desktop":case"screen":a=s.ENUM_MEDIA_TYPE.desktop;break;case"camera":default:a=s.ENUM_MEDIA_TYPE.camera}var p=s.ENUM_WATER_MARK_POS.lt,m=s.ENUM_WATER_MARK_TYPE.none,h="";if(e.waterMark&&"object"==typeof e.waterMark){switch(e.waterMark.position){case"left-top":p=s.ENUM_WATER_MARK_POS.lt;break;case"left-bottom":p=s.ENUM_WATER_MARK_POS.lb;break;case"right-top":p=s.ENUM_WATER_MARK_POS.rt;break;case"right-bottom":p=s.ENUM_WATER_MARK_POS.rb;break;default:p=s.ENUM_WATER_MARK_POS.lt}switch(e.waterMark.type){case"image":m=s.ENUM_WATER_MARK_TYPE.image,"string"==typeof e.waterMark.remarks&&(h=e.waterMark.remarks);break;case"text":m=s.ENUM_WATER_MARK_TYPE.text,"string"==typeof e.waterMark.remarks&&(h=e.waterMark.remarks);break;case"time":default:m=s.ENUM_WATER_MARK_TYPE.time,h=""}}var v=!1,g=parseInt((+new Date/1e3).toString()),y=60;e.relay&&"object"==typeof e.relay&&(v=!0,"number"==typeof e.relay.time&&e.relay.time>0&&(g=e.relay.time),"number"==typeof e.relay.fragment&&e.relay.fragment>0&&(y=e.relay.fragment));var E={waterMarkPos:p,waterMarkType:m,waterMarkRemarks:h,mixStreamUId:o,mixStreamType:a,mixStreamWidth:c,mixStreamHeight:u,mixStreamTemplate:d,isAverage:f,bucket:e.bucket,region:e.region,isRelay:v,relayTime:g,relayFragment:y};if("function"!=typeof t&&(t=function(){}),"function"!=typeof r&&(r=function(){}),!this.sessionManager){var b="please join room first";return i.default.warn(b),void r(l.createError(l.ErrorCodes.NOT_JOIN,b))}this.sessionManager.startRecording(E,t,r)},e.prototype.stopRecording=function(e,t){if("function"!=typeof e&&(e=function(){}),"function"!=typeof t&&(t=function(){}),!this.sessionManager){var r="please join room first";return i.default.warn(r),void t(l.createError(l.ErrorCodes.NOT_JOIN,r))}this.sessionManager.stopRecording(e,t)},e.prototype.getUser=function(){if(this.sessionManager)return d.convertToOuterUser(this.sessionManager.user)},e.prototype.getUsers=function(){return this.sessionManager?this.sessionManager.users.map((function(e){return d.convertToOuterUser(e)})):[]},e.prototype.sync=function(e){var t=function(t){e&&e(t)};if(!this.sessionManager){var r="please join room first";return i.default.warn(r),void t(l.createError(l.ErrorCodes.NOT_JOIN,r))}this.sessionManager.syncRoom().then((function(){t()})).catch((function(e){t(e)}))},e.prototype.getStream=function(e){if(f.streamValidator.isValidStreamId(e)){var t=this.previewStreamManager.getStream(e);if(t)return t.convertToOuterStream()}var r;if(this.sessionManager)return f.streamValidator.isValidStreamId(e)?(r=this.sessionManager.streamManager.getStream(e))&&r.convertToOuterStream():(r=this.sessionManager.streamManager.getAllLocalStreams()[0])&&r.convertToOuterStream()},e.prototype.getLocalStreams=function(){var e=[];return this.sessionManager&&this.sessionManager.streamManager.getAllLocalStreams().forEach((function(t){e.push(t.convertToOuterStream())})),this.previewStreamManager.getAllStreams().forEach((function(t){e.push(t.convertToOuterStream())})),e},e.prototype.getRemoteStreams=function(){return this.sessionManager?this.sessionManager.streamManager.getAllRemoteStreams().map((function(e){return e.convertToOuterStream()})):[]},e.prototype.getStreams=function(){return i.default.warn("getStreams is deprecated, please use getRemoteStreams"),this.getRemoteStreams()},e.prototype.getMediaStream=function(e){var t=this.getStream(e);return t&&t.mediaStream},e.prototype.getLocalMediaStream=function(e){return i.default.warn("getLocalMediaStream is deprecated, please use getMediaStream"),this.getMediaStream(e)},e.prototype.getRemoteMediaStream=function(e){return i.default.warn("getLocalMediaStream is deprecated, please use getMediaStream"),this.getMediaStream(e)},e.prototype.play=function(e,t){var r,n=(e=e||{}).streamId,o=e.container,a=e.mirror,s=void 0!==a&&a,c=e.fit,u=e.controls;if(!f.streamValidator.isValidStreamId(n)){var d="stream Id is invalid";return i.default.warn(d),void(t&&t(l.createError(l.ErrorCodes.INVALID_PARAMETER,d)))}var p=null;if("string"==typeof o&&(p=document.getElementById(o)),o instanceof HTMLElement&&(p=o),!p){d="container is invalid";return i.default.warn(d),void(t&&t(l.createError(l.ErrorCodes.INVALID_PARAMETER,d)))}var m=!1,h=!0;Object.prototype.toString.call(e.mute).indexOf("Boolean")>=0&&(m=e.mute,h=e.mute);var v={mute:m,mirror:!!s,controls:u};if(c)switch(c){case"contain":case"cover":v.fit=c;break;default:v.fit="cover"}if(u)switch(u){case"show":case"hide":case"auto":v.controls=u;break;default:v.controls="auto"}var g=this.previewStreamManager.getStream(n);if(g)return v.mute=h,void g.play(p,v).then((function(){t&&t()})).catch((function(e){t&&t(e)}));var y=null===(r=this.sessionManager)||void 0===r?void 0:r.streamManager.getStream(n);y?(y.isSubscriber||(v.mute=h),y.play(p,v).then((function(){t&&t()})).catch((function(e){t&&t(e)}))):t&&t(l.createError(l.ErrorCodes.STREAM_NOT_EXISTS,"stream is not exist"))},e.prototype.resume=function(e,t){var r,n=this.previewStreamManager.getStream(e);if(n)n.resume().then((function(){t&&t()})).catch((function(e){t&&t(e)}));else{var i=null===(r=this.sessionManager)||void 0===r?void 0:r.streamManager.getStream(e);i?i.resume().then((function(){t&&t()})).catch((function(e){t&&t(e)})):t&&t(l.createError(l.ErrorCodes.STREAM_NOT_EXISTS,"stream is not exist"))}},e.prototype.pause=function(e,t){var r,n=this.previewStreamManager.getStream(e);if(n)n.stop().then((function(){t&&t()})).catch((function(e){t&&t(e)}));else{var i=null===(r=this.sessionManager)||void 0===r?void 0:r.streamManager.getStream(e);i?i.stop().then((function(){t&&t()})).catch((function(e){t&&t(e)})):t&&t(l.createError(l.ErrorCodes.STREAM_NOT_EXISTS,"stream is not exist"))}},e.prototype.stop=function(e,t){var r,n=this.previewStreamManager.getStream(e);if(n)return n.destroyPlayer(),void(t&&t());var i=null===(r=this.sessionManager)||void 0===r?void 0:r.streamManager.getStream(e);i?(i.destroyPlayer(),t&&t()):t&&t(l.createError(l.ErrorCodes.STREAM_NOT_EXISTS,"stream is not exist"))},e.prototype.getMicrophones=function(e,t,r){"function"==typeof e&&(r=t,t=e,e={microphone:!0,camera:!1}),"function"!=typeof t&&(t=function(){}),"function"!=typeof r&&(r=function(){});var n={microphone:!0,camera:!1};e&&(n.microphone=!!e.microphone),c.StreamManager.enumerateDevices(n,(function(e){t&&t(e.filter((function(e){return"audioinput"===e.kind})))}),r)},e.prototype.getCameras=function(e,t,r){"function"==typeof e&&(r=t,t=e,e={microphone:!1,camera:!0}),"function"!=typeof t&&(t=function(){}),"function"!=typeof r&&(r=function(){});var n={microphone:!1,camera:!0};e&&(n.camera=!!e.camera),c.StreamManager.enumerateDevices(n,(function(e){t&&t(e.filter((function(e){return"videoinput"===e.kind})))}),r)},e.prototype.getLoudspeakers=function(e,t){"function"!=typeof e&&(e=function(){}),"function"!=typeof t&&(t=function(){}),c.StreamManager.enumerateDevices({microphone:!1,camera:!1},(function(t){e&&e(t.filter((function(e){return"audiooutput"===e.kind})))}),t)},e.prototype.setVideoProfile=function(e,t,r){var n,o,a,c,u=this;if("object"==typeof e&&e.profile?(a=e.streamId||e.previewId,c=e.profile):c=e,"function"!=typeof t&&(t=function(){}),"function"!=typeof r&&(r=function(){}),"string"==typeof c){var d=p.getSupportProfileNames(),m=p.getInternalSupportProfileNames();if(!d.concat(m).includes(c)){var h=c+" is not supported, you can invoke getSupportProfileNames function to get supported profile";return i.default.warn(h),void r(l.createError(l.ErrorCodes.INVALID_PARAMETER,h))}}else if(!(f.isValidNumber(c.width,!0)&&f.isValidNumber(c.height,!0)&&f.isValidNumber(c.framerate,!0)&&f.isValidNumber(c.bitrate,!0))){h="profile's width, height, framerate or bitrate is invalid, a valid sample is {width: 640, height: 480, framerate: 20, bitrate: 500}";return i.default.warn(h),void r(l.createError(l.ErrorCodes.INVALID_PARAMETER,h))}if(f.streamValidator.isValidStreamId(a)){var v=this.getStream(a);if(!v){h="stream is not found";return void r(l.createError(l.ErrorCodes.STREAM_NOT_EXISTS,h))}var g=this.previewStreamManager.getStream(v.sid);if(!g){if(g=null===(n=this.sessionManager)||void 0===n?void 0:n.streamManager.getLocalStream(v.sid)){var y=void 0;if(y="object"==typeof c?p.getCustomResolution(c):p.getResolution(c),g.mediaType===s.ENUM_MEDIA_TYPE.desktop){h="stream of sharing screen cannot update profile after created";return void r(l.createError(l.ErrorCodes.NOT_SUPPORT,h))}return void(null===(o=this.sessionManager)||void 0===o||o.updateVP(g,y).then((function(){var e;return null===(e=u.sessionManager)||void 0===e?void 0:e.streamManager.setVideoProfile(c,g)})).catch((function(e){r&&r(e)})))}var h="stream is not found";return void r(l.createError(l.ErrorCodes.STREAM_NOT_EXISTS,h))}this.previewStreamManager.setVideoProfile(g.streamId,c).then((function(){t&&t()})).catch((function(e){r&&r(e)}))}else this.profileName=c,this.sessionManager&&this.sessionManager.streamManager.setVideoProfile(c).catch((function(e){return i.default.warn("set video profile ",e)})),t()},e.prototype.switchDevice=function(e,t,r){var n,o,a;if("object"==typeof e)n=e.streamId,o=e.deviceId,a=e.type;else{var s=Array.prototype.slice.call(arguments),c=s[0],u=s[1],d=s[2],f=s[3];a=c,o=u,t=d,r=f}var p=function(e){"function"==typeof t&&t(e)},h=function(e){"function"==typeof r&&r(e)};if(o&&"string"==typeof o){var v=this.getStream(n);if(v){var g=this.previewStreamManager.getStream(v.sid);if(!g&&this.sessionManager&&(g=this.sessionManager.streamManager.getLocalStream(v.sid)),g)switch(a){case"audio":g.switchMicrophone(o).then(p).catch(h);break;case"video":g.switchCamera(o).then((function(){var e;m.default.isFirefox()&&(null===(e=g)||void 0===e||e.resume().catch((function(e){i.default.warn("resume after switch device ",e)}))),p()})).catch(h);break;default:y="device type unknown";h(l.createError(l.ErrorCodes.INVALID_PARAMETER,y))}else{y="stream is not found";h(l.createError(l.ErrorCodes.STREAM_NOT_EXISTS,y))}}else{var y="stream is not found";h(l.createError(l.ErrorCodes.STREAM_NOT_EXISTS,y))}}else{var y="device Id is invalid";h(l.createError(l.ErrorCodes.INVALID_PARAMETER,y))}},e.prototype.switchScreen=function(e,t,r){"function"==typeof e&&(r=t,t=e,e=void 0);var n=function(e){"function"==typeof r&&r(e)},i=this.getStream(e);if(i){var o=this.previewStreamManager.getStream(i.sid);if(!o&&this.sessionManager&&(o=this.sessionManager.streamManager.getLocalStream(i.sid)),o)o.switchScreen().then((function(e){"function"==typeof t&&t(e)})).catch(n);else{a="stream is not found";n(l.createError(l.ErrorCodes.STREAM_NOT_EXISTS,a))}}else{var a="stream is not found";n(l.createError(l.ErrorCodes.STREAM_NOT_EXISTS,a))}},e.prototype.switchImage=function(e,t,r){var n,o;"object"!=typeof e||e instanceof File?o=e:(n=e.streamId,o=e.file?e.file:e.filePath?e.filePath:"");var a=function(e){"function"==typeof r&&r(e)};if(!o||!("string"==typeof o||o instanceof File)){var s="both file and filePath are invalid";return i.default.warn(s),void a(l.createError(l.ErrorCodes.INVALID_PARAMETER,s))}var c=this.getStream(n);if(c){var u=this.previewStreamManager.getStream(c.sid);if(!u&&this.sessionManager&&(u=this.sessionManager.streamManager.getLocalStream(c.sid)),u)u.switchImage(o).then((function(e){"function"==typeof t&&t(e)})).catch(a);else{s="stream is not found";a(l.createError(l.ErrorCodes.STREAM_NOT_EXISTS,s))}}else{var s="stream is not found";a(l.createError(l.ErrorCodes.STREAM_NOT_EXISTS,s))}},e.prototype.getAudioVolume=function(e){if(f.streamValidator.isValidStreamId(e)){var t=this.previewStreamManager.getStream(e);if(t)return Math.floor(100*t.getAudioVolume())}var r=this.getStream(e);if(!r)return i.default.warn("stream is not found"),0;if(this.sessionManager){var n=this.sessionManager.streamManager.getStream(r.sid);if(n)return Math.floor(100*n.getAudioVolume())}return i.default.warn("stream is not found"),0},e.prototype.setAudioVolume=function(e,t){var r=(e=e||{}).streamId,n=e.volume;if("function"!=typeof t&&(t=function(){}),f.isValidVolume(n)){if(f.streamValidator.isValidStreamId(r)){var i=this.previewStreamManager.getStream(r);i&&i.setAudioVolume(n).then(t).catch(t)}var o=this.getStream(r);if(o){if(this.sessionManager){var a=this.sessionManager.streamManager.getStream(o.sid);if(a)a.isSubscriber&&e.element instanceof HTMLMediaElement?(e.element.volume=n/100,t()):a.setAudioVolume(n).then(t).catch(t);else{s="stream is not found";t(l.createError(l.ErrorCodes.STREAM_NOT_EXISTS,s))}}}else{var s="stream is not found";t(l.createError(l.ErrorCodes.STREAM_NOT_EXISTS,s))}}else{var s="volume is invalid";t(l.createError(l.ErrorCodes.INVALID_PARAMETER,s))}},e.prototype.getAudioStats=function(e,t,r){var n;if("function"==typeof e){if(r=t,t=e,!(a=this.getStream())){var o="stream is not found";return i.default.warn(o),void(r&&r(l.createError(l.ErrorCodes.STREAM_NOT_EXISTS,o)))}n=a.sid}else if("string"==typeof e)n=e;else{if(e){o="the arguments are invalid";return i.default.warn(o),void(r&&r(l.createError(l.ErrorCodes.INVALID_PARAMETER,o)))}var a;if(!(a=this.getStream())){var o="stream is not found";return i.default.warn(o),void(r&&r(l.createError(l.ErrorCodes.STREAM_NOT_EXISTS,o)))}n=a.sid}if("function"!=typeof t&&(t=function(){}),"function"!=typeof r&&(r=function(){}),!this.sessionManager){o="please join room first";return i.default.warn(o),void r(l.createError(l.ErrorCodes.NOT_JOIN,o))}var s=this.sessionManager.streamManager.getStream(n);if(!s){o="stream is not found";return i.default.warn(o),void(r&&r(l.createError(l.ErrorCodes.STREAM_NOT_EXISTS,o)))}s.getStats2().then((function(e){t&&t(e.audio)})).catch(r)},e.prototype.getVideoStats=function(e,t,r){var n;if("function"==typeof e){if(r=t,t=e,!(a=this.getStream())){var o="stream is not found";return i.default.warn(o),void(r&&r(l.createError(l.ErrorCodes.STREAM_NOT_EXISTS,o)))}n=a.sid}else if("string"==typeof e)n=e;else{if(e){o="the arguments are invalid";return i.default.warn(o),void(r&&r(l.createError(l.ErrorCodes.INVALID_PARAMETER,o)))}var a;if(!(a=this.getStream())){var o="stream is not found";return i.default.warn(o),void(r&&r(l.createError(l.ErrorCodes.STREAM_NOT_EXISTS,o)))}n=a.sid}if("function"!=typeof t&&(t=function(){}),"function"!=typeof r&&(r=function(){}),!this.sessionManager){o="please join room first";return i.default.warn(o),void r(l.createError(l.ErrorCodes.NOT_JOIN,o))}var s=this.sessionManager.streamManager.getStream(n);if(!s){o="stream is not found";return i.default.warn(o),void(r&&r(l.createError(l.ErrorCodes.STREAM_NOT_EXISTS,o)))}s.getStats2().then((function(e){t&&t(e.video)})).catch(r)},e.prototype.getNetworkStats=function(e,t,r){var n;if("function"==typeof e){if(r=t,t=e,!(a=this.getStream())){var o="stream is not found";return i.default.warn(o),void(r&&r(l.createError(l.ErrorCodes.STREAM_NOT_EXISTS,o)))}n=a.sid}else if("string"==typeof e)n=e;else{if(e){o="the arguments are invalid";return i.default.warn(o),void(r&&r(l.createError(l.ErrorCodes.INVALID_PARAMETER,o)))}var a;if(!(a=this.getStream())){var o="stream is not found";return i.default.warn(o),void(r&&r(l.createError(l.ErrorCodes.STREAM_NOT_EXISTS,o)))}n=a.sid}if("function"!=typeof t&&(t=function(){}),"function"!=typeof r&&(r=function(){}),!this.sessionManager){o="please join room first";return i.default.warn(o),void(r&&r(l.createError(l.ErrorCodes.NOT_JOIN,o)))}var s=this.sessionManager.streamManager.getStream(n);if(!s){o="stream is not found";return i.default.warn(o),void(r&&r(l.createError(l.ErrorCodes.STREAM_NOT_EXISTS,o)))}s.getStats2().then((function(e){var r={rtt:-1!==e.connection.rtt?e.connection.rtt:e.connection.delay};t&&t(r)})).catch(r)},e.prototype.preloadEffect=function(e,t,r){var n;return"function"!=typeof r&&(r=function(){}),f.effectValidator.isValidId(e)?f.effectValidator.isValidFilePath(t,!0)?void this.effectManager.preloadEffect(e,t).then((function(){r&&r()})).catch((function(e){r&&r(e)})):(n="filePath is invalid",i.default.warn(n),void r(l.createError(l.ErrorCodes.INVALID_PARAMETER,n))):(n="effectId is invalid",i.default.warn(n),void r(l.createError(l.ErrorCodes.INVALID_PARAMETER,n)))},e.prototype.unloadEffect=function(e){if(!f.effectValidator.isValidId(e))return"effectId is invalid",void i.default.warn("effectId is invalid");this.effectManager.unloadEffect(e)},e.prototype.__getLocalStream=function(e){if(f.streamValidator.isValidStreamId(e)){var t=this.previewStreamManager.getStream(e);if(t)return t}if(this.sessionManager)return f.streamValidator.isValidStreamId(e)?this.sessionManager.streamManager.getLocalStream(e):this.sessionManager.streamManager.getAllLocalStreams()[0]},e.prototype.__getRemoteStream=function(e){if(this.sessionManager&&f.streamValidator.isValidStreamId(e))return this.sessionManager.streamManager.getRemoteStream(e)},e.prototype.playEffect=function(e,t){if("function"!=typeof t&&(t=function(){}),!f.effectValidator.isValidEffectOptions(e)){var r="EffectOptions is invalid";return i.default.warn(r),void t(l.createError(l.ErrorCodes.INVALID_PARAMETER,r))}var n,o={effectId:e.effectId,loop:!1,playTime:0,replace:!1};if(e.filePath&&(o.filePath=e.filePath),e.playTime&&(o.playTime=e.playTime),e.loop&&(o.loop=!0),e.replace&&(o.replace=!0),e.onEnd&&"function"==typeof e.onEnd&&(o.onEnd=e.onEnd),e.streamId)n=e.streamId;else{var a=this.getStream();if(!a){r="stream is not found";return i.default.warn(r),void t(l.createError(l.ErrorCodes.STREAM_NOT_EXISTS,r))}n=a.sid}var s=this.__getLocalStream(n);if(s){var c=this.effectManager.getCachedEffect(o.effectId);if(c)s.playEffect(c,o,t);else{if("string"!=typeof o.filePath){o.filePath=e.filePath;r="Cannot find effect and filePath is invalid";return i.default.warn(r),void t(l.createError(l.ErrorCodes.INVALID_PARAMETER,r))}this.effectManager.preloadEffect(o.effectId,o.filePath).then((function(e){s.playEffect(e,o,t)})).catch((function(e){t&&t(e)}))}}else{r="stream is not found";i.default.warn(r),t(l.createError(l.ErrorCodes.STREAM_NOT_EXISTS,r))}},e.prototype.pauseEffect=function(e,t){if("function"!=typeof t&&(t=function(){}),!f.effectValidator.isValidEffectOptions(e)){var r="EffectOptions is invalid";return i.default.warn(r),void t(l.createError(l.ErrorCodes.INVALID_PARAMETER,r))}var n;if(e.streamId)n=e.streamId;else{var o=this.getStream();if(!o){r="stream is not found";return i.default.warn(r),void t(l.createError(l.ErrorCodes.STREAM_NOT_EXISTS,r))}n=o.sid}var a=this.__getLocalStream(n);if(a)a.pauseEffect(e.effectId,t);else{r="stream is not found";i.default.warn(r),t(l.createError(l.ErrorCodes.STREAM_NOT_EXISTS,r))}},e.prototype.resumeEffect=function(e,t){if("function"!=typeof t&&(t=function(){}),!f.effectValidator.isValidEffectOptions(e)){var r="EffectOptions is invalid";return i.default.warn(r),void t(l.createError(l.ErrorCodes.INVALID_PARAMETER,r))}var n;if(e.streamId)n=e.streamId;else{var o=this.getStream();if(!o){r="stream is not found";return i.default.warn(r),void t(l.createError(l.ErrorCodes.STREAM_NOT_EXISTS,r))}n=o.sid}var a=this.__getLocalStream(n);if(a){var s=this.effectManager.getCachedEffect(e.effectId);if(s)a.resumeEffect(s,e.effectId,t);else{r="Invalid effect, effect may already unloaded";i.default.warn(r),t(l.createError(l.ErrorCodes.INVALID_PARAMETER,r))}}else{r="stream is not found";i.default.warn(r),t(l.createError(l.ErrorCodes.STREAM_NOT_EXISTS,r))}},e.prototype.stopEffect=function(e,t){if("function"!=typeof t&&(t=function(){}),!f.effectValidator.isValidEffectOptions(e)){var r="EffectOptions is invalid";return i.default.warn(r),void t(l.createError(l.ErrorCodes.INVALID_PARAMETER,r))}var n;if(e.streamId)n=e.streamId;else{var o=this.getStream();if(!o){r="stream is not found";return i.default.warn(r),void t(l.createError(l.ErrorCodes.STREAM_NOT_EXISTS,r))}n=o.sid}var a=this.__getLocalStream(n);if(a)a.stopEffect(e.effectId,t);else{r="stream is not found";i.default.warn(r),t(l.createError(l.ErrorCodes.STREAM_NOT_EXISTS,r))}},e.prototype.setEffectVolume=function(e,t){if("function"!=typeof t&&(t=function(){}),!f.effectValidator.isValidEffectOptions(e)){var r="EffectVolumeOptions is invalid";return i.default.warn(r),void t(l.createError(l.ErrorCodes.INVALID_PARAMETER,r))}var n;if(e.streamId)n=e.streamId;else{var o=this.getStream();if(!o){r="stream is not found";return i.default.warn(r),void t(l.createError(l.ErrorCodes.STREAM_NOT_EXISTS,r))}n=o.sid}var a=this.__getLocalStream(n);if(a)a.setEffectVolume(e.effectId,e.volume,t);else{r="stream is not found";i.default.warn(r),t(l.createError(l.ErrorCodes.STREAM_NOT_EXISTS,r))}},e.prototype.snapshot=function(e,t,r){"function"==typeof e&&(r=t,t=e,e={});var n,o,a,s=function(e){"function"==typeof r&&r(e)},c=(e=e||{}).streamId,u=e.download;if(c)n=c;else{var d=this.getStream();if(!d){var f="stream is not found";return i.default.warn(f),void s(l.createError(l.ErrorCodes.STREAM_NOT_EXISTS,f))}n=d.sid}if(u){if("string"!=typeof u&&"boolean"!=typeof u){f="download is invalid, it should be string or boolean";return i.default.warn(f),void s(l.createError(l.ErrorCodes.INVALID_PARAMETER,f))}o=u}else o=!1;if((a=this.__getRemoteStream(n))||(a=this.__getLocalStream(n)),a){var p="";"string"==typeof o?p=o:o&&(p="urtc-snapshot-"+h.formatTime(new Date,"YYYY-MM-DD_HHmmss")),a.snapshot(p).then((function(e){"function"==typeof t&&t(e)})).catch(s)}else{f="stream is not found";i.default.warn(f),s(l.createError(l.ErrorCodes.STREAM_NOT_EXISTS,f))}},e.prototype.startPreviewing=function(e,t,r){"function"==typeof e&&(r=t,t=e,e={audio:!0,video:!0});var n=function(e){"function"==typeof r&&r(e)},o={audio:!0,video:!0,screen:!1};if("object"==typeof e&&(o.audio=e.audio,o.video=e.video,o.facingMode=e.facingMode,o.microphoneId=e.microphoneId,o.cameraId=e.cameraId),!o.audio&&!o.video){var a="audio or video must be true";return i.default.warn(a),void n(l.createError(l.ErrorCodes.INVALID_PARAMETER,a))}if(o.facingMode&&!y.includes(o.facingMode)){a="facingMode is invalid";return i.default.warn(a),void n(l.createError(l.ErrorCodes.INVALID_PARAMETER,a))}if(o.microphoneId&&"string"!=typeof o.microphoneId){a="microphoneId is invalid";return i.default.warn(a),void n(l.createError(l.ErrorCodes.INVALID_PARAMETER,a))}if(o.cameraId&&"string"!=typeof o.cameraId){a="cameraId is invalid";return i.default.warn(a),void n(l.createError(l.ErrorCodes.INVALID_PARAMETER,a))}if(this.previewStreamManager.getStream("preview")){a="you are previewing";n(l.createError(l.ErrorCodes.OTHERS,a))}else{var s=this.getUser(),c=s?s.uid:"unknown";this.previewStreamManager.createStream(c,"preview",o,this.profileName).then((function(e){!function(e){"function"==typeof t&&t(e)}(e.getMediaStream())})).catch(n)}},e.prototype.stopPreviewing=function(){this.previewStreamManager.removeStream("preview",!1).catch((function(e){i.default.warn("stop previewing "+e)}))},e.prototype.deviceDetection=function(e,t){"function"==typeof e&&(t=e,e={audio:!0,video:!0});var r={audio:!0,video:!0};if("object"==typeof e&&(r.audio=e.audio,r.video=e.video,r.microphoneId=e.microphoneId,r.cameraId=e.cameraId),r.audio||r.video)if(r.microphoneId&&"string"!=typeof r.microphoneId){n="microphoneId is invalid";i.default.warn(n)}else if(r.cameraId&&"string"!=typeof r.cameraId){n="cameraId is invalid";i.default.warn(n)}else c.StreamManager.deviceDetection(r).then((function(e){"function"==typeof t&&t(e)})).catch((function(e){i.default.warn("device detection ",e)}));else{var n="audio or video must be true";i.default.warn(n)}},e.prototype.replaceTrack=function(e,t){var r=(e=e||{}).streamId,n=e.track,i=e.retain;if("function"!=typeof t&&(t=function(){}),n instanceof MediaStreamTrack){var o=!!i;if(f.streamValidator.isValidStreamId(r))if(s=this.previewStreamManager.getStream(r)){try{t(void 0,s.replaceTrack(n,o))}catch(c){t(c)}return}var a=this.getStream(r);if(a)if(this.sessionManager){var s;if(s=this.sessionManager.streamManager.getLocalStream(a.sid)){try{t(void 0,s.replaceTrack(n,o))}catch(c){t(c)}return}c="stream is not found";t(l.createError(l.ErrorCodes.STREAM_NOT_EXISTS,c))}else t(l.createError(l.ErrorCodes.STREAM_NOT_EXISTS,"stream is not found"));else{var c="stream is not found";t(l.createError(l.ErrorCodes.STREAM_NOT_EXISTS,c))}}else{var c="invalid track, please check the 'track' parameter";t(l.createError(l.ErrorCodes.INVALID_PARAMETER,c))}},e.prototype.startMix=function(e,t){e=e||{bucket:"",region:""},"function"!=typeof t&&(t=function(){});var r=this.getUser(),n=s.ENUM_MIX_TYPE.record;switch(e.type){case"relay":n=s.ENUM_MIX_TYPE.relay;break;case"relay-and-record":n=s.ENUM_MIX_TYPE.relayRecord;break;case"update-config":n=s.ENUM_MIX_TYPE.update;break;case"record":default:n=s.ENUM_MIX_TYPE.record}var o=[];if(n===s.ENUM_MIX_TYPE.relay||n===s.ENUM_MIX_TYPE.relayRecord){if("[object Array]"!==Object.prototype.toString.call(e.pushURL))return void t(N=l.createError(l.ErrorCodes.INVALID_PARAMETER,"type is "+n+", pushURL must be an array"));o=e.pushURL?e.pushURL:o}var a=0;if("number"==typeof e.timeoutPeriod){var c=e.timeoutPeriod;if(!(c>=60&&c<=86400))return void t(N=l.createError(l.ErrorCodes.INVALID_PARAMETER,"timeoutPeriod must be >= 60 and <= 86400"));a=c}var u=s.ENUM_MIX_LAYOUT.flow,d=[],p=r&&r.uid||"",m=s.ENUM_MEDIA_TYPE.camera,h=[];if(e.layout&&"object"==typeof e.layout){switch(p=e.layout.mainViewUId?e.layout.mainViewUId:p,e.layout.mainViewType){case"screen":case"desktop":m=s.ENUM_MEDIA_TYPE.desktop;break;case"camera":default:m=s.ENUM_MEDIA_TYPE.camera}switch(e.layout.type){case"main":u=s.ENUM_MIX_LAYOUT.main;break;case"custom":u=s.ENUM_MIX_LAYOUT.custom,d=e.layout.custom?e.layout.custom:d;break;case"customMain":u=s.ENUM_MIX_LAYOUT.customMain;break;case"customFlow":u=s.ENUM_MIX_LAYOUT.customFlow;break;case"single":u=s.ENUM_MIX_LAYOUT.single;break;case"flow":default:u=s.ENUM_MIX_LAYOUT.flow}if(e.layout.standbyTypes&&"[object Array]"===Object.prototype.toString.call(e.layout.standbyTypes)&&e.layout.standbyTypes.forEach((function(e){switch(e){case"flow":h.push(s.ENUM_MIX_LAYOUT.flow);break;case"main":h.push(s.ENUM_MIX_LAYOUT.main);break;case"customMain":h.push(s.ENUM_MIX_LAYOUT.customMain);break;case"customFlow":h.push(s.ENUM_MIX_LAYOUT.customFlow);break;case"single":h.push(s.ENUM_MIX_LAYOUT.single)}})),n!==s.ENUM_MIX_TYPE.update){var v=h.indexOf(u);v>=0&&h.splice(v,1),h.unshift(u),h.length>3&&(h.length=3)}}var g="aac";e.audio&&"object"==typeof e.audio&&(g=e.audio.codec?e.audio.codec:g);var y="h264",b="CB",_=15,S=500;e.video&&"object"==typeof e.video&&(y=e.video.codec?e.video.codec:y,b=e.video.quality?e.video.quality:b,e.video.frameRate&&(E.includes(e.video.frameRate)?_=e.video.frameRate:i.default.warn("video framte rate must be one of "+E)),S=e.video.bitRate?e.video.bitRate:S);var T=s.ENUM_MIX_OUTPUT_MODE.audioVideo;switch(e.outputMode){case"audio":T=s.ENUM_MIX_OUTPUT_MODE.audio;break;case"audio-video":default:T=s.ENUM_MIX_OUTPUT_MODE.audioVideo}var w=1280,R=720;"number"==typeof e.width&&e.width>0&&(w=e.width),"number"==typeof e.height&&e.height>0&&(R=e.height);var M={r:0,g:0,b:0};e.backgroundColor&&"object"==typeof e.backgroundColor&&(M.r=e.backgroundColor.r?e.backgroundColor.r:0,M.g=e.backgroundColor.g?e.backgroundColor.g:0,M.b=e.backgroundColor.b?e.backgroundColor.b:0);var C=s.ENUM_WATER_MARK_POS.lt,P=s.ENUM_WATER_MARK_TYPE.none,O="";if(e.waterMark&&"object"==typeof e.waterMark){switch(e.waterMark.position){case"left-top":C=s.ENUM_WATER_MARK_POS.lt;break;case"left-bottom":C=s.ENUM_WATER_MARK_POS.lb;break;case"right-top":C=s.ENUM_WATER_MARK_POS.rt;break;case"right-bottom":C=s.ENUM_WATER_MARK_POS.rb;break;default:C=s.ENUM_WATER_MARK_POS.lt}switch(e.waterMark.type){case"image":P=s.ENUM_WATER_MARK_TYPE.image,"string"==typeof e.waterMark.remarks&&(O=e.waterMark.remarks);break;case"text":P=s.ENUM_WATER_MARK_TYPE.text,"string"==typeof e.waterMark.remarks&&(O=e.waterMark.remarks);break;case"time":default:P=s.ENUM_WATER_MARK_TYPE.time,O=""}}var I=s.ENUM_MIX_STREAM_ADD_MODE.auto;switch(e.streamAddMode){case"manual":I=s.ENUM_MIX_STREAM_ADD_MODE.manual;break;case"automatic":default:I=s.ENUM_MIX_STREAM_ADD_MODE.auto}var A={bucket:e.bucket,region:e.region,pushurl:o,layout:u,custom:d,audiocodec:g,videocodec:y,qualitylevel:b,framerate:_,bitrate:S,mainviewuid:p,mainviewtype:m,width:w,height:R,bgColor:M,watertype:P,waterpos:C,waterurl:O,mimetype:T,addstreammode:I};a>=60&&(A.expand=A.expand||{},A.expand.taskTimeout=a),e.keyUser&&f.isValidString(e.keyUser)&&(A.keyuser=e.keyUser),n!==s.ENUM_MIX_TYPE.update&&(A.layouts=h);var k=[];if(e.streams&&"[object Array]"===Object.prototype.toString.call(e.streams)&&(this.mixStreams=e.streams,k=e.streams.map((function(e){var t;switch(e.mediaType){case"screen":t=s.ENUM_MEDIA_TYPE.desktop;break;case"camera":default:t=s.ENUM_MEDIA_TYPE.camera}return{user_id:e.uid,media_type:t}}))),!this.sessionManager){var N=l.createError(l.ErrorCodes.NOT_JOIN,"please join room first");return i.default.warn("startMix - "+N),void t(N)}this.mixLayout=A.layout,this.mixStreamMode=A.addstreammode,this.mixKeyUser=A.keyuser,this.sessionManager.startMix(n,k,A,t)},e.prototype.stopMix=function(e,t){if(e=e||{type:"record"},"function"!=typeof t&&(t=function(){}),!this.sessionManager){var r=l.createError(l.ErrorCodes.NOT_JOIN,"please join room first");return i.default.warn("stopMix - "+r),void t(r)}var n;switch(e.type){case"relay":n=s.ENUM_MIX_TYPE.relay;break;case"relay-and-record":n=s.ENUM_MIX_TYPE.relayRecord;break;case"record":default:n=s.ENUM_MIX_TYPE.record}var o=[];n!==s.ENUM_MIX_TYPE.relay&&n!==s.ENUM_MIX_TYPE.relayRecord||"[object Array]"===Object.prototype.toString.call(e.pushURL)&&(o=e.pushURL?e.pushURL:o),this.sessionManager.stopMix(n,o,t)},e.prototype.queryMix=function(e){if("function"!=typeof e&&(e=function(){}),!this.sessionManager){var t=l.createError(l.ErrorCodes.NOT_JOIN,"please join room first");return i.default.warn("queryMix - "+t),void e(t)}this.sessionManager.queryMix(e)},e.prototype.addMixStreams=function(e,t){var r=this;if(e=e||{streams:[]},"function"!=typeof t&&(t=function(){}),"[object Array]"!==Object.prototype.toString.call(e.streams)){var n=l.createError(l.ErrorCodes.INVALID_PARAMETER,"streams must be an array");return i.default.warn("addMixStreams - "+n),void t(n)}if(!this.sessionManager){n=l.createError(l.ErrorCodes.NOT_JOIN,"please join room first");return i.default.warn("addMixStreams - "+n),void t(n)}e.streams.forEach((function(e){e.uid&&e.mediaType&&r.mixStreams&&(r.mixStreams.findIndex((function(t){return t.uid===e.uid&&t.mediaType===e.mediaType}))<0&&r.mixStreams.push(e))}));var o=e.streams.map((function(e){var t;switch(e.mediaType){case"screen":t=s.ENUM_MEDIA_TYPE.desktop;break;case"camera":default:t=s.ENUM_MEDIA_TYPE.camera}return{user_id:e.uid,media_type:t}}));this.sessionManager.addMixStreams(o,t)},e.prototype.removeMixStreams=function(e,t){var r=this;if(e=e||{streams:[]},"function"!=typeof t&&(t=function(){}),"[object Array]"!==Object.prototype.toString.call(e.streams)){var n=l.createError(l.ErrorCodes.INVALID_PARAMETER,"streams must be an array");return i.default.warn("removeMixStreams - "+n),void t(n)}if(!this.sessionManager){n=l.createError(l.ErrorCodes.INVALID_PARAMETER,"please join room first");return i.default.warn("removeMixStreams - "+n),void t(n)}e.streams.forEach((function(e){if(e.uid&&e.mediaType&&r.mixStreams){var t=r.mixStreams.findIndex((function(t){return t.uid===e.uid&&t.mediaType===e.mediaType}));t>=0&&r.mixStreams.splice(t,1)}}));var o=e.streams.map((function(e){var t;switch(e.mediaType){case"screen":t=s.ENUM_MEDIA_TYPE.desktop;break;case"camera":default:t=s.ENUM_MEDIA_TYPE.camera}return{user_id:e.uid,media_type:t}}));this.sessionManager.removeMixStreams(o,t)},e.prototype.startRecord=function(e,t){var r=n.__assign(n.__assign({},e),{type:"record"});this.startMix(r,(function(e,r){if("function"==typeof t)if(r){var n={Id:r.MixId,FileName:r.FileName};t(e,n)}else t(e)}))},e.prototype.stopRecord=function(e){this.stopMix({type:"record"},(function(t,r){if("function"==typeof e)if(r){var n={Id:r.MixId,FileName:r.FileName};e(t,n)}else e(t)}))},e.prototype.updateRecordStreams=function(e,t){function r(e,r){if("function"==typeof t)if(r){var n={Id:r.MixId,FileName:r.FileName};t(e,n)}else t(e)}if(e=e||{},!b.includes(e.type)){var n=l.createError(l.ErrorCodes.INVALID_PARAMETER,"type must be one of "+b);return i.default.warn("updateRecordStreams - "+n),void r(n)}if("[object Array]"!==Object.prototype.toString.call(e.streams)){n=l.createError(l.ErrorCodes.INVALID_PARAMETER,"streams must be an array");return i.default.warn("updateRecordStreams - "+n),void r(n)}if(!this.sessionManager){n=l.createError(l.ErrorCodes.NOT_JOIN,"please join room first");return i.default.warn("updateRecordStreams - "+n),void r(n)}switch(e.type){case"remove":this.removeMixStreams({streams:e.streams},r);break;case"add":this.addMixStreams({streams:e.streams},r);break;case"replace":var o=[];e.streams&&"[object Array]"===Object.prototype.toString.call(e.streams)&&(this.mixStreams=e.streams,o=e.streams.map((function(e){var t;switch(e.mediaType){case"screen":t=s.ENUM_MEDIA_TYPE.desktop;break;case"camera":default:t=s.ENUM_MEDIA_TYPE.camera}return{user_id:e.uid,media_type:t}})));var a={layout:-1,addstreammode:-1,watertype:-1};o[0]&&(a.mainviewuid=o[0].user_id,a.mainviewtype=o[0].media_type),this.mixLayout&&(a.layout=this.mixLayout),this.mixStreamMode&&(a.addstreammode=this.mixStreamMode),this.mixKeyUser&&(a.keyuser=this.mixKeyUser),this.sessionManager.updateMix(o,a,r)}},e.prototype.startRelay=function(e,t){var r=n.__assign(n.__assign({},e),{type:"relay"});this.startMix(r,(function(r,n){if("function"==typeof t)if(n){var i={Id:n.MixId,PushURL:n.PushURL?n.PushURL:e.pushURL};t(r,i)}else t(r)}))},e.prototype.stopRelay=function(e){this.stopMix({type:"relay"},(function(t,r){if("function"==typeof e)if(r){var n={Id:r.MixId,PushURL:r.PushURL};e(t,n)}else e(t)}))},e.prototype.updateRelayStreams=function(e,t){function r(e,r){if("function"==typeof t)if(r){var n={Id:r.MixId,PushURL:r.PushURL};t(e,n)}else t(e)}if(e=e||{},!b.includes(e.type)){var n=l.createError(l.ErrorCodes.INVALID_PARAMETER,"type must be one of "+b);return i.default.warn("updateRelayStreams - "+n),void r(n)}if("[object Array]"!==Object.prototype.toString.call(e.streams)){n=l.createError(l.ErrorCodes.INVALID_PARAMETER,"streams must be an array");return i.default.warn("updateRelayStreams - "+n),void r(n)}if(!this.sessionManager){n=l.createError(l.ErrorCodes.NOT_JOIN,"please join room first");return i.default.warn("updateRelayStreams - "+n),void r(n)}switch(e.type){case"remove":this.removeMixStreams(e,r);break;case"add":this.addMixStreams(e,r);break;case"replace":var o=[];e.streams&&"[object Array]"===Object.prototype.toString.call(e.streams)&&(this.mixStreams=e.streams,o=e.streams.map((function(e){var t;switch(e.mediaType){case"screen":t=s.ENUM_MEDIA_TYPE.desktop;break;case"camera":default:t=s.ENUM_MEDIA_TYPE.camera}return{user_id:e.uid,media_type:t}})));var a={layout:-1,addstreammode:-1,watertype:-1};o[0]&&(a.mainviewuid=o[0].user_id,a.mainviewtype=o[0].media_type),this.mixLayout&&(a.layout=this.mixLayout),this.mixStreamMode&&(a.addstreammode=this.mixStreamMode),this.mixKeyUser&&(a.keyuser=this.mixKeyUser),this.sessionManager.updateMix(o,a,r)}},e.prototype.updateRelayPushURL=function(e,t){function r(e,r){if("function"==typeof t)if(r){var n={Id:r.MixId,PushURL:r.PushURL};t(e,n)}else t(e)}if(e=e||{},!_.includes(e.type)){var n=l.createError(l.ErrorCodes.INVALID_PARAMETER,"type must be one of "+_);return i.default.warn("updateRelayPushURL - "+n),void r(n)}if("[object Array]"!==Object.prototype.toString.call(e.pushURL)){n=l.createError(l.ErrorCodes.INVALID_PARAMETER,"pushURL must be an array");return i.default.warn("updateRelayPushURL - "+n),void r(n)}if(!this.sessionManager){n=l.createError(l.ErrorCodes.NOT_JOIN,"please join room first");return i.default.warn("updateRelayStreams - "+n),void r(n)}switch(e.type){case"remove":var o={type:"relay",pushURL:e.pushURL};this.stopMix(o,r);break;case"add":if(!(e.pushURL.length>0))return void r(n=l.createError(l.ErrorCodes.INVALID_PARAMETER,"pushURL must be an non-empty array"));var a={layout:-1,addstreammode:-1,watertype:-1,pushurl:e.pushURL};this.mixLayout&&(a.layout=this.mixLayout);var c=[];this.mixStreamMode&&(a.addstreammode=this.mixStreamMode,this.mixStreamMode===s.ENUM_MIX_STREAM_ADD_MODE.manual&&this.mixStreams&&(c=this.mixStreams.map((function(e){var t;switch(e.mediaType){case"screen":t=s.ENUM_MEDIA_TYPE.desktop;break;case"camera":default:t=s.ENUM_MEDIA_TYPE.camera}return{user_id:e.uid,media_type:t}})))),this.mixKeyUser&&(a.keyuser=this.mixKeyUser),this.sessionManager.updateMix(c,a,r)}},e.prototype.updateRelayLayout=function(e,t){function r(e,r){if("function"==typeof t)if(r){var n={Id:r.MixId,PushURL:r.PushURL};t(e,n)}else t(e)}if((e=e||{}).layout&&"object"!=typeof e.layout){var n=l.createError(l.ErrorCodes.INVALID_PARAMETER,"layout is invalid");return i.default.warn("updateRelayLayout - "+n),void r(n)}if(!this.sessionManager){n=l.createError(l.ErrorCodes.NOT_JOIN,"please join room first");return i.default.warn("updateRelayLayout - "+n),void r(n)}var o={layout:-1,addstreammode:-1,watertype:-1};if(e.layout.mainViewUId)o.mainviewuid=e.layout.mainViewUId;else{var a=this.getUser();a&&(o.mainviewuid=a.uid)}switch(e.layout.mainViewType){case"screen":case"desktop":o.mainviewtype=s.ENUM_MEDIA_TYPE.desktop;break;case"camera":default:o.mainviewtype=s.ENUM_MEDIA_TYPE.camera}switch(e.layout.type){case"main":o.layout=s.ENUM_MIX_LAYOUT.main;break;case"custom":o.layout=s.ENUM_MIX_LAYOUT.custom,e.layout.custom&&(o.custom=e.layout.custom);break;case"customMain":o.layout=s.ENUM_MIX_LAYOUT.customMain;break;case"customFlow":o.layout=s.ENUM_MIX_LAYOUT.customFlow;break;case"single":o.layout=s.ENUM_MIX_LAYOUT.single;break;case"flow":o.layout=s.ENUM_MIX_LAYOUT.flow;break;default:this.mixLayout&&(o.layout=this.mixLayout)}o.layout&&(this.mixLayout=o.layout);var c=[];this.mixStreamMode&&(o.addstreammode=this.mixStreamMode,this.mixStreamMode===s.ENUM_MIX_STREAM_ADD_MODE.manual&&this.mixStreams&&(c=this.mixStreams.map((function(e){var t;switch(e.mediaType){case"screen":t=s.ENUM_MEDIA_TYPE.desktop;break;case"camera":default:t=s.ENUM_MEDIA_TYPE.camera}return{user_id:e.uid,media_type:t}})))),this.mixKeyUser&&(o.keyuser=this.mixKeyUser),this.sessionManager.updateMix(c,o,r)},e.prototype.createStream=function(e,t){if("function"!=typeof t&&(t=function(){}),"object"!=typeof e){var r="the options is invalid";return i.default.warn(r),void t(l.createError(l.ErrorCodes.INVALID_PARAMETER,r))}var n;e.previewId&&f.isValidString(e.previewId)&&(n=e.previewId),e.streamId&&f.isValidString(e.streamId)&&(n=e.streamId);var o={audio:!1,video:!1,screen:!1,mediaStream:e.mediaStream};if("boolean"==typeof e.audio&&(o.audio=e.audio),"boolean"==typeof e.video&&(o.video=e.video),"boolean"==typeof e.screen&&(o.screen=e.screen),"boolean"==typeof e.screenAudio&&(o.screenAudio=e.screenAudio),o.screen&&o.video&&i.default.warn("both video and screen are true, only camera's video will be used"),o.screen&&o.audio&&i.default.warn("both audio and screen are true, only microphone's audio will be used"),o.audio&&o.video&&o.screen){r="audio, video and screen cannot be true at the same time";return i.default.warn(r),void t(l.createError(l.ErrorCodes.INVALID_PARAMETER,r))}if(!(o.audio||o.video||o.screen||o.mediaStream)){r="audio, video and screen cannot be false at the same time";return i.default.warn(r),void t(l.createError(l.ErrorCodes.INVALID_PARAMETER,r))}if(["microphoneId","cameraId","extensionId","file","filePath"].forEach((function(t){o[t]=e[t]})),e.facingMode&&y.includes(e.facingMode)&&(o.facingMode=e.facingMode),!f.isValidString(o.microphoneId)){r="type error, the microphoneId is not blank or a valid string";return i.default.warn(r),void t(l.createError(l.ErrorCodes.INVALID_PARAMETER,r))}if(!f.isValidString(o.cameraId)){r="type error, the cameraId is not blank or a valid string";return i.default.warn(r),void t(l.createError(l.ErrorCodes.INVALID_PARAMETER,r))}if(o.mediaStream&&!(o.mediaStream instanceof MediaStream)){r="type error, the mediaStream is not a valid MediaStream";return i.default.warn(r),void t(l.createError(l.ErrorCodes.INVALID_PARAMETER,r))}var a=this.getUser(),s=a?a.uid:e.userId?""+e.userId:"unknown";this.previewStreamManager.createStream(s,n,o,this.profileName).then((function(e){try{t(void 0,e.convertToOuterStream())}catch(e){i.default.warn("invoke callback error ",e)}})).catch(t)},e.prototype.publishStream=function(e,t){var r=this;if(!f.streamValidator.isValidStreamId(e)){var n="type error, the streamId isnot a valid string";return i.default.warn(n),void(t&&t(l.createError(l.ErrorCodes.INVALID_PARAMETER,n)))}if(!this.sessionManager){n="please join room first";return i.default.warn(n),void(t&&t(l.createError(l.ErrorCodes.NOT_JOIN,n)))}var o=this.previewStreamManager.getStream(e);if(!o){n="stream isnot found, maybe it has already been published or destroyed";return i.default.warn(n),void(t&&t(l.createError(l.ErrorCodes.STREAM_NOT_EXISTS,n)))}this.sessionManager.publishStream(o,(function(n){r.previewStreamManager.removeStream(e,!0).then((function(){t&&t(void 0,n.convertToOuterStream())})).catch((function(e){i.default.warn("publish stream failure when remove it "+e),t&&t(e)}))}),(function(e){t&&t(e)}))},e.prototype.unpublishStream=function(e,t){var r=this;if(!f.streamValidator.isValidStreamId(e)){var n="type error, the streamId isnot a valid string";return i.default.warn(n),void(t&&t(l.createError(l.ErrorCodes.INVALID_PARAMETER,n)))}if(!this.sessionManager){n="please join room first";return i.default.warn(n),void(t&&t(l.createError(l.ErrorCodes.NOT_JOIN,n)))}var o=this.sessionManager.streamManager.getLocalStream(e);if(!o){n="stream is not found";return i.default.warn(n),void(t&&t(l.createError(l.ErrorCodes.STREAM_NOT_EXISTS,n)))}this.sessionManager.unpublishStream(o,(function(e){r.previewStreamManager.copyStream(e).then((function(n){var i;null===(i=r.sessionManager)||void 0===i||i.streamManager.removeLocalStream(e,!0),t&&t(void 0,n.convertToOuterStream())}))}),(function(e){t&&t(e)}))},e.prototype.removeStream=function(e,t){this.destroyStream(e,t)},e.prototype.destroyStream=function(e,t){if("function"!=typeof t&&(t=function(){}),!f.streamValidator.isValidStreamId(e)){var r="type error, the streamId isnot a valid string";return i.default.warn(r),void t(l.createError(l.ErrorCodes.INVALID_PARAMETER,r))}this.previewStreamManager.removeStream(e,!1).then((function(){t()})).catch((function(e){t(e)}))},e.prototype.enableAudioVolumeIndicator=function(e){f.isNil(e)?(this.audioVolumeIndicatorInterval=2e3,this.sessionManager&&this.sessionManager.enableAudioVolumeIndicator()):f.isValidNumber(e,!0)&&e>=200&&(this.audioVolumeIndicatorInterval=e,this.sessionManager&&this.sessionManager.enableAudioVolumeIndicator(e))},e.prototype.logoff=function(e,t,r){var n;switch(e){case"reconnect":n=s.ENUM_LOGOFF_TYPE.reconnect;break;case"switch":n=s.ENUM_LOGOFF_TYPE.switch;break;case"refresh":n=s.ENUM_LOGOFF_TYPE.refresh;break;case"quit":default:n=s.ENUM_LOGOFF_TYPE.quit}if(!this.sessionManager){var o="please join room first";return i.default.warn(o),void(r&&r(l.createError(l.ErrorCodes.NOT_JOIN,o)))}this.sessionManager.logoff(n,t).then((function(){r&&r()})).catch((function(e){r&&r(e)}))},e}();t.default=S},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(6),i=function(){function e(){this.emitter=new n.EventEmitter}return e.prototype.bind=function(e){e.emitter=this.emitter},e.prototype.on=function(e,t){this.emitter.on(e,t)},e.prototype.off=function(e,t){this.emitter.off(e,t)},e}();t.EventManager=i},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(2),i=r(6),o=r(20),a=r(70),s=r(13),c=r(15),u=r(35),d=r(18),f=r(40),p=r(0),l=r(36),m=r(4),h=r(5),v=r(41),g=r(10),y=r(82),E=r(3),b=r(31),_=r(83),S=r(11),T=function(){function e(){}return Object.defineProperty(e.prototype,"devinfo",{get:function(){return f.encode(this._devinfo)},enumerable:!0,configurable:!0}),e}(),w=function(){function e(e,t,r,n,o,a){var c=this;this.session=new T,this.signalManager=new b.SignalManager,this.reconnectTimes=0,this.joinRoomType=h.ENUM_JOIN_ROOM_TYPE.default,this.rpcMap={},this.joinStatus=h.ENUM_ROOM_STATUS.unjoin,this.recordId="",this.recordStreamType=h.ENUM_STREAM_TYPE.publish,this.recordMediaType=h.ENUM_MEDIA_TYPE.camera,this.recordStatus=h.ENUM_RECORD_STATUS.unrecord,this.users=[],this.isDestroyed=!1,this.ping4SyncInterval=0;var f=m.getDeviceInfo(),p=m.getSystemInfo(),v=m.getCPUInfo();this.sessionId="",this.session.app_id=e,this.session.room_token=t,this.session.room_type=r,this.session.role_type=n;var g={sdkv:d.version,agent:l.getAgent(),device:f.vendor+"_"+f.brand+"_"+f.model,system:""+p.name+p.version+"_"+p.versionName,network:""+m.getNetworkInfo().network,cpu:v.brand+"_"+v.model+"_"+v.core,mem:m.getMemInfo().capacity+"GB"};this.session._devinfo=g,this.innerEmitter=new i.EventEmitter,this.innerEmitter.on("mediaStreamPublished",this.onMediaStreamPublished.bind(this)),this.innerEmitter.on("mediaStreamSubscribed",this.onMediaStreamSubscribed.bind(this)),this.innerEmitter.on("screenMediaStreamEnded",this.onScreenMediaStreamEnded.bind(this)),this.innerEmitter.on("streamConnectionClosed",this.onStreamConnectionClosed.bind(this)),this.innerEmitter.on("streamConnectionReconnecting",this.onStreamConnectionReconnecting.bind(this)),this.innerEmitter.on("streamConnectionReconnected",this.onStreamConnectionReconnected.bind(this)),this.innerEmitter.on("streamConnectionDisconnected",this.onStreamConnectionDisconnected.bind(this)),this.innerEmitter.on("stream-playing",(function(e){var t;null===(t=c._emitter)||void 0===t||t.emit("stream-playing",e.convertToOuterStream())})),this.innerEmitter.on("stream-paused",(function(e){var t;null===(t=c._emitter)||void 0===t||t.emit("stream-paused",e.convertToOuterStream())})),this.innerEmitter.on("player-status-change",(function(e){var t;null===(t=c._emitter)||void 0===t||t.emit("player-status-change",e)})),this.streamManager=new s.StreamManager(o,a),this.logReporter=new u.LogReporter,this.streamManager.emitter=this.innerEmitter,this.streamManager.logReporter=this.logReporter,this.networkQualityEvaluator=new y.NetworkQualityEvaluator(this.streamManager),this.networkQualityEvaluator.on("network-quality",(function(e,t){var r;null===(r=c._emitter)||void 0===r||r.emit("network-quality",{uplink:y.NetworkQualityEvaluator.convert2Quality(e),downlink:y.NetworkQualityEvaluator.convert2Quality(t)})})),this.networkQualityEvaluator.on("network-evaluation",(function(e){var t=e[0],r=e[1];t||r?c.signalManager.punish():c.signalManager.award()}))}return Object.defineProperty(e.prototype,"emitter",{set:function(e){this._emitter=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isJoinedRoom",{get:function(){return this.joinStatus===h.ENUM_ROOM_STATUS.joined},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isRecording",{get:function(){return this.recordStatus===h.ENUM_RECORD_STATUS.recording},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"user",{get:function(){return{user_id:this.session.user_id}},enumerable:!0,configurable:!0}),e.prototype.openSignalSwitch=function(){var e=this.signalSwitchConfig.push_threshold,t=e.rtt,r=e.lost,n=e.bandwidth,i=this.signalSwitchConfig.pull_threshold,o=i.rtt,a=i.lost,s=i.bandwidth;p.default.debug("\n 开启弱网自动切换功能,上行阈值 rtt:"+t+" loss:"+r+" bandwidth:"+n+",下行阈值 rtt:"+o+" loss:"+a+" bandwidth:"+s),this.networkQualityEvaluator.startEvaluate({upLossRate:r,downLossRate:a})},e.prototype.connect=function(e){var t=this;this.socketManager=new a.SocketManager(e),this.socketManager.init((function(e){var r;try{r=JSON.parse(e.data)}catch(e){return void p.default.error("socket onmessage ",e)}if(r){var n=t.rpcMap[r.rpc_id]||{},i=n.req,o=n.resource,a=t.rpcMap[r.rpc_id]||{},s=a.onSuccess,c=a.onFailure;if(delete t.rpcMap[r.rpc_id],p.default.debug("socket request: ",i),p.default.debug("socket response: ",r),i){if("function"!=typeof s&&(s=function(){}),0!==r.err){if("queymix"===i.method&&"can't find job"===r.msg)return void t.onQueryMix(void 0,s);if("startmix"===i.method&&i.data&&i.data.type!==h.ENUM_MIX_TYPE.update&&(1072===r.err||1073===r.err)){var u=new Promise((function(e,r){t.queryMix((function(t,n){t?(p.default.warn("start & query mix ",t),r(t)):(p.default.debug("start & query mix ",n),e(n))}))})),d=new Promise((function(e,r){var n=i.data.config,o=i.data.streams||[],a={layout:n.layout,watertype:n.watertype,addstreammode:n.addstreammode};n.pushurl&&n.pushurl.length>0&&(a.pushurl=n.pushurl),n.custom&&n.custom.length>0&&(a.custom=n.custom),n.layouts&&n.layouts.length>0&&(a.layouts=n.layouts),n.mainviewuid&&(a.mainviewuid=n.mainviewuid),n.mainviewtype&&n.mainviewtype>=0&&(a.mainviewtype=n.mainviewtype),n.waterpos&&n.waterpos>=0&&(a.waterpos=n.waterpos),n.waterurl&&(a.waterurl=n.waterurl),t.updateMix(o,a,(function(t,n){t?(p.default.warn("start & update mix ",t),r(t)):(p.default.debug("start & update mix ",n),e(n))}))}));return void Promise.all([u,d]).then((function(e){s&&s(e[0])})).catch((function(e){c&&c(e)}))}return"stopmix"===i.method&&1040===r.err?(p.default.debug("onStopMix 1040"),void(s&&s({}))):void("function"==typeof c?c(E.createError(""+r.err,r.msg)):t.onError({method:i.method,code:""+r.err,msg:r.msg}))}switch("function"!=typeof c&&(c=function(){}),i.method){case"joinroom":switch(t.joinStatus){case h.ENUM_ROOM_STATUS.joining:t.onJoinRoom(r.data,s);break;case h.ENUM_ROOM_STATUS.rejoining:t.onRejoinRoom(r.data,s);break;default:p.default.warn("ignore, room status is "+h.ENUM_ROOM_STATUS[t.joinStatus])}break;case"leaveroom":t.onLeaveRoom(r.data,s);break;case"subscribe":t.onSubscribe({streamsub_id:r.data.streamsub_id,stream_id:r.data.stream_id,media_type:r.data.media_type,user_id:i.data.dst.user_id},s,c,o);break;case"unsubscribe":t.onUnsubscribe(r.data,s,c,o);break;case"publish":t.onPublish(r.data,s,c,o);break;case"unpublish":t.onUnpublish(r.data,s,c,o);break;case"sdp":r.data.stream_type===h.ENUM_STREAM_TYPE.publish&&t.onSdpPublish(r.data,s,c,o),r.data.stream_type===h.ENUM_STREAM_TYPE.subscribe&&t.onSdpSubscribe(r.data,s,c,o);break;case"mute":s();break;case"startrecord":t.onStartRecord(r.data,s);break;case"stoprecord":t.onStopRecord(r.data,s);break;case"startmix":t.onStartMix(r.data,s);break;case"stopmix":t.onStopMix(r.data,s);break;case"queymix":t.onQueryMix(r.data,s);break;case"addmixstream":t.onAddMixStreams(r.data,s);break;case"delmixstream":t.onRemoveMixStreams(r.data,s);break;case"logoff":t.onLogoff(r.data,s);break;case"updatevp":t.onUpdateVP(r.data,s);break;case"ping":t.onPing4Sync(r.data,s);break;case"syncroom":t.onSyncRoom(r.data,s)}}else switch(r.method){case"userst":r.data.cmdtype===h.ENUM_USER_CMD_TYPE.userJoin&&t.onUserJoin(r.data),r.data.cmdtype===h.ENUM_USER_CMD_TYPE.userLeave&&t.onUserLeave(r.data);break;case"streamst":r.data.cmdtype===h.ENUM_STREAM_CMD_TYPE.add&&t.onAddStream(r.data),r.data.cmdtype===h.ENUM_STREAM_CMD_TYPE.remove&&t.onRemoveStream(r.data);break;case"transportclose":t.onTransportClose(r.data);break;case"transporttimeout":t.onTransportTimeout(r.data);break;case"trackst":switch(r.data.track_type){case h.ENUM_TRACK_TYPE.audio:t.onAudioTrackst(r.data);break;case h.ENUM_TRACK_TYPE.video:t.onVideoTrackst(r.data);break;case h.ENUM_TRACK_TYPE.data:t.onDataTrackst(r.data);break;default:p.default.warn("trackst unknown track type ",r.data.track_type)}break;case"kickoff":t.onKickoff(r.data);break;case"mixnotify":t.onMixNotify(r.err,r.msg,r.data);break;case"logoffnotify":t.onLogoffNotify(r.data)}}else p.default.warn("socket receives message ",r)}),(function(e,r){var n,i,o,a,s,c,u;p.default.debug("connection-state-change ",e,r),"CLOSED"===e&&"CONNECTING"===r&&(t.joinStatus===h.ENUM_ROOM_STATUS.joining?null===(n=t._emitter)||void 0===n||n.emit("connection-state-change",{previous:e,current:r}):t.joinStatus===h.ENUM_ROOM_STATUS.joined||t.joinStatus===h.ENUM_ROOM_STATUS.rejoining?(t.clearCachedRPC(),0===t.reconnectTimes&&(null===(i=t._emitter)||void 0===i||i.emit("connection-state-change",{previous:"OPEN",current:"RECONNECTING"})),t.reconnectTimes+=1):p.default.warn("connection exception ",e,r)),"OPEN"===e&&"CLOSED"===r&&p.default.warn("connection is closed and will reconnect automatically"),"CONNECTING"!==e&&"CLOSED"!==e||"CLOSED"!==r||t.reconnectTimes>=60&&(p.default.error("connection is closed and reconnect failed"),t.reconnectTimes=0,null===(o=t.socketManager)||void 0===o||o.destroy(),t.socketManager=void 0,t.destroy(),null===(a=t._emitter)||void 0===a||a.emit("connection-state-change",{previous:"RECONNECTING",current:r})),"CONNECTING"!==e&&"OPEN"!==e||"OPEN"!==r||(0===t.reconnectTimes&&t.joinRoomType!==h.ENUM_JOIN_ROOM_TYPE.reconnect?null===(s=t._emitter)||void 0===s||s.emit("connection-state-change",{previous:e,current:r}):t.joinStatus===h.ENUM_ROOM_STATUS.joined&&t.rejoinRoom().then((function(){var e;p.default.info("rejoin room successfully"),t.reconnectTimes=0,null===(e=t._emitter)||void 0===e||e.emit("connection-state-change",{previous:"RECONNECTING",current:"OPEN"})})).catch((function(e){p.default.error("rejoin room unsuccessfully with error: ",e),0===t.reconnectTimes&&(t.reconnectTimes+=1)}))),"OPEN"===e&&"CLOSING"===r&&(null===(c=t._emitter)||void 0===c||c.emit("connection-state-change",{previous:e,current:r})),"CLOSING"===e&&"CLOSED"===r&&(null===(u=t._emitter)||void 0===u||u.emit("connection-state-change",{previous:e,current:r}))}),(function(e){var r;p.default.debug("connection-error ",e),null===(r=t._emitter)||void 0===r||r.emit("connection-error",e)}));return this.socketManager.initHeartBeat((function(){var e={method:"ping",version:.1,rpc_id:l.getId(),data:{}};return JSON.stringify(e)}),3e4),this.socketManager.connect()},e.prototype.clearCachedRPC=function(){for(var e in this.rpcMap){var t=(this.rpcMap[e]||{}).onFailure;t&&t(E.createError(E.ErrorCodes.BAD_REQUEST,"request failed")),delete this.rpcMap[e]}},e.prototype.disconnect=function(e){var t=this;this.reconnectTimes=0,this.socketManager&&this.socketManager.close(1e3,e||"disconnect").catch((function(e){p.default.error("connect close - ",e)})).finally((function(){t.socketManager&&t.socketManager.destroy(),t.socketManager=void 0}))},e.prototype.send=function(e,t,r,n,i){var o=this,a=l.getId(),s=.1;"ping"===e&&(s=1.1);var c={method:e,version:s,rpc_id:a,data:t};this.rpcMap[a]={req:c,onSuccess:r,onFailure:n,resource:i};var u=JSON.stringify(c);if(this.socketManager)this.socketManager.send(u).catch((function(e){n&&n(e),delete o.rpcMap[a]}));else{n&&n(E.createError(E.ErrorCodes.OTHERS,"connection isnot open")),delete this.rpcMap[a]}},e.prototype.destroy=function(){var e,t=this;this.isDestroyed=!0,setTimeout((function(){t._emitter=void 0}),0),this.rpcMap={},this.users=[],this.networkQualityEvaluator.destory(),this.logReporter.destroy(),null===(e=this.audioVolumeIndicator)||void 0===e||e.destroy(),this.recordId="",this.recordStatus=h.ENUM_RECORD_STATUS.unrecord,this.streamManager.removeAllLocalStreams(),this.streamManager.removeAllRemoteStreams()},e.prototype.getGW=function(){return o.get({data:{Action:"rsugetrtcgateway",rpc_id:l.getId(),user_id:this.session.user_id,room_id:this.session.room_id,app_id:this.session.app_id,token:this.session.room_token,devinfo:this.session.devinfo}}).then((function(e){return e.data}))},e.prototype.getLiveGW=function(){return o.get({data:{Action:"rsugetlivegateway",rpc_id:l.getId(),user_id:this.session.user_id,room_id:this.session.room_id,app_id:this.session.app_id,token:this.session.room_token,role:this.session.role_type,devinfo:this.session.devinfo}}).then((function(e){return e.data}))},e.prototype.setRole=function(e){this.session.role_type=e},e.prototype.joinRoom=function(e,t,r,n){var i=this,o="";switch(this.joinStatus){case h.ENUM_ROOM_STATUS.rejoining:case h.ENUM_ROOM_STATUS.joining:return o="you are joining the room",p.default.debug("joinRoom - ",o),void n(o);case h.ENUM_ROOM_STATUS.leaving:return o="you are leaving the room",p.default.debug("joinRoom - ",o),void n(o);case h.ENUM_ROOM_STATUS.joined:return o="you have already joined the room",p.default.debug("joinRoom - ",o),void n(o);case h.ENUM_ROOM_STATUS.unjoin:}this.joinStatus=h.ENUM_ROOM_STATUS.joining,this.session.room_id=e,this.session.user_id=t,this.logReporter.init(this.session.app_id,e,t);var a=function(){var e;p.default.debug("joinRoom success"),i.joinStatus=h.ENUM_ROOM_STATUS.joined,(null===(e=i.signalSwitchConfig)||void 0===e?void 0:e.switch_on)&&i.openSignalSwitch(),r(v.convertToOuterUser(i.user))},s=function(e){i.destroy(),i.session.user_id="",i.session.room_id="",i.joinStatus=h.ENUM_ROOM_STATUS.unjoin,i.logReporter.reportExceptionLog(u.ENUM_LOG_EXCEPTION_TYPE.joinRoom,{msg:""+e}),n(e)},c=function(e,t,r){i.connect(e).then((function(){var e={app_id:i.session.app_id,room_id:i.session.room_id,user_id:i.session.user_id,authtoken:i.session.room_token,devinfo:i.session.devinfo,role_type:i.session.role_type,room_type:i.session.room_type,sessionid:i.sessionId,cmdtype:i.joinRoomType};i.send("joinroom",e,(function(e){i.joinRoomType=h.ENUM_JOIN_ROOM_TYPE.reconnect,t(e)}),r)})).catch(r)};if(g.SERVER_CONFIG.signal){if(!/^wss:\/\/[\w\-\.]+:\d+$/i.test(g.SERVER_CONFIG.signal))return void s(E.createError(E.ErrorCodes.INVALID_PARAMETER,"invalid signal address "+g.SERVER_CONFIG.signal));var d=g.SERVER_CONFIG.signal.match(/[\w\-\.]+/gi);if(!(d&&d.length>=3))return void s(E.createError(E.ErrorCodes.INVALID_PARAMETER,"invalid signal address "+g.SERVER_CONFIG.signal));this.signalManager.add(new b.Signal(d[1],d[2],1)),c(this.signalManager,a,s)}else this.session.room_type===h.ENUM_ROOM_TYPE.live?this.getLiveGW().then((function(e){var t,r=e.access_token,n=e.auto_switch;p.default.debug("getLiveGW token ",r),n&&(i.signalSwitchConfig=n);try{t=f.decode(r),p.default.debug("getLiveGW token ",t)}catch(e){throw E.createError(E.ErrorCodes.SERVER_API,"get invalid access token "+r)}if(!(t.length>=0))throw E.createError(E.ErrorCodes.SERVER_API,"get blank access token "+r);t.forEach((function(e){i.signalManager.add(new b.Signal(e.singal,e.port,e.ssl))})),c(i.signalManager,a,s)})).catch(s):this.getGW().then((function(e){var t,r=e.access_token,n=e.auto_switch;p.default.debug("getGW token ",r),n&&(i.signalSwitchConfig=n);try{t=f.decode(r)}catch(e){throw E.createError(E.ErrorCodes.SERVER_API,"get invalid access token "+r)}if(!(t.length>=0))throw E.createError(E.ErrorCodes.SERVER_API,"get blank access token "+r);t.forEach((function(e){i.signalManager.add(new b.Signal(e.singal,e.port,e.ssl))})),c(i.signalManager,a,s)})).catch(s);this.ping4SyncInterval=window.setInterval((function(){var e;(null===(e=i.socketManager)||void 0===e?void 0:e.isOpened)&&i.ping4Sync().catch((function(e){return p.default.debug("ping ",e)}))}),5e3)},e.prototype.onJoinRoom=function(e,t){var r=this,n=e.users,i=void 0===n?[]:n,o=e.streams,a=void 0===o?[]:o;p.default.debug("onJoinRoom ",i,a),i=i||[],a=a||[],this.users=i.filter((function(e){return e.user_id!==r.user.user_id})),a.forEach((function(e){e.uid!==r.user.user_id&&r.streamManager.createRemoteStream(e)})),a.forEach((function(e){e.uid!==r.user.user_id&&(r.users.findIndex((function(t){return t.user_id===e.uid}))<0&&r.users.push({user_id:e.uid}))})),this.logReporter.reportJoinRoomLog(),t(),setTimeout((function(){r.users.forEach((function(e){r._emitter&&r._emitter.emit("user-added",v.convertToOuterUser(e))})),r.streamManager.getAllRemoteStreams().forEach((function(e){r._emitter&&r._emitter.emit("stream-added",e.convertToOuterStream())}))}),0)},e.prototype.refreshSignal=function(){var e=this;return new Promise((function(t,r){g.SERVER_CONFIG.signal?t([[],void 0]):e.session.room_type===h.ENUM_ROOM_TYPE.live?e.getLiveGW().then((function(e){var n,i=e.access_token,o=e.auto_switch;p.default.debug("refresh signal - getLiveGW token ",i);try{n=f.decode(i),p.default.debug("getLiveGW token ",n)}catch(e){return void r(E.createError(E.ErrorCodes.SERVER_API,"get invalid access token "+i))}if(n.length<=0)r(E.createError(E.ErrorCodes.SERVER_API,"get blank access token "+i));else{var a=n.map((function(e){return new b.Signal(e.singal,e.port,e.ssl)}));t([a,o])}})).catch(r):e.getGW().then((function(e){var n,i=e.access_token,o=e.auto_switch;p.default.debug("getGW token ",i);try{n=f.decode(i)}catch(e){return void r(E.createError(E.ErrorCodes.SERVER_API,"get invalid access token "+i))}if(n.length<=0)r(E.createError(E.ErrorCodes.SERVER_API,"get blank access token "+i));else{var a=n.map((function(e){return new b.Signal(e.singal,e.port,e.ssl)}));t([a,o])}})).catch(r)}))},e.prototype.rejoinRoom=function(){var e=this;if(!this.socketManager||!this.socketManager.isOpened)return Promise.reject(E.createError(E.ErrorCodes.SOCKET_DISCONNECTED,"connection isnot open"));var t="";switch(this.joinStatus){case h.ENUM_ROOM_STATUS.rejoining:case h.ENUM_ROOM_STATUS.joining:return t="you are joining the room",p.default.debug("rejoinRoom - ",t),Promise.reject(t);case h.ENUM_ROOM_STATUS.leaving:return t="you are leaving the room",p.default.debug("rejoinRoom - ",t),Promise.reject(t);case h.ENUM_ROOM_STATUS.unjoin:return t="you have not joined the room",p.default.debug("rejoinRoom - ",t),Promise.reject(t);case h.ENUM_ROOM_STATUS.joined:}return this.joinStatus=h.ENUM_ROOM_STATUS.rejoining,new Promise((function(t,r){var n={app_id:e.session.app_id,room_id:e.session.room_id,user_id:e.session.user_id,authtoken:e.session.room_token,devinfo:e.session.devinfo,role_type:e.session.role_type,room_type:e.session.room_type,sessionid:e.sessionId,cmdtype:e.joinRoomType};setTimeout((function(){e.send("joinroom",n,(function(){var r;p.default.debug("rejoinRoom success"),e.joinStatus=h.ENUM_ROOM_STATUS.joined,e.joinRoomType=h.ENUM_JOIN_ROOM_TYPE.reconnect,(null===(r=e.signalSwitchConfig)||void 0===r?void 0:r.switch_on)&&e.openSignalSwitch(),t()}),(function(t){e.joinStatus=h.ENUM_ROOM_STATUS.joined,r(t)}))}),0)}))},e.prototype.onRejoinRoom=function(e,t){var r=this,n=e.users,i=void 0===n?[]:n,o=e.streams,a=void 0===o?[]:o;p.default.debug("onRejoinRoom ",i,a),t(),a=a||[];var s=[],c=[],u=[];(i=i||[]).forEach((function(e){e.user_id!==r.user.user_id&&(r.users.findIndex((function(t){return t.user_id===e.user_id}))>=0?s.push(e):c.push(e))})),this.users.forEach((function(e){s.findIndex((function(t){return t.user_id===e.user_id}))<0&&u.push(e)}));var d=this.streamManager.getAllRemoteStreams(),f=[],l=[],m=[];a.forEach((function(e){e.uid!==r.user.user_id&&(d.findIndex((function(t){return t.streamId===e.sid}))>=0?f.push(e):l.push(e))})),d.forEach((function(e){f.findIndex((function(t){return t.sid===e.streamId}))<0&&m.push(e)})),f.forEach((function(e){var t,n=r.streamManager.getRemoteStream(e.sid);if((p.default.info("onRejoin - remote stream will resubscribe ",n),n)&&(n.status!==h.ENUM_SUBSCRIBE_STATUS.unsubscribe&&n.status!==h.ENUM_SUBSCRIBE_STATUS.unsubscribing)){p.default.debug("onRejoin - remote stream will resubscribe ",n);var i=null===(t=r.socketManager)||void 0===t?void 0:t.connectId;r.resubscribe(n).catch((function(e){var t;return i!==(null===(t=r.socketManager)||void 0===t?void 0:t.connectId)?Promise.resolve():e.name===E.ErrorCodes.SOCKET_DISCONNECTED||e.name===E.ErrorCodes.NOT_JOIN||e.name===E.InnerErrorCodes.RESUBSCRIBING?Promise.resolve():(p.default.warn("resubscribe - [rejoin], "+e),new Promise((function(e,t){setTimeout((function(){r.resubscribe(n).then(e).catch(t)}),2e3)})))})).catch((function(e){var t;return i!==(null===(t=r.socketManager)||void 0===t?void 0:t.connectId)?Promise.resolve():e.name===E.ErrorCodes.SOCKET_DISCONNECTED||e.name===E.ErrorCodes.NOT_JOIN||e.name===E.InnerErrorCodes.RESUBSCRIBING?Promise.resolve():(p.default.error("resubscribe2 - [rejoin], "+e),new Promise((function(e,t){setTimeout((function(){r.resubscribe(n).then(e).catch(t)}),4e3)})))})).catch((function(e){var t;if(i!==(null===(t=r.socketManager)||void 0===t?void 0:t.connectId))return Promise.resolve();p.default.error("resubscribe3 - [rejoin], "+e),r.streamManager.removeRemoteStream(n),r._emitter&&r._emitter.emit("stream-removed",n.convertToOuterStream()),r.syncRoom().catch((function(e){p.default.debug("sync room failed ",e),p.default.report("sync room failed in resubscribe [rejoin] ",e)}))}))}}));var g=s.concat(c);a.forEach((function(e){e.uid!==r.user.user_id&&(g.findIndex((function(t){return t.user_id===e.uid}))<0&&(g.push({user_id:e.uid}),c.push({user_id:e.uid})))})),this.users=s.concat(c),u.forEach((function(e){r._emitter&&r._emitter.emit("user-removed",v.convertToOuterUser(e))})),c.forEach((function(e){r._emitter&&r._emitter.emit("user-added",v.convertToOuterUser(e))})),m.forEach((function(e){r.streamManager.removeRemoteStream(e),r._emitter&&r._emitter.emit("stream-removed",e.convertToOuterStream())})),l.forEach((function(e){var t=r.streamManager.createRemoteStream(e);t&&r._emitter&&r._emitter.emit("stream-added",t.convertToOuterStream())})),this.streamManager.getAllLocalStreams().forEach((function(e){var t;p.default.debug("onRejoin - local stream will republish ",e);var n=null===(t=r.socketManager)||void 0===t?void 0:t.connectId;r.republish(e).catch((function(t){var i;return n!==(null===(i=r.socketManager)||void 0===i?void 0:i.connectId)?Promise.resolve():t.name===E.ErrorCodes.SOCKET_DISCONNECTED||t.name===E.ErrorCodes.NOT_JOIN||t.name===E.InnerErrorCodes.REPUBLISHING?Promise.resolve():(p.default.warn("republish - [rejoin], "+t),new Promise((function(t,n){setTimeout((function(){r.republish(e).then(t).catch(n)}),2e3)})))})).catch((function(t){var i;return n!==(null===(i=r.socketManager)||void 0===i?void 0:i.connectId)?Promise.resolve():t.name===E.ErrorCodes.SOCKET_DISCONNECTED||t.name===E.ErrorCodes.NOT_JOIN||t.name===E.InnerErrorCodes.REPUBLISHING?Promise.resolve():(p.default.error("republish2 - [rejoin], "+t),new Promise((function(t,n){setTimeout((function(){r.republish(e).then(t).catch(n)}),4e3)})))})).catch((function(t){p.default.debug("republish3 - [rejoin], "+e.streamId+" "+t),p.default.report("republish3 - [rejoin], "+e.streamId+" "+t)}))}))},e.prototype.ping4Sync=function(){var e=this;if(!this.isJoinedRoom){var t="you have not joined the room";return p.default.debug("ping for syncing room - ",t),Promise.reject(E.createError(E.ErrorCodes.NOT_JOIN,t))}return new Promise((function(t,r){var n={app_id:e.session.app_id,room_id:e.session.room_id,user_id:e.session.user_id};e.send("ping",n,(function(){p.default.debug("ping success"),t()}),r)}))},e.prototype.onPing4Sync=function(e,t){p.default.debug("onPing ",e),t(),this.roomVersion!==e.version&&(this.roomVersion=e.version,this.syncRoom().catch((function(e){p.default.debug("sync room failed ",e),p.default.report("sync room failed ",e)})))},e.prototype.syncRoom=function(){var e=this;if(!this.isJoinedRoom){var t="you have not joined the room";return p.default.warn("sync room - ",t),Promise.reject(E.createError(E.ErrorCodes.NOT_JOIN,t))}return new Promise((function(t,r){var n={app_id:e.session.app_id,room_id:e.session.room_id,user_id:e.session.user_id};e.send("syncroom",n,(function(){p.default.debug("syncroom success"),t()}),r)}))},e.prototype.onSyncRoom=function(e,t){var r=this,n=e.users,i=void 0===n?[]:n,o=e.streams,a=void 0===o?[]:o;p.default.debug("onSyncRoom ",i,a),a=a||[];var s=[],c=[],u=[];(i=i||[]).forEach((function(e){e.user_id!==r.user.user_id&&(r.users.findIndex((function(t){return t.user_id===e.user_id}))>=0?s.push(e):c.push(e))})),this.users.forEach((function(e){s.findIndex((function(t){return t.user_id===e.user_id}))<0&&u.push(e)}));var d=this.streamManager.getAllRemoteStreams(),f=[],l=[],m=[];a.forEach((function(e){e.uid!==r.user.user_id&&(d.findIndex((function(t){return t.streamId===e.sid}))>=0?f.push(e):l.push(e))})),d.forEach((function(e){f.findIndex((function(t){return t.sid===e.streamId}))<0&&m.push(e)}));var g=s.concat(c);a.forEach((function(e){e.uid!==r.user.user_id&&(g.findIndex((function(t){return t.user_id===e.uid}))<0&&(g.push({user_id:e.uid}),c.push({user_id:e.uid})))})),this.users=s.concat(c),c.forEach((function(e){r._emitter&&r._emitter.emit("user-added",v.convertToOuterUser(e))})),u.forEach((function(e){r._emitter&&r._emitter.emit("user-removed",v.convertToOuterUser(e))})),f.forEach((function(e){var t=r.streamManager.getRemoteStream(e.sid);t&&(t.sourceAudioMuted!==e.muteaudio&&r.onAudioTrackst({user_id:e.uid,stream_id:e.sid,mute:e.muteaudio,track_type:h.ENUM_TRACK_TYPE.audio,media_type:e.media_type}),t.sourceVideoMuted!==e.mutevideo&&r.onVideoTrackst({user_id:e.uid,stream_id:e.sid,mute:e.mutevideo,track_type:h.ENUM_TRACK_TYPE.video,media_type:e.media_type}))})),m.forEach((function(e){r.streamManager.removeRemoteStream(e),r._emitter&&r._emitter.emit("stream-removed",e.convertToOuterStream())})),l.forEach((function(e){var t=r.streamManager.createRemoteStream(e);t&&r._emitter&&r._emitter.emit("stream-added",t.convertToOuterStream())})),t()},e.prototype.leaveRoom=function(e,t,r){var n=this,i="";switch(this.joinStatus){case h.ENUM_ROOM_STATUS.unjoin:return i="you have not joined the room",p.default.debug("leaveRoom - ",i),void r(E.createError(E.ErrorCodes.NOT_JOIN,i));case h.ENUM_ROOM_STATUS.joining:return i="you are joining the room",p.default.debug("leaveRoom - ",i),void r(E.createError(E.ErrorCodes.JOINING,i));case h.ENUM_ROOM_STATUS.leaving:return i="you are leaving the room",r(E.createError(E.ErrorCodes.LEAVING,i)),void r(i);case h.ENUM_ROOM_STATUS.joined:case h.ENUM_ROOM_STATUS.rejoining:}this.joinStatus=h.ENUM_ROOM_STATUS.leaving,this.isRecording&&!e.keepRecording&&this.socketManager&&this.stopRecording((function(){p.default.debug("leave room - stopRecording ")}),(function(e){p.default.warn("leave room - stop recording failed ",e)})),this.streamManager.getAllLocalStreams().forEach((function(e){e.connectionState!==c.ENUM_STREAM_CONNECTION_STATE.disconnected?(e.canUnPublish&&n.socketManager&&n._unpublish(e,(function(){p.default.info("leave room - unpublish success")}),(function(e){p.default.warn("leave room - unpublish failed ",e)})),e.close()):n.streamManager.removeLocalStream(e)})),this.streamManager.getAllRemoteStreams().forEach((function(e){e.connectionState!==c.ENUM_STREAM_CONNECTION_STATE.disconnected?(e.canUnSubscribe&&n.socketManager&&n._unsubscribe(n.user.user_id,e,(function(){p.default.info("leave room - unsubscribe success")}),(function(e){p.default.warn("leave room - unsubscribe failed ",e)})),e.close()):n.streamManager.removeRemoteStream(e)}));var o=function(){p.default.debug("leaveRoom success"),n.joinStatus=h.ENUM_ROOM_STATUS.unjoin,n.disconnect("leave room"),n.destroy(),t(v.convertToOuterUser(n.user))};this.socketManager&&this.socketManager.isOpened?this.send("leaveroom",{room_id:this.session.room_id},o,(function(e){p.default.debug("leaveRoom failed ",e),n.joinStatus=h.ENUM_ROOM_STATUS.joined,r(e)})):o(),window.clearInterval(this.ping4SyncInterval)},e.prototype.onLeaveRoom=function(e,t){p.default.debug("onLeaveRoom ",e),t()},e.prototype.publish=function(e,t,r){var n=this,i="";if(!this.isJoinedRoom)return i="you have not joined the room",p.default.warn("publish - ",i),void r(E.createError(E.ErrorCodes.NOT_JOIN,i));if(this.session.role_type===h.ENUM_ROLE_TYPE.pullStream)return i="role type is pull",p.default.warn("publish - ",i),void r(E.createError(E.ErrorCodes.ROLE_TYPE_NOT_MATCH,i));var o=s.StreamManager.generatePublishConfig(e),a=this.streamManager.getAllLocalStreams().find((function(e){return e.mediaType===o.mediaType}));if(a){var c=void 0;switch(a.mediaType){case h.ENUM_MEDIA_TYPE.desktop:c="screen";break;case h.ENUM_MEDIA_TYPE.camera:default:c="camera"}return i="the stream with "+c+" type exists, only one "+c+" stream can be published",p.default.warn(i),void r(E.createError(E.ErrorCodes.STREAM_EXISTS,i))}var d,f=function(e){p.default.debug("publish success"),n.streamManager.addLocalStream(e),t(e.convertToOuterStream())},l=function(e){p.default.warn("publish - ",e),n.logReporter.reportExceptionLog(u.ENUM_LOG_EXCEPTION_TYPE.publish,{stype:h.ENUM_STREAM_TYPE.publish,mtype:o.mediaType}),r(e)};try{d=this.streamManager.createLocalStream(this.user.user_id,o)}catch(i){return p.default.warn("publish - ",i),void l(i)}p.default.debug("create local stream ",d),d.hasVideo()&&d.updateVP(),d.status=h.ENUM_PUBLISH_STATUS.publishing;var m=function(e){n.streamManager.removeLocalStream(d),l(e)};d.init(e).then((function(){n.send("publish",{user_id:d.userId,media_type:d.mediaType,audio:d.hasAudio(),video:d.hasVideo(),data:d.data,vp:d.vp,payload:d.videoCodec},f,m,d)})).catch(m)},e.prototype.publishStream=function(e,t,r){var n=this,i="";if(!this.isJoinedRoom)return i="you have not joined the room",p.default.warn("publish - ",i),void r(E.createError(E.ErrorCodes.NOT_JOIN,i));if(this.session.role_type===h.ENUM_ROLE_TYPE.pullStream)return i="role type is pull",p.default.warn("publish - ",i),void r(E.createError(E.ErrorCodes.ROLE_TYPE_NOT_MATCH,i));var o=this.streamManager.getAllLocalStreams().find((function(t){return t.mediaType===e.mediaType}));if(o){var a=void 0;switch(o.mediaType){case h.ENUM_MEDIA_TYPE.desktop:a="screen";break;case h.ENUM_MEDIA_TYPE.camera:default:a="camera"}return i="the stream with "+a+" type exists, only one "+a+" stream can be published",p.default.warn(i),void r(E.createError(E.ErrorCodes.STREAM_EXISTS,i))}var s,c=function(e){p.default.debug("publish success"),e.audioMuted&&n.muteAudioSync(e,e.audioMuted),e.videoMuted&&n.muteVideoSync(e,e.videoMuted),n.streamManager.addLocalStream(e),t(e)},d=function(t){p.default.warn("publish - ",t),n.logReporter.reportExceptionLog(u.ENUM_LOG_EXCEPTION_TYPE.publish,{stype:h.ENUM_STREAM_TYPE.publish,mtype:e.mediaType}),r(t)};try{s=this.streamManager.createLocalStream(this.user.user_id,e.config)}catch(i){return p.default.warn("publish - ",i),void d(i)}p.default.debug("create local stream ",s),s.status=h.ENUM_PUBLISH_STATUS.publishing;var f=function(e){n.streamManager.removeLocalStream(s),d(e)};s.init({},e).then((function(){s.hasVideo()&&s.updateVP(),n.send("publish",{user_id:s.userId,media_type:s.mediaType,audio:s.hasAudio(),video:s.hasVideo(),data:s.data,vp:s.vp,payload:s.videoCodec},c,f,s)})).catch(f)},e.prototype.republish=function(e){return n.__awaiter(this,void 0,void 0,(function(){var t,r=this;return n.__generator(this,(function(n){return t=function(e,t){e.audio&&e.audioMuted&&(r.send("mute",{user_id:t.userId,stream_id:t.streamId,stream_type:t.streamType,track_type:h.ENUM_TRACK_TYPE.audio,mute:!0},(function(){p.default.info("restore mute audio success after republish")}),(function(){p.default.warn("restore mute audio failure after republish")})),t.muteAudio()),e.hasVideo()&&e.videoMuted&&(r.send("mute",{user_id:t.userId,stream_id:t.streamId,stream_type:t.streamType,track_type:h.ENUM_TRACK_TYPE.video,mute:!0},(function(){p.default.info("restore mute video success after republish")}),(function(){p.default.warn("restore mute video failure after republish")})),t.muteVideo())},[2,new Promise((function(n,i){var o;if(null===(o=r.socketManager)||void 0===o?void 0:o.isOpened)if(r.isJoinedRoom)if(e.status!==h.ENUM_PUBLISH_STATUS.republishing){e.status=h.ENUM_PUBLISH_STATUS.republishing;var a=e.convertToOuterStream();e.destroyConnection(),p.default.debug("republish old stream ",a);r.send("publish",{user_id:e.userId,media_type:e.mediaType,audio:e.hasAudio(),video:e.hasVideo(),data:e.data,vp:e.vp,payload:e.videoCodec},(function(r){var i=r.convertToOuterStream();p.default.debug("republish new stream ",i),t(e,r),e.status=h.ENUM_PUBLISH_STATUS.published,n()}),(function(t){p.default.debug("republish error",t),e.status=h.ENUM_PUBLISH_STATUS.published,i(t)}),e)}else i(E.createError(E.InnerErrorCodes.REPUBLISHING,"stream is republishing"));else i(E.createError(E.ErrorCodes.NOT_JOIN,"not joined the room"));else i(E.createError(E.ErrorCodes.SOCKET_DISCONNECTED,"socket is disconnected"))}))]}))}))},e.prototype.onPublish=function(e,t,r,n){var i=this,o=e.stream_id,a=e.media_type;p.default.debug("onPublish ",o,a),this.logReporter.reportOperationLog(u.ENUM_LOG_OPERATION_TYPE.publish,{streamId:o,stype:n.streamType,mtype:n.mediaType});var s=function(e){p.default.info("rollback publish ",e),i._unpublish(n,(function(){p.default.info("rollback publish success"),r(e)}),(function(t){p.default.warn("rollback publish failed ",t),r(e)}))};n.status!==h.ENUM_PUBLISH_STATUS.published&&n.status!==h.ENUM_PUBLISH_STATUS.republishing||(n.initConnection(),n.initMediaStream(),n.addTracks2PeerConnection()),n.connect(o).then((function(e){i.sdpPublish(n,e,(function(){t(n)}),s)})).catch(s)},e.prototype.muteAudioSync=function(e,t){this.send("mute",{user_id:e.userId,stream_id:e.streamId,stream_type:e.streamType,track_type:h.ENUM_TRACK_TYPE.audio,mute:t},(function(){p.default.info("mute audio sync success after publish")}),(function(){p.default.warn("mute audio sync failure after publish")}))},e.prototype.muteVideoSync=function(e,t){this.send("mute",{user_id:e.userId,stream_id:e.streamId,stream_type:e.streamType,track_type:h.ENUM_TRACK_TYPE.video,mute:t},(function(){p.default.info("mute video sync success after publish")}),(function(){p.default.warn("mute video sync failure after publish")}))},e.prototype.unpublish=function(e,t,r){var n,i=this,o=this.streamManager.getLocalStream(e);if(!o)return n="cannot find stream",void r(E.createError(E.ErrorCodes.STREAM_NOT_EXISTS,n));if(!o.canUnPublish)return n="the stream cannot unpublish",void r(E.createError(E.ErrorCodes.OTHERS,n));if(o.connectionState===c.ENUM_STREAM_CONNECTION_STATE.disconnected)return this.streamManager.removeLocalStream(o),void t(o.convertToOuterStream());o.status=h.ENUM_PUBLISH_STATUS.unpublishing,this.send("unpublish",{user_id:o.userId,stream_id:o.streamId,media_type:o.mediaType},(function(){i.streamManager.removeLocalStream(o),p.default.debug("unpublish success "),t(o.convertToOuterStream())}),(function(e){p.default.error("unpublish ",e),o.status=h.ENUM_PUBLISH_STATUS.published,r(e)}),o)},e.prototype.unpublishStream=function(e,t,r){this.send("unpublish",{user_id:e.userId,stream_id:e.streamId,media_type:e.mediaType},(function(){p.default.debug("unpublish success "),t(e)}),(function(t){p.default.error("unpublish ",t),e.status=h.ENUM_PUBLISH_STATUS.published,r(t)}),e)},e.prototype._unpublish=function(e,t,r){var n=this;this.send("unpublish",{user_id:e.userId,stream_id:e.streamId,media_type:e.mediaType},(function(){n.logReporter.reportOperationLog(u.ENUM_LOG_OPERATION_TYPE.unpublish,{streamId:e.streamId,stype:e.streamType,mtype:e.mediaType}),t()}),(function(e){r(E.createError(E.ErrorCodes.SERVER_API,e))}))},e.prototype.onUnpublish=function(e,t,r,n){p.default.debug("onUnpublish ",e),p.default.debug("onUnpublish placeholder ",r),n?(this.logReporter.reportOperationLog(u.ENUM_LOG_OPERATION_TYPE.unpublish,{streamId:n.streamId,stype:n.streamType,mtype:n.mediaType}),t()):t()},e.prototype.subscribe=function(e,t,r){var n=this,i="";if(!this.isJoinedRoom)return i="you have not joined the room",p.default.warn(i),void r(E.createError(E.ErrorCodes.NOT_JOIN,i));var o=this.streamManager.getRemoteStream(e);if(p.default.debug("subscribe - ",e,o),!o)return i="stream - "+e+" is not found",p.default.warn(i),void r(E.createError(E.ErrorCodes.STREAM_NOT_EXISTS,i));if(!o.canSubscribe)return i="the stream cannot be subscribed",p.default.warn(i),void r(E.createError(E.ErrorCodes.OTHERS,i));o.status=h.ENUM_SUBSCRIBE_STATUS.subscribing,this.send("subscribe",{src:{user_id:this.user.user_id,audio:o.audio,video:o.video,data:o.data},dst:{user_id:o.userId,stream_id:o.streamId,media_type:o.mediaType}},(function(e){p.default.debug("subscribe success "),t(e.convertToOuterStream())}),(function(e){p.default.debug("subscribe - ",e),o.status=h.ENUM_SUBSCRIBE_STATUS.unsubscribe,n.logReporter.reportExceptionLog(u.ENUM_LOG_EXCEPTION_TYPE.subscribe,{userId:o.userId,streamId:o.streamId,stype:o.streamType,mtype:o.mediaType}),r(e)}),o)},e.prototype.resubscribe=function(e){return n.__awaiter(this,void 0,void 0,(function(){var t=this;return n.__generator(this,(function(r){return[2,new Promise((function(r,n){var i;if(null===(i=t.socketManager)||void 0===i?void 0:i.isOpened)if(t.isJoinedRoom)if(e.status!==h.ENUM_SUBSCRIBE_STATUS.resubscribing){e.status=h.ENUM_SUBSCRIBE_STATUS.resubscribing;var o=e.convertToOuterStream();e.destroyMediaStream(),e.destroyConnection(),p.default.debug("resubscribe old stream ",o);t.send("subscribe",{src:{user_id:t.user.user_id,audio:e.audio,video:e.video,data:e.data},dst:{user_id:e.userId,stream_id:e.streamId,media_type:e.mediaType}},(function(t){var n=t.convertToOuterStream();p.default.debug("resubscribe new stream ",n),e.status=h.ENUM_SUBSCRIBE_STATUS.subscribed,r()}),(function(t){p.default.debug("resubscribe error",t),e.status=h.ENUM_SUBSCRIBE_STATUS.subscribed,n(t)}),e)}else n(E.createError(E.InnerErrorCodes.RESUBSCRIBING,"stream is resubscribing"));else n(E.createError(E.ErrorCodes.NOT_JOIN,"not joined the room"));else n(E.createError(E.ErrorCodes.SOCKET_DISCONNECTED,"socket is disconnected"))}))]}))}))},e.prototype.onSubscribe=function(e,t,r,n){var i=this,o=e.streamsub_id,a=e.stream_id,s=e.media_type,c=e.user_id;p.default.debug("onSubscribe ",o,a,s,c),this.logReporter.reportOperationLog(u.ENUM_LOG_OPERATION_TYPE.subscribe,{streamId:n.streamId,userId:n.userId,stype:n.streamType,mtype:n.mediaType});var d=function(e){p.default.debug("rollback subscribe ",e),i._unsubscribe(i.user.user_id,n,(function(){p.default.info("rollback subscribe success"),n.close(),r(E.createError(E.ErrorCodes.SERVER_API,e))}),(function(e){p.default.warn("rollback subscribe failed ",e),n.close(),r(E.createError(E.ErrorCodes.SERVER_API,e))}))};n.initConnection(),n.initMediaStream(),n.handlePeerConnectionTrackEvent(),n.connect(o).then((function(e){i.sdpSubscribe(n,e,(function(){t(n)}),d)})).catch(d)},e.prototype.unsubscribe=function(e,t,r){var n="",i=this.streamManager.getRemoteStream(e);if(!i)return n="stream is not found",p.default.warn(n),void r(n);if(p.default.debug("unsubscribe ",e,i),!i.canUnSubscribe)return n="the stream cannot be unsubscribed",p.default.warn(n),void r(n);i.status=h.ENUM_SUBSCRIBE_STATUS.unsubscribing,this.send("unsubscribe",{src:{user_id:this.user.user_id,streamsub_id:i.streamSubId},dst:{user_id:i.userId,stream_id:i.streamId,media_type:i.mediaType}},(function(){p.default.debug("unsubscribe success"),t(i.convertToOuterStream())}),(function(e){p.default.debug("unsubscribe - ",e),i.status=h.ENUM_SUBSCRIBE_STATUS.subscribed,r(e)}),i)},e.prototype._unsubscribe=function(e,t,r,n){var i=this;this.send("unsubscribe",{src:{user_id:e,streamsub_id:t.streamSubId},dst:{user_id:t.userId,stream_id:t.streamId,media_type:t.mediaType}},(function(){i.logReporter.reportOperationLog(u.ENUM_LOG_OPERATION_TYPE.unsubscribe,{streamId:t.streamId,userId:t.userId,stype:t.streamType,mtype:t.mediaType}),r()}),n)},e.prototype.onUnsubscribe=function(e,t,r,n){var i=e.user_id,o=e.media_type;p.default.debug("onUnsubscribe ",i,o,n),p.default.debug("onUnsubscribe placeholder ",r),n?(this.logReporter.reportOperationLog(u.ENUM_LOG_OPERATION_TYPE.unsubscribe,{streamId:n.streamId,userId:n.userId,stype:n.streamType,mtype:n.mediaType}),n.close(),t()):t()},e.prototype.sdpPublish=function(e,t,r,n){var i=this;p.default.debug("sdpPublish ",e,t);this.send("sdp",{src:{user_id:e.userId,stream_id:e.streamId,stream_type:e.streamType,media_type:e.mediaType},sdp:{type:"offer",sdpcontent:t.sdp,minbitrate:e.minVideoBitRate,maxbitrate:e.hasVideo()?2500:1e3}},(function(){p.default.debug("sdpPublish"),e.hasVideo()&&i.updateVP(e,e.resolution).catch((function(e){p.default.debug("update vp",e)})),r()}),(function(e){p.default.error("sdpPublish - ",e),n(E.createError(E.ErrorCodes.SERVER_API,e))}),e)},e.prototype.onSdpPublish=function(e,t,r,n){p.default.debug("onSdpPublish ",e);var i=e.sdp;n.answer(i).then((function(){p.default.debug("onSdpPublish"),t()})).catch((function(e){p.default.error("onSdpPublish - ",e),r(e)}))},e.prototype.sdpSubscribe=function(e,t,r,n){p.default.debug("sdpSubscribe ",e,t);this.send("sdp",{src:{user_id:this.user.user_id,stream_id:e.streamSubId,stream_type:e.streamType,media_type:e.mediaType},sdp:{type:"offer",sdpcontent:t.sdp}},(function(){p.default.debug("sdpSubscribe"),r()}),(function(e){p.default.debug("sdpSubscribe - ",e),n(e)}),e)},e.prototype.onSdpSubscribe=function(e,t,r,n){p.default.debug("onSdpSubscribe ",e);var i=e.sdp;n.answer(i).then((function(){p.default.debug("onSdpSubscribe"),n.status=h.ENUM_SUBSCRIBE_STATUS.subscribed,t()})).catch((function(e){p.default.debug("onSdpSubscribe - ",e),r(e)}))},e.prototype.muteVideo=function(e,t){var r=this,n=this.streamManager.getStream(e);if(!n){return p.default.warn("cannot find stream"),!1}if(n.videoMuted)return!0;var i=this.user.user_id,o=n.streamId;n.streamType===h.ENUM_STREAM_TYPE.subscribe&&(o=n.streamSubId);var a=function(){r.logReporter.reportOperationLog(u.ENUM_LOG_OPERATION_TYPE.muteVideo,{streamId:o,userId:i,stype:n.streamType,mtype:n.mediaType})},s=function(e){t(e);var n={code:""+e.name,message:""+e.message};r._emitter&&r._emitter.emit("error-notify",n)},c=function(){r.send("mute",{user_id:i,stream_id:o,stream_type:n.streamType,track_type:h.ENUM_TRACK_TYPE.video,mute:!0},a,s)};if(n.muteVideo()){var d=300-(Date.now()-n.lastEmitTime);return!n.isSubscriber&&d>0?setTimeout(c,d):c(),!0}return!1},e.prototype.unmuteVideo=function(e,t){var r=this,n=this.streamManager.getStream(e);if(!n){return p.default.warn("cannot find stream"),!1}if(!n.videoMuted)return!0;var i=this.user.user_id,o=n.streamId;n.streamType===h.ENUM_STREAM_TYPE.subscribe&&(o=n.streamSubId);return!!n.unmuteVideo()&&(this.send("mute",{user_id:i,stream_id:o,stream_type:n.streamType,track_type:h.ENUM_TRACK_TYPE.video,mute:!1},(function(){r.logReporter.reportOperationLog(u.ENUM_LOG_OPERATION_TYPE.unmuteVideo,{streamId:o,userId:i,stype:n.streamType,mtype:n.mediaType})}),(function(e){t(e);var n={code:""+e.name,message:""+e.message};r._emitter&&r._emitter.emit("error-notify",n)})),!0)},e.prototype.muteAudio=function(e,t){var r=this,n=this.streamManager.getStream(e);if(!n){return p.default.warn("cannot find stream"),!1}if(n.audioMuted)return!0;var i=this.user.user_id,o=n.streamId;n.streamType===h.ENUM_STREAM_TYPE.subscribe&&(o=n.streamSubId);var a=function(){r.logReporter.reportOperationLog(u.ENUM_LOG_OPERATION_TYPE.muteAudio,{streamId:o,userId:i,stype:n.streamType,mtype:n.mediaType})},s=function(e){t(e);var n={code:""+e.name,message:""+e.message};r._emitter&&r._emitter.emit("error-notify",n)},c=function(){r.send("mute",{user_id:i,stream_id:o,stream_type:n.streamType,track_type:h.ENUM_TRACK_TYPE.audio,mute:!0},a,s)};if(n.muteAudio()){var d=300-(Date.now()-n.lastEmitTime);return!n.isSubscriber&&d>0?setTimeout(c,d):c(),!0}return!1},e.prototype.unmuteAudio=function(e,t){var r=this,n=this.streamManager.getStream(e);if(!n){return p.default.warn("cannot find stream"),!1}if(!n.audioMuted)return!0;var i=this.user.user_id,o=n.streamId;n.streamType===h.ENUM_STREAM_TYPE.subscribe&&(o=n.streamSubId);return!!n.unmuteAudio()&&(this.send("mute",{user_id:i,stream_id:o,stream_type:n.streamType,track_type:h.ENUM_TRACK_TYPE.audio,mute:!1},(function(){r.logReporter.reportOperationLog(u.ENUM_LOG_OPERATION_TYPE.unmuteAudio,{streamId:o,userId:i,stype:n.streamType,mtype:n.mediaType})}),(function(e){t(e);var n={code:""+e.name,message:""+e.message};r._emitter&&r._emitter.emit("error-notify",n)})),!0)},e.prototype.muteData=function(){},e.prototype.unmuteData=function(){},e.prototype.startRecording=function(e,t,r){var n,i,o=this,a="";if(!(n=e.mixStreamUId===this.user.user_id?this.streamManager.getAllLocalStreams().find((function(t){return t.mediaType===e.mixStreamType})):this.streamManager.getAllRemoteStreams().find((function(t){return t.userId===e.mixStreamUId&&t.mediaType===e.mixStreamType})))){var s="cannot find corresponding stream";return p.default.warn(s),void r(E.createError(E.ErrorCodes.STREAM_NOT_EXISTS,s))}switch(this.recordStatus){case h.ENUM_RECORD_STATUS.starting:return a="record is starting",p.default.warn(a),void r(E.createError(E.ErrorCodes.OTHERS,a));case h.ENUM_RECORD_STATUS.stopping:return a="record is stopping",p.default.warn(a),void r(E.createError(E.ErrorCodes.OTHERS,a));case h.ENUM_RECORD_STATUS.recording:return a="is recording",p.default.warn(a),void r(E.createError(E.ErrorCodes.OTHERS,a));case h.ENUM_RECORD_STATUS.unrecord:}if(n.audio&&n.video)i=h.ENUM_RECORD_MIME.audioVideo;else if(n.audio)i=h.ENUM_RECORD_MIME.audio;else{if(!n.video)return a="stream config is incorrect",p.default.warn(a),void r(E.createError(E.ErrorCodes.OTHERS,a));i=h.ENUM_RECORD_MIME.video}var c=this.recordStreamType=n.streamType,d=this.recordMediaType=n.mediaType;this.recordStatus=h.ENUM_RECORD_STATUS.starting;var f={mimetype:i,mainviewuid:e.mixStreamUId,mainviewtype:e.mixStreamType,width:e.mixStreamWidth,height:e.mixStreamHeight,watermarkpos:e.waterMarkPos,watertype:e.waterMarkType,waterurl:e.waterMarkRemarks,wtemplate:e.mixStreamTemplate,isaverage:e.isAverage,bucket:e.bucket,region:e.region};e.isRelay?(f.isrelay=e.isRelay,f.time=e.relayTime,f.fragment=e.relayFragment):e.isrelay=e.isRelay,this.send("startrecord",{room_id:this.session.room_id,app_id:this.session.app_id,user_id:this.session.user_id,config:f},(function(e){p.default.debug("startRecording success",e),o.logReporter.reportOperationLog(u.ENUM_LOG_OPERATION_TYPE.startRecord,{recordId:e.RecordId,stype:c,mtype:d}),o.recordStatus=h.ENUM_RECORD_STATUS.recording,t({FileName:e.FileName,RecordId:e.RecordId})}),(function(e){p.default.error("startRecording - ",e),o.recordStatus=h.ENUM_RECORD_STATUS.unrecord,r(e)}))},e.prototype.onStartRecord=function(e,t){p.default.debug("onStartRecord ",e);var r=e.RecordId,n=e.FileName;this.recordId=r,t({RecordId:r,FileName:n})},e.prototype.stopRecording=function(e,t){var r=this,n="";switch(this.recordStatus){case h.ENUM_RECORD_STATUS.starting:return n="local stream record is starting",p.default.warn(n),void t(E.createError(E.ErrorCodes.OTHERS,n));case h.ENUM_RECORD_STATUS.stopping:return n="local stream record is stopping",p.default.warn(n),void t(E.createError(E.ErrorCodes.OTHERS,n));case h.ENUM_RECORD_STATUS.unrecord:return n="local stream isnot recording",p.default.warn(n),void t(E.createError(E.ErrorCodes.OTHERS,n));case h.ENUM_RECORD_STATUS.recording:}this.recordStatus=h.ENUM_RECORD_STATUS.stopping;var i=this.recordId,o=this.recordStreamType,a=this.recordMediaType;this.send("stoprecord",{room_id:this.session.room_id,app_id:this.session.app_id,user_id:this.session.user_id},(function(){p.default.debug("stopRecording success"),r.logReporter.reportOperationLog(u.ENUM_LOG_OPERATION_TYPE.stopRecord,{recordId:i,stype:o,mtype:a}),r.recordStatus=h.ENUM_RECORD_STATUS.unrecord,e()}),(function(e){p.default.debug("stopRecording - ",e),r.recordStatus=h.ENUM_RECORD_STATUS.recording,t(e)}))},e.prototype.onStopRecord=function(e,t){p.default.debug("onStopRecord ",e),this.recordId="",this.recordStreamType=h.ENUM_STREAM_TYPE.publish,this.recordMediaType=h.ENUM_MEDIA_TYPE.camera,t()},e.prototype.startMix=function(e,t,r,n){var i=this,o=h.ENUM_STREAM_TYPE.publish;o=r.mainviewuid&&r.mainviewuid===this.user.user_id?h.ENUM_STREAM_TYPE.subscribe:h.ENUM_STREAM_TYPE.publish;var a=h.ENUM_MEDIA_TYPE.camera;r.mainviewtype&&(a=r.mainviewtype),this.mixStream={streamType:o,mediaType:a};this.send("startmix",{type:e,app_id:this.session.app_id,room_id:this.session.room_id,user_id:this.session.user_id,streams:t||[],config:r},(function(t){switch(p.default.debug("startMix success",t),e){case h.ENUM_MIX_TYPE.relay:i.logReporter.reportOperationLog(u.ENUM_LOG_OPERATION_TYPE.startRelay,{recordId:t.MixId,stype:o,mtype:a});break;case h.ENUM_MIX_TYPE.record:i.logReporter.reportOperationLog(u.ENUM_LOG_OPERATION_TYPE.startRecord,{recordId:t.MixId,stype:o,mtype:a});break;case h.ENUM_MIX_TYPE.relayRecord:i.logReporter.reportOperationLog(u.ENUM_LOG_OPERATION_TYPE.startRelay,{recordId:t.MixId,stype:o,mtype:a}),i.logReporter.reportOperationLog(u.ENUM_LOG_OPERATION_TYPE.startRecord,{recordId:t.MixId,stype:o,mtype:a})}n(void 0,t)}),(function(t){switch(p.default.debug("startMix - "+t),e){case h.ENUM_MIX_TYPE.relay:i.logReporter.reportExceptionLog(u.ENUM_LOG_EXCEPTION_TYPE.relay,{msg:""+t});break;case h.ENUM_MIX_TYPE.record:i.logReporter.reportExceptionLog(u.ENUM_LOG_EXCEPTION_TYPE.record,{msg:""+t});break;case h.ENUM_MIX_TYPE.relayRecord:i.logReporter.reportExceptionLog(u.ENUM_LOG_EXCEPTION_TYPE.relay,{msg:""+t}),i.logReporter.reportExceptionLog(u.ENUM_LOG_EXCEPTION_TYPE.record,{msg:""+t})}n(t)}))},e.prototype.updateMix=function(e,t,r){var n={type:h.ENUM_MIX_TYPE.update,app_id:this.session.app_id,room_id:this.session.room_id,user_id:this.session.user_id,config:t};e.length>0&&(n.streams=e,n.config.layoutUserlimit=e.length),this.send("startmix",n,(function(e){p.default.debug("updateMix success",e),r(void 0,e)}),(function(e){p.default.debug("updateMix - "+e),r(e)}))},e.prototype.onStartMix=function(e,t){p.default.debug("onStartMix ",e);var r=e.mix_id,n=e.filename,i=e.pushurl;t(n&&i?{MixId:r,FileName:n,PushURL:[i]}:n?{MixId:r,FileName:n}:i?{MixId:r,PushURL:[i]}:{MixId:r})},e.prototype.stopMix=function(e,t,r){var n=this;this.send("stopmix",{type:e,pushurl:t,app_id:this.session.app_id,room_id:this.session.room_id,user_id:this.session.user_id},(function(t){p.default.debug("stopMix success");var i=n.mixStream||{},o=i.streamType,a=i.mediaType,s=t.MixId||"";switch(e){case h.ENUM_MIX_TYPE.relay:n.logReporter.reportOperationLog(u.ENUM_LOG_OPERATION_TYPE.stopRelay,{recordId:s,stype:o,mtype:a});break;case h.ENUM_MIX_TYPE.record:n.logReporter.reportOperationLog(u.ENUM_LOG_OPERATION_TYPE.stopRecord,{recordId:s,stype:o,mtype:a});break;case h.ENUM_MIX_TYPE.relayRecord:n.logReporter.reportOperationLog(u.ENUM_LOG_OPERATION_TYPE.stopRelay,{recordId:s,stype:o,mtype:a}),n.logReporter.reportOperationLog(u.ENUM_LOG_OPERATION_TYPE.stopRecord,{recordId:s,stype:o,mtype:a})}r(void 0,t)}),(function(e){p.default.warn("stopMix - "+e),n.logReporter.reportExceptionLog(u.ENUM_LOG_EXCEPTION_TYPE.others,{msg:"stopMix - "+e}),r(e)}))},e.prototype.onStopMix=function(e,t){p.default.debug("onStopMix ",e);var r=e.mix_id;t(r?{MixId:r}:{})},e.prototype.queryMix=function(e){this.send("queymix",{app_id:this.session.app_id,room_id:this.session.room_id,user_id:this.session.user_id},(function(t){p.default.debug("queryMix success"),e(void 0,t)}),(function(t){p.default.error("queryMix - "+t),e(t)}))},e.prototype.onQueryMix=function(e,t){if(p.default.debug("onQueryMix ",e),e){var r=e.type,n=e.mix_id,i=e.filename,o=e.pushurl;switch(r){case h.ENUM_MIX_TYPE.relay:t({Type:"relay",MixId:n,PushURL:o?[o]:[]});break;case h.ENUM_MIX_TYPE.relayRecord:t({Type:"relay-and-record",MixId:n,FileName:i,PushURL:o?[o]:[]});break;case h.ENUM_MIX_TYPE.record:t({Type:"record",MixId:n,FileName:i});break;default:t({})}}else t({})},e.prototype.addMixStreams=function(e,t){this.send("addmixstream",{app_id:this.session.app_id,room_id:this.session.room_id,user_id:this.session.user_id,streams:e||[]},(function(e){p.default.debug("addMixStreams success",e),t(void 0,e)}),(function(e){p.default.error("addMixStreams - "+e),t(e)}))},e.prototype.onAddMixStreams=function(e,t){var r=e.mix_id;t(r?{MixId:r}:{})},e.prototype.removeMixStreams=function(e,t){this.send("delmixstream",{app_id:this.session.app_id,room_id:this.session.room_id,user_id:this.session.user_id,streams:e||[]},(function(e){p.default.debug("removeMixStreams success",e),t(void 0,e)}),(function(e){p.default.error("removeMixStreams - "+e),t(e)}))},e.prototype.onRemoveMixStreams=function(e,t){var r=e.mix_id;t(r?{MixId:r}:{})},e.prototype.logoff=function(e,t){var r=this;return new Promise((function(n,i){r.send("logoff",{app_id:r.session.app_id,room_id:r.session.room_id,user_id:r.session.user_id,cmdtype:e,users:t},n,i)}))},e.prototype.onLogoff=function(e,t){p.default.debug("on log off",e),t()},e.prototype.updateVP=function(e,t){var r=this,n=t.attributes,i=S.getVP(n),o=n.maxVideoBW,a=n.minVideoBW;return new Promise((function(t,s){r.send("updatevp",{app_id:r.session.app_id,room_id:r.session.room_id,user_id:r.session.user_id,stream_id:e.streamId,vp:i,maxbitrate:o,minbitrate:a},(function(){r.logReporter.reportOperationLog(u.ENUM_LOG_OPERATION_TYPE.updateVP,{msg:n.videoWidth+"*"+n.videoHeight}),t()}),s)}))},e.prototype.onUpdateVP=function(e,t){p.default.debug("on update vp",e),t()},e.prototype.onError=function(e){p.default.warn("onError - method: "+e.method+", code: "+e.code+", msg: "+e.msg)},e.prototype.onUserJoin=function(e){var t=e.user_id,r=e.cmdtype,n=e.reason;if(p.default.debug("onUserJoin ",t,r,n),!this.users.find((function(e){return e.user_id===t}))){var i={user_id:t};this.users.push(i),this._emitter&&this._emitter.emit("user-added",v.convertToOuterUser(i))}},e.prototype.onUserLeave=function(e){var t=e.user_id,r=e.cmdtype,n=e.reason;p.default.debug("onUserLeave ",t,r,n);var i=this.users.findIndex((function(e){return e.user_id===t}));if(i>=0){var o=this.users[i];this.users.splice(i,1),this._emitter&&this._emitter.emit("user-removed",v.convertToOuterUser(o))}},e.prototype.onAddStream=function(e){var t=e.user_id,r=e.cmdtype,n=e.stream;if(p.default.debug("onAddStream ",t,r,n),!this.users.find((function(e){return e.user_id===t}))){var i={user_id:t};this.users.push(i),this._emitter&&this._emitter.emit("user-added",v.convertToOuterUser(i))}var o=Object.assign({uid:t},n),a=this.streamManager.getAllRemoteStreams().find((function(e){return e.userId===o.uid&&o.media_type===e.mediaType}));a&&(this.streamManager.removeRemoteStream(a),this._emitter&&this._emitter.emit("stream-removed",a.convertToOuterStream()));var s=this.streamManager.createRemoteStream(o);s&&this._emitter&&this._emitter.emit("stream-added",s.convertToOuterStream())},e.prototype.onRemoveStream=function(e){var t=e.user_id,r=e.stream;p.default.debug("onRemoveStream ",t,r);var n=this.streamManager.getRemoteStream(r.sid);if(n)this.streamManager.removeRemoteStream(n),this._emitter&&this._emitter.emit("stream-removed",n.convertToOuterStream());else{var i="stream "+r.sid+" is not found";p.default.debug("onRemoveStream - ",i)}},e.prototype.onTransportClose=function(e){var t=e.user_id,r=e.stream;p.default.debug("onTransportClose ",t,r),t===this.user.user_id||this.onRemoveStream({user_id:t,stream:r})},e.prototype.onTransportTimeout=function(e){p.default.debug("onTransportTimeout",e);var t=e.user_id,r=e.stream;t===this.user.user_id||this.onRemoveStream({user_id:t,stream:r})},e.prototype.onAudioTrackst=function(e){var t=e.user_id,r=e.stream_id,n=e.mute,i=e.track_type,o=e.media_type;p.default.debug("onAudioTrackst ",t,r,n,i,o);var a=this.streamManager.getRemoteStream(r);if(a)a.sourceAudioMuted=!!n,n?(a.muteAudio(!0),this._emitter&&this._emitter.emit("mute-audio",a.convertToOuterStream())):(a.unmuteAudio(!0),this._emitter&&this._emitter.emit("unmute-audio",a.convertToOuterStream()));else{var s="stream "+r+" is not found";p.default.warn("onAudioTrackst - ",s)}},e.prototype.onVideoTrackst=function(e){var t=e.user_id,r=e.stream_id,n=e.mute,i=e.track_type,o=e.media_type;p.default.debug("onVideoTrackst ",t,r,n,i,o);var a=this.streamManager.getRemoteStream(r);if(a)a.sourceVideoMuted=!!n,n?(a.muteVideo(!0),this._emitter&&this._emitter.emit("mute-video",a.convertToOuterStream())):(a.unmuteVideo(!0),this._emitter&&this._emitter.emit("unmute-video",a.convertToOuterStream()));else{var s="stream "+r+" is not found";p.default.warn("onVideoTrackst - ",s)}},e.prototype.onDataTrackst=function(e){var t=e.user_id,r=e.stream_id,n=e.mute,i=e.track_type,o=e.media_type;p.default.debug("onDataTrackst ",t,r,n,i,o);var a=this.streamManager.getRemoteStream(r);if(a)n?this._emitter&&this._emitter.emit("mute-data",a.convertToOuterStream()):this._emitter&&this._emitter.emit("unmute-data",a.convertToOuterStream());else{var s="stream "+r+" is not found";p.default.warn("onDataTrackst - ",s)}},e.prototype.onKickoff=function(e){this.disconnect("kick off"),this.destroy(),this._emitter&&this._emitter.emit("kick-off",e)},e.prototype.onMixNotify=function(e,t,r){var n;switch(e){case 24149:case 24150:case 24152:n=E.createError(""+e,t)}var i={code:""+e,message:""+t};r.filename?(n&&this.logReporter.reportExceptionLog(u.ENUM_LOG_EXCEPTION_TYPE.record,{msg:e+" "+t}),this._emitter&&this._emitter.emit("record-notify",i)):r.pushurl&&r.pushurl.length>0&&(n&&this.logReporter.reportExceptionLog(u.ENUM_LOG_EXCEPTION_TYPE.relay,{msg:e+" "+t}),this._emitter&&this._emitter.emit("relay-notify",i))},e.prototype.onLogoffNotify=function(e){var t=this;p.default.debug("logoff notify ",e);var r=e.user_id;switch(e.cmdtype){case h.ENUM_LOGOFF_TYPE.quit:this.onKickoff({user_id:r,reason:"logoff notify"});break;case h.ENUM_LOGOFF_TYPE.reconnect:this.joinRoomType=h.ENUM_JOIN_ROOM_TYPE.reconnect,this.signalManager.reconnect();break;case h.ENUM_LOGOFF_TYPE.switch:this.joinRoomType=h.ENUM_JOIN_ROOM_TYPE.switch,this.signalManager.switch();break;case h.ENUM_LOGOFF_TYPE.refresh:this.refreshSignal().then((function(e){var r=e[0],n=e[1];t.signalSwitchConfig=n,t.joinRoomType=h.ENUM_JOIN_ROOM_TYPE.refresh,t.signalManager.refresh(r)}))}},e.prototype.onMediaStreamPublished=function(e){this._emitter&&this._emitter.emit("stream-published",e.convertToOuterStream())},e.prototype.onMediaStreamSubscribed=function(e){this._emitter&&this._emitter.emit("stream-subscribed",e.convertToOuterStream())},e.prototype.onScreenMediaStreamEnded=function(e){this._emitter&&this._emitter.emit("screenshare-stopped",e.convertToOuterStream())},e.prototype.onStreamConnectionClosed=function(e){var t,r=this,n=null===(t=this.socketManager)||void 0===t?void 0:t.connectId;e.isSubscriber?this.resubscribe(e).catch((function(t){var i;return n!==(null===(i=r.socketManager)||void 0===i?void 0:i.connectId)?Promise.resolve():t.name===E.ErrorCodes.SOCKET_DISCONNECTED||t.name===E.ErrorCodes.NOT_JOIN||t.name===E.InnerErrorCodes.RESUBSCRIBING?Promise.resolve():(p.default.warn("resubscribe - [iceconnection closed], "+t),new Promise((function(t,n){setTimeout((function(){r.resubscribe(e).then(t).catch(n)}),2e3)})))})).catch((function(t){var i;return n!==(null===(i=r.socketManager)||void 0===i?void 0:i.connectId)?Promise.resolve():t.name===E.ErrorCodes.SOCKET_DISCONNECTED||t.name===E.ErrorCodes.NOT_JOIN||t.name===E.InnerErrorCodes.RESUBSCRIBING?Promise.resolve():(p.default.error("resubscribe2 - [iceconnection closed], "+t),new Promise((function(t,n){setTimeout((function(){r.resubscribe(e).then(t).catch(n)}),4e3)})))})).catch((function(t){var i;if(n!==(null===(i=r.socketManager)||void 0===i?void 0:i.connectId))return Promise.resolve();p.default.error("resubscribe3 - [iceconnection closed], "+t),r.streamManager.removeRemoteStream(e),r._emitter&&r._emitter.emit("stream-removed",e.convertToOuterStream()),r.syncRoom().catch((function(e){p.default.debug("sync room failed ",e),p.default.report("sync room failed in resubscribe",e)}))})):this.republish(e).catch((function(t){var i;return n!==(null===(i=r.socketManager)||void 0===i?void 0:i.connectId)?Promise.resolve():t.name===E.ErrorCodes.SOCKET_DISCONNECTED||t.name===E.ErrorCodes.NOT_JOIN||t.name===E.InnerErrorCodes.REPUBLISHING?Promise.resolve():(p.default.warn("republish - [iceconnection closed], "+t),new Promise((function(t,n){setTimeout((function(){r.republish(e).then(t).catch(n)}),2e3)})))})).catch((function(t){var i;return n!==(null===(i=r.socketManager)||void 0===i?void 0:i.connectId)?Promise.resolve():t.name===E.ErrorCodes.SOCKET_DISCONNECTED||t.name===E.ErrorCodes.NOT_JOIN||t.name===E.InnerErrorCodes.REPUBLISHING?Promise.resolve():(p.default.error("republish2 - [iceconnection closed], "+t),new Promise((function(t,n){setTimeout((function(){r.republish(e).then(t).catch(n)}),4e3)})))})).catch((function(t){p.default.debug("republish3 - [iceconnection closed], "+e.streamId+" "+t),p.default.report("republish3 - [iceconnection closed], "+e.streamId+" "+t)}))},e.prototype.onStreamConnectionReconnecting=function(e){p.default.debug("stream peerconnection reconnecting ",e)},e.prototype.onStreamConnectionReconnected=function(e){var t;p.default.debug("stream peerconnection reconnected ",e),null===(t=this._emitter)||void 0===t||t.emit("stream-reconnected",{previous:e.lastOuterStream,current:e.convertToOuterStream()})},e.prototype.onStreamConnectionDisconnected=function(e){var t;p.default.warn("stream peerconnection disconnected ",e),null===(t=this.socketManager)||void 0===t||t.heartBeat()},e.prototype.enableAudioVolumeIndicator=function(e){var t=this;this.audioVolumeIndicator||(this.audioVolumeIndicator=new _.default(this.streamManager,e)),this.audioVolumeIndicator.start((function(e){var r;null===(r=t._emitter)||void 0===r||r.emit("volume-indicator",e)}),e)},e}();t.SessionManager=w},function(e,t,r){"use strict";var n=r(1),i=r(22),o=r(50),a=r(28);function s(e){var t=new o(e),r=i(o.prototype.request,t);return n.extend(r,o.prototype,t),n.extend(r,t),r}var c=s(r(25));c.Axios=o,c.create=function(e){return s(a(c.defaults,e))},c.Cancel=r(29),c.CancelToken=r(62),c.isCancel=r(24),c.all=function(e){return Promise.all(e)},c.spread=r(63),e.exports=c,e.exports.default=c},function(e,t){ +var n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)};function i(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var o=function(){return(o=Object.assign||function(e){for(var t,r=1,n=arguments.length;r=0;s--)(i=e[s])&&(a=(o<3?i(a):o>3?i(t,r,a):i(t,r))||a);return o>3&&a&&Object.defineProperty(t,r,a),a}function c(e,t){return function(r,n){t(r,n,e)}}function u(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function d(e,t,r,n){return new(r||(r=Promise))((function(i,o){function a(e){try{c(n.next(e))}catch(e){o(e)}}function s(e){try{c(n.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,s)}c((n=n.apply(e,t||[])).next())}))}function f(e,t){var r,n,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,n=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!((i=(i=a.trys).length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function h(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,o=r.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(n=o.next()).done;)a.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return a}function v(){for(var e=[],t=0;t1||s(e,t)}))})}function s(e,t){try{(r=i[e](t)).value instanceof y?Promise.resolve(r.value.v).then(c,u):d(o[0][2],r)}catch(e){d(o[0][3],e)}var r}function c(e){s("next",e)}function u(e){s("throw",e)}function d(e,t){e(t),o.shift(),o.length&&s(o[0][0],o[0][1])}}function b(e){var t,r;return t={},n("next"),n("throw",(function(e){throw e})),n("return"),t[Symbol.iterator]=function(){return this},t;function n(n,i){t[n]=e[n]?function(t){return(r=!r)?{value:y(e[n](t)),done:"return"===n}:i?i(t):t}:i}}function _(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,r=e[Symbol.asyncIterator];return r?r.call(e):(e=m(e),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(r){t[r]=e[r]&&function(t){return new Promise((function(n,i){!function(e,t,r,n){Promise.resolve(n).then((function(t){e({value:t,done:r})}),t)}(n,i,(t=e[r](t)).done,t.value)}))}}}function S(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}function T(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}function w(e){return e&&e.__esModule?e:{default:e}}function R(e,t){if(!t.has(e))throw new TypeError("attempted to get private field on non-instance");return t.get(e)}function M(e,t,r){if(!t.has(e))throw new TypeError("attempted to set private field on non-instance");return t.set(e,r),r}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getLegacyStats=t.getStats=t.CandidatePairLegacyReports=t.CandidatePairReports=t.VideoOutputLegacyReports=t.VideoInputLegacyReports=t.VideoOutputReports=t.VideoInputReports=t.AudioOutputLegacyReports=t.AudioInputLegacyReports=t.AudioOutputReports=t.AudioInputReports=t.Reports=void 0;var n=r(0),i=r(1);Object.defineProperty(t,"Reports",{enumerable:!0,get:function(){return i.Reports}});var o=r(8);Object.defineProperty(t,"AudioInputReports",{enumerable:!0,get:function(){return o.AudioInputReports}}),Object.defineProperty(t,"AudioOutputReports",{enumerable:!0,get:function(){return o.AudioOutputReports}}),Object.defineProperty(t,"AudioInputLegacyReports",{enumerable:!0,get:function(){return o.AudioInputLegacyReports}}),Object.defineProperty(t,"AudioOutputLegacyReports",{enumerable:!0,get:function(){return o.AudioOutputLegacyReports}});var a=r(9);Object.defineProperty(t,"VideoInputReports",{enumerable:!0,get:function(){return a.VideoInputReports}}),Object.defineProperty(t,"VideoOutputReports",{enumerable:!0,get:function(){return a.VideoOutputReports}}),Object.defineProperty(t,"VideoInputLegacyReports",{enumerable:!0,get:function(){return a.VideoInputLegacyReports}}),Object.defineProperty(t,"VideoOutputLegacyReports",{enumerable:!0,get:function(){return a.VideoOutputLegacyReports}});var s=r(10);function c(e){return e.getStats().then((function(e){var t=[];return e.forEach((function(e){var r=new Map;for(var n in e)r.set(n,e[n]);t.push(r)})),t}))}Object.defineProperty(t,"CandidatePairReports",{enumerable:!0,get:function(){return s.CandidatePairReports}}),Object.defineProperty(t,"CandidatePairLegacyReports",{enumerable:!0,get:function(){return s.CandidatePairLegacyReports}}),t.getStats=c,t.getLegacyStats=function(e){return"chrome"!==n.default.browser?Promise.reject(new Error("Only chrome/chromium style browsers can use this function")):new Promise((function(t,r){var n=[];e.getStats((function(e){e.result().forEach((function(e){var t=new Map;t.set("id",e.id),t.set("type",e.type),e.names().forEach((function(r){t.set(r,e.stat(r))})),n.push(t)})),t(n)})).catch(r)}))},t.default=c},function(e,t,r){"use strict";function n(e){return Object.prototype.toString.call(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.isNull=t.isUndefined=void 0,t.isUndefined=function(e){return"[object Undefined]"===n(e)},t.isNull=function(e){return"[object Null]"===n(e)}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parse=void 0;var n=r(6),i=r(7);t.parse=function(e){return e+="",i.isBoolean(e)?i.parseBoolean(e):n.isNumber(e)?n.parseNumber(e):e}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseNumber=t.isNumber=t.isFloat=t.isInt=void 0;var n=/^-?(?:0|[1-9][0-9]*)$/,i=/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/;function o(e){return e+="",n.test(e)}function a(e){return e+="",i.test(e)}t.isInt=o,t.isFloat=a,t.isNumber=function(e){return o(e+="")||a(e)},t.parseNumber=function(e){var t;if(o(e+=""))t=parseInt(e,10);else{if(!a(e))throw new Error("parameter invalid");t=parseFloat(e)}return t}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseBoolean=t.isBoolean=void 0;var n=/^true|false$/;function i(e){return e+="",n.test(e)}t.isBoolean=i,t.parseBoolean=function(e){if(!i(e+=""))throw new Error("parameter invalid");return"true"===e}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AudioOutputLegacyReports=t.AudioInputLegacyReports=t.AudioOutputReports=t.AudioInputReports=void 0;var n=r(2),i=r(0),o=r(1),a=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n.__extends(t,e),Object.defineProperty(t.prototype,"bytesReceived",{get:function(){return this._find("bytesReceived",{type:"inbound-rtp",mediaType:"audio"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"packetsReceived",{get:function(){return this._find("packetsReceived",{type:"inbound-rtp",mediaType:"audio"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"jitter",{get:function(){return this._find("jitter",{type:"inbound-rtp",mediaType:"audio"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"packetsLost",{get:function(){return this._find("packetsLost",{type:"inbound-rtp",mediaType:"audio"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"audioLevel",{get:function(){switch(i.default.browser){case"chrome":return this._find("audioLevel",{type:"track",kind:"audio"});case"safari":return this._find("audioLevel",{type:"track"});default:return this._find("audioLevel")}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"totalAudioEnergy",{get:function(){switch(i.default.browser){case"chrome":return this._find("totalAudioEnergy",{type:"track",kind:"audio"});default:return this._find("totalAudioEnergy")}},enumerable:!1,configurable:!0}),t}(o.Reports);t.AudioInputReports=a;var s=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n.__extends(t,e),Object.defineProperty(t.prototype,"bytesSent",{get:function(){return this._find("bytesSent",{type:"outbound-rtp",mediaType:"audio"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"packetsSent",{get:function(){return this._find("packetsSent",{type:"outbound-rtp",mediaType:"audio"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"jitter",{get:function(){switch(i.default.browser){case"chrome":case"firefox":return this._find("jitter",{type:"remote-inbound-rtp",kind:"audio"});default:return this._find("jitter",{mediaType:"audio"})}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"packetsLost",{get:function(){switch(i.default.browser){case"chrome":case"firefox":return this._find("packetsLost",{type:"remote-inbound-rtp",kind:"audio"});default:return this._find("packetsLost",{mediaType:"audio"})}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"roundTripTime",{get:function(){switch(i.default.browser){case"chrome":case"firefox":return this._find("roundTripTime",{type:"remote-inbound-rtp",kind:"audio"});default:return this._find("roundTripTime",{mediaType:"audio"})}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"audioLevel",{get:function(){switch(i.default.browser){case"chrome":return this._find("audioLevel",{type:"media-source",kind:"audio"});default:return this._find("audioLevel")}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"totalAudioEnergy",{get:function(){switch(i.default.browser){case"chrome":return this._find("totalAudioEnergy",{type:"media-source",kind:"audio"});default:return this._find("totalAudioEnergy")}},enumerable:!1,configurable:!0}),t}(o.Reports);t.AudioOutputReports=s;var c=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n.__extends(t,e),Object.defineProperty(t.prototype,"bytesReceived",{get:function(){return this._find("bytesReceived",{type:"ssrc",mediaType:"audio"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"packetsReceived",{get:function(){return this._find("packetsReceived",{type:"ssrc",mediaType:"audio"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"packetsLost",{get:function(){return this._find("packetsLost",{type:"ssrc",mediaType:"audio"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"audioLevel",{get:function(){return this._find("audioOutputLevel",{type:"ssrc",mediaType:"audio"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"totalAudioEnergy",{get:function(){return this._find("totalAudioEnergy",{type:"ssrc",mediaType:"audio"})},enumerable:!1,configurable:!0}),t}(o.Reports);t.AudioInputLegacyReports=c;var u=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n.__extends(t,e),Object.defineProperty(t.prototype,"bytesSent",{get:function(){return this._find("bytesSent",{type:"ssrc",mediaType:"audio"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"packetsSent",{get:function(){return this._find("packetsSent",{type:"ssrc",mediaType:"audio"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"packetsLost",{get:function(){return this._find("packetsLost",{type:"ssrc",mediaType:"audio"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"roundTripTime",{get:function(){return this._find("googRtt",{type:"ssrc",mediaType:"audio"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"audioLevel",{get:function(){return this._find("audioInputLevel",{type:"ssrc",mediaType:"audio"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"totalAudioEnergy",{get:function(){return this._find("totalAudioEnergy",{type:"ssrc",mediaType:"audio"})},enumerable:!1,configurable:!0}),t}(o.Reports);t.AudioOutputLegacyReports=u},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.VideoOutputLegacyReports=t.VideoInputLegacyReports=t.VideoOutputReports=t.VideoInputReports=void 0;var n=r(2),i=r(0),o=r(1),a=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n.__extends(t,e),Object.defineProperty(t.prototype,"frameWidth",{get:function(){switch(i.default.browser){case"chrome":return this._find("frameWidth",{type:"track",kind:"video"});case"safari":return this._find("frameWidth",{type:"track"});default:return this._find("frameWidth")}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"frameHeight",{get:function(){switch(i.default.browser){case"chrome":return this._find("frameHeight",{type:"track",kind:"video"});case"safari":return this._find("frameHeight",{type:"track"});default:return this._find("frameHeight")}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"framesReceived",{get:function(){switch(i.default.browser){case"chrome":return this._find("framesReceived",{type:"track",kind:"video"});case"safari":return this._find("framesReceived",{type:"track"});default:return this._find("framesReceived")}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"framesDropped",{get:function(){switch(i.default.browser){case"chrome":return this._find("framesDropped",{type:"track",kind:"video"});case"safari":return this._find("framesDropped",{type:"track"});default:return this._find("framesDropped")}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"bytesReceived",{get:function(){return this._find("bytesReceived",{type:"inbound-rtp",mediaType:"video"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"packetsReceived",{get:function(){return this._find("packetsReceived",{type:"inbound-rtp",mediaType:"video"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"packetsLost",{get:function(){return this._find("packetsLost",{type:"inbound-rtp",mediaType:"video"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"nackCount",{get:function(){return this._find("nackCount",{type:"inbound-rtp",mediaType:"video"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"pliCount",{get:function(){return this._find("pliCount",{type:"inbound-rtp",mediaType:"video"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"firCount",{get:function(){return this._find("firCount",{type:"inbound-rtp",mediaType:"video"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"framesDecoded",{get:function(){switch(i.default.browser){case"chrome":return this._find("framesDecoded",{type:"track",kind:"video"});case"firefox":return this._find("framesDecoded",{type:"inbound-rtp",kind:"video"});case"safari":return this._find("framesDecoded",{type:"track"});default:return this._find("framesDecoded")}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"jitter",{get:function(){switch(i.default.browser){case"firefox":return this._find("jitter",{type:"inbound-rtp",kind:"video"});default:return this._find("jitter",{mediaType:"video"})}},enumerable:!1,configurable:!0}),t}(o.Reports);t.VideoInputReports=a;var s=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n.__extends(t,e),Object.defineProperty(t.prototype,"frameWidth",{get:function(){switch(i.default.browser){case"chrome":return this._find("frameWidth",{type:"track",kind:"video"});case"safari":return this._find("frameWidth",{type:"track"});default:return this._find("frameWidth")}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"frameHeight",{get:function(){switch(i.default.browser){case"chrome":return this._find("frameHeight",{type:"track",kind:"video"});case"safari":return this._find("frameHeight",{type:"track"});default:return this._find("frameHeight")}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"bytesSent",{get:function(){return this._find("bytesSent",{type:"outbound-rtp",mediaType:"video"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"packetsSent",{get:function(){return this._find("packetsSent",{type:"outbound-rtp",mediaType:"video"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"nackCount",{get:function(){return this._find("nackCount",{type:"outbound-rtp",mediaType:"video"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"pliCount",{get:function(){return this._find("pliCount",{type:"outbound-rtp",mediaType:"video"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"firCount",{get:function(){return this._find("firCount",{type:"outbound-rtp",mediaType:"video"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"framesEncoded",{get:function(){return this._find("framesEncoded",{type:"outbound-rtp",mediaType:"video"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"packetsLost",{get:function(){switch(i.default.browser){case"chrome":case"firefox":return this._find("packetsLost",{type:"remote-inbound-rtp",kind:"video"});default:return this._find("packetsLost",{mediaType:"video"})}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"jitter",{get:function(){switch(i.default.browser){case"chrome":case"firefox":return this._find("jitter",{type:"remote-inbound-rtp",kind:"video"});default:return this._find("jitter",{mediaType:"video"})}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"roundTripTime",{get:function(){switch(i.default.browser){case"chrome":case"firefox":return this._find("roundTripTime",{type:"remote-inbound-rtp",kind:"video"});default:return this._find("roundTripTime",{mediaType:"video"})}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"framesSent",{get:function(){switch(i.default.browser){case"chrome":return this._find("framesSent",{type:"track",kind:"video"});case"safari":return this._find("framesSent",{type:"track"});default:return this._find("framesSent")}},enumerable:!1,configurable:!0}),t}(o.Reports);t.VideoOutputReports=s;var c=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n.__extends(t,e),Object.defineProperty(t.prototype,"frameWidth",{get:function(){return this._find("googFrameWidthReceived",{type:"ssrc",mediaType:"video"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"frameHeight",{get:function(){return this._find("googFrameHeightReceived",{type:"ssrc",mediaType:"video"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"bytesReceived",{get:function(){return this._find("bytesReceived",{type:"ssrc",mediaType:"video"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"packetsReceived",{get:function(){return this._find("packetsReceived",{type:"ssrc",mediaType:"video"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"packetsLost",{get:function(){return this._find("packetsLost",{type:"ssrc",mediaType:"video"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"nackCount",{get:function(){return this._find("googNacksSent",{type:"ssrc",mediaType:"video"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"pliCount",{get:function(){return this._find("googPlisSent",{type:"ssrc",mediaType:"video"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"firCount",{get:function(){return this._find("googFirsSent",{type:"ssrc",mediaType:"video"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"framesDecoded",{get:function(){return this._find("framesDecoded",{type:"ssrc",mediaType:"video"})},enumerable:!1,configurable:!0}),t}(o.Reports);t.VideoInputLegacyReports=c;var u=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n.__extends(t,e),Object.defineProperty(t.prototype,"frameWidth",{get:function(){return this._find("googFrameWidthSent",{type:"ssrc",mediaType:"video"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"frameHeight",{get:function(){return this._find("googFrameHeightSent",{type:"ssrc",mediaType:"video"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"bytesSent",{get:function(){return this._find("bytesSent",{type:"ssrc",mediaType:"video"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"packetsSent",{get:function(){return this._find("packetsSent",{type:"ssrc",mediaType:"video"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"nackCount",{get:function(){return this._find("googNacksReceived",{type:"ssrc",mediaType:"video"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"pliCount",{get:function(){return this._find("googPlisReceived",{type:"ssrc",mediaType:"video"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"firCount",{get:function(){return this._find("googFirsReceived",{type:"ssrc",mediaType:"video"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"framesEncoded",{get:function(){return this._find("framesEncoded",{type:"ssrc",mediaType:"video"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"packetsLost",{get:function(){return this._find("packetsLost",{type:"ssrc",mediaType:"video"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"roundTripTime",{get:function(){return this._find("googRtt",{type:"ssrc",mediaType:"video"})},enumerable:!1,configurable:!0}),t}(o.Reports);t.VideoOutputLegacyReports=u},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CandidatePairLegacyReports=t.CandidatePairReports=void 0;var n=r(2),i=r(0),o=r(1),a=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n.__extends(t,e),Object.defineProperty(t.prototype,"bytesSent",{get:function(){switch(i.default.browser){case"chrome":case"safari":return this._find("bytesSent",{type:"candidate-pair"});case"firefox":return this._find("bytesSent",{type:"candidate-pair",selected:!0});default:return this._find("bytesSent",{type:"candidate-pair"})}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"bytesReceived",{get:function(){switch(i.default.browser){case"chrome":case"safari":return this._find("bytesReceived",{type:"candidate-pair"});case"firefox":return this._find("bytesReceived",{type:"candidate-pair",selected:!0});default:return this._find("bytesReceived",{type:"candidate-pair"})}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"currentRoundTripTime",{get:function(){switch(i.default.browser){case"chrome":case"safari":default:return this._find("currentRoundTripTime",{type:"candidate-pair"})}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"totalRoundTripTime",{get:function(){switch(i.default.browser){case"chrome":case"safari":default:return this._find("totalRoundTripTime",{type:"candidate-pair"})}},enumerable:!1,configurable:!0}),t}(o.Reports);t.CandidatePairReports=a;var s=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n.__extends(t,e),Object.defineProperty(t.prototype,"bytesReceived",{get:function(){return this._find("bytesReceived",{type:"googCandidatePair"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"bytesSent",{get:function(){return this._find("bytesSent",{type:"googCandidatePair"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"packetsSent",{get:function(){return this._find("packetsSent",{type:"googCandidatePair"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"currentRoundTripTime",{get:function(){return this._find("googRtt",{type:"googCandidatePair"})},enumerable:!1,configurable:!0}),t}(o.Reports);t.CandidatePairLegacyReports=s}])},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(0),i=r(3),o=function(){function e(e,t,r,o){var a=this;void 0===t&&(t=640),void 0===r&&(r=480),void 0===o&&(o=20),this.width=640,this.height=480,this.frameRate=20,this.handleVisibilityChange=function(){document.hidden?(a.interval&&window.clearInterval(a.interval),a.interval=window.setInterval((function(){a.ctx.drawImage(a.image,0,0,a.width,a.height)}),200)):a.interval&&(window.clearInterval(a.interval),a.interval=0)},this.image=e,this.width=t,this.height=r,this.frameRate=o;var s=document.createElement("canvas");if(s.width=this.width,s.height=this.height,this.ctx=s.getContext("2d"),!this.ctx){var c=i.createError(i.ErrorCodes.NOT_SUPPORT,"cannot create canvas context");throw n.default.error(c),c}var u=function(){a.ctx.drawImage(a.image,0,0,a.width,a.height),a.drawTimer=window.requestAnimationFrame(u)};this.drawTimer=window.requestAnimationFrame(u),this.mediaStream=s.captureStream(this.frameRate),document.addEventListener("visibilitychange",this.handleVisibilityChange)}return e.prototype.destroy=function(){document.removeEventListener("visibilitychange",this.handleVisibilityChange),this.drawTimer&&window.cancelAnimationFrame(this.drawTimer),this.interval&&window.clearInterval(this.interval)},e.prototype.clone=function(t,r,n){return void 0===t&&(t=640),void 0===r&&(r=480),void 0===n&&(n=20),new e(this.image,t,r,n)},e}();t.ImageStream=o;var a=function(){function e(e,t){this.mediaStream=new MediaStream,this.mediaStream.addTrack(e),this.resolutionAttributes=t}return Object.defineProperty(e.prototype,"srcVideoTrack",{get:function(){return this.mediaStream.getVideoTracks()[0]},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"dstVideoTrack",{get:function(){return this.mediaStream.getVideoTracks()[0]},enumerable:!0,configurable:!0}),e.prototype.destroy=function(){this.mediaStream.getTracks().forEach((function(e){e.stop()}))},e.prototype.updateResolutionAttributes=function(e){this.resolutionAttributes=e},e.prototype.updateVideoSourceTrack=function(e){var t=this.srcVideoTrack;return t&&e?(this.mediaStream.removeTrack(t),this.mediaStream.addTrack(e)):e&&this.mediaStream.addTrack(e),t},e.prototype.createMediaStreamByImage=function(t){var r=this.srcVideoTrack;if(!r){var o=i.createError(i.ErrorCodes.OTHERS,"no video track");return n.default.error(o),Promise.reject(o)}var a=r.getSettings(),s=a.width||this.resolutionAttributes.videoWidth||640,c=a.height||this.resolutionAttributes.videoHeight||480;return e.createMediaStreamByImage(t,s,c)},e.prototype.createImageStream=function(t){if(!this.srcVideoTrack){var r=i.createError(i.ErrorCodes.OTHERS,"no video track");return Promise.reject(r)}var n=this.resolutionAttributes.videoWidth||640,o=this.resolutionAttributes.videoHeight||480,a=this.resolutionAttributes.maxFrameRate||20;return e.createImageStream(t,n,o,a)},e.getImageByFile=function(t){return new Promise((function(r,o){var a=new FileReader;a.addEventListener("load",(function(t){n.default.debug("file reader loaded ",t),e.getImageByURL(this.result).then(r).catch(o)})),a.addEventListener("error",(function(e){n.default.debug("file reader load error ",e);var t=i.createError(i.ErrorCodes.OTHERS,"file reader load error");o(t)})),a.readAsDataURL(t)}))},e.getImageByURL=function(e){return new Promise((function(t,r){var o=new Image;o.crossOrigin="anonymous",o.addEventListener("load",(function(e){n.default.debug("image loaded ",e),t(this)})),o.addEventListener("error",(function(e){n.default.debug("image load error ",e);var t=i.createError(i.ErrorCodes.OTHERS,"image load error");r(t)})),o.addEventListener("invalid",(function(e){n.default.debug("image load invalid ",e);var t=i.createError(i.ErrorCodes.OTHERS,"image invalid");r(t)})),o.src=e}))},e.createMediaStreamByImage=function(t,r,o){return void 0===r&&(r=640),void 0===o&&(o=480),new Promise((function(a,s){var c=document.createElement("canvas");c.width=r,c.height=o;var u=c.getContext("2d");if(!u){var d=i.createError(i.ErrorCodes.CREATE_STREAM,"cannot create canvas context");return n.default.error(d),void s(d)}if("string"==typeof t)e.getImageByURL(t).then((function(e){u.drawImage(e,0,0,c.width,c.height),a(c.captureStream())})).catch((function(e){s(e)}));else if(t instanceof File)e.getImageByFile(t).then((function(e){u.drawImage(e,0,0,c.width,c.height),a(c.captureStream())})).catch((function(e){s(e)}));else{d=i.createError(i.ErrorCodes.CREATE_STREAM,"file is invalid");s(d)}}))},e.createImageStream=function(t,r,n,a){if(void 0===r&&(r=640),void 0===n&&(n=480),void 0===a&&(a=20),"string"==typeof t)return e.getImageByURL(t).then((function(e){return new o(e,r,n,a)}));if(t instanceof File)return e.getImageByFile(t).then((function(e){return new o(e,r,n,a)}));var s=i.createError(i.ErrorCodes.CREATE_STREAM,"file is invalid");return Promise.reject(s)},e.prototype.snapshot=function(e){var t=this;return new Promise((function(r,o){var a=document.createElement("video");a.autoplay=!0,a.srcObject=t.mediaStream,a.onplay=function(){var t=document.createElement("canvas");t.width=a.videoWidth,t.height=a.videoHeight;var s=t.getContext("2d");if(!s){var c=i.createError(i.ErrorCodes.OTHERS,"cannot create canvas context");return n.default.warn(c),void o(c)}s.drawImage(a,0,0);var u=t.toDataURL("image");if(a.srcObject=null,a.onplay=null,""!==e){var d=document.createElement("a");d.download=e,d.href=u,d.click()}r(u)}}))},e}();t.VideoHelper=a},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n,i,o,a=r(30),s=r(10),c=r(20),u=r(0),d=r(5),f=r(18),p=r(36),l=r(4),m=r(77);!function(e){e[e.join=10]="join",e[e.stats=2]="stats",e[e.leave=3]="leave",e[e.exception=4]="exception",e[e.operation=5]="operation"}(n||(n={})),function(e){e[e.publish=1]="publish",e[e.subscribe=2]="subscribe",e[e.getCameras=3]="getCameras",e[e.getMicrophones=4]="getMicrophones",e[e.getLoudspeakers=5]="getLoudspeakers",e[e.highCPU=6]="highCPU",e[e.highLoss=7]="highLoss",e[e.highDelay=8]="highDelay",e[e.record=9]="record",e[e.storage=10]="storage",e[e.im=11]="im",e[e.whiteboard=12]="whiteboard",e[e.others=13]="others",e[e.joinRoom=14]="joinRoom",e[e.relay=15]="relay"}(i=t.ENUM_LOG_EXCEPTION_TYPE||(t.ENUM_LOG_EXCEPTION_TYPE={})),function(e){e[e.joinRoom=1]="joinRoom",e[e.leaveRoom=2]="leaveRoom",e[e.publish=3]="publish",e[e.unpublish=4]="unpublish",e[e.subscribe=5]="subscribe",e[e.unsubscribe=6]="unsubscribe",e[e.unmuteVideo=7]="unmuteVideo",e[e.muteVideo=8]="muteVideo",e[e.unmuteAudio=9]="unmuteAudio",e[e.muteAudio=10]="muteAudio",e[e.startRecord=11]="startRecord",e[e.stopRecord=12]="stopRecord",e[e.startRelay=13]="startRelay",e[e.stopRelay=14]="stopRelay",e[e.updateMix=15]="updateMix",e[e.updateVP=16]="updateVP"}(o=t.ENUM_LOG_OPERATION_TYPE||(t.ENUM_LOG_OPERATION_TYPE={}));var h=function(){function e(){}return e.prototype.init=function(e,t,r){var n=this;if(this.app_id=e,this.room_id=t,this.user_id=r,u.default.onReport=function(e){n.reportExceptionLog(i.others,{msg:""+e})},l.default.isFirefox()||l.default.isEdge())try{this.reportWorker=new m.InlineWorker((function(){var e=this;this.onmessage=function(t){var r=t.data;!function(t,r){var n=new XMLHttpRequest;n.open("post",t,!0),n.setRequestHeader("Content-Type","application/json;charset=utf-8"),n.setRequestHeader("Accept","application/json, text/plain, */*"),n.responseType="json",n.send(JSON.stringify(r)),n.onreadystatechange=function(){4===n.readyState&&200===n.status&&e.postMessage({response:n.response})}}(r.url,r.content)}})),this.reportWorker.onmessage=function(e){u.default.debug("report worker recive data ",e.data)}}catch(e){u.default.warn("browser not support web worker")}},e.prototype.destroy=function(){var e;this.app_id="",this.room_id="",this.user_id="",null===(e=this.reportWorker)||void 0===e||e.terminate(),u.default.onError=function(){}},Object.defineProperty(e.prototype,"isValid",{get:function(){return!!s.SERVER_CONFIG.log&&!!(this.app_id&&this.room_id&&this.user_id)},enumerable:!0,configurable:!0}),e.prototype.getCommonHeader=function(e,t){return{version:"1.0",method:"logup",rpc_id:p.getId(),type:e,ts:Math.round(Date.now()/1e3),aid:this.app_id,rid:this.room_id,sid:t&&t.sid||"",uid:this.user_id,streamid:t&&t.streamId||"",stype:t&&t.stype||0,mtype:t&&t.mtype||0}},e.prototype.reportJoinRoomLog=function(){if(this.isValid){var e=this.getCommonHeader(n.join),t=l.getDeviceInfo(),r=l.getSystemInfo(),i=l.getCPUInfo(),o={sdkv:f.version,agent:p.getAgent(),device:t.vendor+"_"+t.brand+"_"+t.model,system:""+r.name+r.version+"_"+r.versionName,network:""+l.getNetworkInfo().network,cpu:i.brand+"_"+i.model+"_"+i.core,mem:l.getMemInfo().capacity,micphone:1,speaker:1,video:1},c=new a(s.SERVER_CONFIG.log).set("pathname","api/rtcJoinLeaveClientLog"),u=Object.assign({},e,{data:o});this.report(c,u)}},e.prototype.reportLeaveRoomLog=function(){if(this.isValid){var e=this.getCommonHeader(n.leave),t=new a(s.SERVER_CONFIG.log).set("pathname","api/rtcJoinLeaveClientLog"),r=Object.assign({},e,{data:{sdkv:"",agent:"",device:"",system:"",network:"",cpu:"",mem:0,micphone:0,speaker:0,video:0}});this.report(t,r)}},e.prototype.reportPublishStatusLog=function(e,t,r){if(this.isValid){var i=this.getCommonHeader(n.stats,{streamId:e,stype:d.ENUM_STREAM_TYPE.publish,mtype:t}),o=new a(s.SERVER_CONFIG.log).set("pathname","api/rtcClinetLog"),c=Object.assign({userid:"",streamid:""},r),u=Object.assign({},i,{data:c});this.report(o,u)}},e.prototype.reportSubscribeStatusLog=function(e,t,r,i,o){if(this.isValid){var c=this.getCommonHeader(n.stats,{streamId:e,stype:d.ENUM_STREAM_TYPE.subscribe,mtype:i}),u=new a(s.SERVER_CONFIG.log).set("pathname","api/rtcClinetLog"),f=Object.assign({userid:r||"",streamid:t||""},o),p=Object.assign({},c,{data:f});this.report(u,p)}},e.prototype.reportExceptionLog=function(e,t){if(this.isValid){var r=this.getCommonHeader(n.exception,t),o=new a(s.SERVER_CONFIG.log).set("pathname","api/exceptionLog"),c=Object.assign({},r,{data:{errorType:e,userid:e===i.subscribe&&t&&t.userId||"",streamid:e===i.subscribe&&t&&t.streamId||"",msg:t&&t.msg||""}});this.report(o,c)}},e.prototype.reportOperationLog=function(e,t){if(this.isValid){var r=o,i=[r.subscribe,r.unsubscribe,r.unmuteVideo,r.muteVideo,r.unmuteAudio,r.muteAudio],c=[r.subscribe,r.unsubscribe,r.unmuteVideo,r.muteVideo,r.unmuteAudio,r.muteAudio],u=[r.startRecord,r.stopRecord],d=this.getCommonHeader(n.operation,t),f=new a(s.SERVER_CONFIG.log).set("pathname","api/opertionLog"),p={opertionType:e,userid:i.includes(e)&&t&&t.userId||"",streamid:c.includes(e)&&t&&t.streamId||"",recordid:u.includes(e)&&t&&t.recordId||""};t&&t.msg&&(p.msg=t.msg);var l=Object.assign({},d,{data:p});this.report(f,l)}},e.prototype.report=function(e,t){var r;this.reportWorker?null===(r=this.reportWorker)||void 0===r||r.postMessage({url:e.href,content:t}):c.post({url:e.href,data:t,crossOrigin:!0,needVerifyResponse:!1}).catch((function(e){u.default.warn("report log "+e)}))},e}();t.LogReporter=h},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(4),i=r(37),o=1e7,a="web_"+n.getBrowserInfo().name+n.getBrowserInfo().version,s=o,c=a;t.getAgent=function(){return c},t.setAgent=function(e){c=e},t.resetSeq=function(){s=o},t.getId=function(){return c+"_"+i.formatTime(new Date,"YYYYMMDDHHmmss")+"_"+s++}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.formatTime=function(e,t){void 0===t&&(t="YYYY/MM/DD HH:mm:ss");var r={"M+":e.getMonth()+1,"D+":e.getDate(),"H+":e.getHours(),"m+":e.getMinutes(),"s+":e.getSeconds(),"q+":Math.floor((e.getMonth()+3)/3),S:e.getMilliseconds()};for(var n in/(y+)/i.test(t)&&(t=t.replace(RegExp.$1,(e.getFullYear()+"").substr(4-RegExp.$1.length))),r)new RegExp("("+n+")").test(t)&&(t=t.replace(RegExp.$1,1==RegExp.$1.length?r[n]:("00"+r[n]).substr((""+r[n]).length)));return t}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(2),i=r(0),o=r(14),a=r(17),s=r(34),c=r(5),u=r(16),d=r(3),f=function(e){function t(t,r){var n=e.call(this,r)||this;return n.status=c.ENUM_SUBSCRIBE_STATUS.unsubscribe,n.isSubscriber=!0,n.userId=t.uid,n.streamId=t.sid,n.streamType=c.ENUM_STREAM_TYPE.subscribe,n.mediaType=t.media_type,n.audio=t.audio,n.video=t.video,n.data=t.data,n.muteaudio=t.muteaudio,n.mutevideo=t.mutevideo,n.sourceAudioMuted=t.muteaudio,n.sourceVideoMuted=t.mutevideo,n.audioMuted=!1,n.videoMuted=!1,n}return n.__extends(t,e),Object.defineProperty(t.prototype,"canSubscribe",{get:function(){var e=!0;switch(this.status){case c.ENUM_SUBSCRIBE_STATUS.subscribing:case c.ENUM_SUBSCRIBE_STATUS.unsubscribing:case c.ENUM_SUBSCRIBE_STATUS.subscribed:case c.ENUM_SUBSCRIBE_STATUS.resubscribing:e=!1;break;case c.ENUM_SUBSCRIBE_STATUS.unsubscribe:default:e=!0}return e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"canUnSubscribe",{get:function(){var e=!0;switch(this.status){case c.ENUM_SUBSCRIBE_STATUS.subscribing:case c.ENUM_SUBSCRIBE_STATUS.unsubscribing:case c.ENUM_SUBSCRIBE_STATUS.unsubscribe:case c.ENUM_SUBSCRIBE_STATUS.resubscribing:e=!1;break;case c.ENUM_SUBSCRIBE_STATUS.subscribed:default:e=!0}return e},enumerable:!0,configurable:!0}),t.prototype.initMediaStream=function(){this.mediaStream=new MediaStream},t.prototype.handlePeerConnectionTrackEvent=function(){var e=this;this.peerConnection&&this.peerConnection.addEventListener("track",(function(t){if(i.default.debug("remote - track event ",t),"audio"===t.track.kind){e.audioHelper=new a.AudioHelper(t.track);var r=e.getAudioTrack();r&&e.mediaStream.addTrack(r)}"video"===t.track.kind&&(e.videoHelper=new s.VideoHelper(t.track,e.resolution.attributes),e.mediaStream.addTrack(t.track))}))},t.prototype.connect=function(e){return n.__awaiter(this,void 0,void 0,(function(){var t,r;return n.__generator(this,(function(n){switch(n.label){case 0:this.streamSubId=e,n.label=1;case 1:if(n.trys.push([1,4,,5]),!this.peerConnection)throw new Error("no peerconnection");return[4,this.peerConnection.createOffer({offerToReceiveAudio:this.audio,offerToReceiveVideo:this.video})];case 2:return(t=n.sent()).sdp&&this.video&&this.videoCodec&&(t.sdp=u.handleSDPVideoCodec(t.sdp,this.videoCodec)),t.sdp&&this.audio&&(t.sdp=u.handleSDPAudioCodec(t.sdp)),[4,this.peerConnection.setLocalDescription(t)];case 3:return n.sent(),[2,t];case 4:throw r=n.sent(),i.default.error("peerconnection create offer error "+r),r;case 5:return[2]}}))}))},t.prototype.setStatusAsDone=function(){this.status=c.ENUM_SUBSCRIBE_STATUS.subscribed},t.prototype.close=function(){this.audioMuted=!1,this.videoMuted=!1,this._close(),this.status=c.ENUM_SUBSCRIBE_STATUS.unsubscribe},t.prototype.convertToOuterStream=function(){var e;switch(this.mediaType){case c.ENUM_MEDIA_TYPE.desktop:e="screen";break;case c.ENUM_MEDIA_TYPE.camera:default:e="camera"}return{sid:this.streamId,uid:this.userId,type:"subscribe",mediaType:e,audio:this.audio,video:this.video,muteAudio:this.muteaudio,muteVideo:this.mutevideo,mediaStream:this.status!==c.ENUM_SUBSCRIBE_STATUS.unsubscribe&&this.status!==c.ENUM_SUBSCRIBE_STATUS.unsubscribing?this.mediaStream:void 0,sourceAudioMuted:this.sourceAudioMuted,sourceVideoMuted:this.sourceVideoMuted,audioMuted:this.audioMuted,videoMuted:this.videoMuted}},t.prototype.convertToInnerStream=function(){return{uid:this.userId,sid:this.streamId,streamsub_id:this.streamSubId,stream_type:this.streamType,media_type:this.mediaType,audio:this.audio,video:this.video,data:this.data,muteaudio:this.muteaudio,mutevideo:this.mutevideo}},t.prototype.setAudioVolume=function(e){return this.player?(this.player.setAudioVolume(e),Promise.resolve()):Promise.reject(d.createError(d.ErrorCodes.OTHERS,"stream isn't playing"))},t}(o.RTCStream);t.RemoteStream=f},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(2),i=r(6),o=r(9),a=r(0),s=r(11),c=r(38),u=r(5),d=r(4),f=function(){function e(e,t){var r=this;this.localStreams=[],this.remoteStreams=[],this.innerEmitter=new i.EventEmitter,this.currentResolution=o.getResolution(""),this.audioCodec=e,this.videoCodec=t,this.innerEmitter.on("stream-connected",(function(e){a.default.debug("stream-connected ",e),e.isSubscriber?r._emitter.emit("mediaStreamSubscribed",e):r._emitter.emit("mediaStreamPublished",e)})),this.innerEmitter.on("stream-disconnected",(function(e){a.default.debug("stream-disconnected ",e),r._emitter.emit("streamConnectionDisconnected",e)})),this.innerEmitter.on("stream-reconnected",(function(e){a.default.debug("stream-reconnected ",e),r._emitter.emit("streamConnectionReconnected",e)})),this.innerEmitter.on("stream-failed",(function(e){a.default.debug("stream-failed ",e),r._emitter.emit("streamConnectionClosed",e)})),this.innerEmitter.on("stream-reconnecting",(function(e){a.default.debug("stream-reconnecting ",e),r._emitter.emit("streamConnectionReconnecting",e)})),this.innerEmitter.on("screen-track-ended",(function(e){a.default.debug("screen-track-ended",e),r._emitter.emit("screenMediaStreamEnded",e)})),this.innerEmitter.on("stream-close",(function(e){e.destroyPlayer()})),this.innerEmitter.on("video-muted",(function(e){a.default.debug("video track muted ",e)})),this.innerEmitter.on("video-unmuted",(function(e){a.default.debug("video track unmuted ",e)})),this.innerEmitter.on("stream-paused",(function(e){var t;a.default.debug("stream paused ",e),null===(t=r._emitter)||void 0===t||t.emit("stream-paused",e)})),this.innerEmitter.on("stream-playing",(function(e){var t;a.default.debug("stream playing ",e),null===(t=r._emitter)||void 0===t||t.emit("stream-playing",e)})),this.innerEmitter.on("player-status-change",(function(e){var t;a.default.debug("stream playing ",e),null===(t=r._emitter)||void 0===t||t.emit("player-status-change",e)}))}return Object.defineProperty(e.prototype,"emitter",{set:function(e){this._emitter=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"logReporter",{set:function(e){this._logReporter=e},enumerable:!0,configurable:!0}),e.generatePublishConfig=function(e){var t=e.audio,r=e.video,n=e.facingMode,i=e.screenAudio,o=e.screen,a=e.microphoneId,s=e.cameraId,c=e.extensionId,d={audio:!0,video:!0,screenAudio:!1,screen:!1,mediaType:u.ENUM_MEDIA_TYPE.camera,data:!1};return d.audio=t,d.video=r,n&&(d.facingMode=n),"boolean"==typeof i&&(d.screenAudio=i),d.screen=o,a&&(d.microphoneId=a),s&&(d.cameraId=s),o&&(d.mediaType=u.ENUM_MEDIA_TYPE.desktop),r&&(d.mediaType=u.ENUM_MEDIA_TYPE.camera),c&&(d.extensionId=c),d},e.prototype.getResolution=function(){return this.currentResolution},e.prototype.getLocalStream=function(e){return this.localStreams.find((function(t){return t.streamId===e||t.previewId===e}))},e.prototype.getLocalStreamByPreviewId=function(e){return this.localStreams.find((function(t){return t.previewId===e}))},e.prototype.getAllLocalStreams=function(){return this.localStreams},e.prototype.getRemoteStream=function(e){return this.remoteStreams.find((function(t){return t.streamId===e||t.streamSubId===e}))},e.prototype.getAllRemoteStreams=function(){return this.remoteStreams},e.prototype.getRemoteStreamsByUserId=function(e){return this.remoteStreams.filter((function(t){return t.userId===e}))},e.prototype.getStream=function(e){return this.getLocalStream(e)||this.getRemoteStream(e)},e.prototype.createLocalStream=function(e,t){a.default.debug("create local stream ",e,t);var r=new s.LocalStream(e,t,this.innerEmitter);return r.audioCodec=this.audioCodec,r.videoCodec=this.videoCodec,r.logReporter=this._logReporter,r.setResolution(this.currentResolution),r},e.prototype.addLocalStream=function(e){this.localStreams.push(e)},e.prototype.removeLocalStream=function(e,t){try{var r=this.localStreams.indexOf(e);r>=0&&(this.localStreams.splice(r,1),e.close(t))}catch(e){a.default.error("remove LocalStream failed "+e)}},e.prototype.removeAllLocalStreams=function(){try{this.localStreams.forEach((function(e){e.close()})),this.localStreams=[]}catch(e){a.default.error("clean local streams "+e)}},e.prototype.createRemoteStream=function(e){a.default.debug("create remote stream ",e);var t=this.getRemoteStream(e.sid);if(!t){(t=new c.RemoteStream(e,this.innerEmitter)).audioCodec=this.audioCodec;return/VP8/.test(e.sid)?t.videoCodec="vp8":/H264/.test(e.sid)?t.videoCodec="h264":/H265/.test(e.sid)?t.videoCodec="h265":t.videoCodec=this.videoCodec,t.logReporter=this._logReporter,t.setResolution(this.currentResolution),this.remoteStreams.push(t),t}a.default.error("create remote stream - ","remote stream exists")},e.prototype.removeRemoteStream=function(e){try{var t=this.remoteStreams.indexOf(e);t>=0&&(this.remoteStreams.splice(t,1),e.close())}catch(e){a.default.error("remove RemoteStream failed "+e)}},e.prototype.removeAllRemoteStreams=function(){try{this.remoteStreams.forEach((function(e){e.close()})),this.localStreams=[]}catch(e){a.default.error("clean remote streams "+e)}},e.prototype.setVideoProfile=function(e,t){return n.__awaiter(this,void 0,void 0,(function(){var r;return n.__generator(this,(function(n){switch(n.label){case 0:return r="object"==typeof e?o.getCustomResolution(e):o.getResolution(e),t?(t.setResolution(r),[4,t.applyResolution(r)]):[3,2];case 1:return n.sent(),[3,3];case 2:this.currentResolution=r,n.label=3;case 3:return[2]}}))}))},e.enumerateDevices=function(e,t,r){var i=this;new Promise((function(t,r){return n.__awaiter(i,void 0,void 0,(function(){var i,o,c,d,f,p,l;return n.__generator(this,(function(n){switch(n.label){case 0:return n.trys.push([0,5,,6]),[4,navigator.mediaDevices.enumerateDevices()];case 1:return 0===(i=n.sent()).length?(t(i),[2]):i[0].deviceId||!e.microphone&&!e.camera?[3,4]:(a.default.warn("get blank device information, please allow device permission to try again"),[4,(o=new s.LocalStream("get-devices",{audio:!!e.microphone,video:!!e.camera,screen:!1,mediaType:u.ENUM_MEDIA_TYPE.camera,data:!1})).init({audio:!!e.microphone,video:!!e.camera,screen:!1})]);case 2:return n.sent(),[4,navigator.mediaDevices.enumerateDevices()];case 3:i=n.sent(),o.close(),n.label=4;case 4:return c=0,d=0,f=0,p=i.map((function(e){if(e.label)return e;var t={};switch(["deviceId","groupId","kind"].forEach((function(r){t[r]=e[r]})),e.kind){case"audioinput":t.label="microphone_"+c++;break;case"audiooutput":t.label="speaker_"+d++;break;case"videoinput":t.label="camera_"+f++}return Object.freeze(t)})),t(p),[3,6];case 5:return l=n.sent(),r(l),[3,6];case 6:return[2]}}))}))})).then(t).catch(r)},e.deviceDetection=function(e){var t,r,i=this;if(e.audio){var o={audio:!0,video:!1,screen:!1,data:!1,mediaType:u.ENUM_MEDIA_TYPE.camera,microphoneId:e.microphoneId};t=new s.LocalStream("audioDetection",o)}if(e.video){o={audio:!1,video:!0,screen:!1,data:!1,mediaType:u.ENUM_MEDIA_TYPE.camera,cameraId:e.cameraId};r=new s.LocalStream("videoDetection",o)}return new Promise((function(e){return n.__awaiter(i,void 0,void 0,(function(){var i,o,s;return n.__generator(this,(function(n){switch(n.label){case 0:if(i={audio:!1,video:!1},!t)return[3,6];n.label=1;case 1:return n.trys.push([1,4,,5]),[4,t.initMediaStream()];case 2:return n.sent(),[4,t.addTracks2MediaStream()];case 3:return n.sent(),i.audio=!0,[3,5];case 4:return o=n.sent(),a.default.warn("audio input device invalid ",o),i.audioError=o.message,[3,5];case 5:try{t.close()}catch(e){a.default.warn("audio input device invalid ",e),i.audioError=e.message}n.label=6;case 6:if(!r)return[3,12];n.label=7;case 7:return n.trys.push([7,10,,11]),[4,r.initMediaStream()];case 8:return n.sent(),[4,r.addTracks2MediaStream()];case 9:return n.sent(),i.video=!0,[3,11];case 10:return s=n.sent(),a.default.warn("video input device invalid ",s),i.videoError=s.message,[3,11];case 11:try{r.close()}catch(e){a.default.warn("video input device invalid ",e),i.videoError=e.message}n.label=12;case 12:return e(i),[2]}}))}))}))},e.getSupportedCodec=function(){return n.__awaiter(this,void 0,void 0,(function(){var e,t,r,i,o;return n.__generator(this,(function(n){switch(n.label){case 0:t={video:[],audio:[]};try{if(d.default.isChrome()){r=80;try{r=parseInt(d.getBrowserInfo().version,10)}catch(e){r=79}i={sdpSemantics:"plan-b"},r>=80&&(i={sdpSemantics:"unified-plan"}),e=new RTCPeerConnection(i)}else d.default.isSafari()||d.default.isOldEdge()?(i={bundlePolicy:"max-bundle"},e=new RTCPeerConnection(i)):e=new RTCPeerConnection}catch(e){return a.default.error("get supported codec "+e),[2,t]}return[4,e.createOffer({offerToReceiveAudio:!0,offerToReceiveVideo:!0})];case 1:return o=n.sent(),e.close(),o.sdp&&(o.sdp.match(/ vp8/i)&&t.video.push("vp8"),o.sdp.match(/ h264/i)&&t.video.push("h264"),o.sdp.match(/ h265/i)&&t.video.push("h265"),o.sdp.match(/ opus/i)&&t.audio.push("opus")),[2,t]}}))}))},e.isSupportWebRTC=function(){var e=d.getSystemInfo(),t=d.getBrowserInfo();if(/windows/i.test(e.name)&&/wechat/i.test(t.name))return!1;var r=window.RTCPeerConnection||window.mozRTCPeerConnection||window.webkitRTCPeerConnection,n=navigator&&(navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.msGetUserMedia||navigator.mozGetUserMedia||navigator.mediaDevices&&navigator.mediaDevices.getUserMedia),i=window.WebSocket;return!!r&&!!n&&!!i},e}();t.StreamManager=f},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(79),i=r(80),o=r(81);function a(e,t,r,a){var s=e,c=t,u=r,d=a,f=n.Base64.encode(JSON.stringify({user_id:d,room_id:u,app_id:s})),p=Math.round(Date.now()/1e3),l=o.randNum(8),m=d+s+p+l+u,h=new i("SHA-1","TEXT");return h.setHMACKey(c,"TEXT"),h.update(m),f+"."+h.getHMAC("HEX")+p+l}function s(e){return JSON.parse(n.Base64.decode(e))}function c(e){return n.Base64.encode(JSON.stringify(e))}t.genToken=a,t.decode=s,t.encode=c;var u={genToken:a,decode:s,encode:c};t.default=u},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.convertToOuterUser=function(e){return{uid:e.user_id}}},function(e,t,r){"use strict";var n=r(7);function i(e,t,r,i,o){var a=n.writeRtpDescription(e.kind,t);if(a+=n.writeIceParameters(e.iceGatherer.getLocalParameters()),a+=n.writeDtlsParameters(e.dtlsTransport.getLocalParameters(),"offer"===r?"actpass":o||"active"),a+="a=mid:"+e.mid+"\r\n",e.rtpSender&&e.rtpReceiver?a+="a=sendrecv\r\n":e.rtpSender?a+="a=sendonly\r\n":e.rtpReceiver?a+="a=recvonly\r\n":a+="a=inactive\r\n",e.rtpSender){var s=e.rtpSender._initialTrackId||e.rtpSender.track.id;e.rtpSender._initialTrackId=s;var c="msid:"+(i?i.id:"-")+" "+s+"\r\n";a+="a="+c,a+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" "+c,e.sendEncodingParameters[0].rtx&&(a+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" "+c,a+="a=ssrc-group:FID "+e.sendEncodingParameters[0].ssrc+" "+e.sendEncodingParameters[0].rtx.ssrc+"\r\n")}return a+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" cname:"+n.localCName+"\r\n",e.rtpSender&&e.sendEncodingParameters[0].rtx&&(a+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" cname:"+n.localCName+"\r\n"),a}function o(e,t){var r={codecs:[],headerExtensions:[],fecMechanisms:[]},n=function(e,t){e=parseInt(e,10);for(var r=0;r=14393&&-1===e.indexOf("?transport=udp")})),delete e.url,e.urls=i?n[0]:n,!!n.length}}))}(r.iceServers||[],t),this._iceGatherers=[],r.iceCandidatePoolSize)for(var a=r.iceCandidatePoolSize;a>0;a--)this._iceGatherers.push(new e.RTCIceGatherer({iceServers:r.iceServers,gatherPolicy:r.iceTransportPolicy}));else r.iceCandidatePoolSize=0;this._config=r,this.transceivers=[],this._sdpSessionId=n.generateSessionId(),this._sdpSessionVersion=0,this._dtlsRole=void 0,this._isClosed=!1};Object.defineProperty(d.prototype,"localDescription",{configurable:!0,get:function(){return this._localDescription}}),Object.defineProperty(d.prototype,"remoteDescription",{configurable:!0,get:function(){return this._remoteDescription}}),d.prototype.onicecandidate=null,d.prototype.onaddstream=null,d.prototype.ontrack=null,d.prototype.onremovestream=null,d.prototype.onsignalingstatechange=null,d.prototype.oniceconnectionstatechange=null,d.prototype.onconnectionstatechange=null,d.prototype.onicegatheringstatechange=null,d.prototype.onnegotiationneeded=null,d.prototype.ondatachannel=null,d.prototype._dispatchEvent=function(e,t){this._isClosed||(this.dispatchEvent(t),"function"==typeof this["on"+e]&&this["on"+e](t))},d.prototype._emitGatheringStateChange=function(){var e=new Event("icegatheringstatechange");this._dispatchEvent("icegatheringstatechange",e)},d.prototype.getConfiguration=function(){return this._config},d.prototype.getLocalStreams=function(){return this.localStreams},d.prototype.getRemoteStreams=function(){return this.remoteStreams},d.prototype._createTransceiver=function(e,t){var r=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,associatedRemoteMediaStreams:[],wantReceive:!0};if(this.usingBundle&&r)n.iceTransport=this.transceivers[0].iceTransport,n.dtlsTransport=this.transceivers[0].dtlsTransport;else{var i=this._createIceAndDtlsTransports();n.iceTransport=i.iceTransport,n.dtlsTransport=i.dtlsTransport}return t||this.transceivers.push(n),n},d.prototype.addTrack=function(t,r){if(this._isClosed)throw c("InvalidStateError","Attempted to call addTrack on a closed peerconnection.");var n;if(this.transceivers.find((function(e){return e.track===t})))throw c("InvalidAccessError","Track already exists.");for(var i=0;i=15025)e.getTracks().forEach((function(t){r.addTrack(t,e)}));else{var n=e.clone();e.getTracks().forEach((function(e,t){var r=n.getTracks()[t];e.addEventListener("enabled",(function(e){r.enabled=e.enabled}))})),n.getTracks().forEach((function(e){r.addTrack(e,n)}))}},d.prototype.removeTrack=function(t){if(this._isClosed)throw c("InvalidStateError","Attempted to call removeTrack on a closed peerconnection.");if(!(t instanceof e.RTCRtpSender))throw new TypeError("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.");var r=this.transceivers.find((function(e){return e.rtpSender===t}));if(!r)throw c("InvalidAccessError","Sender was not created by this connection.");var n=r.stream;r.rtpSender.stop(),r.rtpSender=null,r.track=null,r.stream=null,-1===this.transceivers.map((function(e){return e.stream})).indexOf(n)&&this.localStreams.indexOf(n)>-1&&this.localStreams.splice(this.localStreams.indexOf(n),1),this._maybeFireNegotiationNeeded()},d.prototype.removeStream=function(e){var t=this;e.getTracks().forEach((function(e){var r=t.getSenders().find((function(t){return t.track===e}));r&&t.removeTrack(r)}))},d.prototype.getSenders=function(){return this.transceivers.filter((function(e){return!!e.rtpSender})).map((function(e){return e.rtpSender}))},d.prototype.getReceivers=function(){return this.transceivers.filter((function(e){return!!e.rtpReceiver})).map((function(e){return e.rtpReceiver}))},d.prototype._createIceGatherer=function(t,r){var n=this;if(r&&t>0)return this.transceivers[0].iceGatherer;if(this._iceGatherers.length)return this._iceGatherers.shift();var i=new e.RTCIceGatherer({iceServers:this._config.iceServers,gatherPolicy:this._config.iceTransportPolicy});return Object.defineProperty(i,"state",{value:"new",writable:!0}),this.transceivers[t].bufferedCandidateEvents=[],this.transceivers[t].bufferCandidates=function(e){var r=!e.candidate||0===Object.keys(e.candidate).length;i.state=r?"completed":"gathering",null!==n.transceivers[t].bufferedCandidateEvents&&n.transceivers[t].bufferedCandidateEvents.push(e)},i.addEventListener("localcandidate",this.transceivers[t].bufferCandidates),i},d.prototype._gather=function(t,r){var i=this,o=this.transceivers[r].iceGatherer;if(!o.onlocalcandidate){var a=this.transceivers[r].bufferedCandidateEvents;this.transceivers[r].bufferedCandidateEvents=null,o.removeEventListener("localcandidate",this.transceivers[r].bufferCandidates),o.onlocalcandidate=function(e){if(!(i.usingBundle&&r>0)){var a=new Event("icecandidate");a.candidate={sdpMid:t,sdpMLineIndex:r};var s=e.candidate,c=!s||0===Object.keys(s).length;if(c)"new"!==o.state&&"gathering"!==o.state||(o.state="completed");else{"new"===o.state&&(o.state="gathering"),s.component=1,s.ufrag=o.getLocalParameters().usernameFragment;var u=n.writeCandidate(s);a.candidate=Object.assign(a.candidate,n.parseCandidate(u)),a.candidate.candidate=u,a.candidate.toJSON=function(){return{candidate:a.candidate.candidate,sdpMid:a.candidate.sdpMid,sdpMLineIndex:a.candidate.sdpMLineIndex,usernameFragment:a.candidate.usernameFragment}}}var d=n.getMediaSections(i._localDescription.sdp);d[a.candidate.sdpMLineIndex]+=c?"a=end-of-candidates\r\n":"a="+a.candidate.candidate+"\r\n",i._localDescription.sdp=n.getDescription(i._localDescription.sdp)+d.join("");var f=i.transceivers.every((function(e){return e.iceGatherer&&"completed"===e.iceGatherer.state}));"gathering"!==i.iceGatheringState&&(i.iceGatheringState="gathering",i._emitGatheringStateChange()),c||i._dispatchEvent("icecandidate",a),f&&(i._dispatchEvent("icecandidate",new Event("icecandidate")),i.iceGatheringState="complete",i._emitGatheringStateChange())}},e.setTimeout((function(){a.forEach((function(e){o.onlocalcandidate(e)}))}),0)}},d.prototype._createIceAndDtlsTransports=function(){var t=this,r=new e.RTCIceTransport(null);r.onicestatechange=function(){t._updateIceConnectionState(),t._updateConnectionState()};var n=new e.RTCDtlsTransport(r);return n.ondtlsstatechange=function(){t._updateConnectionState()},n.onerror=function(){Object.defineProperty(n,"state",{value:"failed",writable:!0}),t._updateConnectionState()},{iceTransport:r,dtlsTransport:n}},d.prototype._disposeIceAndDtlsTransports=function(e){var t=this.transceivers[e].iceGatherer;t&&(delete t.onlocalcandidate,delete this.transceivers[e].iceGatherer);var r=this.transceivers[e].iceTransport;r&&(delete r.onicestatechange,delete this.transceivers[e].iceTransport);var n=this.transceivers[e].dtlsTransport;n&&(delete n.ondtlsstatechange,delete n.onerror,delete this.transceivers[e].dtlsTransport)},d.prototype._transceive=function(e,r,i){var a=o(e.localCapabilities,e.remoteCapabilities);r&&e.rtpSender&&(a.encodings=e.sendEncodingParameters,a.rtcp={cname:n.localCName,compound:e.rtcpParameters.compound},e.recvEncodingParameters.length&&(a.rtcp.ssrc=e.recvEncodingParameters[0].ssrc),e.rtpSender.send(a)),i&&e.rtpReceiver&&a.codecs.length>0&&("video"===e.kind&&e.recvEncodingParameters&&t<15019&&e.recvEncodingParameters.forEach((function(e){delete e.rtx})),e.recvEncodingParameters.length?a.encodings=e.recvEncodingParameters:a.encodings=[{}],a.rtcp={compound:e.rtcpParameters.compound},e.rtcpParameters.cname&&(a.rtcp.cname=e.rtcpParameters.cname),e.sendEncodingParameters.length&&(a.rtcp.ssrc=e.sendEncodingParameters[0].ssrc),e.rtpReceiver.receive(a))},d.prototype.setLocalDescription=function(e){var t,r,i=this;if(-1===["offer","answer"].indexOf(e.type))return Promise.reject(c("TypeError",'Unsupported type "'+e.type+'"'));if(!a("setLocalDescription",e.type,i.signalingState)||i._isClosed)return Promise.reject(c("InvalidStateError","Can not set local "+e.type+" in state "+i.signalingState));if("offer"===e.type)t=n.splitSections(e.sdp),r=t.shift(),t.forEach((function(e,t){var r=n.parseRtpParameters(e);i.transceivers[t].localCapabilities=r})),i.transceivers.forEach((function(e,t){i._gather(e.mid,t)}));else if("answer"===e.type){t=n.splitSections(i._remoteDescription.sdp),r=t.shift();var s=n.matchPrefix(r,"a=ice-lite").length>0;t.forEach((function(e,t){var a=i.transceivers[t],c=a.iceGatherer,u=a.iceTransport,d=a.dtlsTransport,f=a.localCapabilities,p=a.remoteCapabilities;if(!(n.isRejected(e)&&0===n.matchPrefix(e,"a=bundle-only").length)&&!a.rejected){var l=n.getIceParameters(e,r),m=n.getDtlsParameters(e,r);s&&(m.role="server"),i.usingBundle&&0!==t||(i._gather(a.mid,t),"new"===u.state&&u.start(c,l,s?"controlling":"controlled"),"new"===d.state&&d.start(m));var h=o(f,p);i._transceive(a,h.codecs.length>0,!1)}}))}return i._localDescription={type:e.type,sdp:e.sdp},"offer"===e.type?i._updateSignalingState("have-local-offer"):i._updateSignalingState("stable"),Promise.resolve()},d.prototype.setRemoteDescription=function(i){var d=this;if(-1===["offer","answer"].indexOf(i.type))return Promise.reject(c("TypeError",'Unsupported type "'+i.type+'"'));if(!a("setRemoteDescription",i.type,d.signalingState)||d._isClosed)return Promise.reject(c("InvalidStateError","Can not set remote "+i.type+" in state "+d.signalingState));var f={};d.remoteStreams.forEach((function(e){f[e.id]=e}));var p=[],l=n.splitSections(i.sdp),m=l.shift(),h=n.matchPrefix(m,"a=ice-lite").length>0,v=n.matchPrefix(m,"a=group:BUNDLE ").length>0;d.usingBundle=v;var g=n.matchPrefix(m,"a=ice-options:")[0];return d.canTrickleIceCandidates=!!g&&g.substr(14).split(" ").indexOf("trickle")>=0,l.forEach((function(a,c){var u=n.splitLines(a),l=n.getKind(a),g=n.isRejected(a)&&0===n.matchPrefix(a,"a=bundle-only").length,y=u[0].substr(2).split(" ")[2],E=n.getDirection(a,m),b=n.parseMsid(a),_=n.getMid(a)||n.generateIdentifier();if(g||"application"===l&&("DTLS/SCTP"===y||"UDP/DTLS/SCTP"===y))d.transceivers[c]={mid:_,kind:l,protocol:y,rejected:!0};else{var S,T,w,R,M,C,P,O,I;!g&&d.transceivers[c]&&d.transceivers[c].rejected&&(d.transceivers[c]=d._createTransceiver(l,!0));var A,k,N=n.parseRtpParameters(a);g||(A=n.getIceParameters(a,m),(k=n.getDtlsParameters(a,m)).role="client"),P=n.parseRtpEncodingParameters(a);var U=n.parseRtcpParameters(a),L=n.matchPrefix(a,"a=end-of-candidates",m).length>0,x=n.matchPrefix(a,"a=candidate:").map((function(e){return n.parseCandidate(e)})).filter((function(e){return 1===e.component}));if(("offer"===i.type||"answer"===i.type)&&!g&&v&&c>0&&d.transceivers[c]&&(d._disposeIceAndDtlsTransports(c),d.transceivers[c].iceGatherer=d.transceivers[0].iceGatherer,d.transceivers[c].iceTransport=d.transceivers[0].iceTransport,d.transceivers[c].dtlsTransport=d.transceivers[0].dtlsTransport,d.transceivers[c].rtpSender&&d.transceivers[c].rtpSender.setTransport(d.transceivers[0].dtlsTransport),d.transceivers[c].rtpReceiver&&d.transceivers[c].rtpReceiver.setTransport(d.transceivers[0].dtlsTransport)),"offer"!==i.type||g){if("answer"===i.type&&!g){T=(S=d.transceivers[c]).iceGatherer,w=S.iceTransport,R=S.dtlsTransport,M=S.rtpReceiver,C=S.sendEncodingParameters,O=S.localCapabilities,d.transceivers[c].recvEncodingParameters=P,d.transceivers[c].remoteCapabilities=N,d.transceivers[c].rtcpParameters=U,x.length&&"new"===w.state&&(!h&&!L||v&&0!==c?x.forEach((function(e){s(S.iceTransport,e)})):w.setRemoteCandidates(x)),v&&0!==c||("new"===w.state&&w.start(T,A,"controlling"),"new"===R.state&&R.start(k)),!o(S.localCapabilities,S.remoteCapabilities).codecs.filter((function(e){return"rtx"===e.name.toLowerCase()})).length&&S.sendEncodingParameters[0].rtx&&delete S.sendEncodingParameters[0].rtx,d._transceive(S,"sendrecv"===E||"recvonly"===E,"sendrecv"===E||"sendonly"===E),!M||"sendrecv"!==E&&"sendonly"!==E?delete S.rtpReceiver:(I=M.track,b?(f[b.stream]||(f[b.stream]=new e.MediaStream),r(I,f[b.stream]),p.push([I,M,f[b.stream]])):(f.default||(f.default=new e.MediaStream),r(I,f.default),p.push([I,M,f.default])))}}else{(S=d.transceivers[c]||d._createTransceiver(l)).mid=_,S.iceGatherer||(S.iceGatherer=d._createIceGatherer(c,v)),x.length&&"new"===S.iceTransport.state&&(!L||v&&0!==c?x.forEach((function(e){s(S.iceTransport,e)})):S.iceTransport.setRemoteCandidates(x)),O=e.RTCRtpReceiver.getCapabilities(l),t<15019&&(O.codecs=O.codecs.filter((function(e){return"rtx"!==e.name}))),C=S.sendEncodingParameters||[{ssrc:1001*(2*c+2)}];var j,D=!1;if("sendrecv"===E||"sendonly"===E){if(D=!S.rtpReceiver,M=S.rtpReceiver||new e.RTCRtpReceiver(S.dtlsTransport,l),D)I=M.track,b&&"-"===b.stream||(b?(f[b.stream]||(f[b.stream]=new e.MediaStream,Object.defineProperty(f[b.stream],"id",{get:function(){return b.stream}})),Object.defineProperty(I,"id",{get:function(){return b.track}}),j=f[b.stream]):(f.default||(f.default=new e.MediaStream),j=f.default)),j&&(r(I,j),S.associatedRemoteMediaStreams.push(j)),p.push([I,M,j])}else S.rtpReceiver&&S.rtpReceiver.track&&(S.associatedRemoteMediaStreams.forEach((function(t){var r=t.getTracks().find((function(e){return e.id===S.rtpReceiver.track.id}));r&&function(t,r){r.removeTrack(t),r.dispatchEvent(new e.MediaStreamTrackEvent("removetrack",{track:t}))}(r,t)})),S.associatedRemoteMediaStreams=[]);S.localCapabilities=O,S.remoteCapabilities=N,S.rtpReceiver=M,S.rtcpParameters=U,S.sendEncodingParameters=C,S.recvEncodingParameters=P,d._transceive(d.transceivers[c],!1,D)}}})),void 0===d._dtlsRole&&(d._dtlsRole="offer"===i.type?"active":"passive"),d._remoteDescription={type:i.type,sdp:i.sdp},"offer"===i.type?d._updateSignalingState("have-remote-offer"):d._updateSignalingState("stable"),Object.keys(f).forEach((function(t){var r=f[t];if(r.getTracks().length){if(-1===d.remoteStreams.indexOf(r)){d.remoteStreams.push(r);var n=new Event("addstream");n.stream=r,e.setTimeout((function(){d._dispatchEvent("addstream",n)}))}p.forEach((function(e){var t=e[0],n=e[1];r.id===e[2].id&&u(d,t,n,[r])}))}})),p.forEach((function(e){e[2]||u(d,e[0],e[1],[])})),e.setTimeout((function(){d&&d.transceivers&&d.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),Promise.resolve()},d.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._isClosed=!0,this._updateSignalingState("closed")},d.prototype._updateSignalingState=function(e){this.signalingState=e;var t=new Event("signalingstatechange");this._dispatchEvent("signalingstatechange",t)},d.prototype._maybeFireNegotiationNeeded=function(){var t=this;"stable"===this.signalingState&&!0!==this.needNegotiation&&(this.needNegotiation=!0,e.setTimeout((function(){if(t.needNegotiation){t.needNegotiation=!1;var e=new Event("negotiationneeded");t._dispatchEvent("negotiationneeded",e)}}),0))},d.prototype._updateIceConnectionState=function(){var e,t={new:0,closed:0,checking:0,connected:0,completed:0,disconnected:0,failed:0};if(this.transceivers.forEach((function(e){e.iceTransport&&!e.rejected&&t[e.iceTransport.state]++})),e="new",t.failed>0?e="failed":t.checking>0?e="checking":t.disconnected>0?e="disconnected":t.new>0?e="new":t.connected>0?e="connected":t.completed>0&&(e="completed"),e!==this.iceConnectionState){this.iceConnectionState=e;var r=new Event("iceconnectionstatechange");this._dispatchEvent("iceconnectionstatechange",r)}},d.prototype._updateConnectionState=function(){var e,t={new:0,closed:0,connecting:0,connected:0,completed:0,disconnected:0,failed:0};if(this.transceivers.forEach((function(e){e.iceTransport&&e.dtlsTransport&&!e.rejected&&(t[e.iceTransport.state]++,t[e.dtlsTransport.state]++)})),t.connected+=t.completed,e="new",t.failed>0?e="failed":t.connecting>0?e="connecting":t.disconnected>0?e="disconnected":t.new>0?e="new":t.connected>0&&(e="connected"),e!==this.connectionState){this.connectionState=e;var r=new Event("connectionstatechange");this._dispatchEvent("connectionstatechange",r)}},d.prototype.createOffer=function(){var r=this;if(r._isClosed)return Promise.reject(c("InvalidStateError","Can not call createOffer after close"));var o=r.transceivers.filter((function(e){return"audio"===e.kind})).length,a=r.transceivers.filter((function(e){return"video"===e.kind})).length,s=arguments[0];if(s){if(s.mandatory||s.optional)throw new TypeError("Legacy mandatory/optional constraints not supported.");void 0!==s.offerToReceiveAudio&&(o=!0===s.offerToReceiveAudio?1:!1===s.offerToReceiveAudio?0:s.offerToReceiveAudio),void 0!==s.offerToReceiveVideo&&(a=!0===s.offerToReceiveVideo?1:!1===s.offerToReceiveVideo?0:s.offerToReceiveVideo)}for(r.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&&(r._createTransceiver("audio"),o--),a>0&&(r._createTransceiver("video"),a--);var u=n.writeSessionBoilerplate(r._sdpSessionId,r._sdpSessionVersion++);r.transceivers.forEach((function(i,o){var a=i.track,s=i.kind,c=i.mid||n.generateIdentifier();i.mid=c,i.iceGatherer||(i.iceGatherer=r._createIceGatherer(o,r.usingBundle));var u=e.RTCRtpSender.getCapabilities(s);t<15019&&(u.codecs=u.codecs.filter((function(e){return"rtx"!==e.name}))),u.codecs.forEach((function(e){"H264"===e.name&&void 0===e.parameters["level-asymmetry-allowed"]&&(e.parameters["level-asymmetry-allowed"]="1"),i.remoteCapabilities&&i.remoteCapabilities.codecs&&i.remoteCapabilities.codecs.forEach((function(t){e.name.toLowerCase()===t.name.toLowerCase()&&e.clockRate===t.clockRate&&(e.preferredPayloadType=t.payloadType)}))})),u.headerExtensions.forEach((function(e){(i.remoteCapabilities&&i.remoteCapabilities.headerExtensions||[]).forEach((function(t){e.uri===t.uri&&(e.id=t.id)}))}));var d=i.sendEncodingParameters||[{ssrc:1001*(2*o+1)}];a&&t>=15019&&"video"===s&&!d[0].rtx&&(d[0].rtx={ssrc:d[0].ssrc+1}),i.wantReceive&&(i.rtpReceiver=new e.RTCRtpReceiver(i.dtlsTransport,s)),i.localCapabilities=u,i.sendEncodingParameters=d})),"max-compat"!==r._config.bundlePolicy&&(u+="a=group:BUNDLE "+r.transceivers.map((function(e){return e.mid})).join(" ")+"\r\n"),u+="a=ice-options:trickle\r\n",r.transceivers.forEach((function(e,t){u+=i(e,e.localCapabilities,"offer",e.stream,r._dtlsRole),u+="a=rtcp-rsize\r\n",!e.iceGatherer||"new"===r.iceGatheringState||0!==t&&r.usingBundle||(e.iceGatherer.getLocalCandidates().forEach((function(e){e.component=1,u+="a="+n.writeCandidate(e)+"\r\n"})),"completed"===e.iceGatherer.state&&(u+="a=end-of-candidates\r\n"))}));var d=new e.RTCSessionDescription({type:"offer",sdp:u});return Promise.resolve(d)},d.prototype.createAnswer=function(){var r=this;if(r._isClosed)return Promise.reject(c("InvalidStateError","Can not call createAnswer after close"));if("have-remote-offer"!==r.signalingState&&"have-local-pranswer"!==r.signalingState)return Promise.reject(c("InvalidStateError","Can not call createAnswer in signalingState "+r.signalingState));var a=n.writeSessionBoilerplate(r._sdpSessionId,r._sdpSessionVersion++);r.usingBundle&&(a+="a=group:BUNDLE "+r.transceivers.map((function(e){return e.mid})).join(" ")+"\r\n"),a+="a=ice-options:trickle\r\n";var s=n.getMediaSections(r._remoteDescription.sdp).length;r.transceivers.forEach((function(e,n){if(!(n+1>s)){if(e.rejected)return"application"===e.kind?"DTLS/SCTP"===e.protocol?a+="m=application 0 DTLS/SCTP 5000\r\n":a+="m=application 0 "+e.protocol+" webrtc-datachannel\r\n":"audio"===e.kind?a+="m=audio 0 UDP/TLS/RTP/SAVPF 0\r\na=rtpmap:0 PCMU/8000\r\n":"video"===e.kind&&(a+="m=video 0 UDP/TLS/RTP/SAVPF 120\r\na=rtpmap:120 VP8/90000\r\n"),void(a+="c=IN IP4 0.0.0.0\r\na=inactive\r\na=mid:"+e.mid+"\r\n");var c;if(e.stream)"audio"===e.kind?c=e.stream.getAudioTracks()[0]:"video"===e.kind&&(c=e.stream.getVideoTracks()[0]),c&&t>=15019&&"video"===e.kind&&!e.sendEncodingParameters[0].rtx&&(e.sendEncodingParameters[0].rtx={ssrc:e.sendEncodingParameters[0].ssrc+1});var u=o(e.localCapabilities,e.remoteCapabilities);!u.codecs.filter((function(e){return"rtx"===e.name.toLowerCase()})).length&&e.sendEncodingParameters[0].rtx&&delete e.sendEncodingParameters[0].rtx,a+=i(e,u,"answer",e.stream,r._dtlsRole),e.rtcpParameters&&e.rtcpParameters.reducedSize&&(a+="a=rtcp-rsize\r\n")}}));var u=new e.RTCSessionDescription({type:"answer",sdp:a});return Promise.resolve(u)},d.prototype.addIceCandidate=function(e){var t,r=this;return e&&void 0===e.sdpMLineIndex&&!e.sdpMid?Promise.reject(new TypeError("sdpMLineIndex or sdpMid required")):new Promise((function(i,o){if(!r._remoteDescription)return o(c("InvalidStateError","Can not add ICE candidate without a remote description"));if(e&&""!==e.candidate){var a=e.sdpMLineIndex;if(e.sdpMid)for(var u=0;u0?n.parseCandidate(e.candidate):{};if("tcp"===f.protocol&&(0===f.port||9===f.port))return i();if(f.component&&1!==f.component)return i();if((0===a||a>0&&d.iceTransport!==r.transceivers[0].iceTransport)&&!s(d.iceTransport,f))return o(c("OperationError","Can not add ICE candidate"));var p=e.candidate.trim();0===p.indexOf("a=")&&(p=p.substr(2)),(t=n.getMediaSections(r._remoteDescription.sdp))[a]+="a="+(f.type?p:"end-of-candidates")+"\r\n",r._remoteDescription.sdp=n.getDescription(r._remoteDescription.sdp)+t.join("")}else for(var l=0;l=200&&o.enableAudioVolumeIndicator(o.audioVolumeIndicatorInterval)),r&&r(e,t)}),(function(e){o.sessionManager=void 0,n&&n(l.createError(l.ErrorCodes.OTHERS,e))}))}))},e.prototype.leaveRoom=function(e,t,r){var n,o=this;if("function"==typeof e?(r=t,t=e,n={keepRecording:!1}):n=e?{keepRecording:!!e.keepRecording}:{keepRecording:!1},"function"!=typeof t&&(t=function(){}),"function"!=typeof r&&(r=function(){}),!this.sessionManager){var a="please join room first";return i.default.warn(a),void r(l.createError(l.ErrorCodes.NOT_JOIN,a))}if(this.sessionManager.isDestroyed)return this.sessionManager=void 0,void t();this.sessionManager.leaveRoom(n,(function(e){i.default.debug(e," leave room"),o.sessionManager=void 0,t&&t()}),r)},e.prototype.publish=function(e,t){var r=this;if("function"!=typeof t&&(t=function(){}),!this.sessionManager){var n="please join room first";return i.default.warn(n),void t(l.createError(l.ErrorCodes.NOT_JOIN,n))}if(e&&f.streamValidator.isValidStreamId(e.previewId)){var o=e.previewId,a=this.previewStreamManager.getStream(o);if(!a){n="stream isnot found, maybe it has already been published or destroyed";return i.default.warn(n),void t(l.createError(l.ErrorCodes.STREAM_NOT_EXISTS,n))}this.sessionManager.publishStream(a,(function(){r.previewStreamManager.removeStream(o,!0).catch((function(e){i.default.error("publish stream failure when remove it "+e)}))}),t)}else{var s;if("function"==typeof e)t=e,s={audio:!0,video:!0,screen:!1};else if(e){if(e.screen&&e.video&&i.default.warn("both video and screen are true, only camera's video will be published"),e.screen&&e.audio&&i.default.warn("both audio and screen are true, only microphone's audio will be published"),e.audio&&e.video&&e.screen){n="audio, video and screen cannot be true at the same time";return i.default.warn(n),void("function"==typeof t&&t(l.createError(l.ErrorCodes.INVALID_PARAMETER,n)))}if(!(e.audio||e.video||e.screen||e.mediaStream)){n="audio, video and screen cannot be false at the same time";return i.default.warn(n),void("function"==typeof t&&t(l.createError(l.ErrorCodes.INVALID_PARAMETER,n)))}s={audio:!!e.audio,video:!!e.video,screen:!!e.screen,microphoneId:e.microphoneId,cameraId:e.cameraId,extensionId:e.extensionId,mediaStream:e.mediaStream,file:e.file,filePath:e.filePath},"boolean"==typeof e.screenAudio&&(s.screenAudio=e.screenAudio),e.facingMode&&y.includes(e.facingMode)&&(s.facingMode=e.facingMode)}else s={audio:!0,video:!0,screen:!1};if("function"!=typeof t&&(t=function(){}),!f.isValidString(s.microphoneId)){n="type error, the microphoneId is not blank or a valid string";return i.default.warn(n),void t(l.createError(l.ErrorCodes.INVALID_PARAMETER,n))}if(!f.isValidString(s.cameraId)){n="type error, the cameraId is not blank or a valid string";return i.default.warn(n),void t(l.createError(l.ErrorCodes.INVALID_PARAMETER,n))}if(s.mediaStream&&!(s.mediaStream instanceof MediaStream)){n="type error, the mediaStream is not a valid MediaStream";return i.default.warn(n),void t(l.createError(l.ErrorCodes.INVALID_PARAMETER,n))}if(!this.sessionManager){n="please join room first";return i.default.warn(n),void t(l.createError(l.ErrorCodes.NOT_JOIN,n))}this.sessionManager.publish(s,(function(){}),t)}},e.prototype.unpublish=function(e,t,r){var n;if("function"==typeof e){if(r=t,t=e,!(a=this.getStream())){var o="stream is not found";return i.default.warn(o),void(r&&r(l.createError(l.ErrorCodes.STREAM_NOT_EXISTS,o)))}n=a.sid}else{if(!f.isValidString(e)){o="the arguments are invalid";return i.default.warn(o),void(r&&r(l.createError(l.ErrorCodes.INVALID_PARAMETER,o)))}var a;if(!(a=this.getStream(e))){var o="stream is not found";return i.default.warn(o),void(r&&r(l.createError(l.ErrorCodes.STREAM_NOT_EXISTS,o)))}n=a.sid}if("function"!=typeof t&&(t=function(){}),"function"!=typeof r&&(r=function(){}),!this.sessionManager){o="please join room first";return i.default.warn(o),void r(l.createError(l.ErrorCodes.NOT_JOIN,o))}this.sessionManager.unpublish(n,t,r)},e.prototype.subscribe=function(e,t){if("function"!=typeof t&&(t=function(){}),!f.streamValidator.isValidStreamId(e)){var r="stream Id is invalid";return i.default.warn(r),void t(l.createError(l.ErrorCodes.INVALID_PARAMETER,r))}var n="vp8";if(n=/VP8/.exec(e)?"vp8":/H264/.exec(e)?"h264":/H265/.exec(e)?"h265":"vp8",!this.supportedVideoCodecs.includes(n)){r="your browser can't decode the video of "+e+" stream";return i.default.warn(r),void t(l.createError(l.ErrorCodes.OTHERS,r))}if(!this.sessionManager){r="please join room first";return i.default.warn(r),void t(l.createError(l.ErrorCodes.NOT_JOIN,r))}this.sessionManager.subscribe(e,(function(){}),t)},e.prototype.unsubscribe=function(e,t,r){if("function"!=typeof t&&(t=function(){}),"function"!=typeof r&&(r=function(){}),!f.streamValidator.isValidStreamId(e)){var n="stream Id is invalid";return i.default.warn(n),void r(l.createError(l.ErrorCodes.INVALID_PARAMETER,n))}if(!this.sessionManager){n="please join room first";return i.default.warn(n),void r(l.createError(l.ErrorCodes.NOT_JOIN,n))}this.sessionManager.unsubscribe(e,t,r)},e.prototype.on=function(e,t){if(i.default.debug("Client on ",e),g.includes(e))this.eventManager.on(e,t);else{if("string"!=typeof e)throw l.createError(l.ErrorCodes.INVALID_PARAMETER,"not supported event type");i.default.warn(e+" is an invalid event type")}},e.prototype.off=function(e,t){if(i.default.debug("Client off ",e),g.includes(e))this.eventManager.off(e,t);else{if("string"!=typeof e)throw l.createError(l.ErrorCodes.INVALID_PARAMETER,"not supported event type");i.default.warn(e+" is an invalid event type")}},e.prototype.muteAudio=function(e){if(f.streamValidator.isValidStreamId(e)){var t=this.previewStreamManager.getStream(e);if(t)return t.muteAudio()}var r=this.getStream(e);return r?!!this.sessionManager&&this.sessionManager.muteAudio(r.sid,(function(){})):(i.default.warn("stream is not found"),!1)},e.prototype.unmuteAudio=function(e){if(f.streamValidator.isValidStreamId(e)){var t=this.previewStreamManager.getStream(e);if(t)return t.unmuteAudio()}var r=this.getStream(e);return r?!!this.sessionManager&&this.sessionManager.unmuteAudio(r.sid,(function(){})):(i.default.warn("stream is not found"),!1)},e.prototype.muteVideo=function(e){if(f.streamValidator.isValidStreamId(e)){var t=this.previewStreamManager.getStream(e);if(t)return t.muteVideo()}var r=this.getStream(e);return r?!!this.sessionManager&&this.sessionManager.muteVideo(r.sid,(function(){})):(i.default.warn("stream is not found"),!1)},e.prototype.unmuteVideo=function(e){if(f.streamValidator.isValidStreamId(e)){var t=this.previewStreamManager.getStream(e);if(t)return t.unmuteVideo()}var r=this.getStream(e);return r?!!this.sessionManager&&this.sessionManager.unmuteVideo(r.sid,(function(){})):(i.default.warn("stream is not found"),!1)},e.prototype.startRecording=function(e,t,r){e=e||{bucket:"",region:""};var n=this.getUser(),o=n&&n.uid||"",a=s.ENUM_MEDIA_TYPE.camera,c=1280,u=720,d=1,f=!0;if(e.mixStream&&"object"==typeof e.mixStream){switch(e.mixStream.uid&&"string"==typeof e.mixStream.uid&&(o=e.mixStream.uid),e.mixStream.type){case"desktop":case"screen":a=s.ENUM_MEDIA_TYPE.desktop;break;case"camera":default:a=s.ENUM_MEDIA_TYPE.camera}switch("number"==typeof e.mixStream.width&&e.mixStream.width>0&&(c=e.mixStream.width),"number"==typeof e.mixStream.height&&e.mixStream.height>0&&(u=e.mixStream.height),e.mixStream.template){case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 9:d=e.mixStream.template;break;default:d=1}"boolean"==typeof e.mixStream.isAverage&&(f=e.mixStream.isAverage)}if(e.uid&&"string"==typeof e.uid&&(o=e.uid),e.mainViewType&&"string"==typeof e.mainViewType)switch(e.mainViewType){case"desktop":case"screen":a=s.ENUM_MEDIA_TYPE.desktop;break;case"camera":default:a=s.ENUM_MEDIA_TYPE.camera}var p=s.ENUM_WATER_MARK_POS.lt,m=s.ENUM_WATER_MARK_TYPE.none,h="";if(e.waterMark&&"object"==typeof e.waterMark){switch(e.waterMark.position){case"left-top":p=s.ENUM_WATER_MARK_POS.lt;break;case"left-bottom":p=s.ENUM_WATER_MARK_POS.lb;break;case"right-top":p=s.ENUM_WATER_MARK_POS.rt;break;case"right-bottom":p=s.ENUM_WATER_MARK_POS.rb;break;default:p=s.ENUM_WATER_MARK_POS.lt}switch(e.waterMark.type){case"image":m=s.ENUM_WATER_MARK_TYPE.image,"string"==typeof e.waterMark.remarks&&(h=e.waterMark.remarks);break;case"text":m=s.ENUM_WATER_MARK_TYPE.text,"string"==typeof e.waterMark.remarks&&(h=e.waterMark.remarks);break;case"time":default:m=s.ENUM_WATER_MARK_TYPE.time,h=""}}var v=!1,g=parseInt((+new Date/1e3).toString()),y=60;e.relay&&"object"==typeof e.relay&&(v=!0,"number"==typeof e.relay.time&&e.relay.time>0&&(g=e.relay.time),"number"==typeof e.relay.fragment&&e.relay.fragment>0&&(y=e.relay.fragment));var E={waterMarkPos:p,waterMarkType:m,waterMarkRemarks:h,mixStreamUId:o,mixStreamType:a,mixStreamWidth:c,mixStreamHeight:u,mixStreamTemplate:d,isAverage:f,bucket:e.bucket,region:e.region,isRelay:v,relayTime:g,relayFragment:y};if("function"!=typeof t&&(t=function(){}),"function"!=typeof r&&(r=function(){}),!this.sessionManager){var b="please join room first";return i.default.warn(b),void r(l.createError(l.ErrorCodes.NOT_JOIN,b))}this.sessionManager.startRecording(E,t,r)},e.prototype.stopRecording=function(e,t){if("function"!=typeof e&&(e=function(){}),"function"!=typeof t&&(t=function(){}),!this.sessionManager){var r="please join room first";return i.default.warn(r),void t(l.createError(l.ErrorCodes.NOT_JOIN,r))}this.sessionManager.stopRecording(e,t)},e.prototype.getUser=function(){if(this.sessionManager)return d.convertToOuterUser(this.sessionManager.user)},e.prototype.getUsers=function(){return this.sessionManager?this.sessionManager.users.map((function(e){return d.convertToOuterUser(e)})):[]},e.prototype.sync=function(e){var t=function(t){e&&e(t)};if(!this.sessionManager){var r="please join room first";return i.default.warn(r),void t(l.createError(l.ErrorCodes.NOT_JOIN,r))}this.sessionManager.syncRoom().then((function(){t()})).catch((function(e){t(e)}))},e.prototype.getStream=function(e){if(f.streamValidator.isValidStreamId(e)){var t=this.previewStreamManager.getStream(e);if(t)return t.convertToOuterStream()}var r;if(this.sessionManager)return f.streamValidator.isValidStreamId(e)?(r=this.sessionManager.streamManager.getStream(e))&&r.convertToOuterStream():(r=this.sessionManager.streamManager.getAllLocalStreams()[0])&&r.convertToOuterStream()},e.prototype.getLocalStreams=function(){var e=[];return this.sessionManager&&this.sessionManager.streamManager.getAllLocalStreams().forEach((function(t){e.push(t.convertToOuterStream())})),this.previewStreamManager.getAllStreams().forEach((function(t){e.push(t.convertToOuterStream())})),e},e.prototype.getRemoteStreams=function(){return this.sessionManager?this.sessionManager.streamManager.getAllRemoteStreams().map((function(e){return e.convertToOuterStream()})):[]},e.prototype.getStreams=function(){return i.default.warn("getStreams is deprecated, please use getRemoteStreams"),this.getRemoteStreams()},e.prototype.getMediaStream=function(e){var t=this.getStream(e);return t&&t.mediaStream},e.prototype.getLocalMediaStream=function(e){return i.default.warn("getLocalMediaStream is deprecated, please use getMediaStream"),this.getMediaStream(e)},e.prototype.getRemoteMediaStream=function(e){return i.default.warn("getLocalMediaStream is deprecated, please use getMediaStream"),this.getMediaStream(e)},e.prototype.play=function(e,t){var r,n=(e=e||{}).streamId,o=e.container,a=e.mirror,s=void 0!==a&&a,c=e.fit,u=e.controls;if(!f.streamValidator.isValidStreamId(n)){var d="stream Id is invalid";return i.default.warn(d),void(t&&t(l.createError(l.ErrorCodes.INVALID_PARAMETER,d)))}var p=null;if("string"==typeof o&&(p=document.getElementById(o)),o instanceof HTMLElement&&(p=o),!p){d="container is invalid";return i.default.warn(d),void(t&&t(l.createError(l.ErrorCodes.INVALID_PARAMETER,d)))}var m=!1,h=!0;Object.prototype.toString.call(e.mute).indexOf("Boolean")>=0&&(m=e.mute,h=e.mute);var v={mute:m,mirror:!!s,controls:u};if(c)switch(c){case"contain":case"cover":v.fit=c;break;default:v.fit="cover"}if(u)switch(u){case"show":case"hide":case"auto":v.controls=u;break;default:v.controls="auto"}var g=this.previewStreamManager.getStream(n);if(g)return v.mute=h,void g.play(p,v).then((function(){t&&t()})).catch((function(e){t&&t(e)}));var y=null===(r=this.sessionManager)||void 0===r?void 0:r.streamManager.getStream(n);y?(y.isSubscriber||(v.mute=h),y.play(p,v).then((function(){t&&t()})).catch((function(e){t&&t(e)}))):t&&t(l.createError(l.ErrorCodes.STREAM_NOT_EXISTS,"stream is not exist"))},e.prototype.resume=function(e,t){var r,n=this.previewStreamManager.getStream(e);if(n)n.resume().then((function(){t&&t()})).catch((function(e){t&&t(e)}));else{var i=null===(r=this.sessionManager)||void 0===r?void 0:r.streamManager.getStream(e);i?i.resume().then((function(){t&&t()})).catch((function(e){t&&t(e)})):t&&t(l.createError(l.ErrorCodes.STREAM_NOT_EXISTS,"stream is not exist"))}},e.prototype.pause=function(e,t){var r,n=this.previewStreamManager.getStream(e);if(n)n.stop().then((function(){t&&t()})).catch((function(e){t&&t(e)}));else{var i=null===(r=this.sessionManager)||void 0===r?void 0:r.streamManager.getStream(e);i?i.stop().then((function(){t&&t()})).catch((function(e){t&&t(e)})):t&&t(l.createError(l.ErrorCodes.STREAM_NOT_EXISTS,"stream is not exist"))}},e.prototype.stop=function(e,t){var r,n=this.previewStreamManager.getStream(e);if(n)return n.destroyPlayer(),void(t&&t());var i=null===(r=this.sessionManager)||void 0===r?void 0:r.streamManager.getStream(e);i?(i.destroyPlayer(),t&&t()):t&&t(l.createError(l.ErrorCodes.STREAM_NOT_EXISTS,"stream is not exist"))},e.prototype.getMicrophones=function(e,t,r){"function"==typeof e&&(r=t,t=e,e={microphone:!0,camera:!1}),"function"!=typeof t&&(t=function(){}),"function"!=typeof r&&(r=function(){});var n={microphone:!0,camera:!1};e&&(n.microphone=!!e.microphone),c.StreamManager.enumerateDevices(n,(function(e){t&&t(e.filter((function(e){return"audioinput"===e.kind})))}),r)},e.prototype.getCameras=function(e,t,r){"function"==typeof e&&(r=t,t=e,e={microphone:!1,camera:!0}),"function"!=typeof t&&(t=function(){}),"function"!=typeof r&&(r=function(){});var n={microphone:!1,camera:!0};e&&(n.camera=!!e.camera),c.StreamManager.enumerateDevices(n,(function(e){t&&t(e.filter((function(e){return"videoinput"===e.kind})))}),r)},e.prototype.getLoudspeakers=function(e,t){"function"!=typeof e&&(e=function(){}),"function"!=typeof t&&(t=function(){}),c.StreamManager.enumerateDevices({microphone:!1,camera:!1},(function(t){e&&e(t.filter((function(e){return"audiooutput"===e.kind})))}),t)},e.prototype.setVideoProfile=function(e,t,r){var n,o,a,c,u=this;if("object"==typeof e&&e.profile?(a=e.streamId||e.previewId,c=e.profile):c=e,"function"!=typeof t&&(t=function(){}),"function"!=typeof r&&(r=function(){}),"string"==typeof c){var d=p.getSupportProfileNames(),m=p.getInternalSupportProfileNames();if(!d.concat(m).includes(c)){var h=c+" is not supported, you can invoke getSupportProfileNames function to get supported profile";return i.default.warn(h),void r(l.createError(l.ErrorCodes.INVALID_PARAMETER,h))}}else if(!(f.isValidNumber(c.width,!0)&&f.isValidNumber(c.height,!0)&&f.isValidNumber(c.framerate,!0)&&f.isValidNumber(c.bitrate,!0))){h="profile's width, height, framerate or bitrate is invalid, a valid sample is {width: 640, height: 480, framerate: 20, bitrate: 500}";return i.default.warn(h),void r(l.createError(l.ErrorCodes.INVALID_PARAMETER,h))}if(f.streamValidator.isValidStreamId(a)){var v=this.getStream(a);if(!v){h="stream is not found";return void r(l.createError(l.ErrorCodes.STREAM_NOT_EXISTS,h))}var g=this.previewStreamManager.getStream(v.sid);if(!g){if(g=null===(n=this.sessionManager)||void 0===n?void 0:n.streamManager.getLocalStream(v.sid)){var y=void 0;if(y="object"==typeof c?p.getCustomResolution(c):p.getResolution(c),g.mediaType===s.ENUM_MEDIA_TYPE.desktop){h="stream of sharing screen cannot update profile after created";return void r(l.createError(l.ErrorCodes.NOT_SUPPORT,h))}return void(null===(o=this.sessionManager)||void 0===o||o.updateVP(g,y).then((function(){var e;return null===(e=u.sessionManager)||void 0===e?void 0:e.streamManager.setVideoProfile(c,g)})).catch((function(e){r&&r(e)})))}var h="stream is not found";return void r(l.createError(l.ErrorCodes.STREAM_NOT_EXISTS,h))}this.previewStreamManager.setVideoProfile(g.streamId,c).then((function(){t&&t()})).catch((function(e){r&&r(e)}))}else this.profileName=c,this.sessionManager&&this.sessionManager.streamManager.setVideoProfile(c).catch((function(e){return i.default.warn("set video profile ",e)})),t()},e.prototype.switchDevice=function(e,t,r){var n,o,a;if("object"==typeof e)n=e.streamId,o=e.deviceId,a=e.type;else{var s=Array.prototype.slice.call(arguments),c=s[0],u=s[1],d=s[2],f=s[3];a=c,o=u,t=d,r=f}var p=function(e){"function"==typeof t&&t(e)},h=function(e){"function"==typeof r&&r(e)};if(o&&"string"==typeof o){var v=this.getStream(n);if(v){var g=this.previewStreamManager.getStream(v.sid);if(!g&&this.sessionManager&&(g=this.sessionManager.streamManager.getLocalStream(v.sid)),g)switch(a){case"audio":g.switchMicrophone(o).then(p).catch(h);break;case"video":g.switchCamera(o).then((function(){var e;m.default.isFirefox()&&(null===(e=g)||void 0===e||e.resume().catch((function(e){i.default.warn("resume after switch device ",e)}))),p()})).catch(h);break;default:y="device type unknown";h(l.createError(l.ErrorCodes.INVALID_PARAMETER,y))}else{y="stream is not found";h(l.createError(l.ErrorCodes.STREAM_NOT_EXISTS,y))}}else{var y="stream is not found";h(l.createError(l.ErrorCodes.STREAM_NOT_EXISTS,y))}}else{var y="device Id is invalid";h(l.createError(l.ErrorCodes.INVALID_PARAMETER,y))}},e.prototype.switchScreen=function(e,t,r){"function"==typeof e&&(r=t,t=e,e=void 0);var n=function(e){"function"==typeof r&&r(e)},i=this.getStream(e);if(i){var o=this.previewStreamManager.getStream(i.sid);if(!o&&this.sessionManager&&(o=this.sessionManager.streamManager.getLocalStream(i.sid)),o)o.switchScreen().then((function(e){"function"==typeof t&&t(e)})).catch(n);else{a="stream is not found";n(l.createError(l.ErrorCodes.STREAM_NOT_EXISTS,a))}}else{var a="stream is not found";n(l.createError(l.ErrorCodes.STREAM_NOT_EXISTS,a))}},e.prototype.switchImage=function(e,t,r){var n,o;"object"!=typeof e||e instanceof File?o=e:(n=e.streamId,o=e.file?e.file:e.filePath?e.filePath:"");var a=function(e){"function"==typeof r&&r(e)};if(!o||!("string"==typeof o||o instanceof File)){var s="both file and filePath are invalid";return i.default.warn(s),void a(l.createError(l.ErrorCodes.INVALID_PARAMETER,s))}var c=this.getStream(n);if(c){var u=this.previewStreamManager.getStream(c.sid);if(!u&&this.sessionManager&&(u=this.sessionManager.streamManager.getLocalStream(c.sid)),u)u.switchImage(o).then((function(e){"function"==typeof t&&t(e)})).catch(a);else{s="stream is not found";a(l.createError(l.ErrorCodes.STREAM_NOT_EXISTS,s))}}else{var s="stream is not found";a(l.createError(l.ErrorCodes.STREAM_NOT_EXISTS,s))}},e.prototype.getAudioVolume=function(e){if(f.streamValidator.isValidStreamId(e)){var t=this.previewStreamManager.getStream(e);if(t)return Math.floor(100*t.getAudioVolume())}var r=this.getStream(e);if(!r)return i.default.warn("stream is not found"),0;if(this.sessionManager){var n=this.sessionManager.streamManager.getStream(r.sid);if(n)return Math.floor(100*n.getAudioVolume())}return i.default.warn("stream is not found"),0},e.prototype.setAudioVolume=function(e,t){var r=(e=e||{}).streamId,n=e.volume;if("function"!=typeof t&&(t=function(){}),f.isValidVolume(n)){if(f.streamValidator.isValidStreamId(r)){var i=this.previewStreamManager.getStream(r);i&&i.setAudioVolume(n).then(t).catch(t)}var o=this.getStream(r);if(o){if(this.sessionManager){var a=this.sessionManager.streamManager.getStream(o.sid);if(a)a.isSubscriber&&e.element instanceof HTMLMediaElement?(e.element.volume=n/100,t()):a.setAudioVolume(n).then(t).catch(t);else{s="stream is not found";t(l.createError(l.ErrorCodes.STREAM_NOT_EXISTS,s))}}}else{var s="stream is not found";t(l.createError(l.ErrorCodes.STREAM_NOT_EXISTS,s))}}else{var s="volume is invalid";t(l.createError(l.ErrorCodes.INVALID_PARAMETER,s))}},e.prototype.getAudioStats=function(e,t,r){var n;if("function"==typeof e){if(r=t,t=e,!(a=this.getStream())){var o="stream is not found";return i.default.warn(o),void(r&&r(l.createError(l.ErrorCodes.STREAM_NOT_EXISTS,o)))}n=a.sid}else if("string"==typeof e)n=e;else{if(e){o="the arguments are invalid";return i.default.warn(o),void(r&&r(l.createError(l.ErrorCodes.INVALID_PARAMETER,o)))}var a;if(!(a=this.getStream())){var o="stream is not found";return i.default.warn(o),void(r&&r(l.createError(l.ErrorCodes.STREAM_NOT_EXISTS,o)))}n=a.sid}if("function"!=typeof t&&(t=function(){}),"function"!=typeof r&&(r=function(){}),!this.sessionManager){o="please join room first";return i.default.warn(o),void r(l.createError(l.ErrorCodes.NOT_JOIN,o))}var s=this.sessionManager.streamManager.getStream(n);if(!s){o="stream is not found";return i.default.warn(o),void(r&&r(l.createError(l.ErrorCodes.STREAM_NOT_EXISTS,o)))}s.getStats2().then((function(e){t&&t(e.audio)})).catch(r)},e.prototype.getVideoStats=function(e,t,r){var n;if("function"==typeof e){if(r=t,t=e,!(a=this.getStream())){var o="stream is not found";return i.default.warn(o),void(r&&r(l.createError(l.ErrorCodes.STREAM_NOT_EXISTS,o)))}n=a.sid}else if("string"==typeof e)n=e;else{if(e){o="the arguments are invalid";return i.default.warn(o),void(r&&r(l.createError(l.ErrorCodes.INVALID_PARAMETER,o)))}var a;if(!(a=this.getStream())){var o="stream is not found";return i.default.warn(o),void(r&&r(l.createError(l.ErrorCodes.STREAM_NOT_EXISTS,o)))}n=a.sid}if("function"!=typeof t&&(t=function(){}),"function"!=typeof r&&(r=function(){}),!this.sessionManager){o="please join room first";return i.default.warn(o),void r(l.createError(l.ErrorCodes.NOT_JOIN,o))}var s=this.sessionManager.streamManager.getStream(n);if(!s){o="stream is not found";return i.default.warn(o),void(r&&r(l.createError(l.ErrorCodes.STREAM_NOT_EXISTS,o)))}s.getStats2().then((function(e){t&&t(e.video)})).catch(r)},e.prototype.getNetworkStats=function(e,t,r){var n;if("function"==typeof e){if(r=t,t=e,!(a=this.getStream())){var o="stream is not found";return i.default.warn(o),void(r&&r(l.createError(l.ErrorCodes.STREAM_NOT_EXISTS,o)))}n=a.sid}else if("string"==typeof e)n=e;else{if(e){o="the arguments are invalid";return i.default.warn(o),void(r&&r(l.createError(l.ErrorCodes.INVALID_PARAMETER,o)))}var a;if(!(a=this.getStream())){var o="stream is not found";return i.default.warn(o),void(r&&r(l.createError(l.ErrorCodes.STREAM_NOT_EXISTS,o)))}n=a.sid}if("function"!=typeof t&&(t=function(){}),"function"!=typeof r&&(r=function(){}),!this.sessionManager){o="please join room first";return i.default.warn(o),void(r&&r(l.createError(l.ErrorCodes.NOT_JOIN,o)))}var s=this.sessionManager.streamManager.getStream(n);if(!s){o="stream is not found";return i.default.warn(o),void(r&&r(l.createError(l.ErrorCodes.STREAM_NOT_EXISTS,o)))}s.getStats2().then((function(e){var r={rtt:-1!==e.connection.rtt?e.connection.rtt:e.connection.delay};t&&t(r)})).catch(r)},e.prototype.preloadEffect=function(e,t,r){var n;return"function"!=typeof r&&(r=function(){}),f.effectValidator.isValidId(e)?f.effectValidator.isValidFilePath(t,!0)?void this.effectManager.preloadEffect(e,t).then((function(){r&&r()})).catch((function(e){r&&r(e)})):(n="filePath is invalid",i.default.warn(n),void r(l.createError(l.ErrorCodes.INVALID_PARAMETER,n))):(n="effectId is invalid",i.default.warn(n),void r(l.createError(l.ErrorCodes.INVALID_PARAMETER,n)))},e.prototype.unloadEffect=function(e){if(!f.effectValidator.isValidId(e))return"effectId is invalid",void i.default.warn("effectId is invalid");this.effectManager.unloadEffect(e)},e.prototype.__getLocalStream=function(e){if(f.streamValidator.isValidStreamId(e)){var t=this.previewStreamManager.getStream(e);if(t)return t}if(this.sessionManager)return f.streamValidator.isValidStreamId(e)?this.sessionManager.streamManager.getLocalStream(e):this.sessionManager.streamManager.getAllLocalStreams()[0]},e.prototype.__getRemoteStream=function(e){if(this.sessionManager&&f.streamValidator.isValidStreamId(e))return this.sessionManager.streamManager.getRemoteStream(e)},e.prototype.playEffect=function(e,t){if("function"!=typeof t&&(t=function(){}),!f.effectValidator.isValidEffectOptions(e)){var r="EffectOptions is invalid";return i.default.warn(r),void t(l.createError(l.ErrorCodes.INVALID_PARAMETER,r))}var n,o={effectId:e.effectId,loop:!1,playTime:0,replace:!1};if(e.filePath&&(o.filePath=e.filePath),e.playTime&&(o.playTime=e.playTime),e.loop&&(o.loop=!0),e.replace&&(o.replace=!0),e.onEnd&&"function"==typeof e.onEnd&&(o.onEnd=e.onEnd),e.streamId)n=e.streamId;else{var a=this.getStream();if(!a){r="stream is not found";return i.default.warn(r),void t(l.createError(l.ErrorCodes.STREAM_NOT_EXISTS,r))}n=a.sid}var s=this.__getLocalStream(n);if(s){var c=this.effectManager.getCachedEffect(o.effectId);if(c)s.playEffect(c,o,t);else{if("string"!=typeof o.filePath){o.filePath=e.filePath;r="Cannot find effect and filePath is invalid";return i.default.warn(r),void t(l.createError(l.ErrorCodes.INVALID_PARAMETER,r))}this.effectManager.preloadEffect(o.effectId,o.filePath).then((function(e){s.playEffect(e,o,t)})).catch((function(e){t&&t(e)}))}}else{r="stream is not found";i.default.warn(r),t(l.createError(l.ErrorCodes.STREAM_NOT_EXISTS,r))}},e.prototype.pauseEffect=function(e,t){if("function"!=typeof t&&(t=function(){}),!f.effectValidator.isValidEffectOptions(e)){var r="EffectOptions is invalid";return i.default.warn(r),void t(l.createError(l.ErrorCodes.INVALID_PARAMETER,r))}var n;if(e.streamId)n=e.streamId;else{var o=this.getStream();if(!o){r="stream is not found";return i.default.warn(r),void t(l.createError(l.ErrorCodes.STREAM_NOT_EXISTS,r))}n=o.sid}var a=this.__getLocalStream(n);if(a)a.pauseEffect(e.effectId,t);else{r="stream is not found";i.default.warn(r),t(l.createError(l.ErrorCodes.STREAM_NOT_EXISTS,r))}},e.prototype.resumeEffect=function(e,t){if("function"!=typeof t&&(t=function(){}),!f.effectValidator.isValidEffectOptions(e)){var r="EffectOptions is invalid";return i.default.warn(r),void t(l.createError(l.ErrorCodes.INVALID_PARAMETER,r))}var n;if(e.streamId)n=e.streamId;else{var o=this.getStream();if(!o){r="stream is not found";return i.default.warn(r),void t(l.createError(l.ErrorCodes.STREAM_NOT_EXISTS,r))}n=o.sid}var a=this.__getLocalStream(n);if(a){var s=this.effectManager.getCachedEffect(e.effectId);if(s)a.resumeEffect(s,e.effectId,t);else{r="Invalid effect, effect may already unloaded";i.default.warn(r),t(l.createError(l.ErrorCodes.INVALID_PARAMETER,r))}}else{r="stream is not found";i.default.warn(r),t(l.createError(l.ErrorCodes.STREAM_NOT_EXISTS,r))}},e.prototype.stopEffect=function(e,t){if("function"!=typeof t&&(t=function(){}),!f.effectValidator.isValidEffectOptions(e)){var r="EffectOptions is invalid";return i.default.warn(r),void t(l.createError(l.ErrorCodes.INVALID_PARAMETER,r))}var n;if(e.streamId)n=e.streamId;else{var o=this.getStream();if(!o){r="stream is not found";return i.default.warn(r),void t(l.createError(l.ErrorCodes.STREAM_NOT_EXISTS,r))}n=o.sid}var a=this.__getLocalStream(n);if(a)a.stopEffect(e.effectId,t);else{r="stream is not found";i.default.warn(r),t(l.createError(l.ErrorCodes.STREAM_NOT_EXISTS,r))}},e.prototype.setEffectVolume=function(e,t){if("function"!=typeof t&&(t=function(){}),!f.effectValidator.isValidEffectOptions(e)){var r="EffectVolumeOptions is invalid";return i.default.warn(r),void t(l.createError(l.ErrorCodes.INVALID_PARAMETER,r))}var n;if(e.streamId)n=e.streamId;else{var o=this.getStream();if(!o){r="stream is not found";return i.default.warn(r),void t(l.createError(l.ErrorCodes.STREAM_NOT_EXISTS,r))}n=o.sid}var a=this.__getLocalStream(n);if(a)a.setEffectVolume(e.effectId,e.volume,t);else{r="stream is not found";i.default.warn(r),t(l.createError(l.ErrorCodes.STREAM_NOT_EXISTS,r))}},e.prototype.snapshot=function(e,t,r){"function"==typeof e&&(r=t,t=e,e={});var n,o,a,s=function(e){"function"==typeof r&&r(e)},c=(e=e||{}).streamId,u=e.download;if(c)n=c;else{var d=this.getStream();if(!d){var f="stream is not found";return i.default.warn(f),void s(l.createError(l.ErrorCodes.STREAM_NOT_EXISTS,f))}n=d.sid}if(u){if("string"!=typeof u&&"boolean"!=typeof u){f="download is invalid, it should be string or boolean";return i.default.warn(f),void s(l.createError(l.ErrorCodes.INVALID_PARAMETER,f))}o=u}else o=!1;if((a=this.__getRemoteStream(n))||(a=this.__getLocalStream(n)),a){var p="";"string"==typeof o?p=o:o&&(p="urtc-snapshot-"+h.formatTime(new Date,"YYYY-MM-DD_HHmmss")),a.snapshot(p).then((function(e){"function"==typeof t&&t(e)})).catch(s)}else{f="stream is not found";i.default.warn(f),s(l.createError(l.ErrorCodes.STREAM_NOT_EXISTS,f))}},e.prototype.startPreviewing=function(e,t,r){"function"==typeof e&&(r=t,t=e,e={audio:!0,video:!0});var n=function(e){"function"==typeof r&&r(e)},o={audio:!0,video:!0,screen:!1};if("object"==typeof e&&(o.audio=e.audio,o.video=e.video,o.facingMode=e.facingMode,o.microphoneId=e.microphoneId,o.cameraId=e.cameraId),!o.audio&&!o.video){var a="audio or video must be true";return i.default.warn(a),void n(l.createError(l.ErrorCodes.INVALID_PARAMETER,a))}if(o.facingMode&&!y.includes(o.facingMode)){a="facingMode is invalid";return i.default.warn(a),void n(l.createError(l.ErrorCodes.INVALID_PARAMETER,a))}if(o.microphoneId&&"string"!=typeof o.microphoneId){a="microphoneId is invalid";return i.default.warn(a),void n(l.createError(l.ErrorCodes.INVALID_PARAMETER,a))}if(o.cameraId&&"string"!=typeof o.cameraId){a="cameraId is invalid";return i.default.warn(a),void n(l.createError(l.ErrorCodes.INVALID_PARAMETER,a))}if(this.previewStreamManager.getStream("preview")){a="you are previewing";n(l.createError(l.ErrorCodes.OTHERS,a))}else{var s=this.getUser(),c=s?s.uid:"unknown";this.previewStreamManager.createStream(c,"preview",o,this.profileName).then((function(e){!function(e){"function"==typeof t&&t(e)}(e.getMediaStream())})).catch(n)}},e.prototype.stopPreviewing=function(){this.previewStreamManager.removeStream("preview",!1).catch((function(e){i.default.warn("stop previewing "+e)}))},e.prototype.deviceDetection=function(e,t){"function"==typeof e&&(t=e,e={audio:!0,video:!0});var r={audio:!0,video:!0};if("object"==typeof e&&(r.audio=e.audio,r.video=e.video,r.microphoneId=e.microphoneId,r.cameraId=e.cameraId),r.audio||r.video)if(r.microphoneId&&"string"!=typeof r.microphoneId){n="microphoneId is invalid";i.default.warn(n)}else if(r.cameraId&&"string"!=typeof r.cameraId){n="cameraId is invalid";i.default.warn(n)}else c.StreamManager.deviceDetection(r).then((function(e){"function"==typeof t&&t(e)})).catch((function(e){i.default.warn("device detection ",e)}));else{var n="audio or video must be true";i.default.warn(n)}},e.prototype.replaceTrack=function(e,t){var r=(e=e||{}).streamId,n=e.track,i=e.retain;if("function"!=typeof t&&(t=function(){}),n instanceof MediaStreamTrack){var o=!!i;if(f.streamValidator.isValidStreamId(r))if(s=this.previewStreamManager.getStream(r)){try{t(void 0,s.replaceTrack(n,o))}catch(c){t(c)}return}var a=this.getStream(r);if(a)if(this.sessionManager){var s;if(s=this.sessionManager.streamManager.getLocalStream(a.sid)){try{t(void 0,s.replaceTrack(n,o))}catch(c){t(c)}return}c="stream is not found";t(l.createError(l.ErrorCodes.STREAM_NOT_EXISTS,c))}else t(l.createError(l.ErrorCodes.STREAM_NOT_EXISTS,"stream is not found"));else{var c="stream is not found";t(l.createError(l.ErrorCodes.STREAM_NOT_EXISTS,c))}}else{var c="invalid track, please check the 'track' parameter";t(l.createError(l.ErrorCodes.INVALID_PARAMETER,c))}},e.prototype.startMix=function(e,t){e=e||{bucket:"",region:""},"function"!=typeof t&&(t=function(){});var r=this.getUser(),n=s.ENUM_MIX_TYPE.record;switch(e.type){case"relay":n=s.ENUM_MIX_TYPE.relay;break;case"relay-and-record":n=s.ENUM_MIX_TYPE.relayRecord;break;case"update-config":n=s.ENUM_MIX_TYPE.update;break;case"record":default:n=s.ENUM_MIX_TYPE.record}var o=[];if(n===s.ENUM_MIX_TYPE.relay||n===s.ENUM_MIX_TYPE.relayRecord){if("[object Array]"!==Object.prototype.toString.call(e.pushURL))return void t(N=l.createError(l.ErrorCodes.INVALID_PARAMETER,"type is "+n+", pushURL must be an array"));o=e.pushURL?e.pushURL:o}var a=0;if("number"==typeof e.timeoutPeriod){var c=e.timeoutPeriod;if(!(c>=60&&c<=86400))return void t(N=l.createError(l.ErrorCodes.INVALID_PARAMETER,"timeoutPeriod must be >= 60 and <= 86400"));a=c}var u=s.ENUM_MIX_LAYOUT.flow,d=[],p=r&&r.uid||"",m=s.ENUM_MEDIA_TYPE.camera,h=[];if(e.layout&&"object"==typeof e.layout){switch(p=e.layout.mainViewUId?e.layout.mainViewUId:p,e.layout.mainViewType){case"screen":case"desktop":m=s.ENUM_MEDIA_TYPE.desktop;break;case"camera":default:m=s.ENUM_MEDIA_TYPE.camera}switch(e.layout.type){case"main":u=s.ENUM_MIX_LAYOUT.main;break;case"custom":u=s.ENUM_MIX_LAYOUT.custom,d=e.layout.custom?e.layout.custom:d;break;case"customMain":u=s.ENUM_MIX_LAYOUT.customMain;break;case"customFlow":u=s.ENUM_MIX_LAYOUT.customFlow;break;case"single":u=s.ENUM_MIX_LAYOUT.single;break;case"flow":default:u=s.ENUM_MIX_LAYOUT.flow}if(e.layout.standbyTypes&&"[object Array]"===Object.prototype.toString.call(e.layout.standbyTypes)&&e.layout.standbyTypes.forEach((function(e){switch(e){case"flow":h.push(s.ENUM_MIX_LAYOUT.flow);break;case"main":h.push(s.ENUM_MIX_LAYOUT.main);break;case"customMain":h.push(s.ENUM_MIX_LAYOUT.customMain);break;case"customFlow":h.push(s.ENUM_MIX_LAYOUT.customFlow);break;case"single":h.push(s.ENUM_MIX_LAYOUT.single)}})),n!==s.ENUM_MIX_TYPE.update){var v=h.indexOf(u);v>=0&&h.splice(v,1),h.unshift(u),h.length>3&&(h.length=3)}}var g="aac";e.audio&&"object"==typeof e.audio&&(g=e.audio.codec?e.audio.codec:g);var y="h264",b="CB",_=15,S=500;e.video&&"object"==typeof e.video&&(y=e.video.codec?e.video.codec:y,b=e.video.quality?e.video.quality:b,e.video.frameRate&&(E.includes(e.video.frameRate)?_=e.video.frameRate:i.default.warn("video framte rate must be one of "+E)),S=e.video.bitRate?e.video.bitRate:S);var T=s.ENUM_MIX_OUTPUT_MODE.audioVideo;switch(e.outputMode){case"audio":T=s.ENUM_MIX_OUTPUT_MODE.audio;break;case"audio-video":default:T=s.ENUM_MIX_OUTPUT_MODE.audioVideo}var w=1280,R=720;"number"==typeof e.width&&e.width>0&&(w=e.width),"number"==typeof e.height&&e.height>0&&(R=e.height);var M={r:0,g:0,b:0};e.backgroundColor&&"object"==typeof e.backgroundColor&&(M.r=e.backgroundColor.r?e.backgroundColor.r:0,M.g=e.backgroundColor.g?e.backgroundColor.g:0,M.b=e.backgroundColor.b?e.backgroundColor.b:0);var C=s.ENUM_WATER_MARK_POS.lt,P=s.ENUM_WATER_MARK_TYPE.none,O="";if(e.waterMark&&"object"==typeof e.waterMark){switch(e.waterMark.position){case"left-top":C=s.ENUM_WATER_MARK_POS.lt;break;case"left-bottom":C=s.ENUM_WATER_MARK_POS.lb;break;case"right-top":C=s.ENUM_WATER_MARK_POS.rt;break;case"right-bottom":C=s.ENUM_WATER_MARK_POS.rb;break;default:C=s.ENUM_WATER_MARK_POS.lt}switch(e.waterMark.type){case"image":P=s.ENUM_WATER_MARK_TYPE.image,"string"==typeof e.waterMark.remarks&&(O=e.waterMark.remarks);break;case"text":P=s.ENUM_WATER_MARK_TYPE.text,"string"==typeof e.waterMark.remarks&&(O=e.waterMark.remarks);break;case"time":default:P=s.ENUM_WATER_MARK_TYPE.time,O=""}}var I=s.ENUM_MIX_STREAM_ADD_MODE.auto;switch(e.streamAddMode){case"manual":I=s.ENUM_MIX_STREAM_ADD_MODE.manual;break;case"automatic":default:I=s.ENUM_MIX_STREAM_ADD_MODE.auto}var A={bucket:e.bucket,region:e.region,pushurl:o,layout:u,custom:d,audiocodec:g,videocodec:y,qualitylevel:b,framerate:_,bitrate:S,mainviewuid:p,mainviewtype:m,width:w,height:R,bgColor:M,watertype:P,waterpos:C,waterurl:O,mimetype:T,addstreammode:I};a>=60&&(A.expand=A.expand||{},A.expand.taskTimeout=a),e.keyUser&&f.isValidString(e.keyUser)&&(A.keyuser=e.keyUser),n!==s.ENUM_MIX_TYPE.update&&(A.layouts=h);var k=[];if(e.streams&&"[object Array]"===Object.prototype.toString.call(e.streams)&&(this.mixStreams=e.streams,k=e.streams.map((function(e){var t;switch(e.mediaType){case"screen":t=s.ENUM_MEDIA_TYPE.desktop;break;case"camera":default:t=s.ENUM_MEDIA_TYPE.camera}return{user_id:e.uid,media_type:t}}))),!this.sessionManager){var N=l.createError(l.ErrorCodes.NOT_JOIN,"please join room first");return i.default.warn("startMix - "+N),void t(N)}this.mixLayout=A.layout,this.mixStreamMode=A.addstreammode,this.mixKeyUser=A.keyuser,this.sessionManager.startMix(n,k,A,t)},e.prototype.stopMix=function(e,t){if(e=e||{type:"record"},"function"!=typeof t&&(t=function(){}),!this.sessionManager){var r=l.createError(l.ErrorCodes.NOT_JOIN,"please join room first");return i.default.warn("stopMix - "+r),void t(r)}var n;switch(e.type){case"relay":n=s.ENUM_MIX_TYPE.relay;break;case"relay-and-record":n=s.ENUM_MIX_TYPE.relayRecord;break;case"record":default:n=s.ENUM_MIX_TYPE.record}var o=[];n!==s.ENUM_MIX_TYPE.relay&&n!==s.ENUM_MIX_TYPE.relayRecord||"[object Array]"===Object.prototype.toString.call(e.pushURL)&&(o=e.pushURL?e.pushURL:o),this.sessionManager.stopMix(n,o,t)},e.prototype.queryMix=function(e){if("function"!=typeof e&&(e=function(){}),!this.sessionManager){var t=l.createError(l.ErrorCodes.NOT_JOIN,"please join room first");return i.default.warn("queryMix - "+t),void e(t)}this.sessionManager.queryMix(e)},e.prototype.addMixStreams=function(e,t){var r=this;if(e=e||{streams:[]},"function"!=typeof t&&(t=function(){}),"[object Array]"!==Object.prototype.toString.call(e.streams)){var n=l.createError(l.ErrorCodes.INVALID_PARAMETER,"streams must be an array");return i.default.warn("addMixStreams - "+n),void t(n)}if(!this.sessionManager){n=l.createError(l.ErrorCodes.NOT_JOIN,"please join room first");return i.default.warn("addMixStreams - "+n),void t(n)}e.streams.forEach((function(e){e.uid&&e.mediaType&&r.mixStreams&&(r.mixStreams.findIndex((function(t){return t.uid===e.uid&&t.mediaType===e.mediaType}))<0&&r.mixStreams.push(e))}));var o=e.streams.map((function(e){var t;switch(e.mediaType){case"screen":t=s.ENUM_MEDIA_TYPE.desktop;break;case"camera":default:t=s.ENUM_MEDIA_TYPE.camera}return{user_id:e.uid,media_type:t}}));this.sessionManager.addMixStreams(o,t)},e.prototype.removeMixStreams=function(e,t){var r=this;if(e=e||{streams:[]},"function"!=typeof t&&(t=function(){}),"[object Array]"!==Object.prototype.toString.call(e.streams)){var n=l.createError(l.ErrorCodes.INVALID_PARAMETER,"streams must be an array");return i.default.warn("removeMixStreams - "+n),void t(n)}if(!this.sessionManager){n=l.createError(l.ErrorCodes.INVALID_PARAMETER,"please join room first");return i.default.warn("removeMixStreams - "+n),void t(n)}e.streams.forEach((function(e){if(e.uid&&e.mediaType&&r.mixStreams){var t=r.mixStreams.findIndex((function(t){return t.uid===e.uid&&t.mediaType===e.mediaType}));t>=0&&r.mixStreams.splice(t,1)}}));var o=e.streams.map((function(e){var t;switch(e.mediaType){case"screen":t=s.ENUM_MEDIA_TYPE.desktop;break;case"camera":default:t=s.ENUM_MEDIA_TYPE.camera}return{user_id:e.uid,media_type:t}}));this.sessionManager.removeMixStreams(o,t)},e.prototype.startRecord=function(e,t){var r=n.__assign(n.__assign({},e),{type:"record"});this.startMix(r,(function(e,r){if("function"==typeof t)if(r){var n={Id:r.MixId,FileName:r.FileName};t(e,n)}else t(e)}))},e.prototype.stopRecord=function(e){this.stopMix({type:"record"},(function(t,r){if("function"==typeof e)if(r){var n={Id:r.MixId,FileName:r.FileName};e(t,n)}else e(t)}))},e.prototype.updateRecordStreams=function(e,t){function r(e,r){if("function"==typeof t)if(r){var n={Id:r.MixId,FileName:r.FileName};t(e,n)}else t(e)}if(e=e||{},!b.includes(e.type)){var n=l.createError(l.ErrorCodes.INVALID_PARAMETER,"type must be one of "+b);return i.default.warn("updateRecordStreams - "+n),void r(n)}if("[object Array]"!==Object.prototype.toString.call(e.streams)){n=l.createError(l.ErrorCodes.INVALID_PARAMETER,"streams must be an array");return i.default.warn("updateRecordStreams - "+n),void r(n)}if(!this.sessionManager){n=l.createError(l.ErrorCodes.NOT_JOIN,"please join room first");return i.default.warn("updateRecordStreams - "+n),void r(n)}switch(e.type){case"remove":this.removeMixStreams({streams:e.streams},r);break;case"add":this.addMixStreams({streams:e.streams},r);break;case"replace":var o=[];e.streams&&"[object Array]"===Object.prototype.toString.call(e.streams)&&(this.mixStreams=e.streams,o=e.streams.map((function(e){var t;switch(e.mediaType){case"screen":t=s.ENUM_MEDIA_TYPE.desktop;break;case"camera":default:t=s.ENUM_MEDIA_TYPE.camera}return{user_id:e.uid,media_type:t}})));var a={layout:-1,addstreammode:-1,watertype:-1};o[0]&&(a.mainviewuid=o[0].user_id,a.mainviewtype=o[0].media_type),this.mixLayout&&(a.layout=this.mixLayout),this.mixStreamMode&&(a.addstreammode=this.mixStreamMode),this.mixKeyUser&&(a.keyuser=this.mixKeyUser),this.sessionManager.updateMix(o,a,r)}},e.prototype.startRelay=function(e,t){var r=n.__assign(n.__assign({},e),{type:"relay"});this.startMix(r,(function(r,n){if("function"==typeof t)if(n){var i={Id:n.MixId,PushURL:n.PushURL?n.PushURL:e.pushURL};t(r,i)}else t(r)}))},e.prototype.stopRelay=function(e){this.stopMix({type:"relay"},(function(t,r){if("function"==typeof e)if(r){var n={Id:r.MixId,PushURL:r.PushURL};e(t,n)}else e(t)}))},e.prototype.updateRelayStreams=function(e,t){function r(e,r){if("function"==typeof t)if(r){var n={Id:r.MixId,PushURL:r.PushURL};t(e,n)}else t(e)}if(e=e||{},!b.includes(e.type)){var n=l.createError(l.ErrorCodes.INVALID_PARAMETER,"type must be one of "+b);return i.default.warn("updateRelayStreams - "+n),void r(n)}if("[object Array]"!==Object.prototype.toString.call(e.streams)){n=l.createError(l.ErrorCodes.INVALID_PARAMETER,"streams must be an array");return i.default.warn("updateRelayStreams - "+n),void r(n)}if(!this.sessionManager){n=l.createError(l.ErrorCodes.NOT_JOIN,"please join room first");return i.default.warn("updateRelayStreams - "+n),void r(n)}switch(e.type){case"remove":this.removeMixStreams(e,r);break;case"add":this.addMixStreams(e,r);break;case"replace":var o=[];e.streams&&"[object Array]"===Object.prototype.toString.call(e.streams)&&(this.mixStreams=e.streams,o=e.streams.map((function(e){var t;switch(e.mediaType){case"screen":t=s.ENUM_MEDIA_TYPE.desktop;break;case"camera":default:t=s.ENUM_MEDIA_TYPE.camera}return{user_id:e.uid,media_type:t}})));var a={layout:-1,addstreammode:-1,watertype:-1};o[0]&&(a.mainviewuid=o[0].user_id,a.mainviewtype=o[0].media_type),this.mixLayout&&(a.layout=this.mixLayout),this.mixStreamMode&&(a.addstreammode=this.mixStreamMode),this.mixKeyUser&&(a.keyuser=this.mixKeyUser),this.sessionManager.updateMix(o,a,r)}},e.prototype.updateRelayPushURL=function(e,t){function r(e,r){if("function"==typeof t)if(r){var n={Id:r.MixId,PushURL:r.PushURL};t(e,n)}else t(e)}if(e=e||{},!_.includes(e.type)){var n=l.createError(l.ErrorCodes.INVALID_PARAMETER,"type must be one of "+_);return i.default.warn("updateRelayPushURL - "+n),void r(n)}if("[object Array]"!==Object.prototype.toString.call(e.pushURL)){n=l.createError(l.ErrorCodes.INVALID_PARAMETER,"pushURL must be an array");return i.default.warn("updateRelayPushURL - "+n),void r(n)}if(!this.sessionManager){n=l.createError(l.ErrorCodes.NOT_JOIN,"please join room first");return i.default.warn("updateRelayStreams - "+n),void r(n)}switch(e.type){case"remove":var o={type:"relay",pushURL:e.pushURL};this.stopMix(o,r);break;case"add":if(!(e.pushURL.length>0))return void r(n=l.createError(l.ErrorCodes.INVALID_PARAMETER,"pushURL must be an non-empty array"));var a={layout:-1,addstreammode:-1,watertype:-1,pushurl:e.pushURL};this.mixLayout&&(a.layout=this.mixLayout);var c=[];this.mixStreamMode&&(a.addstreammode=this.mixStreamMode,this.mixStreamMode===s.ENUM_MIX_STREAM_ADD_MODE.manual&&this.mixStreams&&(c=this.mixStreams.map((function(e){var t;switch(e.mediaType){case"screen":t=s.ENUM_MEDIA_TYPE.desktop;break;case"camera":default:t=s.ENUM_MEDIA_TYPE.camera}return{user_id:e.uid,media_type:t}})))),this.mixKeyUser&&(a.keyuser=this.mixKeyUser),this.sessionManager.updateMix(c,a,r)}},e.prototype.updateRelayLayout=function(e,t){function r(e,r){if("function"==typeof t)if(r){var n={Id:r.MixId,PushURL:r.PushURL};t(e,n)}else t(e)}if((e=e||{}).layout&&"object"!=typeof e.layout){var n=l.createError(l.ErrorCodes.INVALID_PARAMETER,"layout is invalid");return i.default.warn("updateRelayLayout - "+n),void r(n)}if(!this.sessionManager){n=l.createError(l.ErrorCodes.NOT_JOIN,"please join room first");return i.default.warn("updateRelayLayout - "+n),void r(n)}var o={layout:-1,addstreammode:-1,watertype:-1};if(e.layout.mainViewUId)o.mainviewuid=e.layout.mainViewUId;else{var a=this.getUser();a&&(o.mainviewuid=a.uid)}switch(e.layout.mainViewType){case"screen":case"desktop":o.mainviewtype=s.ENUM_MEDIA_TYPE.desktop;break;case"camera":default:o.mainviewtype=s.ENUM_MEDIA_TYPE.camera}switch(e.layout.type){case"main":o.layout=s.ENUM_MIX_LAYOUT.main;break;case"custom":o.layout=s.ENUM_MIX_LAYOUT.custom,e.layout.custom&&(o.custom=e.layout.custom);break;case"customMain":o.layout=s.ENUM_MIX_LAYOUT.customMain;break;case"customFlow":o.layout=s.ENUM_MIX_LAYOUT.customFlow;break;case"single":o.layout=s.ENUM_MIX_LAYOUT.single;break;case"flow":o.layout=s.ENUM_MIX_LAYOUT.flow;break;default:this.mixLayout&&(o.layout=this.mixLayout)}o.layout&&(this.mixLayout=o.layout);var c=[];this.mixStreamMode&&(o.addstreammode=this.mixStreamMode,this.mixStreamMode===s.ENUM_MIX_STREAM_ADD_MODE.manual&&this.mixStreams&&(c=this.mixStreams.map((function(e){var t;switch(e.mediaType){case"screen":t=s.ENUM_MEDIA_TYPE.desktop;break;case"camera":default:t=s.ENUM_MEDIA_TYPE.camera}return{user_id:e.uid,media_type:t}})))),this.mixKeyUser&&(o.keyuser=this.mixKeyUser),this.sessionManager.updateMix(c,o,r)},e.prototype.createStream=function(e,t){if("function"!=typeof t&&(t=function(){}),"object"!=typeof e){var r="the options is invalid";return i.default.warn(r),void t(l.createError(l.ErrorCodes.INVALID_PARAMETER,r))}var n;e.previewId&&f.isValidString(e.previewId)&&(n=e.previewId),e.streamId&&f.isValidString(e.streamId)&&(n=e.streamId);var o={audio:!1,video:!1,screen:!1,mediaStream:e.mediaStream};if("boolean"==typeof e.audio&&(o.audio=e.audio),"boolean"==typeof e.video&&(o.video=e.video),"boolean"==typeof e.screen&&(o.screen=e.screen),"boolean"==typeof e.screenAudio&&(o.screenAudio=e.screenAudio),o.screen&&o.video&&i.default.warn("both video and screen are true, only camera's video will be used"),o.screen&&o.audio&&i.default.warn("both audio and screen are true, only microphone's audio will be used"),o.audio&&o.video&&o.screen){r="audio, video and screen cannot be true at the same time";return i.default.warn(r),void t(l.createError(l.ErrorCodes.INVALID_PARAMETER,r))}if(!(o.audio||o.video||o.screen||o.mediaStream)){r="audio, video and screen cannot be false at the same time";return i.default.warn(r),void t(l.createError(l.ErrorCodes.INVALID_PARAMETER,r))}if(["microphoneId","cameraId","extensionId","file","filePath"].forEach((function(t){o[t]=e[t]})),e.facingMode&&y.includes(e.facingMode)&&(o.facingMode=e.facingMode),!f.isValidString(o.microphoneId)){r="type error, the microphoneId is not blank or a valid string";return i.default.warn(r),void t(l.createError(l.ErrorCodes.INVALID_PARAMETER,r))}if(!f.isValidString(o.cameraId)){r="type error, the cameraId is not blank or a valid string";return i.default.warn(r),void t(l.createError(l.ErrorCodes.INVALID_PARAMETER,r))}if(o.mediaStream&&!(o.mediaStream instanceof MediaStream)){r="type error, the mediaStream is not a valid MediaStream";return i.default.warn(r),void t(l.createError(l.ErrorCodes.INVALID_PARAMETER,r))}var a=this.getUser(),s=a?a.uid:e.userId?""+e.userId:"unknown";this.previewStreamManager.createStream(s,n,o,this.profileName).then((function(e){try{t(void 0,e.convertToOuterStream())}catch(e){i.default.warn("invoke callback error ",e)}})).catch(t)},e.prototype.publishStream=function(e,t){var r=this;if(!f.streamValidator.isValidStreamId(e)){var n="type error, the streamId isnot a valid string";return i.default.warn(n),void(t&&t(l.createError(l.ErrorCodes.INVALID_PARAMETER,n)))}if(!this.sessionManager){n="please join room first";return i.default.warn(n),void(t&&t(l.createError(l.ErrorCodes.NOT_JOIN,n)))}var o=this.previewStreamManager.getStream(e);if(!o){n="stream isnot found, maybe it has already been published or destroyed";return i.default.warn(n),void(t&&t(l.createError(l.ErrorCodes.STREAM_NOT_EXISTS,n)))}this.sessionManager.publishStream(o,(function(n){r.previewStreamManager.removeStream(e,!0).then((function(){t&&t(void 0,n.convertToOuterStream())})).catch((function(e){i.default.warn("publish stream failure when remove it "+e),t&&t(e)}))}),(function(e){t&&t(e)}))},e.prototype.unpublishStream=function(e,t){var r=this;if(!f.streamValidator.isValidStreamId(e)){var n="type error, the streamId isnot a valid string";return i.default.warn(n),void(t&&t(l.createError(l.ErrorCodes.INVALID_PARAMETER,n)))}if(!this.sessionManager){n="please join room first";return i.default.warn(n),void(t&&t(l.createError(l.ErrorCodes.NOT_JOIN,n)))}var o=this.sessionManager.streamManager.getLocalStream(e);if(!o){n="stream is not found";return i.default.warn(n),void(t&&t(l.createError(l.ErrorCodes.STREAM_NOT_EXISTS,n)))}this.sessionManager.unpublishStream(o,(function(e){r.previewStreamManager.copyStream(e).then((function(n){var i;null===(i=r.sessionManager)||void 0===i||i.streamManager.removeLocalStream(e,!0),t&&t(void 0,n.convertToOuterStream())}))}),(function(e){t&&t(e)}))},e.prototype.removeStream=function(e,t){this.destroyStream(e,t)},e.prototype.destroyStream=function(e,t){if("function"!=typeof t&&(t=function(){}),!f.streamValidator.isValidStreamId(e)){var r="type error, the streamId isnot a valid string";return i.default.warn(r),void t(l.createError(l.ErrorCodes.INVALID_PARAMETER,r))}this.previewStreamManager.removeStream(e,!1).then((function(){t()})).catch((function(e){t(e)}))},e.prototype.enableAudioVolumeIndicator=function(e){f.isNil(e)?(this.audioVolumeIndicatorInterval=2e3,this.sessionManager&&this.sessionManager.enableAudioVolumeIndicator()):f.isValidNumber(e,!0)&&e>=200&&(this.audioVolumeIndicatorInterval=e,this.sessionManager&&this.sessionManager.enableAudioVolumeIndicator(e))},e.prototype.logoff=function(e,t,r){var n;switch(e){case"reconnect":n=s.ENUM_LOGOFF_TYPE.reconnect;break;case"switch":n=s.ENUM_LOGOFF_TYPE.switch;break;case"refresh":n=s.ENUM_LOGOFF_TYPE.refresh;break;case"quit":default:n=s.ENUM_LOGOFF_TYPE.quit}if(!this.sessionManager){var o="please join room first";return i.default.warn(o),void(r&&r(l.createError(l.ErrorCodes.NOT_JOIN,o)))}this.sessionManager.logoff(n,t).then((function(){r&&r()})).catch((function(e){r&&r(e)}))},e}();t.default=S},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(6),i=function(){function e(){this.emitter=new n.EventEmitter}return e.prototype.bind=function(e){e.emitter=this.emitter},e.prototype.on=function(e,t){this.emitter.on(e,t)},e.prototype.off=function(e,t){this.emitter.off(e,t)},e}();t.EventManager=i},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(2),i=r(6),o=r(20),a=r(70),s=r(13),c=r(15),u=r(35),d=r(18),f=r(40),p=r(0),l=r(36),m=r(4),h=r(5),v=r(41),g=r(10),y=r(82),E=r(3),b=r(31),_=r(83),S=r(11),T=function(){function e(){}return Object.defineProperty(e.prototype,"devinfo",{get:function(){return f.encode(this._devinfo)},enumerable:!0,configurable:!0}),e}(),w=function(){function e(e,t,r,n,o,a){var c=this;this.session=new T,this.signalManager=new b.SignalManager,this.reconnectTimes=0,this.joinRoomType=h.ENUM_JOIN_ROOM_TYPE.default,this.rpcMap={},this.joinStatus=h.ENUM_ROOM_STATUS.unjoin,this.recordId="",this.recordStreamType=h.ENUM_STREAM_TYPE.publish,this.recordMediaType=h.ENUM_MEDIA_TYPE.camera,this.recordStatus=h.ENUM_RECORD_STATUS.unrecord,this.users=[],this.isDestroyed=!1,this.ping4SyncInterval=0;var f=m.getDeviceInfo(),p=m.getSystemInfo(),v=m.getCPUInfo();this.sessionId="",this.session.app_id=e,this.session.room_token=t,this.session.room_type=r,this.session.role_type=n;var g={sdkv:d.version,agent:l.getAgent(),device:f.vendor+"_"+f.brand+"_"+f.model,system:""+p.name+p.version+"_"+p.versionName,network:""+m.getNetworkInfo().network,cpu:v.brand+"_"+v.model+"_"+v.core,mem:m.getMemInfo().capacity+"GB"};this.session._devinfo=g,this.innerEmitter=new i.EventEmitter,this.innerEmitter.on("mediaStreamPublished",this.onMediaStreamPublished.bind(this)),this.innerEmitter.on("mediaStreamSubscribed",this.onMediaStreamSubscribed.bind(this)),this.innerEmitter.on("screenMediaStreamEnded",this.onScreenMediaStreamEnded.bind(this)),this.innerEmitter.on("streamConnectionClosed",this.onStreamConnectionClosed.bind(this)),this.innerEmitter.on("streamConnectionReconnecting",this.onStreamConnectionReconnecting.bind(this)),this.innerEmitter.on("streamConnectionReconnected",this.onStreamConnectionReconnected.bind(this)),this.innerEmitter.on("streamConnectionDisconnected",this.onStreamConnectionDisconnected.bind(this)),this.innerEmitter.on("stream-playing",(function(e){var t;null===(t=c._emitter)||void 0===t||t.emit("stream-playing",e.convertToOuterStream())})),this.innerEmitter.on("stream-paused",(function(e){var t;null===(t=c._emitter)||void 0===t||t.emit("stream-paused",e.convertToOuterStream())})),this.innerEmitter.on("player-status-change",(function(e){var t;null===(t=c._emitter)||void 0===t||t.emit("player-status-change",e)})),this.streamManager=new s.StreamManager(o,a),this.logReporter=new u.LogReporter,this.streamManager.emitter=this.innerEmitter,this.streamManager.logReporter=this.logReporter,this.networkQualityEvaluator=new y.NetworkQualityEvaluator(this.streamManager),this.networkQualityEvaluator.on("network-quality",(function(e,t){var r;null===(r=c._emitter)||void 0===r||r.emit("network-quality",{uplink:y.NetworkQualityEvaluator.convert2Quality(e),downlink:y.NetworkQualityEvaluator.convert2Quality(t)})})),this.networkQualityEvaluator.on("network-evaluation",(function(e){var t=e[0],r=e[1];t||r?c.signalManager.punish():c.signalManager.award()}))}return Object.defineProperty(e.prototype,"emitter",{set:function(e){this._emitter=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isJoinedRoom",{get:function(){return this.joinStatus===h.ENUM_ROOM_STATUS.joined},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isRecording",{get:function(){return this.recordStatus===h.ENUM_RECORD_STATUS.recording},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"user",{get:function(){return{user_id:this.session.user_id}},enumerable:!0,configurable:!0}),e.prototype.openSignalSwitch=function(){var e=this.signalSwitchConfig.push_threshold,t=e.rtt,r=e.lost,n=e.bandwidth,i=this.signalSwitchConfig.pull_threshold,o=i.rtt,a=i.lost,s=i.bandwidth;p.default.debug("\n 开启弱网自动切换功能,上行阈值 rtt:"+t+" loss:"+r+" bandwidth:"+n+",下行阈值 rtt:"+o+" loss:"+a+" bandwidth:"+s),this.networkQualityEvaluator.startEvaluate({upLossRate:r,downLossRate:a})},e.prototype.connect=function(e){var t=this;this.socketManager=new a.SocketManager(e),this.socketManager.init((function(e){var r;try{r=JSON.parse(e.data)}catch(e){return void p.default.error("socket onmessage ",e)}if(r){var n=t.rpcMap[r.rpc_id]||{},i=n.req,o=n.resource,a=t.rpcMap[r.rpc_id]||{},s=a.onSuccess,c=a.onFailure;if(delete t.rpcMap[r.rpc_id],p.default.debug("socket request: ",i),p.default.debug("socket response: ",r),i){if("function"!=typeof s&&(s=function(){}),0!==r.err){if("queymix"===i.method&&"can't find job"===r.msg)return void t.onQueryMix(void 0,s);if("startmix"===i.method&&i.data&&i.data.type!==h.ENUM_MIX_TYPE.update&&(1072===r.err||1073===r.err)){var u=new Promise((function(e,r){t.queryMix((function(t,n){t?(p.default.warn("start & query mix ",t),r(t)):(p.default.debug("start & query mix ",n),e(n))}))})),d=new Promise((function(e,r){var n=i.data.config,o=i.data.streams||[],a={layout:n.layout,watertype:n.watertype,addstreammode:n.addstreammode};n.pushurl&&n.pushurl.length>0&&(a.pushurl=n.pushurl),n.custom&&n.custom.length>0&&(a.custom=n.custom),n.layouts&&n.layouts.length>0&&(a.layouts=n.layouts),n.mainviewuid&&(a.mainviewuid=n.mainviewuid),n.mainviewtype&&n.mainviewtype>=0&&(a.mainviewtype=n.mainviewtype),n.waterpos&&n.waterpos>=0&&(a.waterpos=n.waterpos),n.waterurl&&(a.waterurl=n.waterurl),t.updateMix(o,a,(function(t,n){t?(p.default.warn("start & update mix ",t),r(t)):(p.default.debug("start & update mix ",n),e(n))}))}));return void Promise.all([u,d]).then((function(e){s&&s(e[0])})).catch((function(e){c&&c(e)}))}return"stopmix"===i.method&&1040===r.err?(p.default.debug("onStopMix 1040"),void(s&&s({}))):void("function"==typeof c?c(E.createError(""+r.err,r.msg)):t.onError({method:i.method,code:""+r.err,msg:r.msg}))}switch("function"!=typeof c&&(c=function(){}),i.method){case"joinroom":switch(t.joinStatus){case h.ENUM_ROOM_STATUS.joining:t.onJoinRoom(r.data,s);break;case h.ENUM_ROOM_STATUS.rejoining:t.onRejoinRoom(r.data,s);break;default:p.default.warn("ignore, room status is "+h.ENUM_ROOM_STATUS[t.joinStatus])}break;case"leaveroom":t.onLeaveRoom(r.data,s);break;case"subscribe":t.onSubscribe({streamsub_id:r.data.streamsub_id,stream_id:r.data.stream_id,media_type:r.data.media_type,user_id:i.data.dst.user_id},s,c,o);break;case"unsubscribe":t.onUnsubscribe(r.data,s,c,o);break;case"publish":t.onPublish(r.data,s,c,o);break;case"unpublish":t.onUnpublish(r.data,s,c,o);break;case"sdp":r.data.stream_type===h.ENUM_STREAM_TYPE.publish&&t.onSdpPublish(r.data,s,c,o),r.data.stream_type===h.ENUM_STREAM_TYPE.subscribe&&t.onSdpSubscribe(r.data,s,c,o);break;case"mute":s();break;case"startrecord":t.onStartRecord(r.data,s);break;case"stoprecord":t.onStopRecord(r.data,s);break;case"startmix":t.onStartMix(r.data,s);break;case"stopmix":t.onStopMix(r.data,s);break;case"queymix":t.onQueryMix(r.data,s);break;case"addmixstream":t.onAddMixStreams(r.data,s);break;case"delmixstream":t.onRemoveMixStreams(r.data,s);break;case"logoff":t.onLogoff(r.data,s);break;case"updatevp":t.onUpdateVP(r.data,s);break;case"ping":t.onPing4Sync(r.data,s);break;case"syncroom":t.onSyncRoom(r.data,s)}}else switch(r.method){case"userst":r.data.cmdtype===h.ENUM_USER_CMD_TYPE.userJoin&&t.onUserJoin(r.data),r.data.cmdtype===h.ENUM_USER_CMD_TYPE.userLeave&&t.onUserLeave(r.data);break;case"streamst":r.data.cmdtype===h.ENUM_STREAM_CMD_TYPE.add&&t.onAddStream(r.data),r.data.cmdtype===h.ENUM_STREAM_CMD_TYPE.remove&&t.onRemoveStream(r.data);break;case"transportclose":t.onTransportClose(r.data);break;case"transporttimeout":t.onTransportTimeout(r.data);break;case"trackst":switch(r.data.track_type){case h.ENUM_TRACK_TYPE.audio:t.onAudioTrackst(r.data);break;case h.ENUM_TRACK_TYPE.video:t.onVideoTrackst(r.data);break;case h.ENUM_TRACK_TYPE.data:t.onDataTrackst(r.data);break;default:p.default.warn("trackst unknown track type ",r.data.track_type)}break;case"kickoff":t.onKickoff(r.data);break;case"mixnotify":t.onMixNotify(r.err,r.msg,r.data);break;case"logoffnotify":t.onLogoffNotify(r.data)}}else p.default.warn("socket receives message ",r)}),(function(e,r){var n,i,o,a,s,c,u;p.default.debug("connection-state-change ",e,r),"CLOSED"===e&&"CONNECTING"===r&&(t.joinStatus===h.ENUM_ROOM_STATUS.joining?null===(n=t._emitter)||void 0===n||n.emit("connection-state-change",{previous:e,current:r}):t.joinStatus===h.ENUM_ROOM_STATUS.joined||t.joinStatus===h.ENUM_ROOM_STATUS.rejoining?(t.clearCachedRPC(),0===t.reconnectTimes&&(null===(i=t._emitter)||void 0===i||i.emit("connection-state-change",{previous:"OPEN",current:"RECONNECTING"})),t.reconnectTimes+=1):p.default.warn("connection exception ",e,r)),"OPEN"===e&&"CLOSED"===r&&p.default.warn("connection is closed and will reconnect automatically"),"CONNECTING"!==e&&"CLOSED"!==e||"CLOSED"!==r||t.reconnectTimes>=60&&(p.default.error("connection is closed and reconnect failed"),t.reconnectTimes=0,null===(o=t.socketManager)||void 0===o||o.destroy(),t.socketManager=void 0,t.destroy(),null===(a=t._emitter)||void 0===a||a.emit("connection-state-change",{previous:"RECONNECTING",current:r})),"CONNECTING"!==e&&"OPEN"!==e||"OPEN"!==r||(0===t.reconnectTimes&&t.joinRoomType!==h.ENUM_JOIN_ROOM_TYPE.reconnect?null===(s=t._emitter)||void 0===s||s.emit("connection-state-change",{previous:e,current:r}):t.joinStatus===h.ENUM_ROOM_STATUS.joined&&t.rejoinRoom().then((function(){var e;p.default.info("rejoin room successfully"),t.reconnectTimes=0,null===(e=t._emitter)||void 0===e||e.emit("connection-state-change",{previous:"RECONNECTING",current:"OPEN"})})).catch((function(e){p.default.error("rejoin room unsuccessfully with error: ",e),0===t.reconnectTimes&&(t.reconnectTimes+=1)}))),"OPEN"===e&&"CLOSING"===r&&(null===(c=t._emitter)||void 0===c||c.emit("connection-state-change",{previous:e,current:r})),"CLOSING"===e&&"CLOSED"===r&&(null===(u=t._emitter)||void 0===u||u.emit("connection-state-change",{previous:e,current:r}))}),(function(e){var r;p.default.debug("connection-error ",e),null===(r=t._emitter)||void 0===r||r.emit("connection-error",e)}));return this.socketManager.initHeartBeat((function(){var e={method:"ping",version:.1,rpc_id:l.getId(),data:{}};return JSON.stringify(e)}),3e4),this.socketManager.connect()},e.prototype.clearCachedRPC=function(){for(var e in this.rpcMap){var t=(this.rpcMap[e]||{}).onFailure;t&&t(E.createError(E.ErrorCodes.BAD_REQUEST,"request failed")),delete this.rpcMap[e]}},e.prototype.disconnect=function(e){var t=this;this.reconnectTimes=0,this.socketManager&&this.socketManager.close(1e3,e||"disconnect").catch((function(e){p.default.error("connect close - ",e)})).finally((function(){t.socketManager&&t.socketManager.destroy(),t.socketManager=void 0}))},e.prototype.send=function(e,t,r,n,i){var o=this,a=l.getId(),s=.1;"ping"===e&&(s=1.1);var c={method:e,version:s,rpc_id:a,data:t};this.rpcMap[a]={req:c,onSuccess:r,onFailure:n,resource:i};var u=JSON.stringify(c);if(this.socketManager)this.socketManager.send(u).catch((function(e){n&&n(e),delete o.rpcMap[a]}));else{n&&n(E.createError(E.ErrorCodes.OTHERS,"connection isnot open")),delete this.rpcMap[a]}},e.prototype.destroy=function(){var e,t=this;this.isDestroyed=!0,setTimeout((function(){t._emitter=void 0}),0),this.rpcMap={},this.users=[],this.networkQualityEvaluator.destory(),this.logReporter.destroy(),null===(e=this.audioVolumeIndicator)||void 0===e||e.destroy(),this.recordId="",this.recordStatus=h.ENUM_RECORD_STATUS.unrecord,this.streamManager.removeAllLocalStreams(),this.streamManager.removeAllRemoteStreams()},e.prototype.getGW=function(){return n.__awaiter(this,void 0,void 0,(function(){var e,t,r;return n.__generator(this,(function(n){switch(n.label){case 0:e={Action:"rsugetrtcgateway",rpc_id:l.getId(),user_id:this.session.user_id,room_id:this.session.room_id,app_id:this.session.app_id,token:this.session.room_token,devinfo:this.session.devinfo},n.label=1;case 1:return n.trys.push([1,3,,4]),[4,o.get({data:e})];case 2:return[2,n.sent().data];case 3:if(!(t=n.sent()).message||"timeout"!==t.message.toLowerCase())throw t;return p.default.warn("rsugetrtcgateway first time failed ",t),this.logReporter.reportExceptionLog(u.ENUM_LOG_EXCEPTION_TYPE.others,{msg:"rsugetrtcgateway first time failed "+t}),[3,4];case 4:return n.trys.push([4,6,,7]),[4,o.get({data:e})];case 5:return[2,n.sent().data];case 6:throw r=n.sent(),p.default.warn("rsugetrtcgateway second time failed ",r),this.logReporter.reportExceptionLog(u.ENUM_LOG_EXCEPTION_TYPE.others,{msg:"rsugetrtcgateway second time failed "+r}),r;case 7:return[2]}}))}))},e.prototype.getLiveGW=function(){return n.__awaiter(this,void 0,void 0,(function(){var e,t,r;return n.__generator(this,(function(n){switch(n.label){case 0:e={Action:"rsugetlivegateway",rpc_id:l.getId(),user_id:this.session.user_id,room_id:this.session.room_id,app_id:this.session.app_id,token:this.session.room_token,role:this.session.role_type,devinfo:this.session.devinfo},n.label=1;case 1:return n.trys.push([1,3,,4]),[4,o.get({data:e})];case 2:return[2,n.sent().data];case 3:if(!(t=n.sent()).message||"timeout"!==t.message.toLowerCase())throw t;return p.default.warn("rsugetlivegateway first time failed ",t),this.logReporter.reportExceptionLog(u.ENUM_LOG_EXCEPTION_TYPE.others,{msg:"rsugetlivegateway first time failed "+t}),[3,4];case 4:return n.trys.push([4,6,,7]),[4,o.get({data:e})];case 5:return[2,n.sent().data];case 6:throw r=n.sent(),p.default.warn("rsugetlivegateway second time failed ",r),this.logReporter.reportExceptionLog(u.ENUM_LOG_EXCEPTION_TYPE.others,{msg:"rsugetlivegateway second time failed "+r}),r;case 7:return[2]}}))}))},e.prototype.setRole=function(e){this.session.role_type=e},e.prototype.joinRoom=function(e,t,r,n){var i=this,o="";switch(this.joinStatus){case h.ENUM_ROOM_STATUS.rejoining:case h.ENUM_ROOM_STATUS.joining:return o="you are joining the room",p.default.debug("joinRoom - ",o),void n(o);case h.ENUM_ROOM_STATUS.leaving:return o="you are leaving the room",p.default.debug("joinRoom - ",o),void n(o);case h.ENUM_ROOM_STATUS.joined:return o="you have already joined the room",p.default.debug("joinRoom - ",o),void n(o);case h.ENUM_ROOM_STATUS.unjoin:}this.joinStatus=h.ENUM_ROOM_STATUS.joining,this.session.room_id=e,this.session.user_id=t,this.logReporter.init(this.session.app_id,e,t);var a=function(){var e;p.default.debug("joinRoom success"),i.joinStatus=h.ENUM_ROOM_STATUS.joined,(null===(e=i.signalSwitchConfig)||void 0===e?void 0:e.switch_on)&&i.openSignalSwitch(),r(v.convertToOuterUser(i.user))},s=function(e){i.logReporter.reportExceptionLog(u.ENUM_LOG_EXCEPTION_TYPE.joinRoom,{msg:""+e}),i.destroy(),i.session.user_id="",i.session.room_id="",i.joinStatus=h.ENUM_ROOM_STATUS.unjoin,n(e)},c=function(e,t,r){i.connect(e).then((function(){var e={app_id:i.session.app_id,room_id:i.session.room_id,user_id:i.session.user_id,authtoken:i.session.room_token,devinfo:i.session.devinfo,role_type:i.session.role_type,room_type:i.session.room_type,sessionid:i.sessionId,cmdtype:i.joinRoomType,whiteid:navigator.userAgent};i.send("joinroom",e,(function(e){i.joinRoomType=h.ENUM_JOIN_ROOM_TYPE.reconnect,t(e)}),r)})).catch(r)};if(g.SERVER_CONFIG.signal){if(!/^wss:\/\/[\w\-\.]+:\d+$/i.test(g.SERVER_CONFIG.signal))return void s(E.createError(E.ErrorCodes.INVALID_PARAMETER,"invalid signal address "+g.SERVER_CONFIG.signal));var d=g.SERVER_CONFIG.signal.match(/[\w\-\.]+/gi);if(!(d&&d.length>=3))return void s(E.createError(E.ErrorCodes.INVALID_PARAMETER,"invalid signal address "+g.SERVER_CONFIG.signal));this.signalManager.add(new b.Signal(d[1],d[2],1)),c(this.signalManager,a,s)}else this.session.room_type===h.ENUM_ROOM_TYPE.live?this.getLiveGW().then((function(e){var t,r=e.access_token,n=e.auto_switch;p.default.debug("getLiveGW token ",r),n&&(i.signalSwitchConfig=n);try{t=f.decode(r),p.default.debug("getLiveGW token ",t)}catch(e){throw E.createError(E.ErrorCodes.SERVER_API,"get invalid access token "+r)}if(!(t.length>=0))throw E.createError(E.ErrorCodes.SERVER_API,"get blank access token "+r);t.forEach((function(e){i.signalManager.add(new b.Signal(e.singal,e.port,e.ssl))})),c(i.signalManager,a,s)})).catch(s):this.getGW().then((function(e){var t,r=e.access_token,n=e.auto_switch;p.default.debug("getGW token ",r),n&&(i.signalSwitchConfig=n);try{t=f.decode(r)}catch(e){throw E.createError(E.ErrorCodes.SERVER_API,"get invalid access token "+r)}if(!(t.length>=0))throw E.createError(E.ErrorCodes.SERVER_API,"get blank access token "+r);t.forEach((function(e){i.signalManager.add(new b.Signal(e.singal,e.port,e.ssl))})),c(i.signalManager,a,s)})).catch(s);this.ping4SyncInterval=window.setInterval((function(){var e;(null===(e=i.socketManager)||void 0===e?void 0:e.isOpened)&&i.ping4Sync().catch((function(e){return p.default.debug("ping ",e)}))}),5e3)},e.prototype.onJoinRoom=function(e,t){var r=this,n=e.users,i=void 0===n?[]:n,o=e.streams,a=void 0===o?[]:o;p.default.debug("onJoinRoom ",i,a),i=i||[],a=a||[],this.users=i.filter((function(e){return e.user_id!==r.user.user_id})),a.forEach((function(e){e.uid!==r.user.user_id&&r.streamManager.createRemoteStream(e)})),a.forEach((function(e){e.uid!==r.user.user_id&&(r.users.findIndex((function(t){return t.user_id===e.uid}))<0&&r.users.push({user_id:e.uid}))})),this.logReporter.reportJoinRoomLog(),t(),setTimeout((function(){r.users.forEach((function(e){r._emitter&&r._emitter.emit("user-added",v.convertToOuterUser(e))})),r.streamManager.getAllRemoteStreams().forEach((function(e){r._emitter&&r._emitter.emit("stream-added",e.convertToOuterStream())}))}),0)},e.prototype.refreshSignal=function(){var e=this;return new Promise((function(t,r){g.SERVER_CONFIG.signal?t([[],void 0]):e.session.room_type===h.ENUM_ROOM_TYPE.live?e.getLiveGW().then((function(e){var n,i=e.access_token,o=e.auto_switch;p.default.debug("refresh signal - getLiveGW token ",i);try{n=f.decode(i),p.default.debug("getLiveGW token ",n)}catch(e){return void r(E.createError(E.ErrorCodes.SERVER_API,"get invalid access token "+i))}if(n.length<=0)r(E.createError(E.ErrorCodes.SERVER_API,"get blank access token "+i));else{var a=n.map((function(e){return new b.Signal(e.singal,e.port,e.ssl)}));t([a,o])}})).catch(r):e.getGW().then((function(e){var n,i=e.access_token,o=e.auto_switch;p.default.debug("getGW token ",i);try{n=f.decode(i)}catch(e){return void r(E.createError(E.ErrorCodes.SERVER_API,"get invalid access token "+i))}if(n.length<=0)r(E.createError(E.ErrorCodes.SERVER_API,"get blank access token "+i));else{var a=n.map((function(e){return new b.Signal(e.singal,e.port,e.ssl)}));t([a,o])}})).catch(r)}))},e.prototype.rejoinRoom=function(){var e=this;if(!this.socketManager||!this.socketManager.isOpened)return Promise.reject(E.createError(E.ErrorCodes.SOCKET_DISCONNECTED,"connection isnot open"));var t="";switch(this.joinStatus){case h.ENUM_ROOM_STATUS.rejoining:case h.ENUM_ROOM_STATUS.joining:return t="you are joining the room",p.default.debug("rejoinRoom - ",t),Promise.reject(t);case h.ENUM_ROOM_STATUS.leaving:return t="you are leaving the room",p.default.debug("rejoinRoom - ",t),Promise.reject(t);case h.ENUM_ROOM_STATUS.unjoin:return t="you have not joined the room",p.default.debug("rejoinRoom - ",t),Promise.reject(t);case h.ENUM_ROOM_STATUS.joined:}return this.joinStatus=h.ENUM_ROOM_STATUS.rejoining,new Promise((function(t,r){var n={app_id:e.session.app_id,room_id:e.session.room_id,user_id:e.session.user_id,authtoken:e.session.room_token,devinfo:e.session.devinfo,role_type:e.session.role_type,room_type:e.session.room_type,sessionid:e.sessionId,cmdtype:e.joinRoomType};setTimeout((function(){e.send("joinroom",n,(function(){var r;p.default.debug("rejoinRoom success"),e.joinStatus=h.ENUM_ROOM_STATUS.joined,e.joinRoomType=h.ENUM_JOIN_ROOM_TYPE.reconnect,(null===(r=e.signalSwitchConfig)||void 0===r?void 0:r.switch_on)&&e.openSignalSwitch(),t()}),(function(t){e.joinStatus=h.ENUM_ROOM_STATUS.joined,r(t)}))}),0)}))},e.prototype.onRejoinRoom=function(e,t){var r=this,n=e.users,i=void 0===n?[]:n,o=e.streams,a=void 0===o?[]:o;p.default.debug("onRejoinRoom ",i,a),t(),a=a||[];var s=[],c=[],u=[];(i=i||[]).forEach((function(e){e.user_id!==r.user.user_id&&(r.users.findIndex((function(t){return t.user_id===e.user_id}))>=0?s.push(e):c.push(e))})),this.users.forEach((function(e){s.findIndex((function(t){return t.user_id===e.user_id}))<0&&u.push(e)}));var d=this.streamManager.getAllRemoteStreams(),f=[],l=[],m=[];a.forEach((function(e){e.uid!==r.user.user_id&&(d.findIndex((function(t){return t.streamId===e.sid}))>=0?f.push(e):l.push(e))})),d.forEach((function(e){f.findIndex((function(t){return t.sid===e.streamId}))<0&&m.push(e)})),f.forEach((function(e){var t,n=r.streamManager.getRemoteStream(e.sid);if((p.default.info("onRejoin - remote stream will resubscribe ",n),n)&&(n.status!==h.ENUM_SUBSCRIBE_STATUS.unsubscribe&&n.status!==h.ENUM_SUBSCRIBE_STATUS.unsubscribing)){p.default.debug("onRejoin - remote stream will resubscribe ",n);var i=null===(t=r.socketManager)||void 0===t?void 0:t.connectId;r.resubscribe(n).catch((function(e){var t;return i!==(null===(t=r.socketManager)||void 0===t?void 0:t.connectId)?Promise.resolve():e.name===E.ErrorCodes.SOCKET_DISCONNECTED||e.name===E.ErrorCodes.NOT_JOIN||e.name===E.InnerErrorCodes.RESUBSCRIBING?Promise.resolve():(p.default.warn("resubscribe - [rejoin], "+e),new Promise((function(e,t){setTimeout((function(){r.resubscribe(n).then(e).catch(t)}),2e3)})))})).catch((function(e){var t;return i!==(null===(t=r.socketManager)||void 0===t?void 0:t.connectId)?Promise.resolve():e.name===E.ErrorCodes.SOCKET_DISCONNECTED||e.name===E.ErrorCodes.NOT_JOIN||e.name===E.InnerErrorCodes.RESUBSCRIBING?Promise.resolve():(p.default.error("resubscribe2 - [rejoin], "+e),new Promise((function(e,t){setTimeout((function(){r.resubscribe(n).then(e).catch(t)}),4e3)})))})).catch((function(e){var t;if(i!==(null===(t=r.socketManager)||void 0===t?void 0:t.connectId))return Promise.resolve();p.default.error("resubscribe3 - [rejoin], "+e),r.streamManager.removeRemoteStream(n),r._emitter&&r._emitter.emit("stream-removed",n.convertToOuterStream()),r.syncRoom().catch((function(e){p.default.debug("sync room failed ",e),p.default.report("sync room failed in resubscribe [rejoin] ",e)}))}))}}));var g=s.concat(c);a.forEach((function(e){e.uid!==r.user.user_id&&(g.findIndex((function(t){return t.user_id===e.uid}))<0&&(g.push({user_id:e.uid}),c.push({user_id:e.uid})))})),this.users=s.concat(c),u.forEach((function(e){r._emitter&&r._emitter.emit("user-removed",v.convertToOuterUser(e))})),c.forEach((function(e){r._emitter&&r._emitter.emit("user-added",v.convertToOuterUser(e))})),m.forEach((function(e){r.streamManager.removeRemoteStream(e),r._emitter&&r._emitter.emit("stream-removed",e.convertToOuterStream())})),l.forEach((function(e){var t=r.streamManager.createRemoteStream(e);t&&r._emitter&&r._emitter.emit("stream-added",t.convertToOuterStream())})),this.streamManager.getAllLocalStreams().forEach((function(e){var t;p.default.debug("onRejoin - local stream will republish ",e);var n=null===(t=r.socketManager)||void 0===t?void 0:t.connectId;r.republish(e).catch((function(t){var i;return n!==(null===(i=r.socketManager)||void 0===i?void 0:i.connectId)?Promise.resolve():t.name===E.ErrorCodes.SOCKET_DISCONNECTED||t.name===E.ErrorCodes.NOT_JOIN||t.name===E.InnerErrorCodes.REPUBLISHING?Promise.resolve():(p.default.warn("republish - [rejoin], "+t),new Promise((function(t,n){setTimeout((function(){r.republish(e).then(t).catch(n)}),2e3)})))})).catch((function(t){var i;return n!==(null===(i=r.socketManager)||void 0===i?void 0:i.connectId)?Promise.resolve():t.name===E.ErrorCodes.SOCKET_DISCONNECTED||t.name===E.ErrorCodes.NOT_JOIN||t.name===E.InnerErrorCodes.REPUBLISHING?Promise.resolve():(p.default.error("republish2 - [rejoin], "+t),new Promise((function(t,n){setTimeout((function(){r.republish(e).then(t).catch(n)}),4e3)})))})).catch((function(t){p.default.debug("republish3 - [rejoin], "+e.streamId+" "+t),p.default.report("republish3 - [rejoin], "+e.streamId+" "+t)}))}))},e.prototype.ping4Sync=function(){var e=this;if(!this.isJoinedRoom){var t="you have not joined the room";return p.default.debug("ping for syncing room - ",t),Promise.reject(E.createError(E.ErrorCodes.NOT_JOIN,t))}return new Promise((function(t,r){var n={app_id:e.session.app_id,room_id:e.session.room_id,user_id:e.session.user_id};e.send("ping",n,(function(){p.default.debug("ping success"),t()}),r)}))},e.prototype.onPing4Sync=function(e,t){p.default.debug("onPing ",e),t(),this.roomVersion!==e.version&&(this.roomVersion=e.version,this.syncRoom().catch((function(e){p.default.debug("sync room failed ",e),p.default.report("sync room failed ",e)})))},e.prototype.syncRoom=function(){var e=this;if(!this.isJoinedRoom){var t="you have not joined the room";return p.default.warn("sync room - ",t),Promise.reject(E.createError(E.ErrorCodes.NOT_JOIN,t))}return new Promise((function(t,r){var n={app_id:e.session.app_id,room_id:e.session.room_id,user_id:e.session.user_id};e.send("syncroom",n,(function(){p.default.debug("syncroom success"),t()}),r)}))},e.prototype.onSyncRoom=function(e,t){var r=this,n=e.users,i=void 0===n?[]:n,o=e.streams,a=void 0===o?[]:o;p.default.debug("onSyncRoom ",i,a),a=a||[];var s=[],c=[],u=[];(i=i||[]).forEach((function(e){e.user_id!==r.user.user_id&&(r.users.findIndex((function(t){return t.user_id===e.user_id}))>=0?s.push(e):c.push(e))})),this.users.forEach((function(e){s.findIndex((function(t){return t.user_id===e.user_id}))<0&&u.push(e)}));var d=this.streamManager.getAllRemoteStreams(),f=[],l=[],m=[];a.forEach((function(e){e.uid!==r.user.user_id&&(d.findIndex((function(t){return t.streamId===e.sid}))>=0?f.push(e):l.push(e))})),d.forEach((function(e){f.findIndex((function(t){return t.sid===e.streamId}))<0&&m.push(e)}));var g=s.concat(c);a.forEach((function(e){e.uid!==r.user.user_id&&(g.findIndex((function(t){return t.user_id===e.uid}))<0&&(g.push({user_id:e.uid}),c.push({user_id:e.uid})))})),this.users=s.concat(c),c.forEach((function(e){r._emitter&&r._emitter.emit("user-added",v.convertToOuterUser(e))})),u.forEach((function(e){r._emitter&&r._emitter.emit("user-removed",v.convertToOuterUser(e))})),f.forEach((function(e){var t=r.streamManager.getRemoteStream(e.sid);t&&(t.sourceAudioMuted!==e.muteaudio&&r.onAudioTrackst({user_id:e.uid,stream_id:e.sid,mute:e.muteaudio,track_type:h.ENUM_TRACK_TYPE.audio,media_type:e.media_type}),t.sourceVideoMuted!==e.mutevideo&&r.onVideoTrackst({user_id:e.uid,stream_id:e.sid,mute:e.mutevideo,track_type:h.ENUM_TRACK_TYPE.video,media_type:e.media_type}))})),m.forEach((function(e){r.streamManager.removeRemoteStream(e),r._emitter&&r._emitter.emit("stream-removed",e.convertToOuterStream())})),l.forEach((function(e){var t=r.streamManager.createRemoteStream(e);t&&r._emitter&&r._emitter.emit("stream-added",t.convertToOuterStream())})),t()},e.prototype.leaveRoom=function(e,t,r){var n=this,i="";switch(this.joinStatus){case h.ENUM_ROOM_STATUS.unjoin:return i="you have not joined the room",p.default.debug("leaveRoom - ",i),void r(E.createError(E.ErrorCodes.NOT_JOIN,i));case h.ENUM_ROOM_STATUS.joining:return i="you are joining the room",p.default.debug("leaveRoom - ",i),void r(E.createError(E.ErrorCodes.JOINING,i));case h.ENUM_ROOM_STATUS.leaving:return i="you are leaving the room",r(E.createError(E.ErrorCodes.LEAVING,i)),void r(i);case h.ENUM_ROOM_STATUS.joined:case h.ENUM_ROOM_STATUS.rejoining:}this.joinStatus=h.ENUM_ROOM_STATUS.leaving,this.isRecording&&!e.keepRecording&&this.socketManager&&this.stopRecording((function(){p.default.debug("leave room - stopRecording ")}),(function(e){p.default.warn("leave room - stop recording failed ",e)})),this.streamManager.getAllLocalStreams().forEach((function(e){e.connectionState!==c.ENUM_STREAM_CONNECTION_STATE.disconnected?(e.canUnPublish&&n.socketManager&&n._unpublish(e,(function(){p.default.info("leave room - unpublish success")}),(function(e){p.default.warn("leave room - unpublish failed ",e)})),e.close()):n.streamManager.removeLocalStream(e)})),this.streamManager.getAllRemoteStreams().forEach((function(e){e.connectionState!==c.ENUM_STREAM_CONNECTION_STATE.disconnected?(e.canUnSubscribe&&n.socketManager&&n._unsubscribe(n.user.user_id,e,(function(){p.default.info("leave room - unsubscribe success")}),(function(e){p.default.warn("leave room - unsubscribe failed ",e)})),e.close()):n.streamManager.removeRemoteStream(e)}));var o=function(){p.default.debug("leaveRoom success"),n.joinStatus=h.ENUM_ROOM_STATUS.unjoin,n.disconnect("leave room"),n.destroy(),t(v.convertToOuterUser(n.user))};this.socketManager&&this.socketManager.isOpened?this.send("leaveroom",{room_id:this.session.room_id},o,(function(e){p.default.debug("leaveRoom failed ",e),n.joinStatus=h.ENUM_ROOM_STATUS.joined,r(e)})):o(),window.clearInterval(this.ping4SyncInterval)},e.prototype.onLeaveRoom=function(e,t){p.default.debug("onLeaveRoom ",e),t()},e.prototype.publish=function(e,t,r){var n=this,i="";if(!this.isJoinedRoom)return i="you have not joined the room",p.default.warn("publish - ",i),void r(E.createError(E.ErrorCodes.NOT_JOIN,i));if(this.session.role_type===h.ENUM_ROLE_TYPE.pullStream)return i="role type is pull",p.default.warn("publish - ",i),void r(E.createError(E.ErrorCodes.ROLE_TYPE_NOT_MATCH,i));var o=s.StreamManager.generatePublishConfig(e),a=this.streamManager.getAllLocalStreams().find((function(e){return e.mediaType===o.mediaType}));if(a){var c=void 0;switch(a.mediaType){case h.ENUM_MEDIA_TYPE.desktop:c="screen";break;case h.ENUM_MEDIA_TYPE.camera:default:c="camera"}return i="the stream with "+c+" type exists, only one "+c+" stream can be published",p.default.warn(i),void r(E.createError(E.ErrorCodes.STREAM_EXISTS,i))}var d,f=function(e){p.default.debug("publish success"),n.streamManager.addLocalStream(e),t(e.convertToOuterStream())},l=function(e){p.default.warn("publish - ",e),n.logReporter.reportExceptionLog(u.ENUM_LOG_EXCEPTION_TYPE.publish,{stype:h.ENUM_STREAM_TYPE.publish,mtype:o.mediaType}),r(e)};try{d=this.streamManager.createLocalStream(this.user.user_id,o)}catch(i){return p.default.warn("publish - ",i),void l(i)}p.default.debug("create local stream ",d),d.hasVideo()&&d.updateVP(),d.status=h.ENUM_PUBLISH_STATUS.publishing;var m=function(e){n.streamManager.removeLocalStream(d),l(e)};d.init(e).then((function(){n.send("publish",{user_id:d.userId,media_type:d.mediaType,audio:d.hasAudio(),video:d.hasVideo(),data:d.data,vp:d.vp,payload:d.videoCodec},f,m,d)})).catch(m)},e.prototype.publishStream=function(e,t,r){var n=this,i="";if(!this.isJoinedRoom)return i="you have not joined the room",p.default.warn("publish - ",i),void r(E.createError(E.ErrorCodes.NOT_JOIN,i));if(this.session.role_type===h.ENUM_ROLE_TYPE.pullStream)return i="role type is pull",p.default.warn("publish - ",i),void r(E.createError(E.ErrorCodes.ROLE_TYPE_NOT_MATCH,i));var o=this.streamManager.getAllLocalStreams().find((function(t){return t.mediaType===e.mediaType}));if(o){var a=void 0;switch(o.mediaType){case h.ENUM_MEDIA_TYPE.desktop:a="screen";break;case h.ENUM_MEDIA_TYPE.camera:default:a="camera"}return i="the stream with "+a+" type exists, only one "+a+" stream can be published",p.default.warn(i),void r(E.createError(E.ErrorCodes.STREAM_EXISTS,i))}var s,c=function(e){p.default.debug("publish success"),e.audioMuted&&n.muteAudioSync(e,e.audioMuted),e.videoMuted&&n.muteVideoSync(e,e.videoMuted),n.streamManager.addLocalStream(e),t(e)},d=function(t){p.default.warn("publish - ",t),n.logReporter.reportExceptionLog(u.ENUM_LOG_EXCEPTION_TYPE.publish,{stype:h.ENUM_STREAM_TYPE.publish,mtype:e.mediaType}),r(t)};try{s=this.streamManager.createLocalStream(this.user.user_id,e.config)}catch(i){return p.default.warn("publish - ",i),void d(i)}p.default.debug("create local stream ",s),s.status=h.ENUM_PUBLISH_STATUS.publishing;var f=function(e){n.streamManager.removeLocalStream(s),d(e)};s.init({},e).then((function(){s.hasVideo()&&s.updateVP(),n.send("publish",{user_id:s.userId,media_type:s.mediaType,audio:s.hasAudio(),video:s.hasVideo(),data:s.data,vp:s.vp,payload:s.videoCodec},c,f,s)})).catch(f)},e.prototype.republish=function(e){return n.__awaiter(this,void 0,void 0,(function(){var t,r=this;return n.__generator(this,(function(n){return t=function(e,t){e.audio&&e.audioMuted&&(r.send("mute",{user_id:t.userId,stream_id:t.streamId,stream_type:t.streamType,track_type:h.ENUM_TRACK_TYPE.audio,mute:!0},(function(){p.default.info("restore mute audio success after republish")}),(function(){p.default.warn("restore mute audio failure after republish")})),t.muteAudio()),e.hasVideo()&&e.videoMuted&&(r.send("mute",{user_id:t.userId,stream_id:t.streamId,stream_type:t.streamType,track_type:h.ENUM_TRACK_TYPE.video,mute:!0},(function(){p.default.info("restore mute video success after republish")}),(function(){p.default.warn("restore mute video failure after republish")})),t.muteVideo())},[2,new Promise((function(n,i){var o;if(null===(o=r.socketManager)||void 0===o?void 0:o.isOpened)if(r.isJoinedRoom)if(e.status!==h.ENUM_PUBLISH_STATUS.republishing){e.status=h.ENUM_PUBLISH_STATUS.republishing;var a=e.convertToOuterStream();e.destroyConnection(),p.default.debug("republish old stream ",a);r.send("publish",{user_id:e.userId,media_type:e.mediaType,audio:e.hasAudio(),video:e.hasVideo(),data:e.data,vp:e.vp,payload:e.videoCodec},(function(r){var i=r.convertToOuterStream();p.default.debug("republish new stream ",i),t(e,r),e.status=h.ENUM_PUBLISH_STATUS.published,n()}),(function(t){p.default.debug("republish error",t),e.status=h.ENUM_PUBLISH_STATUS.published,i(t)}),e)}else i(E.createError(E.InnerErrorCodes.REPUBLISHING,"stream is republishing"));else i(E.createError(E.ErrorCodes.NOT_JOIN,"not joined the room"));else i(E.createError(E.ErrorCodes.SOCKET_DISCONNECTED,"socket is disconnected"))}))]}))}))},e.prototype.onPublish=function(e,t,r,n){var i=this,o=e.stream_id,a=e.media_type;p.default.debug("onPublish ",o,a),this.logReporter.reportOperationLog(u.ENUM_LOG_OPERATION_TYPE.publish,{streamId:o,stype:n.streamType,mtype:n.mediaType});var s=function(e){p.default.info("rollback publish ",e),i._unpublish(n,(function(){p.default.info("rollback publish success"),r(e)}),(function(t){p.default.warn("rollback publish failed ",t),r(e)}))};n.status!==h.ENUM_PUBLISH_STATUS.published&&n.status!==h.ENUM_PUBLISH_STATUS.republishing||(n.initConnection(),n.initMediaStream(),n.addTracks2PeerConnection()),n.connect(o).then((function(e){i.sdpPublish(n,e,(function(){t(n)}),s)})).catch(s)},e.prototype.muteAudioSync=function(e,t){this.send("mute",{user_id:e.userId,stream_id:e.streamId,stream_type:e.streamType,track_type:h.ENUM_TRACK_TYPE.audio,mute:t},(function(){p.default.info("mute audio sync success after publish")}),(function(){p.default.warn("mute audio sync failure after publish")}))},e.prototype.muteVideoSync=function(e,t){this.send("mute",{user_id:e.userId,stream_id:e.streamId,stream_type:e.streamType,track_type:h.ENUM_TRACK_TYPE.video,mute:t},(function(){p.default.info("mute video sync success after publish")}),(function(){p.default.warn("mute video sync failure after publish")}))},e.prototype.unpublish=function(e,t,r){var n,i=this,o=this.streamManager.getLocalStream(e);if(!o)return n="cannot find stream",void r(E.createError(E.ErrorCodes.STREAM_NOT_EXISTS,n));if(!o.canUnPublish)return n="the stream cannot unpublish",void r(E.createError(E.ErrorCodes.OTHERS,n));if(o.connectionState===c.ENUM_STREAM_CONNECTION_STATE.disconnected)return this.streamManager.removeLocalStream(o),void t(o.convertToOuterStream());o.status=h.ENUM_PUBLISH_STATUS.unpublishing,this.send("unpublish",{user_id:o.userId,stream_id:o.streamId,media_type:o.mediaType},(function(){i.streamManager.removeLocalStream(o),p.default.debug("unpublish success "),t(o.convertToOuterStream())}),(function(e){p.default.error("unpublish ",e),o.status=h.ENUM_PUBLISH_STATUS.published,r(e)}),o)},e.prototype.unpublishStream=function(e,t,r){this.send("unpublish",{user_id:e.userId,stream_id:e.streamId,media_type:e.mediaType},(function(){p.default.debug("unpublish success "),t(e)}),(function(t){p.default.error("unpublish ",t),e.status=h.ENUM_PUBLISH_STATUS.published,r(t)}),e)},e.prototype._unpublish=function(e,t,r){var n=this;this.send("unpublish",{user_id:e.userId,stream_id:e.streamId,media_type:e.mediaType},(function(){n.logReporter.reportOperationLog(u.ENUM_LOG_OPERATION_TYPE.unpublish,{streamId:e.streamId,stype:e.streamType,mtype:e.mediaType}),t()}),(function(e){r(E.createError(E.ErrorCodes.SERVER_API,e))}))},e.prototype.onUnpublish=function(e,t,r,n){p.default.debug("onUnpublish ",e),p.default.debug("onUnpublish placeholder ",r),n?(this.logReporter.reportOperationLog(u.ENUM_LOG_OPERATION_TYPE.unpublish,{streamId:n.streamId,stype:n.streamType,mtype:n.mediaType}),t()):t()},e.prototype.subscribe=function(e,t,r){var n=this,i="";if(!this.isJoinedRoom)return i="you have not joined the room",p.default.warn(i),void r(E.createError(E.ErrorCodes.NOT_JOIN,i));var o=this.streamManager.getRemoteStream(e);if(p.default.debug("subscribe - ",e,o),!o)return i="stream - "+e+" is not found",p.default.warn(i),void r(E.createError(E.ErrorCodes.STREAM_NOT_EXISTS,i));if(!o.canSubscribe)return i="the stream cannot be subscribed",p.default.warn(i),void r(E.createError(E.ErrorCodes.OTHERS,i));o.status=h.ENUM_SUBSCRIBE_STATUS.subscribing,this.send("subscribe",{src:{user_id:this.user.user_id,audio:o.audio,video:o.video,data:o.data},dst:{user_id:o.userId,stream_id:o.streamId,media_type:o.mediaType}},(function(e){p.default.debug("subscribe success "),t(e.convertToOuterStream())}),(function(e){p.default.debug("subscribe - ",e),o.status=h.ENUM_SUBSCRIBE_STATUS.unsubscribe,n.logReporter.reportExceptionLog(u.ENUM_LOG_EXCEPTION_TYPE.subscribe,{userId:o.userId,streamId:o.streamId,stype:o.streamType,mtype:o.mediaType}),r(e)}),o)},e.prototype.resubscribe=function(e){return n.__awaiter(this,void 0,void 0,(function(){var t=this;return n.__generator(this,(function(r){return[2,new Promise((function(r,n){var i;if(null===(i=t.socketManager)||void 0===i?void 0:i.isOpened)if(t.isJoinedRoom)if(e.status!==h.ENUM_SUBSCRIBE_STATUS.resubscribing){e.status=h.ENUM_SUBSCRIBE_STATUS.resubscribing;var o=e.convertToOuterStream();e.destroyMediaStream(),e.destroyConnection(),p.default.debug("resubscribe old stream ",o);t.send("subscribe",{src:{user_id:t.user.user_id,audio:e.audio,video:e.video,data:e.data},dst:{user_id:e.userId,stream_id:e.streamId,media_type:e.mediaType}},(function(t){var n=t.convertToOuterStream();p.default.debug("resubscribe new stream ",n),e.status=h.ENUM_SUBSCRIBE_STATUS.subscribed,r()}),(function(t){p.default.debug("resubscribe error",t),e.status=h.ENUM_SUBSCRIBE_STATUS.subscribed,n(t)}),e)}else n(E.createError(E.InnerErrorCodes.RESUBSCRIBING,"stream is resubscribing"));else n(E.createError(E.ErrorCodes.NOT_JOIN,"not joined the room"));else n(E.createError(E.ErrorCodes.SOCKET_DISCONNECTED,"socket is disconnected"))}))]}))}))},e.prototype.onSubscribe=function(e,t,r,n){var i=this,o=e.streamsub_id,a=e.stream_id,s=e.media_type,c=e.user_id;p.default.debug("onSubscribe ",o,a,s,c),this.logReporter.reportOperationLog(u.ENUM_LOG_OPERATION_TYPE.subscribe,{streamId:n.streamId,userId:n.userId,stype:n.streamType,mtype:n.mediaType});var d=function(e){p.default.debug("rollback subscribe ",e),i._unsubscribe(i.user.user_id,n,(function(){p.default.info("rollback subscribe success"),n.close(),r(E.createError(E.ErrorCodes.SERVER_API,e))}),(function(e){p.default.warn("rollback subscribe failed ",e),n.close(),r(E.createError(E.ErrorCodes.SERVER_API,e))}))};n.initConnection(),n.initMediaStream(),n.handlePeerConnectionTrackEvent(),n.connect(o).then((function(e){i.sdpSubscribe(n,e,(function(){t(n)}),d)})).catch(d)},e.prototype.unsubscribe=function(e,t,r){var n="",i=this.streamManager.getRemoteStream(e);if(!i)return n="stream is not found",p.default.warn(n),void r(n);if(p.default.debug("unsubscribe ",e,i),!i.canUnSubscribe)return n="the stream cannot be unsubscribed",p.default.warn(n),void r(n);i.status=h.ENUM_SUBSCRIBE_STATUS.unsubscribing,this.send("unsubscribe",{src:{user_id:this.user.user_id,streamsub_id:i.streamSubId},dst:{user_id:i.userId,stream_id:i.streamId,media_type:i.mediaType}},(function(){p.default.debug("unsubscribe success"),t(i.convertToOuterStream())}),(function(e){p.default.debug("unsubscribe - ",e),i.status=h.ENUM_SUBSCRIBE_STATUS.subscribed,r(e)}),i)},e.prototype._unsubscribe=function(e,t,r,n){var i=this;this.send("unsubscribe",{src:{user_id:e,streamsub_id:t.streamSubId},dst:{user_id:t.userId,stream_id:t.streamId,media_type:t.mediaType}},(function(){i.logReporter.reportOperationLog(u.ENUM_LOG_OPERATION_TYPE.unsubscribe,{streamId:t.streamId,userId:t.userId,stype:t.streamType,mtype:t.mediaType}),r()}),n)},e.prototype.onUnsubscribe=function(e,t,r,n){var i=e.user_id,o=e.media_type;p.default.debug("onUnsubscribe ",i,o,n),p.default.debug("onUnsubscribe placeholder ",r),n?(this.logReporter.reportOperationLog(u.ENUM_LOG_OPERATION_TYPE.unsubscribe,{streamId:n.streamId,userId:n.userId,stype:n.streamType,mtype:n.mediaType}),n.close(),t()):t()},e.prototype.sdpPublish=function(e,t,r,n){var i=this;p.default.debug("sdpPublish ",e,t);this.send("sdp",{src:{user_id:e.userId,stream_id:e.streamId,stream_type:e.streamType,media_type:e.mediaType},sdp:{type:"offer",sdpcontent:t.sdp,minbitrate:e.minVideoBitRate,maxbitrate:e.hasVideo()?"h265"===e.videoCodec?4e3:2500:1e3}},(function(){p.default.debug("sdpPublish"),e.hasVideo()&&i.updateVP(e,e.resolution).catch((function(e){p.default.debug("update vp",e)})),r()}),(function(e){p.default.error("sdpPublish - ",e),n(E.createError(E.ErrorCodes.SERVER_API,e))}),e)},e.prototype.onSdpPublish=function(e,t,r,n){p.default.debug("onSdpPublish ",e);var i=e.sdp;n.answer(i).then((function(){p.default.debug("onSdpPublish"),t()})).catch((function(e){p.default.error("onSdpPublish - ",e),r(e)}))},e.prototype.sdpSubscribe=function(e,t,r,n){p.default.debug("sdpSubscribe ",e,t);this.send("sdp",{src:{user_id:this.user.user_id,stream_id:e.streamSubId,stream_type:e.streamType,media_type:e.mediaType},sdp:{type:"offer",sdpcontent:t.sdp}},(function(){p.default.debug("sdpSubscribe"),r()}),(function(e){p.default.debug("sdpSubscribe - ",e),n(e)}),e)},e.prototype.onSdpSubscribe=function(e,t,r,n){p.default.debug("onSdpSubscribe ",e);var i=e.sdp;n.answer(i).then((function(){p.default.debug("onSdpSubscribe"),n.status=h.ENUM_SUBSCRIBE_STATUS.subscribed,t()})).catch((function(e){p.default.debug("onSdpSubscribe - ",e),r(e)}))},e.prototype.muteVideo=function(e,t){var r=this,n=this.streamManager.getStream(e);if(!n){return p.default.warn("cannot find stream"),!1}if(n.videoMuted)return!0;var i=this.user.user_id,o=n.streamId;n.streamType===h.ENUM_STREAM_TYPE.subscribe&&(o=n.streamSubId);var a=function(){r.logReporter.reportOperationLog(u.ENUM_LOG_OPERATION_TYPE.muteVideo,{streamId:o,userId:i,stype:n.streamType,mtype:n.mediaType})},s=function(e){t(e);var n={code:""+e.name,message:""+e.message};r._emitter&&r._emitter.emit("error-notify",n)},c=function(){r.send("mute",{user_id:i,stream_id:o,stream_type:n.streamType,track_type:h.ENUM_TRACK_TYPE.video,mute:!0},a,s)};if(n.muteVideo()){var d=300-(Date.now()-n.lastEmitTime);return!n.isSubscriber&&d>0?setTimeout(c,d):c(),!0}return!1},e.prototype.unmuteVideo=function(e,t){var r=this,n=this.streamManager.getStream(e);if(!n){return p.default.warn("cannot find stream"),!1}if(!n.videoMuted)return!0;var i=this.user.user_id,o=n.streamId;n.streamType===h.ENUM_STREAM_TYPE.subscribe&&(o=n.streamSubId);return!!n.unmuteVideo()&&(this.send("mute",{user_id:i,stream_id:o,stream_type:n.streamType,track_type:h.ENUM_TRACK_TYPE.video,mute:!1},(function(){r.logReporter.reportOperationLog(u.ENUM_LOG_OPERATION_TYPE.unmuteVideo,{streamId:o,userId:i,stype:n.streamType,mtype:n.mediaType})}),(function(e){t(e);var n={code:""+e.name,message:""+e.message};r._emitter&&r._emitter.emit("error-notify",n)})),!0)},e.prototype.muteAudio=function(e,t){var r=this,n=this.streamManager.getStream(e);if(!n){return p.default.warn("cannot find stream"),!1}if(n.audioMuted)return!0;var i=this.user.user_id,o=n.streamId;n.streamType===h.ENUM_STREAM_TYPE.subscribe&&(o=n.streamSubId);var a=function(){r.logReporter.reportOperationLog(u.ENUM_LOG_OPERATION_TYPE.muteAudio,{streamId:o,userId:i,stype:n.streamType,mtype:n.mediaType})},s=function(e){t(e);var n={code:""+e.name,message:""+e.message};r._emitter&&r._emitter.emit("error-notify",n)},c=function(){r.send("mute",{user_id:i,stream_id:o,stream_type:n.streamType,track_type:h.ENUM_TRACK_TYPE.audio,mute:!0},a,s)};if(n.muteAudio()){var d=300-(Date.now()-n.lastEmitTime);return!n.isSubscriber&&d>0?setTimeout(c,d):c(),!0}return!1},e.prototype.unmuteAudio=function(e,t){var r=this,n=this.streamManager.getStream(e);if(!n){return p.default.warn("cannot find stream"),!1}if(!n.audioMuted)return!0;var i=this.user.user_id,o=n.streamId;n.streamType===h.ENUM_STREAM_TYPE.subscribe&&(o=n.streamSubId);return!!n.unmuteAudio()&&(this.send("mute",{user_id:i,stream_id:o,stream_type:n.streamType,track_type:h.ENUM_TRACK_TYPE.audio,mute:!1},(function(){r.logReporter.reportOperationLog(u.ENUM_LOG_OPERATION_TYPE.unmuteAudio,{streamId:o,userId:i,stype:n.streamType,mtype:n.mediaType})}),(function(e){t(e);var n={code:""+e.name,message:""+e.message};r._emitter&&r._emitter.emit("error-notify",n)})),!0)},e.prototype.muteData=function(){},e.prototype.unmuteData=function(){},e.prototype.startRecording=function(e,t,r){var n,i,o=this,a="";if(!(n=e.mixStreamUId===this.user.user_id?this.streamManager.getAllLocalStreams().find((function(t){return t.mediaType===e.mixStreamType})):this.streamManager.getAllRemoteStreams().find((function(t){return t.userId===e.mixStreamUId&&t.mediaType===e.mixStreamType})))){var s="cannot find corresponding stream";return p.default.warn(s),void r(E.createError(E.ErrorCodes.STREAM_NOT_EXISTS,s))}switch(this.recordStatus){case h.ENUM_RECORD_STATUS.starting:return a="record is starting",p.default.warn(a),void r(E.createError(E.ErrorCodes.OTHERS,a));case h.ENUM_RECORD_STATUS.stopping:return a="record is stopping",p.default.warn(a),void r(E.createError(E.ErrorCodes.OTHERS,a));case h.ENUM_RECORD_STATUS.recording:return a="is recording",p.default.warn(a),void r(E.createError(E.ErrorCodes.OTHERS,a));case h.ENUM_RECORD_STATUS.unrecord:}if(n.audio&&n.video)i=h.ENUM_RECORD_MIME.audioVideo;else if(n.audio)i=h.ENUM_RECORD_MIME.audio;else{if(!n.video)return a="stream config is incorrect",p.default.warn(a),void r(E.createError(E.ErrorCodes.OTHERS,a));i=h.ENUM_RECORD_MIME.video}var c=this.recordStreamType=n.streamType,d=this.recordMediaType=n.mediaType;this.recordStatus=h.ENUM_RECORD_STATUS.starting;var f={mimetype:i,mainviewuid:e.mixStreamUId,mainviewtype:e.mixStreamType,width:e.mixStreamWidth,height:e.mixStreamHeight,watermarkpos:e.waterMarkPos,watertype:e.waterMarkType,waterurl:e.waterMarkRemarks,wtemplate:e.mixStreamTemplate,isaverage:e.isAverage,bucket:e.bucket,region:e.region};e.isRelay?(f.isrelay=e.isRelay,f.time=e.relayTime,f.fragment=e.relayFragment):e.isrelay=e.isRelay,this.send("startrecord",{room_id:this.session.room_id,app_id:this.session.app_id,user_id:this.session.user_id,config:f},(function(e){p.default.debug("startRecording success",e),o.logReporter.reportOperationLog(u.ENUM_LOG_OPERATION_TYPE.startRecord,{recordId:e.RecordId,stype:c,mtype:d}),o.recordStatus=h.ENUM_RECORD_STATUS.recording,t({FileName:e.FileName,RecordId:e.RecordId})}),(function(e){p.default.error("startRecording - ",e),o.recordStatus=h.ENUM_RECORD_STATUS.unrecord,r(e)}))},e.prototype.onStartRecord=function(e,t){p.default.debug("onStartRecord ",e);var r=e.RecordId,n=e.FileName;this.recordId=r,t({RecordId:r,FileName:n})},e.prototype.stopRecording=function(e,t){var r=this,n="";switch(this.recordStatus){case h.ENUM_RECORD_STATUS.starting:return n="local stream record is starting",p.default.warn(n),void t(E.createError(E.ErrorCodes.OTHERS,n));case h.ENUM_RECORD_STATUS.stopping:return n="local stream record is stopping",p.default.warn(n),void t(E.createError(E.ErrorCodes.OTHERS,n));case h.ENUM_RECORD_STATUS.unrecord:return n="local stream isnot recording",p.default.warn(n),void t(E.createError(E.ErrorCodes.OTHERS,n));case h.ENUM_RECORD_STATUS.recording:}this.recordStatus=h.ENUM_RECORD_STATUS.stopping;var i=this.recordId,o=this.recordStreamType,a=this.recordMediaType;this.send("stoprecord",{room_id:this.session.room_id,app_id:this.session.app_id,user_id:this.session.user_id},(function(){p.default.debug("stopRecording success"),r.logReporter.reportOperationLog(u.ENUM_LOG_OPERATION_TYPE.stopRecord,{recordId:i,stype:o,mtype:a}),r.recordStatus=h.ENUM_RECORD_STATUS.unrecord,e()}),(function(e){p.default.debug("stopRecording - ",e),r.recordStatus=h.ENUM_RECORD_STATUS.recording,t(e)}))},e.prototype.onStopRecord=function(e,t){p.default.debug("onStopRecord ",e),this.recordId="",this.recordStreamType=h.ENUM_STREAM_TYPE.publish,this.recordMediaType=h.ENUM_MEDIA_TYPE.camera,t()},e.prototype.startMix=function(e,t,r,n){var i=this,o=h.ENUM_STREAM_TYPE.publish;o=r.mainviewuid&&r.mainviewuid===this.user.user_id?h.ENUM_STREAM_TYPE.subscribe:h.ENUM_STREAM_TYPE.publish;var a=h.ENUM_MEDIA_TYPE.camera;r.mainviewtype&&(a=r.mainviewtype),this.mixStream={streamType:o,mediaType:a};this.send("startmix",{type:e,app_id:this.session.app_id,room_id:this.session.room_id,user_id:this.session.user_id,streams:t||[],config:r},(function(t){switch(p.default.debug("startMix success",t),e){case h.ENUM_MIX_TYPE.relay:i.logReporter.reportOperationLog(u.ENUM_LOG_OPERATION_TYPE.startRelay,{recordId:t.MixId,stype:o,mtype:a});break;case h.ENUM_MIX_TYPE.record:i.logReporter.reportOperationLog(u.ENUM_LOG_OPERATION_TYPE.startRecord,{recordId:t.MixId,stype:o,mtype:a});break;case h.ENUM_MIX_TYPE.relayRecord:i.logReporter.reportOperationLog(u.ENUM_LOG_OPERATION_TYPE.startRelay,{recordId:t.MixId,stype:o,mtype:a}),i.logReporter.reportOperationLog(u.ENUM_LOG_OPERATION_TYPE.startRecord,{recordId:t.MixId,stype:o,mtype:a})}n(void 0,t)}),(function(t){switch(p.default.debug("startMix - "+t),e){case h.ENUM_MIX_TYPE.relay:i.logReporter.reportExceptionLog(u.ENUM_LOG_EXCEPTION_TYPE.relay,{msg:""+t});break;case h.ENUM_MIX_TYPE.record:i.logReporter.reportExceptionLog(u.ENUM_LOG_EXCEPTION_TYPE.record,{msg:""+t});break;case h.ENUM_MIX_TYPE.relayRecord:i.logReporter.reportExceptionLog(u.ENUM_LOG_EXCEPTION_TYPE.relay,{msg:""+t}),i.logReporter.reportExceptionLog(u.ENUM_LOG_EXCEPTION_TYPE.record,{msg:""+t})}n(t)}))},e.prototype.updateMix=function(e,t,r){var n={type:h.ENUM_MIX_TYPE.update,app_id:this.session.app_id,room_id:this.session.room_id,user_id:this.session.user_id,config:t};e.length>0&&(n.streams=e,n.config.layoutUserlimit=e.length),this.send("startmix",n,(function(e){p.default.debug("updateMix success",e),r(void 0,e)}),(function(e){p.default.debug("updateMix - "+e),r(e)}))},e.prototype.onStartMix=function(e,t){p.default.debug("onStartMix ",e);var r=e.mix_id,n=e.filename,i=e.pushurl;t(n&&i?{MixId:r,FileName:n,PushURL:[i]}:n?{MixId:r,FileName:n}:i?{MixId:r,PushURL:[i]}:{MixId:r})},e.prototype.stopMix=function(e,t,r){var n=this;this.send("stopmix",{type:e,pushurl:t,app_id:this.session.app_id,room_id:this.session.room_id,user_id:this.session.user_id},(function(t){p.default.debug("stopMix success");var i=n.mixStream||{},o=i.streamType,a=i.mediaType,s=t.MixId||"";switch(e){case h.ENUM_MIX_TYPE.relay:n.logReporter.reportOperationLog(u.ENUM_LOG_OPERATION_TYPE.stopRelay,{recordId:s,stype:o,mtype:a});break;case h.ENUM_MIX_TYPE.record:n.logReporter.reportOperationLog(u.ENUM_LOG_OPERATION_TYPE.stopRecord,{recordId:s,stype:o,mtype:a});break;case h.ENUM_MIX_TYPE.relayRecord:n.logReporter.reportOperationLog(u.ENUM_LOG_OPERATION_TYPE.stopRelay,{recordId:s,stype:o,mtype:a}),n.logReporter.reportOperationLog(u.ENUM_LOG_OPERATION_TYPE.stopRecord,{recordId:s,stype:o,mtype:a})}r(void 0,t)}),(function(e){p.default.warn("stopMix - "+e),n.logReporter.reportExceptionLog(u.ENUM_LOG_EXCEPTION_TYPE.others,{msg:"stopMix - "+e}),r(e)}))},e.prototype.onStopMix=function(e,t){p.default.debug("onStopMix ",e);var r=e.mix_id;t(r?{MixId:r}:{})},e.prototype.queryMix=function(e){this.send("queymix",{app_id:this.session.app_id,room_id:this.session.room_id,user_id:this.session.user_id},(function(t){p.default.debug("queryMix success"),e(void 0,t)}),(function(t){p.default.error("queryMix - "+t),e(t)}))},e.prototype.onQueryMix=function(e,t){if(p.default.debug("onQueryMix ",e),e){var r=e.type,n=e.mix_id,i=e.filename,o=e.pushurl;switch(r){case h.ENUM_MIX_TYPE.relay:t({Type:"relay",MixId:n,PushURL:o?[o]:[]});break;case h.ENUM_MIX_TYPE.relayRecord:t({Type:"relay-and-record",MixId:n,FileName:i,PushURL:o?[o]:[]});break;case h.ENUM_MIX_TYPE.record:t({Type:"record",MixId:n,FileName:i});break;default:t({})}}else t({})},e.prototype.addMixStreams=function(e,t){this.send("addmixstream",{app_id:this.session.app_id,room_id:this.session.room_id,user_id:this.session.user_id,streams:e||[]},(function(e){p.default.debug("addMixStreams success",e),t(void 0,e)}),(function(e){p.default.error("addMixStreams - "+e),t(e)}))},e.prototype.onAddMixStreams=function(e,t){var r=e.mix_id;t(r?{MixId:r}:{})},e.prototype.removeMixStreams=function(e,t){this.send("delmixstream",{app_id:this.session.app_id,room_id:this.session.room_id,user_id:this.session.user_id,streams:e||[]},(function(e){p.default.debug("removeMixStreams success",e),t(void 0,e)}),(function(e){p.default.error("removeMixStreams - "+e),t(e)}))},e.prototype.onRemoveMixStreams=function(e,t){var r=e.mix_id;t(r?{MixId:r}:{})},e.prototype.logoff=function(e,t){var r=this;return new Promise((function(n,i){r.send("logoff",{app_id:r.session.app_id,room_id:r.session.room_id,user_id:r.session.user_id,cmdtype:e,users:t},n,i)}))},e.prototype.onLogoff=function(e,t){p.default.debug("on log off",e),t()},e.prototype.updateVP=function(e,t){var r=this,n=t.attributes,i=S.getVP(n),o=n.maxVideoBW,a=n.minVideoBW;return new Promise((function(t,s){r.send("updatevp",{app_id:r.session.app_id,room_id:r.session.room_id,user_id:r.session.user_id,stream_id:e.streamId,vp:i,maxbitrate:o,minbitrate:a},(function(){r.logReporter.reportOperationLog(u.ENUM_LOG_OPERATION_TYPE.updateVP,{msg:n.videoWidth+"*"+n.videoHeight}),t()}),s)}))},e.prototype.onUpdateVP=function(e,t){p.default.debug("on update vp",e),t()},e.prototype.onError=function(e){p.default.warn("onError - method: "+e.method+", code: "+e.code+", msg: "+e.msg)},e.prototype.onUserJoin=function(e){var t=e.user_id,r=e.cmdtype,n=e.reason;if(p.default.debug("onUserJoin ",t,r,n),!this.users.find((function(e){return e.user_id===t}))){var i={user_id:t};this.users.push(i),this._emitter&&this._emitter.emit("user-added",v.convertToOuterUser(i))}},e.prototype.onUserLeave=function(e){var t=e.user_id,r=e.cmdtype,n=e.reason;p.default.debug("onUserLeave ",t,r,n);var i=this.users.findIndex((function(e){return e.user_id===t}));if(i>=0){var o=this.users[i];this.users.splice(i,1),this._emitter&&this._emitter.emit("user-removed",v.convertToOuterUser(o))}},e.prototype.onAddStream=function(e){var t=e.user_id,r=e.cmdtype,n=e.stream;if(p.default.debug("onAddStream ",t,r,n),!this.users.find((function(e){return e.user_id===t}))){var i={user_id:t};this.users.push(i),this._emitter&&this._emitter.emit("user-added",v.convertToOuterUser(i))}var o=Object.assign({uid:t},n),a=this.streamManager.getAllRemoteStreams().find((function(e){return e.userId===o.uid&&o.media_type===e.mediaType}));a&&(this.streamManager.removeRemoteStream(a),this._emitter&&this._emitter.emit("stream-removed",a.convertToOuterStream()));var s=this.streamManager.createRemoteStream(o);s&&this._emitter&&this._emitter.emit("stream-added",s.convertToOuterStream())},e.prototype.onRemoveStream=function(e){var t=e.user_id,r=e.stream;p.default.debug("onRemoveStream ",t,r);var n=this.streamManager.getRemoteStream(r.sid);if(n)this.streamManager.removeRemoteStream(n),this._emitter&&this._emitter.emit("stream-removed",n.convertToOuterStream());else{var i="stream "+r.sid+" is not found";p.default.debug("onRemoveStream - ",i)}},e.prototype.onTransportClose=function(e){var t=e.user_id,r=e.stream;p.default.debug("onTransportClose ",t,r),t===this.user.user_id||this.onRemoveStream({user_id:t,stream:r})},e.prototype.onTransportTimeout=function(e){p.default.debug("onTransportTimeout",e);var t=e.user_id,r=e.stream;t===this.user.user_id||this.onRemoveStream({user_id:t,stream:r})},e.prototype.onAudioTrackst=function(e){var t=e.user_id,r=e.stream_id,n=e.mute,i=e.track_type,o=e.media_type;p.default.debug("onAudioTrackst ",t,r,n,i,o);var a=this.streamManager.getRemoteStream(r);if(a)a.sourceAudioMuted=!!n,n?(a.muteAudio(!0),this._emitter&&this._emitter.emit("mute-audio",a.convertToOuterStream())):(a.unmuteAudio(!0),this._emitter&&this._emitter.emit("unmute-audio",a.convertToOuterStream()));else{var s="stream "+r+" is not found";p.default.warn("onAudioTrackst - ",s)}},e.prototype.onVideoTrackst=function(e){var t=e.user_id,r=e.stream_id,n=e.mute,i=e.track_type,o=e.media_type;p.default.debug("onVideoTrackst ",t,r,n,i,o);var a=this.streamManager.getRemoteStream(r);if(a)a.sourceVideoMuted=!!n,n?(a.muteVideo(!0),this._emitter&&this._emitter.emit("mute-video",a.convertToOuterStream())):(a.unmuteVideo(!0),this._emitter&&this._emitter.emit("unmute-video",a.convertToOuterStream()));else{var s="stream "+r+" is not found";p.default.warn("onVideoTrackst - ",s)}},e.prototype.onDataTrackst=function(e){var t=e.user_id,r=e.stream_id,n=e.mute,i=e.track_type,o=e.media_type;p.default.debug("onDataTrackst ",t,r,n,i,o);var a=this.streamManager.getRemoteStream(r);if(a)n?this._emitter&&this._emitter.emit("mute-data",a.convertToOuterStream()):this._emitter&&this._emitter.emit("unmute-data",a.convertToOuterStream());else{var s="stream "+r+" is not found";p.default.warn("onDataTrackst - ",s)}},e.prototype.onKickoff=function(e){this.disconnect("kick off"),this.destroy(),this._emitter&&this._emitter.emit("kick-off",e)},e.prototype.onMixNotify=function(e,t,r){var n;switch(e){case 24149:case 24150:case 24152:n=E.createError(""+e,t)}var i={code:""+e,message:""+t};r.filename?(n&&this.logReporter.reportExceptionLog(u.ENUM_LOG_EXCEPTION_TYPE.record,{msg:e+" "+t}),this._emitter&&this._emitter.emit("record-notify",i)):r.pushurl&&r.pushurl.length>0&&(n&&this.logReporter.reportExceptionLog(u.ENUM_LOG_EXCEPTION_TYPE.relay,{msg:e+" "+t}),this._emitter&&this._emitter.emit("relay-notify",i))},e.prototype.onLogoffNotify=function(e){var t=this;p.default.debug("logoff notify ",e);var r=e.user_id;switch(e.cmdtype){case h.ENUM_LOGOFF_TYPE.quit:this.onKickoff({user_id:r,reason:"logoff notify"});break;case h.ENUM_LOGOFF_TYPE.reconnect:this.joinRoomType=h.ENUM_JOIN_ROOM_TYPE.reconnect,this.signalManager.reconnect();break;case h.ENUM_LOGOFF_TYPE.switch:this.joinRoomType=h.ENUM_JOIN_ROOM_TYPE.switch,this.signalManager.switch();break;case h.ENUM_LOGOFF_TYPE.refresh:this.refreshSignal().then((function(e){var r=e[0],n=e[1];t.signalSwitchConfig=n,t.joinRoomType=h.ENUM_JOIN_ROOM_TYPE.refresh,t.signalManager.refresh(r)}))}},e.prototype.onMediaStreamPublished=function(e){this._emitter&&this._emitter.emit("stream-published",e.convertToOuterStream())},e.prototype.onMediaStreamSubscribed=function(e){this._emitter&&this._emitter.emit("stream-subscribed",e.convertToOuterStream())},e.prototype.onScreenMediaStreamEnded=function(e){this._emitter&&this._emitter.emit("screenshare-stopped",e.convertToOuterStream())},e.prototype.onStreamConnectionClosed=function(e){var t,r=this,n=null===(t=this.socketManager)||void 0===t?void 0:t.connectId;e.isSubscriber?this.resubscribe(e).catch((function(t){var i;return n!==(null===(i=r.socketManager)||void 0===i?void 0:i.connectId)?Promise.resolve():t.name===E.ErrorCodes.SOCKET_DISCONNECTED||t.name===E.ErrorCodes.NOT_JOIN||t.name===E.InnerErrorCodes.RESUBSCRIBING?Promise.resolve():(p.default.warn("resubscribe - [iceconnection closed], "+t),new Promise((function(t,n){setTimeout((function(){r.resubscribe(e).then(t).catch(n)}),2e3)})))})).catch((function(t){var i;return n!==(null===(i=r.socketManager)||void 0===i?void 0:i.connectId)?Promise.resolve():t.name===E.ErrorCodes.SOCKET_DISCONNECTED||t.name===E.ErrorCodes.NOT_JOIN||t.name===E.InnerErrorCodes.RESUBSCRIBING?Promise.resolve():(p.default.error("resubscribe2 - [iceconnection closed], "+t),new Promise((function(t,n){setTimeout((function(){r.resubscribe(e).then(t).catch(n)}),4e3)})))})).catch((function(t){var i;if(n!==(null===(i=r.socketManager)||void 0===i?void 0:i.connectId))return Promise.resolve();p.default.error("resubscribe3 - [iceconnection closed], "+t),r.streamManager.removeRemoteStream(e),r._emitter&&r._emitter.emit("stream-removed",e.convertToOuterStream()),r.syncRoom().catch((function(e){p.default.debug("sync room failed ",e),p.default.report("sync room failed in resubscribe",e)}))})):this.republish(e).catch((function(t){var i;return n!==(null===(i=r.socketManager)||void 0===i?void 0:i.connectId)?Promise.resolve():t.name===E.ErrorCodes.SOCKET_DISCONNECTED||t.name===E.ErrorCodes.NOT_JOIN||t.name===E.InnerErrorCodes.REPUBLISHING?Promise.resolve():(p.default.warn("republish - [iceconnection closed], "+t),new Promise((function(t,n){setTimeout((function(){r.republish(e).then(t).catch(n)}),2e3)})))})).catch((function(t){var i;return n!==(null===(i=r.socketManager)||void 0===i?void 0:i.connectId)?Promise.resolve():t.name===E.ErrorCodes.SOCKET_DISCONNECTED||t.name===E.ErrorCodes.NOT_JOIN||t.name===E.InnerErrorCodes.REPUBLISHING?Promise.resolve():(p.default.error("republish2 - [iceconnection closed], "+t),new Promise((function(t,n){setTimeout((function(){r.republish(e).then(t).catch(n)}),4e3)})))})).catch((function(t){p.default.debug("republish3 - [iceconnection closed], "+e.streamId+" "+t),p.default.report("republish3 - [iceconnection closed], "+e.streamId+" "+t)}))},e.prototype.onStreamConnectionReconnecting=function(e){p.default.debug("stream peerconnection reconnecting ",e)},e.prototype.onStreamConnectionReconnected=function(e){var t;p.default.debug("stream peerconnection reconnected ",e),null===(t=this._emitter)||void 0===t||t.emit("stream-reconnected",{previous:e.lastOuterStream,current:e.convertToOuterStream()})},e.prototype.onStreamConnectionDisconnected=function(e){var t;p.default.warn("stream peerconnection disconnected ",e),null===(t=this.socketManager)||void 0===t||t.heartBeat()},e.prototype.enableAudioVolumeIndicator=function(e){var t=this;this.audioVolumeIndicator||(this.audioVolumeIndicator=new _.default(this.streamManager,e)),this.audioVolumeIndicator.start((function(e){var r;null===(r=t._emitter)||void 0===r||r.emit("volume-indicator",e)}),e)},e}();t.SessionManager=w},function(e,t,r){"use strict";var n=r(1),i=r(22),o=r(50),a=r(28);function s(e){var t=new o(e),r=i(o.prototype.request,t);return n.extend(r,o.prototype,t),n.extend(r,t),r}var c=s(r(25));c.Axios=o,c.create=function(e){return s(a(c.defaults,e))},c.Cancel=r(29),c.CancelToken=r(62),c.isCancel=r(24),c.all=function(e){return Promise.all(e)},c.spread=r(63),e.exports=c,e.exports.default=c},function(e,t){ /*! * Determine if an object is a Buffer * * @author Feross Aboukhadijeh * @license MIT */ -e.exports=function(e){return null!=e&&null!=e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}},function(e,t,r){"use strict";var n=r(1),i=r(23),o=r(51),a=r(52),s=r(28);function c(e){this.defaults=e,this.interceptors={request:new o,response:new o}}c.prototype.request=function(e){"string"==typeof e?(e=arguments[1]||{}).url=arguments[0]:e=e||{},(e=s(this.defaults,e)).method=e.method?e.method.toLowerCase():"get";var t=[a,void 0],r=Promise.resolve(e);for(this.interceptors.request.forEach((function(e){t.unshift(e.fulfilled,e.rejected)})),this.interceptors.response.forEach((function(e){t.push(e.fulfilled,e.rejected)}));t.length;)r=r.then(t.shift(),t.shift());return r},c.prototype.getUri=function(e){return e=s(this.defaults,e),i(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")},n.forEach(["delete","get","head","options"],(function(e){c.prototype[e]=function(t,r){return this.request(n.merge(r||{},{method:e,url:t}))}})),n.forEach(["post","put","patch"],(function(e){c.prototype[e]=function(t,r,i){return this.request(n.merge(i||{},{method:e,url:t,data:r}))}})),e.exports=c},function(e,t,r){"use strict";var n=r(1);function i(){this.handlers=[]}i.prototype.use=function(e,t){return this.handlers.push({fulfilled:e,rejected:t}),this.handlers.length-1},i.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},i.prototype.forEach=function(e){n.forEach(this.handlers,(function(t){null!==t&&e(t)}))},e.exports=i},function(e,t,r){"use strict";var n=r(1),i=r(53),o=r(24),a=r(25),s=r(60),c=r(61);function u(e){e.cancelToken&&e.cancelToken.throwIfRequested()}e.exports=function(e){return u(e),e.baseURL&&!s(e.url)&&(e.url=c(e.baseURL,e.url)),e.headers=e.headers||{},e.data=i(e.data,e.headers,e.transformRequest),e.headers=n.merge(e.headers.common||{},e.headers[e.method]||{},e.headers||{}),n.forEach(["delete","get","head","post","put","patch","common"],(function(t){delete e.headers[t]})),(e.adapter||a.adapter)(e).then((function(t){return u(e),t.data=i(t.data,t.headers,e.transformResponse),t}),(function(t){return o(t)||(u(e),t&&t.response&&(t.response.data=i(t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)}))}},function(e,t,r){"use strict";var n=r(1);e.exports=function(e,t,r){return n.forEach(r,(function(r){e=r(e,t)})),e}},function(e,t,r){"use strict";var n=r(1);e.exports=function(e,t){n.forEach(e,(function(r,n){n!==t&&n.toUpperCase()===t.toUpperCase()&&(e[t]=r,delete e[n])}))}},function(e,t,r){"use strict";var n=r(27);e.exports=function(e,t,r){var i=r.config.validateStatus;!i||i(r.status)?e(r):t(n("Request failed with status code "+r.status,r.config,null,r.request,r))}},function(e,t,r){"use strict";e.exports=function(e,t,r,n,i){return e.config=t,r&&(e.code=r),e.request=n,e.response=i,e.isAxiosError=!0,e.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code}},e}},function(e,t,r){"use strict";var n=r(1),i=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];e.exports=function(e){var t,r,o,a={};return e?(n.forEach(e.split("\n"),(function(e){if(o=e.indexOf(":"),t=n.trim(e.substr(0,o)).toLowerCase(),r=n.trim(e.substr(o+1)),t){if(a[t]&&i.indexOf(t)>=0)return;a[t]="set-cookie"===t?(a[t]?a[t]:[]).concat([r]):a[t]?a[t]+", "+r:r}})),a):a}},function(e,t,r){"use strict";var n=r(1);e.exports=n.isStandardBrowserEnv()?function(){var e,t=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a");function i(e){var n=e;return t&&(r.setAttribute("href",n),n=r.href),r.setAttribute("href",n),{href:r.href,protocol:r.protocol?r.protocol.replace(/:$/,""):"",host:r.host,search:r.search?r.search.replace(/^\?/,""):"",hash:r.hash?r.hash.replace(/^#/,""):"",hostname:r.hostname,port:r.port,pathname:"/"===r.pathname.charAt(0)?r.pathname:"/"+r.pathname}}return e=i(window.location.href),function(t){var r=n.isString(t)?i(t):t;return r.protocol===e.protocol&&r.host===e.host}}():function(){return!0}},function(e,t,r){"use strict";var n=r(1);e.exports=n.isStandardBrowserEnv()?{write:function(e,t,r,i,o,a){var s=[];s.push(e+"="+encodeURIComponent(t)),n.isNumber(r)&&s.push("expires="+new Date(r).toGMTString()),n.isString(i)&&s.push("path="+i),n.isString(o)&&s.push("domain="+o),!0===a&&s.push("secure"),document.cookie=s.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}}},function(e,t,r){"use strict";e.exports=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)}},function(e,t,r){"use strict";e.exports=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}},function(e,t,r){"use strict";var n=r(29);function i(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise((function(e){t=e}));var r=this;e((function(e){r.reason||(r.reason=new n(e),t(r.reason))}))}i.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},i.source=function(){var e;return{token:new i((function(t){e=t})),cancel:e}},e.exports=i},function(e,t,r){"use strict";e.exports=function(e){return function(t){return e.apply(null,t)}}},function(e,t,r){var n=r(65)("jsonp");e.exports=function(e,t,r){"function"==typeof t&&(r=t,t={});t||(t={});var a,s,c=t.prefix||"__jp",u=t.name||c+i++,d=t.param||"callback",f=null!=t.timeout?t.timeout:6e4,p=encodeURIComponent,l=document.getElementsByTagName("script")[0]||document.head;f&&(s=setTimeout((function(){m(),r&&r(new Error("Timeout"))}),f));function m(){a.parentNode&&a.parentNode.removeChild(a),window[u]=o,s&&clearTimeout(s)}return window[u]=function(e){n("jsonp got",e),m(),r&&r(null,e)},e=(e+=(~e.indexOf("?")?"&":"?")+d+"="+p(u)).replace("?&","?"),n('jsonp req "%s"',e),(a=document.createElement("script")).src=e,l.parentNode.insertBefore(a,l),function(){window[u]&&m()}};var i=0;function o(){}},function(e,t,r){(function(n){function i(){var e;try{e=t.storage.debug}catch(e){}return!e&&void 0!==n&&"env"in n&&(e=n.env.DEBUG),e}(t=e.exports=r(66)).log=function(){return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)},t.formatArgs=function(e){var r=this.useColors;if(e[0]=(r?"%c":"")+this.namespace+(r?" %c":" ")+e[0]+(r?"%c ":" ")+"+"+t.humanize(this.diff),!r)return;var n="color: "+this.color;e.splice(1,0,n,"color: inherit");var i=0,o=0;e[0].replace(/%[a-zA-Z%]/g,(function(e){"%%"!==e&&(i++,"%c"===e&&(o=i))})),e.splice(o,0,n)},t.save=function(e){try{null==e?t.storage.removeItem("debug"):t.storage.debug=e}catch(e){}},t.load=i,t.useColors=function(){if("undefined"!=typeof window&&window.process&&"renderer"===window.process.type)return!0;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage="undefined"!=typeof chrome&&void 0!==chrome.storage?chrome.storage.local:function(){try{return window.localStorage}catch(e){}}(),t.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"],t.formatters.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}},t.enable(i())}).call(this,r(12))},function(e,t,r){var n;function i(e){function r(){if(r.enabled){var e=r,i=+new Date,o=i-(n||i);e.diff=o,e.prev=n,e.curr=i,n=i;for(var a=new Array(arguments.length),s=0;s0)return function(e){if((e=String(e)).length>100)return;var t=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(e);if(!t)return;var s=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return s*a;case"days":case"day":case"d":return s*o;case"hours":case"hour":case"hrs":case"hr":case"h":return s*i;case"minutes":case"minute":case"mins":case"min":case"m":return s*n;case"seconds":case"second":case"secs":case"sec":case"s":return s*r;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return s;default:return}}(e);if("number"===u&&!1===isNaN(e))return t.long?s(c=e,o,"day")||s(c,i,"hour")||s(c,n,"minute")||s(c,r,"second")||c+" ms":function(e){if(e>=o)return Math.round(e/o)+"d";if(e>=i)return Math.round(e/i)+"h";if(e>=n)return Math.round(e/n)+"m";if(e>=r)return Math.round(e/r)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},function(e,t,r){"use strict";e.exports=function(e,t){if(t=t.split(":")[0],!(e=+e))return!1;switch(t){case"http":case"ws":return 80!==e;case"https":case"wss":return 443!==e;case"ftp":return 21!==e;case"gopher":return 70!==e;case"file":return!1}return 0!==e}},function(e,t,r){"use strict";var n,i=Object.prototype.hasOwnProperty;function o(e){try{return decodeURIComponent(e.replace(/\+/g," "))}catch(e){return null}}t.stringify=function(e,t){t=t||"";var r,o,a=[];for(o in"string"!=typeof t&&(t="?"),e)if(i.call(e,o)){if((r=e[o])||null!==r&&r!==n&&!isNaN(r)||(r=""),o=encodeURIComponent(o),r=encodeURIComponent(r),null===o||null===r)continue;a.push(o+"="+r)}return a.length?t+a.join("&"):""},t.parse=function(e){for(var t,r=/([^=?&]+)=?([^&]*)/g,n={};t=r.exec(e);){var i=o(t[1]),a=o(t[2]);null===i||null===a||i in n||(n[i]=a)}return n}},function(e,t,r){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0});var n=r(71),i=r(0),o=r(31),a=r(3),s=function(){function t(e){this.readyState=n.w3cwebsocket.CLOSED,this.connectId=1,this.BEATTIM=6e4,this.pingTimeout=0,this.retry=0,this.signalManager=e}return t.prototype.init=function(e,t,r){var n=this;this.messageCb=e,this.stateChangeCb=t,this.errorCb=r,this.signalManager.on("change-signal",(function(e,t){i.default.debug("change signal "+e.wss+" => "+t.wss),e&&(e.status=o.SignalStatus.unconnected),n.reconnect()}))},t.prototype.initHeartBeat=function(e,t){this.getHeartBeatData=e,t&&(this.BEATTIM=t)},t.prototype.startHeartBeat=function(){var e=this;i.default.debug("socket manager - start head beat"),this.keepAlive&&window.clearInterval(this.keepAlive),this.getHeartBeatData&&(this.keepAlive=window.setInterval((function(){e.heartBeat()}),this.BEATTIM))},t.prototype.heartBeat=function(){var e=this;if(this.getHeartBeatData&&this.readyState===n.w3cwebsocket.OPEN){this.pingTimeout||(this.pingTimeout=window.setTimeout((function(){e.pingTimeout=0,e.stopHeartBeat(),e.onStateChanged(e.readyState,n.w3cwebsocket.CLOSED),e.readyState=n.w3cwebsocket.CLOSED,e.reconnect()}),8e3));var t=this.getHeartBeatData();this.send(t).catch((function(e){i.default.warn("head beat ",e)}))}},t.prototype.stopHeartBeat=function(){i.default.debug("socket manager - stop head beat"),this.keepAlive&&window.clearInterval(this.keepAlive)},t.prototype.destroy=function(){this.stopHeartBeat(),this.messageCb=void 0,this.stateChangeCb=void 0,this.errorCb=void 0,this.retry&&(window.clearTimeout(this.retry),this.retry=0)},t.prototype.connect=function(e){var t=this;return this.connectId+=1,i.default.debug("socket manager - connect ",this.readyState,e),new Promise((function(r,s){if(e||t.signalManager.current){t.readyState=n.w3cwebsocket.CLOSED;var c=t.signalManager.current,u=!0;try{t._websocket=new n.w3cwebsocket(e||c.wss),c.status=o.SignalStatus.connecting}catch(e){return i.default.debug("socket manager - connect error ",e),void s(a.createError(a.ErrorCodes.OTHERS,"Create Socket Error"))}t.onconnecting(t.readyState,n.w3cwebsocket.CONNECTING),t.readyState=n.w3cwebsocket.CONNECTING,t._websocket.onopen=function(){var e=t.readyState;t.readyState=n.w3cwebsocket.OPEN,c.status=o.SignalStatus.connected,t.onopened(e,n.w3cwebsocket.OPEN),u&&(u=!1,r("opened"))},t._websocket.onclose=function(){i.default.debug("socket manager - onclose ",t.readyState);var e=t.readyState;t.readyState=n.w3cwebsocket.CLOSED,c.status=o.SignalStatus.unconnected,t.onclosed(e,n.w3cwebsocket.CLOSED)},t._websocket.onmessage=function(e){t.pingTimeout&&(window.clearTimeout(t.pingTimeout),t.pingTimeout=0),t.onmessage(e)},t._websocket.onerror=function(e){var r;i.default.debug("socket manager - onerror ",e),i.default.debug("socket manager - onerror state ",t.readyState,null===(r=t._websocket)||void 0===r?void 0:r.readyState),u?(u=!1,s(a.createError(a.ErrorCodes.OTHERS,"connection error"))):t.onerror("connection error")}}else s(a.createError(a.ErrorCodes.OTHERS,"signal is blank"))}))},t.prototype.onmessage=function(e){this.messageCb&&this.messageCb(e)},t.prototype.onStateChanged=function(e,t){function r(e){var t="CLOSED";switch(e){case n.w3cwebsocket.OPEN:t="OPEN";break;case n.w3cwebsocket.CONNECTING:t="CONNECTING";break;case n.w3cwebsocket.CLOSING:t="CLOSING";break;case n.w3cwebsocket.CLOSED:t="CLOSED"}return t}var o=r(e),a=r(t);i.default.debug("socket manager - onStateChanged ",o,a),this.stateChangeCb&&this.stateChangeCb(o,a)},t.prototype.onconnecting=function(e,t){i.default.debug("socket manager - onconnecting ",e,t),this.onStateChanged(e,t)},t.prototype.onopened=function(e,t){i.default.debug("socket manager - onopened ",e,t),this.startHeartBeat(),this.onStateChanged(e,t)},t.prototype.ondisconnecting=function(e,t){i.default.debug("socket manager - ondisconnecting ",e,t),this.onStateChanged(e,t)},t.prototype.onclosed=function(t,r){var o=this;i.default.debug("socket manager - onclosed ",t,r),this.stopHeartBeat(),this.onStateChanged(t,r),t===n.w3cwebsocket.OPEN&&e((function(){i.default.warn("connection is closed - reconnecting..."),o.reconnect()}))},t.prototype.onerror=function(e){i.default.debug("socket manager - onerror ",e),this.errorCb&&this.errorCb(e)},t.prototype.send=function(e){var t=this;return new Promise((function(r,n){var i;t.isOpened?(null===(i=t._websocket)||void 0===i||i.send(e),r()):n(a.createError(a.ErrorCodes.OTHERS,"connection isnot open"))}))},t.prototype.close=function(e,t){var r=this;return void 0===e&&(e=1e3),i.default.debug("socket manager - close ",this.readyState),this.ondisconnecting(this.readyState,n.w3cwebsocket.CLOSING),this.readyState=n.w3cwebsocket.CLOSING,new Promise((function(n,i){r._websocket?(r._websocket.close(e,t),n()):i(a.createError(a.ErrorCodes.OTHERS,"no socket connection"))}))},Object.defineProperty(t.prototype,"isOpened",{get:function(){return this.readyState===n.w3cwebsocket.OPEN},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isClosed",{get:function(){return this.readyState===n.w3cwebsocket.CLOSED},enumerable:!0,configurable:!0}),t.prototype.reconnect=function(){var e=this;if(i.default.debug("socket manager - reconnect ",this.readyState),this._websocket){var t=this._websocket,r=function(){};this._websocket.onopen=r,this._websocket.onclose=r,this._websocket.onmessage=r,this._websocket.onerror=r,this._websocket=void 0,this.pingTimeout&&(window.clearTimeout(this.pingTimeout),this.pingTimeout=0),i.default.debug("socket manager - before reconnect ",this.readyState);var a=this.readyState;this.signalManager.current.status=o.SignalStatus.unconnected,a!==n.w3cwebsocket.CLOSED&&(this.readyState=n.w3cwebsocket.CLOSED,this.onclosed(a,n.w3cwebsocket.CLOSED));try{t.close(1e3,"reconnect")}catch(e){i.default.warn("reconenct - close websocket "+e)}}this.retry&&(window.clearTimeout(this.retry),this.retry=0),this.retry=window.setTimeout((function(){return e.reconnect()}),1e4),e.connect().then((function(){e.retry&&(window.clearTimeout(e.retry),e.retry=0)})).catch((function(e){i.default.warn("reconnect unsuccessfully with error: ",e),i.default.warn("reconnection will restart later...")}))},t}();t.SocketManager=s}).call(this,r(19).setImmediate)},function(e,t,r){(function(t){var n=function(){return this||void 0===t?this:t}(),i=n.WebSocket||n.MozWebSocket,o=r(72);function a(e,t){return t?new i(e,t):new i(e)}i&&["CONNECTING","OPEN","CLOSING","CLOSED"].forEach((function(e){Object.defineProperty(a,e,{get:function(){return i[e]}})})),e.exports={w3cwebsocket:i?a:null,version:o}}).call(this,r(8))},function(e,t,r){e.exports=r(73).version},function(e){e.exports=JSON.parse('{"name":"websocket","description":"Websocket Client & Server Library implementing the WebSocket protocol as specified in RFC 6455.","keywords":["websocket","websockets","socket","networking","comet","push","RFC-6455","realtime","server","client"],"author":"Brian McKelvey (https://github.com/theturtle32)","contributors":["Iñaki Baz Castillo (http://dev.sipdoc.net)"],"version":"1.0.30","repository":{"type":"git","url":"https://github.com/theturtle32/WebSocket-Node.git"},"homepage":"https://github.com/theturtle32/WebSocket-Node","engines":{"node":">=0.10.0"},"dependencies":{"debug":"^2.2.0","nan":"^2.14.0","typedarray-to-buffer":"^3.1.5","yaeti":"^0.0.6"},"devDependencies":{"buffer-equal":"^1.0.0","faucet":"^0.0.1","gulp":"^4.0.2","gulp-jshint":"^2.0.4","jshint-stylish":"^2.2.1","jshint":"^2.0.0","tape":"^4.9.1"},"config":{"verbose":false},"scripts":{"install":"(node-gyp rebuild 2> builderror.log) || (exit 0)","test":"faucet test/unit","gulp":"gulp"},"main":"index","directories":{"lib":"./lib"},"browser":"lib/browser.js","license":"Apache-2.0"}')},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ErrorCodes={NOT_JOIN:"NotJoinRoomError",JOINING:"JoiningRoomError",LEAVING:"LeavingRoomError",DUPLICATED_JOIN:"DuplicatedJoinRoomError",ROLE_TYPE_NOT_MATCH:"RoleTypeNotMatchError",INVALID_MEDIASTREAM:"InvalidMediaStreamError",STREAM_EXISTS:"StreamExistsError",CREATE_STREAM:"CreateStreamError",STREAM_NOT_EXISTS:"StreamNotExistsError",AUDIO_TRACK_NOT_EXISTS:"AudioTrackNotExistsError",VIDEO_TRACK_NOT_EXISTS:"VideoTrackNotExistsError",SERVER_API:"ServerError",INVALID_PARAMETER:"InvalidParameterError",NOT_SUPPORT:"NotSupportError",BAD_REQUEST:"BadRequestError",SOCKET_DISCONNECTED:"SocketDisconnectedError",OTHERS:"OtherError"},t.InnerErrorCodes={REPUBLISHING:"Republishing",RESUBSCRIBING:"Resubscribing"}},function(e,t,r){e.exports=function(e){var t={};function r(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)r.d(n,i,function(t){return e[t]}.bind(null,i));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=90)}({17:function(e,t,r){"use strict";t.__esModule=!0,t.default=void 0;var n=r(18),i=function(){function e(){}return e.getFirstMatch=function(e,t){var r=t.match(e);return r&&r.length>0&&r[1]||""},e.getSecondMatch=function(e,t){var r=t.match(e);return r&&r.length>1&&r[2]||""},e.matchAndReturnConst=function(e,t,r){if(e.test(t))return r},e.getWindowsVersionName=function(e){switch(e){case"NT":return"NT";case"XP":return"XP";case"NT 5.0":return"2000";case"NT 5.1":return"XP";case"NT 5.2":return"2003";case"NT 6.0":return"Vista";case"NT 6.1":return"7";case"NT 6.2":return"8";case"NT 6.3":return"8.1";case"NT 10.0":return"10";default:return}},e.getMacOSVersionName=function(e){var t=e.split(".").splice(0,2).map((function(e){return parseInt(e,10)||0}));if(t.push(0),10===t[0])switch(t[1]){case 5:return"Leopard";case 6:return"Snow Leopard";case 7:return"Lion";case 8:return"Mountain Lion";case 9:return"Mavericks";case 10:return"Yosemite";case 11:return"El Capitan";case 12:return"Sierra";case 13:return"High Sierra";case 14:return"Mojave";case 15:return"Catalina";default:return}},e.getAndroidVersionName=function(e){var t=e.split(".").splice(0,2).map((function(e){return parseInt(e,10)||0}));if(t.push(0),!(1===t[0]&&t[1]<5))return 1===t[0]&&t[1]<6?"Cupcake":1===t[0]&&t[1]>=6?"Donut":2===t[0]&&t[1]<2?"Eclair":2===t[0]&&2===t[1]?"Froyo":2===t[0]&&t[1]>2?"Gingerbread":3===t[0]?"Honeycomb":4===t[0]&&t[1]<1?"Ice Cream Sandwich":4===t[0]&&t[1]<4?"Jelly Bean":4===t[0]&&t[1]>=4?"KitKat":5===t[0]?"Lollipop":6===t[0]?"Marshmallow":7===t[0]?"Nougat":8===t[0]?"Oreo":9===t[0]?"Pie":void 0},e.getVersionPrecision=function(e){return e.split(".").length},e.compareVersions=function(t,r,n){void 0===n&&(n=!1);var i=e.getVersionPrecision(t),o=e.getVersionPrecision(r),a=Math.max(i,o),s=0,c=e.map([t,r],(function(t){var r=a-e.getVersionPrecision(t),n=t+new Array(r+1).join(".0");return e.map(n.split("."),(function(e){return new Array(20-e.length).join("0")+e})).reverse()}));for(n&&(s=a-Math.min(i,o)),a-=1;a>=s;){if(c[0][a]>c[1][a])return 1;if(c[0][a]===c[1][a]){if(a===s)return 0;a-=1}else if(c[0][a]1?i-1:0),a=1;a0){var a=Object.keys(r),c=s.default.find(a,(function(e){return t.isOS(e)}));if(c){var u=this.satisfies(r[c]);if(void 0!==u)return u}var d=s.default.find(a,(function(e){return t.isPlatform(e)}));if(d){var f=this.satisfies(r[d]);if(void 0!==f)return f}}if(o>0){var p=Object.keys(i),l=s.default.find(p,(function(e){return t.isBrowser(e,!0)}));if(void 0!==l)return this.compareVersion(i[l])}},t.isBrowser=function(e,t){void 0===t&&(t=!1);var r=this.getBrowserName().toLowerCase(),n=e.toLowerCase(),i=s.default.getBrowserTypeByAlias(n);return t&&i&&(n=i.toLowerCase()),n===r},t.compareVersion=function(e){var t=[0],r=e,n=!1,i=this.getBrowserVersion();if("string"==typeof i)return">"===e[0]||"<"===e[0]?(r=e.substr(1),"="===e[1]?(n=!0,r=e.substr(2)):t=[],">"===e[0]?t.push(1):t.push(-1)):"="===e[0]?r=e.substr(1):"~"===e[0]&&(n=!0,r=e.substr(1)),t.indexOf(s.default.compareVersions(i,r,n))>-1},t.isOS=function(e){return this.getOSName(!0)===String(e).toLowerCase()},t.isPlatform=function(e){return this.getPlatformType(!0)===String(e).toLowerCase()},t.isEngine=function(e){return this.getEngineName(!0)===String(e).toLowerCase()},t.is=function(e,t){return void 0===t&&(t=!1),this.isBrowser(e,t)||this.isOS(e)||this.isPlatform(e)},t.some=function(e){var t=this;return void 0===e&&(e=[]),e.some((function(e){return t.is(e)}))},e}();t.default=u,e.exports=t.default},92:function(e,t,r){"use strict";t.__esModule=!0,t.default=void 0;var n,i=(n=r(17))&&n.__esModule?n:{default:n},o=/version\/(\d+(\.?_?\d+)+)/i,a=[{test:[/googlebot/i],describe:function(e){var t={name:"Googlebot"},r=i.default.getFirstMatch(/googlebot\/(\d+(\.\d+))/i,e)||i.default.getFirstMatch(o,e);return r&&(t.version=r),t}},{test:[/opera/i],describe:function(e){var t={name:"Opera"},r=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/(?:opera)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/opr\/|opios/i],describe:function(e){var t={name:"Opera"},r=i.default.getFirstMatch(/(?:opr|opios)[\s/](\S+)/i,e)||i.default.getFirstMatch(o,e);return r&&(t.version=r),t}},{test:[/SamsungBrowser/i],describe:function(e){var t={name:"Samsung Internet for Android"},r=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/(?:SamsungBrowser)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/Whale/i],describe:function(e){var t={name:"NAVER Whale Browser"},r=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/(?:whale)[\s/](\d+(?:\.\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/MZBrowser/i],describe:function(e){var t={name:"MZ Browser"},r=i.default.getFirstMatch(/(?:MZBrowser)[\s/](\d+(?:\.\d+)+)/i,e)||i.default.getFirstMatch(o,e);return r&&(t.version=r),t}},{test:[/focus/i],describe:function(e){var t={name:"Focus"},r=i.default.getFirstMatch(/(?:focus)[\s/](\d+(?:\.\d+)+)/i,e)||i.default.getFirstMatch(o,e);return r&&(t.version=r),t}},{test:[/swing/i],describe:function(e){var t={name:"Swing"},r=i.default.getFirstMatch(/(?:swing)[\s/](\d+(?:\.\d+)+)/i,e)||i.default.getFirstMatch(o,e);return r&&(t.version=r),t}},{test:[/coast/i],describe:function(e){var t={name:"Opera Coast"},r=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/(?:coast)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/opt\/\d+(?:.?_?\d+)+/i],describe:function(e){var t={name:"Opera Touch"},r=i.default.getFirstMatch(/(?:opt)[\s/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(o,e);return r&&(t.version=r),t}},{test:[/yabrowser/i],describe:function(e){var t={name:"Yandex Browser"},r=i.default.getFirstMatch(/(?:yabrowser)[\s/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(o,e);return r&&(t.version=r),t}},{test:[/ucbrowser/i],describe:function(e){var t={name:"UC Browser"},r=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/(?:ucbrowser)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/Maxthon|mxios/i],describe:function(e){var t={name:"Maxthon"},r=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/(?:Maxthon|mxios)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/epiphany/i],describe:function(e){var t={name:"Epiphany"},r=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/(?:epiphany)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/puffin/i],describe:function(e){var t={name:"Puffin"},r=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/(?:puffin)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/sleipnir/i],describe:function(e){var t={name:"Sleipnir"},r=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/(?:sleipnir)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/k-meleon/i],describe:function(e){var t={name:"K-Meleon"},r=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/(?:k-meleon)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/micromessenger/i],describe:function(e){var t={name:"WeChat"},r=i.default.getFirstMatch(/(?:micromessenger)[\s/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(o,e);return r&&(t.version=r),t}},{test:[/qqbrowser/i],describe:function(e){var t={name:/qqbrowserlite/i.test(e)?"QQ Browser Lite":"QQ Browser"},r=i.default.getFirstMatch(/(?:qqbrowserlite|qqbrowser)[/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(o,e);return r&&(t.version=r),t}},{test:[/msie|trident/i],describe:function(e){var t={name:"Internet Explorer"},r=i.default.getFirstMatch(/(?:msie |rv:)(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/\sedg\//i],describe:function(e){var t={name:"Microsoft Edge"},r=i.default.getFirstMatch(/\sedg\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/edg([ea]|ios)/i],describe:function(e){var t={name:"Microsoft Edge"},r=i.default.getSecondMatch(/edg([ea]|ios)\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/vivaldi/i],describe:function(e){var t={name:"Vivaldi"},r=i.default.getFirstMatch(/vivaldi\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/seamonkey/i],describe:function(e){var t={name:"SeaMonkey"},r=i.default.getFirstMatch(/seamonkey\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/sailfish/i],describe:function(e){var t={name:"Sailfish"},r=i.default.getFirstMatch(/sailfish\s?browser\/(\d+(\.\d+)?)/i,e);return r&&(t.version=r),t}},{test:[/silk/i],describe:function(e){var t={name:"Amazon Silk"},r=i.default.getFirstMatch(/silk\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/phantom/i],describe:function(e){var t={name:"PhantomJS"},r=i.default.getFirstMatch(/phantomjs\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/slimerjs/i],describe:function(e){var t={name:"SlimerJS"},r=i.default.getFirstMatch(/slimerjs\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/blackberry|\bbb\d+/i,/rim\stablet/i],describe:function(e){var t={name:"BlackBerry"},r=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/blackberry[\d]+\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/(web|hpw)[o0]s/i],describe:function(e){var t={name:"WebOS Browser"},r=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/w(?:eb)?[o0]sbrowser\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/bada/i],describe:function(e){var t={name:"Bada"},r=i.default.getFirstMatch(/dolfin\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/tizen/i],describe:function(e){var t={name:"Tizen"},r=i.default.getFirstMatch(/(?:tizen\s?)?browser\/(\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(o,e);return r&&(t.version=r),t}},{test:[/qupzilla/i],describe:function(e){var t={name:"QupZilla"},r=i.default.getFirstMatch(/(?:qupzilla)[\s/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(o,e);return r&&(t.version=r),t}},{test:[/firefox|iceweasel|fxios/i],describe:function(e){var t={name:"Firefox"},r=i.default.getFirstMatch(/(?:firefox|iceweasel|fxios)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/electron/i],describe:function(e){var t={name:"Electron"},r=i.default.getFirstMatch(/(?:electron)\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/MiuiBrowser/i],describe:function(e){var t={name:"Miui"},r=i.default.getFirstMatch(/(?:MiuiBrowser)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/chromium/i],describe:function(e){var t={name:"Chromium"},r=i.default.getFirstMatch(/(?:chromium)[\s/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(o,e);return r&&(t.version=r),t}},{test:[/chrome|crios|crmo/i],describe:function(e){var t={name:"Chrome"},r=i.default.getFirstMatch(/(?:chrome|crios|crmo)\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/GSA/i],describe:function(e){var t={name:"Google Search"},r=i.default.getFirstMatch(/(?:GSA)\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:function(e){var t=!e.test(/like android/i),r=e.test(/android/i);return t&&r},describe:function(e){var t={name:"Android Browser"},r=i.default.getFirstMatch(o,e);return r&&(t.version=r),t}},{test:[/playstation 4/i],describe:function(e){var t={name:"PlayStation 4"},r=i.default.getFirstMatch(o,e);return r&&(t.version=r),t}},{test:[/safari|applewebkit/i],describe:function(e){var t={name:"Safari"},r=i.default.getFirstMatch(o,e);return r&&(t.version=r),t}},{test:[/.*/i],describe:function(e){var t=-1!==e.search("\\(")?/^(.*)\/(.*)[ \t]\((.*)/:/^(.*)\/(.*) /;return{name:i.default.getFirstMatch(t,e),version:i.default.getSecondMatch(t,e)}}}];t.default=a,e.exports=t.default},93:function(e,t,r){"use strict";t.__esModule=!0,t.default=void 0;var n,i=(n=r(17))&&n.__esModule?n:{default:n},o=r(18),a=[{test:[/Roku\/DVP/],describe:function(e){var t=i.default.getFirstMatch(/Roku\/DVP-(\d+\.\d+)/i,e);return{name:o.OS_MAP.Roku,version:t}}},{test:[/windows phone/i],describe:function(e){var t=i.default.getFirstMatch(/windows phone (?:os)?\s?(\d+(\.\d+)*)/i,e);return{name:o.OS_MAP.WindowsPhone,version:t}}},{test:[/windows /i],describe:function(e){var t=i.default.getFirstMatch(/Windows ((NT|XP)( \d\d?.\d)?)/i,e),r=i.default.getWindowsVersionName(t);return{name:o.OS_MAP.Windows,version:t,versionName:r}}},{test:[/Macintosh(.*?) FxiOS(.*?)\//],describe:function(e){var t={name:o.OS_MAP.iOS},r=i.default.getSecondMatch(/(Version\/)(\d[\d.]+)/,e);return r&&(t.version=r),t}},{test:[/macintosh/i],describe:function(e){var t=i.default.getFirstMatch(/mac os x (\d+(\.?_?\d+)+)/i,e).replace(/[_\s]/g,"."),r=i.default.getMacOSVersionName(t),n={name:o.OS_MAP.MacOS,version:t};return r&&(n.versionName=r),n}},{test:[/(ipod|iphone|ipad)/i],describe:function(e){var t=i.default.getFirstMatch(/os (\d+([_\s]\d+)*) like mac os x/i,e).replace(/[_\s]/g,".");return{name:o.OS_MAP.iOS,version:t}}},{test:function(e){var t=!e.test(/like android/i),r=e.test(/android/i);return t&&r},describe:function(e){var t=i.default.getFirstMatch(/android[\s/-](\d+(\.\d+)*)/i,e),r=i.default.getAndroidVersionName(t),n={name:o.OS_MAP.Android,version:t};return r&&(n.versionName=r),n}},{test:[/(web|hpw)[o0]s/i],describe:function(e){var t=i.default.getFirstMatch(/(?:web|hpw)[o0]s\/(\d+(\.\d+)*)/i,e),r={name:o.OS_MAP.WebOS};return t&&t.length&&(r.version=t),r}},{test:[/blackberry|\bbb\d+/i,/rim\stablet/i],describe:function(e){var t=i.default.getFirstMatch(/rim\stablet\sos\s(\d+(\.\d+)*)/i,e)||i.default.getFirstMatch(/blackberry\d+\/(\d+([_\s]\d+)*)/i,e)||i.default.getFirstMatch(/\bbb(\d+)/i,e);return{name:o.OS_MAP.BlackBerry,version:t}}},{test:[/bada/i],describe:function(e){var t=i.default.getFirstMatch(/bada\/(\d+(\.\d+)*)/i,e);return{name:o.OS_MAP.Bada,version:t}}},{test:[/tizen/i],describe:function(e){var t=i.default.getFirstMatch(/tizen[/\s](\d+(\.\d+)*)/i,e);return{name:o.OS_MAP.Tizen,version:t}}},{test:[/linux/i],describe:function(){return{name:o.OS_MAP.Linux}}},{test:[/CrOS/],describe:function(){return{name:o.OS_MAP.ChromeOS}}},{test:[/PlayStation 4/],describe:function(e){var t=i.default.getFirstMatch(/PlayStation 4[/\s](\d+(\.\d+)*)/i,e);return{name:o.OS_MAP.PlayStation4,version:t}}}];t.default=a,e.exports=t.default},94:function(e,t,r){"use strict";t.__esModule=!0,t.default=void 0;var n,i=(n=r(17))&&n.__esModule?n:{default:n},o=r(18),a=[{test:[/googlebot/i],describe:function(){return{type:"bot",vendor:"Google"}}},{test:[/huawei/i],describe:function(e){var t=i.default.getFirstMatch(/(can-l01)/i,e)&&"Nova",r={type:o.PLATFORMS_MAP.mobile,vendor:"Huawei"};return t&&(r.model=t),r}},{test:[/nexus\s*(?:7|8|9|10).*/i],describe:function(){return{type:o.PLATFORMS_MAP.tablet,vendor:"Nexus"}}},{test:[/ipad/i],describe:function(){return{type:o.PLATFORMS_MAP.tablet,vendor:"Apple",model:"iPad"}}},{test:[/Macintosh(.*?) FxiOS(.*?)\//],describe:function(){return{type:o.PLATFORMS_MAP.tablet,vendor:"Apple",model:"iPad"}}},{test:[/kftt build/i],describe:function(){return{type:o.PLATFORMS_MAP.tablet,vendor:"Amazon",model:"Kindle Fire HD 7"}}},{test:[/silk/i],describe:function(){return{type:o.PLATFORMS_MAP.tablet,vendor:"Amazon"}}},{test:[/tablet(?! pc)/i],describe:function(){return{type:o.PLATFORMS_MAP.tablet}}},{test:function(e){var t=e.test(/ipod|iphone/i),r=e.test(/like (ipod|iphone)/i);return t&&!r},describe:function(e){var t=i.default.getFirstMatch(/(ipod|iphone)/i,e);return{type:o.PLATFORMS_MAP.mobile,vendor:"Apple",model:t}}},{test:[/nexus\s*[0-6].*/i,/galaxy nexus/i],describe:function(){return{type:o.PLATFORMS_MAP.mobile,vendor:"Nexus"}}},{test:[/[^-]mobi/i],describe:function(){return{type:o.PLATFORMS_MAP.mobile}}},{test:function(e){return"blackberry"===e.getBrowserName(!0)},describe:function(){return{type:o.PLATFORMS_MAP.mobile,vendor:"BlackBerry"}}},{test:function(e){return"bada"===e.getBrowserName(!0)},describe:function(){return{type:o.PLATFORMS_MAP.mobile}}},{test:function(e){return"windows phone"===e.getBrowserName()},describe:function(){return{type:o.PLATFORMS_MAP.mobile,vendor:"Microsoft"}}},{test:function(e){var t=Number(String(e.getOSVersion()).split(".")[0]);return"android"===e.getOSName(!0)&&t>=3},describe:function(){return{type:o.PLATFORMS_MAP.tablet}}},{test:function(e){return"android"===e.getOSName(!0)},describe:function(){return{type:o.PLATFORMS_MAP.mobile}}},{test:function(e){return"macos"===e.getOSName(!0)},describe:function(){return{type:o.PLATFORMS_MAP.desktop,vendor:"Apple"}}},{test:function(e){return"windows"===e.getOSName(!0)},describe:function(){return{type:o.PLATFORMS_MAP.desktop}}},{test:function(e){return"linux"===e.getOSName(!0)},describe:function(){return{type:o.PLATFORMS_MAP.desktop}}},{test:function(e){return"playstation 4"===e.getOSName(!0)},describe:function(){return{type:o.PLATFORMS_MAP.tv}}},{test:function(e){return"roku"===e.getOSName(!0)},describe:function(){return{type:o.PLATFORMS_MAP.tv}}}];t.default=a,e.exports=t.default},95:function(e,t,r){"use strict";t.__esModule=!0,t.default=void 0;var n,i=(n=r(17))&&n.__esModule?n:{default:n},o=r(18),a=[{test:function(e){return"microsoft edge"===e.getBrowserName(!0)},describe:function(e){if(/\sedg\//i.test(e))return{name:o.ENGINE_MAP.Blink};var t=i.default.getFirstMatch(/edge\/(\d+(\.?_?\d+)+)/i,e);return{name:o.ENGINE_MAP.EdgeHTML,version:t}}},{test:[/trident/i],describe:function(e){var t={name:o.ENGINE_MAP.Trident},r=i.default.getFirstMatch(/trident\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:function(e){return e.test(/presto/i)},describe:function(e){var t={name:o.ENGINE_MAP.Presto},r=i.default.getFirstMatch(/presto\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:function(e){var t=e.test(/gecko/i),r=e.test(/like gecko/i);return t&&!r},describe:function(e){var t={name:o.ENGINE_MAP.Gecko},r=i.default.getFirstMatch(/gecko\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/(apple)?webkit\/537\.36/i],describe:function(){return{name:o.ENGINE_MAP.Blink}}},{test:[/(apple)?webkit/i],describe:function(e){var t={name:o.ENGINE_MAP.WebKit},r=i.default.getFirstMatch(/webkit\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}}];t.default=a,e.exports=t.default}})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n,i,o=r(2),a=r(6),s=r(5),c=r(3),u=r(0),d=r(4);!function(e){e[e.played=1]="played",e[e.playing=2]="playing",e[e.paused=3]="paused"}(n||(n={})),function(e){e[e.played=1]="played",e[e.playing=2]="playing",e[e.paused=3]="paused"}(i||(i={}));var f=function(e){function t(t,r,o){var a=e.call(this)||this;a.mute=!1,a.audioMediaStream=new MediaStream,a.videoMediaStream=new MediaStream,a.isPlayVideoLocked=!1,a.audioPlayStatus=n.paused,a.videoPlayStatus=i.paused,a.onTrackStateChange=function(e){var t=e.target.kind;switch(e.type){case"mute":u.default.debug("player - "+t+" mute",a.stream.streamId);break;case"unmute":u.default.debug("player - "+t+" unmute",a.stream.streamId);break;case"ended":u.default.debug("player - "+t+" ended",a.stream.streamId)}},a.container=r,a.stream=t;var s=o.mute,c=void 0!==s&&s,d=o.mirror,f=void 0!==d&&d,p=o.fit,l=o.controls;return l&&(a.controls=l),a.mute=c,a.initWrapper(),a.initVideoElement(f,p),a.wrapper.appendChild(a.video),a.initAudioElement(c),a.wrapper.appendChild(a.audio),a.init(),a}return o.__extends(t,e),Object.defineProperty(t.prototype,"isPlaying",{get:function(){return this.audioPlayStatus===n.playing&&this.videoPlayStatus===i.playing},enumerable:!0,configurable:!0}),t.prototype.updateAudioTrack=function(e){var t=this;this.audioMediaStream.getAudioTracks().forEach((function(e){e.removeEventListener("mute",t.onTrackStateChange),e.removeEventListener("unmute",t.onTrackStateChange),e.removeEventListener("ended",t.onTrackStateChange),t.audioMediaStream.removeTrack(e)})),e.addEventListener("mute",this.onTrackStateChange),e.addEventListener("unmute",this.onTrackStateChange),e.addEventListener("ended",this.onTrackStateChange),this.audioMediaStream.addTrack(e)},t.prototype.updateVideoTrack=function(e){var t=this;this.videoMediaStream.getVideoTracks().forEach((function(e){e.removeEventListener("mute",t.onTrackStateChange),e.removeEventListener("unmute",t.onTrackStateChange),e.removeEventListener("ended",t.onTrackStateChange),t.videoMediaStream.removeTrack(e)})),e.addEventListener("mute",this.onTrackStateChange),e.addEventListener("unmute",this.onTrackStateChange),e.addEventListener("ended",this.onTrackStateChange),this.videoMediaStream.addTrack(e)},t.prototype.hasAudio=function(){return this.stream.isSubscriber?this.stream.audio:this.stream.hasAudio()},t.prototype.hasVideo=function(){return this.stream.isSubscriber?this.stream.video:this.stream.hasVideo()},t.prototype.init=function(){var e=this,t=this.stream.getMediaStream();if(t){var r=t.getAudioTracks()[0];r&&this.updateAudioTrack(r);var o=t.getVideoTracks()[0];o&&this.updateVideoTrack(o)}this.audio.addEventListener("play",(function(){u.default.info("audio played"),e.updateControls(e.audio,!0)})),this.audio.addEventListener("playing",(function(){u.default.info("audio playing"),e.hasVideo()||e.emit("playing"),e.audioPlayStatus!==n.playing&&e.emit("audio-playing"),e.hasVideo()&&!e.isPlayVideoLocked&&e.playVideo().catch((function(e){u.default.info("audio trigger autoplay video "+e,e),u.default.report("audio trigger autoplay video "+e,e)})),e.audioPlayStatus=n.playing})),this.audio.addEventListener("pause",(function(){u.default.info("audio paused"),e.hasVideo()||e.emit("paused"),e.audioPlayStatus!==n.paused&&e.emit("audio-paused"),e.audioPlayStatus=n.paused,e.updateControls(e.audio,!1)})),this.video.addEventListener("play",(function(){u.default.info("video played")})),this.video.addEventListener("playing",(function(){u.default.info("video playing"),e.emit("playing"),e.videoPlayStatus!==i.playing&&e.emit("video-playing"),e.videoPlayStatus=i.playing,e.video.controls=!1})),this.video.addEventListener("pause",(function(){u.default.info("video paused"),e.emit("paused"),e.videoPlayStatus!==i.paused&&e.emit("video-paused"),e.videoPlayStatus=i.paused})),this.video.addEventListener("stalled",(function(){u.default.info("video stalled")})),this.video.addEventListener("canplay",(function(){u.default.info("video canplay")})),this.video.addEventListener("suspend",(function(){u.default.info("video suspend")})),this.video.addEventListener("timer",(function(){u.default.info("video timer")})),this.video.addEventListener("waiting",(function(){u.default.info("video waiting")})),this.video.addEventListener("seeking",(function(){u.default.info("video seeking")}))},t.prototype.updateControls=function(e,t){switch(this.controls){case"hide":e.style.display="none",e.controls=!1;break;case"show":e.style.display="inline-block",e.controls=!0;break;case"auto":default:t?(e.style.display="none",e.controls=!1):(e.style.display="inline-block",e.controls=!0)}},t.prototype.playAudio=function(){return this.audio.srcObject=this.audioMediaStream,this.mute?Promise.resolve():this.audio.play().catch((function(e){if(!e||!e.toString().toLowerCase().includes("the play() request was interrupted by a"))throw e}))},t.prototype.playVideo=function(){var e=this;return this.video.srcObject=this.videoMediaStream,new Promise((function(t,r){return o.__awaiter(e,void 0,void 0,(function(){var e,n,i;return o.__generator(this,(function(o){switch(o.label){case 0:e=this.stream.videoMuted||this.stream.sourceVideoMuted?window.setTimeout((function(){t()}),1e3):window.setTimeout((function(){r(c.createError(c.ErrorCodes.OTHERS,"the play() request was pending"))}),8e3),n=function(){window.clearTimeout(e),t()},o.label=1;case 1:return o.trys.push([1,3,,4]),[4,this.video.play()];case 2:return o.sent(),n(),[3,4];case 3:return(i=o.sent())&&i.toString().toLowerCase().includes("the play() request was interrupted by a")?n():i&&i.toString().toLowerCase().includes("the operation was aborted")?n():r(i),[3,4];case 4:return[2]}}))}))}))},t.prototype.resume=function(){return o.__awaiter(this,void 0,void 0,(function(){var e,t;return o.__generator(this,(function(r){switch(r.label){case 0:if(this.isPlayVideoLocked=!0,!this.hasAudio())return[3,4];r.label=1;case 1:return r.trys.push([1,3,,4]),this.updateControls(this.audio,!1),u.default.debug("player - before resume audio "+this.stream.streamId),[4,this.playAudio()];case 2:return r.sent(),u.default.debug("player - resume audio "+this.stream.streamId),[3,4];case 3:throw e=r.sent(),u.default.warn("player - resume audio error "+e),u.default.report("player - resume "+this.stream.streamId+" audio error "+e),this.updateControls(this.audio,!1),this.isPlayVideoLocked=!1,e;case 4:if(!this.hasVideo())return[3,8];r.label=5;case 5:return r.trys.push([5,7,,8]),u.default.debug("player - before resume video "+this.stream.streamId),[4,this.playVideo()];case 6:return r.sent(),u.default.debug("player - resume video "+this.stream.streamId),[3,8];case 7:throw t=r.sent(),u.default.warn("player - resume video error "+t),u.default.report("player - resume "+this.stream.streamId+" video error "+t),this.isPlayVideoLocked=!1,t;case 8:return this.isPlayVideoLocked=!1,[2]}}))}))},t.prototype.play=function(){return o.__awaiter(this,void 0,void 0,(function(){var e,t;return o.__generator(this,(function(r){switch(r.label){case 0:if(!this.stream.getMediaStream())return[2,Promise.reject(c.createError(c.ErrorCodes.INVALID_MEDIASTREAM,"no media stream can play"))];if(this.container.appendChild(this.wrapper),this.isPlayVideoLocked=!0,!this.hasAudio())return[3,4];r.label=1;case 1:return r.trys.push([1,3,,4]),this.updateControls(this.audio,!1),u.default.debug("player - before play audio "+this.stream.streamId),[4,this.playAudio()];case 2:return r.sent(),u.default.debug("player - play audio "+this.stream.streamId),[3,4];case 3:throw e=r.sent(),u.default.warn("player - play audio error "+e),u.default.report("player - play "+this.stream.streamId+" audio error "+e),this.updateControls(this.audio,!1),this.isPlayVideoLocked=!1,e;case 4:if(!this.hasVideo())return[3,8];r.label=5;case 5:return r.trys.push([5,7,,8]),u.default.debug("player - before play video "+this.stream.streamId),[4,this.playVideo()];case 6:return r.sent(),u.default.debug("player - play video "+this.stream.streamId),[3,8];case 7:throw t=r.sent(),d.default.isIOS()&&d.default.isWeChat()&&!this.hasAudio()&&"NotAllowedError"===t.name&&"hide"!==this.controls&&(this.video.controlsList="nodownload nofullscreen noremoteplayback",this.video.controls=!0),u.default.warn("player - play video error "+t),u.default.report("player - play "+this.stream.streamId+" video error "+t),this.isPlayVideoLocked=!1,t;case 8:return this.isPlayVideoLocked=!1,[2]}}))}))},t.prototype.stop=function(){this.audio.pause(),this.video.pause()},t.prototype.destroy=function(){try{this.stop()}catch(e){u.default.warn(e.name+": "+e.message)}try{this.container.removeChild(this.wrapper)}catch(e){u.default.warn(e.name+": "+e.message)}},t.prototype.initWrapper=function(){this.wrapper=document.createElement("div"),this.hasVideo()?this.wrapper.setAttribute("style","width: 100%; height: 100%; position: relative; background-color: black; overflow: hidden;"):this.wrapper.setAttribute("style","width: 100%; height: 100%; position: relative; overflow: hidden;")},t.prototype.initAudioElement=function(e){void 0===e&&(e=!1),this.audio=document.createElement("audio"),this.audio.setAttribute("id","audio-"+this.stream.streamId),e&&(this.audio.setAttribute("muted","muted"),this.audio.muted=!0,this.audio.volume=0),this.audio.setAttribute("style","position: absolute; bottom: 0; width: 100%; opacity: 0.5;"),d.default.isChrome()&&(this.audio.style.maxHeight="20%",d.isMobile()||(this.audio.style.backgroundColor="#eee")),this.audio.setAttribute("playsinline",""),this.audio.setAttribute("webkit-playsinline","true"),this.stream.isSubscriber||(this.audio.style.visibility="hidden",this.audio.style.zIndex="-1")},t.prototype.initVideoElement=function(e,t){void 0===e&&(e=!1),this.video=document.createElement("video"),this.video.setAttribute("id","video-"+this.stream.streamId),this.stream.isSubscriber||"user"===this.stream.config.facingMode&&(e=!0),t||(t="cover",this.stream.mediaType===s.ENUM_MEDIA_TYPE.desktop&&(t="contain"));var r="width: 100%; height: 100%; position: absolute;";e&&(r+="transform: rotateY(180deg);"),r+="object-fit: "+t,this.video.setAttribute("style",r),this.video.setAttribute("muted","muted"),this.video.muted=!0,this.video.volume=0,this.video.setAttribute("playsinline",""),this.video.setAttribute("webkit-playsinline","true")},t.prototype.setAudioVolume=function(e){e/=100,this.audio.volume=e},t}(a.EventEmitter);t.Player=f},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(0),i=function(){function e(e){var t=this;if(!!!Worker)throw new Error("Web Worker is Not Enabled");var r=e.toString().replace(/^[^{]*{\s*/,"").replace(/\s*}[^}]*$/,"");this.worker=new Worker(URL.createObjectURL(new Blob([r],{type:"text/javascript"}))),this.worker.onmessage=function(e){t.onmessage(e)},this.worker.onerror=function(e){t.onerror(e)}}return e.prototype.postMessage=function(e){this.worker.postMessage(e)},e.prototype.onmessage=function(e){n.default.debug("onmessage ",e)},e.prototype.onerror=function(e){n.default.debug("onerror ",e)},e.prototype.terminate=function(){var e;null===(e=this.worker)||void 0===e||e.terminate()},e}();t.InlineWorker=i},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(2),i=r(87),o=r(6),a=r(11),s=r(39),c=r(9),u=r(0),d=r(3),f=r(5),p=function(e){function t(){var t=e.call(this)||this;return t.streams=new Map,t.on("screen-track-ended",(function(e){u.default.debug("screen-track-ended",e);var r=t.getStream(e.streamId);r&&t.emitter&&t.emitter.emit("screenshare-stopped",r.convertToOuterStream())})),t.on("stream-close",(function(e){e.destroyPlayer()})),t}return n.__extends(t,e),t.prototype.createStream=function(e,t,r,o){var u,d=this;t||(t=i.v4()),u="preview"===t?{audio:r.audio,video:r.video,screen:!1,data:!1,mediaType:f.ENUM_MEDIA_TYPE.camera,microphoneId:r.microphoneId,cameraId:r.cameraId,facingMode:r.facingMode}:s.StreamManager.generatePublishConfig(r);var p,l=new a.LocalStream(e,u,this);return l.previewId=t,l.streamId=t,p="object"==typeof o?c.getCustomResolution(o):c.getResolution(o),l.setResolution(p),new Promise((function(e,t){return n.__awaiter(d,void 0,void 0,(function(){var i;return n.__generator(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,l.init(r)];case 1:return n.sent(),this.streams.set(l.streamId,l),e(l),[3,3];case 2:return i=n.sent(),l.close(),t(i),[3,3];case 3:return[2]}}))}))}))},t.prototype.copyStream=function(e){var t=this,r=new a.LocalStream(e.userId,e.config,this);return r.previewId=e.previewId||e.streamId,r.streamId=e.streamId,r.setResolution(e.resolution),this.streams.set(r.streamId,r),new Promise((function(i,o){return n.__awaiter(t,void 0,void 0,(function(){var t;return n.__generator(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,r.init({},e)];case 1:return n.sent(),i(r),[3,3];case 2:return t=n.sent(),o(t),[3,3];case 3:return[2]}}))}))}))},t.prototype.removeStream=function(e,t){var r=this;return new Promise((function(n,i){var o=r.getStream(e);o?(o.close(t),r.streams.delete(o.streamId),n()):i(d.createError(d.ErrorCodes.STREAM_NOT_EXISTS,"stream isnot found"))}))},t.prototype.removeAllStreams=function(){var e=this;return new Promise((function(t,r){try{e.streams.forEach((function(e){e.close()})),e.streams.clear(),t()}catch(e){r(e)}}))},t.prototype.getStream=function(e){var t;return(t=this.streams.get(e))||this.streams.forEach((function(r){r.previewId===e&&(t=r)})),t},t.prototype.getAllStreams=function(){var e=[];return this.streams.forEach((function(t){e.push(t)})),e},t.prototype.setVideoProfile=function(e,t){var r;r="object"==typeof t?c.getCustomResolution(t):c.getResolution(t);var n=this.getStream(e);return n?(n.setResolution(r),n.applyResolution(r)):Promise.reject(d.createError(d.ErrorCodes.STREAM_NOT_EXISTS,"stream isn't found"))},t.prototype.destroy=function(){this.removeAllStreams().catch((function(e){u.default.warn("remove all preview streams error: "+e)}))},t}(o.EventEmitter);t.PreviewStreamManager=p},function(module,exports,__webpack_require__){(function(global){var __WEBPACK_AMD_DEFINE_ARRAY__,__WEBPACK_AMD_DEFINE_RESULT__;!function(e,t){module.exports=t(e)}("undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0!==global?global:this,(function(global){"use strict";global=global||{};var _Base64=global.Base64,version="2.5.1",buffer;if(module.exports)try{buffer=eval("require('buffer').Buffer")}catch(e){buffer=void 0}var b64chars="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",b64tab=function(e){for(var t={},r=0,n=e.length;r>>6)+fromCharCode(128|63&t):fromCharCode(224|t>>>12&15)+fromCharCode(128|t>>>6&63)+fromCharCode(128|63&t);var t=65536+1024*(e.charCodeAt(0)-55296)+(e.charCodeAt(1)-56320);return fromCharCode(240|t>>>18&7)+fromCharCode(128|t>>>12&63)+fromCharCode(128|t>>>6&63)+fromCharCode(128|63&t)},re_utob=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,utob=function(e){return e.replace(re_utob,cb_utob)},cb_encode=function(e){var t=[0,2,1][e.length%3],r=e.charCodeAt(0)<<16|(e.length>1?e.charCodeAt(1):0)<<8|(e.length>2?e.charCodeAt(2):0);return[b64chars.charAt(r>>>18),b64chars.charAt(r>>>12&63),t>=2?"=":b64chars.charAt(r>>>6&63),t>=1?"=":b64chars.charAt(63&r)].join("")},btoa=global.btoa?function(e){return global.btoa(e)}:function(e){return e.replace(/[\s\S]{1,3}/g,cb_encode)},_encode=buffer?buffer.from&&Uint8Array&&buffer.from!==Uint8Array.from?function(e){return(e.constructor===buffer.constructor?e:buffer.from(e)).toString("base64")}:function(e){return(e.constructor===buffer.constructor?e:new buffer(e)).toString("base64")}:function(e){return btoa(utob(e))},encode=function(e,t){return t?_encode(String(e)).replace(/[+\/]/g,(function(e){return"+"==e?"-":"_"})).replace(/=/g,""):_encode(String(e))},encodeURI=function(e){return encode(e,!0)},re_btou=new RegExp(["[À-ß][€-¿]","[à-ï][€-¿]{2}","[ð-÷][€-¿]{3}"].join("|"),"g"),cb_btou=function(e){switch(e.length){case 4:var t=((7&e.charCodeAt(0))<<18|(63&e.charCodeAt(1))<<12|(63&e.charCodeAt(2))<<6|63&e.charCodeAt(3))-65536;return fromCharCode(55296+(t>>>10))+fromCharCode(56320+(1023&t));case 3:return fromCharCode((15&e.charCodeAt(0))<<12|(63&e.charCodeAt(1))<<6|63&e.charCodeAt(2));default:return fromCharCode((31&e.charCodeAt(0))<<6|63&e.charCodeAt(1))}},btou=function(e){return e.replace(re_btou,cb_btou)},cb_decode=function(e){var t=e.length,r=t%4,n=(t>0?b64tab[e.charAt(0)]<<18:0)|(t>1?b64tab[e.charAt(1)]<<12:0)|(t>2?b64tab[e.charAt(2)]<<6:0)|(t>3?b64tab[e.charAt(3)]:0),i=[fromCharCode(n>>>16),fromCharCode(n>>>8&255),fromCharCode(255&n)];return i.length-=[0,0,2,1][r],i.join("")},_atob=global.atob?function(e){return global.atob(e)}:function(e){return e.replace(/\S{1,4}/g,cb_decode)},atob=function(e){return _atob(String(e).replace(/[^A-Za-z0-9\+\/]/g,""))},_decode=buffer?buffer.from&&Uint8Array&&buffer.from!==Uint8Array.from?function(e){return(e.constructor===buffer.constructor?e:buffer.from(e,"base64")).toString()}:function(e){return(e.constructor===buffer.constructor?e:new buffer(e,"base64")).toString()}:function(e){return btou(_atob(e))},decode=function(e){return _decode(String(e).replace(/[-_]/g,(function(e){return"-"==e?"+":"/"})).replace(/[^A-Za-z0-9\+\/]/g,""))},noConflict=function(){var e=global.Base64;return global.Base64=_Base64,e};if(global.Base64={VERSION:version,atob:atob,btoa:btoa,fromBase64:decode,toBase64:encode,utob:utob,encode:encode,encodeURI:encodeURI,btou:btou,decode:decode,noConflict:noConflict,__buffer__:buffer},"function"==typeof Object.defineProperty){var noEnum=function(e){return{value:e,enumerable:!1,writable:!0,configurable:!0}};global.Base64.extendString=function(){Object.defineProperty(String.prototype,"fromBase64",noEnum((function(){return decode(this)}))),Object.defineProperty(String.prototype,"toBase64",noEnum((function(e){return encode(this,e)}))),Object.defineProperty(String.prototype,"toBase64URI",noEnum((function(){return encode(this,!0)})))}}return global.Meteor&&(Base64=global.Base64),module.exports?module.exports.Base64=global.Base64:(__WEBPACK_AMD_DEFINE_ARRAY__=[],__WEBPACK_AMD_DEFINE_RESULT__=function(){return global.Base64}.apply(exports,__WEBPACK_AMD_DEFINE_ARRAY__),void 0===__WEBPACK_AMD_DEFINE_RESULT__||(module.exports=__WEBPACK_AMD_DEFINE_RESULT__)),{Base64:global.Base64}}))}).call(this,__webpack_require__(8))},function(e,t,r){"use strict";var n;!function(i){function o(e,t,r){var n,i,o,a,l,m,h,v,g,y=0,E=[],b=0,_=!1,S=[],T=[],w=!1,R=!1,M=-1;if(n=(r=r||{}).encoding||"UTF8",(g=r.numRounds||1)!==parseInt(g,10)||1>g)throw Error("numRounds must a integer >= 1");if("SHA-1"===e)l=512,m=D,h=V,a=160,v=function(e){return e.slice()};else if(0===e.lastIndexOf("SHA-",0))if(m=function(t,r){return B(t,r,e)},h=function(t,r,n,i){var o,a;if("SHA-224"===e||"SHA-256"===e)o=15+(r+65>>>9<<4),a=16;else{if("SHA-384"!==e&&"SHA-512"!==e)throw Error("Unexpected error in SHA-2 implementation");o=31+(r+129>>>10<<5),a=32}for(;t.length<=o;)t.push(0);for(t[r>>>5]|=128<<24-r%32,r+=n,t[o]=4294967295&r,t[o-1]=r/4294967296|0,n=t.length,r=0;rt;t+=1)r[t]=e[t].slice();return r},M=1,"SHA3-224"===e)l=1152,a=224;else if("SHA3-256"===e)l=1088,a=256;else if("SHA3-384"===e)l=832,a=384;else if("SHA3-512"===e)l=576,a=512;else if("SHAKE128"===e)l=1344,a=-1,C=31,R=!0;else{if("SHAKE256"!==e)throw Error("Chosen SHA variant is not supported");l=1088,a=-1,C=31,R=!0}h=function(e,t,r,n,i){var o,a=C,s=[],c=(r=l)>>>5,u=0,d=t>>>5;for(o=0;o=r;o+=c)n=F(e.slice(o,o+c),n),t-=r;for(e=e.slice(o),t%=r;e.length>>3)>>2]^=a<=i));)s.push(e.a),0==64*(u+=1)%r&&F(null,n);return s}}o=p(t,n,M),i=j(e),this.setHMACKey=function(t,r,o){var s;if(!0===_)throw Error("HMAC key already set");if(!0===w)throw Error("Cannot set HMAC key after calling update");if(!0===R)throw Error("SHAKE is not supported for HMAC");if(t=(r=p(r,n=(o||{}).encoding||"UTF8",M)(t)).binLen,r=r.value,o=(s=l>>>3)/4-1,st/8){for(;r.length<=o;)r.push(0);r[o]&=4294967040}for(t=0;t<=o;t+=1)S[t]=909522486^r[t],T[t]=1549556828^r[t];i=m(S,i),y=l,_=!0},this.update=function(e){var t,r,n,a=0,s=l>>>5;for(e=(t=o(e,E,b)).binLen,r=t.value,t=e>>>5,n=0;n>>5),b=e%l,w=!0},this.getHash=function(t,r){var n,o,p,l;if(!0===_)throw Error("Cannot call getHash after setting HMAC key");if(p=f(r),!0===R){if(-1===p.shakeLen)throw Error("shakeLen must be specified in options");a=p.shakeLen}switch(t){case"HEX":n=function(e){return s(e,a,M,p)};break;case"B64":n=function(e){return c(e,a,M,p)};break;case"BYTES":n=function(e){return u(e,a,M)};break;case"ARRAYBUFFER":try{o=new ArrayBuffer(0)}catch(e){throw Error("ARRAYBUFFER not supported by this environment")}n=function(e){return d(e,a,M)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER")}for(l=h(E.slice(),b,y,v(i),a),o=1;o>>24-a%32),l=h(l,a,0,j(e),a);return n(l)},this.getHMAC=function(t,r){var n,o,p,g;if(!1===_)throw Error("Cannot call getHMAC without first setting HMAC key");switch(p=f(r),t){case"HEX":n=function(e){return s(e,a,M,p)};break;case"B64":n=function(e){return c(e,a,M,p)};break;case"BYTES":n=function(e){return u(e,a,M)};break;case"ARRAYBUFFER":try{n=new ArrayBuffer(0)}catch(e){throw Error("ARRAYBUFFER not supported by this environment")}n=function(e){return d(e,a,M)};break;default:throw Error("outputFormat must be HEX, B64, BYTES, or ARRAYBUFFER")}return o=h(E.slice(),b,y,v(i),a),g=m(T,j(e)),n(g=h(o,a,l,g,a))}}function a(e,t){this.a=e,this.b=t}function s(e,t,r,n){var i,o,a,s="";for(t/=8,a=-1===r?3:0,i=0;i>>2]>>>8*(a+i%4*r),s+="0123456789abcdef".charAt(o>>>4&15)+"0123456789abcdef".charAt(15&o);return n.outputUpper?s.toUpperCase():s}function c(e,t,r,n){var i,o,a,s,c="",u=t/8;for(s=-1===r?3:0,i=0;i>>2]:0,a=i+2>>2]:0,a=(e[i>>>2]>>>8*(s+i%4*r)&255)<<16|(o>>>8*(s+(i+1)%4*r)&255)<<8|a>>>8*(s+(i+2)%4*r)&255,o=0;4>o;o+=1)c+=8*i+6*o<=t?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(a>>>6*(3-o)&63):n.b64Pad;return c}function u(e,t,r){var n,i,o,a="";for(t/=8,o=-1===r?3:0,n=0;n>>2]>>>8*(o+n%4*r)&255,a+=String.fromCharCode(i);return a}function d(e,t,r){t/=8;var n,i,o,a=new ArrayBuffer(t);for(o=new Uint8Array(a),i=-1===r?3:0,n=0;n>>2]>>>8*(i+n%4*r)&255;return a}function f(e){var t={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(e=e||{},t.outputUpper=e.outputUpper||!1,!0===e.hasOwnProperty("b64Pad")&&(t.b64Pad=e.b64Pad),!0===e.hasOwnProperty("shakeLen")){if(0!=e.shakeLen%8)throw Error("shakeLen must be a multiple of 8");t.shakeLen=e.shakeLen}if("boolean"!=typeof t.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof t.b64Pad)throw Error("Invalid b64Pad formatting option");return t}function p(e,t,r){switch(t){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(e){case"HEX":e=function(e,t,n){var i,o,a,s,c,u,d=e.length;if(0!=d%2)throw Error("String of HEX type must be in byte increments");for(t=t||[0],c=(n=n||0)>>>3,u=-1===r?3:0,i=0;i>>1)+c)>>>2;t.length<=a;)t.push(0);t[a]|=o<<8*(u+s%4*r)}return{value:t,binLen:4*d+n}};break;case"TEXT":e=function(e,n,i){var o,a,s,c,u,d,f,p,l=0;if(n=n||[0],u=(i=i||0)>>>3,"UTF8"===t)for(p=-1===r?3:0,s=0;s(o=e.charCodeAt(s))?a.push(o):2048>o?(a.push(192|o>>>6),a.push(128|63&o)):55296>o||57344<=o?a.push(224|o>>>12,128|o>>>6&63,128|63&o):(s+=1,o=65536+((1023&o)<<10|1023&e.charCodeAt(s)),a.push(240|o>>>18,128|o>>>12&63,128|o>>>6&63,128|63&o)),c=0;c>>2;n.length<=d;)n.push(0);n[d]|=a[c]<<8*(p+f%4*r),l+=1}else if("UTF16BE"===t||"UTF16LE"===t)for(p=-1===r?2:0,a="UTF16LE"===t&&1!==r||"UTF16LE"!==t&&1===r,s=0;s>>8),d=(f=l+u)>>>2;n.length<=d;)n.push(0);n[d]|=o<<8*(p+f%4*r),l+=2}return{value:n,binLen:8*l+i}};break;case"B64":e=function(e,t,n){var i,o,a,s,c,u,d,f,p=0;if(-1===e.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(o=e.indexOf("="),e=e.replace(/\=/g,""),-1!==o&&oe===t))throw new DOMException("The adapter.js addTrack polyfill only supports a single stream which is associated with the specified track.","NotSupportedError");const i=this.getSenders().find(e=>e.track===t);if(i)throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};const o=this._streams[r.id];if(o)o.addTrack(t),Promise.resolve().then(()=>{this.dispatchEvent(new Event("negotiationneeded"))});else{const n=new e.MediaStream([t]);this._streams[r.id]=n,this._reverseStreams[n.id]=r,this.addStream(n)}return this.getSenders().find(e=>e.track===t)},["createOffer","createAnswer"].forEach((function(t){const r=e.RTCPeerConnection.prototype[t],n={[t](){const e=arguments;return arguments.length&&"function"==typeof arguments[0]?r.apply(this,[t=>{const r=o(this,t);e[0].apply(null,[r])},t=>{e[1]&&e[1].apply(null,t)},arguments[2]]):r.apply(this,arguments).then(e=>o(this,e))}};e.RTCPeerConnection.prototype[t]=n[t]}));const s=e.RTCPeerConnection.prototype.setLocalDescription;e.RTCPeerConnection.prototype.setLocalDescription=function(){return arguments.length&&arguments[0].type?(arguments[0]=a(this,arguments[0]),s.apply(this,arguments)):s.apply(this,arguments)};const c=Object.getOwnPropertyDescriptor(e.RTCPeerConnection.prototype,"localDescription");Object.defineProperty(e.RTCPeerConnection.prototype,"localDescription",{get(){const e=c.get.apply(this);return""===e.type?e:o(this,e)}}),e.RTCPeerConnection.prototype.removeTrack=function(e){if("closed"===this.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");if(!e._pc)throw new DOMException("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.","TypeError");if(!(e._pc===this))throw new DOMException("Sender was not created by this connection.","InvalidAccessError");let t;this._streams=this._streams||{},Object.keys(this._streams).forEach(r=>{this._streams[r].getTracks().find(t=>e.track===t)&&(t=this._streams[r])}),t&&(1===t.getTracks().length?this.removeStream(this._reverseStreams[t.id]):t.removeTrack(e.track),this.dispatchEvent(new Event("negotiationneeded")))}}function I(e){const t=v(e);if(!e.RTCPeerConnection&&e.webkitRTCPeerConnection&&(e.RTCPeerConnection=e.webkitRTCPeerConnection),!e.RTCPeerConnection)return;const r=0===e.RTCPeerConnection.prototype.addIceCandidate.length;t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach((function(t){const r=e.RTCPeerConnection.prototype[t],n={[t](){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),r.apply(this,arguments)}};e.RTCPeerConnection.prototype[t]=n[t]}));const n=e.RTCPeerConnection.prototype.addIceCandidate;e.RTCPeerConnection.prototype.addIceCandidate=function(){return r||arguments[0]?t.version<78&&arguments[0]&&""===arguments[0].candidate?Promise.resolve():n.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())}}function A(e){const t=v(e);f(e,"negotiationneeded",e=>{const r=e.target;if(!(t.version<72||r.getConfiguration&&"plan-b"===r.getConfiguration().sdpSemantics)||"stable"===r.signalingState)return e})}var k=r(42),N=r.n(k);function U(e){const t=e&&e.navigator,r=t.mediaDevices.getUserMedia.bind(t.mediaDevices);t.mediaDevices.getUserMedia=function(e){return r(e).catch(e=>Promise.reject(function(e){return{name:{PermissionDeniedError:"NotAllowedError"}[e.name]||e.name,message:e.message,constraint:e.constraint,toString(){return this.name}}}(e)))}}function L(e){"getDisplayMedia"in e.navigator&&e.navigator.mediaDevices&&(e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||(e.navigator.mediaDevices.getDisplayMedia=e.navigator.getDisplayMedia.bind(e.navigator)))}function x(e){const t=v(e);if(e.RTCIceGatherer&&(e.RTCIceCandidate||(e.RTCIceCandidate=function(e){return e}),e.RTCSessionDescription||(e.RTCSessionDescription=function(e){return e}),t.version<15025)){const t=Object.getOwnPropertyDescriptor(e.MediaStreamTrack.prototype,"enabled");Object.defineProperty(e.MediaStreamTrack.prototype,"enabled",{set(e){t.set.call(this,e);const r=new Event("enabled");r.enabled=e,this.dispatchEvent(r)}})}!e.RTCRtpSender||"dtmf"in e.RTCRtpSender.prototype||Object.defineProperty(e.RTCRtpSender.prototype,"dtmf",{get(){return void 0===this._dtmf&&("audio"===this.track.kind?this._dtmf=new e.RTCDtmfSender(this):"video"===this.track.kind&&(this._dtmf=null)),this._dtmf}}),e.RTCDtmfSender&&!e.RTCDTMFSender&&(e.RTCDTMFSender=e.RTCDtmfSender);const r=N()(e,t.version);e.RTCPeerConnection=function(e){return e&&e.iceServers&&(e.iceServers=function(e,t){let r=!1;return(e=JSON.parse(JSON.stringify(e))).filter(e=>{if(e&&(e.urls||e.url)){let t=e.urls||e.url;e.url&&!e.urls&&h("RTCIceServer.url","RTCIceServer.urls");const n="string"==typeof t;return n&&(t=[t]),t=t.filter(e=>{if(0===e.indexOf("stun:"))return!1;const t=e.startsWith("turn")&&!e.startsWith("turn:[")&&e.includes("transport=udp");return t&&!r?(r=!0,!0):t&&!r}),delete e.url,e.urls=n?t[0]:t,!!t.length}})}(e.iceServers,t.version),m("ICE servers after filtering:",e.iceServers)),new r(e)},e.RTCPeerConnection.prototype=r.prototype}function j(e){!e.RTCRtpSender||"replaceTrack"in e.RTCRtpSender.prototype||(e.RTCRtpSender.prototype.replaceTrack=e.RTCRtpSender.prototype.setTrack)}function D(e){const t=v(e),r=e&&e.navigator,n=e&&e.MediaStreamTrack;if(r.getUserMedia=function(e,t,n){h("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),r.mediaDevices.getUserMedia(e).then(t,n)},!(t.version>55&&"autoGainControl"in r.mediaDevices.getSupportedConstraints())){const e=function(e,t,r){t in e&&!(r in e)&&(e[r]=e[t],delete e[t])},t=r.mediaDevices.getUserMedia.bind(r.mediaDevices);if(r.mediaDevices.getUserMedia=function(r){return"object"==typeof r&&"object"==typeof r.audio&&(r=JSON.parse(JSON.stringify(r)),e(r.audio,"autoGainControl","mozAutoGainControl"),e(r.audio,"noiseSuppression","mozNoiseSuppression")),t(r)},n&&n.prototype.getSettings){const t=n.prototype.getSettings;n.prototype.getSettings=function(){const r=t.apply(this,arguments);return e(r,"mozAutoGainControl","autoGainControl"),e(r,"mozNoiseSuppression","noiseSuppression"),r}}if(n&&n.prototype.applyConstraints){const t=n.prototype.applyConstraints;n.prototype.applyConstraints=function(r){return"audio"===this.kind&&"object"==typeof r&&(r=JSON.parse(JSON.stringify(r)),e(r,"autoGainControl","mozAutoGainControl"),e(r,"noiseSuppression","mozNoiseSuppression")),t.apply(this,[r])}}}}function V(e,t){e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||e.navigator.mediaDevices&&(e.navigator.mediaDevices.getDisplayMedia=function(r){if(!r||!r.video){const e=new DOMException("getDisplayMedia without video constraints is undefined");return e.name="NotFoundError",e.code=8,Promise.reject(e)}return!0===r.video?r.video={mediaSource:t}:r.video.mediaSource=t,e.navigator.mediaDevices.getUserMedia(r)})}function B(e){"object"==typeof e&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&Object.defineProperty(e.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function F(e){const t=v(e);if("object"!=typeof e||!e.RTCPeerConnection&&!e.mozRTCPeerConnection)return;if(!e.RTCPeerConnection&&e.mozRTCPeerConnection&&(e.RTCPeerConnection=e.mozRTCPeerConnection),t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach((function(t){const r=e.RTCPeerConnection.prototype[t],n={[t](){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),r.apply(this,arguments)}};e.RTCPeerConnection.prototype[t]=n[t]})),t.version<68){const t=e.RTCPeerConnection.prototype.addIceCandidate;e.RTCPeerConnection.prototype.addIceCandidate=function(){return arguments[0]?arguments[0]&&""===arguments[0].candidate?Promise.resolve():t.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())}}const r={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"},n=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){const[e,i,o]=arguments;return n.apply(this,[e||null]).then(e=>{if(t.version<53&&!i)try{e.forEach(e=>{e.type=r[e.type]||e.type})}catch(t){if("TypeError"!==t.name)throw t;e.forEach((t,n)=>{e.set(n,Object.assign({},t,{type:r[t.type]||t.type}))})}return e}).then(i,o)}}function H(e){if("object"!=typeof e||!e.RTCPeerConnection||!e.RTCRtpSender)return;if(e.RTCRtpSender&&"getStats"in e.RTCRtpSender.prototype)return;const t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){const e=t.apply(this,[]);return e.forEach(e=>e._pc=this),e});const r=e.RTCPeerConnection.prototype.addTrack;r&&(e.RTCPeerConnection.prototype.addTrack=function(){const e=r.apply(this,arguments);return e._pc=this,e}),e.RTCRtpSender.prototype.getStats=function(){return this.track?this._pc.getStats(this.track):Promise.resolve(new Map)}}function Y(e){if("object"!=typeof e||!e.RTCPeerConnection||!e.RTCRtpSender)return;if(e.RTCRtpSender&&"getStats"in e.RTCRtpReceiver.prototype)return;const t=e.RTCPeerConnection.prototype.getReceivers;t&&(e.RTCPeerConnection.prototype.getReceivers=function(){const e=t.apply(this,[]);return e.forEach(e=>e._pc=this),e}),f(e,"track",e=>(e.receiver._pc=e.srcElement,e)),e.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}function G(e){!e.RTCPeerConnection||"removeStream"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.removeStream=function(e){h("removeStream","removeTrack"),this.getSenders().forEach(t=>{t.track&&e.getTracks().includes(t.track)&&this.removeTrack(t)})})}function W(e){e.DataChannel&&!e.RTCDataChannel&&(e.RTCDataChannel=e.DataChannel)}function X(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype.addTransceiver;t&&(e.RTCPeerConnection.prototype.addTransceiver=function(){this.setParametersPromises=[];const e=arguments[1],r=e&&"sendEncodings"in e;r&&e.sendEncodings.forEach(e=>{if("rid"in e){if(!/^[a-z0-9]{0,16}$/i.test(e.rid))throw new TypeError("Invalid RID value provided.")}if("scaleResolutionDownBy"in e&&!(parseFloat(e.scaleResolutionDownBy)>=1))throw new RangeError("scale_resolution_down_by must be >= 1.0");if("maxFramerate"in e&&!(parseFloat(e.maxFramerate)>=0))throw new RangeError("max_framerate must be >= 0.0")});const n=t.apply(this,arguments);if(r){const{sender:t}=n,r=t.getParameters();"encodings"in r&&(1!==r.encodings.length||0!==Object.keys(r.encodings[0]).length)||(r.encodings=e.sendEncodings,t.sendEncodings=e.sendEncodings,this.setParametersPromises.push(t.setParameters(r).then(()=>{delete t.sendEncodings}).catch(()=>{delete t.sendEncodings})))}return n})}function J(e){if("object"!=typeof e||!e.RTCRtpSender)return;const t=e.RTCRtpSender.prototype.getParameters;t&&(e.RTCRtpSender.prototype.getParameters=function(){const e=t.apply(this,arguments);return"encodings"in e||(e.encodings=[].concat(this.sendEncodings||[{}])),e})}function K(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(()=>t.apply(this,arguments)).finally(()=>{this.setParametersPromises=[]}):t.apply(this,arguments)}}function q(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype.createAnswer;e.RTCPeerConnection.prototype.createAnswer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(()=>t.apply(this,arguments)).finally(()=>{this.setParametersPromises=[]}):t.apply(this,arguments)}}function z(e){if("object"==typeof e&&e.RTCPeerConnection){if("getLocalStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getLocalStreams=function(){return this._localStreams||(this._localStreams=[]),this._localStreams}),!("addStream"in e.RTCPeerConnection.prototype)){const t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addStream=function(e){this._localStreams||(this._localStreams=[]),this._localStreams.includes(e)||this._localStreams.push(e),e.getAudioTracks().forEach(r=>t.call(this,r,e)),e.getVideoTracks().forEach(r=>t.call(this,r,e))},e.RTCPeerConnection.prototype.addTrack=function(e,...r){return r&&r.forEach(e=>{this._localStreams?this._localStreams.includes(e)||this._localStreams.push(e):this._localStreams=[e]}),t.apply(this,arguments)}}"removeStream"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.removeStream=function(e){this._localStreams||(this._localStreams=[]);const t=this._localStreams.indexOf(e);if(-1===t)return;this._localStreams.splice(t,1);const r=e.getTracks();this.getSenders().forEach(e=>{r.includes(e.track)&&this.removeTrack(e)})})}}function Q(e){if("object"==typeof e&&e.RTCPeerConnection&&("getRemoteStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getRemoteStreams=function(){return this._remoteStreams?this._remoteStreams:[]}),!("onaddstream"in e.RTCPeerConnection.prototype))){Object.defineProperty(e.RTCPeerConnection.prototype,"onaddstream",{get(){return this._onaddstream},set(e){this._onaddstream&&(this.removeEventListener("addstream",this._onaddstream),this.removeEventListener("track",this._onaddstreampoly)),this.addEventListener("addstream",this._onaddstream=e),this.addEventListener("track",this._onaddstreampoly=e=>{e.streams.forEach(e=>{if(this._remoteStreams||(this._remoteStreams=[]),this._remoteStreams.includes(e))return;this._remoteStreams.push(e);const t=new Event("addstream");t.stream=e,this.dispatchEvent(t)})})}});const t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){const e=this;return this._onaddstreampoly||this.addEventListener("track",this._onaddstreampoly=function(t){t.streams.forEach(t=>{if(e._remoteStreams||(e._remoteStreams=[]),e._remoteStreams.indexOf(t)>=0)return;e._remoteStreams.push(t);const r=new Event("addstream");r.stream=t,e.dispatchEvent(r)})}),t.apply(e,arguments)}}}function $(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype,r=t.createOffer,n=t.createAnswer,i=t.setLocalDescription,o=t.setRemoteDescription,a=t.addIceCandidate;t.createOffer=function(e,t){const n=arguments.length>=2?arguments[2]:arguments[0],i=r.apply(this,[n]);return t?(i.then(e,t),Promise.resolve()):i},t.createAnswer=function(e,t){const r=arguments.length>=2?arguments[2]:arguments[0],i=n.apply(this,[r]);return t?(i.then(e,t),Promise.resolve()):i};let s=function(e,t,r){const n=i.apply(this,[e]);return r?(n.then(t,r),Promise.resolve()):n};t.setLocalDescription=s,s=function(e,t,r){const n=o.apply(this,[e]);return r?(n.then(t,r),Promise.resolve()):n},t.setRemoteDescription=s,s=function(e,t,r){const n=a.apply(this,[e]);return r?(n.then(t,r),Promise.resolve()):n},t.addIceCandidate=s}function Z(e){const t=e&&e.navigator;if(t.mediaDevices&&t.mediaDevices.getUserMedia){const e=t.mediaDevices,r=e.getUserMedia.bind(e);t.mediaDevices.getUserMedia=e=>r(ee(e))}!t.getUserMedia&&t.mediaDevices&&t.mediaDevices.getUserMedia&&(t.getUserMedia=function(e,r,n){t.mediaDevices.getUserMedia(e).then(r,n)}.bind(t))}function ee(e){return e&&void 0!==e.video?Object.assign({},e,{video:y(e.video)}):e}function te(e){if(!e.RTCPeerConnection)return;const t=e.RTCPeerConnection;e.RTCPeerConnection=function(e,r){if(e&&e.iceServers){const t=[];for(let r=0;rt.generateCertificate})}function re(e){"object"==typeof e&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&Object.defineProperty(e.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function ne(e){const t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(e){if(e){void 0!==e.offerToReceiveAudio&&(e.offerToReceiveAudio=!!e.offerToReceiveAudio);const t=this.getTransceivers().find(e=>"audio"===e.receiver.track.kind);!1===e.offerToReceiveAudio&&t?"sendrecv"===t.direction?t.setDirection?t.setDirection("sendonly"):t.direction="sendonly":"recvonly"===t.direction&&(t.setDirection?t.setDirection("inactive"):t.direction="inactive"):!0!==e.offerToReceiveAudio||t||this.addTransceiver("audio"),void 0!==e.offerToReceiveVideo&&(e.offerToReceiveVideo=!!e.offerToReceiveVideo);const r=this.getTransceivers().find(e=>"video"===e.receiver.track.kind);!1===e.offerToReceiveVideo&&r?"sendrecv"===r.direction?r.setDirection?r.setDirection("sendonly"):r.direction="sendonly":"recvonly"===r.direction&&(r.setDirection?r.setDirection("inactive"):r.direction="inactive"):!0!==e.offerToReceiveVideo||r||this.addTransceiver("video")}return t.apply(this,arguments)}}function ie(e){"object"!=typeof e||e.AudioContext||(e.AudioContext=e.webkitAudioContext)}var oe=r(7),ae=r.n(oe);function se(e){if(!e.RTCIceCandidate||e.RTCIceCandidate&&"foundation"in e.RTCIceCandidate.prototype)return;const t=e.RTCIceCandidate;e.RTCIceCandidate=function(e){if("object"==typeof e&&e.candidate&&0===e.candidate.indexOf("a=")&&((e=JSON.parse(JSON.stringify(e))).candidate=e.candidate.substr(2)),e.candidate&&e.candidate.length){const r=new t(e),n=ae.a.parseCandidate(e.candidate),i=Object.assign(r,n);return i.toJSON=function(){return{candidate:i.candidate,sdpMid:i.sdpMid,sdpMLineIndex:i.sdpMLineIndex,usernameFragment:i.usernameFragment}},i}return new t(e)},e.RTCIceCandidate.prototype=t.prototype,f(e,"icecandidate",t=>(t.candidate&&Object.defineProperty(t,"candidate",{value:new e.RTCIceCandidate(t.candidate),writable:"false"}),t))}function ce(e){if(!e.RTCPeerConnection)return;const t=v(e);"sctp"in e.RTCPeerConnection.prototype||Object.defineProperty(e.RTCPeerConnection.prototype,"sctp",{get(){return void 0===this._sctp?null:this._sctp}});const r=function(e){if(!e||!e.sdp)return!1;const t=ae.a.splitSections(e.sdp);return t.shift(),t.some(e=>{const t=ae.a.parseMLine(e);return t&&"application"===t.kind&&-1!==t.protocol.indexOf("SCTP")})},n=function(e){const t=e.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);if(null===t||t.length<2)return-1;const r=parseInt(t[1],10);return r!=r?-1:r},i=function(e){let r=65536;return"firefox"===t.browser&&(r=t.version<57?-1===e?16384:2147483637:t.version<60?57===t.version?65535:65536:2147483637),r},o=function(e,r){let n=65536;"firefox"===t.browser&&57===t.version&&(n=65535);const i=ae.a.matchPrefix(e.sdp,"a=max-message-size:");return i.length>0?n=parseInt(i[0].substr(19),10):"firefox"===t.browser&&-1!==r&&(n=2147483637),n},a=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){if(this._sctp=null,"chrome"===t.browser&&t.version>=76){const{sdpSemantics:e}=this.getConfiguration();"plan-b"===e&&Object.defineProperty(this,"sctp",{get(){return void 0===this._sctp?null:this._sctp},enumerable:!0,configurable:!0})}if(r(arguments[0])){const e=n(arguments[0]),t=i(e),r=o(arguments[0],e);let a;a=0===t&&0===r?Number.POSITIVE_INFINITY:0===t||0===r?Math.max(t,r):Math.min(t,r);const s={};Object.defineProperty(s,"maxMessageSize",{get:()=>a}),this._sctp=s}return a.apply(this,arguments)}}function ue(e){if(!(e.RTCPeerConnection&&"createDataChannel"in e.RTCPeerConnection.prototype))return;function t(e,t){const r=e.send;e.send=function(){const n=arguments[0],i=n.length||n.size||n.byteLength;if("open"===e.readyState&&t.sctp&&i>t.sctp.maxMessageSize)throw new TypeError("Message too large (can send a maximum of "+t.sctp.maxMessageSize+" bytes)");return r.apply(e,arguments)}}const r=e.RTCPeerConnection.prototype.createDataChannel;e.RTCPeerConnection.prototype.createDataChannel=function(){const e=r.apply(this,arguments);return t(e,this),e},f(e,"datachannel",e=>(t(e.channel,e.target),e))}function de(e){if(!e.RTCPeerConnection||"connectionState"in e.RTCPeerConnection.prototype)return;const t=e.RTCPeerConnection.prototype;Object.defineProperty(t,"connectionState",{get(){return{completed:"connected",checking:"connecting"}[this.iceConnectionState]||this.iceConnectionState},enumerable:!0,configurable:!0}),Object.defineProperty(t,"onconnectionstatechange",{get(){return this._onconnectionstatechange||null},set(e){this._onconnectionstatechange&&(this.removeEventListener("connectionstatechange",this._onconnectionstatechange),delete this._onconnectionstatechange),e&&this.addEventListener("connectionstatechange",this._onconnectionstatechange=e)},enumerable:!0,configurable:!0}),["setLocalDescription","setRemoteDescription"].forEach(e=>{const r=t[e];t[e]=function(){return this._connectionstatechangepoly||(this._connectionstatechangepoly=e=>{const t=e.target;if(t._lastConnectionState!==t.connectionState){t._lastConnectionState=t.connectionState;const r=new Event("connectionstatechange",e);t.dispatchEvent(r)}return e},this.addEventListener("iceconnectionstatechange",this._connectionstatechangepoly)),r.apply(this,arguments)}})}function fe(e){if(!e.RTCPeerConnection)return;const t=v(e);if("chrome"===t.browser&&t.version>=71)return;if("safari"===t.browser&&t.version>=605)return;const r=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(e){return e&&e.sdp&&-1!==e.sdp.indexOf("\na=extmap-allow-mixed")&&(e.sdp=e.sdp.split("\n").filter(e=>"a=extmap-allow-mixed"!==e.trim()).join("\n")),r.apply(this,arguments)}}const pe=function({window:e}={},t={shimChrome:!0,shimFirefox:!0,shimEdge:!0,shimSafari:!0}){const r=m,c=v(e),u={browserDetails:c,commonShim:s,extractVersion:d,disableLog:p,disableWarnings:l};switch(c.browser){case"chrome":if(!n||!I||!t.shimChrome)return r("Chrome shim is not included in this adapter release."),u;if(null===c.version)return r("Chrome shim can not determine version, not shimming."),u;r("adapter.js shimming chrome."),u.browserShim=n,_(e),T(e),I(e),w(e),O(e),R(e),M(e),C(e),A(e),se(e),de(e),ce(e),ue(e),fe(e);break;case"firefox":if(!o||!F||!t.shimFirefox)return r("Firefox shim is not included in this adapter release."),u;r("adapter.js shimming firefox."),u.browserShim=o,D(e),F(e),B(e),G(e),H(e),Y(e),W(e),X(e),J(e),K(e),q(e),se(e),de(e),ce(e),ue(e);break;case"edge":if(!i||!x||!t.shimEdge)return r("MS edge shim is not included in this adapter release."),u;r("adapter.js shimming edge."),u.browserShim=i,U(e),L(e),x(e),j(e),ce(e),ue(e);break;case"safari":if(!a||!t.shimSafari)return r("Safari shim is not included in this adapter release."),u;r("adapter.js shimming safari."),u.browserShim=a,te(e),ne(e),$(e),z(e),Q(e),re(e),Z(e),ie(e),se(e),ce(e),ue(e),fe(e);break;default:r("Unsupported browser!")}return u}({window:"undefined"==typeof window?void 0:window});t.default=pe},function(e,t,r){"use strict";var n;r.r(t);var i=new Uint8Array(16);function o(){if(!n&&!(n="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return n(i)}var a=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;for(var s=function(e){return"string"==typeof e&&a.test(e)},c=[],u=0;u<256;++u)c.push((u+256).toString(16).substr(1));var d,f,p=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=(c[e[t+0]]+c[e[t+1]]+c[e[t+2]]+c[e[t+3]]+"-"+c[e[t+4]]+c[e[t+5]]+"-"+c[e[t+6]]+c[e[t+7]]+"-"+c[e[t+8]]+c[e[t+9]]+"-"+c[e[t+10]]+c[e[t+11]]+c[e[t+12]]+c[e[t+13]]+c[e[t+14]]+c[e[t+15]]).toLowerCase();if(!s(r))throw TypeError("Stringified UUID is invalid");return r},l=0,m=0;var h=function(e,t,r){var n=t&&r||0,i=t||new Array(16),a=(e=e||{}).node||d,s=void 0!==e.clockseq?e.clockseq:f;if(null==a||null==s){var c=e.random||(e.rng||o)();null==a&&(a=d=[1|c[0],c[1],c[2],c[3],c[4],c[5]]),null==s&&(s=f=16383&(c[6]<<8|c[7]))}var u=void 0!==e.msecs?e.msecs:Date.now(),h=void 0!==e.nsecs?e.nsecs:m+1,v=u-l+(h-m)/1e4;if(v<0&&void 0===e.clockseq&&(s=s+1&16383),(v<0||u>l)&&void 0===e.nsecs&&(h=0),h>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");l=u,m=h,f=s;var g=(1e4*(268435455&(u+=122192928e5))+h)%4294967296;i[n++]=g>>>24&255,i[n++]=g>>>16&255,i[n++]=g>>>8&255,i[n++]=255&g;var y=u/4294967296*1e4&268435455;i[n++]=y>>>8&255,i[n++]=255&y,i[n++]=y>>>24&15|16,i[n++]=y>>>16&255,i[n++]=s>>>8|128,i[n++]=255&s;for(var E=0;E<6;++E)i[n+E]=a[E];return t||p(i)};var v=function(e){if(!s(e))throw TypeError("Invalid UUID");var t,r=new Uint8Array(16);return r[0]=(t=parseInt(e.slice(0,8),16))>>>24,r[1]=t>>>16&255,r[2]=t>>>8&255,r[3]=255&t,r[4]=(t=parseInt(e.slice(9,13),16))>>>8,r[5]=255&t,r[6]=(t=parseInt(e.slice(14,18),16))>>>8,r[7]=255&t,r[8]=(t=parseInt(e.slice(19,23),16))>>>8,r[9]=255&t,r[10]=(t=parseInt(e.slice(24,36),16))/1099511627776&255,r[11]=t/4294967296&255,r[12]=t>>>24&255,r[13]=t>>>16&255,r[14]=t>>>8&255,r[15]=255&t,r};var g=function(e,t,r){function n(e,n,i,o){if("string"==typeof e&&(e=function(e){e=unescape(encodeURIComponent(e));for(var t=[],r=0;r>>9<<4)+1}function E(e,t){var r=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(r>>16)<<16|65535&r}function b(e,t,r,n,i,o){return E((a=E(E(t,e),E(n,o)))<<(s=i)|a>>>32-s,r);var a,s}function _(e,t,r,n,i,o,a){return b(t&r|~t&n,e,t,i,o,a)}function S(e,t,r,n,i,o,a){return b(t&n|r&~n,e,t,i,o,a)}function T(e,t,r,n,i,o,a){return b(t^r^n,e,t,i,o,a)}function w(e,t,r,n,i,o,a){return b(r^(t|~n),e,t,i,o,a)}var R=g("v3",48,(function(e){if("string"==typeof e){var t=unescape(encodeURIComponent(e));e=new Uint8Array(t.length);for(var r=0;r>5]>>>n%32&255,o=parseInt("0123456789abcdef".charAt(i>>>4&15)+"0123456789abcdef".charAt(15&i),16);t.push(o)}return t}(function(e,t){e[t>>5]|=128<>5]|=(255&e[n/8])<>>32-t}var O=g("v5",80,(function(e){var t=[1518500249,1859775393,2400959708,3395469782],r=[1732584193,4023233417,2562383102,271733878,3285377520];if("string"==typeof e){var n=unescape(encodeURIComponent(e));e=[];for(var i=0;i>>0;E=y,y=g,g=P(v,30)>>>0,v=h,h=S}r[0]=r[0]+h>>>0,r[1]=r[1]+v>>>0,r[2]=r[2]+g>>>0,r[3]=r[3]+y>>>0,r[4]=r[4]+E>>>0}return[r[0]>>24&255,r[0]>>16&255,r[0]>>8&255,255&r[0],r[1]>>24&255,r[1]>>16&255,r[1]>>8&255,255&r[1],r[2]>>24&255,r[2]>>16&255,r[2]>>8&255,255&r[2],r[3]>>24&255,r[3]>>16&255,r[3]>>8&255,255&r[3],r[4]>>24&255,r[4]>>16&255,r[4]>>8&255,255&r[4]]}));var I=function(e){if(!s(e))throw TypeError("Invalid UUID");return parseInt(e.substr(14,1),16)};r.d(t,"v1",(function(){return h})),r.d(t,"v3",(function(){return R})),r.d(t,"v4",(function(){return M})),r.d(t,"v5",(function(){return O})),r.d(t,"NIL",(function(){return"00000000-0000-0000-0000-000000000000"})),r.d(t,"version",(function(){return I})),r.d(t,"validate",(function(){return s})),r.d(t,"stringify",(function(){return p})),r.d(t,"parse",(function(){return v}))}])})); \ No newline at end of file +e.exports=function(e){return null!=e&&null!=e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}},function(e,t,r){"use strict";var n=r(1),i=r(23),o=r(51),a=r(52),s=r(28);function c(e){this.defaults=e,this.interceptors={request:new o,response:new o}}c.prototype.request=function(e){"string"==typeof e?(e=arguments[1]||{}).url=arguments[0]:e=e||{},(e=s(this.defaults,e)).method=e.method?e.method.toLowerCase():"get";var t=[a,void 0],r=Promise.resolve(e);for(this.interceptors.request.forEach((function(e){t.unshift(e.fulfilled,e.rejected)})),this.interceptors.response.forEach((function(e){t.push(e.fulfilled,e.rejected)}));t.length;)r=r.then(t.shift(),t.shift());return r},c.prototype.getUri=function(e){return e=s(this.defaults,e),i(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")},n.forEach(["delete","get","head","options"],(function(e){c.prototype[e]=function(t,r){return this.request(n.merge(r||{},{method:e,url:t}))}})),n.forEach(["post","put","patch"],(function(e){c.prototype[e]=function(t,r,i){return this.request(n.merge(i||{},{method:e,url:t,data:r}))}})),e.exports=c},function(e,t,r){"use strict";var n=r(1);function i(){this.handlers=[]}i.prototype.use=function(e,t){return this.handlers.push({fulfilled:e,rejected:t}),this.handlers.length-1},i.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},i.prototype.forEach=function(e){n.forEach(this.handlers,(function(t){null!==t&&e(t)}))},e.exports=i},function(e,t,r){"use strict";var n=r(1),i=r(53),o=r(24),a=r(25),s=r(60),c=r(61);function u(e){e.cancelToken&&e.cancelToken.throwIfRequested()}e.exports=function(e){return u(e),e.baseURL&&!s(e.url)&&(e.url=c(e.baseURL,e.url)),e.headers=e.headers||{},e.data=i(e.data,e.headers,e.transformRequest),e.headers=n.merge(e.headers.common||{},e.headers[e.method]||{},e.headers||{}),n.forEach(["delete","get","head","post","put","patch","common"],(function(t){delete e.headers[t]})),(e.adapter||a.adapter)(e).then((function(t){return u(e),t.data=i(t.data,t.headers,e.transformResponse),t}),(function(t){return o(t)||(u(e),t&&t.response&&(t.response.data=i(t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)}))}},function(e,t,r){"use strict";var n=r(1);e.exports=function(e,t,r){return n.forEach(r,(function(r){e=r(e,t)})),e}},function(e,t,r){"use strict";var n=r(1);e.exports=function(e,t){n.forEach(e,(function(r,n){n!==t&&n.toUpperCase()===t.toUpperCase()&&(e[t]=r,delete e[n])}))}},function(e,t,r){"use strict";var n=r(27);e.exports=function(e,t,r){var i=r.config.validateStatus;!i||i(r.status)?e(r):t(n("Request failed with status code "+r.status,r.config,null,r.request,r))}},function(e,t,r){"use strict";e.exports=function(e,t,r,n,i){return e.config=t,r&&(e.code=r),e.request=n,e.response=i,e.isAxiosError=!0,e.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code}},e}},function(e,t,r){"use strict";var n=r(1),i=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];e.exports=function(e){var t,r,o,a={};return e?(n.forEach(e.split("\n"),(function(e){if(o=e.indexOf(":"),t=n.trim(e.substr(0,o)).toLowerCase(),r=n.trim(e.substr(o+1)),t){if(a[t]&&i.indexOf(t)>=0)return;a[t]="set-cookie"===t?(a[t]?a[t]:[]).concat([r]):a[t]?a[t]+", "+r:r}})),a):a}},function(e,t,r){"use strict";var n=r(1);e.exports=n.isStandardBrowserEnv()?function(){var e,t=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a");function i(e){var n=e;return t&&(r.setAttribute("href",n),n=r.href),r.setAttribute("href",n),{href:r.href,protocol:r.protocol?r.protocol.replace(/:$/,""):"",host:r.host,search:r.search?r.search.replace(/^\?/,""):"",hash:r.hash?r.hash.replace(/^#/,""):"",hostname:r.hostname,port:r.port,pathname:"/"===r.pathname.charAt(0)?r.pathname:"/"+r.pathname}}return e=i(window.location.href),function(t){var r=n.isString(t)?i(t):t;return r.protocol===e.protocol&&r.host===e.host}}():function(){return!0}},function(e,t,r){"use strict";var n=r(1);e.exports=n.isStandardBrowserEnv()?{write:function(e,t,r,i,o,a){var s=[];s.push(e+"="+encodeURIComponent(t)),n.isNumber(r)&&s.push("expires="+new Date(r).toGMTString()),n.isString(i)&&s.push("path="+i),n.isString(o)&&s.push("domain="+o),!0===a&&s.push("secure"),document.cookie=s.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}}},function(e,t,r){"use strict";e.exports=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)}},function(e,t,r){"use strict";e.exports=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}},function(e,t,r){"use strict";var n=r(29);function i(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise((function(e){t=e}));var r=this;e((function(e){r.reason||(r.reason=new n(e),t(r.reason))}))}i.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},i.source=function(){var e;return{token:new i((function(t){e=t})),cancel:e}},e.exports=i},function(e,t,r){"use strict";e.exports=function(e){return function(t){return e.apply(null,t)}}},function(e,t,r){var n=r(65)("jsonp");e.exports=function(e,t,r){"function"==typeof t&&(r=t,t={});t||(t={});var a,s,c=t.prefix||"__jp",u=t.name||c+i++,d=t.param||"callback",f=null!=t.timeout?t.timeout:6e4,p=encodeURIComponent,l=document.getElementsByTagName("script")[0]||document.head;f&&(s=setTimeout((function(){m(),r&&r(new Error("Timeout"))}),f));function m(){a.parentNode&&a.parentNode.removeChild(a),window[u]=o,s&&clearTimeout(s)}return window[u]=function(e){n("jsonp got",e),m(),r&&r(null,e)},e=(e+=(~e.indexOf("?")?"&":"?")+d+"="+p(u)).replace("?&","?"),n('jsonp req "%s"',e),(a=document.createElement("script")).src=e,l.parentNode.insertBefore(a,l),function(){window[u]&&m()}};var i=0;function o(){}},function(e,t,r){(function(n){function i(){var e;try{e=t.storage.debug}catch(e){}return!e&&void 0!==n&&"env"in n&&(e=n.env.DEBUG),e}(t=e.exports=r(66)).log=function(){return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)},t.formatArgs=function(e){var r=this.useColors;if(e[0]=(r?"%c":"")+this.namespace+(r?" %c":" ")+e[0]+(r?"%c ":" ")+"+"+t.humanize(this.diff),!r)return;var n="color: "+this.color;e.splice(1,0,n,"color: inherit");var i=0,o=0;e[0].replace(/%[a-zA-Z%]/g,(function(e){"%%"!==e&&(i++,"%c"===e&&(o=i))})),e.splice(o,0,n)},t.save=function(e){try{null==e?t.storage.removeItem("debug"):t.storage.debug=e}catch(e){}},t.load=i,t.useColors=function(){if("undefined"!=typeof window&&window.process&&"renderer"===window.process.type)return!0;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage="undefined"!=typeof chrome&&void 0!==chrome.storage?chrome.storage.local:function(){try{return window.localStorage}catch(e){}}(),t.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"],t.formatters.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}},t.enable(i())}).call(this,r(12))},function(e,t,r){var n;function i(e){function r(){if(r.enabled){var e=r,i=+new Date,o=i-(n||i);e.diff=o,e.prev=n,e.curr=i,n=i;for(var a=new Array(arguments.length),s=0;s0)return function(e){if((e=String(e)).length>100)return;var t=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(e);if(!t)return;var s=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return s*a;case"days":case"day":case"d":return s*o;case"hours":case"hour":case"hrs":case"hr":case"h":return s*i;case"minutes":case"minute":case"mins":case"min":case"m":return s*n;case"seconds":case"second":case"secs":case"sec":case"s":return s*r;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return s;default:return}}(e);if("number"===u&&!1===isNaN(e))return t.long?s(c=e,o,"day")||s(c,i,"hour")||s(c,n,"minute")||s(c,r,"second")||c+" ms":function(e){if(e>=o)return Math.round(e/o)+"d";if(e>=i)return Math.round(e/i)+"h";if(e>=n)return Math.round(e/n)+"m";if(e>=r)return Math.round(e/r)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},function(e,t,r){"use strict";e.exports=function(e,t){if(t=t.split(":")[0],!(e=+e))return!1;switch(t){case"http":case"ws":return 80!==e;case"https":case"wss":return 443!==e;case"ftp":return 21!==e;case"gopher":return 70!==e;case"file":return!1}return 0!==e}},function(e,t,r){"use strict";var n,i=Object.prototype.hasOwnProperty;function o(e){try{return decodeURIComponent(e.replace(/\+/g," "))}catch(e){return null}}t.stringify=function(e,t){t=t||"";var r,o,a=[];for(o in"string"!=typeof t&&(t="?"),e)if(i.call(e,o)){if((r=e[o])||null!==r&&r!==n&&!isNaN(r)||(r=""),o=encodeURIComponent(o),r=encodeURIComponent(r),null===o||null===r)continue;a.push(o+"="+r)}return a.length?t+a.join("&"):""},t.parse=function(e){for(var t,r=/([^=?&]+)=?([^&]*)/g,n={};t=r.exec(e);){var i=o(t[1]),a=o(t[2]);null===i||null===a||i in n||(n[i]=a)}return n}},function(e,t,r){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0});var n=r(71),i=r(0),o=r(31),a=r(3),s=function(){function t(e){this.readyState=n.w3cwebsocket.CLOSED,this.connectId=1,this.BEATTIM=6e4,this.pingTimeout=0,this.retry=0,this.signalManager=e}return t.prototype.init=function(e,t,r){var n=this;this.messageCb=e,this.stateChangeCb=t,this.errorCb=r,this.signalManager.on("change-signal",(function(e,t){i.default.debug("change signal "+e.wss+" => "+t.wss),e&&(e.status=o.SignalStatus.unconnected),n.reconnect()}))},t.prototype.initHeartBeat=function(e,t){this.getHeartBeatData=e,t&&(this.BEATTIM=t)},t.prototype.startHeartBeat=function(){var e=this;i.default.debug("socket manager - start head beat"),this.keepAlive&&window.clearInterval(this.keepAlive),this.getHeartBeatData&&(this.keepAlive=window.setInterval((function(){e.heartBeat()}),this.BEATTIM))},t.prototype.heartBeat=function(){var e=this;if(this.getHeartBeatData&&this.readyState===n.w3cwebsocket.OPEN){this.pingTimeout||(this.pingTimeout=window.setTimeout((function(){e.pingTimeout=0,e.stopHeartBeat(),e.onStateChanged(e.readyState,n.w3cwebsocket.CLOSED),e.readyState=n.w3cwebsocket.CLOSED,e.reconnect()}),8e3));var t=this.getHeartBeatData();this.send(t).catch((function(e){i.default.warn("head beat ",e)}))}},t.prototype.stopHeartBeat=function(){i.default.debug("socket manager - stop head beat"),this.keepAlive&&window.clearInterval(this.keepAlive)},t.prototype.destroy=function(){this.stopHeartBeat(),this.messageCb=void 0,this.stateChangeCb=void 0,this.errorCb=void 0,this.retry&&(window.clearTimeout(this.retry),this.retry=0)},t.prototype.connect=function(e){var t=this;return this.connectId+=1,i.default.debug("socket manager - connect ",this.readyState,e),new Promise((function(r,s){if(e||t.signalManager.current){t.readyState=n.w3cwebsocket.CLOSED;var c=t.signalManager.current,u=!0;try{t._websocket=new n.w3cwebsocket(e||c.wss),c.status=o.SignalStatus.connecting}catch(e){return i.default.debug("socket manager - connect error ",e),void s(a.createError(a.ErrorCodes.OTHERS,"Create Socket Error"))}t.onconnecting(t.readyState,n.w3cwebsocket.CONNECTING),t.readyState=n.w3cwebsocket.CONNECTING,t._websocket.onopen=function(){var e=t.readyState;t.readyState=n.w3cwebsocket.OPEN,c.status=o.SignalStatus.connected,t.onopened(e,n.w3cwebsocket.OPEN),u&&(u=!1,r("opened"))},t._websocket.onclose=function(){i.default.debug("socket manager - onclose ",t.readyState);var e=t.readyState;t.readyState=n.w3cwebsocket.CLOSED,c.status=o.SignalStatus.unconnected,t.onclosed(e,n.w3cwebsocket.CLOSED)},t._websocket.onmessage=function(e){t.pingTimeout&&(window.clearTimeout(t.pingTimeout),t.pingTimeout=0),t.onmessage(e)},t._websocket.onerror=function(e){var r;i.default.debug("socket manager - onerror ",e),i.default.debug("socket manager - onerror state ",t.readyState,null===(r=t._websocket)||void 0===r?void 0:r.readyState),u?(u=!1,s(a.createError(a.ErrorCodes.OTHERS,"connection error"))):t.onerror("connection error")}}else s(a.createError(a.ErrorCodes.OTHERS,"signal is blank"))}))},t.prototype.onmessage=function(e){this.messageCb&&this.messageCb(e)},t.prototype.onStateChanged=function(e,t){function r(e){var t="CLOSED";switch(e){case n.w3cwebsocket.OPEN:t="OPEN";break;case n.w3cwebsocket.CONNECTING:t="CONNECTING";break;case n.w3cwebsocket.CLOSING:t="CLOSING";break;case n.w3cwebsocket.CLOSED:t="CLOSED"}return t}var o=r(e),a=r(t);i.default.debug("socket manager - onStateChanged ",o,a),this.stateChangeCb&&this.stateChangeCb(o,a)},t.prototype.onconnecting=function(e,t){i.default.debug("socket manager - onconnecting ",e,t),this.onStateChanged(e,t)},t.prototype.onopened=function(e,t){i.default.debug("socket manager - onopened ",e,t),this.startHeartBeat(),this.onStateChanged(e,t)},t.prototype.ondisconnecting=function(e,t){i.default.debug("socket manager - ondisconnecting ",e,t),this.onStateChanged(e,t)},t.prototype.onclosed=function(t,r){var o=this;i.default.debug("socket manager - onclosed ",t,r),this.stopHeartBeat(),this.onStateChanged(t,r),t===n.w3cwebsocket.OPEN&&e((function(){i.default.warn("connection is closed - reconnecting..."),o.reconnect()}))},t.prototype.onerror=function(e){i.default.debug("socket manager - onerror ",e),this.errorCb&&this.errorCb(e)},t.prototype.send=function(e){var t=this;return new Promise((function(r,n){var i;t.isOpened?(null===(i=t._websocket)||void 0===i||i.send(e),r()):n(a.createError(a.ErrorCodes.OTHERS,"connection isnot open"))}))},t.prototype.close=function(e,t){var r=this;return void 0===e&&(e=1e3),i.default.debug("socket manager - close ",this.readyState),this.ondisconnecting(this.readyState,n.w3cwebsocket.CLOSING),this.readyState=n.w3cwebsocket.CLOSING,new Promise((function(n,i){r._websocket?(r._websocket.close(e,t),n()):i(a.createError(a.ErrorCodes.OTHERS,"no socket connection"))}))},Object.defineProperty(t.prototype,"isOpened",{get:function(){return this.readyState===n.w3cwebsocket.OPEN},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isClosed",{get:function(){return this.readyState===n.w3cwebsocket.CLOSED},enumerable:!0,configurable:!0}),t.prototype.reconnect=function(){var e=this;if(i.default.debug("socket manager - reconnect ",this.readyState),this._websocket){var t=this._websocket,r=function(){};this._websocket.onopen=r,this._websocket.onclose=r,this._websocket.onmessage=r,this._websocket.onerror=r,this._websocket=void 0,this.pingTimeout&&(window.clearTimeout(this.pingTimeout),this.pingTimeout=0),i.default.debug("socket manager - before reconnect ",this.readyState);var a=this.readyState;this.signalManager.current.status=o.SignalStatus.unconnected,a!==n.w3cwebsocket.CLOSED&&(this.readyState=n.w3cwebsocket.CLOSED,this.onclosed(a,n.w3cwebsocket.CLOSED));try{t.close(1e3,"reconnect")}catch(e){i.default.warn("reconenct - close websocket "+e)}}this.retry&&(window.clearTimeout(this.retry),this.retry=0),this.retry=window.setTimeout((function(){return e.reconnect()}),1e4),e.connect().then((function(){e.retry&&(window.clearTimeout(e.retry),e.retry=0)})).catch((function(e){i.default.warn("reconnect unsuccessfully with error: ",e),i.default.warn("reconnection will restart later...")}))},t}();t.SocketManager=s}).call(this,r(19).setImmediate)},function(e,t,r){(function(t){var n=function(){return this||void 0===t?this:t}(),i=n.WebSocket||n.MozWebSocket,o=r(72);function a(e,t){return t?new i(e,t):new i(e)}i&&["CONNECTING","OPEN","CLOSING","CLOSED"].forEach((function(e){Object.defineProperty(a,e,{get:function(){return i[e]}})})),e.exports={w3cwebsocket:i?a:null,version:o}}).call(this,r(8))},function(e,t,r){e.exports=r(73).version},function(e){e.exports=JSON.parse('{"name":"websocket","description":"Websocket Client & Server Library implementing the WebSocket protocol as specified in RFC 6455.","keywords":["websocket","websockets","socket","networking","comet","push","RFC-6455","realtime","server","client"],"author":"Brian McKelvey (https://github.com/theturtle32)","contributors":["Iñaki Baz Castillo (http://dev.sipdoc.net)"],"version":"1.0.30","repository":{"type":"git","url":"https://github.com/theturtle32/WebSocket-Node.git"},"homepage":"https://github.com/theturtle32/WebSocket-Node","engines":{"node":">=0.10.0"},"dependencies":{"debug":"^2.2.0","nan":"^2.14.0","typedarray-to-buffer":"^3.1.5","yaeti":"^0.0.6"},"devDependencies":{"buffer-equal":"^1.0.0","faucet":"^0.0.1","gulp":"^4.0.2","gulp-jshint":"^2.0.4","jshint-stylish":"^2.2.1","jshint":"^2.0.0","tape":"^4.9.1"},"config":{"verbose":false},"scripts":{"install":"(node-gyp rebuild 2> builderror.log) || (exit 0)","test":"faucet test/unit","gulp":"gulp"},"main":"index","directories":{"lib":"./lib"},"browser":"lib/browser.js","license":"Apache-2.0"}')},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ErrorCodes={NOT_JOIN:"NotJoinRoomError",JOINING:"JoiningRoomError",LEAVING:"LeavingRoomError",DUPLICATED_JOIN:"DuplicatedJoinRoomError",ROLE_TYPE_NOT_MATCH:"RoleTypeNotMatchError",INVALID_MEDIASTREAM:"InvalidMediaStreamError",STREAM_EXISTS:"StreamExistsError",CREATE_STREAM:"CreateStreamError",STREAM_NOT_EXISTS:"StreamNotExistsError",AUDIO_TRACK_NOT_EXISTS:"AudioTrackNotExistsError",VIDEO_TRACK_NOT_EXISTS:"VideoTrackNotExistsError",SERVER_API:"ServerError",INVALID_PARAMETER:"InvalidParameterError",NOT_SUPPORT:"NotSupportError",BAD_REQUEST:"BadRequestError",SOCKET_DISCONNECTED:"SocketDisconnectedError",OTHERS:"OtherError"},t.InnerErrorCodes={REPUBLISHING:"Republishing",RESUBSCRIBING:"Resubscribing"}},function(e,t,r){e.exports=function(e){var t={};function r(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)r.d(n,i,function(t){return e[t]}.bind(null,i));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=90)}({17:function(e,t,r){"use strict";t.__esModule=!0,t.default=void 0;var n=r(18),i=function(){function e(){}return e.getFirstMatch=function(e,t){var r=t.match(e);return r&&r.length>0&&r[1]||""},e.getSecondMatch=function(e,t){var r=t.match(e);return r&&r.length>1&&r[2]||""},e.matchAndReturnConst=function(e,t,r){if(e.test(t))return r},e.getWindowsVersionName=function(e){switch(e){case"NT":return"NT";case"XP":return"XP";case"NT 5.0":return"2000";case"NT 5.1":return"XP";case"NT 5.2":return"2003";case"NT 6.0":return"Vista";case"NT 6.1":return"7";case"NT 6.2":return"8";case"NT 6.3":return"8.1";case"NT 10.0":return"10";default:return}},e.getMacOSVersionName=function(e){var t=e.split(".").splice(0,2).map((function(e){return parseInt(e,10)||0}));if(t.push(0),10===t[0])switch(t[1]){case 5:return"Leopard";case 6:return"Snow Leopard";case 7:return"Lion";case 8:return"Mountain Lion";case 9:return"Mavericks";case 10:return"Yosemite";case 11:return"El Capitan";case 12:return"Sierra";case 13:return"High Sierra";case 14:return"Mojave";case 15:return"Catalina";default:return}},e.getAndroidVersionName=function(e){var t=e.split(".").splice(0,2).map((function(e){return parseInt(e,10)||0}));if(t.push(0),!(1===t[0]&&t[1]<5))return 1===t[0]&&t[1]<6?"Cupcake":1===t[0]&&t[1]>=6?"Donut":2===t[0]&&t[1]<2?"Eclair":2===t[0]&&2===t[1]?"Froyo":2===t[0]&&t[1]>2?"Gingerbread":3===t[0]?"Honeycomb":4===t[0]&&t[1]<1?"Ice Cream Sandwich":4===t[0]&&t[1]<4?"Jelly Bean":4===t[0]&&t[1]>=4?"KitKat":5===t[0]?"Lollipop":6===t[0]?"Marshmallow":7===t[0]?"Nougat":8===t[0]?"Oreo":9===t[0]?"Pie":void 0},e.getVersionPrecision=function(e){return e.split(".").length},e.compareVersions=function(t,r,n){void 0===n&&(n=!1);var i=e.getVersionPrecision(t),o=e.getVersionPrecision(r),a=Math.max(i,o),s=0,c=e.map([t,r],(function(t){var r=a-e.getVersionPrecision(t),n=t+new Array(r+1).join(".0");return e.map(n.split("."),(function(e){return new Array(20-e.length).join("0")+e})).reverse()}));for(n&&(s=a-Math.min(i,o)),a-=1;a>=s;){if(c[0][a]>c[1][a])return 1;if(c[0][a]===c[1][a]){if(a===s)return 0;a-=1}else if(c[0][a]1?i-1:0),a=1;a0){var a=Object.keys(r),c=s.default.find(a,(function(e){return t.isOS(e)}));if(c){var u=this.satisfies(r[c]);if(void 0!==u)return u}var d=s.default.find(a,(function(e){return t.isPlatform(e)}));if(d){var f=this.satisfies(r[d]);if(void 0!==f)return f}}if(o>0){var p=Object.keys(i),l=s.default.find(p,(function(e){return t.isBrowser(e,!0)}));if(void 0!==l)return this.compareVersion(i[l])}},t.isBrowser=function(e,t){void 0===t&&(t=!1);var r=this.getBrowserName().toLowerCase(),n=e.toLowerCase(),i=s.default.getBrowserTypeByAlias(n);return t&&i&&(n=i.toLowerCase()),n===r},t.compareVersion=function(e){var t=[0],r=e,n=!1,i=this.getBrowserVersion();if("string"==typeof i)return">"===e[0]||"<"===e[0]?(r=e.substr(1),"="===e[1]?(n=!0,r=e.substr(2)):t=[],">"===e[0]?t.push(1):t.push(-1)):"="===e[0]?r=e.substr(1):"~"===e[0]&&(n=!0,r=e.substr(1)),t.indexOf(s.default.compareVersions(i,r,n))>-1},t.isOS=function(e){return this.getOSName(!0)===String(e).toLowerCase()},t.isPlatform=function(e){return this.getPlatformType(!0)===String(e).toLowerCase()},t.isEngine=function(e){return this.getEngineName(!0)===String(e).toLowerCase()},t.is=function(e,t){return void 0===t&&(t=!1),this.isBrowser(e,t)||this.isOS(e)||this.isPlatform(e)},t.some=function(e){var t=this;return void 0===e&&(e=[]),e.some((function(e){return t.is(e)}))},e}();t.default=u,e.exports=t.default},92:function(e,t,r){"use strict";t.__esModule=!0,t.default=void 0;var n,i=(n=r(17))&&n.__esModule?n:{default:n},o=/version\/(\d+(\.?_?\d+)+)/i,a=[{test:[/googlebot/i],describe:function(e){var t={name:"Googlebot"},r=i.default.getFirstMatch(/googlebot\/(\d+(\.\d+))/i,e)||i.default.getFirstMatch(o,e);return r&&(t.version=r),t}},{test:[/opera/i],describe:function(e){var t={name:"Opera"},r=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/(?:opera)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/opr\/|opios/i],describe:function(e){var t={name:"Opera"},r=i.default.getFirstMatch(/(?:opr|opios)[\s/](\S+)/i,e)||i.default.getFirstMatch(o,e);return r&&(t.version=r),t}},{test:[/SamsungBrowser/i],describe:function(e){var t={name:"Samsung Internet for Android"},r=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/(?:SamsungBrowser)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/Whale/i],describe:function(e){var t={name:"NAVER Whale Browser"},r=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/(?:whale)[\s/](\d+(?:\.\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/MZBrowser/i],describe:function(e){var t={name:"MZ Browser"},r=i.default.getFirstMatch(/(?:MZBrowser)[\s/](\d+(?:\.\d+)+)/i,e)||i.default.getFirstMatch(o,e);return r&&(t.version=r),t}},{test:[/focus/i],describe:function(e){var t={name:"Focus"},r=i.default.getFirstMatch(/(?:focus)[\s/](\d+(?:\.\d+)+)/i,e)||i.default.getFirstMatch(o,e);return r&&(t.version=r),t}},{test:[/swing/i],describe:function(e){var t={name:"Swing"},r=i.default.getFirstMatch(/(?:swing)[\s/](\d+(?:\.\d+)+)/i,e)||i.default.getFirstMatch(o,e);return r&&(t.version=r),t}},{test:[/coast/i],describe:function(e){var t={name:"Opera Coast"},r=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/(?:coast)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/opt\/\d+(?:.?_?\d+)+/i],describe:function(e){var t={name:"Opera Touch"},r=i.default.getFirstMatch(/(?:opt)[\s/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(o,e);return r&&(t.version=r),t}},{test:[/yabrowser/i],describe:function(e){var t={name:"Yandex Browser"},r=i.default.getFirstMatch(/(?:yabrowser)[\s/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(o,e);return r&&(t.version=r),t}},{test:[/ucbrowser/i],describe:function(e){var t={name:"UC Browser"},r=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/(?:ucbrowser)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/Maxthon|mxios/i],describe:function(e){var t={name:"Maxthon"},r=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/(?:Maxthon|mxios)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/epiphany/i],describe:function(e){var t={name:"Epiphany"},r=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/(?:epiphany)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/puffin/i],describe:function(e){var t={name:"Puffin"},r=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/(?:puffin)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/sleipnir/i],describe:function(e){var t={name:"Sleipnir"},r=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/(?:sleipnir)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/k-meleon/i],describe:function(e){var t={name:"K-Meleon"},r=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/(?:k-meleon)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/micromessenger/i],describe:function(e){var t={name:"WeChat"},r=i.default.getFirstMatch(/(?:micromessenger)[\s/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(o,e);return r&&(t.version=r),t}},{test:[/qqbrowser/i],describe:function(e){var t={name:/qqbrowserlite/i.test(e)?"QQ Browser Lite":"QQ Browser"},r=i.default.getFirstMatch(/(?:qqbrowserlite|qqbrowser)[/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(o,e);return r&&(t.version=r),t}},{test:[/msie|trident/i],describe:function(e){var t={name:"Internet Explorer"},r=i.default.getFirstMatch(/(?:msie |rv:)(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/\sedg\//i],describe:function(e){var t={name:"Microsoft Edge"},r=i.default.getFirstMatch(/\sedg\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/edg([ea]|ios)/i],describe:function(e){var t={name:"Microsoft Edge"},r=i.default.getSecondMatch(/edg([ea]|ios)\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/vivaldi/i],describe:function(e){var t={name:"Vivaldi"},r=i.default.getFirstMatch(/vivaldi\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/seamonkey/i],describe:function(e){var t={name:"SeaMonkey"},r=i.default.getFirstMatch(/seamonkey\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/sailfish/i],describe:function(e){var t={name:"Sailfish"},r=i.default.getFirstMatch(/sailfish\s?browser\/(\d+(\.\d+)?)/i,e);return r&&(t.version=r),t}},{test:[/silk/i],describe:function(e){var t={name:"Amazon Silk"},r=i.default.getFirstMatch(/silk\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/phantom/i],describe:function(e){var t={name:"PhantomJS"},r=i.default.getFirstMatch(/phantomjs\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/slimerjs/i],describe:function(e){var t={name:"SlimerJS"},r=i.default.getFirstMatch(/slimerjs\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/blackberry|\bbb\d+/i,/rim\stablet/i],describe:function(e){var t={name:"BlackBerry"},r=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/blackberry[\d]+\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/(web|hpw)[o0]s/i],describe:function(e){var t={name:"WebOS Browser"},r=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/w(?:eb)?[o0]sbrowser\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/bada/i],describe:function(e){var t={name:"Bada"},r=i.default.getFirstMatch(/dolfin\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/tizen/i],describe:function(e){var t={name:"Tizen"},r=i.default.getFirstMatch(/(?:tizen\s?)?browser\/(\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(o,e);return r&&(t.version=r),t}},{test:[/qupzilla/i],describe:function(e){var t={name:"QupZilla"},r=i.default.getFirstMatch(/(?:qupzilla)[\s/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(o,e);return r&&(t.version=r),t}},{test:[/firefox|iceweasel|fxios/i],describe:function(e){var t={name:"Firefox"},r=i.default.getFirstMatch(/(?:firefox|iceweasel|fxios)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/electron/i],describe:function(e){var t={name:"Electron"},r=i.default.getFirstMatch(/(?:electron)\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/MiuiBrowser/i],describe:function(e){var t={name:"Miui"},r=i.default.getFirstMatch(/(?:MiuiBrowser)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/chromium/i],describe:function(e){var t={name:"Chromium"},r=i.default.getFirstMatch(/(?:chromium)[\s/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(o,e);return r&&(t.version=r),t}},{test:[/chrome|crios|crmo/i],describe:function(e){var t={name:"Chrome"},r=i.default.getFirstMatch(/(?:chrome|crios|crmo)\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/GSA/i],describe:function(e){var t={name:"Google Search"},r=i.default.getFirstMatch(/(?:GSA)\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:function(e){var t=!e.test(/like android/i),r=e.test(/android/i);return t&&r},describe:function(e){var t={name:"Android Browser"},r=i.default.getFirstMatch(o,e);return r&&(t.version=r),t}},{test:[/playstation 4/i],describe:function(e){var t={name:"PlayStation 4"},r=i.default.getFirstMatch(o,e);return r&&(t.version=r),t}},{test:[/safari|applewebkit/i],describe:function(e){var t={name:"Safari"},r=i.default.getFirstMatch(o,e);return r&&(t.version=r),t}},{test:[/.*/i],describe:function(e){var t=-1!==e.search("\\(")?/^(.*)\/(.*)[ \t]\((.*)/:/^(.*)\/(.*) /;return{name:i.default.getFirstMatch(t,e),version:i.default.getSecondMatch(t,e)}}}];t.default=a,e.exports=t.default},93:function(e,t,r){"use strict";t.__esModule=!0,t.default=void 0;var n,i=(n=r(17))&&n.__esModule?n:{default:n},o=r(18),a=[{test:[/Roku\/DVP/],describe:function(e){var t=i.default.getFirstMatch(/Roku\/DVP-(\d+\.\d+)/i,e);return{name:o.OS_MAP.Roku,version:t}}},{test:[/windows phone/i],describe:function(e){var t=i.default.getFirstMatch(/windows phone (?:os)?\s?(\d+(\.\d+)*)/i,e);return{name:o.OS_MAP.WindowsPhone,version:t}}},{test:[/windows /i],describe:function(e){var t=i.default.getFirstMatch(/Windows ((NT|XP)( \d\d?.\d)?)/i,e),r=i.default.getWindowsVersionName(t);return{name:o.OS_MAP.Windows,version:t,versionName:r}}},{test:[/Macintosh(.*?) FxiOS(.*?)\//],describe:function(e){var t={name:o.OS_MAP.iOS},r=i.default.getSecondMatch(/(Version\/)(\d[\d.]+)/,e);return r&&(t.version=r),t}},{test:[/macintosh/i],describe:function(e){var t=i.default.getFirstMatch(/mac os x (\d+(\.?_?\d+)+)/i,e).replace(/[_\s]/g,"."),r=i.default.getMacOSVersionName(t),n={name:o.OS_MAP.MacOS,version:t};return r&&(n.versionName=r),n}},{test:[/(ipod|iphone|ipad)/i],describe:function(e){var t=i.default.getFirstMatch(/os (\d+([_\s]\d+)*) like mac os x/i,e).replace(/[_\s]/g,".");return{name:o.OS_MAP.iOS,version:t}}},{test:function(e){var t=!e.test(/like android/i),r=e.test(/android/i);return t&&r},describe:function(e){var t=i.default.getFirstMatch(/android[\s/-](\d+(\.\d+)*)/i,e),r=i.default.getAndroidVersionName(t),n={name:o.OS_MAP.Android,version:t};return r&&(n.versionName=r),n}},{test:[/(web|hpw)[o0]s/i],describe:function(e){var t=i.default.getFirstMatch(/(?:web|hpw)[o0]s\/(\d+(\.\d+)*)/i,e),r={name:o.OS_MAP.WebOS};return t&&t.length&&(r.version=t),r}},{test:[/blackberry|\bbb\d+/i,/rim\stablet/i],describe:function(e){var t=i.default.getFirstMatch(/rim\stablet\sos\s(\d+(\.\d+)*)/i,e)||i.default.getFirstMatch(/blackberry\d+\/(\d+([_\s]\d+)*)/i,e)||i.default.getFirstMatch(/\bbb(\d+)/i,e);return{name:o.OS_MAP.BlackBerry,version:t}}},{test:[/bada/i],describe:function(e){var t=i.default.getFirstMatch(/bada\/(\d+(\.\d+)*)/i,e);return{name:o.OS_MAP.Bada,version:t}}},{test:[/tizen/i],describe:function(e){var t=i.default.getFirstMatch(/tizen[/\s](\d+(\.\d+)*)/i,e);return{name:o.OS_MAP.Tizen,version:t}}},{test:[/linux/i],describe:function(){return{name:o.OS_MAP.Linux}}},{test:[/CrOS/],describe:function(){return{name:o.OS_MAP.ChromeOS}}},{test:[/PlayStation 4/],describe:function(e){var t=i.default.getFirstMatch(/PlayStation 4[/\s](\d+(\.\d+)*)/i,e);return{name:o.OS_MAP.PlayStation4,version:t}}}];t.default=a,e.exports=t.default},94:function(e,t,r){"use strict";t.__esModule=!0,t.default=void 0;var n,i=(n=r(17))&&n.__esModule?n:{default:n},o=r(18),a=[{test:[/googlebot/i],describe:function(){return{type:"bot",vendor:"Google"}}},{test:[/huawei/i],describe:function(e){var t=i.default.getFirstMatch(/(can-l01)/i,e)&&"Nova",r={type:o.PLATFORMS_MAP.mobile,vendor:"Huawei"};return t&&(r.model=t),r}},{test:[/nexus\s*(?:7|8|9|10).*/i],describe:function(){return{type:o.PLATFORMS_MAP.tablet,vendor:"Nexus"}}},{test:[/ipad/i],describe:function(){return{type:o.PLATFORMS_MAP.tablet,vendor:"Apple",model:"iPad"}}},{test:[/Macintosh(.*?) FxiOS(.*?)\//],describe:function(){return{type:o.PLATFORMS_MAP.tablet,vendor:"Apple",model:"iPad"}}},{test:[/kftt build/i],describe:function(){return{type:o.PLATFORMS_MAP.tablet,vendor:"Amazon",model:"Kindle Fire HD 7"}}},{test:[/silk/i],describe:function(){return{type:o.PLATFORMS_MAP.tablet,vendor:"Amazon"}}},{test:[/tablet(?! pc)/i],describe:function(){return{type:o.PLATFORMS_MAP.tablet}}},{test:function(e){var t=e.test(/ipod|iphone/i),r=e.test(/like (ipod|iphone)/i);return t&&!r},describe:function(e){var t=i.default.getFirstMatch(/(ipod|iphone)/i,e);return{type:o.PLATFORMS_MAP.mobile,vendor:"Apple",model:t}}},{test:[/nexus\s*[0-6].*/i,/galaxy nexus/i],describe:function(){return{type:o.PLATFORMS_MAP.mobile,vendor:"Nexus"}}},{test:[/[^-]mobi/i],describe:function(){return{type:o.PLATFORMS_MAP.mobile}}},{test:function(e){return"blackberry"===e.getBrowserName(!0)},describe:function(){return{type:o.PLATFORMS_MAP.mobile,vendor:"BlackBerry"}}},{test:function(e){return"bada"===e.getBrowserName(!0)},describe:function(){return{type:o.PLATFORMS_MAP.mobile}}},{test:function(e){return"windows phone"===e.getBrowserName()},describe:function(){return{type:o.PLATFORMS_MAP.mobile,vendor:"Microsoft"}}},{test:function(e){var t=Number(String(e.getOSVersion()).split(".")[0]);return"android"===e.getOSName(!0)&&t>=3},describe:function(){return{type:o.PLATFORMS_MAP.tablet}}},{test:function(e){return"android"===e.getOSName(!0)},describe:function(){return{type:o.PLATFORMS_MAP.mobile}}},{test:function(e){return"macos"===e.getOSName(!0)},describe:function(){return{type:o.PLATFORMS_MAP.desktop,vendor:"Apple"}}},{test:function(e){return"windows"===e.getOSName(!0)},describe:function(){return{type:o.PLATFORMS_MAP.desktop}}},{test:function(e){return"linux"===e.getOSName(!0)},describe:function(){return{type:o.PLATFORMS_MAP.desktop}}},{test:function(e){return"playstation 4"===e.getOSName(!0)},describe:function(){return{type:o.PLATFORMS_MAP.tv}}},{test:function(e){return"roku"===e.getOSName(!0)},describe:function(){return{type:o.PLATFORMS_MAP.tv}}}];t.default=a,e.exports=t.default},95:function(e,t,r){"use strict";t.__esModule=!0,t.default=void 0;var n,i=(n=r(17))&&n.__esModule?n:{default:n},o=r(18),a=[{test:function(e){return"microsoft edge"===e.getBrowserName(!0)},describe:function(e){if(/\sedg\//i.test(e))return{name:o.ENGINE_MAP.Blink};var t=i.default.getFirstMatch(/edge\/(\d+(\.?_?\d+)+)/i,e);return{name:o.ENGINE_MAP.EdgeHTML,version:t}}},{test:[/trident/i],describe:function(e){var t={name:o.ENGINE_MAP.Trident},r=i.default.getFirstMatch(/trident\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:function(e){return e.test(/presto/i)},describe:function(e){var t={name:o.ENGINE_MAP.Presto},r=i.default.getFirstMatch(/presto\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:function(e){var t=e.test(/gecko/i),r=e.test(/like gecko/i);return t&&!r},describe:function(e){var t={name:o.ENGINE_MAP.Gecko},r=i.default.getFirstMatch(/gecko\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/(apple)?webkit\/537\.36/i],describe:function(){return{name:o.ENGINE_MAP.Blink}}},{test:[/(apple)?webkit/i],describe:function(e){var t={name:o.ENGINE_MAP.WebKit},r=i.default.getFirstMatch(/webkit\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}}];t.default=a,e.exports=t.default}})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n,i,o=r(2),a=r(6),s=r(5),c=r(3),u=r(0),d=r(4);!function(e){e[e.played=1]="played",e[e.playing=2]="playing",e[e.paused=3]="paused"}(n||(n={})),function(e){e[e.played=1]="played",e[e.playing=2]="playing",e[e.paused=3]="paused"}(i||(i={}));var f=function(e){function t(t,r,o){var a=e.call(this)||this;a.mute=!1,a.audioMediaStream=new MediaStream,a.videoMediaStream=new MediaStream,a.isPlayVideoLocked=!1,a.audioPlayStatus=n.paused,a.videoPlayStatus=i.paused,a.onTrackStateChange=function(e){var t=e.target.kind;switch(e.type){case"mute":u.default.debug("player - "+t+" mute",a.stream.streamId);break;case"unmute":u.default.debug("player - "+t+" unmute",a.stream.streamId);break;case"ended":u.default.debug("player - "+t+" ended",a.stream.streamId)}},a.container=r,a.stream=t;var s=o.mute,c=void 0!==s&&s,d=o.mirror,f=void 0!==d&&d,p=o.fit,l=o.controls;return l&&(a.controls=l),a.mute=c,a.initWrapper(),a.initVideoElement(f,p),a.wrapper.appendChild(a.video),a.initAudioElement(c),a.wrapper.appendChild(a.audio),a.init(),a}return o.__extends(t,e),Object.defineProperty(t.prototype,"isPlaying",{get:function(){return this.audioPlayStatus===n.playing&&this.videoPlayStatus===i.playing},enumerable:!0,configurable:!0}),t.prototype.updateAudioTrack=function(e){var t=this;this.audioMediaStream.getAudioTracks().forEach((function(e){e.removeEventListener("mute",t.onTrackStateChange),e.removeEventListener("unmute",t.onTrackStateChange),e.removeEventListener("ended",t.onTrackStateChange),t.audioMediaStream.removeTrack(e)})),e.addEventListener("mute",this.onTrackStateChange),e.addEventListener("unmute",this.onTrackStateChange),e.addEventListener("ended",this.onTrackStateChange),this.audioMediaStream.addTrack(e)},t.prototype.updateVideoTrack=function(e){var t=this;this.videoMediaStream.getVideoTracks().forEach((function(e){e.removeEventListener("mute",t.onTrackStateChange),e.removeEventListener("unmute",t.onTrackStateChange),e.removeEventListener("ended",t.onTrackStateChange),t.videoMediaStream.removeTrack(e)})),e.addEventListener("mute",this.onTrackStateChange),e.addEventListener("unmute",this.onTrackStateChange),e.addEventListener("ended",this.onTrackStateChange),this.videoMediaStream.addTrack(e)},t.prototype.hasAudio=function(){return this.stream.isSubscriber?this.stream.audio:this.stream.hasAudio()},t.prototype.hasVideo=function(){return this.stream.isSubscriber?this.stream.video:this.stream.hasVideo()},t.prototype.init=function(){var e=this,t=this.stream.getMediaStream();if(t){var r=t.getAudioTracks()[0];r&&this.updateAudioTrack(r);var o=t.getVideoTracks()[0];o&&this.updateVideoTrack(o)}this.audio.addEventListener("play",(function(){u.default.info("audio played"),e.updateControls(e.audio,!0)})),this.audio.addEventListener("playing",(function(){u.default.info("audio playing"),e.hasVideo()||e.emit("playing"),e.audioPlayStatus!==n.playing&&e.emit("audio-playing"),e.hasVideo()&&!e.isPlayVideoLocked&&e.playVideo().catch((function(e){u.default.info("audio trigger autoplay video "+e,e),u.default.report("audio trigger autoplay video "+e,e)})),e.audioPlayStatus=n.playing})),this.audio.addEventListener("pause",(function(){u.default.info("audio paused"),e.hasVideo()||e.emit("paused"),e.audioPlayStatus!==n.paused&&e.emit("audio-paused"),e.audioPlayStatus=n.paused,e.updateControls(e.audio,!1)})),this.video.addEventListener("play",(function(){u.default.info("video played")})),this.video.addEventListener("playing",(function(){u.default.info("video playing"),e.emit("playing"),e.videoPlayStatus!==i.playing&&e.emit("video-playing"),e.videoPlayStatus=i.playing,e.video.controls=!1})),this.video.addEventListener("pause",(function(){u.default.info("video paused"),e.emit("paused"),e.videoPlayStatus!==i.paused&&e.emit("video-paused"),e.videoPlayStatus=i.paused})),this.video.addEventListener("stalled",(function(){u.default.info("video stalled")})),this.video.addEventListener("canplay",(function(){u.default.info("video canplay")})),this.video.addEventListener("suspend",(function(){u.default.info("video suspend")})),this.video.addEventListener("timer",(function(){u.default.info("video timer")})),this.video.addEventListener("waiting",(function(){u.default.info("video waiting")})),this.video.addEventListener("seeking",(function(){u.default.info("video seeking")}))},t.prototype.updateControls=function(e,t){switch(this.controls){case"hide":e.style.display="none",e.controls=!1;break;case"show":e.style.display="inline-block",e.controls=!0;break;case"auto":default:t?(e.style.display="none",e.controls=!1):(e.style.display="inline-block",e.controls=!0)}},t.prototype.playAudio=function(){if(this.audio.srcObject=this.audioMediaStream,this.mute)return Promise.resolve();var e=window.setTimeout((function(){u.default.warn("the play() of audio request was pending"),u.default.report("the play() of audio request was pending - "+navigator.userAgent)}),8e3);return this.audio.play().catch((function(e){if(!e||!e.toString().toLowerCase().includes("the play() request was interrupted by a"))throw e})).finally((function(){window.clearTimeout(e)}))},t.prototype.playVideo=function(){var e=this;return this.video.srcObject=this.videoMediaStream,new Promise((function(t,r){return o.__awaiter(e,void 0,void 0,(function(){var e,n,i;return o.__generator(this,(function(o){switch(o.label){case 0:e=this.stream.videoMuted||this.stream.sourceVideoMuted?window.setTimeout((function(){t()}),1e3):window.setTimeout((function(){r(c.createError(c.ErrorCodes.OTHERS,"the play() request was pending"))}),8e3),n=function(){window.clearTimeout(e),t()},o.label=1;case 1:return o.trys.push([1,3,,4]),[4,this.video.play()];case 2:return o.sent(),n(),[3,4];case 3:return(i=o.sent())&&i.toString().toLowerCase().includes("the play() request was interrupted by a")?n():i&&i.toString().toLowerCase().includes("the operation was aborted")?n():r(i),[3,4];case 4:return[2]}}))}))}))},t.prototype.resume=function(){return o.__awaiter(this,void 0,void 0,(function(){var e,t;return o.__generator(this,(function(r){switch(r.label){case 0:if(this.isPlayVideoLocked=!0,!this.hasAudio())return[3,4];r.label=1;case 1:return r.trys.push([1,3,,4]),this.updateControls(this.audio,!1),u.default.debug("player - before resume audio "+this.stream.streamId),[4,this.playAudio()];case 2:return r.sent(),u.default.debug("player - resume audio "+this.stream.streamId),[3,4];case 3:throw e=r.sent(),u.default.warn("player - resume audio error "+e),u.default.report("player - resume "+this.stream.streamId+" audio error "+e),this.updateControls(this.audio,!1),this.isPlayVideoLocked=!1,e;case 4:if(!this.hasVideo())return[3,8];r.label=5;case 5:return r.trys.push([5,7,,8]),u.default.debug("player - before resume video "+this.stream.streamId),[4,this.playVideo()];case 6:return r.sent(),u.default.debug("player - resume video "+this.stream.streamId),[3,8];case 7:throw t=r.sent(),u.default.warn("player - resume video error "+t),u.default.report("player - resume "+this.stream.streamId+" video error "+t),this.isPlayVideoLocked=!1,t;case 8:return this.isPlayVideoLocked=!1,[2]}}))}))},t.prototype.play=function(){return o.__awaiter(this,void 0,void 0,(function(){var e,t;return o.__generator(this,(function(r){switch(r.label){case 0:if(!this.stream.getMediaStream())return[2,Promise.reject(c.createError(c.ErrorCodes.INVALID_MEDIASTREAM,"no media stream can play"))];if(this.container.appendChild(this.wrapper),this.isPlayVideoLocked=!0,!this.hasAudio())return[3,4];r.label=1;case 1:return r.trys.push([1,3,,4]),this.updateControls(this.audio,!1),u.default.debug("player - before play audio "+this.stream.streamId),[4,this.playAudio()];case 2:return r.sent(),u.default.debug("player - play audio "+this.stream.streamId),[3,4];case 3:throw e=r.sent(),u.default.warn("player - play audio error "+e),u.default.report("player - play "+this.stream.streamId+" audio error "+e),this.updateControls(this.audio,!1),this.isPlayVideoLocked=!1,e;case 4:if(!this.hasVideo())return[3,8];r.label=5;case 5:return r.trys.push([5,7,,8]),u.default.debug("player - before play video "+this.stream.streamId),[4,this.playVideo()];case 6:return r.sent(),u.default.debug("player - play video "+this.stream.streamId),[3,8];case 7:throw t=r.sent(),d.default.isIOS()&&d.default.isWeChat()&&!this.hasAudio()&&"NotAllowedError"===t.name&&"hide"!==this.controls&&(this.video.controlsList="nodownload nofullscreen noremoteplayback",this.video.controls=!0),u.default.warn("player - play video error "+t),u.default.report("player - play "+this.stream.streamId+" video error "+t),this.isPlayVideoLocked=!1,t;case 8:return this.isPlayVideoLocked=!1,[2]}}))}))},t.prototype.stop=function(){this.audio.pause(),this.video.pause()},t.prototype.destroy=function(){try{this.stop()}catch(e){u.default.warn(e.name+": "+e.message)}try{this.container.removeChild(this.wrapper)}catch(e){u.default.warn(e.name+": "+e.message)}},t.prototype.initWrapper=function(){this.wrapper=document.createElement("div"),this.hasVideo()?this.wrapper.setAttribute("style","width: 100%; height: 100%; position: relative; background-color: black; overflow: hidden;"):this.wrapper.setAttribute("style","width: 100%; height: 100%; position: relative; overflow: hidden;")},t.prototype.initAudioElement=function(e){void 0===e&&(e=!1),this.audio=document.createElement("audio"),this.audio.setAttribute("id","audio-"+this.stream.streamId),e&&(this.audio.setAttribute("muted","muted"),this.audio.muted=!0,this.audio.volume=0),this.audio.setAttribute("style","position: absolute; bottom: 0; width: 100%; opacity: 0.5;"),d.default.isChrome()&&(this.audio.style.maxHeight="20%",d.isMobile()||(this.audio.style.backgroundColor="#eee")),this.audio.setAttribute("playsinline",""),this.audio.setAttribute("webkit-playsinline","true"),this.stream.isSubscriber||(this.audio.style.visibility="hidden",this.audio.style.zIndex="-1")},t.prototype.initVideoElement=function(e,t){void 0===e&&(e=!1),this.video=document.createElement("video"),this.video.setAttribute("id","video-"+this.stream.streamId),this.stream.isSubscriber||"user"===this.stream.config.facingMode&&(e=!0),t||(t="cover",this.stream.mediaType===s.ENUM_MEDIA_TYPE.desktop&&(t="contain"));var r="width: 100%; height: 100%; position: absolute;";e&&(r+="transform: rotateY(180deg);"),r+="object-fit: "+t,this.video.setAttribute("style",r),this.video.setAttribute("muted","muted"),this.video.muted=!0,this.video.volume=0,this.video.setAttribute("playsinline",""),this.video.setAttribute("webkit-playsinline","true")},t.prototype.setAudioVolume=function(e){e/=100,this.audio.volume=e},t}(a.EventEmitter);t.Player=f},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(0),i=function(){function e(e){var t=this;if(!!!Worker)throw new Error("Web Worker is Not Enabled");var r=e.toString().replace(/^[^{]*{\s*/,"").replace(/\s*}[^}]*$/,"");this.worker=new Worker(URL.createObjectURL(new Blob([r],{type:"text/javascript"}))),this.worker.onmessage=function(e){t.onmessage(e)},this.worker.onerror=function(e){t.onerror(e)}}return e.prototype.postMessage=function(e){this.worker.postMessage(e)},e.prototype.onmessage=function(e){n.default.debug("onmessage ",e)},e.prototype.onerror=function(e){n.default.debug("onerror ",e)},e.prototype.terminate=function(){var e;null===(e=this.worker)||void 0===e||e.terminate()},e}();t.InlineWorker=i},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(2),i=r(87),o=r(6),a=r(11),s=r(39),c=r(9),u=r(0),d=r(3),f=r(5),p=function(e){function t(){var t=e.call(this)||this;return t.streams=new Map,t.on("screen-track-ended",(function(e){u.default.debug("screen-track-ended",e);var r=t.getStream(e.streamId);r&&t.emitter&&t.emitter.emit("screenshare-stopped",r.convertToOuterStream())})),t.on("stream-close",(function(e){e.destroyPlayer()})),t}return n.__extends(t,e),t.prototype.createStream=function(e,t,r,o){var u,d=this;t||(t=i.v4()),u="preview"===t?{audio:r.audio,video:r.video,screen:!1,data:!1,mediaType:f.ENUM_MEDIA_TYPE.camera,microphoneId:r.microphoneId,cameraId:r.cameraId,facingMode:r.facingMode}:s.StreamManager.generatePublishConfig(r);var p,l=new a.LocalStream(e,u,this);return l.previewId=t,l.streamId=t,p="object"==typeof o?c.getCustomResolution(o):c.getResolution(o),l.setResolution(p),new Promise((function(e,t){return n.__awaiter(d,void 0,void 0,(function(){var i;return n.__generator(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,l.init(r)];case 1:return n.sent(),this.streams.set(l.streamId,l),e(l),[3,3];case 2:return i=n.sent(),l.close(),t(i),[3,3];case 3:return[2]}}))}))}))},t.prototype.copyStream=function(e){var t=this,r=new a.LocalStream(e.userId,e.config,this);return r.previewId=e.previewId||e.streamId,r.streamId=e.streamId,r.setResolution(e.resolution),this.streams.set(r.streamId,r),new Promise((function(i,o){return n.__awaiter(t,void 0,void 0,(function(){var t;return n.__generator(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,r.init({},e)];case 1:return n.sent(),i(r),[3,3];case 2:return t=n.sent(),o(t),[3,3];case 3:return[2]}}))}))}))},t.prototype.removeStream=function(e,t){var r=this;return new Promise((function(n,i){var o=r.getStream(e);o?(o.close(t),r.streams.delete(o.streamId),n()):i(d.createError(d.ErrorCodes.STREAM_NOT_EXISTS,"stream isnot found"))}))},t.prototype.removeAllStreams=function(){var e=this;return new Promise((function(t,r){try{e.streams.forEach((function(e){e.close()})),e.streams.clear(),t()}catch(e){r(e)}}))},t.prototype.getStream=function(e){var t;return(t=this.streams.get(e))||this.streams.forEach((function(r){r.previewId===e&&(t=r)})),t},t.prototype.getAllStreams=function(){var e=[];return this.streams.forEach((function(t){e.push(t)})),e},t.prototype.setVideoProfile=function(e,t){var r;r="object"==typeof t?c.getCustomResolution(t):c.getResolution(t);var n=this.getStream(e);return n?(n.setResolution(r),n.applyResolution(r)):Promise.reject(d.createError(d.ErrorCodes.STREAM_NOT_EXISTS,"stream isn't found"))},t.prototype.destroy=function(){this.removeAllStreams().catch((function(e){u.default.warn("remove all preview streams error: "+e)}))},t}(o.EventEmitter);t.PreviewStreamManager=p},function(module,exports,__webpack_require__){(function(global){var __WEBPACK_AMD_DEFINE_ARRAY__,__WEBPACK_AMD_DEFINE_RESULT__;!function(e,t){module.exports=t(e)}("undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0!==global?global:this,(function(global){"use strict";global=global||{};var _Base64=global.Base64,version="2.5.1",buffer;if(module.exports)try{buffer=eval("require('buffer').Buffer")}catch(e){buffer=void 0}var b64chars="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",b64tab=function(e){for(var t={},r=0,n=e.length;r>>6)+fromCharCode(128|63&t):fromCharCode(224|t>>>12&15)+fromCharCode(128|t>>>6&63)+fromCharCode(128|63&t);var t=65536+1024*(e.charCodeAt(0)-55296)+(e.charCodeAt(1)-56320);return fromCharCode(240|t>>>18&7)+fromCharCode(128|t>>>12&63)+fromCharCode(128|t>>>6&63)+fromCharCode(128|63&t)},re_utob=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,utob=function(e){return e.replace(re_utob,cb_utob)},cb_encode=function(e){var t=[0,2,1][e.length%3],r=e.charCodeAt(0)<<16|(e.length>1?e.charCodeAt(1):0)<<8|(e.length>2?e.charCodeAt(2):0);return[b64chars.charAt(r>>>18),b64chars.charAt(r>>>12&63),t>=2?"=":b64chars.charAt(r>>>6&63),t>=1?"=":b64chars.charAt(63&r)].join("")},btoa=global.btoa?function(e){return global.btoa(e)}:function(e){return e.replace(/[\s\S]{1,3}/g,cb_encode)},_encode=buffer?buffer.from&&Uint8Array&&buffer.from!==Uint8Array.from?function(e){return(e.constructor===buffer.constructor?e:buffer.from(e)).toString("base64")}:function(e){return(e.constructor===buffer.constructor?e:new buffer(e)).toString("base64")}:function(e){return btoa(utob(e))},encode=function(e,t){return t?_encode(String(e)).replace(/[+\/]/g,(function(e){return"+"==e?"-":"_"})).replace(/=/g,""):_encode(String(e))},encodeURI=function(e){return encode(e,!0)},re_btou=new RegExp(["[À-ß][€-¿]","[à-ï][€-¿]{2}","[ð-÷][€-¿]{3}"].join("|"),"g"),cb_btou=function(e){switch(e.length){case 4:var t=((7&e.charCodeAt(0))<<18|(63&e.charCodeAt(1))<<12|(63&e.charCodeAt(2))<<6|63&e.charCodeAt(3))-65536;return fromCharCode(55296+(t>>>10))+fromCharCode(56320+(1023&t));case 3:return fromCharCode((15&e.charCodeAt(0))<<12|(63&e.charCodeAt(1))<<6|63&e.charCodeAt(2));default:return fromCharCode((31&e.charCodeAt(0))<<6|63&e.charCodeAt(1))}},btou=function(e){return e.replace(re_btou,cb_btou)},cb_decode=function(e){var t=e.length,r=t%4,n=(t>0?b64tab[e.charAt(0)]<<18:0)|(t>1?b64tab[e.charAt(1)]<<12:0)|(t>2?b64tab[e.charAt(2)]<<6:0)|(t>3?b64tab[e.charAt(3)]:0),i=[fromCharCode(n>>>16),fromCharCode(n>>>8&255),fromCharCode(255&n)];return i.length-=[0,0,2,1][r],i.join("")},_atob=global.atob?function(e){return global.atob(e)}:function(e){return e.replace(/\S{1,4}/g,cb_decode)},atob=function(e){return _atob(String(e).replace(/[^A-Za-z0-9\+\/]/g,""))},_decode=buffer?buffer.from&&Uint8Array&&buffer.from!==Uint8Array.from?function(e){return(e.constructor===buffer.constructor?e:buffer.from(e,"base64")).toString()}:function(e){return(e.constructor===buffer.constructor?e:new buffer(e,"base64")).toString()}:function(e){return btou(_atob(e))},decode=function(e){return _decode(String(e).replace(/[-_]/g,(function(e){return"-"==e?"+":"/"})).replace(/[^A-Za-z0-9\+\/]/g,""))},noConflict=function(){var e=global.Base64;return global.Base64=_Base64,e};if(global.Base64={VERSION:version,atob:atob,btoa:btoa,fromBase64:decode,toBase64:encode,utob:utob,encode:encode,encodeURI:encodeURI,btou:btou,decode:decode,noConflict:noConflict,__buffer__:buffer},"function"==typeof Object.defineProperty){var noEnum=function(e){return{value:e,enumerable:!1,writable:!0,configurable:!0}};global.Base64.extendString=function(){Object.defineProperty(String.prototype,"fromBase64",noEnum((function(){return decode(this)}))),Object.defineProperty(String.prototype,"toBase64",noEnum((function(e){return encode(this,e)}))),Object.defineProperty(String.prototype,"toBase64URI",noEnum((function(){return encode(this,!0)})))}}return global.Meteor&&(Base64=global.Base64),module.exports?module.exports.Base64=global.Base64:(__WEBPACK_AMD_DEFINE_ARRAY__=[],__WEBPACK_AMD_DEFINE_RESULT__=function(){return global.Base64}.apply(exports,__WEBPACK_AMD_DEFINE_ARRAY__),void 0===__WEBPACK_AMD_DEFINE_RESULT__||(module.exports=__WEBPACK_AMD_DEFINE_RESULT__)),{Base64:global.Base64}}))}).call(this,__webpack_require__(8))},function(e,t,r){"use strict";var n;!function(i){function o(e,t,r){var n,i,o,a,l,m,h,v,g,y=0,E=[],b=0,_=!1,S=[],T=[],w=!1,R=!1,M=-1;if(n=(r=r||{}).encoding||"UTF8",(g=r.numRounds||1)!==parseInt(g,10)||1>g)throw Error("numRounds must a integer >= 1");if("SHA-1"===e)l=512,m=D,h=V,a=160,v=function(e){return e.slice()};else if(0===e.lastIndexOf("SHA-",0))if(m=function(t,r){return B(t,r,e)},h=function(t,r,n,i){var o,a;if("SHA-224"===e||"SHA-256"===e)o=15+(r+65>>>9<<4),a=16;else{if("SHA-384"!==e&&"SHA-512"!==e)throw Error("Unexpected error in SHA-2 implementation");o=31+(r+129>>>10<<5),a=32}for(;t.length<=o;)t.push(0);for(t[r>>>5]|=128<<24-r%32,r+=n,t[o]=4294967295&r,t[o-1]=r/4294967296|0,n=t.length,r=0;rt;t+=1)r[t]=e[t].slice();return r},M=1,"SHA3-224"===e)l=1152,a=224;else if("SHA3-256"===e)l=1088,a=256;else if("SHA3-384"===e)l=832,a=384;else if("SHA3-512"===e)l=576,a=512;else if("SHAKE128"===e)l=1344,a=-1,C=31,R=!0;else{if("SHAKE256"!==e)throw Error("Chosen SHA variant is not supported");l=1088,a=-1,C=31,R=!0}h=function(e,t,r,n,i){var o,a=C,s=[],c=(r=l)>>>5,u=0,d=t>>>5;for(o=0;o=r;o+=c)n=F(e.slice(o,o+c),n),t-=r;for(e=e.slice(o),t%=r;e.length>>3)>>2]^=a<=i));)s.push(e.a),0==64*(u+=1)%r&&F(null,n);return s}}o=p(t,n,M),i=j(e),this.setHMACKey=function(t,r,o){var s;if(!0===_)throw Error("HMAC key already set");if(!0===w)throw Error("Cannot set HMAC key after calling update");if(!0===R)throw Error("SHAKE is not supported for HMAC");if(t=(r=p(r,n=(o||{}).encoding||"UTF8",M)(t)).binLen,r=r.value,o=(s=l>>>3)/4-1,st/8){for(;r.length<=o;)r.push(0);r[o]&=4294967040}for(t=0;t<=o;t+=1)S[t]=909522486^r[t],T[t]=1549556828^r[t];i=m(S,i),y=l,_=!0},this.update=function(e){var t,r,n,a=0,s=l>>>5;for(e=(t=o(e,E,b)).binLen,r=t.value,t=e>>>5,n=0;n>>5),b=e%l,w=!0},this.getHash=function(t,r){var n,o,p,l;if(!0===_)throw Error("Cannot call getHash after setting HMAC key");if(p=f(r),!0===R){if(-1===p.shakeLen)throw Error("shakeLen must be specified in options");a=p.shakeLen}switch(t){case"HEX":n=function(e){return s(e,a,M,p)};break;case"B64":n=function(e){return c(e,a,M,p)};break;case"BYTES":n=function(e){return u(e,a,M)};break;case"ARRAYBUFFER":try{o=new ArrayBuffer(0)}catch(e){throw Error("ARRAYBUFFER not supported by this environment")}n=function(e){return d(e,a,M)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER")}for(l=h(E.slice(),b,y,v(i),a),o=1;o>>24-a%32),l=h(l,a,0,j(e),a);return n(l)},this.getHMAC=function(t,r){var n,o,p,g;if(!1===_)throw Error("Cannot call getHMAC without first setting HMAC key");switch(p=f(r),t){case"HEX":n=function(e){return s(e,a,M,p)};break;case"B64":n=function(e){return c(e,a,M,p)};break;case"BYTES":n=function(e){return u(e,a,M)};break;case"ARRAYBUFFER":try{n=new ArrayBuffer(0)}catch(e){throw Error("ARRAYBUFFER not supported by this environment")}n=function(e){return d(e,a,M)};break;default:throw Error("outputFormat must be HEX, B64, BYTES, or ARRAYBUFFER")}return o=h(E.slice(),b,y,v(i),a),g=m(T,j(e)),n(g=h(o,a,l,g,a))}}function a(e,t){this.a=e,this.b=t}function s(e,t,r,n){var i,o,a,s="";for(t/=8,a=-1===r?3:0,i=0;i>>2]>>>8*(a+i%4*r),s+="0123456789abcdef".charAt(o>>>4&15)+"0123456789abcdef".charAt(15&o);return n.outputUpper?s.toUpperCase():s}function c(e,t,r,n){var i,o,a,s,c="",u=t/8;for(s=-1===r?3:0,i=0;i>>2]:0,a=i+2>>2]:0,a=(e[i>>>2]>>>8*(s+i%4*r)&255)<<16|(o>>>8*(s+(i+1)%4*r)&255)<<8|a>>>8*(s+(i+2)%4*r)&255,o=0;4>o;o+=1)c+=8*i+6*o<=t?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(a>>>6*(3-o)&63):n.b64Pad;return c}function u(e,t,r){var n,i,o,a="";for(t/=8,o=-1===r?3:0,n=0;n>>2]>>>8*(o+n%4*r)&255,a+=String.fromCharCode(i);return a}function d(e,t,r){t/=8;var n,i,o,a=new ArrayBuffer(t);for(o=new Uint8Array(a),i=-1===r?3:0,n=0;n>>2]>>>8*(i+n%4*r)&255;return a}function f(e){var t={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(e=e||{},t.outputUpper=e.outputUpper||!1,!0===e.hasOwnProperty("b64Pad")&&(t.b64Pad=e.b64Pad),!0===e.hasOwnProperty("shakeLen")){if(0!=e.shakeLen%8)throw Error("shakeLen must be a multiple of 8");t.shakeLen=e.shakeLen}if("boolean"!=typeof t.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof t.b64Pad)throw Error("Invalid b64Pad formatting option");return t}function p(e,t,r){switch(t){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(e){case"HEX":e=function(e,t,n){var i,o,a,s,c,u,d=e.length;if(0!=d%2)throw Error("String of HEX type must be in byte increments");for(t=t||[0],c=(n=n||0)>>>3,u=-1===r?3:0,i=0;i>>1)+c)>>>2;t.length<=a;)t.push(0);t[a]|=o<<8*(u+s%4*r)}return{value:t,binLen:4*d+n}};break;case"TEXT":e=function(e,n,i){var o,a,s,c,u,d,f,p,l=0;if(n=n||[0],u=(i=i||0)>>>3,"UTF8"===t)for(p=-1===r?3:0,s=0;s(o=e.charCodeAt(s))?a.push(o):2048>o?(a.push(192|o>>>6),a.push(128|63&o)):55296>o||57344<=o?a.push(224|o>>>12,128|o>>>6&63,128|63&o):(s+=1,o=65536+((1023&o)<<10|1023&e.charCodeAt(s)),a.push(240|o>>>18,128|o>>>12&63,128|o>>>6&63,128|63&o)),c=0;c>>2;n.length<=d;)n.push(0);n[d]|=a[c]<<8*(p+f%4*r),l+=1}else if("UTF16BE"===t||"UTF16LE"===t)for(p=-1===r?2:0,a="UTF16LE"===t&&1!==r||"UTF16LE"!==t&&1===r,s=0;s>>8),d=(f=l+u)>>>2;n.length<=d;)n.push(0);n[d]|=o<<8*(p+f%4*r),l+=2}return{value:n,binLen:8*l+i}};break;case"B64":e=function(e,t,n){var i,o,a,s,c,u,d,f,p=0;if(-1===e.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(o=e.indexOf("="),e=e.replace(/\=/g,""),-1!==o&&oe===t))throw new DOMException("The adapter.js addTrack polyfill only supports a single stream which is associated with the specified track.","NotSupportedError");const i=this.getSenders().find(e=>e.track===t);if(i)throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};const o=this._streams[r.id];if(o)o.addTrack(t),Promise.resolve().then(()=>{this.dispatchEvent(new Event("negotiationneeded"))});else{const n=new e.MediaStream([t]);this._streams[r.id]=n,this._reverseStreams[n.id]=r,this.addStream(n)}return this.getSenders().find(e=>e.track===t)},["createOffer","createAnswer"].forEach((function(t){const r=e.RTCPeerConnection.prototype[t],n={[t](){const e=arguments;return arguments.length&&"function"==typeof arguments[0]?r.apply(this,[t=>{const r=o(this,t);e[0].apply(null,[r])},t=>{e[1]&&e[1].apply(null,t)},arguments[2]]):r.apply(this,arguments).then(e=>o(this,e))}};e.RTCPeerConnection.prototype[t]=n[t]}));const s=e.RTCPeerConnection.prototype.setLocalDescription;e.RTCPeerConnection.prototype.setLocalDescription=function(){return arguments.length&&arguments[0].type?(arguments[0]=a(this,arguments[0]),s.apply(this,arguments)):s.apply(this,arguments)};const c=Object.getOwnPropertyDescriptor(e.RTCPeerConnection.prototype,"localDescription");Object.defineProperty(e.RTCPeerConnection.prototype,"localDescription",{get(){const e=c.get.apply(this);return""===e.type?e:o(this,e)}}),e.RTCPeerConnection.prototype.removeTrack=function(e){if("closed"===this.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");if(!e._pc)throw new DOMException("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.","TypeError");if(!(e._pc===this))throw new DOMException("Sender was not created by this connection.","InvalidAccessError");let t;this._streams=this._streams||{},Object.keys(this._streams).forEach(r=>{this._streams[r].getTracks().find(t=>e.track===t)&&(t=this._streams[r])}),t&&(1===t.getTracks().length?this.removeStream(this._reverseStreams[t.id]):t.removeTrack(e.track),this.dispatchEvent(new Event("negotiationneeded")))}}function I(e){const t=v(e);if(!e.RTCPeerConnection&&e.webkitRTCPeerConnection&&(e.RTCPeerConnection=e.webkitRTCPeerConnection),!e.RTCPeerConnection)return;const r=0===e.RTCPeerConnection.prototype.addIceCandidate.length;t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach((function(t){const r=e.RTCPeerConnection.prototype[t],n={[t](){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),r.apply(this,arguments)}};e.RTCPeerConnection.prototype[t]=n[t]}));const n=e.RTCPeerConnection.prototype.addIceCandidate;e.RTCPeerConnection.prototype.addIceCandidate=function(){return r||arguments[0]?t.version<78&&arguments[0]&&""===arguments[0].candidate?Promise.resolve():n.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())}}function A(e){const t=v(e);f(e,"negotiationneeded",e=>{const r=e.target;if(!(t.version<72||r.getConfiguration&&"plan-b"===r.getConfiguration().sdpSemantics)||"stable"===r.signalingState)return e})}var k=r(42),N=r.n(k);function U(e){const t=e&&e.navigator,r=t.mediaDevices.getUserMedia.bind(t.mediaDevices);t.mediaDevices.getUserMedia=function(e){return r(e).catch(e=>Promise.reject(function(e){return{name:{PermissionDeniedError:"NotAllowedError"}[e.name]||e.name,message:e.message,constraint:e.constraint,toString(){return this.name}}}(e)))}}function L(e){"getDisplayMedia"in e.navigator&&e.navigator.mediaDevices&&(e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||(e.navigator.mediaDevices.getDisplayMedia=e.navigator.getDisplayMedia.bind(e.navigator)))}function x(e){const t=v(e);if(e.RTCIceGatherer&&(e.RTCIceCandidate||(e.RTCIceCandidate=function(e){return e}),e.RTCSessionDescription||(e.RTCSessionDescription=function(e){return e}),t.version<15025)){const t=Object.getOwnPropertyDescriptor(e.MediaStreamTrack.prototype,"enabled");Object.defineProperty(e.MediaStreamTrack.prototype,"enabled",{set(e){t.set.call(this,e);const r=new Event("enabled");r.enabled=e,this.dispatchEvent(r)}})}!e.RTCRtpSender||"dtmf"in e.RTCRtpSender.prototype||Object.defineProperty(e.RTCRtpSender.prototype,"dtmf",{get(){return void 0===this._dtmf&&("audio"===this.track.kind?this._dtmf=new e.RTCDtmfSender(this):"video"===this.track.kind&&(this._dtmf=null)),this._dtmf}}),e.RTCDtmfSender&&!e.RTCDTMFSender&&(e.RTCDTMFSender=e.RTCDtmfSender);const r=N()(e,t.version);e.RTCPeerConnection=function(e){return e&&e.iceServers&&(e.iceServers=function(e,t){let r=!1;return(e=JSON.parse(JSON.stringify(e))).filter(e=>{if(e&&(e.urls||e.url)){let t=e.urls||e.url;e.url&&!e.urls&&h("RTCIceServer.url","RTCIceServer.urls");const n="string"==typeof t;return n&&(t=[t]),t=t.filter(e=>{if(0===e.indexOf("stun:"))return!1;const t=e.startsWith("turn")&&!e.startsWith("turn:[")&&e.includes("transport=udp");return t&&!r?(r=!0,!0):t&&!r}),delete e.url,e.urls=n?t[0]:t,!!t.length}})}(e.iceServers,t.version),m("ICE servers after filtering:",e.iceServers)),new r(e)},e.RTCPeerConnection.prototype=r.prototype}function j(e){!e.RTCRtpSender||"replaceTrack"in e.RTCRtpSender.prototype||(e.RTCRtpSender.prototype.replaceTrack=e.RTCRtpSender.prototype.setTrack)}function D(e){const t=v(e),r=e&&e.navigator,n=e&&e.MediaStreamTrack;if(r.getUserMedia=function(e,t,n){h("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),r.mediaDevices.getUserMedia(e).then(t,n)},!(t.version>55&&"autoGainControl"in r.mediaDevices.getSupportedConstraints())){const e=function(e,t,r){t in e&&!(r in e)&&(e[r]=e[t],delete e[t])},t=r.mediaDevices.getUserMedia.bind(r.mediaDevices);if(r.mediaDevices.getUserMedia=function(r){return"object"==typeof r&&"object"==typeof r.audio&&(r=JSON.parse(JSON.stringify(r)),e(r.audio,"autoGainControl","mozAutoGainControl"),e(r.audio,"noiseSuppression","mozNoiseSuppression")),t(r)},n&&n.prototype.getSettings){const t=n.prototype.getSettings;n.prototype.getSettings=function(){const r=t.apply(this,arguments);return e(r,"mozAutoGainControl","autoGainControl"),e(r,"mozNoiseSuppression","noiseSuppression"),r}}if(n&&n.prototype.applyConstraints){const t=n.prototype.applyConstraints;n.prototype.applyConstraints=function(r){return"audio"===this.kind&&"object"==typeof r&&(r=JSON.parse(JSON.stringify(r)),e(r,"autoGainControl","mozAutoGainControl"),e(r,"noiseSuppression","mozNoiseSuppression")),t.apply(this,[r])}}}}function V(e,t){e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||e.navigator.mediaDevices&&(e.navigator.mediaDevices.getDisplayMedia=function(r){if(!r||!r.video){const e=new DOMException("getDisplayMedia without video constraints is undefined");return e.name="NotFoundError",e.code=8,Promise.reject(e)}return!0===r.video?r.video={mediaSource:t}:r.video.mediaSource=t,e.navigator.mediaDevices.getUserMedia(r)})}function B(e){"object"==typeof e&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&Object.defineProperty(e.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function F(e){const t=v(e);if("object"!=typeof e||!e.RTCPeerConnection&&!e.mozRTCPeerConnection)return;if(!e.RTCPeerConnection&&e.mozRTCPeerConnection&&(e.RTCPeerConnection=e.mozRTCPeerConnection),t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach((function(t){const r=e.RTCPeerConnection.prototype[t],n={[t](){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),r.apply(this,arguments)}};e.RTCPeerConnection.prototype[t]=n[t]})),t.version<68){const t=e.RTCPeerConnection.prototype.addIceCandidate;e.RTCPeerConnection.prototype.addIceCandidate=function(){return arguments[0]?arguments[0]&&""===arguments[0].candidate?Promise.resolve():t.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())}}const r={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"},n=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){const[e,i,o]=arguments;return n.apply(this,[e||null]).then(e=>{if(t.version<53&&!i)try{e.forEach(e=>{e.type=r[e.type]||e.type})}catch(t){if("TypeError"!==t.name)throw t;e.forEach((t,n)=>{e.set(n,Object.assign({},t,{type:r[t.type]||t.type}))})}return e}).then(i,o)}}function H(e){if("object"!=typeof e||!e.RTCPeerConnection||!e.RTCRtpSender)return;if(e.RTCRtpSender&&"getStats"in e.RTCRtpSender.prototype)return;const t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){const e=t.apply(this,[]);return e.forEach(e=>e._pc=this),e});const r=e.RTCPeerConnection.prototype.addTrack;r&&(e.RTCPeerConnection.prototype.addTrack=function(){const e=r.apply(this,arguments);return e._pc=this,e}),e.RTCRtpSender.prototype.getStats=function(){return this.track?this._pc.getStats(this.track):Promise.resolve(new Map)}}function Y(e){if("object"!=typeof e||!e.RTCPeerConnection||!e.RTCRtpSender)return;if(e.RTCRtpSender&&"getStats"in e.RTCRtpReceiver.prototype)return;const t=e.RTCPeerConnection.prototype.getReceivers;t&&(e.RTCPeerConnection.prototype.getReceivers=function(){const e=t.apply(this,[]);return e.forEach(e=>e._pc=this),e}),f(e,"track",e=>(e.receiver._pc=e.srcElement,e)),e.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}function G(e){!e.RTCPeerConnection||"removeStream"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.removeStream=function(e){h("removeStream","removeTrack"),this.getSenders().forEach(t=>{t.track&&e.getTracks().includes(t.track)&&this.removeTrack(t)})})}function W(e){e.DataChannel&&!e.RTCDataChannel&&(e.RTCDataChannel=e.DataChannel)}function X(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype.addTransceiver;t&&(e.RTCPeerConnection.prototype.addTransceiver=function(){this.setParametersPromises=[];const e=arguments[1],r=e&&"sendEncodings"in e;r&&e.sendEncodings.forEach(e=>{if("rid"in e){if(!/^[a-z0-9]{0,16}$/i.test(e.rid))throw new TypeError("Invalid RID value provided.")}if("scaleResolutionDownBy"in e&&!(parseFloat(e.scaleResolutionDownBy)>=1))throw new RangeError("scale_resolution_down_by must be >= 1.0");if("maxFramerate"in e&&!(parseFloat(e.maxFramerate)>=0))throw new RangeError("max_framerate must be >= 0.0")});const n=t.apply(this,arguments);if(r){const{sender:t}=n,r=t.getParameters();"encodings"in r&&(1!==r.encodings.length||0!==Object.keys(r.encodings[0]).length)||(r.encodings=e.sendEncodings,t.sendEncodings=e.sendEncodings,this.setParametersPromises.push(t.setParameters(r).then(()=>{delete t.sendEncodings}).catch(()=>{delete t.sendEncodings})))}return n})}function J(e){if("object"!=typeof e||!e.RTCRtpSender)return;const t=e.RTCRtpSender.prototype.getParameters;t&&(e.RTCRtpSender.prototype.getParameters=function(){const e=t.apply(this,arguments);return"encodings"in e||(e.encodings=[].concat(this.sendEncodings||[{}])),e})}function q(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(()=>t.apply(this,arguments)).finally(()=>{this.setParametersPromises=[]}):t.apply(this,arguments)}}function K(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype.createAnswer;e.RTCPeerConnection.prototype.createAnswer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(()=>t.apply(this,arguments)).finally(()=>{this.setParametersPromises=[]}):t.apply(this,arguments)}}function z(e){if("object"==typeof e&&e.RTCPeerConnection){if("getLocalStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getLocalStreams=function(){return this._localStreams||(this._localStreams=[]),this._localStreams}),!("addStream"in e.RTCPeerConnection.prototype)){const t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addStream=function(e){this._localStreams||(this._localStreams=[]),this._localStreams.includes(e)||this._localStreams.push(e),e.getAudioTracks().forEach(r=>t.call(this,r,e)),e.getVideoTracks().forEach(r=>t.call(this,r,e))},e.RTCPeerConnection.prototype.addTrack=function(e,...r){return r&&r.forEach(e=>{this._localStreams?this._localStreams.includes(e)||this._localStreams.push(e):this._localStreams=[e]}),t.apply(this,arguments)}}"removeStream"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.removeStream=function(e){this._localStreams||(this._localStreams=[]);const t=this._localStreams.indexOf(e);if(-1===t)return;this._localStreams.splice(t,1);const r=e.getTracks();this.getSenders().forEach(e=>{r.includes(e.track)&&this.removeTrack(e)})})}}function Q(e){if("object"==typeof e&&e.RTCPeerConnection&&("getRemoteStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getRemoteStreams=function(){return this._remoteStreams?this._remoteStreams:[]}),!("onaddstream"in e.RTCPeerConnection.prototype))){Object.defineProperty(e.RTCPeerConnection.prototype,"onaddstream",{get(){return this._onaddstream},set(e){this._onaddstream&&(this.removeEventListener("addstream",this._onaddstream),this.removeEventListener("track",this._onaddstreampoly)),this.addEventListener("addstream",this._onaddstream=e),this.addEventListener("track",this._onaddstreampoly=e=>{e.streams.forEach(e=>{if(this._remoteStreams||(this._remoteStreams=[]),this._remoteStreams.includes(e))return;this._remoteStreams.push(e);const t=new Event("addstream");t.stream=e,this.dispatchEvent(t)})})}});const t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){const e=this;return this._onaddstreampoly||this.addEventListener("track",this._onaddstreampoly=function(t){t.streams.forEach(t=>{if(e._remoteStreams||(e._remoteStreams=[]),e._remoteStreams.indexOf(t)>=0)return;e._remoteStreams.push(t);const r=new Event("addstream");r.stream=t,e.dispatchEvent(r)})}),t.apply(e,arguments)}}}function $(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype,r=t.createOffer,n=t.createAnswer,i=t.setLocalDescription,o=t.setRemoteDescription,a=t.addIceCandidate;t.createOffer=function(e,t){const n=arguments.length>=2?arguments[2]:arguments[0],i=r.apply(this,[n]);return t?(i.then(e,t),Promise.resolve()):i},t.createAnswer=function(e,t){const r=arguments.length>=2?arguments[2]:arguments[0],i=n.apply(this,[r]);return t?(i.then(e,t),Promise.resolve()):i};let s=function(e,t,r){const n=i.apply(this,[e]);return r?(n.then(t,r),Promise.resolve()):n};t.setLocalDescription=s,s=function(e,t,r){const n=o.apply(this,[e]);return r?(n.then(t,r),Promise.resolve()):n},t.setRemoteDescription=s,s=function(e,t,r){const n=a.apply(this,[e]);return r?(n.then(t,r),Promise.resolve()):n},t.addIceCandidate=s}function Z(e){const t=e&&e.navigator;if(t.mediaDevices&&t.mediaDevices.getUserMedia){const e=t.mediaDevices,r=e.getUserMedia.bind(e);t.mediaDevices.getUserMedia=e=>r(ee(e))}!t.getUserMedia&&t.mediaDevices&&t.mediaDevices.getUserMedia&&(t.getUserMedia=function(e,r,n){t.mediaDevices.getUserMedia(e).then(r,n)}.bind(t))}function ee(e){return e&&void 0!==e.video?Object.assign({},e,{video:y(e.video)}):e}function te(e){if(!e.RTCPeerConnection)return;const t=e.RTCPeerConnection;e.RTCPeerConnection=function(e,r){if(e&&e.iceServers){const t=[];for(let r=0;rt.generateCertificate})}function re(e){"object"==typeof e&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&Object.defineProperty(e.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function ne(e){const t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(e){if(e){void 0!==e.offerToReceiveAudio&&(e.offerToReceiveAudio=!!e.offerToReceiveAudio);const t=this.getTransceivers().find(e=>"audio"===e.receiver.track.kind);!1===e.offerToReceiveAudio&&t?"sendrecv"===t.direction?t.setDirection?t.setDirection("sendonly"):t.direction="sendonly":"recvonly"===t.direction&&(t.setDirection?t.setDirection("inactive"):t.direction="inactive"):!0!==e.offerToReceiveAudio||t||this.addTransceiver("audio"),void 0!==e.offerToReceiveVideo&&(e.offerToReceiveVideo=!!e.offerToReceiveVideo);const r=this.getTransceivers().find(e=>"video"===e.receiver.track.kind);!1===e.offerToReceiveVideo&&r?"sendrecv"===r.direction?r.setDirection?r.setDirection("sendonly"):r.direction="sendonly":"recvonly"===r.direction&&(r.setDirection?r.setDirection("inactive"):r.direction="inactive"):!0!==e.offerToReceiveVideo||r||this.addTransceiver("video")}return t.apply(this,arguments)}}function ie(e){"object"!=typeof e||e.AudioContext||(e.AudioContext=e.webkitAudioContext)}var oe=r(7),ae=r.n(oe);function se(e){if(!e.RTCIceCandidate||e.RTCIceCandidate&&"foundation"in e.RTCIceCandidate.prototype)return;const t=e.RTCIceCandidate;e.RTCIceCandidate=function(e){if("object"==typeof e&&e.candidate&&0===e.candidate.indexOf("a=")&&((e=JSON.parse(JSON.stringify(e))).candidate=e.candidate.substr(2)),e.candidate&&e.candidate.length){const r=new t(e),n=ae.a.parseCandidate(e.candidate),i=Object.assign(r,n);return i.toJSON=function(){return{candidate:i.candidate,sdpMid:i.sdpMid,sdpMLineIndex:i.sdpMLineIndex,usernameFragment:i.usernameFragment}},i}return new t(e)},e.RTCIceCandidate.prototype=t.prototype,f(e,"icecandidate",t=>(t.candidate&&Object.defineProperty(t,"candidate",{value:new e.RTCIceCandidate(t.candidate),writable:"false"}),t))}function ce(e){if(!e.RTCPeerConnection)return;const t=v(e);"sctp"in e.RTCPeerConnection.prototype||Object.defineProperty(e.RTCPeerConnection.prototype,"sctp",{get(){return void 0===this._sctp?null:this._sctp}});const r=function(e){if(!e||!e.sdp)return!1;const t=ae.a.splitSections(e.sdp);return t.shift(),t.some(e=>{const t=ae.a.parseMLine(e);return t&&"application"===t.kind&&-1!==t.protocol.indexOf("SCTP")})},n=function(e){const t=e.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);if(null===t||t.length<2)return-1;const r=parseInt(t[1],10);return r!=r?-1:r},i=function(e){let r=65536;return"firefox"===t.browser&&(r=t.version<57?-1===e?16384:2147483637:t.version<60?57===t.version?65535:65536:2147483637),r},o=function(e,r){let n=65536;"firefox"===t.browser&&57===t.version&&(n=65535);const i=ae.a.matchPrefix(e.sdp,"a=max-message-size:");return i.length>0?n=parseInt(i[0].substr(19),10):"firefox"===t.browser&&-1!==r&&(n=2147483637),n},a=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){if(this._sctp=null,"chrome"===t.browser&&t.version>=76){const{sdpSemantics:e}=this.getConfiguration();"plan-b"===e&&Object.defineProperty(this,"sctp",{get(){return void 0===this._sctp?null:this._sctp},enumerable:!0,configurable:!0})}if(r(arguments[0])){const e=n(arguments[0]),t=i(e),r=o(arguments[0],e);let a;a=0===t&&0===r?Number.POSITIVE_INFINITY:0===t||0===r?Math.max(t,r):Math.min(t,r);const s={};Object.defineProperty(s,"maxMessageSize",{get:()=>a}),this._sctp=s}return a.apply(this,arguments)}}function ue(e){if(!(e.RTCPeerConnection&&"createDataChannel"in e.RTCPeerConnection.prototype))return;function t(e,t){const r=e.send;e.send=function(){const n=arguments[0],i=n.length||n.size||n.byteLength;if("open"===e.readyState&&t.sctp&&i>t.sctp.maxMessageSize)throw new TypeError("Message too large (can send a maximum of "+t.sctp.maxMessageSize+" bytes)");return r.apply(e,arguments)}}const r=e.RTCPeerConnection.prototype.createDataChannel;e.RTCPeerConnection.prototype.createDataChannel=function(){const e=r.apply(this,arguments);return t(e,this),e},f(e,"datachannel",e=>(t(e.channel,e.target),e))}function de(e){if(!e.RTCPeerConnection||"connectionState"in e.RTCPeerConnection.prototype)return;const t=e.RTCPeerConnection.prototype;Object.defineProperty(t,"connectionState",{get(){return{completed:"connected",checking:"connecting"}[this.iceConnectionState]||this.iceConnectionState},enumerable:!0,configurable:!0}),Object.defineProperty(t,"onconnectionstatechange",{get(){return this._onconnectionstatechange||null},set(e){this._onconnectionstatechange&&(this.removeEventListener("connectionstatechange",this._onconnectionstatechange),delete this._onconnectionstatechange),e&&this.addEventListener("connectionstatechange",this._onconnectionstatechange=e)},enumerable:!0,configurable:!0}),["setLocalDescription","setRemoteDescription"].forEach(e=>{const r=t[e];t[e]=function(){return this._connectionstatechangepoly||(this._connectionstatechangepoly=e=>{const t=e.target;if(t._lastConnectionState!==t.connectionState){t._lastConnectionState=t.connectionState;const r=new Event("connectionstatechange",e);t.dispatchEvent(r)}return e},this.addEventListener("iceconnectionstatechange",this._connectionstatechangepoly)),r.apply(this,arguments)}})}function fe(e){if(!e.RTCPeerConnection)return;const t=v(e);if("chrome"===t.browser&&t.version>=71)return;if("safari"===t.browser&&t.version>=605)return;const r=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(e){return e&&e.sdp&&-1!==e.sdp.indexOf("\na=extmap-allow-mixed")&&(e.sdp=e.sdp.split("\n").filter(e=>"a=extmap-allow-mixed"!==e.trim()).join("\n")),r.apply(this,arguments)}}const pe=function({window:e}={},t={shimChrome:!0,shimFirefox:!0,shimEdge:!0,shimSafari:!0}){const r=m,c=v(e),u={browserDetails:c,commonShim:s,extractVersion:d,disableLog:p,disableWarnings:l};switch(c.browser){case"chrome":if(!n||!I||!t.shimChrome)return r("Chrome shim is not included in this adapter release."),u;if(null===c.version)return r("Chrome shim can not determine version, not shimming."),u;r("adapter.js shimming chrome."),u.browserShim=n,_(e),T(e),I(e),w(e),O(e),R(e),M(e),C(e),A(e),se(e),de(e),ce(e),ue(e),fe(e);break;case"firefox":if(!o||!F||!t.shimFirefox)return r("Firefox shim is not included in this adapter release."),u;r("adapter.js shimming firefox."),u.browserShim=o,D(e),F(e),B(e),G(e),H(e),Y(e),W(e),X(e),J(e),q(e),K(e),se(e),de(e),ce(e),ue(e);break;case"edge":if(!i||!x||!t.shimEdge)return r("MS edge shim is not included in this adapter release."),u;r("adapter.js shimming edge."),u.browserShim=i,U(e),L(e),x(e),j(e),ce(e),ue(e);break;case"safari":if(!a||!t.shimSafari)return r("Safari shim is not included in this adapter release."),u;r("adapter.js shimming safari."),u.browserShim=a,te(e),ne(e),$(e),z(e),Q(e),re(e),Z(e),ie(e),se(e),ce(e),ue(e),fe(e);break;default:r("Unsupported browser!")}return u}({window:"undefined"==typeof window?void 0:window});t.default=pe},function(e,t,r){"use strict";var n;r.r(t);var i=new Uint8Array(16);function o(){if(!n&&!(n="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return n(i)}var a=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;for(var s=function(e){return"string"==typeof e&&a.test(e)},c=[],u=0;u<256;++u)c.push((u+256).toString(16).substr(1));var d,f,p=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=(c[e[t+0]]+c[e[t+1]]+c[e[t+2]]+c[e[t+3]]+"-"+c[e[t+4]]+c[e[t+5]]+"-"+c[e[t+6]]+c[e[t+7]]+"-"+c[e[t+8]]+c[e[t+9]]+"-"+c[e[t+10]]+c[e[t+11]]+c[e[t+12]]+c[e[t+13]]+c[e[t+14]]+c[e[t+15]]).toLowerCase();if(!s(r))throw TypeError("Stringified UUID is invalid");return r},l=0,m=0;var h=function(e,t,r){var n=t&&r||0,i=t||new Array(16),a=(e=e||{}).node||d,s=void 0!==e.clockseq?e.clockseq:f;if(null==a||null==s){var c=e.random||(e.rng||o)();null==a&&(a=d=[1|c[0],c[1],c[2],c[3],c[4],c[5]]),null==s&&(s=f=16383&(c[6]<<8|c[7]))}var u=void 0!==e.msecs?e.msecs:Date.now(),h=void 0!==e.nsecs?e.nsecs:m+1,v=u-l+(h-m)/1e4;if(v<0&&void 0===e.clockseq&&(s=s+1&16383),(v<0||u>l)&&void 0===e.nsecs&&(h=0),h>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");l=u,m=h,f=s;var g=(1e4*(268435455&(u+=122192928e5))+h)%4294967296;i[n++]=g>>>24&255,i[n++]=g>>>16&255,i[n++]=g>>>8&255,i[n++]=255&g;var y=u/4294967296*1e4&268435455;i[n++]=y>>>8&255,i[n++]=255&y,i[n++]=y>>>24&15|16,i[n++]=y>>>16&255,i[n++]=s>>>8|128,i[n++]=255&s;for(var E=0;E<6;++E)i[n+E]=a[E];return t||p(i)};var v=function(e){if(!s(e))throw TypeError("Invalid UUID");var t,r=new Uint8Array(16);return r[0]=(t=parseInt(e.slice(0,8),16))>>>24,r[1]=t>>>16&255,r[2]=t>>>8&255,r[3]=255&t,r[4]=(t=parseInt(e.slice(9,13),16))>>>8,r[5]=255&t,r[6]=(t=parseInt(e.slice(14,18),16))>>>8,r[7]=255&t,r[8]=(t=parseInt(e.slice(19,23),16))>>>8,r[9]=255&t,r[10]=(t=parseInt(e.slice(24,36),16))/1099511627776&255,r[11]=t/4294967296&255,r[12]=t>>>24&255,r[13]=t>>>16&255,r[14]=t>>>8&255,r[15]=255&t,r};var g=function(e,t,r){function n(e,n,i,o){if("string"==typeof e&&(e=function(e){e=unescape(encodeURIComponent(e));for(var t=[],r=0;r>>9<<4)+1}function E(e,t){var r=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(r>>16)<<16|65535&r}function b(e,t,r,n,i,o){return E((a=E(E(t,e),E(n,o)))<<(s=i)|a>>>32-s,r);var a,s}function _(e,t,r,n,i,o,a){return b(t&r|~t&n,e,t,i,o,a)}function S(e,t,r,n,i,o,a){return b(t&n|r&~n,e,t,i,o,a)}function T(e,t,r,n,i,o,a){return b(t^r^n,e,t,i,o,a)}function w(e,t,r,n,i,o,a){return b(r^(t|~n),e,t,i,o,a)}var R=g("v3",48,(function(e){if("string"==typeof e){var t=unescape(encodeURIComponent(e));e=new Uint8Array(t.length);for(var r=0;r>5]>>>n%32&255,o=parseInt("0123456789abcdef".charAt(i>>>4&15)+"0123456789abcdef".charAt(15&i),16);t.push(o)}return t}(function(e,t){e[t>>5]|=128<>5]|=(255&e[n/8])<>>32-t}var O=g("v5",80,(function(e){var t=[1518500249,1859775393,2400959708,3395469782],r=[1732584193,4023233417,2562383102,271733878,3285377520];if("string"==typeof e){var n=unescape(encodeURIComponent(e));e=[];for(var i=0;i>>0;E=y,y=g,g=P(v,30)>>>0,v=h,h=S}r[0]=r[0]+h>>>0,r[1]=r[1]+v>>>0,r[2]=r[2]+g>>>0,r[3]=r[3]+y>>>0,r[4]=r[4]+E>>>0}return[r[0]>>24&255,r[0]>>16&255,r[0]>>8&255,255&r[0],r[1]>>24&255,r[1]>>16&255,r[1]>>8&255,255&r[1],r[2]>>24&255,r[2]>>16&255,r[2]>>8&255,255&r[2],r[3]>>24&255,r[3]>>16&255,r[3]>>8&255,255&r[3],r[4]>>24&255,r[4]>>16&255,r[4]>>8&255,255&r[4]]}));var I=function(e){if(!s(e))throw TypeError("Invalid UUID");return parseInt(e.substr(14,1),16)};r.d(t,"v1",(function(){return h})),r.d(t,"v3",(function(){return R})),r.d(t,"v4",(function(){return M})),r.d(t,"v5",(function(){return O})),r.d(t,"NIL",(function(){return"00000000-0000-0000-0000-000000000000"})),r.d(t,"version",(function(){return I})),r.d(t,"validate",(function(){return s})),r.d(t,"stringify",(function(){return p})),r.d(t,"parse",(function(){return v}))}])})); \ No newline at end of file diff --git a/package.json b/package.json index 478310b..7775161 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "urtc-sdk", - "version": "1.6.28", + "version": "1.6.29", "description": "UCloud RTC javascript SDK", "main": "lib/index.js", "types": "lib/index.d.ts",