dingrtc 3.6.2-fix.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).DingRTC={})}(this,(function(exports){"use strict";function _mergeNamespaces(e,t){return t.forEach((function(t){t&&"string"!=typeof t&&!Array.isArray(t)&&Object.keys(t).forEach((function(r){if("default"!==r&&!(r in e)){var n=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,n.get?n:{enumerable:!0,get:function(){return t[r]}})}}))})),Object.freeze(e)}function asyncGeneratorStep$1(e,t,r,n,i,o,a){try{var s=e[o](a),c=s.value}catch(e){return void r(e)}s.done?t(c):Promise.resolve(c).then(n,i)}function _asyncToGenerator$1(e){return function(){var t=this,r=arguments;return new Promise((function(n,i){var o=e.apply(t,r);function a(e){asyncGeneratorStep$1(o,n,i,a,s,"next",e)}function s(e){asyncGeneratorStep$1(o,n,i,a,s,"throw",e)}a(void 0)}))}}function _classCallCheck$1(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _typeof$3(e){return _typeof$3="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_typeof$3(e)}function toPrimitive$1(e,t){if("object"!=_typeof$3(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=_typeof$3(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}function toPropertyKey$1(e){var t=toPrimitive$1(e,"string");return"symbol"==_typeof$3(t)?t:t+""}function _defineProperties$1(e,t){for(var r=0;t.length>r;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,toPropertyKey$1(n.key),n)}}function _createClass$1(e,t,r){return t&&_defineProperties$1(e.prototype,t),r&&_defineProperties$1(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function _assertThisInitialized$1(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _possibleConstructorReturn$1(e,t){if(t&&("object"==_typeof$3(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized$1(e)}function _getPrototypeOf$1(e){return _getPrototypeOf$1=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},_getPrototypeOf$1(e)}function _setPrototypeOf$1(e,t){return _setPrototypeOf$1=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},_setPrototypeOf$1(e,t)}function _inherits$1(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&_setPrototypeOf$1(e,t)}function getDefaultExportFromCjs$1(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var regeneratorRuntime$2={exports:{}},_typeof$2={exports:{}};!function(e){function t(r){return e.exports=t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.__esModule=!0,e.exports.default=e.exports,t(r)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports}(_typeof$2);var _typeofExports$1=_typeof$2.exports;!function(e){var t=_typeofExports$1.default;function r(){e.exports=r=function(){return i},e.exports.__esModule=!0,e.exports.default=e.exports;var n,i={},o=Object.prototype,a=o.hasOwnProperty,s=Object.defineProperty||function(e,t,r){e[t]=r.value},c="function"==typeof Symbol?Symbol:{},u=c.iterator||"@@iterator",l=c.asyncIterator||"@@asyncIterator",d=c.toStringTag||"@@toStringTag";function p(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{p({},"")}catch(n){p=function(e,t,r){return e[t]=r}}function f(e,t,r,n){var i=Object.create((t&&t.prototype instanceof b?t:b).prototype),o=new N(n||[]);return s(i,"_invoke",{value:w(e,r,o)}),i}function h(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}i.wrap=f;var m="suspendedStart",g="suspendedYield",y="executing",v="completed",_={};function b(){}function E(){}function S(){}var T={};p(T,u,(function(){return this}));var R=Object.getPrototypeOf,O=R&&R(R(D([])));O&&O!==o&&a.call(O,u)&&(T=O);var C=S.prototype=b.prototype=Object.create(T);function k(e){["next","throw","return"].forEach((function(t){p(e,t,(function(e){return this._invoke(t,e)}))}))}function I(e,r){function n(i,o,s,c){var u=h(e[i],e,o);if("throw"!==u.type){var l=u.arg,d=l.value;return d&&"object"==t(d)&&a.call(d,"__await")?r.resolve(d.__await).then((function(e){n("next",e,s,c)}),(function(e){n("throw",e,s,c)})):r.resolve(d).then((function(e){l.value=e,s(l)}),(function(e){return n("throw",e,s,c)}))}c(u.arg)}var i;s(this,"_invoke",{value:function(e,t){function o(){return new r((function(r,i){n(e,t,r,i)}))}return i=i?i.then(o,o):o()}})}function w(e,t,r){var i=m;return function(o,a){if(i===y)throw Error("Generator is already running");if(i===v){if("throw"===o)throw a;return{value:n,done:!0}}for(r.method=o,r.arg=a;;){var s=r.delegate;if(s){var c=P(s,r);if(c){if(c===_)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(i===m)throw i=v,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);i=y;var u=h(e,t,r);if("normal"===u.type){if(i=r.done?v:g,u.arg===_)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(i=v,r.method="throw",r.arg=u.arg)}}}function P(e,t){var r=t.method,i=e.iterator[r];if(i===n)return t.delegate=null,"throw"===r&&e.iterator.return&&(t.method="return",t.arg=n,P(e,t),"throw"===t.method)||"return"!==r&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+r+"' method")),_;var o=h(i,e.iterator,t.arg);if("throw"===o.type)return t.method="throw",t.arg=o.arg,t.delegate=null,_;var a=o.arg;return a?a.done?(t[e.resultName]=a.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=n),t.delegate=null,_):a:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,_)}function A(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function M(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function N(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(A,this),this.reset(!0)}function D(e){if(e||""===e){var r=e[u];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,o=function t(){for(;++i<e.length;)if(a.call(e,i))return t.value=e[i],t.done=!1,t;return t.value=n,t.done=!0,t};return o.next=o}}throw new TypeError(t(e)+" is not iterable")}return E.prototype=S,s(C,"constructor",{value:S,configurable:!0}),s(S,"constructor",{value:E,configurable:!0}),E.displayName=p(S,d,"GeneratorFunction"),i.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===E||"GeneratorFunction"===(t.displayName||t.name))},i.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,S):(e.__proto__=S,p(e,d,"GeneratorFunction")),e.prototype=Object.create(C),e},i.awrap=function(e){return{__await:e}},k(I.prototype),p(I.prototype,l,(function(){return this})),i.AsyncIterator=I,i.async=function(e,t,r,n,o){void 0===o&&(o=Promise);var a=new I(f(e,t,r,n),o);return i.isGeneratorFunction(t)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},k(C),p(C,d,"Generator"),p(C,u,(function(){return this})),p(C,"toString",(function(){return"[object Generator]"})),i.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},i.values=D,N.prototype={constructor:N,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=n,this.done=!1,this.delegate=null,this.method="next",this.arg=n,this.tryEntries.forEach(M),!e)for(var t in this)"t"===t.charAt(0)&&a.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=n)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(r,i){return s.type="throw",s.arg=e,t.next=r,i&&(t.method="next",t.arg=n),!!i}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],s=o.completion;if("root"===o.tryLoc)return r("end");if(this.prev>=o.tryLoc){var c=a.call(o,"catchLoc"),u=a.call(o,"finallyLoc");if(c&&u){if(o.catchLoc>this.prev)return r(o.catchLoc,!0);if(o.finallyLoc>this.prev)return r(o.finallyLoc)}else if(c){if(o.catchLoc>this.prev)return r(o.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(o.finallyLoc>this.prev)return r(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(this.prev>=n.tryLoc&&a.call(n,"finallyLoc")&&n.finallyLoc>this.prev){var i=n;break}}i&&("break"===e||"continue"===e)&&t>=i.tryLoc&&i.finallyLoc>=t&&(i=null);var o=i?i.completion:{};return o.type=e,o.arg=t,i?(this.method="next",this.next=i.finallyLoc,_):this.complete(o)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),_},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),M(r),_}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;M(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:D(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=n),_}},i}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports}(regeneratorRuntime$2);var regeneratorRuntimeExports$1=regeneratorRuntime$2.exports,runtime$1=regeneratorRuntimeExports$1(),regenerator$1=runtime$1;try{regeneratorRuntime=runtime$1}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=runtime$1:Function("r","regeneratorRuntime = r")(runtime$1)}var _regeneratorRuntime$1=getDefaultExportFromCjs$1(regenerator$1);let logDisabled_=!0,deprecationWarnings_=!0;function extractVersion(e,t,r){const n=e.match(t);return n&&n.length>=r&&parseInt(n[r],10)}function wrapPeerConnectionEvent(e,t,r){if(!e.RTCPeerConnection)return;const n=e.RTCPeerConnection.prototype,i=n.addEventListener;n.addEventListener=function(e,n){if(e!==t)return i.apply(this,arguments);const o=e=>{const t=r(e);t&&(n.handleEvent?n.handleEvent(t):n(t))};return this._eventMap=this._eventMap||{},this._eventMap[t]||(this._eventMap[t]=new Map),this._eventMap[t].set(n,o),i.call(this,e,o)};const o=n.removeEventListener;n.removeEventListener=function(e,r){if(e!==t||!this._eventMap||!this._eventMap[t])return o.apply(this,arguments);if(!this._eventMap[t].has(r))return o.apply(this,arguments);const n=this._eventMap[t].get(r);return this._eventMap[t].delete(r),0===this._eventMap[t].size&&delete this._eventMap[t],0===Object.keys(this._eventMap).length&&delete this._eventMap,o.call(this,e,n)},Object.defineProperty(n,"on"+t,{get(){return this["_on"+t]},set(e){this["_on"+t]&&(this.removeEventListener(t,this["_on"+t]),delete this["_on"+t]),e&&this.addEventListener(t,this["_on"+t]=e)},enumerable:!0,configurable:!0})}function disableLog(e){return"boolean"!=typeof e?Error("Argument type: "+typeof e+". Please use a boolean."):(logDisabled_=e,e?"adapter.js logging disabled":"adapter.js logging enabled")}function disableWarnings(e){return"boolean"!=typeof e?Error("Argument type: "+typeof e+". Please use a boolean."):(deprecationWarnings_=!e,"adapter.js deprecation warnings "+(e?"disabled":"enabled"))}function log(){if("object"==typeof window){if(logDisabled_)return;void 0!==console&&"function"==typeof console.log&&console.log.apply(console,arguments)}}function deprecated(e,t){deprecationWarnings_&&console.warn(e+" is deprecated, please use "+t+" instead.")}function detectBrowser(e){const t={browser:null,version:null};if(void 0===e||!e.navigator||!e.navigator.userAgent)return t.browser="Not a browser.",t;const{navigator:r}=e;if(r.mozGetUserMedia)t.browser="firefox",t.version=extractVersion(r.userAgent,/Firefox\/(\d+)\./,1);else if(r.webkitGetUserMedia||!1===e.isSecureContext&&e.webkitRTCPeerConnection)t.browser="chrome",t.version=extractVersion(r.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else{if(!e.RTCPeerConnection||!r.userAgent.match(/AppleWebKit\/(\d+)\./))return t.browser="Not a supported browser.",t;t.browser="safari",t.version=extractVersion(r.userAgent,/AppleWebKit\/(\d+)\./,1),t.supportsUnifiedPlan=e.RTCRtpTransceiver&&"currentDirection"in e.RTCRtpTransceiver.prototype}return t}function isObject$1(e){return"[object Object]"===Object.prototype.toString.call(e)}function compactObject(e){return isObject$1(e)?Object.keys(e).reduce((function(t,r){const n=isObject$1(e[r]),i=n?compactObject(e[r]):e[r];return void 0===i||n&&!Object.keys(i).length?t:Object.assign(t,{[r]:i})}),{}):e}function walkStats(e,t,r){t&&!r.has(t.id)&&(r.set(t.id,t),Object.keys(t).forEach((n=>{n.endsWith("Id")?walkStats(e,e.get(t[n]),r):n.endsWith("Ids")&&t[n].forEach((t=>{walkStats(e,e.get(t),r)}))})))}function filterStats(e,t,r){const n=r?"outbound-rtp":"inbound-rtp",i=new Map;if(null===t)return i;const o=[];return e.forEach((e=>{"track"===e.type&&e.trackIdentifier===t.id&&o.push(e)})),o.forEach((t=>{e.forEach((r=>{r.type===n&&r.trackId===t.id&&walkStats(e,r,i)}))})),i}const logging=log;function shimGetUserMedia$2(e,t){const r=e&&e.navigator;if(!r.mediaDevices)return;const n=function(e){if("object"!=typeof e||e.mandatory||e.optional)return e;const t={};return Object.keys(e).forEach((r=>{if("require"===r||"advanced"===r||"mediaSource"===r)return;const n="object"==typeof e[r]?e[r]:{ideal:e[r]};void 0!==n.exact&&"number"==typeof n.exact&&(n.min=n.max=n.exact);const i=function(e,t){return e?e+t.charAt(0).toUpperCase()+t.slice(1):"deviceId"===t?"sourceId":t};if(void 0!==n.ideal){t.optional=t.optional||[];let e={};"number"==typeof n.ideal?(e[i("min",r)]=n.ideal,t.optional.push(e),e={},e[i("max",r)]=n.ideal,t.optional.push(e)):(e[i("",r)]=n.ideal,t.optional.push(e))}void 0!==n.exact&&"number"!=typeof n.exact?(t.mandatory=t.mandatory||{},t.mandatory[i("",r)]=n.exact):["min","max"].forEach((e=>{void 0!==n[e]&&(t.mandatory=t.mandatory||{},t.mandatory[i(e,r)]=n[e])}))})),e.advanced&&(t.optional=(t.optional||[]).concat(e.advanced)),t},i=function(e,i){if(t.version>=61)return i(e);if((e=JSON.parse(JSON.stringify(e)))&&"object"==typeof e.audio){const t=function(e,t,r){t in e&&!(r in e)&&(e[r]=e[t],delete e[t])};t((e=JSON.parse(JSON.stringify(e))).audio,"autoGainControl","googAutoGainControl"),t(e.audio,"noiseSuppression","googNoiseSuppression"),e.audio=n(e.audio)}if(e&&"object"==typeof e.video){let o=e.video.facingMode;o=o&&("object"==typeof o?o:{ideal:o});const a=66>t.version;if(o&&("user"===o.exact||"environment"===o.exact||"user"===o.ideal||"environment"===o.ideal)&&(!r.mediaDevices.getSupportedConstraints||!r.mediaDevices.getSupportedConstraints().facingMode||a)){let t;if(delete e.video.facingMode,"environment"===o.exact||"environment"===o.ideal?t=["back","rear"]:"user"!==o.exact&&"user"!==o.ideal||(t=["front"]),t)return r.mediaDevices.enumerateDevices().then((r=>{let a=(r=r.filter((e=>"videoinput"===e.kind))).find((e=>t.some((t=>e.label.toLowerCase().includes(t)))));return!a&&r.length&&t.includes("back")&&(a=r[r.length-1]),a&&(e.video.deviceId=o.exact?{exact:a.deviceId}:{ideal:a.deviceId}),e.video=n(e.video),logging("chrome: "+JSON.stringify(e)),i(e)}))}e.video=n(e.video)}return logging("chrome: "+JSON.stringify(e)),i(e)},o=function(e){return 64>t.version?{name:{PermissionDeniedError:"NotAllowedError",PermissionDismissedError:"NotAllowedError",InvalidStateError:"NotAllowedError",DevicesNotFoundError:"NotFoundError",ConstraintNotSatisfiedError:"OverconstrainedError",TrackStartError:"NotReadableError",MediaDeviceFailedDueToShutdown:"NotAllowedError",MediaDeviceKillSwitchOn:"NotAllowedError",TabCaptureError:"AbortError",ScreenCaptureError:"AbortError",DeviceCaptureError:"AbortError"}[e.name]||e.name,message:e.message,constraint:e.constraint||e.constraintName,toString(){return this.name+(this.message&&": ")+this.message}}:e};if(r.getUserMedia=function(e,t,n){i(e,(e=>{r.webkitGetUserMedia(e,t,(e=>{n&&n(o(e))}))}))}.bind(r),r.mediaDevices.getUserMedia){const e=r.mediaDevices.getUserMedia.bind(r.mediaDevices);r.mediaDevices.getUserMedia=function(t){return i(t,(t=>e(t).then((e=>{if(t.audio&&!e.getAudioTracks().length||t.video&&!e.getVideoTracks().length)throw e.getTracks().forEach((e=>{e.stop()})),new DOMException("","NotFoundError");return e}),(e=>Promise.reject(o(e))))))}}}function shimGetDisplayMedia$1(e,t){e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||e.navigator.mediaDevices&&("function"==typeof t?e.navigator.mediaDevices.getDisplayMedia=function(r){return t(r).then((t=>{const n=r.video&&r.video.width,i=r.video&&r.video.height;return r.video={mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:t,maxFrameRate:r.video&&r.video.frameRate||3}},n&&(r.video.mandatory.maxWidth=n),i&&(r.video.mandatory.maxHeight=i),e.navigator.mediaDevices.getUserMedia(r)}))}:console.error("shimGetDisplayMedia: getSourceId argument is not a function"))}function shimMediaStream(e){e.MediaStream=e.MediaStream||e.webkitMediaStream}function shimOnTrack$1(e){if("object"==typeof e&&e.RTCPeerConnection&&!("ontrack"in e.RTCPeerConnection.prototype)){Object.defineProperty(e.RTCPeerConnection.prototype,"ontrack",{get(){return this._ontrack},set(e){this._ontrack&&this.removeEventListener("track",this._ontrack),this.addEventListener("track",this._ontrack=e)},enumerable:!0,configurable:!0});const t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){return this._ontrackpoly||(this._ontrackpoly=t=>{t.stream.addEventListener("addtrack",(r=>{let n;n=e.RTCPeerConnection.prototype.getReceivers?this.getReceivers().find((e=>e.track&&e.track.id===r.track.id)):{track:r.track};const i=new Event("track");i.track=r.track,i.receiver=n,i.transceiver={receiver:n},i.streams=[t.stream],this.dispatchEvent(i)})),t.stream.getTracks().forEach((r=>{let n;n=e.RTCPeerConnection.prototype.getReceivers?this.getReceivers().find((e=>e.track&&e.track.id===r.id)):{track:r};const i=new Event("track");i.track=r,i.receiver=n,i.transceiver={receiver:n},i.streams=[t.stream],this.dispatchEvent(i)}))},this.addEventListener("addstream",this._ontrackpoly)),t.apply(this,arguments)}}else wrapPeerConnectionEvent(e,"track",(e=>(e.transceiver||Object.defineProperty(e,"transceiver",{value:{receiver:e.receiver}}),e)))}function shimGetSendersWithDtmf(e){if("object"==typeof e&&e.RTCPeerConnection&&!("getSenders"in e.RTCPeerConnection.prototype)&&"createDTMFSender"in e.RTCPeerConnection.prototype){const t=function(e,t){return{track:t,get dtmf(){return void 0===this._dtmf&&(this._dtmf="audio"===t.kind?e.createDTMFSender(t):null),this._dtmf},_pc:e}};if(!e.RTCPeerConnection.prototype.getSenders){e.RTCPeerConnection.prototype.getSenders=function(){return this._senders=this._senders||[],this._senders.slice()};const r=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,n){let i=r.apply(this,arguments);return i||(i=t(this,e),this._senders.push(i)),i};const n=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){n.apply(this,arguments);const t=this._senders.indexOf(e);-1!==t&&this._senders.splice(t,1)}}const r=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){this._senders=this._senders||[],r.call(this,e),e.getTracks().forEach((e=>{this._senders.push(t(this,e))}))};const n=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){this._senders=this._senders||[],n.call(this,e),e.getTracks().forEach((e=>{const t=this._senders.find((t=>t.track===e));t&&this._senders.splice(this._senders.indexOf(t),1)}))}}else if("object"==typeof e&&e.RTCPeerConnection&&"getSenders"in e.RTCPeerConnection.prototype&&"createDTMFSender"in e.RTCPeerConnection.prototype&&e.RTCRtpSender&&!("dtmf"in e.RTCRtpSender.prototype)){const t=e.RTCPeerConnection.prototype.getSenders;e.RTCPeerConnection.prototype.getSenders=function(){const e=t.call(this);return e.forEach((e=>e._pc=this)),e},Object.defineProperty(e.RTCRtpSender.prototype,"dtmf",{get(){return void 0===this._dtmf&&(this._dtmf="audio"===this.track.kind?this._pc.createDTMFSender(this.track):null),this._dtmf}})}}function shimGetStats(e){if(!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){const[e,r,n]=arguments;if(arguments.length>0&&"function"==typeof e)return t.apply(this,arguments);if(0===t.length&&(0===arguments.length||"function"!=typeof e))return t.call(this);const i=function(e){const t={};return e.result().forEach((e=>{const r={id:e.id,timestamp:e.timestamp,type:{localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[e.type]||e.type};e.names().forEach((t=>{r[t]=e.stat(t)})),t[r.id]=r})),t},o=function(e){return new Map(Object.keys(e).map((t=>[t,e[t]])))};if(arguments.length>=2){return t.call(this,(function(e){r(o(i(e)))}),e)}return new Promise(((e,r)=>{t.call(this,(function(t){e(o(i(t)))}),r)})).then(r,n)}}function shimSenderReceiverGetStats(e){if(!("object"==typeof e&&e.RTCPeerConnection&&e.RTCRtpSender&&e.RTCRtpReceiver))return;if(!("getStats"in e.RTCRtpSender.prototype)){const t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){const e=t.call(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(){const e=this;return this._pc.getStats().then((t=>filterStats(t,e.track,!0)))}}if(!("getStats"in e.RTCRtpReceiver.prototype)){const t=e.RTCPeerConnection.prototype.getReceivers;t&&(e.RTCPeerConnection.prototype.getReceivers=function(){const e=t.call(this);return e.forEach((e=>e._pc=this)),e}),wrapPeerConnectionEvent(e,"track",(e=>(e.receiver._pc=e.srcElement,e))),e.RTCRtpReceiver.prototype.getStats=function(){const e=this;return this._pc.getStats().then((t=>filterStats(t,e.track,!1)))}}if(!("getStats"in e.RTCRtpSender.prototype)||!("getStats"in e.RTCRtpReceiver.prototype))return;const t=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){if(arguments.length>0&&arguments[0]instanceof e.MediaStreamTrack){const e=arguments[0];let t,r,n;return this.getSenders().forEach((r=>{r.track===e&&(t?n=!0:t=r)})),this.getReceivers().forEach((t=>(t.track===e&&(r?n=!0:r=t),t.track===e))),n||t&&r?Promise.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):t?t.getStats():r?r.getStats():Promise.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return t.apply(this,arguments)}}function shimAddTrackRemoveTrackWithNative(e){e.RTCPeerConnection.prototype.getLocalStreams=function(){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},Object.keys(this._shimmedLocalStreams).map((e=>this._shimmedLocalStreams[e][0]))};const t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,r){if(!r)return t.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};const n=t.apply(this,arguments);return this._shimmedLocalStreams[r.id]?-1===this._shimmedLocalStreams[r.id].indexOf(n)&&this._shimmedLocalStreams[r.id].push(n):this._shimmedLocalStreams[r.id]=[r,n],n};const r=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){this._shimmedLocalStreams=this._shimmedLocalStreams||{},e.getTracks().forEach((e=>{if(this.getSenders().find((t=>t.track===e)))throw new DOMException("Track already exists.","InvalidAccessError")}));const t=this.getSenders();r.apply(this,arguments);const n=this.getSenders().filter((e=>-1===t.indexOf(e)));this._shimmedLocalStreams[e.id]=[e].concat(n)};const n=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},delete this._shimmedLocalStreams[e.id],n.apply(this,arguments)};const i=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},e&&Object.keys(this._shimmedLocalStreams).forEach((t=>{const r=this._shimmedLocalStreams[t].indexOf(e);-1!==r&&this._shimmedLocalStreams[t].splice(r,1),1===this._shimmedLocalStreams[t].length&&delete this._shimmedLocalStreams[t]})),i.apply(this,arguments)}}function shimAddTrackRemoveTrack(e,t){if(!e.RTCPeerConnection)return;if(e.RTCPeerConnection.prototype.addTrack&&t.version>=65)return shimAddTrackRemoveTrackWithNative(e);const r=e.RTCPeerConnection.prototype.getLocalStreams;e.RTCPeerConnection.prototype.getLocalStreams=function(){const e=r.apply(this);return this._reverseStreams=this._reverseStreams||{},e.map((e=>this._reverseStreams[e.id]))};const n=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(t){if(this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},t.getTracks().forEach((e=>{if(this.getSenders().find((t=>t.track===e)))throw new DOMException("Track already exists.","InvalidAccessError")})),!this._reverseStreams[t.id]){const r=new e.MediaStream(t.getTracks());this._streams[t.id]=r,this._reverseStreams[r.id]=t,t=r}n.call(this,t)};const i=e.RTCPeerConnection.prototype.removeStream;function o(e,t){let r=t.sdp;return Object.keys(e._reverseStreams||[]).forEach((t=>{const n=e._reverseStreams[t];r=r.replace(RegExp(e._streams[n.id].id,"g"),n.id)})),new RTCSessionDescription({type:t.type,sdp:r})}e.RTCPeerConnection.prototype.removeStream=function(e){this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},i.call(this,this._streams[e.id]||e),delete this._reverseStreams[this._streams[e.id]?this._streams[e.id].id:e.id],delete this._streams[e.id]},e.RTCPeerConnection.prototype.addTrack=function(t,r){if("closed"===this.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");const n=[].slice.call(arguments,1);if(1!==n.length||!n[0].getTracks().find((e=>e===t)))throw new DOMException("The adapter.js addTrack polyfill only supports a single stream which is associated with the specified track.","NotSupportedError");if(this.getSenders().find((e=>e.track===t)))throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};const i=this._streams[r.id];if(i)i.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.call(this,(t=>{const r=o(this,t);e[0].call(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 a=e.RTCPeerConnection.prototype.setLocalDescription;e.RTCPeerConnection.prototype.setLocalDescription=function(){return arguments.length&&arguments[0].type?(arguments[0]=function(e,t){let r=t.sdp;return Object.keys(e._reverseStreams||[]).forEach((t=>{const n=e._reverseStreams[t],i=e._streams[n.id];r=r.replace(RegExp(n.id,"g"),i.id)})),new RTCSessionDescription({type:t.type,sdp:r})}(this,arguments[0]),a.apply(this,arguments)):a.apply(this,arguments)};const s=Object.getOwnPropertyDescriptor(e.RTCPeerConnection.prototype,"localDescription");Object.defineProperty(e.RTCPeerConnection.prototype,"localDescription",{get(){const e=s.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 shimPeerConnection$1(e,t){!e.RTCPeerConnection&&e.webkitRTCPeerConnection&&(e.RTCPeerConnection=e.webkitRTCPeerConnection),e.RTCPeerConnection&&53>t.version&&["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]}))}function fixNegotiationNeeded(e,t){wrapPeerConnectionEvent(e,"negotiationneeded",(e=>{const r=e.target;if(!(72>t.version||r.getConfiguration&&"plan-b"===r.getConfiguration().sdpSemantics)||"stable"===r.signalingState)return e}))}var chromeShim=Object.freeze({__proto__:null,fixNegotiationNeeded:fixNegotiationNeeded,shimAddTrackRemoveTrack:shimAddTrackRemoveTrack,shimAddTrackRemoveTrackWithNative:shimAddTrackRemoveTrackWithNative,shimGetDisplayMedia:shimGetDisplayMedia$1,shimGetSendersWithDtmf:shimGetSendersWithDtmf,shimGetStats:shimGetStats,shimGetUserMedia:shimGetUserMedia$2,shimMediaStream:shimMediaStream,shimOnTrack:shimOnTrack$1,shimPeerConnection:shimPeerConnection$1,shimSenderReceiverGetStats:shimSenderReceiverGetStats});function shimGetUserMedia$1(e,t){const r=e&&e.navigator,n=e&&e.MediaStreamTrack;if(r.getUserMedia=function(e,t,n){deprecated("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),r.mediaDevices.getUserMedia(e).then(t,n)},55>=t.version||!("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.call(this,r)}}}}function shimGetDisplayMedia(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 shimOnTrack(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 shimPeerConnection(e,t){if("object"!=typeof e||!e.RTCPeerConnection&&!e.mozRTCPeerConnection)return;!e.RTCPeerConnection&&e.mozRTCPeerConnection&&(e.RTCPeerConnection=e.mozRTCPeerConnection),53>t.version&&["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 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.call(this,e||null).then((e=>{if(53>t.version&&!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 shimSenderGetStats(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.call(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 shimReceiverGetStats(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.call(this);return e.forEach((e=>e._pc=this)),e}),wrapPeerConnectionEvent(e,"track",(e=>(e.receiver._pc=e.srcElement,e))),e.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}function shimRemoveStream(e){e.RTCPeerConnection&&!("removeStream"in e.RTCPeerConnection.prototype)&&(e.RTCPeerConnection.prototype.removeStream=function(e){deprecated("removeStream","removeTrack"),this.getSenders().forEach((t=>{t.track&&e.getTracks().includes(t.track)&&this.removeTrack(t)}))})}function shimRTCDataChannel(e){e.DataChannel&&!e.RTCDataChannel&&(e.RTCDataChannel=e.DataChannel)}function shimAddTransceiver(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype.addTransceiver;t&&(e.RTCPeerConnection.prototype.addTransceiver=function(){this.setParametersPromises=[];let e=arguments[1]&&arguments[1].sendEncodings;void 0===e&&(e=[]),e=[...e];const r=e.length>0;r&&e.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,t.sendEncodings=e,this.setParametersPromises.push(t.setParameters(r).then((()=>{delete t.sendEncodings})).catch((()=>{delete t.sendEncodings}))))}return n})}function shimGetParameters(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 shimCreateOffer(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 shimCreateAnswer(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)}}var firefoxShim=Object.freeze({__proto__:null,shimAddTransceiver:shimAddTransceiver,shimCreateAnswer:shimCreateAnswer,shimCreateOffer:shimCreateOffer,shimGetDisplayMedia:shimGetDisplayMedia,shimGetParameters:shimGetParameters,shimGetUserMedia:shimGetUserMedia$1,shimOnTrack:shimOnTrack,shimPeerConnection:shimPeerConnection,shimRTCDataChannel:shimRTCDataChannel,shimReceiverGetStats:shimReceiverGetStats,shimRemoveStream:shimRemoveStream,shimSenderGetStats:shimSenderGetStats});function shimLocalStreamsAPI(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 shimRemoteStreamsAPI(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 shimCallbacksAPI(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=r.call(this,2>arguments.length?arguments[0]:arguments[2]);return t?(n.then(e,t),Promise.resolve()):n},t.createAnswer=function(e,t){const r=n.call(this,2>arguments.length?arguments[0]:arguments[2]);return t?(r.then(e,t),Promise.resolve()):r};let s=function(e,t,r){const n=i.call(this,e);return r?(n.then(t,r),Promise.resolve()):n};t.setLocalDescription=s,s=function(e,t,r){const n=o.call(this,e);return r?(n.then(t,r),Promise.resolve()):n},t.setRemoteDescription=s,s=function(e,t,r){const n=a.call(this,e);return r?(n.then(t,r),Promise.resolve()):n},t.addIceCandidate=s}function shimGetUserMedia(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(shimConstraints(e))}!t.getUserMedia&&t.mediaDevices&&t.mediaDevices.getUserMedia&&(t.getUserMedia=function(e,r,n){t.mediaDevices.getUserMedia(e).then(r,n)}.bind(t))}function shimConstraints(e){return e&&void 0!==e.video?Object.assign({},e,{video:compactObject(e.video)}):e}function shimRTCIceServerUrls(e){if(!e.RTCPeerConnection)return;const t=e.RTCPeerConnection;e.RTCPeerConnection=function(e,r){if(e&&e.iceServers){const t=[];for(let r=0;e.iceServers.length>r;r++){let n=e.iceServers[r];void 0===n.urls&&n.url?(deprecated("RTCIceServer.url","RTCIceServer.urls"),n=JSON.parse(JSON.stringify(n)),n.urls=n.url,delete n.url,t.push(n)):t.push(e.iceServers[r])}e.iceServers=t}return new t(e,r)},e.RTCPeerConnection.prototype=t.prototype,"generateCertificate"in t&&Object.defineProperty(e.RTCPeerConnection,"generateCertificate",{get:()=>t.generateCertificate})}function shimTrackEventTransceiver(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 shimCreateOfferLegacy(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",{direction:"recvonly"}),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",{direction:"recvonly"})}return t.apply(this,arguments)}}function shimAudioContext(e){"object"!=typeof e||e.AudioContext||(e.AudioContext=e.webkitAudioContext)}var safariShim=Object.freeze({__proto__:null,shimAudioContext:shimAudioContext,shimCallbacksAPI:shimCallbacksAPI,shimConstraints:shimConstraints,shimCreateOfferLegacy:shimCreateOfferLegacy,shimGetUserMedia:shimGetUserMedia,shimLocalStreamsAPI:shimLocalStreamsAPI,shimRTCIceServerUrls:shimRTCIceServerUrls,shimRemoteStreamsAPI:shimRemoteStreamsAPI,shimTrackEventTransceiver:shimTrackEventTransceiver}),sdp$1={exports:{}};!function(e){const t={generateIdentifier:function(){return Math.random().toString(36).substring(2,12)}};t.localCName=t.generateIdentifier(),t.splitLines=function(e){return e.trim().split("\n").map((e=>e.trim()))},t.splitSections=function(e){return e.split("\nm=").map(((e,t)=>(t>0?"m="+e:e).trim()+"\r\n"))},t.getDescription=function(e){const r=t.splitSections(e);return r&&r[0]},t.getMediaSections=function(e){const r=t.splitSections(e);return r.shift(),r},t.matchPrefix=function(e,r){return t.splitLines(e).filter((e=>0===e.indexOf(r)))},t.parseCandidate=function(e){let t;t=0===e.indexOf("a=candidate:")?e.substring(12).split(" "):e.substring(10).split(" ");const r={foundation:t[0],component:{1:"rtp",2:"rtcp"}[t[1]]||t[1],protocol:t[2].toLowerCase(),priority:parseInt(t[3],10),ip:t[4],address:t[4],port:parseInt(t[5],10),type:t[7]};for(let e=8;t.length>e;e+=2)switch(t[e]){case"raddr":r.relatedAddress=t[e+1];break;case"rport":r.relatedPort=parseInt(t[e+1],10);break;case"tcptype":r.tcpType=t[e+1];break;case"ufrag":r.ufrag=t[e+1],r.usernameFragment=t[e+1];break;default:void 0===r[t[e]]&&(r[t[e]]=t[e+1])}return r},t.writeCandidate=function(e){const t=[];t.push(e.foundation);const r=e.component;t.push("rtp"===r?1:"rtcp"===r?2:r),t.push(e.protocol.toUpperCase()),t.push(e.priority),t.push(e.address||e.ip),t.push(e.port);const n=e.type;return t.push("typ"),t.push(n),"host"!==n&&e.relatedAddress&&e.relatedPort&&(t.push("raddr"),t.push(e.relatedAddress),t.push("rport"),t.push(e.relatedPort)),e.tcpType&&"tcp"===e.protocol.toLowerCase()&&(t.push("tcptype"),t.push(e.tcpType)),(e.usernameFragment||e.ufrag)&&(t.push("ufrag"),t.push(e.usernameFragment||e.ufrag)),"candidate:"+t.join(" ")},t.parseIceOptions=function(e){return e.substring(14).split(" ")},t.parseRtpMap=function(e){let t=e.substring(9).split(" ");const r={payloadType:parseInt(t.shift(),10)};return t=t[0].split("/"),r.name=t[0],r.clockRate=parseInt(t[1],10),r.channels=3===t.length?parseInt(t[2],10):1,r.numChannels=r.channels,r},t.writeRtpMap=function(e){let t=e.payloadType;void 0!==e.preferredPayloadType&&(t=e.preferredPayloadType);const r=e.channels||e.numChannels||1;return"a=rtpmap:"+t+" "+e.name+"/"+e.clockRate+(1!==r?"/"+r:"")+"\r\n"},t.parseExtmap=function(e){const t=e.substring(9).split(" ");return{id:parseInt(t[0],10),direction:t[0].indexOf("/")>0?t[0].split("/")[1]:"sendrecv",uri:t[1],attributes:t.slice(2).join(" ")}},t.writeExtmap=function(e){return"a=extmap:"+(e.id||e.preferredId)+(e.direction&&"sendrecv"!==e.direction?"/"+e.direction:"")+" "+e.uri+(e.attributes?" "+e.attributes:"")+"\r\n"},t.parseFmtp=function(e){const t={};let r;const n=e.substring(e.indexOf(" ")+1).split(";");for(let e=0;n.length>e;e++)r=n[e].trim().split("="),t[r[0].trim()]=r[1];return t},t.writeFmtp=function(e){let t="",r=e.payloadType;if(void 0!==e.preferredPayloadType&&(r=e.preferredPayloadType),e.parameters&&Object.keys(e.parameters).length){const n=[];Object.keys(e.parameters).forEach((t=>{n.push(void 0!==e.parameters[t]?t+"="+e.parameters[t]:t)})),t+="a=fmtp:"+r+" "+n.join(";")+"\r\n"}return t},t.parseRtcpFb=function(e){const t=e.substring(e.indexOf(" ")+1).split(" ");return{type:t.shift(),parameter:t.join(" ")}},t.writeRtcpFb=function(e){let t="",r=e.payloadType;return void 0!==e.preferredPayloadType&&(r=e.preferredPayloadType),e.rtcpFeedback&&e.rtcpFeedback.length&&e.rtcpFeedback.forEach((e=>{t+="a=rtcp-fb:"+r+" "+e.type+(e.parameter&&e.parameter.length?" "+e.parameter:"")+"\r\n"})),t},t.parseSsrcMedia=function(e){const t=e.indexOf(" "),r={ssrc:parseInt(e.substring(7,t),10)},n=e.indexOf(":",t);return n>-1?(r.attribute=e.substring(t+1,n),r.value=e.substring(n+1)):r.attribute=e.substring(t+1),r},t.parseSsrcGroup=function(e){const t=e.substring(13).split(" ");return{semantics:t.shift(),ssrcs:t.map((e=>parseInt(e,10)))}},t.getMid=function(e){const r=t.matchPrefix(e,"a=mid:")[0];if(r)return r.substring(6)},t.parseFingerprint=function(e){const t=e.substring(14).split(" ");return{algorithm:t[0].toLowerCase(),value:t[1].toUpperCase()}},t.getDtlsParameters=function(e,r){return{role:"auto",fingerprints:t.matchPrefix(e+r,"a=fingerprint:").map(t.parseFingerprint)}},t.writeDtlsParameters=function(e,t){let r="a=setup:"+t+"\r\n";return e.fingerprints.forEach((e=>{r+="a=fingerprint:"+e.algorithm+" "+e.value+"\r\n"})),r},t.parseCryptoLine=function(e){const t=e.substring(9).split(" ");return{tag:parseInt(t[0],10),cryptoSuite:t[1],keyParams:t[2],sessionParams:t.slice(3)}},t.writeCryptoLine=function(e){return"a=crypto:"+e.tag+" "+e.cryptoSuite+" "+("object"==typeof e.keyParams?t.writeCryptoKeyParams(e.keyParams):e.keyParams)+(e.sessionParams?" "+e.sessionParams.join(" "):"")+"\r\n"},t.parseCryptoKeyParams=function(e){if(0!==e.indexOf("inline:"))return null;const t=e.substring(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}},t.writeCryptoKeyParams=function(e){return e.keyMethod+":"+e.keySalt+(e.lifeTime?"|"+e.lifeTime:"")+(e.mkiValue&&e.mkiLength?"|"+e.mkiValue+":"+e.mkiLength:"")},t.getCryptoParameters=function(e,r){return t.matchPrefix(e+r,"a=crypto:").map(t.parseCryptoLine)},t.getIceParameters=function(e,r){const n=t.matchPrefix(e+r,"a=ice-ufrag:")[0],i=t.matchPrefix(e+r,"a=ice-pwd:")[0];return n&&i?{usernameFragment:n.substring(12),password:i.substring(10)}:null},t.writeIceParameters=function(e){let t="a=ice-ufrag:"+e.usernameFragment+"\r\na=ice-pwd:"+e.password+"\r\n";return e.iceLite&&(t+="a=ice-lite\r\n"),t},t.parseRtpParameters=function(e){const r={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},n=t.splitLines(e)[0].split(" ");r.profile=n[2];for(let i=3;n.length>i;i++){const o=n[i],a=t.matchPrefix(e,"a=rtpmap:"+o+" ")[0];if(a){const n=t.parseRtpMap(a),i=t.matchPrefix(e,"a=fmtp:"+o+" ");switch(n.parameters=i.length?t.parseFmtp(i[0]):{},n.rtcpFeedback=t.matchPrefix(e,"a=rtcp-fb:"+o+" ").map(t.parseRtcpFb),r.codecs.push(n),n.name.toUpperCase()){case"RED":case"ULPFEC":r.fecMechanisms.push(n.name.toUpperCase())}}}t.matchPrefix(e,"a=extmap:").forEach((e=>{r.headerExtensions.push(t.parseExtmap(e))}));const i=t.matchPrefix(e,"a=rtcp-fb:* ").map(t.parseRtcpFb);return r.codecs.forEach((e=>{i.forEach((t=>{e.rtcpFeedback.find((e=>e.type===t.type&&e.parameter===t.parameter))||e.rtcpFeedback.push(t)}))})),r},t.writeRtpDescription=function(e,r){let n="";n+="m="+e+" ",n+=r.codecs.length>0?"9":"0",n+=" "+(r.profile||"UDP/TLS/RTP/SAVPF")+" ",n+=r.codecs.map((e=>void 0!==e.preferredPayloadType?e.preferredPayloadType:e.payloadType)).join(" ")+"\r\n",n+="c=IN IP4 0.0.0.0\r\n",n+="a=rtcp:9 IN IP4 0.0.0.0\r\n",r.codecs.forEach((e=>{n+=t.writeRtpMap(e),n+=t.writeFmtp(e),n+=t.writeRtcpFb(e)}));let i=0;return r.codecs.forEach((e=>{e.maxptime>i&&(i=e.maxptime)})),i>0&&(n+="a=maxptime:"+i+"\r\n"),r.headerExtensions&&r.headerExtensions.forEach((e=>{n+=t.writeExtmap(e)})),n},t.parseRtpEncodingParameters=function(e){const r=[],n=t.parseRtpParameters(e),i=-1!==n.fecMechanisms.indexOf("RED"),o=-1!==n.fecMechanisms.indexOf("ULPFEC"),a=t.matchPrefix(e,"a=ssrc:").map((e=>t.parseSsrcMedia(e))).filter((e=>"cname"===e.attribute)),s=a.length>0&&a[0].ssrc;let c;const u=t.matchPrefix(e,"a=ssrc-group:FID").map((e=>e.substring(17).split(" ").map((e=>parseInt(e,10)))));u.length>0&&u[0].length>1&&u[0][0]===s&&(c=u[0][1]),n.codecs.forEach((e=>{if("RTX"===e.name.toUpperCase()&&e.parameters.apt){let t={ssrc:s,codecPayloadType:parseInt(e.parameters.apt,10)};s&&c&&(t.rtx={ssrc:c}),r.push(t),i&&(t=JSON.parse(JSON.stringify(t)),t.fec={ssrc:s,mechanism:o?"red+ulpfec":"red"},r.push(t))}})),0===r.length&&s&&r.push({ssrc:s});let l=t.matchPrefix(e,"b=");return l.length&&(l=0===l[0].indexOf("b=TIAS:")?parseInt(l[0].substring(7),10):0===l[0].indexOf("b=AS:")?1e3*parseInt(l[0].substring(5),10)*.95-16e3:void 0,r.forEach((e=>{e.maxBitrate=l}))),r},t.parseRtcpParameters=function(e){const r={},n=t.matchPrefix(e,"a=ssrc:").map((e=>t.parseSsrcMedia(e))).filter((e=>"cname"===e.attribute))[0];n&&(r.cname=n.value,r.ssrc=n.ssrc);const i=t.matchPrefix(e,"a=rtcp-rsize");r.reducedSize=i.length>0,r.compound=0===i.length;const o=t.matchPrefix(e,"a=rtcp-mux");return r.mux=o.length>0,r},t.writeRtcpParameters=function(e){let t="";return e.reducedSize&&(t+="a=rtcp-rsize\r\n"),e.mux&&(t+="a=rtcp-mux\r\n"),void 0!==e.ssrc&&e.cname&&(t+="a=ssrc:"+e.ssrc+" cname:"+e.cname+"\r\n"),t},t.parseMsid=function(e){let r;const n=t.matchPrefix(e,"a=msid:");if(1===n.length)return r=n[0].substring(7).split(" "),{stream:r[0],track:r[1]};const i=t.matchPrefix(e,"a=ssrc:").map((e=>t.parseSsrcMedia(e))).filter((e=>"msid"===e.attribute));return i.length>0?(r=i[0].value.split(" "),{stream:r[0],track:r[1]}):void 0},t.parseSctpDescription=function(e){const r=t.parseMLine(e),n=t.matchPrefix(e,"a=max-message-size:");let i;n.length>0&&(i=parseInt(n[0].substring(19),10)),isNaN(i)&&(i=65536);const o=t.matchPrefix(e,"a=sctp-port:");if(o.length>0)return{port:parseInt(o[0].substring(12),10),protocol:r.fmt,maxMessageSize:i};const a=t.matchPrefix(e,"a=sctpmap:");if(a.length>0){const e=a[0].substring(10).split(" ");return{port:parseInt(e[0],10),protocol:e[1],maxMessageSize:i}}},t.writeSctpDescription=function(e,t){let 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("")},t.generateSessionId=function(){return(""+Math.random()).substr(2,22)},t.writeSessionBoilerplate=function(e,r,n){let i;const o=void 0!==r?r:2;i=e||t.generateSessionId();return"v=0\r\no="+(n||"thisisadapterortc")+" "+i+" "+o+" IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\n"},t.getDirection=function(e,r){const n=t.splitLines(e);for(let e=0;n.length>e;e++)switch(n[e]){case"a=sendrecv":case"a=sendonly":case"a=recvonly":case"a=inactive":return n[e].substring(2)}return r?t.getDirection(r):"sendrecv"},t.getKind=function(e){return t.splitLines(e)[0].split(" ")[0].substring(2)},t.isRejected=function(e){return"0"===e.split(" ",2)[1]},t.parseMLine=function(e){const r=t.splitLines(e)[0].substring(2).split(" ");return{kind:r[0],port:parseInt(r[1],10),protocol:r[2],fmt:r.slice(3).join(" ")}},t.parseOLine=function(e){const r=t.matchPrefix(e,"o=")[0].substring(2).split(" ");return{username:r[0],sessionId:r[1],sessionVersion:parseInt(r[2],10),netType:r[3],addressType:r[4],address:r[5]}},t.isValidSDP=function(e){if("string"!=typeof e||0===e.length)return!1;const r=t.splitLines(e);for(let e=0;r.length>e;e++)if(2>r[e].length||"="!==r[e].charAt(1))return!1;return!0},e.exports=t}(sdp$1);var sdpExports=sdp$1.exports,SDPUtils=getDefaultExportFromCjs$1(sdpExports),sdp=_mergeNamespaces({__proto__:null,default:SDPUtils},[sdpExports]);function shimRTCIceCandidate(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.substring(2)),e.candidate&&e.candidate.length){const r=new t(e),n=SDPUtils.parseCandidate(e.candidate);for(const e in n)e in r||Object.defineProperty(r,e,{value:n[e]});return r.toJSON=function(){return{candidate:r.candidate,sdpMid:r.sdpMid,sdpMLineIndex:r.sdpMLineIndex,usernameFragment:r.usernameFragment}},r}return new t(e)},e.RTCIceCandidate.prototype=t.prototype,wrapPeerConnectionEvent(e,"icecandidate",(t=>(t.candidate&&Object.defineProperty(t,"candidate",{value:new e.RTCIceCandidate(t.candidate),writable:"false"}),t)))}function shimRTCIceCandidateRelayProtocol(e){!e.RTCIceCandidate||e.RTCIceCandidate&&"relayProtocol"in e.RTCIceCandidate.prototype||wrapPeerConnectionEvent(e,"icecandidate",(e=>{if(e.candidate){const t=SDPUtils.parseCandidate(e.candidate.candidate);"relay"===t.type&&(e.candidate.relayProtocol={0:"tls",1:"tcp",2:"udp"}[t.priority>>24])}return e}))}function shimMaxMessageSize(e,t){if(!e.RTCPeerConnection)return;"sctp"in e.RTCPeerConnection.prototype||Object.defineProperty(e.RTCPeerConnection.prototype,"sctp",{get(){return void 0===this._sctp?null:this._sctp}});const r=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(function(e){if(!e||!e.sdp)return!1;const t=SDPUtils.splitSections(e.sdp);return t.shift(),t.some((e=>{const t=SDPUtils.parseMLine(e);return t&&"application"===t.kind&&-1!==t.protocol.indexOf("SCTP")}))}(arguments[0])){const e=function(e){const t=e.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);if(null===t||2>t.length)return-1;const r=parseInt(t[1],10);return r!=r?-1:r}(arguments[0]),r=function(e){let r=65536;return"firefox"===t.browser&&(r=57>t.version?-1===e?16384:2147483637:60>t.version?57===t.version?65535:65536:2147483637),r}(e),n=function(e,r){let n=65536;"firefox"===t.browser&&57===t.version&&(n=65535);const i=SDPUtils.matchPrefix(e.sdp,"a=max-message-size:");return i.length>0?n=parseInt(i[0].substring(19),10):"firefox"===t.browser&&-1!==r&&(n=2147483637),n}(arguments[0],e);let i;i=0===r&&0===n?1/0:0===r||0===n?Math.max(r,n):Math.min(r,n);const o={};Object.defineProperty(o,"maxMessageSize",{get:()=>i}),this._sctp=o}return r.apply(this,arguments)}}function shimSendThrowTypeError(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];if("open"===e.readyState&&t.sctp&&(n.length||n.size||n.byteLength)>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},wrapPeerConnectionEvent(e,"datachannel",(e=>(t(e.channel,e.target),e)))}function shimConnectionState(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 removeExtmapAllowMixed(e,t){if(!e.RTCPeerConnection)return;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(t){if(t&&t.sdp&&-1!==t.sdp.indexOf("\na=extmap-allow-mixed")){const r=t.sdp.split("\n").filter((e=>"a=extmap-allow-mixed"!==e.trim())).join("\n");e.RTCSessionDescription&&t instanceof e.RTCSessionDescription?arguments[0]=new e.RTCSessionDescription({type:t.type,sdp:r}):t.sdp=r}return r.apply(this,arguments)}}function shimAddIceCandidateNullOrEmpty(e,t){if(!e.RTCPeerConnection||!e.RTCPeerConnection.prototype)return;const r=e.RTCPeerConnection.prototype.addIceCandidate;r&&0!==r.length&&(e.RTCPeerConnection.prototype.addIceCandidate=function(){return arguments[0]?("chrome"===t.browser&&78>t.version||"firefox"===t.browser&&68>t.version||"safari"===t.browser)&&arguments[0]&&""===arguments[0].candidate?Promise.resolve():r.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())})}function shimParameterlessSetLocalDescription(e,t){if(!e.RTCPeerConnection||!e.RTCPeerConnection.prototype)return;const r=e.RTCPeerConnection.prototype.setLocalDescription;r&&0!==r.length&&(e.RTCPeerConnection.prototype.setLocalDescription=function(){let e=arguments[0]||{};if("object"!=typeof e||e.type&&e.sdp)return r.apply(this,arguments);if(e={type:e.type,sdp:e.sdp},!e.type)switch(this.signalingState){case"stable":case"have-local-offer":case"have-remote-pranswer":e.type="offer";break;default:e.type="answer"}if(e.sdp||"offer"!==e.type&&"answer"!==e.type)return r.call(this,e);return("offer"===e.type?this.createOffer:this.createAnswer).apply(this).then((e=>r.call(this,e)))})}var commonShim=Object.freeze({__proto__:null,removeExtmapAllowMixed:removeExtmapAllowMixed,shimAddIceCandidateNullOrEmpty:shimAddIceCandidateNullOrEmpty,shimConnectionState:shimConnectionState,shimMaxMessageSize:shimMaxMessageSize,shimParameterlessSetLocalDescription:shimParameterlessSetLocalDescription,shimRTCIceCandidate:shimRTCIceCandidate,shimRTCIceCandidateRelayProtocol:shimRTCIceCandidateRelayProtocol,shimSendThrowTypeError:shimSendThrowTypeError}),AudioSourceState,Catgory$1,Module$1,Event$1;function adapterFactory({window:e}={},t={shimChrome:!0,shimFirefox:!0,shimSafari:!0}){const r=log,n=detectBrowser(e),i={browserDetails:n,commonShim:commonShim,extractVersion:extractVersion,disableLog:disableLog,disableWarnings:disableWarnings,sdp:sdp};switch(n.browser){case"chrome":if(!chromeShim||!shimPeerConnection$1||!t.shimChrome)return r("Chrome shim is not included in this adapter release."),i;if(null===n.version)return r("Chrome shim can not determine version, not shimming."),i;r("adapter.js shimming chrome."),i.browserShim=chromeShim,shimAddIceCandidateNullOrEmpty(e,n),shimParameterlessSetLocalDescription(e),shimGetUserMedia$2(e,n),shimMediaStream(e),shimPeerConnection$1(e,n),shimOnTrack$1(e),shimAddTrackRemoveTrack(e,n),shimGetSendersWithDtmf(e),shimGetStats(e),shimSenderReceiverGetStats(e),fixNegotiationNeeded(e,n),shimRTCIceCandidate(e),shimRTCIceCandidateRelayProtocol(e),shimConnectionState(e),shimMaxMessageSize(e,n),shimSendThrowTypeError(e),removeExtmapAllowMixed(e,n);break;case"firefox":if(!firefoxShim||!shimPeerConnection||!t.shimFirefox)return r("Firefox shim is not included in this adapter release."),i;r("adapter.js shimming firefox."),i.browserShim=firefoxShim,shimAddIceCandidateNullOrEmpty(e,n),shimParameterlessSetLocalDescription(e),shimGetUserMedia$1(e,n),shimPeerConnection(e,n),shimOnTrack(e),shimRemoveStream(e),shimSenderGetStats(e),shimReceiverGetStats(e),shimRTCDataChannel(e),shimAddTransceiver(e),shimGetParameters(e),shimCreateOffer(e),shimCreateAnswer(e),shimRTCIceCandidate(e),shimConnectionState(e),shimMaxMessageSize(e,n),shimSendThrowTypeError(e);break;case"safari":if(!safariShim||!t.shimSafari)return r("Safari shim is not included in this adapter release."),i;r("adapter.js shimming safari."),i.browserShim=safariShim,shimAddIceCandidateNullOrEmpty(e,n),shimParameterlessSetLocalDescription(e),shimRTCIceServerUrls(e),shimCreateOfferLegacy(e),shimCallbacksAPI(e),shimLocalStreamsAPI(e),shimRemoteStreamsAPI(e),shimTrackEventTransceiver(e),shimGetUserMedia(e),shimAudioContext(e),shimRTCIceCandidate(e),shimRTCIceCandidateRelayProtocol(e),shimMaxMessageSize(e,n),shimSendThrowTypeError(e),removeExtmapAllowMixed(e,n);break;default:r("Unsupported browser!")}return i}adapterFactory({window:"undefined"==typeof window?void 0:window}),function(e){e.Playing="playing",e.Paused="paused",e.Stopped="stopped"}(AudioSourceState||(AudioSourceState={})),function(e){e.ROOM="room_stats",e.CHANNEL="channel_stats"}(Catgory$1||(Catgory$1={})),function(e){e.CONFERENCE="conference",e.SYNC="sync"}(Module$1||(Module$1={})),function(e){e.BACKGROUND="app_background",e.FOREGROUND="app_foreground",e.ERROR="error",e.SIMPLE_LOGGER="simple_logger"}(Event$1||(Event$1={}));var TraceEvent$1={APP_BACKGROUND:{logCatgory:Catgory$1.ROOM,module:Module$1.CONFERENCE,event:Event$1.BACKGROUND},APP_FOREGROUND:{logCatgory:Catgory$1.ROOM,module:Module$1.CONFERENCE,event:Event$1.FOREGROUND},EXCEPTION:{logCatgory:Catgory$1.ROOM,module:Module$1.SYNC,event:Event$1.ERROR},SIMPLE_LOGGER:{logCatgory:Catgory$1.ROOM,module:Module$1.SYNC,event:Event$1.SIMPLE_LOGGER}},UPLOAD_LOG_INTERVAL=4e4,METRIC_STATS_INTERVAL$1=2e3,BaseWebTrackingURL="https://onertc-client-zb.cn-zhangjiakou.log.aliyuncs.com/logstores/webtracking/track?APIVersion=0.6.0",DEVICEID="DINGRTC_DEVICE_ID_FOR_MARK",gslbDomain="",setGslb=function(e){gslbDomain=e},getGslb=function(){return gslbDomain},VideoSourceInfo,RTCStatsType,Catgory,Module,Event$2;function _typeof$1(e){return _typeof$1="function"==typeof Symbol&&"symbol"==_typeof$3(Symbol.iterator)?function(e){return _typeof$3(e)}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":_typeof$3(e)},_typeof$1(e)}function toPrimitive(e,t){if("object"!=_typeof$1(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=_typeof$1(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}function toPropertyKey(e){var t=toPrimitive(e,"string");return"symbol"==_typeof$1(t)?t:t+""}function _defineProperties(e,t){for(var r=0;t.length>r;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,toPropertyKey(n.key),n)}}function _createClass(e,t,r){return t&&_defineProperties(e.prototype,t),r&&_defineProperties(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _possibleConstructorReturn(e,t){if(t&&("object"==_typeof$1(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(e)}function _getPrototypeOf(e){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},_getPrototypeOf(e)}function _setPrototypeOf(e,t){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},_setPrototypeOf(e,t)}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&_setPrototypeOf(e,t)}function _isNativeFunction(e){try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return"function"==typeof e}}function _isNativeReflectConstruct$2$1(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(_isNativeReflectConstruct$2$1=function(){return!!e})()}function _construct(e,t,r){if(_isNativeReflectConstruct$2$1())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,t);var i=new(e.bind.apply(e,n));return r&&_setPrototypeOf(i,r.prototype),i}function _wrapNativeSuper(e){var t="function"==typeof Map?new Map:void 0;return _wrapNativeSuper=function(e){if(null===e||!_isNativeFunction(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return _construct(e,arguments,_getPrototypeOf(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),_setPrototypeOf(r,e)},_wrapNativeSuper(e)}function _defineProperty$1(e,t,r){return(t=toPropertyKey(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}!function(e){e.CAMERA="camera",e.SCREENCAST="screen-cast",e.FILE="file",e.MIXED="mixed"}(VideoSourceInfo||(VideoSourceInfo={})),function(e){e.CandidatePair="candidate-pair",e.Certificate="certificate",e.Codec="codec",e.Csrc="csrc",e.DataCahnnel="data-channel",e.InboundRtp="inbound-rtp",e.LocalCandidate="local-candidate",e.OutboundRtp="outbound-rtp",e.PeerConnection="peer-connection",e.Receiver="receiver",e.RemoteCandidate="remote-candidate",e.RemoteInboundRtp="remote-inbound-rtp",e.RemoteOutboundRtp="remote-outbound-rtp",e.Sender="sender",e.Transport="transport",e.MediaSource="media-source"}(RTCStatsType||(RTCStatsType={})),function(e){e.ROOM="room_stats",e.CHANNEL="channel_stats"}(Catgory||(Catgory={})),function(e){e.CONFERENCE="conference",e.PUBLISH="publish",e.SUBSCRIBE="subscribe",e.RECEIVE_FRAME="video_recv_frame",e.VIDEO_RECEIVE_STREAM="video_recv_stream",e.AUDIO_RECEIVE_STREAM="audio_recv_stream",e.VIDEO_SEND_STREAM="video_send_stream",e.AUDIO_DEVICE="audio_device",e.VIDEO_DEVICE="video_device",e.SCREEN_DEVICE="screen_device",e.NETWORK="network",e.AUDIO_SEND_STREAM="audio_send_stream",e.RENDER="renderer",e.AUDIO_BUFFER="audio_device_buffer",e.BWE="bwe",e.ICE="ice_channel",e.SYSTEM="system_info",e.AUDIO_NET_EQ="audio_neteq",e.USER="users",e.STREAM="streams",e.CONNECTION="connections",e.SYNC="sync"}(Module||(Module={})),function(e){e.JOIN="join",e.REJOIN="rejoin",e.START="start",e.JOIN_SUCCESS="join_success",e.JOIN_FAILED="join_failure",e.REJOIN_SUCCESS="rejoin_success",e.REJOIN_FAILED="rejoin_failure",e.LEAVE="leave",e.INIT="initialize",e.FAILED="failed",e.SUCCESS="success",e.READY="ready",e.FIRST_FRAME="first_frame",e.FIRST_PACKET="first_packet",e.STOP="stop",e.STREAM_CONTROL="stream_control",e.BACKGROUND="app_background",e.FOREGROUND="app_foreground",e.ERROR="error",e.FIRST_DRAW="firstdraw",e.NETWORK_TYPE_CHANGE="network_type_change",e.STATS="stats",e.UNMATCHED="match_failed",e.SIMPLE_LOGGER="simple_logger"}(Event$2||(Event$2={}));var TraceEvent={JOIN_CHANNEL:{logCatgory:Catgory.ROOM,module:Module.CONFERENCE,event:Event$2.JOIN},JOIN_CHANNEL_SUCCESS:{logCatgory:Catgory.ROOM,module:Module.CONFERENCE,event:Event$2.JOIN_SUCCESS},JOIN_CHANNEL_FAILED:{logCatgory:Catgory.ROOM,module:Module.CONFERENCE,event:Event$2.JOIN_FAILED},REJOIN_CHANNEL:{logCatgory:Catgory.ROOM,module:Module.CONFERENCE,event:Event$2.REJOIN},REJOIN_CHANNEL_SUCCESS:{logCatgory:Catgory.ROOM,module:Module.CONFERENCE,event:Event$2.REJOIN_SUCCESS},REJOIN_CHANNEL_FAILED:{logCatgory:Catgory.ROOM,module:Module.CONFERENCE,event:Event$2.REJOIN_FAILED},LEAVE_CHANNEL:{logCatgory:Catgory.ROOM,module:Module.CONFERENCE,event:Event$2.LEAVE},PUBLISH_INIT:{logCatgory:Catgory.CHANNEL,module:Module.PUBLISH,event:Event$2.INIT},PUBLISH_REDAY:{logCatgory:Catgory.CHANNEL,module:Module.PUBLISH,event:Event$2.INIT},PUBLISH_SUCCESS:{logCatgory:Catgory.CHANNEL,module:Module.PUBLISH,event:Event$2.SUCCESS},PUBLISH_FAILED:{logCatgory:Catgory.CHANNEL,module:Module.PUBLISH,event:Event$2.FAILED},SEND_STREAM:{logCatgory:Catgory.CHANNEL,module:Module.VIDEO_SEND_STREAM,event:Event$2.FIRST_PACKET},PUBLISH_STOP:{logCatgory:Catgory.CHANNEL,module:Module.PUBLISH,event:Event$2.STOP},SUBSCRIBE_INIT:{logCatgory:Catgory.CHANNEL,module:Module.SUBSCRIBE,event:Event$2.INIT},SUBSCRIBE_READY:{logCatgory:Catgory.CHANNEL,module:Module.SUBSCRIBE,event:Event$2.READY},SUBSCRIBE_SUCCESS:{logCatgory:Catgory.CHANNEL,module:Module.SUBSCRIBE,event:Event$2.SUCCESS},SUBSCRIBE_FIALED:{logCatgory:Catgory.CHANNEL,module:Module.SUBSCRIBE,event:Event$2.FAILED},RECEIVE_FIRST_FRAME:{logCatgory:Catgory.CHANNEL,module:Module.RECEIVE_FRAME,event:Event$2.FIRST_FRAME},SUBSCRIBE_STOP:{logCatgory:Catgory.CHANNEL,module:Module.SUBSCRIBE,event:Event$2.STOP},LOCAL_CONTROL:{logCatgory:Catgory.CHANNEL,module:Module.PUBLISH,event:Event$2.STREAM_CONTROL},APP_BACKGROUND:{logCatgory:Catgory.ROOM,module:Module.CONFERENCE,event:Event$2.BACKGROUND},APP_FOREGROUND:{logCatgory:Catgory.ROOM,module:Module.CONFERENCE,event:Event$2.FOREGROUND},AUDIO_DEVICE_START:{logCatgory:Catgory.CHANNEL,module:Module.AUDIO_DEVICE,event:Event$2.START},AUDIO_DEVICE_STOP:{logCatgory:Catgory.CHANNEL,module:Module.AUDIO_DEVICE,event:Event$2.STOP},AUDIO_DEVICE_ERROR:{logCatgory:Catgory.CHANNEL,module:Module.AUDIO_DEVICE,event:Event$2.ERROR},VIDEO_DEVICE_START:{logCatgory:Catgory.CHANNEL,module:Module.VIDEO_DEVICE,event:Event$2.START},VIDEO_DEVICE_ERROR:{logCatgory:Catgory.CHANNEL,module:Module.VIDEO_DEVICE,event:Event$2.ERROR},VIDEO_DEVICE_STOP:{logCatgory:Catgory.CHANNEL,module:Module.VIDEO_DEVICE,event:Event$2.STOP},FIRST_DRAW:{logCatgory:Catgory.CHANNEL,module:Module.VIDEO_DEVICE,event:Event$2.FIRST_DRAW},SCREEN_DEVICE_START:{logCatgory:Catgory.CHANNEL,module:Module.SCREEN_DEVICE,event:Event$2.START},SCREEN_DEVICE_STOP:{logCatgory:Catgory.CHANNEL,module:Module.SCREEN_DEVICE,event:Event$2.STOP},NETWORK_TYPE_CHANGE:{logCatgory:Catgory.ROOM,module:Module.NETWORK,event:Event$2.NETWORK_TYPE_CHANGE},AUDIO_SEND_STATS:{logCatgory:Catgory.CHANNEL,module:Module.AUDIO_SEND_STREAM,event:Event$2.STATS},AUDIO_DEVICE_BUFFER:{logCatgory:Catgory.ROOM,module:Module.AUDIO_BUFFER,event:Event$2.STATS},VIDEO_SEND_STATS:{logCatgory:Catgory.CHANNEL,module:Module.VIDEO_SEND_STREAM,event:Event$2.STATS},VIDEO_BWE:{logCatgory:Catgory.CHANNEL,module:Module.BWE,event:Event$2.STATS},VIDEO_RENDER_FPS:{logCatgory:Catgory.CHANNEL,module:Module.RENDER,event:Event$2.STATS},ICE_STATS:{logCatgory:Catgory.CHANNEL,module:Module.ICE,event:Event$2.STATS},SYSTEM_INFO:{logCatgory:Catgory.ROOM,module:Module.SYSTEM,event:Event$2.STATS},SEND_BWE:{logCatgory:Catgory.CHANNEL,module:Module.BWE,event:Event$2.STATS},AUDIO_RECV_STATS:{logCatgory:Catgory.CHANNEL,module:Module.AUDIO_RECEIVE_STREAM,event:Event$2.STATS},VIDEO_RECV_STATS:{logCatgory:Catgory.CHANNEL,module:Module.VIDEO_RECEIVE_STREAM,event:Event$2.STATS},VIDEO_RECV_FIRST_FRAME:{logCatgory:Catgory.CHANNEL,module:Module.VIDEO_RECEIVE_STREAM,event:Event$2.FIRST_FRAME},VIDEO_RECV_FIRST_PACK:{logCatgory:Catgory.CHANNEL,module:Module.VIDEO_RECEIVE_STREAM,event:Event$2.FIRST_PACKET},AUDIO_RECV_FIRST_PACK:{logCatgory:Catgory.CHANNEL,module:Module.AUDIO_RECEIVE_STREAM,event:Event$2.FIRST_PACKET},AUDIO_NET_EQ:{logCatgory:Catgory.CHANNEL,module:Module.AUDIO_NET_EQ,event:Event$2.STATS},USER_EVENT:{logCatgory:Catgory.ROOM,module:Module.USER,event:Event$2.STATS},STREAM_EVENT:{logCatgory:Catgory.ROOM,module:Module.STREAM,event:Event$2.STATS},CONNECTION_EVENT:{logCatgory:Catgory.ROOM,module:Module.CONNECTION,event:Event$2.STATS},SYNC_EVENT:{logCatgory:Catgory.ROOM,module:Module.SYNC,event:Event$2.UNMATCHED},EXCEPTION:{logCatgory:Catgory.ROOM,module:Module.SYNC,event:Event$2.ERROR},SIMPLE_LOGGER:{logCatgory:Catgory.ROOM,module:Module.SYNC,event:Event$2.SIMPLE_LOGGER}};function ownKeys$4$1(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function _objectSpread$4$1(e){for(var t=1;arguments.length>t;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ownKeys$4$1(Object(r),!0).forEach((function(t){_defineProperty$1(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ownKeys$4$1(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var Trace=_createClass((function e(t,r){_classCallCheck(this,e),Object.defineProperty(this,"webtracking",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"sender",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.webtracking=t,this.sender=r}),[{key:"wtJoin",value:function(e){this.webtracking.send(e?{event:"join"}:{event:"joinResult",success:arguments.length>2&&void 0!==arguments[2]&&arguments[2],elapse:arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,message:arguments.length>3&&void 0!==arguments[3]?arguments[3]:""})}},{key:"wtReJoin",value:function(e){this.webtracking.send(e?{event:"rejoin"}:{event:"rejoinResult",success:arguments.length>2&&void 0!==arguments[2]&&arguments[2],elapse:arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,message:arguments.length>3&&void 0!==arguments[3]?arguments[3]:""})}},{key:"wtGslb",value:function(e){this.webtracking.send({event:e,message:arguments.length>1&&void 0!==arguments[1]?arguments[1]:""})}},{key:"simpleLogger",value:function(e){this.sender.sendEvent(_objectSpread$4$1(_objectSpread$4$1({},TraceEvent.SIMPLE_LOGGER),{},{log:e}))}},{key:"wtLeave",value:function(e){this.webtracking.send({event:"leave",reason:e})}},{key:"leave",value:function(){this.sender.sendEvent(_objectSpread$4$1({},TraceEvent.LEAVE_CHANNEL))}},{key:"publish",value:function(e,t){var r,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",i=arguments.length>3?arguments[3]:void 0,o=t.source,a=t.trackMediaType,s=t.getMediaStreamTrack().getSettings(),c=s.width,u=s.height;r="audio"===a?"audio:".concat(o,"/video:false/"):"audio:false/video:".concat(o,"/resolution:").concat(c,"*").concat(u);var l=TraceEvent.PUBLISH_INIT;e||(l=n?TraceEvent.PUBLISH_SUCCESS:TraceEvent.PUBLISH_FAILED),this.sender.sendEvent(_objectSpread$4$1(_objectSpread$4$1({},l),{},{attr_options:r,elapse:i,sessionId:n}))}},{key:"unpublish",value:function(e){this.sender.sendEvent(_objectSpread$4$1({sessionId:e},TraceEvent.PUBLISH_STOP))}},{key:"exception",value:function(e){this.sender.sendEvent(_objectSpread$4$1(_objectSpread$4$1({},TraceEvent.EXCEPTION),{},{code:e.code,message:e.message,name:e.name}))}},{key:"getTrackId",value:function(e,t){var r=e.video,n=!(null==r||!r.source)&&"camera",i="audio:".concat(!!e.audio&&"mic","/video:").concat(n,"/");return null!=t&&t.resolution&&(i+="resolution:".concat(t.resolution.width,"*").concat(t.resolution.height)),i}},{key:"sendEvent",value:function(e){return this.sender.sendEvent(_objectSpread$4$1({},TraceEvent[e]))}},{key:"subscribe",value:function(e){var t=e.sessionId,r=void 0===t?"":t,n=e.remoteStreamId,i=e.remoteUserId,o=e.capabilities,a=e.elapse,s=e.resolutionInfo,c=TraceEvent.SUBSCRIBE_INIT;e.init||(c=r?TraceEvent.SUBSCRIBE_SUCCESS:TraceEvent.SUBSCRIBE_FIALED),this.sender.sendEvent(_objectSpread$4$1(_objectSpread$4$1({},c),{},{sessionId:r,remoteUserId:i,elapse:a,remoteStreamId:n,attr_options:this.getTrackId(o,s)}))}},{key:"join",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"",n=TraceEvent.JOIN_CHANNEL;e||(n=arguments.length>2&&void 0!==arguments[2]&&arguments[2]?TraceEvent.JOIN_CHANNEL_SUCCESS:TraceEvent.JOIN_CHANNEL_FAILED),this.sender.sendEvent(_objectSpread$4$1(_objectSpread$4$1({},n),{},{attr_elapse:t,reason:r}))}},{key:"rejoin",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"",n=TraceEvent.REJOIN_CHANNEL;e||(n=arguments.length>2&&void 0!==arguments[2]&&arguments[2]?TraceEvent.REJOIN_CHANNEL_SUCCESS:TraceEvent.REJOIN_CHANNEL_FAILED),this.sender.sendEvent(_objectSpread$4$1(_objectSpread$4$1({},n),{},{attr_elapse:t,reason:r}))}},{key:"localControl",value:function(e,t,r){var n=TraceEvent.LOCAL_CONTROL,i="".concat(e,"/").concat(t?"pause":"play");this.sender.sendEvent(_objectSpread$4$1(_objectSpread$4$1({},n),{},{attr_info:i,sessionId:r}))}},{key:"usersEvent",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";this.sender.sendEvent(_objectSpread$4$1(_objectSpread$4$1({},TraceEvent.USER_EVENT),{},{uid:e,state:t,payload:r}))}},{key:"streamsEvent",value:function(e,t){this.sender.sendEvent(_objectSpread$4$1(_objectSpread$4$1({},TraceEvent.STREAM_EVENT),{},{streamId:e,state:t}))}},{key:"connectionsEvent",value:function(e,t){this.sender.sendEvent(_objectSpread$4$1(_objectSpread$4$1({},TraceEvent.CONNECTION_EVENT),{},{sessionId:e,action:t}))}},{key:"syncEvent",value:function(e,t,r){this.sender.sendEvent(_objectSpread$4$1(_objectSpread$4$1({},TraceEvent.SYNC_EVENT),{},{syncType:e,clientUids:JSON.stringify(t),serverIds:JSON.stringify(r)}))}},{key:"videoFirstFrame",value:function(e){this.sender.sendEvent(_objectSpread$4$1(_objectSpread$4$1({},TraceEvent.VIDEO_RECV_FIRST_FRAME),e))}},{key:"videoFirstPacket",value:function(e){this.sender.sendEvent(_objectSpread$4$1(_objectSpread$4$1({},TraceEvent.VIDEO_RECV_FIRST_PACK),e))}},{key:"audioFirstPacket",value:function(e){this.sender.sendEvent(_objectSpread$4$1(_objectSpread$4$1({},TraceEvent.AUDIO_RECV_FIRST_PACK),e))}},{key:"unsubscribe",value:function(e){this.sender.sendEvent(_objectSpread$4$1(_objectSpread$4$1({},TraceEvent.SUBSCRIBE_STOP),e))}}]);function ownKeys$3$1(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function _objectSpread$3$1(e){for(var t=1;arguments.length>t;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ownKeys$3$1(Object(r),!0).forEach((function(t){_defineProperty$1(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ownKeys$3$1(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var Metric=_createClass((function e(t){_classCallCheck(this,e),Object.defineProperty(this,"sender",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.sender=t}),[{key:"videoRecvStream",value:function(e){this.sender.sendMetric(_objectSpread$3$1(_objectSpread$3$1({},TraceEvent.VIDEO_RECV_STATS),e))}},{key:"audioNetEQ",value:function(e){this.sender.sendMetric(_objectSpread$3$1(_objectSpread$3$1({},TraceEvent.AUDIO_NET_EQ),e))}},{key:"audioRecvStream",value:function(e){this.sender.sendMetric(_objectSpread$3$1(_objectSpread$3$1({},TraceEvent.AUDIO_RECV_STATS),e))}},{key:"videoSendStream",value:function(e){this.sender.sendMetric(_objectSpread$3$1(_objectSpread$3$1({},TraceEvent.VIDEO_SEND_STATS),e))}},{key:"audioSendStream",value:function(e){this.sender.sendMetric(_objectSpread$3$1(_objectSpread$3$1({},TraceEvent.AUDIO_SEND_STATS),e))}},{key:"audioDeviceBuffer",value:function(e){this.sender.sendMetric(_objectSpread$3$1(_objectSpread$3$1({},TraceEvent.AUDIO_DEVICE_BUFFER),e))}},{key:"bwe",value:function(e){this.sender.sendMetric(_objectSpread$3$1(_objectSpread$3$1({},TraceEvent.VIDEO_BWE),e))}}]);function asyncGeneratorStep(e,t,r,n,i,o,a){try{var s=e[o](a),c=s.value}catch(e){return void r(e)}s.done?t(c):Promise.resolve(c).then(n,i)}function _asyncToGenerator(e){return function(){var t=this,r=arguments;return new Promise((function(n,i){var o=e.apply(t,r);function a(e){asyncGeneratorStep(o,n,i,a,s,"next",e)}function s(e){asyncGeneratorStep(o,n,i,a,s,"throw",e)}a(void 0)}))}}var commonjsGlobal="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function getDefaultExportFromCjs(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function getAugmentedNamespace(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}var regeneratorRuntime$1={exports:{}},_typeof={exports:{}};!function(e){function t(r){return e.exports=t="function"==typeof Symbol&&"symbol"==_typeof$3(Symbol.iterator)?function(e){return _typeof$3(e)}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":_typeof$3(e)},e.exports.__esModule=!0,e.exports.default=e.exports,t(r)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports}(_typeof);var _typeofExports=_typeof.exports;!function(e){var t=_typeofExports.default;function r(){e.exports=r=function(){return i},e.exports.__esModule=!0,e.exports.default=e.exports;var n,i={},o=Object.prototype,a=o.hasOwnProperty,s=Object.defineProperty||function(e,t,r){e[t]=r.value},c="function"==typeof Symbol?Symbol:{},u=c.iterator||"@@iterator",l=c.asyncIterator||"@@asyncIterator",d=c.toStringTag||"@@toStringTag";function p(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{p({},"")}catch(n){p=function(e,t,r){return e[t]=r}}function f(e,t,r,n){var i=Object.create((t&&t.prototype instanceof b?t:b).prototype),o=new N(n||[]);return s(i,"_invoke",{value:w(e,r,o)}),i}function h(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}i.wrap=f;var m="suspendedStart",g="suspendedYield",y="executing",v="completed",_={};function b(){}function E(){}function S(){}var T={};p(T,u,(function(){return this}));var R=Object.getPrototypeOf,O=R&&R(R(D([])));O&&O!==o&&a.call(O,u)&&(T=O);var C=S.prototype=b.prototype=Object.create(T);function k(e){["next","throw","return"].forEach((function(t){p(e,t,(function(e){return this._invoke(t,e)}))}))}function I(e,r){function n(i,o,s,c){var u=h(e[i],e,o);if("throw"!==u.type){var l=u.arg,d=l.value;return d&&"object"==t(d)&&a.call(d,"__await")?r.resolve(d.__await).then((function(e){n("next",e,s,c)}),(function(e){n("throw",e,s,c)})):r.resolve(d).then((function(e){l.value=e,s(l)}),(function(e){return n("throw",e,s,c)}))}c(u.arg)}var i;s(this,"_invoke",{value:function(e,t){function o(){return new r((function(r,i){n(e,t,r,i)}))}return i=i?i.then(o,o):o()}})}function w(e,t,r){var i=m;return function(o,a){if(i===y)throw Error("Generator is already running");if(i===v){if("throw"===o)throw a;return{value:n,done:!0}}for(r.method=o,r.arg=a;;){var s=r.delegate;if(s){var c=P(s,r);if(c){if(c===_)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(i===m)throw i=v,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);i=y;var u=h(e,t,r);if("normal"===u.type){if(i=r.done?v:g,u.arg===_)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(i=v,r.method="throw",r.arg=u.arg)}}}function P(e,t){var r=t.method,i=e.iterator[r];if(i===n)return t.delegate=null,"throw"===r&&e.iterator.return&&(t.method="return",t.arg=n,P(e,t),"throw"===t.method)||"return"!==r&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+r+"' method")),_;var o=h(i,e.iterator,t.arg);if("throw"===o.type)return t.method="throw",t.arg=o.arg,t.delegate=null,_;var a=o.arg;return a?a.done?(t[e.resultName]=a.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=n),t.delegate=null,_):a:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,_)}function A(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function M(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function N(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(A,this),this.reset(!0)}function D(e){if(e||""===e){var r=e[u];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,o=function t(){for(;++i<e.length;)if(a.call(e,i))return t.value=e[i],t.done=!1,t;return t.value=n,t.done=!0,t};return o.next=o}}throw new TypeError(t(e)+" is not iterable")}return E.prototype=S,s(C,"constructor",{value:S,configurable:!0}),s(S,"constructor",{value:E,configurable:!0}),E.displayName=p(S,d,"GeneratorFunction"),i.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===E||"GeneratorFunction"===(t.displayName||t.name))},i.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,S):(e.__proto__=S,p(e,d,"GeneratorFunction")),e.prototype=Object.create(C),e},i.awrap=function(e){return{__await:e}},k(I.prototype),p(I.prototype,l,(function(){return this})),i.AsyncIterator=I,i.async=function(e,t,r,n,o){void 0===o&&(o=Promise);var a=new I(f(e,t,r,n),o);return i.isGeneratorFunction(t)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},k(C),p(C,d,"Generator"),p(C,u,(function(){return this})),p(C,"toString",(function(){return"[object Generator]"})),i.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},i.values=D,N.prototype={constructor:N,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=n,this.done=!1,this.delegate=null,this.method="next",this.arg=n,this.tryEntries.forEach(M),!e)for(var t in this)"t"===t.charAt(0)&&a.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=n)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(r,i){return s.type="throw",s.arg=e,t.next=r,i&&(t.method="next",t.arg=n),!!i}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],s=o.completion;if("root"===o.tryLoc)return r("end");if(this.prev>=o.tryLoc){var c=a.call(o,"catchLoc"),u=a.call(o,"finallyLoc");if(c&&u){if(o.catchLoc>this.prev)return r(o.catchLoc,!0);if(o.finallyLoc>this.prev)return r(o.finallyLoc)}else if(c){if(o.catchLoc>this.prev)return r(o.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(o.finallyLoc>this.prev)return r(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(this.prev>=n.tryLoc&&a.call(n,"finallyLoc")&&n.finallyLoc>this.prev){var i=n;break}}i&&("break"===e||"continue"===e)&&t>=i.tryLoc&&i.finallyLoc>=t&&(i=null);var o=i?i.completion:{};return o.type=e,o.arg=t,i?(this.method="next",this.next=i.finallyLoc,_):this.complete(o)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),_},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),M(r),_}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;M(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:D(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=n),_}},i}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports}(regeneratorRuntime$1);var regeneratorRuntimeExports=regeneratorRuntime$1.exports,runtime=regeneratorRuntimeExports(),regenerator=runtime;try{regeneratorRuntime=runtime}catch(e){"object"==("undefined"==typeof globalThis?"undefined":_typeof$3(globalThis))?globalThis.regeneratorRuntime=runtime:Function("r","regeneratorRuntime = r")(runtime)}var _regeneratorRuntime=getDefaultExportFromCjs(regenerator),encBase64={exports:{}};function commonjsRequire(e){throw Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var core={exports:{}},_nodeResolve_empty={},_nodeResolve_empty$1=Object.freeze({__proto__:null,default:_nodeResolve_empty}),require$$0=getAugmentedNamespace(_nodeResolve_empty$1),hasRequiredCore,CryptoJS;function requireCore(){return hasRequiredCore||(hasRequiredCore=1,core.exports=(e=e||function(e){var t;if("undefined"!=typeof window&&window.crypto&&(t=window.crypto),"undefined"!=typeof self&&self.crypto&&(t=self.crypto),"undefined"!=typeof globalThis&&globalThis.crypto&&(t=globalThis.crypto),!t&&"undefined"!=typeof window&&window.msCrypto&&(t=window.msCrypto),!t&&void 0!==commonjsGlobal&&commonjsGlobal.crypto&&(t=commonjsGlobal.crypto),!t&&"function"==typeof commonjsRequire)try{t=require$$0}catch(e){}var r=function(){if(t){if("function"==typeof t.getRandomValues)try{return t.getRandomValues(new Uint32Array(1))[0]}catch(e){}if("function"==typeof t.randomBytes)try{return t.randomBytes(4).readInt32LE()}catch(e){}}throw Error("Native crypto module could not be used to get secure random number.")},n=Object.create||function(){function e(){}return function(t){var r;return e.prototype=t,r=new e,e.prototype=null,r}}(),i={},o=i.lib={},a=o.Base={extend:function(e){var t=n(this);return e&&t.mixIn(e),t.hasOwnProperty("init")&&this.init!==t.init||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},s=o.WordArray=a.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:4*e.length},toString:function(e){return(e||u).stringify(this)},concat:function(e){var t=this.words,r=e.words,n=this.sigBytes,i=e.sigBytes;if(this.clamp(),n%4)for(var o=0;i>o;o++)t[n+o>>>2]|=(r[o>>>2]>>>24-o%4*8&255)<<24-(n+o)%4*8;else for(var a=0;i>a;a+=4)t[n+a>>>2]=r[a>>>2];return this.sigBytes+=i,this},clamp:function(){var t=this.words,r=this.sigBytes;t[r>>>2]&=4294967295<<32-r%4*8,t.length=e.ceil(r/4)},clone:function(){var e=a.clone.call(this);return e.words=this.words.slice(0),e},random:function(e){for(var t=[],n=0;e>n;n+=4)t.push(r());return new s.init(t,e)}}),c=i.enc={},u=c.Hex={stringify:function(e){for(var t=e.words,r=e.sigBytes,n=[],i=0;r>i;i++){var o=t[i>>>2]>>>24-i%4*8&255;n.push((o>>>4).toString(16)),n.push((15&o).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,r=[],n=0;t>n;n+=2)r[n>>>3]|=parseInt(e.substr(n,2),16)<<24-n%8*4;return new s.init(r,t/2)}},l=c.Latin1={stringify:function(e){for(var t=e.words,r=e.sigBytes,n=[],i=0;r>i;i++)n.push(String.fromCharCode(t[i>>>2]>>>24-i%4*8&255));return n.join("")},parse:function(e){for(var t=e.length,r=[],n=0;t>n;n++)r[n>>>2]|=(255&e.charCodeAt(n))<<24-n%4*8;return new s.init(r,t)}},d=c.Utf8={stringify:function(e){try{return decodeURIComponent(escape(l.stringify(e)))}catch(e){throw Error("Malformed UTF-8 data")}},parse:function(e){return l.parse(unescape(encodeURIComponent(e)))}},p=o.BufferedBlockAlgorithm=a.extend({reset:function(){this._data=new s.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=d.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var r,n=this._data,i=n.words,o=n.sigBytes,a=this.blockSize,c=o/(4*a),u=(c=t?e.ceil(c):e.max((0|c)-this._minBufferSize,0))*a,l=e.min(4*u,o);if(u){for(var d=0;u>d;d+=a)this._doProcessBlock(i,d);r=i.splice(0,u),n.sigBytes-=l}return new s.init(r,l)},clone:function(){var e=a.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0});o.Hasher=p.extend({cfg:a.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){p.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(e){return function(t,r){return new e.init(r).finalize(t)}},_createHmacHelper:function(e){return function(t,r){return new f.HMAC.init(e,r).finalize(t)}}});var f=i.algo={};return i}(Math),e)),core.exports;var e}encBase64.exports=(CryptoJS=requireCore(),function(){var e=CryptoJS.lib.WordArray;function t(t,r,n){for(var i=[],o=0,a=0;r>a;a++)if(a%4){var s=n[t.charCodeAt(a-1)]<<a%4*2,c=n[t.charCodeAt(a)]>>>6-a%4*2;i[o>>>2]|=(s|c)<<24-o%4*8,o++}return e.create(i,o)}CryptoJS.enc.Base64={stringify:function(e){var t=e.words,r=e.sigBytes,n=this._map;e.clamp();for(var i=[],o=0;r>o;o+=3)for(var a=(t[o>>>2]>>>24-o%4*8&255)<<16|(t[o+1>>>2]>>>24-(o+1)%4*8&255)<<8|t[o+2>>>2]>>>24-(o+2)%4*8&255,s=0;4>s&&r>o+.75*s;s++)i.push(n.charAt(a>>>6*(3-s)&63));var c=n.charAt(64);if(c)for(;i.length%4;)i.push(c);return i.join("")},parse:function(e){var r=e.length,n=this._map,i=this._reverseMap;if(!i){i=this._reverseMap=[];for(var o=0;n.length>o;o++)i[n.charCodeAt(o)]=o}var a=n.charAt(64);if(a){var s=e.indexOf(a);-1!==s&&(r=s)}return t(e,r,i)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),CryptoJS.enc.Base64);var encBase64Exports=encBase64.exports,Base64=getDefaultExportFromCjs(encBase64Exports),encUtf8={exports:{}};encUtf8.exports=function(e){return e.enc.Utf8}(requireCore());var encUtf8Exports=encUtf8.exports,UTF8=getDefaultExportFromCjs(encUtf8Exports),indexLight={exports:{}},indexMinimal={},minimal={},aspromise=asPromise;function asPromise(e,t){for(var r=Array(arguments.length-1),n=0,i=2,o=!0;arguments.length>i;)r[n++]=arguments[i++];return new Promise((function(i,a){r[n]=function(e){if(o)if(o=!1,e)a(e);else{for(var t=Array(arguments.length-1),r=0;t.length>r;)t[r++]=arguments[r];i.apply(null,t)}};try{e.apply(t||null,r)}catch(e){o&&(o=!1,a(e))}}))}var base64$1={};!function(e){var t=base64$1;t.length=function(e){var t=e.length;if(!t)return 0;for(var r=0;--t%4>1&&"="===e.charAt(t);)++r;return Math.ceil(3*e.length)/4-r};for(var r=Array(64),n=Array(123),i=0;64>i;)n[r[i]=26>i?i+65:52>i?i+71:62>i?i-4:i-59|43]=i++;t.encode=function(e,t,n){for(var i,o=null,a=[],s=0,c=0;n>t;){var u=e[t++];switch(c){case 0:a[s++]=r[u>>2],i=(3&u)<<4,c=1;break;case 1:a[s++]=r[i|u>>4],i=(15&u)<<2,c=2;break;case 2:a[s++]=r[i|u>>6],a[s++]=r[63&u],c=0}s>8191&&((o||(o=[])).push(String.fromCharCode.apply(String,a)),s=0)}return c&&(a[s++]=r[i],a[s++]=61,1===c&&(a[s++]=61)),o?(s&&o.push(String.fromCharCode.apply(String,a.slice(0,s))),o.join("")):String.fromCharCode.apply(String,a.slice(0,s))};var o="invalid encoding";t.decode=function(e,t,r){for(var i,a=r,s=0,c=0;e.length>c;){var u=e.charCodeAt(c++);if(61===u&&s>1)break;if(void 0===(u=n[u]))throw Error(o);switch(s){case 0:i=u,s=1;break;case 1:t[r++]=i<<2|(48&u)>>4,i=u,s=2;break;case 2:t[r++]=(15&i)<<4|(60&u)>>2,i=u,s=3;break;case 3:t[r++]=(3&i)<<6|u,s=0}}if(1===s)throw Error(o);return r-a},t.test=function(e){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(e)}}();var eventemitter=EventEmitter$1;function EventEmitter$1(){this._listeners={}}EventEmitter$1.prototype.on=function(e,t,r){return(this._listeners[e]||(this._listeners[e]=[])).push({fn:t,ctx:r||this}),this},EventEmitter$1.prototype.off=function(e,t){if(void 0===e)this._listeners={};else if(void 0===t)this._listeners[e]=[];else for(var r=this._listeners[e],n=0;r.length>n;)r[n].fn===t?r.splice(n,1):++n;return this},EventEmitter$1.prototype.emit=function(e){var t=this._listeners[e];if(t){for(var r=[],n=1;arguments.length>n;)r.push(arguments[n++]);for(n=0;t.length>n;)t[n].fn.apply(t[n++].ctx,r)}return this};var _float=factory(factory);function factory(e){return"undefined"!=typeof Float32Array?function(){var t=new Float32Array([-0]),r=new Uint8Array(t.buffer),n=128===r[3];function i(e,n,i){t[0]=e,n[i]=r[0],n[i+1]=r[1],n[i+2]=r[2],n[i+3]=r[3]}function o(e,n,i){t[0]=e,n[i]=r[3],n[i+1]=r[2],n[i+2]=r[1],n[i+3]=r[0]}function a(e,n){return r[0]=e[n],r[1]=e[n+1],r[2]=e[n+2],r[3]=e[n+3],t[0]}function s(e,n){return r[3]=e[n],r[2]=e[n+1],r[1]=e[n+2],r[0]=e[n+3],t[0]}e.writeFloatLE=n?i:o,e.writeFloatBE=n?o:i,e.readFloatLE=n?a:s,e.readFloatBE=n?s:a}():function(){function t(e,t,r,n){var i=0>t?1:0;if(i&&(t=-t),0===t)e(1/t>0?0:2147483648,r,n);else if(isNaN(t))e(2143289344,r,n);else if(t>34028234663852886e22)e((i<<31|2139095040)>>>0,r,n);else if(11754943508222875e-54>t)e((i<<31|Math.round(t/1401298464324817e-60))>>>0,r,n);else{var o=Math.floor(Math.log(t)/Math.LN2);e((i<<31|o+127<<23|8388607&Math.round(t*Math.pow(2,-o)*8388608))>>>0,r,n)}}function r(e,t,r){var n=e(t,r),i=2*(n>>31)+1,o=n>>>23&255,a=8388607&n;return 255===o?a?NaN:i*(1/0):0===o?1401298464324817e-60*i*a:i*Math.pow(2,o-150)*(a+8388608)}e.writeFloatLE=t.bind(null,writeUintLE),e.writeFloatBE=t.bind(null,writeUintBE),e.readFloatLE=r.bind(null,readUintLE),e.readFloatBE=r.bind(null,readUintBE)}(),"undefined"!=typeof Float64Array?function(){var t=new Float64Array([-0]),r=new Uint8Array(t.buffer),n=128===r[7];function i(e,n,i){t[0]=e,n[i]=r[0],n[i+1]=r[1],n[i+2]=r[2],n[i+3]=r[3],n[i+4]=r[4],n[i+5]=r[5],n[i+6]=r[6],n[i+7]=r[7]}function o(e,n,i){t[0]=e,n[i]=r[7],n[i+1]=r[6],n[i+2]=r[5],n[i+3]=r[4],n[i+4]=r[3],n[i+5]=r[2],n[i+6]=r[1],n[i+7]=r[0]}function a(e,n){return r[0]=e[n],r[1]=e[n+1],r[2]=e[n+2],r[3]=e[n+3],r[4]=e[n+4],r[5]=e[n+5],r[6]=e[n+6],r[7]=e[n+7],t[0]}function s(e,n){return r[7]=e[n],r[6]=e[n+1],r[5]=e[n+2],r[4]=e[n+3],r[3]=e[n+4],r[2]=e[n+5],r[1]=e[n+6],r[0]=e[n+7],t[0]}e.writeDoubleLE=n?i:o,e.writeDoubleBE=n?o:i,e.readDoubleLE=n?a:s,e.readDoubleBE=n?s:a}():function(){function t(e,t,r,n,i,o){var a=0>n?1:0;if(a&&(n=-n),0===n)e(0,i,o+t),e(1/n>0?0:2147483648,i,o+r);else if(isNaN(n))e(0,i,o+t),e(2146959360,i,o+r);else if(n>17976931348623157e292)e(0,i,o+t),e((a<<31|2146435072)>>>0,i,o+r);else{var s;if(22250738585072014e-324>n)e((s=n/5e-324)>>>0,i,o+t),e((a<<31|s/4294967296)>>>0,i,o+r);else{var c=Math.floor(Math.log(n)/Math.LN2);1024===c&&(c=1023),e(4503599627370496*(s=n*Math.pow(2,-c))>>>0,i,o+t),e((a<<31|c+1023<<20|1048576*s&1048575)>>>0,i,o+r)}}}function r(e,t,r,n,i){var o=e(n,i+t),a=e(n,i+r),s=2*(a>>31)+1,c=a>>>20&2047,u=4294967296*(1048575&a)+o;return 2047===c?u?NaN:s*(1/0):0===c?5e-324*s*u:s*Math.pow(2,c-1075)*(u+4503599627370496)}e.writeDoubleLE=t.bind(null,writeUintLE,0,4),e.writeDoubleBE=t.bind(null,writeUintBE,4,0),e.readDoubleLE=r.bind(null,readUintLE,0,4),e.readDoubleBE=r.bind(null,readUintBE,4,0)}(),e}function writeUintLE(e,t,r){t[r]=255&e,t[r+1]=e>>>8&255,t[r+2]=e>>>16&255,t[r+3]=e>>>24}function writeUintBE(e,t,r){t[r]=e>>>24,t[r+1]=e>>>16&255,t[r+2]=e>>>8&255,t[r+3]=255&e}function readUintLE(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0}function readUintBE(e,t){return(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0}var inquire_1=inquire;function inquire(moduleName){try{var mod=eval("require")(moduleName);if(mod&&(mod.length||Object.keys(mod).length))return mod}catch(e){}return null}var utf8$2={},t;t=utf8$2,t.length=function(e){for(var t=0,r=0,n=0;e.length>n;++n)128>(r=e.charCodeAt(n))?t+=1:2048>r?t+=2:55296==(64512&r)&&56320==(64512&e.charCodeAt(n+1))?(++n,t+=4):t+=3;return t},t.read=function(e,t,r){if(1>r-t)return"";for(var n,i=null,o=[],a=0;r>t;)128>(n=e[t++])?o[a++]=n:n>191&&224>n?o[a++]=(31&n)<<6|63&e[t++]:n>239&&365>n?(n=((7&n)<<18|(63&e[t++])<<12|(63&e[t++])<<6|63&e[t++])-65536,o[a++]=55296+(n>>10),o[a++]=56320+(1023&n)):o[a++]=(15&n)<<12|(63&e[t++])<<6|63&e[t++],a>8191&&((i||(i=[])).push(String.fromCharCode.apply(String,o)),a=0);return i?(a&&i.push(String.fromCharCode.apply(String,o.slice(0,a))),i.join("")):String.fromCharCode.apply(String,o.slice(0,a))},t.write=function(e,t,r){for(var n,i,o=r,a=0;e.length>a;++a)128>(n=e.charCodeAt(a))?t[r++]=n:2048>n?(t[r++]=n>>6|192,t[r++]=63&n|128):55296==(64512&n)&&56320==(64512&(i=e.charCodeAt(a+1)))?(++a,t[r++]=(n=65536+((1023&n)<<10)+(1023&i))>>18|240,t[r++]=n>>12&63|128,t[r++]=n>>6&63|128,t[r++]=63&n|128):(t[r++]=n>>12|224,t[r++]=n>>6&63|128,t[r++]=63&n|128);return r-o};var pool_1=pool,longbits,hasRequiredLongbits,hasRequiredMinimal;function pool(e,t,r){var n=r||8192,i=n>>>1,o=null,a=n;return function(r){if(1>r||r>i)return e(r);a+r>n&&(o=e(n),a=0);var s=t.call(o,a,a+=r);return 7&a&&(a=1+(7|a)),s}}function requireLongbits(){if(hasRequiredLongbits)return longbits;hasRequiredLongbits=1,longbits=t;var e=requireMinimal();function t(e,t){this.lo=e>>>0,this.hi=t>>>0}var r=t.zero=new t(0,0);r.toNumber=function(){return 0},r.zzEncode=r.zzDecode=function(){return this},r.length=function(){return 1};var n=t.zeroHash="\0\0\0\0\0\0\0\0";t.fromNumber=function(e){if(0===e)return r;var n=0>e;n&&(e=-e);var i=e>>>0,o=(e-i)/4294967296>>>0;return n&&(o=~o>>>0,i=~i>>>0,++i>4294967295&&(i=0,++o>4294967295&&(o=0))),new t(i,o)},t.from=function(n){if("number"==typeof n)return t.fromNumber(n);if(e.isString(n)){if(!e.Long)return t.fromNumber(parseInt(n,10));n=e.Long.fromString(n)}return n.low||n.high?new t(n.low>>>0,n.high>>>0):r},t.prototype.toNumber=function(e){if(!e&&this.hi>>>31){var t=1+~this.lo>>>0,r=~this.hi>>>0;return t||(r=r+1>>>0),-(t+4294967296*r)}return this.lo+4294967296*this.hi},t.prototype.toLong=function(t){return e.Long?new e.Long(0|this.lo,0|this.hi,!!t):{low:0|this.lo,high:0|this.hi,unsigned:!!t}};var i=String.prototype.charCodeAt;return t.fromHash=function(e){return e===n?r:new t((i.call(e,0)|i.call(e,1)<<8|i.call(e,2)<<16|i.call(e,3)<<24)>>>0,(i.call(e,4)|i.call(e,5)<<8|i.call(e,6)<<16|i.call(e,7)<<24)>>>0)},t.prototype.toHash=function(){return String.fromCharCode(255&this.lo,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,255&this.hi,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)},t.prototype.zzEncode=function(){var e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this},t.prototype.zzDecode=function(){var e=-(1&this.lo);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this},t.prototype.length=function(){var e=this.lo,t=(this.lo>>>28|this.hi<<4)>>>0,r=this.hi>>>24;return 0===r?0===t?16384>e?128>e?1:2:2097152>e?3:4:16384>t?128>t?5:6:2097152>t?7:8:128>r?9:10},longbits}function requireMinimal(){return hasRequiredMinimal||(hasRequiredMinimal=1,function(){var e=minimal;function t(e,t,r){for(var n=Object.keys(t),i=0;n.length>i;++i)void 0!==e[n[i]]&&r||(e[n[i]]=t[n[i]]);return e}function r(e){function r(e,n){if(!(this instanceof r))return new r(e,n);Object.defineProperty(this,"message",{get:function(){return e}}),Error.captureStackTrace?Error.captureStackTrace(this,r):Object.defineProperty(this,"stack",{value:Error().stack||""}),n&&t(this,n)}return r.prototype=Object.create(Error.prototype,{constructor:{value:r,writable:!0,enumerable:!1,configurable:!0},name:{get:function(){return e},set:void 0,enumerable:!1,configurable:!0},toString:{value:function(){return this.name+": "+this.message},writable:!0,enumerable:!1,configurable:!0}}),r}e.asPromise=aspromise,e.base64=base64$1,e.EventEmitter=eventemitter,e.float=_float,e.inquire=inquire_1,e.utf8=utf8$2,e.pool=pool_1,e.LongBits=requireLongbits(),e.isNode=!!(void 0!==commonjsGlobal&&commonjsGlobal&&commonjsGlobal.process&&commonjsGlobal.process.versions&&commonjsGlobal.process.versions.node),e.global=e.isNode&&commonjsGlobal||"undefined"!=typeof window&&window||"undefined"!=typeof self&&self||commonjsGlobal,e.emptyArray=Object.freeze?Object.freeze([]):[],e.emptyObject=Object.freeze?Object.freeze({}):{},e.isInteger=Number.isInteger||function(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e},e.isString=function(e){return"string"==typeof e||e instanceof String},e.isObject=function(e){return e&&"object"==_typeof$3(e)},e.isset=e.isSet=function(e,t){var r=e[t];return!(null==r||!e.hasOwnProperty(t)||"object"==_typeof$3(r)&&0>=(Array.isArray(r)?r.length:Object.keys(r).length))},e.Buffer=function(){try{var t=e.inquire("buffer").Buffer;return t.prototype.utf8Write?t:null}catch(e){return null}}(),e._Buffer_from=null,e._Buffer_allocUnsafe=null,e.newBuffer=function(t){return"number"==typeof t?e.Buffer?e._Buffer_allocUnsafe(t):new e.Array(t):e.Buffer?e._Buffer_from(t):"undefined"==typeof Uint8Array?t:new Uint8Array(t)},e.Array="undefined"!=typeof Uint8Array?Uint8Array:Array,e.Long=e.global.dcodeIO&&e.global.dcodeIO.Long||e.global.Long||e.inquire("long"),e.key2Re=/^true|false|0|1$/,e.key32Re=/^-?(?:0|[1-9][0-9]*)$/,e.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/,e.longToHash=function(t){return t?e.LongBits.from(t).toHash():e.LongBits.zeroHash},e.longFromHash=function(t,r){var n=e.LongBits.fromHash(t);return e.Long?e.Long.fromBits(n.lo,n.hi,r):n.toNumber(!!r)},e.merge=t,e.lcFirst=function(e){return e.charAt(0).toLowerCase()+e.substring(1)},e.newError=r,e.ProtocolError=r("ProtocolError"),e.oneOfGetter=function(e){for(var t={},r=0;e.length>r;++r)t[e[r]]=1;return function(){for(var e=Object.keys(this),r=e.length-1;r>-1;--r)if(1===t[e[r]]&&null!=this[e[r]])return e[r]}},e.oneOfSetter=function(e){return function(t){for(var r=0;e.length>r;++r)e[r]!==t&&delete this[e[r]]}},e.toJSONOptions={longs:String,enums:String,bytes:String,json:!0},e._configure=function(){var t=e.Buffer;t?(e._Buffer_from=t.from!==Uint8Array.from&&t.from||function(e,r){return new t(e,r)},e._Buffer_allocUnsafe=t.allocUnsafe||function(e){return new t(e)}):e._Buffer_from=e._Buffer_allocUnsafe=null}}()),minimal}var writer$2=Writer$1,util$6=requireMinimal(),BufferWriter$1,LongBits$1=util$6.LongBits,base64=util$6.base64,utf8$1=util$6.utf8;function Op(e,t,r){this.fn=e,this.len=t,this.next=void 0,this.val=r}function noop(){}function State(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}function Writer$1(){this.len=0,this.head=new Op(noop,0,0),this.tail=this.head,this.states=null}var create$1=function(){return util$6.Buffer?function(){return(Writer$1.create=function(){return new BufferWriter$1})()}:function(){return new Writer$1}};function writeByte(e,t,r){t[r]=255&e}function writeVarint32(e,t,r){for(;e>127;)t[r++]=127&e|128,e>>>=7;t[r]=e}function VarintOp(e,t){this.len=e,this.next=void 0,this.val=t}function writeVarint64(e,t,r){for(;e.hi;)t[r++]=127&e.lo|128,e.lo=(e.lo>>>7|e.hi<<25)>>>0,e.hi>>>=7;for(;e.lo>127;)t[r++]=127&e.lo|128,e.lo=e.lo>>>7;t[r++]=e.lo}function writeFixed32(e,t,r){t[r]=255&e,t[r+1]=e>>>8&255,t[r+2]=e>>>16&255,t[r+3]=e>>>24}Writer$1.create=create$1(),Writer$1.alloc=function(e){return new util$6.Array(e)},util$6.Array!==Array&&(Writer$1.alloc=util$6.pool(Writer$1.alloc,util$6.Array.prototype.subarray)),Writer$1.prototype._push=function(e,t,r){return this.tail=this.tail.next=new Op(e,t,r),this.len+=t,this},VarintOp.prototype=Object.create(Op.prototype),VarintOp.prototype.fn=writeVarint32,Writer$1.prototype.uint32=function(e){return this.len+=(this.tail=this.tail.next=new VarintOp(128>(e>>>=0)?1:16384>e?2:2097152>e?3:268435456>e?4:5,e)).len,this},Writer$1.prototype.int32=function(e){return 0>e?this._push(writeVarint64,10,LongBits$1.fromNumber(e)):this.uint32(e)},Writer$1.prototype.sint32=function(e){return this.uint32((e<<1^e>>31)>>>0)},Writer$1.prototype.uint64=function(e){var t=LongBits$1.from(e);return this._push(writeVarint64,t.length(),t)},Writer$1.prototype.int64=Writer$1.prototype.uint64,Writer$1.prototype.sint64=function(e){var t=LongBits$1.from(e).zzEncode();return this._push(writeVarint64,t.length(),t)},Writer$1.prototype.bool=function(e){return this._push(writeByte,1,e?1:0)},Writer$1.prototype.fixed32=function(e){return this._push(writeFixed32,4,e>>>0)},Writer$1.prototype.sfixed32=Writer$1.prototype.fixed32,Writer$1.prototype.fixed64=function(e){var t=LongBits$1.from(e);return this._push(writeFixed32,4,t.lo)._push(writeFixed32,4,t.hi)},Writer$1.prototype.sfixed64=Writer$1.prototype.fixed64,Writer$1.prototype.float=function(e){return this._push(util$6.float.writeFloatLE,4,e)},Writer$1.prototype.double=function(e){return this._push(util$6.float.writeDoubleLE,8,e)};var writeBytes=util$6.Array.prototype.set?function(e,t,r){t.set(e,r)}:function(e,t,r){for(var n=0;e.length>n;++n)t[r+n]=e[n]};Writer$1.prototype.bytes=function(e){var t=e.length>>>0;if(!t)return this._push(writeByte,1,0);if(util$6.isString(e)){var r=Writer$1.alloc(t=base64.length(e));base64.decode(e,r,0),e=r}return this.uint32(t)._push(writeBytes,t,e)},Writer$1.prototype.string=function(e){var t=utf8$1.length(e);return t?this.uint32(t)._push(utf8$1.write,t,e):this._push(writeByte,1,0)},Writer$1.prototype.fork=function(){return this.states=new State(this),this.head=this.tail=new Op(noop,0,0),this.len=0,this},Writer$1.prototype.reset=function(){return this.states?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new Op(noop,0,0),this.len=0),this},Writer$1.prototype.ldelim=function(){var e=this.head,t=this.tail,r=this.len;return this.reset().uint32(r),r&&(this.tail.next=e.next,this.tail=t,this.len+=r),this},Writer$1.prototype.finish=function(){for(var e=this.head.next,t=this.constructor.alloc(this.len),r=0;e;)e.fn(e.val,t,r),r+=e.len,e=e.next;return t},Writer$1._configure=function(e){BufferWriter$1=e,Writer$1.create=create$1(),BufferWriter$1._configure()};var writer_buffer=BufferWriter,Writer=writer$2;(BufferWriter.prototype=Object.create(Writer.prototype)).constructor=BufferWriter;var util$5=requireMinimal();function BufferWriter(){Writer.call(this)}function writeStringBuffer(e,t,r){40>e.length?util$5.utf8.write(e,t,r):t.utf8Write?t.utf8Write(e,r):t.write(e,r)}BufferWriter._configure=function(){BufferWriter.alloc=util$5._Buffer_allocUnsafe,BufferWriter.writeBytesBuffer=util$5.Buffer&&util$5.Buffer.prototype instanceof Uint8Array&&"set"===util$5.Buffer.prototype.set.name?function(e,t,r){t.set(e,r)}:function(e,t,r){if(e.copy)e.copy(t,r,0,e.length);else for(var n=0;e.length>n;)t[r++]=e[n++]}},BufferWriter.prototype.bytes=function(e){util$5.isString(e)&&(e=util$5._Buffer_from(e,"base64"));var t=e.length>>>0;return this.uint32(t),t&&this._push(BufferWriter.writeBytesBuffer,t,e),this},BufferWriter.prototype.string=function(e){var t=util$5.Buffer.byteLength(e);return this.uint32(t),t&&this._push(writeStringBuffer,t,e),this},BufferWriter._configure();var reader=Reader$1,util$4=requireMinimal(),BufferReader$1,LongBits=util$4.LongBits,utf8=util$4.utf8;function indexOutOfRange(e,t){return RangeError("index out of range: "+e.pos+" + "+(t||1)+" > "+e.len)}function Reader$1(e){this.buf=e,this.pos=0,this.len=e.length}var create_array="undefined"!=typeof Uint8Array?function(e){if(e instanceof Uint8Array||Array.isArray(e))return new Reader$1(e);throw Error("illegal buffer")}:function(e){if(Array.isArray(e))return new Reader$1(e);throw Error("illegal buffer")},create=function(){return util$4.Buffer?function(e){return(Reader$1.create=function(e){return util$4.Buffer.isBuffer(e)?new BufferReader$1(e):create_array(e)})(e)}:create_array},value;function readLongVarint(){var e=new LongBits(0,0),t=0;if(4>=this.len-this.pos){for(;3>t;++t){if(this.pos>=this.len)throw indexOutOfRange(this);if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,128>this.buf[this.pos++])return e}return e.lo=(e.lo|(127&this.buf[this.pos++])<<7*t)>>>0,e}for(;4>t;++t)if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,128>this.buf[this.pos++])return e;if(e.lo=(e.lo|(127&this.buf[this.pos])<<28)>>>0,e.hi=(e.hi|(127&this.buf[this.pos])>>4)>>>0,128>this.buf[this.pos++])return e;if(t=0,this.len-this.pos>4){for(;5>t;++t)if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,128>this.buf[this.pos++])return e}else for(;5>t;++t){if(this.pos>=this.len)throw indexOutOfRange(this);if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,128>this.buf[this.pos++])return e}throw Error("invalid varint encoding")}function readFixed32_end(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}function readFixed64(){if(this.pos+8>this.len)throw indexOutOfRange(this,8);return new LongBits(readFixed32_end(this.buf,this.pos+=4),readFixed32_end(this.buf,this.pos+=4))}Reader$1.create=create(),Reader$1.prototype._slice=util$4.Array.prototype.subarray||util$4.Array.prototype.slice,Reader$1.prototype.uint32=(value=4294967295,function(){if(value=(127&this.buf[this.pos])>>>0,128>this.buf[this.pos++])return value;if(value=(value|(127&this.buf[this.pos])<<7)>>>0,128>this.buf[this.pos++])return value;if(value=(value|(127&this.buf[this.pos])<<14)>>>0,128>this.buf[this.pos++])return value;if(value=(value|(127&this.buf[this.pos])<<21)>>>0,128>this.buf[this.pos++])return value;if(value=(value|(15&this.buf[this.pos])<<28)>>>0,128>this.buf[this.pos++])return value;if((this.pos+=5)>this.len)throw this.pos=this.len,indexOutOfRange(this,10);return value}),Reader$1.prototype.int32=function(){return 0|this.uint32()},Reader$1.prototype.sint32=function(){var e=this.uint32();return e>>>1^-(1&e)},Reader$1.prototype.bool=function(){return 0!==this.uint32()},Reader$1.prototype.fixed32=function(){if(this.pos+4>this.len)throw indexOutOfRange(this,4);return readFixed32_end(this.buf,this.pos+=4)},Reader$1.prototype.sfixed32=function(){if(this.pos+4>this.len)throw indexOutOfRange(this,4);return 0|readFixed32_end(this.buf,this.pos+=4)},Reader$1.prototype.float=function(){if(this.pos+4>this.len)throw indexOutOfRange(this,4);var e=util$4.float.readFloatLE(this.buf,this.pos);return this.pos+=4,e},Reader$1.prototype.double=function(){if(this.pos+8>this.len)throw indexOutOfRange(this,4);var e=util$4.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,e},Reader$1.prototype.bytes=function(){var e=this.uint32(),t=this.pos,r=this.pos+e;if(r>this.len)throw indexOutOfRange(this,e);if(this.pos+=e,Array.isArray(this.buf))return this.buf.slice(t,r);if(t===r){var n=util$4.Buffer;return n?n.alloc(0):new this.buf.constructor(0)}return this._slice.call(this.buf,t,r)},Reader$1.prototype.string=function(){var e=this.bytes();return utf8.read(e,0,e.length)},Reader$1.prototype.skip=function(e){if("number"==typeof e){if(this.pos+e>this.len)throw indexOutOfRange(this,e);this.pos+=e}else do{if(this.pos>=this.len)throw indexOutOfRange(this)}while(128&this.buf[this.pos++]);return this},Reader$1.prototype.skipType=function(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;4!=(e=7&this.uint32());)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+e+" at offset "+this.pos)}return this},Reader$1._configure=function(e){BufferReader$1=e,Reader$1.create=create(),BufferReader$1._configure();var t=util$4.Long?"toLong":"toNumber";util$4.merge(Reader$1.prototype,{int64:function(){return readLongVarint.call(this)[t](!1)},uint64:function(){return readLongVarint.call(this)[t](!0)},sint64:function(){return readLongVarint.call(this).zzDecode()[t](!1)},fixed64:function(){return readFixed64.call(this)[t](!0)},sfixed64:function(){return readFixed64.call(this)[t](!1)}})};var reader_buffer=BufferReader,Reader=reader;(BufferReader.prototype=Object.create(Reader.prototype)).constructor=BufferReader;var util$3=requireMinimal();function BufferReader(e){Reader.call(this,e)}BufferReader._configure=function(){util$3.Buffer&&(BufferReader.prototype._slice=util$3.Buffer.prototype.slice)},BufferReader.prototype.string=function(){var e=this.uint32();return this.buf.utf8Slice?this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+e,this.len)):this.buf.toString("utf-8",this.pos,this.pos=Math.min(this.pos+e,this.len))},BufferReader._configure();var rpc={},service$1=Service,util$2=requireMinimal(),exports$1;function Service(e,t,r){if("function"!=typeof e)throw TypeError("rpcImpl must be a function");util$2.EventEmitter.call(this),this.rpcImpl=e,this.requestDelimited=!!t,this.responseDelimited=!!r}(Service.prototype=Object.create(util$2.EventEmitter.prototype)).constructor=Service,Service.prototype.rpcCall=function e(t,r,n,i,o){if(!i)throw TypeError("request must be specified");var a=this;if(!o)return util$2.asPromise(e,a,t,r,n,i);if(a.rpcImpl)try{return a.rpcImpl(t,r[a.requestDelimited?"encodeDelimited":"encode"](i).finish(),(function(e,r){if(e)return a.emit("error",e,t),o(e);if(null!==r){if(!(r instanceof n))try{r=n[a.responseDelimited?"decodeDelimited":"decode"](r)}catch(e){return a.emit("error",e,t),o(e)}return a.emit("data",r,t),o(null,r)}a.end(!0)}))}catch(e){return a.emit("error",e,t),void setTimeout((function(){o(e)}),0)}else setTimeout((function(){o(Error("already ended"))}),0)},Service.prototype.end=function(e){return this.rpcImpl&&(e||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this},exports$1=rpc,exports$1.Service=service$1;var roots={};!function(e){var t=indexMinimal;function r(){t.util._configure(),t.Writer._configure(t.BufferWriter),t.Reader._configure(t.BufferReader)}t.build="minimal",t.Writer=writer$2,t.BufferWriter=writer_buffer,t.Reader=reader,t.BufferReader=reader_buffer,t.util=requireMinimal(),t.rpc=rpc,t.roots=roots,t.configure=r,r()}();var util$1={exports:{}},codegen_1,hasRequiredCodegen,fetch_1,hasRequiredFetch;function requireCodegen(){if(hasRequiredCodegen)return codegen_1;function e(t,r){"string"==typeof t&&(r=t,t=void 0);var n=[];function i(t){if("string"!=typeof t){var r=o();if(e.verbose&&console.log("codegen: "+r),r="return "+r,t){for(var a=Object.keys(t),s=Array(a.length+1),c=Array(a.length),u=0;a.length>u;)s[u]=a[u],c[u]=t[a[u++]];return s[u]=r,Function.apply(null,s).apply(null,c)}return Function(r)()}for(var l=Array(arguments.length-1),d=0;l.length>d;)l[d]=arguments[++d];if(d=0,t=t.replace(/%([%dfijs])/g,(function(e,t){var r=l[d++];switch(t){case"d":case"f":return Number(r)+"";case"i":return Math.floor(r)+"";case"j":return JSON.stringify(r);case"s":return r+""}return"%"})),d!==l.length)throw Error("parameter count mismatch");return n.push(t),i}function o(e){return"function "+(e||r||"")+"("+(t&&t.join(",")||"")+"){\n "+n.join("\n ")+"\n}"}return i.toString=o,i}return hasRequiredCodegen=1,codegen_1=e,e.verbose=!1,codegen_1}function requireFetch(){if(hasRequiredFetch)return fetch_1;hasRequiredFetch=1,fetch_1=r;var e=aspromise,t=inquire_1("fs");function r(n,i,o){return"function"==typeof i?(o=i,i={}):i||(i={}),o?!i.xhr&&t&&t.readFile?t.readFile(n,(function(e,t){return e&&"undefined"!=typeof XMLHttpRequest?r.xhr(n,i,o):e?o(e):o(null,i.binary?t:t.toString("utf8"))})):r.xhr(n,i,o):e(r,this,n,i)}return r.xhr=function(e,t,r){var n=new XMLHttpRequest;n.onreadystatechange=function(){if(4===n.readyState){if(0!==n.status&&200!==n.status)return r(Error("status "+n.status));if(t.binary){var e=n.response;if(!e){e=[];for(var i=0;n.responseText.length>i;++i)e.push(255&n.responseText.charCodeAt(i))}return r(null,"undefined"!=typeof Uint8Array?new Uint8Array(e):e)}return r(null,n.responseText)}},t.binary&&("overrideMimeType"in n&&n.overrideMimeType("text/plain; charset=x-user-defined"),n.responseType="arraybuffer"),n.open("GET",e),n.send()},fetch_1}var path={},hasRequiredPath;function requirePath(){return hasRequiredPath||(hasRequiredPath=1,function(e){var t=e,r=t.isAbsolute=function(e){return/^(?:\/|\w+:)/.test(e)},n=t.normalize=function(e){var t=(e=e.replace(/\\/g,"/").replace(/\/{2,}/g,"/")).split("/"),n=r(e),i="";n&&(i=t.shift()+"/");for(var o=0;t.length>o;)".."===t[o]?o>0&&".."!==t[o-1]?t.splice(--o,2):n?t.splice(o,1):++o:"."===t[o]?t.splice(o,1):++o;return i+t.join("/")};t.resolve=function(e,t,i){return i||(t=n(t)),r(t)?t:(i||(e=n(e)),(e=e.replace(/(?:\/|^)[^/]+$/,"")).length?n(e+"/"+t):t)}}(path)),path}var types={},hasRequiredTypes,field,hasRequiredField,oneof,hasRequiredOneof,namespace,hasRequiredNamespace,mapfield,hasRequiredMapfield,method,hasRequiredMethod,service,hasRequiredService;function requireTypes(){return hasRequiredTypes||(hasRequiredTypes=1,function(e){var t=e,r=requireUtil(),n=["double","float","int32","uint32","sint32","fixed32","sfixed32","int64","uint64","sint64","fixed64","sfixed64","bool","string","bytes"];function i(e,t){var r=0,i={};for(t|=0;e.length>r;)i[n[r+t]]=e[r++];return i}t.basic=i([1,5,0,0,0,5,5,0,0,0,1,1,0,2,2]),t.defaults=i([0,0,0,0,0,0,0,0,0,0,0,0,!1,"",r.emptyArray,null]),t.long=i([0,0,0,1,1],7),t.mapKey=i([0,0,0,5,5,0,0,0,1,1,0,2],2),t.packed=i([1,5,0,0,0,5,5,0,0,0,1,1,0])}(types)),types}function requireField(){if(hasRequiredField)return field;hasRequiredField=1,field=a;var e=requireObject();((a.prototype=Object.create(e.prototype)).constructor=a).className="Field";var t,r=require_enum(),n=requireTypes(),i=requireUtil(),o=/^required|optional|repeated$/;function a(t,r,a,s,c,u,l){if(i.isObject(s)?(l=c,u=s,s=c=void 0):i.isObject(c)&&(l=u,u=c,c=void 0),e.call(this,t,u),!i.isInteger(r)||0>r)throw TypeError("id must be a non-negative integer");if(!i.isString(a))throw TypeError("type must be a string");if(void 0!==s&&!o.test(s=(""+s).toLowerCase()))throw TypeError("rule must be a string rule");if(void 0!==c&&!i.isString(c))throw TypeError("extend must be a string");"proto3_optional"===s&&(s="optional"),this.rule=s&&"optional"!==s?s:void 0,this.type=a,this.id=r,this.extend=c||void 0,this.required="required"===s,this.optional=!this.required,this.repeated="repeated"===s,this.map=!1,this.message=null,this.partOf=null,this.typeDefault=null,this.defaultValue=null,this.long=!!i.Long&&void 0!==n.long[a],this.bytes="bytes"===a,this.resolvedType=null,this.extensionField=null,this.declaringField=null,this._packed=null,this.comment=l}return a.fromJSON=function(e,t){return new a(e,t.id,t.type,t.rule,t.extend,t.options,t.comment)},Object.defineProperty(a.prototype,"packed",{get:function(){return null===this._packed&&(this._packed=!1!==this.getOption("packed")),this._packed}}),a.prototype.setOption=function(t,r,n){return"packed"===t&&(this._packed=null),e.prototype.setOption.call(this,t,r,n)},a.prototype.toJSON=function(e){return i.toObject(["rule","optional"!==this.rule&&this.rule||void 0,"type",this.type,"id",this.id,"extend",this.extend,"options",this.options,"comment",e&&e.keepComments?this.comment:void 0])},a.prototype.resolve=function(){if(this.resolved)return this;if(void 0===(this.typeDefault=n.defaults[this.type])?(this.resolvedType=(this.declaringField?this.declaringField.parent:this.parent).lookupTypeOrEnum(this.type),this.typeDefault=this.resolvedType instanceof t?null:this.resolvedType.values[Object.keys(this.resolvedType.values)[0]]):this.options&&this.options.proto3_optional&&(this.typeDefault=null),this.options&&null!=this.options.default&&(this.typeDefault=this.options.default,this.resolvedType instanceof r&&"string"==typeof this.typeDefault&&(this.typeDefault=this.resolvedType.values[this.typeDefault])),this.options&&(!0!==this.options.packed&&(void 0===this.options.packed||!this.resolvedType||this.resolvedType instanceof r)||delete this.options.packed,Object.keys(this.options).length||(this.options=void 0)),this.long)this.typeDefault=i.Long.fromNumber(this.typeDefault,"u"===this.type.charAt(0)),Object.freeze&&Object.freeze(this.typeDefault);else if(this.bytes&&"string"==typeof this.typeDefault){var o;i.base64.test(this.typeDefault)?i.base64.decode(this.typeDefault,o=i.newBuffer(i.base64.length(this.typeDefault)),0):i.utf8.write(this.typeDefault,o=i.newBuffer(i.utf8.length(this.typeDefault)),0),this.typeDefault=o}return this.defaultValue=this.map?i.emptyObject:this.repeated?i.emptyArray:this.typeDefault,this.parent instanceof t&&(this.parent.ctor.prototype[this.name]=this.defaultValue),e.prototype.resolve.call(this)},a.d=function(e,t,r,n){return"function"==typeof t?t=i.decorateType(t).name:t&&"object"==_typeof$3(t)&&(t=i.decorateEnum(t).name),function(o,s){i.decorateType(o.constructor).add(new a(s,e,t,r,{default:n}))}},a._configure=function(e){t=e},field}function requireOneof(){if(hasRequiredOneof)return oneof;hasRequiredOneof=1,oneof=n;var e=requireObject();((n.prototype=Object.create(e.prototype)).constructor=n).className="OneOf";var t=requireField(),r=requireUtil();function n(t,r,n,i){if(Array.isArray(r)||(n=r,r=void 0),e.call(this,t,n),void 0!==r&&!Array.isArray(r))throw TypeError("fieldNames must be an Array");this.oneof=r||[],this.fieldsArray=[],this.comment=i}function i(e){if(e.parent)for(var t=0;e.fieldsArray.length>t;++t)e.fieldsArray[t].parent||e.parent.add(e.fieldsArray[t])}return n.fromJSON=function(e,t){return new n(e,t.oneof,t.options,t.comment)},n.prototype.toJSON=function(e){return r.toObject(["options",this.options,"oneof",this.oneof,"comment",e&&e.keepComments?this.comment:void 0])},n.prototype.add=function(e){if(!(e instanceof t))throw TypeError("field must be a Field");return e.parent&&e.parent!==this.parent&&e.parent.remove(e),this.oneof.push(e.name),this.fieldsArray.push(e),e.partOf=this,i(this),this},n.prototype.remove=function(e){if(!(e instanceof t))throw TypeError("field must be a Field");var r=this.fieldsArray.indexOf(e);if(0>r)throw Error(e+" is not a member of "+this);return this.fieldsArray.splice(r,1),(r=this.oneof.indexOf(e.name))>-1&&this.oneof.splice(r,1),e.partOf=null,this},n.prototype.onAdd=function(t){e.prototype.onAdd.call(this,t);for(var r=0;this.oneof.length>r;++r){var n=t.get(this.oneof[r]);n&&!n.partOf&&(n.partOf=this,this.fieldsArray.push(n))}i(this)},n.prototype.onRemove=function(t){for(var r,n=0;this.fieldsArray.length>n;++n)(r=this.fieldsArray[n]).parent&&r.parent.remove(r);e.prototype.onRemove.call(this,t)},n.d=function(){for(var e=Array(arguments.length),t=0;arguments.length>t;)e[t]=arguments[t++];return function(t,i){r.decorateType(t.constructor).add(new n(i,e)),Object.defineProperty(t,i,{get:r.oneOfGetter(e),set:r.oneOfSetter(e)})}},oneof}function requireNamespace(){if(hasRequiredNamespace)return namespace;hasRequiredNamespace=1,namespace=c;var e=requireObject();((c.prototype=Object.create(e.prototype)).constructor=c).className="Namespace";var t,r,n,i=requireField(),o=requireUtil(),a=requireOneof();function s(e,t){if(e&&e.length){for(var r={},n=0;e.length>n;++n)r[e[n].name]=e[n].toJSON(t);return r}}function c(t,r){e.call(this,t,r),this.nested=void 0,this._nestedArray=null}function u(e){return e._nestedArray=null,e}return c.fromJSON=function(e,t){return new c(e,t.options).addJSON(t.nested)},c.arrayToJSON=s,c.isReservedId=function(e,t){if(e)for(var r=0;e.length>r;++r)if("string"!=typeof e[r]&&t>=e[r][0]&&e[r][1]>t)return!0;return!1},c.isReservedName=function(e,t){if(e)for(var r=0;e.length>r;++r)if(e[r]===t)return!0;return!1},Object.defineProperty(c.prototype,"nestedArray",{get:function(){return this._nestedArray||(this._nestedArray=o.toArray(this.nested))}}),c.prototype.toJSON=function(e){return o.toObject(["options",this.options,"nested",s(this.nestedArray,e)])},c.prototype.addJSON=function(e){if(e)for(var o,a=Object.keys(e),s=0;a.length>s;++s)this.add((void 0!==(o=e[a[s]]).fields?t.fromJSON:void 0!==o.values?n.fromJSON:void 0!==o.methods?r.fromJSON:void 0!==o.id?i.fromJSON:c.fromJSON)(a[s],o));return this},c.prototype.get=function(e){return this.nested&&this.nested[e]||null},c.prototype.getEnum=function(e){if(this.nested&&this.nested[e]instanceof n)return this.nested[e].values;throw Error("no such enum: "+e)},c.prototype.add=function(e){if(!(e instanceof i&&void 0!==e.extend||e instanceof t||e instanceof a||e instanceof n||e instanceof r||e instanceof c))throw TypeError("object must be a valid nested object");if(this.nested){var o=this.get(e.name);if(o){if(!(o instanceof c&&e instanceof c)||o instanceof t||o instanceof r)throw Error("duplicate name '"+e.name+"' in "+this);for(var s=o.nestedArray,l=0;s.length>l;++l)e.add(s[l]);this.remove(o),this.nested||(this.nested={}),e.setOptions(o.options,!0)}}else this.nested={};return this.nested[e.name]=e,e.onAdd(this),u(this)},c.prototype.remove=function(t){if(!(t instanceof e))throw TypeError("object must be a ReflectionObject");if(t.parent!==this)throw Error(t+" is not a member of "+this);return delete this.nested[t.name],Object.keys(this.nested).length||(this.nested=void 0),t.onRemove(this),u(this)},c.prototype.define=function(e,t){if(o.isString(e))e=e.split(".");else if(!Array.isArray(e))throw TypeError("illegal path");if(e&&e.length&&""===e[0])throw Error("path must be relative");for(var r=this;e.length>0;){var n=e.shift();if(r.nested&&r.nested[n]){if(!((r=r.nested[n])instanceof c))throw Error("path conflicts with non-namespace objects")}else r.add(r=new c(n))}return t&&r.addJSON(t),r},c.prototype.resolveAll=function(){for(var e=this.nestedArray,t=0;e.length>t;)e[t]instanceof c?e[t++].resolveAll():e[t++].resolve();return this.resolve()},c.prototype.lookup=function(e,t,r){if("boolean"==typeof t?(r=t,t=void 0):t&&!Array.isArray(t)&&(t=[t]),o.isString(e)&&e.length){if("."===e)return this.root;e=e.split(".")}else if(!e.length)return this;if(""===e[0])return this.root.lookup(e.slice(1),t);var n=this.get(e[0]);if(n){if(1===e.length){if(!t||t.indexOf(n.constructor)>-1)return n}else if(n instanceof c&&(n=n.lookup(e.slice(1),t,!0)))return n}else for(var i=0;this.nestedArray.length>i;++i)if(this._nestedArray[i]instanceof c&&(n=this._nestedArray[i].lookup(e,t,!0)))return n;return null===this.parent||r?null:this.parent.lookup(e,t)},c.prototype.lookupType=function(e){var r=this.lookup(e,[t]);if(!r)throw Error("no such type: "+e);return r},c.prototype.lookupEnum=function(e){var t=this.lookup(e,[n]);if(!t)throw Error("no such Enum '"+e+"' in "+this);return t},c.prototype.lookupTypeOrEnum=function(e){var r=this.lookup(e,[t,n]);if(!r)throw Error("no such Type or Enum '"+e+"' in "+this);return r},c.prototype.lookupService=function(e){var t=this.lookup(e,[r]);if(!t)throw Error("no such Service '"+e+"' in "+this);return t},c._configure=function(e,i,o){t=e,r=i,n=o},namespace}function requireMapfield(){if(hasRequiredMapfield)return mapfield;hasRequiredMapfield=1,mapfield=n;var e=requireField();((n.prototype=Object.create(e.prototype)).constructor=n).className="MapField";var t=requireTypes(),r=requireUtil();function n(t,n,i,o,a,s){if(e.call(this,t,n,o,void 0,void 0,a,s),!r.isString(i))throw TypeError("keyType must be a string");this.keyType=i,this.resolvedKeyType=null,this.map=!0}return n.fromJSON=function(e,t){return new n(e,t.id,t.keyType,t.type,t.options,t.comment)},n.prototype.toJSON=function(e){return r.toObject(["keyType",this.keyType,"type",this.type,"id",this.id,"extend",this.extend,"options",this.options,"comment",e&&e.keepComments?this.comment:void 0])},n.prototype.resolve=function(){if(this.resolved)return this;if(void 0===t.mapKey[this.keyType])throw Error("invalid key type: "+this.keyType);return e.prototype.resolve.call(this)},n.d=function(e,t,i){return"function"==typeof i?i=r.decorateType(i).name:i&&"object"==_typeof$3(i)&&(i=r.decorateEnum(i).name),function(o,a){r.decorateType(o.constructor).add(new n(a,e,t,i))}},mapfield}function requireMethod(){if(hasRequiredMethod)return method;hasRequiredMethod=1,method=r;var e=requireObject();((r.prototype=Object.create(e.prototype)).constructor=r).className="Method";var t=requireUtil();function r(r,n,i,o,a,s,c,u,l){if(t.isObject(a)?(c=a,a=s=void 0):t.isObject(s)&&(c=s,s=void 0),void 0!==n&&!t.isString(n))throw TypeError("type must be a string");if(!t.isString(i))throw TypeError("requestType must be a string");if(!t.isString(o))throw TypeError("responseType must be a string");e.call(this,r,c),this.type=n||"rpc",this.requestType=i,this.requestStream=!!a||void 0,this.responseType=o,this.responseStream=!!s||void 0,this.resolvedRequestType=null,this.resolvedResponseType=null,this.comment=u,this.parsedOptions=l}return r.fromJSON=function(e,t){return new r(e,t.type,t.requestType,t.responseType,t.requestStream,t.responseStream,t.options,t.comment,t.parsedOptions)},r.prototype.toJSON=function(e){return t.toObject(["type","rpc"!==this.type&&this.type||void 0,"requestType",this.requestType,"requestStream",this.requestStream,"responseType",this.responseType,"responseStream",this.responseStream,"options",this.options,"comment",e&&e.keepComments?this.comment:void 0,"parsedOptions",this.parsedOptions])},r.prototype.resolve=function(){return this.resolved?this:(this.resolvedRequestType=this.parent.lookupType(this.requestType),this.resolvedResponseType=this.parent.lookupType(this.responseType),e.prototype.resolve.call(this))},method}function requireService(){if(hasRequiredService)return service;hasRequiredService=1,service=i;var e=requireNamespace();((i.prototype=Object.create(e.prototype)).constructor=i).className="Service";var t=requireMethod(),r=requireUtil(),n=rpc;function i(t,r){e.call(this,t,r),this.methods={},this._methodsArray=null}function o(e){return e._methodsArray=null,e}return i.fromJSON=function(e,r){var n=new i(e,r.options);if(r.methods)for(var o=Object.keys(r.methods),a=0;o.length>a;++a)n.add(t.fromJSON(o[a],r.methods[o[a]]));return r.nested&&n.addJSON(r.nested),n.comment=r.comment,n},i.prototype.toJSON=function(t){var n=e.prototype.toJSON.call(this,t),i=!!t&&!!t.keepComments;return r.toObject(["options",n&&n.options||void 0,"methods",e.arrayToJSON(this.methodsArray,t)||{},"nested",n&&n.nested||void 0,"comment",i?this.comment:void 0])},Object.defineProperty(i.prototype,"methodsArray",{get:function(){return this._methodsArray||(this._methodsArray=r.toArray(this.methods))}}),i.prototype.get=function(t){return this.methods[t]||e.prototype.get.call(this,t)},i.prototype.resolveAll=function(){for(var t=this.methodsArray,r=0;t.length>r;++r)t[r].resolve();return e.prototype.resolve.call(this)},i.prototype.add=function(r){if(this.get(r.name))throw Error("duplicate name '"+r.name+"' in "+this);return r instanceof t?(this.methods[r.name]=r,r.parent=this,o(this)):e.prototype.add.call(this,r)},i.prototype.remove=function(r){if(r instanceof t){if(this.methods[r.name]!==r)throw Error(r+" is not a member of "+this);return delete this.methods[r.name],r.parent=null,o(this)}return e.prototype.remove.call(this,r)},i.prototype.create=function(e,t,i){for(var o,a=new n.Service(e,t,i),s=0;this.methodsArray.length>s;++s){var c=r.lcFirst((o=this._methodsArray[s]).resolve().name).replace(/[^$\w_]/g,"");a[c]=r.codegen(["r","c"],r.isReserved(c)?c+"_":c)("return this.rpcCall(m,q,s,r,c)")({m:o,q:o.resolvedRequestType.ctor,s:o.resolvedResponseType.ctor})}return a},service}var message=Message,util=requireMinimal(),decoder_1,hasRequiredDecoder,verifier_1,hasRequiredVerifier;function Message(e){if(e)for(var t=Object.keys(e),r=0;t.length>r;++r)this[t[r]]=e[t[r]]}function requireDecoder(){if(hasRequiredDecoder)return decoder_1;hasRequiredDecoder=1,decoder_1=function(i){var o=r.codegen(["r","l"],i.name+"$decode")("if(!(r instanceof Reader))")("r=Reader.create(r)")("var c=l===undefined?r.len:r.pos+l,m=new this.ctor"+(i.fieldsArray.filter((function(e){return e.map})).length?",k,value":""))("while(r.pos<c){")("var t=r.uint32()");i.group&&o("if((t&7)===4)")("break"),o("switch(t>>>3){");for(var a=0;i.fieldsArray.length>a;++a){var s=i._fieldsArray[a].resolve(),c=s.resolvedType instanceof e?"int32":s.type,u="m"+r.safeProp(s.name);o("case %i: {",s.id),s.map?(o("if(%s===util.emptyObject)",u)("%s={}",u)("var c2 = r.uint32()+r.pos"),void 0!==t.defaults[s.keyType]?o("k=%j",t.defaults[s.keyType]):o("k=null"),void 0!==t.defaults[c]?o("value=%j",t.defaults[c]):o("value=null"),o("while(r.pos<c2){")("var tag2=r.uint32()")("switch(tag2>>>3){")("case 1: k=r.%s(); break",s.keyType)("case 2:"),void 0===t.basic[c]?o("value=types[%i].decode(r,r.uint32())",a):o("value=r.%s()",c),o("break")("default:")("r.skipType(tag2&7)")("break")("}")("}"),o(void 0!==t.long[s.keyType]?'%s[typeof k==="object"?util.longToHash(k):k]=value':"%s[k]=value",u)):s.repeated?(o("if(!(%s&&%s.length))",u,u)("%s=[]",u),void 0!==t.packed[c]&&o("if((t&7)===2){")("var c2=r.uint32()+r.pos")("while(r.pos<c2)")("%s.push(r.%s())",u,c)("}else"),void 0===t.basic[c]?o(s.resolvedType.group?"%s.push(types[%i].decode(r))":"%s.push(types[%i].decode(r,r.uint32()))",u,a):o("%s.push(r.%s())",u,c)):void 0===t.basic[c]?o(s.resolvedType.group?"%s=types[%i].decode(r)":"%s=types[%i].decode(r,r.uint32())",u,a):o("%s=r.%s()",u,c),o("break")("}")}for(o("default:")("r.skipType(t&7)")("break")("}")("}"),a=0;i._fieldsArray.length>a;++a){var l=i._fieldsArray[a];l.required&&o("if(!m.hasOwnProperty(%j))",l.name)("throw util.ProtocolError(%j,{instance:m})",n(l))}return o("return m")};var e=require_enum(),t=requireTypes(),r=requireUtil();function n(e){return"missing required '"+e.name+"'"}return decoder_1}function requireVerifier(){if(hasRequiredVerifier)return verifier_1;hasRequiredVerifier=1,verifier_1=function(e){var o=t.codegen(["m"],e.name+"$verify")('if(typeof m!=="object"||m===null)')("return%j","object expected"),a={};e.oneofsArray.length&&o("var p={}");for(var s=0;e.fieldsArray.length>s;++s){var c=e._fieldsArray[s].resolve(),u="m"+t.safeProp(c.name);if(c.optional&&o("if(%s!=null&&m.hasOwnProperty(%j)){",u,c.name),c.map)o("if(!util.isObject(%s))",u)("return%j",r(c,"object"))("var k=Object.keys(%s)",u)("for(var i=0;i<k.length;++i){"),i(o,c,"k[i]"),n(o,c,s,u+"[k[i]]")("}");else if(c.repeated)o("if(!Array.isArray(%s))",u)("return%j",r(c,"array"))("for(var i=0;i<%s.length;++i){",u),n(o,c,s,u+"[i]")("}");else{if(c.partOf){var l=t.safeProp(c.partOf.name);1===a[c.partOf.name]&&o("if(p%s===1)",l)("return%j",c.partOf.name+": multiple values"),a[c.partOf.name]=1,o("p%s=1",l)}n(o,c,s,u)}c.optional&&o("}")}return o("return null")};var e=require_enum(),t=requireUtil();function r(e,t){return e.name+": "+t+(e.repeated&&"array"!==t?"[]":e.map&&"object"!==t?"{k:"+e.keyType+"}":"")+" expected"}function n(t,n,i,o){if(n.resolvedType)if(n.resolvedType instanceof e){t("switch(%s){",o)("default:")("return%j",r(n,"enum value"));for(var a=Object.keys(n.resolvedType.values),s=0;a.length>s;++s)t("case %i:",n.resolvedType.values[a[s]]);t("break")("}")}else t("{")("var e=types[%i].verify(%s);",i,o)("if(e)")("return%j+e",n.name+".")("}");else switch(n.type){case"int32":case"uint32":case"sint32":case"fixed32":case"sfixed32":t("if(!util.isInteger(%s))",o)("return%j",r(n,"integer"));break;case"int64":case"uint64":case"sint64":case"fixed64":case"sfixed64":t("if(!util.isInteger(%s)&&!(%s&&util.isInteger(%s.low)&&util.isInteger(%s.high)))",o,o,o,o)("return%j",r(n,"integer|Long"));break;case"float":case"double":t('if(typeof %s!=="number")',o)("return%j",r(n,"number"));break;case"bool":t('if(typeof %s!=="boolean")',o)("return%j",r(n,"boolean"));break;case"string":t("if(!util.isString(%s))",o)("return%j",r(n,"string"));break;case"bytes":t('if(!(%s&&typeof %s.length==="number"||util.isString(%s)))',o,o,o)("return%j",r(n,"buffer"))}return t}function i(e,t,n){switch(t.keyType){case"int32":case"uint32":case"sint32":case"fixed32":case"sfixed32":e("if(!util.key32Re.test(%s))",n)("return%j",r(t,"integer key"));break;case"int64":case"uint64":case"sint64":case"fixed64":case"sfixed64":e("if(!util.key64Re.test(%s))",n)("return%j",r(t,"integer|Long key"));break;case"bool":e("if(!util.key2Re.test(%s))",n)("return%j",r(t,"boolean key"))}return e}return verifier_1}Message.create=function(e){return this.$type.create(e)},Message.encode=function(e,t){return this.$type.encode(e,t)},Message.encodeDelimited=function(e,t){return this.$type.encodeDelimited(e,t)},Message.decode=function(e){return this.$type.decode(e)},Message.decodeDelimited=function(e){return this.$type.decodeDelimited(e)},Message.verify=function(e){return this.$type.verify(e)},Message.fromObject=function(e){return this.$type.fromObject(e)},Message.toObject=function(e,t){return this.$type.toObject(e,t)},Message.prototype.toJSON=function(){return this.$type.toObject(this,util.toJSONOptions)};var converter={},hasRequiredConverter;function requireConverter(){return hasRequiredConverter||(hasRequiredConverter=1,function(e){var t=e,r=require_enum(),n=requireUtil();function i(e,t,n,i){var o=!1;if(t.resolvedType)if(t.resolvedType instanceof r){e("switch(d%s){",i);for(var a=t.resolvedType.values,s=Object.keys(a),c=0;s.length>c;++c)a[s[c]]!==t.typeDefault||o||(e("default:")('if(typeof(d%s)==="number"){m%s=d%s;break}',i,i,i),t.repeated||e("break"),o=!0),e("case%j:",s[c])("case %i:",a[s[c]])("m%s=%j",i,a[s[c]])("break");e("}")}else e('if(typeof d%s!=="object")',i)("throw TypeError(%j)",t.fullName+": object expected")("m%s=types[%i].fromObject(d%s)",i,n,i);else{var u=!1;switch(t.type){case"double":case"float":e("m%s=Number(d%s)",i,i);break;case"uint32":case"fixed32":e("m%s=d%s>>>0",i,i);break;case"int32":case"sint32":case"sfixed32":e("m%s=d%s|0",i,i);break;case"uint64":u=!0;case"int64":case"sint64":case"fixed64":case"sfixed64":e("if(util.Long)")("(m%s=util.Long.fromValue(d%s)).unsigned=%j",i,i,u)('else if(typeof d%s==="string")',i)("m%s=parseInt(d%s,10)",i,i)('else if(typeof d%s==="number")',i)("m%s=d%s",i,i)('else if(typeof d%s==="object")',i)("m%s=new util.LongBits(d%s.low>>>0,d%s.high>>>0).toNumber(%s)",i,i,i,u?"true":"");break;case"bytes":e('if(typeof d%s==="string")',i)("util.base64.decode(d%s,m%s=util.newBuffer(util.base64.length(d%s)),0)",i,i,i)("else if(d%s.length >= 0)",i)("m%s=d%s",i,i);break;case"string":e("m%s=String(d%s)",i,i);break;case"bool":e("m%s=Boolean(d%s)",i,i)}}return e}function o(e,t,n,i){if(t.resolvedType)t.resolvedType instanceof r?e("d%s=o.enums===String?(types[%i].values[m%s]===undefined?m%s:types[%i].values[m%s]):m%s",i,n,i,i,n,i,i):e("d%s=types[%i].toObject(m%s,o)",i,n,i);else{var o=!1;switch(t.type){case"double":case"float":e("d%s=o.json&&!isFinite(m%s)?String(m%s):m%s",i,i,i,i);break;case"uint64":o=!0;case"int64":case"sint64":case"fixed64":case"sfixed64":e('if(typeof m%s==="number")',i)("d%s=o.longs===String?String(m%s):m%s",i,i,i)("else")("d%s=o.longs===String?util.Long.prototype.toString.call(m%s):o.longs===Number?new util.LongBits(m%s.low>>>0,m%s.high>>>0).toNumber(%s):m%s",i,i,i,i,o?"true":"",i);break;case"bytes":e("d%s=o.bytes===String?util.base64.encode(m%s,0,m%s.length):o.bytes===Array?Array.prototype.slice.call(m%s):m%s",i,i,i,i,i);break;default:e("d%s=m%s",i,i)}}return e}t.fromObject=function(e){var t=e.fieldsArray,o=n.codegen(["d"],e.name+"$fromObject")("if(d instanceof this.ctor)")("return d");if(!t.length)return o("return new this.ctor");o("var m=new this.ctor");for(var a=0;t.length>a;++a){var s=t[a].resolve(),c=n.safeProp(s.name);s.map?(o("if(d%s){",c)('if(typeof d%s!=="object")',c)("throw TypeError(%j)",s.fullName+": object expected")("m%s={}",c)("for(var ks=Object.keys(d%s),i=0;i<ks.length;++i){",c),i(o,s,a,c+"[ks[i]]")("}")("}")):s.repeated?(o("if(d%s){",c)("if(!Array.isArray(d%s))",c)("throw TypeError(%j)",s.fullName+": array expected")("m%s=[]",c)("for(var i=0;i<d%s.length;++i){",c),i(o,s,a,c+"[i]")("}")("}")):(s.resolvedType instanceof r||o("if(d%s!=null){",c),i(o,s,a,c),s.resolvedType instanceof r||o("}"))}return o("return m")},t.toObject=function(e){var t=e.fieldsArray.slice().sort(n.compareFieldsById);if(!t.length)return n.codegen()("return {}");for(var i=n.codegen(["m","o"],e.name+"$toObject")("if(!o)")("o={}")("var d={}"),a=[],s=[],c=[],u=0;t.length>u;++u)t[u].partOf||(t[u].resolve().repeated?a:t[u].map?s:c).push(t[u]);if(a.length){for(i("if(o.arrays||o.defaults){"),u=0;a.length>u;++u)i("d%s=[]",n.safeProp(a[u].name));i("}")}if(s.length){for(i("if(o.objects||o.defaults){"),u=0;s.length>u;++u)i("d%s={}",n.safeProp(s[u].name));i("}")}if(c.length){for(i("if(o.defaults){"),u=0;c.length>u;++u){var l=n.safeProp((f=c[u]).name);if(f.resolvedType instanceof r)i("d%s=o.enums===String?%j:%j",l,f.resolvedType.valuesById[f.typeDefault],f.typeDefault);else if(f.long)i("if(util.Long){")("var n=new util.Long(%i,%i,%j)",f.typeDefault.low,f.typeDefault.high,f.typeDefault.unsigned)("d%s=o.longs===String?n.toString():o.longs===Number?n.toNumber():n",l)("}else")("d%s=o.longs===String?%j:%i",l,""+f.typeDefault,f.typeDefault.toNumber());else if(f.bytes){var d="["+Array.prototype.slice.call(f.typeDefault).join(",")+"]";i("if(o.bytes===String)d%s=%j",l,String.fromCharCode.apply(String,f.typeDefault))("else{")("d%s=%s",l,d)("if(o.bytes!==Array)d%s=util.newBuffer(d%s)",l,l)("}")}else i("d%s=%j",l,f.typeDefault)}i("}")}var p=!1;for(u=0;t.length>u;++u){var f,h=e._fieldsArray.indexOf(f=t[u]);l=n.safeProp(f.name),f.map?(p||(p=!0,i("var ks2")),i("if(m%s&&(ks2=Object.keys(m%s)).length){",l,l)("d%s={}",l)("for(var j=0;j<ks2.length;++j){"),o(i,f,h,l+"[ks2[j]]")("}")):f.repeated?(i("if(m%s&&m%s.length){",l,l)("d%s=[]",l)("for(var j=0;j<m%s.length;++j){",l),o(i,f,h,l+"[j]")("}")):(i("if(m%s!=null&&m.hasOwnProperty(%j)){",l,f.name),o(i,f,h,l),f.partOf&&i("if(o.oneofs)")("d%s=%j",n.safeProp(f.partOf.name),f.name)),i("}")}return i("return d")}}(converter)),converter}var wrappers={},type$1,hasRequiredType,root$1,hasRequiredRoot,hasRequiredUtil,object,hasRequiredObject,_enum,hasRequired_enum,encoder_1,hasRequiredEncoder;function requireType(){if(hasRequiredType)return type$1;hasRequiredType=1,type$1=m;var e=requireNamespace();((m.prototype=Object.create(e.prototype)).constructor=m).className="Type";var t=require_enum(),r=requireOneof(),n=requireField(),i=requireMapfield(),o=requireService(),a=message,s=reader,c=writer$2,u=requireUtil(),l=requireEncoder(),d=requireDecoder(),p=requireVerifier(),f=requireConverter(),h=wrappers;function m(t,r){e.call(this,t,r),this.fields={},this.oneofs=void 0,this.extensions=void 0,this.reserved=void 0,this.group=void 0,this._fieldsById=null,this._fieldsArray=null,this._oneofsArray=null,this._ctor=null}function g(e){return e._fieldsById=e._fieldsArray=e._oneofsArray=null,delete e.encode,delete e.decode,delete e.verify,e}return Object.defineProperties(m.prototype,{fieldsById:{get:function(){if(this._fieldsById)return this._fieldsById;this._fieldsById={};for(var e=Object.keys(this.fields),t=0;e.length>t;++t){var r=this.fields[e[t]],n=r.id;if(this._fieldsById[n])throw Error("duplicate id "+n+" in "+this);this._fieldsById[n]=r}return this._fieldsById}},fieldsArray:{get:function(){return this._fieldsArray||(this._fieldsArray=u.toArray(this.fields))}},oneofsArray:{get:function(){return this._oneofsArray||(this._oneofsArray=u.toArray(this.oneofs))}},ctor:{get:function(){return this._ctor||(this.ctor=m.generateConstructor(this)())},set:function(e){var t=e.prototype;t instanceof a||((e.prototype=new a).constructor=e,u.merge(e.prototype,t)),e.$type=e.prototype.$type=this,u.merge(e,a,!0),this._ctor=e;for(var r=0;this.fieldsArray.length>r;++r)this._fieldsArray[r].resolve();var n={};for(r=0;this.oneofsArray.length>r;++r)n[this._oneofsArray[r].resolve().name]={get:u.oneOfGetter(this._oneofsArray[r].oneof),set:u.oneOfSetter(this._oneofsArray[r].oneof)};r&&Object.defineProperties(e.prototype,n)}}}),m.generateConstructor=function(e){for(var t,r=u.codegen(["p"],e.name),n=0;e.fieldsArray.length>n;++n)(t=e._fieldsArray[n]).map?r("this%s={}",u.safeProp(t.name)):t.repeated&&r("this%s=[]",u.safeProp(t.name));return r("if(p)for(var ks=Object.keys(p),i=0;i<ks.length;++i)if(p[ks[i]]!=null)")("this[ks[i]]=p[ks[i]]")},m.fromJSON=function(a,s){var c=new m(a,s.options);c.extensions=s.extensions,c.reserved=s.reserved;for(var u=Object.keys(s.fields),l=0;u.length>l;++l)c.add((void 0!==s.fields[u[l]].keyType?i.fromJSON:n.fromJSON)(u[l],s.fields[u[l]]));if(s.oneofs)for(u=Object.keys(s.oneofs),l=0;u.length>l;++l)c.add(r.fromJSON(u[l],s.oneofs[u[l]]));if(s.nested)for(u=Object.keys(s.nested),l=0;u.length>l;++l){var d=s.nested[u[l]];c.add((void 0!==d.id?n.fromJSON:void 0!==d.fields?m.fromJSON:void 0!==d.values?t.fromJSON:void 0!==d.methods?o.fromJSON:e.fromJSON)(u[l],d))}return s.extensions&&s.extensions.length&&(c.extensions=s.extensions),s.reserved&&s.reserved.length&&(c.reserved=s.reserved),s.group&&(c.group=!0),s.comment&&(c.comment=s.comment),c},m.prototype.toJSON=function(t){var r=e.prototype.toJSON.call(this,t),n=!!t&&!!t.keepComments;return u.toObject(["options",r&&r.options||void 0,"oneofs",e.arrayToJSON(this.oneofsArray,t),"fields",e.arrayToJSON(this.fieldsArray.filter((function(e){return!e.declaringField})),t)||{},"extensions",this.extensions&&this.extensions.length?this.extensions:void 0,"reserved",this.reserved&&this.reserved.length?this.reserved:void 0,"group",this.group||void 0,"nested",r&&r.nested||void 0,"comment",n?this.comment:void 0])},m.prototype.resolveAll=function(){for(var t=this.fieldsArray,r=0;t.length>r;)t[r++].resolve();var n=this.oneofsArray;for(r=0;n.length>r;)n[r++].resolve();return e.prototype.resolveAll.call(this)},m.prototype.get=function(e){return this.fields[e]||this.oneofs&&this.oneofs[e]||this.nested&&this.nested[e]||null},m.prototype.add=function(t){if(this.get(t.name))throw Error("duplicate name '"+t.name+"' in "+this);if(t instanceof n&&void 0===t.extend){if(this._fieldsById?this._fieldsById[t.id]:this.fieldsById[t.id])throw Error("duplicate id "+t.id+" in "+this);if(this.isReservedId(t.id))throw Error("id "+t.id+" is reserved in "+this);if(this.isReservedName(t.name))throw Error("name '"+t.name+"' is reserved in "+this);return t.parent&&t.parent.remove(t),this.fields[t.name]=t,t.message=this,t.onAdd(this),g(this)}return t instanceof r?(this.oneofs||(this.oneofs={}),this.oneofs[t.name]=t,t.onAdd(this),g(this)):e.prototype.add.call(this,t)},m.prototype.remove=function(t){if(t instanceof n&&void 0===t.extend){if(!this.fields||this.fields[t.name]!==t)throw Error(t+" is not a member of "+this);return delete this.fields[t.name],t.parent=null,t.onRemove(this),g(this)}if(t instanceof r){if(!this.oneofs||this.oneofs[t.name]!==t)throw Error(t+" is not a member of "+this);return delete this.oneofs[t.name],t.parent=null,t.onRemove(this),g(this)}return e.prototype.remove.call(this,t)},m.prototype.isReservedId=function(t){return e.isReservedId(this.reserved,t)},m.prototype.isReservedName=function(t){return e.isReservedName(this.reserved,t)},m.prototype.create=function(e){return new this.ctor(e)},m.prototype.setup=function(){for(var e=this.fullName,t=[],r=0;this.fieldsArray.length>r;++r)t.push(this._fieldsArray[r].resolve().resolvedType);this.encode=l(this)({Writer:c,types:t,util:u}),this.decode=d(this)({Reader:s,types:t,util:u}),this.verify=p(this)({types:t,util:u}),this.fromObject=f.fromObject(this)({types:t,util:u}),this.toObject=f.toObject(this)({types:t,util:u});var n=h[e];if(n){var i=Object.create(this);i.fromObject=this.fromObject,this.fromObject=n.fromObject.bind(i),i.toObject=this.toObject,this.toObject=n.toObject.bind(i)}return this},m.prototype.encode=function(e,t){return this.setup().encode(e,t)},m.prototype.encodeDelimited=function(e,t){return this.encode(e,t&&t.len?t.fork():t).ldelim()},m.prototype.decode=function(e,t){return this.setup().decode(e,t)},m.prototype.decodeDelimited=function(e){return e instanceof s||(e=s.create(e)),this.decode(e,e.uint32())},m.prototype.verify=function(e){return this.setup().verify(e)},m.prototype.fromObject=function(e){return this.setup().fromObject(e)},m.prototype.toObject=function(e,t){return this.setup().toObject(e,t)},m.d=function(e){return function(t){u.decorateType(t,e)}},type$1}function requireRoot(){if(hasRequiredRoot)return root$1;hasRequiredRoot=1,root$1=c;var e=requireNamespace();((c.prototype=Object.create(e.prototype)).constructor=c).className="Root";var t,r,n,i=requireField(),o=require_enum(),a=requireOneof(),s=requireUtil();function c(t){e.call(this,"",t),this.deferred=[],this.files=[]}function u(){}c.fromJSON=function(e,t){return t||(t=new c),e.options&&t.setOptions(e.options),t.addJSON(e.nested)},c.prototype.resolvePath=s.path.resolve,c.prototype.fetch=s.fetch,c.prototype.load=function e(t,i,o){"function"==typeof i&&(o=i,i=void 0);var a=this;if(!o)return s.asPromise(e,a,t,i);var c=o===u;function l(e,t){if(o){if(c)throw e;var r=o;o=null,r(e,t)}}function d(e){var t=e.lastIndexOf("google/protobuf/");if(t>-1){var r=e.substring(t);if(r in n)return r}return null}function p(e,t){try{if(s.isString(t)&&"{"===t.charAt(0)&&(t=JSON.parse(t)),s.isString(t)){r.filename=e;var n,o=r(t,a,i),u=0;if(o.imports)for(;o.imports.length>u;++u)(n=d(o.imports[u])||a.resolvePath(e,o.imports[u]))&&f(n);if(o.weakImports)for(u=0;o.weakImports.length>u;++u)(n=d(o.weakImports[u])||a.resolvePath(e,o.weakImports[u]))&&f(n,!0)}else a.setOptions(t.options).addJSON(t.nested)}catch(e){l(e)}c||h||l(null,a)}function f(e,t){if(e=d(e)||e,-1>=a.files.indexOf(e))if(a.files.push(e),e in n)c?p(e,n[e]):(++h,setTimeout((function(){--h,p(e,n[e])})));else if(c){var r;try{r=s.fs.readFileSync(e).toString("utf8")}catch(e){return void(t||l(e))}p(e,r)}else++h,a.fetch(e,(function(r,n){--h,o&&(r?t?h||l(null,a):l(r):p(e,n))}))}var h=0;s.isString(t)&&(t=[t]);for(var m,g=0;t.length>g;++g)(m=a.resolvePath("",t[g]))&&f(m);if(c)return a;h||l(null,a)},c.prototype.loadSync=function(e,t){if(!s.isNode)throw Error("not supported");return this.load(e,t,u)},c.prototype.resolveAll=function(){if(this.deferred.length)throw Error("unresolvable extensions: "+this.deferred.map((function(e){return"'extend "+e.extend+"' in "+e.parent.fullName})).join(", "));return e.prototype.resolveAll.call(this)};var l=/^[A-Z]/;function d(e,t){var r=t.parent.lookup(t.extend);if(r){var n=new i(t.fullName,t.id,t.type,t.rule,void 0,t.options);return r.get(n.name)||(n.declaringField=t,t.extensionField=n,r.add(n)),!0}return!1}return c.prototype._handleAdd=function(e){if(e instanceof i)void 0===e.extend||e.extensionField||d(0,e)||this.deferred.push(e);else if(e instanceof o)l.test(e.name)&&(e.parent[e.name]=e.values);else if(!(e instanceof a)){if(e instanceof t)for(var r=0;this.deferred.length>r;)d(0,this.deferred[r])?this.deferred.splice(r,1):++r;for(var n=0;e.nestedArray.length>n;++n)this._handleAdd(e._nestedArray[n]);l.test(e.name)&&(e.parent[e.name]=e)}},c.prototype._handleRemove=function(t){if(t instanceof i){if(void 0!==t.extend)if(t.extensionField)t.extensionField.parent.remove(t.extensionField),t.extensionField=null;else{var r=this.deferred.indexOf(t);r>-1&&this.deferred.splice(r,1)}}else if(t instanceof o)l.test(t.name)&&delete t.parent[t.name];else if(t instanceof e){for(var n=0;t.nestedArray.length>n;++n)this._handleRemove(t._nestedArray[n]);l.test(t.name)&&delete t.parent[t.name]}},c._configure=function(e,i,o){t=e,r=i,n=o},root$1}function requireUtil(){if(hasRequiredUtil)return util$1.exports;hasRequiredUtil=1;var e,t,r=util$1.exports=requireMinimal(),n=roots;r.codegen=requireCodegen(),r.fetch=requireFetch(),r.path=requirePath(),r.fs=r.inquire("fs"),r.toArray=function(e){if(e){for(var t=Object.keys(e),r=Array(t.length),n=0;t.length>n;)r[n]=e[t[n++]];return r}return[]},r.toObject=function(e){for(var t={},r=0;e.length>r;){var n=e[r++],i=e[r++];void 0!==i&&(t[n]=i)}return t};var i=/\\/g,o=/"/g;r.isReserved=function(e){return/^(?:do|if|in|for|let|new|try|var|case|else|enum|eval|false|null|this|true|void|with|break|catch|class|const|super|throw|while|yield|delete|export|import|public|return|static|switch|typeof|default|extends|finally|package|private|continue|debugger|function|arguments|interface|protected|implements|instanceof)$/.test(e)},r.safeProp=function(e){return!/^[$\w_]+$/.test(e)||r.isReserved(e)?'["'+e.replace(i,"\\\\").replace(o,'\\"')+'"]':"."+e},r.ucFirst=function(e){return e.charAt(0).toUpperCase()+e.substring(1)};var a=/_([a-z])/g;r.camelCase=function(e){return e.substring(0,1)+e.substring(1).replace(a,(function(e,t){return t.toUpperCase()}))},r.compareFieldsById=function(e,t){return e.id-t.id},r.decorateType=function(t,n){if(t.$type)return n&&t.$type.name!==n&&(r.decorateRoot.remove(t.$type),t.$type.name=n,r.decorateRoot.add(t.$type)),t.$type;e||(e=requireType());var i=new e(n||t.name);return r.decorateRoot.add(i),i.ctor=t,Object.defineProperty(t,"$type",{value:i,enumerable:!1}),Object.defineProperty(t.prototype,"$type",{value:i,enumerable:!1}),i};var s=0;return r.decorateEnum=function(e){if(e.$type)return e.$type;t||(t=require_enum());var n=new t("Enum"+s++,e);return r.decorateRoot.add(n),Object.defineProperty(e,"$type",{value:n,enumerable:!1}),n},r.setProperty=function(e,t,r){if("object"!=_typeof$3(e))throw TypeError("dst must be an object");if(!t)throw TypeError("path must be specified");return function e(t,r,n){var i=r.shift();if("__proto__"===i||"prototype"===i)return t;if(r.length>0)t[i]=e(t[i]||{},r,n);else{var o=t[i];o&&(n=[].concat(o).concat(n)),t[i]=n}return t}(e,t=t.split("."),r)},Object.defineProperty(r,"decorateRoot",{get:function(){return n.decorated||(n.decorated=new(requireRoot()))}}),util$1.exports}function requireObject(){if(hasRequiredObject)return object;hasRequiredObject=1,object=r,r.className="ReflectionObject";var e,t=requireUtil();function r(e,r){if(!t.isString(e))throw TypeError("name must be a string");if(r&&!t.isObject(r))throw TypeError("options must be an object");this.options=r,this.parsedOptions=null,this.name=e,this.parent=null,this.resolved=!1,this.comment=null,this.filename=null}return Object.defineProperties(r.prototype,{root:{get:function(){for(var e=this;null!==e.parent;)e=e.parent;return e}},fullName:{get:function(){for(var e=[this.name],t=this.parent;t;)e.unshift(t.name),t=t.parent;return e.join(".")}}}),r.prototype.toJSON=function(){throw Error()},r.prototype.onAdd=function(t){this.parent&&this.parent!==t&&this.parent.remove(this),this.parent=t,this.resolved=!1;var r=t.root;r instanceof e&&r._handleAdd(this)},r.prototype.onRemove=function(t){var r=t.root;r instanceof e&&r._handleRemove(this),this.parent=null,this.resolved=!1},r.prototype.resolve=function(){return this.resolved||this.root instanceof e&&(this.resolved=!0),this},r.prototype.getOption=function(e){if(this.options)return this.options[e]},r.prototype.setOption=function(e,t,r){return r&&this.options&&void 0!==this.options[e]||((this.options||(this.options={}))[e]=t),this},r.prototype.setParsedOption=function(e,r,n){this.parsedOptions||(this.parsedOptions=[]);var i=this.parsedOptions;if(n){var o=i.find((function(t){return Object.prototype.hasOwnProperty.call(t,e)}));o?t.setProperty(o[e],n,r):((o={})[e]=t.setProperty({},n,r),i.push(o))}else{var a={};a[e]=r,i.push(a)}return this},r.prototype.setOptions=function(e,t){if(e)for(var r=Object.keys(e),n=0;r.length>n;++n)this.setOption(r[n],e[r[n]],t);return this},r.prototype.toString=function(){var e=this.constructor.className,t=this.fullName;return t.length?e+" "+t:e},r._configure=function(t){e=t},object}function require_enum(){if(hasRequired_enum)return _enum;hasRequired_enum=1,_enum=n;var e=requireObject();((n.prototype=Object.create(e.prototype)).constructor=n).className="Enum";var t=requireNamespace(),r=requireUtil();function n(t,r,n,i,o,a){if(e.call(this,t,n),r&&"object"!=_typeof$3(r))throw TypeError("values must be an object");if(this.valuesById={},this.values=Object.create(this.valuesById),this.comment=i,this.comments=o||{},this.valuesOptions=a,this.reserved=void 0,r)for(var s=Object.keys(r),c=0;s.length>c;++c)"number"==typeof r[s[c]]&&(this.valuesById[this.values[s[c]]=r[s[c]]]=s[c])}return n.fromJSON=function(e,t){var r=new n(e,t.values,t.options,t.comment,t.comments);return r.reserved=t.reserved,r},n.prototype.toJSON=function(e){var t=!!e&&!!e.keepComments;return r.toObject(["options",this.options,"valuesOptions",this.valuesOptions,"values",this.values,"reserved",this.reserved&&this.reserved.length?this.reserved:void 0,"comment",t?this.comment:void 0,"comments",t?this.comments:void 0])},n.prototype.add=function(e,t,n,i){if(!r.isString(e))throw TypeError("name must be a string");if(!r.isInteger(t))throw TypeError("id must be an integer");if(void 0!==this.values[e])throw Error("duplicate name '"+e+"' in "+this);if(this.isReservedId(t))throw Error("id "+t+" is reserved in "+this);if(this.isReservedName(e))throw Error("name '"+e+"' is reserved in "+this);if(void 0!==this.valuesById[t]){if(!this.options||!this.options.allow_alias)throw Error("duplicate id "+t+" in "+this);this.values[e]=t}else this.valuesById[this.values[e]=t]=e;return i&&(void 0===this.valuesOptions&&(this.valuesOptions={}),this.valuesOptions[e]=i||null),this.comments[e]=n||null,this},n.prototype.remove=function(e){if(!r.isString(e))throw TypeError("name must be a string");var t=this.values[e];if(null==t)throw Error("name '"+e+"' does not exist in "+this);return delete this.valuesById[t],delete this.values[e],delete this.comments[e],this.valuesOptions&&delete this.valuesOptions[e],this},n.prototype.isReservedId=function(e){return t.isReservedId(this.reserved,e)},n.prototype.isReservedName=function(e){return t.isReservedName(this.reserved,e)},_enum}function requireEncoder(){if(hasRequiredEncoder)return encoder_1;hasRequiredEncoder=1,encoder_1=function(i){for(var o,a=r.codegen(["m","w"],i.name+"$encode")("if(!w)")("w=Writer.create()"),s=i.fieldsArray.slice().sort(r.compareFieldsById),c=0;s.length>c;++c){var u=s[c].resolve(),l=i._fieldsArray.indexOf(u),d=u.resolvedType instanceof e?"int32":u.type,p=t.basic[d];o="m"+r.safeProp(u.name),u.map?(a("if(%s!=null&&Object.hasOwnProperty.call(m,%j)){",o,u.name)("for(var ks=Object.keys(%s),i=0;i<ks.length;++i){",o)("w.uint32(%i).fork().uint32(%i).%s(ks[i])",(u.id<<3|2)>>>0,8|t.mapKey[u.keyType],u.keyType),void 0===p?a("types[%i].encode(%s[ks[i]],w.uint32(18).fork()).ldelim().ldelim()",l,o):a(".uint32(%i).%s(%s[ks[i]]).ldelim()",16|p,d,o),a("}")("}")):u.repeated?(a("if(%s!=null&&%s.length){",o,o),u.packed&&void 0!==t.packed[d]?a("w.uint32(%i).fork()",(u.id<<3|2)>>>0)("for(var i=0;i<%s.length;++i)",o)("w.%s(%s[i])",d,o)("w.ldelim()"):(a("for(var i=0;i<%s.length;++i)",o),void 0===p?n(a,u,l,o+"[i]"):a("w.uint32(%i).%s(%s[i])",(u.id<<3|p)>>>0,d,o)),a("}")):(u.optional&&a("if(%s!=null&&Object.hasOwnProperty.call(m,%j))",o,u.name),void 0===p?n(a,u,l,o):a("w.uint32(%i).%s(%s)",(u.id<<3|p)>>>0,d,o))}return a("return w")};var e=require_enum(),t=requireTypes(),r=requireUtil();function n(e,t,r,n){return t.resolvedType.group?e("types[%i].encode(%s,w.uint32(%i)).uint32(%i)",r,n,(t.id<<3|3)>>>0,(t.id<<3|4)>>>0):e("types[%i].encode(%s,w.uint32(%i).fork()).ldelim()",r,n,(t.id<<3|2)>>>0)}return encoder_1}!function(e){var t=message;e[".google.protobuf.Any"]={fromObject:function(e){if(e&&e["@type"]){var t=e["@type"].substring(e["@type"].lastIndexOf("/")+1),r=this.lookup(t);if(r){var n="."===e["@type"].charAt(0)?e["@type"].slice(1):e["@type"];return-1===n.indexOf("/")&&(n="/"+n),this.create({type_url:n,value:r.encode(r.fromObject(e)).finish()})}}return this.fromObject(e)},toObject:function(e,r){var n="",i="";if(r&&r.json&&e.type_url&&e.value){i=e.type_url.substring(e.type_url.lastIndexOf("/")+1),n=e.type_url.substring(0,e.type_url.lastIndexOf("/")+1);var o=this.lookup(i);o&&(e=o.decode(e.value))}if(!(e instanceof this.ctor)&&e instanceof t){var a=e.$type.toObject(e,r),s="."===e.$type.fullName[0]?e.$type.fullName.slice(1):e.$type.fullName;return""===n&&(n="type.googleapis.com/"),a["@type"]=i=n+s,a}return this.toObject(e,r)}}}(wrappers);var protobuf=indexLight.exports=indexMinimal;function load(e,t,r){return"function"==typeof t?(r=t,t=new protobuf.Root):t||(t=new protobuf.Root),t.load(e,r)}function loadSync(e,t){return t||(t=new protobuf.Root),t.loadSync(e)}protobuf.build="light",protobuf.load=load,protobuf.loadSync=loadSync,protobuf.encoder=requireEncoder(),protobuf.decoder=requireDecoder(),protobuf.verifier=requireVerifier(),protobuf.converter=requireConverter(),protobuf.ReflectionObject=requireObject(),protobuf.Namespace=requireNamespace(),protobuf.Root=requireRoot(),protobuf.Enum=require_enum(),protobuf.Type=requireType(),protobuf.Field=requireField(),protobuf.OneOf=requireOneof(),protobuf.MapField=requireMapfield(),protobuf.Service=requireService(),protobuf.Method=requireMethod(),protobuf.Message=message,protobuf.wrappers=wrappers,protobuf.types=requireTypes(),protobuf.util=requireUtil(),protobuf.ReflectionObject._configure(protobuf.Root),protobuf.Namespace._configure(protobuf.Type,protobuf.Service,protobuf.Enum),protobuf.Root._configure(protobuf.Type),protobuf.Field._configure(protobuf.Type);var indexLightExports=indexLight.exports,light=indexLightExports,wasm$1=null;try{wasm$1=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch(e){}function Long$1(e,t,r){this.low=0|e,this.high=0|t,this.unsigned=!!r}function isLong$1(e){return!0===(e&&e.__isLong__)}function ctz32$1(e){var t=Math.clz32(e&-e);return e?31-t:t}Object.defineProperty(Long$1.prototype,"__isLong__",{value:!0}),Long$1.isLong=isLong$1;var INT_CACHE$1={},UINT_CACHE$1={};function fromInt$1(e,t){var r,n,i;return t?(i=(e>>>=0)>=0&&256>e)&&(n=UINT_CACHE$1[e])?n:(r=fromBits$1(e,0,!0),i&&(UINT_CACHE$1[e]=r),r):(i=(e|=0)>=-128&&128>e)&&(n=INT_CACHE$1[e])?n:(r=fromBits$1(e,0>e?-1:0,!1),i&&(INT_CACHE$1[e]=r),r)}function fromNumber$1(e,t){if(isNaN(e))return t?UZERO$1:ZERO$1;if(t){if(0>e)return UZERO$1;if(e>=TWO_PWR_64_DBL$1)return MAX_UNSIGNED_VALUE$1}else{if(-0x8000000000000000>=e)return MIN_VALUE$1;if(e+1>=TWO_PWR_63_DBL$1)return MAX_VALUE$1}return 0>e?fromNumber$1(-e,t).neg():fromBits$1(e%TWO_PWR_32_DBL$1|0,e/TWO_PWR_32_DBL$1|0,t)}function fromBits$1(e,t,r){return new Long$1(e,t,r)}Long$1.fromInt=fromInt$1,Long$1.fromNumber=fromNumber$1,Long$1.fromBits=fromBits$1;var pow_dbl$1=Math.pow;function fromString$1(e,t,r){if(0===e.length)throw Error("empty string");if("number"==typeof t?(r=t,t=!1):t=!!t,"NaN"===e||"Infinity"===e||"+Infinity"===e||"-Infinity"===e)return t?UZERO$1:ZERO$1;if(2>(r=r||10)||r>36)throw RangeError("radix");var n;if((n=e.indexOf("-"))>0)throw Error("interior hyphen");if(0===n)return fromString$1(e.substring(1),t,r).neg();for(var i=fromNumber$1(pow_dbl$1(r,8)),o=ZERO$1,a=0;e.length>a;a+=8){var s=Math.min(8,e.length-a),c=parseInt(e.substring(a,a+s),r);if(8>s){var u=fromNumber$1(pow_dbl$1(r,s));o=o.mul(u).add(fromNumber$1(c))}else o=(o=o.mul(i)).add(fromNumber$1(c))}return o.unsigned=t,o}function fromValue$1(e,t){return"number"==typeof e?fromNumber$1(e,t):"string"==typeof e?fromString$1(e,t):fromBits$1(e.low,e.high,"boolean"==typeof t?t:e.unsigned)}Long$1.fromString=fromString$1,Long$1.fromValue=fromValue$1;var TWO_PWR_16_DBL$1=65536,TWO_PWR_24_DBL$1=1<<24,TWO_PWR_32_DBL$1=TWO_PWR_16_DBL$1*TWO_PWR_16_DBL$1,TWO_PWR_64_DBL$1=TWO_PWR_32_DBL$1*TWO_PWR_32_DBL$1,TWO_PWR_63_DBL$1=TWO_PWR_64_DBL$1/2,TWO_PWR_24$1=fromInt$1(TWO_PWR_24_DBL$1),ZERO$1=fromInt$1(0);Long$1.ZERO=ZERO$1;var UZERO$1=fromInt$1(0,!0);Long$1.UZERO=UZERO$1;var ONE$1=fromInt$1(1);Long$1.ONE=ONE$1;var UONE$1=fromInt$1(1,!0);Long$1.UONE=UONE$1;var NEG_ONE$1=fromInt$1(-1);Long$1.NEG_ONE=NEG_ONE$1;var MAX_VALUE$1=fromBits$1(-1,2147483647,!1);Long$1.MAX_VALUE=MAX_VALUE$1;var MAX_UNSIGNED_VALUE$1=fromBits$1(-1,-1,!0);Long$1.MAX_UNSIGNED_VALUE=MAX_UNSIGNED_VALUE$1;var MIN_VALUE$1=fromBits$1(0,-2147483648,!1);Long$1.MIN_VALUE=MIN_VALUE$1;var LongPrototype$1=Long$1.prototype;LongPrototype$1.toInt=function(){return this.unsigned?this.low>>>0:this.low},LongPrototype$1.toNumber=function(){return this.unsigned?(this.high>>>0)*TWO_PWR_32_DBL$1+(this.low>>>0):this.high*TWO_PWR_32_DBL$1+(this.low>>>0)},LongPrototype$1.toString=function(e){if(2>(e=e||10)||e>36)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative()){if(this.eq(MIN_VALUE$1)){var t=fromNumber$1(e),r=this.div(t),n=r.mul(t).sub(this);return r.toString(e)+n.toInt().toString(e)}return"-"+this.neg().toString(e)}for(var i=fromNumber$1(pow_dbl$1(e,6),this.unsigned),o=this,a="";;){var s=o.div(i),c=(o.sub(s.mul(i)).toInt()>>>0).toString(e);if((o=s).isZero())return c+a;for(;6>c.length;)c="0"+c;a=""+c+a}},LongPrototype$1.getHighBits=function(){return this.high},LongPrototype$1.getHighBitsUnsigned=function(){return this.high>>>0},LongPrototype$1.getLowBits=function(){return this.low},LongPrototype$1.getLowBitsUnsigned=function(){return this.low>>>0},LongPrototype$1.getNumBitsAbs=function(){if(this.isNegative())return this.eq(MIN_VALUE$1)?64:this.neg().getNumBitsAbs();for(var e=0!=this.high?this.high:this.low,t=31;t>0&&!(e&1<<t);t--);return 0!=this.high?t+33:t+1},LongPrototype$1.isZero=function(){return 0===this.high&&0===this.low},LongPrototype$1.eqz=LongPrototype$1.isZero,LongPrototype$1.isNegative=function(){return!this.unsigned&&0>this.high},LongPrototype$1.isPositive=function(){return this.unsigned||this.high>=0},LongPrototype$1.isOdd=function(){return!(1&~this.low)},LongPrototype$1.isEven=function(){return!(1&this.low)},LongPrototype$1.equals=function(e){return isLong$1(e)||(e=fromValue$1(e)),(this.unsigned===e.unsigned||this.high>>>31!=1||e.high>>>31!=1)&&this.high===e.high&&this.low===e.low},LongPrototype$1.eq=LongPrototype$1.equals,LongPrototype$1.notEquals=function(e){return!this.eq(e)},LongPrototype$1.neq=LongPrototype$1.notEquals,LongPrototype$1.ne=LongPrototype$1.notEquals,LongPrototype$1.lessThan=function(e){return 0>this.comp(e)},LongPrototype$1.lt=LongPrototype$1.lessThan,LongPrototype$1.lessThanOrEqual=function(e){return 0>=this.comp(e)},LongPrototype$1.lte=LongPrototype$1.lessThanOrEqual,LongPrototype$1.le=LongPrototype$1.lessThanOrEqual,LongPrototype$1.greaterThan=function(e){return this.comp(e)>0},LongPrototype$1.gt=LongPrototype$1.greaterThan,LongPrototype$1.greaterThanOrEqual=function(e){return this.comp(e)>=0},LongPrototype$1.gte=LongPrototype$1.greaterThanOrEqual,LongPrototype$1.ge=LongPrototype$1.greaterThanOrEqual,LongPrototype$1.compare=function(e){if(isLong$1(e)||(e=fromValue$1(e)),this.eq(e))return 0;var t=this.isNegative(),r=e.isNegative();return t&&!r?-1:!t&&r?1:this.unsigned?e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1:this.sub(e).isNegative()?-1:1},LongPrototype$1.comp=LongPrototype$1.compare,LongPrototype$1.negate=function(){return!this.unsigned&&this.eq(MIN_VALUE$1)?MIN_VALUE$1:this.not().add(ONE$1)},LongPrototype$1.neg=LongPrototype$1.negate,LongPrototype$1.add=function(e){isLong$1(e)||(e=fromValue$1(e));var t=0,r=0,n=0,i=0;return n+=(i+=(65535&this.low)+(65535&e.low))>>>16,r+=(n+=(this.low>>>16)+(e.low>>>16))>>>16,t+=(r+=(65535&this.high)+(65535&e.high))>>>16,t+=(this.high>>>16)+(e.high>>>16),fromBits$1((n&=65535)<<16|(i&=65535),(t&=65535)<<16|(r&=65535),this.unsigned)},LongPrototype$1.subtract=function(e){return isLong$1(e)||(e=fromValue$1(e)),this.add(e.neg())},LongPrototype$1.sub=LongPrototype$1.subtract,LongPrototype$1.multiply=function(e){if(this.isZero())return this;if(isLong$1(e)||(e=fromValue$1(e)),wasm$1)return fromBits$1(wasm$1.mul(this.low,this.high,e.low,e.high),wasm$1.get_high(),this.unsigned);if(e.isZero())return this.unsigned?UZERO$1:ZERO$1;if(this.eq(MIN_VALUE$1))return e.isOdd()?MIN_VALUE$1:ZERO$1;if(e.eq(MIN_VALUE$1))return this.isOdd()?MIN_VALUE$1:ZERO$1;if(this.isNegative())return e.isNegative()?this.neg().mul(e.neg()):this.neg().mul(e).neg();if(e.isNegative())return this.mul(e.neg()).neg();if(this.lt(TWO_PWR_24$1)&&e.lt(TWO_PWR_24$1))return fromNumber$1(this.toNumber()*e.toNumber(),this.unsigned);var t=65535&this.high,r=this.low>>>16,n=65535&this.low,i=65535&e.high,o=e.low>>>16,a=65535&e.low,s=0,c=0,u=0,l=0;return u+=(l+=n*a)>>>16,c+=(u+=r*a)>>>16,u&=65535,c+=(u+=n*o)>>>16,s+=(c+=t*a)>>>16,c&=65535,s+=(c+=r*o)>>>16,c&=65535,s+=(c+=n*i)>>>16,s+=(this.high>>>16)*a+t*o+r*i+n*(e.high>>>16),fromBits$1((u&=65535)<<16|(l&=65535),(s&=65535)<<16|(c&=65535),this.unsigned)},LongPrototype$1.mul=LongPrototype$1.multiply,LongPrototype$1.divide=function(e){if(isLong$1(e)||(e=fromValue$1(e)),e.isZero())throw Error("division by zero");var t,r,n;if(wasm$1)return this.unsigned||-2147483648!==this.high||-1!==e.low||-1!==e.high?fromBits$1((this.unsigned?wasm$1.div_u:wasm$1.div_s)(this.low,this.high,e.low,e.high),wasm$1.get_high(),this.unsigned):this;if(this.isZero())return this.unsigned?UZERO$1:ZERO$1;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return UZERO$1;if(e.gt(this.shru(1)))return UONE$1;n=UZERO$1}else{if(this.eq(MIN_VALUE$1))return e.eq(ONE$1)||e.eq(NEG_ONE$1)?MIN_VALUE$1:e.eq(MIN_VALUE$1)?ONE$1:(t=this.shr(1).div(e).shl(1)).eq(ZERO$1)?e.isNegative()?ONE$1:NEG_ONE$1:(r=this.sub(e.mul(t)),n=t.add(r.div(e)));if(e.eq(MIN_VALUE$1))return this.unsigned?UZERO$1:ZERO$1;if(this.isNegative())return e.isNegative()?this.neg().div(e.neg()):this.neg().div(e).neg();if(e.isNegative())return this.div(e.neg()).neg();n=ZERO$1}for(r=this;r.gte(e);){t=Math.max(1,Math.floor(r.toNumber()/e.toNumber()));for(var i=Math.ceil(Math.log(t)/Math.LN2),o=i>48?pow_dbl$1(2,i-48):1,a=fromNumber$1(t),s=a.mul(e);s.isNegative()||s.gt(r);)s=(a=fromNumber$1(t-=o,this.unsigned)).mul(e);a.isZero()&&(a=ONE$1),n=n.add(a),r=r.sub(s)}return n},LongPrototype$1.div=LongPrototype$1.divide,LongPrototype$1.modulo=function(e){return isLong$1(e)||(e=fromValue$1(e)),wasm$1?fromBits$1((this.unsigned?wasm$1.rem_u:wasm$1.rem_s)(this.low,this.high,e.low,e.high),wasm$1.get_high(),this.unsigned):this.sub(this.div(e).mul(e))},LongPrototype$1.mod=LongPrototype$1.modulo,LongPrototype$1.rem=LongPrototype$1.modulo,LongPrototype$1.not=function(){return fromBits$1(~this.low,~this.high,this.unsigned)},LongPrototype$1.countLeadingZeros=function(){return this.high?Math.clz32(this.high):Math.clz32(this.low)+32},LongPrototype$1.clz=LongPrototype$1.countLeadingZeros,LongPrototype$1.countTrailingZeros=function(){return this.low?ctz32$1(this.low):ctz32$1(this.high)+32},LongPrototype$1.ctz=LongPrototype$1.countTrailingZeros,LongPrototype$1.and=function(e){return isLong$1(e)||(e=fromValue$1(e)),fromBits$1(this.low&e.low,this.high&e.high,this.unsigned)},LongPrototype$1.or=function(e){return isLong$1(e)||(e=fromValue$1(e)),fromBits$1(this.low|e.low,this.high|e.high,this.unsigned)},LongPrototype$1.xor=function(e){return isLong$1(e)||(e=fromValue$1(e)),fromBits$1(this.low^e.low,this.high^e.high,this.unsigned)},LongPrototype$1.shiftLeft=function(e){return isLong$1(e)&&(e=e.toInt()),0==(e&=63)?this:32>e?fromBits$1(this.low<<e,this.high<<e|this.low>>>32-e,this.unsigned):fromBits$1(0,this.low<<e-32,this.unsigned)},LongPrototype$1.shl=LongPrototype$1.shiftLeft,LongPrototype$1.shiftRight=function(e){return isLong$1(e)&&(e=e.toInt()),0==(e&=63)?this:32>e?fromBits$1(this.low>>>e|this.high<<32-e,this.high>>e,this.unsigned):fromBits$1(this.high>>e-32,0>this.high?-1:0,this.unsigned)},LongPrototype$1.shr=LongPrototype$1.shiftRight,LongPrototype$1.shiftRightUnsigned=function(e){return isLong$1(e)&&(e=e.toInt()),0==(e&=63)?this:32>e?fromBits$1(this.low>>>e|this.high<<32-e,this.high>>>e,this.unsigned):fromBits$1(32===e?this.high:this.high>>>e-32,0,this.unsigned)},LongPrototype$1.shru=LongPrototype$1.shiftRightUnsigned,LongPrototype$1.shr_u=LongPrototype$1.shiftRightUnsigned,LongPrototype$1.rotateLeft=function(e){var t;return isLong$1(e)&&(e=e.toInt()),0==(e&=63)?this:32===e?fromBits$1(this.high,this.low,this.unsigned):32>e?fromBits$1(this.low<<e|this.high>>>(t=32-e),this.high<<e|this.low>>>t,this.unsigned):fromBits$1(this.high<<(e-=32)|this.low>>>(t=32-e),this.low<<e|this.high>>>t,this.unsigned)},LongPrototype$1.rotl=LongPrototype$1.rotateLeft,LongPrototype$1.rotateRight=function(e){var t;return isLong$1(e)&&(e=e.toInt()),0==(e&=63)?this:32===e?fromBits$1(this.high,this.low,this.unsigned):32>e?fromBits$1(this.high<<(t=32-e)|this.low>>>e,this.low<<t|this.high>>>e,this.unsigned):fromBits$1(this.low<<(t=32-(e-=32))|this.high>>>e,this.high<<t|this.low>>>e,this.unsigned)},LongPrototype$1.rotr=LongPrototype$1.rotateRight,LongPrototype$1.toSigned=function(){return this.unsigned?fromBits$1(this.low,this.high,!1):this},LongPrototype$1.toUnsigned=function(){return this.unsigned?this:fromBits$1(this.low,this.high,!0)},LongPrototype$1.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()},LongPrototype$1.toBytesLE=function(){var e=this.high,t=this.low;return[255&t,t>>>8&255,t>>>16&255,t>>>24,255&e,e>>>8&255,e>>>16&255,e>>>24]},LongPrototype$1.toBytesBE=function(){var e=this.high,t=this.low;return[e>>>24,e>>>16&255,e>>>8&255,255&e,t>>>24,t>>>16&255,t>>>8&255,255&t]},Long$1.fromBytes=function(e,t,r){return r?Long$1.fromBytesLE(e,t):Long$1.fromBytesBE(e,t)},Long$1.fromBytesLE=function(e,t){return new Long$1(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,t)},Long$1.fromBytesBE=function(e,t){return new Long$1(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],t)};var fakeIdToCallback={},lastFakeId=0,addTimer=function(e,t){return"interval"===(arguments.length>2&&void 0!==arguments[2]?arguments[2]:"timeout")?window.setInterval(e,t):window.setTimeout(e,t)},removeTimer=function(e){return"interval"===(arguments.length>1&&void 0!==arguments[1]?arguments[1]:"timeout")?window.clearInterval(e):window.clearTimeout(e)};function _createForOfIteratorHelper$d(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=_unsupportedIterableToArray$e(e))||t){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return e.length>n?{done:!1,value:e[n++]}:{done:!0}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function _unsupportedIterableToArray$e(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray$e(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray$e(e,t):void 0}}function _arrayLikeToArray$e(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);t>r;r++)n[r]=e[r];return n}!function(e){var t,r;if(!/MSIE 10/i.test(navigator.userAgent))try{t=new Blob(["\nconst fakeIdToId = {};\nonmessage = (event) => {\n const { fakeId, name, time } = event.data;\n switch (name) {\n case 'setInterval':\n fakeIdToId[fakeId] = setInterval(() => {\n postMessage({ fakeId });\n }, time);\n break;\n case 'clearInterval':\n if (fakeIdToId[fakeId] !== undefined) {\n clearInterval(fakeIdToId[fakeId]);\n delete fakeIdToId[fakeId];\n }\n break;\n case 'setTimeout':\n fakeIdToId[fakeId] = setTimeout(() => {\n postMessage({ fakeId });\n if (fakeIdToId[fakeId] !== undefined) {\n delete fakeIdToId[fakeId];\n }\n }, time);\n break;\n case 'clearTimeout':\n if (fakeIdToId[fakeId] !== undefined) {\n clearTimeout(fakeIdToId[fakeId]);\n delete fakeIdToId[fakeId];\n }\n break;\n }\n}\n"]),e=window.URL.createObjectURL(t)}catch(e){}if("undefined"!=typeof Worker)try{r=new Worker(e),addTimer=function(e,t,n){var i=lastFakeId++;return fakeIdToCallback[i]={callback:e,time:t,isTimeout:"timeout"===n},r.postMessage({name:"interval"===n?"setInterval":"setTimeout",fakeId:i,time:t}),i},removeTimer=function(e,t){fakeIdToCallback[e]&&(delete fakeIdToCallback[e],r.postMessage({name:"timeout"===t?"clearInterval":"clearTimeout",fakeId:e}))},r.onmessage=function(e){var t,r,n=e.data.fakeId;fakeIdToCallback[n]&&(r=(t=fakeIdToCallback[n]).callback,t.isTimeout&&t.isTimeout&&delete fakeIdToCallback[n]),r&&r()},r.onerror=function(e){console.error(e)}}catch(e){console.error("Initialisation failed")}}("timerWorker.js"),light.util.Long=Long$1,light.util.LongBits.prototype.toLong=function(e){return 0===this.hi?this.lo:new Long$1(this.lo,this.hi,e)},light.configure();var type=function(e){return Object.prototype.toString.call(e).match(/\[object (.*?)\]/)[1].toLowerCase()},isNumber=function(e){return"number"===type(e)},isString=function(e){return"string"===type(e)},isObject=function(e){return"object"===type(e)},uniqBy=function(){var e,t=arguments.length>1?arguments[1]:void 0,r=[],n={},i=_createForOfIteratorHelper$d(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]);try{for(i.s();!(e=i.n()).done;){var o=e.value;n[o[t]]||(r.push(o),n[o[t]]=1)}}catch(e){i.e(e)}finally{i.f()}return r},createUuid=function(e){var t="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}));return t.substring(0,e||t.length)},ensureDigits=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2;if(2===t)return 10>e?"0".concat(e):"".concat(e);if(3===t){if(10>e)return"00".concat(e);if(100>e)return"0".concat(e)}return"".concat(e)},formatToBeijingTime=function(e){if(!(e instanceof Date))return"[not a Date]";var t=e.getTime()+288e5,r=new Date(t),n="";try{n="".concat(r.getUTCFullYear(),"-").concat(ensureDigits(r.getUTCMonth()+1),"-").concat(ensureDigits(r.getUTCDate())," ").concat(ensureDigits(r.getUTCHours()),":").concat(ensureDigits(r.getUTCMinutes()),":").concat(ensureDigits(r.getUTCSeconds()),".").concat(ensureDigits(r.getUTCMilliseconds(),3))}catch(e){}return n},tryJsonStringify=function(e){if(void 0===e)return"[undefined]";try{if(e instanceof Set||e instanceof Map)return JSON.stringify(Array.from(e));if(e instanceof Error){var t={name:e.name,message:e.message,stack:e.stack};return e.log&&(t.log=e.log),e.code&&(t.code=e.code),JSON.stringify(t)}return JSON.stringify(e)}catch(e){return"[tryJsonStringify failed]"}},Debouncer=_createClass((function e(){_classCallCheck(this,e),Object.defineProperty(this,"timer",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}),[{key:"debounce",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:500;clearTimeout(this.timer),this.timer=setTimeout((function(){e&&e(),t.timer=null}),r)}}]),isPrivateIP=function(e){var t=e.split(".").reduce((function(e,t,r){return e+Number(t)*Math.pow(256,3-r)}),0);return t>=167772160&&184549375>=t||t>=2886729728&&2887778303>=t||t>=3232235520&&3232301055>=t},toBase64=function(e){return Base64.stringify(UTF8.parse(e))},parseBase64=function(e){return JSON.parse(Base64.parse(e).toString(UTF8))},getProtobufRoot=function(e){return light.Root.fromJSON(e)},diffTime=0,setDiffTime=function(e){diffTime=e},getTime=function(){return Date.now()+diffTime},taskQueue$1=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,t=[],r=0,n=!1,i=function(){var n=_asyncToGenerator(_regeneratorRuntime.mark((function n(){var o;return _regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(r>=e||!t.length){n.next=16;break}if(r++,!(o=t.shift())){n.next=14;break}return n.prev=4,n.next=7,o();case 7:n.next=12;break;case 9:n.prev=9,n.t0=n.catch(4),console.log(n.t0);case 12:r--,i();case 14:n.next=0;break;case 16:case"end":return n.stop()}}),n,null,[[4,9]])})));return function(){return n.apply(this,arguments)}}();return{add:function(e){t.push(e),n&&i()},start:function(){n=!0,i()}}},awaitTime$1=function(e){return new Promise((function(t){addTimer(t,1e3*e)}))},LIBVERSION="1.0.37",EMPTY="",UNKNOWN="?",FUNC_TYPE="function",UNDEF_TYPE="undefined",OBJ_TYPE="object",STR_TYPE="string",MAJOR="major",MODEL="model",NAME$1="name",TYPE$2="type",VENDOR="vendor",VERSION="version",ARCHITECTURE="architecture",CONSOLE="console",MOBILE="mobile",TABLET="tablet",SMARTTV="smarttv",WEARABLE="wearable",EMBEDDED="embedded",UA_MAX_LENGTH=500,AMAZON="Amazon",APPLE="Apple",ASUS="ASUS",BLACKBERRY="BlackBerry",BROWSER="Browser",CHROME="Chrome",EDGE="Edge",FIREFOX="Firefox",GOOGLE="Google",HUAWEI="Huawei",LG="LG",MICROSOFT="Microsoft",MOTOROLA="Motorola",OPERA="Opera",SAMSUNG="Samsung",SHARP="Sharp",SONY="Sony",XIAOMI="Xiaomi",ZEBRA="Zebra",FACEBOOK="Facebook",CHROMIUM_OS="Chromium OS",MAC_OS="macOS",extend=function(e,t){var r={};for(var n in e)r[n]=t[n]&&t[n].length%2==0?t[n].concat(e[n]):e[n];return r},enumerize=function(e){for(var t={},r=0;e.length>r;r++)t[e[r].toUpperCase()]=e[r];return t},has=function(e,t){return _typeof$1(e)===STR_TYPE&&-1!==lowerize(t).indexOf(lowerize(e))},lowerize=function(e){return e.toLowerCase()},majorize=function(e){return _typeof$1(e)===STR_TYPE?e.replace(/[^\d\.]/g,EMPTY).split(".")[0]:void 0},trim=function(e,t){if(_typeof$1(e)===STR_TYPE)return e=e.replace(/^\s\s*/,EMPTY),_typeof$1(t)===UNDEF_TYPE?e:e.substring(0,UA_MAX_LENGTH)},rgxMapper=function(e,t){for(var r,n,i,o,a,s,c=0;t.length>c&&!a;){var u=t[c],l=t[c+1];for(r=n=0;u.length>r&&!a&&u[r];)if(a=u[r++].exec(e))for(i=0;l.length>i;i++)s=a[++n],_typeof$1(o=l[i])===OBJ_TYPE&&o.length>0?2===o.length?this[o[0]]=_typeof$1(o[1])==FUNC_TYPE?o[1].call(this,s):o[1]:3===o.length?this[o[0]]=_typeof$1(o[1])!==FUNC_TYPE||o[1].exec&&o[1].test?s?s.replace(o[1],o[2]):void 0:s?o[1].call(this,s,o[2]):void 0:4===o.length&&(this[o[0]]=s?o[3].call(this,s.replace(o[1],o[2])):void 0):this[o]=s||void 0;c+=2}},strMapper=function(e,t){for(var r in t)if(_typeof$1(t[r])===OBJ_TYPE&&t[r].length>0){for(var n=0;t[r].length>n;n++)if(has(t[r][n],e))return r===UNKNOWN?void 0:r}else if(has(t[r],e))return r===UNKNOWN?void 0:r;return e},oldSafariMap={"1.0":"/8",1.2:"/1",1.3:"/3","2.0":"/412","2.0.2":"/416","2.0.3":"/417","2.0.4":"/419","?":"/"},windowsVersionMap={ME:"4.90","NT 3.11":"NT3.51","NT 4.0":"NT4.0",2e3:"NT 5.0",XP:["NT 5.1","NT 5.2"],Vista:"NT 6.0",7:"NT 6.1",8:"NT 6.2",8.1:"NT 6.3",10:["NT 6.4","NT 10.0"],RT:"ARM"},regexes={browser:[[/\b(?:crmo|crios)\/([\w\.]+)/i],[VERSION,[NAME$1,"Chrome"]],[/edg(?:e|ios|a)?\/([\w\.]+)/i],[VERSION,[NAME$1,"Edge"]],[/(opera mini)\/([-\w\.]+)/i,/(opera [mobiletab]{3,6})\b.+version\/([-\w\.]+)/i,/(opera)(?:.+version\/|[\/ ]+)([\w\.]+)/i],[NAME$1,VERSION],[/opios[\/ ]+([\w\.]+)/i],[VERSION,[NAME$1,OPERA+" Mini"]],[/\bopr\/([\w\.]+)/i],[VERSION,[NAME$1,OPERA]],[/\bb[ai]*d(?:uhd|[ub]*[aekoprswx]{5,6})[\/ ]?([\w\.]+)/i],[VERSION,[NAME$1,"Baidu"]],[/(kindle)\/([\w\.]+)/i,/(lunascape|maxthon|netfront|jasmine|blazer)[\/ ]?([\w\.]*)/i,/(avant|iemobile|slim)\s?(?:browser)?[\/ ]?([\w\.]*)/i,/(?:ms|\()(ie) ([\w\.]+)/i,/(flock|rockmelt|midori|epiphany|silk|skyfire|bolt|iron|vivaldi|iridium|phantomjs|bowser|quark|qupzilla|falkon|rekonq|puffin|brave|whale(?!.+naver)|qqbrowserlite|qq|duckduckgo)\/([-\w\.]+)/i,/(heytap|ovi)browser\/([\d\.]+)/i,/(weibo)__([\d\.]+)/i],[NAME$1,VERSION],[/(?:\buc? ?browser|(?:juc.+)ucweb)[\/ ]?([\w\.]+)/i],[VERSION,[NAME$1,"UC"+BROWSER]],[/microm.+\bqbcore\/([\w\.]+)/i,/\bqbcore\/([\w\.]+).+microm/i,/micromessenger\/([\w\.]+)/i],[VERSION,[NAME$1,"WeChat"]],[/konqueror\/([\w\.]+)/i],[VERSION,[NAME$1,"Konqueror"]],[/trident.+rv[: ]([\w\.]{1,9})\b.+like gecko/i],[VERSION,[NAME$1,"IE"]],[/ya(?:search)?browser\/([\w\.]+)/i],[VERSION,[NAME$1,"Yandex"]],[/slbrowser\/([\w\.]+)/i],[VERSION,[NAME$1,"Smart Lenovo "+BROWSER]],[/(avast|avg)\/([\w\.]+)/i],[[NAME$1,/(.+)/,"$1 Secure "+BROWSER],VERSION],[/\bfocus\/([\w\.]+)/i],[VERSION,[NAME$1,FIREFOX+" Focus"]],[/\bopt\/([\w\.]+)/i],[VERSION,[NAME$1,OPERA+" Touch"]],[/coc_coc\w+\/([\w\.]+)/i],[VERSION,[NAME$1,"Coc Coc"]],[/dolfin\/([\w\.]+)/i],[VERSION,[NAME$1,"Dolphin"]],[/coast\/([\w\.]+)/i],[VERSION,[NAME$1,OPERA+" Coast"]],[/miuibrowser\/([\w\.]+)/i],[VERSION,[NAME$1,"MIUI "+BROWSER]],[/fxios\/([-\w\.]+)/i],[VERSION,[NAME$1,FIREFOX]],[/\bqihu|(qi?ho?o?|360)browser/i],[[NAME$1,"360 "+BROWSER]],[/(oculus|sailfish|huawei|vivo)browser\/([\w\.]+)/i],[[NAME$1,/(.+)/,"$1 "+BROWSER],VERSION],[/samsungbrowser\/([\w\.]+)/i],[VERSION,[NAME$1,SAMSUNG+" Internet"]],[/(comodo_dragon)\/([\w\.]+)/i],[[NAME$1,/_/g," "],VERSION],[/metasr[\/ ]?([\d\.]+)/i],[VERSION,[NAME$1,"Sogou Explorer"]],[/(sogou)mo\w+\/([\d\.]+)/i],[[NAME$1,"Sogou Mobile"],VERSION],[/(electron)\/([\w\.]+) safari/i,/(tesla)(?: qtcarbrowser|\/(20\d\d\.[-\w\.]+))/i,/m?(qqbrowser|2345Explorer)[\/ ]?([\w\.]+)/i],[NAME$1,VERSION],[/(lbbrowser)/i,/\[(linkedin)app\]/i],[NAME$1],[/((?:fban\/fbios|fb_iab\/fb4a)(?!.+fbav)|;fbav\/([\w\.]+);)/i],[[NAME$1,FACEBOOK],VERSION],[/(Klarna)\/([\w\.]+)/i,/(kakao(?:talk|story))[\/ ]([\w\.]+)/i,/(naver)\(.*?(\d+\.[\w\.]+).*\)/i,/safari (line)\/([\w\.]+)/i,/\b(line)\/([\w\.]+)\/iab/i,/(alipay)client\/([\w\.]+)/i,/(chromium|instagram|snapchat)[\/ ]([-\w\.]+)/i],[NAME$1,VERSION],[/\bgsa\/([\w\.]+) .*safari\//i],[VERSION,[NAME$1,"GSA"]],[/musical_ly(?:.+app_?version\/|_)([\w\.]+)/i],[VERSION,[NAME$1,"TikTok"]],[/headlesschrome(?:\/([\w\.]+)| )/i],[VERSION,[NAME$1,CHROME+" Headless"]],[/ wv\).+(chrome)\/([\w\.]+)/i],[[NAME$1,CHROME+" WebView"],VERSION],[/droid.+ version\/([\w\.]+)\b.+(?:mobile safari|safari)/i],[VERSION,[NAME$1,"Android "+BROWSER]],[/(chrome|omniweb|arora|[tizenoka]{5} ?browser)\/v?([\w\.]+)/i],[NAME$1,VERSION],[/version\/([\w\.\,]+) .*mobile\/\w+ (safari)/i],[VERSION,[NAME$1,"Mobile Safari"]],[/version\/([\w(\.|\,)]+) .*(mobile ?safari|safari)/i],[VERSION,NAME$1],[/webkit.+?(mobile ?safari|safari)(\/[\w\.]+)/i],[NAME$1,[VERSION,strMapper,oldSafariMap]],[/(webkit|khtml)\/([\w\.]+)/i],[NAME$1,VERSION],[/(navigator|netscape\d?)\/([-\w\.]+)/i],[[NAME$1,"Netscape"],VERSION],[/mobile vr; rv:([\w\.]+)\).+firefox/i],[VERSION,[NAME$1,FIREFOX+" Reality"]],[/ekiohf.+(flow)\/([\w\.]+)/i,/(swiftfox)/i,/(icedragon|iceweasel|camino|chimera|fennec|maemo browser|minimo|conkeror|klar)[\/ ]?([\w\.\+]+)/i,/(seamonkey|k-meleon|icecat|iceape|firebird|phoenix|palemoon|basilisk|waterfox)\/([-\w\.]+)$/i,/(firefox)\/([\w\.]+)/i,/(mozilla)\/([\w\.]+) .+rv\:.+gecko\/\d+/i,/(polaris|lynx|dillo|icab|doris|amaya|w3m|netsurf|sleipnir|obigo|mosaic|(?:go|ice|up)[\. ]?browser)[-\/ ]?v?([\w\.]+)/i,/(links) \(([\w\.]+)/i,/panasonic;(viera)/i],[NAME$1,VERSION],[/(cobalt)\/([\w\.]+)/i],[NAME$1,[VERSION,/master.|lts./,""]]],cpu:[[/(?:(amd|x(?:(?:86|64)[-_])?|wow|win)64)[;\)]/i],[[ARCHITECTURE,"amd64"]],[/(ia32(?=;))/i],[[ARCHITECTURE,lowerize]],[/((?:i[346]|x)86)[;\)]/i],[[ARCHITECTURE,"ia32"]],[/\b(aarch64|arm(v?8e?l?|_?64))\b/i],[[ARCHITECTURE,"arm64"]],[/\b(arm(?:v[67])?ht?n?[fl]p?)\b/i],[[ARCHITECTURE,"armhf"]],[/windows (ce|mobile); ppc;/i],[[ARCHITECTURE,"arm"]],[/((?:ppc|powerpc)(?:64)?)(?: mac|;|\))/i],[[ARCHITECTURE,/ower/,EMPTY,lowerize]],[/(sun4\w)[;\)]/i],[[ARCHITECTURE,"sparc"]],[/((?:avr32|ia64(?=;))|68k(?=\))|\barm(?=v(?:[1-7]|[5-7]1)l?|;|eabi)|(?=atmel )avr|(?:irix|mips|sparc)(?:64)?\b|pa-risc)/i],[[ARCHITECTURE,lowerize]]],device:[[/\b(sch-i[89]0\d|shw-m380s|sm-[ptx]\w{2,4}|gt-[pn]\d{2,4}|sgh-t8[56]9|nexus 10)/i],[MODEL,[VENDOR,SAMSUNG],[TYPE$2,TABLET]],[/\b((?:s[cgp]h|gt|sm)-\w+|sc[g-]?[\d]+a?|galaxy nexus)/i,/samsung[- ]([-\w]+)/i,/sec-(sgh\w+)/i],[MODEL,[VENDOR,SAMSUNG],[TYPE$2,MOBILE]],[/(?:\/|\()(ip(?:hone|od)[\w, ]*)(?:\/|;)/i],[MODEL,[VENDOR,APPLE],[TYPE$2,MOBILE]],[/\((ipad);[-\w\),; ]+apple/i,/applecoremedia\/[\w\.]+ \((ipad)/i,/\b(ipad)\d\d?,\d\d?[;\]].+ios/i],[MODEL,[VENDOR,APPLE],[TYPE$2,TABLET]],[/(macintosh);/i],[MODEL,[VENDOR,APPLE]],[/\b(sh-?[altvz]?\d\d[a-ekm]?)/i],[MODEL,[VENDOR,SHARP],[TYPE$2,MOBILE]],[/\b((?:ag[rs][23]?|bah2?|sht?|btv)-a?[lw]\d{2})\b(?!.+d\/s)/i],[MODEL,[VENDOR,HUAWEI],[TYPE$2,TABLET]],[/(?:huawei|honor)([-\w ]+)[;\)]/i,/\b(nexus 6p|\w{2,4}e?-[atu]?[ln][\dx][012359c][adn]?)\b(?!.+d\/s)/i],[MODEL,[VENDOR,HUAWEI],[TYPE$2,MOBILE]],[/\b(poco[\w ]+|m2\d{3}j\d\d[a-z]{2})(?: bui|\))/i,/\b; (\w+) build\/hm\1/i,/\b(hm[-_ ]?note?[_ ]?(?:\d\w)?) bui/i,/\b(redmi[\-_ ]?(?:note|k)?[\w_ ]+)(?: bui|\))/i,/oid[^\)]+; (m?[12][0-389][01]\w{3,6}[c-y])( bui|; wv|\))/i,/\b(mi[-_ ]?(?:a\d|one|one[_ ]plus|note lte|max|cc)?[_ ]?(?:\d?\w?)[_ ]?(?:plus|se|lite)?)(?: bui|\))/i],[[MODEL,/_/g," "],[VENDOR,XIAOMI],[TYPE$2,MOBILE]],[/oid[^\)]+; (2\d{4}(283|rpbf)[cgl])( bui|\))/i,/\b(mi[-_ ]?(?:pad)(?:[\w_ ]+))(?: bui|\))/i],[[MODEL,/_/g," "],[VENDOR,XIAOMI],[TYPE$2,TABLET]],[/; (\w+) bui.+ oppo/i,/\b(cph[12]\d{3}|p(?:af|c[al]|d\w|e[ar])[mt]\d0|x9007|a101op)\b/i],[MODEL,[VENDOR,"OPPO"],[TYPE$2,MOBILE]],[/vivo (\w+)(?: bui|\))/i,/\b(v[12]\d{3}\w?[at])(?: bui|;)/i],[MODEL,[VENDOR,"Vivo"],[TYPE$2,MOBILE]],[/\b(rmx[1-3]\d{3})(?: bui|;|\))/i],[MODEL,[VENDOR,"Realme"],[TYPE$2,MOBILE]],[/\b(milestone|droid(?:[2-4x]| (?:bionic|x2|pro|razr))?:?( 4g)?)\b[\w ]+build\//i,/\bmot(?:orola)?[- ](\w*)/i,/((?:moto[\w\(\) ]+|xt\d{3,4}|nexus 6)(?= bui|\)))/i],[MODEL,[VENDOR,MOTOROLA],[TYPE$2,MOBILE]],[/\b(mz60\d|xoom[2 ]{0,2}) build\//i],[MODEL,[VENDOR,MOTOROLA],[TYPE$2,TABLET]],[/((?=lg)?[vl]k\-?\d{3}) bui| 3\.[-\w; ]{10}lg?-([06cv9]{3,4})/i],[MODEL,[VENDOR,LG],[TYPE$2,TABLET]],[/(lm(?:-?f100[nv]?|-[\w\.]+)(?= bui|\))|nexus [45])/i,/\blg[-e;\/ ]+((?!browser|netcast|android tv)\w+)/i,/\blg-?([\d\w]+) bui/i],[MODEL,[VENDOR,LG],[TYPE$2,MOBILE]],[/(ideatab[-\w ]+)/i,/lenovo ?(s[56]000[-\w]+|tab(?:[\w ]+)|yt[-\d\w]{6}|tb[-\d\w]{6})/i],[MODEL,[VENDOR,"Lenovo"],[TYPE$2,TABLET]],[/(?:maemo|nokia).*(n900|lumia \d+)/i,/nokia[-_ ]?([-\w\.]*)/i],[[MODEL,/_/g," "],[VENDOR,"Nokia"],[TYPE$2,MOBILE]],[/(pixel c)\b/i],[MODEL,[VENDOR,GOOGLE],[TYPE$2,TABLET]],[/droid.+; (pixel[\daxl ]{0,6})(?: bui|\))/i],[MODEL,[VENDOR,GOOGLE],[TYPE$2,MOBILE]],[/droid.+ (a?\d[0-2]{2}so|[c-g]\d{4}|so[-gl]\w+|xq-a\w[4-7][12])(?= bui|\).+chrome\/(?![1-6]{0,1}\d\.))/i],[MODEL,[VENDOR,SONY],[TYPE$2,MOBILE]],[/sony tablet [ps]/i,/\b(?:sony)?sgp\w+(?: bui|\))/i],[[MODEL,"Xperia Tablet"],[VENDOR,SONY],[TYPE$2,TABLET]],[/ (kb2005|in20[12]5|be20[12][59])\b/i,/(?:one)?(?:plus)? (a\d0\d\d)(?: b|\))/i],[MODEL,[VENDOR,"OnePlus"],[TYPE$2,MOBILE]],[/(alexa)webm/i,/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i,/(kf[a-z]+)( bui|\)).+silk\//i],[MODEL,[VENDOR,AMAZON],[TYPE$2,TABLET]],[/((?:sd|kf)[0349hijorstuw]+)( bui|\)).+silk\//i],[[MODEL,/(.+)/g,"Fire Phone $1"],[VENDOR,AMAZON],[TYPE$2,MOBILE]],[/(playbook);[-\w\),; ]+(rim)/i],[MODEL,VENDOR,[TYPE$2,TABLET]],[/\b((?:bb[a-f]|st[hv])100-\d)/i,/\(bb10; (\w+)/i],[MODEL,[VENDOR,BLACKBERRY],[TYPE$2,MOBILE]],[/(?:\b|asus_)(transfo[prime ]{4,10} \w+|eeepc|slider \w+|nexus 7|padfone|p00[cj])/i],[MODEL,[VENDOR,ASUS],[TYPE$2,TABLET]],[/ (z[bes]6[027][012][km][ls]|zenfone \d\w?)\b/i],[MODEL,[VENDOR,ASUS],[TYPE$2,MOBILE]],[/(nexus 9)/i],[MODEL,[VENDOR,"HTC"],[TYPE$2,TABLET]],[/(htc)[-;_ ]{1,2}([\w ]+(?=\)| bui)|\w+)/i,/(zte)[- ]([\w ]+?)(?: bui|\/|\))/i,/(alcatel|geeksphone|nexian|panasonic(?!(?:;|\.))|sony(?!-bra))[-_ ]?([-\w]*)/i],[VENDOR,[MODEL,/_/g," "],[TYPE$2,MOBILE]],[/droid.+; ([ab][1-7]-?[0178a]\d\d?)/i],[MODEL,[VENDOR,"Acer"],[TYPE$2,TABLET]],[/droid.+; (m[1-5] note) bui/i,/\bmz-([-\w]{2,})/i],[MODEL,[VENDOR,"Meizu"],[TYPE$2,MOBILE]],[/; ((?:power )?armor(?:[\w ]{0,8}))(?: bui|\))/i],[MODEL,[VENDOR,"Ulefone"],[TYPE$2,MOBILE]],[/(blackberry|benq|palm(?=\-)|sonyericsson|acer|asus|dell|meizu|motorola|polytron|infinix|tecno)[-_ ]?([-\w]*)/i,/(hp) ([\w ]+\w)/i,/(asus)-?(\w+)/i,/(microsoft); (lumia[\w ]+)/i,/(lenovo)[-_ ]?([-\w]+)/i,/(jolla)/i,/(oppo) ?([\w ]+) bui/i],[VENDOR,MODEL,[TYPE$2,MOBILE]],[/(kobo)\s(ereader|touch)/i,/(archos) (gamepad2?)/i,/(hp).+(touchpad(?!.+tablet)|tablet)/i,/(kindle)\/([\w\.]+)/i,/(nook)[\w ]+build\/(\w+)/i,/(dell) (strea[kpr\d ]*[\dko])/i,/(le[- ]+pan)[- ]+(\w{1,9}) bui/i,/(trinity)[- ]*(t\d{3}) bui/i,/(gigaset)[- ]+(q\w{1,9}) bui/i,/(vodafone) ([\w ]+)(?:\)| bui)/i],[VENDOR,MODEL,[TYPE$2,TABLET]],[/(surface duo)/i],[MODEL,[VENDOR,MICROSOFT],[TYPE$2,TABLET]],[/droid [\d\.]+; (fp\du?)(?: b|\))/i],[MODEL,[VENDOR,"Fairphone"],[TYPE$2,MOBILE]],[/(u304aa)/i],[MODEL,[VENDOR,"AT&T"],[TYPE$2,MOBILE]],[/\bsie-(\w*)/i],[MODEL,[VENDOR,"Siemens"],[TYPE$2,MOBILE]],[/\b(rct\w+) b/i],[MODEL,[VENDOR,"RCA"],[TYPE$2,TABLET]],[/\b(venue[\d ]{2,7}) b/i],[MODEL,[VENDOR,"Dell"],[TYPE$2,TABLET]],[/\b(q(?:mv|ta)\w+) b/i],[MODEL,[VENDOR,"Verizon"],[TYPE$2,TABLET]],[/\b(?:barnes[& ]+noble |bn[rt])([\w\+ ]*) b/i],[MODEL,[VENDOR,"Barnes & Noble"],[TYPE$2,TABLET]],[/\b(tm\d{3}\w+) b/i],[MODEL,[VENDOR,"NuVision"],[TYPE$2,TABLET]],[/\b(k88) b/i],[MODEL,[VENDOR,"ZTE"],[TYPE$2,TABLET]],[/\b(nx\d{3}j) b/i],[MODEL,[VENDOR,"ZTE"],[TYPE$2,MOBILE]],[/\b(gen\d{3}) b.+49h/i],[MODEL,[VENDOR,"Swiss"],[TYPE$2,MOBILE]],[/\b(zur\d{3}) b/i],[MODEL,[VENDOR,"Swiss"],[TYPE$2,TABLET]],[/\b((zeki)?tb.*\b) b/i],[MODEL,[VENDOR,"Zeki"],[TYPE$2,TABLET]],[/\b([yr]\d{2}) b/i,/\b(dragon[- ]+touch |dt)(\w{5}) b/i],[[VENDOR,"Dragon Touch"],MODEL,[TYPE$2,TABLET]],[/\b(ns-?\w{0,9}) b/i],[MODEL,[VENDOR,"Insignia"],[TYPE$2,TABLET]],[/\b((nxa|next)-?\w{0,9}) b/i],[MODEL,[VENDOR,"NextBook"],[TYPE$2,TABLET]],[/\b(xtreme\_)?(v(1[045]|2[015]|[3469]0|7[05])) b/i],[[VENDOR,"Voice"],MODEL,[TYPE$2,MOBILE]],[/\b(lvtel\-)?(v1[12]) b/i],[[VENDOR,"LvTel"],MODEL,[TYPE$2,MOBILE]],[/\b(ph-1) /i],[MODEL,[VENDOR,"Essential"],[TYPE$2,MOBILE]],[/\b(v(100md|700na|7011|917g).*\b) b/i],[MODEL,[VENDOR,"Envizen"],[TYPE$2,TABLET]],[/\b(trio[-\w\. ]+) b/i],[MODEL,[VENDOR,"MachSpeed"],[TYPE$2,TABLET]],[/\btu_(1491) b/i],[MODEL,[VENDOR,"Rotor"],[TYPE$2,TABLET]],[/(shield[\w ]+) b/i],[MODEL,[VENDOR,"Nvidia"],[TYPE$2,TABLET]],[/(sprint) (\w+)/i],[VENDOR,MODEL,[TYPE$2,MOBILE]],[/(kin\.[onetw]{3})/i],[[MODEL,/\./g," "],[VENDOR,MICROSOFT],[TYPE$2,MOBILE]],[/droid.+; (cc6666?|et5[16]|mc[239][23]x?|vc8[03]x?)\)/i],[MODEL,[VENDOR,ZEBRA],[TYPE$2,TABLET]],[/droid.+; (ec30|ps20|tc[2-8]\d[kx])\)/i],[MODEL,[VENDOR,ZEBRA],[TYPE$2,MOBILE]],[/smart-tv.+(samsung)/i],[VENDOR,[TYPE$2,SMARTTV]],[/hbbtv.+maple;(\d+)/i],[[MODEL,/^/,"SmartTV"],[VENDOR,SAMSUNG],[TYPE$2,SMARTTV]],[/(nux; netcast.+smarttv|lg (netcast\.tv-201\d|android tv))/i],[[VENDOR,LG],[TYPE$2,SMARTTV]],[/(apple) ?tv/i],[VENDOR,[MODEL,APPLE+" TV"],[TYPE$2,SMARTTV]],[/crkey/i],[[MODEL,CHROME+"cast"],[VENDOR,GOOGLE],[TYPE$2,SMARTTV]],[/droid.+aft(\w+)( bui|\))/i],[MODEL,[VENDOR,AMAZON],[TYPE$2,SMARTTV]],[/\(dtv[\);].+(aquos)/i,/(aquos-tv[\w ]+)\)/i],[MODEL,[VENDOR,SHARP],[TYPE$2,SMARTTV]],[/(bravia[\w ]+)( bui|\))/i],[MODEL,[VENDOR,SONY],[TYPE$2,SMARTTV]],[/(mitv-\w{5}) bui/i],[MODEL,[VENDOR,XIAOMI],[TYPE$2,SMARTTV]],[/Hbbtv.*(technisat) (.*);/i],[VENDOR,MODEL,[TYPE$2,SMARTTV]],[/\b(roku)[\dx]*[\)\/]((?:dvp-)?[\d\.]*)/i,/hbbtv\/\d+\.\d+\.\d+ +\([\w\+ ]*; *([\w\d][^;]*);([^;]*)/i],[[VENDOR,trim],[MODEL,trim],[TYPE$2,SMARTTV]],[/\b(android tv|smart[- ]?tv|opera tv|tv; rv:)\b/i],[[TYPE$2,SMARTTV]],[/(ouya)/i,/(nintendo) ([wids3utch]+)/i],[VENDOR,MODEL,[TYPE$2,CONSOLE]],[/droid.+; (shield) bui/i],[MODEL,[VENDOR,"Nvidia"],[TYPE$2,CONSOLE]],[/(playstation [345portablevi]+)/i],[MODEL,[VENDOR,SONY],[TYPE$2,CONSOLE]],[/\b(xbox(?: one)?(?!; xbox))[\); ]/i],[MODEL,[VENDOR,MICROSOFT],[TYPE$2,CONSOLE]],[/((pebble))app/i],[VENDOR,MODEL,[TYPE$2,WEARABLE]],[/(watch)(?: ?os[,\/]|\d,\d\/)[\d\.]+/i],[MODEL,[VENDOR,APPLE],[TYPE$2,WEARABLE]],[/droid.+; (glass) \d/i],[MODEL,[VENDOR,GOOGLE],[TYPE$2,WEARABLE]],[/droid.+; (wt63?0{2,3})\)/i],[MODEL,[VENDOR,ZEBRA],[TYPE$2,WEARABLE]],[/(quest( 2| pro)?)/i],[MODEL,[VENDOR,FACEBOOK],[TYPE$2,WEARABLE]],[/(tesla)(?: qtcarbrowser|\/[-\w\.]+)/i],[VENDOR,[TYPE$2,EMBEDDED]],[/(aeobc)\b/i],[MODEL,[VENDOR,AMAZON],[TYPE$2,EMBEDDED]],[/droid .+?; ([^;]+?)(?: bui|; wv\)|\) applew).+? mobile safari/i],[MODEL,[TYPE$2,MOBILE]],[/droid .+?; ([^;]+?)(?: bui|\) applew).+?(?! mobile) safari/i],[MODEL,[TYPE$2,TABLET]],[/\b((tablet|tab)[;\/]|focus\/\d(?!.+mobile))/i],[[TYPE$2,TABLET]],[/(phone|mobile(?:[;\/]| [ \w\/\.]*safari)|pda(?=.+windows ce))/i],[[TYPE$2,MOBILE]],[/(android[-\w\. ]{0,9});.+buil/i],[MODEL,[VENDOR,"Generic"]]],engine:[[/windows.+ edge\/([\w\.]+)/i],[VERSION,[NAME$1,EDGE+"HTML"]],[/webkit\/537\.36.+chrome\/(?!27)([\w\.]+)/i],[VERSION,[NAME$1,"Blink"]],[/(presto)\/([\w\.]+)/i,/(webkit|trident|netfront|netsurf|amaya|lynx|w3m|goanna)\/([\w\.]+)/i,/ekioh(flow)\/([\w\.]+)/i,/(khtml|tasman|links)[\/ ]\(?([\w\.]+)/i,/(icab)[\/ ]([23]\.[\d\.]+)/i,/\b(libweb)/i],[NAME$1,VERSION],[/rv\:([\w\.]{1,9})\b.+(gecko)/i],[VERSION,NAME$1]],os:[[/microsoft (windows) (vista|xp)/i],[NAME$1,VERSION],[/(windows (?:phone(?: os)?|mobile))[\/ ]?([\d\.\w ]*)/i],[NAME$1,[VERSION,strMapper,windowsVersionMap]],[/windows nt 6\.2; (arm)/i,/windows[\/ ]?([ntce\d\. ]+\w)(?!.+xbox)/i,/(?:win(?=3|9|n)|win 9x )([nt\d\.]+)/i],[[VERSION,strMapper,windowsVersionMap],[NAME$1,"Windows"]],[/ip[honead]{2,4}\b(?:.*os ([\w]+) like mac|; opera)/i,/(?:ios;fbsv\/|iphone.+ios[\/ ])([\d\.]+)/i,/cfnetwork\/.+darwin/i],[[VERSION,/_/g,"."],[NAME$1,"iOS"]],[/(mac os x) ?([\w\. ]*)/i,/(macintosh|mac_powerpc\b)(?!.+haiku)/i],[[NAME$1,MAC_OS],[VERSION,/_/g,"."]],[/droid ([\w\.]+)\b.+(android[- ]x86|harmonyos)/i],[VERSION,NAME$1],[/(android|webos|qnx|bada|rim tablet os|maemo|meego|sailfish)[-\/ ]?([\w\.]*)/i,/(blackberry)\w*\/([\w\.]*)/i,/(tizen|kaios)[\/ ]([\w\.]+)/i,/\((series40);/i],[NAME$1,VERSION],[/\(bb(10);/i],[VERSION,[NAME$1,BLACKBERRY]],[/(?:symbian ?os|symbos|s60(?=;)|series60)[-\/ ]?([\w\.]*)/i],[VERSION,[NAME$1,"Symbian"]],[/mozilla\/[\d\.]+ \((?:mobile|tablet|tv|mobile; [\w ]+); rv:.+ gecko\/([\w\.]+)/i],[VERSION,[NAME$1,FIREFOX+" OS"]],[/web0s;.+rt(tv)/i,/\b(?:hp)?wos(?:browser)?\/([\w\.]+)/i],[VERSION,[NAME$1,"webOS"]],[/watch(?: ?os[,\/]|\d,\d\/)([\d\.]+)/i],[VERSION,[NAME$1,"watchOS"]],[/crkey\/([\d\.]+)/i],[VERSION,[NAME$1,CHROME+"cast"]],[/(cros) [\w]+(?:\)| ([\w\.]+)\b)/i],[[NAME$1,CHROMIUM_OS],VERSION],[/panasonic;(viera)/i,/(netrange)mmh/i,/(nettv)\/(\d+\.[\w\.]+)/i,/(nintendo|playstation) ([wids345portablevuch]+)/i,/(xbox); +xbox ([^\);]+)/i,/\b(joli|palm)\b ?(?:os)?\/?([\w\.]*)/i,/(mint)[\/\(\) ]?(\w*)/i,/(mageia|vectorlinux)[; ]/i,/([kxln]?ubuntu|debian|suse|opensuse|gentoo|arch(?= linux)|slackware|fedora|mandriva|centos|pclinuxos|red ?hat|zenwalk|linpus|raspbian|plan 9|minix|risc os|contiki|deepin|manjaro|elementary os|sabayon|linspire)(?: gnu\/linux)?(?: enterprise)?(?:[- ]linux)?(?:-gnu)?[-\/ ]?(?!chrom|package)([-\w\.]*)/i,/(hurd|linux) ?([\w\.]*)/i,/(gnu) ?([\w\.]*)/i,/\b([-frentopcghs]{0,5}bsd|dragonfly)[\/ ]?(?!amd|[ix346]{1,2}86)([\w\.]*)/i,/(haiku) (\w+)/i],[NAME$1,VERSION],[/(sunos) ?([\w\.\d]*)/i],[[NAME$1,"Solaris"],VERSION],[/((?:open)?solaris)[-\/ ]?([\w\.]*)/i,/(aix) ((\d)(?=\.|\)| )[\w\.])*/i,/\b(beos|os\/2|amigaos|morphos|openvms|fuchsia|hp-ux|serenityos)/i,/(unix) ?([\w\.]*)/i],[NAME$1,VERSION]]},_UAParser2=function(e,t){if(_typeof$1(e)===OBJ_TYPE&&(t=e,e=void 0),!(this instanceof _UAParser2))return new _UAParser2(e,t).getResult();var r=("undefined"==typeof window?"undefined":_typeof$1(window))!==UNDEF_TYPE&&window.navigator?window.navigator:void 0,n=e||(r&&r.userAgent?r.userAgent:EMPTY),i=r&&r.userAgentData?r.userAgentData:void 0,o=t?extend(regexes,t):regexes,a=r&&r.userAgent==n;return this.getBrowser=function(){var e={};return e[NAME$1]=void 0,e[VERSION]=void 0,rgxMapper.call(e,n,o.browser),e[MAJOR]=majorize(e[VERSION]),a&&r&&r.brave&&_typeof$1(r.brave.isBrave)==FUNC_TYPE&&(e[NAME$1]="Brave"),e},this.getCPU=function(){var e={};return e[ARCHITECTURE]=void 0,rgxMapper.call(e,n,o.cpu),e},this.getDevice=function(){var e={};return e[VENDOR]=void 0,e[MODEL]=void 0,e[TYPE$2]=void 0,rgxMapper.call(e,n,o.device),a&&!e[TYPE$2]&&i&&i.mobile&&(e[TYPE$2]=MOBILE),a&&"Macintosh"==e[MODEL]&&r&&_typeof$1(r.standalone)!==UNDEF_TYPE&&r.maxTouchPoints&&r.maxTouchPoints>2&&(e[MODEL]="iPad",e[TYPE$2]=TABLET),e},this.getEngine=function(){var e={};return e[NAME$1]=void 0,e[VERSION]=void 0,rgxMapper.call(e,n,o.engine),e},this.getOS=function(){var e={};return e[NAME$1]=void 0,e[VERSION]=void 0,rgxMapper.call(e,n,o.os),a&&!e[NAME$1]&&i&&"Unknown"!=i.platform&&(e[NAME$1]=i.platform.replace(/chrome os/i,CHROMIUM_OS).replace(/macos/i,MAC_OS)),e},this.getResult=function(){return{ua:this.getUA(),browser:this.getBrowser(),engine:this.getEngine(),os:this.getOS(),device:this.getDevice(),cpu:this.getCPU()}},this.getUA=function(){return n},this.setUA=function(e){return n=_typeof$1(e)===STR_TYPE&&e.length>UA_MAX_LENGTH?trim(e,UA_MAX_LENGTH):e,this},this.setUA(n),this},BrowserType,OSType,_device$vendor,_a;_UAParser2.VERSION=LIBVERSION,_UAParser2.BROWSER=enumerize([NAME$1,VERSION,MAJOR]),_UAParser2.CPU=enumerize([ARCHITECTURE]),_UAParser2.DEVICE=enumerize([MODEL,VENDOR,TYPE$2,CONSOLE,MOBILE,SMARTTV,TABLET,WEARABLE,EMBEDDED]),_UAParser2.ENGINE=_UAParser2.OS=enumerize([NAME$1,VERSION]),function(e){e._2345_EXPLORER="2345Explorer",e._360="360 Browser",e.ALIPAY="Alipay",e.AMAYA="Amaya",e.ANDROID="Android Browser",e.ARORA="Arora",e.AVANT="Avant",e.AVAST="Avast Secure Browser",e.AVG="AVG Secure Browser",e.BAIDU="Baidu Browser",e.BASILISK="Basilisk",e.BLAZER="Blazer",e.BOLT="Bolt",e.BOWSER="Bowser",e.BRAVE="Brave",e.CAMINO="Camino",e.CHIMERA="Chimera",e.CHROME="Chrome",e.CHROME_HEADLESS="Chrome Headless",e.CHROME_MOBILE="Mobile Chrome",e.CHROME_WEBVIEW="Chrome WebView",e.CHROMIUM="Chromium",e.COBALT="Cobalt",e.COC_COC="Coc Coc",e.COMODO_DRAGON="Comodo Dragon",e.CONKEROR="Conkeror",e.DILLO="Dillo",e.DOLPHIN="Dolphin",e.DORIS="Doris",e.DUCKDUCKGO="DuckDuckGo",e.EDGE="Edge",e.EPIPHANY="Epiphany",e.FACEBOOK="Facebook",e.FALKON="Falkon",e.FIREBIRD="Firebird",e.FIREFOX="Firefox",e.FIREFOX_FOCUS="Firefox Focus",e.FIREFOX_MOBILE="Mobile Firefox",e.FIREFOX_REALITY="Firefox Reality",e.FENNEC="Fennec",e.FLOCK="Flock",e.FLOW="Flow",e.GO="Go Browser",e.GOOGLE_SEARCH="GSA",e.HEYTAP="HeyTap",e.HUAWEI="Huawei Browser",e.ICAB="iCab",e.ICE="ICE Browser",e.ICEAPE="IceApe",e.ICECAT="IceCat",e.ICEDRAGON="IceDragon",e.ICEWEASEL="IceWeasel",e.IE="IE",e.INSTAGRAM="Instagram",e.IRIDIUM="Iridium",e.IRON="Iron",e.JASMINE="Jasmine",e.KONQUEROR="Konqueror",e.KAKAO="KakaoTalk",e.KHTML="KHTML",e.K_MELEON="K-Meleon",e.KLAR="Klar",e.KLARNA="Klarna",e.KINDLE="Kindle",e.LENOVO="Smart Lenovo Browser",e.LIEBAO="LBBROWSER",e.LINE="Line",e.LINKEDIN="LinkedIn",e.LINKS="Links",e.LUNASCAPE="Lunascape",e.LYNX="Lynx",e.MAEMO="Maemo Browser",e.MAXTHON="Maxthon",e.MIDORI="Midori",e.MINIMO="Minimo",e.MIUI="MIUI Browser",e.MOZILLA="Mozilla",e.MOSAIC="Mosaic",e.NAVER="Naver",e.NETFRONT="NetFront",e.NETSCAPE="Netscape",e.NETSURF="Netsurf",e.NOKIA="Nokia Browser",e.OBIGO="Obigo",e.OCULUS="Oculus Browser",e.OMNIWEB="OmniWeb",e.OPERA="Opera",e.OPERA_COAST="Opera Coast",e.OPERA_MINI="Opera Mini",e.OPERA_MOBI="Opera Mobi",e.OPERA_TABLET="Opera Tablet",e.OPERA_TOUCH="Opera Touch",e.OVI="OviBrowser",e.PALEMOON="PaleMoon",e.PHANTOMJS="PhantomJS",e.PHOENIX="Phoenix",e.POLARIS="Polaris",e.PUFFIN="Puffin",e.QQ="QQBrowser",e.QQ_LITE="QQBrowserLite",e.QUARK="Quark",e.QUPZILLA="QupZilla",e.REKONQ="rekonq",e.ROCKMELT="Rockmelt",e.SAFARI="Safari",e.SAFARI_MOBILE="Mobile Safari",e.SAILFISH="Sailfish Browser",e.SAMSUNG="Samsung Internet",e.SEAMONKEY="SeaMonkey",e.SILK="Silk",e.SKYFIRE="Skyfire",e.SLEIPNIR="Sleipnir",e.SLIMBROWSER="SlimBrowser",e.SNAPCHAT="Snapchat",e.SOGOU_EXPLORER="Sogou Explorer",e.SOGOU_MOBILE="Sogou Mobile",e.SWIFTFOX="Swiftfox",e.TESLA="Tesla",e.TIKTOK="TikTok",e.TIZEN="Tizen Browser",e.UC="UCBrowser",e.UP="UP.Browser",e.VIERA="Viera",e.VIVALDI="Vivaldi",e.VIVO="Vivo Browser",e.W3M="w3m",e.WATERFOX="Waterfox",e.WEBKIT="WebKit",e.WECHAT="WeChat",e.WEIBO="Weibo",e.WHALE="Whale",e.YANDEX="Yandex"}(BrowserType||(BrowserType={})),function(e){e.AIX="AIX",e.AMIGA_OS="Amiga OS",e.ANDROID="Android",e.ANDROID_X86="Android-x86",e.ARCH="Arch",e.BADA="Bada",e.BEOS="BeOS",e.BLACKBERRY="BlackBerry",e.CENTOS="CentOS",e.CHROME_OS="Chrome OS",e.CHROMECAST="Chromecast",e.CONTIKI="Contiki",e.DEBIAN="Debian",e.DEEPIN="Deepin",e.DRAGONFLY="DragonFly",e.ELEMENTARY_OS="elementary OS",e.FEDORA="Fedora",e.FIREFOX_OS="Firefox OS",e.FREEBSD="FreeBSD",e.FUCHSIA="Fuchsia",e.GENTOO="Gentoo",e.GHOSTBSD="GhostBSD",e.GNU="GNU",e.HAIKU="Haiku",e.HARMONYOS="HarmonyOS",e.HP_UX="HP-UX",e.HURD="Hurd",e.IOS="iOS",e.JOLI="Joli",e.KAIOS="KaiOS",e.LINPUS="Linpus",e.LINSPIRE="Linspire",e.LINUX="Linux",e.MACOS="macOS",e.MAEMO="Maemo",e.MAGEIA="Mageia",e.MANDRIVA="Mandriva",e.MANJARO="Manjaro",e.MEEGO="MeeGo",e.MINIX="Minix",e.MINT="Mint",e.MORPH_OS="Morph OS",e.NETBSD="NetBSD",e.NETRANGE="NetRange",e.NETTV="NetTV",e.NINTENDO="Nintendo",e.OPENBSD="OpenBSD",e.OPENVMS="OpenVMS",e.OS2="OS/2",e.PALM="Palm",e.PC_BSD="PC-BSD",e.PCLINUXOS="PCLinuxOS",e.PLAN9="Plan9",e.PLAYSTATION="PlayStation",e.QNX="QNX",e.RASPBIAN="Raspbian",e.REDHAT="RedHat",e.RIM_TABLET_OS="RIM Tablet OS",e.RISC_OS="RISC OS",e.SABAYON="Sabayon",e.SAILFISH="Sailfish",e.SERENITYOS="SerenityOS",e.SERIES40="Series40",e.SLACKWARE="Slackware",e.SOLARIS="Solaris",e.SUSE="SUSE",e.SYMBIAN="Symbian",e.TIZEN="Tizen",e.UBUNTU="Ubuntu",e.UNIX="Unix",e.VECTORLINUX="VectorLinux",e.VIERA="Viera",e.WATCHOS="watchOS",e.WEBOS="WebOS",e.WINDOWS="Windows",e.WINDOWS_MOBILE="Windows Mobile",e.WINDOWS_PHONE="Windows Phone",e.XBOX="Xbox",e.ZENWALK="Zenwalk"}(OSType||(OSType={}));var parser$2=new _UAParser2(navigator.userAgent),_parser$getResult=parser$2.getResult(),os=_parser$getResult.os,cpu=_parser$getResult.cpu,browser=_parser$getResult.browser,device=_parser$getResult.device,TerminalType$1,SdkType$1;"HarmonyOS"===os.name&&(os.name="Android"),function(e){e[e.Windows=1]="Windows",e[e.Android=2]="Android",e[e.Mac=3]="Mac",e[e.iOS=4]="iOS",e[e.Linux=5]="Linux",e[e.Others=6]="Others"}(TerminalType$1||(TerminalType$1={})),function(e){e[e.Native=1]="Native",e[e.Web=2]="Web",e[e.MiniProgram=3]="MiniProgram"}(SdkType$1||(SdkType$1={}));var clientDeviceId="";try{clientDeviceId=localStorage.getItem(DEVICEID)}catch(e){}if(!clientDeviceId){clientDeviceId=createUuid();try{localStorage.setItem(DEVICEID,clientDeviceId)}catch(e){}}var deviceId=clientDeviceId,getTerminalType=function(){var e=TerminalType$1.Others;return os.name===OSType.WINDOWS?e=TerminalType$1.Windows:os.name===OSType.MACOS?e=TerminalType$1.Mac:os.name.includes(OSType.ANDROID)?e=TerminalType$1.Android:os.name===OSType.IOS?e=TerminalType$1.iOS:os.name===OSType.LINUX&&(e=TerminalType$1.Linux),e},Environment=_createClass((function e(){_classCallCheck(this,e)}));function ownKeys$2$1(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function _objectSpread$2$1(e){for(var t=1;arguments.length>t;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ownKeys$2$1(Object(r),!0).forEach((function(t){_defineProperty$1(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ownKeys$2$1(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}_a=Environment,Object.defineProperty(Environment,"browserType",{enumerable:!0,configurable:!0,writable:!0,value:browser.name}),Object.defineProperty(Environment,"browserVersion",{enumerable:!0,configurable:!0,writable:!0,value:browser.version}),Object.defineProperty(Environment,"system",{enumerable:!0,configurable:!0,writable:!0,value:os.name}),Object.defineProperty(Environment,"terminalType",{enumerable:!0,configurable:!0,writable:!0,value:getTerminalType()}),Object.defineProperty(Environment,"sdkType",{enumerable:!0,configurable:!0,writable:!0,value:SdkType$1.Web}),Object.defineProperty(Environment,"systemVersion",{enumerable:!0,configurable:!0,writable:!0,value:os.version}),Object.defineProperty(Environment,"deviceId",{enumerable:!0,configurable:!0,writable:!0,value:deviceId}),Object.defineProperty(Environment,"networkType",{enumerable:!0,configurable:!0,writable:!0,value:"unknown"}),Object.defineProperty(Environment,"manu",{enumerable:!0,configurable:!0,writable:!0,value:null===(_device$vendor=device.vendor)||void 0===_device$vendor?void 0:_device$vendor.toLocaleLowerCase()}),Object.defineProperty(Environment,"model",{enumerable:!0,configurable:!0,writable:!0,value:device.model}),Object.defineProperty(Environment,"cpu",{enumerable:!0,configurable:!0,writable:!0,value:cpu.architecture}),Object.defineProperty(Environment,"isAndroid",{enumerable:!0,configurable:!0,writable:!0,value:function(){return _a.system.includes(OSType.ANDROID)}}),Object.defineProperty(Environment,"isIOS",{enumerable:!0,configurable:!0,writable:!0,value:function(){return _a.system===OSType.IOS}}),Object.defineProperty(Environment,"isWeixin",{enumerable:!0,configurable:!0,writable:!0,value:function(){return _a.browserType===BrowserType.WECHAT}}),Object.defineProperty(Environment,"isChrome",{enumerable:!0,configurable:!0,writable:!0,value:function(){return _a.browserType.includes(BrowserType.CHROME)}}),Object.defineProperty(Environment,"isSafari",{enumerable:!0,configurable:!0,writable:!0,value:function(){return _a.browserType.includes(BrowserType.SAFARI)}}),Object.defineProperty(Environment,"isFirefox",{enumerable:!0,configurable:!0,writable:!0,value:function(){return _a.browserType.includes(BrowserType.FIREFOX)}}),Object.defineProperty(Environment,"isOpera",{enumerable:!0,configurable:!0,writable:!0,value:function(){return _a.browserType.includes(BrowserType.OPERA)}}),Object.defineProperty(Environment,"isQQBrowser",{enumerable:!0,configurable:!0,writable:!0,value:function(){return _a.browserType===BrowserType.QQ}});var iFetch=function(e,t,r){var n=_objectSpread$2$1(_objectSpread$2$1({},arguments.length>3&&void 0!==arguments[3]?arguments[3]:{}),{},{"Content-Type":"application/json",Accept:"application/json"});return new Promise((function(i,o){var a;fetch(t,{method:e,body:r,headers:n}).then((function(e){return a=e,e.ok?e.json():e.text()})).then((function(e){var t;null!==(t=a)&&void 0!==t&&t.ok?e.code?o(e):i(e):o(a)})).catch((function(e){o(e)}))}))},post$1=function(e,t,r){return iFetch("POST",e,t,r)},logService=function(e){var t=e.userId;delete e.userId;var r="/v1/users/".concat(t,"/log-service");return post$1("".concat(getGslb()).concat(r),JSON.stringify(e))},EventEmitter=_createClass((function e(){_classCallCheck(this,e),Object.defineProperty(this,"eventMap",{enumerable:!0,configurable:!0,writable:!0,value:{}})}),[{key:"listenerCount",value:function(e){return this.eventMap[e].length||0}},{key:"emit",value:function(e){for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;t>n;n++)r[n-1]=arguments[n];var i=this.eventMap[e];return!(!i||0===i.length||(i.forEach((function(e){e.fn.apply(e,r)})),this.eventMap[e]=i.filter((function(e){return!e.once})),0))}},{key:"on",value:function(e,t){return this.eventMap[e]||(this.eventMap[e]=[]),this.eventMap[e].push({fn:t,once:!1}),this}},{key:"once",value:function(e,t){return this.eventMap[e]||(this.eventMap[e]=[]),this.eventMap[e].push({fn:t,once:!0}),this}},{key:"off",value:function(e,t){if(t){var r=this.eventMap[e];if(r&&r.length>0){var n=r.findIndex((function(e){return e.fn===t}));n>-1&&r.splice(n,1)}}else this.eventMap[e]=[]}},{key:"removeAllListeners",value:function(e){e?this.eventMap[e]=[]:this.eventMap={}}}]),EventBus=new EventEmitter;function _callSuper$1$1(e,t,r){return t=_getPrototypeOf(t),_possibleConstructorReturn(e,_isNativeReflectConstruct$1$1()?Reflect.construct(t,[],_getPrototypeOf(e).constructor):t.apply(e,r))}function _isNativeReflectConstruct$1$1(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(_isNativeReflectConstruct$1$1=function(){return!!e})()}var STSTokenManager=function(e){function t(e,r,n){var i;return _classCallCheck(this,t),i=_callSuper$1$1(this,t),Object.defineProperty(i,"credential",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(i,"updating",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(i,"requesting",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(i,"commonInfo",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(i,"securityToken",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(i,"delayTimerId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(i,"checkTokenTimerId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(i,"startTime",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),i.commonInfo=r,i.securityToken=e,i.updating=!0,i.delayTimerId=0,i.checkTokenTimerId=0,i.requesting=!1,i.updateCredential(n),i}return _inherits(t,EventEmitter),_createClass(t,[{key:"stopUpdateToken",value:function(){this.updating=!1,this.stopDelayTimer(),this.stopCheckTokenTimer()}},{key:"requestStsToken",value:function(){var e=this;if(!this.requesting&&this.updating){this.requesting=!0;var t=this.commonInfo;logService({userId:t.usrid,channelId:t.roomName,appId:t.apid,securityToken:this.securityToken.securityToken}).then((function(t){if(t&&t.logService)return e.updateCredential(t.logService.credentials),e.emit("update",t.logService),e.securityToken=t.securityToken,e.requesting=!1,!0;e.updating&&e.delayRequest()})).catch((function(){e.updating&&e.delayRequest()}))}}},{key:"delayRequest",value:function(){var e=this;this.delayTimerId||(this.delayTimerId=window.setTimeout((function(){e.requestStsToken()}),arguments.length>0&&void 0!==arguments[0]?arguments[0]:3e4))}},{key:"stopDelayTimer",value:function(){this.delayTimerId&&(clearTimeout(this.delayTimerId),this.delayTimerId=null)}},{key:"updateSecurityToken",value:function(e){this.stopDelayTimer(),this.securityToken=e,this.delayRequest()}},{key:"updateCredential",value:function(e){this.credential=e,this.startTime=Date.now(),this.checkToken()}},{key:"checkToken",value:function(){var e=this;if(this.updating)if(this.credential.durationSeconds){var t=Math.round((Date.now()-this.startTime)/1e3);this.credential.durationSeconds-t>0?this.checkTokenTimerId||(this.checkTokenTimerId=window.setTimeout((function(){e.stopCheckTokenTimer(),e.checkToken()}),3e5)):this.requestStsToken()}else this.requestStsToken()}},{key:"stopCheckTokenTimer",value:function(){this.checkTokenTimerId&&(clearTimeout(this.checkTokenTimerId),this.checkTokenTimerId=null)}}])}(),Z_FIXED$1=4,Z_BINARY=0,Z_TEXT=1,Z_UNKNOWN$1=2;
2
+ /*! pako 2.1.0 https://github.com/nodeca/pako @license (MIT AND Zlib) */function zero$1(e){for(var t=e.length;--t>=0;)e[t]=0}var STORED_BLOCK=0,STATIC_TREES=1,DYN_TREES=2,MIN_MATCH$1=3,MAX_MATCH$1=258,LENGTH_CODES$1=29,LITERALS$1=256,L_CODES$1=LITERALS$1+1+LENGTH_CODES$1,D_CODES$1=30,BL_CODES$1=19,HEAP_SIZE$1=2*L_CODES$1+1,MAX_BITS$1=15,Buf_size=16,MAX_BL_BITS=7,END_BLOCK=256,REP_3_6=16,REPZ_3_10=17,REPZ_11_138=18,extra_lbits=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),extra_dbits=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),extra_blbits=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),bl_order=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),DIST_CODE_LEN=512,static_ltree=Array(2*(L_CODES$1+2));zero$1(static_ltree);var static_dtree=Array(2*D_CODES$1);zero$1(static_dtree);var _dist_code=Array(DIST_CODE_LEN);zero$1(_dist_code);var _length_code=Array(MAX_MATCH$1-MIN_MATCH$1+1);zero$1(_length_code);var base_length=Array(LENGTH_CODES$1);zero$1(base_length);var base_dist=Array(D_CODES$1),static_l_desc,static_d_desc,static_bl_desc;function StaticTreeDesc(e,t,r,n,i){this.static_tree=e,this.extra_bits=t,this.extra_base=r,this.elems=n,this.max_length=i,this.has_stree=e&&e.length}function TreeDesc(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}zero$1(base_dist);var d_code=function(e){return 256>e?_dist_code[e]:_dist_code[256+(e>>>7)]},put_short=function(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255},send_bits=function(e,t,r){e.bi_valid>Buf_size-r?(e.bi_buf|=t<<e.bi_valid&65535,put_short(e,e.bi_buf),e.bi_buf=t>>Buf_size-e.bi_valid,e.bi_valid+=r-Buf_size):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=r)},send_code=function(e,t,r){send_bits(e,r[2*t],r[2*t+1])},bi_reverse=function(e,t){var r=0;do{r|=1&e,e>>>=1,r<<=1}while(--t>0);return r>>>1},bi_flush=function(e){16===e.bi_valid?(put_short(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):8>e.bi_valid||(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)},gen_bitlen=function(e,t){var r,n,i,o,a,s,c=t.dyn_tree,u=t.max_code,l=t.stat_desc.static_tree,d=t.stat_desc.has_stree,p=t.stat_desc.extra_bits,f=t.stat_desc.extra_base,h=t.stat_desc.max_length,m=0;for(o=0;MAX_BITS$1>=o;o++)e.bl_count[o]=0;for(c[2*e.heap[e.heap_max]+1]=0,r=e.heap_max+1;HEAP_SIZE$1>r;r++)(o=c[2*c[2*(n=e.heap[r])+1]+1]+1)>h&&(o=h,m++),c[2*n+1]=o,n>u||(e.bl_count[o]++,a=0,f>n||(a=p[n-f]),e.opt_len+=(s=c[2*n])*(o+a),d&&(e.static_len+=s*(l[2*n+1]+a)));if(0!==m){do{for(o=h-1;0===e.bl_count[o];)o--;e.bl_count[o]--,e.bl_count[o+1]+=2,e.bl_count[h]--,m-=2}while(m>0);for(o=h;0!==o;o--)for(n=e.bl_count[o];0!==n;)(i=e.heap[--r])>u||(c[2*i+1]!==o&&(e.opt_len+=(o-c[2*i+1])*c[2*i],c[2*i+1]=o),n--)}},gen_codes=function(e,t,r){var n,i,o=Array(MAX_BITS$1+1),a=0;for(n=1;MAX_BITS$1>=n;n++)o[n]=a=a+r[n-1]<<1;for(i=0;t>=i;i++){var s=e[2*i+1];0!==s&&(e[2*i]=bi_reverse(o[s]++,s))}},tr_static_init=function(){var e,t,r,n,i,o=Array(MAX_BITS$1+1);for(r=0,n=0;LENGTH_CODES$1-1>n;n++)for(base_length[n]=r,e=0;1<<extra_lbits[n]>e;e++)_length_code[r++]=n;for(_length_code[r-1]=n,i=0,n=0;16>n;n++)for(base_dist[n]=i,e=0;1<<extra_dbits[n]>e;e++)_dist_code[i++]=n;for(i>>=7;D_CODES$1>n;n++)for(base_dist[n]=i<<7,e=0;1<<extra_dbits[n]-7>e;e++)_dist_code[256+i++]=n;for(t=0;MAX_BITS$1>=t;t++)o[t]=0;for(e=0;143>=e;)static_ltree[2*e+1]=8,e++,o[8]++;for(;255>=e;)static_ltree[2*e+1]=9,e++,o[9]++;for(;279>=e;)static_ltree[2*e+1]=7,e++,o[7]++;for(;287>=e;)static_ltree[2*e+1]=8,e++,o[8]++;for(gen_codes(static_ltree,L_CODES$1+1,o),e=0;D_CODES$1>e;e++)static_dtree[2*e+1]=5,static_dtree[2*e]=bi_reverse(e,5);static_l_desc=new StaticTreeDesc(static_ltree,extra_lbits,LITERALS$1+1,L_CODES$1,MAX_BITS$1),static_d_desc=new StaticTreeDesc(static_dtree,extra_dbits,0,D_CODES$1,MAX_BITS$1),static_bl_desc=new StaticTreeDesc([],extra_blbits,0,BL_CODES$1,MAX_BL_BITS)},init_block=function(e){var t;for(t=0;L_CODES$1>t;t++)e.dyn_ltree[2*t]=0;for(t=0;D_CODES$1>t;t++)e.dyn_dtree[2*t]=0;for(t=0;BL_CODES$1>t;t++)e.bl_tree[2*t]=0;e.dyn_ltree[2*END_BLOCK]=1,e.opt_len=e.static_len=0,e.sym_next=e.matches=0},bi_windup=function(e){e.bi_valid>8?put_short(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},smaller=function(e,t,r,n){var i=2*t,o=2*r;return e[o]>e[i]||e[i]===e[o]&&n[r]>=n[t]},pqdownheap=function(e,t,r){for(var n=e.heap[r],i=r<<1;e.heap_len>=i&&(e.heap_len>i&&smaller(t,e.heap[i+1],e.heap[i],e.depth)&&i++,!smaller(t,n,e.heap[i],e.depth));)e.heap[r]=e.heap[i],r=i,i<<=1;e.heap[r]=n},compress_block=function(e,t,r){var n,i,o,a,s=0;if(0!==e.sym_next)do{n=255&e.pending_buf[e.sym_buf+s++],n+=(255&e.pending_buf[e.sym_buf+s++])<<8,i=e.pending_buf[e.sym_buf+s++],0===n?send_code(e,i,t):(send_code(e,(o=_length_code[i])+LITERALS$1+1,t),0!==(a=extra_lbits[o])&&send_bits(e,i-=base_length[o],a),n--,o=d_code(n),send_code(e,o,r),0!==(a=extra_dbits[o])&&send_bits(e,n-=base_dist[o],a))}while(e.sym_next>s);send_code(e,END_BLOCK,t)},build_tree=function(e,t){var r,n,i,o=t.dyn_tree,a=t.stat_desc.static_tree,s=t.stat_desc.has_stree,c=t.stat_desc.elems,u=-1;for(e.heap_len=0,e.heap_max=HEAP_SIZE$1,r=0;c>r;r++)0!==o[2*r]?(e.heap[++e.heap_len]=u=r,e.depth[r]=0):o[2*r+1]=0;for(;2>e.heap_len;)o[2*(i=e.heap[++e.heap_len]=2>u?++u:0)]=1,e.depth[i]=0,e.opt_len--,s&&(e.static_len-=a[2*i+1]);for(t.max_code=u,r=e.heap_len>>1;r>=1;r--)pqdownheap(e,o,r);i=c;do{r=e.heap[1],e.heap[1]=e.heap[e.heap_len--],pqdownheap(e,o,1),n=e.heap[1],e.heap[--e.heap_max]=r,e.heap[--e.heap_max]=n,o[2*i]=o[2*r]+o[2*n],e.depth[i]=(e.depth[n]>e.depth[r]?e.depth[n]:e.depth[r])+1,o[2*r+1]=o[2*n+1]=i,e.heap[1]=i++,pqdownheap(e,o,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],gen_bitlen(e,t),gen_codes(o,u,e.bl_count)},scan_tree=function(e,t,r){var n,i,o=-1,a=t[1],s=0,c=7,u=4;for(0===a&&(c=138,u=3),t[2*(r+1)+1]=65535,n=0;r>=n;n++)i=a,a=t[2*(n+1)+1],++s<c&&i===a||(u>s?e.bl_tree[2*i]+=s:0!==i?(i!==o&&e.bl_tree[2*i]++,e.bl_tree[2*REP_3_6]++):s>10?e.bl_tree[2*REPZ_11_138]++:e.bl_tree[2*REPZ_3_10]++,s=0,o=i,0===a?(c=138,u=3):i===a?(c=6,u=3):(c=7,u=4))},send_tree=function(e,t,r){var n,i,o=-1,a=t[1],s=0,c=7,u=4;for(0===a&&(c=138,u=3),n=0;r>=n;n++)if(i=a,a=t[2*(n+1)+1],++s>=c||i!==a){if(u>s)do{send_code(e,i,e.bl_tree)}while(0!=--s);else 0!==i?(i!==o&&(send_code(e,i,e.bl_tree),s--),send_code(e,REP_3_6,e.bl_tree),send_bits(e,s-3,2)):s>10?(send_code(e,REPZ_11_138,e.bl_tree),send_bits(e,s-11,7)):(send_code(e,REPZ_3_10,e.bl_tree),send_bits(e,s-3,3));s=0,o=i,0===a?(c=138,u=3):i===a?(c=6,u=3):(c=7,u=4)}},build_bl_tree=function(e){var t;for(scan_tree(e,e.dyn_ltree,e.l_desc.max_code),scan_tree(e,e.dyn_dtree,e.d_desc.max_code),build_tree(e,e.bl_desc),t=BL_CODES$1-1;t>=3&&0===e.bl_tree[2*bl_order[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t},send_all_trees=function(e,t,r,n){var i;for(send_bits(e,t-257,5),send_bits(e,r-1,5),send_bits(e,n-4,4),i=0;n>i;i++)send_bits(e,e.bl_tree[2*bl_order[i]+1],3);send_tree(e,e.dyn_ltree,t-1),send_tree(e,e.dyn_dtree,r-1)},detect_data_type=function(e){var t,r=4093624447;for(t=0;31>=t;t++,r>>>=1)if(1&r&&0!==e.dyn_ltree[2*t])return Z_BINARY;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return Z_TEXT;for(t=32;LITERALS$1>t;t++)if(0!==e.dyn_ltree[2*t])return Z_TEXT;return Z_BINARY},static_init_done=!1,_tr_init$1=function(e){static_init_done||(tr_static_init(),static_init_done=!0),e.l_desc=new TreeDesc(e.dyn_ltree,static_l_desc),e.d_desc=new TreeDesc(e.dyn_dtree,static_d_desc),e.bl_desc=new TreeDesc(e.bl_tree,static_bl_desc),e.bi_buf=0,e.bi_valid=0,init_block(e)},_tr_stored_block$1=function(e,t,r,n){send_bits(e,(STORED_BLOCK<<1)+(n?1:0),3),bi_windup(e),put_short(e,r),put_short(e,~r),r&&e.pending_buf.set(e.window.subarray(t,t+r),e.pending),e.pending+=r},_tr_align$1=function(e){send_bits(e,STATIC_TREES<<1,3),send_code(e,END_BLOCK,static_ltree),bi_flush(e)},_tr_flush_block$1=function(e,t,r,n){var i,o,a=0;e.level>0?(e.strm.data_type===Z_UNKNOWN$1&&(e.strm.data_type=detect_data_type(e)),build_tree(e,e.l_desc),build_tree(e,e.d_desc),a=build_bl_tree(e),(o=e.static_len+3+7>>>3)>(i=e.opt_len+3+7>>>3)||(i=o)):i=o=r+5,r+4>i||-1===t?e.strategy===Z_FIXED$1||o===i?(send_bits(e,(STATIC_TREES<<1)+(n?1:0),3),compress_block(e,static_ltree,static_dtree)):(send_bits(e,(DYN_TREES<<1)+(n?1:0),3),send_all_trees(e,e.l_desc.max_code+1,e.d_desc.max_code+1,a+1),compress_block(e,e.dyn_ltree,e.dyn_dtree)):_tr_stored_block$1(e,t,r,n),init_block(e),n&&bi_windup(e)},_tr_tally$1=function(e,t,r){return e.pending_buf[e.sym_buf+e.sym_next++]=t,e.pending_buf[e.sym_buf+e.sym_next++]=t>>8,e.pending_buf[e.sym_buf+e.sym_next++]=r,0===t?e.dyn_ltree[2*r]++:(e.matches++,t--,e.dyn_ltree[2*(_length_code[r]+LITERALS$1+1)]++,e.dyn_dtree[2*d_code(t)]++),e.sym_next===e.sym_end},_tr_init_1=_tr_init$1,_tr_stored_block_1=_tr_stored_block$1,_tr_flush_block_1=_tr_flush_block$1,_tr_tally_1=_tr_tally$1,_tr_align_1=_tr_align$1,trees={_tr_init:_tr_init_1,_tr_stored_block:_tr_stored_block_1,_tr_flush_block:_tr_flush_block_1,_tr_tally:_tr_tally_1,_tr_align:_tr_align_1},adler32=function(e,t,r,n){for(var i=65535&e,o=e>>>16&65535,a=0;0!==r;){r-=a=r>2e3?2e3:r;do{o=o+(i=i+t[n++]|0)|0}while(--a);i%=65521,o%=65521}return i|o<<16},adler32_1=adler32,makeTable=function(){for(var e,t=[],r=0;256>r;r++){e=r;for(var n=0;8>n;n++)e=1&e?3988292384^e>>>1:e>>>1;t[r]=e}return t},crcTable=new Uint32Array(makeTable()),crc32=function(e,t,r,n){var i=crcTable,o=n+r;e^=-1;for(var a=n;o>a;a++)e=e>>>8^i[255&(e^t[a])];return~e},crc32_1=crc32,messages={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},constants$2={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8},_tr_init=trees._tr_init,_tr_stored_block=trees._tr_stored_block,_tr_flush_block=trees._tr_flush_block,_tr_tally=trees._tr_tally,_tr_align=trees._tr_align,Z_NO_FLUSH$2=constants$2.Z_NO_FLUSH,Z_PARTIAL_FLUSH=constants$2.Z_PARTIAL_FLUSH,Z_FULL_FLUSH$1=constants$2.Z_FULL_FLUSH,Z_FINISH$3=constants$2.Z_FINISH,Z_BLOCK$1=constants$2.Z_BLOCK,Z_OK$3=constants$2.Z_OK,Z_STREAM_END$3=constants$2.Z_STREAM_END,Z_STREAM_ERROR$2=constants$2.Z_STREAM_ERROR,Z_DATA_ERROR$2=constants$2.Z_DATA_ERROR,Z_BUF_ERROR$1=constants$2.Z_BUF_ERROR,Z_DEFAULT_COMPRESSION$1=constants$2.Z_DEFAULT_COMPRESSION,Z_FILTERED=constants$2.Z_FILTERED,Z_HUFFMAN_ONLY=constants$2.Z_HUFFMAN_ONLY,Z_RLE=constants$2.Z_RLE,Z_FIXED=constants$2.Z_FIXED,Z_DEFAULT_STRATEGY$1=constants$2.Z_DEFAULT_STRATEGY,Z_UNKNOWN=constants$2.Z_UNKNOWN,Z_DEFLATED$2=constants$2.Z_DEFLATED,MAX_MEM_LEVEL=9,MAX_WBITS$1=15,DEF_MEM_LEVEL=8,LENGTH_CODES=29,LITERALS=256,L_CODES=LITERALS+1+LENGTH_CODES,D_CODES=30,BL_CODES=19,HEAP_SIZE=2*L_CODES+1,MAX_BITS=15,MIN_MATCH=3,MAX_MATCH=258,MIN_LOOKAHEAD=MAX_MATCH+MIN_MATCH+1,PRESET_DICT=32,INIT_STATE=42,GZIP_STATE=57,EXTRA_STATE=69,NAME_STATE=73,COMMENT_STATE=91,HCRC_STATE=103,BUSY_STATE=113,FINISH_STATE=666,BS_NEED_MORE=1,BS_BLOCK_DONE=2,BS_FINISH_STARTED=3,BS_FINISH_DONE=4,OS_CODE=3,err=function(e,t){return e.msg=messages[t],t},rank=function(e){return 2*e-(e>4?9:0)},zero=function(e){for(var t=e.length;--t>=0;)e[t]=0},slide_hash=function(e){var t,r,n,i=e.w_size;n=t=e.hash_size;do{r=e.head[--n],e.head[n]=i>r?0:r-i}while(--t);n=t=i;do{r=e.prev[--n],e.prev[n]=i>r?0:r-i}while(--t)},HASH_ZLIB=function(e,t,r){return(t<<e.hash_shift^r)&e.hash_mask},HASH=HASH_ZLIB,flush_pending=function(e){var t=e.state,r=t.pending;r>e.avail_out&&(r=e.avail_out),0!==r&&(e.output.set(t.pending_buf.subarray(t.pending_out,t.pending_out+r),e.next_out),e.next_out+=r,t.pending_out+=r,e.total_out+=r,e.avail_out-=r,t.pending-=r,0===t.pending&&(t.pending_out=0))},flush_block_only=function(e,t){_tr_flush_block(e,0>e.block_start?-1:e.block_start,e.strstart-e.block_start,t),e.block_start=e.strstart,flush_pending(e.strm)},put_byte=function(e,t){e.pending_buf[e.pending++]=t},putShortMSB=function(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t},read_buf=function(e,t,r,n){var i=e.avail_in;return i>n&&(i=n),0===i?0:(e.avail_in-=i,t.set(e.input.subarray(e.next_in,e.next_in+i),r),1===e.state.wrap?e.adler=adler32_1(e.adler,t,i,r):2===e.state.wrap&&(e.adler=crc32_1(e.adler,t,i,r)),e.next_in+=i,e.total_in+=i,i)},longest_match=function(e,t){var r,n,i=e.max_chain_length,o=e.strstart,a=e.prev_length,s=e.nice_match,c=e.strstart>e.w_size-MIN_LOOKAHEAD?e.strstart-(e.w_size-MIN_LOOKAHEAD):0,u=e.window,l=e.w_mask,d=e.prev,p=e.strstart+MAX_MATCH,f=u[o+a-1],h=u[o+a];e.good_match>e.prev_length||(i>>=2),s>e.lookahead&&(s=e.lookahead);do{if(u[(r=t)+a]===h&&u[r+a-1]===f&&u[r]===u[o]&&u[++r]===u[o+1]){o+=2,r++;do{}while(u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&p>o);if(n=MAX_MATCH-(p-o),o=p-MAX_MATCH,n>a){if(e.match_start=t,a=n,n>=s)break;f=u[o+a-1],h=u[o+a]}}}while((t=d[t&l])>c&&0!=--i);return a>e.lookahead?e.lookahead:a},fill_window=function(e){var t,r,n,i=e.w_size;do{if(r=e.window_size-e.lookahead-e.strstart,i+(i-MIN_LOOKAHEAD)>e.strstart||(e.window.set(e.window.subarray(i,i+i-r),0),e.match_start-=i,e.strstart-=i,e.block_start-=i,e.insert>e.strstart&&(e.insert=e.strstart),slide_hash(e),r+=i),0===e.strm.avail_in)break;if(t=read_buf(e.strm,e.window,e.strstart+e.lookahead,r),e.lookahead+=t,e.lookahead+e.insert>=MIN_MATCH)for(e.ins_h=e.window[n=e.strstart-e.insert],e.ins_h=HASH(e,e.ins_h,e.window[n+1]);e.insert&&(e.ins_h=HASH(e,e.ins_h,e.window[n+MIN_MATCH-1]),e.prev[n&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=n,n++,e.insert--,e.lookahead+e.insert>=MIN_MATCH););}while(MIN_LOOKAHEAD>e.lookahead&&0!==e.strm.avail_in)},deflate_stored=function(e,t){var r,n,i,o=e.pending_buf_size-5>e.w_size?e.w_size:e.pending_buf_size-5,a=0,s=e.strm.avail_in;do{if(r=65535,(i=e.bi_valid+42>>3)>e.strm.avail_out)break;if(r>(n=e.strstart-e.block_start)+e.strm.avail_in&&(r=n+e.strm.avail_in),r>(i=e.strm.avail_out-i)&&(r=i),o>r&&(0===r&&t!==Z_FINISH$3||t===Z_NO_FLUSH$2||r!==n+e.strm.avail_in))break;_tr_stored_block(e,0,0,a=t===Z_FINISH$3&&r===n+e.strm.avail_in?1:0),e.pending_buf[e.pending-4]=r,e.pending_buf[e.pending-3]=r>>8,e.pending_buf[e.pending-2]=~r,e.pending_buf[e.pending-1]=~r>>8,flush_pending(e.strm),n&&(n>r&&(n=r),e.strm.output.set(e.window.subarray(e.block_start,e.block_start+n),e.strm.next_out),e.strm.next_out+=n,e.strm.avail_out-=n,e.strm.total_out+=n,e.block_start+=n,r-=n),r&&(read_buf(e.strm,e.strm.output,e.strm.next_out,r),e.strm.next_out+=r,e.strm.avail_out-=r,e.strm.total_out+=r)}while(0===a);return(s-=e.strm.avail_in)&&(e.w_size>s?(e.window_size-e.strstart>s||(e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),2>e.matches&&e.matches++,e.insert>e.strstart&&(e.insert=e.strstart)),e.window.set(e.strm.input.subarray(e.strm.next_in-s,e.strm.next_in),e.strstart),e.strstart+=s,e.insert+=s>e.w_size-e.insert?e.w_size-e.insert:s):(e.matches=2,e.window.set(e.strm.input.subarray(e.strm.next_in-e.w_size,e.strm.next_in),0),e.strstart=e.w_size,e.insert=e.strstart),e.block_start=e.strstart),e.strstart>e.high_water&&(e.high_water=e.strstart),a?BS_FINISH_DONE:t!==Z_NO_FLUSH$2&&t!==Z_FINISH$3&&0===e.strm.avail_in&&e.strstart===e.block_start?BS_BLOCK_DONE:(e.strm.avail_in>(i=e.window_size-e.strstart)&&e.block_start>=e.w_size&&(e.block_start-=e.w_size,e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),2>e.matches&&e.matches++,i+=e.w_size,e.insert>e.strstart&&(e.insert=e.strstart)),i>e.strm.avail_in&&(i=e.strm.avail_in),i&&(read_buf(e.strm,e.window,e.strstart,i),e.strstart+=i,e.insert+=i>e.w_size-e.insert?e.w_size-e.insert:i),e.strstart>e.high_water&&(e.high_water=e.strstart),(o=(i=e.pending_buf_size-(i=e.bi_valid+42>>3)>65535?65535:e.pending_buf_size-i)>e.w_size?e.w_size:i)>(n=e.strstart-e.block_start)&&(!n&&t!==Z_FINISH$3||t===Z_NO_FLUSH$2||0!==e.strm.avail_in||n>i)||(_tr_stored_block(e,e.block_start,r=n>i?i:n,a=t===Z_FINISH$3&&0===e.strm.avail_in&&r===n?1:0),e.block_start+=r,flush_pending(e.strm)),a?BS_FINISH_STARTED:BS_NEED_MORE)},deflate_fast=function(e,t){for(var r,n;;){if(MIN_LOOKAHEAD>e.lookahead){if(fill_window(e),MIN_LOOKAHEAD>e.lookahead&&t===Z_NO_FLUSH$2)return BS_NEED_MORE;if(0===e.lookahead)break}if(r=0,MIN_MATCH>e.lookahead||(e.ins_h=HASH(e,e.ins_h,e.window[e.strstart+MIN_MATCH-1]),r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0===r||e.strstart-r>e.w_size-MIN_LOOKAHEAD||(e.match_length=longest_match(e,r)),MIN_MATCH>e.match_length)n=_tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;else if(n=_tr_tally(e,e.strstart-e.match_start,e.match_length-MIN_MATCH),e.lookahead-=e.match_length,e.match_length>e.max_lazy_match||MIN_MATCH>e.lookahead)e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=HASH(e,e.ins_h,e.window[e.strstart+1]);else{e.match_length--;do{e.strstart++,e.ins_h=HASH(e,e.ins_h,e.window[e.strstart+MIN_MATCH-1]),r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart}while(0!=--e.match_length);e.strstart++}if(n&&(flush_block_only(e,!1),0===e.strm.avail_out))return BS_NEED_MORE}return e.insert=MIN_MATCH-1>e.strstart?e.strstart:MIN_MATCH-1,t===Z_FINISH$3?(flush_block_only(e,!0),0===e.strm.avail_out?BS_FINISH_STARTED:BS_FINISH_DONE):e.sym_next&&(flush_block_only(e,!1),0===e.strm.avail_out)?BS_NEED_MORE:BS_BLOCK_DONE},deflate_slow=function(e,t){for(var r,n,i;;){if(MIN_LOOKAHEAD>e.lookahead){if(fill_window(e),MIN_LOOKAHEAD>e.lookahead&&t===Z_NO_FLUSH$2)return BS_NEED_MORE;if(0===e.lookahead)break}if(r=0,MIN_MATCH>e.lookahead||(e.ins_h=HASH(e,e.ins_h,e.window[e.strstart+MIN_MATCH-1]),r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=MIN_MATCH-1,0!==r&&e.max_lazy_match>e.prev_length&&e.w_size-MIN_LOOKAHEAD>=e.strstart-r&&(e.match_length=longest_match(e,r),5>=e.match_length&&(e.strategy===Z_FILTERED||e.match_length===MIN_MATCH&&e.strstart-e.match_start>4096)&&(e.match_length=MIN_MATCH-1)),MIN_MATCH>e.prev_length||e.match_length>e.prev_length)if(e.match_available){if((n=_tr_tally(e,0,e.window[e.strstart-1]))&&flush_block_only(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return BS_NEED_MORE}else e.match_available=1,e.strstart++,e.lookahead--;else{i=e.strstart+e.lookahead-MIN_MATCH,n=_tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-MIN_MATCH),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart>i||(e.ins_h=HASH(e,e.ins_h,e.window[e.strstart+MIN_MATCH-1]),r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart)}while(0!=--e.prev_length);if(e.match_available=0,e.match_length=MIN_MATCH-1,e.strstart++,n&&(flush_block_only(e,!1),0===e.strm.avail_out))return BS_NEED_MORE}}return e.match_available&&(n=_tr_tally(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=MIN_MATCH-1>e.strstart?e.strstart:MIN_MATCH-1,t===Z_FINISH$3?(flush_block_only(e,!0),0===e.strm.avail_out?BS_FINISH_STARTED:BS_FINISH_DONE):e.sym_next&&(flush_block_only(e,!1),0===e.strm.avail_out)?BS_NEED_MORE:BS_BLOCK_DONE},deflate_rle=function(e,t){for(var r,n,i,o,a=e.window;;){if(MAX_MATCH>=e.lookahead){if(fill_window(e),MAX_MATCH>=e.lookahead&&t===Z_NO_FLUSH$2)return BS_NEED_MORE;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=MIN_MATCH&&e.strstart>0&&((n=a[i=e.strstart-1])===a[++i]&&n===a[++i]&&n===a[++i])){o=e.strstart+MAX_MATCH;do{}while(n===a[++i]&&n===a[++i]&&n===a[++i]&&n===a[++i]&&n===a[++i]&&n===a[++i]&&n===a[++i]&&n===a[++i]&&o>i);e.match_length=MAX_MATCH-(o-i),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(MIN_MATCH>e.match_length?(r=_tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++):(r=_tr_tally(e,1,e.match_length-MIN_MATCH),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0),r&&(flush_block_only(e,!1),0===e.strm.avail_out))return BS_NEED_MORE}return e.insert=0,t===Z_FINISH$3?(flush_block_only(e,!0),0===e.strm.avail_out?BS_FINISH_STARTED:BS_FINISH_DONE):e.sym_next&&(flush_block_only(e,!1),0===e.strm.avail_out)?BS_NEED_MORE:BS_BLOCK_DONE},deflate_huff=function(e,t){for(var r;;){if(0===e.lookahead&&(fill_window(e),0===e.lookahead)){if(t===Z_NO_FLUSH$2)return BS_NEED_MORE;break}if(e.match_length=0,r=_tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,r&&(flush_block_only(e,!1),0===e.strm.avail_out))return BS_NEED_MORE}return e.insert=0,t===Z_FINISH$3?(flush_block_only(e,!0),0===e.strm.avail_out?BS_FINISH_STARTED:BS_FINISH_DONE):e.sym_next&&(flush_block_only(e,!1),0===e.strm.avail_out)?BS_NEED_MORE:BS_BLOCK_DONE};function Config(e,t,r,n,i){this.good_length=e,this.max_lazy=t,this.nice_length=r,this.max_chain=n,this.func=i}var configuration_table=[new Config(0,0,0,0,deflate_stored),new Config(4,4,8,4,deflate_fast),new Config(4,5,16,8,deflate_fast),new Config(4,6,32,32,deflate_fast),new Config(4,4,16,16,deflate_slow),new Config(8,16,32,32,deflate_slow),new Config(8,16,128,128,deflate_slow),new Config(8,32,128,256,deflate_slow),new Config(32,128,258,1024,deflate_slow),new Config(32,258,258,4096,deflate_slow)],lm_init=function(e){e.window_size=2*e.w_size,zero(e.head),e.max_lazy_match=configuration_table[e.level].max_lazy,e.good_match=configuration_table[e.level].good_length,e.nice_match=configuration_table[e.level].nice_length,e.max_chain_length=configuration_table[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=MIN_MATCH-1,e.match_available=0,e.ins_h=0};function DeflateState(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=Z_DEFLATED$2,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(2*HEAP_SIZE),this.dyn_dtree=new Uint16Array(2*(2*D_CODES+1)),this.bl_tree=new Uint16Array(2*(2*BL_CODES+1)),zero(this.dyn_ltree),zero(this.dyn_dtree),zero(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(MAX_BITS+1),this.heap=new Uint16Array(2*L_CODES+1),zero(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(2*L_CODES+1),zero(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}var deflateStateCheck=function(e){if(!e)return 1;var t=e.state;return!t||t.strm!==e||t.status!==INIT_STATE&&t.status!==GZIP_STATE&&t.status!==EXTRA_STATE&&t.status!==NAME_STATE&&t.status!==COMMENT_STATE&&t.status!==HCRC_STATE&&t.status!==BUSY_STATE&&t.status!==FINISH_STATE?1:0},deflateResetKeep=function(e){if(deflateStateCheck(e))return err(e,Z_STREAM_ERROR$2);e.total_in=e.total_out=0,e.data_type=Z_UNKNOWN;var t=e.state;return t.pending=0,t.pending_out=0,0>t.wrap&&(t.wrap=-t.wrap),t.status=2===t.wrap?GZIP_STATE:t.wrap?INIT_STATE:BUSY_STATE,e.adler=2===t.wrap?0:1,t.last_flush=-2,_tr_init(t),Z_OK$3},deflateReset=function(e){var t=deflateResetKeep(e);return t===Z_OK$3&&lm_init(e.state),t},deflateSetHeader=function(e,t){return deflateStateCheck(e)||2!==e.state.wrap?Z_STREAM_ERROR$2:(e.state.gzhead=t,Z_OK$3)},deflateInit2=function(e,t,r,n,i,o){if(!e)return Z_STREAM_ERROR$2;var a=1;if(t===Z_DEFAULT_COMPRESSION$1&&(t=6),0>n?(a=0,n=-n):n>15&&(a=2,n-=16),1>i||i>MAX_MEM_LEVEL||r!==Z_DEFLATED$2||8>n||n>15||0>t||t>9||0>o||o>Z_FIXED||8===n&&1!==a)return err(e,Z_STREAM_ERROR$2);8===n&&(n=9);var s=new DeflateState;return e.state=s,s.strm=e,s.status=INIT_STATE,s.wrap=a,s.gzhead=null,s.w_bits=n,s.w_size=1<<s.w_bits,s.w_mask=s.w_size-1,s.hash_bits=i+7,s.hash_size=1<<s.hash_bits,s.hash_mask=s.hash_size-1,s.hash_shift=~~((s.hash_bits+MIN_MATCH-1)/MIN_MATCH),s.window=new Uint8Array(2*s.w_size),s.head=new Uint16Array(s.hash_size),s.prev=new Uint16Array(s.w_size),s.lit_bufsize=1<<i+6,s.pending_buf_size=4*s.lit_bufsize,s.pending_buf=new Uint8Array(s.pending_buf_size),s.sym_buf=s.lit_bufsize,s.sym_end=3*(s.lit_bufsize-1),s.level=t,s.strategy=o,s.method=r,deflateReset(e)},deflateInit=function(e,t){return deflateInit2(e,t,Z_DEFLATED$2,MAX_WBITS$1,DEF_MEM_LEVEL,Z_DEFAULT_STRATEGY$1)},deflate$2=function(e,t){if(deflateStateCheck(e)||t>Z_BLOCK$1||0>t)return e?err(e,Z_STREAM_ERROR$2):Z_STREAM_ERROR$2;var r=e.state;if(!e.output||0!==e.avail_in&&!e.input||r.status===FINISH_STATE&&t!==Z_FINISH$3)return err(e,0===e.avail_out?Z_BUF_ERROR$1:Z_STREAM_ERROR$2);var n=r.last_flush;if(r.last_flush=t,0!==r.pending){if(flush_pending(e),0===e.avail_out)return r.last_flush=-1,Z_OK$3}else if(0===e.avail_in&&rank(t)<=rank(n)&&t!==Z_FINISH$3)return err(e,Z_BUF_ERROR$1);if(r.status===FINISH_STATE&&0!==e.avail_in)return err(e,Z_BUF_ERROR$1);if(r.status===INIT_STATE&&0===r.wrap&&(r.status=BUSY_STATE),r.status===INIT_STATE){var i=Z_DEFLATED$2+(r.w_bits-8<<4)<<8;if(i|=(r.strategy>=Z_HUFFMAN_ONLY||2>r.level?0:6>r.level?1:6===r.level?2:3)<<6,0!==r.strstart&&(i|=PRESET_DICT),putShortMSB(r,i+=31-i%31),0!==r.strstart&&(putShortMSB(r,e.adler>>>16),putShortMSB(r,65535&e.adler)),e.adler=1,r.status=BUSY_STATE,flush_pending(e),0!==r.pending)return r.last_flush=-1,Z_OK$3}if(r.status===GZIP_STATE)if(e.adler=0,put_byte(r,31),put_byte(r,139),put_byte(r,8),r.gzhead)put_byte(r,(r.gzhead.text?1:0)+(r.gzhead.hcrc?2:0)+(r.gzhead.extra?4:0)+(r.gzhead.name?8:0)+(r.gzhead.comment?16:0)),put_byte(r,255&r.gzhead.time),put_byte(r,r.gzhead.time>>8&255),put_byte(r,r.gzhead.time>>16&255),put_byte(r,r.gzhead.time>>24&255),put_byte(r,9===r.level?2:r.strategy>=Z_HUFFMAN_ONLY||2>r.level?4:0),put_byte(r,255&r.gzhead.os),r.gzhead.extra&&r.gzhead.extra.length&&(put_byte(r,255&r.gzhead.extra.length),put_byte(r,r.gzhead.extra.length>>8&255)),r.gzhead.hcrc&&(e.adler=crc32_1(e.adler,r.pending_buf,r.pending,0)),r.gzindex=0,r.status=EXTRA_STATE;else if(put_byte(r,0),put_byte(r,0),put_byte(r,0),put_byte(r,0),put_byte(r,0),put_byte(r,9===r.level?2:r.strategy>=Z_HUFFMAN_ONLY||2>r.level?4:0),put_byte(r,OS_CODE),r.status=BUSY_STATE,flush_pending(e),0!==r.pending)return r.last_flush=-1,Z_OK$3;if(r.status===EXTRA_STATE){if(r.gzhead.extra){for(var o=r.pending,a=(65535&r.gzhead.extra.length)-r.gzindex;r.pending+a>r.pending_buf_size;){var s=r.pending_buf_size-r.pending;if(r.pending_buf.set(r.gzhead.extra.subarray(r.gzindex,r.gzindex+s),r.pending),r.pending=r.pending_buf_size,r.gzhead.hcrc&&r.pending>o&&(e.adler=crc32_1(e.adler,r.pending_buf,r.pending-o,o)),r.gzindex+=s,flush_pending(e),0!==r.pending)return r.last_flush=-1,Z_OK$3;o=0,a-=s}var c=new Uint8Array(r.gzhead.extra);r.pending_buf.set(c.subarray(r.gzindex,r.gzindex+a),r.pending),r.pending+=a,r.gzhead.hcrc&&r.pending>o&&(e.adler=crc32_1(e.adler,r.pending_buf,r.pending-o,o)),r.gzindex=0}r.status=NAME_STATE}if(r.status===NAME_STATE){if(r.gzhead.name){var u,l=r.pending;do{if(r.pending===r.pending_buf_size){if(r.gzhead.hcrc&&r.pending>l&&(e.adler=crc32_1(e.adler,r.pending_buf,r.pending-l,l)),flush_pending(e),0!==r.pending)return r.last_flush=-1,Z_OK$3;l=0}u=r.gzhead.name.length>r.gzindex?255&r.gzhead.name.charCodeAt(r.gzindex++):0,put_byte(r,u)}while(0!==u);r.gzhead.hcrc&&r.pending>l&&(e.adler=crc32_1(e.adler,r.pending_buf,r.pending-l,l)),r.gzindex=0}r.status=COMMENT_STATE}if(r.status===COMMENT_STATE){if(r.gzhead.comment){var d,p=r.pending;do{if(r.pending===r.pending_buf_size){if(r.gzhead.hcrc&&r.pending>p&&(e.adler=crc32_1(e.adler,r.pending_buf,r.pending-p,p)),flush_pending(e),0!==r.pending)return r.last_flush=-1,Z_OK$3;p=0}d=r.gzhead.comment.length>r.gzindex?255&r.gzhead.comment.charCodeAt(r.gzindex++):0,put_byte(r,d)}while(0!==d);r.gzhead.hcrc&&r.pending>p&&(e.adler=crc32_1(e.adler,r.pending_buf,r.pending-p,p))}r.status=HCRC_STATE}if(r.status===HCRC_STATE){if(r.gzhead.hcrc){if(r.pending+2>r.pending_buf_size&&(flush_pending(e),0!==r.pending))return r.last_flush=-1,Z_OK$3;put_byte(r,255&e.adler),put_byte(r,e.adler>>8&255),e.adler=0}if(r.status=BUSY_STATE,flush_pending(e),0!==r.pending)return r.last_flush=-1,Z_OK$3}if(0!==e.avail_in||0!==r.lookahead||t!==Z_NO_FLUSH$2&&r.status!==FINISH_STATE){var f=0===r.level?deflate_stored(r,t):r.strategy===Z_HUFFMAN_ONLY?deflate_huff(r,t):r.strategy===Z_RLE?deflate_rle(r,t):configuration_table[r.level].func(r,t);if(f!==BS_FINISH_STARTED&&f!==BS_FINISH_DONE||(r.status=FINISH_STATE),f===BS_NEED_MORE||f===BS_FINISH_STARTED)return 0===e.avail_out&&(r.last_flush=-1),Z_OK$3;if(f===BS_BLOCK_DONE&&(t===Z_PARTIAL_FLUSH?_tr_align(r):t!==Z_BLOCK$1&&(_tr_stored_block(r,0,0,!1),t===Z_FULL_FLUSH$1&&(zero(r.head),0===r.lookahead&&(r.strstart=0,r.block_start=0,r.insert=0))),flush_pending(e),0===e.avail_out))return r.last_flush=-1,Z_OK$3}return t!==Z_FINISH$3?Z_OK$3:r.wrap>0?(2===r.wrap?(put_byte(r,255&e.adler),put_byte(r,e.adler>>8&255),put_byte(r,e.adler>>16&255),put_byte(r,e.adler>>24&255),put_byte(r,255&e.total_in),put_byte(r,e.total_in>>8&255),put_byte(r,e.total_in>>16&255),put_byte(r,e.total_in>>24&255)):(putShortMSB(r,e.adler>>>16),putShortMSB(r,65535&e.adler)),flush_pending(e),r.wrap>0&&(r.wrap=-r.wrap),0!==r.pending?Z_OK$3:Z_STREAM_END$3):Z_STREAM_END$3},deflateEnd=function(e){if(deflateStateCheck(e))return Z_STREAM_ERROR$2;var t=e.state.status;return e.state=null,t===BUSY_STATE?err(e,Z_DATA_ERROR$2):Z_OK$3},deflateSetDictionary=function(e,t){var r=t.length;if(deflateStateCheck(e))return Z_STREAM_ERROR$2;var n=e.state,i=n.wrap;if(2===i||1===i&&n.status!==INIT_STATE||n.lookahead)return Z_STREAM_ERROR$2;if(1===i&&(e.adler=adler32_1(e.adler,t,r,0)),n.wrap=0,r>=n.w_size){0===i&&(zero(n.head),n.strstart=0,n.block_start=0,n.insert=0);var o=new Uint8Array(n.w_size);o.set(t.subarray(r-n.w_size,r),0),t=o,r=n.w_size}var a=e.avail_in,s=e.next_in,c=e.input;for(e.avail_in=r,e.next_in=0,e.input=t,fill_window(n);n.lookahead>=MIN_MATCH;){var u=n.strstart,l=n.lookahead-(MIN_MATCH-1);do{n.ins_h=HASH(n,n.ins_h,n.window[u+MIN_MATCH-1]),n.prev[u&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=u,u++}while(--l);n.strstart=u,n.lookahead=MIN_MATCH-1,fill_window(n)}return n.strstart+=n.lookahead,n.block_start=n.strstart,n.insert=n.lookahead,n.lookahead=0,n.match_length=n.prev_length=MIN_MATCH-1,n.match_available=0,e.next_in=s,e.input=c,e.avail_in=a,n.wrap=i,Z_OK$3},deflateInit_1=deflateInit,deflateInit2_1=deflateInit2,deflateReset_1=deflateReset,deflateResetKeep_1=deflateResetKeep,deflateSetHeader_1=deflateSetHeader,deflate_2$1=deflate$2,deflateEnd_1=deflateEnd,deflateSetDictionary_1=deflateSetDictionary,deflateInfo="pako deflate (from Nodeca project)",deflate_1$2={deflateInit:deflateInit_1,deflateInit2:deflateInit2_1,deflateReset:deflateReset_1,deflateResetKeep:deflateResetKeep_1,deflateSetHeader:deflateSetHeader_1,deflate:deflate_2$1,deflateEnd:deflateEnd_1,deflateSetDictionary:deflateSetDictionary_1,deflateInfo:deflateInfo},_has=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},assign=function(e){for(var t=Array.prototype.slice.call(arguments,1);t.length;){var r=t.shift();if(r){if("object"!=_typeof$3(r))throw new TypeError(r+"must be non-object");for(var n in r)_has(r,n)&&(e[n]=r[n])}}return e},flattenChunks=function(e){for(var t=0,r=0,n=e.length;n>r;r++)t+=e[r].length;for(var i=new Uint8Array(t),o=0,a=0,s=e.length;s>o;o++){var c=e[o];i.set(c,a),a+=c.length}return i},common={assign:assign,flattenChunks:flattenChunks},STR_APPLY_UIA_OK=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(e){STR_APPLY_UIA_OK=!1}for(var _utf8len=new Uint8Array(256),e=0;256>e;e++)_utf8len[e]=252>e?248>e?240>e?224>e?192>e?1:2:3:4:5:6;_utf8len[254]=_utf8len[254]=1;var string2buf=function(e){if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(e);var t,r,n,i,o,a=e.length,s=0;for(i=0;a>i;i++)55296==(64512&(r=e.charCodeAt(i)))&&a>i+1&&(56320==(64512&(n=e.charCodeAt(i+1)))&&(r=65536+(r-55296<<10)+(n-56320),i++)),s+=128>r?1:2048>r?2:65536>r?3:4;for(t=new Uint8Array(s),o=0,i=0;s>o;i++)55296==(64512&(r=e.charCodeAt(i)))&&a>i+1&&(56320==(64512&(n=e.charCodeAt(i+1)))&&(r=65536+(r-55296<<10)+(n-56320),i++)),128>r?t[o++]=r:2048>r?(t[o++]=192|r>>>6,t[o++]=128|63&r):65536>r?(t[o++]=224|r>>>12,t[o++]=128|r>>>6&63,t[o++]=128|63&r):(t[o++]=240|r>>>18,t[o++]=128|r>>>12&63,t[o++]=128|r>>>6&63,t[o++]=128|63&r);return t},buf2binstring=function(e,t){if(65534>t&&e.subarray&&STR_APPLY_UIA_OK)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));for(var r="",n=0;t>n;n++)r+=String.fromCharCode(e[n]);return r},buf2string=function(e,t){var r,n,i=t||e.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(e.subarray(0,t));var o=Array(2*i);for(n=0,r=0;i>r;){var a=e[r++];if(a<128)o[n++]=a;else{var s=_utf8len[a];if(s>4)o[n++]=65533,r+=s-1;else{for(a&=2===s?31:3===s?15:7;s>1&&i>r;)a=a<<6|63&e[r++],s--;s>1?o[n++]=65533:65536>a?o[n++]=a:(o[n++]=55296|(a-=65536)>>10&1023,o[n++]=56320|1023&a)}}}return buf2binstring(o,n)},utf8border=function(e,t){(t=t||e.length)>e.length&&(t=e.length);for(var r=t-1;r>=0&&128==(192&e[r]);)r--;return 0>r||0===r?t:r+_utf8len[e[r]]>t?r:t},strings={string2buf:string2buf,buf2string:buf2string,utf8border:utf8border};function ZStream(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}var zstream=ZStream,toString$1=Object.prototype.toString,Z_NO_FLUSH$1=constants$2.Z_NO_FLUSH,Z_SYNC_FLUSH=constants$2.Z_SYNC_FLUSH,Z_FULL_FLUSH=constants$2.Z_FULL_FLUSH,Z_FINISH$2=constants$2.Z_FINISH,Z_OK$2=constants$2.Z_OK,Z_STREAM_END$2=constants$2.Z_STREAM_END,Z_DEFAULT_COMPRESSION=constants$2.Z_DEFAULT_COMPRESSION,Z_DEFAULT_STRATEGY=constants$2.Z_DEFAULT_STRATEGY,Z_DEFLATED$1=constants$2.Z_DEFLATED;function Deflate$1(e){this.options=common.assign({level:Z_DEFAULT_COMPRESSION,method:Z_DEFLATED$1,chunkSize:16384,windowBits:15,memLevel:8,strategy:Z_DEFAULT_STRATEGY},e||{});var t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&16>t.windowBits&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new zstream,this.strm.avail_out=0;var r=deflate_1$2.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(r!==Z_OK$2)throw Error(messages[r]);if(t.header&&deflate_1$2.deflateSetHeader(this.strm,t.header),t.dictionary){var n;if(n="string"==typeof t.dictionary?strings.string2buf(t.dictionary):"[object ArrayBuffer]"===toString$1.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,(r=deflate_1$2.deflateSetDictionary(this.strm,n))!==Z_OK$2)throw Error(messages[r]);this._dict_set=!0}}function deflate$1(e,t){var r=new Deflate$1(t);if(r.push(e,!0),r.err)throw r.msg||messages[r.err];return r.result}function deflateRaw$1(e,t){return(t=t||{}).raw=!0,deflate$1(e,t)}function gzip$1(e,t){return(t=t||{}).gzip=!0,deflate$1(e,t)}Deflate$1.prototype.push=function(e,t){var r,n,i=this.strm,o=this.options.chunkSize;if(this.ended)return!1;for(n=t===~~t?t:!0===t?Z_FINISH$2:Z_NO_FLUSH$1,i.input="string"==typeof e?strings.string2buf(e):"[object ArrayBuffer]"===toString$1.call(e)?new Uint8Array(e):e,i.next_in=0,i.avail_in=i.input.length;;)if(0===i.avail_out&&(i.output=new Uint8Array(o),i.next_out=0,i.avail_out=o),n!==Z_SYNC_FLUSH&&n!==Z_FULL_FLUSH||i.avail_out>6){if((r=deflate_1$2.deflate(i,n))===Z_STREAM_END$2)return i.next_out>0&&this.onData(i.output.subarray(0,i.next_out)),r=deflate_1$2.deflateEnd(this.strm),this.onEnd(r),this.ended=!0,r===Z_OK$2;if(0!==i.avail_out){if(n>0&&i.next_out>0)this.onData(i.output.subarray(0,i.next_out)),i.avail_out=0;else if(0===i.avail_in)break}else this.onData(i.output)}else this.onData(i.output.subarray(0,i.next_out)),i.avail_out=0;return!0},Deflate$1.prototype.onData=function(e){this.chunks.push(e)},Deflate$1.prototype.onEnd=function(e){e===Z_OK$2&&(this.result=common.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var Deflate_1$1=Deflate$1,deflate_2=deflate$1,deflateRaw_1$1=deflateRaw$1,gzip_1$1=gzip$1,constants$1=constants$2,deflate_1$1={Deflate:Deflate_1$1,deflate:deflate_2,deflateRaw:deflateRaw_1$1,gzip:gzip_1$1,constants:constants$1},BAD$1=16209,TYPE$1=16191,inffast=function(e,t){var r,n,i,o,a,s,c,u,l,d,p,f,h,m,g,y,v,_,b,E,S,T,R,O,C=e.state;R=e.input,n=(r=e.next_in)+(e.avail_in-5),O=e.output,o=(i=e.next_out)-(t-e.avail_out),a=i+(e.avail_out-257),s=C.dmax,c=C.wsize,u=C.whave,l=C.wnext,d=C.window,p=C.hold,f=C.bits,h=C.lencode,m=C.distcode,g=(1<<C.lenbits)-1,y=(1<<C.distbits)-1;e:do{15>f&&(p+=R[r++]<<f,p+=R[r++]<<(f+=8),f+=8),v=h[p&g];t:for(;;){if(p>>>=_=v>>>24,f-=_,0===(_=v>>>16&255))O[i++]=65535&v;else{if(!(16&_)){if(64&_){if(32&_){C.mode=TYPE$1;break e}e.msg="invalid literal/length code",C.mode=BAD$1;break e}v=h[(65535&v)+(p&(1<<_)-1)];continue t}for(b=65535&v,(_&=15)&&(_>f&&(p+=R[r++]<<f,f+=8),b+=p&(1<<_)-1,p>>>=_,f-=_),15>f&&(p+=R[r++]<<f,p+=R[r++]<<(f+=8),f+=8),v=m[p&y];;){if(p>>>=_=v>>>24,f-=_,16&(_=v>>>16&255)){if(E=65535&v,(_&=15)>f&&(p+=R[r++]<<f,_>(f+=8)&&(p+=R[r++]<<f,f+=8)),(E+=p&(1<<_)-1)>s){e.msg="invalid distance too far back",C.mode=BAD$1;break e}if(p>>>=_,f-=_,E>(_=i-o)){if((_=E-_)>u&&C.sane){e.msg="invalid distance too far back",C.mode=BAD$1;break e}if(S=0,T=d,0===l){if(S+=c-_,b>_){b-=_;do{O[i++]=d[S++]}while(--_);S=i-E,T=O}}else if(_>l){if(S+=c+l-_,b>(_-=l)){b-=_;do{O[i++]=d[S++]}while(--_);if(S=0,b>l){b-=_=l;do{O[i++]=d[S++]}while(--_);S=i-E,T=O}}}else if(S+=l-_,b>_){b-=_;do{O[i++]=d[S++]}while(--_);S=i-E,T=O}for(;b>2;)O[i++]=T[S++],O[i++]=T[S++],O[i++]=T[S++],b-=3;b&&(O[i++]=T[S++],b>1&&(O[i++]=T[S++]))}else{S=i-E;do{O[i++]=O[S++],O[i++]=O[S++],O[i++]=O[S++],b-=3}while(b>2);b&&(O[i++]=O[S++],b>1&&(O[i++]=O[S++]))}break}if(64&_){e.msg="invalid distance code",C.mode=BAD$1;break e}v=m[(65535&v)+(p&(1<<_)-1)]}}break}}while(n>r&&a>i);p&=(1<<(f-=(b=f>>3)<<3))-1,e.next_in=r-=b,e.next_out=i,e.avail_in=n>r?n-r+5:5-(r-n),e.avail_out=a>i?a-i+257:257-(i-a),C.hold=p,C.bits=f},MAXBITS=15,ENOUGH_LENS$1=852,ENOUGH_DISTS$1=592,CODES$1=0,LENS$1=1,DISTS$1=2,lbase=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),lext=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),dbase=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),dext=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]),inflate_table=function(e,t,r,n,i,o,a,s){var c,u,l,d,p,f,h,m,g,y=s.bits,v=0,_=0,b=0,E=0,S=0,T=0,R=0,O=0,C=0,k=0,I=null,w=new Uint16Array(MAXBITS+1),P=new Uint16Array(MAXBITS+1),A=null;for(v=0;MAXBITS>=v;v++)w[v]=0;for(_=0;n>_;_++)w[t[r+_]]++;for(S=y,E=MAXBITS;E>=1&&0===w[E];E--);if(S>E&&(S=E),0===E)return i[o++]=20971520,i[o++]=20971520,s.bits=1,0;for(b=1;E>b&&0===w[b];b++);for(b>S&&(S=b),O=1,v=1;MAXBITS>=v;v++)if(O<<=1,0>(O-=w[v]))return-1;if(O>0&&(e===CODES$1||1!==E))return-1;for(P[1]=0,v=1;MAXBITS>v;v++)P[v+1]=P[v]+w[v];for(_=0;n>_;_++)0!==t[r+_]&&(a[P[t[r+_]]++]=_);if(e===CODES$1?(I=A=a,f=20):e===LENS$1?(I=lbase,A=lext,f=257):(I=dbase,A=dext,f=0),k=0,_=0,v=b,p=o,T=S,R=0,l=-1,d=(C=1<<S)-1,e===LENS$1&&C>ENOUGH_LENS$1||e===DISTS$1&&C>ENOUGH_DISTS$1)return 1;for(;;){h=v-R,f>a[_]+1?(m=0,g=a[_]):f>a[_]?(m=96,g=0):(m=A[a[_]-f],g=I[a[_]-f]),c=1<<v-R,b=u=1<<T;do{i[p+(k>>R)+(u-=c)]=h<<24|m<<16|g}while(0!==u);for(c=1<<v-1;k&c;)c>>=1;if(0!==c?(k&=c-1,k+=c):k=0,_++,0==--w[v]){if(v===E)break;v=t[r+a[_]]}if(v>S&&(k&d)!==l){for(0===R&&(R=S),p+=b,O=1<<(T=v-R);E>T+R&&(O-=w[T+R])>0;)T++,O<<=1;if(C+=1<<T,e===LENS$1&&C>ENOUGH_LENS$1||e===DISTS$1&&C>ENOUGH_DISTS$1)return 1;i[l=k&d]=S<<24|T<<16|p-o}}return 0!==k&&(i[p+k]=v-R<<24|64<<16),s.bits=S,0},inftrees=inflate_table,CODES=0,LENS=1,DISTS=2,Z_FINISH$1=constants$2.Z_FINISH,Z_BLOCK=constants$2.Z_BLOCK,Z_TREES=constants$2.Z_TREES,Z_OK$1=constants$2.Z_OK,Z_STREAM_END$1=constants$2.Z_STREAM_END,Z_NEED_DICT$1=constants$2.Z_NEED_DICT,Z_STREAM_ERROR$1=constants$2.Z_STREAM_ERROR,Z_DATA_ERROR$1=constants$2.Z_DATA_ERROR,Z_MEM_ERROR$1=constants$2.Z_MEM_ERROR,Z_BUF_ERROR=constants$2.Z_BUF_ERROR,Z_DEFLATED=constants$2.Z_DEFLATED,HEAD=16180,FLAGS=16181,TIME=16182,OS=16183,EXLEN=16184,EXTRA=16185,NAME=16186,COMMENT=16187,HCRC=16188,DICTID=16189,DICT=16190,TYPE=16191,TYPEDO=16192,STORED=16193,COPY_=16194,COPY=16195,TABLE=16196,LENLENS=16197,CODELENS=16198,LEN_=16199,LEN=16200,LENEXT=16201,DIST=16202,DISTEXT=16203,MATCH=16204,LIT=16205,CHECK=16206,LENGTH=16207,DONE=16208,BAD=16209,MEM=16210,SYNC=16211,ENOUGH_LENS=852,ENOUGH_DISTS=592,MAX_WBITS=15,DEF_WBITS=MAX_WBITS,zswap32=function(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)};function InflateState(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}var inflateStateCheck=function(e){if(!e)return 1;var t=e.state;return!t||t.strm!==e||HEAD>t.mode||t.mode>SYNC?1:0},inflateResetKeep=function(e){if(inflateStateCheck(e))return Z_STREAM_ERROR$1;var t=e.state;return e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=HEAD,t.last=0,t.havedict=0,t.flags=-1,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(ENOUGH_LENS),t.distcode=t.distdyn=new Int32Array(ENOUGH_DISTS),t.sane=1,t.back=-1,Z_OK$1},inflateReset=function(e){if(inflateStateCheck(e))return Z_STREAM_ERROR$1;var t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,inflateResetKeep(e)},inflateReset2=function(e,t){var r;if(inflateStateCheck(e))return Z_STREAM_ERROR$1;var n=e.state;return 0>t?(r=0,t=-t):(r=5+(t>>4),48>t&&(t&=15)),t&&(8>t||t>15)?Z_STREAM_ERROR$1:(null!==n.window&&n.wbits!==t&&(n.window=null),n.wrap=r,n.wbits=t,inflateReset(e))},inflateInit2=function(e,t){if(!e)return Z_STREAM_ERROR$1;var r=new InflateState;e.state=r,r.strm=e,r.window=null,r.mode=HEAD;var n=inflateReset2(e,t);return n!==Z_OK$1&&(e.state=null),n},inflateInit=function(e){return inflateInit2(e,DEF_WBITS)},virgin=!0,lenfix,distfix,fixedtables=function(e){if(virgin){lenfix=new Int32Array(512),distfix=new Int32Array(32);for(var t=0;144>t;)e.lens[t++]=8;for(;256>t;)e.lens[t++]=9;for(;280>t;)e.lens[t++]=7;for(;288>t;)e.lens[t++]=8;for(inftrees(LENS,e.lens,0,288,lenfix,0,e.work,{bits:9}),t=0;32>t;)e.lens[t++]=5;inftrees(DISTS,e.lens,0,32,distfix,0,e.work,{bits:5}),virgin=!1}e.lencode=lenfix,e.lenbits=9,e.distcode=distfix,e.distbits=5},updatewindow=function(e,t,r,n){var i,o=e.state;return null===o.window&&(o.wsize=1<<o.wbits,o.wnext=0,o.whave=0,o.window=new Uint8Array(o.wsize)),o.wsize>n?((i=o.wsize-o.wnext)>n&&(i=n),o.window.set(t.subarray(r-n,r-n+i),o.wnext),(n-=i)?(o.window.set(t.subarray(r-n,r),0),o.wnext=n,o.whave=o.wsize):(o.wnext+=i,o.wnext===o.wsize&&(o.wnext=0),o.wsize>o.whave&&(o.whave+=i))):(o.window.set(t.subarray(r-o.wsize,r),0),o.wnext=0,o.whave=o.wsize),0},inflate$2=function(e,t){var r,n,i,o,a,s,c,u,l,d,p,f,h,m,g,y,v,_,b,E,S,T,R,O,C=0,k=new Uint8Array(4),I=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(inflateStateCheck(e)||!e.output||!e.input&&0!==e.avail_in)return Z_STREAM_ERROR$1;(r=e.state).mode===TYPE&&(r.mode=TYPEDO),a=e.next_out,i=e.output,o=e.next_in,n=e.input,u=r.hold,l=r.bits,d=s=e.avail_in,p=c=e.avail_out,T=Z_OK$1;e:for(;;)switch(r.mode){case HEAD:if(0===r.wrap){r.mode=TYPEDO;break}for(;16>l;){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}if(2&r.wrap&&35615===u){0===r.wbits&&(r.wbits=15),r.check=0,k[0]=255&u,k[1]=u>>>8&255,r.check=crc32_1(r.check,k,2,0),u=0,l=0,r.mode=FLAGS;break}if(r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&u)<<8)+(u>>8))%31){e.msg="incorrect header check",r.mode=BAD;break}if((15&u)!==Z_DEFLATED){e.msg="unknown compression method",r.mode=BAD;break}if(l-=4,S=8+(15&(u>>>=4)),0===r.wbits&&(r.wbits=S),S>15||S>r.wbits){e.msg="invalid window size",r.mode=BAD;break}r.dmax=1<<r.wbits,r.flags=0,e.adler=r.check=1,r.mode=512&u?DICTID:TYPE,u=0,l=0;break;case FLAGS:for(;16>l;){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}if(r.flags=u,(255&r.flags)!==Z_DEFLATED){e.msg="unknown compression method",r.mode=BAD;break}if(57344&r.flags){e.msg="unknown header flags set",r.mode=BAD;break}r.head&&(r.head.text=u>>8&1),512&r.flags&&4&r.wrap&&(k[0]=255&u,k[1]=u>>>8&255,r.check=crc32_1(r.check,k,2,0)),u=0,l=0,r.mode=TIME;case TIME:for(;32>l;){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}r.head&&(r.head.time=u),512&r.flags&&4&r.wrap&&(k[0]=255&u,k[1]=u>>>8&255,k[2]=u>>>16&255,k[3]=u>>>24&255,r.check=crc32_1(r.check,k,4,0)),u=0,l=0,r.mode=OS;case OS:for(;16>l;){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}r.head&&(r.head.xflags=255&u,r.head.os=u>>8),512&r.flags&&4&r.wrap&&(k[0]=255&u,k[1]=u>>>8&255,r.check=crc32_1(r.check,k,2,0)),u=0,l=0,r.mode=EXLEN;case EXLEN:if(1024&r.flags){for(;16>l;){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}r.length=u,r.head&&(r.head.extra_len=u),512&r.flags&&4&r.wrap&&(k[0]=255&u,k[1]=u>>>8&255,r.check=crc32_1(r.check,k,2,0)),u=0,l=0}else r.head&&(r.head.extra=null);r.mode=EXTRA;case EXTRA:if(1024&r.flags&&((f=r.length)>s&&(f=s),f&&(r.head&&(S=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Uint8Array(r.head.extra_len)),r.head.extra.set(n.subarray(o,o+f),S)),512&r.flags&&4&r.wrap&&(r.check=crc32_1(r.check,n,f,o)),s-=f,o+=f,r.length-=f),r.length))break e;r.length=0,r.mode=NAME;case NAME:if(2048&r.flags){if(0===s)break e;f=0;do{S=n[o+f++],r.head&&S&&65536>r.length&&(r.head.name+=String.fromCharCode(S))}while(S&&s>f);if(512&r.flags&&4&r.wrap&&(r.check=crc32_1(r.check,n,f,o)),s-=f,o+=f,S)break e}else r.head&&(r.head.name=null);r.length=0,r.mode=COMMENT;case COMMENT:if(4096&r.flags){if(0===s)break e;f=0;do{S=n[o+f++],r.head&&S&&65536>r.length&&(r.head.comment+=String.fromCharCode(S))}while(S&&s>f);if(512&r.flags&&4&r.wrap&&(r.check=crc32_1(r.check,n,f,o)),s-=f,o+=f,S)break e}else r.head&&(r.head.comment=null);r.mode=HCRC;case HCRC:if(512&r.flags){for(;16>l;){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}if(4&r.wrap&&u!==(65535&r.check)){e.msg="header crc mismatch",r.mode=BAD;break}u=0,l=0}r.head&&(r.head.hcrc=r.flags>>9&1,r.head.done=!0),e.adler=r.check=0,r.mode=TYPE;break;case DICTID:for(;32>l;){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}e.adler=r.check=zswap32(u),u=0,l=0,r.mode=DICT;case DICT:if(0===r.havedict)return e.next_out=a,e.avail_out=c,e.next_in=o,e.avail_in=s,r.hold=u,r.bits=l,Z_NEED_DICT$1;e.adler=r.check=1,r.mode=TYPE;case TYPE:if(t===Z_BLOCK||t===Z_TREES)break e;case TYPEDO:if(r.last){u>>>=7&l,l-=7&l,r.mode=CHECK;break}for(;3>l;){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}switch(r.last=1&u,l-=1,3&(u>>>=1)){case 0:r.mode=STORED;break;case 1:if(fixedtables(r),r.mode=LEN_,t===Z_TREES){u>>>=2,l-=2;break e}break;case 2:r.mode=TABLE;break;case 3:e.msg="invalid block type",r.mode=BAD}u>>>=2,l-=2;break;case STORED:for(u>>>=7&l,l-=7&l;32>l;){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}if((65535&u)!=(u>>>16^65535)){e.msg="invalid stored block lengths",r.mode=BAD;break}if(r.length=65535&u,u=0,l=0,r.mode=COPY_,t===Z_TREES)break e;case COPY_:r.mode=COPY;case COPY:if(f=r.length){if(f>s&&(f=s),f>c&&(f=c),0===f)break e;i.set(n.subarray(o,o+f),a),s-=f,o+=f,c-=f,a+=f,r.length-=f;break}r.mode=TYPE;break;case TABLE:for(;14>l;){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}if(r.nlen=257+(31&u),l-=5,r.ndist=1+(31&(u>>>=5)),l-=5,r.ncode=4+(15&(u>>>=5)),u>>>=4,l-=4,r.nlen>286||r.ndist>30){e.msg="too many length or distance symbols",r.mode=BAD;break}r.have=0,r.mode=LENLENS;case LENLENS:for(;r.ncode>r.have;){for(;3>l;){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}r.lens[I[r.have++]]=7&u,u>>>=3,l-=3}for(;19>r.have;)r.lens[I[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,T=inftrees(CODES,r.lens,0,19,r.lencode,0,r.work,R={bits:r.lenbits}),r.lenbits=R.bits,T){e.msg="invalid code lengths set",r.mode=BAD;break}r.have=0,r.mode=CODELENS;case CODELENS:for(;r.nlen+r.ndist>r.have;){for(;y=(C=r.lencode[u&(1<<r.lenbits)-1])>>>16&255,v=65535&C,(g=C>>>24)>l;){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}if(16>v)u>>>=g,l-=g,r.lens[r.have++]=v;else{if(16===v){for(O=g+2;O>l;){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}if(u>>>=g,l-=g,0===r.have){e.msg="invalid bit length repeat",r.mode=BAD;break}S=r.lens[r.have-1],f=3+(3&u),u>>>=2,l-=2}else if(17===v){for(O=g+3;O>l;){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}l-=g,S=0,f=3+(7&(u>>>=g)),u>>>=3,l-=3}else{for(O=g+7;O>l;){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}l-=g,S=0,f=11+(127&(u>>>=g)),u>>>=7,l-=7}if(r.have+f>r.nlen+r.ndist){e.msg="invalid bit length repeat",r.mode=BAD;break}for(;f--;)r.lens[r.have++]=S}}if(r.mode===BAD)break;if(0===r.lens[256]){e.msg="invalid code -- missing end-of-block",r.mode=BAD;break}if(r.lenbits=9,T=inftrees(LENS,r.lens,0,r.nlen,r.lencode,0,r.work,R={bits:r.lenbits}),r.lenbits=R.bits,T){e.msg="invalid literal/lengths set",r.mode=BAD;break}if(r.distbits=6,r.distcode=r.distdyn,T=inftrees(DISTS,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,R={bits:r.distbits}),r.distbits=R.bits,T){e.msg="invalid distances set",r.mode=BAD;break}if(r.mode=LEN_,t===Z_TREES)break e;case LEN_:r.mode=LEN;case LEN:if(s>=6&&c>=258){e.next_out=a,e.avail_out=c,e.next_in=o,e.avail_in=s,r.hold=u,r.bits=l,inffast(e,p),a=e.next_out,i=e.output,c=e.avail_out,o=e.next_in,n=e.input,s=e.avail_in,u=r.hold,l=r.bits,r.mode===TYPE&&(r.back=-1);break}for(r.back=0;y=(C=r.lencode[u&(1<<r.lenbits)-1])>>>16&255,v=65535&C,(g=C>>>24)>l;){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}if(y&&!(240&y)){for(_=g,b=y,E=v;y=(C=r.lencode[E+((u&(1<<_+b)-1)>>_)])>>>16&255,v=65535&C,_+(g=C>>>24)>l;){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}u>>>=_,l-=_,r.back+=_}if(u>>>=g,l-=g,r.back+=g,r.length=v,0===y){r.mode=LIT;break}if(32&y){r.back=-1,r.mode=TYPE;break}if(64&y){e.msg="invalid literal/length code",r.mode=BAD;break}r.extra=15&y,r.mode=LENEXT;case LENEXT:if(r.extra){for(O=r.extra;O>l;){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}r.length+=u&(1<<r.extra)-1,u>>>=r.extra,l-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=DIST;case DIST:for(;y=(C=r.distcode[u&(1<<r.distbits)-1])>>>16&255,v=65535&C,(g=C>>>24)>l;){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}if(!(240&y)){for(_=g,b=y,E=v;y=(C=r.distcode[E+((u&(1<<_+b)-1)>>_)])>>>16&255,v=65535&C,_+(g=C>>>24)>l;){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}u>>>=_,l-=_,r.back+=_}if(u>>>=g,l-=g,r.back+=g,64&y){e.msg="invalid distance code",r.mode=BAD;break}r.offset=v,r.extra=15&y,r.mode=DISTEXT;case DISTEXT:if(r.extra){for(O=r.extra;O>l;){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}r.offset+=u&(1<<r.extra)-1,u>>>=r.extra,l-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){e.msg="invalid distance too far back",r.mode=BAD;break}r.mode=MATCH;case MATCH:if(0===c)break e;if(r.offset>(f=p-c)){if((f=r.offset-f)>r.whave&&r.sane){e.msg="invalid distance too far back",r.mode=BAD;break}f>r.wnext?h=r.wsize-(f-=r.wnext):h=r.wnext-f,f>r.length&&(f=r.length),m=r.window}else m=i,h=a-r.offset,f=r.length;f>c&&(f=c),c-=f,r.length-=f;do{i[a++]=m[h++]}while(--f);0===r.length&&(r.mode=LEN);break;case LIT:if(0===c)break e;i[a++]=r.length,c--,r.mode=LEN;break;case CHECK:if(r.wrap){for(;32>l;){if(0===s)break e;s--,u|=n[o++]<<l,l+=8}if(e.total_out+=p-=c,r.total+=p,4&r.wrap&&p&&(e.adler=r.check=r.flags?crc32_1(r.check,i,p,a-p):adler32_1(r.check,i,p,a-p)),p=c,4&r.wrap&&(r.flags?u:zswap32(u))!==r.check){e.msg="incorrect data check",r.mode=BAD;break}u=0,l=0}r.mode=LENGTH;case LENGTH:if(r.wrap&&r.flags){for(;32>l;){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}if(4&r.wrap&&u!==(4294967295&r.total)){e.msg="incorrect length check",r.mode=BAD;break}u=0,l=0}r.mode=DONE;case DONE:T=Z_STREAM_END$1;break e;case BAD:T=Z_DATA_ERROR$1;break e;case MEM:return Z_MEM_ERROR$1;default:return Z_STREAM_ERROR$1}return e.next_out=a,e.avail_out=c,e.next_in=o,e.avail_in=s,r.hold=u,r.bits=l,(r.wsize||p!==e.avail_out&&BAD>r.mode&&(CHECK>r.mode||t!==Z_FINISH$1))&&updatewindow(e,e.output,e.next_out,p-e.avail_out),p-=e.avail_out,e.total_in+=d-=e.avail_in,e.total_out+=p,r.total+=p,4&r.wrap&&p&&(e.adler=r.check=r.flags?crc32_1(r.check,i,p,e.next_out-p):adler32_1(r.check,i,p,e.next_out-p)),e.data_type=r.bits+(r.last?64:0)+(r.mode===TYPE?128:0)+(r.mode===LEN_||r.mode===COPY_?256:0),(0===d&&0===p||t===Z_FINISH$1)&&T===Z_OK$1&&(T=Z_BUF_ERROR),T},inflateEnd=function(e){if(inflateStateCheck(e))return Z_STREAM_ERROR$1;var t=e.state;return t.window&&(t.window=null),e.state=null,Z_OK$1},inflateGetHeader=function(e,t){if(inflateStateCheck(e))return Z_STREAM_ERROR$1;var r=e.state;return 2&r.wrap?(r.head=t,t.done=!1,Z_OK$1):Z_STREAM_ERROR$1},inflateSetDictionary=function(e,t){var r,n=t.length;return inflateStateCheck(e)?Z_STREAM_ERROR$1:0!==(r=e.state).wrap&&r.mode!==DICT?Z_STREAM_ERROR$1:r.mode===DICT&&adler32_1(1,t,n,0)!==r.check?Z_DATA_ERROR$1:updatewindow(e,t,n,n)?(r.mode=MEM,Z_MEM_ERROR$1):(r.havedict=1,Z_OK$1)},inflateReset_1=inflateReset,inflateReset2_1=inflateReset2,inflateResetKeep_1=inflateResetKeep,inflateInit_1=inflateInit,inflateInit2_1=inflateInit2,inflate_2$1=inflate$2,inflateEnd_1=inflateEnd,inflateGetHeader_1=inflateGetHeader,inflateSetDictionary_1=inflateSetDictionary,inflateInfo="pako inflate (from Nodeca project)",inflate_1$2={inflateReset:inflateReset_1,inflateReset2:inflateReset2_1,inflateResetKeep:inflateResetKeep_1,inflateInit:inflateInit_1,inflateInit2:inflateInit2_1,inflate:inflate_2$1,inflateEnd:inflateEnd_1,inflateGetHeader:inflateGetHeader_1,inflateSetDictionary:inflateSetDictionary_1,inflateInfo:inflateInfo};function GZheader(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}var gzheader=GZheader,toString=Object.prototype.toString,Z_NO_FLUSH=constants$2.Z_NO_FLUSH,Z_FINISH=constants$2.Z_FINISH,Z_OK=constants$2.Z_OK,Z_STREAM_END=constants$2.Z_STREAM_END,Z_NEED_DICT=constants$2.Z_NEED_DICT,Z_STREAM_ERROR=constants$2.Z_STREAM_ERROR,Z_DATA_ERROR=constants$2.Z_DATA_ERROR,Z_MEM_ERROR=constants$2.Z_MEM_ERROR;function Inflate$1(e){this.options=common.assign({chunkSize:65536,windowBits:15,to:""},e||{});var t=this.options;t.raw&&t.windowBits>=0&&16>t.windowBits&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),0>t.windowBits||t.windowBits>=16||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&48>t.windowBits&&(15&t.windowBits||(t.windowBits|=15)),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new zstream,this.strm.avail_out=0;var r=inflate_1$2.inflateInit2(this.strm,t.windowBits);if(r!==Z_OK)throw Error(messages[r]);if(this.header=new gzheader,inflate_1$2.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=strings.string2buf(t.dictionary):"[object ArrayBuffer]"===toString.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(r=inflate_1$2.inflateSetDictionary(this.strm,t.dictionary))!==Z_OK))throw Error(messages[r])}function inflate$1(e,t){var r=new Inflate$1(t);if(r.push(e),r.err)throw r.msg||messages[r.err];return r.result}function inflateRaw$1(e,t){return(t=t||{}).raw=!0,inflate$1(e,t)}Inflate$1.prototype.push=function(e,t){var r,n,i,o=this.strm,a=this.options.chunkSize,s=this.options.dictionary;if(this.ended)return!1;for(n=t===~~t?t:!0===t?Z_FINISH:Z_NO_FLUSH,o.input="[object ArrayBuffer]"===toString.call(e)?new Uint8Array(e):e,o.next_in=0,o.avail_in=o.input.length;;){for(0===o.avail_out&&(o.output=new Uint8Array(a),o.next_out=0,o.avail_out=a),(r=inflate_1$2.inflate(o,n))===Z_NEED_DICT&&s&&((r=inflate_1$2.inflateSetDictionary(o,s))===Z_OK?r=inflate_1$2.inflate(o,n):r===Z_DATA_ERROR&&(r=Z_NEED_DICT));o.avail_in>0&&r===Z_STREAM_END&&o.state.wrap>0&&0!==e[o.next_in];)inflate_1$2.inflateReset(o),r=inflate_1$2.inflate(o,n);switch(r){case Z_STREAM_ERROR:case Z_DATA_ERROR:case Z_NEED_DICT:case Z_MEM_ERROR:return this.onEnd(r),this.ended=!0,!1}if(i=o.avail_out,o.next_out&&(0===o.avail_out||r===Z_STREAM_END))if("string"===this.options.to){var c=strings.utf8border(o.output,o.next_out),u=o.next_out-c,l=strings.buf2string(o.output,c);o.next_out=u,o.avail_out=a-u,u&&o.output.set(o.output.subarray(c,c+u),0),this.onData(l)}else this.onData(o.output.length===o.next_out?o.output:o.output.subarray(0,o.next_out));if(r!==Z_OK||0!==i){if(r===Z_STREAM_END)return r=inflate_1$2.inflateEnd(this.strm),this.onEnd(r),this.ended=!0,!0;if(0===o.avail_in)break}}return!0},Inflate$1.prototype.onData=function(e){this.chunks.push(e)},Inflate$1.prototype.onEnd=function(e){e===Z_OK&&(this.result="string"===this.options.to?this.chunks.join(""):common.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var Inflate_1$1=Inflate$1,inflate_2=inflate$1,inflateRaw_1$1=inflateRaw$1,ungzip$1=inflate$1,constants=constants$2,inflate_1$1={Inflate:Inflate_1$1,inflate:inflate_2,inflateRaw:inflateRaw_1$1,ungzip:ungzip$1,constants:constants},Deflate=deflate_1$1.Deflate,deflate=deflate_1$1.deflate,deflateRaw=deflate_1$1.deflateRaw,gzip=deflate_1$1.gzip,Inflate=inflate_1$1.Inflate,inflate=inflate_1$1.inflate,inflateRaw=inflate_1$1.inflateRaw,ungzip=inflate_1$1.ungzip,Deflate_1=Deflate,deflate_1=deflate,deflateRaw_1=deflateRaw,gzip_1=gzip,Inflate_1=Inflate,inflate_1=inflate,inflateRaw_1=inflateRaw,ungzip_1=ungzip,constants_1=constants$2,pako={Deflate:Deflate_1,deflate:deflate_1,deflateRaw:deflateRaw_1,gzip:gzip_1,Inflate:Inflate_1,inflate:inflate_1,inflateRaw:inflateRaw_1,ungzip:ungzip_1,constants:constants_1},SLS_PROTO={nested:{sls:{nested:{Log:{fields:{Time:{rule:"required",type:"uint32",id:1},Contents:{rule:"repeated",type:"Content",id:2}},nested:{Content:{fields:{Key:{rule:"required",type:"string",id:1},Value:{rule:"required",type:"string",id:2}}}}},LogTag:{fields:{Key:{rule:"required",type:"string",id:1},Value:{rule:"required",type:"string",id:2}}},LogGroup:{fields:{Logs:{rule:"repeated",type:"Log",id:1},Reserved:{type:"string",id:2},Topic:{type:"string",id:3},Source:{type:"string",id:4},LogTags:{rule:"repeated",type:"LogTag",id:6}}},LogGroupList:{fields:{logGroupList:{rule:"repeated",type:"LogGroup",id:1}}}}}}},md5={exports:{}};md5.exports=function(e){return function(t){var r=e,n=r.lib,i=n.WordArray,o=n.Hasher,a=r.algo,s=[];!function(){for(var e=0;64>e;e++)s[e]=4294967296*t.abs(t.sin(e+1))|0}();var c=a.MD5=o.extend({_doReset:function(){this._hash=new i.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,t){for(var r=0;16>r;r++){var n=t+r,i=e[n];e[n]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8)}var o=this._hash.words,a=e[t+0],c=e[t+1],f=e[t+2],h=e[t+3],m=e[t+4],g=e[t+5],y=e[t+6],v=e[t+7],_=e[t+8],b=e[t+9],E=e[t+10],S=e[t+11],T=e[t+12],R=e[t+13],O=e[t+14],C=e[t+15],k=o[0],I=o[1],w=o[2],P=o[3];k=u(k,I,w,P,a,7,s[0]),P=u(P,k,I,w,c,12,s[1]),w=u(w,P,k,I,f,17,s[2]),I=u(I,w,P,k,h,22,s[3]),k=u(k,I,w,P,m,7,s[4]),P=u(P,k,I,w,g,12,s[5]),w=u(w,P,k,I,y,17,s[6]),I=u(I,w,P,k,v,22,s[7]),k=u(k,I,w,P,_,7,s[8]),P=u(P,k,I,w,b,12,s[9]),w=u(w,P,k,I,E,17,s[10]),I=u(I,w,P,k,S,22,s[11]),k=u(k,I,w,P,T,7,s[12]),P=u(P,k,I,w,R,12,s[13]),w=u(w,P,k,I,O,17,s[14]),k=l(k,I=u(I,w,P,k,C,22,s[15]),w,P,c,5,s[16]),P=l(P,k,I,w,y,9,s[17]),w=l(w,P,k,I,S,14,s[18]),I=l(I,w,P,k,a,20,s[19]),k=l(k,I,w,P,g,5,s[20]),P=l(P,k,I,w,E,9,s[21]),w=l(w,P,k,I,C,14,s[22]),I=l(I,w,P,k,m,20,s[23]),k=l(k,I,w,P,b,5,s[24]),P=l(P,k,I,w,O,9,s[25]),w=l(w,P,k,I,h,14,s[26]),I=l(I,w,P,k,_,20,s[27]),k=l(k,I,w,P,R,5,s[28]),P=l(P,k,I,w,f,9,s[29]),w=l(w,P,k,I,v,14,s[30]),k=d(k,I=l(I,w,P,k,T,20,s[31]),w,P,g,4,s[32]),P=d(P,k,I,w,_,11,s[33]),w=d(w,P,k,I,S,16,s[34]),I=d(I,w,P,k,O,23,s[35]),k=d(k,I,w,P,c,4,s[36]),P=d(P,k,I,w,m,11,s[37]),w=d(w,P,k,I,v,16,s[38]),I=d(I,w,P,k,E,23,s[39]),k=d(k,I,w,P,R,4,s[40]),P=d(P,k,I,w,a,11,s[41]),w=d(w,P,k,I,h,16,s[42]),I=d(I,w,P,k,y,23,s[43]),k=d(k,I,w,P,b,4,s[44]),P=d(P,k,I,w,T,11,s[45]),w=d(w,P,k,I,C,16,s[46]),k=p(k,I=d(I,w,P,k,f,23,s[47]),w,P,a,6,s[48]),P=p(P,k,I,w,v,10,s[49]),w=p(w,P,k,I,O,15,s[50]),I=p(I,w,P,k,g,21,s[51]),k=p(k,I,w,P,T,6,s[52]),P=p(P,k,I,w,h,10,s[53]),w=p(w,P,k,I,E,15,s[54]),I=p(I,w,P,k,c,21,s[55]),k=p(k,I,w,P,_,6,s[56]),P=p(P,k,I,w,C,10,s[57]),w=p(w,P,k,I,y,15,s[58]),I=p(I,w,P,k,R,21,s[59]),k=p(k,I,w,P,m,6,s[60]),P=p(P,k,I,w,S,10,s[61]),w=p(w,P,k,I,f,15,s[62]),I=p(I,w,P,k,b,21,s[63]),o[0]=o[0]+k|0,o[1]=o[1]+I|0,o[2]=o[2]+w|0,o[3]=o[3]+P|0},_doFinalize:function(){var e=this._data,r=e.words,n=8*this._nDataBytes,i=8*e.sigBytes;r[i>>>5]|=128<<24-i%32;var o=t.floor(n/4294967296),a=n;r[15+(i+64>>>9<<4)]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),r[14+(i+64>>>9<<4)]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8),e.sigBytes=4*(r.length+1),this._process();for(var s=this._hash,c=s.words,u=0;4>u;u++){var l=c[u];c[u]=16711935&(l<<8|l>>>24)|4278255360&(l<<24|l>>>8)}return s},clone:function(){var e=o.clone.call(this);return e._hash=this._hash.clone(),e}});function u(e,t,r,n,i,o,a){var s=e+(t&r|~t&n)+i+a;return(s<<o|s>>>32-o)+t}function l(e,t,r,n,i,o,a){var s=e+(t&n|r&~n)+i+a;return(s<<o|s>>>32-o)+t}function d(e,t,r,n,i,o,a){var s=e+(t^r^n)+i+a;return(s<<o|s>>>32-o)+t}function p(e,t,r,n,i,o,a){var s=e+(r^(t|~n))+i+a;return(s<<o|s>>>32-o)+t}r.MD5=o._createHelper(c),r.HmacMD5=o._createHmacHelper(c)}(Math),e.MD5}(requireCore());var md5Exports=md5.exports,MD5=getDefaultExportFromCjs(md5Exports),libTypedarrays={exports:{}};libTypedarrays.exports=function(e){return function(){if("function"==typeof ArrayBuffer){var t=e.lib.WordArray,r=t.init,n=t.init=function(e){if(e instanceof ArrayBuffer&&(e=new Uint8Array(e)),(e instanceof Int8Array||"undefined"!=typeof Uint8ClampedArray&&e instanceof Uint8ClampedArray||e instanceof Int16Array||e instanceof Uint16Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Float32Array||e instanceof Float64Array)&&(e=new Uint8Array(e.buffer,e.byteOffset,e.byteLength)),e instanceof Uint8Array){for(var t=e.byteLength,n=[],i=0;t>i;i++)n[i>>>2]|=e[i]<<24-i%4*8;r.call(this,n,t)}else r.apply(this,arguments)};n.prototype=t}}(),e.lib.WordArray}(requireCore());var libTypedarraysExports=libTypedarrays.exports,TypedArray=getDefaultExportFromCjs(libTypedarraysExports),hmacSha1={exports:{}},sha1={exports:{}},hasRequiredSha1;function requireSha1(){return hasRequiredSha1||(hasRequiredSha1=1,sha1.exports=function(e){return n=(r=(t=e).lib).WordArray,o=[],a=t.algo.SHA1=(i=r.Hasher).extend({_doReset:function(){this._hash=new n.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(e,t){for(var r=this._hash.words,n=r[0],i=r[1],a=r[2],s=r[3],c=r[4],u=0;80>u;u++){if(16>u)o[u]=0|e[t+u];else{var l=o[u-3]^o[u-8]^o[u-14]^o[u-16];o[u]=l<<1|l>>>31}var d=(n<<5|n>>>27)+c+o[u];d+=20>u?1518500249+(i&a|~i&s):40>u?1859775393+(i^a^s):60>u?(i&a|i&s|a&s)-1894007588:(i^a^s)-899497514,c=s,s=a,a=i<<30|i>>>2,i=n,n=d}r[0]=r[0]+n|0,r[1]=r[1]+i|0,r[2]=r[2]+a|0,r[3]=r[3]+s|0,r[4]=r[4]+c|0},_doFinalize:function(){var e=this._data,t=e.words,r=8*this._nDataBytes,n=8*e.sigBytes;return t[n>>>5]|=128<<24-n%32,t[14+(n+64>>>9<<4)]=Math.floor(r/4294967296),t[15+(n+64>>>9<<4)]=r,e.sigBytes=4*t.length,this._process(),this._hash},clone:function(){var e=i.clone.call(this);return e._hash=this._hash.clone(),e}}),t.SHA1=i._createHelper(a),t.HmacSHA1=i._createHmacHelper(a),e.SHA1;var t,r,n,i,o,a}(requireCore())),sha1.exports}var hmac={exports:{}},hasRequiredHmac;function requireHmac(){return hasRequiredHmac||(hasRequiredHmac=1,hmac.exports=function(e){var t;t=e.enc.Utf8,e.algo.HMAC=e.lib.Base.extend({init:function(e,r){e=this._hasher=new e.init,"string"==typeof r&&(r=t.parse(r));var n=e.blockSize,i=4*n;r.sigBytes>i&&(r=e.finalize(r)),r.clamp();for(var o=this._oKey=r.clone(),a=this._iKey=r.clone(),s=o.words,c=a.words,u=0;n>u;u++)s[u]^=1549556828,c[u]^=909522486;o.sigBytes=a.sigBytes=i,this.reset()},reset:function(){var e=this._hasher;e.reset(),e.update(this._iKey)},update:function(e){return this._hasher.update(e),this},finalize:function(e){var t=this._hasher,r=t.finalize(e);return t.reset(),t.finalize(this._oKey.clone().concat(r))}})}(requireCore())),hmac.exports}hmacSha1.exports=function(e){return e.HmacSHA1}(requireCore(),requireSha1(),requireHmac());var hmacSha1Exports=hmacSha1.exports,HmacSHA1=getDefaultExportFromCjs(hmacSha1Exports),builder=getProtobufRoot(SLS_PROTO),LogContentProto=builder.lookupType("sls.Log.Content"),LogGroupProto=builder.lookupType("sls.LogGroup"),getCanonicalizedHeaders=function(e){for(var t=Object.keys(e),r=[],n=0;t.length>n;n++){var i=t[n];(i.startsWith("x-log-")||i.startsWith("x-acs-"))&&r.push(i)}r.sort();for(var o="",a=0;r.length>a;a++){var s=r[a];o+="".concat(s,":").concat((e[s]+"").trim(),"\n")}return o},getCanonicalizedResource=function(e,t){for(var r="".concat(e),n=Object.keys(t),i=Array(n.length),o=0;n.length>o;o++){var a=n[o];i[o]="".concat(a,"=").concat(t[a]||"")}i.sort();var s=i.join("&");return s&&(r+="?".concat(s)),r},sign=function(e,t,r,n){var i=r["Content-MD5"]||"",o=r["Content-Type"],a=r.Date,s=getCanonicalizedHeaders(r),c=getCanonicalizedResource(e,t),u=["POST",i,o,a,"".concat(s).concat(c)].join("\n"),l=Base64.stringify(HmacSHA1(u,n.credentials.accessKeySecret));return"LOG ".concat(n.credentials.accessKeyId,":").concat(l)},postLog=function(e,t,r,n){var i=e.project,o=e.endpoint,a=e.credentials,s="/logstores/".concat(e.logstore,"/shards/lb"),c=i?i+".":"",u="?".concat(new URLSearchParams(t)).replace(/\?$/,""),l=window.location.href.indexOf("file://")>-1?"http://":"//",d="".concat(l).concat(c).concat(o.replace(/https?:\/\//,"")).concat(s).concat(u),p=new Date(getTime()).toUTCString(),f={"Content-Type":"application/x-protobuf","x-log-compresstype":"deflate","x-log-bodyrawsize":n,Date:p,Host:"".concat(c).concat(o),"x-log-apiversion":"0.6.0","x-log-signaturemethod":"hmac-sha1",Authorization:"","x-acs-security-token":a.securityToken};return r&&(f["Content-MD5"]=(""+MD5(TypedArray.create(r))).toUpperCase(),f["Content-Length"]=r.length),f.Authorization=sign(s,t,f,e),f["x-log-date"]=p,{url:d,param:{method:"POST",body:r,headers:f}}},getUploadParam=function(e,t){var r,n=parseInt((getTime()+"").substr(0,10)),i={Logs:[],Topic:"Event Track"};if(e.forEach((function(e){i.Logs.push({Time:n,Contents:Object.keys(e).map((function(t){var r={Key:t,Value:e[t]+""},n=LogContentProto.verify(r);if(n)throw n;return r}))})})),r=LogGroupProto.verify(i))throw Error(r);var o=LogGroupProto.create(i),a=LogGroupProto.encode(o).finish(),s=pako.deflate(a);return postLog(t,{},s,a.byteLength)},_excute2=function(e,t,r){return new Promise((function(n,i){fetch(e,t).then(n).catch((function(n){++r>3?i(n):setTimeout((function(){_excute2(e,t,r)}),500*(r+1))}))}))},post=function(e,t){if(e.length){var r=getUploadParam(e,t);return _excute2(r.url,r.param,0)}},UPLOADTIMER=5e3,UPLOADITEMMAX=10,SlsClient=_createClass((function e(t,r){var n=this;_classCallCheck(this,e),Object.defineProperty(this,"logService",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"cache",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"statsCache",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"tokenManager",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"eventTriggedTimer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"cycleStatsTimer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"cycleStatsInterval",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"eventTriggedInterval",{enumerable:!0,configurable:!0,writable:!0,value:void 0});var i=t.securityToken,o=t.cycleStatsConfig;this.logService=t.logService,this.cache=[],this.statsCache=[],this.cycleStatsInterval=o.uploadIntervalMs||UPLOAD_LOG_INTERVAL,this.eventTriggedInterval=UPLOADTIMER,this.tokenManager=new STSTokenManager(i,r,this.logService.credentials),this.tokenManager.on("update",(function(e){n.logService=e})),this.upload(!1,"eventTrigged"),this.cycleStatsTimer=addTimer((function(){n.upload(!0,"cycleStats")}),this.cycleStatsInterval,"interval"),this.eventTriggedTimer=addTimer((function(){n.upload(!1,"eventTrigged")}),this.eventTriggedInterval,"interval")}),[{key:"securityToken",get:function(){var e;return null===(e=this.tokenManager)||void 0===e||null===(e=e.securityToken)||void 0===e?void 0:e.securityToken}},{key:"stopUpdateToken",value:function(){this.tokenManager.stopUpdateToken()}},{key:"send",value:function(e){var t=e.cycleStats;delete e.serverDiffTime,t?(delete e.cycleStats,this.sendStats(e)):this.cache.push(e)}},{key:"sendStats",value:function(e){this.statsCache.push(e)}},{key:"flush",value:function(){this.upload(!0,"eventTrigged"),this.upload(!0,"cycleStats")}},{key:"upload",value:function(){var e;return e="eventTrigged"===(arguments.length>1&&void 0!==arguments[1]?arguments[1]:"eventTrigged")?arguments.length>0&&void 0!==arguments[0]&&arguments[0]?this.cache.splice(0):this.cache.splice(0,UPLOADITEMMAX):this.statsCache.splice(0),post(e,this.logService)}},{key:"clear",value:function(){this.eventTriggedTimer&&(removeTimer(this.eventTriggedTimer,"interval"),this.eventTriggedTimer=null),this.cycleStatsTimer&&(removeTimer(this.cycleStatsTimer,"interval"),this.cycleStatsTimer=null)}}]),Logging=_createClass((function e(){_classCallCheck(this,e),Object.defineProperty(this,"commonInfo",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"cache",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"slsClient",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.cache=[],this.slsClient=null,this.commonInfo={}}),[{key:"updateCommonInfo",value:function(e){this.commonInfo=Object.assign({},this.commonInfo,e)}},{key:"start",value:function(e){this.slsClient=new SlsClient(e,this.commonInfo),this.clear()}},{key:"stop",value:function(){var e,t;this.clear(),null===(e=this.slsClient)||void 0===e||e.stopUpdateToken(),null===(t=this.slsClient)||void 0===t||t.clear()}},{key:"send",value:function(e){var t=new Date(getTime());e.date=t.getTime(),e.timeStr="".concat(t.toLocaleString(),":").concat(t.getMilliseconds()),e.acs=Environment.networkType||"unknown",0===this.cache.length&&this.commonInfo.apid?this.realSend(e):this.cache.push(e)}},{key:"clear",value:function(){var e=this;this.cache.length&&this.cache.splice(0).forEach((function(t){e.realSend(t)})),this.slsClient&&this.slsClient.flush()}},{key:"realSend",value:function(e){var t=Object.assign({},this.commonInfo,e);this.slsClient&&this.slsClient.send(t)}}]);function ownKeys$1$1(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function _objectSpread$1$1(e){for(var t=1;arguments.length>t;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ownKeys$1$1(Object(r),!0).forEach((function(t){_defineProperty$1(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ownKeys$1$1(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var WebTrackingClient=_createClass((function e(){_classCallCheck(this,e),Object.defineProperty(this,"commonInfo",{enumerable:!0,configurable:!0,writable:!0,value:{}})}),[{key:"updateCommonInfo",value:function(e){this.commonInfo=Object.assign({},this.commonInfo,e)}},{key:"gslbAccess",value:function(e,t){this.send({event:"gslbAccess",success:e,message:t})}},{key:"send",value:function(e){var t=new Date(getTime());e.date=t.getTime(),e.timeStr="".concat(t.toLocaleString(),":").concat(t.getMilliseconds());var r=_objectSpread$1$1(_objectSpread$1$1({},this.commonInfo),{},{tm:e.date},e);(new Image).src="".concat(BaseWebTrackingURL,"&").concat(new URLSearchParams(r))}}]);function ownKeys$a(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function _objectSpread$a(e){for(var t=1;arguments.length>t;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ownKeys$a(Object(r),!0).forEach((function(t){_defineProperty$1(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ownKeys$a(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var SLSSender=_createClass((function e(){_classCallCheck(this,e),Object.defineProperty(this,"logging",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"statsConfig",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.logging=new Logging}),[{key:"simpleLogger",value:function(e){this.logging.send(_objectSpread$a(_objectSpread$a({},TraceEvent$1.SIMPLE_LOGGER),{},{log:e}))}},{key:"start",value:function(e){var t=e.cycleStatsConfig;this.logging.start(e),this.statsConfig=t}},{key:"stop",value:function(){this.logging.stop()}},{key:"securityToken",get:function(){var e;return null===(e=this.logging)||void 0===e||null===(e=e.slsClient)||void 0===e?void 0:e.securityToken}},{key:"updateSecurityToken",value:function(e){var t;return null===(t=this.logging)||void 0===t?void 0:t.slsClient.tokenManager.updateSecurityToken(e)}},{key:"sendMetric",value:function(e){return this.logging.send(_objectSpread$a(_objectSpread$a({},e),{},{cycleStats:!0}))}},{key:"sendEvent",value:function(e){return this.logging.send(_objectSpread$a({},e))}},{key:"exception",value:function(e){this.logging.send(_objectSpread$a(_objectSpread$a({},TraceEvent$1.EXCEPTION),{},{code:e.code,message:e.message,name:e.name}))}}]),MAX_LOG_COUNT=5e3,ONE_FLUSH_LIMIT=500,ONE_FLUSH_CHAR_COUNT_LIMIT=5e5,LOG_LEVEL_NUM={debug:1,info:10,warn:20,error:30,none:99},Logger=function(){function e(){var t,r=this,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";_classCallCheck(this,e),Object.defineProperty(this,"logBuffer",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"metricBuffer",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"envInfo",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"isFlushing",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"logSendFunction",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"afterPrinter",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"loggerPrefix",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"flushLog",{enumerable:!0,configurable:!0,writable:!0,value:(t=_asyncToGenerator(_regeneratorRuntime.mark((function e(){var t,n,i,o;return _regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!r.logBuffer.length||r.isFlushing){e.next=17;break}if(r.isFlushing=!0,t=r.logBuffer.length,r.logBuffer.length>ONE_FLUSH_LIMIT&&(t=ONE_FLUSH_LIMIT),r.logSendFunction){e.next=8;break}return r.isFlushing=!1,e.abrupt("return",Promise.reject("no log sender"));case 8:for(n=r.logBuffer.slice(0,t),i=n.map((function(e){return JSON.stringify(e)})),o=i.length?i.reduce((function(e,t){return e+t.length}),0):0;o>ONE_FLUSH_CHAR_COUNT_LIMIT&&n.length>=2;)n=n.slice(0,n.length/2),i=n.map((function(e){return JSON.stringify(e)})),o=i.length?i.reduce((function(e,t){return e+t.length}),0):0;return o>ONE_FLUSH_CHAR_COUNT_LIMIT&&(console.error("error: truncated logs for flushing log size is too large",n),i=["error: truncated logs for flushing log size is too large"]),e.abrupt("return",(0,r.logSendFunction)(i).then((function(e){e&&e.success&&r.logBuffer.splice(0,t)})).catch((function(e){console.warn("caught flushLogs error",e)})).finally((function(){r.isFlushing=!1})));case 17:return e.abrupt("return",Promise.resolve());case 18:case"end":return e.stop()}}),e)}))),function(){return t.apply(this,arguments)})}),this.loggerPrefix=n}return _createClass(e,[{key:"getLogger",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=function(){var e=_asyncToGenerator(_regeneratorRuntime.mark((function e(){return _regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return");case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),i={debug:n,info:n,warn:n,error:n};return["debug","info","warn","error"].forEach((function(n){return i[n]=t.log(n,"".concat(e,":"),r)})),i}},{key:"pushToMetricBuffer",value:function(e){MAX_LOG_COUNT>this.metricBuffer.length?this.metricBuffer.push(e):console.error("drop metric for log buffer is full: ",e)}},{key:"pushToLogBuffer",value:function(e){MAX_LOG_COUNT>this.logBuffer.length?this.logBuffer.push(e):console.error("drop log for log buffer is full: ",e)}},{key:"log",value:function(t){for(var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.loggerPrefix,i=arguments.length,o=Array(i>2?i-2:0),a=2;i>a;a++)o[a-2]=arguments[a];var s=[formatToBeijingTime(new Date(getTime())),t.toLocaleUpperCase(),n].concat(o);"none"===t||e.levelThreshold>LOG_LEVEL_NUM[t]||Function.apply.call(console[t],console,s);var c=tryJsonStringify(s);null===(r=this.afterPrinter)||void 0===r||r.call(this,c),this.logSendFunction&&this.pushToLogBuffer(c)}},{key:"debug",value:function(){for(var e=arguments.length,t=Array(e),r=0;e>r;r++)t[r]=arguments[r];return this.log.apply(this,["debug",void 0,""].concat(t))}},{key:"info",value:function(){for(var e=arguments.length,t=Array(e),r=0;e>r;r++)t[r]=arguments[r];return this.log.apply(this,["info",void 0,""].concat(t))}},{key:"warn",value:function(){for(var e=arguments.length,t=Array(e),r=0;e>r;r++)t[r]=arguments[r];return this.log.apply(this,["warn",void 0,""].concat(t))}},{key:"error",value:function(){for(var e=arguments.length,t=Array(e),r=0;e>r;r++)t[r]=arguments[r];return this.log.apply(this,["error",void 0,""].concat(t))}},{key:"injectLogSender",value:function(e){this.logSendFunction=e}},{key:"injectLogPrint",value:function(e){this.afterPrinter=e}}],[{key:"setLogLevel",value:function(t){e.levelThreshold=LOG_LEVEL_NUM[t]}}])}();Object.defineProperty(Logger,"levelThreshold",{enumerable:!0,configurable:!0,writable:!0,value:LOG_LEVEL_NUM.info});var Reporter=_createClass((function e(){var t=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";_classCallCheck(this,e),Object.defineProperty(this,"trace",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metric",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"log",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"id",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"sender",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"webtracking",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"commonInfo",{enumerable:!0,configurable:!0,writable:!0,value:{bt:Environment.browserType,bv:Environment.browserVersion,osn:Environment.system,osv:Environment.systemVersion}}),this.sender=new SLSSender,this.webtracking=new WebTrackingClient,this.trace=new Trace(this.webtracking,this.sender),this.metric=new Metric(this.sender),this.log=new Logger,this.setId(r),this.log.injectLogPrint((function(e){t.trace.simpleLogger(e)}))}),[{key:"setId",value:function(e){this.id=e,this.log.loggerPrefix="clientId ".concat(this.id)}},{key:"securityToken",get:function(){return this.sender.securityToken}},{key:"statsConfig",get:function(){return this.sender.statsConfig}},{key:"updateCommonInfo",value:function(e){this.commonInfo=Object.assign({},this.commonInfo,e),this.webtracking.updateCommonInfo(this.commonInfo),this.sender.logging.updateCommonInfo(this.commonInfo),e.serverDiffTime&&setDiffTime(e.serverDiffTime)}},{key:"updateSecurityToken",value:function(e){this.sender.updateSecurityToken(e)}},{key:"start",value:function(e){this.sender.start(e)}},{key:"stop",value:function(){this.sender.stop()}}]),clientIdToReportMap=new Map,defaultReport,registerReporter=function(e){var t;return defaultReport?defaultReport&&!defaultReport.id?(defaultReport.setId(e),t=defaultReport):t=new Reporter(e):t=defaultReport=new Reporter(e),clientIdToReportMap.set(e,t),t},getReporter=function(e){return defaultReport||(defaultReport=new Reporter),defaultReport},setLogLevel=function(e){Logger.setLogLevel(e)},_ErrorCodeAndMsgMap,_McsExceptionToRtcErr,_McsEventCodeToRtcErr,DeviceErrorDescription={MESSAGE_DEVICENOTFOUND:"Requested device not found",MESSAGE_DEVICENOTALLOWED:"Permission denied",MESSAGE_MACCHROMEDEVICENOTREADABLE:"Permission denied by system",MESSAGE_MACSAFARIDEVICENOTALLOWED:"The request is not allowed by the user agent or the platform in the current context, possibly because the user denied permission.",MESSAGE_MOBILEDEVICE_NOTALLOWED:"video device not allowed",MESSAGE_AUDIODEVICENOTREADABLE:"Could not start audio source",MESSAGE_VIDEODEVICENOTREADABLE:"Could not start video source",NAME_ABORTEERROR:"AbortError",NAME_INVALIDSTATEERROR:"InvalidStateError",NAME_DEVICENOTALLOWED:"NotAllowedError",NAME_DEVICENOTFOUND:"NotFoundError",NAME_DEVICENOTREADABLE:"NotReadableError",NAME_DEVICEOVERCONSTRAINED:"OverconstrainedError",NAME_INVALID_ACCESS:"InvalidAccessError",NAME_TYPEERROR:"TypeError"},GSLBErrorCode,ErrorCode;!function(e){e.CLIENT_ERROR_INVALID_AUTHORIZATION="invalid authorization",e.CLIENT_ERROR_NOT_FOUND_APP="app not found",e.CLIENT_ERROR_INVALID_APP_STATUS="invalid app status",e.CLIENT_ERROR_MISSING_CHANNEL_NAME="channel missing",e.CLIENT_ERROR_INVALID_TOKEN_TIMESTAMP="invalid token timestamp",e.CLIENT_ERROR_INVALID_APP_ID="invalid appId",e.CLIENT_ERROR_MISSING_REQUEST="request missing",e.CLIENT_ERROR_MISSING_DEVICE_ID="deviceId missing",e.CLIENT_ERROR_MISSING_UA="ua missing",e.CLIENT_ERROR_MISSING_CLIENT_IP="clientIp missing",e.CLIENT_ERROR_INVALID_USER_ID="invalid userId",e.CLIENT_ERROR_MISSING_SERVIC="service missing",e.CLIENT_ERROR_MISSING_TASK_ID="taskId missing",e.CLIENT_ERROR_MISSING_APP_ID="appId missing",e.CLIENT_ERROR_MISSING_USER_ID="userId missing",e.CLIENT_ERROR_MISSING_USER="user missing",e.CLIENT_ERROR_MISSING_CHANNEL_ID="channel missing",e.CLIENT_ERROR_MISSING_PARTICIPANT_ID="participantId missing",e.CLIENT_ERROR_INVALID_REQUEST="invalid request",e.CLIENT_ERROR_NOT_FOUND_GSLB_CHANNEL="gslb channel not found",e.SERVER_ERROR_GSLB_NOT_FOUND_CHANNEL_ID_ERROR="gslb not found channelId error",e.SERVER_ERROR_INTERNAL_ERROR="internal error",e.SERVER_ERROR_MEDIA_ENGINE_ACCESS_ERROR="media-engine access error",e.SERVER_ERROR_MEDIA_ENGINE_SCHEDULE_AND_CREATE_ERROR="media-engine scheduleAndCreate error",e.SERVER_ERROR_SECURITY_TOKEN_NOT_FOUND_ERROR="security token not found error",e.SERVER_ERROR_GSLB_ACCESS_ERROR="gslb access error",e.SERVER_ERROR_GSLB_DISPATCH_ERROR="gslb dispatch error",e.SERVER_ERROR_GSLB_MAPI_ERROR="gslb mapi error"}(GSLBErrorCode||(GSLBErrorCode={})),function(e){e[e.JoinTimeout=16908804]="JoinTimeout",e[e.JoinChannelFailed=16974338]="JoinChannelFailed",e[e.CLIENT_ERROR_INVALID_AUTHORIZATION=33620485]="CLIENT_ERROR_INVALID_AUTHORIZATION",e[e.CLIENT_ERROR_NOT_FOUND_APP=33620481]="CLIENT_ERROR_NOT_FOUND_APP",e[e.CLIENT_ERROR_INVALID_APP_STATUS=33620486]="CLIENT_ERROR_INVALID_APP_STATUS",e[e.JoinBadParam=16974081]="JoinBadParam",e[e.CLIENT_ERROR_MISSING_CHANNEL_NAME=16974081]="CLIENT_ERROR_MISSING_CHANNEL_NAME",e[e.CLIENT_ERROR_INVALID_TOKEN_TIMESTAMP=33620483]="CLIENT_ERROR_INVALID_TOKEN_TIMESTAMP",e[e.CLIENT_ERROR_INVALID_APP_ID=33620482]="CLIENT_ERROR_INVALID_APP_ID",e[e.CLIENT_ERROR_MISSING_REQUEST=16974081]="CLIENT_ERROR_MISSING_REQUEST",e[e.CLIENT_ERROR_MISSING_CLIENT_IP=16974081]="CLIENT_ERROR_MISSING_CLIENT_IP",e[e.CLIENT_ERROR_INVALID_USER_ID=33622278]="CLIENT_ERROR_INVALID_USER_ID",e[e.CLIENT_ERROR_MISSING_SERVIC=16974081]="CLIENT_ERROR_MISSING_SERVIC",e[e.CLIENT_ERROR_MISSING_TASK_ID=16974081]="CLIENT_ERROR_MISSING_TASK_ID",e[e.CLIENT_ERROR_MISSING_APP_ID=16974081]="CLIENT_ERROR_MISSING_APP_ID",e[e.CLIENT_ERROR_MISSING_USER_ID=16974081]="CLIENT_ERROR_MISSING_USER_ID",e[e.CLIENT_ERROR_MISSING_USER=16974081]="CLIENT_ERROR_MISSING_USER",e[e.CLIENT_ERROR_MISSING_CHANNEL_ID=16974081]="CLIENT_ERROR_MISSING_CHANNEL_ID",e[e.CLIENT_ERROR_MISSING_PARTICIPANT_ID=16974081]="CLIENT_ERROR_MISSING_PARTICIPANT_ID",e[e.CLIENT_ERROR_INVALID_REQUEST=16974082]="CLIENT_ERROR_INVALID_REQUEST",e[e.CLIENT_ERROR_NOT_FOUND_GSLB_CHANNEL=33620484]="CLIENT_ERROR_NOT_FOUND_GSLB_CHANNEL",e[e.ServerResponseInvalid=16974354]="ServerResponseInvalid",e[e.SERVER_ERROR_GSLB_NOT_FOUND_CHANNEL_ID_ERROR=33620496]="SERVER_ERROR_GSLB_NOT_FOUND_CHANNEL_ID_ERROR",e[e.SERVER_ERROR_INTERNAL_ERROR=33620497]="SERVER_ERROR_INTERNAL_ERROR",e[e.SERVER_ERROR_MEDIA_ENGINE_ACCESS_ERROR=33620498]="SERVER_ERROR_MEDIA_ENGINE_ACCESS_ERROR",e[e.SERVER_ERROR_MEDIA_ENGINE_SCHEDULE_AND_CREATE_ERROR=33620499]="SERVER_ERROR_MEDIA_ENGINE_SCHEDULE_AND_CREATE_ERROR",e[e.SERVER_ERROR_SECURITY_TOKEN_NOT_FOUND_ERROR=33620500]="SERVER_ERROR_SECURITY_TOKEN_NOT_FOUND_ERROR",e[e.SERVER_ERROR_GSLB_ACCESS_ERROR=33622281]="SERVER_ERROR_GSLB_ACCESS_ERROR",e[e.SERVER_ERROR_GSLB_DISPATCH_ERROR=33620501]="SERVER_ERROR_GSLB_DISPATCH_ERROR",e[e.SERVER_ERROR_GSLB_MAPI_ERROR=33620502]="SERVER_ERROR_GSLB_MAPI_ERROR",e[e.MicOpenFail=17040388]="MicOpenFail",e[e.SpeakerOpenFail=17040389]="SpeakerOpenFail",e[e.MicInterrupt=17040390]="MicInterrupt",e[e.SpeakerSetNotSupported=17040416]="SpeakerSetNotSupported",e[e.SpeakerInterrupt=17040391]="SpeakerInterrupt",e[e.MicAuthFail=17040392]="MicAuthFail",e[e.MicNotAvailable=17040393]="MicNotAvailable",e[e.SpeakerNotAvailable=17040400]="SpeakerNotAvailable",e[e.SpecifiedAudioDeviceNotFound=17040401]="SpecifiedAudioDeviceNotFound",e[e.AudioMixingUnknownError=17040896]="AudioMixingUnknownError",e[e.LoadAudioFailed=17040897]="LoadAudioFailed",e[e.AudioMixingStateInvalid=17040898]="AudioMixingStateInvalid",e[e.AudioContextNotSupported=17040899]="AudioContextNotSupported",e[e.NotArrayBuffer=17040900]="NotArrayBuffer",e[e.AudioMixingMissingParam=17040901]="AudioMixingMissingParam",e[e.AudioMixingStartFailed=17040902]="AudioMixingStartFailed",e[e.AudioMixingResumeFailed=17040903]="AudioMixingResumeFailed",e[e.AudioPlayTimeError=17040912]="AudioPlayTimeError",e[e.AutoPlayFailed=17040928]="AutoPlayFailed",e[e.CameraOpenFail=17039620]="CameraOpenFail",e[e.CameraInterrupt=17039622]="CameraInterrupt",e[e.SpecifiedCameraDeviceNotFound=17039623]="SpecifiedCameraDeviceNotFound",e[e.CameraNotAvailable=17039673]="CameraNotAvailable",e[e.CameraAuthFail=17039680]="CameraAuthFail",e[e.ScreenShareOpenFail=17039624]="ScreenShareOpenFail",e[e.VideoDisplayOpenFail=17039873]="VideoDisplayOpenFail",e[e.VideoDisplayInterrupt=17039874]="VideoDisplayInterrupt",e[e.DeviceUnknownError=17040537]="DeviceUnknownError",e[e.OverConstrainedError=17040536]="OverConstrainedError",e[e.ScreenShareUnknownError=17040640]="ScreenShareUnknownError",e[e.ScreenShareNotAllowed=17040641]="ScreenShareNotAllowed",e[e.ScreenShareEnded=17040642]="ScreenShareEnded",e[e.ScreenShareNotAuthed=17040643]="ScreenShareNotAuthed",e[e.ScreenShareInvalidAccess=17040644]="ScreenShareInvalidAccess",e[e.ScreenShareAbortError=17040645]="ScreenShareAbortError",e[e.ScreenShareStateError=17040646]="ScreenShareStateError",e[e.ScreenShareTypeError=17040647]="ScreenShareTypeError",e[e.IceConnectionConnectFail=17105409]="IceConnectionConnectFail",e[e.IceConnectionReconnectFail=17105410]="IceConnectionReconnectFail",e[e.IceConnectionAnswerFail=17105426]="IceConnectionAnswerFail",e[e.IceConnectionNoCandidate=17105427]="IceConnectionNoCandidate",e[e.IceConnectionDisconnected=17105428]="IceConnectionDisconnected",e[e.IceConnectionSetLocalDescFail=17105429]="IceConnectionSetLocalDescFail",e[e.ConnectionHeartbeatTimeout=17105411]="ConnectionHeartbeatTimeout",e[e.ConnectionConnectFail=17105665]="ConnectionConnectFail",e[e.APICallTimeOut=17105681]="APICallTimeOut",e[e.PublishNoStream=16974596]="PublishNoStream",e[e.PublishInvaild=16974597]="PublishInvaild",e[e.PublishNotJoinChannel=16843782]="PublishNotJoinChannel",e[e.PublishAudioStreamFailed=16843856]="PublishAudioStreamFailed",e[e.PublishVideoStreamFailed=16843857]="PublishVideoStreamFailed",e[e.PublishScreenShareFailed=16843859]="PublishScreenShareFailed",e[e.PublishScreenShareConfigError=16843860]="PublishScreenShareConfigError",e[e.SubscribeStreamNotExisted=16974851]="SubscribeStreamNotExisted",e[e.SubscribeInvaild=16974852]="SubscribeInvaild",e[e.SubscribeNotJoinChannel=16844112]="SubscribeNotJoinChannel",e[e.SubscribeAudioStreamFailed=16844113]="SubscribeAudioStreamFailed",e[e.SubscribeVideoStreamFailed=16844114]="SubscribeVideoStreamFailed",e[e.SubscribeScreenShareFailed=16844116]="SubscribeScreenShareFailed",e[e.LogAlreadyInit=16974085]="LogAlreadyInit",e[e.LogRootPathError=16974086]="LogRootPathError",e[e.QuotaLimitExceed=16974096]="QuotaLimitExceed",e[e.BrowserNotSupported=16974101]="BrowserNotSupported",e[e.InvaildState=16974340]="InvaildState",e[e.InvaildArgument=16974083]="InvaildArgument",e[e.SessionRemoved=33620229]="SessionRemoved",e[e.AudioBufferFull=17236225]="AudioBufferFull",e[e.VideoBufferFull=17236226]="VideoBufferFull",e[e.AudioStreamError=17301761]="AudioStreamError",e[e.AudioFileOpenFail=17301762]="AudioFileOpenFail",e[e.AudioFormatNotSupported=17301763]="AudioFormatNotSupported",e[e.UpdateRoleChannel=16908801]="UpdateRoleChannel",e[e.Inner=-1]="Inner"}(ErrorCode||(ErrorCode={}));var ErrorCodeAndMsgMap=(_ErrorCodeAndMsgMap={},_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_ErrorCodeAndMsgMap,ErrorCode.SERVER_ERROR_GSLB_ACCESS_ERROR,"GSLB access error"),ErrorCode.CLIENT_ERROR_NOT_FOUND_APP,"AppId is not exist"),ErrorCode.CLIENT_ERROR_INVALID_APP_ID,"AppId is invalid"),ErrorCode.CLIENT_ERROR_NOT_FOUND_GSLB_CHANNEL,"channel is not exist"),ErrorCode.CLIENT_ERROR_INVALID_TOKEN_TIMESTAMP,"channel is invalid"),ErrorCode.CLIENT_ERROR_INVALID_AUTHORIZATION,"token is invalid"),ErrorCode.JoinTimeout,"join timeout"),ErrorCode.JoinBadParam,"join with invalid parameter"),ErrorCode.JoinChannelFailed,"join channel failed"),ErrorCode.CLIENT_ERROR_INVALID_APP_STATUS,"invalid app status"),_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_ErrorCodeAndMsgMap,ErrorCode.CLIENT_ERROR_INVALID_USER_ID,"invalid userId"),ErrorCode.CLIENT_ERROR_INVALID_REQUEST,"invalid request"),ErrorCode.SERVER_ERROR_GSLB_NOT_FOUND_CHANNEL_ID_ERROR,"gslb not found channelId error"),ErrorCode.SERVER_ERROR_INTERNAL_ERROR,"internal error"),ErrorCode.SERVER_ERROR_MEDIA_ENGINE_ACCESS_ERROR,"media-engine access error"),ErrorCode.SERVER_ERROR_MEDIA_ENGINE_SCHEDULE_AND_CREATE_ERROR,"media-engine scheduleAndCreate error"),ErrorCode.SERVER_ERROR_SECURITY_TOKEN_NOT_FOUND_ERROR,"security token not found error"),ErrorCode.SERVER_ERROR_GSLB_DISPATCH_ERROR,"gslb dispatch error"),ErrorCode.SERVER_ERROR_GSLB_MAPI_ERROR,"gslb mapi error"),ErrorCode.ScreenShareUnknownError,"unknown screenShare error"),_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_ErrorCodeAndMsgMap,ErrorCode.ScreenShareNotAllowed,"screenShare not allowned"),ErrorCode.ScreenShareEnded,"screenShare ended"),ErrorCode.ScreenShareNotAuthed,"screenShare no permission"),ErrorCode.ScreenShareInvalidAccess,"screenShare invalid access"),ErrorCode.ScreenShareAbortError,"screenShare abort access"),ErrorCode.ScreenShareStateError,"screenShare state error"),ErrorCode.ScreenShareTypeError,"screenShare type error"),ErrorCode.AutoPlayFailed,"auto play failed"),ErrorCode.OverConstrainedError,"Overconstrained error"),ErrorCode.DeviceUnknownError,"unknown device error"),_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_ErrorCodeAndMsgMap,ErrorCode.MicOpenFail,"failed to open audio record device or audio device occupied"),ErrorCode.MicInterrupt,"audio recording error or audio device occupied"),ErrorCode.SpeakerInterrupt,"audio playing error or audio device occupied"),ErrorCode.SpeakerOpenFail,"failed to open playback device"),ErrorCode.SpeakerSetNotSupported,"not support set output device"),ErrorCode.MicAuthFail,"no audio recording permission or audio device occupied"),ErrorCode.MicNotAvailable,"no audio record device found"),ErrorCode.SpeakerNotAvailable,"no audio play device found"),ErrorCode.SpecifiedAudioDeviceNotFound,"specified audio device not found"),ErrorCode.CameraOpenFail,"failed to open camera due to no permission or camera device occupied"),_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_ErrorCodeAndMsgMap,ErrorCode.CameraInterrupt,"camera capturing happens error"),ErrorCode.SpecifiedCameraDeviceNotFound,"specified camera device not found"),ErrorCode.VideoDisplayOpenFail,"failed to open render device"),ErrorCode.VideoDisplayInterrupt,"render happens error"),ErrorCode.ScreenShareOpenFail,"failed to start shareScreen"),ErrorCode.CameraNotAvailable,"no camera device found"),ErrorCode.CameraAuthFail,"no camera permission"),ErrorCode.IceConnectionConnectFail,"ICE connection failed"),ErrorCode.IceConnectionAnswerFail,"failed to answer ICE connection"),ErrorCode.IceConnectionDisconnected,"ICE connection disconnected"),_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_ErrorCodeAndMsgMap,ErrorCode.IceConnectionNoCandidate,"ICE connection has no candidates"),ErrorCode.IceConnectionSetLocalDescFail,"failed to set local SDP"),ErrorCode.ConnectionHeartbeatTimeout,"signal heartbeat timeout"),ErrorCode.ConnectionConnectFail,"signal connection failed"),ErrorCode.APICallTimeOut,"api call is timeout"),ErrorCode.IceConnectionReconnectFail,"failed to reconnect ICE connection"),ErrorCode.PublishVideoStreamFailed,"failed to publish video"),ErrorCode.PublishNoStream,"publish stream is not exist\t"),ErrorCode.PublishInvaild,"already unpublish or not publish for now"),ErrorCode.PublishNotJoinChannel,"can not publish before join channel"),_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_ErrorCodeAndMsgMap,ErrorCode.PublishAudioStreamFailed,"failed to publish audio"),ErrorCode.PublishScreenShareFailed,"failed to publish ScreenShare"),ErrorCode.PublishScreenShareConfigError,"failed to publish ScreenShare due to config error"),ErrorCode.SubscribeStreamNotExisted,"subscribe stream is not exist"),ErrorCode.SubscribeInvaild,"already unsubscribe or not subscribe for now"),ErrorCode.SubscribeNotJoinChannel,"can not subscribe before join channel"),ErrorCode.SubscribeAudioStreamFailed,"failed to subscribe audio"),ErrorCode.SubscribeScreenShareFailed,"failed to subscribe ScreenShare"),ErrorCode.SubscribeVideoStreamFailed,"failed to subscribe video"),ErrorCode.AudioMixingUnknownError,"audio mixing unknown error"),_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_ErrorCodeAndMsgMap,ErrorCode.LoadAudioFailed,"load audio source failed"),ErrorCode.AudioMixingStateInvalid,"invalid audio mixing state"),ErrorCode.AudioContextNotSupported,"audio context is not supported"),ErrorCode.NotArrayBuffer,"source type is not array buffer"),ErrorCode.AudioMixingMissingParam,"audio mixing is missing param"),ErrorCode.AudioMixingStartFailed,"audio mixing start failed"),ErrorCode.AudioMixingResumeFailed,"audio mixing resume failed"),ErrorCode.AudioPlayTimeError,"time out of range"),ErrorCode.QuotaLimitExceed,"task exceed limit"),ErrorCode.InvaildState,"the operation is rejected in current state"),_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_ErrorCodeAndMsgMap,ErrorCode.InvaildArgument,"invalid argument"),ErrorCode.AudioBufferFull,"external audio input buffer is full"),ErrorCode.VideoBufferFull,"external video input buffer is full"),ErrorCode.AudioStreamError,"auido stream has error"),ErrorCode.AudioFileOpenFail,"failed to open audio file"),ErrorCode.AudioFormatNotSupported,"no support the audio format"),ErrorCode.UpdateRoleChannel,"failed to update role"),ErrorCode.BrowserNotSupported,"failed to update role"),ErrorCode.Inner,"sdk internel error occured"),ErrorCode.LogAlreadyInit,"log already init"),_defineProperty$1(_defineProperty$1(_defineProperty$1(_ErrorCodeAndMsgMap,ErrorCode.LogRootPathError,"log root path error"),ErrorCode.SessionRemoved,"session has been removed"),ErrorCode.ServerResponseInvalid,"Server response invalid")),McsCode,ExceptionType;!function(e){e[e.kMcsMicrophoneInitFailed=11e3]="kMcsMicrophoneInitFailed",e[e.kMcsMicrophoneStartCaptureFailed=11002]="kMcsMicrophoneStartCaptureFailed",e[e.kMcsMicrophoneStopCaptureFailed=11003]="kMcsMicrophoneStopCaptureFailed",e[e.kMcsMicrophoneInitSuccess=11004]="kMcsMicrophoneInitSuccess",e[e.kMcsMicrophoneStartCaptureSuccess=11005]="kMcsMicrophoneStartCaptureSuccess",e[e.kMcsMicrophoneStartCaptureAccessDenied=11006]="kMcsMicrophoneStartCaptureAccessDenied",e[e.kMcsMicrophoneRecordingDevicesSize=11007]="kMcsMicrophoneRecordingDevicesSize",e[e.kMcsMicrophoneStartRecordingSuccess=11008]="kMcsMicrophoneStartRecordingSuccess",e[e.kMcsMicrophoneIosAuSrChInitFailed=11009]="kMcsMicrophoneIosAuSrChInitFailed",e[e.kMcsMicrophoneIosAuSrChStartFailed=11010]="kMcsMicrophoneIosAuSrChStartFailed",e[e.kMcsSpeakerInitFailed=11100]="kMcsSpeakerInitFailed",e[e.kMcsSpeakerStartPlayoutFailed=11102]="kMcsSpeakerStartPlayoutFailed",e[e.kMcsSpeakerStopPlayoutFailed=11103]="kMcsSpeakerStopPlayoutFailed",e[e.kMcsSpeakerInitSuccess=11104]="kMcsSpeakerInitSuccess",e[e.kMcsSpeakerStartPlayoutSuccess=11105]="kMcsSpeakerStartPlayoutSuccess",e[e.kMcsSpeakerPanningShouldChange=11106]="kMcsSpeakerPanningShouldChange",e[e.kMcsSpeakerFirstPlayoutAuidoData=11107]="kMcsSpeakerFirstPlayoutAuidoData",e[e.kMcsAudioInterruptStart=11108]="kMcsAudioInterruptStart",e[e.kMcsAudioInterruptStop=11109]="kMcsAudioInterruptStop",e[e.kMcsAudioEnergyMonitor=11200]="kMcsAudioEnergyMonitor",e[e.kMcsAudioProcessingMonitor=11201]="kMcsAudioProcessingMonitor",e[e.kMcsAudioDeviceConfigChange=11202]="kMcsAudioDeviceConfigChange",e[e.kMcsAudioRecordLevelException=11203]="kMcsAudioRecordLevelException",e[e.kMcsSystemSampleRateChange=11204]="kMcsSystemSampleRateChange",e[e.kMcsAudioRecordEnergyException=11205]="kMcsAudioRecordEnergyException",e[e.kMcsAudioSessionConfigFailed=11300]="kMcsAudioSessionConfigFailed",e[e.kMcsWebrtcThreadSocketWaitFailure=11400]="kMcsWebrtcThreadSocketWaitFailure",e[e.kMcsLoopbackStartFailed=11500]="kMcsLoopbackStartFailed",e[e.kMcsVideoOpenDeviceFailed=12e3]="kMcsVideoOpenDeviceFailed",e[e.kMcsVideoCloseDeviceFailed=12001]="kMcsVideoCloseDeviceFailed",e[e.kMcsVideoStartCaptureFailed=12002]="kMcsVideoStartCaptureFailed",e[e.kMcsVideoStopCaptureFailed=12003]="kMcsVideoStopCaptureFailed",e[e.kMcsVideoOpenDeviceSuccess=12004]="kMcsVideoOpenDeviceSuccess",e[e.kMcsVideoStartCaptureSuccess=12005]="kMcsVideoStartCaptureSuccess",e[e.kMcsVideoCameraFreezed=12006]="kMcsVideoCameraFreezed",e[e.kMcsSwitchCameraSuccess=12007]="kMcsSwitchCameraSuccess",e[e.kMcsSwitchCameraFail=12008]="kMcsSwitchCameraFail",e[e.kMcsVideoCameraOccupied=12009]="kMcsVideoCameraOccupied",e[e.kMcsVideoCameraNoFrame=12010]="kMcsVideoCameraNoFrame",e[e.kMcsVideoStopCaptureSuccess=12011]="kMcsVideoStopCaptureSuccess",e[e.kMcsVideoStartCaptureAsyncFailed=12102]="kMcsVideoStartCaptureAsyncFailed",e[e.kMcsVideoCameraOccupiedAsync=12109]="kMcsVideoCameraOccupiedAsync",e[e.kMcsVideoScreenCaptureFallback=12201]="kMcsVideoScreenCaptureFallback",e[e.kMcsVideoScreenStartCaptureSuccess=12205]="kMcsVideoScreenStartCaptureSuccess",e[e.kMcsVideoScreenStopCaptureSuccess=12211]="kMcsVideoScreenStopCaptureSuccess",e[e.kMcsIceDisconnected=14e3]="kMcsIceDisconnected",e[e.kMcsIceFailed=14001]="kMcsIceFailed",e[e.kMcsIceNetworkInterfaceDetected=14002]="kMcsIceNetworkInterfaceDetected",e[e.kMcsIceRelayFailed=14003]="kMcsIceRelayFailed",e[e.kMcsIceConnectionSelected=14004]="kMcsIceConnectionSelected",e[e.kMcsIceConnectionReceivingStatus=14005]="kMcsIceConnectionReceivingStatus",e[e.kMcsIceConnectionWriteStatus=14006]="kMcsIceConnectionWriteStatus",e[e.kMcsIceConnectionStats=14007]="kMcsIceConnectionStats",e[e.kMcsIceAllNetworkInterfaceBindFailed=14008]="kMcsIceAllNetworkInterfaceBindFailed",e[e.kMcsIceDtlsSuccess=14009]="kMcsIceDtlsSuccess",e[e.kMcsIceDtlsError=14010]="kMcsIceDtlsError",e[e.kMcsIceConnectionCreate=14011]="kMcsIceConnectionCreate",e[e.kMcsIceNetworkInterfaceFailed=14012]="kMcsIceNetworkInterfaceFailed",e[e.kMcsIceAllocationTimeout=14013]="kMcsIceAllocationTimeout",e[e.kMcsIceTurnPortStats=14014]="kMcsIceTurnPortStats",e[e.kMcsIceFailOverStart=14016]="kMcsIceFailOverStart",e[e.kMcsIceFailOverFailed=14017]="kMcsIceFailOverFailed",e[e.kMcsIceFailOverSuccess=14018]="kMcsIceFailOverSuccess",e[e.kMcsIceFailOverEventStatus=14019]="kMcsIceFailOverEventStatus",e[e.kMcsIceEventStatus=14100]="kMcsIceEventStatus",e[e.kMcsNetEqRecvPacketLossy=18e3]="kMcsNetEqRecvPacketLossy",e[e.kMcsApmHowlingDetected=18001]="kMcsApmHowlingDetected",e[e.kMcsAudioRecvStreamFirstPacket=18002]="kMcsAudioRecvStreamFirstPacket",e[e.kMcsNetEqPacketBufferFlushed=18003]="kMcsNetEqPacketBufferFlushed",e[e.kMcsAudioRecvMonitor=18004]="kMcsAudioRecvMonitor",e[e.kMcsAudioSendMonitor=18005]="kMcsAudioSendMonitor",e[e.kMcsAudioFrozen=18006]="kMcsAudioFrozen",e[e.kMcsAudioSendNack=18007]="kMcsAudioSendNack",e[e.kMcsNeteqLossRate=18008]="kMcsNeteqLossRate",e[e.kMcsAudioSendNackReduce=18009]="kMcsAudioSendNackReduce",e[e.kMcsNeteqLossRateReduce=18010]="kMcsNeteqLossRateReduce",e[e.kMcsAudioSendStreamFirstPacket=18011]="kMcsAudioSendStreamFirstPacket",e[e.kMcsNeteqRedDecodeError=18012]="kMcsNeteqRedDecodeError",e[e.kMcsApmVoicePresence=18013]="kMcsApmVoicePresence",e[e.kMcsAudioUnitMonitor=18020]="kMcsAudioUnitMonitor",e[e.kMcsApmMicLevelLow=18021]="kMcsApmMicLevelLow",e[e.kMcsTransportLossRate=18022]="kMcsTransportLossRate",e[e.kMcsTransportLossRateReduce=18023]="kMcsTransportLossRateReduce",e[e.kMcsBweUplinkLossrateRtt=18024]="kMcsBweUplinkLossrateRtt",e[e.kMcsBweUplinkLossrateRttReduce=18025]="kMcsBweUplinkLossrateRttReduce",e[e.kMcsTurnPingLossrateRtt=18026]="kMcsTurnPingLossrateRtt",e[e.kMcsTurnPingLossrateRttReduce=18027]="kMcsTurnPingLossrateRttReduce",e[e.kMcsRemoteAudioVolumeInfo=18101]="kMcsRemoteAudioVolumeInfo",e[e.kMcsRaceBeautyMonitor=19e3]="kMcsRaceBeautyMonitor",e[e.kMcsVideoRecvMonitor=19001]="kMcsVideoRecvMonitor",e[e.kMcsVideoSendMonitor=19002]="kMcsVideoSendMonitor",e[e.kMcsVideoEncodeError=19003]="kMcsVideoEncodeError",e[e.kMcsVideoDecodeError=19004]="kMcsVideoDecodeError",e[e.kMcsVideoRecvStreamFirstPacket=19005]="kMcsVideoRecvStreamFirstPacket",e[e.kMcsVideoRecvStreamFirstFrame=19006]="kMcsVideoRecvStreamFirstFrame",e[e.kMcsVideoSendNack=19007]="kMcsVideoSendNack",e[e.kMcsVideoSendNackReduce=19008]="kMcsVideoSendNackReduce",e[e.kMcsVideoDecodeFallbackSW=19009]="kMcsVideoDecodeFallbackSW",e[e.kMcsVideoDecodeHWOveruse=19010]="kMcsVideoDecodeHWOveruse",e[e.kMcsVideoCaptureReport=19011]="kMcsVideoCaptureReport",e[e.kMcsVideoRenderReport=19012]="kMcsVideoRenderReport",e[e.kMcsVideoScreenReport=19013]="kMcsVideoScreenReport",e[e.kMcsVideoSimulcastEncode=19014]="kMcsVideoSimulcastEncode",e[e.kMcsVideoSccPPTScence=19015]="kMcsVideoSccPPTScence",e[e.kMcsVideoSccVideoScence=19016]="kMcsVideoSccVideoScence",e[e.kMcsVideoEncodeFallbackSW=19017]="kMcsVideoEncodeFallbackSW",e[e.kMcsVideoDecodeError2=19018]="kMcsVideoDecodeError2",e[e.kMcsVideoEncodeError2=19019]="kMcsVideoEncodeError2",e[e.kMcsVideoSendStreamFirstFrame=19020]="kMcsVideoSendStreamFirstFrame",e[e.kMcsDtmasMonitor=19021]="kMcsDtmasMonitor",e[e.kMcsVideoEncoderCreate=19022]="kMcsVideoEncoderCreate",e[e.kMcsVideoHWEncoderCreateSuccess=19023]="kMcsVideoHWEncoderCreateSuccess",e[e.kMcsVideoSWEncoderCreateSuccess=19024]="kMcsVideoSWEncoderCreateSuccess",e[e.kMcsVideoEncodeResolutionChange=19025]="kMcsVideoEncodeResolutionChange",e[e.kMcsBwePoorNetwork=2e4]="kMcsBwePoorNetwork",e[e.kMcsBweMonitor=20001]="kMcsBweMonitor",e[e.kMcsABTestStats=20101]="kMcsABTestStats",e[e.kMcsConsistencyProtectException=20102]="kMcsConsistencyProtectException",e[e.kMcsSyncConfInfoStart=20201]="kMcsSyncConfInfoStart",e[e.kMcsSyncConfInfoFinish=20202]="kMcsSyncConfInfoFinish",e[e.kMcsSocketIoDisconnected=21e3]="kMcsSocketIoDisconnected",e[e.kMcsReloginFailed=21001]="kMcsReloginFailed",e[e.kMcsSignalDisconnected=21100]="kMcsSignalDisconnected",e[e.kMcsSignalOnDrop=21101]="kMcsSignalOnDrop",e[e.kMcsServerFailoverQuit=21102]="kMcsServerFailoverQuit",e[e.kMcsRemoteProcessDisconnected=21105]="kMcsRemoteProcessDisconnected",e[e.kMcsServerReofferFailed=21107]="kMcsServerReofferFailed",e[e.kMcsWarningPoorNetwork=22e3]="kMcsWarningPoorNetwork",e[e.kMcsErrorBadNetwork=22001]="kMcsErrorBadNetwork",e[e.kMcsWarningCongestionNetwork=22002]="kMcsWarningCongestionNetwork",e[e.kMcsGoodNetwork=22003]="kMcsGoodNetwork",e[e.kMcsPoorNetwork=22004]="kMcsPoorNetwork",e[e.kMcsBadNetwork=22005]="kMcsBadNetwork",e[e.kMcsNetworkSelected=22006]="kMcsNetworkSelected",e[e.kMcsWarningConnectionPoorNetwork=22007]="kMcsWarningConnectionPoorNetwork",e[e.kMcsWarningMediaPoorNetwork=22008]="kMcsWarningMediaPoorNetwork",e[e.kMcsPoorRemoteNetwork=22009]="kMcsPoorRemoteNetwork",e[e.kMcsGoodRemoteNetwork=22010]="kMcsGoodRemoteNetwork",e[e.KMcsRemoteNetworkCutoff=22011]="KMcsRemoteNetworkCutoff",e[e.kMcsRemoteNetworkStats=22012]="kMcsRemoteNetworkStats",e[e.KMcsUserNetworkStats=22013]="KMcsUserNetworkStats",e[e.kMcsHighLossrate=22014]="kMcsHighLossrate",e[e.kMcsLowLossrate=22015]="kMcsLowLossrate",e[e.kMcsDownlinkNetworkStats=22016]="kMcsDownlinkNetworkStats",e[e.kMcsPauseLowLevelUpTcpRequest=22017]="kMcsPauseLowLevelUpTcpRequest",e[e.kMcsResumeLowLevelUpTcpRequest=22018]="kMcsResumeLowLevelUpTcpRequest",e[e.kMcsPauseLowLevelDownTcpRequest=22019]="kMcsPauseLowLevelDownTcpRequest",e[e.kMcsResumeLowLevelDownTcpRequest=22020]="kMcsResumeLowLevelDownTcpRequest",e[e.kMcsNetworkUpDownQuality=22021]="kMcsNetworkUpDownQuality",e[e.kMcsNetworkUplinkQualityReport=22022]="kMcsNetworkUplinkQualityReport",e[e.kMcsWarningPoorPeerNetwork=22023]="kMcsWarningPoorPeerNetwork",e[e.kMcsWarningPoorLocalNetwork=22024]="kMcsWarningPoorLocalNetwork",e[e.kMcsCallmePoorNetowrk=22025]="kMcsCallmePoorNetowrk",e[e.kMcsCallmeGoodNetowrk=22026]="kMcsCallmeGoodNetowrk",e[e.kMcsP2pDtlsHandShakeError=24e3]="kMcsP2pDtlsHandShakeError",e[e.kMcsQualityMonitorStatistics=7e5]="kMcsQualityMonitorStatistics",e[e.kMcsMetricLogItemUpload=700001]="kMcsMetricLogItemUpload",e[e.kMcsSwitchToEndInfo=8e4]="kMcsSwitchToEndInfo",e[e.kMcsSFUAddSSRC=9e4]="kMcsSFUAddSSRC",e[e.kMcsSFURemoveSSRC=90001]="kMcsSFURemoveSSRC"}(McsCode||(McsCode={})),function(e){e[e.kUnknown=1e3]="kUnknown",e[e.kObjectNotExist=1001]="kObjectNotExist",e[e.kSignalConnectTimeout=1002]="kSignalConnectTimeout",e[e.kSignalJoinTimeout=1003]="kSignalJoinTimeout",e[e.kLocalUnknown=1100]="kLocalUnknown",e[e.kLocalDeviceNotFound=1102]="kLocalDeviceNotFound",e[e.kLocalInvalidOption=1104]="kLocalInvalidOption",e[e.kLocalNotSupported=1105]="kLocalNotSupported",e[e.kP2PUnknown=2001]="kP2PUnknown",e[e.kP2PConnectionAuthFailed=2121]="kP2PConnectionAuthFailed",e[e.kP2PMessageTargetUnreachable=2201]="kP2PMessageTargetUnreachable",e[e.kP2PClientUnsupportedMethod=2401]="kP2PClientUnsupportedMethod",e[e.kP2PClientInvalidArgument=2402]="kP2PClientInvalidArgument",e[e.kP2PClientInvalidState=2403]="kP2PClientInvalidState",e[e.kP2PClientRemoteNotAllowed=2404]="kP2PClientRemoteNotAllowed",e[e.kP2PClientRemoteNotExisted=2405]="kP2PClientRemoteNotExisted",e[e.kConferenceUnknown=3001]="kConferenceUnknown",e[e.kConferenceInvalidUser=3002]="kConferenceInvalidUser",e[e.kConferenceInvalidParam=3003]="kConferenceInvalidParam",e[e.kConferenceNotSupported=3004]="kConferenceNotSupported",e[e.kConferenceInvalidToken=3005]="kConferenceInvalidToken",e[e.kConferenceInvalidSession=3006]="kConferenceInvalidSession",e[e.kConferenceNotFoundMediaStream=3007]="kConferenceNotFoundMediaStream",e[e.kConferenceTakeSnapShotFailed=3008]="kConferenceTakeSnapShotFailed",e[e.kConferenceConnectFailed=3009]="kConferenceConnectFailed",e[e.kConferenceAlreadyJoined=3010]="kConferenceAlreadyJoined",e[e.kConferenceJoinFailure=3011]="kConferenceJoinFailure",e[e.kConferenceNotHaveToLeave=3012]="kConferenceNotHaveToLeave",e[e.kConferenceIsEnd=3013]="kConferenceIsEnd",e[e.kConferenceGetParticipantAndStreamsError=3014]="kConferenceGetParticipantAndStreamsError",e[e.kConferenceSubscribeOptionMismatch=3015]="kConferenceSubscribeOptionMismatch",e[e.kInvokeTimeout=4001]="kInvokeTimeout",e[e.kStreamAlreadyPublish=5001]="kStreamAlreadyPublish",e[e.kStreamAlreadyWork=5002]="kStreamAlreadyWork",e[e.kStreamNotInConference=5003]="kStreamNotInConference",e[e.kStreamInvalidParam=5004]="kStreamInvalidParam",e[e.kStreamNotReceiveAnswer=5005]="kStreamNotReceiveAnswer",e[e.kStreamNotReceiveReady=5006]="kStreamNotReceiveReady",e[e.kStreamNotPublish=5007]="kStreamNotPublish",e[e.kStreamPublishCanceled=5008]="kStreamPublishCanceled",e[e.kStreamAlreadySubscribe=6001]="kStreamAlreadySubscribe",e[e.kStreamNotSubscribe=6002]="kStreamNotSubscribe",e[e.kStreamSubscribeCanceled=6003]="kStreamSubscribeCanceled",e[e.kStreamError=7001]="kStreamError",e[e.kCreatePeerConnectionFailed=8001]="kCreatePeerConnectionFailed"}(ExceptionType||(ExceptionType={}));var converToRtcErrorFromGslbCode=function(e,t){return new DingRTCError(ErrorCode[e],ErrorCodeAndMsgMap[e]||GSLBErrorCode[e]||t)};_McsExceptionToRtcErr={},_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_McsExceptionToRtcErr,ExceptionType.kConferenceConnectFailed,ErrorCode.IceConnectionConnectFail),ExceptionType.kConferenceInvalidParam,ErrorCode.InvaildArgument),ExceptionType.kStreamInvalidParam,ErrorCode.InvaildArgument),ExceptionType.kSignalConnectTimeout,ErrorCode.JoinTimeout),ExceptionType.kConferenceJoinFailure,ErrorCode.JoinChannelFailed),ExceptionType.kConferenceAlreadyJoined,ErrorCode.InvaildState),ExceptionType.kConferenceIsEnd,ErrorCode.InvaildState),ExceptionType.kConferenceSubscribeOptionMismatch,ErrorCode.SubscribeInvaild),ExceptionType.kStreamNotInConference,ErrorCode.PublishNotJoinChannel),ExceptionType.kStreamAlreadyPublish,ErrorCode.PublishInvaild),_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_McsExceptionToRtcErr,ExceptionType.kStreamNotPublish,ErrorCode.PublishNoStream),ExceptionType.kStreamAlreadySubscribe,ErrorCode.SubscribeInvaild),ExceptionType.kStreamNotSubscribe,ErrorCode.SubscribeStreamNotExisted),ExceptionType.kConferenceGetParticipantAndStreamsError,ErrorCode.ServerResponseInvalid),ExceptionType.kLocalDeviceNotFound,ErrorCode.SpecifiedCameraDeviceNotFound),ExceptionType.kLocalNotSupported,ErrorCode.CameraOpenFail),ExceptionType.kConferenceNotSupported,ErrorCode.ConnectionHeartbeatTimeout),ExceptionType.kConferenceInvalidToken,ErrorCode.JoinChannelFailed),_McsEventCodeToRtcErr={},_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_McsEventCodeToRtcErr,McsCode.kMcsMicrophoneInitFailed,ErrorCode.MicOpenFail),McsCode.kMcsMicrophoneIosAuSrChInitFailed,ErrorCode.MicOpenFail),McsCode.kMcsMicrophoneStartCaptureFailed,ErrorCode.MicOpenFail),McsCode.kMcsMicrophoneIosAuSrChStartFailed,ErrorCode.MicOpenFail),McsCode.kMcsMicrophoneStartCaptureAccessDenied,ErrorCode.MicAuthFail),McsCode.kMcsMicrophoneStopCaptureFailed,ErrorCode.MicInterrupt),McsCode.kMcsSpeakerInitFailed,ErrorCode.SpeakerOpenFail),McsCode.kMcsSpeakerStartPlayoutFailed,ErrorCode.SpeakerOpenFail),McsCode.kMcsSpeakerStopPlayoutFailed,ErrorCode.SpeakerInterrupt),McsCode.kMcsVideoOpenDeviceFailed,ErrorCode.CameraOpenFail),_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_McsEventCodeToRtcErr,McsCode.kMcsVideoStartCaptureFailed,ErrorCode.CameraOpenFail),McsCode.kMcsVideoStartCaptureAsyncFailed,ErrorCode.CameraOpenFail),McsCode.kMcsVideoCameraOccupiedAsync,ErrorCode.CameraOpenFail),McsCode.kMcsVideoCameraOccupied,ErrorCode.CameraOpenFail),McsCode.kMcsSwitchCameraFail,ErrorCode.CameraOpenFail),McsCode.kMcsVideoCloseDeviceFailed,ErrorCode.CameraInterrupt),McsCode.kMcsVideoStopCaptureFailed,ErrorCode.CameraInterrupt),McsCode.kMcsVideoCameraNoFrame,ErrorCode.CameraInterrupt),McsCode.kMcsVideoDecodeError,ErrorCode.VideoDisplayInterrupt),McsCode.kMcsVideoDecodeError2,ErrorCode.VideoDisplayInterrupt),_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_McsEventCodeToRtcErr,McsCode.kMcsVideoScreenCaptureFallback,ErrorCode.ScreenShareOpenFail),McsCode.kMcsIceFailed,ErrorCode.IceConnectionReconnectFail),McsCode.kMcsIceRelayFailed,ErrorCode.IceConnectionReconnectFail),McsCode.kMcsIceAllNetworkInterfaceBindFailed,ErrorCode.IceConnectionReconnectFail),McsCode.kMcsIceDtlsError,ErrorCode.IceConnectionReconnectFail),McsCode.kMcsIceNetworkInterfaceFailed,ErrorCode.IceConnectionReconnectFail),McsCode.kMcsIceAllocationTimeout,ErrorCode.ConnectionHeartbeatTimeout),McsCode.kMcsSocketIoDisconnected,ErrorCode.ConnectionConnectFail),McsCode.kMcsReloginFailed,ErrorCode.ConnectionConnectFail),McsCode.kMcsSignalDisconnected,ErrorCode.ConnectionConnectFail);var NAME_TYPEERROR=DeviceErrorDescription.NAME_TYPEERROR,NAME_ABORTEERROR=DeviceErrorDescription.NAME_ABORTEERROR,NAME_INVALID_ACCESS=DeviceErrorDescription.NAME_INVALID_ACCESS,NAME_DEVICENOTFOUND=DeviceErrorDescription.NAME_DEVICENOTFOUND,NAME_DEVICENOTALLOWED=DeviceErrorDescription.NAME_DEVICENOTALLOWED,NAME_INVALIDSTATEERROR=DeviceErrorDescription.NAME_INVALIDSTATEERROR,MESSAGE_DEVICENOTFOUND=DeviceErrorDescription.MESSAGE_DEVICENOTFOUND,NAME_DEVICENOTREADABLE=DeviceErrorDescription.NAME_DEVICENOTREADABLE,MESSAGE_DEVICENOTALLOWED=DeviceErrorDescription.MESSAGE_DEVICENOTALLOWED,NAME_DEVICEOVERCONSTRAINED=DeviceErrorDescription.NAME_DEVICEOVERCONSTRAINED,MESSAGE_VIDEODEVICENOTREADABLE=DeviceErrorDescription.MESSAGE_VIDEODEVICENOTREADABLE,MESSAGE_AUDIODEVICENOTREADABLE=DeviceErrorDescription.MESSAGE_AUDIODEVICENOTREADABLE,MESSAGE_MOBILEDEVICE_NOTALLOWED=DeviceErrorDescription.MESSAGE_MOBILEDEVICE_NOTALLOWED,MESSAGE_MACSAFARIDEVICENOTALLOWED=DeviceErrorDescription.MESSAGE_MACSAFARIDEVICENOTALLOWED,MESSAGE_MACCHROMEDEVICENOTREADABLE=DeviceErrorDescription.MESSAGE_MACCHROMEDEVICENOTREADABLE,parseAudioDeviceError=function(e){if(e){var t=e.message,r=e.name;if(t===MESSAGE_DEVICENOTFOUND||r===NAME_DEVICENOTFOUND)return new DingRTCError(ErrorCode.MicNotAvailable);if([MESSAGE_DEVICENOTALLOWED,MESSAGE_MACSAFARIDEVICENOTALLOWED].includes(t))return new DingRTCError(ErrorCode.MicAuthFail);if([MESSAGE_MACCHROMEDEVICENOTREADABLE,MESSAGE_AUDIODEVICENOTREADABLE].includes(t)||r===NAME_DEVICENOTREADABLE)return new DingRTCError(ErrorCode.MicOpenFail);if(e instanceof TypeError)return new DingRTCError(ErrorCode.InvaildArgument,t)}return new DingRTCError(ErrorCode.DeviceUnknownError,e.message)},parseVideoDeviceError=function(e){if(e){var t=e.message,r=e.name;if(t===MESSAGE_DEVICENOTFOUND||r===NAME_DEVICENOTFOUND)return new DingRTCError(ErrorCode.CameraNotAvailable);if(t==MESSAGE_DEVICENOTALLOWED||t==MESSAGE_MOBILEDEVICE_NOTALLOWED||t==MESSAGE_MACSAFARIDEVICENOTALLOWED)return new DingRTCError(ErrorCode.CameraAuthFail);if(t==MESSAGE_MACCHROMEDEVICENOTREADABLE||t==MESSAGE_VIDEODEVICENOTREADABLE||r==NAME_DEVICENOTREADABLE)return new DingRTCError(ErrorCode.CameraOpenFail);if(r==NAME_DEVICEOVERCONSTRAINED)return new DingRTCError(ErrorCode.OverConstrainedError);if(e instanceof TypeError)return new DingRTCError(ErrorCode.InvaildArgument,t)}return new DingRTCError(ErrorCode.DeviceUnknownError,e.message)},parseScreenShareError=function(e){if(e){var t=e.name,r=e.message;if("ended"==e.type)return new DingRTCError(ErrorCode.ScreenShareEnded);if(NAME_DEVICENOTALLOWED===t)return new DingRTCError(r==MESSAGE_DEVICENOTALLOWED?ErrorCode.ScreenShareNotAllowed:ErrorCode.ScreenShareNotAuthed,r);if(NAME_INVALID_ACCESS===t)return new DingRTCError(ErrorCode.ScreenShareInvalidAccess,r);if(NAME_ABORTEERROR===t)return new DingRTCError(ErrorCode.ScreenShareAbortError,r);if(NAME_INVALIDSTATEERROR===t)return new DingRTCError(ErrorCode.ScreenShareStateError,r);if(NAME_TYPEERROR===t)return new DingRTCError(ErrorCode.ScreenShareTypeError,r);if(e instanceof TypeError)return new DingRTCError(ErrorCode.InvaildArgument,r)}return new DingRTCError(ErrorCode.ScreenShareUnknownError,"name: ".concat(e.name," message: ").concat(e.message))};function _callSuper$m(e,t,r){return t=_getPrototypeOf(t),_possibleConstructorReturn(e,_isNativeReflectConstruct$m()?Reflect.construct(t,r,_getPrototypeOf(e).constructor):t.apply(e,r))}function _isNativeReflectConstruct$m(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(_isNativeReflectConstruct$m=function(){return!!e})()}var DingRTCError=function(e){function t(e,r){var n;return _classCallCheck(this,t),n=_callSuper$m(this,t,[r=r||ErrorCodeAndMsgMap[e]]),Object.defineProperty(n,"code",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(n,"reason",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),n.code=e,n.reason=r,getReporter().trace.exception(n),n}return _inherits(t,_wrapNativeSuper(Error)),_createClass(t)}(),AudioCodec,VideoCodec,AudioSourceInfo,TaskType,NetworkQualityType,SdkType,TerminalType,DropType,PubSubStates,PeerConnectionState,SubPubFailReason,ClientUserStats,VideoProfileType;function _defineProperty(e,t,r){return(t=toPropertyKey$1(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}!function(e){e.PCMU="pcmu",e.PCMA="pcma",e.OPUS="opus",e.G722="g722",e.ISAC="iSAC",e.ILBC="iLBC",e.AAC="aac",e.AC3="ac3",e.NELLYMOSER="nellymoser"}(AudioCodec||(AudioCodec={})),function(e){e.VP8="vp8",e.VP9="vp9",e.H264="h264",e.H265="h265",e.AV1="av1",e.AV1X="av1x"}(VideoCodec||(VideoCodec={})),exports.AudioSourceInfo=void 0,AudioSourceInfo=exports.AudioSourceInfo||(exports.AudioSourceInfo={}),AudioSourceInfo.MIC="mic",AudioSourceInfo.SCREENCAST="screen-cast",AudioSourceInfo.MIXED="mixed",exports.VideoSourceInfo=void 0,function(e){e.CAMERA="camera",e.SCREENCAST="screen-cast",e.MIXED="mixed"}(exports.VideoSourceInfo||(exports.VideoSourceInfo={})),function(e){e.PUBLISH="publish",e.SUBSCRIBE="subscribe"}(TaskType||(TaskType={})),function(e){e[e.UNKNOWN=0]="UNKNOWN",e[e.GREAT=1]="GREAT",e[e.GOOD=2]="GOOD",e[e.NORMAL=3]="NORMAL",e[e.POOR=4]="POOR",e[e.BAD=5]="BAD",e[e.DISCONNECTED=6]="DISCONNECTED"}(NetworkQualityType||(NetworkQualityType={})),function(e){e[e.Native=1]="Native",e[e.Web=2]="Web",e[e.MiniProgram=3]="MiniProgram"}(SdkType||(SdkType={})),function(e){e[e.Windows=1]="Windows",e[e.Android=2]="Android",e[e.Mac=3]="Mac",e[e.iOS=4]="iOS",e[e.Linux=5]="Linux",e[e.Others=6]="Others"}(TerminalType||(TerminalType={})),function(e){e[e.UserKickOut=2011]="UserKickOut",e[e.UserReplaced=2012]="UserReplaced"}(DropType||(DropType={})),function(e){e[e.Idle=0]="Idle",e[e.Processing=1]="Processing",e[e.End=2]="End"}(PubSubStates||(PubSubStates={})),function(e){e[e.New=0]="New",e[e.Idle=1]="Idle",e[e.Processing=2]="Processing",e[e.Ended=3]="Ended"}(PeerConnectionState||(PeerConnectionState={})),function(e){e.QuotaLimit="task exceed limit",e.PCNotExisted="connection does NOT exist",e.RoomClosed="room_already_closed:30107",e.RoomNotExisted="room does not exist",e.RoomBusy="RoomBusy",e.RoomNotJoined="participant has not joined",e.FailOver="Session has been aborted"}(SubPubFailReason||(SubPubFailReason={})),function(e){e[e.MIC_OPEN=0]="MIC_OPEN",e[e.MIC_INTERRUPTED=1]="MIC_INTERRUPTED",e[e.CAMERA_OPEN=2]="CAMERA_OPEN",e[e.BACKGROUND_MODE=3]="BACKGROUND_MODE",e[e.DOWNLINK=4]="DOWNLINK",e[e.UPLINK=5]="UPLINK"}(ClientUserStats||(ClientUserStats={})),function(e){e[e.None=0]="None",e[e.LD=2]="LD",e[e.SD=4]="SD",e[e.HD=8]="HD",e[e.FHD=16]="FHD",e[e.QHD=32]="QHD",e[e.UHD=64]="UHD"}(VideoProfileType||(VideoProfileType={}));var VideoDimensions={VD_120x120:[120,120],VD_160x120:[160,120],VD_180x180:[180,180],VD_240x180:[240,180],VD_320x180:[320,180],VD_240x240:[240,240],VD_320x240:[320,240],VD_424x240:[424,240],VD_360x360:[360,360],VD_480x360:[480,360],VD_640x360:[640,360],VD_480x480:[480,480],VD_640x480:[640,480],VD_840x480:[840,480],VD_960x540:[960,540],VD_960x720:[960,720],VD_1280x720:[1280,720],VD_1920x1080:[1920,1080]};exports.AudioSourceState=void 0,function(e){e.Playing="playing",e.Paused="paused",e.Stopped="stopped"}(exports.AudioSourceState||(exports.AudioSourceState={}));var SDK_VERSION="3.6.1",DEFAULT_GSLB_DOMAIN="https://gslb.dingrtc.com",IGNOGRED_VERSION=-999,SIGNAL_CALL_TIMEOUT=1e4,SUB_PUB_TIMEOUT=15e3,NETWORK_QUALITY_TIMEOUT=2e3,METRIC_STATS_INTERVAL=2e3,CREATE_PC_TIMEOUT=4e3,MEDIA_ELEMENT_LABEL_ATTR="rtc-label";JSON.stringify({needPersonalityAudioStream:!0,outPeerConnectionNotReuse:!0});var USER_STATS_SYNC="onertc_state_sync",TRACK_EVENT_NAME="onertc_internal_track_event",parseVideoDimension=function(e){return{width:VideoDimensions[e][0],height:VideoDimensions[e][1]}},isScreenCast=function(e){return"object"===_typeof$3(e.video)&&e.video.source===exports.VideoSourceInfo.SCREENCAST},addAudioTrackAttribute=function(e){var t,r=Object.create({}),n={};null!==(t=navigator)&&void 0!==t&&null!==(t=t.mediaDevices)&&void 0!==t&&t.getSupportedConstraints&&(n=navigator.mediaDevices.getSupportedConstraints());var i=e.AEC,o=e.AGC,a=e.ANS;return e.deviceId&&(r.deviceId=Environment.isSafari()?e.deviceId:{exact:e.deviceId}),n.autoGainControl&&(r.autoGainControl={ideal:null==o||o}),n.echoCancellation&&(r.echoCancellation={ideal:null==i||i}),n.noiseSuppression&&(r.noiseSuppression={ideal:null==a||a}),r},createMediaStream=function(e){if(!isObject(e)||!e.audio&&!e.video)return Promise.reject(new TypeError("Invalid constrains"));var t=e.audio,r=e.video;if(!isScreenCast(e)&&"object"===_typeof$3(t)&&t.source===exports.AudioSourceInfo.SCREENCAST)return Promise.reject(new TypeError("Cannot share screen without video."));if(isScreenCast(e)&&"object"===_typeof$3(t)&&t.source!==exports.AudioSourceInfo.SCREENCAST)return Promise.reject(new TypeError("Cannot capture video from screen cast while capture audio from other source."));if(!t&&!r)return Promise.reject(new TypeError("At least one of audio and video must be requested."));var n=Object.create({});if(n.audio="object"===_typeof$3(t)&&t.source===exports.AudioSourceInfo.MIC||"object"===_typeof$3(t)&&t.source===exports.AudioSourceInfo.SCREENCAST?addAudioTrackAttribute(t):e.audio,"object"===_typeof$3(r)){var i,o=r.frameRate,a=r.deviceId,s=r.source,c=r.facingMode,u=r.displaySurface,l=r.dimension;n.video=Object.create({}),isNumber(o)&&(n.video.frameRate=Math.min(r.frameRate,30)),l&&(i=parseVideoDimension(l)),i&&i.width&&i.height&&(s===exports.VideoSourceInfo.SCREENCAST?(n.video.width=i.width,n.video.height=i.height):(n.video.width={ideal:i.width,max:i.width},n.video.height={ideal:i.height,max:i.width})),isString(a)&&a&&(n.video.deviceId={exact:a}),s===exports.VideoSourceInfo.SCREENCAST&&(Environment.isFirefox()&&(n.video.mediaSource="screen"),u&&["browser","window","monitor"].includes(u)&&(n.video.displaySurface=u)),c&&["user","environment"].includes(c)&&(n.video.facingMode=c)}else n.video=r;return isScreenCast(e)?navigator.mediaDevices.getDisplayMedia(n):navigator.mediaDevices.getUserMedia(n)};function _superPropBase(e,t){for(;!{}.hasOwnProperty.call(e,t)&&null!==(e=_getPrototypeOf$1(e)););return e}function _get(){return _get="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,r){var n=_superPropBase(e,t);if(n){var i=Object.getOwnPropertyDescriptor(n,t);return i.get?i.get.call(3>arguments.length?e:r):i.value}},_get.apply(null,arguments)}function _arrayLikeToArray$d(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);t>r;r++)n[r]=e[r];return n}function _arrayWithoutHoles(e){if(Array.isArray(e))return _arrayLikeToArray$d(e)}function _iterableToArray(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function _unsupportedIterableToArray$d(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray$d(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray$d(e,t):void 0}}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _toConsumableArray(e){return _arrayWithoutHoles(e)||_iterableToArray(e)||_unsupportedIterableToArray$d(e)||_nonIterableSpread()}var getPlainMediaTrackInfo=function(e){var t={};return e?(t.kind=e.kind,t.label=e.label,t.id=e.id,t.contentHint=e.contentHint,t.enabled=e.enabled,t.muted=e.muted,t.readyState=e.readyState,t.settings=e.getSettings(),t.constraints=e.getConstraints(),t):t},getPlainMediaStreamInfo=function(e){if(!e)return{};var t={id:e.id,active:e.active},r=e.getTracks().map((function(e){return getPlainMediaTrackInfo(e)}));return t.trackInfos=r,t},isVideoStreamPlayable=function(e){if(!e)return!1;var t=e.getVideoTracks()[0];return t&&t.enabled&&!t.muted},getDeltaDurationInSeconds=function(e,t){var r=(e.timestamp-((null==t?void 0:t.timestamp)||e.timestamp))/1e3;return r>0||(r=1),r},transNativeAndWebNetworkRank=function(e,t){return null!=e?[2,4,6,0][e]:null!==t?[3,0,0,0,1,1,2][t]:void 0},getDelta=function(e,t){isNaN(e)&&(e=0),isNaN(t)&&(t=0);var r=e-t;return 0>r&&(r=e),r},InternalTryTimesTimerMap=new Map,tryTimes=function(e){var t=e.fn,r=e.times,n=e.interval,i=void 0===n?0:n,o=e.key,a=InternalTryTimesTimerMap.get(o),s=function(){a&&(removeTimer(a),InternalTryTimesTimerMap.delete(o),a=null)};s();var c=function(){var e=_asyncToGenerator$1(_regeneratorRuntime$1.mark((function e(){return _regeneratorRuntime$1.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,r--,e.next=4,t();case 4:s(),e.next=14;break;case 7:if(e.prev=7,e.t0=e.catch(0),0<r){e.next=12;break}throw s(),e.t0;case 12:a=addTimer((function(){c()}),i),InternalTryTimesTimerMap.set(o,a);case 14:case"end":return e.stop()}}),e,null,[[0,7]])})));return function(){return e.apply(this,arguments)}}();return c()},taskQueue=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,t=[],r=0,n=!1,i=function(){for(;e>r&&t.length;){r++;var n=t.shift();n&&n().finally((function(){r--,i()}))}};return{add:function(e){t.push(e),n&&i()},start:function(){n=!0,i()}}},awaitTime=function(e){return new Promise((function(t){addTimer(t,1e3*e)}))},_getReporter$5=getReporter(),logger$1=_getReporter$5.log,MEDIA_ELEMENT_INTERSECTING_ATTR="rtc-intersecting",MEDIA_ELEMENT_INTERSECTING_ATTR_VALUES={visible:"visible",invisible:"invisible"},MEDIA_ELEMENT_EVENT_NAMES=["abort","canplay","canplaythrough","durationchange","emptied","ended","error","loadeddata","loadedmetadata","loadstart","pause","play","playing","ratechange","seeked","seeking","stalled","suspend","volumechange","waiting"],MEDIA_PLAYBACK_CHECK_PERIOD_MS=4e3,getLabel=function(e){return"".concat(null==e?void 0:e.getAttribute(MEDIA_ELEMENT_LABEL_ATTR),"-").concat(null==e?void 0:e.rtcPurpose)},isVideoTagIntersectingVisible=function(e){return e&&e.getAttribute(MEDIA_ELEMENT_INTERSECTING_ATTR)===MEDIA_ELEMENT_INTERSECTING_ATTR_VALUES.visible},MediaElementPool=function(){return _createClass$1((function e(t,r){var n=this;_classCallCheck$1(this,e),Object.defineProperty(this,"mediaElementPool",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"mediaElementsInUse",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"allElements",{enumerable:!0,configurable:!0,writable:!0,value:new Set}),Object.defineProperty(this,"hasActivated",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"mediaKind",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"mediaPlaybackCheckInterval",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"debouncer",{enumerable:!0,configurable:!0,writable:!0,value:new Debouncer}),Object.defineProperty(this,"currentTimeOfLastCheckMap",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),Object.defineProperty(this,"observer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_activatedListener",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"destroy",{enumerable:!0,configurable:!0,writable:!0,value:function(){n.mediaElementPool.forEach((function(e){return n._resetMediaElement(e)})),n.mediaElementPool=[],n.allElements.clear(),n.mediaElementsInUse.forEach((function(e){return n._resetMediaElement(e)})),n.mediaElementsInUse=[],document.removeEventListener("click",n._onUserInteraction),document.removeEventListener("touchstart",n._onUserInteraction),document.removeEventListener("visibilitychange",n._tryReloadOnPauseAndErrorWhenVisibleTriggerByVisible),n.mediaPlaybackCheckInterval&&(removeTimer(n.mediaPlaybackCheckInterval,"interval"),n.mediaPlaybackCheckInterval=null),[].concat(_toConsumableArray(n.mediaElementPool),_toConsumableArray(n.mediaElementsInUse)).forEach((function(e){var t;return null===(t=n.observer)||void 0===t?void 0:t.unobserve(e)}))}}),Object.defineProperty(this,"_tryReloadOnPauseAndErrorWhenVisible",{enumerable:!0,configurable:!0,writable:!0,value:function(e){n.mediaElementsInUse.forEach((function(t){if(t.srcObject){var r=t.srcObject;if(t.error){var i="".concat(e,": ").concat(getLabel(t)," has error, error=").concat(t.error,",doc.visibilityState=").concat(document.visibilityState,", mediaStream="),o=getPlainMediaStreamInfo(r);logger$1.debug(i,o),"visible"===document.visibilityState&&isVideoStreamPlayable(r)&&t.load()}if(t.paused){var a=!1;if(n.hasActivated&&"video"===n.mediaKind?isVideoTagIntersectingVisible(t)&&"visible"===document.visibilityState&&"visible"===getComputedStyle(t).visibility&&(a=!0):a=!0,a){var s="".concat(e,": ").concat(getLabel(t)," paused, doc.visibilityState=").concat(document.visibilityState,", intersecting=").concat(t.getAttribute(MEDIA_ELEMENT_INTERSECTING_ATTR),", mediaStream="),c=getPlainMediaStreamInfo(r);logger$1.error(s,c),isVideoStreamPlayable(r)&&t.load(),t.paused&&t.play().catch((function(e){console.error("inPoll",e)}))}}}})),n.debouncer.debounce(n._tryReloadOnCurrentTimeFreeze.bind(n,e),1e3)}}),Object.defineProperty(this,"_tryReloadOnCurrentTimeFreeze",{enumerable:!0,configurable:!0,writable:!0,value:function(e){n.mediaElementsInUse.forEach((function(t){if(t.srcObject){var r=t.srcObject,i="video"===n.mediaKind?r.getVideoTracks()[0]:void 0;if(!t.paused&&n.currentTimeOfLastCheckMap.get(t)===t.currentTime&&!0!==(null==i?void 0:i.muted)){var o="".concat(e,": ").concat(getLabel(t)," currentTime stop, doc.visibilityState=").concat(document.visibilityState,", curTime=").concat(t.currentTime,", mediaStream="),a=getPlainMediaStreamInfo(r);return logger$1.error(o,a),void("visible"===document.visibilityState&&isVideoStreamPlayable(r)&&t.load())}n.currentTimeOfLastCheckMap.set(t,t.currentTime)}}))}}),Object.defineProperty(this,"_tryReloadOnPauseAndErrorWhenVisibleTriggerByVisible",{enumerable:!0,configurable:!0,writable:!0,value:function(){n._tryReloadOnPauseAndErrorWhenVisible("visibilityChange")}}),Object.defineProperty(this,"_elementDefaultErrorHandler",{enumerable:!0,configurable:!0,writable:!0,value:function(e){var t=e.target,r="error event on ".concat(n.mediaKind," playback, mediaStream="),i=getPlainMediaStreamInfo(null==t?void 0:t.srcObject);logger$1.error(r,i,null==t?void 0:t.error)}}),Object.defineProperty(this,"_elementDefaultPauseHandler",{enumerable:!0,configurable:!0,writable:!0,value:function(e){var t=e.target,r="pause event on ".concat(n.mediaKind," playback, mediaStream="),i=getPlainMediaStreamInfo(null==t?void 0:t.srcObject);logger$1.error(r,i,null==t?void 0:t.error)}}),Object.defineProperty(this,"_elementDefaultPlayHandler",{enumerable:!0,configurable:!0,writable:!0,value:function(e){var t=e.target,r="play event on ".concat(n.mediaKind," playback, mediaStream="),i=getPlainMediaStreamInfo(null==t?void 0:t.srcObject);logger$1.debug(r,i)}}),Object.defineProperty(this,"_onUserInteraction",{enumerable:!0,configurable:!0,writable:!0,value:function(){var e=[].concat(_toConsumableArray(n.mediaElementPool),_toConsumableArray(n.mediaElementsInUse));if(!n.hasActivated&&(n.hasActivated=!0,e.forEach((function(e){e.load()})),n._activatedListener))try{n._activatedListener()}catch(e){logger$1.error("error occurred when exec activatedListener",tryJsonStringify(e))}n._tryReloadOnPauseAndErrorWhenVisible("userInteract")}}),this.mediaElementsInUse=[],this.mediaElementPool=[],this.mediaKind=t,window.IntersectionObserver&&(this.observer=new IntersectionObserver((function(e){e.forEach((function(e){var t,r;e.isIntersecting?null===(t=e.target)||void 0===t||t.setAttribute(MEDIA_ELEMENT_INTERSECTING_ATTR,MEDIA_ELEMENT_INTERSECTING_ATTR_VALUES.visible):null===(r=e.target)||void 0===r||r.setAttribute(MEDIA_ELEMENT_INTERSECTING_ATTR,MEDIA_ELEMENT_INTERSECTING_ATTR_VALUES.invisible)}))})));for(var i=0;r>i;i++){var o,a=this._createElement();null===(o=this.observer)||void 0===o||o.observe(a),this.addAtttribute(a),a.setAttribute(MEDIA_ELEMENT_LABEL_ATTR,"".concat(t,"-").concat(i)),this.mediaElementPool.push(a),this.allElements.add(a)}document.addEventListener("click",this._onUserInteraction,!0),document.addEventListener("touchstart",this._onUserInteraction,!0),document.addEventListener("visibilitychange",this._tryReloadOnPauseAndErrorWhenVisibleTriggerByVisible,!0),this.mediaPlaybackCheckInterval=addTimer((function(){n.hasActivated&&n._tryReloadOnPauseAndErrorWhenVisible("intervalCheck")}),MEDIA_PLAYBACK_CHECK_PERIOD_MS,"interval")}),[{key:"addAtttribute",value:function(e){if(e.autoplay=!0,e.setAttribute(MEDIA_ELEMENT_LABEL_ATTR,"toReused"),e instanceof HTMLVideoElement)e.muted=!0,e.playsInline=!0,e.controls=!1,e.setAttribute("webkit-playsinline","true"),e.setAttribute("x5-video-player-type","h5"),e.setAttribute("x5-playsinline","true");else{var t,r=e;r.volume=1,null===(t=r.setSinkId)||void 0===t||t.call(r,"")}}},{key:"popElement",value:function(e){var t;return(t=this.mediaElementPool.shift())?(this._resetMediaElement(t),t.addEventListener("error",this._elementDefaultErrorHandler),t.addEventListener("pause",this._elementDefaultPauseHandler),t.addEventListener("play",this._elementDefaultPlayHandler),t.rtcPurpose=e||""):(t=document.createElement(this.mediaKind),this.addAtttribute(t)),t}},{key:"pushElement",value:function(e){if(this.allElements.has(e)){var t=this.mediaElementsInUse;this.mediaElementsInUse=this.mediaElementsInUse.filter((function(t){return t!==e})),t.length!==this.mediaElementsInUse.length&&(this.mediaElementPool.push(e),this._resetMediaElement(e))}}},{key:"isMediaElementActivated",value:function(){return this.hasActivated}},{key:"setActivateListener",value:function(e){this._activatedListener=e}},{key:"_createElement",value:function(){var e,t=document.createElement(this.mediaKind);return null===(e=this.observer)||void 0===e||e.observe(t),t}},{key:"_resetMediaElement",value:function(e){MEDIA_ELEMENT_EVENT_NAMES.forEach((function(t){e["on".concat(t)]=null})),e.removeEventListener("error",this._elementDefaultErrorHandler),e.removeEventListener("pause",this._elementDefaultPauseHandler),e.removeEventListener("play",this._elementDefaultPlayHandler),e.style.cssText="",e.className="",this.addAtttribute(e),e.srcObject=null}}])}(),audioElementMgr,videoElementMgr,getAudioElementMgr=function(){return audioElementMgr||initMediaElementManager(),audioElementMgr},getVideoElementMgr=function(){return videoElementMgr||initMediaElementManager(),videoElementMgr},INIT_AUDIO_TAG_COUNT=2,INIT_VIDEO_TAG_COUNT=Environment.isIOS()||Environment.isAndroid()?9:25,initMediaElementManager=function(){audioElementMgr||(audioElementMgr=new MediaElementPool("audio",INIT_AUDIO_TAG_COUNT)),videoElementMgr||(videoElementMgr=new MediaElementPool("video",INIT_VIDEO_TAG_COUNT))},audioContext=new AudioContext,getAudioContext=function(){return audioContext},mergeAudioTracks=function(e){var t=e.getAudioTracks(),r=audioContext.createMediaStreamDestination();return t.forEach((function(e){audioContext.createMediaStreamSource(new MediaStream([e])).connect(r)})),r.stream.getAudioTracks()[0]},playVideo=function(e,t,r){var n=getVideoElementMgr().popElement();n.style.width="100%",n.style.height="100%";var i=r.fit;return!0===r.mirror&&(n.style.transform="scaleX(-1)"),i&&(n.style.objectFit=i),e.appendChild(n),n.pause(),n.srcObject=t,n.load(),n},playAudio=function(e){var t=getAudioElementMgr().popElement();return t.srcObject=e,t},getAudioVolumeLevel=function(e,t,r){"running"!==e.state&&e.resume(),r.connect(t),t.fftSize=2048,t.smoothingTimeConstant=.4;var n=new Float32Array(t.fftSize);if(t.getFloatTimeDomainData)t.getFloatTimeDomainData(n);else{var i=new Uint8Array(t.fftSize);t.getByteTimeDomainData(i);for(var o=0;n.length>o;++o)n[o]=i[o]/128-1}for(var a=0,s=0;n.length>s;s++)a+=n[s]*n[s];return Math.max(10*Math.log10(a/n.length)+100,0)/100},getCurrentFrame=function(e){var t=document.createElement("canvas"),r=t.getContext("2d"),n=e.videoHeight,i=e.videoWidth;return t.width=i,t.height=n,r.drawImage(e,0,0,i,n),t.toDataURL("image/png")};function _callSuper$l(e,t,r){return t=_getPrototypeOf$1(t),_possibleConstructorReturn$1(e,_isNativeReflectConstruct$l()?Reflect.construct(t,[],_getPrototypeOf$1(e).constructor):t.apply(e,r))}function _isNativeReflectConstruct$l(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(_isNativeReflectConstruct$l=function(){return!!e})()}var _getReporter$4=getReporter(),simpleLogger$3=_getReporter$4.log,trace=_getReporter$4.trace,wrapperDomToTrack=new Map,Track=function(e){function t(e,r){var n;return _classCallCheck$1(this,t),n=_callSuper$l(this,t),Object.defineProperty(n,"trackMediaType",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(n,"isPlaying",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(n,"source",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(n,"logger",{enumerable:!0,configurable:!0,writable:!0,value:trace}),Object.defineProperty(n,"sourceNode",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(n,"element",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(n,"audioContext",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(n,"analyser",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(n,"trackSettings",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(n,"sfuStream",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(n,"mediaStreamTrack",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(n,"playerConfig",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(n,"wrapperDom",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(n,"trackId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(n,"sourceMirror",{enumerable:!0,configurable:!0,writable:!0,value:!1}),n.trackId=createUuid(),e?(n.trackMediaType=e.kind,n.trackSettings=e.getSettings()):r&&(n.trackMediaType="audio"),"audio"===n.trackMediaType&&(n.audioContext=getAudioContext(),n.analyser=n.audioContext.createAnalyser()),n.setMediaStreamTrack(e,r),n}return _inherits$1(t,e),_createClass$1(t,[{key:"getTrackId",value:function(){return this.trackId}},{key:"setMediaStreamTrack",value:function(e,t){var r=this,n=this.mediaStreamTrack;if(n&&(n.onended=null),e||t){var i;if(n&&e&&(e.enabled=n.enabled),"audio"===this.trackMediaType)if(this.sourceNode&&(this.sourceNode.disconnect(),this.sourceNode=null),e)this.sourceNode=null===(i=this.audioContext)||void 0===i?void 0:i.createMediaStreamSource(new MediaStream([e]));else if(t){var o,a=mergeAudioTracks(t);this.sourceNode=null===(o=this.audioContext)||void 0===o?void 0:o.createMediaStreamSource(new MediaStream([a]))}e?(this.mediaStreamTrack=e,this.mediaStreamTrack.onended=function(){r.source===exports.VideoSourceInfo.SCREENCAST?r.logger.sendEvent("SCREEN_DEVICE_STOP"):r.source===exports.AudioSourceInfo.MIC?new DingRTCError(ErrorCode.MicInterrupt):r.source===exports.VideoSourceInfo.CAMERA&&new DingRTCError(ErrorCode.CameraInterrupt)}):t&&(this.sfuStream=t)}}},{key:"replaceTrack",value:function(e,t){simpleLogger$3.info("replaceTrack",e,t),t&&this.isPlaying&&this.stop(),this.replaceTrackInner(e)}},{key:"replaceTrackInner",value:function(e,t){this.setMediaStreamTrack(e,t),this.emit(TRACK_EVENT_NAME,"replace",this),this.isPlaying&&this.innnerPlay()}},{key:"setSource",value:function(e){e===exports.VideoSourceInfo.CAMERA?this.logger.sendEvent("VIDEO_DEVICE_START"):e===exports.VideoSourceInfo.SCREENCAST?this.logger.sendEvent("SCREEN_DEVICE_START"):e===exports.AudioSourceInfo.MIC&&this.logger.sendEvent("AUDIO_DEVICE_START"),this.source=e}},{key:"stop",value:function(){this.isPlaying=!1,simpleLogger$3.info("stop paly track ".concat(this.getTrackId())),this.element&&(wrapperDomToTrack.get(this.wrapperDom)===this&&wrapperDomToTrack.delete(this.wrapperDom),this.wrapperDom&&(this.wrapperDom.removeChild(this.element),this.wrapperDom=null),this.element.pause(),this.element.srcObject=null,"audio"===this.trackMediaType?getAudioElementMgr().pushElement(this.element):getVideoElementMgr().pushElement(this.element),this.setMediaElement(null))}},{key:"innnerPlay",value:function(e,t){var r=this,n=this.element;t&&(this.playerConfig=t);var i,o=this.playerConfig||{},a=o.mirror,s=o.fit;if(e&&(i="string"==typeof e?document.querySelector(e):e,!document.contains(i)))throw new DingRTCError(ErrorCode.InvaildArgument,"wrapper dom not found");if(n){if(i&&this.wrapperDom&&i!==this.wrapperDom)return this.stop(),void this.innnerPlay(e,t);n.pause(),n.style.transform=!this.sourceMirror!=!a?"scaleX(-1)":"",n.srcObject=this.sfuStream||new MediaStream([this.getMediaStreamTrack()]),n.load()}else{if("audio"===this.trackMediaType){n=playAudio(this.sfuStream||new MediaStream([this.getMediaStreamTrack()]));try{"running"!==this.audioContext.state&&this.audioContext.resume()}catch(e){simpleLogger$3.debug("resume audioContext failed: ".concat(tryJsonStringify(e)))}}else{var c=wrapperDomToTrack.get(i);c&&c.stop();var u=playVideo(i,new MediaStream([this.getMediaStreamTrack()]),{mirror:!this.sourceMirror!=!a,fit:s});this.wrapperDom=i,n=u,wrapperDomToTrack.set(this.wrapperDom,this)}this.setMediaElement(n)}n.paused&&n.play().then((function(){r.isPlaying=!0})).catch((function(e){"NotAllowedError"===e.name?(r.isPlaying=!1,simpleLogger$3.error("autoplay failed",tryJsonStringify(e)),EventBus.emit("autoplay-failed",r)):simpleLogger$3.warn("".concat(r.trackMediaType," play has exception"),tryJsonStringify(e))}))}},{key:"setMediaElement",value:function(e){this.element=e}},{key:"getMediaStreamTrack",value:function(){return this.mediaStreamTrack}}])}(EventEmitter);function _arrayWithHoles(e){if(Array.isArray(e))return e}function _iterableToArrayLimit(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,i,o,a,s=[],c=!0,u=!1;try{if(o=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=o.call(r)).done)&&(s.push(n.value),s.length!==t);c=!0);}catch(e){u=!0,i=e}finally{try{if(!c&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(u)throw i}}return s}}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _slicedToArray(e,t){return _arrayWithHoles(e)||_iterableToArrayLimit(e,t)||_unsupportedIterableToArray$d(e,t)||_nonIterableRest()}var _getReporter$3=getReporter(),logger=_getReporter$3.log,Support=function(){return _createClass$1((function e(){_classCallCheck$1(this,e),Object.defineProperty(this,"system",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"browser",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"browserVersion",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.system=Environment.system,this.browser=Environment.browserType,this.browserVersion=Environment.browserVersion}),[{key:"getSupportedCodec",value:(e=_asyncToGenerator$1(_regeneratorRuntime$1.mark((function e(){var t,r,n;return _regeneratorRuntime$1.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t={audio:[],video:[]},e.prev=1,(r=new RTCPeerConnection).addTransceiver("video",{direction:"recvonly"}),r.addTransceiver("audio",{direction:"recvonly"}),e.next=7,r.createOffer();case 7:if(n=e.sent.sdp){e.next=10;break}return e.abrupt("return",t);case 10:return r.close(),r=null,n.match(/ VP8/i)&&t.video.push("VP8"),n.match(/ VP9/i)&&t.video.push("VP9"),n.match(/ AV1/i)&&t.video.push("AV1"),n.match(/ H264/i)&&t.video.push("H264"),n.match(/ H265/i)&&t.video.push("H265"),n.match(/ opus/i)&&t.audio.push("OPUS"),n.match(/ PCMU/i)&&t.audio.push("PCMU"),n.match(/ PCMA/i)&&t.audio.push("PCMA"),n.match(/ G722/i)&&t.audio.push("G722"),e.abrupt("return",t);case 24:throw e.prev=24,e.t0=e.catch(1),logger.error("get supportedCodecs failed"),new DingRTCError(ErrorCode.IceConnectionSetLocalDescFail,"get supportedCodecs failed");case 28:case"end":return e.stop()}}),e,null,[[1,24]])}))),function(){return e.apply(this,arguments)})},{key:"checkSupported",value:function(){var e=!1;try{var t=window.RTCPeerConnection,r=navigator.mediaDevices&&navigator.mediaDevices.getUserMedia,n=window.WebSocket;e=!!(t&&r&&n)}catch(e){return!1}var i=!1;i=Environment.isChrome()||Environment.isFirefox()?parseInt(Environment.browserVersion,10)>=69:Environment.isOpera()?parseInt(Environment.browserVersion,10)>=45:Environment.isSafari()?parseInt(Environment.browserVersion,10)>=11:(Environment.isWeixin()||Environment.isQQBrowser(),!0);var o=e&&i;return logger.debug("checkSystemRequirements, api:",e,"browser",i),o}},{key:"isSupportScreenShare",value:function(){return!this.system.includes(OSType.ANDROID)&&this.system!==OSType.IOS&&((this.browser!==BrowserType.SAFARI||parseInt(this.browserVersion)>=13)&&((this.browser!==BrowserType.FIREFOX||parseInt(this.browserVersion)>=66)&&!!(navigator&&navigator.mediaDevices&&navigator.mediaDevices.getDisplayMedia)))}}]);var e}(),support=new Support,isSupportSimulcast=function(){var e,t=(null===(e=window.RTCRtpSender)||void 0===e?void 0:e.prototype)||{};return!(!t.setParameters||!t.getParameters)&&(!Environment.isFirefox()&&(Environment.isSafari()?parseInt(Environment.browserVersion)>=14:!Environment.isChrome()||parseInt(Environment.browserVersion)>=81))};function _callSuper$k(e,t,r){return t=_getPrototypeOf$1(t),_possibleConstructorReturn$1(e,_isNativeReflectConstruct$k()?Reflect.construct(t,[],_getPrototypeOf$1(e).constructor):t.apply(e,r))}function _isNativeReflectConstruct$k(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(_isNativeReflectConstruct$k=function(){return!!e})()}var ClientConfig=function(e){function t(){var e;return _classCallCheck$1(this,t),e=_callSuper$k(this,t),Object.defineProperty(e,"gslb",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(e,"simulcast",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(e,"grouptalk",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(e,"audioSFU",{enumerable:!0,configurable:!0,writable:!0,value:!0}),e.setClientConfig({gslb:[DEFAULT_GSLB_DOMAIN]}),e}return _inherits$1(t,e),_createClass$1(t,[{key:"setClientConfig",value:function(e){var t=e||{},r=t.gslb,n=t.simulcast,i=t.audioSFU;"string"==typeof r&&(this.gslb=[r],setGslb(r)),Array.isArray(r)&&isString(r[0])&&(this.gslb=r,setGslb(r[0])),null!=n&&isSupportSimulcast()&&(this.simulcast=!!n),null!=i&&(this.audioSFU=!!i)}}])}(EventEmitter),clientConfig=new ClientConfig,ResolutionProfile;function ownKeys$9(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function _objectSpread$9(e){for(var t=1;arguments.length>t;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ownKeys$9(Object(r),!0).forEach((function(t){_defineProperty(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ownKeys$9(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}!function(e){e[e.LLD=0]="LLD",e[e.LD=1]="LD",e[e.SD=2]="SD",e[e.HD=3]="HD",e[e.FHD=4]="FHD"}(ResolutionProfile||(ResolutionProfile={}));var ResolutionProfileMap=_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({},ResolutionProfile.LLD,"lld"),ResolutionProfile.LD,"ld"),ResolutionProfile.SD,"sd"),ResolutionProfile.HD,"hd"),ResolutionProfile.FHD,"fhd"),ResolutionRange={high:[1228800,2764800],FHD:[1228800,2764800],HD:[307200,1228800],SD:[76800,307200],LD:[0,76800],low:[0,76800]},getResolutionLevel=function(e,t){var r={high:VideoProfileType.FHD,low:VideoProfileType.LD,FHD:VideoProfileType.FHD,HD:VideoProfileType.HD,SD:VideoProfileType.SD,LD:VideoProfileType.LD},n=r[e]||VideoProfileType.None,i=t[t.length-1].width*t[t.length-1].height;if(ResolutionRange[e][0]>i){var o=Object.entries(ResolutionRange).find((function(e){var t=_slicedToArray(e,2),r=t[1];return i>r[0]&&r[1]>=i}));n=r[_slicedToArray(o,1)[0]]}return n},getResolutionInfo=function(e,t){return{resolution:getResolution(e,t),resolutionLevel:getResolutionLevel(e,t)}},getResolution=function(e,t){var r=ResolutionRange[e],n=t.length;if(t[0].width*t[0].height>ResolutionRange.FHD[1])return t[0];for(var i=0;n>i;i++){var o=t[i].width*t[i].height;if(o>=r[0]&&r[1]>=o)return t[i]}for(var a=n-1;a>=0;a--){if(r[1]>t[a].width*t[a].height)return t[a]}return t[0]},DefaultVideoMaxPixelCount=[49152,76800,307200,1228800,2764800],DefaultMaxBitrateKbps=[200,350,1e3,1800,2828],DefaultResolution_16_9=[[256,144],[320,180],[640,360],[1280,720],[1920,1080]],DefaultResolution_4_3=[[256,192],[320,240],[640,480],[1280,960],[1920,1440]],getVideoProfile=function(e,t){var r=ResolutionProfile.FHD,n=e*t;return n>DefaultVideoMaxPixelCount[ResolutionProfile.LLD]?n>DefaultVideoMaxPixelCount[ResolutionProfile.LD]?n>DefaultVideoMaxPixelCount[ResolutionProfile.SD]?n>DefaultVideoMaxPixelCount[ResolutionProfile.HD]?n>DefaultVideoMaxPixelCount[ResolutionProfile.FHD]||(r=ResolutionProfile.FHD):r=ResolutionProfile.HD:r=ResolutionProfile.SD:r=ResolutionProfile.LD:r=ResolutionProfile.LLD,r},getTargetResolution=function(e,t,r,n){var i=0,o=0;if(r>=n)return[i=e,o=t];if(t>e){var a=[e,t];t=a[0],e=a[1]}if(16*t==9*e)i=DefaultResolution_16_9[r][0],o=DefaultResolution_16_9[r][1];else if(4*t==3*e)i=DefaultResolution_4_3[r][0],o=DefaultResolution_4_3[r][1];else{var s=Math.sqrt(1*DefaultResolution_16_9[r][0]*DefaultResolution_16_9[r][1]/e/t);o=Math.round(t*(s=1*(i=(i=Math.round(e*s))+15&-16)/e))}return[i,o]},getVideoMaxbitrate=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;if(!r){var n=1;30!==t&&(n=Math.sqrt(t/30));var i=e.getSettings(),o=DefaultMaxBitrateKbps[getVideoProfile(i.width,i.height)];r=Math.round(Math.max(n*o,50))}return r},getVideoSenderEncodings=function(e){var t=e.getMaxBitrate(),r=e.trackSettings,n=r.height,i=r.width,o=r.frameRate,a=[],s=getVideoProfile(i,n);if(!clientConfig.simulcast||e.source===exports.VideoSourceInfo.SCREENCAST)return[{maxFramerate:o,maxBitrate:t,scaleResolutionDownBy:1,active:!0,rid:"",minBitrate:Math.round((t+30)/2),targetWidth:i,targetHeight:n}];var c=s>ResolutionProfile.HD?3:2,u=function(e){var r=_slicedToArray(getTargetResolution(i,n,e,s),2),a=r[1];return{targetWidth:r[0],rid:ResolutionProfileMap[e],targetHeight:a,minBitrate:50,maxFramerate:o,maxBitrate:Math.round(Math.max(30,t*(DefaultMaxBitrateKbps[e]/DefaultMaxBitrateKbps[s]))),scaleResolutionDownBy:1/(a/n)}};s>ResolutionProfile.LLD&&a.push(_objectSpread$9({active:!1},u(ResolutionProfile.LLD))),s>ResolutionProfile.LD&&a.push(_objectSpread$9({active:c>1},u(ResolutionProfile.LD))),s>ResolutionProfile.SD&&a.push(_objectSpread$9({active:c>2},u(ResolutionProfile.SD))),s>ResolutionProfile.HD?(a.push(_objectSpread$9({active:!1},u(ResolutionProfile.HD))),a.push(_objectSpread$9({active:!0},u(ResolutionProfile.FHD)))):a.push(_objectSpread$9({active:!0},u(s)));for(var l=0,d=0;a.length>d;++d)0!=d&&(a[d].minBitrate=l),l=Math.round(Math.max((a[d].maxBitrate+a[d].minBitrate)/2,a[d].maxBitrate-400));return a.shift(),a};function ownKeys$8(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function _objectSpread$8(e){for(var t=1;arguments.length>t;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ownKeys$8(Object(r),!0).forEach((function(t){_defineProperty(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ownKeys$8(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function _callSuper$j(e,t,r){return t=_getPrototypeOf$1(t),_possibleConstructorReturn$1(e,_isNativeReflectConstruct$j()?Reflect.construct(t,r||[],_getPrototypeOf$1(e).constructor):t.apply(e,r))}function _isNativeReflectConstruct$j(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(_isNativeReflectConstruct$j=function(){return!!e})()}function _superPropGet$2(e,t,r,n){var i=_get(_getPrototypeOf$1(e.prototype),t,r);return"function"==typeof i?function(e){return i.apply(r,e)}:i}var _getReporter$2=getReporter(),simpleLogger$2=_getReporter$2.log,LocalTrack=function(e){function t(e,r){var n;(_classCallCheck$1(this,t),n=_callSuper$j(this,t,[e]),Object.defineProperty(n,"deviceId",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(n,"muted",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(n,"maxBitrate",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(n,"enabled",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(n,"config",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(n,"isClosed",{enumerable:!0,configurable:!0,writable:!0,value:!1}),e)&&(n.muted=e.muted);return n.enabled=!0,n.isPlaying=!1,n.deviceId=r,n}return _inherits$1(t,e),_createClass$1(t,[{key:"setMediaStreamTrack",value:function(e){var r,n=this;_superPropGet$2(t,"setMediaStreamTrack",this)([e]),e&&(this.trackSettings=e.getSettings(),null===(r=this.element)||void 0===r||r.addEventListener("loadeddata",(function(){n.emit("first-frame-decoded")})),e.onended=function(){n.stop(),n.close&&n.close(),n.emit("track-ended")})}},{key:"play",value:function(e,t){this.innnerPlay(e,t)}},{key:"setEnabled",value:function(e){return simpleLogger$2.info("setEnabled",e),this.isClosed?Promise.reject(new DingRTCError(ErrorCode.InvaildState)):(this.enabled=e,this.emit(TRACK_EVENT_NAME,e?"unmute":"mute"),e?this.updateNewTrack():(null===(t=this.mediaStreamTrack)||void 0===t||t.stop(),this.setMediaStreamTrack(null),this.source===exports.VideoSourceInfo.CAMERA?this.logger.sendEvent("VIDEO_DEVICE_STOP"):this.source===exports.VideoSourceInfo.SCREENCAST&&this.logger.sendEvent("SCREEN_DEVICE_STOP"),Promise.resolve()));var t}},{key:"close",value:function(){var e;simpleLogger$2.info("".concat(this.source," track:").concat(this.getTrackId()," close")),this.isClosed||(this.isClosed=!0,this.isPlaying&&this.stop(),this.emit(TRACK_EVENT_NAME,"stop"),null===(e=this.mediaStreamTrack)||void 0===e||e.stop(),this.setMediaStreamTrack(null),this.audioContext&&(this.sourceNode=null,this.analyser=null,this.audioContext=null),this.source===exports.VideoSourceInfo.CAMERA?this.logger.sendEvent("VIDEO_DEVICE_STOP"):this.source===exports.VideoSourceInfo.SCREENCAST&&this.logger.sendEvent("SCREEN_DEVICE_STOP"))}},{key:"setMuted",value:function(e){return simpleLogger$2.info("setMuted",e),this.isClosed?Promise.reject(new DingRTCError(ErrorCode.InvaildState)):(this.muted=e,this.mediaStreamTrack.enabled=!e,this.emit(TRACK_EVENT_NAME,e?"mute":"unmute"),Promise.resolve())}},{key:"getAudioTrack",value:function(){var e=this;return simpleLogger$2.debug("gengrate new audioTrack"),new Promise((function(t,r){var n;createMediaStream({audio:_objectSpread$8(_objectSpread$8({source:e.source},e.config),{},{deviceId:e.deviceId})}).then((function(e){n=e.getAudioTracks()[0]})).catch((function(t){try{var i=e.audioContext.createOscillator(),o=e.audioContext.createMediaStreamDestination();i.connect(o),n=o.stream.getAudioTracks()[0]}catch(e){simpleLogger$2.error("gengrate new audioTrack error",parseAudioDeviceError(t)),r(parseAudioDeviceError(t))}})).finally((function(){n&&t(n)}))}))}},{key:"getVideoTrack",value:function(){var e=this;return simpleLogger$2.debug("gengrate new videoTrack"),new Promise((function(t,r){var n;createMediaStream({video:_objectSpread$8(_objectSpread$8({source:e.source},e.config),{},{deviceId:e.deviceId}),audio:!1}).then((function(e){n=e.getVideoTracks()[0],t(n)})).catch((function(e){simpleLogger$2.error("gengrate new videoTrack error",parseVideoDeviceError(e)),r(parseVideoDeviceError(e))}))}))}},{key:"updateNewTrack",value:function(){var e=this,t=this.getMediaStreamTrack();return t.onended=null,simpleLogger$2.debug("stop oldTrack first"),t.stop(),"audio"===this.trackMediaType?this.getAudioTrack().then((function(t){return e.replaceTrackInner(t)})):"video"===this.trackMediaType?this.getVideoTrack().then((function(t){return e.replaceTrackInner(t)})):void 0}},{key:"setDevice",value:(r=_asyncToGenerator$1(_regeneratorRuntime$1.mark((function e(t){return _regeneratorRuntime$1.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(simpleLogger$2.info("setDevice",t),!this.isClosed){e.next=3;break}return e.abrupt("return");case 3:if(!(this instanceof CameraVideoTrack)||"user"!==t&&"environment"!==t){e.next=7;break}this.config.facingMode=t,e.next=10;break;case 7:if(this.deviceId!==t){e.next=9;break}return e.abrupt("return");case 9:this.deviceId=t;case 10:return e.abrupt("return",this.updateNewTrack());case 11:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"getTrackLabel",value:function(){if(simpleLogger$2.info("getTrackLabel"),!this.isClosed)return this.mediaStreamTrack.label}},{key:"getMaxBitrate",value:function(){if(!this.isClosed)return this.maxBitrate}}]);var r}(Track),LocalVideoTrack=function(e){function t(e,r,n){var i;return _classCallCheck$1(this,t),(i=_callSuper$j(this,t,[e,r])).config=n,e&&(i.maxBitrate=getVideoMaxbitrate(e,n.frameRate,n.maxBitrate)),i}return _inherits$1(t,e),_createClass$1(t,[{key:"optimizationMode",get:function(){return this.config.optimizationMode}},{key:"setEncoderConfiguration",value:function(e){var t=this;simpleLogger$2.info("videoTrack ".concat(this.getTrackId()," setEncoderConfiguration"),e);var r=e.dimension,n=e.frameRate,i=e.maxBitrate,o=e.optimizationMode,a=e.mirror;if(n&&Number.isNaN(n))return Promise.reject(new DingRTCError(ErrorCode.InvaildArgument,"invalid frameRate"));if(r&&!VideoDimensions[r])return Promise.reject(new DingRTCError(ErrorCode.InvaildArgument,"invalid dimension"));!a!=!this.config.mirror&&(this.emit(TRACK_EVENT_NAME,"mirror",a),this.config.mirror=a),o&&o!==this.optimizationMode&&(this.config.optimizationMode=o,this.emit(TRACK_EVENT_NAME,"optimizationMode"));var s=!1;if(r&&this.config.dimension!==r&&(this.config.dimension=r,s=!0),n&&this.config.frameRate!==Math.min(30,n)&&(this.config.frameRate=Math.min(30,n),s=!0),i&&this.maxBitrate!==i&&(s=!0),!s)return Promise.resolve();var c=_objectSpread$8({frameRate:this.config.frameRate},parseVideoDimension(this.config.dimension)),u=this.getMediaStreamTrack();return null==u?void 0:u.applyConstraints(c).then((function(){t.maxBitrate=getVideoMaxbitrate(t.getMediaStreamTrack(),t.config.frameRate,i),t.emit(TRACK_EVENT_NAME,"republish",t)})).catch((function(e){var r=parseVideoDeviceError(e);throw simpleLogger$2.error("videoTrack ".concat(t.getTrackId()," setEncoderConfiguration error"),r),r}))}},{key:"getCurrentFrameData",value:function(){return simpleLogger$2.info("getCurrentFrameData"),this.isClosed||!this.isPlaying?null:getCurrentFrame(this.element)}},{key:"play",value:function(e,r){return simpleLogger$2.info("local video play"),_superPropGet$2(t,"play",this)([e,r])}}])}(LocalTrack),LocalAudioTrack=function(e){function t(e,r){return _classCallCheck$1(this,t),_callSuper$j(this,t,[e,r])}return _inherits$1(t,e),_createClass$1(t,[{key:"setVolume",value:function(e){simpleLogger$2.info("setVolume",e),this.isClosed||this.element&&(this.element.volume=e)}},{key:"getVolume",value:function(){if(simpleLogger$2.info("getVolume"),!this.isClosed)return this.element?this.element.volume:void 0}},{key:"getVolumeLevel",value:function(){return this.isClosed?0:getAudioVolumeLevel(this.audioContext,this.analyser,this.sourceNode)}},{key:"play",value:function(){return simpleLogger$2.info("local audio play"),_superPropGet$2(t,"play",this)([])}}])}(LocalTrack),CameraVideoTrack=function(e){function t(e,r){var n;return _classCallCheck$1(this,t),(n=_callSuper$j(this,t,[e,r.deviceId,r])).setSource(exports.VideoSourceInfo.CAMERA),n}return _inherits$1(t,e),_createClass$1(t)}(LocalVideoTrack),MicrophoneAudioTrack=function(e){function t(e,r){var n;return _classCallCheck$1(this,t),(n=_callSuper$j(this,t,[e,(r||{}).deviceId])).config=r,n.setSource(exports.AudioSourceInfo.MIC),n.analyser=n.audioContext.createAnalyser(),n}return _inherits$1(t,e),_createClass$1(t,[{key:"setVolume",value:function(e){simpleLogger$2.info("setVolume",e),this.isClosed||this.element&&(this.element.volume=e)}},{key:"getVolume",value:function(){if(simpleLogger$2.info("getVolume"),!this.isClosed)return this.element?this.element.volume:void 0}}])}(LocalAudioTrack),createMicrophoneAudioTrack=function(){var e=_asyncToGenerator$1(_regeneratorRuntime$1.mark((function e(t){var r,n,i,o,a,s,c,u,l;return _regeneratorRuntime$1.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r={AEC:!0,AGC:!0,ANS:!0},o=void 0===(i=(n=t||r).AEC)||i,s=void 0===(a=n.AGC)||a,u=void 0===(c=n.ANS)||c,e.prev=2,e.next=5,createMediaStream({video:!1,audio:{deviceId:null==t?void 0:t.deviceId,source:exports.AudioSourceInfo.MIC,AEC:o,AGC:s,ANS:u}});case 5:return l=e.sent.getAudioTracks()[0],simpleLogger$2.info("MicrophoneAudioTrack created"),e.abrupt("return",new MicrophoneAudioTrack(l,Object.assign({},t,{AEC:o,AGC:s,ANS:u})));case 11:throw e.prev=11,e.t0=e.catch(2),parseAudioDeviceError(e.t0);case 14:case"end":return e.stop()}}),e,null,[[2,11]])})));return function(t){return e.apply(this,arguments)}}(),createCameraVideoTrack=function(){var e=_asyncToGenerator$1(_regeneratorRuntime$1.mark((function e(t){var r,n,i,o,a,s,c,u;return _regeneratorRuntime$1.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.deviceId,n=t.facingMode,o=void 0===(i=t.dimension)?"VD_640x480":i,s=void 0===(a=t.optimizationMode)?"balanced":a,c=Math.min(30,t.frameRate||15),e.prev=2,e.next=5,createMediaStream({video:{deviceId:r,source:exports.VideoSourceInfo.CAMERA,frameRate:c,dimension:o,facingMode:n},audio:!1});case 5:return u=e.sent.getVideoTracks()[0],simpleLogger$2.info("CameraVideoTrack created"),e.abrupt("return",new CameraVideoTrack(u,Object.assign({},t,{frameRate:c,dimension:o,optimizationMode:s})));case 11:throw e.prev=11,e.t0=e.catch(2),parseVideoDeviceError(e.t0);case 14:case"end":return e.stop()}}),e,null,[[2,11]])})));return function(t){return e.apply(this,arguments)}}(),createScreenVideoTrack=function(){var e=_asyncToGenerator$1(_regeneratorRuntime$1.mark((function e(t){var r,n,i,o,a,s,c,u;return _regeneratorRuntime$1.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=void 0===(r=t.displaySurface)?"monitor":r,o=void 0===(i=t.dimension)?"VD_1920x1080":i,s=void 0===(a=t.optimizationMode)?"detail":a,c=Math.min(t.frameRate||5,30),e.prev=2,e.next=5,createMediaStream({video:{source:exports.VideoSourceInfo.SCREENCAST,displaySurface:n,frameRate:c,dimension:o},audio:!1});case 5:return(u=new LocalVideoTrack(e.sent.getVideoTracks()[0],null,Object.assign({},t,{frameRate:c,dimension:o,optimizationMode:s}))).setSource(exports.VideoSourceInfo.SCREENCAST),simpleLogger$2.info("ScreenVideoTrack created"),e.abrupt("return",[u]);case 12:throw e.prev=12,e.t0=e.catch(2),parseScreenShareError(e.t0);case 15:case"end":return e.stop()}}),e,null,[[2,12]])})));return function(t){return e.apply(this,arguments)}}(),createMicrophoneAndCameraTracks=function(){var e=_asyncToGenerator$1(_regeneratorRuntime$1.mark((function e(t,r){var n,i,o,a,s,c,u,l,d,p,f,h,m,g,y,v,_,b,E,S;return _regeneratorRuntime$1.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Math.min(t.frameRate||15,30),i=t.deviceId,o=t.facingMode,s=void 0===(a=t.dimension)?"VD_640x480":a,u=void 0===(c=t.optimizationMode)?"balanced":c,l={AEC:!0,AGC:!0,ANS:!0},f=void 0===(p=(d=r||l).AEC)||p,m=void 0===(h=d.AGC)||h,y=void 0===(g=d.ANS)||g,e.prev=4,e.next=7,createMediaStream({video:{deviceId:i,source:exports.VideoSourceInfo.CAMERA,frameRate:n,dimension:s,facingMode:o},audio:{deviceId:null==r?void 0:r.deviceId,source:exports.AudioSourceInfo.MIC,AEC:f,AGC:m,ANS:y}});case 7:return _=(v=e.sent).getVideoTracks()[0],b=v.getAudioTracks()[0],simpleLogger$2.info("CameraVideoTrack and MicrophoneTrack created"),E=new CameraVideoTrack(_,Object.assign({},t,{frameRate:n,dimension:s,optimizationMode:u})),S=new MicrophoneAudioTrack(b,Object.assign({},Object.assign({},r,{AEC:f,AGC:m,ANS:y}))),e.abrupt("return",[E,S]);case 16:throw e.prev=16,e.t0=e.catch(4),parseVideoDeviceError(e.t0);case 19:case"end":return e.stop()}}),e,null,[[4,16]])})));return function(t,r){return e.apply(this,arguments)}}(),createCustomVideoTrack=function(){var e=_asyncToGenerator$1(_regeneratorRuntime$1.mark((function e(t){var r,n,i,o,a,s,c,u;return _regeneratorRuntime$1.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=(r=t||{}).mediaStreamTrack,o=void 0===(i=r.dimension)?"VD_640x480":i,s=void 0===(a=r.optimizationMode)?"balanced":a,c=Math.min(t.frameRate||15,30),n instanceof MediaStreamTrack&&"video"===n.kind){e.next=4;break}throw new DingRTCError(ErrorCode.InvaildArgument,"missing video mediaStreamTrack");case 4:return(u=new LocalVideoTrack(n,null,Object.assign({},t,{frameRate:c,dimension:o,optimizationMode:s}))).setSource(exports.VideoSourceInfo.CAMERA),e.abrupt("return",u);case 7:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),createCustomAudioTrack=function(){var e=_asyncToGenerator$1(_regeneratorRuntime$1.mark((function e(t){var r,n;return _regeneratorRuntime$1.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if((r=(t||{}).mediaStreamTrack)instanceof MediaStreamTrack&&"audio"===r.kind){e.next=3;break}throw new DingRTCError(ErrorCode.InvaildArgument,"missing audio mediaStreamTrack");case 3:return(n=new LocalAudioTrack(r)).setSource(exports.AudioSourceInfo.MIC),e.abrupt("return",n);case 6:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();function _superPropGet$1(e,t,r,n){var i=_get(_getPrototypeOf$1(1&n?e.prototype:e),t,r);return 2&n&&"function"==typeof i?function(e){return i.apply(r,e)}:i}function _callSuper$i(e,t,r){return t=_getPrototypeOf$1(t),_possibleConstructorReturn$1(e,_isNativeReflectConstruct$i()?Reflect.construct(t,r||[],_getPrototypeOf$1(e).constructor):t.apply(e,r))}function _isNativeReflectConstruct$i(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(_isNativeReflectConstruct$i=function(){return!!e})()}var _getReporter$1=getReporter(),simpleLogger$1=_getReporter$1.log,RemoteTrack=function(e){function t(e,r,n){var i;return _classCallCheck$1(this,t),i=_callSuper$i(this,t,[e,n]),Object.defineProperty(i,"userId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(i,"subscription",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),i.userId=r,i}return _inherits$1(t,e),_createClass$1(t,[{key:"getUserId",value:function(){return simpleLogger$1.info("getUserId"),this.userId}},{key:"onFirstFrame",value:function(){this.emit("first-frame-decoded")}},{key:"attachSubscription",value:function(e){this.subscription&&this.subscription.off("audio-first-frame",this.onFirstFrame),this.subscription=e,null==e||e.on("audio-first-frame",this.onFirstFrame)}}])}(Track),RemoteAudioTrack=function(e){function t(e,r,n){var i;return _classCallCheck$1(this,t),i=_callSuper$i(this,t,[e,r,n]),Object.defineProperty(i,"deviceId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),i.deviceId="",i}return _inherits$1(t,e),_createClass$1(t,[{key:"getMediaStreamTrack",value:function(){return clientConfig.audioSFU?mergeAudioTracks(this.sfuStream):_superPropGet$1(t,"getMediaStreamTrack",this,3)([])}},{key:"replaceStream",value:function(e,t){simpleLogger$1.info("replaceRemote Audio",e,t),t&&this.isPlaying&&this.stop(),this.replaceTrackInner(null,e)}},{key:"setVolume",value:function(e){simpleLogger$1.info("setVolume",e),this.element&&(this.element.volume=e)}},{key:"getVolume",value:function(){if(simpleLogger$1.info("getVolume"),this.element)return this.element.volume}},{key:"setSpeaker",value:function(e){var t=this;return simpleLogger$1.info("setSpeaker",e),new Promise((function(r,n){var i,o=t.element;o||n(new DingRTCError(ErrorCode.InvaildState,"please playout audio first")),o.setSinkId||n(new DingRTCError(ErrorCode.SpeakerSetNotSupported)),null===(i=o.setSinkId)||void 0===i||i.call(o,e).then((function(){t.deviceId=e,r()})).catch((function(e){n(parseAudioDeviceError(e))}))}))}},{key:"getVolumeLevel",value:function(){return getAudioVolumeLevel(this.audioContext,this.analyser,this.sourceNode)}},{key:"play",value:function(){return simpleLogger$1.info("remote audio play"),_superPropGet$1(t,"innnerPlay",this,3)([])}}])}(RemoteTrack),RemoteVideoTrack=function(e){function t(e,r){return _classCallCheck$1(this,t),_callSuper$i(this,t,[e,r])}return _inherits$1(t,e),_createClass$1(t,[{key:"play",value:function(e,r){return simpleLogger$1.info("remote video play"),_superPropGet$1(t,"innnerPlay",this,3)([e,r])}},{key:"setSourceMirror",value:function(e){e!==this.sourceMirror&&(simpleLogger$1.info("remote video track set Mirror",e),this.sourceMirror=e,this.isPlaying&&_superPropGet$1(t,"innnerPlay",this,3)([]))}},{key:"setMediaElement",value:function(e){var r,n=this;_superPropGet$1(t,"setMediaElement",this,3)([e]),null===(r=this.element)||void 0===r||r.addEventListener("loadeddata",(function(){n.emit("first-frame-decoded")}))}},{key:"getCurrentFrameData",value:function(){return simpleLogger$1.info("getCurrentFrameData"),this.isPlaying?getCurrentFrame(this.element):null}}])}(RemoteTrack),signal_msg;!function(e){var t,r,n,i,o,a,s,c;(t=e.DataType||(e.DataType={}))[t.DATA_TYPE_STREAM=0]="DATA_TYPE_STREAM",t[t.DATA_TYPE_PARTICIPANTS=1]="DATA_TYPE_PARTICIPANTS",t[t.DATA_TYPE_CONFERENCE=2]="DATA_TYPE_CONFERENCE",t[t.DATA_TYPE_GROUP_LIST=3]="DATA_TYPE_GROUP_LIST",t[t.DATA_TYPE_GROUP=4]="DATA_TYPE_GROUP",(r=e.OptType||(e.OptType={}))[r.OPT_TYPE_ADD=0]="OPT_TYPE_ADD",r[r.OPT_TYPE_REMOVE=1]="OPT_TYPE_REMOVE",r[r.OPT_TYPE_UPDATE=2]="OPT_TYPE_UPDATE",(n=e.SyncResponseCode||(e.SyncResponseCode={}))[n.SYNC_OK=0]="SYNC_OK",n[n.SYNC_PART_SUC=10]="SYNC_PART_SUC",n[n.SYNC_DATA_SIZE_LIMITED=11]="SYNC_DATA_SIZE_LIMITED",n[n.SYNC_NOT_SUPPORT_TYPE=12]="SYNC_NOT_SUPPORT_TYPE",n[n.SYNC_NOT_FOUND=13]="SYNC_NOT_FOUND",n[n.SYNC_CHANNEL_NOT_EXIST=14]="SYNC_CHANNEL_NOT_EXIST",n[n.SYNC_INTERNAL_ERROR=15]="SYNC_INTERNAL_ERROR",(i=e.GroupUpdate||(e.GroupUpdate={}))[i.GROUP_UPDATE_AUDIO_STREAM_LOST=0]="GROUP_UPDATE_AUDIO_STREAM_LOST",i[i.GROUP_UPDATE_AUDIO_STREAM_RECOVER=1]="GROUP_UPDATE_AUDIO_STREAM_RECOVER",i[i.GROUP_UPDATE_ADD_PARTICIPANTS=2]="GROUP_UPDATE_ADD_PARTICIPANTS",i[i.GROUP_UPDATE_REMOVE_PARTICIPANTS=3]="GROUP_UPDATE_REMOVE_PARTICIPANTS",i[i.GROUP_UPDATE_SET_PROPERTIES=4]="GROUP_UPDATE_SET_PROPERTIES",i[i.GROUP_UPDATE_REMOVE_PROPERTIES=5]="GROUP_UPDATE_REMOVE_PROPERTIES",(o=e.GroupListUpdate||(e.GroupListUpdate={}))[o.GROUP_LIST_UPDATE_ADD_ID=0]="GROUP_LIST_UPDATE_ADD_ID",o[o.GROUP_LIST_UPDATE_REMOVE_ID=1]="GROUP_LIST_UPDATE_REMOVE_ID",(a=e.LEAVE_GROUP_REASON_CODE||(e.LEAVE_GROUP_REASON_CODE={}))[a.NORMAL_LEAVE=0]="NORMAL_LEAVE",(s=e.DismissGroupReasonCode||(e.DismissGroupReasonCode={}))[s.NORMAL_DISMISS=0]="NORMAL_DISMISS",(c=e.Result||(e.Result={}))[c.Ok=0]="Ok",c[c.Error=1]="Error"}(signal_msg||(signal_msg={}));var nested={signal_msg:{nested:{AudioSsrcSpec:{fields:{ssrc:{type:"uint32",id:1},rtxSsrc:{type:"uint32",id:2}}},VideoSsrcSpec:{fields:{ssrc:{type:"uint32",id:1},rtxSsrc:{type:"uint32",id:2},fecSsrc:{type:"uint32",id:3}}},MultiPcAdaptRequestInfo:{fields:{audioSsrcSpec:{rule:"repeated",type:"AudioSsrcSpec",id:1},videoSsrcSpec:{rule:"repeated",type:"VideoSsrcSpec",id:2}}},AudioStreamFormat:{fields:{codec:{type:"string",id:1},sampleRate:{type:"int64",id:2},channelNum:{type:"int64",id:3}}},AudioFormatPreference:{fields:{preferred:{type:"AudioStreamFormat",id:1},optional:{rule:"repeated",type:"AudioStreamFormat",id:2}}},AudioStreamOptional:{fields:{format:{rule:"repeated",type:"AudioStreamFormat",id:1}}},VideoStreamFormat:{fields:{codec:{type:"string",id:1},profile:{type:"string",id:2}}},VideoFormatPreference:{fields:{preferred:{type:"VideoStreamFormat",id:1},optional:{rule:"repeated",type:"VideoStreamFormat",id:2}}},FormatPreference:{fields:{audio:{type:"AudioFormatPreference",id:1},video:{type:"VideoFormatPreference",id:2}}},Resolution:{fields:{width:{type:"uint32",id:1},height:{type:"uint32",id:2}}},VideoSsrcParameters:{fields:{ssrc:{type:"uint32",id:1},framerate:{type:"int32",id:2},resolution:{type:"Resolution",id:3},maxBitrate:{type:"int32",id:4},minBitrate:{type:"int32",id:5},active:{type:"bool",id:6},bitrate:{type:"int64",id:7},tlayer:{type:"int64",id:8},multiSlice:{type:"int64",id:9},keyFrameInterval:{type:"int64",id:10},constantPpsid:{type:"int64",id:11},rid:{type:"string",id:12}}},VideoParameters:{oneofs:{_resolutionLevel:{oneof:["resolutionLevel"]}},fields:{ssrc:{type:"uint32",id:1},resolution:{type:"Resolution",id:2},framerate:{type:"int32",id:3},bitrate:{type:"string",id:4},multiSlice:{type:"int32",id:5},keyFrameInterval:{type:"int64",id:6},constantPpsid:{type:"int64",id:7},resolutionLevel:{type:"uint32",id:8,options:{proto3_optional:!0}}}},GroupVersion:{fields:{id:{type:"string",id:1},ver:{type:"int64",id:2}}},StreamInfo:{fields:{type:{type:"string",id:1},owner:{type:"string",id:2},attributesJsonStr:{type:"string",id:3},label:{type:"string",id:4},createTime:{type:"int64",id:7}}},StreamVideoParameters:{fields:{resolution:{type:"Resolution",id:1},framerate:{type:"int64",id:2},bitrate:{type:"int64",id:3},keyFrameInterval:{type:"int64",id:4},multiSlice:{type:"int64",id:5},constantPpsid:{type:"int64",id:6}}},VideoStreamPara:{fields:{specs:{rule:"repeated",type:"string",id:1},resolution:{rule:"repeated",type:"Resolution",id:2},framerate:{rule:"repeated",type:"int32",id:3},bitrate:{rule:"repeated",type:"string",id:4},keyFrameInterval:{rule:"repeated",type:"int32",id:5}}},VideoStreamOptional:{fields:{format:{rule:"repeated",type:"VideoStreamFormat",id:1},parameters:{type:"VideoStreamPara",id:2}}},StreamAudioDesc:{fields:{trackId:{type:"string",id:1},msid:{type:"string",id:2},status:{type:"string",id:3},format:{type:"AudioStreamFormat",id:4},source:{type:"string",id:5},ssrc:{rule:"repeated",type:"uint32",id:6},ssrcGroup:{rule:"repeated",type:"AudioSsrcSpec",id:7},optional:{type:"AudioStreamOptional",id:8}}},StreamVideoDesc:{fields:{trackId:{type:"string",id:1},msid:{type:"string",id:2},status:{type:"string",id:3},source:{type:"string",id:4},format:{type:"VideoStreamFormat",id:5},ssrc:{rule:"repeated",type:"uint32",id:6},ssrcGroup:{rule:"repeated",type:"VideoSsrcSpec",id:7},parameters:{type:"StreamVideoParameters",id:8},optional:{type:"VideoStreamOptional",id:9}}},StreamMediaDesc:{fields:{audio:{type:"StreamAudioDesc",id:1},video:{type:"StreamVideoDesc",id:2}}},Stream:{fields:{id:{type:"string",id:1},type:{type:"string",id:2},media:{type:"StreamMediaDesc",id:3},info:{type:"StreamInfo",id:4},version:{type:"int64",id:5}}},OriginMsg:{fields:{type:{type:"string",id:1},id:{type:"string",id:2}}},ErrorMsg:{fields:{id:{type:"string",id:1},code:{type:"int32",id:2},msg:{type:"string",id:3},origin:{type:"OriginMsg",id:4}}},ErrorMsgs:{fields:{globalStatus:{type:"string",id:1},detailStatus:{rule:"repeated",type:"ErrorMsg",id:2}}},DataType:{values:{DATA_TYPE_STREAM:0,DATA_TYPE_PARTICIPANTS:1,DATA_TYPE_CONFERENCE:2,DATA_TYPE_GROUP_LIST:3,DATA_TYPE_GROUP:4}},OptType:{values:{OPT_TYPE_ADD:0,OPT_TYPE_REMOVE:1,OPT_TYPE_UPDATE:2}},SyncResponseCode:{values:{SYNC_OK:0,SYNC_PART_SUC:10,SYNC_DATA_SIZE_LIMITED:11,SYNC_NOT_SUPPORT_TYPE:12,SYNC_NOT_FOUND:13,SYNC_CHANNEL_NOT_EXIST:14,SYNC_INTERNAL_ERROR:15}},GroupParticipant:{fields:{uid:{type:"string",id:1},pid:{type:"string",id:2},userData:{type:"string",id:3}}},GroupAudioInfo:{fields:{label:{type:"string",id:1},audio:{type:"Stream",id:2}}},GroupInfo:{fields:{id:{type:"string",id:1},ver:{type:"int64",id:2},participants:{rule:"repeated",type:"GroupParticipant",id:3},audioInfo:{type:"GroupAudioInfo",id:4},properties:{rule:"repeated",type:"GroupProperty",id:5}}},GroupProperty:{fields:{key:{type:"string",id:1},value:{type:"string",id:2}}},SyncFullData:{oneofs:{_ver:{oneof:["ver"]},_totalPages:{oneof:["totalPages"]},_pagingSeq:{oneof:["pagingSeq"]}},fields:{ver:{type:"int64",id:1,options:{proto3_optional:!0}},totalPages:{type:"int32",id:2,options:{proto3_optional:!0}},pagingSeq:{type:"int64",id:3,options:{proto3_optional:!0}},groupData:{type:"GroupPagingData",id:10},groupListData:{type:"GroupListPagingData",id:11}}},GroupPagingData:{fields:{pagingSeq:{type:"int64",id:1},curPage:{type:"int32",id:2},groupInfos:{rule:"repeated",type:"GroupInfo",id:3}}},GroupListPagingData:{fields:{pagingSeq:{type:"int64",id:1},curPage:{type:"int32",id:2},groupIds:{rule:"repeated",type:"string",id:3}}},SyncChangeLog:{fields:{groupListChangeLogs:{rule:"repeated",type:"GroupListChangeLog",id:1},groupChangeLogs:{rule:"repeated",type:"GroupChangeLog",id:2}}},SyncDataRequest:{oneofs:{_id:{oneof:["id"]}},fields:{type:{type:"DataType",id:1},id:{type:"string",id:2,options:{proto3_optional:!0}},ver:{type:"int64",id:3},forceFullSync:{type:"bool",id:4},supportPagingSync:{type:"bool",id:5}}},SyncDataResponse:{fields:{code:{type:"SyncResponseCode",id:1},errMsg:{type:"string",id:2},fullSync:{type:"SyncFullData",id:3},changeLogs:{rule:"repeated",type:"SyncChangeLog",id:4}}},SyncIds:{fields:{id:{type:"string",id:1},ver:{type:"int64",id:2}}},SyncDataByIdsRequest:{fields:{type:{type:"DataType",id:1},ids:{rule:"repeated",type:"SyncIds",id:2},forceFullSync:{type:"bool",id:3},supportPagingSync:{type:"bool",id:4}}},SyncDataByIdsResponse:{fields:{code:{type:"SyncResponseCode",id:1},errMsg:{type:"string",id:2},notFoundIds:{rule:"repeated",type:"string",id:3},fullSync:{type:"SyncFullData",id:4},changeLogs:{rule:"repeated",type:"SyncChangeLog",id:5}}},GroupUpdate:{values:{GROUP_UPDATE_AUDIO_STREAM_LOST:0,GROUP_UPDATE_AUDIO_STREAM_RECOVER:1,GROUP_UPDATE_ADD_PARTICIPANTS:2,GROUP_UPDATE_REMOVE_PARTICIPANTS:3,GROUP_UPDATE_SET_PROPERTIES:4,GROUP_UPDATE_REMOVE_PROPERTIES:5}},GroupUpdateOpt:{fields:{updateAction:{type:"GroupUpdate",id:1},participants:{rule:"repeated",type:"GroupParticipant",id:2},properties:{rule:"repeated",type:"GroupProperty",id:3}}},GroupChangeLog:{oneofs:{_groupInfo:{oneof:["groupInfo"]},_updateOpt:{oneof:["updateOpt"]},_msgId:{oneof:["msgId"]}},fields:{ver:{type:"int64",id:1},type:{type:"OptType",id:2},id:{type:"string",id:3},groupInfo:{type:"GroupInfo",id:4,options:{proto3_optional:!0}},updateOpt:{type:"GroupUpdateOpt",id:5,options:{proto3_optional:!0}},msgId:{type:"string",id:6,options:{proto3_optional:!0}}}},GroupListUpdate:{values:{GROUP_LIST_UPDATE_ADD_ID:0,GROUP_LIST_UPDATE_REMOVE_ID:1}},GroupListUpdateOpt:{fields:{updateAction:{type:"GroupListUpdate",id:1},id:{type:"string",id:2}}},GroupListChangeLog:{oneofs:{_msgId:{oneof:["msgId"]}},fields:{ver:{type:"int64",id:1},type:{type:"OptType",id:2},updateOpt:{type:"GroupListUpdateOpt",id:3},msgId:{type:"string",id:4,options:{proto3_optional:!0}}}},JoinGroupRequest:{fields:{groupId:{type:"string",id:1},userData:{type:"string",id:2},autoJoinGroupAudio:{type:"bool",id:3},autoLeaveChannelAudio:{type:"bool",id:4}}},JoinGroupResponse:{oneofs:{_joinGroupAudioSuccess:{oneof:["joinGroupAudioSuccess"]}},fields:{code:{type:"int32",id:1},errMsg:{type:"string",id:2},group:{type:"GroupInfo",id:3},joinGroupAudioSuccess:{type:"bool",id:4,options:{proto3_optional:!0}}}},LEAVE_GROUP_REASON_CODE:{values:{NORMAL_LEAVE:0}},LeaveGroupRequest:{fields:{groupId:{type:"string",id:1},reasonCode:{type:"LEAVE_GROUP_REASON_CODE",id:2},autoJoinChannelAudio:{type:"bool",id:3}}},LeaveGroupResponse:{oneofs:{_joinChannelAudioSuccess:{oneof:["joinChannelAudioSuccess"]}},fields:{code:{type:"int32",id:1},errMsg:{type:"string",id:2},joinChannelAudioSuccess:{type:"bool",id:3,options:{proto3_optional:!0}}}},DismissGroupReasonCode:{values:{NORMAL_DISMISS:0}},DismissGroupRequest:{fields:{groupId:{type:"string",id:1},reasonCode:{type:"DismissGroupReasonCode",id:2}}},DismissGroupResponse:{fields:{code:{type:"int32",id:1},errMsg:{type:"string",id:2}}},ObserveAllGroupsRequest:{fields:{}},ObserveAllGroupsResponse:{fields:{code:{type:"int32",id:1},errMsg:{type:"string",id:2}}},UnobserveAllGroupsRequest:{fields:{}},UnobserveAllGroupsResponse:{fields:{code:{type:"int32",id:1},errMsg:{type:"string",id:2}}},SetGroupPropertiesRequest:{fields:{groupId:{type:"string",id:1},properties:{rule:"repeated",type:"GroupProperty",id:2}}},SetGroupPropertiesResponse:{fields:{code:{type:"int32",id:1},errMsg:{type:"string",id:2}}},RemoveGroupPropertiesRequest:{fields:{groupId:{type:"string",id:1},keys:{rule:"repeated",type:"string",id:2}}},RemoveGroupPropertiesResponse:{fields:{code:{type:"int32",id:1},errMsg:{type:"string",id:2}}},SetParticipantPropertiesRequest:{fields:{roomId:{type:"string",id:1},participantId:{type:"string",id:2},propertiesJsonStr:{type:"string",id:3},tid:{type:"string",id:4},traceId:{type:"string",id:5}}},RemoveParticipantPropertiesRequest:{fields:{roomId:{type:"string",id:1},participantId:{type:"string",id:2},propertiesJsonStr:{type:"string",id:3},tid:{type:"string",id:4},traceId:{type:"string",id:5}}},Result:{values:{Ok:0,Error:1}},Response:{oneofs:{data:{oneof:["reason","createPeerConnectionResponse","errorMsg","queryStreamsVerResponse","queryStreamsResponse","publishResponse","subscribeResponse","joinGroupResponse","leaveGroupResponse","dismissGroupResponse","observeAllGroupsResponse","unobserveAllGroupsResponse","syncDataResponse","syncDataByIdsResponse","setGroupPropertiesResponse","removeGroupPropertiesResponse"]}},fields:{result:{type:"Result",id:1},tid:{type:"string",id:2},traceId:{type:"string",id:3},code:{type:"int32",id:4},reason:{type:"string",id:11},createPeerConnectionResponse:{type:"CreatePeerConnectionResponse",id:15},errorMsg:{type:"ErrorMsgs",id:16},queryStreamsVerResponse:{type:"QueryStreamsVerResponse",id:17},queryStreamsResponse:{type:"QueryStreamsResponse",id:18},publishResponse:{type:"PublishResponse",id:21},subscribeResponse:{type:"SubscribeResponse",id:22},joinGroupResponse:{type:"JoinGroupResponse",id:24},leaveGroupResponse:{type:"LeaveGroupResponse",id:25},dismissGroupResponse:{type:"DismissGroupResponse",id:26},observeAllGroupsResponse:{type:"ObserveAllGroupsResponse",id:27},unobserveAllGroupsResponse:{type:"UnobserveAllGroupsResponse",id:28},syncDataResponse:{type:"SyncDataResponse",id:29},syncDataByIdsResponse:{type:"SyncDataByIdsResponse",id:30},setGroupPropertiesResponse:{type:"SetGroupPropertiesResponse",id:31},removeGroupPropertiesResponse:{type:"RemoveGroupPropertiesResponse",id:32}}},NotificationItem:{oneofs:{notification:{oneof:["streamNotification","serverFailoverNotification","progressNotification","groupNotification","groupListNotification"]}},fields:{event:{type:"string",id:1},streamNotification:{type:"StreamNotification",id:11},serverFailoverNotification:{type:"ServerFailoverNotification",id:13},progressNotification:{type:"ProgressNotification",id:14},groupNotification:{type:"GroupChangeLog",id:17},groupListNotification:{type:"GroupListChangeLog",id:18}}},BatchNotification:{fields:{notificationItem:{rule:"repeated",type:"NotificationItem",id:1},tid:{type:"string",id:2},traceId:{type:"string",id:3}}},MediaMessage:{fields:{payload:{type:"string",id:1}}},AudioStreamTrackDesc:{fields:{streamId:{type:"string",id:1},trackId:{type:"string",id:2},msid:{type:"string",id:3},source:{type:"string",id:4},uplinkSsrcGroup:{rule:"repeated",type:"AudioSsrcSpec",id:5},format:{type:"AudioStreamFormat",id:6},autoMix:{rule:"repeated",type:"string",id:7},attributesJsonString:{type:"string",id:8}}},VideoStreamTrackDesc:{fields:{streamId:{type:"string",id:1},trackId:{type:"string",id:2},msid:{type:"string",id:3},source:{type:"string",id:4},logicSsrc:{rule:"repeated",type:"uint32",id:5},uplinkSsrcGroup:{rule:"repeated",type:"VideoSsrcSpec",id:6},ssrcParameters:{rule:"repeated",type:"VideoSsrcParameters",id:7},streamParameters:{type:"VideoParameters",id:8},attributesJsonString:{type:"string",id:9},forwardOnly:{type:"bool",id:10},mid:{type:"string",id:11}}},MediaStreamTrackDesc:{fields:{audio:{rule:"repeated",type:"AudioStreamTrackDesc",id:1},video:{rule:"repeated",type:"VideoStreamTrackDesc",id:2}}},StreamVersion:{fields:{streamId:{type:"string",id:1},streamVer:{type:"int64",id:2}}},StreamData:{fields:{id:{type:"string",id:1},stream:{type:"Stream",id:2}}},AudioPubOptions:{fields:{source:{type:"string",id:1},format:{type:"AudioStreamFormat",id:2},autoMix:{rule:"repeated",type:"string",id:3}}},VideoPubOptions:{fields:{source:{type:"string",id:1},format:{type:"VideoStreamFormat",id:2},parameters:{type:"VideoParameters",id:3},forwardOnly:{type:"bool",id:4}}},MediaPubOptionsSpecify:{fields:{audio:{type:"AudioPubOptions",id:1},video:{type:"VideoPubOptions",id:2}}},BatchPublishRequest:{fields:{roomId:{type:"string",id:1},participantId:{type:"string",id:2},connectionId:{type:"string",id:3},type:{type:"string",id:4},simulcast:{type:"bool",id:5},simulcastVersion:{type:"string",id:6},supportTemporalLayer:{type:"bool",id:7},clientType:{type:"string",id:8},clientVersion:{type:"string",id:9},media:{type:"MediaStreamTrackDesc",id:10},event:{type:"string",id:11},tid:{type:"string",id:12},traceId:{type:"string",id:13}}},BatchUnpublishRequest:{fields:{roomId:{type:"string",id:1},participantId:{type:"string",id:2},connectionId:{type:"string",id:3},audio:{rule:"repeated",type:"string",id:4},video:{rule:"repeated",type:"string",id:5},tid:{type:"string",id:6},traceId:{type:"string",id:7}}},QueryStreamsVerRequest:{fields:{roomId:{type:"string",id:1},participantId:{type:"string",id:2},streamIds:{rule:"repeated",type:"string",id:3},tid:{type:"string",id:4},traceId:{type:"string",id:5}}},QueryStreamsVerResponse:{fields:{streamVersions:{rule:"repeated",type:"StreamVersion",id:1},totalVer:{type:"int32",id:2},msg:{type:"string",id:3}}},StreamControlRequest:{fields:{roomId:{type:"string",id:1},participantId:{type:"string",id:2},streamId:{type:"string",id:3},operation:{type:"string",id:4},data:{type:"string",id:5},tid:{type:"string",id:6},traceId:{type:"string",id:7}}},QueryStreamsRequest:{fields:{roomId:{type:"string",id:1},participantId:{type:"string",id:2},streamIds:{rule:"repeated",type:"string",id:3},tid:{type:"string",id:4},traceId:{type:"string",id:5}}},QueryStreamsResponse:{fields:{totalVer:{type:"int64",id:1},msg:{type:"string",id:2},streams:{rule:"repeated",type:"StreamData",id:3}}},SetStreamPropertiesRequest:{fields:{roomId:{type:"string",id:1},streamId:{type:"string",id:2},propertiesJsonStr:{type:"string",id:3},tid:{type:"string",id:4},traceId:{type:"string",id:5}}},PublishRequest:{fields:{roomId:{type:"string",id:1},participantId:{type:"string",id:2},type:{type:"string",id:3},event:{type:"string",id:4},media:{type:"MediaPubOptionsSpecify",id:5},attributesJsonStr:{type:"string",id:6},tid:{type:"string",id:7},traceId:{type:"string",id:8}}},PublishResponse:{fields:{id:{type:"string",id:1}}},UnpublishRequest:{fields:{roomId:{type:"string",id:1},participantId:{type:"string",id:2},streamId:{type:"string",id:3},tid:{type:"string",id:4},traceId:{type:"string",id:5}}},NetworkHealth:{fields:{receiving:{type:"bool",id:1},lossRate:{type:"int32",id:2},timestamp:{type:"int64",id:3},cutoff:{type:"bool",id:4},tid:{type:"string",id:5}}},StreamMsg:{oneofs:{value:{oneof:["networkHealth","streamStatus","stream","activeStream","propertiesJsonStr"]}},fields:{field:{type:"string",id:1},streamVer:{type:"int64",id:2},expiredMs:{type:"int64",id:3},extraValue:{rule:"repeated",type:"string",id:4},tid:{type:"string",id:5},networkHealth:{type:"NetworkHealth",id:10},streamStatus:{type:"string",id:11},stream:{type:"Stream",id:12},activeStream:{type:"string",id:13},propertiesJsonStr:{type:"string",id:14}}},StreamNotification:{oneofs:{data:{oneof:["stream","msg"]}},fields:{streamId:{type:"string",id:1},status:{type:"string",id:2},totalVer:{type:"int64",id:3},msgId:{type:"string",id:4},ts:{type:"int64",id:5},tid:{type:"string",id:6},traceId:{type:"string",id:7},stream:{type:"Stream",id:10},msg:{type:"StreamMsg",id:11}}},Candidate:{fields:{candidate:{type:"string",id:1},sdpMlineIndex:{type:"int32",id:2},sdpMid:{type:"string",id:3}}},SessionSignaling:{fields:{type:{type:"string",id:1},sdp:{type:"string",id:2},candidate:{type:"Candidate",id:3},optionsJsonStr:{type:"string",id:4}}},SignalingData:{fields:{type:{type:"string",id:1},sdp:{type:"string",id:2}}},CreatePeerConnectionRequest:{fields:{roomId:{type:"string",id:1},participantId:{type:"string",id:2},connectionId:{type:"string",id:3},tid:{type:"string",id:4},event:{type:"string",id:5},direction:{type:"string",id:6},sdpOffer:{type:"string",id:7},type:{type:"string",id:8},isOca:{type:"bool",id:9},isFailover:{type:"bool",id:10},multiPcAdaptInfo:{type:"MultiPcAdaptRequestInfo",id:11},pcFormatPreference:{type:"FormatPreference",id:12},optionsJsonStr:{type:"string",id:13},traceId:{type:"string",id:14},sfuSsrcGroup:{rule:"repeated",type:"AudioSsrcSpec",id:15}}},CreatePeerConnectionResponse:{fields:{connectionId:{type:"string",id:1},sdpAnswer:{type:"string",id:2}}},ClosePeerConnectionRequest:{fields:{roomId:{type:"string",id:1},participantId:{type:"string",id:2},connectionId:{type:"string",id:3},direction:{type:"string",id:4},tid:{type:"string",id:5},traceId:{type:"string",id:6}}},SoacRequest:{fields:{id:{type:"string",id:1},signaling:{type:"SessionSignaling",id:2},tid:{type:"string",id:3},traceId:{type:"string",id:4}}},NotifyAction:{fields:{actionName:{type:"string",id:1},connectionId:{type:"string",id:2},traceId:{type:"string",id:3}}},ServerFailoverNotification:{fields:{actions:{rule:"repeated",type:"NotifyAction",id:1},msgId:{type:"string",id:2},tid:{type:"string",id:3},traceId:{type:"string",id:4}}},ProgressNotification:{fields:{id:{type:"string",id:1},status:{type:"string",id:2},data:{type:"SignalingData",id:3},msgId:{type:"string",id:4},tid:{type:"string",id:5},traceId:{type:"string",id:6}}},AudioBatchSubOptions:{fields:{subscriptionId:{type:"string",id:1},from:{type:"string",id:2},trackId:{type:"string",id:3},ssrcGroup:{rule:"repeated",type:"AudioSsrcSpec",id:4},format:{type:"AudioStreamFormat",id:5}}},VideoBatchSubOptions:{fields:{subscriptionId:{type:"string",id:1},from:{type:"string",id:2},trackId:{type:"string",id:3},ssrcGroup:{rule:"repeated",type:"VideoSsrcSpec",id:4},parameters:{type:"VideoParameters",id:5},format:{type:"VideoStreamFormat",id:6},subSsrcGroup:{type:"VideoSsrcSpec",id:7}}},MediaBatchSubOptions:{fields:{audio:{rule:"repeated",type:"AudioBatchSubOptions",id:1},video:{rule:"repeated",type:"VideoBatchSubOptions",id:2}}},Audio:{fields:{from:{type:"string",id:1}}},Video:{fields:{from:{type:"string",id:1},params:{type:"VideoParameters",id:2}}},MediaUpdateDesc:{fields:{audio:{type:"Audio",id:1},video:{type:"Video",id:2}}},AudioSubOptions:{fields:{from:{type:"string",id:1},format:{type:"AudioStreamFormat",id:2}}},VideoSubOptions:{fields:{from:{type:"string",id:1},format:{type:"VideoStreamFormat",id:2},parameters:{type:"VideoParameters",id:3}}},MediaSubOptionsSpecify:{fields:{audio:{type:"AudioSubOptions",id:1},video:{type:"VideoSubOptions",id:2}}},SubscribeRequest:{fields:{roomId:{type:"string",id:1},participantId:{type:"string",id:2},tid:{type:"string",id:3},event:{type:"string",id:4},media:{type:"MediaSubOptionsSpecify",id:5},type:{type:"string",id:6},propertiesJsonStr:{type:"string",id:7},traceId:{type:"string",id:8}}},SubscribeResponse:{fields:{id:{type:"string",id:1}}},UnsubscribeRequest:{fields:{roomId:{type:"string",id:1},participantId:{type:"string",id:2},subscriptionId:{type:"string",id:3},tid:{type:"string",id:4},traceId:{type:"string",id:5}}},BatchSubscribeRequest:{fields:{roomId:{type:"string",id:1},participantId:{type:"string",id:2},connectionId:{type:"string",id:3},supportTemporalLayer:{type:"bool",id:4},clientType:{type:"string",id:5},clientVersion:{type:"string",id:6},media:{type:"MediaBatchSubOptions",id:7},tid:{type:"string",id:8},type:{type:"string",id:9},event:{type:"string",id:10},propertiesJsonStr:{type:"string",id:11},traceId:{type:"string",id:12}}},BatchUnsubscribeRequest:{fields:{roomId:{type:"string",id:1},participantId:{type:"string",id:2},connectionId:{type:"string",id:3},audio:{rule:"repeated",type:"string",id:4},video:{rule:"repeated",type:"string",id:5},tid:{type:"string",id:6},traceId:{type:"string",id:7}}},SubscriptionControlRequest:{oneofs:{data:{oneof:["updateDesc","track"]}},fields:{roomId:{type:"string",id:1},participantId:{type:"string",id:2},subscriptionId:{type:"string",id:3},operation:{type:"string",id:4},updateDesc:{type:"MediaUpdateDesc",id:6},track:{type:"string",id:7},tid:{type:"string",id:8},traceId:{type:"string",id:9}}}}}},SIGNAL_PROTO={nested:nested},root=getProtobufRoot(SIGNAL_PROTO),Response=root.lookupType("signal_msg.Response"),BatchNotification=root.lookupType("signal_msg.BatchNotification"),MediaMessage=root.lookupType("signal_msg.MediaMessage"),StreamNotification=root.lookupType("signal_msg.StreamNotification");root.lookupType("signal_msg.ProgressNotification");var ServerFailoverNotification=root.lookupType("signal_msg.ServerFailoverNotification"),PublishRequest=root.lookupType("signal_msg.PublishRequest"),SoacRequest=root.lookupType("signal_msg.SoacRequest"),UnpublishRequest=root.lookupType("signal_msg.UnpublishRequest"),StreamControlRequest=root.lookupType("signal_msg.StreamControlRequest"),SubscribeRequest=root.lookupType("signal_msg.SubscribeRequest"),SetStreamPropertiesRequest=root.lookupType("signal_msg.SetStreamPropertiesRequest"),UnsubscribeRequest=root.lookupType("signal_msg.UnsubscribeRequest"),SubscriptionControlRequest=root.lookupType("signal_msg.SubscriptionControlRequest"),CreatePeerConnectionRequest=root.lookupType("signal_msg.CreatePeerConnectionRequest"),ClosePeerConnectionRequest=root.lookupType("signal_msg.ClosePeerConnectionRequest"),BatchPublishRequest=root.lookupType("signal_msg.BatchPublishRequest"),BatchUnpublishRequest=root.lookupType("signal_msg.BatchUnpublishRequest"),BatchSubscribeRequest=root.lookupType("signal_msg.BatchSubscribeRequest"),BatchUnsubscribeRequest=root.lookupType("signal_msg.BatchUnsubscribeRequest"),JoinGroupRequest=root.lookupType("signal_msg.JoinGroupRequest"),SetGroupPropertiesRequest=root.lookupType("signal_msg.SetGroupPropertiesRequest"),DismissGroupRequest=root.lookupType("signal_msg.DismissGroupRequest"),LeaveGroupRequest=root.lookupType("signal_msg.LeaveGroupRequest"),SyncDataRequest=root.lookupType("signal_msg.SyncDataRequest"),SyncDataByIdsRequest=root.lookupType("signal_msg.SyncDataByIdsRequest"),GroupChangeLog=root.lookupType("signal_msg.GroupChangeLog"),GroupListChangeLog=root.lookupType("signal_msg.GroupListChangeLog"),SetParticipantPropertiesRequest=root.lookupType("signal_msg.SetParticipantPropertiesRequest"),QueryStreamsVerRequest=root.lookupType("signal_msg.QueryStreamsVerRequest"),QueryStreamsRequest=root.lookupType("signal_msg.QueryStreamsRequest");function _callSuper$h(e,t,r){return t=_getPrototypeOf$1(t),_possibleConstructorReturn$1(e,_isNativeReflectConstruct$h()?Reflect.construct(t,[],_getPrototypeOf$1(e).constructor):t.apply(e,r))}function _isNativeReflectConstruct$h(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(_isNativeReflectConstruct$h=function(){return!!e})()}var Signaling=function(e){function t(e){var r;return _classCallCheck$1(this,t),r=_callSuper$h(this,t),Object.defineProperty(r,"loggedIn",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"channel",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"rpcId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"reporter",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),r.channel=e,r.rpcId=0,r.reporter=e.reporter,r.handleBatchNotifyEvent=r.handleBatchNotifyEvent.bind(r),r.handleNotifyEvent=r.handleNotifyEvent.bind(r),r.handleConnectionStateChangeEvent=r.handleConnectionStateChangeEvent.bind(r),r.handleSyncEvent=r.handleSyncEvent.bind(r),r.handleUserEvent=r.handleUserEvent.bind(r),r.channel.on("connection-state-change",r.handleConnectionStateChangeEvent),r.channel.on("sync",r.handleSyncEvent),r.channel.on("batch-notify",r.handleBatchNotifyEvent),r.channel.on("notify",r.handleNotifyEvent),r.channel.on("user",r.handleUserEvent),r}return _inherits$1(t,e),_createClass$1(t,[{key:"join",value:function(e,t){return this.channel.join(e,t).then((function(e){return{joinResponse:e.joinResponse,iceConfig:e.iceConfig}}))}},{key:"leave",value:function(){return this.channel.leave()}},{key:"handleUserEvent",value:function(e,t){this.emit("user",e,t)}},{key:"handleSyncEvent",value:function(e){this.emit("sync",e)}},{key:"handleConnectionStateChangeEvent",value:function(e,t,r){this.emit("connection-state-change",e,t,r)}},{key:"handleNotifyEvent",value:function(e,t){"stream"===e?this.emit("stream",StreamNotification.decode(t)):"serverFailover"===e?this.emit("serverFailover",ServerFailoverNotification.decode(t)):"media-message"===e?this.emit("media-message",MediaMessage.decode(t)):"group"===e?this.emit("group",GroupChangeLog.decode(t)):"group-list"===e&&this.emit("group-list",GroupListChangeLog.decode(t))}},{key:"handleBatchNotifyEvent",value:function(e){var t=this;BatchNotification.decode(e).notificationItem.forEach((function(e){"stream"===e.event?t.emit("stream",e.streamNotification):"serverFailover"===e.event?t.emit("serverFailover",e.serverFailoverNotification):"group"===e.event?t.emit("group",e.groupNotification):"group-list"===e.event&&t.emit("group-list",e.groupListNotification)}))}},{key:"createPeerConnection",value:function(e){var t=CreatePeerConnectionRequest.encode(e).finish();return this.rpc("create-peer-connection",t,e).then((function(e){return e.createPeerConnectionResponse}))}},{key:"closePeerConnection",value:function(e){var t=ClosePeerConnectionRequest.encode(e).finish();return this.rpc("close-peer-connection",t,e)}},{key:"batchSubscribe",value:function(e){var t=BatchSubscribeRequest.encode(e).finish();return this.rpc("batch-subscribe",t,e).then((function(e){return e.errorMsg}))}},{key:"setGroupProperties",value:function(e){var t=SetGroupPropertiesRequest.encode(e).finish();return this.rpc("set-group-properties",t,e).then((function(e){return e.setGroupPropertiesResponse}))}},{key:"batchUnSubscribe",value:function(e){var t=BatchUnsubscribeRequest.encode(e).finish();return this.rpc("batch-unsubscribe",t,e)}},{key:"batchPublish",value:function(e){var t=BatchPublishRequest.encode(e).finish();return this.rpc("batch-publish",t,e).then((function(e){return e.errorMsg}))}},{key:"batchUnPublish",value:function(e){var t=BatchUnpublishRequest.encode(e).finish();return this.rpc("batch-unpublish",t,e)}},{key:"publish",value:function(e){var t=PublishRequest.encode(e).finish();return this.rpc("publish",t,e).then((function(e){return e.publishResponse}))}},{key:"setParticipantProperties",value:function(e){var t=SetParticipantPropertiesRequest.encode(e).finish();return this.rpc("set-participant-properties",t,e)}},{key:"soac",value:function(e){var t=SoacRequest.encode(e).finish();return this.rpc("soac",t,e)}},{key:"unpublish",value:function(e){var t=UnpublishRequest.encode(e).finish();return this.rpc("unpublish",t,e)}},{key:"streamControl",value:function(e){var t=StreamControlRequest.encode(e).finish();return this.rpc("stream-control",t,e)}},{key:"setStreamProperties",value:function(e){var t=SetStreamPropertiesRequest.encode(e).finish();return this.rpc("set-stream-properties",t,e)}},{key:"subscribe",value:function(e){var t=SubscribeRequest.encode(e).finish();return this.rpc("subscribe",t,e).then((function(e){return e.subscribeResponse}))}},{key:"unsubscribe",value:function(e){var t=UnsubscribeRequest.encode(e).finish();return this.rpc("unsubscribe",t,e)}},{key:"subscriptionControl",value:function(e){var t=SubscriptionControlRequest.encode(e).finish();return this.rpc("subscription-control",t,e)}},{key:"getStreamsVer",value:function(e){var t=QueryStreamsVerRequest.encode(e).finish();return this.rpc("query-streams-ver",t,e).then((function(e){return e.queryStreamsVerResponse}))}},{key:"getStreams",value:function(e){var t=QueryStreamsRequest.encode(e).finish();return this.rpc("query-streams",t,e).then((function(e){return e.queryStreamsResponse}))}},{key:"joinGroup",value:function(e){var t=JoinGroupRequest.encode(e).finish();return this.rpc("join-group",t,e).then((function(e){return e.joinGroupResponse}))}},{key:"leaveGroup",value:function(e){var t=LeaveGroupRequest.encode(e).finish();return this.rpc("leave-group",t,e).then((function(e){return e.leaveGroupResponse}))}},{key:"dismissGroup",value:function(e){var t=DismissGroupRequest.encode(e).finish();return this.rpc("dismiss-group",t,e).then((function(e){return e.dismissGroupResponse}))}},{key:"syncData",value:function(e){var t=SyncDataRequest.encode(e).finish();return this.rpc("sync-data",t,e).then((function(e){return e.syncDataResponse}))}},{key:"syncDataByIds",value:function(e){var t=SyncDataByIdsRequest.encode(e).finish();return this.rpc("sync-data-by-ids",t,e).then((function(e){return e.syncDataByIdsResponse}))}},{key:"observeAllGroups",value:function(){return this.rpc("observe-all-groups",null).then((function(e){return e.observeAllGroupsResponse}))}},{key:"unobserveAllGroups",value:function(){return this.rpc("unobserve-all-groups",null).then((function(e){return e.unobserveAllGroupsResponse}))}},{key:"rpc",value:function(e,t){var r=this,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0;return new Promise((function(i,o){var a=r.rpcId++;r.reporter.log.debug("rtc rpcId ".concat(a,":").concat(e," param====> ").concat(JSON.stringify(n||""))),r.channel.signaling.rpc(e,t,n).then((function(t){var n=Response.decode(t);n.code===signal_msg.Result.Ok?(r.reporter.log.debug("rtc rpcId ".concat(a,":").concat(e," result====> ").concat(JSON.stringify(n))),i(n)):(r.reporter.log.debug("rtc rpcId ".concat(a,":").concat(e," error====> ").concat(JSON.stringify(n))),o(n))}))}))}}])}(EventEmitter);function _callSuper$g(e,t,r){return t=_getPrototypeOf$1(t),_possibleConstructorReturn$1(e,_isNativeReflectConstruct$g()?Reflect.construct(t,[],_getPrototypeOf$1(e).constructor):t.apply(e,r))}function _isNativeReflectConstruct$g(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(_isNativeReflectConstruct$g=function(){return!!e})()}var Monitor=function(e){function t(){var e;_classCallCheck$1(this,t),e=_callSuper$g(this,t),Object.defineProperty(e,"interval",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(e,"timer",{enumerable:!0,configurable:!0,writable:!0,value:void 0});var r=getReporter().statsConfig;return e.interval=(null==r?void 0:r.statsIntervalMs)||METRIC_STATS_INTERVAL,e.start(),e}return _inherits$1(t,e),_createClass$1(t,[{key:"start",value:function(){var e=this;this.stop(),this.makeReport&&this.makeReport(),this.timer=addTimer((function(){e.makeReport()}),this.interval,"interval")}},{key:"stop",value:function(){this.timer&&(removeTimer(this.timer,"interval"),this.timer=null)}}])}(EventEmitter);function ownKeys$7(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function _objectSpread$7(e){for(var t=1;arguments.length>t;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ownKeys$7(Object(r),!0).forEach((function(t){_defineProperty(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ownKeys$7(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function _createForOfIteratorHelper$c(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=_unsupportedIterableToArray$c(e))||t){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return e.length>n?{done:!1,value:e[n++]}:{done:!0}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function _unsupportedIterableToArray$c(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray$c(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray$c(e,t):void 0}}function _arrayLikeToArray$c(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);t>r;r++)n[r]=e[r];return n}function _callSuper$f(e,t,r){return t=_getPrototypeOf$1(t),_possibleConstructorReturn$1(e,_isNativeReflectConstruct$f()?Reflect.construct(t,[],_getPrototypeOf$1(e).constructor):t.apply(e,r))}function _isNativeReflectConstruct$f(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(_isNativeReflectConstruct$f=function(){return!!e})()}var initAudioSendInfo={timestamp:0,audioLevel:0,bytesSent:0,packetsSent:0,packetsLost:0,roundTripTime:0},initVideoSendInfo={totalFramesSent:0,totalBytesSent:0,totalPacketsLost:0,totalPacketsSent:0,totalFramesEncoded:0,timestamp:0,totalQpSum:0,maxSendFrameHeight:0,maxSendFrameWidth:0,captureFrameHeight:0,captureFrameWidth:0,captureFramesPerSecond:0,sendFramesPerSecond:0,availableOutgoingBitrate:0,targetBitrate:0,roundTripTime:0,encodeFramesPerSecond:0,totalEncodedTime:0,trackStats:new Map},PublishMonitor=function(e){function t(e){var r;_classCallCheck$1(this,t),r=_callSuper$f(this,t),Object.defineProperty(r,"videoSendReport",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"audioSendReport",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"bweReport",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"lastVideoSendInfo",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"lastAudioSendInfo",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"track",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"source",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"pc",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"tranceiver",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"connection",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),r.connection=e.connection,r.pc=e.connection.pc;var n=e.tracks.filter((function(e){return"video"===e.trackMediaType}))[0];return r.source=null==n?void 0:n.source,r.track=e.tracks[0],r.tranceiver=e.transceiver,r.lastVideoSendInfo=Object.assign({},initVideoSendInfo),r.videoSendReport={attr_bitrate:0,attr_capture_frames:0,attr_enc_average_elapsed_ms:0,attr_encode_qp_sim:"",attr_encoded_framerate_sim:"",attr_resolution_sim:"",attr_stream_options:"",attr_duration_ms:0},r.lastAudioSendInfo=Object.assign({},initAudioSendInfo),r.audioSendReport={attr_duration_ms:0,attr_bitrate:0},r.bweReport={attr_rtt:0,attr_lossrate:0,attr_reported_bitrate:0,attr_duration_ms:0},r}return _inherits$1(t,e),_createClass$1(t,[{key:"extractVideoMetrics",value:function(e){var t=this,r=Object.assign({source:this.source,trackStats:[]},initVideoSendInfo,this.connection.peerConnectionStats);if(r.timestamp=Date.now(),this.track){var n=this.track.getMediaStreamTrack().getSettings(),i=n.width,o=n.height,a=n.frameRate;r.captureFramesPerSecond=a===1/0?0:a||0,r.captureFrameWidth=i||0,r.captureFrameHeight=o||0}var s=new Map,c=getDeltaDurationInSeconds(r,this.lastVideoSendInfo);return e.forEach((function(e){if(/outboundrtp|outbound-rtp/i.test(e.type)){var n=s.get(e.ssrc)||{},i=t.lastVideoSendInfo.trackStats.get(e.ssrc)||{};if(n.sendFrameWidth=e.frameWidth||0,n.sendFrameHeight=e.frameHeight||0,n.framesSent=e.framesSent||0,n.framesEncoded=e.framesEncoded||0,n.targetBitrate=e.targetBitrate||0,n.qpSum=e.qpSum||0,n.bytesSent=e.bytesSent||0,n.packetsSent=e.packetsSent||0,n.packetsSentForLost=n.packetsSent||0,n.totalEncodeTime=e.totalEncodeTime||0,n.keyFramesEncoded=e.keyFramesEncoded||0,n.firCount=e.firCount||0,n.pliCount=e.pliCount||0,n.retransmittedBytesSent=e.retransmittedBytesSent||0,n.retransmittedPacketsSent=e.retransmittedPacketsSent||0,n.qualityLimitationReason=e.qualityLimitationReason||"",n.sendFramesPerSecond=e.framesPerSecond||0,n.sendFrameWidth>r.maxSendFrameWidth){if(r.maxSendFrameWidth=n.sendFrameWidth,!n.sendFramesPerSecond&&i){var o=getDelta(n.framesSent||n.framesEncoded,i.framesSent||i.framesEncoded);n.sendFramesPerSecond=Math.round(o/c)}if(n.framesEncoded){var a=getDelta(n.framesEncoded,null==i?void 0:i.framesEncoded);r.encodeFramesPerSecond=Math.round(a/c)}r.sendFramesPerSecond=n.sendFramesPerSecond}s.set(e.ssrc,n),r.targetBitrate=n.targetBitrate,r.totalBytesSent+=n.bytesSent,r.totalPacketsSent+=n.packetsSent,r.totalEncodedTime+=n.totalEncodeTime,r.totalFramesEncoded+=n.framesEncoded,r.totalFramesSent+=n.framesSent,r.totalQpSum+=n.qpSum,r.maxSendFrameHeight=Math.max(n.sendFrameHeight,r.maxSendFrameHeight),s.set(e.ssrc,n)}else if(/track/i.test(e.type)&&!1===e.remoteSource){if(Environment.isSafari()){var u=s.get(e.ssrc)||{};u.sendFrameHeight>0||(u.sendFrameWidth=e.frameWidth||0,u.sendFrameHeight=e.frameHeight||0),u.framesSent=e.framesSent||0,u.totalEncodeTime=e.totalEncodeTime||0,s.set(e.ssrc,u),r.totalFramesEncoded+=u.framesEncoded,r.totalEncodedTime+=u.totalEncodeTime,r.totalFramesSent+=u.framesSent,s.set(e.ssrc,u)}}else if(/remote-inbound-rtp/i.test(e.type)){var l=s.get(e.ssrc)||{},d=t.lastVideoSendInfo.trackStats.get(e.ssrc)||{};l.packetsLost=e.packetsLost||0,l.lostTimestamp=e.timestamp,r.totalPacketsLost+=l.packetsLost,l.packetsLost===(d.packetsLost||0)&&(l.packetsSentForLost=d.packetsSentForLost||0,l.lostTimestamp=d.lostTimestamp||0),s.set(e.ssrc,l)}})),r.trackStats=s,r}},{key:"getLayersMetricInfo",value:function(e){var t,r=[],n=_createForOfIteratorHelper$c(e.trackStats.entries());try{for(n.s();!(t=n.n()).done;){var i=_slicedToArray(t.value,2),o=i[1],a=this.lastVideoSendInfo.trackStats.get(i[0])||{},s=getDelta(o.framesSent,a.framesSent),c=getDelta(o.framesEncoded,a.framesEncoded),u=getDelta(o.keyFramesEncoded,a.keyFramesEncoded),l=getDelta(o.retransmittedBytesSent,a.retransmittedBytesSent),d=getDelta(o.retransmittedPacketsSent,a.retransmittedPacketsSent),p=getDelta(o.firCount,a.firCount),f=getDelta(o.pliCount,a.pliCount),h=getDelta(o.packetsSent,a.packetsSent),m=getDelta(o.packetsSentForLost,a.packetsSentForLost),g=getDelta(o.lostTimestamp,a.lostTimestamp),y=getDelta(o.packetsLost,a.packetsLost),v=getDelta(o.totalEncodeTime,a.totalEncodeTime),_=getDelta(o.qpSum,a.qpSum),b=_objectSpread$7(_objectSpread$7({sendFrameHeight:o.sendFrameHeight,sendFrameWidth:o.sendFrameWidth,qualityLimitationReason:o.qualityLimitationReason},o),{},{deltaQbSum:_,deltaPacketsSent:h,deltaPacketsLost:y,deltaFramesSent:s,deltaTimestampForLost:g,deltaFramesEncoded:c,deltaKeyFramesEncoded:u,deltaFirCount:p,deltaEncodedTime:v,deltaPliCount:f,deltaPacketsSentForLost:m,deltaRetransmittedBytesSent:l,deltaRetransmittedPacketsSent:d});r.push(b)}}catch(e){n.e(e)}finally{n.f()}return{tracksStatInfo:r,totalBytesSent:e.totalBytesSent,totalFramesEncoded:e.totalFramesEncoded||e.totalFramesSent,totalPacketsSent:e.totalPacketsSent,totalEncodedTime:e.totalEncodedTime,totalQpSum:e.totalQpSum,totalPacketsLost:e.totalPacketsLost}}},{key:"makeVideoReport",value:function(e){var t={attr_capture_frames:Math.round(e.captureFramesPerSecond),attr_stream_options:"audio:false/video:".concat(this.source,"/resolution:").concat(e.captureFrameWidth,"*").concat(e.captureFrameHeight,"/")};if(this.lastVideoSendInfo.timestamp){for(var r=this.getLayersMetricInfo(e),n=r.tracksStatInfo,i=r.totalBytesSent,o=r.totalFramesEncoded,a=r.totalEncodedTime,s={attr_encoded_framerate_sim:[],attr_enc_key_frames_sim:[],attr_fir_count_sim:[],attr_pli_count_sim:[],attr_quality_limitation_reason_sim:[],attr_retx_bytes_sim:[],attr_retx_packets_sim:[],attr_resolution_sim:[],attr_encode_qp_sim:[]},c=[],u=0,l=getDelta(e.timestamp,this.lastVideoSendInfo.timestamp),d=0,p=0;n.length>p;p++){var f=n[p];s.attr_enc_key_frames_sim.push(f.deltaKeyFramesEncoded),s.attr_fir_count_sim.push(f.deltaFirCount),s.attr_pli_count_sim.push(f.deltaPliCount),s.attr_quality_limitation_reason_sim.push(f.qualityLimitationReason),s.attr_retx_bytes_sim.push(f.deltaRetransmittedBytesSent),s.attr_retx_packets_sim.push(f.deltaRetransmittedPacketsSent),d=Math.max(f.deltaTimestampForLost),f.sendFrameWidth&&(f.deltaFramesEncoded||f.deltaFramesSent)&&(s.attr_resolution_sim.push({count:f.deltaFramesSent||f.deltaFramesEncoded,index:p,resolution:"".concat(f.sendFrameWidth,"*").concat(f.sendFrameHeight)}),s.attr_encoded_framerate_sim.push(_defineProperty({},p,Math.round(1e3*(f.deltaFramesEncoded||f.deltaFramesSent)/l))),s.attr_encode_qp_sim.push(_defineProperty({},p,Math.round((f.deltaQbSum||0)/(f.deltaFramesEncoded||f.deltaFramesSent))))),f.deltaPacketsLost&&f.deltaPacketsSentForLost&&c.push(f.deltaPacketsLost/f.deltaPacketsSentForLost*255)}for(var h=0,m=Object.entries(s);m.length>h;h++){var g=_slicedToArray(m[h],2),y=g[1];t[g[0]]=y.length?JSON.stringify(y):""}var v=0,_=getDelta(o,this.lastVideoSendInfo.totalFramesEncoded),b=getDelta(a,this.lastVideoSendInfo.totalEncodedTime);_&&b&&(v=Math.round(1e3*b/_));var E=getDelta(i,this.lastVideoSendInfo.totalBytesSent);t.attr_duration_ms=l,t.attr_bitrate=l>0?Math.min(Math.round(8*E*1e3/l),2e7):0,t.attr_enc_average_elapsed_ms=v,this.videoSendReport=t,this.emit("video-send-stream",Object.assign({},this.videoSendReport)),c.length&&(u=Math.min(Math.round(c.reduce((function(e,t){return t+e}),0)/c.length),255),this.bweReport={attr_duration_ms:d,attr_rtt:Math.round(e.roundTripTime||0),attr_reported_bitrate:Math.max(0,Math.min(e.availableOutgoingBitrate||0,2e7)),attr_lossrate:u},this.emit("bwe",Object.assign({},this.bweReport)))}this.lastVideoSendInfo=e}},{key:"extractAudioMetrics",value:function(e){var t=this,r=Object.assign({},initAudioSendInfo,this.connection.peerConnectionStats);return e.forEach((function(e){if(/outboundrtp|outbound-rtp/i.test(e.type)?(r.timestamp=e.timestamp,r.bytesSent=e.bytesSent||0,r.packetsSent=e.packetsSent):/remote-inbound-rtp|remoteinboundrt/i.test(e.type)?void 0!==e.packetsLost&&(r.packetsLost=e.packetsLost):/media-source/i.test(e.type)&&e.audioLevel&&(r.audioLevel=e.audioLevel),t.track){var n=t.track.getMediaStreamTrack().getSettings(),i=n.sampleRate;r.channels=n.channelCount,r.sampleRate=i}})),r}},{key:"makeAudioReport",value:function(e){this.lastAudioSendInfo.timestamp>0&&e.timestamp&&(this.audioSendReport={attr_duration_ms:Math.round(getDelta(e.timestamp,this.lastAudioSendInfo.timestamp)),attr_bitrate:Math.round(8*getDelta(e.bytesSent,this.lastAudioSendInfo.bytesSent)*1e3/getDelta(e.timestamp,this.lastAudioSendInfo.timestamp))},this.emit("audio-send-stream",Object.assign({},this.audioSendReport))),this.lastAudioSendInfo=e}},{key:"makeReport",value:function(){var e=this;this.getStats().then((function(t){null!=t&&t.audioMetrics&&e.makeAudioReport(t.audioMetrics),null!=t&&t.videoMetrics&&e.makeVideoReport(t.videoMetrics)}))}},{key:"getStats",value:function(){var e,t,r=this,n=this.tranceiver,i=this.pc;if(!i||null==n||null===(e=n.sender)||void 0===e||!e.track)return Promise.resolve({});if(null==i||!i.getStats)throw new DingRTCError(ErrorCode.BrowserNotSupported,"getStats is not supported");return null===(t=this.pc.getStats(n.sender.track))||void 0===t?void 0:t.then((function(e){return{videoMetrics:r.source?r.extractVideoMetrics(e):void 0,audioMetrics:r.source?void 0:r.extractAudioMetrics(e)}}))}}])}(Monitor);function _createForOfIteratorHelper$b(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=_unsupportedIterableToArray$b(e))||t){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return e.length>n?{done:!1,value:e[n++]}:{done:!0}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function _unsupportedIterableToArray$b(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray$b(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray$b(e,t):void 0}}function _arrayLikeToArray$b(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);t>r;r++)n[r]=e[r];return n}function _callSuper$e(e,t,r){return t=_getPrototypeOf$1(t),_possibleConstructorReturn$1(e,_isNativeReflectConstruct$e()?Reflect.construct(t,[],_getPrototypeOf$1(e).constructor):t.apply(e,r))}function _isNativeReflectConstruct$e(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(_isNativeReflectConstruct$e=function(){return!!e})()}function _superPropGet(e,t,r,n){var i=_get(_getPrototypeOf$1(e.prototype),t,r);return"function"==typeof i?function(e){return i.apply(r,e)}:i}var initAudioReceiveInfo={timestamp:0,packetsLost:0,packetsReceived:0,bytesReceived:0,audioLevel:0,decodingNormal:0,roundTripTime:0},initVideoReciveInfo={packetsLost:0,packetsReceived:0,framesDropped:0,frameHeight:0,frameWidth:0,framesDecoded:0,framesReceived:0,timestamp:0,framesPerSecond:0,bytesReceived:0,roundTripTime:0},SubscribeMonitor=function(e){function t(e){var r,n;_classCallCheck$1(this,t),n=_callSuper$e(this,t),Object.defineProperty(n,"videoReceiveReport",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(n,"audioReceiveReport",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(n,"lastVideoReceiveInfo",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(n,"lastAudioReceiveInfo",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(n,"source",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(n,"firstReportFlag",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(n,"firstReportTimer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(n,"pc",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(n,"tranceiver",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(n,"tranceivers",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(n,"connection",{enumerable:!0,configurable:!0,writable:!0,value:void 0});var i=e.connection,o=e.transceiver,a=e.uid,s=e.stream,c=e.transceivers;return n.connection=i,n.pc=i.pc,n.tranceiver=o,n.tranceivers=c,n.firstReportTimer=addTimer((function(){n.getStats().then((function(e){n.makeFirstReport(e)}))}),400,"interval"),n.source="mcu"!==a&&(null===(r=s.media)||void 0===r||null===(r=r.video)||void 0===r?void 0:r.source),n.videoReceiveReport={attr_duration_ms:0,attr_bitrate:0,attr_current_delay:0,attr_stream_options:"",attr_resolution:"",attr_dec_frames:0,attr_decode_qp:0,attr_fraction_lost:0,attr_network_framerate:0,attr_render_delay:0,attr_dec_key_frames:-1},n.lastVideoReceiveInfo=Object.assign({},initVideoReciveInfo),n.firstReportFlag={audioFirstPacket:!1,videoFirstPacket:!1,audioFirstFrame:!1},n.lastAudioReceiveInfo=Object.assign({},initAudioReceiveInfo),n.audioReceiveReport={attr_duration_ms:0,attr_delay_estimate:0,attr_bitrate:0},n}return _inherits$1(t,e),_createClass$1(t,[{key:"extractAudioMetrics",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=Object.assign({},initAudioReceiveInfo,this.connection.peerConnectionStats);return n.timestamp=Date.now(),e.forEach((function(e){e.isRemote||(/inboundrtp|inbound-rtp/i.test(e.type)?(n.bytesReceived=e.bytesReceived||0,n.packetsReceived=e.packetsReceived||0,r||(n.packetsReceivedForLost=n.packetsLost===(t.lastAudioReceiveInfo.packetsLost||0)?t.lastAudioReceiveInfo.packetsReceived||0:n.packetsReceived||0),n.packetsLost=e.packetsLost||0,n.audioLevel=e.audioLevel||0,n.decodingNormal=Number(e.googDecodingNormal||0)):/track/i.test(e.type)&&(n.audioLevel=e.audioLevel))})),n}},{key:"extractMultipleAudioMetrics",value:function(e){var t=this,r=e.map((function(e){return t.extractAudioMetrics(e,!0)})),n=Object.assign({},initAudioReceiveInfo,this.connection.peerConnectionStats);n.timestamp=Date.now();var i,o=_createForOfIteratorHelper$b(r);try{for(o.s();!(i=o.n()).done;){var a=i.value;n.bytesReceived+=a.bytesReceived||0,n.packetsLost+=a.packetsLost||0,n.packetsReceived+=a.packetsReceived||0,n.audioLevel=Math.max(n.audioLevel,a.audioLevel||0),n.decodingNormal=Math.max(n.decodingNormal,a.decodingNormal||0)}}catch(e){o.e(e)}finally{o.f()}return n.packetsReceivedForLost=n.packetsLost===(this.lastAudioReceiveInfo.packetsLost||0)?this.lastAudioReceiveInfo.packetsReceived||0:n.packetsReceived||0,n}},{key:"extractVideoMetrics",value:function(e){var t=this,r=Object.assign({source:this.source},initVideoReciveInfo,this.connection.peerConnectionStats);return r.timestamp=Date.now(),e.forEach((function(e){if(!e.isRemote)if(/inboundrtp|inbound-rtp/i.test(e.type))r.framesDecoded=e.framesDecoded,r.packetsReceived=e.packetsReceived||0,r.framesReceived=e.framesReceived,r.keyFramesDecoded=e.keyFramesDecoded||0,r.packetsLost=e.packetsLost||0,r.packetsReceivedForLost=r.packetsLost===(t.lastVideoReceiveInfo.packetsLost||0)?t.lastVideoReceiveInfo.packetsReceived||0:r.packetsReceived||0,r.bytesReceived=e.bytesReceived||0,r.firCount=e.firCount||0,r.pliCount=e.pliCount||0,r.freezeCount=e.freezeCount||0,r.retransmittedBytesReceived=e.retransmittedBytesReceived||0,r.retransmittedPacketsReceived=e.retransmittedPacketsReceived||0,void 0!==e.frameHeight&&(r.frameWidth=e.frameWidth||0,r.frameHeight=e.frameHeight||0);else if(/track/i.test(e.type))r.frameWidth=e.frameWidth||0,r.frameHeight=e.frameHeight||0;else if(/codec/i.test(e.type)){var n;null!==(n=e.mimeType)&&void 0!==n&&n.includes("video")&&(r.sdpFmtpLine=e.sdpFmtpLine)}})),r}},{key:"makeAudioReport",value:function(e){if(this.lastAudioReceiveInfo.timestamp>0&&e.timestamp){var t=Math.round(getDelta(e.timestamp,this.lastAudioReceiveInfo.timestamp)),r=getDelta(e.packetsLost,this.lastAudioReceiveInfo.packetsLost),n=getDelta(e.packetsReceivedForLost,this.lastAudioReceiveInfo.packetsReceivedForLost),i=getDelta(e.bytesReceived,this.lastAudioReceiveInfo.bytesReceived),o=0;try{o=Math.max(r/n,0)}catch(e){o=0}isNaN(o)&&(o=0),this.audioReceiveReport={attr_delay_estimate:0,attr_duration_ms:t,attr_bitrate:Math.round(8*i/(t/1e3))},this.emit("audio-net-eq",{attr_speech_expand_rate:0,attr_duration_ms:this.audioReceiveReport.attr_duration_ms,attr_packet_lossrate:Math.round(Math.min(16384*o,16384))}),this.emit("audio-recv-stream",Object.assign({},this.audioReceiveReport))}this.lastAudioReceiveInfo=e}},{key:"makeVideoReport",value:function(e){var t=this.lastVideoReceiveInfo,r=t.firCount,n=t.pliCount,i=t.timestamp,o=t.freezeCount,a=t.packetsLost,s=t.framesDecoded,c=t.framesDropped,u=t.bytesReceived,l=t.packetsReceivedForLost,d=t.retransmittedBytesReceived,p=t.retransmittedPacketsReceived;if(i>0&&e.timestamp){var f=getDelta(e.timestamp,i);if(e.bytesReceived-u>=0){var h=getDelta(e.packetsLost,a),m=getDelta(e.packetsReceivedForLost,l),g=0;try{g=Math.round(h/m*255)}catch(e){g=0}isNaN(g)&&(g=0);var y=getDelta(e.framesDecoded,s);this.videoReceiveReport={attr_network_framerate:Math.round(1e3*y/f),attr_dec_frames:y,attr_dec_key_frames:e.keyFramesDecoded,attr_decode_qp:0,attr_render_delay:0,attr_current_delay:0,attr_dropped_count:getDelta(e.framesDropped,c),attr_fir_count:getDelta(e.firCount,r),attr_freeze_count:getDelta(e.freezeCount,o),attr_pli_count:getDelta(e.pliCount,n),attr_retx_bytes:getDelta(e.retransmittedBytesReceived,d),attr_retx_packets:getDelta(e.retransmittedPacketsReceived,p),attr_bitrate:Math.round(8*getDelta(e.bytesReceived,u)*1e3/f),attr_stream_options:"audio:false/video:".concat(this.source,"/resolution:").concat(e.frameWidth,"*").concat(e.frameHeight,"/"),attr_fraction_lost:Math.max(0,Math.min(g,255)),attr_resolution:JSON.stringify([{count:y,resolution:"".concat(e.frameWidth,"*").concat(e.frameHeight)}]),attr_duration_ms:Math.round(f)},e.frameWidth&&e.frameHeight&&this.emit("video-recv-stream",Object.assign({},this.videoReceiveReport))}}this.lastVideoReceiveInfo=e}},{key:"makeReport",value:function(){var e=this;this.getStats().then((function(t){t.audioMetrics&&e.makeAudioReport(t.audioMetrics),t.videoMetrics&&e.makeVideoReport(t.videoMetrics)}))}},{key:"makeFirstReport",value:function(e){var t=this.firstReportFlag,r=t.audioFirstFrame,n=t.audioFirstPacket,i=t.videoFirstPacket,o=e.audioMetrics,a=e.videoMetrics;if(o&&a){if((r||-1===(null==o?void 0:o.decodingNormal))&&n&&i)return void(this.firstReportTimer&&(removeTimer(this.firstReportTimer,"interval"),this.firstReportTimer=null))}else if(o){if((r||-1===(null==o?void 0:o.decodingNormal))&&n)return void(this.firstReportTimer&&(removeTimer(this.firstReportTimer,"interval"),this.firstReportTimer=null))}else if(a&&i)return void(this.firstReportTimer&&(removeTimer(this.firstReportTimer,"interval"),this.firstReportTimer=null));null!=o&&o.packetsReceived&&!n&&(this.emit("audio-first-packet"),this.firstReportFlag.audioFirstPacket=!0),Number(null==o?void 0:o.decodingNormal)>0&&!r&&(this.emit("audio-first-frame"),this.firstReportFlag.audioFirstPacket=!0),null!=a&&a.packetsReceived&&!i&&(this.emit("video-first-packet"),this.firstReportFlag.videoFirstPacket=!0)}},{key:"getStats",value:function(){var e,t=this,r=this.tranceiver,n=this.tranceivers,i=this.pc;if(!(i&&(null!=n&&n.length||null!=r&&r.receiver.track)))return Promise.resolve({});if(null==i||!i.getStats)throw new DingRTCError(ErrorCode.BrowserNotSupported,"getStats is not supported");if(n&&n.length){var o=n.map((function(e){return e.receiver.track})).filter((function(e){return!!e}));return Promise.all(o.map((function(e){return i.getStats(e)}))).then((function(e){return{audioMetrics:t.extractMultipleAudioMetrics(e)}}))}return null!=r&&null!==(e=r.receiver)&&void 0!==e&&e.track?i.getStats(r.receiver.track).then((function(e){return{videoMetrics:t.source?t.extractVideoMetrics(e):void 0,audioMetrics:t.source?void 0:t.extractAudioMetrics(e)}})):void 0}},{key:"stop",value:function(){_superPropGet(t,"stop",this)([]),this.firstReportTimer&&(removeTimer(this.firstReportTimer,"interval"),this.firstReportTimer=null)}}])}(Monitor),sortResolutions=function(e,t){return e.width!==t.width?e.width-t.width:e.height-t.height},getResolutions=function(e){var t;if(!e)return[];var r=e.media.video;if(!r)return[];var n=[],i=r.optional,o=r.parameters;return null!=o&&o.resolution&&n.push(o.resolution),null!=i&&null!==(t=i.parameters)&&void 0!==t&&null!==(t=t.resolution)&&void 0!==t&&t.length&&n.push.apply(n,_toConsumableArray(i.parameters.resolution)),n.sort(sortResolutions),n},parseSubscribeError=function(e,t){var r,n=e.media,i=n.audio,o=n.video;if(t===SubPubFailReason.QuotaLimit)return r=new DingRTCError(ErrorCode.QuotaLimitExceed);if(i)r=new DingRTCError(ErrorCode.SubscribeAudioStreamFailed,t);else if(o){var a=o.source;a===exports.VideoSourceInfo.CAMERA?r=new DingRTCError(ErrorCode.SubscribeVideoStreamFailed,t):a===exports.VideoSourceInfo.SCREENCAST&&(r=new DingRTCError(ErrorCode.SubscribeScreenShareFailed,t))}return r},parsePublishError=function(e,t){var r,n=e.trackMediaType;if(t===SubPubFailReason.QuotaLimit)return r=new DingRTCError(ErrorCode.QuotaLimitExceed);if("audio"===n)r=new DingRTCError(ErrorCode.PublishAudioStreamFailed,t);else{var i=e.source;i===exports.VideoSourceInfo.CAMERA?r=new DingRTCError(ErrorCode.PublishVideoStreamFailed,t):i===exports.VideoSourceInfo.SCREENCAST&&(r=new DingRTCError(ErrorCode.PublishScreenShareFailed,t))}return r},updateRemoteTrack=function(e,t,r,n){var i=n,o=e.getVideoTracks(),a=e.getAudioTracks();return"audio"===t&&a.length?clientConfig.audioSFU?n?n.replaceStream(e):i=new RemoteAudioTrack(null,r,e):n?n.replaceTrack(a[0]):i=new RemoteAudioTrack(a[0],r):"video"===t&&o.length&&(n?n.replaceTrack(o[0]):i=new RemoteVideoTrack(o[0],r)),i},lib={},parser$1={},grammar$3={exports:{}},grammar$2=grammar$3.exports={v:[{name:"version",reg:/^(\d*)$/}],o:[{name:"origin",reg:/^(\S*) (\d*) (\d*) (\S*) IP(\d) (\S*)/,names:["username","sessionId","sessionVersion","netType","ipVer","address"],format:"%s %s %d %s IP%d %s"}],s:[{name:"name"}],i:[{name:"description"}],u:[{name:"uri"}],e:[{name:"email"}],p:[{name:"phone"}],z:[{name:"timezones"}],r:[{name:"repeats"}],t:[{name:"timing",reg:/^(\d*) (\d*)/,names:["start","stop"],format:"%d %d"}],c:[{name:"connection",reg:/^IN IP(\d) (\S*)/,names:["version","ip"],format:"IN IP%d %s"}],b:[{push:"bandwidth",reg:/^(TIAS|AS|CT|RR|RS):(\d*)/,names:["type","limit"],format:"%s:%s"}],m:[{reg:/^(\w*) (\d*) ([\w/]*)(?: (.*))?/,names:["type","port","protocol","payloads"],format:"%s %d %s %s"}],a:[{push:"rtp",reg:/^rtpmap:(\d*) ([\w\-.]*)(?:\s*\/(\d*)(?:\s*\/(\S*))?)?/,names:["payload","codec","rate","encoding"],format:function(e){return e.encoding?"rtpmap:%d %s/%s/%s":e.rate?"rtpmap:%d %s/%s":"rtpmap:%d %s"}},{push:"fmtp",reg:/^fmtp:(\d*) ([\S| ]*)/,names:["payload","config"],format:"fmtp:%d %s"},{name:"control",reg:/^control:(.*)/,format:"control:%s"},{name:"rtcp",reg:/^rtcp:(\d*)(?: (\S*) IP(\d) (\S*))?/,names:["port","netType","ipVer","address"],format:function(e){return null!=e.address?"rtcp:%d %s IP%d %s":"rtcp:%d"}},{push:"rtcpFbTrrInt",reg:/^rtcp-fb:(\*|\d*) trr-int (\d*)/,names:["payload","value"],format:"rtcp-fb:%s trr-int %d"},{push:"rtcpFb",reg:/^rtcp-fb:(\*|\d*) ([\w-_]*)(?: ([\w-_]*))?/,names:["payload","type","subtype"],format:function(e){return null!=e.subtype?"rtcp-fb:%s %s %s":"rtcp-fb:%s %s"}},{push:"ext",reg:/^extmap:(\d+)(?:\/(\w+))?(?: (urn:ietf:params:rtp-hdrext:encrypt))? (\S*)(?: (\S*))?/,names:["value","direction","encrypt-uri","uri","config"],format:function(e){return"extmap:%d"+(e.direction?"/%s":"%v")+(e["encrypt-uri"]?" %s":"%v")+" %s"+(e.config?" %s":"")}},{name:"extmapAllowMixed",reg:/^(extmap-allow-mixed)/},{push:"crypto",reg:/^crypto:(\d*) ([\w_]*) (\S*)(?: (\S*))?/,names:["id","suite","config","sessionConfig"],format:function(e){return null!=e.sessionConfig?"crypto:%d %s %s %s":"crypto:%d %s %s"}},{name:"setup",reg:/^setup:(\w*)/,format:"setup:%s"},{name:"connectionType",reg:/^connection:(new|existing)/,format:"connection:%s"},{name:"mid",reg:/^mid:([^\s]*)/,format:"mid:%s"},{name:"msid",reg:/^msid:(.*)/,format:"msid:%s"},{name:"ptime",reg:/^ptime:(\d*(?:\.\d*)*)/,format:"ptime:%d"},{name:"maxptime",reg:/^maxptime:(\d*(?:\.\d*)*)/,format:"maxptime:%d"},{name:"direction",reg:/^(sendrecv|recvonly|sendonly|inactive)/},{name:"icelite",reg:/^(ice-lite)/},{name:"iceUfrag",reg:/^ice-ufrag:(\S*)/,format:"ice-ufrag:%s"},{name:"icePwd",reg:/^ice-pwd:(\S*)/,format:"ice-pwd:%s"},{name:"fingerprint",reg:/^fingerprint:(\S*) (\S*)/,names:["type","hash"],format:"fingerprint:%s %s"},{push:"candidates",reg:/^candidate:(\S*) (\d*) (\S*) (\d*) (\S*) (\d*) typ (\S*)(?: raddr (\S*) rport (\d*))?(?: tcptype (\S*))?(?: generation (\d*))?(?: network-id (\d*))?(?: network-cost (\d*))?/,names:["foundation","component","transport","priority","ip","port","type","raddr","rport","tcptype","generation","network-id","network-cost"],format:function(e){var t="candidate:%s %d %s %d %s %d typ %s";return t+=null!=e.raddr?" raddr %s rport %d":"%v%v",t+=null!=e.tcptype?" tcptype %s":"%v",null!=e.generation&&(t+=" generation %d"),t+=null!=e["network-id"]?" network-id %d":"%v",t+=null!=e["network-cost"]?" network-cost %d":"%v"}},{name:"endOfCandidates",reg:/^(end-of-candidates)/},{name:"remoteCandidates",reg:/^remote-candidates:(.*)/,format:"remote-candidates:%s"},{name:"iceOptions",reg:/^ice-options:(\S*)/,format:"ice-options:%s"},{push:"ssrcs",reg:/^ssrc:(\d*) ([\w_-]*)(?::(.*))?/,names:["id","attribute","value"],format:function(e){var t="ssrc:%d";return null!=e.attribute&&(t+=" %s",null!=e.value&&(t+=":%s")),t}},{push:"ssrcGroups",reg:/^ssrc-group:([\x21\x23\x24\x25\x26\x27\x2A\x2B\x2D\x2E\w]*) (.*)/,names:["semantics","ssrcs"],format:"ssrc-group:%s %s"},{name:"msidSemantic",reg:/^msid-semantic:\s?(\w*) (\S*)/,names:["semantic","token"],format:"msid-semantic: %s %s"},{push:"groups",reg:/^group:(\w*) (.*)/,names:["type","mids"],format:"group:%s %s"},{name:"rtcpMux",reg:/^(rtcp-mux)/},{name:"rtcpRsize",reg:/^(rtcp-rsize)/},{name:"sctpmap",reg:/^sctpmap:([\w_/]*) (\S*)(?: (\S*))?/,names:["sctpmapNumber","app","maxMessageSize"],format:function(e){return null!=e.maxMessageSize?"sctpmap:%s %s %s":"sctpmap:%s %s"}},{name:"xGoogleFlag",reg:/^x-google-flag:([^\s]*)/,format:"x-google-flag:%s"},{push:"rids",reg:/^rid:([\d\w]+) (\w+)(?: ([\S| ]*))?/,names:["id","direction","params"],format:function(e){return e.params?"rid:%s %s %s":"rid:%s %s"}},{push:"imageattrs",reg:RegExp("^imageattr:(\\d+|\\*)[\\s\\t]+(send|recv)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*)(?:[\\s\\t]+(recv|send)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*))?"),names:["pt","dir1","attrs1","dir2","attrs2"],format:function(e){return"imageattr:%s %s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast",reg:RegExp("^simulcast:(send|recv) ([a-zA-Z0-9\\-_~;,]+)(?:\\s?(send|recv) ([a-zA-Z0-9\\-_~;,]+))?$"),names:["dir1","list1","dir2","list2"],format:function(e){return"simulcast:%s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast_03",reg:/^simulcast:[\s\t]+([\S+\s\t]+)$/,names:["value"],format:"simulcast: %s"},{name:"framerate",reg:/^framerate:(\d+(?:$|\.\d+))/,format:"framerate:%s"},{name:"sourceFilter",reg:/^source-filter: *(excl|incl) (\S*) (IP4|IP6|\*) (\S*) (.*)/,names:["filterMode","netType","addressTypes","destAddress","srcList"],format:"source-filter: %s %s %s %s %s"},{name:"bundleOnly",reg:/^(bundle-only)/},{name:"label",reg:/^label:(.+)/,format:"label:%s"},{name:"sctpPort",reg:/^sctp-port:(\d+)$/,format:"sctp-port:%s"},{name:"maxMessageSize",reg:/^max-message-size:(\d+)$/,format:"max-message-size:%s"},{push:"tsRefClocks",reg:/^ts-refclk:([^\s=]*)(?:=(\S*))?/,names:["clksrc","clksrcExt"],format:function(e){return"ts-refclk:%s"+(null!=e.clksrcExt?"=%s":"")}},{name:"mediaClk",reg:/^mediaclk:(?:id=(\S*))? *([^\s=]*)(?:=(\S*))?(?: *rate=(\d+)\/(\d+))?/,names:["id","mediaClockName","mediaClockValue","rateNumerator","rateDenominator"],format:function(e){var t="mediaclk:";return t+=null!=e.id?"id=%s %s":"%v%s",t+=null!=e.mediaClockValue?"=%s":"",t+=null!=e.rateNumerator?" rate=%s":"",t+=null!=e.rateDenominator?"/%s":""}},{name:"keywords",reg:/^keywds:(.+)$/,format:"keywds:%s"},{name:"content",reg:/^content:(.+)/,format:"content:%s"},{name:"bfcpFloorCtrl",reg:/^floorctrl:(c-only|s-only|c-s)/,format:"floorctrl:%s"},{name:"bfcpConfId",reg:/^confid:(\d+)/,format:"confid:%s"},{name:"bfcpUserId",reg:/^userid:(\d+)/,format:"userid:%s"},{name:"bfcpFloorId",reg:/^floorid:(.+) (?:m-stream|mstrm):(.+)/,names:["id","mStream"],format:"floorid:%s mstrm:%s"},{push:"invalid",names:["value"]}]};Object.keys(grammar$2).forEach((function(e){grammar$2[e].forEach((function(e){e.reg||(e.reg=/(.*)/),e.format||(e.format="%s")}))}));var grammarExports=grammar$3.exports;!function(e){var t=function(e){return Number(e)+""===e?Number(e):e},r=function(e,r,n){var i=e.name&&e.names;e.push&&!r[e.push]?r[e.push]=[]:i&&!r[e.name]&&(r[e.name]={});var o=e.push?{}:i?r[e.name]:r;!function(e,r,n,i){if(i&&!n)r[i]=t(e[1]);else for(var o=0;n.length>o;o+=1)null!=e[o+1]&&(r[n[o]]=t(e[o+1]))}(n.match(e.reg),o,e.names,e.name),e.push&&r[e.push].push(o)},n=grammarExports,i=RegExp.prototype.test.bind(/^([a-z])=(.*)/);e.parse=function(e){var t={},o=[],a=t;return e.split(/(\r\n|\r|\n)/).filter(i).forEach((function(e){var t=e[0],i=e.slice(2);"m"===t&&(o.push({rtp:[],fmtp:[]}),a=o[o.length-1]);for(var s=0;(n[t]||[]).length>s;s+=1){var c=n[t][s];if(c.reg.test(i))return r(c,a,i)}})),t.media=o,t};var o=function(e,r){var n=r.split(/=(.+)/,2);return 2===n.length?e[n[0]]=t(n[1]):1===n.length&&r.length>1&&(e[n[0]]=void 0),e};e.parseParams=function(e){return e.split(/;\s?/).reduce(o,{})},e.parseFmtpConfig=e.parseParams,e.parsePayloads=function(e){return(""+e).split(" ").map(Number)},e.parseRemoteCandidates=function(e){for(var r=[],n=e.split(" ").map(t),i=0;n.length>i;i+=3)r.push({component:n[i],ip:n[i+1],port:n[i+2]});return r},e.parseImageAttributes=function(e){return e.split(" ").map((function(e){return e.substring(1,e.length-1).split(",").reduce(o,{})}))},e.parseSimulcastStreamList=function(e){return e.split(";").map((function(e){return e.split(",").map((function(e){var r,n=!1;return"~"!==e[0]?r=t(e):(r=t(e.substring(1,e.length)),n=!0),{scid:r,paused:n}}))}))}}(parser$1);var grammar$1=grammarExports,formatRegExp=/%[sdv%]/g,format=function(e){var t=1,r=arguments,n=r.length;return e.replace(formatRegExp,(function(e){if(t>=n)return e;var i=r[t];switch(t+=1,e){case"%%":return"%";case"%s":return i+"";case"%d":return Number(i);case"%v":return""}}))},makeLine=function(e,t,r){var n=[e+"="+(t.format instanceof Function?t.format(t.push?r:r[t.name]):t.format)];if(t.names)for(var i=0;t.names.length>i;i+=1){n.push(t.name?r[t.name][t.names[i]]:r[t.names[i]])}else n.push(r[t.name]);return format.apply(null,n)},defaultOuterOrder=["v","o","s","i","u","e","p","c","b","t","r","z","a"],defaultInnerOrder=["i","c","b","a"],writer$1=function(e,t){t=t||{},null==e.version&&(e.version=0),null==e.name&&(e.name=" "),e.media.forEach((function(e){null==e.payloads&&(e.payloads="")}));var r=t.innerOrder||defaultInnerOrder,n=[];return(t.outerOrder||defaultOuterOrder).forEach((function(t){grammar$1[t].forEach((function(r){r.name in e&&null!=e[r.name]?n.push(makeLine(t,r,e)):r.push in e&&null!=e[r.push]&&e[r.push].forEach((function(e){n.push(makeLine(t,r,e))}))}))})),e.media.forEach((function(e){n.push(makeLine("m",grammar$1.m[0],e)),r.forEach((function(t){grammar$1[t].forEach((function(r){r.name in e&&null!=e[r.name]?n.push(makeLine(t,r,e)):r.push in e&&null!=e[r.push]&&e[r.push].forEach((function(e){n.push(makeLine(t,r,e))}))}))}))})),n.join("\r\n")+"\r\n"},parser=parser$1,writer=writer$1,grammar=grammarExports;function _createForOfIteratorHelper$a(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=_unsupportedIterableToArray$a(e))||t){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return e.length>n?{done:!1,value:e[n++]}:{done:!0}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function _unsupportedIterableToArray$a(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray$a(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray$a(e,t):void 0}}function _arrayLikeToArray$a(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);t>r;r++)n[r]=e[r];return n}function ownKeys$6(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function _objectSpread$6(e){for(var t=1;arguments.length>t;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ownKeys$6(Object(r),!0).forEach((function(t){_defineProperty(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ownKeys$6(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function _callSuper$d(e,t,r){return t=_getPrototypeOf$1(t),_possibleConstructorReturn$1(e,_isNativeReflectConstruct$d()?Reflect.construct(t,[],_getPrototypeOf$1(e).constructor):t.apply(e,r))}function _isNativeReflectConstruct$d(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(_isNativeReflectConstruct$d=function(){return!!e})()}lib.grammar=grammar,lib.write=writer,lib.parse=parser.parse,lib.parseParams=parser.parseParams,lib.parseFmtpConfig=parser.parseFmtpConfig,lib.parsePayloads=parser.parsePayloads,lib.parseRemoteCandidates=parser.parseRemoteCandidates,lib.parseImageAttributes=parser.parseImageAttributes,lib.parseSimulcastStreamList=parser.parseSimulcastStreamList;var Subscription=function(e){function t(e){var r;_classCallCheck$1(this,t),r=_callSuper$d(this,t),Object.defineProperty(r,"stream",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"resolutionInfo",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"ssrc",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"startTime",{enumerable:!0,configurable:!0,writable:!0,value:Date.now()}),Object.defineProperty(r,"uid",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"id",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"state",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"monitor",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"connection",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"signaling",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"_stream",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"reporter",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"metricsMap",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"audioStatsMap",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"videoStatsMap",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"transceiver",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"transceivers",{enumerable:!0,configurable:!0,writable:!0,value:void 0});var n=e.connection,i=e.stream,o=e.uid,a=e.resolutionInfo;return r.connection=n,r.resolutionInfo=a,r.signaling=n.signaling,r.stream=i,r.uid=o,r.reporter=n.reporter,r.connection.once("ended",(function(){r.clear()})),r.videoStatsMap=new Map,r.audioStatsMap=new Map,r.metricsMap=new Map,r.state=PubSubStates.Processing,r.handleStreamAdd=r.handleStreamAdd.bind(r),r.connection.on("track",r.handleStreamAdd),r}return _inherits$1(t,e),_createClass$1(t,[{key:"handleStreamAdd",value:function(e,t){var r,n=this,i=function(){n.reporter.trace.subscribe({init:!1,capabilities:n.stream.media,remoteStreamId:n.stream.id,remoteUserId:n.uid,sessionId:n.id,elapse:Date.now()-n.startTime,resolutionInfo:n.resolutionInfo}),n.startTime=Date.now()};if(clientConfig.audioSFU&&"audio"===e.kind){var o,a=null===(o=this.transceivers)||void 0===o?void 0:o.map((function(e){var t;return null===(t=e.receiver)||void 0===t||null===(t=t.track)||void 0===t?void 0:t.id}));null!=a&&a.includes(e.id)&&!this._stream&&(this._stream=t,i())}else e.id===(null===(r=this.transceiver)||void 0===r||null===(r=r.receiver)||void 0===r||null===(r=r.track)||void 0===r?void 0:r.id)&&(this._stream=new MediaStream([e]),i())}},{key:"mediaStream",get:function(){return this._stream||this.connection.mcuAudioStream}},{key:"stop",value:function(){var e=this;if(this.state===PubSubStates.Processing)return this.clear(),this.signaling.unsubscribe({subscriptionId:this.id}).catch((function(t){e.reporter.log.warn("negative ack for unsubscribing, ".concat(t))}))}},{key:"mute",value:function(e){return this.signaling.subscriptionControl({subscriptionId:this.id,operation:"pause",track:e})}},{key:"unmute",value:function(e){return this.signaling.subscriptionControl({subscriptionId:this.id,operation:"play",track:e})}},{key:"applyOptions",value:function(e){var t=this.stream.id;return this.resolutionInfo=e,this.signaling.subscriptionControl({subscriptionId:this.id,operation:"update",updateDesc:{video:{from:t,params:e}}})}},{key:"clear",value:function(){this.state!==PubSubStates.End&&(this.connection.off("track",this.handleStreamAdd),this.monitor&&(this.monitor.stop(),this.monitor.removeAllListeners(),this.monitor=null),this.metricsMap.clear(),this.audioStatsMap.clear(),this.videoStatsMap.clear(),this.state=PubSubStates.End,this.connection.reset(),this.emit("ended"))}},{key:"addTransceiver",value:function(e){this.monitor&&(this.monitor.stop(),this.monitor.removeAllListeners(),this.monitor=null),this.metricsMap.clear(),this.audioStatsMap.clear(),this.videoStatsMap.clear(),this.transceiver=e,this.monitor=new SubscribeMonitor(this),this.onMonitor()}},{key:"addTransceivers",value:function(e){this.monitor&&(this.monitor.stop(),this.monitor.removeAllListeners(),this.monitor=null),this.transceivers=e,this.monitor=new SubscribeMonitor(this),this.onMonitor()}},{key:"handleVideoFirstFrame",value:function(){this.reporter.trace.videoFirstFrame({sessionId:this.id,remoteStreamId:this.stream.id,attr_elapse_time:-1,remoteUserId:this.uid})}},{key:"handleMetrics",value:function(e,t){var r=e.audioMetrics,n=e.videoMetrics;if(r){var i,o=(null===(i=this.metricsMap.get(t))||void 0===i?void 0:i.audioMetrics)||{},a=getDeltaDurationInSeconds(r,o),s=getDelta(r.bytesReceived,o.bytesReceived);this.audioStatsMap.set(t,{codec:this.connection.peerConnectionStats.audioCodec||r.codec,receiveBytes:r.bytesReceived,receivePackets:r.packetsReceived,receivePacketsLost:r.packetsLost,rtt:r.roundTripTime,audioLevel:Math.max(r.audioLevel,0),timestamp:r.timestamp,receiveBitrate:8*s/a})}else if(n){var c,u=(null===(c=this.metricsMap.get(t))||void 0===c?void 0:c.videoMetrics)||{},l=getDeltaDurationInSeconds(n,u),d=getDelta(n.bytesReceived,u.bytesReceived),p={codec:this.connection.peerConnectionStats.videoCodec||n.codec,receiveResolution:{width:n.frameWidth,height:n.frameHeight},receiveBitrate:8*d/l,decodeFrameRate:Math.round(getDelta(null==n?void 0:n.framesDecoded,u.framesDecoded)/l),receiveFrameRate:Math.round(getDelta(null==n?void 0:n.framesReceived,u.framesReceived)/l),receiveBytes:n.bytesReceived,receivePackets:n.packetsReceived,receivePacketsLost:n.packetsLost,rtt:n.roundTripTime,timestamp:n.timestamp};this.videoStatsMap.set(t,p)}this.metricsMap.set(t,e)}},{key:"getMetrics",value:function(e){var t,r=this;return null===(t=this.connection)||void 0===t?void 0:t.getStats().then((function(){var t;null===(t=r.monitor)||void 0===t||t.getStats().then((function(t){return r.handleMetrics(t,e)}))}))}},{key:"onMonitor",value:function(){var e=this;"mcu"===this.uid?(this.monitor.on("audio-net-eq",(function(t){e.reporter.metric.audioNetEQ(_objectSpread$6({sessionId:e.id,remoteStreamId:e.stream.id,remoteUserId:e.uid},t))})),this.monitor.on("audio-recv-stream",(function(t){e.reporter.metric.audioRecvStream(_objectSpread$6({sessionId:e.id,remoteStreamId:e.stream.id,remoteUserId:e.uid},t))})),this.monitor.on("audio-first-packet",(function(){e.reporter.trace.audioFirstPacket({sessionId:e.id,remoteStreamId:e.stream.id,remoteUserId:e.uid})})),this.monitor.on("audio-first-frame",(function(){e.emit("audio-first-frame")}))):(this.monitor.on("video-first-packet",(function(){e.reporter.trace.videoFirstPacket({sessionId:e.id,remoteStreamId:e.stream.id,remoteUserId:e.uid})})),this.monitor.on("video-recv-stream",(function(t){e.reporter.metric.videoRecvStream(_objectSpread$6({sessionId:e.id,remoteStreamId:e.stream.id,remoteUserId:e.uid},t))})))}}])}(EventEmitter),prepareForBatchSubscribe=function(e){var t,r={audio:[],video:[]},n=_createForOfIteratorHelper$a(e);try{for(n.s();!(t=n.n()).done;){var i=t.value,o=i.stream;if(!i.error){var a=getSingleMediaOption(o,i.resolutionInfo),s=a.audio,c=a.video;if(s){var u=_objectSpread$6(_objectSpread$6({},s),{},{trackId:o.media.audio.trackId,ssrcGroup:[{ssrc:generateSubSsrc()}]});clientConfig.audioSFU&&(u.ssrcGroup=[,,,,,,].fill(0).map((function(){return{ssrc:generateSubSsrc()}}))),r.audio.push(u)}else if(c){var l,d;r.video.push(_objectSpread$6(_objectSpread$6({},c),{},{trackId:null===(l=o.media)||void 0===l||null===(l=l.video)||void 0===l?void 0:l.trackId,ssrcGroup:null===(d=o.media)||void 0===d||null===(d=d.video)||void 0===d?void 0:d.ssrcGroup,subSsrcGroup:{ssrc:generateSubSsrc(),rtxSsrc:generateSubSsrc()}}))}}}}catch(e){n.e(e)}finally{n.f()}return r},getSingleMediaOption=function(e,t){var r=e.id,n=e.media,i=n.video,o={};if(n.audio)o.audio={from:r};else if(i){var a;o.video={from:r,format:null===(a=n.video)||void 0===a?void 0:a.format,parameters:t}}return o},batchSubscribeStart=function(){var e=_asyncToGenerator$1(_regeneratorRuntime$1.mark((function e(t,r){var n,i,o,a,s;return _regeneratorRuntime$1.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=r.connection,i=[],o={},t.forEach((function(e,t){var n=e.stream,a=e.error,s=e.uid,c=e.resolutionInfo;if(i[t]={stream:n,error:a,uid:s,resolutionInfo:c},!a){var u=new Subscription(_objectSpread$6(_objectSpread$6({},r),{},{uid:s,resolutionInfo:c,stream:n}));o[n.id]=u}})),s=new Promise((function(e,r){a=function(){var a=_asyncToGenerator$1(_regeneratorRuntime$1.mark((function a(){var s;return _regeneratorRuntime$1.wrap((function(a){for(;;)switch(a.prev=a.next){case 0:return s=prepareForBatchSubscribe(t),a.next=3,adjustDownlinkSDPWhenSubscribe(n,s,o);case 3:n.signaling.batchSubscribe({connectionId:n.id,propertiesJsonStr:JSON.stringify({opusExtendInbandFec:!0,type:clientConfig.audioSFU?"selective":"mixed"}),supportTemporalLayer:!1,media:s}).then(function(){var r=_asyncToGenerator$1(_regeneratorRuntime$1.mark((function r(n){var a,s,c,u,l;return _regeneratorRuntime$1.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(a=n.detailStatus,"ok"===(s=n.globalStatus)){r.next=4;break}return i.forEach((function(e){e.error=e.error||parseSubscribeError(e.stream,s)})),r.abrupt("return",e(i));case 4:c=_createForOfIteratorHelper$a(a),r.prev=5,l=_regeneratorRuntime$1.mark((function e(){var r,n,a,s,c,l;return _regeneratorRuntime$1.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=(r=u.value).id,a=r.msg,c=o[(s=r.origin).id],l=t.findIndex((function(e){return e.stream.id===s.id})),"ok"===a&&c?(c.id=n,i[l].id=n,i[l].subscription=c):"ok"!==a&&(i[l].error=parseSubscribeError(c.stream,a));case 4:case"end":return e.stop()}}),e)})),c.s();case 8:if((u=c.n()).done){r.next=12;break}return r.delegateYield(l(),"t0",10);case 10:r.next=8;break;case 12:r.next=17;break;case 14:r.prev=14,r.t1=r.catch(5),c.e(r.t1);case 17:return r.prev=17,c.f(),r.finish(17);case 20:e(i);case 21:case"end":return r.stop()}}),r,null,[[5,14,17,20]])})));return function(e){return r.apply(this,arguments)}}()).catch(r);case 4:case"end":return a.stop()}}),a)})));return function(){return a.apply(this,arguments)}}()})),n.addTask(a),e.abrupt("return",s);case 7:case"end":return e.stop()}}),e)})));return function(t,r){return e.apply(this,arguments)}}(),batchSubscribeStop=function(){var e=_asyncToGenerator$1(_regeneratorRuntime$1.mark((function e(t,r){var n,i,o;return _regeneratorRuntime$1.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=r.connection,o=new Promise((function(e,r){n=function(){var n=_asyncToGenerator$1(_regeneratorRuntime$1.mark((function n(){var o,a;return _regeneratorRuntime$1.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return o=t.filter((function(e){var t;return!(null===(t=e.stream)||void 0===t||null===(t=t.media)||void 0===t||!t.audio)})).map((function(e){return e.id})),a=t.filter((function(e){var t;return!(null===(t=e.stream)||void 0===t||null===(t=t.media)||void 0===t||!t.video)})).map((function(e){return e.id})),n.next=4,adjustDownlinkSDPWhenUnsubscribe(i,t);case 4:i.signaling.batchUnSubscribe({connectionId:i.id,audio:o,video:a}).then((function(){t.forEach((function(e){e.state=PubSubStates.End,e.clear()})),e(void 0)})).catch(r);case 5:case"end":return n.stop()}}),n)})));return function(){return n.apply(this,arguments)}}()})),r.connection.addTask(n),e.abrupt("return",o);case 4:case"end":return e.stop()}}),e)})));return function(t,r){return e.apply(this,arguments)}}();function ownKeys$5(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function _objectSpread$5(e){for(var t=1;arguments.length>t;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ownKeys$5(Object(r),!0).forEach((function(t){_defineProperty(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ownKeys$5(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function _createForOfIteratorHelper$9(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=_unsupportedIterableToArray$9(e))||t){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return e.length>n?{done:!1,value:e[n++]}:{done:!0}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function _unsupportedIterableToArray$9(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray$9(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray$9(e,t):void 0}}function _arrayLikeToArray$9(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);t>r;r++)n[r]=e[r];return n}var optionzationMap={motion:"maintain-framerate",detail:"maintain-resolution",balanced:"balanced"},ssrcPrefix=0,ssrcMask=0,ssrcSeed=0,inUseSsrcSet=new Set,parseSubSsrcInfo=function(e,t){var r=Math.log2(e+1);t>2147483647>>r||(ssrcMask=e,ssrcPrefix=(t<<r|2147483648)>>>0)},generateSubSsrc=function(){if(0==ssrcPrefix||0==ssrcMask)return 0;var e=Math.min(ssrcMask+1,1e4);do{var t=ssrcPrefix+(ssrcMask&ssrcSeed++);if(0!=t&&!inUseSsrcSet.has(t))return t}while(--e>0);return 0},useSubSsrcGroup=function(e){e.ssrc&&inUseSsrcSet.add(e.ssrc),e.rtxSsrc&&inUseSsrcSet.add(e.rtxSsrc)},addRidsToMline=function(e,t){var r,n;if((null===(r=e.rids)||void 0===r?void 0:r.length)>1)return Environment.isFirefox()&&(t=addRidExtForFirefox(t)),t.rids=null===(n=e.rids)||void 0===n?void 0:n.map((function(e){return{direction:"recv",id:e.id}})),t.simulcast={dir1:"recv",list1:e.simulcast.list1},t},adjustUplinkSDPWhenPublish=function(){var e=_asyncToGenerator$1(_regeneratorRuntime$1.mark((function e(t,r){var n,i,o,a,s,c,u,l,d,p;return _regeneratorRuntime$1.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.pc,i=t.idToTransceiverMap,o=t.remoteSDP,a=new MediaStream(r.map((function(e){return e.getMediaStreamTrack()}))),s=r.map((function(e){var r={direction:"sendonly"};if(e instanceof LocalVideoTrack){var n=getVideoSenderEncodings(e).filter((function(e){return e.active}));r.sendEncodings=n.map((function(t){return{rid:t.rid||void 0,maxBitrate:1e3*t.maxBitrate,maxFramerate:t.maxFramerate,active:!clientConfig.simulcast||e.source===exports.VideoSourceInfo.SCREENCAST}}))}var o=t.pc.addTransceiver(e.getMediaStreamTrack()||e.trackMediaType,r);if(e instanceof LocalVideoTrack&&o.sender.setParameters){var a=e.optimizationMode,s=o.sender.getParameters();s.degradationPreference=optionzationMap[a]||"balanced",o.sender.setParameters(s)}return i.set(e.getTrackId(),o),o})),e.next=5,n.createOffer();case 5:return u=lib.parse((c=e.sent).sdp),e.next=9,n.setLocalDescription(c);case 9:t.localSDP=u,o.groups[0].mids=t.localSDP.groups[0].mids,l=_createForOfIteratorHelper$9(s),e.prev=12,p=_regeneratorRuntime$1.mark((function e(){var t,r,n,i;return _regeneratorRuntime$1.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=d.value,r=o.media.find((function(e){return e.type===t.sender.track.kind})),Environment.isFirefox()&&"video"===r.type&&(delete r.rids,delete r.simulcast),n=_objectSpread$5(_objectSpread$5({},r),{},{ext:_toConsumableArray(r.ext),mid:t.mid}),i=u.media.find((function(e){return e.mid==t.mid})),addRidsToMline(i,n),o.media.push(n);case 7:case"end":return e.stop()}}),e)})),l.s();case 15:if((d=l.n()).done){e.next=19;break}return e.delegateYield(p(),"t0",17);case 17:e.next=15;break;case 19:e.next=24;break;case 21:e.prev=21,e.t1=e.catch(12),l.e(e.t1);case 24:return e.prev=24,l.f(),e.finish(24);case 27:return e.next=29,n.setRemoteDescription({type:"answer",sdp:lib.write(o)});case 29:return t.remoteSDP=o,e.abrupt("return",{localSDP:t.localSDP,stream:a});case 31:case"end":return e.stop()}}),e,null,[[12,21,24,27]])})));return function(t,r){return e.apply(this,arguments)}}(),adjustUplinkSDPWhenUnpublish=function(){var e=_asyncToGenerator$1(_regeneratorRuntime$1.mark((function e(t,r){var n,i,o,a;return _regeneratorRuntime$1.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.pc,i=t.remoteSDP,r.map((function(e){return e.transceiver})).forEach((function(e){if(e){n.removeTrack(e.sender);var t=i.media.find((function(t){return t.mid==(null==e?void 0:e.mid)}));e.direction="inactive",t.direction="inactive"}})),e.next=5,n.createOffer();case 5:return a=lib.parse((o=e.sent).sdp),e.next=9,n.setLocalDescription(o);case 9:return t.localSDP=a,i.groups[0].mids=a.groups[0].mids,t.remoteSDP=i,e.next=14,n.setRemoteDescription({type:"answer",sdp:lib.write(i)});case 14:case"end":return e.stop()}}),e)})));return function(t,r){return e.apply(this,arguments)}}(),addSSRC=function(e,t,r){var n=e.ssrc,i=e.rtxSsrc;useSubSsrcGroup(e),t.ssrcGroups=[],i&&t.ssrcGroups.push({semantics:"FID",ssrcs:"".concat(n," ").concat(i)}),t.ssrcs=[],[n,i].filter((function(e){return void 0!==e})).forEach((function(e){t.ssrcs.push({attribute:"msid",value:"".concat(r," v").concat(n),id:e},{attribute:"cname",value:createUuid(),id:e})}))},addRidExtForFirefox=function(e){var t;return null!=e&&null!==(t=e.ext)&&void 0!==t&&t.some((function(e){return e.uri.includes("rtp-stream-id")}))||e.ext.push({value:8,uri:"urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id"},{value:9,uri:"urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id"}),e},adjustDownlinkSDPWhenSubscribe=function(){var e=_asyncToGenerator$1(_regeneratorRuntime$1.mark((function e(t,r,n){var i,o,a,s,c,u,l,d,p,f,h,m,g,y,v,_,b,E,S,T,R,O,C,k,I,w,P;return _regeneratorRuntime$1.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(a=t.pc,s=t.idToTransceiverMap,u=t.idToTransceiversMap,l=(c=t.remoteSDP).media.find((function(e){return"video"===e.type})),d=c.media.find((function(e){return"audio"===e.type})),p=null===(i=l.ssrcs)||void 0===i?void 0:i.find((function(e){return"msid"===e.attribute})).value.split(" ")[0],null!==(o=r.audio)&&void 0!==o&&o[0])if(h=null===(f=r.audio)||void 0===f?void 0:f[0],m=h.from,clientConfig.audioSFU){if(u.get(m)){g=_createForOfIteratorHelper$9(u.get(m));try{for(g.s();!(y=g.n()).done;)y.value.direction="recvonly"}catch(e){g.e(e)}finally{g.f()}v=c.media.filter((function(e){return"audio"===e.type})),_=_createForOfIteratorHelper$9(v);try{for(_.s();!(b=_.n()).done;)b.value.direction="sendonly"}catch(e){_.e(e)}finally{_.f()}}else t.mcuAudioTranceivers=[,,,,,,].fill(0).map((function(e){return t.pc.addTransceiver("audio",{direction:"recvonly"})})),u.set(m,t.mcuAudioTranceivers);n[m].addTransceivers(u.get(m))}else s.get(m)||s.set(m,t.mcuAudioTranceiver),s.get(m).direction="recvonly",d.direction="sendonly",n[m].addTransceiver(s.get(m));E=_createForOfIteratorHelper$9(r.video),e.prev=6,T=_regeneratorRuntime$1.mark((function e(){var t,r,i;return _regeneratorRuntime$1.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=s.get(t=S.value.from)){e.next=7;break}s.set(t,a.addTransceiver("video",{direction:"recvonly"})),e.next=19;break;case 7:if("inactive"===r.direction){e.next=18;break}return r.direction="inactive",e.next=11,a.createOffer();case 11:return i=e.sent,e.next=14,a.setLocalDescription(i);case 14:return c.media.find((function(e){return e.mid==r.mid})).direction="inactive",e.next=18,a.setRemoteDescription({type:"answer",sdp:lib.write(c)});case 18:s.get(t).direction="recvonly";case 19:n[t].addTransceiver(s.get(t));case 20:case"end":return e.stop()}}),e)})),E.s();case 9:if((S=E.n()).done){e.next=13;break}return e.delegateYield(T(),"t0",11);case 11:e.next=9;break;case 13:e.next=18;break;case 15:e.prev=15,e.t1=e.catch(6),E.e(e.t1);case 18:return e.prev=18,E.f(),e.finish(18);case 21:return e.next=23,a.createOffer();case 23:return O=lib.parse((R=e.sent).sdp),c.groups[0].mids=O.groups[0].mids,e.next=28,a.setLocalDescription(R);case 28:t.localSDP=O,clientConfig.audioSFU&&r.audio[0]&&(k=(C=r.audio[0]).ssrcGroup,u.get(C.from).forEach((function(e,t){var r,n=null===(r=k[t])||void 0===r?void 0:r.ssrc,i=c.media.find((function(t){return t.mid==e.mid&&"audio"===t.type}));i||(i=_objectSpread$5(_objectSpread$5({},d),{},{mid:e.mid}),c.media.push(i)),i.ssrcs=getSsrcInfo(n,p),i.direction="sendonly"}))),I=_createForOfIteratorHelper$9(r.video),e.prev=31,P=_regeneratorRuntime$1.mark((function e(){var t,r,i,o,a;return _regeneratorRuntime$1.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i=(t=w.value).subSsrcGroup,o=s.get(r=t.from),(a=c.media.find((function(e){return e.mid==o.mid&&"video"===e.type})))||((a=_objectSpread$5({},l)).mid=o.mid,c.media.push(a)),a.direction="sendonly",n[r].ssrc=null==i?void 0:i.ssrc,addSSRC(i,a,p);case 8:case"end":return e.stop()}}),e)})),I.s();case 34:if((w=I.n()).done){e.next=38;break}return e.delegateYield(P(),"t2",36);case 36:e.next=34;break;case 38:e.next=43;break;case 40:e.prev=40,e.t3=e.catch(31),I.e(e.t3);case 43:return e.prev=43,I.f(),e.finish(43);case 46:return t.remoteSDP=c,e.next=49,a.setRemoteDescription({type:"answer",sdp:lib.write(c)});case 49:case"end":return e.stop()}}),e,null,[[6,15,18,21],[31,40,43,46]])})));return function(t,r,n){return e.apply(this,arguments)}}(),adjustDownlinkSDPWhenUnsubscribe=function(){var e=_asyncToGenerator$1(_regeneratorRuntime$1.mark((function e(t,r){var n,i,o,a,s,c,u,l,d,p,f,h;return _regeneratorRuntime$1.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=t.pc,i=t.remoteSDP,o=[],a=_createForOfIteratorHelper$9(r);try{for(a.s();!(s=a.n()).done;)l=(c=s.value).transceivers,(u=c.transceiver)?o.push(u):l&&o.push.apply(o,_toConsumableArray(l))}catch(e){a.e(e)}finally{a.f()}return o.forEach((function(e){e.direction="inactive"})),e.next=7,n.createOffer();case 7:return d=e.sent,e.next=10,n.setLocalDescription(d);case 10:t.localSDP=lib.parse(d.sdp),p=_regeneratorRuntime$1.mark((function e(){var t;return _regeneratorRuntime$1.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=h[f],i.media.find((function(e){return e.mid==t.mid})).direction="inactive";case 3:case"end":return e.stop()}}),e)})),f=0,h=o;case 13:if(h.length<=f){e.next=18;break}return e.delegateYield(p(),"t0",15);case 15:f++,e.next=13;break;case 18:return t.remoteSDP=i,e.next=21,n.setRemoteDescription({type:"answer",sdp:lib.write(i)});case 21:case"end":return e.stop()}}),e)})));return function(t,r){return e.apply(this,arguments)}}(),adjustRemoteSDPWhenFailover=function(e,t){var r=t.media.find((function(e){return"audio"===e.type})),n=t.media.find((function(e){return"video"===e.type}));return e.media.forEach((function(t,i){var o=t.mid,a=t.ssrcGroups,s=void 0===a?[]:a,c=t.ssrcs,u=void 0===c?[]:c,l=t.rids,d=void 0===l?[]:l;"audio"===t.type?e.media[i]=_objectSpread$5(_objectSpread$5({},r),{},{mid:o,ssrcs:u}):"video"===t.type&&(e.media[i]=_objectSpread$5(_objectSpread$5({},n),{},{mid:o,ssrcGroups:s,ssrcs:u}),d.length&&(e.media[i].rids=d,e.media[i].simulcast={dir1:"recv",list1:d.map((function(e){return"~".concat(e.id)})).join(";")}))})),e},adjustLocalSDPWhenFailover=function(e,t){var r=t.media;return e.media.forEach((function(e){var t=e.mid,n=e.ssrcGroups,i=void 0===n?[]:n,o=e.ssrcs,a=void 0===o?[]:o,s=e.type,c=r.findIndex((function(e){return e.mid==t&&e.type===s}));c>-1&&(r[c]=_objectSpread$5(_objectSpread$5({},r[c]),{},{ssrcGroups:i,ssrcs:a}))})),t},getSsrcInfo=function(e,t){return[{attribute:"msid",value:"".concat(t," v").concat(e),id:e},{attribute:"cname",value:createUuid(),id:e}]},remoteSDPAdaptor=function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"all",i=t.direction,o=t.remoteSDP,a=lib.parse(e);"relay"===n&&a.media.forEach((function(e){e.candidates=e.candidates.filter((function(e){return isPrivateIP(e.ip)}))})),r&&(a=adjustRemoteSDPWhenFailover(o,a));var s=a.media.find((function(e){return"video"===e.type}));if("uplink"===i&&Environment.isFirefox()&&clientConfig.simulcast&&(s.ext=s.ext.filter((function(e){return!e.uri.includes("rtp-stream-id")}))),!s.ssrcs&&"downlink"===i){var c=generateSubSsrc();s.ssrcs=getSsrcInfo(c,a.msidSemantic.token)}return t.remoteSDP=a,a},localSDPAdaptor=function(e,t){var r=t.direction,n=["uplink"===r,"downlink"===r&&"macOS"===Environment.system&&Environment.isChrome()],i=lib.parse(e);if(n.some((function(e){return e}))&&(i=removeProfileByPrefix(i,"64")),Environment.isFirefox()&&(i=removeProfileOfUnsetPacketzationMode(i)),"uplink"===r&&Environment.isFirefox()&&clientConfig.simulcast){var o=i.media.find((function(e){return"video"===e.type}));addRidExtForFirefox(o)}return t.localSDP=i,i},adjustOfferWhenFailover=function(e){var t=e.remoteSDP,r=e.sessionManager,n=e.mcuAudioTranceiver,i=e.pc,o=e.idToTransceiverMap,a=e.idToTransceiversMap,s=e.direction,c=e.localSDP.media.slice(2),u=_toConsumableArray(r.sessions.values());if("downlink"===s){var l=t.media.slice(2),d=u.filter((function(e){return e instanceof Subscription})),p=d.find((function(e){var t;return"admin"===(null===(t=e.stream)||void 0===t||null===(t=t.info)||void 0===t?void 0:t.owner)}));p&&!clientConfig.audioSFU&&(o.set(p.id,n),p.addTransceiver(n));var f=[];c.forEach((function(e){var t={direction:e.direction},r=l.find((function(t){return t.type===e.type&&e.mid==t.mid})),n=d.find((function(e){return(null==e?void 0:e.ssrc)===(null==r?void 0:r.ssrcs[0].id)})),a=i.addTransceiver(e.type,t);"recvonly"===e.direction&&("video"===e.type&&n?(o.set(n.stream.id,a),n.addTransceiver(a)):"audio"===e.type&&f.push(a))})),f.length&&p&&(e.mcuAudioTranceivers=f,a.set(p.id,f),p.addTransceivers(f))}else{var h=u.filter((function(e){return e instanceof Publication}));c.forEach((function(e){var t={direction:e.direction},r=h.find((function(t){return t.mid==e.mid}));if("sendonly"===e.direction&&r){var n=r.tracks[0],a=(null==n?void 0:n.getMediaStreamTrack())||(null==n?void 0:n.trackMediaType);if(n instanceof LocalVideoTrack){var s=getVideoSenderEncodings(n).filter((function(e){return e.active}));t.sendEncodings=s.map((function(e){return{rid:e.rid||void 0,maxBitrate:1e3*e.maxBitrate,maxFramerate:e.maxFramerate,active:!clientConfig.simulcast||n.source===exports.VideoSourceInfo.SCREENCAST}}))}var c=i.addTransceiver(a,t);o.set(n.getTrackId(),c),r.addTransceiver(c)}else i.addTransceiver(e.type,t)}))}},removePayloadTypes=function(e,t){if(e){var r,n=e.fmtp,i=e.payloads,o=e.rtp,a=e.rtcpFb,s=[],c={},u=_createForOfIteratorHelper$9(n);try{for(u.s();!(r=u.n()).done;){var l=r.value,d=l.payload,p=l.config.split(";");c[d]={};var f,h=_createForOfIteratorHelper$9(p);try{for(h.s();!(f=h.n()).done;){var m=_slicedToArray(f.value.split("="),2);c[d][m[0]]=m[1]}}catch(e){h.e(e)}finally{h.f()}}}catch(e){u.e(e)}finally{u.f()}for(var g in c){var y=c[g];(t(y)||s.includes(+y.apt))&&s.push(parseInt(g))}if(s.length){for(var v=n.length-1;v>=0;v--){s.includes(n[v].payload)&&n.splice(v,1)}for(var _=o.length-1;_>=0;_--)s.includes(o[_].payload)&&o.splice(_,1);for(var b=a.length-1;b>=0;b--)s.includes(a[b].payload)&&a.splice(b,1);e.payloads=i.split(" ").map(Number).filter((function(e){return!s.includes(e)})).join(" ")}}},removeProfileByPrefix=function(e,t){var r=e.media.find((function(e){return"video"===e.type}));return removePayloadTypes(r,(function(e){var r;return null===(r=e["profile-level-id"])||void 0===r?void 0:r.includes(t)})),e},removeProfileOfUnsetPacketzationMode=function(e){var t=e.media.find((function(e){return"video"===e.type}));return removePayloadTypes(t,(function(e){return e["profile-level-id"]&&!e["packetization-mode"]})),e};function ownKeys$4(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function _objectSpread$4(e){for(var t=1;arguments.length>t;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ownKeys$4(Object(r),!0).forEach((function(t){_defineProperty(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ownKeys$4(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function _createForOfIteratorHelper$8(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=_unsupportedIterableToArray$8(e))||t){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return e.length>n?{done:!1,value:e[n++]}:{done:!0}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function _unsupportedIterableToArray$8(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray$8(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray$8(e,t):void 0}}function _arrayLikeToArray$8(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);t>r;r++)n[r]=e[r];return n}function _callSuper$c(e,t,r){return t=_getPrototypeOf$1(t),_possibleConstructorReturn$1(e,_isNativeReflectConstruct$c()?Reflect.construct(t,[],_getPrototypeOf$1(e).constructor):t.apply(e,r))}function _isNativeReflectConstruct$c(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(_isNativeReflectConstruct$c=function(){return!!e})()}var Publication=function(e){function t(e){var r;_classCallCheck$1(this,t),r=_callSuper$c(this,t),Object.defineProperty(r,"uid",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"connection",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"tracks",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"id",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"signaling",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"transceiver",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"metricsMap",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"audioStatsMap",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"videoStatsMap",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"state",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"reporter",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"mid",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(r,"encodings",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"feedbackIndex",{enumerable:!0,configurable:!0,writable:!0,value:-1}),Object.defineProperty(r,"monitor",{enumerable:!0,configurable:!0,writable:!0,value:void 0});var n=e.connection,i=e.uid,o=e.tracks,a=void 0===o?[]:o;return r.tracks=a,r.connection=n,r.signaling=n.signaling,r.uid=i,r.reporter=n.reporter,r.state=PubSubStates.Idle,r.videoStatsMap=new Map,r.audioStatsMap=new Map,r.metricsMap=new Map,r.handleTracEvent=r.handleTracEvent.bind(r),a.forEach((function(e){e.on(TRACK_EVENT_NAME,r.handleTracEvent)})),r.encodings=getVideoSenderEncodings(a[0]),r.state=PubSubStates.Processing,r.connection.once("ended",(function(){r.clear()})),r}return _inherits$1(t,e),_createClass$1(t,[{key:"stop",value:function(){var e=this;return this.state!==PubSubStates.Processing?Promise.resolve():batchPublishStop([this],{connection:this.connection}).catch((function(t){e.clear(),e.reporter.log.warn("negative ack for unpublish, ".concat(tryJsonStringify(t)))}))}},{key:"mute",value:function(){if(this.tracks.length&&this.state===PubSubStates.Processing){var e=this.tracks[0].trackMediaType;return this.reporter.trace.localControl(e,!0,this.id),this.signaling.streamControl({streamId:this.id,operation:"pause",data:e})}}},{key:"unmute",value:function(){if(this.tracks.length&&this.state===PubSubStates.Processing){var e=this.tracks[0].trackMediaType;return this.reporter.trace.localControl(e,!1,this.id),this.signaling.streamControl({streamId:this.id,operation:"play",data:e})}}},{key:"initInner",value:function(e){this.id=e;var t=this.tracks[0];this.addTransceiver(this.connection.idToTransceiverMap.get(t.getTrackId())),"video"===t.trackMediaType&&t.config.mirror&&this.handleMirror(t.config.mirror)}},{key:"handleMirror",value:function(e){return this.signaling.setStreamProperties({streamId:this.id,propertiesJsonStr:JSON.stringify({mirror:!!e})})}},{key:"handleTracEvent",value:function(e,t){var r,n=this,i={replace:function(){return n.replaceTrack(t.getMediaStreamTrack())},mute:function(){return n.mute()},unmute:function(){return n.unmute()},republish:function(){n.stop().then((function(){n.connection.sessionManager.channel.client.publish([t])}))},stop:function(){return n.stop()},optimizationMode:function(){return n.updateOptionzationMode()},mirror:function(){return n.handleMirror(t)}};return null===(r=i[e])||void 0===r?void 0:r.call(i)}},{key:"clear",value:function(){var e=this;this.state!==PubSubStates.End&&(this.monitor&&(this.monitor.stop(),this.monitor.removeAllListeners(),this.monitor=null),this.tracks.forEach((function(t){t.off(TRACK_EVENT_NAME,e.handleTracEvent)})),this.tracks=[],this.metricsMap.clear(),this.audioStatsMap.clear(),this.videoStatsMap.clear(),this.connection.reset(),this.state=PubSubStates.End,this.emit("ended"))}},{key:"applyOptions",value:function(e){var t=this,r=e[0],n=r.index,i=r.bitrate;if(n>=this.feedbackIndex&&this.state===PubSubStates.Processing){this.feedbackIndex=n;var o,a=0===i,s=this.transceiver,c=!1,u=!1,l=s.sender.getParameters(),d=e.map((function(e){return e.rid})),p=_createForOfIteratorHelper$8(l.encodings);try{for(p.s();!(o=p.n()).done;){var f,h=o.value,m=_createForOfIteratorHelper$8(e);try{var g=function(){var e=f.value,r=t.encodings.find((function(t){return t.rid===e.rid}));if(e.rid!==h.rid&&h.rid||h.active||a||(h.active=!0,h.scaleResolutionDownBy=r.scaleResolutionDownBy,c=!0),e.rid===h.rid&&!a){var n=Math.max(Math.min(e.bitrate,r.maxBitrate),r.minBitrate);n!==Math.round(h.maxBitrate/1e3)&&(h.maxBitrate=1e3*n,u=!0)}};for(m.s();!(f=m.n()).done;)g()}catch(e){m.e(e)}finally{m.f()}!h.active||d.includes(h.rid)&&!a||(h.active=!1,c=!0)}}catch(e){p.e(e)}finally{p.f()}(c||u)&&s.sender.setParameters(l)}}},{key:"updateOptionzationMode",value:function(){var e;if(this.tracks[0]instanceof LocalVideoTrack&&null!==(e=this.transceiver)&&void 0!==e&&null!==(e=e.sender)&&void 0!==e&&e.setParameters){var t=this.tracks[0].optimizationMode,r=this.transceiver.sender.getParameters();r.degradationPreference=optionzationMap[t]||"balanced",this.transceiver.sender.setParameters(r)}}},{key:"addTransceiver",value:function(e){this.monitor&&(this.monitor.stop(),this.monitor.removeAllListeners(),this.monitor=null),this.metricsMap.clear(),this.audioStatsMap.clear(),this.videoStatsMap.clear(),this.transceiver=e,this.mid||(this.mid=null==e?void 0:e.mid),this.state=PubSubStates.Processing,this.feedbackIndex=-1,this.monitor=new PublishMonitor(this),this.onMonitor()}},{key:"replaceTrack",value:function(e){var t;this.transceiver&&(null===(t=this.transceiver.sender.track)||void 0===t||t.stop(),this.transceiver.sender.replaceTrack(e))}},{key:"handleMetrics",value:function(e,t){var r=e.audioMetrics,n=e.videoMetrics;if(r){var i,o=(null===(i=this.metricsMap.get(t))||void 0===i?void 0:i.audioMetrics)||{},a=getDeltaDurationInSeconds(r,o),s=getDelta(r.bytesSent,o.bytesSent);this.audioStatsMap.set(t,{codec:this.connection.peerConnectionStats.audioCodec||r.codec,sendBytes:r.bytesSent,audioLevel:Math.max(r.audioLevel,0),sendPackets:r.packetsSent,sendPacketsLost:r.packetsLost,sampleRate:r.sampleRate,channelCount:r.channels,rtt:this.connection.peerConnectionStats.roundTripTime||r.roundTripTime,timestamp:r.timestamp,sendBitrate:8*s/a})}else if(n){var c,u,l=((null===(c=this.transceiver)||void 0===c||null===(c=c.sender)||void 0===c?void 0:c.getParameters())||{}).encodings,d=void 0===l?[]:l,p=(null===(u=this.metricsMap.get(t))||void 0===u?void 0:u.videoMetrics)||{},f=getDeltaDurationInSeconds(n,p),h=getDelta(n.totalBytesSent,p.totalBytesSent),m={codec:this.connection.peerConnectionStats.videoCodec||n.codec,sendFrameRate:Math.round(n.sendFramesPerSecond),captureFrameRate:n.captureFramesPerSecond,encodeFrameRate:n.encodeFramesPerSecond,qpSum:n.totalQpSum||0,targetBitrate:n.targetBitrate,encodeLayers:d.length,sendLayers:d.filter((function(e){return e.active})).length,outgingBitrate:n.availableOutgoingBitrate,sendResolution:{width:n.maxSendFrameWidth,height:n.maxSendFrameHeight},captureResolution:{width:n.captureFrameWidth,height:n.captureFrameHeight},sendBytes:n.totalBytesSent,sendPackets:n.totalPacketsSent,sendPacketsLost:n.totalPacketsLost,timestamp:n.timestamp,rtt:this.connection.peerConnectionStats.roundTripTime||n.roundTripTime,sendBitrate:8*h/f};this.videoStatsMap.set(t,m)}this.metricsMap.set(t,e)}},{key:"getMetrics",value:function(e){var t,r=this;return null===(t=this.connection)||void 0===t?void 0:t.getStats().then((function(){var t;null===(t=r.monitor)||void 0===t||t.getStats().then((function(t){return r.handleMetrics(t,e)}))}))}},{key:"onMonitor",value:function(){var e=this;this.monitor.on("audio-send-stream",(function(t){e.reporter.metric.audioSendStream(_objectSpread$4({sessionId:e.id},t))})),this.monitor.on("video-send-stream",(function(t){e.reporter.metric.videoSendStream(_objectSpread$4({sessionId:e.id},t))})),this.monitor.on("bwe",(function(t){e.reporter.metric.bwe(_objectSpread$4({sessionId:e.id},t))}))}}])}(EventEmitter),prepareForPublish=function(){var e=_asyncToGenerator$1(_regeneratorRuntime$1.mark((function e(t,r){var n,i,o,a,s,c=arguments;return _regeneratorRuntime$1.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=c.length>2&&void 0!==c[2]?c[2]:["common"],i={},e.next=4,adjustUplinkSDPWhenPublish(r,t);case 4:return a=(o=e.sent).localSDP,s=o.stream,t.forEach((function(e){var t=e.getTrackId(),o=a.media.find((function(e){return e.mid==r.idToTransceiverMap.get(t).mid}));if("audio"===e.trackMediaType)i.audio=[{source:"mic",autoMix:n,trackId:t,msid:s.id,uplinkSsrcGroup:[{ssrc:Number(o.ssrcs[0].id)}]}];else if(e instanceof LocalVideoTrack){var c;i.video=i.video||[];var u=e.trackSettings,l=o.ssrcGroups,d=void 0===l?[]:l,p=getVideoSenderEncodings(e);p.length>1&&(d=p.map((function(){return{semantics:"FID",ssrcs:"".concat(generateSubSsrc()," ").concat(generateSubSsrc())}})));var f=d.filter((function(e){return"FID"===e.semantics})).map((function(e){return{ssrc:Number(e.ssrcs.split(" ")[0]),rtxSsrc:Number(e.ssrcs.split(" ")[1])}})),h={trackId:e.getTrackId(),forwardOnly:e.source===exports.VideoSourceInfo.SCREENCAST,msid:s.id,mid:"".concat(o.mid),uplinkSsrcGroup:f,source:e.source||exports.VideoSourceInfo.CAMERA,streamParameters:{ssrc:null==f||null===(c=f[0])||void 0===c?void 0:c.ssrc,bitrate:"".concat(p[p.length-1].maxBitrate),resolution:{width:u.width,height:u.height},framerate:u.frameRate},ssrcParameters:f.map((function(e,t){var r;return{ssrc:e.ssrc,active:p[t].active,tlayer:1,bitrate:p[t].maxBitrate,rid:(null===(r=p[t])||void 0===r?void 0:r.rid)||void 0,maxBitrate:p[t].maxBitrate,minBitrate:p[t].minBitrate,framerate:p[t].maxFramerate,resolution:{width:p[t].targetWidth,height:p[t].targetHeight}}}))};i.video.push(h)}})),e.abrupt("return",i);case 9:case"end":return e.stop()}}),e)})));return function(t,r){return e.apply(this,arguments)}}(),batchPublishStart=function(e){var t,r=e.tracks,n=e.connection,i=e.labels,o=r.map((function(t){return{publication:new Publication(_objectSpread$4(_objectSpread$4({},e),{},{tracks:[t]})),track:t}})),a=new Promise((function(e,a){t=function(){var t=_asyncToGenerator$1(_regeneratorRuntime$1.mark((function t(){return _regeneratorRuntime$1.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,prepareForPublish(r,n,i);case 2:return t.abrupt("return",n.signaling.batchPublish({connectionId:n.id,media:t.sent,simulcast:clientConfig.simulcast,simulcastVersion:"1.0",clientType:"web",supportTemporalLayer:!1,type:"webrtc"}).then(function(){var t=_asyncToGenerator$1(_regeneratorRuntime$1.mark((function t(r){var n,i,a,s,c;return _regeneratorRuntime$1.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=r.detailStatus,"ok"===(i=r.globalStatus)){t.next=4;break}return o.forEach((function(e){e.error=parsePublishError(e.track,i)})),t.abrupt("return",e(o));case 4:a=_createForOfIteratorHelper$8(n),t.prev=5,c=_regeneratorRuntime$1.mark((function e(){var t,r,n,i,a,c;return _regeneratorRuntime$1.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=(t=s.value).id,n=t.origin,i=t.msg,a=o.findIndex((function(e){return e.track.getTrackId()===n.id})),c=(o[a]||{}).publication,"ok"===i&&c?c.initInner(r):"ok"!==i&&(o[a].error=parsePublishError(o[a].track,i));case 4:case"end":return e.stop()}}),e)})),a.s();case 8:if((s=a.n()).done){t.next=12;break}return t.delegateYield(c(),"t0",10);case 10:t.next=8;break;case 12:t.next=17;break;case 14:t.prev=14,t.t1=t.catch(5),a.e(t.t1);case 17:return t.prev=17,a.f(),t.finish(17);case 20:e(o);case 21:case"end":return t.stop()}}),t,null,[[5,14,17,20]])})));return function(e){return t.apply(this,arguments)}}()).catch((function(e){a(e)})));case 5:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}()}));return n.addTask(t),a},batchPublishStop=function(){var e=_asyncToGenerator$1(_regeneratorRuntime$1.mark((function e(t,r){var n,i;return _regeneratorRuntime$1.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=new Promise((function(e,i){n=function(){var n=_asyncToGenerator$1(_regeneratorRuntime$1.mark((function n(){var o,a;return _regeneratorRuntime$1.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return o=t.filter((function(e){var t;return"audio"===(null===(t=e.tracks)||void 0===t||null===(t=t[0])||void 0===t?void 0:t.trackMediaType)})).map((function(e){return e.id})),a=t.filter((function(e){var t;return"video"===(null===(t=e.tracks)||void 0===t||null===(t=t[0])||void 0===t?void 0:t.trackMediaType)})).map((function(e){return e.id})),n.next=4,adjustUplinkSDPWhenUnpublish(r.connection,t);case 4:r.connection.signaling.batchUnPublish({connectionId:r.connection.id,audio:o,video:a}).then((function(){t.forEach((function(e){e.clear(),e.state=PubSubStates.End})),e(void 0)})).catch(i);case 5:case"end":return n.stop()}}),n)})));return function(){return n.apply(this,arguments)}}()})),r.connection.addTask(n),e.abrupt("return",i);case 3:case"end":return e.stop()}}),e)})));return function(t,r){return e.apply(this,arguments)}}();function _callSuper$b(e,t,r){return t=_getPrototypeOf$1(t),_possibleConstructorReturn$1(e,_isNativeReflectConstruct$b()?Reflect.construct(t,[],_getPrototypeOf$1(e).constructor):t.apply(e,r))}function _isNativeReflectConstruct$b(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(_isNativeReflectConstruct$b=function(){return!!e})()}var initPeerConnectionMetrics={audioCodec:"",videoCodec:"",roundTripTime:-1,availableOutgoingBitrate:-1},PeerConnectionMonitor=function(e){function t(e){var r;return _classCallCheck$1(this,t),r=_callSuper$b(this,t),Object.defineProperty(r,"connectionMetrics",{enumerable:!0,configurable:!0,writable:!0,value:Object.assign({},initPeerConnectionMetrics)}),Object.defineProperty(r,"pc",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),r.pc=e.pc,r}return _inherits$1(t,e),_createClass$1(t,[{key:"extractMetrics",value:function(e){var t=Object.assign({},initPeerConnectionMetrics),r="";return e.forEach((function(e){var n;if(!e.isRemote)if(/local-candidate/i.test(e.type)&&e.id===r)Environment.networkType=(null!==(n=e.networkType)&&void 0!==n?n:Environment.networkType).replace("vpn","unknown");else if(/candidate-pair/i.test(e.type)&&"succeeded"===e.state)r=e.localCandidateId,Environment.isFirefox()||(t.roundTripTime=1e3*(e.currentRoundTripTime||e.totalRoundTripTime/e.responsesReceived)),void 0!==e.availableOutgoingBitrate&&(t.availableOutgoingBitrate=e.availableOutgoingBitrate);else if(/codec/i.test(e.type)){var i,o;null!==(i=e.mimeType)&&void 0!==i&&i.includes("audio")?t.audioCodec=e.mimeType.replace("audio/",""):null!==(o=e.mimeType)&&void 0!==o&&o.includes("video")&&(t.videoCodec=e.mimeType.replace("video/",""))}})),this.connectionMetrics=Object.assign({},t),this.connectionMetrics}},{key:"makeReport",value:function(){var e=this;this.getStats().then((function(t){e.emit("metrics",t)}))}},{key:"getStats",value:function(){var e=this;if(!this.pc)return Promise.resolve({});if(!this.pc.getStats)throw new DingRTCError(ErrorCode.BrowserNotSupported,"getStats is not supported");return this.pc.getStats(null).then((function(t){return e.extractMetrics(t)}))}}])}(Monitor);function _createForOfIteratorHelper$7(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=_unsupportedIterableToArray$7(e))||t){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return e.length>n?{done:!1,value:e[n++]}:{done:!0}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function _unsupportedIterableToArray$7(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray$7(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray$7(e,t):void 0}}function _arrayLikeToArray$7(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);t>r;r++)n[r]=e[r];return n}function _callSuper$a(e,t,r){return t=_getPrototypeOf$1(t),_possibleConstructorReturn$1(e,_isNativeReflectConstruct$a()?Reflect.construct(t,[],_getPrototypeOf$1(e).constructor):t.apply(e,r))}function _isNativeReflectConstruct$a(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(_isNativeReflectConstruct$a=function(){return!!e})()}var icePolicyMap={uplink:"",downlink:""},PeerConnection=function(e){function t(e){var r;_classCallCheck$1(this,t),r=_callSuper$a(this,t),Object.defineProperty(r,"pc",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"pendingTask",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"signaling",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"state",{enumerable:!0,configurable:!0,writable:!0,value:PeerConnectionState.New}),Object.defineProperty(r,"exchangeSdpTask",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"monitor",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"peerConnectionTimer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"createPeerConnectionPromise",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"peerConnectionStats",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"reporter",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"createPeerConnectionTimer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"mcuAudioStream",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"idToTransceiverMap",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"mcuAudioTranceiver",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"idToTransceiversMap",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"mcuAudioTranceivers",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"localSDP",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"remoteSDP",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"sessionManager",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"prevId",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(r,"offerSDP",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"clientFailoverTimer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"audioSfuSsrcs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"id",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"enquenTask",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"direction",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"onIceGatheringStateChange",{enumerable:!0,configurable:!0,writable:!0,value:function(e){r.reporter.log.debug("ice gathering state: ".concat(e.target.iceGatheringState))}}),r.pc=null;var n=e.direction,i=e.sessionManager;return r.signaling=i.channel.signaling,r.sessionManager=i,r.reporter=i.reporter,r.enquenTask=taskQueue(),r.direction=n,r.idToTransceiverMap=new Map,r.idToTransceiversMap=new Map,r.createPeerConnection(),r.id="".concat(r.direction,"_").concat(createUuid()),r.startSinglePC().then((function(){r.state=PeerConnectionState.Idle,r.enquenTask.start()})),r}return _inherits$1(t,e),_createClass$1(t,[{key:"startSinglePC",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return"uplink"===this.direction?(this.pc.addTransceiver("audio",{direction:"sendonly"}),this.pc.addTransceiver("video",{direction:"sendonly"})):(this.mcuAudioStream=null,this.mcuAudioTranceiver=this.pc.addTransceiver("audio",{direction:"recvonly"}),this.pc.addTransceiver("video",{direction:"recvonly"})),e&&adjustOfferWhenFailover(this),this.exchangeSDP(e)}},{key:"stopSinglePC",value:function(){return arguments.length>0&&void 0!==arguments[0]&&arguments[0]||this.emit("ended"),this.signaling.closePeerConnection({connectionId:this.id,direction:"downlink"===this.direction?"out":"in"})}},{key:"reset",value:function(){this.pendingTask&&(this.pendingTask=null)}},{key:"closePeerConnection",value:function(){this.pc&&(this.reporter.log.debug("sessionId ".concat(this.id,": clear RTC PeerConnection.")),this.detachEvents(),"closed"!==this.pc.signalingState&&this.pc.close(),this.pc=null)}},{key:"onTrack",value:function(e){var t=e.track;"audio"===t.kind?clientConfig.audioSFU?this.emit("track",t,e.streams[0]):this.mcuAudioStream=new MediaStream([t]):this.emit("track",t)}},{key:"fireEndedEvent",value:function(){this.state!==PeerConnectionState.Ended&&(this.state=PeerConnectionState.Ended,this.emit("ended"))}},{key:"onIceConnectionStateChange",value:function(){var e=this.pc.iceConnectionState;this.reporter.log.debug("sessionId ".concat(this.id,": ICE connection state changed to ").concat(e))}},{key:"handleClientReoffer",value:(r=_asyncToGenerator$1(_regeneratorRuntime$1.mark((function e(){return _regeneratorRuntime$1.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.state!==PeerConnectionState.New){e.next=2;break}return e.abrupt("return",Promise.reject());case 2:return this.reporter.log.debug("sessionId ".concat(this.id,": start client reoffer process")),e.prev=3,e.next=6,this.stopSinglePC(!0);case 6:this.removeAllListeners(),e.next=12;break;case 9:e.prev=9,e.t0=e.catch(3),this.reporter.log.debug("sessionId ".concat(this.id,": client reoffer close failed ").concat(tryJsonStringify(e.t0)));case 12:this.closePeerConnection();case 13:case"end":return e.stop()}}),e,this,[[3,9]])}))),function(){return r.apply(this,arguments)})},{key:"addTask",value:function(e){this.enquenTask.add(e)}},{key:"onConnectionStateChange",value:function(){var e=this,t=this.pc.connectionState;this.reporter.trace.connectionsEvent(this.id,t),"failed"===t||"closed"===t?(this.clientFailoverTimer&&removeTimer(this.clientFailoverTimer),this.clientFailoverTimer=addTimer((function(){e.state!==PeerConnectionState.New&&e.emit("reoffer")}),SIGNAL_CALL_TIMEOUT)):"connected"===t&&(this.clientFailoverTimer&&(removeTimer(this.clientFailoverTimer),this.clientFailoverTimer=null),this.createPeerConnectionTimer&&(removeTimer(this.createPeerConnectionTimer),this.createPeerConnectionTimer=null))}},{key:"getPeerConnectionConfig",value:function(){var e=this.sessionManager.channel.iceConfig,t=e.username,r=e.password,n=e.port,i=e.iceServerList,o={bundlePolicy:"max-bundle",iceTransportPolicy:i.length?"relay":"all",sdpSemantics:"unified-plan"};if(i.length){var a,s=[],c=_createForOfIteratorHelper$7(i);try{for(c.s();!(a=c.n()).done;){var u=a.value;s.push("turn:".concat(u,":").concat(n,"?transport=udp"),"turn:".concat(u,":").concat(n,"?transport=tcp"))}}catch(e){c.e(e)}finally{c.f()}Environment.isFirefox()&&s.splice(4,2),"relay"===icePolicyMap[this.direction]&&(icePolicyMap[this.direction]="all",o.iceTransportPolicy="all"),o.iceServers=[{urls:s,username:t,credential:r}]}return icePolicyMap[this.direction]=o.iceTransportPolicy,this.reporter.log.debug("PeerConnectionConfig",o),o}},{key:"createPeerConnection",value:function(){var e=this;this.pc?this.reporter.log.warn("sessionId ".concat(this.id,": A PeerConnection was created. Cannot create again for the same PeerConnectionChannel.")):(this.pc=new RTCPeerConnection(this.getPeerConnectionConfig()),this.attachEvents(),this.createPeerConnectionTimer=addTimer((function(){var t;"connected"===(null===(t=e.pc)||void 0===t?void 0:t.connectionState)||e.exchangeSdpTask||e.emit("reoffer")}),CREATE_PC_TIMEOUT))}},{key:"attachEvents",value:function(){var e=this;this.pc&&(this.pc.ontrack=function(t){e.onTrack(t)},this.pc.oniceconnectionstatechange=function(){e.onIceConnectionStateChange()},this.pc.onconnectionstatechange=function(){e.onConnectionStateChange()},this.pc.onicegatheringstatechange=function(t){e.onIceGatheringStateChange(t)},this.monitor=new PeerConnectionMonitor(this),this.monitor.on("metrics",(function(t){e.peerConnectionStats=t})))}},{key:"getStats",value:function(){var e,t,r=this;return this.monitor?null===(e=this.monitor)||void 0===e||null===(t=e.getStats)||void 0===t?void 0:t.call(e).then((function(e){r.peerConnectionStats=e})):Promise.resolve()}},{key:"detachEvents",value:function(){this.createPeerConnectionTimer&&removeTimer(this.createPeerConnectionTimer),this.clientFailoverTimer&&removeTimer(this.clientFailoverTimer),this.pc&&(this.pc.ontrack=null,this.pc.oniceconnectionstatechange=null,this.pc.onconnectionstatechange=null,this.pc.onicegatheringstatechange=null,this.monitor.stop(),this.monitor.removeAllListeners(),this.monitor=null)}},{key:"startTask",value:function(){var e=this;return new Promise((function(t,r){e.pendingTask={resolve:t,reject:r},e.exchangeSDP(),addTimer((function(){var t;e.pendingTask&&e.state===PeerConnectionState.Processing&&(null===(t=e.pendingTask)||void 0===t||t.reject(),e.fireEndedEvent())}),SUB_PUB_TIMEOUT)}))}},{key:"exchangeSDP",value:function(){var e,t=this,r=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return new Promise((function(n,i){t.exchangeSdpTask={resolve:n,reject:i},t.pc.createOffer().then((function(n){return e=n,r&&(e.sdp=lib.write(adjustLocalSDPWhenFailover(t.localSDP,lib.parse(e.sdp)))),t.pc.setLocalDescription(e).catch((function(e){throw t.reporter.log.error("sessionId ".concat(t.id,": Failed to create offer or set SDP. Message: ").concat(e.message,")}")),e}))})).then((function(){t.reporter.log.debug("sessionId ".concat(t.id,": set local sdp success"));var n=localSDPAdaptor(e.sdp,t);e.sdp=lib.write(n),t.offerSDP=n,e.sdp=lib.write(n);var i,o={direction:"downlink"!==t.direction?"in":"out",sdpOffer:e.sdp,connectionId:t.id,isFailover:r,optionsJsonStr:JSON.stringify({supportCVO:1})};if(r){var a=lib.parse(e.sdp);a.media=a.media.slice(0,2),a.groups=[{mids:"0 1",type:"BUNDLE"}],o.sdpOffer=lib.write(a)}return tryTimes({key:"createPeerConnection_".concat(t.direction),fn:(i=_asyncToGenerator$1(_regeneratorRuntime$1.mark((function e(){var n;return _regeneratorRuntime$1.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("connected"===(null===(n=t.sessionManager)||void 0===n||null===(n=n.channel)||void 0===n||null===(n=n.client)||void 0===n?void 0:n.connectionState)){e.next=2;break}return e.abrupt("return");case 2:if(o.isFailover||!t.prevId){e.next=7;break}return e.next=5,t.stopSinglePC(!0);case 5:t.id="".concat(t.direction,"_").concat(createUuid()),o.connectionId=t.id;case 7:return t.prevId=t.id,e.abrupt("return",t.signaling.createPeerConnection(o).then((function(e){var n=remoteSDPAdaptor(e.sdpAnswer,t,r,icePolicyMap[t.direction]);t.pc.setRemoteDescription({sdp:lib.write(n),type:"answer"}).then((function(){var e;t.reporter.log.debug("sessionId ".concat(t.id,": receive answer success")),null===(e=t.exchangeSdpTask)||void 0===e||e.resolve(),t.exchangeSdpTask=void 0})).catch((function(e){var r,n;t.reporter.log.error("sessionId ".concat(t.id,": Set remote description failed: ").concat(e)),null===(r=t.exchangeSdpTask)||void 0===r||r.reject(e),t.exchangeSdpTask=void 0,null===(n=t.pendingTask)||void 0===n||n.reject(new DingRTCError(ErrorCode.IceConnectionAnswerFail)),t.fireEndedEvent()}))})));case 9:case"end":return e.stop()}}),e)}))),function(){return i.apply(this,arguments)}),times:3,interval:2e3})})).catch((function(e){var r,n;t.reporter.log.error("sessionId ".concat(t.id,": Failed to create offer or set SDP. Message: ").concat(e.message)),null===(r=t.pendingTask)||void 0===r||r.reject(new DingRTCError(ErrorCode.IceConnectionSetLocalDescFail)),t.fireEndedEvent(),null===(n=t.exchangeSdpTask)||void 0===n||n.reject(e),t.exchangeSdpTask=void 0}))}))}},{key:"reoffer",value:function(){var e=this;return this.state===PeerConnectionState.New?Promise.reject():(this.reporter.log.debug("sessionId ".concat(this.id,": start reoffer process")),this.closePeerConnection(),this.idToTransceiverMap=new Map,this.idToTransceiversMap=new Map,this.createPeerConnection(),this.state=PeerConnectionState.New,this.startSinglePC(!0).then((function(){e.state=PeerConnectionState.Idle,e.enquenTask.start()})))}}]);var r}(EventEmitter);function ownKeys$3(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function _objectSpread$3(e){for(var t=1;arguments.length>t;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ownKeys$3(Object(r),!0).forEach((function(t){_defineProperty(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ownKeys$3(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function _createForOfIteratorHelper$6(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=_unsupportedIterableToArray$6(e))||t){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return e.length>n?{done:!1,value:e[n++]}:{done:!0}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function _unsupportedIterableToArray$6(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray$6(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray$6(e,t):void 0}}function _arrayLikeToArray$6(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);t>r;r++)n[r]=e[r];return n}function _callSuper$9(e,t,r){return t=_getPrototypeOf$1(t),_possibleConstructorReturn$1(e,_isNativeReflectConstruct$9()?Reflect.construct(t,[],_getPrototypeOf$1(e).constructor):t.apply(e,r))}function _isNativeReflectConstruct$9(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(_isNativeReflectConstruct$9=function(){return!!e})()}var SessionManager=function(e){function t(e,r){var n;return _classCallCheck$1(this,t),n=_callSuper$9(this,t),Object.defineProperty(n,"client",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(n,"sessions",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(n,"networkQualityInterval",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(n,"lastChannelNetworkQuality",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(n,"uplink",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(n,"downlink",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(n,"streamIdToSessionId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(n,"channel",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(n,"reporter",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),n.channel=r,n.client=e,n.reporter=r.reporter,n.streamIdToSessionId=new Map,n.sessions=new Map,n.handleMediaMessage=n.handleMediaMessage.bind(n),n.handleServerFailover=n.handleServerFailover.bind(n),n.handleRepulish=n.handleRepulish.bind(n),n.handleResubscribe=n.handleResubscribe.bind(n),n}return _inherits$1(t,e),_createClass$1(t,[{key:"getOrCreatePeerConnection",value:function(e){var t=this;return"uplink"===e?(this.uplink||(this.uplink=new PeerConnection({direction:e,sessionManager:this}),this.uplink.on("reoffer",this.handleRepulish),this.uplink.on("ended",(function(){t.uplink=null}))),this.uplink):(this.downlink||(this.downlink=new PeerConnection({direction:e,sessionManager:this}),this.downlink.on("reoffer",this.handleResubscribe),this.downlink.on("ended",(function(){t.downlink=null}))),this.downlink)}},{key:"handleRepulish",value:(l=_asyncToGenerator$1(_regeneratorRuntime$1.mark((function e(){var t,r,n,i,o,a,s;return _regeneratorRuntime$1.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=_toConsumableArray(this.client.localTracks),n=_createForOfIteratorHelper$6(this.sessions.values());try{for(n.s();!(i=n.n()).done;)(o=i.value)instanceof Publication&&o.state===PubSubStates.Processing&&(o.clear(),this.sessions.delete(o.id))}catch(e){n.e(e)}finally{n.f()}return this.client.emit("media-reconnect-start",this.client.userId),a=null===(t=this.uplink)||void 0===t?void 0:t.id,e.prev=5,this.reporter.trace.connectionsEvent(a,"clientReofferStart"),e.next=9,null===(s=this.uplink)||void 0===s?void 0:s.handleClientReoffer();case 9:if(this.uplink=null,this.reporter.log.info("".concat(this.client.userId," republish ").concat(r.map((function(e){return e.trackMediaType})).join()," start")),!r.length){e.next=14;break}return e.next=14,this.batchPublish(r);case 14:this.reporter.trace.connectionsEvent(a,"clientReofferSuccess"),this.client.emit("media-reconnect-end",this.client.userId),e.next=24;break;case 18:e.prev=18,e.t0=e.catch(5),this.reporter.log.debug("".concat(this.client.userId," republish failed for ").concat(tryJsonStringify(e.t0))),this.reporter.trace.connectionsEvent(a,"clientReofferFailed"),this.client.emit("media-reconnect-end",this.client.userId),this.channel.signaling.emit("connection-state-change","disconnected",this.client.connectionState,"network_error");case 24:case"end":return e.stop()}}),e,this,[[5,18]])}))),function(){return l.apply(this,arguments)})},{key:"handleResubscribe",value:(u=_asyncToGenerator$1(_regeneratorRuntime$1.mark((function e(){var t,r,n,i,o,a,s,c,u,l,d,p,f,h,m,g=arguments;return _regeneratorRuntime$1.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=g.length>0&&void 0!==g[0]&&g[0],n=[],i=_createForOfIteratorHelper$6(this.sessions.values());try{for(i.s();!(o=i.n()).done;)(a=o.value)instanceof Subscription&&a.state===PubSubStates.Processing&&(n.push({stream:a.stream,uid:a.uid}),a.clear(),this.sessions.delete(a.id))}catch(e){i.e(e)}finally{i.f()}return s=r?"server":"client",c=n.map((function(e){return e.uid})).join(),this.client.emit("media-reconnect-start",c),this.reporter.log.info("resubscribe ".concat(c," start")),u=null===(t=this.downlink)||void 0===t?void 0:t.id,e.prev=9,this.reporter.trace.connectionsEvent(u,"".concat(s,"ReofferStart")),e.next=13,null===(l=this.downlink)||void 0===l?void 0:l.handleClientReoffer();case 13:if(this.downlink=null,!n.length){e.next=20;break}return e.next=17,this.batchSubscribe(n);case 17:d=_createForOfIteratorHelper$6(e.sent);try{for(d.s();!(p=d.n()).done;)m=(f=p.value).error,(h=f.subscription)&&!m&&this.handleSubscribeReoffer(h)}catch(e){d.e(e)}finally{d.f()}case 20:this.reporter.trace.connectionsEvent(u,"".concat(s,"ReofferSuccess")),this.client.emit("media-reconnect-end",c),e.next=30;break;case 24:e.prev=24,e.t0=e.catch(9),this.reporter.log.debug("".concat(this.client.userId," resubscribe failed for ").concat(tryJsonStringify(e.t0))),this.reporter.trace.connectionsEvent(u,"".concat(s,"ReofferFailed")),this.client.emit("media-reconnect-end",c),this.channel.signaling.emit("connection-state-change","disconnected",this.client.connectionState,"network_error");case 30:case"end":return e.stop()}}),e,this,[[9,24]])}))),function(){return u.apply(this,arguments)})},{key:"getSessionByStreamId",value:function(e){return this.sessions.get(this.streamIdToSessionId.get(e))}},{key:"handleSubscribeReoffer",value:function(e){var t,r=e.uid,n=e.mediaStream,i=(null===(t=e.stream.media.video)||void 0===t?void 0:t.source)===exports.VideoSourceInfo.SCREENCAST,o=n.getAudioTracks()[0],a=n.getVideoTracks()[0],s=o?"audio":i?"screen":"camera";if(this.reporter.log.debug("".concat(r," resubscribe ").concat(s," success")),o&&this.channel.remoteAudioTrack){var c,u;if(clientConfig.audioSFU)null===(c=(u=this.channel.remoteAudioTrack).replaceStream)||void 0===c||c.call(u,n);else this.channel.remoteAudioTrack.replaceTrack(o)}else{var l=this.channel.userManager.remoteUsers.find((function(e){return e.userId===r}));a&&null!=l&&l.auxiliaryTrack&&i?l.auxiliaryTrack.replaceTrack(a):a&&null!=l&&l.videoTrack&&!i&&l.videoTrack.replaceTrack(a)}}},{key:"handleServerFailover",value:function(e){var t=this;this.reporter.log.debug("serverFailover ".concat(JSON.stringify(e)));var r,n=e.actions,i=_createForOfIteratorHelper$6(void 0===n?[]:n);try{var o=function(){var e,n,i=r.value,o=i.connectionId;if("reoffer"!==i.actionName)return 1;if(o===(null===(e=t.uplink)||void 0===e?void 0:e.id)){var a=t.uplink,s=t.client,c=s.userId,u=s.localTracks;t.client.emit("media-reconnect-start",c),t.reporter.trace.connectionsEvent(o,"serverReofferStart"),a.reoffer().then((function(){t.reporter.log.info("".concat(c," republish ").concat(u.map((function(e){return e.trackMediaType})).join()," success")),t.reporter.trace.connectionsEvent(o,"serverReofferSuccess"),t.client.emit("media-reconnect-end",c)})).catch((function(e){t.reporter.log.debug("".concat(t.client.userId," resubscribe failed for ").concat(tryJsonStringify(e))),t.reporter.trace.connectionsEvent(o,"serverReofferFailed"),t.channel.signaling.emit("connection-state-change","disconnected",t.client.connectionState,"network_error")}))}else o===(null===(n=t.downlink)||void 0===n?void 0:n.id)&&t.handleResubscribe(!0)};for(i.s();!(r=i.n()).done;)o()}catch(e){i.e(e)}finally{i.f()}}},{key:"addSession",value:function(e,t){this.sessions.set(t.id,t),this.streamIdToSessionId.set(e,t.id)}},{key:"getNetworkQuality",value:function(e,t){return e>50||t>600?NetworkQualityType.BAD:e>30||t>450?NetworkQualityType.POOR:e>20||t>300?NetworkQualityType.NORMAL:e>10||t>200?NetworkQualityType.GOOD:0>e&&0>t?NetworkQualityType.UNKNOWN:NetworkQualityType.GREAT}},{key:"checkChannelNetworkQuality",value:(c=_asyncToGenerator$1(_regeneratorRuntime$1.mark((function e(){var t,r=this;return _regeneratorRuntime$1.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(0!==(t=_toConsumableArray(this.sessions.values())).length){e.next=4;break}return this.emit("network-quality",NetworkQualityType.UNKNOWN,NetworkQualityType.UNKNOWN),e.abrupt("return");case 4:if(0!==t.filter((function(e){var t,r=e.connection;return"connected"===(null==r||null===(t=r.pc)||void 0===t?void 0:t.connectionState)})).length){e.next=8;break}return this.emit("network-quality",NetworkQualityType.DISCONNECTED,NetworkQualityType.DISCONNECTED),e.abrupt("return");case 8:Promise.all([this.getLocalVideoStats(),this.getLocalAudioStats(),this.getRemoteAudioStats(),this.getRemoteVideoStats()]).then((function(e){var t=_slicedToArray(e,4),n=t[0],i=t[1],o=t[2],a=t[3],s=0,c=0,u=0,l=0,d=0,p=0;if(n){var f=n.camera,h=n.auxiliary;f&&(c+=f.sendPacketsLost,s+=f.sendPackets,d=Math.max(d,f.rtt||0)),h&&(c+=h.sendPacketsLost,s+=h.sendPackets,d=Math.max(d,h.rtt||0))}for(var m in i&&(c+=i.sendPacketsLost||0,s+=i.sendPackets||0,d=Math.max(d,i.rtt||0)),o&&(u+=o.receivePacketsLost||0,l+=o.receivePackets||0,p=Math.max(p,o.rtt||0)),a){var g=a[m],y=g.camera,v=g.auxiliary;y&&(u+=y.receivePacketsLost,l+=y.receivePackets,p=Math.max(p,y.rtt||0)),v&&(u+=v.receivePacketsLost,l+=v.receivePackets,p=Math.max(p,v.rtt||0))}var _=-1,b=-1,E={timestamp:Date.now(),totalUplinkPacketsLost:c,totalUplinkPacketsSent:s,totalDownlinkPacketsLost:u,totalDownlinkPacketsRecv:l};if(s){var S,T,R=c-((null===(S=r.lastChannelNetworkQuality)||void 0===S?void 0:S.totalUplinkPacketsLost)||0);if(0>R&&(R=c),E.totalUplinkPacketsSentForLost=(null===(T=r.lastChannelNetworkQuality)||void 0===T?void 0:T.totalUplinkPacketsSentForLost)||0,0!==R){var O;E.totalUplinkPacketsSentForLost=s;var C=s-((null===(O=r.lastChannelNetworkQuality)||void 0===O?void 0:O.totalUplinkPacketsSentForLost)||0);0>C&&(C=s),_=R/C}}if(l){var k,I,w,P=u-((null===(k=r.lastChannelNetworkQuality)||void 0===k?void 0:k.totalDownlinkPacketsLost)||0);0>P&&(P=u),E.totalDownlinkPacketsRecvForLost=(null===(I=r.lastChannelNetworkQuality)||void 0===I?void 0:I.totalDownlinkPacketsRecvForLost)||0,P&&(u!==((null===(w=r.lastChannelNetworkQuality)||void 0===w?void 0:w.totalDownlinkPacketsLost)||0)&&(E.totalDownlinkPacketsRecvForLost=l),b=P/l)}r.emit("network-quality",r.getNetworkQuality(Math.min(100*_,100),d),r.getNetworkQuality(Math.min(100*b,100),p)),r.lastChannelNetworkQuality=E}));case 9:case"end":return e.stop()}}),e,this)}))),function(){return c.apply(this,arguments)})},{key:"removeSession",value:function(e,t){t&&(e=this.streamIdToSessionId.get(t),this.streamIdToSessionId.delete(t));var r=this.sessions.get(e);r&&(r.clear(),this.sessions.delete(e))}},{key:"batchPublish",value:function(e,t){var r=this,n=Date.now();return batchPublishStart({uid:this.client.userId,tracks:e,connection:this.getOrCreatePeerConnection("uplink"),labels:t}).then((function(e){var t,i=_createForOfIteratorHelper$6(e);try{var o=function(){var e=t.value,i=e.publication,o=e.track;e.error?r.reporter.trace.publish(!1,o,"",Date.now()-n):(r.addSession(o.getTrackId(),i),r.reporter.trace.publish(!0,o,i.id,Date.now()-n),r.reporter.trace.publish(!1,o,i.id,Date.now()-n),i.on("ended",(function(){r.removeSession(i.id)})))};for(i.s();!(t=i.n()).done;)o()}catch(e){i.e(e)}finally{i.f()}}))}},{key:"batchUnPublish",value:function(e){var t=this;return e.length?batchPublishStop(e,{connection:this.getOrCreatePeerConnection("uplink")}).then((function(){var r,n=_createForOfIteratorHelper$6(e);try{for(n.s();!(r=n.n()).done;){var i,o,a,s=r.value;t.streamIdToSessionId.delete(null===(i=s.tracks)||void 0===i||null===(i=i[0])||void 0===i||null===(o=(a=i).getTrackId)||void 0===o?void 0:o.call(a)),t.removeSession(s.id)}}catch(e){n.e(e)}finally{n.f()}})):Promise.resolve()}},{key:"batchSubscribe",value:function(e){var t=this,r=Date.now(),n=0,i=function(e){return batchSubscribeStart(e,{connection:t.getOrCreatePeerConnection("downlink")}).then(function(){var r=_asyncToGenerator$1(_regeneratorRuntime$1.mark((function r(o){var a,s,c,u;return _regeneratorRuntime$1.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:for(a=new Map,s=[],c=0;o.length>c;c++)"RoomBusy"===(null===(u=o[c].error)||void 0===u?void 0:u.message)&&(s.push(e[c]),a.set(s.length-1,c));if(!s.length||n>3){r.next=12;break}return n++,r.next=7,awaitTime(1);case 7:if("connected"!==t.client.connectionState){r.next=12;break}return r.next=10,i(s);case 10:r.sent.forEach((function(e,t){var r=a.get(t);o[r]=e}));case 12:return r.abrupt("return",o);case 13:case"end":return r.stop()}}),r)})));return function(e){return r.apply(this,arguments)}}())};return i(e).then((function(e){var n,i=_createForOfIteratorHelper$6(e);try{var o=function(){var e=n.value,i=e.error,o=e.subscription,a=e.id,s=e.stream,c=e.uid,u=e.resolutionInfo;o&&(t.reporter.trace.subscribe({init:!0,capabilities:s.media,remoteStreamId:s.id,remoteUserId:c,elapse:Date.now()-r,sessionId:a,resolutionInfo:u}),"mcu"===o.uid&&t.reporter.trace.subscribe({init:!1,capabilities:s.media,remoteStreamId:s.id,remoteUserId:c,elapse:Date.now()-r,sessionId:o.id,resolutionInfo:u}),t.addSession(s.id,o),o.on("ended",(function(){t.removeSession(a)}))),i&&t.reporter.trace.subscribe({init:!1,capabilities:(null==s?void 0:s.media)||{},remoteStreamId:null==s?void 0:s.id,remoteUserId:c,elapse:Date.now()-r,sessionId:"",resolutionInfo:u})};for(i.s();!(n=i.n()).done;)o()}catch(e){i.e(e)}finally{i.f()}return e}))}},{key:"batchUnscribe",value:(s=_asyncToGenerator$1(_regeneratorRuntime$1.mark((function e(t){var r,n,i,o=this;return _regeneratorRuntime$1.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=Array(t.length),n=[],i={},t.forEach((function(e,t){var o=e.error,a=e.stream,s=e.session;o?r[t]={error:o}:(i[null==a?void 0:a.id]=t,n.push(s))})),e.abrupt("return",batchSubscribeStop(n,{connection:this.getOrCreatePeerConnection("downlink")}).then((function(){for(var e=0,t=n;t.length>e;e++)o.removeSession(t[e].id)})));case 5:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"clear",value:function(){var e,t,r=this;this.sessions.forEach((function(e){r.removeSession(e.id)})),null===(e=this.uplink)||void 0===e||e.closePeerConnection(),this.uplink=null,null===(t=this.downlink)||void 0===t||t.closePeerConnection(),this.downlink=null,this.streamIdToSessionId.clear(),this.networkQualityInterval&&(removeTimer(this.networkQualityInterval,"interval"),this.networkQualityInterval=null),this.channel.signaling.off("media-message",this.handleMediaMessage),this.channel.signaling.off("serverFailover",this.handleServerFailover)}},{key:"start",value:function(){this.startNetworkQualityTimer(),this.uplink=this.getOrCreatePeerConnection("uplink"),this.downlink=this.getOrCreatePeerConnection("downlink"),this.channel.signaling.on("media-message",this.handleMediaMessage),this.channel.signaling.on("serverFailover",this.handleServerFailover)}},{key:"startNetworkQualityTimer",value:function(){var e=this;this.networkQualityInterval=addTimer((function(){navigator&&void 0!==navigator.onLine&&!navigator.onLine?e.emit("network-quality",NetworkQualityType.DISCONNECTED,NetworkQualityType.DISCONNECTED):"connected"!==e.client.connectionState?e.emit("network-quality",NetworkQualityType.BAD,NetworkQualityType.BAD):"connected"===e.client.connectionState?e.checkChannelNetworkQuality():e.emit("network-quality",NetworkQualityType.UNKNOWN,NetworkQualityType.UNKNOWN)}),NETWORK_QUALITY_TIMEOUT,"interval")}},{key:"getLocalAudioStats",value:(a=_asyncToGenerator$1(_regeneratorRuntime$1.mark((function e(){var t,r,n,i=arguments;return _regeneratorRuntime$1.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=i.length>0&&void 0!==i[0]?i[0]:"network",n=_toConsumableArray(this.sessions.values()).filter((function(e){var t,r;return e instanceof Publication&&"connected"===(null===(t=e.connection)||void 0===t||null===(t=t.pc)||void 0===t?void 0:t.connectionState)&&"audio"===(null===(r=e.tracks)||void 0===r||null===(r=r[0])||void 0===r?void 0:r.trackMediaType)})),e.next=4,Promise.all(n.map((function(e){return e.getMetrics(r)})));case 4:return e.abrupt("return",(null===(t=n[0])||void 0===t?void 0:t.audioStatsMap.get(r))||{});case 5:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"getLocalVideoStats",value:(o=_asyncToGenerator$1(_regeneratorRuntime$1.mark((function e(){var t,r,n,i,o,a,s,c,u,l,d,p,f=arguments;return _regeneratorRuntime$1.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=f.length>0&&void 0!==f[0]?f[0]:"network",i=_toConsumableArray(this.sessions.values()).filter((function(e){var t;return e instanceof Publication&&"connected"===(null===(t=e.connection)||void 0===t||null===(t=t.pc)||void 0===t?void 0:t.connectionState)&&"video"===e.tracks[0].trackMediaType})),e.next=4,Promise.all(i.map((function(e){return e.getMetrics(n)})));case 4:o=function(e){var t;return(null==e||null===(t=e.fmtp)||void 0===t?void 0:t.filter((function(e){var t;return null==e||null===(t=e.config)||void 0===t?void 0:t.includes("profile-level-id")})).map((function(e){var t,r=(null==e||null===(t=e.config)||void 0===t?void 0:t.split(";"))||[],n=r.findIndex((function(e){return e.includes("profile-level-id")}));return r[n].split("=")[1]})))||[]},a=null===(t=this.uplink)||void 0===t||null===(t=t.offerSDP)||void 0===t||null===(t=t.media)||void 0===t?void 0:t.find((function(e){return"video"===e.type})),s=null===(r=this.downlink)||void 0===r||null===(r=r.offerSDP)||void 0===r||null===(r=r.media)||void 0===r?void 0:r.find((function(e){return"video"===e.type})),c={uplinkProfile:_toConsumableArray(new Set(o(a))),downlinkProfile:_toConsumableArray(new Set(o(s)))},u=_createForOfIteratorHelper$6(i),e.prev=9,u.s();case 11:if((l=u.n()).done){e.next=21;break}if(p=(d=l.value).videoStatsMap.get(n)){e.next=16;break}return e.abrupt("continue",19);case 16:c[d.tracks[0].source===exports.VideoSourceInfo.SCREENCAST?"auxiliary":"camera"]=p;case 19:e.next=11;break;case 21:e.next=26;break;case 23:e.prev=23,e.t0=e.catch(9),u.e(e.t0);case 26:return e.prev=26,u.f(),e.finish(26);case 29:return e.abrupt("return",c);case 30:case"end":return e.stop()}}),e,this,[[9,23,26,29]])}))),function(){return o.apply(this,arguments)})},{key:"getRemoteVideoStats",value:(i=_asyncToGenerator$1(_regeneratorRuntime$1.mark((function e(){var t,r,n,i,o,a,s,c,u,l,d,p=arguments;return _regeneratorRuntime$1.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=p.length>0&&void 0!==p[0]?p[0]:"network",r=_toConsumableArray(this.sessions.values()).filter((function(e){var t;return e instanceof Subscription&&"connected"===(null===(t=e.connection)||void 0===t||null===(t=t.pc)||void 0===t?void 0:t.connectionState)&&e.stream.media.video})),e.next=4,Promise.all(r.map((function(e){return e.getMetrics(t)})));case 4:n={},i=_createForOfIteratorHelper$6(r),e.prev=6,i.s();case 8:if((o=i.n()).done){e.next=17;break}if(c=(s=o.value).uid,u=s.stream,l=s.videoStatsMap.get(t)){e.next=13;break}return e.abrupt("continue",15);case 13:d=(null===(a=u.media.video)||void 0===a?void 0:a.source)===exports.VideoSourceInfo.SCREENCAST?"auxiliary":"camera",n[c]=_objectSpread$3(_objectSpread$3({},n[c]||{}),{},_defineProperty({},d,l));case 15:e.next=8;break;case 17:e.next=22;break;case 19:e.prev=19,e.t0=e.catch(6),i.e(e.t0);case 22:return e.prev=22,i.f(),e.finish(22);case 25:return e.abrupt("return",n);case 26:case"end":return e.stop()}}),e,this,[[6,19,22,25]])}))),function(){return i.apply(this,arguments)})},{key:"getRemoteAudioStats",value:(n=_asyncToGenerator$1(_regeneratorRuntime$1.mark((function e(){var t,r,n,i=arguments;return _regeneratorRuntime$1.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=i.length>0&&void 0!==i[0]?i[0]:"network",n=_toConsumableArray(this.sessions.values()).filter((function(e){var t;return e instanceof Subscription&&"connected"===(null===(t=e.connection)||void 0===t||null===(t=t.pc)||void 0===t?void 0:t.connectionState)&&e.stream.media.audio})),e.next=4,Promise.all(n.map((function(e){return e.getMetrics(r)})));case 4:return e.abrupt("return",(null===(t=n[0])||void 0===t?void 0:t.audioStatsMap.get(r))||{});case 5:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"handleMediaMessage",value:(r=_asyncToGenerator$1(_regeneratorRuntime$1.mark((function e(t){var r,n,i,o,a;return _regeneratorRuntime$1.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.reporter.log.debug("remote feedback: ".concat(t.payload)),r=JSON.parse(t.payload),Array.isArray(r)&&0!==r.length){e.next=4;break}return e.abrupt("return");case 4:n=_toConsumableArray(this.sessions.values()).filter((function(e){return e instanceof Publication&&e.state===PubSubStates.Processing&&e.tracks[0].source===exports.VideoSourceInfo.CAMERA})),i=_createForOfIteratorHelper$6(n),e.prev=6,a=_regeneratorRuntime$1.mark((function e(){var t,n;return _regeneratorRuntime$1.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=o.value,(n=r.filter((function(e){return e.mid==t.transceiver.mid}))).length&&t.applyOptions(n);case 3:case"end":return e.stop()}}),e)})),i.s();case 9:if((o=i.n()).done){e.next=13;break}return e.delegateYield(a(),"t0",11);case 11:e.next=9;break;case 13:e.next=18;break;case 15:e.prev=15,e.t1=e.catch(6),i.e(e.t1);case 18:return e.prev=18,i.f(),e.finish(18);case 21:case"end":return e.stop()}}),e,this,[[6,15,18,21]])}))),function(e){return r.apply(this,arguments)})}]);var r,n,i,o,a,s,c,u,l}(EventEmitter);function _createForOfIteratorHelper$5(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=_unsupportedIterableToArray$5(e))||t){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return e.length>n?{done:!1,value:e[n++]}:{done:!0}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function _unsupportedIterableToArray$5(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray$5(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray$5(e,t):void 0}}function _arrayLikeToArray$5(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);t>r;r++)n[r]=e[r];return n}function _callSuper$8(e,t,r){return t=_getPrototypeOf$1(t),_possibleConstructorReturn$1(e,_isNativeReflectConstruct$8()?Reflect.construct(t,[],_getPrototypeOf$1(e).constructor):t.apply(e,r))}function _isNativeReflectConstruct$8(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(_isNativeReflectConstruct$8=function(){return!!e})()}var PropertyNameMap={name:"name"},GroupManager=function(e){function t(e){var r;return _classCallCheck$1(this,t),r=_callSuper$8(this,t),Object.defineProperty(r,"channel",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(r,"groupIds",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"groups",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"default",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"listVer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"client",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),r.channel=e,r.groups=new Map,r.listVer=0,r.groupIds=new Set,r.handleGroupListEvents=r.handleGroupListEvents.bind(r),r.handleGroupEvents=r.handleGroupEvents.bind(r),r.handleSyncEvent=r.handleSyncEvent.bind(r),r}return _inherits$1(t,e),_createClass$1(t,[{key:"joinedIds",get:function(){var e=this.channel.userManager.currentPid,t=new Set;return this.groups.forEach((function(r){var n=r.id;r.participants.some((function(t){return t.pid===e}))&&t.add(n)})),t}},{key:"parseGroup",value:function(e){var t,r=this,n=e.properties,i=e.participants;return{id:e.id,name:(null==n||null===(t=n.find((function(e){return"name"===e.key})))||void 0===t?void 0:t.value)||"",joined:i.some((function(e){return e.pid===r.channel.userManager.currentPid})),users:i.map((function(e){return{userId:e.uid,userData:e.userData}}))}}},{key:"groupList",get:function(){var e=this,t=[];return this.groups.forEach((function(r){t.push(e.parseGroup(r))})),t}},{key:"init",value:function(e,t){this.listVer=t,this.groupIds=new Set(e),this.batchSyncGroup(e),this.observerAllGroup(),this.channel.signaling.on("group-list",this.handleGroupListEvents),this.channel.signaling.on("group",this.handleGroupEvents),this.channel.signaling.on("sync",this.handleSyncEvent)}},{key:"clear",value:function(){this.listVer=0,this.channel.signaling.off("group",this.handleGroupEvents),this.channel.signaling.off("group-list",this.handleGroupListEvents),this.channel.signaling.off("sync",this.handleSyncEvent),this.groupIds.clear(),this.groups.clear()}},{key:"join",value:function(e){var t=e.publishAudioToGroup,r=void 0===t||t,n=e.groupId,i=e.userData;if(this.joinedIds.has(n))throw new DingRTCError(ErrorCode.InvaildArgument,"you were in group already");return this.channel.signaling.joinGroup({groupId:n,userData:i,autoJoinGroupAudio:!!r,autoLeaveChannelAudio:!0})}},{key:"leave",value:function(e){var t=e.groupId,r=e.publishAudioToChannel,n=void 0===r||r;if(!this.joinedIds.has(t))throw new DingRTCError(ErrorCode.InvaildArgument,"you are not in the group");return this.channel.signaling.leaveGroup({groupId:t,reasonCode:signal_msg.LEAVE_GROUP_REASON_CODE.NORMAL_LEAVE,autoJoinChannelAudio:n})}},{key:"dismiss",value:function(e){if(!this.groupIds.has(e))throw new DingRTCError(ErrorCode.InvaildArgument,"group not existed");return this.channel.signaling.dismissGroup({groupId:e})}},{key:"addUser",value:function(e,t){var r,n=null===(r=this.groups.get(t))||void 0===r?void 0:r.participants;n&&!n.find((function(t){return t.pid===e.pid}))&&n.push(e)}},{key:"removeUser",value:function(e,t){var r,n=null===(r=this.groups.get(t))||void 0===r?void 0:r.participants;if(n){var i=n.findIndex((function(t){return t.pid===e.pid}));i>-1&&n.splice(i,1)}}},{key:"observerAllGroup",value:function(){return this.channel.signaling.observeAllGroups()}},{key:"unobserverAllGroup",value:function(){return this.channel.signaling.unobserveAllGroups()}},{key:"setProperties",value:function(e,t){return this.channel.signaling.setGroupProperties({groupId:e,properties:[t]})}},{key:"handleGroupListEvents",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=e.ver,n=e.type,i=e.updateOpt;if(this.channel.reporter.log.debug("groupList ".concat(JSON.stringify(e))),r!==this.listVer+1&&!t||n!==signal_msg.OptType.OPT_TYPE_UPDATE)r>this.listVer+1&&this.syncGroupList();else{var o=i.updateAction,a=i.id;o===signal_msg.GroupListUpdate.GROUP_LIST_UPDATE_ADD_ID?this.groupIds.add(a):o===signal_msg.GroupListUpdate.GROUP_LIST_UPDATE_REMOVE_ID&&this.groupIds.delete(a),this.listVer=r}}},{key:"handleGroupEvents",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.channel.reporter.log.debug("group ".concat(JSON.stringify(e)));var n,i=e.id,o=e.ver,a=e.groupInfo,s=e.type,c=e.updateOpt,u=this.groups.get(i);if(s!==signal_msg.OptType.OPT_TYPE_ADD||u){if(s===signal_msg.OptType.OPT_TYPE_REMOVE&&u)this.groups.delete(i),this.emit("group","remove",this.parseGroup(u));else if(s===signal_msg.OptType.OPT_TYPE_UPDATE){var l=c.updateAction,d=c.participants;if(u&&(u.ver+1===o||r)){if(l===signal_msg.GroupUpdate.GROUP_UPDATE_ADD_PARTICIPANTS){var p,f=u.participants.map((function(e){return e.pid})),h=_createForOfIteratorHelper$5(d);try{for(h.s();!(p=h.n()).done;){var m=p.value;f.includes(m.pid)||(u.participants.push(m),this.emit("group","user-join",i,{userId:m.uid,userData:m.userData}))}}catch(e){h.e(e)}finally{h.f()}}else if(l===signal_msg.GroupUpdate.GROUP_UPDATE_REMOVE_PARTICIPANTS){var g=d.map((function(e){return e.pid})),y=_toConsumableArray(u.participants);u.participants=u.participants.filter((function(e){return!g.includes(e.pid)})),y.forEach((function(e){g.includes(e.pid)&&t.emit("group","user-leave",i,{userId:e.uid,userData:e.userData})}))}else if(l===signal_msg.GroupUpdate.GROUP_UPDATE_AUDIO_STREAM_LOST)this.channel.reporter.log.debug("group ".concat(i," audioStream lost"));else if(l===signal_msg.GroupUpdate.GROUP_UPDATE_AUDIO_STREAM_RECOVER)this.channel.reporter.log.debug("group ".concat(i," audioStream recover"));else if(l===signal_msg.GroupUpdate.GROUP_UPDATE_SET_PROPERTIES)c.properties.forEach((function(e){var r=!0;u.properties||(u.properties=[]),u.properties.forEach((function(t){t.key===e.key&&(t.value=e.value,r=!1)})),r&&u.properties.push(e),t.emit("group","info-updated",i,{key:"set-".concat(PropertyNameMap[e.key]),value:e.value})}));else if(l===signal_msg.GroupUpdate.GROUP_UPDATE_REMOVE_PROPERTIES){var v,_=c.properties.map((function(e){return e.key}));u.properties=null===(v=u.properties)||void 0===v?void 0:v.filter((function(e){return!_.includes(e.key)})),c.properties.forEach((function(e){t.emit("group","info-updated",i,{key:"remove-".concat(PropertyNameMap[e.key])})}))}u.ver=o}else u&&o>u.ver+1&&this.syncGroup(u.id)}}else null==a||null===(n=a.audioInfo)||void 0===n||null===(n=n.audio)||void 0===n||null===(n=n.media)||void 0===n||delete n.video,null==a.ver&&(a.ver=o),this.groups.set(i,a),this.emit("group","add",this.parseGroup(a))}},{key:"syncGroup",value:function(e){var t=this,r=this.groups.get(e);return this.channel.signaling.syncData({type:signal_msg.DataType.DATA_TYPE_GROUP,id:e,ver:null==r?void 0:r.ver}).then((function(n){var i=n.fullSync.groupData.groupInfos,o=(void 0===i?[]:i)[0];if(o){var a=o.participants,s=o.properties,c=void 0===s?[]:s,u=(null==r?void 0:r.participants)||[],l=new Map(((null==r?void 0:r.properties)||[]).map((function(e){return[e.key,e.value]}))),d=u.map((function(e){return e.pid})),p=a.map((function(e){return e.pid})),f=c.filter((function(e){return e.value!==l[e.key]})),h=c.filter((function(e){return!l.has(e.key)})),m=a.filter((function(e){return!d.includes(e.pid)})),g=u.filter((function(e){return!p.includes(e.pid)}));m.length&&t.handleGroupEvents({id:e,type:signal_msg.OptType.OPT_TYPE_REMOVE,ver:o.ver,updateOpt:{updateAction:signal_msg.GroupUpdate.GROUP_UPDATE_ADD_PARTICIPANTS,participants:m}},!0),g.length&&t.handleGroupEvents({id:e,ver:o.ver,type:signal_msg.OptType.OPT_TYPE_REMOVE,updateOpt:{updateAction:signal_msg.GroupUpdate.GROUP_UPDATE_REMOVE_PARTICIPANTS,participants:g}},!0),f.length&&t.handleGroupEvents({id:e,ver:o.ver,type:signal_msg.OptType.OPT_TYPE_UPDATE,updateOpt:{updateAction:signal_msg.GroupUpdate.GROUP_UPDATE_SET_PROPERTIES,properties:f}},!0),h.length&&t.handleGroupEvents({id:e,ver:o.ver,type:signal_msg.OptType.OPT_TYPE_UPDATE,updateOpt:{updateAction:signal_msg.GroupUpdate.GROUP_UPDATE_REMOVE_PROPERTIES,properties:h}},!0)}else t.handleGroupEvents({id:e,type:signal_msg.OptType.OPT_TYPE_REMOVE})}))}},{key:"batchSyncGroup",value:function(e){var t=this;if(e.length)return this.channel.signaling.syncDataByIds({type:signal_msg.DataType.DATA_TYPE_GROUP,ids:e.map((function(e){return{id:e}}))}).then((function(e){e.fullSync.groupData.groupInfos.forEach((function(e){t.groupIds.add(e.id),t.groups.set(e.id,e)}))}))}},{key:"syncGroupList",value:function(){var e=this;this.channel.signaling.syncData({type:signal_msg.DataType.DATA_TYPE_GROUP_LIST,forceFullSync:!0,ver:this.listVer}).then((function(t){var r=t.fullSync,n=r.ver,i=r.groupListData.groupIds,o=void 0===i?[]:i,a=o.filter((function(t){return!e.groupIds.has(t)})),s=_toConsumableArray(e.groupIds).filter((function(e){return!o.includes(e)}));a.length&&a.forEach((function(t){e.handleGroupListEvents({ver:n,updateOpt:{updateAction:signal_msg.GroupListUpdate.GROUP_LIST_UPDATE_ADD_ID,id:t}},!0)})),s.length&&s.forEach((function(t){e.handleGroupListEvents({ver:n,updateOpt:{updateAction:signal_msg.GroupListUpdate.GROUP_LIST_UPDATE_REMOVE_ID,id:t}},!0)}))}))}},{key:"handleSyncEvent",value:function(e){var t=this,r=e.groupListVer,n=e.groupVer,i=void 0===n?[]:n;r>this.listVer&&(this.syncGroupList(),this.listVer=r),i.forEach((function(e){var r=e.id,n=e.ver,i=t.groups.get(r);n>(null==i?void 0:i.ver)&&(t.syncGroup(r),i.ver=n)}))}}])}(EventEmitter);function _callSuper$7(e,t,r){return t=_getPrototypeOf$1(t),_possibleConstructorReturn$1(e,_isNativeReflectConstruct$7()?Reflect.construct(t,[],_getPrototypeOf$1(e).constructor):t.apply(e,r))}function _isNativeReflectConstruct$7(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(_isNativeReflectConstruct$7=function(){return!!e})()}var User=function(e){function t(e,r){var n;return _classCallCheck$1(this,t),n=_callSuper$7(this,t),Object.defineProperty(n,"channel",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(n,"userId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(n,"id",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(n,"userName",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(n,"version",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(n,"streamMap",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(n,"videoTrack",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(n,"auxiliaryTrack",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(n,"audioTrack",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(n,"joinedTime",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(n,"properties",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),n.userId=e.user,n.videoTrack=null,n.audioTrack=null,n.auxiliaryTrack=null,n.channel=r,n.joinedTime=Date.now(),n.update(e),n}return _inherits$1(t,e),_createClass$1(t,[{key:"relatedStreams",get:function(){var e=this;return _toConsumableArray(this.channel.streamManager.streams.values()).filter((function(t){var r;return(null==t||null===(r=t.info)||void 0===r?void 0:r.owner)===e.id}))}},{key:"hasAuxiliary",get:function(){return this.relatedStreams.some((function(e){var t;return(null===(t=e.media)||void 0===t||null===(t=t.video)||void 0===t?void 0:t.source)===exports.VideoSourceInfo.SCREENCAST}))}},{key:"hasVideo",get:function(){return this.relatedStreams.some((function(e){var t,r=e.media;return(null==r||null===(t=r.video)||void 0===t?void 0:t.source)===exports.VideoSourceInfo.CAMERA}))}},{key:"hasAudio",get:function(){return this.relatedStreams.some((function(e){var t,r=e.media;return(null==r||null===(t=r.audio)||void 0===t?void 0:t.source)===exports.AudioSourceInfo.MIC}))}},{key:"audioMuted",get:function(){return this.relatedStreams.some((function(e){var t,r,n=e.media;return"active"!==(null==n||null===(t=n.audio)||void 0===t?void 0:t.status)&&(null==n||null===(r=n.audio)||void 0===r?void 0:r.source)===exports.AudioSourceInfo.MIC}))}},{key:"auxiliaryMuted",get:function(){return this.relatedStreams.some((function(e){var t,r,n=e.media;return"active"!==(null==n||null===(t=n.video)||void 0===t?void 0:t.status)&&(null==n||null===(r=n.video)||void 0===r?void 0:r.source)===exports.VideoSourceInfo.SCREENCAST}))}},{key:"videoMuted",get:function(){return this.relatedStreams.some((function(e){var t,r,n=e.media;return"active"!==(null==n||null===(t=n.video)||void 0===t?void 0:t.status)&&(null==n||null===(r=n.video)||void 0===r?void 0:r.source)===exports.VideoSourceInfo.CAMERA}))}},{key:"updateNetworkOfUser",value:function(e){var t;if(this.properties.SdkType!==SdkType$1.Web&&e){var r=e.split("");r[ClientUserStats.UPLINK]=transNativeAndWebNetworkRank(r[ClientUserStats.UPLINK]),r[ClientUserStats.DOWNLINK]=transNativeAndWebNetworkRank(r[ClientUserStats.DOWNLINK]),e=r.join("")}e!==(null===(t=this.properties)||void 0===t?void 0:t[USER_STATS_SYNC])&&(this.properties[USER_STATS_SYNC]=e)}},{key:"update",value:function(e){var t=e.id,r=e.ver,n=JSON.parse(e.propertiesJsonStr||"{}");this.id=t,this.userName=n.__nick,this.version=r,this.properties=n,this.updateNetworkOfUser(n[USER_STATS_SYNC])}},{key:"getRemoteVideoTrack",value:function(e,t){var r=t?this.auxiliaryTrack:this.videoTrack,n=JSON.parse(e.stream.info.attributesJsonStr),i=updateRemoteTrack(e.mediaStream,"video",this.userId,r);return r||i.once("first-frame-decoded",(function(){e.handleVideoFirstFrame()})),t?this.auxiliaryTrack=i:this.videoTrack=i,n.mirror&&i.setSourceMirror(n.mirror),i}}])}(EventEmitter);function _createForOfIteratorHelper$4(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=_unsupportedIterableToArray$4(e))||t){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return e.length>n?{done:!1,value:e[n++]}:{done:!0}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function _unsupportedIterableToArray$4(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray$4(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray$4(e,t):void 0}}function _arrayLikeToArray$4(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);t>r;r++)n[r]=e[r];return n}function _callSuper$6(e,t,r){return t=_getPrototypeOf$1(t),_possibleConstructorReturn$1(e,_isNativeReflectConstruct$6()?Reflect.construct(t,[],_getPrototypeOf$1(e).constructor):t.apply(e,r))}function _isNativeReflectConstruct$6(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(_isNativeReflectConstruct$6=function(){return!!e})()}var UserManager=function(e){function t(e){var r;return _classCallCheck$1(this,t),r=_callSuper$6(this,t),Object.defineProperty(r,"channel",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(r,"users",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"currentUid",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"currentPid",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"reporter",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),r.users=new Map,r.channel=e,r.reporter=e.reporter,r.handleEvent=r.handleEvent.bind(r),r}return _inherits$1(t,e),_createClass$1(t,[{key:"remoteUsers",get:function(){var e=this;return uniqBy(_toConsumableArray(this.users.values()).sort((function(e,t){return e.joinedTime-t.joinedTime})),"userId").filter((function(t){return t.userId&&t.id!==e.currentPid}))}},{key:"init",value:function(e,t){var r,n=_createForOfIteratorHelper$4(e);try{for(n.s();!(r=n.n()).done;){var i=r.value,o=new User(i,this.channel);this.users.set(i.user,o),t===i.user&&(this.currentUid=i.user)}}catch(e){n.e(e)}finally{n.f()}this.currentPid=t,this.channel.internalChannel.on("user",this.handleEvent)}},{key:"clear",value:function(){this.currentPid="",this.currentUid="",this.users.clear(),this.channel.internalChannel.off("user",this.handleEvent)}},{key:"handleEvent",value:function(e,t){if(this.reporter.log.debug("userEvent ".concat(e," ").concat(JSON.stringify(t))),"join"===e){var r=new User(t,this.channel);this.users.set(t.user,r),this.emit("user","join",r)}else if("leave"===e){var n=this.users.get(t.user);this.users.delete(t.user),this.emit("user","leave",n)}else if("update"===e){var i=this.users.get(t.user);null==i||i.update(t)}}},{key:"setParticipantProperties",value:function(e){return this.channel.signaling.setParticipantProperties({participantId:this.currentPid,roomId:this.channel.roomId,propertiesJsonStr:JSON.stringify(_defineProperty({},USER_STATS_SYNC,e))})}}])}(EventEmitter);function _createForOfIteratorHelper$3(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=_unsupportedIterableToArray$3(e))||t){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return e.length>n?{done:!1,value:e[n++]}:{done:!0}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function _unsupportedIterableToArray$3(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray$3(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray$3(e,t):void 0}}function _arrayLikeToArray$3(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);t>r;r++)n[r]=e[r];return n}function ownKeys$2(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function _objectSpread$2(e){for(var t=1;arguments.length>t;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ownKeys$2(Object(r),!0).forEach((function(t){_defineProperty(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ownKeys$2(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function _callSuper$5(e,t,r){return t=_getPrototypeOf$1(t),_possibleConstructorReturn$1(e,_isNativeReflectConstruct$5()?Reflect.construct(t,[],_getPrototypeOf$1(e).constructor):t.apply(e,r))}function _isNativeReflectConstruct$5(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(_isNativeReflectConstruct$5=function(){return!!e})()}var StreamManager=function(e){function t(e){var r;_classCallCheck$1(this,t),r=_callSuper$5(this,t),Object.defineProperty(r,"streams",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"totalVer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"reporter",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"signaling",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),r.streams=new Map;var n=e.reporter;return r.signaling=e.signaling,r.reporter=n,r.handleEvent=r.handleEvent.bind(r),r.handleSyncEvent=r.handleSyncEvent.bind(r),r.sync=r.sync.bind(r),r}return _inherits$1(t,e),_createClass$1(t,[{key:"clear",value:function(){this.streams.clear(),this.totalVer=0,this.signaling.off("stream",this.handleEvent),this.signaling.off("sync",this.handleSyncEvent)}},{key:"init",value:function(e,t){var r,n=e.find((function(e){return"admin"===e.info.owner&&"mixed"===e.type}));null==n||null===(r=n.media)||void 0===r||delete r.video,this.streams=new Map(e.map((function(e){return[e.id,e]}))),this.totalVer=t,this.signaling.on("stream",this.handleEvent),this.signaling.on("sync",this.handleSyncEvent)}},{key:"add",value:function(e){var t,r=e.id,n=e.info.owner,i=e.media,o=i.video,a=i.audio;if(!this.streams.get(r)){var s=null===(t=e.media)||void 0===t||null===(t=t.video)||void 0===t?void 0:t.source,c=_toConsumableArray(this.streams.values()).find((function(e){var t;return e.info.owner===n&&(null===(t=e.media)||void 0===t||null===(t=t.video)||void 0===t?void 0:t.source)===s}));c&&this.remove(c.id),this.reporter.trace.streamsEvent(r,"add"),this.streams.set(e.id,e);var u=(null==o?void 0:o.source)===VideoSourceInfo.SCREENCAST;((null==o?void 0:o.source)===VideoSourceInfo.CAMERA||u)&&this.emit("stream","add",{id:r,owner:n,mediaType:"video",auxiliary:u}),(null==a?void 0:a.source)!==exports.AudioSourceInfo.MIC&&(null==a?void 0:a.source)!==exports.AudioSourceInfo.MIXED||this.emit("stream","add",{id:r,owner:n,mediaType:"audio"})}}},{key:"remove",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=this.streams.get(e);if(r&&(this.streams.delete(e),t)){this.reporter.trace.streamsEvent(e,"remove");var n=r.media,i=n.video,o=n.audio,a=r.info.owner,s=(null==i?void 0:i.source)===VideoSourceInfo.SCREENCAST;((null==i?void 0:i.source)===VideoSourceInfo.CAMERA||s)&&this.emit("stream","remove",{id:e,owner:a,mediaType:"video",auxiliary:s}),(null==o?void 0:o.source)!==exports.AudioSourceInfo.MIC&&(null==o?void 0:o.source)!==exports.AudioSourceInfo.MIXED||this.emit("stream","remove",{id:e,owner:a,mediaType:"audio"})}}},{key:"getStreamByTrackId",value:function(e){return _toConsumableArray(this.streams.values()).find((function(t){var r,n;return(null===(r=t.media.audio)||void 0===r?void 0:r.trackId)===e||(null===(n=t.media.video)||void 0===n?void 0:n.trackId)===e}))}},{key:"handleEvent",value:function(e,t){var r=this,n=e.streamId,i=e.status,o=e.stream,a=e.msg,s=e.totalVer,c={add:[],remove:[],update:["audio.status","video.status","properties"]}[i];c.length&&!c.includes(a.field)||this.reporter.log.debug("streamEvent ".concat(JSON.stringify(e)));var u=this.totalVer;if(s===u+1||s==IGNOGRED_VERSION||t)if("add"===i){if(!o||!o.media||!o.info)return;this.add(o)}else if("remove"===i)this.remove(n,!0);else if("update"===i){var l=a.field,d=a.streamStatus,p=a.activeStream,f=a.extraValue,h=a.streamVer,m=a.propertiesJsonStr,g=this.streams.get(n);if(g){h!==IGNOGRED_VERSION&&(g.version=h);var y,v=g.media,_=v.video,b=g.info.owner;if("audio.status"===l||"video.status"===l)"audio.status"===l?(y="audio",v.audio.status=d):"video.status"===l&&(y="video",_.status=d),this.reporter.trace.streamsEvent(n,"".concat(y," ").concat(d)),this.emit("stream","update",{owner:b,id:n,updateStatus:"".concat("active"===d?"unmute":"mute","-").concat(y)});else if("activeInput"===l){var E=[p].concat(f||[]).map((function(e){var t;return null===(t=r.streams.get(e))||void 0===t||null===(t=t.info)||void 0===t?void 0:t.owner})).filter((function(e){return!!e}));this.reporter.trace.streamsEvent(JSON.stringify(E),l),this.emit("stream","volumeActive",{owners:E})}else if("properties"==l){var S,T=JSON.parse(m);g.info.attributesJsonStr=JSON.stringify(_objectSpread$2(_objectSpread$2({},JSON.parse(g.info.attributesJsonStr)),T));var R=(null===(S=g.media)||void 0===S||null===(S=S.video)||void 0===S?void 0:S.source)===VideoSourceInfo.SCREENCAST;this.emit("stream","update",{owner:b,id:n,properties:T,auxiliary:R})}}}t||this.totalVer>=s&&s!==IGNOGRED_VERSION||(s===u+1&&(this.totalVer=s),s>u+1&&!t&&this.sync())}},{key:"sync",value:(r=_asyncToGenerator$1(_regeneratorRuntime$1.mark((function e(){var t,r,n,i,o,a,s,c,u,l,d,p,f,h,m=this;return _regeneratorRuntime$1.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=[],r=[],e.next=4,this.signaling.getStreamsVer({});case 4:i=(n=e.sent).streamVersions,o=n.totalVer,a=_toConsumableArray(this.streams.keys()).filter((function(e){return!e.includes("vad")})),s=_createForOfIteratorHelper$3(i),e.prev=9,s.s();case 11:if((c=s.n()).done){e.next=19;break}if(d=(u=c.value).streamVer,!(l=u.streamId).includes("vad")){e.next=15;break}return e.abrupt("continue",17);case 15:(p=this.streams.get(l))?p&&p.version!==d&&t.push(l):(r.push(l),t.push(l));case 17:e.next=11;break;case 19:e.next=24;break;case 21:e.prev=21,e.t0=e.catch(9),s.e(e.t0);case 24:return e.prev=24,s.f(),e.finish(24);case 27:if(f=i.map((function(e){return e.streamId})),h=a.filter((function(e){return!f.includes(e)})),this.reporter.trace.syncEvent("stream",a,f),this.totalVer=o,0!==t.length){e.next=33;break}return e.abrupt("return");case 33:this.signaling.getStreams({streamIds:t}).then((function(e){var n,i=e.totalVer,o=e.streams,a=new Map,s=_createForOfIteratorHelper$3(m.streams.values());try{for(s.s();!(n=s.n()).done;){var c=n.value;a.set(c.id,c)}}catch(e){s.e(e)}finally{s.f()}var u,l=_createForOfIteratorHelper$3(o);try{for(l.s();!(u=l.n()).done;){var d=u.value;m.streams.has(d.id)?m.streams.set(d.id,d.stream):a.set(d.id,d.stream)}}catch(e){l.e(e)}finally{l.f()}for(var p=t.map((function(e){return a.get(e)})).filter((function(e){return!!e})).sort((function(e,t){return e.version-t.version})),f=0;p.length>f;f++){var g=p[f];h.includes(g.id)?m.handleEvent({status:"remove",streamId:g.id,stream:g,totalVer:i},!0):r.includes(g.id)&&m.handleEvent({status:"add",streamId:g.id,stream:g,totalVer:i},!0)}a.clear(),m.totalVer=i}));case 34:case"end":return e.stop()}}),e,this,[[9,21,24,27]])}))),function(){return r.apply(this,arguments)})},{key:"handleSyncEvent",value:function(e){e.streamsVer>this.totalVer&&this.sync()}}]);var r}(EventEmitter),wasm=null;
3
+ /**
4
+ * @license
5
+ * Copyright 2009 The Closure Library Authors
6
+ * Copyright 2020 Daniel Wirtz / The long.js Authors.
7
+ *
8
+ * Licensed under the Apache License, Version 2.0 (the "License");
9
+ * you may not use this file except in compliance with the License.
10
+ * You may obtain a copy of the License at
11
+ *
12
+ * http://www.apache.org/licenses/LICENSE-2.0
13
+ *
14
+ * Unless required by applicable law or agreed to in writing, software
15
+ * distributed under the License is distributed on an "AS IS" BASIS,
16
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ * See the License for the specific language governing permissions and
18
+ * limitations under the License.
19
+ *
20
+ * SPDX-License-Identifier: Apache-2.0
21
+ */try{wasm=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch(e){}function Long(e,t,r){this.low=0|e,this.high=0|t,this.unsigned=!!r}function isLong(e){return!0===(e&&e.__isLong__)}function ctz32(e){var t=Math.clz32(e&-e);return e?31-t:t}Object.defineProperty(Long.prototype,"__isLong__",{value:!0}),Long.isLong=isLong;var INT_CACHE={},UINT_CACHE={};function fromInt(e,t){var r,n,i;return t?(i=(e>>>=0)>=0&&256>e)&&(n=UINT_CACHE[e])?n:(r=fromBits(e,0,!0),i&&(UINT_CACHE[e]=r),r):(i=(e|=0)>=-128&&128>e)&&(n=INT_CACHE[e])?n:(r=fromBits(e,0>e?-1:0,!1),i&&(INT_CACHE[e]=r),r)}function fromNumber(e,t){if(isNaN(e))return t?UZERO:ZERO;if(t){if(0>e)return UZERO;if(e>=TWO_PWR_64_DBL)return MAX_UNSIGNED_VALUE}else{if(-0x8000000000000000>=e)return MIN_VALUE;if(e+1>=TWO_PWR_63_DBL)return MAX_VALUE}return 0>e?fromNumber(-e,t).neg():fromBits(e%TWO_PWR_32_DBL|0,e/TWO_PWR_32_DBL|0,t)}function fromBits(e,t,r){return new Long(e,t,r)}Long.fromInt=fromInt,Long.fromNumber=fromNumber,Long.fromBits=fromBits;var pow_dbl=Math.pow;function fromString(e,t,r){if(0===e.length)throw Error("empty string");if("number"==typeof t?(r=t,t=!1):t=!!t,"NaN"===e||"Infinity"===e||"+Infinity"===e||"-Infinity"===e)return t?UZERO:ZERO;if(2>(r=r||10)||r>36)throw RangeError("radix");var n;if((n=e.indexOf("-"))>0)throw Error("interior hyphen");if(0===n)return fromString(e.substring(1),t,r).neg();for(var i=fromNumber(pow_dbl(r,8)),o=ZERO,a=0;e.length>a;a+=8){var s=Math.min(8,e.length-a),c=parseInt(e.substring(a,a+s),r);if(8>s){var u=fromNumber(pow_dbl(r,s));o=o.mul(u).add(fromNumber(c))}else o=(o=o.mul(i)).add(fromNumber(c))}return o.unsigned=t,o}function fromValue(e,t){return"number"==typeof e?fromNumber(e,t):"string"==typeof e?fromString(e,t):fromBits(e.low,e.high,"boolean"==typeof t?t:e.unsigned)}Long.fromString=fromString,Long.fromValue=fromValue;var TWO_PWR_16_DBL=65536,TWO_PWR_24_DBL=1<<24,TWO_PWR_32_DBL=TWO_PWR_16_DBL*TWO_PWR_16_DBL,TWO_PWR_64_DBL=TWO_PWR_32_DBL*TWO_PWR_32_DBL,TWO_PWR_63_DBL=TWO_PWR_64_DBL/2,TWO_PWR_24=fromInt(TWO_PWR_24_DBL),ZERO=fromInt(0);Long.ZERO=ZERO;var UZERO=fromInt(0,!0);Long.UZERO=UZERO;var ONE=fromInt(1);Long.ONE=ONE;var UONE=fromInt(1,!0);Long.UONE=UONE;var NEG_ONE=fromInt(-1);Long.NEG_ONE=NEG_ONE;var MAX_VALUE=fromBits(-1,2147483647,!1);Long.MAX_VALUE=MAX_VALUE;var MAX_UNSIGNED_VALUE=fromBits(-1,-1,!0);Long.MAX_UNSIGNED_VALUE=MAX_UNSIGNED_VALUE;var MIN_VALUE=fromBits(0,-2147483648,!1);Long.MIN_VALUE=MIN_VALUE;var LongPrototype=Long.prototype;function S(e,t,r,n,i,o,a){try{var s=e[o](a),c=s.value}catch(e){return void r(e)}s.done?t(c):Promise.resolve(c).then(n,i)}function T(e){return function(){var t=this,r=arguments;return new Promise((function(n,i){var o=e.apply(t,r);function a(e){S(o,n,i,a,s,"next",e)}function s(e){S(o,n,i,a,s,"throw",e)}a(void 0)}))}}function E(e){return E="function"==typeof Symbol&&"symbol"==_typeof$3(Symbol.iterator)?function(e){return _typeof$3(e)}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":_typeof$3(e)},E(e)}function O(e){var t=function(e){if("object"!=E(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=E(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return e+""}(e);return"symbol"==E(t)?t:t+""}function I(e,t,r){return(t=O(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function C(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function N(e,t){for(var r=0;t.length>r;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,O(n.key),n)}}function _(e,t,r){return t&&N(e.prototype,t),r&&N(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function k(e,t){if(t&&("object"==E(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function P(e){return P=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},P(e)}function M(e,t){return M=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},M(e,t)}function w(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&M(e,t)}function R(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}LongPrototype.toInt=function(){return this.unsigned?this.low>>>0:this.low},LongPrototype.toNumber=function(){return this.unsigned?(this.high>>>0)*TWO_PWR_32_DBL+(this.low>>>0):this.high*TWO_PWR_32_DBL+(this.low>>>0)},LongPrototype.toString=function(e){if(2>(e=e||10)||e>36)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative()){if(this.eq(MIN_VALUE)){var t=fromNumber(e),r=this.div(t),n=r.mul(t).sub(this);return r.toString(e)+n.toInt().toString(e)}return"-"+this.neg().toString(e)}for(var i=fromNumber(pow_dbl(e,6),this.unsigned),o=this,a="";;){var s=o.div(i),c=(o.sub(s.mul(i)).toInt()>>>0).toString(e);if((o=s).isZero())return c+a;for(;6>c.length;)c="0"+c;a=""+c+a}},LongPrototype.getHighBits=function(){return this.high},LongPrototype.getHighBitsUnsigned=function(){return this.high>>>0},LongPrototype.getLowBits=function(){return this.low},LongPrototype.getLowBitsUnsigned=function(){return this.low>>>0},LongPrototype.getNumBitsAbs=function(){if(this.isNegative())return this.eq(MIN_VALUE)?64:this.neg().getNumBitsAbs();for(var e=0!=this.high?this.high:this.low,t=31;t>0&&!(e&1<<t);t--);return 0!=this.high?t+33:t+1},LongPrototype.isZero=function(){return 0===this.high&&0===this.low},LongPrototype.eqz=LongPrototype.isZero,LongPrototype.isNegative=function(){return!this.unsigned&&0>this.high},LongPrototype.isPositive=function(){return this.unsigned||this.high>=0},LongPrototype.isOdd=function(){return!(1&~this.low)},LongPrototype.isEven=function(){return!(1&this.low)},LongPrototype.equals=function(e){return isLong(e)||(e=fromValue(e)),(this.unsigned===e.unsigned||this.high>>>31!=1||e.high>>>31!=1)&&(this.high===e.high&&this.low===e.low)},LongPrototype.eq=LongPrototype.equals,LongPrototype.notEquals=function(e){return!this.eq(e)},LongPrototype.neq=LongPrototype.notEquals,LongPrototype.ne=LongPrototype.notEquals,LongPrototype.lessThan=function(e){return 0>this.comp(e)},LongPrototype.lt=LongPrototype.lessThan,LongPrototype.lessThanOrEqual=function(e){return 0>=this.comp(e)},LongPrototype.lte=LongPrototype.lessThanOrEqual,LongPrototype.le=LongPrototype.lessThanOrEqual,LongPrototype.greaterThan=function(e){return this.comp(e)>0},LongPrototype.gt=LongPrototype.greaterThan,LongPrototype.greaterThanOrEqual=function(e){return this.comp(e)>=0},LongPrototype.gte=LongPrototype.greaterThanOrEqual,LongPrototype.ge=LongPrototype.greaterThanOrEqual,LongPrototype.compare=function(e){if(isLong(e)||(e=fromValue(e)),this.eq(e))return 0;var t=this.isNegative(),r=e.isNegative();return t&&!r?-1:!t&&r?1:this.unsigned?e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1:this.sub(e).isNegative()?-1:1},LongPrototype.comp=LongPrototype.compare,LongPrototype.negate=function(){return!this.unsigned&&this.eq(MIN_VALUE)?MIN_VALUE:this.not().add(ONE)},LongPrototype.neg=LongPrototype.negate,LongPrototype.add=function(e){isLong(e)||(e=fromValue(e));var t=0,r=0,n=0,i=0;return n+=(i+=(65535&this.low)+(65535&e.low))>>>16,r+=(n+=(this.low>>>16)+(e.low>>>16))>>>16,t+=(r+=(65535&this.high)+(65535&e.high))>>>16,t+=(this.high>>>16)+(e.high>>>16),fromBits((n&=65535)<<16|(i&=65535),(t&=65535)<<16|(r&=65535),this.unsigned)},LongPrototype.subtract=function(e){return isLong(e)||(e=fromValue(e)),this.add(e.neg())},LongPrototype.sub=LongPrototype.subtract,LongPrototype.multiply=function(e){if(this.isZero())return this;if(isLong(e)||(e=fromValue(e)),wasm)return fromBits(wasm.mul(this.low,this.high,e.low,e.high),wasm.get_high(),this.unsigned);if(e.isZero())return this.unsigned?UZERO:ZERO;if(this.eq(MIN_VALUE))return e.isOdd()?MIN_VALUE:ZERO;if(e.eq(MIN_VALUE))return this.isOdd()?MIN_VALUE:ZERO;if(this.isNegative())return e.isNegative()?this.neg().mul(e.neg()):this.neg().mul(e).neg();if(e.isNegative())return this.mul(e.neg()).neg();if(this.lt(TWO_PWR_24)&&e.lt(TWO_PWR_24))return fromNumber(this.toNumber()*e.toNumber(),this.unsigned);var t=65535&this.high,r=this.low>>>16,n=65535&this.low,i=65535&e.high,o=e.low>>>16,a=65535&e.low,s=0,c=0,u=0,l=0;return u+=(l+=n*a)>>>16,c+=(u+=r*a)>>>16,u&=65535,c+=(u+=n*o)>>>16,s+=(c+=t*a)>>>16,c&=65535,s+=(c+=r*o)>>>16,c&=65535,s+=(c+=n*i)>>>16,s+=(this.high>>>16)*a+t*o+r*i+n*(e.high>>>16),fromBits((u&=65535)<<16|(l&=65535),(s&=65535)<<16|(c&=65535),this.unsigned)},LongPrototype.mul=LongPrototype.multiply,LongPrototype.divide=function(e){if(isLong(e)||(e=fromValue(e)),e.isZero())throw Error("division by zero");var t,r,n;if(wasm)return this.unsigned||-2147483648!==this.high||-1!==e.low||-1!==e.high?fromBits((this.unsigned?wasm.div_u:wasm.div_s)(this.low,this.high,e.low,e.high),wasm.get_high(),this.unsigned):this;if(this.isZero())return this.unsigned?UZERO:ZERO;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return UZERO;if(e.gt(this.shru(1)))return UONE;n=UZERO}else{if(this.eq(MIN_VALUE))return e.eq(ONE)||e.eq(NEG_ONE)?MIN_VALUE:e.eq(MIN_VALUE)?ONE:(t=this.shr(1).div(e).shl(1)).eq(ZERO)?e.isNegative()?ONE:NEG_ONE:(r=this.sub(e.mul(t)),n=t.add(r.div(e)));if(e.eq(MIN_VALUE))return this.unsigned?UZERO:ZERO;if(this.isNegative())return e.isNegative()?this.neg().div(e.neg()):this.neg().div(e).neg();if(e.isNegative())return this.div(e.neg()).neg();n=ZERO}for(r=this;r.gte(e);){t=Math.max(1,Math.floor(r.toNumber()/e.toNumber()));for(var i=Math.ceil(Math.log(t)/Math.LN2),o=i>48?pow_dbl(2,i-48):1,a=fromNumber(t),s=a.mul(e);s.isNegative()||s.gt(r);)s=(a=fromNumber(t-=o,this.unsigned)).mul(e);a.isZero()&&(a=ONE),n=n.add(a),r=r.sub(s)}return n},LongPrototype.div=LongPrototype.divide,LongPrototype.modulo=function(e){return isLong(e)||(e=fromValue(e)),wasm?fromBits((this.unsigned?wasm.rem_u:wasm.rem_s)(this.low,this.high,e.low,e.high),wasm.get_high(),this.unsigned):this.sub(this.div(e).mul(e))},LongPrototype.mod=LongPrototype.modulo,LongPrototype.rem=LongPrototype.modulo,LongPrototype.not=function(){return fromBits(~this.low,~this.high,this.unsigned)},LongPrototype.countLeadingZeros=function(){return this.high?Math.clz32(this.high):Math.clz32(this.low)+32},LongPrototype.clz=LongPrototype.countLeadingZeros,LongPrototype.countTrailingZeros=function(){return this.low?ctz32(this.low):ctz32(this.high)+32},LongPrototype.ctz=LongPrototype.countTrailingZeros,LongPrototype.and=function(e){return isLong(e)||(e=fromValue(e)),fromBits(this.low&e.low,this.high&e.high,this.unsigned)},LongPrototype.or=function(e){return isLong(e)||(e=fromValue(e)),fromBits(this.low|e.low,this.high|e.high,this.unsigned)},LongPrototype.xor=function(e){return isLong(e)||(e=fromValue(e)),fromBits(this.low^e.low,this.high^e.high,this.unsigned)},LongPrototype.shiftLeft=function(e){return isLong(e)&&(e=e.toInt()),0==(e&=63)?this:32>e?fromBits(this.low<<e,this.high<<e|this.low>>>32-e,this.unsigned):fromBits(0,this.low<<e-32,this.unsigned)},LongPrototype.shl=LongPrototype.shiftLeft,LongPrototype.shiftRight=function(e){return isLong(e)&&(e=e.toInt()),0==(e&=63)?this:32>e?fromBits(this.low>>>e|this.high<<32-e,this.high>>e,this.unsigned):fromBits(this.high>>e-32,0>this.high?-1:0,this.unsigned)},LongPrototype.shr=LongPrototype.shiftRight,LongPrototype.shiftRightUnsigned=function(e){return isLong(e)&&(e=e.toInt()),0==(e&=63)?this:32>e?fromBits(this.low>>>e|this.high<<32-e,this.high>>>e,this.unsigned):fromBits(32===e?this.high:this.high>>>e-32,0,this.unsigned)},LongPrototype.shru=LongPrototype.shiftRightUnsigned,LongPrototype.shr_u=LongPrototype.shiftRightUnsigned,LongPrototype.rotateLeft=function(e){var t;return isLong(e)&&(e=e.toInt()),0==(e&=63)?this:32===e?fromBits(this.high,this.low,this.unsigned):32>e?fromBits(this.low<<e|this.high>>>(t=32-e),this.high<<e|this.low>>>t,this.unsigned):fromBits(this.high<<(e-=32)|this.low>>>(t=32-e),this.low<<e|this.high>>>t,this.unsigned)},LongPrototype.rotl=LongPrototype.rotateLeft,LongPrototype.rotateRight=function(e){var t;return isLong(e)&&(e=e.toInt()),0==(e&=63)?this:32===e?fromBits(this.high,this.low,this.unsigned):32>e?fromBits(this.high<<(t=32-e)|this.low>>>e,this.low<<t|this.high>>>e,this.unsigned):fromBits(this.low<<(t=32-(e-=32))|this.high>>>e,this.high<<t|this.low>>>e,this.unsigned)},LongPrototype.rotr=LongPrototype.rotateRight,LongPrototype.toSigned=function(){return this.unsigned?fromBits(this.low,this.high,!1):this},LongPrototype.toUnsigned=function(){return this.unsigned?this:fromBits(this.low,this.high,!0)},LongPrototype.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()},LongPrototype.toBytesLE=function(){var e=this.high,t=this.low;return[255&t,t>>>8&255,t>>>16&255,t>>>24,255&e,e>>>8&255,e>>>16&255,e>>>24]},LongPrototype.toBytesBE=function(){var e=this.high,t=this.low;return[e>>>24,e>>>16&255,e>>>8&255,255&e,t>>>24,t>>>16&255,t>>>8&255,255&t]},Long.fromBytes=function(e,t,r){return r?Long.fromBytesLE(e,t):Long.fromBytesBE(e,t)},Long.fromBytesLE=function(e,t){return new Long(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,t)},Long.fromBytesBE=function(e,t){return new Long(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],t)};var D={exports:{}},A={exports:{}};!function(e){function t(r){return e.exports=t="function"==typeof Symbol&&"symbol"==_typeof$3(Symbol.iterator)?function(e){return _typeof$3(e)}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":_typeof$3(e)},e.exports.__esModule=!0,e.exports.default=e.exports,t(r)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports}(A);var j=A.exports;!function(e){var t=j.default;function r(){e.exports=r=function(){return i},e.exports.__esModule=!0,e.exports.default=e.exports;var n,i={},o=Object.prototype,a=o.hasOwnProperty,s=Object.defineProperty||function(e,t,r){e[t]=r.value},c="function"==typeof Symbol?Symbol:{},u=c.iterator||"@@iterator",l=c.asyncIterator||"@@asyncIterator",d=c.toStringTag||"@@toStringTag";function p(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{p({},"")}catch(n){p=function(e,t,r){return e[t]=r}}function f(e,t,r,n){var i=Object.create((t&&t.prototype instanceof b?t:b).prototype),o=new N(n||[]);return s(i,"_invoke",{value:w(e,r,o)}),i}function h(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}i.wrap=f;var m="suspendedStart",g="suspendedYield",y="executing",v="completed",_={};function b(){}function E(){}function S(){}var T={};p(T,u,(function(){return this}));var R=Object.getPrototypeOf,O=R&&R(R(D([])));O&&O!==o&&a.call(O,u)&&(T=O);var C=S.prototype=b.prototype=Object.create(T);function k(e){["next","throw","return"].forEach((function(t){p(e,t,(function(e){return this._invoke(t,e)}))}))}function I(e,r){function n(i,o,s,c){var u=h(e[i],e,o);if("throw"!==u.type){var l=u.arg,d=l.value;return d&&"object"==t(d)&&a.call(d,"__await")?r.resolve(d.__await).then((function(e){n("next",e,s,c)}),(function(e){n("throw",e,s,c)})):r.resolve(d).then((function(e){l.value=e,s(l)}),(function(e){return n("throw",e,s,c)}))}c(u.arg)}var i;s(this,"_invoke",{value:function(e,t){function o(){return new r((function(r,i){n(e,t,r,i)}))}return i=i?i.then(o,o):o()}})}function w(e,t,r){var i=m;return function(o,a){if(i===y)throw Error("Generator is already running");if(i===v){if("throw"===o)throw a;return{value:n,done:!0}}for(r.method=o,r.arg=a;;){var s=r.delegate;if(s){var c=P(s,r);if(c){if(c===_)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(i===m)throw i=v,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);i=y;var u=h(e,t,r);if("normal"===u.type){if(i=r.done?v:g,u.arg===_)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(i=v,r.method="throw",r.arg=u.arg)}}}function P(e,t){var r=t.method,i=e.iterator[r];if(i===n)return t.delegate=null,"throw"===r&&e.iterator.return&&(t.method="return",t.arg=n,P(e,t),"throw"===t.method)||"return"!==r&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+r+"' method")),_;var o=h(i,e.iterator,t.arg);if("throw"===o.type)return t.method="throw",t.arg=o.arg,t.delegate=null,_;var a=o.arg;return a?a.done?(t[e.resultName]=a.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=n),t.delegate=null,_):a:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,_)}function A(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function M(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function N(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(A,this),this.reset(!0)}function D(e){if(e||""===e){var r=e[u];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,o=function t(){for(;++i<e.length;)if(a.call(e,i))return t.value=e[i],t.done=!1,t;return t.value=n,t.done=!0,t};return o.next=o}}throw new TypeError(t(e)+" is not iterable")}return E.prototype=S,s(C,"constructor",{value:S,configurable:!0}),s(S,"constructor",{value:E,configurable:!0}),E.displayName=p(S,d,"GeneratorFunction"),i.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===E||"GeneratorFunction"===(t.displayName||t.name))},i.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,S):(e.__proto__=S,p(e,d,"GeneratorFunction")),e.prototype=Object.create(C),e},i.awrap=function(e){return{__await:e}},k(I.prototype),p(I.prototype,l,(function(){return this})),i.AsyncIterator=I,i.async=function(e,t,r,n,o){void 0===o&&(o=Promise);var a=new I(f(e,t,r,n),o);return i.isGeneratorFunction(t)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},k(C),p(C,d,"Generator"),p(C,u,(function(){return this})),p(C,"toString",(function(){return"[object Generator]"})),i.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},i.values=D,N.prototype={constructor:N,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=n,this.done=!1,this.delegate=null,this.method="next",this.arg=n,this.tryEntries.forEach(M),!e)for(var t in this)"t"===t.charAt(0)&&a.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=n)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(r,i){return s.type="throw",s.arg=e,t.next=r,i&&(t.method="next",t.arg=n),!!i}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],s=o.completion;if("root"===o.tryLoc)return r("end");if(this.prev>=o.tryLoc){var c=a.call(o,"catchLoc"),u=a.call(o,"finallyLoc");if(c&&u){if(o.catchLoc>this.prev)return r(o.catchLoc,!0);if(o.finallyLoc>this.prev)return r(o.finallyLoc)}else if(c){if(o.catchLoc>this.prev)return r(o.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(o.finallyLoc>this.prev)return r(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(this.prev>=n.tryLoc&&a.call(n,"finallyLoc")&&n.finallyLoc>this.prev){var i=n;break}}i&&("break"===e||"continue"===e)&&t>=i.tryLoc&&i.finallyLoc>=t&&(i=null);var o=i?i.completion:{};return o.type=e,o.arg=t,i?(this.method="next",this.next=i.finallyLoc,_):this.complete(o)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),_},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),M(r),_}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;M(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:D(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=n),_}},i}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports}(D);var L=(0,D.exports)(),U=L;try{regeneratorRuntime=L}catch(e){"object"==("undefined"==typeof globalThis?"undefined":_typeof$3(globalThis))?globalThis.regeneratorRuntime=L:Function("r","regeneratorRuntime = r")(L)}var Y,V,q,F,x,J,B=R(U);function K(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);t>r;r++)n[r]=e[r];return n}function H(e,t){if(e){if("string"==typeof e)return K(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?K(e,t):void 0}}function G(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,i,o,a,s=[],c=!0,u=!1;try{if(o=(r=r.call(e)).next,0===t);else for(;!(c=(n=o.call(r)).done)&&(s.push(n.value),s.length!==t);c=!0);}catch(e){u=!0,i=e}finally{try{if(!c&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(u)throw i}}return s}}(e,t)||H(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}!function(e){var t;(t=e.Result||(e.Result={}))[t.Ok=0]="Ok",t[t.Error=1]="Error"}(Y||(Y={})),function(e){var t;(t=e.MessageType||(e.MessageType={}))[t.TYPE_UNKNOWN=0]="TYPE_UNKNOWN",t[t.TYPE_NODE_JOIN=1]="TYPE_NODE_JOIN",t[t.TYPE_NODE_JOIN_CONFIRM=2]="TYPE_NODE_JOIN_CONFIRM",t[t.TYPE_NODE_LEFT=3]="TYPE_NODE_LEFT",t[t.TYPE_ATTACH_USER_CONFIRM=4]="TYPE_ATTACH_USER_CONFIRM",t[t.TYPE_DETACH_USER_CONFIRM=5]="TYPE_DETACH_USER_CONFIRM",t[t.TYPE_NODE_MAP_UPDATE=6]="TYPE_NODE_MAP_UPDATE",t[t.TYPE_CREATE_SESSION=7]="TYPE_CREATE_SESSION",t[t.TYPE_CREATE_SESSION_CONFIRM=8]="TYPE_CREATE_SESSION_CONFIRM",t[t.TYPE_SESSION_CREATED=9]="TYPE_SESSION_CREATED",t[t.TYPE_JOIN_SESSION=10]="TYPE_JOIN_SESSION",t[t.TYPE_JOIN_SESSION_CONFIRM=11]="TYPE_JOIN_SESSION_CONFIRM",t[t.TYPE_LEAVE_SESSION=12]="TYPE_LEAVE_SESSION",t[t.TYPE_LEAVE_SESSION_CONFIRM=13]="TYPE_LEAVE_SESSION_CONFIRM",t[t.TYPE_CLOSE_SESSION=14]="TYPE_CLOSE_SESSION",t[t.TYPE_CLOSE_SESSION_CONFIRM=15]="TYPE_CLOSE_SESSION_CONFIRM",t[t.TYPE_SESSION_CLOSED=16]="TYPE_SESSION_CLOSED",t[t.TYPE_SESSION_CMD_DATA=17]="TYPE_SESSION_CMD_DATA",t[t.TYPE_SESSION_CMD_DATA_CONFIRM=18]="TYPE_SESSION_CMD_DATA_CONFIRM",t[t.TYPE_SESSION_CMD_DATA_NOTIFICATION=19]="TYPE_SESSION_CMD_DATA_NOTIFICATION",t[t.TYPE_SESSION_DATA=20]="TYPE_SESSION_DATA",t[t.TYPE_NODE_MAP_SNAPSHOT=21]="TYPE_NODE_MAP_SNAPSHOT",t[t.TYPE_CLOSE_SWITCHER=22]="TYPE_CLOSE_SWITCHER",t[t.TYPE_KICK_USER=23]="TYPE_KICK_USER"}(V||(V={})),function(e){var t;(t=e.Type||(e.Type={}))[t.kUnknown=0]="kUnknown",t[t.kConnectReq=1]="kConnectReq",t[t.kConnectResp=2]="kConnectResp",t[t.kDisconnect=3]="kDisconnect",t[t.kChannelCreated=4]="kChannelCreated",t[t.kChannelClosed=5]="kChannelClosed",t[t.kPing=6]="kPing",t[t.kPong=7]="kPong",t[t.kData=64]="kData"}(q||(q={})),function(e){var t;(t=e.RpcType||(e.RpcType={}))[t.Req=0]="Req",t[t.Resp=1]="Resp"}(F||(F={})),function(e){var t,r,n;(t=e.MessageType||(e.MessageType={}))[t.AuthType=0]="AuthType",t[t.AuthResponseType=1]="AuthResponseType",t[t.ChannelBindType=2]="ChannelBindType",t[t.ChannelBindResponseType=3]="ChannelBindResponseType",t[t.KeepaliveType=4]="KeepaliveType",t[t.KeepaliveResponseType=5]="KeepaliveResponseType",t[t.ChannelDataType=6]="ChannelDataType",t[t.ReAuthType=7]="ReAuthType",t[t.ReAuthResponseType=8]="ReAuthResponseType",t[t.RefreshTicketType=9]="RefreshTicketType",t[t.RefreshTicketResponseType=10]="RefreshTicketResponseType",t[t.ServerRequestType=11]="ServerRequestType",function(e){e[e.Ok=0]="Ok",e[e.Error=1]="Error",e[e.ErrorLogin=2]="ErrorLogin",e[e.ErrorDSInternal=3]="ErrorDSInternal"}(e.ErrorCode||(e.ErrorCode={})),(r=e.AuthErrorMsg||(e.AuthErrorMsg={}))[r.SignatureInvalid=0]="SignatureInvalid",r[r.Expired=1]="Expired",r[r.Unavailable=2]="Unavailable",function(e){e[e.MessageChannel=0]="MessageChannel",e[e.PortalChannel=1]="PortalChannel",e[e.DataSwitcherChannel=2]="DataSwitcherChannel"}(e.ChannelType||(e.ChannelType={})),(n=e.ServerEvent||(e.ServerEvent={}))[n.RejoinRequest=0]="RejoinRequest",n[n.ReauthRequest=1]="ReauthRequest"}(x||(x={}));var W=2e3,z={confirmTypes:[V.MessageType.TYPE_ATTACH_USER_CONFIRM,V.MessageType.TYPE_JOIN_SESSION_CONFIRM,V.MessageType.TYPE_LEAVE_SESSION_CONFIRM,V.MessageType.TYPE_CLOSE_SESSION_CONFIRM,V.MessageType.TYPE_SESSION_CMD_DATA_CONFIRM],rpcTypeKeyMap:I(I(I(I(I({},V.MessageType.TYPE_JOIN_SESSION,"joinSession"),V.MessageType.TYPE_LEAVE_SESSION,"leaveSession"),V.MessageType.TYPE_CLOSE_SESSION,"closeSession"),V.MessageType.TYPE_SESSION_DATA,"sessionData"),V.MessageType.TYPE_SESSION_CMD_DATA,"sessionCmdData"),sendDataTypes:[V.MessageType.TYPE_SESSION_DATA,V.MessageType.TYPE_SESSION_CMD_DATA],msgTypeKeyMap:(J={},I(I(I(I(I(I(I(I(I(I(J,V.MessageType.TYPE_JOIN_SESSION_CONFIRM,"joinSessionConfirm"),V.MessageType.TYPE_CLOSE_SESSION_CONFIRM,"closeSessionConfirm"),V.MessageType.TYPE_SESSION_CLOSED,"sessionClosed"),V.MessageType.TYPE_SESSION_CREATED,"sessionCreated"),V.MessageType.TYPE_LEAVE_SESSION_CONFIRM,"leaveSessionConfirm"),V.MessageType.TYPE_SESSION_CMD_DATA_CONFIRM,"sessionCmdDataConfirm"),V.MessageType.TYPE_SESSION_CMD_DATA_NOTIFICATION,"sessionCmdDataNoti"),V.MessageType.TYPE_SESSION_DATA,"sessionData"),V.MessageType.TYPE_ATTACH_USER_CONFIRM,"attachUserConfirm"),V.MessageType.TYPE_DETACH_USER_CONFIRM,"detachUserConfirm"),I(I(J,V.MessageType.TYPE_NODE_MAP_SNAPSHOT,"nodeMapSnapshot"),V.MessageType.TYPE_NODE_MAP_UPDATE,"nodeMapUpdate"))},Q=getProtobufRoot({options:{syntax:"proto3"},nested:{signal_msg:{nested:{AudioSsrcSpec:{fields:{ssrc:{type:"uint32",id:1},rtxSsrc:{type:"uint32",id:2}}},VideoSsrcSpec:{fields:{ssrc:{type:"uint32",id:1},rtxSsrc:{type:"uint32",id:2},fecSsrc:{type:"uint32",id:3}}},MultiPcAdaptRequestInfo:{fields:{audioSsrcSpec:{rule:"repeated",type:"AudioSsrcSpec",id:1},videoSsrcSpec:{rule:"repeated",type:"VideoSsrcSpec",id:2}}},AudioStreamFormat:{fields:{codec:{type:"string",id:1},sampleRate:{type:"int64",id:2},channelNum:{type:"int64",id:3}}},AudioFormatPreference:{fields:{preferred:{type:"AudioStreamFormat",id:1},optional:{rule:"repeated",type:"AudioStreamFormat",id:2}}},AudioStreamOptional:{fields:{format:{rule:"repeated",type:"AudioStreamFormat",id:1}}},VideoStreamFormat:{fields:{codec:{type:"string",id:1},profile:{type:"string",id:2}}},VideoFormatPreference:{fields:{preferred:{type:"VideoStreamFormat",id:1},optional:{rule:"repeated",type:"VideoStreamFormat",id:2}}},FormatPreference:{fields:{audio:{type:"AudioFormatPreference",id:1},video:{type:"VideoFormatPreference",id:2}}},Resolution:{fields:{width:{type:"uint32",id:1},height:{type:"uint32",id:2}}},VideoSsrcParameters:{fields:{ssrc:{type:"uint32",id:1},framerate:{type:"int32",id:2},resolution:{type:"Resolution",id:3},maxBitrate:{type:"int32",id:4},minBitrate:{type:"int32",id:5},active:{type:"bool",id:6},bitrate:{type:"int64",id:7},tlayer:{type:"int64",id:8},multiSlice:{type:"int64",id:9},keyFrameInterval:{type:"int64",id:10},constantPpsid:{type:"int64",id:11},rid:{type:"string",id:12}}},VideoParameters:{fields:{ssrc:{type:"uint32",id:1},resolution:{type:"Resolution",id:2},framerate:{type:"int32",id:3},bitrate:{type:"string",id:4},multiSlice:{type:"int32",id:5},keyFrameInterval:{type:"int64",id:6},constantPpsid:{type:"int64",id:7}}},GroupVersion:{fields:{id:{type:"string",id:1},ver:{type:"int64",id:2}}},StreamInfo:{fields:{type:{type:"string",id:1},owner:{type:"string",id:2},attributesJsonStr:{type:"string",id:3},label:{type:"string",id:4},createTime:{type:"int64",id:7}}},StreamVideoParameters:{fields:{resolution:{type:"Resolution",id:1},framerate:{type:"int64",id:2},bitrate:{type:"int64",id:3},keyFrameInterval:{type:"int64",id:4},multiSlice:{type:"int64",id:5},constantPpsid:{type:"int64",id:6}}},VideoStreamPara:{fields:{specs:{rule:"repeated",type:"string",id:1},resolution:{rule:"repeated",type:"Resolution",id:2},framerate:{rule:"repeated",type:"int32",id:3},bitrate:{rule:"repeated",type:"string",id:4},keyFrameInterval:{rule:"repeated",type:"int32",id:5}}},VideoStreamOptional:{fields:{format:{rule:"repeated",type:"VideoStreamFormat",id:1},parameters:{type:"VideoStreamPara",id:2}}},StreamAudioDesc:{fields:{trackId:{type:"string",id:1},msid:{type:"string",id:2},status:{type:"string",id:3},format:{type:"AudioStreamFormat",id:4},source:{type:"string",id:5},ssrc:{rule:"repeated",type:"uint32",id:6},ssrcGroup:{rule:"repeated",type:"AudioSsrcSpec",id:7},optional:{type:"AudioStreamOptional",id:8}}},StreamVideoDesc:{fields:{trackId:{type:"string",id:1},msid:{type:"string",id:2},status:{type:"string",id:3},source:{type:"string",id:4},format:{type:"VideoStreamFormat",id:5},ssrc:{rule:"repeated",type:"uint32",id:6},ssrcGroup:{rule:"repeated",type:"VideoSsrcSpec",id:7},parameters:{type:"StreamVideoParameters",id:8},optional:{type:"VideoStreamOptional",id:9}}},StreamMediaDesc:{fields:{audio:{type:"StreamAudioDesc",id:1},video:{type:"StreamVideoDesc",id:2}}},Stream:{fields:{id:{type:"string",id:1},type:{type:"string",id:2},media:{type:"StreamMediaDesc",id:3},info:{type:"StreamInfo",id:4},version:{type:"int64",id:5}}},OriginMsg:{fields:{type:{type:"string",id:1},id:{type:"string",id:2}}},ErrorMsg:{fields:{id:{type:"string",id:1},code:{type:"int32",id:2},msg:{type:"string",id:3},origin:{type:"OriginMsg",id:4}}},ErrorMsgs:{fields:{globalStatus:{type:"string",id:1},detailStatus:{rule:"repeated",type:"ErrorMsg",id:2}}},Permission:{fields:{audio:{type:"bool",id:1},video:{type:"bool",id:2}}},PermissionInfo:{fields:{subscribe:{type:"Permission",id:1},publish:{type:"Permission",id:2},vip:{type:"bool",id:3}}},ParticipantInfo:{fields:{id:{type:"string",id:1},user:{type:"string",id:2},role:{type:"string",id:3},ver:{type:"int64",id:4},propertiesJsonStr:{type:"string",id:5}}},RoomInfo:{fields:{id:{type:"string",id:1},views:{rule:"repeated",type:"string",id:2},participants:{rule:"repeated",type:"ParticipantInfo",id:3},participantsVer:{type:"int64",id:4},streams:{rule:"repeated",type:"Stream",id:5},streamsVer:{type:"uint64",id:6},conferenceVer:{type:"uint64",id:7},ts:{type:"int64",id:8},audioSelectEnableV1:{type:"bool",id:9},simulcastEnableV1:{type:"bool",id:10},mediaOutVideoParameters:{rule:"repeated",type:"VideoStreamFormat",id:11},propertiesJsonStr:{type:"string",id:12},ssrcClientSequence:{type:"uint32",id:13},ssrcMask:{type:"uint32",id:14},timeLeft:{type:"int64",id:15},groupList:{rule:"repeated",type:"string",id:16},groupListVer:{type:"int64",id:17}}},ParticipantVer:{fields:{id:{type:"string",id:1},ver:{type:"int64",id:2}}},ParticipantDetail:{fields:{id:{type:"string",id:1},user:{type:"string",id:2},role:{type:"string",id:3},ver:{type:"int64",id:4},propertiesJsonStr:{type:"string",id:5},permission:{type:"PermissionInfo",id:6}}},QueryParticipantsData:{fields:{id:{type:"string",id:1},data:{type:"ParticipantDetail",id:2}}},SetPropertiesData:{fields:{id:{type:"string",id:1},ver:{type:"int64",id:2},propertiesJsonStr:{type:"string",id:3}}},Os:{fields:{name:{type:"string",id:1},version:{type:"string",id:2}}},Runtime:{fields:{name:{type:"string",id:1},version:{type:"string",id:2}}},Sdk:{fields:{version:{type:"string",id:1},type:{type:"string",id:2}}},UserAgent:{fields:{os:{type:"Os",id:1},runtime:{type:"Runtime",id:2},sdk:{type:"Sdk",id:3}}},JoinRequest:{fields:{protocol:{type:"string",id:1},token:{type:"string",id:2},userAgent:{type:"UserAgent",id:3},configJsonStr:{type:"string",id:4},tid:{type:"string",id:5},traceId:{type:"string",id:6}}},JoinResponse:{fields:{user:{type:"string",id:1},role:{type:"string",id:2},permission:{type:"PermissionInfo",id:3},room:{type:"RoomInfo",id:4},id:{type:"string",id:5}}},RejoinRequest:{fields:{token:{type:"string",id:1},tid:{type:"string",id:2},traceId:{type:"string",id:3}}},RejoinResponse:{fields:{participantsVer:{type:"int64",id:1},streamsVer:{type:"uint64",id:2}}},LeaveRequest:{fields:{roomId:{type:"string",id:1},participantId:{type:"string",id:2},tid:{type:"string",id:3},traceId:{type:"string",id:4}}},QueryParticipantsVerRequest:{fields:{roomId:{type:"string",id:1},participantId:{type:"string",id:2},pids:{rule:"repeated",type:"string",id:3},tid:{type:"string",id:4},traceId:{type:"string",id:5}}},QueryParticipantsVerResponse:{fields:{participants:{rule:"repeated",type:"ParticipantVer",id:1},totalVer:{type:"int64",id:2},msg:{type:"string",id:3}}},QueryParticipantsRequest:{fields:{roomId:{type:"string",id:1},participantId:{type:"string",id:2},pids:{rule:"repeated",type:"string",id:3},tid:{type:"string",id:4},traceId:{type:"string",id:5}}},QueryParticipantsResponse:{fields:{totalVer:{type:"int64",id:1},msg:{type:"string",id:2},participants:{rule:"repeated",type:"QueryParticipantsData",id:3}}},GetParticipantsAndStreamsRequest:{fields:{roomId:{type:"string",id:1},participantId:{type:"string",id:2},pids:{rule:"repeated",type:"string",id:3},tid:{type:"string",id:4},traceId:{type:"string",id:5}}},GetParticipantsAndStreamsResponse:{fields:{ts:{type:"int64",id:1},msg:{type:"string",id:2},participants:{rule:"repeated",type:"ParticipantDetail",id:3},streams:{rule:"repeated",type:"Stream",id:4}}},SetParticipantPropertiesRequest:{fields:{roomId:{type:"string",id:1},participantId:{type:"string",id:2},propertiesJsonStr:{type:"string",id:3},tid:{type:"string",id:4},traceId:{type:"string",id:5}}},RemoveParticipantPropertiesRequest:{fields:{roomId:{type:"string",id:1},participantId:{type:"string",id:2},propertiesJsonStr:{type:"string",id:3},tid:{type:"string",id:4},traceId:{type:"string",id:5}}},ParticipantNotification:{oneofs:{data:{oneof:["info","participantId","propertiesData"]}},fields:{action:{type:"string",id:1},totalVer:{type:"int64",id:2},msgId:{type:"string",id:3},tid:{type:"string",id:4},traceId:{type:"string",id:5},info:{type:"ParticipantInfo",id:10},participantId:{type:"string",id:11},propertiesData:{type:"SetPropertiesData",id:12}}},SyncNotification:{fields:{streamsVer:{type:"int64",id:1},participantsVer:{type:"int64",id:2},conferenceVer:{type:"int64",id:3},msgId:{type:"string",id:4},tid:{type:"string",id:5},traceId:{type:"string",id:6},groupListVer:{type:"int64",id:7},groupVer:{rule:"repeated",type:"GroupVersion",id:8}}},Result:{values:{Ok:0,Error:1}},Response:{oneofs:{data:{oneof:["reason","joinResponse","queryParticipantsResponse","queryParticipantsVerResponse","ticket","rejoinResponse"]}},fields:{result:{type:"Result",id:1},tid:{type:"string",id:2},traceId:{type:"string",id:3},code:{type:"int32",id:4},reason:{type:"string",id:11},joinResponse:{type:"JoinResponse",id:12},queryParticipantsResponse:{type:"QueryParticipantsResponse",id:13},queryParticipantsVerResponse:{type:"QueryParticipantsVerResponse",id:14},ticket:{type:"string",id:20},rejoinResponse:{type:"RejoinResponse",id:23}}},ConferenceNotification:{fields:{action:{type:"string",id:1},ver:{type:"int64",id:2},id:{type:"string",id:3},msgId:{type:"string",id:4},tid:{type:"string",id:5},traceId:{type:"string",id:6},propertiesJsonStr:{type:"string",id:7}}},DropNotification:{fields:{tid:{type:"string",id:1},traceId:{type:"string",id:2},code:{type:"int32",id:3},reason:{type:"string",id:4}}},NotificationItem:{oneofs:{notification:{oneof:["participantNotification","syncNotification","conferenceNotification"]}},fields:{event:{type:"string",id:1},participantNotification:{type:"ParticipantNotification",id:12},syncNotification:{type:"SyncNotification",id:15},conferenceNotification:{type:"ConferenceNotification",id:16}}},BatchNotification:{fields:{notificationItem:{rule:"repeated",type:"NotificationItem",id:1},tid:{type:"string",id:2},traceId:{type:"string",id:3}}}}},ddmsg:{options:{optimize_for:"LITE_RUNTIME"},nested:{Type:{values:{kUnknown:0,kConnectReq:1,kConnectResp:2,kDisconnect:3,kChannelCreated:4,kChannelClosed:5,kPing:6,kPong:7,kData:64}},Message:{oneofs:{messageOneof:{oneof:["connectReq","connectResp","diconnect","channelsCreated","channelsClosed","data"]}},fields:{msgType:{type:"Type",id:1},connectReq:{type:"ConnectReq",id:2},connectResp:{type:"ConnectResp",id:3},diconnect:{type:"Disconnect",id:4},channelsCreated:{type:"ChannelsCreated",id:5},channelsClosed:{type:"ChannelsClosed",id:6},data:{type:"Data",id:64}}},ServerAddress:{fields:{name:{type:"string",id:1},ip:{type:"string",id:2},port:{type:"uint32",id:3}}},Channel:{fields:{channelId:{type:"uint32",id:1},customizedChannelType:{type:"uint32",id:2},ownerEndpointId:{type:"uint32",id:3}}},ConnectReq:{fields:{parentAddr:{type:"ServerAddress",id:1},topAddr:{type:"ServerAddress",id:2},nodeId:{type:"fixed64",id:3},requestId:{type:"int32",id:4},reqData:{type:"bytes",id:10}}},ConnectResp:{fields:{result:{type:"int32",id:1},requestId:{type:"int32",id:2},nodeId:{type:"fixed64",id:3},parentNodeId:{type:"fixed64",id:4},topNodeId:{type:"fixed64",id:5},channels:{rule:"repeated",type:"Channel",id:6},respData:{type:"bytes",id:10}}},Disconnect:{fields:{reason:{type:"int32",id:1}}},ChannelsCreated:{fields:{channels:{rule:"repeated",type:"Channel",id:1}}},ChannelsClosed:{fields:{reason:{type:"int32",id:1},channels:{rule:"repeated",type:"Channel",id:2}}},Data:{fields:{priority:{type:"uint32",id:1},uniform:{type:"bool",id:2},echo:{type:"bool",id:3},compressed:{type:"bool",id:4},from:{type:"fixed64",id:5},to:{type:"fixed64",id:6},excludes:{rule:"repeated",type:"fixed64",id:7},data:{type:"bytes",id:10}}}}},dsmsg:{options:{optimize_for:"LITE_RUNTIME"},nested:{MessageType:{values:{TYPE_UNKNOWN:0,TYPE_NODE_JOIN:1,TYPE_NODE_JOIN_CONFIRM:2,TYPE_NODE_LEFT:3,TYPE_ATTACH_USER_CONFIRM:4,TYPE_DETACH_USER_CONFIRM:5,TYPE_NODE_MAP_UPDATE:6,TYPE_CREATE_SESSION:7,TYPE_CREATE_SESSION_CONFIRM:8,TYPE_SESSION_CREATED:9,TYPE_JOIN_SESSION:10,TYPE_JOIN_SESSION_CONFIRM:11,TYPE_LEAVE_SESSION:12,TYPE_LEAVE_SESSION_CONFIRM:13,TYPE_CLOSE_SESSION:14,TYPE_CLOSE_SESSION_CONFIRM:15,TYPE_SESSION_CLOSED:16,TYPE_SESSION_CMD_DATA:17,TYPE_SESSION_CMD_DATA_CONFIRM:18,TYPE_SESSION_CMD_DATA_NOTIFICATION:19,TYPE_SESSION_DATA:20,TYPE_NODE_MAP_SNAPSHOT:21}},Message:{oneofs:{messageOneof:{oneof:["nodeJoin","nodeJoinConfirm","nodeLeft","attachUserConfirm","detachUserConfirm","nodeMapUpdate","createSession","createSessionConfirm","sessionCreated","joinSession","joinSessionConfirm","leaveSession","leaveSessionConfirm","closeSession","closeSessionConfirm","sessionClosed","sessionCmdData","sessionCmdDataConfirm","sessionCmdDataNoti","sessionData","nodeMapSnapshot"]}},fields:{version:{type:"int32",id:1},type:{type:"MessageType",id:2},nodeJoin:{type:"NodeJoin",id:3},nodeJoinConfirm:{type:"NodeJoinConfirm",id:4},nodeLeft:{type:"NodeLeft",id:5},attachUserConfirm:{type:"AttachUserConfirm",id:6},detachUserConfirm:{type:"DetachUserConfirm",id:7},nodeMapUpdate:{type:"NodeMapUpdate",id:8},createSession:{type:"CreateSession",id:9},createSessionConfirm:{type:"CreateSessionConfirm",id:10},sessionCreated:{type:"SessionCreated",id:11},joinSession:{type:"JoinSession",id:12},joinSessionConfirm:{type:"JoinSessionConfirm",id:13},leaveSession:{type:"LeaveSession",id:14},leaveSessionConfirm:{type:"LeaveSessionConfirm",id:15},closeSession:{type:"CloseSession",id:16},closeSessionConfirm:{type:"CloseSessionConfirm",id:17},sessionClosed:{type:"SessionClosed",id:18},sessionCmdData:{type:"SessionCmdData",id:19},sessionCmdDataConfirm:{type:"SessionCmdDataConfirm",id:20},sessionCmdDataNoti:{type:"SessionCmdDataNotification",id:21},sessionData:{type:"SessionData",id:22},nodeMapSnapshot:{type:"NodeMapSnapshot",id:23}}},NodeJoin:{fields:{nodeName:{type:"string",id:1}}},NodeJoinConfirm:{fields:{nodeName:{type:"string",id:1},channels:{rule:"repeated",type:"Channel",id:2},endpointId:{type:"int32",id:3},sessionCreateds:{rule:"repeated",type:"SessionCreated",id:4},config:{type:"Config",id:5}}},Config:{fields:{nodeInfoBundleSize:{type:"int32",id:1}}},NodeLeft:{fields:{nodeId:{type:"uint64",id:1}}},AttachUserConfirm:{fields:{pid:{type:"string",id:1},nodeId:{type:"uint64",id:2},serverNodeId:{type:"uint64",id:3},topServerNodeId:{type:"uint64",id:4},endpointId:{type:"int32",id:5},result:{type:"uint32",id:6},channels:{rule:"repeated",type:"Channel",id:7},sessionCreateds:{rule:"repeated",type:"SessionCreated",id:8},reason:{type:"uint32",id:9}}},DetachUser:{fields:{pid:{type:"string",id:1},nodeId:{type:"uint64",id:2},reason:{type:"uint32",id:3}}},DetachUserConfirm:{fields:{pid:{type:"string",id:1},nodeId:{type:"uint64",id:2},result:{type:"uint32",id:3}}},NodeMapUpdate:{fields:{items:{rule:"repeated",type:"NodeMapUpdateItem",id:1}}},NodeMapUpdateItem:{fields:{pid:{type:"string",id:1},nodeId:{type:"uint64",id:2},action:{type:"uint32",id:3}}},NodeMapSnapshot:{fields:{start:{type:"bool",id:1},end:{type:"bool",id:2},items:{rule:"repeated",type:"NodeMapUpdateItem",id:3}}},NodeMapSnapshotItem:{fields:{pid:{type:"string",id:1},nodeId:{type:"uint64",id:2}}},CreateSession:{fields:{sessionType:{type:"int32",id:1},sessionKey:{type:"string",id:2}}},CreateSessionConfirm:{fields:{sessionType:{type:"int32",id:1},sessionKey:{type:"string",id:2},endpointId:{type:"int32",id:3},result:{type:"uint32",id:4}}},SessionCreated:{fields:{sessionType:{type:"int32",id:1},sessionKey:{type:"string",id:2},endpointId:{type:"int32",id:3},channels:{rule:"repeated",type:"Channel",id:4}}},JoinSession:{fields:{sessionType:{type:"int32",id:1},sessionKey:{type:"string",id:2},pid:{type:"string",id:3},nodeId:{type:"uint64",id:4}}},JoinSessionConfirm:{fields:{sessionType:{type:"int32",id:1},sessionKey:{type:"string",id:2},endpointId:{type:"int32",id:3},pid:{type:"string",id:4},nodeId:{type:"uint64",id:5},result:{type:"uint32",id:6},channels:{rule:"repeated",type:"Channel",id:7}}},LeaveSession:{fields:{sessionType:{type:"int32",id:1},sessionKey:{type:"string",id:2},nodeId:{type:"uint64",id:3}}},LeaveSessionConfirm:{fields:{sessionType:{type:"int32",id:1},sessionKey:{type:"string",id:2},nodeId:{type:"uint64",id:3},result:{type:"uint32",id:4}}},CloseSession:{fields:{sessionType:{type:"int32",id:1},sessionKey:{type:"string",id:2},nodeId:{type:"uint64",id:3}}},CloseSessionConfirm:{fields:{sessionType:{type:"int32",id:1},sessionKey:{type:"string",id:2},result:{type:"uint32",id:3}}},SessionClosed:{fields:{sessionType:{type:"int32",id:1},sessionKey:{type:"string",id:2}}},Channel:{fields:{id:{type:"int32",id:1},type:{type:"uint32",id:2}}},SessionCmdData:{fields:{cmdType:{type:"uint32",id:1},cmd:{type:"string",id:2},requestId:{type:"uint32",id:3},data:{type:"bytes",id:4},broadcast:{type:"bool",id:5},echo:{type:"bool",id:6},toNodeId:{type:"uint64",id:7},fromPid:{type:"string",id:8}}},SessionCmdDataConfirm:{fields:{cmdType:{type:"uint32",id:1},cmd:{type:"string",id:2},requestId:{type:"uint32",id:3},result:{type:"uint32",id:4},fromPid:{type:"string",id:5}}},SessionCmdDataNotification:{fields:{cmdType:{type:"uint32",id:1},cmd:{type:"string",id:2},requestId:{type:"uint32",id:3},data:{type:"bytes",id:4},fromPid:{type:"string",id:5}}},SessionData:{fields:{data:{type:"bytes",id:1}}}}},rpc:{nested:{RpcType:{values:{Req:0,Resp:1}},RpcMessage:{fields:{Version:{type:"uint32",id:1},MagicNumber:{type:"uint32",id:2},Type:{type:"RpcType",id:3},RpcId:{type:"uint32",id:4},NeedAck:{type:"bool",id:5},Method:{type:"string",id:6},Data:{type:"bytes",id:7}}}}},transport:{nested:{MessageType:{values:{AuthType:0,AuthResponseType:1,ChannelBindType:2,ChannelBindResponseType:3,KeepaliveType:4,KeepaliveResponseType:5,ChannelDataType:6,ReAuthType:7,ReAuthResponseType:8,RefreshTicketType:9,RefreshTicketResponseType:10,ServerRequestType:11}},ErrorCode:{values:{Ok:0,Error:1,ErrorLogin:2,ErrorDSInternal:3}},PingConfig:{fields:{pingInterval:{type:"uint32",id:1},pingTimeout:{type:"uint32",id:2}}},TransportOptions:{oneofs:{_supportPingConfig:{oneof:["supportPingConfig"]}},fields:{supportReliable:{type:"bool",id:1},reliableId:{type:"string",id:2},supportPingConfig:{type:"bool",id:3,options:{proto3_optional:!0}}}},AuthErrorMsg:{values:{SignatureInvalid:0,Expired:1,Unavailable:2}},Auth:{fields:{token:{type:"string",id:1},duplicate:{type:"bool",id:2},options:{type:"TransportOptions",id:3}}},AuthResponse:{fields:{code:{type:"ErrorCode",id:1},reason:{type:"string",id:2},ticket:{type:"string",id:3},errorMsg:{type:"AuthErrorMsg",id:4},pingConfig:{type:"PingConfig",id:5}}},ReAuth:{fields:{id:{type:"string",id:1},ticket:{type:"string",id:2},options:{type:"TransportOptions",id:3}}},ReAuthResponse:{fields:{code:{type:"ErrorCode",id:1},reason:{type:"string",id:2},ticket:{type:"string",id:3},errorMsg:{type:"AuthErrorMsg",id:4},pingConfig:{type:"PingConfig",id:5}}},RefreshTicket:{fields:{}},RefreshTicketResponse:{fields:{code:{type:"ErrorCode",id:1},reason:{type:"string",id:2},ticket:{type:"string",id:3}}},ChannelType:{values:{MessageChannel:0,PortalChannel:1}},ChannelBind:{fields:{type:{type:"ChannelType",id:1},chanId:{type:"uint64",id:2},address:{type:"string",id:3}}},ChannelBindResponse:{fields:{code:{type:"ErrorCode",id:1},reason:{type:"string",id:2}}},Keepalive:{fields:{sequence:{type:"uint32",id:1},pingMs:{type:"uint64",id:2}}},KeepaliveResponse:{fields:{sequence:{type:"uint32",id:1},pongMs:{type:"uint64",id:2}}},ChannelData:{fields:{chanId:{type:"uint64",id:1},data:{type:"bytes",id:2}}},ServerEvent:{values:{RejoinRequest:0,ReauthRequest:1}},Notification:{fields:{event:{type:"ServerEvent",id:1}}},Message:{oneofs:{data:{oneof:["auth","authResponse","channelBind","channelBindResponse","keepalive","keepaliveResponse","channelData","reauth","reauthResponse","refreshTicket","refreshTicketResponse","notification"]}},fields:{Type:{type:"MessageType",id:1},Version:{type:"uint32",id:2},SequenceId:{type:"uint32",id:3},auth:{type:"Auth",id:11},authResponse:{type:"AuthResponse",id:12},channelBind:{type:"ChannelBind",id:13},channelBindResponse:{type:"ChannelBindResponse",id:14},keepalive:{type:"Keepalive",id:15},keepaliveResponse:{type:"KeepaliveResponse",id:16},channelData:{type:"ChannelData",id:17},reauth:{type:"ReAuth",id:18},reauthResponse:{type:"ReAuthResponse",id:19},refreshTicket:{type:"RefreshTicket",id:20},refreshTicketResponse:{type:"RefreshTicketResponse",id:21},notification:{type:"Notification",id:22}}}}}}}),Z=Q.lookupType("signal_msg.Response"),$=Q.lookupType("signal_msg.BatchNotification"),X=Q.lookupType("signal_msg.ParticipantNotification"),ee=Q.lookupType("signal_msg.ConferenceNotification"),te=Q.lookupType("signal_msg.DropNotification"),ne=Q.lookupType("signal_msg.SyncNotification"),ie=Q.lookupType("signal_msg.RejoinRequest"),re=Q.lookupType("signal_msg.QueryParticipantsVerRequest"),oe=Q.lookupType("signal_msg.QueryParticipantsRequest"),ae=Q.lookupType("signal_msg.JoinRequest"),se=Q.lookupType("transport.Message"),ce=Q.lookupType("rpc.RpcMessage"),de=Q.lookupType("ddmsg.Message"),le=Q.lookupType("dsmsg.Message");function pe(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(pe=function(){return!!e})()}Q.lookupType("ddmsg.Data");var ue=function(){function e(){var t,r,n;return C(this,e),r=this,n=P(n=e),t=k(r,pe()?Reflect.construct(n,[],P(r).constructor):n.apply(r,undefined)),Object.defineProperty(t,"timer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(t,"seconds",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(t,"gapTime",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(t,"sequence",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(t,"maxTime",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),t.timer=null,t.gapTime=15e3,t.maxTime=6e4,t.seconds=0,t.sequence=0,t}return w(e,EventEmitter),_(e,[{key:"start",value:function(e){var t=this,r=e||{},n=r.pingInterval,i=r.pingTimeout;n&&i&&(this.stop(),this.gapTime=1e3*n,this.maxTime=1e3*i),this.timer||(this.ping(),this.timer=addTimer((function(){if(t.seconds++,1e3*t.seconds%t.gapTime==0&&t.ping(),1e3*t.seconds>t.maxTime)throw t.stop(),t.emit("retry"),new DingRTCError(ErrorCode.ConnectionHeartbeatTimeout)}),1e3,"interval"))}},{key:"ping",value:function(){var e={sequence:++this.sequence,pingMs:Date.now()};this.emit("ping",{keepalive:e})}},{key:"pong",value:function(e){this.sequence=e.sequence,this.seconds=0}},{key:"stop",value:function(){this.timer&&(removeTimer(this.timer,"interval"),this.timer=null,this.sequence=0,this.seconds=0)}}])}();function fe(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(fe=function(){return!!e})()}var ye,he,ge,ve,me,be,Se,Te,Ee,Oe=function(){function e(t,r){var n,i,o;return C(this,e),i=this,o=P(o=e),n=k(i,fe()?Reflect.construct(o,[],P(i).constructor):o.apply(i,undefined)),Object.defineProperty(n,"socket",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(n,"reporter",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(n,"rpcId",{enumerable:!0,configurable:!0,writable:!0,value:20}),Object.defineProperty(n,"requestMap",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(n,"domain",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),n.socket=t,n.reporter=r,n.requestMap=new Map,n}return w(e,EventEmitter),_(e,[{key:"connect",value:function(e,t){var r=this,n=parseBase64(e),i=n.secure,o=n.relayServerHosts,a=void 0===o?[]:o;return a[0]&&(this.domain=a[0]),new Promise((function(n,o){var s=(i?"wss":"ws")+"://"+(a[0]||r.domain);r.socket.removeAllListeners(),r.socket.init(s,e,t),r.socket.on("reauth",(function(){r.emit("reauth")})),r.socket.on("rejoin",(function(){r.emit("rejoin")})),r.socket.on("connection-state-change",(function(e,t,i){r.emit("connection-state-change",e,t,i),"disconnected"===e?o(i):"connected"===e&&n()}))}))}},{key:"disconnect",value:function(){var e;if(this.requestMap.clear(),null!==(e=this.socket)&&void 0!==e&&e.instance&&"disconnected"!==this.socket.state)return this.socket.close(!0)}},{key:"send",value:function(e,t){var r=this,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,i=arguments.length>3&&void 0!==arguments[3]&&arguments[3],o={MagicNumber:5,Version:1,Type:0,NeedAck:!0,RpcId:this.rpcId++,Method:e,Data:t},a=ce.encode(o).finish();return i&&this.reporter.log.debug("rpcId ".concat(o.RpcId,":").concat(e," param====> ").concat(JSON.stringify(n||""))),new Promise((function(t,s){r.socket.send(x.MessageType.ChannelDataType,{channelData:{data:a,chanId:1}},o.RpcId,e);var c=o.RpcId;r.requestMap.set(c,{resolve:t,reject:s,payload:{methond:e,internal:i,rpcId:c,param:n||""}}),addTimer((function(){var t=r.requestMap.get(c);null!=t&&t.reject&&(t.reject(new DingRTCError(ErrorCode.APICallTimeOut,"".concat(e," timeout"))),r.requestMap.delete(c))}),1e4)}))}},{key:"handleNotification",value:function(e,t){var r=this;if("batch-notify"===e){var n=$.decode(t).notificationItem,i=["participant","conference","sync"];n.forEach((function(e){"participant"===e.event?r.emit("participant",e.participantNotification):"conference"===e.event?r.emit("conference",e.conferenceNotification):"sync"===e.event&&r.emit("sync",e.syncNotification)})),n.filter((function(e){return!i.includes(e.event)})).length&&this.emit("batch-notify",t)}else"participant"===e?this.emit("participant",X.decode(t)):"conference"===e?this.emit("conference",ee.decode(t)):"drop"===e?this.emit("drop",te.decode(t)):"sync"===e?this.emit("sync",ne.decode(t)):this.emit("notify",e,t)}},{key:"onMessage",value:function(e){var t=ce.decode(new Uint8Array(e.channelData.data));if(t.Type===F.RpcType.Resp){var r=this.requestMap.get(t.RpcId);if(!r)return;var n=r.resolve,i=r.reject,o=r.payload;if(o.internal){var a=Z.decode(t.Data);a.result===Y.Result.Ok?(this.reporter.log.debug("rpcId ".concat(o.rpcId,": ").concat(o.methond," result====> ").concat(JSON.stringify(a))),n(a)):(this.reporter.log.error("rpcId ".concat(o.rpcId,": ").concat(o.methond," error====> ").concat(JSON.stringify(a))),i(a))}else n(t.Data);this.requestMap.delete(t.RpcId)}else t.Type===F.RpcType.Req&&this.handleNotification(t.Method,t.Data)}}])}();!function(e){e[e.UserKickOut=2011]="UserKickOut",e[e.UserReplaced=2012]="UserReplaced"}(ye||(ye={})),function(e){e[e.UnknownId=0]="UnknownId",e[e.ControlNodeId=1]="ControlNodeId",e[e.TerminalNodeId=2]="TerminalNodeId",e[e.ChannelId=3]="ChannelId"}(he||(he={})),function(e){e[e.NORMAL_ATTACH=0]="NORMAL_ATTACH",e[e.FORCE_REATTACH=1]="FORCE_REATTACH",e[e.RESYNC=2]="RESYNC"}(ge||(ge={})),function(e){e[e.NODE_JOIN=0]="NODE_JOIN",e[e.NODE_LEAVE=1]="NODE_LEAVE"}(ve||(ve={})),function(e){e[e.High=0]="High",e[e.Normal=1]="Normal",e[e.Low=2]="Low"}(me||(me={})),function(e){e.UNINITED="uninited",e.READY="ready",e.LEFT="left",e.CLOSED="closed"}(be||(be={})),function(e){e[e.SUCCESS=0]="SUCCESS",e[e.SWITCHER_NOT_FOUND=1]="SWITCHER_NOT_FOUND",e[e.USER_NOT_FOUND=4]="USER_NOT_FOUND",e[e.CREATE_SESSION_FAILED=5]="CREATE_SESSION_FAILED",e[e.SESSION_NOT_FOUND=6]="SESSION_NOT_FOUND",e[e.SESSION_INIT_FAILED=7]="SESSION_INIT_FAILED",e[e.TOP_UNAVAILABLE=8]="TOP_UNAVAILABLE",e[e.SWITCHER_DESTROYED=9]="SWITCHER_DESTROYED",e[e.INIT_THREAD_POOL_FAILED=10]="INIT_THREAD_POOL_FAILED",e[e.CREATE_LOCAL_ENDPOINT_FAILED=11]="CREATE_LOCAL_ENDPOINT_FAILED",e[e.CREATE_CHANNEL_FAILED=12]="CREATE_CHANNEL_FAILED",e[e.RECOVER_TIMEOUT=13]="RECOVER_TIMEOUT",e[e.SESSION_CMD_PID_NOTFOUND=51]="SESSION_CMD_PID_NOTFOUND",e[e.SESSION_ALREADY_CLOSED=1e3]="SESSION_ALREADY_CLOSED",e[e.SESSION_NOT_READY=1001]="SESSION_NOT_READY",e[e.SESSION_LEAVE_BY_USER=30]="SESSION_LEAVE_BY_USER",e[e.SESSION_LEAVE_FOR_SESSION_CLOSED=31]="SESSION_LEAVE_FOR_SESSION_CLOSED",e[e.SESSION_LEAVE_BY_USER_FAILED=32]="SESSION_LEAVE_BY_USER_FAILED",e[e.SESSION_LEAVE_BY_USER_FAILED_RECONNECT=34]="SESSION_LEAVE_BY_USER_FAILED_RECONNECT",e[e.SESSION_CLOSE_FAILED_RECONNECT=41]="SESSION_CLOSE_FAILED_RECONNECT"}(Se||(Se={})),function(e){e.UNINITED="uninited",e.BINDING="binding",e.READY="ready",e.CLOSED="closed"}(Te||(Te={})),function(e){e[e.UNKNOWN=0]="UNKNOWN",e[e.DEFAULT=1]="DEFAULT",e[e.NODE_MAP=2]="NODE_MAP"}(Ee||(Ee={}));var Ie=function(){function e(){C(this,e)}return _(e,null,[{key:"isValidId",value:function(t){if("number"==typeof t){if(!(t&~e.ChannelMask))return!0;var r=(e.NodeTypeMask&t)==e.NodeTypeMask,n=!(e.TerminalMask&t);return!(!r&&n||r&&!n||(n=!(e.CtrlLayer1Mask&t),(r=(e.UseCtrlL1Mask&t)==e.UseCtrlL1Mask)&&n||!r&&!n))}var i=new Long(t.low,t.high,t.unsigned);if(i.and(e.ChannelMaskLong.not()).eq(Long.ZERO))return!0;var o=i.and(e.NodeTypeMaskLong).eq(e.NodeTypeMaskLong),a=i.and(e.TerminalMaskLong).eq(Long.ZERO);if(!o&&a||o&&!a)return!1;var s=i.and(e.UseCtrlL1MaskLong).eq(e.UseCtrlL1MaskLong),c=i.and(e.CtrlLayer1MaskLong).eq(Long.ZERO);return!(s&&c||!s&&!c)}},{key:"getIdType",value:function(t){if("number"==typeof t)return(t&e.ChannelMask)==t?he.ChannelId:e.isValidId(t)?(t&e.NodeTypeMask)==e.NodeTypeMask?he.ControlNodeId:he.TerminalNodeId:he.UnknownId;var r=new Long(t.low,t.high,t.unsigned);return r.and(e.ChannelMaskLong).eq(r)?he.ChannelId:e.isValidId(t)?r.and(e.NodeTypeMaskLong).eq(e.NodeTypeMaskLong)?he.ControlNodeId:he.TerminalNodeId:he.UnknownId}},{key:"replaceClusterId",value:function(t,r){return t.and(e.ClusterIdMaskLong.not()).or(Long.fromNumber(r).shiftLeft(42))}},{key:"getTopNodeId",value:function(t){return(4095&t)<<42|e.NodeTypeMask}},{key:"extractParentNodeId",value:function(t,r){if(!this.isValidId(t))return Long.fromNumber(0);var n="number"==typeof t?Long.fromNumber(t):new Long(t.low,t.high,t.unsigned),i=n.and(e.EndpointMask),o=n.and(e.NodeTypeMask).equals(e.NodeTypeMask),a=n.and(e.UseCtrlL1Mask).equals(e.UseCtrlL1Mask);return o&&a||!o&&!a?e.replaceClusterId(e.NodeTypeMaskLong.or(e.CtrlLayer0MaskLong.and(n)),r).or(i):o&&!a?e.replaceClusterId(Long.fromNumber(e.NodeTypeMask),r).or(i):!o&&a?e.replaceClusterId(e.NodeTypeMaskLong.or(e.UseCtrlL1MaskLong).or(e.CtrlLayer0MaskLong.or(e.CtrlLayer1MaskLong).and(n)),r).or(i):0}},{key:"extractNodeIdWithoutClusterId",value:function(t){var r="number"==typeof t?Long.fromNumber(t):new Long(t.low,t.high,t.unsigned),n=e.EndpointMaskLong.or(e.ClusterIdMaskLong).or(e.ReservedMaskLong);return r.and(n.not())}},{key:"isTopControlNode",value:function(t){var r="number"==typeof t?Long.fromNumber(t):new Long(t.low,t.high,t.unsigned);return r.and(e.NodeTypeMaskLong).equals(e.NodeTypeMaskLong)&&r.and(e.UseCtrlL1MaskLong).or(e.CtrlLayer0MaskLong).or(e.CtrlLayer1MaskLong).or(e.TerminalMaskLong)}},{key:"isDirectChild",value:function(t,r){if(!(r&e.NodeTypeMask))return!1;var n=t&(e.CtrlLayer0Mask|e.CtrlLayer1Mask|e.TerminalMask),i=r&(e.CtrlLayer0Mask|e.CtrlLayer1Mask|e.TerminalMask);return!(n==r||0==t||i!=(n&(e.CtrlLayer0Mask|e.CtrlLayer1Mask))&&(i!=(n&e.CtrlLayer0Mask)||n&~(e.CtrlLayer0Mask|e.CtrlLayer1Mask))&&(0!=i||t&~e.CtrlLayer0Mask))}},{key:"isChild",value:function(t,r){if(!(r&e.NodeTypeMask))return!1;var n=t&(e.CtrlLayer0Mask|e.CtrlLayer1Mask|e.TerminalMask),i=r&(e.CtrlLayer0Mask|e.CtrlLayer1Mask|e.TerminalMask);return n!==i&&0!==n&&(0===i||r==(n&(e.CtrlLayer0Mask|e.CtrlLayer1Mask))||i==(n&e.CtrlLayer0Mask))}},{key:"isMe",value:function(t,r){if(!this.isValidId(t)||!this.isValidId(r))return!1;var n="number"==typeof t?Long.fromNumber(t):new Long(t.low,t.high,t.unsigned),i="number"==typeof r?Long.fromNumber(r):new Long(r.low,r.high,r.unsigned),o=e.EndpointMaskLong.or(e.ClusterIdMask).or(e.ReservedMaskLong);return n.and(o.not()).eq(i.and(o.not()))}},{key:"extractEndpointId",value:function(t){return("number"==typeof t?Long.fromNumber(t):new Long(t.low,t.high,t.unsigned)).and(e.EndpointMaskLong).low}},{key:"composeId",value:function(t,r){var n="number"==typeof t?Long.fromNumber(t):new Long(t.low,t.high,t.unsigned),i="number"==typeof r?Long.fromNumber(r):new Long(r.low,r.high,r.unsigned),o=n.and(e.EndpointMaskLong.not()).or(i);return{low:o.and(e.EndpointMaskLong.not()).or(i).low,high:o.high,unsigned:o.unsigned}}},{key:"extractNodeId",value:function(t){var r=("number"==typeof t?Long.fromNumber(t):new Long(t.low,t.high,t.unsigned)).and(e.EndpointMaskLong.not());return{low:r.low,high:r.high,unsigned:r.unsigned}}}])}();function Ce(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function Ne(e){for(var t=1;arguments.length>t;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Ce(Object(r),!0).forEach((function(t){I(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Ce(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function _e(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(_e=function(){return!!e})()}Object.defineProperty(Ie,"ReservedMask",{enumerable:!0,configurable:!0,writable:!0,value:-4194304}),Object.defineProperty(Ie,"ClusterIdMask",{enumerable:!0,configurable:!0,writable:!0,value:4193280}),Object.defineProperty(Ie,"NodeTypeMask",{enumerable:!0,configurable:!0,writable:!0,value:512}),Object.defineProperty(Ie,"UseCtrlL1Mask",{enumerable:!0,configurable:!0,writable:!0,value:256}),Object.defineProperty(Ie,"CtrlLayer0Mask",{enumerable:!0,configurable:!0,writable:!0,value:1023<<30}),Object.defineProperty(Ie,"CtrlLayer1Mask",{enumerable:!0,configurable:!0,writable:!0,value:1023<<20}),Object.defineProperty(Ie,"TerminalMask",{enumerable:!0,configurable:!0,writable:!0,value:1048320}),Object.defineProperty(Ie,"EndpointMask",{enumerable:!0,configurable:!0,writable:!0,value:255}),Object.defineProperty(Ie,"ChannelMask",{enumerable:!0,configurable:!0,writable:!0,value:255}),Object.defineProperty(Ie,"ReservedMaskLong",{enumerable:!0,configurable:!0,writable:!0,value:Long.fromNumber(1023).shiftLeft(54)}),Object.defineProperty(Ie,"ClusterIdMaskLong",{enumerable:!0,configurable:!0,writable:!0,value:Long.fromNumber(4095).shiftLeft(42)}),Object.defineProperty(Ie,"NodeTypeMaskLong",{enumerable:!0,configurable:!0,writable:!0,value:Long.fromNumber(1).shiftLeft(41)}),Object.defineProperty(Ie,"UseCtrlL1MaskLong",{enumerable:!0,configurable:!0,writable:!0,value:Long.fromNumber(1).shiftLeft(40)}),Object.defineProperty(Ie,"CtrlLayer0MaskLong",{enumerable:!0,configurable:!0,writable:!0,value:Long.fromNumber(1023).shiftLeft(30)}),Object.defineProperty(Ie,"CtrlLayer1MaskLong",{enumerable:!0,configurable:!0,writable:!0,value:Long.fromNumber(63).shiftLeft(20)}),Object.defineProperty(Ie,"TerminalMaskLong",{enumerable:!0,configurable:!0,writable:!0,value:Long.fromNumber(4095).shiftLeft(8)}),Object.defineProperty(Ie,"EndpointMaskLong",{enumerable:!0,configurable:!0,writable:!0,value:Long.fromNumber(255)}),Object.defineProperty(Ie,"ChannelMaskLong",{enumerable:!0,configurable:!0,writable:!0,value:Long.fromNumber(255)});var ke=function(){function e(t,r){var n,i,o;return C(this,e),i=this,o=P(o=e),n=k(i,_e()?Reflect.construct(o,[],P(i).constructor):o.apply(i,undefined)),Object.defineProperty(n,"socket",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(n,"log",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(n,"requestMap",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),n.socket=t,n.log=r,n.requestMap=new Map,n}return w(e,EventEmitter),_(e,[{key:"channelBind",value:function(e){var t=this,r={chanId:2,type:x.ChannelType.DataSwitcherChannel,address:location.hostname},n="".concat(e,"#").concat(V.MessageType.TYPE_ATTACH_USER_CONFIRM);return this.commitRPC((function(){return t.socket.send(x.MessageType.ChannelBindType,{channelBind:r}).catch((function(e){var r;null===(r=t.requestMap.get(n))||void 0===r||r.reject(e),t.requestMap.delete(n)}))}),n)}},{key:"commitRPC",value:function(e,t){var r=this;return t?new Promise((function(n,i){e(),r.requestMap.set(t,{resolve:n,reject:i}),addTimer((function(){var e=r.requestMap.get(t);null!=e&&e.reject&&(e.reject(new DingRTCError(ErrorCode.APICallTimeOut,"".concat(t," timeout"))),r.requestMap.delete(t))}),8e3)})):Promise.resolve(e())}},{key:"send",value:function(e,t){var r,n=this,i=e[z.rpcTypeKeyMap[e.type]],o=i.sessionType,a=i.sessionKey,s=i.requestId;s?r="".concat(Ie.extractEndpointId(t.from),"#").concat(s):a&&(r="".concat(o,"#").concat(a,"#").concat(e.type+1));var c={msgType:q.Type.kData,data:Ne(Ne({},t),{},{data:le.encode(e).finish()})},u={Type:x.MessageType.ChannelDataType,Version:1,channelData:{chanId:2,data:de.encode(c).finish()}};return this.commitRPC((function(){return n.socket.instance.send(se.encode(u).finish())}),r)}},{key:"onMessage",value:function(e){var t=de.decode(e),r=t.data,n=r.to,i=r.from,o=r.data;if(t.msgType===q.Type.kData){var a;try{a=le.decode(o)}catch(e){return void this.log.warn("handleMessage, dsmsg parse failed")}var s=Ie.getIdType(n)===he.ChannelId,c=Ie.extractEndpointId(s?i:n),u=a.type,l=z.msgTypeKeyMap[u],d=a[l];if(d)if(z.confirmTypes.includes(u)){this.log.info("".concat(l,": ").concat(JSON.stringify(d)));var p,f=d.result,h=d.requestId,m=d.sessionKey,g=d.sessionType,y=d.serverNodeId,v=d.pid;p=h?"".concat(c,"#").concat(h):y?"".concat(v,"#").concat(u):"".concat(g,"#").concat(m,"#").concat(u);var _=this.requestMap.get(p);if(!_)return;0===f?(this.log.info("".concat(l," rpcId:").concat(p," result===> ").concat(JSON.stringify(d))),_.resolve(d)):(this.log.warn("".concat(l," rpcId:").concat(p," error===> ").concat(JSON.stringify(d))),_.reject(d)),this.requestMap.delete(p)}else u===V.MessageType.TYPE_SESSION_CMD_DATA_NOTIFICATION?this.emit("sessionCmdData",c,s,d):u===V.MessageType.TYPE_SESSION_DATA?this.emit("sessionData",i,c,s,d):u===V.MessageType.TYPE_DETACH_USER_CONFIRM?this.emit("detachUserConfirm",d):u===V.MessageType.TYPE_NODE_MAP_UPDATE?this.emit("nodeMapUpdated",c,d):u===V.MessageType.TYPE_NODE_MAP_SNAPSHOT?this.emit("nodeMapSnapshot",c,d):u===V.MessageType.TYPE_SESSION_CREATED?this.emit("sessionCreated",d):u===V.MessageType.TYPE_SESSION_CLOSED&&this.emit("sessionClosed",d);else this.log.warn("msgType: ".concat(l," has no payload"))}}}])}();function Pe(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function Me(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(Me=function(){return!!e})()}var we=getReporter().log,Re=function(){function e(t){var r,n,i;return C(this,e),n=this,i=P(i=e),r=k(n,Me()?Reflect.construct(i,[],P(n).constructor):i.apply(n,undefined)),Object.defineProperty(r,"instance",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"url",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"heartBeat",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"requestMap",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"ticket",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"token",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"refreshTimer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"sequenceId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"rejoin",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"basicTransport",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"switchTransport",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"destroyed",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"retryCount",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"socketReconnectionTimeoutTimer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"signalReconnectionTimeoutTimer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"connectionTimeoutTimer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"state",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),r.state="disconnected",r.requestMap=new Map,r.heartBeat=new ue,r.refreshTimer=null,r.sequenceId=1,r.retryCount=0,r.switchTransport=new ke(r,t.log),r.basicTransport=new Oe(r,t),r}return w(e,EventEmitter),_(e,[{key:"onHeartBeat",value:function(){var e=this;this.heartBeat.on("retry",(function(){e.destroyed||e.reconnect("keepalive")})),this.heartBeat.on("ping",(function(t){e.send(x.MessageType.KeepaliveType,t)}))}},{key:"signalReconnectionTimeout",value:function(){var e=this;this.signalReconnectionTimeoutTimer&&(removeTimer(this.signalReconnectionTimeoutTimer),this.signalReconnectionTimeoutTimer=null),this.signalReconnectionTimeoutTimer=addTimer((function(){e.reconnect("reconnect Timeout")}),15e3)}},{key:"reconnect",value:function(e){this.close(),we.debug("retry connect start, for ".concat(e)),this.clearConnectionTimer(!0),"connected"!==this.state&&"connecting"!==this.state||this.updateState("reconnecting"),this.init(this.url,this.token)}},{key:"init",value:function(e,t){var r=this,n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];this.url=e,this.token=t,this.rejoin=n,"reconnecting"!==this.state&&(this.updateState("connecting"),this.connectionTimeoutTimer=addTimer((function(){r.updateState("disconnected","network_error"),r.close(!0)}),32e3)),this.instance=new WebSocket(e),this.instance.binaryType="arraybuffer",this.instance.onopen=function(){r.onOpen()},this.instance.onmessage=function(e){r.onMessage(e)},this.instance.onerror=function(e){r.onError(e)},this.instance.onclose=function(e){r.onClose(e)}}},{key:"clear",value:function(){this.heartBeat.stop(),this.clearConnectionTimer(),this.requestMap.clear(),this.heartBeat.removeAllListeners()}},{key:"close",value:function(){this.destroyed=arguments.length>0&&void 0!==arguments[0]&&arguments[0],this.clear(),this.instance&&(this.instance.onerror=null,this.instance.onmessage=null,this.instance.onclose=null,this.instance.onopen=null,this.instance.close(),this.instance=null)}},{key:"getTransportData",value:function(e,t){var r=function(e){for(var t=1;arguments.length>t;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Pe(Object(r),!0).forEach((function(t){I(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Pe(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}({Type:e,Version:1,SequenceId:this.sequenceId++},t);return se.encode(r).finish()}},{key:"send",value:function(e,t,r,n){var i,o,a=this;if(1!==(null===(i=this.instance)||void 0===i?void 0:i.readyState))return Promise.reject("socket state error: ".concat((null===(o=this.instance)||void 0===o?void 0:o.readyState)||0));var s=this.getTransportData(e,t);if(x.MessageType.KeepaliveType!==e&&this.signalReconnectionTimeout(),![x.MessageType.KeepaliveType,x.MessageType.ChannelDataType].includes(e))return new Promise((function(t,i){a.instance.send(s);var o=null!=r?r:e,c=n||e;a.requestMap.set(o,{resolve:t,reject:i}),addTimer((function(){var e=a.requestMap.get(o);null!=e&&e.reject&&(e.reject(new DingRTCError(ErrorCode.APICallTimeOut,"".concat(c," timeout"))),a.requestMap.delete(o))}),1e4)}));this.instance.send(s)}},{key:"clearConnectionTimer",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.signalReconnectionTimeoutTimer&&(removeTimer(this.signalReconnectionTimeoutTimer),this.signalReconnectionTimeoutTimer=null),this.socketReconnectionTimeoutTimer&&e&&(removeTimer(this.socketReconnectionTimeoutTimer),this.socketReconnectionTimeoutTimer=null),null!=this.connectionTimeoutTimer&&(removeTimer(this.connectionTimeoutTimer),this.connectionTimeoutTimer=null)}},{key:"channelBind",value:function(){var e={chanId:1,type:x.ChannelType.PortalChannel,address:location.hostname};return this.send(x.MessageType.ChannelBindType,{channelBind:e})}},{key:"auth",value:function(e){var t=this;return this.send(x.MessageType.AuthType,{auth:{token:e,duplicate:this.rejoin,options:{supportReliable:!1,supportPingConfig:!0}}}).then((function(e){if(t.refresh(e.ticket),e.pingConfig)return e.pingConfig}))}},{key:"refresh",value:function(e){var t=this;this.ticket=e;var r=parseBase64(e).notAfter,n=Date.now();if(r>n-1e4){var i=r-n-6e4;0>i&&(i=r-n-1e4),removeTimer(this.refreshTimer),this.refreshTimer=addTimer((function(){t.refreshTicket().then((function(e){t.refresh(e.ticket)}))}),i)}else we.warn("Reconnection ticket expires too soon.")}},{key:"refreshTicket",value:function(){return this.send(x.MessageType.RefreshTicketType,{refreshTicket:{}})}},{key:"reauth",value:function(e){var t=this;return this.send(x.MessageType.ReAuthType,{reauth:{ticket:e,options:{supportReliable:!1,supportPingConfig:!0}}}).then((function(e){t.emit("reauth"),e.pingConfig&&t.heartBeat.start(e.pingConfig)})).catch((function(e){we.error("reauth error"+JSON.stringify(e)),(null==e?void 0:e.errorMsg)!==x.AuthErrorMsg.Unavailable?t.onRejoin():(t.updateState("disconnected","timeout"),t.close(!0))}))}},{key:"onRejoin",value:function(){this.rejoin||(this.emit("rejoin"),we.warn("rejoin started")),this.close(!0)}},{key:"onMessage",value:function(e){this.signalReconnectionTimeout();var t=se.decode(new Uint8Array(e.data));if(t.Type===x.MessageType.ChannelDataType)1===t.channelData.chanId?this.basicTransport.onMessage(t):2===t.channelData.chanId&&this.switchTransport.onMessage(t.channelData.data);else if(t.Type===x.MessageType.KeepaliveResponseType)this.heartBeat.pong(t.keepaliveResponse);else if(t.Type===x.MessageType.ServerRequestType){var r=t.notification.event;we.warn("server request ".concat(1===r?"reauth":"rejoin")),r===x.ServerEvent.ReauthRequest?this.reauth(this.ticket):r===x.ServerEvent.RejoinRequest&&this.onRejoin()}else{var n,i,o=new Map([[x.MessageType.AuthResponseType,t.authResponse],[x.MessageType.ChannelBindResponseType,t.channelBindResponse],[x.MessageType.ReAuthResponseType,t.reauthResponse],[x.MessageType.RefreshTicketResponseType,t.refreshTicketResponse]]).get(t.Type);o.code===x.ErrorCode.Ok?null===(n=this.requestMap.get(t.Type-1))||void 0===n||n.resolve(o):null===(i=this.requestMap.get(t.Type-1))||void 0===i||i.reject(o),this.requestMap.delete(t.Type-1)}}},{key:"onError",value:function(e){we.error("onError: ".concat(JSON.stringify(e)))}},{key:"onOpen",value:function(){var e=this;this.clearConnectionTimer(!0),this.retryCount=0,"reconnecting"===this.state?this.reauth(this.ticket).then((function(){e.rejoin=!1,e.updateState("connected"),e.onHeartBeat()})):Promise.all([this.auth(this.token),this.channelBind()]).then((function(t){var r=G(t,1)[0];e.rejoin=!1,e.updateState("connected"),e.onHeartBeat(),e.heartBeat.start(r)})).catch((function(t){we.debug("auth or channelBind failed, ".concat(JSON.stringify(t))),e.updateState("disconnected","server_error"),e.close(!0)}))}},{key:"updateState",value:function(e,t){e!==this.state&&(this.emit("connection-state-change",e,this.state,t),this.state=e)}},{key:"onClose",value:function(e){var t=this;we.warn("socket closed:"+JSON.stringify(e)),this.rejoin?this.updateState("disconnected","server_error"):this.destroyed||("reconnecting"===this.state?(this.retryCount++,this.retryCount>6?(this.updateState("disconnected","network_error"),this.retryCount=0):this.socketReconnectionTimeoutTimer=addTimer((function(){t.reconnect("retry count"+t.retryCount)}),W)):"connecting"==this.state?this.socketReconnectionTimeoutTimer=addTimer((function(){t.reconnect("localNetwork")}),W):"disconnected"!==this.state&&(this.socketReconnectionTimeoutTimer=addTimer((function(){t.reconnect("server closed, retry count"+t.retryCount)}),W))),this.clear()}}])}();function De(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function Ae(e){for(var t=1;arguments.length>t;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?De(Object(r),!0).forEach((function(t){I(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):De(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function je(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(je=function(){return!!e})()}var Le=function(){function e(t,r){var n,i,o;return C(this,e),i=this,o=P(o=e),n=k(i,je()?Reflect.construct(o,[],P(i).constructor):o.apply(i,undefined)),Object.defineProperty(n,"reporter",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(n,"transport",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),n.transport=t.basicTransport,n.reporter=r,n.forwardNotification(),n}return w(e,EventEmitter),_(e,[{key:"forwardNotification",value:function(){var e=this;["participant","batch-notify","conference","drop","notify","rejoin","connection-state-change","sync","reauth"].forEach((function(t){e.transport.on(t,(function(){for(var r=arguments.length,n=Array(r),i=0;r>i;i++)n[i]=arguments[i];e.emit.apply(e,[t].concat(n))}))}))}},{key:"relogin",value:function(e){var t=this,r=e.token,n=ie.encode(e).finish();return this.transport.connect(r,!0).then((function(){return t.transport.send("rejoin-login",n,e,!0).then((function(e){return e.rejoinResponse}))}))}},{key:"login",value:function(e){var t=this,r=e.token,n=ae.encode(e).finish();return this.transport.connect(r,!1).then((function(){return t.transport.send("login",n,e,!0).then((function(e){return e.joinResponse}))}))}},{key:"diconnect",value:function(){return this.transport.disconnect()}},{key:"logout",value:function(){var e=this;return this.transport.send("logout",void 0,null,!0).catch((function(t){e.reporter.log.debug("logout api called failed ".concat(JSON.stringify(t)))})),this.diconnect()}},{key:"getUsersVer",value:function(e){var t=re.encode(e).finish();return this.transport.send("query-participants-ver",t,e,!0).then((function(e){return e.queryParticipantsVerResponse}))}},{key:"getUsers",value:function(e){var t=oe.encode(e).finish();return this.transport.send("query-participants",t,e,!0).then((function(e){return e.queryParticipantsResponse}))}},{key:"rpc",value:function(e,t,r){return this.transport.send(e,t,r)}}])}();function Ue(e){return function(e){if(Array.isArray(e))return K(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||H(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Ye(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function Ve(e){for(var t=1;arguments.length>t;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Ye(Object(r),!0).forEach((function(t){I(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Ye(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function qe(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return Fe(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Fe(e,t):void 0}}(e))||t){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return e.length>n?{done:!1,value:e[n++]}:{done:!0}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function Fe(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);t>r;r++)n[r]=e[r];return n}function xe(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(xe=function(){return!!e})()}var Je,Be,Ke,He=function(){function e(t){var r,n,i;return C(this,e),n=this,i=P(i=e),r=k(n,xe()?Reflect.construct(i,[],P(n).constructor):i.apply(n,undefined)),Object.defineProperty(r,"channel",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(r,"participants",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"currentPid",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"reporter",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"totalVer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),r.participants=new Map,r.channel=t,r.reporter=t.reporter,r.handleEvent=r.handleEvent.bind(r),r.handleSyncEvent=r.handleSyncEvent.bind(r),r.sync=r.sync.bind(r),r}return w(e,EventEmitter),_(e,[{key:"currentUids",get:function(){return Ue(this.participants.values()).map((function(e){return e.user}))}},{key:"init",value:function(e,t,r){var n,i=qe(e);try{for(i.s();!(n=i.n()).done;){var o=n.value;this.participants.set(o.id,o)}}catch(e){i.e(e)}finally{i.f()}this.totalVer=t,this.currentPid=r,this.channel.signaling.on("participant",this.handleEvent),this.channel.signaling.on("sync",this.handleSyncEvent),this.channel.signaling.on("reauth",this.sync)}},{key:"clear",value:function(){this.participants.clear(),this.currentPid="",this.totalVer=0,this.channel.signaling.off("participant",this.handleEvent),this.channel.signaling.off("sync",this.handleSyncEvent),this.channel.signaling.off("reauth",this.sync)}},{key:"handleEvent",value:function(e,t){this.reporter.log.debug("channelUserEvent ".concat(JSON.stringify(e)));var r=e.action,n=e.info,i=e.participantId,o=e.totalVer,a=e.propertiesData,s=this.totalVer,c=this.participants.get(i||(null==a?void 0:a.id));if(o==s+1||-999==o||t)if("join"===r&&n){var u=this.currentUids.includes(n.user);this.participants.set(n.id,n),u?(this.emit("user","update",n),this.reporter.log.debug("user ".concat(n.user," joined again"))):this.emit("user","join",n)}else"leave"===r?c?(this.participants.delete(i),this.currentUids.includes(c.user)?this.reporter.log.debug("user ".concat(c.user," has another pid in channel")):this.emit("user","leave",c)):this.reporter.log.debug("Received leave message for unknown participant."):"setProperties"===r&&(c.propertiesJsonStr=JSON.stringify(Ve(Ve({},JSON.parse(c.propertiesJsonStr||"{}")),JSON.parse(a.propertiesJsonStr||"{}"))),this.emit("user","update",c));t||this.totalVer>=o&&-999!==o||(o===s+1&&(this.totalVer=o),o>s+1&&!t&&this.sync())}},{key:"handleSyncEvent",value:function(e){e.participantsVer>this.totalVer&&this.sync()}},{key:"sync",value:(t=T(B.mark((function e(){var t,r,n,i,o,a,s,c,u,l,d,p,f,h,m=this;return B.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=[],e.next=3,this.channel.signaling.getUsersVer({});case 3:n=(r=e.sent).participants,i=r.totalVer,o=[],a=Ue(this.participants.keys()),s=n.map((function(e){return e.id})),c=qe(n);try{for(c.s();!(u=c.n()).done;)f=(d=u.value).ver,this.participants.has(p=d.id)?(null===(l=this.participants.get(p))||void 0===l?void 0:l.ver)!==f&&o.push(p):t.push(p)}catch(e){c.e(e)}finally{c.f()}if(this.reporter.trace.syncEvent("user",a,s),h=a.filter((function(e){return!s.includes(e)})),o=Ue(new Set(o.concat(h,t))),this.totalVer=i,0!==o.length){e.next=17;break}return e.abrupt("return");case 17:this.channel.signaling.getUsers({pids:o}).then((function(e){var r,n=e.totalVer,i=e.participants,a=new Map,s=qe(m.participants.values());try{for(s.s();!(r=s.n()).done;){var c=r.value;a.set(c.id,c)}}catch(e){s.e(e)}finally{s.f()}var u,l=qe(i);try{for(l.s();!(u=l.n()).done;){var d=u.value;m.participants.has(d.id)?m.participants.set(d.id,d.data):a.set(d.id,d.data)}}catch(e){l.e(e)}finally{l.f()}for(var p=o.map((function(e){return a.get(e)})).filter((function(e){return!!e})).sort((function(e,t){return e.version-t.version})),f=0;p.length>f;f++){var g=p[f];t.includes(g.id)?m.handleEvent({action:"join",participantId:g.id,info:g,totalVer:n},!0):h.includes(g.id)&&m.handleEvent({action:"leave",participantId:g.id,info:g,totalVer:n},!0)}m.totalVer=n}));case 18:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]);var t}();!function(e){e[e.UNKNOWN=-1]="UNKNOWN",e[e.WHITEBOARD=0]="WHITEBOARD",e[e.RTCSERVICE=1]="RTCSERVICE",e[e.CUSTOMIZE=101]="CUSTOMIZE"}(Je||(Je={})),function(e){e[e.NODE_JOIN=0]="NODE_JOIN",e[e.NODE_LEAVE=1]="NODE_LEAVE"}(Be||(Be={})),function(e){e[e.RTMS=0]="RTMS",e[e.SDK=1]="SDK",e[e.APP=2]="APP"}(Ke||(Ke={}));var Ge=_((function e(t){C(this,e),Object.defineProperty(this,"log",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"pending",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),Object.defineProperty(this,"nodesInfo",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),Object.defineProperty(this,"pid",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"pidToNodeId",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),Object.defineProperty(this,"getNodeInfoKey",{enumerable:!0,configurable:!0,writable:!0,value:function(e){return"number"==typeof e?"number"+e:"low".concat(e.low,"high").concat(e.high,"unsigned").concat(e.unsigned)}}),this.log=t}),[{key:"handleNodeMapUpdate",value:function(e){var t=this;return e.items.filter((function(e){return e.action===Be.NODE_JOIN&&t.addNode(e)||e.action===Be.NODE_LEAVE&&t.removeNode(e)}))}},{key:"handleNodeMapSnapshot",value:function(e){var t=this,r=e.end,n=e.items;if(e.start&&this.pending.clear(),n.forEach((function(e){return t.pending.set(e.pid,e.nodeId)})),r){this.log.info("Snapshot,size:".concat(this.pidToNodeId.size," to:").concat(this.pending.size));var i=[];return this.pidToNodeId.forEach((function(e,r){i.push({pid:r,nodeId:t.pending.get(r)||e,action:t.pending.has(r)?Be.NODE_JOIN:Be.NODE_LEAVE}),t.pending.delete(r)})),this.pending.forEach((function(e,t){i.push({pid:t,nodeId:e,action:Be.NODE_JOIN})})),this.pending.clear(),this.handleNodeMapUpdate({items:i})}}},{key:"addNode",value:function(e){var t=e.pid,r=e.nodeId,n=this.getNodeInfoKey(r);return this.nodesInfo.has(n)?(this.log.debug("updateNode,pid:".concat(t,", nodeId:").concat(r)),this.nodesInfo.set(n,e),this.pidToNodeId.set(n,r),!1):(this.log.debug("addNode,pid:".concat(t,", nodeId:").concat(r)),this.nodesInfo.set(n,e),this.pidToNodeId.set(t,r),t!==this.pid)}},{key:"removeNode",value:function(e){var t=e.pid,r=e.nodeId,n=this.getNodeInfoKey(r);return!!this.nodesInfo.has(n)&&(this.log.debug("removeNode, pid:".concat(t,", nodeId:").concat(r)),this.nodesInfo.delete(n),this.pidToNodeId.delete(t),t!==this.pid)}},{key:"getPid",value:function(e){var t,r=this.getNodeInfoKey(e);return null===(t=this.nodesInfo.get(r))||void 0===t?void 0:t.pid}}]);function We(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(We=function(){return!!e})()}var ze=function(){function e(t,r,n){var i,o,a;return C(this,e),o=this,a=P(a=e),i=k(o,We()?Reflect.construct(a,[],P(o).constructor):a.apply(o,undefined)),Object.defineProperty(i,"type",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(i,"switcher",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(i,"log",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(i,"syncing",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(i,"pendingMessages",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(i,"joinPromise",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(i,"id",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(i,"state",{enumerable:!0,configurable:!0,writable:!0,value:be.UNINITED}),Object.defineProperty(i,"endpointId",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(i,"nodeMap",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(i,"broadcastChannel",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(i,"userData",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),i.type=t,i.id=r,i.switcher=n,i.log=n.log,i.nodeMap=new Ge(i.log),i.join=i.join.bind(i),i.leave=i.leave.bind(i),i.close=i.close.bind(i),i}return w(e,EventEmitter),_(e,[{key:"available",get:function(){var e;return"connected"===(null===(e=this.switcher)||void 0===e||null===(e=e.channel)||void 0===e?void 0:e.connectionState)&&this.state===be.READY}},{key:"recover",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.log.info("".concat(this.type,"#").concat(this.id," recover rejoin:").concat(e,",state:").concat(this.state)),e?this.state==be.READY&&(this.syncing=!0,this.join()):this.syncing=!0}},{key:"retransmit",value:function(){for(this.log.info("".concat(this.type,"#").concat(this.id," retransmit:").concat(this.pendingMessages.length));this.pendingMessages.length;){var e=this.pendingMessages.shift(),t=e.resolve,r=e.reject;this.sendInner(e.message).then(t).catch(r)}}},{key:"join",value:function(e){var t,r=this;return this.log.info("".concat(this.type,"#").concat(this.id," join:").concat(this.state)),null!==(t=this.switcher)&&void 0!==t&&null!==(t=t.channel)&&void 0!==t&&t.enableDS?new Promise((function(t,n){r.switcher.enquenTask.add((function(){if(r.state!==be.READY||r.syncing)return r.joinPromise={resolve:t,reject:n},r.switcher.send({type:V.MessageType.TYPE_JOIN_SESSION,joinSession:{sessionType:r.type,sessionKey:r.id,customSessionData:e||r.userData,nodeId:r.switcher.nodeId,pid:r.switcher.pid}}).then((function(e){var t,n=e.customSessionData,i=e.channels;r.endpointId=e.endpointId,r.broadcastChannel=null===(t=i.find((function(e){return e.type===Ee.DEFAULT})))||void 0===t?void 0:t.id,r.userData=n,r.state=be.READY})).catch((function(e){var t;null===(t=r.joinPromise)||void 0===t||t.reject(e),r.joinPromise=null}));n(new DingRTCError(ErrorCode.InvaildState,"session is already ready"))}))})):Promise.reject(new DingRTCError(ErrorCode.InvaildState,"dataSwitcher not enabled"))}},{key:"leave",value:function(){var e,t=this;return null!==(e=this.switcher)&&void 0!==e&&null!==(e=e.channel)&&void 0!==e&&e.enableDS?(this.log.info("".concat(this.type,"#").concat(this.id," leave:").concat(this.state)),new Promise((function(e,r){t.state!==be.READY&&r(new DingRTCError(ErrorCode.InvaildState,"session is not ready")),t.switcher.enquenTask.add((function(){return t.switcher.send({type:V.MessageType.TYPE_LEAVE_SESSION,leaveSession:{sessionType:t.type,sessionKey:t.id,nodeId:t.switcher.nodeId}}).then((function(){t.state=be.LEFT,e()})).catch(r)}))}))):Promise.reject(new DingRTCError(ErrorCode.InvaildState,"dataSwitcher not enabled"))}},{key:"close",value:function(){var e,t=this;return null!==(e=this.switcher)&&void 0!==e&&null!==(e=e.channel)&&void 0!==e&&e.enableDS?(this.log.info("".concat(this.type,"#").concat(this.id," close:").concat(this.state)),new Promise((function(e,r){t.switcher.enquenTask.add((function(){return t.state===be.CLOSED&&r(new DingRTCError(ErrorCode.InvaildState,"session is already closed")),t.switcher.send({type:V.MessageType.TYPE_CLOSE_SESSION,closeSession:{sessionType:t.type,sessionKey:t.id,nodeId:t.switcher.nodeId}}).then((function(){t.state=be.CLOSED,e()})).catch(r)}))}))):Promise.reject(new DingRTCError(ErrorCode.InvaildState,"dataSwitcher not enabled"))}},{key:"sendMessage",value:function(e){var t=this;return new Promise((function(r,n){if(t.state===be.READY)return t.syncing||!t.available?(t.pendingMessages.length>1e3&&t.pendingMessages.shift().reject(new DingRTCError(ErrorCode.InvaildState,"pending size is full")),void t.pendingMessages.push({message:e,resolve:r,reject:n})):t.sendInner(e).then(r).catch(n);n(new DingRTCError(ErrorCode.InvaildState,"session is not ready"))}))}},{key:"sendInner",value:function(e){var t,r,n=e.targetPid,i=void 0===n?"":n,o=e.echo,a=e.uniform,s=void 0!==a&&a,c=e.message,u=e.cmd,l=e.cmdType,d=e.requestId,p=u&&void 0!==l,f=i?this.nodeMap.pidToNodeId.get(i):void 0,h="string"==typeof c?(new TextEncoder).encode(c):c;return p?(t=Ie.composeId(this.switcher.serverNodeId,this.endpointId),r={type:V.MessageType.TYPE_SESSION_CMD_DATA,sessionCmdData:{cmd:u,echo:o,cmdType:l,toNodeId:f,requestId:d,data:h,broadcast:!i,fromPid:this.switcher.pid}}):(t=i?Ie.composeId(f,this.endpointId):this.broadcastChannel,r={type:V.MessageType.TYPE_SESSION_DATA,sessionData:{data:h}}),this.switcher.send(r,{to:t,echo:o,uniform:s,broadcast:!i,endpointId:this.endpointId,priority:p?me.Normal:me.Low})}},{key:"handleNodeMapSnapshot",value:function(e){var t,r=this.nodeMap.handleNodeMapSnapshot(e);e.end&&(this.log.info("".concat(this.type,"#").concat(this.id," nodeSnapshot:").concat(JSON.stringify(r))),this.retransmit(),null===(t=this.joinPromise)||void 0===t||t.resolve(),this.joinPromise=null,this.syncing&&(this.syncing=!1,r.length&&this.emit("user-update",r),this.log.info("".concat(this.type,"#").concat(this.id," rejoin success"))))}},{key:"handleNodeMapUpdate",value:function(e){var t=this.nodeMap.handleNodeMapUpdate(e);this.log.info("".concat(this.type,"#").concat(this.id," nodeUpdated:").concat(JSON.stringify(t))),t.length&&this.emit("user-update",t)}},{key:"handleSessionCreated",value:function(e,t,r){this.endpointId=e,this.broadcastChannel=t,this.userData=r}},{key:"handleSessionClosed",value:function(){this.state=be.CLOSED,this.emit("leave",Se.SESSION_LEAVE_FOR_SESSION_CLOSED)}},{key:"handleSessionCmdData",value:function(e,t){var r=t.fromPid,n=t.cmd,i=t.cmdType,o=t.requestId,a=t.data,s=this.type!==Je.CUSTOMIZE?(new TextDecoder).decode(a):a;this.emit("message",{cmd:n,cmdType:i,requestId:o,broadcast:e,messageType:this.type!==Je.CUSTOMIZE?"STRING":"BINARY",pid:r,message:s})}},{key:"handleSessionData",value:function(e,t,r){var n=r.data,i=this.nodeMap.getPid(e),o=this.type!==Je.CUSTOMIZE?(new TextDecoder).decode(n):n;this.emit("message",{pid:i,message:o,broadcast:t,messageType:this.type!==Je.CUSTOMIZE?"STRING":"BINARY"})}}])}();function Qe(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(Qe=function(){return!!e})()}var Ze=function(){function e(t){var r,n,i;return C(this,e),n=this,i=P(i=e),r=k(n,Qe()?Reflect.construct(i,[],P(n).constructor):i.apply(n,undefined)),Object.defineProperty(r,"endpointId",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(r,"nodeMap",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"broadcastChannel",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(r,"transport",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"sessionEndPointMap",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),Object.defineProperty(r,"log",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"pid",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"nodeId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"channel",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"state",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"serverNodeId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"enquenTask",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"sessionMap",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),Object.defineProperty(r,"handleSessionData",{enumerable:!0,configurable:!0,writable:!0,value:function(e,t,n,i){var o;null===(o=r.fetchSession(t,"SessionData"))||void 0===o||o.handleSessionData(Ie.extractNodeId(e),n,i)}}),r.state=Te.UNINITED,r.enquenTask=taskQueue$1(),r.channel=t,r.log=t.reporter.log,r.nodeMap=new Ge(r.log),r.handleDetachUserConfirm=r.handleDetachUserConfirm.bind(r),r.handleNodeMapSnapshot=r.handleNodeMapSnapshot.bind(r),r.handleNodeMapUpdate=r.handleNodeMapUpdate.bind(r),r.handleSessionClosed=r.handleSessionClosed.bind(r),r.handleSessionCreated=r.handleSessionCreated.bind(r),r.handleSessionData=r.handleSessionData.bind(r),r.handleSessionCmdData=r.handleSessionCmdData.bind(r),r}return w(e,EventEmitter),_(e,[{key:"init",value:function(e){var t=this,r=this.state,n=this.channel;if(this.log.debug("pid:".concat(e," switcher channelBind start:").concat(r," enable:").concat(n.enableDS)),r!==Te.BINDING&&this.channel.enableDS)return this.transport=this.channel.socket.switchTransport,this.pid=e,this.state=Te.BINDING,this.transport.channelBind(e).then((function(r){t.nodeMap.pid=e,t.addEventListeners(),t.handleAttachUserConfirm(r),t.enquenTask.start()})).catch(function(){var r=T(B.mark((function r(n){return B.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return t.log.warn("pid:".concat(e," switcher channelBind failed:").concat(tryJsonStringify(n))),r.next=3,awaitTime$1(1);case 3:"connected"===t.channel.connectionState&&t.state!==Te.CLOSED&&(t.state=Te.UNINITED,t.init(e));case 4:case"end":return r.stop()}}),r)})));return function(e){return r.apply(this,arguments)}}())}},{key:"addEventListeners",value:function(){this.transport.on("detachUserConfirm",this.handleDetachUserConfirm),this.transport.on("nodeMapSnapshot",this.handleNodeMapSnapshot),this.transport.on("nodeMapUpdated",this.handleNodeMapUpdate),this.transport.on("sessionClosed",this.handleSessionClosed),this.transport.on("sessionCreated",this.handleSessionCreated),this.transport.on("sessionData",this.handleSessionData),this.transport.on("sessionCmdData",this.handleSessionCmdData)}},{key:"removeEventListeners",value:function(){this.transport&&(this.transport.off("detachUserConfirm",this.handleDetachUserConfirm),this.transport.off("nodeMapSnapshot",this.handleNodeMapSnapshot),this.transport.off("nodeMapUpdated",this.handleNodeMapUpdate),this.transport.off("sessionClosed",this.handleSessionClosed),this.transport.off("sessionCreated",this.handleSessionCreated),this.transport.off("sessionData",this.handleSessionData),this.transport.off("sessionCmdData",this.handleSessionCmdData))}},{key:"clear",value:function(){this.sessionMap.clear(),this.sessionEndPointMap.clear(),this.state=Te.UNINITED,this.removeEventListeners()}},{key:"getSession",value:function(e,t){var r;if(t.length>128)throw new DingRTCError(ErrorCode.InvaildArgument,"invalid id");var n=null===(r=this.sessionMap.get(e))||void 0===r?void 0:r.get(t);return n||(this.log.info("get new localSession:".concat(e,"#").concat(t)),n=new ze(e,t,this),this.sessionMap.get(e)?this.sessionMap.get(e).set(t,n):this.sessionMap.set(e,new Map([[t,n]]))),n}},{key:"fetchSession",value:function(e,t){var r=this.sessionEndPointMap.get(e);if(r)return r;this.log.warn("".concat(t," fetchSession:").concat(e," not existed"))}},{key:"send",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this.state===Te.CLOSED)return Promise.reject(new DingRTCError(ErrorCode.InvaildState,"switcher is closed"));var r=t.echo,n=void 0!==r&&r,i=t.priority,o=void 0===i?me.High:i,a=t.broadcast,s=void 0!==a&&a,c=t.uniform,u=void 0===c||c,l=t.to,d=o===me.High,p=Ie.composeId(this.nodeId,d?this.endpointId:t.endpointId);return d&&(l=s?this.broadcastChannel:Ie.composeId(this.serverNodeId,this.endpointId)),this.transport.send(e,{to:l,from:p,compressed:!1,priority:o,uniform:d||u,echo:n})}},{key:"handleNodeMapUpdate",value:function(e,t){var r;e===this.endpointId?this.nodeMap.handleNodeMapUpdate(t):null===(r=this.fetchSession(e,"NodeMapUpdate"))||void 0===r||r.handleNodeMapUpdate(t)}},{key:"handleAttachUserConfirm",value:function(e){var t,r=this,n=e.nodeId,i=e.serverNodeId,o=e.endpointId,a=e.sessionCreateds,s=e.reason;this.broadcastChannel=null===(t=e.channels.find((function(e){return e.type===Ee.DEFAULT})))||void 0===t?void 0:t.id,this.nodeId=n,this.endpointId=o,this.serverNodeId=i;var c=[ge.NORMAL_ATTACH,ge.FORCE_REATTACH].includes(s);this.sessionMap.forEach((function(e,t){e.forEach((function(e,n){a.some((function(e){return e.sessionType===t&&e.sessionKey===n}))?e.recover(c):r.handleSessionClosed({sessionKey:n,sessionType:t})}))})),a.forEach((function(e){r.handleSessionCreated(e)})),this.state=Te.READY}},{key:"handleNodeMapSnapshot",value:function(e,t){var r;this.endpointId==e?this.nodeMap.handleNodeMapSnapshot(t):null===(r=this.fetchSession(e,"NodeMapSnapshot"))||void 0===r||r.handleNodeMapSnapshot(t)}},{key:"handleSessionCreated",value:function(e){var t,r,n=e.sessionKey,i=e.sessionType,o=e.endpointId,a=e.customSessionData,s=null===(t=e.channels.find((function(e){return e.type===Ee.DEFAULT})))||void 0===t?void 0:t.id,c=null===(r=this.sessionMap.get(i))||void 0===r?void 0:r.get(n),u=!c,l=u||c&&!c.available;this.log.info("onSessionCreated: ".concat(i,"#").concat(n," is ").concat(u?"new":"existed")),u&&(this.log.info("Created ".concat(i,"#").concat(n)),c=new ze(i,n,this),this.sessionMap.get(i)?this.sessionMap.get(i).set(n,c):this.sessionMap.set(i,new Map([[n,c]]))),this.sessionEndPointMap.set(o,c),c.handleSessionCreated(o,s,a),l&&this.emit("sessionCreate",{type:i,id:n})}},{key:"handleSessionClosed",value:function(e){var t,r=e.sessionKey,n=e.sessionType,i=null===(t=this.sessionMap.get(n))||void 0===t?void 0:t.get(r);this.log.info("handleSessionClosed: ".concat(n,"#").concat(r," is ").concat(i?"closed":"not existed")),i&&i.state!==be.UNINITED&&(i.handleSessionClosed(),this.sessionMap.get(n).delete(r),this.sessionEndPointMap.delete(i.endpointId),this.emit("sessionClose",{type:n,id:r}))}},{key:"handleDetachUserConfirm",value:function(e){var t=e.pid,r=e.result;this.log.warn("DetachUser pid:".concat(this.pid," result:").concat(r," state:").concat(this.state)),t==this.pid&&0===r&&this.state!==Te.CLOSED&&(this.state=Te.CLOSED)}},{key:"handleSessionCmdData",value:function(e,t,r){var n;null===(n=this.fetchSession(e,"CmdData"))||void 0===n||n.handleSessionCmdData(t,r)}}])}();function $e(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function Xe(e){for(var t=1;arguments.length>t;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?$e(Object(r),!0).forEach((function(t){I(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):$e(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function et(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(et=function(){return!!e})()}var tt=function(){function e(t){var r,n,i;C(this,e),n=this,i=P(i=e),r=k(n,et()?Reflect.construct(i,[],P(n).constructor):i.apply(n,undefined)),Object.defineProperty(r,"dataSwitcher",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"signaling",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"reporter",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"joinInfo",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"sdkVersion",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"scene",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"socket",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"id",{enumerable:!0,configurable:!0,writable:!0,value:createUuid(6)}),Object.defineProperty(r,"userManager",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"enableDS",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(r,"gslb",{enumerable:!0,configurable:!0,writable:!0,value:"https://gslb.dingrtc.com"}),Object.defineProperty(r,"connectionState",{enumerable:!0,configurable:!0,writable:!0,value:"disconnected"}),Object.defineProperty(r,"securityToken",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"checkJoinParam",{enumerable:!0,configurable:!0,writable:!0,value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",r=!t;return r||("userName"===e?r=(new TextEncoder).encode(t).length>64:"token"!==e&&(r=t.length>64||/[^a-zA-Z0-9_-]/g.test(t))),r?"Join with invalid ".concat(e):""}});var o=t.reporter,a=t.gslb,s=t.sdkVersion,c=t.scene;return a&&(r.gslb=a),r.sdkVersion=s,r.scene=c,r.reporter=o,r.userManager=new He(r),r.dataSwitcher=new Ze(r),r.handleRejoin=r.handleRejoin.bind(r),r.handleConferenceEvent=r.handleConferenceEvent.bind(r),r.handleDropEvent=r.handleDropEvent.bind(r),r.handleConnectionChangeEvent=r.handleConnectionChangeEvent.bind(r),r.handleUserEvent=r.handleUserEvent.bind(r),r.handleSyncEvent=r.handleSyncEvent.bind(r),r.handleNotifyEvent=r.handleNotifyEvent.bind(r),r.handleReauthEvent=r.handleReauthEvent.bind(r),r.handleBatchNotifyEvent=r.handleBatchNotifyEvent.bind(r),r}return w(e,EventEmitter),_(e,[{key:"addEventListeners",value:function(){this.signaling.on("rejoin",this.handleRejoin),this.signaling.on("conference",this.handleConferenceEvent),this.signaling.on("drop",this.handleDropEvent),this.signaling.on("sync",this.handleSyncEvent),this.signaling.on("connection-state-change",this.handleConnectionChangeEvent),this.userManager.on("user",this.handleUserEvent),this.signaling.on("batch-notify",this.handleBatchNotifyEvent),this.signaling.on("notify",this.handleNotifyEvent),this.signaling.on("reauth",this.handleReauthEvent)}},{key:"removeEventListeners",value:function(){this.signaling.off("rejoin",this.handleRejoin),this.signaling.off("conference",this.handleConferenceEvent),this.signaling.off("drop",this.handleDropEvent),this.signaling.off("sync",this.handleSyncEvent),this.signaling.off("connection-state-change",this.handleConnectionChangeEvent),this.userManager.off("user",this.handleUserEvent),this.signaling.off("batch-notify",this.handleBatchNotifyEvent),this.signaling.off("notify",this.handleNotifyEvent),this.signaling.off("reauth",this.handleReauthEvent)}},{key:"handleLeave",value:function(e){this.reporter.trace.wtLeave(e),this.userManager.clear(),this.dataSwitcher.clear(),this.joinInfo=null,this.removeEventListeners();var t=this.connectionState;this.connectionState="disconnected",this.emit("connection-state-change","disconnected",t,e),this.signaling.diconnect(),this.reporter.stop()}},{key:"modifyToken",value:function(e,t){var r=parseBase64(t);return r.properties=Xe(Xe({},r.properties),{},{__nick:e,SdkType:Environment.sdkType,TerminalType:Environment.terminalType}),toBase64(JSON.stringify(r))}},{key:"beforeJoin",value:function(e){var t=this;this.reporter.trace.wtGslb("accessGslbStart");var r=e.channel,n=e.uid,i=e.token,o=e.userName;return this.handleConnectionChangeEvent("connecting",this.connectionState),function(e){var t=e.accessToken,r=e.sdkVersion,n="/v1/users/".concat(e.userId,"/access");delete e.userId,delete e.accessToken,delete e.sdkVersion;var i=Ae(Ae({},e),{},{deviceSpecs:{platform:"Web",sdkv:r,osv:Environment.systemVersion,manu:Environment.manu,model:Environment.model}});return Environment.cpu&&(i.deviceSpecs.cpuUarch=Environment.cpu),post$1("".concat(e.gslb).concat(n),JSON.stringify(i),{Authorization:t})}({timestamp:Date.now(),deviceId:deviceId,userId:n,gslb:this.gslb,sdkVersion:this.sdkVersion,channelId:r,accessToken:i}).then((function(e){var r,n=e.logService,i=e.securityToken,a=e.access,s=a.staticConfig,c=s.statsConfig,u=void 0===c?{uploadIntervalMs:UPLOAD_LOG_INTERVAL,statsIntervalMs:METRIC_STATS_INTERVAL$1}:c,l=s.linkClientConfig,d=a.iceConfig,p=a.rtcToken;t.enableDS=(null==l?void 0:l.enable)&&(null==l?void 0:l.enable_ds),t.reporter.trace.wtGslb("accessGslbSuccess",tryJsonStringify(e));var f=Date.now();return t.reporter.updateCommonInfo({serverDiffTime:(1e3*(null!==(r=null==i?void 0:i.updateTime)&&void 0!==r?r:0)||f)-f}),t.reporter.trace.wtGslb("accessGslbSuccess",tryJsonStringify(e)),n?t.reporter.start({securityToken:i,logService:n,cycleStatsConfig:u}):t.reporter.log.warn("logService is empty"),{rtcToken:t.modifyToken(o,p),iceConfig:d,securityToken:i}})).catch((function(e){var r=e.code,n=e.cause;throw t.reporter.trace.wtGslb("accessGslbFailed",tryJsonStringify(e)),converToRtcErrorFromGslbCode(r,n)}))}},{key:"beforeRejoin",value:function(e,t){var r=this;this.reporter.trace.wtGslb("linkerServerStart");var n=e.channel,i=e.uid,o=e.appId,a=e.userName;return function(e){var t=e.userId;delete e.userId;var r="/v1/users/".concat(t,"/link-server");return post$1("".concat(e.gslb).concat(r),JSON.stringify(e))}({timestamp:Date.now(),deviceId:deviceId,userId:i,channelId:n,appId:o,gslb:this.gslb,securityToken:this.reporter.securityToken,participantId:t}).then((function(e){var t=e.access.rtcToken;return r.reporter.updateSecurityToken(e.securityToken),r.reporter.trace.wtGslb("linkerServerSuccess",tryJsonStringify(e)),r.modifyToken(a,t)})).catch((function(e){var t=e.code,n=e.cause;throw r.reporter.trace.wtGslb("linkerServerFailed",tryJsonStringify(e)),converToRtcErrorFromGslbCode(t,n)}))}},{key:"join",value:(r=T(B.mark((function e(t,r){var n,i,o,a,s,c,u,l,d,p,f,h,m,g,y=this;return B.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i=(n=t||{}).channel,o=n.uid,a=n.userName,c=n.token,u=[this.checkJoinParam("appId",s=n.appId),this.checkJoinParam("token",c),this.checkJoinParam("channel",i),this.checkJoinParam("uid",o),this.checkJoinParam("userName",a)],l=0;case 3:if(l>=u.length){e.next=9;break}if(!u[l]){e.next=6;break}return e.abrupt("return",Promise.reject(new DingRTCError(ErrorCode.JoinChannelFailed,u[l])));case 6:l++,e.next=3;break;case 9:return r&&(this.gslb=r),this.reporter.log.info("join",t),this.reporter.updateCommonInfo({apid:s,usrid:o,usrn:a,clientId:this.id,roomName:i,gslb:this.gslb,udid:Environment.deviceId,sdkvrs:this.sdkVersion}),this.reporter.trace.wtJoin(!0),d=Date.now(),e.next=16,this.beforeJoin(t);case 16:return f=(p=e.sent).rtcToken,h=p.iceConfig,this.securityToken=m=p.securityToken,g=Date.now(),this.reporter.trace.join(!0),this.socket&&this.socket.removeAllListeners(),this.socket=new Re(this.reporter),this.joinInfo=t,this.signaling=new Le(this.socket,this.reporter),this.addEventListeners(),e.abrupt("return",this.signaling.login(Xe({token:f},(v=this.sdkVersion,_=this.scene,{protocol:"1.0",configJsonStr:JSON.stringify({needPersonalityAudioStream:!0}),userAgent:{sdk:{version:v,type:"JavaScript",scene:_},runtime:{name:Environment.browserType,version:Environment.browserVersion},os:{name:Environment.system,version:Environment.systemVersion}}}))).then((function(e){var t=e.room,r=t.participants,n=t.participantsVer,i=e.id;return y.dataSwitcher.init(i),y.userManager.init(r,n,i),y.reporter.trace.join(!1,Date.now()-g,!0),y.reporter.trace.wtJoin(!1,Date.now()-d,!0),{joinResponse:e,iceConfig:h,securityToken:m}})).catch((function(e){throw y.reporter.trace.wtJoin(!0,Date.now()-d,!1,tryJsonStringify(e)),e})));case 29:case"end":return e.stop()}var v,_}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"handleConferenceEvent",value:function(e){this.reporter.log.debug("roomEvent ".concat(JSON.stringify(e))),"destroy"===(null==e?void 0:e.action)&&this.handleLeave("channel_banned")}},{key:"handleConnectionChangeEvent",value:function(e,t,r){e!==this.connectionState&&("disconnected"===e?this.handleLeave(r):(this.connectionState=e,this.emit("connection-state-change",e,t)))}},{key:"handleDropEvent",value:function(e){this.reporter.log.debug("dropEvent ".concat((null==e?void 0:e.reason)||(null==e?void 0:e.code))),this.handleLeave((null==e?void 0:e.code)===ye.UserReplaced?"uid_replaced":"uid_banned")}},{key:"handleRejoin",value:function(){var e=this,t=Date.now();this.reporter.trace.wtReJoin(!0),this.beforeRejoin(this.joinInfo,this.userManager.currentPid).then((function(r){var n=Date.now();return e.reporter.trace.rejoin(!0),e.rejoin(r).then((function(){e.dataSwitcher.init(e.userManager.currentPid),e.reporter.trace.rejoin(!1,Date.now()-n),e.reporter.trace.wtReJoin(!1,Date.now()-t,!0)}),(function(t){throw e.reporter.trace.rejoin(!1,Date.now()-n,!1,tryJsonStringify(t)),t}))})).catch((function(r){e.reporter.trace.wtReJoin(!1,Date.now()-t,!1,tryJsonStringify(r)),e.handleLeave("server_error")}))}},{key:"handleUserEvent",value:function(e,t){this.emit("user",e,t)}},{key:"handleNotifyEvent",value:function(e,t){this.emit("notify",e,t)}},{key:"handleBatchNotifyEvent",value:function(e){this.emit("batch-notify",e)}},{key:"handleSyncEvent",value:function(e){this.emit("sync",e)}},{key:"handleReauthEvent",value:function(){this.dataSwitcher.init(this.userManager.currentPid)}},{key:"rejoin",value:(t=T(B.mark((function e(t){var r=this;return B.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.signaling.relogin({token:t}).then((function(e){r.signaling.emit("sync",e)})));case 1:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"leave",value:function(){this.signaling.logout(),this.handleLeave("leave")}}]);var t,r}();function _createForOfIteratorHelper$2(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=_unsupportedIterableToArray$2(e))||t){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return e.length>n?{done:!1,value:e[n++]}:{done:!0}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function _unsupportedIterableToArray$2(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray$2(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray$2(e,t):void 0}}function _arrayLikeToArray$2(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);t>r;r++)n[r]=e[r];return n}function ownKeys$1(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function _objectSpread$1(e){for(var t=1;arguments.length>t;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ownKeys$1(Object(r),!0).forEach((function(t){_defineProperty(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ownKeys$1(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function _callSuper$4(e,t,r){return t=_getPrototypeOf$1(t),_possibleConstructorReturn$1(e,_isNativeReflectConstruct$4()?Reflect.construct(t,[],_getPrototypeOf$1(e).constructor):t.apply(e,r))}function _isNativeReflectConstruct$4(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(_isNativeReflectConstruct$4=function(){return!!e})()}var Channel=function(e){function t(e,r){var n;return _classCallCheck$1(this,t),n=_callSuper$4(this,t),Object.defineProperty(n,"signaling",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(n,"sessionManager",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(n,"groupManager",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(n,"userManager",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(n,"streamManager",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(n,"remoteAudioTrack",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(n,"internalChannel",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(n,"reporter",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(n,"roomId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(n,"defaultVideoStreamType",{enumerable:!0,configurable:!0,writable:!0,value:"high"}),Object.defineProperty(n,"client",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(n,"subscribedAudioStream",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(n,"micMixedGroups",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(n,"iceConfig",{enumerable:!0,configurable:!0,writable:!0,value:{level:0,iceServerList:[]}}),Object.defineProperty(n,"handleSubscribeParam",{enumerable:!0,configurable:!0,writable:!0,value:function(e){var t,r=e.mediaType,i=e.action,o=e.uid,a=e.auxiliary,s=n.getStream(e),c=n.userManager.users.get(o),u=n.groups.some((function(e){return e.joined})),l="mcu"===o?n.remoteAudioTrack:a?null==c?void 0:c.auxiliaryTrack:null==c?void 0:c.videoTrack;return"mcu"===o&&"video"===r||o&&"mcu"!==o&&"audio"===r?t=new DingRTCError(ErrorCode.InvaildArgument,"only support ".concat(i," mcu audio")):"mcu"===o&&u&&"subscribe"===i?t=new DingRTCError(ErrorCode.SubscribeInvaild,"cannot subscribe mcu while in group"):"subscribe"===i&&l?t=new DingRTCError(ErrorCode.SubscribeInvaild,"duplicated subscription"):s&&("unsubscribe"!==i||l)||(n.reporter.log.warn("".concat(o," videoTrack not existed")),t=new DingRTCError(ErrorCode.SubscribeStreamNotExisted)),{uid:o,user:c,error:t,stream:s,session:"unsubscribe"===i?n.sessionManager.getSessionByStreamId(s.id):null,resolutionInfo:"video"===r?getResolutionInfo(n.defaultVideoStreamType,getResolutions(s)):null}}}),Object.defineProperty(n,"handleJoinResponse",{enumerable:!0,configurable:!0,writable:!0,value:function(e){var t=e.room,r=e.id,i=t.participants,o=t.groupList,a=t.groupListVer;n.streamManager.init(t.streams,t.streamsVer),clientConfig.grouptalk&&n.groupManager.init(o,a),n.userManager.init(i,r),n.streamManager.on("stream",n.handleStreamEvent),n.userManager.on("user",n.handleUserEvent),n.groupManager.on("group",n.handleGroupEvent)}}),n.reporter=r,n.internalChannel=new tt({reporter:r,gslb:clientConfig.gslb[0],sdkVersion:SDK_VERSION}),n.signaling=new Signaling(n.internalChannel),n.client=e,n.micMixedGroups=new Set,n.groupManager=new GroupManager(n),n.userManager=new UserManager(n),n.streamManager=new StreamManager(n),n.sessionManager=new SessionManager(e,n),n.subscribedAudioStream="",n.handleStreamEvent=n.handleStreamEvent.bind(n),n.handleUserEvent=n.handleUserEvent.bind(n),n.handleGroupEvent=n.handleGroupEvent.bind(n),n}return _inherits$1(t,e),_createClass$1(t,[{key:"localTracks",get:function(){return _toConsumableArray(this.sessionManager.sessions.values()).filter((function(e){return e.state===PubSubStates.Processing&&e instanceof Publication})).map((function(e){return e.tracks[0]}))}},{key:"groups",get:function(){var e=this;return this.groupManager.groupList.map((function(t){return _objectSpread$1(_objectSpread$1({},t),{},{audioPublished:e.micMixedGroups.has(t.id)})}))}},{key:"handleStreamEvent",value:function(e,t){var r=t.id,n=t.owner,i=t.mediaType,o=t.auxiliary,a=t.owners,s=t.updateStatus,c=t.properties,u=this.internalChannel.userManager.participants,l=u.get(n),d=this.userManager.users.get(null==l?void 0:l.user);if("add"===e&&!(n===this.userManager.currentPid)&&d)this.client.emit("user-published",d,i,o);else if("remove"===e&&d)this.sessionManager.removeSession(void 0,r),"video"===i&&(o&&d.auxiliaryTrack&&(d.auxiliaryTrack.stop(),d.auxiliaryTrack=null),!o&&d.videoTrack&&(d.videoTrack.stop(),d.videoTrack=null)),this.client.emit("user-unpublished",d,i,o);else if("update"===e){if(s)this.client.emit("user-info-updated",(null==d?void 0:d.userId)||this.userManager.currentUid,s);else if(null!=(null==c?void 0:c.mirror)){var p=o?d.auxiliaryTrack:d.videoTrack;null==p||p.setSourceMirror(c.mirror)}}else if("volumeActive"===e){var f=a.map((function(e){return u.get(e)})).map((function(e){return null==e?void 0:e.user})).filter((function(e){return!!e}));this.client.emit("volume-indicator",f)}}},{key:"handleGroupEvent",value:function(e,t,r){if("add"===e)this.client.emit("group-add",t);else if("remove"===e)this.client.emit("group-remove",t);else if("user-join"===e)this.client.emit("group-user-join",t,r);else if("user-leave"===e)this.client.emit("group-user-leave",t,r);else if("info-updated"===e){this.client.emit("group-info-updated",t,r.key,r.value)}}},{key:"handleUserEvent",value:function(e,t){"join"===e?(this.client.emit("user-joined",t),t.hasVideo&&this.client.emit("user-published",t,"video"),t.hasAudio&&this.client.emit("user-published",t,"audio"),t.hasAuxiliary&&this.client.emit("user-published",t,"video",!0)):"leave"===e&&this.client.emit("user-left",t)}},{key:"getStream",value:function(e){var t,r=e.groupId,n=e.uid,i=e.auxiliary;if(r){var o,a=this.groupManager.groups.get(r);return null==a||null===(o=a.audioInfo)||void 0===o?void 0:o.audio}var s="mcu"===n?_toConsumableArray(this.streamManager.streams.values()):null===(t=this.userManager.users.get(n))||void 0===t?void 0:t.relatedStreams;return s.find("mcu"===n?function(e){return"admin"===e.info.owner&&"mixed"===e.type}:function(e){var t=e.media.video;return(null==t?void 0:t.source)===(i?VideoSourceInfo.SCREENCAST:VideoSourceInfo.CAMERA)})}},{key:"join",value:(s=_asyncToGenerator$1(_regeneratorRuntime$1.mark((function e(t){var r=this;return _regeneratorRuntime$1.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.signaling.join(t,clientConfig.gslb[0]).then((function(e){var t=e.joinResponse,n=e.iceConfig;return r.roomId=t.room.id,parseSubSsrcInfo(t.room.ssrcMask,t.room.ssrcClientSequence),r.reporter.updateCommonInfo({roomId:r.roomId,participantId:t.id}),n&&n.uis&&r.setIceConfig(n.uis),r.sessionManager.start(),r.handleJoinResponse(t),t})));case 1:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"setIceConfig",value:function(e){var t=e.iceServerList;e.level&&(e.iceServerList=(void 0===t?[]:t).filter((function(e){return/([0-9]{1,3}\.){3}[0-9]{1,3}/i.test(e)})),this.iceConfig=e)}},{key:"clear",value:function(){var e;this.userManager.clear(),this.streamManager.clear(),this.sessionManager.clear(),this.micMixedGroups.clear(),this.groupManager.clear(),this.subscribedAudioStream="",null===(e=this.remoteAudioTrack)||void 0===e||e.stop(),this.remoteAudioTrack=null,this.iceConfig=null,this.roomId="",this.streamManager.off("stream",this.handleStreamEvent),this.userManager.off("user",this.handleUserEvent),this.groupManager.off("group",this.handleGroupEvent)}},{key:"leave",value:function(){if("disconnected"!==this.internalChannel.connectionState)return this.reporter.trace.leave(),this.signaling.leave()}},{key:"publish",value:(a=_asyncToGenerator$1(_regeneratorRuntime$1.mark((function e(t){var r,n,i;return _regeneratorRuntime$1.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=this.micMixedGroups,n=this.groupManager,i=[],this.groups.some((function(e){return e.joined}))?i.push.apply(i,_toConsumableArray(_toConsumableArray(r).map((function(e){var t;return null===(t=n.groups.get(e))||void 0===t||null===(t=t.audioInfo)||void 0===t?void 0:t.label})).filter((function(e){return!!e})))):i.push("common"),e.abrupt("return",this.sessionManager.batchPublish(t,i));case 5:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"unpublish",value:function(e){var t=this,r=new Set(e.map((function(e){return e.getTrackId()}))),n=_toConsumableArray(this.sessionManager.sessions.values()).filter((function(e){var t;return e instanceof Publication&&r.has(null===(t=e.tracks)||void 0===t||null===(t=t[0])||void 0===t?void 0:t.getTrackId())}));return n.forEach((function(e){t.reporter.trace.unpublish(e.id)})),this.sessionManager.batchUnPublish(n)}},{key:"getRemoteTrack",value:function(e,t){var r=this;if(!t.mediaStream)return null;var n=this.userManager.users.get(e.uid);if("audio"===e.mediaType){var i=this.remoteAudioTrack;return this.remoteAudioTrack=updateRemoteTrack(t.mediaStream,"audio","mcu",this.remoteAudioTrack),i||t.once("audio-first-frame",(function(){r.remoteAudioTrack.emit("first-frame-decoded")})),this.remoteAudioTrack}return n.getRemoteVideoTrack(t,e.auxiliary)}},{key:"subscribe",value:(o=_asyncToGenerator$1(_regeneratorRuntime$1.mark((function e(t){var r,n,i,o,a=this;return _regeneratorRuntime$1.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=this.handleSubscribeParam(t),i=r.stream,o=r.resolutionInfo,!(n=r.error)){e.next=3;break}throw n;case 3:return e.abrupt("return",this.sessionManager.batchSubscribe([{stream:i,uid:t.uid,resolutionInfo:o}]).then((function(e){var r=e[0],n=r.error;if(n)throw n;return a.getRemoteTrack(t,r.subscription)})));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"batchSubscribe",value:(i=_asyncToGenerator$1(_regeneratorRuntime$1.mark((function e(t){var r=this;return _regeneratorRuntime$1.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.sessionManager.batchSubscribe(t.map(this.handleSubscribeParam)).then(function(){var e=_asyncToGenerator$1(_regeneratorRuntime$1.mark((function e(n){var i;return _regeneratorRuntime$1.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=[],t.forEach((function(e,t){var o=n[t];i.push({uid:e.uid,auxiliary:e.auxiliary,error:o.error,track:r.getRemoteTrack(e,o.subscription)})})),e.abrupt("return",i);case 3:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()));case 1:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"unsubscribe",value:function(e){var t=this,r=this.getStream(e),n=e.mediaType,i=e.auxiliary,o=this.handleSubscribeParam(e),a=o.user,s=o.stream,c=o.session,u=o.error;if(u)throw u;this.reporter.trace.unsubscribe({sessionId:null==c?void 0:c.id,remoteStreamId:null==r?void 0:r.id,remoteUserId:e.uid});return t.sessionManager.batchUnscribe([{stream:s,session:c,error:u}]).then((function(){"audio"===n?(t.subscribedAudioStream="",t.remoteAudioTrack.stop(),t.remoteAudioTrack=null):i?a.auxiliaryTrack=null:a.videoTrack=null}))}},{key:"batchUnsubscribe",value:function(e){var t,r=this,n=[],i=_createForOfIteratorHelper$2(e);try{for(i.s();!(t=i.n()).done;){var o=t.value,a=this.handleSubscribeParam(_objectSpread$1(_objectSpread$1({},o),{},{action:"unsubscribe"})),s=a.session,c=a.stream,u=a.user;this.reporter.trace.unsubscribe({sessionId:s.id,remoteStreamId:c.id,remoteUserId:u.userId}),c&&n.push(_objectSpread$1({stream:c,user:u,session:s},o))}}catch(e){i.e(e)}finally{i.f()}return n.length?this.sessionManager.batchUnscribe(n).then((function(){for(var e=0,t=n;t.length>e;e++){var i,o=t[e],a=o.user,s=o.auxiliary;if("audio"===o.mediaType)null===(i=r.remoteAudioTrack)||void 0===i||i.stop(),r.remoteAudioTrack=null;else if(s){var c;null===(c=a.auxiliaryTrack)||void 0===c||c.stop(),a.auxiliaryTrack=null}else{var u;null===(u=a.videoTrack)||void 0===u||u.stop(),a.videoTrack=null}}})):Promise.resolve()}},{key:"subscribeGroup",value:function(e){var t=this,r=this.getStream({groupId:e});if(!r)throw new DingRTCError(ErrorCode.InvaildArgument,"cannot find audio info of the group");if(this.subscribedAudioStream)throw new DingRTCError(ErrorCode.InvaildState,"you were subscribed group or channel already");return this.sessionManager.batchSubscribe([{stream:r,uid:e}]).then((function(n){return t.subscribedAudioStream=r.id,t.remoteAudioTrack=updateRemoteTrack(n[0].subscription.mediaStream,"audio",e,t.remoteAudioTrack),t.remoteAudioTrack}))}},{key:"unsubscribeGroup",value:function(e){var t=this,r=this.getStream({groupId:e});if(!r)throw new DingRTCError(ErrorCode.InvaildArgument,"cannot find audio info of the group");if(this.subscribedAudioStream!==r.id)throw new DingRTCError(ErrorCode.InvaildState,"you were not subscribed the group");return this.sessionManager.batchUnscribe([{stream:r,session:this.sessionManager.getSessionByStreamId(r.id)}]).then((function(){r.id===t.subscribedAudioStream&&(t.subscribedAudioStream="",t.remoteAudioTrack.stop(),t.remoteAudioTrack=null)}))}},{key:"setRemoteStreamType",value:function(e,t,r){this.reporter.log.info("setRemoteStreamType",e,t,r);var n=this.getStream({uid:e,mediaType:"video",auxiliary:r}),i=this.sessionManager.getSessionByStreamId(n.id),o=getResolutionInfo(t,getResolutions(n));return i.applyOptions(o)}},{key:"joinGroup",value:function(e){var t=this,r=e.groupId,n=e.publishAudioToGroup;return this.groupManager.join(e).then((function(e){n&&e.joinGroupAudioSuccess&&t.micMixedGroups.add(r)}))}},{key:"leaveGroup",value:function(e){var t=this,r=e.groupId;return this.groupManager.leave(e).then((function(){t.micMixedGroups.delete(r)}))}},{key:"dismissGroup",value:function(e){var t=this;return this.groupManager.dismiss(e).then((function(){t.micMixedGroups.delete(e)}))}},{key:"mixGroupAudio",value:function(e,t,r){return this.signaling.streamControl({operation:r,streamId:e,data:t})}},{key:"setGroupProperties",value:function(e,t){return this.groupManager.setProperties(e,t)}},{key:"publishToGroup",value:(n=_asyncToGenerator$1(_regeneratorRuntime$1.mark((function e(t,r){var n,i,o,a=arguments;return _regeneratorRuntime$1.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=2>=a.length||void 0===a[2]||a[2],i=[],null!=r&&i.push(this.groupManager.groups.get(r).audioInfo.label),!this.localTracks.includes(t)){e.next=18;break}if(o=this.streamManager.getStreamByTrackId(t.getTrackId()),null==r){e.next=14;break}return e.next=8,this.mixGroupAudio(o.id,i[0],"mix");case 8:if(this.micMixedGroups.add(r),!n){e.next=12;break}return e.next=12,this.mixGroupAudio(o.id,"common","unmix");case 12:e.next=16;break;case 14:return e.next=16,this.mixGroupAudio(o.id,"common","mix");case 16:e.next=22;break;case 18:return n||i.push("common"),e.next=21,this.sessionManager.batchPublish([t],i);case 21:this.micMixedGroups.add(r);case 22:case"end":return e.stop()}}),e,this)}))),function(e,t){return n.apply(this,arguments)})},{key:"unpublishFromGroup",value:(r=_asyncToGenerator$1(_regeneratorRuntime$1.mark((function e(t,r){var n,i,o,a=arguments;return _regeneratorRuntime$1.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=a.length>2&&void 0!==a[2]&&a[2],i=this.groupManager.groups.get(r).audioInfo.label,o=this.streamManager.getStreamByTrackId(t.getTrackId()),e.next=5,this.mixGroupAudio(o.id,i,"unmix");case 5:if(this.micMixedGroups.delete(r),!n){e.next=9;break}return e.next=9,this.mixGroupAudio(o.id,"common","mix");case 9:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})}]);var r,n,i,o,a,s}(EventEmitter);function _callSuper$3(e,t,r){return t=_getPrototypeOf$1(t),_possibleConstructorReturn$1(e,_isNativeReflectConstruct$3()?Reflect.construct(t,[],_getPrototypeOf$1(e).constructor):t.apply(e,r))}function _isNativeReflectConstruct$3(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(_isNativeReflectConstruct$3=function(){return!!e})()}var initAudioDeviceBufferInfo={timestamp:-1,maxPlayLevel:-1,maxRecLevel:-1},DeviceMonitor=function(e){function t(e){var r,n;return _classCallCheck$1(this,t),r=_callSuper$3(this,t),Object.defineProperty(r,"audioDeviceBufferReport",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"audioDeviceBufferInfo",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"client",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"makeReport",{enumerable:!0,configurable:!0,writable:!0,value:(n=_asyncToGenerator$1(_regeneratorRuntime$1.mark((function e(){var t,n,i;return _regeneratorRuntime$1.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,r.client.getLocalAudioStats();case 2:return t=e.sent.audioLevel,e.next=6,r.client.getRemoteAudioStats();case 6:n=e.sent.audioLevel,i={timestamp:Date.now(),maxRecLevel:Math.min(1,t||0),maxPlayLevel:Math.min(1,Math.max(0,n||0))},r.audioDeviceBufferInfo.timestamp>0&&(r.audioDeviceBufferReport={attr_duration_ms:getDelta(i.timestamp,r.audioDeviceBufferInfo.timestamp),attr_play_level:Math.round(32767*i.maxPlayLevel),attr_rec_level:Math.round(32767*i.maxRecLevel)},r.emit("audio-device-buffer",Object.assign({},r.audioDeviceBufferReport))),r.audioDeviceBufferInfo=i;case 11:case"end":return e.stop()}}),e)}))),function(){return n.apply(this,arguments)})}),r.audioDeviceBufferReport={attr_duration_ms:0,attr_rec_level:0,attr_play_level:0},r.audioDeviceBufferInfo=Object.assign({},initAudioDeviceBufferInfo),r.client=e,r}return _inherits$1(t,e),_createClass$1(t)}(Monitor);function ownKeys(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function _objectSpread(e){for(var t=1;arguments.length>t;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(r),!0).forEach((function(t){_defineProperty(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ownKeys(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function _createForOfIteratorHelper$1(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=_unsupportedIterableToArray$1(e))||t){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return e.length>n?{done:!1,value:e[n++]}:{done:!0}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function _unsupportedIterableToArray$1(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray$1(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray$1(e,t):void 0}}function _arrayLikeToArray$1(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);t>r;r++)n[r]=e[r];return n}function _callSuper$2(e,t,r){return t=_getPrototypeOf$1(t),_possibleConstructorReturn$1(e,_isNativeReflectConstruct$2()?Reflect.construct(t,[],_getPrototypeOf$1(e).constructor):t.apply(e,r))}function _isNativeReflectConstruct$2(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(_isNativeReflectConstruct$2=function(){return!!e})()}var DingRTCClient=function(e){function t(){var e;return _classCallCheck$1(this,t),e=_callSuper$2(this,t),Object.defineProperty(e,"channelName",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(e,"id",{enumerable:!0,configurable:!0,writable:!0,value:createUuid(6)}),Object.defineProperty(e,"reporter",{enumerable:!0,configurable:!0,writable:!0,value:registerReporter(e.id)}),Object.defineProperty(e,"channel",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(e,"monitor",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(e,"syncStatTimer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(e,"clientStatSync",{enumerable:!0,configurable:!0,writable:!0,value:[0,0,0,0,0,0]}),Object.defineProperty(e,"currentClientState",{enumerable:!0,configurable:!0,writable:!0,value:""}),e.channel=new Channel(e,e.reporter),e.handleVisibilitychange=e.handleVisibilitychange.bind(e),e.handleNetworkQuality=e.handleNetworkQuality.bind(e),e.handleConnectionChangeEvent=e.handleConnectionChangeEvent.bind(e),e.handlePageUnload=e.handlePageUnload.bind(e),e.init(),e}return _inherits$1(t,e),_createClass$1(t,[{key:"remoteUsers",get:function(){return this.channel.userManager.remoteUsers}},{key:"groups",get:function(){return this.channel.groups}},{key:"userId",get:function(){var e;return(null===(e=this.channel.internalChannel)||void 0===e||null===(e=e.joinInfo)||void 0===e?void 0:e.uid)||""}},{key:"localTracks",get:function(){return this.channel.localTracks}},{key:"connectionState",get:function(){var e;return(null===(e=this.channel.internalChannel)||void 0===e?void 0:e.connectionState)||"disconnected"}},{key:"init",value:function(){this.syncStatTimer&&(removeTimer(this.syncStatTimer,"interval"),this.syncStatTimer=null),this.currentClientState="",this.channelName="",this.channel.clear(),this.removeEventListeners(),this.monitor&&(this.monitor.stop(),this.monitor.removeAllListeners(),this.monitor=null),this.clientStatSync=[0,0,0,0,0,0]}},{key:"join",value:function(e){var t=this;return this.addEventListeners(),this.channel.join(e).then((function(r){var n;return t.channelName=e.channel,t.monitor=new DeviceMonitor(t),t.monitor.on("audio-device-buffer",(function(e){t.reporter.metric.audioDeviceBuffer(e)})),t.syncStatTimer=addTimer((function(){t.sendClientStatToRemote()}),NETWORK_QUALITY_TIMEOUT,"interval"),{remoteUsers:t.remoteUsers,timeLeft:null===(n=r.room)||void 0===n?void 0:n.timeLeft}})).catch((function(e){throw t.init(),e}))}},{key:"setRemoteDefaultVideoStreamType",value:function(e){this.reporter.log.info("setRemoteDefaultVideoStreamType",e),this.channel.defaultVideoStreamType=e}},{key:"leave",value:function(){this.reporter.log.info("leave"),this.channel.leave(),this.init()}},{key:"publish",value:function(e){var t=this;if(this.reporter.log.info("publish",(Array.isArray(e)?e:[e]).map((function(e){return e.trackMediaType}))),"connected"!==this.connectionState)return Promise.reject(new DingRTCError(ErrorCode.PublishNotJoinChannel));var r,n=(Array.isArray(e)?e:[e]).filter((function(e){return e instanceof LocalTrack&&!t.localTracks.includes(e)})),i=n.concat(this.localTracks),o=_defineProperty(_defineProperty(_defineProperty(_defineProperty({},exports.VideoSourceInfo.CAMERA,0),exports.VideoSourceInfo.SCREENCAST,0),exports.AudioSourceInfo.MIC,0),exports.AudioSourceInfo.MIXED,0),a=_createForOfIteratorHelper$1(i);try{for(a.s();!(r=a.n()).done;){var s=r.value;if(o[s.source]++,o[s.source]>=2)throw new DingRTCError(ErrorCode.QuotaLimitExceed,"".concat(s.source," published already"))}}catch(e){a.e(e)}finally{a.f()}if(!n.length)throw new DingRTCError(ErrorCode.PublishNoStream);return this.channel.publish(n)}},{key:"unpublish",value:function(e){var t=Array.isArray(e)?e:[e];return e||(t=this.localTracks),this.reporter.log.info("unpublish",t.map((function(e){return e.trackMediaType}))),this.channel.unpublish(t)}},{key:"subscribe",value:(n=_asyncToGenerator$1(_regeneratorRuntime$1.mark((function e(t,r,n){return _regeneratorRuntime$1.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.reporter.log.info("subscribe",t,r),"connected"===this.connectionState){e.next=3;break}throw new DingRTCError(ErrorCode.SubscribeNotJoinChannel);case 3:return e.abrupt("return",this.channel.subscribe({uid:t,mediaType:r,action:"subscribe",auxiliary:n}));case 4:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return n.apply(this,arguments)})},{key:"batchSubscribe",value:function(e){if(Array.isArray(e)&&e.length){if(this.reporter.log.info("batchSubscribe",e),"connected"!==this.connectionState)throw new DingRTCError(ErrorCode.SubscribeNotJoinChannel);return this.channel.batchSubscribe(e.map((function(e){return _objectSpread(_objectSpread({},e),{},{action:"subscribe"})})))}}},{key:"unsubscribe",value:(r=_asyncToGenerator$1(_regeneratorRuntime$1.mark((function e(t,r,n){return _regeneratorRuntime$1.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.reporter.log.info("unsubscribe",t,r),e.abrupt("return",this.channel.unsubscribe({uid:t,auxiliary:n,mediaType:r,action:"unsubscribe"}));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return r.apply(this,arguments)})},{key:"batchUnsubscribe",value:function(e){if(Array.isArray(e)&&e.length)return this.reporter.log.info("batchUnsubscribe",e),"connected"!==this.connectionState?Promise.reject(new DingRTCError(ErrorCode.SubscribeNotJoinChannel)):this.channel.batchUnsubscribe(e.map((function(e){return _objectSpread(_objectSpread({},e),{},{action:"unsubscribe"})})))}},{key:"getLocalAudioStats",value:function(){return this.channel.sessionManager.getLocalAudioStats("user")}},{key:"getLocalVideoStats",value:function(){return this.channel.sessionManager.getLocalVideoStats("user")}},{key:"setRemoteVideoStreamType",value:function(e,t,r){var n=this;this.reporter.log.info("setRemoteVideoStreamType",e,t);var i=this.remoteUsers.find((function(t){return t.userId===e}));return null!=i&&i.relatedStreams?this.channel.setRemoteStreamType(e,t,r).then((function(){n.emit("stream-type-changed",e,t,r)})):(this.reporter.log.warn("".concat(e," videoTrack not existed")),Promise.reject("viedoTrack doesnt exiested"))}},{key:"getRemoteVideoStats",value:function(){return this.channel.sessionManager.getRemoteVideoStats("user")}},{key:"getRemoteAudioStats",value:function(){return this.channel.sessionManager.getRemoteAudioStats("user")}},{key:"getRemoteNetworkQuality",value:function(){var e={};return this.remoteUsers.forEach((function(t){var r,n,i=t.properties;e[t.userId]={downlinkNetworkQuality:Number((null==i||null===(r=i[USER_STATS_SYNC])||void 0===r?void 0:r[ClientUserStats.DOWNLINK])||0),uplinkNetworkQuality:Number((null==i||null===(n=i[USER_STATS_SYNC])||void 0===n?void 0:n[ClientUserStats.UPLINK])||0)}})),e}},{key:"handleConnectionChangeEvent",value:function(e,t,r){this.reporter.log.debug("connectionStateChange from ".concat(t," to ").concat(e," ").concat(r||"")),this.emit("connection-state-change",e,t,r)}},{key:"sendClientStatToRemote",value:function(){var e=this.clientStatSync.join("");if(e!==this.currentClientState){var t=transNativeAndWebNetworkRank(null,e[ClientUserStats.UPLINK]),r=transNativeAndWebNetworkRank(null,this.currentClientState[ClientUserStats.UPLINK]),n=transNativeAndWebNetworkRank(null,e[ClientUserStats.DOWNLINK]),i=transNativeAndWebNetworkRank(null,this.currentClientState[ClientUserStats.DOWNLINK]);t===r&&n===i||this.channel.userManager.setParticipantProperties(e),this.currentClientState=e}}},{key:"handleVisibilitychange",value:function(){var e="visible"!==document.visibilityState,t=e?TraceEvent$1.APP_BACKGROUND:TraceEvent$1.APP_FOREGROUND;(Environment.isAndroid()||Environment.isIOS())&&(this.reporter.sender.sendEvent(t),this.clientStatSync[ClientUserStats.BACKGROUND_MODE]=Number(e))}},{key:"handleNetworkQuality",value:function(e,t){this.clientStatSync[ClientUserStats.UPLINK]=e,this.clientStatSync[ClientUserStats.DOWNLINK]=t,this.emit("network-quality",e,t)}},{key:"handlePageUnload",value:function(e){"connected"===this.connectionState&&(this.reporter.log.info("leave for ".concat(e.type)),this.leave())}},{key:"addEventListeners",value:function(){window.addEventListener(Environment.isSafari()?"beforeunload":"pagehide",this.handlePageUnload),document.addEventListener("visibilitychange",this.handleVisibilitychange),this.channel.sessionManager.on("network-quality",this.handleNetworkQuality),this.channel.signaling.on("connection-state-change",this.handleConnectionChangeEvent)}},{key:"removeEventListeners",value:function(){window.removeEventListener(Environment.isSafari()?"beforeunload":"pagehide",this.handlePageUnload),document.removeEventListener("visibilitychange",this.handleVisibilitychange),this.channel.sessionManager.off("network-quality",this.handleNetworkQuality),this.channel.signaling.off("connection-state-change",this.handleConnectionChangeEvent)}},{key:"joinGroup",value:function(e){var t=e.userData,r=e.groupId,n=new TextEncoder;if(!r||n.encode(r).length>64)throw new DingRTCError(ErrorCode.InvaildArgument,"join group with invalid groupId");if(t){var i=new TextEncoder;if("string"!=typeof t||i.encode(t).length>64)throw new DingRTCError(ErrorCode.InvaildArgument,"join group with invalid userData")}return this.channel.joinGroup(e)}},{key:"leaveGroup",value:function(e){return this.channel.leaveGroup({groupId:e,publishAudioToChannel:!1})}},{key:"setGroupName",value:function(e,t){var r=new TextEncoder;if(!t||r.encode(t).length>64)throw new DingRTCError(ErrorCode.InvaildArgument,"update group with invalid name");return this.channel.setGroupProperties(e,{key:"name",value:t})}},{key:"subscribeGroup",value:function(e){return this.channel.subscribeGroup(e)}},{key:"unsubscribeGroup",value:function(e){return this.channel.unsubscribeGroup(e)}},{key:"mixAudioToGroup",value:function(e,t,r){if("audio"!==e.trackMediaType)throw new DingRTCError(ErrorCode.InvaildArgument,"only support publish audio to group");if("connected"!==this.connectionState)throw new DingRTCError(ErrorCode.PublishNotJoinChannel);if(t){if(this.reporter.log.info("mix audio track:".concat(e.getTrackId()," to group ").concat(r)),null==r&&this.channel.micMixedGroups.size)throw new DingRTCError(ErrorCode.InvaildState,"cannot mix audio to channel while mixing to others group");return this.channel.publishToGroup(e,r,!0)}if(this.reporter.log.info("unmix audio track:".concat(e.getTrackId()," from group ").concat(r)),!this.channel.micMixedGroups.has(r))throw new DingRTCError(ErrorCode.InvaildState,"cannot unmix audio from the unmixed group");return this.channel.unpublishFromGroup(e,r)}},{key:"dismissGroup",value:function(e){return this.channel.dismissGroup(e)}},{key:"register",value:function(e){e.attach(this.channel.internalChannel)}},{key:"ungister",value:function(e){e.detach(this.channel.internalChannel)}}]);var r,n}(EventEmitter);function _createForOfIteratorHelper(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=_unsupportedIterableToArray(e))||t){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return e.length>n?{done:!1,value:e[n++]}:{done:!0}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(e,t):void 0}}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);t>r;r++)n[r]=e[r];return n}function _callSuper$1(e,t,r){return t=_getPrototypeOf$1(t),_possibleConstructorReturn$1(e,_isNativeReflectConstruct$1()?Reflect.construct(t,[],_getPrototypeOf$1(e).constructor):t.apply(e,r))}function _isNativeReflectConstruct$1(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(_isNativeReflectConstruct$1=function(){return!!e})()}var DeviceManager=function(e){function t(){var e,r;return _classCallCheck$1(this,t),e=_callSuper$1(this,t),Object.defineProperty(e,"deviceList",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(e,"checking",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(e,"checkDeviceUpdate",{enumerable:!0,configurable:!0,writable:!0,value:(r=_asyncToGenerator$1(_regeneratorRuntime$1.mark((function r(){var n;return _regeneratorRuntime$1.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(!e.checking){r.next=2;break}return r.abrupt("return");case 2:return e.checking=!0,r.next=5,t.getDevices();case 5:e.compareDevices(n=r.sent,"audiooutput"),e.compareDevices(n,"videoinput"),e.compareDevices(n,"audioinput"),e.deviceList=n,e.checking=!1;case 11:case"end":return r.stop()}}),r)}))),function(){return r.apply(this,arguments)})}),Object.defineProperty(e,"compareDevices",{enumerable:!0,configurable:!0,writable:!0,value:function(t,r){var n,i=t.filter((function(e){return e.kind===r})),o=e.deviceList.filter((function(e){return e.kind===r})),a=i.map((function(e){return e.deviceId})),s=o.map((function(e){return e.deviceId})),c=i.filter((function(e){return!s.includes(e.deviceId)})),u=o.filter((function(e){return!a.includes(e.deviceId)})),l={audioinput:"microphone-changed",audiooutput:"playback-device-changed",videoinput:"camera-changed"},d=_createForOfIteratorHelper(c);try{for(d.s();!(n=d.n()).done;){e.emit(l[r],{device:n.value,state:"active"})}}catch(e){d.e(e)}finally{d.f()}var p,f=_createForOfIteratorHelper(u);try{for(f.s();!(p=f.n()).done;){e.emit(l[r],{device:p.value,state:"inactive"})}}catch(e){f.e(e)}finally{f.f()}}}),t._instance?_possibleConstructorReturn$1(e,t._instance):(e.deviceList=[],support.checkSupported()?(t.getDevices().then((function(t){e.deviceList=t,e.addEventListeners()})),e):_possibleConstructorReturn$1(e))}return _inherits$1(t,e),_createClass$1(t,[{key:"addEventListeners",value:function(){"ondevicechange"in navigator.mediaDevices?navigator.mediaDevices.addEventListener("devicechange",this.checkDeviceUpdate):addTimer(this.checkDeviceUpdate,1e3,"interval")}}],[{key:"getInstance",value:function(){return t._instance}},{key:"getDevices",value:function(){return new Promise((function(e,t){var r,n;null!==(r=navigator.mediaDevices)&&void 0!==r&&r.enumerateDevices?null===(n=navigator.mediaDevices)||void 0===n||n.enumerateDevices().then((function(t){return e(t.filter((function(e){return e.deviceId})))})).catch(t):t(new DingRTCError(ErrorCode.BrowserNotSupported,"enumerateDevices is not supported"))}))}}])}(EventEmitter);Object.defineProperty(DeviceManager,"_instance",{enumerable:!0,configurable:!0,writable:!0,value:new DeviceManager}),Object.defineProperty(DeviceManager,"getPlaybackDevices",{enumerable:!0,configurable:!0,writable:!0,value:function(){return DeviceManager.getDevices().then((function(e){return e.filter((function(e){return"audiooutput"===e.kind}))})).catch((function(e){throw parseAudioDeviceError(e)}))}}),Object.defineProperty(DeviceManager,"getCameras",{enumerable:!0,configurable:!0,writable:!0,value:function(){return DeviceManager.getDevices().then((function(e){return e.filter((function(e){return"videoinput"===e.kind}))})).catch((function(e){throw parseVideoDeviceError(e)}))}}),Object.defineProperty(DeviceManager,"getMicrophones",{enumerable:!0,configurable:!0,writable:!0,value:function(){return DeviceManager.getDevices().then((function(e){return e.filter((function(e){return"audioinput"===e.kind}))})).catch((function(e){throw parseAudioDeviceError(e)}))}});var FALLBACK_SUB_VIDEO_PROFILE={height:360,width:640};function _callSuper(e,t,r){return t=_getPrototypeOf$1(t),_possibleConstructorReturn$1(e,_isNativeReflectConstruct()?Reflect.construct(t,[],_getPrototypeOf$1(e).constructor):t.apply(e,r))}function _isNativeReflectConstruct(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(_isNativeReflectConstruct=function(){return!!e})()}initMediaElementManager();var _getReporter=getReporter(),simpleLogger=_getReporter.log,DingRTC=function(e){function t(){var e;if(_classCallCheck$1(this,t),e=_callSuper(this,t),Object.defineProperty(e,"VERSION",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),e.VERSION=SDK_VERSION,!support.checkSupported())return _possibleConstructorReturn$1(e);var r=DeviceManager.getInstance();return r.on("camera-changed",(function(t){e.emit("camera-changed",t)})),r.on("microphone-changed",(function(t){e.emit("microphone-changed",t)})),r.on("playback-device-changed",(function(t){e.emit("playback-device-changed",t)})),EventBus.on("autoplay-failed",(function(t){e.emit("autoplay-failed",t)})),e}return _inherits$1(t,e),_createClass$1(t,[{key:"createClient",value:function(){return simpleLogger.info("createClient"),new DingRTCClient}},{key:"checkSystemRequirements",value:function(){return simpleLogger.info("checkSystemRequirements"),support.checkSupported()}},{key:"getSupportedCodec",value:function(){return simpleLogger.info("getSupportedCodec"),support.getSupportedCodec()}},{key:"createCameraVideoTrack",value:function(e){return simpleLogger.info("createCameraVideoTrack",e),createCameraVideoTrack(e)}},{key:"createMicrophoneAudioTrack",value:function(e){return simpleLogger.info("createMicrophoneAudioTrack",e),createMicrophoneAudioTrack(e)}},{key:"createCustomVideoTrack",value:function(e){return simpleLogger.info("createCustomVideoTrack",e),createCustomVideoTrack(e)}},{key:"createCustomAudioTrack",value:function(e){return simpleLogger.info("createCustomAudioTrack",e),createCustomAudioTrack(e)}},{key:"createScreenVideoTrack",value:function(e){return simpleLogger.info("createScreenVideoTrack",e),createScreenVideoTrack(e)}},{key:"createMicrophoneAndCameraTracks",value:(r=_asyncToGenerator$1(_regeneratorRuntime$1.mark((function e(t,r){return _regeneratorRuntime$1.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return simpleLogger.info("createMicrophoneAndCameraTracks",{videoConfig:t,audioConfig:r}),e.abrupt("return",createMicrophoneAndCameraTracks(t,r));case 2:case"end":return e.stop()}}),e)}))),function(e,t){return r.apply(this,arguments)})},{key:"getCameras",value:function(){return simpleLogger.info("getCameras"),DeviceManager.getCameras()}},{key:"getDevices",value:function(){return simpleLogger.info("getDevices"),DeviceManager.getDevices()}},{key:"getPlaybackDevices",value:function(){return simpleLogger.info("getPlaybackDevices"),DeviceManager.getPlaybackDevices()}},{key:"getMicrophones",value:function(){return simpleLogger.info("getMicrophones"),DeviceManager.getMicrophones()}},{key:"setLogLevel",value:function(e){setLogLevel(e),simpleLogger.info("setLogLevel",e)}},{key:"setClientConfig",value:function(e){simpleLogger.info("setClientConfig",e),clientConfig.setClientConfig(e)}}]);var r}(EventEmitter),index=new DingRTC;exports.ErrorCodeAndMsgMap=ErrorCodeAndMsgMap,exports.FALLBACK_SUB_VIDEO_PROFILE=FALLBACK_SUB_VIDEO_PROFILE,exports.default=index,Object.defineProperty(exports,"__esModule",{value:!0})}));