var Iu=Object.defineProperty,bu=Object.defineProperties;var Ou=Object.getOwnPropertyDescriptors;var Xn=Object.getOwnPropertySymbols;var vo=Object.prototype.hasOwnProperty,Ro=Object.prototype.propertyIsEnumerable;var _o=(n,e,t)=>e in n?Iu(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,Et=(n,e)=>{for(var t in e||(e={}))vo.call(e,t)&&_o(n,t,e[t]);if(Xn)for(var t of Xn(e))Ro.call(e,t)&&_o(n,t,e[t]);return n},ln=(n,e)=>bu(n,Ou(e));var Eo=(n,e)=>{var t={};for(var r in n)vo.call(n,r)&&e.indexOf(r)<0&&(t[r]=n[r]);if(n!=null&&Xn)for(var r of Xn(n))e.indexOf(r)<0&&Ro.call(n,r)&&(t[r]=n[r]);return t};import{s as ge,r as $n,a as Nu}from"./index.8ea5a330.js";import{j as Ha,n as $a,d as Je,E as wu,f as L,l as se,p as gr,q as Ai,t as Mi,u as yo,v as _t,x as Au,y as Mu,z as ui,A as pt,r as Ne,B as Yt,C as Pu,D as Lu,F as ku,G as yr,H as Uu,I as Du,J as xu,K as di,L as li}from"./vendor.2b18510b.js";const Vu="_liveHeader_8nata_1",Bu="_liveLogo_8nata_12",Fu="_liveHeaderLeft_8nata_17",Hu="_liveHeaderLeftIcon_8nata_23",$u="_liveHeaderLeftText_8nata_27",ju="_avatarWrapper_8nata_30",Ku="_userAvatar_8nata_37";var At={liveHeader:Vu,liveLogo:Bu,liveHeaderLeft:Fu,liveHeaderLeftIcon:Hu,liveHeaderLeftText:$u,avatarWrapper:ju,userAvatar:Ku},Pi;(function(n){n[n.READ=1]="READ",n[n.LISTENED=2]="LISTENED",n[n.DOWNLOADED=4]="DOWNLOADED",n[n.RETRIEVED=8]="RETRIEVED",n[n.UNREAD=0]="UNREAD"})(Pi||(Pi={}));var yt,hi,Mn=Pi,qu=["https://nav.cn.ronghub.com","https://nav2-cn.ronghub.com"],Gu=["wsproxy.cn.ronghub.com","wsap-cn.ronghub.com"],Yu=["cometproxy-cn.ronghub.com","mini-cn.ronghub.com"],To={"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}},Ju=["RC:TypSts","RC:InterceptMsg"];(function(n){n.WEBSOCKET="websocket",n.COMET="comet"})(yt||(yt={}));var Gr=function(n){return hi||(hi={set:function(e,t){n.localStorage.setItem(e,JSON.stringify(t))},get:function(e){var t;try{t=JSON.parse(n.localStorage.getItem(e))}catch{t=null}return t},remove:function(e){return n.localStorage.removeItem(e)},getKeys:function(){var e=[];for(var t in n.localStorage)e.push(t);return e}}),hi},Wu=function(){function n(e){this._caches={},e&&(this._caches=e)}return n.prototype.set=function(e,t){this._caches[e]=t},n.prototype.remove=function(e){var t=this.get(e);return delete this._caches[e],t},n.prototype.get=function(e){return this._caches[e]},n.prototype.getKeys=function(){var e=[];for(var t in this._caches)e.push(t);return e},n}(),So=function(){function n(e,t){var r,i=t?"RCV4-"+t:"RCV4-";this._rootStorage=Gr(e);var s=this._rootStorage.get(i)||{};this._cache=new Wu(((r={})[i]=s,r)),this._storageKey=i}return n.prototype._get=function(){var e=this._storageKey;return this._cache.get(e)||{}},n.prototype._set=function(e){var t=this._storageKey;e=e||{},this._cache.set(t,e),this._rootStorage.set(t,e)},n.prototype.set=function(e,t){var r=this._get();r[e]=t,this._set(r)},n.prototype.remove=function(e){var t=this._get();delete t[e],this._set(t)},n.prototype.clear=function(){var e=this._storageKey;this._rootStorage.remove(e),this._cache.remove(e)},n.prototype.get=function(e){return this._get()[e]},n.prototype.getKeys=function(){var e=this._get(),t=[];for(var r in e)t.push(r);return t},n.prototype.getValues=function(){return this._get()||{}},n}(),ja=function(n,e){return(ja=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,r){t.__proto__=r}||function(t,r){for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(t[i]=r[i])})(n,e)};function Ie(n,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function t(){this.constructor=n}ja(n,e),n.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}var Re=function(){return(Re=Object.assign||function(n){for(var e,t=1,r=arguments.length;t0&&i[i.length-1])||h[0]!==6&&h[0]!==2)){o=0;continue}if(h[0]===3&&(!i||h[1]>i[0]&&h[1] "+t)||this}return Ie(e,n),e})(Error);var Io=function(n,e,t){if(e===void 0||t===void 0)return n.toUpperCase();var r=n.slice(e,t);return n=n.replace(r,function(i){return i.toUpperCase()})},Ka=function(n,e){e===void 0&&(e="utf-8");var t,r=0;if(e==="utf-16")for(var i=0,s=n.length;i0&&i.indexs.forEach(function(u){s.createIndex(u.indexName,u.key,{unique:u.unique})})}}(e,Jt,{indexs:[{indexName:"time",key:"time",unique:!1}],objectStoreParams:{autoIncrement:!0}})}var Li,ps=function(){function n(){}return n.init=function(){if(typeof window!="undefined"&&window&&window.indexedDB){var e=window.indexedDB.open("RC_ENGINE_DB",2);e.onerror=function(t){console.warn("open indexDB request failed "+t.target.error)},e.onsuccess=function(t){n._db=t.target.result,n._db&&(n._db.onclose=function(r){var i;console.warn("The database "+((i=n._db)===null||i===void 0?void 0:i.name)+" has unexpectedly closed.",r),n._db=null,n._instance=null},n._db.onerror=function(r){var i;console.warn("The database "+((i=n._db)===null||i===void 0?void 0:i.name)+" has opening error.",r),n._db=null,n._instance=null},n._db.onabort=function(r){var i;console.warn("The database "+((i=n._db)===null||i===void 0?void 0:i.name)+" has opening aborted.",r),n._db=null,n._instance=null}),n._instance=new n},e.onupgradeneeded=function(t){n._db=t.target.result,zu(t)}}else console.debug("IndexDB is not currently supported in the environment!")},n.getInstance=function(){return n._instance},n.prototype.addList=function(e,t){return new Promise(function(r){if(n._db){var i=n._db.transaction([e],"readwrite"),s=i.objectStore(e);t.forEach(function(o){s==null||s.add(o)}),i.oncomplete=function(o){r(!0)},i.onerror=function(o){r(!1)}}else r(!1)})},n.prototype.getRangeData=function(e,t,r,i){return new Promise(function(s){if(n._db){var o=n._db.transaction([e],"readwrite").objectStore(e),u=IDBKeyRange.bound(r,i),d=o.index(t),l=[],h=d.openCursor(u);h.onsuccess=function(a){var c=a.target.result;c?(l.push(c.value),c.continue()):s(l)},h.onerror=function(a){console.error(a),s([])}}else s([])})},n.prototype.getCount=function(e,t){return new Promise(function(r){if(n._db){var i=n._db.transaction([e],"readonly").objectStore(e).count();i.onsuccess=function(){r(i.result)},i.onerror=function(s){console.error(s),r(0)}}else r(0)})},n.prototype.removeFirstData=function(e,t,r){return new Promise(function(i){if(n._db){var s=n._db.transaction([e],"readwrite").objectStore(e),o=s.getAllKeys(IDBKeyRange.lowerBound(0),r);o.onsuccess=function(){var u=o.result;u.length>0&&(s.delete(IDBKeyRange.bound(u[0],u[u.length-1])).onsuccess=function(){i(!0)})}}else i(!1)})},n._db=null,n}(),qa=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(n){var e=16*Math.random()|0;return(n==="x"?e:3&e|8).toString(16)})},Ga=function(){var n=qa();if(n=n.replace(/-/g,"")+"a",(n=function(r){var i="0123456789abcdefghigklmnopqrstuvwxyzABCDEFGHIGKLMNOPQRSTUVWXYZa0".split(""),s=i.length+1,o=+r,u=[];do{var d=o%s;o=(o-d)/s,u.unshift(i[d])}while(o);return u.join("")}(n=parseInt(n,16))).length>22&&(n=n.slice(0,22)),n.length<22)for(var e=22-n.length,t=0;t0},Ve=function(n){return Object.prototype.toString.call(n)==="[object Object]"},Ir=function(n){return Object.prototype.toString.call(n)==="[object Function]"},fe=function(n){return n===void 0||Object.prototype.toString.call(n)==="[object Undefined]"},bo=function(n){return Object.prototype.toString.call(n)==="[object Null]"},Pn=function(n){return Qe(n)&&/https?:\/\//.test(n)},Sn=function(n){for(var e in n)return!0;return!1},Qu=function(n){return Te(n)&&Object.prototype.hasOwnProperty.call(ke,n)},Oo=((Ft={})[Pe.DEBUG]=console.debug.bind(console),Ft[Pe.INFO]=console.info.bind(console),Ft[Pe.WARN]=console.warn.bind(console),Ft[Pe.ERROR]=console.error.bind(console),Ft[Pe.FATAL]=console.log.bind(console),Ft),No=function(n){return Qe(n)||Te(n)||fe(n)||Sr(n)?n:n instanceof Error?JSON.stringify({name:n.name,message:n.message,stack:n.stack}):JSON.stringify(n)},wt=function(){function n(e,t,r){this.tag=e,this.type=t,this.initiator=r,this._outLevel=Pe.WARN,this.debug=this.log.bind(this,Pe.DEBUG),this.info=this.log.bind(this,Pe.INFO),this.warn=this.log.bind(this,Pe.WARN),this.error=this.log.bind(this,Pe.ERROR),this.fatal=this.log.bind(this,Pe.FATAL)}return n.init=function(e){n.userId=e},n.reset=function(){n.userId=""},n.prototype._defaultStdout=function(e,t){for(var r=[],i=2;i=1e3&&(t=function(l,h,a){if(a===void 0&&(a="utf-8"),!l||!h)return"";var c=a==="utf-8"?3:2,p=0,f=0,m="";for(f=0;f255?p+=c:p++,p>h)return m;m+=l.charAt(f)}return l}(t,1e3));var o=JSON.stringify({message:t,userId:n.userId}).replace(/"/g,'""'),u=/^[\w]+-[\w]+-[\w]+?/.test(r)?r:(this.initiator||"L")+"-"+r+"-O",d={sessionId:n.sessionId,time:s,level:4-e,content:n.sessionId+","+Date.now()+","+i+","+(4-e)+","+u+',"'+o+`" `,userId:n.userId};n.databaseLogList.push(d),(n.databaseLogList.length>=100||e===Pe.FATAL)&&this.__insertLogIntoDatabase()},n.prototype.__insertLogIntoDatabase=function(){return x(this,void 0,void 0,function(){var e,t,r;return V(this,function(i){switch(i.label){case 0:return e=Ut([],n.databaseLogList),n.databaseLogList=[],(t=ps.getInstance())?[4,t.addList(Jt,e)]:[3,3];case 1:return r=i.sent(),[4,t.getCount(Jt,"time")];case 2:return i.sent()>1e5&&t.removeFirstData(Jt,"time",2e3),[2,r];case 3:return[2,!1]}})})},n.prototype.setLogLevel=function(e){this._outLevel=typeof e!="number"?Pe.WARN:e},n.prototype.setLogStdout=function(e){this._logStdout=e},n.prototype.log=function(e){for(var t=[],r=1;rPe.DEBUG&&this.__pushLocalLog(e,t.map(No).join(" "),this.tag),!(e=600&&(n.realTimeLogList=n.realTimeLogList.slice(-500))},n.prototype.set=function(e,t){this.warn("logger.set has being deprecated!")},n.prototype.setStdout=function(e){this._stdout=e},n.prototype.__clearRealTimeLog=function(){n.realTimeLogList=[]},n.databaseLogList=[],n.realTimeLogList=[],n.sessionId=Ga(),n.userId="",n}(),j=new wt("RCLog"),jn=function(){function n(){this._map={}}return n.prototype.on=function(e,t,r){var i=this._map[e]||(this._map[e]=[]);i.some(function(s){return s.listener===t&&s.target===r})||i.push({listener:t,target:r})},n.prototype.once=function(e,t,r){var i=this._map[e]||(this._map[e]=[]);i.some(function(s){return s.listener===t&&s.target===r})||i.push({listener:t,target:r,once:!0})},n.prototype.off=function(e,t,r){var i=this._map[e];i&&((i=i.filter(function(s){return s.listener!==t||s.target!==r})).length?this._map[e]=i:delete this._map[e])},n.prototype.emit=function(e){for(var t=[],r=1;r=0;s-=1){var o=i[s],u=o.target,d=o.once,l=o.listener;d&&i.splice(s,1);try{l.call.apply(l,Ut([u],t))}catch(h){j.error(h)}}},n.prototype.removeAll=function(e){delete this._map[e]},n.prototype.clear=function(){Object.keys(this._map).forEach(this.removeAll,this)},n}();(function(n){n[n.SEND=1]="SEND",n[n.RECEIVE=2]="RECEIVE"})(Ui||(Ui={}));var Di,nt=Ui;(function(n){n[n.TIMEOUT=-1]="TIMEOUT",n[n.UNKNOWN=-2]="UNKNOWN",n[n.PARAMETER_ERROR=-3]="PARAMETER_ERROR",n[n.EXTRA_METHOD_UNDEFINED=-4]="EXTRA_METHOD_UNDEFINED",n[n.MAIN_PROCESS_ERROR=-5]="MAIN_PROCESS_ERROR",n[n.PARAMETER_CHANGED=-6]="PARAMETER_CHANGED",n[n.SUCCESS=0]="SUCCESS",n[n.RC_MSG_UNAUTHORIZED=20406]="RC_MSG_UNAUTHORIZED",n[n.RC_DISCUSSION_GROUP_ID_INVALID=20407]="RC_DISCUSSION_GROUP_ID_INVALID",n[n.SEND_FREQUENCY_TOO_FAST=20604]="SEND_FREQUENCY_TOO_FAST",n[n.NOT_IN_DISCUSSION=21406]="NOT_IN_DISCUSSION",n[n.FORBIDDEN_IN_GROUP=22408]="FORBIDDEN_IN_GROUP",n[n.RECALL_MESSAGE=25101]="RECALL_MESSAGE",n[n.NOT_IN_GROUP=22406]="NOT_IN_GROUP",n[n.NOT_IN_CHATROOM=23406]="NOT_IN_CHATROOM",n[n.FORBIDDEN_IN_CHATROOM=23408]="FORBIDDEN_IN_CHATROOM",n[n.RC_CHATROOM_USER_KICKED=23409]="RC_CHATROOM_USER_KICKED",n[n.RC_CHATROOM_NOT_EXIST=23410]="RC_CHATROOM_NOT_EXIST",n[n.RC_CHATROOM_IS_FULL=23411]="RC_CHATROOM_IS_FULL",n[n.RC_CHATROOM_PATAMETER_INVALID=23412]="RC_CHATROOM_PATAMETER_INVALID",n[n.CHATROOM_GET_HISTORYMSG_ERROR=23413]="CHATROOM_GET_HISTORYMSG_ERROR",n[n.CHATROOM_NOT_OPEN_HISTORYMSG_STORE=23414]="CHATROOM_NOT_OPEN_HISTORYMSG_STORE",n[n.CHATROOM_KV_EXCEED=23423]="CHATROOM_KV_EXCEED",n[n.CHATROOM_KV_OVERWRITE_INVALID=23424]="CHATROOM_KV_OVERWRITE_INVALID",n[n.CHATROOM_KV_STORE_NOT_OPEN=23426]="CHATROOM_KV_STORE_NOT_OPEN",n[n.CHATROOM_KEY_NOT_EXIST=23427]="CHATROOM_KEY_NOT_EXIST",n[n.SENSITIVE_SHIELD=21501]="SENSITIVE_SHIELD",n[n.SENSITIVE_REPLACE=21502]="SENSITIVE_REPLACE",n[n.JOIN_IN_DISCUSSION=21407]="JOIN_IN_DISCUSSION",n[n.CREATE_DISCUSSION=21408]="CREATE_DISCUSSION",n[n.INVITE_DICUSSION=21409]="INVITE_DICUSSION",n[n.GET_USERINFO_ERROR=23407]="GET_USERINFO_ERROR",n[n.REJECTED_BY_BLACKLIST=405]="REJECTED_BY_BLACKLIST",n[n.RC_NET_CHANNEL_INVALID=30001]="RC_NET_CHANNEL_INVALID",n[n.RC_NET_UNAVAILABLE=30002]="RC_NET_UNAVAILABLE",n[n.RC_MSG_RESP_TIMEOUT=30003]="RC_MSG_RESP_TIMEOUT",n[n.RC_HTTP_SEND_FAIL=30004]="RC_HTTP_SEND_FAIL",n[n.RC_HTTP_REQ_TIMEOUT=30005]="RC_HTTP_REQ_TIMEOUT",n[n.RC_HTTP_RECV_FAIL=30006]="RC_HTTP_RECV_FAIL",n[n.RC_NAVI_RESOURCE_ERROR=30007]="RC_NAVI_RESOURCE_ERROR",n[n.RC_NODE_NOT_FOUND=30008]="RC_NODE_NOT_FOUND",n[n.RC_DOMAIN_NOT_RESOLVE=30009]="RC_DOMAIN_NOT_RESOLVE",n[n.RC_SOCKET_NOT_CREATED=30010]="RC_SOCKET_NOT_CREATED",n[n.RC_SOCKET_DISCONNECTED=30011]="RC_SOCKET_DISCONNECTED",n[n.RC_PING_SEND_FAIL=30012]="RC_PING_SEND_FAIL",n[n.RC_PONG_RECV_FAIL=30013]="RC_PONG_RECV_FAIL",n[n.RC_MSG_SEND_FAIL=30014]="RC_MSG_SEND_FAIL",n[n.RC_MSG_CONTENT_EXCEED_LIMIT=30016]="RC_MSG_CONTENT_EXCEED_LIMIT",n[n.RC_CONN_ACK_TIMEOUT=31e3]="RC_CONN_ACK_TIMEOUT",n[n.RC_CONN_PROTO_VERSION_ERROR=31001]="RC_CONN_PROTO_VERSION_ERROR",n[n.RC_CONN_ID_REJECT=31002]="RC_CONN_ID_REJECT",n[n.RC_CONN_SERVER_UNAVAILABLE=31003]="RC_CONN_SERVER_UNAVAILABLE",n[n.RC_CONN_USER_OR_PASSWD_ERROR=31004]="RC_CONN_USER_OR_PASSWD_ERROR",n[n.RC_CONN_NOT_AUTHRORIZED=31005]="RC_CONN_NOT_AUTHRORIZED",n[n.RC_CONN_REDIRECTED=31006]="RC_CONN_REDIRECTED",n[n.RC_CONN_PACKAGE_NAME_INVALID=31007]="RC_CONN_PACKAGE_NAME_INVALID",n[n.RC_CONN_APP_BLOCKED_OR_DELETED=31008]="RC_CONN_APP_BLOCKED_OR_DELETED",n[n.RC_CONN_USER_BLOCKED=31009]="RC_CONN_USER_BLOCKED",n[n.RC_DISCONN_KICK=31010]="RC_DISCONN_KICK",n[n.RC_DISCONN_EXCEPTION=31011]="RC_DISCONN_EXCEPTION",n[n.RC_APP_AUTH_NOT_PASS=31026]="RC_APP_AUTH_NOT_PASS",n[n.RC_OTP_USED=31027]="RC_OTP_USED",n[n.RC_PLATFORM_ERROR=31028]="RC_PLATFORM_ERROR",n[n.RC_QUERY_ACK_NO_DATA=32001]="RC_QUERY_ACK_NO_DATA",n[n.RC_MSG_DATA_INCOMPLETE=32002]="RC_MSG_DATA_INCOMPLETE",n[n.BIZ_ERROR_CLIENT_NOT_INIT=33001]="BIZ_ERROR_CLIENT_NOT_INIT",n[n.BIZ_ERROR_DATABASE_ERROR=33002]="BIZ_ERROR_DATABASE_ERROR",n[n.BIZ_ERROR_INVALID_PARAMETER=33003]="BIZ_ERROR_INVALID_PARAMETER",n[n.BIZ_ERROR_NO_CHANNEL=33004]="BIZ_ERROR_NO_CHANNEL",n[n.BIZ_ERROR_RECONNECT_SUCCESS=33005]="BIZ_ERROR_RECONNECT_SUCCESS",n[n.BIZ_ERROR_CONNECTING=33006]="BIZ_ERROR_CONNECTING",n[n.MSG_ROAMING_SERVICE_UNAVAILABLE=33007]="MSG_ROAMING_SERVICE_UNAVAILABLE",n[n.MSG_INSERT_ERROR=33008]="MSG_INSERT_ERROR",n[n.MSG_DEL_ERROR=33009]="MSG_DEL_ERROR",n[n.TAG_EXISTS=33101]="TAG_EXISTS",n[n.TAG_NOT_EXIST=33100]="TAG_NOT_EXIST",n[n.NO_TAG_IN_CONVER=33102]="NO_TAG_IN_CONVER",n[n.CONVER_REMOVE_ERROR=34001]="CONVER_REMOVE_ERROR",n[n.CONVER_GETLIST_ERROR=34002]="CONVER_GETLIST_ERROR",n[n.CONVER_SETOP_ERROR=34003]="CONVER_SETOP_ERROR",n[n.CONVER_TOTAL_UNREAD_ERROR=34004]="CONVER_TOTAL_UNREAD_ERROR",n[n.CONVER_TYPE_UNREAD_ERROR=34005]="CONVER_TYPE_UNREAD_ERROR",n[n.CONVER_ID_TYPE_UNREAD_ERROR=34006]="CONVER_ID_TYPE_UNREAD_ERROR",n[n.CONVER_CLEAR_ERROR=34007]="CONVER_CLEAR_ERROR",n[n.EXPANSION_LIMIT_EXCEET=34010]="EXPANSION_LIMIT_EXCEET",n[n.MESSAGE_KV_NOT_SUPPORT=34008]="MESSAGE_KV_NOT_SUPPORT",n[n.CLEAR_HIS_TIME_ERROR=34011]="CLEAR_HIS_TIME_ERROR",n[n.CONVER_OUT_LIMIT_ERROR=34013]="CONVER_OUT_LIMIT_ERROR",n[n.CONVER_GET_ERROR=35021]="CONVER_GET_ERROR",n[n.GROUP_SYNC_ERROR=35001]="GROUP_SYNC_ERROR",n[n.GROUP_MATCH_ERROR=35002]="GROUP_MATCH_ERROR",n[n.READ_RECEIPT_ERROR=35003]="READ_RECEIPT_ERROR",n[n.PACKAGE_ENVIRONMENT_ERROR=35006]="PACKAGE_ENVIRONMENT_ERROR",n[n.CAN_NOT_RECONNECT=35007]="CAN_NOT_RECONNECT",n[n.SERVER_UNAVAILABLE=35008]="SERVER_UNAVAILABLE",n[n.HOSTNAME_ERROR=35009]="HOSTNAME_ERROR",n[n.HAS_OHTER_SAME_CLIENT_ON_LINE=35010]="HAS_OHTER_SAME_CLIENT_ON_LINE",n[n.UPLOAD_FILE_FAILED=35020]="UPLOAD_FILE_FAILED",n[n.CHATROOM_ID_ISNULL=36001]="CHATROOM_ID_ISNULL",n[n.CHARTOOM_JOIN_ERROR=36002]="CHARTOOM_JOIN_ERROR",n[n.CHATROOM_HISMESSAGE_ERROR=36003]="CHATROOM_HISMESSAGE_ERROR",n[n.CHATROOM_KV_NOT_FOUND=36004]="CHATROOM_KV_NOT_FOUND",n[n.BLACK_ADD_ERROR=37001]="BLACK_ADD_ERROR",n[n.BLACK_GETSTATUS_ERROR=37002]="BLACK_GETSTATUS_ERROR",n[n.BLACK_REMOVE_ERROR=37003]="BLACK_REMOVE_ERROR",n[n.DRAF_GET_ERROR=38001]="DRAF_GET_ERROR",n[n.DRAF_SAVE_ERROR=38002]="DRAF_SAVE_ERROR",n[n.DRAF_REMOVE_ERROR=38003]="DRAF_REMOVE_ERROR",n[n.SUBSCRIBE_ERROR=39001]="SUBSCRIBE_ERROR",n[n.NOT_SUPPORT=39002]="NOT_SUPPORT",n[n.QNTKN_FILETYPE_ERROR=41001]="QNTKN_FILETYPE_ERROR",n[n.QNTKN_GET_ERROR=41002]="QNTKN_GET_ERROR",n[n.COOKIE_ENABLE=51001]="COOKIE_ENABLE",n[n.GET_MESSAGE_BY_ID_ERROR=61001]="GET_MESSAGE_BY_ID_ERROR",n[n.HAVNODEVICEID=24001]="HAVNODEVICEID",n[n.DEVICEIDISHAVE=24002]="DEVICEIDISHAVE",n[n.FEILD=24009]="FEILD",n[n.VOIPISNULL=24013]="VOIPISNULL",n[n.NOENGINETYPE=24010]="NOENGINETYPE",n[n.NULLCHANNELNAME=24011]="NULLCHANNELNAME",n[n.VOIPDYANMICERROR=24012]="VOIPDYANMICERROR",n[n.NOVOIP=24014]="NOVOIP",n[n.INTERNALERRROR=24015]="INTERNALERRROR",n[n.VOIPCLOSE=24016]="VOIPCLOSE",n[n.CLOSE_BEFORE_OPEN=51001]="CLOSE_BEFORE_OPEN",n[n.ALREADY_IN_USE=51002]="ALREADY_IN_USE",n[n.INVALID_CHANNEL_NAME=51003]="INVALID_CHANNEL_NAME",n[n.VIDEO_CONTAINER_IS_NULL=51004]="VIDEO_CONTAINER_IS_NULL",n[n.DELETE_MESSAGE_ID_IS_NULL=61001]="DELETE_MESSAGE_ID_IS_NULL",n[n.CANCEL=1]="CANCEL",n[n.REJECT=2]="REJECT",n[n.HANGUP=3]="HANGUP",n[n.BUSYLINE=4]="BUSYLINE",n[n.NO_RESPONSE=5]="NO_RESPONSE",n[n.ENGINE_UN_SUPPORTED=6]="ENGINE_UN_SUPPORTED",n[n.NETWORK_ERROR=7]="NETWORK_ERROR",n[n.REMOTE_CANCEL=11]="REMOTE_CANCEL",n[n.REMOTE_REJECT=12]="REMOTE_REJECT",n[n.REMOTE_HANGUP=13]="REMOTE_HANGUP",n[n.REMOTE_BUSYLINE=14]="REMOTE_BUSYLINE",n[n.REMOTE_NO_RESPONSE=15]="REMOTE_NO_RESPONSE",n[n.REMOTE_ENGINE_UN_SUPPORTED=16]="REMOTE_ENGINE_UN_SUPPORTED",n[n.REMOTE_NETWORK_ERROR=17]="REMOTE_NETWORK_ERROR",n[n.VOIP_NOT_AVALIABLE=18]="VOIP_NOT_AVALIABLE",n[n.CHATROOM_KV_STORE_NOT_ALL_SUCCESS=23428]="CHATROOM_KV_STORE_NOT_ALL_SUCCESS",n[n.CHATROOM_KV_STORE_OUT_LIMIT=23429]="CHATROOM_KV_STORE_OUT_LIMIT"})(Di||(Di={}));var xi,S=Di;(function(n){n[n.CONNECTED=0]="CONNECTED",n[n.CONNECTING=1]="CONNECTING",n[n.DISCONNECTED=2]="DISCONNECTED",n[n.NETWORK_UNAVAILABLE=3]="NETWORK_UNAVAILABLE",n[n.CONNECTION_CLOSED=4]="CONNECTION_CLOSED",n[n.KICKED_OFFLINE_BY_OTHER_CLIENT=6]="KICKED_OFFLINE_BY_OTHER_CLIENT",n[n.WEBSOCKET_UNAVAILABLE=7]="WEBSOCKET_UNAVAILABLE",n[n.WEBSOCKET_ERROR=8]="WEBSOCKET_ERROR",n[n.BLOCKED=9]="BLOCKED",n[n.DOMAIN_INCORRECT=12]="DOMAIN_INCORRECT",n[n.DISCONNECT_BY_SERVER=13]="DISCONNECT_BY_SERVER",n[n.REDIRECT=14]="REDIRECT",n[n.APPKEY_IS_FAKE=20]="APPKEY_IS_FAKE",n[n.ULTRALIMIT=1101]="ULTRALIMIT",n[n.REQUEST_NAVI=201]="REQUEST_NAVI",n[n.RESPONSE_NAVI=202]="RESPONSE_NAVI",n[n.RESPONSE_NAVI_ERROR=203]="RESPONSE_NAVI_ERROR",n[n.RESPONSE_NAVI_TIMEOUT=204]="RESPONSE_NAVI_TIMEOUT"})(xi||(xi={}));var Vi,te=xi,Be={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(n){n.TextMessage="RC:TxtMsg",n.VOICE="RC:VcMsg",n.HQ_VOICE="RC:HQVCMsg",n.IMAGE="RC:ImgMsg",n.GIF="RC:GIFMsg",n.RICH_CONTENT="RC:ImgTextMsg",n.LOCATION="RC:LBSMsg",n.FILE="RC:FileMsg",n.SIGHT="RC:SightMsg",n.COMBINE="RC:CombineMsg",n.CHRM_KV_NOTIFY="RC:chrmKVNotiMsg",n.LOG_COMMAND="RC:LogCmdMsg",n.EXPANSION_NOTIFY="RC:MsgExMsg",n.REFERENCE="RC:ReferenceMsg",n.RECALL="RC:RcCmd",n.READ_RECEIPT="RC:ReadNtf",n.READ_RECEIPT_REQUEST="RC:RRReqMsg",n.READ_RECEIPT_RESPONSE="RC:RRRspMsg",n.SYNC_READ_STATUS="RC:SRSMsg",n.GROUP_READ_RECEIPT_REQUEST="RC:RRMsg",n.CHATROOM_JOIN="RC:ChrmJoinNtf",n.CHATROOM_LEFT="RC:ChrmQuitNtf",n.CHATROOM_MERGE_CHANGE="RC:ChrmMemChange",n.TYPING_STATUS="RC:TypSts",n.INTERCEPT="RC:InterceptMsg"})(Vi||(Vi={}));var Bi,He=Vi;(function(n){n[n.OPEN=1]="OPEN",n[n.CLOSE=2]="CLOSE"})(Bi||(Bi={}));var Fi,Kt=Bi;(function(n){n[n.ALL=1]="ALL",n[n.SINGAL=2]="SINGAL"})(Fi||(Fi={}));var Hi,fs=Fi;(function(n){n[n.QINIU=1]="QINIU",n[n.ALI=2]="ALI",n[n.AWS=3]="AWS",n[n.STC=4]="STC"})(Hi||(Hi={}));var $i,Ge=Hi;(function(n){n[n.UPDATE=1]="UPDATE",n[n.DELETE=2]="DELETE"})($i||($i={}));var ji,We=$i;(function(n){n[n.QUIT=0]="QUIT",n[n.JOIN=1]="JOIN"})(ji||(ji={}));var wo,Ao=ji;(function(n){/*! 全局敏感词:命中了融云内置的全局敏感词 */n[n.GLOBAL=1]="GLOBAL",n[n.CUSTOM=2]="CUSTOM",n[n.THIRD_PARTY=3]="THIRD_PARTY"})(wo||(wo={}));var je,Mo,Po;(function(n){n[n.RTC=0]="RTC",n[n.LIVE=2]="LIVE"})(je||(je={})),function(n){n[n.AUDIO_AND_VIDEO=0]="AUDIO_AND_VIDEO",n[n.AUDIO=1]="AUDIO"}(Mo||(Mo={})),function(n){n[n.ANCHOR=1]="ANCHOR",n[n.AUDIENCE=2]="AUDIENCE"}(Po||(Po={}));var ht,br,Ki,Xu={"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(n){n[n.ROOM=1]="ROOM",n[n.PERSON=2]="PERSON"})(ht||(ht={})),function(n){n[n.AnchorToViewer=1]="AnchorToViewer",n[n.ViewerToAnchor=2]="ViewerToAnchor"}(br||(br={})),function(n){n[n.KICK=0]="KICK",n[n.REFUSE=1]="REFUSE",n[n.COEXIST=2]="COEXIST"}(Ki||(Ki={}));var dt,we,pi={engine:"5.1.1"},Dt=function(){function n(){}return n.add=function(e,t){pi[e]=t},n.validEngine=function(e){var t=e.match(/\d+\.\d+\.\d+/);if(!t)return j.warn("The validation engine version '"+e+"' is invalid!"),!1;var r=t[0].split(".").map(function(i){return i.padStart(3,"0")}).join("");return pi.engine.match(/\d+\.\d+\.\d+/)[0].split(".").map(function(i){return i.padStart(3,"0")}).join("")>=r},n.getInfo=function(){return pi},n}();(function(n){n[n.STRING=0]="STRING",n[n.ONLY_STRING=1]="ONLY_STRING",n[n.NUMBER=2]="NUMBER",n[n.BOOLEAN=3]="BOOLEAN",n[n.OBJECT=4]="OBJECT",n[n.ARRAY=5]="ARRAY",n[n.CALLBACK=6]="CALLBACK",n[n.CHANNEL_ID=7]="CHANNEL_ID"})(we||(we={}));var vt,Fe,Xe,xt,Lt,Zu=((dt={})[we.STRING]=ze,dt[we.ONLY_STRING]=Qe,dt[we.NUMBER]=Te,dt[we.BOOLEAN]=function(n){return typeof n=="boolean"},dt[we.OBJECT]=Ve,dt[we.ARRAY]=Ye,dt[we.CALLBACK]=function(n){var e=!0;return Ve(n)||(e=!1),(n=n||{}).onSuccess&&!Ir(n.onSuccess)&&(e=!1),n.onError&&!Ir(n.onError)&&(e=!1),e},dt[we.CHANNEL_ID]=function(n){var e=!1;return Qe(n)&&!/_/g.test(n)&&n.length<=20&&(e=!0),e},dt),ed=function(n){function e(t){var r=n.call(this,t)||this;return r.name="RCAssertError",r}return Ie(e,n),e}(Error),Ue=function(n,e,t,r){if(r===void 0&&(r=!1),!Ee(n,e,t,r))throw new ed("'"+n+"' is invalid: "+JSON.stringify(e))},Ee=function(n,e,t,r){r===void 0&&(r=!1),t=Zu[t]||t;var i=r&&!t(e)||!r&&!(fe(e)||e===null||t(e));return i&&j.error("'"+n+"' is invalid: "+JSON.stringify(e)),!i},Ze=function(n){if(!Ve(n)||n.low===void 0||n.high===void 0)return n;var e=n.low;return e<0&&(e+=4294967296),e=e.toString(16),parseInt(n.high.toString(16)+"00000000".replace(new RegExp("0{"+e.length+"}$"),e),16)},td=function(n,e){var t=Math.floor(1e3*Math.random()%1e4),r=qa(),i=function(d){d=d||"-";var l=new Date;return""+l.getFullYear()+d+(l.getMonth()+1)+d+l.getDate()}(),s=new Date().getTime(),o="";if(e){var u=e.split(".");o="."+u[u.length-1]}return n+"__RC-"+i+"_"+t+"_"+s+r+o},nd=function(n,e){n===void 0&&(n={}),e===void 0&&(e={});var t=n.threadId,r=n.apnsCollapseId,i=n.category,s=n.richMediaUri,o=e.channelIdMi,u=e.channelIdHW,d=e.channelIdOPPO,l=e.typeVivo,h=e.googleConfig,a={};a["thread-id"]=t||"",a["apns-collapse-id"]=r||"",a.category=i||"",a.richMediaUri=s||"";var c={};c.collapse_key=h==null?void 0:h.collapseKey,c.imageUrl=h==null?void 0:h.imageUrl;var p=h==null?void 0:h.priority;p&&!["high","normal"].includes(p)&&(p="normal"),c.priority=p;var f=[{HW:{channelId:u||""}},{MI:{channelId:o||""}},{OPPO:{channelId:d||""}},{VIVO:{classification:l||""}},{APNS:a},{FCM:c}];return JSON.stringify(f)},Lo=function(n,e){var t={},r={notificationId:e||""};if(!n)return{iOSConfig:t,androidConfig:r};try{var i=JSON.parse(n);i==null||i.forEach(function(s){var o,u,d,l,h=Object.keys(s);if(h.length!==0){var a=h[0];switch(a){case"HW":return void(r.channelIdHW=(o=s[a])===null||o===void 0?void 0:o.channelId);case"MI":return void(r.channelIdMi=(u=s[a])===null||u===void 0?void 0:u.channelId);case"OPPO":return void(r.channelIdOPPO=(d=s[a])===null||d===void 0?void 0:d.channelId);case"VIVO":return void(r.typeVivo=(l=s[a])===null||l===void 0?void 0:l.classification);case"APNS":return t.threadId=s[a]["thread-id"],t.apnsCollapseId=s[a]["apns-collapse-id"],t.category=s[a].category,void(t.richMediaUri=s[a].richMediaUri);case"FCM":r.googleConfig={collapseKey:s[a].collapse_key||"",imageUrl:s[a].imageUrl||"",priority:s[a].priority||""}}}})}catch{j.error("Wrong format for pushConfigs field! content: "+n)}return{iOSConfig:t,androidConfig:r}},Ht=function(n){var e=/^[A-Za-z0-9_=+-]+$/.test(n),t=n.length;return e&&t<=128&&t>=1},fi=function(n){var e=n.length;return e<=4096&&e>=1},Oe=function(n,e,t){e=e||function(){};var r=(t=t||{}).isReverse;Ve(n)&&function(){for(var i in n)e(n[i],i,n)}(),(Ye(n)||Qe(n))&&function(){if(r)for(var i=n.length-1;i>=0;i--)e(n[i],i);else for(var s=0,o=n.length;s0;e&&s&&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=t,this.qos=r,this._dup=i)}return n.prototype.encode=function(){var e=this.type<<4;return e|=this._retain?1:0,e|=this.qos<<1,e|=this._dup?8:0},n}(),Kn=function(){function n(){}return n.writeUTF=function(e,t){var r=[],i=0;if(Qe(e))for(var s=0,o=e.length;s=0&&u<=127?(i+=1,r.push(u)):u>=128&&u<=2047?(i+=2,r.push(192|31&u>>6),r.push(128|63&u)):u>=2048&&u<=65535&&(i+=3,r.push(224|15&u>>12),r.push(128|63&u>>6),r.push(128|63&u))}for(s=0,o=r.length;s255&&(r[s]&=255);return t?r:i<=255?[0,i].concat(r):[i>>8,255&i].concat(r)},n.readUTF=function(e){for(var t,r,i=[],s=-1,o=e,u="";++s1114111||Math.floor(d)!==d)throw RangeError("Invalid code point: "+d);d<=65535?i.push(d):(t=(d-=65536)>>10|55296,r=d%1024|56320,i.push(t,r)),(s+1===o.length||i.length>16384)&&(u+=String.fromCharCode.apply(null,i),i.length=0)}return u},n}(),od=function(){function n(e){this._position=0,this._poolLen=0,this._pool=e,this._poolLen=e.length}return n.prototype.check=function(){return this._position>=this._pool.length},n.prototype.read2Byte=function(){var e=this;if(e.check())return-1;for(var t="",r=0;r<2;r++){var i=e._pool[e._position++].toString(16);i.length===1&&(i="0"+i),t+=i.toString()}return parseInt(t,16)},n.prototype.readInt=function(){var e=this;if(e.check())return-1;for(var t="",r=0;r<4;r++){var i=e._pool[e._position++].toString(16);i.length===1&&(i="0"+i),t+=i.toString()}return parseInt(t,16)},n.prototype.readLong=function(){var e=this;if(e.check())return-1;for(var t="",r=0;r<8;r++){var i=e._pool[e._position++].toString(16);i.length===1&&(i="0"+i),t+=i}return parseInt(t,16)},n.prototype.readByte=function(){if(this.check())return-1;var e=this._pool[this._position++];return e>255&&(e&=255),e},n.prototype.readUTF=function(){if(this.check())return"";var e=this.readByte()<<8|this.readByte(),t=this._pool.subarray(this._position,this._position+=e);return Kn.readUTF(t)},n.prototype.readAll=function(){return this._pool.subarray(this._position,this._poolLen)},n}(),ad=function(){function n(){this._pool=[],this._position=0,this._writen=0}return n.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},n.prototype.writeArr=function(e){return this._pool=this._pool.concat(e),e},n.prototype.writeUTF=function(e){var t=Kn.writeUTF(e);this._pool=this._pool.concat(t),this._writen+=t.length},n.prototype.getBytesArray=function(){return this._pool},n}(),Ln="UpStreamMessage",ms="PushExtra",Jr="DownStreamMessage",kn="DownStreamMessages",_s="SessionsAttQryInput",Wa="SessionsAttOutput",vs="SyncRequestMsg",Rs="ChrmPullMsg",Or="NotifyMsg",Es="HistoryMsgInput",Un="HistoryMsgOuput",Nr="RelationQryInput",Dn="RelationsOutput",Cs="DeleteSessionsInput",ys="SessionInfo",za="DeleteSessionsOutput",Ts="RelationsInput",Ss="DeleteMsgInput",Is="CleanHisMsgInput",bs="SessionMsgReadInput",Os="ChrmInput",Ns="ChrmOutput",ws="QueryChatRoomInfoInput",Wr="QueryChatRoomInfoOutput",wr="RtcInput",kt="RtcUserListOutput",As="SetUserStatusInput",Ms="RtcSetDataInput",Ar="RtcUserSetDataInput",Mr="RtcDataInput",Ps="RtcSetOutDataInput",Ls="MCFollowInput",zr="RtcTokenOutput",Qr="RtcQryOutput",ks="RtcQryUserOutDataInput",Qa="RtcUserOutDataOutput",Us="RtcQueryListInput",Xa="RtcRoomInfoOutput",et="RtcValueInfo",Ds="RtcKeyDeleteInput",xs="GetQNupTokenInput",Vs="GetQNupTokenOutput",Bs="GetQNdownloadUrlInput",Fs="GetDownloadUrlInput",Hs="GetQNdownloadUrlOutput",$s="GetDownloadUrlOutput",js="SetChrmKV",Ks="SetChrmKVS",Za="DeleteChrmKVS",Wt="ChrmKVOutput",qs="ChrmKVSOutput",ec="ChrmKVSOutputEntity",Gs="QueryChrmKV",tc="SetUserSettingInput",zt="SetUserSettingOutput",Ys="PullUserSettingInput",Xr="PullUserSettingOutput",Zr="UserSettingNotification",Js="SessionReq",ei="SessionStates",Pr="SessionState",Lr="SessionStateItem",kr="SessionStateModifyReq",Ws="SessionStateModifyResp",Ur="GrpReadReceiptMsg",nc="GrpReadReceiptQryReq",ti="GrpReadReceiptQryResp",rc="GrpMsgReadUser",zs="SessionTagAddInput",In="SessionTagItem",Qs="SessionTagDelInput",Xs="SessionDisTagReq",Zs="ReportSDKInput",ic="ReportSDKOutput",eo="RtcNotifyMsg",to="RtcPullKV",ni="RtcKVOutput",no="RtcQueryUserJoinedInput",ri="RtcQueryUserJoinedOutput",sc="RtcViewerJoinedOutput",ro="RtcInviteInput",io="RtcCancelInviteInput",so="RtcInviteAnswerInput",oo="RtcEndInviteInput",oc=((K={})[Ln]=["sessionId","classname","content","pushText","userId","configFlag","appData","extraContent","pushExt","busChannel"],K[kn]=["list","syncTime","finished"],K[Jr]=["fromUserId","type","groupId","classname","content","dataTime","status","msgId","extraContent","pushContent","configFlag","pushExt","busChannel"],K[ms]=["title","templateIdNoUse","pushId","pushConfigs","templateId"],K[_s]=["nothing"],K[Wa]=["inboxTime","sendboxTime","totalUnreadCount"],K[vs]=["syncTime","ispolling","isweb","isPullSend","isKeeping","sendBoxSyncTime"],K[Rs]=["syncTime","count"],K[Or]=["type","time","chrmId"],K[Es]=["targetId","time","count","order","busChannel"],K[Un]=["list","syncTime","hasMsg"],K[Nr]=["type","count","startTime","order"],K[Dn]=["info"],K[Cs]=["sessions"],K[ys]=["type","channelId","busChannel"],K[za]=["nothing"],K[Ts]=["type","msg","count","busChannel","startTime","endTime"],K[Ss]=["type","conversationId","msgs","busChannel"],K[Is]=["targetId","dataTime","conversationType","busChannel"],K[bs]=["type","msgTime","channelId"],K[Os]=["nothing"],K[Ns]=["nothing","sessionId","joinTime"],K[ws]=["count","order"],K[Wr]=["userTotalNums","userInfos"],K[xs]=["type","key","httpMethod","queryString"],K[Bs]=["type","key","fileName"],K[Fs]=["type","key","fileName"],K[Vs]=["deadline","token","bosToken","bosDate","path","osskeyId","ossPolicy","ossSign","ossBucketName"],K[Hs]=["downloadUrl"],K[$s]=["downloadUrl"],K[js]=["entry","bNotify","notification","type"],K[Ks]=["entry","bNotify","notification","type"],K[Za]=["entry","bNotify","notification","type"],K[Wt]=["entries","bFullUpdate","syncTime"],K[qs]=["timestamp","errorKeys"],K[ec]=["key","errorCode"],K[Gs]=["timestamp"],K[tc]=["version","value"],K[zt]=["version","reserve"],K[Ys]=["version","reserve"],K[Xr]=["items","version"],K.UserSettingItem=["targetId","type","key","value","version","status","tags"],K[Js]=["time"],K[ei]=["version","state"],K[Pr]=["type","channelId","time","stateItem","busChannel"],K[Lr]=["sessionStateType","value","tags"],K[kr]=["version","state"],K[Ws]=["version"],K[Ur]=["msgId","busChannel"],K[nc]=["msgId","busChannel"],K[ti]=["totalMemberNum","list"],K[rc]=["readTime","userId"],K[zs]=["version","tags"],K[In]=["tagId","name","createdTime","isTop"],K[Qs]=["version","tags"],K[Xs]=["tagId"],K[Zr]=["version","reserve"],K[Zs]=["sdkInfo"],K[ic]=["nothing"],K[wr]=["roomType","broadcastType","extraInnerData","needSysChatroom","identityChangeType","joinType"],K[kt]=["users","token","sessionId","roomInfo"],K[As]=["status"],K[Ms]=["interior","target","key","value","objectName","content"],K[Ar]=["valueInfo","objectName","content"],K[Mr]=["interior","target","key","objectName","content"],K[Ps]=["target","valueInfo","objectName","content"],K[Ls]=["state"],K[zr]=["rtcToken"],K[Qr]=["outInfo"],K[ks]=["userId"],K[Qa]=["user"],K[Us]=["order"],K[Xa]=["roomId","roomData","userCount","list"],K[et]=["key","value"],K[Ds]=["key"],K[eo]=["type","time","roomId"],K[to]=["timestamp","roomId"],K[ni]=["entries","bFullUpdate","syncTime"],K[no]=["userId"],K[ri]=["info"],K[ro]=["invitedUserId","timeoutTime","invitedRoomId","inviteInfo","inviteSessionId"],K[io]=["invitedUserId","invitedRoomId","inviteInfo","inviteSessionId"],K[so]=["inviteUserID","answerCode","inviteRoomId","inviteSessionId","content","key","value"],K[oo]=["inviteRoomId","inviteSessionId","inviteContent","inviteRoomKeys"],K),xn={},cd=function(n){var e=oc[n];xn[n]=function(){for(var t={},r={getArrayData:function(){return t}},i=function(o){var u=e[o],d="set"+Io(u,0,1);r[d]=function(l){t[u]=l}},s=0;s]/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(s,o){function u(m,_){var v=-1,R=1;if(m.charAt(0)=="-"&&(R=-1,m=m.substring(1)),o.NUMBER_DEC.test(m))v=parseInt(m);else if(o.NUMBER_HEX.test(m))v=parseInt(m.substring(2),16);else{if(!o.NUMBER_OCT.test(m))throw Error("illegal id value: "+(R<0?"-":"")+m);v=parseInt(m.substring(1),8)}if(v=0|R*v,!_&&v<0)throw Error("illegal id value: "+(R<0?"-":"")+m);return v}function d(m){var _=1;if(m.charAt(0)=="-"&&(_=-1,m=m.substring(1)),o.NUMBER_DEC.test(m))return _*parseInt(m,10);if(o.NUMBER_HEX.test(m))return _*parseInt(m.substring(2),16);if(o.NUMBER_OCT.test(m))return _*parseInt(m.substring(1),8);if(m==="inf")return 1/0*_;if(m==="nan")return NaN;if(o.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,c={},p=function(m){this.source=m+"",this.index=0,this.line=1,this.stack=[],this._stringOpen=null},f=p.prototype;return f._readString=function(){var m,_=this._stringOpen==='"'?o.STRING_DQ:o.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]},f.next=function(){var m,_,v,R,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;o.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(R=this.index,o.DELIM.lastIndex=0,!o.DELIM.test(this.source.charAt(R++)))for(;R"),C=this.tn.next(),!o.NAME.test(C))throw Error("illegal message field name: "+C);R.name=C,this.tn.skip("="),R.id=u(this.tn.next()),(C=this.tn.peek())==="["&&this._parseFieldOptions(R),this.tn.skip(";")}else if((v=v!==void 0?v:this.tn.next())==="group"){if(A=this._parseMessage(m,R),!/^[A-Z]/.test(A.name))throw Error("illegal group name: "+A.name);R.type=A.name,R.name=A.name.toLowerCase(),this.tn.omit(";")}else{if(!o.TYPE.test(v)&&!o.TYPEREF.test(v))throw Error("illegal message field type: "+v);if(R.type=v,C=this.tn.next(),!o.NAME.test(C))throw Error("illegal message field name: "+C);R.name=C,this.tn.skip("="),R.id=u(this.tn.next()),(C=this.tn.peek())==="["&&this._parseFieldOptions(R),this.tn.skip(";")}return m.fields.push(R),R},a._parseMessageOneOf=function(m){var _,v,R,C=this.tn.next();if(!o.NAME.test(C))throw Error("illegal oneof name: "+C);for(v=C,R=[],this.tn.skip("{");(C=this.tn.next())!=="}";)(_=this._parseMessageField(m,"optional",C)).oneof=v,R.push(_.id);this.tn.omit(";"),m.oneofs[v]=R},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:{}},R=this.tn.next();if(!o.NAME.test(R))throw Error("illegal name: "+R);for(v.name=R,this.tn.skip("{");(R=this.tn.next())!=="}";)if(R==="option")this._parseOption(v);else{if(!o.NAME.test(R))throw Error("illegal name: "+R);this.tn.skip("="),_={name:R,id:u(this.tn.next(),!0)},(R=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,R=[];do{for(_=[];;){switch(m=this.tn.next()){case"min":v=s.ID_MIN;break;case"max":v=s.ID_MAX;break;default:v=d(m)}if(_.push(v),_.length===2)break;if(this.tn.peek()!=="to"){_.push(v);break}this.tn.next()}R.push(_)}while(this.tn.omit(","));return this.tn.skip(";"),R},a._parseExtend=function(m){var _,v=this.tn.next();if(!o.TYPEREF.test(v))throw Error("illegal extend reference: "+v);for(_={ref:v,fields:[]},this.tn.skip("{");(v=this.tn.next())!=="}";)if(o.RULE.test(v))this._parseMessageField(_,v);else{if(!o.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},c.Parser=h,c}(i,i.Lang),i.Reflect=function(s){function o(E,T){if(E&&typeof E.low=="number"&&typeof E.high=="number"&&typeof E.unsigned=="boolean"&&E.low==E.low&&E.high==E.high)return new s.Long(E.low,E.high,T===void 0?E.unsigned:T);if(typeof E=="string")return s.Long.fromString(E,T||!1,10);if(typeof E=="number")return s.Long.fromNumber(E,T||!1);throw Error("not convertible to Long")}function u(E,T){var N=T.readVarint32(),P=7&N,k=N>>>3;switch(P){case s.WIRE_TYPES.VARINT:do N=T.readUint8();while((128&N)==128);break;case s.WIRE_TYPES.BITS64:T.offset+=8;break;case s.WIRE_TYPES.LDELIM:N=T.readVarint32(),T.offset+=N;break;case s.WIRE_TYPES.STARTGROUP:u(k,T);break;case s.WIRE_TYPES.ENDGROUP:if(k===E)return!1;throw Error("Illegal GROUPEND after unknown group: "+k+" ("+E+" expected)");case s.WIRE_TYPES.BITS32:T.offset+=4;break;default:throw Error("Illegal wire type in unknown group "+E+": "+P)}return!0}var d,l,h,a,c,p,f,m,_,v,R,C,A,M,O,y,w={},$=function(E,T,N){this.builder=E,this.parent=T,this.name=N,this.className},Y=$.prototype;return Y.fqn=function(){for(var E=this.name,T=this;(T=T.parent)!=null;)E=T.name+"."+E;return E},Y.toString=function(E){return(E?this.className+" ":"")+this.fqn()},Y.build=function(){throw Error(this.toString(!0)+" cannot be built directly")},w.T=$,(l=(d=function(E,T,N,P,k){$.call(this,E,T,N),this.className="Namespace",this.children=[],this.options=P||{},this.syntax=k||"proto2"}).prototype=Object.create($.prototype)).getChildren=function(E){var T,N,P;if((E=E||null)==null)return this.children.slice();for(T=[],N=0,P=this.children.length;P>N;++N)this.children[N]instanceof E&&T.push(this.children[N]);return T},l.addChild=function(E){var T;if(T=this.getChild(E.name))if(T instanceof c.Field&&T.name!==T.originalName&&this.getChild(T.originalName)===null)T.name=T.originalName;else{if(!(E instanceof c.Field&&E.name!==E.originalName&&this.getChild(E.originalName)===null))throw Error("Duplicate name in namespace "+this.toString(!0)+": "+E.name);E.name=E.originalName}this.children.push(E)},l.getChild=function(E){var T,N,P=typeof E=="number"?"id":"name";for(T=0,N=this.children.length;N>T;++T)if(this.children[T][P]===E)return this.children[T];return null},l.resolve=function(E,T){var N,P=typeof E=="string"?E.split("."):E,k=this,B=0;if(P[B]===""){for(;k.parent!==null;)k=k.parent;B++}do{do{if(!(k instanceof w.Namespace)){k=null;break}if(!((N=k.getChild(P[B]))&&N instanceof w.T&&(!T||N instanceof w.Namespace))){k=null;break}k=N,B++}while(BT;++T)(E=k[T])instanceof d&&(P[E.name]=E.build());return Object.defineProperty&&Object.defineProperty(P,"$options",{value:this.buildOpt()}),P},l.buildOpt=function(){var E,T,N,P,k={},B=Object.keys(this.options);for(E=0,T=B.length;T>E;++E)N=B[E],P=this.options[B[E]],k[N]=P;return k},l.getOption=function(E){return E===void 0?this.options:this.options[E]!==void 0?this.options[E]:null},w.Namespace=d,a=(h=function(E,T,N,P){if(this.type=E,this.resolvedType=T,this.isMapKey=N,this.syntax=P,N&&s.MAP_KEY_TYPES.indexOf(E)<0)throw Error("Invalid map key type: "+E.name)}).prototype,h.defaultFieldValue=function(E){if(typeof E=="string"&&(E=s.TYPES[E]),E.defaultValue===void 0)throw Error("default value for type "+E.name+" is not supported");return E==s.TYPES.bytes?new t(0):E.defaultValue},a.verifyValue=function(E){var T,N,P,k=function(B,H){throw Error("Illegal value for "+this.toString(!0)+" of type "+this.type.name+": "+B+" ("+H+")")}.bind(this);switch(this.type){case s.TYPES.int32:case s.TYPES.sint32:case s.TYPES.sfixed32:return(typeof E!="number"||E==E&&E%1!=0)&&k(typeof E,"not an integer"),E>4294967295?0|E:E;case s.TYPES.uint32:case s.TYPES.fixed32:return(typeof E!="number"||E==E&&E%1!=0)&&k(typeof E,"not an integer"),E<0?E>>>0:E;case s.TYPES.int64:case s.TYPES.sint64:case s.TYPES.sfixed64:if(s.Long)try{return o(E,!1)}catch(B){k(typeof E,B.message)}else k(typeof E,"requires Long.js");case s.TYPES.uint64:case s.TYPES.fixed64:if(s.Long)try{return o(E,!0)}catch(B){k(typeof E,B.message)}else k(typeof E,"requires Long.js");case s.TYPES.bool:return typeof E!="boolean"&&k(typeof E,"not a boolean"),E;case s.TYPES.float:case s.TYPES.double:return typeof E!="number"&&k(typeof E,"not a number"),E;case s.TYPES.string:return typeof E=="string"||E&&E instanceof String||k(typeof E,"not a string"),""+E;case s.TYPES.bytes:return n.isByteBuffer(E)?E:n.wrap(E);case s.TYPES.enum:for(T=this.resolvedType.getChildren(s.Reflect.Enum.Value),P=0;P4294967295||E<0)&&k(typeof E,"not in range for uint32"),E;k(E,"not a valid enum value");case s.TYPES.group:case s.TYPES.message:if(E&&typeof E=="object"||k(typeof E,"object expected"),E instanceof this.resolvedType.clazz)return E;if(E instanceof s.Builder.Message){for(P in N={},E)E.hasOwnProperty(P)&&(N[P]=E[P]);E=N}return new this.resolvedType.clazz(E)}throw Error("[INTERNAL] Illegal value for "+this.toString(!0)+": "+E+" (undefined type "+this.type+")")},a.calculateLength=function(E,T){if(T===null)return 0;var N;switch(this.type){case s.TYPES.int32:return T<0?t.calculateVarint64(T):t.calculateVarint32(T);case s.TYPES.uint32:return t.calculateVarint32(T);case s.TYPES.sint32:return t.calculateVarint32(t.zigZagEncode32(T));case s.TYPES.fixed32:case s.TYPES.sfixed32:case s.TYPES.float:return 4;case s.TYPES.int64:case s.TYPES.uint64:return t.calculateVarint64(T);case s.TYPES.sint64:return t.calculateVarint64(t.zigZagEncode64(T));case s.TYPES.fixed64:case s.TYPES.sfixed64:return 8;case s.TYPES.bool:return 1;case s.TYPES.enum:return t.calculateVarint32(T);case s.TYPES.double:return 8;case s.TYPES.string:return N=t.calculateUTF8Bytes(T),t.calculateVarint32(N)+N;case s.TYPES.bytes:if(T.remaining()<0)throw Error("Illegal value for "+this.toString(!0)+": "+T.remaining()+" bytes remaining");return t.calculateVarint32(T.remaining())+T.remaining();case s.TYPES.message:return N=this.resolvedType.calculate(T),t.calculateVarint32(N)+N;case s.TYPES.group:return(N=this.resolvedType.calculate(T))+t.calculateVarint32(E<<3|s.WIRE_TYPES.ENDGROUP)}throw Error("[INTERNAL] Illegal value to encode in "+this.toString(!0)+": "+T+" (unknown type)")},a.encodeValue=function(E,T,N){var P,k;if(T===null)return N;switch(this.type){case s.TYPES.int32:T<0?N.writeVarint64(T):N.writeVarint32(T);break;case s.TYPES.uint32:N.writeVarint32(T);break;case s.TYPES.sint32:N.writeVarint32ZigZag(T);break;case s.TYPES.fixed32:N.writeUint32(T);break;case s.TYPES.sfixed32:N.writeInt32(T);break;case s.TYPES.int64:case s.TYPES.uint64:N.writeVarint64(T);break;case s.TYPES.sint64:N.writeVarint64ZigZag(T);break;case s.TYPES.fixed64:N.writeUint64(T);break;case s.TYPES.sfixed64:N.writeInt64(T);break;case s.TYPES.bool:typeof T=="string"?N.writeVarint32(T.toLowerCase()==="false"?0:!!T):N.writeVarint32(T?1:0);break;case s.TYPES.enum:N.writeVarint32(T);break;case s.TYPES.float:N.writeFloat32(T);break;case s.TYPES.double:N.writeFloat64(T);break;case s.TYPES.string:N.writeVString(T);break;case s.TYPES.bytes:if(T.remaining()<0)throw Error("Illegal value for "+this.toString(!0)+": "+T.remaining()+" bytes remaining");P=T.offset,N.writeVarint32(T.remaining()),N.append(T),T.offset=P;break;case s.TYPES.message:k=new t().LE(),this.resolvedType.encode(T,k),N.writeVarint32(k.offset),N.append(k.flip());break;case s.TYPES.group:this.resolvedType.encode(T,N),N.writeVarint32(E<<3|s.WIRE_TYPES.ENDGROUP);break;default:throw Error("[INTERNAL] Illegal value to encode in "+this.toString(!0)+": "+T+" (unknown type)")}return N},a.decode=function(E,T,N){if(T!=this.type.wireType)throw Error("Unexpected wire type for element");var P,k;switch(this.type){case s.TYPES.int32:return 0|E.readVarint32();case s.TYPES.uint32:return E.readVarint32()>>>0;case s.TYPES.sint32:return 0|E.readVarint32ZigZag();case s.TYPES.fixed32:return E.readUint32()>>>0;case s.TYPES.sfixed32:return 0|E.readInt32();case s.TYPES.int64:return E.readVarint64();case s.TYPES.uint64:return E.readVarint64().toUnsigned();case s.TYPES.sint64:return E.readVarint64ZigZag();case s.TYPES.fixed64:return E.readUint64();case s.TYPES.sfixed64:return E.readInt64();case s.TYPES.bool:return!!E.readVarint32();case s.TYPES.enum:return E.readVarint32();case s.TYPES.float:return E.readFloat();case s.TYPES.double:return E.readDouble();case s.TYPES.string:return E.readVString();case s.TYPES.bytes:if(k=E.readVarint32(),E.remaining()G;++G)this[ue[G].name]=null;for(G=0,Z=de.length;Z>G;++G)this[(ne=de[G]).name]=ne.repeated?[]:ne.map?new B.Map(ne):null,!ne.required&&H.syntax!=="proto3"||ne.defaultValue===null||(this[ne.name]=ne.defaultValue);if(arguments.length>0)if(arguments.length!==1||U===null||typeof U!="object"||!(typeof U.encode!="function"||U instanceof ie)||Array.isArray(U)||U instanceof B.Map||t.isByteBuffer(U)||U instanceof ArrayBuffer||B.Long&&U instanceof B.Long)for(G=0,Z=arguments.length;Z>G;++G)(ce=arguments[G])!==void 0&&this.$set(de[G].name,ce);else this.$set(U)},ee=ie.prototype=Object.create(B.Builder.Message.prototype);for(ee.add=function(U,G,Z){var ne=H._fieldsByName[U];if(!Z){if(!ne)throw Error(this+"#"+U+" is undefined");if(!(ne instanceof B.Reflect.Message.Field))throw Error(this+"#"+U+" is not a field: "+ne.toString(!0));if(!ne.repeated)throw Error(this+"#"+U+" is not a repeated field");G=ne.verifyValue(G,!0)}return this[U]===null&&(this[U]=[]),this[U].push(G),this},ee.$add=ee.add,ee.set=function(U,G,Z){var ne,ce,ve;if(U&&typeof U=="object"){for(ne in Z=G,U)U.hasOwnProperty(ne)&&(G=U[ne])!==void 0&&this.$set(ne,G,Z);return this}if(ce=H._fieldsByName[U],Z)this[U]=G;else{if(!ce)throw Error(this+"#"+U+" is not a field: undefined");if(!(ce instanceof B.Reflect.Message.Field))throw Error(this+"#"+U+" is not a field: "+ce.toString(!0));this[ce.name]=G=ce.verifyValue(G)}return ce&&ce.oneof&&(ve=this[ce.oneof.name],G!==null?(ve!==null&&ve!==ce.name&&(this[ve]=null),this[ce.oneof.name]=ce.name):ve===U&&(this[ce.oneof.name]=null)),this},ee.$set=ee.set,ee.get=function(U,G){if(G)return this[U];var Z=H._fieldsByName[U];if(!(Z&&Z instanceof B.Reflect.Message.Field))throw Error(this+"#"+U+" is not a field: undefined");if(!(Z instanceof B.Reflect.Message.Field))throw Error(this+"#"+U+" is not a field: "+Z.toString(!0));return this[Z.name]},ee.$get=ee.get,J=0;JP;P++)if((N=this.children[P])instanceof R||N instanceof c||N instanceof M){if(T.hasOwnProperty(N.name))throw Error("Illegal reflect child of "+this.toString(!0)+": "+N.toString(!0)+" cannot override static property '"+N.name+"'");T[N.name]=N.build()}else if(N instanceof c.Field)N.build(),this._fields.push(N),this._fieldsById[N.id]=N,this._fieldsByName[N.name]=N;else if(!(N instanceof c.OneOf||N instanceof A))throw Error("Illegal reflect child of "+this.toString(!0)+": "+this.children[P].toString(!0));return this.clazz=T},p.encode=function(E,T,N){var P,k,B,H,q,J=null;for(B=0,H=this._fields.length;H>B;++B)k=E[(P=this._fields[B]).name],P.required&&k===null?J===null&&(J=P):P.encode(N?k:P.verifyValue(k),T,E);if(J!==null)throw(q=Error("Missing at least one required field for "+this.toString(!0)+": "+J)).encoded=T,q;return T},p.calculate=function(E){for(var T,N,P=0,k=0,B=this._fields.length;B>k;++k){if(N=E[(T=this._fields[k]).name],T.required&&N===null)throw Error("Missing at least one required field for "+this.toString(!0)+": "+T);P+=T.calculate(N,E)}return P},p.decode=function(E,T,N){var P,k,B,H,q,J,re,de,ue,ie,ee,U;for(T=typeof T=="number"?T:-1,q=E.offset,J=new this.clazz;E.offset0;){if(B=(P=E.readVarint32())>>>3,(k=7&P)===s.WIRE_TYPES.ENDGROUP){if(B!==N)throw Error("Illegal group end indicator for "+this.toString(!0)+": "+B+" ("+(N?N+" expected":"not a group")+")");break}if(H=this._fieldsById[B])H.repeated&&!H.options.packed?J[H.name].push(H.decode(k,E)):H.map?(de=H.decode(k,E),J[H.name].set(de[0],de[1])):(J[H.name]=H.decode(k,E),H.oneof&&((ue=J[H.oneof.name])!==null&&ue!==H.name&&(J[ue]=null),J[H.oneof.name]=H.name));else switch(k){case s.WIRE_TYPES.VARINT:E.readVarint32();break;case s.WIRE_TYPES.BITS32:E.offset+=4;break;case s.WIRE_TYPES.BITS64:E.offset+=8;break;case s.WIRE_TYPES.LDELIM:re=E.readVarint32(),E.offset+=re;break;case s.WIRE_TYPES.STARTGROUP:for(;u(B,E););break;default:throw Error("Illegal wire type for unknown field "+B+" in "+this.toString(!0)+"#decode: "+k)}}for(ie=0,ee=this._fields.length;ee>ie;++ie)if(J[(H=this._fields[ie]).name]===null)if(this.syntax==="proto3")J[H.name]=H.defaultValue;else{if(H.required)throw(U=Error("Missing at least one required field for "+this.toString(!0)+": "+H.name)).decoded=J,U;s.populateDefaults&&H.defaultValue!==null&&(J[H.name]=H.defaultValue)}return J},w.Message=c,(m=(f=function(E,T,N,P,k,B,H,q,J,re){$.call(this,E,T,B),this.className="Message.Field",this.required=N==="required",this.repeated=N==="repeated",this.map=N==="map",this.keyType=P||null,this.type=k,this.resolvedType=null,this.id=H,this.options=q||{},this.defaultValue=null,this.oneof=J||null,this.syntax=re||"proto2",this.originalName=this.name,this.element=null,this.keyElement=null,!this.builder.options.convertFieldsToCamelCase||this instanceof c.ExtensionField||(this.name=s.Util.toCamelCase(this.name))}).prototype=Object.create($.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(E,T){var N,P,k;if(T=T||!1,N=function(B,H){throw Error("Illegal value for "+this.toString(!0)+" of type "+this.type.name+": "+B+" ("+H+")")}.bind(this),E===null)return this.required&&N(typeof E,"required"),this.syntax==="proto3"&&this.type!==s.TYPES.message&&N(typeof E,"proto3 field without field presence cannot be null"),null;if(this.repeated&&!T){for(Array.isArray(E)||(E=[E]),k=[],P=0;P0;case s.TYPES.bytes:return E.remaining()>0;case s.TYPES.enum:return E!==0;case s.TYPES.message:return E!==null;default:return!0}},m.encode=function(E,T,N){var P,k,B,H,q;if(this.type===null||typeof this.type!="object")throw Error("[INTERNAL] Unresolved type in "+this.toString(!0)+": "+this.type);if(E===null||this.repeated&&E.length==0)return T;try{if(this.repeated)if(this.options.packed&&s.PACKABLE_WIRE_TYPES.indexOf(this.type.wireType)>=0){for(T.writeVarint32(this.id<<3|s.WIRE_TYPES.LDELIM),T.ensureCapacity(T.offset+=1),k=T.offset,P=0;P1&&(q=T.slice(k,T.offset),k+=H-1,T.offset=k,T.append(q)),T.writeVarint32(B,k-H)}else for(P=0;P=0){for(N+=t.calculateVarint32(this.id<<3|s.WIRE_TYPES.LDELIM),k=0,P=0;P=0&&!N){for(k=T.readVarint32(),k=T.offset+k,B=[];T.offset0;)if(E=7&(J=q.readVarint32()),(re=J>>>3)==1)H=this.keyElement.decode(q,E,re);else{if(re!==2)throw Error("Unexpected tag in map field key/value submessage");P=this.element.decode(q,E,re)}return[H,P]}return this.element.decode(T,E,this.id)},w.Message.Field=f,(_=function(E,T,N,P,k,B,H){f.call(this,E,T,N,null,P,k,B,H),this.extension}).prototype=Object.create(f.prototype),w.Message.ExtensionField=_,v=function(E,T,N){$.call(this,E,T,N),this.fields=[]},w.Message.OneOf=v,(R=function(E,T,N,P,k){d.call(this,E,T,N,P,k),this.className="Enum",this.object=null}).getName=function(E,T){var N,P,k=Object.keys(E);for(P=0;PP;++P)T[N[P].name]=N[P].id;return Object.defineProperty&&Object.defineProperty(T,"$options",{value:this.buildOpt(),enumerable:!1}),this.object=T},w.Enum=R,(C=function(E,T,N,P){$.call(this,E,T,N),this.className="Enum.Value",this.id=P}).prototype=Object.create($.prototype),w.Enum.Value=C,(A=function(E,T,N,P){$.call(this,E,T,N),this.field=P}).prototype=Object.create($.prototype),w.Extension=A,((M=function(E,T,N,P){d.call(this,E,T,N,P),this.className="Service",this.clazz=null}).prototype=Object.create(d.prototype)).build=function(E){return this.clazz&&!E?this.clazz:this.clazz=function(T,N){var P,k=function(q){T.Builder.Service.call(this),this.rpcImpl=q||function(J,re,de){setTimeout(de.bind(this,Error("Not implemented, see: https://github.com/dcodeIO/ProtoBuf.js/wiki/Services")),0)}},B=k.prototype=Object.create(T.Builder.Service.prototype),H=N.getChildren(T.Reflect.Service.RPCMethod);for(P=0;P0;){if(a=c.pop(),!Array.isArray(a))throw Error("not a valid namespace: "+JSON.stringify(a));for(;a.length>0;){if(p=a.shift(),l.isMessage(p)){if(f=new u.Message(this,this.ptr,p.name,p.options,p.isGroup,p.syntax),m={},p.oneofs&&Object.keys(p.oneofs).forEach(function(v){f.addChild(m[v]=new u.Message.OneOf(this,f,v))},this),p.fields&&p.fields.forEach(function(v){if(f.getChild(0|v.id)!==null)throw Error("duplicate or invalid field id in "+f.name+": "+v.id);if(v.options&&typeof v.options!="object")throw Error("illegal field options in "+f.name+"#"+v.name);var R=null;if(typeof v.oneof=="string"&&!(R=m[v.oneof]))throw Error("illegal oneof in "+f.name+"#"+v.name+": "+v.oneof);v=new u.Message.Field(this,f,v.rule,v.keytype,v.type,v.name,v.id,v.options,R,p.syntax),R&&R.fields.push(v),f.addChild(v)},this),_=[],p.enums&&p.enums.forEach(function(v){_.push(v)}),p.messages&&p.messages.forEach(function(v){_.push(v)}),p.services&&p.services.forEach(function(v){_.push(v)}),p.extensions&&(f.extensions=typeof p.extensions[0]=="number"?[p.extensions]:p.extensions),this.ptr.addChild(f),_.length>0){c.push(a),a=_,_=null,this.ptr=f,f=null;continue}_=null}else if(l.isEnum(p))f=new u.Enum(this,this.ptr,p.name,p.options,p.syntax),p.values.forEach(function(v){f.addChild(new u.Enum.Value(this,f,v.name,v.id))},this),this.ptr.addChild(f);else if(l.isService(p))f=new u.Service(this,this.ptr,p.name,p.options),Object.keys(p.rpc).forEach(function(v){var R=p.rpc[v];f.addChild(new u.Service.RPCMethod(this,f,v,R.request,R.response,!!R.request_stream,!!R.response_stream,R.options))},this),this.ptr.addChild(f);else{if(!l.isExtend(p))throw Error("not a valid definition: "+JSON.stringify(p));if(f=this.ptr.resolve(p.ref,!0))p.fields.forEach(function(v){var R,C,A,M;if(f.getChild(0|v.id)!==null)throw Error("duplicate extended field id in "+f.name+": "+v.id);if(f.extensions&&(R=!1,f.extensions.forEach(function(O){v.id>=O[0]&&v.id<=O[1]&&(R=!0)}),!R))throw Error("illegal extended field id in "+f.name+": "+v.id+" (not within valid ranges)");C=v.name,this.options.convertFieldsToCamelCase&&(C=s.Util.toCamelCase(C)),A=new u.Message.ExtensionField(this,f,v.rule,v.type,this.ptr.fqn()+"."+C,v.id,v.options),M=new u.Extension(this,this.ptr,v.name,A),A.extension=M,this.ptr.addChild(M),f.addChild(A)},this);else if(!/\.?google\.protobuf\./.test(p.ref))throw Error("extended message "+p.ref+" is not defined")}p=null,f=null}a=null,this.ptr=this.ptr.parent}return this.resolved=!1,this.result=null,this},h.import=function(a,c){var p,f,m,_,v,R,C,A,M="/";if(typeof c=="string"){if(s.Util.IS_NODE,this.files[c]===!0)return this.reset();this.files[c]=!0}else if(typeof c=="object"){if(p=c.root,s.Util.IS_NODE,(p.indexOf("\\")>=0||c.file.indexOf("\\")>=0)&&(M="\\"),f=p+M+c.file,this.files[f]===!0)return this.reset();this.files[f]=!0}if(a.imports&&a.imports.length>0){for(_=!1,typeof c=="object"?(this.importRoot=c.root,_=!0,m=this.importRoot,c=c.file,(m.indexOf("\\")>=0||c.indexOf("\\")>=0)&&(M="\\")):typeof c=="string"?this.importRoot?m=this.importRoot:c.indexOf("/")>=0?(m=c.replace(/\/[^\/]*$/,""))===""&&(m="/"):c.indexOf("\\")>=0?(m=c.replace(/\\[^\\]*$/,""),M="\\"):m=".":m=null,v=0;v1024&&(c.push(u.apply(String,a)),a.length=0),void Array.prototype.push.apply(a,arguments))}}function r(a,c,p,f,m){var _,v,R=8*m-f-1,C=(1<>1,M=-7,O=p?m-1:0,y=p?-1:1,w=a[c+O];for(O+=y,_=w&(1<<-M)-1,w>>=-M,M+=R;M>0;_=256*_+a[c+O],O+=y,M-=8);for(v=_&(1<<-M)-1,_>>=-M,M+=f;M>0;v=256*v+a[c+O],O+=y,M-=8);if(_===0)_=1-A;else{if(_===C)return v?NaN:1/0*(w?-1:1);v+=Math.pow(2,f),_-=A}return(w?-1:1)*v*Math.pow(2,_-f)}function i(a,c,p,f,m,_){var v,R,C,A=8*_-m-1,M=(1<>1,y=m===23?Math.pow(2,-24)-Math.pow(2,-77):0,w=f?0:_-1,$=f?1:-1,Y=c<0||c===0&&1/c<0?1:0;for(c=Math.abs(c),isNaN(c)||1/0===c?(R=isNaN(c)?1:0,v=M):(v=Math.floor(Math.log(c)/Math.LN2),c*(C=Math.pow(2,-v))<1&&(v--,C*=2),(c+=v+O>=1?y/C:y*Math.pow(2,1-O))*C>=2&&(v++,C/=2),v+O>=M?(R=0,v=M):v+O>=1?(R=(c*C-1)*Math.pow(2,m),v+=O):(R=c*Math.pow(2,O-1)*Math.pow(2,m),v=0));m>=8;a[p+w]=255&R,w+=$,R/=256,m-=8);for(v=v<0;a[p+w]=255&v,w+=$,v/=256,A-=8);a[p+w-$]|=128*Y}var s,o,u,d,l,h=function(a,c,p){if(a===void 0&&(a=h.DEFAULT_CAPACITY),c===void 0&&(c=h.DEFAULT_ENDIAN),p===void 0&&(p=h.DEFAULT_NOASSERT),!p){if((a|=0)<0)throw RangeError("Illegal capacity");c=!!c,p=!!p}this.buffer=a===0?o:new ArrayBuffer(a),this.view=a===0?null:new Uint8Array(this.buffer),this.offset=0,this.markedOffset=-1,this.limit=a,this.littleEndian=c,this.noAssert=p};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=n||null,(s=h.prototype).__isByteBuffer__,Object.defineProperty(s,"__isByteBuffer__",{value:!0,enumerable:!1,configurable:!1}),o=new ArrayBuffer(0),u=String.fromCharCode,h.accessor=function(){return Uint8Array},h.allocate=function(a,c,p){return new h(a,c,p)},h.concat=function(a,c,p,f){var m,_,v,R,C,A;for((typeof c=="boolean"||typeof c!="string")&&(f=p,p=c,c=void 0),m=0,v=0,R=a.length;R>v;++v)h.isByteBuffer(a[v])||(a[v]=h.wrap(a[v],c)),(_=a[v].limit-a[v].offset)>0&&(m+=_);if(m===0)return new h(0,p,f);for(A=new h(m,p,f),v=0;R>v;)(_=(C=a[v++]).limit-C.offset)<=0||(A.view.set(C.view.subarray(C.offset,C.limit),A.offset),A.offset+=_);return A.limit=A.offset,A.offset=0,A},h.isByteBuffer=function(a){return(a&&a.__isByteBuffer__)===!0},h.type=function(){return ArrayBuffer},h.wrap=function(a,c,p,f){var m,_;if(typeof c!="string"&&(f=p,p=c,c=void 0),typeof a=="string")switch(c===void 0&&(c="utf8"),c){case"base64":return h.fromBase64(a,p);case"hex":return h.fromHex(a,p);case"binary":return h.fromBinary(a,p);case"utf8":return h.fromUTF8(a,p);case"debug":return h.fromDebug(a,p);default:throw Error("Unsupported encoding: "+c)}if(a===null||typeof a!="object")throw TypeError("Illegal buffer");if(h.isByteBuffer(a))return(m=s.clone.call(a)).markedOffset=-1,m;if(a instanceof Uint8Array)m=new h(0,p,f),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,p,f),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,p,f)).limit=a.length,_=0;_>>=0)<0||c+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+c+" (+0) <= "+this.buffer.byteLength)}for(f=c,_=(m=a.length)>>3,v=0,c+=this.writeVarint32(m,c);_--;)p=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(p,c++);if(m>v){for(R=0,p=0;m>v;)p|=(1&!!a[v++])<>3,_=0,v=[],a+=p.length;m--;)c=this.readByte(a++),v[_++]=!!(1&c),v[_++]=!!(2&c),v[_++]=!!(4&c),v[_++]=!!(8&c),v[_++]=!!(16&c),v[_++]=!!(32&c),v[_++]=!!(64&c),v[_++]=!!(128&c);if(f>_)for(R=0,c=this.readByte(a++);f>_;)v[_++]=!!(1&c>>R++);return C&&(this.offset=a),v},s.readBytes=function(a,c){var p,f=c===void 0;if(f&&(c=this.offset),!this.noAssert){if(typeof c!="number"||c%1!=0)throw TypeError("Illegal offset: "+c+" (not an integer)");if((c>>>=0)<0||c+a>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+c+" (+"+a+") <= "+this.buffer.byteLength)}return p=this.slice(c,c+a),f&&(this.offset+=a),p},s.writeBytes=s.append,s.writeInt8=function(a,c){var p,f=c===void 0;if(f&&(c=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal value: "+a+" (not an integer)");if(a|=0,typeof c!="number"||c%1!=0)throw TypeError("Illegal offset: "+c+" (not an integer)");if((c>>>=0)<0||c+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+c+" (+0) <= "+this.buffer.byteLength)}return(c+=1)>(p=this.buffer.byteLength)&&this.resize((p*=2)>c?p:c),c-=1,this.view[c]=a,f&&(this.offset+=1),this},s.writeByte=s.writeInt8,s.readInt8=function(a){var c,p=a===void 0;if(p&&(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&(c=this.view[a]))==128&&(c=-(255-c+1)),p&&(this.offset+=1),c},s.readByte=s.readInt8,s.writeUint8=function(a,c){var p,f=c===void 0;if(f&&(c=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal value: "+a+" (not an integer)");if(a>>>=0,typeof c!="number"||c%1!=0)throw TypeError("Illegal offset: "+c+" (not an integer)");if((c>>>=0)<0||c+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+c+" (+0) <= "+this.buffer.byteLength)}return(c+=1)>(p=this.buffer.byteLength)&&this.resize((p*=2)>c?p:c),c-=1,this.view[c]=a,f&&(this.offset+=1),this},s.writeUInt8=s.writeUint8,s.readUint8=function(a){var c,p=a===void 0;if(p&&(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 c=this.view[a],p&&(this.offset+=1),c},s.readUInt8=s.readUint8,s.writeInt16=function(a,c){var p,f=c===void 0;if(f&&(c=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal value: "+a+" (not an integer)");if(a|=0,typeof c!="number"||c%1!=0)throw TypeError("Illegal offset: "+c+" (not an integer)");if((c>>>=0)<0||c+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+c+" (+0) <= "+this.buffer.byteLength)}return(c+=2)>(p=this.buffer.byteLength)&&this.resize((p*=2)>c?p:c),c-=2,this.littleEndian?(this.view[c+1]=(65280&a)>>>8,this.view[c]=255&a):(this.view[c]=(65280&a)>>>8,this.view[c+1]=255&a),f&&(this.offset+=2),this},s.writeShort=s.writeInt16,s.readInt16=function(a){var c,p=a===void 0;if(p&&(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 c=0,this.littleEndian?(c=this.view[a],c|=this.view[a+1]<<8):(c=this.view[a]<<8,c|=this.view[a+1]),(32768&c)==32768&&(c=-(65535-c+1)),p&&(this.offset+=2),c},s.readShort=s.readInt16,s.writeUint16=function(a,c){var p,f=c===void 0;if(f&&(c=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal value: "+a+" (not an integer)");if(a>>>=0,typeof c!="number"||c%1!=0)throw TypeError("Illegal offset: "+c+" (not an integer)");if((c>>>=0)<0||c+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+c+" (+0) <= "+this.buffer.byteLength)}return(c+=2)>(p=this.buffer.byteLength)&&this.resize((p*=2)>c?p:c),c-=2,this.littleEndian?(this.view[c+1]=(65280&a)>>>8,this.view[c]=255&a):(this.view[c]=(65280&a)>>>8,this.view[c+1]=255&a),f&&(this.offset+=2),this},s.writeUInt16=s.writeUint16,s.readUint16=function(a){var c,p=a===void 0;if(p&&(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 c=0,this.littleEndian?(c=this.view[a],c|=this.view[a+1]<<8):(c=this.view[a]<<8,c|=this.view[a+1]),p&&(this.offset+=2),c},s.readUInt16=s.readUint16,s.writeInt32=function(a,c){var p,f=c===void 0;if(f&&(c=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal value: "+a+" (not an integer)");if(a|=0,typeof c!="number"||c%1!=0)throw TypeError("Illegal offset: "+c+" (not an integer)");if((c>>>=0)<0||c+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+c+" (+0) <= "+this.buffer.byteLength)}return(c+=4)>(p=this.buffer.byteLength)&&this.resize((p*=2)>c?p:c),c-=4,this.littleEndian?(this.view[c+3]=255&a>>>24,this.view[c+2]=255&a>>>16,this.view[c+1]=255&a>>>8,this.view[c]=255&a):(this.view[c]=255&a>>>24,this.view[c+1]=255&a>>>16,this.view[c+2]=255&a>>>8,this.view[c+3]=255&a),f&&(this.offset+=4),this},s.writeInt=s.writeInt32,s.readInt32=function(a){var c,p=a===void 0;if(p&&(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 c=0,this.littleEndian?(c=this.view[a+2]<<16,c|=this.view[a+1]<<8,c|=this.view[a],c+=this.view[a+3]<<24>>>0):(c=this.view[a+1]<<16,c|=this.view[a+2]<<8,c|=this.view[a+3],c+=this.view[a]<<24>>>0),c|=0,p&&(this.offset+=4),c},s.readInt=s.readInt32,s.writeUint32=function(a,c){var p,f=c===void 0;if(f&&(c=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal value: "+a+" (not an integer)");if(a>>>=0,typeof c!="number"||c%1!=0)throw TypeError("Illegal offset: "+c+" (not an integer)");if((c>>>=0)<0||c+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+c+" (+0) <= "+this.buffer.byteLength)}return(c+=4)>(p=this.buffer.byteLength)&&this.resize((p*=2)>c?p:c),c-=4,this.littleEndian?(this.view[c+3]=255&a>>>24,this.view[c+2]=255&a>>>16,this.view[c+1]=255&a>>>8,this.view[c]=255&a):(this.view[c]=255&a>>>24,this.view[c+1]=255&a>>>16,this.view[c+2]=255&a>>>8,this.view[c+3]=255&a),f&&(this.offset+=4),this},s.writeUInt32=s.writeUint32,s.readUint32=function(a){var c,p=a===void 0;if(p&&(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 c=0,this.littleEndian?(c=this.view[a+2]<<16,c|=this.view[a+1]<<8,c|=this.view[a],c+=this.view[a+3]<<24>>>0):(c=this.view[a+1]<<16,c|=this.view[a+2]<<8,c|=this.view[a+3],c+=this.view[a]<<24>>>0),p&&(this.offset+=4),c},s.readUInt32=s.readUint32,n&&(s.writeInt64=function(a,c){var p,f,m,_=c===void 0;if(_&&(c=this.offset),!this.noAssert){if(typeof a=="number")a=n.fromNumber(a);else if(typeof a=="string")a=n.fromString(a);else if(!(a&&a instanceof n))throw TypeError("Illegal value: "+a+" (not an integer or Long)");if(typeof c!="number"||c%1!=0)throw TypeError("Illegal offset: "+c+" (not an integer)");if((c>>>=0)<0||c+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+c+" (+0) <= "+this.buffer.byteLength)}return typeof a=="number"?a=n.fromNumber(a):typeof a=="string"&&(a=n.fromString(a)),(c+=8)>(p=this.buffer.byteLength)&&this.resize((p*=2)>c?p:c),c-=8,f=a.low,m=a.high,this.littleEndian?(this.view[c+3]=255&f>>>24,this.view[c+2]=255&f>>>16,this.view[c+1]=255&f>>>8,this.view[c]=255&f,c+=4,this.view[c+3]=255&m>>>24,this.view[c+2]=255&m>>>16,this.view[c+1]=255&m>>>8,this.view[c]=255&m):(this.view[c]=255&m>>>24,this.view[c+1]=255&m>>>16,this.view[c+2]=255&m>>>8,this.view[c+3]=255&m,c+=4,this.view[c]=255&f>>>24,this.view[c+1]=255&f>>>16,this.view[c+2]=255&f>>>8,this.view[c+3]=255&f),_&&(this.offset+=8),this},s.writeLong=s.writeInt64,s.readInt64=function(a){var c,p,f,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 c=0,p=0,this.littleEndian?(c=this.view[a+2]<<16,c|=this.view[a+1]<<8,c|=this.view[a],c+=this.view[a+3]<<24>>>0,a+=4,p=this.view[a+2]<<16,p|=this.view[a+1]<<8,p|=this.view[a],p+=this.view[a+3]<<24>>>0):(p=this.view[a+1]<<16,p|=this.view[a+2]<<8,p|=this.view[a+3],p+=this.view[a]<<24>>>0,a+=4,c=this.view[a+1]<<16,c|=this.view[a+2]<<8,c|=this.view[a+3],c+=this.view[a]<<24>>>0),f=new n(c,p,!1),m&&(this.offset+=8),f},s.readLong=s.readInt64,s.writeUint64=function(a,c){var p,f,m,_=c===void 0;if(_&&(c=this.offset),!this.noAssert){if(typeof a=="number")a=n.fromNumber(a);else if(typeof a=="string")a=n.fromString(a);else if(!(a&&a instanceof n))throw TypeError("Illegal value: "+a+" (not an integer or Long)");if(typeof c!="number"||c%1!=0)throw TypeError("Illegal offset: "+c+" (not an integer)");if((c>>>=0)<0||c+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+c+" (+0) <= "+this.buffer.byteLength)}return typeof a=="number"?a=n.fromNumber(a):typeof a=="string"&&(a=n.fromString(a)),(c+=8)>(p=this.buffer.byteLength)&&this.resize((p*=2)>c?p:c),c-=8,f=a.low,m=a.high,this.littleEndian?(this.view[c+3]=255&f>>>24,this.view[c+2]=255&f>>>16,this.view[c+1]=255&f>>>8,this.view[c]=255&f,c+=4,this.view[c+3]=255&m>>>24,this.view[c+2]=255&m>>>16,this.view[c+1]=255&m>>>8,this.view[c]=255&m):(this.view[c]=255&m>>>24,this.view[c+1]=255&m>>>16,this.view[c+2]=255&m>>>8,this.view[c+3]=255&m,c+=4,this.view[c]=255&f>>>24,this.view[c+1]=255&f>>>16,this.view[c+2]=255&f>>>8,this.view[c+3]=255&f),_&&(this.offset+=8),this},s.writeUInt64=s.writeUint64,s.readUint64=function(a){var c,p,f,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 c=0,p=0,this.littleEndian?(c=this.view[a+2]<<16,c|=this.view[a+1]<<8,c|=this.view[a],c+=this.view[a+3]<<24>>>0,a+=4,p=this.view[a+2]<<16,p|=this.view[a+1]<<8,p|=this.view[a],p+=this.view[a+3]<<24>>>0):(p=this.view[a+1]<<16,p|=this.view[a+2]<<8,p|=this.view[a+3],p+=this.view[a]<<24>>>0,a+=4,c=this.view[a+1]<<16,c|=this.view[a+2]<<8,c|=this.view[a+3],c+=this.view[a]<<24>>>0),f=new n(c,p,!0),m&&(this.offset+=8),f},s.readUInt64=s.readUint64),s.writeFloat32=function(a,c){var p,f=c===void 0;if(f&&(c=this.offset),!this.noAssert){if(typeof a!="number")throw TypeError("Illegal value: "+a+" (not a number)");if(typeof c!="number"||c%1!=0)throw TypeError("Illegal offset: "+c+" (not an integer)");if((c>>>=0)<0||c+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+c+" (+0) <= "+this.buffer.byteLength)}return(c+=4)>(p=this.buffer.byteLength)&&this.resize((p*=2)>c?p:c),c-=4,i(this.view,a,c,this.littleEndian,23,4),f&&(this.offset+=4),this},s.writeFloat=s.writeFloat32,s.readFloat32=function(a){var c,p=a===void 0;if(p&&(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 c=r(this.view,a,this.littleEndian,23,4),p&&(this.offset+=4),c},s.readFloat=s.readFloat32,s.writeFloat64=function(a,c){var p,f=c===void 0;if(f&&(c=this.offset),!this.noAssert){if(typeof a!="number")throw TypeError("Illegal value: "+a+" (not a number)");if(typeof c!="number"||c%1!=0)throw TypeError("Illegal offset: "+c+" (not an integer)");if((c>>>=0)<0||c+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+c+" (+0) <= "+this.buffer.byteLength)}return(c+=8)>(p=this.buffer.byteLength)&&this.resize((p*=2)>c?p:c),c-=8,i(this.view,a,c,this.littleEndian,52,8),f&&(this.offset+=8),this},s.writeDouble=s.writeFloat64,s.readFloat64=function(a){var c,p=a===void 0;if(p&&(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 c=r(this.view,a,this.littleEndian,52,8),p&&(this.offset+=8),c},s.readDouble=s.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)},s.writeVarint32=function(a,c){var p,f,m,_=c===void 0;if(_&&(c=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal value: "+a+" (not an integer)");if(a|=0,typeof c!="number"||c%1!=0)throw TypeError("Illegal offset: "+c+" (not an integer)");if((c>>>=0)<0||c+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+c+" (+0) <= "+this.buffer.byteLength)}for((c+=f=h.calculateVarint32(a))>(m=this.buffer.byteLength)&&this.resize((m*=2)>c?m:c),c-=f,a>>>=0;a>=128;)p=128|127&a,this.view[c++]=p,a>>>=7;return this.view[c++]=a,_?(this.offset=c,this):f},s.writeVarint32ZigZag=function(a,c){return this.writeVarint32(h.zigZagEncode32(a),c)},s.readVarint32=function(a){var c,p,f,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)}p=0,f=0;do{if(!this.noAssert&&a>this.limit)throw(m=Error("Truncated")).truncated=!0,m;c=this.view[a++],p<5&&(f|=(127&c)<<7*p),++p}while((128&c)!=0);return f|=0,_?(this.offset=a,f):{value:f,length:p}},s.readVarint32ZigZag=function(a){var c=this.readVarint32(a);return typeof c=="object"?c.value=h.zigZagDecode32(c.value):c=h.zigZagDecode32(c),c},n&&(h.MAX_VARINT64_BYTES=10,h.calculateVarint64=function(a){typeof a=="number"?a=n.fromNumber(a):typeof a=="string"&&(a=n.fromString(a));var c=a.toInt()>>>0,p=a.shiftRightUnsigned(28).toInt()>>>0,f=a.shiftRightUnsigned(56).toInt()>>>0;return f==0?p==0?c<16384?c<128?1:2:1<<21>c?3:4:p<16384?p<128?5:6:1<<21>p?7:8:f<128?9:10},h.zigZagEncode64=function(a){return typeof a=="number"?a=n.fromNumber(a,!1):typeof a=="string"?a=n.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=n.fromNumber(a,!1):typeof a=="string"?a=n.fromString(a,!1):a.unsigned!==!1&&(a=a.toSigned()),a.shiftRightUnsigned(1).xor(a.and(n.ONE).toSigned().negate()).toSigned()},s.writeVarint64=function(a,c){var p,f,m,_,v,R=c===void 0;if(R&&(c=this.offset),!this.noAssert){if(typeof a=="number")a=n.fromNumber(a);else if(typeof a=="string")a=n.fromString(a);else if(!(a&&a instanceof n))throw TypeError("Illegal value: "+a+" (not an integer or Long)");if(typeof c!="number"||c%1!=0)throw TypeError("Illegal offset: "+c+" (not an integer)");if((c>>>=0)<0||c+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+c+" (+0) <= "+this.buffer.byteLength)}switch(typeof a=="number"?a=n.fromNumber(a,!1):typeof a=="string"?a=n.fromString(a,!1):a.unsigned!==!1&&(a=a.toSigned()),p=h.calculateVarint64(a),f=a.toInt()>>>0,m=a.shiftRightUnsigned(28).toInt()>>>0,_=a.shiftRightUnsigned(56).toInt()>>>0,(c+=p)>(v=this.buffer.byteLength)&&this.resize((v*=2)>c?v:c),c-=p,p){case 10:this.view[c+9]=1&_>>>7;case 9:this.view[c+8]=p!==9?128|_:127&_;case 8:this.view[c+7]=p!==8?128|m>>>21:127&m>>>21;case 7:this.view[c+6]=p!==7?128|m>>>14:127&m>>>14;case 6:this.view[c+5]=p!==6?128|m>>>7:127&m>>>7;case 5:this.view[c+4]=p!==5?128|m:127&m;case 4:this.view[c+3]=p!==4?128|f>>>21:127&f>>>21;case 3:this.view[c+2]=p!==3?128|f>>>14:127&f>>>14;case 2:this.view[c+1]=p!==2?128|f>>>7:127&f>>>7;case 1:this.view[c]=p!==1?128|f:127&f}return R?(this.offset+=p,this):p},s.writeVarint64ZigZag=function(a,c){return this.writeVarint64(h.zigZagEncode64(a),c)},s.readVarint64=function(a){var c,p,f,m,_,v,R=a===void 0;if(R&&(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(c=a,p=0,f=0,m=0,_=0,p=127&(_=this.view[a++]),128&_&&(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)&&(f=127&(_=this.view[a++]),(128&_||this.noAssert&&_===void 0)&&(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)&&(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=n.fromBits(p|f<<28,f>>>4|m<<24,!1),R?(this.offset=a,v):{value:v,length:a-c}},s.readVarint64ZigZag=function(a){var c=this.readVarint64(a);return c&&c.value instanceof n?c.value=h.zigZagDecode64(c.value):c=h.zigZagDecode64(c),c}),s.writeCString=function(a,c){var p,f,m,_=c===void 0;if(_&&(c=this.offset),f=a.length,!this.noAssert){if(typeof a!="string")throw TypeError("Illegal str: Not a string");for(p=0;f>p;++p)if(a.charCodeAt(p)===0)throw RangeError("Illegal str: Contains NULL-characters");if(typeof c!="number"||c%1!=0)throw TypeError("Illegal offset: "+c+" (not an integer)");if((c>>>=0)<0||c+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+c+" (+0) <= "+this.buffer.byteLength)}return f=l.calculateUTF16asUTF8(e(a))[1],c+=f+1,m=this.buffer.byteLength,c>m&&this.resize((m*=2)>c?m:c),c-=f+1,l.encodeUTF16toUTF8(e(a),function(v){this.view[c++]=v}.bind(this)),this.view[c++]=0,_?(this.offset=c,this):f},s.readCString=function(a){var c,p,f,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 c=a,f=-1,l.decodeUTF8toUTF16(function(){if(f===0)return null;if(a>=this.limit)throw RangeError("Illegal range: Truncated data, "+a+" < "+this.limit);return(f=this.view[a++])===0?null:f}.bind(this),p=t(),!0),m?(this.offset=a,p()):{string:p(),length:a-c}},s.writeIString=function(a,c){var p,f,m,_=c===void 0;if(_&&(c=this.offset),!this.noAssert){if(typeof a!="string")throw TypeError("Illegal str: Not a string");if(typeof c!="number"||c%1!=0)throw TypeError("Illegal offset: "+c+" (not an integer)");if((c>>>=0)<0||c+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+c+" (+0) <= "+this.buffer.byteLength)}if(f=c,p=l.calculateUTF16asUTF8(e(a),this.noAssert)[1],c+=4+p,m=this.buffer.byteLength,c>m&&this.resize((m*=2)>c?m:c),c-=4+p,this.littleEndian?(this.view[c+3]=255&p>>>24,this.view[c+2]=255&p>>>16,this.view[c+1]=255&p>>>8,this.view[c]=255&p):(this.view[c]=255&p>>>24,this.view[c+1]=255&p>>>16,this.view[c+2]=255&p>>>8,this.view[c+3]=255&p),c+=4,l.encodeUTF16toUTF8(e(a),function(v){this.view[c++]=v}.bind(this)),c!==f+4+p)throw RangeError("Illegal range: Truncated data, "+c+" == "+(c+4+p));return _?(this.offset=c,this):c-f},s.readIString=function(a){var c,p,f,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 c=a,p=this.readUint32(a),f=this.readUTF8String(p,h.METRICS_BYTES,a+=4),a+=f.length,m?(this.offset=a,f.string):{string:f.string,length:a-c}},h.METRICS_CHARS="c",h.METRICS_BYTES="b",s.writeUTF8String=function(a,c){var p,f,m,_=c===void 0;if(_&&(c=this.offset),!this.noAssert){if(typeof c!="number"||c%1!=0)throw TypeError("Illegal offset: "+c+" (not an integer)");if((c>>>=0)<0||c+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+c+" (+0) <= "+this.buffer.byteLength)}return f=c,p=l.calculateUTF16asUTF8(e(a))[1],c+=p,m=this.buffer.byteLength,c>m&&this.resize((m*=2)>c?m:c),c-=p,l.encodeUTF16toUTF8(e(a),function(v){this.view[c++]=v}.bind(this)),_?(this.offset=c,this):c-f},s.writeString=s.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,s.readUTF8String=function(a,c,p){var f,m,_,v,R;if(typeof c=="number"&&(p=c,c=void 0),(f=p===void 0)&&(p=this.offset),c===void 0&&(c=h.METRICS_CHARS),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal length: "+a+" (not an integer)");if(a|=0,typeof p!="number"||p%1!=0)throw TypeError("Illegal offset: "+p+" (not an integer)");if((p>>>=0)<0||p+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+p+" (+0) <= "+this.buffer.byteLength)}if(_=0,v=p,c===h.METRICS_CHARS){if(m=t(),l.decodeUTF8(function(){return a>_&&p>>=0)<0||p+a>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+p+" (+"+a+") <= "+this.buffer.byteLength)}if(R=p+a,l.decodeUTF8toUTF16(function(){return R>p?this.view[p++]:null}.bind(this),m=t(),this.noAssert),p!==R)throw RangeError("Illegal range: Truncated data, "+p+" == "+R);return f?(this.offset=p,m()):{string:m(),length:p-v}}throw TypeError("Unsupported metrics: "+c)},s.readString=s.readUTF8String,s.writeVString=function(a,c){var p,f,m,_,v=c===void 0;if(v&&(c=this.offset),!this.noAssert){if(typeof a!="string")throw TypeError("Illegal str: Not a string");if(typeof c!="number"||c%1!=0)throw TypeError("Illegal offset: "+c+" (not an integer)");if((c>>>=0)<0||c+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+c+" (+0) <= "+this.buffer.byteLength)}if(m=c,p=l.calculateUTF16asUTF8(e(a),this.noAssert)[1],f=h.calculateVarint32(p),c+=f+p,_=this.buffer.byteLength,c>_&&this.resize((_*=2)>c?_:c),c-=f+p,c+=this.writeVarint32(p,c),l.encodeUTF16toUTF8(e(a),function(R){this.view[c++]=R}.bind(this)),c!==m+p+f)throw RangeError("Illegal range: Truncated data, "+c+" == "+(c+p+f));return v?(this.offset=c,this):c-m},s.readVString=function(a){var c,p,f,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 c=a,p=this.readVarint32(a),f=this.readUTF8String(p.value,h.METRICS_BYTES,a+=p.length),a+=f.length,m?(this.offset=a,f.string):{string:f.string,length:a-c}},s.append=function(a,c,p){var f,m,_;if((typeof c=="number"||typeof c!="string")&&(p=c,c=void 0),(f=p===void 0)&&(p=this.offset),!this.noAssert){if(typeof p!="number"||p%1!=0)throw TypeError("Illegal offset: "+p+" (not an integer)");if((p>>>=0)<0||p+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+p+" (+0) <= "+this.buffer.byteLength)}return a instanceof h||(a=h.wrap(a,c)),(m=a.limit-a.offset)<=0||((p+=m)>(_=this.buffer.byteLength)&&this.resize((_*=2)>p?_:p),p-=m,this.view.set(a.view.subarray(a.offset,a.limit),p),a.offset+=m,f&&(this.offset+=m)),this},s.appendTo=function(a,c){return a.append(this,c),this},s.assert=function(a){return this.noAssert=!a,this},s.capacity=function(){return this.buffer.byteLength},s.clear=function(){return this.offset=0,this.limit=this.buffer.byteLength,this.markedOffset=-1,this},s.clone=function(a){var c=new h(0,this.littleEndian,this.noAssert);return a?(c.buffer=new ArrayBuffer(this.buffer.byteLength),c.view=new Uint8Array(c.buffer)):(c.buffer=this.buffer,c.view=this.view),c.offset=this.offset,c.markedOffset=this.markedOffset,c.limit=this.limit,c},s.compact=function(a,c){var p,f,m;if(a===void 0&&(a=this.offset),c===void 0&&(c=this.limit),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal begin: Not an integer");if(a>>>=0,typeof c!="number"||c%1!=0)throw TypeError("Illegal end: Not an integer");if(c>>>=0,a<0||a>c||c>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+a+" <= "+c+" <= "+this.buffer.byteLength)}return a===0&&c===this.buffer.byteLength?this:(p=c-a)==0?(this.buffer=o,this.view=null,this.markedOffset>=0&&(this.markedOffset-=a),this.offset=0,this.limit=0,this):(f=new ArrayBuffer(p),(m=new Uint8Array(f)).set(this.view.subarray(a,c)),this.buffer=f,this.view=m,this.markedOffset>=0&&(this.markedOffset-=a),this.offset=0,this.limit=p,this)},s.copy=function(a,c){if(a===void 0&&(a=this.offset),c===void 0&&(c=this.limit),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal begin: Not an integer");if(a>>>=0,typeof c!="number"||c%1!=0)throw TypeError("Illegal end: Not an integer");if(c>>>=0,a<0||a>c||c>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+a+" <= "+c+" <= "+this.buffer.byteLength)}if(a===c)return new h(0,this.littleEndian,this.noAssert);var p=c-a,f=new h(p,this.littleEndian,this.noAssert);return f.offset=0,f.limit=p,f.markedOffset>=0&&(f.markedOffset-=a),this.copyTo(f,0,a,c),f},s.copyTo=function(a,c,p,f){var m,_,v;if(!this.noAssert&&!h.isByteBuffer(a))throw TypeError("Illegal target: Not a ByteBuffer");if(c=(_=c===void 0)?a.offset:0|c,p=(m=p===void 0)?this.offset:0|p,f=f===void 0?this.limit:0|f,c<0||c>a.buffer.byteLength)throw RangeError("Illegal target range: 0 <= "+c+" <= "+a.buffer.byteLength);if(p<0||f>this.buffer.byteLength)throw RangeError("Illegal source range: 0 <= "+p+" <= "+this.buffer.byteLength);return(v=f-p)==0?a:(a.ensureCapacity(c+v),a.view.set(this.view.subarray(p,f),c),m&&(this.offset+=v),_&&(a.offset+=v),this)},s.ensureCapacity=function(a){var c=this.buffer.byteLength;return a>c?this.resize((c*=2)>a?c:a):this},s.fill=function(a,c,p){var f=c===void 0;if(f&&(c=this.offset),typeof a=="string"&&a.length>0&&(a=a.charCodeAt(0)),c===void 0&&(c=this.offset),p===void 0&&(p=this.limit),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal value: "+a+" (not an integer)");if(a|=0,typeof c!="number"||c%1!=0)throw TypeError("Illegal begin: Not an integer");if(c>>>=0,typeof p!="number"||p%1!=0)throw TypeError("Illegal end: Not an integer");if(p>>>=0,c<0||c>p||p>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+c+" <= "+p+" <= "+this.buffer.byteLength)}if(c>=p)return this;for(;p>c;)this.view[c++]=a;return f&&(this.offset=c),this},s.flip=function(){return this.limit=this.offset,this.offset=0,this},s.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},s.order=function(a){if(!this.noAssert&&typeof a!="boolean")throw TypeError("Illegal littleEndian: Not a boolean");return this.littleEndian=!!a,this},s.LE=function(a){return this.littleEndian=a===void 0||!!a,this},s.BE=function(a){return this.littleEndian=a!==void 0&&!a,this},s.prepend=function(a,c,p){var f,m,_,v,R;if((typeof c=="number"||typeof c!="string")&&(p=c,c=void 0),(f=p===void 0)&&(p=this.offset),!this.noAssert){if(typeof p!="number"||p%1!=0)throw TypeError("Illegal offset: "+p+" (not an integer)");if((p>>>=0)<0||p+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+p+" (+0) <= "+this.buffer.byteLength)}return a instanceof h||(a=h.wrap(a,c)),(m=a.limit-a.offset)<=0||((_=m-p)>0?(v=new ArrayBuffer(this.buffer.byteLength+_),(R=new Uint8Array(v)).set(this.view.subarray(p,this.buffer.byteLength),m),this.buffer=v,this.view=R,this.offset+=_,this.markedOffset>=0&&(this.markedOffset+=_),this.limit+=_,p+=_):new Uint8Array(this.buffer),this.view.set(a.view.subarray(a.offset,a.limit),p-m),a.offset=a.limit,f&&(this.offset-=m)),this},s.prependTo=function(a,c){return a.prepend(this,c),this},s.printDebug=function(a){typeof a!="function"&&(a=console.log.bind(console)),a(this.toString()+` ------------------------------------------------------------------- `+this.toDebug(!0))},s.remaining=function(){return this.limit-this.offset},s.reset=function(){return this.markedOffset>=0?(this.offset=this.markedOffset,this.markedOffset=-1):this.offset=0,this},s.resize=function(a){var c,p;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 c!="number"||c%1!=0)throw TypeError("Illegal end: Not an integer");if(c>>>=0,a<0||a>c||c>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+a+" <= "+c+" <= "+this.buffer.byteLength)}return a===c||Array.prototype.reverse.call(this.view.subarray(a,c)),this},s.skip=function(a){if(!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal length: "+a+" (not an integer)");a|=0}var c=this.offset+a;if(!this.noAssert&&(c<0||c>this.buffer.byteLength))throw RangeError("Illegal length: 0 <= "+this.offset+" + "+a+" <= "+this.buffer.byteLength);return this.offset=c,this},s.slice=function(a,c){if(a===void 0&&(a=this.offset),c===void 0&&(c=this.limit),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal begin: Not an integer");if(a>>>=0,typeof c!="number"||c%1!=0)throw TypeError("Illegal end: Not an integer");if(c>>>=0,a<0||a>c||c>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+a+" <= "+c+" <= "+this.buffer.byteLength)}var p=this.clone();return p.offset=a,p.limit=c,p},s.toBuffer=function(a){var c,p=this.offset,f=this.limit;if(!this.noAssert){if(typeof p!="number"||p%1!=0)throw TypeError("Illegal offset: Not an integer");if(p>>>=0,typeof f!="number"||f%1!=0)throw TypeError("Illegal limit: Not an integer");if(f>>>=0,p<0||p>f||f>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+p+" <= "+f+" <= "+this.buffer.byteLength)}return a||p!==0||f!==this.buffer.byteLength?p===f?o:(c=new ArrayBuffer(f-p),new Uint8Array(c).set(new Uint8Array(this.buffer).subarray(p,f),0),c):this.buffer},s.toArrayBuffer=s.toBuffer,s.toString=function(a,c,p){if(a===void 0)return"ByteBufferAB(offset="+this.offset+",markedOffset="+this.markedOffset+",limit="+this.limit+",capacity="+this.capacity()+")";switch(typeof a=="number"&&(p=c=a="utf8"),a){case"utf8":return this.toUTF8(c,p);case"base64":return this.toBase64(c,p);case"hex":return this.toHex(c,p);case"binary":return this.toBinary(c,p);case"debug":return this.toDebug();case"columns":return this.toColumns();default:throw Error("Unsupported encoding: "+a)}},d=function(){var a,c,p={},f=[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,c=f.length;c>a;++a)m[f[a]]=a;return p.encode=function(_,v){for(var R,C;(R=_())!==null;)v(f[63&R>>2]),C=(3&R)<<4,(R=_())!==null?(v(f[63&((C|=15&R>>4)|15&R>>4)]),C=(15&R)<<2,(R=_())!==null?(v(f[63&(C|3&R>>6)]),v(f[63&R])):(v(f[63&C]),v(61))):(v(f[63&C]),v(61),v(61))},p.decode=function(_,v){function R(O){throw Error("Illegal character code: "+O)}for(var C,A,M;(C=_())!==null;)if((A=m[C])===void 0&&R(C),(C=_())!==null&&((M=m[C])===void 0&&R(C),v(A<<2>>>0|(48&M)>>4),(C=_())!==null)){if((A=m[C])===void 0){if(C===61)break;R(C)}if(v((15&M)<<4>>>0|(60&A)>>2),(C=_())!==null){if((M=m[C])===void 0){if(C===61)break;R(C)}v((3&A)<<6>>>0|M)}}},p.test=function(_){return/^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/.test(_)},p}(),s.toBase64=function(a,c){if(a===void 0&&(a=this.offset),c===void 0&&(c=this.limit),c|=0,(a|=0)<0||c>this.capacity||a>c)throw RangeError("begin, end");var p;return d.encode(function(){return c>a?this.view[a++]:null}.bind(this),p=t()),p()},h.fromBase64=function(a,c){if(typeof a!="string")throw TypeError("str");var p=new h(a.length/4*3,c),f=0;return d.decode(e(a),function(m){p.view[f++]=m}),p.limit=f,p},h.btoa=function(a){return h.fromBinary(a).toBase64()},h.atob=function(a){return h.fromBase64(a).toBinary()},s.toBinary=function(a,c){if(a===void 0&&(a=this.offset),c===void 0&&(c=this.limit),c|=0,(a|=0)<0||c>this.capacity()||a>c)throw RangeError("begin, end");if(a===c)return"";for(var p=[],f=[];c>a;)p.push(this.view[a++]),p.length>=1024&&(f.push(String.fromCharCode.apply(String,p)),p=[]);return f.join("")+String.fromCharCode.apply(String,p)},h.fromBinary=function(a,c){if(typeof a!="string")throw TypeError("str");for(var p,f=0,m=a.length,_=new h(m,c);m>f;){if((p=a.charCodeAt(f))>255)throw RangeError("illegal char code: "+p);_.view[f++]=p}return _.limit=m,_},s.toDebug=function(a){for(var c,p=-1,f=this.buffer.byteLength,m="",_="",v="";f>p;){if(p!==-1&&(m+=(c=this.view[p])<16?"0"+c.toString(16).toUpperCase():c.toString(16).toUpperCase(),a&&(_+=c>32&&c<127?String.fromCharCode(c):".")),++p,a&&p>0&&p%16==0&&p!==f){for(;m.length<51;)m+=" ";v+=m+_+` `,m=_=""}m+=p===this.offset&&p===this.limit?p===this.markedOffset?"!":"|":p===this.offset?p===this.markedOffset?"[":"<":p===this.limit?p===this.markedOffset?"]":">":p===this.markedOffset?"'":a||p!==0&&p!==f?" ":""}if(a&&m!==" "){for(;m.length<51;)m+=" ";v+=m+_+` `}return a?v:m},h.fromDebug=function(a,c,p){for(var f,m,_=a.length,v=new h(0|(_+1)/3,c,p),R=0,C=0,A=!1,M=!1,O=!1,y=!1,w=!1;_>R;){switch(f=a.charAt(R++)){case"!":if(!p){if(M||O||y){w=!0;break}M=O=y=!0}v.offset=v.markedOffset=v.limit=C,A=!1;break;case"|":if(!p){if(M||y){w=!0;break}M=y=!0}v.offset=v.limit=C,A=!1;break;case"[":if(!p){if(M||O){w=!0;break}M=O=!0}v.offset=v.markedOffset=C,A=!1;break;case"<":if(!p){if(M){w=!0;break}M=!0}v.offset=C,A=!1;break;case"]":if(!p){if(y||O){w=!0;break}y=O=!0}v.limit=v.markedOffset=C,A=!1;break;case">":if(!p){if(y){w=!0;break}y=!0}v.limit=C,A=!1;break;case"'":if(!p){if(O){w=!0;break}O=!0}v.markedOffset=C,A=!1;break;case" ":A=!1;break;default:if(!p&&A){w=!0;break}if(m=parseInt(f+a.charAt(R++),16),!p&&(isNaN(m)||m<0||m>255))throw TypeError("Illegal str: Not a debug encoded string");v.view[C++]=m,A=!0}if(w)throw TypeError("Illegal str: Invalid symbol at "+R)}if(!p){if(!M||!y)throw TypeError("Illegal str: Missing offset or limit");if(C>>=0,typeof c!="number"||c%1!=0)throw TypeError("Illegal end: Not an integer");if(c>>>=0,a<0||a>c||c>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+a+" <= "+c+" <= "+this.buffer.byteLength)}for(var p,f=new Array(c-a);c>a;)(p=this.view[a++])<16?f.push("0",p.toString(16)):f.push(p.toString(16));return f.join("")},h.fromHex=function(a,c,p){var f,m,_,v,R;if(!p){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,c),v=0,R=0;m>v;v+=2){if(f=parseInt(a.substring(v,v+2),16),!p&&(!isFinite(f)||f<0||f>255))throw TypeError("Illegal str: Contains non-hex characters");_.view[R++]=f}return _.limit=R,_},l=function(){var a={MAX_CODEPOINT:1114111,encodeUTF8:function(c,p){var f=null;for(typeof c=="number"&&(f=c,c=function(){return null});f!==null||(f=c())!==null;)f<128?p(127&f):f<2048?(p(192|31&f>>6),p(128|63&f)):f<65536?(p(224|15&f>>12),p(128|63&f>>6),p(128|63&f)):(p(240|7&f>>18),p(128|63&f>>12),p(128|63&f>>6),p(128|63&f)),f=null},decodeUTF8:function(c,p){for(var f,m,_,v,R=function(C){C=C.slice(0,C.indexOf(null));var A=Error(C.toString());throw A.name="TruncatedError",A.bytes=C,A};(f=c())!==null;)if((128&f)==0)p(f);else if((224&f)==192)(m=c())===null&&R([f,m]),p((31&f)<<6|63&m);else if((240&f)==224)((m=c())===null||(_=c())===null)&&R([f,m,_]),p((15&f)<<12|(63&m)<<6|63&_);else{if((248&f)!=240)throw RangeError("Illegal starting byte: "+f);((m=c())===null||(_=c())===null||(v=c())===null)&&R([f,m,_,v]),p((7&f)<<18|(63&m)<<12|(63&_)<<6|63&v)}},UTF16toUTF8:function(c,p){for(var f,m=null;(f=m!==null?m:c())!==null;)f>=55296&&f<=57343&&(m=c())!==null&&m>=56320&&m<=57343?(p(1024*(f-55296)+m-56320+65536),m=null):p(f);m!==null&&p(m)},UTF8toUTF16:function(c,p){var f=null;for(typeof c=="number"&&(f=c,c=function(){return null});f!==null||(f=c())!==null;)f<=65535?p(f):(p(55296+((f-=65536)>>10)),p(f%1024+56320)),f=null},encodeUTF16toUTF8:function(c,p){a.UTF16toUTF8(c,function(f){a.encodeUTF8(f,p)})},decodeUTF8toUTF16:function(c,p){a.decodeUTF8(c,function(f){a.UTF8toUTF16(f,p)})},calculateCodePoint:function(c){return c<128?1:c<2048?2:c<65536?3:4},calculateUTF8:function(c){for(var p,f=0;(p=c())!==null;)f+=p<128?1:p<2048?2:p<65536?3:4;return f},calculateUTF16asUTF8:function(c){var p=0,f=0;return a.UTF16toUTF8(c,function(m){++p,f+=m<128?1:m<2048?2:m<65536?3:4}),[p,f]}};return a}(),s.toUTF8=function(a,c){if(a===void 0&&(a=this.offset),c===void 0&&(c=this.limit),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal begin: Not an integer");if(a>>>=0,typeof c!="number"||c%1!=0)throw TypeError("Illegal end: Not an integer");if(c>>>=0,a<0||a>c||c>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+a+" <= "+c+" <= "+this.buffer.byteLength)}var p;try{l.decodeUTF8toUTF16(function(){return c>a?this.view[a++]:null}.bind(this),p=t())}catch{if(a!==c)throw RangeError("Illegal range: Truncated data, "+a+" != "+c)}return p()},h.fromUTF8=function(a,c,p){if(!p&&typeof a!="string")throw TypeError("Illegal str: Not a string");var f=new h(l.calculateUTF16asUTF8(e(a),!0)[1],c,p),m=0;return l.encodeUTF16toUTF8(e(a),function(_){f.view[m++]=_}),f.limit=m,f},h}(Vo=function(){function n(y,w,$){this.low=0|y,this.high=0|w,this.unsigned=!!$}function e(y){return(y&&y.__isLong__)===!0}function t(y,w){var $,Y,E;return w?(E=(y>>>=0)>=0&&y<256)&&(Y=d[y])?Y:($=i(y,(0|y)<0?-1:0,!0),E&&(d[y]=$),$):(E=(y|=0)>=-128&&y<128)&&(Y=u[y])?Y:($=i(y,y<0?-1:0,!1),E&&(u[y]=$),$)}function r(y,w){if(isNaN(y)||!isFinite(y))return w?m:f;if(w){if(y<0)return m;if(y>=a)return A}else{if(-c>=y)return M;if(y+1>=c)return C}return y<0?r(-y,w).neg():i(0|y%h,0|y/h,w)}function i(y,w,$){return new n(y,w,$)}function s(y,w,$){var Y,E,T,N,P,k,B;if(y.length===0)throw Error("empty string");if(y==="NaN"||y==="Infinity"||y==="+Infinity"||y==="-Infinity")return f;if(typeof w=="number"?($=w,w=!1):w=!!w,($=$||10)<2||$>36)throw RangeError("radix");if((Y=y.indexOf("-"))>0)throw Error("interior hyphen");if(Y===0)return s(y.substring(1),w,$).neg();for(E=r(l($,8)),T=f,N=0;N>>0:this.low},O.toNumber=function(){return this.unsigned?(this.high>>>0)*h+(this.low>>>0):this.high*h+(this.low>>>0)},O.toString=function(y){var w,$,Y,E,T,N,P,k;if((y=y||10)<2||y>36)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative())return this.eq(M)?(w=r(y),Y=($=this.div(w)).mul(w).sub(this),$.toString(y)+Y.toInt().toString(y)):"-"+this.neg().toString(y);for(E=r(l(y,6),this.unsigned),T=this,N="";;){if(P=T.div(E),k=(T.sub(P.mul(E)).toInt()>>>0).toString(y),(T=P).isZero())return k+N;for(;k.length<6;)k="0"+k;N=""+k+N}},O.getHighBits=function(){return this.high},O.getHighBitsUnsigned=function(){return this.high>>>0},O.getLowBits=function(){return this.low},O.getLowBitsUnsigned=function(){return this.low>>>0},O.getNumBitsAbs=function(){var y,w;if(this.isNegative())return this.eq(M)?64:this.neg().getNumBitsAbs();for(y=this.high!=0?this.high:this.low,w=31;w>0&&(y&1<=0},O.isOdd=function(){return(1&this.low)==1},O.isEven=function(){return(1&this.low)==0},O.equals=function(y){return e(y)||(y=o(y)),(this.unsigned===y.unsigned||this.high>>>31!=1||y.high>>>31!=1)&&this.high===y.high&&this.low===y.low},O.eq=O.equals,O.notEquals=function(y){return!this.eq(y)},O.neq=O.notEquals,O.lessThan=function(y){return this.comp(y)<0},O.lt=O.lessThan,O.lessThanOrEqual=function(y){return this.comp(y)<=0},O.lte=O.lessThanOrEqual,O.greaterThan=function(y){return this.comp(y)>0},O.gt=O.greaterThan,O.greaterThanOrEqual=function(y){return this.comp(y)>=0},O.gte=O.greaterThanOrEqual,O.compare=function(y){if(e(y)||(y=o(y)),this.eq(y))return 0;var w=this.isNegative(),$=y.isNegative();return w&&!$?-1:!w&&$?1:this.unsigned?y.high>>>0>this.high>>>0||y.high===this.high&&y.low>>>0>this.low>>>0?-1:1:this.sub(y).isNegative()?-1:1},O.comp=O.compare,O.negate=function(){return!this.unsigned&&this.eq(M)?M:this.not().add(_)},O.neg=O.negate,O.add=function(y){var w,$,Y,E,T,N,P,k,B,H,q;return e(y)||(y=o(y)),w=this.high>>>16,$=65535&this.high,Y=this.low>>>16,E=65535&this.low,T=y.high>>>16,N=65535&y.high,P=y.low>>>16,k=0,B=0,H=0,q=0,H+=(q+=E+(65535&y.low))>>>16,B+=(H+=Y+P)>>>16,k+=(B+=$+N)>>>16,k+=w+T,i((H&=65535)<<16|(q&=65535),(k&=65535)<<16|(B&=65535),this.unsigned)},O.subtract=function(y){return e(y)||(y=o(y)),this.add(y.neg())},O.sub=O.subtract,O.multiply=function(y){var w,$,Y,E,T,N,P,k,B,H,q,J;return this.isZero()?f:(e(y)||(y=o(y)),y.isZero()?f:this.eq(M)?y.isOdd()?M:f:y.eq(M)?this.isOdd()?M:f:this.isNegative()?y.isNegative()?this.neg().mul(y.neg()):this.neg().mul(y).neg():y.isNegative()?this.mul(y.neg()).neg():this.lt(p)&&y.lt(p)?r(this.toNumber()*y.toNumber(),this.unsigned):(w=this.high>>>16,$=65535&this.high,Y=this.low>>>16,E=65535&this.low,T=y.high>>>16,N=65535&y.high,P=y.low>>>16,B=0,H=0,q=0,J=0,q+=(J+=E*(k=65535&y.low))>>>16,H+=(q+=Y*k)>>>16,q&=65535,H+=(q+=E*P)>>>16,B+=(H+=$*k)>>>16,H&=65535,B+=(H+=Y*P)>>>16,H&=65535,B+=(H+=E*N)>>>16,B+=w*k+$*P+Y*N+E*T,i((q&=65535)<<16|(J&=65535),(B&=65535)<<16|(H&=65535),this.unsigned)))},O.mul=O.multiply,O.divide=function(y){var w,$,Y,E,T,N,P;if(e(y)||(y=o(y)),y.isZero())throw Error("division by zero");if(this.isZero())return this.unsigned?m:f;if(this.unsigned){if(y.unsigned||(y=y.toUnsigned()),y.gt(this))return m;if(y.gt(this.shru(1)))return v;Y=m}else{if(this.eq(M))return y.eq(_)||y.eq(R)?M:y.eq(M)?_:(w=this.shr(1).div(y).shl(1)).eq(f)?y.isNegative()?_:R:($=this.sub(y.mul(w)),Y=w.add($.div(y)));if(y.eq(M))return this.unsigned?m:f;if(this.isNegative())return y.isNegative()?this.neg().div(y.neg()):this.neg().div(y).neg();if(y.isNegative())return this.div(y.neg()).neg();Y=f}for($=this;$.gte(y);){for(w=Math.max(1,Math.floor($.toNumber()/y.toNumber())),T=(E=Math.ceil(Math.log(w)/Math.LN2))<=48?1:l(2,E-48),P=(N=r(w)).mul(y);P.isNegative()||P.gt($);)P=(N=r(w-=T,this.unsigned)).mul(y);N.isZero()&&(N=_),Y=Y.add(N),$=$.sub(P)}return Y},O.div=O.divide,O.modulo=function(y){return e(y)||(y=o(y)),this.sub(this.div(y).mul(y))},O.mod=O.modulo,O.not=function(){return i(~this.low,~this.high,this.unsigned)},O.and=function(y){return e(y)||(y=o(y)),i(this.low&y.low,this.high&y.high,this.unsigned)},O.or=function(y){return e(y)||(y=o(y)),i(this.low|y.low,this.high|y.high,this.unsigned)},O.xor=function(y){return e(y)||(y=o(y)),i(this.low^y.low,this.high^y.high,this.unsigned)},O.shiftLeft=function(y){return e(y)&&(y=y.toInt()),(y&=63)==0?this:y<32?i(this.low<>>32-y,this.unsigned):i(0,this.low<>>y|this.high<<32-y,this.high>>y,this.unsigned):i(this.high>>y-32,this.high>=0?0:-1,this.unsigned)},O.shr=O.shiftRight,O.shiftRightUnsigned=function(y){var w;return e(y)&&(y=y.toInt()),(y&=63)==0?this:(w=this.high,y<32?i(this.low>>>y|w<<32-y,w>>>y,this.unsigned):i(y===32?w:w>>>y-32,0,this.unsigned))},O.shru=O.shiftRightUnsigned,O.toSigned=function(){return this.unsigned?i(this.low,this.high,!1):this},O.toUnsigned=function(){return this.unsigned?this:i(this.low,this.high,!0)},O.toBytes=function(y){return y?this.toBytesLE():this.toBytesBE()},O.toBytesLE=function(){var y=this.high,w=this.low;return[255&w,255&w>>>8,255&w>>>16,255&w>>>24,255&y,255&y>>>8,255&y>>>16,255&y>>>24]},O.toBytesBE=function(){var y=this.high,w=this.low;return[255&y>>>24,255&y>>>16,255&y>>>8,255&y,255&w>>>24,255&w>>>16,255&w>>>8,255&w]},n}()),Vo));qi.getModule=function(n){var e=new qi[n];return e.getArrayData=function(){var t=e.toArrayBuffer();return t=Ya(t)?[].slice.call(new Int8Array(t)):t},e};var Gi,ld="pgMsgP",hd="chatMsg",pd="pcMsgP",fd={PRIVATE:"ppMsgS",GROUP:"pgMsgS",CHATROOM:"chatMsgS"},gd="delMsg",md="joinChrm",_d="joinChrmR",vd="exitChrm",Rd="setKV",Ed="delKV",Cd="setKVS",yd="delKVS",Bo="qryRelationR",Td="delRelation",Sd="setSeAtt",er={PRIVATE:"cleanPMsg",GROUP:"cleanGMsg",CUSTOMER_SERVICE:"cleanCMsg",SYSTEM:"cleanSMsg"},ac="qryPMsg",Id="qryGMsg",cc="qryCHMsg",bd="qryCMsg",Od="qrySMsg",Nd=((hn={}).ppMsgP=z.PRIVATE,hn[ld]=z.GROUP,hn[hd]=z.CHATROOM,hn[pd]=z.CUSTOMER_SERVICE,hn),wd=(($t={})[z.PRIVATE]=ac,$t[z.GROUP]=Id,$t[z.CHATROOM]=cc,$t[z.CUSTOMER_SERVICE]=bd,$t[z.SYSTEM]=Od,$t),Ad=((pn={})[z.PRIVATE]=er.PRIVATE,pn[z.GROUP]=er.GROUP,pn[z.CUSTOMER_SERVICE]=er.CUSTOMER_SERVICE,pn[z.SYSTEM]=er.SYSTEM,pn),gi="1",Md="0",Fo=1,Ho=2,$o=3,Pd=function(){function n(e){this._codec=e==="websocket"?qi:xn,this._connectType=e}return n.prototype.decodeByPBName=function(e,t,r){var i,s=this,o=e,u=((i={})[kn]=s._formatSyncMessages,i[Jr]=s._formatReceivedMessage,i[Ln]=s._formatSentMessage,i[Un]=s._formatHistoryMessages,i[Dn]=s._formatConversationList,i[Wr]=s._formatChatRoomInfos,i[kt]=s._formatRTCUserList,i[Qr]=s._formatRTCData,i[Wt]=s._formatChatRoomKVList,i[Xr]=s._formatUserSetting,i[ei]=s._formatConversationStatus,i[ti]=s._formatGrpReadReceiptQryResp,i[zt]=s._formatSetUserSettingOutput,i[Zr]=s._formatUserSettingNotification,i[ni]=s._formatRTCRoomKVList,i[zr]=s._formatRTCAuidenceJoinRoomData,i[ri]=s._formatRTCJoinedUserInfo,i)[t];try{o=e.length>0&&s._codec[t].decode(e),Ve(o)&&(o=function(d){for(var l in d)Ve(d[l])&&(d[l]=Ze(d[l]));return d}(o)),Ir(u)&&(o=u.call(this,o,r))}catch(d){j.error(`PB parse error `,d,e,t)}return o},n.prototype._readBytes=function(e){var t=e.offset,r=e.buffer,i=e.limit;if(t)try{var s=Ya(r)?new Uint8Array(r):r;return Kn.readUTF(s.subarray(t,i))}catch(o){j.info(`readBytes error `,o)}return e},n.prototype._formatBytes=function(e){var t=this._readBytes(e);try{t=JSON.parse(t)}catch(r){j.info(`formatBytes error `,r)}return t||e},n.prototype._formatSyncMessages=function(e,t){t=t||{};var r=this,i=e.list,s=e.syncTime,o=e.finished;return(fe(o)||o===null)&&(e.finished=!0),e.syncTime=Ze(s),e.list=Zn(i,function(u){return r._formatReceivedMessage(u,t)}),e},n.prototype._formatReceivedMessage=function(e,t){var r=(t=t||{}).currentUserId,i=t.connectedTime,s=e.content,o=e.fromUserId,u=e.type,d=e.groupId,l=e.status,h=e.dataTime,a=e.classname,c=e.msgId,p=e.extraContent,f=e.pushContent,m=e.pushExt,_=e.configFlag,v=(e.direction||nt.RECEIVE)===nt.SEND,R=function(ie){var ee=Mn.READ;return{isPersited:!!(16&ie),isCounted:!!(32&ie),isMentioned:!!(64&ie),disableNotification:!!(512&ie),receivedStatus:ee=2&ie?Mn.RETRIEVED:ee,canIncludeExpansion:!!(1024&ie)}}(l),C=R.isPersited,A=R.isCounted,M=R.isMentioned,O=R.disableNotification,y=R.receivedStatus,w=R.canIncludeExpansion,$=[z.GROUP,z.CHATROOM,z.RTC_ROOM].indexOf(u)>-1?d:o,Y=v?r:o,E=Ze(h),T=E "+o),this.timestamp=t.readLong()}return{stream:t,length:r}},e.MESSAGE_LENGTH=2,e}(qn),ao=function(n){function e(){var t=n!==null&&n.apply(this,arguments)||this;return t._name=Xe.DISCONNECT,t.status=0,t}return Ie(e,n),e.prototype.readMessage=function(t,r){return t.readByte(),this.status=+t.readByte(),{stream:t,length:r}},e.MESSAGE_LENGTH=2,e}(qn),Ld=function(n){function e(){var t=n.call(this,Fe.PING_REQ)||this;return t._name=Xe.PING_REQ,t}return Ie(e,n),e.prototype.writeMessage=function(t){},e}(lc),pc=function(n){function e(t){var r=n.call(this,t)||this;return r._name=Xe.PING_RESP,r}return Ie(e,n),e}(qn),co=function(n){function e(){var t=n!==null&&n.apply(this,arguments)||this;return t.messageId=0,t}return Ie(e,n),e.prototype.readMessage=function(t,r){var i=256*t.readByte()+t.readByte();return this.messageId=parseInt(i.toString(),10),{stream:t,length:r}},e}(qn),ii=function(n){function e(){var t=n!==null&&n.apply(this,arguments)||this;return t.messageId=0,t}return Ie(e,n),e.prototype.writeMessage=function(t){var r=this.messageId,i=255&r,s=(65280&r)>>8;t.write(s),t.write(i)},e}(lc),Vn=function(n){function e(){var t=n!==null&&n.apply(this,arguments)||this;return t._name=Xe.PUBLISH,t.topic="",t.targetId="",t.syncMsg=!1,t.identifier=xt.PUB,t}return Ie(e,n),e.prototype.readMessage=function(t,r){return this.date=t.readInt(),this.topic=t.readUTF(),this.targetId=t.readUTF(),n.prototype.readMessage.call(this,t,r),this.data=t.readAll(),{stream:t,length:r}},e}(co),fn=function(n){function e(t,r,i){var s=n.call(this,Fe.PUBLISH)||this;return s._name=Xe.PUBLISH,s.syncMsg=!1,s.identifier=xt.PUB,s.topic=t,s.data=Qe(r)?Kn.writeUTF(r):r,s.targetId=i,s}return Ie(e,n),e.prototype.writeMessage=function(t){t.writeUTF(this.topic),t.writeUTF(this.targetId),n.prototype.writeMessage.call(this,t),t.write(this.data)},e}(ii),Yi=function(n){function e(){var t=n!==null&&n.apply(this,arguments)||this;return t._name=Xe.PUB_ACK,t.status=0,t.date=0,t.millisecond=0,t.messageUId="",t.timestamp=0,t.identifier=xt.PUB,t.topic="",t.targetId="",t}return Ie(e,n),e.prototype.readMessage=function(t,r){return n.prototype.readMessage.call(this,t,r),this.date=t.readInt(),this.status=256*t.readByte()+t.readByte(),this.millisecond=256*t.readByte()+t.readByte(),this.timestamp=1e3*this.date+this.millisecond,this.messageUId=t.readUTF(),{stream:t,length:r}},e}(co),fc=function(n){function e(t){var r=n.call(this,Fe.PUB_ACK)||this;return r._name=Xe.PUB_ACK,r.status=0,r.date=0,r.millisecond=0,r.messageUId="",r.timestamp=0,r.messageId=t,r}return Ie(e,n),e.prototype.writeMessage=function(t){n.prototype.writeMessage.call(this,t)},e}(ii),Q=function(n){function e(t,r,i){var s=n.call(this,Fe.QUERY)||this;return s.name=Xe.QUERY,s.identifier=xt.QUERY,s.topic=t,s.data=Qe(r)?Kn.writeUTF(r):r,s.targetId=i,s}return Ie(e,n),e.prototype.writeMessage=function(t){t.writeUTF(this.topic),t.writeUTF(this.targetId),n.prototype.writeMessage.call(this,t),t.write(this.data)},e}(ii),gc=function(n){function e(t){var r=n.call(this,Fe.QUERY_CONFIRM)||this;return r._name=Xe.QUERY_CON,r.messageId=t,r}return Ie(e,n),e}(ii),bn=function(n){function e(){var t=n!==null&&n.apply(this,arguments)||this;return t._name=Xe.QUERY_ACK,t.status=0,t.identifier=xt.QUERY,t.topic="",t.targetId="",t}return Ie(e,n),e.prototype.readMessage=function(t,r){return n.prototype.readMessage.call(this,t,r),this.date=t.readInt(),this.status=256*t.readByte()+t.readByte(),this.data=t.readAll(),{stream:t,length:r}},e}(co),mc=function(n){var e,t=n.type;switch(t){case Fe.CONN_ACK:e=new hc(n);break;case Fe.PUBLISH:(e=new Vn(n)).syncMsg=n.syncMsg;break;case Fe.PUB_ACK:e=new Yi(n);break;case Fe.QUERY_ACK:e=new bn(n);break;case Fe.SUB_ACK:case Fe.UNSUB_ACK:case Fe.PING_RESP:e=new pc(n);break;case Fe.DISCONNECT:e=new ao(n);break;default:e=new qn(n),j.error("No support for deserializing "+t+" messages")}return e};(function(n){n[n.ppMsgP=1]="ppMsgP",n[n.ppMsgN=2]="ppMsgN",n[n.ppMsgS=3]="ppMsgS",n[n.pgMsgP=4]="pgMsgP",n[n.chatMsg=5]="chatMsg",n[n.pcMsgP=6]="pcMsgP",n[n.qryPMsg=7]="qryPMsg",n[n.qryGMsg=8]="qryGMsg",n[n.qryCHMsg=9]="qryCHMsg",n[n.qryCMsg=10]="qryCMsg",n[n.qrySMsg=11]="qrySMsg",n[n.recallMsg=12]="recallMsg",n[n.prMsgS=13]="prMsgS",n[n.rrMsg=14]="rrMsg",n[n.rrList=15]="rrList",n[n.s_ntf=16]="s_ntf",n[n.s_msg=17]="s_msg",n[n.s_stat=18]="s_stat",n[n.s_cmd=19]="s_cmd",n[n.s_us=20]="s_us",n[n.pullUS=21]="pullUS",n[n.pgMsgS=22]="pgMsgS",n[n.chatMsgS=23]="chatMsgS",n[n.qrySessionsAtt=24]="qrySessionsAtt",n[n.pullMsg=25]="pullMsg",n[n.qrySessions=26]="qrySessions",n[n.delSessions=27]="delSessions",n[n.delMsg=28]="delMsg",n[n.updRRTime=29]="updRRTime",n[n.chrmPull=30]="chrmPull",n[n.joinChrm=31]="joinChrm",n[n.joinChrmR=32]="joinChrmR",n[n.exitChrm=33]="exitChrm",n[n.queryChrmI=34]="queryChrmI",n[n.setKV=35]="setKV",n[n.delKV=36]="delKV",n[n.pullKV=37]="pullKV",n[n.qryRelation=38]="qryRelation",n[n.delRelation=39]="delRelation",n[n.pullSeAtts=40]="pullSeAtts",n[n.setSeAtt=41]="setSeAtt",n[n.qnTkn=42]="qnTkn",n[n.qnUrl=43]="qnUrl",n[n.aliUrl=44]="aliUrl",n[n.s3Url=45]="s3Url",n[n.stcUrl=46]="stcUrl",n[n.cleanPMsg=47]="cleanPMsg",n[n.cleanGMsg=48]="cleanGMsg",n[n.cleanCMsg=49]="cleanCMsg",n[n.cleanSMsg=50]="cleanSMsg",n[n.rtcRJoin_data=51]="rtcRJoin_data",n[n.rtcRExit=52]="rtcRExit",n[n.rtcPing=53]="rtcPing",n[n.rtcSetData=54]="rtcSetData",n[n.rtc_ntf=55]="rtc_ntf",n[n.viewerJoinR=56]="viewerJoinR",n[n.viewerExitR=57]="viewerExitR",n[n.rtcPullKv=58]="rtcPullKv",n[n.rtcIdentityChange=59]="rtcIdentityChange",n[n.userSetData=60]="userSetData",n[n.rtcQryData=61]="rtcQryData",n[n.rtcDelData=62]="rtcDelData",n[n.rtcSetOutData=63]="rtcSetOutData",n[n.rtcQryUserOutData=64]="rtcQryUserOutData",n[n.rtcToken=65]="rtcToken",n[n.rtcUserState=66]="rtcUserState",n[n.rtcRInfo=67]="rtcRInfo",n[n.rtcUData=68]="rtcUData",n[n.rtcUPut=69]="rtcUPut",n[n.rtcUDel=70]="rtcUDel",n[n.rtcUList=71]="rtcUList",n[n.rtcQueryJoined=72]="rtcQueryJoined",n[n.addSeTag=73]="addSeTag",n[n.delSeTag=74]="delSeTag",n[n.addTag=75]="addTag",n[n.delTag=76]="delTag",n[n.disTag=77]="disTag",n[n.reportsdk=78]="reportsdk",n[n.rtcInvite=79]="rtcInvite",n[n.rtcCancelInvite=80]="rtcCancelInvite",n[n.rtcInviteAnswer=81]="rtcInviteAnswer",n[n.rtcEndInvite=82]="rtcEndInvite"})(Gi||(Gi={}));var at,D=Gi,_c=function(n,e,t,r){return x(void 0,void 0,void 0,function(){var i;return V(this,function(s){return i=0,n.forEach(function(o){return x(void 0,void 0,void 0,function(){var u,d;return V(this,function(l){switch(l.label){case 0:return u=e+"://"+o+"/ping?r="+(a=9999,(h=1e3)+Math.floor(Math.random()*(a-h))),j.debug("start ping",u),[4,t.httpReq({url:u,timeout:5e3})];case 1:return d=l.sent(),j.debug("end ping",i,u,d.status),i++,r({finished:i===n.length,code:d.status,host:o}),[2]}var h,a})})}),[2]})})},vc=function(n,e,t,r,i,s,o,u){return n+"://"+e+"/websocket?appId="+t+"&token="+encodeURIComponent(r)+"&sdkVer="+s+"&pid="+o+"&apiVer="+(i.isFromUniapp?"uniapp":"normal")+(i.connectPlatform?"&platform="+i.connectPlatform:"")+(u?"&protocolVer="+u:"")},Rc=function(n){return[D.ppMsgS,D.pgMsgS,D.chatMsgS].map(function(e){return D[e]}).indexOf(n)>=0};(function(n){n[n.REDIRECT=0]="REDIRECT",n[n.OTHER_DEVICE_LOGIN=1]="OTHER_DEVICE_LOGIN",n[n.BLOCK=2]="BLOCK",n[n.REMOTE_CLOSE=3]="REMOTE_CLOSE",n[n.LOGOUT=4]="LOGOUT",n[n.BLOCK_NEW=5]="BLOCK_NEW",n[n.REDIRECT_NEW=6]="REDIRECT_NEW"})(at||(at={}));var ut,jo=function(n,e){j.info("websocket send -> messageId: "+n.messageId);var t=n.getBufferData();e.send(t.buffer)},on=function(n){function e(t,r){var i=n.call(this,"websocket",r)||this;return i._runtime=t,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 Ie(e,n),e.prototype.connect=function(t,r,i,s,o,u){return x(this,void 0,void 0,function(){var d=this;return V(this,function(l){return[2,new Promise(function(h){var a=[],c=0,p=!1,f=!1,m=function(){return x(d,void 0,void 0,function(){var _;return V(this,function(v){switch(v.label){case 0:return a.length===0||p?[2]:(p=!0,[4,this._connect(t,r,a.shift(),s,o,u)]);case 1:if((_=v.sent())===S.SUCCESS)this._checkAlive(),h(_);else if(_===Be.REDIRECT)h(_);else{if(f&&a.length===0)return h(Ja(_)),[2];p=!1,m()}return[2]}})})};o=hs(o),d._watcher.status(te.CONNECTING),_c(i,s,d._runtime,function(_){var v=_.code,R=_.finished,C=_.host;f=R,v===200&&(a.push(C),c++,m()),R&&c===0&&(j.error("No valid websocket server hosts!"),h(S.RC_SOCKET_NOT_CREATED))})})]})})},e.prototype._connect=function(t,r,i,s,o,u){return x(this,void 0,void 0,function(){var d,l,h,a,c,p=this;return V(this,function(f){switch(f.label){case 0:return d=s.replace("http","ws"),l=vc(d,i,t,r,this._runtime,o,"",u),j.debug("conenct start -> "+l),this.sendConnectTime=Date.now(),h=this._runtime.createWebSocket(l),a=function(m){p._timer&&(clearTimeout(p._timer),p._timer=null),p._socket===h&&(p._socket=null,p._watcher.status(m))},[4,new Promise(function(m){h.onMessage(function(_){if(Object.prototype.toString.call(_)==="[object ArrayBuffer]"){var v=function(C,A){var M=new Uint8Array(C),O=new od(M),y=O.readByte(),w=new gs(y),$=mc(w);return $.read(O,M.length-1,A),$}(_,u);if(v instanceof pc&&p._pingResolve)return p._pingResolve(S.SUCCESS),void(p._pingResolve=void 0);if(v instanceof hc)return j.debug("recv connect ack -> "+v.status),v.status!==Be.ACCEPTED?(j.warn("connect failed: "+v.status),void m(v.status)):(j.info("connect success -> "+l),p.connectedTime=v.timestamp,p.userId=v.userId||"",p._idCount=v.messageId,void m(S.SUCCESS));if(v instanceof ao){var R=v.status;switch(j.warn("recv disconnect signal -> status: "+R),R){case at.BLOCK:p._watcher.status(te.BLOCKED);break;case at.OTHER_DEVICE_LOGIN:p._watcher.status(te.KICKED_OFFLINE_BY_OTHER_CLIENT);break;case at.REDIRECT_NEW:case at.REDIRECT:p._watcher.status(te.REDIRECT);break;default:p._watcher.status(te.DISCONNECT_BY_SERVER)}}else p._onReceiveSignal(v)}else j.error("Socket received invalid data:",_)}),h.onClose(function(_,v){for(var R in j.warn("websocket closed! code:",_,"reason:",v),a(te.CONNECTION_CLOSED),p._messageIds){var C=p._messageIds[R];delete p._messageIds[R],C(S.RC_NET_CHANNEL_INVALID)}m(_)}),h.onError(function(_){var v;for(var R in j.error("websocket error!",(v=_)===null||v===void 0?void 0:v.stack),a(te.WEBSOCKET_ERROR),p._messageIds){var C=p._messageIds[R];delete p._messageIds[R],C(S.RC_NET_CHANNEL_INVALID)}m(S.NETWORK_ERROR)}),h.onOpen(function(){return j.debug("websocket open =>",l)}),setTimeout(function(){m(S.TIMEOUT)},5e3)})];case 1:return(c=f.sent())===S.SUCCESS?this._socket=h:(j.warn("connect result -> code: "+c+", url: "+l),h.close()),[2,c]}})})},e.prototype._checkAlive=function(){var t;return x(this,void 0,void 0,function(){var r,i=this;return V(this,function(s){switch(s.label){case 0:return this._socket?(j.debug("send ping ->"),this.sendOnly(new Ld),[4,new Promise(function(o){i._pingResolve=o,i._timer&&clearTimeout(i._timer),i._timer=setTimeout(function(){i._pingResolve=void 0,o(S.TIMEOUT)},15e3)})]):[2];case 1:return(r=s.sent())!==S.SUCCESS?(this._failedCount+=1,j.warn("ping failed count: "+this._failedCount+", code: "+r),this._failedCount>=this.ALLOW_FAILED_TIMES?(this._failedCount=0,j.warn("ping timeout, close current websocket to reconnect!"),(t=this._socket)===null||t===void 0||t.close(),this._watcher.status(te.NETWORK_UNAVAILABLE)):this._checkAlive(),[2]):(j.debug("recv pong <-"),this._failedCount=0,setTimeout(function(){return i._checkAlive()},15e3),[2])}})})},e.prototype._onReceiveSignal=function(t){return x(this,void 0,void 0,function(){var r,i,s,o,u,d,l=this;return V(this,function(h){switch(h.label){case 0:return r=t.messageId,t.header&&t.header.qos!==vt.AT_MOST_ONCE&&(t instanceof Vn&&!t.syncMsg&&(j.debug("send pubAck -> "+r),this.sendOnly(new fc(r))),t instanceof bn&&(j.debug("send queryCon -> "+r),this.sendOnly(new gc(r)))),r>0&&(t instanceof Yi||t instanceof bn)&&(j.debug("recv ack -> messageId: "+r),(i=this._messageIds[r])&&(i(t),delete this._messageIds[r]),(s=this._syncMessageIds[r])&&(delete this._syncMessageIds[r],s(t))),t instanceof Vn?(o=t.syncMsg,(u=t.topic)===D[D.userSetData]?[2]:!o||Rc(u)?(this._watcher.signal(t),[2]):[4,new Promise(function(a){l._syncMessageIds[r]=a})]):[3,2];case 1:d=h.sent(),delete this._syncMessageIds[r],this._watcher.signal(t,d),h.label=2;case 2:return[2]}})})},e.prototype.sendOnly=function(t){this._socket&&jo(t,this._socket)},e.prototype.send=function(t,r,i,s){return s===void 0&&(s=3e4),x(this,void 0,void 0,function(){var o,u,d,l=this;return V(this,function(h){switch(h.label){case 0:return this._socket?(o=this._generateMessageId(),t.messageId=o,jo(t,this._socket),[4,new Promise(function(a){l._messageIds[o]=a,setTimeout(function(){l._messageIds[o]&&delete l._messageIds[o],a()},s)})]):[3,2];case 1:return(u=h.sent())?u instanceof bn||u instanceof Yi?(d=r&&u.data?this.codec.decodeByPBName(u.data,r,i):u,u.status!==0?(j.warn("send failed -> message: "+o+", respPBName: "+r+", status: "+u.status),[2,{code:u.status,data:r&&u.data?d:null}]):[2,{code:S.SUCCESS,data:d}]):[2,{code:u}]:(j.warn("send timeout -> message: "+o+", respPBName: "+r+", timeout: "+s),[2,{code:S.TIMEOUT}]);case 2:return[2,{code:S.RC_NET_CHANNEL_INVALID}]}})})},e.prototype.close=function(){this._socket&&(this._socket.close(),this._socket=null,this._watcher.status(te.DISCONNECTED))},e}(uc);(function(n){n.GET="GET",n.POST="POST"})(ut||(ut={}));var an=function(n){function e(t,r){var i=n.call(this,"comet",r)||this;return i._runtime=t,i._messageIds={},i._syncMessageIds={},i._idCount=0,i._generateMessageId=function(){return++i._idCount},i._pid=encodeURIComponent(new Date().getTime()+Math.random()+""),i}return Ie(e,n),e.prototype.handleCometRes=function(t){var r=this;if(t.status!==200&&t.status!==202)return!1;var i=Qe(t.data)?JSON.parse(t.data):t.data;return i?!Ye(i)||(Oe(i,function(s){return x(r,void 0,void 0,function(){var o,u,d,l,h,a,c,p,f,m,_,v=this;return V(this,function(R){switch(R.label){case 0:if((o=s.sessionid)&&(this._sessionid=o),u=function(C){var A=C.headerCode,M=new gs(A),O=mc(M);for(var y in C)O[y]=C[y];return O}(s),d=u.messageId,l=u._header,h=u.status,u.identifier,a=l&&l.qos!==vt.AT_MOST_ONCE,d&&u.getIdentifier&&((c=this._messageIds[d])&&c(u),this._syncMessageIds[d]&&this._syncMessageIds[d](u)),a&&(u instanceof Vn&&!u.syncMsg&&(p=new fc(d),this.sendOnly(p)),u instanceof bn&&(p=new gc(d),this.sendOnly(p))),u instanceof ao){switch(h){case at.OTHER_DEVICE_LOGIN:this._watcher.status(te.KICKED_OFFLINE_BY_OTHER_CLIENT);break;case at.BLOCK:this._watcher.status(te.BLOCKED);break;case at.REDIRECT_NEW:case at.REDIRECT:this._watcher.status(te.REDIRECT);break;default:this._watcher.status(te.DISCONNECT_BY_SERVER)}return[2]}return u instanceof Vn?(f=u.syncMsg,m=u.topic,!f||Rc(m)?(this._watcher.signal(u),[2,!1]):[4,new Promise(function(C){v._syncMessageIds[d]=C})]):[3,2];case 1:_=R.sent(),delete this._syncMessageIds[d],this._watcher.signal(u,_),R.label=2;case 2:return[2]}})})}),!0):(j.error("received data is not a validJson",i),!1)},e.prototype._startPullSignal=function(t){return x(this,void 0,void 0,function(){var r,i,s,o;return V(this,function(u){switch(u.label){case 0:return r=new Date().getTime(),i=t+"://"+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 s=u.sent(),o=this.handleCometRes(s),this._isDisconnected||(o?this._startPullSignal(t):(this._isDisconnected=!0,this._watcher.status(te.NETWORK_UNAVAILABLE))),[2]}})})},e.prototype.connect=function(t,r,i,s,o,u){return x(this,void 0,void 0,function(){var d,l,h,a,c=this;return V(this,function(p){return o=hs(o),this._protocol=s,this._isDisconnected=!1,this._watcher.status(te.CONNECTING),d=[],l=0,h=!1,a=!1,[2,new Promise(function(f){var m=function(){return x(c,void 0,void 0,function(){var _;return V(this,function(v){switch(v.label){case 0:return d.length===0||h?[2]:(h=!0,[4,this._connect(t,r,d.shift(),s,o)]);case 1:if((_=v.sent())===S.SUCCESS)this._startPullSignal(s),f(_);else if(_===Be.REDIRECT)f(_);else{if(a&&d.length===0)return f(Ja(_)),[2];h=!1,m()}return[2]}})})};c._watcher.status(te.CONNECTING),_c(i,s,c._runtime,function(_){var v=_.code,R=_.finished,C=_.host;a=R,v===200&&(d.push(C),l++,m()),R&&l===0&&(j.error("No valid websocket server hosts!"),f(S.RC_SOCKET_NOT_CREATED))})})]})})},e.prototype._connect=function(t,r,i,s,o){return x(this,void 0,void 0,function(){var u,d,l,h;return V(this,function(a){switch(a.label){case 0:return u=function(c){return c.status!==200&&c.status!==202?(j.error("handle comet res -> res: "+JSON.stringify(c||{})),!1):!!c.data&&(function(p){if(Ve(p))return!0;var f=!1;try{var m=JSON.parse(p);f=JSON.stringify(m)===p}catch{f=!1}return f}(c.data)?Ve(c.data)?c.data:JSON.parse(c.data):(j.error("received data is not a validJson",c.data),!1))},d=vc(s,i,t,r,this._runtime,o,this._pid),this.sendConnectTime=Date.now(),j.debug("conenct start -> "+d),[4,this._runtime.httpReq({url:d,body:{pid:this._pid},timeout:5e3})];case 1:return l=a.sent(),h=u(l),this._domain=i,h&&h.status===0?(this._sessionid=h.sessionid,this.userId=h.userId,this.connectedTime=h.timestamp):j.warn("connect result -> code: "+(h==null?void 0:h.status)+", url: "+d),[2,h==null?void 0:h.status]}})})},e.prototype.sendCometData=function(t,r){return x(this,void 0,void 0,function(){var i,s,o,u,d,l,h,a,c,p;return V(this,function(f){switch(f.label){case 0:return s=(i=this)._domain,o=i._sessionid,u=i._pid,d=t.messageId,l=t.topic,h=t.targetId,t.identifier,a=t.getHeaderFlag(),c=l?this._protocol+"://"+s+"/websocket?messageid="+d+"&header="+a+"&sessionid="+o+"&topic="+l+"&targetid="+h+"&pid="+u:this._protocol+"://"+s+"/websocket?messageid="+d+"&header="+a+"&sessionid="+o+"&pid="+u,[4,this._runtime.httpReq({url:c,method:ut.POST,body:t.getCometData()})];case 1:return p=f.sent(),this.handleCometRes(p),[2]}})})},e.prototype.sendOnly=function(t){this.sendCometData(t)},e.prototype.send=function(t,r,i,s){return s===void 0&&(s=3e4),x(this,void 0,void 0,function(){var o,u,d,l=this;return V(this,function(h){switch(h.label){case 0:return o=this._generateMessageId(),t.messageId=o,this.sendCometData(t),[4,new Promise(function(a){l._messageIds[o]=a,setTimeout(function(){delete l._messageIds[o],a()},s)})];case 1:return(u=h.sent())?(d=r&&u.data?this.codec.decodeByPBName(u.data,r,i):u,u.status!==0?[2,{code:u.status,data:r&&u.data?d:null}]:[2,{code:S.SUCCESS,data:d}]):[2,{code:S.TIMEOUT}]}})})},e.prototype.close=function(){this._isDisconnected=!0,this._watcher.status(te.DISCONNECTED)},e}(uc),kd=function(n,e,t){this.runtime=n,this._watcher=e,this._options=t,this.currentUserId="",this._appkey=this._options.appkey,this._apiVer=this._options.apiVersion,this.navi=this._createNavi()},mi=function(n){return["navi",n].join("_")},Ud=function(){function n(e,t){this._runtime=e,this._options=t,this._naviInfo=null,this._appkey=this._options.appkey,this._apiVersion=hs(this._options.apiVersion)}return n.prototype.getInfo=function(e,t,r,i){return x(this,void 0,void 0,function(){var s,o;return V(this,function(u){switch(u.label){case 0:return r&&this._clear(e),(s=function(d,l,h){var a,c,p=mi(d);try{var f=h.getItem(p);c=f?JSON.parse(f):[]}catch{c=[]}var m=Date.now();return c.length>0&&(c=c.filter(function(_){return m-_.timestamp<72e5})),c.length===0?h.removeItem(p):h.setItem(p,JSON.stringify(c)),((a=c.find(function(_){return _.token===l}))===null||a===void 0?void 0:a.naviInfo)||null}(this._appkey,e,this._runtime.localStorage))?(this._naviInfo=s,[2,s]):(o=this._options.navigators.slice(),t.length&&t.forEach(function(d){o.indexOf(d)<0&&o.unshift(d)}),[4,this._reqNavi(o,this._appkey,e,i)]);case 1:return(s=u.sent())?(this._naviInfo=s,this.setNaviInfo2Cache(e,s),[2,s]):[2,s]}})})},n.prototype.setNaviInfo2Cache=function(e,t){this._naviInfo=t,function(r,i,s,o){var u,d=mi(r);try{var l=o.getItem(d);u=l?JSON.parse(l):[]}catch{u=[]}var h=Date.now();u.length>0&&(u=u.filter(function(a){return h-a.timestamp<72e5&&i!==a.token})),u.push({timestamp:h,naviInfo:s,token:i}),o.setItem(d,JSON.stringify(u))}(this._appkey,e,t,this._runtime.localStorage)},n.prototype.getInfoFromCache=function(e){return this._naviInfo},n.prototype._clear=function(e){(function(t,r,i){var s,o=mi(t);try{var u=i.getItem(o);s=u?JSON.parse(u):[]}catch{s=[]}var d=Date.now();s.length>0&&(s=s.filter(function(l){return d-l.timestamp<72e5&&r!==l.token})),s.length===0?i.removeItem(o):i.setItem(o,JSON.stringify(s))})(this._appkey,e,this._runtime.localStorage)},n}(),tr=function(n,e,t){return[n,e,t].join("_")},Dd=function(){function n(e,t){this._runtime=e,this._appkey=t,this._users={}}return n.prototype._getMemData=function(e){return this._users[e]||(this._users[e]={inboxTime:0,outboxTime:0})},n.prototype.setInboxTime=function(e,t){var r=this._getMemData(t);if(!(r.inboxTime>e)){r.inboxTime=e;var i=tr("inbox",this._appkey,t);this._runtime.localStorage.setItem(i,e.toString())}},n.prototype.getInboxTime=function(e){var t=this._getMemData(e);if(t.inboxTime===0){var r=tr("inbox",this._appkey,e);t.inboxTime=parseInt(this._runtime.localStorage.getItem(r))||0}return t.inboxTime},n.prototype.setOutboxTime=function(e,t){var r=this._getMemData(t);if(!(r.outboxTime>=e)){r.outboxTime=e;var i=tr("outbox",this._appkey,t);this._runtime.localStorage.setItem(i,e.toString())}},n.prototype.getOutboxTime=function(e){var t=this._getMemData(e);if(t.outboxTime===0){var r=tr("outbox",this._appkey,e);t.outboxTime=parseInt(this._runtime.localStorage.getItem(r))||0}return t.outboxTime},n}(),_i={_caches:{},set:function(n,e){this._caches[n]=e},get:function(n){return this._caches[n]||0},clear:function(n){this._caches[n]=0}},xd=function(){function n(e,t){this._kvCaches={},this._chatroomId=e,this._currentUserId=t}return n.prototype._add=function(e){var t=e.key;e.isDeleted=!1,this._kvCaches[t]=e},n.prototype._remove=function(e){var t=e.key,r=this._kvCaches[t];r&&(r.isDeleted=!0,this._kvCaches[t]=r)},n.prototype._setEntry=function(e,t){var r=e.key,i=e.type,s=e.isOverwrite,o=e.userId,u=this._getSetUserId(r),d=i===We.DELETE,l=u===o,h=!this._isExisted(r),a=d?this._remove:this._add;(t||s||l||h)&&a.call(this,e)},n.prototype.getValue=function(e){var t=this._kvCaches[e]||{};return t.isDeleted?null:t.value},n.prototype.getAllValue=function(){var e={};for(var t in this._kvCaches)this._kvCaches[t].isDeleted||(e[t]=this._kvCaches[t].value);return e},n.prototype._getSetUserId=function(e){return(this._kvCaches[e]||{}).userId},n.prototype._isExisted=function(e){var t=this._kvCaches[e]||{},r=t.value,i=t.isDeleted;return r&&!i},n.prototype.setEntries=function(e){var t=this,r=e.kvEntries,i=e.isFullUpdate;r=r||[],(i=i||!1)&&this.clear(),r.forEach(function(s){t._setEntry(s,i)}),j.debug("end setEntries")},n.prototype.clear=function(){this._kvCaches={}},n}(),Vd=function(){function n(e){this._pullQueue=[],this._isPulling=!1,this._storeCaches={},this._engine=e}return n.prototype._startPull=function(){return x(this,void 0,void 0,function(){var e,t,r,i,s,o,u;return V(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],t=e.chrmId,r=e.timestamp,(i=_i.get(t))>r?(this._isPulling=!1,this._startPull(),[2]):[4,this._engine.pullChatroomEntry(t,i)]);case 1:return s=d.sent(),o=s.code,u=s.data,this._isPulling=!1,o===S.SUCCESS?(_i.set(t,u.syncTime||0),this._startPull()):this._startPull(),[2]}})})},n.prototype.reset=function(e){_i.clear(e);var t=this._storeCaches[e];t&&t.clear()},n.prototype.pullEntry=function(e,t){this._pullQueue.push({chrmId:e,timestamp:t}),this._startPull()},n.prototype.setLocal=function(e,t,r){var i=this._storeCaches[e];Sn(i)||(i=new xd(e,r)),i.setEntries(t),this._storeCaches[e]=i},n.prototype.getValue=function(e,t){var r=this._storeCaches[e];return r?r.getValue(t):null},n.prototype.getAll=function(e){var t=this._storeCaches[e],r={};return t&&(r=t.getAllValue()),r},n}(),Bd=function(){function n(e,t,r,i){this._runtime=e,this._appkey=t,this._userId=r,this._canJoinMulipleChrm=i,this._sessionKey="",this._joinedChrmsInfo={},this._sessionKey="sync-chrm-"+this._appkey+"-"+this._userId}return n.prototype.set=function(e,t){t===void 0&&(t=10),!this._canJoinMulipleChrm&&(this._joinedChrmsInfo={}),this._joinedChrmsInfo[e]=t,this._runtime.sessionStorage.setItem(this._sessionKey,JSON.stringify(this._joinedChrmsInfo))},n.prototype.get=function(){var e,t;try{t=this._runtime.sessionStorage.getItem(this._sessionKey),e=JSON.parse(t||"{}")}catch{j.error("parse rejoined chrm infos error -> "+t),e={}}return e},n.prototype.remove=function(e){delete this._joinedChrmsInfo[e],Sn(this._joinedChrmsInfo)?this._runtime.sessionStorage.setItem(this._sessionKey,JSON.stringify(this._joinedChrmsInfo)):this.clear()},n.prototype.clear=function(){this._joinedChrmsInfo={},this._runtime.sessionStorage.removeItem(this._sessionKey)},n}(),vi="converStatusChanged",Fd=function(){function n(e,t,r){this._eventEmitter=new jn,this._pullQueue=[],this._isPulling=!1,this._storage=Gr(e.runtime),this._appkey=t,this._currentUserId=r,this._engine=e,this._storagePullTimeKey="con-s-"+t+"-"+r}return n.prototype._set=function(e){var t=this;if(!fe(e)&&Array.isArray(e)){var r=this._storage.get(this._storagePullTimeKey)||0,i=e.length;e.forEach(function(s,o){var u=s.updatedTime||0;r=u>r?u:r,s.conversationType=s.type,t._eventEmitter.emit(vi,{statusItem:s,isLastPull:o===i-1})}),this._storage.set(this._storagePullTimeKey,r)}},n.prototype._startPull=function(){return x(this,void 0,void 0,function(){var e,t,r,i;return V(this,function(s){switch(s.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 t=s.sent(),r=t.code,i=t.data,r===S.SUCCESS?(this._isPulling=!1,this._set(i),this._startPull()):this._startPull(),[2]}})})},n.prototype.pull=function(e){var t=this._storage.get(this._storagePullTimeKey)||0;(e>t||e===0)&&(this._pullQueue.push(t),this._startPull())},n.prototype.watch=function(e){this._eventEmitter.on(vi,function(t){e(t)})},n.prototype.unwatch=function(){this._eventEmitter.off(vi,function(e){})},n}(),Pt={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}},_r={};for(var Ko in Pt){var Hd=Pt[Ko].keyName;_r[Hd]=Ko}var gn,$d=function(){function n(e,t,r){this._appkey=t,this._currentUserId=r;var i="con-"+t+"-"+r;this.storage=new So(e,i),this._localStore=new So(e,"CONVER-"+t+"-"+r)}return n.prototype._getStoreKey=function(e,t,r){return r+"_"+e+"_"+t},n.prototype._getConOptionByKey=function(e){var t=(e=e||"").split("_");if(t.length>=2){var r=t.shift(),i=t.shift(),s=t.join("_");return{conversationType:Number(i),targetId:s,channelId:r}}return{conversationType:z.PRIVATE,targetId:"",channelId:""}},n.prototype.updateMentionedData=function(e){var t=this,r=e.conversationType,i=e.targetId,s=e.messageType,o=e.isMentioned,u=e.content,d=e.senderUserId,l=e.channelId,h=this._getStoreKey(r,i,l),a=this._localStore.get(h)||{},c=_r.mentionedInfo,p=_r.hasMentioned,f=a[c]||{},m=f.userIdList||[],_=u.mentionedInfo;if(_){if(o&&r===z.GROUP&&((_.userIdList||[]).forEach(function(R){R===t._currentUserId&&m.indexOf(d)<0&&m.push(d)}),_.type===fs.ALL&&m.indexOf(d)<0&&m.push(d)),s===He.RECALL&&r===z.GROUP){var v=m.indexOf(d);v>=0&&m.splice(v,1)}_={userIdList:m,type:(_==null?void 0:_.type)||f.type},m.length!==0?(a[c]=_,a[p]=!0):(delete a[c],delete a[p]),Sn(a)?this._localStore.set(h,a):this._localStore.remove(h)}},n.prototype.set=function(e,t,r,i){var s=this._getStoreKey(e,t,i),o=this._localStore.get(s)||{};for(var u in r){var d=_r[u],l=r[u];if(!fe(d)&&!fe(l)&&u!=="hasMentioned"&&u!=="MentionedInfo"){if(l===Pt[d].defaultVal||u==="tags"&&!Sn(l))delete o[d];else if(u==="tags"){var h=l;for(var a in h)h[a].isTop||delete h[a].isTop;o[d]=l}else o[d]=l;o.c||(delete o.t,delete o.hm,delete o.m,delete o.mc)}}Sn(o)?this._localStore.set(s,o):this._localStore.remove(s)},n.prototype.get=function(e,t,r){r===void 0&&(r="");var i=this._getStoreKey(e,t,r),s=this._localStore.get(i)||{},o={};for(var u in Pt){var d=Pt[u],l=d.keyName,h=d.defaultVal;o[l]=s[u]||mr(h)}return o},n.prototype.getValue=function(e){var t=this._localStore.getValues()||{},r=[];for(var i in t){var s=this._getConOptionByKey(i),o={conversationType:s.conversationType,targetId:s.targetId,channelId:s.channelId},u=t[i];for(var d in u){var l=Pt[d],h=l.keyName,a=l.defaultVal;o[h]=u[d]||mr(a)}o=e?e(o):o,r.push(o)}return r},n.prototype.getValueForTag=function(){var e=this._localStore.getValues()||{},t={};for(var r in e){var i=this._getConOptionByKey(r),s=i.conversationType,o=i.targetId,u={},d=e[r];for(var l in d){var h=Pt[l],a=h.keyName,c=h.defaultVal;u[a]=d[l]||mr(c)}for(var p in u.tags){fe(t[p])&&(t[p]=[]);var f=Object.assign({},u,{conversationType:s,targetId:o});delete f.tags,t[p].push(f)}}return t},n.prototype.adaptOldStore=function(){try{var e=this.storage.getValues();if(Object.keys(e).length===0)return;for(var t in e){var r="_"+t;this._localStore.set(r,e[t])}}catch(i){j.error("adaptOldStore error: "+i.message)}},n}(),jd=[z.PRIVATE,z.GROUP,z.SYSTEM,z.PUBLIC_SERVICE,z.APP_PUBLIC_SERVICE],qo="conversationChanged",Go="conTagStatusChanged",Kd=function(){function n(e,t,r,i,s){var o=this;this._updatedConversations={},this._conTagStatusChanged=!1,this._eventEmitter=new jn,this._draftMap={},this._appkey=t,this._loginUserId=r,this._store=new $d(e.runtime,t,r),this._statusManager=new Fd(e,t,r),this._statusManager.watch(function(u){var d=u.statusItem,l=u.isLastPull;o.addStatus(d,l)}),this._eventEmitter.on(qo,function(u){i(u)}),this._eventEmitter.on(Go,function(){s()})}return n.prototype._calcUnreadCount=function(e,t){var r=e.content,i=e.messageType,s=e.sentTime,o=e.isCounted,u=e.messageDirection,d=e.senderUserId,l=u===nt.SEND&&d===this._loginUserId,h=i===He.RECALL,a=Ve(r),c=!1,p={},f=t.lastUnreadTime||0,m=t.unreadMessageCount||0;return f>s||l?{hasChanged:c,localConversation:t,updateItems:p}:(o&&(t.unreadMessageCount=m+1,t.lastUnreadTime=s,c=!0),h&&a&&f>=r.sentTime&&m&&(t.unreadMessageCount=m-1,c=!0),c&&(p.unreadMessageCount={val:t.unreadMessageCount,time:s}),{hasChanged:c,localConversation:t,updateItems:p})},n.prototype._calcMentionedInfo=function(e,t){var r=e.content,i=(e.messageDirection,e.isMentioned),s=e.sentTime;nt.SEND;var o=Ve(r),u=!1,d={};return i&&o&&r.mentionedInfo&&(t.hasMentioned=!0,u=!0,d.hasMentioned={val:!0,time:s},d.mentionedInfo={val:r.mentionedInfo,time:s}),{hasChanged:u,localConversation:t,updateItems:d}},n.prototype._calcMentionedCount=function(e,t){var r=e.content,i=e.messageDirection,s=!1;if(e.isMentioned&&i===nt.RECEIVE&&(r==null?void 0:r.mentionedInfo)){var o=r.mentionedInfo,u=o.type,d=o.userIdList;if(u===fs.ALL||(d||[]).includes(this._loginUserId)){s=!0;var l=t.unreadMentionedCount||0;t.unreadMentionedCount=l+1}}return{hasChanged:s,localConversation:t}},n.prototype._setUpdatedConversation=function(e){if(Ve(e)){var t=e.conversationType,r=e.targetId,i=e.channelId,s=t+"_"+r,o=this._store.get(t,r,i)||{};this._updatedConversations[s]=Object.assign(o,e)}},n.prototype._setConTagStatusChanged=function(e,t,r,i){var s=(this._store.get(e,t,i)||{}).tags||{};if(Object.keys(s).length===Object.keys(r).length){for(var o in s)if(!r[o]||s[o].isTop!==r[o].isTop)return void(this._conTagStatusChanged=!0)}else this._conTagStatusChanged=!0},n.prototype.addStatus=function(e,t){var r=e.conversationType,i=e.targetId,s=e.updatedTime,o=e.notificationStatus,u=e.isTop,d=e.tags,l=e.channelId,h={},a={};fe(o)||(a.notificationStatus={time:s,val:o}),fe(u)||(a.isTop={time:s,val:u}),fe(d)||(a.tags={time:s,val:d},d==null||d.forEach(function(c){h[c.tagId]={isTop:c.isTop}})),this._setConTagStatusChanged(r,i,h,l),this._store.set(r,i,{notificationStatus:o,isTop:u,tags:h},l),this._setUpdatedConversation({conversationType:r,targetId:i,updatedItems:a,channelId:l}),t&&this._notifyConversationChanged()},n.prototype._notifyConversationChanged=function(){var e=[];for(var t in this._updatedConversations)e.push(this._updatedConversations[t]);e.length!==0&&(this._eventEmitter.emit(qo,e),this._updatedConversations={},this._conTagStatusChanged&&(this._eventEmitter.emit(Go),this._conTagStatusChanged=!1))},n.prototype.setConversationCacheByMessage=function(e,t){var r=this,i=e.conversationType,s=e.isPersited,o=e.targetId,u=e.channelId;if(jd.indexOf(i)>=0){var d=!1,l=this._store.get(i,o,u),h={};if([this._calcUnreadCount,this._calcMentionedInfo,this._calcMentionedCount].forEach(function(p){var f=p.call(r,e,l),m=f.hasChanged,_=f.localConversation,v=f.updateItems;d=d||m,h=Re(Re({},h),v),l=mr(_)}),d&&this._store.set(i,o,l,u),this._store.updateMentionedData(e),s){var a=this._store.get(i,o,u);a.updatedItems=Re({latestMessage:{time:e.sentTime,val:e}},h),a.latestMessage=e;var c=Object.assign(a,{conversationType:i,targetId:o,channelId:u});this._setUpdatedConversation(c)}(d||s)&&this._notifyConversationChanged()}},n.prototype.get=function(e,t,r){return r===void 0&&(r=""),this._store.get(e,t,r)},n.prototype.getAllUnreadCount=function(e,t,r){var i=this._store.getValue(),s=0;return i.forEach(function(o){var u=o.unreadMessageCount,d=o.notificationStatus,l=o.conversationType;u=u||0,(r||d!==1)&&(t.length>0?t.includes(Number(l))&&(s+=Number(u)):s+=Number(u))}),s},n.prototype.getUnreadCountByTag=function(e,t){var r=this._store.getValueForTag()[e]||[],i=0;return r.forEach(function(s){var o=s.unreadMessageCount,u=s.notificationStatus;(t||u!==1)&&(o=o||0,i+=Number(o))}),i},n.prototype.getUnreadCount=function(e,t,r){return this._store.get(e,t,r).unreadMessageCount||0},n.prototype.clearUnreadCount=function(e,t,r,i){i===void 0&&(i=!0);var s=this._store.get(e,t,r),o=s.unreadMessageCount,u=s.hasMentioned,d={};if(o&&(s.unreadMessageCount=0,d.unreadMessageCount={val:0,time:Date.now()}),u&&(s.hasMentioned=!1,s.unreadMentionedCount=0,s.mentionedInfo=void 0,d.hasMentioned={val:!1,time:Date.now()},d.mentionedInfo={val:void 0,time:Date.now()}),this._store.set(e,t,s,r),i&&Object.keys(d).length!==0){var l=Object.assign(s,{conversationType:e,targetId:t,channelId:r,updatedItems:d});this._setUpdatedConversation(l),this._notifyConversationChanged()}},n.prototype.clearAllUnreadCount=function(){var e=this;this._store.getValue().forEach(function(t){t.unreadMessageCount&&(t.unreadMessageCount=0,e._store.set(t.conversationType,t.targetId,t,t.channelId))})},n.prototype.startPullConversationStatus=function(e){this._statusManager.pull(e)},n.prototype.setDraft=function(e,t,r,i){var s=e+"_"+t+"_"+i;this._draftMap[s]=r},n.prototype.getDraft=function(e,t,r){var i=e+"_"+t+"_"+r;return this._draftMap[i]},n.prototype.clearDraft=function(e,t,r){var i=e+"_"+t+"_"+r;delete this._draftMap[i]},n.prototype.addTagStatus=function(e,t,r,i){i===void 0&&(i="");var s=this._store.get(e,t,i).tags;s=Object.assign(s,r),this._store.set(e,t,{tags:s},i)},n.prototype.deleteTagStatus=function(e,t,r,i){i===void 0&&(i="");var s=this._store.get(e,t,i).tags;r.forEach(function(o){delete s[o]}),this._store.set(e,t,{tags:s},i)},n.prototype.getConversationListForTag=function(){return this._store.getValueForTag()},n.prototype.getBlockConversationList=function(){return this._store.getValue().filter(function(e){return e.notificationStatus===Kt.OPEN}).map(function(e){return{conversationType:e.conversationType,targetId:e.targetId,channelId:e.channelId}})},n.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}})},n.prototype.adaptOldStore=function(){this._store.adaptOldStore()},n.prototype.getUnreadMentionedCount=function(e,t,r){return e===void 0&&(e=""),this.get(t,r,e).unreadMentionedCount||0},n.prototype.getAllUnreadMentionedCount=function(){var e=this._store.getValue(),t=0;return e.forEach(function(r){var i=r.unreadMentionedCount;i=i||0,t+=Number(i)}),t},n}(),qd=function(){function n(e,t,r,i){this._pullQueue=[],this._isPulling=!1,this._storageTagKey="tag-"+t+"-"+r,this._storagePullTimeKey="us-s-"+t+"-"+r,this._storage=Gr(e.runtime),this._engine=e,this._tagWatcherFunc=i}return n.prototype._updateTag=function(e){var t=e.tags,r={};t.forEach(function(i){r[i.tagId]={tagName:i.tagName,createdTime:i.createdTime}}),this._storage.set(this._storageTagKey,r),this._tagWatcherFunc()},n.prototype.addTag=function(e,t){var r=this._storage.get(this._storageTagKey)||{};e.forEach(function(i){var s,o=((s=r[i.tagId])===null||s===void 0?void 0:s.createdTime)||i.createdTime||0;r[i.tagId]={tagName:i.tagName,createdTime:o}}),this._storage.set(this._storageTagKey,r),this._storage.set(this._storagePullTimeKey,t)},n.prototype.deleteTag=function(e,t){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,t)},n.prototype.getTagsInfo=function(){return this._storage.get(this._storageTagKey)||{}},n.prototype.getTags=function(){var e=this._storage.get(this._storageTagKey)||{},t=[];for(var r in e)t.push({tagId:r,tagName:e[r].tagName,createdTime:e[r].createdTime,conversationCount:0});return t.sort(function(i,s){return(i.createdTime||0)-(s.createdTime||0)})},n.prototype.getTagById=function(e){var t=this._storage.get(this._storageTagKey)||{};return t[e]?{tagId:e,tagName:t[e].tagName,createdTime:t[e].createdTime,conversationCount:0}:null},n.prototype._startPull=function(){return x(this,void 0,void 0,function(){var e,t,r,i,s,o,u,d;return V(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 t=l.sent(),r=t.code,i=t.data,r!==S.SUCCESS||fe(i)?(this._isPulling=!1,this._startPull()):(o=(s=i).settings,u=s.version,d=o.Tag,fe(d)||this._updateTag(d),this._storage.set(this._storagePullTimeKey,u),this._isPulling=!1,this._startPull()),[2]}})})},n.prototype.pullUserSettings=function(e){var t=this._storage.get(this._storagePullTimeKey)||0;(e>t||e===0)&&(this._pullQueue.push(t),this._startPull())},n.prototype.getVersion=function(){return this._storage.get(this._storagePullTimeKey)||0},n}(),Gd=function(n){function e(t,r){var i=n.call(this,t,r)||this;return i._miniConnectUrl="",i._connectType=r.connectionType,i}return Ie(e,n),e.prototype._formatJSONPUrl=function(t,r,i,s){return t+"/"+(this._runtime.isSupportSocket()&&this._connectType==="websocket"?"navi":"cometnavi")+".js?appId="+i+"&token="+encodeURIComponent(r)+"&callBack="+s+"&v="+this._apiVersion+"&r="+Date.now()},e.prototype.getInfo=function(t,r,i){var s;return x(this,void 0,void 0,function(){var o;return V(this,function(u){return this._runtime.useNavi||(o=void 0,o=this._runtime.isSupportSocket()&&this._connectType==="websocket"?Gu.join(","):Yu.join(","),this._miniConnectUrl=((s=this._options.miniCMPProxy)===null||s===void 0?void 0:s.length)?this._options.miniCMPProxy.join(","):o||"",r=[]),[2,n.prototype.getInfo.call(this,t,r,i)]})})},e.prototype._reqNavi=function(t,r,i){return x(this,void 0,void 0,function(){var s,o,u,d,l,h,a,c,p;return V(this,function(f){switch(f.label){case 0:s="getServerEndpoint",o=0,u=t.length,f.label=1;case 1:return o "+d),[4,this._runtime.httpReq({url:d,timeout:1e4,dataType:"text"})]):[3,4];case 2:if((l=f.sent()).status!==200)return l.status===403?j.error("request navi error: "+S.RC_CONN_USER_OR_PASSWD_ERROR):l.status===401&&j.error("request navi error: "+S.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+'"')),p=JSON.parse(a),c=/^https/.test(d)?"https":"http",p.protocol=c,this._runtime.useNavi||(p.server="",p.backupServer=this._miniConnectUrl,p.logSwitch=0),[2,p]}catch(m){j.error("parse navi err =>",m)}f.label=3;case 3:return o+=1,[3,1];case 4:return this._runtime.useNavi?[2,null]:[2,p={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}(Ud),Yd=function(){function n(e){this._pullQueue=[],this._isPulling=!1,this._pullTime=0,this._engine=e}return n.prototype._startPull=function(){return x(this,void 0,void 0,function(){var e,t,r,i,s,o,u;return V(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],t=e.roomId,r=e.timestamp,(i=this._pullTime)>r?(this._isPulling=!1,this._startPull(),[2]):[4,this._engine.pullRTCRoomEntry(t,i)]);case 1:return s=d.sent(),o=s.code,u=s.data,o===S.SUCCESS?(this._isPulling=!1,this._pullTime=u.syncTime||0,this._startPull()):this._startPull(),[2]}})})},n.prototype.pullEntry=function(e,t){this._pullQueue.push({roomId:e,timestamp:t}),this._startPull()},n.prototype.reset=function(){this._pullTime=0,this._isPulling=!1},n}(),Ri=function(n,e){return["send_msg",n,e].join("_")},Jd=function(){function n(e,t){this._runtime=e,this._appkey=t,this._sendMessageMap={},this._userId=""}return n.prototype.init=function(e){this._userId=e;var t=Ri(this._appkey,e);this._sendMessageMap=this._getLocalInfo(t)},n.prototype._getLocalInfo=function(e){var t=this._runtime.localStorage.getItem(e);try{return t?JSON.parse(t):{}}catch{return{}}},n.prototype.setMessage=function(e,t){this._sendMessageMap[e]=t;var r=Ri(this._appkey,this._userId),i=this._getLocalInfo(r);i[e]=t,this._runtime.localStorage.setItem(r,JSON.stringify(i))},n.prototype.getSendMessageMap=function(){return this._sendMessageMap},n.prototype.removeByUID=function(e){delete this._sendMessageMap[e]},n.prototype.removeByTimestamp=function(e){var t=Ri(this._appkey,this._userId),r=this._getLocalInfo(t);Object.keys(r).forEach(function(i){r[i] signal.messageId: "+t.messageId),this._pullMsg(t);break;case D.s_msg:this._receiveMsg(t);break;case D.s_cmd:this._receiveStateNotify(t);break;case D.s_us:this._receiveSettingNotify(t);break;case D.rtc_ntf:this._receiveRtcKv(t)}else j.error("unknown topic:",s)}},e.prototype._receiveStateNotify=function(t){var r,i=(r=this._channel)===null||r===void 0?void 0:r.codec.decodeByPBName(t.data,Or),s=i.time,o=i.type,u=i.chrmId;switch(o){case 2:this._chrmEntryHandler.pullEntry(u,s);break;case 3:this._conversationManager.startPullConversationStatus(s);break;case 4:this._chrmEntryHandler.reset(u),this._watcher.chatroom({chatroomDestroyed:t.targetId})}},e.prototype._receiveSettingNotify=function(t){var r,i=((r=this._channel)===null||r===void 0?void 0:r.codec.decodeByPBName(t.data,Zr)).version;this._userSettingManager.pullUserSettings(i)},e.prototype._receiveRtcKv=function(t){var r,i=(r=this._channel)===null||r===void 0?void 0:r.codec.decodeByPBName(t.data,eo),s=i.time,o=i.type,u=i.roomId;switch(o){case 1:this._rtcKVManager.pullEntry(u,s)}},e.prototype._receiveMessageExpansion=function(t){var r=t.content,i=r.put,s=r.del,o=r.mid;i&&this._watcher.expansion({updatedExpansion:{messageUId:o,expansion:i}}),s&&this._watcher.expansion({deletedExpansion:{messageUId:o,deletedKeys:s}})},e.prototype._receiveSyncMsg=function(t,r){var i;if(Wd.includes(t.topic)){var s=(i=this._channel)===null||i===void 0?void 0:i.codec.decodeByPBName(t.data,Ln,{currentUserId:this.currentUserId,signal:t});s=this._handleMsgProperties(s),r&&(s.sentTime=r.timestamp,s.messageUId=r.messageUId),this._pullingMsg?this._pullQueue.push((r==null?void 0:r.timestamp)||s.sentTime):(r&&this._sendMessageStore.setMessage(r.messageUId,r.timestamp),s.messageType!==He.EXPANSION_NOTIFY?(s.messageType===He.SYNC_READ_STATUS&&this._conversationManager.clearUnreadCount(s.conversationType,s.targetId,s.channelId),this._conversationManager.setConversationCacheByMessage(s,!0),this._watcher.batchMessage([s])):this._receiveMessageExpansion(s))}},e.prototype._pullMsg=function(t){if(this._channel){var r=this._channel.codec.decodeByPBName(t.data,Or),i=r.type,s=r.chrmId,o=r.time;if(j.info("s_ntf -> type: "+i+", chrmId: "+s+", time: "+o),i===2){var u=this._chrmsQueue[s];if(!u)return;u.queue.push(o),this._pullChrmMsg(s)}else this._pullQueue.push(o),this._syncMsg()}},e.prototype._startSyncInterval=function(){var t=this;this._stopSyncInterval(),this._intervalTimer=setInterval(function(){Date.now()-t._latestSyncTimestamp>=18e4&&t._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 x(this,void 0,void 0,function(){var t,r,i,s,o,u,d,l,h,a,c,p,f,m,_=this;return V(this,function(v){switch(v.label){case 0:return this._pullingMsg?[2]:this._channel?(this._pullingMsg=!0,t=this._letterbox.getOutboxTime(this.currentUserId),r=this._letterbox.getInboxTime(this.currentUserId),j.info("pullMsg -> sendboxTime: "+t+", inboxTime: "+r),i=this._channel.codec.encodeSyncMsg({sendboxTime:t,inboxTime:r}),s=new Q(D[D.pullMsg],i,this.currentUserId),[4,this._channel.send(s,kn,{connectedTime:this._channel.connectedTime,currentUserId:this.currentUserId})]):(this._pullingMsg=!1,[2]);case 1:return o=v.sent(),u=o.code,d=o.data,this._latestSyncTimestamp=Date.now(),u===S.SUCCESS&&d?(l=d.list,h=d.finished,a=d.syncTime,j.info("pullMsg success -> syncTime: "+a+", finished: "+h),c=0,p=[],l.forEach(function(R){if(R.messageDirection===nt.SEND&&(c=Math.max(R.sentTime,c),_._sendMessageStore.getSendMessageMap()[R.messageUId]))return void _._sendMessageStore.removeByUID(R.messageUId);if(R.messageType!==He.EXPANSION_NOTIFY){if(R.messageType===He.SYNC_READ_STATUS){if(R.senderUserId!==_.currentUserId)return;_._conversationManager.clearUnreadCount(R.conversationType,R.targetId,R.channelId)}var C=_._handleMsgProperties(R);_._conversationManager.setConversationCacheByMessage(C,!0),p.push(C)}else _._receiveMessageExpansion(R)}),this._watcher.batchMessage(p),this._letterbox.setInboxTime(a,this.currentUserId),this._letterbox.setOutboxTime(c,this.currentUserId),this._sendMessageStore.removeByTimestamp(c),this._pullingMsg=!1,f=this._pullQueue.filter(function(R){return R>a}),this._pullQueue.length=0,(m=this._pullQueue).push.apply(m,f),h&&!this._pullOfflineFinished&&(this._pullOfflineFinished=!0,this._watcher.pullFinished()),(!h||f.length>0)&&this._syncMsg(),[2]):(j.warn("pullMsg failed -> code:",u,", data: ",d),this._pullingMsg=!1,[2])}})})},e.prototype._receiveMsg=function(t){if(this._channel&&!this._pullingMsg)if(this._pullQueue.length>0)this._syncMsg();else{var r=this._channel.codec.decodeByPBName(t.data,Jr,{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!==He.EXPANSION_NOTIFY?r.messageType===He.SYNC_READ_STATUS&&r.senderUserId!==this.currentUserId||(this._conversationManager.setConversationCacheByMessage(r,!0),this._watcher.batchMessage([r])):this._receiveMessageExpansion(r)}},e.prototype._handleMsgProperties=function(t,r){r===void 0&&(r=!1);var i,s=t.messageType,o=t.isCounted,u=t.isPersited,d=t.isStatusMessage,l=s in To,h=s in this._customMessageType;if(i=l?To[s]:h?this._customMessageType[s]:{isCounted:!bo(o)&&o,isPersited:!bo(u)&&u},Object.assign(t,{isCounted:i.isCounted,isPersited:i.isPersited,isStatusMessage:Ju.includes(s)}),r&&(t.isStatusMessage=d),!r){var a=t.content.user;if(a){var c=a.portrait,p=a.portraitUri,f=c||p;f&&(a.portrait=a.portraitUri=f)}}return t},e.prototype.getHistoryMessage=function(t,r,i,s,o,u){return u===void 0&&(u=""),x(this,void 0,void 0,function(){var d,l,h,a,c,p,f,m,_;return V(this,function(v){switch(v.label){case 0:return l=(d=this).currentUserId,h=d._channel,a=wd[t]||ac,c=s===1&&i===0,h?(p=h.codec.encodeGetHistoryMsg(r,{timestamp:i,count:c?2:s,order:o,channelId:u}),[4,h.send(new Q(a,p,l),Un,{currentUserId:l,connectedTime:h.connectedTime,conversation:{targetId:r}})]):[3,2];case 1:return f=v.sent(),(m=f.code)!==S.SUCCESS?[2,{code:m}]:(_=f.data,c&&_.list.length===2&&(_.hasMore=!0,o===0?_.list.shift():_.list.pop()),[2,{code:m,data:{list:_.list,hasMore:_.hasMore}}]);case 2:return[2,{code:S.RC_NET_CHANNEL_INVALID}]}})})},e.prototype.reportSDKInfo=function(t){var r=this.currentUserId,i=this._channel;if(i){j.debug("reportSDKInfo ->",t);var s=i.codec.encodeReportSDKInfo(JSON.stringify(t)),o=new Q(D[D.reportsdk],s,r);i.send(o).then(function(u){var d=u.code;d!==S.SUCCESS&&j.warn("reportSDKInfo failed -> code: "+d)})}},e.prototype.deleteRemoteMessage=function(t,r,i,s){return x(this,void 0,void 0,function(){var o,u,d,l,h,a,c;return V(this,function(p){switch(p.label){case 0:return u=(o=this).currentUserId,(d=o._channel)?(l=d.codec.encodeDeleteMessages(t,r,i,s),h=new Q(gd,l,u),[4,d.send(h)]):[3,2];case 1:return a=p.sent(),c=a.code,S.SUCCESS,[2,c];case 2:return[2,S.RC_NET_CHANNEL_INVALID]}})})},e.prototype.deleteRemoteMessageByTimestamp=function(t,r,i,s){return x(this,void 0,void 0,function(){var o,u,d,l,h,a,c,p;return V(this,function(f){switch(f.label){case 0:return u=(o=this).currentUserId,(d=o._channel)?(l=d.codec.encodeClearMessages(r,i,s),h=Ad[t],a=new Q(h,l,u),[4,d.send(a)]):[3,2];case 1:return c=f.sent(),p=c.code,S.SUCCESS,[2,p];case 2:return[2,S.RC_NET_CHANNEL_INVALID]}})})},e.prototype.getConversationList=function(t,r,i,s,o){return t===void 0&&(t=300),x(this,void 0,void 0,function(){var u,d,l,h,a,c,p,f,m=this;return V(this,function(_){switch(_.label){case 0:return d=(u=this).currentUserId,l=u._channel,r=r||z.PRIVATE,l?(h=l.codec.encodeOldConversationList({count:t,type:r,startTime:i,order:s}),a=new Q(Bo,h,d),[4,l.send(a,Dn,{currentUserId:d,connectedTime:l.connectedTime,afterDecode:function(v){var R=v.conversationType,C=v.targetId,A=v.channelId,M=m._conversationManager.get(R,C,A);return Object.assign(v,M),v}})]):[3,2];case 1:return c=_.sent(),p=c.code,f=c.data,p!==S.SUCCESS?[2,{code:p}]:[2,{code:p,data:f}];case 2:return[2,{code:S.RC_NET_CHANNEL_INVALID}]}})})},e.prototype.removeConversation=function(t,r,i){return x(this,void 0,void 0,function(){var s,o,u,d,l;return V(this,function(h){switch(h.label){case 0:return(s=this._channel)?(o=s.codec.encodeRemoveOldConversationList({conversationType:t,channelId:i,targetId:r}),u=new Q(Td,o,r),[4,s.send(u)]):[3,2];case 1:return d=h.sent(),j.info("RemoveConversation =>",d),l=d.code,S.SUCCESS,[2,l];case 2:return[2,S.RC_NET_CHANNEL_INVALID]}})})},e.prototype.getConversation=function(t,r,i){return x(this,void 0,void 0,function(){var s,o,u,d,l,h;return V(this,function(a){switch(a.label){case 0:return(s=this._conversationManager.get(t,r,i))?[4,this.getHistoryMessage(t,r,0,1,0)]:[2,{code:S.CONVER_GET_ERROR}];case 1:return o=a.sent(),u=o.code,d=o.data,u!==S.SUCCESS?[2,{code:S.CONVER_GET_ERROR}]:(l=(d==null?void 0:d.list[0])||null,h={conversationType:t,targetId:r,channelId:i,unreadMessageCount:s.unreadMessageCount||0,latestMessage:l,notificationStatus:s.notificationStatus||Kt.CLOSE,isTop:s.isTop||!1,lastUnreadTime:s.lastUnreadTime||0,unreadMentionedCount:s.unreadMentionedCount||0},[2,{code:S.SUCCESS,data:h}])}})})},e.prototype.getAllConversationUnreadCount=function(t,r,i){var s=this._conversationManager.getAllUnreadCount(t,r,i);return Promise.resolve({code:S.SUCCESS,data:s})},e.prototype.getConversationUnreadCount=function(t,r,i){var s=this._conversationManager.getUnreadCount(t,r,i);return Promise.resolve({code:S.SUCCESS,data:s})},e.prototype.clearConversationUnreadCount=function(t,r,i){return this._conversationManager.clearUnreadCount(t,r,i,!1),Promise.resolve(S.SUCCESS)},e.prototype.clearAllUnreadCount=function(){return this._conversationManager.clearAllUnreadCount(),Promise.resolve(S.SUCCESS)},e.prototype.getFirstUnreadMessage=function(t,r){throw new Error("Method not implemented.")},e.prototype.saveConversationMessageDraft=function(t,r,i,s){return this._conversationManager.setDraft(t,r,i,s),Promise.resolve(S.SUCCESS)},e.prototype.getConversationMessageDraft=function(t,r,i){var s=this._conversationManager.getDraft(t,r,i);return Promise.resolve({code:S.SUCCESS,data:s})},e.prototype.clearConversationMessageDraft=function(t,r,i){return this._conversationManager.clearDraft(t,r,i),Promise.resolve(S.SUCCESS)},e.prototype.pullConversationStatus=function(t){return x(this,void 0,void 0,function(){var r,i,s,o,u,d,l,h;return V(this,function(a){switch(a.label){case 0:return i=(r=this)._channel,s=r.currentUserId,i?(o=i.codec.encodeGetConversationStatus(t),u=new Q(D[D.pullSeAtts],o,s),[4,i.send(u,ei)]):[3,2];case 1:return d=a.sent(),l=d.code,h=d.data,l!==S.SUCCESS?[2,{code:l}]:[2,{code:l,data:h}];case 2:return[2,{code:S.RC_NET_CHANNEL_INVALID}]}})})},e.prototype.batchSetConversationStatus=function(t){return x(this,void 0,void 0,function(){var r,i,s,o,u,d,l,h,a,c=this;return V(this,function(p){switch(p.label){case 0:return i=(r=this).currentUserId,(s=r._channel)?(o=s.codec.encodeSetConversationStatus(t),u=new Q(Sd,o,i),[4,s.send(u,Ws)]):[3,2];case 1:return d=p.sent(),l=d.code,h=d.data,l===S.SUCCESS?(a=h,t.forEach(function(f){c._conversationManager.addStatus(Re(Re({},f),{updatedTime:a.version}),!0)}),[2,l]):[2,l];case 2:return[2,S.RC_NET_CHANNEL_INVALID]}})})},e.prototype._joinChrm=function(t,r,i){return x(this,void 0,void 0,function(){var s,o,u,d,l,h,a;return V(this,function(c){switch(c.label){case 0:return(s=this._channel)?(o=s.codec.encodeJoinOrQuitChatRoom(),u=new Q(i?_d:md,o,t),[4,s.send(u,Ns)]):[2,S.RC_NET_CHANNEL_INVALID];case 1:return d=c.sent(),l=d.code,h=d.data,l===S.SUCCESS&&(a=h.joinTime,this._chrmsQueue[t]||(this._chrmsQueue[t]={pulling:!1,queue:[],timestamp:0}),this._pullChrmMsg(t,r,a),this._naviInfo.kvStorage&&this._chrmEntryHandler.pullEntry(t,0),this._joinedChrmManager.set(t,r)),[2,l]}})})},e.prototype._rejoinChrm=function(){return x(this,void 0,void 0,function(){var t,r,i,s,o,u;return V(this,function(d){switch(d.label){case 0:for(i in t=this._joinedChrmManager.get(),r=[],t)r.push(i);s=0,d.label=1;case 1:return sf}),_=[],p.forEach(function(R){R.sentTime0)&&this._pullChrmMsg(t),[2]):(j.warn("pull chatroom msg failed, code:",a,", data:",c),[2])}})})},e.prototype.joinChatroom=function(t,r){return x(this,void 0,void 0,function(){return V(this,function(i){return[2,this._joinChrm(t,r,!1)]})})},e.prototype.joinExistChatroom=function(t,r){return x(this,void 0,void 0,function(){return V(this,function(i){return[2,this._joinChrm(t,r,!0)]})})},e.prototype.quitChatroom=function(t){return x(this,void 0,void 0,function(){var r,i,s,o,u;return V(this,function(d){switch(d.label){case 0:return(r=this._channel)?(i=r.codec.encodeJoinOrQuitChatRoom(),s=new Q(vd,i,t),[4,r.send(s)]):[2,S.RC_NET_CHANNEL_INVALID];case 1:return o=d.sent(),(u=o.code)===S.SUCCESS&&(delete this._chrmsQueue[t],this._chrmEntryHandler.reset(t),this._joinedChrmManager.remove(t)),[2,u]}})})},e.prototype.getChatroomInfo=function(t,r,i){return x(this,void 0,void 0,function(){var s,o,u,d,l,h;return V(this,function(a){switch(a.label){case 0:return(s=this._channel)?(o=s.codec.encodeGetChatRoomInfo(r,i),u=new Q(D[D.queryChrmI],o,t),[4,s.send(u,Wr)]):[2,{code:S.RC_NET_CHANNEL_INVALID}];case 1:return d=a.sent(),l=d.code,h=d.data,l!==S.SUCCESS?[2,{code:l}]:[2,{code:l,data:h}]}})})},e.prototype.getChatroomHistoryMessages=function(t,r,i,s){return x(this,void 0,void 0,function(){var o,u,d,l,h,a;return V(this,function(c){switch(c.label){case 0:return(o=this._channel)?(u=o.codec.encodeGetHistoryMsg(t,{timestamp:r,count:i,order:s}),d=new Q(cc,u,t),[4,o.send(d,Un,{conversation:{targetId:t}})]):[2,{code:S.RC_NET_CHANNEL_INVALID}];case 1:return l=c.sent(),h=l.code,a=l.data,h!==S.SUCCESS?[2,{code:h}]:[2,{code:h,data:{list:a.list,hasMore:a.hasMore}}]}})})},e.prototype._modifyChatroomKV=function(t,r){return x(this,void 0,void 0,function(){var i,s,o,u,d,l,h,a;return V(this,function(c){switch(c.label){case 0:return s=(i=this)._channel,o=i.currentUserId,s?(u=s.codec.encodeModifyChatRoomKV(t,r,o),d=r.type===We.UPDATE?Rd:Ed,l=new Q(d,u,t),[4,s.send(l)]):[2,S.RC_NET_CHANNEL_INVALID];case 1:return h=c.sent(),(a=h.code)===S.SUCCESS?(this._chrmEntryHandler.setLocal(t,{kvEntries:[r],syncTime:new Date().getTime()},o),[2,a]):[2,a]}})})},e.prototype._modifyChatroomKVS=function(t,r){return x(this,void 0,void 0,function(){var i,s,o,u,d,l,h,a,c,p,f,m;return V(this,function(_){switch(_.label){case 0:return s=(i=this)._channel,o=i.currentUserId,s?(u=s.codec.encodeModifyChatRoomKVS(t,r,o),d=r.type===We.UPDATE?Cd:yd,l=new Q(d,u,t),[4,s.send(l,qs)]):[2,{code:S.RC_NET_CHANNEL_INVALID}];case 1:return h=_.sent(),a=h.code,[S.SUCCESS,S.CHATROOM_KV_STORE_NOT_ALL_SUCCESS].indexOf(a)!==-1&&(p=[],delete(f=Object.assign({},r)).entries,r.entries.forEach(function(v){p.push(Object.assign({},v,f))}),a===S.CHATROOM_KV_STORE_NOT_ALL_SUCCESS&&(m=h.data,j.warn("\u8BBE\u7F6E\u5931\u8D25\u7684\u5C5E\u6027\uFF1A",m.errorKeys),c=m.errorKeys,m&&Array.isArray(m.errorKeys)&&m.errorKeys.forEach(function(v){var R=p.findIndex(function(C){return v.key===C.key});R!==-1&&p.splice(R,1)})),j.warn("\u8BBE\u7F6E\u6210\u529F\u7684\u5C5E\u6027\uFF1A",p),this._chrmEntryHandler.setLocal(t,{kvEntries:p,syncTime:new Date().getTime()},o)),[2,{code:a,data:c}]}})})},e.prototype.setChatroomEntry=function(t,r){return x(this,void 0,void 0,function(){return V(this,function(i){return r.type=We.UPDATE,r.userId=r.userId||this.currentUserId,[2,this._modifyChatroomKV(t,r)]})})},e.prototype.setChatroomEntries=function(t,r){return x(this,void 0,void 0,function(){return V(this,function(i){return r.type=We.UPDATE,r.userId=r.userId||this.currentUserId,[2,this._modifyChatroomKVS(t,r)]})})},e.prototype.forceSetChatroomEntry=function(t,r){return x(this,void 0,void 0,function(){return V(this,function(i){return r.type=We.UPDATE,r.isOverwrite=!0,r.userId=r.userId||this.currentUserId,[2,this._modifyChatroomKV(t,r)]})})},e.prototype.removeChatroomEntry=function(t,r){return x(this,void 0,void 0,function(){return V(this,function(i){return r.type=We.DELETE,r.userId=r.userId||this.currentUserId,[2,this._modifyChatroomKV(t,r)]})})},e.prototype.removeChatroomEntries=function(t,r){return x(this,void 0,void 0,function(){return V(this,function(i){return r.type=We.DELETE,r.userId=r.userId||this.currentUserId,[2,this._modifyChatroomKVS(t,r)]})})},e.prototype.forceRemoveChatroomEntry=function(t,r){return x(this,void 0,void 0,function(){return V(this,function(i){return r.type=We.DELETE,r.isOverwrite=!0,r.userId=r.userId||this.currentUserId,[2,this._modifyChatroomKV(t,r)]})})},e.prototype.getChatroomEntry=function(t,r){return x(this,void 0,void 0,function(){var i,s,o,u,d,l,h;return V(this,function(a){switch(a.label){case 0:return(i=this._chrmEntryHandler.getValue(t,r))?[2,Promise.resolve({code:S.SUCCESS,data:i})]:[3,1];case 1:return(s=this._channel)?(o=s.codec.encodePullChatRoomKV(0),u=new Q(D[D.pullKV],o,t),[4,s.send(u,Wt)]):[2,Promise.reject({code:S.RC_NET_CHANNEL_INVALID})];case 2:return d=a.sent(),(l=d.data||{})&&l.kvEntries&&l.kvEntries.length&&(h=l.kvEntries.find(function(c){return c.key===r}))!==void 0?[2,Promise.resolve({code:S.SUCCESS,data:h==null?void 0:h.value})]:[2,Promise.resolve({code:S.CHATROOM_KEY_NOT_EXIST})]}})})},e.prototype.getAllChatroomEntry=function(t){return x(this,void 0,void 0,function(){var r,i,s,o,u,d,l;return V(this,function(h){switch(h.label){case 0:return(r=this._chrmEntryHandler.getAll(t))&&Object.keys(r).length?[2,Promise.resolve({code:S.SUCCESS,data:r})]:[3,1];case 1:return(i=this._channel)?(s={},o=i.codec.encodePullChatRoomKV(0),u=new Q(D[D.pullKV],o,t),[4,i.send(u,Wt)]):[2,Promise.reject({code:S.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&&(s[a.key]=a.value||"")}),[2,Promise.resolve({code:S.SUCCESS,data:s})]}})})},e.prototype.pullChatroomEntry=function(t,r){return x(this,void 0,void 0,function(){var i,s,o,u,d,l,h,a,c,p;return V(this,function(f){switch(f.label){case 0:return s=(i=this)._channel,o=i.currentUserId,s?(u=s.codec.encodePullChatRoomKV(r),d=new Q(D[D.pullKV],u,t),[4,s.send(d,Wt)]):[2,{code:S.RC_NET_CHANNEL_INVALID}];case 1:return l=f.sent(),h=l.code,a=l.data,h===S.SUCCESS?(j.info("Pull success ChrmKV, "+JSON.stringify(l)),this._chrmEntryHandler.setLocal(t,a,o),j.info("Save into cache success!"),c=a.kvEntries,p=[],c.length>0&&(c.forEach(function(m){var _=m.key,v=m.value,R=m.type,C=m.timestamp;p.push({key:_,value:v,type:R,timestamp:C,chatroomId:t})}),this._watcher.chatroom({updatedEntries:p})),[2,{code:h,data:a}]):[2,{code:h}]}})})},e.prototype.sendMessage=function(t,r,i){return x(this,void 0,void 0,function(){var s,o,u,d,l,h,a,c,p,f;return V(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),s=!![z.PRIVATE,z.GROUP].includes(t)&&i.isStatusMessage,o=s?function(_){var v;return(v={},v[z.PRIVATE]=D.ppMsgS,v[z.GROUP]=D.pgMsgS,v)[_]}(t):function(_){var v;return(v={},v[z.PRIVATE]=D.ppMsgP,v[z.GROUP]=D.pgMsgP,v[z.CHATROOM]=D.chatMsg,v[z.CUSTOMER_SERVICE]=D.pcMsgP,v[z.RTC_ROOM]=D.prMsgS,v)[_]}(t)||D.ppMsgP,s&&(i.isPersited=!1,i.isCounted=!1),u=this._channel.codec.encodeUpMsg({conversationType:t,targetId:r},i),(d=new fn(D[o],u,r)).setHeaderQos(vt.AT_LEAST_ONCE),s?(this._channel.sendOnly(d),[2,{code:S.SUCCESS,data:Ei(t,r,Re({},i),"",0,this.currentUserId)}]):(l=Date.now()-this._localConnectedTime+this._connectedTime,h=Ei(t,r,Re({},i),"",l,this.currentUserId),[4,this._channel.send(d)])):[2,{code:S.RC_NET_CHANNEL_INVALID}];case 1:return a=m.sent(),c=a.code,p=a.data,c!==S.SUCCESS?[2,{code:c,data:h}]:(f=p,this._sendMessageStore.setMessage(f.messageUId,f.timestamp),h.sentTime=f.timestamp,h.messageUId=f.messageUId,this._conversationManager.setConversationCacheByMessage(h,!0),[2,{code:S.SUCCESS,data:h}])}})})},e.prototype.recallMsg=function(t,r,i,s,o){var u;return x(this,void 0,void 0,function(){var d,l,h,a,c,p,f,m,_,v;return V(this,function(R){switch(R.label){case 0:return this._channel?(d=o.user,l={content:{conversationType:t,targetId:r,messageUId:i,sentTime:s,user:d},messageType:"RC:RcCmd",disableNotification:o==null?void 0:o.disableNotification,pushConfig:o==null?void 0:o.pushConfig,pushContent:((u=o.pushConfig)===null||u===void 0?void 0:u.pushContent)||o.pushContent||"",channelId:o.channelId},h=D[D.recallMsg],a=this._channel.codec.encodeUpMsg({conversationType:t,targetId:r},l),(c=new fn(h,a,this.currentUserId)).setHeaderQos(vt.AT_LEAST_ONCE),[4,this._channel.send(c)]):[2,{code:S.RC_NET_CHANNEL_INVALID}];case 1:return p=R.sent(),f=p.code,m=p.data,f!==S.SUCCESS?[2,{code:f}]:(_=m,this._sendMessageStore.setMessage(_.messageUId,_.timestamp),v=Ei(t,r,Re(Re({},l),{isPersited:!0}),_.messageUId,_.timestamp,this.currentUserId),this._conversationManager.setConversationCacheByMessage(v,!0),[2,{code:S.SUCCESS,data:v}])}})})},e.prototype.sendReadReceiptMessage=function(t,r,i){return x(this,void 0,void 0,function(){var s,o;return V(this,function(u){switch(u.label){case 0:return this._channel?(s=this._channel.codec.encodeReadReceipt(r,i),o=new Q(D[D.rrMsg],s,t),[4,this._channel.send(o)]):[2,{code:S.RC_NET_CHANNEL_INVALID}];case 1:return[2,u.sent()]}})})},e.prototype.getMessageReader=function(t,r,i){return x(this,void 0,void 0,function(){var s,o;return V(this,function(u){switch(u.label){case 0:return this._channel?(s=this._channel.codec.encodeMessageReader(r,i),o=new Q(D[D.rrList],s,t),[4,this._channel.send(o,ti)]):[2,{code:S.RC_NET_CHANNEL_INVALID}];case 1:return[2,u.sent()]}})})},e.prototype.pullUserSettings=function(t){return x(this,void 0,void 0,function(){var r,i;return V(this,function(s){return this._channel?(r=this._channel.codec.encodePullUserSetting(t),i=new Q(D[D.pullUS],r,this.currentUserId),[2,this._channel.send(i,Xr)]):[2,{code:S.RC_NET_CHANNEL_INVALID}]})})},e.prototype.getFileToken=function(t,r,i,s){return x(this,void 0,void 0,function(){var o,u,d,l,h,a;return V(this,function(c){switch(c.label){case 0:return this._channel?(o=s&&s!=="uploads"?r||"":td(t,r),u=this._channel.codec.encodeGetFileToken(t,o,i||"",s||""),d=new Q(D[D.qnTkn],u,this.currentUserId),[4,this._channel.send(d,Vs)]):[2,{code:S.RC_NET_CHANNEL_INVALID}];case 1:return l=c.sent(),h=l.code,a=l.data,a=Object.assign(a,{fileName:o}),h===S.SUCCESS?[2,{code:h,data:a}]:[2,{code:h}]}})})},e.prototype.getFileUrl=function(t,r,i,s){return x(this,void 0,void 0,function(){var o,u,d,l,h,a,c,p,f;return V(this,function(m){switch(m.label){case 0:return this._channel?(o="",u="",d="",r===Ge.QINIU?(u=Bs,d=Hs):(u=Fs,d=$s),o=r===Ge.QINIU?D[D.qnUrl]:r===Ge.AWS?D[D.s3Url]:r===Ge.STC?D[D.stcUrl]:D[D.aliUrl],l=this._channel.codec.encodeGetFileUrl(u,t,i,s),h=new Q(o,l,this.currentUserId),[4,this._channel.send(h,d)]):[2,{code:S.RC_NET_CHANNEL_INVALID}];case 1:return a=m.sent(),c=a.code,p=a.data,f=p,c===S.SUCCESS?[2,{code:c,data:f}]:[2,{code:c}]}})})},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(t,r,i,s){this._customMessageType[t]={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(t){return x(this,void 0,void 0,function(){var r,i,s,o,u,d,l;return V(this,function(h){switch(h.label){case 0:return this._channel?(r=this._userSettingManager.getVersion(),i=this._channel.codec.encodeCreateTag([t],r),s=new Q(D[D.addSeTag],i,this.currentUserId),[4,this._channel.send(s,zt)]):[2,{code:S.RC_NET_CHANNEL_INVALID}];case 1:return o=h.sent(),u=o.code,d=o.data,u!==S.SUCCESS?[2,{code:u}]:(l=d.version,this._userSettingManager.addTag([Re(Re({},t),{createdTime:l})],l),[2,{code:S.SUCCESS,data:d}])}})})},e.prototype.removeTag=function(t){return x(this,void 0,void 0,function(){var r,i,s,o,u,d,l;return V(this,function(h){switch(h.label){case 0:return this._channel?(r=this._userSettingManager.getVersion(),i=this._channel.codec.encodeRemoveTag([t],r),s=new Q(D[D.delSeTag],i,this.currentUserId),[4,this._channel.send(s,zt)]):[2,{code:S.RC_NET_CHANNEL_INVALID}];case 1:return o=h.sent(),u=o.code,d=o.data,u!==S.SUCCESS?[2,{code:u}]:(l=d.version,this._userSettingManager.deleteTag([t],l),[2,{code:S.SUCCESS}])}})})},e.prototype.updateTag=function(t){return x(this,void 0,void 0,function(){var r,i,s,o,u,d,l;return V(this,function(h){switch(h.label){case 0:return this._channel?(r=this._userSettingManager.getVersion(),i=this._channel.codec.encodeCreateTag([t],r),s=new Q(D[D.addSeTag],i,this.currentUserId),[4,this._channel.send(s,zt)]):[2,{code:S.RC_NET_CHANNEL_INVALID}];case 1:return o=h.sent(),u=o.code,d=o.data,u!==S.SUCCESS?[2,{code:u}]:(l=d.version,this._userSettingManager.addTag([t],l),[2,{code:S.SUCCESS,data:d}])}})})},e.prototype.getTagList=function(){return x(this,void 0,void 0,function(){var t,r;return V(this,function(i){return t=this._userSettingManager.getTags(),r=this._conversationManager.getConversationListForTag(),t.forEach(function(s){s.conversationCount=r[s.tagId]?r[s.tagId].length:0}),[2,{code:S.SUCCESS,data:t}]})})},e.prototype.addTagForConversations=function(t,r){return x(this,void 0,void 0,function(){var i,s,o,u,d=this;return V(this,function(l){switch(l.label){case 0:return this._channel?this._userSettingManager.getTagById(t)?(i=this._channel.codec.encodeUpdateConversationTag([{tagId:t}],r),s=new Q(D[D.addTag],i,this.currentUserId),[4,this._channel.send(s)]):[2,{code:S.TAG_NOT_EXIST}]:[2,{code:S.RC_NET_CHANNEL_INVALID}];case 1:return(o=l.sent().code)!==S.SUCCESS?[2,{code:o}]:((u={})[t]={},r.forEach(function(h){d._conversationManager.addTagStatus(h.conversationType,h.targetId,u,h.channelId)}),[2,{code:S.SUCCESS}])}})})},e.prototype.removeTagForConversations=function(t,r){return x(this,void 0,void 0,function(){var i,s,o,u=this;return V(this,function(d){switch(d.label){case 0:return this._channel?(i=this._channel.codec.encodeUpdateConversationTag([{tagId:t}],r),s=new Q(D[D.delTag],i,this.currentUserId),[4,this._channel.send(s)]):[2,{code:S.RC_NET_CHANNEL_INVALID}];case 1:return(o=d.sent().code)!==S.SUCCESS?[2,{code:o}]:(r.forEach(function(l){u._conversationManager.deleteTagStatus(l.conversationType,l.targetId,[t],l.channelId)}),[2,{code:S.SUCCESS}])}})})},e.prototype.removeTagsForConversation=function(t,r){return x(this,void 0,void 0,function(){var i,s,o,u,d,l,h;return V(this,function(a){switch(a.label){case 0:return this._channel?(i=t.conversationType,s=t.targetId,o=t.channelId,u=r.map(function(c){return{tagId:c}}),d=this._channel.codec.encodeUpdateConversationTag(u,[t]),l=new Q(D[D.delTag],d,this.currentUserId),[4,this._channel.send(l)]):[2,{code:S.RC_NET_CHANNEL_INVALID}];case 1:return(h=a.sent().code)!==S.SUCCESS?[2,{code:h}]:(this._conversationManager.deleteTagStatus(i,s,r,o),[2,{code:S.SUCCESS}])}})})},e.prototype.getConversationListByTag=function(t,r,i){return x(this,void 0,void 0,function(){var s,o,u,d,l,h,a,c,p;return V(this,function(f){switch(f.label){case 0:return o=(s=this).currentUserId,(u=s._channel)?(d=u.codec.encodeOldConversationList({count:i,type:z.PRIVATE,startTime:r}),l=new Q(Bo,d,o),[4,u.send(l,Dn,{currentUserId:o,connectedTime:u.connectedTime})]):[2,{code:S.RC_NET_CHANNEL_INVALID}];case 1:return h=f.sent(),a=h.code,c=h.data,p=this._conversationHasTagFilter(t,c),j.info("GetConversationListByTag",p),a!==S.SUCCESS?[2,{code:a}]:[2,{code:a,data:p}]}})})},e.prototype._conversationHasTagFilter=function(t,r){var i=this,s=[],o=[];function u(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,c=i._conversationManager.get(l,h,a),p=c.hasMentioned,f=c.mentionedInfo,m=c.lastUnreadTime,_=c.notificationStatus,v=c.isTop,R=c.tags,C=c.unreadMessageCount,A=R&&R[t];if(A){var M=Re(Re({},d),{hasMentioned:p,mentionedInfo:f,lastUnreadTime:m,notificationStatus:_,isTop:v,unreadMessageCount:C});A.isTop?s.push(Re(Re({},M),{isTopInTag:!0})):o.push(Re(Re({},M),{isTopInTag:!1}))}}),Ut(Ut([],s.sort(u)),o.sort(u))},e.prototype.getUnreadCountByTag=function(t,r){return x(this,void 0,void 0,function(){var i;return V(this,function(s){return this._channel?(i=this._conversationManager.getUnreadCountByTag(t,r),[2,{code:S.SUCCESS,data:i}]):[2,{code:S.RC_NET_CHANNEL_INVALID}]})})},e.prototype.setConversationStatusInTag=function(t,r,i){return x(this,void 0,void 0,function(){var s,o,u,d,l,h,a,c,p,f;return V(this,function(m){switch(m.label){case 0:return this._channel?(s=r.targetId,o=r.conversationType,u=r.channelId,d=i.isTop,l=[{tagId:t,isTop:d}],(h=this._conversationManager.get(o,s,u)).tags&&Object.hasOwnProperty.call(h.tags,t)?(a=this._channel.codec.encodeUpdateConversationTag(l,[r]),c=new Q(D[D.addTag],a,this.currentUserId),[4,this._channel.send(c)]):[2,{code:S.NO_TAG_IN_CONVER}]):[2,{code:S.RC_NET_CHANNEL_INVALID}];case 1:return(p=m.sent().code)!==S.SUCCESS?[2,{code:p}]:((f={})[t]={},d&&(f[t].isTop=!0),this._conversationManager.addTagStatus(o,s,f,u),[2,{code:S.SUCCESS}])}})})},e.prototype.getTagsForConversation=function(t){var r;return x(this,void 0,void 0,function(){var i,s,o,u;return V(this,function(d){if(!this._channel)return[2,{code:S.RC_NET_CHANNEL_INVALID}];if(i=this._conversationManager.get(t.conversationType,t.targetId,t.channelId),s=this._userSettingManager.getTagsInfo(),o=[],i.tags)for(u in i.tags)o.push({tagId:u,tagName:(r=s[u])===null||r===void 0?void 0:r.tagName});return[2,{code:S.SUCCESS,data:o}]})})},e.prototype.getBlockConversationList=function(){var t=this._conversationManager.getBlockConversationList();return Promise.resolve({code:S.SUCCESS,data:t})},e.prototype.getTopConversationList=function(){var t=this._conversationManager.getTopConversationList();return Promise.resolve({code:S.SUCCESS,data:t})},e.prototype.getUnreadMentionedCount=function(t){var r=this._conversationManager.getUnreadMentionedCount(t.channelId,t.conversationType,t.targetId);return Promise.resolve({code:S.SUCCESS,data:r})},e.prototype.getAllUnreadMentionedCount=function(){var t=this._conversationManager.getAllUnreadMentionedCount();return Promise.resolve({code:S.SUCCESS,data:t})},e.prototype.joinRTCRoom=function(t,r,i,s){return x(this,void 0,void 0,function(){var o,u;return V(this,function(d){return this._channel?(o=this._channel.codec.encodeJoinRTCRoom(r,i,s),u=new Q(D[D.rtcRJoin_data],o,t),[2,this._channel.send(u,kt)]):[2,{code:S.RC_NET_CHANNEL_INVALID}]})})},e.prototype.quitRTCRoom=function(t){return x(this,void 0,void 0,function(){var r,i;return V(this,function(s){switch(s.label){case 0:return this._channel?(r=this._channel.codec.encodeQuitRTCRoom(),i=new Q(D[D.rtcRExit],r,t),[4,this._channel.send(i)]):[2,S.RC_NET_CHANNEL_INVALID];case 1:return[2,s.sent().code]}})})},e.prototype.rtcPing=function(t,r,i){return x(this,void 0,void 0,function(){var s,o;return V(this,function(u){switch(u.label){case 0:return this._channel?(s=this._channel.codec.encodeJoinRTCRoom(r,i),o=new Q(D[D.rtcPing],s,t),[4,this._channel.send(o)]):[2,S.RC_NET_CHANNEL_INVALID];case 1:return[2,u.sent().code]}})})},e.prototype.getRTCRoomInfo=function(t){return x(this,void 0,void 0,function(){var r,i;return V(this,function(s){return this._channel?(r=this._channel.codec.encodeGetRTCRoomInfo(),i=new Q(D[D.rtcRInfo],r,t),[2,this._channel.send(i,Xa)]):[2,{code:S.RC_NET_CHANNEL_INVALID}]})})},e.prototype.getRTCUserInfoList=function(t){return x(this,void 0,void 0,function(){var r,i,s,o,u;return V(this,function(d){switch(d.label){case 0:return this._channel?(r=this._channel.codec.encodeGetRTCRoomInfo(),i=new Q(D[D.rtcUData],r,t),[4,this._channel.send(i,kt)]):[2,{code:S.RC_NET_CHANNEL_INVALID}];case 1:return s=d.sent(),o=s.code,u=s.data,[2,{code:o,data:u&&{users:u.users}}]}})})},e.prototype.setRTCUserInfo=function(t,r,i){return x(this,void 0,void 0,function(){var s,o;return V(this,function(u){switch(u.label){case 0:return this._channel?(s=this._channel.codec.encodeSetRTCUserInfo(r,i),o=new Q(D[D.rtcUPut],s,t),[4,this._channel.send(o)]):[2,S.RC_NET_CHANNEL_INVALID];case 1:return[2,u.sent().code]}})})},e.prototype.removeRTCUserInfo=function(t,r){return x(this,void 0,void 0,function(){var i,s;return V(this,function(o){switch(o.label){case 0:return this._channel?(i=this._channel.codec.encodeRemoveRTCUserInfo(r),s=new fn(D[D.rtcUDel],i,t),[4,this._channel.send(s)]):[2,S.RC_NET_CHANNEL_INVALID];case 1:return[2,o.sent().code]}})})},e.prototype.setRTCData=function(t,r,i,s,o,u){return x(this,void 0,void 0,function(){var d,l;return V(this,function(h){switch(h.label){case 0:return this._channel?(d=this._channel.codec.encodeSetRTCData(r,i,s,o,u),l=new fn(D[D.rtcSetData],d,t),[4,this._channel.send(l)]):[2,S.RC_NET_CHANNEL_INVALID];case 1:return[2,h.sent().code]}})})},e.prototype.setRTCTotalRes=function(t,r,i,s,o){return x(this,void 0,void 0,function(){var u,d;return V(this,function(l){switch(l.label){case 0:return this._channel?(u=this._channel.codec.encodeUserSetRTCData(r,i,s,o),d=new Q(D[D.userSetData],u,t),[4,this._channel.send(d)]):[2,S.RC_NET_CHANNEL_INVALID];case 1:return[2,l.sent().code]}})})},e.prototype.setRTCCDNUris=function(t,r,i){return x(this,void 0,void 0,function(){var s,o;return V(this,function(u){switch(u.label){case 0:return this._channel?(s=this._channel.codec.encodeUserSetRTCCDNUris(r,i),o=new Q(D[D.userSetData],s,t),[4,this._channel.send(o)]):[2,S.RC_NET_CHANNEL_INVALID];case 1:return[2,u.sent().code]}})})},e.prototype.getRTCData=function(t,r,i,s){if(!this._channel)return Promise.resolve({code:S.RC_NET_CHANNEL_INVALID});var o=this._channel.codec.encodeGetRTCData(r,i,s),u=new Q(D[D.rtcQryData],o,t);return this._channel.send(u,Qr)},e.prototype.removeRTCData=function(t,r,i,s,o){return x(this,void 0,void 0,function(){var u,d;return V(this,function(l){switch(l.label){case 0:return this._channel?(u=this._channel.codec.encodeRemoveRTCData(r,i,s,o),d=new fn(D[D.rtcDelData],u,t),[4,this._channel.send(d)]):[2,S.RC_NET_CHANNEL_INVALID];case 1:return[2,l.sent().code]}})})},e.prototype.setRTCOutData=function(t,r,i,s){throw new Error("JSEngine's method not implemented.")},e.prototype.getRTCOutData=function(t,r){throw new Error("JSEngine's method not implemented.")},e.prototype.getRTCToken=function(t,r,i){return x(this,void 0,void 0,function(){var s,o;return V(this,function(u){return this._channel?(s=this._channel.codec.encodeJoinRTCRoom(r,i),o=new Q(D[D.rtcToken],s,t),[2,this._channel.send(o,zr)]):[2,{code:S.RC_NET_CHANNEL_INVALID}]})})},e.prototype.setRTCState=function(t,r){return x(this,void 0,void 0,function(){var i,s;return V(this,function(o){switch(o.label){case 0:return this._channel?(i=this._channel.codec.encodeSetRTCState(r),s=new Q(D[D.rtcUserState],i,t),[4,this._channel.send(s)]):[2,S.RC_NET_CHANNEL_INVALID];case 1:return[2,o.sent().code]}})})},e.prototype.getRTCUserInfo=function(t){return x(this,void 0,void 0,function(){return V(this,function(r){throw new Error("Method not implemented.")})})},e.prototype.getRTCUserList=function(t){if(!this._channel)return Promise.resolve({code:S.RC_NET_CHANNEL_INVALID});var r=this._channel.codec.encodeGetRTCRoomInfo(),i=new Q(D[D.rtcUList],r,t);return this._channel.send(i,kt)},e.prototype.joinLivingRoomAsAudience=function(t,r,i){return r===void 0&&(r=je.LIVE),x(this,void 0,void 0,function(){var s,o,u,d,l,h,a,c;return V(this,function(p){switch(p.label){case 0:return this._channel?(s=this._channel.codec.encodeJoinRTCRoom(r,i),o=new Q(D[D.viewerJoinR],s,t),[4,this._channel.send(o,sc)]):[2,{code:S.RC_NET_CHANNEL_INVALID}];case 1:return u=p.sent(),d=u.code,l=u.data,d!==S.SUCCESS?[2,{code:d}]:(a=(h=l).rtcToken,c=h.entries,[2,{code:d,data:{token:a,kvEntries:c}}])}})})},e.prototype.quitLivingRoomAsAudience=function(t){return x(this,void 0,void 0,function(){var r,i,s;return V(this,function(o){switch(o.label){case 0:return this._channel?(r=this._channel.codec.encodeQuitRTCRoom(),i=new Q(D[D.viewerExitR],r,t),[4,this._channel.send(i)]):[2,S.RC_NET_CHANNEL_INVALID];case 1:return s=o.sent().code,this._rtcKVManager.reset(),[2,s]}})})},e.prototype.rtcIdentityChange=function(t,r,i){return x(this,void 0,void 0,function(){var s,o,u,d,l;return V(this,function(h){switch(h.label){case 0:return this._channel?(s=this._channel.codec.encodeIdentityChangeInfo(r,i),o=new Q(D[D.rtcIdentityChange],s,t),[4,this._channel.send(o,kt)]):[2,{code:S.RC_NET_CHANNEL_INVALID}];case 1:return u=h.sent(),d=u.code,l=u.data,d!==S.SUCCESS?[2,{code:d}]:[2,{code:d,data:l}]}})})},e.prototype.pullRTCRoomEntry=function(t,r){return x(this,void 0,void 0,function(){var i,s,o,u,d,l,h,a,c;return V(this,function(p){switch(p.label){case 0:return s=(i=this)._channel,o=i.currentUserId,s?(j.info("audience in room start pull KV"),u=s.codec.encodePullRTCRoomKV(t,0),d=new Q(D[D.rtcPullKv],u,o),[4,s.send(d,ni)]):[2,{code:S.RC_NET_CHANNEL_INVALID}];case 1:return l=p.sent(),h=l.code,a=l.data,j.info("audience in room end pull KV, code: "+h+", data: "+JSON.stringify(a||{})),h===S.SUCCESS?(c=a.kvEntries,this._watcher.onRTCDataChange(c,t),[2,{code:h,data:a}]):[2,{code:h}]}})})},e.prototype.getRTCJoinedUserInfo=function(t){return x(this,void 0,void 0,function(){var r,i,s,o,u,d,l,h;return V(this,function(a){switch(a.label){case 0:return i=(r=this)._channel,s=r.currentUserId,i?(o=i.codec.encodeQueryUserJoinedInfo(t),u=new Q(D[D.rtcQueryJoined],o,s),[4,i.send(u,ri)]):[2,{code:S.RC_NET_CHANNEL_INVALID}];case 1:return d=a.sent(),l=d.code,h=d.data,l===S.SUCCESS?[2,{code:l,data:h}]:[2,{code:l}]}})})},e.prototype.getDeviceId=function(){return Ec(this.runtime)},e.prototype.requestRoomPK=function(t){return x(this,void 0,void 0,function(){var r,i,s;return V(this,function(o){switch(o.label){case 0:return this._channel?(r=this._channel.codec.encodeRequestRoomPK(t),i=new Q(D[D.rtcInvite],r,t.roomId),[4,this._channel.send(i)]):[2,S.RC_NET_CHANNEL_INVALID];case 1:return s=o.sent().code,this._rtcKVManager.reset(),[2,s]}})})},e.prototype.cancelRoomPK=function(t){return x(this,void 0,void 0,function(){var r,i,s;return V(this,function(o){switch(o.label){case 0:return this._channel?(r=this._channel.codec.encodeCancelRoomPK(t),i=new Q(D[D.rtcCancelInvite],r,t.roomId),[4,this._channel.send(i)]):[2,S.RC_NET_CHANNEL_INVALID];case 1:return s=o.sent().code,this._rtcKVManager.reset(),[2,s]}})})},e.prototype.responseRoomPK=function(t){return x(this,void 0,void 0,function(){var r,i,s;return V(this,function(o){switch(o.label){case 0:return this._channel?(r=this._channel.codec.encodeResponseRoomPK(t),i=new Q(D[D.rtcInviteAnswer],r,t.roomId),[4,this._channel.send(i)]):[2,S.RC_NET_CHANNEL_INVALID];case 1:return s=o.sent().code,this._rtcKVManager.reset(),[2,s]}})})},e.prototype.endRoomPK=function(t){return x(this,void 0,void 0,function(){var r,i,s;return V(this,function(o){switch(o.label){case 0:return this._channel?(r=this._channel.codec.encodeEndRoomPK(t),i=new Q(D[D.rtcEndInvite],r,t.roomId),[4,this._channel.send(i)]):[2,S.RC_NET_CHANNEL_INVALID];case 1:return s=o.sent().code,this._rtcKVManager.reset(),[2,s]}})})},e.prototype.callExtra=function(t){for(var r=[],i=1;i0){var _=u.join("");if(u=[],_.length>26){var v=t.numberEncode(_.length),R=String.fromCharCode(t.dataType.NormalExt|v.length);o.push(R+v)}else{var C=String.fromCharCode(t.dataType.Normal|_.length);o.push(C)}o.push(_)}},l=0;l=h.length)u.push(e.substr(l,h.length)),l+=h.length;else{d();var p=String.fromCharCode(t.dataType.Compressed|a.length<<2|c.length);o.push(p+a+c),l+=h.length}}}d();var f=t.numberEncode(e.length),m=String.fromCharCode(t.dataType.Tail|f.length);return o.push(m+f),o.join("")},n.uncompress=function(e){var t=this,r=0,i="";e:do{var s=e.charCodeAt(r++),o=s&t.dataType.Mark,u=15&s,d=void 0;switch(o){case t.dataType.Compressed:var l=u>>2,h=3&u;if(l===0||h===0)throw new Error("Data parsing error,at "+r);var a=t.numberDecode(e.substr(r,l)),c=t.numberDecode(e.substr(r+=l,h));if((a=i.length-a)+c>i.length)throw new Error("Data parsing error,at "+r);r+=h,i+=i.substr(a,c);break;case t.dataType.Tail:if((d=t.numberDecode(e.substr(r,u)))!==i.length)throw console.log(i.length),console.log(d),new Error("Data parsing error,at "+r);r+=u;break e;case t.dataType.NormalExt:d=t.numberDecode(e.substr(r,u)),i+=e.substr(r+=u,d),r+=d;break;case t.dataType.Normal:i+=e.substr(r,u),r+=u;break;case t.dataType.Mark:if(u>10)throw new Error("Data parsing error,at "+r);i+=e.substr(r,16+u),r+=16+u;break;default:throw new Error("Data parsing error,at "+r+" header:"+o)}}while(r=t.length-1)return i;var s=e[t.charAt(r)+t.charAt(r+1)];if(s[0]===r)return i;for(var o=t.length-r,u=0,d=s.length;uthis.max)){var a=Math.min(o,h);if(a<=i.length)break;if(!(i.length>2&&t.charAt(l+i.length-1)!==t.charAt(r+i.length-1))){for(var c=2,p=c;p=i.length&&(i.length=c,i.offset=l)}}}return i},n.numberEncode=function(e){var t=this,r=[],i=0;do i=e%t.scale,r.push(t.chars.charAt(i)),e=(e-i)/t.scale;while(e>0);return r.join("")},n.numberDecode=function(e){for(var t=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+'"');t=t*this.scale+r}return t},n.dataType={Tail:48,Compressed:64,NormalExt:80,Normal:96,Mark:112},n.chars="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",n.scale=n.chars.length,n.max=238327,n}(),mn=1,_n=!1,Jo=typeof location!="undefined"&&location.protocol==="https://"?"https://":"http://",nr=function(){function n(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=Ec(e.runtime),this.logSwitch=e.logSwitch;var t=sd(e.runtime);this.deviceInfo=t.type+"|"+t.version+"|"+wt.sessionId,this.startReport()}return n.init=function(e){return _n=!0,n._instance||(n._instance=new n(e)),n._instance},n.getInstance=function(){return n._instance},n.prototype.startReport=function(){var e=this;if(this.logSwitch&&_n){var t=this.itv*Math.pow(2,mn-1);mn "+s),e.startReport()})}else this.startReport()},n.prototype.reportFullLog=function(e){return x(this,void 0,void 0,function(){var t,r,i,s,o,u,d,l,h,a,c=this;return V(this,function(p){switch(p.label){case 0:return t=e.startTime,r=e.endTime,i=e.platform,s=e.logId,o=e.uri,u=ps.getInstance(),j.debug("received report log msg, "+i.toLowerCase(),u),i.toLowerCase()==="web"&&u?t>r?(j.warn("report error: The start time("+t+") cannot be greater than the end time("+t+")"),[2]):[4,j.__insertLogIntoDatabase()]:[2];case 1:return p.sent(),[4,u.getRangeData(Jt,"time",t,r)];case 2:return d=(d=p.sent()).filter(function(f){return!f.userId||f.userId===c.info.userId}),l=Yo.compress(d.map(function(f){return f.content}).join("")||"no data"),h=1,(a=function(){if(!(h>3)&&_n){var f=o||c.logUrl,m=""+Jo+f+"?version="+c.info.version+"&appkey="+c.info.appkey+"&userId="+c.info.userId+"&logId="+s+"&deviceId="+c.deviceId+"&deviceInfo="+c.deviceInfo+"&platform=Web",_=5e3*(h-1);h++,setTimeout(function(){_n&&c.info.runtime.httpReq({url:m,method:"POST",body:l}).then(function(){j.debug("report full log success!")}).catch(function(v){a(),j.warn("report full log error -> "+v)})},_)}})(),[2]}})})},n.prototype.distroy=function(){mn=1,_n=!1},n}();function rr(n){return Object.assign({},n)}var Wo,Xd=function(){function n(e,t){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=te.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({},t),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(s){return/^https?:\/\//.test(s)}),this._options.navigators=this._options.navigators.map(function(s){return s.replace(/\/$/g,"")}),this._options.navigators.length===0&&(r=this._options.navigators).push.apply(r,qu);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=ko()?new RCCppEngine(e,i,this._options):new zd(e,i,this._options)}return n.init=function(e,t){return j.setLogLevel(t.logLevel),j.setLogStdout(t.logStdout),(t.indexDBSwitch||fe(t.indexDBSwitch))&&ps.init(),j.debug("APIContext.init =>",t.appkey,t.navigators),this._context?(j.error("Repeat initialize!"),this._context):(j.warn("RCEngine Commit:","41dbe38d1b376ca0a791b23ed94be291e3f92e81"),this._context=new n(e,t),j.__insertLogIntoDatabase(),this._context)},n.destroy=function(){this._context&&(this._context._destroy(),this._context=void 0)},n.prototype.install=function(e,t){if(this._pluginInstanseMap[e.tag])return j.warn("Repeat install plugin: "+e.tag),this._pluginInstanseMap[e.tag];var r=e.tag==="RCRTC"?new Qd(this):new Cc(this),i=null;try{if(!e.verify(this._runtime))return null;i=e.setup(r,this._runtime,t)}catch(s){j.error(`install plugin error! `,s)}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},n.prototype._handleRedirect=function(){return x(this,void 0,void 0,function(){var e=this;return V(this,function(t){switch(t.label){case 0:return j.debug("_handleRedirct",this._token),[4,this.connect(this._token,!0)];case 1:return t.sent().code!==S.SUCCESS&&this._canRedirectConnect&&(this._handleSuspend(),setTimeout(function(){e._handleRedirect()},5e3)),[2]}})})},n.prototype._connectionStatusListener=function(e){var t;return x(this,void 0,void 0,function(){return V(this,function(r){return e===te.REDIRECT?(this._canRedirectConnect=!0,this._handleSuspend(),this._handleRedirect()):e===te.BLOCKED||e===te.KICKED_OFFLINE_BY_OTHER_CLIENT||e===te.DISCONNECT_BY_SERVER?(this._canRedirectConnect=!1,this._handleDisconnect()):e===te.CONNECTING?this._handleConnecting():e===te.CONNECTED?this._handleConnected():e===te.DISCONNECTED?this._handleDisconnect():e===te.NETWORK_UNAVAILABLE&&this._handleSuspend(),this._connectionStatus=e,((t=this._watcher.rtcInnerWatcher)===null||t===void 0?void 0:t.status)&&this._watcher.rtcInnerWatcher.status(e),this._pluginContextQueue.forEach(function(i){i.onconnectionstatechange&&i.onconnectionstatechange(e)}),this._watcher.connectionState&&this._watcher.connectionState(e),[2]})})},n.prototype._handleConnecting=function(){this._watcher.onConnecting&&this._watcher.onConnecting()},n.prototype._handleConnected=function(){this._watcher.onConnected&&this._watcher.onConnected()},n.prototype._handleDisconnect=function(){this._watcher.onDisconnect&&this._watcher.onDisconnect()},n.prototype._handleSuspend=function(){this._watcher.onSuspend&&this._watcher.onSuspend()},n.prototype._messageReceiver=function(e,t,r){var i,s,o;if((e.conversationType===z.RTC_ROOM||Object.prototype.hasOwnProperty.call(Xu,e.messageType))&&this._watcher.rtcInnerWatcher&&this._watcher.rtcInnerWatcher.message)this._watcher.rtcInnerWatcher.message(rr(e));else if(["RC:ChrmJoinNtf","RC:ChrmQuitNtf"].indexOf(e.messageType)===-1||typeof this._watcher.chatroomState!="function"){if(e.messageType!=="RC:ChrmMemChange"){if(e.messageType!==He.TYPING_STATUS||(this._addTypingInfo(rr(e)),!this._watcher.typingState))if(e.messageType!==He.LOG_COMMAND||e.senderUserId!=="rongcloudsystem")if(e.messageType!==He.INTERCEPT){if(!this._pluginContextQueue.some(function(v){if(!v.onmessage)return!1;try{return v.onmessage(rr(e))}catch(R){return j.error("plugin error =>",R),!1}}))if(e.messageType!=="RC:ReadNtf")if(e.messageType!=="RC:RRReqMsg"){if(e.messageType!=="RC:RRRspMsg")return this._watcher.message&&this._watcher.message(rr(e),t,r),e;var u=(o=e.content)===null||o===void 0?void 0:o.receiptMessageDic;u&&Array.isArray(u[this._engine.currentUserId])&&typeof this._watcher.messageReceiptResponse=="function"&&this._watcher.messageReceiptResponse({conversationType:e.conversationType,targetId:e.targetId,channelId:e.channelId},e.senderUserId,u[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,c=d.logId,p=d.uri,f=d.packageName,m={startTime:parseInt(l),endTime:parseInt(h),platform:a,logId:c,uri:p,packageName:f};(s=nr.getInstance())===null||s===void 0||s.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"?Ao.QUIT:Ao.JOIN,i),chatroomId:e.targetId}})},n.prototype._batchMessageReceiver=function(e,t,r){var i=this,s=[];e.forEach(function(o){var u=i._messageReceiver(o,t,r);u&&s.push(u)}),s.length&&this._watcher.batchMessage&&this._watcher.batchMessage(s)},n.prototype._chatroomInfoListener=function(e){this._watcher.chatroomState&&this._watcher.chatroomState(e)},n.prototype._conversationInfoListener=function(e){this._watcher.conversationState&&this._watcher.conversationState(e)},n.prototype._expansionInfoListener=function(e){this._watcher.expansion&&this._watcher.expansion(e)},n.prototype._tagListener=function(){this._watcher.tag&&this._watcher.tag()},n.prototype._conversationTagListener=function(){this._watcher.conversationTagChanged&&this._watcher.conversationTagChanged()},n.prototype._typingStatusListener=function(e){this._watcher.typingState&&this._watcher.typingState(e)},n.prototype._pullFinishedListener=function(){this._watcher.pullFinished&&this._watcher.pullFinished()},n.prototype._MessageBlockedListener=function(e){this._watcher.messageBlocked&&this._watcher.messageBlocked(e)},n.prototype._rtcDataChange=function(e,t){this._pluginContextQueue.forEach(function(r){r.onrtcdatachange&&r.onrtcdatachange(e,t)})},n.prototype.assignWatcher=function(e){var t=this;Object.keys(this._watcher).forEach(function(r){if(Object.prototype.hasOwnProperty.call(e,r)){var i=e[r];t._watcher[r]=Ir(i)||Ve(i)?i:void 0}})},n.prototype.resetWatcher=function(){var e=this;Object.keys(this._watcher).forEach(function(t){e._watcher[t]=void 0})},n.prototype._addTypingInfo=function(e){var t=e.senderUserId,r=e.conversationType,i=e.targetId,s=e.content,o=e.channelId,u=s.typingContentType,d=r+"#"+i+"#"+(o||"");this._typingInfo[d]||(this._typingInfo[d]=[]);var l=this._typingInfo[d].findIndex(function(h){return h.userId===t});l>=0&&this._typingInfo[d][l].messageType===u?this._typingInfo[d][l].timestamp=Date.now():(l>=0&&this._typingInfo[d].splice(l,1),this._typingInfo[d].push({userId:t,messageType:u,timestamp:Date.now()}),this._typingChangedList.includes(d)||this._typingChangedList.push(d),this._startCheckTypingInfo())},n.prototype._startCheckTypingInfo=function(){var e=this;this._typingInternalTimer===-1&&Object.keys(this._typingInfo).length!==0&&(this._typingInternalTimer=setInterval(function(){for(var t in e._typingInfo){var r=e._typingInfo[t].length;e._typingInfo[t]=e._typingInfo[t].filter(function(s){return Date.now()-s.timestamp0){var i=e._typingChangedList.map(function(s){return{conversationType:Number(s.split("#")[0]),targetId:s.split("#")[1],channelId:s.split("#")[2],list:e._typingInfo[s]||[]}});e._typingStatusListener(i),e._typingChangedList=[]}Object.keys(e._typingInfo).length===0&&(clearInterval(e._typingInternalTimer),e._typingInternalTimer=-1)},500))},n.prototype.getConnectedTime=function(){return this._engine.getConnectedTime()},n.prototype.getServerTime=function(){return this._engine.getServerTime()},n.prototype.getDeviceId=function(){return this._engine.getDeviceId()},n.prototype.getCurrentUserId=function(){return this._engine.currentUserId},n.prototype.getConnectionStatus=function(){return this._connectionStatus},Object.defineProperty(n.prototype,"token",{get:function(){return this._token},enumerable:!1,configurable:!0}),n.prototype.connect=function(e,t){return t===void 0&&(t=!1),x(this,void 0,void 0,function(){var r,i,s,o,u,d;return V(this,function(l){switch(l.label){case 0:return this._connectionStatus===te.CONNECTED?[2,{code:S.SUCCESS,userId:this._engine.currentUserId}]:this._connectionStatus===te.CONNECTING?[2,{code:S.BIZ_ERROR_CONNECTING}]:typeof e!="string"||e.length===0?[2,{code:S.RC_CONN_USER_OR_PASSWD_ERROR}]:(this._token=e,r=e.split("@"),i=r[1],s=i?i.split(";").map(function(h){return/^https?:/.test(h)?h:"https://"+h}):[],[4,this._engine.navi.getInfo(this._getTokenWithoutNavi(),s,t,this._options.checkCA)]);case 1:return(o=l.sent())?(o==null?void 0:o.type)===1?[2,{code:S.PACKAGE_ENVIRONMENT_ERROR}]:(u=Dt.getInfo(),[4,this._engine.connect(this._getTokenWithoutNavi(),o)]):[2,{code:S.RC_NAVI_RESOURCE_ERROR}];case 2:return d=l.sent(),j.__insertLogIntoDatabase(),d!==Be.REDIRECT?[3,4]:(this._connectionStatus=te.REDIRECT,[4,this.connect(e,!0)]);case 3:return[2,l.sent()];case 4:return d===S.SUCCESS&&(j.info("connect success, userId: "+this._engine.currentUserId),(o==null?void 0:o.type)!==1&&this._engine.reportSDKInfo&&this._engine.reportSDKInfo(u),nr.init({runtime:this._runtime,logSwitch:(o==null?void 0:o.logSwitch)||0,logPolicy:JSON.parse((o==null?void 0:o.logPolicy)||"{}"),appkey:this.appkey,version:this.apiVersion,userId:this._engine.currentUserId}),wt.init(this._engine.currentUserId),this._isInternalConnected=!0),d!==S.SUCCESS||ko()||o.openUS===1&&this._pullUserSettings(),d!==S.SUCCESS&&(this._connectionStatus=te.CONNECTION_CLOSED),[2,{code:d,userId:this._engine.currentUserId}]}})})},n.prototype._pullUserSettings=function(){return x(this,void 0,void 0,function(){return V(this,function(e){return[2]})})},n.prototype.disconnect=function(){var e;return this._isInternalConnected=!1,clearInterval(this._typingInternalTimer),this._typingInternalTimer=-1,(e=nr.getInstance())===null||e===void 0||e.distroy(),j.__insertLogIntoDatabase(),wt.reset(),this._engine.disconnect(),this._pluginContextQueue.forEach(function(t){if(t.ondisconnect)try{t.ondisconnect()}catch(r){j.error("plugin error =>",r)}}),Promise.resolve()},n.prototype.reconnect=function(){return this._isInternalConnected?Promise.resolve({code:S.CAN_NOT_RECONNECT}):this.connect(this._getTokenWithoutNavi())},n.prototype._getTokenWithoutNavi=function(){return this._token.replace(/@.+$/,"@")},n.prototype.getInfoFromCache=function(){return this._engine.navi.getInfoFromCache(this._getTokenWithoutNavi())},n.prototype.registerMessageType=function(e,t,r,i){i===void 0&&(i=[]),this._engine.registerMessageType(e,t,r,i)},n.prototype.sendMessage=function(e,t,r,i){var s=this.getInfoFromCache();if(((s==null?void 0:s.grpRRVer)||0)===1&&r.messageType===He.READ_RECEIPT_RESPONSE)return Promise.resolve({code:S.READ_RECEIPT_ERROR});var o=JSON.stringify(r.content);return Ka(o)>131072?Promise.resolve({code:S.RC_MSG_CONTENT_EXCEED_LIMIT}):this._engine.sendMessage(e,t,r,i)},n.prototype.sendExpansionMessage=function(e){return x(this,void 0,void 0,function(){var t,r,i,s,o,u,d,l,h,a,c,p,f,m;return V(this,function(_){switch(_.label){case 0:if(t=e.channelId,r=e.conversationType,i=e.targetId,s=e.messageUId,o=e.keys,u=e.expansion,d=e.removeAll,!e.canIncludeExpansion)return[2,{code:S.MESSAGE_KV_NOT_SUPPORT}];if(l=!1,h=!1,a=!1,Ve(u)){for(p in c=Object.keys(u).length,l=c>20,u)if(f=u[p],h=Qe(p)&&!/^[A-Za-z0-9_=+-]+$/.test(p),(a=p.length>32||f.length>64)||h)break}return l||a?[2,{code:S.EXPANSION_LIMIT_EXCEET}]:h?[2,{code:S.BIZ_ERROR_INVALID_PARAMETER}]:(m={mid:s},u&&(m.put=u),o&&(m.del=o),d&&(m.removeAll=1),[4,this._engine.sendMessage(r,i,{content:m,messageType:He.EXPANSION_NOTIFY,channelId:t})]);case 1:return[2,{code:_.sent().code}]}})})},n.prototype.sendReadReceiptMessage=function(e,t,r){return x(this,void 0,void 0,function(){var i;return V(this,function(s){return i=this.getInfoFromCache(),((i==null?void 0:i.grpRRVer)||0)===0?[2,{code:S.READ_RECEIPT_ERROR,data:"The read receipt switch is not on, please call the sendMessage method!"}]:[2,this._engine.sendReadReceiptMessage(e,t,r)]})})},n.prototype.getMessageReader=function(e,t,r){return x(this,void 0,void 0,function(){var i;return V(this,function(s){return i=this.getInfoFromCache(),((i==null?void 0:i.grpRRVer)||0)===0?[2,{code:S.READ_RECEIPT_ERROR}]:[2,this._engine.getMessageReader(e,t,r)]})})},n.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(t){if(t.ondestroy)try{t.ondestroy()}catch(r){j.error("plugin error =>",r)}}),this._pluginContextQueue.length=0,this._pluginInstanseMap={},(e=nr.getInstance())===null||e===void 0||e.distroy(),wt.reset()},n.prototype.getHistoryMessage=function(e,t,r,i,s,o,u){return r===void 0&&(r=0),i===void 0&&(i=20),s===void 0&&(s=0),o===void 0&&(o=""),u===void 0&&(u=""),this._engine.getHistoryMessage(e,t,r,i,s,o,u||"")},n.prototype.getConversationList=function(e,t,r,i,s){return e===void 0&&(e=300),s===void 0&&(s=""),this._engine.getConversationList(e,t,r,i,s)},n.prototype.getConversation=function(e,t,r){return this._engine.getConversation(e,t,r)},n.prototype.removeConversation=function(e,t,r){return r===void 0&&(r=""),this._engine.removeConversation(e,t,r)},n.prototype.clearUnreadCount=function(e,t,r){return r===void 0&&(r=""),this._engine.clearConversationUnreadCount(e,t,r)},n.prototype.clearAllUnreadCount=function(){return this._engine.clearAllUnreadCount()},n.prototype.getUnreadCount=function(e,t,r){return r===void 0&&(r=""),this._engine.getConversationUnreadCount(e,t,r)},n.prototype.getTotalUnreadCount=function(e,t,r){return this._engine.getAllConversationUnreadCount(e,t&&t.length>0?t:[z.PRIVATE,z.GROUP,z.SYSTEM,z.PUBLIC_SERVICE],!!r)},n.prototype.getFirstUnreadMessage=function(e,t,r){return r===void 0&&(r=""),this._engine.getFirstUnreadMessage(e,t,r)},n.prototype.setConversationStatus=function(e,t,r,i,s){s===void 0&&(s="");var o=[{conversationType:e,targetId:t,isTop:r,notificationStatus:i,channelId:s}];return this._engine.batchSetConversationStatus(o)},n.prototype.saveConversationMessageDraft=function(e,t,r,i){return i===void 0&&(i=""),this._engine.saveConversationMessageDraft(e,t,r,i)},n.prototype.getConversationMessageDraft=function(e,t,r){return r===void 0&&(r=""),this._engine.getConversationMessageDraft(e,t,r)},n.prototype.clearConversationMessageDraft=function(e,t,r){return r===void 0&&(r=""),this._engine.clearConversationMessageDraft(e,t,r)},n.prototype.recallMessage=function(e,t,r,i,s){return this._engine.recallMsg(e,t,r,i,s)},n.prototype.deleteRemoteMessage=function(e,t,r,i){return i===void 0&&(i=""),this._engine.deleteRemoteMessage(e,t,r,i)},n.prototype.deleteRemoteMessageByTimestamp=function(e,t,r,i){return i===void 0&&(i=""),this._engine.deleteRemoteMessageByTimestamp(e,t,r,i)},n.prototype.joinChatroom=function(e,t){return t===void 0&&(t=10),this._engine.joinChatroom(e,t)},n.prototype.joinExistChatroom=function(e,t){return t===void 0&&(t=10),this._engine.joinExistChatroom(e,t)},n.prototype.quitChatroom=function(e){return this._engine.quitChatroom(e)},n.prototype.getChatroomInfo=function(e,t,r){return t===void 0&&(t=0),r===void 0&&(r=0),this._engine.getChatroomInfo(e,t,r)},n.prototype.setChatroomEntry=function(e,t){var r=t.key,i=t.value;return Ht(r)&&fi(i)?this._engine.setChatroomEntry(e,t):Promise.resolve(S.BIZ_ERROR_INVALID_PARAMETER)},n.prototype.setChatroomEntries=function(e,t){for(var r=0;r1e3?[2,Promise.reject(S.CONVER_OUT_LIMIT_ERROR)]:[2,this._engine.addTagForConversations(e,t)]})})},n.prototype.removeTagForConversations=function(e,t){return x(this,void 0,void 0,function(){return V(this,function(r){return[2,this._engine.removeTagForConversations(e,t)]})})},n.prototype.removeTagsForConversation=function(e,t){return x(this,void 0,void 0,function(){return V(this,function(r){return[2,this._engine.removeTagsForConversation(e,t)]})})},n.prototype.getConversationListByTag=function(e,t,r,i){return x(this,void 0,void 0,function(){return V(this,function(s){return[2,this._engine.getConversationListByTag(e,t,r,i)]})})},n.prototype.getUnreadCountByTag=function(e,t){return x(this,void 0,void 0,function(){return V(this,function(r){return[2,this._engine.getUnreadCountByTag(e,t)]})})},n.prototype.setConversationStatusInTag=function(e,t,r){return x(this,void 0,void 0,function(){return V(this,function(i){return[2,this._engine.setConversationStatusInTag(e,t,r)]})})},n.prototype.getTagsForConversation=function(e){return x(this,void 0,void 0,function(){return V(this,function(t){return[2,this._engine.getTagsForConversation(e)]})})},n.prototype.getBlockConversationList=function(){return this._engine.getBlockConversationList()},n.prototype.getTopConversationList=function(){return this._engine.getTopConversationList()},n.prototype.getUnreadMentionedCount=function(e){return this._engine.getUnreadMentionedCount(e)},n.prototype.getAllUnreadMentionedCount=function(){return this._engine.getAllUnreadMentionedCount()},n.prototype.callExtra=function(e){for(var t,r=[],i=1;i0&&i[i.length-1])||h[0]!==6&&h[0]!==2)){o=0;continue}if(h[0]===3&&(!i||h[1]>i[0]&&h[1]"+t),[4,ot.imClient.context.joinChatroom(n,e.count)];case 1:return(r=i.sent())!==S.SUCCESS?(Ke.warn("join chatroom fail ->code+:"+en[r]+","+t),[2,{code:r,msg:en[r]}]):[2,{code:r}]}})})}var yc=function(n,e,t,r){t===void 0&&(t=!0),r===void 0&&(r=!0),this.messageType=n,this.content=e,this.isPersited=t,this.isCounted=r};function it(n,e,t){return e===void 0&&(e=!0),t===void 0&&(t=!0),function(r){return new yc(n,r,e,t)}}var Tc,zi,ll=it("RC:ImgMsg"),hl=it("RC:HQVCMsg"),pl=it("RC:SightMsg"),fl=it("RC:TxtMsg"),gl=it("RC:CombineMsg"),ml=it("RC:FileMsg");it("RC:GIFMsg");it("RC:VcMsg");it("RC:LBSMsg");it("RC:ReferenceMsg");it("RC:ImgTextMsg");var jt={qiniu:function(n,e,t,r){var i,s="https://"+e.uploadHost.qiniu;i=Rn()+_e[0][1]||s,_e.shift();var o=new XMLHttpRequest;o.upload&&e.support_options&&(o.upload.onprogress=function(u){t.onProgress(u.loaded,u.total)}),o.onreadystatechange=function(){if(o.readyState===4){var u=o.responseText||"{}";(u=JSON.parse(u)).filename=e.uniqueValue,u.uploadMethod=Ge?Ge.QINIU:"",o.status===200?t.onCompleted(u):_e.length?jt[_e[0][0]](n,e,t,r):t.onError("upload fail")}},e.isChunk&&(i=function(u,d){var l="";return da(d,function(h,a){h!=="token"&&(l+=(l?"&":"")+encodeURIComponent(h)+"="+encodeURIComponent(a))}),l&&(u+=(u.indexOf("?")>0?"&":"?")+l),u}(i+="/mkblk/"+n.size,e.multi_parmas)),o.open(e.method,i,!0),t.onOpen(o),e.stream&&o.setRequestHeader("authorization","UpToken "+e.multi_parmas.token),da(e.headers,function(u,d){o.setRequestHeader(u,d)}),o.send(n)},baidu:function(n,e,t,r){if(console.log(r,e),r.size>ua)throw new Error("the file size is over 5GB!");var i=e||{};e=e||zi;var s=new XMLHttpRequest,o=Rn();if(!(!i.uploadHost.bos&&!i.bosUploadPath)){var u=o+_e[0][1]+i.bosUploadPath;_e.shift();var d=i.bosHeader||{},l={filename:e.uniqueValue||r.uniqueName,name:r.name,downloadUrl:u,isBosRes:!0};s.upload&&e.support_options&&(s.upload.onprogress=function(h){t.onProgress(h.loaded,h.total,!0)}),s.onreadystatechange=function(){if(s.readyState===4){var h=s.responseText||"{}";(h=JSON.parse(h)).filename=e.uniqueValue,s.status===200?t.onCompleted(l,!0):_e.length?jt[_e[0][0]](n,e,t,r):t.onError("upload fail")}},s.open(e.method,u,!0),s.setRequestHeader("authorization",d.bosToken),s.setRequestHeader("x-bce-date",d.bosDate),s.send(r)}},aliyun:function(n,e,t,r){if(r.size>ua)throw new Error("the file size is over 5GB!");const i=new FormData;i.set("file",n.get("file")),i.set("key",n.get("key")),i.set("token",n.get("token"));const s=_e[0][1];_e.shift(),n=n||Tc,e=(e=e||{})||zi;var o=new XMLHttpRequest,u=Rn()+e.ossBucketName+"."+s;o.upload&&e.support_options&&(o.upload.onprogress=function(l){t.onProgress(l.loaded,l.total)}),o.onreadystatechange=function(){if(o.readyState===4){var l=o.responseText||"{}";(l=JSON.parse(l)).name=e.uniqueValue,l.filename=e.uploadFileName,l.uploadMethod=Ge?Ge.ALI:"",o.status===200?t.onCompleted(l):_e.length?jt[_e[0][0]](i,e,t,r):t.onError("upload fail")}},o.open(e.method,u,!0),console.log("ali:url",u);var d=e.aliHeader||{};n.set("OSSAccessKeyId",d.osskeyId),n.set("policy",d.ossPolicy),n.set("Signature",d.ossSign),n.set("success_action_status",200),n.delete("key"),n.append("key",e.uploadFileName),n.delete("file"),n.append("file",r),o.send(n)},s3:function(n,e,t,r){var i=new FormData,s=new XMLHttpRequest,o=Rn();const u=_e[0][1];var d=o+e.s3BucketName+"."+u;console.log("uploadS3:url",d),_e.shift(),s.upload&&e.support_options&&(s.upload.onprogress=function(a){t.onProgress(a.loaded,a.total)}),s.onreadystatechange=function(){if(s.readyState===4){var a=s.responseText||"{}";if((a=JSON.parse(a)).name=e.uniqueValue,a.filename=e.uploadFileName,a.uploadMethod=Ge.AWS,console.log("UploadMethod:",Ge),s.status===200||s.status===204)t.onCompleted(a);else if(_e.length){const c=new FormData;c.set("file",n.get("file")),c.set("key",n.get("key")),c.set("token",n.get("token")),jt[_e[0][0]](c,e,t,r)}else t.onError("upload fail")}},s.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),s.send(i)},stc:function(n,e,t,r){new FormData;var i=new XMLHttpRequest;Rn();var s="https://"+_e[0][1]+"/"+e.stcBucketName+"/"+e.uploadFileName;_e.shift(),i.upload&&e.support_options&&(i.upload.onprogress=function(u){t.onProgress(u.loaded,u.total)}),i.onreadystatechange=function(){if(i.readyState===4){var u=i.responseText||"{}";if((u=JSON.parse(u)).name=e.uniqueValue,u.filename=e.uploadFileName,u.uploadMethod=Ge?Ge.STC:"",i.status===200||i.status===204)t.onCompleted(u);else if(_e.length){const d=new FormData;d.set("file",n.get("file")),d.set("key",n.get("key")),d.set("token",n.get("token")),jt[_e[0][0]](d,e,t,r)}else t.onError("upload fail")}},i.open("PUT",s,!0);var o=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",o.stcAuthorization),i.setRequestHeader("x-amz-content-sha256",o.stcContentSha256),i.setRequestHeader("x-amz-date",o.stcDate),i.send(r)}},_e=[],ua=5368709120;function da(n,e){for(var t in n)e(t,n[t])}function Rn(){var n="https://";return location.protocol!=="http:"&&location.protocol!=="file:"||(n="http://"),n}function _l(n,e,t){var r,i,s=n&&n.type||"text/plain",o=s.indexOf("image")>-1?1:4,u=Math.ceil(n.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";ot.imClient.getFileToken(o,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),s==="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",s),_.send(),_.onreadystatechange=function(v){if(_.readyState===4){var R=_.response.match(/(?:)(\S*?)(?:<\/UploadId>)/);console.log("uploadId",R),_.status===200||_.status===204?function(C){for(var A=[],M=1;M<=u;M++)A.push(f(C,M));p(C,A)}(Array.isArray(R)&&R[1]):t.onError("uploadStcMultipart:did not get uploadId")}}},function(m){t.onError("uploadStcMultipart:"+m)});var a=[],c=new Map;function p(m,_){_&&Array.isArray(_)&&_.length!==0&&Promise.all(_).then(()=>{var v="uploadId="+m;if(c.size===u)ot.imClient.context.getFileToken(o,r,"POST",v).then(function(A){console.log("onSuccess",A),console.log("onSuccess:uploadId",m);var M=new XMLHttpRequest;M.open("POST",i+"?"+v,!0),M.setRequestHeader("Authorization",A&&A.stcAuthorization),M.setRequestHeader("x-amz-content-sha256",A&&A.stcContentSha256),M.setRequestHeader("x-amz-date",A&&A.stcDate),M.setRequestHeader("Content-Type",s);var O="",y=Array.from(c.keys()||[]).sort((w,$)=>w-$);console.log("keys",y),y.map(w=>{O+=`${c.get(w)}${w}`}),O+="",M.send(O),console.log("xml",O),M.onreadystatechange=function(){if(M.readyState===4)if(M.status===200||M.status===204){var w={};w.name=n.name,w.filename=e.uploadFileName,w.uploadMethod=Ge.STC,t.onCompleted(w)}else t.onError("uploadStcMultipart:upload does not end")}},function(A){t.onError("uploadStcMultipart:"+A)});else{var R=[];for(var C of a)R.push(f(m,C));p(m,R)}},v=>{console.error(v),t.onError("uploadStcMultipart: chunkFiles upload failed and those will reupload");var R=[];for(var C of a)R.push(f(m,C));p(m,R)})}function f(m,_){return new Promise((v,R)=>{var C="partNumber="+_+"&uploadId="+m;ot.imClient.context.getFileToken(o,r,"PUT",C).then(function(A){console.log("signature "+_+" onSuccess",A);var M=n&&n.slice((_-1)*e.stc_chunk_size,_*e.stc_chunk_size);console.log("fileChunk:size",M.size);var O=new XMLHttpRequest;O.open("PUT",i+"?"+C,!0),O.setRequestHeader("Authorization",A&&A.stcAuthorization),O.setRequestHeader("x-amz-content-sha256",A&&A.stcContentSha256),O.setRequestHeader("x-amz-date",A&&A.stcDate),O.setRequestHeader("Content-Type",s),O.send(M),O.onreadystatechange=function(){if(O.readyState===4)if(O.status===200||O.status===204){var y=O.getResponseHeader("etag");console.log("etag:"+_,y),c.set(_,y),v(y)}else a.includes(_)||a.push(_),R(_)}},function(A){console.log("getETags:\u7B7E\u540D\u9A8C\u8BC1\u5931\u8D25"),a.includes(_)||a.push(_),R(_)})})}}var Sc={form:function(n,e){var t=new FormData;if(e.unique_key){var r=n.name.substr(n.name.lastIndexOf(".")),i=Qi()+r;t.append(e.unique_key,i),e.uniqueValue=i}return t.append(e.file_data_name,n),Xi(e.multi_parmas,function(s,o){t.append(s,o)}),t},json:function(n,e){var t={};if(e.unique_key){var r=n.name.substr(n.name.lastIndexOf(".")),i=Qi()+r;t[e.unique_key]=i,e.uniqueValue=i}return t[e.file_data_name]=n,Xi(e.multi_parmas,function(s,o){t[s]=o}),JSON.stringify(t)},data:function(n,e){return n}};function Qi(){var n=new Date().getTime();return"xxxxxx4xxxyxxxxxxx".replace(/[xy]/g,function(e){var t=(n+16*Math.random())%16|0;return n=Math.floor(n/16),(e==="x"?t:3&t|8).toString(16)})}function Xi(n,e){for(var t in n)e(t,n[t])}var ur,Ci=0;function vl(n){this.options=function(e){var t={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:Sc.form,genUId:Qi};if(!e||!e.domain)throw new Error("domain is null");for(var r in e)t[r]=e[r];return t}(n),this.setOptions=function(e){var t=this;Xi(e,function(r,i){t.options[r]=i})},console.log("options",n),this.upload=function(e,t){if(e){var r=this;(function(i,s,o){if(Tc=i,zi=s,_e=[],s.ossConfig){const h=JSON.parse(s.ossConfig);let a,c,p="";const f=[];h.forEach(m=>{const _=Number(m.p)-1;for(const v in m)v==="aliyun"&&(p=m[v]),v==="s3"&&(a=m[v]),v==="stc"&&(c=m[v]),v!=="p"&&(f[_]=[v,m[v]])}),f.forEach(function(m){m&&_e.push(m)}),h.length!==_e.length&&(_e=[["qiniu",s.domain],["baidu",s.uploadHost.bos],["aliyun",p],["s3",a],["stc",c]])}else _e=[["qiniu",s.domain],["baidu",s.uploadHost.bos]];var u;if(s.ossConfig){var d=s&&JSON.parse(s.ossConfig);Array.isArray(d)||(d=[]),u=d.find(h=>Object.keys(h).includes("stc"))}if(u&&parseInt(u.p)===1&&i.size>=4194304)_l(i,s,o);else{var l=s.data(i,s);jt[_e[0][0]](l,s,o,i)}})(e,this.options,{onProgress:function(i,s,o){ur=i,o?ur=Ci+i/s*(s-Ci):Ci=ur,t.onProgress(ur,s)},onCompleted:function(i){t.onCompleted(i)},onError:function(i){t.onError(i)},onOpen:function(i){r.xhr=i}})}else t.onError("upload file is null.")},this.cancel=function(){this.xhr&&this.xhr.abort()}}var la={init:function(n){return new vl(n)},dataType:Sc,resize:function(n,e,t){n.type;var r=document.createElement("canvas"),i=new FileReader;i.readAsDataURL(n),i.onload=function(s){var o=s.target.result,u=new Image;u.src=o;var d=u.width,l=u.height,h=function(c,p){var f=1,m=c.width,_=p.maxWidth||0;_>0&&m>_&&(f=_/m);var v=c.height,R=p.maxHeight||0;if(R>0&&v>R){var C=R/v;f=Math.min(f,C)}var A=p.maxSize||0,M=Math.ceil(c.size/1e3);if(M>A){var O=A/M;f=Math.min(f,O)}return f}({width:d,height:l,size:s.total},e),a=o;h<1&&(a=function(c,p,f){r.width=p,r.height=f,r.getContext("2d").drawImage(c,0,0,p,f);var m="image/jpg";return r.toDataURL(m)}(u,d*h,l*h)),t(a)}}};const Rl=function(n,e,t){var r=document.createElement("canvas"),i=r.getContext("2d"),s=new Image;s.onload=function(){var o=function(l,h,a){var c,p,f,m=la.scale?(m?(p=100,v=((f=h/(c=l/100))-a.maxHeight)/2):(f=100,_=((p=l/(c=h/100))-a.maxWidth)/2),{w:p,h:f,x:-_,y:-v}):(m?(c=h/a.maxHeight,f=a.maxHeight,p=l/c):(c=l/a.maxWidth,p=a.maxWidth,f=h/c),{w:p,h:f,x:-_,y:-v})}(s.width,s.height,e);r.width=o.w>e.maxWidth?e.maxWidth:o.w,r.height=o.h>e.maxHeight?e.maxHeight:o.h,i.drawImage(s,o.x,o.y,o.w,o.h);try{var u=r.toDataURL(n.type,e.quality),d=new RegExp("^data:image/[^;]+;base64,");u=u.replace(d,""),t(u)}catch(l){throw new Error(l)}},s.src=typeof n=="string"?"data:image/jpg;base64,"+n:function(o){var u=window.URL||window.webkitURL;return u?u.createObjectURL(o):""}(n)},El=function(n,e){var t=n.file,r=n.compress;Rl(t,r,e)},Ic=function(n,e){if(n.getToken)n.getToken(function(r,i){i=i||{},n.multi_parmas||(n.multi_parmas={}),n.multi_parmas.token=r,n.uploadHost||(n.uploadHost={}),n.uploadHost.bos=i.bos,n.ossConfig=i.ossConfig,n.bosHeader||(n.bosHeader={}),n.bosHeader.bosDate=i.bosDate,n.bosHeader.bosToken=i.bosToken,n.bosUploadPath=i.path,n.aliHeader={},n.aliHeader.osskeyId=i.osskeyId,n.aliHeader.ossPolicy=i.ossPolicy,n.aliHeader.ossSign=i.ossSign,n.ossBucketName=i.ossBucketName,n.uploadFileName=i.fileName,n.s3Header={},n.s3Header.s3Credential=i.s3Credential,n.s3Header.s3Algorithm=i.s3Algorithm,n.s3Header.s3Date=i.s3Date,n.s3Header.s3Policy=i.s3Policy,n.s3Header.s3Signature=i.s3Signature,n.s3BucketName=i.s3BucketName,n.stcHeader={},n.stcHeader.stcAuthorization=i.stcAuthorization,n.stcHeader.stcContentSha256=i.stcContentSha256,n.stcHeader.stcDate=i.stcDate,n.stcBucketName=i.stcBucketName,n.headers||(n.headers={}),n.base64&&(n.headers["Content-type"]="application/octet-stream",n.headers.Authorization="UpToken "+r),console.log("data",i);var s=la.init(n);e(s)});else{n.headers||(n.headers={}),n.base64&&(n.headers["Content-type"]="application/octet-stream");var t=la.init(n);e(t)}};var yi,dr,bc=function(n,e,t){e.upload(n.file,{onError:function(r){t.onError(r)},onProgress:function(r,i){t.onProgress(r,i)},onCompleted:function(r){r.filename||(r.filename=r.hash);var i=n.compressThumbnail||El;n.compress?i(n,function(s){r.thumbnail=s,t.onCompleted(r)}):t.onCompleted(r)}})},Cl=function(n){var e=this;this.instance=n,this.upload=function(t,r){bc({file:t},e.instance,r)},this.cancel=function(){e.instance.cancel()}},yl=function(n,e){var t=this;this.cfg=e,this.instance=n,this.upload=function(r,i){var s={file:r,compress:t.cfg};bc(s,t.instance,i)},this.cancel=function(){t.instance.cancel()}},Tl=function(n,e){Ic(n,function(t){var r={maxHeight:n.maxHeight||160,maxWidth:n.maxWidth||160,quality:n.quality||.5,scale:n.scale||2.4},i=new yl(t,r);e(i)})},Sl=function(n,e){Ic(n,function(t){var r=new Cl(t);e(r)})},Il=Tl;function ha(n){return yi=yi||new AudioContext,new Promise(function(e,t){yi.decodeAudioData(n,function(r){e({duration:r.duration,length:r.length})},t)})}function bl(n,e,t,r,i){return Ue("fileType",n,Qu,!0),Ue("filename",e,we.STRING),Ue("saveName",t,we.STRING),Ue("serverType",i,we.NUMBER),new Promise(function(s){ot.imClient.context.getFileUrl(n,e,t,r,i).then(function(o){s({code:S.SUCCESS,data:o})}).catch(function(o){s({code:o})})})}function Oc(n,e,t){return Bn(this,void 0,void 0,function(){var r,i,s,o,u,d,l,h,a;return Fn(this,function(c){switch(c.label){case 0:return t=t||{},e instanceof yc?(Ue("conversation.channelId",n==null?void 0:n.channelId,we.CHANNEL_ID),r=n.conversationType,i=n.targetId,s=n.channelId,o="conversationType:"+r+",targetId:"+i,Ke.debug("send message ->"+o),(u=Object.assign(t,e)).channelId=s||"",[4,ot.imClient.context.sendMessage(r,i,u)]):(Ke.warn("send message fail -> message parameter is not an instance of BaseMessage"),[2,xr.ILLGAL_PARAMS]);case 1:return d=c.sent(),l=d.code,h=d.data,l===S.SUCCESS?(a=Dr(h),[2,{code:l,data:a}]):(Ke.warn("send message fail ->"+l+":"+en[l]+","+o),[2,{code:l,msg:en[l],data:Dr({isMentioned:!!t.isMentioned,content:e.content,messageType:e.messageType,isPersited:e.isPersited||!1,isCounted:e.isCounted||!1,disableNotification:!!(t==null?void 0:t.disableNotification),canIncludeExpansion:!!(t==null?void 0:t.canIncludeExpansion),expansion:(t==null?void 0:t.expansion)||null,conversationType:r,targetId:i,channelId:s||"",senderUserId:ot.imClient.context.getCurrentUserId(),messageUId:"",messageDirection:nt.SEND,isOffLineMessage:!1,sentTime:(h==null?void 0:h.sentTime)||0,receivedTime:0,isStatusMessage:t.isStatusMessage||!1,receivedStatus:Mn.UNREAD})}])}})})}function Jn(n,e){return function(t,r,i,s){return new Promise(function(o){var u;(function(d,l,h,a){var c,p=this;if(l===void 0&&(l=ke.FILE),c=l===ke.IMAGE?ke.IMAGE:ke.FILE,!dr){dr="upload.qiniup.com";var f=ot.imClient.context.getInfoFromCache();if(f&&f.ossConfig)try{var m=JSON.parse(f.ossConfig).find(function(v){return v.qiniu!==void 0});m&&(dr=m.qiniu)}catch{}}var _=Wi({domain:dr,getToken:function(v){ot.imClient.context.getFileToken(c).then(function(R){v(R.token,R)}).catch(function(R){h.onFail(R)})}},a);(c===ke.IMAGE?Il:Sl)(_,function(v){v.upload(d,{onProgress:function(R,C){var A,M=Math.floor(R/C*100);(A=h.onProgress)===null||A===void 0||A.call(h,M)},onCompleted:function(R){return Bn(p,void 0,void 0,function(){var C=this;return Fn(this,function(A){return bl(c,R.filename,R.name,R,R.uploadMethod).then(function(M){return Bn(C,void 0,void 0,function(){var O,y;return Fn(this,function(w){return M.code!==0?(h.onFail(M),[2]):((O=M.data).type=d.type,O.name=R.name||R.filename,l===ke.AUDIO?(typeof d.arrayBuffer=="function"?d.arrayBuffer().then(ha).then(function($){Object.assign(O,$),h.onSuccess(O)},function(){h.onSuccess(O)}):((y=new FileReader).onload=function(){y.result?ha(y.result).then(function($){Object.assign(O,$),h.onSuccess(O)},function(){h.onSuccess(O)}):h.onSuccess(O)},y.onerror=function(){O.duration=0,h.onSuccess(O)},y.readAsArrayBuffer(d)),[2]):(c===ke.IMAGE&&(O.thumbnail=R.thumbnail),h.onSuccess(O),[2]))})})}).catch(function(M){h.onFail(M)}),[2]})})},onError:function(R){h.onFail(R)}})})})(r.file,n,{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);Oc(t,h,s).then(o)},onFail:function(d){o({code:S.UPLOAD_FILE_FAILED,msg:d||S[S.UPLOAD_FILE_FAILED]})}},((u=s)===null||u===void 0?void 0:u.thumbnailConfig)||{})})}}Jn(ke.FILE,function(n,e){return new ml({name:n.name,size:e.file.size,type:e.file.type,fileUrl:n.downloadUrl,user:e.user,extra:e.extra})});Jn(ke.IMAGE,function(n,e){return new ll({content:n.thumbnail,imageUri:n.downloadUrl,user:e.user,extra:e.extra})});Jn(ke.AUDIO,function(n,e){return new hl({remoteUrl:n.downloadUrl,duration:n.duration,type:n.type,user:e.user,extra:e.extra})});Jn(ke.SIGHT,function(n,e){return new pl({sightUrl:n.downloadUrl,content:e.thumbnail,duration:e.duration,size:e.file.size||n.size,name:e.name||n.name,user:e.user,extra:e.extra})});function si(n,e,t,r){return Ue("messageType",n,we.STRING,!0),Ue("isPersited",e,we.BOOLEAN,!0),Ue("isCounted",t,we.BOOLEAN,!0),ot.imClient.context.registerMessageType(n,e,t,r),it(n,e,t)}Jn(ke.COMBINE_HTML,function(n,e){return new gl({remoteUrl:n.downloadUrl,nameList:e.nameList,summaryList:e.summaryList,conversationType:e.conversationType,user:e.user,extra:e.extra})});Dt.add("imlib","5.1.1"),Dt.validEngine("~5.1.1")||Ke.error("The current engine version '"+Dt.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 F(n,e,t,r){return new(t||(t=Promise))(function(i,s){function o(l){try{d(r.next(l))}catch(h){s(h)}}function u(l){try{d(r.throw(l))}catch(h){s(h)}}function d(l){var h;l.done?i(l.value):(h=l.value,h instanceof t?h:new t(function(a){a(h)})).then(o,u)}d((r=r.apply(n,e||[])).next())})}const b=new wt("RCRTC");var I,Zi;(function(n){n[n.SUCCESS=1e4]="SUCCESS",n[n.SIGNAL_DISCONNECTED=5e4]="SIGNAL_DISCONNECTED",n[n.PARAMS_ERROR=50001]="PARAMS_ERROR",n[n.REPERT_JOIN_ROOM=50002]="REPERT_JOIN_ROOM",n[n.NOT_IN_ROOM=50003]="NOT_IN_ROOM",n[n.SERVICE_INVALID=50004]="SERVICE_INVALID",n[n.RTC_TOKEN_INVALID=50006]="RTC_TOKEN_INVALID",n[n.SIGNAL_ERROR=53001]="SIGNAL_ERROR",n[n.CREATE_OFFER_FAILED=53003]="CREATE_OFFER_FAILED",n[n.REQUEST_FAILED=53004]="REQUEST_FAILED",n[n.MCU_SERVER_NOT_FOUND=53005]="MCU_SERVER_NOT_FOUND",n[n.BROADCAST_SUB_LIST_NOT_EMPTY=53007]="BROADCAST_SUB_LIST_NOT_EMPTY",n[n.ROOM_HAS_BEEN_DESTROYED=53008]="ROOM_HAS_BEEN_DESTROYED",n[n.NOT_OPEN_VIDEO_AUDIO_SERVER=53009]="NOT_OPEN_VIDEO_AUDIO_SERVER",n[n.GET_USER_MEDIA_FAILED=53010]="GET_USER_MEDIA_FAILED",n[n.GET_DISPLAY_MEDIA_FAILED=53011]="GET_DISPLAY_MEDIA_FAILED",n[n.PERMISSION_DENIED=53012]="PERMISSION_DENIED",n[n.CREATE_CUSTOM_TRACK_FAILED=53013]="CREATE_CUSTOM_TRACK_FAILED",n[n.INVALID_TAGS=53014]="INVALID_TAGS",n[n.INVALID_USER_ID=53015]="INVALID_USER_ID",n[n.CREATE_FILE_TRACK_FAILED=53016]="CREATE_FILE_TRACK_FAILED",n[n.INVALID_FILE_INSTANCE=53017]="INVALID_FILE_INSTANCE",n[n.SET_REMOTE_DESCRIPTION_FAILED=53018]="SET_REMOTE_DESCRIPTION_FAILED",n[n.BROWSER_NOT_SUPPORT=53019]="BROWSER_NOT_SUPPORT",n[n.TRACK_NOT_READY=53020]="TRACK_NOT_READY",n[n.VIDEO_TRACK_MISS_MEDIA_ELEMENT=53021]="VIDEO_TRACK_MISS_MEDIA_ELEMENT",n[n.TRACK_PLAY_ERROR=53022]="TRACK_PLAY_ERROR",n[n.SIGNAL_AUDIENCE_JOIN_ROOM_FAILED=53023]="SIGNAL_AUDIENCE_JOIN_ROOM_FAILED",n[n.SIGNAL_ROOM_CHANGE_IDENTITY_FAILED=53024]="SIGNAL_ROOM_CHANGE_IDENTITY_FAILED",n[n.PACKAGE_ENVIRONMENT_ERROR=53025]="PACKAGE_ENVIRONMENT_ERROR",n[n.PUBLISH_TRACK_LIMIT_EXCEEDED=53026]="PUBLISH_TRACK_LIMIT_EXCEEDED",n[n.CDN_RESOURCE_IS_EMPTY=53027]="CDN_RESOURCE_IS_EMPTY",n[n.SIGNAL_JOIN_RTC_ROOM_REFUSED=53028]="SIGNAL_JOIN_RTC_ROOM_REFUSED",n[n.NO_PERMISSION_TO_USE_REQUESTED_DEVICE=53029]="NO_PERMISSION_TO_USE_REQUESTED_DEVICE",n[n.THE_FUNCTION_IS_DISABLED_IN_PKROOM=53030]="THE_FUNCTION_IS_DISABLED_IN_PKROOM"})(I||(I={})),function(n){n[n.JOIN_REFUSED=40032]="JOIN_REFUSED"}(Zi||(Zi={}));class Nc{constructor(){this.queue=[],this.locked=!1}checkToStart(){return F(this,void 0,void 0,function*(){if(this.queue.length===0||this.locked)return;this.locked=!0;const{resolve:e,task:t,reject:r}=this.queue.shift();let i;try{i=yield t(),e(i)}catch(s){r(s)}this.locked=!1,this.checkToStart()})}push(e){const t=new Promise((r,i)=>{this.queue.push({resolve:r,task:e,reject:i})});return this.checkToStart(),t}}const Ol=new Nc,Se=n=>Ol.push(n);let wc=!0,Ac=!0;function En(n,e,t){const r=n.match(e);return r&&r.length>=t&&parseInt(r[t],10)}function cn(n,e,t){if(!n.RTCPeerConnection)return;const r=n.RTCPeerConnection.prototype,i=r.addEventListener;r.addEventListener=function(o,u){if(o!==e)return i.apply(this,arguments);const d=l=>{const h=t(l);h&&(u.handleEvent?u.handleEvent(h):u(h))};return this._eventMap=this._eventMap||{},this._eventMap[e]||(this._eventMap[e]=new Map),this._eventMap[e].set(u,d),i.apply(this,[o,d])};const s=r.removeEventListener;r.removeEventListener=function(o,u){if(o!==e||!this._eventMap||!this._eventMap[e])return s.apply(this,arguments);if(!this._eventMap[e].has(u))return s.apply(this,arguments);const d=this._eventMap[e].get(u);return this._eventMap[e].delete(u),this._eventMap[e].size===0&&delete this._eventMap[e],Object.keys(this._eventMap).length===0&&delete this._eventMap,s.apply(this,[o,d])},Object.defineProperty(r,"on"+e,{get(){return this["_on"+e]},set(o){this["_on"+e]&&(this.removeEventListener(e,this["_on"+e]),delete this["_on"+e]),o&&this.addEventListener(e,this["_on"+e]=o)},enumerable:!0,configurable:!0})}function Nl(n){return typeof n!="boolean"?new Error("Argument type: "+typeof n+". Please use a boolean."):(wc=n,n?"adapter.js logging disabled":"adapter.js logging enabled")}function wl(n){return typeof n!="boolean"?new Error("Argument type: "+typeof n+". Please use a boolean."):(Ac=!n,"adapter.js deprecation warnings "+(n?"disabled":"enabled"))}function uo(){if(typeof window=="object"){if(wc)return;typeof console!="undefined"&&typeof console.log=="function"&&console.log.apply(console,arguments)}}function oi(n,e){Ac&&console.warn(n+" is deprecated, please use "+e+" instead.")}function pa(n){return Object.prototype.toString.call(n)==="[object Object]"}function Mc(n){return pa(n)?Object.keys(n).reduce(function(e,t){const r=pa(n[t]),i=r?Mc(n[t]):n[t],s=r&&!Object.keys(i).length;return i===void 0||s?e:Object.assign(e,{[t]:i})},{}):n}function es(n,e,t){e&&!t.has(e.id)&&(t.set(e.id,e),Object.keys(e).forEach(r=>{r.endsWith("Id")?es(n,n.get(e[r]),t):r.endsWith("Ids")&&e[r].forEach(i=>{es(n,n.get(i),t)})}))}function fa(n,e,t){const r=t?"outbound-rtp":"inbound-rtp",i=new Map;if(e===null)return i;const s=[];return n.forEach(o=>{o.type==="track"&&o.trackIdentifier===e.id&&s.push(o)}),s.forEach(o=>{n.forEach(u=>{u.type===r&&u.trackId===o.id&&es(n,u,i)})}),i}const ga=uo;function Pc(n,e){const t=n&&n.navigator;if(!t.mediaDevices)return;const r=function(o){if(typeof o!="object"||o.mandatory||o.optional)return o;const u={};return Object.keys(o).forEach(d=>{if(d==="require"||d==="advanced"||d==="mediaSource")return;const l=typeof o[d]=="object"?o[d]:{ideal:o[d]};l.exact!==void 0&&typeof l.exact=="number"&&(l.min=l.max=l.exact);const h=function(a,c){return a?a+c.charAt(0).toUpperCase()+c.slice(1):c==="deviceId"?"sourceId":c};if(l.ideal!==void 0){u.optional=u.optional||[];let a={};typeof l.ideal=="number"?(a[h("min",d)]=l.ideal,u.optional.push(a),a={},a[h("max",d)]=l.ideal,u.optional.push(a)):(a[h("",d)]=l.ideal,u.optional.push(a))}l.exact!==void 0&&typeof l.exact!="number"?(u.mandatory=u.mandatory||{},u.mandatory[h("",d)]=l.exact):["min","max"].forEach(a=>{l[a]!==void 0&&(u.mandatory=u.mandatory||{},u.mandatory[h(a,d)]=l[a])})}),o.advanced&&(u.optional=(u.optional||[]).concat(o.advanced)),u},i=function(o,u){if(e.version>=61)return u(o);if((o=JSON.parse(JSON.stringify(o)))&&typeof o.audio=="object"){const d=function(l,h,a){h in l&&!(a in l)&&(l[a]=l[h],delete l[h])};d((o=JSON.parse(JSON.stringify(o))).audio,"autoGainControl","googAutoGainControl"),d(o.audio,"noiseSuppression","googNoiseSuppression"),o.audio=r(o.audio)}if(o&&typeof o.video=="object"){let d=o.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")&&(!t.mediaDevices.getSupportedConstraints||!t.mediaDevices.getSupportedConstraints().facingMode||l)){let h;if(delete o.video.facingMode,d.exact==="environment"||d.ideal==="environment"?h=["back","rear"]:d.exact!=="user"&&d.ideal!=="user"||(h=["front"]),h)return t.mediaDevices.enumerateDevices().then(a=>{let c=(a=a.filter(p=>p.kind==="videoinput")).find(p=>h.some(f=>p.label.toLowerCase().includes(f)));return!c&&a.length&&h.includes("back")&&(c=a[a.length-1]),c&&(o.video.deviceId=d.exact?{exact:c.deviceId}:{ideal:c.deviceId}),o.video=r(o.video),ga("chrome: "+JSON.stringify(o)),u(o)})}o.video=r(o.video)}return ga("chrome: "+JSON.stringify(o)),u(o)},s=function(o){return e.version>=64?o:{name:{PermissionDeniedError:"NotAllowedError",PermissionDismissedError:"NotAllowedError",InvalidStateError:"NotAllowedError",DevicesNotFoundError:"NotFoundError",ConstraintNotSatisfiedError:"OverconstrainedError",TrackStartError:"NotReadableError",MediaDeviceFailedDueToShutdown:"NotAllowedError",MediaDeviceKillSwitchOn:"NotAllowedError",TabCaptureError:"AbortError",ScreenCaptureError:"AbortError",DeviceCaptureError:"AbortError"}[o.name]||o.name,message:o.message,constraint:o.constraint||o.constraintName,toString(){return this.name+(this.message&&": ")+this.message}}};if(t.getUserMedia=function(o,u,d){i(o,l=>{t.webkitGetUserMedia(l,u,h=>{d&&d(s(h))})})}.bind(t),t.mediaDevices.getUserMedia){const o=t.mediaDevices.getUserMedia.bind(t.mediaDevices);t.mediaDevices.getUserMedia=function(u){return i(u,d=>o(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(s(l))))}}}function Lc(n){n.MediaStream=n.MediaStream||n.webkitMediaStream}function kc(n){if(typeof n=="object"&&n.RTCPeerConnection&&!("ontrack"in n.RTCPeerConnection.prototype)){Object.defineProperty(n.RTCPeerConnection.prototype,"ontrack",{get(){return this._ontrack},set(t){this._ontrack&&this.removeEventListener("track",this._ontrack),this.addEventListener("track",this._ontrack=t)},enumerable:!0,configurable:!0});const e=n.RTCPeerConnection.prototype.setRemoteDescription;n.RTCPeerConnection.prototype.setRemoteDescription=function(){return this._ontrackpoly||(this._ontrackpoly=t=>{t.stream.addEventListener("addtrack",r=>{let i;i=n.RTCPeerConnection.prototype.getReceivers?this.getReceivers().find(o=>o.track&&o.track.id===r.track.id):{track:r.track};const s=new Event("track");s.track=r.track,s.receiver=i,s.transceiver={receiver:i},s.streams=[t.stream],this.dispatchEvent(s)}),t.stream.getTracks().forEach(r=>{let i;i=n.RTCPeerConnection.prototype.getReceivers?this.getReceivers().find(o=>o.track&&o.track.id===r.id):{track:r};const s=new Event("track");s.track=r,s.receiver=i,s.transceiver={receiver:i},s.streams=[t.stream],this.dispatchEvent(s)})},this.addEventListener("addstream",this._ontrackpoly)),e.apply(this,arguments)}}else cn(n,"track",e=>(e.transceiver||Object.defineProperty(e,"transceiver",{value:{receiver:e.receiver}}),e))}function Uc(n){if(typeof n=="object"&&n.RTCPeerConnection&&!("getSenders"in n.RTCPeerConnection.prototype)&&"createDTMFSender"in n.RTCPeerConnection.prototype){const e=function(i,s){return{track:s,get dtmf(){return this._dtmf===void 0&&(s.kind==="audio"?this._dtmf=i.createDTMFSender(s):this._dtmf=null),this._dtmf},_pc:i}};if(!n.RTCPeerConnection.prototype.getSenders){n.RTCPeerConnection.prototype.getSenders=function(){return this._senders=this._senders||[],this._senders.slice()};const i=n.RTCPeerConnection.prototype.addTrack;n.RTCPeerConnection.prototype.addTrack=function(o,u){let d=i.apply(this,arguments);return d||(d=e(this,o),this._senders.push(d)),d};const s=n.RTCPeerConnection.prototype.removeTrack;n.RTCPeerConnection.prototype.removeTrack=function(o){s.apply(this,arguments);const u=this._senders.indexOf(o);u!==-1&&this._senders.splice(u,1)}}const t=n.RTCPeerConnection.prototype.addStream;n.RTCPeerConnection.prototype.addStream=function(i){this._senders=this._senders||[],t.apply(this,[i]),i.getTracks().forEach(s=>{this._senders.push(e(this,s))})};const r=n.RTCPeerConnection.prototype.removeStream;n.RTCPeerConnection.prototype.removeStream=function(i){this._senders=this._senders||[],r.apply(this,[i]),i.getTracks().forEach(s=>{const o=this._senders.find(u=>u.track===s);o&&this._senders.splice(this._senders.indexOf(o),1)})}}else if(typeof n=="object"&&n.RTCPeerConnection&&"getSenders"in n.RTCPeerConnection.prototype&&"createDTMFSender"in n.RTCPeerConnection.prototype&&n.RTCRtpSender&&!("dtmf"in n.RTCRtpSender.prototype)){const e=n.RTCPeerConnection.prototype.getSenders;n.RTCPeerConnection.prototype.getSenders=function(){const t=e.apply(this,[]);return t.forEach(r=>r._pc=this),t},Object.defineProperty(n.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 Dc(n){if(!n.RTCPeerConnection)return;const e=n.RTCPeerConnection.prototype.getStats;n.RTCPeerConnection.prototype.getStats=function(){const[t,r,i]=arguments;if(arguments.length>0&&typeof t=="function")return e.apply(this,arguments);if(e.length===0&&(arguments.length===0||typeof t!="function"))return e.apply(this,[]);const s=function(u){const d={};return u.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},o=function(u){return new Map(Object.keys(u).map(d=>[d,u[d]]))};if(arguments.length>=2){const u=function(d){r(o(s(d)))};return e.apply(this,[u,t])}return new Promise((u,d)=>{e.apply(this,[function(l){u(o(s(l)))},d])}).then(r,i)}}function xc(n){if(!(typeof n=="object"&&n.RTCPeerConnection&&n.RTCRtpSender&&n.RTCRtpReceiver))return;if(!("getStats"in n.RTCRtpSender.prototype)){const t=n.RTCPeerConnection.prototype.getSenders;t&&(n.RTCPeerConnection.prototype.getSenders=function(){const i=t.apply(this,[]);return i.forEach(s=>s._pc=this),i});const r=n.RTCPeerConnection.prototype.addTrack;r&&(n.RTCPeerConnection.prototype.addTrack=function(){const i=r.apply(this,arguments);return i._pc=this,i}),n.RTCRtpSender.prototype.getStats=function(){const i=this;return this._pc.getStats().then(s=>fa(s,i.track,!0))}}if(!("getStats"in n.RTCRtpReceiver.prototype)){const t=n.RTCPeerConnection.prototype.getReceivers;t&&(n.RTCPeerConnection.prototype.getReceivers=function(){const r=t.apply(this,[]);return r.forEach(i=>i._pc=this),r}),cn(n,"track",r=>(r.receiver._pc=r.srcElement,r)),n.RTCRtpReceiver.prototype.getStats=function(){const r=this;return this._pc.getStats().then(i=>fa(i,r.track,!1))}}if(!("getStats"in n.RTCRtpSender.prototype)||!("getStats"in n.RTCRtpReceiver.prototype))return;const e=n.RTCPeerConnection.prototype.getStats;n.RTCPeerConnection.prototype.getStats=function(){if(arguments.length>0&&arguments[0]instanceof n.MediaStreamTrack){const t=arguments[0];let r,i,s;return this.getSenders().forEach(o=>{o.track===t&&(r?s=!0:r=o)}),this.getReceivers().forEach(o=>(o.track===t&&(i?s=!0:i=o),o.track===t)),s||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 Vc(n){n.RTCPeerConnection.prototype.getLocalStreams=function(){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},Object.keys(this._shimmedLocalStreams).map(s=>this._shimmedLocalStreams[s][0])};const e=n.RTCPeerConnection.prototype.addTrack;n.RTCPeerConnection.prototype.addTrack=function(s,o){if(!o)return e.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};const u=e.apply(this,arguments);return this._shimmedLocalStreams[o.id]?this._shimmedLocalStreams[o.id].indexOf(u)===-1&&this._shimmedLocalStreams[o.id].push(u):this._shimmedLocalStreams[o.id]=[o,u],u};const t=n.RTCPeerConnection.prototype.addStream;n.RTCPeerConnection.prototype.addStream=function(s){this._shimmedLocalStreams=this._shimmedLocalStreams||{},s.getTracks().forEach(d=>{if(this.getSenders().find(l=>l.track===d))throw new DOMException("Track already exists.","InvalidAccessError")});const o=this.getSenders();t.apply(this,arguments);const u=this.getSenders().filter(d=>o.indexOf(d)===-1);this._shimmedLocalStreams[s.id]=[s].concat(u)};const r=n.RTCPeerConnection.prototype.removeStream;n.RTCPeerConnection.prototype.removeStream=function(s){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},delete this._shimmedLocalStreams[s.id],r.apply(this,arguments)};const i=n.RTCPeerConnection.prototype.removeTrack;n.RTCPeerConnection.prototype.removeTrack=function(s){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},s&&Object.keys(this._shimmedLocalStreams).forEach(o=>{const u=this._shimmedLocalStreams[o].indexOf(s);u!==-1&&this._shimmedLocalStreams[o].splice(u,1),this._shimmedLocalStreams[o].length===1&&delete this._shimmedLocalStreams[o]}),i.apply(this,arguments)}}function Bc(n,e){if(!n.RTCPeerConnection)return;if(n.RTCPeerConnection.prototype.addTrack&&e.version>=65)return Vc(n);const t=n.RTCPeerConnection.prototype.getLocalStreams;n.RTCPeerConnection.prototype.getLocalStreams=function(){const l=t.apply(this);return this._reverseStreams=this._reverseStreams||{},l.map(h=>this._reverseStreams[h.id])};const r=n.RTCPeerConnection.prototype.addStream;n.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 n.MediaStream(l.getTracks());this._streams[l.id]=h,this._reverseStreams[h.id]=l,l=h}r.apply(this,[l])};const i=n.RTCPeerConnection.prototype.removeStream;function s(l,h){let a=h.sdp;return Object.keys(l._reverseStreams||[]).forEach(c=>{const p=l._reverseStreams[c],f=l._streams[p.id];a=a.replace(new RegExp(f.id,"g"),p.id)}),new RTCSessionDescription({type:h.type,sdp:a})}function o(l,h){let a=h.sdp;return Object.keys(l._reverseStreams||[]).forEach(c=>{const p=l._reverseStreams[c],f=l._streams[p.id];a=a.replace(new RegExp(p.id,"g"),f.id)}),new RTCSessionDescription({type:h.type,sdp:a})}n.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]},n.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(f=>f===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(f=>f.track===l))throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};const p=this._streams[h.id];if(p)p.addTrack(l),Promise.resolve().then(()=>{this.dispatchEvent(new Event("negotiationneeded"))});else{const f=new n.MediaStream([l]);this._streams[h.id]=f,this._reverseStreams[f.id]=h,this.addStream(f)}return this.getSenders().find(f=>f.track===l)},["createOffer","createAnswer"].forEach(function(l){const h=n.RTCPeerConnection.prototype[l],a={[l](){const c=arguments;return arguments.length&&typeof arguments[0]=="function"?h.apply(this,[p=>{const f=s(this,p);c[0].apply(null,[f])},p=>{c[1]&&c[1].apply(null,p)},arguments[2]]):h.apply(this,arguments).then(p=>s(this,p))}};n.RTCPeerConnection.prototype[l]=a[l]});const u=n.RTCPeerConnection.prototype.setLocalDescription;n.RTCPeerConnection.prototype.setLocalDescription=function(){return arguments.length&&arguments[0].type?(arguments[0]=o(this,arguments[0]),u.apply(this,arguments)):u.apply(this,arguments)};const d=Object.getOwnPropertyDescriptor(n.RTCPeerConnection.prototype,"localDescription");Object.defineProperty(n.RTCPeerConnection.prototype,"localDescription",{get(){const l=d.get.apply(this);return l.type===""?l:s(this,l)}}),n.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(c=>l.track===c)&&(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 ts(n,e){!n.RTCPeerConnection&&n.webkitRTCPeerConnection&&(n.RTCPeerConnection=n.webkitRTCPeerConnection),n.RTCPeerConnection&&e.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(t){const r=n.RTCPeerConnection.prototype[t],i={[t](){return arguments[0]=new(t==="addIceCandidate"?n.RTCIceCandidate:n.RTCSessionDescription)(arguments[0]),r.apply(this,arguments)}};n.RTCPeerConnection.prototype[t]=i[t]})}function Fc(n,e){cn(n,"negotiationneeded",t=>{const r=t.target;if(!(e.version<72||r.getConfiguration&&r.getConfiguration().sdpSemantics==="plan-b")||r.signalingState==="stable")return t})}var ma=Object.freeze({__proto__:null,shimMediaStream:Lc,shimOnTrack:kc,shimGetSendersWithDtmf:Uc,shimGetStats:Dc,shimSenderReceiverGetStats:xc,shimAddTrackRemoveTrackWithNative:Vc,shimAddTrackRemoveTrack:Bc,shimPeerConnection:ts,fixNegotiationNeeded:Fc,shimGetUserMedia:Pc,shimGetDisplayMedia:function(n,e){n.navigator.mediaDevices&&"getDisplayMedia"in n.navigator.mediaDevices||n.navigator.mediaDevices&&(typeof e=="function"?n.navigator.mediaDevices.getDisplayMedia=function(t){return e(t).then(r=>{const i=t.video&&t.video.width,s=t.video&&t.video.height,o=t.video&&t.video.frameRate;return t.video={mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:r,maxFrameRate:o||3}},i&&(t.video.mandatory.maxWidth=i),s&&(t.video.mandatory.maxHeight=s),n.navigator.mediaDevices.getUserMedia(t)})}:console.error("shimGetDisplayMedia: getSourceId argument is not a function"))}}),_a,Ti,X=(_a=function(n){var e={generateIdentifier:function(){return Math.random().toString(36).substr(2,10)}};e.localCName=e.generateIdentifier(),e.splitLines=function(t){return t.trim().split(` `).map(function(r){return r.trim()})},e.splitSections=function(t){return t.split(` m=`).map(function(r,i){return(i>0?"m="+r:r).trim()+`\r `})},e.getDescription=function(t){var r=e.splitSections(t);return r&&r[0]},e.getMediaSections=function(t){var r=e.splitSections(t);return r.shift(),r},e.matchPrefix=function(t,r){return e.splitLines(t).filter(function(i){return i.indexOf(r)===0})},e.parseCandidate=function(t){for(var r,i={foundation:(r=t.indexOf("a=candidate:")===0?t.substring(12).split(" "):t.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]},s=8;s0?r[0].split("/")[1]:"sendrecv",uri:r[1]}},e.writeExtmap=function(t){return"a=extmap:"+(t.id||t.preferredId)+(t.direction&&t.direction!=="sendrecv"?"/"+t.direction:"")+" "+t.uri+`\r `},e.parseFmtp=function(t){for(var r,i={},s=t.substr(t.indexOf(" ")+1).split(";"),o=0;o-1?(i.attribute=t.substr(r+1,s-r-1),i.value=t.substr(s+1)):i.attribute=t.substr(r+1),i},e.parseSsrcGroup=function(t){var r=t.substr(13).split(" ");return{semantics:r.shift(),ssrcs:r.map(function(i){return parseInt(i,10)})}},e.getMid=function(t){var r=e.matchPrefix(t,"a=mid:")[0];if(r)return r.substr(6)},e.parseFingerprint=function(t){var r=t.substr(14).split(" ");return{algorithm:r[0].toLowerCase(),value:r[1]}},e.getDtlsParameters=function(t,r){return{role:"auto",fingerprints:e.matchPrefix(t+r,"a=fingerprint:").map(e.parseFingerprint)}},e.writeDtlsParameters=function(t,r){var i="a=setup:"+r+`\r `;return t.fingerprints.forEach(function(s){i+="a=fingerprint:"+s.algorithm+" "+s.value+`\r `}),i},e.parseCryptoLine=function(t){var r=t.substr(9).split(" ");return{tag:parseInt(r[0],10),cryptoSuite:r[1],keyParams:r[2],sessionParams:r.slice(3)}},e.writeCryptoLine=function(t){return"a=crypto:"+t.tag+" "+t.cryptoSuite+" "+(typeof t.keyParams=="object"?e.writeCryptoKeyParams(t.keyParams):t.keyParams)+(t.sessionParams?" "+t.sessionParams.join(" "):"")+`\r `},e.parseCryptoKeyParams=function(t){if(t.indexOf("inline:")!==0)return null;var r=t.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(t){return t.keyMethod+":"+t.keySalt+(t.lifeTime?"|"+t.lifeTime:"")+(t.mkiValue&&t.mkiLength?"|"+t.mkiValue+":"+t.mkiLength:"")},e.getCryptoParameters=function(t,r){return e.matchPrefix(t+r,"a=crypto:").map(e.parseCryptoLine)},e.getIceParameters=function(t,r){var i=e.matchPrefix(t+r,"a=ice-ufrag:")[0],s=e.matchPrefix(t+r,"a=ice-pwd:")[0];return i&&s?{usernameFragment:i.substr(12),password:s.substr(10)}:null},e.writeIceParameters=function(t){return"a=ice-ufrag:"+t.usernameFragment+`\r a=ice-pwd:`+t.password+`\r `},e.parseRtpParameters=function(t){for(var r={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},i=e.splitLines(t)[0].split(" "),s=3;s0?"9":"0",i+=" UDP/TLS/RTP/SAVPF ",i+=r.codecs.map(function(o){return o.preferredPayloadType!==void 0?o.preferredPayloadType:o.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(o){i+=e.writeRtpMap(o),i+=e.writeFmtp(o),i+=e.writeRtcpFb(o)});var s=0;return r.codecs.forEach(function(o){o.maxptime>s&&(s=o.maxptime)}),s>0&&(i+="a=maxptime:"+s+`\r `),i+=`a=rtcp-mux\r `,r.headerExtensions&&r.headerExtensions.forEach(function(o){i+=e.writeExtmap(o)}),i},e.parseRtpEncodingParameters=function(t){var r,i=[],s=e.parseRtpParameters(t),o=s.fecMechanisms.indexOf("RED")!==-1,u=s.fecMechanisms.indexOf("ULPFEC")!==-1,d=e.matchPrefix(t,"a=ssrc:").map(function(c){return e.parseSsrcMedia(c)}).filter(function(c){return c.attribute==="cname"}),l=d.length>0&&d[0].ssrc,h=e.matchPrefix(t,"a=ssrc-group:FID").map(function(c){return c.substr(17).split(" ").map(function(p){return parseInt(p,10)})});h.length>0&&h[0].length>1&&h[0][0]===l&&(r=h[0][1]),s.codecs.forEach(function(c){if(c.name.toUpperCase()==="RTX"&&c.parameters.apt){var p={ssrc:l,codecPayloadType:parseInt(c.parameters.apt,10)};l&&r&&(p.rtx={ssrc:r}),i.push(p),o&&((p=JSON.parse(JSON.stringify(p))).fec={ssrc:l,mechanism:u?"red+ulpfec":"red"},i.push(p))}}),i.length===0&&l&&i.push({ssrc:l});var a=e.matchPrefix(t,"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(c){c.maxBitrate=a})),i},e.parseRtcpParameters=function(t){var r={},i=e.matchPrefix(t,"a=ssrc:").map(function(u){return e.parseSsrcMedia(u)}).filter(function(u){return u.attribute==="cname"})[0];i&&(r.cname=i.value,r.ssrc=i.ssrc);var s=e.matchPrefix(t,"a=rtcp-rsize");r.reducedSize=s.length>0,r.compound=s.length===0;var o=e.matchPrefix(t,"a=rtcp-mux");return r.mux=o.length>0,r},e.parseMsid=function(t){var r,i=e.matchPrefix(t,"a=msid:");if(i.length===1)return{stream:(r=i[0].substr(7).split(" "))[0],track:r[1]};var s=e.matchPrefix(t,"a=ssrc:").map(function(o){return e.parseSsrcMedia(o)}).filter(function(o){return o.attribute==="msid"});return s.length>0?{stream:(r=s[0].value.split(" "))[0],track:r[1]}:void 0},e.parseSctpDescription=function(t){var r,i=e.parseMLine(t),s=e.matchPrefix(t,"a=max-message-size:");s.length>0&&(r=parseInt(s[0].substr(19),10)),isNaN(r)&&(r=65536);var o=e.matchPrefix(t,"a=sctp-port:");if(o.length>0)return{port:parseInt(o[0].substr(12),10),protocol:i.fmt,maxMessageSize:r};if(e.matchPrefix(t,"a=sctpmap:").length>0){var u=e.matchPrefix(t,"a=sctpmap:")[0].substr(10).split(" ");return{port:parseInt(u[0],10),protocol:u[1],maxMessageSize:r}}},e.writeSctpDescription=function(t,r){var i=[];return i=t.protocol!=="DTLS/SCTP"?["m="+t.kind+" 9 "+t.protocol+" "+r.protocol+`\r `,`c=IN IP4 0.0.0.0\r `,"a=sctp-port:"+r.port+`\r `]:["m="+t.kind+" 9 "+t.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(t,r,i){var s=r!==void 0?r:2;return`v=0\r o=`+(i||"thisisadapterortc")+" "+(t||e.generateSessionId())+" "+s+` IN IP4 127.0.0.1\r s=-\r t=0 0\r `},e.writeMediaSection=function(t,r,i,s){var o=e.writeRtpDescription(t.kind,r);if(o+=e.writeIceParameters(t.iceGatherer.getLocalParameters()),o+=e.writeDtlsParameters(t.dtlsTransport.getLocalParameters(),i==="offer"?"actpass":"active"),o+="a=mid:"+t.mid+`\r `,t.direction?o+="a="+t.direction+`\r `:t.rtpSender&&t.rtpReceiver?o+=`a=sendrecv\r `:t.rtpSender?o+=`a=sendonly\r `:t.rtpReceiver?o+=`a=recvonly\r `:o+=`a=inactive\r `,t.rtpSender){var u="msid:"+s.id+" "+t.rtpSender.track.id+`\r `;o+="a="+u,o+="a=ssrc:"+t.sendEncodingParameters[0].ssrc+" "+u,t.sendEncodingParameters[0].rtx&&(o+="a=ssrc:"+t.sendEncodingParameters[0].rtx.ssrc+" "+u,o+="a=ssrc-group:FID "+t.sendEncodingParameters[0].ssrc+" "+t.sendEncodingParameters[0].rtx.ssrc+`\r `)}return o+="a=ssrc:"+t.sendEncodingParameters[0].ssrc+" cname:"+e.localCName+`\r `,t.rtpSender&&t.sendEncodingParameters[0].rtx&&(o+="a=ssrc:"+t.sendEncodingParameters[0].rtx.ssrc+" cname:"+e.localCName+`\r `),o},e.getDirection=function(t,r){for(var i=e.splitLines(t),s=0;s=14393&&_.indexOf("?transport=udp")===-1:(c=!0,!0)}),delete p.url,p.urls=m?f[0]:f,!!f.length}})}(o.iceServers||[],e),this._iceGatherers=[],o.iceCandidatePoolSize)for(var l=o.iceCandidatePoolSize;l>0;l--)this._iceGatherers.push(new n.RTCIceGatherer({iceServers:o.iceServers,gatherPolicy:o.iceTransportPolicy}));else o.iceCandidatePoolSize=0;this._config=o,this.transceivers=[],this._sdpSessionId=X.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(o,u){this._isClosed||(this.dispatchEvent(u),typeof this["on"+o]=="function"&&this["on"+o](u))},i.prototype._emitGatheringStateChange=function(){var o=new Event("icegatheringstatechange");this._dispatchEvent("icegatheringstatechange",o)},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(o,u){var d=this.transceivers.length>0,l={track:null,iceGatherer:null,iceTransport:null,dtlsTransport:null,localCapabilities:null,remoteCapabilities:null,rtpSender:null,rtpReceiver:null,kind:o,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 u||this.transceivers.push(l),l},i.prototype.addTrack=function(o,u){if(this._isClosed)throw De("InvalidStateError","Attempted to call addTrack on a closed peerconnection.");var d;if(this.transceivers.find(function(h){return h.track===o}))throw De("InvalidAccessError","Track already exists.");for(var l=0;l=15025)o.getTracks().forEach(function(l){u.addTrack(l,o)});else{var d=o.clone();o.getTracks().forEach(function(l,h){var a=d.getTracks()[h];l.addEventListener("enabled",function(c){a.enabled=c.enabled})}),d.getTracks().forEach(function(l){u.addTrack(l,d)})}},i.prototype.removeTrack=function(o){if(this._isClosed)throw De("InvalidStateError","Attempted to call removeTrack on a closed peerconnection.");if(!(o instanceof n.RTCRtpSender))throw new TypeError("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.");var u=this.transceivers.find(function(l){return l.rtpSender===o});if(!u)throw De("InvalidAccessError","Sender was not created by this connection.");var d=u.stream;u.rtpSender.stop(),u.rtpSender=null,u.track=null,u.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(o){var u=this;o.getTracks().forEach(function(d){var l=u.getSenders().find(function(h){return h.track===d});l&&u.removeTrack(l)})},i.prototype.getSenders=function(){return this.transceivers.filter(function(o){return!!o.rtpSender}).map(function(o){return o.rtpSender})},i.prototype.getReceivers=function(){return this.transceivers.filter(function(o){return!!o.rtpReceiver}).map(function(o){return o.rtpReceiver})},i.prototype._createIceGatherer=function(o,u){var d=this;if(u&&o>0)return this.transceivers[0].iceGatherer;if(this._iceGatherers.length)return this._iceGatherers.shift();var l=new n.RTCIceGatherer({iceServers:this._config.iceServers,gatherPolicy:this._config.iceTransportPolicy});return Object.defineProperty(l,"state",{value:"new",writable:!0}),this.transceivers[o].bufferedCandidateEvents=[],this.transceivers[o].bufferCandidates=function(h){var a=!h.candidate||Object.keys(h.candidate).length===0;l.state=a?"completed":"gathering",d.transceivers[o].bufferedCandidateEvents!==null&&d.transceivers[o].bufferedCandidateEvents.push(h)},l.addEventListener("localcandidate",this.transceivers[o].bufferCandidates),l},i.prototype._gather=function(o,u){var d=this,l=this.transceivers[u].iceGatherer;if(!l.onlocalcandidate){var h=this.transceivers[u].bufferedCandidateEvents;this.transceivers[u].bufferedCandidateEvents=null,l.removeEventListener("localcandidate",this.transceivers[u].bufferCandidates),l.onlocalcandidate=function(a){if(!(d.usingBundle&&u>0)){var c=new Event("icecandidate");c.candidate={sdpMid:o,sdpMLineIndex:u};var p=a.candidate,f=!p||Object.keys(p).length===0;if(f)l.state!=="new"&&l.state!=="gathering"||(l.state="completed");else{l.state==="new"&&(l.state="gathering"),p.component=1,p.ufrag=l.getLocalParameters().usernameFragment;var m=X.writeCandidate(p);c.candidate=Object.assign(c.candidate,X.parseCandidate(m)),c.candidate.candidate=m,c.candidate.toJSON=function(){return{candidate:c.candidate.candidate,sdpMid:c.candidate.sdpMid,sdpMLineIndex:c.candidate.sdpMLineIndex,usernameFragment:c.candidate.usernameFragment}}}var _=X.getMediaSections(d._localDescription.sdp);_[c.candidate.sdpMLineIndex]+=f?`a=end-of-candidates\r `:"a="+c.candidate.candidate+`\r `,d._localDescription.sdp=X.getDescription(d._localDescription.sdp)+_.join("");var v=d.transceivers.every(function(R){return R.iceGatherer&&R.iceGatherer.state==="completed"});d.iceGatheringState!=="gathering"&&(d.iceGatheringState="gathering",d._emitGatheringStateChange()),f||d._dispatchEvent("icecandidate",c),v&&(d._dispatchEvent("icecandidate",new Event("icecandidate")),d.iceGatheringState="complete",d._emitGatheringStateChange())}},n.setTimeout(function(){h.forEach(function(a){l.onlocalcandidate(a)})},0)}},i.prototype._createIceAndDtlsTransports=function(){var o=this,u=new n.RTCIceTransport(null);u.onicestatechange=function(){o._updateIceConnectionState(),o._updateConnectionState()};var d=new n.RTCDtlsTransport(u);return d.ondtlsstatechange=function(){o._updateConnectionState()},d.onerror=function(){Object.defineProperty(d,"state",{value:"failed",writable:!0}),o._updateConnectionState()},{iceTransport:u,dtlsTransport:d}},i.prototype._disposeIceAndDtlsTransports=function(o){var u=this.transceivers[o].iceGatherer;u&&(delete u.onlocalcandidate,delete this.transceivers[o].iceGatherer);var d=this.transceivers[o].iceTransport;d&&(delete d.onicestatechange,delete this.transceivers[o].iceTransport);var l=this.transceivers[o].dtlsTransport;l&&(delete l.ondtlsstatechange,delete l.onerror,delete this.transceivers[o].dtlsTransport)},i.prototype._transceive=function(o,u,d){var l=lr(o.localCapabilities,o.remoteCapabilities);u&&o.rtpSender&&(l.encodings=o.sendEncodingParameters,l.rtcp={cname:X.localCName,compound:o.rtcpParameters.compound},o.recvEncodingParameters.length&&(l.rtcp.ssrc=o.recvEncodingParameters[0].ssrc),o.rtpSender.send(l)),d&&o.rtpReceiver&&l.codecs.length>0&&(o.kind==="video"&&o.recvEncodingParameters&&e<15019&&o.recvEncodingParameters.forEach(function(h){delete h.rtx}),o.recvEncodingParameters.length?l.encodings=o.recvEncodingParameters:l.encodings=[{}],l.rtcp={compound:o.rtcpParameters.compound},o.rtcpParameters.cname&&(l.rtcp.cname=o.rtcpParameters.cname),o.sendEncodingParameters.length&&(l.rtcp.ssrc=o.sendEncodingParameters[0].ssrc),o.rtpReceiver.receive(l))},i.prototype.setLocalDescription=function(o){var u,d,l=this;if(["offer","answer"].indexOf(o.type)===-1)return Promise.reject(De("TypeError",'Unsupported type "'+o.type+'"'));if(!Ra("setLocalDescription",o.type,l.signalingState)||l._isClosed)return Promise.reject(De("InvalidStateError","Can not set local "+o.type+" in state "+l.signalingState));if(o.type==="offer")u=X.splitSections(o.sdp),d=u.shift(),u.forEach(function(a,c){var p=X.parseRtpParameters(a);l.transceivers[c].localCapabilities=p}),l.transceivers.forEach(function(a,c){l._gather(a.mid,c)});else if(o.type==="answer"){u=X.splitSections(l._remoteDescription.sdp),d=u.shift();var h=X.matchPrefix(d,"a=ice-lite").length>0;u.forEach(function(a,c){var p=l.transceivers[c],f=p.iceGatherer,m=p.iceTransport,_=p.dtlsTransport,v=p.localCapabilities,R=p.remoteCapabilities;if(!(X.isRejected(a)&&X.matchPrefix(a,"a=bundle-only").length===0)&&!p.rejected){var C=X.getIceParameters(a,d),A=X.getDtlsParameters(a,d);h&&(A.role="server"),l.usingBundle&&c!==0||(l._gather(p.mid,c),m.state==="new"&&m.start(f,C,h?"controlling":"controlled"),_.state==="new"&&_.start(A));var M=lr(v,R);l._transceive(p,M.codecs.length>0,!1)}})}return l._localDescription={type:o.type,sdp:o.sdp},o.type==="offer"?l._updateSignalingState("have-local-offer"):l._updateSignalingState("stable"),Promise.resolve()},i.prototype.setRemoteDescription=function(o){var u=this;if(["offer","answer"].indexOf(o.type)===-1)return Promise.reject(De("TypeError",'Unsupported type "'+o.type+'"'));if(!Ra("setRemoteDescription",o.type,u.signalingState)||u._isClosed)return Promise.reject(De("InvalidStateError","Can not set remote "+o.type+" in state "+u.signalingState));var d={};u.remoteStreams.forEach(function(m){d[m.id]=m});var l=[],h=X.splitSections(o.sdp),a=h.shift(),c=X.matchPrefix(a,"a=ice-lite").length>0,p=X.matchPrefix(a,"a=group:BUNDLE ").length>0;u.usingBundle=p;var f=X.matchPrefix(a,"a=ice-options:")[0];return u.canTrickleIceCandidates=!!f&&f.substr(14).split(" ").indexOf("trickle")>=0,h.forEach(function(m,_){var v=X.splitLines(m),R=X.getKind(m),C=X.isRejected(m)&&X.matchPrefix(m,"a=bundle-only").length===0,A=v[0].substr(2).split(" ")[2],M=X.getDirection(m,a),O=X.parseMsid(m),y=X.getMid(m)||X.generateIdentifier();if(C||R==="application"&&(A==="DTLS/SCTP"||A==="UDP/DTLS/SCTP"))u.transceivers[_]={mid:y,kind:R,protocol:A,rejected:!0};else{var w,$,Y,E,T,N,P,k,B;!C&&u.transceivers[_]&&u.transceivers[_].rejected&&(u.transceivers[_]=u._createTransceiver(R,!0));var H,q,J=X.parseRtpParameters(m);C||(H=X.getIceParameters(m,a),(q=X.getDtlsParameters(m,a)).role="client"),P=X.parseRtpEncodingParameters(m);var re=X.parseRtcpParameters(m),de=X.matchPrefix(m,"a=end-of-candidates",a).length>0,ue=X.matchPrefix(m,"a=candidate:").map(function(U){return X.parseCandidate(U)}).filter(function(U){return U.component===1});if((o.type==="offer"||o.type==="answer")&&!C&&p&&_>0&&u.transceivers[_]&&(u._disposeIceAndDtlsTransports(_),u.transceivers[_].iceGatherer=u.transceivers[0].iceGatherer,u.transceivers[_].iceTransport=u.transceivers[0].iceTransport,u.transceivers[_].dtlsTransport=u.transceivers[0].dtlsTransport,u.transceivers[_].rtpSender&&u.transceivers[_].rtpSender.setTransport(u.transceivers[0].dtlsTransport),u.transceivers[_].rtpReceiver&&u.transceivers[_].rtpReceiver.setTransport(u.transceivers[0].dtlsTransport)),o.type!=="offer"||C)o.type==="answer"&&!C&&($=(w=u.transceivers[_]).iceGatherer,Y=w.iceTransport,E=w.dtlsTransport,T=w.rtpReceiver,N=w.sendEncodingParameters,k=w.localCapabilities,u.transceivers[_].recvEncodingParameters=P,u.transceivers[_].remoteCapabilities=J,u.transceivers[_].rtcpParameters=re,ue.length&&Y.state==="new"&&(!c&&!de||p&&_!==0?ue.forEach(function(U){Si(w.iceTransport,U)}):Y.setRemoteCandidates(ue)),p&&_!==0||(Y.state==="new"&&Y.start($,H,"controlling"),E.state==="new"&&E.start(q)),!lr(w.localCapabilities,w.remoteCapabilities).codecs.filter(function(U){return U.name.toLowerCase()==="rtx"}).length&&w.sendEncodingParameters[0].rtx&&delete w.sendEncodingParameters[0].rtx,u._transceive(w,M==="sendrecv"||M==="recvonly",M==="sendrecv"||M==="sendonly"),!T||M!=="sendrecv"&&M!=="sendonly"?delete w.rtpReceiver:(B=T.track,O?(d[O.stream]||(d[O.stream]=new n.MediaStream),t(B,d[O.stream]),l.push([B,T,d[O.stream]])):(d.default||(d.default=new n.MediaStream),t(B,d.default),l.push([B,T,d.default]))));else{(w=u.transceivers[_]||u._createTransceiver(R)).mid=y,w.iceGatherer||(w.iceGatherer=u._createIceGatherer(_,p)),ue.length&&w.iceTransport.state==="new"&&(!de||p&&_!==0?ue.forEach(function(U){Si(w.iceTransport,U)}):w.iceTransport.setRemoteCandidates(ue)),k=n.RTCRtpReceiver.getCapabilities(R),e<15019&&(k.codecs=k.codecs.filter(function(U){return U.name!=="rtx"})),N=w.sendEncodingParameters||[{ssrc:1001*(2*_+2)}];var ie,ee=!1;M==="sendrecv"||M==="sendonly"?(ee=!w.rtpReceiver,T=w.rtpReceiver||new n.RTCRtpReceiver(w.dtlsTransport,R),ee&&(B=T.track,O&&O.stream==="-"||(O?(d[O.stream]||(d[O.stream]=new n.MediaStream,Object.defineProperty(d[O.stream],"id",{get:function(){return O.stream}})),Object.defineProperty(B,"id",{get:function(){return O.track}}),ie=d[O.stream]):(d.default||(d.default=new n.MediaStream),ie=d.default)),ie&&(t(B,ie),w.associatedRemoteMediaStreams.push(ie)),l.push([B,T,ie]))):w.rtpReceiver&&w.rtpReceiver.track&&(w.associatedRemoteMediaStreams.forEach(function(U){var G=U.getTracks().find(function(Z){return Z.id===w.rtpReceiver.track.id});G&&function(Z,ne){ne.removeTrack(Z),ne.dispatchEvent(new n.MediaStreamTrackEvent("removetrack",{track:Z}))}(G,U)}),w.associatedRemoteMediaStreams=[]),w.localCapabilities=k,w.remoteCapabilities=J,w.rtpReceiver=T,w.rtcpParameters=re,w.sendEncodingParameters=N,w.recvEncodingParameters=P,u._transceive(u.transceivers[_],!1,ee)}}}),u._dtlsRole===void 0&&(u._dtlsRole=o.type==="offer"?"active":"passive"),u._remoteDescription={type:o.type,sdp:o.sdp},o.type==="offer"?u._updateSignalingState("have-remote-offer"):u._updateSignalingState("stable"),Object.keys(d).forEach(function(m){var _=d[m];if(_.getTracks().length){if(u.remoteStreams.indexOf(_)===-1){u.remoteStreams.push(_);var v=new Event("addstream");v.stream=_,n.setTimeout(function(){u._dispatchEvent("addstream",v)})}l.forEach(function(R){var C=R[0],A=R[1];_.id===R[2].id&&r(u,C,A,[_])})}}),l.forEach(function(m){m[2]||r(u,m[0],m[1],[])}),n.setTimeout(function(){u&&u.transceivers&&u.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(o){o.iceTransport&&o.iceTransport.stop(),o.dtlsTransport&&o.dtlsTransport.stop(),o.rtpSender&&o.rtpSender.stop(),o.rtpReceiver&&o.rtpReceiver.stop()}),this._isClosed=!0,this._updateSignalingState("closed")},i.prototype._updateSignalingState=function(o){this.signalingState=o;var u=new Event("signalingstatechange");this._dispatchEvent("signalingstatechange",u)},i.prototype._maybeFireNegotiationNeeded=function(){var o=this;this.signalingState==="stable"&&this.needNegotiation!==!0&&(this.needNegotiation=!0,n.setTimeout(function(){if(o.needNegotiation){o.needNegotiation=!1;var u=new Event("negotiationneeded");o._dispatchEvent("negotiationneeded",u)}},0))},i.prototype._updateIceConnectionState=function(){var o,u={new:0,closed:0,checking:0,connected:0,completed:0,disconnected:0,failed:0};if(this.transceivers.forEach(function(l){l.iceTransport&&!l.rejected&&u[l.iceTransport.state]++}),o="new",u.failed>0?o="failed":u.checking>0?o="checking":u.disconnected>0?o="disconnected":u.new>0?o="new":u.connected>0?o="connected":u.completed>0&&(o="completed"),o!==this.iceConnectionState){this.iceConnectionState=o;var d=new Event("iceconnectionstatechange");this._dispatchEvent("iceconnectionstatechange",d)}},i.prototype._updateConnectionState=function(){var o,u={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&&(u[l.iceTransport.state]++,u[l.dtlsTransport.state]++)}),u.connected+=u.completed,o="new",u.failed>0?o="failed":u.connecting>0?o="connecting":u.disconnected>0?o="disconnected":u.new>0?o="new":u.connected>0&&(o="connected"),o!==this.connectionState){this.connectionState=o;var d=new Event("connectionstatechange");this._dispatchEvent("connectionstatechange",d)}},i.prototype.createOffer=function(){var o=this;if(o._isClosed)return Promise.reject(De("InvalidStateError","Can not call createOffer after close"));var u=o.transceivers.filter(function(c){return c.kind==="audio"}).length,d=o.transceivers.filter(function(c){return c.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&&(u=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(o.transceivers.forEach(function(c){c.kind==="audio"?--u<0&&(c.wantReceive=!1):c.kind==="video"&&--d<0&&(c.wantReceive=!1)});u>0||d>0;)u>0&&(o._createTransceiver("audio"),u--),d>0&&(o._createTransceiver("video"),d--);var h=X.writeSessionBoilerplate(o._sdpSessionId,o._sdpSessionVersion++);o.transceivers.forEach(function(c,p){var f=c.track,m=c.kind,_=c.mid||X.generateIdentifier();c.mid=_,c.iceGatherer||(c.iceGatherer=o._createIceGatherer(p,o.usingBundle));var v=n.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"),c.remoteCapabilities&&c.remoteCapabilities.codecs&&c.remoteCapabilities.codecs.forEach(function(A){C.name.toLowerCase()===A.name.toLowerCase()&&C.clockRate===A.clockRate&&(C.preferredPayloadType=A.payloadType)})}),v.headerExtensions.forEach(function(C){(c.remoteCapabilities&&c.remoteCapabilities.headerExtensions||[]).forEach(function(A){C.uri===A.uri&&(C.id=A.id)})});var R=c.sendEncodingParameters||[{ssrc:1001*(2*p+1)}];f&&e>=15019&&m==="video"&&!R[0].rtx&&(R[0].rtx={ssrc:R[0].ssrc+1}),c.wantReceive&&(c.rtpReceiver=new n.RTCRtpReceiver(c.dtlsTransport,m)),c.localCapabilities=v,c.sendEncodingParameters=R}),o._config.bundlePolicy!=="max-compat"&&(h+="a=group:BUNDLE "+o.transceivers.map(function(c){return c.mid}).join(" ")+`\r `),h+=`a=ice-options:trickle\r `,o.transceivers.forEach(function(c,p){h+=va(c,c.localCapabilities,"offer",c.stream,o._dtlsRole),h+=`a=rtcp-rsize\r `,!c.iceGatherer||o.iceGatheringState==="new"||p!==0&&o.usingBundle||(c.iceGatherer.getLocalCandidates().forEach(function(f){f.component=1,h+="a="+X.writeCandidate(f)+`\r `}),c.iceGatherer.state==="completed"&&(h+=`a=end-of-candidates\r `))});var a=new n.RTCSessionDescription({type:"offer",sdp:h});return Promise.resolve(a)},i.prototype.createAnswer=function(){var o=this;if(o._isClosed)return Promise.reject(De("InvalidStateError","Can not call createAnswer after close"));if(o.signalingState!=="have-remote-offer"&&o.signalingState!=="have-local-pranswer")return Promise.reject(De("InvalidStateError","Can not call createAnswer in signalingState "+o.signalingState));var u=X.writeSessionBoilerplate(o._sdpSessionId,o._sdpSessionVersion++);o.usingBundle&&(u+="a=group:BUNDLE "+o.transceivers.map(function(h){return h.mid}).join(" ")+`\r `),u+=`a=ice-options:trickle\r `;var d=X.getMediaSections(o._remoteDescription.sdp).length;o.transceivers.forEach(function(h,a){if(!(a+1>d)){if(h.rejected)return h.kind==="application"?h.protocol==="DTLS/SCTP"?u+=`m=application 0 DTLS/SCTP 5000\r `:u+="m=application 0 "+h.protocol+` webrtc-datachannel\r `:h.kind==="audio"?u+=`m=audio 0 UDP/TLS/RTP/SAVPF 0\r a=rtpmap:0 PCMU/8000\r `:h.kind==="video"&&(u+=`m=video 0 UDP/TLS/RTP/SAVPF 120\r a=rtpmap:120 VP8/90000\r `),void(u+=`c=IN IP4 0.0.0.0\r a=inactive\r a=mid:`+h.mid+`\r `);var c;h.stream&&(h.kind==="audio"?c=h.stream.getAudioTracks()[0]:h.kind==="video"&&(c=h.stream.getVideoTracks()[0]),c&&e>=15019&&h.kind==="video"&&!h.sendEncodingParameters[0].rtx&&(h.sendEncodingParameters[0].rtx={ssrc:h.sendEncodingParameters[0].ssrc+1}));var p=lr(h.localCapabilities,h.remoteCapabilities);!p.codecs.filter(function(f){return f.name.toLowerCase()==="rtx"}).length&&h.sendEncodingParameters[0].rtx&&delete h.sendEncodingParameters[0].rtx,u+=va(h,p,"answer",h.stream,o._dtlsRole),h.rtcpParameters&&h.rtcpParameters.reducedSize&&(u+=`a=rtcp-rsize\r `)}});var l=new n.RTCSessionDescription({type:"answer",sdp:u});return Promise.resolve(l)},i.prototype.addIceCandidate=function(o){var u,d=this;return o&&o.sdpMLineIndex===void 0&&!o.sdpMid?Promise.reject(new TypeError("sdpMLineIndex or sdpMid required")):new Promise(function(l,h){if(!d._remoteDescription)return h(De("InvalidStateError","Can not add ICE candidate without a remote description"));if(o&&o.candidate!==""){var a=o.sdpMLineIndex;if(o.sdpMid){for(var c=0;c0?X.parseCandidate(o.candidate):{};if(f.protocol==="tcp"&&(f.port===0||f.port===9)||f.component&&f.component!==1)return l();if((a===0||a>0&&p.iceTransport!==d.transceivers[0].iceTransport)&&!Si(p.iceTransport,f))return h(De("OperationError","Can not add ICE candidate"));var m=o.candidate.trim();m.indexOf("a=")===0&&(m=m.substr(2)),(u=X.getMediaSections(d._remoteDescription.sdp))[a]+="a="+(f.type?m:"end-of-candidates")+`\r `,d._remoteDescription.sdp=X.getDescription(d._remoteDescription.sdp)+u.join("")}else for(var _=0;_Promise.reject(function(s){return{name:{PermissionDeniedError:"NotAllowedError"}[s.name]||s.name,message:s.message,constraint:s.constraint,toString(){return this.name}}}(i)))}}function $c(n){"getDisplayMedia"in n.navigator&&n.navigator.mediaDevices&&(n.navigator.mediaDevices&&"getDisplayMedia"in n.navigator.mediaDevices||(n.navigator.mediaDevices.getDisplayMedia=n.navigator.getDisplayMedia.bind(n.navigator)))}function ns(n,e){if(n.RTCIceGatherer&&(n.RTCIceCandidate||(n.RTCIceCandidate=function(r){return r}),n.RTCSessionDescription||(n.RTCSessionDescription=function(r){return r}),e.version<15025)){const r=Object.getOwnPropertyDescriptor(n.MediaStreamTrack.prototype,"enabled");Object.defineProperty(n.MediaStreamTrack.prototype,"enabled",{set(i){r.set.call(this,i);const s=new Event("enabled");s.enabled=i,this.dispatchEvent(s)}})}n.RTCRtpSender&&!("dtmf"in n.RTCRtpSender.prototype)&&Object.defineProperty(n.RTCRtpSender.prototype,"dtmf",{get(){return this._dtmf===void 0&&(this.track.kind==="audio"?this._dtmf=new n.RTCDtmfSender(this):this.track.kind==="video"&&(this._dtmf=null)),this._dtmf}}),n.RTCDtmfSender&&!n.RTCDTMFSender&&(n.RTCDTMFSender=n.RTCDtmfSender);const t=Al(n,e.version);n.RTCPeerConnection=function(r){return r&&r.iceServers&&(r.iceServers=function(i,s){let o=!1;return(i=JSON.parse(JSON.stringify(i))).filter(u=>{if(u&&(u.urls||u.url)){let d=u.urls||u.url;u.url&&!u.urls&&oi("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&&!o?(o=!0,!0):a&&!o}),delete u.url,u.urls=l?d[0]:d,!!d.length}})}(r.iceServers,e.version),uo("ICE servers after filtering:",r.iceServers)),new t(r)},n.RTCPeerConnection.prototype=t.prototype}function jc(n){n.RTCRtpSender&&!("replaceTrack"in n.RTCRtpSender.prototype)&&(n.RTCRtpSender.prototype.replaceTrack=n.RTCRtpSender.prototype.setTrack)}var Ea=Object.freeze({__proto__:null,shimPeerConnection:ns,shimReplaceTrack:jc,shimGetUserMedia:Hc,shimGetDisplayMedia:$c});function Kc(n,e){const t=n&&n.navigator,r=n&&n.MediaStreamTrack;if(t.getUserMedia=function(i,s,o){oi("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),t.mediaDevices.getUserMedia(i).then(s,o)},!(e.version>55&&"autoGainControl"in t.mediaDevices.getSupportedConstraints())){const i=function(o,u,d){u in o&&!(d in o)&&(o[d]=o[u],delete o[u])},s=t.mediaDevices.getUserMedia.bind(t.mediaDevices);if(t.mediaDevices.getUserMedia=function(o){return typeof o=="object"&&typeof o.audio=="object"&&(o=JSON.parse(JSON.stringify(o)),i(o.audio,"autoGainControl","mozAutoGainControl"),i(o.audio,"noiseSuppression","mozNoiseSuppression")),s(o)},r&&r.prototype.getSettings){const o=r.prototype.getSettings;r.prototype.getSettings=function(){const u=o.apply(this,arguments);return i(u,"mozAutoGainControl","autoGainControl"),i(u,"mozNoiseSuppression","noiseSuppression"),u}}if(r&&r.prototype.applyConstraints){const o=r.prototype.applyConstraints;r.prototype.applyConstraints=function(u){return this.kind==="audio"&&typeof u=="object"&&(u=JSON.parse(JSON.stringify(u)),i(u,"autoGainControl","mozAutoGainControl"),i(u,"noiseSuppression","mozNoiseSuppression")),o.apply(this,[u])}}}}function qc(n){typeof n=="object"&&n.RTCTrackEvent&&"receiver"in n.RTCTrackEvent.prototype&&!("transceiver"in n.RTCTrackEvent.prototype)&&Object.defineProperty(n.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function rs(n,e){if(typeof n!="object"||!n.RTCPeerConnection&&!n.mozRTCPeerConnection)return;!n.RTCPeerConnection&&n.mozRTCPeerConnection&&(n.RTCPeerConnection=n.mozRTCPeerConnection),e.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(i){const s=n.RTCPeerConnection.prototype[i],o={[i](){return arguments[0]=new(i==="addIceCandidate"?n.RTCIceCandidate:n.RTCSessionDescription)(arguments[0]),s.apply(this,arguments)}};n.RTCPeerConnection.prototype[i]=o[i]});const t={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"},r=n.RTCPeerConnection.prototype.getStats;n.RTCPeerConnection.prototype.getStats=function(){const[i,s,o]=arguments;return r.apply(this,[i||null]).then(u=>{if(e.version<53&&!s)try{u.forEach(d=>{d.type=t[d.type]||d.type})}catch(d){if(d.name!=="TypeError")throw d;u.forEach((l,h)=>{u.set(h,Object.assign({},l,{type:t[l.type]||l.type}))})}return u}).then(s,o)}}function Gc(n){if(typeof n!="object"||!n.RTCPeerConnection||!n.RTCRtpSender||n.RTCRtpSender&&"getStats"in n.RTCRtpSender.prototype)return;const e=n.RTCPeerConnection.prototype.getSenders;e&&(n.RTCPeerConnection.prototype.getSenders=function(){const r=e.apply(this,[]);return r.forEach(i=>i._pc=this),r});const t=n.RTCPeerConnection.prototype.addTrack;t&&(n.RTCPeerConnection.prototype.addTrack=function(){const r=t.apply(this,arguments);return r._pc=this,r}),n.RTCRtpSender.prototype.getStats=function(){return this.track?this._pc.getStats(this.track):Promise.resolve(new Map)}}function Yc(n){if(typeof n!="object"||!n.RTCPeerConnection||!n.RTCRtpSender||n.RTCRtpSender&&"getStats"in n.RTCRtpReceiver.prototype)return;const e=n.RTCPeerConnection.prototype.getReceivers;e&&(n.RTCPeerConnection.prototype.getReceivers=function(){const t=e.apply(this,[]);return t.forEach(r=>r._pc=this),t}),cn(n,"track",t=>(t.receiver._pc=t.srcElement,t)),n.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}function Jc(n){n.RTCPeerConnection&&!("removeStream"in n.RTCPeerConnection.prototype)&&(n.RTCPeerConnection.prototype.removeStream=function(e){oi("removeStream","removeTrack"),this.getSenders().forEach(t=>{t.track&&e.getTracks().includes(t.track)&&this.removeTrack(t)})})}function Wc(n){n.DataChannel&&!n.RTCDataChannel&&(n.RTCDataChannel=n.DataChannel)}function zc(n){if(typeof n!="object"||!n.RTCPeerConnection)return;const e=n.RTCPeerConnection.prototype.addTransceiver;e&&(n.RTCPeerConnection.prototype.addTransceiver=function(){this.setParametersPromises=[];const t=arguments[1],r=t&&"sendEncodings"in t;r&&t.sendEncodings.forEach(s=>{if("rid"in s&&!/^[a-z0-9]{0,16}$/i.test(s.rid))throw new TypeError("Invalid RID value provided.");if("scaleResolutionDownBy"in s&&!(parseFloat(s.scaleResolutionDownBy)>=1))throw new RangeError("scale_resolution_down_by must be >= 1.0");if("maxFramerate"in s&&!(parseFloat(s.maxFramerate)>=0))throw new RangeError("max_framerate must be >= 0.0")});const i=e.apply(this,arguments);if(r){const{sender:s}=i,o=s.getParameters();(!("encodings"in o)||o.encodings.length===1&&Object.keys(o.encodings[0]).length===0)&&(o.encodings=t.sendEncodings,s.sendEncodings=t.sendEncodings,this.setParametersPromises.push(s.setParameters(o).then(()=>{delete s.sendEncodings}).catch(()=>{delete s.sendEncodings})))}return i})}function Qc(n){if(typeof n!="object"||!n.RTCRtpSender)return;const e=n.RTCRtpSender.prototype.getParameters;e&&(n.RTCRtpSender.prototype.getParameters=function(){const t=e.apply(this,arguments);return"encodings"in t||(t.encodings=[].concat(this.sendEncodings||[{}])),t})}function Xc(n){if(typeof n!="object"||!n.RTCPeerConnection)return;const e=n.RTCPeerConnection.prototype.createOffer;n.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 Zc(n){if(typeof n!="object"||!n.RTCPeerConnection)return;const e=n.RTCPeerConnection.prototype.createAnswer;n.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 Ca=Object.freeze({__proto__:null,shimOnTrack:qc,shimPeerConnection:rs,shimSenderGetStats:Gc,shimReceiverGetStats:Yc,shimRemoveStream:Jc,shimRTCDataChannel:Wc,shimAddTransceiver:zc,shimGetParameters:Qc,shimCreateOffer:Xc,shimCreateAnswer:Zc,shimGetUserMedia:Kc,shimGetDisplayMedia:function(n,e){n.navigator.mediaDevices&&"getDisplayMedia"in n.navigator.mediaDevices||n.navigator.mediaDevices&&(n.navigator.mediaDevices.getDisplayMedia=function(t){if(!t||!t.video){const r=new DOMException("getDisplayMedia without video constraints is undefined");return r.name="NotFoundError",r.code=8,Promise.reject(r)}return t.video===!0?t.video={mediaSource:e}:t.video.mediaSource=e,n.navigator.mediaDevices.getUserMedia(t)})}});function eu(n){if(typeof n=="object"&&n.RTCPeerConnection){if("getLocalStreams"in n.RTCPeerConnection.prototype||(n.RTCPeerConnection.prototype.getLocalStreams=function(){return this._localStreams||(this._localStreams=[]),this._localStreams}),!("addStream"in n.RTCPeerConnection.prototype)){const e=n.RTCPeerConnection.prototype.addTrack;n.RTCPeerConnection.prototype.addStream=function(t){this._localStreams||(this._localStreams=[]),this._localStreams.includes(t)||this._localStreams.push(t),t.getAudioTracks().forEach(r=>e.call(this,r,t)),t.getVideoTracks().forEach(r=>e.call(this,r,t))},n.RTCPeerConnection.prototype.addTrack=function(t,...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 n.RTCPeerConnection.prototype||(n.RTCPeerConnection.prototype.removeStream=function(e){this._localStreams||(this._localStreams=[]);const t=this._localStreams.indexOf(e);if(t===-1)return;this._localStreams.splice(t,1);const r=e.getTracks();this.getSenders().forEach(i=>{r.includes(i.track)&&this.removeTrack(i)})})}}function tu(n){if(typeof n=="object"&&n.RTCPeerConnection&&("getRemoteStreams"in n.RTCPeerConnection.prototype||(n.RTCPeerConnection.prototype.getRemoteStreams=function(){return this._remoteStreams?this._remoteStreams:[]}),!("onaddstream"in n.RTCPeerConnection.prototype))){Object.defineProperty(n.RTCPeerConnection.prototype,"onaddstream",{get(){return this._onaddstream},set(t){this._onaddstream&&(this.removeEventListener("addstream",this._onaddstream),this.removeEventListener("track",this._onaddstreampoly)),this.addEventListener("addstream",this._onaddstream=t),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 s=new Event("addstream");s.stream=i,this.dispatchEvent(s)})})}});const e=n.RTCPeerConnection.prototype.setRemoteDescription;n.RTCPeerConnection.prototype.setRemoteDescription=function(){const t=this;return this._onaddstreampoly||this.addEventListener("track",this._onaddstreampoly=function(r){r.streams.forEach(i=>{if(t._remoteStreams||(t._remoteStreams=[]),t._remoteStreams.indexOf(i)>=0)return;t._remoteStreams.push(i);const s=new Event("addstream");s.stream=i,t.dispatchEvent(s)})}),e.apply(t,arguments)}}}function nu(n){if(typeof n!="object"||!n.RTCPeerConnection)return;const e=n.RTCPeerConnection.prototype,t=e.createOffer,r=e.createAnswer,i=e.setLocalDescription,s=e.setRemoteDescription,o=e.addIceCandidate;e.createOffer=function(d,l){const h=arguments.length>=2?arguments[2]:arguments[0],a=t.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 u=function(d,l,h){const a=i.apply(this,[d]);return h?(a.then(l,h),Promise.resolve()):a};e.setLocalDescription=u,u=function(d,l,h){const a=s.apply(this,[d]);return h?(a.then(l,h),Promise.resolve()):a},e.setRemoteDescription=u,u=function(d,l,h){const a=o.apply(this,[d]);return h?(a.then(l,h),Promise.resolve()):a},e.addIceCandidate=u}function ru(n){const e=n&&n.navigator;if(e.mediaDevices&&e.mediaDevices.getUserMedia){const t=e.mediaDevices,r=t.getUserMedia.bind(t);e.mediaDevices.getUserMedia=i=>r(iu(i))}!e.getUserMedia&&e.mediaDevices&&e.mediaDevices.getUserMedia&&(e.getUserMedia=function(t,r,i){e.mediaDevices.getUserMedia(t).then(r,i)}.bind(e))}function iu(n){return n&&n.video!==void 0?Object.assign({},n,{video:Mc(n.video)}):n}function su(n){if(!n.RTCPeerConnection)return;const e=n.RTCPeerConnection;n.RTCPeerConnection=function(t,r){if(t&&t.iceServers){const i=[];for(let s=0;se.generateCertificate})}function ou(n){typeof n=="object"&&n.RTCTrackEvent&&"receiver"in n.RTCTrackEvent.prototype&&!("transceiver"in n.RTCTrackEvent.prototype)&&Object.defineProperty(n.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function au(n){const e=n.RTCPeerConnection.prototype.createOffer;n.RTCPeerConnection.prototype.createOffer=function(t){if(t){t.offerToReceiveAudio!==void 0&&(t.offerToReceiveAudio=!!t.offerToReceiveAudio);const r=this.getTransceivers().find(s=>s.receiver.track.kind==="audio");t.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"):t.offerToReceiveAudio!==!0||r||this.addTransceiver("audio"),t.offerToReceiveVideo!==void 0&&(t.offerToReceiveVideo=!!t.offerToReceiveVideo);const i=this.getTransceivers().find(s=>s.receiver.track.kind==="video");t.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"):t.offerToReceiveVideo!==!0||i||this.addTransceiver("video")}return e.apply(this,arguments)}}function cu(n){typeof n!="object"||n.AudioContext||(n.AudioContext=n.webkitAudioContext)}var ya=Object.freeze({__proto__:null,shimLocalStreamsAPI:eu,shimRemoteStreamsAPI:tu,shimCallbacksAPI:nu,shimGetUserMedia:ru,shimConstraints:iu,shimRTCIceServerUrls:su,shimTrackEventTransceiver:ou,shimCreateOfferLegacy:au,shimAudioContext:cu});function vr(n){if(!n.RTCIceCandidate||n.RTCIceCandidate&&"foundation"in n.RTCIceCandidate.prototype)return;const e=n.RTCIceCandidate;n.RTCIceCandidate=function(t){if(typeof t=="object"&&t.candidate&&t.candidate.indexOf("a=")===0&&((t=JSON.parse(JSON.stringify(t))).candidate=t.candidate.substr(2)),t.candidate&&t.candidate.length){const r=new e(t),i=X.parseCandidate(t.candidate),s=Object.assign(r,i);return s.toJSON=function(){return{candidate:s.candidate,sdpMid:s.sdpMid,sdpMLineIndex:s.sdpMLineIndex,usernameFragment:s.usernameFragment}},s}return new e(t)},n.RTCIceCandidate.prototype=e.prototype,cn(n,"icecandidate",t=>(t.candidate&&Object.defineProperty(t,"candidate",{value:new n.RTCIceCandidate(t.candidate),writable:"false"}),t))}function yn(n,e){if(!n.RTCPeerConnection)return;"sctp"in n.RTCPeerConnection.prototype||Object.defineProperty(n.RTCPeerConnection.prototype,"sctp",{get(){return this._sctp===void 0?null:this._sctp}});const t=function(u){if(!u||!u.sdp)return!1;const d=X.splitSections(u.sdp);return d.shift(),d.some(l=>{const h=X.parseMLine(l);return h&&h.kind==="application"&&h.protocol.indexOf("SCTP")!==-1})},r=function(u){const d=u.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(u){let d=65536;return e.browser==="firefox"&&(d=e.version<57?u===-1?16384:2147483637:e.version<60?e.version===57?65535:65536:2147483637),d},s=function(u,d){let l=65536;e.browser==="firefox"&&e.version===57&&(l=65535);const h=X.matchPrefix(u.sdp,"a=max-message-size:");return h.length>0?l=parseInt(h[0].substr(19),10):e.browser==="firefox"&&d!==-1&&(l=2147483637),l},o=n.RTCPeerConnection.prototype.setRemoteDescription;n.RTCPeerConnection.prototype.setRemoteDescription=function(){if(this._sctp=null,e.browser==="chrome"&&e.version>=76){const{sdpSemantics:u}=this.getConfiguration();u==="plan-b"&&Object.defineProperty(this,"sctp",{get(){return this._sctp===void 0?null:this._sctp},enumerable:!0,configurable:!0})}if(t(arguments[0])){const u=r(arguments[0]),d=i(u),l=s(arguments[0],u);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 o.apply(this,arguments)}}function Tn(n){if(!n.RTCPeerConnection||!("createDataChannel"in n.RTCPeerConnection.prototype))return;function e(r,i){const s=r.send;r.send=function(){const o=arguments[0],u=o.length||o.size||o.byteLength;if(r.readyState==="open"&&i.sctp&&u>i.sctp.maxMessageSize)throw new TypeError("Message too large (can send a maximum of "+i.sctp.maxMessageSize+" bytes)");return s.apply(r,arguments)}}const t=n.RTCPeerConnection.prototype.createDataChannel;n.RTCPeerConnection.prototype.createDataChannel=function(){const r=t.apply(this,arguments);return e(r,this),r},cn(n,"datachannel",r=>(e(r.channel,r.target),r))}function is(n){if(!n.RTCPeerConnection||"connectionState"in n.RTCPeerConnection.prototype)return;const e=n.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(t){this._onconnectionstatechange&&(this.removeEventListener("connectionstatechange",this._onconnectionstatechange),delete this._onconnectionstatechange),t&&this.addEventListener("connectionstatechange",this._onconnectionstatechange=t)},enumerable:!0,configurable:!0}),["setLocalDescription","setRemoteDescription"].forEach(t=>{const r=e[t];e[t]=function(){return this._connectionstatechangepoly||(this._connectionstatechangepoly=i=>{const s=i.target;if(s._lastConnectionState!==s.connectionState){s._lastConnectionState=s.connectionState;const o=new Event("connectionstatechange",i);s.dispatchEvent(o)}return i},this.addEventListener("iceconnectionstatechange",this._connectionstatechangepoly)),r.apply(this,arguments)}})}function ss(n,e){if(!n.RTCPeerConnection||e.browser==="chrome"&&e.version>=71||e.browser==="safari"&&e.version>=605)return;const t=n.RTCPeerConnection.prototype.setRemoteDescription;n.RTCPeerConnection.prototype.setRemoteDescription=function(r){if(r&&r.sdp&&r.sdp.indexOf(` a=extmap-allow-mixed`)!==-1){const i=r.sdp.split(` `).filter(s=>s.trim()!=="a=extmap-allow-mixed").join(` `);n.RTCSessionDescription&&r instanceof n.RTCSessionDescription?arguments[0]=new n.RTCSessionDescription({type:r.type,sdp:i}):r.sdp=i}return t.apply(this,arguments)}}function Rr(n,e){if(!n.RTCPeerConnection||!n.RTCPeerConnection.prototype)return;const t=n.RTCPeerConnection.prototype.addIceCandidate;t&&t.length!==0&&(n.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():t.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())})}var Ml=Object.freeze({__proto__:null,shimRTCIceCandidate:vr,shimMaxMessageSize:yn,shimSendThrowTypeError:Tn,shimConnectionState:is,removeExtmapAllowMixed:ss,shimAddIceCandidateNullOrEmpty:Rr});const Pl=function({window:n}={},e={shimChrome:!0,shimFirefox:!0,shimEdge:!0,shimSafari:!0}){const t=uo,r=function(s){const o={browser:null,version:null};if(s===void 0||!s.navigator)return o.browser="Not a browser.",o;const{navigator:u}=s;if(u.mozGetUserMedia)o.browser="firefox",o.version=En(u.userAgent,/Firefox\/(\d+)\./,1);else if(u.webkitGetUserMedia||s.isSecureContext===!1&&s.webkitRTCPeerConnection&&!s.RTCIceGatherer)o.browser="chrome",o.version=En(u.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else if(u.mediaDevices&&u.userAgent.match(/Edge\/(\d+).(\d+)$/))o.browser="edge",o.version=En(u.userAgent,/Edge\/(\d+).(\d+)$/,2);else{if(!s.RTCPeerConnection||!u.userAgent.match(/AppleWebKit\/(\d+)\./))return o.browser="Not a supported browser.",o;o.browser="safari",o.version=En(u.userAgent,/AppleWebKit\/(\d+)\./,1),o.supportsUnifiedPlan=s.RTCRtpTransceiver&&"currentDirection"in s.RTCRtpTransceiver.prototype}return o}(n),i={browserDetails:r,commonShim:Ml,extractVersion:En,disableLog:Nl,disableWarnings:wl};switch(r.browser){case"chrome":if(!ma||!ts||!e.shimChrome)return t("Chrome shim is not included in this adapter release."),i;if(r.version===null)return t("Chrome shim can not determine version, not shimming."),i;t("adapter.js shimming chrome."),i.browserShim=ma,Rr(n,r),Pc(n,r),Lc(n),ts(n,r),kc(n),Bc(n,r),Uc(n),Dc(n),xc(n),Fc(n,r),vr(n),is(n),yn(n,r),Tn(n),ss(n,r);break;case"firefox":if(!Ca||!rs||!e.shimFirefox)return t("Firefox shim is not included in this adapter release."),i;t("adapter.js shimming firefox."),i.browserShim=Ca,Rr(n,r),Kc(n,r),rs(n,r),qc(n),Jc(n),Gc(n),Yc(n),Wc(n),zc(n),Qc(n),Xc(n),Zc(n),vr(n),is(n),yn(n,r),Tn(n);break;case"edge":if(!Ea||!ns||!e.shimEdge)return t("MS edge shim is not included in this adapter release."),i;t("adapter.js shimming edge."),i.browserShim=Ea,Hc(n),$c(n),ns(n,r),jc(n),yn(n,r),Tn(n);break;case"safari":if(!ya||!e.shimSafari)return t("Safari shim is not included in this adapter release."),i;t("adapter.js shimming safari."),i.browserShim=ya,Rr(n,r),su(n),au(n),nu(n),eu(n),tu(n),ou(n),ru(n),cu(n),vr(n),yn(n,r),Tn(n),ss(n,r);break;default:t("Unsupported browser!")}return i}({window:typeof window=="undefined"?void 0:window});var ft,Ce,me;(function(n){n.FPS_10="FPS_10",n.FPS_15="FPS_15",n.FPS_24="FPS_24",n.FPS_30="FPS_30"})(ft||(ft={})),function(n){n.W176_H132="W176_H132",n.W176_H144="W176_H144",n.W256_H144="W256_H144",n.W320_H180="W320_H180",n.W240_H240="W240_H240",n.W320_H240="W320_H240",n.W480_H360="W480_H360",n.W640_H360="W640_H360",n.W480_H480="W480_H480",n.W640_H480="W640_H480",n.W720_H480="W720_H480",n.W1280_H720="W1280_H720",n.W1920_H1080="W1920_H1080"}(Ce||(Ce={})),function(n){n[n.AUDIO_ONLY=0]="AUDIO_ONLY",n[n.VIDEO_ONLY=1]="VIDEO_ONLY",n[n.AUDIO_VIDEO=2]="AUDIO_VIDEO"}(me||(me={}));const Ta={[Ce.W176_H132]:{width:176,height:132,maxBitrate:150,minBitrate:80},[Ce.W176_H144]:{width:176,height:144,maxBitrate:160,minBitrate:80},[Ce.W256_H144]:{width:256,height:144,maxBitrate:240,minBitrate:120},[Ce.W320_H180]:{width:320,height:180,maxBitrate:280,minBitrate:120},[Ce.W240_H240]:{width:240,height:240,maxBitrate:280,minBitrate:120},[Ce.W320_H240]:{width:320,height:240,maxBitrate:400,minBitrate:120},[Ce.W480_H360]:{width:480,height:360,maxBitrate:650,minBitrate:150},[Ce.W640_H360]:{width:640,height:360,maxBitrate:800,minBitrate:180},[Ce.W480_H480]:{width:480,height:480,maxBitrate:800,minBitrate:180},[Ce.W640_H480]:{width:640,height:480,maxBitrate:900,minBitrate:200},[Ce.W720_H480]:{width:720,height:480,maxBitrate:1e3,minBitrate:200},[Ce.W1280_H720]:{width:1280,height:720,maxBitrate:2200,minBitrate:250},[Ce.W1920_H1080]:{width:1920,height:1080,maxBitrate:4e3,minBitrate:400}},uu=(n,e)=>{const t=n*e;let r=Number.MAX_VALUE,i=null;for(const s in Ta){const o=Ta[s],u=Math.abs(o.width*o.height-t);u{let e=Number.MAX_VALUE,t=1;for(const r in Sa){const i=Math.abs(n-parseInt(r));iF(void 0,void 0,void 0,function*(){return(yield navigator.mediaDevices.enumerateDevices()).filter(n=>n.kind==="videoinput")}),getMicrophones:()=>F(void 0,void 0,void 0,function*(){return(yield navigator.mediaDevices.enumerateDevices()).filter(n=>n.kind==="audioinput")}),getSpeakers:()=>F(void 0,void 0,void 0,function*(){return(yield navigator.mediaDevices.enumerateDevices()).filter(n=>n.kind==="audiooutput")})};class ho extends jn{constructor(e,t,r,i,s){super(),this._tag=e,this._userId=t,this._kind=r,this._isLocalTrack=i,this._roomId=s,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 t=this._msStream=this._msStream||new MediaStream,r=t.getTracks()[0];r&&t.removeTrack(r),e?t.addTrack(e):this._element&&(this._element.pause(),this._element.srcObject=null)}_setLocalMuted(e){this._msTrack&&(this._msTrack.enabled=!e),this._localMuted=e}mute(){b.info(`set ${this._id} enabled: false`),this._setLocalMuted(!0)}unmute(){b.info(`set ${this._id} enabled: true`),this._setLocalMuted(!1)}isLocalMuted(){return this._localMuted}isMCUTrack(){return Boolean(this._roomId)}isOwnerMuted(){return this._remoteMuted}play(e,t){return F(this,void 0,void 0,function*(){if(!this._msTrack)return b.warn(`the track is not ready to play -> id: ${this._id}`),{code:I.TRACK_NOT_READY};if(this._msTrack.readyState==="ended"&&b.warn(`the track's readyState is 'ended' -> id: ${this._id}`),t==null?void 0:t.volume){if(!Te(t==null?void 0:t.volume))return b.error(`${t==null?void 0:t.volume} is not a number, the valid range of options.volume is 0-100`),{code:I.PARAMS_ERROR};(t==null?void 0:t.volume)<0&&(t.volume=0,b.warn("the valid range of options.volume is 0-100, the value of volume has been set 0")),(t==null?void 0:t.volume)>100&&(t.volume=100,b.warn("the valid range of options.volume is 0-100, the value of volume has been set 100"))}if((t==null?void 0:t.audioDeviceId)&&!(yield lo.getSpeakers()).map(i=>i.deviceId).includes(t.audioDeviceId))return b.error(`the options.audioDeviceId is invalid --> ${t.audioDeviceId}`),{code:I.PARAMS_ERROR};const r=this.isVideoTrack();if(r&&(!e||!(e instanceof HTMLVideoElement)))return b.error(`the video track need an