WGShare.Client.Wx/lib/agora-miniapp-sdk.js

3 lines
159 KiB
JavaScript

/*! For license information please see agora-miniapp-sdk.js.LICENSE.txt */
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("AgoraSDK",[],t):"object"==typeof exports?exports.AgoraSDK=t():e.AgoraSDK=t()}(self,(()=>(()=>{var __webpack_modules__={537:e=>{"use strict";e.exports=function(e,t){for(var n=new Array(arguments.length-1),r=0,i=2,o=!0;i<arguments.length;)n[r++]=arguments[i++];return new Promise((function(i,s){n[r]=function(e){if(o)if(o=!1,e)s(e);else{for(var t=new Array(arguments.length-1),n=0;n<t.length;)t[n++]=arguments[n];i.apply(null,t)}};try{e.apply(t||null,n)}catch(e){o&&(o=!1,s(e))}}))}},419:(e,t)=>{"use strict";var n=t;n.length=function(e){var t=e.length;if(!t)return 0;for(var n=0;--t%4>1&&"="===e.charAt(t);)++n;return Math.ceil(3*e.length)/4-n};for(var r=new Array(64),i=new Array(123),o=0;o<64;)i[r[o]=o<26?o+65:o<52?o+71:o<62?o-4:o-59|43]=o++;n.encode=function(e,t,n){for(var i,o=null,s=[],a=0,c=0;t<n;){var l=e[t++];switch(c){case 0:s[a++]=r[l>>2],i=(3&l)<<4,c=1;break;case 1:s[a++]=r[i|l>>4],i=(15&l)<<2,c=2;break;case 2:s[a++]=r[i|l>>6],s[a++]=r[63&l],c=0}a>8191&&((o||(o=[])).push(String.fromCharCode.apply(String,s)),a=0)}return c&&(s[a++]=r[i],s[a++]=61,1===c&&(s[a++]=61)),o?(a&&o.push(String.fromCharCode.apply(String,s.slice(0,a))),o.join("")):String.fromCharCode.apply(String,s.slice(0,a))};var s="invalid encoding";n.decode=function(e,t,n){for(var r,o=n,a=0,c=0;c<e.length;){var l=e.charCodeAt(c++);if(61===l&&a>1)break;if(void 0===(l=i[l]))throw Error(s);switch(a){case 0:r=l,a=1;break;case 1:t[n++]=r<<2|(48&l)>>4,r=l,a=2;break;case 2:t[n++]=(15&r)<<4|(60&l)>>2,r=l,a=3;break;case 3:t[n++]=(3&r)<<6|l,a=0}}if(1===a)throw Error(s);return n-o},n.test=function(e){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(e)}},211:e=>{"use strict";function t(){this._listeners={}}e.exports=t,t.prototype.on=function(e,t,n){return(this._listeners[e]||(this._listeners[e]=[])).push({fn:t,ctx:n||this}),this},t.prototype.off=function(e,t){if(void 0===e)this._listeners={};else if(void 0===t)this._listeners[e]=[];else for(var n=this._listeners[e],r=0;r<n.length;)n[r].fn===t?n.splice(r,1):++r;return this},t.prototype.emit=function(e){var t=this._listeners[e];if(t){for(var n=[],r=1;r<arguments.length;)n.push(arguments[r++]);for(r=0;r<t.length;)t[r].fn.apply(t[r++].ctx,n)}return this}},945:e=>{"use strict";function t(e){return"undefined"!=typeof Float32Array?function(){var t=new Float32Array([-0]),n=new Uint8Array(t.buffer),r=128===n[3];function i(e,r,i){t[0]=e,r[i]=n[0],r[i+1]=n[1],r[i+2]=n[2],r[i+3]=n[3]}function o(e,r,i){t[0]=e,r[i]=n[3],r[i+1]=n[2],r[i+2]=n[1],r[i+3]=n[0]}function s(e,r){return n[0]=e[r],n[1]=e[r+1],n[2]=e[r+2],n[3]=e[r+3],t[0]}function a(e,r){return n[3]=e[r],n[2]=e[r+1],n[1]=e[r+2],n[0]=e[r+3],t[0]}e.writeFloatLE=r?i:o,e.writeFloatBE=r?o:i,e.readFloatLE=r?s:a,e.readFloatBE=r?a:s}():function(){function t(e,t,n,r){var i=t<0?1:0;if(i&&(t=-t),0===t)e(1/t>0?0:2147483648,n,r);else if(isNaN(t))e(2143289344,n,r);else if(t>34028234663852886e22)e((i<<31|2139095040)>>>0,n,r);else if(t<11754943508222875e-54)e((i<<31|Math.round(t/1401298464324817e-60))>>>0,n,r);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,n,r)}}function s(e,t,n){var r=e(t,n),i=2*(r>>31)+1,o=r>>>23&255,s=8388607&r;return 255===o?s?NaN:i*(1/0):0===o?1401298464324817e-60*i*s:i*Math.pow(2,o-150)*(s+8388608)}e.writeFloatLE=t.bind(null,n),e.writeFloatBE=t.bind(null,r),e.readFloatLE=s.bind(null,i),e.readFloatBE=s.bind(null,o)}(),"undefined"!=typeof Float64Array?function(){var t=new Float64Array([-0]),n=new Uint8Array(t.buffer),r=128===n[7];function i(e,r,i){t[0]=e,r[i]=n[0],r[i+1]=n[1],r[i+2]=n[2],r[i+3]=n[3],r[i+4]=n[4],r[i+5]=n[5],r[i+6]=n[6],r[i+7]=n[7]}function o(e,r,i){t[0]=e,r[i]=n[7],r[i+1]=n[6],r[i+2]=n[5],r[i+3]=n[4],r[i+4]=n[3],r[i+5]=n[2],r[i+6]=n[1],r[i+7]=n[0]}function s(e,r){return n[0]=e[r],n[1]=e[r+1],n[2]=e[r+2],n[3]=e[r+3],n[4]=e[r+4],n[5]=e[r+5],n[6]=e[r+6],n[7]=e[r+7],t[0]}function a(e,r){return n[7]=e[r],n[6]=e[r+1],n[5]=e[r+2],n[4]=e[r+3],n[3]=e[r+4],n[2]=e[r+5],n[1]=e[r+6],n[0]=e[r+7],t[0]}e.writeDoubleLE=r?i:o,e.writeDoubleBE=r?o:i,e.readDoubleLE=r?s:a,e.readDoubleBE=r?a:s}():function(){function t(e,t,n,r,i,o){var s=r<0?1:0;if(s&&(r=-r),0===r)e(0,i,o+t),e(1/r>0?0:2147483648,i,o+n);else if(isNaN(r))e(0,i,o+t),e(2146959360,i,o+n);else if(r>17976931348623157e292)e(0,i,o+t),e((s<<31|2146435072)>>>0,i,o+n);else{var a;if(r<22250738585072014e-324)e((a=r/5e-324)>>>0,i,o+t),e((s<<31|a/4294967296)>>>0,i,o+n);else{var c=Math.floor(Math.log(r)/Math.LN2);1024===c&&(c=1023),e(4503599627370496*(a=r*Math.pow(2,-c))>>>0,i,o+t),e((s<<31|c+1023<<20|1048576*a&1048575)>>>0,i,o+n)}}}function s(e,t,n,r,i){var o=e(r,i+t),s=e(r,i+n),a=2*(s>>31)+1,c=s>>>20&2047,l=4294967296*(1048575&s)+o;return 2047===c?l?NaN:a*(1/0):0===c?5e-324*a*l:a*Math.pow(2,c-1075)*(l+4503599627370496)}e.writeDoubleLE=t.bind(null,n,0,4),e.writeDoubleBE=t.bind(null,r,4,0),e.readDoubleLE=s.bind(null,i,0,4),e.readDoubleBE=s.bind(null,o,4,0)}(),e}function n(e,t,n){t[n]=255&e,t[n+1]=e>>>8&255,t[n+2]=e>>>16&255,t[n+3]=e>>>24}function r(e,t,n){t[n]=e>>>24,t[n+1]=e>>>16&255,t[n+2]=e>>>8&255,t[n+3]=255&e}function i(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0}function o(e,t){return(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0}e.exports=t(t)},199:module=>{"use strict";function inquire(moduleName){try{var mod=eval("quire".replace(/^/,"re"))(moduleName);if(mod&&(mod.length||Object.keys(mod).length))return mod}catch(e){}return null}module.exports=inquire},662:e=>{"use strict";e.exports=function(e,t,n){var r=n||8192,i=r>>>1,o=null,s=r;return function(n){if(n<1||n>i)return e(n);s+n>r&&(o=e(r),s=0);var a=t.call(o,s,s+=n);return 7&s&&(s=1+(7|s)),a}}},997:(e,t)=>{"use strict";var n=t;n.length=function(e){for(var t=0,n=0,r=0;r<e.length;++r)(n=e.charCodeAt(r))<128?t+=1:n<2048?t+=2:55296==(64512&n)&&56320==(64512&e.charCodeAt(r+1))?(++r,t+=4):t+=3;return t},n.read=function(e,t,n){if(n-t<1)return"";for(var r,i=null,o=[],s=0;t<n;)(r=e[t++])<128?o[s++]=r:r>191&&r<224?o[s++]=(31&r)<<6|63&e[t++]:r>239&&r<365?(r=((7&r)<<18|(63&e[t++])<<12|(63&e[t++])<<6|63&e[t++])-65536,o[s++]=55296+(r>>10),o[s++]=56320+(1023&r)):o[s++]=(15&r)<<12|(63&e[t++])<<6|63&e[t++],s>8191&&((i||(i=[])).push(String.fromCharCode.apply(String,o)),s=0);return i?(s&&i.push(String.fromCharCode.apply(String,o.slice(0,s))),i.join("")):String.fromCharCode.apply(String,o.slice(0,s))},n.write=function(e,t,n){for(var r,i,o=n,s=0;s<e.length;++s)(r=e.charCodeAt(s))<128?t[n++]=r:r<2048?(t[n++]=r>>6|192,t[n++]=63&r|128):55296==(64512&r)&&56320==(64512&(i=e.charCodeAt(s+1)))?(r=65536+((1023&r)<<10)+(1023&i),++s,t[n++]=r>>18|240,t[n++]=r>>12&63|128,t[n++]=r>>6&63|128,t[n++]=63&r|128):(t[n++]=r>>12|224,t[n++]=r>>6&63|128,t[n++]=63&r|128);return n-o}},699:(e,t,n)=>{"use strict";var r,i,o,s,a,c=n(100),l=c.Writer,u=c.util,p=c.roots.default||(c.roots.default={});p.io=((a={}).agora=((s={}).pb=((o={}).CounterCompact=function(){function e(e){if(this.items=[],e)for(var t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.sid="",e.prototype.peer=u.Long?u.Long.fromBits(0,0,!1):0,e.prototype.items=u.emptyArray,e.create=function(t){return new e(t)},e.encode=function(e,t){if(t||(t=l.create()),null!=e.sid&&Object.hasOwnProperty.call(e,"sid")&&t.uint32(10).string(e.sid),null!=e.peer&&Object.hasOwnProperty.call(e,"peer")&&t.uint32(16).int64(e.peer),null!=e.items&&e.items.length)for(var n=0;n<e.items.length;++n)p.io.agora.pb.Item.encode(e.items[n],t.uint32(26).fork()).ldelim();return t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e}(),o.Item=function(){function e(e){if(e)for(var t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.lts=u.Long?u.Long.fromBits(0,0,!1):0,e.prototype.id=11001,e.prototype.value=0,e.prototype.tagErrorCode=0,e.prototype.streamId=0,e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=l.create()),null!=e.lts&&Object.hasOwnProperty.call(e,"lts")&&t.uint32(8).int64(e.lts),null!=e.id&&Object.hasOwnProperty.call(e,"id")&&t.uint32(16).int32(e.id),null!=e.value&&Object.hasOwnProperty.call(e,"value")&&t.uint32(24).int32(e.value),null!=e.tagErrorCode&&Object.hasOwnProperty.call(e,"tagErrorCode")&&t.uint32(32).int32(e.tagErrorCode),null!=e.streamId&&Object.hasOwnProperty.call(e,"streamId")&&t.uint32(40).uint32(e.streamId),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e}(),o.Id=(r={},(i=Object.create(r))[r[11001]="Miniapp_SDK_Pusher_Video_Bitrate"]=11001,i[r[11002]="Miniapp_SDK_Pusher_Audio_Bitrate"]=11002,i[r[11003]="Miniapp_SDK_Pusher_Video_FPS"]=11003,i[r[11004]="Miniapp_SDK_Pusher_Video_GOP"]=11004,i[r[11005]="Miniapp_SDK_Pusher_Net_Speed"]=11005,i[r[11006]="Miniapp_SDK_Pusher_Video_Cache"]=11006,i[r[11007]="Miniapp_SDK_Pusher_Audio_Cache"]=11007,i[r[11008]="Miniapp_SDK_Player_Video_Bitrate"]=11008,i[r[11009]="Miniapp_SDK_Player_Audio_Bitrate"]=11009,i[r[11010]="Miniapp_SDK_Player_Video_FPS"]=11010,i[r[11011]="Miniapp_SDK_Player_Video_GOP"]=11011,i[r[11012]="Miniapp_SDK_Player_Net_Speed"]=11012,i[r[11013]="Miniapp_SDK_Player_Video_Cache"]=11013,i[r[11014]="Miniapp_SDK_Player_Audio_Cache"]=11014,i[r[11015]="Miniapp_SDK_Player_V_Dec_Cache_Size"]=11015,i[r[11016]="Miniapp_SDK_Player_V_Sum_Cache_Size"]=11016,i[r[11017]="Miniapp_SDK_Player_AV_Play_Interval"]=11017,i[r[11018]="Miniapp_SDK_Player_AV_Recv_Interval"]=11018,i[r[11019]="Miniapp_SDK_Player_Audio_Cache_Threshold"]=11019,i[r[11022]="Miniapp_SDK_Pusher_Video_Height"]=11022,i[r[11023]="Miniapp_SDK_Pusher_Video_Width"]=11023,i[r[11024]="Miniapp_SDK_Player_Video_Width"]=11024,i[r[11025]="Miniapp_SDK_Player_Video_Height"]=11025,i[r[11035]="Miniapp_SDK_Pusher_Net_Jitter"]=11035,i[r[11036]="Miniapp_SDK_Pusher_Net_QualityLevel"]=11036,i[r[11037]="Miniapp_SDK_Player_Net_Jitter"]=11037,i[r[11038]="Miniapp_SDK_Player_Net_QualityLevel"]=11038,i),o.ConnectWebSocket=function(){function e(e){if(e)for(var t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.lts=u.Long?u.Long.fromBits(0,0,!1):0,e.prototype.sid="",e.prototype.cname="",e.prototype.cid=u.Long?u.Long.fromBits(0,0,!1):0,e.prototype.ip="",e.prototype.uid="",e.prototype.success=0,e.prototype.elapse=u.Long?u.Long.fromBits(0,0,!1):0,e.prototype.peer=u.Long?u.Long.fromBits(0,0,!1):0,e.prototype.gateway="",e.prototype.ec="",e.prototype.wsurl="",e.prototype.details="",e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=l.create()),null!=e.lts&&Object.hasOwnProperty.call(e,"lts")&&t.uint32(8).int64(e.lts),null!=e.sid&&Object.hasOwnProperty.call(e,"sid")&&t.uint32(18).string(e.sid),null!=e.cname&&Object.hasOwnProperty.call(e,"cname")&&t.uint32(26).string(e.cname),null!=e.cid&&Object.hasOwnProperty.call(e,"cid")&&t.uint32(32).int64(e.cid),null!=e.ip&&Object.hasOwnProperty.call(e,"ip")&&t.uint32(42).string(e.ip),null!=e.uid&&Object.hasOwnProperty.call(e,"uid")&&t.uint32(50).string(e.uid),null!=e.success&&Object.hasOwnProperty.call(e,"success")&&t.uint32(56).int32(e.success),null!=e.elapse&&Object.hasOwnProperty.call(e,"elapse")&&t.uint32(64).int64(e.elapse),null!=e.peer&&Object.hasOwnProperty.call(e,"peer")&&t.uint32(72).int64(e.peer),null!=e.gateway&&Object.hasOwnProperty.call(e,"gateway")&&t.uint32(82).string(e.gateway),null!=e.ec&&Object.hasOwnProperty.call(e,"ec")&&t.uint32(90).string(e.ec),null!=e.wsurl&&Object.hasOwnProperty.call(e,"wsurl")&&t.uint32(98).string(e.wsurl),null!=e.details&&Object.hasOwnProperty.call(e,"details")&&t.uint32(106).string(e.details),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e}(),o.Join=function(){function e(e){if(e)for(var t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.lts=u.Long?u.Long.fromBits(0,0,!1):0,e.prototype.sid="",e.prototype.cname="",e.prototype.cid=u.Long?u.Long.fromBits(0,0,!1):0,e.prototype.ip="",e.prototype.uid="",e.prototype.success=0,e.prototype.elapse=u.Long?u.Long.fromBits(0,0,!1):0,e.prototype.peer=u.Long?u.Long.fromBits(0,0,!1):0,e.prototype.ec="",e.prototype.isrejoin=0,e.prototype.details="",e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=l.create()),null!=e.lts&&Object.hasOwnProperty.call(e,"lts")&&t.uint32(8).int64(e.lts),null!=e.sid&&Object.hasOwnProperty.call(e,"sid")&&t.uint32(18).string(e.sid),null!=e.cname&&Object.hasOwnProperty.call(e,"cname")&&t.uint32(26).string(e.cname),null!=e.cid&&Object.hasOwnProperty.call(e,"cid")&&t.uint32(32).int64(e.cid),null!=e.ip&&Object.hasOwnProperty.call(e,"ip")&&t.uint32(42).string(e.ip),null!=e.uid&&Object.hasOwnProperty.call(e,"uid")&&t.uint32(50).string(e.uid),null!=e.success&&Object.hasOwnProperty.call(e,"success")&&t.uint32(56).int32(e.success),null!=e.elapse&&Object.hasOwnProperty.call(e,"elapse")&&t.uint32(64).int64(e.elapse),null!=e.peer&&Object.hasOwnProperty.call(e,"peer")&&t.uint32(72).int64(e.peer),null!=e.ec&&Object.hasOwnProperty.call(e,"ec")&&t.uint32(82).string(e.ec),null!=e.isrejoin&&Object.hasOwnProperty.call(e,"isrejoin")&&t.uint32(88).int32(e.isrejoin),null!=e.details&&Object.hasOwnProperty.call(e,"details")&&t.uint32(98).string(e.details),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e}(),o.JoinChooseServer=function(){function e(e){if(e)for(var t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.lts=u.Long?u.Long.fromBits(0,0,!1):0,e.prototype.sid="",e.prototype.cname="",e.prototype.cid=u.Long?u.Long.fromBits(0,0,!1):0,e.prototype.ip="",e.prototype.uid="",e.prototype.success=0,e.prototype.elapse=u.Long?u.Long.fromBits(0,0,!1):0,e.prototype.peer=u.Long?u.Long.fromBits(0,0,!1):0,e.prototype.csurl="",e.prototype.ec="",e.prototype.gatewaylist="",e.prototype.details="",e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=l.create()),null!=e.lts&&Object.hasOwnProperty.call(e,"lts")&&t.uint32(8).int64(e.lts),null!=e.sid&&Object.hasOwnProperty.call(e,"sid")&&t.uint32(18).string(e.sid),null!=e.cname&&Object.hasOwnProperty.call(e,"cname")&&t.uint32(26).string(e.cname),null!=e.cid&&Object.hasOwnProperty.call(e,"cid")&&t.uint32(32).int64(e.cid),null!=e.ip&&Object.hasOwnProperty.call(e,"ip")&&t.uint32(42).string(e.ip),null!=e.uid&&Object.hasOwnProperty.call(e,"uid")&&t.uint32(50).string(e.uid),null!=e.success&&Object.hasOwnProperty.call(e,"success")&&t.uint32(56).int32(e.success),null!=e.elapse&&Object.hasOwnProperty.call(e,"elapse")&&t.uint32(64).int64(e.elapse),null!=e.peer&&Object.hasOwnProperty.call(e,"peer")&&t.uint32(72).int64(e.peer),null!=e.csurl&&Object.hasOwnProperty.call(e,"csurl")&&t.uint32(82).string(e.csurl),null!=e.ec&&Object.hasOwnProperty.call(e,"ec")&&t.uint32(90).string(e.ec),null!=e.gatewaylist&&Object.hasOwnProperty.call(e,"gatewaylist")&&t.uint32(98).string(e.gatewaylist),null!=e.details&&Object.hasOwnProperty.call(e,"details")&&t.uint32(106).string(e.details),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e}(),o.Leave=function(){function e(e){if(e)for(var t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.lts=u.Long?u.Long.fromBits(0,0,!1):0,e.prototype.sid="",e.prototype.cname="",e.prototype.cid=u.Long?u.Long.fromBits(0,0,!1):0,e.prototype.ip="",e.prototype.uid="",e.prototype.success=0,e.prototype.elapse=u.Long?u.Long.fromBits(0,0,!1):0,e.prototype.peer=u.Long?u.Long.fromBits(0,0,!1):0,e.prototype.details="",e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=l.create()),null!=e.lts&&Object.hasOwnProperty.call(e,"lts")&&t.uint32(8).int64(e.lts),null!=e.sid&&Object.hasOwnProperty.call(e,"sid")&&t.uint32(18).string(e.sid),null!=e.cname&&Object.hasOwnProperty.call(e,"cname")&&t.uint32(26).string(e.cname),null!=e.cid&&Object.hasOwnProperty.call(e,"cid")&&t.uint32(32).int64(e.cid),null!=e.ip&&Object.hasOwnProperty.call(e,"ip")&&t.uint32(42).string(e.ip),null!=e.uid&&Object.hasOwnProperty.call(e,"uid")&&t.uint32(50).string(e.uid),null!=e.success&&Object.hasOwnProperty.call(e,"success")&&t.uint32(56).int32(e.success),null!=e.elapse&&Object.hasOwnProperty.call(e,"elapse")&&t.uint32(64).int64(e.elapse),null!=e.peer&&Object.hasOwnProperty.call(e,"peer")&&t.uint32(72).int64(e.peer),null!=e.details&&Object.hasOwnProperty.call(e,"details")&&t.uint32(82).string(e.details),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e}(),o.MuteLocal=function(){function e(e){if(e)for(var t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.lts=u.Long?u.Long.fromBits(0,0,!1):0,e.prototype.vid=u.Long?u.Long.fromBits(0,0,!1):0,e.prototype.sid="",e.prototype.cname="",e.prototype.cid=u.Long?u.Long.fromBits(0,0,!1):0,e.prototype.ip="",e.prototype.uid="",e.prototype.success=0,e.prototype.elapse=u.Long?u.Long.fromBits(0,0,!1):0,e.prototype.ec="",e.prototype.target=0,e.prototype.mute=0,e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=l.create()),null!=e.lts&&Object.hasOwnProperty.call(e,"lts")&&t.uint32(8).int64(e.lts),null!=e.vid&&Object.hasOwnProperty.call(e,"vid")&&t.uint32(16).int64(e.vid),null!=e.sid&&Object.hasOwnProperty.call(e,"sid")&&t.uint32(26).string(e.sid),null!=e.cname&&Object.hasOwnProperty.call(e,"cname")&&t.uint32(34).string(e.cname),null!=e.cid&&Object.hasOwnProperty.call(e,"cid")&&t.uint32(40).int64(e.cid),null!=e.ip&&Object.hasOwnProperty.call(e,"ip")&&t.uint32(50).string(e.ip),null!=e.uid&&Object.hasOwnProperty.call(e,"uid")&&t.uint32(58).string(e.uid),null!=e.success&&Object.hasOwnProperty.call(e,"success")&&t.uint32(64).int32(e.success),null!=e.elapse&&Object.hasOwnProperty.call(e,"elapse")&&t.uint32(72).int64(e.elapse),null!=e.ec&&Object.hasOwnProperty.call(e,"ec")&&t.uint32(90).string(e.ec),null!=e.target&&Object.hasOwnProperty.call(e,"target")&&t.uint32(96).int32(e.target),null!=e.mute&&Object.hasOwnProperty.call(e,"mute")&&t.uint32(104).int32(e.mute),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e}(),o.MuteRemote=function(){function e(e){if(e)for(var t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.lts=u.Long?u.Long.fromBits(0,0,!1):0,e.prototype.vid=u.Long?u.Long.fromBits(0,0,!1):0,e.prototype.sid="",e.prototype.cname="",e.prototype.cid=u.Long?u.Long.fromBits(0,0,!1):0,e.prototype.ip="",e.prototype.uid="",e.prototype.success=0,e.prototype.elapse=u.Long?u.Long.fromBits(0,0,!1):0,e.prototype.peer=u.Long?u.Long.fromBits(0,0,!1):0,e.prototype.ec="",e.prototype.target=0,e.prototype.mute=0,e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=l.create()),null!=e.lts&&Object.hasOwnProperty.call(e,"lts")&&t.uint32(8).int64(e.lts),null!=e.vid&&Object.hasOwnProperty.call(e,"vid")&&t.uint32(16).int64(e.vid),null!=e.sid&&Object.hasOwnProperty.call(e,"sid")&&t.uint32(26).string(e.sid),null!=e.cname&&Object.hasOwnProperty.call(e,"cname")&&t.uint32(34).string(e.cname),null!=e.cid&&Object.hasOwnProperty.call(e,"cid")&&t.uint32(40).int64(e.cid),null!=e.ip&&Object.hasOwnProperty.call(e,"ip")&&t.uint32(50).string(e.ip),null!=e.uid&&Object.hasOwnProperty.call(e,"uid")&&t.uint32(58).string(e.uid),null!=e.success&&Object.hasOwnProperty.call(e,"success")&&t.uint32(64).int32(e.success),null!=e.elapse&&Object.hasOwnProperty.call(e,"elapse")&&t.uint32(72).int64(e.elapse),null!=e.peer&&Object.hasOwnProperty.call(e,"peer")&&t.uint32(80).int64(e.peer),null!=e.ec&&Object.hasOwnProperty.call(e,"ec")&&t.uint32(90).string(e.ec),null!=e.target&&Object.hasOwnProperty.call(e,"target")&&t.uint32(96).int32(e.target),null!=e.mute&&Object.hasOwnProperty.call(e,"mute")&&t.uint32(104).int32(e.mute),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e}(),o.PlayerState=function(){function e(e){if(e)for(var t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.lts=u.Long?u.Long.fromBits(0,0,!1):0,e.prototype.sid="",e.prototype.cname="",e.prototype.cid=u.Long?u.Long.fromBits(0,0,!1):0,e.prototype.ip="",e.prototype.uid="",e.prototype.success=0,e.prototype.elapse=u.Long?u.Long.fromBits(0,0,!1):0,e.prototype.peer=u.Long?u.Long.fromBits(0,0,!1):0,e.prototype.url="",e.prototype.code=0,e.prototype.status="",e.prototype.error="",e.prototype.details="",e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=l.create()),null!=e.lts&&Object.hasOwnProperty.call(e,"lts")&&t.uint32(8).int64(e.lts),null!=e.sid&&Object.hasOwnProperty.call(e,"sid")&&t.uint32(18).string(e.sid),null!=e.cname&&Object.hasOwnProperty.call(e,"cname")&&t.uint32(26).string(e.cname),null!=e.cid&&Object.hasOwnProperty.call(e,"cid")&&t.uint32(32).int64(e.cid),null!=e.ip&&Object.hasOwnProperty.call(e,"ip")&&t.uint32(42).string(e.ip),null!=e.uid&&Object.hasOwnProperty.call(e,"uid")&&t.uint32(50).string(e.uid),null!=e.success&&Object.hasOwnProperty.call(e,"success")&&t.uint32(56).int32(e.success),null!=e.elapse&&Object.hasOwnProperty.call(e,"elapse")&&t.uint32(64).int64(e.elapse),null!=e.peer&&Object.hasOwnProperty.call(e,"peer")&&t.uint32(72).int64(e.peer),null!=e.url&&Object.hasOwnProperty.call(e,"url")&&t.uint32(82).string(e.url),null!=e.code&&Object.hasOwnProperty.call(e,"code")&&t.uint32(88).int32(e.code),null!=e.status&&Object.hasOwnProperty.call(e,"status")&&t.uint32(98).string(e.status),null!=e.error&&Object.hasOwnProperty.call(e,"error")&&t.uint32(106).string(e.error),null!=e.details&&Object.hasOwnProperty.call(e,"details")&&t.uint32(114).string(e.details),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e}(),o.Publish=function(){function e(e){if(e)for(var t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.lts=u.Long?u.Long.fromBits(0,0,!1):0,e.prototype.sid="",e.prototype.cname="",e.prototype.cid=u.Long?u.Long.fromBits(0,0,!1):0,e.prototype.ip="",e.prototype.uid="",e.prototype.success=0,e.prototype.elapse=u.Long?u.Long.fromBits(0,0,!1):0,e.prototype.peer=u.Long?u.Long.fromBits(0,0,!1):0,e.prototype.ec="",e.prototype.pushurl="",e.prototype.details="",e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=l.create()),null!=e.lts&&Object.hasOwnProperty.call(e,"lts")&&t.uint32(8).int64(e.lts),null!=e.sid&&Object.hasOwnProperty.call(e,"sid")&&t.uint32(18).string(e.sid),null!=e.cname&&Object.hasOwnProperty.call(e,"cname")&&t.uint32(26).string(e.cname),null!=e.cid&&Object.hasOwnProperty.call(e,"cid")&&t.uint32(32).int64(e.cid),null!=e.ip&&Object.hasOwnProperty.call(e,"ip")&&t.uint32(42).string(e.ip),null!=e.uid&&Object.hasOwnProperty.call(e,"uid")&&t.uint32(50).string(e.uid),null!=e.success&&Object.hasOwnProperty.call(e,"success")&&t.uint32(56).int32(e.success),null!=e.elapse&&Object.hasOwnProperty.call(e,"elapse")&&t.uint32(64).int64(e.elapse),null!=e.peer&&Object.hasOwnProperty.call(e,"peer")&&t.uint32(72).int64(e.peer),null!=e.ec&&Object.hasOwnProperty.call(e,"ec")&&t.uint32(82).string(e.ec),null!=e.pushurl&&Object.hasOwnProperty.call(e,"pushurl")&&t.uint32(90).string(e.pushurl),null!=e.details&&Object.hasOwnProperty.call(e,"details")&&t.uint32(106).string(e.details),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e}(),o.PusherState=function(){function e(e){if(e)for(var t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.lts=u.Long?u.Long.fromBits(0,0,!1):0,e.prototype.sid="",e.prototype.cname="",e.prototype.cid=u.Long?u.Long.fromBits(0,0,!1):0,e.prototype.ip="",e.prototype.uid="",e.prototype.success=0,e.prototype.elapse=u.Long?u.Long.fromBits(0,0,!1):0,e.prototype.peer=u.Long?u.Long.fromBits(0,0,!1):0,e.prototype.url="",e.prototype.code=0,e.prototype.status="",e.prototype.error="",e.prototype.details="",e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=l.create()),null!=e.lts&&Object.hasOwnProperty.call(e,"lts")&&t.uint32(8).int64(e.lts),null!=e.sid&&Object.hasOwnProperty.call(e,"sid")&&t.uint32(18).string(e.sid),null!=e.cname&&Object.hasOwnProperty.call(e,"cname")&&t.uint32(26).string(e.cname),null!=e.cid&&Object.hasOwnProperty.call(e,"cid")&&t.uint32(32).int64(e.cid),null!=e.ip&&Object.hasOwnProperty.call(e,"ip")&&t.uint32(42).string(e.ip),null!=e.uid&&Object.hasOwnProperty.call(e,"uid")&&t.uint32(50).string(e.uid),null!=e.success&&Object.hasOwnProperty.call(e,"success")&&t.uint32(56).int32(e.success),null!=e.elapse&&Object.hasOwnProperty.call(e,"elapse")&&t.uint32(64).int64(e.elapse),null!=e.peer&&Object.hasOwnProperty.call(e,"peer")&&t.uint32(72).int64(e.peer),null!=e.url&&Object.hasOwnProperty.call(e,"url")&&t.uint32(82).string(e.url),null!=e.code&&Object.hasOwnProperty.call(e,"code")&&t.uint32(88).int32(e.code),null!=e.status&&Object.hasOwnProperty.call(e,"status")&&t.uint32(98).string(e.status),null!=e.error&&Object.hasOwnProperty.call(e,"error")&&t.uint32(106).string(e.error),null!=e.details&&Object.hasOwnProperty.call(e,"details")&&t.uint32(114).string(e.details),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e}(),o.ServerEvent=function(){function e(e){if(e)for(var t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.lts=u.Long?u.Long.fromBits(0,0,!1):0,e.prototype.sid="",e.prototype.cname="",e.prototype.cid=u.Long?u.Long.fromBits(0,0,!1):0,e.prototype.ip="",e.prototype.uid="",e.prototype.success=0,e.prototype.elapse=u.Long?u.Long.fromBits(0,0,!1):0,e.prototype.peer=u.Long?u.Long.fromBits(0,0,!1):0,e.prototype.action="",e.prototype.details="",e.prototype.reqTs=u.Long?u.Long.fromBits(0,0,!1):0,e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=l.create()),null!=e.lts&&Object.hasOwnProperty.call(e,"lts")&&t.uint32(8).int64(e.lts),null!=e.sid&&Object.hasOwnProperty.call(e,"sid")&&t.uint32(18).string(e.sid),null!=e.cname&&Object.hasOwnProperty.call(e,"cname")&&t.uint32(26).string(e.cname),null!=e.cid&&Object.hasOwnProperty.call(e,"cid")&&t.uint32(32).int64(e.cid),null!=e.ip&&Object.hasOwnProperty.call(e,"ip")&&t.uint32(42).string(e.ip),null!=e.uid&&Object.hasOwnProperty.call(e,"uid")&&t.uint32(50).string(e.uid),null!=e.success&&Object.hasOwnProperty.call(e,"success")&&t.uint32(56).int32(e.success),null!=e.elapse&&Object.hasOwnProperty.call(e,"elapse")&&t.uint32(64).int64(e.elapse),null!=e.peer&&Object.hasOwnProperty.call(e,"peer")&&t.uint32(72).int64(e.peer),null!=e.action&&Object.hasOwnProperty.call(e,"action")&&t.uint32(82).string(e.action),null!=e.details&&Object.hasOwnProperty.call(e,"details")&&t.uint32(90).string(e.details),null!=e.reqTs&&Object.hasOwnProperty.call(e,"reqTs")&&t.uint32(96).int64(e.reqTs),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e}(),o.Session=function(){function e(e){if(e)for(var t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.lts=u.Long?u.Long.fromBits(0,0,!1):0,e.prototype.sid="",e.prototype.cname="",e.prototype.cid=u.Long?u.Long.fromBits(0,0,!1):0,e.prototype.ip="",e.prototype.uid="",e.prototype.success=0,e.prototype.elapse=u.Long?u.Long.fromBits(0,0,!1):0,e.prototype.peer=u.Long?u.Long.fromBits(0,0,!1):0,e.prototype.appid="",e.prototype.uname="",e.prototype.ver="",e.prototype.dk="",e.prototype.details="",e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=l.create()),null!=e.lts&&Object.hasOwnProperty.call(e,"lts")&&t.uint32(8).int64(e.lts),null!=e.sid&&Object.hasOwnProperty.call(e,"sid")&&t.uint32(18).string(e.sid),null!=e.cname&&Object.hasOwnProperty.call(e,"cname")&&t.uint32(26).string(e.cname),null!=e.cid&&Object.hasOwnProperty.call(e,"cid")&&t.uint32(32).int64(e.cid),null!=e.ip&&Object.hasOwnProperty.call(e,"ip")&&t.uint32(42).string(e.ip),null!=e.uid&&Object.hasOwnProperty.call(e,"uid")&&t.uint32(50).string(e.uid),null!=e.success&&Object.hasOwnProperty.call(e,"success")&&t.uint32(56).int32(e.success),null!=e.elapse&&Object.hasOwnProperty.call(e,"elapse")&&t.uint32(64).int64(e.elapse),null!=e.peer&&Object.hasOwnProperty.call(e,"peer")&&t.uint32(72).int64(e.peer),null!=e.appid&&Object.hasOwnProperty.call(e,"appid")&&t.uint32(82).string(e.appid),null!=e.uname&&Object.hasOwnProperty.call(e,"uname")&&t.uint32(90).string(e.uname),null!=e.ver&&Object.hasOwnProperty.call(e,"ver")&&t.uint32(98).string(e.ver),null!=e.dk&&Object.hasOwnProperty.call(e,"dk")&&t.uint32(106).string(e.dk),null!=e.details&&Object.hasOwnProperty.call(e,"details")&&t.uint32(114).string(e.details),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e}(),o.Subscribe=function(){function e(e){if(e)for(var t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.lts=u.Long?u.Long.fromBits(0,0,!1):0,e.prototype.sid="",e.prototype.cname="",e.prototype.cid=u.Long?u.Long.fromBits(0,0,!1):0,e.prototype.ip="",e.prototype.uid="",e.prototype.success=0,e.prototype.elapse=u.Long?u.Long.fromBits(0,0,!1):0,e.prototype.peer=u.Long?u.Long.fromBits(0,0,!1):0,e.prototype.ec="",e.prototype.pullurl="",e.prototype.peerid="",e.prototype.details="",e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=l.create()),null!=e.lts&&Object.hasOwnProperty.call(e,"lts")&&t.uint32(8).int64(e.lts),null!=e.sid&&Object.hasOwnProperty.call(e,"sid")&&t.uint32(18).string(e.sid),null!=e.cname&&Object.hasOwnProperty.call(e,"cname")&&t.uint32(26).string(e.cname),null!=e.cid&&Object.hasOwnProperty.call(e,"cid")&&t.uint32(32).int64(e.cid),null!=e.ip&&Object.hasOwnProperty.call(e,"ip")&&t.uint32(42).string(e.ip),null!=e.uid&&Object.hasOwnProperty.call(e,"uid")&&t.uint32(50).string(e.uid),null!=e.success&&Object.hasOwnProperty.call(e,"success")&&t.uint32(56).int32(e.success),null!=e.elapse&&Object.hasOwnProperty.call(e,"elapse")&&t.uint32(64).int64(e.elapse),null!=e.peer&&Object.hasOwnProperty.call(e,"peer")&&t.uint32(72).int64(e.peer),null!=e.ec&&Object.hasOwnProperty.call(e,"ec")&&t.uint32(82).string(e.ec),null!=e.pullurl&&Object.hasOwnProperty.call(e,"pullurl")&&t.uint32(90).string(e.pullurl),null!=e.peerid&&Object.hasOwnProperty.call(e,"peerid")&&t.uint32(98).string(e.peerid),null!=e.details&&Object.hasOwnProperty.call(e,"details")&&t.uint32(106).string(e.details),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e}(),o.Unpublish=function(){function e(e){if(e)for(var t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.lts=u.Long?u.Long.fromBits(0,0,!1):0,e.prototype.sid="",e.prototype.cname="",e.prototype.cid=u.Long?u.Long.fromBits(0,0,!1):0,e.prototype.ip="",e.prototype.uid="",e.prototype.success=0,e.prototype.elapse=u.Long?u.Long.fromBits(0,0,!1):0,e.prototype.peer=u.Long?u.Long.fromBits(0,0,!1):0,e.prototype.ec="",e.prototype.details="",e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=l.create()),null!=e.lts&&Object.hasOwnProperty.call(e,"lts")&&t.uint32(8).int64(e.lts),null!=e.sid&&Object.hasOwnProperty.call(e,"sid")&&t.uint32(18).string(e.sid),null!=e.cname&&Object.hasOwnProperty.call(e,"cname")&&t.uint32(26).string(e.cname),null!=e.cid&&Object.hasOwnProperty.call(e,"cid")&&t.uint32(32).int64(e.cid),null!=e.ip&&Object.hasOwnProperty.call(e,"ip")&&t.uint32(42).string(e.ip),null!=e.uid&&Object.hasOwnProperty.call(e,"uid")&&t.uint32(50).string(e.uid),null!=e.success&&Object.hasOwnProperty.call(e,"success")&&t.uint32(56).int32(e.success),null!=e.elapse&&Object.hasOwnProperty.call(e,"elapse")&&t.uint32(64).int64(e.elapse),null!=e.peer&&Object.hasOwnProperty.call(e,"peer")&&t.uint32(72).int64(e.peer),null!=e.ec&&Object.hasOwnProperty.call(e,"ec")&&t.uint32(82).string(e.ec),null!=e.details&&Object.hasOwnProperty.call(e,"details")&&t.uint32(98).string(e.details),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e}(),o.Unsubscribe=function(){function e(e){if(e)for(var t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.lts=u.Long?u.Long.fromBits(0,0,!1):0,e.prototype.sid="",e.prototype.cname="",e.prototype.cid=u.Long?u.Long.fromBits(0,0,!1):0,e.prototype.ip="",e.prototype.uid="",e.prototype.success=0,e.prototype.elapse=u.Long?u.Long.fromBits(0,0,!1):0,e.prototype.peer=u.Long?u.Long.fromBits(0,0,!1):0,e.prototype.ec="",e.prototype.peerid="",e.prototype.details="",e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=l.create()),null!=e.lts&&Object.hasOwnProperty.call(e,"lts")&&t.uint32(8).int64(e.lts),null!=e.sid&&Object.hasOwnProperty.call(e,"sid")&&t.uint32(18).string(e.sid),null!=e.cname&&Object.hasOwnProperty.call(e,"cname")&&t.uint32(26).string(e.cname),null!=e.cid&&Object.hasOwnProperty.call(e,"cid")&&t.uint32(32).int64(e.cid),null!=e.ip&&Object.hasOwnProperty.call(e,"ip")&&t.uint32(42).string(e.ip),null!=e.uid&&Object.hasOwnProperty.call(e,"uid")&&t.uint32(50).string(e.uid),null!=e.success&&Object.hasOwnProperty.call(e,"success")&&t.uint32(56).int32(e.success),null!=e.elapse&&Object.hasOwnProperty.call(e,"elapse")&&t.uint32(64).int64(e.elapse),null!=e.peer&&Object.hasOwnProperty.call(e,"peer")&&t.uint32(72).int64(e.peer),null!=e.ec&&Object.hasOwnProperty.call(e,"ec")&&t.uint32(82).string(e.ec),null!=e.peerid&&Object.hasOwnProperty.call(e,"peerid")&&t.uint32(90).string(e.peerid),null!=e.details&&Object.hasOwnProperty.call(e,"details")&&t.uint32(98).string(e.details),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e}(),o.SetRemoteVideoStreamType=function(){function e(e){if(e)for(var t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.lts=u.Long?u.Long.fromBits(0,0,!1):0,e.prototype.vid=u.Long?u.Long.fromBits(0,0,!1):0,e.prototype.sid="",e.prototype.cname="",e.prototype.cid=u.Long?u.Long.fromBits(0,0,!1):0,e.prototype.ip="",e.prototype.uid="",e.prototype.success=0,e.prototype.elapse=u.Long?u.Long.fromBits(0,0,!1):0,e.prototype.ec="",e.prototype.type=0,e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=l.create()),null!=e.lts&&Object.hasOwnProperty.call(e,"lts")&&t.uint32(8).int64(e.lts),null!=e.vid&&Object.hasOwnProperty.call(e,"vid")&&t.uint32(16).int64(e.vid),null!=e.sid&&Object.hasOwnProperty.call(e,"sid")&&t.uint32(26).string(e.sid),null!=e.cname&&Object.hasOwnProperty.call(e,"cname")&&t.uint32(34).string(e.cname),null!=e.cid&&Object.hasOwnProperty.call(e,"cid")&&t.uint32(40).int64(e.cid),null!=e.ip&&Object.hasOwnProperty.call(e,"ip")&&t.uint32(50).string(e.ip),null!=e.uid&&Object.hasOwnProperty.call(e,"uid")&&t.uint32(58).string(e.uid),null!=e.success&&Object.hasOwnProperty.call(e,"success")&&t.uint32(64).int32(e.success),null!=e.elapse&&Object.hasOwnProperty.call(e,"elapse")&&t.uint32(72).int64(e.elapse),null!=e.ec&&Object.hasOwnProperty.call(e,"ec")&&t.uint32(82).string(e.ec),null!=e.type&&Object.hasOwnProperty.call(e,"type")&&t.uint32(88).int32(e.type),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e}(),o.RenewToken=function(){function e(e){if(e)for(var t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.lts=u.Long?u.Long.fromBits(0,0,!1):0,e.prototype.vid=u.Long?u.Long.fromBits(0,0,!1):0,e.prototype.sid="",e.prototype.cname="",e.prototype.cid=u.Long?u.Long.fromBits(0,0,!1):0,e.prototype.ip="",e.prototype.uid="",e.prototype.success=0,e.prototype.elapse=u.Long?u.Long.fromBits(0,0,!1):0,e.prototype.ec="",e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=l.create()),null!=e.lts&&Object.hasOwnProperty.call(e,"lts")&&t.uint32(8).int64(e.lts),null!=e.vid&&Object.hasOwnProperty.call(e,"vid")&&t.uint32(16).int64(e.vid),null!=e.sid&&Object.hasOwnProperty.call(e,"sid")&&t.uint32(26).string(e.sid),null!=e.cname&&Object.hasOwnProperty.call(e,"cname")&&t.uint32(34).string(e.cname),null!=e.cid&&Object.hasOwnProperty.call(e,"cid")&&t.uint32(40).int64(e.cid),null!=e.ip&&Object.hasOwnProperty.call(e,"ip")&&t.uint32(50).string(e.ip),null!=e.uid&&Object.hasOwnProperty.call(e,"uid")&&t.uint32(58).string(e.uid),null!=e.success&&Object.hasOwnProperty.call(e,"success")&&t.uint32(64).int32(e.success),null!=e.elapse&&Object.hasOwnProperty.call(e,"elapse")&&t.uint32(72).int64(e.elapse),null!=e.ec&&Object.hasOwnProperty.call(e,"ec")&&t.uint32(82).string(e.ec),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e}(),o.SetRole=function(){function e(e){if(e)for(var t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.lts=u.Long?u.Long.fromBits(0,0,!1):0,e.prototype.vid=u.Long?u.Long.fromBits(0,0,!1):0,e.prototype.sid="",e.prototype.cname="",e.prototype.cid=u.Long?u.Long.fromBits(0,0,!1):0,e.prototype.ip="",e.prototype.uid="",e.prototype.success=0,e.prototype.elapse=u.Long?u.Long.fromBits(0,0,!1):0,e.prototype.ec="",e.prototype.role=0,e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=l.create()),null!=e.lts&&Object.hasOwnProperty.call(e,"lts")&&t.uint32(8).int64(e.lts),null!=e.vid&&Object.hasOwnProperty.call(e,"vid")&&t.uint32(16).int64(e.vid),null!=e.sid&&Object.hasOwnProperty.call(e,"sid")&&t.uint32(26).string(e.sid),null!=e.cname&&Object.hasOwnProperty.call(e,"cname")&&t.uint32(34).string(e.cname),null!=e.cid&&Object.hasOwnProperty.call(e,"cid")&&t.uint32(40).int64(e.cid),null!=e.ip&&Object.hasOwnProperty.call(e,"ip")&&t.uint32(50).string(e.ip),null!=e.uid&&Object.hasOwnProperty.call(e,"uid")&&t.uint32(58).string(e.uid),null!=e.success&&Object.hasOwnProperty.call(e,"success")&&t.uint32(64).int32(e.success),null!=e.elapse&&Object.hasOwnProperty.call(e,"elapse")&&t.uint32(72).int64(e.elapse),null!=e.ec&&Object.hasOwnProperty.call(e,"ec")&&t.uint32(82).string(e.ec),null!=e.role&&Object.hasOwnProperty.call(e,"role")&&t.uint32(88).int32(e.role),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e}(),o),s),a),e.exports=p},446:(e,t,n)=>{"use strict";n.r(t),n.d(t,{DOMAIN_NAME:()=>o,SDK_VERSION:()=>i,VERSION:()=>r});var r="1.1.0",i="2.6.4",o="mini-app.broadcastapp.agoraio.cn"},426:(e,t,n)=>{"use strict";n.r(t),n.d(t,{generateSessionId:()=>s,is32Uint:()=>l,isWeiXin:()=>c,random:()=>o,shouldUseHttps:()=>a});var r=n(171),i=n.n(r),o=function(e){isNaN(e)&&(e=1e3);var t=+new Date,n=(t=(9301*t+49297)%233280)/233280;return Math.ceil(n*e)},s=function(){return i()().replace(/-/g,"").toUpperCase()},a=function(){return"https:"==document.location.protocol},c=function(){try{return wx,!0}catch(e){return!1}},l=function(e){return!!(0<=e&&e<=4294967295)}},186:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>u});var r=n(861),i=n(671),o=n(144),s=n(687),a=n.n(s),c=(n(568),n(446)),l=function(){function e(t){var n=t.appId,r=t.content,o=t.ts;(0,i.Z)(this,e),this.appId=n,this.content=r,this.ts=o}return(0,o.Z)(e,[{key:"upload",value:function(){var e=this;return new Promise((function(t,n){wx.request({url:"https://report-ad.agoralab.co/v1/log/report",method:"post",data:{data:e.content,appId:e.appId,ts:e.ts,src:"miniapp",version:c.SDK_VERSION},success:function(){t()},fail:function(e){n(e)}})}))}}]),e}();const u=new(function(){function e(){(0,i.Z)(this,e),this.level=3,this.onLog=null,this.logItems=[],this.appId="",this.sid=""}return(0,o.Z)(e,[{key:"setOptions",value:function(e){var t=e.appId,n=void 0===t?"":t,r=e.sid,i=void 0===r?"":r;this.appId=n,this.sid=i}},{key:"setLogLevel",value:function(e){if("number"!=typeof e||!(e<=4&&e>=-1))throw Error("Invalid level");this.level=e}},{key:"_storeLog",value:function(e){this.logItems.push({msg:e,sid:this.sid}),this.logItems.length>5e4&&this.logItems.shift()}},{key:"_log",value:function(){for(var e="",t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];for(var i=0,o=n;i<o.length;i++){var s=o[i];e+="string"==typeof s?s:JSON.stringify(s)}this.onLog&&this.onLog(e),this._storeLog(e),console.log(e)}},{key:"_err",value:function(){for(var e="",t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];for(var i=0,o=n;i<o.length;i++){var s=o[i];e+="string"==typeof s?s:JSON.stringify(s)}this.onLog&&this.onLog(e),this._storeLog(e),console.error(e)}},{key:"uploadLogs",value:function(e,t){var n=this;return new Promise(function(){var i=(0,r.Z)(a().mark((function r(i,o){var s,c,u,p;return a().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(n.appId&&"string"==typeof n.appId){r.next=6;break}return s=new Error("uploadLogs before client init"),n.error("uploadLogs failed: ".concat(s.message)),t&&t(s),o(s),r.abrupt("return");case 6:if(n.sid&&"string"==typeof n.sid){r.next=12;break}return c=new Error("uploadLogs before client init"),n.error("uploadLogs failed: ".concat(c.message)),t&&t(c),o(c),r.abrupt("return");case 12:for(u=[];n.logItems.length;)p=n.logItems.splice(0,500),u.push(new l({appId:n.appId,content:p,ts:(new Date).getTime()}));Promise.all(u.map((function(e){return e.upload()}))).then((function(t){n.debug("uploadLogs success"),e&&e(),i()}),(function(e){var r=(null==e?void 0:e.errMsg)||(null==e?void 0:e.message)||e;n.error("uploadLogs failed: ".concat(r)),t&&t(e),o(e)}));case 15:case"end":return r.stop()}}),r)})));return function(e,t){return i.apply(this,arguments)}}())}},{key:"blind",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.level<=-1&&this._log.apply(this,["".concat(new Date,"[BLIND]: ")].concat(t))}},{key:"debug",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.level<=0&&this._log.apply(this,["".concat(new Date,"[DEBUG]: ")].concat(t))}},{key:"info",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.level<=1&&this._log.apply(this,["".concat(new Date,"[INFO]: ")].concat(t))}},{key:"warn",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.level<=2&&this._log.apply(this,["".concat(new Date,"[WARN]: ")].concat(t))}},{key:"error",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.level<=3&&this._err.apply(this,["".concat(new Date,"[ERROR]: ")].concat(t))}}]),e}())},483:(e,t,n)=>{"use strict";n.r(t),n.d(t,{checkValidBoolean:()=>l,checkValidEnum:()=>i,checkValidFloatNumber:()=>c,checkValidNumber:()=>a,checkValidObject:()=>o,checkValidString:()=>s,getServerUrlIp:()=>b,isASCII:()=>_,isArray:()=>w,isEmpty:()=>O,isInteger:()=>g,isNumber:()=>v,isString:()=>m,isValidBoolean:()=>d,isValidChannelName:()=>y,isValidNumber:()=>p,isValidString:()=>u,isValidToken:()=>f,stringifyErr:()=>E,throttle:()=>S,transformElapseStr:()=>R});var r=n(2),i=function(e,t,n){for(var r=0;r<n.length;r++)if(e===n[r])return!0;throw new Error("".concat(t," can only be set as ").concat(JSON.stringify(n)))},o=function(e,t){if(!e)throw new Error("Invalid param: ".concat(t||"param"," cannot be empty"));if("object"!==(0,r.Z)(e))throw new Error("".concat(t||"This paramter"," is of the object type"));return!0},s=function(e,t,n,r,i){if(O(n)&&(n=1),r=r||255,O(i)&&(i=!0),O(e))throw new Error("".concat(t||"param"," cannot be empty"));if(!u(e,n,r,i))throw new Error("Invalid ".concat(t||"string param",": Length of the string: [").concat(n,",").concat(r,"].").concat(i?" ASCII characters only.":""))},a=function(e,t,n,r){if(O(n)&&(n=1),r=r||1e4,O(e))throw new Error("".concat(t||"param"," cannot be empty"));if(!p(e,n,r))throw new Error("Invalid ".concat(t||"number param",": The value range is [").concat(n,",").concat(r,"]. integer only"))},c=function(e,t,n,r){if(null==e)throw new Error("".concat(t||"param"," cannot be null"));if(O(n)&&(n=0),r=r||1e4,O(e))throw new Error("".concat(t||"param"," cannot be empty"));if(!h(e,n,r))throw new Error("Invalid ".concat(t||"number param",": The value range is [").concat(n,",").concat(r,"]."))},l=function(e,t){if(O(e))throw new Error("".concat(t||"param"," cannot be empty"));if(!d(e))throw new Error("Invalid ".concat(t||"boolean param",": The value is of the boolean type."))},u=function(e,t,n,r){return t||(t=0),n||(n=Number.MAX_SAFE_INTEGER),O(r)&&(r=!0),m(e)&&(!r||_(e))&&e.length>=t&&e.length<=n},p=function(e,t,n){return g(e)&&e>=t&&e<=n},h=function(e,t,n){return v(e)&&e>=t&&e<=n},d=function(e){return"boolean"==typeof e},f=function(e){return u(e,1,2047)},y=function(e){return m(e)&&/^[a-zA-Z0-9 \!\#\$\%\&\(\)\+\-\:\;\<\=\.\>\?\@\[\]\^\_\{\}\|\~\,]{1,64}$/.test(e)},_=function(e){if("string"==typeof e){for(var t=0;t<e.length;t++){var n=e.charCodeAt(t);if(n<0||n>255)return!1}return!0}},g=function(e){return"number"==typeof e&&e%1==0},v=function(e){return"number"==typeof e},m=function(e){return"string"==typeof e},w=function(e){return e instanceof Array},O=function(e){return null==e},E=function(e){return e instanceof Error||e.message?e.message:JSON.stringify(e)},b=function(e){var t=/wss:\/\/miniapp.agoraio.cn\/(\S+)\/api/g.exec(e);return t instanceof Array&&t[1]||""},R=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return(e=Number(e))<=0?"<0ms":e>0&&e<=50?"0~50ms":e>50&&e<=100?"50~100ms":e>100&&e<=200?"100~200ms":e>200&&e<=300?"200~300ms":e>300&&e<=500?"300~500ms":e>500&&e<=800?"500~800ms":e>800&&e<=1e3?"800~1000ms":e>1e3&&e<=1500?"1~1.5s":e>1500&&e<=2e3?"1.5~2s":e>2e3&&e<=3e3?"2~3s":e>3e3&&e<=5e3?"3~5s":e>5e3&&e<=8e3?"5~8s":e>8e3&&e<=1e4?"8~10s":">10s"},S=function(e){var t,n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return function(){for(var i=arguments.length,o=new Array(i),s=0;s<i;s++)o[s]=arguments[s];var a=+new Date;t&&a<t+r?(clearTimeout(n),n=setTimeout((function(){t=a,e.apply(void 0,o)}),r)):(t=a,e.apply(void 0,o))}}},487:e=>{var t={utf8:{stringToBytes:function(e){return t.bin.stringToBytes(unescape(encodeURIComponent(e)))},bytesToString:function(e){return decodeURIComponent(escape(t.bin.bytesToString(e)))}},bin:{stringToBytes:function(e){for(var t=[],n=0;n<e.length;n++)t.push(255&e.charCodeAt(n));return t},bytesToString:function(e){for(var t=[],n=0;n<e.length;n++)t.push(String.fromCharCode(e[n]));return t.join("")}}};e.exports=t},12:e=>{var t,n;t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",n={rotl:function(e,t){return e<<t|e>>>32-t},rotr:function(e,t){return e<<32-t|e>>>t},endian:function(e){if(e.constructor==Number)return 16711935&n.rotl(e,8)|4278255360&n.rotl(e,24);for(var t=0;t<e.length;t++)e[t]=n.endian(e[t]);return e},randomBytes:function(e){for(var t=[];e>0;e--)t.push(Math.floor(256*Math.random()));return t},bytesToWords:function(e){for(var t=[],n=0,r=0;n<e.length;n++,r+=8)t[r>>>5]|=e[n]<<24-r%32;return t},wordsToBytes:function(e){for(var t=[],n=0;n<32*e.length;n+=8)t.push(e[n>>>5]>>>24-n%32&255);return t},bytesToHex:function(e){for(var t=[],n=0;n<e.length;n++)t.push((e[n]>>>4).toString(16)),t.push((15&e[n]).toString(16));return t.join("")},hexToBytes:function(e){for(var t=[],n=0;n<e.length;n+=2)t.push(parseInt(e.substr(n,2),16));return t},bytesToBase64:function(e){for(var n=[],r=0;r<e.length;r+=3)for(var i=e[r]<<16|e[r+1]<<8|e[r+2],o=0;o<4;o++)8*r+6*o<=8*e.length?n.push(t.charAt(i>>>6*(3-o)&63)):n.push("=");return n.join("")},base64ToBytes:function(e){e=e.replace(/[^A-Z0-9+\/]/gi,"");for(var n=[],r=0,i=0;r<e.length;i=++r%4)0!=i&&n.push((t.indexOf(e.charAt(r-1))&Math.pow(2,-2*i+8)-1)<<2*i|t.indexOf(e.charAt(r))>>>6-2*i);return n}},e.exports=n},738:e=>{function t(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}e.exports=function(e){return null!=e&&(t(e)||function(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&t(e.slice(0,0))}(e)||!!e._isBuffer)}},568:(e,t,n)=>{var r,i,o,s,a;r=n(12),i=n(487).utf8,o=n(738),s=n(487).bin,(a=function(e,t){e.constructor==String?e=t&&"binary"===t.encoding?s.stringToBytes(e):i.stringToBytes(e):o(e)?e=Array.prototype.slice.call(e,0):Array.isArray(e)||e.constructor===Uint8Array||(e=e.toString());for(var n=r.bytesToWords(e),c=8*e.length,l=1732584193,u=-271733879,p=-1732584194,h=271733878,d=0;d<n.length;d++)n[d]=16711935&(n[d]<<8|n[d]>>>24)|4278255360&(n[d]<<24|n[d]>>>8);n[c>>>5]|=128<<c%32,n[14+(c+64>>>9<<4)]=c;var f=a._ff,y=a._gg,_=a._hh,g=a._ii;for(d=0;d<n.length;d+=16){var v=l,m=u,w=p,O=h;l=f(l,u,p,h,n[d+0],7,-680876936),h=f(h,l,u,p,n[d+1],12,-389564586),p=f(p,h,l,u,n[d+2],17,606105819),u=f(u,p,h,l,n[d+3],22,-1044525330),l=f(l,u,p,h,n[d+4],7,-176418897),h=f(h,l,u,p,n[d+5],12,1200080426),p=f(p,h,l,u,n[d+6],17,-1473231341),u=f(u,p,h,l,n[d+7],22,-45705983),l=f(l,u,p,h,n[d+8],7,1770035416),h=f(h,l,u,p,n[d+9],12,-1958414417),p=f(p,h,l,u,n[d+10],17,-42063),u=f(u,p,h,l,n[d+11],22,-1990404162),l=f(l,u,p,h,n[d+12],7,1804603682),h=f(h,l,u,p,n[d+13],12,-40341101),p=f(p,h,l,u,n[d+14],17,-1502002290),l=y(l,u=f(u,p,h,l,n[d+15],22,1236535329),p,h,n[d+1],5,-165796510),h=y(h,l,u,p,n[d+6],9,-1069501632),p=y(p,h,l,u,n[d+11],14,643717713),u=y(u,p,h,l,n[d+0],20,-373897302),l=y(l,u,p,h,n[d+5],5,-701558691),h=y(h,l,u,p,n[d+10],9,38016083),p=y(p,h,l,u,n[d+15],14,-660478335),u=y(u,p,h,l,n[d+4],20,-405537848),l=y(l,u,p,h,n[d+9],5,568446438),h=y(h,l,u,p,n[d+14],9,-1019803690),p=y(p,h,l,u,n[d+3],14,-187363961),u=y(u,p,h,l,n[d+8],20,1163531501),l=y(l,u,p,h,n[d+13],5,-1444681467),h=y(h,l,u,p,n[d+2],9,-51403784),p=y(p,h,l,u,n[d+7],14,1735328473),l=_(l,u=y(u,p,h,l,n[d+12],20,-1926607734),p,h,n[d+5],4,-378558),h=_(h,l,u,p,n[d+8],11,-2022574463),p=_(p,h,l,u,n[d+11],16,1839030562),u=_(u,p,h,l,n[d+14],23,-35309556),l=_(l,u,p,h,n[d+1],4,-1530992060),h=_(h,l,u,p,n[d+4],11,1272893353),p=_(p,h,l,u,n[d+7],16,-155497632),u=_(u,p,h,l,n[d+10],23,-1094730640),l=_(l,u,p,h,n[d+13],4,681279174),h=_(h,l,u,p,n[d+0],11,-358537222),p=_(p,h,l,u,n[d+3],16,-722521979),u=_(u,p,h,l,n[d+6],23,76029189),l=_(l,u,p,h,n[d+9],4,-640364487),h=_(h,l,u,p,n[d+12],11,-421815835),p=_(p,h,l,u,n[d+15],16,530742520),l=g(l,u=_(u,p,h,l,n[d+2],23,-995338651),p,h,n[d+0],6,-198630844),h=g(h,l,u,p,n[d+7],10,1126891415),p=g(p,h,l,u,n[d+14],15,-1416354905),u=g(u,p,h,l,n[d+5],21,-57434055),l=g(l,u,p,h,n[d+12],6,1700485571),h=g(h,l,u,p,n[d+3],10,-1894986606),p=g(p,h,l,u,n[d+10],15,-1051523),u=g(u,p,h,l,n[d+1],21,-2054922799),l=g(l,u,p,h,n[d+8],6,1873313359),h=g(h,l,u,p,n[d+15],10,-30611744),p=g(p,h,l,u,n[d+6],15,-1560198380),u=g(u,p,h,l,n[d+13],21,1309151649),l=g(l,u,p,h,n[d+4],6,-145523070),h=g(h,l,u,p,n[d+11],10,-1120210379),p=g(p,h,l,u,n[d+2],15,718787259),u=g(u,p,h,l,n[d+9],21,-343485551),l=l+v>>>0,u=u+m>>>0,p=p+w>>>0,h=h+O>>>0}return r.endian([l,u,p,h])})._ff=function(e,t,n,r,i,o,s){var a=e+(t&n|~t&r)+(i>>>0)+s;return(a<<o|a>>>32-o)+t},a._gg=function(e,t,n,r,i,o,s){var a=e+(t&r|n&~r)+(i>>>0)+s;return(a<<o|a>>>32-o)+t},a._hh=function(e,t,n,r,i,o,s){var a=e+(t^n^r)+(i>>>0)+s;return(a<<o|a>>>32-o)+t},a._ii=function(e,t,n,r,i,o,s){var a=e+(n^(t|~r))+(i>>>0)+s;return(a<<o|a>>>32-o)+t},a._blocksize=16,a._digestsize=16,e.exports=function(e,t){if(null==e)throw new Error("Illegal argument "+e);var n=r.wordsToBytes(a(e,t));return t&&t.asBytes?n:t&&t.asString?s.bytesToString(n):r.bytesToHex(n)}},100:(e,t,n)=>{"use strict";e.exports=n(482)},482:(e,t,n)=>{"use strict";var r=t;function i(){r.util._configure(),r.Writer._configure(r.BufferWriter),r.Reader._configure(r.BufferReader)}r.build="minimal",r.Writer=n(173),r.BufferWriter=n(155),r.Reader=n(408),r.BufferReader=n(593),r.util=n(693),r.rpc=n(994),r.roots=n(54),r.configure=i,i()},408:(e,t,n)=>{"use strict";e.exports=c;var r,i=n(693),o=i.LongBits,s=i.utf8;function a(e,t){return RangeError("index out of range: "+e.pos+" + "+(t||1)+" > "+e.len)}function c(e){this.buf=e,this.pos=0,this.len=e.length}var l,u="undefined"!=typeof Uint8Array?function(e){if(e instanceof Uint8Array||Array.isArray(e))return new c(e);throw Error("illegal buffer")}:function(e){if(Array.isArray(e))return new c(e);throw Error("illegal buffer")},p=function(){return i.Buffer?function(e){return(c.create=function(e){return i.Buffer.isBuffer(e)?new r(e):u(e)})(e)}:u};function h(){var e=new o(0,0),t=0;if(!(this.len-this.pos>4)){for(;t<3;++t){if(this.pos>=this.len)throw a(this);if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(127&this.buf[this.pos++])<<7*t)>>>0,e}for(;t<4;++t)if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)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,this.buf[this.pos++]<128)return e;if(t=0,this.len-this.pos>4){for(;t<5;++t)if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}else for(;t<5;++t){if(this.pos>=this.len)throw a(this);if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}function d(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}function f(){if(this.pos+8>this.len)throw a(this,8);return new o(d(this.buf,this.pos+=4),d(this.buf,this.pos+=4))}c.create=p(),c.prototype._slice=i.Array.prototype.subarray||i.Array.prototype.slice,c.prototype.uint32=(l=4294967295,function(){if(l=(127&this.buf[this.pos])>>>0,this.buf[this.pos++]<128)return l;if(l=(l|(127&this.buf[this.pos])<<7)>>>0,this.buf[this.pos++]<128)return l;if(l=(l|(127&this.buf[this.pos])<<14)>>>0,this.buf[this.pos++]<128)return l;if(l=(l|(127&this.buf[this.pos])<<21)>>>0,this.buf[this.pos++]<128)return l;if(l=(l|(15&this.buf[this.pos])<<28)>>>0,this.buf[this.pos++]<128)return l;if((this.pos+=5)>this.len)throw this.pos=this.len,a(this,10);return l}),c.prototype.int32=function(){return 0|this.uint32()},c.prototype.sint32=function(){var e=this.uint32();return e>>>1^-(1&e)|0},c.prototype.bool=function(){return 0!==this.uint32()},c.prototype.fixed32=function(){if(this.pos+4>this.len)throw a(this,4);return d(this.buf,this.pos+=4)},c.prototype.sfixed32=function(){if(this.pos+4>this.len)throw a(this,4);return 0|d(this.buf,this.pos+=4)},c.prototype.float=function(){if(this.pos+4>this.len)throw a(this,4);var e=i.float.readFloatLE(this.buf,this.pos);return this.pos+=4,e},c.prototype.double=function(){if(this.pos+8>this.len)throw a(this,4);var e=i.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,e},c.prototype.bytes=function(){var e=this.uint32(),t=this.pos,n=this.pos+e;if(n>this.len)throw a(this,e);return this.pos+=e,Array.isArray(this.buf)?this.buf.slice(t,n):t===n?new this.buf.constructor(0):this._slice.call(this.buf,t,n)},c.prototype.string=function(){var e=this.bytes();return s.read(e,0,e.length)},c.prototype.skip=function(e){if("number"==typeof e){if(this.pos+e>this.len)throw a(this,e);this.pos+=e}else do{if(this.pos>=this.len)throw a(this)}while(128&this.buf[this.pos++]);return this},c.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},c._configure=function(e){r=e,c.create=p(),r._configure();var t=i.Long?"toLong":"toNumber";i.merge(c.prototype,{int64:function(){return h.call(this)[t](!1)},uint64:function(){return h.call(this)[t](!0)},sint64:function(){return h.call(this).zzDecode()[t](!1)},fixed64:function(){return f.call(this)[t](!0)},sfixed64:function(){return f.call(this)[t](!1)}})}},593:(e,t,n)=>{"use strict";e.exports=o;var r=n(408);(o.prototype=Object.create(r.prototype)).constructor=o;var i=n(693);function o(e){r.call(this,e)}o._configure=function(){i.Buffer&&(o.prototype._slice=i.Buffer.prototype.slice)},o.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))},o._configure()},54:e=>{"use strict";e.exports={}},994:(e,t,n)=>{"use strict";t.Service=n(948)},948:(e,t,n)=>{"use strict";e.exports=i;var r=n(693);function i(e,t,n){if("function"!=typeof e)throw TypeError("rpcImpl must be a function");r.EventEmitter.call(this),this.rpcImpl=e,this.requestDelimited=Boolean(t),this.responseDelimited=Boolean(n)}(i.prototype=Object.create(r.EventEmitter.prototype)).constructor=i,i.prototype.rpcCall=function e(t,n,i,o,s){if(!o)throw TypeError("request must be specified");var a=this;if(!s)return r.asPromise(e,a,t,n,i,o);if(a.rpcImpl)try{return a.rpcImpl(t,n[a.requestDelimited?"encodeDelimited":"encode"](o).finish(),(function(e,n){if(e)return a.emit("error",e,t),s(e);if(null!==n){if(!(n instanceof i))try{n=i[a.responseDelimited?"decodeDelimited":"decode"](n)}catch(e){return a.emit("error",e,t),s(e)}return a.emit("data",n,t),s(null,n)}a.end(!0)}))}catch(e){return a.emit("error",e,t),void setTimeout((function(){s(e)}),0)}else setTimeout((function(){s(Error("already ended"))}),0)},i.prototype.end=function(e){return this.rpcImpl&&(e||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this}},630:(e,t,n)=>{"use strict";e.exports=i;var r=n(693);function i(e,t){this.lo=e>>>0,this.hi=t>>>0}var o=i.zero=new i(0,0);o.toNumber=function(){return 0},o.zzEncode=o.zzDecode=function(){return this},o.length=function(){return 1};var s=i.zeroHash="\0\0\0\0\0\0\0\0";i.fromNumber=function(e){if(0===e)return o;var t=e<0;t&&(e=-e);var n=e>>>0,r=(e-n)/4294967296>>>0;return t&&(r=~r>>>0,n=~n>>>0,++n>4294967295&&(n=0,++r>4294967295&&(r=0))),new i(n,r)},i.from=function(e){if("number"==typeof e)return i.fromNumber(e);if(r.isString(e)){if(!r.Long)return i.fromNumber(parseInt(e,10));e=r.Long.fromString(e)}return e.low||e.high?new i(e.low>>>0,e.high>>>0):o},i.prototype.toNumber=function(e){if(!e&&this.hi>>>31){var t=1+~this.lo>>>0,n=~this.hi>>>0;return t||(n=n+1>>>0),-(t+4294967296*n)}return this.lo+4294967296*this.hi},i.prototype.toLong=function(e){return r.Long?new r.Long(0|this.lo,0|this.hi,Boolean(e)):{low:0|this.lo,high:0|this.hi,unsigned:Boolean(e)}};var a=String.prototype.charCodeAt;i.fromHash=function(e){return e===s?o:new i((a.call(e,0)|a.call(e,1)<<8|a.call(e,2)<<16|a.call(e,3)<<24)>>>0,(a.call(e,4)|a.call(e,5)<<8|a.call(e,6)<<16|a.call(e,7)<<24)>>>0)},i.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)},i.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},i.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},i.prototype.length=function(){var e=this.lo,t=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return 0===n?0===t?e<16384?e<128?1:2:e<2097152?3:4:t<16384?t<128?5:6:t<2097152?7:8:n<128?9:10}},693:function(e,t,n){"use strict";var r=t;function i(e,t,n){for(var r=Object.keys(t),i=0;i<r.length;++i)void 0!==e[r[i]]&&n||(e[r[i]]=t[r[i]]);return e}function o(e){function t(e,n){if(!(this instanceof t))return new t(e,n);Object.defineProperty(this,"message",{get:function(){return e}}),Error.captureStackTrace?Error.captureStackTrace(this,t):Object.defineProperty(this,"stack",{value:(new Error).stack||""}),n&&i(this,n)}return(t.prototype=Object.create(Error.prototype)).constructor=t,Object.defineProperty(t.prototype,"name",{get:function(){return e}}),t.prototype.toString=function(){return this.name+": "+this.message},t}r.asPromise=n(537),r.base64=n(419),r.EventEmitter=n(211),r.float=n(945),r.inquire=n(199),r.utf8=n(997),r.pool=n(662),r.LongBits=n(630),r.isNode=Boolean(void 0!==n.g&&n.g&&n.g.process&&n.g.process.versions&&n.g.process.versions.node),r.global=r.isNode&&n.g||"undefined"!=typeof window&&window||"undefined"!=typeof self&&self||this,r.emptyArray=Object.freeze?Object.freeze([]):[],r.emptyObject=Object.freeze?Object.freeze({}):{},r.isInteger=Number.isInteger||function(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e},r.isString=function(e){return"string"==typeof e||e instanceof String},r.isObject=function(e){return e&&"object"==typeof e},r.isset=r.isSet=function(e,t){var n=e[t];return!(null==n||!e.hasOwnProperty(t))&&("object"!=typeof n||(Array.isArray(n)?n.length:Object.keys(n).length)>0)},r.Buffer=function(){try{var e=r.inquire("buffer").Buffer;return e.prototype.utf8Write?e:null}catch(e){return null}}(),r._Buffer_from=null,r._Buffer_allocUnsafe=null,r.newBuffer=function(e){return"number"==typeof e?r.Buffer?r._Buffer_allocUnsafe(e):new r.Array(e):r.Buffer?r._Buffer_from(e):"undefined"==typeof Uint8Array?e:new Uint8Array(e)},r.Array="undefined"!=typeof Uint8Array?Uint8Array:Array,r.Long=r.global.dcodeIO&&r.global.dcodeIO.Long||r.global.Long||r.inquire("long"),r.key2Re=/^true|false|0|1$/,r.key32Re=/^-?(?:0|[1-9][0-9]*)$/,r.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/,r.longToHash=function(e){return e?r.LongBits.from(e).toHash():r.LongBits.zeroHash},r.longFromHash=function(e,t){var n=r.LongBits.fromHash(e);return r.Long?r.Long.fromBits(n.lo,n.hi,t):n.toNumber(Boolean(t))},r.merge=i,r.lcFirst=function(e){return e.charAt(0).toLowerCase()+e.substring(1)},r.newError=o,r.ProtocolError=o("ProtocolError"),r.oneOfGetter=function(e){for(var t={},n=0;n<e.length;++n)t[e[n]]=1;return function(){for(var e=Object.keys(this),n=e.length-1;n>-1;--n)if(1===t[e[n]]&&void 0!==this[e[n]]&&null!==this[e[n]])return e[n]}},r.oneOfSetter=function(e){return function(t){for(var n=0;n<e.length;++n)e[n]!==t&&delete this[e[n]]}},r.toJSONOptions={longs:String,enums:String,bytes:String,json:!0},r._configure=function(){var e=r.Buffer;e?(r._Buffer_from=e.from!==Uint8Array.from&&e.from||function(t,n){return new e(t,n)},r._Buffer_allocUnsafe=e.allocUnsafe||function(t){return new e(t)}):r._Buffer_from=r._Buffer_allocUnsafe=null}},173:(e,t,n)=>{"use strict";e.exports=p;var r,i=n(693),o=i.LongBits,s=i.base64,a=i.utf8;function c(e,t,n){this.fn=e,this.len=t,this.next=void 0,this.val=n}function l(){}function u(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}function p(){this.len=0,this.head=new c(l,0,0),this.tail=this.head,this.states=null}var h=function(){return i.Buffer?function(){return(p.create=function(){return new r})()}:function(){return new p}};function d(e,t,n){t[n]=255&e}function f(e,t){this.len=e,this.next=void 0,this.val=t}function y(e,t,n){for(;e.hi;)t[n++]=127&e.lo|128,e.lo=(e.lo>>>7|e.hi<<25)>>>0,e.hi>>>=7;for(;e.lo>127;)t[n++]=127&e.lo|128,e.lo=e.lo>>>7;t[n++]=e.lo}function _(e,t,n){t[n]=255&e,t[n+1]=e>>>8&255,t[n+2]=e>>>16&255,t[n+3]=e>>>24}p.create=h(),p.alloc=function(e){return new i.Array(e)},i.Array!==Array&&(p.alloc=i.pool(p.alloc,i.Array.prototype.subarray)),p.prototype._push=function(e,t,n){return this.tail=this.tail.next=new c(e,t,n),this.len+=t,this},f.prototype=Object.create(c.prototype),f.prototype.fn=function(e,t,n){for(;e>127;)t[n++]=127&e|128,e>>>=7;t[n]=e},p.prototype.uint32=function(e){return this.len+=(this.tail=this.tail.next=new f((e>>>=0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this},p.prototype.int32=function(e){return e<0?this._push(y,10,o.fromNumber(e)):this.uint32(e)},p.prototype.sint32=function(e){return this.uint32((e<<1^e>>31)>>>0)},p.prototype.uint64=function(e){var t=o.from(e);return this._push(y,t.length(),t)},p.prototype.int64=p.prototype.uint64,p.prototype.sint64=function(e){var t=o.from(e).zzEncode();return this._push(y,t.length(),t)},p.prototype.bool=function(e){return this._push(d,1,e?1:0)},p.prototype.fixed32=function(e){return this._push(_,4,e>>>0)},p.prototype.sfixed32=p.prototype.fixed32,p.prototype.fixed64=function(e){var t=o.from(e);return this._push(_,4,t.lo)._push(_,4,t.hi)},p.prototype.sfixed64=p.prototype.fixed64,p.prototype.float=function(e){return this._push(i.float.writeFloatLE,4,e)},p.prototype.double=function(e){return this._push(i.float.writeDoubleLE,8,e)};var g=i.Array.prototype.set?function(e,t,n){t.set(e,n)}:function(e,t,n){for(var r=0;r<e.length;++r)t[n+r]=e[r]};p.prototype.bytes=function(e){var t=e.length>>>0;if(!t)return this._push(d,1,0);if(i.isString(e)){var n=p.alloc(t=s.length(e));s.decode(e,n,0),e=n}return this.uint32(t)._push(g,t,e)},p.prototype.string=function(e){var t=a.length(e);return t?this.uint32(t)._push(a.write,t,e):this._push(d,1,0)},p.prototype.fork=function(){return this.states=new u(this),this.head=this.tail=new c(l,0,0),this.len=0,this},p.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 c(l,0,0),this.len=0),this},p.prototype.ldelim=function(){var e=this.head,t=this.tail,n=this.len;return this.reset().uint32(n),n&&(this.tail.next=e.next,this.tail=t,this.len+=n),this},p.prototype.finish=function(){for(var e=this.head.next,t=this.constructor.alloc(this.len),n=0;e;)e.fn(e.val,t,n),n+=e.len,e=e.next;return t},p._configure=function(e){r=e,p.create=h(),r._configure()}},155:(e,t,n)=>{"use strict";e.exports=o;var r=n(173);(o.prototype=Object.create(r.prototype)).constructor=o;var i=n(693);function o(){r.call(this)}function s(e,t,n){e.length<40?i.utf8.write(e,t,n):t.utf8Write?t.utf8Write(e,n):t.write(e,n)}o._configure=function(){o.alloc=i._Buffer_allocUnsafe,o.writeBytesBuffer=i.Buffer&&i.Buffer.prototype instanceof Uint8Array&&"set"===i.Buffer.prototype.set.name?function(e,t,n){t.set(e,n)}:function(e,t,n){if(e.copy)e.copy(t,n,0,e.length);else for(var r=0;r<e.length;)t[n++]=e[r++]}},o.prototype.bytes=function(e){i.isString(e)&&(e=i._Buffer_from(e,"base64"));var t=e.length>>>0;return this.uint32(t),t&&this._push(o.writeBytesBuffer,t,e),this},o.prototype.string=function(e){var t=i.Buffer.byteLength(e);return this.uint32(t),t&&this._push(s,t,e),this},o._configure()},500:function(e,t,n){"use strict";var r,i=this&&this.__extends||(r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},r(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},s=this&&this.__generator||function(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.CHANNEL_MEDIA_RELAY_ERROR=t.CHANNEL_MEDIA_RELAY_STATE=t.CHANNEL_MEDIA_RELAY_EVENT=t.CHANNEL_MEDIA_ERROR=t.ChannelMediaError=t.ChannelMediaRelayConfiguration=void 0;var c=a(n(795)),l=n(446),u=a(n(186)),p=n(483),h=n(426),d=function(){},f=function(e){function t(t,n){var r=e.call(this)||this;return r._state=m.RELAY_STATE_IDLE,r._onStatus=function(e){u.default.debug("[".concat(r.clientId,"] ChannelMediaStatus: ").concat(JSON.stringify(e))),e&&e.command&&("onAudioPacketReceived"===e.command&&r.emit("event",v.PACKET_RECEIVED_AUDIO_FROM_SRC),"onVideoPacketReceived"===e.command&&r.emit("event",v.PACKET_RECEIVED_VIDEO_FROM_SRC),"onSrcTokenPrivilegeDidExpire"===e.command&&(r._state=m.RELAY_STATE_FAILURE,r.emit("state",m.RELAY_STATE_FAILURE,w.SRC_TOKEN_EXPIRED)),"onDestTokenPrivilegeDidExpire"===e.command&&(r._state=m.RELAY_STATE_FAILURE,r.emit("state",m.RELAY_STATE_FAILURE,w.DEST_TOKEN_EXPIRED,e.channelName?{came:e.channelName}:null)))},r._onClose=function(){return o(r,void 0,void 0,(function(){var e;return s(this,(function(t){switch(t.label){case 0:if(u.default.debug("[".concat(this.clientId,"] ChannelMediaSocket onClose")),this.emit("event",v.NETWORK_DISCONNECTED),this.state=m.RELAY_STATE_IDLE,!this._prevChannelMediaConfig)return[3,4];t.label=1;case 1:return t.trys.push([1,3,,4]),[4,this.startChannelMediaRelay(this._prevChannelMediaConfig)];case 2:return t.sent(),[3,4];case 3:return(e=t.sent())instanceof E&&(e.message===_.WS_ABORT||e.message===_.AP_REQUEST_ABORT)?[2]:(this.emit("state",m.RELAY_STATE_FAILURE,w.SERVER_CONNECTION_LOST),[3,4]);case 4:return[2]}}))}))},r.token=t.appId,r.appId=t.appId,r.cname=t.cname,r.uid=t.uid,r.sid=t.sid,r.clientId=n,r}return i(t,e),Object.defineProperty(t.prototype,"state",{get:function(){return this._state},set:function(e){var t=this._state;this._state=e,t!==e&&this.emit("state",e)},enumerable:!1,configurable:!0}),t.prototype.startChannelMediaRelay=function(e){return o(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:if(this.state!==m.RELAY_STATE_IDLE)throw new E(_.BAD_STATE);return this.state=m.RELAY_STATE_CONNECTING,[4,this._connect()];case 1:return t.sent(),u.default.debug("[".concat(this.clientId,"] startChannelMediaRelay: connect success")),[4,this._sendStartRelayMessage(e)];case 2:return t.sent(),this._prevChannelMediaConfig=e,[2]}}))}))},t.prototype.updateChannelMediaRelay=function(e){return o(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:if(this.state!==m.RELAY_STATE_RUNNING)throw new E(_.BAD_STATE);return[4,this._sendUpdateMessage(e)];case 1:return t.sent(),this._prevChannelMediaConfig=e,[2]}}))}))},t.prototype.stopChannelMediaRelay=function(){return o(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._sendStopRelayMessage()];case 1:return e.sent(),u.default.debug("[".concat(this.clientId,"] stopChannelMediaRelay: send stop message success")),this.state=m.RELAY_STATE_IDLE,this.dispose(),[2]}}))}))},t.prototype.dispose=function(){u.default.debug("[".concat(this.clientId,"] disposeChannelMediaRelay")),this.state=m.RELAY_STATE_IDLE,this.emit("dispose"),this._signal&&this._signal.dispose(),this._prevChannelMediaConfig=null,this.removeEvent()},t.prototype._requestOneAP=function(e){var t=this;return new Promise((function(n,r){var i={command:"convergeAllocateEdge",sid:t.sid,appId:t.appId,token:"",ts:+new Date,version:l.VERSION,cname:t.cname,uid:t.uid+"",seq:1,requestId:1},o={service_name:"tele_channel",json_body:JSON.stringify(i)},s="https://".concat(e);wx.request({url:s,data:o,header:{"content-type":"application/json","X-Packet-Service-Type":0,"X-Packet-URI":61},method:"POST",success:function(e){var t=null,i=null;try{t=e.data}catch(e){r(new E(_.AP_JSON_PARSE_ERROR,e))}0!==t.code&&r(new E(_.AP_REQUEST_ERROR,t));try{i=JSON.parse(t.json_body)}catch(e){r(new E(_.AP_JSON_PARSE_ERROR,e))}200!==i.code&&r(new E(_.AP_REQUEST_ERROR,i)),i.servers?n(i.servers):r(new E(_.AP_JSON_PARSE_ERROR,i))},fail:function(e){return r(e)}})}))},t.prototype._requestAP=function(){var e=this,t=["uap-ap-web-1.agora.io","uap-ap-web-2.agoraio.cn","uap-ap-web-3.agora.io","uap-ap-web-4.agoraio.cn"];return new Promise((function(n,r){setTimeout((function(){r(new E(_.AP_REQUEST_TIMEOUT))}),3e3),e.on("dispose",(function(){r(new E(_.AP_REQUEST_ABORT))})),t.forEach((function(t){t+="/api/v1",e._requestOneAP(t).then((function(r){u.default.debug("[".concat(e.clientId,"] startChannelMediaRelay request AP ").concat(t," success: ").concat(JSON.stringify(r)));var i=r[0],o=(t=i.address).split("."),s=o.length,a="wss://miniapp.agoraio.cn/".concat(o[s-4],"-").concat(o[s-3],"-").concat(o[s-2],"-").concat(o[s-1],"-").concat(i.ws,"/");n(a)})).catch((function(n){u.default.debug("[".concat(e.clientId,"] startChannelMediaRelay request AP ").concat(t," failed: ").concat(JSON.stringify(n)))}))}))}))},t.prototype._connectWebsocket=function(e){return this._signal=new O(this.appId,this.cname,this.uid,this.sid),this._signal.connect(e)},t.prototype._connect=function(){return o(this,void 0,void 0,(function(){var e;return s(this,(function(t){switch(t.label){case 0:return[4,this._requestAP()];case 1:return e=t.sent(),[4,this._connectWebsocket(e)];case 2:return t.sent(),this._signal.on("close",this._onClose.bind(this)),this._signal.on("status",this._onStatus.bind(this)),this.emit("event",v.NETWORK_CONNECTED),[2]}}))}))},t.prototype._sendStartRelayMessage=function(e){return o(this,void 0,void 0,(function(){var t,n,r,i,o,a;return s(this,(function(s){switch(s.label){case 0:return this._checkSignal(),t=this._genMessage(g.StopPacketTransfer),[4,Promise.all([this._signal.request(t),this._signal.waitStatus("Normal Quit")])];case 1:return s.sent(),u.default.debug("[".concat(this.clientId,"] startChannelMediaRelay: StopPacketTransfer success")),n=this._genMessage(g.SetSdkProfile,e),[4,this._signal.request(n)];case 2:return s.sent(),u.default.debug("[".concat(this.clientId,"] startChannelMediaRelay: SetSdkProfile success")),r=this._genMessage(g.SetSourceChannel,e),[4,Promise.all([this._signal.request(r),this._signal.waitStatus("SetSourceChannelStatus")])];case 3:return s.sent(),this.emit("event",v.PACKET_JOINED_SRC_CHANNEL),u.default.debug("[".concat(this.clientId,"] startChannelMediaRelay: SetSourceChannel success")),i=this._genMessage(g.SetSourceUserId,e),[4,this._signal.request(i)];case 4:return s.sent(),u.default.debug("[".concat(this.clientId,"] startChannelMediaRelay: SetSourceUserId success")),o=this._genMessage(g.SetDestChannel,e),[4,Promise.all([this._signal.request(o),this._signal.waitStatus("SetDestChannelStatus")])];case 5:return s.sent(),this.emit("event",v.PACKET_JOINED_DEST_CHANNEL),u.default.debug("[".concat(this.clientId,"] startChannelMediaRelay: SetDestChannel success")),a=this._genMessage(g.StartPacketTransfer,e),[4,this._signal.request(a)];case 6:return s.sent(),this.emit("event",v.PACKET_SENT_TO_DEST_CHANNEL),this.state=m.RELAY_STATE_RUNNING,u.default.debug("[".concat(this.clientId,"] startChannelMediaRelay: StartPacketTransfer success")),[2]}}))}))},t.prototype._sendReconnectMessage=function(e){return o(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return this._checkSignal(),t=this._genMessage(g.Reconnect,e),[4,this._signal.request(t)];case 1:return n.sent(),[2]}}))}))},t.prototype._sendUpdateMessage=function(e){return o(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return this._checkSignal(),t=this._genMessage(g.UpdateDestChannel,e),[4,this._signal.request(t)];case 1:return n.sent(),this.emit("event",v.PACKET_UPDATE_DEST_CHANNEL),u.default.debug("[".concat(this.clientId,"] sendUpdateMessage: UpdateDestChannel success")),[2]}}))}))},t.prototype._sendStopRelayMessage=function(){return o(this,void 0,void 0,(function(){var e;return s(this,(function(t){switch(t.label){case 0:return this._checkSignal(),e=this._genMessage(g.StopPacketTransfer),[4,this._signal.request(e)];case 1:return t.sent(),u.default.debug("[".concat(this.clientId,"] sendStopRelayMessage: StopPacketTransfer success")),[2]}}))}))},t.prototype._genMessage=function(e,t){var n=this,r=[],i=[],o=[],s={appId:this.appId,cname:this.cname,uid:this.uid+"",sdkVersion:l.VERSION,sid:this.sid,ts:+new Date,requestId:0,seq:0,allocate:!0,clientRequest:{}},a=null;switch(e){case g.SetSdkProfile:return s.clientRequest={command:"SetSdkProfile",type:"multi_channel"},s;case g.SetSourceChannel:return a=t.getSrcChannelMediaInfo(),s.clientRequest={command:"SetSourceChannel",uid:a.uid+"",channelName:a.channelName,token:a.token||this.appId},s;case g.SetSourceUserId:return a=t.getSrcChannelMediaInfo(),s.clientRequest={command:"SetSourceUserId",uid:this.uid+""},s;case g.SetDestChannel:return t.getDestChannelMediaInfos().forEach((function(e){r.push(e.channelName),i.push(e.uid+""),o.push(e.token||n.appId)})),s.clientRequest={command:"SetDestChannel",channelName:r,uid:i,token:o},s;case g.StartPacketTransfer:return s.clientRequest={command:"StartPacketTransfer"},s;case g.Reconnect:return s.clientRequest={command:"Reconnect"},s;case g.StopPacketTransfer:return s.clientRequest={command:"StopPacketTransfer"},s;case g.UpdateDestChannel:return t.getDestChannelMediaInfos().forEach((function(e){r.push(e.channelName),i.push(e.uid+""),o.push(e.token||n.appId)})),s.clientRequest={command:"UpdateDestChannel",channelName:r,uid:i,token:o},s}},t.prototype._checkSignal=function(){if(!this._signal||!this._signal.isConnect())throw new E(_.WS_DISCONNECTED)},t}(c.default);t.default=f;var y=function(){function e(){this.destChannelMediaInfos=new Map}return e.prototype.setSrcChannelInfo=function(e){(0,p.checkValidObject)(e,"srcInfo");var t=e.uid,n=e.channelName,r=e.token;if(r&&!(0,p.isValidToken)(r))throw new Error("Invalid token in SrcChannelInfo");if(!(0,p.isValidChannelName)(n))throw new Error("Invalid channelName in SrcChannelInfo");if(!(0,h.is32Uint)(t))throw new Error("Invalid uid in SrcChannelInfo");u.default.debug("[setSrcChannelInfo]: srcInfo: ",e),this.srcChannelMediaInfo=e},e.prototype.setDestChannelInfo=function(e,t){if(!(0,p.isValidChannelName)(e))throw new Error("Invalid channelName in DestChannelInfo");(0,p.checkValidObject)(t,"destInfo");var n=t.uid,r=t.token,i=t.channelName;if(r&&!(0,p.isValidToken)(r))throw new Error("Invalid token in DestChannelInfo");if(!(0,p.isValidChannelName)(i))throw new Error("Invalid channelName in DestChannelInfo");if(!(0,h.is32Uint)(n))throw new Error("Invalid uid in DestChannelInfo");u.default.debug("[setDestChannelInfo]: destInfo: ",t,"channelName: ",e),this.destChannelMediaInfos.set(e,t)},e.prototype.removeDestChannelInfo=function(e){if(!(0,p.isValidChannelName)(e))throw new Error("Invalid channelName when invoke removeDestChannelInfo");u.default.debug("[removeDestChannelInfo]: channelName: ",e),this.destChannelMediaInfos.delete(e)},e.prototype.getSrcChannelMediaInfo=function(){return this.srcChannelMediaInfo},e.prototype.getDestChannelMediaInfos=function(){return this.destChannelMediaInfos},e}();t.ChannelMediaRelayConfiguration=y;var _,g,v,m,w,O=function(e){function t(t,n,r,i){var o=e.call(this)||this;return o._onOpen=function(){u.default.debug("[ChannelMediaRelay] onOpen"),o.emit("open")},o._onClose=function(e){u.default.debug("[ChannelMediaRelay] onClose"),o.emit("close"),o.dispose()},o._onMessage=function(e){u.default.blind("ChannelMediaRelay receive message",e);var t=JSON.parse(e.data);if(!t||"serverResponse"!==t.command||!t.requestId)return t&&"serverStatus"===t.command&&t.serverStatus&&t.serverStatus.command?(o.emit("status",t.serverStatus),void o.emit(t.serverStatus.command,t.serverStatus)):void 0;o.emit("req_".concat(t.requestId),t)},o._requestId=1,o.appId=t,o.cname=n,o.uid=r,o.sid=i,o}return i(t,e),t.prototype.isConnect=function(){return this._ws&&1===this._ws.readyState},t.prototype.sendMessage=function(e){if(!this._ws||1!==this._ws.readyState)throw new E(_.WS_DISCONNECTED);var t=this._requestId++;return e.requestId=t,e.seq=t,this._ws.send({data:JSON.stringify(e)}),t},t.prototype.waitStatus=function(e){var t=this;return new Promise((function(n,r){var i=setTimeout((function(){r(new E(_.WAIT_STATUS_TIMEOUT,e))}),5e3);t.once(e,(function(t){clearTimeout(i),t.state&&0!==t.state?r(new E(_.WAIT_STATUS_ERROR,e)):n("")})),t.once("dispose",(function(){clearTimeout(i),r(new E(_.WS_ABORT))}))}))},t.prototype.request=function(e){var t=this;return new Promise((function(n,r){var i=t.sendMessage(e),o=setTimeout((function(){t.removeAllListeners("req_".concat(i)),r(new E(_.REQUEST_TIMEOUT))}),3e3);t.once("req_".concat(i),(function(e){clearTimeout(o),e&&200===e.code?n(e):r(new E(_.REQUEST_FAILED,e))})),t.once("dispose",(function(){clearTimeout(o),r(new E(_.WS_ABORT))}))}))},t.prototype.connect=function(e){var t=this;return new Promise((function(n,r){t._ws=wx.connectSocket({url:e}),t._ws.onOpen((function(r,i){u.default.debug("[ChannelMediaRelay] ws.onOpen"),t._onOpen(),t._prvUrl=e,t._ws.onMessage(t._onMessage),t._ws.onClose(t._onClose),t._startHeartBeatCheck(),n(null)})),t._ws.onClose((function(e){u.default.debug("[ChannelMediaRelay] ws.onClose",e),t.dispose(),r(new E(_.CONNECT_FAILED,"websocket error code: ".concat(e.code)))})),setTimeout((function(){t._ws&&1!==t._ws.readyState&&(t._ws.onMessage(d),t._ws.onClose(d),t._ws.close(),t._ws=null,r(new E(_.CONNECT_TIMEOUT)))}),5e3),t.once("dispose",(function(){r(new E(_.WS_ABORT))}))}))},t.prototype.dispose=function(){u.default.debug("[ChannelMediaRelay] dispose"),this._clearHeartBeatCheck(),this.emit("dispose"),this.removeEvent(),this._ws&&(this._ws.onOpen(d),this._ws.onClose(d),this._ws.onMessage(d),this._ws.close(d)),this._ws=null},t.prototype._sendPing=function(e){if(!this._ws||1!==this._ws.readyState)throw new E(_.WS_DISCONNECTED);var t=this._requestId++;return e.requestId=t,this._ws.send({data:JSON.stringify(e)}),t},t.prototype._startHeartBeatCheck=function(){var e=this;this._heartBeatTimer=setInterval((function(){e._sendPing({command:"ping",appId:e.appId,cname:e.cname,uid:e.uid+"",sid:e.sid,ts:+new Date,requestId:0})}),3e3)},t.prototype._clearHeartBeatCheck=function(){clearInterval(this._heartBeatTimer)},t}(c.default),E=function(e,t,n){void 0===e&&(e=""),this.code=n,this.data=t,this.message=e};t.ChannelMediaError=E,function(e){e.CONNECT_FAILED="connect failed",e.CONNECT_TIMEOUT="connect timeout",e.WS_DISCONNECTED="websocket disconnected",e.REQUEST_TIMEOUT="request timeout",e.REQUEST_FAILED="request failed",e.WAIT_STATUS_TIMEOUT="wait status timeout",e.WAIT_STATUS_ERROR="wait status error",e.BAD_STATE="bad state",e.WS_ABORT="ws abort",e.AP_REQUEST_TIMEOUT="AP request timeout",e.AP_JSON_PARSE_ERROR="AP json parse error",e.AP_REQUEST_ERROR="AP request error",e.AP_REQUEST_ABORT="AP request abort"}(_=t.CHANNEL_MEDIA_ERROR||(t.CHANNEL_MEDIA_ERROR={})),function(e){e[e.SetSdkProfile=0]="SetSdkProfile",e[e.SetSourceChannel=1]="SetSourceChannel",e[e.SetSourceUserId=2]="SetSourceUserId",e[e.SetDestChannel=3]="SetDestChannel",e[e.StartPacketTransfer=4]="StartPacketTransfer",e[e.StopPacketTransfer=5]="StopPacketTransfer",e[e.UpdateDestChannel=6]="UpdateDestChannel",e[e.Reconnect=7]="Reconnect",e[e.SetVideoProfile=8]="SetVideoProfile"}(g||(g={})),function(e){e[e.NETWORK_DISCONNECTED=0]="NETWORK_DISCONNECTED",e[e.NETWORK_CONNECTED=1]="NETWORK_CONNECTED",e[e.PACKET_JOINED_SRC_CHANNEL=2]="PACKET_JOINED_SRC_CHANNEL",e[e.PACKET_JOINED_DEST_CHANNEL=3]="PACKET_JOINED_DEST_CHANNEL",e[e.PACKET_SENT_TO_DEST_CHANNEL=4]="PACKET_SENT_TO_DEST_CHANNEL",e[e.PACKET_RECEIVED_VIDEO_FROM_SRC=5]="PACKET_RECEIVED_VIDEO_FROM_SRC",e[e.PACKET_RECEIVED_AUDIO_FROM_SRC=6]="PACKET_RECEIVED_AUDIO_FROM_SRC",e[e.PACKET_UPDATE_DEST_CHANNEL=7]="PACKET_UPDATE_DEST_CHANNEL",e[e.PACKET_UPDATE_DEST_CHANNEL_REFUSED=8]="PACKET_UPDATE_DEST_CHANNEL_REFUSED",e[e.PACKET_UPDATE_DEST_CHANNEL_NOT_CHANGE=9]="PACKET_UPDATE_DEST_CHANNEL_NOT_CHANGE"}(v=t.CHANNEL_MEDIA_RELAY_EVENT||(t.CHANNEL_MEDIA_RELAY_EVENT={})),function(e){e[e.RELAY_STATE_IDLE=0]="RELAY_STATE_IDLE",e[e.RELAY_STATE_CONNECTING=1]="RELAY_STATE_CONNECTING",e[e.RELAY_STATE_RUNNING=2]="RELAY_STATE_RUNNING",e[e.RELAY_STATE_FAILURE=3]="RELAY_STATE_FAILURE"}(m=t.CHANNEL_MEDIA_RELAY_STATE||(t.CHANNEL_MEDIA_RELAY_STATE={})),function(e){e[e.RELAY_OK=0]="RELAY_OK",e[e.SERVER_ERROR_RESPONSE=1]="SERVER_ERROR_RESPONSE",e[e.SERVER_NO_RESPONSE=2]="SERVER_NO_RESPONSE",e[e.NO_RESOURCE_AVAILABLE=3]="NO_RESOURCE_AVAILABLE",e[e.FAILED_JOIN_SRC=4]="FAILED_JOIN_SRC",e[e.FAILED_JOIN_DEST=5]="FAILED_JOIN_DEST",e[e.FAILED_PACKET_RECEIVED_FROM_SRC=6]="FAILED_PACKET_RECEIVED_FROM_SRC",e[e.FAILED_PACKET_SENT_TO_DEST=7]="FAILED_PACKET_SENT_TO_DEST",e[e.SERVER_CONNECTION_LOST=8]="SERVER_CONNECTION_LOST",e[e.INTERNAL_ERROR=9]="INTERNAL_ERROR",e[e.SRC_TOKEN_EXPIRED=10]="SRC_TOKEN_EXPIRED",e[e.DEST_TOKEN_EXPIRED=11]="DEST_TOKEN_EXPIRED",e[e.RELAY_ALREADY_START=12]="RELAY_ALREADY_START",e[e.RELAY_NOT_START=13]="RELAY_NOT_START",e[e.OPERATION_ABORT=14]="OPERATION_ABORT"}(w=t.CHANNEL_MEDIA_RELAY_ERROR||(t.CHANNEL_MEDIA_RELAY_ERROR={}))},327:e=>{for(var t=[],n=0;n<256;++n)t[n]=(n+256).toString(16).substr(1);e.exports=function(e,n){var r=n||0,i=t;return[i[e[r++]],i[e[r++]],i[e[r++]],i[e[r++]],"-",i[e[r++]],i[e[r++]],"-",i[e[r++]],i[e[r++]],"-",i[e[r++]],i[e[r++]],"-",i[e[r++]],i[e[r++]],i[e[r++]],i[e[r++]],i[e[r++]],i[e[r++]]].join("")}},217:e=>{var t="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(t){var n=new Uint8Array(16);e.exports=function(){return t(n),n}}else{var r=new Array(16);e.exports=function(){for(var e,t=0;t<16;t++)0==(3&t)&&(e=4294967296*Math.random()),r[t]=e>>>((3&t)<<3)&255;return r}}},171:(e,t,n)=>{var r=n(217),i=n(327);e.exports=function(e,t,n){var o=t&&n||0;"string"==typeof e&&(t="binary"===e?new Array(16):null,e=null);var s=(e=e||{}).random||(e.rng||r)();if(s[6]=15&s[6]|64,s[8]=63&s[8]|128,t)for(var a=0;a<16;++a)t[o+a]=s[a];return t||i(s)}},795:function(e,t,n){var r;!function(t){"use strict";function i(){}var o=i.prototype,s=t.EventEmitter;function a(e,t){for(var n=e.length;n--;)if(e[n].listener===t)return n;return-1}function c(e){return function(){return this[e].apply(this,arguments)}}function l(e){return"function"==typeof e||e instanceof RegExp||!(!e||"object"!=typeof e)&&l(e.listener)}o.getListeners=function(e){var t,n,r=this._getEvents();if(e instanceof RegExp)for(n in t={},r)r.hasOwnProperty(n)&&e.test(n)&&(t[n]=r[n]);else t=r[e]||(r[e]=[]);return t},o.flattenListeners=function(e){var t,n=[];for(t=0;t<e.length;t+=1)n.push(e[t].listener);return n},o.getListenersAsObject=function(e){var t,n=this.getListeners(e);return n instanceof Array&&((t={})[e]=n),t||n},o.addListener=function(e,t){if(!l(t))throw new TypeError("listener must be a function");var n,r=this.getListenersAsObject(e),i="object"==typeof t;for(n in r)r.hasOwnProperty(n)&&-1===a(r[n],t)&&r[n].push(i?t:{listener:t,once:!1});return this},o.on=c("addListener"),o.addOnceListener=function(e,t){return this.addListener(e,{listener:t,once:!0})},o.once=c("addOnceListener"),o.defineEvent=function(e){return this.getListeners(e),this},o.defineEvents=function(e){for(var t=0;t<e.length;t+=1)this.defineEvent(e[t]);return this},o.removeListener=function(e,t){var n,r,i=this.getListenersAsObject(e);for(r in i)i.hasOwnProperty(r)&&-1!==(n=a(i[r],t))&&i[r].splice(n,1);return this},o.off=c("removeListener"),o.addListeners=function(e,t){return this.manipulateListeners(!1,e,t)},o.removeListeners=function(e,t){return this.manipulateListeners(!0,e,t)},o.manipulateListeners=function(e,t,n){var r,i,o=e?this.removeListener:this.addListener,s=e?this.removeListeners:this.addListeners;if("object"!=typeof t||t instanceof RegExp)for(r=n.length;r--;)o.call(this,t,n[r]);else for(r in t)t.hasOwnProperty(r)&&(i=t[r])&&("function"==typeof i?o.call(this,r,i):s.call(this,r,i));return this},o.removeEvent=function(e){var t,n=typeof e,r=this._getEvents();if("string"===n)delete r[e];else if(e instanceof RegExp)for(t in r)r.hasOwnProperty(t)&&e.test(t)&&delete r[t];else delete this._events;return this},o.removeAllListeners=c("removeEvent"),o.emitEvent=function(e,t){var n,r,i,o,s=this.getListenersAsObject(e);for(o in s)if(s.hasOwnProperty(o))for(n=s[o].slice(0),i=0;i<n.length;i++)!0===(r=n[i]).once&&this.removeListener(e,r.listener),r.listener.apply(this,t||[])===this._getOnceReturnValue()&&this.removeListener(e,r.listener);return this},o.trigger=c("emitEvent"),o.emit=function(e){var t=Array.prototype.slice.call(arguments,1);return this.emitEvent(e,t)},o.setOnceReturnValue=function(e){return this._onceReturnValue=e,this},o._getOnceReturnValue=function(){return!this.hasOwnProperty("_onceReturnValue")||this._onceReturnValue},o._getEvents=function(){return this._events||(this._events={})},i.noConflict=function(){return t.EventEmitter=s,i},void 0===(r=function(){return i}.call(t,n,t,e))||(e.exports=r)}("undefined"!=typeof window?window:this||{})},61:(e,t,n)=>{var r=n(698).default;function i(){"use strict";e.exports=i=function(){return n},e.exports.__esModule=!0,e.exports.default=e.exports;var t,n={},o=Object.prototype,s=o.hasOwnProperty,a=Object.defineProperty||function(e,t,n){e[t]=n.value},c="function"==typeof Symbol?Symbol:{},l=c.iterator||"@@iterator",u=c.asyncIterator||"@@asyncIterator",p=c.toStringTag||"@@toStringTag";function h(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{h({},"")}catch(t){h=function(e,t,n){return e[t]=n}}function d(e,t,n,r){var i=t&&t.prototype instanceof w?t:w,o=Object.create(i.prototype),s=new L(r||[]);return a(o,"_invoke",{value:A(e,n,s)}),o}function f(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}n.wrap=d;var y="suspendedStart",_="suspendedYield",g="executing",v="completed",m={};function w(){}function O(){}function E(){}var b={};h(b,l,(function(){return this}));var R=Object.getPrototypeOf,S=R&&R(R(M([])));S&&S!==o&&s.call(S,l)&&(b=S);var k=E.prototype=w.prototype=Object.create(b);function P(e){["next","throw","return"].forEach((function(t){h(e,t,(function(e){return this._invoke(t,e)}))}))}function I(e,t){function n(i,o,a,c){var l=f(e[i],e,o);if("throw"!==l.type){var u=l.arg,p=u.value;return p&&"object"==r(p)&&s.call(p,"__await")?t.resolve(p.__await).then((function(e){n("next",e,a,c)}),(function(e){n("throw",e,a,c)})):t.resolve(p).then((function(e){u.value=e,a(u)}),(function(e){return n("throw",e,a,c)}))}c(l.arg)}var i;a(this,"_invoke",{value:function(e,r){function o(){return new t((function(t,i){n(e,r,t,i)}))}return i=i?i.then(o,o):o()}})}function A(e,n,r){var i=y;return function(o,s){if(i===g)throw new Error("Generator is already running");if(i===v){if("throw"===o)throw s;return{value:t,done:!0}}for(r.method=o,r.arg=s;;){var a=r.delegate;if(a){var c=T(a,r);if(c){if(c===m)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(i===y)throw i=v,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);i=g;var l=f(e,n,r);if("normal"===l.type){if(i=r.done?v:_,l.arg===m)continue;return{value:l.arg,done:r.done}}"throw"===l.type&&(i=v,r.method="throw",r.arg=l.arg)}}}function T(e,n){var r=n.method,i=e.iterator[r];if(i===t)return n.delegate=null,"throw"===r&&e.iterator.return&&(n.method="return",n.arg=t,T(e,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),m;var o=f(i,e.iterator,n.arg);if("throw"===o.type)return n.method="throw",n.arg=o.arg,n.delegate=null,m;var s=o.arg;return s?s.done?(n[e.resultName]=s.value,n.next=e.nextLoc,"return"!==n.method&&(n.method="next",n.arg=t),n.delegate=null,m):s:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,m)}function C(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 N(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function L(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(C,this),this.reset(!0)}function M(e){if(e||""===e){var n=e[l];if(n)return n.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,o=function n(){for(;++i<e.length;)if(s.call(e,i))return n.value=e[i],n.done=!1,n;return n.value=t,n.done=!0,n};return o.next=o}}throw new TypeError(r(e)+" is not iterable")}return O.prototype=E,a(k,"constructor",{value:E,configurable:!0}),a(E,"constructor",{value:O,configurable:!0}),O.displayName=h(E,p,"GeneratorFunction"),n.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===O||"GeneratorFunction"===(t.displayName||t.name))},n.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,E):(e.__proto__=E,h(e,p,"GeneratorFunction")),e.prototype=Object.create(k),e},n.awrap=function(e){return{__await:e}},P(I.prototype),h(I.prototype,u,(function(){return this})),n.AsyncIterator=I,n.async=function(e,t,r,i,o){void 0===o&&(o=Promise);var s=new I(d(e,t,r,i),o);return n.isGeneratorFunction(t)?s:s.next().then((function(e){return e.done?e.value:s.next()}))},P(k),h(k,p,"Generator"),h(k,l,(function(){return this})),h(k,"toString",(function(){return"[object Generator]"})),n.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},n.values=M,L.prototype={constructor:L,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(N),!e)for(var n in this)"t"===n.charAt(0)&&s.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=t)},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 n=this;function r(r,i){return a.type="throw",a.arg=e,n.next=r,i&&(n.method="next",n.arg=t),!!i}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var c=s.call(o,"catchLoc"),l=s.call(o,"finallyLoc");if(c&&l){if(this.prev<o.catchLoc)return r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(c){if(this.prev<o.catchLoc)return r(o.catchLoc,!0)}else{if(!l)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return r(o.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&s.call(r,"finallyLoc")&&this.prev<r.finallyLoc){var i=r;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var o=i?i.completion:{};return o.type=e,o.arg=t,i?(this.method="next",this.next=i.finallyLoc,m):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),m},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),N(n),m}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;N(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,n,r){return this.delegate={iterator:M(e),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=t),m}},n}e.exports=i,e.exports.__esModule=!0,e.exports.default=e.exports},698:e=>{function t(n){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(n)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports},687:(e,t,n)=>{var r=n(61)();e.exports=r;try{regeneratorRuntime=r}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=r:Function("r","regeneratorRuntime = r")(r)}},861:(e,t,n)=>{"use strict";function r(e,t,n,r,i,o,s){try{var a=e[o](s),c=a.value}catch(e){return void n(e)}a.done?t(c):Promise.resolve(c).then(r,i)}function i(e){return function(){var t=this,n=arguments;return new Promise((function(i,o){var s=e.apply(t,n);function a(e){r(s,i,o,a,c,"next",e)}function c(e){r(s,i,o,a,c,"throw",e)}a(void 0)}))}}n.d(t,{Z:()=>i})},671:(e,t,n)=>{"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}n.d(t,{Z:()=>r})},144:(e,t,n)=>{"use strict";n.d(t,{Z:()=>o});var r=n(142);function i(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,(0,r.Z)(i.key),i)}}function o(e,t,n){return t&&i(e.prototype,t),n&&i(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}},142:(e,t,n)=>{"use strict";n.d(t,{Z:()=>i});var r=n(2);function i(e){var t=function(e,t){if("object"!=(0,r.Z)(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,"string");if("object"!=(0,r.Z)(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==(0,r.Z)(t)?t:String(t)}},2:(e,t,n)=>{"use strict";function r(e){return r="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},r(e)}n.d(t,{Z:()=>r})}},__webpack_module_cache__={};function __webpack_require__(e){var t=__webpack_module_cache__[e];if(void 0!==t)return t.exports;var n=__webpack_module_cache__[e]={exports:{}};return __webpack_modules__[e].call(n.exports,n,n.exports,__webpack_require__),n.exports}__webpack_require__.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return __webpack_require__.d(t,{a:t}),t},__webpack_require__.d=(e,t)=>{for(var n in t)__webpack_require__.o(t,n)&&!__webpack_require__.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},__webpack_require__.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),__webpack_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),__webpack_require__.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var __webpack_exports__={};return(()=>{"use strict";__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{ChannelMediaRelayConfiguration:()=>I.ChannelMediaRelayConfiguration,Client:()=>le,LOG:()=>a.default,SDK_VERSION:()=>s.SDK_VERSION});var e=__webpack_require__(861),t=__webpack_require__(671),n=__webpack_require__(144),r=__webpack_require__(687),i=__webpack_require__.n(r),o=__webpack_require__(426),s=__webpack_require__(446),a=__webpack_require__(186);function c(){return c=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},c.apply(this,arguments)}var l=__webpack_require__(142);function u(e,t,n){return(t=(0,l.Z)(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var p=__webpack_require__(568),h=__webpack_require__.n(p);function d(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function f(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?d(Object(n),!0).forEach((function(t){u(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):d(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var y="success",_="fail",g=function(){function r(){(0,t.Z)(this,r);var e=O().vid,n=void 0===e?"":e;this.ip="",this.vid=n,this.appId="",this.url="https://report-ad.agoralab.co/v1/report",this.sdk_version=s.SDK_VERSION,this.systemInfo={},this.onlineTimer=null,this.pts=[],this.netStatusPts=[]}var o,l,u;return(0,n.Z)(r,[{key:"_flushReport",value:(u=(0,e.Z)(i().mark((function e(){var t,n,r,o;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=Date.now(),n={sign:h()("src=miniapp_sdk&ts=".concat(t)),src:"miniapp_sdk",ts:t},!this.pts.length){e.next=8;break}return(r=f({},n)).pts=this.pts,e.next=7,this.request({body:r,url:this.url});case 7:this.pts=[];case 8:if(!this.netStatusPts.length){e.next=14;break}return(o=f({},n)).pts=this.netStatusPts,e.next=13,this.request({body:o,url:this.url});case 13:this.netStatusPts=[];case 14:case"end":return e.stop()}}),e,this)}))),function(){return u.apply(this,arguments)})},{key:"setOptions",value:function(e){var t=e.systemInfo,n=e.ip,r=e.appId;t&&(this.systemInfo=t),n&&(this.ip=n),r&&(this.appId=r)}},{key:"onlineUser",value:function(){var e=this;this.onlineTimer||(this.onlineTimer=setInterval((function(){e.report("online_user")}),2e4))}},{key:"destroy",value:function(){this.onlineTimer&&(clearInterval(this.onlineTimer),this.onlineTimer=null),this._flushReport()}},{key:"reportNetStatus",value:(l=(0,e.Z)(i().mark((function e(){var t,n,r,o,s,a,c,l,u=arguments;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=u.length>0&&void 0!==u[0]?u[0]:0,o=u.length>1&&void 0!==u[1]?u[1]:{},this.vid||(this.vid=O().vid),s={m:"net_status",ls:{type:0===r?"live-pusher":"live-player",vid:String(this.vid),app_id:this.appId,version:this.sdk_version,ip:this.ip,wx_version:null===(t=this.systemInfo)||void 0===t?void 0:t.version,wx_basic_version:null===(n=this.systemInfo)||void 0===n?void 0:n.SDKVersion},vs:{videoBitrate:String(null==o?void 0:o.videoBitrate),audioBitrate:String(null==o?void 0:o.audioBitrate),videoFPS:String(null==o?void 0:o.videoFPS),videoGOP:String(null==o?void 0:o.videoGOP),netSpeed:String(null==o?void 0:o.netSpeed),netQualityLevel:String(null==o?void 0:o.netQualityLevel),netJitter:String(null==o?void 0:o.netJitter)}},this.netStatusPts.push(s),10!==this.netStatusPts.length){e.next=11;break}return a=Date.now(),c=this.netStatusPts.splice(0,10),l={pts:c,sign:h()("src=miniapp_sdk&ts=".concat(a)),src:"miniapp_sdk",ts:a},e.next=11,this.request({body:l,url:this.url});case 11:case"end":return e.stop()}}),e,this)}))),function(){return l.apply(this,arguments)})},{key:"report",value:(o=(0,e.Z)(i().mark((function e(t){var n,r,o,s,a,l,u,p,d,y,_,g=arguments;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=g.length>1&&void 0!==g[1]?g[1]:"",s=g.length>2&&void 0!==g[2]?g[2]:"",a=g.length>3&&void 0!==g[3]?g[3]:"",l=g.length>4&&void 0!==g[4]?g[4]:{},this.vid||(this.vid=O().vid),u={m:"online_user"===t?"online_user":"event",ls:f({vid:String(this.vid),app_id:this.appId,version:this.sdk_version,ip:this.ip,wx_version:null===(n=this.systemInfo)||void 0===n?void 0:n.version,wx_basic_version:null===(r=this.systemInfo)||void 0===r?void 0:r.SDKVersion},l),vs:{count:1}},"online_user"!==t&&((p={event:t,result:"success"===o?"1":"0",err_code:s.toString()}).message="string"==typeof a?a:JSON.stringify(a),c(u.ls,p)),this.pts.push(u),10!==this.pts.length){e.next=14;break}return d=this.pts.splice(0,10),y=Date.now(),_={pts:d,sign:h()("src=miniapp_sdk&ts=".concat(y)),src:"miniapp_sdk",ts:y},e.next=14,this.request({body:_,url:this.url});case 14:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"request",value:function(e){return new Promise((function(t,n){wx.request({url:e.url,data:e.body,header:{"content-type":"application/json"},method:"POST",success:function(e){200===e.statusCode?t(e):a.default.error("grafana report fail: ".concat(e.statusCode))},fail:function(e){a.default.error("grafana report fail",JSON.stringify(e)),n(e)}})}))}}]),r}(),v=function(){function e(){(0,t.Z)(this,e),this.ts=-1}return(0,n.Z)(e,[{key:"start",value:function(){return this.ts=(new Date).getTime(),this}},{key:"elapse",value:function(){if(-1===this.ts)throw new Error("timer not started");return(new Date).getTime()-this.ts}}],[{key:"create",value:function(){return new e}}]),e}(),m=__webpack_require__(483),w={ip:"",vid:""};function O(){return w}var E=["https://uap-ap-web-1.agora.io/api/v1","https://uap-ap-web-3.agora.io/api/v1","https://uap-ap-web-2.agoraio.cn/api/v1","https://uap-ap-web-4.agoraio.cn/api/v1"],b="connected",R="disconnected";const S=function(){function e(n,r){(0,t.Z)(this,e),this.serverlist=[],this.option=n,this.index=0,this.isInit=!0,this.state=R,this.hasInvokeClose=!1,this.emitter=r,this.on=this.emitter.on,this.off=this.emitter.off,this.emit=this.emitter.emit}return(0,n.Z)(e,[{key:"connect",value:function(){var e=this,t=this.option.grafanaReport;this.state!==R&&this.close(),function(e){var t=e.grafanaReport,n=e.argusReport,r={command:"convergeAllocateEdge",sid:e.sid,appId:e.appId,token:e.appId,uid:e.uid+"",cname:e.channel,ts:Math.floor(Date.now()/1e3),version:s.VERSION,seq:0,requestId:1};return new Promise((function(i,o){var s=0,c=v.create().start(),l=function(r,i){n.reportJoinCS(e.channel,e.uid,!1,c.elapse(),JSON.stringify(r),i,null),s++,a.default.error("get server list failed, counter:".concat(s," url:").concat(i," "),JSON.stringify(r)),4===s&&(t&&t.report("get_server_list",_,null==r?void 0:r.code,null==r?void 0:r.reason),o(r))},u=function(o){wx.request({url:o,data:{service_name:"miniapp",json_body:JSON.stringify(r)},header:{"content-type":"application/json","X-Packet-URI":61,"X-Packet-Service-Type":0},method:"POST",success:function(r){var s,u,p=r.data;if(r.profile?(s=r.profile.peerIP,w.ip=s):a.default.info("skip user IP report!"),200!==r.statusCode){var h="choose server fail";l({code:r.statusCode,reason:h},o),t&&t.report("choose_server",_,r.statusCode,h)}else{var d=c.elapse(),f=(0,m.transformElapseStr)(d),g=JSON.parse(p.json_body);u=g.vid,w.vid=u;var v=function(e){if(void 0!==e)return e.map((function(e){var t=e.address.split("."),n=t.length;return"wss://miniapp.agoraio.cn/".concat(t[n-4],"-").concat(t[n-3],"-").concat(t[n-2],"-").concat(t[n-1],"/api")}));a.default.error("miniapp service is not enabled for this AppID")}(g.servers);n.reportJoinCS(e.channel,e.uid,!0,d,null,o,v.join(",")),t.report("choose_server",y,"","",{elapse:f}),a.default.info("get server list request success,url:".concat(o,",time:").concat(d,"ms,elapse:").concat(f,",serverlist:").concat(JSON.stringify(v))),i({serverlist:v,url:o})}},fail:function(e){var n=e.errMsg||"choose server fail";l({code:901,reason:n},o),t&&t.report("choose_server",_,901,n)}})};e.apUrl?u(e.apUrl):E.map((function(e,t){u(e)}))}))}(this.option).then((function(t){var n=t.serverlist,r=t.url;a.default.info("websocket get server list final success, url:".concat(r,",serverlist:").concat(JSON.stringify(n))),e.index=0,e.serverlist=n,e.option&&e.option.servers&&(e.serverlist=e.option.servers),e.connectWorker(e.serverlist[e.index])})).catch((function(n){a.default.error("websocket connect failed in get server list ".concat(JSON.stringify(n))),t&&t.report("wxsocket_connect",_,null==n?void 0:n.code,null==n?void 0:n.reason),e.emit&&e.emit("socketError",n)}))}},{key:"connectWorker",value:function(){var e=this;this.state="connecting";var t=this.serverlist[this.index];a.default.info("websocket connect server: ",t);var n=this.option,r=(n.sid,n.channel),i=n.uid,o=n.argusReport,s=n.grafanaReport,c=v.create().start();this.ws=wx.connectSocket({url:t,fail:function(n){var l=JSON.stringify(n);a.default.error("websocket connect worker failed url:".concat(t," "),l),o&&o.reportConnectWS(r,i,!1,c.elapse(),l,null,t),s&&s.report("wxsocket_connect_worker",_,n.statusCode,l,{retry:String(e.index)})},success:function(n){var l=c.elapse(),u=(0,m.transformElapseStr)(l);if(a.default.info("websocket connect worker success,url:".concat(t,",time:").concat(l,"ms,elapse:").concat(u)),e.option.grafanaReport){var p=(0,m.getServerUrlIp)(t);e.option.grafanaReport.setOptions({ip:p})}o&&o.reportConnectWS(r,i,!0,l,null,null,t),s&&s.report("wxsocket_connect_worker",y,"","".concat(t),{elapse:u,retry:String(e.index)})}}),this.ws.onOpen(this._onopen.bind(this)),this.ws.onMessage(this._onmessage.bind(this)),this.ws.onError((function(e){a.default.error("websocket onerror: "+JSON.stringify(e)),o&&o.reportConnectWS(r,i,!1,c.elapse(),JSON.stringify(e),null,t),s&&s.report("wxsocket_connect_worker_on_error",_,"",JSON.stringify(e))})),this.establishWSTimeoutTimer=setTimeout((function(){e.state!==b&&e.connectNextWorker()}),5e3)}},{key:"connectNextWorker",value:function(){var e=this,t=this.option.grafanaReport;this.close().then((function(n){if(a.default.info("websocket connect next worker current:".concat(e.index," total:").concat(e.serverlist.length)),e.index>=e.serverlist.length-1){var r={code:905,reason:"connect websocket failed"};a.default.error("websocket connect next worker failed, all serverlist tried. ",JSON.stringify(r)),e.emit&&e.emit("socketError",{code:r.code,reason:r.reason,wsurl:JSON.stringify(e.serverlist)}),t&&t.report("wxsocket_connect_next_worker",_,r.code,r.reason)}else e.index++,e.connectWorker()}))}},{key:"_onopen",value:function(){a.default.info("websocket onopen"),clearTimeout(this.establishWSTimeoutTimer),this.state=b,this.isInit=!1,this.hasInvokeClose?a.default.info("websocket already invoke ws.Close, will not throw onopen event"):(this.ws.onClose(this._onclose.bind(this)),this.emit&&this.emit("onopen"))}},{key:"_onclose",value:function(e){a.default.info("websocket onclose:"+JSON.stringify(e)),this.emitter.emit("_wsClose"),clearTimeout(this.establishWSTimeoutTimer),this.state=R,e&&"close"==e.reason||this.hasInvokeClose||(this.isInit?this.connectNextWorker():this.emit&&this.emit("onclose",e))}},{key:"_onmessage",value:function(e){if(!this.hasInvokeClose){var t=JSON.parse(null==e?void 0:e.data)||{};"pong"!==(null==t?void 0:t.command)&&a.default.info("websocket receive message: ",JSON.stringify(e)),this.isConnected()&&this.emit&&this.emit("onmessage",e)}}},{key:"isConnected",value:function(){return this.state===b}},{key:"sendMessage",value:function(e){var t=JSON.parse(e)||{};"ping"!==(null==t?void 0:t.command)&&a.default.info("websocket send message: ",e),this.isConnected()&&this.ws&&this.ws.send({data:e})}},{key:"_checkServerList",value:function(e){return e instanceof Array!=0&&0!=e.length}},{key:"destroy",value:function(e){var t=this;this.state!==R&&this.close(),this.on("_wsClose",(function n(){t.off("_wsClose",n),t.serverlist=null,t.ws=null,t.emitter=null,t.on=null,t.off=null,t.emit=null,e&&e()}))}},{key:"close",value:function(){var e=this;return new Promise((function(t,n){return e.state==R?t():(clearTimeout(e.establishWSTimeoutTimer),e.hasInvokeClose=!0,e.state=R,e.ws?void e.ws.close({reason:"close",success:function(){a.default.info("websocket close success"),t()},fail:function(t){a.default.error("websocket close failed: ",JSON.stringify(t));var r=e.option,i=(r.sid,r.channel),o=r.uid,s=r.argusReport,c=r.grafanaReport;n();var l=e.serverlist[e.index];s&&s.reportConnectWS(i,o,!1,0,JSON.stringify(t),null,l),c&&c.report("wxsocket_close",_,"",JSON.stringify(t))},complete:function(){e.ws=null}}):t())}))}}]),e}(),k=function(){function e(n){(0,t.Z)(this,e),this.appId=n.appId,this.channel=n.channel,this.uid=n.uid+"",this.sid=n.sid,this.seq=1,this.requestId=2}return(0,n.Z)(e,[{key:"setSid",value:function(e){this.sid=e}},{key:"_getWorkerManagerMsg",value:function(){return{appId:this.appId,cname:this.channel,uid:this.uid,sid:this.sid,sdkVersion:s.VERSION,seq:++this.seq,requestId:++this.requestId,ts:Math.floor(Date.now()/1e3)}}},{key:"send",value:function(e){var t=this._getWorkerManagerMsg();return t.clientRequest=e,t}},{key:"updatePushUrl",value:function(){var e=this._getWorkerManagerMsg();return e.clientRequest={action:"update_url",role:"publish",uid:+this.uid},e}},{key:"ping",value:function(){return{command:"ping",requestId:++this.requestId,appId:this.appId,cname:this.channel,uid:this.uid+"",sid:this.sid,ts:Math.floor(Date.now()/1e3)}}},{key:"ping2",value:function(){var e=this._getWorkerManagerMsg();return e.clientRequest={action:"ping"},e}},{key:"setRole",value:function(e){var t=this._getWorkerManagerMsg();return t.clientRequest={action:"set_role",role:e},t}},{key:"rejoin",value:function(e,t,n,r,i,o,s,a,c){var l=this._getWorkerManagerMsg();return l.clientRequest={action:"join",role:o,appId:e,customAudioCodec:a,key_vocs:r||e,key_vos:r||e,channel_name:t,uid:n+"",known_speakers:i,clientType:"undefined"==typeof qq?"wechat":"qq",audio_only:s,uidType:c},l}},{key:"join",value:function(e,t,n,r,i,o,a,c,l,u){var p=this._getWorkerManagerMsg();return p.clientRequest={action:"join",role:i,appId:e,customAudioCodec:l,key_vocs:r||e,key_vos:r||e,channel_name:t,uid:n+"",vid:O().vid.toString(),device:o,os:a,version:s.SDK_VERSION,clientType:"undefined"==typeof qq?"wechat":"qq",audio_only:c,uidType:u},p}},{key:"muteLocal",value:function(e,t){var n=this._getWorkerManagerMsg();return n.clientRequest={action:"mute_local",uid:+e,target:t,mute:!0},n}},{key:"unmuteLocal",value:function(e,t){var n=this._getWorkerManagerMsg();return n.clientRequest={action:"mute_local",uid:+e,target:t,mute:!1},n}},{key:"mute",value:function(e,t){var n=this._getWorkerManagerMsg();return n.clientRequest={action:"mute",uid:+e,target:t},n}},{key:"unmute",value:function(e,t){var n=this._getWorkerManagerMsg();return n.clientRequest={action:"unmute",uid:+e,target:t},n}},{key:"publish",value:function(e){var t=this._getWorkerManagerMsg();return t.clientRequest={action:"publish",uid:+e},t}},{key:"unpublish",value:function(e){var t=this._getWorkerManagerMsg();return t.clientRequest={action:"unpublish",uid:+e},t}},{key:"subscribe",value:function(e,t){var n=this._getWorkerManagerMsg();return n.clientRequest={action:"subscribe",uid:+e,options:{audio:t.audio,video:t.video}},n}},{key:"unsubscribe",value:function(e){var t=this._getWorkerManagerMsg();return t.clientRequest={action:"unsubscribe",uid:[+e]},t}},{key:"setRemoteVideoStreamType",value:function(e,t){var n=this._getWorkerManagerMsg();return n.clientRequest={action:"set_remote_stream_type",uid:+e,type:t},n}},{key:"renewToken",value:function(e){var t=this._getWorkerManagerMsg();return t.clientRequest={action:"update_key",key_vos:e},t}},{key:"leave",value:function(e){var t=this._getWorkerManagerMsg();return t.clientRequest={action:"leave",uid:+e},t}}]),e}();function P(e){return{all:e=e||new Map,on:function(t,n){var r=e.get(t);r?r.push(n):e.set(t,[n])},off:function(t,n){var r=e.get(t);r&&(n?r.splice(r.indexOf(n)>>>0,1):e.set(t,[]))},emit:function(t,n){var r=e.get(t);r&&r.slice().map((function(e){e(n)})),(r=e.get("*"))&&r.slice().map((function(e){e(t,n)}))}}}var I=__webpack_require__(500),A=__webpack_require__.n(I);const T=function(){function r(e,n){(0,t.Z)(this,r),this.appId=e.appId,this.channel=e.channel,this.uid=e.uid,this.sid=e.sid,this.role=e.role,this.channelKey=e.channelKey,this.clientId="client",this.option=e,this.timers=new Set,this.grafanaReport=e.grafanaReport,this.argusReport=e.argusReport,this.audioCodec=e.audioCodec,this.uidType=e.uidType,this.clientEmitter=n,this.emitter=new P,this.on=this.emitter.on,this.off=this.emitter.off,this.emit=this.emitter.emit,this.join=this.join.bind(this),this.msgManager=new k(e)}var o,s,c;return(0,n.Z)(r,[{key:"connect",value:function(){var e=this;return new Promise((function(t,n){e.ws=new S(e.option,e.emitter),e.ws.connect(),e.on("onmessage",e._onMessage.bind(e)),e.on("socketError",(function(t){n(t),a.default.error("worker socket error: ",JSON.stringify(t)),e.grafanaReport&&e.grafanaReport.report("worker_connect_socket_error",_,"",JSON.stringify(t))})),e.on("onopen",(function n(){e.off&&e.off("onopen",n),e._ping(),t()})),e.on("onclose",(function(t){a.default.error("worker on close: ",JSON.stringify(t)),e.ws=null,e.clientEmitter.emit("error",{code:904,reason:"websocket disconnected"}),e.grafanaReport&&e.grafanaReport.report("worker_connect_on_close",_,"",JSON.stringify(t))}))}))}},{key:"_onMessage",value:function(e){if(e&&e.data){var t=JSON.parse(e.data);if(t&&"pong"!==t.command&&(a.default.info("worker onmessage: ",t),this.argusReport.reportServerEvent(this.channel,this.uid,!0,0,"serverEvent",t)),t.requestId&&this.emit(t.requestId,t),"serverStatus"===t.command){if(t.code&&200!==t.code){if(this.grafanaReport&&this.grafanaReport.report("worker_on_message",_,t.code,null==t?void 0:t.reason),503===t.code)return;a.default.error("worker onmessage error: ",JSON.stringify(t)),this.clientEmitter.emit("error",{code:t.code,reason:t.reason||"server error"})}if(t.serverStatus){a.default.info("Receive message from server: ".concat(JSON.stringify(t.serverStatus)));var n=t.serverStatus.action;if("audio-mute"==n)return t.serverStatus.mute?this.clientEmitter.emit("mute-audio",{uid:t.serverStatus.uid}):this.clientEmitter.emit("unmute-audio",{uid:t.serverStatus.uid});if("video-mute"==n)return t.serverStatus.mute?this.clientEmitter.emit("mute-video",{uid:t.serverStatus.uid}):this.clientEmitter.emit("unmute-video",{uid:t.serverStatus.uid});if("key-expired"===n)return this.clientEmitter.emit("token-privilege-did-expire");if("key-will-expire"===n)return this.clientEmitter.emit("token-privilege-will-expire");if("client-is-banned-by-server"===n)return this.clientEmitter.emit("client-banned");this.clientEmitter.emit(n,t.serverStatus)}}}}},{key:"_sendMessage",value:function(e){var t=this;if(this.ws)return new Promise((function(n,r){if(!t.isWSConnected())return r({code:904,reason:"websocket disconnected",wsurl:t.getWSUrl()});"ping"!==e.command&&a.default.info("worker send message: ",e);var i,o=e?e.requestId:null,s=function e(s){if(t.ws)return t.off(o,e),clearTimeout(i),t.timers.delete(i),200==s.code?n(s.serverResponse):r({code:s.code,reason:s.msg||s.reason,serverResponse:s.serverResponse,wsurl:t.getWSUrl()})};if(!o)return r({code:902,reason:"no requestid"});t.ws.sendMessage(JSON.stringify(e)),t.on(o,s),i=setTimeout((function(){return s({code:903,reason:"time out"})}),1e4),t.timers.add(i)}))}},{key:"_ping",value:function(){var e=this;this.pingTimer=setInterval((function(){e.ws.sendMessage(JSON.stringify(e.msgManager.ping()))}),3e3)}},{key:"setRole",value:function(e){return this._sendMessage(this.msgManager.setRole(e))}},{key:"rejoin",value:function(e,t){return this._sendMessage(this.msgManager.rejoin(this.appId,this.channel,this.uid,this.channelKey,e,this.role,t,this.audioCodec,this.uidType))}},{key:"join",value:function(e,t,n){return this._sendMessage(this.msgManager.join(this.appId,this.channel,this.uid,this.channelKey,this.role,e,t,n,this.audioCodec,this.uidType))}},{key:"send",value:function(e){return this._sendMessage(this.msgManager.send(e))}},{key:"updatePushUrl",value:function(){return this._sendMessage(this.msgManager.updatePushUrl())}},{key:"publish",value:function(){return this._sendMessage(this.msgManager.publish(this.uid))}},{key:"unpublish",value:function(){return this._sendMessage(this.msgManager.unpublish(this.uid))}},{key:"subscribe",value:function(e,t){return this._sendMessage(this.msgManager.subscribe(e,t))}},{key:"unsubscribe",value:function(e){return this._sendMessage(this.msgManager.unsubscribe(e))}},{key:"setRemoteVideoStreamType",value:function(e,t){return this._sendMessage(this.msgManager.setRemoteVideoStreamType(e,t))}},{key:"mute",value:function(e,t){return this._sendMessage(this.msgManager.mute(e,t))}},{key:"unmute",value:function(e,t){return this._sendMessage(this.msgManager.unmute(e,t))}},{key:"muteLocal",value:function(e){return this._sendMessage(this.msgManager.muteLocal(this.uid,e))}},{key:"unmuteLocal",value:function(e){return this._sendMessage(this.msgManager.unmuteLocal(this.uid,e))}},{key:"renewToken",value:function(e){return this._sendMessage(this.msgManager.renewToken(e))}},{key:"leave",value:function(){return this._sendMessage(this.msgManager.leave(this.uid))}},{key:"isWSConnected",value:function(){return!!this.ws&&this.ws.isConnected()}},{key:"getWSUrl",value:function(){return this.ws?this.ws.serverlist[this.ws.index]:""}},{key:"destroy",value:function(){var e=this;return new Promise((function(t,n){clearInterval(e.pingTimer),e.timers.size&&(e.timers.forEach((function(e){clearInterval(e)})),e.timers.clear()),e.ws?e.ws.destroy((function(){e.ws=null,e.emitter=null,e.on=null,e.off=null,e.emit=null,t()})):t()}))}},{key:"startChannelMediaRelay",value:(c=(0,e.Z)(i().mark((function e(t){var n,r,o,s,c,l=this;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.channelMediaRelayController){e.next=2;break}throw new I.ChannelMediaError("RELAY_ALREADY_START","",I.CHANNEL_MEDIA_RELAY_ERROR.RELAY_ALREADY_START);case 2:return n=function(e){l.clientEmitter.emit("channel-media-relay-event",{code:e})},r=function(e,t,n){e===I.CHANNEL_MEDIA_RELAY_STATE.RELAY_STATE_FAILURE&&t===I.CHANNEL_MEDIA_RELAY_ERROR.SERVER_CONNECTION_LOST&&(l.channelMediaRelayController.dispose(),l.channelMediaRelayController=null),l.clientEmitter.emit("channel-media-relay-state",{state:e,code:t,data:n})},o={token:this.appId,appId:this.appId,cname:this.channel,uid:this.uid,sid:this.sid,clientId:this.clientId},this.channelMediaRelayController=new(A())(o,this.clientId),this.channelMediaRelayController.on("event",n),this.channelMediaRelayController.on("state",r),e.prev=8,e.next=11,this.channelMediaRelayController.startChannelMediaRelay(t);case 11:e.next=23;break;case 13:throw e.prev=13,e.t0=e.catch(8),a.default.error("[".concat(this.clientId,"] startChannelMediaRelay exception: ").concat(JSON.stringify(e.t0))),s=I.CHANNEL_MEDIA_RELAY_STATE.RELAY_STATE_FAILURE,"",c=e.t0 instanceof I.ChannelMediaError?"SetSourceChannelStatus"===e.t0.data||e.t0.data&&e.t0.data.serverResponse&&"SetSourceChannel"===e.t0.data.serverResponse.command?"FAILED_JOIN_SRC":"SetDestChannelStatus"===e.t0.data||e.t0.data&&e.t0.data.serverResponse&&"SetDestChannel"===e.t0.data.serverResponse.command?"FAILED_JOIN_DEST":e.t0.data&&e.t0.data.serverResponse&&"StartPacketTransfer"===e.t0.data.serverResponse.command?"FAILED_PACKET_SENT_TO_DEST":e.t0.message===I.CHANNEL_MEDIA_ERROR.REQUEST_TIMEOUT||e.t0.message===I.CHANNEL_MEDIA_ERROR.WAIT_STATUS_TIMEOUT?"SERVER_NO_RESPONSE":e.t0.message===I.CHANNEL_MEDIA_ERROR.REQUEST_FAILED||e.t0.message===I.CHANNEL_MEDIA_ERROR.WAIT_STATUS_ERROR?"SERVER_ERROR_RESPONSE":e.t0.message===I.CHANNEL_MEDIA_ERROR.AP_REQUEST_TIMEOUT?"NO_RESOURCE_AVAILABLE":e.t0.message===I.CHANNEL_MEDIA_ERROR.WS_ABORT||e.t0.message===I.CHANNEL_MEDIA_ERROR.AP_REQUEST_ABORT?"OPERATION_ABORT":"INTERNAL_ERROR":"INTERNAL_ERROR",this.clientEmitter.emit("channel-media-relay-state",{state:s,code:I.CHANNEL_MEDIA_RELAY_ERROR[c]}),this.channelMediaRelayController&&(this.channelMediaRelayController.dispose(),this.channelMediaConfig=null,this.channelMediaRelayController=null),this.clientEmitter.emit("channel-media-relay-state",{state:I.CHANNEL_MEDIA_RELAY_STATE.RELAY_STATE_IDLE}),new I.ChannelMediaError(c,null,I.CHANNEL_MEDIA_RELAY_ERROR[c]);case 23:this.clientEmitter.emit("channel-media-relay-state",{state:I.CHANNEL_MEDIA_RELAY_STATE.RELAY_STATE_RUNNING,code:I.CHANNEL_MEDIA_RELAY_ERROR.RELAY_OK}),this.channelMediaConfig=t;case 25:case"end":return e.stop()}}),e,this,[[8,13]])}))),function(e){return c.apply(this,arguments)})},{key:"updateChannelMediaRelay",value:(s=(0,e.Z)(i().mark((function e(t){var n,r;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.channelMediaRelayController){e.next=2;break}throw new I.ChannelMediaError("RELAY_NOT_START",null,I.CHANNEL_MEDIA_RELAY_ERROR.RELAY_NOT_START);case 2:return e.prev=2,e.next=5,this.channelMediaRelayController.updateChannelMediaRelay(t);case 5:e.next=18;break;case 7:throw e.prev=7,e.t0=e.catch(2),a.default.debug("[".concat(this.clientId,"] updateChannelMediaRelay exception: ").concat(JSON.stringify(e.t0))),n=I.CHANNEL_MEDIA_RELAY_STATE.RELAY_STATE_FAILURE,"",r=e.t0 instanceof I.ChannelMediaError?e.t0.message===I.CHANNEL_MEDIA_ERROR.REQUEST_TIMEOUT||e.t0.message===I.CHANNEL_MEDIA_ERROR.WAIT_STATUS_TIMEOUT?"SERVER_NO_RESPONSE":e.t0.message===I.CHANNEL_MEDIA_ERROR.REQUEST_FAILED||e.t0.message===I.CHANNEL_MEDIA_ERROR.WAIT_STATUS_ERROR?"SERVER_ERROR_RESPONSE":e.t0.message===I.CHANNEL_MEDIA_ERROR.WS_ABORT||e.t0.message===I.CHANNEL_MEDIA_ERROR.AP_REQUEST_ABORT?"OPERATION_ABORT":"INTERNAL_ERROR":"INTERNAL_ERROR",this.clientEmitter.emit("channel-media-relay-event",{code:I.CHANNEL_MEDIA_RELAY_EVENT.PACKET_UPDATE_DEST_CHANNEL_REFUSED}),this.clientEmitter.emit("channel-media-relay-state",{state:n,code:I.CHANNEL_MEDIA_RELAY_ERROR[r]}),this.channelMediaRelayController&&(this.channelMediaRelayController.dispose(),this.channelMediaConfig=null,this.channelMediaRelayController=null),this.clientEmitter.emit("channel-media-relay-state",{state:I.CHANNEL_MEDIA_RELAY_STATE.RELAY_STATE_IDLE}),new I.ChannelMediaError(r,null,I.CHANNEL_MEDIA_RELAY_ERROR[r]);case 18:this.channelMediaConfig=t;case 19:case"end":return e.stop()}}),e,this,[[2,7]])}))),function(e){return s.apply(this,arguments)})},{key:"stopChannelMediaRelay",value:(o=(0,e.Z)(i().mark((function e(){var t,n;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.channelMediaRelayController){e.next=2;break}throw new I.ChannelMediaError("RELAY_NOT_START",null,I.CHANNEL_MEDIA_RELAY_ERROR.RELAY_NOT_START);case 2:return e.prev=2,e.next=5,this.channelMediaRelayController.stopChannelMediaRelay();case 5:e.next=17;break;case 7:throw e.prev=7,e.t0=e.catch(2),a.default.debug("[".concat(this.clientId,"] stopChannelMediaRelay exception: ").concat(JSON.stringify(e.t0))),t=I.CHANNEL_MEDIA_RELAY_STATE.RELAY_STATE_FAILURE,"",n=e.t0 instanceof I.ChannelMediaError?e.t0.message===I.CHANNEL_MEDIA_ERROR.REQUEST_TIMEOUT||e.t0.message===I.CHANNEL_MEDIA_ERROR.WAIT_STATUS_TIMEOUT?"SERVER_NO_RESPONSE":e.t0.message===I.CHANNEL_MEDIA_ERROR.REQUEST_FAILED||e.t0.message===I.CHANNEL_MEDIA_ERROR.WAIT_STATUS_ERROR?"SERVER_ERROR_RESPONSE":"INTERNAL_ERROR":"INTERNAL_ERROR",this.clientEmitter.emit("channel-media-relay-state",{state:t,code:I.CHANNEL_MEDIA_RELAY_ERROR[n]}),this.channelMediaRelayController&&(this.channelMediaRelayController.dispose(),this.channelMediaConfig=null,this.channelMediaRelayController=null),this.emit("channel-media-relay-state",{state:I.CHANNEL_MEDIA_RELAY_STATE.RELAY_STATE_IDLE}),new I.ChannelMediaError(n,null,I.CHANNEL_MEDIA_RELAY_ERROR[n]);case 17:this.channelMediaConfig=null,this.channelMediaRelayController=null;case 19:case"end":return e.stop()}}),e,this,[[2,7]])}))),function(){return o.apply(this,arguments)})}]),r}();var C={videoBitrate:"Miniapp_SDK_Pusher_Video_Bitrate",audioBitrate:"Miniapp_SDK_Pusher_Audio_Bitrate",videoFPS:"Miniapp_SDK_Pusher_Video_FPS",videoGOP:"Miniapp_SDK_Pusher_Video_GOP",netSpeed:"Miniapp_SDK_Pusher_Net_Speed",videoCache:"Miniapp_SDK_Pusher_Video_Cache",audioCache:"Miniapp_SDK_Pusher_Audio_Cache",videoWidth:"Miniapp_SDK_Pusher_Video_Width",videoHeight:"Miniapp_SDK_Pusher_Video_Height",netJitter:"Miniapp_SDK_Pusher_Net_Jitter",netQualityLevel:"Miniapp_SDK_Pusher_Net_QualityLevel"},N={videoBitrate:"Miniapp_SDK_Player_Video_Bitrate",audioBitrate:"Miniapp_SDK_Player_Audio_Bitrate",videoFPS:"Miniapp_SDK_Player_Video_FPS",videoGOP:"Miniapp_SDK_Player_Video_GOP",netSpeed:"Miniapp_SDK_Player_Net_Speed",videoCache:"Miniapp_SDK_Player_Video_Cache",audioCache:"Miniapp_SDK_Player_Audio_Cache",vDecCacheSize:"Miniapp_SDK_Player_V_Dec_Cache_Size",vSumCacheSize:"Miniapp_SDK_Player_V_Sum_Cache_Size",avPlayInterval:"Miniapp_SDK_Player_AV_Play_Interval",avRecvInterval:"Miniapp_SDK_Player_AV_Recv_Interval",audioCacheThreshold:"Miniapp_SDK_Player_Audio_Cache_Threshold",videoWidth:"Miniapp_SDK_Player_Video_Width",videoHeight:"Miniapp_SDK_Player_Video_Height",netJitter:"Miniapp_SDK_Player_Net_Jitter",netQualityLevel:"Miniapp_SDK_Player_Net_QualityLevel"},L=__webpack_require__(699),M=__webpack_require__.n(L),j=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10;if("function"!=typeof e)throw Error("request must be function");var n=function(e,t){!function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;if(null==e)e=1;else if(0===e)throw new Error("Concurrency must not be zero")}(t);var n=[],r=[];return{concurrency:t,push:function(e,t){var r=this;n.push({task:e,callback:t}),setTimeout((function(){r.process()}),0)},process:function(){for(var e=this,t=function(){var t,i=n.shift();r.push(i),function(e,t){e(t)}(i.task,(t=function(){e.pull(i),"function"==typeof i.callback&&i.callback.apply(i,arguments),e.process()},function(){if(null===t)throw new Error("Callback was already called");var e=t;return t=null,e.apply(void 0,arguments)}))};this.concurrency>r.length&&n.length;)t()},pull:function(e){var t=r.indexOf(e);-1!==t&&r.splice(t,1)}}}(0,t);return function(t){n.push((function(n){var r=t.complete;t.complete=function(){n(),"function"==typeof r&&r.apply(void 0,arguments)},e(t)}))}}(wx.request,2);function D(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function x(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?D(Object(n),!0).forEach((function(t){u(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):D(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var B=M().io.agora.pb,U=B.CounterCompact,q=B.Id,J=B.MuteLocal,V=B.MuteRemote,K=B.Join,W=B.Leave,H=B.Publish,Y=B.Unpublish,F=B.Subscribe,Z=B.Unsubscribe,z=B.ConnectWebSocket,G=B.ServerEvent,Q=B.JoinChooseServer,X=B.RenewToken,$=B.SetRemoteVideoStreamType,ee=B.SetRole,te=B.Session,ne=B.PusherState,re=B.PlayerState,ie=function(){function e(){(0,t.Z)(this,e),this.url="https://rest-argus-ad.agoralab.co/v2/report",this.sid=(0,o.generateSessionId)(),this.pusherNet=null,this.playerNetMap={},this.pusherTimer=null,this.playerTimer=null,this.seqId=0,this.startPusherReport(),this.startPlayerReport()}return(0,n.Z)(e,[{key:"setPusherNetData",value:function(e){this.pusherNet=e}},{key:"setPlayerNetData",value:function(e,t){this.playerNetMap[e]=t}},{key:"getMessageTypeId",value:function(e){return q[e]}},{key:"encodePb",value:function(e,t,n){var r=null,i=null;switch(t){case"pusher_net":case"player_net":i=U.create({sid:this.sid,peer:n.peerId,items:n.items}),r=U.encode(i).finish();break;case"api_join":i=K.create({lts:e,sid:this.sid,cname:n.cname,uid:"".concat(n.uid),success:n.success,elapse:n.elapse,ec:n.ec,details:JSON.stringify({seqId:this.seqId++}),isrejoin:n.isrejoin,ip:O().ip}),r=K.encode(i).finish();break;case"api_leave":i=W.create({lts:e,sid:this.sid,cname:n.cname,uid:"".concat(n.uid),success:n.success,elapse:n.elapse,ec:n.ec,details:JSON.stringify({seqId:this.seqId++}),ip:O().ip}),r=W.encode(i).finish();break;case"api_publish":i=H.create({pushurl:n.pushurl,lts:e,sid:this.sid,cname:n.cname,uid:"".concat(n.uid),success:n.success,elapse:n.elapse,ec:n.ec,details:JSON.stringify({seqId:this.seqId++}),ip:O().ip}),r=H.encode(i).finish();break;case"api_unpublish":i=Y.create({lts:e,sid:this.sid,cname:n.cname,uid:"".concat(n.uid),success:n.success,elapse:n.elapse,ec:n.ec,details:JSON.stringify({seqId:this.seqId++}),ip:O().ip}),r=Y.encode(i).finish();break;case"api_subscribe":i=F.create({pullurl:n.pullurl,peer:n.peer,lts:e,sid:this.sid,cname:n.cname,uid:"".concat(n.uid),success:n.success,elapse:n.elapse,ec:n.ec,details:JSON.stringify({seqId:this.seqId++}),ip:O().ip}),r=F.encode(i).finish();break;case"api_unsubscribe":i=Z.create({peer:n.peer,lts:e,sid:this.sid,cname:n.cname,uid:"".concat(n.uid),success:n.success,elapse:n.elapse,ec:n.ec,details:JSON.stringify({seqId:this.seqId++}),ip:O().ip}),r=Z.encode(i).finish();break;case"connect_websocket":i=z.create({lts:e,sid:this.sid,cname:n.cname,cid:null,ip:O().ip,uid:"".concat(n.uid),success:n.success,elapse:n.elapse,peer:null,gateway:n.gateway,ec:n.ec,wsurl:n.wsurl,details:JSON.stringify({seqId:this.seqId++})}),r=z.encode(i).finish();break;case"join_chooseserver":i=Q.create({lts:e,sid:this.sid,cname:n.cname,cid:null,ip:O().ip,uid:"".concat(n.uid),success:n.success,elapse:n.elapse,peer:null,csurl:n.csurl,ec:n.ec,gatewaylist:n.gatewaylist,details:JSON.stringify(x(x({},n.details),{},{seqId:this.seqId++}))}),r=Q.encode(i).finish();break;case"api_muteLocal":i=J.create({lts:e,vid:O().vid,sid:this.sid,cname:n.cname,cid:null,ip:O().ip,uid:"".concat(n.uid),success:n.success,elapse:n.elapse,ec:n.ec,target:n.target,mute:n.mute,details:JSON.stringify(x(x({},n.details),{},{seqId:this.seqId++}))}),r=J.encode(i).finish();break;case"api_muteRemote":i=V.create({lts:e,vid:O().vid,sid:this.sid,cname:n.cname,cid:null,ip:O().ip,uid:"".concat(n.uid),success:n.success,elapse:n.elapse,peer:n.peer,ec:n.ec,target:n.target,mute:n.mute,details:JSON.stringify(x(x({},n.details),{},{seqId:this.seqId++}))}),r=V.encode(i).finish();break;case"api_renewToken":i=X.create({lts:e,vid:O().vid,sid:this.sid,cname:n.cname,cid:null,ip:O().ip,uid:"".concat(n.uid),success:n.success,elapse:n.elapse,ec:n.ec,details:JSON.stringify(x(x({},n.details),{},{seqId:this.seqId++}))}),r=X.encode(i).finish();break;case"api_setRemoteStreamType":i=$.create({lts:e,vid:O().vid,sid:this.sid,cname:n.cname,cid:null,ip:O().ip,uid:"".concat(n.uid),success:n.success,elapse:n.elapse,ec:n.ec,type:n.type,details:JSON.stringify(x(x({},n.details),{},{seqId:this.seqId++}))}),r=$.encode(i).finish();break;case"api_setRole":i=ee.create({lts:e,vid:O().vid,sid:this.sid,cname:n.cname,cid:null,ip:O().ip,uid:"".concat(n.uid),success:n.success,elapse:n.elapse,ec:n.ec,type:n.type,role:n.role,details:JSON.stringify(x(x({},n.details),{},{seqId:this.seqId++}))}),r=ee.encode(i).finish();break;case"session":i=te.create({lts:e,sid:this.sid,cname:null,cid:null,ip:O().ip,uid:null,success:n.success,elapse:n.elapse,peer:null,appid:n.appId,uname:n.uname,ver:n.ver,dk:n.dk,details:JSON.stringify(x(x({},n.details),{},{seqId:this.seqId++}))}),r=te.encode(i).finish();break;case"serverEvent":i=G.create({lts:e,sid:this.sid,cname:n.cname,cid:null,ip:O().ip,uid:"".concat(n.uid),success:n.success,elapse:n.elapse,peer:null,action:n.action,details:JSON.stringify(x(x({},n.details),{},{seqId:this.seqId++})),req_ts:null}),r=G.encode(i).finish();break;case"pusher_state":i=ne.create({lts:e,sid:this.sid,cname:n.cname,cid:null,ip:O().ip,uid:"".concat(n.uid),success:n.success,elapse:n.elapse,peer:null,url:n.url,code:n.code,status:null,error:null,details:JSON.stringify(x(x({},n.details),{},{seqId:this.seqId++}))}),r=ne.encode(i).finish();break;case"player_state":i=re.create({lts:e,sid:this.sid,cname:n.cname,cid:null,ip:O().ip,uid:"".concat(n.uid),success:n.success,elapse:n.elapse,peer:n.peer,url:n.url,code:n.code,status:null,error:null,details:JSON.stringify(x(x({},n.details),{},{seqId:this.seqId++}))}),r=re.encode(i).finish()}return r}},{key:"startPusherReport",value:function(){var e=this;this.pusherTimer=setInterval((function(){var t=Date.now();if(e.pusherNet){var n=[];if(Object.keys(e.pusherNet).map((function(r){if(void 0!==C[r]){var i=q[C[r]];if(void 0!==i){var o={lts:t,id:i,value:e.pusherNet[r],tagErrorCode:6,streamId:0};n.push(o)}}})),0===n.length)return a.default.warn("[argus] no kv exists for pusher data reporting");var r=e.encodePb(t,"pusher_net",{peerId:0,items:n});e.report(t,r,1)}}),6e3)}},{key:"startPlayerReport",value:function(){var e=this;this.playerTimer=setInterval((function(){var t=Date.now();if(e.playerNetMap){var n,r=function(){var n=[],r=e.playerNetMap[i];if(Object.keys(r).map((function(e){if(void 0!==N[e]){var i=q[N[e]];if(void 0!==i){var o={lts:t,id:i,value:r[e],tagErrorCode:6,streamId:0};n.push(o)}}})),0===n.length)return{v:a.default.warn("[argus] no kv exists for live data reporting")};var o=e.encodePb(t,"player_net",{peerId:i,items:n});e.report(t,o,1)};for(var i in e.playerNetMap)if(n=r())return n.v}e.playerNetMap={}}),6e3)}},{key:"_silent_call",value:function(e){var t=this;return function(){try{e.apply(t,arguments)}catch(e){}}}},{key:"reportJoin",value:function(e,t,n,r,i,o,s){this._silent_call(this.reportAPI)("api_join",{cname:e,uid:t,success:n,elapse:r,isrejoin:!1,ec:i,appId:o,wsurl:s},9292)}},{key:"reportRejoin",value:function(e,t,n,r,i,o,s){this._silent_call(this.reportAPI)("api_join",{cname:e,uid:t,success:n,elapse:r,isrejoin:!0,ec:i,appId:o,wsurl:s},9292)}},{key:"reportLeave",value:function(e,t,n,r,i){this._silent_call(this.reportAPI)("api_leave",{cname:e,uid:t,success:n,elapse:r,ec:i},9297)}},{key:"reportPublish",value:function(e,t,n,r,i,o){this._silent_call(this.reportAPI)("api_publish",{pushurl:e,cname:t,uid:n,success:r,elapse:i,ec:o},9293)}},{key:"reportUnPublish",value:function(e,t,n,r,i){this._silent_call(this.reportAPI)("api_unpublish",{cname:e,uid:t,success:n,elapse:r,ec:i},9294)}},{key:"reportSubscribe",value:function(e,t,n,r,i,o,s){this._silent_call(this.reportAPI)("api_subscribe",{pullurl:e,peer:t,cname:n,uid:r,success:i,elapse:o,ec:s},9295)}},{key:"reportUnSubscribe",value:function(e,t,n,r,i,o){this._silent_call(this.reportAPI)("api_unsubscribe",{peer:e,cname:t,uid:n,success:r,elapse:i,ec:o},9296)}},{key:"reportConnectWS",value:function(e,t,n,r,i,o,s){this._silent_call(this.reportAPI)("connect_websocket",{cname:e,uid:t,success:n,elapse:r,ec:i,gateway:o,wsurl:s},9291)}},{key:"reportJoinCS",value:function(e,t,n,r,i,o,s){this._silent_call(this.reportAPI)("join_chooseserver",{cname:e,uid:t,success:n,elapse:r,ec:i,csurl:o,gatewaylist:s},9290)}},{key:"reportMuteLocal",value:function(e,t,n,r,i,o,s){this._silent_call(this.reportAPI)("api_muteLocal",{cname:e,uid:t,success:n,elapse:r,ec:i,target:o,mute:s},9798)}},{key:"reportMuteRemote",value:function(e,t,n,r,i,o,s,a){this._silent_call(this.reportAPI)("api_muteRemote",{cname:e,uid:t,success:n,elapse:r,ec:i,peer:o,target:s,mute:a},9794)}},{key:"reportRenewToken",value:function(e,t,n,r,i){this._silent_call(this.reportAPI)("api_renewToken",{cname:e,uid:t,success:n,elapse:r,ec:i},9800)}},{key:"reportSetRemoteStreamType",value:function(e,t,n,r,i,o){this._silent_call(this.reportAPI)("api_setRemoteStreamType",{cname:e,uid:t,success:n,elapse:r,ec:i,type:o},9799)}},{key:"reportSetRole",value:function(e,t,n,r,i,o){this._silent_call(this.reportAPI)("api_setRole",{cname:e,uid:t,success:n,elapse:r,ec:i,role:"broadcaster"===o?1:2},9801)}},{key:"reportSession",value:function(e,t,n,r,i,o,s,a,c){this._silent_call(this.reportAPI)("session",{cname:e,uid:t,success:n,elapse:r,ec:i,appId:o,uname:s,ver:a,dk:c},9289)}},{key:"reportServerEvent",value:function(e,t,n,r,i,o){this._silent_call(this.reportAPI)("serverEvent",{cname:e,uid:t,success:n,elapse:r,action:i,details:o},9298)}},{key:"reportPusherStateChange",value:function(e,t,n,r,i,o,s){this._silent_call(this.reportAPI)("pusher_state",{cname:e,uid:t,success:n,elapse:r,url:i,code:o,message:s},9300)}},{key:"reportPlayerStateChange",value:function(e,t,n,r,i,o,s,a){this._silent_call(this.reportAPI)("player_state",{peer:e,cname:t,uid:n,success:r,elapse:i,url:o,code:s,message:a},9301)}},{key:"reportAPI",value:function(e,t,n){var r=Date.now(),i=this.encodePb(r,e,t);i&&this.report(r,i,n)}},{key:"destroy",value:function(){null!==this.pusherTimer&&clearInterval(this.pusherTimer),null!==this.playerTimer&&clearInterval(this.playerTimer),this.pusherNet=null,this.playerNet=null}},{key:"report",value:function(e,t,n){var r=wx.arrayBufferToBase64(t),i={id:n,payload:r,qos:1,sign:h()("payload=".concat(r,"&src=miniapp_sdk&ts=").concat(e)),src:"miniapp_sdk",ts:e,vid:O().vid};return this.request({body:i,url:this.url})}},{key:"request",value:function(e){return new Promise((function(t,n){j({url:e.url,data:e.body,timeout:1e4,header:{"Content-Type":"application/json","Request-ID":"".concat((new Date).getTime())},method:"POST",success:function(e){200===e.statusCode||a.default.error("[argus] response fail: ".concat(e.statusCode)),t(e)},fail:function(e){a.default.error("[argus] weixin request argus report fail"),n(e)}})}))}}]),e}(),oe=(0,m.throttle)((function(e,t,n){a.default.info("client update pusher netStatus, ".concat(JSON.stringify(n,(function(e,t){return void 0===t?String(t):t})))),e.reportNetStatus(t,n)}),1e4),se=(0,m.throttle)((function(e,t,n,r){a.default.info("client update player netStatus, uid:".concat(r," ").concat(JSON.stringify(n,(function(e,t){return void 0===t?String(t):t})))),e.reportNetStatus(t,n)}),1e4),ae=function(e){a.default.info("client network status change, ".concat(JSON.stringify(e)))},ce=function(e){a.default.info("client network status weak, ".concat(JSON.stringify(e)))};const le=function(){function r(e){var n=this;(0,t.Z)(this,r),this.emitter=new P,this.on=this.emitter.on,this.off=this.emitter.off,this.sid="",this.pushUrl=null,this.playUrls=new Map,this.servers=e&&e.servers,this.apUrl=e&&e.apUrl,this.role="audience",this.audioCodec=null,this.grafanaReport=new g,this.argusReport=new ie,this.systemInfo={},this.emitter.on("stream-removed",(function(e){n.playUrls&&n.playUrls.delete(e.uid),delete n.argusReport.playerNetMap[e.uid]})),this.targetMap={audio:0,video:1,all:2},this.networkJudge=!1}return(0,n.Z)(r,[{key:"init",value:function(e,t,n){var r=this;return new Promise((function(i,o){if(!e||"string"!=typeof e||"null"===e.toLowerCase()){var c=new Error("Invalid appId");return a.default.error("client init failed: ".concat(c.message)),n&&n(c),void o(c)}r.appId=e.trim(),r.grafanaReport.vid="",r._dealSid();try{r.systemInfo=wx.getSystemInfoSync()}catch(e){console.warn("wx getSystemInfoSync error",JSON.stringify(e))}r.grafanaReport.setOptions({systemInfo:r.systemInfo,appId:r.appId}),r.argusReport.reportSession(null,null,!0,0,null,r.appId,r.systemInfo.platform,s.SDK_VERSION,r.systemInfo.brand+"/"+r.systemInfo.model),a.default.info("client init success"),a.default.info("client systemInfo: ".concat(JSON.stringify(r.systemInfo))),t&&t(),i()}))}},{key:"setAudioCodec",value:function(e){a.default.info("client set audioCodec ".concat(e," success")),this.audioCodec=e}},{key:"setRole",value:function(e,t,n){var r=this;return new Promise((function(i,o){if("broadcaster"!==e&&"audience"!==e){var s=new Error("Invalid role");return a.default.error("client set role: ".concat(e," failed: ").concat(s.message)),n&&n(s),void o(s)}if(r.role=e,r.worker){var c=v.create().start();r.worker.setRole(e).then((function(n){setTimeout((function(){if(!n)return a.default.info("client set role ".concat(e," success")),t&&t(),void i();var o=n["update-url"],s={updateURL:o};a.default.info("client set role ".concat(e," success url: ").concat(o)),t&&t(s),i(s),r.argusReport.reportSetRole(r.channel,r.uid,!0,c.elapse(),null,e),r.grafanaReport.report("set_role",y)}),1)})).catch((function(t){a.default.error("client set role: ".concat(e," failed: ").concat((0,m.stringifyErr)(t))),n&&n(),o(),r.argusReport.reportSetRole(r.channel,r.uid,!1,c.elapse(),JSON.stringify(t),e),r.grafanaReport.report("set_role",_,t.code,null==t?void 0:t.reason)}))}else a.default.info("client set role ".concat(e," success url: ")),t&&t(),i(),r.grafanaReport.report("set_role",y)}))}},{key:"rejoin",value:function(e,t,n,r){var i=this,s=arguments.length>4&&void 0!==arguments[4]&&arguments[4],c=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0,l=arguments.length>6?arguments[6]:void 0,u=arguments.length>7?arguments[7]:void 0;if("function"==typeof s){var p=l,h=u;l=s,u=c,s=p||!1,c=h||0}return new Promise((function(p,h){if(i._dealSid(),i.grafanaReport.onlineUser(),i.worker)return i._startNetworkJudge(),l&&l(),p();if(e){if("string"!=typeof e||"null"===e.toLowerCase()){var d=new Error("Invalid channelKey");return a.default.error("client rejoin channel failed: ".concat(d.message)),u&&u(d),void h(d)}}else e=i.appId;if(!t||"string"!=typeof t||"null"===t.toLowerCase()||t.length>128){var f=new Error("Invalid channel");return a.default.error("client rejoin channel failed: ".concat(f.message)),u&&u(f),void h(f)}if("boolean"!=typeof s){var g=new Error("isAudioOnly should be boolean");return a.default.error("client rejoin channel failed: ".concat(g.message)),u&&u(g),h(g),void i.grafanaReport.report("join",_,"",g.message)}if(1==c){if(!n.trim()){var w=new Error("uid empty");return a.default.error("client rejoin channel failed: ".concat(w.message)),u&&u(w),void h(w)}i.uid=n}else if(i.uid=n||(0,o.random)(1e7),i.uid=Number.parseInt(i.uid),!(0,o.is32Uint)(i.uid)){var O=new Error("Invalid uid type");return a.default.error("client rejoin channel failed: ".concat(O.message)),u&&u(O),void h(O)}i.channel=t,i.worker=new T({appId:i.appId,channel:i.channel,uid:i.uid,sid:i.sid,role:i.role,servers:i.servers,apUrl:i.apUrl,channelKey:e,grafanaReport:i.grafanaReport,argusReport:i.argusReport,audioCodec:i.audioCodec,uidType:c},i.emitter);var E=v.create().start();i.worker.connect().then((function(){return i.worker.rejoin(r,s)})).then((function(e){setTimeout((function(){a.default.info("client rejoin channel success"),l&&l(i.uid),p(i.uid),i.argusReport.reportRejoin(i.channel,i.uid,!0,E.elapse(),null,i.appId,i.worker&&i.worker.getWSUrl()),i.grafanaReport.report("join",y),i._startNetworkJudge()}),1),e&&e.uid&&(i.uid=e.uid,i.worker.uid=e.uid)})).catch((function(e){i.destroy(),a.default.error("client rejoin channel failed: ".concat((0,m.stringifyErr)(e))),u&&u(e),h(e),i.argusReport.reportRejoin(i.channel,i.uid,!1,E.elapse(),JSON.stringify(e),i.appId,i.worker&&i.worker.getWSUrl()),i.grafanaReport.report("join",_,e.code,null==e?void 0:e.reason)}))}))}},{key:"join",value:function(e,t,n){var r=this,i=arguments.length>3&&void 0!==arguments[3]&&arguments[3],s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,c=arguments.length>5?arguments[5]:void 0,l=arguments.length>6?arguments[6]:void 0;if("function"==typeof i){var u=c,p=l;c=i,l=s,i=u||!1,s=p||0}return new Promise((function(u,p){if(r._dealSid(),r.grafanaReport.onlineUser(),r.worker)return a.default.info("client join channel success"),c&&c(),r._startNetworkJudge(),u();if(e){if("string"!=typeof e||"null"===e.toLowerCase()){var h=new Error("Invalid channelKey");return a.default.error("client join channel failed: ".concat(h.message)),l&&l(h),p(h),void r.grafanaReport.report("join",_,"",h.message)}}else e=r.appId;if(!t||"string"!=typeof t||"null"===t.toLowerCase()||t.length>128){var d=new Error("Invalid channel");return a.default.error("client join channel failed: ".concat(d.message)),l&&l(d),p(d),void r.grafanaReport.report("join",_,"",d.message)}if("boolean"!=typeof i){var f=new Error("isAudioOnly should be boolean");return a.default.error("client join channel failed: ".concat(f.message)),l&&l(f),p(f),void r.grafanaReport.report("join",_,"",f.message)}if(1==s){if(!n.trim()){var g=new Error("uid empty");return a.default.error("client join channel failed: ".concat(g.message)),l&&l(g),p(g),void r.grafanaReport.report("join",_,"",g.message)}r.uid=n}else if(r.uid=n||(0,o.random)(1e7),r.uid=Number.parseInt(r.uid),!(0,o.is32Uint)(r.uid)){var w=new Error("Invalid uid type");return a.default.error("client join channel failed: ".concat(w.message)),l&&l(w),p(w),void r.grafanaReport.report("join",_,"",w.message)}r.channel=t,r.worker=new T({appId:r.appId,channel:r.channel,uid:r.uid,sid:r.sid,role:r.role,servers:r.servers,apUrl:r.apUrl,channelKey:e,grafanaReport:r.grafanaReport,argusReport:r.argusReport,audioCodec:r.audioCodec,uidType:s},r.emitter);var O=v.create().start();r.worker.connect().then((function(){return r.worker.join(r.systemInfo.model,r.systemInfo.system,i)})).then((function(e){var t=O.elapse(),n=(0,m.transformElapseStr)(t);setTimeout((function(){a.default.info("client join channel success,time:".concat(t,"ms,elapse:").concat(n)),c&&c(r.uid),u(r.uid),r._startNetworkJudge(),r.argusReport.reportJoin(r.channel,r.uid,!0,t),r.grafanaReport.report("join",y,"","",{elapse:n})}),1),e&&e.uid&&(r.uid=e.uid,r.worker.uid=e.uid)})).catch((function(e){r.destroy(),a.default.error("client join channel failed: ".concat((0,m.stringifyErr)(e))),l&&l(e),p(e),r.argusReport.reportJoin(r.channel,r.uid,!1,O.elapse(),JSON.stringify(e)),r.grafanaReport.report("join",_,null==e?void 0:e.code,null==e?void 0:e.reason)}))}))}},{key:"publish",value:function(e,t){var n=this;return new Promise((function(r,i){n._checkWorker();var o=v.create().start();n.worker.publish().then((function(t){n.pushUrl=t.url,setTimeout((function(){a.default.info("client publish url: ".concat(t.url," success")),e&&e(t.url),r(t.url),n.argusReport.reportPublish(t.url,n.channel,n.uid,!0,o.elapse()),n.grafanaReport.report("publish",y)}),1)})).catch((function(e){a.default.error("client publish failed: ".concat((0,m.stringifyErr)(e))),t&&t(e),i(e),n.argusReport.reportPublish(null,n.channel,n.uid,!1,o.elapse(),JSON.stringify(e)),n.grafanaReport.report("publish",_,e.code,null==e?void 0:e.reason)}))}))}},{key:"unpublish",value:function(e,t){var n=this;return new Promise((function(r,i){n._checkWorker();var o=v.create().start();n.worker.unpublish().then((function(t){n.pushUrl=null,setTimeout((function(){a.default.info("client unpublish success"),e&&e(),r(),n.argusReport.reportUnPublish(n.channel,n.uid,!0,o.elapse()),n.grafanaReport.report("unpublish",y)}),1)})).catch((function(e){a.default.error("client unpublish failed: ".concat((0,m.stringifyErr)(e))),t&&t(e),i(e),n.argusReport.reportUnPublish(n.channel,n.uid,!1,o.elapse(),JSON.stringify(e)),n.grafanaReport.report("unpublish",_,e.code,null==e?void 0:e.reason)}))}))}},{key:"subscribe",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{audio:!0,video:!0},r=arguments.length>2?arguments[2]:void 0,i=arguments.length>3?arguments[3]:void 0;if("function"==typeof n){var o=i;i=r,r=n,n=o||{audio:!0,video:!0}}return new Promise((function(o,s){t._checkUid(e),t._checkWorker();var c=v.create().start();t.worker.subscribe(e,n).then((function(n){t.playUrls.set(e,n.url),setTimeout((function(){a.default.info("client stream ".concat(e," subscribed successful")),r&&r(n.url,n.rotation),o({url:n.url,rotation:n.rotation}),t.argusReport.reportSubscribe(n.url,e,t.channel,t.uid,!0,c.elapse()),t.grafanaReport.report("subscribe",y)}),1)})).catch((function(n){a.default.error("client stream ".concat(e," subscribed failed: ").concat((0,m.stringifyErr)(n))),i&&i(n),s(n),t.argusReport.reportSubscribe(null,e,t.channel,t.uid,!1,c.elapse(),JSON.stringify(n)),t.grafanaReport.report("subscribe",_,n.code,null==n?void 0:n.reason)}))}))}},{key:"unsubscribe",value:function(e,t,n){var r=this;return new Promise((function(i,o){r._checkUid(e),r._checkWorker();var s=v.create().start();r.worker.unsubscribe(e).then((function(n){r.playUrls.delete(e),setTimeout((function(){a.default.info("client unsubscribe ".concat(e," successful")),t&&t(),i(),r.argusReport.reportUnSubscribe(e,r.channel,r.uid,!0,s.elapse(),null),r.grafanaReport.report("unsubscribe",y)}),1)})).catch((function(t){a.default.error("client unsubscribe ".concat(e," failed: ").concat((0,m.stringifyErr)(t))),n&&n(t),o(t),r.argusReport.reportUnSubscribe(e,r.channel,r.uid,!1,s.elapse(),JSON.stringify(t)),r.grafanaReport.report("unsubscribe",_,t.code,null==t?void 0:t.reason)}))}))}},{key:"mute",value:function(e,t,n,r){var i=this;return new Promise((function(o,s){if(i._checkUid(e),i._checkWorker(),"video"!==t&&"audio"!==t&&"all"!==t){var c=new Error('target should be "video", "audio" or "all"');return a.default.error("client mute ".concat(e," failed: ").concat(c.message)),r&&r(c),void s(c)}var l=v.create().start();i.worker.mute(e,t).then((function(r){setTimeout((function(){a.default.info("client mute ".concat(e," ").concat(t," success")),n&&n(),o(),i.argusReport.reportMuteRemote(i.channel,i.uid,!0,l.elapse(),null,e,i.targetMap[t],1),i.grafanaReport.report("mute",y)}),1)})).catch((function(n){a.default.error("client mute ".concat(e," ").concat(t," failed: ").concat((0,m.stringifyErr)(n))),r&&r(n),s(n),i.argusReport.reportMuteRemote(i.channel,i.uid,!1,l.elapse(),JSON.stringify(n),e,i.targetMap[t],1),i.grafanaReport.report("mute",_,n.code,null==n?void 0:n.reason)}))}))}},{key:"unmute",value:function(e,t,n,r){var i=this;return new Promise((function(o,s){if(i._checkUid(e),i._checkWorker(),"video"!==t&&"audio"!==t&&"all"!==t){var c=new Error('target should be "video", "audio" or "all"');return a.default.error("client unmute ".concat(e," ").concat(t," failed: ").concat(c.message)),r&&r(c),void s(c)}var l=v.create().start();i.worker.unmute(e,t).then((function(r){setTimeout((function(){a.default.info("client unmute ".concat(e," ").concat(t," success")),n&&n(),o(),i.argusReport.reportMuteRemote(i.channel,i.uid,!0,l.elapse(),null,e,i.targetMap[t],-1),i.grafanaReport.report("unmute",y)}),1)})).catch((function(n){a.default.error("client unmute ".concat(e," ").concat(t," failed: ").concat((0,m.stringifyErr)(n))),r&&r(n),s(n),i.argusReport.reportMuteRemote(i.channel,i.uid,!1,l.elapse(),JSON.stringify(n),e,i.targetMap[t],-1),i.grafanaReport.report("unmute",_,n.code,null==n?void 0:n.reason)}))}))}},{key:"setRemoteVideoStreamType",value:function(e,t,n,r){var i=this;return new Promise((function(o,s){i._checkUid(e),i._checkWorker();var c=v.create().start();i.worker.setRemoteVideoStreamType(e,t).then((function(r){setTimeout((function(){a.default.info("client set remoteVideoStreamType ".concat(e," ").concat(t," success")),n&&n(),o(),i.argusReport.reportSetRemoteStreamType(i.channel,i.uid,!0,c.elapse(),null,t),i.grafanaReport.report("set_remote_stream_type",y)}),1)})).catch((function(n){a.default.error("client set remoteVideoStreamType ".concat(e," ").concat(t," failed: ").concat((0,m.stringifyErr)(n))),r&&r(n),s(n),i.argusReport.reportSetRemoteStreamType(i.channel,i.uid,!1,c.elapse(),JSON.stringify(n),t),i.grafanaReport.report("set_remote_stream_type",_,n.code,null==n?void 0:n.reason)}))}))}},{key:"renewToken",value:function(e,t,n){var r=this;return new Promise((function(i,o){r._checkWorker();var s=v.create().start();r.worker.renewToken(e).then((function(e){setTimeout((function(){a.default.info("client renew token success"),t&&t(),i(),r.argusReport.reportRenewToken(r.channel,r.uid,!0,s.elapse(),null),r.grafanaReport.report("renew_token",y)}),1)})).catch((function(e){a.default.error("client renew token failed: ".concat((0,m.stringifyErr)(e))),n&&n(e),o(e),r.argusReport.reportRenewToken(r.channel,r.uid,!1,s.elapse(),JSON.stringify(e)),r.grafanaReport.report("renew_token",_,e.code,null==e?void 0:e.reason)}))}))}},{key:"muteLocal",value:function(e,t,n){var r=this;return new Promise((function(i,o){if(r._checkWorker(),"video"!==e&&"audio"!==e&&"all"!==e){var s=new Error('target should be "video", "audio" or "all"');return a.default.error("client muteLocal failed: ".concat(s.message)),n&&n(s),void o(s)}var c=v.create().start();r.worker.muteLocal(e).then((function(n){setTimeout((function(){a.default.info("client muteLocal ".concat(e," success")),t&&t(),i(),r.argusReport.reportMuteLocal(r.channel,r.uid,!0,c.elapse(),null,r.targetMap[e],1),r.grafanaReport.report("mute_local",y)}),1)})).catch((function(t){a.default.error("client muteLocal ".concat(e," failed: ").concat((0,m.stringifyErr)(t))),n&&n(t),o(t),r.argusReport.reportMuteLocal(r.channel,r.uid,!1,c.elapse(),JSON.stringify(t),r.targetMap[e],1),r.grafanaReport.report("mute_local",_,t.code,null==t?void 0:t.reason)}))}))}},{key:"unmuteLocal",value:function(e,t,n){var r=this;return new Promise((function(i,o){if(r._checkWorker(),"video"!==e&&"audio"!==e&&"all"!==e){var s=new Error('target should be "video", "audio" or "all"');return a.default.error("client unmuteLocal failed: ".concat(s.message)),n&&n(s),void o(s)}var c=v.create().start();r.worker.unmuteLocal(e).then((function(n){setTimeout((function(){a.default.info("client unmuteLocal ".concat(e," success")),t&&t(),i(),r.argusReport.reportMuteLocal(r.channel,r.uid,!0,c.elapse(),null,r.targetMap[e],-1),r.grafanaReport.report("unmute_local",y)}),1)})).catch((function(t){a.default.error("client unmuteLocal ".concat(e," failed: ").concat((0,m.stringifyErr)(t))),n&&n(t),o(t),r.argusReport.reportMuteLocal(r.channel,r.uid,!1,c.elapse(),JSON.stringify(t),r.targetMap[e],-1),r.grafanaReport.report("unmute_local",_,t.code,null==t?void 0:t.reason)}))}))}},{key:"leave",value:function(t,n){var r=this;return new Promise((function(o,s){if(r.worker&&r.worker.isWSConnected()){var c=v.create().start();r.worker.leave().then(function(){var n=(0,e.Z)(i().mark((function e(n){return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r.argusReport.reportLeave(r.channel,r.uid,!0,c.elapse()),r.grafanaReport.report("leave",y),e.next=4,r.destroy();case 4:setTimeout((function(){a.default.info("client leave success"),t&&t(),o()}),1);case 5:case"end":return e.stop()}}),e)})));return function(e){return n.apply(this,arguments)}}()).catch((function(e){a.default.error("client leave failed: ".concat((0,m.stringifyErr)(e))),n&&n(e),s(e),r.argusReport.reportLeave(r.channel,r.uid,!1,c.elapse(),JSON.stringify(e)),r.grafanaReport.report("leave",_,e.code,null==e?void 0:e.reason)}))}else a.default.info("client leave success without worker"),t&&t(),o(),r._stopNetworkJudge(),r._resetData()}))}},{key:"isConnected",value:function(){return!(!this.worker||!this.worker.isWSConnected())}},{key:"updatePusherStateChange",value:function(e){if(this.pushUrl){var t=e.detail.code,n=e.detail.message;a.default.info("client update pusher state, code:".concat(t," message:").concat(n)),this.argusReport.reportPusherStateChange(this.channel,this.uid,t>=1002,0,this.pushUrl,t,{message:n}),1002===t?this.grafanaReport.report("pusher_state_change",y,t,n):-1307===t&&this.grafanaReport.report("pusher_state_change",_,t,n)}}},{key:"updatePlayerStateChange",value:function(e,t){var n=this.playUrls.get(Number(e));if(n){var r=t.detail.code,i=t.detail.message;if(a.default.info("client update player state, uid:".concat(e," code:").concat(r," message:").concat(i)),this.argusReport.reportPlayerStateChange(e,this.channel,this.uid,r>=2002,0,n,r,{message:i}),2003===r||-2301===r){var o=2003===r?y:_;this.grafanaReport.report("player_state_change",o,r,i)}}}},{key:"updatePusherNetStatus",value:function(e){if(this.pushUrl){var t=e.detail.info;this.argusReport.setPusherNetData(t),oe(this.grafanaReport,0,t)}}},{key:"updatePlayerNetStatus",value:function(e,t){if(this.playUrls.get(Number(e))){var n=t.detail.info;this.argusReport.setPlayerNetData(e,n),se(this.grafanaReport,1,n,e)}}},{key:"send",value:function(e,t,n){var r=this;return new Promise((function(i,o){r._checkWorker(),r.worker.send(e).then((function(e){t&&t(e),i(e)})).catch((function(e){n&&n(e),o(e)}))}))}},{key:"updatePushUrl",value:function(e,t){var n=this;return new Promise((function(r,i){n._checkWorker(),n.worker.updatePushUrl().then((function(t){setTimeout((function(){a.default.info("client updatePushUrl success"),e&&e(t),r(t),n.grafanaReport.report("update_url",y)}),1)})).catch((function(e){a.default.error("client updatePushUrl failed: ".concat((0,m.stringifyErr)(e))),t&&t(e),i(e),n.grafanaReport.report("update_url",_,e.code,null==e?void 0:e.reason)}))}))}},{key:"destroy",value:function(e,t){var n=this;return new Promise((function(r,i){n.worker?n.worker.destroy().then((function(){n.pushUrl=null,n.playUrls.clear(),a.default.info("client destroy success"),e&&e(),r()})).catch((function(e){a.default.error("client destroy failed: ".concat((0,m.stringifyErr)(e))),t&&t(e),i(e)})).finally((function(){n.worker=null,n._stopNetworkJudge(),n._resetData()})):(n.pushUrl=null,n.playUrls.clear(),a.default.info("client destroy success without worker"),e&&e(),r(),n._stopNetworkJudge(),n._resetData()),n.grafanaReport.destroy(),n.argusReport.destroy()}))}},{key:"startChannelMediaRelay",value:function(e,t){if(!(e instanceof I.ChannelMediaRelayConfiguration))throw"Configration should be instance of [ChannelMediaRelayConfiguration]";var n=e.getSrcChannelMediaInfo(),r=e.getDestChannelMediaInfos();if((0,m.isEmpty)(n))throw"srcChannelMediaInfo should not be empty";if((0,m.isEmpty)(r)||0===r.length)throw"destChannelMediaInfos should not be empty";if(a.default.info("[startChannelMediaRelay]: srcInfo: ",n," destInfo: ",r),!(0,o.is32Uint)(n.uid))throw"Invalid uid in srcChannelMediaInfo";if(!(0,m.isValidChannelName)(n.channelName))throw"Invalid channelName in srcChannelMediaInfo";if(n.token&&!(0,m.isValidToken)(n.token))throw"Invalid token in srcChannelMediaInfo";if(r.forEach((function(e){if(!(0,o.is32Uint)(e.uid))throw"Invalid uid in destChannelMediaInfo";if(!(0,m.isValidChannelName)(e.channelName))throw"Invalid channelName in destChannelMediaInfo";if(e.token&&!(0,m.isValidToken)(e.token))throw"Invalid token in destChannelMediaInfo"})),!this.worker)throw"startChannelMediaRelay should be used after join";this.worker.startChannelMediaRelay(e).then((function(){a.default.info("client startChannelMediaRelay success"),t&&t()})).catch((function(e){a.default.error("client startChannelMediaRelay failed: ".concat((0,m.stringifyErr)(e))),t&&t(e)}))}},{key:"updateChannelMediaRelay",value:function(e,t){if(!(e instanceof I.ChannelMediaRelayConfiguration))throw"Configration should be instance of [ChannelMediaRelayConfiguration]";var n=e.getSrcChannelMediaInfo(),r=e.getDestChannelMediaInfos();if((0,m.isEmpty)(n))throw"srcChannelMediaInfo should not be empty";if((0,m.isEmpty)(r)||0===r.length)throw"destChannelMediaInfos should not be empty";if(a.default.info("[updateChannelMediaRelay]: srcInfo: ",n," destInfo: ",r),!(0,o.is32Uint)(n.uid))throw"Invalid uid in srcChannelMediaInfo";if(!(0,m.isValidChannelName)(n.channelName))throw"Invalid channelName in srcChannelMediaInfo";if(n.token&&!(0,m.isValidToken)(n.token))throw"Invalid token in srcChannelMediaInfo";if(r.forEach((function(e){if(!(0,o.is32Uint)(e.uid))throw"Invalid uid in destChannelMediaInfo";if(!(0,m.isValidChannelName)(e.channelName))throw"Invalid channelName in destChannelMediaInfo";if(e.token&&!(0,m.isValidToken)(e.token))throw"Invalid token in destChannelMediaInfo"})),!this.worker)throw"updateChannelMediaRelay should be used after join";this.worker.updateChannelMediaRelay(e).then((function(){a.default.info("client updateChannelMediaRelay success"),t&&t()})).catch((function(e){a.default.error("client updateChannelMediaRelay failed: ".concat((0,m.stringifyErr)(e))),t&&t(e)}))}},{key:"stopChannelMediaRelay",value:function(e){a.default.info("[stopChannelMediaRelay]"),this.worker.stopChannelMediaRelay().then((function(){a.default.info("client stopChannelMediaRelay success"),e&&e()})).catch((function(t){a.default.error("client stopChannelMediaRelay failed: ".concat((0,m.stringifyErr)(t))),e&&e(t)}))}},{key:"_checkUid",value:function(e){if(!e||"number"!=typeof e||!(0,o.is32Uint)(e)){var t=new Error("Invalid uid type");throw a.default.error("client ".concat(t.message)),t}}},{key:"_checkWorker",value:function(){if(!this.worker||!this.worker.isWSConnected()){var e=new Error("Disconnected from server");throw a.default.error("client ".concat(e.message)),e}}},{key:"_dealSid",value:function(){this.sid||(this.sid=(0,o.generateSessionId)(),this.argusReport.sid=this.sid,a.default.setOptions({appId:this.appId,sid:this.sid}),a.default.info("client sid: ".concat(this.sid)))}},{key:"_startNetworkJudge",value:function(){this.networkJudge||(this.networkJudge=!0,a.default.info("client start network judge"),wx.onNetworkStatusChange(ae),wx.onNetworkWeakChange(ce))}},{key:"_stopNetworkJudge",value:function(){this.networkJudge&&(this.networkJudge=!1,a.default.info("client stop network judge"),wx.offNetworkStatusChange(ae),wx.offNetworkWeakChange(ce))}},{key:"_resetData",value:function(){this.sid=""}}]),r}()})(),__webpack_exports__})()));