UNPKG

zego-express-engine-webrtc

Version:

zego webrtc express sdk

1 lines 1.65 MB
!function(t,i){if("object"==typeof exports&&"object"==typeof module)module.exports=i(require("long"),require("protobufjs/minimal"),require("zego-express-logger"),require("localforage"));else if("function"==typeof define&&define.amd)define(["long","protobufjs/minimal","zego-express-logger","localforage"],i);else{var n="object"==typeof exports?i(require("long"),require("protobufjs/minimal"),require("zego-express-logger"),require("localforage")):i(t.long,t["protobufjs/minimal"],t["zego-express-logger"],t.localforage);for(var e in n)("object"==typeof exports?exports:t)[e]=n[e]}}(Object("undefined"!=typeof self?self:this),function(t,i,n,e){return function(){var r={477:function(){},754:function(t,i,n){var e;t.exports=(e=n(9021),function(){var t=e.lib.WordArray;function i(i,n,e){for(var r=[],s=0,o=0;o<n;o++)if(o%4){var u=e[i.charCodeAt(o-1)]<<o%4*2,a=e[i.charCodeAt(o)]>>>6-o%4*2;r[s>>>2]|=(u|a)<<24-s%4*8,s++}return t.create(r,s)}e.enc.Base64={stringify:function(t){var i=t.words,n=t.sigBytes,e=this._map;t.clamp();for(var r=[],s=0;s<n;s+=3)for(var o=(i[s>>>2]>>>24-s%4*8&255)<<16|(i[s+1>>>2]>>>24-(s+1)%4*8&255)<<8|i[s+2>>>2]>>>24-(s+2)%4*8&255,u=0;u<4&&s+.75*u<n;u++)r.push(e.charAt(o>>>6*(3-u)&63));var a=e.charAt(64);if(a)for(;r.length%4;)r.push(a);return r.join("")},parse:function(t){var n=t.length,e=this._map,r=this._reverseMap;if(!r){r=this._reverseMap=[];for(var s=0;s<e.length;s++)r[e.charCodeAt(s)]=s}var o=e.charAt(64);if(o){var u=t.indexOf(o);-1!==u&&(n=u)}return i(t,n,r)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),e.enc.Base64)},757:function(t,i,n){"undefined"!=typeof self&&self,t.exports=function(t,i,n,e){return s=[function(t,i,n){Object.defineProperty(i,"u",{value:!0}),i.LinkedList=i.ListNode=i.ENUM_NETWORK_STATE=i.SOCKET_DISCONNECT=i.errorList=i.Queue=i.getSeq=i.E_CLIENT_TYPE=i.ENUM_LOG_LEVEL=i.ZEGO_BROWSER_TYPE=i.ZEGO_ENV=i.PROTO_VERSION=void 0,i.PROTO_VERSION="1.0.8",(r=i.ZEGO_ENV||(i.ZEGO_ENV={}))[r.BROWSER=0]="BROWSER",r[r.WEIXINMINI=1]="WEIXINMINI",(r=i.ZEGO_BROWSER_TYPE||(i.ZEGO_BROWSER_TYPE={}))[r.IE=0]="IE",r[r.FIREFOX=1]="FIREFOX",r[r.CHROME=2]="CHROME",r[r.SAFARI=3]="SAFARI",r[r.OPERA=4]="OPERA",r[r.WEIXIN=5]="WEIXIN",r[r.WEIXINMINI=6]="WEIXINMINI",r[r.UNKOWN=7]="UNKOWN",i.ENUM_LOG_LEVEL={DEBUG:0,INFO:1,WARN:2,ERROR:3,REPORT:99,DISABLE:100,debug:0,info:1,warn:2,error:3,report:99,disable:100},(r=i.E_CLIENT_TYPE||(i.E_CLIENT_TYPE={}))[r.ClientType_None=0]="ClientType_None",r[r.ClientType_H5=1]="ClientType_H5",r[r.ClientType_SmallPragram=2]="ClientType_SmallPragram",r[r.ClientType_Webrtc=3]="ClientType_Webrtc",i.getSeq=(e=1,function(){return e++}),s.prototype.isEmpty=function(){return 0==this.items.length},s.prototype.enqueue=function(t){this.items.push(t)},s.prototype.dequeue=function(){return this.isEmpty()?"Underflow":this.items.shift()},s.prototype.front=function(){return this.isEmpty()?"No elements in Queue":this.items[0]},s.prototype.size=function(){return this.items.length},s.prototype.clear=function(){this.items=[]},s.prototype.all=function(){return this.items};var e,r=s;function s(){this.items=[],this.items=[]}i.Queue=r,i.errorList={TIMEOUT:{code:100001,msg:"network timeout"},DATAEXIST:{code:100002,msg:"data exist"},BROKEN:{code:100003,msg:"network broken"}},i.SOCKET_DISCONNECT=-1,(r=i.ENUM_NETWORK_STATE||(i.ENUM_NETWORK_STATE={}))[r.offline=0]="offline",r[r.online=1]="online",Object.defineProperty(u.prototype,"id",{get:function(){return this.h||null},set:function(t){this.h=t},enumerable:!1,configurable:!0}),Object.defineProperty(u.prototype,"data",{get:function(){return this.v},set:function(t){this.v=t},enumerable:!1,configurable:!0}),u.prototype.hasNext=function(){return this.next&&this.next.id},u.prototype.hasPrev=function(){return this.prev&&this.prev.id};var o=u;function u(t,i){void 0===t&&(t=null),void 0===i&&(i=null),this.next=null,this.prev=null,this.h=t,this.v=i}function a(){this.start=new o,this.end=new o,this.g=0,this.O=0,this.start.next=this.end,this.start.prev=null,this.end.prev=this.start,this.end.next=null}i.ListNode=o,a.prototype.insertBefore=function(t,i){return(i=new o(this.g,i)).next=t,i.prev=t.prev,t.prev&&(t.prev.next=i),t.prev=i,++this.g,++this.O,i},a.prototype.addLast=function(t){return this.insertBefore(this.end,t)},a.prototype.add=function(t){return this.addLast(t)},a.prototype.getFirst=function(){return 0===this.O?null:this.start.next},a.prototype.getLast=function(){return 0===this.O?null:this.end.prev},a.prototype.size=function(){return this.O},a.prototype.getFromFirst=function(t){var i=0,n=this.start.next;if(0<=t)for(;i<t&&null!==n;)n=n.next,++i;else n=null;if(null===n)throw"Index out of bounds.";return n},a.prototype.get=function(t){return 0===t?this.getFirst():t===this.O-1?this.getLast():this.getFromFirst(t)},a.prototype.remove=function(t){return t.prev&&(t.prev.next=t.next),t.next&&(t.next.prev=t.prev),--this.O,t},a.prototype.removeFirst=function(){return 0<this.O&&this.start.next?this.remove(this.start.next):null},a.prototype.removeLast=function(){return 0<this.O&&this.end.prev?this.remove(this.end.prev):null},a.prototype.removeAll=function(){this.start.next=this.end,this.end.prev=this.start,this.O=0,this.g=0},a.prototype.each=function(t){for(var i=this.start;i.hasNext();)t(i=i.next)},a.prototype.find=function(t){for(var i=this.start,n=!1,e=null;i.hasNext()&&!n;)t(i=i.next)&&(e=i,n=!0);return e},a.prototype.map=function(t){for(var i=this.start,n=[];i.hasNext();)t(i=i.next)&&n.push(i);return n},a.prototype.push=function(t){return this.addLast(t)},a.prototype.unshift=function(t){this.insertBefore(0<this.O?this.start.next:this.end,t)},a.prototype.pop=function(){return this.removeLast()},a.prototype.shift=function(){return this.removeFirst()},i.LinkedList=a},function(t,i,n){var e=this&&this.__read||function(t,i){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var e,r,s=n.call(t),o=[];try{for(;(void 0===i||0<i--)&&!(e=s.next()).done;)o.push(e.value)}catch(t){r={error:t}}finally{try{e&&!e.done&&(n=s.return)&&n.call(s)}finally{if(r)throw r.error}}return o},r=this&&this.__spread||function(){for(var t=[],i=0;i<arguments.length;i++)t=t.concat(e(arguments[i]));return t},s=(Object.defineProperty(i,"u",{value:!0}),i.ContextAPI=i.suppressInstrumentation=i.ROOT_CONTEXT=i.BaseContext=i.setSpan=i.getSpanContext=i.getSpan=i.createContextKey=void 0,n(17));function o(t){return Symbol.for(t)}var u=(i.createContextKey=o)("OpenTelemetry Context Key SUPPRESS_INSTRUMENTATION"),a=o("OpenTelemetry Context Key SPAN");function c(t){return t.getValue(a)||void 0}function h(t){this._=t,this.S=new s.StackContextManager}i.getSpan=c,i.getSpanContext=function(t){return null==(t=c(t))?void 0:t.context()},i.setSpan=function(t,i){return t.setValue(a,i)},i.BaseContext=n=function t(i){var n=this;n.M=i?new Map(i):new Map,n.getValue=function(t){return n.M.get(t)},n.setValue=function(i,e){var r=new t(n.M);return r.M.set(i,e),r},n.deleteValue=function(i){var e=new t(n.M);return e.M.delete(i),e}},i.ROOT_CONTEXT=new n,i.suppressInstrumentation=function(t){return t.setValue(u,!0)},h.getInstance=function(t){return void 0===t&&(t="context"),this.j||(this.j=new h(t)),this.j},h.prototype.active=function(){return this.S.active()},h.prototype.with=function(t,i,n){for(var e,s=[],o=3;o<arguments.length;o++)s[o-3]=arguments[o];return(e=this.T()).with.apply(e,r([t,i,n],s))},h.prototype.T=function(){return this.S},i.ContextAPI=h},function(t,i,n){var e,r;Object.defineProperty(i,"u",{value:!0}),i.INVALID_SPAN_CONTEXT=i.INVALID_TRACEID=i.INVALID_SPANID=i.TraceFlags=i.SpanKind=i.SpanStatusCode=void 0,(e=i.SpanStatusCode||(i.SpanStatusCode={}))[e.UNSET=0]="UNSET",e[e.OK=1]="OK",e[e.ERROR=2]="ERROR",(e=i.SpanKind||(i.SpanKind={}))[e.INTERNAL=0]="INTERNAL",e[e.SERVER=1]="SERVER",e[e.CLIENT=2]="CLIENT",e[e.PRODUCER=3]="PRODUCER",e[e.CONSUMER=4]="CONSUMER",(r=e=i.TraceFlags||(i.TraceFlags={}))[r.NONE=0]="NONE",r[r.SAMPLED=1]="SAMPLED",i.INVALID_SPANID="0000000000000000",i.INVALID_TRACEID="00000000000000000000000000000000",i.INVALID_SPAN_CONTEXT={traceId:i.INVALID_TRACEID,spanId:i.INVALID_SPANID,traceFlags:e.NONE}},function(t,i,n){Object.defineProperty(i,"u",{value:!0}),i.log=i.ZegoLog=void 0,r.prototype.log=function(){for(var t=[],i=0;i<arguments.length;i++)t[i]=arguments[i];var n=t.join("");console.log(n)},r.prototype.debug=function(){for(var t=[],i=0;i<arguments.length;i++)t[i]=arguments[i];var n=t.join("");console.debug(n)},r.prototype.info=function(){for(var t=[],i=0;i<arguments.length;i++)t[i]=arguments[i];var n=t.join("");console.info(n)},r.prototype.warn=function(){for(var t=[],i=0;i<arguments.length;i++)t[i]=arguments[i];var n=t.join("");console.warn(n)},r.prototype.error=function(){for(var t=[],i=0;i<arguments.length;i++)t[i]=arguments[i];var n=t.join("");console.error(n)};var e=r;function r(){}e=new(i.ZegoLog=e),i.log=e},function(t,i,n){Object.defineProperty(i,"u",{value:!0}),i.FAIL_TIME=i.FAIL_MAX_COUNT=i.FAIL_COUNT=i.STORE_SIZE=i.CACHE_SIZE=i.BUCKET_CONFIG=i.DEFAULT_CONFIG=void 0,i.DEFAULT_CONFIG={importantLevel:0,reportSize:3e3,reportNum:10,bps:16e3,netTimeout:10},i.BUCKET_CONFIG={bucketSize:1e4,tokensPerInterval:1600},i.CACHE_SIZE={totalAvailCache:102400,cacheMaxSize:2e4,cacheDelPer:.2},i.STORE_SIZE={totalDBSize:2048e3,storeDelPer:.2},i.FAIL_COUNT=5,i.FAIL_MAX_COUNT=10,i.FAIL_TIME=30},function(t,i,n){var e=this&&this.__importDefault||function(t){return t&&t.u?t:{default:t}},r=(Object.defineProperty(i,"u",{value:!0}),i.uuid=i.calculateMemSize=i.analyzeKey=i.getCurrentTime=i.getCurrentEnv=i.getBrowser=void 0,n(0)),s=e(n(31)),o=(i.getBrowser=function(){var t=window.navigator.userAgent,i=null!=window.ActiveXObject&&-1!=t.indexOf("MSIE"),n=-1!=t.indexOf("Firefox"),e=null!=window.opr,s=t.indexOf("Chrome")&&window.chrome,o=-1!=t.indexOf("Safari")&&-1!=t.indexOf("Version");return t=t.toLowerCase().match(/MicroMessenger/i)&&"micromessenger"===t.toLowerCase().match(/MicroMessenger/i)[0],i?r.ZEGO_BROWSER_TYPE.IE:n?r.ZEGO_BROWSER_TYPE.FIREFOX:e?r.ZEGO_BROWSER_TYPE.OPERA:s?r.ZEGO_BROWSER_TYPE.CHROME:o?r.ZEGO_BROWSER_TYPE.SAFARI:t?r.ZEGO_BROWSER_TYPE.WEIXIN:r.ZEGO_BROWSER_TYPE.UNKOWN},i.getCurrentEnv=function(){var t=window.navigator.userAgent;return new Promise(function(i){-1==t.indexOf("MicroMessage")?i(r.ZEGO_ENV.BROWSER):wx.miniProgram.getEnv(function(t){})})},["00","01","02","03","04","05","06","07","08","09"]);i.getCurrentTime=function(){var t=new Date;return[t.getFullYear()+"/",(o[t.getMonth()+1]||t.getMonth()+1)+"/",(o[t.getDate()]||t.getDate())+" ",(o[t.getHours()]||t.getHours())+":",(o[t.getMinutes()]||t.getMinutes())+":",o[t.getSeconds()]||t.getSeconds(),"."+t.getTime()%1e3].join("")},i.analyzeKey=function(t){return t=t.split("_"),{level:Number(t[0]),timestamp:t[1],seq:t[2]}},i.calculateMemSize=function(t){return s.default(t)},i.uuid=function(t,i){var n,e,r="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),s=[];if(i=i||r.length,t)for(n=0;n<t;n++)s[n]=r[0|Math.random()*i];else for(s[8]=s[13]=s[18]=s[23]="-",s[14]="4",n=0;n<36;n++)s[n]||(e=0|16*Math.random(),s[n]=r[19==n?3&e|8:e]);return s.join("")}},function(t,i,n){var e=this&&this.__values||function(t){var i="function"==typeof Symbol&&Symbol.iterator,n=i&&t[i],e=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return{value:(t=t&&e>=t.length?void 0:t)&&t[e++],done:!t}}};throw new TypeError(i?"Object is not iterable.":"Symbol.iterator is not defined.")},r=this&&this.__read||function(t,i){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var e,r,s=n.call(t),o=[];try{for(;(void 0===i||0<i--)&&!(e=s.next()).done;)o.push(e.value)}catch(t){r={error:t}}finally{try{e&&!e.done&&(n=s.return)&&n.call(s)}finally{if(r)throw r.error}}return o};function s(t){var i,n,r;if(null!=t&&Array.isArray(t))try{for(var s=e(t),o=s.next();!o.done;o=s.next()){var u=o.value;if(null!=u)if(r){if(typeof u!==r)return!1}else r=typeof u}}catch(t){i={error:t}}finally{try{o&&!o.done&&(n=s.return)&&n.call(s)}finally{if(i)throw i.error}}return!0}Object.defineProperty(i,"u",{value:!0}),i.sanitizeAttributes=i.isAttributeValue=void 0,i.isAttributeValue=s,i.sanitizeAttributes=function(t){var i,n,o={};if(null!=t&&"object"==typeof t)try{for(var u=e(Object.entries(t)),a=u.next();!a.done;a=u.next()){var c=r(a.value,2),h=c[0],f=c[1];s(f)&&(o[h]=Array.isArray(f)?f.slice():f)}}catch(t){i={error:t}}finally{try{a&&!a.done&&(n=u.return)&&n.call(u)}finally{if(i)throw i.error}}return o}},function(t,i,n){Object.defineProperty(i,"u",{value:!0}),i.IdGenerator=void 0;var e=Array(32);function r(t){return function(){for(var i=0;i<2*t;i++)e[i]=Math.floor(16*Math.random())+48,58<=e[i]&&(e[i]+=39);return String.fromCharCode.apply(null,e.slice(0,2*t))}}i.IdGenerator=function(){this.generateTraceId=r(16),this.generateSpanId=r(8),this.generateEventId=r(4)}},function(t,i,n){Object.defineProperty(i,"u",{value:!0}),i.Resource=i.SDK_INFO=i.SemanticResourceAttributes=void 0,i.SemanticResourceAttributes={PROCESS_RUNTIME_NAME:"process.runtime.name",TELEMETRY_SDK_NAME:"telemetry.sdk.name",TELEMETRY_SDK_LANGUAGE:"telemetry.sdk.language",TELEMETRY_SDK_VERSION:"telemetry.sdk.version"},i.SDK_INFO=((e={})[i.SemanticResourceAttributes.TELEMETRY_SDK_NAME]="opentelemetry",e[i.SemanticResourceAttributes.PROCESS_RUNTIME_NAME]="browser",e[i.SemanticResourceAttributes.TELEMETRY_SDK_LANGUAGE]="webjs",e[i.SemanticResourceAttributes.TELEMETRY_SDK_VERSION]=i.VERSION,e),r.empty=function(){return r.EMPTY},r.createTelemetrySDKResource=function(){var t;return new r(((t={})[i.SemanticResourceAttributes.TELEMETRY_SDK_LANGUAGE]=i.SDK_INFO[i.SemanticResourceAttributes.TELEMETRY_SDK_LANGUAGE],t[i.SemanticResourceAttributes.TELEMETRY_SDK_NAME]=i.SDK_INFO[i.SemanticResourceAttributes.TELEMETRY_SDK_NAME],t[i.SemanticResourceAttributes.TELEMETRY_SDK_VERSION]=i.SDK_INFO[i.SemanticResourceAttributes.TELEMETRY_SDK_VERSION],t))},r.prototype.merge=function(t){return t&&Object.keys(t.attributes).length?new r(Object.assign({},this.attributes,t.attributes)):this},r.EMPTY=new r({});var e=r;function r(t){this.attributes=t}i.Resource=e},function(t,i,n){var e=this&&this.__values||function(t){var i="function"==typeof Symbol&&Symbol.iterator,n=i&&t[i],e=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return{value:(t=t&&e>=t.length?void 0:t)&&t[e++],done:!t}}};throw new TypeError(i?"Object is not iterable.":"Symbol.iterator is not defined.")},r=this&&this.__read||function(t,i){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var e,r,s=n.call(t),o=[];try{for(;(void 0===i||0<i--)&&!(e=s.next()).done;)o.push(e.value)}catch(t){r={error:t}}finally{try{e&&!e.done&&(n=s.return)&&n.call(s)}finally{if(r)throw r.error}}return o},s=(Object.defineProperty(i,"u",{value:!0}),i.Span=void 0,n(6)),o=n(1),u=n(2),a=n(7),c=n(18);function h(t,i,n,e,r,s,o,c){void 0===c&&(c=[]),this.attributes={},this.links=[],this.events=[],this.status={code:u.SpanStatusCode.UNSET},this.endTime=0,this.N=!1,this.A=0,this.exported=!0,this.R=t.context,this.reporter=t.reporter,this.spanProcessor=t.spanProcessor,this.parentTracer=t,this.name=n,this.level=e,this.spanContext=r,this.parentSpanId=o,this.kind=s,this.links=c,this.startTime=Date.now(),this.resource=t.resource,this.instrumentationLibrary=t.instrumentationLibrary,this.I=t.getActiveTraceParams(),this.k=new a.IdGenerator}h.prototype.context=function(){return this.spanContext},h.prototype.setAttribute=function(t,i){return null==i||0===t.length||!s.isAttributeValue(i)||Object.keys(this.attributes).length>=this.I.numberOfAttributesPerSpan&&!Object.prototype.hasOwnProperty.call(this.attributes,t)||(this.attributes[t]=i),this},h.prototype.appendAttribute=function(t,i){return null==i||0===t.length||!s.isAttributeValue(i)||Object.keys(this.attributes).length>=this.I.numberOfAttributesPerSpan&&!Object.prototype.hasOwnProperty.call(this.attributes,t)||(this.attributes[t]&&Array.isArray(this.attributes[t])?this.attributes[t].push(i):this.attributes[t]=[i]),this},h.prototype.setAttributes=function(t){var i,n;try{for(var s=e(Object.entries(t)),o=s.next();!o.done;o=s.next()){var u=r(o.value,2);this.setAttribute(u[0],u[1])}}catch(t){i={error:t}}finally{try{o&&!o.done&&(n=s.return)&&n.call(s)}finally{if(i)throw i.error}}return this},h.prototype.addEvent=function(t,i,n){this.events.length>=this.I.numberOfEventsPerSpan&&this.events.shift();var e=this.k.generateEventId();return c.isTimeInput(i)&&(void 0===n&&(n=i),i=void 0),void 0===n&&(n=c.hrTime()),this.events.push({name:t,attributes:i,time:c.timeInputToHrTime(n),event_id:e}),this},h.prototype.setStatus=function(t){return this.status=t,this},h.prototype.updateName=function(t){return this.name=t,this},h.prototype.end=function(t){var i,n=this;this.D()||(this.N=!0,this.resource=this.parentTracer.resource,this.spanProcessor.spanBeforeEnd&&this.spanProcessor.spanBeforeEnd(this),i=c.getCurrentTime(),this.setAttribute("e_time_s",i),this.endTime=Date.now(),this.A=this.endTime-this.startTime,this.R.with(o.suppressInstrumentation(this.R.active()),function(){var i=n.P(n);n.spanProcessor.spanEnd&&n.spanProcessor.spanEnd(i,n.level),i.droped||!1===t||(delete i.droped,n.reporter.report(JSON.stringify(i),n.level))}))},h.prototype.spanReport=function(){var t=this.P(this);this.reporter.report(JSON.stringify(t),this.level)},h.prototype.isRecording=function(){return!1===this.N},Object.defineProperty(h.prototype,"duration",{get:function(){return this.A},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"ended",{get:function(){return this.N},enumerable:!1,configurable:!0}),h.prototype.D=function(){return this.N},h.prototype.P=function(t){var i=[],n=(t.events.forEach(function(t){var n={};Object.keys(t).forEach(function(i){"name"===i&&(n[i]=t[i]),"time"===i&&(n.timestamp=c.hrTimeToMilliseconds(t[i])),"attributes"===i&&(n.tags=t[i])}),i.push(n)}),[]);return t.links.forEach(function(t){n.push({span_id:t.context.spanId,trace_id:t.context.traceId})}),{trace_id:t.spanContext.traceId,parent_span_id:t.parentSpanId,name:t.name,span_id:t.spanContext.spanId,kind:t.kind,start_time:t.startTime,end_time:t.endTime,duration:t.duration,logs:i,tags:t.attributes,links:n}},i.Span=h},function(t,i,n){Object.defineProperty(i,"u",{value:!0}),i.ZegoSpan=void 0;var e=n(3),r=n(9);function s(t,i){this.spanId=t,this.span=i}s.prototype.setAttribute=function(t,i){var n=this;return this.span?this.span.setAttribute(t,i):this.B().then(function(){n.span&&n.span.setAttribute(t,i)}),this},s.prototype.setAttributes=function(t){var i=this;return this.span?this.span.setAttributes(t):this.B().then(function(){i.span&&i.span.setAttributes(t)}),this},s.prototype.appendAttribute=function(t,i){var n=this;return this.span?this.span.appendAttribute(t,i):this.B().then(function(){n.span&&n.span.appendAttribute(t,i)}),this},s.prototype.addEvent=function(t,i,n){var e=this;return this.span?this.span.addEvent(t,i,n):this.B().then(function(){e.span&&e.span.addEvent(t,i,n)}),this},s.prototype.setStatus=function(t){var i=this;return this.span?this.span.setStatus(t):this.B().then(function(){i.span&&i.span.setStatus(t)}),this},s.prototype.updateName=function(t){var i=this;return this.span?this.span.updateName(t):this.B().then(function(){i.span&&i.span.updateName(t)}),this},s.prototype.end=function(t){var i=this;void 0===t&&(t=!0),this.span?this.span.end(t):this.B(!0).then(function(){i.span&&i.span.end(t),i.U()})},s.prototype.setSpanActive=function(t){this.activeCallback=t},s.prototype.setSpanEnd=function(t){this.endCallback=t},s.prototype.spanReport=function(){var t;null!=(t=this.span)&&t.spanReport()},s.prototype.U=function(){this.L()||(this.J(this.spanId),this.endCallback&&this.endCallback(this.spanInfo))},s.prototype.L=function(){return"noop"===this.spanId},s.prototype.B=function(t){var i=this;return void 0===t&&(t=!1),new Promise(function(n,e){i.store.getItem(i.spanId).then(function(e){var o=new r.Span(s.tracer,s.tracer.context.active(),e.name,e.level,e.spanContext,e.kind,e.parentSpanId,e.links);o.setStatus(e.status),o.setAttributes(e.attributes),i.span=o,i.activeCallback&&i.activeCallback(i.spanId,t),n()}).catch(function(t){e(t)})})},s.prototype.J=function(t){var i=this;this.store.getItem(t).then(function(n){n&&i.store.removeItem(t).then(function(){e.log.log("remove suc")}).catch(function(t){e.log.warn("remove fail")})})},i.ZegoSpan=s},function(t,i,n){function e(t){this.q=t=void 0===t?"":t,this.count=0,this.isStarting=!1,this.timer=0,this.lastLogTime=0,this.speed=0,this.lastTime=0}Object.defineProperty(i,"u",{value:!0}),i.SpeedUtil=void 0,e.prototype.add=function(t){this.isStarting&&(this.count+=t)},e.prototype.stop=function(){return this.isStarting=!1,this.reset()},e.prototype.start=function(t){var i=this;void 0===t&&(t=0),this.isStarting=!0,this.count=0,clearInterval(this.timer),t&&(this.timer=window.setInterval(function(){i.speed=i.count/t,i.count=0},t))},e.prototype.reset=function(){this.count=0,clearInterval(this.timer),this.timer=0,this.speed=0},i.SpeedUtil=e},function(t,i,n){Object.defineProperty(i,"u",{value:!0}),i.createZegoStore=i.ZegoWechatMiniStore=i.ZEGO_ENV=void 0;var e,r,s=n(13),o=((r=e=i.ZEGO_ENV||(i.ZEGO_ENV={}))[r.BROWSER=0]="BROWSER",r[r.WEIXINMINI=1]="WEIXINMINI",n(3)),u=(a.prototype.getItem=function(t){var i=this;return new Promise(function(n,e){try{n(wx.getStorageSync(i.keyPrefix+t))}catch(n){e(n)}})},a.prototype.setItem=function(t,i){var n=this;return new Promise(function(e,r){try{wx.setStorageSync(n.keyPrefix+t,i),e()}catch(e){r(e)}})},a.prototype.removeItem=function(t){var i=this;return new Promise(function(n,e){try{n(wx.removeStorageSync(i.keyPrefix+t))}catch(n){e(n)}})},a.prototype.clear=function(){return new Promise(function(t,i){try{wx.clearStorageSync(),t()}catch(t){i(t)}})},a.prototype.keys=function(){var t=this;return new Promise(function(i,n){try{var e=wx.getStorageInfoSync().keys,r=(o.log.warn("keys",e),[]);e.forEach(function(i){0==i.indexOf(t.keyPrefix)&&r.push(i.replace(t.keyPrefix,""))}),o.log.warn("keyArr",JSON.stringify(r)),r.sort(),i(r)}catch(i){n(i)}})},a);function a(t){this.storeName=t,this.keyPrefix=t+"/"}i.ZegoWechatMiniStore=u,i.createZegoStore=function(t,i,n){return i===e.BROWSER?s.createInstance({name:t+":"+(n||"store")}):new u(t)}},function(i,n){i.exports=t},function(t,i,n){Object.defineProperty(i,"u",{value:!0}),i.DynamicCode=i.ZegoTracer=i.ZegoSpan=void 0;var e=n(15),r=(Object.defineProperty(i,"ZegoTracer",{enumerable:!0,get:function(){return e.ZegoTracer}}),n(46)),s=(Object.defineProperty(i,"DynamicCode",{enumerable:!0,get:function(){return r.DynamicCode}}),n(10));Object.defineProperty(i,"ZegoSpan",{enumerable:!0,get:function(){return s.ZegoSpan}})},function(t,i,n){Object.defineProperty(i,"u",{value:!0}),i.ZegoTracer=void 0;var e=n(16),r=n(22),s=n(10),o=n(23),u=n(3),a=n(1),c=n(8),h=n(24),f=n(39),l=n(12),d=n(44),v=n(45);function m(t){this.C=o.DEFAULT_MAX_SPAN_SIZE,this.level=0,this.log=new d.ZegoLog,this.stateCenter=new v.StateCenter(this.log),this.stateCenter.proxyCtrl=t}m.prototype.init=function(t){t.deflate?(this.stateCenter.deflate=t.deflate,"boolean"==typeof t.keepLive&&(this.stateCenter.keepLive=t.keepLive),this.options=t,this.name=t.product,this.reporter=new h.ZegoDataReport(this.name,this.stateCenter),this.reporter.init({appID:t.appID,env:t.env||0,importantLevel:t.importantLevel,levels:t.levels,deviceID:t.deviceID,bps:t.bps,serverUrl:t.serverUrl}),this.tracer=new e.Tracer({name:this.name,version:t.version},{resource:new c.Resource(t.resources)},this.reporter,{spanStart:t.spanStart,spanBeforeEnd:t.spanBeforeEnd,spanEnd:t.spanEnd}),this.reporter.setProcessData(this.tracer.resource.attributes),this.F(this.options),this.dyStore=l.createZegoStore(t.product+"_"+t.appID+"_dy",t.env||0)):console.error("init tracer failed. need input pako inflate function")},m.prototype.F=function(t){this.rootSpan=this.tracer.startSpan("root",0);var i=a.setSpan(this.tracer.context.active(),this.rootSpan);this.tracer.context.T().M=i,this.rootSpan.end()},m.prototype.createSpan=function(t,i,n){var e,c;return t<=this.level?(e=a.setSpan(this.tracer.context.active(),n&&n.parent?n.parent.span:this.rootSpan),c=[],n&&n.linkSpans&&(n.linkSpans.forEach(function(t){c.push({context:t.span.context()})}),delete n.linkSpans),i=this.tracer.startSpan(i,t,Object.assign({},n,{links:c}),e),t=new s.ZegoSpan(i.spanContext.spanId,i),s.ZegoSpan.tracer=this.tracer,t):(u.log.warn("createSpan level not fix"),new s.ZegoSpan(o.NOOP_SPAN_ID,new r.NoopSpan))},m.prototype.setLogger=function(t){this.stateCenter.logger=t},m.prototype.setTimeOffset=function(t){this.reporter.setTimeOffset(t)},m.prototype.setWaitNtpTimeout=function(t){this.reporter.setWaitNtpTimeout(t)},m.prototype.setLogLevel=function(t){return this.stateCenter.W.setLogLevel(t)},m.prototype.startReport=function(t){return this.reporter.startReport(t)},m.prototype.setConfig=function(t){this.reporter.setConfig(t)},m.prototype.loadJs=function(t,i,n,e,r,s){return f.loadJS(t,this.dyStore,i,n,e,r,s)},m.prototype.flush=function(t){this.reporter.flush(t)},m.prototype.setUnloadState=function(t){this.reporter.setUnloadState(t)},m.prototype.shutdown=function(){this.reporter.saveDataBeforeUnload()},m.prototype.destroy=function(){this.reporter.uninit()},m.prototype.setSampleConfig=function(t){this.level=t.level||this.level},m.prototype.setResource=function(t){this.tracer.setResource(t),this.reporter.setProcessData(this.tracer.resource.attributes)},m.prototype.setNetStateCheck=function(){this.reporter.setNetStateCheck()},m.prototype.getUnloadStatus=function(){return{uploadSpeed:this.reporter.uploadSpeed,increaseSpeed:this.reporter.speed,unreportLength:this.reporter.unreportDataByteLen}},m.prototype.reportSize=function(){return this.reporter.traceType.MEM_I_API},i.ZegoTracer=m},function(t,i,n){Object.defineProperty(i,"u",{value:!0}),i.Tracer=void 0;var e=n(6),r=n(1),s=n(2),o=n(7),u=n(8),a=n(9),c=n(19),h=n(20);function f(t,i,n,e){var s=h.mergeConfig(i);this.I=s.traceParams,this.k=new o.IdGenerator,this.resource=null!=(s=i.resource)?s:u.Resource.createTelemetrySDKResource(),this.instrumentationLibrary=t,i=Math.random().toString(36).slice(-6),this.context=new r.ContextAPI(i),this.reporter=n,this.spanProcessor=e||{}}f.prototype.startSpan=function(t,i,n,o){var u,h,f,l=((t,i)=>{if(!t.root)return r.getSpanContext(i)})(n=void 0===n?{}:n,o=void 0===o?this.context.active():o),d=this.k.generateSpanId(),v=(l&&c.isSpanContextValid(l)?(u=l.traceId,h=l.traceState,f=l.spanId):u=this.k.generateTraceId(),l=null!=(l=n.kind)?l:s.SpanKind.INTERNAL,null!=(v=n.links)?v:[]);return n=e.sanitizeAttributes(n.attributes),(o=new a.Span(this,o,t,i,{traceId:u,spanId:d,traceFlags:s.TraceFlags.NONE,traceState:h},l,f,v)).setAttributes(n),this.spanProcessor.spanStart&&this.spanProcessor.spanStart(o),o},f.prototype.setResource=function(t){this.resource=this.resource.merge(new u.Resource(t))},f.prototype.getActiveTraceParams=function(){return this.I},i.Tracer=f},function(t,i,n){var e=this&&this.__read||function(t,i){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var e,r,s=n.call(t),o=[];try{for(;(void 0===i||0<i--)&&!(e=s.next()).done;)o.push(e.value)}catch(t){r={error:t}}finally{try{e&&!e.done&&(n=s.return)&&n.call(s)}finally{if(r)throw r.error}}return o},r=this&&this.__spread||function(){for(var t=[],i=0;i<arguments.length;i++)t=t.concat(e(arguments[i]));return t},s=(Object.defineProperty(i,"u",{value:!0}),i.StackContextManager=void 0,n(1));function o(){this.X=!1,this.M=s.ROOT_CONTEXT}o.prototype.K=function(t,i){function n(){for(var n=this,r=[],s=0;s<arguments.length;s++)r[s]=arguments[s];return e.with(i,function(){return t.apply(n,r)})}void 0===i&&(i=s.ROOT_CONTEXT);var e=this;return Object.defineProperty(n,"length",{enumerable:!1,configurable:!0,writable:!1,value:t.length}),n},o.prototype.active=function(){return this.M},o.prototype.bind=function(t,i){return void 0===(i=void 0===i?s.ROOT_CONTEXT:i)&&(i=this.active()),"function"==typeof t?this.K(t,i):t},o.prototype.disable=function(){return this.M=s.ROOT_CONTEXT,this.X=!1,this},o.prototype.enable=function(){return this.X||(this.X=!0,this.M=s.ROOT_CONTEXT),this},o.prototype.with=function(t,i,n){for(var e=[],o=3;o<arguments.length;o++)e[o-3]=arguments[o];var u=this.M;this.M=t||s.ROOT_CONTEXT;try{return i.call.apply(i,r([n],e))}finally{this.M=u}},i.StackContextManager=o},function(t,i,n){Object.defineProperty(i,"u",{value:!0}),i.getCurrentTime=i.isTimeInput=i.hrTimeToMilliseconds=i.hrTimeDuration=i.timeInputToHrTime=i.isTimeInputHrTime=i.hrTime=void 0;var e=9,r=Math.pow(10,e),s=["00","01","02","03","04","05","06","07","08","09"];function o(t){t/=1e3;var i=Math.trunc(t);return[i,Number((t-i).toFixed(e))*r]}function u(){var t,i=performance.timeOrigin;return"number"!=typeof i?(t=performance).timing&&t.timing.fetchStart:i}function a(t){var i=o(u()),n=(t=o("number"==typeof t?t:performance.now()),i[0]+t[0]);return r<(i=i[1]+t[1])&&(i-=r,n+=1),[n,i]}function c(t){return Array.isArray(t)&&2===t.length&&"number"==typeof t[0]&&"number"==typeof t[1]}i.hrTime=a,i.isTimeInputHrTime=c,i.timeInputToHrTime=function(t){if(c(t))return t;if("number"==typeof t)return(t<u()?a:o)(t);if(t instanceof Date)return o(t.getTime());throw TypeError("Invalid input type")},i.hrTimeDuration=function(t,i){var n=i[0]-t[0];return(i=i[1]-t[1])<0&&(--n,i+=r),[n,i]},i.hrTimeToMilliseconds=function(t){return Math.round(1e3*t[0]+t[1]/1e6)},i.isTimeInput=function(t){return c(t)||"number"==typeof t||t instanceof Date},i.getCurrentTime=function(){var t=new Date;return[t.getFullYear()+"/",(s[t.getMonth()+1]||t.getMonth()+1)+"/",(s[t.getDate()]||t.getDate())+" ",(s[t.getHours()]||t.getHours())+":",(s[t.getMinutes()]||t.getMinutes())+":",s[t.getSeconds()]||t.getSeconds(),"."+(""+t.getTime()).slice(-3)].join("")}},function(t,i,n){Object.defineProperty(i,"u",{value:!0}),i.isSpanContextValid=i.isValidSpanId=i.isValidTraceId=i.INVALID_SPAN_CONTEXT=i.INVALID_TRACEID=i.INVALID_SPANID=void 0,n=n(2);var e=/^([0-9a-f]{32})$/i,r=/^[0-9a-f]{16}$/i;function s(t){return e.test(t)&&t!==i.INVALID_TRACEID}function o(t){return r.test(t)&&t!==i.INVALID_SPANID}i.INVALID_SPANID="0000000000000000",i.INVALID_TRACEID="00000000000000000000000000000000",i.INVALID_SPAN_CONTEXT={traceId:i.INVALID_TRACEID,spanId:i.INVALID_SPANID,traceFlags:n.TraceFlags.NONE},i.isValidTraceId=s,i.isValidSpanId=o,i.isSpanContextValid=function(t){return s(t.traceId)&&o(t.spanId)}},function(t,i,n){Object.defineProperty(i,"u",{value:!0}),i.mergeConfig=void 0;var e=n(21);i.mergeConfig=function(t){var i=Object.assign({},e.DEFAULT_CONFIG,t);return i.traceParams=Object.assign({},e.DEFAULT_CONFIG.traceParams,t.traceParams||{}),i}},function(t,i,n){Object.defineProperty(i,"u",{value:!0}),i.DEFAULT_CONFIG=void 0,i.DEFAULT_CONFIG={traceParams:{numberOfAttributesPerSpan:128,numberOfLinksPerSpan:128,numberOfEventsPerSpan:128}}},function(t,i,n){Object.defineProperty(i,"u",{value:!0}),i.NoopSpan=void 0;var e=n(2);function r(t){void 0===t&&(t=e.INVALID_SPAN_CONTEXT),this.G=t}r.prototype.context=function(){return this.G},r.prototype.setAttribute=function(t,i){return this},r.prototype.appendAttribute=function(t,i){return this},r.prototype.setAttributes=function(t){return this},r.prototype.addEvent=function(t,i,n){return this},r.prototype.setStatus=function(t){return this},r.prototype.updateName=function(t){return this},r.prototype.end=function(t){},r.prototype.isRecording=function(){return!1},r.prototype.spanReport=function(){},r.prototype.recordException=function(t,i){},i.NoopSpan=r},function(t,i,n){Object.defineProperty(i,"u",{value:!0}),i.NOOP_SPAN_ID=i.SCHEDULED_DELAY_MILLIS=i.DEFAULT_MAX_SPAN_SIZE=i.readSpanKeys=void 0,i.readSpanKeys=["name","level","kind","spanContext","parentSpanId","startTime","endTime","status","attributes","links","events","duration","ended","resource","instrumentationLibrary"],i.DEFAULT_MAX_SPAN_SIZE=1e3,i.SCHEDULED_DELAY_MILLIS=3e3,i.NOOP_SPAN_ID="noop"},function(t,i,n){var e=this&&this.__assign||function(){return(e=Object.assign||function(t){for(var i,n=1,e=arguments.length;n<e;n++)for(var r in i=arguments[n])Object.prototype.hasOwnProperty.call(i,r)&&(t[r]=i[r]);return t}).apply(this,arguments)},r=this&&this.__awaiter||function(t,i,n,e){return new(n=n||Promise)(function(r,s){function o(t){try{a(e.next(t))}catch(t){s(t)}}function u(t){try{a(e.throw(t))}catch(t){s(t)}}function a(t){var i;t.done?r(t.value):((i=t.value)instanceof n?i:new n(function(t){t(i)})).then(o,u)}a((e=e.apply(t,i||[])).next())})},s=this&&this.__generator||function(t,i){var n,e,r,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]},o={next:u(0),throw:u(1),return:u(2)};return"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function u(o){return function(u){var a=[o,u];if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,e&&(r=2&a[0]?e.return:a[0]?e.throw||((r=e.return)&&r.call(e),0):e.next)&&!(r=r.call(e,a[1])).done)return r;switch(e=0,(a=r?[2&a[0],r.value]:a)[0]){case 0:case 1:r=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,e=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(r=0<(r=s.trys).length&&r[r.length-1])&&(6===a[0]||2===a[0])){s=0;continue}if(3===a[0]&&(!r||a[1]>r[0]&&a[1]<r[3]))s.label=a[1];else if(6===a[0]&&s.label<r[1])s.label=r[1],r=a;else{if(!(r&&s.label<r[2])){r[2]&&s.ops.pop(),s.trys.pop();continue}s.label=r[2],s.ops.push(a)}}a=i.call(t,s)}catch(u){a=[6,u],e=0}finally{n=r=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}}},o=this&&this.__read||function(t,i){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var e,r,s=n.call(t),o=[];try{for(;(void 0===i||0<i--)&&!(e=s.next()).done;)o.push(e.value)}catch(t){r={error:t}}finally{try{e&&!e.done&&(n=s.return)&&n.call(s)}finally{if(r)throw r.error}}return o},u=this&&this.__spread||function(){for(var t=[],i=0;i<arguments.length;i++)t=t.concat(o(arguments[i]));return t},a=this&&this.__values||function(t){var i="function"==typeof Symbol&&Symbol.iterator,n=i&&t[i],e=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return{value:(t=t&&e>=t.length?void 0:t)&&t[e++],done:!t}}};throw new TypeError(i?"Object is not iterable.":"Symbol.iterator is not defined.")},c=(Object.defineProperty(i,"u",{value:!0}),i.ZegoDataReport=void 0,n(0)),h=n(25),f=n(30),l=n(38),d=n(5),v=n(4),m=n(11);function p(t,i){this.H=i,this.QUEUE_MAX=100,this.cacheMaxSize=v.CACHE_SIZE.cacheMaxSize,this.cacheDelPer=v.CACHE_SIZE.cacheDelPer,this.state="normal",this.forceDataTotalLen=0,this.reportPackagesSize=0,this.staticConfig={totalAvailCache:v.CACHE_SIZE.totalAvailCache,totalDBSize:v.STORE_SIZE.totalDBSize,bps:1600},this.dataInDb=[],this.listenerList={progressUpdate:[],forceResult:[],postFail:[],dataDroped:[]},this.tempBuffer=[],this.traceType={MEM_I_API:0,MEM_O_DONE:0,MEM_O_DUMP:0,MEM_I_LOAD:0,DB_O_DROP:0,DB_O_DONE:0,DB_I_BACKUP:0},this.isPaused=!1,this.pro="json",this.isLoadReportData=!1,this.dropCount=0,this.timeInterval=!1,this.isWaitNtpTimeout=!1,this.waitNtpTimeout=2e3,this.postDataState="",this.product=t,this.reportMap=new Map,this.Y=new m.SpeedUtil("tracer increase"),null!=(i=this.Y)&&i.start(3e3)}Object.defineProperty(p.prototype,"speed",{get:function(){return this.Y.speed},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"uploadSpeed",{get:function(){return this.zegoService.speed},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"unreportDataByteLen",{get:function(){return this.traceType.MEM_I_API+this.traceType.MEM_I_LOAD-this.traceType.MEM_O_DONE-this.traceType.MEM_O_DUMP},enumerable:!1,configurable:!0}),p.prototype.init=function(t){return r(this,void 0,void 0,function(){var i=this;return s(this,function(n){switch(n.label){case 0:return this.config=e(e({},v.DEFAULT_CONFIG),t),this.config.env%2!=1&&this.V(),this.zegoService=new h.ZegoService(this.config.env||c.ZEGO_ENV.BROWSER,this.config.bps||v.DEFAULT_CONFIG.bps,this.product,this.pro,this.H),this.zegoService.setLogUrlParams({product:this.product,signature:this.config.token||"",appid:this.config.appID,id_name:this.config.userID||"",deviceid:this.config.deviceID||""}),this.config.serverUrl&&this.zegoService.setLogServer(this.config.serverUrl),this.zegoService.setPostSucCallback(this.product,this.Z.bind(this)),this.zegoService.setPostFailCallback(this.product,function(t){return r(i,void 0,void 0,function(){return s(this,function(i){switch(i.label){case 0:return this.H.logger.warn("zt.zd.i fail"),this.postDataState="fail",this.dropCount++,this.$(t),[4,this.tt(1)];case 1:return i.sent(),this.it("postFail"),[2]}})})}),this.nt(),this.storeHandler=new f.ZegoStoreHandler(this.product+"_"+this.config.appID+"_datareporter",d.uuid(6),this.config,this.traceType,this.staticConfig,this.H,this.product),this.storeHandler.setDropCallBack(function(t){i.traceType.DB_O_DROP+=d.calculateMemSize(t),i.it("dataDroped",t)}),[4,this.storeHandler.loadPendingData()];case 1:return n.sent(),this.storeHandler.init().then(function(){i.rt()}).catch(function(t){console.warn(t)}),this.et(),this.st(),this.ut(),[2]}})})},p.prototype.uninit=function(){this.isWaitNtpTimeout=!1,this.ntpTimer&&(clearTimeout(this.ntpTimer),this.ntpTimer=null),this.Y.stop(),this.zegoService.destroy()},p.prototype.setConfig=function(t){"object"==typeof t&&"number"==typeof t.bps&&(this.config.bps=t.bps,this.zegoService.setBps(this.config.bps)),"object"==typeof t&&"number"==typeof t.totalDBSize&&(this.staticConfig.totalDBSize=t.totalDBSize),"object"==typeof t&&"string"==typeof t.serverUrl&&""!==t.serverUrl&&(this.config.serverUrl=t.serverUrl,this.zegoService.setLogServer(this.config.serverUrl))},p.prototype.pause=function(){this.isPaused=!0},p.prototype.resume=function(){this.isPaused=!1;var t=this.pendingQueue.getPendingDataInfo();this.ot(t.pendingDataSize,t.size)},p.prototype.startReport=function(t){var i=t.get("userID"),n=t.get("token");return!(!i||"string"!=typeof i||!n||"string"!=typeof n||(this.startCommonField=t,this.config.userID=i,this.config.token=n,this.zegoService.setLogUrlParams({product:this.product,signature:this.config.token,appid:this.config.appID,id_name:this.config.userID||"",deviceid:this.config.deviceID||""}),this.ht()&&this.ct(),(i=t.get("serverUrl"))&&(this.config.serverUrl=i,this.zegoService.setLogServer(this.config.serverUrl)),this.isConfigOK(this.config)&&(t=(n=this.pendingQueue.getPendingDataInfo()).pendingDataSize,this.ot(t,n.size)),0))},p.prototype.setTimeOffset=function(t){var i=this;this.clientTimeOffset=t,this.tempBuffer.forEach(function(t){(t=t.data).tags.time_offset||(t.tags.time_offset=i.clientTimeOffset)}),this.config.userID&&this.ct()},p.prototype.setProcessData=function(t){this.H.processData=t},p.prototype.on=function(t,i){return this.ft(t,i)},p.prototype.off=function(t,i){return this.lt(t,i)},p.prototype.report=function(t,i){var n;if(15e3<t.length)return!1;try{n=JSON.parse(t)}catch(t){return!1}return this.H.W.debug(t+" "+i),(null!=n&&n.id_name||null!=(t=null==n?void 0:n.tags)&&t.id_name||this.config.userID)&&this.ht()?(null!=n&&n.id_name||null!=(t=null==n?void 0:n.tags)&&t.id_name?this.clientTimeOffset&&(n.tags.time_offset=this.clientTimeOffset):(this.clientTimeOffset&&(n.tags.time_offset=this.clientTimeOffset),n.tags.id_name=this.config.userID),this.vt(JSON.stringify(n),i)):this.tempBuffer.push({data:n,level:i}),!0},p.prototype.setUnloadState=function(t){this.unloadLevel=t,this.state="unload"},p.prototype.vt=function(t,i){var n=this,e=d.calculateMemSize(t),r=(this.traceType.MEM_I_API+=e,this.Y.add(8*e),c.getSeq()),s=(new Date).getTime(),o={seq:r,content:t,level:i,timestamp:s};"unload"===this.state?void 0!==this.unloadLevel&&i<=this.unloadLevel?(this.storeHandler.saveDataToStorage(o),this.pendingQueue.enqueue(o,i)):this.H.W.debug("level is low"):i<=this.config.importantLevel?(o.key=i+"_"+s+"_"+r,this.dataInDb.push(o.key),this.storeHandler.storeData(o).then(function(t){n.pendingQueue.enqueue(o,i),n.traceType.DB_I_BACKUP+=e}).catch(function(t){var e=n.dataInDb.findIndex(function(t){return t===o.key});-1<e&&n.dataInDb.splice(e,1),n.pendingQueue.enqueue(o,i)})):this.pendingQueue.enqueue(o,i),"force"===this.state&&(s=d.calculateMemSize(t),this.forceDataTotalLen+=s)},p.prototype.ht=function(){return this.isWaitNtpTimeout||void 0!==this.clientTimeOffset},p.prototype.ct=function(){var t,i=this.tempBuffer.shift();i&&(t=i.data,i=i.level,t.tags.id_name=this.config.userID,this.vt(JSON.stringify(t),i),this.ct())},p.prototype.isConfigOK=function(t){return""!==t.userID&&""!==t.token&&""!==t.server},p.prototype.testSize=function(t){},p.prototype.flush=function(t){var i;"force"!==this.state&&(this.state="force",i=16e6,"object"==typeof t&&"number"==typeof t.bps&&(i=t.bps),this.zegoService.setBps(i),this.forceDataTotalLen=this.storeHandler.storeSize+this.pendingQueue.pendingDataSize+this.reportPackagesSize,0<(i=(t=this.pendingQueue.getPendingDataInfo()).pendingDataSize)?this.ot(i,t.size):this.rt())},p.prototype.setWaitNtpTimeout=function(t){this.waitNtpTimeout=t},p.prototype.st=function(){var t=this;this.ntpTimer=setTimeout(function(){t.isWaitNtpTimeout=!0,t.config.userID&&t.ct()},this.waitNtpTimeout)},p.prototype.et=function(){var t=this,i=(this.H.W.debug("startReportTimer "+new Date),this.timeInterval=!0,this.pendingQueue.getPendingDataInfo());this.ot(i.pendingDataSize,i.size),this.reportTimer=window.setTimeout(function(){t.et()},3e4)},p.prototype.ut=function(){return r(this,void 0,void 0,function(){var t,i,n=this;return s(this,function(e){switch(e.label){case 0:return i=this.pendingQueue.getPendingDataInfo(),t=i.pendingDataSize,i=i.size,t>this.config.reportSize||i>this.config.reportNum?[4,this.ot(t,i)]:[3,2];case 1:return e.sent(),[3,3];case 2:this.rt(),e.label=3;case 3:return this.checkDataTimer=window.setTimeout(function(){n.ut()},15e3),[2]}})})},p.prototype.V=function(){var t=this,i=navigator.userAgent.match(/iPad/i)||navigator.userAgent.match(/iPhone/i);navigator.userAgent.indexOf("Firefox"),window.addEventListener(i?"pagehide":"beforeunload",function(){window.event&&(window.event.cancelBubble=!0),t.saveDataBeforeUnload()})},p.prototype.saveDataBeforeUnload=function(){var t=(t=this.pendingQueue.readStoreData(1)).storeArr,i=(this.storeHandler.resetCommonStore(),[]);i.push.apply(i,u(t)),t=this.zegoService.readReportQueueData(),i.push.apply(i,u(t)),0<i.length&&this.storeHandler.storePendingData(i)},p.prototype.setNetStateCheck=function(){"fail"===this.postDataState&&this.zegoService.handleNetConnect()},p.prototype.Z=function(t,i,n){return r(this,void 0,void 0,function(){var n,e,r,o,u,a=this;return s(this,function(s){switch(s.label){case 0:for(this.H.W.debug("post suc"),this.postDataState="suc",t.forEach(function(t){a.traceType.MEM_O_DONE+=d.calculateMemSize(t.content)}),n=function(i){var n=t[i];e.storeHandler.removeDataItem(n).then(function(t){n.key&&a.reportMap.delete(n.key)}).catch(function(t){})},e=this,r=0;r<t.length;r++)n(r);return this.reportPackagesSize-=i,u=this.pendingQueue.getPendingDataInfo(),o=u.pendingDataSize,u=u.size,o>this.config.reportSize||u>this.config.reportNum?[4,this.ot(o,u)]:[3,2];case 1:return s.sent(),[3,3];case 2:this.rt(),s.label=3;case 3:return"force"===this.state&&0==this.reportPackagesSize&&(o=this.reportPackagesSize+this.pendingQueue.pendingDataSize+this.storeHandler.storeSize,u=1-Number((o/this.forceDataTotalLen).toFixed(2)),this.listenerList.progressUpdate&&this.it("progressUpdate",u),0<this.storeHandler.storeSize)&&this.rt(function(t){0===t&&(a.state="normal",a.zegoService.setBps(a.config.bps||v.DEFAULT_CONFIG.bps),a.listenerList.forceSuccessCallback)&&a.it("forceResult","SUCCESS")}),[2]}})})},p.prototype.ot=function(t,i){return r(this,void 0,void 0,function(){var n,e,r,o,u;return s(this,function(s){switch(s.label){case 0:return t>this.config.reportSize||i>this.config.reportNum||["force","unload"].includes(this.state)||this.timeInterval?(this.timeInterval=!1,!this.isPaused&&this.config.userID&&this.config.token&&this.config.serverUrl?[3,3]:(this.H.W.debug("isPaused "+this.isPaused+" "+this.userID+" "+this.config.token+" "+this.config.serverUrl),t>=this.cacheMaxSize||this.staticConfig.totalAvailCache<=0?[4,this.tt(this.cacheDelPer)]:[3,2])):[3,7];case 1:s.sent(),s.label=2;case 2:return[2];case 3:return this.zegoService.reportAllowed()?[3,6]:(this.zegoService.resumeReport(),t>=this.cacheMaxSize||this.staticConfig.totalAvailCache<=0?[4,this.tt(this.cacheDelPer)]:[3,5]);case 4:s.sent(),s.label=5;case 5:return[2];case 6:if(r=this.pendingQueue.readReportData(this.config.reportSize),n=r.totalLen,r=r.reportDataArr,n<=0)return[2];for(r=this.dt(r),this.zegoService.report(e=r.packageArr,r=r.packageLen,this.product,"unload"===this.state),o=0;o<e.length;o++)this.reportMap.set((u=e[o]).key,u);this.reportPackagesSize+=r,this.pendingQueue.refresh(n),s.label=7;case 7:return[2]}})})},p.prototype.nt=function(){var t=this;this.pendingQueue=new l.PendingQueue(this.config.levels,this.product,this.staticConfig,this.H),this.pendingQueue.setListener({enCallback:function(i,n,e){return r(t,void 0,void 0,function(){return s(this,function(t){switch(t.label){case 0:return[4,this.ot(e,n)];case 1:return t.sent(),[2]}})})}})},p.prototype.yt=function(){var t=this;this.storeHandler.readStoreDataItem().then(function(i){var n=d.calculateMemSize(i.content);t.traceType.MEM_I_LOAD+=n,t.pendingQueue.enqueue(i,i.level)}).catch(function(t){})},p.prototype.tt=function(t){return r(this,void 0,void 0,function(){var i,n,e,r,o,u,c,h,f;return s(this,function(l){switch(l.label){case 0:n=this.pendingQueue.readStoreData(t),i=n.totalLen,n=n.storeArr,e=function(t){var n,e;return s(this,function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),[4,r.wt(t,i)];case 1:return s.sent(),n=t.level+"_"+t.timestamp+"_"+t.seq,-1<(e=r.dataInDb.findIndex(function(t){return t===n}))&&r.dataInDb.splice(e,1),[3,3];case 2:return s.sent(),[3,3];case 3:return[2]}})},r=this,l.label=1;case 1:l.trys.push([1,6,7,8]),o=a(n),u=o.next(),l.label=2;case 2:return u.done?[3,5]:[5,e(c=u.value)];case 3:l.sent(),l.label=4;case 4:return u=o.next(),[3,2];case 5:return[3,8];case 6:return c=l.sent(),h={error:c},[3,8];case 7:try{u&&!u.done&&(f=o.return)&&f.call(o)}finally{if(h)throw h.error}return[7];case 8:return[2]}})})},p.prototype.$=function(t){var i=this;t.length&&t.forEach(function(t){i.storeHandler.storeData(t).then(function(n){var e=d.calculateMemSize(t.content);i.traceType.MEM_O_DUMP+=e}).catch(function(t){})})},p.prototype.wt=function(t,i){var n=this;return new Promise(function(i,e){return r(n,void 0,void 0,function(){var n;return s(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,this.storeHandler.storeData(t)];case 1:return r.sent(),n=d.calculateMemSize(t.content),this.traceType.MEM_O_DUMP+=n,i(),[3,3];case 2:return n=r.sent(),e(n),[3,3];case 3:return[2]}})})})},p.prototype.rt=function(t){var i=this;this.storeHandler.storeSize<=0||this.isLoadReportData||(this.isLoadReportData=!0,this.storeHandler.loadDBData(this.config.reportSize,5,Math.floor(this.cacheMaxSize/3),function(t){return-1<i.dataInDb.indexOf(t)}).then(function(n){i.isLoadReportData=!1,n.datas.forEach(function(t){var n;i.reportMap.has(t.key)||i.pendingQueue.findInQueue(t)||(n=d.calculateMemSize(t.content),i.traceType.MEM_I_LOAD+=n,i.pendingQueue.enqueue(t,t.level),i.dataInDb.push(t.key))}),t&&t(n.len)}).catch(function(t){i.isLoadReportData=!1}))},p.prototype.dt=function(t){var i=this,n=0;return t.forEach(function(t){var e,r,s=JSON.parse(t.content);if(i.startCommonField)try{for(var u=a(i.startCommonField),c=u.next();!c.done;c=u.next()){var h=o(c.value,2),f=h[0];"userID"!==f&&"token"!==f&&"serverUrl"!==f&&(s[f]=h[1])}}catch(t){e={error:t}}finally{try{c&&!c.done&&(r=u.return)&&r.call(u)}finally{if(e)throw e.error}}n+=d.calculateMemSize(s),t.content=JSON.stringify(s)}),{packageArr:t,packageLen:n}},p.prototype.ft=function(t,i){return!!this.listenerList[t]&&"function"==typeof i&&(-1==this.listenerList[t].indexOf(i)&&this.listenerList[t].push(i),!0)},p.prototype.lt=function(t,i){var n;return!!this.listenerList[t]&&(n=this.listenerList[t],i?n.splice(n.indexOf(i),1):this.listenerList[t]=[],!0)},p.prototype.it=function(t){for(var i=[],n=1;n<arguments.length;n++)i[n-1]=arguments[n];this.listenerList[t]&&this.listenerList[t].forEach(function(t){try{t.apply(void 0,u(i))}catch(t){}})},i.ZegoDataReport=p},function(t,i,n){var e=this&&this.__read||function(t,i){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var e,r,s=n.call(t),o=[];try{for(;(void 0===i||0<i--)&&!(e=s.next()).done;)o.push(e.value)}catch(t){r={error:t}}finally{try{e&&!e.done&&(n=s.return)&&n.call(s)}finally{if(r)throw r.error}}return o},r=this&&this.__spread||function(){for(var t=[],i=0;i<arguments.length;i++)t=t.concat(e(arguments[i]));return t},s=(Object.defineProperty(i,"u",{value:!0}),i.ZegoService=void 0,n(0)),o=n(26),u=n(29),a=n(4);function c(t,i,n,e,r){var u,a,c,h=this;this.bt=t,this.gt=n,this.Ot=e,this.H=r,this.isDestroy=!1,this.packageLen=0,this.packagesDataSize=0,this.PACKAGE_MAX_LEN=5,this.msgID=0,this.logUploadTimer=null,this.logUploadInterval=1e4,this.logCacheSend=[],this.logCacheMax=100,this._t=1e3,this.postSucCallbackList={},this.postFailCallbackList={},this.failCount=0,this.failStartTime=0,this.netWorkFail=!1,this.networkState=s.ENUM_NETWORK_STATE.online,this.state=0,this.St=(a=u=0,c=function(){a=u=0},{onOpen:function(){u=performance.now()},onClose:function(){0<u&&(performance.now()-u<100?(a++,h.H.logger.info("zt.rzs.wfsc frequently shutdown.")):c())},isOutOfMaxTimes:function(){return 10<=a}}),this.Mt={offline:function(){h.networkState=s.ENUM_NETWORK_STATE.offline},online:function(t){h.handleNetConnect()}},this.bindWindowListener(),this.networkState=s.ENUM_NETWORK_STATE.online,this.service=new o.LogService(t,n,e,r),this.service.onHbTimeout=function(){h.H.logger.warn("zt.rzs.ohbto hb timeout."),h.socketReconnect(!0,!0)},this.setBps(i),this.reportQueue=new s.Queue}Object.defineProperty(c.prototype,"speed",{get:function(){return this.service.speed},enumerable:!1,configurable:!0}),c.prototype.destroy=func