var bl=Object.defineProperty,wl=Object.defineProperties;var Ol=Object.getOwnPropertyDescriptors;var yr=Object.getOwnPropertySymbols;var Oa=Object.prototype.hasOwnProperty,Na=Object.prototype.propertyIsEnumerable;var wa=(t,e,n)=>e in t?bl(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,ot=(t,e)=>{for(var n in e||(e={}))Oa.call(e,n)&&wa(t,n,e[n]);if(yr)for(var n of yr(e))Na.call(e,n)&&wa(t,n,e[n]);return t},Pn=(t,e)=>wl(t,Ol(e));var Aa=(t,e)=>{var n={};for(var r in t)Oa.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&yr)for(var r of yr(t))e.indexOf(r)<0&&Na.call(t,r)&&(n[r]=t[r]);return n};import{s as he,r as yt,a as cu}from"./index.5c46bac7.js";import{n as hs,j as Ei,p as Ri,i as zt,d as Ve,a as I,l as re,t as Vr,v as Io,x as bo,y as Pa,A as ft,B as Nl,C as uu,D as wo,F as du,G as Al,H as Ml,I as lu,J as Pl,K as qi,r as Pe,L as Ll,M as kl,N as Dl,O as Ul,P as xl,Q as Bl,R as Gi,S as Yi,T as Wi}from"./vendor.95d457e9.js";const Vl="_liveHeader_turek_1",Fl="_liveLogo_turek_12",Hl="_liveHeaderLeft_turek_17",$l="_liveHeaderLeftIcon_turek_23",jl="_liveHeaderLeftText_turek_27",Kl="_avatarWrapper_turek_30",ql="_userAvatar_turek_37";var Pt={liveHeader:Vl,liveLogo:Fl,liveHeaderLeft:Hl,liveHeaderLeftIcon:$l,liveHeaderLeftText:jl,avatarWrapper:Kl,userAvatar:ql},Oo;(function(t){t[t.READ=1]="READ",t[t.LISTENED=2]="LISTENED",t[t.DOWNLOADED=4]="DOWNLOADED",t[t.RETRIEVED=8]="RETRIEVED",t[t.UNREAD=0]="UNREAD"})(Oo||(Oo={}));var Dt,Ji,Xn=Oo,Gl=["https://nav.cn.ronghub.com","https://nav2-cn.ronghub.com"],Yl=["wsproxy.cn.ronghub.com","wsap-cn.ronghub.com"],Wl=["cometproxy-cn.ronghub.com","mini-cn.ronghub.com"],La={"RC:TxtMsg":{isCounted:!0,isPersited:!0},"RC:ImgMsg":{isCounted:!0,isPersited:!0},"RC:VcMsg":{isCounted:!0,isPersited:!0},"RC:ImgTextMsg":{isCounted:!0,isPersited:!0},"RC:FileMsg":{isCounted:!0,isPersited:!0},"RC:HQVCMsg":{isCounted:!0,isPersited:!0},"RC:LBSMsg":{isCounted:!0,isPersited:!0},"RC:PSImgTxtMsg":{isCounted:!0,isPersited:!0},"RC:PSMultiImgTxtMsg":{isCounted:!0,isPersited:!0},"RCJrmf:RpMsg":{isCounted:!0,isPersited:!0},"RCJrmf:RpOpendMsg":{isCounted:!0,isPersited:!0},"RC:CombineMsg":{isCounted:!0,isPersited:!0},"RC:ReferenceMsg":{isCounted:!0,isPersited:!0},"RC:SightMsg":{isCounted:!0,isPersited:!0},"RC:GIFMsg":{isCounted:!0,isPersited:!0},"RC:InfoNtf":{isCounted:!1,isPersited:!0},"RC:ContactNtf":{isCounted:!1,isPersited:!0},"RC:ProfileNtf":{isCounted:!1,isPersited:!0},"RC:CmdNtf":{isCounted:!1,isPersited:!0},"RC:GrpNtf":{isCounted:!1,isPersited:!0},"RC:RcCmd":{isCounted:!1,isPersited:!0},"RC:CmdMsg":{isCounted:!1,isPersited:!1},"RC:TypSts":{isCounted:!1,isPersited:!1},"RC:PSCmd":{isCounted:!1,isPersited:!1},"RC:SRSMsg":{isCounted:!1,isPersited:!1},"RC:RRReqMsg":{isCounted:!1,isPersited:!1},"RC:RRRspMsg":{isCounted:!1,isPersited:!1},"RC:CsChaR":{isCounted:!1,isPersited:!1},"RC:CSCha":{isCounted:!1,isPersited:!1},"RC:CsEva":{isCounted:!1,isPersited:!1},"RC:CsContact":{isCounted:!1,isPersited:!1},"RC:CsHs":{isCounted:!1,isPersited:!1},"RC:CsHsR":{isCounted:!1,isPersited:!1},"RC:CsSp":{isCounted:!1,isPersited:!1},"RC:CsEnd":{isCounted:!1,isPersited:!1},"RC:CsUpdate":{isCounted:!1,isPersited:!1},"RC:ReadNtf":{isCounted:!1,isPersited:!1},"RC:chrmKVNotiMsg":{isCounted:!1,isPersited:!1},"RC:VCAccept":{isCounted:!1,isPersited:!1},"RC:VCRinging":{isCounted:!1,isPersited:!1},"RC:VCSummary":{isCounted:!1,isPersited:!1},"RC:VCHangup":{isCounted:!1,isPersited:!1},"RC:VCInvite":{isCounted:!1,isPersited:!1},"RC:VCModifyMedia":{isCounted:!1,isPersited:!1},"RC:VCModifyMem":{isCounted:!1,isPersited:!1},"RC:MsgExMsg":{isCounted:!1,isPersited:!1},"RC:RRMsg":{isCounted:!1,isPersited:!1},"RC:LogCmdMsg":{isCounted:!1,isPersited:!1},"RC:InterceptMsg":{isCounted:!1,isPersited:!1}},Jl=["RC:TypSts","RC:InterceptMsg"];(function(t){t.WEBSOCKET="websocket",t.COMET="comet"})(Dt||(Dt={}));var Ti=function(t){return Ji||(Ji={set:function(e,n){t.localStorage.setItem(e,JSON.stringify(n))},get:function(e){var n;try{n=JSON.parse(t.localStorage.getItem(e))}catch{n=null}return n},remove:function(e){return t.localStorage.removeItem(e)},getKeys:function(){var e=[];for(var n in t.localStorage)e.push(n);return e}}),Ji},zl=function(){function t(e){this._caches={},e&&(this._caches=e)}return t.prototype.set=function(e,n){this._caches[e]=n},t.prototype.remove=function(e){var n=this.get(e);return delete this._caches[e],n},t.prototype.get=function(e){return this._caches[e]},t.prototype.getKeys=function(){var e=[];for(var n in this._caches)e.push(n);return e},t}(),ka=function(){function t(e,n){var r,i=n?"RCV4-"+n:"RCV4-";this._rootStorage=Ti(e);var o=this._rootStorage.get(i)||{};this._cache=new zl(((r={})[i]=o,r)),this._storageKey=i}return t.prototype._get=function(){var e=this._storageKey;return this._cache.get(e)||{}},t.prototype._set=function(e){var n=this._storageKey;e=e||{},this._cache.set(n,e),this._rootStorage.set(n,e)},t.prototype.set=function(e,n){var r=this._get();r[e]=n,this._set(r)},t.prototype.remove=function(e){var n=this._get();delete n[e],this._set(n)},t.prototype.clear=function(){var e=this._storageKey;this._rootStorage.remove(e),this._cache.remove(e)},t.prototype.get=function(e){return this._get()[e]},t.prototype.getKeys=function(){var e=this._get(),n=[];for(var r in e)n.push(r);return n},t.prototype.getValues=function(){return this._get()||{}},t}(),hu=function(t,e){return(hu=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(n[i]=r[i])})(t,e)};function Oe(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}hu(t,e),t.prototype=e===null?Object.create(e):(n.prototype=e.prototype,new n)}var Ee=function(){return(Ee=Object.assign||function(t){for(var e,n=1,r=arguments.length;n0&&i[i.length-1])||h[0]!==6&&h[0]!==2)){s=0;continue}if(h[0]===3&&(!i||h[1]>i[0]&&h[1] "+n)||this}return Oe(e,t),e})(Error);var Da=function(t,e,n){if(e===void 0||n===void 0)return t.toUpperCase();var r=t.slice(e,n);return t=t.replace(r,function(i){return i.toUpperCase()})},fu=function(t,e){e===void 0&&(e="utf-8");var n,r=0;if(e==="utf-16")for(var i=0,o=t.length;i0&&i.indexs.forEach(function(c){o.createIndex(c.indexName,c.key,{unique:c.unique})})}}(e,dn,{indexs:[{indexName:"time",key:"time",unique:!1}],objectStoreParams:{autoIncrement:!0}})}var No,ps=function(){function t(){}return t.init=function(){if(typeof window!="undefined"&&window&&window.indexedDB){var e=window.indexedDB.open("RC_ENGINE_DB",2);e.onerror=function(n){console.warn("open indexDB request failed "+n.target.error)},e.onsuccess=function(n){t._db=n.target.result,t._db&&(t._db.onclose=function(r){var i;console.warn("The database "+((i=t._db)===null||i===void 0?void 0:i.name)+" has unexpectedly closed.",r),t._db=null,t._instance=null},t._db.onerror=function(r){var i;console.warn("The database "+((i=t._db)===null||i===void 0?void 0:i.name)+" has opening error.",r),t._db=null,t._instance=null},t._db.onabort=function(r){var i;console.warn("The database "+((i=t._db)===null||i===void 0?void 0:i.name)+" has opening aborted.",r),t._db=null,t._instance=null}),t._instance=new t},e.onupgradeneeded=function(n){t._db=n.target.result,Ql(n)}}else console.debug("IndexDB is not currently supported in the environment!")},t.getInstance=function(){return t._instance},t.prototype.addList=function(e,n){return new Promise(function(r){if(t._db){var i=t._db.transaction([e],"readwrite"),o=i.objectStore(e);n.forEach(function(s){o==null||o.add(s)}),i.oncomplete=function(s){r(!0)},i.onerror=function(s){r(!1)}}else r(!1)})},t.prototype.getRangeData=function(e,n,r,i){return new Promise(function(o){if(t._db){var s=t._db.transaction([e],"readwrite").objectStore(e),c=IDBKeyRange.bound(r,i),d=s.index(n),l=[],h=d.openCursor(c);h.onsuccess=function(a){var u=a.target.result;u?(l.push(u.value),u.continue()):o(l)},h.onerror=function(a){console.error(a),o([])}}else o([])})},t.prototype.getCount=function(e,n){return new Promise(function(r){if(t._db){var i=t._db.transaction([e],"readonly").objectStore(e).count();i.onsuccess=function(){r(i.result)},i.onerror=function(o){console.error(o),r(0)}}else r(0)})},t.prototype.removeFirstData=function(e,n,r){return new Promise(function(i){if(t._db){var o=t._db.transaction([e],"readwrite").objectStore(e),s=o.getAllKeys(IDBKeyRange.lowerBound(0),r);s.onsuccess=function(){var c=s.result;c.length>0&&(o.delete(IDBKeyRange.bound(c[0],c[c.length-1])).onsuccess=function(){i(!0)})}}else i(!1)})},t._db=null,t}(),pu=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var e=16*Math.random()|0;return(t==="x"?e:3&e|8).toString(16)})},gu=function(){var t=pu();if(t=t.replace(/-/g,"")+"a",(t=function(r){var i="0123456789abcdefghigklmnopqrstuvwxyzABCDEFGHIGKLMNOPQRSTUVWXYZa0".split(""),o=i.length+1,s=+r,c=[];do{var d=s%o;s=(s-d)/o,c.unshift(i[d])}while(s);return c.join("")}(t=parseInt(t,16))).length>22&&(t=t.slice(0,22)),t.length<22)for(var e=22-t.length,n=0;n0},$e=function(t){return Object.prototype.toString.call(t)==="[object Object]"},Jr=function(t){return Object.prototype.toString.call(t)==="[object Function]"},_e=function(t){return t===void 0||Object.prototype.toString.call(t)==="[object Undefined]"},Ua=function(t){return Object.prototype.toString.call(t)==="[object Null]"},Zn=function(t){return nt(t)&&/https?:\/\//.test(t)},Gn=function(t){for(var e in t)return!0;return!1},Xl=function(t){return be(t)&&Object.prototype.hasOwnProperty.call(Ue,t)},xa=((nn={})[De.DEBUG]=console.debug.bind(console),nn[De.INFO]=console.info.bind(console),nn[De.WARN]=console.warn.bind(console),nn[De.ERROR]=console.error.bind(console),nn[De.FATAL]=console.log.bind(console),nn),Ba=function(t){return nt(t)||be(t)||_e(t)||Wr(t)?t:t instanceof Error?JSON.stringify({name:t.name,message:t.message,stack:t.stack}):JSON.stringify(t)},jt=function(){function t(e,n,r){this.tag=e,this.type=n,this.initiator=r,this._outLevel=De.WARN,this.debug=this.log.bind(this,De.DEBUG),this.info=this.log.bind(this,De.INFO),this.warn=this.log.bind(this,De.WARN),this.error=this.log.bind(this,De.ERROR),this.fatal=this.log.bind(this,De.FATAL)}return t.init=function(e){t.userId=e},t.reset=function(){t.userId=""},t.prototype._defaultStdout=function(e,n){for(var r=[],i=2;i=1e3&&(n=function(l,h,a){if(a===void 0&&(a="utf-8"),!l||!h)return"";var u=a==="utf-8"?3:2,f=0,p=0,m="";for(p=0;p255?f+=u:f++,f>h)return m;m+=l.charAt(p)}return l}(n,1e3));var s=JSON.stringify({message:n,userId:t.userId}).replace(/"/g,'""'),c=/^[\w]+-[\w]+-[\w]+?/.test(r)?r:(this.initiator||"L")+"-"+r+"-O",d={sessionId:t.sessionId,time:o,level:4-e,content:t.sessionId+","+Date.now()+","+i+","+(4-e)+","+c+',"'+s+`" `,userId:t.userId};t.databaseLogList.push(d),(t.databaseLogList.length>=100||e===De.FATAL)&&this.__insertLogIntoDatabase()},t.prototype.__insertLogIntoDatabase=function(){return F(this,void 0,void 0,function(){var e,n,r;return H(this,function(i){switch(i.label){case 0:return e=Qt([],t.databaseLogList),t.databaseLogList=[],(n=ps.getInstance())?[4,n.addList(dn,e)]:[3,3];case 1:return r=i.sent(),[4,n.getCount(dn,"time")];case 2:return i.sent()>1e5&&n.removeFirstData(dn,"time",2e3),[2,r];case 3:return[2,!1]}})})},t.prototype.setLogLevel=function(e){this._outLevel=typeof e!="number"?De.WARN:e},t.prototype.setLogStdout=function(e){this._logStdout=e},t.prototype.log=function(e){for(var n=[],r=1;rDe.DEBUG&&this.__pushLocalLog(e,n.map(Ba).join(" "),this.tag),!(e=600&&(t.realTimeLogList=t.realTimeLogList.slice(-500))},t.prototype.set=function(e,n){this.warn("logger.set has being deprecated!")},t.prototype.setStdout=function(e){this._stdout=e},t.prototype.__clearRealTimeLog=function(){t.realTimeLogList=[]},t.databaseLogList=[],t.realTimeLogList=[],t.sessionId=gu(),t.userId="",t}(),Q=new jt("RCLog"),ur=function(){function t(){this._map={}}return t.prototype.on=function(e,n,r){var i=this._map[e]||(this._map[e]=[]);i.some(function(o){return o.listener===n&&o.target===r})||i.push({listener:n,target:r})},t.prototype.once=function(e,n,r){var i=this._map[e]||(this._map[e]=[]);i.some(function(o){return o.listener===n&&o.target===r})||i.push({listener:n,target:r,once:!0})},t.prototype.off=function(e,n,r){var i=this._map[e];i&&((i=i.filter(function(o){return o.listener!==n||o.target!==r})).length?this._map[e]=i:delete this._map[e])},t.prototype.emit=function(e){for(var n=[],r=1;r=0;o-=1){var s=i[o],c=s.target,d=s.once,l=s.listener;d&&i.splice(o,1);try{l.call.apply(l,Qt([c],n))}catch(h){Q.error(h)}}},t.prototype.removeAll=function(e){delete this._map[e]},t.prototype.clear=function(){Object.keys(this._map).forEach(this.removeAll,this)},t}();(function(t){t[t.SEND=1]="SEND",t[t.RECEIVE=2]="RECEIVE"})(Mo||(Mo={}));var Po,ct=Mo;(function(t){t[t.TIMEOUT=-1]="TIMEOUT",t[t.UNKNOWN=-2]="UNKNOWN",t[t.PARAMETER_ERROR=-3]="PARAMETER_ERROR",t[t.EXTRA_METHOD_UNDEFINED=-4]="EXTRA_METHOD_UNDEFINED",t[t.MAIN_PROCESS_ERROR=-5]="MAIN_PROCESS_ERROR",t[t.PARAMETER_CHANGED=-6]="PARAMETER_CHANGED",t[t.SUCCESS=0]="SUCCESS",t[t.RC_MSG_UNAUTHORIZED=20406]="RC_MSG_UNAUTHORIZED",t[t.RC_DISCUSSION_GROUP_ID_INVALID=20407]="RC_DISCUSSION_GROUP_ID_INVALID",t[t.SEND_FREQUENCY_TOO_FAST=20604]="SEND_FREQUENCY_TOO_FAST",t[t.NOT_IN_DISCUSSION=21406]="NOT_IN_DISCUSSION",t[t.FORBIDDEN_IN_GROUP=22408]="FORBIDDEN_IN_GROUP",t[t.RECALL_MESSAGE=25101]="RECALL_MESSAGE",t[t.NOT_IN_GROUP=22406]="NOT_IN_GROUP",t[t.NOT_IN_CHATROOM=23406]="NOT_IN_CHATROOM",t[t.FORBIDDEN_IN_CHATROOM=23408]="FORBIDDEN_IN_CHATROOM",t[t.RC_CHATROOM_USER_KICKED=23409]="RC_CHATROOM_USER_KICKED",t[t.RC_CHATROOM_NOT_EXIST=23410]="RC_CHATROOM_NOT_EXIST",t[t.RC_CHATROOM_IS_FULL=23411]="RC_CHATROOM_IS_FULL",t[t.RC_CHATROOM_PATAMETER_INVALID=23412]="RC_CHATROOM_PATAMETER_INVALID",t[t.CHATROOM_GET_HISTORYMSG_ERROR=23413]="CHATROOM_GET_HISTORYMSG_ERROR",t[t.CHATROOM_NOT_OPEN_HISTORYMSG_STORE=23414]="CHATROOM_NOT_OPEN_HISTORYMSG_STORE",t[t.CHATROOM_KV_EXCEED=23423]="CHATROOM_KV_EXCEED",t[t.CHATROOM_KV_OVERWRITE_INVALID=23424]="CHATROOM_KV_OVERWRITE_INVALID",t[t.CHATROOM_KV_STORE_NOT_OPEN=23426]="CHATROOM_KV_STORE_NOT_OPEN",t[t.CHATROOM_KEY_NOT_EXIST=23427]="CHATROOM_KEY_NOT_EXIST",t[t.SENSITIVE_SHIELD=21501]="SENSITIVE_SHIELD",t[t.SENSITIVE_REPLACE=21502]="SENSITIVE_REPLACE",t[t.JOIN_IN_DISCUSSION=21407]="JOIN_IN_DISCUSSION",t[t.CREATE_DISCUSSION=21408]="CREATE_DISCUSSION",t[t.INVITE_DICUSSION=21409]="INVITE_DICUSSION",t[t.GET_USERINFO_ERROR=23407]="GET_USERINFO_ERROR",t[t.REJECTED_BY_BLACKLIST=405]="REJECTED_BY_BLACKLIST",t[t.RC_NET_CHANNEL_INVALID=30001]="RC_NET_CHANNEL_INVALID",t[t.RC_NET_UNAVAILABLE=30002]="RC_NET_UNAVAILABLE",t[t.RC_MSG_RESP_TIMEOUT=30003]="RC_MSG_RESP_TIMEOUT",t[t.RC_HTTP_SEND_FAIL=30004]="RC_HTTP_SEND_FAIL",t[t.RC_HTTP_REQ_TIMEOUT=30005]="RC_HTTP_REQ_TIMEOUT",t[t.RC_HTTP_RECV_FAIL=30006]="RC_HTTP_RECV_FAIL",t[t.RC_NAVI_RESOURCE_ERROR=30007]="RC_NAVI_RESOURCE_ERROR",t[t.RC_NODE_NOT_FOUND=30008]="RC_NODE_NOT_FOUND",t[t.RC_DOMAIN_NOT_RESOLVE=30009]="RC_DOMAIN_NOT_RESOLVE",t[t.RC_SOCKET_NOT_CREATED=30010]="RC_SOCKET_NOT_CREATED",t[t.RC_SOCKET_DISCONNECTED=30011]="RC_SOCKET_DISCONNECTED",t[t.RC_PING_SEND_FAIL=30012]="RC_PING_SEND_FAIL",t[t.RC_PONG_RECV_FAIL=30013]="RC_PONG_RECV_FAIL",t[t.RC_MSG_SEND_FAIL=30014]="RC_MSG_SEND_FAIL",t[t.RC_MSG_CONTENT_EXCEED_LIMIT=30016]="RC_MSG_CONTENT_EXCEED_LIMIT",t[t.RC_CONN_ACK_TIMEOUT=31e3]="RC_CONN_ACK_TIMEOUT",t[t.RC_CONN_PROTO_VERSION_ERROR=31001]="RC_CONN_PROTO_VERSION_ERROR",t[t.RC_CONN_ID_REJECT=31002]="RC_CONN_ID_REJECT",t[t.RC_CONN_SERVER_UNAVAILABLE=31003]="RC_CONN_SERVER_UNAVAILABLE",t[t.RC_CONN_USER_OR_PASSWD_ERROR=31004]="RC_CONN_USER_OR_PASSWD_ERROR",t[t.RC_CONN_NOT_AUTHRORIZED=31005]="RC_CONN_NOT_AUTHRORIZED",t[t.RC_CONN_REDIRECTED=31006]="RC_CONN_REDIRECTED",t[t.RC_CONN_PACKAGE_NAME_INVALID=31007]="RC_CONN_PACKAGE_NAME_INVALID",t[t.RC_CONN_APP_BLOCKED_OR_DELETED=31008]="RC_CONN_APP_BLOCKED_OR_DELETED",t[t.RC_CONN_USER_BLOCKED=31009]="RC_CONN_USER_BLOCKED",t[t.RC_DISCONN_KICK=31010]="RC_DISCONN_KICK",t[t.RC_DISCONN_EXCEPTION=31011]="RC_DISCONN_EXCEPTION",t[t.RC_APP_AUTH_NOT_PASS=31026]="RC_APP_AUTH_NOT_PASS",t[t.RC_OTP_USED=31027]="RC_OTP_USED",t[t.RC_PLATFORM_ERROR=31028]="RC_PLATFORM_ERROR",t[t.RC_QUERY_ACK_NO_DATA=32001]="RC_QUERY_ACK_NO_DATA",t[t.RC_MSG_DATA_INCOMPLETE=32002]="RC_MSG_DATA_INCOMPLETE",t[t.BIZ_ERROR_CLIENT_NOT_INIT=33001]="BIZ_ERROR_CLIENT_NOT_INIT",t[t.BIZ_ERROR_DATABASE_ERROR=33002]="BIZ_ERROR_DATABASE_ERROR",t[t.BIZ_ERROR_INVALID_PARAMETER=33003]="BIZ_ERROR_INVALID_PARAMETER",t[t.BIZ_ERROR_NO_CHANNEL=33004]="BIZ_ERROR_NO_CHANNEL",t[t.BIZ_ERROR_RECONNECT_SUCCESS=33005]="BIZ_ERROR_RECONNECT_SUCCESS",t[t.BIZ_ERROR_CONNECTING=33006]="BIZ_ERROR_CONNECTING",t[t.MSG_ROAMING_SERVICE_UNAVAILABLE=33007]="MSG_ROAMING_SERVICE_UNAVAILABLE",t[t.MSG_INSERT_ERROR=33008]="MSG_INSERT_ERROR",t[t.MSG_DEL_ERROR=33009]="MSG_DEL_ERROR",t[t.TAG_EXISTS=33101]="TAG_EXISTS",t[t.TAG_NOT_EXIST=33100]="TAG_NOT_EXIST",t[t.NO_TAG_IN_CONVER=33102]="NO_TAG_IN_CONVER",t[t.CONVER_REMOVE_ERROR=34001]="CONVER_REMOVE_ERROR",t[t.CONVER_GETLIST_ERROR=34002]="CONVER_GETLIST_ERROR",t[t.CONVER_SETOP_ERROR=34003]="CONVER_SETOP_ERROR",t[t.CONVER_TOTAL_UNREAD_ERROR=34004]="CONVER_TOTAL_UNREAD_ERROR",t[t.CONVER_TYPE_UNREAD_ERROR=34005]="CONVER_TYPE_UNREAD_ERROR",t[t.CONVER_ID_TYPE_UNREAD_ERROR=34006]="CONVER_ID_TYPE_UNREAD_ERROR",t[t.CONVER_CLEAR_ERROR=34007]="CONVER_CLEAR_ERROR",t[t.EXPANSION_LIMIT_EXCEET=34010]="EXPANSION_LIMIT_EXCEET",t[t.MESSAGE_KV_NOT_SUPPORT=34008]="MESSAGE_KV_NOT_SUPPORT",t[t.CLEAR_HIS_TIME_ERROR=34011]="CLEAR_HIS_TIME_ERROR",t[t.CONVER_OUT_LIMIT_ERROR=34013]="CONVER_OUT_LIMIT_ERROR",t[t.CONVER_GET_ERROR=35021]="CONVER_GET_ERROR",t[t.GROUP_SYNC_ERROR=35001]="GROUP_SYNC_ERROR",t[t.GROUP_MATCH_ERROR=35002]="GROUP_MATCH_ERROR",t[t.READ_RECEIPT_ERROR=35003]="READ_RECEIPT_ERROR",t[t.PACKAGE_ENVIRONMENT_ERROR=35006]="PACKAGE_ENVIRONMENT_ERROR",t[t.CAN_NOT_RECONNECT=35007]="CAN_NOT_RECONNECT",t[t.SERVER_UNAVAILABLE=35008]="SERVER_UNAVAILABLE",t[t.HOSTNAME_ERROR=35009]="HOSTNAME_ERROR",t[t.HAS_OHTER_SAME_CLIENT_ON_LINE=35010]="HAS_OHTER_SAME_CLIENT_ON_LINE",t[t.UPLOAD_FILE_FAILED=35020]="UPLOAD_FILE_FAILED",t[t.CHATROOM_ID_ISNULL=36001]="CHATROOM_ID_ISNULL",t[t.CHARTOOM_JOIN_ERROR=36002]="CHARTOOM_JOIN_ERROR",t[t.CHATROOM_HISMESSAGE_ERROR=36003]="CHATROOM_HISMESSAGE_ERROR",t[t.CHATROOM_KV_NOT_FOUND=36004]="CHATROOM_KV_NOT_FOUND",t[t.BLACK_ADD_ERROR=37001]="BLACK_ADD_ERROR",t[t.BLACK_GETSTATUS_ERROR=37002]="BLACK_GETSTATUS_ERROR",t[t.BLACK_REMOVE_ERROR=37003]="BLACK_REMOVE_ERROR",t[t.DRAF_GET_ERROR=38001]="DRAF_GET_ERROR",t[t.DRAF_SAVE_ERROR=38002]="DRAF_SAVE_ERROR",t[t.DRAF_REMOVE_ERROR=38003]="DRAF_REMOVE_ERROR",t[t.SUBSCRIBE_ERROR=39001]="SUBSCRIBE_ERROR",t[t.NOT_SUPPORT=39002]="NOT_SUPPORT",t[t.QNTKN_FILETYPE_ERROR=41001]="QNTKN_FILETYPE_ERROR",t[t.QNTKN_GET_ERROR=41002]="QNTKN_GET_ERROR",t[t.COOKIE_ENABLE=51001]="COOKIE_ENABLE",t[t.GET_MESSAGE_BY_ID_ERROR=61001]="GET_MESSAGE_BY_ID_ERROR",t[t.HAVNODEVICEID=24001]="HAVNODEVICEID",t[t.DEVICEIDISHAVE=24002]="DEVICEIDISHAVE",t[t.FEILD=24009]="FEILD",t[t.VOIPISNULL=24013]="VOIPISNULL",t[t.NOENGINETYPE=24010]="NOENGINETYPE",t[t.NULLCHANNELNAME=24011]="NULLCHANNELNAME",t[t.VOIPDYANMICERROR=24012]="VOIPDYANMICERROR",t[t.NOVOIP=24014]="NOVOIP",t[t.INTERNALERRROR=24015]="INTERNALERRROR",t[t.VOIPCLOSE=24016]="VOIPCLOSE",t[t.CLOSE_BEFORE_OPEN=51001]="CLOSE_BEFORE_OPEN",t[t.ALREADY_IN_USE=51002]="ALREADY_IN_USE",t[t.INVALID_CHANNEL_NAME=51003]="INVALID_CHANNEL_NAME",t[t.VIDEO_CONTAINER_IS_NULL=51004]="VIDEO_CONTAINER_IS_NULL",t[t.DELETE_MESSAGE_ID_IS_NULL=61001]="DELETE_MESSAGE_ID_IS_NULL",t[t.CANCEL=1]="CANCEL",t[t.REJECT=2]="REJECT",t[t.HANGUP=3]="HANGUP",t[t.BUSYLINE=4]="BUSYLINE",t[t.NO_RESPONSE=5]="NO_RESPONSE",t[t.ENGINE_UN_SUPPORTED=6]="ENGINE_UN_SUPPORTED",t[t.NETWORK_ERROR=7]="NETWORK_ERROR",t[t.REMOTE_CANCEL=11]="REMOTE_CANCEL",t[t.REMOTE_REJECT=12]="REMOTE_REJECT",t[t.REMOTE_HANGUP=13]="REMOTE_HANGUP",t[t.REMOTE_BUSYLINE=14]="REMOTE_BUSYLINE",t[t.REMOTE_NO_RESPONSE=15]="REMOTE_NO_RESPONSE",t[t.REMOTE_ENGINE_UN_SUPPORTED=16]="REMOTE_ENGINE_UN_SUPPORTED",t[t.REMOTE_NETWORK_ERROR=17]="REMOTE_NETWORK_ERROR",t[t.VOIP_NOT_AVALIABLE=18]="VOIP_NOT_AVALIABLE",t[t.CHATROOM_KV_STORE_NOT_ALL_SUCCESS=23428]="CHATROOM_KV_STORE_NOT_ALL_SUCCESS",t[t.CHATROOM_KV_STORE_OUT_LIMIT=23429]="CHATROOM_KV_STORE_OUT_LIMIT"})(Po||(Po={}));var Lo,M=Po;(function(t){t[t.CONNECTED=0]="CONNECTED",t[t.CONNECTING=1]="CONNECTING",t[t.DISCONNECTED=2]="DISCONNECTED",t[t.NETWORK_UNAVAILABLE=3]="NETWORK_UNAVAILABLE",t[t.CONNECTION_CLOSED=4]="CONNECTION_CLOSED",t[t.KICKED_OFFLINE_BY_OTHER_CLIENT=6]="KICKED_OFFLINE_BY_OTHER_CLIENT",t[t.WEBSOCKET_UNAVAILABLE=7]="WEBSOCKET_UNAVAILABLE",t[t.WEBSOCKET_ERROR=8]="WEBSOCKET_ERROR",t[t.BLOCKED=9]="BLOCKED",t[t.DOMAIN_INCORRECT=12]="DOMAIN_INCORRECT",t[t.DISCONNECT_BY_SERVER=13]="DISCONNECT_BY_SERVER",t[t.REDIRECT=14]="REDIRECT",t[t.APPKEY_IS_FAKE=20]="APPKEY_IS_FAKE",t[t.ULTRALIMIT=1101]="ULTRALIMIT",t[t.REQUEST_NAVI=201]="REQUEST_NAVI",t[t.RESPONSE_NAVI=202]="RESPONSE_NAVI",t[t.RESPONSE_NAVI_ERROR=203]="RESPONSE_NAVI_ERROR",t[t.RESPONSE_NAVI_TIMEOUT=204]="RESPONSE_NAVI_TIMEOUT"})(Lo||(Lo={}));var ko,ue=Lo,Ke={ACCEPTED:0,UNACCEPTABLE_PROTOCOL_VERSION:1,IDENTIFIER_REJECTED:2,SERVER_UNAVAILABLE:3,TOKEN_INCORRECT:4,NOT_AUTHORIZED:5,REDIRECT:6,PACKAGE_ERROR:7,APP_BLOCK_OR_DELETE:8,BLOCK:9,TOKEN_EXPIRE:10,DEVICE_ERROR:11,HOSTNAME_ERROR:12,HASOHTERSAMECLIENTONLINE:13,IN_OTHER_CLUSTER:15,APP_AUTH_NOT_PASS:16,OTP_USED:17,PLATFORM_ERROR:18};(function(t){t.TextMessage="RC:TxtMsg",t.VOICE="RC:VcMsg",t.HQ_VOICE="RC:HQVCMsg",t.IMAGE="RC:ImgMsg",t.GIF="RC:GIFMsg",t.RICH_CONTENT="RC:ImgTextMsg",t.LOCATION="RC:LBSMsg",t.FILE="RC:FileMsg",t.SIGHT="RC:SightMsg",t.COMBINE="RC:CombineMsg",t.CHRM_KV_NOTIFY="RC:chrmKVNotiMsg",t.LOG_COMMAND="RC:LogCmdMsg",t.EXPANSION_NOTIFY="RC:MsgExMsg",t.REFERENCE="RC:ReferenceMsg",t.RECALL="RC:RcCmd",t.READ_RECEIPT="RC:ReadNtf",t.READ_RECEIPT_REQUEST="RC:RRReqMsg",t.READ_RECEIPT_RESPONSE="RC:RRRspMsg",t.SYNC_READ_STATUS="RC:SRSMsg",t.GROUP_READ_RECEIPT_REQUEST="RC:RRMsg",t.CHATROOM_JOIN="RC:ChrmJoinNtf",t.CHATROOM_LEFT="RC:ChrmQuitNtf",t.CHATROOM_MERGE_CHANGE="RC:ChrmMemChange",t.TYPING_STATUS="RC:TypSts",t.INTERCEPT="RC:InterceptMsg"})(ko||(ko={}));var Do,Ge=ko;(function(t){t[t.OPEN=1]="OPEN",t[t.CLOSE=2]="CLOSE"})(Do||(Do={}));var Uo,an=Do;(function(t){t[t.ALL=1]="ALL",t[t.SINGAL=2]="SINGAL"})(Uo||(Uo={}));var xo,gs=Uo;(function(t){t[t.QINIU=1]="QINIU",t[t.ALI=2]="ALI",t[t.AWS=3]="AWS",t[t.STC=4]="STC"})(xo||(xo={}));var Bo,ze=xo;(function(t){t[t.UPDATE=1]="UPDATE",t[t.DELETE=2]="DELETE"})(Bo||(Bo={}));var Vo,Ze=Bo;(function(t){t[t.QUIT=0]="QUIT",t[t.JOIN=1]="JOIN"})(Vo||(Vo={}));var Va,Fa=Vo;(function(t){/*! 全局敏感词:命中了融云内置的全局敏感词 */t[t.GLOBAL=1]="GLOBAL",t[t.CUSTOM=2]="CUSTOM",t[t.THIRD_PARTY=3]="THIRD_PARTY"})(Va||(Va={}));var We,Ha,$a;(function(t){t[t.RTC=0]="RTC",t[t.LIVE=2]="LIVE"})(We||(We={})),function(t){t[t.AUDIO_AND_VIDEO=0]="AUDIO_AND_VIDEO",t[t.AUDIO=1]="AUDIO"}(Ha||(Ha={})),function(t){t[t.ANCHOR=1]="ANCHOR",t[t.AUDIENCE=2]="AUDIENCE"}($a||($a={}));var Tt,zr,Fo,Zl={"RC:VCAccept":"RC:VCAccept","RC:VCRinging":"RC:VCRinging","RC:VCSummary":"RC:VCSummary","RC:VCHangup":"RC:VCHangup","RC:VCInvite":"RC:VCInvite","RC:VCModifyMedia":"RC:VCModifyMedia","RC:VCModifyMem":"RC:VCModifyMem"};(function(t){t[t.ROOM=1]="ROOM",t[t.PERSON=2]="PERSON"})(Tt||(Tt={})),function(t){t[t.AnchorToViewer=1]="AnchorToViewer",t[t.ViewerToAnchor=2]="ViewerToAnchor"}(zr||(zr={})),function(t){t[t.KICK=0]="KICK",t[t.REFUSE=1]="REFUSE",t[t.COEXIST=2]="COEXIST"}(Fo||(Fo={}));var Et,Le,zi={engine:"5.1.1"},Xt=function(){function t(){}return t.add=function(e,n){zi[e]=n},t.validEngine=function(e){var n=e.match(/\d+\.\d+\.\d+/);if(!n)return Q.warn("The validation engine version '"+e+"' is invalid!"),!1;var r=n[0].split(".").map(function(i){return i.padStart(3,"0")}).join("");return zi.engine.match(/\d+\.\d+\.\d+/)[0].split(".").map(function(i){return i.padStart(3,"0")}).join("")>=r},t.getInfo=function(){return zi},t}();(function(t){t[t.STRING=0]="STRING",t[t.ONLY_STRING=1]="ONLY_STRING",t[t.NUMBER=2]="NUMBER",t[t.BOOLEAN=3]="BOOLEAN",t[t.OBJECT=4]="OBJECT",t[t.ARRAY=5]="ARRAY",t[t.CALLBACK=6]="CALLBACK",t[t.CHANNEL_ID=7]="CHANNEL_ID"})(Le||(Le={}));var Ot,qe,rt,Zt,Wt,eh=((Et={})[Le.STRING]=et,Et[Le.ONLY_STRING]=nt,Et[Le.NUMBER]=be,Et[Le.BOOLEAN]=function(t){return typeof t=="boolean"},Et[Le.OBJECT]=$e,Et[Le.ARRAY]=Qe,Et[Le.CALLBACK]=function(t){var e=!0;return $e(t)||(e=!1),(t=t||{}).onSuccess&&!Jr(t.onSuccess)&&(e=!1),t.onError&&!Jr(t.onError)&&(e=!1),e},Et[Le.CHANNEL_ID]=function(t){var e=!1;return nt(t)&&!/_/g.test(t)&&t.length<=20&&(e=!0),e},Et),th=function(t){function e(n){var r=t.call(this,n)||this;return r.name="RCAssertError",r}return Oe(e,t),e}(Error),Be=function(t,e,n,r){if(r===void 0&&(r=!1),!Re(t,e,n,r))throw new th("'"+t+"' is invalid: "+JSON.stringify(e))},Re=function(t,e,n,r){r===void 0&&(r=!1),n=eh[n]||n;var i=r&&!n(e)||!r&&!(_e(e)||e===null||n(e));return i&&Q.error("'"+t+"' is invalid: "+JSON.stringify(e)),!i},st=function(t){if(!$e(t)||t.low===void 0||t.high===void 0)return t;var e=t.low;return e<0&&(e+=4294967296),e=e.toString(16),parseInt(t.high.toString(16)+"00000000".replace(new RegExp("0{"+e.length+"}$"),e),16)},nh=function(t,e){var n=Math.floor(1e3*Math.random()%1e4),r=pu(),i=function(d){d=d||"-";var l=new Date;return""+l.getFullYear()+d+(l.getMonth()+1)+d+l.getDate()}(),o=new Date().getTime(),s="";if(e){var c=e.split(".");s="."+c[c.length-1]}return t+"__RC-"+i+"_"+n+"_"+o+r+s},rh=function(t,e){t===void 0&&(t={}),e===void 0&&(e={});var n=t.threadId,r=t.apnsCollapseId,i=t.category,o=t.richMediaUri,s=e.channelIdMi,c=e.channelIdHW,d=e.channelIdOPPO,l=e.typeVivo,h=e.googleConfig,a={};a["thread-id"]=n||"",a["apns-collapse-id"]=r||"",a.category=i||"",a.richMediaUri=o||"";var u={};u.collapse_key=h==null?void 0:h.collapseKey,u.imageUrl=h==null?void 0:h.imageUrl;var f=h==null?void 0:h.priority;f&&!["high","normal"].includes(f)&&(f="normal"),u.priority=f;var p=[{HW:{channelId:c||""}},{MI:{channelId:s||""}},{OPPO:{channelId:d||""}},{VIVO:{classification:l||""}},{APNS:a},{FCM:u}];return JSON.stringify(p)},ja=function(t,e){var n={},r={notificationId:e||""};if(!t)return{iOSConfig:n,androidConfig:r};try{var i=JSON.parse(t);i==null||i.forEach(function(o){var s,c,d,l,h=Object.keys(o);if(h.length!==0){var a=h[0];switch(a){case"HW":return void(r.channelIdHW=(s=o[a])===null||s===void 0?void 0:s.channelId);case"MI":return void(r.channelIdMi=(c=o[a])===null||c===void 0?void 0:c.channelId);case"OPPO":return void(r.channelIdOPPO=(d=o[a])===null||d===void 0?void 0:d.channelId);case"VIVO":return void(r.typeVivo=(l=o[a])===null||l===void 0?void 0:l.classification);case"APNS":return n.threadId=o[a]["thread-id"],n.apnsCollapseId=o[a]["apns-collapse-id"],n.category=o[a].category,void(n.richMediaUri=o[a].richMediaUri);case"FCM":r.googleConfig={collapseKey:o[a].collapse_key||"",imageUrl:o[a].imageUrl||"",priority:o[a].priority||""}}}})}catch{Q.error("Wrong format for pushConfigs field! content: "+t)}return{iOSConfig:n,androidConfig:r}},rn=function(t){var e=/^[A-Za-z0-9_=+-]+$/.test(t),n=t.length;return e&&n<=128&&n>=1},Qi=function(t){var e=t.length;return e<=4096&&e>=1},Me=function(t,e,n){e=e||function(){};var r=(n=n||{}).isReverse;$e(t)&&function(){for(var i in t)e(t[i],i,t)}(),(Qe(t)||nt(t))&&function(){if(r)for(var i=t.length-1;i>=0;i--)e(t[i],i);else for(var o=0,s=t.length;o0;e&&o&&arguments.length===1?(this._retain=(1&e)>0,this.qos=(6&e)>>1,this._dup=(8&e)>0,this.type=e>>4&15,this.syncMsg=(8&e)==8):(this.type=e,this._retain=n,this.qos=r,this._dup=i)}return t.prototype.encode=function(){var e=this.type<<4;return e|=this._retain?1:0,e|=this.qos<<1,e|=this._dup?8:0},t}(),dr=function(){function t(){}return t.writeUTF=function(e,n){var r=[],i=0;if(nt(e))for(var o=0,s=e.length;o=0&&c<=127?(i+=1,r.push(c)):c>=128&&c<=2047?(i+=2,r.push(192|31&c>>6),r.push(128|63&c)):c>=2048&&c<=65535&&(i+=3,r.push(224|15&c>>12),r.push(128|63&c>>6),r.push(128|63&c))}for(o=0,s=r.length;o255&&(r[o]&=255);return n?r:i<=255?[0,i].concat(r):[i>>8,255&i].concat(r)},t.readUTF=function(e){for(var n,r,i=[],o=-1,s=e,c="";++o1114111||Math.floor(d)!==d)throw RangeError("Invalid code point: "+d);d<=65535?i.push(d):(n=(d-=65536)>>10|55296,r=d%1024|56320,i.push(n,r)),(o+1===s.length||i.length>16384)&&(c+=String.fromCharCode.apply(null,i),i.length=0)}return c},t}(),ah=function(){function t(e){this._position=0,this._poolLen=0,this._pool=e,this._poolLen=e.length}return t.prototype.check=function(){return this._position>=this._pool.length},t.prototype.read2Byte=function(){var e=this;if(e.check())return-1;for(var n="",r=0;r<2;r++){var i=e._pool[e._position++].toString(16);i.length===1&&(i="0"+i),n+=i.toString()}return parseInt(n,16)},t.prototype.readInt=function(){var e=this;if(e.check())return-1;for(var n="",r=0;r<4;r++){var i=e._pool[e._position++].toString(16);i.length===1&&(i="0"+i),n+=i.toString()}return parseInt(n,16)},t.prototype.readLong=function(){var e=this;if(e.check())return-1;for(var n="",r=0;r<8;r++){var i=e._pool[e._position++].toString(16);i.length===1&&(i="0"+i),n+=i}return parseInt(n,16)},t.prototype.readByte=function(){if(this.check())return-1;var e=this._pool[this._position++];return e>255&&(e&=255),e},t.prototype.readUTF=function(){if(this.check())return"";var e=this.readByte()<<8|this.readByte(),n=this._pool.subarray(this._position,this._position+=e);return dr.readUTF(n)},t.prototype.readAll=function(){return this._pool.subarray(this._position,this._poolLen)},t}(),ch=function(){function t(){this._pool=[],this._position=0,this._writen=0}return t.prototype.write=function(e){return Object.prototype.toString.call(e).indexOf("Array")!==-1?this._pool=this._pool.concat(e):e>=0&&(e>255&&(e&=255),this._pool.push(e),this._writen++),e},t.prototype.writeArr=function(e){return this._pool=this._pool.concat(e),e},t.prototype.writeUTF=function(e){var n=dr.writeUTF(e);this._pool=this._pool.concat(n),this._writen+=n.length},t.prototype.getBytesArray=function(){return this._pool},t}(),er="UpStreamMessage",_s="PushExtra",Ii="DownStreamMessage",tr="DownStreamMessages",vs="SessionsAttQryInput",vu="SessionsAttOutput",ys="SyncRequestMsg",Cs="ChrmPullMsg",Qr="NotifyMsg",Es="HistoryMsgInput",nr="HistoryMsgOuput",Xr="RelationQryInput",rr="RelationsOutput",Rs="DeleteSessionsInput",Ts="SessionInfo",yu="DeleteSessionsOutput",Ss="RelationsInput",Is="DeleteMsgInput",bs="CleanHisMsgInput",ws="SessionMsgReadInput",Os="ChrmInput",Ns="ChrmOutput",As="QueryChatRoomInfoInput",bi="QueryChatRoomInfoOutput",Zr="RtcInput",Jt="RtcUserListOutput",Ms="SetUserStatusInput",Ps="RtcSetDataInput",ei="RtcUserSetDataInput",ti="RtcDataInput",Ls="RtcSetOutDataInput",ks="MCFollowInput",wi="RtcTokenOutput",Oi="RtcQryOutput",Ds="RtcQryUserOutDataInput",Cu="RtcUserOutDataOutput",Us="RtcQueryListInput",Eu="RtcRoomInfoOutput",at="RtcValueInfo",xs="RtcKeyDeleteInput",Bs="GetQNupTokenInput",Vs="GetQNupTokenOutput",Fs="GetQNdownloadUrlInput",Hs="GetDownloadUrlInput",$s="GetQNdownloadUrlOutput",js="GetDownloadUrlOutput",Ks="SetChrmKV",qs="SetChrmKVS",Ru="DeleteChrmKVS",ln="ChrmKVOutput",Gs="ChrmKVSOutput",Tu="ChrmKVSOutputEntity",Ys="QueryChrmKV",Su="SetUserSettingInput",hn="SetUserSettingOutput",Ws="PullUserSettingInput",Ni="PullUserSettingOutput",Ai="UserSettingNotification",Js="SessionReq",Mi="SessionStates",ni="SessionState",ri="SessionStateItem",ii="SessionStateModifyReq",zs="SessionStateModifyResp",oi="GrpReadReceiptMsg",Iu="GrpReadReceiptQryReq",Pi="GrpReadReceiptQryResp",bu="GrpMsgReadUser",Qs="SessionTagAddInput",Yn="SessionTagItem",Xs="SessionTagDelInput",Zs="SessionDisTagReq",ea="ReportSDKInput",wu="ReportSDKOutput",ta="RtcNotifyMsg",na="RtcPullKV",Li="RtcKVOutput",ra="RtcQueryUserJoinedInput",ki="RtcQueryUserJoinedOutput",Ou="RtcViewerJoinedOutput",ia="RtcInviteInput",oa="RtcCancelInviteInput",sa="RtcInviteAnswerInput",aa="RtcEndInviteInput",Nu=((X={})[er]=["sessionId","classname","content","pushText","userId","configFlag","appData","extraContent","pushExt","busChannel"],X[tr]=["list","syncTime","finished"],X[Ii]=["fromUserId","type","groupId","classname","content","dataTime","status","msgId","extraContent","pushContent","configFlag","pushExt","busChannel"],X[_s]=["title","templateIdNoUse","pushId","pushConfigs","templateId"],X[vs]=["nothing"],X[vu]=["inboxTime","sendboxTime","totalUnreadCount"],X[ys]=["syncTime","ispolling","isweb","isPullSend","isKeeping","sendBoxSyncTime"],X[Cs]=["syncTime","count"],X[Qr]=["type","time","chrmId"],X[Es]=["targetId","time","count","order","busChannel"],X[nr]=["list","syncTime","hasMsg"],X[Xr]=["type","count","startTime","order"],X[rr]=["info"],X[Rs]=["sessions"],X[Ts]=["type","channelId","busChannel"],X[yu]=["nothing"],X[Ss]=["type","msg","count","busChannel","startTime","endTime"],X[Is]=["type","conversationId","msgs","busChannel"],X[bs]=["targetId","dataTime","conversationType","busChannel"],X[ws]=["type","msgTime","channelId"],X[Os]=["nothing"],X[Ns]=["nothing","sessionId","joinTime"],X[As]=["count","order"],X[bi]=["userTotalNums","userInfos"],X[Bs]=["type","key","httpMethod","queryString"],X[Fs]=["type","key","fileName"],X[Hs]=["type","key","fileName"],X[Vs]=["deadline","token","bosToken","bosDate","path","osskeyId","ossPolicy","ossSign","ossBucketName"],X[$s]=["downloadUrl"],X[js]=["downloadUrl"],X[Ks]=["entry","bNotify","notification","type"],X[qs]=["entry","bNotify","notification","type"],X[Ru]=["entry","bNotify","notification","type"],X[ln]=["entries","bFullUpdate","syncTime"],X[Gs]=["timestamp","errorKeys"],X[Tu]=["key","errorCode"],X[Ys]=["timestamp"],X[Su]=["version","value"],X[hn]=["version","reserve"],X[Ws]=["version","reserve"],X[Ni]=["items","version"],X.UserSettingItem=["targetId","type","key","value","version","status","tags"],X[Js]=["time"],X[Mi]=["version","state"],X[ni]=["type","channelId","time","stateItem","busChannel"],X[ri]=["sessionStateType","value","tags"],X[ii]=["version","state"],X[zs]=["version"],X[oi]=["msgId","busChannel"],X[Iu]=["msgId","busChannel"],X[Pi]=["totalMemberNum","list"],X[bu]=["readTime","userId"],X[Qs]=["version","tags"],X[Yn]=["tagId","name","createdTime","isTop"],X[Xs]=["version","tags"],X[Zs]=["tagId"],X[Ai]=["version","reserve"],X[ea]=["sdkInfo"],X[wu]=["nothing"],X[Zr]=["roomType","broadcastType","extraInnerData","needSysChatroom","identityChangeType","joinType"],X[Jt]=["users","token","sessionId","roomInfo"],X[Ms]=["status"],X[Ps]=["interior","target","key","value","objectName","content"],X[ei]=["valueInfo","objectName","content"],X[ti]=["interior","target","key","objectName","content"],X[Ls]=["target","valueInfo","objectName","content"],X[ks]=["state"],X[wi]=["rtcToken"],X[Oi]=["outInfo"],X[Ds]=["userId"],X[Cu]=["user"],X[Us]=["order"],X[Eu]=["roomId","roomData","userCount","list"],X[at]=["key","value"],X[xs]=["key"],X[ta]=["type","time","roomId"],X[na]=["timestamp","roomId"],X[Li]=["entries","bFullUpdate","syncTime"],X[ra]=["userId"],X[ki]=["info"],X[ia]=["invitedUserId","timeoutTime","invitedRoomId","inviteInfo","inviteSessionId"],X[oa]=["invitedUserId","invitedRoomId","inviteInfo","inviteSessionId"],X[sa]=["inviteUserID","answerCode","inviteRoomId","inviteSessionId","content","key","value"],X[aa]=["inviteRoomId","inviteSessionId","inviteContent","inviteRoomKeys"],X),ir={},uh=function(t){var e=Nu[t];ir[t]=function(){for(var n={},r={getArrayData:function(){return n}},i=function(s){var c=e[s],d="set"+Da(c,0,1);r[d]=function(l){n[c]=l}},o=0;o]/g,RULE:/^(?:required|optional|repeated|map)$/,TYPE:/^(?:double|float|int32|uint32|sint32|int64|uint64|sint64|fixed32|sfixed32|fixed64|sfixed64|bool|string|bytes)$/,NAME:/^[a-zA-Z_][a-zA-Z_0-9]*$/,TYPEDEF:/^[a-zA-Z][a-zA-Z_0-9]*$/,TYPEREF:/^(?:\.?[a-zA-Z_][a-zA-Z_0-9]*)+$/,FQTYPEREF:/^(?:\.[a-zA-Z][a-zA-Z_0-9]*)+$/,NUMBER:/^-?(?:[1-9][0-9]*|0|0[xX][0-9a-fA-F]+|0[0-7]+|([0-9]*(\.[0-9]*)?([Ee][+-]?[0-9]+)?)|inf|nan)$/,NUMBER_DEC:/^(?:[1-9][0-9]*|0)$/,NUMBER_HEX:/^0[xX][0-9a-fA-F]+$/,NUMBER_OCT:/^0[0-7]+$/,NUMBER_FLT:/^([0-9]*(\.[0-9]*)?([Ee][+-]?[0-9]+)?|inf|nan)$/,BOOL:/^(?:true|false)$/i,ID:/^(?:[1-9][0-9]*|0|0[xX][0-9a-fA-F]+|0[0-7]+)$/,NEGID:/^\-?(?:[1-9][0-9]*|0|0[xX][0-9a-fA-F]+|0[0-7]+)$/,WHITESPACE:/\s/,STRING:/(?:"([^"\\]*(?:\\.[^"\\]*)*)")|(?:'([^'\\]*(?:\\.[^'\\]*)*)')/g,STRING_DQ:/(?:"([^"\\]*(?:\\.[^"\\]*)*)")/g,STRING_SQ:/(?:'([^'\\]*(?:\\.[^'\\]*)*)')/g},i.DotProto=function(o,s){function c(m,_){var v=-1,y=1;if(m.charAt(0)=="-"&&(y=-1,m=m.substring(1)),s.NUMBER_DEC.test(m))v=parseInt(m);else if(s.NUMBER_HEX.test(m))v=parseInt(m.substring(2),16);else{if(!s.NUMBER_OCT.test(m))throw Error("illegal id value: "+(y<0?"-":"")+m);v=parseInt(m.substring(1),8)}if(v=0|y*v,!_&&v<0)throw Error("illegal id value: "+(y<0?"-":"")+m);return v}function d(m){var _=1;if(m.charAt(0)=="-"&&(_=-1,m=m.substring(1)),s.NUMBER_DEC.test(m))return _*parseInt(m,10);if(s.NUMBER_HEX.test(m))return _*parseInt(m.substring(2),16);if(s.NUMBER_OCT.test(m))return _*parseInt(m.substring(1),8);if(m==="inf")return 1/0*_;if(m==="nan")return NaN;if(s.NUMBER_FLT.test(m))return _*parseFloat(m);throw Error("illegal number value: "+(_<0?"-":"")+m)}function l(m,_,v){m[_]===void 0?m[_]=v:(Array.isArray(m[_])||(m[_]=[m[_]]),m[_].push(v))}var h,a,u={},f=function(m){this.source=m+"",this.index=0,this.line=1,this.stack=[],this._stringOpen=null},p=f.prototype;return p._readString=function(){var m,_=this._stringOpen==='"'?s.STRING_DQ:s.STRING_SQ;if(_.lastIndex=this.index-1,!(m=_.exec(this.source)))throw Error("unterminated string");return this.index=_.lastIndex,this.stack.push(this._stringOpen),this._stringOpen=null,m[1]},p.next=function(){var m,_,v,y,C;if(this.stack.length>0)return this.stack.shift();if(this.index>=this.source.length)return null;if(this._stringOpen!==null)return this._readString();do{for(m=!1;s.WHITESPACE.test(v=this.source.charAt(this.index));)if(v===` `&&++this.line,++this.index===this.source.length)return null;if(this.source.charAt(this.index)==="/")if(++this.index,this.source.charAt(this.index)==="/"){for(;this.source.charAt(++this.index)!==` `;)if(this.index==this.source.length)return null;++this.index,++this.line,m=!0}else{if((v=this.source.charAt(this.index))!=="*")return"/";do{if(v===` `&&++this.line,++this.index===this.source.length)return null;_=v,v=this.source.charAt(this.index)}while(_!=="*"||v!=="/");++this.index,m=!0}}while(m);if(this.index===this.source.length)return null;if(y=this.index,s.DELIM.lastIndex=0,!s.DELIM.test(this.source.charAt(y++)))for(;y"),C=this.tn.next(),!s.NAME.test(C))throw Error("illegal message field name: "+C);y.name=C,this.tn.skip("="),y.id=c(this.tn.next()),(C=this.tn.peek())==="["&&this._parseFieldOptions(y),this.tn.skip(";")}else if((v=v!==void 0?v:this.tn.next())==="group"){if(w=this._parseMessage(m,y),!/^[A-Z]/.test(w.name))throw Error("illegal group name: "+w.name);y.type=w.name,y.name=w.name.toLowerCase(),this.tn.omit(";")}else{if(!s.TYPE.test(v)&&!s.TYPEREF.test(v))throw Error("illegal message field type: "+v);if(y.type=v,C=this.tn.next(),!s.NAME.test(C))throw Error("illegal message field name: "+C);y.name=C,this.tn.skip("="),y.id=c(this.tn.next()),(C=this.tn.peek())==="["&&this._parseFieldOptions(y),this.tn.skip(";")}return m.fields.push(y),y},a._parseMessageOneOf=function(m){var _,v,y,C=this.tn.next();if(!s.NAME.test(C))throw Error("illegal oneof name: "+C);for(v=C,y=[],this.tn.skip("{");(C=this.tn.next())!=="}";)(_=this._parseMessageField(m,"optional",C)).oneof=v,y.push(_.id);this.tn.omit(";"),m.oneofs[v]=y},a._parseFieldOptions=function(m){this.tn.skip("[");for(var _=!0;this.tn.peek()!=="]";)_||this.tn.skip(","),this._parseOption(m,!0),_=!1;this.tn.next()},a._parseEnum=function(m){var _,v={name:"",values:[],options:{}},y=this.tn.next();if(!s.NAME.test(y))throw Error("illegal name: "+y);for(v.name=y,this.tn.skip("{");(y=this.tn.next())!=="}";)if(y==="option")this._parseOption(v);else{if(!s.NAME.test(y))throw Error("illegal name: "+y);this.tn.skip("="),_={name:y,id:c(this.tn.next(),!0)},(y=this.tn.peek())==="["&&this._parseFieldOptions({options:{}}),this.tn.skip(";"),v.values.push(_)}this.tn.omit(";"),m.enums.push(v)},a._parseExtensionRanges=function(){var m,_,v,y=[];do{for(_=[];;){switch(m=this.tn.next()){case"min":v=o.ID_MIN;break;case"max":v=o.ID_MAX;break;default:v=d(m)}if(_.push(v),_.length===2)break;if(this.tn.peek()!=="to"){_.push(v);break}this.tn.next()}y.push(_)}while(this.tn.omit(","));return this.tn.skip(";"),y},a._parseExtend=function(m){var _,v=this.tn.next();if(!s.TYPEREF.test(v))throw Error("illegal extend reference: "+v);for(_={ref:v,fields:[]},this.tn.skip("{");(v=this.tn.next())!=="}";)if(s.RULE.test(v))this._parseMessageField(_,v);else{if(!s.TYPEREF.test(v))throw Error("illegal extend token: "+v);if(!this.proto3)throw Error("illegal field rule: "+v);this._parseMessageField(_,"optional",v)}return this.tn.omit(";"),m.messages.push(_),_},a.toString=function(){return"Parser at line "+this.tn.line},u.Parser=h,u}(i,i.Lang),i.Reflect=function(o){function s(R,S){if(R&&typeof R.low=="number"&&typeof R.high=="number"&&typeof R.unsigned=="boolean"&&R.low==R.low&&R.high==R.high)return new o.Long(R.low,R.high,S===void 0?R.unsigned:S);if(typeof R=="string")return o.Long.fromString(R,S||!1,10);if(typeof R=="number")return o.Long.fromNumber(R,S||!1);throw Error("not convertible to Long")}function c(R,S){var b=S.readVarint32(),A=7&b,N=b>>>3;switch(A){case o.WIRE_TYPES.VARINT:do b=S.readUint8();while((128&b)==128);break;case o.WIRE_TYPES.BITS64:S.offset+=8;break;case o.WIRE_TYPES.LDELIM:b=S.readVarint32(),S.offset+=b;break;case o.WIRE_TYPES.STARTGROUP:c(N,S);break;case o.WIRE_TYPES.ENDGROUP:if(N===R)return!1;throw Error("Illegal GROUPEND after unknown group: "+N+" ("+R+" expected)");case o.WIRE_TYPES.BITS32:S.offset+=4;break;default:throw Error("Illegal wire type in unknown group "+R+": "+A)}return!0}var d,l,h,a,u,f,p,m,_,v,y,C,w,P,T,E,O={},B=function(R,S,b){this.builder=R,this.parent=S,this.name=b,this.className},$=B.prototype;return $.fqn=function(){for(var R=this.name,S=this;(S=S.parent)!=null;)R=S.name+"."+R;return R},$.toString=function(R){return(R?this.className+" ":"")+this.fqn()},$.build=function(){throw Error(this.toString(!0)+" cannot be built directly")},O.T=B,(l=(d=function(R,S,b,A,N){B.call(this,R,S,b),this.className="Namespace",this.children=[],this.options=A||{},this.syntax=N||"proto2"}).prototype=Object.create(B.prototype)).getChildren=function(R){var S,b,A;if((R=R||null)==null)return this.children.slice();for(S=[],b=0,A=this.children.length;A>b;++b)this.children[b]instanceof R&&S.push(this.children[b]);return S},l.addChild=function(R){var S;if(S=this.getChild(R.name))if(S instanceof u.Field&&S.name!==S.originalName&&this.getChild(S.originalName)===null)S.name=S.originalName;else{if(!(R instanceof u.Field&&R.name!==R.originalName&&this.getChild(R.originalName)===null))throw Error("Duplicate name in namespace "+this.toString(!0)+": "+R.name);R.name=R.originalName}this.children.push(R)},l.getChild=function(R){var S,b,A=typeof R=="number"?"id":"name";for(S=0,b=this.children.length;b>S;++S)if(this.children[S][A]===R)return this.children[S];return null},l.resolve=function(R,S){var b,A=typeof R=="string"?R.split("."):R,N=this,x=0;if(A[x]===""){for(;N.parent!==null;)N=N.parent;x++}do{do{if(!(N instanceof O.Namespace)){N=null;break}if(!((b=N.getChild(A[x]))&&b instanceof O.T&&(!S||b instanceof O.Namespace))){N=null;break}N=b,x++}while(xS;++S)(R=N[S])instanceof d&&(A[R.name]=R.build());return Object.defineProperty&&Object.defineProperty(A,"$options",{value:this.buildOpt()}),A},l.buildOpt=function(){var R,S,b,A,N={},x=Object.keys(this.options);for(R=0,S=x.length;S>R;++R)b=x[R],A=this.options[x[R]],N[b]=A;return N},l.getOption=function(R){return R===void 0?this.options:this.options[R]!==void 0?this.options[R]:null},O.Namespace=d,a=(h=function(R,S,b,A){if(this.type=R,this.resolvedType=S,this.isMapKey=b,this.syntax=A,b&&o.MAP_KEY_TYPES.indexOf(R)<0)throw Error("Invalid map key type: "+R.name)}).prototype,h.defaultFieldValue=function(R){if(typeof R=="string"&&(R=o.TYPES[R]),R.defaultValue===void 0)throw Error("default value for type "+R.name+" is not supported");return R==o.TYPES.bytes?new n(0):R.defaultValue},a.verifyValue=function(R){var S,b,A,N=function(x,U){throw Error("Illegal value for "+this.toString(!0)+" of type "+this.type.name+": "+x+" ("+U+")")}.bind(this);switch(this.type){case o.TYPES.int32:case o.TYPES.sint32:case o.TYPES.sfixed32:return(typeof R!="number"||R==R&&R%1!=0)&&N(typeof R,"not an integer"),R>4294967295?0|R:R;case o.TYPES.uint32:case o.TYPES.fixed32:return(typeof R!="number"||R==R&&R%1!=0)&&N(typeof R,"not an integer"),R<0?R>>>0:R;case o.TYPES.int64:case o.TYPES.sint64:case o.TYPES.sfixed64:if(o.Long)try{return s(R,!1)}catch(x){N(typeof R,x.message)}else N(typeof R,"requires Long.js");case o.TYPES.uint64:case o.TYPES.fixed64:if(o.Long)try{return s(R,!0)}catch(x){N(typeof R,x.message)}else N(typeof R,"requires Long.js");case o.TYPES.bool:return typeof R!="boolean"&&N(typeof R,"not a boolean"),R;case o.TYPES.float:case o.TYPES.double:return typeof R!="number"&&N(typeof R,"not a number"),R;case o.TYPES.string:return typeof R=="string"||R&&R instanceof String||N(typeof R,"not a string"),""+R;case o.TYPES.bytes:return t.isByteBuffer(R)?R:t.wrap(R);case o.TYPES.enum:for(S=this.resolvedType.getChildren(o.Reflect.Enum.Value),A=0;A4294967295||R<0)&&N(typeof R,"not in range for uint32"),R;N(R,"not a valid enum value");case o.TYPES.group:case o.TYPES.message:if(R&&typeof R=="object"||N(typeof R,"object expected"),R instanceof this.resolvedType.clazz)return R;if(R instanceof o.Builder.Message){for(A in b={},R)R.hasOwnProperty(A)&&(b[A]=R[A]);R=b}return new this.resolvedType.clazz(R)}throw Error("[INTERNAL] Illegal value for "+this.toString(!0)+": "+R+" (undefined type "+this.type+")")},a.calculateLength=function(R,S){if(S===null)return 0;var b;switch(this.type){case o.TYPES.int32:return S<0?n.calculateVarint64(S):n.calculateVarint32(S);case o.TYPES.uint32:return n.calculateVarint32(S);case o.TYPES.sint32:return n.calculateVarint32(n.zigZagEncode32(S));case o.TYPES.fixed32:case o.TYPES.sfixed32:case o.TYPES.float:return 4;case o.TYPES.int64:case o.TYPES.uint64:return n.calculateVarint64(S);case o.TYPES.sint64:return n.calculateVarint64(n.zigZagEncode64(S));case o.TYPES.fixed64:case o.TYPES.sfixed64:return 8;case o.TYPES.bool:return 1;case o.TYPES.enum:return n.calculateVarint32(S);case o.TYPES.double:return 8;case o.TYPES.string:return b=n.calculateUTF8Bytes(S),n.calculateVarint32(b)+b;case o.TYPES.bytes:if(S.remaining()<0)throw Error("Illegal value for "+this.toString(!0)+": "+S.remaining()+" bytes remaining");return n.calculateVarint32(S.remaining())+S.remaining();case o.TYPES.message:return b=this.resolvedType.calculate(S),n.calculateVarint32(b)+b;case o.TYPES.group:return(b=this.resolvedType.calculate(S))+n.calculateVarint32(R<<3|o.WIRE_TYPES.ENDGROUP)}throw Error("[INTERNAL] Illegal value to encode in "+this.toString(!0)+": "+S+" (unknown type)")},a.encodeValue=function(R,S,b){var A,N;if(S===null)return b;switch(this.type){case o.TYPES.int32:S<0?b.writeVarint64(S):b.writeVarint32(S);break;case o.TYPES.uint32:b.writeVarint32(S);break;case o.TYPES.sint32:b.writeVarint32ZigZag(S);break;case o.TYPES.fixed32:b.writeUint32(S);break;case o.TYPES.sfixed32:b.writeInt32(S);break;case o.TYPES.int64:case o.TYPES.uint64:b.writeVarint64(S);break;case o.TYPES.sint64:b.writeVarint64ZigZag(S);break;case o.TYPES.fixed64:b.writeUint64(S);break;case o.TYPES.sfixed64:b.writeInt64(S);break;case o.TYPES.bool:typeof S=="string"?b.writeVarint32(S.toLowerCase()==="false"?0:!!S):b.writeVarint32(S?1:0);break;case o.TYPES.enum:b.writeVarint32(S);break;case o.TYPES.float:b.writeFloat32(S);break;case o.TYPES.double:b.writeFloat64(S);break;case o.TYPES.string:b.writeVString(S);break;case o.TYPES.bytes:if(S.remaining()<0)throw Error("Illegal value for "+this.toString(!0)+": "+S.remaining()+" bytes remaining");A=S.offset,b.writeVarint32(S.remaining()),b.append(S),S.offset=A;break;case o.TYPES.message:N=new n().LE(),this.resolvedType.encode(S,N),b.writeVarint32(N.offset),b.append(N.flip());break;case o.TYPES.group:this.resolvedType.encode(S,b),b.writeVarint32(R<<3|o.WIRE_TYPES.ENDGROUP);break;default:throw Error("[INTERNAL] Illegal value to encode in "+this.toString(!0)+": "+S+" (unknown type)")}return b},a.decode=function(R,S,b){if(S!=this.type.wireType)throw Error("Unexpected wire type for element");var A,N;switch(this.type){case o.TYPES.int32:return 0|R.readVarint32();case o.TYPES.uint32:return R.readVarint32()>>>0;case o.TYPES.sint32:return 0|R.readVarint32ZigZag();case o.TYPES.fixed32:return R.readUint32()>>>0;case o.TYPES.sfixed32:return 0|R.readInt32();case o.TYPES.int64:return R.readVarint64();case o.TYPES.uint64:return R.readVarint64().toUnsigned();case o.TYPES.sint64:return R.readVarint64ZigZag();case o.TYPES.fixed64:return R.readUint64();case o.TYPES.sfixed64:return R.readInt64();case o.TYPES.bool:return!!R.readVarint32();case o.TYPES.enum:return R.readVarint32();case o.TYPES.float:return R.readFloat();case o.TYPES.double:return R.readDouble();case o.TYPES.string:return R.readVString();case o.TYPES.bytes:if(N=R.readVarint32(),R.remaining()G;++G)this[W[G].name]=null;for(G=0,te=z.length;te>G;++G)this[(ie=z[G]).name]=ie.repeated?[]:ie.map?new x.Map(ie):null,!ie.required&&U.syntax!=="proto3"||ie.defaultValue===null||(this[ie.name]=ie.defaultValue);if(arguments.length>0)if(arguments.length!==1||D===null||typeof D!="object"||!(typeof D.encode!="function"||D instanceof K)||Array.isArray(D)||D instanceof x.Map||n.isByteBuffer(D)||D instanceof ArrayBuffer||x.Long&&D instanceof x.Long)for(G=0,te=arguments.length;te>G;++G)(ce=arguments[G])!==void 0&&this.$set(z[G].name,ce);else this.$set(D)},J=K.prototype=Object.create(x.Builder.Message.prototype);for(J.add=function(D,G,te){var ie=U._fieldsByName[D];if(!te){if(!ie)throw Error(this+"#"+D+" is undefined");if(!(ie instanceof x.Reflect.Message.Field))throw Error(this+"#"+D+" is not a field: "+ie.toString(!0));if(!ie.repeated)throw Error(this+"#"+D+" is not a repeated field");G=ie.verifyValue(G,!0)}return this[D]===null&&(this[D]=[]),this[D].push(G),this},J.$add=J.add,J.set=function(D,G,te){var ie,ce,fe;if(D&&typeof D=="object"){for(ie in te=G,D)D.hasOwnProperty(ie)&&(G=D[ie])!==void 0&&this.$set(ie,G,te);return this}if(ce=U._fieldsByName[D],te)this[D]=G;else{if(!ce)throw Error(this+"#"+D+" is not a field: undefined");if(!(ce instanceof x.Reflect.Message.Field))throw Error(this+"#"+D+" is not a field: "+ce.toString(!0));this[ce.name]=G=ce.verifyValue(G)}return ce&&ce.oneof&&(fe=this[ce.oneof.name],G!==null?(fe!==null&&fe!==ce.name&&(this[fe]=null),this[ce.oneof.name]=ce.name):fe===D&&(this[ce.oneof.name]=null)),this},J.$set=J.set,J.get=function(D,G){if(G)return this[D];var te=U._fieldsByName[D];if(!(te&&te instanceof x.Reflect.Message.Field))throw Error(this+"#"+D+" is not a field: undefined");if(!(te instanceof x.Reflect.Message.Field))throw Error(this+"#"+D+" is not a field: "+te.toString(!0));return this[te.name]},J.$get=J.get,Y=0;YA;A++)if((b=this.children[A])instanceof y||b instanceof u||b instanceof P){if(S.hasOwnProperty(b.name))throw Error("Illegal reflect child of "+this.toString(!0)+": "+b.toString(!0)+" cannot override static property '"+b.name+"'");S[b.name]=b.build()}else if(b instanceof u.Field)b.build(),this._fields.push(b),this._fieldsById[b.id]=b,this._fieldsByName[b.name]=b;else if(!(b instanceof u.OneOf||b instanceof w))throw Error("Illegal reflect child of "+this.toString(!0)+": "+this.children[A].toString(!0));return this.clazz=S},f.encode=function(R,S,b){var A,N,x,U,j,Y=null;for(x=0,U=this._fields.length;U>x;++x)N=R[(A=this._fields[x]).name],A.required&&N===null?Y===null&&(Y=A):A.encode(b?N:A.verifyValue(N),S,R);if(Y!==null)throw(j=Error("Missing at least one required field for "+this.toString(!0)+": "+Y)).encoded=S,j;return S},f.calculate=function(R){for(var S,b,A=0,N=0,x=this._fields.length;x>N;++N){if(b=R[(S=this._fields[N]).name],S.required&&b===null)throw Error("Missing at least one required field for "+this.toString(!0)+": "+S);A+=S.calculate(b,R)}return A},f.decode=function(R,S,b){var A,N,x,U,j,Y,ee,z,W,K,J,D;for(S=typeof S=="number"?S:-1,j=R.offset,Y=new this.clazz;R.offset0;){if(x=(A=R.readVarint32())>>>3,(N=7&A)===o.WIRE_TYPES.ENDGROUP){if(x!==b)throw Error("Illegal group end indicator for "+this.toString(!0)+": "+x+" ("+(b?b+" expected":"not a group")+")");break}if(U=this._fieldsById[x])U.repeated&&!U.options.packed?Y[U.name].push(U.decode(N,R)):U.map?(z=U.decode(N,R),Y[U.name].set(z[0],z[1])):(Y[U.name]=U.decode(N,R),U.oneof&&((W=Y[U.oneof.name])!==null&&W!==U.name&&(Y[W]=null),Y[U.oneof.name]=U.name));else switch(N){case o.WIRE_TYPES.VARINT:R.readVarint32();break;case o.WIRE_TYPES.BITS32:R.offset+=4;break;case o.WIRE_TYPES.BITS64:R.offset+=8;break;case o.WIRE_TYPES.LDELIM:ee=R.readVarint32(),R.offset+=ee;break;case o.WIRE_TYPES.STARTGROUP:for(;c(x,R););break;default:throw Error("Illegal wire type for unknown field "+x+" in "+this.toString(!0)+"#decode: "+N)}}for(K=0,J=this._fields.length;J>K;++K)if(Y[(U=this._fields[K]).name]===null)if(this.syntax==="proto3")Y[U.name]=U.defaultValue;else{if(U.required)throw(D=Error("Missing at least one required field for "+this.toString(!0)+": "+U.name)).decoded=Y,D;o.populateDefaults&&U.defaultValue!==null&&(Y[U.name]=U.defaultValue)}return Y},O.Message=u,(m=(p=function(R,S,b,A,N,x,U,j,Y,ee){B.call(this,R,S,x),this.className="Message.Field",this.required=b==="required",this.repeated=b==="repeated",this.map=b==="map",this.keyType=A||null,this.type=N,this.resolvedType=null,this.id=U,this.options=j||{},this.defaultValue=null,this.oneof=Y||null,this.syntax=ee||"proto2",this.originalName=this.name,this.element=null,this.keyElement=null,!this.builder.options.convertFieldsToCamelCase||this instanceof u.ExtensionField||(this.name=o.Util.toCamelCase(this.name))}).prototype=Object.create(B.prototype)).build=function(){this.element=new h(this.type,this.resolvedType,!1,this.syntax),this.map&&(this.keyElement=new h(this.keyType,void 0,!0,this.syntax)),this.syntax!=="proto3"||this.repeated||this.map?this.options.default!==void 0&&(this.defaultValue=this.verifyValue(this.options.default)):this.defaultValue=h.defaultFieldValue(this.type)},m.verifyValue=function(R,S){var b,A,N;if(S=S||!1,b=function(x,U){throw Error("Illegal value for "+this.toString(!0)+" of type "+this.type.name+": "+x+" ("+U+")")}.bind(this),R===null)return this.required&&b(typeof R,"required"),this.syntax==="proto3"&&this.type!==o.TYPES.message&&b(typeof R,"proto3 field without field presence cannot be null"),null;if(this.repeated&&!S){for(Array.isArray(R)||(R=[R]),N=[],A=0;A0;case o.TYPES.bytes:return R.remaining()>0;case o.TYPES.enum:return R!==0;case o.TYPES.message:return R!==null;default:return!0}},m.encode=function(R,S,b){var A,N,x,U,j;if(this.type===null||typeof this.type!="object")throw Error("[INTERNAL] Unresolved type in "+this.toString(!0)+": "+this.type);if(R===null||this.repeated&&R.length==0)return S;try{if(this.repeated)if(this.options.packed&&o.PACKABLE_WIRE_TYPES.indexOf(this.type.wireType)>=0){for(S.writeVarint32(this.id<<3|o.WIRE_TYPES.LDELIM),S.ensureCapacity(S.offset+=1),N=S.offset,A=0;A1&&(j=S.slice(N,S.offset),N+=U-1,S.offset=N,S.append(j)),S.writeVarint32(x,N-U)}else for(A=0;A=0){for(b+=n.calculateVarint32(this.id<<3|o.WIRE_TYPES.LDELIM),N=0,A=0;A=0&&!b){for(N=S.readVarint32(),N=S.offset+N,x=[];S.offset0;)if(R=7&(Y=j.readVarint32()),(ee=Y>>>3)==1)U=this.keyElement.decode(j,R,ee);else{if(ee!==2)throw Error("Unexpected tag in map field key/value submessage");A=this.element.decode(j,R,ee)}return[U,A]}return this.element.decode(S,R,this.id)},O.Message.Field=p,(_=function(R,S,b,A,N,x,U){p.call(this,R,S,b,null,A,N,x,U),this.extension}).prototype=Object.create(p.prototype),O.Message.ExtensionField=_,v=function(R,S,b){B.call(this,R,S,b),this.fields=[]},O.Message.OneOf=v,(y=function(R,S,b,A,N){d.call(this,R,S,b,A,N),this.className="Enum",this.object=null}).getName=function(R,S){var b,A,N=Object.keys(R);for(A=0;AA;++A)S[b[A].name]=b[A].id;return Object.defineProperty&&Object.defineProperty(S,"$options",{value:this.buildOpt(),enumerable:!1}),this.object=S},O.Enum=y,(C=function(R,S,b,A){B.call(this,R,S,b),this.className="Enum.Value",this.id=A}).prototype=Object.create(B.prototype),O.Enum.Value=C,(w=function(R,S,b,A){B.call(this,R,S,b),this.field=A}).prototype=Object.create(B.prototype),O.Extension=w,((P=function(R,S,b,A){d.call(this,R,S,b,A),this.className="Service",this.clazz=null}).prototype=Object.create(d.prototype)).build=function(R){return this.clazz&&!R?this.clazz:this.clazz=function(S,b){var A,N=function(j){S.Builder.Service.call(this),this.rpcImpl=j||function(Y,ee,z){setTimeout(z.bind(this,Error("Not implemented, see: https://github.com/dcodeIO/ProtoBuf.js/wiki/Services")),0)}},x=N.prototype=Object.create(S.Builder.Service.prototype),U=b.getChildren(S.Reflect.Service.RPCMethod);for(A=0;A0;){if(a=u.pop(),!Array.isArray(a))throw Error("not a valid namespace: "+JSON.stringify(a));for(;a.length>0;){if(f=a.shift(),l.isMessage(f)){if(p=new c.Message(this,this.ptr,f.name,f.options,f.isGroup,f.syntax),m={},f.oneofs&&Object.keys(f.oneofs).forEach(function(v){p.addChild(m[v]=new c.Message.OneOf(this,p,v))},this),f.fields&&f.fields.forEach(function(v){if(p.getChild(0|v.id)!==null)throw Error("duplicate or invalid field id in "+p.name+": "+v.id);if(v.options&&typeof v.options!="object")throw Error("illegal field options in "+p.name+"#"+v.name);var y=null;if(typeof v.oneof=="string"&&!(y=m[v.oneof]))throw Error("illegal oneof in "+p.name+"#"+v.name+": "+v.oneof);v=new c.Message.Field(this,p,v.rule,v.keytype,v.type,v.name,v.id,v.options,y,f.syntax),y&&y.fields.push(v),p.addChild(v)},this),_=[],f.enums&&f.enums.forEach(function(v){_.push(v)}),f.messages&&f.messages.forEach(function(v){_.push(v)}),f.services&&f.services.forEach(function(v){_.push(v)}),f.extensions&&(p.extensions=typeof f.extensions[0]=="number"?[f.extensions]:f.extensions),this.ptr.addChild(p),_.length>0){u.push(a),a=_,_=null,this.ptr=p,p=null;continue}_=null}else if(l.isEnum(f))p=new c.Enum(this,this.ptr,f.name,f.options,f.syntax),f.values.forEach(function(v){p.addChild(new c.Enum.Value(this,p,v.name,v.id))},this),this.ptr.addChild(p);else if(l.isService(f))p=new c.Service(this,this.ptr,f.name,f.options),Object.keys(f.rpc).forEach(function(v){var y=f.rpc[v];p.addChild(new c.Service.RPCMethod(this,p,v,y.request,y.response,!!y.request_stream,!!y.response_stream,y.options))},this),this.ptr.addChild(p);else{if(!l.isExtend(f))throw Error("not a valid definition: "+JSON.stringify(f));if(p=this.ptr.resolve(f.ref,!0))f.fields.forEach(function(v){var y,C,w,P;if(p.getChild(0|v.id)!==null)throw Error("duplicate extended field id in "+p.name+": "+v.id);if(p.extensions&&(y=!1,p.extensions.forEach(function(T){v.id>=T[0]&&v.id<=T[1]&&(y=!0)}),!y))throw Error("illegal extended field id in "+p.name+": "+v.id+" (not within valid ranges)");C=v.name,this.options.convertFieldsToCamelCase&&(C=o.Util.toCamelCase(C)),w=new c.Message.ExtensionField(this,p,v.rule,v.type,this.ptr.fqn()+"."+C,v.id,v.options),P=new c.Extension(this,this.ptr,v.name,w),w.extension=P,this.ptr.addChild(P),p.addChild(w)},this);else if(!/\.?google\.protobuf\./.test(f.ref))throw Error("extended message "+f.ref+" is not defined")}f=null,p=null}a=null,this.ptr=this.ptr.parent}return this.resolved=!1,this.result=null,this},h.import=function(a,u){var f,p,m,_,v,y,C,w,P="/";if(typeof u=="string"){if(o.Util.IS_NODE,this.files[u]===!0)return this.reset();this.files[u]=!0}else if(typeof u=="object"){if(f=u.root,o.Util.IS_NODE,(f.indexOf("\\")>=0||u.file.indexOf("\\")>=0)&&(P="\\"),p=f+P+u.file,this.files[p]===!0)return this.reset();this.files[p]=!0}if(a.imports&&a.imports.length>0){for(_=!1,typeof u=="object"?(this.importRoot=u.root,_=!0,m=this.importRoot,u=u.file,(m.indexOf("\\")>=0||u.indexOf("\\")>=0)&&(P="\\")):typeof u=="string"?this.importRoot?m=this.importRoot:u.indexOf("/")>=0?(m=u.replace(/\/[^\/]*$/,""))===""&&(m="/"):u.indexOf("\\")>=0?(m=u.replace(/\\[^\\]*$/,""),P="\\"):m=".":m=null,v=0;v1024&&(u.push(c.apply(String,a)),a.length=0),void Array.prototype.push.apply(a,arguments))}}function r(a,u,f,p,m){var _,v,y=8*m-p-1,C=(1<>1,P=-7,T=f?m-1:0,E=f?-1:1,O=a[u+T];for(T+=E,_=O&(1<<-P)-1,O>>=-P,P+=y;P>0;_=256*_+a[u+T],T+=E,P-=8);for(v=_&(1<<-P)-1,_>>=-P,P+=p;P>0;v=256*v+a[u+T],T+=E,P-=8);if(_===0)_=1-w;else{if(_===C)return v?NaN:1/0*(O?-1:1);v+=Math.pow(2,p),_-=w}return(O?-1:1)*v*Math.pow(2,_-p)}function i(a,u,f,p,m,_){var v,y,C,w=8*_-m-1,P=(1<>1,E=m===23?Math.pow(2,-24)-Math.pow(2,-77):0,O=p?0:_-1,B=p?1:-1,$=u<0||u===0&&1/u<0?1:0;for(u=Math.abs(u),isNaN(u)||1/0===u?(y=isNaN(u)?1:0,v=P):(v=Math.floor(Math.log(u)/Math.LN2),u*(C=Math.pow(2,-v))<1&&(v--,C*=2),(u+=v+T>=1?E/C:E*Math.pow(2,1-T))*C>=2&&(v++,C/=2),v+T>=P?(y=0,v=P):v+T>=1?(y=(u*C-1)*Math.pow(2,m),v+=T):(y=u*Math.pow(2,T-1)*Math.pow(2,m),v=0));m>=8;a[f+O]=255&y,O+=B,y/=256,m-=8);for(v=v<0;a[f+O]=255&v,O+=B,v/=256,w-=8);a[f+O-B]|=128*$}var o,s,c,d,l,h=function(a,u,f){if(a===void 0&&(a=h.DEFAULT_CAPACITY),u===void 0&&(u=h.DEFAULT_ENDIAN),f===void 0&&(f=h.DEFAULT_NOASSERT),!f){if((a|=0)<0)throw RangeError("Illegal capacity");u=!!u,f=!!f}this.buffer=a===0?s:new ArrayBuffer(a),this.view=a===0?null:new Uint8Array(this.buffer),this.offset=0,this.markedOffset=-1,this.limit=a,this.littleEndian=u,this.noAssert=f};return h.VERSION="5.0.1",h.LITTLE_ENDIAN=!0,h.BIG_ENDIAN=!1,h.DEFAULT_CAPACITY=16,h.DEFAULT_ENDIAN=h.BIG_ENDIAN,h.DEFAULT_NOASSERT=!1,h.Long=t||null,(o=h.prototype).__isByteBuffer__,Object.defineProperty(o,"__isByteBuffer__",{value:!0,enumerable:!1,configurable:!1}),s=new ArrayBuffer(0),c=String.fromCharCode,h.accessor=function(){return Uint8Array},h.allocate=function(a,u,f){return new h(a,u,f)},h.concat=function(a,u,f,p){var m,_,v,y,C,w;for((typeof u=="boolean"||typeof u!="string")&&(p=f,f=u,u=void 0),m=0,v=0,y=a.length;y>v;++v)h.isByteBuffer(a[v])||(a[v]=h.wrap(a[v],u)),(_=a[v].limit-a[v].offset)>0&&(m+=_);if(m===0)return new h(0,f,p);for(w=new h(m,f,p),v=0;y>v;)(_=(C=a[v++]).limit-C.offset)<=0||(w.view.set(C.view.subarray(C.offset,C.limit),w.offset),w.offset+=_);return w.limit=w.offset,w.offset=0,w},h.isByteBuffer=function(a){return(a&&a.__isByteBuffer__)===!0},h.type=function(){return ArrayBuffer},h.wrap=function(a,u,f,p){var m,_;if(typeof u!="string"&&(p=f,f=u,u=void 0),typeof a=="string")switch(u===void 0&&(u="utf8"),u){case"base64":return h.fromBase64(a,f);case"hex":return h.fromHex(a,f);case"binary":return h.fromBinary(a,f);case"utf8":return h.fromUTF8(a,f);case"debug":return h.fromDebug(a,f);default:throw Error("Unsupported encoding: "+u)}if(a===null||typeof a!="object")throw TypeError("Illegal buffer");if(h.isByteBuffer(a))return(m=o.clone.call(a)).markedOffset=-1,m;if(a instanceof Uint8Array)m=new h(0,f,p),a.length>0&&(m.buffer=a.buffer,m.offset=a.byteOffset,m.limit=a.byteOffset+a.byteLength,m.view=new Uint8Array(a.buffer));else if(a instanceof ArrayBuffer)m=new h(0,f,p),a.byteLength>0&&(m.buffer=a,m.offset=0,m.limit=a.byteLength,m.view=a.byteLength>0?new Uint8Array(a):null);else{if(Object.prototype.toString.call(a)!=="[object Array]")throw TypeError("Illegal buffer");for((m=new h(a.length,f,p)).limit=a.length,_=0;_>>=0)<0||u+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+u+" (+0) <= "+this.buffer.byteLength)}for(p=u,_=(m=a.length)>>3,v=0,u+=this.writeVarint32(m,u);_--;)f=1&!!a[v++]|(1&!!a[v++])<<1|(1&!!a[v++])<<2|(1&!!a[v++])<<3|(1&!!a[v++])<<4|(1&!!a[v++])<<5|(1&!!a[v++])<<6|(1&!!a[v++])<<7,this.writeByte(f,u++);if(m>v){for(y=0,f=0;m>v;)f|=(1&!!a[v++])<>3,_=0,v=[],a+=f.length;m--;)u=this.readByte(a++),v[_++]=!!(1&u),v[_++]=!!(2&u),v[_++]=!!(4&u),v[_++]=!!(8&u),v[_++]=!!(16&u),v[_++]=!!(32&u),v[_++]=!!(64&u),v[_++]=!!(128&u);if(p>_)for(y=0,u=this.readByte(a++);p>_;)v[_++]=!!(1&u>>y++);return C&&(this.offset=a),v},o.readBytes=function(a,u){var f,p=u===void 0;if(p&&(u=this.offset),!this.noAssert){if(typeof u!="number"||u%1!=0)throw TypeError("Illegal offset: "+u+" (not an integer)");if((u>>>=0)<0||u+a>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+u+" (+"+a+") <= "+this.buffer.byteLength)}return f=this.slice(u,u+a),p&&(this.offset+=a),f},o.writeBytes=o.append,o.writeInt8=function(a,u){var f,p=u===void 0;if(p&&(u=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal value: "+a+" (not an integer)");if(a|=0,typeof u!="number"||u%1!=0)throw TypeError("Illegal offset: "+u+" (not an integer)");if((u>>>=0)<0||u+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+u+" (+0) <= "+this.buffer.byteLength)}return(u+=1)>(f=this.buffer.byteLength)&&this.resize((f*=2)>u?f:u),u-=1,this.view[u]=a,p&&(this.offset+=1),this},o.writeByte=o.writeInt8,o.readInt8=function(a){var u,f=a===void 0;if(f&&(a=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal offset: "+a+" (not an integer)");if((a>>>=0)<0||a+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+1) <= "+this.buffer.byteLength)}return(128&(u=this.view[a]))==128&&(u=-(255-u+1)),f&&(this.offset+=1),u},o.readByte=o.readInt8,o.writeUint8=function(a,u){var f,p=u===void 0;if(p&&(u=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal value: "+a+" (not an integer)");if(a>>>=0,typeof u!="number"||u%1!=0)throw TypeError("Illegal offset: "+u+" (not an integer)");if((u>>>=0)<0||u+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+u+" (+0) <= "+this.buffer.byteLength)}return(u+=1)>(f=this.buffer.byteLength)&&this.resize((f*=2)>u?f:u),u-=1,this.view[u]=a,p&&(this.offset+=1),this},o.writeUInt8=o.writeUint8,o.readUint8=function(a){var u,f=a===void 0;if(f&&(a=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal offset: "+a+" (not an integer)");if((a>>>=0)<0||a+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+1) <= "+this.buffer.byteLength)}return u=this.view[a],f&&(this.offset+=1),u},o.readUInt8=o.readUint8,o.writeInt16=function(a,u){var f,p=u===void 0;if(p&&(u=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal value: "+a+" (not an integer)");if(a|=0,typeof u!="number"||u%1!=0)throw TypeError("Illegal offset: "+u+" (not an integer)");if((u>>>=0)<0||u+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+u+" (+0) <= "+this.buffer.byteLength)}return(u+=2)>(f=this.buffer.byteLength)&&this.resize((f*=2)>u?f:u),u-=2,this.littleEndian?(this.view[u+1]=(65280&a)>>>8,this.view[u]=255&a):(this.view[u]=(65280&a)>>>8,this.view[u+1]=255&a),p&&(this.offset+=2),this},o.writeShort=o.writeInt16,o.readInt16=function(a){var u,f=a===void 0;if(f&&(a=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal offset: "+a+" (not an integer)");if((a>>>=0)<0||a+2>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+2) <= "+this.buffer.byteLength)}return u=0,this.littleEndian?(u=this.view[a],u|=this.view[a+1]<<8):(u=this.view[a]<<8,u|=this.view[a+1]),(32768&u)==32768&&(u=-(65535-u+1)),f&&(this.offset+=2),u},o.readShort=o.readInt16,o.writeUint16=function(a,u){var f,p=u===void 0;if(p&&(u=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal value: "+a+" (not an integer)");if(a>>>=0,typeof u!="number"||u%1!=0)throw TypeError("Illegal offset: "+u+" (not an integer)");if((u>>>=0)<0||u+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+u+" (+0) <= "+this.buffer.byteLength)}return(u+=2)>(f=this.buffer.byteLength)&&this.resize((f*=2)>u?f:u),u-=2,this.littleEndian?(this.view[u+1]=(65280&a)>>>8,this.view[u]=255&a):(this.view[u]=(65280&a)>>>8,this.view[u+1]=255&a),p&&(this.offset+=2),this},o.writeUInt16=o.writeUint16,o.readUint16=function(a){var u,f=a===void 0;if(f&&(a=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal offset: "+a+" (not an integer)");if((a>>>=0)<0||a+2>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+2) <= "+this.buffer.byteLength)}return u=0,this.littleEndian?(u=this.view[a],u|=this.view[a+1]<<8):(u=this.view[a]<<8,u|=this.view[a+1]),f&&(this.offset+=2),u},o.readUInt16=o.readUint16,o.writeInt32=function(a,u){var f,p=u===void 0;if(p&&(u=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal value: "+a+" (not an integer)");if(a|=0,typeof u!="number"||u%1!=0)throw TypeError("Illegal offset: "+u+" (not an integer)");if((u>>>=0)<0||u+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+u+" (+0) <= "+this.buffer.byteLength)}return(u+=4)>(f=this.buffer.byteLength)&&this.resize((f*=2)>u?f:u),u-=4,this.littleEndian?(this.view[u+3]=255&a>>>24,this.view[u+2]=255&a>>>16,this.view[u+1]=255&a>>>8,this.view[u]=255&a):(this.view[u]=255&a>>>24,this.view[u+1]=255&a>>>16,this.view[u+2]=255&a>>>8,this.view[u+3]=255&a),p&&(this.offset+=4),this},o.writeInt=o.writeInt32,o.readInt32=function(a){var u,f=a===void 0;if(f&&(a=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal offset: "+a+" (not an integer)");if((a>>>=0)<0||a+4>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+4) <= "+this.buffer.byteLength)}return u=0,this.littleEndian?(u=this.view[a+2]<<16,u|=this.view[a+1]<<8,u|=this.view[a],u+=this.view[a+3]<<24>>>0):(u=this.view[a+1]<<16,u|=this.view[a+2]<<8,u|=this.view[a+3],u+=this.view[a]<<24>>>0),u|=0,f&&(this.offset+=4),u},o.readInt=o.readInt32,o.writeUint32=function(a,u){var f,p=u===void 0;if(p&&(u=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal value: "+a+" (not an integer)");if(a>>>=0,typeof u!="number"||u%1!=0)throw TypeError("Illegal offset: "+u+" (not an integer)");if((u>>>=0)<0||u+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+u+" (+0) <= "+this.buffer.byteLength)}return(u+=4)>(f=this.buffer.byteLength)&&this.resize((f*=2)>u?f:u),u-=4,this.littleEndian?(this.view[u+3]=255&a>>>24,this.view[u+2]=255&a>>>16,this.view[u+1]=255&a>>>8,this.view[u]=255&a):(this.view[u]=255&a>>>24,this.view[u+1]=255&a>>>16,this.view[u+2]=255&a>>>8,this.view[u+3]=255&a),p&&(this.offset+=4),this},o.writeUInt32=o.writeUint32,o.readUint32=function(a){var u,f=a===void 0;if(f&&(a=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal offset: "+a+" (not an integer)");if((a>>>=0)<0||a+4>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+4) <= "+this.buffer.byteLength)}return u=0,this.littleEndian?(u=this.view[a+2]<<16,u|=this.view[a+1]<<8,u|=this.view[a],u+=this.view[a+3]<<24>>>0):(u=this.view[a+1]<<16,u|=this.view[a+2]<<8,u|=this.view[a+3],u+=this.view[a]<<24>>>0),f&&(this.offset+=4),u},o.readUInt32=o.readUint32,t&&(o.writeInt64=function(a,u){var f,p,m,_=u===void 0;if(_&&(u=this.offset),!this.noAssert){if(typeof a=="number")a=t.fromNumber(a);else if(typeof a=="string")a=t.fromString(a);else if(!(a&&a instanceof t))throw TypeError("Illegal value: "+a+" (not an integer or Long)");if(typeof u!="number"||u%1!=0)throw TypeError("Illegal offset: "+u+" (not an integer)");if((u>>>=0)<0||u+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+u+" (+0) <= "+this.buffer.byteLength)}return typeof a=="number"?a=t.fromNumber(a):typeof a=="string"&&(a=t.fromString(a)),(u+=8)>(f=this.buffer.byteLength)&&this.resize((f*=2)>u?f:u),u-=8,p=a.low,m=a.high,this.littleEndian?(this.view[u+3]=255&p>>>24,this.view[u+2]=255&p>>>16,this.view[u+1]=255&p>>>8,this.view[u]=255&p,u+=4,this.view[u+3]=255&m>>>24,this.view[u+2]=255&m>>>16,this.view[u+1]=255&m>>>8,this.view[u]=255&m):(this.view[u]=255&m>>>24,this.view[u+1]=255&m>>>16,this.view[u+2]=255&m>>>8,this.view[u+3]=255&m,u+=4,this.view[u]=255&p>>>24,this.view[u+1]=255&p>>>16,this.view[u+2]=255&p>>>8,this.view[u+3]=255&p),_&&(this.offset+=8),this},o.writeLong=o.writeInt64,o.readInt64=function(a){var u,f,p,m=a===void 0;if(m&&(a=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal offset: "+a+" (not an integer)");if((a>>>=0)<0||a+8>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+8) <= "+this.buffer.byteLength)}return u=0,f=0,this.littleEndian?(u=this.view[a+2]<<16,u|=this.view[a+1]<<8,u|=this.view[a],u+=this.view[a+3]<<24>>>0,a+=4,f=this.view[a+2]<<16,f|=this.view[a+1]<<8,f|=this.view[a],f+=this.view[a+3]<<24>>>0):(f=this.view[a+1]<<16,f|=this.view[a+2]<<8,f|=this.view[a+3],f+=this.view[a]<<24>>>0,a+=4,u=this.view[a+1]<<16,u|=this.view[a+2]<<8,u|=this.view[a+3],u+=this.view[a]<<24>>>0),p=new t(u,f,!1),m&&(this.offset+=8),p},o.readLong=o.readInt64,o.writeUint64=function(a,u){var f,p,m,_=u===void 0;if(_&&(u=this.offset),!this.noAssert){if(typeof a=="number")a=t.fromNumber(a);else if(typeof a=="string")a=t.fromString(a);else if(!(a&&a instanceof t))throw TypeError("Illegal value: "+a+" (not an integer or Long)");if(typeof u!="number"||u%1!=0)throw TypeError("Illegal offset: "+u+" (not an integer)");if((u>>>=0)<0||u+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+u+" (+0) <= "+this.buffer.byteLength)}return typeof a=="number"?a=t.fromNumber(a):typeof a=="string"&&(a=t.fromString(a)),(u+=8)>(f=this.buffer.byteLength)&&this.resize((f*=2)>u?f:u),u-=8,p=a.low,m=a.high,this.littleEndian?(this.view[u+3]=255&p>>>24,this.view[u+2]=255&p>>>16,this.view[u+1]=255&p>>>8,this.view[u]=255&p,u+=4,this.view[u+3]=255&m>>>24,this.view[u+2]=255&m>>>16,this.view[u+1]=255&m>>>8,this.view[u]=255&m):(this.view[u]=255&m>>>24,this.view[u+1]=255&m>>>16,this.view[u+2]=255&m>>>8,this.view[u+3]=255&m,u+=4,this.view[u]=255&p>>>24,this.view[u+1]=255&p>>>16,this.view[u+2]=255&p>>>8,this.view[u+3]=255&p),_&&(this.offset+=8),this},o.writeUInt64=o.writeUint64,o.readUint64=function(a){var u,f,p,m=a===void 0;if(m&&(a=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal offset: "+a+" (not an integer)");if((a>>>=0)<0||a+8>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+8) <= "+this.buffer.byteLength)}return u=0,f=0,this.littleEndian?(u=this.view[a+2]<<16,u|=this.view[a+1]<<8,u|=this.view[a],u+=this.view[a+3]<<24>>>0,a+=4,f=this.view[a+2]<<16,f|=this.view[a+1]<<8,f|=this.view[a],f+=this.view[a+3]<<24>>>0):(f=this.view[a+1]<<16,f|=this.view[a+2]<<8,f|=this.view[a+3],f+=this.view[a]<<24>>>0,a+=4,u=this.view[a+1]<<16,u|=this.view[a+2]<<8,u|=this.view[a+3],u+=this.view[a]<<24>>>0),p=new t(u,f,!0),m&&(this.offset+=8),p},o.readUInt64=o.readUint64),o.writeFloat32=function(a,u){var f,p=u===void 0;if(p&&(u=this.offset),!this.noAssert){if(typeof a!="number")throw TypeError("Illegal value: "+a+" (not a number)");if(typeof u!="number"||u%1!=0)throw TypeError("Illegal offset: "+u+" (not an integer)");if((u>>>=0)<0||u+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+u+" (+0) <= "+this.buffer.byteLength)}return(u+=4)>(f=this.buffer.byteLength)&&this.resize((f*=2)>u?f:u),u-=4,i(this.view,a,u,this.littleEndian,23,4),p&&(this.offset+=4),this},o.writeFloat=o.writeFloat32,o.readFloat32=function(a){var u,f=a===void 0;if(f&&(a=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal offset: "+a+" (not an integer)");if((a>>>=0)<0||a+4>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+4) <= "+this.buffer.byteLength)}return u=r(this.view,a,this.littleEndian,23,4),f&&(this.offset+=4),u},o.readFloat=o.readFloat32,o.writeFloat64=function(a,u){var f,p=u===void 0;if(p&&(u=this.offset),!this.noAssert){if(typeof a!="number")throw TypeError("Illegal value: "+a+" (not a number)");if(typeof u!="number"||u%1!=0)throw TypeError("Illegal offset: "+u+" (not an integer)");if((u>>>=0)<0||u+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+u+" (+0) <= "+this.buffer.byteLength)}return(u+=8)>(f=this.buffer.byteLength)&&this.resize((f*=2)>u?f:u),u-=8,i(this.view,a,u,this.littleEndian,52,8),p&&(this.offset+=8),this},o.writeDouble=o.writeFloat64,o.readFloat64=function(a){var u,f=a===void 0;if(f&&(a=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal offset: "+a+" (not an integer)");if((a>>>=0)<0||a+8>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+8) <= "+this.buffer.byteLength)}return u=r(this.view,a,this.littleEndian,52,8),f&&(this.offset+=8),u},o.readDouble=o.readFloat64,h.MAX_VARINT32_BYTES=5,h.calculateVarint32=function(a){return(a>>>=0)<128?1:a<16384?2:1<<21>a?3:1<<28>a?4:5},h.zigZagEncode32=function(a){return((a|=0)<<1^a>>31)>>>0},h.zigZagDecode32=function(a){return 0|a>>>1^-(1&a)},o.writeVarint32=function(a,u){var f,p,m,_=u===void 0;if(_&&(u=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal value: "+a+" (not an integer)");if(a|=0,typeof u!="number"||u%1!=0)throw TypeError("Illegal offset: "+u+" (not an integer)");if((u>>>=0)<0||u+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+u+" (+0) <= "+this.buffer.byteLength)}for((u+=p=h.calculateVarint32(a))>(m=this.buffer.byteLength)&&this.resize((m*=2)>u?m:u),u-=p,a>>>=0;a>=128;)f=128|127&a,this.view[u++]=f,a>>>=7;return this.view[u++]=a,_?(this.offset=u,this):p},o.writeVarint32ZigZag=function(a,u){return this.writeVarint32(h.zigZagEncode32(a),u)},o.readVarint32=function(a){var u,f,p,m,_=a===void 0;if(_&&(a=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal offset: "+a+" (not an integer)");if((a>>>=0)<0||a+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+1) <= "+this.buffer.byteLength)}f=0,p=0;do{if(!this.noAssert&&a>this.limit)throw(m=Error("Truncated")).truncated=!0,m;u=this.view[a++],f<5&&(p|=(127&u)<<7*f),++f}while((128&u)!=0);return p|=0,_?(this.offset=a,p):{value:p,length:f}},o.readVarint32ZigZag=function(a){var u=this.readVarint32(a);return typeof u=="object"?u.value=h.zigZagDecode32(u.value):u=h.zigZagDecode32(u),u},t&&(h.MAX_VARINT64_BYTES=10,h.calculateVarint64=function(a){typeof a=="number"?a=t.fromNumber(a):typeof a=="string"&&(a=t.fromString(a));var u=a.toInt()>>>0,f=a.shiftRightUnsigned(28).toInt()>>>0,p=a.shiftRightUnsigned(56).toInt()>>>0;return p==0?f==0?u<16384?u<128?1:2:1<<21>u?3:4:f<16384?f<128?5:6:1<<21>f?7:8:p<128?9:10},h.zigZagEncode64=function(a){return typeof a=="number"?a=t.fromNumber(a,!1):typeof a=="string"?a=t.fromString(a,!1):a.unsigned!==!1&&(a=a.toSigned()),a.shiftLeft(1).xor(a.shiftRight(63)).toUnsigned()},h.zigZagDecode64=function(a){return typeof a=="number"?a=t.fromNumber(a,!1):typeof a=="string"?a=t.fromString(a,!1):a.unsigned!==!1&&(a=a.toSigned()),a.shiftRightUnsigned(1).xor(a.and(t.ONE).toSigned().negate()).toSigned()},o.writeVarint64=function(a,u){var f,p,m,_,v,y=u===void 0;if(y&&(u=this.offset),!this.noAssert){if(typeof a=="number")a=t.fromNumber(a);else if(typeof a=="string")a=t.fromString(a);else if(!(a&&a instanceof t))throw TypeError("Illegal value: "+a+" (not an integer or Long)");if(typeof u!="number"||u%1!=0)throw TypeError("Illegal offset: "+u+" (not an integer)");if((u>>>=0)<0||u+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+u+" (+0) <= "+this.buffer.byteLength)}switch(typeof a=="number"?a=t.fromNumber(a,!1):typeof a=="string"?a=t.fromString(a,!1):a.unsigned!==!1&&(a=a.toSigned()),f=h.calculateVarint64(a),p=a.toInt()>>>0,m=a.shiftRightUnsigned(28).toInt()>>>0,_=a.shiftRightUnsigned(56).toInt()>>>0,(u+=f)>(v=this.buffer.byteLength)&&this.resize((v*=2)>u?v:u),u-=f,f){case 10:this.view[u+9]=1&_>>>7;case 9:this.view[u+8]=f!==9?128|_:127&_;case 8:this.view[u+7]=f!==8?128|m>>>21:127&m>>>21;case 7:this.view[u+6]=f!==7?128|m>>>14:127&m>>>14;case 6:this.view[u+5]=f!==6?128|m>>>7:127&m>>>7;case 5:this.view[u+4]=f!==5?128|m:127&m;case 4:this.view[u+3]=f!==4?128|p>>>21:127&p>>>21;case 3:this.view[u+2]=f!==3?128|p>>>14:127&p>>>14;case 2:this.view[u+1]=f!==2?128|p>>>7:127&p>>>7;case 1:this.view[u]=f!==1?128|p:127&p}return y?(this.offset+=f,this):f},o.writeVarint64ZigZag=function(a,u){return this.writeVarint64(h.zigZagEncode64(a),u)},o.readVarint64=function(a){var u,f,p,m,_,v,y=a===void 0;if(y&&(a=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal offset: "+a+" (not an integer)");if((a>>>=0)<0||a+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+1) <= "+this.buffer.byteLength)}if(u=a,f=0,p=0,m=0,_=0,f=127&(_=this.view[a++]),128&_&&(f|=(127&(_=this.view[a++]))<<7,(128&_||this.noAssert&&_===void 0)&&(f|=(127&(_=this.view[a++]))<<14,(128&_||this.noAssert&&_===void 0)&&(f|=(127&(_=this.view[a++]))<<21,(128&_||this.noAssert&&_===void 0)&&(p=127&(_=this.view[a++]),(128&_||this.noAssert&&_===void 0)&&(p|=(127&(_=this.view[a++]))<<7,(128&_||this.noAssert&&_===void 0)&&(p|=(127&(_=this.view[a++]))<<14,(128&_||this.noAssert&&_===void 0)&&(p|=(127&(_=this.view[a++]))<<21,(128&_||this.noAssert&&_===void 0)&&(m=127&(_=this.view[a++]),(128&_||this.noAssert&&_===void 0)&&(m|=(127&(_=this.view[a++]))<<7,128&_||this.noAssert&&_===void 0))))))))))throw Error("Buffer overrun");return v=t.fromBits(f|p<<28,p>>>4|m<<24,!1),y?(this.offset=a,v):{value:v,length:a-u}},o.readVarint64ZigZag=function(a){var u=this.readVarint64(a);return u&&u.value instanceof t?u.value=h.zigZagDecode64(u.value):u=h.zigZagDecode64(u),u}),o.writeCString=function(a,u){var f,p,m,_=u===void 0;if(_&&(u=this.offset),p=a.length,!this.noAssert){if(typeof a!="string")throw TypeError("Illegal str: Not a string");for(f=0;p>f;++f)if(a.charCodeAt(f)===0)throw RangeError("Illegal str: Contains NULL-characters");if(typeof u!="number"||u%1!=0)throw TypeError("Illegal offset: "+u+" (not an integer)");if((u>>>=0)<0||u+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+u+" (+0) <= "+this.buffer.byteLength)}return p=l.calculateUTF16asUTF8(e(a))[1],u+=p+1,m=this.buffer.byteLength,u>m&&this.resize((m*=2)>u?m:u),u-=p+1,l.encodeUTF16toUTF8(e(a),function(v){this.view[u++]=v}.bind(this)),this.view[u++]=0,_?(this.offset=u,this):p},o.readCString=function(a){var u,f,p,m=a===void 0;if(m&&(a=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal offset: "+a+" (not an integer)");if((a>>>=0)<0||a+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+1) <= "+this.buffer.byteLength)}return u=a,p=-1,l.decodeUTF8toUTF16(function(){if(p===0)return null;if(a>=this.limit)throw RangeError("Illegal range: Truncated data, "+a+" < "+this.limit);return(p=this.view[a++])===0?null:p}.bind(this),f=n(),!0),m?(this.offset=a,f()):{string:f(),length:a-u}},o.writeIString=function(a,u){var f,p,m,_=u===void 0;if(_&&(u=this.offset),!this.noAssert){if(typeof a!="string")throw TypeError("Illegal str: Not a string");if(typeof u!="number"||u%1!=0)throw TypeError("Illegal offset: "+u+" (not an integer)");if((u>>>=0)<0||u+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+u+" (+0) <= "+this.buffer.byteLength)}if(p=u,f=l.calculateUTF16asUTF8(e(a),this.noAssert)[1],u+=4+f,m=this.buffer.byteLength,u>m&&this.resize((m*=2)>u?m:u),u-=4+f,this.littleEndian?(this.view[u+3]=255&f>>>24,this.view[u+2]=255&f>>>16,this.view[u+1]=255&f>>>8,this.view[u]=255&f):(this.view[u]=255&f>>>24,this.view[u+1]=255&f>>>16,this.view[u+2]=255&f>>>8,this.view[u+3]=255&f),u+=4,l.encodeUTF16toUTF8(e(a),function(v){this.view[u++]=v}.bind(this)),u!==p+4+f)throw RangeError("Illegal range: Truncated data, "+u+" == "+(u+4+f));return _?(this.offset=u,this):u-p},o.readIString=function(a){var u,f,p,m=a===void 0;if(m&&(a=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal offset: "+a+" (not an integer)");if((a>>>=0)<0||a+4>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+4) <= "+this.buffer.byteLength)}return u=a,f=this.readUint32(a),p=this.readUTF8String(f,h.METRICS_BYTES,a+=4),a+=p.length,m?(this.offset=a,p.string):{string:p.string,length:a-u}},h.METRICS_CHARS="c",h.METRICS_BYTES="b",o.writeUTF8String=function(a,u){var f,p,m,_=u===void 0;if(_&&(u=this.offset),!this.noAssert){if(typeof u!="number"||u%1!=0)throw TypeError("Illegal offset: "+u+" (not an integer)");if((u>>>=0)<0||u+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+u+" (+0) <= "+this.buffer.byteLength)}return p=u,f=l.calculateUTF16asUTF8(e(a))[1],u+=f,m=this.buffer.byteLength,u>m&&this.resize((m*=2)>u?m:u),u-=f,l.encodeUTF16toUTF8(e(a),function(v){this.view[u++]=v}.bind(this)),_?(this.offset=u,this):u-p},o.writeString=o.writeUTF8String,h.calculateUTF8Chars=function(a){return l.calculateUTF16asUTF8(e(a))[0]},h.calculateUTF8Bytes=function(a){return l.calculateUTF16asUTF8(e(a))[1]},h.calculateString=h.calculateUTF8Bytes,o.readUTF8String=function(a,u,f){var p,m,_,v,y;if(typeof u=="number"&&(f=u,u=void 0),(p=f===void 0)&&(f=this.offset),u===void 0&&(u=h.METRICS_CHARS),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal length: "+a+" (not an integer)");if(a|=0,typeof f!="number"||f%1!=0)throw TypeError("Illegal offset: "+f+" (not an integer)");if((f>>>=0)<0||f+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+f+" (+0) <= "+this.buffer.byteLength)}if(_=0,v=f,u===h.METRICS_CHARS){if(m=n(),l.decodeUTF8(function(){return a>_&&f>>=0)<0||f+a>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+f+" (+"+a+") <= "+this.buffer.byteLength)}if(y=f+a,l.decodeUTF8toUTF16(function(){return y>f?this.view[f++]:null}.bind(this),m=n(),this.noAssert),f!==y)throw RangeError("Illegal range: Truncated data, "+f+" == "+y);return p?(this.offset=f,m()):{string:m(),length:f-v}}throw TypeError("Unsupported metrics: "+u)},o.readString=o.readUTF8String,o.writeVString=function(a,u){var f,p,m,_,v=u===void 0;if(v&&(u=this.offset),!this.noAssert){if(typeof a!="string")throw TypeError("Illegal str: Not a string");if(typeof u!="number"||u%1!=0)throw TypeError("Illegal offset: "+u+" (not an integer)");if((u>>>=0)<0||u+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+u+" (+0) <= "+this.buffer.byteLength)}if(m=u,f=l.calculateUTF16asUTF8(e(a),this.noAssert)[1],p=h.calculateVarint32(f),u+=p+f,_=this.buffer.byteLength,u>_&&this.resize((_*=2)>u?_:u),u-=p+f,u+=this.writeVarint32(f,u),l.encodeUTF16toUTF8(e(a),function(y){this.view[u++]=y}.bind(this)),u!==m+f+p)throw RangeError("Illegal range: Truncated data, "+u+" == "+(u+f+p));return v?(this.offset=u,this):u-m},o.readVString=function(a){var u,f,p,m=a===void 0;if(m&&(a=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal offset: "+a+" (not an integer)");if((a>>>=0)<0||a+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+1) <= "+this.buffer.byteLength)}return u=a,f=this.readVarint32(a),p=this.readUTF8String(f.value,h.METRICS_BYTES,a+=f.length),a+=p.length,m?(this.offset=a,p.string):{string:p.string,length:a-u}},o.append=function(a,u,f){var p,m,_;if((typeof u=="number"||typeof u!="string")&&(f=u,u=void 0),(p=f===void 0)&&(f=this.offset),!this.noAssert){if(typeof f!="number"||f%1!=0)throw TypeError("Illegal offset: "+f+" (not an integer)");if((f>>>=0)<0||f+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+f+" (+0) <= "+this.buffer.byteLength)}return a instanceof h||(a=h.wrap(a,u)),(m=a.limit-a.offset)<=0||((f+=m)>(_=this.buffer.byteLength)&&this.resize((_*=2)>f?_:f),f-=m,this.view.set(a.view.subarray(a.offset,a.limit),f),a.offset+=m,p&&(this.offset+=m)),this},o.appendTo=function(a,u){return a.append(this,u),this},o.assert=function(a){return this.noAssert=!a,this},o.capacity=function(){return this.buffer.byteLength},o.clear=function(){return this.offset=0,this.limit=this.buffer.byteLength,this.markedOffset=-1,this},o.clone=function(a){var u=new h(0,this.littleEndian,this.noAssert);return a?(u.buffer=new ArrayBuffer(this.buffer.byteLength),u.view=new Uint8Array(u.buffer)):(u.buffer=this.buffer,u.view=this.view),u.offset=this.offset,u.markedOffset=this.markedOffset,u.limit=this.limit,u},o.compact=function(a,u){var f,p,m;if(a===void 0&&(a=this.offset),u===void 0&&(u=this.limit),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal begin: Not an integer");if(a>>>=0,typeof u!="number"||u%1!=0)throw TypeError("Illegal end: Not an integer");if(u>>>=0,a<0||a>u||u>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+a+" <= "+u+" <= "+this.buffer.byteLength)}return a===0&&u===this.buffer.byteLength?this:(f=u-a)==0?(this.buffer=s,this.view=null,this.markedOffset>=0&&(this.markedOffset-=a),this.offset=0,this.limit=0,this):(p=new ArrayBuffer(f),(m=new Uint8Array(p)).set(this.view.subarray(a,u)),this.buffer=p,this.view=m,this.markedOffset>=0&&(this.markedOffset-=a),this.offset=0,this.limit=f,this)},o.copy=function(a,u){if(a===void 0&&(a=this.offset),u===void 0&&(u=this.limit),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal begin: Not an integer");if(a>>>=0,typeof u!="number"||u%1!=0)throw TypeError("Illegal end: Not an integer");if(u>>>=0,a<0||a>u||u>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+a+" <= "+u+" <= "+this.buffer.byteLength)}if(a===u)return new h(0,this.littleEndian,this.noAssert);var f=u-a,p=new h(f,this.littleEndian,this.noAssert);return p.offset=0,p.limit=f,p.markedOffset>=0&&(p.markedOffset-=a),this.copyTo(p,0,a,u),p},o.copyTo=function(a,u,f,p){var m,_,v;if(!this.noAssert&&!h.isByteBuffer(a))throw TypeError("Illegal target: Not a ByteBuffer");if(u=(_=u===void 0)?a.offset:0|u,f=(m=f===void 0)?this.offset:0|f,p=p===void 0?this.limit:0|p,u<0||u>a.buffer.byteLength)throw RangeError("Illegal target range: 0 <= "+u+" <= "+a.buffer.byteLength);if(f<0||p>this.buffer.byteLength)throw RangeError("Illegal source range: 0 <= "+f+" <= "+this.buffer.byteLength);return(v=p-f)==0?a:(a.ensureCapacity(u+v),a.view.set(this.view.subarray(f,p),u),m&&(this.offset+=v),_&&(a.offset+=v),this)},o.ensureCapacity=function(a){var u=this.buffer.byteLength;return a>u?this.resize((u*=2)>a?u:a):this},o.fill=function(a,u,f){var p=u===void 0;if(p&&(u=this.offset),typeof a=="string"&&a.length>0&&(a=a.charCodeAt(0)),u===void 0&&(u=this.offset),f===void 0&&(f=this.limit),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal value: "+a+" (not an integer)");if(a|=0,typeof u!="number"||u%1!=0)throw TypeError("Illegal begin: Not an integer");if(u>>>=0,typeof f!="number"||f%1!=0)throw TypeError("Illegal end: Not an integer");if(f>>>=0,u<0||u>f||f>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+u+" <= "+f+" <= "+this.buffer.byteLength)}if(u>=f)return this;for(;f>u;)this.view[u++]=a;return p&&(this.offset=u),this},o.flip=function(){return this.limit=this.offset,this.offset=0,this},o.mark=function(a){if(a=a===void 0?this.offset:a,!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal offset: "+a+" (not an integer)");if((a>>>=0)<0||a+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+0) <= "+this.buffer.byteLength)}return this.markedOffset=a,this},o.order=function(a){if(!this.noAssert&&typeof a!="boolean")throw TypeError("Illegal littleEndian: Not a boolean");return this.littleEndian=!!a,this},o.LE=function(a){return this.littleEndian=a===void 0||!!a,this},o.BE=function(a){return this.littleEndian=a!==void 0&&!a,this},o.prepend=function(a,u,f){var p,m,_,v,y;if((typeof u=="number"||typeof u!="string")&&(f=u,u=void 0),(p=f===void 0)&&(f=this.offset),!this.noAssert){if(typeof f!="number"||f%1!=0)throw TypeError("Illegal offset: "+f+" (not an integer)");if((f>>>=0)<0||f+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+f+" (+0) <= "+this.buffer.byteLength)}return a instanceof h||(a=h.wrap(a,u)),(m=a.limit-a.offset)<=0||((_=m-f)>0?(v=new ArrayBuffer(this.buffer.byteLength+_),(y=new Uint8Array(v)).set(this.view.subarray(f,this.buffer.byteLength),m),this.buffer=v,this.view=y,this.offset+=_,this.markedOffset>=0&&(this.markedOffset+=_),this.limit+=_,f+=_):new Uint8Array(this.buffer),this.view.set(a.view.subarray(a.offset,a.limit),f-m),a.offset=a.limit,p&&(this.offset-=m)),this},o.prependTo=function(a,u){return a.prepend(this,u),this},o.printDebug=function(a){typeof a!="function"&&(a=console.log.bind(console)),a(this.toString()+` ------------------------------------------------------------------- `+this.toDebug(!0))},o.remaining=function(){return this.limit-this.offset},o.reset=function(){return this.markedOffset>=0?(this.offset=this.markedOffset,this.markedOffset=-1):this.offset=0,this},o.resize=function(a){var u,f;if(!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal capacity: "+a+" (not an integer)");if((a|=0)<0)throw RangeError("Illegal capacity: 0 <= "+a)}return this.buffer.byteLength>>=0,typeof u!="number"||u%1!=0)throw TypeError("Illegal end: Not an integer");if(u>>>=0,a<0||a>u||u>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+a+" <= "+u+" <= "+this.buffer.byteLength)}return a===u||Array.prototype.reverse.call(this.view.subarray(a,u)),this},o.skip=function(a){if(!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal length: "+a+" (not an integer)");a|=0}var u=this.offset+a;if(!this.noAssert&&(u<0||u>this.buffer.byteLength))throw RangeError("Illegal length: 0 <= "+this.offset+" + "+a+" <= "+this.buffer.byteLength);return this.offset=u,this},o.slice=function(a,u){if(a===void 0&&(a=this.offset),u===void 0&&(u=this.limit),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal begin: Not an integer");if(a>>>=0,typeof u!="number"||u%1!=0)throw TypeError("Illegal end: Not an integer");if(u>>>=0,a<0||a>u||u>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+a+" <= "+u+" <= "+this.buffer.byteLength)}var f=this.clone();return f.offset=a,f.limit=u,f},o.toBuffer=function(a){var u,f=this.offset,p=this.limit;if(!this.noAssert){if(typeof f!="number"||f%1!=0)throw TypeError("Illegal offset: Not an integer");if(f>>>=0,typeof p!="number"||p%1!=0)throw TypeError("Illegal limit: Not an integer");if(p>>>=0,f<0||f>p||p>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+f+" <= "+p+" <= "+this.buffer.byteLength)}return a||f!==0||p!==this.buffer.byteLength?f===p?s:(u=new ArrayBuffer(p-f),new Uint8Array(u).set(new Uint8Array(this.buffer).subarray(f,p),0),u):this.buffer},o.toArrayBuffer=o.toBuffer,o.toString=function(a,u,f){if(a===void 0)return"ByteBufferAB(offset="+this.offset+",markedOffset="+this.markedOffset+",limit="+this.limit+",capacity="+this.capacity()+")";switch(typeof a=="number"&&(f=u=a="utf8"),a){case"utf8":return this.toUTF8(u,f);case"base64":return this.toBase64(u,f);case"hex":return this.toHex(u,f);case"binary":return this.toBinary(u,f);case"debug":return this.toDebug();case"columns":return this.toColumns();default:throw Error("Unsupported encoding: "+a)}},d=function(){var a,u,f={},p=[65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,48,49,50,51,52,53,54,55,56,57,43,47],m=[];for(a=0,u=p.length;u>a;++a)m[p[a]]=a;return f.encode=function(_,v){for(var y,C;(y=_())!==null;)v(p[63&y>>2]),C=(3&y)<<4,(y=_())!==null?(v(p[63&((C|=15&y>>4)|15&y>>4)]),C=(15&y)<<2,(y=_())!==null?(v(p[63&(C|3&y>>6)]),v(p[63&y])):(v(p[63&C]),v(61))):(v(p[63&C]),v(61),v(61))},f.decode=function(_,v){function y(T){throw Error("Illegal character code: "+T)}for(var C,w,P;(C=_())!==null;)if((w=m[C])===void 0&&y(C),(C=_())!==null&&((P=m[C])===void 0&&y(C),v(w<<2>>>0|(48&P)>>4),(C=_())!==null)){if((w=m[C])===void 0){if(C===61)break;y(C)}if(v((15&P)<<4>>>0|(60&w)>>2),(C=_())!==null){if((P=m[C])===void 0){if(C===61)break;y(C)}v((3&w)<<6>>>0|P)}}},f.test=function(_){return/^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/.test(_)},f}(),o.toBase64=function(a,u){if(a===void 0&&(a=this.offset),u===void 0&&(u=this.limit),u|=0,(a|=0)<0||u>this.capacity||a>u)throw RangeError("begin, end");var f;return d.encode(function(){return u>a?this.view[a++]:null}.bind(this),f=n()),f()},h.fromBase64=function(a,u){if(typeof a!="string")throw TypeError("str");var f=new h(a.length/4*3,u),p=0;return d.decode(e(a),function(m){f.view[p++]=m}),f.limit=p,f},h.btoa=function(a){return h.fromBinary(a).toBase64()},h.atob=function(a){return h.fromBase64(a).toBinary()},o.toBinary=function(a,u){if(a===void 0&&(a=this.offset),u===void 0&&(u=this.limit),u|=0,(a|=0)<0||u>this.capacity()||a>u)throw RangeError("begin, end");if(a===u)return"";for(var f=[],p=[];u>a;)f.push(this.view[a++]),f.length>=1024&&(p.push(String.fromCharCode.apply(String,f)),f=[]);return p.join("")+String.fromCharCode.apply(String,f)},h.fromBinary=function(a,u){if(typeof a!="string")throw TypeError("str");for(var f,p=0,m=a.length,_=new h(m,u);m>p;){if((f=a.charCodeAt(p))>255)throw RangeError("illegal char code: "+f);_.view[p++]=f}return _.limit=m,_},o.toDebug=function(a){for(var u,f=-1,p=this.buffer.byteLength,m="",_="",v="";p>f;){if(f!==-1&&(m+=(u=this.view[f])<16?"0"+u.toString(16).toUpperCase():u.toString(16).toUpperCase(),a&&(_+=u>32&&u<127?String.fromCharCode(u):".")),++f,a&&f>0&&f%16==0&&f!==p){for(;m.length<51;)m+=" ";v+=m+_+` `,m=_=""}m+=f===this.offset&&f===this.limit?f===this.markedOffset?"!":"|":f===this.offset?f===this.markedOffset?"[":"<":f===this.limit?f===this.markedOffset?"]":">":f===this.markedOffset?"'":a||f!==0&&f!==p?" ":""}if(a&&m!==" "){for(;m.length<51;)m+=" ";v+=m+_+` `}return a?v:m},h.fromDebug=function(a,u,f){for(var p,m,_=a.length,v=new h(0|(_+1)/3,u,f),y=0,C=0,w=!1,P=!1,T=!1,E=!1,O=!1;_>y;){switch(p=a.charAt(y++)){case"!":if(!f){if(P||T||E){O=!0;break}P=T=E=!0}v.offset=v.markedOffset=v.limit=C,w=!1;break;case"|":if(!f){if(P||E){O=!0;break}P=E=!0}v.offset=v.limit=C,w=!1;break;case"[":if(!f){if(P||T){O=!0;break}P=T=!0}v.offset=v.markedOffset=C,w=!1;break;case"<":if(!f){if(P){O=!0;break}P=!0}v.offset=C,w=!1;break;case"]":if(!f){if(E||T){O=!0;break}E=T=!0}v.limit=v.markedOffset=C,w=!1;break;case">":if(!f){if(E){O=!0;break}E=!0}v.limit=C,w=!1;break;case"'":if(!f){if(T){O=!0;break}T=!0}v.markedOffset=C,w=!1;break;case" ":w=!1;break;default:if(!f&&w){O=!0;break}if(m=parseInt(p+a.charAt(y++),16),!f&&(isNaN(m)||m<0||m>255))throw TypeError("Illegal str: Not a debug encoded string");v.view[C++]=m,w=!0}if(O)throw TypeError("Illegal str: Invalid symbol at "+y)}if(!f){if(!P||!E)throw TypeError("Illegal str: Missing offset or limit");if(C>>=0,typeof u!="number"||u%1!=0)throw TypeError("Illegal end: Not an integer");if(u>>>=0,a<0||a>u||u>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+a+" <= "+u+" <= "+this.buffer.byteLength)}for(var f,p=new Array(u-a);u>a;)(f=this.view[a++])<16?p.push("0",f.toString(16)):p.push(f.toString(16));return p.join("")},h.fromHex=function(a,u,f){var p,m,_,v,y;if(!f){if(typeof a!="string")throw TypeError("Illegal str: Not a string");if(a.length%2!=0)throw TypeError("Illegal str: Length not a multiple of 2")}for(m=a.length,_=new h(0|m/2,u),v=0,y=0;m>v;v+=2){if(p=parseInt(a.substring(v,v+2),16),!f&&(!isFinite(p)||p<0||p>255))throw TypeError("Illegal str: Contains non-hex characters");_.view[y++]=p}return _.limit=y,_},l=function(){var a={MAX_CODEPOINT:1114111,encodeUTF8:function(u,f){var p=null;for(typeof u=="number"&&(p=u,u=function(){return null});p!==null||(p=u())!==null;)p<128?f(127&p):p<2048?(f(192|31&p>>6),f(128|63&p)):p<65536?(f(224|15&p>>12),f(128|63&p>>6),f(128|63&p)):(f(240|7&p>>18),f(128|63&p>>12),f(128|63&p>>6),f(128|63&p)),p=null},decodeUTF8:function(u,f){for(var p,m,_,v,y=function(C){C=C.slice(0,C.indexOf(null));var w=Error(C.toString());throw w.name="TruncatedError",w.bytes=C,w};(p=u())!==null;)if((128&p)==0)f(p);else if((224&p)==192)(m=u())===null&&y([p,m]),f((31&p)<<6|63&m);else if((240&p)==224)((m=u())===null||(_=u())===null)&&y([p,m,_]),f((15&p)<<12|(63&m)<<6|63&_);else{if((248&p)!=240)throw RangeError("Illegal starting byte: "+p);((m=u())===null||(_=u())===null||(v=u())===null)&&y([p,m,_,v]),f((7&p)<<18|(63&m)<<12|(63&_)<<6|63&v)}},UTF16toUTF8:function(u,f){for(var p,m=null;(p=m!==null?m:u())!==null;)p>=55296&&p<=57343&&(m=u())!==null&&m>=56320&&m<=57343?(f(1024*(p-55296)+m-56320+65536),m=null):f(p);m!==null&&f(m)},UTF8toUTF16:function(u,f){var p=null;for(typeof u=="number"&&(p=u,u=function(){return null});p!==null||(p=u())!==null;)p<=65535?f(p):(f(55296+((p-=65536)>>10)),f(p%1024+56320)),p=null},encodeUTF16toUTF8:function(u,f){a.UTF16toUTF8(u,function(p){a.encodeUTF8(p,f)})},decodeUTF8toUTF16:function(u,f){a.decodeUTF8(u,function(p){a.UTF8toUTF16(p,f)})},calculateCodePoint:function(u){return u<128?1:u<2048?2:u<65536?3:4},calculateUTF8:function(u){for(var f,p=0;(f=u())!==null;)p+=f<128?1:f<2048?2:f<65536?3:4;return p},calculateUTF16asUTF8:function(u){var f=0,p=0;return a.UTF16toUTF8(u,function(m){++f,p+=m<128?1:m<2048?2:m<65536?3:4}),[f,p]}};return a}(),o.toUTF8=function(a,u){if(a===void 0&&(a=this.offset),u===void 0&&(u=this.limit),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal begin: Not an integer");if(a>>>=0,typeof u!="number"||u%1!=0)throw TypeError("Illegal end: Not an integer");if(u>>>=0,a<0||a>u||u>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+a+" <= "+u+" <= "+this.buffer.byteLength)}var f;try{l.decodeUTF8toUTF16(function(){return u>a?this.view[a++]:null}.bind(this),f=n())}catch{if(a!==u)throw RangeError("Illegal range: Truncated data, "+a+" != "+u)}return f()},h.fromUTF8=function(a,u,f){if(!f&&typeof a!="string")throw TypeError("Illegal str: Not a string");var p=new h(l.calculateUTF16asUTF8(e(a),!0)[1],u,f),m=0;return l.encodeUTF16toUTF8(e(a),function(_){p.view[m++]=_}),p.limit=m,p},h}(Wa=function(){function t(E,O,B){this.low=0|E,this.high=0|O,this.unsigned=!!B}function e(E){return(E&&E.__isLong__)===!0}function n(E,O){var B,$,R;return O?(R=(E>>>=0)>=0&&E<256)&&($=d[E])?$:(B=i(E,(0|E)<0?-1:0,!0),R&&(d[E]=B),B):(R=(E|=0)>=-128&&E<128)&&($=c[E])?$:(B=i(E,E<0?-1:0,!1),R&&(c[E]=B),B)}function r(E,O){if(isNaN(E)||!isFinite(E))return O?m:p;if(O){if(E<0)return m;if(E>=a)return w}else{if(-u>=E)return P;if(E+1>=u)return C}return E<0?r(-E,O).neg():i(0|E%h,0|E/h,O)}function i(E,O,B){return new t(E,O,B)}function o(E,O,B){var $,R,S,b,A,N,x;if(E.length===0)throw Error("empty string");if(E==="NaN"||E==="Infinity"||E==="+Infinity"||E==="-Infinity")return p;if(typeof O=="number"?(B=O,O=!1):O=!!O,(B=B||10)<2||B>36)throw RangeError("radix");if(($=E.indexOf("-"))>0)throw Error("interior hyphen");if($===0)return o(E.substring(1),O,B).neg();for(R=r(l(B,8)),S=p,b=0;b>>0:this.low},T.toNumber=function(){return this.unsigned?(this.high>>>0)*h+(this.low>>>0):this.high*h+(this.low>>>0)},T.toString=function(E){var O,B,$,R,S,b,A,N;if((E=E||10)<2||E>36)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative())return this.eq(P)?(O=r(E),$=(B=this.div(O)).mul(O).sub(this),B.toString(E)+$.toInt().toString(E)):"-"+this.neg().toString(E);for(R=r(l(E,6),this.unsigned),S=this,b="";;){if(A=S.div(R),N=(S.sub(A.mul(R)).toInt()>>>0).toString(E),(S=A).isZero())return N+b;for(;N.length<6;)N="0"+N;b=""+N+b}},T.getHighBits=function(){return this.high},T.getHighBitsUnsigned=function(){return this.high>>>0},T.getLowBits=function(){return this.low},T.getLowBitsUnsigned=function(){return this.low>>>0},T.getNumBitsAbs=function(){var E,O;if(this.isNegative())return this.eq(P)?64:this.neg().getNumBitsAbs();for(E=this.high!=0?this.high:this.low,O=31;O>0&&(E&1<=0},T.isOdd=function(){return(1&this.low)==1},T.isEven=function(){return(1&this.low)==0},T.equals=function(E){return e(E)||(E=s(E)),(this.unsigned===E.unsigned||this.high>>>31!=1||E.high>>>31!=1)&&this.high===E.high&&this.low===E.low},T.eq=T.equals,T.notEquals=function(E){return!this.eq(E)},T.neq=T.notEquals,T.lessThan=function(E){return this.comp(E)<0},T.lt=T.lessThan,T.lessThanOrEqual=function(E){return this.comp(E)<=0},T.lte=T.lessThanOrEqual,T.greaterThan=function(E){return this.comp(E)>0},T.gt=T.greaterThan,T.greaterThanOrEqual=function(E){return this.comp(E)>=0},T.gte=T.greaterThanOrEqual,T.compare=function(E){if(e(E)||(E=s(E)),this.eq(E))return 0;var O=this.isNegative(),B=E.isNegative();return O&&!B?-1:!O&&B?1:this.unsigned?E.high>>>0>this.high>>>0||E.high===this.high&&E.low>>>0>this.low>>>0?-1:1:this.sub(E).isNegative()?-1:1},T.comp=T.compare,T.negate=function(){return!this.unsigned&&this.eq(P)?P:this.not().add(_)},T.neg=T.negate,T.add=function(E){var O,B,$,R,S,b,A,N,x,U,j;return e(E)||(E=s(E)),O=this.high>>>16,B=65535&this.high,$=this.low>>>16,R=65535&this.low,S=E.high>>>16,b=65535&E.high,A=E.low>>>16,N=0,x=0,U=0,j=0,U+=(j+=R+(65535&E.low))>>>16,x+=(U+=$+A)>>>16,N+=(x+=B+b)>>>16,N+=O+S,i((U&=65535)<<16|(j&=65535),(N&=65535)<<16|(x&=65535),this.unsigned)},T.subtract=function(E){return e(E)||(E=s(E)),this.add(E.neg())},T.sub=T.subtract,T.multiply=function(E){var O,B,$,R,S,b,A,N,x,U,j,Y;return this.isZero()?p:(e(E)||(E=s(E)),E.isZero()?p:this.eq(P)?E.isOdd()?P:p:E.eq(P)?this.isOdd()?P:p:this.isNegative()?E.isNegative()?this.neg().mul(E.neg()):this.neg().mul(E).neg():E.isNegative()?this.mul(E.neg()).neg():this.lt(f)&&E.lt(f)?r(this.toNumber()*E.toNumber(),this.unsigned):(O=this.high>>>16,B=65535&this.high,$=this.low>>>16,R=65535&this.low,S=E.high>>>16,b=65535&E.high,A=E.low>>>16,x=0,U=0,j=0,Y=0,j+=(Y+=R*(N=65535&E.low))>>>16,U+=(j+=$*N)>>>16,j&=65535,U+=(j+=R*A)>>>16,x+=(U+=B*N)>>>16,U&=65535,x+=(U+=$*A)>>>16,U&=65535,x+=(U+=R*b)>>>16,x+=O*N+B*A+$*b+R*S,i((j&=65535)<<16|(Y&=65535),(x&=65535)<<16|(U&=65535),this.unsigned)))},T.mul=T.multiply,T.divide=function(E){var O,B,$,R,S,b,A;if(e(E)||(E=s(E)),E.isZero())throw Error("division by zero");if(this.isZero())return this.unsigned?m:p;if(this.unsigned){if(E.unsigned||(E=E.toUnsigned()),E.gt(this))return m;if(E.gt(this.shru(1)))return v;$=m}else{if(this.eq(P))return E.eq(_)||E.eq(y)?P:E.eq(P)?_:(O=this.shr(1).div(E).shl(1)).eq(p)?E.isNegative()?_:y:(B=this.sub(E.mul(O)),$=O.add(B.div(E)));if(E.eq(P))return this.unsigned?m:p;if(this.isNegative())return E.isNegative()?this.neg().div(E.neg()):this.neg().div(E).neg();if(E.isNegative())return this.div(E.neg()).neg();$=p}for(B=this;B.gte(E);){for(O=Math.max(1,Math.floor(B.toNumber()/E.toNumber())),S=(R=Math.ceil(Math.log(O)/Math.LN2))<=48?1:l(2,R-48),A=(b=r(O)).mul(E);A.isNegative()||A.gt(B);)A=(b=r(O-=S,this.unsigned)).mul(E);b.isZero()&&(b=_),$=$.add(b),B=B.sub(A)}return $},T.div=T.divide,T.modulo=function(E){return e(E)||(E=s(E)),this.sub(this.div(E).mul(E))},T.mod=T.modulo,T.not=function(){return i(~this.low,~this.high,this.unsigned)},T.and=function(E){return e(E)||(E=s(E)),i(this.low&E.low,this.high&E.high,this.unsigned)},T.or=function(E){return e(E)||(E=s(E)),i(this.low|E.low,this.high|E.high,this.unsigned)},T.xor=function(E){return e(E)||(E=s(E)),i(this.low^E.low,this.high^E.high,this.unsigned)},T.shiftLeft=function(E){return e(E)&&(E=E.toInt()),(E&=63)==0?this:E<32?i(this.low<>>32-E,this.unsigned):i(0,this.low<>>E|this.high<<32-E,this.high>>E,this.unsigned):i(this.high>>E-32,this.high>=0?0:-1,this.unsigned)},T.shr=T.shiftRight,T.shiftRightUnsigned=function(E){var O;return e(E)&&(E=E.toInt()),(E&=63)==0?this:(O=this.high,E<32?i(this.low>>>E|O<<32-E,O>>>E,this.unsigned):i(E===32?O:O>>>E-32,0,this.unsigned))},T.shru=T.shiftRightUnsigned,T.toSigned=function(){return this.unsigned?i(this.low,this.high,!1):this},T.toUnsigned=function(){return this.unsigned?this:i(this.low,this.high,!0)},T.toBytes=function(E){return E?this.toBytesLE():this.toBytesBE()},T.toBytesLE=function(){var E=this.high,O=this.low;return[255&O,255&O>>>8,255&O>>>16,255&O>>>24,255&E,255&E>>>8,255&E>>>16,255&E>>>24]},T.toBytesBE=function(){var E=this.high,O=this.low;return[255&E>>>24,255&E>>>16,255&E>>>8,255&E,255&O>>>24,255&O>>>16,255&O>>>8,255&O]},t}()),Wa));Ho.getModule=function(t){var e=new Ho[t];return e.getArrayData=function(){var n=e.toArrayBuffer();return n=mu(n)?[].slice.call(new Int8Array(n)):n},e};var $o,hh="pgMsgP",fh="chatMsg",ph="pcMsgP",gh={PRIVATE:"ppMsgS",GROUP:"pgMsgS",CHATROOM:"chatMsgS"},mh="delMsg",_h="joinChrm",vh="joinChrmR",yh="exitChrm",Ch="setKV",Eh="delKV",Rh="setKVS",Th="delKVS",Ja="qryRelationR",Sh="delRelation",Ih="setSeAtt",Er={PRIVATE:"cleanPMsg",GROUP:"cleanGMsg",CUSTOMER_SERVICE:"cleanCMsg",SYSTEM:"cleanSMsg"},Au="qryPMsg",bh="qryGMsg",Mu="qryCHMsg",wh="qryCMsg",Oh="qrySMsg",Nh=((Ln={}).ppMsgP=oe.PRIVATE,Ln[hh]=oe.GROUP,Ln[fh]=oe.CHATROOM,Ln[ph]=oe.CUSTOMER_SERVICE,Ln),Ah=((on={})[oe.PRIVATE]=Au,on[oe.GROUP]=bh,on[oe.CHATROOM]=Mu,on[oe.CUSTOMER_SERVICE]=wh,on[oe.SYSTEM]=Oh,on),Mh=((kn={})[oe.PRIVATE]=Er.PRIVATE,kn[oe.GROUP]=Er.GROUP,kn[oe.CUSTOMER_SERVICE]=Er.CUSTOMER_SERVICE,kn[oe.SYSTEM]=Er.SYSTEM,kn),Xi="1",Ph="0",za=1,Qa=2,Xa=3,Lh=function(){function t(e){this._codec=e==="websocket"?Ho:ir,this._connectType=e}return t.prototype.decodeByPBName=function(e,n,r){var i,o=this,s=e,c=((i={})[tr]=o._formatSyncMessages,i[Ii]=o._formatReceivedMessage,i[er]=o._formatSentMessage,i[nr]=o._formatHistoryMessages,i[rr]=o._formatConversationList,i[bi]=o._formatChatRoomInfos,i[Jt]=o._formatRTCUserList,i[Oi]=o._formatRTCData,i[ln]=o._formatChatRoomKVList,i[Ni]=o._formatUserSetting,i[Mi]=o._formatConversationStatus,i[Pi]=o._formatGrpReadReceiptQryResp,i[hn]=o._formatSetUserSettingOutput,i[Ai]=o._formatUserSettingNotification,i[Li]=o._formatRTCRoomKVList,i[wi]=o._formatRTCAuidenceJoinRoomData,i[ki]=o._formatRTCJoinedUserInfo,i)[n];try{s=e.length>0&&o._codec[n].decode(e),$e(s)&&(s=function(d){for(var l in d)$e(d[l])&&(d[l]=st(d[l]));return d}(s)),Jr(c)&&(s=c.call(this,s,r))}catch(d){Q.error(`PB parse error `,d,e,n)}return s},t.prototype._readBytes=function(e){var n=e.offset,r=e.buffer,i=e.limit;if(n)try{var o=mu(r)?new Uint8Array(r):r;return dr.readUTF(o.subarray(n,i))}catch(s){Q.info(`readBytes error `,s)}return e},t.prototype._formatBytes=function(e){var n=this._readBytes(e);try{n=JSON.parse(n)}catch(r){Q.info(`formatBytes error `,r)}return n||e},t.prototype._formatSyncMessages=function(e,n){n=n||{};var r=this,i=e.list,o=e.syncTime,s=e.finished;return(_e(s)||s===null)&&(e.finished=!0),e.syncTime=st(o),e.list=Cr(i,function(c){return r._formatReceivedMessage(c,n)}),e},t.prototype._formatReceivedMessage=function(e,n){var r=(n=n||{}).currentUserId,i=n.connectedTime,o=e.content,s=e.fromUserId,c=e.type,d=e.groupId,l=e.status,h=e.dataTime,a=e.classname,u=e.msgId,f=e.extraContent,p=e.pushContent,m=e.pushExt,_=e.configFlag,v=(e.direction||ct.RECEIVE)===ct.SEND,y=function(K){var J=Xn.READ;return{isPersited:!!(16&K),isCounted:!!(32&K),isMentioned:!!(64&K),disableNotification:!!(512&K),receivedStatus:J=2&K?Xn.RETRIEVED:J,canIncludeExpansion:!!(1024&K)}}(l),C=y.isPersited,w=y.isCounted,P=y.isMentioned,T=y.disableNotification,E=y.receivedStatus,O=y.canIncludeExpansion,B=[oe.GROUP,oe.CHATROOM,oe.RTC_ROOM].indexOf(c)>-1?d:s,$=v?r:s,R=st(h),S=R "+s),this.timestamp=n.readLong()}return{stream:n,length:r}},e.MESSAGE_LENGTH=2,e}(lr),ca=function(t){function e(){var n=t!==null&&t.apply(this,arguments)||this;return n._name=rt.DISCONNECT,n.status=0,n}return Oe(e,t),e.prototype.readMessage=function(n,r){return n.readByte(),this.status=+n.readByte(),{stream:n,length:r}},e.MESSAGE_LENGTH=2,e}(lr),kh=function(t){function e(){var n=t.call(this,qe.PING_REQ)||this;return n._name=rt.PING_REQ,n}return Oe(e,t),e.prototype.writeMessage=function(n){},e}(ku),Uu=function(t){function e(n){var r=t.call(this,n)||this;return r._name=rt.PING_RESP,r}return Oe(e,t),e}(lr),ua=function(t){function e(){var n=t!==null&&t.apply(this,arguments)||this;return n.messageId=0,n}return Oe(e,t),e.prototype.readMessage=function(n,r){var i=256*n.readByte()+n.readByte();return this.messageId=parseInt(i.toString(),10),{stream:n,length:r}},e}(lr),Di=function(t){function e(){var n=t!==null&&t.apply(this,arguments)||this;return n.messageId=0,n}return Oe(e,t),e.prototype.writeMessage=function(n){var r=this.messageId,i=255&r,o=(65280&r)>>8;n.write(o),n.write(i)},e}(ku),or=function(t){function e(){var n=t!==null&&t.apply(this,arguments)||this;return n._name=rt.PUBLISH,n.topic="",n.targetId="",n.syncMsg=!1,n.identifier=Zt.PUB,n}return Oe(e,t),e.prototype.readMessage=function(n,r){return this.date=n.readInt(),this.topic=n.readUTF(),this.targetId=n.readUTF(),t.prototype.readMessage.call(this,n,r),this.data=n.readAll(),{stream:n,length:r}},e}(ua),Dn=function(t){function e(n,r,i){var o=t.call(this,qe.PUBLISH)||this;return o._name=rt.PUBLISH,o.syncMsg=!1,o.identifier=Zt.PUB,o.topic=n,o.data=nt(r)?dr.writeUTF(r):r,o.targetId=i,o}return Oe(e,t),e.prototype.writeMessage=function(n){n.writeUTF(this.topic),n.writeUTF(this.targetId),t.prototype.writeMessage.call(this,n),n.write(this.data)},e}(Di),jo=function(t){function e(){var n=t!==null&&t.apply(this,arguments)||this;return n._name=rt.PUB_ACK,n.status=0,n.date=0,n.millisecond=0,n.messageUId="",n.timestamp=0,n.identifier=Zt.PUB,n.topic="",n.targetId="",n}return Oe(e,t),e.prototype.readMessage=function(n,r){return t.prototype.readMessage.call(this,n,r),this.date=n.readInt(),this.status=256*n.readByte()+n.readByte(),this.millisecond=256*n.readByte()+n.readByte(),this.timestamp=1e3*this.date+this.millisecond,this.messageUId=n.readUTF(),{stream:n,length:r}},e}(ua),xu=function(t){function e(n){var r=t.call(this,qe.PUB_ACK)||this;return r._name=rt.PUB_ACK,r.status=0,r.date=0,r.millisecond=0,r.messageUId="",r.timestamp=0,r.messageId=n,r}return Oe(e,t),e.prototype.writeMessage=function(n){t.prototype.writeMessage.call(this,n)},e}(Di),se=function(t){function e(n,r,i){var o=t.call(this,qe.QUERY)||this;return o.name=rt.QUERY,o.identifier=Zt.QUERY,o.topic=n,o.data=nt(r)?dr.writeUTF(r):r,o.targetId=i,o}return Oe(e,t),e.prototype.writeMessage=function(n){n.writeUTF(this.topic),n.writeUTF(this.targetId),t.prototype.writeMessage.call(this,n),n.write(this.data)},e}(Di),Bu=function(t){function e(n){var r=t.call(this,qe.QUERY_CONFIRM)||this;return r._name=rt.QUERY_CON,r.messageId=n,r}return Oe(e,t),e}(Di),Wn=function(t){function e(){var n=t!==null&&t.apply(this,arguments)||this;return n._name=rt.QUERY_ACK,n.status=0,n.identifier=Zt.QUERY,n.topic="",n.targetId="",n}return Oe(e,t),e.prototype.readMessage=function(n,r){return t.prototype.readMessage.call(this,n,r),this.date=n.readInt(),this.status=256*n.readByte()+n.readByte(),this.data=n.readAll(),{stream:n,length:r}},e}(ua),Vu=function(t){var e,n=t.type;switch(n){case qe.CONN_ACK:e=new Du(t);break;case qe.PUBLISH:(e=new or(t)).syncMsg=t.syncMsg;break;case qe.PUB_ACK:e=new jo(t);break;case qe.QUERY_ACK:e=new Wn(t);break;case qe.SUB_ACK:case qe.UNSUB_ACK:case qe.PING_RESP:e=new Uu(t);break;case qe.DISCONNECT:e=new ca(t);break;default:e=new lr(t),Q.error("No support for deserializing "+n+" messages")}return e};(function(t){t[t.ppMsgP=1]="ppMsgP",t[t.ppMsgN=2]="ppMsgN",t[t.ppMsgS=3]="ppMsgS",t[t.pgMsgP=4]="pgMsgP",t[t.chatMsg=5]="chatMsg",t[t.pcMsgP=6]="pcMsgP",t[t.qryPMsg=7]="qryPMsg",t[t.qryGMsg=8]="qryGMsg",t[t.qryCHMsg=9]="qryCHMsg",t[t.qryCMsg=10]="qryCMsg",t[t.qrySMsg=11]="qrySMsg",t[t.recallMsg=12]="recallMsg",t[t.prMsgS=13]="prMsgS",t[t.rrMsg=14]="rrMsg",t[t.rrList=15]="rrList",t[t.s_ntf=16]="s_ntf",t[t.s_msg=17]="s_msg",t[t.s_stat=18]="s_stat",t[t.s_cmd=19]="s_cmd",t[t.s_us=20]="s_us",t[t.pullUS=21]="pullUS",t[t.pgMsgS=22]="pgMsgS",t[t.chatMsgS=23]="chatMsgS",t[t.qrySessionsAtt=24]="qrySessionsAtt",t[t.pullMsg=25]="pullMsg",t[t.qrySessions=26]="qrySessions",t[t.delSessions=27]="delSessions",t[t.delMsg=28]="delMsg",t[t.updRRTime=29]="updRRTime",t[t.chrmPull=30]="chrmPull",t[t.joinChrm=31]="joinChrm",t[t.joinChrmR=32]="joinChrmR",t[t.exitChrm=33]="exitChrm",t[t.queryChrmI=34]="queryChrmI",t[t.setKV=35]="setKV",t[t.delKV=36]="delKV",t[t.pullKV=37]="pullKV",t[t.qryRelation=38]="qryRelation",t[t.delRelation=39]="delRelation",t[t.pullSeAtts=40]="pullSeAtts",t[t.setSeAtt=41]="setSeAtt",t[t.qnTkn=42]="qnTkn",t[t.qnUrl=43]="qnUrl",t[t.aliUrl=44]="aliUrl",t[t.s3Url=45]="s3Url",t[t.stcUrl=46]="stcUrl",t[t.cleanPMsg=47]="cleanPMsg",t[t.cleanGMsg=48]="cleanGMsg",t[t.cleanCMsg=49]="cleanCMsg",t[t.cleanSMsg=50]="cleanSMsg",t[t.rtcRJoin_data=51]="rtcRJoin_data",t[t.rtcRExit=52]="rtcRExit",t[t.rtcPing=53]="rtcPing",t[t.rtcSetData=54]="rtcSetData",t[t.rtc_ntf=55]="rtc_ntf",t[t.viewerJoinR=56]="viewerJoinR",t[t.viewerExitR=57]="viewerExitR",t[t.rtcPullKv=58]="rtcPullKv",t[t.rtcIdentityChange=59]="rtcIdentityChange",t[t.userSetData=60]="userSetData",t[t.rtcQryData=61]="rtcQryData",t[t.rtcDelData=62]="rtcDelData",t[t.rtcSetOutData=63]="rtcSetOutData",t[t.rtcQryUserOutData=64]="rtcQryUserOutData",t[t.rtcToken=65]="rtcToken",t[t.rtcUserState=66]="rtcUserState",t[t.rtcRInfo=67]="rtcRInfo",t[t.rtcUData=68]="rtcUData",t[t.rtcUPut=69]="rtcUPut",t[t.rtcUDel=70]="rtcUDel",t[t.rtcUList=71]="rtcUList",t[t.rtcQueryJoined=72]="rtcQueryJoined",t[t.addSeTag=73]="addSeTag",t[t.delSeTag=74]="delSeTag",t[t.addTag=75]="addTag",t[t.delTag=76]="delTag",t[t.disTag=77]="disTag",t[t.reportsdk=78]="reportsdk",t[t.rtcInvite=79]="rtcInvite",t[t.rtcCancelInvite=80]="rtcCancelInvite",t[t.rtcInviteAnswer=81]="rtcInviteAnswer",t[t.rtcEndInvite=82]="rtcEndInvite"})($o||($o={}));var mt,V=$o,Fu=function(t,e,n,r){return F(void 0,void 0,void 0,function(){var i;return H(this,function(o){return i=0,t.forEach(function(s){return F(void 0,void 0,void 0,function(){var c,d;return H(this,function(l){switch(l.label){case 0:return c=e+"://"+s+"/ping?r="+(a=9999,(h=1e3)+Math.floor(Math.random()*(a-h))),Q.debug("start ping",c),[4,n.httpReq({url:c,timeout:5e3})];case 1:return d=l.sent(),Q.debug("end ping",i,c,d.status),i++,r({finished:i===t.length,code:d.status,host:s}),[2]}var h,a})})}),[2]})})},Hu=function(t,e,n,r,i,o,s,c){return t+"://"+e+"/websocket?appId="+n+"&token="+encodeURIComponent(r)+"&sdkVer="+o+"&pid="+s+"&apiVer="+(i.isFromUniapp?"uniapp":"normal")+(i.connectPlatform?"&platform="+i.connectPlatform:"")+(c?"&protocolVer="+c:"")},$u=function(t){return[V.ppMsgS,V.pgMsgS,V.chatMsgS].map(function(e){return V[e]}).indexOf(t)>=0};(function(t){t[t.REDIRECT=0]="REDIRECT",t[t.OTHER_DEVICE_LOGIN=1]="OTHER_DEVICE_LOGIN",t[t.BLOCK=2]="BLOCK",t[t.REMOTE_CLOSE=3]="REMOTE_CLOSE",t[t.LOGOUT=4]="LOGOUT",t[t.BLOCK_NEW=5]="BLOCK_NEW",t[t.REDIRECT_NEW=6]="REDIRECT_NEW"})(mt||(mt={}));var vt,Za=function(t,e){Q.info("websocket send -> messageId: "+t.messageId);var n=t.getBufferData();e.send(n.buffer)},bn=function(t){function e(n,r){var i=t.call(this,"websocket",r)||this;return i._runtime=n,i._socket=null,i._messageIds={},i._syncMessageIds={},i._failedCount=0,i.ALLOW_FAILED_TIMES=2,i._timer=null,i._idCount=0,i._generateMessageId=function(){return i._idCount>=65535&&(i._idCount=0),++i._idCount},i}return Oe(e,t),e.prototype.connect=function(n,r,i,o,s,c){return F(this,void 0,void 0,function(){var d=this;return H(this,function(l){return[2,new Promise(function(h){var a=[],u=0,f=!1,p=!1,m=function(){return F(d,void 0,void 0,function(){var _;return H(this,function(v){switch(v.label){case 0:return a.length===0||f?[2]:(f=!0,[4,this._connect(n,r,a.shift(),o,s,c)]);case 1:if((_=v.sent())===M.SUCCESS)this._checkAlive(),h(_);else if(_===Ke.REDIRECT)h(_);else{if(p&&a.length===0)return h(_u(_)),[2];f=!1,m()}return[2]}})})};s=fs(s),d._watcher.status(ue.CONNECTING),Fu(i,o,d._runtime,function(_){var v=_.code,y=_.finished,C=_.host;p=y,v===200&&(a.push(C),u++,m()),y&&u===0&&(Q.error("No valid websocket server hosts!"),h(M.RC_SOCKET_NOT_CREATED))})})]})})},e.prototype._connect=function(n,r,i,o,s,c){return F(this,void 0,void 0,function(){var d,l,h,a,u,f=this;return H(this,function(p){switch(p.label){case 0:return d=o.replace("http","ws"),l=Hu(d,i,n,r,this._runtime,s,"",c),Q.debug("conenct start -> "+l),this.sendConnectTime=Date.now(),h=this._runtime.createWebSocket(l),a=function(m){f._timer&&(clearTimeout(f._timer),f._timer=null),f._socket===h&&(f._socket=null,f._watcher.status(m))},[4,new Promise(function(m){h.onMessage(function(_){if(Object.prototype.toString.call(_)==="[object ArrayBuffer]"){var v=function(C,w){var P=new Uint8Array(C),T=new ah(P),E=T.readByte(),O=new ms(E),B=Vu(O);return B.read(T,P.length-1,w),B}(_,c);if(v instanceof Uu&&f._pingResolve)return f._pingResolve(M.SUCCESS),void(f._pingResolve=void 0);if(v instanceof Du)return Q.debug("recv connect ack -> "+v.status),v.status!==Ke.ACCEPTED?(Q.warn("connect failed: "+v.status),void m(v.status)):(Q.info("connect success -> "+l),f.connectedTime=v.timestamp,f.userId=v.userId||"",f._idCount=v.messageId,void m(M.SUCCESS));if(v instanceof ca){var y=v.status;switch(Q.warn("recv disconnect signal -> status: "+y),y){case mt.BLOCK:f._watcher.status(ue.BLOCKED);break;case mt.OTHER_DEVICE_LOGIN:f._watcher.status(ue.KICKED_OFFLINE_BY_OTHER_CLIENT);break;case mt.REDIRECT_NEW:case mt.REDIRECT:f._watcher.status(ue.REDIRECT);break;default:f._watcher.status(ue.DISCONNECT_BY_SERVER)}}else f._onReceiveSignal(v)}else Q.error("Socket received invalid data:",_)}),h.onClose(function(_,v){for(var y in Q.warn("websocket closed! code:",_,"reason:",v),a(ue.CONNECTION_CLOSED),f._messageIds){var C=f._messageIds[y];delete f._messageIds[y],C(M.RC_NET_CHANNEL_INVALID)}m(_)}),h.onError(function(_){var v;for(var y in Q.error("websocket error!",(v=_)===null||v===void 0?void 0:v.stack),a(ue.WEBSOCKET_ERROR),f._messageIds){var C=f._messageIds[y];delete f._messageIds[y],C(M.RC_NET_CHANNEL_INVALID)}m(M.NETWORK_ERROR)}),h.onOpen(function(){return Q.debug("websocket open =>",l)}),setTimeout(function(){m(M.TIMEOUT)},5e3)})];case 1:return(u=p.sent())===M.SUCCESS?this._socket=h:(Q.warn("connect result -> code: "+u+", url: "+l),h.close()),[2,u]}})})},e.prototype._checkAlive=function(){var n;return F(this,void 0,void 0,function(){var r,i=this;return H(this,function(o){switch(o.label){case 0:return this._socket?(Q.debug("send ping ->"),this.sendOnly(new kh),[4,new Promise(function(s){i._pingResolve=s,i._timer&&clearTimeout(i._timer),i._timer=setTimeout(function(){i._pingResolve=void 0,s(M.TIMEOUT)},15e3)})]):[2];case 1:return(r=o.sent())!==M.SUCCESS?(this._failedCount+=1,Q.warn("ping failed count: "+this._failedCount+", code: "+r),this._failedCount>=this.ALLOW_FAILED_TIMES?(this._failedCount=0,Q.warn("ping timeout, close current websocket to reconnect!"),(n=this._socket)===null||n===void 0||n.close(),this._watcher.status(ue.NETWORK_UNAVAILABLE)):this._checkAlive(),[2]):(Q.debug("recv pong <-"),this._failedCount=0,setTimeout(function(){return i._checkAlive()},15e3),[2])}})})},e.prototype._onReceiveSignal=function(n){return F(this,void 0,void 0,function(){var r,i,o,s,c,d,l=this;return H(this,function(h){switch(h.label){case 0:return r=n.messageId,n.header&&n.header.qos!==Ot.AT_MOST_ONCE&&(n instanceof or&&!n.syncMsg&&(Q.debug("send pubAck -> "+r),this.sendOnly(new xu(r))),n instanceof Wn&&(Q.debug("send queryCon -> "+r),this.sendOnly(new Bu(r)))),r>0&&(n instanceof jo||n instanceof Wn)&&(Q.debug("recv ack -> messageId: "+r),(i=this._messageIds[r])&&(i(n),delete this._messageIds[r]),(o=this._syncMessageIds[r])&&(delete this._syncMessageIds[r],o(n))),n instanceof or?(s=n.syncMsg,(c=n.topic)===V[V.userSetData]?[2]:!s||$u(c)?(this._watcher.signal(n),[2]):[4,new Promise(function(a){l._syncMessageIds[r]=a})]):[3,2];case 1:d=h.sent(),delete this._syncMessageIds[r],this._watcher.signal(n,d),h.label=2;case 2:return[2]}})})},e.prototype.sendOnly=function(n){this._socket&&Za(n,this._socket)},e.prototype.send=function(n,r,i,o){return o===void 0&&(o=3e4),F(this,void 0,void 0,function(){var s,c,d,l=this;return H(this,function(h){switch(h.label){case 0:return this._socket?(s=this._generateMessageId(),n.messageId=s,Za(n,this._socket),[4,new Promise(function(a){l._messageIds[s]=a,setTimeout(function(){l._messageIds[s]&&delete l._messageIds[s],a()},o)})]):[3,2];case 1:return(c=h.sent())?c instanceof Wn||c instanceof jo?(d=r&&c.data?this.codec.decodeByPBName(c.data,r,i):c,c.status!==0?(Q.warn("send failed -> message: "+s+", respPBName: "+r+", status: "+c.status),[2,{code:c.status,data:r&&c.data?d:null}]):[2,{code:M.SUCCESS,data:d}]):[2,{code:c}]:(Q.warn("send timeout -> message: "+s+", respPBName: "+r+", timeout: "+o),[2,{code:M.TIMEOUT}]);case 2:return[2,{code:M.RC_NET_CHANNEL_INVALID}]}})})},e.prototype.close=function(){this._socket&&(this._socket.close(),this._socket=null,this._watcher.status(ue.DISCONNECTED))},e}(Pu);(function(t){t.GET="GET",t.POST="POST"})(vt||(vt={}));var wn=function(t){function e(n,r){var i=t.call(this,"comet",r)||this;return i._runtime=n,i._messageIds={},i._syncMessageIds={},i._idCount=0,i._generateMessageId=function(){return++i._idCount},i._pid=encodeURIComponent(new Date().getTime()+Math.random()+""),i}return Oe(e,t),e.prototype.handleCometRes=function(n){var r=this;if(n.status!==200&&n.status!==202)return!1;var i=nt(n.data)?JSON.parse(n.data):n.data;return i?!Qe(i)||(Me(i,function(o){return F(r,void 0,void 0,function(){var s,c,d,l,h,a,u,f,p,m,_,v=this;return H(this,function(y){switch(y.label){case 0:if((s=o.sessionid)&&(this._sessionid=s),c=function(C){var w=C.headerCode,P=new ms(w),T=Vu(P);for(var E in C)T[E]=C[E];return T}(o),d=c.messageId,l=c._header,h=c.status,c.identifier,a=l&&l.qos!==Ot.AT_MOST_ONCE,d&&c.getIdentifier&&((u=this._messageIds[d])&&u(c),this._syncMessageIds[d]&&this._syncMessageIds[d](c)),a&&(c instanceof or&&!c.syncMsg&&(f=new xu(d),this.sendOnly(f)),c instanceof Wn&&(f=new Bu(d),this.sendOnly(f))),c instanceof ca){switch(h){case mt.OTHER_DEVICE_LOGIN:this._watcher.status(ue.KICKED_OFFLINE_BY_OTHER_CLIENT);break;case mt.BLOCK:this._watcher.status(ue.BLOCKED);break;case mt.REDIRECT_NEW:case mt.REDIRECT:this._watcher.status(ue.REDIRECT);break;default:this._watcher.status(ue.DISCONNECT_BY_SERVER)}return[2]}return c instanceof or?(p=c.syncMsg,m=c.topic,!p||$u(m)?(this._watcher.signal(c),[2,!1]):[4,new Promise(function(C){v._syncMessageIds[d]=C})]):[3,2];case 1:_=y.sent(),delete this._syncMessageIds[d],this._watcher.signal(c,_),y.label=2;case 2:return[2]}})})}),!0):(Q.error("received data is not a validJson",i),!1)},e.prototype._startPullSignal=function(n){return F(this,void 0,void 0,function(){var r,i,o,s;return H(this,function(c){switch(c.label){case 0:return r=new Date().getTime(),i=n+"://"+this._domain+"/pullmsg.js?sessionid="+this._sessionid+"×trap="+r+"&pid="+this._pid,[4,this._runtime.httpReq({url:i,body:{pid:this._pid},timeout:45e3})];case 1:return o=c.sent(),s=this.handleCometRes(o),this._isDisconnected||(s?this._startPullSignal(n):(this._isDisconnected=!0,this._watcher.status(ue.NETWORK_UNAVAILABLE))),[2]}})})},e.prototype.connect=function(n,r,i,o,s,c){return F(this,void 0,void 0,function(){var d,l,h,a,u=this;return H(this,function(f){return s=fs(s),this._protocol=o,this._isDisconnected=!1,this._watcher.status(ue.CONNECTING),d=[],l=0,h=!1,a=!1,[2,new Promise(function(p){var m=function(){return F(u,void 0,void 0,function(){var _;return H(this,function(v){switch(v.label){case 0:return d.length===0||h?[2]:(h=!0,[4,this._connect(n,r,d.shift(),o,s)]);case 1:if((_=v.sent())===M.SUCCESS)this._startPullSignal(o),p(_);else if(_===Ke.REDIRECT)p(_);else{if(a&&d.length===0)return p(_u(_)),[2];h=!1,m()}return[2]}})})};u._watcher.status(ue.CONNECTING),Fu(i,o,u._runtime,function(_){var v=_.code,y=_.finished,C=_.host;a=y,v===200&&(d.push(C),l++,m()),y&&l===0&&(Q.error("No valid websocket server hosts!"),p(M.RC_SOCKET_NOT_CREATED))})})]})})},e.prototype._connect=function(n,r,i,o,s){return F(this,void 0,void 0,function(){var c,d,l,h;return H(this,function(a){switch(a.label){case 0:return c=function(u){return u.status!==200&&u.status!==202?(Q.error("handle comet res -> res: "+JSON.stringify(u||{})),!1):!!u.data&&(function(f){if($e(f))return!0;var p=!1;try{var m=JSON.parse(f);p=JSON.stringify(m)===f}catch{p=!1}return p}(u.data)?$e(u.data)?u.data:JSON.parse(u.data):(Q.error("received data is not a validJson",u.data),!1))},d=Hu(o,i,n,r,this._runtime,s,this._pid),this.sendConnectTime=Date.now(),Q.debug("conenct start -> "+d),[4,this._runtime.httpReq({url:d,body:{pid:this._pid},timeout:5e3})];case 1:return l=a.sent(),h=c(l),this._domain=i,h&&h.status===0?(this._sessionid=h.sessionid,this.userId=h.userId,this.connectedTime=h.timestamp):Q.warn("connect result -> code: "+(h==null?void 0:h.status)+", url: "+d),[2,h==null?void 0:h.status]}})})},e.prototype.sendCometData=function(n,r){return F(this,void 0,void 0,function(){var i,o,s,c,d,l,h,a,u,f;return H(this,function(p){switch(p.label){case 0:return o=(i=this)._domain,s=i._sessionid,c=i._pid,d=n.messageId,l=n.topic,h=n.targetId,n.identifier,a=n.getHeaderFlag(),u=l?this._protocol+"://"+o+"/websocket?messageid="+d+"&header="+a+"&sessionid="+s+"&topic="+l+"&targetid="+h+"&pid="+c:this._protocol+"://"+o+"/websocket?messageid="+d+"&header="+a+"&sessionid="+s+"&pid="+c,[4,this._runtime.httpReq({url:u,method:vt.POST,body:n.getCometData()})];case 1:return f=p.sent(),this.handleCometRes(f),[2]}})})},e.prototype.sendOnly=function(n){this.sendCometData(n)},e.prototype.send=function(n,r,i,o){return o===void 0&&(o=3e4),F(this,void 0,void 0,function(){var s,c,d,l=this;return H(this,function(h){switch(h.label){case 0:return s=this._generateMessageId(),n.messageId=s,this.sendCometData(n),[4,new Promise(function(a){l._messageIds[s]=a,setTimeout(function(){delete l._messageIds[s],a()},o)})];case 1:return(c=h.sent())?(d=r&&c.data?this.codec.decodeByPBName(c.data,r,i):c,c.status!==0?[2,{code:c.status,data:r&&c.data?d:null}]:[2,{code:M.SUCCESS,data:d}]):[2,{code:M.TIMEOUT}]}})})},e.prototype.close=function(){this._isDisconnected=!0,this._watcher.status(ue.DISCONNECTED)},e}(Pu),Dh=function(t,e,n){this.runtime=t,this._watcher=e,this._options=n,this.currentUserId="",this._appkey=this._options.appkey,this._apiVer=this._options.apiVersion,this.navi=this._createNavi()},Zi=function(t){return["navi",t].join("_")},Uh=function(){function t(e,n){this._runtime=e,this._options=n,this._naviInfo=null,this._appkey=this._options.appkey,this._apiVersion=fs(this._options.apiVersion)}return t.prototype.getInfo=function(e,n,r,i){return F(this,void 0,void 0,function(){var o,s;return H(this,function(c){switch(c.label){case 0:return r&&this._clear(e),(o=function(d,l,h){var a,u,f=Zi(d);try{var p=h.getItem(f);u=p?JSON.parse(p):[]}catch{u=[]}var m=Date.now();return u.length>0&&(u=u.filter(function(_){return m-_.timestamp<72e5})),u.length===0?h.removeItem(f):h.setItem(f,JSON.stringify(u)),((a=u.find(function(_){return _.token===l}))===null||a===void 0?void 0:a.naviInfo)||null}(this._appkey,e,this._runtime.localStorage))?(this._naviInfo=o,[2,o]):(s=this._options.navigators.slice(),n.length&&n.forEach(function(d){s.indexOf(d)<0&&s.unshift(d)}),[4,this._reqNavi(s,this._appkey,e,i)]);case 1:return(o=c.sent())?(this._naviInfo=o,this.setNaviInfo2Cache(e,o),[2,o]):[2,o]}})})},t.prototype.setNaviInfo2Cache=function(e,n){this._naviInfo=n,function(r,i,o,s){var c,d=Zi(r);try{var l=s.getItem(d);c=l?JSON.parse(l):[]}catch{c=[]}var h=Date.now();c.length>0&&(c=c.filter(function(a){return h-a.timestamp<72e5&&i!==a.token})),c.push({timestamp:h,naviInfo:o,token:i}),s.setItem(d,JSON.stringify(c))}(this._appkey,e,n,this._runtime.localStorage)},t.prototype.getInfoFromCache=function(e){return this._naviInfo},t.prototype._clear=function(e){(function(n,r,i){var o,s=Zi(n);try{var c=i.getItem(s);o=c?JSON.parse(c):[]}catch{o=[]}var d=Date.now();o.length>0&&(o=o.filter(function(l){return d-l.timestamp<72e5&&r!==l.token})),o.length===0?i.removeItem(s):i.setItem(s,JSON.stringify(o))})(this._appkey,e,this._runtime.localStorage)},t}(),Rr=function(t,e,n){return[t,e,n].join("_")},xh=function(){function t(e,n){this._runtime=e,this._appkey=n,this._users={}}return t.prototype._getMemData=function(e){return this._users[e]||(this._users[e]={inboxTime:0,outboxTime:0})},t.prototype.setInboxTime=function(e,n){var r=this._getMemData(n);if(!(r.inboxTime>e)){r.inboxTime=e;var i=Rr("inbox",this._appkey,n);this._runtime.localStorage.setItem(i,e.toString())}},t.prototype.getInboxTime=function(e){var n=this._getMemData(e);if(n.inboxTime===0){var r=Rr("inbox",this._appkey,e);n.inboxTime=parseInt(this._runtime.localStorage.getItem(r))||0}return n.inboxTime},t.prototype.setOutboxTime=function(e,n){var r=this._getMemData(n);if(!(r.outboxTime>=e)){r.outboxTime=e;var i=Rr("outbox",this._appkey,n);this._runtime.localStorage.setItem(i,e.toString())}},t.prototype.getOutboxTime=function(e){var n=this._getMemData(e);if(n.outboxTime===0){var r=Rr("outbox",this._appkey,e);n.outboxTime=parseInt(this._runtime.localStorage.getItem(r))||0}return n.outboxTime},t}(),eo={_caches:{},set:function(t,e){this._caches[t]=e},get:function(t){return this._caches[t]||0},clear:function(t){this._caches[t]=0}},Bh=function(){function t(e,n){this._kvCaches={},this._chatroomId=e,this._currentUserId=n}return t.prototype._add=function(e){var n=e.key;e.isDeleted=!1,this._kvCaches[n]=e},t.prototype._remove=function(e){var n=e.key,r=this._kvCaches[n];r&&(r.isDeleted=!0,this._kvCaches[n]=r)},t.prototype._setEntry=function(e,n){var r=e.key,i=e.type,o=e.isOverwrite,s=e.userId,c=this._getSetUserId(r),d=i===Ze.DELETE,l=c===s,h=!this._isExisted(r),a=d?this._remove:this._add;(n||o||l||h)&&a.call(this,e)},t.prototype.getValue=function(e){var n=this._kvCaches[e]||{};return n.isDeleted?null:n.value},t.prototype.getAllValue=function(){var e={};for(var n in this._kvCaches)this._kvCaches[n].isDeleted||(e[n]=this._kvCaches[n].value);return e},t.prototype._getSetUserId=function(e){return(this._kvCaches[e]||{}).userId},t.prototype._isExisted=function(e){var n=this._kvCaches[e]||{},r=n.value,i=n.isDeleted;return r&&!i},t.prototype.setEntries=function(e){var n=this,r=e.kvEntries,i=e.isFullUpdate;r=r||[],(i=i||!1)&&this.clear(),r.forEach(function(o){n._setEntry(o,i)}),Q.debug("end setEntries")},t.prototype.clear=function(){this._kvCaches={}},t}(),Vh=function(){function t(e){this._pullQueue=[],this._isPulling=!1,this._storeCaches={},this._engine=e}return t.prototype._startPull=function(){return F(this,void 0,void 0,function(){var e,n,r,i,o,s,c;return H(this,function(d){switch(d.label){case 0:return this._isPulling||this._pullQueue.length===0?[2]:(this._isPulling=!0,e=this._pullQueue.splice(0,1)[0],n=e.chrmId,r=e.timestamp,(i=eo.get(n))>r?(this._isPulling=!1,this._startPull(),[2]):[4,this._engine.pullChatroomEntry(n,i)]);case 1:return o=d.sent(),s=o.code,c=o.data,this._isPulling=!1,s===M.SUCCESS?(eo.set(n,c.syncTime||0),this._startPull()):this._startPull(),[2]}})})},t.prototype.reset=function(e){eo.clear(e);var n=this._storeCaches[e];n&&n.clear()},t.prototype.pullEntry=function(e,n){this._pullQueue.push({chrmId:e,timestamp:n}),this._startPull()},t.prototype.setLocal=function(e,n,r){var i=this._storeCaches[e];Gn(i)||(i=new Bh(e,r)),i.setEntries(n),this._storeCaches[e]=i},t.prototype.getValue=function(e,n){var r=this._storeCaches[e];return r?r.getValue(n):null},t.prototype.getAll=function(e){var n=this._storeCaches[e],r={};return n&&(r=n.getAllValue()),r},t}(),Fh=function(){function t(e,n,r,i){this._runtime=e,this._appkey=n,this._userId=r,this._canJoinMulipleChrm=i,this._sessionKey="",this._joinedChrmsInfo={},this._sessionKey="sync-chrm-"+this._appkey+"-"+this._userId}return t.prototype.set=function(e,n){n===void 0&&(n=10),!this._canJoinMulipleChrm&&(this._joinedChrmsInfo={}),this._joinedChrmsInfo[e]=n,this._runtime.sessionStorage.setItem(this._sessionKey,JSON.stringify(this._joinedChrmsInfo))},t.prototype.get=function(){var e,n;try{n=this._runtime.sessionStorage.getItem(this._sessionKey),e=JSON.parse(n||"{}")}catch{Q.error("parse rejoined chrm infos error -> "+n),e={}}return e},t.prototype.remove=function(e){delete this._joinedChrmsInfo[e],Gn(this._joinedChrmsInfo)?this._runtime.sessionStorage.setItem(this._sessionKey,JSON.stringify(this._joinedChrmsInfo)):this.clear()},t.prototype.clear=function(){this._joinedChrmsInfo={},this._runtime.sessionStorage.removeItem(this._sessionKey)},t}(),to="converStatusChanged",Hh=function(){function t(e,n,r){this._eventEmitter=new ur,this._pullQueue=[],this._isPulling=!1,this._storage=Ti(e.runtime),this._appkey=n,this._currentUserId=r,this._engine=e,this._storagePullTimeKey="con-s-"+n+"-"+r}return t.prototype._set=function(e){var n=this;if(!_e(e)&&Array.isArray(e)){var r=this._storage.get(this._storagePullTimeKey)||0,i=e.length;e.forEach(function(o,s){var c=o.updatedTime||0;r=c>r?c:r,o.conversationType=o.type,n._eventEmitter.emit(to,{statusItem:o,isLastPull:s===i-1})}),this._storage.set(this._storagePullTimeKey,r)}},t.prototype._startPull=function(){return F(this,void 0,void 0,function(){var e,n,r,i;return H(this,function(o){switch(o.label){case 0:return this._isPulling||this._pullQueue.length===0?[2]:(this._isPulling=!0,e=this._pullQueue.splice(0,1)[0],[4,this._engine.pullConversationStatus(e)]);case 1:return n=o.sent(),r=n.code,i=n.data,r===M.SUCCESS?(this._isPulling=!1,this._set(i),this._startPull()):this._startPull(),[2]}})})},t.prototype.pull=function(e){var n=this._storage.get(this._storagePullTimeKey)||0;(e>n||e===0)&&(this._pullQueue.push(n),this._startPull())},t.prototype.watch=function(e){this._eventEmitter.on(to,function(n){e(n)})},t.prototype.unwatch=function(){this._eventEmitter.off(to,function(e){})},t}(),Yt={c:{keyName:"unreadMessageCount",defaultVal:0},hm:{keyName:"hasMentioned",defaultVal:!1},m:{keyName:"mentionedInfo",defaultVal:null},t:{keyName:"lastUnreadTime",defaultVal:0},nc:{keyName:"notificationStatus",defaultVal:2},to:{keyName:"isTop",defaultVal:!1},tg:{keyName:"tags",defaultVal:{}},mc:{keyName:"unreadMentionedCount",defaultVal:0}},Hr={};for(var ec in Yt){var $h=Yt[ec].keyName;Hr[$h]=ec}var Un,jh=function(){function t(e,n,r){this._appkey=n,this._currentUserId=r;var i="con-"+n+"-"+r;this.storage=new ka(e,i),this._localStore=new ka(e,"CONVER-"+n+"-"+r)}return t.prototype._getStoreKey=function(e,n,r){return r+"_"+e+"_"+n},t.prototype._getConOptionByKey=function(e){var n=(e=e||"").split("_");if(n.length>=2){var r=n.shift(),i=n.shift(),o=n.join("_");return{conversationType:Number(i),targetId:o,channelId:r}}return{conversationType:oe.PRIVATE,targetId:"",channelId:""}},t.prototype.updateMentionedData=function(e){var n=this,r=e.conversationType,i=e.targetId,o=e.messageType,s=e.isMentioned,c=e.content,d=e.senderUserId,l=e.channelId,h=this._getStoreKey(r,i,l),a=this._localStore.get(h)||{},u=Hr.mentionedInfo,f=Hr.hasMentioned,p=a[u]||{},m=p.userIdList||[],_=c.mentionedInfo;if(_){if(s&&r===oe.GROUP&&((_.userIdList||[]).forEach(function(y){y===n._currentUserId&&m.indexOf(d)<0&&m.push(d)}),_.type===gs.ALL&&m.indexOf(d)<0&&m.push(d)),o===Ge.RECALL&&r===oe.GROUP){var v=m.indexOf(d);v>=0&&m.splice(v,1)}_={userIdList:m,type:(_==null?void 0:_.type)||p.type},m.length!==0?(a[u]=_,a[f]=!0):(delete a[u],delete a[f]),Gn(a)?this._localStore.set(h,a):this._localStore.remove(h)}},t.prototype.set=function(e,n,r,i){var o=this._getStoreKey(e,n,i),s=this._localStore.get(o)||{};for(var c in r){var d=Hr[c],l=r[c];if(!_e(d)&&!_e(l)&&c!=="hasMentioned"&&c!=="MentionedInfo"){if(l===Yt[d].defaultVal||c==="tags"&&!Gn(l))delete s[d];else if(c==="tags"){var h=l;for(var a in h)h[a].isTop||delete h[a].isTop;s[d]=l}else s[d]=l;s.c||(delete s.t,delete s.hm,delete s.m,delete s.mc)}}Gn(s)?this._localStore.set(o,s):this._localStore.remove(o)},t.prototype.get=function(e,n,r){r===void 0&&(r="");var i=this._getStoreKey(e,n,r),o=this._localStore.get(i)||{},s={};for(var c in Yt){var d=Yt[c],l=d.keyName,h=d.defaultVal;s[l]=o[c]||Fr(h)}return s},t.prototype.getValue=function(e){var n=this._localStore.getValues()||{},r=[];for(var i in n){var o=this._getConOptionByKey(i),s={conversationType:o.conversationType,targetId:o.targetId,channelId:o.channelId},c=n[i];for(var d in c){var l=Yt[d],h=l.keyName,a=l.defaultVal;s[h]=c[d]||Fr(a)}s=e?e(s):s,r.push(s)}return r},t.prototype.getValueForTag=function(){var e=this._localStore.getValues()||{},n={};for(var r in e){var i=this._getConOptionByKey(r),o=i.conversationType,s=i.targetId,c={},d=e[r];for(var l in d){var h=Yt[l],a=h.keyName,u=h.defaultVal;c[a]=d[l]||Fr(u)}for(var f in c.tags){_e(n[f])&&(n[f]=[]);var p=Object.assign({},c,{conversationType:o,targetId:s});delete p.tags,n[f].push(p)}}return n},t.prototype.adaptOldStore=function(){try{var e=this.storage.getValues();if(Object.keys(e).length===0)return;for(var n in e){var r="_"+n;this._localStore.set(r,e[n])}}catch(i){Q.error("adaptOldStore error: "+i.message)}},t}(),Kh=[oe.PRIVATE,oe.GROUP,oe.SYSTEM,oe.PUBLIC_SERVICE,oe.APP_PUBLIC_SERVICE],tc="conversationChanged",nc="conTagStatusChanged",qh=function(){function t(e,n,r,i,o){var s=this;this._updatedConversations={},this._conTagStatusChanged=!1,this._eventEmitter=new ur,this._draftMap={},this._appkey=n,this._loginUserId=r,this._store=new jh(e.runtime,n,r),this._statusManager=new Hh(e,n,r),this._statusManager.watch(function(c){var d=c.statusItem,l=c.isLastPull;s.addStatus(d,l)}),this._eventEmitter.on(tc,function(c){i(c)}),this._eventEmitter.on(nc,function(){o()})}return t.prototype._calcUnreadCount=function(e,n){var r=e.content,i=e.messageType,o=e.sentTime,s=e.isCounted,c=e.messageDirection,d=e.senderUserId,l=c===ct.SEND&&d===this._loginUserId,h=i===Ge.RECALL,a=$e(r),u=!1,f={},p=n.lastUnreadTime||0,m=n.unreadMessageCount||0;return p>o||l?{hasChanged:u,localConversation:n,updateItems:f}:(s&&(n.unreadMessageCount=m+1,n.lastUnreadTime=o,u=!0),h&&a&&p>=r.sentTime&&m&&(n.unreadMessageCount=m-1,u=!0),u&&(f.unreadMessageCount={val:n.unreadMessageCount,time:o}),{hasChanged:u,localConversation:n,updateItems:f})},t.prototype._calcMentionedInfo=function(e,n){var r=e.content,i=(e.messageDirection,e.isMentioned),o=e.sentTime;ct.SEND;var s=$e(r),c=!1,d={};return i&&s&&r.mentionedInfo&&(n.hasMentioned=!0,c=!0,d.hasMentioned={val:!0,time:o},d.mentionedInfo={val:r.mentionedInfo,time:o}),{hasChanged:c,localConversation:n,updateItems:d}},t.prototype._calcMentionedCount=function(e,n){var r=e.content,i=e.messageDirection,o=!1;if(e.isMentioned&&i===ct.RECEIVE&&(r==null?void 0:r.mentionedInfo)){var s=r.mentionedInfo,c=s.type,d=s.userIdList;if(c===gs.ALL||(d||[]).includes(this._loginUserId)){o=!0;var l=n.unreadMentionedCount||0;n.unreadMentionedCount=l+1}}return{hasChanged:o,localConversation:n}},t.prototype._setUpdatedConversation=function(e){if($e(e)){var n=e.conversationType,r=e.targetId,i=e.channelId,o=n+"_"+r,s=this._store.get(n,r,i)||{};this._updatedConversations[o]=Object.assign(s,e)}},t.prototype._setConTagStatusChanged=function(e,n,r,i){var o=(this._store.get(e,n,i)||{}).tags||{};if(Object.keys(o).length===Object.keys(r).length){for(var s in o)if(!r[s]||o[s].isTop!==r[s].isTop)return void(this._conTagStatusChanged=!0)}else this._conTagStatusChanged=!0},t.prototype.addStatus=function(e,n){var r=e.conversationType,i=e.targetId,o=e.updatedTime,s=e.notificationStatus,c=e.isTop,d=e.tags,l=e.channelId,h={},a={};_e(s)||(a.notificationStatus={time:o,val:s}),_e(c)||(a.isTop={time:o,val:c}),_e(d)||(a.tags={time:o,val:d},d==null||d.forEach(function(u){h[u.tagId]={isTop:u.isTop}})),this._setConTagStatusChanged(r,i,h,l),this._store.set(r,i,{notificationStatus:s,isTop:c,tags:h},l),this._setUpdatedConversation({conversationType:r,targetId:i,updatedItems:a,channelId:l}),n&&this._notifyConversationChanged()},t.prototype._notifyConversationChanged=function(){var e=[];for(var n in this._updatedConversations)e.push(this._updatedConversations[n]);e.length!==0&&(this._eventEmitter.emit(tc,e),this._updatedConversations={},this._conTagStatusChanged&&(this._eventEmitter.emit(nc),this._conTagStatusChanged=!1))},t.prototype.setConversationCacheByMessage=function(e,n){var r=this,i=e.conversationType,o=e.isPersited,s=e.targetId,c=e.channelId;if(Kh.indexOf(i)>=0){var d=!1,l=this._store.get(i,s,c),h={};if([this._calcUnreadCount,this._calcMentionedInfo,this._calcMentionedCount].forEach(function(f){var p=f.call(r,e,l),m=p.hasChanged,_=p.localConversation,v=p.updateItems;d=d||m,h=Ee(Ee({},h),v),l=Fr(_)}),d&&this._store.set(i,s,l,c),this._store.updateMentionedData(e),o){var a=this._store.get(i,s,c);a.updatedItems=Ee({latestMessage:{time:e.sentTime,val:e}},h),a.latestMessage=e;var u=Object.assign(a,{conversationType:i,targetId:s,channelId:c});this._setUpdatedConversation(u)}(d||o)&&this._notifyConversationChanged()}},t.prototype.get=function(e,n,r){return r===void 0&&(r=""),this._store.get(e,n,r)},t.prototype.getAllUnreadCount=function(e,n,r){var i=this._store.getValue(),o=0;return i.forEach(function(s){var c=s.unreadMessageCount,d=s.notificationStatus,l=s.conversationType;c=c||0,(r||d!==1)&&(n.length>0?n.includes(Number(l))&&(o+=Number(c)):o+=Number(c))}),o},t.prototype.getUnreadCountByTag=function(e,n){var r=this._store.getValueForTag()[e]||[],i=0;return r.forEach(function(o){var s=o.unreadMessageCount,c=o.notificationStatus;(n||c!==1)&&(s=s||0,i+=Number(s))}),i},t.prototype.getUnreadCount=function(e,n,r){return this._store.get(e,n,r).unreadMessageCount||0},t.prototype.clearUnreadCount=function(e,n,r,i){i===void 0&&(i=!0);var o=this._store.get(e,n,r),s=o.unreadMessageCount,c=o.hasMentioned,d={};if(s&&(o.unreadMessageCount=0,d.unreadMessageCount={val:0,time:Date.now()}),c&&(o.hasMentioned=!1,o.unreadMentionedCount=0,o.mentionedInfo=void 0,d.hasMentioned={val:!1,time:Date.now()},d.mentionedInfo={val:void 0,time:Date.now()}),this._store.set(e,n,o,r),i&&Object.keys(d).length!==0){var l=Object.assign(o,{conversationType:e,targetId:n,channelId:r,updatedItems:d});this._setUpdatedConversation(l),this._notifyConversationChanged()}},t.prototype.clearAllUnreadCount=function(){var e=this;this._store.getValue().forEach(function(n){n.unreadMessageCount&&(n.unreadMessageCount=0,e._store.set(n.conversationType,n.targetId,n,n.channelId))})},t.prototype.startPullConversationStatus=function(e){this._statusManager.pull(e)},t.prototype.setDraft=function(e,n,r,i){var o=e+"_"+n+"_"+i;this._draftMap[o]=r},t.prototype.getDraft=function(e,n,r){var i=e+"_"+n+"_"+r;return this._draftMap[i]},t.prototype.clearDraft=function(e,n,r){var i=e+"_"+n+"_"+r;delete this._draftMap[i]},t.prototype.addTagStatus=function(e,n,r,i){i===void 0&&(i="");var o=this._store.get(e,n,i).tags;o=Object.assign(o,r),this._store.set(e,n,{tags:o},i)},t.prototype.deleteTagStatus=function(e,n,r,i){i===void 0&&(i="");var o=this._store.get(e,n,i).tags;r.forEach(function(s){delete o[s]}),this._store.set(e,n,{tags:o},i)},t.prototype.getConversationListForTag=function(){return this._store.getValueForTag()},t.prototype.getBlockConversationList=function(){return this._store.getValue().filter(function(e){return e.notificationStatus===an.OPEN}).map(function(e){return{conversationType:e.conversationType,targetId:e.targetId,channelId:e.channelId}})},t.prototype.getTopConversationList=function(){return(this._store.getValue()||{}).filter(function(e){return e.isTop}).map(function(e){return{conversationType:e.conversationType,targetId:e.targetId,channelId:e.channelId}})},t.prototype.adaptOldStore=function(){this._store.adaptOldStore()},t.prototype.getUnreadMentionedCount=function(e,n,r){return e===void 0&&(e=""),this.get(n,r,e).unreadMentionedCount||0},t.prototype.getAllUnreadMentionedCount=function(){var e=this._store.getValue(),n=0;return e.forEach(function(r){var i=r.unreadMentionedCount;i=i||0,n+=Number(i)}),n},t}(),Gh=function(){function t(e,n,r,i){this._pullQueue=[],this._isPulling=!1,this._storageTagKey="tag-"+n+"-"+r,this._storagePullTimeKey="us-s-"+n+"-"+r,this._storage=Ti(e.runtime),this._engine=e,this._tagWatcherFunc=i}return t.prototype._updateTag=function(e){var n=e.tags,r={};n.forEach(function(i){r[i.tagId]={tagName:i.tagName,createdTime:i.createdTime}}),this._storage.set(this._storageTagKey,r),this._tagWatcherFunc()},t.prototype.addTag=function(e,n){var r=this._storage.get(this._storageTagKey)||{};e.forEach(function(i){var o,s=((o=r[i.tagId])===null||o===void 0?void 0:o.createdTime)||i.createdTime||0;r[i.tagId]={tagName:i.tagName,createdTime:s}}),this._storage.set(this._storageTagKey,r),this._storage.set(this._storagePullTimeKey,n)},t.prototype.deleteTag=function(e,n){var r=this._storage.get(this._storageTagKey)||{};e.forEach(function(i){delete r[i]}),this._storage.set(this._storageTagKey,r),this._storage.set(this._storagePullTimeKey,n)},t.prototype.getTagsInfo=function(){return this._storage.get(this._storageTagKey)||{}},t.prototype.getTags=function(){var e=this._storage.get(this._storageTagKey)||{},n=[];for(var r in e)n.push({tagId:r,tagName:e[r].tagName,createdTime:e[r].createdTime,conversationCount:0});return n.sort(function(i,o){return(i.createdTime||0)-(o.createdTime||0)})},t.prototype.getTagById=function(e){var n=this._storage.get(this._storageTagKey)||{};return n[e]?{tagId:e,tagName:n[e].tagName,createdTime:n[e].createdTime,conversationCount:0}:null},t.prototype._startPull=function(){return F(this,void 0,void 0,function(){var e,n,r,i,o,s,c,d;return H(this,function(l){switch(l.label){case 0:return this._isPulling||this._pullQueue.length===0?[2]:(this._isPulling=!0,e=this._pullQueue.splice(0,1)[0],[4,this._engine.pullUserSettings(e)]);case 1:return n=l.sent(),r=n.code,i=n.data,r!==M.SUCCESS||_e(i)?(this._isPulling=!1,this._startPull()):(s=(o=i).settings,c=o.version,d=s.Tag,_e(d)||this._updateTag(d),this._storage.set(this._storagePullTimeKey,c),this._isPulling=!1,this._startPull()),[2]}})})},t.prototype.pullUserSettings=function(e){var n=this._storage.get(this._storagePullTimeKey)||0;(e>n||e===0)&&(this._pullQueue.push(n),this._startPull())},t.prototype.getVersion=function(){return this._storage.get(this._storagePullTimeKey)||0},t}(),Yh=function(t){function e(n,r){var i=t.call(this,n,r)||this;return i._miniConnectUrl="",i._connectType=r.connectionType,i}return Oe(e,t),e.prototype._formatJSONPUrl=function(n,r,i,o){return n+"/"+(this._runtime.isSupportSocket()&&this._connectType==="websocket"?"navi":"cometnavi")+".js?appId="+i+"&token="+encodeURIComponent(r)+"&callBack="+o+"&v="+this._apiVersion+"&r="+Date.now()},e.prototype.getInfo=function(n,r,i){var o;return F(this,void 0,void 0,function(){var s;return H(this,function(c){return this._runtime.useNavi||(s=void 0,s=this._runtime.isSupportSocket()&&this._connectType==="websocket"?Yl.join(","):Wl.join(","),this._miniConnectUrl=((o=this._options.miniCMPProxy)===null||o===void 0?void 0:o.length)?this._options.miniCMPProxy.join(","):s||"",r=[]),[2,t.prototype.getInfo.call(this,n,r,i)]})})},e.prototype._reqNavi=function(n,r,i){return F(this,void 0,void 0,function(){var o,s,c,d,l,h,a,u,f;return H(this,function(p){switch(p.label){case 0:o="getServerEndpoint",s=0,c=n.length,p.label=1;case 1:return s "+d),[4,this._runtime.httpReq({url:d,timeout:1e4,dataType:"text"})]):[3,4];case 2:if((l=p.sent()).status!==200)return l.status===403?Q.error("request navi error: "+M.RC_CONN_USER_OR_PASSWD_ERROR):l.status===401&&Q.error("request navi error: "+M.RC_CONN_APP_BLOCKED_OR_DELETED),[3,3];try{return h=l.data.match(/{[\d\D]+}/),(a=h&&h[0]?h[0]:"").indexOf('{\\"code\\":')===0&&(a=JSON.parse('"'+a+'"')),f=JSON.parse(a),u=/^https/.test(d)?"https":"http",f.protocol=u,this._runtime.useNavi||(f.server="",f.backupServer=this._miniConnectUrl,f.logSwitch=0),[2,f]}catch(m){Q.error("parse navi err =>",m)}p.label=3;case 3:return s+=1,[3,1];case 4:return this._runtime.useNavi?[2,null]:[2,f={code:200,protocol:"https",server:"",voipCallInfo:"",kvStorage:0,openHttpDNS:!1,historyMsg:!1,chatroomMsg:!1,uploadServer:"https://upload.qiniup.com",bosAddr:"https://gz.bcebos.com",location:"",monitor:0,joinMChrm:!1,openMp:0,openUS:0,grpMsgLimit:0,isFormatted:0,gifSize:2048,logSwitch:0,logPolicy:"",compDays:0,msgAck:"",activeServer:"",qnAddr:"",extkitSwitch:0,alone:!1,voipServer:"",offlinelogserver:"",backupServer:this._miniConnectUrl}]}})})},e}(Uh),Wh=function(){function t(e){this._pullQueue=[],this._isPulling=!1,this._pullTime=0,this._engine=e}return t.prototype._startPull=function(){return F(this,void 0,void 0,function(){var e,n,r,i,o,s,c;return H(this,function(d){switch(d.label){case 0:return this._isPulling||this._pullQueue.length===0?[2]:(this._isPulling=!0,e=this._pullQueue.splice(0,1)[0],n=e.roomId,r=e.timestamp,(i=this._pullTime)>r?(this._isPulling=!1,this._startPull(),[2]):[4,this._engine.pullRTCRoomEntry(n,i)]);case 1:return o=d.sent(),s=o.code,c=o.data,s===M.SUCCESS?(this._isPulling=!1,this._pullTime=c.syncTime||0,this._startPull()):this._startPull(),[2]}})})},t.prototype.pullEntry=function(e,n){this._pullQueue.push({roomId:e,timestamp:n}),this._startPull()},t.prototype.reset=function(){this._pullTime=0,this._isPulling=!1},t}(),no=function(t,e){return["send_msg",t,e].join("_")},Jh=function(){function t(e,n){this._runtime=e,this._appkey=n,this._sendMessageMap={},this._userId=""}return t.prototype.init=function(e){this._userId=e;var n=no(this._appkey,e);this._sendMessageMap=this._getLocalInfo(n)},t.prototype._getLocalInfo=function(e){var n=this._runtime.localStorage.getItem(e);try{return n?JSON.parse(n):{}}catch{return{}}},t.prototype.setMessage=function(e,n){this._sendMessageMap[e]=n;var r=no(this._appkey,this._userId),i=this._getLocalInfo(r);i[e]=n,this._runtime.localStorage.setItem(r,JSON.stringify(i))},t.prototype.getSendMessageMap=function(){return this._sendMessageMap},t.prototype.removeByUID=function(e){delete this._sendMessageMap[e]},t.prototype.removeByTimestamp=function(e){var n=no(this._appkey,this._userId),r=this._getLocalInfo(n);Object.keys(r).forEach(function(i){r[i] signal.messageId: "+n.messageId),this._pullMsg(n);break;case V.s_msg:this._receiveMsg(n);break;case V.s_cmd:this._receiveStateNotify(n);break;case V.s_us:this._receiveSettingNotify(n);break;case V.rtc_ntf:this._receiveRtcKv(n)}else Q.error("unknown topic:",o)}},e.prototype._receiveStateNotify=function(n){var r,i=(r=this._channel)===null||r===void 0?void 0:r.codec.decodeByPBName(n.data,Qr),o=i.time,s=i.type,c=i.chrmId;switch(s){case 2:this._chrmEntryHandler.pullEntry(c,o);break;case 3:this._conversationManager.startPullConversationStatus(o);break;case 4:this._chrmEntryHandler.reset(c),this._watcher.chatroom({chatroomDestroyed:n.targetId})}},e.prototype._receiveSettingNotify=function(n){var r,i=((r=this._channel)===null||r===void 0?void 0:r.codec.decodeByPBName(n.data,Ai)).version;this._userSettingManager.pullUserSettings(i)},e.prototype._receiveRtcKv=function(n){var r,i=(r=this._channel)===null||r===void 0?void 0:r.codec.decodeByPBName(n.data,ta),o=i.time,s=i.type,c=i.roomId;switch(s){case 1:this._rtcKVManager.pullEntry(c,o)}},e.prototype._receiveMessageExpansion=function(n){var r=n.content,i=r.put,o=r.del,s=r.mid;i&&this._watcher.expansion({updatedExpansion:{messageUId:s,expansion:i}}),o&&this._watcher.expansion({deletedExpansion:{messageUId:s,deletedKeys:o}})},e.prototype._receiveSyncMsg=function(n,r){var i;if(zh.includes(n.topic)){var o=(i=this._channel)===null||i===void 0?void 0:i.codec.decodeByPBName(n.data,er,{currentUserId:this.currentUserId,signal:n});o=this._handleMsgProperties(o),r&&(o.sentTime=r.timestamp,o.messageUId=r.messageUId),this._pullingMsg?this._pullQueue.push((r==null?void 0:r.timestamp)||o.sentTime):(r&&this._sendMessageStore.setMessage(r.messageUId,r.timestamp),o.messageType!==Ge.EXPANSION_NOTIFY?(o.messageType===Ge.SYNC_READ_STATUS&&this._conversationManager.clearUnreadCount(o.conversationType,o.targetId,o.channelId),this._conversationManager.setConversationCacheByMessage(o,!0),this._watcher.batchMessage([o])):this._receiveMessageExpansion(o))}},e.prototype._pullMsg=function(n){if(this._channel){var r=this._channel.codec.decodeByPBName(n.data,Qr),i=r.type,o=r.chrmId,s=r.time;if(Q.info("s_ntf -> type: "+i+", chrmId: "+o+", time: "+s),i===2){var c=this._chrmsQueue[o];if(!c)return;c.queue.push(s),this._pullChrmMsg(o)}else this._pullQueue.push(s),this._syncMsg()}},e.prototype._startSyncInterval=function(){var n=this;this._stopSyncInterval(),this._intervalTimer=setInterval(function(){Date.now()-n._latestSyncTimestamp>=18e4&&n._syncMsg()},3e4),this._latestSyncTimestamp=Date.now(),this._syncMsg()},e.prototype._stopSyncInterval=function(){this._intervalTimer!==-1&&(clearInterval(this._intervalTimer),this._intervalTimer=-1)},e.prototype._syncMsg=function(){return F(this,void 0,void 0,function(){var n,r,i,o,s,c,d,l,h,a,u,f,p,m,_=this;return H(this,function(v){switch(v.label){case 0:return this._pullingMsg?[2]:this._channel?(this._pullingMsg=!0,n=this._letterbox.getOutboxTime(this.currentUserId),r=this._letterbox.getInboxTime(this.currentUserId),Q.info("pullMsg -> sendboxTime: "+n+", inboxTime: "+r),i=this._channel.codec.encodeSyncMsg({sendboxTime:n,inboxTime:r}),o=new se(V[V.pullMsg],i,this.currentUserId),[4,this._channel.send(o,tr,{connectedTime:this._channel.connectedTime,currentUserId:this.currentUserId})]):(this._pullingMsg=!1,[2]);case 1:return s=v.sent(),c=s.code,d=s.data,this._latestSyncTimestamp=Date.now(),c===M.SUCCESS&&d?(l=d.list,h=d.finished,a=d.syncTime,Q.info("pullMsg success -> syncTime: "+a+", finished: "+h),u=0,f=[],l.forEach(function(y){if(y.messageDirection===ct.SEND&&(u=Math.max(y.sentTime,u),_._sendMessageStore.getSendMessageMap()[y.messageUId]))return void _._sendMessageStore.removeByUID(y.messageUId);if(y.messageType!==Ge.EXPANSION_NOTIFY){if(y.messageType===Ge.SYNC_READ_STATUS){if(y.senderUserId!==_.currentUserId)return;_._conversationManager.clearUnreadCount(y.conversationType,y.targetId,y.channelId)}var C=_._handleMsgProperties(y);_._conversationManager.setConversationCacheByMessage(C,!0),f.push(C)}else _._receiveMessageExpansion(y)}),this._watcher.batchMessage(f),this._letterbox.setInboxTime(a,this.currentUserId),this._letterbox.setOutboxTime(u,this.currentUserId),this._sendMessageStore.removeByTimestamp(u),this._pullingMsg=!1,p=this._pullQueue.filter(function(y){return y>a}),this._pullQueue.length=0,(m=this._pullQueue).push.apply(m,p),h&&!this._pullOfflineFinished&&(this._pullOfflineFinished=!0,this._watcher.pullFinished()),(!h||p.length>0)&&this._syncMsg(),[2]):(Q.warn("pullMsg failed -> code:",c,", data: ",d),this._pullingMsg=!1,[2])}})})},e.prototype._receiveMsg=function(n){if(this._channel&&!this._pullingMsg)if(this._pullQueue.length>0)this._syncMsg();else{var r=this._channel.codec.decodeByPBName(n.data,Ii,{currentUserId:this.currentUserId,connectedTime:this._channel.connectedTime});(r=this._handleMsgProperties(r)).senderUserId===this.currentUserId&&this._sendMessageStore.setMessage(r.messageUId,r.sentTime),r.isStatusMessage||r.senderUserId===this.currentUserId||this._letterbox.setInboxTime(r.sentTime,this.currentUserId),r.messageType!==Ge.EXPANSION_NOTIFY?r.messageType===Ge.SYNC_READ_STATUS&&r.senderUserId!==this.currentUserId||(this._conversationManager.setConversationCacheByMessage(r,!0),this._watcher.batchMessage([r])):this._receiveMessageExpansion(r)}},e.prototype._handleMsgProperties=function(n,r){r===void 0&&(r=!1);var i,o=n.messageType,s=n.isCounted,c=n.isPersited,d=n.isStatusMessage,l=o in La,h=o in this._customMessageType;if(i=l?La[o]:h?this._customMessageType[o]:{isCounted:!Ua(s)&&s,isPersited:!Ua(c)&&c},Object.assign(n,{isCounted:i.isCounted,isPersited:i.isPersited,isStatusMessage:Jl.includes(o)}),r&&(n.isStatusMessage=d),!r){var a=n.content.user;if(a){var u=a.portrait,f=a.portraitUri,p=u||f;p&&(a.portrait=a.portraitUri=p)}}return n},e.prototype.getHistoryMessage=function(n,r,i,o,s,c){return c===void 0&&(c=""),F(this,void 0,void 0,function(){var d,l,h,a,u,f,p,m,_;return H(this,function(v){switch(v.label){case 0:return l=(d=this).currentUserId,h=d._channel,a=Ah[n]||Au,u=o===1&&i===0,h?(f=h.codec.encodeGetHistoryMsg(r,{timestamp:i,count:u?2:o,order:s,channelId:c}),[4,h.send(new se(a,f,l),nr,{currentUserId:l,connectedTime:h.connectedTime,conversation:{targetId:r}})]):[3,2];case 1:return p=v.sent(),(m=p.code)!==M.SUCCESS?[2,{code:m}]:(_=p.data,u&&_.list.length===2&&(_.hasMore=!0,s===0?_.list.shift():_.list.pop()),[2,{code:m,data:{list:_.list,hasMore:_.hasMore}}]);case 2:return[2,{code:M.RC_NET_CHANNEL_INVALID}]}})})},e.prototype.reportSDKInfo=function(n){var r=this.currentUserId,i=this._channel;if(i){Q.debug("reportSDKInfo ->",n);var o=i.codec.encodeReportSDKInfo(JSON.stringify(n)),s=new se(V[V.reportsdk],o,r);i.send(s).then(function(c){var d=c.code;d!==M.SUCCESS&&Q.warn("reportSDKInfo failed -> code: "+d)})}},e.prototype.deleteRemoteMessage=function(n,r,i,o){return F(this,void 0,void 0,function(){var s,c,d,l,h,a,u;return H(this,function(f){switch(f.label){case 0:return c=(s=this).currentUserId,(d=s._channel)?(l=d.codec.encodeDeleteMessages(n,r,i,o),h=new se(mh,l,c),[4,d.send(h)]):[3,2];case 1:return a=f.sent(),u=a.code,M.SUCCESS,[2,u];case 2:return[2,M.RC_NET_CHANNEL_INVALID]}})})},e.prototype.deleteRemoteMessageByTimestamp=function(n,r,i,o){return F(this,void 0,void 0,function(){var s,c,d,l,h,a,u,f;return H(this,function(p){switch(p.label){case 0:return c=(s=this).currentUserId,(d=s._channel)?(l=d.codec.encodeClearMessages(r,i,o),h=Mh[n],a=new se(h,l,c),[4,d.send(a)]):[3,2];case 1:return u=p.sent(),f=u.code,M.SUCCESS,[2,f];case 2:return[2,M.RC_NET_CHANNEL_INVALID]}})})},e.prototype.getConversationList=function(n,r,i,o,s){return n===void 0&&(n=300),F(this,void 0,void 0,function(){var c,d,l,h,a,u,f,p,m=this;return H(this,function(_){switch(_.label){case 0:return d=(c=this).currentUserId,l=c._channel,r=r||oe.PRIVATE,l?(h=l.codec.encodeOldConversationList({count:n,type:r,startTime:i,order:o}),a=new se(Ja,h,d),[4,l.send(a,rr,{currentUserId:d,connectedTime:l.connectedTime,afterDecode:function(v){var y=v.conversationType,C=v.targetId,w=v.channelId,P=m._conversationManager.get(y,C,w);return Object.assign(v,P),v}})]):[3,2];case 1:return u=_.sent(),f=u.code,p=u.data,f!==M.SUCCESS?[2,{code:f}]:[2,{code:f,data:p}];case 2:return[2,{code:M.RC_NET_CHANNEL_INVALID}]}})})},e.prototype.removeConversation=function(n,r,i){return F(this,void 0,void 0,function(){var o,s,c,d,l;return H(this,function(h){switch(h.label){case 0:return(o=this._channel)?(s=o.codec.encodeRemoveOldConversationList({conversationType:n,channelId:i,targetId:r}),c=new se(Sh,s,r),[4,o.send(c)]):[3,2];case 1:return d=h.sent(),Q.info("RemoveConversation =>",d),l=d.code,M.SUCCESS,[2,l];case 2:return[2,M.RC_NET_CHANNEL_INVALID]}})})},e.prototype.getConversation=function(n,r,i){return F(this,void 0,void 0,function(){var o,s,c,d,l,h;return H(this,function(a){switch(a.label){case 0:return(o=this._conversationManager.get(n,r,i))?[4,this.getHistoryMessage(n,r,0,1,0)]:[2,{code:M.CONVER_GET_ERROR}];case 1:return s=a.sent(),c=s.code,d=s.data,c!==M.SUCCESS?[2,{code:M.CONVER_GET_ERROR}]:(l=(d==null?void 0:d.list[0])||null,h={conversationType:n,targetId:r,channelId:i,unreadMessageCount:o.unreadMessageCount||0,latestMessage:l,notificationStatus:o.notificationStatus||an.CLOSE,isTop:o.isTop||!1,lastUnreadTime:o.lastUnreadTime||0,unreadMentionedCount:o.unreadMentionedCount||0},[2,{code:M.SUCCESS,data:h}])}})})},e.prototype.getAllConversationUnreadCount=function(n,r,i){var o=this._conversationManager.getAllUnreadCount(n,r,i);return Promise.resolve({code:M.SUCCESS,data:o})},e.prototype.getConversationUnreadCount=function(n,r,i){var o=this._conversationManager.getUnreadCount(n,r,i);return Promise.resolve({code:M.SUCCESS,data:o})},e.prototype.clearConversationUnreadCount=function(n,r,i){return this._conversationManager.clearUnreadCount(n,r,i,!1),Promise.resolve(M.SUCCESS)},e.prototype.clearAllUnreadCount=function(){return this._conversationManager.clearAllUnreadCount(),Promise.resolve(M.SUCCESS)},e.prototype.getFirstUnreadMessage=function(n,r){throw new Error("Method not implemented.")},e.prototype.saveConversationMessageDraft=function(n,r,i,o){return this._conversationManager.setDraft(n,r,i,o),Promise.resolve(M.SUCCESS)},e.prototype.getConversationMessageDraft=function(n,r,i){var o=this._conversationManager.getDraft(n,r,i);return Promise.resolve({code:M.SUCCESS,data:o})},e.prototype.clearConversationMessageDraft=function(n,r,i){return this._conversationManager.clearDraft(n,r,i),Promise.resolve(M.SUCCESS)},e.prototype.pullConversationStatus=function(n){return F(this,void 0,void 0,function(){var r,i,o,s,c,d,l,h;return H(this,function(a){switch(a.label){case 0:return i=(r=this)._channel,o=r.currentUserId,i?(s=i.codec.encodeGetConversationStatus(n),c=new se(V[V.pullSeAtts],s,o),[4,i.send(c,Mi)]):[3,2];case 1:return d=a.sent(),l=d.code,h=d.data,l!==M.SUCCESS?[2,{code:l}]:[2,{code:l,data:h}];case 2:return[2,{code:M.RC_NET_CHANNEL_INVALID}]}})})},e.prototype.batchSetConversationStatus=function(n){return F(this,void 0,void 0,function(){var r,i,o,s,c,d,l,h,a,u=this;return H(this,function(f){switch(f.label){case 0:return i=(r=this).currentUserId,(o=r._channel)?(s=o.codec.encodeSetConversationStatus(n),c=new se(Ih,s,i),[4,o.send(c,zs)]):[3,2];case 1:return d=f.sent(),l=d.code,h=d.data,l===M.SUCCESS?(a=h,n.forEach(function(p){u._conversationManager.addStatus(Ee(Ee({},p),{updatedTime:a.version}),!0)}),[2,l]):[2,l];case 2:return[2,M.RC_NET_CHANNEL_INVALID]}})})},e.prototype._joinChrm=function(n,r,i){return F(this,void 0,void 0,function(){var o,s,c,d,l,h,a;return H(this,function(u){switch(u.label){case 0:return(o=this._channel)?(s=o.codec.encodeJoinOrQuitChatRoom(),c=new se(i?vh:_h,s,n),[4,o.send(c,Ns)]):[2,M.RC_NET_CHANNEL_INVALID];case 1:return d=u.sent(),l=d.code,h=d.data,l===M.SUCCESS&&(a=h.joinTime,this._chrmsQueue[n]||(this._chrmsQueue[n]={pulling:!1,queue:[],timestamp:0}),this._pullChrmMsg(n,r,a),this._naviInfo.kvStorage&&this._chrmEntryHandler.pullEntry(n,0),this._joinedChrmManager.set(n,r)),[2,l]}})})},e.prototype._rejoinChrm=function(){return F(this,void 0,void 0,function(){var n,r,i,o,s,c;return H(this,function(d){switch(d.label){case 0:for(i in n=this._joinedChrmManager.get(),r=[],n)r.push(i);o=0,d.label=1;case 1:return op}),_=[],f.forEach(function(y){y.sentTime0)&&this._pullChrmMsg(n),[2]):(Q.warn("pull chatroom msg failed, code:",a,", data:",u),[2])}})})},e.prototype.joinChatroom=function(n,r){return F(this,void 0,void 0,function(){return H(this,function(i){return[2,this._joinChrm(n,r,!1)]})})},e.prototype.joinExistChatroom=function(n,r){return F(this,void 0,void 0,function(){return H(this,function(i){return[2,this._joinChrm(n,r,!0)]})})},e.prototype.quitChatroom=function(n){return F(this,void 0,void 0,function(){var r,i,o,s,c;return H(this,function(d){switch(d.label){case 0:return(r=this._channel)?(i=r.codec.encodeJoinOrQuitChatRoom(),o=new se(yh,i,n),[4,r.send(o)]):[2,M.RC_NET_CHANNEL_INVALID];case 1:return s=d.sent(),(c=s.code)===M.SUCCESS&&(delete this._chrmsQueue[n],this._chrmEntryHandler.reset(n),this._joinedChrmManager.remove(n)),[2,c]}})})},e.prototype.getChatroomInfo=function(n,r,i){return F(this,void 0,void 0,function(){var o,s,c,d,l,h;return H(this,function(a){switch(a.label){case 0:return(o=this._channel)?(s=o.codec.encodeGetChatRoomInfo(r,i),c=new se(V[V.queryChrmI],s,n),[4,o.send(c,bi)]):[2,{code:M.RC_NET_CHANNEL_INVALID}];case 1:return d=a.sent(),l=d.code,h=d.data,l!==M.SUCCESS?[2,{code:l}]:[2,{code:l,data:h}]}})})},e.prototype.getChatroomHistoryMessages=function(n,r,i,o){return F(this,void 0,void 0,function(){var s,c,d,l,h,a;return H(this,function(u){switch(u.label){case 0:return(s=this._channel)?(c=s.codec.encodeGetHistoryMsg(n,{timestamp:r,count:i,order:o}),d=new se(Mu,c,n),[4,s.send(d,nr,{conversation:{targetId:n}})]):[2,{code:M.RC_NET_CHANNEL_INVALID}];case 1:return l=u.sent(),h=l.code,a=l.data,h!==M.SUCCESS?[2,{code:h}]:[2,{code:h,data:{list:a.list,hasMore:a.hasMore}}]}})})},e.prototype._modifyChatroomKV=function(n,r){return F(this,void 0,void 0,function(){var i,o,s,c,d,l,h,a;return H(this,function(u){switch(u.label){case 0:return o=(i=this)._channel,s=i.currentUserId,o?(c=o.codec.encodeModifyChatRoomKV(n,r,s),d=r.type===Ze.UPDATE?Ch:Eh,l=new se(d,c,n),[4,o.send(l)]):[2,M.RC_NET_CHANNEL_INVALID];case 1:return h=u.sent(),(a=h.code)===M.SUCCESS?(this._chrmEntryHandler.setLocal(n,{kvEntries:[r],syncTime:new Date().getTime()},s),[2,a]):[2,a]}})})},e.prototype._modifyChatroomKVS=function(n,r){return F(this,void 0,void 0,function(){var i,o,s,c,d,l,h,a,u,f,p,m;return H(this,function(_){switch(_.label){case 0:return o=(i=this)._channel,s=i.currentUserId,o?(c=o.codec.encodeModifyChatRoomKVS(n,r,s),d=r.type===Ze.UPDATE?Rh:Th,l=new se(d,c,n),[4,o.send(l,Gs)]):[2,{code:M.RC_NET_CHANNEL_INVALID}];case 1:return h=_.sent(),a=h.code,[M.SUCCESS,M.CHATROOM_KV_STORE_NOT_ALL_SUCCESS].indexOf(a)!==-1&&(f=[],delete(p=Object.assign({},r)).entries,r.entries.forEach(function(v){f.push(Object.assign({},v,p))}),a===M.CHATROOM_KV_STORE_NOT_ALL_SUCCESS&&(m=h.data,Q.warn("\u8BBE\u7F6E\u5931\u8D25\u7684\u5C5E\u6027\uFF1A",m.errorKeys),u=m.errorKeys,m&&Array.isArray(m.errorKeys)&&m.errorKeys.forEach(function(v){var y=f.findIndex(function(C){return v.key===C.key});y!==-1&&f.splice(y,1)})),Q.warn("\u8BBE\u7F6E\u6210\u529F\u7684\u5C5E\u6027\uFF1A",f),this._chrmEntryHandler.setLocal(n,{kvEntries:f,syncTime:new Date().getTime()},s)),[2,{code:a,data:u}]}})})},e.prototype.setChatroomEntry=function(n,r){return F(this,void 0,void 0,function(){return H(this,function(i){return r.type=Ze.UPDATE,r.userId=r.userId||this.currentUserId,[2,this._modifyChatroomKV(n,r)]})})},e.prototype.setChatroomEntries=function(n,r){return F(this,void 0,void 0,function(){return H(this,function(i){return r.type=Ze.UPDATE,r.userId=r.userId||this.currentUserId,[2,this._modifyChatroomKVS(n,r)]})})},e.prototype.forceSetChatroomEntry=function(n,r){return F(this,void 0,void 0,function(){return H(this,function(i){return r.type=Ze.UPDATE,r.isOverwrite=!0,r.userId=r.userId||this.currentUserId,[2,this._modifyChatroomKV(n,r)]})})},e.prototype.removeChatroomEntry=function(n,r){return F(this,void 0,void 0,function(){return H(this,function(i){return r.type=Ze.DELETE,r.userId=r.userId||this.currentUserId,[2,this._modifyChatroomKV(n,r)]})})},e.prototype.removeChatroomEntries=function(n,r){return F(this,void 0,void 0,function(){return H(this,function(i){return r.type=Ze.DELETE,r.userId=r.userId||this.currentUserId,[2,this._modifyChatroomKVS(n,r)]})})},e.prototype.forceRemoveChatroomEntry=function(n,r){return F(this,void 0,void 0,function(){return H(this,function(i){return r.type=Ze.DELETE,r.isOverwrite=!0,r.userId=r.userId||this.currentUserId,[2,this._modifyChatroomKV(n,r)]})})},e.prototype.getChatroomEntry=function(n,r){return F(this,void 0,void 0,function(){var i,o,s,c,d,l,h;return H(this,function(a){switch(a.label){case 0:return(i=this._chrmEntryHandler.getValue(n,r))?[2,Promise.resolve({code:M.SUCCESS,data:i})]:[3,1];case 1:return(o=this._channel)?(s=o.codec.encodePullChatRoomKV(0),c=new se(V[V.pullKV],s,n),[4,o.send(c,ln)]):[2,Promise.reject({code:M.RC_NET_CHANNEL_INVALID})];case 2:return d=a.sent(),(l=d.data||{})&&l.kvEntries&&l.kvEntries.length&&(h=l.kvEntries.find(function(u){return u.key===r}))!==void 0?[2,Promise.resolve({code:M.SUCCESS,data:h==null?void 0:h.value})]:[2,Promise.resolve({code:M.CHATROOM_KEY_NOT_EXIST})]}})})},e.prototype.getAllChatroomEntry=function(n){return F(this,void 0,void 0,function(){var r,i,o,s,c,d,l;return H(this,function(h){switch(h.label){case 0:return(r=this._chrmEntryHandler.getAll(n))&&Object.keys(r).length?[2,Promise.resolve({code:M.SUCCESS,data:r})]:[3,1];case 1:return(i=this._channel)?(o={},s=i.codec.encodePullChatRoomKV(0),c=new se(V[V.pullKV],s,n),[4,i.send(c,ln)]):[2,Promise.reject({code:M.RC_NET_CHANNEL_INVALID})];case 2:return d=h.sent(),(l=d.data||{})&&l.kvEntries&&l.kvEntries.length&&l.kvEntries.forEach(function(a){a.key&&(o[a.key]=a.value||"")}),[2,Promise.resolve({code:M.SUCCESS,data:o})]}})})},e.prototype.pullChatroomEntry=function(n,r){return F(this,void 0,void 0,function(){var i,o,s,c,d,l,h,a,u,f;return H(this,function(p){switch(p.label){case 0:return o=(i=this)._channel,s=i.currentUserId,o?(c=o.codec.encodePullChatRoomKV(r),d=new se(V[V.pullKV],c,n),[4,o.send(d,ln)]):[2,{code:M.RC_NET_CHANNEL_INVALID}];case 1:return l=p.sent(),h=l.code,a=l.data,h===M.SUCCESS?(Q.info("Pull success ChrmKV, "+JSON.stringify(l)),this._chrmEntryHandler.setLocal(n,a,s),Q.info("Save into cache success!"),u=a.kvEntries,f=[],u.length>0&&(u.forEach(function(m){var _=m.key,v=m.value,y=m.type,C=m.timestamp;f.push({key:_,value:v,type:y,timestamp:C,chatroomId:n})}),this._watcher.chatroom({updatedEntries:f})),[2,{code:h,data:a}]):[2,{code:h}]}})})},e.prototype.sendMessage=function(n,r,i){return F(this,void 0,void 0,function(){var o,s,c,d,l,h,a,u,f,p;return H(this,function(m){switch(m.label){case 0:return this._channel?(i=function(_,v){return _.messageType==="RC:SRSMsg"&&Object.assign(_,{directionalUserIdList:[v]}),_}(i,this.currentUserId),i=this._handleMsgProperties(i,!0),o=!![oe.PRIVATE,oe.GROUP].includes(n)&&i.isStatusMessage,s=o?function(_){var v;return(v={},v[oe.PRIVATE]=V.ppMsgS,v[oe.GROUP]=V.pgMsgS,v)[_]}(n):function(_){var v;return(v={},v[oe.PRIVATE]=V.ppMsgP,v[oe.GROUP]=V.pgMsgP,v[oe.CHATROOM]=V.chatMsg,v[oe.CUSTOMER_SERVICE]=V.pcMsgP,v[oe.RTC_ROOM]=V.prMsgS,v)[_]}(n)||V.ppMsgP,o&&(i.isPersited=!1,i.isCounted=!1),c=this._channel.codec.encodeUpMsg({conversationType:n,targetId:r},i),(d=new Dn(V[s],c,r)).setHeaderQos(Ot.AT_LEAST_ONCE),o?(this._channel.sendOnly(d),[2,{code:M.SUCCESS,data:ro(n,r,Ee({},i),"",0,this.currentUserId)}]):(l=Date.now()-this._localConnectedTime+this._connectedTime,h=ro(n,r,Ee({},i),"",l,this.currentUserId),[4,this._channel.send(d)])):[2,{code:M.RC_NET_CHANNEL_INVALID}];case 1:return a=m.sent(),u=a.code,f=a.data,u!==M.SUCCESS?[2,{code:u,data:h}]:(p=f,this._sendMessageStore.setMessage(p.messageUId,p.timestamp),h.sentTime=p.timestamp,h.messageUId=p.messageUId,this._conversationManager.setConversationCacheByMessage(h,!0),[2,{code:M.SUCCESS,data:h}])}})})},e.prototype.recallMsg=function(n,r,i,o,s){var c;return F(this,void 0,void 0,function(){var d,l,h,a,u,f,p,m,_,v;return H(this,function(y){switch(y.label){case 0:return this._channel?(d=s.user,l={content:{conversationType:n,targetId:r,messageUId:i,sentTime:o,user:d},messageType:"RC:RcCmd",disableNotification:s==null?void 0:s.disableNotification,pushConfig:s==null?void 0:s.pushConfig,pushContent:((c=s.pushConfig)===null||c===void 0?void 0:c.pushContent)||s.pushContent||"",channelId:s.channelId},h=V[V.recallMsg],a=this._channel.codec.encodeUpMsg({conversationType:n,targetId:r},l),(u=new Dn(h,a,this.currentUserId)).setHeaderQos(Ot.AT_LEAST_ONCE),[4,this._channel.send(u)]):[2,{code:M.RC_NET_CHANNEL_INVALID}];case 1:return f=y.sent(),p=f.code,m=f.data,p!==M.SUCCESS?[2,{code:p}]:(_=m,this._sendMessageStore.setMessage(_.messageUId,_.timestamp),v=ro(n,r,Ee(Ee({},l),{isPersited:!0}),_.messageUId,_.timestamp,this.currentUserId),this._conversationManager.setConversationCacheByMessage(v,!0),[2,{code:M.SUCCESS,data:v}])}})})},e.prototype.sendReadReceiptMessage=function(n,r,i){return F(this,void 0,void 0,function(){var o,s;return H(this,function(c){switch(c.label){case 0:return this._channel?(o=this._channel.codec.encodeReadReceipt(r,i),s=new se(V[V.rrMsg],o,n),[4,this._channel.send(s)]):[2,{code:M.RC_NET_CHANNEL_INVALID}];case 1:return[2,c.sent()]}})})},e.prototype.getMessageReader=function(n,r,i){return F(this,void 0,void 0,function(){var o,s;return H(this,function(c){switch(c.label){case 0:return this._channel?(o=this._channel.codec.encodeMessageReader(r,i),s=new se(V[V.rrList],o,n),[4,this._channel.send(s,Pi)]):[2,{code:M.RC_NET_CHANNEL_INVALID}];case 1:return[2,c.sent()]}})})},e.prototype.pullUserSettings=function(n){return F(this,void 0,void 0,function(){var r,i;return H(this,function(o){return this._channel?(r=this._channel.codec.encodePullUserSetting(n),i=new se(V[V.pullUS],r,this.currentUserId),[2,this._channel.send(i,Ni)]):[2,{code:M.RC_NET_CHANNEL_INVALID}]})})},e.prototype.getFileToken=function(n,r,i,o){return F(this,void 0,void 0,function(){var s,c,d,l,h,a;return H(this,function(u){switch(u.label){case 0:return this._channel?(s=o&&o!=="uploads"?r||"":nh(n,r),c=this._channel.codec.encodeGetFileToken(n,s,i||"",o||""),d=new se(V[V.qnTkn],c,this.currentUserId),[4,this._channel.send(d,Vs)]):[2,{code:M.RC_NET_CHANNEL_INVALID}];case 1:return l=u.sent(),h=l.code,a=l.data,a=Object.assign(a,{fileName:s}),h===M.SUCCESS?[2,{code:h,data:a}]:[2,{code:h}]}})})},e.prototype.getFileUrl=function(n,r,i,o){return F(this,void 0,void 0,function(){var s,c,d,l,h,a,u,f,p;return H(this,function(m){switch(m.label){case 0:return this._channel?(s="",c="",d="",r===ze.QINIU?(c=Fs,d=$s):(c=Hs,d=js),s=r===ze.QINIU?V[V.qnUrl]:r===ze.AWS?V[V.s3Url]:r===ze.STC?V[V.stcUrl]:V[V.aliUrl],l=this._channel.codec.encodeGetFileUrl(c,n,i,o),h=new se(s,l,this.currentUserId),[4,this._channel.send(h,d)]):[2,{code:M.RC_NET_CHANNEL_INVALID}];case 1:return a=m.sent(),u=a.code,f=a.data,p=f,u===M.SUCCESS?[2,{code:u,data:p}]:[2,{code:u}]}})})},e.prototype.disconnect=function(){this._reconnectTimer!==-1&&(clearTimeout(this._reconnectTimer),this._reconnectTimer=-1),this._channel&&(this._channel.close(),this._channel=void 0),this._pullQueue.length=0,this._stopSyncInterval()},e.prototype.destroy=function(){throw new Error("JSEngine's method not implemented.")},e.prototype.registerMessageType=function(n,r,i,o){this._customMessageType[n]={isPersited:r,isCounted:i}},e.prototype.getServerTime=function(){return Date.now()-this._localConnectedTime+this._connectedTime},e.prototype.getCurrentUserId=function(){return this.currentUserId},e.prototype.createTag=function(n){return F(this,void 0,void 0,function(){var r,i,o,s,c,d,l;return H(this,function(h){switch(h.label){case 0:return this._channel?(r=this._userSettingManager.getVersion(),i=this._channel.codec.encodeCreateTag([n],r),o=new se(V[V.addSeTag],i,this.currentUserId),[4,this._channel.send(o,hn)]):[2,{code:M.RC_NET_CHANNEL_INVALID}];case 1:return s=h.sent(),c=s.code,d=s.data,c!==M.SUCCESS?[2,{code:c}]:(l=d.version,this._userSettingManager.addTag([Ee(Ee({},n),{createdTime:l})],l),[2,{code:M.SUCCESS,data:d}])}})})},e.prototype.removeTag=function(n){return F(this,void 0,void 0,function(){var r,i,o,s,c,d,l;return H(this,function(h){switch(h.label){case 0:return this._channel?(r=this._userSettingManager.getVersion(),i=this._channel.codec.encodeRemoveTag([n],r),o=new se(V[V.delSeTag],i,this.currentUserId),[4,this._channel.send(o,hn)]):[2,{code:M.RC_NET_CHANNEL_INVALID}];case 1:return s=h.sent(),c=s.code,d=s.data,c!==M.SUCCESS?[2,{code:c}]:(l=d.version,this._userSettingManager.deleteTag([n],l),[2,{code:M.SUCCESS}])}})})},e.prototype.updateTag=function(n){return F(this,void 0,void 0,function(){var r,i,o,s,c,d,l;return H(this,function(h){switch(h.label){case 0:return this._channel?(r=this._userSettingManager.getVersion(),i=this._channel.codec.encodeCreateTag([n],r),o=new se(V[V.addSeTag],i,this.currentUserId),[4,this._channel.send(o,hn)]):[2,{code:M.RC_NET_CHANNEL_INVALID}];case 1:return s=h.sent(),c=s.code,d=s.data,c!==M.SUCCESS?[2,{code:c}]:(l=d.version,this._userSettingManager.addTag([n],l),[2,{code:M.SUCCESS,data:d}])}})})},e.prototype.getTagList=function(){return F(this,void 0,void 0,function(){var n,r;return H(this,function(i){return n=this._userSettingManager.getTags(),r=this._conversationManager.getConversationListForTag(),n.forEach(function(o){o.conversationCount=r[o.tagId]?r[o.tagId].length:0}),[2,{code:M.SUCCESS,data:n}]})})},e.prototype.addTagForConversations=function(n,r){return F(this,void 0,void 0,function(){var i,o,s,c,d=this;return H(this,function(l){switch(l.label){case 0:return this._channel?this._userSettingManager.getTagById(n)?(i=this._channel.codec.encodeUpdateConversationTag([{tagId:n}],r),o=new se(V[V.addTag],i,this.currentUserId),[4,this._channel.send(o)]):[2,{code:M.TAG_NOT_EXIST}]:[2,{code:M.RC_NET_CHANNEL_INVALID}];case 1:return(s=l.sent().code)!==M.SUCCESS?[2,{code:s}]:((c={})[n]={},r.forEach(function(h){d._conversationManager.addTagStatus(h.conversationType,h.targetId,c,h.channelId)}),[2,{code:M.SUCCESS}])}})})},e.prototype.removeTagForConversations=function(n,r){return F(this,void 0,void 0,function(){var i,o,s,c=this;return H(this,function(d){switch(d.label){case 0:return this._channel?(i=this._channel.codec.encodeUpdateConversationTag([{tagId:n}],r),o=new se(V[V.delTag],i,this.currentUserId),[4,this._channel.send(o)]):[2,{code:M.RC_NET_CHANNEL_INVALID}];case 1:return(s=d.sent().code)!==M.SUCCESS?[2,{code:s}]:(r.forEach(function(l){c._conversationManager.deleteTagStatus(l.conversationType,l.targetId,[n],l.channelId)}),[2,{code:M.SUCCESS}])}})})},e.prototype.removeTagsForConversation=function(n,r){return F(this,void 0,void 0,function(){var i,o,s,c,d,l,h;return H(this,function(a){switch(a.label){case 0:return this._channel?(i=n.conversationType,o=n.targetId,s=n.channelId,c=r.map(function(u){return{tagId:u}}),d=this._channel.codec.encodeUpdateConversationTag(c,[n]),l=new se(V[V.delTag],d,this.currentUserId),[4,this._channel.send(l)]):[2,{code:M.RC_NET_CHANNEL_INVALID}];case 1:return(h=a.sent().code)!==M.SUCCESS?[2,{code:h}]:(this._conversationManager.deleteTagStatus(i,o,r,s),[2,{code:M.SUCCESS}])}})})},e.prototype.getConversationListByTag=function(n,r,i){return F(this,void 0,void 0,function(){var o,s,c,d,l,h,a,u,f;return H(this,function(p){switch(p.label){case 0:return s=(o=this).currentUserId,(c=o._channel)?(d=c.codec.encodeOldConversationList({count:i,type:oe.PRIVATE,startTime:r}),l=new se(Ja,d,s),[4,c.send(l,rr,{currentUserId:s,connectedTime:c.connectedTime})]):[2,{code:M.RC_NET_CHANNEL_INVALID}];case 1:return h=p.sent(),a=h.code,u=h.data,f=this._conversationHasTagFilter(n,u),Q.info("GetConversationListByTag",f),a!==M.SUCCESS?[2,{code:a}]:[2,{code:a,data:f}]}})})},e.prototype._conversationHasTagFilter=function(n,r){var i=this,o=[],s=[];function c(d,l){return d.latestMessage&&l.latestMessage?d.latestMessage.sentTime-l.latestMessage.sentTime:0}return r.forEach(function(d){var l=d.conversationType,h=d.targetId,a=d.channelId,u=i._conversationManager.get(l,h,a),f=u.hasMentioned,p=u.mentionedInfo,m=u.lastUnreadTime,_=u.notificationStatus,v=u.isTop,y=u.tags,C=u.unreadMessageCount,w=y&&y[n];if(w){var P=Ee(Ee({},d),{hasMentioned:f,mentionedInfo:p,lastUnreadTime:m,notificationStatus:_,isTop:v,unreadMessageCount:C});w.isTop?o.push(Ee(Ee({},P),{isTopInTag:!0})):s.push(Ee(Ee({},P),{isTopInTag:!1}))}}),Qt(Qt([],o.sort(c)),s.sort(c))},e.prototype.getUnreadCountByTag=function(n,r){return F(this,void 0,void 0,function(){var i;return H(this,function(o){return this._channel?(i=this._conversationManager.getUnreadCountByTag(n,r),[2,{code:M.SUCCESS,data:i}]):[2,{code:M.RC_NET_CHANNEL_INVALID}]})})},e.prototype.setConversationStatusInTag=function(n,r,i){return F(this,void 0,void 0,function(){var o,s,c,d,l,h,a,u,f,p;return H(this,function(m){switch(m.label){case 0:return this._channel?(o=r.targetId,s=r.conversationType,c=r.channelId,d=i.isTop,l=[{tagId:n,isTop:d}],(h=this._conversationManager.get(s,o,c)).tags&&Object.hasOwnProperty.call(h.tags,n)?(a=this._channel.codec.encodeUpdateConversationTag(l,[r]),u=new se(V[V.addTag],a,this.currentUserId),[4,this._channel.send(u)]):[2,{code:M.NO_TAG_IN_CONVER}]):[2,{code:M.RC_NET_CHANNEL_INVALID}];case 1:return(f=m.sent().code)!==M.SUCCESS?[2,{code:f}]:((p={})[n]={},d&&(p[n].isTop=!0),this._conversationManager.addTagStatus(s,o,p,c),[2,{code:M.SUCCESS}])}})})},e.prototype.getTagsForConversation=function(n){var r;return F(this,void 0,void 0,function(){var i,o,s,c;return H(this,function(d){if(!this._channel)return[2,{code:M.RC_NET_CHANNEL_INVALID}];if(i=this._conversationManager.get(n.conversationType,n.targetId,n.channelId),o=this._userSettingManager.getTagsInfo(),s=[],i.tags)for(c in i.tags)s.push({tagId:c,tagName:(r=o[c])===null||r===void 0?void 0:r.tagName});return[2,{code:M.SUCCESS,data:s}]})})},e.prototype.getBlockConversationList=function(){var n=this._conversationManager.getBlockConversationList();return Promise.resolve({code:M.SUCCESS,data:n})},e.prototype.getTopConversationList=function(){var n=this._conversationManager.getTopConversationList();return Promise.resolve({code:M.SUCCESS,data:n})},e.prototype.getUnreadMentionedCount=function(n){var r=this._conversationManager.getUnreadMentionedCount(n.channelId,n.conversationType,n.targetId);return Promise.resolve({code:M.SUCCESS,data:r})},e.prototype.getAllUnreadMentionedCount=function(){var n=this._conversationManager.getAllUnreadMentionedCount();return Promise.resolve({code:M.SUCCESS,data:n})},e.prototype.joinRTCRoom=function(n,r,i,o){return F(this,void 0,void 0,function(){var s,c;return H(this,function(d){return this._channel?(s=this._channel.codec.encodeJoinRTCRoom(r,i,o),c=new se(V[V.rtcRJoin_data],s,n),[2,this._channel.send(c,Jt)]):[2,{code:M.RC_NET_CHANNEL_INVALID}]})})},e.prototype.quitRTCRoom=function(n){return F(this,void 0,void 0,function(){var r,i;return H(this,function(o){switch(o.label){case 0:return this._channel?(r=this._channel.codec.encodeQuitRTCRoom(),i=new se(V[V.rtcRExit],r,n),[4,this._channel.send(i)]):[2,M.RC_NET_CHANNEL_INVALID];case 1:return[2,o.sent().code]}})})},e.prototype.rtcPing=function(n,r,i){return F(this,void 0,void 0,function(){var o,s;return H(this,function(c){switch(c.label){case 0:return this._channel?(o=this._channel.codec.encodeJoinRTCRoom(r,i),s=new se(V[V.rtcPing],o,n),[4,this._channel.send(s)]):[2,M.RC_NET_CHANNEL_INVALID];case 1:return[2,c.sent().code]}})})},e.prototype.getRTCRoomInfo=function(n){return F(this,void 0,void 0,function(){var r,i;return H(this,function(o){return this._channel?(r=this._channel.codec.encodeGetRTCRoomInfo(),i=new se(V[V.rtcRInfo],r,n),[2,this._channel.send(i,Eu)]):[2,{code:M.RC_NET_CHANNEL_INVALID}]})})},e.prototype.getRTCUserInfoList=function(n){return F(this,void 0,void 0,function(){var r,i,o,s,c;return H(this,function(d){switch(d.label){case 0:return this._channel?(r=this._channel.codec.encodeGetRTCRoomInfo(),i=new se(V[V.rtcUData],r,n),[4,this._channel.send(i,Jt)]):[2,{code:M.RC_NET_CHANNEL_INVALID}];case 1:return o=d.sent(),s=o.code,c=o.data,[2,{code:s,data:c&&{users:c.users}}]}})})},e.prototype.setRTCUserInfo=function(n,r,i){return F(this,void 0,void 0,function(){var o,s;return H(this,function(c){switch(c.label){case 0:return this._channel?(o=this._channel.codec.encodeSetRTCUserInfo(r,i),s=new se(V[V.rtcUPut],o,n),[4,this._channel.send(s)]):[2,M.RC_NET_CHANNEL_INVALID];case 1:return[2,c.sent().code]}})})},e.prototype.removeRTCUserInfo=function(n,r){return F(this,void 0,void 0,function(){var i,o;return H(this,function(s){switch(s.label){case 0:return this._channel?(i=this._channel.codec.encodeRemoveRTCUserInfo(r),o=new Dn(V[V.rtcUDel],i,n),[4,this._channel.send(o)]):[2,M.RC_NET_CHANNEL_INVALID];case 1:return[2,s.sent().code]}})})},e.prototype.setRTCData=function(n,r,i,o,s,c){return F(this,void 0,void 0,function(){var d,l;return H(this,function(h){switch(h.label){case 0:return this._channel?(d=this._channel.codec.encodeSetRTCData(r,i,o,s,c),l=new Dn(V[V.rtcSetData],d,n),[4,this._channel.send(l)]):[2,M.RC_NET_CHANNEL_INVALID];case 1:return[2,h.sent().code]}})})},e.prototype.setRTCTotalRes=function(n,r,i,o,s){return F(this,void 0,void 0,function(){var c,d;return H(this,function(l){switch(l.label){case 0:return this._channel?(c=this._channel.codec.encodeUserSetRTCData(r,i,o,s),d=new se(V[V.userSetData],c,n),[4,this._channel.send(d)]):[2,M.RC_NET_CHANNEL_INVALID];case 1:return[2,l.sent().code]}})})},e.prototype.setRTCCDNUris=function(n,r,i){return F(this,void 0,void 0,function(){var o,s;return H(this,function(c){switch(c.label){case 0:return this._channel?(o=this._channel.codec.encodeUserSetRTCCDNUris(r,i),s=new se(V[V.userSetData],o,n),[4,this._channel.send(s)]):[2,M.RC_NET_CHANNEL_INVALID];case 1:return[2,c.sent().code]}})})},e.prototype.getRTCData=function(n,r,i,o){if(!this._channel)return Promise.resolve({code:M.RC_NET_CHANNEL_INVALID});var s=this._channel.codec.encodeGetRTCData(r,i,o),c=new se(V[V.rtcQryData],s,n);return this._channel.send(c,Oi)},e.prototype.removeRTCData=function(n,r,i,o,s){return F(this,void 0,void 0,function(){var c,d;return H(this,function(l){switch(l.label){case 0:return this._channel?(c=this._channel.codec.encodeRemoveRTCData(r,i,o,s),d=new Dn(V[V.rtcDelData],c,n),[4,this._channel.send(d)]):[2,M.RC_NET_CHANNEL_INVALID];case 1:return[2,l.sent().code]}})})},e.prototype.setRTCOutData=function(n,r,i,o){throw new Error("JSEngine's method not implemented.")},e.prototype.getRTCOutData=function(n,r){throw new Error("JSEngine's method not implemented.")},e.prototype.getRTCToken=function(n,r,i){return F(this,void 0,void 0,function(){var o,s;return H(this,function(c){return this._channel?(o=this._channel.codec.encodeJoinRTCRoom(r,i),s=new se(V[V.rtcToken],o,n),[2,this._channel.send(s,wi)]):[2,{code:M.RC_NET_CHANNEL_INVALID}]})})},e.prototype.setRTCState=function(n,r){return F(this,void 0,void 0,function(){var i,o;return H(this,function(s){switch(s.label){case 0:return this._channel?(i=this._channel.codec.encodeSetRTCState(r),o=new se(V[V.rtcUserState],i,n),[4,this._channel.send(o)]):[2,M.RC_NET_CHANNEL_INVALID];case 1:return[2,s.sent().code]}})})},e.prototype.getRTCUserInfo=function(n){return F(this,void 0,void 0,function(){return H(this,function(r){throw new Error("Method not implemented.")})})},e.prototype.getRTCUserList=function(n){if(!this._channel)return Promise.resolve({code:M.RC_NET_CHANNEL_INVALID});var r=this._channel.codec.encodeGetRTCRoomInfo(),i=new se(V[V.rtcUList],r,n);return this._channel.send(i,Jt)},e.prototype.joinLivingRoomAsAudience=function(n,r,i){return r===void 0&&(r=We.LIVE),F(this,void 0,void 0,function(){var o,s,c,d,l,h,a,u;return H(this,function(f){switch(f.label){case 0:return this._channel?(o=this._channel.codec.encodeJoinRTCRoom(r,i),s=new se(V[V.viewerJoinR],o,n),[4,this._channel.send(s,Ou)]):[2,{code:M.RC_NET_CHANNEL_INVALID}];case 1:return c=f.sent(),d=c.code,l=c.data,d!==M.SUCCESS?[2,{code:d}]:(a=(h=l).rtcToken,u=h.entries,[2,{code:d,data:{token:a,kvEntries:u}}])}})})},e.prototype.quitLivingRoomAsAudience=function(n){return F(this,void 0,void 0,function(){var r,i,o;return H(this,function(s){switch(s.label){case 0:return this._channel?(r=this._channel.codec.encodeQuitRTCRoom(),i=new se(V[V.viewerExitR],r,n),[4,this._channel.send(i)]):[2,M.RC_NET_CHANNEL_INVALID];case 1:return o=s.sent().code,this._rtcKVManager.reset(),[2,o]}})})},e.prototype.rtcIdentityChange=function(n,r,i){return F(this,void 0,void 0,function(){var o,s,c,d,l;return H(this,function(h){switch(h.label){case 0:return this._channel?(o=this._channel.codec.encodeIdentityChangeInfo(r,i),s=new se(V[V.rtcIdentityChange],o,n),[4,this._channel.send(s,Jt)]):[2,{code:M.RC_NET_CHANNEL_INVALID}];case 1:return c=h.sent(),d=c.code,l=c.data,d!==M.SUCCESS?[2,{code:d}]:[2,{code:d,data:l}]}})})},e.prototype.pullRTCRoomEntry=function(n,r){return F(this,void 0,void 0,function(){var i,o,s,c,d,l,h,a,u;return H(this,function(f){switch(f.label){case 0:return o=(i=this)._channel,s=i.currentUserId,o?(Q.info("audience in room start pull KV"),c=o.codec.encodePullRTCRoomKV(n,0),d=new se(V[V.rtcPullKv],c,s),[4,o.send(d,Li)]):[2,{code:M.RC_NET_CHANNEL_INVALID}];case 1:return l=f.sent(),h=l.code,a=l.data,Q.info("audience in room end pull KV, code: "+h+", data: "+JSON.stringify(a||{})),h===M.SUCCESS?(u=a.kvEntries,this._watcher.onRTCDataChange(u,n),[2,{code:h,data:a}]):[2,{code:h}]}})})},e.prototype.getRTCJoinedUserInfo=function(n){return F(this,void 0,void 0,function(){var r,i,o,s,c,d,l,h;return H(this,function(a){switch(a.label){case 0:return i=(r=this)._channel,o=r.currentUserId,i?(s=i.codec.encodeQueryUserJoinedInfo(n),c=new se(V[V.rtcQueryJoined],s,o),[4,i.send(c,ki)]):[2,{code:M.RC_NET_CHANNEL_INVALID}];case 1:return d=a.sent(),l=d.code,h=d.data,l===M.SUCCESS?[2,{code:l,data:h}]:[2,{code:l}]}})})},e.prototype.getDeviceId=function(){return ju(this.runtime)},e.prototype.requestRoomPK=function(n){return F(this,void 0,void 0,function(){var r,i,o;return H(this,function(s){switch(s.label){case 0:return this._channel?(r=this._channel.codec.encodeRequestRoomPK(n),i=new se(V[V.rtcInvite],r,n.roomId),[4,this._channel.send(i)]):[2,M.RC_NET_CHANNEL_INVALID];case 1:return o=s.sent().code,this._rtcKVManager.reset(),[2,o]}})})},e.prototype.cancelRoomPK=function(n){return F(this,void 0,void 0,function(){var r,i,o;return H(this,function(s){switch(s.label){case 0:return this._channel?(r=this._channel.codec.encodeCancelRoomPK(n),i=new se(V[V.rtcCancelInvite],r,n.roomId),[4,this._channel.send(i)]):[2,M.RC_NET_CHANNEL_INVALID];case 1:return o=s.sent().code,this._rtcKVManager.reset(),[2,o]}})})},e.prototype.responseRoomPK=function(n){return F(this,void 0,void 0,function(){var r,i,o;return H(this,function(s){switch(s.label){case 0:return this._channel?(r=this._channel.codec.encodeResponseRoomPK(n),i=new se(V[V.rtcInviteAnswer],r,n.roomId),[4,this._channel.send(i)]):[2,M.RC_NET_CHANNEL_INVALID];case 1:return o=s.sent().code,this._rtcKVManager.reset(),[2,o]}})})},e.prototype.endRoomPK=function(n){return F(this,void 0,void 0,function(){var r,i,o;return H(this,function(s){switch(s.label){case 0:return this._channel?(r=this._channel.codec.encodeEndRoomPK(n),i=new se(V[V.rtcEndInvite],r,n.roomId),[4,this._channel.send(i)]):[2,M.RC_NET_CHANNEL_INVALID];case 1:return o=s.sent().code,this._rtcKVManager.reset(),[2,o]}})})},e.prototype.callExtra=function(n){for(var r=[],i=1;i0){var _=c.join("");if(c=[],_.length>26){var v=n.numberEncode(_.length),y=String.fromCharCode(n.dataType.NormalExt|v.length);s.push(y+v)}else{var C=String.fromCharCode(n.dataType.Normal|_.length);s.push(C)}s.push(_)}},l=0;l=h.length)c.push(e.substr(l,h.length)),l+=h.length;else{d();var f=String.fromCharCode(n.dataType.Compressed|a.length<<2|u.length);s.push(f+a+u),l+=h.length}}}d();var p=n.numberEncode(e.length),m=String.fromCharCode(n.dataType.Tail|p.length);return s.push(m+p),s.join("")},t.uncompress=function(e){var n=this,r=0,i="";e:do{var o=e.charCodeAt(r++),s=o&n.dataType.Mark,c=15&o,d=void 0;switch(s){case n.dataType.Compressed:var l=c>>2,h=3&c;if(l===0||h===0)throw new Error("Data parsing error,at "+r);var a=n.numberDecode(e.substr(r,l)),u=n.numberDecode(e.substr(r+=l,h));if((a=i.length-a)+u>i.length)throw new Error("Data parsing error,at "+r);r+=h,i+=i.substr(a,u);break;case n.dataType.Tail:if((d=n.numberDecode(e.substr(r,c)))!==i.length)throw console.log(i.length),console.log(d),new Error("Data parsing error,at "+r);r+=c;break e;case n.dataType.NormalExt:d=n.numberDecode(e.substr(r,c)),i+=e.substr(r+=c,d),r+=d;break;case n.dataType.Normal:i+=e.substr(r,c),r+=c;break;case n.dataType.Mark:if(c>10)throw new Error("Data parsing error,at "+r);i+=e.substr(r,16+c),r+=16+c;break;default:throw new Error("Data parsing error,at "+r+" header:"+s)}}while(r=n.length-1)return i;var o=e[n.charAt(r)+n.charAt(r+1)];if(o[0]===r)return i;for(var s=n.length-r,c=0,d=o.length;cthis.max)){var a=Math.min(s,h);if(a<=i.length)break;if(!(i.length>2&&n.charAt(l+i.length-1)!==n.charAt(r+i.length-1))){for(var u=2,f=u;f=i.length&&(i.length=u,i.offset=l)}}}return i},t.numberEncode=function(e){var n=this,r=[],i=0;do i=e%n.scale,r.push(n.chars.charAt(i)),e=(e-i)/n.scale;while(e>0);return r.join("")},t.numberDecode=function(e){for(var n=0,r=0,i=e.length-1;i>=0;i--){if((r=this.chars.indexOf(e.charAt(i)))===-1)throw new Error('decode number error, data is "'+e+'"');n=n*this.scale+r}return n},t.dataType={Tail:48,Compressed:64,NormalExt:80,Normal:96,Mark:112},t.chars="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",t.scale=t.chars.length,t.max=238327,t}(),xn=1,Bn=!1,ic=typeof location!="undefined"&&location.protocol==="https://"?"https://":"http://",Tr=function(){function t(e){this.info=e,this.logUrl="logcollection.ronghub.com",this.level=1,this.itv=30,this.times=5,this.deviceId="",this.deviceInfo="",this.logSwitch=0,this.logUrl=e.logPolicy.url||this.logUrl,this.level=e.logPolicy.level||this.level,this.itv=e.logPolicy.itv||this.itv,this.times=e.logPolicy.times||this.times,this.deviceId=ju(e.runtime),this.logSwitch=e.logSwitch;var n=sh(e.runtime);this.deviceInfo=n.type+"|"+n.version+"|"+jt.sessionId,this.startReport()}return t.init=function(e){return Bn=!0,t._instance||(t._instance=new t(e)),t._instance},t.getInstance=function(){return t._instance},t.prototype.startReport=function(){var e=this;if(this.logSwitch&&Bn){var n=this.itv*Math.pow(2,xn-1);xn "+o),e.startReport()})}else this.startReport()},t.prototype.reportFullLog=function(e){return F(this,void 0,void 0,function(){var n,r,i,o,s,c,d,l,h,a,u=this;return H(this,function(f){switch(f.label){case 0:return n=e.startTime,r=e.endTime,i=e.platform,o=e.logId,s=e.uri,c=ps.getInstance(),Q.debug("received report log msg, "+i.toLowerCase(),c),i.toLowerCase()==="web"&&c?n>r?(Q.warn("report error: The start time("+n+") cannot be greater than the end time("+n+")"),[2]):[4,Q.__insertLogIntoDatabase()]:[2];case 1:return f.sent(),[4,c.getRangeData(dn,"time",n,r)];case 2:return d=(d=f.sent()).filter(function(p){return!p.userId||p.userId===u.info.userId}),l=rc.compress(d.map(function(p){return p.content}).join("")||"no data"),h=1,(a=function(){if(!(h>3)&&Bn){var p=s||u.logUrl,m=""+ic+p+"?version="+u.info.version+"&appkey="+u.info.appkey+"&userId="+u.info.userId+"&logId="+o+"&deviceId="+u.deviceId+"&deviceInfo="+u.deviceInfo+"&platform=Web",_=5e3*(h-1);h++,setTimeout(function(){Bn&&u.info.runtime.httpReq({url:m,method:"POST",body:l}).then(function(){Q.debug("report full log success!")}).catch(function(v){a(),Q.warn("report full log error -> "+v)})},_)}})(),[2]}})})},t.prototype.distroy=function(){xn=1,Bn=!1},t}();function Sr(t){return Object.assign({},t)}var oc,Zh=function(){function t(e,n){var r;this._runtime=e,this._token="",this._pluginContextQueue=[],this._pluginInstanseMap={},this.coreVersion="5.1.1",this._versionInfo={},this._typingInfo={},this._isInternalConnected=!1,this._connectionStatus=ue.DISCONNECTED,this._canRedirectConnect=!1,this._watcher={message:void 0,batchMessage:void 0,conversationState:void 0,chatroomState:void 0,connectionState:void 0,rtcInnerWatcher:void 0,expansion:void 0,tag:void 0,conversationTagChanged:void 0,pullFinished:void 0,onConnecting:void 0,onConnected:void 0,onDisconnect:void 0,onSuspend:void 0,readReceiptReceived:void 0,messageReceiptRequest:void 0,messageReceiptResponse:void 0,typingState:void 0,messageBlocked:void 0},this._typingInternalTimer=-1,this._typingExpireTime=2e3,this._typingChangedList=[],this.getChatRoomHistoryMessages=this.getChatroomHistoryMessages,this._options=Object.assign({},n),this.appkey=this._options.appkey,this.apiVersion=this._options.apiVersion,this._options.typingExpireTime&&(this._options.typingExpireTime<2e3?this._typingExpireTime=2e3:this._options.typingExpireTime>6e3?this._typingExpireTime=6e3:this._typingExpireTime=this._options.typingExpireTime),this._options.navigators=this._options.navigators.filter(function(o){return/^https?:\/\//.test(o)}),this._options.navigators=this._options.navigators.map(function(o){return o.replace(/\/$/g,"")}),this._options.navigators.length===0&&(r=this._options.navigators).push.apply(r,Gl);var i={status:this._connectionStatusListener.bind(this),batchMessage:this._batchMessageReceiver.bind(this),chatroom:this._chatroomInfoListener.bind(this),conversation:this._conversationInfoListener.bind(this),expansion:this._expansionInfoListener.bind(this),tag:this._tagListener.bind(this),conversationTag:this._conversationTagListener.bind(this),onRTCDataChange:this._rtcDataChange.bind(this),pullFinished:this._pullFinishedListener.bind(this)};this._engine=Ka()?new RCCppEngine(e,i,this._options):new Qh(e,i,this._options)}return t.init=function(e,n){return Q.setLogLevel(n.logLevel),Q.setLogStdout(n.logStdout),(n.indexDBSwitch||_e(n.indexDBSwitch))&&ps.init(),Q.debug("APIContext.init =>",n.appkey,n.navigators),this._context?(Q.error("Repeat initialize!"),this._context):(Q.warn("RCEngine Commit:","41dbe38d1b376ca0a791b23ed94be291e3f92e81"),this._context=new t(e,n),Q.__insertLogIntoDatabase(),this._context)},t.destroy=function(){this._context&&(this._context._destroy(),this._context=void 0)},t.prototype.install=function(e,n){if(this._pluginInstanseMap[e.tag])return Q.warn("Repeat install plugin: "+e.tag),this._pluginInstanseMap[e.tag];var r=e.tag==="RCRTC"?new Xh(this):new Ku(this),i=null;try{if(!e.verify(this._runtime))return null;i=e.setup(r,this._runtime,n)}catch(o){Q.error(`install plugin error! `,o)}return["RCRTC","RCCall"].includes(e.tag)&&e.version&&e.name&&(this._versionInfo[e.name]=e.version),i&&this._pluginContextQueue.push(r),i&&(this._pluginInstanseMap[e.tag]=i),i},t.prototype._handleRedirect=function(){return F(this,void 0,void 0,function(){var e=this;return H(this,function(n){switch(n.label){case 0:return Q.debug("_handleRedirct",this._token),[4,this.connect(this._token,!0)];case 1:return n.sent().code!==M.SUCCESS&&this._canRedirectConnect&&(this._handleSuspend(),setTimeout(function(){e._handleRedirect()},5e3)),[2]}})})},t.prototype._connectionStatusListener=function(e){var n;return F(this,void 0,void 0,function(){return H(this,function(r){return e===ue.REDIRECT?(this._canRedirectConnect=!0,this._handleSuspend(),this._handleRedirect()):e===ue.BLOCKED||e===ue.KICKED_OFFLINE_BY_OTHER_CLIENT||e===ue.DISCONNECT_BY_SERVER?(this._canRedirectConnect=!1,this._handleDisconnect()):e===ue.CONNECTING?this._handleConnecting():e===ue.CONNECTED?this._handleConnected():e===ue.DISCONNECTED?this._handleDisconnect():e===ue.NETWORK_UNAVAILABLE&&this._handleSuspend(),this._connectionStatus=e,((n=this._watcher.rtcInnerWatcher)===null||n===void 0?void 0:n.status)&&this._watcher.rtcInnerWatcher.status(e),this._pluginContextQueue.forEach(function(i){i.onconnectionstatechange&&i.onconnectionstatechange(e)}),this._watcher.connectionState&&this._watcher.connectionState(e),[2]})})},t.prototype._handleConnecting=function(){this._watcher.onConnecting&&this._watcher.onConnecting()},t.prototype._handleConnected=function(){this._watcher.onConnected&&this._watcher.onConnected()},t.prototype._handleDisconnect=function(){this._watcher.onDisconnect&&this._watcher.onDisconnect()},t.prototype._handleSuspend=function(){this._watcher.onSuspend&&this._watcher.onSuspend()},t.prototype._messageReceiver=function(e,n,r){var i,o,s;if((e.conversationType===oe.RTC_ROOM||Object.prototype.hasOwnProperty.call(Zl,e.messageType))&&this._watcher.rtcInnerWatcher&&this._watcher.rtcInnerWatcher.message)this._watcher.rtcInnerWatcher.message(Sr(e));else if(["RC:ChrmJoinNtf","RC:ChrmQuitNtf"].indexOf(e.messageType)===-1||typeof this._watcher.chatroomState!="function"){if(e.messageType!=="RC:ChrmMemChange"){if(e.messageType!==Ge.TYPING_STATUS||(this._addTypingInfo(Sr(e)),!this._watcher.typingState))if(e.messageType!==Ge.LOG_COMMAND||e.senderUserId!=="rongcloudsystem")if(e.messageType!==Ge.INTERCEPT){if(!this._pluginContextQueue.some(function(v){if(!v.onmessage)return!1;try{return v.onmessage(Sr(e))}catch(y){return Q.error("plugin error =>",y),!1}}))if(e.messageType!=="RC:ReadNtf")if(e.messageType!=="RC:RRReqMsg"){if(e.messageType!=="RC:RRRspMsg")return this._watcher.message&&this._watcher.message(Sr(e),n,r),e;var c=(s=e.content)===null||s===void 0?void 0:s.receiptMessageDic;c&&Array.isArray(c[this._engine.currentUserId])&&typeof this._watcher.messageReceiptResponse=="function"&&this._watcher.messageReceiptResponse({conversationType:e.conversationType,targetId:e.targetId,channelId:e.channelId},e.senderUserId,c[this._engine.currentUserId])}else typeof this._watcher.messageReceiptRequest=="function"&&this._watcher.messageReceiptRequest({conversationType:e.conversationType,targetId:e.targetId,channelId:e.channelId},e.content.messageUId,e.senderUserId);else typeof this._watcher.readReceiptReceived=="function"&&this._watcher.readReceiptReceived({conversationType:e.conversationType,targetId:e.targetId,channelId:e.channelId},e.content.messageUId,e.content.lastMessageSendTime)}else this._MessageBlockedListener({conversationType:e.conversationType,targetId:e.targetId,channelId:e.channelId||"",blockType:e.content.interceptType,blockedMessageUId:e.content.msgUId});else{var d=e.content,l=d.startTime,h=d.endTime,a=d.platform,u=d.logId,f=d.uri,p=d.packageName,m={startTime:parseInt(l),endTime:parseInt(h),platform:a,logId:u,uri:f,packageName:p};(o=Tr.getInstance())===null||o===void 0||o.reportFullLog(m)}}else if(typeof this._watcher.chatroomState=="function"){var _={};Array.isArray(e.content.userList)&&e.content.userList.forEach(function(v){_[v.userId]=v.status}),this._watcher.chatroomState({userChange:{users:_,chatroomId:e.targetId}})}}else this._watcher.chatroomState({userChange:{users:(i={},i[e.senderUserId]=e.messageType==="RC:ChrmQuitNtf"?Fa.QUIT:Fa.JOIN,i),chatroomId:e.targetId}})},t.prototype._batchMessageReceiver=function(e,n,r){var i=this,o=[];e.forEach(function(s){var c=i._messageReceiver(s,n,r);c&&o.push(c)}),o.length&&this._watcher.batchMessage&&this._watcher.batchMessage(o)},t.prototype._chatroomInfoListener=function(e){this._watcher.chatroomState&&this._watcher.chatroomState(e)},t.prototype._conversationInfoListener=function(e){this._watcher.conversationState&&this._watcher.conversationState(e)},t.prototype._expansionInfoListener=function(e){this._watcher.expansion&&this._watcher.expansion(e)},t.prototype._tagListener=function(){this._watcher.tag&&this._watcher.tag()},t.prototype._conversationTagListener=function(){this._watcher.conversationTagChanged&&this._watcher.conversationTagChanged()},t.prototype._typingStatusListener=function(e){this._watcher.typingState&&this._watcher.typingState(e)},t.prototype._pullFinishedListener=function(){this._watcher.pullFinished&&this._watcher.pullFinished()},t.prototype._MessageBlockedListener=function(e){this._watcher.messageBlocked&&this._watcher.messageBlocked(e)},t.prototype._rtcDataChange=function(e,n){this._pluginContextQueue.forEach(function(r){r.onrtcdatachange&&r.onrtcdatachange(e,n)})},t.prototype.assignWatcher=function(e){var n=this;Object.keys(this._watcher).forEach(function(r){if(Object.prototype.hasOwnProperty.call(e,r)){var i=e[r];n._watcher[r]=Jr(i)||$e(i)?i:void 0}})},t.prototype.resetWatcher=function(){var e=this;Object.keys(this._watcher).forEach(function(n){e._watcher[n]=void 0})},t.prototype._addTypingInfo=function(e){var n=e.senderUserId,r=e.conversationType,i=e.targetId,o=e.content,s=e.channelId,c=o.typingContentType,d=r+"#"+i+"#"+(s||"");this._typingInfo[d]||(this._typingInfo[d]=[]);var l=this._typingInfo[d].findIndex(function(h){return h.userId===n});l>=0&&this._typingInfo[d][l].messageType===c?this._typingInfo[d][l].timestamp=Date.now():(l>=0&&this._typingInfo[d].splice(l,1),this._typingInfo[d].push({userId:n,messageType:c,timestamp:Date.now()}),this._typingChangedList.includes(d)||this._typingChangedList.push(d),this._startCheckTypingInfo())},t.prototype._startCheckTypingInfo=function(){var e=this;this._typingInternalTimer===-1&&Object.keys(this._typingInfo).length!==0&&(this._typingInternalTimer=setInterval(function(){for(var n in e._typingInfo){var r=e._typingInfo[n].length;e._typingInfo[n]=e._typingInfo[n].filter(function(o){return Date.now()-o.timestamp0){var i=e._typingChangedList.map(function(o){return{conversationType:Number(o.split("#")[0]),targetId:o.split("#")[1],channelId:o.split("#")[2],list:e._typingInfo[o]||[]}});e._typingStatusListener(i),e._typingChangedList=[]}Object.keys(e._typingInfo).length===0&&(clearInterval(e._typingInternalTimer),e._typingInternalTimer=-1)},500))},t.prototype.getConnectedTime=function(){return this._engine.getConnectedTime()},t.prototype.getServerTime=function(){return this._engine.getServerTime()},t.prototype.getDeviceId=function(){return this._engine.getDeviceId()},t.prototype.getCurrentUserId=function(){return this._engine.currentUserId},t.prototype.getConnectionStatus=function(){return this._connectionStatus},Object.defineProperty(t.prototype,"token",{get:function(){return this._token},enumerable:!1,configurable:!0}),t.prototype.connect=function(e,n){return n===void 0&&(n=!1),F(this,void 0,void 0,function(){var r,i,o,s,c,d;return H(this,function(l){switch(l.label){case 0:return this._connectionStatus===ue.CONNECTED?[2,{code:M.SUCCESS,userId:this._engine.currentUserId}]:this._connectionStatus===ue.CONNECTING?[2,{code:M.BIZ_ERROR_CONNECTING}]:typeof e!="string"||e.length===0?[2,{code:M.RC_CONN_USER_OR_PASSWD_ERROR}]:(this._token=e,r=e.split("@"),i=r[1],o=i?i.split(";").map(function(h){return/^https?:/.test(h)?h:"https://"+h}):[],[4,this._engine.navi.getInfo(this._getTokenWithoutNavi(),o,n,this._options.checkCA)]);case 1:return(s=l.sent())?(s==null?void 0:s.type)===1?[2,{code:M.PACKAGE_ENVIRONMENT_ERROR}]:(c=Xt.getInfo(),[4,this._engine.connect(this._getTokenWithoutNavi(),s)]):[2,{code:M.RC_NAVI_RESOURCE_ERROR}];case 2:return d=l.sent(),Q.__insertLogIntoDatabase(),d!==Ke.REDIRECT?[3,4]:(this._connectionStatus=ue.REDIRECT,[4,this.connect(e,!0)]);case 3:return[2,l.sent()];case 4:return d===M.SUCCESS&&(Q.info("connect success, userId: "+this._engine.currentUserId),(s==null?void 0:s.type)!==1&&this._engine.reportSDKInfo&&this._engine.reportSDKInfo(c),Tr.init({runtime:this._runtime,logSwitch:(s==null?void 0:s.logSwitch)||0,logPolicy:JSON.parse((s==null?void 0:s.logPolicy)||"{}"),appkey:this.appkey,version:this.apiVersion,userId:this._engine.currentUserId}),jt.init(this._engine.currentUserId),this._isInternalConnected=!0),d!==M.SUCCESS||Ka()||s.openUS===1&&this._pullUserSettings(),d!==M.SUCCESS&&(this._connectionStatus=ue.CONNECTION_CLOSED),[2,{code:d,userId:this._engine.currentUserId}]}})})},t.prototype._pullUserSettings=function(){return F(this,void 0,void 0,function(){return H(this,function(e){return[2]})})},t.prototype.disconnect=function(){var e;return this._isInternalConnected=!1,clearInterval(this._typingInternalTimer),this._typingInternalTimer=-1,(e=Tr.getInstance())===null||e===void 0||e.distroy(),Q.__insertLogIntoDatabase(),jt.reset(),this._engine.disconnect(),this._pluginContextQueue.forEach(function(n){if(n.ondisconnect)try{n.ondisconnect()}catch(r){Q.error("plugin error =>",r)}}),Promise.resolve()},t.prototype.reconnect=function(){return this._isInternalConnected?Promise.resolve({code:M.CAN_NOT_RECONNECT}):this.connect(this._getTokenWithoutNavi())},t.prototype._getTokenWithoutNavi=function(){return this._token.replace(/@.+$/,"@")},t.prototype.getInfoFromCache=function(){return this._engine.navi.getInfoFromCache(this._getTokenWithoutNavi())},t.prototype.registerMessageType=function(e,n,r,i){i===void 0&&(i=[]),this._engine.registerMessageType(e,n,r,i)},t.prototype.sendMessage=function(e,n,r,i){var o=this.getInfoFromCache();if(((o==null?void 0:o.grpRRVer)||0)===1&&r.messageType===Ge.READ_RECEIPT_RESPONSE)return Promise.resolve({code:M.READ_RECEIPT_ERROR});var s=JSON.stringify(r.content);return fu(s)>131072?Promise.resolve({code:M.RC_MSG_CONTENT_EXCEED_LIMIT}):this._engine.sendMessage(e,n,r,i)},t.prototype.sendExpansionMessage=function(e){return F(this,void 0,void 0,function(){var n,r,i,o,s,c,d,l,h,a,u,f,p,m;return H(this,function(_){switch(_.label){case 0:if(n=e.channelId,r=e.conversationType,i=e.targetId,o=e.messageUId,s=e.keys,c=e.expansion,d=e.removeAll,!e.canIncludeExpansion)return[2,{code:M.MESSAGE_KV_NOT_SUPPORT}];if(l=!1,h=!1,a=!1,$e(c)){for(f in u=Object.keys(c).length,l=u>20,c)if(p=c[f],h=nt(f)&&!/^[A-Za-z0-9_=+-]+$/.test(f),(a=f.length>32||p.length>64)||h)break}return l||a?[2,{code:M.EXPANSION_LIMIT_EXCEET}]:h?[2,{code:M.BIZ_ERROR_INVALID_PARAMETER}]:(m={mid:o},c&&(m.put=c),s&&(m.del=s),d&&(m.removeAll=1),[4,this._engine.sendMessage(r,i,{content:m,messageType:Ge.EXPANSION_NOTIFY,channelId:n})]);case 1:return[2,{code:_.sent().code}]}})})},t.prototype.sendReadReceiptMessage=function(e,n,r){return F(this,void 0,void 0,function(){var i;return H(this,function(o){return i=this.getInfoFromCache(),((i==null?void 0:i.grpRRVer)||0)===0?[2,{code:M.READ_RECEIPT_ERROR,data:"The read receipt switch is not on, please call the sendMessage method!"}]:[2,this._engine.sendReadReceiptMessage(e,n,r)]})})},t.prototype.getMessageReader=function(e,n,r){return F(this,void 0,void 0,function(){var i;return H(this,function(o){return i=this.getInfoFromCache(),((i==null?void 0:i.grpRRVer)||0)===0?[2,{code:M.READ_RECEIPT_ERROR}]:[2,this._engine.getMessageReader(e,n,r)]})})},t.prototype._destroy=function(){var e;this._isInternalConnected=!1,this._watcher={batchMessage:void 0,message:void 0,conversationState:void 0,chatroomState:void 0,connectionState:void 0,rtcInnerWatcher:void 0,expansion:void 0,tag:void 0,conversationTagChanged:void 0,typingState:void 0,pullFinished:void 0,onConnecting:void 0,onConnected:void 0,onDisconnect:void 0,onSuspend:void 0},this._engine.disconnect(),this._pluginContextQueue.forEach(function(n){if(n.ondestroy)try{n.ondestroy()}catch(r){Q.error("plugin error =>",r)}}),this._pluginContextQueue.length=0,this._pluginInstanseMap={},(e=Tr.getInstance())===null||e===void 0||e.distroy(),jt.reset()},t.prototype.getHistoryMessage=function(e,n,r,i,o,s,c){return r===void 0&&(r=0),i===void 0&&(i=20),o===void 0&&(o=0),s===void 0&&(s=""),c===void 0&&(c=""),this._engine.getHistoryMessage(e,n,r,i,o,s,c||"")},t.prototype.getConversationList=function(e,n,r,i,o){return e===void 0&&(e=300),o===void 0&&(o=""),this._engine.getConversationList(e,n,r,i,o)},t.prototype.getConversation=function(e,n,r){return this._engine.getConversation(e,n,r)},t.prototype.removeConversation=function(e,n,r){return r===void 0&&(r=""),this._engine.removeConversation(e,n,r)},t.prototype.clearUnreadCount=function(e,n,r){return r===void 0&&(r=""),this._engine.clearConversationUnreadCount(e,n,r)},t.prototype.clearAllUnreadCount=function(){return this._engine.clearAllUnreadCount()},t.prototype.getUnreadCount=function(e,n,r){return r===void 0&&(r=""),this._engine.getConversationUnreadCount(e,n,r)},t.prototype.getTotalUnreadCount=function(e,n,r){return this._engine.getAllConversationUnreadCount(e,n&&n.length>0?n:[oe.PRIVATE,oe.GROUP,oe.SYSTEM,oe.PUBLIC_SERVICE],!!r)},t.prototype.getFirstUnreadMessage=function(e,n,r){return r===void 0&&(r=""),this._engine.getFirstUnreadMessage(e,n,r)},t.prototype.setConversationStatus=function(e,n,r,i,o){o===void 0&&(o="");var s=[{conversationType:e,targetId:n,isTop:r,notificationStatus:i,channelId:o}];return this._engine.batchSetConversationStatus(s)},t.prototype.saveConversationMessageDraft=function(e,n,r,i){return i===void 0&&(i=""),this._engine.saveConversationMessageDraft(e,n,r,i)},t.prototype.getConversationMessageDraft=function(e,n,r){return r===void 0&&(r=""),this._engine.getConversationMessageDraft(e,n,r)},t.prototype.clearConversationMessageDraft=function(e,n,r){return r===void 0&&(r=""),this._engine.clearConversationMessageDraft(e,n,r)},t.prototype.recallMessage=function(e,n,r,i,o){return this._engine.recallMsg(e,n,r,i,o)},t.prototype.deleteRemoteMessage=function(e,n,r,i){return i===void 0&&(i=""),this._engine.deleteRemoteMessage(e,n,r,i)},t.prototype.deleteRemoteMessageByTimestamp=function(e,n,r,i){return i===void 0&&(i=""),this._engine.deleteRemoteMessageByTimestamp(e,n,r,i)},t.prototype.joinChatroom=function(e,n){return n===void 0&&(n=10),this._engine.joinChatroom(e,n)},t.prototype.joinExistChatroom=function(e,n){return n===void 0&&(n=10),this._engine.joinExistChatroom(e,n)},t.prototype.quitChatroom=function(e){return this._engine.quitChatroom(e)},t.prototype.getChatroomInfo=function(e,n,r){return n===void 0&&(n=0),r===void 0&&(r=0),this._engine.getChatroomInfo(e,n,r)},t.prototype.setChatroomEntry=function(e,n){var r=n.key,i=n.value;return rn(r)&&Qi(i)?this._engine.setChatroomEntry(e,n):Promise.resolve(M.BIZ_ERROR_INVALID_PARAMETER)},t.prototype.setChatroomEntries=function(e,n){for(var r=0;r1e3?[2,Promise.reject(M.CONVER_OUT_LIMIT_ERROR)]:[2,this._engine.addTagForConversations(e,n)]})})},t.prototype.removeTagForConversations=function(e,n){return F(this,void 0,void 0,function(){return H(this,function(r){return[2,this._engine.removeTagForConversations(e,n)]})})},t.prototype.removeTagsForConversation=function(e,n){return F(this,void 0,void 0,function(){return H(this,function(r){return[2,this._engine.removeTagsForConversation(e,n)]})})},t.prototype.getConversationListByTag=function(e,n,r,i){return F(this,void 0,void 0,function(){return H(this,function(o){return[2,this._engine.getConversationListByTag(e,n,r,i)]})})},t.prototype.getUnreadCountByTag=function(e,n){return F(this,void 0,void 0,function(){return H(this,function(r){return[2,this._engine.getUnreadCountByTag(e,n)]})})},t.prototype.setConversationStatusInTag=function(e,n,r){return F(this,void 0,void 0,function(){return H(this,function(i){return[2,this._engine.setConversationStatusInTag(e,n,r)]})})},t.prototype.getTagsForConversation=function(e){return F(this,void 0,void 0,function(){return H(this,function(n){return[2,this._engine.getTagsForConversation(e)]})})},t.prototype.getBlockConversationList=function(){return this._engine.getBlockConversationList()},t.prototype.getTopConversationList=function(){return this._engine.getTopConversationList()},t.prototype.getUnreadMentionedCount=function(e){return this._engine.getUnreadMentionedCount(e)},t.prototype.getAllUnreadMentionedCount=function(){return this._engine.getAllUnreadMentionedCount()},t.prototype.callExtra=function(e){for(var n,r=[],i=1;i0&&i[i.length-1])||h[0]!==6&&h[0]!==2)){s=0;continue}if(h[0]===3&&(!i||h[1]>i[0]&&h[1]"+n),[4,ht.imClient.context.joinChatroom(t,e.count)];case 1:return(r=i.sent())!==M.SUCCESS?(Je.warn("join chatroom fail ->code+:"+_n[r]+","+n),[2,{code:r,msg:_n[r]}]):[2,{code:r}]}})})}var qu=function(t,e,n,r){n===void 0&&(n=!0),r===void 0&&(r=!0),this.messageType=t,this.content=e,this.isPersited=n,this.isCounted=r};function dt(t,e,n){return e===void 0&&(e=!0),n===void 0&&(n=!0),function(r){return new qu(t,r,e,n)}}var Gu,Go,ff=dt("RC:ImgMsg"),pf=dt("RC:HQVCMsg"),gf=dt("RC:SightMsg"),mf=dt("RC:TxtMsg"),_f=dt("RC:CombineMsg"),vf=dt("RC:FileMsg");dt("RC:GIFMsg");dt("RC:VcMsg");dt("RC:LBSMsg");dt("RC:ReferenceMsg");dt("RC:ImgTextMsg");var sn={qiniu:function(t,e,n,r){var i,o="https://"+e.uploadHost.qiniu;i=Fn()+ye[0][1]||o,ye.shift();var s=new XMLHttpRequest;s.upload&&e.support_options&&(s.upload.onprogress=function(c){n.onProgress(c.loaded,c.total)}),s.onreadystatechange=function(){if(s.readyState===4){var c=s.responseText||"{}";(c=JSON.parse(c)).filename=e.uniqueValue,c.uploadMethod=ze?ze.QINIU:"",s.status===200?n.onCompleted(c):ye.length?sn[ye[0][0]](t,e,n,r):n.onError("upload fail")}},e.isChunk&&(i=function(c,d){var l="";return Cc(d,function(h,a){h!=="token"&&(l+=(l?"&":"")+encodeURIComponent(h)+"="+encodeURIComponent(a))}),l&&(c+=(c.indexOf("?")>0?"&":"?")+l),c}(i+="/mkblk/"+t.size,e.multi_parmas)),s.open(e.method,i,!0),n.onOpen(s),e.stream&&s.setRequestHeader("authorization","UpToken "+e.multi_parmas.token),Cc(e.headers,function(c,d){s.setRequestHeader(c,d)}),s.send(t)},baidu:function(t,e,n,r){if(console.log(r,e),r.size>yc)throw new Error("the file size is over 5GB!");var i=e||{};e=e||Go;var o=new XMLHttpRequest,s=Fn();if(!(!i.uploadHost.bos&&!i.bosUploadPath)){var c=s+ye[0][1]+i.bosUploadPath;ye.shift();var d=i.bosHeader||{},l={filename:e.uniqueValue||r.uniqueName,name:r.name,downloadUrl:c,isBosRes:!0};o.upload&&e.support_options&&(o.upload.onprogress=function(h){n.onProgress(h.loaded,h.total,!0)}),o.onreadystatechange=function(){if(o.readyState===4){var h=o.responseText||"{}";(h=JSON.parse(h)).filename=e.uniqueValue,o.status===200?n.onCompleted(l,!0):ye.length?sn[ye[0][0]](t,e,n,r):n.onError("upload fail")}},o.open(e.method,c,!0),o.setRequestHeader("authorization",d.bosToken),o.setRequestHeader("x-bce-date",d.bosDate),o.send(r)}},aliyun:function(t,e,n,r){if(r.size>yc)throw new Error("the file size is over 5GB!");const i=new FormData;i.set("file",t.get("file")),i.set("key",t.get("key")),i.set("token",t.get("token"));const o=ye[0][1];ye.shift(),t=t||Gu,e=(e=e||{})||Go;var s=new XMLHttpRequest,c=Fn()+e.ossBucketName+"."+o;s.upload&&e.support_options&&(s.upload.onprogress=function(l){n.onProgress(l.loaded,l.total)}),s.onreadystatechange=function(){if(s.readyState===4){var l=s.responseText||"{}";(l=JSON.parse(l)).name=e.uniqueValue,l.filename=e.uploadFileName,l.uploadMethod=ze?ze.ALI:"",s.status===200?n.onCompleted(l):ye.length?sn[ye[0][0]](i,e,n,r):n.onError("upload fail")}},s.open(e.method,c,!0),console.log("ali:url",c);var d=e.aliHeader||{};t.set("OSSAccessKeyId",d.osskeyId),t.set("policy",d.ossPolicy),t.set("Signature",d.ossSign),t.set("success_action_status",200),t.delete("key"),t.append("key",e.uploadFileName),t.delete("file"),t.append("file",r),s.send(t)},s3:function(t,e,n,r){var i=new FormData,o=new XMLHttpRequest,s=Fn();const c=ye[0][1];var d=s+e.s3BucketName+"."+c;console.log("uploadS3:url",d),ye.shift(),o.upload&&e.support_options&&(o.upload.onprogress=function(a){n.onProgress(a.loaded,a.total)}),o.onreadystatechange=function(){if(o.readyState===4){var a=o.responseText||"{}";if((a=JSON.parse(a)).name=e.uniqueValue,a.filename=e.uploadFileName,a.uploadMethod=ze.AWS,console.log("UploadMethod:",ze),o.status===200||o.status===204)n.onCompleted(a);else if(ye.length){const u=new FormData;u.set("file",t.get("file")),u.set("key",t.get("key")),u.set("token",t.get("token")),sn[ye[0][0]](u,e,n,r)}else n.onError("upload fail")}},o.open(e.method,d,!0);var l=e?e.s3Header:{},h=r&&r.type;h==="text/html"?i.set("Content-Disposition","inline;"):i.set("Content-Disposition","attachment;"),i.set("Content-Type",h),i.set("x-amz-credential",l.s3Credential),i.set("x-amz-algorithm",l.s3Algorithm),i.set("x-amz-date",l.s3Date),i.set("policy",l.s3Policy),i.set("x-amz-signature",l.s3Signature),i.set("key",e.uploadFileName),i.set("file",r),o.send(i)},stc:function(t,e,n,r){new FormData;var i=new XMLHttpRequest;Fn();var o="https://"+ye[0][1]+"/"+e.stcBucketName+"/"+e.uploadFileName;ye.shift(),i.upload&&e.support_options&&(i.upload.onprogress=function(c){n.onProgress(c.loaded,c.total)}),i.onreadystatechange=function(){if(i.readyState===4){var c=i.responseText||"{}";if((c=JSON.parse(c)).name=e.uniqueValue,c.filename=e.uploadFileName,c.uploadMethod=ze?ze.STC:"",i.status===200||i.status===204)n.onCompleted(c);else if(ye.length){const d=new FormData;d.set("file",t.get("file")),d.set("key",t.get("key")),d.set("token",t.get("token")),sn[ye[0][0]](d,e,n,r)}else n.onError("upload fail")}},i.open("PUT",o,!0);var s=e?e.stcHeader:{};i.setRequestHeader("Content-Type",r.type),r.type==="text/html"?i.setRequestHeader("Content-Disposition","inline;"):i.setRequestHeader("Content-Disposition","attachment;"),i.setRequestHeader("Authorization",s.stcAuthorization),i.setRequestHeader("x-amz-content-sha256",s.stcContentSha256),i.setRequestHeader("x-amz-date",s.stcDate),i.send(r)}},ye=[],yc=5368709120;function Cc(t,e){for(var n in t)e(n,t[n])}function Fn(){var t="https://";return location.protocol!=="http:"&&location.protocol!=="file:"||(t="http://"),t}function yf(t,e,n){var r,i,o=t&&t.type||"text/plain",s=o.indexOf("image")>-1?1:4,c=Math.ceil(t.size/e.stc_chunk_size),d=e&&JSON.parse(e.ossConfig?e.ossConfig:"");Array.isArray(d)||(d=[]);var l=d.find(m=>Object.keys(m).includes("stc")),h="uploads";ht.imClient.getFileToken(s,r,"POST",h).then(function(m){r=m.fileName,i="https://"+l.stc+"/"+e.stcBucketName+"/"+r,console.log("uploadStcMultipart:url",i);var _=new XMLHttpRequest;_.open("POST",i+"?"+h,!0),o==="text/html"?_.setRequestHeader("Content-Disposition","inline;"):_.setRequestHeader("Content-Disposition","attacshment;"),_.setRequestHeader("Authorization",m&&m.stcAuthorization),_.setRequestHeader("x-amz-content-sha256",m&&m.stcContentSha256),_.setRequestHeader("x-amz-date",m&&m.stcDate),_.setRequestHeader("Content-Type",o),_.send(),_.onreadystatechange=function(v){if(_.readyState===4){var y=_.response.match(/(?:)(\S*?)(?:<\/UploadId>)/);console.log("uploadId",y),_.status===200||_.status===204?function(C){for(var w=[],P=1;P<=c;P++)w.push(p(C,P));f(C,w)}(Array.isArray(y)&&y[1]):n.onError("uploadStcMultipart:did not get uploadId")}}},function(m){n.onError("uploadStcMultipart:"+m)});var a=[],u=new Map;function f(m,_){_&&Array.isArray(_)&&_.length!==0&&Promise.all(_).then(()=>{var v="uploadId="+m;if(u.size===c)ht.imClient.context.getFileToken(s,r,"POST",v).then(function(w){console.log("onSuccess",w),console.log("onSuccess:uploadId",m);var P=new XMLHttpRequest;P.open("POST",i+"?"+v,!0),P.setRequestHeader("Authorization",w&&w.stcAuthorization),P.setRequestHeader("x-amz-content-sha256",w&&w.stcContentSha256),P.setRequestHeader("x-amz-date",w&&w.stcDate),P.setRequestHeader("Content-Type",o);var T="",E=Array.from(u.keys()||[]).sort((O,B)=>O-B);console.log("keys",E),E.map(O=>{T+=`${u.get(O)}${O}`}),T+="",P.send(T),console.log("xml",T),P.onreadystatechange=function(){if(P.readyState===4)if(P.status===200||P.status===204){var O={};O.name=t.name,O.filename=e.uploadFileName,O.uploadMethod=ze.STC,n.onCompleted(O)}else n.onError("uploadStcMultipart:upload does not end")}},function(w){n.onError("uploadStcMultipart:"+w)});else{var y=[];for(var C of a)y.push(p(m,C));f(m,y)}},v=>{console.error(v),n.onError("uploadStcMultipart: chunkFiles upload failed and those will reupload");var y=[];for(var C of a)y.push(p(m,C));f(m,y)})}function p(m,_){return new Promise((v,y)=>{var C="partNumber="+_+"&uploadId="+m;ht.imClient.context.getFileToken(s,r,"PUT",C).then(function(w){console.log("signature "+_+" onSuccess",w);var P=t&&t.slice((_-1)*e.stc_chunk_size,_*e.stc_chunk_size);console.log("fileChunk:size",P.size);var T=new XMLHttpRequest;T.open("PUT",i+"?"+C,!0),T.setRequestHeader("Authorization",w&&w.stcAuthorization),T.setRequestHeader("x-amz-content-sha256",w&&w.stcContentSha256),T.setRequestHeader("x-amz-date",w&&w.stcDate),T.setRequestHeader("Content-Type",o),T.send(P),T.onreadystatechange=function(){if(T.readyState===4)if(T.status===200||T.status===204){var E=T.getResponseHeader("etag");console.log("etag:"+_,E),u.set(_,E),v(E)}else a.includes(_)||a.push(_),y(_)}},function(w){console.log("getETags:\u7B7E\u540D\u9A8C\u8BC1\u5931\u8D25"),a.includes(_)||a.push(_),y(_)})})}}var Yu={form:function(t,e){var n=new FormData;if(e.unique_key){var r=t.name.substr(t.name.lastIndexOf(".")),i=Yo()+r;n.append(e.unique_key,i),e.uniqueValue=i}return n.append(e.file_data_name,t),Wo(e.multi_parmas,function(o,s){n.append(o,s)}),n},json:function(t,e){var n={};if(e.unique_key){var r=t.name.substr(t.name.lastIndexOf(".")),i=Yo()+r;n[e.unique_key]=i,e.uniqueValue=i}return n[e.file_data_name]=t,Wo(e.multi_parmas,function(o,s){n[o]=s}),JSON.stringify(n)},data:function(t,e){return t}};function Yo(){var t=new Date().getTime();return"xxxxxx4xxxyxxxxxxx".replace(/[xy]/g,function(e){var n=(t+16*Math.random())%16|0;return t=Math.floor(t/16),(e==="x"?n:3&n|8).toString(16)})}function Wo(t,e){for(var n in t)e(n,t[n])}var Ar,io=0;function Cf(t){this.options=function(e){var n={domain:"",method:"POST",file_data_name:"file",unique_key:"key",base64_size:4194304,chunk_size:4194304,bos_chunk_size:4294967296,stc_chunk_size:10485760,headers:{},multi_parmas:{},query:{},support_options:!0,data:Yu.form,genUId:Yo};if(!e||!e.domain)throw new Error("domain is null");for(var r in e)n[r]=e[r];return n}(t),this.setOptions=function(e){var n=this;Wo(e,function(r,i){n.options[r]=i})},console.log("options",t),this.upload=function(e,n){if(e){var r=this;(function(i,o,s){if(Gu=i,Go=o,ye=[],o.ossConfig){const h=JSON.parse(o.ossConfig);let a,u,f="";const p=[];h.forEach(m=>{const _=Number(m.p)-1;for(const v in m)v==="aliyun"&&(f=m[v]),v==="s3"&&(a=m[v]),v==="stc"&&(u=m[v]),v!=="p"&&(p[_]=[v,m[v]])}),p.forEach(function(m){m&&ye.push(m)}),h.length!==ye.length&&(ye=[["qiniu",o.domain],["baidu",o.uploadHost.bos],["aliyun",f],["s3",a],["stc",u]])}else ye=[["qiniu",o.domain],["baidu",o.uploadHost.bos]];var c;if(o.ossConfig){var d=o&&JSON.parse(o.ossConfig);Array.isArray(d)||(d=[]),c=d.find(h=>Object.keys(h).includes("stc"))}if(c&&parseInt(c.p)===1&&i.size>=4194304)yf(i,o,s);else{var l=o.data(i,o);sn[ye[0][0]](l,o,s,i)}})(e,this.options,{onProgress:function(i,o,s){Ar=i,s?Ar=io+i/o*(o-io):io=Ar,n.onProgress(Ar,o)},onCompleted:function(i){n.onCompleted(i)},onError:function(i){n.onError(i)},onOpen:function(i){r.xhr=i}})}else n.onError("upload file is null.")},this.cancel=function(){this.xhr&&this.xhr.abort()}}var Ec={init:function(t){return new Cf(t)},dataType:Yu,resize:function(t,e,n){t.type;var r=document.createElement("canvas"),i=new FileReader;i.readAsDataURL(t),i.onload=function(o){var s=o.target.result,c=new Image;c.src=s;var d=c.width,l=c.height,h=function(u,f){var p=1,m=u.width,_=f.maxWidth||0;_>0&&m>_&&(p=_/m);var v=u.height,y=f.maxHeight||0;if(y>0&&v>y){var C=y/v;p=Math.min(p,C)}var w=f.maxSize||0,P=Math.ceil(u.size/1e3);if(P>w){var T=w/P;p=Math.min(p,T)}return p}({width:d,height:l,size:o.total},e),a=s;h<1&&(a=function(u,f,p){r.width=f,r.height=p,r.getContext("2d").drawImage(u,0,0,f,p);var m="image/jpg";return r.toDataURL(m)}(c,d*h,l*h)),n(a)}}};const Ef=function(t,e,n){var r=document.createElement("canvas"),i=r.getContext("2d"),o=new Image;o.onload=function(){var s=function(l,h,a){var u,f,p,m=la.scale?(m?(f=100,v=((p=h/(u=l/100))-a.maxHeight)/2):(p=100,_=((f=l/(u=h/100))-a.maxWidth)/2),{w:f,h:p,x:-_,y:-v}):(m?(u=h/a.maxHeight,p=a.maxHeight,f=l/u):(u=l/a.maxWidth,f=a.maxWidth,p=h/u),{w:f,h:p,x:-_,y:-v})}(o.width,o.height,e);r.width=s.w>e.maxWidth?e.maxWidth:s.w,r.height=s.h>e.maxHeight?e.maxHeight:s.h,i.drawImage(o,s.x,s.y,s.w,s.h);try{var c=r.toDataURL(t.type,e.quality),d=new RegExp("^data:image/[^;]+;base64,");c=c.replace(d,""),n(c)}catch(l){throw new Error(l)}},o.src=typeof t=="string"?"data:image/jpg;base64,"+t:function(s){var c=window.URL||window.webkitURL;return c?c.createObjectURL(s):""}(t)},Rf=function(t,e){var n=t.file,r=t.compress;Ef(n,r,e)},Wu=function(t,e){if(t.getToken)t.getToken(function(r,i){i=i||{},t.multi_parmas||(t.multi_parmas={}),t.multi_parmas.token=r,t.uploadHost||(t.uploadHost={}),t.uploadHost.bos=i.bos,t.ossConfig=i.ossConfig,t.bosHeader||(t.bosHeader={}),t.bosHeader.bosDate=i.bosDate,t.bosHeader.bosToken=i.bosToken,t.bosUploadPath=i.path,t.aliHeader={},t.aliHeader.osskeyId=i.osskeyId,t.aliHeader.ossPolicy=i.ossPolicy,t.aliHeader.ossSign=i.ossSign,t.ossBucketName=i.ossBucketName,t.uploadFileName=i.fileName,t.s3Header={},t.s3Header.s3Credential=i.s3Credential,t.s3Header.s3Algorithm=i.s3Algorithm,t.s3Header.s3Date=i.s3Date,t.s3Header.s3Policy=i.s3Policy,t.s3Header.s3Signature=i.s3Signature,t.s3BucketName=i.s3BucketName,t.stcHeader={},t.stcHeader.stcAuthorization=i.stcAuthorization,t.stcHeader.stcContentSha256=i.stcContentSha256,t.stcHeader.stcDate=i.stcDate,t.stcBucketName=i.stcBucketName,t.headers||(t.headers={}),t.base64&&(t.headers["Content-type"]="application/octet-stream",t.headers.Authorization="UpToken "+r),console.log("data",i);var o=Ec.init(t);e(o)});else{t.headers||(t.headers={}),t.base64&&(t.headers["Content-type"]="application/octet-stream");var n=Ec.init(t);e(n)}};var oo,Mr,Ju=function(t,e,n){e.upload(t.file,{onError:function(r){n.onError(r)},onProgress:function(r,i){n.onProgress(r,i)},onCompleted:function(r){r.filename||(r.filename=r.hash);var i=t.compressThumbnail||Rf;t.compress?i(t,function(o){r.thumbnail=o,n.onCompleted(r)}):n.onCompleted(r)}})},Tf=function(t){var e=this;this.instance=t,this.upload=function(n,r){Ju({file:n},e.instance,r)},this.cancel=function(){e.instance.cancel()}},Sf=function(t,e){var n=this;this.cfg=e,this.instance=t,this.upload=function(r,i){var o={file:r,compress:n.cfg};Ju(o,n.instance,i)},this.cancel=function(){n.instance.cancel()}},If=function(t,e){Wu(t,function(n){var r={maxHeight:t.maxHeight||160,maxWidth:t.maxWidth||160,quality:t.quality||.5,scale:t.scale||2.4},i=new Sf(n,r);e(i)})},bf=function(t,e){Wu(t,function(n){var r=new Tf(n);e(r)})},wf=If;function Rc(t){return oo=oo||new AudioContext,new Promise(function(e,n){oo.decodeAudioData(t,function(r){e({duration:r.duration,length:r.length})},n)})}function Of(t,e,n,r,i){return Be("fileType",t,Xl,!0),Be("filename",e,Le.STRING),Be("saveName",n,Le.STRING),Be("serverType",i,Le.NUMBER),new Promise(function(o){ht.imClient.context.getFileUrl(t,e,n,r,i).then(function(s){o({code:M.SUCCESS,data:s})}).catch(function(s){o({code:s})})})}function zu(t,e,n){return sr(this,void 0,void 0,function(){var r,i,o,s,c,d,l,h,a;return ar(this,function(u){switch(u.label){case 0:return n=n||{},e instanceof qu?(Be("conversation.channelId",t==null?void 0:t.channelId,Le.CHANNEL_ID),r=t.conversationType,i=t.targetId,o=t.channelId,s="conversationType:"+r+",targetId:"+i,Je.debug("send message ->"+s),(c=Object.assign(n,e)).channelId=o||"",[4,ht.imClient.context.sendMessage(r,i,c)]):(Je.warn("send message fail -> message parameter is not an instance of BaseMessage"),[2,ai.ILLGAL_PARAMS]);case 1:return d=u.sent(),l=d.code,h=d.data,l===M.SUCCESS?(a=si(h),[2,{code:l,data:a}]):(Je.warn("send message fail ->"+l+":"+_n[l]+","+s),[2,{code:l,msg:_n[l],data:si({isMentioned:!!n.isMentioned,content:e.content,messageType:e.messageType,isPersited:e.isPersited||!1,isCounted:e.isCounted||!1,disableNotification:!!(n==null?void 0:n.disableNotification),canIncludeExpansion:!!(n==null?void 0:n.canIncludeExpansion),expansion:(n==null?void 0:n.expansion)||null,conversationType:r,targetId:i,channelId:o||"",senderUserId:ht.imClient.context.getCurrentUserId(),messageUId:"",messageDirection:ct.SEND,isOffLineMessage:!1,sentTime:(h==null?void 0:h.sentTime)||0,receivedTime:0,isStatusMessage:n.isStatusMessage||!1,receivedStatus:Xn.UNREAD})}])}})})}function pr(t,e){return function(n,r,i,o){return new Promise(function(s){var c;(function(d,l,h,a){var u,f=this;if(l===void 0&&(l=Ue.FILE),u=l===Ue.IMAGE?Ue.IMAGE:Ue.FILE,!Mr){Mr="upload.qiniup.com";var p=ht.imClient.context.getInfoFromCache();if(p&&p.ossConfig)try{var m=JSON.parse(p.ossConfig).find(function(v){return v.qiniu!==void 0});m&&(Mr=m.qiniu)}catch{}}var _=qo({domain:Mr,getToken:function(v){ht.imClient.context.getFileToken(u).then(function(y){v(y.token,y)}).catch(function(y){h.onFail(y)})}},a);(u===Ue.IMAGE?wf:bf)(_,function(v){v.upload(d,{onProgress:function(y,C){var w,P=Math.floor(y/C*100);(w=h.onProgress)===null||w===void 0||w.call(h,P)},onCompleted:function(y){return sr(f,void 0,void 0,function(){var C=this;return ar(this,function(w){return Of(u,y.filename,y.name,y,y.uploadMethod).then(function(P){return sr(C,void 0,void 0,function(){var T,E;return ar(this,function(O){return P.code!==0?(h.onFail(P),[2]):((T=P.data).type=d.type,T.name=y.name||y.filename,l===Ue.AUDIO?(typeof d.arrayBuffer=="function"?d.arrayBuffer().then(Rc).then(function(B){Object.assign(T,B),h.onSuccess(T)},function(){h.onSuccess(T)}):((E=new FileReader).onload=function(){E.result?Rc(E.result).then(function(B){Object.assign(T,B),h.onSuccess(T)},function(){h.onSuccess(T)}):h.onSuccess(T)},E.onerror=function(){T.duration=0,h.onSuccess(T)},E.readAsArrayBuffer(d)),[2]):(u===Ue.IMAGE&&(T.thumbnail=y.thumbnail),h.onSuccess(T),[2]))})})}).catch(function(P){h.onFail(P)}),[2]})})},onError:function(y){h.onFail(y)}})})})(r.file,t,{onProgress:i==null?void 0:i.onProgress,onSuccess:function(d){var l,h=((l=i==null?void 0:i.onComplete)===null||l===void 0?void 0:l.call(i,{url:d.downloadUrl}))||e(d,r);zu(n,h,o).then(s)},onFail:function(d){s({code:M.UPLOAD_FILE_FAILED,msg:d||M[M.UPLOAD_FILE_FAILED]})}},((c=o)===null||c===void 0?void 0:c.thumbnailConfig)||{})})}}pr(Ue.FILE,function(t,e){return new vf({name:t.name,size:e.file.size,type:e.file.type,fileUrl:t.downloadUrl,user:e.user,extra:e.extra})});pr(Ue.IMAGE,function(t,e){return new ff({content:t.thumbnail,imageUri:t.downloadUrl,user:e.user,extra:e.extra})});pr(Ue.AUDIO,function(t,e){return new pf({remoteUrl:t.downloadUrl,duration:t.duration,type:t.type,user:e.user,extra:e.extra})});pr(Ue.SIGHT,function(t,e){return new gf({sightUrl:t.downloadUrl,content:e.thumbnail,duration:e.duration,size:e.file.size||t.size,name:e.name||t.name,user:e.user,extra:e.extra})});function On(t,e,n,r){return Be("messageType",t,Le.STRING,!0),Be("isPersited",e,Le.BOOLEAN,!0),Be("isCounted",n,Le.BOOLEAN,!0),ht.imClient.context.registerMessageType(t,e,n,r),dt(t,e,n)}pr(Ue.COMBINE_HTML,function(t,e){return new _f({remoteUrl:t.downloadUrl,nameList:e.nameList,summaryList:e.summaryList,conversationType:e.conversationType,user:e.user,extra:e.extra})});Xt.add("imlib","5.1.1"),Xt.validEngine("~5.1.1")||Je.error("The current engine version '"+Xt.getInfo().engine+"' error\uFF0Cimlib required engine version at least '~5.1.1'.");/*! ***************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */function q(t,e,n,r){return new(n||(n=Promise))(function(i,o){function s(l){try{d(r.next(l))}catch(h){o(h)}}function c(l){try{d(r.throw(l))}catch(h){o(h)}}function d(l){var h;l.done?i(l.value):(h=l.value,h instanceof n?h:new n(function(a){a(h)})).then(s,c)}d((r=r.apply(t,e||[])).next())})}const k=new jt("RCRTC");var L,Jo;(function(t){t[t.SUCCESS=1e4]="SUCCESS",t[t.SIGNAL_DISCONNECTED=5e4]="SIGNAL_DISCONNECTED",t[t.PARAMS_ERROR=50001]="PARAMS_ERROR",t[t.REPERT_JOIN_ROOM=50002]="REPERT_JOIN_ROOM",t[t.NOT_IN_ROOM=50003]="NOT_IN_ROOM",t[t.SERVICE_INVALID=50004]="SERVICE_INVALID",t[t.RTC_TOKEN_INVALID=50006]="RTC_TOKEN_INVALID",t[t.SIGNAL_ERROR=53001]="SIGNAL_ERROR",t[t.CREATE_OFFER_FAILED=53003]="CREATE_OFFER_FAILED",t[t.REQUEST_FAILED=53004]="REQUEST_FAILED",t[t.MCU_SERVER_NOT_FOUND=53005]="MCU_SERVER_NOT_FOUND",t[t.BROADCAST_SUB_LIST_NOT_EMPTY=53007]="BROADCAST_SUB_LIST_NOT_EMPTY",t[t.ROOM_HAS_BEEN_DESTROYED=53008]="ROOM_HAS_BEEN_DESTROYED",t[t.NOT_OPEN_VIDEO_AUDIO_SERVER=53009]="NOT_OPEN_VIDEO_AUDIO_SERVER",t[t.GET_USER_MEDIA_FAILED=53010]="GET_USER_MEDIA_FAILED",t[t.GET_DISPLAY_MEDIA_FAILED=53011]="GET_DISPLAY_MEDIA_FAILED",t[t.PERMISSION_DENIED=53012]="PERMISSION_DENIED",t[t.CREATE_CUSTOM_TRACK_FAILED=53013]="CREATE_CUSTOM_TRACK_FAILED",t[t.INVALID_TAGS=53014]="INVALID_TAGS",t[t.INVALID_USER_ID=53015]="INVALID_USER_ID",t[t.CREATE_FILE_TRACK_FAILED=53016]="CREATE_FILE_TRACK_FAILED",t[t.INVALID_FILE_INSTANCE=53017]="INVALID_FILE_INSTANCE",t[t.SET_REMOTE_DESCRIPTION_FAILED=53018]="SET_REMOTE_DESCRIPTION_FAILED",t[t.BROWSER_NOT_SUPPORT=53019]="BROWSER_NOT_SUPPORT",t[t.TRACK_NOT_READY=53020]="TRACK_NOT_READY",t[t.VIDEO_TRACK_MISS_MEDIA_ELEMENT=53021]="VIDEO_TRACK_MISS_MEDIA_ELEMENT",t[t.TRACK_PLAY_ERROR=53022]="TRACK_PLAY_ERROR",t[t.SIGNAL_AUDIENCE_JOIN_ROOM_FAILED=53023]="SIGNAL_AUDIENCE_JOIN_ROOM_FAILED",t[t.SIGNAL_ROOM_CHANGE_IDENTITY_FAILED=53024]="SIGNAL_ROOM_CHANGE_IDENTITY_FAILED",t[t.PACKAGE_ENVIRONMENT_ERROR=53025]="PACKAGE_ENVIRONMENT_ERROR",t[t.PUBLISH_TRACK_LIMIT_EXCEEDED=53026]="PUBLISH_TRACK_LIMIT_EXCEEDED",t[t.CDN_RESOURCE_IS_EMPTY=53027]="CDN_RESOURCE_IS_EMPTY",t[t.SIGNAL_JOIN_RTC_ROOM_REFUSED=53028]="SIGNAL_JOIN_RTC_ROOM_REFUSED",t[t.NO_PERMISSION_TO_USE_REQUESTED_DEVICE=53029]="NO_PERMISSION_TO_USE_REQUESTED_DEVICE",t[t.THE_FUNCTION_IS_DISABLED_IN_PKROOM=53030]="THE_FUNCTION_IS_DISABLED_IN_PKROOM"})(L||(L={})),function(t){t[t.JOIN_REFUSED=40032]="JOIN_REFUSED"}(Jo||(Jo={}));class Qu{constructor(){this.queue=[],this.locked=!1}checkToStart(){return q(this,void 0,void 0,function*(){if(this.queue.length===0||this.locked)return;this.locked=!0;const{resolve:e,task:n,reject:r}=this.queue.shift();let i;try{i=yield n(),e(i)}catch(o){r(o)}this.locked=!1,this.checkToStart()})}push(e){const n=new Promise((r,i)=>{this.queue.push({resolve:r,task:e,reject:i})});return this.checkToStart(),n}}const Nf=new Qu,we=t=>Nf.push(t);let Xu=!0,Zu=!0;function Hn(t,e,n){const r=t.match(e);return r&&r.length>=n&&parseInt(r[n],10)}function Nn(t,e,n){if(!t.RTCPeerConnection)return;const r=t.RTCPeerConnection.prototype,i=r.addEventListener;r.addEventListener=function(s,c){if(s!==e)return i.apply(this,arguments);const d=l=>{const h=n(l);h&&(c.handleEvent?c.handleEvent(h):c(h))};return this._eventMap=this._eventMap||{},this._eventMap[e]||(this._eventMap[e]=new Map),this._eventMap[e].set(c,d),i.apply(this,[s,d])};const o=r.removeEventListener;r.removeEventListener=function(s,c){if(s!==e||!this._eventMap||!this._eventMap[e])return o.apply(this,arguments);if(!this._eventMap[e].has(c))return o.apply(this,arguments);const d=this._eventMap[e].get(c);return this._eventMap[e].delete(c),this._eventMap[e].size===0&&delete this._eventMap[e],Object.keys(this._eventMap).length===0&&delete this._eventMap,o.apply(this,[s,d])},Object.defineProperty(r,"on"+e,{get(){return this["_on"+e]},set(s){this["_on"+e]&&(this.removeEventListener(e,this["_on"+e]),delete this["_on"+e]),s&&this.addEventListener(e,this["_on"+e]=s)},enumerable:!0,configurable:!0})}function Af(t){return typeof t!="boolean"?new Error("Argument type: "+typeof t+". Please use a boolean."):(Xu=t,t?"adapter.js logging disabled":"adapter.js logging enabled")}function Mf(t){return typeof t!="boolean"?new Error("Argument type: "+typeof t+". Please use a boolean."):(Zu=!t,"adapter.js deprecation warnings "+(t?"disabled":"enabled"))}function da(){if(typeof window=="object"){if(Xu)return;typeof console!="undefined"&&typeof console.log=="function"&&console.log.apply(console,arguments)}}function Ui(t,e){Zu&&console.warn(t+" is deprecated, please use "+e+" instead.")}function Tc(t){return Object.prototype.toString.call(t)==="[object Object]"}function ed(t){return Tc(t)?Object.keys(t).reduce(function(e,n){const r=Tc(t[n]),i=r?ed(t[n]):t[n],o=r&&!Object.keys(i).length;return i===void 0||o?e:Object.assign(e,{[n]:i})},{}):t}function zo(t,e,n){e&&!n.has(e.id)&&(n.set(e.id,e),Object.keys(e).forEach(r=>{r.endsWith("Id")?zo(t,t.get(e[r]),n):r.endsWith("Ids")&&e[r].forEach(i=>{zo(t,t.get(i),n)})}))}function Sc(t,e,n){const r=n?"outbound-rtp":"inbound-rtp",i=new Map;if(e===null)return i;const o=[];return t.forEach(s=>{s.type==="track"&&s.trackIdentifier===e.id&&o.push(s)}),o.forEach(s=>{t.forEach(c=>{c.type===r&&c.trackId===s.id&&zo(t,c,i)})}),i}const Ic=da;function td(t,e){const n=t&&t.navigator;if(!n.mediaDevices)return;const r=function(s){if(typeof s!="object"||s.mandatory||s.optional)return s;const c={};return Object.keys(s).forEach(d=>{if(d==="require"||d==="advanced"||d==="mediaSource")return;const l=typeof s[d]=="object"?s[d]:{ideal:s[d]};l.exact!==void 0&&typeof l.exact=="number"&&(l.min=l.max=l.exact);const h=function(a,u){return a?a+u.charAt(0).toUpperCase()+u.slice(1):u==="deviceId"?"sourceId":u};if(l.ideal!==void 0){c.optional=c.optional||[];let a={};typeof l.ideal=="number"?(a[h("min",d)]=l.ideal,c.optional.push(a),a={},a[h("max",d)]=l.ideal,c.optional.push(a)):(a[h("",d)]=l.ideal,c.optional.push(a))}l.exact!==void 0&&typeof l.exact!="number"?(c.mandatory=c.mandatory||{},c.mandatory[h("",d)]=l.exact):["min","max"].forEach(a=>{l[a]!==void 0&&(c.mandatory=c.mandatory||{},c.mandatory[h(a,d)]=l[a])})}),s.advanced&&(c.optional=(c.optional||[]).concat(s.advanced)),c},i=function(s,c){if(e.version>=61)return c(s);if((s=JSON.parse(JSON.stringify(s)))&&typeof s.audio=="object"){const d=function(l,h,a){h in l&&!(a in l)&&(l[a]=l[h],delete l[h])};d((s=JSON.parse(JSON.stringify(s))).audio,"autoGainControl","googAutoGainControl"),d(s.audio,"noiseSuppression","googNoiseSuppression"),s.audio=r(s.audio)}if(s&&typeof s.video=="object"){let d=s.video.facingMode;d=d&&(typeof d=="object"?d:{ideal:d});const l=e.version<66;if(d&&(d.exact==="user"||d.exact==="environment"||d.ideal==="user"||d.ideal==="environment")&&(!n.mediaDevices.getSupportedConstraints||!n.mediaDevices.getSupportedConstraints().facingMode||l)){let h;if(delete s.video.facingMode,d.exact==="environment"||d.ideal==="environment"?h=["back","rear"]:d.exact!=="user"&&d.ideal!=="user"||(h=["front"]),h)return n.mediaDevices.enumerateDevices().then(a=>{let u=(a=a.filter(f=>f.kind==="videoinput")).find(f=>h.some(p=>f.label.toLowerCase().includes(p)));return!u&&a.length&&h.includes("back")&&(u=a[a.length-1]),u&&(s.video.deviceId=d.exact?{exact:u.deviceId}:{ideal:u.deviceId}),s.video=r(s.video),Ic("chrome: "+JSON.stringify(s)),c(s)})}s.video=r(s.video)}return Ic("chrome: "+JSON.stringify(s)),c(s)},o=function(s){return e.version>=64?s:{name:{PermissionDeniedError:"NotAllowedError",PermissionDismissedError:"NotAllowedError",InvalidStateError:"NotAllowedError",DevicesNotFoundError:"NotFoundError",ConstraintNotSatisfiedError:"OverconstrainedError",TrackStartError:"NotReadableError",MediaDeviceFailedDueToShutdown:"NotAllowedError",MediaDeviceKillSwitchOn:"NotAllowedError",TabCaptureError:"AbortError",ScreenCaptureError:"AbortError",DeviceCaptureError:"AbortError"}[s.name]||s.name,message:s.message,constraint:s.constraint||s.constraintName,toString(){return this.name+(this.message&&": ")+this.message}}};if(n.getUserMedia=function(s,c,d){i(s,l=>{n.webkitGetUserMedia(l,c,h=>{d&&d(o(h))})})}.bind(n),n.mediaDevices.getUserMedia){const s=n.mediaDevices.getUserMedia.bind(n.mediaDevices);n.mediaDevices.getUserMedia=function(c){return i(c,d=>s(d).then(l=>{if(d.audio&&!l.getAudioTracks().length||d.video&&!l.getVideoTracks().length)throw l.getTracks().forEach(h=>{h.stop()}),new DOMException("","NotFoundError");return l},l=>Promise.reject(o(l))))}}}function nd(t){t.MediaStream=t.MediaStream||t.webkitMediaStream}function rd(t){if(typeof t=="object"&&t.RTCPeerConnection&&!("ontrack"in t.RTCPeerConnection.prototype)){Object.defineProperty(t.RTCPeerConnection.prototype,"ontrack",{get(){return this._ontrack},set(n){this._ontrack&&this.removeEventListener("track",this._ontrack),this.addEventListener("track",this._ontrack=n)},enumerable:!0,configurable:!0});const e=t.RTCPeerConnection.prototype.setRemoteDescription;t.RTCPeerConnection.prototype.setRemoteDescription=function(){return this._ontrackpoly||(this._ontrackpoly=n=>{n.stream.addEventListener("addtrack",r=>{let i;i=t.RTCPeerConnection.prototype.getReceivers?this.getReceivers().find(s=>s.track&&s.track.id===r.track.id):{track:r.track};const o=new Event("track");o.track=r.track,o.receiver=i,o.transceiver={receiver:i},o.streams=[n.stream],this.dispatchEvent(o)}),n.stream.getTracks().forEach(r=>{let i;i=t.RTCPeerConnection.prototype.getReceivers?this.getReceivers().find(s=>s.track&&s.track.id===r.id):{track:r};const o=new Event("track");o.track=r,o.receiver=i,o.transceiver={receiver:i},o.streams=[n.stream],this.dispatchEvent(o)})},this.addEventListener("addstream",this._ontrackpoly)),e.apply(this,arguments)}}else Nn(t,"track",e=>(e.transceiver||Object.defineProperty(e,"transceiver",{value:{receiver:e.receiver}}),e))}function id(t){if(typeof t=="object"&&t.RTCPeerConnection&&!("getSenders"in t.RTCPeerConnection.prototype)&&"createDTMFSender"in t.RTCPeerConnection.prototype){const e=function(i,o){return{track:o,get dtmf(){return this._dtmf===void 0&&(o.kind==="audio"?this._dtmf=i.createDTMFSender(o):this._dtmf=null),this._dtmf},_pc:i}};if(!t.RTCPeerConnection.prototype.getSenders){t.RTCPeerConnection.prototype.getSenders=function(){return this._senders=this._senders||[],this._senders.slice()};const i=t.RTCPeerConnection.prototype.addTrack;t.RTCPeerConnection.prototype.addTrack=function(s,c){let d=i.apply(this,arguments);return d||(d=e(this,s),this._senders.push(d)),d};const o=t.RTCPeerConnection.prototype.removeTrack;t.RTCPeerConnection.prototype.removeTrack=function(s){o.apply(this,arguments);const c=this._senders.indexOf(s);c!==-1&&this._senders.splice(c,1)}}const n=t.RTCPeerConnection.prototype.addStream;t.RTCPeerConnection.prototype.addStream=function(i){this._senders=this._senders||[],n.apply(this,[i]),i.getTracks().forEach(o=>{this._senders.push(e(this,o))})};const r=t.RTCPeerConnection.prototype.removeStream;t.RTCPeerConnection.prototype.removeStream=function(i){this._senders=this._senders||[],r.apply(this,[i]),i.getTracks().forEach(o=>{const s=this._senders.find(c=>c.track===o);s&&this._senders.splice(this._senders.indexOf(s),1)})}}else if(typeof t=="object"&&t.RTCPeerConnection&&"getSenders"in t.RTCPeerConnection.prototype&&"createDTMFSender"in t.RTCPeerConnection.prototype&&t.RTCRtpSender&&!("dtmf"in t.RTCRtpSender.prototype)){const e=t.RTCPeerConnection.prototype.getSenders;t.RTCPeerConnection.prototype.getSenders=function(){const n=e.apply(this,[]);return n.forEach(r=>r._pc=this),n},Object.defineProperty(t.RTCRtpSender.prototype,"dtmf",{get(){return this._dtmf===void 0&&(this.track.kind==="audio"?this._dtmf=this._pc.createDTMFSender(this.track):this._dtmf=null),this._dtmf}})}}function od(t){if(!t.RTCPeerConnection)return;const e=t.RTCPeerConnection.prototype.getStats;t.RTCPeerConnection.prototype.getStats=function(){const[n,r,i]=arguments;if(arguments.length>0&&typeof n=="function")return e.apply(this,arguments);if(e.length===0&&(arguments.length===0||typeof n!="function"))return e.apply(this,[]);const o=function(c){const d={};return c.result().forEach(l=>{const h={id:l.id,timestamp:l.timestamp,type:{localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[l.type]||l.type};l.names().forEach(a=>{h[a]=l.stat(a)}),d[h.id]=h}),d},s=function(c){return new Map(Object.keys(c).map(d=>[d,c[d]]))};if(arguments.length>=2){const c=function(d){r(s(o(d)))};return e.apply(this,[c,n])}return new Promise((c,d)=>{e.apply(this,[function(l){c(s(o(l)))},d])}).then(r,i)}}function sd(t){if(!(typeof t=="object"&&t.RTCPeerConnection&&t.RTCRtpSender&&t.RTCRtpReceiver))return;if(!("getStats"in t.RTCRtpSender.prototype)){const n=t.RTCPeerConnection.prototype.getSenders;n&&(t.RTCPeerConnection.prototype.getSenders=function(){const i=n.apply(this,[]);return i.forEach(o=>o._pc=this),i});const r=t.RTCPeerConnection.prototype.addTrack;r&&(t.RTCPeerConnection.prototype.addTrack=function(){const i=r.apply(this,arguments);return i._pc=this,i}),t.RTCRtpSender.prototype.getStats=function(){const i=this;return this._pc.getStats().then(o=>Sc(o,i.track,!0))}}if(!("getStats"in t.RTCRtpReceiver.prototype)){const n=t.RTCPeerConnection.prototype.getReceivers;n&&(t.RTCPeerConnection.prototype.getReceivers=function(){const r=n.apply(this,[]);return r.forEach(i=>i._pc=this),r}),Nn(t,"track",r=>(r.receiver._pc=r.srcElement,r)),t.RTCRtpReceiver.prototype.getStats=function(){const r=this;return this._pc.getStats().then(i=>Sc(i,r.track,!1))}}if(!("getStats"in t.RTCRtpSender.prototype)||!("getStats"in t.RTCRtpReceiver.prototype))return;const e=t.RTCPeerConnection.prototype.getStats;t.RTCPeerConnection.prototype.getStats=function(){if(arguments.length>0&&arguments[0]instanceof t.MediaStreamTrack){const n=arguments[0];let r,i,o;return this.getSenders().forEach(s=>{s.track===n&&(r?o=!0:r=s)}),this.getReceivers().forEach(s=>(s.track===n&&(i?o=!0:i=s),s.track===n)),o||r&&i?Promise.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):r?r.getStats():i?i.getStats():Promise.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return e.apply(this,arguments)}}function ad(t){t.RTCPeerConnection.prototype.getLocalStreams=function(){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},Object.keys(this._shimmedLocalStreams).map(o=>this._shimmedLocalStreams[o][0])};const e=t.RTCPeerConnection.prototype.addTrack;t.RTCPeerConnection.prototype.addTrack=function(o,s){if(!s)return e.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};const c=e.apply(this,arguments);return this._shimmedLocalStreams[s.id]?this._shimmedLocalStreams[s.id].indexOf(c)===-1&&this._shimmedLocalStreams[s.id].push(c):this._shimmedLocalStreams[s.id]=[s,c],c};const n=t.RTCPeerConnection.prototype.addStream;t.RTCPeerConnection.prototype.addStream=function(o){this._shimmedLocalStreams=this._shimmedLocalStreams||{},o.getTracks().forEach(d=>{if(this.getSenders().find(l=>l.track===d))throw new DOMException("Track already exists.","InvalidAccessError")});const s=this.getSenders();n.apply(this,arguments);const c=this.getSenders().filter(d=>s.indexOf(d)===-1);this._shimmedLocalStreams[o.id]=[o].concat(c)};const r=t.RTCPeerConnection.prototype.removeStream;t.RTCPeerConnection.prototype.removeStream=function(o){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},delete this._shimmedLocalStreams[o.id],r.apply(this,arguments)};const i=t.RTCPeerConnection.prototype.removeTrack;t.RTCPeerConnection.prototype.removeTrack=function(o){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},o&&Object.keys(this._shimmedLocalStreams).forEach(s=>{const c=this._shimmedLocalStreams[s].indexOf(o);c!==-1&&this._shimmedLocalStreams[s].splice(c,1),this._shimmedLocalStreams[s].length===1&&delete this._shimmedLocalStreams[s]}),i.apply(this,arguments)}}function cd(t,e){if(!t.RTCPeerConnection)return;if(t.RTCPeerConnection.prototype.addTrack&&e.version>=65)return ad(t);const n=t.RTCPeerConnection.prototype.getLocalStreams;t.RTCPeerConnection.prototype.getLocalStreams=function(){const l=n.apply(this);return this._reverseStreams=this._reverseStreams||{},l.map(h=>this._reverseStreams[h.id])};const r=t.RTCPeerConnection.prototype.addStream;t.RTCPeerConnection.prototype.addStream=function(l){if(this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},l.getTracks().forEach(h=>{if(this.getSenders().find(a=>a.track===h))throw new DOMException("Track already exists.","InvalidAccessError")}),!this._reverseStreams[l.id]){const h=new t.MediaStream(l.getTracks());this._streams[l.id]=h,this._reverseStreams[h.id]=l,l=h}r.apply(this,[l])};const i=t.RTCPeerConnection.prototype.removeStream;function o(l,h){let a=h.sdp;return Object.keys(l._reverseStreams||[]).forEach(u=>{const f=l._reverseStreams[u],p=l._streams[f.id];a=a.replace(new RegExp(p.id,"g"),f.id)}),new RTCSessionDescription({type:h.type,sdp:a})}function s(l,h){let a=h.sdp;return Object.keys(l._reverseStreams||[]).forEach(u=>{const f=l._reverseStreams[u],p=l._streams[f.id];a=a.replace(new RegExp(f.id,"g"),p.id)}),new RTCSessionDescription({type:h.type,sdp:a})}t.RTCPeerConnection.prototype.removeStream=function(l){this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},i.apply(this,[this._streams[l.id]||l]),delete this._reverseStreams[this._streams[l.id]?this._streams[l.id].id:l.id],delete this._streams[l.id]},t.RTCPeerConnection.prototype.addTrack=function(l,h){if(this.signalingState==="closed")throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");const a=[].slice.call(arguments,1);if(a.length!==1||!a[0].getTracks().find(p=>p===l))throw new DOMException("The adapter.js addTrack polyfill only supports a single stream which is associated with the specified track.","NotSupportedError");if(this.getSenders().find(p=>p.track===l))throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};const f=this._streams[h.id];if(f)f.addTrack(l),Promise.resolve().then(()=>{this.dispatchEvent(new Event("negotiationneeded"))});else{const p=new t.MediaStream([l]);this._streams[h.id]=p,this._reverseStreams[p.id]=h,this.addStream(p)}return this.getSenders().find(p=>p.track===l)},["createOffer","createAnswer"].forEach(function(l){const h=t.RTCPeerConnection.prototype[l],a={[l](){const u=arguments;return arguments.length&&typeof arguments[0]=="function"?h.apply(this,[f=>{const p=o(this,f);u[0].apply(null,[p])},f=>{u[1]&&u[1].apply(null,f)},arguments[2]]):h.apply(this,arguments).then(f=>o(this,f))}};t.RTCPeerConnection.prototype[l]=a[l]});const c=t.RTCPeerConnection.prototype.setLocalDescription;t.RTCPeerConnection.prototype.setLocalDescription=function(){return arguments.length&&arguments[0].type?(arguments[0]=s(this,arguments[0]),c.apply(this,arguments)):c.apply(this,arguments)};const d=Object.getOwnPropertyDescriptor(t.RTCPeerConnection.prototype,"localDescription");Object.defineProperty(t.RTCPeerConnection.prototype,"localDescription",{get(){const l=d.get.apply(this);return l.type===""?l:o(this,l)}}),t.RTCPeerConnection.prototype.removeTrack=function(l){if(this.signalingState==="closed")throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");if(!l._pc)throw new DOMException("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.","TypeError");if(l._pc!==this)throw new DOMException("Sender was not created by this connection.","InvalidAccessError");let h;this._streams=this._streams||{},Object.keys(this._streams).forEach(a=>{this._streams[a].getTracks().find(u=>l.track===u)&&(h=this._streams[a])}),h&&(h.getTracks().length===1?this.removeStream(this._reverseStreams[h.id]):h.removeTrack(l.track),this.dispatchEvent(new Event("negotiationneeded")))}}function Qo(t,e){!t.RTCPeerConnection&&t.webkitRTCPeerConnection&&(t.RTCPeerConnection=t.webkitRTCPeerConnection),t.RTCPeerConnection&&e.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(n){const r=t.RTCPeerConnection.prototype[n],i={[n](){return arguments[0]=new(n==="addIceCandidate"?t.RTCIceCandidate:t.RTCSessionDescription)(arguments[0]),r.apply(this,arguments)}};t.RTCPeerConnection.prototype[n]=i[n]})}function ud(t,e){Nn(t,"negotiationneeded",n=>{const r=n.target;if(!(e.version<72||r.getConfiguration&&r.getConfiguration().sdpSemantics==="plan-b")||r.signalingState==="stable")return n})}var bc=Object.freeze({__proto__:null,shimMediaStream:nd,shimOnTrack:rd,shimGetSendersWithDtmf:id,shimGetStats:od,shimSenderReceiverGetStats:sd,shimAddTrackRemoveTrackWithNative:ad,shimAddTrackRemoveTrack:cd,shimPeerConnection:Qo,fixNegotiationNeeded:ud,shimGetUserMedia:td,shimGetDisplayMedia:function(t,e){t.navigator.mediaDevices&&"getDisplayMedia"in t.navigator.mediaDevices||t.navigator.mediaDevices&&(typeof e=="function"?t.navigator.mediaDevices.getDisplayMedia=function(n){return e(n).then(r=>{const i=n.video&&n.video.width,o=n.video&&n.video.height,s=n.video&&n.video.frameRate;return n.video={mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:r,maxFrameRate:s||3}},i&&(n.video.mandatory.maxWidth=i),o&&(n.video.mandatory.maxHeight=o),t.navigator.mediaDevices.getUserMedia(n)})}:console.error("shimGetDisplayMedia: getSourceId argument is not a function"))}}),wc,so,ae=(wc=function(t){var e={generateIdentifier:function(){return Math.random().toString(36).substr(2,10)}};e.localCName=e.generateIdentifier(),e.splitLines=function(n){return n.trim().split(` `).map(function(r){return r.trim()})},e.splitSections=function(n){return n.split(` m=`).map(function(r,i){return(i>0?"m="+r:r).trim()+`\r `})},e.getDescription=function(n){var r=e.splitSections(n);return r&&r[0]},e.getMediaSections=function(n){var r=e.splitSections(n);return r.shift(),r},e.matchPrefix=function(n,r){return e.splitLines(n).filter(function(i){return i.indexOf(r)===0})},e.parseCandidate=function(n){for(var r,i={foundation:(r=n.indexOf("a=candidate:")===0?n.substring(12).split(" "):n.substring(10).split(" "))[0],component:parseInt(r[1],10),protocol:r[2].toLowerCase(),priority:parseInt(r[3],10),ip:r[4],address:r[4],port:parseInt(r[5],10),type:r[7]},o=8;o0?r[0].split("/")[1]:"sendrecv",uri:r[1]}},e.writeExtmap=function(n){return"a=extmap:"+(n.id||n.preferredId)+(n.direction&&n.direction!=="sendrecv"?"/"+n.direction:"")+" "+n.uri+`\r `},e.parseFmtp=function(n){for(var r,i={},o=n.substr(n.indexOf(" ")+1).split(";"),s=0;s-1?(i.attribute=n.substr(r+1,o-r-1),i.value=n.substr(o+1)):i.attribute=n.substr(r+1),i},e.parseSsrcGroup=function(n){var r=n.substr(13).split(" ");return{semantics:r.shift(),ssrcs:r.map(function(i){return parseInt(i,10)})}},e.getMid=function(n){var r=e.matchPrefix(n,"a=mid:")[0];if(r)return r.substr(6)},e.parseFingerprint=function(n){var r=n.substr(14).split(" ");return{algorithm:r[0].toLowerCase(),value:r[1]}},e.getDtlsParameters=function(n,r){return{role:"auto",fingerprints:e.matchPrefix(n+r,"a=fingerprint:").map(e.parseFingerprint)}},e.writeDtlsParameters=function(n,r){var i="a=setup:"+r+`\r `;return n.fingerprints.forEach(function(o){i+="a=fingerprint:"+o.algorithm+" "+o.value+`\r `}),i},e.parseCryptoLine=function(n){var r=n.substr(9).split(" ");return{tag:parseInt(r[0],10),cryptoSuite:r[1],keyParams:r[2],sessionParams:r.slice(3)}},e.writeCryptoLine=function(n){return"a=crypto:"+n.tag+" "+n.cryptoSuite+" "+(typeof n.keyParams=="object"?e.writeCryptoKeyParams(n.keyParams):n.keyParams)+(n.sessionParams?" "+n.sessionParams.join(" "):"")+`\r `},e.parseCryptoKeyParams=function(n){if(n.indexOf("inline:")!==0)return null;var r=n.substr(7).split("|");return{keyMethod:"inline",keySalt:r[0],lifeTime:r[1],mkiValue:r[2]?r[2].split(":")[0]:void 0,mkiLength:r[2]?r[2].split(":")[1]:void 0}},e.writeCryptoKeyParams=function(n){return n.keyMethod+":"+n.keySalt+(n.lifeTime?"|"+n.lifeTime:"")+(n.mkiValue&&n.mkiLength?"|"+n.mkiValue+":"+n.mkiLength:"")},e.getCryptoParameters=function(n,r){return e.matchPrefix(n+r,"a=crypto:").map(e.parseCryptoLine)},e.getIceParameters=function(n,r){var i=e.matchPrefix(n+r,"a=ice-ufrag:")[0],o=e.matchPrefix(n+r,"a=ice-pwd:")[0];return i&&o?{usernameFragment:i.substr(12),password:o.substr(10)}:null},e.writeIceParameters=function(n){return"a=ice-ufrag:"+n.usernameFragment+`\r a=ice-pwd:`+n.password+`\r `},e.parseRtpParameters=function(n){for(var r={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},i=e.splitLines(n)[0].split(" "),o=3;o0?"9":"0",i+=" UDP/TLS/RTP/SAVPF ",i+=r.codecs.map(function(s){return s.preferredPayloadType!==void 0?s.preferredPayloadType:s.payloadType}).join(" ")+`\r `,i+=`c=IN IP4 0.0.0.0\r `,i+=`a=rtcp:9 IN IP4 0.0.0.0\r `,r.codecs.forEach(function(s){i+=e.writeRtpMap(s),i+=e.writeFmtp(s),i+=e.writeRtcpFb(s)});var o=0;return r.codecs.forEach(function(s){s.maxptime>o&&(o=s.maxptime)}),o>0&&(i+="a=maxptime:"+o+`\r `),i+=`a=rtcp-mux\r `,r.headerExtensions&&r.headerExtensions.forEach(function(s){i+=e.writeExtmap(s)}),i},e.parseRtpEncodingParameters=function(n){var r,i=[],o=e.parseRtpParameters(n),s=o.fecMechanisms.indexOf("RED")!==-1,c=o.fecMechanisms.indexOf("ULPFEC")!==-1,d=e.matchPrefix(n,"a=ssrc:").map(function(u){return e.parseSsrcMedia(u)}).filter(function(u){return u.attribute==="cname"}),l=d.length>0&&d[0].ssrc,h=e.matchPrefix(n,"a=ssrc-group:FID").map(function(u){return u.substr(17).split(" ").map(function(f){return parseInt(f,10)})});h.length>0&&h[0].length>1&&h[0][0]===l&&(r=h[0][1]),o.codecs.forEach(function(u){if(u.name.toUpperCase()==="RTX"&&u.parameters.apt){var f={ssrc:l,codecPayloadType:parseInt(u.parameters.apt,10)};l&&r&&(f.rtx={ssrc:r}),i.push(f),s&&((f=JSON.parse(JSON.stringify(f))).fec={ssrc:l,mechanism:c?"red+ulpfec":"red"},i.push(f))}}),i.length===0&&l&&i.push({ssrc:l});var a=e.matchPrefix(n,"b=");return a.length&&(a=a[0].indexOf("b=TIAS:")===0?parseInt(a[0].substr(7),10):a[0].indexOf("b=AS:")===0?1e3*parseInt(a[0].substr(5),10)*.95-16e3:void 0,i.forEach(function(u){u.maxBitrate=a})),i},e.parseRtcpParameters=function(n){var r={},i=e.matchPrefix(n,"a=ssrc:").map(function(c){return e.parseSsrcMedia(c)}).filter(function(c){return c.attribute==="cname"})[0];i&&(r.cname=i.value,r.ssrc=i.ssrc);var o=e.matchPrefix(n,"a=rtcp-rsize");r.reducedSize=o.length>0,r.compound=o.length===0;var s=e.matchPrefix(n,"a=rtcp-mux");return r.mux=s.length>0,r},e.parseMsid=function(n){var r,i=e.matchPrefix(n,"a=msid:");if(i.length===1)return{stream:(r=i[0].substr(7).split(" "))[0],track:r[1]};var o=e.matchPrefix(n,"a=ssrc:").map(function(s){return e.parseSsrcMedia(s)}).filter(function(s){return s.attribute==="msid"});return o.length>0?{stream:(r=o[0].value.split(" "))[0],track:r[1]}:void 0},e.parseSctpDescription=function(n){var r,i=e.parseMLine(n),o=e.matchPrefix(n,"a=max-message-size:");o.length>0&&(r=parseInt(o[0].substr(19),10)),isNaN(r)&&(r=65536);var s=e.matchPrefix(n,"a=sctp-port:");if(s.length>0)return{port:parseInt(s[0].substr(12),10),protocol:i.fmt,maxMessageSize:r};if(e.matchPrefix(n,"a=sctpmap:").length>0){var c=e.matchPrefix(n,"a=sctpmap:")[0].substr(10).split(" ");return{port:parseInt(c[0],10),protocol:c[1],maxMessageSize:r}}},e.writeSctpDescription=function(n,r){var i=[];return i=n.protocol!=="DTLS/SCTP"?["m="+n.kind+" 9 "+n.protocol+" "+r.protocol+`\r `,`c=IN IP4 0.0.0.0\r `,"a=sctp-port:"+r.port+`\r `]:["m="+n.kind+" 9 "+n.protocol+" "+r.port+`\r `,`c=IN IP4 0.0.0.0\r `,"a=sctpmap:"+r.port+" "+r.protocol+` 65535\r `],r.maxMessageSize!==void 0&&i.push("a=max-message-size:"+r.maxMessageSize+`\r `),i.join("")},e.generateSessionId=function(){return Math.random().toString().substr(2,21)},e.writeSessionBoilerplate=function(n,r,i){var o=r!==void 0?r:2;return`v=0\r o=`+(i||"thisisadapterortc")+" "+(n||e.generateSessionId())+" "+o+` IN IP4 127.0.0.1\r s=-\r t=0 0\r `},e.writeMediaSection=function(n,r,i,o){var s=e.writeRtpDescription(n.kind,r);if(s+=e.writeIceParameters(n.iceGatherer.getLocalParameters()),s+=e.writeDtlsParameters(n.dtlsTransport.getLocalParameters(),i==="offer"?"actpass":"active"),s+="a=mid:"+n.mid+`\r `,n.direction?s+="a="+n.direction+`\r `:n.rtpSender&&n.rtpReceiver?s+=`a=sendrecv\r `:n.rtpSender?s+=`a=sendonly\r `:n.rtpReceiver?s+=`a=recvonly\r `:s+=`a=inactive\r `,n.rtpSender){var c="msid:"+o.id+" "+n.rtpSender.track.id+`\r `;s+="a="+c,s+="a=ssrc:"+n.sendEncodingParameters[0].ssrc+" "+c,n.sendEncodingParameters[0].rtx&&(s+="a=ssrc:"+n.sendEncodingParameters[0].rtx.ssrc+" "+c,s+="a=ssrc-group:FID "+n.sendEncodingParameters[0].ssrc+" "+n.sendEncodingParameters[0].rtx.ssrc+`\r `)}return s+="a=ssrc:"+n.sendEncodingParameters[0].ssrc+" cname:"+e.localCName+`\r `,n.rtpSender&&n.sendEncodingParameters[0].rtx&&(s+="a=ssrc:"+n.sendEncodingParameters[0].rtx.ssrc+" cname:"+e.localCName+`\r `),s},e.getDirection=function(n,r){for(var i=e.splitLines(n),o=0;o=14393&&_.indexOf("?transport=udp")===-1:(u=!0,!0)}),delete f.url,f.urls=m?p[0]:p,!!p.length}})}(s.iceServers||[],e),this._iceGatherers=[],s.iceCandidatePoolSize)for(var l=s.iceCandidatePoolSize;l>0;l--)this._iceGatherers.push(new t.RTCIceGatherer({iceServers:s.iceServers,gatherPolicy:s.iceTransportPolicy}));else s.iceCandidatePoolSize=0;this._config=s,this.transceivers=[],this._sdpSessionId=ae.generateSessionId(),this._sdpSessionVersion=0,this._dtlsRole=void 0,this._isClosed=!1};Object.defineProperty(i.prototype,"localDescription",{configurable:!0,get:function(){return this._localDescription}}),Object.defineProperty(i.prototype,"remoteDescription",{configurable:!0,get:function(){return this._remoteDescription}}),i.prototype.onicecandidate=null,i.prototype.onaddstream=null,i.prototype.ontrack=null,i.prototype.onremovestream=null,i.prototype.onsignalingstatechange=null,i.prototype.oniceconnectionstatechange=null,i.prototype.onconnectionstatechange=null,i.prototype.onicegatheringstatechange=null,i.prototype.onnegotiationneeded=null,i.prototype.ondatachannel=null,i.prototype._dispatchEvent=function(s,c){this._isClosed||(this.dispatchEvent(c),typeof this["on"+s]=="function"&&this["on"+s](c))},i.prototype._emitGatheringStateChange=function(){var s=new Event("icegatheringstatechange");this._dispatchEvent("icegatheringstatechange",s)},i.prototype.getConfiguration=function(){return this._config},i.prototype.getLocalStreams=function(){return this.localStreams},i.prototype.getRemoteStreams=function(){return this.remoteStreams},i.prototype._createTransceiver=function(s,c){var d=this.transceivers.length>0,l={track:null,iceGatherer:null,iceTransport:null,dtlsTransport:null,localCapabilities:null,remoteCapabilities:null,rtpSender:null,rtpReceiver:null,kind:s,mid:null,sendEncodingParameters:null,recvEncodingParameters:null,stream:null,associatedRemoteMediaStreams:[],wantReceive:!0};if(this.usingBundle&&d)l.iceTransport=this.transceivers[0].iceTransport,l.dtlsTransport=this.transceivers[0].dtlsTransport;else{var h=this._createIceAndDtlsTransports();l.iceTransport=h.iceTransport,l.dtlsTransport=h.dtlsTransport}return c||this.transceivers.push(l),l},i.prototype.addTrack=function(s,c){if(this._isClosed)throw Fe("InvalidStateError","Attempted to call addTrack on a closed peerconnection.");var d;if(this.transceivers.find(function(h){return h.track===s}))throw Fe("InvalidAccessError","Track already exists.");for(var l=0;l=15025)s.getTracks().forEach(function(l){c.addTrack(l,s)});else{var d=s.clone();s.getTracks().forEach(function(l,h){var a=d.getTracks()[h];l.addEventListener("enabled",function(u){a.enabled=u.enabled})}),d.getTracks().forEach(function(l){c.addTrack(l,d)})}},i.prototype.removeTrack=function(s){if(this._isClosed)throw Fe("InvalidStateError","Attempted to call removeTrack on a closed peerconnection.");if(!(s instanceof t.RTCRtpSender))throw new TypeError("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.");var c=this.transceivers.find(function(l){return l.rtpSender===s});if(!c)throw Fe("InvalidAccessError","Sender was not created by this connection.");var d=c.stream;c.rtpSender.stop(),c.rtpSender=null,c.track=null,c.stream=null,this.transceivers.map(function(l){return l.stream}).indexOf(d)===-1&&this.localStreams.indexOf(d)>-1&&this.localStreams.splice(this.localStreams.indexOf(d),1),this._maybeFireNegotiationNeeded()},i.prototype.removeStream=function(s){var c=this;s.getTracks().forEach(function(d){var l=c.getSenders().find(function(h){return h.track===d});l&&c.removeTrack(l)})},i.prototype.getSenders=function(){return this.transceivers.filter(function(s){return!!s.rtpSender}).map(function(s){return s.rtpSender})},i.prototype.getReceivers=function(){return this.transceivers.filter(function(s){return!!s.rtpReceiver}).map(function(s){return s.rtpReceiver})},i.prototype._createIceGatherer=function(s,c){var d=this;if(c&&s>0)return this.transceivers[0].iceGatherer;if(this._iceGatherers.length)return this._iceGatherers.shift();var l=new t.RTCIceGatherer({iceServers:this._config.iceServers,gatherPolicy:this._config.iceTransportPolicy});return Object.defineProperty(l,"state",{value:"new",writable:!0}),this.transceivers[s].bufferedCandidateEvents=[],this.transceivers[s].bufferCandidates=function(h){var a=!h.candidate||Object.keys(h.candidate).length===0;l.state=a?"completed":"gathering",d.transceivers[s].bufferedCandidateEvents!==null&&d.transceivers[s].bufferedCandidateEvents.push(h)},l.addEventListener("localcandidate",this.transceivers[s].bufferCandidates),l},i.prototype._gather=function(s,c){var d=this,l=this.transceivers[c].iceGatherer;if(!l.onlocalcandidate){var h=this.transceivers[c].bufferedCandidateEvents;this.transceivers[c].bufferedCandidateEvents=null,l.removeEventListener("localcandidate",this.transceivers[c].bufferCandidates),l.onlocalcandidate=function(a){if(!(d.usingBundle&&c>0)){var u=new Event("icecandidate");u.candidate={sdpMid:s,sdpMLineIndex:c};var f=a.candidate,p=!f||Object.keys(f).length===0;if(p)l.state!=="new"&&l.state!=="gathering"||(l.state="completed");else{l.state==="new"&&(l.state="gathering"),f.component=1,f.ufrag=l.getLocalParameters().usernameFragment;var m=ae.writeCandidate(f);u.candidate=Object.assign(u.candidate,ae.parseCandidate(m)),u.candidate.candidate=m,u.candidate.toJSON=function(){return{candidate:u.candidate.candidate,sdpMid:u.candidate.sdpMid,sdpMLineIndex:u.candidate.sdpMLineIndex,usernameFragment:u.candidate.usernameFragment}}}var _=ae.getMediaSections(d._localDescription.sdp);_[u.candidate.sdpMLineIndex]+=p?`a=end-of-candidates\r `:"a="+u.candidate.candidate+`\r `,d._localDescription.sdp=ae.getDescription(d._localDescription.sdp)+_.join("");var v=d.transceivers.every(function(y){return y.iceGatherer&&y.iceGatherer.state==="completed"});d.iceGatheringState!=="gathering"&&(d.iceGatheringState="gathering",d._emitGatheringStateChange()),p||d._dispatchEvent("icecandidate",u),v&&(d._dispatchEvent("icecandidate",new Event("icecandidate")),d.iceGatheringState="complete",d._emitGatheringStateChange())}},t.setTimeout(function(){h.forEach(function(a){l.onlocalcandidate(a)})},0)}},i.prototype._createIceAndDtlsTransports=function(){var s=this,c=new t.RTCIceTransport(null);c.onicestatechange=function(){s._updateIceConnectionState(),s._updateConnectionState()};var d=new t.RTCDtlsTransport(c);return d.ondtlsstatechange=function(){s._updateConnectionState()},d.onerror=function(){Object.defineProperty(d,"state",{value:"failed",writable:!0}),s._updateConnectionState()},{iceTransport:c,dtlsTransport:d}},i.prototype._disposeIceAndDtlsTransports=function(s){var c=this.transceivers[s].iceGatherer;c&&(delete c.onlocalcandidate,delete this.transceivers[s].iceGatherer);var d=this.transceivers[s].iceTransport;d&&(delete d.onicestatechange,delete this.transceivers[s].iceTransport);var l=this.transceivers[s].dtlsTransport;l&&(delete l.ondtlsstatechange,delete l.onerror,delete this.transceivers[s].dtlsTransport)},i.prototype._transceive=function(s,c,d){var l=Pr(s.localCapabilities,s.remoteCapabilities);c&&s.rtpSender&&(l.encodings=s.sendEncodingParameters,l.rtcp={cname:ae.localCName,compound:s.rtcpParameters.compound},s.recvEncodingParameters.length&&(l.rtcp.ssrc=s.recvEncodingParameters[0].ssrc),s.rtpSender.send(l)),d&&s.rtpReceiver&&l.codecs.length>0&&(s.kind==="video"&&s.recvEncodingParameters&&e<15019&&s.recvEncodingParameters.forEach(function(h){delete h.rtx}),s.recvEncodingParameters.length?l.encodings=s.recvEncodingParameters:l.encodings=[{}],l.rtcp={compound:s.rtcpParameters.compound},s.rtcpParameters.cname&&(l.rtcp.cname=s.rtcpParameters.cname),s.sendEncodingParameters.length&&(l.rtcp.ssrc=s.sendEncodingParameters[0].ssrc),s.rtpReceiver.receive(l))},i.prototype.setLocalDescription=function(s){var c,d,l=this;if(["offer","answer"].indexOf(s.type)===-1)return Promise.reject(Fe("TypeError",'Unsupported type "'+s.type+'"'));if(!Nc("setLocalDescription",s.type,l.signalingState)||l._isClosed)return Promise.reject(Fe("InvalidStateError","Can not set local "+s.type+" in state "+l.signalingState));if(s.type==="offer")c=ae.splitSections(s.sdp),d=c.shift(),c.forEach(function(a,u){var f=ae.parseRtpParameters(a);l.transceivers[u].localCapabilities=f}),l.transceivers.forEach(function(a,u){l._gather(a.mid,u)});else if(s.type==="answer"){c=ae.splitSections(l._remoteDescription.sdp),d=c.shift();var h=ae.matchPrefix(d,"a=ice-lite").length>0;c.forEach(function(a,u){var f=l.transceivers[u],p=f.iceGatherer,m=f.iceTransport,_=f.dtlsTransport,v=f.localCapabilities,y=f.remoteCapabilities;if(!(ae.isRejected(a)&&ae.matchPrefix(a,"a=bundle-only").length===0)&&!f.rejected){var C=ae.getIceParameters(a,d),w=ae.getDtlsParameters(a,d);h&&(w.role="server"),l.usingBundle&&u!==0||(l._gather(f.mid,u),m.state==="new"&&m.start(p,C,h?"controlling":"controlled"),_.state==="new"&&_.start(w));var P=Pr(v,y);l._transceive(f,P.codecs.length>0,!1)}})}return l._localDescription={type:s.type,sdp:s.sdp},s.type==="offer"?l._updateSignalingState("have-local-offer"):l._updateSignalingState("stable"),Promise.resolve()},i.prototype.setRemoteDescription=function(s){var c=this;if(["offer","answer"].indexOf(s.type)===-1)return Promise.reject(Fe("TypeError",'Unsupported type "'+s.type+'"'));if(!Nc("setRemoteDescription",s.type,c.signalingState)||c._isClosed)return Promise.reject(Fe("InvalidStateError","Can not set remote "+s.type+" in state "+c.signalingState));var d={};c.remoteStreams.forEach(function(m){d[m.id]=m});var l=[],h=ae.splitSections(s.sdp),a=h.shift(),u=ae.matchPrefix(a,"a=ice-lite").length>0,f=ae.matchPrefix(a,"a=group:BUNDLE ").length>0;c.usingBundle=f;var p=ae.matchPrefix(a,"a=ice-options:")[0];return c.canTrickleIceCandidates=!!p&&p.substr(14).split(" ").indexOf("trickle")>=0,h.forEach(function(m,_){var v=ae.splitLines(m),y=ae.getKind(m),C=ae.isRejected(m)&&ae.matchPrefix(m,"a=bundle-only").length===0,w=v[0].substr(2).split(" ")[2],P=ae.getDirection(m,a),T=ae.parseMsid(m),E=ae.getMid(m)||ae.generateIdentifier();if(C||y==="application"&&(w==="DTLS/SCTP"||w==="UDP/DTLS/SCTP"))c.transceivers[_]={mid:E,kind:y,protocol:w,rejected:!0};else{var O,B,$,R,S,b,A,N,x;!C&&c.transceivers[_]&&c.transceivers[_].rejected&&(c.transceivers[_]=c._createTransceiver(y,!0));var U,j,Y=ae.parseRtpParameters(m);C||(U=ae.getIceParameters(m,a),(j=ae.getDtlsParameters(m,a)).role="client"),A=ae.parseRtpEncodingParameters(m);var ee=ae.parseRtcpParameters(m),z=ae.matchPrefix(m,"a=end-of-candidates",a).length>0,W=ae.matchPrefix(m,"a=candidate:").map(function(D){return ae.parseCandidate(D)}).filter(function(D){return D.component===1});if((s.type==="offer"||s.type==="answer")&&!C&&f&&_>0&&c.transceivers[_]&&(c._disposeIceAndDtlsTransports(_),c.transceivers[_].iceGatherer=c.transceivers[0].iceGatherer,c.transceivers[_].iceTransport=c.transceivers[0].iceTransport,c.transceivers[_].dtlsTransport=c.transceivers[0].dtlsTransport,c.transceivers[_].rtpSender&&c.transceivers[_].rtpSender.setTransport(c.transceivers[0].dtlsTransport),c.transceivers[_].rtpReceiver&&c.transceivers[_].rtpReceiver.setTransport(c.transceivers[0].dtlsTransport)),s.type!=="offer"||C)s.type==="answer"&&!C&&(B=(O=c.transceivers[_]).iceGatherer,$=O.iceTransport,R=O.dtlsTransport,S=O.rtpReceiver,b=O.sendEncodingParameters,N=O.localCapabilities,c.transceivers[_].recvEncodingParameters=A,c.transceivers[_].remoteCapabilities=Y,c.transceivers[_].rtcpParameters=ee,W.length&&$.state==="new"&&(!u&&!z||f&&_!==0?W.forEach(function(D){ao(O.iceTransport,D)}):$.setRemoteCandidates(W)),f&&_!==0||($.state==="new"&&$.start(B,U,"controlling"),R.state==="new"&&R.start(j)),!Pr(O.localCapabilities,O.remoteCapabilities).codecs.filter(function(D){return D.name.toLowerCase()==="rtx"}).length&&O.sendEncodingParameters[0].rtx&&delete O.sendEncodingParameters[0].rtx,c._transceive(O,P==="sendrecv"||P==="recvonly",P==="sendrecv"||P==="sendonly"),!S||P!=="sendrecv"&&P!=="sendonly"?delete O.rtpReceiver:(x=S.track,T?(d[T.stream]||(d[T.stream]=new t.MediaStream),n(x,d[T.stream]),l.push([x,S,d[T.stream]])):(d.default||(d.default=new t.MediaStream),n(x,d.default),l.push([x,S,d.default]))));else{(O=c.transceivers[_]||c._createTransceiver(y)).mid=E,O.iceGatherer||(O.iceGatherer=c._createIceGatherer(_,f)),W.length&&O.iceTransport.state==="new"&&(!z||f&&_!==0?W.forEach(function(D){ao(O.iceTransport,D)}):O.iceTransport.setRemoteCandidates(W)),N=t.RTCRtpReceiver.getCapabilities(y),e<15019&&(N.codecs=N.codecs.filter(function(D){return D.name!=="rtx"})),b=O.sendEncodingParameters||[{ssrc:1001*(2*_+2)}];var K,J=!1;P==="sendrecv"||P==="sendonly"?(J=!O.rtpReceiver,S=O.rtpReceiver||new t.RTCRtpReceiver(O.dtlsTransport,y),J&&(x=S.track,T&&T.stream==="-"||(T?(d[T.stream]||(d[T.stream]=new t.MediaStream,Object.defineProperty(d[T.stream],"id",{get:function(){return T.stream}})),Object.defineProperty(x,"id",{get:function(){return T.track}}),K=d[T.stream]):(d.default||(d.default=new t.MediaStream),K=d.default)),K&&(n(x,K),O.associatedRemoteMediaStreams.push(K)),l.push([x,S,K]))):O.rtpReceiver&&O.rtpReceiver.track&&(O.associatedRemoteMediaStreams.forEach(function(D){var G=D.getTracks().find(function(te){return te.id===O.rtpReceiver.track.id});G&&function(te,ie){ie.removeTrack(te),ie.dispatchEvent(new t.MediaStreamTrackEvent("removetrack",{track:te}))}(G,D)}),O.associatedRemoteMediaStreams=[]),O.localCapabilities=N,O.remoteCapabilities=Y,O.rtpReceiver=S,O.rtcpParameters=ee,O.sendEncodingParameters=b,O.recvEncodingParameters=A,c._transceive(c.transceivers[_],!1,J)}}}),c._dtlsRole===void 0&&(c._dtlsRole=s.type==="offer"?"active":"passive"),c._remoteDescription={type:s.type,sdp:s.sdp},s.type==="offer"?c._updateSignalingState("have-remote-offer"):c._updateSignalingState("stable"),Object.keys(d).forEach(function(m){var _=d[m];if(_.getTracks().length){if(c.remoteStreams.indexOf(_)===-1){c.remoteStreams.push(_);var v=new Event("addstream");v.stream=_,t.setTimeout(function(){c._dispatchEvent("addstream",v)})}l.forEach(function(y){var C=y[0],w=y[1];_.id===y[2].id&&r(c,C,w,[_])})}}),l.forEach(function(m){m[2]||r(c,m[0],m[1],[])}),t.setTimeout(function(){c&&c.transceivers&&c.transceivers.forEach(function(m){m.iceTransport&&m.iceTransport.state==="new"&&m.iceTransport.getRemoteCandidates().length>0&&(console.warn("Timeout for addRemoteCandidate. Consider sending an end-of-candidates notification"),m.iceTransport.addRemoteCandidate({}))})},4e3),Promise.resolve()},i.prototype.close=function(){this.transceivers.forEach(function(s){s.iceTransport&&s.iceTransport.stop(),s.dtlsTransport&&s.dtlsTransport.stop(),s.rtpSender&&s.rtpSender.stop(),s.rtpReceiver&&s.rtpReceiver.stop()}),this._isClosed=!0,this._updateSignalingState("closed")},i.prototype._updateSignalingState=function(s){this.signalingState=s;var c=new Event("signalingstatechange");this._dispatchEvent("signalingstatechange",c)},i.prototype._maybeFireNegotiationNeeded=function(){var s=this;this.signalingState==="stable"&&this.needNegotiation!==!0&&(this.needNegotiation=!0,t.setTimeout(function(){if(s.needNegotiation){s.needNegotiation=!1;var c=new Event("negotiationneeded");s._dispatchEvent("negotiationneeded",c)}},0))},i.prototype._updateIceConnectionState=function(){var s,c={new:0,closed:0,checking:0,connected:0,completed:0,disconnected:0,failed:0};if(this.transceivers.forEach(function(l){l.iceTransport&&!l.rejected&&c[l.iceTransport.state]++}),s="new",c.failed>0?s="failed":c.checking>0?s="checking":c.disconnected>0?s="disconnected":c.new>0?s="new":c.connected>0?s="connected":c.completed>0&&(s="completed"),s!==this.iceConnectionState){this.iceConnectionState=s;var d=new Event("iceconnectionstatechange");this._dispatchEvent("iceconnectionstatechange",d)}},i.prototype._updateConnectionState=function(){var s,c={new:0,closed:0,connecting:0,connected:0,completed:0,disconnected:0,failed:0};if(this.transceivers.forEach(function(l){l.iceTransport&&l.dtlsTransport&&!l.rejected&&(c[l.iceTransport.state]++,c[l.dtlsTransport.state]++)}),c.connected+=c.completed,s="new",c.failed>0?s="failed":c.connecting>0?s="connecting":c.disconnected>0?s="disconnected":c.new>0?s="new":c.connected>0&&(s="connected"),s!==this.connectionState){this.connectionState=s;var d=new Event("connectionstatechange");this._dispatchEvent("connectionstatechange",d)}},i.prototype.createOffer=function(){var s=this;if(s._isClosed)return Promise.reject(Fe("InvalidStateError","Can not call createOffer after close"));var c=s.transceivers.filter(function(u){return u.kind==="audio"}).length,d=s.transceivers.filter(function(u){return u.kind==="video"}).length,l=arguments[0];if(l){if(l.mandatory||l.optional)throw new TypeError("Legacy mandatory/optional constraints not supported.");l.offerToReceiveAudio!==void 0&&(c=l.offerToReceiveAudio===!0?1:l.offerToReceiveAudio===!1?0:l.offerToReceiveAudio),l.offerToReceiveVideo!==void 0&&(d=l.offerToReceiveVideo===!0?1:l.offerToReceiveVideo===!1?0:l.offerToReceiveVideo)}for(s.transceivers.forEach(function(u){u.kind==="audio"?--c<0&&(u.wantReceive=!1):u.kind==="video"&&--d<0&&(u.wantReceive=!1)});c>0||d>0;)c>0&&(s._createTransceiver("audio"),c--),d>0&&(s._createTransceiver("video"),d--);var h=ae.writeSessionBoilerplate(s._sdpSessionId,s._sdpSessionVersion++);s.transceivers.forEach(function(u,f){var p=u.track,m=u.kind,_=u.mid||ae.generateIdentifier();u.mid=_,u.iceGatherer||(u.iceGatherer=s._createIceGatherer(f,s.usingBundle));var v=t.RTCRtpSender.getCapabilities(m);e<15019&&(v.codecs=v.codecs.filter(function(C){return C.name!=="rtx"})),v.codecs.forEach(function(C){C.name==="H264"&&C.parameters["level-asymmetry-allowed"]===void 0&&(C.parameters["level-asymmetry-allowed"]="1"),u.remoteCapabilities&&u.remoteCapabilities.codecs&&u.remoteCapabilities.codecs.forEach(function(w){C.name.toLowerCase()===w.name.toLowerCase()&&C.clockRate===w.clockRate&&(C.preferredPayloadType=w.payloadType)})}),v.headerExtensions.forEach(function(C){(u.remoteCapabilities&&u.remoteCapabilities.headerExtensions||[]).forEach(function(w){C.uri===w.uri&&(C.id=w.id)})});var y=u.sendEncodingParameters||[{ssrc:1001*(2*f+1)}];p&&e>=15019&&m==="video"&&!y[0].rtx&&(y[0].rtx={ssrc:y[0].ssrc+1}),u.wantReceive&&(u.rtpReceiver=new t.RTCRtpReceiver(u.dtlsTransport,m)),u.localCapabilities=v,u.sendEncodingParameters=y}),s._config.bundlePolicy!=="max-compat"&&(h+="a=group:BUNDLE "+s.transceivers.map(function(u){return u.mid}).join(" ")+`\r `),h+=`a=ice-options:trickle\r `,s.transceivers.forEach(function(u,f){h+=Oc(u,u.localCapabilities,"offer",u.stream,s._dtlsRole),h+=`a=rtcp-rsize\r `,!u.iceGatherer||s.iceGatheringState==="new"||f!==0&&s.usingBundle||(u.iceGatherer.getLocalCandidates().forEach(function(p){p.component=1,h+="a="+ae.writeCandidate(p)+`\r `}),u.iceGatherer.state==="completed"&&(h+=`a=end-of-candidates\r `))});var a=new t.RTCSessionDescription({type:"offer",sdp:h});return Promise.resolve(a)},i.prototype.createAnswer=function(){var s=this;if(s._isClosed)return Promise.reject(Fe("InvalidStateError","Can not call createAnswer after close"));if(s.signalingState!=="have-remote-offer"&&s.signalingState!=="have-local-pranswer")return Promise.reject(Fe("InvalidStateError","Can not call createAnswer in signalingState "+s.signalingState));var c=ae.writeSessionBoilerplate(s._sdpSessionId,s._sdpSessionVersion++);s.usingBundle&&(c+="a=group:BUNDLE "+s.transceivers.map(function(h){return h.mid}).join(" ")+`\r `),c+=`a=ice-options:trickle\r `;var d=ae.getMediaSections(s._remoteDescription.sdp).length;s.transceivers.forEach(function(h,a){if(!(a+1>d)){if(h.rejected)return h.kind==="application"?h.protocol==="DTLS/SCTP"?c+=`m=application 0 DTLS/SCTP 5000\r `:c+="m=application 0 "+h.protocol+` webrtc-datachannel\r `:h.kind==="audio"?c+=`m=audio 0 UDP/TLS/RTP/SAVPF 0\r a=rtpmap:0 PCMU/8000\r `:h.kind==="video"&&(c+=`m=video 0 UDP/TLS/RTP/SAVPF 120\r a=rtpmap:120 VP8/90000\r `),void(c+=`c=IN IP4 0.0.0.0\r a=inactive\r a=mid:`+h.mid+`\r `);var u;h.stream&&(h.kind==="audio"?u=h.stream.getAudioTracks()[0]:h.kind==="video"&&(u=h.stream.getVideoTracks()[0]),u&&e>=15019&&h.kind==="video"&&!h.sendEncodingParameters[0].rtx&&(h.sendEncodingParameters[0].rtx={ssrc:h.sendEncodingParameters[0].ssrc+1}));var f=Pr(h.localCapabilities,h.remoteCapabilities);!f.codecs.filter(function(p){return p.name.toLowerCase()==="rtx"}).length&&h.sendEncodingParameters[0].rtx&&delete h.sendEncodingParameters[0].rtx,c+=Oc(h,f,"answer",h.stream,s._dtlsRole),h.rtcpParameters&&h.rtcpParameters.reducedSize&&(c+=`a=rtcp-rsize\r `)}});var l=new t.RTCSessionDescription({type:"answer",sdp:c});return Promise.resolve(l)},i.prototype.addIceCandidate=function(s){var c,d=this;return s&&s.sdpMLineIndex===void 0&&!s.sdpMid?Promise.reject(new TypeError("sdpMLineIndex or sdpMid required")):new Promise(function(l,h){if(!d._remoteDescription)return h(Fe("InvalidStateError","Can not add ICE candidate without a remote description"));if(s&&s.candidate!==""){var a=s.sdpMLineIndex;if(s.sdpMid){for(var u=0;u0?ae.parseCandidate(s.candidate):{};if(p.protocol==="tcp"&&(p.port===0||p.port===9)||p.component&&p.component!==1)return l();if((a===0||a>0&&f.iceTransport!==d.transceivers[0].iceTransport)&&!ao(f.iceTransport,p))return h(Fe("OperationError","Can not add ICE candidate"));var m=s.candidate.trim();m.indexOf("a=")===0&&(m=m.substr(2)),(c=ae.getMediaSections(d._remoteDescription.sdp))[a]+="a="+(p.type?m:"end-of-candidates")+`\r `,d._remoteDescription.sdp=ae.getDescription(d._remoteDescription.sdp)+c.join("")}else for(var _=0;_Promise.reject(function(o){return{name:{PermissionDeniedError:"NotAllowedError"}[o.name]||o.name,message:o.message,constraint:o.constraint,toString(){return this.name}}}(i)))}}function ld(t){"getDisplayMedia"in t.navigator&&t.navigator.mediaDevices&&(t.navigator.mediaDevices&&"getDisplayMedia"in t.navigator.mediaDevices||(t.navigator.mediaDevices.getDisplayMedia=t.navigator.getDisplayMedia.bind(t.navigator)))}function Xo(t,e){if(t.RTCIceGatherer&&(t.RTCIceCandidate||(t.RTCIceCandidate=function(r){return r}),t.RTCSessionDescription||(t.RTCSessionDescription=function(r){return r}),e.version<15025)){const r=Object.getOwnPropertyDescriptor(t.MediaStreamTrack.prototype,"enabled");Object.defineProperty(t.MediaStreamTrack.prototype,"enabled",{set(i){r.set.call(this,i);const o=new Event("enabled");o.enabled=i,this.dispatchEvent(o)}})}t.RTCRtpSender&&!("dtmf"in t.RTCRtpSender.prototype)&&Object.defineProperty(t.RTCRtpSender.prototype,"dtmf",{get(){return this._dtmf===void 0&&(this.track.kind==="audio"?this._dtmf=new t.RTCDtmfSender(this):this.track.kind==="video"&&(this._dtmf=null)),this._dtmf}}),t.RTCDtmfSender&&!t.RTCDTMFSender&&(t.RTCDTMFSender=t.RTCDtmfSender);const n=Pf(t,e.version);t.RTCPeerConnection=function(r){return r&&r.iceServers&&(r.iceServers=function(i,o){let s=!1;return(i=JSON.parse(JSON.stringify(i))).filter(c=>{if(c&&(c.urls||c.url)){let d=c.urls||c.url;c.url&&!c.urls&&Ui("RTCIceServer.url","RTCIceServer.urls");const l=typeof d=="string";return l&&(d=[d]),d=d.filter(h=>{if(h.indexOf("stun:")===0)return!1;const a=h.startsWith("turn")&&!h.startsWith("turn:[")&&h.includes("transport=udp");return a&&!s?(s=!0,!0):a&&!s}),delete c.url,c.urls=l?d[0]:d,!!d.length}})}(r.iceServers,e.version),da("ICE servers after filtering:",r.iceServers)),new n(r)},t.RTCPeerConnection.prototype=n.prototype}function hd(t){t.RTCRtpSender&&!("replaceTrack"in t.RTCRtpSender.prototype)&&(t.RTCRtpSender.prototype.replaceTrack=t.RTCRtpSender.prototype.setTrack)}var Ac=Object.freeze({__proto__:null,shimPeerConnection:Xo,shimReplaceTrack:hd,shimGetUserMedia:dd,shimGetDisplayMedia:ld});function fd(t,e){const n=t&&t.navigator,r=t&&t.MediaStreamTrack;if(n.getUserMedia=function(i,o,s){Ui("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),n.mediaDevices.getUserMedia(i).then(o,s)},!(e.version>55&&"autoGainControl"in n.mediaDevices.getSupportedConstraints())){const i=function(s,c,d){c in s&&!(d in s)&&(s[d]=s[c],delete s[c])},o=n.mediaDevices.getUserMedia.bind(n.mediaDevices);if(n.mediaDevices.getUserMedia=function(s){return typeof s=="object"&&typeof s.audio=="object"&&(s=JSON.parse(JSON.stringify(s)),i(s.audio,"autoGainControl","mozAutoGainControl"),i(s.audio,"noiseSuppression","mozNoiseSuppression")),o(s)},r&&r.prototype.getSettings){const s=r.prototype.getSettings;r.prototype.getSettings=function(){const c=s.apply(this,arguments);return i(c,"mozAutoGainControl","autoGainControl"),i(c,"mozNoiseSuppression","noiseSuppression"),c}}if(r&&r.prototype.applyConstraints){const s=r.prototype.applyConstraints;r.prototype.applyConstraints=function(c){return this.kind==="audio"&&typeof c=="object"&&(c=JSON.parse(JSON.stringify(c)),i(c,"autoGainControl","mozAutoGainControl"),i(c,"noiseSuppression","mozNoiseSuppression")),s.apply(this,[c])}}}}function pd(t){typeof t=="object"&&t.RTCTrackEvent&&"receiver"in t.RTCTrackEvent.prototype&&!("transceiver"in t.RTCTrackEvent.prototype)&&Object.defineProperty(t.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function Zo(t,e){if(typeof t!="object"||!t.RTCPeerConnection&&!t.mozRTCPeerConnection)return;!t.RTCPeerConnection&&t.mozRTCPeerConnection&&(t.RTCPeerConnection=t.mozRTCPeerConnection),e.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(i){const o=t.RTCPeerConnection.prototype[i],s={[i](){return arguments[0]=new(i==="addIceCandidate"?t.RTCIceCandidate:t.RTCSessionDescription)(arguments[0]),o.apply(this,arguments)}};t.RTCPeerConnection.prototype[i]=s[i]});const n={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"},r=t.RTCPeerConnection.prototype.getStats;t.RTCPeerConnection.prototype.getStats=function(){const[i,o,s]=arguments;return r.apply(this,[i||null]).then(c=>{if(e.version<53&&!o)try{c.forEach(d=>{d.type=n[d.type]||d.type})}catch(d){if(d.name!=="TypeError")throw d;c.forEach((l,h)=>{c.set(h,Object.assign({},l,{type:n[l.type]||l.type}))})}return c}).then(o,s)}}function gd(t){if(typeof t!="object"||!t.RTCPeerConnection||!t.RTCRtpSender||t.RTCRtpSender&&"getStats"in t.RTCRtpSender.prototype)return;const e=t.RTCPeerConnection.prototype.getSenders;e&&(t.RTCPeerConnection.prototype.getSenders=function(){const r=e.apply(this,[]);return r.forEach(i=>i._pc=this),r});const n=t.RTCPeerConnection.prototype.addTrack;n&&(t.RTCPeerConnection.prototype.addTrack=function(){const r=n.apply(this,arguments);return r._pc=this,r}),t.RTCRtpSender.prototype.getStats=function(){return this.track?this._pc.getStats(this.track):Promise.resolve(new Map)}}function md(t){if(typeof t!="object"||!t.RTCPeerConnection||!t.RTCRtpSender||t.RTCRtpSender&&"getStats"in t.RTCRtpReceiver.prototype)return;const e=t.RTCPeerConnection.prototype.getReceivers;e&&(t.RTCPeerConnection.prototype.getReceivers=function(){const n=e.apply(this,[]);return n.forEach(r=>r._pc=this),n}),Nn(t,"track",n=>(n.receiver._pc=n.srcElement,n)),t.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}function _d(t){t.RTCPeerConnection&&!("removeStream"in t.RTCPeerConnection.prototype)&&(t.RTCPeerConnection.prototype.removeStream=function(e){Ui("removeStream","removeTrack"),this.getSenders().forEach(n=>{n.track&&e.getTracks().includes(n.track)&&this.removeTrack(n)})})}function vd(t){t.DataChannel&&!t.RTCDataChannel&&(t.RTCDataChannel=t.DataChannel)}function yd(t){if(typeof t!="object"||!t.RTCPeerConnection)return;const e=t.RTCPeerConnection.prototype.addTransceiver;e&&(t.RTCPeerConnection.prototype.addTransceiver=function(){this.setParametersPromises=[];const n=arguments[1],r=n&&"sendEncodings"in n;r&&n.sendEncodings.forEach(o=>{if("rid"in o&&!/^[a-z0-9]{0,16}$/i.test(o.rid))throw new TypeError("Invalid RID value provided.");if("scaleResolutionDownBy"in o&&!(parseFloat(o.scaleResolutionDownBy)>=1))throw new RangeError("scale_resolution_down_by must be >= 1.0");if("maxFramerate"in o&&!(parseFloat(o.maxFramerate)>=0))throw new RangeError("max_framerate must be >= 0.0")});const i=e.apply(this,arguments);if(r){const{sender:o}=i,s=o.getParameters();(!("encodings"in s)||s.encodings.length===1&&Object.keys(s.encodings[0]).length===0)&&(s.encodings=n.sendEncodings,o.sendEncodings=n.sendEncodings,this.setParametersPromises.push(o.setParameters(s).then(()=>{delete o.sendEncodings}).catch(()=>{delete o.sendEncodings})))}return i})}function Cd(t){if(typeof t!="object"||!t.RTCRtpSender)return;const e=t.RTCRtpSender.prototype.getParameters;e&&(t.RTCRtpSender.prototype.getParameters=function(){const n=e.apply(this,arguments);return"encodings"in n||(n.encodings=[].concat(this.sendEncodings||[{}])),n})}function Ed(t){if(typeof t!="object"||!t.RTCPeerConnection)return;const e=t.RTCPeerConnection.prototype.createOffer;t.RTCPeerConnection.prototype.createOffer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(()=>e.apply(this,arguments)).finally(()=>{this.setParametersPromises=[]}):e.apply(this,arguments)}}function Rd(t){if(typeof t!="object"||!t.RTCPeerConnection)return;const e=t.RTCPeerConnection.prototype.createAnswer;t.RTCPeerConnection.prototype.createAnswer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(()=>e.apply(this,arguments)).finally(()=>{this.setParametersPromises=[]}):e.apply(this,arguments)}}var Mc=Object.freeze({__proto__:null,shimOnTrack:pd,shimPeerConnection:Zo,shimSenderGetStats:gd,shimReceiverGetStats:md,shimRemoveStream:_d,shimRTCDataChannel:vd,shimAddTransceiver:yd,shimGetParameters:Cd,shimCreateOffer:Ed,shimCreateAnswer:Rd,shimGetUserMedia:fd,shimGetDisplayMedia:function(t,e){t.navigator.mediaDevices&&"getDisplayMedia"in t.navigator.mediaDevices||t.navigator.mediaDevices&&(t.navigator.mediaDevices.getDisplayMedia=function(n){if(!n||!n.video){const r=new DOMException("getDisplayMedia without video constraints is undefined");return r.name="NotFoundError",r.code=8,Promise.reject(r)}return n.video===!0?n.video={mediaSource:e}:n.video.mediaSource=e,t.navigator.mediaDevices.getUserMedia(n)})}});function Td(t){if(typeof t=="object"&&t.RTCPeerConnection){if("getLocalStreams"in t.RTCPeerConnection.prototype||(t.RTCPeerConnection.prototype.getLocalStreams=function(){return this._localStreams||(this._localStreams=[]),this._localStreams}),!("addStream"in t.RTCPeerConnection.prototype)){const e=t.RTCPeerConnection.prototype.addTrack;t.RTCPeerConnection.prototype.addStream=function(n){this._localStreams||(this._localStreams=[]),this._localStreams.includes(n)||this._localStreams.push(n),n.getAudioTracks().forEach(r=>e.call(this,r,n)),n.getVideoTracks().forEach(r=>e.call(this,r,n))},t.RTCPeerConnection.prototype.addTrack=function(n,...r){return r&&r.forEach(i=>{this._localStreams?this._localStreams.includes(i)||this._localStreams.push(i):this._localStreams=[i]}),e.apply(this,arguments)}}"removeStream"in t.RTCPeerConnection.prototype||(t.RTCPeerConnection.prototype.removeStream=function(e){this._localStreams||(this._localStreams=[]);const n=this._localStreams.indexOf(e);if(n===-1)return;this._localStreams.splice(n,1);const r=e.getTracks();this.getSenders().forEach(i=>{r.includes(i.track)&&this.removeTrack(i)})})}}function Sd(t){if(typeof t=="object"&&t.RTCPeerConnection&&("getRemoteStreams"in t.RTCPeerConnection.prototype||(t.RTCPeerConnection.prototype.getRemoteStreams=function(){return this._remoteStreams?this._remoteStreams:[]}),!("onaddstream"in t.RTCPeerConnection.prototype))){Object.defineProperty(t.RTCPeerConnection.prototype,"onaddstream",{get(){return this._onaddstream},set(n){this._onaddstream&&(this.removeEventListener("addstream",this._onaddstream),this.removeEventListener("track",this._onaddstreampoly)),this.addEventListener("addstream",this._onaddstream=n),this.addEventListener("track",this._onaddstreampoly=r=>{r.streams.forEach(i=>{if(this._remoteStreams||(this._remoteStreams=[]),this._remoteStreams.includes(i))return;this._remoteStreams.push(i);const o=new Event("addstream");o.stream=i,this.dispatchEvent(o)})})}});const e=t.RTCPeerConnection.prototype.setRemoteDescription;t.RTCPeerConnection.prototype.setRemoteDescription=function(){const n=this;return this._onaddstreampoly||this.addEventListener("track",this._onaddstreampoly=function(r){r.streams.forEach(i=>{if(n._remoteStreams||(n._remoteStreams=[]),n._remoteStreams.indexOf(i)>=0)return;n._remoteStreams.push(i);const o=new Event("addstream");o.stream=i,n.dispatchEvent(o)})}),e.apply(n,arguments)}}}function Id(t){if(typeof t!="object"||!t.RTCPeerConnection)return;const e=t.RTCPeerConnection.prototype,n=e.createOffer,r=e.createAnswer,i=e.setLocalDescription,o=e.setRemoteDescription,s=e.addIceCandidate;e.createOffer=function(d,l){const h=arguments.length>=2?arguments[2]:arguments[0],a=n.apply(this,[h]);return l?(a.then(d,l),Promise.resolve()):a},e.createAnswer=function(d,l){const h=arguments.length>=2?arguments[2]:arguments[0],a=r.apply(this,[h]);return l?(a.then(d,l),Promise.resolve()):a};let c=function(d,l,h){const a=i.apply(this,[d]);return h?(a.then(l,h),Promise.resolve()):a};e.setLocalDescription=c,c=function(d,l,h){const a=o.apply(this,[d]);return h?(a.then(l,h),Promise.resolve()):a},e.setRemoteDescription=c,c=function(d,l,h){const a=s.apply(this,[d]);return h?(a.then(l,h),Promise.resolve()):a},e.addIceCandidate=c}function bd(t){const e=t&&t.navigator;if(e.mediaDevices&&e.mediaDevices.getUserMedia){const n=e.mediaDevices,r=n.getUserMedia.bind(n);e.mediaDevices.getUserMedia=i=>r(wd(i))}!e.getUserMedia&&e.mediaDevices&&e.mediaDevices.getUserMedia&&(e.getUserMedia=function(n,r,i){e.mediaDevices.getUserMedia(n).then(r,i)}.bind(e))}function wd(t){return t&&t.video!==void 0?Object.assign({},t,{video:ed(t.video)}):t}function Od(t){if(!t.RTCPeerConnection)return;const e=t.RTCPeerConnection;t.RTCPeerConnection=function(n,r){if(n&&n.iceServers){const i=[];for(let o=0;oe.generateCertificate})}function Nd(t){typeof t=="object"&&t.RTCTrackEvent&&"receiver"in t.RTCTrackEvent.prototype&&!("transceiver"in t.RTCTrackEvent.prototype)&&Object.defineProperty(t.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function Ad(t){const e=t.RTCPeerConnection.prototype.createOffer;t.RTCPeerConnection.prototype.createOffer=function(n){if(n){n.offerToReceiveAudio!==void 0&&(n.offerToReceiveAudio=!!n.offerToReceiveAudio);const r=this.getTransceivers().find(o=>o.receiver.track.kind==="audio");n.offerToReceiveAudio===!1&&r?r.direction==="sendrecv"?r.setDirection?r.setDirection("sendonly"):r.direction="sendonly":r.direction==="recvonly"&&(r.setDirection?r.setDirection("inactive"):r.direction="inactive"):n.offerToReceiveAudio!==!0||r||this.addTransceiver("audio"),n.offerToReceiveVideo!==void 0&&(n.offerToReceiveVideo=!!n.offerToReceiveVideo);const i=this.getTransceivers().find(o=>o.receiver.track.kind==="video");n.offerToReceiveVideo===!1&&i?i.direction==="sendrecv"?i.setDirection?i.setDirection("sendonly"):i.direction="sendonly":i.direction==="recvonly"&&(i.setDirection?i.setDirection("inactive"):i.direction="inactive"):n.offerToReceiveVideo!==!0||i||this.addTransceiver("video")}return e.apply(this,arguments)}}function Md(t){typeof t!="object"||t.AudioContext||(t.AudioContext=t.webkitAudioContext)}var Pc=Object.freeze({__proto__:null,shimLocalStreamsAPI:Td,shimRemoteStreamsAPI:Sd,shimCallbacksAPI:Id,shimGetUserMedia:bd,shimConstraints:wd,shimRTCIceServerUrls:Od,shimTrackEventTransceiver:Nd,shimCreateOfferLegacy:Ad,shimAudioContext:Md});function $r(t){if(!t.RTCIceCandidate||t.RTCIceCandidate&&"foundation"in t.RTCIceCandidate.prototype)return;const e=t.RTCIceCandidate;t.RTCIceCandidate=function(n){if(typeof n=="object"&&n.candidate&&n.candidate.indexOf("a=")===0&&((n=JSON.parse(JSON.stringify(n))).candidate=n.candidate.substr(2)),n.candidate&&n.candidate.length){const r=new e(n),i=ae.parseCandidate(n.candidate),o=Object.assign(r,i);return o.toJSON=function(){return{candidate:o.candidate,sdpMid:o.sdpMid,sdpMLineIndex:o.sdpMLineIndex,usernameFragment:o.usernameFragment}},o}return new e(n)},t.RTCIceCandidate.prototype=e.prototype,Nn(t,"icecandidate",n=>(n.candidate&&Object.defineProperty(n,"candidate",{value:new t.RTCIceCandidate(n.candidate),writable:"false"}),n))}function jn(t,e){if(!t.RTCPeerConnection)return;"sctp"in t.RTCPeerConnection.prototype||Object.defineProperty(t.RTCPeerConnection.prototype,"sctp",{get(){return this._sctp===void 0?null:this._sctp}});const n=function(c){if(!c||!c.sdp)return!1;const d=ae.splitSections(c.sdp);return d.shift(),d.some(l=>{const h=ae.parseMLine(l);return h&&h.kind==="application"&&h.protocol.indexOf("SCTP")!==-1})},r=function(c){const d=c.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);if(d===null||d.length<2)return-1;const l=parseInt(d[1],10);return l!=l?-1:l},i=function(c){let d=65536;return e.browser==="firefox"&&(d=e.version<57?c===-1?16384:2147483637:e.version<60?e.version===57?65535:65536:2147483637),d},o=function(c,d){let l=65536;e.browser==="firefox"&&e.version===57&&(l=65535);const h=ae.matchPrefix(c.sdp,"a=max-message-size:");return h.length>0?l=parseInt(h[0].substr(19),10):e.browser==="firefox"&&d!==-1&&(l=2147483637),l},s=t.RTCPeerConnection.prototype.setRemoteDescription;t.RTCPeerConnection.prototype.setRemoteDescription=function(){if(this._sctp=null,e.browser==="chrome"&&e.version>=76){const{sdpSemantics:c}=this.getConfiguration();c==="plan-b"&&Object.defineProperty(this,"sctp",{get(){return this._sctp===void 0?null:this._sctp},enumerable:!0,configurable:!0})}if(n(arguments[0])){const c=r(arguments[0]),d=i(c),l=o(arguments[0],c);let h;h=d===0&&l===0?Number.POSITIVE_INFINITY:d===0||l===0?Math.max(d,l):Math.min(d,l);const a={};Object.defineProperty(a,"maxMessageSize",{get:()=>h}),this._sctp=a}return s.apply(this,arguments)}}function Kn(t){if(!t.RTCPeerConnection||!("createDataChannel"in t.RTCPeerConnection.prototype))return;function e(r,i){const o=r.send;r.send=function(){const s=arguments[0],c=s.length||s.size||s.byteLength;if(r.readyState==="open"&&i.sctp&&c>i.sctp.maxMessageSize)throw new TypeError("Message too large (can send a maximum of "+i.sctp.maxMessageSize+" bytes)");return o.apply(r,arguments)}}const n=t.RTCPeerConnection.prototype.createDataChannel;t.RTCPeerConnection.prototype.createDataChannel=function(){const r=n.apply(this,arguments);return e(r,this),r},Nn(t,"datachannel",r=>(e(r.channel,r.target),r))}function es(t){if(!t.RTCPeerConnection||"connectionState"in t.RTCPeerConnection.prototype)return;const e=t.RTCPeerConnection.prototype;Object.defineProperty(e,"connectionState",{get(){return{completed:"connected",checking:"connecting"}[this.iceConnectionState]||this.iceConnectionState},enumerable:!0,configurable:!0}),Object.defineProperty(e,"onconnectionstatechange",{get(){return this._onconnectionstatechange||null},set(n){this._onconnectionstatechange&&(this.removeEventListener("connectionstatechange",this._onconnectionstatechange),delete this._onconnectionstatechange),n&&this.addEventListener("connectionstatechange",this._onconnectionstatechange=n)},enumerable:!0,configurable:!0}),["setLocalDescription","setRemoteDescription"].forEach(n=>{const r=e[n];e[n]=function(){return this._connectionstatechangepoly||(this._connectionstatechangepoly=i=>{const o=i.target;if(o._lastConnectionState!==o.connectionState){o._lastConnectionState=o.connectionState;const s=new Event("connectionstatechange",i);o.dispatchEvent(s)}return i},this.addEventListener("iceconnectionstatechange",this._connectionstatechangepoly)),r.apply(this,arguments)}})}function ts(t,e){if(!t.RTCPeerConnection||e.browser==="chrome"&&e.version>=71||e.browser==="safari"&&e.version>=605)return;const n=t.RTCPeerConnection.prototype.setRemoteDescription;t.RTCPeerConnection.prototype.setRemoteDescription=function(r){if(r&&r.sdp&&r.sdp.indexOf(` a=extmap-allow-mixed`)!==-1){const i=r.sdp.split(` `).filter(o=>o.trim()!=="a=extmap-allow-mixed").join(` `);t.RTCSessionDescription&&r instanceof t.RTCSessionDescription?arguments[0]=new t.RTCSessionDescription({type:r.type,sdp:i}):r.sdp=i}return n.apply(this,arguments)}}function jr(t,e){if(!t.RTCPeerConnection||!t.RTCPeerConnection.prototype)return;const n=t.RTCPeerConnection.prototype.addIceCandidate;n&&n.length!==0&&(t.RTCPeerConnection.prototype.addIceCandidate=function(){return arguments[0]?(e.browser==="chrome"&&e.version<78||e.browser==="firefox"&&e.version<68||e.browser==="safari")&&arguments[0]&&arguments[0].candidate===""?Promise.resolve():n.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())})}var Lf=Object.freeze({__proto__:null,shimRTCIceCandidate:$r,shimMaxMessageSize:jn,shimSendThrowTypeError:Kn,shimConnectionState:es,removeExtmapAllowMixed:ts,shimAddIceCandidateNullOrEmpty:jr});const kf=function({window:t}={},e={shimChrome:!0,shimFirefox:!0,shimEdge:!0,shimSafari:!0}){const n=da,r=function(o){const s={browser:null,version:null};if(o===void 0||!o.navigator)return s.browser="Not a browser.",s;const{navigator:c}=o;if(c.mozGetUserMedia)s.browser="firefox",s.version=Hn(c.userAgent,/Firefox\/(\d+)\./,1);else if(c.webkitGetUserMedia||o.isSecureContext===!1&&o.webkitRTCPeerConnection&&!o.RTCIceGatherer)s.browser="chrome",s.version=Hn(c.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else if(c.mediaDevices&&c.userAgent.match(/Edge\/(\d+).(\d+)$/))s.browser="edge",s.version=Hn(c.userAgent,/Edge\/(\d+).(\d+)$/,2);else{if(!o.RTCPeerConnection||!c.userAgent.match(/AppleWebKit\/(\d+)\./))return s.browser="Not a supported browser.",s;s.browser="safari",s.version=Hn(c.userAgent,/AppleWebKit\/(\d+)\./,1),s.supportsUnifiedPlan=o.RTCRtpTransceiver&&"currentDirection"in o.RTCRtpTransceiver.prototype}return s}(t),i={browserDetails:r,commonShim:Lf,extractVersion:Hn,disableLog:Af,disableWarnings:Mf};switch(r.browser){case"chrome":if(!bc||!Qo||!e.shimChrome)return n("Chrome shim is not included in this adapter release."),i;if(r.version===null)return n("Chrome shim can not determine version, not shimming."),i;n("adapter.js shimming chrome."),i.browserShim=bc,jr(t,r),td(t,r),nd(t),Qo(t,r),rd(t),cd(t,r),id(t),od(t),sd(t),ud(t,r),$r(t),es(t),jn(t,r),Kn(t),ts(t,r);break;case"firefox":if(!Mc||!Zo||!e.shimFirefox)return n("Firefox shim is not included in this adapter release."),i;n("adapter.js shimming firefox."),i.browserShim=Mc,jr(t,r),fd(t,r),Zo(t,r),pd(t),_d(t),gd(t),md(t),vd(t),yd(t),Cd(t),Ed(t),Rd(t),$r(t),es(t),jn(t,r),Kn(t);break;case"edge":if(!Ac||!Xo||!e.shimEdge)return n("MS edge shim is not included in this adapter release."),i;n("adapter.js shimming edge."),i.browserShim=Ac,dd(t),ld(t),Xo(t,r),hd(t),jn(t,r),Kn(t);break;case"safari":if(!Pc||!e.shimSafari)return n("Safari shim is not included in this adapter release."),i;n("adapter.js shimming safari."),i.browserShim=Pc,jr(t,r),Od(t),Ad(t),Id(t),Td(t),Sd(t),Nd(t),bd(t),Md(t),$r(t),jn(t,r),Kn(t),ts(t,r);break;default:n("Unsupported browser!")}return i}({window:typeof window=="undefined"?void 0:window});var St,Te,ve;(function(t){t.FPS_10="FPS_10",t.FPS_15="FPS_15",t.FPS_24="FPS_24",t.FPS_30="FPS_30"})(St||(St={})),function(t){t.W176_H132="W176_H132",t.W176_H144="W176_H144",t.W256_H144="W256_H144",t.W320_H180="W320_H180",t.W240_H240="W240_H240",t.W320_H240="W320_H240",t.W480_H360="W480_H360",t.W640_H360="W640_H360",t.W480_H480="W480_H480",t.W640_H480="W640_H480",t.W720_H480="W720_H480",t.W1280_H720="W1280_H720",t.W1920_H1080="W1920_H1080"}(Te||(Te={})),function(t){t[t.AUDIO_ONLY=0]="AUDIO_ONLY",t[t.VIDEO_ONLY=1]="VIDEO_ONLY",t[t.AUDIO_VIDEO=2]="AUDIO_VIDEO"}(ve||(ve={}));const Lc={[Te.W176_H132]:{width:176,height:132,maxBitrate:150,minBitrate:80},[Te.W176_H144]:{width:176,height:144,maxBitrate:160,minBitrate:80},[Te.W256_H144]:{width:256,height:144,maxBitrate:240,minBitrate:120},[Te.W320_H180]:{width:320,height:180,maxBitrate:280,minBitrate:120},[Te.W240_H240]:{width:240,height:240,maxBitrate:280,minBitrate:120},[Te.W320_H240]:{width:320,height:240,maxBitrate:400,minBitrate:120},[Te.W480_H360]:{width:480,height:360,maxBitrate:650,minBitrate:150},[Te.W640_H360]:{width:640,height:360,maxBitrate:800,minBitrate:180},[Te.W480_H480]:{width:480,height:480,maxBitrate:800,minBitrate:180},[Te.W640_H480]:{width:640,height:480,maxBitrate:900,minBitrate:200},[Te.W720_H480]:{width:720,height:480,maxBitrate:1e3,minBitrate:200},[Te.W1280_H720]:{width:1280,height:720,maxBitrate:2200,minBitrate:250},[Te.W1920_H1080]:{width:1920,height:1080,maxBitrate:4e3,minBitrate:400}},Pd=(t,e)=>{const n=t*e;let r=Number.MAX_VALUE,i=null;for(const o in Lc){const s=Lc[o],c=Math.abs(s.width*s.height-n);c{let e=Number.MAX_VALUE,n=1;for(const r in kc){const i=Math.abs(t-parseInt(r));iq(void 0,void 0,void 0,function*(){return(yield navigator.mediaDevices.enumerateDevices()).filter(t=>t.kind==="videoinput")}),getMicrophones:()=>q(void 0,void 0,void 0,function*(){return(yield navigator.mediaDevices.enumerateDevices()).filter(t=>t.kind==="audioinput")}),getSpeakers:()=>q(void 0,void 0,void 0,function*(){return(yield navigator.mediaDevices.enumerateDevices()).filter(t=>t.kind==="audiooutput")})};class ha extends ur{constructor(e,n,r,i,o){super(),this._tag=e,this._userId=n,this._kind=r,this._isLocalTrack=i,this._roomId=o,this._localMuted=!1,this._remoteMuted=!1,this._streamId=[this._userId||this._roomId,this._tag].join("_"),this._id=[this._streamId,this.isAudioTrack()?0:1].join("_")}getStreamId(){return this._streamId}getTrackId(){return this._id}getUserId(){return this._userId}__innerGetMediaStreamTrack(){return this._msTrack}getTag(){return this._tag}isLocalTrack(){return this._isLocalTrack}isVideoTrack(){return this._kind==="video"}isAudioTrack(){return this._kind==="audio"}isReady(){var e;return((e=this._msTrack)===null||e===void 0?void 0:e.readyState)==="live"}__innerSetMediaStreamTrack(e){this._msTrack=e,this._setLocalMuted(this._localMuted);const n=this._msStream=this._msStream||new MediaStream,r=n.getTracks()[0];r&&n.removeTrack(r),e?n.addTrack(e):this._element&&(this._element.pause(),this._element.srcObject=null)}_setLocalMuted(e){this._msTrack&&(this._msTrack.enabled=!e),this._localMuted=e}mute(){k.info(`set ${this._id} enabled: false`),this._setLocalMuted(!0)}unmute(){k.info(`set ${this._id} enabled: true`),this._setLocalMuted(!1)}isLocalMuted(){return this._localMuted}isMCUTrack(){return Boolean(this._roomId)}isOwnerMuted(){return this._remoteMuted}play(e,n){return q(this,void 0,void 0,function*(){if(!this._msTrack)return k.warn(`the track is not ready to play -> id: ${this._id}`),{code:L.TRACK_NOT_READY};if(this._msTrack.readyState==="ended"&&k.warn(`the track's readyState is 'ended' -> id: ${this._id}`),n==null?void 0:n.volume){if(!be(n==null?void 0:n.volume))return k.error(`${n==null?void 0:n.volume} is not a number, the valid range of options.volume is 0-100`),{code:L.PARAMS_ERROR};(n==null?void 0:n.volume)<0&&(n.volume=0,k.warn("the valid range of options.volume is 0-100, the value of volume has been set 0")),(n==null?void 0:n.volume)>100&&(n.volume=100,k.warn("the valid range of options.volume is 0-100, the value of volume has been set 100"))}if((n==null?void 0:n.audioDeviceId)&&!(yield la.getSpeakers()).map(i=>i.deviceId).includes(n.audioDeviceId))return k.error(`the options.audioDeviceId is invalid --> ${n.audioDeviceId}`),{code:L.PARAMS_ERROR};const r=this.isVideoTrack();if(r&&(!e||!(e instanceof HTMLVideoElement)))return k.error(`the video track need an