index.f1cebeaa.js 642 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940
  1. var ml=Object.defineProperty,_l=Object.defineProperties;var vl=Object.getOwnPropertyDescriptors;var gr=Object.getOwnPropertySymbols;var ba=Object.prototype.hasOwnProperty,wa=Object.prototype.propertyIsEnumerable;var Ia=(n,e,t)=>e in n?ml(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,it=(n,e)=>{for(var t in e||(e={}))ba.call(e,t)&&Ia(n,t,e[t]);if(gr)for(var t of gr(e))wa.call(e,t)&&Ia(n,t,e[t]);return n},bn=(n,e)=>_l(n,vl(e));var Na=(n,e)=>{var t={};for(var r in n)ba.call(n,r)&&e.indexOf(r)<0&&(t[r]=n[r]);if(n!=null&&gr)for(var r of gr(n))e.indexOf(r)<0&&wa.call(n,r)&&(t[r]=n[r]);return t};import{s as ve,r as Jt,a as yl}from"./index.d14810a8.js";import{j as co,n as uo,p as Tt,d as Be,i as Ur,f as I,l as z,t as Dr,u as Cs,v as Es,x as Aa,y as ht,z as au,A as Rs,B as cu,C as Cl,D as El,F as uu,G as Hi,r as Ae,H as Rl,I as Tl,J as Sl,K as Il,L as bl,M as wl,N as Nl,O as $i,P as ji,Q as Ki}from"./vendor.b0ed3cca.js";const Ol="_liveHeader_8nata_1",Al="_liveLogo_8nata_12",Ml="_liveHeaderLeft_8nata_17",Pl="_liveHeaderLeftIcon_8nata_23",Ll="_liveHeaderLeftText_8nata_27",kl="_avatarWrapper_8nata_30",Ul="_userAvatar_8nata_37";var Ht={liveHeader:Ol,liveLogo:Al,liveHeaderLeft:Ml,liveHeaderLeftIcon:Pl,liveHeaderLeftText:Ll,avatarWrapper:kl,userAvatar:Ul},Ts;(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"})(Ts||(Ts={}));var Nt,qi,Gn=Ts,Dl=["https://nav.cn.ronghub.com","https://nav2-cn.ronghub.com"],xl=["wsproxy.cn.ronghub.com","wsap-cn.ronghub.com"],Bl=["cometproxy-cn.ronghub.com","mini-cn.ronghub.com"],Ma={"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}},Vl=["RC:TypSts","RC:InterceptMsg"];(function(n){n.WEBSOCKET="websocket",n.COMET="comet"})(Nt||(Nt={}));var vi=function(n){return qi||(qi={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}}),qi},Fl=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}(),Pa=function(){function n(e,t){var r,i=t?"RCV4-"+t:"RCV4-";this._rootStorage=vi(e);var s=this._rootStorage.get(i)||{};this._cache=new Fl(((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}(),du=function(n,e){return(du=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 we(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}du(n,e),n.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}var Ce=function(){return(Ce=Object.assign||function(n){for(var e,t=1,r=arguments.length;t<r;t++)for(var i in e=arguments[t])Object.prototype.hasOwnProperty.call(e,i)&&(n[i]=e[i]);return n}).apply(this,arguments)};function x(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 c(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,c)}d((r=r.apply(n,e||[])).next())})}function B(n,e){var t,r,i,s,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:c(0),throw:c(1),return:c(2)},typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function c(d){return function(l){return function(h){if(t)throw new TypeError("Generator is already executing.");for(;o;)try{if(t=1,r&&(i=2&h[0]?r.return:h[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,h[1])).done)return i;switch(r=0,i&&(h=[2&h[0],i.value]),h[0]){case 0:case 1:i=h;break;case 4:return o.label++,{value:h[1],done:!1};case 5:o.label++,r=h[1],h=[0];continue;case 7:h=o.ops.pop(),o.trys.pop();continue;default:if(i=o.trys,!((i=i.length>0&&i[i.length-1])||h[0]!==6&&h[0]!==2)){o=0;continue}if(h[0]===3&&(!i||h[1]>i[0]&&h[1]<i[3])){o.label=h[1];break}if(h[0]===6&&o.label<i[1]){o.label=i[1],i=h;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(h);break}i[2]&&o.ops.pop(),o.trys.pop();continue}h=e.call(n,o)}catch(a){h=[6,a],r=0}finally{t=i=0}if(5&h[0])throw h[1];return{value:h[0]?h[1]:void 0,done:!0}}([d,l])}}}function Gt(n,e){for(var t=0,r=e.length,i=n.length;t<r;t++,i++)n[i]=e[t];return n}var Le,Kr;(function(n){function e(t){return n.call(this,"TODO => "+t)||this}return we(e,n),e})(Error);var La=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()})},lu=function(n,e){e===void 0&&(e="utf-8");var t,r=0;if(e==="utf-16")for(var i=0,s=n.length;i<s;i++)r+=(t=n.charCodeAt(i))<=65535?2:4;else for(i=0,s=n.length;i<s;i++)r+=(t=n.charCodeAt(i))<127?1:t<=2047?2:t<=65535?3:4;return r},yi=function(n,e){if(n=n.replace(/\?$/,""),!e)return n;var t=Object.keys(e).map(function(r){return r+"="+e[r]}).filter(function(r){return!!r});return t.length?[n,t.join("&")].join("?"):n},lo=function(n){return n.match(/\d+(\.\d+){2}/)[0]};(function(n){n[n.LOG=0]="LOG",n[n.DEBUG=0]="DEBUG",n[n.INFO=1]="INFO",n[n.WARN=2]="WARN",n[n.ERROR=3]="ERROR",n[n.FATAL=4]="FATAL",n[n.NONE=1e3]="NONE"})(Le||(Le={})),function(n){n.IM="IM",n.RTC="RTC"}(Kr||(Kr={}));var an="RC_Logs";function Hl(n){var e=n.target.result;n.oldVersion===1&&e.deleteObjectStore(an),function(t,r,i){var s;if(!t.objectStoreNames.contains(r)){var o=Ce({},i.objectStoreParams);s=t.createObjectStore(r,o),i.indexs&&i.indexs.length>0&&i.indexs.forEach(function(c){s.createIndex(c.indexName,c.key,{unique:c.unique})})}}(e,an,{indexs:[{indexName:"time",key:"time",unique:!1}],objectStoreParams:{autoIncrement:!0}})}var Ss,ho=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,Hl(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),c=IDBKeyRange.bound(r,i),d=o.index(t),l=[],h=d.openCursor(c);h.onsuccess=function(a){var u=a.target.result;u?(l.push(u.value),u.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 c=o.result;c.length>0&&(s.delete(IDBKeyRange.bound(c[0],c[c.length-1])).onsuccess=function(){i(!0)})}}else i(!1)})},n._db=null,n}(),hu=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)})},fu=function(){var n=hu();if(n=n.replace(/-/g,"")+"a",(n=function(r){var i="0123456789abcdefghigklmnopqrstuvwxyzABCDEFGHIGKLMNOPQRSTUVWXYZa0".split(""),s=i.length+1,o=+r,c=[];do{var d=o%s;o=(o-d)/s,c.unshift(i[d])}while(o);return c.join("")}(n=parseInt(n,16))).length>22&&(n=n.slice(0,22)),n.length<22)for(var e=22-n.length,t=0;t<e;t++)n+="0";return n};(function(n){n[n.NONE=0]="NONE",n[n.PRIVATE=1]="PRIVATE",n[n.DISCUSSION=2]="DISCUSSION",n[n.GROUP=3]="GROUP",n[n.CHATROOM=4]="CHATROOM",n[n.CUSTOMER_SERVICE=5]="CUSTOMER_SERVICE",n[n.SYSTEM=6]="SYSTEM",n[n.APP_PUBLIC_SERVICE=7]="APP_PUBLIC_SERVICE",n[n.PUBLIC_SERVICE=8]="PUBLIC_SERVICE",n[n.RTC_ROOM=12]="RTC_ROOM"})(Ss||(Ss={}));var Is,Q=Ss;(function(n){n[n.IMAGE=1]="IMAGE",n[n.AUDIO=2]="AUDIO",n[n.VIDEO=3]="VIDEO",n[n.FILE=4]="FILE",n[n.SIGHT=5]="SIGHT",n[n.COMBINE_HTML=6]="COMBINE_HTML"})(Is||(Is={}));var Zt,bs,ke=Is,et=function(n){return typeof n=="string"},qr=function(n){return typeof n=="boolean"},Ie=function(n){return typeof n=="number"&&!isNaN(n)},ze=function(n){return Object.prototype.toString.call(n).indexOf("Array")!==-1},pu=function(n){return Object.prototype.toString.call(n)==="[object ArrayBuffer]"},Ze=function(n){return et(n)&&n.length>0},He=function(n){return Object.prototype.toString.call(n)==="[object Object]"},Gr=function(n){return Object.prototype.toString.call(n)==="[object Function]"},ge=function(n){return n===void 0||Object.prototype.toString.call(n)==="[object Undefined]"},ka=function(n){return Object.prototype.toString.call(n)==="[object Null]"},Yn=function(n){return et(n)&&/https?:\/\//.test(n)},Fn=function(n){for(var e in n)return!0;return!1},$l=function(n){return Ie(n)&&Object.prototype.hasOwnProperty.call(ke,n)},Ua=((Zt={})[Le.DEBUG]=console.debug.bind(console),Zt[Le.INFO]=console.info.bind(console),Zt[Le.WARN]=console.warn.bind(console),Zt[Le.ERROR]=console.error.bind(console),Zt[Le.FATAL]=console.log.bind(console),Zt),Da=function(n){return et(n)||Ie(n)||ge(n)||qr(n)?n:n instanceof Error?JSON.stringify({name:n.name,message:n.message,stack:n.stack}):JSON.stringify(n)},Dt=function(){function n(e,t,r){this.tag=e,this.type=t,this.initiator=r,this._outLevel=Le.WARN,this.debug=this.log.bind(this,Le.DEBUG),this.info=this.log.bind(this,Le.INFO),this.warn=this.log.bind(this,Le.WARN),this.error=this.log.bind(this,Le.ERROR),this.fatal=this.log.bind(this,Le.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<arguments.length;i++)r[i-2]=arguments[i];Ua[e].apply(Ua,Gt([t+":"],r))},n.prototype.__pushLocalLog=function(e,t,r){var i;i=this.type?this.type:["RCRTCLog","RCCall","RCRTC","RTC-A"].includes(this.tag)?Kr.RTC:Kr.IM;var s=Date.now();lu(t)>=1e3&&(t=function(l,h,a){if(a===void 0&&(a="utf-8"),!l||!h)return"";var u=a==="utf-8"?3:2,f=0,p=0,m="";for(p=0;p<l.length;p++){if(l.charCodeAt(p)>255?f+=u:f++,f>h)return m;m+=l.charAt(p)}return l}(t,1e3));var o=JSON.stringify({message:t,userId:n.userId}).replace(/"/g,'""'),c=/^[\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)+","+c+',"'+o+`"
  2. `,userId:n.userId};n.databaseLogList.push(d),(n.databaseLogList.length>=100||e===Le.FATAL)&&this.__insertLogIntoDatabase()},n.prototype.__insertLogIntoDatabase=function(){return x(this,void 0,void 0,function(){var e,t,r;return B(this,function(i){switch(i.label){case 0:return e=Gt([],n.databaseLogList),n.databaseLogList=[],(t=ho.getInstance())?[4,t.addList(an,e)]:[3,3];case 1:return r=i.sent(),[4,t.getCount(an,"time")];case 2:return i.sent()>1e5&&t.removeFirstData(an,"time",2e3),[2,r];case 3:return[2,!1]}})})},n.prototype.setLogLevel=function(e){this._outLevel=typeof e!="number"?Le.WARN:e},n.prototype.setLogStdout=function(e){this._logStdout=e},n.prototype.log=function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];if(e>Le.DEBUG&&this.__pushLocalLog(e,t.map(Da).join(" "),this.tag),!(e<this._outLevel)){var i=new Date().toISOString()+"["+this.tag+"]["+Le[e]+"]",s=i+" - "+t.map(Da).join(" ");this._logStdout?this._logStdout(e,s):this._stdout?this._stdout(e,s):this._defaultStdout.apply(this,Gt([e,i],t))}},n.prototype.reportLog=function(e,t,r){this.__pushLocalLog(4-e,r,t);var i=JSON.stringify({message:r}).replace(/"/g,'""');i='"'+i+'"';var s={level:e,content:[n.sessionId,Date.now(),this.type,e,t,i].join()+`
  3. `};n.realTimeLogList.push(s),n.realTimeLogList.length>=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=fu(),n.userId="",n}(),K=new Dt("RCLog"),ir=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<arguments.length;r++)t[r-1]=arguments[r];var i=this._map[e];if(i)for(var s=i.length-1;s>=0;s-=1){var o=i[s],c=o.target,d=o.once,l=o.listener;d&&i.splice(s,1);try{l.call.apply(l,Gt([c],t))}catch(h){K.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"})(bs||(bs={}));var ws,at=bs;(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"})(ws||(ws={}));var Ns,N=ws;(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"})(Ns||(Ns={}));var Os,re=Ns,je={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"})(Os||(Os={}));var As,qe=Os;(function(n){n[n.OPEN=1]="OPEN",n[n.CLOSE=2]="CLOSE"})(As||(As={}));var Ms,rn=As;(function(n){n[n.ALL=1]="ALL",n[n.SINGAL=2]="SINGAL"})(Ms||(Ms={}));var Ps,fo=Ms;(function(n){n[n.QINIU=1]="QINIU",n[n.ALI=2]="ALI",n[n.AWS=3]="AWS",n[n.STC=4]="STC"})(Ps||(Ps={}));var Ls,We=Ps;(function(n){n[n.UPDATE=1]="UPDATE",n[n.DELETE=2]="DELETE"})(Ls||(Ls={}));var ks,Xe=Ls;(function(n){n[n.QUIT=0]="QUIT",n[n.JOIN=1]="JOIN"})(ks||(ks={}));var xa,Ba=ks;(function(n){/*!
  4. 全局敏感词:命中了融云内置的全局敏感词
  5. */n[n.GLOBAL=1]="GLOBAL",n[n.CUSTOM=2]="CUSTOM",n[n.THIRD_PARTY=3]="THIRD_PARTY"})(xa||(xa={}));var Ye,Va,Fa;(function(n){n[n.RTC=0]="RTC",n[n.LIVE=2]="LIVE"})(Ye||(Ye={})),function(n){n[n.AUDIO_AND_VIDEO=0]="AUDIO_AND_VIDEO",n[n.AUDIO=1]="AUDIO"}(Va||(Va={})),function(n){n[n.ANCHOR=1]="ANCHOR",n[n.AUDIENCE=2]="AUDIENCE"}(Fa||(Fa={}));var yt,Yr,Us,jl={"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"})(yt||(yt={})),function(n){n[n.AnchorToViewer=1]="AnchorToViewer",n[n.ViewerToAnchor=2]="ViewerToAnchor"}(Yr||(Yr={})),function(n){n[n.KICK=0]="KICK",n[n.REFUSE=1]="REFUSE",n[n.COEXIST=2]="COEXIST"}(Us||(Us={}));var _t,Me,Gi={engine:"5.1.1"},Yt=function(){function n(){}return n.add=function(e,t){Gi[e]=t},n.validEngine=function(e){var t=e.match(/\d+\.\d+\.\d+/);if(!t)return K.warn("The validation engine version '"+e+"' is invalid!"),!1;var r=t[0].split(".").map(function(i){return i.padStart(3,"0")}).join("");return Gi.engine.match(/\d+\.\d+\.\d+/)[0].split(".").map(function(i){return i.padStart(3,"0")}).join("")>=r},n.getInfo=function(){return Gi},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"})(Me||(Me={}));var St,Ke,nt,Wt,Kt,Kl=((_t={})[Me.STRING]=Ze,_t[Me.ONLY_STRING]=et,_t[Me.NUMBER]=Ie,_t[Me.BOOLEAN]=function(n){return typeof n=="boolean"},_t[Me.OBJECT]=He,_t[Me.ARRAY]=ze,_t[Me.CALLBACK]=function(n){var e=!0;return He(n)||(e=!1),(n=n||{}).onSuccess&&!Gr(n.onSuccess)&&(e=!1),n.onError&&!Gr(n.onError)&&(e=!1),e},_t[Me.CHANNEL_ID]=function(n){var e=!1;return et(n)&&!/_/g.test(n)&&n.length<=20&&(e=!0),e},_t),ql=function(n){function e(t){var r=n.call(this,t)||this;return r.name="RCAssertError",r}return we(e,n),e}(Error),xe=function(n,e,t,r){if(r===void 0&&(r=!1),!Ee(n,e,t,r))throw new ql("'"+n+"' is invalid: "+JSON.stringify(e))},Ee=function(n,e,t,r){r===void 0&&(r=!1),t=Kl[t]||t;var i=r&&!t(e)||!r&&!(ge(e)||e===null||t(e));return i&&K.error("'"+n+"' is invalid: "+JSON.stringify(e)),!i},st=function(n){if(!He(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)},Gl=function(n,e){var t=Math.floor(1e3*Math.random()%1e4),r=hu(),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 c=e.split(".");o="."+c[c.length-1]}return n+"__RC-"+i+"_"+t+"_"+s+r+o},Yl=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,c=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 u={};u.collapse_key=h==null?void 0:h.collapseKey,u.imageUrl=h==null?void 0:h.imageUrl;var f=h==null?void 0:h.priority;f&&!["high","normal"].includes(f)&&(f="normal"),u.priority=f;var p=[{HW:{channelId:c||""}},{MI:{channelId:o||""}},{OPPO:{channelId:d||""}},{VIVO:{classification:l||""}},{APNS:a},{FCM:u}];return JSON.stringify(p)},Ha=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,c,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=(c=s[a])===null||c===void 0?void 0:c.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{K.error("Wrong format for pushConfigs field! content: "+n)}return{iOSConfig:t,androidConfig:r}},en=function(n){var e=/^[A-Za-z0-9_=+-]+$/.test(n),t=n.length;return e&&t<=128&&t>=1},Yi=function(n){var e=n.length;return e<=4096&&e>=1},Oe=function(n,e,t){e=e||function(){};var r=(t=t||{}).isReverse;He(n)&&function(){for(var i in n)e(n[i],i,n)}(),(ze(n)||et(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;s<o;s++)e(n[s],s)}()},mr=function(n,e){return Oe(n,function(t,r){n[r]=e(t,r)}),n},Jl=function(n,e){if(n.indexOf)return n.indexOf(e);var t=-1;return Oe(n,function(r,i){e===r&&(t=i)}),t},Wl=function(n,e){var t=[];return Oe(n,function(r){t.push(r)}),Jl(t,e)!==-1},xr=function(n){return JSON.parse(JSON.stringify(n))},$a=function(){return typeof RCCppEngine!="undefined"},zl=function(n){if(n.tag!=="browser")return{type:n.tag,version:"UnKonw"};var e,t,r=navigator.userAgent,i={IE:/rv:([\d.]+)\) like Gecko|MSIE ([\d.]+)/,Edge:/Edge\/([\d.]+)/,Firefox:/Firefox\/([\d.]+)/,Opera:/(?:OPERA|OPR).([\d.]+)/,WeChat:/MicroMessenger\/([\d.]+)/,QQBrowser:/QQBrowser\/([\d.]+)/,Chrome:/Chrome\/([\d.]+)/,Safari:/Version\/([\d.]+).*Safari/,iOSChrome:/Mobile\/([\d.]+).*Safari/};for(var s in i)if(i.hasOwnProperty(s)){var o=r.match(i[s]);if(o){t=s,e=o[1]||o[2];break}}return{type:t||"UnKonw",version:e||"UnKonw"}},gu=function(n){switch(n){case je.SERVER_UNAVAILABLE:return N.SERVER_UNAVAILABLE;case je.TOKEN_INCORRECT:return N.RC_CONN_USER_OR_PASSWD_ERROR;case je.REDIRECT:return N.RC_CONN_REDIRECTED;case je.APP_BLOCK_OR_DELETE:return N.RC_CONN_APP_BLOCKED_OR_DELETED;case je.BLOCK:return N.RC_CONN_USER_BLOCKED;case je.TOKEN_EXPIRE:return N.RC_CONN_USER_OR_PASSWD_ERROR;case je.HOSTNAME_ERROR:return N.HOSTNAME_ERROR;case je.HASOHTERSAMECLIENTONLINE:return N.HAS_OHTER_SAME_CLIENT_ON_LINE;case je.APP_AUTH_NOT_PASS:return N.RC_APP_AUTH_NOT_PASS;case je.OTP_USED:return N.RC_OTP_USED;case je.PLATFORM_ERROR:return N.RC_PLATFORM_ERROR;default:return N.RC_NET_UNAVAILABLE}},ja=function(n){var e={},t=JSON.parse(n);return Oe(t,function(r,i){e[i]=r.v}),e},sn={_delayTime:0,setTime:function(n){var e=new Date().getTime();sn._delayTime=e-n},getTime:function(){var n=sn._delayTime;return new Date().getTime()-n}},Ka=function(n,e){var t=0;return n.isAutoDelete&&(t|=1),n.isOverwrite&&(t|=2),e===2&&(t|=4),t};(function(n){n[n.AT_MOST_ONCE=0]="AT_MOST_ONCE",n[n.AT_LEAST_ONCE=1]="AT_LEAST_ONCE",n[n.EXACTLY_ONCE=2]="EXACTLY_ONCE",n[n.DEFAULT=3]="DEFAULT"})(St||(St={})),function(n){n[n.SYMMETRIC=0]="SYMMETRIC",n[n.CONNECT=1]="CONNECT",n[n.CONN_ACK=2]="CONN_ACK",n[n.PUBLISH=3]="PUBLISH",n[n.PUB_ACK=4]="PUB_ACK",n[n.QUERY=5]="QUERY",n[n.QUERY_ACK=6]="QUERY_ACK",n[n.QUERY_CONFIRM=7]="QUERY_CONFIRM",n[n.SUBSCRIBE=8]="SUBSCRIBE",n[n.SUB_ACK=9]="SUB_ACK",n[n.UNSUBSCRIBE=10]="UNSUBSCRIBE",n[n.UNSUB_ACK=11]="UNSUB_ACK",n[n.PING_REQ=12]="PING_REQ",n[n.PING_RESP=13]="PING_RESP",n[n.DISCONNECT=14]="DISCONNECT",n[n.RESERVER2=15]="RESERVER2"}(Ke||(Ke={})),function(n){n.CONN_ACK="ConnAckMessage",n.DISCONNECT="DisconnectMessage",n.PING_REQ="PingReqMessage",n.PING_RESP="PingRespMessage",n.PUBLISH="PublishMessage",n.PUB_ACK="PubAckMessage",n.QUERY="QueryMessage",n.QUERY_CON="QueryConMessage",n.QUERY_ACK="QueryAckMessage"}(nt||(nt={})),function(n){n.PUB="pub",n.QUERY="qry"}(Wt||(Wt={})),function(n){n[n.V4=4]="V4",n[n.V3=3]="V3"}(Kt||(Kt={}));var q,po=function(){function n(e,t,r,i){t===void 0&&(t=!1),r===void 0&&(r=St.AT_LEAST_ONCE),i===void 0&&(i=!1),this._retain=!1,this.qos=St.AT_LEAST_ONCE,this._dup=!1,this.syncMsg=!1;var s=e>0;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}(),sr=function(){function n(){}return n.writeUTF=function(e,t){var r=[],i=0;if(et(e))for(var s=0,o=e.length;s<o;s++){var c=e.charCodeAt(s);c>=0&&c<=127?(i+=1,r.push(c)):c>=128&&c<=2047?(i+=2,r.push(192|31&c>>6),r.push(128|63&c)):c>=2048&&c<=65535&&(i+=3,r.push(224|15&c>>12),r.push(128|63&c>>6),r.push(128|63&c))}for(s=0,o=r.length;s<o;s++)r[s]>255&&(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,c="";++s<o.length;){var d=Number(o[s]);if(d===(127&d)||((240&d)==240?d=(d=(d=(d^=240)<<6|128^o[++s])<<6|128^o[++s])<<6|128^o[++s]:(224&d)==224?d=(d=(d^=224)<<6|128^o[++s])<<6|128^o[++s]:(192&d)==192&&(d=(d^=192)<<6|128^o[++s])),!isFinite(d)||d<0||d>1114111||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)&&(c+=String.fromCharCode.apply(null,i),i.length=0)}return c},n}(),Ql=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 sr.readUTF(t)},n.prototype.readAll=function(){return this._pool.subarray(this._position,this._poolLen)},n}(),Xl=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=sr.writeUTF(e);this._pool=this._pool.concat(t),this._writen+=t.length},n.prototype.getBytesArray=function(){return this._pool},n}(),Jn="UpStreamMessage",go="PushExtra",Ci="DownStreamMessage",Wn="DownStreamMessages",mo="SessionsAttQryInput",mu="SessionsAttOutput",_o="SyncRequestMsg",vo="ChrmPullMsg",Jr="NotifyMsg",yo="HistoryMsgInput",zn="HistoryMsgOuput",Wr="RelationQryInput",Qn="RelationsOutput",Co="DeleteSessionsInput",Eo="SessionInfo",_u="DeleteSessionsOutput",Ro="RelationsInput",To="DeleteMsgInput",So="CleanHisMsgInput",Io="SessionMsgReadInput",bo="ChrmInput",wo="ChrmOutput",No="QueryChatRoomInfoInput",Ei="QueryChatRoomInfoOutput",zr="RtcInput",qt="RtcUserListOutput",Oo="SetUserStatusInput",Ao="RtcSetDataInput",Qr="RtcUserSetDataInput",Xr="RtcDataInput",Mo="RtcSetOutDataInput",Po="MCFollowInput",Ri="RtcTokenOutput",Ti="RtcQryOutput",Lo="RtcQryUserOutDataInput",vu="RtcUserOutDataOutput",ko="RtcQueryListInput",yu="RtcRoomInfoOutput",ot="RtcValueInfo",Uo="RtcKeyDeleteInput",Do="GetQNupTokenInput",xo="GetQNupTokenOutput",Bo="GetQNdownloadUrlInput",Vo="GetDownloadUrlInput",Fo="GetQNdownloadUrlOutput",Ho="GetDownloadUrlOutput",$o="SetChrmKV",jo="SetChrmKVS",Cu="DeleteChrmKVS",cn="ChrmKVOutput",Ko="ChrmKVSOutput",Eu="ChrmKVSOutputEntity",qo="QueryChrmKV",Ru="SetUserSettingInput",un="SetUserSettingOutput",Go="PullUserSettingInput",Si="PullUserSettingOutput",Ii="UserSettingNotification",Yo="SessionReq",bi="SessionStates",Zr="SessionState",ei="SessionStateItem",ti="SessionStateModifyReq",Jo="SessionStateModifyResp",ni="GrpReadReceiptMsg",Tu="GrpReadReceiptQryReq",wi="GrpReadReceiptQryResp",Su="GrpMsgReadUser",Wo="SessionTagAddInput",Hn="SessionTagItem",zo="SessionTagDelInput",Qo="SessionDisTagReq",Xo="ReportSDKInput",Iu="ReportSDKOutput",Zo="RtcNotifyMsg",ea="RtcPullKV",Ni="RtcKVOutput",ta="RtcQueryUserJoinedInput",Oi="RtcQueryUserJoinedOutput",bu="RtcViewerJoinedOutput",na="RtcInviteInput",ra="RtcCancelInviteInput",ia="RtcInviteAnswerInput",sa="RtcEndInviteInput",wu=((q={})[Jn]=["sessionId","classname","content","pushText","userId","configFlag","appData","extraContent","pushExt","busChannel"],q[Wn]=["list","syncTime","finished"],q[Ci]=["fromUserId","type","groupId","classname","content","dataTime","status","msgId","extraContent","pushContent","configFlag","pushExt","busChannel"],q[go]=["title","templateIdNoUse","pushId","pushConfigs","templateId"],q[mo]=["nothing"],q[mu]=["inboxTime","sendboxTime","totalUnreadCount"],q[_o]=["syncTime","ispolling","isweb","isPullSend","isKeeping","sendBoxSyncTime"],q[vo]=["syncTime","count"],q[Jr]=["type","time","chrmId"],q[yo]=["targetId","time","count","order","busChannel"],q[zn]=["list","syncTime","hasMsg"],q[Wr]=["type","count","startTime","order"],q[Qn]=["info"],q[Co]=["sessions"],q[Eo]=["type","channelId","busChannel"],q[_u]=["nothing"],q[Ro]=["type","msg","count","busChannel","startTime","endTime"],q[To]=["type","conversationId","msgs","busChannel"],q[So]=["targetId","dataTime","conversationType","busChannel"],q[Io]=["type","msgTime","channelId"],q[bo]=["nothing"],q[wo]=["nothing","sessionId","joinTime"],q[No]=["count","order"],q[Ei]=["userTotalNums","userInfos"],q[Do]=["type","key","httpMethod","queryString"],q[Bo]=["type","key","fileName"],q[Vo]=["type","key","fileName"],q[xo]=["deadline","token","bosToken","bosDate","path","osskeyId","ossPolicy","ossSign","ossBucketName"],q[Fo]=["downloadUrl"],q[Ho]=["downloadUrl"],q[$o]=["entry","bNotify","notification","type"],q[jo]=["entry","bNotify","notification","type"],q[Cu]=["entry","bNotify","notification","type"],q[cn]=["entries","bFullUpdate","syncTime"],q[Ko]=["timestamp","errorKeys"],q[Eu]=["key","errorCode"],q[qo]=["timestamp"],q[Ru]=["version","value"],q[un]=["version","reserve"],q[Go]=["version","reserve"],q[Si]=["items","version"],q.UserSettingItem=["targetId","type","key","value","version","status","tags"],q[Yo]=["time"],q[bi]=["version","state"],q[Zr]=["type","channelId","time","stateItem","busChannel"],q[ei]=["sessionStateType","value","tags"],q[ti]=["version","state"],q[Jo]=["version"],q[ni]=["msgId","busChannel"],q[Tu]=["msgId","busChannel"],q[wi]=["totalMemberNum","list"],q[Su]=["readTime","userId"],q[Wo]=["version","tags"],q[Hn]=["tagId","name","createdTime","isTop"],q[zo]=["version","tags"],q[Qo]=["tagId"],q[Ii]=["version","reserve"],q[Xo]=["sdkInfo"],q[Iu]=["nothing"],q[zr]=["roomType","broadcastType","extraInnerData","needSysChatroom","identityChangeType","joinType"],q[qt]=["users","token","sessionId","roomInfo"],q[Oo]=["status"],q[Ao]=["interior","target","key","value","objectName","content"],q[Qr]=["valueInfo","objectName","content"],q[Xr]=["interior","target","key","objectName","content"],q[Mo]=["target","valueInfo","objectName","content"],q[Po]=["state"],q[Ri]=["rtcToken"],q[Ti]=["outInfo"],q[Lo]=["userId"],q[vu]=["user"],q[ko]=["order"],q[yu]=["roomId","roomData","userCount","list"],q[ot]=["key","value"],q[Uo]=["key"],q[Zo]=["type","time","roomId"],q[ea]=["timestamp","roomId"],q[Ni]=["entries","bFullUpdate","syncTime"],q[ta]=["userId"],q[Oi]=["info"],q[na]=["invitedUserId","timeoutTime","invitedRoomId","inviteInfo","inviteSessionId"],q[ra]=["invitedUserId","invitedRoomId","inviteInfo","inviteSessionId"],q[ia]=["inviteUserID","answerCode","inviteRoomId","inviteSessionId","content","key","value"],q[sa]=["inviteRoomId","inviteSessionId","inviteContent","inviteRoomKeys"],q),Xn={},Zl=function(n){var e=wu[n];Xn[n]=function(){for(var t={},r={getArrayData:function(){return t}},i=function(o){var c=e[o],d="set"+La(c,0,1);r[d]=function(l){t[c]=l}},s=0;s<e.length;s++)i(s);return r},Xn[n].decode=function(t){var r={};et(t)&&(t=JSON.parse(t));var i=function(o){var c="get"+La(o,0,1);r[o]=t[o],r[c]=function(){return t[o]}};for(var s in t)i(s);return r}};for(var eh in wu)Zl(eh);Xn.getModule=function(n){return Xn[n]()};var th=`
  6. package Modules;
  7. message probuf {
  8. message `+Oo+`
  9. {
  10. optional int32 status=1;
  11. }
  12. message SetUserStatusOutput
  13. {
  14. optional int32 nothing=1;
  15. }
  16. message GetUserStatusInput
  17. {
  18. optional int32 nothing=1;
  19. }
  20. message GetUserStatusOutput
  21. {
  22. optional string status=1;
  23. optional string subUserId=2;
  24. }
  25. message SubUserStatusInput
  26. {
  27. repeated string userid =1;
  28. }
  29. message SubUserStatusOutput
  30. {
  31. optional int32 nothing=1;
  32. }
  33. message VoipDynamicInput
  34. {
  35. required int32 engineType = 1;
  36. required string channelName = 2;
  37. optional string channelExtra = 3;
  38. }
  39. message VoipDynamicOutput
  40. {
  41. required string dynamicKey=1;
  42. }
  43. message `+Jr+` {
  44. required int32 type = 1;
  45. optional int64 time = 2;
  46. optional string chrmId=3;
  47. }
  48. message `+_o+` {
  49. required int64 syncTime = 1;
  50. required bool ispolling = 2;
  51. optional bool isweb=3;
  52. optional bool isPullSend=4;
  53. optional bool isKeeping=5;
  54. optional int64 sendBoxSyncTime=6;
  55. }
  56. message `+Jn+` {
  57. required int32 sessionId = 1;
  58. required string classname = 2;
  59. required bytes content = 3;
  60. optional string pushText = 4;
  61. optional string appData = 5;
  62. repeated string userId = 6;
  63. optional int64 delMsgTime = 7;
  64. optional string delMsgId = 8;
  65. optional int32 configFlag = 9;
  66. optional int64 clientUniqueId = 10;
  67. optional string extraContent = 11;
  68. optional PushExtra pushExt = 12;
  69. optional string busChannel = 13; // \u8BE5\u6D88\u606F\u6240\u5C5E\u4F1A\u8BDD\u7684\u4E1A\u52A1\u6807\u8BC6
  70. }
  71. message `+go+` {
  72. optional string title = 1;
  73. optional int32 templateIdNoUse= 2;
  74. optional string pushId = 3;
  75. optional string pushConfigs = 4;
  76. optional string templateId = 5;
  77. }
  78. message `+Wn+` {
  79. repeated DownStreamMessage list = 1;
  80. required int64 syncTime = 2;
  81. optional bool finished = 3;
  82. }
  83. message `+Ci+` {
  84. required string fromUserId = 1;
  85. required ChannelType type = 2;
  86. optional string groupId = 3;
  87. required string classname = 4;
  88. required bytes content = 5;
  89. required int64 dataTime = 6;
  90. required int64 status = 7;
  91. optional int64 extra = 8;
  92. optional string msgId = 9;
  93. optional int32 direction = 10;
  94. optional int32 plantform =11;
  95. optional int32 isRemoved = 12;
  96. optional string source = 13;
  97. optional int64 clientUniqueId = 14;
  98. optional string extraContent = 15;
  99. optional string pushContent = 16;
  100. optional int32 configFlag = 17;
  101. optional PushExtra pushExt = 18;
  102. optional string busChannel = 19; // \u8BE5\u6D88\u606F\u6240\u5C5E\u4F1A\u8BDD\u7684\u4E1A\u52A1\u6807\u8BC6\uFF0C\u9650\u523620\u5B57\u7B26\u4EE5\u5185
  103. }
  104. enum ChannelType {
  105. PERSON = 1;
  106. PERSONS = 2;
  107. GROUP = 3;
  108. TEMPGROUP = 4;
  109. CUSTOMERSERVICE = 5;
  110. NOTIFY = 6;
  111. MC=7;
  112. MP=8;
  113. }
  114. message CreateDiscussionInput {
  115. optional string name = 1;
  116. }
  117. message CreateDiscussionOutput {
  118. required string id = 1;
  119. }
  120. message ChannelInvitationInput {
  121. repeated string users = 1;
  122. }
  123. message LeaveChannelInput {
  124. required int32 nothing = 1;
  125. }
  126. message ChannelEvictionInput {
  127. required string user = 1;
  128. }
  129. message RenameChannelInput {
  130. required string name = 1;
  131. }
  132. message ChannelInfoInput {
  133. required int32 nothing = 1;
  134. }
  135. message ChannelInfoOutput {
  136. required ChannelType type = 1;
  137. required string channelId = 2;
  138. required string channelName = 3;
  139. required string adminUserId = 4;
  140. repeated string firstTenUserIds = 5;
  141. required int32 openStatus = 6;
  142. }
  143. message ChannelInfosInput {
  144. required int32 page = 1;
  145. optional int32 number = 2;
  146. }
  147. message ChannelInfosOutput {
  148. repeated ChannelInfoOutput channels = 1;
  149. required int32 total = 2;
  150. }
  151. message MemberInfo {
  152. required string userId = 1;
  153. required string userName = 2;
  154. required string userPortrait = 3;
  155. required string extension = 4;
  156. }
  157. message GroupMembersInput {
  158. required int32 page = 1;
  159. optional int32 number = 2;
  160. }
  161. message GroupMembersOutput {
  162. repeated MemberInfo members = 1;
  163. required int32 total = 2;
  164. }
  165. message GetUserInfoInput {
  166. required int32 nothing = 1;
  167. }
  168. message GetUserInfoOutput {
  169. required string userId = 1;
  170. required string userName = 2;
  171. required string userPortrait = 3;
  172. }
  173. message GetSessionIdInput {
  174. required int32 nothing = 1;
  175. }
  176. message GetSessionIdOutput {
  177. required int32 sessionId = 1;
  178. }
  179. enum FileType {
  180. image = `+ke.IMAGE+`;
  181. audio = `+ke.AUDIO+`;
  182. video = `+ke.VIDEO+`;
  183. file = `+ke.FILE+`;
  184. }
  185. message `+Do+` {
  186. required FileType type = 1;
  187. optional string key = 2;
  188. optional string httpMethod = 3;
  189. optional string queryString = 4;
  190. }
  191. message `+Bo+` {
  192. required FileType type = 1;
  193. required string key = 2;
  194. optional string fileName = 3;
  195. }
  196. message `+Vo+` {
  197. required FileType type = 1;
  198. required string key = 2;
  199. optional string fileName = 3;
  200. }
  201. message `+xo+` {
  202. required int64 deadline = 1;
  203. required string token = 2;
  204. optional string bosToken = 3;
  205. optional string bosDate = 4;
  206. optional string path = 5;
  207. optional string osskeyId = 6;
  208. optional string ossPolicy = 7;
  209. optional string ossSign = 8;
  210. optional string ossBucketName = 9;
  211. optional string s3Credential = 10;
  212. optional string s3Algorithm = 11;
  213. optional string s3Date = 12;
  214. optional string s3Policy = 13;
  215. optional string s3Signature = 14;
  216. optional string s3BucketName = 15;
  217. optional string stcAuthorization = 16;
  218. optional string stcContentSha256 = 17;
  219. optional string stcDate = 18;
  220. optional string stcBucketName = 19;
  221. }
  222. message `+Fo+` {
  223. required string downloadUrl = 1;
  224. }
  225. message `+Ho+` {
  226. required string downloadUrl = 1;
  227. }
  228. message Add2BlackListInput {
  229. required string userId = 1;
  230. }
  231. message RemoveFromBlackListInput {
  232. required string userId = 1;
  233. }
  234. message QueryBlackListInput {
  235. required int32 nothing = 1;
  236. }
  237. message QueryBlackListOutput {
  238. repeated string userIds = 1;
  239. }
  240. message BlackListStatusInput {
  241. required string userId = 1;
  242. }
  243. message BlockPushInput {
  244. required string blockeeId = 1;
  245. }
  246. message ModifyPermissionInput {
  247. required int32 openStatus = 1;
  248. }
  249. message GroupInput {
  250. repeated GroupInfo groupInfo = 1;
  251. }
  252. message GroupOutput {
  253. required int32 nothing = 1;
  254. }
  255. message GroupInfo {
  256. required string id = 1;
  257. required string name = 2;
  258. }
  259. message GroupHashInput {
  260. required string userId = 1;
  261. required string groupHashCode = 2;
  262. }
  263. message GroupHashOutput {
  264. required GroupHashType result = 1;
  265. }
  266. enum GroupHashType {
  267. group_success = 0x00;
  268. group_failure = 0x01;
  269. }
  270. message `+bo+` {
  271. required int32 nothing = 1;
  272. }
  273. message `+wo+` {
  274. required int32 nothing = 1;
  275. optional string sessionId = 2;
  276. optional int64 joinTime = 3;
  277. }
  278. message `+vo+` {
  279. required int64 syncTime = 1;
  280. required int32 count = 2;
  281. }
  282. message ChrmPullMsgNew
  283. {
  284. required int32 count = 1;
  285. required int64 syncTime = 2;
  286. optional string chrmId=3;
  287. }
  288. message `+Wr+`
  289. {
  290. optional ChannelType type = 1;
  291. optional int32 count = 2;
  292. optional int64 startTime = 3;
  293. optional int32 order = 4;
  294. }
  295. message `+Ro+`
  296. {
  297. required ChannelType type = 1;
  298. optional DownStreamMessage msg =2;
  299. optional int32 count = 3;
  300. optional string busChannel = 4;
  301. optional int64 startTime = 5;
  302. optional int64 endTime = 6;
  303. }
  304. message `+Qn+`
  305. {
  306. repeated RelationInfo info = 1;
  307. }
  308. message RelationInfo
  309. {
  310. required ChannelType type = 1;
  311. required string userId = 2;
  312. optional DownStreamMessage msg =3;
  313. optional int64 readMsgTime= 4;
  314. optional int64 unreadCount= 5;
  315. optional string busChannel = 6;//\u8BE5\u6D88\u606F\u6240\u5C5E\u4F1A\u8BDD\u7684\u4E1A\u52A1\u6807\u8BC6
  316. }
  317. message RelationInfoReadTime
  318. {
  319. required ChannelType type = 1;
  320. required int64 readMsgTime= 2;
  321. required string targetId = 3;
  322. }
  323. message `+So+`
  324. {
  325. required string targetId = 1;
  326. required int64 dataTime = 2;
  327. optional int32 conversationType= 3;
  328. optional string busChannel = 4; //\u8BE5\u6D88\u606F\u6240\u5C5E\u4F1A\u8BDD\u7684\u4E1A\u52A1\u6807\u8BC6\uFF0C\u9650\u523620\u5B57\u7B26\u4EE5\u5185
  329. }
  330. message HistoryMessageInput
  331. {
  332. required string targetId = 1;
  333. required int64 dataTime =2;
  334. required int32 size = 3;
  335. }
  336. message HistoryMessagesOuput
  337. {
  338. repeated DownStreamMessage list = 1;
  339. required int64 syncTime = 2;
  340. required int32 hasMsg = 3;
  341. }
  342. message `+No+`
  343. {
  344. required int32 count= 1;
  345. optional int32 order= 2;
  346. }
  347. message `+Ei+`
  348. {
  349. optional int32 userTotalNums = 1;
  350. repeated ChrmMember userInfos = 2;
  351. }
  352. message ChrmMember
  353. {
  354. required int64 time = 1;
  355. required string id = 2;
  356. }
  357. message MPFollowInput
  358. {
  359. required string id = 1;
  360. }
  361. message MPFollowOutput
  362. {
  363. required int32 nothing = 1;
  364. optional MpInfo info =2;
  365. }
  366. message `+Po+`
  367. {
  368. required string state = 1;
  369. }
  370. message MCFollowOutput
  371. {
  372. required int32 nothing = 1;
  373. optional MpInfo info =2;
  374. }
  375. message MpInfo
  376. {
  377. required string mpid=1;
  378. required string name = 2;
  379. required string type = 3;
  380. required int64 time=4;
  381. optional string portraitUrl=5;
  382. optional string extra =6;
  383. }
  384. message SearchMpInput
  385. {
  386. required int32 type=1;
  387. required string id=2;
  388. }
  389. message SearchMpOutput
  390. {
  391. required int32 nothing=1;
  392. repeated MpInfo info = 2;
  393. }
  394. message PullMpInput
  395. {
  396. required int64 time=1;
  397. required string mpid=2;
  398. }
  399. message PullMpOutput
  400. {
  401. required int32 status=1;
  402. repeated MpInfo info = 2;
  403. }
  404. message `+yo+`
  405. {
  406. optional string targetId = 1;
  407. optional int64 time = 2;
  408. optional int32 count = 3;
  409. optional int32 order = 4;
  410. optional string busChannel = 5; //\u8BE5\u6D88\u606F\u6240\u5C5E\u4F1A\u8BDD\u7684\u4E1A\u52A1\u6807\u8BC6\uFF0C\u9650\u523620\u5B57\u7B26\u4EE5\u5185
  411. }
  412. message `+zn+`
  413. {
  414. repeated DownStreamMessage list=1;
  415. required int64 syncTime=2;
  416. required int32 hasMsg=3;
  417. }
  418. message `+ko+`{
  419. optional int32 order=1;
  420. }
  421. message `+Uo+`{
  422. repeated string key=1;
  423. }
  424. message `+ot+`{
  425. required string key=1;
  426. required string value=2;
  427. }
  428. message RtcUserInfo{
  429. required string userId=1;
  430. repeated `+ot+` userData=2; //\u7528\u6237\u8D44\u6E90\u4FE1\u606F
  431. }
  432. message `+qt+`{
  433. repeated RtcUserInfo users=1;
  434. optional string token=2;
  435. optional string sessionId=3;
  436. repeated RtcValueInfo roomInfo = 4; //\u623F\u95F4key value
  437. repeated RtcKVEntity entries = 5;//\u76F4\u64ADKV\u5C5E\u6027\u5BF9\u8C61\u96C6\u5408
  438. optional int64 syncTime = 6;//\u6240\u6709\u5C5E\u6027\u7684\u6700\u5927\u65F6\u95F4\u6233\uFF08\u4E0B\u6B21\u62C9\u53D6KV\u65F6\u7528\uFF09\u3002
  439. optional int32 offlineKickTime = 7;//server\u8D85\u65F6\u8E22\u4EBA\u65F6\u95F4\uFF0C\u9ED8\u8BA460s
  440. }
  441. message RtcRoomInfoOutput{
  442. optional string roomId = 1;
  443. repeated `+ot+` roomData = 2;
  444. optional int32 userCount = 3;
  445. repeated RtcUserInfo list=4;
  446. }
  447. message `+zr+`{
  448. required int32 roomType=1;
  449. optional int32 broadcastType=2;
  450. optional RtcValueInfo extraInnerData = 3;
  451. optional bool needSysChatroom = 4; //\u662F\u5426\u9700\u8981\u540C\u6B65\u804A\u5929\u5BA4
  452. optional IdentityChangeType identityChangeType = 5; //\u8EAB\u4EFD\u53D8\u66F4\u7C7B\u578B
  453. optional JoinType joinType = 6; // \u52A0\u5165\u623F\u95F4\u7C7B\u578B
  454. }
  455. enum JoinType {
  456. KICK = 0; //\u8E22\u524D\u4E00\u4E2A\u8BBE\u5907
  457. REFUSE = 1; //\u5F53\u524D\u52A0\u5165\u62D2\u7EDD
  458. COEXIST = 2; //\u4E24\u4E2A\u8BBE\u5907\u5171\u5B58
  459. }
  460. message RtcQryInput{
  461. required bool isInterior=1;
  462. required targetType target=2;
  463. repeated string key=3;
  464. }
  465. message `+Ti+`{
  466. repeated `+ot+` outInfo=1;
  467. }
  468. message RtcDelDataInput{
  469. repeated string key=1;
  470. required bool isInterior=2;
  471. required targetType target=3;
  472. }
  473. message `+Xr+`{
  474. required bool interior=1;
  475. required targetType target=2;
  476. repeated string key=3;
  477. optional string objectName=4;
  478. optional string content=5;
  479. }
  480. message `+Ao+`{
  481. required bool interior=1;
  482. required targetType target=2;
  483. required string key=3;
  484. required string value=4;
  485. optional string objectName=5;
  486. optional string content=6;
  487. }
  488. message `+Qr+` {
  489. repeated `+ot+` valueInfo = 1;
  490. required string objectName = 2;
  491. repeated `+ot+` content = 3;
  492. }
  493. message RtcOutput
  494. {
  495. optional int32 nothing=1;
  496. }
  497. message `+Ri+`{
  498. required string rtcToken=1;
  499. }
  500. enum targetType {
  501. ROOM =1 ;
  502. PERSON = 2;
  503. }
  504. message `+Mo+`{
  505. required targetType target=1;
  506. repeated `+ot+` valueInfo=2;
  507. optional string objectName=3;
  508. optional string content=4;
  509. }
  510. message `+Lo+`{
  511. repeated string userId = 1;
  512. }
  513. message `+vu+`{
  514. repeated RtcUserInfo user = 1;
  515. }
  516. message `+mo+`{
  517. required int32 nothing = 1;
  518. }
  519. message `+mu+`{
  520. required int64 inboxTime = 1;
  521. required int64 sendboxTime = 2;
  522. required int64 totalUnreadCount = 3;
  523. }
  524. message `+Io+`
  525. {
  526. required ChannelType type = 1;
  527. required int64 msgTime = 2;
  528. required string channelId = 3;
  529. }
  530. message SessionMsgReadOutput
  531. {
  532. optional int32 nothing=1;
  533. }
  534. message `+Co+`
  535. {
  536. repeated SessionInfo sessions = 1;
  537. }
  538. message `+Eo+`
  539. {
  540. required ChannelType type = 1;
  541. required string channelId = 2;
  542. optional string busChannel = 3;//\u6240\u5C5E\u4F1A\u8BDD\u4E1A\u52A1\u6807\u8BC6
  543. }
  544. message `+_u+`
  545. {
  546. optional int32 nothing=1;
  547. }
  548. message `+To+`
  549. {
  550. optional ChannelType type = 1;
  551. optional string conversationId = 2;
  552. repeated DeleteMsg msgs = 3;
  553. optional string busChannel = 4; //\u8BE5\u6D88\u606F\u6240\u5C5E\u4F1A\u8BDD\u7684\u4E1A\u52A1\u6807\u8BC6\uFF0C\u9650\u523620\u5B57\u7B26\u4EE5\u5185
  554. }
  555. message DeleteMsg
  556. {
  557. optional string msgId = 1;
  558. optional int64 msgDataTime = 2;
  559. optional int32 direct = 3;
  560. }
  561. message ChrmKVEntity {
  562. required string key = 1;
  563. required string value = 2;
  564. optional int32 status = 3;
  565. optional int64 timestamp = 4;
  566. optional string uid = 5;
  567. }
  568. message `+$o+` {
  569. required ChrmKVEntity entry = 1;
  570. optional bool bNotify = 2;
  571. optional UpStreamMessage notification = 3;
  572. optional ChannelType type = 4;
  573. }
  574. message `+jo+` {
  575. repeated ChrmKVEntity entry = 1;
  576. optional bool bNotify = 2;
  577. optional UpStreamMessage notification = 3;
  578. optional ChannelType type = 4;
  579. }
  580. message `+Cu+` {
  581. repeated ChrmKVEntity entry = 1;
  582. optional bool bNotify = 2;
  583. optional UpStreamMessage notification = 3;
  584. optional ChannelType type = 4;
  585. }
  586. message `+cn+` {
  587. repeated ChrmKVEntity entries = 1;
  588. optional bool bFullUpdate = 2;
  589. optional int64 syncTime = 3;
  590. }
  591. message `+Ko+` {
  592. repeated ChrmKVSOutputEntity errorKeys = 1;
  593. }
  594. message `+Eu+`
  595. {
  596. optional string key = 1;
  597. optional int32 errorCode = 2;
  598. }
  599. message `+qo+` {
  600. required int64 timestamp = 1;
  601. }
  602. message `+Ru+` {
  603. required int64 version=1;
  604. required string value=2;
  605. }
  606. message `+un+` {
  607. required int64 version=1;
  608. required bool reserve=2;
  609. }
  610. message `+Go+` {
  611. required int64 version=1;
  612. optional bool reserve=2;
  613. }
  614. message `+Si+` {
  615. repeated UserSettingItem items = 1;
  616. required int64 version=2;
  617. }
  618. message UserSettingItem {
  619. required string targetId= 1;
  620. required ChannelType type = 2;
  621. required string key = 4;
  622. required bytes value = 5;
  623. required int64 version=6;
  624. required int32 status=7;
  625. repeated SessionTagItem tags= 8;
  626. }
  627. message `+Yo+` {
  628. required int64 time = 1;
  629. }
  630. message `+bi+` {
  631. required int64 version=1;
  632. repeated SessionState state= 2;
  633. }
  634. message `+Zr+` {
  635. required ChannelType type = 1;
  636. required string channelId = 2;
  637. optional int64 time = 3;
  638. repeated SessionStateItem stateItem = 4;
  639. optional string busChannel = 5;//\u8BE5\u6D88\u606F\u6240\u5C5E\u4F1A\u8BDD\u7684\u4E1A\u52A1\u6807\u8BC6
  640. }
  641. message `+ei+` {
  642. required SessionStateType sessionStateType = 1;
  643. required string value = 2;
  644. repeated SessionTagItem tags = 3;
  645. }
  646. enum SessionStateType {
  647. IsSilent = 1;
  648. IsTop = 2;
  649. Tags = 3;
  650. }
  651. message `+ti+` {
  652. required int64 version=1;
  653. repeated SessionState state= 2;
  654. }
  655. message `+Jo+` {
  656. required int64 version=1;
  657. }
  658. message `+ni+` {
  659. repeated string msgId=1; //\u5DF2\u8BFB\u6D88\u606FID
  660. optional string channelId = 2; // \u8BE5\u6D88\u606F\u6240\u5C5E\u4F1A\u8BDD\u7684\u4E1A\u52A1\u6807\u8BC6
  661. }
  662. message `+Tu+` {
  663. repeated string msgId=1; //\u5DF2\u8BFB\u6D88\u606FID
  664. optional string channelId = 2; // \u8BE5\u6D88\u606F\u6240\u5C5E\u4F1A\u8BDD\u7684\u4E1A\u52A1\u6807\u8BC6
  665. }
  666. message `+wi+` {
  667. required int32 totalMemberNum = 1;//\u7FA4\u5185\u603B\u4EBA\u6570
  668. repeated GrpMsgReadUser list = 2;//\u5DF2\u8BFB\u7528\u6237\u5217\u8868\uFF08list\u590D\u7C7B\u578B\uFF09
  669. }
  670. message `+Su+` {
  671. required int64 readTime = 1;//\u5DF2\u8BFB\u65F6\u95F4
  672. required string userId = 2;//\u5DF2\u8BFB\u7528\u6237id
  673. }
  674. message `+Wo+` {
  675. required int64 version=1;
  676. repeated SessionTagItem tags=2;
  677. }
  678. message `+Hn+` {
  679. required string tagId=1;
  680. optional string name=2;
  681. optional int64 createdTime=3;
  682. optional bool isTop=4;
  683. }
  684. message `+zo+` {
  685. required int64 version=1;
  686. repeated SessionTagItem tags=2;
  687. }
  688. message `+Qo+` {
  689. repeated string tagId=1;
  690. }
  691. message `+Ii+` {
  692. required int64 version=1;
  693. required bool reserve=2;
  694. }
  695. message `+Xo+` {
  696. required string sdkInfo=1; // \u7528\u6237\u96C6\u6210\u7684 sdk \u4FE1\u606F,json \u683C\u5F0F {"web-rtc": "4.0.3.7"}
  697. }
  698. message `+Iu+`
  699. {
  700. optional int32 nothing=1; //\u5360\u4F4D
  701. }
  702. message `+Zo+`
  703. {
  704. required int32 type= 1; //(\u901A\u77E5\u7C7B\u578B 1:rtc\u623F\u95F4\u72B6\u6001KV\u53D8\u66F4\u901A\u77E5)
  705. optional int64 time= 2; //\u6D88\u606F\u4EA7\u751F\u65F6\u95F4
  706. optional string roomId=3; //\u4E3B\u64AD\u623F\u95F4id
  707. }
  708. message `+ea+`
  709. {
  710. required int64 timestamp = 1;
  711. required string roomId = 2;
  712. }
  713. message `+Ni+`
  714. {
  715. repeated RtcKVEntity entries = 1;
  716. optional bool bFullUpdate = 2;
  717. optional int64 syncTime = 3;
  718. }
  719. message RtcKVEntity
  720. {
  721. required string key = 1;
  722. required string value = 2;
  723. optional int32 status = 3;
  724. optional int64 timestamp = 4;
  725. optional string uid = 5;
  726. }
  727. enum IdentityChangeType
  728. {
  729. AnchorToViewer = 1; //1\u4E3A\u4E3B\u64AD\u53D8\u89C2\u4F17
  730. ViewerToAnchor = 2; //2\u4E3A\u89C2\u4F17\u53D8\u4E3B\u64AD
  731. }
  732. message `+ta+`
  733. {
  734. required string userId = 1;
  735. }
  736. message `+Oi+`
  737. {
  738. repeated RtcJoinedInfo info = 1;
  739. }
  740. message RtcJoinedInfo
  741. {
  742. required string deviceId = 1; //\u8BBE\u5907ID
  743. required string roomId = 2; //\u52A0\u5165\u7684\u623F\u95F4ID
  744. optional int64 joinTime = 3; //\u52A0\u5165\u7684\u65F6\u95F4
  745. }
  746. message `+bu+`
  747. {
  748. required string rtcToken=1;
  749. repeated RtcKVEntity entries = 2;//KV\u5C5E\u6027\u5BF9\u8C61\u96C6\u5408
  750. optional int64 syncTime = 3;//\u6240\u6709\u5C5E\u6027\u7684\u6700\u5927\u65F6\u95F4\u6233\uFF08\u4E0B\u6B21\u62C9\u53D6KV\u65F6\u7528\uFF09\u3002
  751. }
  752. message `+na+`
  753. {
  754. required string invitedUserId=1; //\u88AB\u9080\u8BF7\u7684\u4EBA\u7684uid
  755. optional int32 timeoutTime=2; //\u9080\u8BF7\u8D85\u65F6\u65F6\u95F4(\u79D2),\u9ED8\u8BA4\u4E09\u5341\u79D2
  756. required string invitedRoomId=3; //\u88AB\u9080\u8BF7\u7684\u623F\u95F4
  757. required string inviteInfo=4; //\u9080\u8BF7\u7684\u4FE1\u606F(\u5305\u542B\u9080\u8BF7\u4EBA,\u88AB\u9080\u8BF7\u4EBA,\u5404\u81EAuserid)\u5BA2\u6237\u7AEF\u5B9A\u4E49\u597D.\u534F\u8BAE\u6808\u548Cserver\u900F\u4F20
  758. required string inviteSessionId= 5; //\u5BA2\u6237\u7AEF\u4FDD\u8BC1\u552F\u4E00\u6027(\u5EFA\u8BAEroomid_userid_\u65F6\u95F4\u6233_\u968F\u673A\u6570)
  759. }
  760. message `+ra+`
  761. {
  762. required string invitedUserId=1; //\u88AB\u9080\u8BF7\u7684\u4EBA\u7684uid
  763. required string invitedRoomId=2; //\u88AB\u9080\u8BF7\u7684\u623F\u95F4
  764. required string inviteInfo=3; //\u53D6\u6D88\u9080\u8BF7\u7684\u4FE1\u606F(\u5305\u542B\u9080\u8BF7\u4EBA,\u88AB\u9080\u8BF7\u4EBA,\u5404\u81EAuserid)\u5BA2\u6237\u7AEF\u5B9A\u4E49\u597D.\u534F\u8BAE\u6808\u548Cserver\u900F\u4F20
  765. required string inviteSessionId=4; //\u9080\u8BF7\u7684sessionId,\u5BA2\u6237\u7AEF\u53D1\u8D77\u9080\u8BF7\u65F6\u4EA7\u751F
  766. }
  767. message `+ia+`
  768. {
  769. required string inviteUserId=1; //\u9080\u8BF7\u7684\u4EBA\u7684uid
  770. required int32 answerCode=2; //\u662F\u5426\u63A5\u53D7\u8FDE\u9EA6\u9080\u8BF7.0\u4E3A\u62D2\u7EDD,1\u4E3A\u63A5\u53D7
  771. required string inviteRoomId=3; //\u9080\u8BF7\u7684\u623F\u95F4
  772. required string inviteSessionId=4; //\u9080\u8BF7\u7684sessionId
  773. required string content=5; //\u9700\u8981\u8F6C\u53D1\u7684content
  774. optional string key=6; //\u5982\u679C\u63A5\u53D7\u7684\u8BDD,\u9700\u8981\u52A0\u8FD9\u4E2A\u5B57\u6BB5,\u653E\u5728room\u7EA7\u522B\u7684k\u548Cv,\u65B0\u52A0\u5165\u623F\u95F4\u7684\u80FD\u62C9\u53D6\u5230
  775. optional string value=7; //\u5982\u679C\u63A5\u53D7\u7684\u8BDD,\u9700\u8981\u52A0\u8FD9\u4E2A\u5B57\u6BB5,\u653E\u5728room\u7EA7\u522B\u7684k\u548Cv,\u65B0\u52A0\u5165\u623F\u95F4\u7684\u80FD\u62C9\u53D6\u5230
  776. }
  777. message `+sa+`
  778. {
  779. required string inviteRoomId=1; //\u9080\u8BF7\u7684\u623F\u95F4
  780. required string inviteSessionId=2; //\u9080\u8BF7\u7684sessionId
  781. required string inviteContent=3; //\u7ED3\u675F\u8FDE\u9EA6\u7684\u4FE1\u606F(\u9700\u8981\u900F\u4F20\u7ED9\u623F\u95F4\u5185\u5176\u4ED6\u4EBA)
  782. repeated string inviteRoomKeys=4; //\u9700\u8981\u5220\u9664\u8FDE\u9EA6\u7684\u4FE1\u606F\u7684key
  783. }
  784. }
  785. `,qa,Ga,wn,tn,Nn,Ds=(qa=th,function(n,e){var t,r,i={};return i.ByteBuffer=n,i.c=n,t=n,i.Long=e||null,i.VERSION="5.0.1",i.WIRE_TYPES={},i.WIRE_TYPES.VARINT=0,i.WIRE_TYPES.BITS64=1,i.WIRE_TYPES.LDELIM=2,i.WIRE_TYPES.STARTGROUP=3,i.WIRE_TYPES.ENDGROUP=4,i.WIRE_TYPES.BITS32=5,i.PACKABLE_WIRE_TYPES=[i.WIRE_TYPES.VARINT,i.WIRE_TYPES.BITS64,i.WIRE_TYPES.BITS32],i.TYPES={int32:{name:"int32",wireType:i.WIRE_TYPES.VARINT,defaultValue:0},uint32:{name:"uint32",wireType:i.WIRE_TYPES.VARINT,defaultValue:0},sint32:{name:"sint32",wireType:i.WIRE_TYPES.VARINT,defaultValue:0},int64:{name:"int64",wireType:i.WIRE_TYPES.VARINT,defaultValue:i.Long?i.Long.ZERO:void 0},uint64:{name:"uint64",wireType:i.WIRE_TYPES.VARINT,defaultValue:i.Long?i.Long.UZERO:void 0},sint64:{name:"sint64",wireType:i.WIRE_TYPES.VARINT,defaultValue:i.Long?i.Long.ZERO:void 0},bool:{name:"bool",wireType:i.WIRE_TYPES.VARINT,defaultValue:!1},double:{name:"double",wireType:i.WIRE_TYPES.BITS64,defaultValue:0},string:{name:"string",wireType:i.WIRE_TYPES.LDELIM,defaultValue:""},bytes:{name:"bytes",wireType:i.WIRE_TYPES.LDELIM,defaultValue:null},fixed32:{name:"fixed32",wireType:i.WIRE_TYPES.BITS32,defaultValue:0},sfixed32:{name:"sfixed32",wireType:i.WIRE_TYPES.BITS32,defaultValue:0},fixed64:{name:"fixed64",wireType:i.WIRE_TYPES.BITS64,defaultValue:i.Long?i.Long.UZERO:void 0},sfixed64:{name:"sfixed64",wireType:i.WIRE_TYPES.BITS64,defaultValue:i.Long?i.Long.ZERO:void 0},float:{name:"float",wireType:i.WIRE_TYPES.BITS32,defaultValue:0},enum:{name:"enum",wireType:i.WIRE_TYPES.VARINT,defaultValue:0},message:{name:"message",wireType:i.WIRE_TYPES.LDELIM,defaultValue:null},group:{name:"group",wireType:i.WIRE_TYPES.STARTGROUP,defaultValue:null}},i.MAP_KEY_TYPES=[i.TYPES.int32,i.TYPES.sint32,i.TYPES.sfixed32,i.TYPES.uint32,i.TYPES.fixed32,i.TYPES.int64,i.TYPES.sint64,i.TYPES.sfixed64,i.TYPES.uint64,i.TYPES.fixed64,i.TYPES.bool,i.TYPES.string,i.TYPES.bytes],i.ID_MIN=1,i.ID_MAX=536870911,i.convertFieldsToCamelCase=!1,i.populateAccessors=!0,i.populateDefaults=!0,i.Util=function(){var s={};return s.IS_NODE=!(typeof process!="object"||process+""!="[object process]"||process.browser),s.XHR=function(){var o,c=[function(){return new XMLHttpRequest},function(){return new ActiveXObject("Msxml2.XMLHTTP")},function(){return new ActiveXObject("Msxml3.XMLHTTP")},function(){return new ActiveXObject("Microsoft.XMLHTTP")}],d=null;for(o=0;o<c.length;o++){try{d=c[o]()}catch{continue}break}if(!d)throw Error("XMLHttpRequest is not supported");return d},s.fetch=function(o,c){if(c&&typeof c!="function"&&(c=null),s.IS_NODE)if(c)g.readFile(o,function(l,h){c(l?null:""+h)});else try{return g.readFileSync(o)}catch{return null}else{var d=s.XHR();if(d.open("GET",o,!!c),d.setRequestHeader("Accept","text/plain"),typeof d.overrideMimeType=="function"&&d.overrideMimeType("text/plain"),!c)return d.send(null),d.status==200||d.status==0&&typeof d.responseText=="string"?d.responseText:null;if(d.onreadystatechange=function(){d.readyState==4&&(d.status==200||d.status==0&&typeof d.responseText=="string"?c(d.responseText):c(null))},d.readyState==4)return;d.send(null)}},s.toCamelCase=function(o){return o.replace(/_([a-zA-Z])/g,function(c,d){return d.toUpperCase()})},s}(),i.Lang={DELIM:/[\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 c(m,_){var v=-1,y=1;if(m.charAt(0)=="-"&&(y=-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: "+(y<0?"-":"")+m);v=parseInt(m.substring(1),8)}if(v=0|y*v,!_&&v<0)throw Error("illegal id value: "+(y<0?"-":"")+m);return v}function d(m){var _=1;if(m.charAt(0)=="-"&&(_=-1,m=m.substring(1)),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,u={},f=function(m){this.source=m+"",this.index=0,this.line=1,this.stack=[],this._stringOpen=null},p=f.prototype;return p._readString=function(){var m,_=this._stringOpen==='"'?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]},p.next=function(){var m,_,v,y,C;if(this.stack.length>0)return this.stack.shift();if(this.index>=this.source.length)return null;if(this._stringOpen!==null)return this._readString();do{for(m=!1;o.WHITESPACE.test(v=this.source.charAt(this.index));)if(v===`
  786. `&&++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)!==`
  787. `;)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===`
  788. `&&++this.line,++this.index===this.source.length)return null;_=v,v=this.source.charAt(this.index)}while(_!=="*"||v!=="/");++this.index,m=!0}}while(m);if(this.index===this.source.length)return null;if(y=this.index,o.DELIM.lastIndex=0,!o.DELIM.test(this.source.charAt(y++)))for(;y<this.source.length&&!o.DELIM.test(this.source.charAt(y));)++y;return((C=this.source.substring(this.index,this.index=y))==='"'||C==="'")&&(this._stringOpen=C),C},p.peek=function(){if(this.stack.length===0){var m=this.next();if(m===null)return null;this.stack.push(m)}return this.stack[0]},p.skip=function(m){var _=this.next();if(_!==m)throw Error("illegal '"+_+"', '"+m+"' expected")},p.omit=function(m){return this.peek()===m&&(this.next(),!0)},p.toString=function(){return"Tokenizer ("+this.index+"/"+this.source.length+" at line "+this.line+")"},u.Tokenizer=f,(a=(h=function(m){this.tn=new f(m),this.proto3=!1}).prototype).parse=function(){var m,_={name:"[ROOT]",package:null,messages:[],enums:[],imports:[],options:{},services:[]},v=!0;try{for(;m=this.tn.next();)switch(m){case"package":if(!v||_.package!==null)throw Error("unexpected 'package'");if(m=this.tn.next(),!o.TYPEREF.test(m))throw Error("illegal package name: "+m);this.tn.skip(";"),_.package=m;break;case"import":if(!v)throw Error("unexpected 'import'");(m=this.tn.peek())==="public"&&this.tn.next(),m=this._readString(),this.tn.skip(";"),_.imports.push(m);break;case"syntax":if(!v)throw Error("unexpected 'syntax'");this.tn.skip("="),(_.syntax=this._readString())==="proto3"&&(this.proto3=!0),this.tn.skip(";");break;case"message":this._parseMessage(_,null),v=!1;break;case"enum":this._parseEnum(_),v=!1;break;case"option":this._parseOption(_);break;case"service":this._parseService(_);break;case"extend":this._parseExtend(_);break;default:throw Error("unexpected '"+m+"'")}}catch(y){throw y.message="Parse error at line "+this.tn.line+": "+y.message,y}return delete _.name,_},h.parse=function(m){return new h(m).parse()},a._readString=function(){var m,_,v="";do{if((_=this.tn.next())!=="'"&&_!=='"')throw Error("illegal string delimiter: "+_);v+=this.tn.next(),this.tn.skip(_),m=this.tn.peek()}while(m==='"'||m==='"');return v},a._readValue=function(m){var _=this.tn.peek();if(_==='"'||_==="'")return this._readString();if(this.tn.next(),o.NUMBER.test(_))return d(_);if(o.BOOL.test(_))return _.toLowerCase()==="true";if(m&&o.TYPEREF.test(_))return _;throw Error("illegal value: "+_)},a._parseOption=function(m,_){var v,y=this.tn.next(),C=!1;if(y==="("&&(C=!0,y=this.tn.next()),!o.TYPEREF.test(y))throw Error("illegal option name: "+y);v=y,C&&(this.tn.skip(")"),v="("+v+")",y=this.tn.peek(),o.FQTYPEREF.test(y)&&(v+=y,this.tn.next())),this.tn.skip("="),this._parseOptionValue(m,v),_||this.tn.skip(";")},a._parseOptionValue=function(m,_){var v=this.tn.peek();if(v!=="{")l(m.options,_,this._readValue(!0));else for(this.tn.skip("{");(v=this.tn.next())!=="}";){if(!o.NAME.test(v))throw Error("illegal option name: "+_+"."+v);this.tn.omit(":")?l(m.options,_+"."+v,this._readValue(!0)):this._parseOptionValue(m,_+"."+v)}},a._parseService=function(m){var _,v=this.tn.next();if(!o.NAME.test(v))throw Error("illegal service name at line "+this.tn.line+": "+v);for(_={name:v,rpc:{},options:{}},this.tn.skip("{");(v=this.tn.next())!=="}";)if(v==="option")this._parseOption(_);else{if(v!=="rpc")throw Error("illegal service token: "+v);this._parseServiceRPC(_)}this.tn.omit(";"),m.services.push(_)},a._parseServiceRPC=function(m){var _,v,y="rpc",C=this.tn.next();if(!o.NAME.test(C))throw Error("illegal rpc service method name: "+C);if(_=C,v={request:null,response:null,request_stream:!1,response_stream:!1,options:{}},this.tn.skip("("),(C=this.tn.next()).toLowerCase()==="stream"&&(v.request_stream=!0,C=this.tn.next()),!o.TYPEREF.test(C))throw Error("illegal rpc service request type: "+C);if(v.request=C,this.tn.skip(")"),(C=this.tn.next()).toLowerCase()!=="returns")throw Error("illegal rpc service request type delimiter: "+C);if(this.tn.skip("("),(C=this.tn.next()).toLowerCase()==="stream"&&(v.response_stream=!0,C=this.tn.next()),v.response=C,this.tn.skip(")"),(C=this.tn.peek())==="{"){for(this.tn.next();(C=this.tn.next())!=="}";){if(C!=="option")throw Error("illegal rpc service token: "+C);this._parseOption(v)}this.tn.omit(";")}else this.tn.skip(";");m[y]===void 0&&(m[y]={}),m[y][_]=v},a._parseMessage=function(m,_){var v=!!_,y=this.tn.next(),C={name:"",fields:[],enums:[],messages:[],options:{},services:[],oneofs:{}};if(!o.NAME.test(y))throw Error("illegal "+(v?"group":"message")+" name: "+y);for(C.name=y,v&&(this.tn.skip("="),_.id=c(this.tn.next()),C.isGroup=!0),(y=this.tn.peek())==="["&&_&&this._parseFieldOptions(_),this.tn.skip("{");(y=this.tn.next())!=="}";)if(o.RULE.test(y))this._parseMessageField(C,y);else if(y==="oneof")this._parseMessageOneOf(C);else if(y==="enum")this._parseEnum(C);else if(y==="message")this._parseMessage(C);else if(y==="option")this._parseOption(C);else if(y==="service")this._parseService(C);else if(y==="extensions")C.extensions=this._parseExtensionRanges();else if(y==="reserved")this._parseIgnored();else if(y==="extend")this._parseExtend(C);else{if(!o.TYPEREF.test(y))throw Error("illegal message token: "+y);if(!this.proto3)throw Error("illegal field rule: "+y);this._parseMessageField(C,"optional",y)}return this.tn.omit(";"),m.messages.push(C),C},a._parseIgnored=function(){for(;this.tn.peek()!==";";)this.tn.next();this.tn.skip(";")},a._parseMessageField=function(m,_,v){var y,C,b;if(!o.RULE.test(_))throw Error("illegal message field rule: "+_);if(y={rule:_,type:"",name:"",options:{},id:0},_==="map"){if(v)throw Error("illegal type: "+v);if(this.tn.skip("<"),C=this.tn.next(),!o.TYPE.test(C)&&!o.TYPEREF.test(C))throw Error("illegal message field type: "+C);if(y.keytype=C,this.tn.skip(","),C=this.tn.next(),!o.TYPE.test(C)&&!o.TYPEREF.test(C))throw Error("illegal message field: "+C);if(y.type=C,this.tn.skip(">"),C=this.tn.next(),!o.NAME.test(C))throw Error("illegal message field name: "+C);y.name=C,this.tn.skip("="),y.id=c(this.tn.next()),(C=this.tn.peek())==="["&&this._parseFieldOptions(y),this.tn.skip(";")}else if((v=v!==void 0?v:this.tn.next())==="group"){if(b=this._parseMessage(m,y),!/^[A-Z]/.test(b.name))throw Error("illegal group name: "+b.name);y.type=b.name,y.name=b.name.toLowerCase(),this.tn.omit(";")}else{if(!o.TYPE.test(v)&&!o.TYPEREF.test(v))throw Error("illegal message field type: "+v);if(y.type=v,C=this.tn.next(),!o.NAME.test(C))throw Error("illegal message field name: "+C);y.name=C,this.tn.skip("="),y.id=c(this.tn.next()),(C=this.tn.peek())==="["&&this._parseFieldOptions(y),this.tn.skip(";")}return m.fields.push(y),y},a._parseMessageOneOf=function(m){var _,v,y,C=this.tn.next();if(!o.NAME.test(C))throw Error("illegal oneof name: "+C);for(v=C,y=[],this.tn.skip("{");(C=this.tn.next())!=="}";)(_=this._parseMessageField(m,"optional",C)).oneof=v,y.push(_.id);this.tn.omit(";"),m.oneofs[v]=y},a._parseFieldOptions=function(m){this.tn.skip("[");for(var _=!0;this.tn.peek()!=="]";)_||this.tn.skip(","),this._parseOption(m,!0),_=!1;this.tn.next()},a._parseEnum=function(m){var _,v={name:"",values:[],options:{}},y=this.tn.next();if(!o.NAME.test(y))throw Error("illegal name: "+y);for(v.name=y,this.tn.skip("{");(y=this.tn.next())!=="}";)if(y==="option")this._parseOption(v);else{if(!o.NAME.test(y))throw Error("illegal name: "+y);this.tn.skip("="),_={name:y,id:c(this.tn.next(),!0)},(y=this.tn.peek())==="["&&this._parseFieldOptions({options:{}}),this.tn.skip(";"),v.values.push(_)}this.tn.omit(";"),m.enums.push(v)},a._parseExtensionRanges=function(){var m,_,v,y=[];do{for(_=[];;){switch(m=this.tn.next()){case"min":v=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()}y.push(_)}while(this.tn.omit(","));return this.tn.skip(";"),y},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},u.Parser=h,u}(i,i.Lang),i.Reflect=function(s){function o(R,T){if(R&&typeof R.low=="number"&&typeof R.high=="number"&&typeof R.unsigned=="boolean"&&R.low==R.low&&R.high==R.high)return new s.Long(R.low,R.high,T===void 0?R.unsigned:T);if(typeof R=="string")return s.Long.fromString(R,T||!1,10);if(typeof R=="number")return s.Long.fromNumber(R,T||!1);throw Error("not convertible to Long")}function c(R,T){var A=T.readVarint32(),L=7&A,k=A>>>3;switch(L){case s.WIRE_TYPES.VARINT:do A=T.readUint8();while((128&A)==128);break;case s.WIRE_TYPES.BITS64:T.offset+=8;break;case s.WIRE_TYPES.LDELIM:A=T.readVarint32(),T.offset+=A;break;case s.WIRE_TYPES.STARTGROUP:c(k,T);break;case s.WIRE_TYPES.ENDGROUP:if(k===R)return!1;throw Error("Illegal GROUPEND after unknown group: "+k+" ("+R+" expected)");case s.WIRE_TYPES.BITS32:T.offset+=4;break;default:throw Error("Illegal wire type in unknown group "+R+": "+L)}return!0}var d,l,h,a,u,f,p,m,_,v,y,C,b,O,S,E,w={},V=function(R,T,A){this.builder=R,this.parent=T,this.name=A,this.className},j=V.prototype;return j.fqn=function(){for(var R=this.name,T=this;(T=T.parent)!=null;)R=T.name+"."+R;return R},j.toString=function(R){return(R?this.className+" ":"")+this.fqn()},j.build=function(){throw Error(this.toString(!0)+" cannot be built directly")},w.T=V,(l=(d=function(R,T,A,L,k){V.call(this,R,T,A),this.className="Namespace",this.children=[],this.options=L||{},this.syntax=k||"proto2"}).prototype=Object.create(V.prototype)).getChildren=function(R){var T,A,L;if((R=R||null)==null)return this.children.slice();for(T=[],A=0,L=this.children.length;L>A;++A)this.children[A]instanceof R&&T.push(this.children[A]);return T},l.addChild=function(R){var T;if(T=this.getChild(R.name))if(T instanceof u.Field&&T.name!==T.originalName&&this.getChild(T.originalName)===null)T.name=T.originalName;else{if(!(R instanceof u.Field&&R.name!==R.originalName&&this.getChild(R.originalName)===null))throw Error("Duplicate name in namespace "+this.toString(!0)+": "+R.name);R.name=R.originalName}this.children.push(R)},l.getChild=function(R){var T,A,L=typeof R=="number"?"id":"name";for(T=0,A=this.children.length;A>T;++T)if(this.children[T][L]===R)return this.children[T];return null},l.resolve=function(R,T){var A,L=typeof R=="string"?R.split("."):R,k=this,F=0;if(L[F]===""){for(;k.parent!==null;)k=k.parent;F++}do{do{if(!(k instanceof w.Namespace)){k=null;break}if(!((A=k.getChild(L[F]))&&A instanceof w.T&&(!T||A instanceof w.Namespace))){k=null;break}k=A,F++}while(F<L.length);if(k!=null)break;if(this.parent!==null)return this.parent.resolve(R,T)}while(k!=null);return k},l.qn=function(R){var T,A,L=[],k=R;do L.unshift(k.name),k=k.parent;while(k!==null);for(T=1;T<=L.length;T++)if(A=L.slice(L.length-T),R===this.resolve(A,R instanceof w.Namespace))return A.join(".");return R.fqn()},l.build=function(){var R,T,A,L={},k=this.children;for(T=0,A=k.length;A>T;++T)(R=k[T])instanceof d&&(L[R.name]=R.build());return Object.defineProperty&&Object.defineProperty(L,"$options",{value:this.buildOpt()}),L},l.buildOpt=function(){var R,T,A,L,k={},F=Object.keys(this.options);for(R=0,T=F.length;T>R;++R)A=F[R],L=this.options[F[R]],k[A]=L;return k},l.getOption=function(R){return R===void 0?this.options:this.options[R]!==void 0?this.options[R]:null},w.Namespace=d,a=(h=function(R,T,A,L){if(this.type=R,this.resolvedType=T,this.isMapKey=A,this.syntax=L,A&&s.MAP_KEY_TYPES.indexOf(R)<0)throw Error("Invalid map key type: "+R.name)}).prototype,h.defaultFieldValue=function(R){if(typeof R=="string"&&(R=s.TYPES[R]),R.defaultValue===void 0)throw Error("default value for type "+R.name+" is not supported");return R==s.TYPES.bytes?new t(0):R.defaultValue},a.verifyValue=function(R){var T,A,L,k=function(F,H){throw Error("Illegal value for "+this.toString(!0)+" of type "+this.type.name+": "+F+" ("+H+")")}.bind(this);switch(this.type){case s.TYPES.int32:case s.TYPES.sint32:case s.TYPES.sfixed32:return(typeof R!="number"||R==R&&R%1!=0)&&k(typeof R,"not an integer"),R>4294967295?0|R:R;case s.TYPES.uint32:case s.TYPES.fixed32:return(typeof R!="number"||R==R&&R%1!=0)&&k(typeof R,"not an integer"),R<0?R>>>0:R;case s.TYPES.int64:case s.TYPES.sint64:case s.TYPES.sfixed64:if(s.Long)try{return o(R,!1)}catch(F){k(typeof R,F.message)}else k(typeof R,"requires Long.js");case s.TYPES.uint64:case s.TYPES.fixed64:if(s.Long)try{return o(R,!0)}catch(F){k(typeof R,F.message)}else k(typeof R,"requires Long.js");case s.TYPES.bool:return typeof R!="boolean"&&k(typeof R,"not a boolean"),R;case s.TYPES.float:case s.TYPES.double:return typeof R!="number"&&k(typeof R,"not a number"),R;case s.TYPES.string:return typeof R=="string"||R&&R instanceof String||k(typeof R,"not a string"),""+R;case s.TYPES.bytes:return n.isByteBuffer(R)?R:n.wrap(R);case s.TYPES.enum:for(T=this.resolvedType.getChildren(s.Reflect.Enum.Value),L=0;L<T.length;L++)if(T[L].name==R||T[L].id==R)return T[L].id;if(this.syntax==="proto3")return(typeof R!="number"||R==R&&R%1!=0)&&k(typeof R,"not an integer"),(R>4294967295||R<0)&&k(typeof R,"not in range for uint32"),R;k(R,"not a valid enum value");case s.TYPES.group:case s.TYPES.message:if(R&&typeof R=="object"||k(typeof R,"object expected"),R instanceof this.resolvedType.clazz)return R;if(R instanceof s.Builder.Message){for(L in A={},R)R.hasOwnProperty(L)&&(A[L]=R[L]);R=A}return new this.resolvedType.clazz(R)}throw Error("[INTERNAL] Illegal value for "+this.toString(!0)+": "+R+" (undefined type "+this.type+")")},a.calculateLength=function(R,T){if(T===null)return 0;var A;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 A=t.calculateUTF8Bytes(T),t.calculateVarint32(A)+A;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 A=this.resolvedType.calculate(T),t.calculateVarint32(A)+A;case s.TYPES.group:return(A=this.resolvedType.calculate(T))+t.calculateVarint32(R<<3|s.WIRE_TYPES.ENDGROUP)}throw Error("[INTERNAL] Illegal value to encode in "+this.toString(!0)+": "+T+" (unknown type)")},a.encodeValue=function(R,T,A){var L,k;if(T===null)return A;switch(this.type){case s.TYPES.int32:T<0?A.writeVarint64(T):A.writeVarint32(T);break;case s.TYPES.uint32:A.writeVarint32(T);break;case s.TYPES.sint32:A.writeVarint32ZigZag(T);break;case s.TYPES.fixed32:A.writeUint32(T);break;case s.TYPES.sfixed32:A.writeInt32(T);break;case s.TYPES.int64:case s.TYPES.uint64:A.writeVarint64(T);break;case s.TYPES.sint64:A.writeVarint64ZigZag(T);break;case s.TYPES.fixed64:A.writeUint64(T);break;case s.TYPES.sfixed64:A.writeInt64(T);break;case s.TYPES.bool:typeof T=="string"?A.writeVarint32(T.toLowerCase()==="false"?0:!!T):A.writeVarint32(T?1:0);break;case s.TYPES.enum:A.writeVarint32(T);break;case s.TYPES.float:A.writeFloat32(T);break;case s.TYPES.double:A.writeFloat64(T);break;case s.TYPES.string:A.writeVString(T);break;case s.TYPES.bytes:if(T.remaining()<0)throw Error("Illegal value for "+this.toString(!0)+": "+T.remaining()+" bytes remaining");L=T.offset,A.writeVarint32(T.remaining()),A.append(T),T.offset=L;break;case s.TYPES.message:k=new t().LE(),this.resolvedType.encode(T,k),A.writeVarint32(k.offset),A.append(k.flip());break;case s.TYPES.group:this.resolvedType.encode(T,A),A.writeVarint32(R<<3|s.WIRE_TYPES.ENDGROUP);break;default:throw Error("[INTERNAL] Illegal value to encode in "+this.toString(!0)+": "+T+" (unknown type)")}return A},a.decode=function(R,T,A){if(T!=this.type.wireType)throw Error("Unexpected wire type for element");var L,k;switch(this.type){case s.TYPES.int32:return 0|R.readVarint32();case s.TYPES.uint32:return R.readVarint32()>>>0;case s.TYPES.sint32:return 0|R.readVarint32ZigZag();case s.TYPES.fixed32:return R.readUint32()>>>0;case s.TYPES.sfixed32:return 0|R.readInt32();case s.TYPES.int64:return R.readVarint64();case s.TYPES.uint64:return R.readVarint64().toUnsigned();case s.TYPES.sint64:return R.readVarint64ZigZag();case s.TYPES.fixed64:return R.readUint64();case s.TYPES.sfixed64:return R.readInt64();case s.TYPES.bool:return!!R.readVarint32();case s.TYPES.enum:return R.readVarint32();case s.TYPES.float:return R.readFloat();case s.TYPES.double:return R.readDouble();case s.TYPES.string:return R.readVString();case s.TYPES.bytes:if(k=R.readVarint32(),R.remaining()<k)throw Error("Illegal number of bytes for "+this.toString(!0)+": "+k+" required but got only "+R.remaining());return(L=R.clone()).limit=L.offset+k,R.offset+=k,L;case s.TYPES.message:return k=R.readVarint32(),this.resolvedType.decode(R,k);case s.TYPES.group:return this.resolvedType.decode(R,-1,A)}throw Error("[INTERNAL] Illegal decode type")},a.valueFromString=function(R){if(!this.isMapKey)throw Error("valueFromString() called on non-map-key element");switch(this.type){case s.TYPES.int32:case s.TYPES.sint32:case s.TYPES.sfixed32:case s.TYPES.uint32:case s.TYPES.fixed32:return this.verifyValue(parseInt(R));case s.TYPES.int64:case s.TYPES.sint64:case s.TYPES.sfixed64:case s.TYPES.uint64:case s.TYPES.fixed64:return this.verifyValue(R);case s.TYPES.bool:return R==="true";case s.TYPES.string:return this.verifyValue(R);case s.TYPES.bytes:return t.fromBinary(R)}},a.valueToString=function(R){if(!this.isMapKey)throw Error("valueToString() called on non-map-key element");return this.type===s.TYPES.bytes?R.toString("binary"):R.toString()},w.Element=h,(f=(u=function(R,T,A,L,k,F){d.call(this,R,T,A,L,F),this.className="Message",this.extensions=void 0,this.clazz=null,this.isGroup=!!k,this._fields=null,this._fieldsById=null,this._fieldsByName=null}).prototype=Object.create(d.prototype)).build=function(R){var T,A,L,k;if(this.clazz&&!R)return this.clazz;for(T=function(F,H){function G(U,J,ee,ie){var ue,ye,pr,In,Vi,Fi,Xt;if(U===null||typeof U!="object")return ie&&ie instanceof F.Reflect.Enum&&(ue=F.Reflect.Enum.getName(ie.object,U))!==null?ue:U;if(t.isByteBuffer(U))return J?U.toBase64():U.toBuffer();if(F.Long.isLong(U))return ee?U.toString():F.Long.fromValue(U);if(Array.isArray(U))return ye=[],U.forEach(function(pl,gl){ye[gl]=G(pl,J,ee,ie)}),ye;if(ye={},U instanceof F.Map){for(In=(pr=U.entries()).next();!In.done;In=pr.next())ye[U.keyElem.valueToString(In.value[0])]=G(In.value[1],J,ee,U.valueElem.resolvedType);return ye}for(Xt in Vi=U.$type,Fi=void 0,U)U.hasOwnProperty(Xt)&&(ye[Xt]=Vi&&(Fi=Vi.getChild(Xt))?G(U[Xt],J,ee,Fi.resolvedType):G(U[Xt],J,ee));return ye}var W,oe,he=H.getChildren(F.Reflect.Message.Field),de=H.getChildren(F.Reflect.Message.OneOf),ae=function(U){var J,ee,ie,ue;for(F.Builder.Message.call(this),J=0,ee=de.length;ee>J;++J)this[de[J].name]=null;for(J=0,ee=he.length;ee>J;++J)this[(ie=he[J]).name]=ie.repeated?[]:ie.map?new F.Map(ie):null,!ie.required&&H.syntax!=="proto3"||ie.defaultValue===null||(this[ie.name]=ie.defaultValue);if(arguments.length>0)if(arguments.length!==1||U===null||typeof U!="object"||!(typeof U.encode!="function"||U instanceof ae)||Array.isArray(U)||U instanceof F.Map||t.isByteBuffer(U)||U instanceof ArrayBuffer||F.Long&&U instanceof F.Long)for(J=0,ee=arguments.length;ee>J;++J)(ue=arguments[J])!==void 0&&this.$set(he[J].name,ue);else this.$set(U)},te=ae.prototype=Object.create(F.Builder.Message.prototype);for(te.add=function(U,J,ee){var ie=H._fieldsByName[U];if(!ee){if(!ie)throw Error(this+"#"+U+" is undefined");if(!(ie instanceof F.Reflect.Message.Field))throw Error(this+"#"+U+" is not a field: "+ie.toString(!0));if(!ie.repeated)throw Error(this+"#"+U+" is not a repeated field");J=ie.verifyValue(J,!0)}return this[U]===null&&(this[U]=[]),this[U].push(J),this},te.$add=te.add,te.set=function(U,J,ee){var ie,ue,ye;if(U&&typeof U=="object"){for(ie in ee=J,U)U.hasOwnProperty(ie)&&(J=U[ie])!==void 0&&this.$set(ie,J,ee);return this}if(ue=H._fieldsByName[U],ee)this[U]=J;else{if(!ue)throw Error(this+"#"+U+" is not a field: undefined");if(!(ue instanceof F.Reflect.Message.Field))throw Error(this+"#"+U+" is not a field: "+ue.toString(!0));this[ue.name]=J=ue.verifyValue(J)}return ue&&ue.oneof&&(ye=this[ue.oneof.name],J!==null?(ye!==null&&ye!==ue.name&&(this[ye]=null),this[ue.oneof.name]=ue.name):ye===U&&(this[ue.oneof.name]=null)),this},te.$set=te.set,te.get=function(U,J){if(J)return this[U];var ee=H._fieldsByName[U];if(!(ee&&ee instanceof F.Reflect.Message.Field))throw Error(this+"#"+U+" is not a field: undefined");if(!(ee instanceof F.Reflect.Message.Field))throw Error(this+"#"+U+" is not a field: "+ee.toString(!0));return this[ee.name]},te.$get=te.get,W=0;W<he.length;W++)(oe=he[W])instanceof F.Reflect.Message.ExtensionField||H.builder.options.populateAccessors&&function(U){var J,ee,ie,ue=U.originalName.replace(/(_[a-zA-Z])/g,function(ye){return ye.toUpperCase().replace("_","")});ue=ue.substring(0,1).toUpperCase()+ue.substring(1),J=U.originalName.replace(/([A-Z])/g,function(ye){return"_"+ye}),ee=function(ye,pr){return this[U.name]=pr?ye:U.verifyValue(ye),this},ie=function(){return this[U.name]},H.getChild("set"+ue)===null&&(te["set"+ue]=ee),H.getChild("set_"+J)===null&&(te["set_"+J]=ee),H.getChild("get"+ue)===null&&(te["get"+ue]=ie),H.getChild("get_"+J)===null&&(te["get_"+J]=ie)}(oe);return te.encode=function(U,J){var ee,ie;typeof U=="boolean"&&(J=U,U=void 0),ee=!1,U||(U=new n,ee=!0),ie=U.littleEndian;try{return H.encode(this,U.LE(),J),(ee?U.flip():U).LE(ie)}catch(ue){throw U.LE(ie),ue}},ae.encode=function(U,J,ee){return new ae(U).encode(J,ee)},te.calculate=function(){return H.calculate(this)},te.encodeDelimited=function(U){var J,ee=!1;return U||(U=new t,ee=!0),J=new t().LE(),H.encode(this,J).flip(),U.writeVarint32(J.remaining()),U.append(J),ee?U.flip():U},te.encodeAB=function(){try{return this.encode().toArrayBuffer()}catch(U){throw U.encoded&&(U.encoded=U.encoded.toArrayBuffer()),U}},te.toArrayBuffer=te.encodeAB,te.encodeNB=function(){try{return this.encode().toBuffer()}catch(U){throw U.encoded&&(U.encoded=U.encoded.toBuffer()),U}},te.toBuffer=te.encodeNB,te.encode64=function(){try{return this.encode().toBase64()}catch(U){throw U.encoded&&(U.encoded=U.encoded.toBase64()),U}},te.toBase64=te.encode64,te.encodeHex=function(){try{return this.encode().toHex()}catch(U){throw U.encoded&&(U.encoded=U.encoded.toHex()),U}},te.toHex=te.encodeHex,te.toRaw=function(U,J){return G(this,!!U,!!J,this.$type)},te.encodeJSON=function(){return JSON.stringify(G(this,!0,!0,this.$type))},ae.decode=function(U,J){var ee,ie;typeof U=="string"&&(U=t.wrap(U,J||"base64")),ee=(U=t.isByteBuffer(U)?U:t.wrap(U)).littleEndian;try{return ie=H.decode(U.LE()),U.LE(ee),ie}catch(ue){throw U.LE(ee),ue}},ae.decodeDelimited=function(U,J){var ee,ie,ue;if(typeof U=="string"&&(U=t.wrap(U,J||"base64")),(U=t.isByteBuffer(U)?U:t.wrap(U)).remaining()<1)return null;if(ee=U.offset,ie=U.readVarint32(),U.remaining()<ie)return U.offset=ee,null;try{return ue=H.decode(U.slice(U.offset,U.offset+ie).LE()),U.offset+=ie,ue}catch(ye){throw U.offset+=ie,ye}},ae.decode64=function(U){return ae.decode(U,"base64")},ae.decodeHex=function(U){return ae.decode(U,"hex")},ae.decodeJSON=function(U){return new ae(JSON.parse(U))},te.toString=function(){return H.toString()},Object.defineProperty&&(Object.defineProperty(ae,"$options",{value:H.buildOpt()}),Object.defineProperty(te,"$options",{value:ae.$options}),Object.defineProperty(ae,"$type",{value:H}),Object.defineProperty(te,"$type",{value:H})),ae}(s,this),this._fields=[],this._fieldsById={},this._fieldsByName={},L=0,k=this.children.length;k>L;L++)if((A=this.children[L])instanceof y||A instanceof u||A instanceof O){if(T.hasOwnProperty(A.name))throw Error("Illegal reflect child of "+this.toString(!0)+": "+A.toString(!0)+" cannot override static property '"+A.name+"'");T[A.name]=A.build()}else if(A instanceof u.Field)A.build(),this._fields.push(A),this._fieldsById[A.id]=A,this._fieldsByName[A.name]=A;else if(!(A instanceof u.OneOf||A instanceof b))throw Error("Illegal reflect child of "+this.toString(!0)+": "+this.children[L].toString(!0));return this.clazz=T},f.encode=function(R,T,A){var L,k,F,H,G,W=null;for(F=0,H=this._fields.length;H>F;++F)k=R[(L=this._fields[F]).name],L.required&&k===null?W===null&&(W=L):L.encode(A?k:L.verifyValue(k),T,R);if(W!==null)throw(G=Error("Missing at least one required field for "+this.toString(!0)+": "+W)).encoded=T,G;return T},f.calculate=function(R){for(var T,A,L=0,k=0,F=this._fields.length;F>k;++k){if(A=R[(T=this._fields[k]).name],T.required&&A===null)throw Error("Missing at least one required field for "+this.toString(!0)+": "+T);L+=T.calculate(A,R)}return L},f.decode=function(R,T,A){var L,k,F,H,G,W,oe,he,de,ae,te,U;for(T=typeof T=="number"?T:-1,G=R.offset,W=new this.clazz;R.offset<G+T||T===-1&&R.remaining()>0;){if(F=(L=R.readVarint32())>>>3,(k=7&L)===s.WIRE_TYPES.ENDGROUP){if(F!==A)throw Error("Illegal group end indicator for "+this.toString(!0)+": "+F+" ("+(A?A+" expected":"not a group")+")");break}if(H=this._fieldsById[F])H.repeated&&!H.options.packed?W[H.name].push(H.decode(k,R)):H.map?(he=H.decode(k,R),W[H.name].set(he[0],he[1])):(W[H.name]=H.decode(k,R),H.oneof&&((de=W[H.oneof.name])!==null&&de!==H.name&&(W[de]=null),W[H.oneof.name]=H.name));else switch(k){case s.WIRE_TYPES.VARINT:R.readVarint32();break;case s.WIRE_TYPES.BITS32:R.offset+=4;break;case s.WIRE_TYPES.BITS64:R.offset+=8;break;case s.WIRE_TYPES.LDELIM:oe=R.readVarint32(),R.offset+=oe;break;case s.WIRE_TYPES.STARTGROUP:for(;c(F,R););break;default:throw Error("Illegal wire type for unknown field "+F+" in "+this.toString(!0)+"#decode: "+k)}}for(ae=0,te=this._fields.length;te>ae;++ae)if(W[(H=this._fields[ae]).name]===null)if(this.syntax==="proto3")W[H.name]=H.defaultValue;else{if(H.required)throw(U=Error("Missing at least one required field for "+this.toString(!0)+": "+H.name)).decoded=W,U;s.populateDefaults&&H.defaultValue!==null&&(W[H.name]=H.defaultValue)}return W},w.Message=u,(m=(p=function(R,T,A,L,k,F,H,G,W,oe){V.call(this,R,T,F),this.className="Message.Field",this.required=A==="required",this.repeated=A==="repeated",this.map=A==="map",this.keyType=L||null,this.type=k,this.resolvedType=null,this.id=H,this.options=G||{},this.defaultValue=null,this.oneof=W||null,this.syntax=oe||"proto2",this.originalName=this.name,this.element=null,this.keyElement=null,!this.builder.options.convertFieldsToCamelCase||this instanceof u.ExtensionField||(this.name=s.Util.toCamelCase(this.name))}).prototype=Object.create(V.prototype)).build=function(){this.element=new h(this.type,this.resolvedType,!1,this.syntax),this.map&&(this.keyElement=new h(this.keyType,void 0,!0,this.syntax)),this.syntax!=="proto3"||this.repeated||this.map?this.options.default!==void 0&&(this.defaultValue=this.verifyValue(this.options.default)):this.defaultValue=h.defaultFieldValue(this.type)},m.verifyValue=function(R,T){var A,L,k;if(T=T||!1,A=function(F,H){throw Error("Illegal value for "+this.toString(!0)+" of type "+this.type.name+": "+F+" ("+H+")")}.bind(this),R===null)return this.required&&A(typeof R,"required"),this.syntax==="proto3"&&this.type!==s.TYPES.message&&A(typeof R,"proto3 field without field presence cannot be null"),null;if(this.repeated&&!T){for(Array.isArray(R)||(R=[R]),k=[],L=0;L<R.length;L++)k.push(this.element.verifyValue(R[L]));return k}return this.map&&!T?R instanceof s.Map?R:(R instanceof Object||A(typeof R,"expected ProtoBuf.Map or raw object for map field"),new s.Map(this,R)):(!this.repeated&&Array.isArray(R)&&A(typeof R,"no array expected"),this.element.verifyValue(R))},m.hasWirePresence=function(R,T){if(this.syntax!=="proto3")return R!==null;if(this.oneof&&T[this.oneof.name]===this.name)return!0;switch(this.type){case s.TYPES.int32:case s.TYPES.sint32:case s.TYPES.sfixed32:case s.TYPES.uint32:case s.TYPES.fixed32:return R!==0;case s.TYPES.int64:case s.TYPES.sint64:case s.TYPES.sfixed64:case s.TYPES.uint64:case s.TYPES.fixed64:return R.low!==0||R.high!==0;case s.TYPES.bool:return R;case s.TYPES.float:case s.TYPES.double:return R!==0;case s.TYPES.string:return R.length>0;case s.TYPES.bytes:return R.remaining()>0;case s.TYPES.enum:return R!==0;case s.TYPES.message:return R!==null;default:return!0}},m.encode=function(R,T,A){var L,k,F,H,G;if(this.type===null||typeof this.type!="object")throw Error("[INTERNAL] Unresolved type in "+this.toString(!0)+": "+this.type);if(R===null||this.repeated&&R.length==0)return 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,L=0;L<R.length;L++)this.element.encodeValue(this.id,R[L],T);F=T.offset-k,(H=t.calculateVarint32(F))>1&&(G=T.slice(k,T.offset),k+=H-1,T.offset=k,T.append(G)),T.writeVarint32(F,k-H)}else for(L=0;L<R.length;L++)T.writeVarint32(this.id<<3|this.type.wireType),this.element.encodeValue(this.id,R[L],T);else this.map?R.forEach(function(W,oe){var he=t.calculateVarint32(8|this.keyType.wireType)+this.keyElement.calculateLength(1,oe)+t.calculateVarint32(16|this.type.wireType)+this.element.calculateLength(2,W);T.writeVarint32(this.id<<3|s.WIRE_TYPES.LDELIM),T.writeVarint32(he),T.writeVarint32(8|this.keyType.wireType),this.keyElement.encodeValue(1,oe,T),T.writeVarint32(16|this.type.wireType),this.element.encodeValue(2,W,T)},this):this.hasWirePresence(R,A)&&(T.writeVarint32(this.id<<3|this.type.wireType),this.element.encodeValue(this.id,R,T))}catch(W){throw Error("Illegal value for "+this.toString(!0)+": "+R+" ("+W+")")}return T},m.calculate=function(R,T){var A,L,k;if(R=this.verifyValue(R),this.type===null||typeof this.type!="object")throw Error("[INTERNAL] Unresolved type in "+this.toString(!0)+": "+this.type);if(R===null||this.repeated&&R.length==0)return 0;A=0;try{if(this.repeated)if(this.options.packed&&s.PACKABLE_WIRE_TYPES.indexOf(this.type.wireType)>=0){for(A+=t.calculateVarint32(this.id<<3|s.WIRE_TYPES.LDELIM),k=0,L=0;L<R.length;L++)k+=this.element.calculateLength(this.id,R[L]);A+=t.calculateVarint32(k),A+=k}else for(L=0;L<R.length;L++)A+=t.calculateVarint32(this.id<<3|this.type.wireType),A+=this.element.calculateLength(this.id,R[L]);else this.map?R.forEach(function(F,H){var G=t.calculateVarint32(8|this.keyType.wireType)+this.keyElement.calculateLength(1,H)+t.calculateVarint32(16|this.type.wireType)+this.element.calculateLength(2,F);A+=t.calculateVarint32(this.id<<3|s.WIRE_TYPES.LDELIM),A+=t.calculateVarint32(G),A+=G},this):this.hasWirePresence(R,T)&&(A+=t.calculateVarint32(this.id<<3|this.type.wireType),A+=this.element.calculateLength(this.id,R))}catch(F){throw Error("Illegal value for "+this.toString(!0)+": "+R+" ("+F+")")}return A},m.decode=function(R,T,A){var L,k,F,H,G,W,oe;if(!(!this.map&&R==this.type.wireType||!A&&this.repeated&&this.options.packed&&R==s.WIRE_TYPES.LDELIM||this.map&&R==s.WIRE_TYPES.LDELIM))throw Error("Illegal wire type for field "+this.toString(!0)+": "+R+" ("+this.type.wireType+" expected)");if(R==s.WIRE_TYPES.LDELIM&&this.repeated&&this.options.packed&&s.PACKABLE_WIRE_TYPES.indexOf(this.type.wireType)>=0&&!A){for(k=T.readVarint32(),k=T.offset+k,F=[];T.offset<k;)F.push(this.decode(this.type.wireType,T,!0));return F}if(this.map){if(H=h.defaultFieldValue(this.keyType),L=h.defaultFieldValue(this.type),k=T.readVarint32(),T.remaining()<k)throw Error("Illegal number of bytes for "+this.toString(!0)+": "+k+" required but got only "+T.remaining());for((G=T.clone()).limit=G.offset+k,T.offset+=k;G.remaining()>0;)if(R=7&(W=G.readVarint32()),(oe=W>>>3)==1)H=this.keyElement.decode(G,R,oe);else{if(oe!==2)throw Error("Unexpected tag in map field key/value submessage");L=this.element.decode(G,R,oe)}return[H,L]}return this.element.decode(T,R,this.id)},w.Message.Field=p,(_=function(R,T,A,L,k,F,H){p.call(this,R,T,A,null,L,k,F,H),this.extension}).prototype=Object.create(p.prototype),w.Message.ExtensionField=_,v=function(R,T,A){V.call(this,R,T,A),this.fields=[]},w.Message.OneOf=v,(y=function(R,T,A,L,k){d.call(this,R,T,A,L,k),this.className="Enum",this.object=null}).getName=function(R,T){var A,L,k=Object.keys(R);for(L=0;L<k.length;++L)if(R[A=k[L]]===T)return A;return null},(y.prototype=Object.create(d.prototype)).build=function(R){var T,A,L,k;if(this.object&&!R)return this.object;for(T=new s.Builder.Enum,L=0,k=(A=this.getChildren(y.Value)).length;k>L;++L)T[A[L].name]=A[L].id;return Object.defineProperty&&Object.defineProperty(T,"$options",{value:this.buildOpt(),enumerable:!1}),this.object=T},w.Enum=y,(C=function(R,T,A,L){V.call(this,R,T,A),this.className="Enum.Value",this.id=L}).prototype=Object.create(V.prototype),w.Enum.Value=C,(b=function(R,T,A,L){V.call(this,R,T,A),this.field=L}).prototype=Object.create(V.prototype),w.Extension=b,((O=function(R,T,A,L){d.call(this,R,T,A,L),this.className="Service",this.clazz=null}).prototype=Object.create(d.prototype)).build=function(R){return this.clazz&&!R?this.clazz:this.clazz=function(T,A){var L,k=function(G){T.Builder.Service.call(this),this.rpcImpl=G||function(W,oe,he){setTimeout(he.bind(this,Error("Not implemented, see: https://github.com/dcodeIO/ProtoBuf.js/wiki/Services")),0)}},F=k.prototype=Object.create(T.Builder.Service.prototype),H=A.getChildren(T.Reflect.Service.RPCMethod);for(L=0;L<H.length;L++)(function(G){F[G.name]=function(W,oe){try{try{W=G.resolvedRequestType.clazz.decode(t.wrap(W))}catch(he){if(!(he instanceof TypeError))throw he}if(W===null||typeof W!="object")throw Error("Illegal arguments");W instanceof G.resolvedRequestType.clazz||(W=new G.resolvedRequestType.clazz(W)),this.rpcImpl(G.fqn(),W,function(he,de){if(!he){try{de=G.resolvedResponseType.clazz.decode(de)}catch{}return de&&de instanceof G.resolvedResponseType.clazz?void oe(null,de):void oe(Error("Illegal response type received in service method "+A.name+"#"+G.name))}oe(he)})}catch(he){setTimeout(oe.bind(this,he),0)}},k[G.name]=function(W,oe,he){new k(W)[G.name](oe,he)},Object.defineProperty&&(Object.defineProperty(k[G.name],"$options",{value:G.buildOpt()}),Object.defineProperty(F[G.name],"$options",{value:k[G.name].$options}))})(H[L]);return Object.defineProperty&&(Object.defineProperty(k,"$options",{value:A.buildOpt()}),Object.defineProperty(F,"$options",{value:k.$options}),Object.defineProperty(k,"$type",{value:A}),Object.defineProperty(F,"$type",{value:A})),k}(s,this)},w.Service=O,((S=function(R,T,A,L){V.call(this,R,T,A),this.className="Service.Method",this.options=L||{}}).prototype=Object.create(V.prototype)).buildOpt=l.buildOpt,w.Service.Method=S,(E=function(R,T,A,L,k,F,H,G){S.call(this,R,T,A,G),this.className="Service.RPCMethod",this.requestName=L,this.responseName=k,this.requestStream=F,this.responseStream=H,this.resolvedRequestType=null,this.resolvedResponseType=null}).prototype=Object.create(S.prototype),w.Service.RPCMethod=E,w}(i),i.Builder=function(s,o,c){function d(a){a.messages&&a.messages.forEach(function(u){u.syntax=a.syntax,d(u)}),a.enums&&a.enums.forEach(function(u){u.syntax=a.syntax})}var l=function(a){this.ns=new c.Namespace(this,null,""),this.ptr=this.ns,this.resolved=!1,this.result=null,this.files={},this.importRoot=null,this.options=a||{}},h=l.prototype;return l.isMessage=function(a){return typeof a.name=="string"&&a.values===void 0&&a.rpc===void 0},l.isMessageField=function(a){return typeof a.rule=="string"&&typeof a.name=="string"&&typeof a.type=="string"&&a.id!==void 0},l.isEnum=function(a){return typeof a.name=="string"&&!(a.values===void 0||!Array.isArray(a.values)||a.values.length===0)},l.isService=function(a){return!(typeof a.name!="string"||typeof a.rpc!="object"||!a.rpc)},l.isExtend=function(a){return typeof a.ref=="string"},h.reset=function(){return this.ptr=this.ns,this},h.define=function(a){if(typeof a!="string"||!o.TYPEREF.test(a))throw Error("illegal namespace: "+a);return a.split(".").forEach(function(u){var f=this.ptr.getChild(u);f===null&&this.ptr.addChild(f=new c.Namespace(this,this.ptr,u)),this.ptr=f},this),this},h.create=function(a){var u,f,p,m,_;if(!a)return this;if(Array.isArray(a)){if(a.length===0)return this;a=a.slice()}else a=[a];for(u=[a];u.length>0;){if(a=u.pop(),!Array.isArray(a))throw Error("not a valid namespace: "+JSON.stringify(a));for(;a.length>0;){if(f=a.shift(),l.isMessage(f)){if(p=new c.Message(this,this.ptr,f.name,f.options,f.isGroup,f.syntax),m={},f.oneofs&&Object.keys(f.oneofs).forEach(function(v){p.addChild(m[v]=new c.Message.OneOf(this,p,v))},this),f.fields&&f.fields.forEach(function(v){if(p.getChild(0|v.id)!==null)throw Error("duplicate or invalid field id in "+p.name+": "+v.id);if(v.options&&typeof v.options!="object")throw Error("illegal field options in "+p.name+"#"+v.name);var y=null;if(typeof v.oneof=="string"&&!(y=m[v.oneof]))throw Error("illegal oneof in "+p.name+"#"+v.name+": "+v.oneof);v=new c.Message.Field(this,p,v.rule,v.keytype,v.type,v.name,v.id,v.options,y,f.syntax),y&&y.fields.push(v),p.addChild(v)},this),_=[],f.enums&&f.enums.forEach(function(v){_.push(v)}),f.messages&&f.messages.forEach(function(v){_.push(v)}),f.services&&f.services.forEach(function(v){_.push(v)}),f.extensions&&(p.extensions=typeof f.extensions[0]=="number"?[f.extensions]:f.extensions),this.ptr.addChild(p),_.length>0){u.push(a),a=_,_=null,this.ptr=p,p=null;continue}_=null}else if(l.isEnum(f))p=new c.Enum(this,this.ptr,f.name,f.options,f.syntax),f.values.forEach(function(v){p.addChild(new c.Enum.Value(this,p,v.name,v.id))},this),this.ptr.addChild(p);else if(l.isService(f))p=new c.Service(this,this.ptr,f.name,f.options),Object.keys(f.rpc).forEach(function(v){var y=f.rpc[v];p.addChild(new c.Service.RPCMethod(this,p,v,y.request,y.response,!!y.request_stream,!!y.response_stream,y.options))},this),this.ptr.addChild(p);else{if(!l.isExtend(f))throw Error("not a valid definition: "+JSON.stringify(f));if(p=this.ptr.resolve(f.ref,!0))f.fields.forEach(function(v){var y,C,b,O;if(p.getChild(0|v.id)!==null)throw Error("duplicate extended field id in "+p.name+": "+v.id);if(p.extensions&&(y=!1,p.extensions.forEach(function(S){v.id>=S[0]&&v.id<=S[1]&&(y=!0)}),!y))throw Error("illegal extended field id in "+p.name+": "+v.id+" (not within valid ranges)");C=v.name,this.options.convertFieldsToCamelCase&&(C=s.Util.toCamelCase(C)),b=new c.Message.ExtensionField(this,p,v.rule,v.type,this.ptr.fqn()+"."+C,v.id,v.options),O=new c.Extension(this,this.ptr,v.name,b),b.extension=O,this.ptr.addChild(O),p.addChild(b)},this);else if(!/\.?google\.protobuf\./.test(f.ref))throw Error("extended message "+f.ref+" is not defined")}f=null,p=null}a=null,this.ptr=this.ptr.parent}return this.resolved=!1,this.result=null,this},h.import=function(a,u){var f,p,m,_,v,y,C,b,O="/";if(typeof u=="string"){if(s.Util.IS_NODE,this.files[u]===!0)return this.reset();this.files[u]=!0}else if(typeof u=="object"){if(f=u.root,s.Util.IS_NODE,(f.indexOf("\\")>=0||u.file.indexOf("\\")>=0)&&(O="\\"),p=f+O+u.file,this.files[p]===!0)return this.reset();this.files[p]=!0}if(a.imports&&a.imports.length>0){for(_=!1,typeof u=="object"?(this.importRoot=u.root,_=!0,m=this.importRoot,u=u.file,(m.indexOf("\\")>=0||u.indexOf("\\")>=0)&&(O="\\")):typeof u=="string"?this.importRoot?m=this.importRoot:u.indexOf("/")>=0?(m=u.replace(/\/[^\/]*$/,""))===""&&(m="/"):u.indexOf("\\")>=0?(m=u.replace(/\\[^\\]*$/,""),O="\\"):m=".":m=null,v=0;v<a.imports.length;v++)if(typeof a.imports[v]=="string"){if(!m)throw Error("cannot determine import root");if((y=a.imports[v])==="google/protobuf/descriptor.proto"||(y=m+O+y,this.files[y]===!0))continue;if(/\.proto$/i.test(y)&&!s.DotProto&&(y=y.replace(/\.proto$/,".json")),(C=s.Util.fetch(y))===null)throw Error("failed to import '"+y+"' in '"+u+"': file not found");/\.json$/i.test(y)?this.import(JSON.parse(C+""),y):this.import(s.DotProto.Parser.parse(C),y)}else u?/\.(\w+)$/.test(u)?this.import(a.imports[v],u.replace(/^(.+)\.(\w+)$/,function(S,E,w){return E+"_import"+v+"."+w})):this.import(a.imports[v],u+"_import"+v):this.import(a.imports[v]);_&&(this.importRoot=null)}return a.package&&this.define(a.package),a.syntax&&d(a),b=this.ptr,a.options&&Object.keys(a.options).forEach(function(S){b.options[S]=a.options[S]}),a.messages&&(this.create(a.messages),this.ptr=b),a.enums&&(this.create(a.enums),this.ptr=b),a.services&&(this.create(a.services),this.ptr=b),a.extends&&this.create(a.extends),this.reset()},h.resolveAll=function(){var a;if(this.ptr==null||typeof this.ptr.type=="object")return this;if(this.ptr instanceof c.Namespace)this.ptr.children.forEach(function(u){this.ptr=u,this.resolveAll()},this);else if(this.ptr instanceof c.Message.Field){if(o.TYPE.test(this.ptr.type))this.ptr.type=s.TYPES[this.ptr.type];else{if(!o.TYPEREF.test(this.ptr.type))throw Error("illegal type reference in "+this.ptr.toString(!0)+": "+this.ptr.type);if(!(a=(this.ptr instanceof c.Message.ExtensionField?this.ptr.extension.parent:this.ptr.parent).resolve(this.ptr.type,!0)))throw Error("unresolvable type reference in "+this.ptr.toString(!0)+": "+this.ptr.type);if(this.ptr.resolvedType=a,a instanceof c.Enum){if(this.ptr.type=s.TYPES.enum,this.ptr.syntax==="proto3"&&a.syntax!=="proto3")throw Error("proto3 message cannot reference proto2 enum")}else{if(!(a instanceof c.Message))throw Error("illegal type reference in "+this.ptr.toString(!0)+": "+this.ptr.type);this.ptr.type=a.isGroup?s.TYPES.group:s.TYPES.message}}if(this.ptr.map){if(!o.TYPE.test(this.ptr.keyType))throw Error("illegal key type for map field in "+this.ptr.toString(!0)+": "+this.ptr.keyType);this.ptr.keyType=s.TYPES[this.ptr.keyType]}}else if(this.ptr instanceof s.Reflect.Service.Method){if(!(this.ptr instanceof s.Reflect.Service.RPCMethod))throw Error("illegal service type in "+this.ptr.toString(!0));if(!((a=this.ptr.parent.resolve(this.ptr.requestName,!0))&&a instanceof s.Reflect.Message))throw Error("Illegal type reference in "+this.ptr.toString(!0)+": "+this.ptr.requestName);if(this.ptr.resolvedRequestType=a,!((a=this.ptr.parent.resolve(this.ptr.responseName,!0))&&a instanceof s.Reflect.Message))throw Error("Illegal type reference in "+this.ptr.toString(!0)+": "+this.ptr.responseName);this.ptr.resolvedResponseType=a}else if(!(this.ptr instanceof s.Reflect.Message.OneOf||this.ptr instanceof s.Reflect.Extension||this.ptr instanceof s.Reflect.Enum.Value))throw Error("illegal object in namespace: "+typeof this.ptr+": "+this.ptr);return this.reset()},h.build=function(a){var u,f,p;if(this.reset(),this.resolved||(this.resolveAll(),this.resolved=!0,this.result=null),this.result===null&&(this.result=this.ns.build()),!a)return this.result;for(u=typeof a=="string"?a.split("."):a,f=this.result,p=0;p<u.length;p++){if(!f[u[p]]){f=null;break}f=f[u[p]]}return f},h.lookup=function(a,u){return a?this.ns.resolve(a,u):this.ns},h.toString=function(){return"Builder"},l.Message=function(){},l.Enum=function(){},l.Service=function(){},l}(i,i.Lang,i.Reflect),i.Map=function(s,o){function c(h){var a=0;return{next:function(){return a<h.length?{done:!1,value:h[a++]}:{done:!0}}}}var d=function(h,a){var u,f,p,m;if(!h.map)throw Error("field is not a map");if(this.field=h,this.keyElem=new o.Element(h.keyType,null,!0,h.syntax),this.valueElem=new o.Element(h.type,h.resolvedType,!1,h.syntax),this.map={},Object.defineProperty(this,"size",{get:function(){return Object.keys(this.map).length}}),a)for(u=Object.keys(a),f=0;f<u.length;f++)p=this.keyElem.valueFromString(u[f]),m=this.valueElem.verifyValue(a[u[f]]),this.map[this.keyElem.valueToString(p)]={key:p,value:m}},l=d.prototype;return l.clear=function(){this.map={}},l.delete=function(h){var a=this.keyElem.valueToString(this.keyElem.verifyValue(h)),u=a in this.map;return delete this.map[a],u},l.entries=function(){var h,a,u=[],f=Object.keys(this.map);for(a=0;a<f.length;a++)u.push([(h=this.map[f[a]]).key,h.value]);return c(u)},l.keys=function(){var h,a=[],u=Object.keys(this.map);for(h=0;h<u.length;h++)a.push(this.map[u[h]].key);return c(a)},l.values=function(){var h,a=[],u=Object.keys(this.map);for(h=0;h<u.length;h++)a.push(this.map[u[h]].value);return c(a)},l.forEach=function(h,a){var u,f,p=Object.keys(this.map);for(f=0;f<p.length;f++)h.call(a,(u=this.map[p[f]]).value,u.key,this)},l.set=function(h,a){var u=this.keyElem.verifyValue(h),f=this.valueElem.verifyValue(a);return this.map[this.keyElem.valueToString(u)]={key:u,value:f},this},l.get=function(h){var a=this.keyElem.valueToString(this.keyElem.verifyValue(h));return a in this.map?this.map[a].value:void 0},l.has=function(h){return this.keyElem.valueToString(this.keyElem.verifyValue(h))in this.map},d}(0,i.Reflect),i.loadProto=function(s,o,c){return(typeof o=="string"||o&&typeof o.file=="string"&&typeof o.root=="string")&&(c=o,o=void 0),i.loadJson(i.DotProto.Parser.parse(s),o,c)},i.protoFromString=i.loadProto,i.loadProtoFile=function(s,o,c){if(o&&typeof o=="object"?(c=o,o=null):o&&typeof o=="function"||(o=null),o)return i.Util.fetch(typeof s=="string"?s:s.root+"/"+s.file,function(l){if(l!==null)try{o(null,i.loadProto(l,c,s))}catch(h){o(h)}else o(Error("Failed to fetch file"))});var d=i.Util.fetch(typeof s=="object"?s.root+"/"+s.file:s);return d===null?null:i.loadProto(d,c,s)},i.protoFromFile=i.loadProtoFile,i.newBuilder=function(s){return(s=s||{}).convertFieldsToCamelCase===void 0&&(s.convertFieldsToCamelCase=i.convertFieldsToCamelCase),s.populateAccessors===void 0&&(s.populateAccessors=i.populateAccessors),new i.Builder(s)},i.loadJson=function(s,o,c){return(typeof o=="string"||o&&typeof o.file=="string"&&typeof o.root=="string")&&(c=o,o=null),o&&typeof o=="object"||(o=i.newBuilder()),typeof s=="string"&&(s=JSON.parse(s)),o.import(s,c),o.resolveAll(),o},i.loadJsonFile=function(s,o,c){if(o&&typeof o=="object"?(c=o,o=null):o&&typeof o=="function"||(o=null),o)return i.Util.fetch(typeof s=="string"?s:s.root+"/"+s.file,function(l){if(l!==null)try{o(null,i.loadJson(JSON.parse(l),c,s))}catch(h){o(h)}else o(Error("Failed to fetch file"))});var d=i.Util.fetch(typeof s=="object"?s.root+"/"+s.file:s);return d===null?null:i.loadJson(JSON.parse(d),c,s)},r=qa,i.loadProto(r,void 0,"").build("Modules").probuf}(function(n){function e(a){var u=0;return function(){return u<a.length?a.charCodeAt(u++):null}}function t(){var a=[],u=[];return function(){return arguments.length===0?u.join("")+c.apply(String,a):(a.length+arguments.length>1024&&(u.push(c.apply(String,a)),a.length=0),void Array.prototype.push.apply(a,arguments))}}function r(a,u,f,p,m){var _,v,y=8*m-p-1,C=(1<<y)-1,b=C>>1,O=-7,S=f?m-1:0,E=f?-1:1,w=a[u+S];for(S+=E,_=w&(1<<-O)-1,w>>=-O,O+=y;O>0;_=256*_+a[u+S],S+=E,O-=8);for(v=_&(1<<-O)-1,_>>=-O,O+=p;O>0;v=256*v+a[u+S],S+=E,O-=8);if(_===0)_=1-b;else{if(_===C)return v?NaN:1/0*(w?-1:1);v+=Math.pow(2,p),_-=b}return(w?-1:1)*v*Math.pow(2,_-p)}function i(a,u,f,p,m,_){var v,y,C,b=8*_-m-1,O=(1<<b)-1,S=O>>1,E=m===23?Math.pow(2,-24)-Math.pow(2,-77):0,w=p?0:_-1,V=p?1:-1,j=u<0||u===0&&1/u<0?1:0;for(u=Math.abs(u),isNaN(u)||1/0===u?(y=isNaN(u)?1:0,v=O):(v=Math.floor(Math.log(u)/Math.LN2),u*(C=Math.pow(2,-v))<1&&(v--,C*=2),(u+=v+S>=1?E/C:E*Math.pow(2,1-S))*C>=2&&(v++,C/=2),v+S>=O?(y=0,v=O):v+S>=1?(y=(u*C-1)*Math.pow(2,m),v+=S):(y=u*Math.pow(2,S-1)*Math.pow(2,m),v=0));m>=8;a[f+w]=255&y,w+=V,y/=256,m-=8);for(v=v<<m|y,b+=m;b>0;a[f+w]=255&v,w+=V,v/=256,b-=8);a[f+w-V]|=128*j}var s,o,c,d,l,h=function(a,u,f){if(a===void 0&&(a=h.DEFAULT_CAPACITY),u===void 0&&(u=h.DEFAULT_ENDIAN),f===void 0&&(f=h.DEFAULT_NOASSERT),!f){if((a|=0)<0)throw RangeError("Illegal capacity");u=!!u,f=!!f}this.buffer=a===0?o:new ArrayBuffer(a),this.view=a===0?null:new Uint8Array(this.buffer),this.offset=0,this.markedOffset=-1,this.limit=a,this.littleEndian=u,this.noAssert=f};return h.VERSION="5.0.1",h.LITTLE_ENDIAN=!0,h.BIG_ENDIAN=!1,h.DEFAULT_CAPACITY=16,h.DEFAULT_ENDIAN=h.BIG_ENDIAN,h.DEFAULT_NOASSERT=!1,h.Long=n||null,(s=h.prototype).__isByteBuffer__,Object.defineProperty(s,"__isByteBuffer__",{value:!0,enumerable:!1,configurable:!1}),o=new ArrayBuffer(0),c=String.fromCharCode,h.accessor=function(){return Uint8Array},h.allocate=function(a,u,f){return new h(a,u,f)},h.concat=function(a,u,f,p){var m,_,v,y,C,b;for((typeof u=="boolean"||typeof u!="string")&&(p=f,f=u,u=void 0),m=0,v=0,y=a.length;y>v;++v)h.isByteBuffer(a[v])||(a[v]=h.wrap(a[v],u)),(_=a[v].limit-a[v].offset)>0&&(m+=_);if(m===0)return new h(0,f,p);for(b=new h(m,f,p),v=0;y>v;)(_=(C=a[v++]).limit-C.offset)<=0||(b.view.set(C.view.subarray(C.offset,C.limit),b.offset),b.offset+=_);return b.limit=b.offset,b.offset=0,b},h.isByteBuffer=function(a){return(a&&a.__isByteBuffer__)===!0},h.type=function(){return ArrayBuffer},h.wrap=function(a,u,f,p){var m,_;if(typeof u!="string"&&(p=f,f=u,u=void 0),typeof a=="string")switch(u===void 0&&(u="utf8"),u){case"base64":return h.fromBase64(a,f);case"hex":return h.fromHex(a,f);case"binary":return h.fromBinary(a,f);case"utf8":return h.fromUTF8(a,f);case"debug":return h.fromDebug(a,f);default:throw Error("Unsupported encoding: "+u)}if(a===null||typeof a!="object")throw TypeError("Illegal buffer");if(h.isByteBuffer(a))return(m=s.clone.call(a)).markedOffset=-1,m;if(a instanceof Uint8Array)m=new h(0,f,p),a.length>0&&(m.buffer=a.buffer,m.offset=a.byteOffset,m.limit=a.byteOffset+a.byteLength,m.view=new Uint8Array(a.buffer));else if(a instanceof ArrayBuffer)m=new h(0,f,p),a.byteLength>0&&(m.buffer=a,m.offset=0,m.limit=a.byteLength,m.view=a.byteLength>0?new Uint8Array(a):null);else{if(Object.prototype.toString.call(a)!=="[object Array]")throw TypeError("Illegal buffer");for((m=new h(a.length,f,p)).limit=a.length,_=0;_<a.length;++_)m.view[_]=a[_]}return m},s.writeBitSet=function(a,u){var f,p,m,_,v,y,C=u===void 0;if(C&&(u=this.offset),!this.noAssert){if(!(a instanceof Array))throw TypeError("Illegal BitSet: Not an array");if(typeof u!="number"||u%1!=0)throw TypeError("Illegal offset: "+u+" (not an integer)");if((u>>>=0)<0||u+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+u+" (+0) <= "+this.buffer.byteLength)}for(p=u,_=(m=a.length)>>3,v=0,u+=this.writeVarint32(m,u);_--;)f=1&!!a[v++]|(1&!!a[v++])<<1|(1&!!a[v++])<<2|(1&!!a[v++])<<3|(1&!!a[v++])<<4|(1&!!a[v++])<<5|(1&!!a[v++])<<6|(1&!!a[v++])<<7,this.writeByte(f,u++);if(m>v){for(y=0,f=0;m>v;)f|=(1&!!a[v++])<<y++;this.writeByte(f,u++)}return C?(this.offset=u,this):u-p},s.readBitSet=function(a){var u,f,p,m,_,v,y,C=a===void 0;for(C&&(a=this.offset),m=(p=(f=this.readVarint32(a)).value)>>3,_=0,v=[],a+=f.length;m--;)u=this.readByte(a++),v[_++]=!!(1&u),v[_++]=!!(2&u),v[_++]=!!(4&u),v[_++]=!!(8&u),v[_++]=!!(16&u),v[_++]=!!(32&u),v[_++]=!!(64&u),v[_++]=!!(128&u);if(p>_)for(y=0,u=this.readByte(a++);p>_;)v[_++]=!!(1&u>>y++);return C&&(this.offset=a),v},s.readBytes=function(a,u){var f,p=u===void 0;if(p&&(u=this.offset),!this.noAssert){if(typeof u!="number"||u%1!=0)throw TypeError("Illegal offset: "+u+" (not an integer)");if((u>>>=0)<0||u+a>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+u+" (+"+a+") <= "+this.buffer.byteLength)}return f=this.slice(u,u+a),p&&(this.offset+=a),f},s.writeBytes=s.append,s.writeInt8=function(a,u){var f,p=u===void 0;if(p&&(u=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal value: "+a+" (not an integer)");if(a|=0,typeof u!="number"||u%1!=0)throw TypeError("Illegal offset: "+u+" (not an integer)");if((u>>>=0)<0||u+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+u+" (+0) <= "+this.buffer.byteLength)}return(u+=1)>(f=this.buffer.byteLength)&&this.resize((f*=2)>u?f:u),u-=1,this.view[u]=a,p&&(this.offset+=1),this},s.writeByte=s.writeInt8,s.readInt8=function(a){var u,f=a===void 0;if(f&&(a=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal offset: "+a+" (not an integer)");if((a>>>=0)<0||a+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+1) <= "+this.buffer.byteLength)}return(128&(u=this.view[a]))==128&&(u=-(255-u+1)),f&&(this.offset+=1),u},s.readByte=s.readInt8,s.writeUint8=function(a,u){var f,p=u===void 0;if(p&&(u=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal value: "+a+" (not an integer)");if(a>>>=0,typeof u!="number"||u%1!=0)throw TypeError("Illegal offset: "+u+" (not an integer)");if((u>>>=0)<0||u+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+u+" (+0) <= "+this.buffer.byteLength)}return(u+=1)>(f=this.buffer.byteLength)&&this.resize((f*=2)>u?f:u),u-=1,this.view[u]=a,p&&(this.offset+=1),this},s.writeUInt8=s.writeUint8,s.readUint8=function(a){var u,f=a===void 0;if(f&&(a=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal offset: "+a+" (not an integer)");if((a>>>=0)<0||a+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+1) <= "+this.buffer.byteLength)}return u=this.view[a],f&&(this.offset+=1),u},s.readUInt8=s.readUint8,s.writeInt16=function(a,u){var f,p=u===void 0;if(p&&(u=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal value: "+a+" (not an integer)");if(a|=0,typeof u!="number"||u%1!=0)throw TypeError("Illegal offset: "+u+" (not an integer)");if((u>>>=0)<0||u+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+u+" (+0) <= "+this.buffer.byteLength)}return(u+=2)>(f=this.buffer.byteLength)&&this.resize((f*=2)>u?f:u),u-=2,this.littleEndian?(this.view[u+1]=(65280&a)>>>8,this.view[u]=255&a):(this.view[u]=(65280&a)>>>8,this.view[u+1]=255&a),p&&(this.offset+=2),this},s.writeShort=s.writeInt16,s.readInt16=function(a){var u,f=a===void 0;if(f&&(a=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal offset: "+a+" (not an integer)");if((a>>>=0)<0||a+2>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+2) <= "+this.buffer.byteLength)}return u=0,this.littleEndian?(u=this.view[a],u|=this.view[a+1]<<8):(u=this.view[a]<<8,u|=this.view[a+1]),(32768&u)==32768&&(u=-(65535-u+1)),f&&(this.offset+=2),u},s.readShort=s.readInt16,s.writeUint16=function(a,u){var f,p=u===void 0;if(p&&(u=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal value: "+a+" (not an integer)");if(a>>>=0,typeof u!="number"||u%1!=0)throw TypeError("Illegal offset: "+u+" (not an integer)");if((u>>>=0)<0||u+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+u+" (+0) <= "+this.buffer.byteLength)}return(u+=2)>(f=this.buffer.byteLength)&&this.resize((f*=2)>u?f:u),u-=2,this.littleEndian?(this.view[u+1]=(65280&a)>>>8,this.view[u]=255&a):(this.view[u]=(65280&a)>>>8,this.view[u+1]=255&a),p&&(this.offset+=2),this},s.writeUInt16=s.writeUint16,s.readUint16=function(a){var u,f=a===void 0;if(f&&(a=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal offset: "+a+" (not an integer)");if((a>>>=0)<0||a+2>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+2) <= "+this.buffer.byteLength)}return u=0,this.littleEndian?(u=this.view[a],u|=this.view[a+1]<<8):(u=this.view[a]<<8,u|=this.view[a+1]),f&&(this.offset+=2),u},s.readUInt16=s.readUint16,s.writeInt32=function(a,u){var f,p=u===void 0;if(p&&(u=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal value: "+a+" (not an integer)");if(a|=0,typeof u!="number"||u%1!=0)throw TypeError("Illegal offset: "+u+" (not an integer)");if((u>>>=0)<0||u+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+u+" (+0) <= "+this.buffer.byteLength)}return(u+=4)>(f=this.buffer.byteLength)&&this.resize((f*=2)>u?f:u),u-=4,this.littleEndian?(this.view[u+3]=255&a>>>24,this.view[u+2]=255&a>>>16,this.view[u+1]=255&a>>>8,this.view[u]=255&a):(this.view[u]=255&a>>>24,this.view[u+1]=255&a>>>16,this.view[u+2]=255&a>>>8,this.view[u+3]=255&a),p&&(this.offset+=4),this},s.writeInt=s.writeInt32,s.readInt32=function(a){var u,f=a===void 0;if(f&&(a=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal offset: "+a+" (not an integer)");if((a>>>=0)<0||a+4>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+4) <= "+this.buffer.byteLength)}return u=0,this.littleEndian?(u=this.view[a+2]<<16,u|=this.view[a+1]<<8,u|=this.view[a],u+=this.view[a+3]<<24>>>0):(u=this.view[a+1]<<16,u|=this.view[a+2]<<8,u|=this.view[a+3],u+=this.view[a]<<24>>>0),u|=0,f&&(this.offset+=4),u},s.readInt=s.readInt32,s.writeUint32=function(a,u){var f,p=u===void 0;if(p&&(u=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal value: "+a+" (not an integer)");if(a>>>=0,typeof u!="number"||u%1!=0)throw TypeError("Illegal offset: "+u+" (not an integer)");if((u>>>=0)<0||u+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+u+" (+0) <= "+this.buffer.byteLength)}return(u+=4)>(f=this.buffer.byteLength)&&this.resize((f*=2)>u?f:u),u-=4,this.littleEndian?(this.view[u+3]=255&a>>>24,this.view[u+2]=255&a>>>16,this.view[u+1]=255&a>>>8,this.view[u]=255&a):(this.view[u]=255&a>>>24,this.view[u+1]=255&a>>>16,this.view[u+2]=255&a>>>8,this.view[u+3]=255&a),p&&(this.offset+=4),this},s.writeUInt32=s.writeUint32,s.readUint32=function(a){var u,f=a===void 0;if(f&&(a=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal offset: "+a+" (not an integer)");if((a>>>=0)<0||a+4>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+4) <= "+this.buffer.byteLength)}return u=0,this.littleEndian?(u=this.view[a+2]<<16,u|=this.view[a+1]<<8,u|=this.view[a],u+=this.view[a+3]<<24>>>0):(u=this.view[a+1]<<16,u|=this.view[a+2]<<8,u|=this.view[a+3],u+=this.view[a]<<24>>>0),f&&(this.offset+=4),u},s.readUInt32=s.readUint32,n&&(s.writeInt64=function(a,u){var f,p,m,_=u===void 0;if(_&&(u=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 u!="number"||u%1!=0)throw TypeError("Illegal offset: "+u+" (not an integer)");if((u>>>=0)<0||u+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+u+" (+0) <= "+this.buffer.byteLength)}return typeof a=="number"?a=n.fromNumber(a):typeof a=="string"&&(a=n.fromString(a)),(u+=8)>(f=this.buffer.byteLength)&&this.resize((f*=2)>u?f:u),u-=8,p=a.low,m=a.high,this.littleEndian?(this.view[u+3]=255&p>>>24,this.view[u+2]=255&p>>>16,this.view[u+1]=255&p>>>8,this.view[u]=255&p,u+=4,this.view[u+3]=255&m>>>24,this.view[u+2]=255&m>>>16,this.view[u+1]=255&m>>>8,this.view[u]=255&m):(this.view[u]=255&m>>>24,this.view[u+1]=255&m>>>16,this.view[u+2]=255&m>>>8,this.view[u+3]=255&m,u+=4,this.view[u]=255&p>>>24,this.view[u+1]=255&p>>>16,this.view[u+2]=255&p>>>8,this.view[u+3]=255&p),_&&(this.offset+=8),this},s.writeLong=s.writeInt64,s.readInt64=function(a){var u,f,p,m=a===void 0;if(m&&(a=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal offset: "+a+" (not an integer)");if((a>>>=0)<0||a+8>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+8) <= "+this.buffer.byteLength)}return u=0,f=0,this.littleEndian?(u=this.view[a+2]<<16,u|=this.view[a+1]<<8,u|=this.view[a],u+=this.view[a+3]<<24>>>0,a+=4,f=this.view[a+2]<<16,f|=this.view[a+1]<<8,f|=this.view[a],f+=this.view[a+3]<<24>>>0):(f=this.view[a+1]<<16,f|=this.view[a+2]<<8,f|=this.view[a+3],f+=this.view[a]<<24>>>0,a+=4,u=this.view[a+1]<<16,u|=this.view[a+2]<<8,u|=this.view[a+3],u+=this.view[a]<<24>>>0),p=new n(u,f,!1),m&&(this.offset+=8),p},s.readLong=s.readInt64,s.writeUint64=function(a,u){var f,p,m,_=u===void 0;if(_&&(u=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 u!="number"||u%1!=0)throw TypeError("Illegal offset: "+u+" (not an integer)");if((u>>>=0)<0||u+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+u+" (+0) <= "+this.buffer.byteLength)}return typeof a=="number"?a=n.fromNumber(a):typeof a=="string"&&(a=n.fromString(a)),(u+=8)>(f=this.buffer.byteLength)&&this.resize((f*=2)>u?f:u),u-=8,p=a.low,m=a.high,this.littleEndian?(this.view[u+3]=255&p>>>24,this.view[u+2]=255&p>>>16,this.view[u+1]=255&p>>>8,this.view[u]=255&p,u+=4,this.view[u+3]=255&m>>>24,this.view[u+2]=255&m>>>16,this.view[u+1]=255&m>>>8,this.view[u]=255&m):(this.view[u]=255&m>>>24,this.view[u+1]=255&m>>>16,this.view[u+2]=255&m>>>8,this.view[u+3]=255&m,u+=4,this.view[u]=255&p>>>24,this.view[u+1]=255&p>>>16,this.view[u+2]=255&p>>>8,this.view[u+3]=255&p),_&&(this.offset+=8),this},s.writeUInt64=s.writeUint64,s.readUint64=function(a){var u,f,p,m=a===void 0;if(m&&(a=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal offset: "+a+" (not an integer)");if((a>>>=0)<0||a+8>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+8) <= "+this.buffer.byteLength)}return u=0,f=0,this.littleEndian?(u=this.view[a+2]<<16,u|=this.view[a+1]<<8,u|=this.view[a],u+=this.view[a+3]<<24>>>0,a+=4,f=this.view[a+2]<<16,f|=this.view[a+1]<<8,f|=this.view[a],f+=this.view[a+3]<<24>>>0):(f=this.view[a+1]<<16,f|=this.view[a+2]<<8,f|=this.view[a+3],f+=this.view[a]<<24>>>0,a+=4,u=this.view[a+1]<<16,u|=this.view[a+2]<<8,u|=this.view[a+3],u+=this.view[a]<<24>>>0),p=new n(u,f,!0),m&&(this.offset+=8),p},s.readUInt64=s.readUint64),s.writeFloat32=function(a,u){var f,p=u===void 0;if(p&&(u=this.offset),!this.noAssert){if(typeof a!="number")throw TypeError("Illegal value: "+a+" (not a number)");if(typeof u!="number"||u%1!=0)throw TypeError("Illegal offset: "+u+" (not an integer)");if((u>>>=0)<0||u+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+u+" (+0) <= "+this.buffer.byteLength)}return(u+=4)>(f=this.buffer.byteLength)&&this.resize((f*=2)>u?f:u),u-=4,i(this.view,a,u,this.littleEndian,23,4),p&&(this.offset+=4),this},s.writeFloat=s.writeFloat32,s.readFloat32=function(a){var u,f=a===void 0;if(f&&(a=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal offset: "+a+" (not an integer)");if((a>>>=0)<0||a+4>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+4) <= "+this.buffer.byteLength)}return u=r(this.view,a,this.littleEndian,23,4),f&&(this.offset+=4),u},s.readFloat=s.readFloat32,s.writeFloat64=function(a,u){var f,p=u===void 0;if(p&&(u=this.offset),!this.noAssert){if(typeof a!="number")throw TypeError("Illegal value: "+a+" (not a number)");if(typeof u!="number"||u%1!=0)throw TypeError("Illegal offset: "+u+" (not an integer)");if((u>>>=0)<0||u+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+u+" (+0) <= "+this.buffer.byteLength)}return(u+=8)>(f=this.buffer.byteLength)&&this.resize((f*=2)>u?f:u),u-=8,i(this.view,a,u,this.littleEndian,52,8),p&&(this.offset+=8),this},s.writeDouble=s.writeFloat64,s.readFloat64=function(a){var u,f=a===void 0;if(f&&(a=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal offset: "+a+" (not an integer)");if((a>>>=0)<0||a+8>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+8) <= "+this.buffer.byteLength)}return u=r(this.view,a,this.littleEndian,52,8),f&&(this.offset+=8),u},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,u){var f,p,m,_=u===void 0;if(_&&(u=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal value: "+a+" (not an integer)");if(a|=0,typeof u!="number"||u%1!=0)throw TypeError("Illegal offset: "+u+" (not an integer)");if((u>>>=0)<0||u+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+u+" (+0) <= "+this.buffer.byteLength)}for((u+=p=h.calculateVarint32(a))>(m=this.buffer.byteLength)&&this.resize((m*=2)>u?m:u),u-=p,a>>>=0;a>=128;)f=128|127&a,this.view[u++]=f,a>>>=7;return this.view[u++]=a,_?(this.offset=u,this):p},s.writeVarint32ZigZag=function(a,u){return this.writeVarint32(h.zigZagEncode32(a),u)},s.readVarint32=function(a){var u,f,p,m,_=a===void 0;if(_&&(a=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal offset: "+a+" (not an integer)");if((a>>>=0)<0||a+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+1) <= "+this.buffer.byteLength)}f=0,p=0;do{if(!this.noAssert&&a>this.limit)throw(m=Error("Truncated")).truncated=!0,m;u=this.view[a++],f<5&&(p|=(127&u)<<7*f),++f}while((128&u)!=0);return p|=0,_?(this.offset=a,p):{value:p,length:f}},s.readVarint32ZigZag=function(a){var u=this.readVarint32(a);return typeof u=="object"?u.value=h.zigZagDecode32(u.value):u=h.zigZagDecode32(u),u},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 u=a.toInt()>>>0,f=a.shiftRightUnsigned(28).toInt()>>>0,p=a.shiftRightUnsigned(56).toInt()>>>0;return p==0?f==0?u<16384?u<128?1:2:1<<21>u?3:4:f<16384?f<128?5:6:1<<21>f?7:8:p<128?9:10},h.zigZagEncode64=function(a){return typeof a=="number"?a=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,u){var f,p,m,_,v,y=u===void 0;if(y&&(u=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 u!="number"||u%1!=0)throw TypeError("Illegal offset: "+u+" (not an integer)");if((u>>>=0)<0||u+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+u+" (+0) <= "+this.buffer.byteLength)}switch(typeof a=="number"?a=n.fromNumber(a,!1):typeof a=="string"?a=n.fromString(a,!1):a.unsigned!==!1&&(a=a.toSigned()),f=h.calculateVarint64(a),p=a.toInt()>>>0,m=a.shiftRightUnsigned(28).toInt()>>>0,_=a.shiftRightUnsigned(56).toInt()>>>0,(u+=f)>(v=this.buffer.byteLength)&&this.resize((v*=2)>u?v:u),u-=f,f){case 10:this.view[u+9]=1&_>>>7;case 9:this.view[u+8]=f!==9?128|_:127&_;case 8:this.view[u+7]=f!==8?128|m>>>21:127&m>>>21;case 7:this.view[u+6]=f!==7?128|m>>>14:127&m>>>14;case 6:this.view[u+5]=f!==6?128|m>>>7:127&m>>>7;case 5:this.view[u+4]=f!==5?128|m:127&m;case 4:this.view[u+3]=f!==4?128|p>>>21:127&p>>>21;case 3:this.view[u+2]=f!==3?128|p>>>14:127&p>>>14;case 2:this.view[u+1]=f!==2?128|p>>>7:127&p>>>7;case 1:this.view[u]=f!==1?128|p:127&p}return y?(this.offset+=f,this):f},s.writeVarint64ZigZag=function(a,u){return this.writeVarint64(h.zigZagEncode64(a),u)},s.readVarint64=function(a){var u,f,p,m,_,v,y=a===void 0;if(y&&(a=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal offset: "+a+" (not an integer)");if((a>>>=0)<0||a+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+1) <= "+this.buffer.byteLength)}if(u=a,f=0,p=0,m=0,_=0,f=127&(_=this.view[a++]),128&_&&(f|=(127&(_=this.view[a++]))<<7,(128&_||this.noAssert&&_===void 0)&&(f|=(127&(_=this.view[a++]))<<14,(128&_||this.noAssert&&_===void 0)&&(f|=(127&(_=this.view[a++]))<<21,(128&_||this.noAssert&&_===void 0)&&(p=127&(_=this.view[a++]),(128&_||this.noAssert&&_===void 0)&&(p|=(127&(_=this.view[a++]))<<7,(128&_||this.noAssert&&_===void 0)&&(p|=(127&(_=this.view[a++]))<<14,(128&_||this.noAssert&&_===void 0)&&(p|=(127&(_=this.view[a++]))<<21,(128&_||this.noAssert&&_===void 0)&&(m=127&(_=this.view[a++]),(128&_||this.noAssert&&_===void 0)&&(m|=(127&(_=this.view[a++]))<<7,128&_||this.noAssert&&_===void 0))))))))))throw Error("Buffer overrun");return v=n.fromBits(f|p<<28,p>>>4|m<<24,!1),y?(this.offset=a,v):{value:v,length:a-u}},s.readVarint64ZigZag=function(a){var u=this.readVarint64(a);return u&&u.value instanceof n?u.value=h.zigZagDecode64(u.value):u=h.zigZagDecode64(u),u}),s.writeCString=function(a,u){var f,p,m,_=u===void 0;if(_&&(u=this.offset),p=a.length,!this.noAssert){if(typeof a!="string")throw TypeError("Illegal str: Not a string");for(f=0;p>f;++f)if(a.charCodeAt(f)===0)throw RangeError("Illegal str: Contains NULL-characters");if(typeof u!="number"||u%1!=0)throw TypeError("Illegal offset: "+u+" (not an integer)");if((u>>>=0)<0||u+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+u+" (+0) <= "+this.buffer.byteLength)}return p=l.calculateUTF16asUTF8(e(a))[1],u+=p+1,m=this.buffer.byteLength,u>m&&this.resize((m*=2)>u?m:u),u-=p+1,l.encodeUTF16toUTF8(e(a),function(v){this.view[u++]=v}.bind(this)),this.view[u++]=0,_?(this.offset=u,this):p},s.readCString=function(a){var u,f,p,m=a===void 0;if(m&&(a=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal offset: "+a+" (not an integer)");if((a>>>=0)<0||a+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+1) <= "+this.buffer.byteLength)}return u=a,p=-1,l.decodeUTF8toUTF16(function(){if(p===0)return null;if(a>=this.limit)throw RangeError("Illegal range: Truncated data, "+a+" < "+this.limit);return(p=this.view[a++])===0?null:p}.bind(this),f=t(),!0),m?(this.offset=a,f()):{string:f(),length:a-u}},s.writeIString=function(a,u){var f,p,m,_=u===void 0;if(_&&(u=this.offset),!this.noAssert){if(typeof a!="string")throw TypeError("Illegal str: Not a string");if(typeof u!="number"||u%1!=0)throw TypeError("Illegal offset: "+u+" (not an integer)");if((u>>>=0)<0||u+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+u+" (+0) <= "+this.buffer.byteLength)}if(p=u,f=l.calculateUTF16asUTF8(e(a),this.noAssert)[1],u+=4+f,m=this.buffer.byteLength,u>m&&this.resize((m*=2)>u?m:u),u-=4+f,this.littleEndian?(this.view[u+3]=255&f>>>24,this.view[u+2]=255&f>>>16,this.view[u+1]=255&f>>>8,this.view[u]=255&f):(this.view[u]=255&f>>>24,this.view[u+1]=255&f>>>16,this.view[u+2]=255&f>>>8,this.view[u+3]=255&f),u+=4,l.encodeUTF16toUTF8(e(a),function(v){this.view[u++]=v}.bind(this)),u!==p+4+f)throw RangeError("Illegal range: Truncated data, "+u+" == "+(u+4+f));return _?(this.offset=u,this):u-p},s.readIString=function(a){var u,f,p,m=a===void 0;if(m&&(a=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal offset: "+a+" (not an integer)");if((a>>>=0)<0||a+4>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+4) <= "+this.buffer.byteLength)}return u=a,f=this.readUint32(a),p=this.readUTF8String(f,h.METRICS_BYTES,a+=4),a+=p.length,m?(this.offset=a,p.string):{string:p.string,length:a-u}},h.METRICS_CHARS="c",h.METRICS_BYTES="b",s.writeUTF8String=function(a,u){var f,p,m,_=u===void 0;if(_&&(u=this.offset),!this.noAssert){if(typeof u!="number"||u%1!=0)throw TypeError("Illegal offset: "+u+" (not an integer)");if((u>>>=0)<0||u+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+u+" (+0) <= "+this.buffer.byteLength)}return p=u,f=l.calculateUTF16asUTF8(e(a))[1],u+=f,m=this.buffer.byteLength,u>m&&this.resize((m*=2)>u?m:u),u-=f,l.encodeUTF16toUTF8(e(a),function(v){this.view[u++]=v}.bind(this)),_?(this.offset=u,this):u-p},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,u,f){var p,m,_,v,y;if(typeof u=="number"&&(f=u,u=void 0),(p=f===void 0)&&(f=this.offset),u===void 0&&(u=h.METRICS_CHARS),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal length: "+a+" (not an integer)");if(a|=0,typeof f!="number"||f%1!=0)throw TypeError("Illegal offset: "+f+" (not an integer)");if((f>>>=0)<0||f+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+f+" (+0) <= "+this.buffer.byteLength)}if(_=0,v=f,u===h.METRICS_CHARS){if(m=t(),l.decodeUTF8(function(){return a>_&&f<this.limit?this.view[f++]:null}.bind(this),function(C){++_,l.UTF8toUTF16(C,m)}),_!==a)throw RangeError("Illegal range: Truncated data, "+_+" == "+a);return p?(this.offset=f,m()):{string:m(),length:f-v}}if(u===h.METRICS_BYTES){if(!this.noAssert){if(typeof f!="number"||f%1!=0)throw TypeError("Illegal offset: "+f+" (not an integer)");if((f>>>=0)<0||f+a>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+f+" (+"+a+") <= "+this.buffer.byteLength)}if(y=f+a,l.decodeUTF8toUTF16(function(){return y>f?this.view[f++]:null}.bind(this),m=t(),this.noAssert),f!==y)throw RangeError("Illegal range: Truncated data, "+f+" == "+y);return p?(this.offset=f,m()):{string:m(),length:f-v}}throw TypeError("Unsupported metrics: "+u)},s.readString=s.readUTF8String,s.writeVString=function(a,u){var f,p,m,_,v=u===void 0;if(v&&(u=this.offset),!this.noAssert){if(typeof a!="string")throw TypeError("Illegal str: Not a string");if(typeof u!="number"||u%1!=0)throw TypeError("Illegal offset: "+u+" (not an integer)");if((u>>>=0)<0||u+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+u+" (+0) <= "+this.buffer.byteLength)}if(m=u,f=l.calculateUTF16asUTF8(e(a),this.noAssert)[1],p=h.calculateVarint32(f),u+=p+f,_=this.buffer.byteLength,u>_&&this.resize((_*=2)>u?_:u),u-=p+f,u+=this.writeVarint32(f,u),l.encodeUTF16toUTF8(e(a),function(y){this.view[u++]=y}.bind(this)),u!==m+f+p)throw RangeError("Illegal range: Truncated data, "+u+" == "+(u+f+p));return v?(this.offset=u,this):u-m},s.readVString=function(a){var u,f,p,m=a===void 0;if(m&&(a=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal offset: "+a+" (not an integer)");if((a>>>=0)<0||a+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+1) <= "+this.buffer.byteLength)}return u=a,f=this.readVarint32(a),p=this.readUTF8String(f.value,h.METRICS_BYTES,a+=f.length),a+=p.length,m?(this.offset=a,p.string):{string:p.string,length:a-u}},s.append=function(a,u,f){var p,m,_;if((typeof u=="number"||typeof u!="string")&&(f=u,u=void 0),(p=f===void 0)&&(f=this.offset),!this.noAssert){if(typeof f!="number"||f%1!=0)throw TypeError("Illegal offset: "+f+" (not an integer)");if((f>>>=0)<0||f+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+f+" (+0) <= "+this.buffer.byteLength)}return a instanceof h||(a=h.wrap(a,u)),(m=a.limit-a.offset)<=0||((f+=m)>(_=this.buffer.byteLength)&&this.resize((_*=2)>f?_:f),f-=m,this.view.set(a.view.subarray(a.offset,a.limit),f),a.offset+=m,p&&(this.offset+=m)),this},s.appendTo=function(a,u){return a.append(this,u),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 u=new h(0,this.littleEndian,this.noAssert);return a?(u.buffer=new ArrayBuffer(this.buffer.byteLength),u.view=new Uint8Array(u.buffer)):(u.buffer=this.buffer,u.view=this.view),u.offset=this.offset,u.markedOffset=this.markedOffset,u.limit=this.limit,u},s.compact=function(a,u){var f,p,m;if(a===void 0&&(a=this.offset),u===void 0&&(u=this.limit),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal begin: Not an integer");if(a>>>=0,typeof u!="number"||u%1!=0)throw TypeError("Illegal end: Not an integer");if(u>>>=0,a<0||a>u||u>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+a+" <= "+u+" <= "+this.buffer.byteLength)}return a===0&&u===this.buffer.byteLength?this:(f=u-a)==0?(this.buffer=o,this.view=null,this.markedOffset>=0&&(this.markedOffset-=a),this.offset=0,this.limit=0,this):(p=new ArrayBuffer(f),(m=new Uint8Array(p)).set(this.view.subarray(a,u)),this.buffer=p,this.view=m,this.markedOffset>=0&&(this.markedOffset-=a),this.offset=0,this.limit=f,this)},s.copy=function(a,u){if(a===void 0&&(a=this.offset),u===void 0&&(u=this.limit),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal begin: Not an integer");if(a>>>=0,typeof u!="number"||u%1!=0)throw TypeError("Illegal end: Not an integer");if(u>>>=0,a<0||a>u||u>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+a+" <= "+u+" <= "+this.buffer.byteLength)}if(a===u)return new h(0,this.littleEndian,this.noAssert);var f=u-a,p=new h(f,this.littleEndian,this.noAssert);return p.offset=0,p.limit=f,p.markedOffset>=0&&(p.markedOffset-=a),this.copyTo(p,0,a,u),p},s.copyTo=function(a,u,f,p){var m,_,v;if(!this.noAssert&&!h.isByteBuffer(a))throw TypeError("Illegal target: Not a ByteBuffer");if(u=(_=u===void 0)?a.offset:0|u,f=(m=f===void 0)?this.offset:0|f,p=p===void 0?this.limit:0|p,u<0||u>a.buffer.byteLength)throw RangeError("Illegal target range: 0 <= "+u+" <= "+a.buffer.byteLength);if(f<0||p>this.buffer.byteLength)throw RangeError("Illegal source range: 0 <= "+f+" <= "+this.buffer.byteLength);return(v=p-f)==0?a:(a.ensureCapacity(u+v),a.view.set(this.view.subarray(f,p),u),m&&(this.offset+=v),_&&(a.offset+=v),this)},s.ensureCapacity=function(a){var u=this.buffer.byteLength;return a>u?this.resize((u*=2)>a?u:a):this},s.fill=function(a,u,f){var p=u===void 0;if(p&&(u=this.offset),typeof a=="string"&&a.length>0&&(a=a.charCodeAt(0)),u===void 0&&(u=this.offset),f===void 0&&(f=this.limit),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal value: "+a+" (not an integer)");if(a|=0,typeof u!="number"||u%1!=0)throw TypeError("Illegal begin: Not an integer");if(u>>>=0,typeof f!="number"||f%1!=0)throw TypeError("Illegal end: Not an integer");if(f>>>=0,u<0||u>f||f>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+u+" <= "+f+" <= "+this.buffer.byteLength)}if(u>=f)return this;for(;f>u;)this.view[u++]=a;return p&&(this.offset=u),this},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,u,f){var p,m,_,v,y;if((typeof u=="number"||typeof u!="string")&&(f=u,u=void 0),(p=f===void 0)&&(f=this.offset),!this.noAssert){if(typeof f!="number"||f%1!=0)throw TypeError("Illegal offset: "+f+" (not an integer)");if((f>>>=0)<0||f+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+f+" (+0) <= "+this.buffer.byteLength)}return a instanceof h||(a=h.wrap(a,u)),(m=a.limit-a.offset)<=0||((_=m-f)>0?(v=new ArrayBuffer(this.buffer.byteLength+_),(y=new Uint8Array(v)).set(this.view.subarray(f,this.buffer.byteLength),m),this.buffer=v,this.view=y,this.offset+=_,this.markedOffset>=0&&(this.markedOffset+=_),this.limit+=_,f+=_):new Uint8Array(this.buffer),this.view.set(a.view.subarray(a.offset,a.limit),f-m),a.offset=a.limit,p&&(this.offset-=m)),this},s.prependTo=function(a,u){return a.prepend(this,u),this},s.printDebug=function(a){typeof a!="function"&&(a=console.log.bind(console)),a(this.toString()+`
  789. -------------------------------------------------------------------
  790. `+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 u,f;if(!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal capacity: "+a+" (not an integer)");if((a|=0)<0)throw RangeError("Illegal capacity: 0 <= "+a)}return this.buffer.byteLength<a&&(u=new ArrayBuffer(a),(f=new Uint8Array(u)).set(this.view),this.buffer=u,this.view=f),this},s.reverse=function(a,u){if(a===void 0&&(a=this.offset),u===void 0&&(u=this.limit),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal begin: Not an integer");if(a>>>=0,typeof u!="number"||u%1!=0)throw TypeError("Illegal end: Not an integer");if(u>>>=0,a<0||a>u||u>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+a+" <= "+u+" <= "+this.buffer.byteLength)}return a===u||Array.prototype.reverse.call(this.view.subarray(a,u)),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 u=this.offset+a;if(!this.noAssert&&(u<0||u>this.buffer.byteLength))throw RangeError("Illegal length: 0 <= "+this.offset+" + "+a+" <= "+this.buffer.byteLength);return this.offset=u,this},s.slice=function(a,u){if(a===void 0&&(a=this.offset),u===void 0&&(u=this.limit),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal begin: Not an integer");if(a>>>=0,typeof u!="number"||u%1!=0)throw TypeError("Illegal end: Not an integer");if(u>>>=0,a<0||a>u||u>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+a+" <= "+u+" <= "+this.buffer.byteLength)}var f=this.clone();return f.offset=a,f.limit=u,f},s.toBuffer=function(a){var u,f=this.offset,p=this.limit;if(!this.noAssert){if(typeof f!="number"||f%1!=0)throw TypeError("Illegal offset: Not an integer");if(f>>>=0,typeof p!="number"||p%1!=0)throw TypeError("Illegal limit: Not an integer");if(p>>>=0,f<0||f>p||p>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+f+" <= "+p+" <= "+this.buffer.byteLength)}return a||f!==0||p!==this.buffer.byteLength?f===p?o:(u=new ArrayBuffer(p-f),new Uint8Array(u).set(new Uint8Array(this.buffer).subarray(f,p),0),u):this.buffer},s.toArrayBuffer=s.toBuffer,s.toString=function(a,u,f){if(a===void 0)return"ByteBufferAB(offset="+this.offset+",markedOffset="+this.markedOffset+",limit="+this.limit+",capacity="+this.capacity()+")";switch(typeof a=="number"&&(f=u=a="utf8"),a){case"utf8":return this.toUTF8(u,f);case"base64":return this.toBase64(u,f);case"hex":return this.toHex(u,f);case"binary":return this.toBinary(u,f);case"debug":return this.toDebug();case"columns":return this.toColumns();default:throw Error("Unsupported encoding: "+a)}},d=function(){var a,u,f={},p=[65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,48,49,50,51,52,53,54,55,56,57,43,47],m=[];for(a=0,u=p.length;u>a;++a)m[p[a]]=a;return f.encode=function(_,v){for(var y,C;(y=_())!==null;)v(p[63&y>>2]),C=(3&y)<<4,(y=_())!==null?(v(p[63&((C|=15&y>>4)|15&y>>4)]),C=(15&y)<<2,(y=_())!==null?(v(p[63&(C|3&y>>6)]),v(p[63&y])):(v(p[63&C]),v(61))):(v(p[63&C]),v(61),v(61))},f.decode=function(_,v){function y(S){throw Error("Illegal character code: "+S)}for(var C,b,O;(C=_())!==null;)if((b=m[C])===void 0&&y(C),(C=_())!==null&&((O=m[C])===void 0&&y(C),v(b<<2>>>0|(48&O)>>4),(C=_())!==null)){if((b=m[C])===void 0){if(C===61)break;y(C)}if(v((15&O)<<4>>>0|(60&b)>>2),(C=_())!==null){if((O=m[C])===void 0){if(C===61)break;y(C)}v((3&b)<<6>>>0|O)}}},f.test=function(_){return/^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/.test(_)},f}(),s.toBase64=function(a,u){if(a===void 0&&(a=this.offset),u===void 0&&(u=this.limit),u|=0,(a|=0)<0||u>this.capacity||a>u)throw RangeError("begin, end");var f;return d.encode(function(){return u>a?this.view[a++]:null}.bind(this),f=t()),f()},h.fromBase64=function(a,u){if(typeof a!="string")throw TypeError("str");var f=new h(a.length/4*3,u),p=0;return d.decode(e(a),function(m){f.view[p++]=m}),f.limit=p,f},h.btoa=function(a){return h.fromBinary(a).toBase64()},h.atob=function(a){return h.fromBase64(a).toBinary()},s.toBinary=function(a,u){if(a===void 0&&(a=this.offset),u===void 0&&(u=this.limit),u|=0,(a|=0)<0||u>this.capacity()||a>u)throw RangeError("begin, end");if(a===u)return"";for(var f=[],p=[];u>a;)f.push(this.view[a++]),f.length>=1024&&(p.push(String.fromCharCode.apply(String,f)),f=[]);return p.join("")+String.fromCharCode.apply(String,f)},h.fromBinary=function(a,u){if(typeof a!="string")throw TypeError("str");for(var f,p=0,m=a.length,_=new h(m,u);m>p;){if((f=a.charCodeAt(p))>255)throw RangeError("illegal char code: "+f);_.view[p++]=f}return _.limit=m,_},s.toDebug=function(a){for(var u,f=-1,p=this.buffer.byteLength,m="",_="",v="";p>f;){if(f!==-1&&(m+=(u=this.view[f])<16?"0"+u.toString(16).toUpperCase():u.toString(16).toUpperCase(),a&&(_+=u>32&&u<127?String.fromCharCode(u):".")),++f,a&&f>0&&f%16==0&&f!==p){for(;m.length<51;)m+=" ";v+=m+_+`
  791. `,m=_=""}m+=f===this.offset&&f===this.limit?f===this.markedOffset?"!":"|":f===this.offset?f===this.markedOffset?"[":"<":f===this.limit?f===this.markedOffset?"]":">":f===this.markedOffset?"'":a||f!==0&&f!==p?" ":""}if(a&&m!==" "){for(;m.length<51;)m+=" ";v+=m+_+`
  792. `}return a?v:m},h.fromDebug=function(a,u,f){for(var p,m,_=a.length,v=new h(0|(_+1)/3,u,f),y=0,C=0,b=!1,O=!1,S=!1,E=!1,w=!1;_>y;){switch(p=a.charAt(y++)){case"!":if(!f){if(O||S||E){w=!0;break}O=S=E=!0}v.offset=v.markedOffset=v.limit=C,b=!1;break;case"|":if(!f){if(O||E){w=!0;break}O=E=!0}v.offset=v.limit=C,b=!1;break;case"[":if(!f){if(O||S){w=!0;break}O=S=!0}v.offset=v.markedOffset=C,b=!1;break;case"<":if(!f){if(O){w=!0;break}O=!0}v.offset=C,b=!1;break;case"]":if(!f){if(E||S){w=!0;break}E=S=!0}v.limit=v.markedOffset=C,b=!1;break;case">":if(!f){if(E){w=!0;break}E=!0}v.limit=C,b=!1;break;case"'":if(!f){if(S){w=!0;break}S=!0}v.markedOffset=C,b=!1;break;case" ":b=!1;break;default:if(!f&&b){w=!0;break}if(m=parseInt(p+a.charAt(y++),16),!f&&(isNaN(m)||m<0||m>255))throw TypeError("Illegal str: Not a debug encoded string");v.view[C++]=m,b=!0}if(w)throw TypeError("Illegal str: Invalid symbol at "+y)}if(!f){if(!O||!E)throw TypeError("Illegal str: Missing offset or limit");if(C<v.buffer.byteLength)throw TypeError("Illegal str: Not a debug encoded string (is it hex?) "+C+" < "+_)}return v},s.toHex=function(a,u){if(a=a===void 0?this.offset:a,u=u===void 0?this.limit:u,!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal begin: Not an integer");if(a>>>=0,typeof u!="number"||u%1!=0)throw TypeError("Illegal end: Not an integer");if(u>>>=0,a<0||a>u||u>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+a+" <= "+u+" <= "+this.buffer.byteLength)}for(var f,p=new Array(u-a);u>a;)(f=this.view[a++])<16?p.push("0",f.toString(16)):p.push(f.toString(16));return p.join("")},h.fromHex=function(a,u,f){var p,m,_,v,y;if(!f){if(typeof a!="string")throw TypeError("Illegal str: Not a string");if(a.length%2!=0)throw TypeError("Illegal str: Length not a multiple of 2")}for(m=a.length,_=new h(0|m/2,u),v=0,y=0;m>v;v+=2){if(p=parseInt(a.substring(v,v+2),16),!f&&(!isFinite(p)||p<0||p>255))throw TypeError("Illegal str: Contains non-hex characters");_.view[y++]=p}return _.limit=y,_},l=function(){var a={MAX_CODEPOINT:1114111,encodeUTF8:function(u,f){var p=null;for(typeof u=="number"&&(p=u,u=function(){return null});p!==null||(p=u())!==null;)p<128?f(127&p):p<2048?(f(192|31&p>>6),f(128|63&p)):p<65536?(f(224|15&p>>12),f(128|63&p>>6),f(128|63&p)):(f(240|7&p>>18),f(128|63&p>>12),f(128|63&p>>6),f(128|63&p)),p=null},decodeUTF8:function(u,f){for(var p,m,_,v,y=function(C){C=C.slice(0,C.indexOf(null));var b=Error(C.toString());throw b.name="TruncatedError",b.bytes=C,b};(p=u())!==null;)if((128&p)==0)f(p);else if((224&p)==192)(m=u())===null&&y([p,m]),f((31&p)<<6|63&m);else if((240&p)==224)((m=u())===null||(_=u())===null)&&y([p,m,_]),f((15&p)<<12|(63&m)<<6|63&_);else{if((248&p)!=240)throw RangeError("Illegal starting byte: "+p);((m=u())===null||(_=u())===null||(v=u())===null)&&y([p,m,_,v]),f((7&p)<<18|(63&m)<<12|(63&_)<<6|63&v)}},UTF16toUTF8:function(u,f){for(var p,m=null;(p=m!==null?m:u())!==null;)p>=55296&&p<=57343&&(m=u())!==null&&m>=56320&&m<=57343?(f(1024*(p-55296)+m-56320+65536),m=null):f(p);m!==null&&f(m)},UTF8toUTF16:function(u,f){var p=null;for(typeof u=="number"&&(p=u,u=function(){return null});p!==null||(p=u())!==null;)p<=65535?f(p):(f(55296+((p-=65536)>>10)),f(p%1024+56320)),p=null},encodeUTF16toUTF8:function(u,f){a.UTF16toUTF8(u,function(p){a.encodeUTF8(p,f)})},decodeUTF8toUTF16:function(u,f){a.decodeUTF8(u,function(p){a.UTF8toUTF16(p,f)})},calculateCodePoint:function(u){return u<128?1:u<2048?2:u<65536?3:4},calculateUTF8:function(u){for(var f,p=0;(f=u())!==null;)p+=f<128?1:f<2048?2:f<65536?3:4;return p},calculateUTF16asUTF8:function(u){var f=0,p=0;return a.UTF16toUTF8(u,function(m){++f,p+=m<128?1:m<2048?2:m<65536?3:4}),[f,p]}};return a}(),s.toUTF8=function(a,u){if(a===void 0&&(a=this.offset),u===void 0&&(u=this.limit),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal begin: Not an integer");if(a>>>=0,typeof u!="number"||u%1!=0)throw TypeError("Illegal end: Not an integer");if(u>>>=0,a<0||a>u||u>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+a+" <= "+u+" <= "+this.buffer.byteLength)}var f;try{l.decodeUTF8toUTF16(function(){return u>a?this.view[a++]:null}.bind(this),f=t())}catch{if(a!==u)throw RangeError("Illegal range: Truncated data, "+a+" != "+u)}return f()},h.fromUTF8=function(a,u,f){if(!f&&typeof a!="string")throw TypeError("Illegal str: Not a string");var p=new h(l.calculateUTF16asUTF8(e(a),!0)[1],u,f),m=0;return l.encodeUTF16toUTF8(e(a),function(_){p.view[m++]=_}),p.limit=m,p},h}(Ga=function(){function n(E,w,V){this.low=0|E,this.high=0|w,this.unsigned=!!V}function e(E){return(E&&E.__isLong__)===!0}function t(E,w){var V,j,R;return w?(R=(E>>>=0)>=0&&E<256)&&(j=d[E])?j:(V=i(E,(0|E)<0?-1:0,!0),R&&(d[E]=V),V):(R=(E|=0)>=-128&&E<128)&&(j=c[E])?j:(V=i(E,E<0?-1:0,!1),R&&(c[E]=V),V)}function r(E,w){if(isNaN(E)||!isFinite(E))return w?m:p;if(w){if(E<0)return m;if(E>=a)return b}else{if(-u>=E)return O;if(E+1>=u)return C}return E<0?r(-E,w).neg():i(0|E%h,0|E/h,w)}function i(E,w,V){return new n(E,w,V)}function s(E,w,V){var j,R,T,A,L,k,F;if(E.length===0)throw Error("empty string");if(E==="NaN"||E==="Infinity"||E==="+Infinity"||E==="-Infinity")return p;if(typeof w=="number"?(V=w,w=!1):w=!!w,(V=V||10)<2||V>36)throw RangeError("radix");if((j=E.indexOf("-"))>0)throw Error("interior hyphen");if(j===0)return s(E.substring(1),w,V).neg();for(R=r(l(V,8)),T=p,A=0;A<E.length;A+=8)L=Math.min(8,E.length-A),k=parseInt(E.substring(A,A+L),V),L<8?(F=r(l(V,L)),T=T.mul(F).add(r(k))):T=(T=T.mul(R)).add(r(k));return T.unsigned=w,T}function o(E){return E instanceof n?E:typeof E=="number"?r(E):typeof E=="string"?s(E):i(E.low,E.high,E.unsigned)}var c,d,l,h,a,u,f,p,m,_,v,y,C,b,O,S;return n.prototype.__isLong__,Object.defineProperty(n.prototype,"__isLong__",{value:!0,enumerable:!1,configurable:!1}),n.isLong=e,c={},d={},n.fromInt=t,n.fromNumber=r,n.fromBits=i,l=Math.pow,n.fromString=s,n.fromValue=o,u=(a=(h=4294967296)*h)/2,f=t(16777216),p=t(0),n.ZERO=p,m=t(0,!0),n.UZERO=m,_=t(1),n.ONE=_,v=t(1,!0),n.UONE=v,y=t(-1),n.NEG_ONE=y,C=i(-1,2147483647,!1),n.MAX_VALUE=C,b=i(-1,-1,!0),n.MAX_UNSIGNED_VALUE=b,O=i(0,-2147483648,!1),n.MIN_VALUE=O,(S=n.prototype).toInt=function(){return this.unsigned?this.low>>>0:this.low},S.toNumber=function(){return this.unsigned?(this.high>>>0)*h+(this.low>>>0):this.high*h+(this.low>>>0)},S.toString=function(E){var w,V,j,R,T,A,L,k;if((E=E||10)<2||E>36)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative())return this.eq(O)?(w=r(E),j=(V=this.div(w)).mul(w).sub(this),V.toString(E)+j.toInt().toString(E)):"-"+this.neg().toString(E);for(R=r(l(E,6),this.unsigned),T=this,A="";;){if(L=T.div(R),k=(T.sub(L.mul(R)).toInt()>>>0).toString(E),(T=L).isZero())return k+A;for(;k.length<6;)k="0"+k;A=""+k+A}},S.getHighBits=function(){return this.high},S.getHighBitsUnsigned=function(){return this.high>>>0},S.getLowBits=function(){return this.low},S.getLowBitsUnsigned=function(){return this.low>>>0},S.getNumBitsAbs=function(){var E,w;if(this.isNegative())return this.eq(O)?64:this.neg().getNumBitsAbs();for(E=this.high!=0?this.high:this.low,w=31;w>0&&(E&1<<w)==0;w--);return this.high!=0?w+33:w+1},S.isZero=function(){return this.high===0&&this.low===0},S.isNegative=function(){return!this.unsigned&&this.high<0},S.isPositive=function(){return this.unsigned||this.high>=0},S.isOdd=function(){return(1&this.low)==1},S.isEven=function(){return(1&this.low)==0},S.equals=function(E){return e(E)||(E=o(E)),(this.unsigned===E.unsigned||this.high>>>31!=1||E.high>>>31!=1)&&this.high===E.high&&this.low===E.low},S.eq=S.equals,S.notEquals=function(E){return!this.eq(E)},S.neq=S.notEquals,S.lessThan=function(E){return this.comp(E)<0},S.lt=S.lessThan,S.lessThanOrEqual=function(E){return this.comp(E)<=0},S.lte=S.lessThanOrEqual,S.greaterThan=function(E){return this.comp(E)>0},S.gt=S.greaterThan,S.greaterThanOrEqual=function(E){return this.comp(E)>=0},S.gte=S.greaterThanOrEqual,S.compare=function(E){if(e(E)||(E=o(E)),this.eq(E))return 0;var w=this.isNegative(),V=E.isNegative();return w&&!V?-1:!w&&V?1:this.unsigned?E.high>>>0>this.high>>>0||E.high===this.high&&E.low>>>0>this.low>>>0?-1:1:this.sub(E).isNegative()?-1:1},S.comp=S.compare,S.negate=function(){return!this.unsigned&&this.eq(O)?O:this.not().add(_)},S.neg=S.negate,S.add=function(E){var w,V,j,R,T,A,L,k,F,H,G;return e(E)||(E=o(E)),w=this.high>>>16,V=65535&this.high,j=this.low>>>16,R=65535&this.low,T=E.high>>>16,A=65535&E.high,L=E.low>>>16,k=0,F=0,H=0,G=0,H+=(G+=R+(65535&E.low))>>>16,F+=(H+=j+L)>>>16,k+=(F+=V+A)>>>16,k+=w+T,i((H&=65535)<<16|(G&=65535),(k&=65535)<<16|(F&=65535),this.unsigned)},S.subtract=function(E){return e(E)||(E=o(E)),this.add(E.neg())},S.sub=S.subtract,S.multiply=function(E){var w,V,j,R,T,A,L,k,F,H,G,W;return this.isZero()?p:(e(E)||(E=o(E)),E.isZero()?p:this.eq(O)?E.isOdd()?O:p:E.eq(O)?this.isOdd()?O:p:this.isNegative()?E.isNegative()?this.neg().mul(E.neg()):this.neg().mul(E).neg():E.isNegative()?this.mul(E.neg()).neg():this.lt(f)&&E.lt(f)?r(this.toNumber()*E.toNumber(),this.unsigned):(w=this.high>>>16,V=65535&this.high,j=this.low>>>16,R=65535&this.low,T=E.high>>>16,A=65535&E.high,L=E.low>>>16,F=0,H=0,G=0,W=0,G+=(W+=R*(k=65535&E.low))>>>16,H+=(G+=j*k)>>>16,G&=65535,H+=(G+=R*L)>>>16,F+=(H+=V*k)>>>16,H&=65535,F+=(H+=j*L)>>>16,H&=65535,F+=(H+=R*A)>>>16,F+=w*k+V*L+j*A+R*T,i((G&=65535)<<16|(W&=65535),(F&=65535)<<16|(H&=65535),this.unsigned)))},S.mul=S.multiply,S.divide=function(E){var w,V,j,R,T,A,L;if(e(E)||(E=o(E)),E.isZero())throw Error("division by zero");if(this.isZero())return this.unsigned?m:p;if(this.unsigned){if(E.unsigned||(E=E.toUnsigned()),E.gt(this))return m;if(E.gt(this.shru(1)))return v;j=m}else{if(this.eq(O))return E.eq(_)||E.eq(y)?O:E.eq(O)?_:(w=this.shr(1).div(E).shl(1)).eq(p)?E.isNegative()?_:y:(V=this.sub(E.mul(w)),j=w.add(V.div(E)));if(E.eq(O))return this.unsigned?m:p;if(this.isNegative())return E.isNegative()?this.neg().div(E.neg()):this.neg().div(E).neg();if(E.isNegative())return this.div(E.neg()).neg();j=p}for(V=this;V.gte(E);){for(w=Math.max(1,Math.floor(V.toNumber()/E.toNumber())),T=(R=Math.ceil(Math.log(w)/Math.LN2))<=48?1:l(2,R-48),L=(A=r(w)).mul(E);L.isNegative()||L.gt(V);)L=(A=r(w-=T,this.unsigned)).mul(E);A.isZero()&&(A=_),j=j.add(A),V=V.sub(L)}return j},S.div=S.divide,S.modulo=function(E){return e(E)||(E=o(E)),this.sub(this.div(E).mul(E))},S.mod=S.modulo,S.not=function(){return i(~this.low,~this.high,this.unsigned)},S.and=function(E){return e(E)||(E=o(E)),i(this.low&E.low,this.high&E.high,this.unsigned)},S.or=function(E){return e(E)||(E=o(E)),i(this.low|E.low,this.high|E.high,this.unsigned)},S.xor=function(E){return e(E)||(E=o(E)),i(this.low^E.low,this.high^E.high,this.unsigned)},S.shiftLeft=function(E){return e(E)&&(E=E.toInt()),(E&=63)==0?this:E<32?i(this.low<<E,this.high<<E|this.low>>>32-E,this.unsigned):i(0,this.low<<E-32,this.unsigned)},S.shl=S.shiftLeft,S.shiftRight=function(E){return e(E)&&(E=E.toInt()),(E&=63)==0?this:E<32?i(this.low>>>E|this.high<<32-E,this.high>>E,this.unsigned):i(this.high>>E-32,this.high>=0?0:-1,this.unsigned)},S.shr=S.shiftRight,S.shiftRightUnsigned=function(E){var w;return e(E)&&(E=E.toInt()),(E&=63)==0?this:(w=this.high,E<32?i(this.low>>>E|w<<32-E,w>>>E,this.unsigned):i(E===32?w:w>>>E-32,0,this.unsigned))},S.shru=S.shiftRightUnsigned,S.toSigned=function(){return this.unsigned?i(this.low,this.high,!1):this},S.toUnsigned=function(){return this.unsigned?this:i(this.low,this.high,!0)},S.toBytes=function(E){return E?this.toBytesLE():this.toBytesBE()},S.toBytesLE=function(){var E=this.high,w=this.low;return[255&w,255&w>>>8,255&w>>>16,255&w>>>24,255&E,255&E>>>8,255&E>>>16,255&E>>>24]},S.toBytesBE=function(){var E=this.high,w=this.low;return[255&E>>>24,255&E>>>16,255&E>>>8,255&E,255&w>>>24,255&w>>>16,255&w>>>8,255&w]},n}()),Ga));Ds.getModule=function(n){var e=new Ds[n];return e.getArrayData=function(){var t=e.toArrayBuffer();return t=pu(t)?[].slice.call(new Int8Array(t)):t},e};var xs,nh="pgMsgP",rh="chatMsg",ih="pcMsgP",sh={PRIVATE:"ppMsgS",GROUP:"pgMsgS",CHATROOM:"chatMsgS"},oh="delMsg",ah="joinChrm",ch="joinChrmR",uh="exitChrm",dh="setKV",lh="delKV",hh="setKVS",fh="delKVS",Ya="qryRelationR",ph="delRelation",gh="setSeAtt",_r={PRIVATE:"cleanPMsg",GROUP:"cleanGMsg",CUSTOMER_SERVICE:"cleanCMsg",SYSTEM:"cleanSMsg"},Nu="qryPMsg",mh="qryGMsg",Ou="qryCHMsg",_h="qryCMsg",vh="qrySMsg",yh=((wn={}).ppMsgP=Q.PRIVATE,wn[nh]=Q.GROUP,wn[rh]=Q.CHATROOM,wn[ih]=Q.CUSTOMER_SERVICE,wn),Ch=((tn={})[Q.PRIVATE]=Nu,tn[Q.GROUP]=mh,tn[Q.CHATROOM]=Ou,tn[Q.CUSTOMER_SERVICE]=_h,tn[Q.SYSTEM]=vh,tn),Eh=((Nn={})[Q.PRIVATE]=_r.PRIVATE,Nn[Q.GROUP]=_r.GROUP,Nn[Q.CUSTOMER_SERVICE]=_r.CUSTOMER_SERVICE,Nn[Q.SYSTEM]=_r.SYSTEM,Nn),Ji="1",Rh="0",Ja=1,Wa=2,za=3,Th=function(){function n(e){this._codec=e==="websocket"?Ds:Xn,this._connectType=e}return n.prototype.decodeByPBName=function(e,t,r){var i,s=this,o=e,c=((i={})[Wn]=s._formatSyncMessages,i[Ci]=s._formatReceivedMessage,i[Jn]=s._formatSentMessage,i[zn]=s._formatHistoryMessages,i[Qn]=s._formatConversationList,i[Ei]=s._formatChatRoomInfos,i[qt]=s._formatRTCUserList,i[Ti]=s._formatRTCData,i[cn]=s._formatChatRoomKVList,i[Si]=s._formatUserSetting,i[bi]=s._formatConversationStatus,i[wi]=s._formatGrpReadReceiptQryResp,i[un]=s._formatSetUserSettingOutput,i[Ii]=s._formatUserSettingNotification,i[Ni]=s._formatRTCRoomKVList,i[Ri]=s._formatRTCAuidenceJoinRoomData,i[Oi]=s._formatRTCJoinedUserInfo,i)[t];try{o=e.length>0&&s._codec[t].decode(e),He(o)&&(o=function(d){for(var l in d)He(d[l])&&(d[l]=st(d[l]));return d}(o)),Gr(c)&&(o=c.call(this,o,r))}catch(d){K.error(`PB parse error
  793. `,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=pu(r)?new Uint8Array(r):r;return sr.readUTF(s.subarray(t,i))}catch(o){K.info(`readBytes error
  794. `,o)}return e},n.prototype._formatBytes=function(e){var t=this._readBytes(e);try{t=JSON.parse(t)}catch(r){K.info(`formatBytes error
  795. `,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(ge(o)||o===null)&&(e.finished=!0),e.syncTime=st(s),e.list=mr(i,function(c){return r._formatReceivedMessage(c,t)}),e},n.prototype._formatReceivedMessage=function(e,t){var r=(t=t||{}).currentUserId,i=t.connectedTime,s=e.content,o=e.fromUserId,c=e.type,d=e.groupId,l=e.status,h=e.dataTime,a=e.classname,u=e.msgId,f=e.extraContent,p=e.pushContent,m=e.pushExt,_=e.configFlag,v=(e.direction||at.RECEIVE)===at.SEND,y=function(ae){var te=Gn.READ;return{isPersited:!!(16&ae),isCounted:!!(32&ae),isMentioned:!!(64&ae),disableNotification:!!(512&ae),receivedStatus:te=2&ae?Gn.RETRIEVED:te,canIncludeExpansion:!!(1024&ae)}}(l),C=y.isPersited,b=y.isCounted,O=y.isMentioned,S=y.disableNotification,E=y.receivedStatus,w=y.canIncludeExpansion,V=[Q.GROUP,Q.CHATROOM,Q.RTC_ROOM].indexOf(c)>-1?d:o,j=v?r:o,R=st(h),T=R<i,A=c===Q.CHATROOM,L=this._formatBytes(s),k={};if(m&&(k=Ha(m.pushConfigs,m.pushId)),L.user){var F=L.user,H=F.portrait,G=F.portraitUri,W=H||G;W&&(L.user.portrait=L.user.portraitUri=W)}var oe,he=Ce(Ce({},k),{pushTitle:m==null?void 0:m.title,pushContent:p,pushData:p,disablePushTitle:!!_&&Boolean(4&_),forceShowDetailContent:!!_&&Boolean(8&_),templateId:m==null?void 0:m.templateId}),de=v?at.SEND:at.RECEIVE;return A&&o===r&&(de=at.SEND),f&&(oe={},oe=ja(f)),{conversationType:c,targetId:V,senderUserId:j,messageType:a,messageUId:u,isPersited:C,isCounted:b,isMentioned:O,sentTime:R,isOffLineMessage:T,messageDirection:de,receivedTime:sn.getTime(),disableNotification:S,receivedStatus:E,canIncludeExpansion:w,content:L,expansion:oe,configFlag:_,pushConfig:he,channelId:e.busChannel||""}},n.prototype._formatSentMessage=function(e,t){var r,i=e.content,s=e.classname,o=e.sessionId,c=e.msgId,d=e.extraContent,l=e.pushExt,h=e.pushContent,a=e.configFlag,u=t.signal,f=t.currentUserId,p=u.date,m=u.topic,_=u.targetId,v=function(T){return{isPersited:!!(1&T),isCounted:!!(2&T),disableNotification:!!(32&T),canIncludeExpansion:!!(64&T)}}(o),y=v.isPersited,C=v.isCounted,b=v.disableNotification,O=v.canIncludeExpansion,S=yh[m]||Q.PRIVATE,E=Wl(sh,m),w=this._formatBytes(i),V=_;s===qe.RECALL&&(S=w.conversationType||S,V=w.targetId||_),d&&(r={},r=ja(d));var j={};l&&(j=Ha(l.pushConfigs,l.pushId));var R=Ce(Ce({},j),{pushTitle:l==null?void 0:l.title,pushContent:h,pushData:h,disablePushTitle:!!a&&Boolean(4&a),forceShowDetailContent:!!a&&Boolean(8&a),templateId:l==null?void 0:l.templateId});return{conversationType:S,targetId:V,messageType:s,messageUId:c,isPersited:y,isCounted:C,isStatusMessage:E,senderUserId:f,content:this._formatBytes(i),sentTime:1e3*p,receivedTime:sn.getTime(),messageDirection:at.SEND,isOffLineMessage:!1,disableNotification:b,canIncludeExpansion:O,expansion:r,pushConfig:R,channelId:e.busChannel||""}},n.prototype._formatHistoryMessages=function(e,t){var r=this,i=t.conversation||{},s=e.list,o=e.hasMsg,c=i.targetId,d=st(e.syncTime),l=[];return Oe(s,function(h){var a=r._formatReceivedMessage(h,t);a.targetId=c,l.push(a)},{isReverse:!0}),{syncTime:d,list:l,hasMore:!!o}},n.prototype._formatConversationList=function(e,t){var r=this,i=e.info,s=t.afterDecode||function(){};return(i=mr(i,function(o){var c=o.msg,d=o.userId,l=o.type,h=o.unreadCount,a=o.busChannel,u=null;c&&((u=r._formatReceivedMessage(c,t)).targetId=d);var f={targetId:d,conversationType:l,unreadMessageCount:h,latestMessage:u,channelId:a||""};return s(f)||f}))||[]},n.prototype._formatSetUserSettingOutput=function(e){return e},n.prototype._formatChatRoomInfos=function(e){var t=e.userTotalNums,r=e.userInfos;return{userCount:t,userInfos:mr(r,function(i){var s=i.id,o=i.time;return{id:s,time:st(o)}})}},n.prototype._formatChatRoomKVList=function(e){var t=e.entries,r=e.bFullUpdate,i=e.syncTime;return{kvEntries:t=mr(t=t||[],function(s){var o=s.key,c=s.value,d=s.status,l=s.timestamp,h=s.uid,a=function(u){return{isAutoDelete:!!(1&u),isOverwrite:!!(2&u),type:4&u?Xe.DELETE:Xe.UPDATE}}(d);return{key:o,value:c,isAutoDelete:a.isAutoDelete,isOverwrite:a.isOverwrite,type:a.type,userId:h,timestamp:st(l)}}),isFullUpdate:r,syncTime:i}},n.prototype._formatUserSetting=function(e){var t=this,r=e.items,i=e.version,s={};return Oe(r||[],function(o){var c=o.key,d=o.version,l=o.value;o.version=st(d),o.value=t._readBytes(l),c==="Tag"&&o.tags.forEach(function(h){h.createdTime=st(h.createdTime),h.tagName=h.name}),s[c]=o}),{settings:s,version:i}},n.prototype._formatConversationStatus=function(e){var t=e.state,r=[];return Oe(t,function(i){var s=i.type,o=i.channelId,c=i.time,d=i.stateItem,l=i.busChannel,h=rn.CLOSE,a=!1,u=[];Oe(d,function(f){var p=f.sessionStateType,m=f.value,_=f.tags;switch(p){case Ja:h=m===Ji?rn.OPEN:rn.CLOSE;break;case Wa:a=m===Ji;break;case za:u=_}}),r.push({conversationType:s,type:s,targetId:o,notificationStatus:h,isTop:a,updatedTime:st(c),tags:u,channelId:l||""})}),r},n.prototype._formatRTCUserList=function(e){var t=e.users,r=e.token,i=e.sessionId,s=e.roomInfo,o=e.entries,c={};return Oe(t,function(d){var l=d.userId,h=d.userData,a={};Oe(h,function(u){var f=u.key,p=u.value;a[f]=p}),c[l]=a}),{users:c,token:r,sessionId:i,roomInfo:s,kvEntries:o}},n.prototype._formatRTCData=function(e){var t=e.outInfo,r={};return Oe(t,function(i){r[i.key]=i.value}),r},n.prototype._formatRTCRoomInfo=function(e){var t=e.roomId,r=e.userCount,i=e.roomData,s={id:t,total:r};return Oe(i,function(o){s[o.key]=o.value}),s},n.prototype._formatGrpReadReceiptQryResp=function(e){var t=e.totalMemberNum,r=e.list;return r.forEach(function(i){i.readTime=st(i.readTime)}),{totalMemberCount:t,list:r}},n.prototype._formatUserSettingNotification=function(e){return e},n.prototype._formatRTCRoomKVList=function(e){var t=e.entries,r=e.bFullUpdate,i=e.syncTime;return{kvEntries:t=(t=t||[]).map(function(s){var o=s.timestamp;return Object.assign(s,{timestamp:st(o)})}),isFullUpdate:r,syncTime:i}},n.prototype._formatRTCAuidenceJoinRoomData=function(e){return e},n.prototype._formatRTCJoinedUserInfo=function(e){return(e.info||[]).map(function(t){return{deviceId:t.deviceId,roomId:t.roomId,joinTime:st(t.joinTime)}})},n.prototype.encodeServerConfParams=function(){var e=this._codec.getModule(mo);return e.setNothing(1),e.getArrayData()},n.prototype._getUpMsgModule=function(e,t){var r,i,s,o=this._connectType==="comet",c=(e.conversationType,t.messageType),d=t.isMentioned,l=t.mentionedType,h=t.mentionedUserIdList,a=t.content,u=t.pushContent,f=t.pushData,p=t.directionalUserIdList,m=t.isFilerWhiteBlacklist,_=t.isVoipPush,v=t.canIncludeExpansion,y=t.expansion,C=t.pushConfig,b=t.channelId;Q.GROUP;var O=this._codec.getModule(Jn),S=function(de){var ae=de.isStatusMessage,te=de.isPersited,U=de.isCounted;ae&&(te=U=!1);var J=0;return te&&(J|=1),U&&(J|=2),de.isMentioned&&(J|=4),de.disableNotification&&(J|=32),de.canIncludeExpansion&&(J|=64),J}(t),E=C||{},w=E.pushTitle,V=E.pushContent,j=E.pushData,R=E.iOSConfig,T=E.androidConfig,A=E.templateId,L=E.disablePushTitle,k=E.forceShowDetailContent,F=0;O.setSessionId(S),d&&a&&(a.mentionedInfo={userIdList:((r=a.mentionedInfo)===null||r===void 0?void 0:r.userIdList)||h||[],type:((i=a.mentionedInfo)===null||i===void 0?void 0:i.type)||l||fo.ALL,mentionedContent:((s=a.mentionedInfo)===null||s===void 0?void 0:s.mentionedContent)||""});var H=V||u||"",G=j||f||"";if(H&&O.setPushText(H),G&&O.setAppData(G),p&&O.setUserId(p),F|=_?1:0,F|=m?2:0,F|=L?4:0,F|=k?8:0,O.setConfigFlag(F),O.setClassname(c),a.user&&a.user.portraitUri&&(a.user.portrait=a.user.portraitUri),O.setContent(JSON.stringify(a)),v&&y){var W={};Oe(y,function(de,ae){W[ae]={v:de}}),O.setExtraContent(JSON.stringify(W))}if(C){var oe=this._codec.getModule(go);if(w&&oe.setTitle(w),R&&T){var he=Yl(R,T);oe.setPushConfigs(he)}(T==null?void 0:T.notificationId)&&oe.setPushId(T==null?void 0:T.notificationId),oe.setTemplateId(A||""),O.setPushExt(o?oe.getArrayData():oe)}return ge(b)||O.setBusChannel(b),O},n.prototype.encodeUpMsg=function(e,t){return this._getUpMsgModule(e,t).getArrayData()},n.prototype.encodeSyncMsg=function(e){var t=e.sendboxTime,r=e.inboxTime,i=this._codec.getModule(_o);return i.setIspolling(!1),i.setIsPullSend(!0),i.setSendBoxSyncTime(t),i.setSyncTime(r),i.getArrayData()},n.prototype.encodeChrmSyncMsg=function(e,t){e=e||0,t=t||0;var r=this._codec.getModule(vo);return r.setCount(t),r.setSyncTime(e),r.getArrayData()},n.prototype.encodeGetHistoryMsg=function(e,t){var r=t.count,i=t.order,s=t.timestamp,o=t.channelId,c=this._codec.getModule(yo);return c.setTargetId(e),c.setTime(s),c.setCount(r),c.setOrder(i),c.setBusChannel(o||""),c.getArrayData()},n.prototype.encodeGetConversationList=function(e){var t=(e=e||{}).count,r=e.startTime,i=this._codec.getModule(Wr);return i.setType(1),i.setCount(t),i.setStartTime(r),i.getArrayData()},n.prototype.encodeOldConversationList=function(e){var t=(e=e||{}).count,r=e.type,i=e.startTime,s=e.order;t=t||0,i=i||0,s=s||0;var o=this._codec.getModule(Wr);return o.setType(r),o.setCount(t),o.setStartTime(i),o.setOrder(s),o.getArrayData()},n.prototype.encodeRemoveOldConversationList=function(e){var t=(e=e||{}).conversationType,r=e.channelId,i=this._codec.getModule(Ro);return i.setType(t),i.setBusChannel(r),i.getArrayData()},n.prototype.encodeRemoveConversationList=function(e){var t=this,r=this._codec.getModule(Co),i=[];return Oe(e,function(s){var o=s.conversationType,c=s.targetId,d=t._codec.getModule(Eo);d.setType(o),d.setChannelId(c),i.push(d)}),r.setSessions(i),r.getArrayData()},n.prototype.encodeDeleteMessages=function(e,t,r,i){var s=this._codec.getModule(To),o=[];return Oe(r,function(c){o.push({msgId:c.messageUId,msgDataTime:c.sentTime,direct:c.messageDirection})}),s.setType(e),s.setConversationId(t),s.setMsgs(o),s.setBusChannel(i),s.getArrayData()},n.prototype.encodeClearMessages=function(e,t,r){var i=this._codec.getModule(So);return t=t||new Date().getTime(),i.setDataTime(t),i.setTargetId(e),i.setBusChannel(r),i.getArrayData()},n.prototype.encodeClearUnreadCount=function(e,t){var r=e.conversationType,i=e.targetId,s=t.timestamp,o=this._codec.getModule(Io);return s=s||+new Date,o.setType(r),o.setChannelId(i),o.setMsgTime(s),o.getArrayData()},n.prototype.encodeJoinOrQuitChatRoom=function(){var e=this._codec.getModule(bo);return e.setNothing(1),e.getArrayData()},n.prototype.encodeGetChatRoomInfo=function(e,t){var r=this._codec.getModule(No);return r.setCount(e),r.setOrder(t),r.getArrayData()},n.prototype.encodeGetFileToken=function(e,t,r,i){var s=this._codec.getModule(Do);return s.setType(e),s.setKey(t),s.setHttpMethod(r),s.setQueryString(i),s.getArrayData()},n.prototype.encodeGetFileUrl=function(e,t,r,i){var s=this._codec.getModule(e);return s.setType(t),s.setKey(r),i&&s.setFileName(i),s.getArrayData()},n.prototype.encodeModifyChatRoomKV=function(e,t,r){var i=this._connectType==="comet",s=this._codec.getModule($o),o=t.key,c=t.value,d=t.notificationExtra,l=t.isSendNotification,h=t.type||Xe.UPDATE,a=Ka(t,h),u={key:o,value:c||"",uid:r};if(ge(a)||(u.status=a),s.setEntry(u),l){var f={conversationType:Q.CHATROOM,targetId:e},p={key:o,value:c,extra:d,type:h},m=this._getUpMsgModule(f,{messageType:qe.CHRM_KV_NOTIFY,content:p,isPersited:!1,isCounted:!1});i?s.setNotification(m.getArrayData()):s.setNotification(m),s.setBNotify(!0),s.setType(Q.CHATROOM)}return s.getArrayData()},n.prototype.encodeModifyChatRoomKVS=function(e,t,r){this._connectType;var i=this._codec.getModule(jo),s=t.entries,o=t.type||Xe.UPDATE,c=Ka(t,o),d=[];return s.forEach(function(l){var h={key:l.key,value:l.value||"",uid:r};ge(c)||(h.status=c),d.push(h)}),i.setEntry(d),i.getArrayData()},n.prototype.encodePullChatRoomKV=function(e){var t=this._codec.getModule(qo);return t.setTimestamp(e),t.getArrayData()},n.prototype.encodePullUserSetting=function(e){var t=this._codec.getModule(Go);return t.setVersion(e),t.getArrayData()},n.prototype.encodeGetConversationStatus=function(e){var t=this._codec.getModule(Yo);return t.setTime(e),t.getArrayData()},n.prototype.encodeSetConversationStatus=function(e){var t=this,r=this._connectType==="comet",i=this._codec.getModule(ti),s=sn.getTime(),o=[];return Oe(e,function(c){var d=t._codec.getModule(Zr),l=c.conversationType,h=c.targetId,a=c.notificationStatus,u=c.isTop,f=c.channelId,p=[];d.setType(l),d.setChannelId(h),d.setTime(s),d.setBusChannel(f);var m=a===rn.OPEN,_={};ge(a)||(_[Ja]=m),ge(u)||(_[Wa]=u),Oe(_,function(y,C){if(!ge(y)){var b=t._codec.getModule(ei);y=y?Ji:Rh,b.setSessionStateType(Number(C)),b.setValue(y);var O=r?b.getArrayData():b;p.push(O)}}),d.setStateItem(p);var v=r?d.getArrayData():d;o.push(v)}),i.setVersion(s),i.setState(o),i.getArrayData()},n.prototype.encodeReadReceipt=function(e,t){var r=this._codec.getModule(ni);return r.setMsgId(e),t&&r.setChannelId(t),r.getArrayData()},n.prototype.encodeCreateTag=function(e,t){var r=this,i=this._connectType==="comet",s=this._codec.getModule(Wo),o=[];return e.forEach(function(c){var d=r._codec.getModule(Hn);d.setTagId(c.tagId),d.setName(c.tagName),o.push(i?d.getArrayData():d)}),s.setTags(o),s.setVersion(t),s.getArrayData()},n.prototype.encodeMessageReader=function(e,t){var r=this._codec.getModule(ni);return r.setMsgId(e),t&&r.setChannelId(t),r.getArrayData()},n.prototype.encodeRemoveTag=function(e,t){var r=this,i=this._connectType==="comet",s=this._codec.getModule(zo),o=[];return e.forEach(function(c){var d=r._codec.getModule(Hn);d.setTagId(c),o.push(i?d.getArrayData():d)}),s.setTags(o),s.setVersion(t),s.getArrayData()},n.prototype.encodeDisConversationTag=function(e){var t=this._codec.getModule(Qo);return t.setTagId(e),t.getArrayData()},n.prototype.encodeUpdateConversationTag=function(e,t){var r=this,i=this._connectType==="comet",s=this._codec.getModule(ti),o=[];return t.forEach(function(c){var d=r._codec.getModule(Zr),l=r._codec.getModule(ei),h=[];e.forEach(function(a){var u=r._codec.getModule(Hn);u.setTagId(a.tagId),ge(a.isTop)||u.setIsTop(a.isTop),h.push(i?u.getArrayData():u)}),l.setSessionStateType(za),l.setValue(JSON.stringify(h)),l.setTags(h),d.setType(c.conversationType),d.setChannelId(c.targetId),d.setTime(Date.now()),d.setStateItem([i?l.getArrayData():l]),o.push(i?d.getArrayData():d)}),s.setState(o),s.setVersion(sn.getTime()),s.getArrayData()},n.prototype.encodeReportSDKInfo=function(e){var t=this._codec.getModule(Xo);return t.setSdkInfo(e),t.getArrayData()},n.prototype.encodeJoinRTCRoom=function(e,t,r){var i=this._codec.getModule(zr);return e=e||0,i.setRoomType(e),ge(t)||i.setBroadcastType(t),ge(r)||i.setJoinType(r),i.getArrayData()},n.prototype.encodeQuitRTCRoom=function(){return this._codec.getModule(Oo).getArrayData()},n.prototype.encodeSetRTCData=function(e,t,r,i,s){var o=this._codec.getModule(Ao);if(o.setInterior(r),o.setTarget(i),o.setKey(e),o.setValue(t),s){s.name&&o.setObjectName(s.name);var c=s.content;c&&(He(c)&&(c=JSON.stringify(c)),o.setContent(c))}return o.getArrayData()},n.prototype.encodeUserSetRTCData=function(e,t,r,i){var s=this,o=this._connectType==="comet",c=this._codec.getModule(Qr);c.setObjectName(r);var d=this._codec.getModule(ot);d.setKey(e.name),d.setValue(e.content),o?c.setContent([d.getArrayData()]):c.setContent(d);var l=[];return["uris","mcu_uris"].forEach(function(h){var a=s._codec.getModule(ot);a.setKey(h);var u=h==="uris"?t:i;a.setValue(u),o?l.push(a.getArrayData()):l.push(a)}),c.setValueInfo(l),c.getArrayData()},n.prototype.encodeUserSetRTCCDNUris=function(e,t){this._connectType;var r=this._codec.getModule(Qr);r.setObjectName(e);var i=this._codec.getModule(ot);return i.setKey("cdn_uris"),i.setValue(t),r.setValueInfo(i),r.getArrayData()},n.prototype.encodeGetRTCData=function(e,t,r){var i=this._codec.getModule(Xr);return i.setInterior(t),i.setTarget(r),i.setKey(e),i.getArrayData()},n.prototype.encodeRemoveRTCData=function(e,t,r,i){var s=this._codec.getModule(Xr);s.setInterior(t),s.setTarget(r),s.setKey(e);var o=(i=i||{}).name,c=i.content;return!ge(o)&&s.setObjectName(o),ge(c)||(He(c)&&(c=JSON.stringify(c)),s.setContent(c)),s.getArrayData()},n.prototype.encodeSetRTCOutData=function(e,t,r){var i=this._codec.getModule(Mo);i.setTarget(t),ze(e)||(e=[e]),Oe(e,function(c,d){c.key=c.key?c.key.toString():c.key,c.value=c.value?c.value.toString():c.value,e[d]=c}),i.setValueInfo(e);var s=(r=r||{}).name,o=r.content;return!ge(s)&&i.setObjectName(s),ge(o)||(He(o)&&(o=JSON.stringify(o)),i.setContent(o)),i.getArrayData()},n.prototype.ecnodeGetRTCOutData=function(e){var t=this._codec.getModule(Lo);return t.setUserId(e),t.getArrayData()},n.prototype.encodeSetRTCState=function(e){var t=this._codec.getModule(Po);return t.setState(e),t.getArrayData()},n.prototype.encodeGetRTCRoomInfo=function(){var e=this._codec.getModule(ko);return e.setOrder(2),e.getArrayData()},n.prototype.encodeSetRTCUserInfo=function(e,t){var r=this._codec.getModule(ot);return r.setKey(e),r.setValue(t),r.getArrayData()},n.prototype.encodeRemoveRTCUserInfo=function(e){var t=this._codec.getModule(Uo);return t.setKey(e),t.getArrayData()},n.prototype.encodeIdentityChangeInfo=function(e,t,r){r===void 0&&(r=!1);var i=this._codec.getModule(zr);return i.setRoomType(Ye.LIVE),t&&i.setBroadcastType(t),i.setIdentityChangeType(e),i.setNeedSysChatroom(r),i.getArrayData()},n.prototype.encodePullRTCRoomKV=function(e,t){var r=this._codec.getModule(ea);return r.setTimestamp(t),r.setRoomId(e),r.getArrayData()},n.prototype.encodeQueryUserJoinedInfo=function(e){var t=this._codec.getModule(ta);return t.setUserId(e),t.getArrayData()},n.prototype.encodeRequestRoomPK=function(e){var t=e.invitedRoomId,r=e.invitedUserId,i=e.inviteSessionId,s=e.inviteTimeout,o=e.inviteInfo,c=this._codec.getModule(na);return c.setInvitedRoomId(t),c.setInvitedUserId(r),c.setInviteSessionId(i),c.setTimeoutTime(s),c.setInviteInfo(o),c.getArrayData()},n.prototype.encodeCancelRoomPK=function(e){var t=e.invitedRoomId,r=e.invitedUserId,i=e.inviteSessionId,s=e.inviteInfo,o=this._codec.getModule(ra);return o.setInvitedRoomId(t),o.setInvitedUserId(r),o.setInviteSessionId(i),o.setInviteInfo(s),o.getArrayData()},n.prototype.encodeResponseRoomPK=function(e){var t=e.inviteUserId,r=e.inviteRoomId,i=e.inviteSessionId,s=e.content,o=e.key,c=e.value,d=e.agree?1:0,l=this._codec.getModule(ia);return l.setInviteUserId(t),l.setInviteRoomId(r),l.setInviteSessionId(i),l.setContent(s),l.setKey(o),l.setValue(c),l.setAnswerCode(d),l.getArrayData()},n.prototype.encodeEndRoomPK=function(e){var t=e.endRoomId,r=e.sessionId,i=e.content,s=e.keys,o=this._codec.getModule(sa);return o.setInviteRoomId(t),o.setInviteSessionId(r),o.setInviteContent(i),o.setInviteRoomKeys(s),o.getArrayData()},n}(),Au=function(n,e){this._watcher=e,this.codec=new Th(n)},Mu=function(n,e){return n&&e?e+"_"+n:n||Date.now()},or=function(){function n(e){this.header=e,this._name=null,this.lengthSize=0,this.messageId=0,this.timestamp=0,this.syncMsg=!1,this.identifier=""}return n.prototype.getIdentifier=function(){var e=this.messageId,t=this.identifier;return Mu(e,t)},n.prototype.read=function(e,t,r){this.readMessage(e,t,r)},n.prototype.readMessage=function(e,t,r){return{stream:e,length:t}},n}(),Pu=function(){function n(e){this.lengthSize=0,this.messageId=0,this.topic="",this.targetId="",this.identifier="",this._header=new po(e,!1,St.AT_MOST_ONCE,!1)}return n.prototype.getIdentifier=function(){var e=this.messageId,t=this.identifier;return Mu(e,t)},n.prototype.write=function(e){var t=this.getHeaderFlag();e.write(t),this.writeMessage(e)},n.prototype.setHeaderQos=function(e){this._header.qos=e},n.prototype.getHeaderFlag=function(){return this._header.encode()},n.prototype.getLengthSize=function(){return this.lengthSize},n.prototype.getBufferData=function(){var e=new Xl;this.write(e);var t=e.getBytesArray();return new Int8Array(t)},n.prototype.getCometData=function(){var e=this.data||{};return JSON.stringify(e)},n}(),Lu=function(n){function e(){var t=n!==null&&n.apply(this,arguments)||this;return t._name=nt.CONN_ACK,t.status=null,t.userId=null,t.timestamp=0,t}return we(e,n),e.prototype.readMessage=function(t,r,i){if(t.readByte(),this.status=+t.readByte(),r<=e.MESSAGE_LENGTH)return{stream:t,length:r};if(i===Kt.V4){var s=t.readByte();1&s&&(this.userId=t.readUTF()),2&s&&t.readUTF(),4&s&&(this.timestamp=t.readLong()),8&s&&(this.messageId=t.read2Byte())}else{this.userId=t.readUTF();var o=t.readUTF();K.debug("server sessionId -> "+o),this.timestamp=t.readLong()}return{stream:t,length:r}},e.MESSAGE_LENGTH=2,e}(or),oa=function(n){function e(){var t=n!==null&&n.apply(this,arguments)||this;return t._name=nt.DISCONNECT,t.status=0,t}return we(e,n),e.prototype.readMessage=function(t,r){return t.readByte(),this.status=+t.readByte(),{stream:t,length:r}},e.MESSAGE_LENGTH=2,e}(or),Sh=function(n){function e(){var t=n.call(this,Ke.PING_REQ)||this;return t._name=nt.PING_REQ,t}return we(e,n),e.prototype.writeMessage=function(t){},e}(Pu),ku=function(n){function e(t){var r=n.call(this,t)||this;return r._name=nt.PING_RESP,r}return we(e,n),e}(or),aa=function(n){function e(){var t=n!==null&&n.apply(this,arguments)||this;return t.messageId=0,t}return we(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}(or),Ai=function(n){function e(){var t=n!==null&&n.apply(this,arguments)||this;return t.messageId=0,t}return we(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}(Pu),Zn=function(n){function e(){var t=n!==null&&n.apply(this,arguments)||this;return t._name=nt.PUBLISH,t.topic="",t.targetId="",t.syncMsg=!1,t.identifier=Wt.PUB,t}return we(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}(aa),On=function(n){function e(t,r,i){var s=n.call(this,Ke.PUBLISH)||this;return s._name=nt.PUBLISH,s.syncMsg=!1,s.identifier=Wt.PUB,s.topic=t,s.data=et(r)?sr.writeUTF(r):r,s.targetId=i,s}return we(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}(Ai),Bs=function(n){function e(){var t=n!==null&&n.apply(this,arguments)||this;return t._name=nt.PUB_ACK,t.status=0,t.date=0,t.millisecond=0,t.messageUId="",t.timestamp=0,t.identifier=Wt.PUB,t.topic="",t.targetId="",t}return we(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}(aa),Uu=function(n){function e(t){var r=n.call(this,Ke.PUB_ACK)||this;return r._name=nt.PUB_ACK,r.status=0,r.date=0,r.millisecond=0,r.messageUId="",r.timestamp=0,r.messageId=t,r}return we(e,n),e.prototype.writeMessage=function(t){n.prototype.writeMessage.call(this,t)},e}(Ai),X=function(n){function e(t,r,i){var s=n.call(this,Ke.QUERY)||this;return s.name=nt.QUERY,s.identifier=Wt.QUERY,s.topic=t,s.data=et(r)?sr.writeUTF(r):r,s.targetId=i,s}return we(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}(Ai),Du=function(n){function e(t){var r=n.call(this,Ke.QUERY_CONFIRM)||this;return r._name=nt.QUERY_CON,r.messageId=t,r}return we(e,n),e}(Ai),$n=function(n){function e(){var t=n!==null&&n.apply(this,arguments)||this;return t._name=nt.QUERY_ACK,t.status=0,t.identifier=Wt.QUERY,t.topic="",t.targetId="",t}return we(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}(aa),xu=function(n){var e,t=n.type;switch(t){case Ke.CONN_ACK:e=new Lu(n);break;case Ke.PUBLISH:(e=new Zn(n)).syncMsg=n.syncMsg;break;case Ke.PUB_ACK:e=new Bs(n);break;case Ke.QUERY_ACK:e=new $n(n);break;case Ke.SUB_ACK:case Ke.UNSUB_ACK:case Ke.PING_RESP:e=new ku(n);break;case Ke.DISCONNECT:e=new oa(n);break;default:e=new or(n),K.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"})(xs||(xs={}));var ft,D=xs,Bu=function(n,e,t,r){return x(void 0,void 0,void 0,function(){var i;return B(this,function(s){return i=0,n.forEach(function(o){return x(void 0,void 0,void 0,function(){var c,d;return B(this,function(l){switch(l.label){case 0:return c=e+"://"+o+"/ping?r="+(a=9999,(h=1e3)+Math.floor(Math.random()*(a-h))),K.debug("start ping",c),[4,t.httpReq({url:c,timeout:5e3})];case 1:return d=l.sent(),K.debug("end ping",i,c,d.status),i++,r({finished:i===n.length,code:d.status,host:o}),[2]}var h,a})})}),[2]})})},Vu=function(n,e,t,r,i,s,o,c){return n+"://"+e+"/websocket?appId="+t+"&token="+encodeURIComponent(r)+"&sdkVer="+s+"&pid="+o+"&apiVer="+(i.isFromUniapp?"uniapp":"normal")+(i.connectPlatform?"&platform="+i.connectPlatform:"")+(c?"&protocolVer="+c:"")},Fu=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"})(ft||(ft={}));var gt,Qa=function(n,e){K.info("websocket send -> messageId: "+n.messageId);var t=n.getBufferData();e.send(t.buffer)},Cn=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 we(e,n),e.prototype.connect=function(t,r,i,s,o,c){return x(this,void 0,void 0,function(){var d=this;return B(this,function(l){return[2,new Promise(function(h){var a=[],u=0,f=!1,p=!1,m=function(){return x(d,void 0,void 0,function(){var _;return B(this,function(v){switch(v.label){case 0:return a.length===0||f?[2]:(f=!0,[4,this._connect(t,r,a.shift(),s,o,c)]);case 1:if((_=v.sent())===N.SUCCESS)this._checkAlive(),h(_);else if(_===je.REDIRECT)h(_);else{if(p&&a.length===0)return h(gu(_)),[2];f=!1,m()}return[2]}})})};o=lo(o),d._watcher.status(re.CONNECTING),Bu(i,s,d._runtime,function(_){var v=_.code,y=_.finished,C=_.host;p=y,v===200&&(a.push(C),u++,m()),y&&u===0&&(K.error("No valid websocket server hosts!"),h(N.RC_SOCKET_NOT_CREATED))})})]})})},e.prototype._connect=function(t,r,i,s,o,c){return x(this,void 0,void 0,function(){var d,l,h,a,u,f=this;return B(this,function(p){switch(p.label){case 0:return d=s.replace("http","ws"),l=Vu(d,i,t,r,this._runtime,o,"",c),K.debug("conenct start -> "+l),this.sendConnectTime=Date.now(),h=this._runtime.createWebSocket(l),a=function(m){f._timer&&(clearTimeout(f._timer),f._timer=null),f._socket===h&&(f._socket=null,f._watcher.status(m))},[4,new Promise(function(m){h.onMessage(function(_){if(Object.prototype.toString.call(_)==="[object ArrayBuffer]"){var v=function(C,b){var O=new Uint8Array(C),S=new Ql(O),E=S.readByte(),w=new po(E),V=xu(w);return V.read(S,O.length-1,b),V}(_,c);if(v instanceof ku&&f._pingResolve)return f._pingResolve(N.SUCCESS),void(f._pingResolve=void 0);if(v instanceof Lu)return K.debug("recv connect ack -> "+v.status),v.status!==je.ACCEPTED?(K.warn("connect failed: "+v.status),void m(v.status)):(K.info("connect success -> "+l),f.connectedTime=v.timestamp,f.userId=v.userId||"",f._idCount=v.messageId,void m(N.SUCCESS));if(v instanceof oa){var y=v.status;switch(K.warn("recv disconnect signal -> status: "+y),y){case ft.BLOCK:f._watcher.status(re.BLOCKED);break;case ft.OTHER_DEVICE_LOGIN:f._watcher.status(re.KICKED_OFFLINE_BY_OTHER_CLIENT);break;case ft.REDIRECT_NEW:case ft.REDIRECT:f._watcher.status(re.REDIRECT);break;default:f._watcher.status(re.DISCONNECT_BY_SERVER)}}else f._onReceiveSignal(v)}else K.error("Socket received invalid data:",_)}),h.onClose(function(_,v){for(var y in K.warn("websocket closed! code:",_,"reason:",v),a(re.CONNECTION_CLOSED),f._messageIds){var C=f._messageIds[y];delete f._messageIds[y],C(N.RC_NET_CHANNEL_INVALID)}m(_)}),h.onError(function(_){var v;for(var y in K.error("websocket error!",(v=_)===null||v===void 0?void 0:v.stack),a(re.WEBSOCKET_ERROR),f._messageIds){var C=f._messageIds[y];delete f._messageIds[y],C(N.RC_NET_CHANNEL_INVALID)}m(N.NETWORK_ERROR)}),h.onOpen(function(){return K.debug("websocket open =>",l)}),setTimeout(function(){m(N.TIMEOUT)},5e3)})];case 1:return(u=p.sent())===N.SUCCESS?this._socket=h:(K.warn("connect result -> code: "+u+", url: "+l),h.close()),[2,u]}})})},e.prototype._checkAlive=function(){var t;return x(this,void 0,void 0,function(){var r,i=this;return B(this,function(s){switch(s.label){case 0:return this._socket?(K.debug("send ping ->"),this.sendOnly(new Sh),[4,new Promise(function(o){i._pingResolve=o,i._timer&&clearTimeout(i._timer),i._timer=setTimeout(function(){i._pingResolve=void 0,o(N.TIMEOUT)},15e3)})]):[2];case 1:return(r=s.sent())!==N.SUCCESS?(this._failedCount+=1,K.warn("ping failed count: "+this._failedCount+", code: "+r),this._failedCount>=this.ALLOW_FAILED_TIMES?(this._failedCount=0,K.warn("ping timeout, close current websocket to reconnect!"),(t=this._socket)===null||t===void 0||t.close(),this._watcher.status(re.NETWORK_UNAVAILABLE)):this._checkAlive(),[2]):(K.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,c,d,l=this;return B(this,function(h){switch(h.label){case 0:return r=t.messageId,t.header&&t.header.qos!==St.AT_MOST_ONCE&&(t instanceof Zn&&!t.syncMsg&&(K.debug("send pubAck -> "+r),this.sendOnly(new Uu(r))),t instanceof $n&&(K.debug("send queryCon -> "+r),this.sendOnly(new Du(r)))),r>0&&(t instanceof Bs||t instanceof $n)&&(K.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 Zn?(o=t.syncMsg,(c=t.topic)===D[D.userSetData]?[2]:!o||Fu(c)?(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&&Qa(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,c,d,l=this;return B(this,function(h){switch(h.label){case 0:return this._socket?(o=this._generateMessageId(),t.messageId=o,Qa(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(c=h.sent())?c instanceof $n||c instanceof Bs?(d=r&&c.data?this.codec.decodeByPBName(c.data,r,i):c,c.status!==0?(K.warn("send failed -> message: "+o+", respPBName: "+r+", status: "+c.status),[2,{code:c.status,data:r&&c.data?d:null}]):[2,{code:N.SUCCESS,data:d}]):[2,{code:c}]:(K.warn("send timeout -> message: "+o+", respPBName: "+r+", timeout: "+s),[2,{code:N.TIMEOUT}]);case 2:return[2,{code:N.RC_NET_CHANNEL_INVALID}]}})})},e.prototype.close=function(){this._socket&&(this._socket.close(),this._socket=null,this._watcher.status(re.DISCONNECTED))},e}(Au);(function(n){n.GET="GET",n.POST="POST"})(gt||(gt={}));var En=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 we(e,n),e.prototype.handleCometRes=function(t){var r=this;if(t.status!==200&&t.status!==202)return!1;var i=et(t.data)?JSON.parse(t.data):t.data;return i?!ze(i)||(Oe(i,function(s){return x(r,void 0,void 0,function(){var o,c,d,l,h,a,u,f,p,m,_,v=this;return B(this,function(y){switch(y.label){case 0:if((o=s.sessionid)&&(this._sessionid=o),c=function(C){var b=C.headerCode,O=new po(b),S=xu(O);for(var E in C)S[E]=C[E];return S}(s),d=c.messageId,l=c._header,h=c.status,c.identifier,a=l&&l.qos!==St.AT_MOST_ONCE,d&&c.getIdentifier&&((u=this._messageIds[d])&&u(c),this._syncMessageIds[d]&&this._syncMessageIds[d](c)),a&&(c instanceof Zn&&!c.syncMsg&&(f=new Uu(d),this.sendOnly(f)),c instanceof $n&&(f=new Du(d),this.sendOnly(f))),c instanceof oa){switch(h){case ft.OTHER_DEVICE_LOGIN:this._watcher.status(re.KICKED_OFFLINE_BY_OTHER_CLIENT);break;case ft.BLOCK:this._watcher.status(re.BLOCKED);break;case ft.REDIRECT_NEW:case ft.REDIRECT:this._watcher.status(re.REDIRECT);break;default:this._watcher.status(re.DISCONNECT_BY_SERVER)}return[2]}return c instanceof Zn?(p=c.syncMsg,m=c.topic,!p||Fu(m)?(this._watcher.signal(c),[2,!1]):[4,new Promise(function(C){v._syncMessageIds[d]=C})]):[3,2];case 1:_=y.sent(),delete this._syncMessageIds[d],this._watcher.signal(c,_),y.label=2;case 2:return[2]}})})}),!0):(K.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 B(this,function(c){switch(c.label){case 0:return r=new Date().getTime(),i=t+"://"+this._domain+"/pullmsg.js?sessionid="+this._sessionid+"&timestrap="+r+"&pid="+this._pid,[4,this._runtime.httpReq({url:i,body:{pid:this._pid},timeout:45e3})];case 1:return s=c.sent(),o=this.handleCometRes(s),this._isDisconnected||(o?this._startPullSignal(t):(this._isDisconnected=!0,this._watcher.status(re.NETWORK_UNAVAILABLE))),[2]}})})},e.prototype.connect=function(t,r,i,s,o,c){return x(this,void 0,void 0,function(){var d,l,h,a,u=this;return B(this,function(f){return o=lo(o),this._protocol=s,this._isDisconnected=!1,this._watcher.status(re.CONNECTING),d=[],l=0,h=!1,a=!1,[2,new Promise(function(p){var m=function(){return x(u,void 0,void 0,function(){var _;return B(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())===N.SUCCESS)this._startPullSignal(s),p(_);else if(_===je.REDIRECT)p(_);else{if(a&&d.length===0)return p(gu(_)),[2];h=!1,m()}return[2]}})})};u._watcher.status(re.CONNECTING),Bu(i,s,u._runtime,function(_){var v=_.code,y=_.finished,C=_.host;a=y,v===200&&(d.push(C),l++,m()),y&&l===0&&(K.error("No valid websocket server hosts!"),p(N.RC_SOCKET_NOT_CREATED))})})]})})},e.prototype._connect=function(t,r,i,s,o){return x(this,void 0,void 0,function(){var c,d,l,h;return B(this,function(a){switch(a.label){case 0:return c=function(u){return u.status!==200&&u.status!==202?(K.error("handle comet res -> res: "+JSON.stringify(u||{})),!1):!!u.data&&(function(f){if(He(f))return!0;var p=!1;try{var m=JSON.parse(f);p=JSON.stringify(m)===f}catch{p=!1}return p}(u.data)?He(u.data)?u.data:JSON.parse(u.data):(K.error("received data is not a validJson",u.data),!1))},d=Vu(s,i,t,r,this._runtime,o,this._pid),this.sendConnectTime=Date.now(),K.debug("conenct start -> "+d),[4,this._runtime.httpReq({url:d,body:{pid:this._pid},timeout:5e3})];case 1:return l=a.sent(),h=c(l),this._domain=i,h&&h.status===0?(this._sessionid=h.sessionid,this.userId=h.userId,this.connectedTime=h.timestamp):K.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,c,d,l,h,a,u,f;return B(this,function(p){switch(p.label){case 0:return s=(i=this)._domain,o=i._sessionid,c=i._pid,d=t.messageId,l=t.topic,h=t.targetId,t.identifier,a=t.getHeaderFlag(),u=l?this._protocol+"://"+s+"/websocket?messageid="+d+"&header="+a+"&sessionid="+o+"&topic="+l+"&targetid="+h+"&pid="+c:this._protocol+"://"+s+"/websocket?messageid="+d+"&header="+a+"&sessionid="+o+"&pid="+c,[4,this._runtime.httpReq({url:u,method:gt.POST,body:t.getCometData()})];case 1:return f=p.sent(),this.handleCometRes(f),[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,c,d,l=this;return B(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(c=h.sent())?(d=r&&c.data?this.codec.decodeByPBName(c.data,r,i):c,c.status!==0?[2,{code:c.status,data:r&&c.data?d:null}]:[2,{code:N.SUCCESS,data:d}]):[2,{code:N.TIMEOUT}]}})})},e.prototype.close=function(){this._isDisconnected=!0,this._watcher.status(re.DISCONNECTED)},e}(Au),Ih=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()},Wi=function(n){return["navi",n].join("_")},bh=function(){function n(e,t){this._runtime=e,this._options=t,this._naviInfo=null,this._appkey=this._options.appkey,this._apiVersion=lo(this._options.apiVersion)}return n.prototype.getInfo=function(e,t,r,i){return x(this,void 0,void 0,function(){var s,o;return B(this,function(c){switch(c.label){case 0:return r&&this._clear(e),(s=function(d,l,h){var a,u,f=Wi(d);try{var p=h.getItem(f);u=p?JSON.parse(p):[]}catch{u=[]}var m=Date.now();return u.length>0&&(u=u.filter(function(_){return m-_.timestamp<72e5})),u.length===0?h.removeItem(f):h.setItem(f,JSON.stringify(u)),((a=u.find(function(_){return _.token===l}))===null||a===void 0?void 0:a.naviInfo)||null}(this._appkey,e,this._runtime.localStorage))?(this._naviInfo=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=c.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 c,d=Wi(r);try{var l=o.getItem(d);c=l?JSON.parse(l):[]}catch{c=[]}var h=Date.now();c.length>0&&(c=c.filter(function(a){return h-a.timestamp<72e5&&i!==a.token})),c.push({timestamp:h,naviInfo:s,token:i}),o.setItem(d,JSON.stringify(c))}(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=Wi(t);try{var c=i.getItem(o);s=c?JSON.parse(c):[]}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}(),vr=function(n,e,t){return[n,e,t].join("_")},wh=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=vr("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=vr("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=vr("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=vr("outbox",this._appkey,e);t.outboxTime=parseInt(this._runtime.localStorage.getItem(r))||0}return t.outboxTime},n}(),zi={_caches:{},set:function(n,e){this._caches[n]=e},get:function(n){return this._caches[n]||0},clear:function(n){this._caches[n]=0}},Nh=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,c=this._getSetUserId(r),d=i===Xe.DELETE,l=c===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)}),K.debug("end setEntries")},n.prototype.clear=function(){this._kvCaches={}},n}(),Oh=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,c;return B(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=zi.get(t))>r?(this._isPulling=!1,this._startPull(),[2]):[4,this._engine.pullChatroomEntry(t,i)]);case 1:return s=d.sent(),o=s.code,c=s.data,this._isPulling=!1,o===N.SUCCESS?(zi.set(t,c.syncTime||0),this._startPull()):this._startPull(),[2]}})})},n.prototype.reset=function(e){zi.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];Fn(i)||(i=new Nh(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}(),Ah=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{K.error("parse rejoined chrm infos error -> "+t),e={}}return e},n.prototype.remove=function(e){delete this._joinedChrmsInfo[e],Fn(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}(),Qi="converStatusChanged",Mh=function(){function n(e,t,r){this._eventEmitter=new ir,this._pullQueue=[],this._isPulling=!1,this._storage=vi(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(!ge(e)&&Array.isArray(e)){var r=this._storage.get(this._storagePullTimeKey)||0,i=e.length;e.forEach(function(s,o){var c=s.updatedTime||0;r=c>r?c:r,s.conversationType=s.type,t._eventEmitter.emit(Qi,{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 B(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===N.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(Qi,function(t){e(t)})},n.prototype.unwatch=function(){this._eventEmitter.off(Qi,function(e){})},n}(),jt={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}},Br={};for(var Xa in jt){var Ph=jt[Xa].keyName;Br[Ph]=Xa}var An,Lh=function(){function n(e,t,r){this._appkey=t,this._currentUserId=r;var i="con-"+t+"-"+r;this.storage=new Pa(e,i),this._localStore=new Pa(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:Q.PRIVATE,targetId:"",channelId:""}},n.prototype.updateMentionedData=function(e){var t=this,r=e.conversationType,i=e.targetId,s=e.messageType,o=e.isMentioned,c=e.content,d=e.senderUserId,l=e.channelId,h=this._getStoreKey(r,i,l),a=this._localStore.get(h)||{},u=Br.mentionedInfo,f=Br.hasMentioned,p=a[u]||{},m=p.userIdList||[],_=c.mentionedInfo;if(_){if(o&&r===Q.GROUP&&((_.userIdList||[]).forEach(function(y){y===t._currentUserId&&m.indexOf(d)<0&&m.push(d)}),_.type===fo.ALL&&m.indexOf(d)<0&&m.push(d)),s===qe.RECALL&&r===Q.GROUP){var v=m.indexOf(d);v>=0&&m.splice(v,1)}_={userIdList:m,type:(_==null?void 0:_.type)||p.type},m.length!==0?(a[u]=_,a[f]=!0):(delete a[u],delete a[f]),Fn(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 c in r){var d=Br[c],l=r[c];if(!ge(d)&&!ge(l)&&c!=="hasMentioned"&&c!=="MentionedInfo"){if(l===jt[d].defaultVal||c==="tags"&&!Fn(l))delete o[d];else if(c==="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)}}Fn(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 c in jt){var d=jt[c],l=d.keyName,h=d.defaultVal;o[l]=s[c]||xr(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},c=t[i];for(var d in c){var l=jt[d],h=l.keyName,a=l.defaultVal;o[h]=c[d]||xr(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,c={},d=e[r];for(var l in d){var h=jt[l],a=h.keyName,u=h.defaultVal;c[a]=d[l]||xr(u)}for(var f in c.tags){ge(t[f])&&(t[f]=[]);var p=Object.assign({},c,{conversationType:s,targetId:o});delete p.tags,t[f].push(p)}}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){K.error("adaptOldStore error: "+i.message)}},n}(),kh=[Q.PRIVATE,Q.GROUP,Q.SYSTEM,Q.PUBLIC_SERVICE,Q.APP_PUBLIC_SERVICE],Za="conversationChanged",ec="conTagStatusChanged",Uh=function(){function n(e,t,r,i,s){var o=this;this._updatedConversations={},this._conTagStatusChanged=!1,this._eventEmitter=new ir,this._draftMap={},this._appkey=t,this._loginUserId=r,this._store=new Lh(e.runtime,t,r),this._statusManager=new Mh(e,t,r),this._statusManager.watch(function(c){var d=c.statusItem,l=c.isLastPull;o.addStatus(d,l)}),this._eventEmitter.on(Za,function(c){i(c)}),this._eventEmitter.on(ec,function(){s()})}return n.prototype._calcUnreadCount=function(e,t){var r=e.content,i=e.messageType,s=e.sentTime,o=e.isCounted,c=e.messageDirection,d=e.senderUserId,l=c===at.SEND&&d===this._loginUserId,h=i===qe.RECALL,a=He(r),u=!1,f={},p=t.lastUnreadTime||0,m=t.unreadMessageCount||0;return p>s||l?{hasChanged:u,localConversation:t,updateItems:f}:(o&&(t.unreadMessageCount=m+1,t.lastUnreadTime=s,u=!0),h&&a&&p>=r.sentTime&&m&&(t.unreadMessageCount=m-1,u=!0),u&&(f.unreadMessageCount={val:t.unreadMessageCount,time:s}),{hasChanged:u,localConversation:t,updateItems:f})},n.prototype._calcMentionedInfo=function(e,t){var r=e.content,i=(e.messageDirection,e.isMentioned),s=e.sentTime;at.SEND;var o=He(r),c=!1,d={};return i&&o&&r.mentionedInfo&&(t.hasMentioned=!0,c=!0,d.hasMentioned={val:!0,time:s},d.mentionedInfo={val:r.mentionedInfo,time:s}),{hasChanged:c,localConversation:t,updateItems:d}},n.prototype._calcMentionedCount=function(e,t){var r=e.content,i=e.messageDirection,s=!1;if(e.isMentioned&&i===at.RECEIVE&&(r==null?void 0:r.mentionedInfo)){var o=r.mentionedInfo,c=o.type,d=o.userIdList;if(c===fo.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(He(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,c=e.isTop,d=e.tags,l=e.channelId,h={},a={};ge(o)||(a.notificationStatus={time:s,val:o}),ge(c)||(a.isTop={time:s,val:c}),ge(d)||(a.tags={time:s,val:d},d==null||d.forEach(function(u){h[u.tagId]={isTop:u.isTop}})),this._setConTagStatusChanged(r,i,h,l),this._store.set(r,i,{notificationStatus:o,isTop:c,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(Za,e),this._updatedConversations={},this._conTagStatusChanged&&(this._eventEmitter.emit(ec),this._conTagStatusChanged=!1))},n.prototype.setConversationCacheByMessage=function(e,t){var r=this,i=e.conversationType,s=e.isPersited,o=e.targetId,c=e.channelId;if(kh.indexOf(i)>=0){var d=!1,l=this._store.get(i,o,c),h={};if([this._calcUnreadCount,this._calcMentionedInfo,this._calcMentionedCount].forEach(function(f){var p=f.call(r,e,l),m=p.hasChanged,_=p.localConversation,v=p.updateItems;d=d||m,h=Ce(Ce({},h),v),l=xr(_)}),d&&this._store.set(i,o,l,c),this._store.updateMentionedData(e),s){var a=this._store.get(i,o,c);a.updatedItems=Ce({latestMessage:{time:e.sentTime,val:e}},h),a.latestMessage=e;var u=Object.assign(a,{conversationType:i,targetId:o,channelId:c});this._setUpdatedConversation(u)}(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 c=o.unreadMessageCount,d=o.notificationStatus,l=o.conversationType;c=c||0,(r||d!==1)&&(t.length>0?t.includes(Number(l))&&(s+=Number(c)):s+=Number(c))}),s},n.prototype.getUnreadCountByTag=function(e,t){var r=this._store.getValueForTag()[e]||[],i=0;return r.forEach(function(s){var o=s.unreadMessageCount,c=s.notificationStatus;(t||c!==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,c=s.hasMentioned,d={};if(o&&(s.unreadMessageCount=0,d.unreadMessageCount={val:0,time:Date.now()}),c&&(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===rn.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}(),Dh=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=vi(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,c,d;return B(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!==N.SUCCESS||ge(i)?(this._isPulling=!1,this._startPull()):(o=(s=i).settings,c=s.version,d=o.Tag,ge(d)||this._updateTag(d),this._storage.set(this._storagePullTimeKey,c),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}(),xh=function(n){function e(t,r){var i=n.call(this,t,r)||this;return i._miniConnectUrl="",i._connectType=r.connectionType,i}return we(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 B(this,function(c){return this._runtime.useNavi||(o=void 0,o=this._runtime.isSupportSocket()&&this._connectType==="websocket"?xl.join(","):Bl.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,c,d,l,h,a,u,f;return B(this,function(p){switch(p.label){case 0:s="getServerEndpoint",o=0,c=t.length,p.label=1;case 1:return o<c?(d=this._formatJSONPUrl(t[o],i,r,s),K.debug("req navi => "+d),[4,this._runtime.httpReq({url:d,timeout:1e4,dataType:"text"})]):[3,4];case 2:if((l=p.sent()).status!==200)return l.status===403?K.error("request navi error: "+N.RC_CONN_USER_OR_PASSWD_ERROR):l.status===401&&K.error("request navi error: "+N.RC_CONN_APP_BLOCKED_OR_DELETED),[3,3];try{return h=l.data.match(/{[\d\D]+}/),(a=h&&h[0]?h[0]:"").indexOf('{\\"code\\":')===0&&(a=JSON.parse('"'+a+'"')),f=JSON.parse(a),u=/^https/.test(d)?"https":"http",f.protocol=u,this._runtime.useNavi||(f.server="",f.backupServer=this._miniConnectUrl,f.logSwitch=0),[2,f]}catch(m){K.error("parse navi err =>",m)}p.label=3;case 3:return o+=1,[3,1];case 4:return this._runtime.useNavi?[2,null]:[2,f={code:200,protocol:"https",server:"",voipCallInfo:"",kvStorage:0,openHttpDNS:!1,historyMsg:!1,chatroomMsg:!1,uploadServer:"https://upload.qiniup.com",bosAddr:"https://gz.bcebos.com",location:"",monitor:0,joinMChrm:!1,openMp:0,openUS:0,grpMsgLimit:0,isFormatted:0,gifSize:2048,logSwitch:0,logPolicy:"",compDays:0,msgAck:"",activeServer:"",qnAddr:"",extkitSwitch:0,alone:!1,voipServer:"",offlinelogserver:"",backupServer:this._miniConnectUrl}]}})})},e}(bh),Bh=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,c;return B(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,c=s.data,o===N.SUCCESS?(this._isPulling=!1,this._pullTime=c.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}(),Xi=function(n,e){return["send_msg",n,e].join("_")},Vh=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=Xi(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=Xi(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=Xi(this._appkey,this._userId),r=this._getLocalInfo(t);Object.keys(r).forEach(function(i){r[i]<e&&delete r[i]}),this._runtime.localStorage.setItem(t,JSON.stringify(r))},n}(),Hu=function(n){var e="RCDeviceId",t=vi(n),r="",i=t.get(e);return i?r=i:(r=fu(),t.set(e,r)),r};(An={})[Q.PRIVATE]=D.qryPMsg,An[Q.GROUP]=D.qryGMsg,An[Q.CHATROOM]=D.qryCHMsg,An[Q.CUSTOMER_SERVICE]=D.qryCMsg,An[Q.SYSTEM]=D.qrySMsg;var Fh=[D[D.recallMsg],D[D.ppMsgS],D[D.pgMsgS],D[D.ppMsgP],D[D.pgMsgP],D[D.chatMsg],D[D.pcMsgP],D[D.prMsgS]],Zi=function(n,e,t,r,i,s){return{conversationType:n,targetId:e,senderUserId:s,messageDirection:at.SEND,isCounted:!!t.isCounted,isMentioned:!!t.isMentioned,content:t.content,messageType:t.messageType,isOffLineMessage:!1,isPersited:!!t.isPersited,messageUId:r,sentTime:i,receivedTime:0,disableNotification:!!t.disableNotification,isStatusMessage:!!t.isStatusMessage,canIncludeExpansion:!!t.canIncludeExpansion,expansion:t.canIncludeExpansion?t.expansion:null,receivedStatus:Gn.UNREAD,pushConfig:t.pushConfig,channelId:t.channelId}},Hh=function(n){function e(t,r,i){var s=n.call(this,t,r,i)||this;return s._customMessageType={},s._reconnectTimer=-1,s._pullOfflineFinished=!1,s._connectedTime=0,s._localConnectedTime=0,s._pullingMsg=!1,s._pullQueue=[],s._chrmsQueue={},s._latestSyncTimestamp=0,s._intervalTimer=-1,s._letterbox=new wh(t,i.appkey),s._sendMessageStore=new Vh(t,i.appkey),s._chrmEntryHandler=new Oh(s),s}return we(e,n),e.prototype._createNavi=function(){return new xh(this.runtime,this._options)},e.prototype.getConnectedTime=function(){return this._connectedTime},e.prototype.connect=function(t,r){return x(this,void 0,void 0,function(){var i,s,o,c,d,l=this;return B(this,function(h){switch(h.label){case 0:return i=[],this._naviInfo=r,r.server?i.push(r.server):K.warn("navi.server is invalid"),(s=r.backupServer)&&s.split(",").forEach(function(a){i.indexOf(a)<0&&i.push(a)}),i.length===0?(K.error("navi invaild.",i),[2,N.UNKNOWN]):(o=this.runtime.createDataChannel({status:function(a){l._connectionStatusHandler(a,t,i,r.protocol)},signal:this._signalHandler.bind(this)},this._options.connectionType),c=Kt.V3,r.openAnti===1&&(c=Kt.V4),[4,o.connect(this._appkey,t,i,r.protocol,this._apiVer,c)]);case 1:return(d=h.sent())===N.SUCCESS?(this._channel=o,this.currentUserId=o.userId,this._connectedTime=o.connectedTime,this._localConnectedTime=Math.floor((Date.now()+o.sendConnectTime)/2),this._watcher.status(re.CONNECTED),this._pullOfflineFinished=!1,this._conversationManager=new Uh(this,this._appkey,this.currentUserId,this._watcher.conversation,this._watcher.conversationTag),this._conversationManager.startPullConversationStatus(0),this._userSettingManager=new Dh(this,this._appkey,this.currentUserId,this._watcher.tag),this._userSettingManager.pullUserSettings(0),this._sendMessageStore.init(this.currentUserId),this._conversationManager.adaptOldStore(),this._rtcKVManager=new Bh(this),this._joinedChrmManager=new Ah(this.runtime,this._appkey,this.currentUserId,r.joinMChrm),this._startSyncInterval()):o.close(),[2,d]}})})},e.prototype._connectionStatusHandler=function(t,r,i,s){if(K.warn("connection status changed:",t),t!==re.CONNECTING)if(t!==re.CONNECTED){if(this._channel&&t!==re.DISCONNECTED)return t===re.BLOCKED||t===re.KICKED_OFFLINE_BY_OTHER_CLIENT||t===re.DISCONNECT_BY_SERVER?(this.disconnect(),void this._watcher.status(t)):void(t!==re.REDIRECT?(this._watcher.status(t),this._try2Reconnect(r,i,s)):this._watcher.status(t));this._watcher.status(t)}else this._watcher.status(t);else this._watcher.status(t)},e.prototype._try2Reconnect=function(t,r,i){return x(this,void 0,void 0,function(){var s,o=this;return B(this,function(c){switch(c.label){case 0:return this._channel?(s=Kt.V3,this._naviInfo.openAnti===1&&(s=Kt.V4),[4,this._channel.connect(this._appkey,t,r,i,this._apiVer,s)]):[2];case 1:return c.sent()===N.SUCCESS?(this._pullOfflineFinished=!1,this._startSyncInterval(),this._watcher.status(re.CONNECTED),this._rejoinChrm(),K.__insertLogIntoDatabase(),[2]):(this._watcher.status(re.WEBSOCKET_UNAVAILABLE),this._reconnectTimer=setTimeout(function(){o._reconnectTimer=-1,o._try2Reconnect(t,r,i)},5e3),[2])}})})},e.prototype._signalHandler=function(t,r){var i=t.syncMsg,s=t.topic;if(i)this._receiveSyncMsg(t,r);else{var o=D[s];if(o)switch(o){case D.s_ntf:K.info("recv s_ntf -> 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 K.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,Jr),s=i.time,o=i.type,c=i.chrmId;switch(o){case 2:this._chrmEntryHandler.pullEntry(c,s);break;case 3:this._conversationManager.startPullConversationStatus(s);break;case 4:this._chrmEntryHandler.reset(c),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,Ii)).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,Zo),s=i.time,o=i.type,c=i.roomId;switch(o){case 1:this._rtcKVManager.pullEntry(c,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(Fh.includes(t.topic)){var s=(i=this._channel)===null||i===void 0?void 0:i.codec.decodeByPBName(t.data,Jn,{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!==qe.EXPANSION_NOTIFY?(s.messageType===qe.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,Jr),i=r.type,s=r.chrmId,o=r.time;if(K.info("s_ntf -> type: "+i+", chrmId: "+s+", time: "+o),i===2){var c=this._chrmsQueue[s];if(!c)return;c.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,c,d,l,h,a,u,f,p,m,_=this;return B(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),K.info("pullMsg -> sendboxTime: "+t+", inboxTime: "+r),i=this._channel.codec.encodeSyncMsg({sendboxTime:t,inboxTime:r}),s=new X(D[D.pullMsg],i,this.currentUserId),[4,this._channel.send(s,Wn,{connectedTime:this._channel.connectedTime,currentUserId:this.currentUserId})]):(this._pullingMsg=!1,[2]);case 1:return o=v.sent(),c=o.code,d=o.data,this._latestSyncTimestamp=Date.now(),c===N.SUCCESS&&d?(l=d.list,h=d.finished,a=d.syncTime,K.info("pullMsg success -> syncTime: "+a+", finished: "+h),u=0,f=[],l.forEach(function(y){if(y.messageDirection===at.SEND&&(u=Math.max(y.sentTime,u),_._sendMessageStore.getSendMessageMap()[y.messageUId]))return void _._sendMessageStore.removeByUID(y.messageUId);if(y.messageType!==qe.EXPANSION_NOTIFY){if(y.messageType===qe.SYNC_READ_STATUS){if(y.senderUserId!==_.currentUserId)return;_._conversationManager.clearUnreadCount(y.conversationType,y.targetId,y.channelId)}var C=_._handleMsgProperties(y);_._conversationManager.setConversationCacheByMessage(C,!0),f.push(C)}else _._receiveMessageExpansion(y)}),this._watcher.batchMessage(f),this._letterbox.setInboxTime(a,this.currentUserId),this._letterbox.setOutboxTime(u,this.currentUserId),this._sendMessageStore.removeByTimestamp(u),this._pullingMsg=!1,p=this._pullQueue.filter(function(y){return y>a}),this._pullQueue.length=0,(m=this._pullQueue).push.apply(m,p),h&&!this._pullOfflineFinished&&(this._pullOfflineFinished=!0,this._watcher.pullFinished()),(!h||p.length>0)&&this._syncMsg(),[2]):(K.warn("pullMsg failed -> code:",c,", 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,Ci,{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!==qe.EXPANSION_NOTIFY?r.messageType===qe.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,c=t.isPersited,d=t.isStatusMessage,l=s in Ma,h=s in this._customMessageType;if(i=l?Ma[s]:h?this._customMessageType[s]:{isCounted:!ka(o)&&o,isPersited:!ka(c)&&c},Object.assign(t,{isCounted:i.isCounted,isPersited:i.isPersited,isStatusMessage:Vl.includes(s)}),r&&(t.isStatusMessage=d),!r){var a=t.content.user;if(a){var u=a.portrait,f=a.portraitUri,p=u||f;p&&(a.portrait=a.portraitUri=p)}}return t},e.prototype.getHistoryMessage=function(t,r,i,s,o,c){return c===void 0&&(c=""),x(this,void 0,void 0,function(){var d,l,h,a,u,f,p,m,_;return B(this,function(v){switch(v.label){case 0:return l=(d=this).currentUserId,h=d._channel,a=Ch[t]||Nu,u=s===1&&i===0,h?(f=h.codec.encodeGetHistoryMsg(r,{timestamp:i,count:u?2:s,order:o,channelId:c}),[4,h.send(new X(a,f,l),zn,{currentUserId:l,connectedTime:h.connectedTime,conversation:{targetId:r}})]):[3,2];case 1:return p=v.sent(),(m=p.code)!==N.SUCCESS?[2,{code:m}]:(_=p.data,u&&_.list.length===2&&(_.hasMore=!0,o===0?_.list.shift():_.list.pop()),[2,{code:m,data:{list:_.list,hasMore:_.hasMore}}]);case 2:return[2,{code:N.RC_NET_CHANNEL_INVALID}]}})})},e.prototype.reportSDKInfo=function(t){var r=this.currentUserId,i=this._channel;if(i){K.debug("reportSDKInfo ->",t);var s=i.codec.encodeReportSDKInfo(JSON.stringify(t)),o=new X(D[D.reportsdk],s,r);i.send(o).then(function(c){var d=c.code;d!==N.SUCCESS&&K.warn("reportSDKInfo failed -> code: "+d)})}},e.prototype.deleteRemoteMessage=function(t,r,i,s){return x(this,void 0,void 0,function(){var o,c,d,l,h,a,u;return B(this,function(f){switch(f.label){case 0:return c=(o=this).currentUserId,(d=o._channel)?(l=d.codec.encodeDeleteMessages(t,r,i,s),h=new X(oh,l,c),[4,d.send(h)]):[3,2];case 1:return a=f.sent(),u=a.code,N.SUCCESS,[2,u];case 2:return[2,N.RC_NET_CHANNEL_INVALID]}})})},e.prototype.deleteRemoteMessageByTimestamp=function(t,r,i,s){return x(this,void 0,void 0,function(){var o,c,d,l,h,a,u,f;return B(this,function(p){switch(p.label){case 0:return c=(o=this).currentUserId,(d=o._channel)?(l=d.codec.encodeClearMessages(r,i,s),h=Eh[t],a=new X(h,l,c),[4,d.send(a)]):[3,2];case 1:return u=p.sent(),f=u.code,N.SUCCESS,[2,f];case 2:return[2,N.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 c,d,l,h,a,u,f,p,m=this;return B(this,function(_){switch(_.label){case 0:return d=(c=this).currentUserId,l=c._channel,r=r||Q.PRIVATE,l?(h=l.codec.encodeOldConversationList({count:t,type:r,startTime:i,order:s}),a=new X(Ya,h,d),[4,l.send(a,Qn,{currentUserId:d,connectedTime:l.connectedTime,afterDecode:function(v){var y=v.conversationType,C=v.targetId,b=v.channelId,O=m._conversationManager.get(y,C,b);return Object.assign(v,O),v}})]):[3,2];case 1:return u=_.sent(),f=u.code,p=u.data,f!==N.SUCCESS?[2,{code:f}]:[2,{code:f,data:p}];case 2:return[2,{code:N.RC_NET_CHANNEL_INVALID}]}})})},e.prototype.removeConversation=function(t,r,i){return x(this,void 0,void 0,function(){var s,o,c,d,l;return B(this,function(h){switch(h.label){case 0:return(s=this._channel)?(o=s.codec.encodeRemoveOldConversationList({conversationType:t,channelId:i,targetId:r}),c=new X(ph,o,r),[4,s.send(c)]):[3,2];case 1:return d=h.sent(),K.info("RemoveConversation =>",d),l=d.code,N.SUCCESS,[2,l];case 2:return[2,N.RC_NET_CHANNEL_INVALID]}})})},e.prototype.getConversation=function(t,r,i){return x(this,void 0,void 0,function(){var s,o,c,d,l,h;return B(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:N.CONVER_GET_ERROR}];case 1:return o=a.sent(),c=o.code,d=o.data,c!==N.SUCCESS?[2,{code:N.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||rn.CLOSE,isTop:s.isTop||!1,lastUnreadTime:s.lastUnreadTime||0,unreadMentionedCount:s.unreadMentionedCount||0},[2,{code:N.SUCCESS,data:h}])}})})},e.prototype.getAllConversationUnreadCount=function(t,r,i){var s=this._conversationManager.getAllUnreadCount(t,r,i);return Promise.resolve({code:N.SUCCESS,data:s})},e.prototype.getConversationUnreadCount=function(t,r,i){var s=this._conversationManager.getUnreadCount(t,r,i);return Promise.resolve({code:N.SUCCESS,data:s})},e.prototype.clearConversationUnreadCount=function(t,r,i){return this._conversationManager.clearUnreadCount(t,r,i,!1),Promise.resolve(N.SUCCESS)},e.prototype.clearAllUnreadCount=function(){return this._conversationManager.clearAllUnreadCount(),Promise.resolve(N.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(N.SUCCESS)},e.prototype.getConversationMessageDraft=function(t,r,i){var s=this._conversationManager.getDraft(t,r,i);return Promise.resolve({code:N.SUCCESS,data:s})},e.prototype.clearConversationMessageDraft=function(t,r,i){return this._conversationManager.clearDraft(t,r,i),Promise.resolve(N.SUCCESS)},e.prototype.pullConversationStatus=function(t){return x(this,void 0,void 0,function(){var r,i,s,o,c,d,l,h;return B(this,function(a){switch(a.label){case 0:return i=(r=this)._channel,s=r.currentUserId,i?(o=i.codec.encodeGetConversationStatus(t),c=new X(D[D.pullSeAtts],o,s),[4,i.send(c,bi)]):[3,2];case 1:return d=a.sent(),l=d.code,h=d.data,l!==N.SUCCESS?[2,{code:l}]:[2,{code:l,data:h}];case 2:return[2,{code:N.RC_NET_CHANNEL_INVALID}]}})})},e.prototype.batchSetConversationStatus=function(t){return x(this,void 0,void 0,function(){var r,i,s,o,c,d,l,h,a,u=this;return B(this,function(f){switch(f.label){case 0:return i=(r=this).currentUserId,(s=r._channel)?(o=s.codec.encodeSetConversationStatus(t),c=new X(gh,o,i),[4,s.send(c,Jo)]):[3,2];case 1:return d=f.sent(),l=d.code,h=d.data,l===N.SUCCESS?(a=h,t.forEach(function(p){u._conversationManager.addStatus(Ce(Ce({},p),{updatedTime:a.version}),!0)}),[2,l]):[2,l];case 2:return[2,N.RC_NET_CHANNEL_INVALID]}})})},e.prototype._joinChrm=function(t,r,i){return x(this,void 0,void 0,function(){var s,o,c,d,l,h,a;return B(this,function(u){switch(u.label){case 0:return(s=this._channel)?(o=s.codec.encodeJoinOrQuitChatRoom(),c=new X(i?ch:ah,o,t),[4,s.send(c,wo)]):[2,N.RC_NET_CHANNEL_INVALID];case 1:return d=u.sent(),l=d.code,h=d.data,l===N.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,c;return B(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 s<r.length?(o=r[s],[4,this._joinChrm(o,t[o]||10,!0)]):[3,4];case 2:(c=d.sent())===N.SUCCESS?this._watcher.chatroom({rejoinedRoom:{chatroomId:o,count:t[o]}}):this._watcher.chatroom({rejoinedRoom:{chatroomId:o,errorCode:c}}),d.label=3;case 3:return s++,[3,1];case 4:return[2]}})})},e.prototype._pullChrmMsg=function(t,r,i){return r===void 0&&(r=10),i===void 0&&(i=0),x(this,void 0,void 0,function(){var s,o,c,d,l,h,a,u,f,p,m,_;return B(this,function(v){switch(v.label){case 0:return this._channel?(s=this._chrmsQueue[t],o=s.pulling,c=s.timestamp,o?[2]:(s.pulling=!0,d=this._channel.codec.encodeChrmSyncMsg(c,r),l=new X(D[D.chrmPull],d,t),[4,this._channel.send(l,Wn,{connectedTime:this._channel.connectedTime,currentUserId:this.currentUserId})])):[2];case 1:return h=v.sent(),a=h.code,u=h.data,s.pulling=!1,a===N.SUCCESS&&u?(f=u.list,p=u.syncTime,m=u.finished,s.timestamp=i?Math.max(p,i):p,s.queue=s.queue.filter(function(y){return y>p}),_=[],f.forEach(function(y){y.sentTime<c||_.push(y)}),this._watcher.batchMessage(_),(!m||s.queue.length>0)&&this._pullChrmMsg(t),[2]):(K.warn("pull chatroom msg failed, code:",a,", data:",u),[2])}})})},e.prototype.joinChatroom=function(t,r){return x(this,void 0,void 0,function(){return B(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 B(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,c;return B(this,function(d){switch(d.label){case 0:return(r=this._channel)?(i=r.codec.encodeJoinOrQuitChatRoom(),s=new X(uh,i,t),[4,r.send(s)]):[2,N.RC_NET_CHANNEL_INVALID];case 1:return o=d.sent(),(c=o.code)===N.SUCCESS&&(delete this._chrmsQueue[t],this._chrmEntryHandler.reset(t),this._joinedChrmManager.remove(t)),[2,c]}})})},e.prototype.getChatroomInfo=function(t,r,i){return x(this,void 0,void 0,function(){var s,o,c,d,l,h;return B(this,function(a){switch(a.label){case 0:return(s=this._channel)?(o=s.codec.encodeGetChatRoomInfo(r,i),c=new X(D[D.queryChrmI],o,t),[4,s.send(c,Ei)]):[2,{code:N.RC_NET_CHANNEL_INVALID}];case 1:return d=a.sent(),l=d.code,h=d.data,l!==N.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,c,d,l,h,a;return B(this,function(u){switch(u.label){case 0:return(o=this._channel)?(c=o.codec.encodeGetHistoryMsg(t,{timestamp:r,count:i,order:s}),d=new X(Ou,c,t),[4,o.send(d,zn,{conversation:{targetId:t}})]):[2,{code:N.RC_NET_CHANNEL_INVALID}];case 1:return l=u.sent(),h=l.code,a=l.data,h!==N.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,c,d,l,h,a;return B(this,function(u){switch(u.label){case 0:return s=(i=this)._channel,o=i.currentUserId,s?(c=s.codec.encodeModifyChatRoomKV(t,r,o),d=r.type===Xe.UPDATE?dh:lh,l=new X(d,c,t),[4,s.send(l)]):[2,N.RC_NET_CHANNEL_INVALID];case 1:return h=u.sent(),(a=h.code)===N.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,c,d,l,h,a,u,f,p,m;return B(this,function(_){switch(_.label){case 0:return s=(i=this)._channel,o=i.currentUserId,s?(c=s.codec.encodeModifyChatRoomKVS(t,r,o),d=r.type===Xe.UPDATE?hh:fh,l=new X(d,c,t),[4,s.send(l,Ko)]):[2,{code:N.RC_NET_CHANNEL_INVALID}];case 1:return h=_.sent(),a=h.code,[N.SUCCESS,N.CHATROOM_KV_STORE_NOT_ALL_SUCCESS].indexOf(a)!==-1&&(f=[],delete(p=Object.assign({},r)).entries,r.entries.forEach(function(v){f.push(Object.assign({},v,p))}),a===N.CHATROOM_KV_STORE_NOT_ALL_SUCCESS&&(m=h.data,K.warn("\u8BBE\u7F6E\u5931\u8D25\u7684\u5C5E\u6027\uFF1A",m.errorKeys),u=m.errorKeys,m&&Array.isArray(m.errorKeys)&&m.errorKeys.forEach(function(v){var y=f.findIndex(function(C){return v.key===C.key});y!==-1&&f.splice(y,1)})),K.warn("\u8BBE\u7F6E\u6210\u529F\u7684\u5C5E\u6027\uFF1A",f),this._chrmEntryHandler.setLocal(t,{kvEntries:f,syncTime:new Date().getTime()},o)),[2,{code:a,data:u}]}})})},e.prototype.setChatroomEntry=function(t,r){return x(this,void 0,void 0,function(){return B(this,function(i){return r.type=Xe.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 B(this,function(i){return r.type=Xe.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 B(this,function(i){return r.type=Xe.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 B(this,function(i){return r.type=Xe.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 B(this,function(i){return r.type=Xe.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 B(this,function(i){return r.type=Xe.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,c,d,l,h;return B(this,function(a){switch(a.label){case 0:return(i=this._chrmEntryHandler.getValue(t,r))?[2,Promise.resolve({code:N.SUCCESS,data:i})]:[3,1];case 1:return(s=this._channel)?(o=s.codec.encodePullChatRoomKV(0),c=new X(D[D.pullKV],o,t),[4,s.send(c,cn)]):[2,Promise.reject({code:N.RC_NET_CHANNEL_INVALID})];case 2:return d=a.sent(),(l=d.data||{})&&l.kvEntries&&l.kvEntries.length&&(h=l.kvEntries.find(function(u){return u.key===r}))!==void 0?[2,Promise.resolve({code:N.SUCCESS,data:h==null?void 0:h.value})]:[2,Promise.resolve({code:N.CHATROOM_KEY_NOT_EXIST})]}})})},e.prototype.getAllChatroomEntry=function(t){return x(this,void 0,void 0,function(){var r,i,s,o,c,d,l;return B(this,function(h){switch(h.label){case 0:return(r=this._chrmEntryHandler.getAll(t))&&Object.keys(r).length?[2,Promise.resolve({code:N.SUCCESS,data:r})]:[3,1];case 1:return(i=this._channel)?(s={},o=i.codec.encodePullChatRoomKV(0),c=new X(D[D.pullKV],o,t),[4,i.send(c,cn)]):[2,Promise.reject({code:N.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:N.SUCCESS,data:s})]}})})},e.prototype.pullChatroomEntry=function(t,r){return x(this,void 0,void 0,function(){var i,s,o,c,d,l,h,a,u,f;return B(this,function(p){switch(p.label){case 0:return s=(i=this)._channel,o=i.currentUserId,s?(c=s.codec.encodePullChatRoomKV(r),d=new X(D[D.pullKV],c,t),[4,s.send(d,cn)]):[2,{code:N.RC_NET_CHANNEL_INVALID}];case 1:return l=p.sent(),h=l.code,a=l.data,h===N.SUCCESS?(K.info("Pull success ChrmKV, "+JSON.stringify(l)),this._chrmEntryHandler.setLocal(t,a,o),K.info("Save into cache success!"),u=a.kvEntries,f=[],u.length>0&&(u.forEach(function(m){var _=m.key,v=m.value,y=m.type,C=m.timestamp;f.push({key:_,value:v,type:y,timestamp:C,chatroomId:t})}),this._watcher.chatroom({updatedEntries:f})),[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,c,d,l,h,a,u,f,p;return B(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=!![Q.PRIVATE,Q.GROUP].includes(t)&&i.isStatusMessage,o=s?function(_){var v;return(v={},v[Q.PRIVATE]=D.ppMsgS,v[Q.GROUP]=D.pgMsgS,v)[_]}(t):function(_){var v;return(v={},v[Q.PRIVATE]=D.ppMsgP,v[Q.GROUP]=D.pgMsgP,v[Q.CHATROOM]=D.chatMsg,v[Q.CUSTOMER_SERVICE]=D.pcMsgP,v[Q.RTC_ROOM]=D.prMsgS,v)[_]}(t)||D.ppMsgP,s&&(i.isPersited=!1,i.isCounted=!1),c=this._channel.codec.encodeUpMsg({conversationType:t,targetId:r},i),(d=new On(D[o],c,r)).setHeaderQos(St.AT_LEAST_ONCE),s?(this._channel.sendOnly(d),[2,{code:N.SUCCESS,data:Zi(t,r,Ce({},i),"",0,this.currentUserId)}]):(l=Date.now()-this._localConnectedTime+this._connectedTime,h=Zi(t,r,Ce({},i),"",l,this.currentUserId),[4,this._channel.send(d)])):[2,{code:N.RC_NET_CHANNEL_INVALID}];case 1:return a=m.sent(),u=a.code,f=a.data,u!==N.SUCCESS?[2,{code:u,data:h}]:(p=f,this._sendMessageStore.setMessage(p.messageUId,p.timestamp),h.sentTime=p.timestamp,h.messageUId=p.messageUId,this._conversationManager.setConversationCacheByMessage(h,!0),[2,{code:N.SUCCESS,data:h}])}})})},e.prototype.recallMsg=function(t,r,i,s,o){var c;return x(this,void 0,void 0,function(){var d,l,h,a,u,f,p,m,_,v;return B(this,function(y){switch(y.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:((c=o.pushConfig)===null||c===void 0?void 0:c.pushContent)||o.pushContent||"",channelId:o.channelId},h=D[D.recallMsg],a=this._channel.codec.encodeUpMsg({conversationType:t,targetId:r},l),(u=new On(h,a,this.currentUserId)).setHeaderQos(St.AT_LEAST_ONCE),[4,this._channel.send(u)]):[2,{code:N.RC_NET_CHANNEL_INVALID}];case 1:return f=y.sent(),p=f.code,m=f.data,p!==N.SUCCESS?[2,{code:p}]:(_=m,this._sendMessageStore.setMessage(_.messageUId,_.timestamp),v=Zi(t,r,Ce(Ce({},l),{isPersited:!0}),_.messageUId,_.timestamp,this.currentUserId),this._conversationManager.setConversationCacheByMessage(v,!0),[2,{code:N.SUCCESS,data:v}])}})})},e.prototype.sendReadReceiptMessage=function(t,r,i){return x(this,void 0,void 0,function(){var s,o;return B(this,function(c){switch(c.label){case 0:return this._channel?(s=this._channel.codec.encodeReadReceipt(r,i),o=new X(D[D.rrMsg],s,t),[4,this._channel.send(o)]):[2,{code:N.RC_NET_CHANNEL_INVALID}];case 1:return[2,c.sent()]}})})},e.prototype.getMessageReader=function(t,r,i){return x(this,void 0,void 0,function(){var s,o;return B(this,function(c){switch(c.label){case 0:return this._channel?(s=this._channel.codec.encodeMessageReader(r,i),o=new X(D[D.rrList],s,t),[4,this._channel.send(o,wi)]):[2,{code:N.RC_NET_CHANNEL_INVALID}];case 1:return[2,c.sent()]}})})},e.prototype.pullUserSettings=function(t){return x(this,void 0,void 0,function(){var r,i;return B(this,function(s){return this._channel?(r=this._channel.codec.encodePullUserSetting(t),i=new X(D[D.pullUS],r,this.currentUserId),[2,this._channel.send(i,Si)]):[2,{code:N.RC_NET_CHANNEL_INVALID}]})})},e.prototype.getFileToken=function(t,r,i,s){return x(this,void 0,void 0,function(){var o,c,d,l,h,a;return B(this,function(u){switch(u.label){case 0:return this._channel?(o=s&&s!=="uploads"?r||"":Gl(t,r),c=this._channel.codec.encodeGetFileToken(t,o,i||"",s||""),d=new X(D[D.qnTkn],c,this.currentUserId),[4,this._channel.send(d,xo)]):[2,{code:N.RC_NET_CHANNEL_INVALID}];case 1:return l=u.sent(),h=l.code,a=l.data,a=Object.assign(a,{fileName:o}),h===N.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,c,d,l,h,a,u,f,p;return B(this,function(m){switch(m.label){case 0:return this._channel?(o="",c="",d="",r===We.QINIU?(c=Bo,d=Fo):(c=Vo,d=Ho),o=r===We.QINIU?D[D.qnUrl]:r===We.AWS?D[D.s3Url]:r===We.STC?D[D.stcUrl]:D[D.aliUrl],l=this._channel.codec.encodeGetFileUrl(c,t,i,s),h=new X(o,l,this.currentUserId),[4,this._channel.send(h,d)]):[2,{code:N.RC_NET_CHANNEL_INVALID}];case 1:return a=m.sent(),u=a.code,f=a.data,p=f,u===N.SUCCESS?[2,{code:u,data:p}]:[2,{code:u}]}})})},e.prototype.disconnect=function(){this._reconnectTimer!==-1&&(clearTimeout(this._reconnectTimer),this._reconnectTimer=-1),this._channel&&(this._channel.close(),this._channel=void 0),this._pullQueue.length=0,this._stopSyncInterval()},e.prototype.destroy=function(){throw new Error("JSEngine's method not implemented.")},e.prototype.registerMessageType=function(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,c,d,l;return B(this,function(h){switch(h.label){case 0:return this._channel?(r=this._userSettingManager.getVersion(),i=this._channel.codec.encodeCreateTag([t],r),s=new X(D[D.addSeTag],i,this.currentUserId),[4,this._channel.send(s,un)]):[2,{code:N.RC_NET_CHANNEL_INVALID}];case 1:return o=h.sent(),c=o.code,d=o.data,c!==N.SUCCESS?[2,{code:c}]:(l=d.version,this._userSettingManager.addTag([Ce(Ce({},t),{createdTime:l})],l),[2,{code:N.SUCCESS,data:d}])}})})},e.prototype.removeTag=function(t){return x(this,void 0,void 0,function(){var r,i,s,o,c,d,l;return B(this,function(h){switch(h.label){case 0:return this._channel?(r=this._userSettingManager.getVersion(),i=this._channel.codec.encodeRemoveTag([t],r),s=new X(D[D.delSeTag],i,this.currentUserId),[4,this._channel.send(s,un)]):[2,{code:N.RC_NET_CHANNEL_INVALID}];case 1:return o=h.sent(),c=o.code,d=o.data,c!==N.SUCCESS?[2,{code:c}]:(l=d.version,this._userSettingManager.deleteTag([t],l),[2,{code:N.SUCCESS}])}})})},e.prototype.updateTag=function(t){return x(this,void 0,void 0,function(){var r,i,s,o,c,d,l;return B(this,function(h){switch(h.label){case 0:return this._channel?(r=this._userSettingManager.getVersion(),i=this._channel.codec.encodeCreateTag([t],r),s=new X(D[D.addSeTag],i,this.currentUserId),[4,this._channel.send(s,un)]):[2,{code:N.RC_NET_CHANNEL_INVALID}];case 1:return o=h.sent(),c=o.code,d=o.data,c!==N.SUCCESS?[2,{code:c}]:(l=d.version,this._userSettingManager.addTag([t],l),[2,{code:N.SUCCESS,data:d}])}})})},e.prototype.getTagList=function(){return x(this,void 0,void 0,function(){var t,r;return B(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:N.SUCCESS,data:t}]})})},e.prototype.addTagForConversations=function(t,r){return x(this,void 0,void 0,function(){var i,s,o,c,d=this;return B(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 X(D[D.addTag],i,this.currentUserId),[4,this._channel.send(s)]):[2,{code:N.TAG_NOT_EXIST}]:[2,{code:N.RC_NET_CHANNEL_INVALID}];case 1:return(o=l.sent().code)!==N.SUCCESS?[2,{code:o}]:((c={})[t]={},r.forEach(function(h){d._conversationManager.addTagStatus(h.conversationType,h.targetId,c,h.channelId)}),[2,{code:N.SUCCESS}])}})})},e.prototype.removeTagForConversations=function(t,r){return x(this,void 0,void 0,function(){var i,s,o,c=this;return B(this,function(d){switch(d.label){case 0:return this._channel?(i=this._channel.codec.encodeUpdateConversationTag([{tagId:t}],r),s=new X(D[D.delTag],i,this.currentUserId),[4,this._channel.send(s)]):[2,{code:N.RC_NET_CHANNEL_INVALID}];case 1:return(o=d.sent().code)!==N.SUCCESS?[2,{code:o}]:(r.forEach(function(l){c._conversationManager.deleteTagStatus(l.conversationType,l.targetId,[t],l.channelId)}),[2,{code:N.SUCCESS}])}})})},e.prototype.removeTagsForConversation=function(t,r){return x(this,void 0,void 0,function(){var i,s,o,c,d,l,h;return B(this,function(a){switch(a.label){case 0:return this._channel?(i=t.conversationType,s=t.targetId,o=t.channelId,c=r.map(function(u){return{tagId:u}}),d=this._channel.codec.encodeUpdateConversationTag(c,[t]),l=new X(D[D.delTag],d,this.currentUserId),[4,this._channel.send(l)]):[2,{code:N.RC_NET_CHANNEL_INVALID}];case 1:return(h=a.sent().code)!==N.SUCCESS?[2,{code:h}]:(this._conversationManager.deleteTagStatus(i,s,r,o),[2,{code:N.SUCCESS}])}})})},e.prototype.getConversationListByTag=function(t,r,i){return x(this,void 0,void 0,function(){var s,o,c,d,l,h,a,u,f;return B(this,function(p){switch(p.label){case 0:return o=(s=this).currentUserId,(c=s._channel)?(d=c.codec.encodeOldConversationList({count:i,type:Q.PRIVATE,startTime:r}),l=new X(Ya,d,o),[4,c.send(l,Qn,{currentUserId:o,connectedTime:c.connectedTime})]):[2,{code:N.RC_NET_CHANNEL_INVALID}];case 1:return h=p.sent(),a=h.code,u=h.data,f=this._conversationHasTagFilter(t,u),K.info("GetConversationListByTag",f),a!==N.SUCCESS?[2,{code:a}]:[2,{code:a,data:f}]}})})},e.prototype._conversationHasTagFilter=function(t,r){var i=this,s=[],o=[];function c(d,l){return d.latestMessage&&l.latestMessage?d.latestMessage.sentTime-l.latestMessage.sentTime:0}return r.forEach(function(d){var l=d.conversationType,h=d.targetId,a=d.channelId,u=i._conversationManager.get(l,h,a),f=u.hasMentioned,p=u.mentionedInfo,m=u.lastUnreadTime,_=u.notificationStatus,v=u.isTop,y=u.tags,C=u.unreadMessageCount,b=y&&y[t];if(b){var O=Ce(Ce({},d),{hasMentioned:f,mentionedInfo:p,lastUnreadTime:m,notificationStatus:_,isTop:v,unreadMessageCount:C});b.isTop?s.push(Ce(Ce({},O),{isTopInTag:!0})):o.push(Ce(Ce({},O),{isTopInTag:!1}))}}),Gt(Gt([],s.sort(c)),o.sort(c))},e.prototype.getUnreadCountByTag=function(t,r){return x(this,void 0,void 0,function(){var i;return B(this,function(s){return this._channel?(i=this._conversationManager.getUnreadCountByTag(t,r),[2,{code:N.SUCCESS,data:i}]):[2,{code:N.RC_NET_CHANNEL_INVALID}]})})},e.prototype.setConversationStatusInTag=function(t,r,i){return x(this,void 0,void 0,function(){var s,o,c,d,l,h,a,u,f,p;return B(this,function(m){switch(m.label){case 0:return this._channel?(s=r.targetId,o=r.conversationType,c=r.channelId,d=i.isTop,l=[{tagId:t,isTop:d}],(h=this._conversationManager.get(o,s,c)).tags&&Object.hasOwnProperty.call(h.tags,t)?(a=this._channel.codec.encodeUpdateConversationTag(l,[r]),u=new X(D[D.addTag],a,this.currentUserId),[4,this._channel.send(u)]):[2,{code:N.NO_TAG_IN_CONVER}]):[2,{code:N.RC_NET_CHANNEL_INVALID}];case 1:return(f=m.sent().code)!==N.SUCCESS?[2,{code:f}]:((p={})[t]={},d&&(p[t].isTop=!0),this._conversationManager.addTagStatus(o,s,p,c),[2,{code:N.SUCCESS}])}})})},e.prototype.getTagsForConversation=function(t){var r;return x(this,void 0,void 0,function(){var i,s,o,c;return B(this,function(d){if(!this._channel)return[2,{code:N.RC_NET_CHANNEL_INVALID}];if(i=this._conversationManager.get(t.conversationType,t.targetId,t.channelId),s=this._userSettingManager.getTagsInfo(),o=[],i.tags)for(c in i.tags)o.push({tagId:c,tagName:(r=s[c])===null||r===void 0?void 0:r.tagName});return[2,{code:N.SUCCESS,data:o}]})})},e.prototype.getBlockConversationList=function(){var t=this._conversationManager.getBlockConversationList();return Promise.resolve({code:N.SUCCESS,data:t})},e.prototype.getTopConversationList=function(){var t=this._conversationManager.getTopConversationList();return Promise.resolve({code:N.SUCCESS,data:t})},e.prototype.getUnreadMentionedCount=function(t){var r=this._conversationManager.getUnreadMentionedCount(t.channelId,t.conversationType,t.targetId);return Promise.resolve({code:N.SUCCESS,data:r})},e.prototype.getAllUnreadMentionedCount=function(){var t=this._conversationManager.getAllUnreadMentionedCount();return Promise.resolve({code:N.SUCCESS,data:t})},e.prototype.joinRTCRoom=function(t,r,i,s){return x(this,void 0,void 0,function(){var o,c;return B(this,function(d){return this._channel?(o=this._channel.codec.encodeJoinRTCRoom(r,i,s),c=new X(D[D.rtcRJoin_data],o,t),[2,this._channel.send(c,qt)]):[2,{code:N.RC_NET_CHANNEL_INVALID}]})})},e.prototype.quitRTCRoom=function(t){return x(this,void 0,void 0,function(){var r,i;return B(this,function(s){switch(s.label){case 0:return this._channel?(r=this._channel.codec.encodeQuitRTCRoom(),i=new X(D[D.rtcRExit],r,t),[4,this._channel.send(i)]):[2,N.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 B(this,function(c){switch(c.label){case 0:return this._channel?(s=this._channel.codec.encodeJoinRTCRoom(r,i),o=new X(D[D.rtcPing],s,t),[4,this._channel.send(o)]):[2,N.RC_NET_CHANNEL_INVALID];case 1:return[2,c.sent().code]}})})},e.prototype.getRTCRoomInfo=function(t){return x(this,void 0,void 0,function(){var r,i;return B(this,function(s){return this._channel?(r=this._channel.codec.encodeGetRTCRoomInfo(),i=new X(D[D.rtcRInfo],r,t),[2,this._channel.send(i,yu)]):[2,{code:N.RC_NET_CHANNEL_INVALID}]})})},e.prototype.getRTCUserInfoList=function(t){return x(this,void 0,void 0,function(){var r,i,s,o,c;return B(this,function(d){switch(d.label){case 0:return this._channel?(r=this._channel.codec.encodeGetRTCRoomInfo(),i=new X(D[D.rtcUData],r,t),[4,this._channel.send(i,qt)]):[2,{code:N.RC_NET_CHANNEL_INVALID}];case 1:return s=d.sent(),o=s.code,c=s.data,[2,{code:o,data:c&&{users:c.users}}]}})})},e.prototype.setRTCUserInfo=function(t,r,i){return x(this,void 0,void 0,function(){var s,o;return B(this,function(c){switch(c.label){case 0:return this._channel?(s=this._channel.codec.encodeSetRTCUserInfo(r,i),o=new X(D[D.rtcUPut],s,t),[4,this._channel.send(o)]):[2,N.RC_NET_CHANNEL_INVALID];case 1:return[2,c.sent().code]}})})},e.prototype.removeRTCUserInfo=function(t,r){return x(this,void 0,void 0,function(){var i,s;return B(this,function(o){switch(o.label){case 0:return this._channel?(i=this._channel.codec.encodeRemoveRTCUserInfo(r),s=new On(D[D.rtcUDel],i,t),[4,this._channel.send(s)]):[2,N.RC_NET_CHANNEL_INVALID];case 1:return[2,o.sent().code]}})})},e.prototype.setRTCData=function(t,r,i,s,o,c){return x(this,void 0,void 0,function(){var d,l;return B(this,function(h){switch(h.label){case 0:return this._channel?(d=this._channel.codec.encodeSetRTCData(r,i,s,o,c),l=new On(D[D.rtcSetData],d,t),[4,this._channel.send(l)]):[2,N.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 c,d;return B(this,function(l){switch(l.label){case 0:return this._channel?(c=this._channel.codec.encodeUserSetRTCData(r,i,s,o),d=new X(D[D.userSetData],c,t),[4,this._channel.send(d)]):[2,N.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 B(this,function(c){switch(c.label){case 0:return this._channel?(s=this._channel.codec.encodeUserSetRTCCDNUris(r,i),o=new X(D[D.userSetData],s,t),[4,this._channel.send(o)]):[2,N.RC_NET_CHANNEL_INVALID];case 1:return[2,c.sent().code]}})})},e.prototype.getRTCData=function(t,r,i,s){if(!this._channel)return Promise.resolve({code:N.RC_NET_CHANNEL_INVALID});var o=this._channel.codec.encodeGetRTCData(r,i,s),c=new X(D[D.rtcQryData],o,t);return this._channel.send(c,Ti)},e.prototype.removeRTCData=function(t,r,i,s,o){return x(this,void 0,void 0,function(){var c,d;return B(this,function(l){switch(l.label){case 0:return this._channel?(c=this._channel.codec.encodeRemoveRTCData(r,i,s,o),d=new On(D[D.rtcDelData],c,t),[4,this._channel.send(d)]):[2,N.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 B(this,function(c){return this._channel?(s=this._channel.codec.encodeJoinRTCRoom(r,i),o=new X(D[D.rtcToken],s,t),[2,this._channel.send(o,Ri)]):[2,{code:N.RC_NET_CHANNEL_INVALID}]})})},e.prototype.setRTCState=function(t,r){return x(this,void 0,void 0,function(){var i,s;return B(this,function(o){switch(o.label){case 0:return this._channel?(i=this._channel.codec.encodeSetRTCState(r),s=new X(D[D.rtcUserState],i,t),[4,this._channel.send(s)]):[2,N.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 B(this,function(r){throw new Error("Method not implemented.")})})},e.prototype.getRTCUserList=function(t){if(!this._channel)return Promise.resolve({code:N.RC_NET_CHANNEL_INVALID});var r=this._channel.codec.encodeGetRTCRoomInfo(),i=new X(D[D.rtcUList],r,t);return this._channel.send(i,qt)},e.prototype.joinLivingRoomAsAudience=function(t,r,i){return r===void 0&&(r=Ye.LIVE),x(this,void 0,void 0,function(){var s,o,c,d,l,h,a,u;return B(this,function(f){switch(f.label){case 0:return this._channel?(s=this._channel.codec.encodeJoinRTCRoom(r,i),o=new X(D[D.viewerJoinR],s,t),[4,this._channel.send(o,bu)]):[2,{code:N.RC_NET_CHANNEL_INVALID}];case 1:return c=f.sent(),d=c.code,l=c.data,d!==N.SUCCESS?[2,{code:d}]:(a=(h=l).rtcToken,u=h.entries,[2,{code:d,data:{token:a,kvEntries:u}}])}})})},e.prototype.quitLivingRoomAsAudience=function(t){return x(this,void 0,void 0,function(){var r,i,s;return B(this,function(o){switch(o.label){case 0:return this._channel?(r=this._channel.codec.encodeQuitRTCRoom(),i=new X(D[D.viewerExitR],r,t),[4,this._channel.send(i)]):[2,N.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,c,d,l;return B(this,function(h){switch(h.label){case 0:return this._channel?(s=this._channel.codec.encodeIdentityChangeInfo(r,i),o=new X(D[D.rtcIdentityChange],s,t),[4,this._channel.send(o,qt)]):[2,{code:N.RC_NET_CHANNEL_INVALID}];case 1:return c=h.sent(),d=c.code,l=c.data,d!==N.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,c,d,l,h,a,u;return B(this,function(f){switch(f.label){case 0:return s=(i=this)._channel,o=i.currentUserId,s?(K.info("audience in room start pull KV"),c=s.codec.encodePullRTCRoomKV(t,0),d=new X(D[D.rtcPullKv],c,o),[4,s.send(d,Ni)]):[2,{code:N.RC_NET_CHANNEL_INVALID}];case 1:return l=f.sent(),h=l.code,a=l.data,K.info("audience in room end pull KV, code: "+h+", data: "+JSON.stringify(a||{})),h===N.SUCCESS?(u=a.kvEntries,this._watcher.onRTCDataChange(u,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,c,d,l,h;return B(this,function(a){switch(a.label){case 0:return i=(r=this)._channel,s=r.currentUserId,i?(o=i.codec.encodeQueryUserJoinedInfo(t),c=new X(D[D.rtcQueryJoined],o,s),[4,i.send(c,Oi)]):[2,{code:N.RC_NET_CHANNEL_INVALID}];case 1:return d=a.sent(),l=d.code,h=d.data,l===N.SUCCESS?[2,{code:l,data:h}]:[2,{code:l}]}})})},e.prototype.getDeviceId=function(){return Hu(this.runtime)},e.prototype.requestRoomPK=function(t){return x(this,void 0,void 0,function(){var r,i,s;return B(this,function(o){switch(o.label){case 0:return this._channel?(r=this._channel.codec.encodeRequestRoomPK(t),i=new X(D[D.rtcInvite],r,t.roomId),[4,this._channel.send(i)]):[2,N.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 B(this,function(o){switch(o.label){case 0:return this._channel?(r=this._channel.codec.encodeCancelRoomPK(t),i=new X(D[D.rtcCancelInvite],r,t.roomId),[4,this._channel.send(i)]):[2,N.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 B(this,function(o){switch(o.label){case 0:return this._channel?(r=this._channel.codec.encodeResponseRoomPK(t),i=new X(D[D.rtcInviteAnswer],r,t.roomId),[4,this._channel.send(i)]):[2,N.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 B(this,function(o){switch(o.label){case 0:return this._channel?(r=this._channel.codec.encodeEndRoomPK(t),i=new X(D[D.rtcEndInvite],r,t.roomId),[4,this._channel.send(i)]):[2,N.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;i<arguments.length;i++)r[i-1]=arguments[i];return Promise.resolve({code:N.EXTRA_METHOD_UNDEFINED})},e.prototype.getConversationListWithAllChannel=function(){throw new Error("Method not implemented.")},e.prototype.getConversationListWithAllChannelByPage=function(t,r){throw new Error("Method not implemented.")},e.prototype.clearConversations=function(){throw new Error("Method not implemented.")},e.prototype.setUserStatusListener=function(t,r){throw new Error("Method not implemented.")},e.prototype.setUserStatus=function(t){throw new Error("Method not implemented.")},e.prototype.subscribeUserStatus=function(t){throw new Error("Method not implemented.")},e.prototype.getUserStatus=function(t){throw new Error("Method not implemented.")},e.prototype.addToBlacklist=function(t){throw new Error("Method not implemented.")},e.prototype.removeFromBlacklist=function(t){throw new Error("Method not implemented.")},e.prototype.getBlacklist=function(){throw new Error("Method not implemented.")},e.prototype.getBlacklistStatus=function(t){throw new Error("Method not implemented.")},e.prototype.insertMessage=function(t,r,i){throw new Error("Method not implemented.")},e.prototype.deleteMessages=function(t){throw new Error("Method not implemented.")},e.prototype.deleteMessagesByTimestamp=function(t,r,i,s,o){throw new Error("Method not implemented.")},e.prototype.clearMessages=function(t,r,i){throw new Error("Method not implemented.")},e.prototype.getMessage=function(t){throw new Error("Method not implemented.")},e.prototype.setMessageContent=function(t,r,i){throw new Error("Method not implemented.")},e.prototype.setMessageSearchField=function(t,r,i){throw new Error("Method not implemented.")},e.prototype.searchConversationByContent=function(t,r,i,s){throw new Error("Method not implemented.")},e.prototype.searchMessageByContent=function(t,r,i,s,o,c){throw new Error("Method not implemented.")},e.prototype.getUnreadMentionedMessages=function(t,r){throw new Error("Method not implemented.")},e.prototype.setMessageSentStatus=function(t,r){throw new Error("Method not implemented.")},e.prototype.setMessageReceivedStatus=function(t,r){throw new Error("Method not implemented.")},e.prototype.clearUnreadCountByTimestamp=function(t,r,i,s){throw new Error("Method not implemented.")},e.prototype.getConversationNotificationStatus=function(t,r,i){var s=this._conversationManager.get(t,r,i);return s?Promise.resolve({code:N.SUCCESS,data:s.notificationStatus}):Promise.resolve({code:N.CONVER_GET_ERROR})},e.prototype.getRemoteHistoryMessages=function(t,r,i,s,o,c){return this.getHistoryMessage(t,r,i,s,o,c)},e}(Ih),$u=function(){function n(e){this._context=e}return n.prototype.getCoreVersion=function(){return this._context.coreVersion},n.prototype.getAPIVersion=function(){return this._context.apiVersion},n.prototype.getAppkey=function(){return this._context.appkey},n.prototype.getCurrentId=function(){return this._context.getCurrentUserId()},n.prototype.getConnectionStatus=function(){return this._context.getConnectionStatus()},n.prototype.getDeviceId=function(){return this._context.getDeviceId()},n.prototype.sendMessage=function(e,t,r){return this._context.sendMessage(e,t,r)},n.prototype.registerMessageType=function(e,t,r,i){i===void 0&&(i=[]),this._context.registerMessageType(e,t,r,i)},n.prototype.getServerTime=function(){return this._context.getServerTime()},n.prototype.getRTCJoinedUserInfo=function(e){return this._context.getRTCJoinedUserInfo(e)},n}(),$h=function(n){function e(){return n!==null&&n.apply(this,arguments)||this}return we(e,n),e.prototype.getNaviInfo=function(){return this._context.getInfoFromCache()},e.prototype.joinRTCRoom=function(t,r,i,s){return this._context.joinRTCRoom(t,r,i,s)},e.prototype.quitRTCRoom=function(t){return this._context.quitRTCRoom(t)},e.prototype.rtcPing=function(t,r,i){return this._context.rtcPing(t,r,i)},e.prototype.getRTCRoomInfo=function(t){return this._context.getRTCRoomInfo(t)},e.prototype.getRTCUserInfoList=function(t){return this._context.getRTCUserInfoList(t)},e.prototype.getRTCUserInfo=function(t){return this._context.getRTCUserInfo(t)},e.prototype.setRTCUserInfo=function(t,r,i){return this._context.setRTCUserInfo(t,r,i)},e.prototype.removeRTCUserInfo=function(t,r){return this._context.removeRTCUserInfo(t,r)},e.prototype.setRTCData=function(t,r,i,s,o,c){return this._context.setRTCData(t,r,i,s,o,c)},e.prototype.setRTCTotalRes=function(t,r,i,s,o){return this._context.setRTCTotalRes(t,r,i,s,o)},e.prototype.setRTCCDNUris=function(t,r,i){return this._context.setRTCCDNUris(t,r,i)},e.prototype.getRTCData=function(t,r,i,s){return this._context.getRTCData(t,r,i,s)},e.prototype.removeRTCData=function(t,r,i,s,o){return this._context.removeRTCData(t,r,i,s,o)},e.prototype.setRTCOutData=function(t,r,i,s){return this._context.setRTCOutData(t,r,i,s)},e.prototype.getRTCOutData=function(t,r){return this._context.getRTCOutData(t,r)},e.prototype.getRTCToken=function(t,r,i){return this._context.getRTCToken(t,r,i)},e.prototype.setRTCState=function(t,r){return this._context.setRTCState(t,r)},e.prototype.getRTCUserList=function(t){return this._context.getRTCUserList(t)},e.prototype.joinLivingRoomAsAudience=function(t,r,i){return this._context.joinLivingRoomAsAudience(t,r,i)},e.prototype.quitLivingRoomAsAudience=function(t){return this._context.quitLivingRoomAsAudience(t)},e.prototype.rtcIdentityChange=function(t,r,i){return this._context.rtcIdentityChange(t,r,i)},e.prototype.requestRoomPK=function(t){return this._context.requestRoomPK(t)},e.prototype.cancelRoomPK=function(t){return this._context.cancelRoomPK(t)},e.prototype.responseRoomPK=function(t){return this._context.responseRoomPK(t)},e.prototype.endRoomPK=function(t){return this._context.endRoomPK(t)},e}($u),tc=function(){function n(){}return n.compress=function(e){for(var t=this,r={},i=0;i<e.length-1;i++){var s=e.charAt(i)+e.charAt(i+1);r.hasOwnProperty(s)?r[s].push(i):r[s]=[i]}for(var o=[],c=[],d=function(){if(c.length>0){var _=c.join("");if(c=[],_.length>26){var v=t.numberEncode(_.length),y=String.fromCharCode(t.dataType.NormalExt|v.length);o.push(y+v)}else{var C=String.fromCharCode(t.dataType.Normal|_.length);o.push(C)}o.push(_)}},l=0;l<e.length;){var h=t.indexOf(r,e,l);if(h.length<2)c.push(e.charAt(l++));else if(h.length<4)c.push(e.substr(l,h.length)),l+=h.length;else{var a=t.numberEncode(l-h.offset),u=t.numberEncode(h.length);if(a.length+u.length>=h.length)c.push(e.substr(l,h.length)),l+=h.length;else{d();var f=String.fromCharCode(t.dataType.Compressed|a.length<<2|u.length);o.push(f+a+u),l+=h.length}}}d();var p=t.numberEncode(e.length),m=String.fromCharCode(t.dataType.Tail|p.length);return o.push(m+p),o.join("")},n.uncompress=function(e){var t=this,r=0,i="";e:do{var s=e.charCodeAt(r++),o=s&t.dataType.Mark,c=15&s,d=void 0;switch(o){case t.dataType.Compressed:var l=c>>2,h=3&c;if(l===0||h===0)throw new Error("Data parsing error,at "+r);var a=t.numberDecode(e.substr(r,l)),u=t.numberDecode(e.substr(r+=l,h));if((a=i.length-a)+u>i.length)throw new Error("Data parsing error,at "+r);r+=h,i+=i.substr(a,u);break;case t.dataType.Tail:if((d=t.numberDecode(e.substr(r,c)))!==i.length)throw console.log(i.length),console.log(d),new Error("Data parsing error,at "+r);r+=c;break e;case t.dataType.NormalExt:d=t.numberDecode(e.substr(r,c)),i+=e.substr(r+=c,d),r+=d;break;case t.dataType.Normal:i+=e.substr(r,c),r+=c;break;case t.dataType.Mark:if(c>10)throw new Error("Data parsing error,at "+r);i+=e.substr(r,16+c),r+=16+c;break;default:throw new Error("Data parsing error,at "+r+" header:"+o)}}while(r<e.length);return i},n.indexOf=function(e,t,r){var i={length:0,offset:-1};if(t.length,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,c=0,d=s.length;c<d;c++){var l=s[c],h=r-l;if(!(h>this.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 u=2,f=u;f<a&&t.charAt(l+f)===t.charAt(r+f);f++)u++;u>=i.length&&(i.length=u,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,Pn=!1,nc=typeof location!="undefined"&&location.protocol==="https://"?"https://":"http://",yr=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=Hu(e.runtime),this.logSwitch=e.logSwitch;var t=zl(e.runtime);this.deviceInfo=t.type+"|"+t.version+"|"+Dt.sessionId,this.startReport()}return n.init=function(e){return Pn=!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&&Pn){var t=this.itv*Math.pow(2,Mn-1);Mn<this.times&&Mn++,setTimeout(function(){e.reportRealtimeLog()},1e3*t)}},n.prototype.reportRealtimeLog=function(){var e=this,t=Dt.realTimeLogList.filter(function(s){return s.level<=e.level});if(t.length!==0){var r=tc.compress(t.map(function(s){return s.content}).join("")),i=""+nc+this.logUrl+"?version="+this.info.version+"&appkey="+this.info.appkey+"&userId="+this.info.userId+"&deviceId="+this.deviceId+"&deviceInfo="+this.deviceInfo+"&platform=Web";this.info.runtime.httpReq({method:"POST",url:i,body:r}).then(function(s){K.__clearRealTimeLog(),K.debug("report real-time log success");var o=s.data;o&&(o=JSON.parse(o),e.itv=o.nextTime,e.level=o.level,e.logSwitch=o.logSwitch,Mn=1),e.startReport()}).catch(function(s){K.debug("report real-time log error -> "+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,c,d,l,h,a,u=this;return B(this,function(f){switch(f.label){case 0:return t=e.startTime,r=e.endTime,i=e.platform,s=e.logId,o=e.uri,c=ho.getInstance(),K.debug("received report log msg, "+i.toLowerCase(),c),i.toLowerCase()==="web"&&c?t>r?(K.warn("report error: The start time("+t+") cannot be greater than the end time("+t+")"),[2]):[4,K.__insertLogIntoDatabase()]:[2];case 1:return f.sent(),[4,c.getRangeData(an,"time",t,r)];case 2:return d=(d=f.sent()).filter(function(p){return!p.userId||p.userId===u.info.userId}),l=tc.compress(d.map(function(p){return p.content}).join("")||"no data"),h=1,(a=function(){if(!(h>3)&&Pn){var p=o||u.logUrl,m=""+nc+p+"?version="+u.info.version+"&appkey="+u.info.appkey+"&userId="+u.info.userId+"&logId="+s+"&deviceId="+u.deviceId+"&deviceInfo="+u.deviceInfo+"&platform=Web",_=5e3*(h-1);h++,setTimeout(function(){Pn&&u.info.runtime.httpReq({url:m,method:"POST",body:l}).then(function(){K.debug("report full log success!")}).catch(function(v){a(),K.warn("report full log error -> "+v)})},_)}})(),[2]}})})},n.prototype.distroy=function(){Mn=1,Pn=!1},n}();function Cr(n){return Object.assign({},n)}var rc,jh=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=re.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,Dl);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=$a()?new RCCppEngine(e,i,this._options):new Hh(e,i,this._options)}return n.init=function(e,t){return K.setLogLevel(t.logLevel),K.setLogStdout(t.logStdout),(t.indexDBSwitch||ge(t.indexDBSwitch))&&ho.init(),K.debug("APIContext.init =>",t.appkey,t.navigators),this._context?(K.error("Repeat initialize!"),this._context):(K.warn("RCEngine Commit:","41dbe38d1b376ca0a791b23ed94be291e3f92e81"),this._context=new n(e,t),K.__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 K.warn("Repeat install plugin: "+e.tag),this._pluginInstanseMap[e.tag];var r=e.tag==="RCRTC"?new $h(this):new $u(this),i=null;try{if(!e.verify(this._runtime))return null;i=e.setup(r,this._runtime,t)}catch(s){K.error(`install plugin error!
  796. `,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 B(this,function(t){switch(t.label){case 0:return K.debug("_handleRedirct",this._token),[4,this.connect(this._token,!0)];case 1:return t.sent().code!==N.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 B(this,function(r){return e===re.REDIRECT?(this._canRedirectConnect=!0,this._handleSuspend(),this._handleRedirect()):e===re.BLOCKED||e===re.KICKED_OFFLINE_BY_OTHER_CLIENT||e===re.DISCONNECT_BY_SERVER?(this._canRedirectConnect=!1,this._handleDisconnect()):e===re.CONNECTING?this._handleConnecting():e===re.CONNECTED?this._handleConnected():e===re.DISCONNECTED?this._handleDisconnect():e===re.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===Q.RTC_ROOM||Object.prototype.hasOwnProperty.call(jl,e.messageType))&&this._watcher.rtcInnerWatcher&&this._watcher.rtcInnerWatcher.message)this._watcher.rtcInnerWatcher.message(Cr(e));else if(["RC:ChrmJoinNtf","RC:ChrmQuitNtf"].indexOf(e.messageType)===-1||typeof this._watcher.chatroomState!="function"){if(e.messageType!=="RC:ChrmMemChange"){if(e.messageType!==qe.TYPING_STATUS||(this._addTypingInfo(Cr(e)),!this._watcher.typingState))if(e.messageType!==qe.LOG_COMMAND||e.senderUserId!=="rongcloudsystem")if(e.messageType!==qe.INTERCEPT){if(!this._pluginContextQueue.some(function(v){if(!v.onmessage)return!1;try{return v.onmessage(Cr(e))}catch(y){return K.error("plugin error =>",y),!1}}))if(e.messageType!=="RC:ReadNtf")if(e.messageType!=="RC:RRReqMsg"){if(e.messageType!=="RC:RRRspMsg")return this._watcher.message&&this._watcher.message(Cr(e),t,r),e;var c=(o=e.content)===null||o===void 0?void 0:o.receiptMessageDic;c&&Array.isArray(c[this._engine.currentUserId])&&typeof this._watcher.messageReceiptResponse=="function"&&this._watcher.messageReceiptResponse({conversationType:e.conversationType,targetId:e.targetId,channelId:e.channelId},e.senderUserId,c[this._engine.currentUserId])}else typeof this._watcher.messageReceiptRequest=="function"&&this._watcher.messageReceiptRequest({conversationType:e.conversationType,targetId:e.targetId,channelId:e.channelId},e.content.messageUId,e.senderUserId);else typeof this._watcher.readReceiptReceived=="function"&&this._watcher.readReceiptReceived({conversationType:e.conversationType,targetId:e.targetId,channelId:e.channelId},e.content.messageUId,e.content.lastMessageSendTime)}else this._MessageBlockedListener({conversationType:e.conversationType,targetId:e.targetId,channelId:e.channelId||"",blockType:e.content.interceptType,blockedMessageUId:e.content.msgUId});else{var d=e.content,l=d.startTime,h=d.endTime,a=d.platform,u=d.logId,f=d.uri,p=d.packageName,m={startTime:parseInt(l),endTime:parseInt(h),platform:a,logId:u,uri:f,packageName:p};(s=yr.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"?Ba.QUIT:Ba.JOIN,i),chatroomId:e.targetId}})},n.prototype._batchMessageReceiver=function(e,t,r){var i=this,s=[];e.forEach(function(o){var c=i._messageReceiver(o,t,r);c&&s.push(c)}),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]=Gr(i)||He(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,c=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===c?this._typingInfo[d][l].timestamp=Date.now():(l>=0&&this._typingInfo[d].splice(l,1),this._typingInfo[d].push({userId:t,messageType:c,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.timestamp<e._typingExpireTime}),e._typingInfo[t].length===r||e._typingChangedList.includes(t)||e._typingChangedList.push(t),e._typingInfo[t].length===0&&delete e._typingInfo[t]}if(e._typingChangedList.length>0){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,c,d;return B(this,function(l){switch(l.label){case 0:return this._connectionStatus===re.CONNECTED?[2,{code:N.SUCCESS,userId:this._engine.currentUserId}]:this._connectionStatus===re.CONNECTING?[2,{code:N.BIZ_ERROR_CONNECTING}]:typeof e!="string"||e.length===0?[2,{code:N.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:N.PACKAGE_ENVIRONMENT_ERROR}]:(c=Yt.getInfo(),[4,this._engine.connect(this._getTokenWithoutNavi(),o)]):[2,{code:N.RC_NAVI_RESOURCE_ERROR}];case 2:return d=l.sent(),K.__insertLogIntoDatabase(),d!==je.REDIRECT?[3,4]:(this._connectionStatus=re.REDIRECT,[4,this.connect(e,!0)]);case 3:return[2,l.sent()];case 4:return d===N.SUCCESS&&(K.info("connect success, userId: "+this._engine.currentUserId),(o==null?void 0:o.type)!==1&&this._engine.reportSDKInfo&&this._engine.reportSDKInfo(c),yr.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}),Dt.init(this._engine.currentUserId),this._isInternalConnected=!0),d!==N.SUCCESS||$a()||o.openUS===1&&this._pullUserSettings(),d!==N.SUCCESS&&(this._connectionStatus=re.CONNECTION_CLOSED),[2,{code:d,userId:this._engine.currentUserId}]}})})},n.prototype._pullUserSettings=function(){return x(this,void 0,void 0,function(){return B(this,function(e){return[2]})})},n.prototype.disconnect=function(){var e;return this._isInternalConnected=!1,clearInterval(this._typingInternalTimer),this._typingInternalTimer=-1,(e=yr.getInstance())===null||e===void 0||e.distroy(),K.__insertLogIntoDatabase(),Dt.reset(),this._engine.disconnect(),this._pluginContextQueue.forEach(function(t){if(t.ondisconnect)try{t.ondisconnect()}catch(r){K.error("plugin error =>",r)}}),Promise.resolve()},n.prototype.reconnect=function(){return this._isInternalConnected?Promise.resolve({code:N.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===qe.READ_RECEIPT_RESPONSE)return Promise.resolve({code:N.READ_RECEIPT_ERROR});var o=JSON.stringify(r.content);return lu(o)>131072?Promise.resolve({code:N.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,c,d,l,h,a,u,f,p,m;return B(this,function(_){switch(_.label){case 0:if(t=e.channelId,r=e.conversationType,i=e.targetId,s=e.messageUId,o=e.keys,c=e.expansion,d=e.removeAll,!e.canIncludeExpansion)return[2,{code:N.MESSAGE_KV_NOT_SUPPORT}];if(l=!1,h=!1,a=!1,He(c)){for(f in u=Object.keys(c).length,l=u>20,c)if(p=c[f],h=et(f)&&!/^[A-Za-z0-9_=+-]+$/.test(f),(a=f.length>32||p.length>64)||h)break}return l||a?[2,{code:N.EXPANSION_LIMIT_EXCEET}]:h?[2,{code:N.BIZ_ERROR_INVALID_PARAMETER}]:(m={mid:s},c&&(m.put=c),o&&(m.del=o),d&&(m.removeAll=1),[4,this._engine.sendMessage(r,i,{content:m,messageType:qe.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 B(this,function(s){return i=this.getInfoFromCache(),((i==null?void 0:i.grpRRVer)||0)===0?[2,{code:N.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 B(this,function(s){return i=this.getInfoFromCache(),((i==null?void 0:i.grpRRVer)||0)===0?[2,{code:N.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){K.error("plugin error =>",r)}}),this._pluginContextQueue.length=0,this._pluginInstanseMap={},(e=yr.getInstance())===null||e===void 0||e.distroy(),Dt.reset()},n.prototype.getHistoryMessage=function(e,t,r,i,s,o,c){return r===void 0&&(r=0),i===void 0&&(i=20),s===void 0&&(s=0),o===void 0&&(o=""),c===void 0&&(c=""),this._engine.getHistoryMessage(e,t,r,i,s,o,c||"")},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:[Q.PRIVATE,Q.GROUP,Q.SYSTEM,Q.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 en(r)&&Yi(i)?this._engine.setChatroomEntry(e,t):Promise.resolve(N.BIZ_ERROR_INVALID_PARAMETER)},n.prototype.setChatroomEntries=function(e,t){for(var r=0;r<t.entries.length;r++){var i=t.entries[r],s=i.key,o=i.value;if(!en(s)||!Yi(o))return Promise.resolve({code:N.BIZ_ERROR_INVALID_PARAMETER})}return this._engine.setChatroomEntries(e,t)},n.prototype.forceSetChatroomEntry=function(e,t){var r=t.key,i=t.value;return en(r)&&Yi(i)?this._engine.forceSetChatroomEntry(e,t):Promise.resolve(N.BIZ_ERROR_INVALID_PARAMETER)},n.prototype.removeChatroomEntry=function(e,t){var r=t.key;return en(r)?this._engine.removeChatroomEntry(e,t):Promise.resolve(N.BIZ_ERROR_INVALID_PARAMETER)},n.prototype.removeChatroomEntries=function(e,t){for(var r=0;r<t.entries.length;r++){var i=t.entries[r].key;if(!en(i))return Promise.resolve({code:N.BIZ_ERROR_INVALID_PARAMETER})}return this._engine.removeChatroomEntries(e,t)},n.prototype.forceRemoveChatroomEntry=function(e,t){var r=t.key;return en(r)?this._engine.forceRemoveChatroomEntry(e,t):Promise.resolve(N.BIZ_ERROR_INVALID_PARAMETER)},n.prototype.getChatroomEntry=function(e,t){return this._engine.getChatroomEntry(e,t)},n.prototype.getAllChatroomEntries=function(e){return this._engine.getAllChatroomEntry(e)},n.prototype.getChatroomHistoryMessages=function(e,t,r,i){return t===void 0&&(t=20),r===void 0&&(r=0),i===void 0&&(i=0),this._engine.getChatroomHistoryMessages(e,i,t,r)},n.prototype.getFileToken=function(e,t,r,i){return x(this,void 0,void 0,function(){var s,o,c,d,l,h,a;return B(this,function(u){switch(u.label){case 0:return s=this.getInfoFromCache(),o=(s==null?void 0:s.bosAddr)||"",c=(s==null?void 0:s.uploadServer)||"",d=(s==null?void 0:s.ossConfig)||"",[4,this._engine.getFileToken(e,t,r,i)];case 1:return l=u.sent(),h=l.code,a=l.data,h===N.SUCCESS?[2,Promise.resolve(Object.assign(a,{bos:o,qiniu:c,ossConfig:d}))]:[2,Promise.reject(h)]}})})},n.prototype.getFileUrl=function(e,t,r,i,s){return s===void 0&&(s=We.QINIU),x(this,void 0,void 0,function(){var o,c,d;return B(this,function(l){switch(l.label){case 0:return(i==null?void 0:i.isBosRes)?[2,Promise.resolve(i)]:[4,this._engine.getFileUrl(e,s,t,r)];case 1:return o=l.sent(),c=o.code,d=o.data,c===N.SUCCESS?[2,Promise.resolve(d)]:[2,Promise.reject(c)]}})})},n.prototype.createTag=function(e){return x(this,void 0,void 0,function(){return B(this,function(t){return[2,this._engine.createTag(e)]})})},n.prototype.removeTag=function(e){return x(this,void 0,void 0,function(){return B(this,function(t){return[2,this._engine.removeTag(e)]})})},n.prototype.updateTag=function(e){return x(this,void 0,void 0,function(){return B(this,function(t){return[2,this._engine.updateTag(e)]})})},n.prototype.getTagList=function(){return x(this,void 0,void 0,function(){return B(this,function(e){return[2,this._engine.getTagList()]})})},n.prototype.addTagForConversations=function(e,t){return x(this,void 0,void 0,function(){return B(this,function(r){return t.length>1e3?[2,Promise.reject(N.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 B(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 B(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 B(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 B(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 B(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 B(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;i<arguments.length;i++)r[i-1]=arguments[i];return(t=this._engine).callExtra.apply(t,Gt([e],r))},n.prototype.clearConversations=function(e,t){return x(this,void 0,void 0,function(){return B(this,function(r){switch(r.label){case 0:return[4,this._engine.clearConversations(e,t)];case 1:return[2,r.sent()]}})})},n.prototype.setUserStatusListener=function(e,t){return this._engine.setUserStatusListener(e,function(r){try{t(r)}catch(i){K.error(i)}})},n.prototype.addToBlacklist=function(e){return x(this,void 0,void 0,function(){return B(this,function(t){return[2,this._engine.addToBlacklist(e)]})})},n.prototype.removeFromBlacklist=function(e){return x(this,void 0,void 0,function(){return B(this,function(t){return[2,this._engine.removeFromBlacklist(e)]})})},n.prototype.getBlacklist=function(){return x(this,void 0,void 0,function(){return B(this,function(e){return[2,this._engine.getBlacklist()]})})},n.prototype.getBlacklistStatus=function(e){return x(this,void 0,void 0,function(){return B(this,function(t){return[2,this._engine.getBlacklistStatus(e)]})})},n.prototype.insertMessage=function(e,t,r){return x(this,void 0,void 0,function(){return B(this,function(i){return[2,this._engine.insertMessage(e,t,r)]})})},n.prototype.deleteMessages=function(e){return x(this,void 0,void 0,function(){return B(this,function(t){return[2,this._engine.deleteMessages(e)]})})},n.prototype.deleteMessagesByTimestamp=function(e,t,r,i,s){return s===void 0&&(s=""),x(this,void 0,void 0,function(){return B(this,function(o){return[2,this._engine.deleteMessagesByTimestamp(e,t,r,i,s)]})})},n.prototype.clearMessages=function(e,t,r){return r===void 0&&(r=""),x(this,void 0,void 0,function(){return B(this,function(i){return[2,this._engine.clearMessages(e,t,r)]})})},n.prototype.getMessage=function(e){return x(this,void 0,void 0,function(){return B(this,function(t){return[2,this._engine.getMessage(e)]})})},n.prototype.setMessageContent=function(e,t,r){return x(this,void 0,void 0,function(){return B(this,function(i){return[2,this._engine.setMessageContent(e,t,r)]})})},n.prototype.setMessageSearchField=function(e,t,r){return x(this,void 0,void 0,function(){return B(this,function(i){return[2,this._engine.setMessageSearchField(e,t,r)]})})},n.prototype.setMessageSentStatus=function(e,t){return x(this,void 0,void 0,function(){return B(this,function(r){return[2,this._engine.setMessageSentStatus(e,t)]})})},n.prototype.setMessageReceivedStatus=function(e,t){return x(this,void 0,void 0,function(){return B(this,function(r){return[2,this._engine.setMessageReceivedStatus(e,t)]})})},n.prototype.setUserStatus=function(e){return x(this,void 0,void 0,function(){return B(this,function(t){return[2,this._engine.setUserStatus(e)]})})},n.prototype.subscribeUserStatus=function(e){return x(this,void 0,void 0,function(){return B(this,function(t){return[2,this._engine.subscribeUserStatus(e)]})})},n.prototype.getUserStatus=function(e){return x(this,void 0,void 0,function(){return B(this,function(t){return[2,this._engine.getUserStatus(e)]})})},n.prototype.searchConversationByContent=function(e,t,r,i){return t===void 0&&(t=[]),r===void 0&&(r=""),x(this,void 0,void 0,function(){return B(this,function(s){return[2,this._engine.searchConversationByContent(e,t,r,i)]})})},n.prototype.searchMessageByContent=function(e,t,r,i,s,o,c){return c===void 0&&(c=""),x(this,void 0,void 0,function(){return B(this,function(d){return[2,this._engine.searchMessageByContent(e,t,r,i,s,o,c)]})})},n.prototype.getUnreadMentionedMessages=function(e,t,r){return r===void 0&&(r=""),this._engine.getUnreadMentionedMessages(e,t,r)},n.prototype.clearUnreadCountByTimestamp=function(e,t,r,i){return i===void 0&&(i=""),this._engine.clearUnreadCountByTimestamp(e,t,r,i)},n.prototype.getConversationNotificationStatus=function(e,t,r){return r===void 0&&(r=""),this._engine.getConversationNotificationStatus(e,t,r)},n.prototype.getRemoteHistoryMessages=function(e,t,r,i,s,o){return this._engine.getRemoteHistoryMessages(e,t,r,i,s,o)},n.prototype.getConversationListWithAllChannel=function(){return this._engine.getConversationListWithAllChannel()},n.prototype.getConversationListWithAllChannelByPage=function(e,t){return this._engine.getConversationListWithAllChannelByPage(e,t)},n.prototype.joinRTCRoom=function(e,t,r,i){return this._engine.joinRTCRoom(e,t,r,i)},n.prototype.quitRTCRoom=function(e){return this._engine.quitRTCRoom(e)},n.prototype.rtcPing=function(e,t,r){return this._engine.rtcPing(e,t,r)},n.prototype.getRTCRoomInfo=function(e){return this._engine.getRTCRoomInfo(e)},n.prototype.getRTCUserInfoList=function(e){return this._engine.getRTCUserInfoList(e)},n.prototype.getRTCUserInfo=function(e){return this._engine.getRTCUserInfo(e)},n.prototype.setRTCUserInfo=function(e,t,r){return this._engine.setRTCUserInfo(e,t,r)},n.prototype.removeRTCUserInfo=function(e,t){return this._engine.removeRTCUserInfo(e,t)},n.prototype.setRTCData=function(e,t,r,i,s,o){return this._engine.setRTCData(e,t,r,i,s,o)},n.prototype.setRTCTotalRes=function(e,t,r,i,s){return s===void 0&&(s=""),this._engine.setRTCTotalRes(e,t,r,i,s)},n.prototype.setRTCCDNUris=function(e,t,r){return this._engine.setRTCCDNUris(e,t,r)},n.prototype.getRTCData=function(e,t,r,i){return this._engine.getRTCData(e,t,r,i)},n.prototype.removeRTCData=function(e,t,r,i,s){return this._engine.removeRTCData(e,t,r,i,s)},n.prototype.setRTCOutData=function(e,t,r,i){return this._engine.setRTCOutData(e,t,r,i)},n.prototype.getRTCOutData=function(e,t){return this._engine.getRTCOutData(e,t)},n.prototype.getRTCToken=function(e,t,r){return this._engine.getRTCToken(e,t,r)},n.prototype.setRTCState=function(e,t){return this._engine.setRTCState(e,t)},n.prototype.getRTCUserList=function(e){return this._engine.getRTCUserList(e)},n.prototype.joinLivingRoomAsAudience=function(e,t,r){return this._engine.joinLivingRoomAsAudience(e,t,r)},n.prototype.quitLivingRoomAsAudience=function(e){return this._engine.quitLivingRoomAsAudience(e)},n.prototype.rtcIdentityChange=function(e,t,r){return this._engine.rtcIdentityChange(e,t,r)},n.prototype.getRTCJoinedUserInfo=function(e){return this._engine.getRTCJoinedUserInfo(e)},n.prototype.requestRoomPK=function(e){return this._engine.requestRoomPK(e)},n.prototype.cancelRoomPK=function(e){return this._engine.cancelRoomPK(e)},n.prototype.responseRoomPK=function(e){return this._engine.responseRoomPK(e)},n.prototype.endRoomPK=function(e){return this._engine.endRoomPK(e)},n}();(function(n){n[n.add=1]="add",n[n.update=2]="update",n[n.delete=3]="delete"})(rc||(rc={}));/*! *****************************************************************************
  797. Copyright (c) Microsoft Corporation.
  798. Permission to use, copy, modify, and/or distribute this software for any
  799. purpose with or without fee is hereby granted.
  800. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
  801. REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  802. AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
  803. INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  804. LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  805. OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  806. PERFORMANCE OF THIS SOFTWARE.
  807. ***************************************************************************** */var Vs=function(n,e){return Vs=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])},Vs(n,e)},Fs=function(){return Fs=Object.assign||function(n){for(var e,t=1,r=arguments.length;t<r;t++)for(var i in e=arguments[t])Object.prototype.hasOwnProperty.call(e,i)&&(n[i]=e[i]);return n},Fs.apply(this,arguments)};function er(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 c(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,c)}d((r=r.apply(n,e||[])).next())})}function tr(n,e){var t,r,i,s,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:c(0),throw:c(1),return:c(2)},typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function c(d){return function(l){return function(h){if(t)throw new TypeError("Generator is already executing.");for(;o;)try{if(t=1,r&&(i=2&h[0]?r.return:h[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,h[1])).done)return i;switch(r=0,i&&(h=[2&h[0],i.value]),h[0]){case 0:case 1:i=h;break;case 4:return o.label++,{value:h[1],done:!1};case 5:o.label++,r=h[1],h=[0];continue;case 7:h=o.ops.pop(),o.trys.pop();continue;default:if(i=o.trys,!((i=i.length>0&&i[i.length-1])||h[0]!==6&&h[0]!==2)){o=0;continue}if(h[0]===3&&(!i||h[1]>i[0]&&h[1]<i[3])){o.label=h[1];break}if(h[0]===6&&o.label<i[1]){o.label=i[1],i=h;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(h);break}i[2]&&o.ops.pop(),o.trys.pop();continue}h=e.call(n,o)}catch(a){h=[6,a],r=0}finally{t=i=0}if(5&h[0])throw h[1];return{value:h[0]?h[1]:void 0,done:!0}}([d,l])}}}var Je=new Dt("RCIM"),ar=function(){return!(typeof uni=="undefined"||!function(n){for(var e=["canIUse","getSystemInfo"],t=0,r=e.length;t<r;t++)if(!n[e[t]])return!1;return!0}(uni))},Kh=ar(),Ne,ic={tag:"browser",httpReq:function(n){var e=n.method||gt.GET,t=n.timeout||6e4,r=n.headers,i=n.query,s=n.body,o=yi(n.url,i);return new Promise(function(c){var d,l=(d=typeof XMLHttpRequest!="undefined"&&"withCredentials"in new XMLHttpRequest,typeof XMLHttpRequest!="undefined"&&d?new XMLHttpRequest:typeof XDomainRequest!="undefined"?new XDomainRequest:new ActiveXObject("Microsoft.XMLHTTP")),h=Object.prototype.toString.call(l)==="[object XDomainRequest]";if(l.open(e,o),r&&l.setRequestHeader)for(var a in r)l.setRequestHeader(a,r[a]);if(h){l.timeout=t,l.onload=function(){c({data:l.responseText,status:l.status||200})},l.onerror=function(){c({status:l.status||0})},l.ontimeout=function(){c({status:l.status||0})};var u=typeof s=="object"?JSON.stringify(s):s;l.send(u)}else l.onreadystatechange=function(){l.readyState===4&&c({data:l.responseText,status:l.status})},l.onerror=function(){c({status:l.status||0})},setTimeout(function(){return c({status:l.status||0})},t),l.send(s)})},localStorage:window==null?void 0:window.localStorage,sessionStorage:window==null?void 0:window.sessionStorage,isSupportSocket:function(){var n=typeof WebSocket!="undefined";return n||Je.warn("websocket not support"),n},useNavi:!0,connectPlatform:"",isFromUniapp:Kh,createWebSocket:function(n,e){var t=new WebSocket(n,e);return t.binaryType="arraybuffer",{onClose:function(r){t.onclose=function(i){var s=i.code,o=i.reason;r(s,o)}},onError:function(r){t.onerror=r},onMessage:function(r){t.onmessage=function(i){r(i.data)}},onOpen:function(r){t.onopen=r},send:function(r){t.send(r)},close:function(r,i){t.close(r,i)}}},createDataChannel:function(n,e){return this.isSupportSocket()&&e==="websocket"?new Cn(this,n):new En(this,n)}},qh=ar(),Er=function(n){return function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];try{return wx[n].apply(wx,e)}catch(r){Je.error(r)}}},sc={setItem:Er("setStorageSync"),getItem:Er("getStorageSync"),removeItem:Er("removeStorageSync"),clear:Er("clearStorageSync")},oc={tag:"wechat",httpReq:function(n){var e=n.method||gt.GET,t=n.timeout||6e4,r=n.headers,i=n.query,s=n.body,o=yi(n.url,i);return new Promise(function(c){wx.request({url:o,method:e,headers:r,timeout:t,data:s,success:function(d){c({data:d.data,status:d.statusCode})},fail:function(){c({status:N.RC_HTTP_REQ_TIMEOUT})}})})},localStorage:sc,sessionStorage:sc,isSupportSocket:function(){return!0},useNavi:!1,connectPlatform:"MiniProgram",isFromUniapp:qh,createWebSocket:function(n,e){var t=wx.connectSocket({url:n,protocols:e});return{onClose:function(r){t.onClose(function(i){r(i.code,i.reason)})},onError:function(r){t.onError(function(i){r(i.errMsg)})},onMessage:function(r){t.onMessage(function(i){r(i.data)})},onOpen:function(r){t.onOpen(r)},send:function(r){t.send({data:r})},close:function(r,i){t.close({code:r,reason:i})}}},createDataChannel:function(n,e){return e==="websocket"?new Cn(this,n):new En(this,n)}},Gh=ar(),Rr=function(n){return function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];try{return my[n].apply(my,e)}catch(r){Je.error(r)}}},ac={setItem:Rr("setStorageSync"),getItem:Rr("getStorageSync"),removeItem:Rr("removeStorageSync"),clear:Rr("clearStorageSync")},cc={tag:"alipay",httpReq:function(n){var e=n.method||gt.GET,t=n.timeout||6e4,r=n.headers,i=n.query,s=n.body,o=yi(n.url,i),c=n.dataType||"json";return new Promise(function(d){my.request({url:o,method:e,headers:r,timeout:t,data:s,dataType:c,success:function(l){d({data:l.data,status:l.status})},fail:function(){d({status:N.RC_HTTP_REQ_TIMEOUT})}})})},localStorage:ac,sessionStorage:ac,isSupportSocket:function(){return!1},useNavi:!1,connectPlatform:"MiniProgram",isFromUniapp:Gh,createDataChannel:function(n,e){return e==="websocket"?new Cn(this,n):new En(this,n)}},Yh=ar(),Tr=function(n){return function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];try{return console.log("tt",tt),tt[n].apply(tt,e)}catch(r){Je.error(r)}}},uc={setItem:Tr("setStorageSync"),getItem:Tr("getStorageSync"),removeItem:Tr("removeStorageSync"),clear:Tr("clearStorageSync")},dc={tag:"toutiao",isSupportSocket:function(){return!0},useNavi:!1,connectPlatform:"MiniProgram",isFromUniapp:Yh,localStorage:uc,sessionStorage:uc,httpReq:function(n){return new Promise(function(e,t){tt.request({url:n.url,data:n.body,header:n.headers,method:n.method,success:function(r){console.log("\u8C03\u7528\u6210\u529F",r.data);var i=(r==null?void 0:r.data)||{},s={data:JSON.stringify(i),status:r.statusCode};e(s)},fail:function(r){console.log("\u8C03\u7528\u5931\u8D25",r.errMsg),t({data:r.errMsg})}})})},createWebSocket:function(n,e){var t=tt.connectSocket({url:n,protocols:e});return{onOpen:function(r){t.onOpen(r)},onClose:function(r){t.onClose(function(i){return r(i.code,i.reason)})},onError:function(r){t.onError(function(i){return r(i.errMsg)})},onMessage:function(r){t.onMessage(function(i){return r(i.data)})},send:function(r){t.send({data:r})},close:function(r,i){t.close({code:r,reason:i})}}},createDataChannel:function(n,e){return e==="websocket"?new Cn(this,n):new En(this,n)}},Jh=ar(),Sr=function(n){return function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];try{return console.log("swan",swan),swan[n].apply(swan,e)}catch(r){Je.error(r)}}},lc={setItem:Sr("setStorageSync"),getItem:Sr("getStorageSync"),removeItem:Sr("removeStorageSync"),clear:Sr("clearStorageSync")},hc={tag:"baidu",isSupportSocket:function(){return!0},useNavi:!1,connectPlatform:"MiniProgram",isFromUniapp:Jh,localStorage:lc,sessionStorage:lc,httpReq:function(n){return new Promise(function(e,t){swan.request({url:n.url,data:n.body,header:n.headers,method:n.method,success:function(r){console.log("\u8C03\u7528\u6210\u529F",r.data);var i=(r==null?void 0:r.data)||{},s={data:JSON.stringify(i),status:r.statusCode};e(s)},fail:function(r){console.log("\u8C03\u7528\u5931\u8D25",r.errorCode),t({data:r.errorCode})}})})},createWebSocket:function(n,e){var t=swan.connectSocket({url:n,protocols:e});return{onOpen:function(r){t.onOpen(r)},onClose:function(r){t.onClose(function(i){return r(i.code,i.reason)})},onError:function(r){t.onError(function(i){return r(i.errMsg)})},onMessage:function(r){t.onMessage(function(i){return r(i.data)})},send:function(r){t.send({data:r})},close:function(r,i){t.close({code:r,reason:i})}}},createDataChannel:function(n,e){return e==="websocket"?new Cn(this,n):new En(this,n)}},Ir=function(n){return function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];try{return uni[n].apply(uni,e)}catch(r){Je.error(r)}}},fc={setItem:Ir("setStorageSync"),getItem:Ir("getStorageSync"),removeItem:Ir("removeStorageSync"),clear:Ir("clearStorageSync")},Wh={tag:"uniapp",httpReq:function(n){var e=n.method||gt.GET,t=n.timeout||6e4,r=n.headers,i=n.query,s=n.body,o=yi(n.url,i);return new Promise(function(c){uni.request({url:o,method:e,headers:r,timeout:t,data:s,success:function(d){c({data:d.data,status:d.statusCode})},fail:function(){c({status:N.RC_HTTP_REQ_TIMEOUT})}})})},localStorage:fc,sessionStorage:fc,isSupportSocket:function(){return!0},useNavi:!0,connectPlatform:"",isFromUniapp:!0,createWebSocket:function(n,e){var t={complete:function(){},url:n,protocols:e},r=uni.connectSocket(t);return{onClose:function(i){r.onClose(function(s){i(s.code,s.reason)})},onError:function(i){r.onError(function(s){i(s.errMsg)})},onMessage:function(i){r.onMessage(function(s){i(s.data)})},onOpen:function(i){r.onOpen(i)},send:function(i){r.send({data:i})},close:function(i,s){r.close({code:i,reason:s})}}},createDataChannel:function(n,e){return e==="websocket"?new Cn(this,n):new En(this,n)}},Ln=function(n){return n&&n.canIUse&&n.getSystemInfo},zh=typeof uni!="undefined"&&Ln(uni)?function(){switch({}.VUE_APP_PLATFORM){case"app-plus":return Wh;case"mp-baidu":return hc;case"mp-toutiao":return dc;case"mp-alipay":return cc;case"mp-weixin":return oc;default:return ic}}():typeof wx!="undefined"&&Ln(wx)?oc:typeof my!="undefined"&&Ln(my)?cc:typeof tt!="undefined"&&Ln(tt)?dc:typeof swan!="undefined"&&Ln(swan)?hc:ic;function ri(n){var e=n.conversationType,t=n.channelId,r=n.messageType,i=n.content,s=n.senderUserId,o=n.targetId,c=n.sentTime,d=n.receivedTime,l=n.messageUId,h=n.messageDirection,a=n.isPersited,u=n.isCounted,f=n.isOffLineMessage,p=n.canIncludeExpansion,m=n.expansion,_=n.receivedStatus,v=n.disableNotification,y=n.isMentioned,C=n.isStatusMessage,b=n.readReceiptInfo,O=n.pushConfig,S=n.messageId;return _||(_=Gn.UNREAD),{messageType:r,channelId:t||"",content:i,senderUserId:s,targetId:o,conversationType:e,sentTime:c,receivedTime:d,messageUId:l,messageDirection:h,isPersited:a,isCounted:u,isOffLineMessage:f,isMentioned:y,disableNotification:v,isStatusMessage:C,canIncludeExpansion:p,expansion:m,receivedStatus:_,readReceiptInfo:b,pushConfig:O,messageId:S}}(function(n){n.CONNECTING="CONNECTING",n.CONNECTED="CONNECTED",n.DISCONNECT="DISCONNECT",n.SUSPEND="SUSPEND",n.MESSAGES="MESSAGES",n.READ_RECEIPT_RECEIVED="READ_RECEIPT_RECEIVED",n.MESSAGE_RECEIPT_REQUEST="MESSAGE_RECEIPT_REQUEST",n.MESSAGE_RECEIPT_RESPONSE="MESSAGE_RECEIPT_RESPONSE",n.CONVERSATION="CONVERSATION",n.CHATROOM="CHATROOM",n.EXPANSION="EXPANSION",n.PULL_OFFLINE_MESSAGE_FINISHED="PULL_OFFLINE_MESSAGE_FINISHED",n.TAG="TAG",n.CONVERSATION_TAG="CONVERSATION_TAG",n.TYPING_STATUS="TYPING_STATUS",n.MESSAGE_BLOCKED="MESSAGE_BLOCKED"})(Ne||(Ne={}));var hn,lt=function(n){function e(t){var r=n.call(this)||this;if(e.imClient)return Je.error("Please do not repeatedly perform the init method"),e.imClient;xe("options.navigators",t.navigators,function(s){return ze(s)&&(s.length===0||s.every(Yn))});var i=t==null?void 0:t.connectType;return i?Nt.WEBSOCKET!==i&&Nt.COMET!==i&&(Je.warn("RongIMLib connectionType must be "+Nt.WEBSOCKET+" or "+Nt.COMET),i=Nt.WEBSOCKET):i=Nt.WEBSOCKET,r._context=jh.init(zh,{appkey:t.appkey,apiVersion:"5.1.1",navigators:t.navigators||[],miniCMPProxy:t.customCMP||[],connectionType:i,logLevel:t.logLevel,logStdout:t.logStdout,indexDBSwitch:t.indexDBSwitch,checkCA:t.checkCA}),r.watch(),e.imClient=r,r}return function(t,r){if(typeof r!="function"&&r!==null)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function i(){this.constructor=t}Vs(t,r),t.prototype=r===null?Object.create(r):(i.prototype=r.prototype,new i)}(e,n),Object.defineProperty(e.prototype,"context",{get:function(){if(!this._context)throw new Error("Please perform the init method!");return this._context},enumerable:!1,configurable:!0}),e.prototype.watch=function(){var t=this,r={onConnecting:function(){t.emit(Ne.CONNECTING)},onConnected:function(){t.emit(Ne.CONNECTED)},onDisconnect:function(){t.emit(Ne.DISCONNECT)},onSuspend:function(){t.emit(Ne.SUSPEND)},batchMessage:function(i){t.emit(Ne.MESSAGES,{messages:i.map(function(s){return ri(s)})})},typingState:function(i){t.emit(Ne.TYPING_STATUS,{status:i})},readReceiptReceived:function(i,s,o){t.emit(Ne.READ_RECEIPT_RECEIVED,{conversation:i,messageUId:s,sentTime:o})},messageReceiptRequest:function(i,s,o){t.emit(Ne.MESSAGE_RECEIPT_REQUEST,{conversation:i,messageUId:s,senderUserId:o})},messageReceiptResponse:function(i,s,o){t.emit(Ne.MESSAGE_RECEIPT_RESPONSE,{conversation:i,receivedUserId:s,messageUIdList:o})},conversationState:function(i){var s=i.map(function(o){return{conversation:{conversationType:o.conversationType,latestMessage:o.latestMessage?ri(o.latestMessage):null,targetId:o.targetId,unreadMessageCount:o.unreadMessageCount,hasMentioned:o.hasMentioned,mentionedInfo:o.mentionedInfo,lastUnreadTime:o.lastUnreadTime,notificationStatus:o.notificationStatus,isTop:o.isTop,channelId:o.channelId,unreadMentionedCount:o.unreadMentionedCount},updatedItems:o.updatedItems}});t.emit(Ne.CONVERSATION,{conversationList:s})},chatroomState:function(i){t.emit(Ne.CHATROOM,i)},expansion:function(i){t.emit(Ne.EXPANSION,i)},pullFinished:function(){t.emit(Ne.PULL_OFFLINE_MESSAGE_FINISHED)},tag:function(){t.emit(Ne.TAG)},conversationTagChanged:function(){t.emit(Ne.CONVERSATION_TAG)},messageBlocked:function(i){t.emit(Ne.MESSAGE_BLOCKED,i)}};this.context.assignWatcher(r)},e}(ir),ii={TIMEOUT:{code:-1,msg:"Network timeout"},SDK_INTERNAL_ERROR:{code:-2,msg:"SDK internal error"},PARAMETER_ERROR:{code:-3,msg:"Please check the parameters, the {param} expected a value of {expect} but received {current}"},REJECTED_BY_BLACKLIST:{code:405,msg:"Blacklisted by the other party"},SEND_TOO_FAST:{code:20604,msg:"Sending messages too quickly"},NOT_IN_GROUP:{code:22406,msg:"Not in group"},FORBIDDEN_IN_GROUP:{code:22408,msg:"Forbbiden from speaking in the group"},NOT_IN_CHATROOM:{code:23406,msg:"Not in chatRoom"},FORBIDDEN_IN_CHATROOM:{code:23408,msg:"Forbbiden from speaking in the chatRoom"},KICKED_FROM_CHATROOM:{code:23409,msg:"Kicked out and forbbiden from joining the chatRoom"},CHATROOM_NOT_EXIST:{code:23410,msg:"ChatRoom does not exist"},CHATROOM_IS_FULL:{code:23411,msg:"ChatRoom members exceeded"},PARAMETER_INVALID_CHATROOM:{code:23412,msg:"Invalid chatRoom parameters"},ROAMING_SERVICE_UNAVAILABLE_CHATROOM:{code:23414,msg:"ChatRoom message roaming service is not open, Please go to the developer to open this service"},RECALLMESSAGE_PARAMETER_INVALID:{code:25101,msg:"Invalid recall message parameter"},ROAMING_SERVICE_UNAVAILABLE_MESSAGE:{code:25102,msg:"Single group chat roaming service is not open, Please go to the developer to open this service"},PUSHSETTING_PARAMETER_INVALID:{code:26001,msg:"Invalid push parameter"},OPERATION_BLOCKED:{code:20605,msg:"Operation is blocked"},OPERATION_NOT_SUPPORT:{code:20606,msg:"Operation is not supported"},MSG_BLOCKED_SENSITIVE_WORD:{code:21501,msg:"The sent message contains sensitive words"},REPLACED_SENSITIVE_WORD:{code:21502,msg:"Sensitive words in the message have been replaced"},NOT_CONNECTED:{code:30001,msg:"Please connect successfully first"},NAVI_REQUEST_ERROR:{code:30007,msg:"Navigation http request failed"},CMP_REQUEST_ERROR:{code:30010,msg:"CMP sniff http request failed"},CONN_APPKEY_FAKE:{code:31002,msg:"Your appkey is fake"},CONN_MINI_SERVICE_NOT_OPEN:{code:31003,msg:"Mini program service is not open, Please go to the developer to open this service"},CONN_ACK_TIMEOUT:{code:31e3,msg:"Connection ACK timeout"},CONN_TOKEN_INCORRECT:{code:31004,msg:"Your token is not valid or expired"},CONN_NOT_AUTHRORIZED:{code:31005,msg:"AppKey and Token do not match"},CONN_REDIRECTED:{code:31006,msg:"Connection redirection"},CONN_APP_BLOCKED_OR_DELETED:{code:31008,msg:"AppKey is banned or deleted"},CONN_USER_BLOCKED:{code:31009,msg:"User blocked"},CONN_DOMAIN_INCORRECT:{code:31012,msg:"Connect domain error, Please check the set security domain"},ROAMING_SERVICE_UNAVAILABLE:{code:33007,msg:"Roaming service cloud is not open, Please go to the developer to open this service"},RC_CONNECTION_EXIST:{code:34001,msg:"Connection already exists"},CHATROOM_KV_EXCEED:{code:23423,msg:"ChatRoom KV setting exceeds maximum"},CHATROOM_KV_OVERWRITE_INVALID:{code:23424,msg:"ChatRoom KV already exists"},CHATROOM_KV_STORE_NOT_OPEN:{code:23426,msg:"ChatRoom KV storage service is not open, Please go to the developer to open this service"},CHATROOM_KEY_NOT_EXIST:{code:23427,msg:"ChatRoom key does not exist"},MSG_KV_NOT_SUPPORT:{code:34008,msg:"The message cannot be extended"},SEND_MESSAGE_KV_FAIL:{code:34009,msg:"Sending RC expansion message fail"},EXPANSION_LIMIT_EXCEET:{code:34010,msg:"The message expansion size is beyond the limit"},ILLGAL_PARAMS:{code:33003,msg:"Incorrect parameters passed in while calling the interface"},UPLOAD_FILE_FAILED:{code:35020,msg:"File upload failed"},CHATROOM_KV_STORE_NOT_ALL_SUCCESS:{code:23428,msg:"Chatroom kv store not all success"},CHATROOM_KV_STORE_OUT_LIMIT:{code:23429,msg:"Chatroom kv's length is out of limit"},TAG_EXISTS:{code:33101,msg:"The tag already exists"},TAG_NOT_EXIST:{code:33100,msg:"The tag does not exist"},NOT_SUPPORT:{code:N.NOT_SUPPORT,msg:"The method is not supported in a browser!"}},fn={},Qh={};for(var pc in ii){var gc=ii[pc],mc=gc.code;fn[mc]=pc,Qh[mc]=gc}ii.ROAMING_SERVICE_UNAVAILABLE.code;var Xh=function(n){hn=hn||new lt(n)};function Zh(n,e){return hn==null?void 0:hn.context.install(n,e)}function ef(n){return er(this,void 0,void 0,function(){var e;return tr(this,function(t){switch(t.label){case 0:return xe("token",n,Me.STRING,!0),Je.warn("RongIMLib Version: 5.1.1, Commit: 756868a83166be55e30e49e5685b1644456ea30f"),[4,hn.context.connect(n,!0)];case 1:return(e=t.sent()).code===N.SUCCESS?[2,{code:e.code,data:{userId:e.userId}}]:[2,{code:e.code,msg:fn[e.code]}]}})})}function cr(n,e,t){hn.on(n,e,t)}function tf(n,e){return er(this,void 0,void 0,function(){var t,r;return tr(this,function(i){switch(i.label){case 0:return xe("options.count",e.count,Me.NUMBER,!0),t="id:"+n,Je.debug("join chatroom ->"+t),[4,lt.imClient.context.joinChatroom(n,e.count)];case 1:return(r=i.sent())!==N.SUCCESS?(Je.warn("join chatroom fail ->code+:"+fn[r]+","+t),[2,{code:r,msg:fn[r]}]):[2,{code:r}]}})})}var ju=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 ut(n,e,t){return e===void 0&&(e=!0),t===void 0&&(t=!0),function(r){return new ju(n,r,e,t)}}var Ku,Hs,nf=ut("RC:ImgMsg"),rf=ut("RC:HQVCMsg"),sf=ut("RC:SightMsg"),of=ut("RC:TxtMsg"),af=ut("RC:CombineMsg"),cf=ut("RC:FileMsg");ut("RC:GIFMsg");ut("RC:VcMsg");ut("RC:LBSMsg");ut("RC:ReferenceMsg");ut("RC:ImgTextMsg");var nn={qiniu:function(n,e,t,r){var i,s="https://"+e.uploadHost.qiniu;i=kn()+_e[0][1]||s,_e.shift();var o=new XMLHttpRequest;o.upload&&e.support_options&&(o.upload.onprogress=function(c){t.onProgress(c.loaded,c.total)}),o.onreadystatechange=function(){if(o.readyState===4){var c=o.responseText||"{}";(c=JSON.parse(c)).filename=e.uniqueValue,c.uploadMethod=We?We.QINIU:"",o.status===200?t.onCompleted(c):_e.length?nn[_e[0][0]](n,e,t,r):t.onError("upload fail")}},e.isChunk&&(i=function(c,d){var l="";return vc(d,function(h,a){h!=="token"&&(l+=(l?"&":"")+encodeURIComponent(h)+"="+encodeURIComponent(a))}),l&&(c+=(c.indexOf("?")>0?"&":"?")+l),c}(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),vc(e.headers,function(c,d){o.setRequestHeader(c,d)}),o.send(n)},baidu:function(n,e,t,r){if(console.log(r,e),r.size>_c)throw new Error("the file size is over 5GB!");var i=e||{};e=e||Hs;var s=new XMLHttpRequest,o=kn();if(!(!i.uploadHost.bos&&!i.bosUploadPath)){var c=o+_e[0][1]+i.bosUploadPath;_e.shift();var d=i.bosHeader||{},l={filename:e.uniqueValue||r.uniqueName,name:r.name,downloadUrl:c,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?nn[_e[0][0]](n,e,t,r):t.onError("upload fail")}},s.open(e.method,c,!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>_c)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||Ku,e=(e=e||{})||Hs;var o=new XMLHttpRequest,c=kn()+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=We?We.ALI:"",o.status===200?t.onCompleted(l):_e.length?nn[_e[0][0]](i,e,t,r):t.onError("upload fail")}},o.open(e.method,c,!0),console.log("ali:url",c);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=kn();const c=_e[0][1];var d=o+e.s3BucketName+"."+c;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=We.AWS,console.log("UploadMethod:",We),s.status===200||s.status===204)t.onCompleted(a);else if(_e.length){const u=new FormData;u.set("file",n.get("file")),u.set("key",n.get("key")),u.set("token",n.get("token")),nn[_e[0][0]](u,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;kn();var s="https://"+_e[0][1]+"/"+e.stcBucketName+"/"+e.uploadFileName;_e.shift(),i.upload&&e.support_options&&(i.upload.onprogress=function(c){t.onProgress(c.loaded,c.total)}),i.onreadystatechange=function(){if(i.readyState===4){var c=i.responseText||"{}";if((c=JSON.parse(c)).name=e.uniqueValue,c.filename=e.uploadFileName,c.uploadMethod=We?We.STC:"",i.status===200||i.status===204)t.onCompleted(c);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")),nn[_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=[],_c=5368709120;function vc(n,e){for(var t in n)e(t,n[t])}function kn(){var n="https://";return location.protocol!=="http:"&&location.protocol!=="file:"||(n="http://"),n}function uf(n,e,t){var r,i,s=n&&n.type||"text/plain",o=s.indexOf("image")>-1?1:4,c=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";lt.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 y=_.response.match(/(?:<UploadId>)(\S*?)(?:<\/UploadId>)/);console.log("uploadId",y),_.status===200||_.status===204?function(C){for(var b=[],O=1;O<=c;O++)b.push(p(C,O));f(C,b)}(Array.isArray(y)&&y[1]):t.onError("uploadStcMultipart:did not get uploadId")}}},function(m){t.onError("uploadStcMultipart:"+m)});var a=[],u=new Map;function f(m,_){_&&Array.isArray(_)&&_.length!==0&&Promise.all(_).then(()=>{var v="uploadId="+m;if(u.size===c)lt.imClient.context.getFileToken(o,r,"POST",v).then(function(b){console.log("onSuccess",b),console.log("onSuccess:uploadId",m);var O=new XMLHttpRequest;O.open("POST",i+"?"+v,!0),O.setRequestHeader("Authorization",b&&b.stcAuthorization),O.setRequestHeader("x-amz-content-sha256",b&&b.stcContentSha256),O.setRequestHeader("x-amz-date",b&&b.stcDate),O.setRequestHeader("Content-Type",s);var S="<CompleteMultipartUpload xmlns='http://s3.amazonaws.com/doc/2006-03-01/'>",E=Array.from(u.keys()||[]).sort((w,V)=>w-V);console.log("keys",E),E.map(w=>{S+=`<Part><ETag>${u.get(w)}</ETag><PartNumber>${w}</PartNumber></Part>`}),S+="</CompleteMultipartUpload>",O.send(S),console.log("xml",S),O.onreadystatechange=function(){if(O.readyState===4)if(O.status===200||O.status===204){var w={};w.name=n.name,w.filename=e.uploadFileName,w.uploadMethod=We.STC,t.onCompleted(w)}else t.onError("uploadStcMultipart:upload does not end")}},function(b){t.onError("uploadStcMultipart:"+b)});else{var y=[];for(var C of a)y.push(p(m,C));f(m,y)}},v=>{console.error(v),t.onError("uploadStcMultipart: chunkFiles upload failed and those will reupload");var y=[];for(var C of a)y.push(p(m,C));f(m,y)})}function p(m,_){return new Promise((v,y)=>{var C="partNumber="+_+"&uploadId="+m;lt.imClient.context.getFileToken(o,r,"PUT",C).then(function(b){console.log("signature "+_+" onSuccess",b);var O=n&&n.slice((_-1)*e.stc_chunk_size,_*e.stc_chunk_size);console.log("fileChunk:size",O.size);var S=new XMLHttpRequest;S.open("PUT",i+"?"+C,!0),S.setRequestHeader("Authorization",b&&b.stcAuthorization),S.setRequestHeader("x-amz-content-sha256",b&&b.stcContentSha256),S.setRequestHeader("x-amz-date",b&&b.stcDate),S.setRequestHeader("Content-Type",s),S.send(O),S.onreadystatechange=function(){if(S.readyState===4)if(S.status===200||S.status===204){var E=S.getResponseHeader("etag");console.log("etag:"+_,E),u.set(_,E),v(E)}else a.includes(_)||a.push(_),y(_)}},function(b){console.log("getETags:\u7B7E\u540D\u9A8C\u8BC1\u5931\u8D25"),a.includes(_)||a.push(_),y(_)})})}}var qu={form:function(n,e){var t=new FormData;if(e.unique_key){var r=n.name.substr(n.name.lastIndexOf(".")),i=$s()+r;t.append(e.unique_key,i),e.uniqueValue=i}return t.append(e.file_data_name,n),js(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=$s()+r;t[e.unique_key]=i,e.uniqueValue=i}return t[e.file_data_name]=n,js(e.multi_parmas,function(s,o){t[s]=o}),JSON.stringify(t)},data:function(n,e){return n}};function $s(){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 js(n,e){for(var t in n)e(t,n[t])}var br,es=0;function df(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:qu.form,genUId:$s};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;js(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(Ku=i,Hs=s,_e=[],s.ossConfig){const h=JSON.parse(s.ossConfig);let a,u,f="";const p=[];h.forEach(m=>{const _=Number(m.p)-1;for(const v in m)v==="aliyun"&&(f=m[v]),v==="s3"&&(a=m[v]),v==="stc"&&(u=m[v]),v!=="p"&&(p[_]=[v,m[v]])}),p.forEach(function(m){m&&_e.push(m)}),h.length!==_e.length&&(_e=[["qiniu",s.domain],["baidu",s.uploadHost.bos],["aliyun",f],["s3",a],["stc",u]])}else _e=[["qiniu",s.domain],["baidu",s.uploadHost.bos]];var c;if(s.ossConfig){var d=s&&JSON.parse(s.ossConfig);Array.isArray(d)||(d=[]),c=d.find(h=>Object.keys(h).includes("stc"))}if(c&&parseInt(c.p)===1&&i.size>=4194304)uf(i,s,o);else{var l=s.data(i,s);nn[_e[0][0]](l,s,o,i)}})(e,this.options,{onProgress:function(i,s,o){br=i,o?br=es+i/s*(s-es):es=br,t.onProgress(br,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 yc={init:function(n){return new df(n)},dataType:qu,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,c=new Image;c.src=o;var d=c.width,l=c.height,h=function(u,f){var p=1,m=u.width,_=f.maxWidth||0;_>0&&m>_&&(p=_/m);var v=u.height,y=f.maxHeight||0;if(y>0&&v>y){var C=y/v;p=Math.min(p,C)}var b=f.maxSize||0,O=Math.ceil(u.size/1e3);if(O>b){var S=b/O;p=Math.min(p,S)}return p}({width:d,height:l,size:s.total},e),a=o;h<1&&(a=function(u,f,p){r.width=f,r.height=p,r.getContext("2d").drawImage(u,0,0,f,p);var m="image/jpg";return r.toDataURL(m)}(c,d*h,l*h)),t(a)}}};const lf=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 u,f,p,m=l<h,_=0,v=0;return(m?h/l:l/h)>a.scale?(m?(f=100,v=((p=h/(u=l/100))-a.maxHeight)/2):(p=100,_=((f=l/(u=h/100))-a.maxWidth)/2),{w:f,h:p,x:-_,y:-v}):(m?(u=h/a.maxHeight,p=a.maxHeight,f=l/u):(u=l/a.maxWidth,f=a.maxWidth,p=h/u),{w:f,h:p,x:-_,y:-v})}(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 c=r.toDataURL(n.type,e.quality),d=new RegExp("^data:image/[^;]+;base64,");c=c.replace(d,""),t(c)}catch(l){throw new Error(l)}},s.src=typeof n=="string"?"data:image/jpg;base64,"+n:function(o){var c=window.URL||window.webkitURL;return c?c.createObjectURL(o):""}(n)},hf=function(n,e){var t=n.file,r=n.compress;lf(t,r,e)},Gu=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=yc.init(n);e(s)});else{n.headers||(n.headers={}),n.base64&&(n.headers["Content-type"]="application/octet-stream");var t=yc.init(n);e(t)}};var ts,wr,Yu=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||hf;n.compress?i(n,function(s){r.thumbnail=s,t.onCompleted(r)}):t.onCompleted(r)}})},ff=function(n){var e=this;this.instance=n,this.upload=function(t,r){Yu({file:t},e.instance,r)},this.cancel=function(){e.instance.cancel()}},pf=function(n,e){var t=this;this.cfg=e,this.instance=n,this.upload=function(r,i){var s={file:r,compress:t.cfg};Yu(s,t.instance,i)},this.cancel=function(){t.instance.cancel()}},gf=function(n,e){Gu(n,function(t){var r={maxHeight:n.maxHeight||160,maxWidth:n.maxWidth||160,quality:n.quality||.5,scale:n.scale||2.4},i=new pf(t,r);e(i)})},mf=function(n,e){Gu(n,function(t){var r=new ff(t);e(r)})},_f=gf;function Cc(n){return ts=ts||new AudioContext,new Promise(function(e,t){ts.decodeAudioData(n,function(r){e({duration:r.duration,length:r.length})},t)})}function vf(n,e,t,r,i){return xe("fileType",n,$l,!0),xe("filename",e,Me.STRING),xe("saveName",t,Me.STRING),xe("serverType",i,Me.NUMBER),new Promise(function(s){lt.imClient.context.getFileUrl(n,e,t,r,i).then(function(o){s({code:N.SUCCESS,data:o})}).catch(function(o){s({code:o})})})}function Ju(n,e,t){return er(this,void 0,void 0,function(){var r,i,s,o,c,d,l,h,a;return tr(this,function(u){switch(u.label){case 0:return t=t||{},e instanceof ju?(xe("conversation.channelId",n==null?void 0:n.channelId,Me.CHANNEL_ID),r=n.conversationType,i=n.targetId,s=n.channelId,o="conversationType:"+r+",targetId:"+i,Je.debug("send message ->"+o),(c=Object.assign(t,e)).channelId=s||"",[4,lt.imClient.context.sendMessage(r,i,c)]):(Je.warn("send message fail -> message parameter is not an instance of BaseMessage"),[2,ii.ILLGAL_PARAMS]);case 1:return d=u.sent(),l=d.code,h=d.data,l===N.SUCCESS?(a=ri(h),[2,{code:l,data:a}]):(Je.warn("send message fail ->"+l+":"+fn[l]+","+o),[2,{code:l,msg:fn[l],data:ri({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:lt.imClient.context.getCurrentUserId(),messageUId:"",messageDirection:at.SEND,isOffLineMessage:!1,sentTime:(h==null?void 0:h.sentTime)||0,receivedTime:0,isStatusMessage:t.isStatusMessage||!1,receivedStatus:Gn.UNREAD})}])}})})}function ur(n,e){return function(t,r,i,s){return new Promise(function(o){var c;(function(d,l,h,a){var u,f=this;if(l===void 0&&(l=ke.FILE),u=l===ke.IMAGE?ke.IMAGE:ke.FILE,!wr){wr="upload.qiniup.com";var p=lt.imClient.context.getInfoFromCache();if(p&&p.ossConfig)try{var m=JSON.parse(p.ossConfig).find(function(v){return v.qiniu!==void 0});m&&(wr=m.qiniu)}catch{}}var _=Fs({domain:wr,getToken:function(v){lt.imClient.context.getFileToken(u).then(function(y){v(y.token,y)}).catch(function(y){h.onFail(y)})}},a);(u===ke.IMAGE?_f:mf)(_,function(v){v.upload(d,{onProgress:function(y,C){var b,O=Math.floor(y/C*100);(b=h.onProgress)===null||b===void 0||b.call(h,O)},onCompleted:function(y){return er(f,void 0,void 0,function(){var C=this;return tr(this,function(b){return vf(u,y.filename,y.name,y,y.uploadMethod).then(function(O){return er(C,void 0,void 0,function(){var S,E;return tr(this,function(w){return O.code!==0?(h.onFail(O),[2]):((S=O.data).type=d.type,S.name=y.name||y.filename,l===ke.AUDIO?(typeof d.arrayBuffer=="function"?d.arrayBuffer().then(Cc).then(function(V){Object.assign(S,V),h.onSuccess(S)},function(){h.onSuccess(S)}):((E=new FileReader).onload=function(){E.result?Cc(E.result).then(function(V){Object.assign(S,V),h.onSuccess(S)},function(){h.onSuccess(S)}):h.onSuccess(S)},E.onerror=function(){S.duration=0,h.onSuccess(S)},E.readAsArrayBuffer(d)),[2]):(u===ke.IMAGE&&(S.thumbnail=y.thumbnail),h.onSuccess(S),[2]))})})}).catch(function(O){h.onFail(O)}),[2]})})},onError:function(y){h.onFail(y)}})})})(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);Ju(t,h,s).then(o)},onFail:function(d){o({code:N.UPLOAD_FILE_FAILED,msg:d||N[N.UPLOAD_FILE_FAILED]})}},((c=s)===null||c===void 0?void 0:c.thumbnailConfig)||{})})}}ur(ke.FILE,function(n,e){return new cf({name:n.name,size:e.file.size,type:e.file.type,fileUrl:n.downloadUrl,user:e.user,extra:e.extra})});ur(ke.IMAGE,function(n,e){return new nf({content:n.thumbnail,imageUri:n.downloadUrl,user:e.user,extra:e.extra})});ur(ke.AUDIO,function(n,e){return new rf({remoteUrl:n.downloadUrl,duration:n.duration,type:n.type,user:e.user,extra:e.extra})});ur(ke.SIGHT,function(n,e){return new sf({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 Mi(n,e,t,r){return xe("messageType",n,Me.STRING,!0),xe("isPersited",e,Me.BOOLEAN,!0),xe("isCounted",t,Me.BOOLEAN,!0),lt.imClient.context.registerMessageType(n,e,t,r),ut(n,e,t)}ur(ke.COMBINE_HTML,function(n,e){return new af({remoteUrl:n.downloadUrl,nameList:e.nameList,summaryList:e.summaryList,conversationType:e.conversationType,user:e.user,extra:e.extra})});Yt.add("imlib","5.1.1"),Yt.validEngine("~5.1.1")||Je.error("The current engine version '"+Yt.getInfo().engine+"' error\uFF0Cimlib required engine version at least '~5.1.1'.");/*! *****************************************************************************
  808. Copyright (c) Microsoft Corporation.
  809. Permission to use, copy, modify, and/or distribute this software for any
  810. purpose with or without fee is hereby granted.
  811. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
  812. REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  813. AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
  814. INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  815. LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  816. OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  817. PERFORMANCE OF THIS SOFTWARE.
  818. ***************************************************************************** */function $(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 c(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,c)}d((r=r.apply(n,e||[])).next())})}const P=new Dt("RCRTC");var M,Ks;(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"})(M||(M={})),function(n){n[n.JOIN_REFUSED=40032]="JOIN_REFUSED"}(Ks||(Ks={}));class Wu{constructor(){this.queue=[],this.locked=!1}checkToStart(){return $(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 yf=new Wu,be=n=>yf.push(n);let zu=!0,Qu=!0;function Un(n,e,t){const r=n.match(e);return r&&r.length>=t&&parseInt(r[t],10)}function Rn(n,e,t){if(!n.RTCPeerConnection)return;const r=n.RTCPeerConnection.prototype,i=r.addEventListener;r.addEventListener=function(o,c){if(o!==e)return i.apply(this,arguments);const d=l=>{const h=t(l);h&&(c.handleEvent?c.handleEvent(h):c(h))};return this._eventMap=this._eventMap||{},this._eventMap[e]||(this._eventMap[e]=new Map),this._eventMap[e].set(c,d),i.apply(this,[o,d])};const s=r.removeEventListener;r.removeEventListener=function(o,c){if(o!==e||!this._eventMap||!this._eventMap[e])return s.apply(this,arguments);if(!this._eventMap[e].has(c))return s.apply(this,arguments);const d=this._eventMap[e].get(c);return this._eventMap[e].delete(c),this._eventMap[e].size===0&&delete this._eventMap[e],Object.keys(this._eventMap).length===0&&delete this._eventMap,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 Cf(n){return typeof n!="boolean"?new Error("Argument type: "+typeof n+". Please use a boolean."):(zu=n,n?"adapter.js logging disabled":"adapter.js logging enabled")}function Ef(n){return typeof n!="boolean"?new Error("Argument type: "+typeof n+". Please use a boolean."):(Qu=!n,"adapter.js deprecation warnings "+(n?"disabled":"enabled"))}function ca(){if(typeof window=="object"){if(zu)return;typeof console!="undefined"&&typeof console.log=="function"&&console.log.apply(console,arguments)}}function Pi(n,e){Qu&&console.warn(n+" is deprecated, please use "+e+" instead.")}function Ec(n){return Object.prototype.toString.call(n)==="[object Object]"}function Xu(n){return Ec(n)?Object.keys(n).reduce(function(e,t){const r=Ec(n[t]),i=r?Xu(n[t]):n[t],s=r&&!Object.keys(i).length;return i===void 0||s?e:Object.assign(e,{[t]:i})},{}):n}function qs(n,e,t){e&&!t.has(e.id)&&(t.set(e.id,e),Object.keys(e).forEach(r=>{r.endsWith("Id")?qs(n,n.get(e[r]),t):r.endsWith("Ids")&&e[r].forEach(i=>{qs(n,n.get(i),t)})}))}function Rc(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(c=>{c.type===r&&c.trackId===o.id&&qs(n,c,i)})}),i}const Tc=ca;function Zu(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 c={};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,u){return a?a+u.charAt(0).toUpperCase()+u.slice(1):u==="deviceId"?"sourceId":u};if(l.ideal!==void 0){c.optional=c.optional||[];let a={};typeof l.ideal=="number"?(a[h("min",d)]=l.ideal,c.optional.push(a),a={},a[h("max",d)]=l.ideal,c.optional.push(a)):(a[h("",d)]=l.ideal,c.optional.push(a))}l.exact!==void 0&&typeof l.exact!="number"?(c.mandatory=c.mandatory||{},c.mandatory[h("",d)]=l.exact):["min","max"].forEach(a=>{l[a]!==void 0&&(c.mandatory=c.mandatory||{},c.mandatory[h(a,d)]=l[a])})}),o.advanced&&(c.optional=(c.optional||[]).concat(o.advanced)),c},i=function(o,c){if(e.version>=61)return c(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 u=(a=a.filter(f=>f.kind==="videoinput")).find(f=>h.some(p=>f.label.toLowerCase().includes(p)));return!u&&a.length&&h.includes("back")&&(u=a[a.length-1]),u&&(o.video.deviceId=d.exact?{exact:u.deviceId}:{ideal:u.deviceId}),o.video=r(o.video),Tc("chrome: "+JSON.stringify(o)),c(o)})}o.video=r(o.video)}return Tc("chrome: "+JSON.stringify(o)),c(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,c,d){i(o,l=>{t.webkitGetUserMedia(l,c,h=>{d&&d(s(h))})})}.bind(t),t.mediaDevices.getUserMedia){const o=t.mediaDevices.getUserMedia.bind(t.mediaDevices);t.mediaDevices.getUserMedia=function(c){return i(c,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 ed(n){n.MediaStream=n.MediaStream||n.webkitMediaStream}function td(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 Rn(n,"track",e=>(e.transceiver||Object.defineProperty(e,"transceiver",{value:{receiver:e.receiver}}),e))}function nd(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,c){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 c=this._senders.indexOf(o);c!==-1&&this._senders.splice(c,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(c=>c.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 rd(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(c){const d={};return c.result().forEach(l=>{const h={id:l.id,timestamp:l.timestamp,type:{localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[l.type]||l.type};l.names().forEach(a=>{h[a]=l.stat(a)}),d[h.id]=h}),d},o=function(c){return new Map(Object.keys(c).map(d=>[d,c[d]]))};if(arguments.length>=2){const c=function(d){r(o(s(d)))};return e.apply(this,[c,t])}return new Promise((c,d)=>{e.apply(this,[function(l){c(o(s(l)))},d])}).then(r,i)}}function id(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=>Rc(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}),Rn(n,"track",r=>(r.receiver._pc=r.srcElement,r)),n.RTCRtpReceiver.prototype.getStats=function(){const r=this;return this._pc.getStats().then(i=>Rc(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 sd(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 c=e.apply(this,arguments);return this._shimmedLocalStreams[o.id]?this._shimmedLocalStreams[o.id].indexOf(c)===-1&&this._shimmedLocalStreams[o.id].push(c):this._shimmedLocalStreams[o.id]=[o,c],c};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 c=this.getSenders().filter(d=>o.indexOf(d)===-1);this._shimmedLocalStreams[s.id]=[s].concat(c)};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 c=this._shimmedLocalStreams[o].indexOf(s);c!==-1&&this._shimmedLocalStreams[o].splice(c,1),this._shimmedLocalStreams[o].length===1&&delete this._shimmedLocalStreams[o]}),i.apply(this,arguments)}}function od(n,e){if(!n.RTCPeerConnection)return;if(n.RTCPeerConnection.prototype.addTrack&&e.version>=65)return sd(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(u=>{const f=l._reverseStreams[u],p=l._streams[f.id];a=a.replace(new RegExp(p.id,"g"),f.id)}),new RTCSessionDescription({type:h.type,sdp:a})}function o(l,h){let a=h.sdp;return Object.keys(l._reverseStreams||[]).forEach(u=>{const f=l._reverseStreams[u],p=l._streams[f.id];a=a.replace(new RegExp(f.id,"g"),p.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(p=>p===l))throw new DOMException("The adapter.js addTrack polyfill only supports a single stream which is associated with the specified track.","NotSupportedError");if(this.getSenders().find(p=>p.track===l))throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};const f=this._streams[h.id];if(f)f.addTrack(l),Promise.resolve().then(()=>{this.dispatchEvent(new Event("negotiationneeded"))});else{const p=new n.MediaStream([l]);this._streams[h.id]=p,this._reverseStreams[p.id]=h,this.addStream(p)}return this.getSenders().find(p=>p.track===l)},["createOffer","createAnswer"].forEach(function(l){const h=n.RTCPeerConnection.prototype[l],a={[l](){const u=arguments;return arguments.length&&typeof arguments[0]=="function"?h.apply(this,[f=>{const p=s(this,f);u[0].apply(null,[p])},f=>{u[1]&&u[1].apply(null,f)},arguments[2]]):h.apply(this,arguments).then(f=>s(this,f))}};n.RTCPeerConnection.prototype[l]=a[l]});const c=n.RTCPeerConnection.prototype.setLocalDescription;n.RTCPeerConnection.prototype.setLocalDescription=function(){return arguments.length&&arguments[0].type?(arguments[0]=o(this,arguments[0]),c.apply(this,arguments)):c.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(u=>l.track===u)&&(h=this._streams[a])}),h&&(h.getTracks().length===1?this.removeStream(this._reverseStreams[h.id]):h.removeTrack(l.track),this.dispatchEvent(new Event("negotiationneeded")))}}function Gs(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 ad(n,e){Rn(n,"negotiationneeded",t=>{const r=t.target;if(!(e.version<72||r.getConfiguration&&r.getConfiguration().sdpSemantics==="plan-b")||r.signalingState==="stable")return t})}var Sc=Object.freeze({__proto__:null,shimMediaStream:ed,shimOnTrack:td,shimGetSendersWithDtmf:nd,shimGetStats:rd,shimSenderReceiverGetStats:id,shimAddTrackRemoveTrackWithNative:sd,shimAddTrackRemoveTrack:od,shimPeerConnection:Gs,fixNegotiationNeeded:ad,shimGetUserMedia:Zu,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"))}}),Ic,ns,Z=(Ic=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(`
  819. `).map(function(r){return r.trim()})},e.splitSections=function(t){return t.split(`
  820. m=`).map(function(r,i){return(i>0?"m="+r:r).trim()+`\r
  821. `})},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;s<r.length;s+=2)switch(r[s]){case"raddr":i.relatedAddress=r[s+1];break;case"rport":i.relatedPort=parseInt(r[s+1],10);break;case"tcptype":i.tcpType=r[s+1];break;case"ufrag":i.ufrag=r[s+1],i.usernameFragment=r[s+1];break;default:i[r[s]]=r[s+1]}return i},e.writeCandidate=function(t){var r=[];r.push(t.foundation),r.push(t.component),r.push(t.protocol.toUpperCase()),r.push(t.priority),r.push(t.address||t.ip),r.push(t.port);var i=t.type;return r.push("typ"),r.push(i),i!=="host"&&t.relatedAddress&&t.relatedPort&&(r.push("raddr"),r.push(t.relatedAddress),r.push("rport"),r.push(t.relatedPort)),t.tcpType&&t.protocol.toLowerCase()==="tcp"&&(r.push("tcptype"),r.push(t.tcpType)),(t.usernameFragment||t.ufrag)&&(r.push("ufrag"),r.push(t.usernameFragment||t.ufrag)),"candidate:"+r.join(" ")},e.parseIceOptions=function(t){return t.substr(14).split(" ")},e.parseRtpMap=function(t){var r=t.substr(9).split(" "),i={payloadType:parseInt(r.shift(),10)};return r=r[0].split("/"),i.name=r[0],i.clockRate=parseInt(r[1],10),i.channels=r.length===3?parseInt(r[2],10):1,i.numChannels=i.channels,i},e.writeRtpMap=function(t){var r=t.payloadType;t.preferredPayloadType!==void 0&&(r=t.preferredPayloadType);var i=t.channels||t.numChannels||1;return"a=rtpmap:"+r+" "+t.name+"/"+t.clockRate+(i!==1?"/"+i:"")+`\r
  822. `},e.parseExtmap=function(t){var r=t.substr(9).split(" ");return{id:parseInt(r[0],10),direction:r[0].indexOf("/")>0?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
  823. `},e.parseFmtp=function(t){for(var r,i={},s=t.substr(t.indexOf(" ")+1).split(";"),o=0;o<s.length;o++)i[(r=s[o].trim().split("="))[0].trim()]=r[1];return i},e.writeFmtp=function(t){var r="",i=t.payloadType;if(t.preferredPayloadType!==void 0&&(i=t.preferredPayloadType),t.parameters&&Object.keys(t.parameters).length){var s=[];Object.keys(t.parameters).forEach(function(o){t.parameters[o]?s.push(o+"="+t.parameters[o]):s.push(o)}),r+="a=fmtp:"+i+" "+s.join(";")+`\r
  824. `}return r},e.parseRtcpFb=function(t){var r=t.substr(t.indexOf(" ")+1).split(" ");return{type:r.shift(),parameter:r.join(" ")}},e.writeRtcpFb=function(t){var r="",i=t.payloadType;return t.preferredPayloadType!==void 0&&(i=t.preferredPayloadType),t.rtcpFeedback&&t.rtcpFeedback.length&&t.rtcpFeedback.forEach(function(s){r+="a=rtcp-fb:"+i+" "+s.type+(s.parameter&&s.parameter.length?" "+s.parameter:"")+`\r
  825. `}),r},e.parseSsrcMedia=function(t){var r=t.indexOf(" "),i={ssrc:parseInt(t.substr(7,r-7),10)},s=t.indexOf(":",r);return s>-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
  826. `;return t.fingerprints.forEach(function(s){i+="a=fingerprint:"+s.algorithm+" "+s.value+`\r
  827. `}),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
  828. `},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
  829. a=ice-pwd:`+t.password+`\r
  830. `},e.parseRtpParameters=function(t){for(var r={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},i=e.splitLines(t)[0].split(" "),s=3;s<i.length;s++){var o=i[s],c=e.matchPrefix(t,"a=rtpmap:"+o+" ")[0];if(c){var d=e.parseRtpMap(c),l=e.matchPrefix(t,"a=fmtp:"+o+" ");switch(d.parameters=l.length?e.parseFmtp(l[0]):{},d.rtcpFeedback=e.matchPrefix(t,"a=rtcp-fb:"+o+" ").map(e.parseRtcpFb),r.codecs.push(d),d.name.toUpperCase()){case"RED":case"ULPFEC":r.fecMechanisms.push(d.name.toUpperCase())}}}return e.matchPrefix(t,"a=extmap:").forEach(function(h){r.headerExtensions.push(e.parseExtmap(h))}),r},e.writeRtpDescription=function(t,r){var i="";i+="m="+t+" ",i+=r.codecs.length>0?"9":"0",i+=" UDP/TLS/RTP/SAVPF ",i+=r.codecs.map(function(o){return o.preferredPayloadType!==void 0?o.preferredPayloadType:o.payloadType}).join(" ")+`\r
  831. `,i+=`c=IN IP4 0.0.0.0\r
  832. `,i+=`a=rtcp:9 IN IP4 0.0.0.0\r
  833. `,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
  834. `),i+=`a=rtcp-mux\r
  835. `,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,c=s.fecMechanisms.indexOf("ULPFEC")!==-1,d=e.matchPrefix(t,"a=ssrc:").map(function(u){return e.parseSsrcMedia(u)}).filter(function(u){return u.attribute==="cname"}),l=d.length>0&&d[0].ssrc,h=e.matchPrefix(t,"a=ssrc-group:FID").map(function(u){return u.substr(17).split(" ").map(function(f){return parseInt(f,10)})});h.length>0&&h[0].length>1&&h[0][0]===l&&(r=h[0][1]),s.codecs.forEach(function(u){if(u.name.toUpperCase()==="RTX"&&u.parameters.apt){var f={ssrc:l,codecPayloadType:parseInt(u.parameters.apt,10)};l&&r&&(f.rtx={ssrc:r}),i.push(f),o&&((f=JSON.parse(JSON.stringify(f))).fec={ssrc:l,mechanism:c?"red+ulpfec":"red"},i.push(f))}}),i.length===0&&l&&i.push({ssrc:l});var a=e.matchPrefix(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(u){u.maxBitrate=a})),i},e.parseRtcpParameters=function(t){var r={},i=e.matchPrefix(t,"a=ssrc:").map(function(c){return e.parseSsrcMedia(c)}).filter(function(c){return c.attribute==="cname"})[0];i&&(r.cname=i.value,r.ssrc=i.ssrc);var 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 c=e.matchPrefix(t,"a=sctpmap:")[0].substr(10).split(" ");return{port:parseInt(c[0],10),protocol:c[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
  836. `,`c=IN IP4 0.0.0.0\r
  837. `,"a=sctp-port:"+r.port+`\r
  838. `]:["m="+t.kind+" 9 "+t.protocol+" "+r.port+`\r
  839. `,`c=IN IP4 0.0.0.0\r
  840. `,"a=sctpmap:"+r.port+" "+r.protocol+` 65535\r
  841. `],r.maxMessageSize!==void 0&&i.push("a=max-message-size:"+r.maxMessageSize+`\r
  842. `),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
  843. o=`+(i||"thisisadapterortc")+" "+(t||e.generateSessionId())+" "+s+` IN IP4 127.0.0.1\r
  844. s=-\r
  845. t=0 0\r
  846. `},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
  847. `,t.direction?o+="a="+t.direction+`\r
  848. `:t.rtpSender&&t.rtpReceiver?o+=`a=sendrecv\r
  849. `:t.rtpSender?o+=`a=sendonly\r
  850. `:t.rtpReceiver?o+=`a=recvonly\r
  851. `:o+=`a=inactive\r
  852. `,t.rtpSender){var c="msid:"+s.id+" "+t.rtpSender.track.id+`\r
  853. `;o+="a="+c,o+="a=ssrc:"+t.sendEncodingParameters[0].ssrc+" "+c,t.sendEncodingParameters[0].rtx&&(o+="a=ssrc:"+t.sendEncodingParameters[0].rtx.ssrc+" "+c,o+="a=ssrc-group:FID "+t.sendEncodingParameters[0].ssrc+" "+t.sendEncodingParameters[0].rtx.ssrc+`\r
  854. `)}return o+="a=ssrc:"+t.sendEncodingParameters[0].ssrc+" cname:"+e.localCName+`\r
  855. `,t.rtpSender&&t.sendEncodingParameters[0].rtx&&(o+="a=ssrc:"+t.sendEncodingParameters[0].rtx.ssrc+" cname:"+e.localCName+`\r
  856. `),o},e.getDirection=function(t,r){for(var i=e.splitLines(t),s=0;s<i.length;s++)switch(i[s]){case"a=sendrecv":case"a=sendonly":case"a=recvonly":case"a=inactive":return i[s].substr(2)}return r?e.getDirection(r):"sendrecv"},e.getKind=function(t){return e.splitLines(t)[0].split(" ")[0].substr(2)},e.isRejected=function(t){return t.split(" ",2)[1]==="0"},e.parseMLine=function(t){var r=e.splitLines(t)[0].substr(2).split(" ");return{kind:r[0],port:parseInt(r[1],10),protocol:r[2],fmt:r.slice(3).join(" ")}},e.parseOLine=function(t){var r=e.matchPrefix(t,"o=")[0].substr(2).split(" ");return{username:r[0],sessionId:r[1],sessionVersion:parseInt(r[2],10),netType:r[3],addressType:r[4],address:r[5]}},e.isValidSDP=function(t){if(typeof t!="string"||t.length===0)return!1;for(var r=e.splitLines(t),i=0;i<r.length;i++)if(r[i].length<2||r[i].charAt(1)!=="=")return!1;return!0},n.exports=e},Ic(ns={exports:{}},ns.exports),ns.exports);function bc(n,e,t,r,i){var s=Z.writeRtpDescription(n.kind,e);if(s+=Z.writeIceParameters(n.iceGatherer.getLocalParameters()),s+=Z.writeDtlsParameters(n.dtlsTransport.getLocalParameters(),t==="offer"?"actpass":i||"active"),s+="a=mid:"+n.mid+`\r
  857. `,n.rtpSender&&n.rtpReceiver?s+=`a=sendrecv\r
  858. `:n.rtpSender?s+=`a=sendonly\r
  859. `:n.rtpReceiver?s+=`a=recvonly\r
  860. `:s+=`a=inactive\r
  861. `,n.rtpSender){var o=n.rtpSender._initialTrackId||n.rtpSender.track.id;n.rtpSender._initialTrackId=o;var c="msid:"+(r?r.id:"-")+" "+o+`\r
  862. `;s+="a="+c,s+="a=ssrc:"+n.sendEncodingParameters[0].ssrc+" "+c,n.sendEncodingParameters[0].rtx&&(s+="a=ssrc:"+n.sendEncodingParameters[0].rtx.ssrc+" "+c,s+="a=ssrc-group:FID "+n.sendEncodingParameters[0].ssrc+" "+n.sendEncodingParameters[0].rtx.ssrc+`\r
  863. `)}return s+="a=ssrc:"+n.sendEncodingParameters[0].ssrc+" cname:"+Z.localCName+`\r
  864. `,n.rtpSender&&n.sendEncodingParameters[0].rtx&&(s+="a=ssrc:"+n.sendEncodingParameters[0].rtx.ssrc+" cname:"+Z.localCName+`\r
  865. `),s}function Nr(n,e){var t={codecs:[],headerExtensions:[],fecMechanisms:[]},r=function(s,o){s=parseInt(s,10);for(var c=0;c<o.length;c++)if(o[c].payloadType===s||o[c].preferredPayloadType===s)return o[c]},i=function(s,o,c,d){var l=r(s.parameters.apt,c),h=r(o.parameters.apt,d);return l&&h&&l.name.toLowerCase()===h.name.toLowerCase()};return n.codecs.forEach(function(s){for(var o=0;o<e.codecs.length;o++){var c=e.codecs[o];if(s.name.toLowerCase()===c.name.toLowerCase()&&s.clockRate===c.clockRate){if(s.name.toLowerCase()==="rtx"&&s.parameters&&c.parameters.apt&&!i(s,c,n.codecs,e.codecs))continue;(c=JSON.parse(JSON.stringify(c))).numChannels=Math.min(s.numChannels,c.numChannels),t.codecs.push(c),c.rtcpFeedback=c.rtcpFeedback.filter(function(d){for(var l=0;l<s.rtcpFeedback.length;l++)if(s.rtcpFeedback[l].type===d.type&&s.rtcpFeedback[l].parameter===d.parameter)return!0;return!1});break}}}),n.headerExtensions.forEach(function(s){for(var o=0;o<e.headerExtensions.length;o++){var c=e.headerExtensions[o];if(s.uri===c.uri){t.headerExtensions.push(c);break}}}),t}function wc(n,e,t){return{offer:{setLocalDescription:["stable","have-local-offer"],setRemoteDescription:["stable","have-remote-offer"]},answer:{setLocalDescription:["have-remote-offer","have-local-pranswer"],setRemoteDescription:["have-local-offer","have-remote-pranswer"]}}[e][n].indexOf(t)!==-1}function rs(n,e){var t=n.getRemoteCandidates().find(function(r){return e.foundation===r.foundation&&e.ip===r.ip&&e.port===r.port&&e.priority===r.priority&&e.protocol===r.protocol&&e.type===r.type});return t||n.addRemoteCandidate(e),!t}function Ve(n,e){var t=new Error(e);return t.name=n,t.code={NotSupportedError:9,InvalidStateError:11,InvalidAccessError:15,TypeError:void 0,OperationError:void 0}[n],t}var Rf=function(n,e){function t(o,c){c.addTrack(o),c.dispatchEvent(new n.MediaStreamTrackEvent("addtrack",{track:o}))}function r(o,c,d,l){var h=new Event("track");h.track=c,h.receiver=d,h.transceiver={receiver:d},h.streams=l,n.setTimeout(function(){o._dispatchEvent("track",h)})}var i=function(o){var c=this,d=document.createDocumentFragment();if(["addEventListener","removeEventListener","dispatchEvent"].forEach(function(h){c[h]=d[h].bind(d)}),this.canTrickleIceCandidates=null,this.needNegotiation=!1,this.localStreams=[],this.remoteStreams=[],this._localDescription=null,this._remoteDescription=null,this.signalingState="stable",this.iceConnectionState="new",this.connectionState="new",this.iceGatheringState="new",o=JSON.parse(JSON.stringify(o||{})),this.usingBundle=o.bundlePolicy==="max-bundle",o.rtcpMuxPolicy==="negotiate")throw Ve("NotSupportedError","rtcpMuxPolicy 'negotiate' is not supported");switch(o.rtcpMuxPolicy||(o.rtcpMuxPolicy="require"),o.iceTransportPolicy){case"all":case"relay":break;default:o.iceTransportPolicy="all"}switch(o.bundlePolicy){case"balanced":case"max-compat":case"max-bundle":break;default:o.bundlePolicy="balanced"}if(o.iceServers=function(h,a){var u=!1;return(h=JSON.parse(JSON.stringify(h))).filter(function(f){if(f&&(f.urls||f.url)){var p=f.urls||f.url;f.url&&!f.urls&&console.warn("RTCIceServer.url is deprecated! Use urls instead.");var m=typeof p=="string";return m&&(p=[p]),p=p.filter(function(_){return _.indexOf("turn:")!==0||_.indexOf("transport=udp")===-1||_.indexOf("turn:[")!==-1||u?_.indexOf("stun:")===0&&a>=14393&&_.indexOf("?transport=udp")===-1:(u=!0,!0)}),delete f.url,f.urls=m?p[0]:p,!!p.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=Z.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,c){this._isClosed||(this.dispatchEvent(c),typeof this["on"+o]=="function"&&this["on"+o](c))},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,c){var d=this.transceivers.length>0,l={track:null,iceGatherer:null,iceTransport:null,dtlsTransport:null,localCapabilities:null,remoteCapabilities:null,rtpSender:null,rtpReceiver:null,kind: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 c||this.transceivers.push(l),l},i.prototype.addTrack=function(o,c){if(this._isClosed)throw Ve("InvalidStateError","Attempted to call addTrack on a closed peerconnection.");var d;if(this.transceivers.find(function(h){return h.track===o}))throw Ve("InvalidAccessError","Track already exists.");for(var l=0;l<this.transceivers.length;l++)this.transceivers[l].track||this.transceivers[l].kind!==o.kind||(d=this.transceivers[l]);return d||(d=this._createTransceiver(o.kind)),this._maybeFireNegotiationNeeded(),this.localStreams.indexOf(c)===-1&&this.localStreams.push(c),d.track=o,d.stream=c,d.rtpSender=new n.RTCRtpSender(o,d.dtlsTransport),d.rtpSender},i.prototype.addStream=function(o){var c=this;if(e>=15025)o.getTracks().forEach(function(l){c.addTrack(l,o)});else{var d=o.clone();o.getTracks().forEach(function(l,h){var a=d.getTracks()[h];l.addEventListener("enabled",function(u){a.enabled=u.enabled})}),d.getTracks().forEach(function(l){c.addTrack(l,d)})}},i.prototype.removeTrack=function(o){if(this._isClosed)throw Ve("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 c=this.transceivers.find(function(l){return l.rtpSender===o});if(!c)throw Ve("InvalidAccessError","Sender was not created by this connection.");var d=c.stream;c.rtpSender.stop(),c.rtpSender=null,c.track=null,c.stream=null,this.transceivers.map(function(l){return l.stream}).indexOf(d)===-1&&this.localStreams.indexOf(d)>-1&&this.localStreams.splice(this.localStreams.indexOf(d),1),this._maybeFireNegotiationNeeded()},i.prototype.removeStream=function(o){var c=this;o.getTracks().forEach(function(d){var l=c.getSenders().find(function(h){return h.track===d});l&&c.removeTrack(l)})},i.prototype.getSenders=function(){return this.transceivers.filter(function(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,c){var d=this;if(c&&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,c){var d=this,l=this.transceivers[c].iceGatherer;if(!l.onlocalcandidate){var h=this.transceivers[c].bufferedCandidateEvents;this.transceivers[c].bufferedCandidateEvents=null,l.removeEventListener("localcandidate",this.transceivers[c].bufferCandidates),l.onlocalcandidate=function(a){if(!(d.usingBundle&&c>0)){var u=new Event("icecandidate");u.candidate={sdpMid:o,sdpMLineIndex:c};var f=a.candidate,p=!f||Object.keys(f).length===0;if(p)l.state!=="new"&&l.state!=="gathering"||(l.state="completed");else{l.state==="new"&&(l.state="gathering"),f.component=1,f.ufrag=l.getLocalParameters().usernameFragment;var m=Z.writeCandidate(f);u.candidate=Object.assign(u.candidate,Z.parseCandidate(m)),u.candidate.candidate=m,u.candidate.toJSON=function(){return{candidate:u.candidate.candidate,sdpMid:u.candidate.sdpMid,sdpMLineIndex:u.candidate.sdpMLineIndex,usernameFragment:u.candidate.usernameFragment}}}var _=Z.getMediaSections(d._localDescription.sdp);_[u.candidate.sdpMLineIndex]+=p?`a=end-of-candidates\r
  866. `:"a="+u.candidate.candidate+`\r
  867. `,d._localDescription.sdp=Z.getDescription(d._localDescription.sdp)+_.join("");var v=d.transceivers.every(function(y){return y.iceGatherer&&y.iceGatherer.state==="completed"});d.iceGatheringState!=="gathering"&&(d.iceGatheringState="gathering",d._emitGatheringStateChange()),p||d._dispatchEvent("icecandidate",u),v&&(d._dispatchEvent("icecandidate",new Event("icecandidate")),d.iceGatheringState="complete",d._emitGatheringStateChange())}},n.setTimeout(function(){h.forEach(function(a){l.onlocalcandidate(a)})},0)}},i.prototype._createIceAndDtlsTransports=function(){var o=this,c=new n.RTCIceTransport(null);c.onicestatechange=function(){o._updateIceConnectionState(),o._updateConnectionState()};var d=new n.RTCDtlsTransport(c);return d.ondtlsstatechange=function(){o._updateConnectionState()},d.onerror=function(){Object.defineProperty(d,"state",{value:"failed",writable:!0}),o._updateConnectionState()},{iceTransport:c,dtlsTransport:d}},i.prototype._disposeIceAndDtlsTransports=function(o){var c=this.transceivers[o].iceGatherer;c&&(delete c.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,c,d){var l=Nr(o.localCapabilities,o.remoteCapabilities);c&&o.rtpSender&&(l.encodings=o.sendEncodingParameters,l.rtcp={cname:Z.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 c,d,l=this;if(["offer","answer"].indexOf(o.type)===-1)return Promise.reject(Ve("TypeError",'Unsupported type "'+o.type+'"'));if(!wc("setLocalDescription",o.type,l.signalingState)||l._isClosed)return Promise.reject(Ve("InvalidStateError","Can not set local "+o.type+" in state "+l.signalingState));if(o.type==="offer")c=Z.splitSections(o.sdp),d=c.shift(),c.forEach(function(a,u){var f=Z.parseRtpParameters(a);l.transceivers[u].localCapabilities=f}),l.transceivers.forEach(function(a,u){l._gather(a.mid,u)});else if(o.type==="answer"){c=Z.splitSections(l._remoteDescription.sdp),d=c.shift();var h=Z.matchPrefix(d,"a=ice-lite").length>0;c.forEach(function(a,u){var f=l.transceivers[u],p=f.iceGatherer,m=f.iceTransport,_=f.dtlsTransport,v=f.localCapabilities,y=f.remoteCapabilities;if(!(Z.isRejected(a)&&Z.matchPrefix(a,"a=bundle-only").length===0)&&!f.rejected){var C=Z.getIceParameters(a,d),b=Z.getDtlsParameters(a,d);h&&(b.role="server"),l.usingBundle&&u!==0||(l._gather(f.mid,u),m.state==="new"&&m.start(p,C,h?"controlling":"controlled"),_.state==="new"&&_.start(b));var O=Nr(v,y);l._transceive(f,O.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 c=this;if(["offer","answer"].indexOf(o.type)===-1)return Promise.reject(Ve("TypeError",'Unsupported type "'+o.type+'"'));if(!wc("setRemoteDescription",o.type,c.signalingState)||c._isClosed)return Promise.reject(Ve("InvalidStateError","Can not set remote "+o.type+" in state "+c.signalingState));var d={};c.remoteStreams.forEach(function(m){d[m.id]=m});var l=[],h=Z.splitSections(o.sdp),a=h.shift(),u=Z.matchPrefix(a,"a=ice-lite").length>0,f=Z.matchPrefix(a,"a=group:BUNDLE ").length>0;c.usingBundle=f;var p=Z.matchPrefix(a,"a=ice-options:")[0];return c.canTrickleIceCandidates=!!p&&p.substr(14).split(" ").indexOf("trickle")>=0,h.forEach(function(m,_){var v=Z.splitLines(m),y=Z.getKind(m),C=Z.isRejected(m)&&Z.matchPrefix(m,"a=bundle-only").length===0,b=v[0].substr(2).split(" ")[2],O=Z.getDirection(m,a),S=Z.parseMsid(m),E=Z.getMid(m)||Z.generateIdentifier();if(C||y==="application"&&(b==="DTLS/SCTP"||b==="UDP/DTLS/SCTP"))c.transceivers[_]={mid:E,kind:y,protocol:b,rejected:!0};else{var w,V,j,R,T,A,L,k,F;!C&&c.transceivers[_]&&c.transceivers[_].rejected&&(c.transceivers[_]=c._createTransceiver(y,!0));var H,G,W=Z.parseRtpParameters(m);C||(H=Z.getIceParameters(m,a),(G=Z.getDtlsParameters(m,a)).role="client"),L=Z.parseRtpEncodingParameters(m);var oe=Z.parseRtcpParameters(m),he=Z.matchPrefix(m,"a=end-of-candidates",a).length>0,de=Z.matchPrefix(m,"a=candidate:").map(function(U){return Z.parseCandidate(U)}).filter(function(U){return U.component===1});if((o.type==="offer"||o.type==="answer")&&!C&&f&&_>0&&c.transceivers[_]&&(c._disposeIceAndDtlsTransports(_),c.transceivers[_].iceGatherer=c.transceivers[0].iceGatherer,c.transceivers[_].iceTransport=c.transceivers[0].iceTransport,c.transceivers[_].dtlsTransport=c.transceivers[0].dtlsTransport,c.transceivers[_].rtpSender&&c.transceivers[_].rtpSender.setTransport(c.transceivers[0].dtlsTransport),c.transceivers[_].rtpReceiver&&c.transceivers[_].rtpReceiver.setTransport(c.transceivers[0].dtlsTransport)),o.type!=="offer"||C)o.type==="answer"&&!C&&(V=(w=c.transceivers[_]).iceGatherer,j=w.iceTransport,R=w.dtlsTransport,T=w.rtpReceiver,A=w.sendEncodingParameters,k=w.localCapabilities,c.transceivers[_].recvEncodingParameters=L,c.transceivers[_].remoteCapabilities=W,c.transceivers[_].rtcpParameters=oe,de.length&&j.state==="new"&&(!u&&!he||f&&_!==0?de.forEach(function(U){rs(w.iceTransport,U)}):j.setRemoteCandidates(de)),f&&_!==0||(j.state==="new"&&j.start(V,H,"controlling"),R.state==="new"&&R.start(G)),!Nr(w.localCapabilities,w.remoteCapabilities).codecs.filter(function(U){return U.name.toLowerCase()==="rtx"}).length&&w.sendEncodingParameters[0].rtx&&delete w.sendEncodingParameters[0].rtx,c._transceive(w,O==="sendrecv"||O==="recvonly",O==="sendrecv"||O==="sendonly"),!T||O!=="sendrecv"&&O!=="sendonly"?delete w.rtpReceiver:(F=T.track,S?(d[S.stream]||(d[S.stream]=new n.MediaStream),t(F,d[S.stream]),l.push([F,T,d[S.stream]])):(d.default||(d.default=new n.MediaStream),t(F,d.default),l.push([F,T,d.default]))));else{(w=c.transceivers[_]||c._createTransceiver(y)).mid=E,w.iceGatherer||(w.iceGatherer=c._createIceGatherer(_,f)),de.length&&w.iceTransport.state==="new"&&(!he||f&&_!==0?de.forEach(function(U){rs(w.iceTransport,U)}):w.iceTransport.setRemoteCandidates(de)),k=n.RTCRtpReceiver.getCapabilities(y),e<15019&&(k.codecs=k.codecs.filter(function(U){return U.name!=="rtx"})),A=w.sendEncodingParameters||[{ssrc:1001*(2*_+2)}];var ae,te=!1;O==="sendrecv"||O==="sendonly"?(te=!w.rtpReceiver,T=w.rtpReceiver||new n.RTCRtpReceiver(w.dtlsTransport,y),te&&(F=T.track,S&&S.stream==="-"||(S?(d[S.stream]||(d[S.stream]=new n.MediaStream,Object.defineProperty(d[S.stream],"id",{get:function(){return S.stream}})),Object.defineProperty(F,"id",{get:function(){return S.track}}),ae=d[S.stream]):(d.default||(d.default=new n.MediaStream),ae=d.default)),ae&&(t(F,ae),w.associatedRemoteMediaStreams.push(ae)),l.push([F,T,ae]))):w.rtpReceiver&&w.rtpReceiver.track&&(w.associatedRemoteMediaStreams.forEach(function(U){var J=U.getTracks().find(function(ee){return ee.id===w.rtpReceiver.track.id});J&&function(ee,ie){ie.removeTrack(ee),ie.dispatchEvent(new n.MediaStreamTrackEvent("removetrack",{track:ee}))}(J,U)}),w.associatedRemoteMediaStreams=[]),w.localCapabilities=k,w.remoteCapabilities=W,w.rtpReceiver=T,w.rtcpParameters=oe,w.sendEncodingParameters=A,w.recvEncodingParameters=L,c._transceive(c.transceivers[_],!1,te)}}}),c._dtlsRole===void 0&&(c._dtlsRole=o.type==="offer"?"active":"passive"),c._remoteDescription={type:o.type,sdp:o.sdp},o.type==="offer"?c._updateSignalingState("have-remote-offer"):c._updateSignalingState("stable"),Object.keys(d).forEach(function(m){var _=d[m];if(_.getTracks().length){if(c.remoteStreams.indexOf(_)===-1){c.remoteStreams.push(_);var v=new Event("addstream");v.stream=_,n.setTimeout(function(){c._dispatchEvent("addstream",v)})}l.forEach(function(y){var C=y[0],b=y[1];_.id===y[2].id&&r(c,C,b,[_])})}}),l.forEach(function(m){m[2]||r(c,m[0],m[1],[])}),n.setTimeout(function(){c&&c.transceivers&&c.transceivers.forEach(function(m){m.iceTransport&&m.iceTransport.state==="new"&&m.iceTransport.getRemoteCandidates().length>0&&(console.warn("Timeout for addRemoteCandidate. Consider sending an end-of-candidates notification"),m.iceTransport.addRemoteCandidate({}))})},4e3),Promise.resolve()},i.prototype.close=function(){this.transceivers.forEach(function(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 c=new Event("signalingstatechange");this._dispatchEvent("signalingstatechange",c)},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 c=new Event("negotiationneeded");o._dispatchEvent("negotiationneeded",c)}},0))},i.prototype._updateIceConnectionState=function(){var o,c={new:0,closed:0,checking:0,connected:0,completed:0,disconnected:0,failed:0};if(this.transceivers.forEach(function(l){l.iceTransport&&!l.rejected&&c[l.iceTransport.state]++}),o="new",c.failed>0?o="failed":c.checking>0?o="checking":c.disconnected>0?o="disconnected":c.new>0?o="new":c.connected>0?o="connected":c.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,c={new:0,closed:0,connecting:0,connected:0,completed:0,disconnected:0,failed:0};if(this.transceivers.forEach(function(l){l.iceTransport&&l.dtlsTransport&&!l.rejected&&(c[l.iceTransport.state]++,c[l.dtlsTransport.state]++)}),c.connected+=c.completed,o="new",c.failed>0?o="failed":c.connecting>0?o="connecting":c.disconnected>0?o="disconnected":c.new>0?o="new":c.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(Ve("InvalidStateError","Can not call createOffer after close"));var c=o.transceivers.filter(function(u){return u.kind==="audio"}).length,d=o.transceivers.filter(function(u){return u.kind==="video"}).length,l=arguments[0];if(l){if(l.mandatory||l.optional)throw new TypeError("Legacy mandatory/optional constraints not supported.");l.offerToReceiveAudio!==void 0&&(c=l.offerToReceiveAudio===!0?1:l.offerToReceiveAudio===!1?0:l.offerToReceiveAudio),l.offerToReceiveVideo!==void 0&&(d=l.offerToReceiveVideo===!0?1:l.offerToReceiveVideo===!1?0:l.offerToReceiveVideo)}for(o.transceivers.forEach(function(u){u.kind==="audio"?--c<0&&(u.wantReceive=!1):u.kind==="video"&&--d<0&&(u.wantReceive=!1)});c>0||d>0;)c>0&&(o._createTransceiver("audio"),c--),d>0&&(o._createTransceiver("video"),d--);var h=Z.writeSessionBoilerplate(o._sdpSessionId,o._sdpSessionVersion++);o.transceivers.forEach(function(u,f){var p=u.track,m=u.kind,_=u.mid||Z.generateIdentifier();u.mid=_,u.iceGatherer||(u.iceGatherer=o._createIceGatherer(f,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"),u.remoteCapabilities&&u.remoteCapabilities.codecs&&u.remoteCapabilities.codecs.forEach(function(b){C.name.toLowerCase()===b.name.toLowerCase()&&C.clockRate===b.clockRate&&(C.preferredPayloadType=b.payloadType)})}),v.headerExtensions.forEach(function(C){(u.remoteCapabilities&&u.remoteCapabilities.headerExtensions||[]).forEach(function(b){C.uri===b.uri&&(C.id=b.id)})});var y=u.sendEncodingParameters||[{ssrc:1001*(2*f+1)}];p&&e>=15019&&m==="video"&&!y[0].rtx&&(y[0].rtx={ssrc:y[0].ssrc+1}),u.wantReceive&&(u.rtpReceiver=new n.RTCRtpReceiver(u.dtlsTransport,m)),u.localCapabilities=v,u.sendEncodingParameters=y}),o._config.bundlePolicy!=="max-compat"&&(h+="a=group:BUNDLE "+o.transceivers.map(function(u){return u.mid}).join(" ")+`\r
  868. `),h+=`a=ice-options:trickle\r
  869. `,o.transceivers.forEach(function(u,f){h+=bc(u,u.localCapabilities,"offer",u.stream,o._dtlsRole),h+=`a=rtcp-rsize\r
  870. `,!u.iceGatherer||o.iceGatheringState==="new"||f!==0&&o.usingBundle||(u.iceGatherer.getLocalCandidates().forEach(function(p){p.component=1,h+="a="+Z.writeCandidate(p)+`\r
  871. `}),u.iceGatherer.state==="completed"&&(h+=`a=end-of-candidates\r
  872. `))});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(Ve("InvalidStateError","Can not call createAnswer after close"));if(o.signalingState!=="have-remote-offer"&&o.signalingState!=="have-local-pranswer")return Promise.reject(Ve("InvalidStateError","Can not call createAnswer in signalingState "+o.signalingState));var c=Z.writeSessionBoilerplate(o._sdpSessionId,o._sdpSessionVersion++);o.usingBundle&&(c+="a=group:BUNDLE "+o.transceivers.map(function(h){return h.mid}).join(" ")+`\r
  873. `),c+=`a=ice-options:trickle\r
  874. `;var d=Z.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"?c+=`m=application 0 DTLS/SCTP 5000\r
  875. `:c+="m=application 0 "+h.protocol+` webrtc-datachannel\r
  876. `:h.kind==="audio"?c+=`m=audio 0 UDP/TLS/RTP/SAVPF 0\r
  877. a=rtpmap:0 PCMU/8000\r
  878. `:h.kind==="video"&&(c+=`m=video 0 UDP/TLS/RTP/SAVPF 120\r
  879. a=rtpmap:120 VP8/90000\r
  880. `),void(c+=`c=IN IP4 0.0.0.0\r
  881. a=inactive\r
  882. a=mid:`+h.mid+`\r
  883. `);var u;h.stream&&(h.kind==="audio"?u=h.stream.getAudioTracks()[0]:h.kind==="video"&&(u=h.stream.getVideoTracks()[0]),u&&e>=15019&&h.kind==="video"&&!h.sendEncodingParameters[0].rtx&&(h.sendEncodingParameters[0].rtx={ssrc:h.sendEncodingParameters[0].ssrc+1}));var f=Nr(h.localCapabilities,h.remoteCapabilities);!f.codecs.filter(function(p){return p.name.toLowerCase()==="rtx"}).length&&h.sendEncodingParameters[0].rtx&&delete h.sendEncodingParameters[0].rtx,c+=bc(h,f,"answer",h.stream,o._dtlsRole),h.rtcpParameters&&h.rtcpParameters.reducedSize&&(c+=`a=rtcp-rsize\r
  884. `)}});var l=new n.RTCSessionDescription({type:"answer",sdp:c});return Promise.resolve(l)},i.prototype.addIceCandidate=function(o){var c,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(Ve("InvalidStateError","Can not add ICE candidate without a remote description"));if(o&&o.candidate!==""){var a=o.sdpMLineIndex;if(o.sdpMid){for(var u=0;u<d.transceivers.length;u++)if(d.transceivers[u].mid===o.sdpMid){a=u;break}}var f=d.transceivers[a];if(!f)return h(Ve("OperationError","Can not add ICE candidate"));if(f.rejected)return l();var p=Object.keys(o.candidate).length>0?Z.parseCandidate(o.candidate):{};if(p.protocol==="tcp"&&(p.port===0||p.port===9)||p.component&&p.component!==1)return l();if((a===0||a>0&&f.iceTransport!==d.transceivers[0].iceTransport)&&!rs(f.iceTransport,p))return h(Ve("OperationError","Can not add ICE candidate"));var m=o.candidate.trim();m.indexOf("a=")===0&&(m=m.substr(2)),(c=Z.getMediaSections(d._remoteDescription.sdp))[a]+="a="+(p.type?m:"end-of-candidates")+`\r
  885. `,d._remoteDescription.sdp=Z.getDescription(d._remoteDescription.sdp)+c.join("")}else for(var _=0;_<d.transceivers.length&&(d.transceivers[_].rejected||(d.transceivers[_].iceTransport.addRemoteCandidate({}),(c=Z.getMediaSections(d._remoteDescription.sdp))[_]+=`a=end-of-candidates\r
  886. `,d._remoteDescription.sdp=Z.getDescription(d._remoteDescription.sdp)+c.join(""),!d.usingBundle));_++);l()})},i.prototype.getStats=function(o){if(o&&o instanceof n.MediaStreamTrack){var c=null;if(this.transceivers.forEach(function(l){l.rtpSender&&l.rtpSender.track===o?c=l.rtpSender:l.rtpReceiver&&l.rtpReceiver.track===o&&(c=l.rtpReceiver)}),!c)throw Ve("InvalidAccessError","Invalid selector.");return c.getStats()}var d=[];return this.transceivers.forEach(function(l){["rtpSender","rtpReceiver","iceGatherer","iceTransport","dtlsTransport"].forEach(function(h){l[h]&&d.push(l[h].getStats())})}),Promise.all(d).then(function(l){var h=new Map;return l.forEach(function(a){a.forEach(function(u){h.set(u.id,u)})}),h})},["RTCRtpSender","RTCRtpReceiver","RTCIceGatherer","RTCIceTransport","RTCDtlsTransport"].forEach(function(o){var c=n[o];if(c&&c.prototype&&c.prototype.getStats){var d=c.prototype.getStats;c.prototype.getStats=function(){return d.apply(this).then(function(l){var h=new Map;return Object.keys(l).forEach(function(a){var u;l[a].type={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[(u=l[a]).type]||u.type,h.set(a,l[a])}),h})}}});var s=["createOffer","createAnswer"];return s.forEach(function(o){var c=i.prototype[o];i.prototype[o]=function(){var d=arguments;return typeof d[0]=="function"||typeof d[1]=="function"?c.apply(this,[arguments[2]]).then(function(l){typeof d[0]=="function"&&d[0].apply(null,[l])},function(l){typeof d[1]=="function"&&d[1].apply(null,[l])}):c.apply(this,arguments)}}),(s=["setLocalDescription","setRemoteDescription","addIceCandidate"]).forEach(function(o){var c=i.prototype[o];i.prototype[o]=function(){var d=arguments;return typeof d[1]=="function"||typeof d[2]=="function"?c.apply(this,arguments).then(function(){typeof d[1]=="function"&&d[1].apply(null)},function(l){typeof d[2]=="function"&&d[2].apply(null,[l])}):c.apply(this,arguments)}}),["getStats"].forEach(function(o){var c=i.prototype[o];i.prototype[o]=function(){var d=arguments;return typeof d[1]=="function"?c.apply(this,arguments).then(function(){typeof d[1]=="function"&&d[1].apply(null)}):c.apply(this,arguments)}}),i};function cd(n){const e=n&&n.navigator,t=e.mediaDevices.getUserMedia.bind(e.mediaDevices);e.mediaDevices.getUserMedia=function(r){return t(r).catch(i=>Promise.reject(function(s){return{name:{PermissionDeniedError:"NotAllowedError"}[s.name]||s.name,message:s.message,constraint:s.constraint,toString(){return this.name}}}(i)))}}function ud(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 Ys(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=Rf(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(c=>{if(c&&(c.urls||c.url)){let d=c.urls||c.url;c.url&&!c.urls&&Pi("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 c.url,c.urls=l?d[0]:d,!!d.length}})}(r.iceServers,e.version),ca("ICE servers after filtering:",r.iceServers)),new t(r)},n.RTCPeerConnection.prototype=t.prototype}function dd(n){n.RTCRtpSender&&!("replaceTrack"in n.RTCRtpSender.prototype)&&(n.RTCRtpSender.prototype.replaceTrack=n.RTCRtpSender.prototype.setTrack)}var Nc=Object.freeze({__proto__:null,shimPeerConnection:Ys,shimReplaceTrack:dd,shimGetUserMedia:cd,shimGetDisplayMedia:ud});function ld(n,e){const t=n&&n.navigator,r=n&&n.MediaStreamTrack;if(t.getUserMedia=function(i,s,o){Pi("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),t.mediaDevices.getUserMedia(i).then(s,o)},!(e.version>55&&"autoGainControl"in t.mediaDevices.getSupportedConstraints())){const i=function(o,c,d){c in o&&!(d in o)&&(o[d]=o[c],delete o[c])},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 c=o.apply(this,arguments);return i(c,"mozAutoGainControl","autoGainControl"),i(c,"mozNoiseSuppression","noiseSuppression"),c}}if(r&&r.prototype.applyConstraints){const o=r.prototype.applyConstraints;r.prototype.applyConstraints=function(c){return this.kind==="audio"&&typeof c=="object"&&(c=JSON.parse(JSON.stringify(c)),i(c,"autoGainControl","mozAutoGainControl"),i(c,"noiseSuppression","mozNoiseSuppression")),o.apply(this,[c])}}}}function hd(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 Js(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(c=>{if(e.version<53&&!s)try{c.forEach(d=>{d.type=t[d.type]||d.type})}catch(d){if(d.name!=="TypeError")throw d;c.forEach((l,h)=>{c.set(h,Object.assign({},l,{type:t[l.type]||l.type}))})}return c}).then(s,o)}}function fd(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 pd(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}),Rn(n,"track",t=>(t.receiver._pc=t.srcElement,t)),n.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}function gd(n){n.RTCPeerConnection&&!("removeStream"in n.RTCPeerConnection.prototype)&&(n.RTCPeerConnection.prototype.removeStream=function(e){Pi("removeStream","removeTrack"),this.getSenders().forEach(t=>{t.track&&e.getTracks().includes(t.track)&&this.removeTrack(t)})})}function md(n){n.DataChannel&&!n.RTCDataChannel&&(n.RTCDataChannel=n.DataChannel)}function _d(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 vd(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 yd(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 Cd(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 Oc=Object.freeze({__proto__:null,shimOnTrack:hd,shimPeerConnection:Js,shimSenderGetStats:fd,shimReceiverGetStats:pd,shimRemoveStream:gd,shimRTCDataChannel:md,shimAddTransceiver:_d,shimGetParameters:vd,shimCreateOffer:yd,shimCreateAnswer:Cd,shimGetUserMedia:ld,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 Ed(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 Rd(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 Td(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 c=function(d,l,h){const a=i.apply(this,[d]);return h?(a.then(l,h),Promise.resolve()):a};e.setLocalDescription=c,c=function(d,l,h){const a=s.apply(this,[d]);return h?(a.then(l,h),Promise.resolve()):a},e.setRemoteDescription=c,c=function(d,l,h){const a=o.apply(this,[d]);return h?(a.then(l,h),Promise.resolve()):a},e.addIceCandidate=c}function Sd(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(Id(i))}!e.getUserMedia&&e.mediaDevices&&e.mediaDevices.getUserMedia&&(e.getUserMedia=function(t,r,i){e.mediaDevices.getUserMedia(t).then(r,i)}.bind(e))}function Id(n){return n&&n.video!==void 0?Object.assign({},n,{video:Xu(n.video)}):n}function bd(n){if(!n.RTCPeerConnection)return;const e=n.RTCPeerConnection;n.RTCPeerConnection=function(t,r){if(t&&t.iceServers){const i=[];for(let s=0;s<t.iceServers.length;s++){let o=t.iceServers[s];!o.hasOwnProperty("urls")&&o.hasOwnProperty("url")?(Pi("RTCIceServer.url","RTCIceServer.urls"),o=JSON.parse(JSON.stringify(o)),o.urls=o.url,delete o.url,i.push(o)):i.push(t.iceServers[s])}t.iceServers=i}return new e(t,r)},n.RTCPeerConnection.prototype=e.prototype,"generateCertificate"in e&&Object.defineProperty(n.RTCPeerConnection,"generateCertificate",{get:()=>e.generateCertificate})}function wd(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 Nd(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 Od(n){typeof n!="object"||n.AudioContext||(n.AudioContext=n.webkitAudioContext)}var Ac=Object.freeze({__proto__:null,shimLocalStreamsAPI:Ed,shimRemoteStreamsAPI:Rd,shimCallbacksAPI:Td,shimGetUserMedia:Sd,shimConstraints:Id,shimRTCIceServerUrls:bd,shimTrackEventTransceiver:wd,shimCreateOfferLegacy:Nd,shimAudioContext:Od});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=Z.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,Rn(n,"icecandidate",t=>(t.candidate&&Object.defineProperty(t,"candidate",{value:new n.RTCIceCandidate(t.candidate),writable:"false"}),t))}function xn(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(c){if(!c||!c.sdp)return!1;const d=Z.splitSections(c.sdp);return d.shift(),d.some(l=>{const h=Z.parseMLine(l);return h&&h.kind==="application"&&h.protocol.indexOf("SCTP")!==-1})},r=function(c){const d=c.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);if(d===null||d.length<2)return-1;const l=parseInt(d[1],10);return l!=l?-1:l},i=function(c){let d=65536;return e.browser==="firefox"&&(d=e.version<57?c===-1?16384:2147483637:e.version<60?e.version===57?65535:65536:2147483637),d},s=function(c,d){let l=65536;e.browser==="firefox"&&e.version===57&&(l=65535);const h=Z.matchPrefix(c.sdp,"a=max-message-size:");return h.length>0?l=parseInt(h[0].substr(19),10):e.browser==="firefox"&&d!==-1&&(l=2147483637),l},o=n.RTCPeerConnection.prototype.setRemoteDescription;n.RTCPeerConnection.prototype.setRemoteDescription=function(){if(this._sctp=null,e.browser==="chrome"&&e.version>=76){const{sdpSemantics:c}=this.getConfiguration();c==="plan-b"&&Object.defineProperty(this,"sctp",{get(){return this._sctp===void 0?null:this._sctp},enumerable:!0,configurable:!0})}if(t(arguments[0])){const c=r(arguments[0]),d=i(c),l=s(arguments[0],c);let h;h=d===0&&l===0?Number.POSITIVE_INFINITY:d===0||l===0?Math.max(d,l):Math.min(d,l);const a={};Object.defineProperty(a,"maxMessageSize",{get:()=>h}),this._sctp=a}return o.apply(this,arguments)}}function Bn(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],c=o.length||o.size||o.byteLength;if(r.readyState==="open"&&i.sctp&&c>i.sctp.maxMessageSize)throw new TypeError("Message too large (can send a maximum of "+i.sctp.maxMessageSize+" bytes)");return 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},Rn(n,"datachannel",r=>(e(r.channel,r.target),r))}function Ws(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 zs(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(`
  887. a=extmap-allow-mixed`)!==-1){const i=r.sdp.split(`
  888. `).filter(s=>s.trim()!=="a=extmap-allow-mixed").join(`
  889. `);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 Fr(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 Tf=Object.freeze({__proto__:null,shimRTCIceCandidate:Vr,shimMaxMessageSize:xn,shimSendThrowTypeError:Bn,shimConnectionState:Ws,removeExtmapAllowMixed:zs,shimAddIceCandidateNullOrEmpty:Fr});const Sf=function({window:n}={},e={shimChrome:!0,shimFirefox:!0,shimEdge:!0,shimSafari:!0}){const t=ca,r=function(s){const o={browser:null,version:null};if(s===void 0||!s.navigator)return o.browser="Not a browser.",o;const{navigator:c}=s;if(c.mozGetUserMedia)o.browser="firefox",o.version=Un(c.userAgent,/Firefox\/(\d+)\./,1);else if(c.webkitGetUserMedia||s.isSecureContext===!1&&s.webkitRTCPeerConnection&&!s.RTCIceGatherer)o.browser="chrome",o.version=Un(c.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else if(c.mediaDevices&&c.userAgent.match(/Edge\/(\d+).(\d+)$/))o.browser="edge",o.version=Un(c.userAgent,/Edge\/(\d+).(\d+)$/,2);else{if(!s.RTCPeerConnection||!c.userAgent.match(/AppleWebKit\/(\d+)\./))return o.browser="Not a supported browser.",o;o.browser="safari",o.version=Un(c.userAgent,/AppleWebKit\/(\d+)\./,1),o.supportsUnifiedPlan=s.RTCRtpTransceiver&&"currentDirection"in s.RTCRtpTransceiver.prototype}return o}(n),i={browserDetails:r,commonShim:Tf,extractVersion:Un,disableLog:Cf,disableWarnings:Ef};switch(r.browser){case"chrome":if(!Sc||!Gs||!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=Sc,Fr(n,r),Zu(n,r),ed(n),Gs(n,r),td(n),od(n,r),nd(n),rd(n),id(n),ad(n,r),Vr(n),Ws(n),xn(n,r),Bn(n),zs(n,r);break;case"firefox":if(!Oc||!Js||!e.shimFirefox)return t("Firefox shim is not included in this adapter release."),i;t("adapter.js shimming firefox."),i.browserShim=Oc,Fr(n,r),ld(n,r),Js(n,r),hd(n),gd(n),fd(n),pd(n),md(n),_d(n),vd(n),yd(n),Cd(n),Vr(n),Ws(n),xn(n,r),Bn(n);break;case"edge":if(!Nc||!Ys||!e.shimEdge)return t("MS edge shim is not included in this adapter release."),i;t("adapter.js shimming edge."),i.browserShim=Nc,cd(n),ud(n),Ys(n,r),dd(n),xn(n,r),Bn(n);break;case"safari":if(!Ac||!e.shimSafari)return t("Safari shim is not included in this adapter release."),i;t("adapter.js shimming safari."),i.browserShim=Ac,Fr(n,r),bd(n),Nd(n),Td(n),Ed(n),Rd(n),wd(n),Sd(n),Od(n),Vr(n),xn(n,r),Bn(n),zs(n,r);break;default:t("Unsupported browser!")}return i}({window:typeof window=="undefined"?void 0:window});var Ct,Re,me;(function(n){n.FPS_10="FPS_10",n.FPS_15="FPS_15",n.FPS_24="FPS_24",n.FPS_30="FPS_30"})(Ct||(Ct={})),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"}(Re||(Re={})),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 Mc={[Re.W176_H132]:{width:176,height:132,maxBitrate:150,minBitrate:80},[Re.W176_H144]:{width:176,height:144,maxBitrate:160,minBitrate:80},[Re.W256_H144]:{width:256,height:144,maxBitrate:240,minBitrate:120},[Re.W320_H180]:{width:320,height:180,maxBitrate:280,minBitrate:120},[Re.W240_H240]:{width:240,height:240,maxBitrate:280,minBitrate:120},[Re.W320_H240]:{width:320,height:240,maxBitrate:400,minBitrate:120},[Re.W480_H360]:{width:480,height:360,maxBitrate:650,minBitrate:150},[Re.W640_H360]:{width:640,height:360,maxBitrate:800,minBitrate:180},[Re.W480_H480]:{width:480,height:480,maxBitrate:800,minBitrate:180},[Re.W640_H480]:{width:640,height:480,maxBitrate:900,minBitrate:200},[Re.W720_H480]:{width:720,height:480,maxBitrate:1e3,minBitrate:200},[Re.W1280_H720]:{width:1280,height:720,maxBitrate:2200,minBitrate:250},[Re.W1920_H1080]:{width:1920,height:1080,maxBitrate:4e3,minBitrate:400}},Ad=(n,e)=>{const t=n*e;let r=Number.MAX_VALUE,i=null;for(const s in Mc){const o=Mc[s],c=Math.abs(o.width*o.height-t);c<r&&(i=o,r=c)}return i},Pc={10:1,15:1,24:1.5,30:1.5},Md=n=>{let e=Number.MAX_VALUE,t=1;for(const r in Pc){const i=Math.abs(n-parseInt(r));i<e&&(e=i,t=Pc[r])}return t},ua={getCameras:()=>$(void 0,void 0,void 0,function*(){return(yield navigator.mediaDevices.enumerateDevices()).filter(n=>n.kind==="videoinput")}),getMicrophones:()=>$(void 0,void 0,void 0,function*(){return(yield navigator.mediaDevices.enumerateDevices()).filter(n=>n.kind==="audioinput")}),getSpeakers:()=>$(void 0,void 0,void 0,function*(){return(yield navigator.mediaDevices.enumerateDevices()).filter(n=>n.kind==="audiooutput")})};class da extends ir{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(){P.info(`set ${this._id} enabled: false`),this._setLocalMuted(!0)}unmute(){P.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 $(this,void 0,void 0,function*(){if(!this._msTrack)return P.warn(`the track is not ready to play -> id: ${this._id}`),{code:M.TRACK_NOT_READY};if(this._msTrack.readyState==="ended"&&P.warn(`the track's readyState is 'ended' -> id: ${this._id}`),t==null?void 0:t.volume){if(!Ie(t==null?void 0:t.volume))return P.error(`${t==null?void 0:t.volume} is not a number, the valid range of options.volume is 0-100`),{code:M.PARAMS_ERROR};(t==null?void 0:t.volume)<0&&(t.volume=0,P.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,P.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 ua.getSpeakers()).map(i=>i.deviceId).includes(t.audioDeviceId))return P.error(`the options.audioDeviceId is invalid --> ${t.audioDeviceId}`),{code:M.PARAMS_ERROR};const r=this.isVideoTrack();if(r&&(!e||!(e instanceof HTMLVideoElement)))return P.error(`the video track need an <video> to play -> id: ${this._id}`),{code:M.VIDEO_TRACK_MISS_MEDIA_ELEMENT};this._element=r?e:this._element||new Audio,this._localMuted&&this._setLocalMuted(!1),this._element.srcObject&&this._element.srcObject===this._msStream||this._element.pause(),this._element.onloadstart=i=>{var s;P.debug(`HTMLMediaElement onloadstart -> id: ${(s=i.target)===null||s===void 0?void 0:s.id}, trackId: ${this._id}`)},this._element.ondurationchange=i=>{var s;P.debug(`HTMLMediaElement ondurationchange -> id: ${(s=i.target)===null||s===void 0?void 0:s.id}, trackId: ${this._id}`)},this._element.onloadedmetadata=i=>{var s;P.debug(`HTMLMediaElement onloadedmetadata -> id: ${(s=i.target)===null||s===void 0?void 0:s.id}, trackId: ${this._id}`)},this._element.onloadeddata=i=>{var s;P.debug(`HTMLMediaElement onloadeddata -> id: ${(s=i.target)===null||s===void 0?void 0:s.id}, trackId: ${this._id}`)},this._element.onabort=i=>{var s;P.info(`HTMLMediaElement onabort -> id: ${(s=i.target)===null||s===void 0?void 0:s.id}, trackId: ${this._id}`)},this._element.oncanplay=i=>{var s;P.info(`HTMLMediaElement oncanplay -> id: ${(s=i.target)===null||s===void 0?void 0:s.id}, trackId: ${this._id}`)},this._element.onvolumechange=i=>{var s;const o=Math.floor(100*((s=i.target)===null||s===void 0?void 0:s.volume));P.info(`HTMLMediaElement onvolumechange -> volume: ${o}, trackId: ${this._id}`)},this._element.srcObject=this._msStream,this._element.autoplay=!0,r&&(this._element.playsInline=!0,this._element.x5PlaysInline=!0,this._element.webkitPlaysInline=!0),r||!(t==null?void 0:t.volume)&&(t==null?void 0:t.volume)!==0||(this._element.volume=(t==null?void 0:t.volume)/100);try{(t==null?void 0:t.audioDeviceId)&&!r?yield this._element.setSinkId(t.audioDeviceId):this._element.play()}catch(i){return i.message==="No permission to use requested device"?(P.error(`setSinkId failed -> ${i.message}`),{code:M.NO_PERMISSION_TO_USE_REQUESTED_DEVICE}):(P.error(i),{code:M.TRACK_PLAY_ERROR})}return{code:M.SUCCESS}})}__innerDestroy(){this.__innerSetMediaStreamTrack(void 0)}__releaseMediaElement(){this._element&&(this._element.remove(),this._element.srcObject=null)}}class pe extends da{constructor(e,t,r,i){super(e,t,r,!0),this._isPublished=!1,this.__innerSetMediaStreamTrack(i),i.onended=()=>{i.onended=null,this.emit(pe.EVENT_LOCAL_TRACK_END,this),this.removeAll(pe.EVENT_LOCAL_TRACK_END)}}_setLocalMuted(e){const t=this._localMuted!==e;super._setLocalMuted(e),this._remoteMuted=this._localMuted,t&&this.emit(pe.__INNER_EVENT_MUTED_CHANGE__,this)}__innerSetPublished(e){this._isPublished=e}isPublished(){return this._isPublished}destroy(){var e;P.info(`track is destroyed -> trackId: ${this.getTrackId()}`),(e=this._msTrack)===null||e===void 0||e.stop(),super.__innerDestroy(),this.isAudioTrack()&&super.__releaseMediaElement(),this.emit(pe.__INNER_EVENT_DESTROY__,this)}setBitrate(e=0,t=0,r=0){!Ie(e)||!Ie(t)||!Ie(r)||e<=0||t<=0||e<t?P.error("setBitrate params error ->"):this._bitrateInfo={max:e,min:t,start:r}}getBitrate(){var e,t;const{min:r,max:i}=this._msTrack?Of(this._msTrack):{min:0,max:0};return{min:((e=this._bitrateInfo)===null||e===void 0?void 0:e.min)||r,max:((t=this._bitrateInfo)===null||t===void 0?void 0:t.max)||i}}}pe.EVENT_LOCAL_TRACK_END="local-track-end",pe.__INNER_EVENT_MUTED_CHANGE__="inner-muted-change",pe.__INNER_EVENT_DESTROY__="inner-destroy";class Qs extends pe{constructor(e,t,r){super(e,t,"audio",r)}setBitrate(e,t,r){P.warn("`setBitrate` invalid for audio track")}getBitrate(){return{start:32,max:32,min:32}}}class pn extends pe{constructor(e,t,r,i=!1){super(e,t,"video",r),this._isTiny=i}__isTiny(){return this._isTiny}getStreamId(){const e=super.getStreamId();return this._isTiny?`${e}_tiny`:e}getTrackId(){const e=super.getTrackId();return this._isTiny?`${e}_tiny`:e}}class gn extends pe{constructor(e,t,r,i,s){super(e,t,r,i),this._resource=s,gn.__innerSetMapping(this.getTrackId(),s)}static __innerSetMapping(e,t){const r=this._mapping.get(t)||[];r.push(e),this._mapping.set(t,r)}static __innerRemoveMapping(e,t){var r,i;const s=(r=this._mapping.get(t))===null||r===void 0?void 0:r.filter(o=>o!==e);s&&s.length>0?this._mapping.set(t,s):(this._mapping.delete(t),t.pause(),t.src="",(i=t.parentNode)===null||i===void 0||i.removeChild(t))}destroy(){this.isAudioTrack()&&this.mute(),gn.__innerRemoveMapping(this.getTrackId(),this._resource),super.destroy()}}gn._mapping=new Map;class If extends gn{constructor(e,t,r,i){super(e,t,"video",r,i)}}class bf extends gn{constructor(e,t,r,i){super(e,t,"audio",r,i)}_setLocalMuted(e){this._resource&&(this._resource.muted=e),super._setLocalMuted(e)}play(){return this._setLocalMuted(!1),Promise.resolve({code:M.SUCCESS})}}class Lc extends Qs{}class kc extends pn{}class wf extends pn{}class Fe extends da{constructor(e,t,r,i){super(e,t,r,!1,i),this._isSubscribed=!1}__innerSetRemoteMuted(e){this._remoteMuted=e}__innerSetSubscribed(e){this._isSubscribed=e}isSubscribed(){return this._isSubscribed}}class Ot extends Fe{constructor(e,t,r){super(e,t,"audio",r)}}class At extends Fe{constructor(e,t,r){super(e,t,"video",r)}}const Or=(n,e)=>({name:n,content:JSON.stringify({uris:e,ignore:!0})}),$t=n=>JSON.stringify(n),bt=n=>/^[a-zA-Z\d-=]+$/g.test(n),Nf=location.protocol!=="http:"||["localhost","127.0.0.1"].includes(location.hostname),is=n=>{if(n===void 0)return 0;if(Ie(n))return n;const e=n;return e.exact||e.ideal||e.max||0},la=n=>{const e=n.getConstraints();return{width:is(e.width),height:is(e.height),frameRate:is(e.frameRate)}},Of=n=>{const{width:e,height:t,frameRate:r}=la(n),i=Ad(e,t),s=Md(r);return{min:i.minBitrate*s,max:i.maxBitrate*s}},fe=n=>[n.msid,n.mediaType].join("_"),Ge=n=>{const e=n.split("_");return{mediaType:parseInt(e.pop()),tag:e.pop(),userId:e.join("_")}},ss=(n,e)=>[n,e].join("_"),Ar=n=>n.map(e=>Object.assign({},e)),Hr=(n,e,t=!1)=>{n=n.slice();const r=[],i=[],s=[];return e.forEach(o=>{const c=fe(o);let d=n.findIndex(h=>fe(h)===c);if(t&&(d=n.findIndex(h=>h.uri===o.uri)),d===-1)return void r.push(o);const l=n[d];l.uri!==o.uri?r.push(o):l.state!==o.state&&s.push(o),n.splice(d,1)}),i.push(...n),{publishedList:r,unpublishedList:i,modifiedList:s}},Af=()=>{let n="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){const t=16*Math.random()|0;return(e==="x"?t:3&t|8).toString(16)});return n=n.replace(/-/g,"")+"0",n=parseInt(n,16),n=(e=>{const t="0123456789abcdefghigklmnopqrstuvwxyzABCDEFGHIGKLMNOPQRSTUVWXYZ+/".split(""),r=t.length+1;let i=+e;const s=[];do{const o=i%r;i=(i-o)/r,s.unshift(t[o])}while(i);return s.join("")})(n),n.length>22&&(n=n.slice(0,22)),n},Et=n=>{const[e,t]=n.split("_").map(r=>parseInt(r.replace(/[^\d]/g,"")));return{width:e,height:t}},dn=n=>!!Re[n],Xs=n=>!!Ct[n],Rt=n=>parseInt(n.replace("FPS_","")),dt=(()=>{const{browser:n,version:e,supportsUnifiedPlan:t}=Sf.browserDetails;return{browser:n,version:e,supportsUnifiedPlan:t!==!1}})();function Pd(){return"captureStream"in HTMLMediaElement.prototype||"mozCaptureStream"in HTMLMediaElement.prototype}function Ld(){return"mediaDevices"in navigator&&"getDisplayMedia"in navigator.mediaDevices}const Zs=n=>Object.prototype.toString.call(n)==="[object Null]",$r=n=>n.type===1,eo=n=>{const e={},t=Object.keys(n.users);return t.length&&t.forEach(r=>{const i=[],s=n.users[r];if(s.uris)try{i.push(...JSON.parse(s.uris))}catch{P.warn(`invalid user data -> userId: ${r}, userData: ${s}`)}e[r]=i}),e};var ce,si;(function(n){n.PUBLISH="RCRTC:PublishResource",n.UNPUBLISH="RCRTC:UnpublishResource",n.MODIFY="RCRTC:ModifyResource",n.TOTAL_CONTENT_RESOURCE="RCRTC:TotalContentResources",n.STATE="RCRTC:state",n.ROOM_NOTIFY="RCRTC:RoomNtf",n.USER_NOTIFY="RCRTC:UserNtf",n.KICK="RCRTC:kick",n.PK_INVITE="RCRTC:invite",n.PK_INVITE_TIMEOUT="RCRTC:inviteTimeout",n.PK_CANCEL_INVITE="RCRTC:cancelInvite",n.PK_INVITE_ANSWER="RCRTC:answerInvite",n.PK_END="RCRTC:endInvite",n.OTHER_ROOM_OFFLINE="RCRTC:otherRoomOffline"})(ce||(ce={})),function(n){n.SUCCESS="Success",n.FAIL="Fail"}(si||(si={}));class Mf{constructor(e,t,r,i=1e4){this._roomId=e,this._roomMode=t,this._context=r,this._gap=i,this._latestTimestamp=Date.now(),this._timer=null}start(){return $(this,void 0,void 0,function*(){this._timer||(this._timer=setInterval(this._loop.bind(this),this._gap))})}_loop(){var e,t,r;return $(this,void 0,void 0,function*(){const i=yield new Promise(o=>{this._context.rtcPing(this._roomId,this._roomMode).then(o).catch(c=>{P.error(`rtcping receive unknown error -> ${c}`),o(N.UNKNOWN)}),setTimeout(o,1e4,N.TIMEOUT)}),s=Date.now();if(i===N.SUCCESS)return this._latestTimestamp=s,void((e=this.onPingResult)===null||e===void 0||e.call(this,si.SUCCESS));(t=this.onPingResult)===null||t===void 0||t.call(this,si.FAIL),P.warn(`rtcping failed -> code: ${i}`),(i===40003||s-this._latestTimestamp>6e4)&&(this.stop(),(r=this.onFailed)===null||r===void 0||r.call(this,i===40003))})}stop(){this._timer&&(clearInterval(this._timer),this._timer=null)}}var ct;(function(n){n[n.NORMAL=1]="NORMAL",n[n.TINY=2]="TINY"})(ct||(ct={}));const Uc=(n,e)=>Math.round(8*e/n),Dc=(n,e=2)=>{const t=10**e;return Math.round(n*t)/t},Mt=(n,e=2)=>{n>1&&(n/=32767);const t=10**e;return Math.ceil(n*t)},Mr=(n,e,t,r)=>{if(e===0)return 0;if(!t||!r)return Dc(n/e,3);const i=e-r;if(i===0)return 0;const s=n-t;return s<0||i<0?0:Dc(s/i,3)},kd=n=>{const{jitter:e,rtt:t,packetsLostRate:r}=n;return!Zs(e)||!Zs(t)||r!==0};class ha{constructor(e,t){this._rtcPeerConn=e,this._sdpSemantics=t,this._latestPacketsSent={},this._latestBytesSent={},this._latestBytesRecv={},this._latestPacketsRecv={}}updateBytesSent(e,t,r){let i,s;if(this._latestBytesSent[e]&&t<this._latestBytesSent[e].bytesSent&&this.clearLatestpacketsSent([e]),this._latestBytesSent[e]){const{bytesSent:o,timestamp:c}=this._latestBytesSent[e];i=t-o,s=r-c,this._latestBytesSent[e]={bytesSent:t,timestamp:r}}else i=t,s=1e3,this._latestBytesSent[e]={bytesSent:t,timestamp:r};return Uc(s,i)}updateBytesRecv(e,t,r){let i,s;if(this._latestBytesRecv[e]&&t<this._latestBytesRecv[e].bytesRecv&&this.clearLatestPacketsRecv([e]),this._latestBytesRecv[e]){const{bytesRecv:o,timestamp:c}=this._latestBytesRecv[e];i=t-o,s=r-c,this._latestBytesRecv[e]={bytesRecv:t,timestamp:r}}else i=t,s=1e3,this._latestBytesRecv[e]={bytesRecv:t,timestamp:r};return Uc(s,i)}updateSenderPacketsLost(e,t,r){let i;if(Object.prototype.hasOwnProperty.call(this._latestPacketsSent[e],"packetsSent")){const{packetsLost:s,packetsSent:o}=this._latestPacketsSent[e];i=Mr(t,r,s,o),this._latestPacketsSent[e].packetsLost=t,this._latestPacketsSent[e].packetsSent=s===t?o:r}else i=Mr(t,r),this._latestPacketsSent[e].packetsLost=t,this._latestPacketsSent[e].packetsSent=r;return i}updateReceiverPacketsLost(e,t,r){let i;if(this._latestPacketsRecv[e]){const{packetsLost:s,packetsRecv:o}=this._latestPacketsRecv[e];i=Mr(t,r+t,s,o+s)}else i=Mr(t,r);return this._latestPacketsRecv[e]={packetsLost:t,packetsRecv:r},i}clearLatestpacketsSent(e){e.forEach(t=>{if(parseInt(t.split("_").pop())===me.VIDEO_ONLY){const r=`${t}_tiny`;delete this._latestPacketsSent[r],delete this._latestBytesSent[r]}delete this._latestPacketsSent[t],delete this._latestBytesSent[t]})}clearLatestPacketsRecv(e){e.forEach(t=>{delete this._latestPacketsRecv[t],delete this._latestBytesRecv[t]})}parseRTCStatsReport(e){const t=e.keys(),r={};let i=t.next();for(;!i.done;){const s=i.value,o=e.get(s);/^RTCCodec_/.test(s)||(r[s]=o),i=t.next()}return r}formatRCRTCStateReport(e){return{senders:[],receivers:[]}}getAudioLevelList(e){return[]}getResourceIdByParseSdp(e){var t,r;const i=e.ssrc,s=e.kind||e.mediaType,o=(t=this._rtcPeerConn.currentLocalDescription)===null||t===void 0?void 0:t.sdp,c=(r=this._rtcPeerConn.currentRemoteDescription)===null||r===void 0?void 0:r.sdp;let d;d=this._sdpSemantics==="unified-plan"?new RegExp("a=msid:(.*?) "):new RegExp(`a=ssrc:${i} msid:(.*?) `);const l=o==null?void 0:o.split(`\r
  890. m=`),h=l==null?void 0:l.filter(_=>_.includes(`a=ssrc:${i}`))[0],a=h==null?void 0:h.match(d);let u=a?a[1]:"";if(u)return`${u}_${s==="video"?1:0}`;const f=c==null?void 0:c.split(`\r
  891. m=`),p=f==null?void 0:f.filter(_=>_.includes(`a=ssrc:${i}`))[0],m=p==null?void 0:p.match(d);return u=m?m[1]:"",`${u}_${s==="video"?1:0}`}isValidSender(e){var t;const r=(t=this._rtcPeerConn.currentLocalDescription)===null||t===void 0?void 0:t.sdp,{ssrc:i}=e;return!(r==null?void 0:r.split(`\r
  892. m=`).some(s=>s.includes(i)&&s.includes("a=inactive")))}isValidReceiver(e){var t;const r=(t=this._rtcPeerConn.currentRemoteDescription)===null||t===void 0?void 0:t.sdp,{ssrc:i}=e;return!(r==null?void 0:r.split(`\r
  893. m=`).some(s=>s.includes(i)&&s.includes("a=inactive")))}}class Pf extends ha{formatRCRTCStateReport(e){const t={senders:[],receivers:[]},r=Math.floor(e.RTCPeerConnection.timestamp);t.timestamp=r;const i=Object.keys(e);let s=0,o=0;i.filter(l=>/^RTCOutboundRTP(Video|Audio)Stream_/.test(l)).forEach(l=>{const h=e[l];if(this._sdpSemantics==="unified-plan"&&!this.isValidSender(h))return;const{id:a,kind:u,transportId:f,mediaSourceId:p,remoteId:m,packetsSent:_,bytesSent:v,trackId:y,encoderImplementation:C,pliCount:b,nackCount:O,firCount:S}=h;if(!y)return;let{framesPerSecond:E,frameWidth:w,frameHeight:V}=h;u!=="video"||w||V||E||(w=e[y].frameWidth,V=e[y].frameHeight,E=p?e[p].framesPerSecond:null);const j=e[m];let R=null,T=null,A=0;j&&(R=j.jitter,T=j.roundTripTime,A=j.packetsLost),s+=A;const L=this.getResourceIdByParseSdp(h),k=p?e[p].audioLevel:e[y].audioLevel;let F=null;!this._latestPacketsSent[L]&&(this._latestPacketsSent[L]={}),j?F=this.updateSenderPacketsLost(L,A,_):this._latestPacketsSent[L].crtPacketsSent=_;let H=this.updateBytesSent(L,v,r);H<0&&(H=0),o+=H,t.senders.push({id:a,trackId:L,kind:u,packetsLostRate:F,remoteResource:!1,audioLevel:k||k===0?Mt(k):null,frameWidth:w,frameHeight:V,frameRate:E,bitrate:H,jitter:R&&Math.round(1e3*R),rtt:T,encoderImplementation:C,pliCount:b,nackCount:O,googFirsSent:-1,samplingRate:-1,googRenderDelayMs:-1,trackState:-1})}),i.filter(l=>/RTCRemoteInboundRtp(Video|Audio)Stream_/.test(l)).forEach(l=>{const{localId:h,jitter:a,roundTripTime:u,packetsLost:f}=e[l],p=t.senders.filter(m=>m.id===h)[0];if(p&&!kd(p)){const m=this.getResourceIdByParseSdp(e[p.id]);p.jitter=Math.round(1e3*a),p.rtt=u;const _=this._latestPacketsSent[m].crtPacketsSent;p.packetsLostRate=this.updateSenderPacketsLost(m,f,_)}});let c=0;i.filter(l=>/^RTCInboundRTP(Video|Audio)Stream_/.test(l)).forEach(l=>{const h=e[l];if(this._sdpSemantics==="unified-plan"&&!this.isValidReceiver(h))return;const{trackId:a,packetsLost:u,packetsReceived:f,jitter:p,bytesReceived:m,framesPerSecond:_,kind:v,codecImplementationName:y,nackCount:C,pliCount:b}=h;if(!a)return;let{frameWidth:O,frameHeight:S,audioLevel:E}=h;v==="video"?O||S||(O=e[a].frameWidth,S=e[a].frameHeight):E||(E=e[a].audioLevel),s+=u;const w=this.getResourceIdByParseSdp(h),V=this.updateReceiverPacketsLost(w,u,f);let j=this.updateBytesRecv(w,m,r);j<0&&(j=0),c+=j,t.receivers.push({trackId:w,kind:v,packetsLostRate:V,remoteResource:!0,audioLevel:E||E===0?Mt(E):null,frameWidth:O,frameHeight:S,frameRate:_,bitrate:j,jitter:p?Math.round(1e3*p):0,codecImplementationName:y,nackCount:C,pliCount:b,rtt:null,samplingRate:-1,googFirsReceived:-1,googRenderDelayMs:-1,trackState:-1})});const d=i.filter(l=>/^RTCTransport_/.test(l))[0];if(d){const l=e[d],{selectedCandidatePairId:h}=l;if(h){const a=e[h],{availableOutgoingBitrate:u,availableIncomingBitrate:f,currentRoundTripTime:p,localCandidateId:m,remoteCandidateId:_}=a,v=e[m],{ip:y,port:C,networkType:b}=v,O=e[_],{ip:S,port:E,protocol:w}=O;t.iceCandidatePair={IP:y,port:C,networkType:b,remoteIP:S,remotePort:E,protocol:w,bitrateRecv:c,bitrateSend:o,rtt:1e3*p,availableOutgoingBitrate:u,availableIncomingBitrate:f,totalPacketsLost:s},t.receivers.forEach(V=>{V.rtt=p})}}return t}getAudioLevelList(e){const t=[],r=Object.keys(e);return r.filter(i=>/^RTCOutboundRTPAudioStream_/.test(i)).forEach(i=>{var s;const o=e[i];if(this._sdpSemantics==="unified-plan"&&!this.isValidSender(o))return;const{mediaSourceId:c,trackId:d}=o,l=this.getResourceIdByParseSdp(o),h=c&&e[c]?e[c].audioLevel:((s=e[d])===null||s===void 0?void 0:s.audioLevel)||null;t.push({trackId:l,audioLevel:h||h===0?Mt(h):null})}),r.filter(i=>/^RTCInboundRTPAudioStream_/.test(i)).forEach(i=>{const s=e[i];if(this._sdpSemantics==="unified-plan"&&!this.isValidReceiver(s))return;const{trackId:o}=s,c=s.audioLevel||e[o].audioLevel,d=this.getResourceIdByParseSdp(s);t.push({trackId:d,audioLevel:c||c===0?Mt(c):null})}),t}}class Lf extends ha{formatRCRTCStateReport(e){const t=+new Date,r={senders:[],receivers:[],timestamp:t};let i=0,s=0,o=0;for(const c in e){const d=e[c],l=d.type;if(l==="outbound-rtp"){if(this._sdpSemantics==="unified-plan"&&!this.isValidSender(d))continue;const{id:h,kind:a,bytesSent:u,packetsSent:f,bitrateMean:p,framerateMean:m,nackCount:_,pliCount:v,remoteId:y}=d,{jitter:C,roundTripTime:b,packetsLost:O}=y?e[y]:{jitter:null,roundTripTime:null,packetsLost:0},S=this.getResourceIdByParseSdp(d);i+=O;let E=null;!this._latestPacketsSent[S]&&(this._latestPacketsSent[S]={}),y?E=this.updateSenderPacketsLost(S,O,f):this._latestPacketsSent[S].crtPacketsSent=f;let w=0;a==="video"?p&&(w=Math.floor(p/1e3)):w=this.updateBytesSent(S,u,t),w<0&&(w=0),s+=w,r.senders.push({trackId:S,kind:a,packetsLostRate:E,remoteResource:!1,audioLevel:null,frameWidth:null,frameHeight:null,frameRate:Math.floor(m),bitrate:w,jitter:C?Math.round(1e3*C):null,rtt:b,encoderImplementation:null,pliCount:v,nackCount:_,googFirsSent:-1,samplingRate:-1,googRenderDelayMs:-1,trackState:-1})}if(l==="remote-inbound-rtp"){const{localId:h}=d,a=this.getResourceIdByParseSdp(e[h]),u=r.senders.filter(f=>f.trackId===a)[0];u&&kd(u)&&(u.jitter=Math.round(1e3*d.jitter),u.rtt=d.rtt,u.packetsLostRate=this.updateSenderPacketsLost(a,d.packetsLost,this._latestPacketsSent[a].crtPacketsSent))}if(l==="inbound-rtp"){if(this._sdpSemantics==="unified-plan"&&!this.isValidReceiver(d))continue;const{id:h,packetsLost:a,bytesReceived:u,packetsReceived:f,jitter:p,framerateMean:m,kind:_,bitrateMean:v,nackCount:y,pliCount:C}=d,b=this.getResourceIdByParseSdp(d);i+=a;const O=this.updateReceiverPacketsLost(b,a,f);let S=0;_==="video"?v&&(S=Math.floor(v/1e3)):S=this.updateBytesRecv(b,u,t),S<0&&(S=0),o+=S,r.receivers.push({trackId:b,kind:_,packetsLostRate:O,remoteResource:!0,audioLevel:null,frameWidth:null,frameHeight:null,frameRate:Math.floor(m),bitrate:S,jitter:p?Math.round(1e3*p):null,codecImplementationName:null,nackCount:y,pliCount:C,rtt:null,samplingRate:-1,googFirsReceived:-1,googRenderDelayMs:-1,trackState:-1})}if(l==="candidate-pair"&&d.state==="succeeded"){const h=e[d.localCandidateId],{address:a,port:u}=h,f=e[d.remoteCandidateId],{address:p,port:m,protocol:_}=f;r.iceCandidatePair={IP:a,port:u,networkType:null,remoteIP:p,remotePort:m,protocol:_,bitrateRecv:o,bitrateSend:s,rtt:null,availableOutgoingBitrate:null,availableIncomingBitrate:null,totalPacketsLost:i}}}return r.iceCandidatePair&&(r.iceCandidatePair.bitrateSend=s),r.iceCandidatePair&&(r.iceCandidatePair.bitrateRecv=o),r}getAudioLevelList(e){const t=[];for(const r in e){const i=e[r],s=i.type;if(s==="outbound-rtp"){if(this._sdpSemantics==="unified-plan"&&!this.isValidSender(i))continue;const{kind:o}=i;if(o==="video")continue;const c=this.getResourceIdByParseSdp(i);t.push({trackId:c,audioLevel:null})}if(s==="inbound-rtp"){if(this._sdpSemantics==="unified-plan"&&!this.isValidReceiver(i))continue;const{kind:o}=i;if(o==="video")continue;const c=this.getResourceIdByParseSdp(i);t.push({trackId:c,audioLevel:null})}}return t}}class kf extends ha{formatRCRTCStateReport(e){const t={senders:[],receivers:[]},r=Math.floor(e.RTCPeerConnection.timestamp);t.timestamp=r;const i=Object.keys(e);let s=0,o=0;i.filter(l=>/^RTCOutboundRTP(Video|Audio)Stream_/.test(l)).forEach(l=>{const h=e[l];if(this._sdpSemantics==="unified-plan"&&!this.isValidSender(h))return;const a=this.getResourceIdByParseSdp(h),{mediaType:u,transportId:f,remoteId:p,packetsSent:m,bytesSent:_,trackId:v,encoderImplementation:y,pliCount:C,nackCount:b,firCount:O}=h;if(!v)return;const{audioLevel:S,frameHeight:E,frameWidth:w}=e[v];let V=this.updateBytesSent(a,_,r);V<0&&(V=0),o+=V,t.senders.push({trackId:a,kind:u,packetsLostRate:null,remoteResource:!1,audioLevel:S||S===0?Mt(S):null,frameWidth:w,frameHeight:E,frameRate:null,bitrate:V,jitter:null,rtt:null,encoderImplementation:y,pliCount:C,nackCount:b,googFirsSent:-1,samplingRate:-1,googRenderDelayMs:-1,trackState:-1})});let c=0;i.filter(l=>/^RTCInboundRTP(Video|Audio)Stream_/.test(l)).forEach(l=>{const h=e[l];if(this._sdpSemantics==="unified-plan"&&!this.isValidReceiver(h))return;const{trackId:a,packetsLost:u,packetsReceived:f,jitter:p,bytesReceived:m,mediaType:_,nackCount:v,pliCount:y}=h,C=this.getResourceIdByParseSdp(h);if(!a)return;const{frameHeight:b,frameWidth:O,audioLevel:S}=e[a];s+=u;const E=this.updateReceiverPacketsLost(C,u,f);let w=this.updateBytesRecv(C,m,r);w<0&&(w=0),c+=w,t.receivers.push({trackId:C,kind:_,packetsLostRate:E,remoteResource:!0,audioLevel:S||S===0?Mt(S):null,frameWidth:O,frameHeight:b,frameRate:null,bitrate:w,jitter:p,codecImplementationName:null,nackCount:v,pliCount:y,rtt:null,samplingRate:-1,googFirsReceived:-1,googRenderDelayMs:-1,trackState:-1})});const d=i.filter(l=>/^RTCTransport_/.test(l))[0];if(d){const l=e[d],{selectedCandidatePairId:h}=l;if(h){const a=e[h],{availableOutgoingBitrate:u,availableIncomingBitrate:f,currentRoundTripTime:p,localCandidateId:m,remoteCandidateId:_}=a,v=e[m],{address:y,port:C}=v,b=e[_],{address:O,port:S,protocol:E}=b;t.iceCandidatePair={IP:y||null,port:C,networkType:null,remoteIP:O,remotePort:S,protocol:E,bitrateRecv:c,bitrateSend:o,rtt:1e3*p,availableOutgoingBitrate:u,availableIncomingBitrate:f,totalPacketsLost:s},t.receivers.forEach(w=>{w.rtt=p})}}return t}getAudioLevelList(e){const t=[],r=Object.keys(e);return r.filter(i=>/^RTCOutboundRTP(Video|Audio)Stream_/.test(i)).forEach(i=>{const s=e[i];if(this._sdpSemantics==="unified-plan"&&!this.isValidSender(s))return;const{trackId:o,mediaType:c}=s;if(c==="video")return;const d=this.getResourceIdByParseSdp(s),l=e[o];t.push({trackId:d,audioLevel:l||l===0?Mt(l):null})}),r.filter(i=>/^RTCInboundRTP(Video|Audio)Stream_/.test(i)).forEach(i=>{const s=e[i];if(this._sdpSemantics==="unified-plan"&&!this.isValidReceiver(s))return;const{trackId:o,mediaType:c}=s;if(!o||c==="video")return;const{audioLevel:d}=e[o],l=this.getResourceIdByParseSdp(s);t.push({trackId:l,audioLevel:d||d===0?Mt(d):null})}),t}}class Tn{constructor(e){this._peer=e,this._outboundStreams={}}static setSdpSemantics(e){const{browser:t,version:r,supportsUnifiedPlan:i}=dt;i?/chrome/i.test(t)?this._sdpSemantics=r>92?"unified-plan":r<72?"plan-b":e:/firefox/i.test(t)?this._sdpSemantics="unified-plan":/safari/i.test(t)?this._sdpSemantics=r<12?"plan-b":"unified-plan":this._sdpSemantics="unified-plan":this._sdpSemantics="plan-b"}static getSdpSemantics(){return Tn._sdpSemantics}getOutboundVideoInfo(){const e=[];for(const t in this._outboundStreams){const r=this._outboundStreams[t].getVideoTracks()[0];if(!r)continue;const i=/_tiny$/.test(t),{width:s,height:o}=la(r);e.push({trackId:r.id,simulcast:i?ct.TINY:ct.NORMAL,resolution:`${s}x${o}`})}return e}setRemoteAnswer(e){return $(this,void 0,void 0,function*(){e=e.replace(/\s+\r\n/g,`\r
  894. `);try{yield this._peer.setRemoteDescription({type:"answer",sdp:e})}catch(t){return P.error(t),M.SET_REMOTE_DESCRIPTION_FAILED}return M.SUCCESS})}getStatParsr(e,t){return/chrome/i.test(dt.browser)?new Pf(e,t):/Firefox/i.test(dt.browser)?new Lf(e,t):/Safari/i.test(dt.browser)?new kf(e,t):null}}class Uf extends Tn{constructor(){super(...arguments),this.senders={},this._localTracks=[]}addLocalTrack(e){this._localTracks.includes(e)||this._localTracks.push(e);const t=e.getStreamId(),r=e.__innerGetMediaStreamTrack(),i=this._outboundStreams[t]||(this._outboundStreams[t]=new MediaStream);i.getTracks().forEach(c=>{c.kind===r.kind&&i.removeTrack(c)}),i.addTrack(r);const s=e.getTrackId(),o=this.senders[s];o?o.replaceTrack(r):this.senders[s]=this._peer.addTrack(r,i)}removeLocalTrack(e){const t=this._localTracks.findIndex(s=>s===e);t>=0&&this._localTracks.splice(t,1);const r=e.getTrackId(),i=this.senders[r];i&&(i.replaceTrack(null),this._peer.removeTrack(i),delete this.senders[r])}updateSubRemoteTracks(e){}updateRecvTransceiverMap(e,t){}setBitrate(e,t,r){this._maxBitrate=e,this._minBitrate=t,this._startBitrate=r||.7*e}createOffer(e){return $(this,void 0,void 0,function*(){const t=yield this._peer.createOffer({iceRestart:e,offerToReceiveAudio:!0,offerToReceiveVideo:!0});for(const r in this._outboundStreams){const i=this._outboundStreams[r].id;t.sdp=t.sdp.replace(new RegExp(i,"g"),r)}return yield this._peer.setLocalDescription(t),{type:"offer",semantics:"plan-b",sdp:t.sdp}})}setRemoteAnswer(e){let t=0,r=0;this._localTracks.forEach(c=>{const{min:d,max:l}=c.getBitrate();r+=d,t+=l}),t=this._maxBitrate&&this._maxBitrate>0?Math.min(t,this._maxBitrate):t,r=this._minBitrate&&this._minBitrate>0?Math.max(r,this._minBitrate):r;const i=this._startBitrate||Math.round(.7*t),s=`b=AS:${t}`;e=e.replace(/[\r\n]+m=video[^\r\n]+/,c=>`${c}\r
  895. ${s}`);const o=[`;x-google-min-bitrate=${r}`,`;x-google-max-bitrate=${t}`,`;x-google-start-bitrate=${i}`].join("");return e=e.replace(/[\r\n]+[^\r\n]+profile-level-id[^\r\n]+/g,c=>c+o),super.setRemoteAnswer(e)}}class Df extends Tn{constructor(){super(...arguments),this._sendTransceiver={},this._localTracks={},this._recvAudio=[],this._recvVideo=[],this._recvTransceiver={},this._subedTracks=[]}setBitrate(e,t,r){P.warn("the interface named `setBitrate` is invalid while sdpSemantics value is `unified-plan`")}addLocalTrack(e){const t=e.getTrackId(),r=e.getStreamId(),i=e.__innerGetMediaStreamTrack();this._localTracks[t]=e;const s=this._outboundStreams[r]||(this._outboundStreams[r]=new MediaStream);s.getTracks().forEach(c=>{c.kind===i.kind&&s.removeTrack(c)}),s.addTrack(i);const o=this._sendTransceiver[t];o?(o.sender.replaceTrack(i),o.direction="sendonly"):this._sendTransceiver[t]=this._peer.addTransceiver(i,{direction:"sendonly",streams:[s]})}removeLocalTrack(e){const t=e.getTrackId(),r=e.getStreamId();e.__innerGetMediaStreamTrack(),delete this._localTracks[t];const i=this._sendTransceiver[t];if(!i)return;i.direction="inactive",this._peer.removeTrack(i.sender),i.sender.replaceTrack(null);const s=this._outboundStreams[r];(e.isAudioTrack()?s.getAudioTracks():s.getVideoTracks()).forEach(l=>s.removeTrack(l));const o=this._sendTransceiver[`${t}_tiny`];if(!o||o.direction==="inactive")return;o.direction="inactive";const c=o.sender,d=c.track;this._peer.removeTrack(c),c.replaceTrack(null),this._outboundStreams[`${r}_tiny`].removeTrack(d),d.stop()}updateRecvTransceiverMap(e,t){const{mediaType:r}=Ge(e);this._recvTransceiver[e]=t;const i=r===me.AUDIO_ONLY?this._recvAudio:this._recvVideo,s=i.findIndex(o=>o===t);s>=0&&i.splice(s,1)}updateSubRemoteTracks(e){const t=e.slice(),r=this._subedTracks.slice();this._subedTracks=e.slice();for(let s=t.length-1;s>=0;s-=1){const o=t[s],c=r.findIndex(d=>d===o);c>=0&&(t.splice(s,1),r.splice(c,1))}r.length&&r.forEach(s=>{const o=s.getTrackId();s.__innerSetMediaStreamTrack(void 0);const c=this._recvTransceiver[o];c&&(c.direction="inactive")});const i={audio:0,video:0};t.length&&t.forEach(s=>{const o=s.isAudioTrack()?"audio":"video",c=this._recvTransceiver[s.getTrackId()];c?c.direction="recvonly":i[o]+=1});for(let s=this._recvAudio.length;s<i.audio;s+=1)this._recvAudio.push(this._peer.addTransceiver("audio",{direction:"recvonly"}));for(let s=this._recvVideo.length;s<i.video;s+=1)this._recvVideo.push(this._peer.addTransceiver("video",{direction:"recvonly"}))}createOffer(e){return $(this,void 0,void 0,function*(){const t=yield this._peer.createOffer({iceRestart:e});let r=t.sdp;for(const i in this._outboundStreams){const s=this._outboundStreams[i].id;r=r.replace(new RegExp(s,"g"),i)}return r=(i=>i.split(/\r\n(?=m=)/).map(s=>(o=>/a=(recvonly|inactive)/.test(o)?o.replace(/\r\na=(ssrc|msid)[^\r\n]+/g,""):o)(s)).join(`\r
  896. `))(r),r=r.replace(/a=ice-options:trickle/g,`a=ice-options:trickle\r
  897. a=ice-options:renomination`),t.sdp=r,yield this._peer.setLocalDescription(t),{type:"offer",semantics:"unified-plan",sdp:r}})}setRemoteAnswer(e){e=e.split(/\r\n(?=m=)/).map(r=>{var i;const s=r.match(/a=mid:[^\s]+/);if(!s)return r;const o=s[0].replace("a=mid:","");let c="";for(const p in this._sendTransceiver)if(this._sendTransceiver[p].mid===o){c=p;break}if(!c)return r;const d=(i=this._localTracks[c])===null||i===void 0?void 0:i.getBitrate();if(!d)return r;const{max:l,min:h}=d,a=l&&l>0?d.start||.7*l:0,u=[];if(l&&l>0&&u.push(`;x-google-max-bitrate=${l}`),h&&h>0&&u.push(`;x-google-min-bitrate=${h}`),a>0&&u.push(`;x-google-start-bitrate=${a}`),u.length===0)return r;const f=u.join("");return r.replace(/[\r\n]+[^\r\n]+profile-level-id[^\r\n]+/g,p=>p+f)}).join(`\r
  898. `);const t=/[\r\n]+\r\n[\r\n]+/g;return t.test(e)&&(P.warn(`answer sdp invalid -> ${JSON.stringify(e)}`),e=e.replace(t,`\r
  899. `)),super.setRemoteAnswer(e)}}class It extends ir{constructor(e,t){super(),this._reTryExchange=e,this._polarisReport=t,this.pubLocalTracks={},this._reTryExchangeTimer=null,this._reportStatsTimer=null,this._reportListener=null;const r=Tn.getSdpSemantics(),i=this._rtcPeerConn=new RTCPeerConnection({sdpSemantics:r});this._sdpStrategy=r==="plan-b"?new Uf(i):new Df(i),this._rtcPeerConn.oniceconnectionstatechange=this._onICEConnectionStateChange.bind(this),this._rtcPeerConn.onconnectionstatechange=this._onConnectionStateChange.bind(this),this._rtcPeerConn.ontrack=this._onTrackReady.bind(this),this.reportParser=this._sdpStrategy.getStatParsr(this._rtcPeerConn,r)}getLocalTracks(){return Object.values(this.pubLocalTracks)}_onConnectionStateChange(){P.info(`onconnectionstatechange -> ${this._rtcPeerConn.connectionState}`)}_onICEConnectionStateChange(){var e,t;P.info(`oniceconnectionstatechange -> ${this._rtcPeerConn.iceConnectionState}`),this._rtcPeerConn.iceConnectionState==="connected"&&(this._reportStatsTimer&&clearInterval(this._reportStatsTimer),this._reportStatsTimer=setInterval(this._reportHandle.bind(this),1e3)),this._rtcPeerConn.iceConnectionState!=="failed"&&this._rtcPeerConn.iceConnectionState!=="disconnected"||(P.warn("iceconenction state is `failed`, exchange SDP to try again."),this._reTryExchange(),this._reTryExchangeTimer=setInterval(this._reTryExchange,15e3));try{(t=(e=this._reportListener)===null||e===void 0?void 0:e.onICEConnectionStateChange)===null||t===void 0||t.call(e,this._rtcPeerConn.iceConnectionState)}catch(r){P.error("onICEConnectionStateChange error",r)}}_onTrackReady(e){if(!e.streams.length)return;const t=[e.streams[0].id,e.receiver.track.kind==="audio"?me.AUDIO_ONLY:me.VIDEO_ONLY].join("_");this._updateRecvTransceiverMap(t,e.transceiver),this.emit(It.__INNER_EVENT_TRACK_READY__,e)}setBitrate(e,t,r){return $(this,void 0,void 0,function*(){this._sdpStrategy.setBitrate(e,t,r)})}createOffer(e){return $(this,void 0,void 0,function*(){const t=yield this._sdpStrategy.createOffer(e);return P.debug(`offer -> ${JSON.stringify(t.sdp)}`),t})}setRemoteAnswer(e){return $(this,void 0,void 0,function*(){return P.debug(`answer -> ${JSON.stringify(e)}`),this._sdpStrategy.setRemoteAnswer(e)})}getLocalTrack(e){return this.pubLocalTracks[e]||null}addLocalTrack(e){this.pubLocalTracks[e.getTrackId()]=e,this._sdpStrategy.addLocalTrack(e),e.off(pe.__INNER_EVENT_MUTED_CHANGE__,this._onLocalTrackMuted,this),e.off(pe.__INNER_EVENT_DESTROY__,this._onLocalTrackDestroied,this),e.on(pe.__INNER_EVENT_MUTED_CHANGE__,this._onLocalTrackMuted,this),e.on(pe.__INNER_EVENT_DESTROY__,this._onLocalTrackDestroied,this)}removeLocalTrackById(e){const t=this.getLocalTrack(e);t&&this.removeLocalTrack(t)}removeAllLocalTrack(){Object.keys(this.pubLocalTracks).forEach(e=>{/_tiny$/.test(e)||this.removeLocalTrackById(e)})}removeLocalTrack(e){const t=e.getTrackId();delete this.pubLocalTracks[t],this._sdpStrategy.removeLocalTrack(e),e.__innerSetPublished(!1),e.off(pe.__INNER_EVENT_MUTED_CHANGE__,this._onLocalTrackMuted,this),e.off(pe.__INNER_EVENT_DESTROY__,this._onLocalTrackDestroied,this);const r=`${t}_tiny`,i=this.getLocalTrack(r);i&&(this._sdpStrategy.removeLocalTrack(i),delete this.pubLocalTracks[r],i.destroy())}_updateRecvTransceiverMap(e,t){this._sdpStrategy.updateRecvTransceiverMap(e,t)}updateSubRemoteTracks(e){this._sdpStrategy.updateSubRemoteTracks(e)}getOutboundVideoInfo(){return this._sdpStrategy.getOutboundVideoInfo()}_onLocalTrackMuted(e){const t=this.getLocalTrack(`${e.getTrackId()}_tiny`);t&&(t.__innerGetMediaStreamTrack().enabled=!e.isLocalMuted()),this.emit(pe.__INNER_EVENT_MUTED_CHANGE__,e)}_onLocalTrackDestroied(e){this.emit(pe.__INNER_EVENT_DESTROY__,e)}registerReportListener(e){this._reportListener=e}_createRCRTCStateReport(e){const{timestamp:t,iceCandidatePair:r,senders:i,receivers:s}=JSON.parse(JSON.stringify(e));r==null||delete r.totalPacketsLost;for(const o in r)Zs(r[o])&&delete r[o];return{timestamp:t,iceCandidatePair:r,senders:i.map(o=>{const c={};return o.trackId&&(c.trackId=o.trackId),o.kind&&(c.kind=o.kind),(o.packetsLostRate||o.packetsLostRate===0)&&(c.packetsLostRate=o.packetsLostRate),c.remoteResource=o.remoteResource,(o.audioLevel||o.audioLevel===0)&&(c.audioLevel=o.audioLevel),o.frameWidth&&(c.frameWidth=o.frameWidth),o.frameHeight&&(c.frameHeight=o.frameHeight),o.frameRate&&(c.frameRate=o.frameRate),(o.bitrate||o.bitrate===0)&&(c.bitrate=o.bitrate),o.jitter&&(c.jitter=o.jitter),c}),receivers:s.map(o=>{const c={};return o.trackId&&(c.trackId=o.trackId),o.kind&&(c.kind=o.kind),(o.packetsLostRate||o.packetsLostRate===0)&&(c.packetsLostRate=o.packetsLostRate),c.remoteResource=o.remoteResource,(o.audioLevel||o.audioLevel===0)&&(c.audioLevel=o.audioLevel),o.frameWidth&&(c.frameWidth=o.frameWidth),o.frameHeight&&(c.frameHeight=o.frameHeight),o.frameRate&&(c.frameRate=o.frameRate),(o.bitrate||o.bitrate===0)&&(c.bitrate=o.bitrate),o.jitter&&(c.jitter=o.jitter),c})}}_getStatsData(){var e,t;return $(this,void 0,void 0,function*(){const r=yield this._rtcPeerConn.getStats(),i=(e=this.reportParser)===null||e===void 0?void 0:e.parseRTCStatsReport(r);return(t=this.reportParser)===null||t===void 0?void 0:t.formatRCRTCStateReport(i)})}getAudioLevelReportData(){var e,t;return $(this,void 0,void 0,function*(){const r=yield this._rtcPeerConn.getStats(),i=(e=this.reportParser)===null||e===void 0?void 0:e.parseRTCStatsReport(r);return i?(t=this.reportParser)===null||t===void 0?void 0:t.getAudioLevelList(i):[]})}_reportHandle(){var e,t,r;return $(this,void 0,void 0,function*(){const i=yield this._getStatsData();if(!i)return;(i.senders.length||i.receivers.length)&&((e=this._polarisReport)===null||e===void 0||e.sendR3R4Data(i));const s=this._createRCRTCStateReport(i);(r=(t=this._reportListener)===null||t===void 0?void 0:t.onStateReport)===null||r===void 0||r.call(t,s)})}getRTCPeerConn(){return this._rtcPeerConn}destroy(){this.clear(),this.clearReTryExchangeTimer(),this._reportStatsTimer&&(clearInterval(this._reportStatsTimer),this._reportStatsTimer=null),this.registerReportListener(null),this._rtcPeerConn.close(),this.reportParser=null}clearReTryExchangeTimer(){clearInterval(this._reTryExchangeTimer),this._reTryExchangeTimer=null}}var on,oi,Pt,Lt,ai;It.__INNER_EVENT_TRACK_READY__="inner-track-ready",function(n){n[n.DISABLE=0]="DISABLE",n[n.ENABLE=1]="ENABLE"}(on||(on={})),function(n){n[n.MeetingOrAnchor=1]="MeetingOrAnchor",n[n.Audience=2]="Audience"}(oi||(oi={}));class Ud{constructor(e,t,r,i,s=oi.MeetingOrAnchor){this._context=e,this._runtime=t,this._roomId=r,this._crtRTCRoom=i,this._userRole=s}_send(e){this._context.getConnectionStatus()===re.CONNECTED&&this._context.setRTCState(this._roomId,e)}_getClientID(){const e="uuid";let t=this._runtime.localStorage.getItem(e);return t||(t=Af(),this._runtime.localStorage.setItem(e,t)),t}_getRealResourceId(e){let t=e;const r=e.indexOf("_tiny");return r>-1&&(t=e.slice(0,r)),t}_getPolarisTrackId(e){let t="";const r=e.split("_");if(e.includes("_tiny")){const i=r.pop(),s=parseInt(r.pop())===me.AUDIO_ONLY?"audio":"video",o=r.pop();t=[r.join("_"),o,i,s].join("_")}else{const i=parseInt(r.pop())===me.AUDIO_ONLY?"audio":"video",s=r.pop();t=[r.join("_"),s,i].join("_")}return t}sendR3R4Data(e){const{iceCandidatePair:t,senders:r,receivers:i}=e,s=(t==null?void 0:t.bitrateSend)||-1,o=(t==null?void 0:t.bitrateRecv)||-1,c=(t==null?void 0:t.networkType)||"unknown",d=(t==null?void 0:t.rtt)||-1,l=`${(t==null?void 0:t.IP)||-1}:${t==null?void 0:t.port}`,h=(t==null||t.remoteIP,t==null||t.remotePort,(t==null?void 0:t.availableIncomingBitrate)||-1),a=(t==null?void 0:t.availableOutgoingBitrate)||-1,u=(t==null?void 0:t.totalPacketsLost)||-1,f=this._context.getCurrentId();let p=`R3 ${s} -1 -1 -1 ${c} ${d} ${l} ${h} ${a} ${u} ${f}\r`,m=`R4 ${o} -1 -1 -1 ${c} ${d} ${l} ${h} ${a} ${u} ${f}\r`;const _=r.map(y=>{var C;const{trackId:b,audioLevel:O,samplingRate:S,bitrate:E,packetsLostRate:w,frameRate:V,frameWidth:j,frameHeight:R,googRenderDelayMs:T,jitter:A,nackCount:L,pliCount:k,rtt:F,googFirsSent:H,encoderImplementation:G}=y,W=this._getPolarisTrackId(b),oe=this._getRealResourceId(b);return{trackId:W,googCodecName:G||String(-1),audioLevel:O||O===0?O:-1,bitrate:E||E===0?E:-1,packetsLostRate:w||w===0?w:-1,frameRate:V||-1,resolution:j&&R?`${j} * ${R}`:"-1",jitter:A||-1,nackCount:L||L===0?L:-1,pliCount:k||k===0?k:-1,rtt:F||-1,googFirsSent:H,samplingRate:S,googRenderDelayMs:T,encoderImplementation:G||String(-1),trackState:((C=this._crtRTCRoom.getLocalTrack(oe))===null||C===void 0?void 0:C.isLocalMuted())?on.DISABLE:on.ENABLE}}),v=i.filter(y=>!!y.trackId).map(y=>{var C;const{trackId:b,audioLevel:O,samplingRate:S,bitrate:E,packetsLostRate:w,frameRate:V,frameWidth:j,frameHeight:R,googRenderDelayMs:T,jitter:A,nackCount:L,pliCount:k,rtt:F,googFirsReceived:H,codecImplementationName:G}=y,W=this._getPolarisTrackId(b),oe=this._getRealResourceId(b);return{trackId:W,googCodecName:G||String(-1),audioLevel:O||O===0?O:-1,bitrate:E||E===0?E:-1,packetsLostRate:w||w===0?w:-1,frameRate:V||-1,resolution:j&&R?`${j} * ${R}`:"-1",jitter:A||-1,nackCount:L||L===0?L:-1,pliCount:k||k===0?k:-1,rtt:F||-1,googFirsReceived:H,samplingRate:S,googRenderDelayMs:T,codecImplementationName:G||String(-1),trackState:((C=this._crtRTCRoom.getRemoteTrack(oe))===null||C===void 0?void 0:C.isLocalMuted())?on.DISABLE:on.ENABLE}});p+=_.map(y=>`${y.trackId} ${y.googCodecName} ${y.audioLevel} ${y.samplingRate} ${y.bitrate} ${y.packetsLostRate} ${y.frameRate} ${y.resolution} ${y.googRenderDelayMs} ${y.jitter} ${y.nackCount} ${y.pliCount} ${y.rtt} ${y.googFirsSent} ${y.encoderImplementation} ${y.trackState}`).join(`
  900. `),e.senders.length&&this._send(p+`\r${this._userRole}`),m+=v.map(y=>`${y.trackId} ${y.googCodecName} ${y.audioLevel} ${y.samplingRate} ${y.bitrate} ${y.packetsLostRate} ${y.frameRate} ${y.resolution} ${y.googRenderDelayMs} ${y.jitter} ${y.nackCount} ${y.pliCount} ${y.rtt} ${y.googFirsReceived} ${y.codecImplementationName} ${y.trackState}`).join(`
  901. `),e.receivers.length&&this._send(m+`\r${this._userRole}`)}sendR1(){const e=`R1 5.3.1 ${this._context.getCoreVersion()} web ${navigator.platform} -1 ${dt.browser} ${dt.version} ${this._getClientID()} ${this._userRole}`;this._send(e)}sendR2(e,t,r){const i=`R2 ${e} ${t} ${this._getClientID()}\r${r.join(" ")}\r${this._userRole}`;this._send(i)}}(function(n){n.PUBLISH="publish",n.SUBSCRIBE="subscribe"})(Pt||(Pt={})),function(n){n.BEGIN="begin",n.END="end"}(Lt||(Lt={}));class Dd{constructor(e){this._room=e,this._audioLevelChangeHandler=null,this._timer=null,this._pc=this._room.__getPC()}_audioLevelReport(){return $(this,void 0,void 0,function*(){if(this._pc.getRTCPeerConn().iceConnectionState==="new"||!this._audioLevelChangeHandler)return;const e=(yield this._pc.getAudioLevelReportData()).map(t=>{const{userId:r}=Kf.parseTrackId(t.trackId);return{track:this._room.getCrtUserId()===r?this._room.getLocalTrack(t.trackId):this._room.getRemoteTrack(t.trackId),audioLevel:t.audioLevel||0}}).filter(t=>t.track);this._audioLevelChangeHandler(e)})}onAudioLevelChange(e,t){t<300||t>1e3?P.error('the valid range of onAudioLevelChange params "gap" is: > 300 && < 1000'):e?(this._audioLevelChangeHandler=e,this._timer=setInterval(this._audioLevelReport.bind(this),t)):this._audioLevelChangeHandler=null}clearAudioLevelReportTimer(){this._timer&&(clearInterval(this._timer),this._timer=null)}}(function(n){n[n.ANCHOR=1]="ANCHOR",n[n.AUDIENCE=2]="AUDIENCE"})(ai||(ai={}));const Dn=n=>n instanceof da?n.getTrackId():n.track.getTrackId();class xd{constructor(e,t,r,i,s,o,c,d,l,h){this._context=e,this._runtime=t,this._roomId=r,this._roomMode=s,this._service=o,this._initOptions=c,this._ntfClearRoomItem=d,this._isMainRoom=h,this._remoteTracks={},this._subscribedList=[],this._destroyed=!1,this.msgTaskQueue=new Wu,this._appListener=null,this._onRecvPKMsg=null,this._token=i.token,this._sessionId=i.sessionId,this._roomResources=l?{}:eo(i),this._initRemoteTracks();const a=this._context.getCurrentId(),u=this._roomResources[a]=this._roomResources[a]||[];P.debug(`room data -> ${JSON.stringify(this._roomResources)}`),u.length>0&&be(()=>this._unpublishPrev(u)),l&&this._afterChangedRole(i),this._pinger=new Mf(r,this._roomMode,e,this._initOptions.pingGap),this._pinger.onFailed=this._kickoff.bind(this),this._pinger.onPingResult=this._handlePingResult.bind(this),this._pinger.start(),this._polarisReport=new Ud(this._context,this._runtime,this._roomId,this),this._polarisReport.sendR1(),this._pc=new It(this._reTryExchange.bind(this),this._polarisReport),this._pc.on(It.__INNER_EVENT_TRACK_READY__,this._onTrackReady,this),this._pc.on(pe.__INNER_EVENT_MUTED_CHANGE__,this._onLocalTrackMuted,this),this._pc.on(pe.__INNER_EVENT_DESTROY__,this._onLocalTrackDestroied,this)}_initRemoteTracks(){const e=this._context.getCurrentId();for(const t in this._roomResources){const r=this._roomResources[t];t!==e&&r.length!==0&&r.forEach(i=>{const s=fe(i),{tag:o,userId:c,mediaType:d}=Ge(s),l=d===me.AUDIO_ONLY?new Ot(o,c):new At(o,c);l.__innerSetRemoteMuted(i.state===0),this._remoteTracks[s]=l})}}_handlePingResult(e){this._callAppListener("onPing",e)}setBitrate(e,t,r){P.warn("`RCAbstractRoom.setBitrate` will be deprecated, use `RCLocalTrack.setBitrate` instead."),xe("max",e,i=>Ie(i)&&i>Math.max(t||1,200),!0),xe("min",t,i=>Ie(i)&&i>=1&&(!Ie(e)||i<e),!0),xe("start",r,i=>Ie(i)&&i>t&&i<=e),this._pc.setBitrate(e,t,r)}_onTrackReady(e){const t=e.streams[0].id,r=e.receiver.track,i=[t,r.kind==="audio"?me.AUDIO_ONLY:me.VIDEO_ONLY].join("_"),s=this._remoteTracks[i];s?(s.__innerSetMediaStreamTrack(r),this._callAppListener("onTrackReady",s)):P.warn(`cannot found remote track ${r.id}`)}_callAppListener(e,...t){var r;const i=(r=this._appListener)===null||r===void 0?void 0:r[e];if(i)try{i(...t)}catch(s){P.error(s)}}_onUserUnpublish(e){return $(this,void 0,void 0,function*(){yield this.unsubscribe(e),e.forEach(t=>{t.__innerDestroy(),delete this._remoteTracks[t.getTrackId()]}),this._onTrackUnpublish(e)})}_onTrackUnpublish(e){this._callAppListener("onTrackUnpublish",e)}_unpublishPrev(e){return $(this,void 0,void 0,function*(){const t=e.slice();e.length=0,P.info(`unpublish uris prev login: ${JSON.stringify(t)}`);const r=yield this._context.setRTCTotalRes(this._roomId,Or(ce.UNPUBLISH,t),$t([]),ce.TOTAL_CONTENT_RESOURCE,$t([]));r!==N.SUCCESS?P.error(`unpublish prev uris failed -> code: ${r}`):P.debug("unpublish uris prev login succeed")})}__parseInnerMessage(e){const{targetId:t,conversationType:r}=e;if(r!==Q.RTC_ROOM)return!1;if(t!==this._roomId)return!0;P.info(`recv inner msg -> message: ${JSON.stringify(e)} | roomid: ${this._roomId}`);const i=e.content;switch(e.messageType){case ce.KICK:this._kickoff(!0,i);break;case ce.STATE:this.msgTaskQueue.push(()=>this._stateHandle(i));break;case ce.MODIFY:case ce.PUBLISH:case ce.UNPUBLISH:case ce.TOTAL_CONTENT_RESOURCE:this.msgTaskQueue.push(()=>this._resourceHandle(i,e.messageType,e.senderUserId));break;case ce.ROOM_NOTIFY:this._callAppListener("onRoomAttributeChange",e.messageType,e.content);break;case ce.USER_NOTIFY:P.warn(`TODO: ${ce.USER_NOTIFY}`);break;case ce.PK_INVITE:case ce.PK_CANCEL_INVITE:case ce.PK_INVITE_TIMEOUT:case ce.PK_INVITE_ANSWER:case ce.PK_END:this._onRecvPKMsg&&this._onRecvPKMsg(e);break;case ce.OTHER_ROOM_OFFLINE:break;default:this._callAppListener("onMessageReceive",e.messageType,e.content,e.senderUserId,e.messageUId)}return!0}_kickoff(e,t){let r;P.warn(`onKickOff -> byServer: ${e}`),this._ntfClearRoomItem(),this._leaveHandle(!e),e&&((t==null?void 0:t.users)||[]).forEach(i=>{i.userId===this._context.getCurrentId()&&(r=i.type)}),this._callAppListener("onKickOff",e,r)}_rtcpeerClosed(){this._ntfClearRoomItem(),this._leaveHandle(!0),this._callAppListener("onRTCPeerConnectionCloseByException")}_resourceHandle(e,t,r){return $(this,void 0,void 0,function*(){if(this._assertRoomDestroyed())return void P.warn(`room has been destroyed. -> roomId: ${this._roomId}`);const{uris:i,ignore:s}=e;if(s||!i)return;const o=[],c=[],d=[];let l;const h=this._roomResources[r]||(this._roomResources[r]=[]);switch(t){case ce.MODIFY:d.push(...i);break;case ce.PUBLISH:o.push(...i);break;case ce.UNPUBLISH:c.push(...i);break;case ce.TOTAL_CONTENT_RESOURCE:l=Hr(h,i),o.push(...l.publishedList),c.push(...l.unpublishedList),d.push(...l.modifiedList)}if(o.length>0){const a=h.map(fe),u=[],f=[];if(o.forEach(p=>{const m=fe(p),_=a.indexOf(m),{userId:v,tag:y,mediaType:C}=Ge(m);_>-1?h[_]=p:h.push(p);let b=this._remoteTracks[m];b?b.isSubscribed()&&u.push(b):(b=C===me.AUDIO_ONLY?new Ot(y,v):new At(y,v),this._remoteTracks[m]=b,f.push(b)),b.__innerSetRemoteMuted(p.state===0)}),u.length){const p=u.map(_=>_.getTrackId());P.debug(`resub tracks -> ${JSON.stringify(p)}`);const{code:m}=yield be(()=>this.__subscribe(u,!0));m!==M.SUCCESS&&P.error(`resub tracks failed -> code: ${m}, ids: ${JSON.stringify(p)}`)}this._onTrackPublish(f)}if(c.length>0){const a=c.map(fe);for(let f=h.length-1;f>=0;f-=1){const p=h[f];a.includes(fe(p))&&h.splice(f,1)}const u=c.map(f=>{const p=fe(f);return this._remoteTracks[p]});yield this._onUserUnpublish(u)}if(d.length>0){const a=h.map(fe);for(let u=0;u<d.length;u+=1){const f=d[u],p=fe(f),m=a.indexOf(p);h[m].state=f.state;const _=this._remoteTracks[p];_.__innerSetRemoteMuted(f.state===0),_.isAudioTrack()?this._onAudioMuteChange(_):this._onVideoMuteChange(_)}}})}_onTrackPublish(e){this._callAppListener("onTrackPublish",e)}_stateHandle(e){var t;return $(this,void 0,void 0,function*(){const{users:r}=e;if(r.length===0)return;const i=[],s=[],o=[],c=[];r.forEach(h=>{+h.state==0?(P.debug(`user joined -> ${h.userId}`),this._roomResources[h.userId]||(h.switchRoleType?o.push(h.userId):i.push(h.userId)),this._roomResources[h.userId]=this._roomResources[h.userId]||[]):(P.debug(`user left -> ${h.userId}`),h.switchRoleType?c.push(h.userId):s.push(h.userId))});const d=[...i,...o],l=[...s,...c];if(l.length){const h=[],a=[];l.forEach(u=>{h.push(...this.getRemoteTracksByUserId(u)),a.push(u)}),h.length&&(yield this.unsubscribe(h),h.forEach(u=>delete this._remoteTracks[u.getTrackId()])),a.length&&a.forEach(u=>delete this._roomResources[u])}if((t=this._appListener)===null||t===void 0?void 0:t.onSwitchRole)return o.length&&o.forEach(h=>this._callAppListener("onSwitchRole",h,ai.ANCHOR)),c.length&&c.forEach(h=>this._callAppListener("onSwitchRole",h,ai.AUDIENCE)),i.length&&this._callAppListener("onUserJoin",i),void(s.length&&this._callAppListener("onUserLeave",s));d.length&&this._callAppListener("onUserJoin",d),l.length&&this._callAppListener("onUserLeave",l)})}getRoomId(){return this._roomId}getCrtUserId(){return this._context.getCurrentId()}__getPC(){return this._pc}getRemoteUserIds(){const e=this._context.getCurrentId();return Object.keys(this._roomResources).filter(t=>t!==e)}getRemoteTracks(){const e=[];return this.getRemoteUserIds().forEach(t=>{e.push(...this.getRemoteTracksByUserId(t))}),e}getRemoteTracksByUserId(e){const t=[];for(const r in this._remoteTracks){const i=this._remoteTracks[r];i.getUserId()===e&&t.push(i)}return t}getSessionId(){return this._sessionId}sendMessage(e,t){return $(this,void 0,void 0,function*(){const{code:r}=yield this._context.sendMessage(Q.RTC_ROOM,this._roomId,{messageType:e,content:t,isStatusMessage:!0});return r!==N.SUCCESS?(P.error(`send message failed -> code: ${r}`),{code:M.SIGNAL_ERROR}):{code:M.SUCCESS}})}setRoomAttribute(e,t,r,i=!1){return $(this,void 0,void 0,function*(){const s=yield this._context.setRTCData(this._roomId,e,t,i,yt.ROOM,r);return s!==N.SUCCESS?(P.error(`SetRoomAttributeValue Failed: ${s}`),{code:M.SIGNAL_ERROR}):{code:M.SUCCESS}})}deleteRoomAttributes(e,t,r=!1){return $(this,void 0,void 0,function*(){const i=yield this._context.removeRTCData(this._roomId,e,r,yt.ROOM,t);return i!==N.SUCCESS?(P.error(`DeleteRoomAttribute Failed: ${i}`),{code:M.SIGNAL_ERROR}):{code:M.SUCCESS}})}getRoomAttributes(e=[],t=!1){return $(this,void 0,void 0,function*(){const{code:r,data:i}=yield this._context.getRTCData(this._roomId,e,t,yt.ROOM);return r!==N.SUCCESS?(P.error(`GetRoomAttributes Failed: ${r}`),{code:M.SIGNAL_ERROR}):{code:M.SUCCESS,data:i}})}_setUserAttributeValue(e,t,r){return this._context.setRTCData(this._roomId,e,t,!1,yt.PERSON,r)}_deleteUserAttributes(e,t){return this._context.removeRTCData(this._roomId,e,!1,yt.PERSON,t)}_getUserAttributes(e){return this._context.getRTCData(this._roomId,e,!1,yt.PERSON)}isDestroyed(){return this._destroyed}__destroy(e){return this._leaveHandle(e)}_leaveHandle(e){var t;return $(this,void 0,void 0,function*(){this._destroyed||(this._destroyed=!0,(t=this._audioLevelReport)===null||t===void 0||t.clearAudioLevelReportTimer(),e&&(yield this._context.quitRTCRoom(this._roomId)),this._isMainRoom&&this._quitAllPKRoom(),this._pc.removeAllLocalTrack(),this._pinger.stop(),this._isMainRoom&&(yield this._service.exit(this._getRTCReqestHeaders())),this._pc.destroy(),this._polarisReport=null,this._removeRemoteTracks())})}_onLocalTrackDestroied(e){e instanceof pn&&e.__isTiny()||this.unpublish([e])}_onLocalTrackMuted(e){return $(this,void 0,void 0,function*(){const t=e.getTrackId(),r=this._context.getCurrentId(),i=[{resourceId:t,enabled:!e.isLocalMuted()}],s=this._roomResources[r]||[],o=[];for(let d=0;d<s.length;d+=1){const l=s[d],h=fe(l),a=i.findIndex(u=>u.resourceId===h);if(a>=0){const{enabled:u}=i[a];l.state=u?1:0,o.push(l);break}}const c=yield be(()=>this._context.setRTCTotalRes(this._roomId,Or(ce.MODIFY,o),$t(s),ce.TOTAL_CONTENT_RESOURCE));c!==N.SUCCESS&&P.error("notice `track.enabled` change failed -> code: "+c)})}_removePubFailedTracks(e){e.forEach(t=>{const r=t instanceof pe?t:t.track;P.debug(`remove pub failed track from peerconnection -> trackId: ${r.getTrackId()}`),this._pc.removeLocalTrackById(r.getTrackId())})}publish(e){return $(this,void 0,void 0,function*(){return be(()=>this.__publish(e))})}__publish(e){return $(this,void 0,void 0,function*(){if(!this._isMainRoom&&this instanceof kt)return P.error("the `publish` is disabled in PK room "),{code:M.THE_FUNCTION_IS_DISABLED_IN_PKROOM};if(this._assertRoomDestroyed())return P.error(`publish failed, room has been destroyed. -> roomId: ${this._roomId}`),{code:M.ROOM_HAS_BEEN_DESTROYED};if(!Ee("tracks",e,()=>ze(e)&&e.length>0&&e.every(C=>C instanceof pe||C.track instanceof pe),!0))return P.error(`publish failed, tracks is invalid -> roomId: ${this._roomId}`),{code:M.PARAMS_ERROR};const t=this._context.getCurrentId();if(this._pc.getLocalTracks().length+(C=>{let b=0;return C.forEach(O=>{O instanceof pe?b++:O.pubTiny&&O.track.isVideoTrack()?b+=2:b++}),b})(e)>10)return P.error(`publish failed, tracks limit exceeded -> roomId: ${this._roomId}`),{code:M.PUBLISH_TRACK_LIMIT_EXCEEDED};P.debug(`publish tracks -> roomId: ${this._roomId}, tracks: ${e.map(Dn)}`),e.forEach(C=>{const{track:b,pubTiny:O}=C instanceof pe?{pubTiny:!1,track:C}:C;if(this._pc.addLocalTrack(b),b.isVideoTrack()&&O){let S;try{S=b.__innerGetMediaStreamTrack().clone();const E=O.frameRate||Ct.FPS_15,w=O.resolution||Re.W176_H144,{width:V,height:j}=Et(w),R=Rt(E);S.applyConstraints({width:V,height:j,frameRate:R})}catch(E){return S==null||S.stop(),void P.warn(`pubTiny failed -> id: ${b.getTrackId()}, msg: ${E.message}`)}this._pc.addLocalTrack(new pn(b.getTag(),b.getUserId(),S,!0))}}),this._pc.clearReTryExchangeTimer();const r=yield this._createExchangeParams(this._subscribedList,!1),i=this._getPushOtherRoomsParams();i&&(r.pushOtherRooms=i);const s=yield this._exchangeHandle(r);if(s.code!==M.SUCCESS)return P.error(`publish failed -> roomId: ${this._roomId}, code: ${s.code}`),this._removePubFailedTracks(e),{code:s.code};const{publishList:o,sdp:c,resultCode:d,message:l,urls:h,mcuPublishList:a}=s.data;if(d!==M.SUCCESS)return P.error(`publish failed -> roomId: ${this._roomId}, code: ${d}, msg: ${l}`),this._removePubFailedTracks(e),{code:d};const u=yield this._pc.setRemoteAnswer(c.sdp);if(u!==M.SUCCESS)return{code:u};const f=this._roomResources[t],p=o.map(C=>Object.assign({tag:C.msid.split("_").pop(),state:this._getResourceState(fe(C))},C)),{publishedList:m}=Hr(f,p),_=(a==null?void 0:a.map(C=>Object.assign({tag:C.msid.split("_").pop(),state:1},C)))||[],v=yield this._context.setRTCTotalRes(this._roomId,Or(ce.PUBLISH,m),$t(p),ce.TOTAL_CONTENT_RESOURCE,$t(_));if(v!==N.SUCCESS)return P.error(`send publish streams notification failed: ${v}`),{code:M.SIGNAL_ERROR};this._roomResources[t]=p;const y=m.map(C=>fe(C));return this._polarisReport&&this._polarisReport.sendR2(Pt.PUBLISH,Lt.BEGIN,y),e.forEach(C=>{const{track:b}=C instanceof pe?{track:C}:C;b.__innerSetPublished(!0)}),P.debug(`publish success: ${y.join(",")}`),this._roomMode===Ye.LIVE?{code:M.SUCCESS,liveUrl:h==null?void 0:h.liveUrl}:{code:M.SUCCESS}})}_getPushOtherRoomsParams(){if(this instanceof kt){const{code:e,roomPKHandler:t}=this.getRoomPKHandler(),r=[];if(e===M.SUCCESS&&t){const i=t.getJoinedPKRooms();for(const s in i){const o=i[s].getSessionId(),c=t.getPKInfo(s);if(!c)return;const{inviterUserAutoMix:d,inviteeUserAutoMix:l,inviterUserId:h}=c,a=this._context.getCurrentId()===h;r.push({roomId:s,sessionId:o,autoMix:a?!!d:!!l})}}return r}}_reTryExchange(){return $(this,void 0,void 0,function*(){be(()=>$(this,void 0,void 0,function*(){const e=yield this._createExchangeParams(this._subscribedList,!0),t=this._getPushOtherRoomsParams();t&&(e.pushOtherRooms=t);const r=yield this._exchangeHandle(e);if(r.code!==M.SUCCESS)return P.error(`reTryExchange failed: ${r.code}`),{code:r.code};const{sdp:i,resultCode:s}=r.data;if(s!==M.SUCCESS)return P.error(`reTryExchange failed: ${s}`),{code:s};this._pc.clearReTryExchangeTimer();const o=yield this._pc.setRemoteAnswer(i.sdp);return o!==M.SUCCESS?{code:o}:void 0}))})}_exchangeHandle(e){return this._service.exchange(this._getRTCReqestHeaders(),e)}_getRTCReqestHeaders(){return{"App-Key":this._context.getAppkey(),RoomId:this._roomId,Token:this._token,RoomType:this._roomMode,UserId:this._context.getCurrentId()}}_createExchangeParams(e,t){return $(this,void 0,void 0,function*(){return{sdp:yield this._pc.createOffer(t),extend:JSON.stringify({resolutionInfo:this._pc.getOutboundVideoInfo()}),subscribeList:e.filter(r=>{const i=r.track.getTrackId(),{userId:s}=Ge(i);return this._roomResources[s]?this._roomResources[s].filter(c=>i===`${c.msid}_${c.mediaType}`).length:!1}).map(r=>({simulcast:r.subTiny?ct.TINY:ct.NORMAL,resolution:"",uri:this._getResourceById(r.track.getTrackId()).uri})),switchstream:!1}})}_getResourceState(e){var t;return((t=this.getLocalTrack(e))===null||t===void 0?void 0:t.isLocalMuted())?0:1}unpublish(e){return $(this,void 0,void 0,function*(){return be(()=>this.__unpublish(e))})}__unpublish(e){var t;return $(this,void 0,void 0,function*(){if(!this._isMainRoom&&this instanceof kt)return P.error("the `unpublish` is disabled in PK room "),{code:M.THE_FUNCTION_IS_DISABLED_IN_PKROOM};if(this._assertRoomDestroyed())return P.warn(`room has been destroyed, no need to unpublish tracks -> roomId: ${this._roomId}`),{code:M.SUCCESS};const r=this._context.getCurrentId();if(!Ee("tracks",e,()=>e.every(C=>C.getUserId()===r&&C instanceof pe),!0))return P.warn(`unpublish failed, tracks is invalid -> roomId: ${this._roomId}, tracks: ${e.map(Dn)}`),{code:M.PARAMS_ERROR};const i=e.map(C=>C.getTrackId()),s=i.map(this._getResourceById.bind(this)).filter(C=>!!C);if(s.length===0)return{code:M.SUCCESS};const o=this._roomResources[r].filter(C=>!s.includes(C));i.forEach(C=>this._pc.removeLocalTrackById(C)),(t=this._polarisReport)===null||t===void 0||t.sendR2(Pt.PUBLISH,Lt.END,i),this._pc.clearReTryExchangeTimer();const c=yield this._createExchangeParams(this._subscribedList,!1),d=this._getPushOtherRoomsParams();d&&(c.pushOtherRooms=d);const l=yield this._exchangeHandle(c);if(l.code!==M.SUCCESS)return P.error(`exchange failed -> code: ${l.code}`),{code:l.code};const{publishList:h,sdp:a,resultCode:u,message:f,mcuPublishList:p}=l.data;u!==M.SUCCESS&&P.error(`unpublish streams failed -> code: ${u}, msg: ${f}`);const m=p?p.map(C=>Object.assign({tag:C.msid.split("_").pop(),state:1},C)):[],_=yield this._context.setRTCTotalRes(this._roomId,Or(ce.UNPUBLISH,s),$t(o),ce.TOTAL_CONTENT_RESOURCE,$t(m));if(_!==N.SUCCESS)return P.error("send unpublish notification failed:",_),{code:M.SIGNAL_ERROR};P.debug(`unpublish success -> tracks: ${i.join(",")}`);const v=yield this._pc.setRemoteAnswer(a.sdp);if(v!==M.SUCCESS)return{code:v};const y=h.map(C=>Object.assign({tag:C.msid.split("_").pop(),state:this._getResourceState(fe(C))},C));return this._roomResources[r]=y,{code:M.SUCCESS}})}_getResourceById(e){const{userId:t}=Ge(e);return this._roomResources[t].find(r=>fe(r)===e)}_isValidResourceId(e){var t;const{userId:r}=Ge(e);return!!((t=this._roomResources[r])===null||t===void 0?void 0:t.find(i=>fe(i)===e))}subscribe(e){return $(this,void 0,void 0,function*(){return be(()=>this.__subscribe(e,!1))})}__subscribe(e,t=!1){var r;return $(this,void 0,void 0,function*(){if(this._assertRoomDestroyed())return P.error(`subscribe failed, room has been destroyed -> roomId: ${this._roomId}`),{code:M.ROOM_HAS_BEEN_DESTROYED};if(!Ee("tracks",e,()=>ze(e)&&e.length>0&&e.every(d=>d instanceof Fe||d.track instanceof Fe),!0))return P.error(`subscribe failed, tracks is invalid -> roomId: ${this._roomId}`),{code:M.PARAMS_ERROR};P.info(`subscribe -> roomId: ${this._roomId}, tracks: ${e.map(Dn)}`);const i=this._subscribedList.map(d=>Object.assign({},d)),s=e.map(d=>d instanceof Fe?{track:d}:d);let o=!1;const c=[];return s.forEach(d=>{const l=d.track.getTrackId();c.push(l);const h=i.find(a=>a.track.getTrackId()===l);h&&h.subTiny===d.subTiny||(h?h.subTiny=d.subTiny:i.push(d),o=!0)}),o||t?((r=this._polarisReport)===null||r===void 0||r.sendR2(Pt.SUBSCRIBE,Lt.BEGIN,c),this._updateSubListHandle(i,!0)):{code:M.SUCCESS}})}unsubscribe(e){return $(this,void 0,void 0,function*(){return be(()=>this.__unsubscribe(e))})}__unsubscribe(e){var t;return $(this,void 0,void 0,function*(){if(this._assertRoomDestroyed())return P.warn(`room has beed destroyed, no need to unsubscribe tracks -> roomId: ${this._roomId}`),{code:M.SUCCESS};if(!Ee("tracks",e,()=>ze(e)&&e.length>0&&e.every(i=>i instanceof Fe),!0))return P.error(`unsubscribe failed, tracks is invalid -> roomId: ${this._roomId}`),{code:M.PARAMS_ERROR};P.info(`unsubscribe -> roomId: ${this._roomId}, tracks: ${e.map(Dn)}`);const r=this._subscribedList.map(i=>Object.assign({},i)).filter(i=>!e.includes(i.track));return(t=this._polarisReport)===null||t===void 0||t.sendR2(Pt.SUBSCRIBE,Lt.END,e.map(i=>i.getTrackId())),this._updateSubListHandle(r,!1)})}_assertRoomDestroyed(){if(this._destroyed){const e="This room has been destroyed. Please use `RCRTCClient.joinRTCRoom` or `RCRTCClient.joinLivingRoom` to catch another instance.";return P.warn(e),M.ROOM_HAS_BEEN_DESTROYED}}getLocalTrack(e){return this._pc.getLocalTrack(e)}getLocalTracks(){return this._pc.getLocalTracks()}getRemoteTrack(e){return this._remoteTracks[e]||null}updateSubList(e){return $(this,void 0,void 0,function*(){return be(()=>this._updateSubListHandle(e,!1))})}_updateSubListHandle(e,t=!1){return $(this,void 0,void 0,function*(){if(this._assertRoomDestroyed())return{code:M.ROOM_HAS_BEEN_DESTROYED};if(!Ee("resources",e,()=>ze(e)&&e.every(y=>y instanceof Fe||y.track instanceof Fe),!0))return P.error(`update sublist failed, tracks is invalid -> roomId: ${this._roomId}`),{code:M.PARAMS_ERROR};P.info(`update subscribe list -> roomId: ${this._roomId}, forceReq: ${t}, tracks: ${e.map(Dn)}`);let r=e.map(y=>y instanceof Fe?{track:y}:Object.assign({},y));const i={};r=r.filter(y=>{const C=y.track.getTrackId();return this._remoteTracks[C]?!i[C]&&(i[C]=!0):(P.warn(`track cannot found in room -> trackId: ${C}`),!1)}).map(y=>Object.assign({},y));const s=this._subscribedList.map(y=>Object.assign({},y));if(!t){let y=!1;if(r.forEach(C=>{const b=s.findIndex(O=>O.track===C.track);if(b===-1)return void(y=!0);s.splice(b,1)[0].subTiny!==C.subTiny&&(y=!0)}),s.length&&(y=!0),!y)return{code:M.SUCCESS}}this._pc.clearReTryExchangeTimer(),this._pc.updateSubRemoteTracks(r.map(y=>y.track));const o=yield this._createExchangeParams(r,!1),c=this._getPushOtherRoomsParams();c&&(o.pushOtherRooms=c);const d=yield this._exchangeHandle(o),l=r.map(y=>y.track.getTrackId());if(d.code!==M.SUCCESS)return{code:d.code};const{sdp:h,resultCode:a,message:u,subscribedList:f}=d.data;if(a!==M.SUCCESS)return P.error(`change subscribe list failed: ${a}`),{code:a};P.debug(`subscribe success: ${l.join(",")}`);const p=yield this._pc.setRemoteAnswer(h.sdp);if(p!==M.SUCCESS)return{code:p};const m=f==null?void 0:f.map(y=>`${y.msid}_${y.mediaType}`),_=r.filter(y=>m==null?void 0:m.includes(y.track.getTrackId())),v=r.filter(y=>!(m==null?void 0:m.includes(y.track.getTrackId())));for(const y in this._remoteTracks){const C=_.some(b=>b.track.getTrackId()===y);this._remoteTracks[y].__innerSetSubscribed(C)}return this._subscribedList.splice(0,this._subscribedList.length,..._),v.length?{code:M.SUCCESS,failedList:v}:{code:M.SUCCESS}})}registerRoomEventListener(e){this._appListener=e}registerReportListener(e){this._pc.registerReportListener(e)}onAudioLevelChange(e,t){var r;(r=this._audioLevelReport)===null||r===void 0||r.clearAudioLevelReportTimer(),this._audioLevelReport=new Dd(this),this._audioLevelReport.onAudioLevelChange(e,t||1e3)}__onReconnected(e){return $(this,void 0,void 0,function*(){if(this._pc.getRTCPeerConn().connectionState==="closed")return P.warn("RTCPeerConnection closed. Please rejoin room to restore services."),void this._rtcpeerClosed();const{code:t,data:r}=yield this._context.joinRTCRoom(this._roomId,this._roomMode,e);if(t!==N.SUCCESS)return void P.error(`RTC __onReconnected getRTCRoomInfo failed: ${t}`);P.debug(`RTC __onReconnected getRTCRoomInfo success: ${JSON.stringify(r)}`);const i=[],s={},o={},c={},d=eo(r),l=Object.keys(d),h=Object.keys(this._roomResources);for(let a=l.length-1;a>=0;a-=1){const u=l[a],f=h.indexOf(u);if(f===-1){i.push(u),s[u]=Ar(d[u]);continue}const p=this._roomResources[u],m=d[u],{publishedList:_,modifiedList:v,unpublishedList:y}=Hr(p,m,!0);s[u]=Ar(_),o[u]=Ar(y),c[u]=Ar(v),h.splice(f,1)}h.length&&h.forEach(a=>{delete this._roomResources[a]}),Object.assign(this._roomResources,d),h.length&&this._callAppListener("onUserLeave",h),i.length&&this._callAppListener("onUserJoin",i);for(const a in o){const u=o[a];if(u.length){const f=u.map(p=>this._remoteTracks[fe(p)]);yield this._onUserUnpublish(f)}}return Object.keys(s).forEach(a=>{const u=s[a];if(u.length===0)return;const f=u.map(p=>{const m=fe(p),{userId:_,tag:v,mediaType:y}=Ge(m),C=this._remoteTracks[m]=y===me.AUDIO_ONLY?new Ot(v,_):new At(v,_);return C.__innerSetRemoteMuted(p.state===0),C});this._onTrackPublish(f)}),Object.keys(c).forEach(a=>{c[a].forEach(u=>{const f=fe(u),p=this._remoteTracks[f];p.__innerSetRemoteMuted(u.state===0),p.isAudioTrack()?this._onAudioMuteChange(p):this._onVideoMuteChange(p)})}),{data:r}})}_onAudioMuteChange(e){this._callAppListener("onAudioMuteChange",e)}_onVideoMuteChange(e){this._callAppListener("onVideoMuteChange",e)}_afterChangedRole(e){}_removeRemoteTracks(){const e=Object.values(this._remoteTracks);e.length&&(e.forEach(t=>{t.isAudioTrack()&&t.__releaseMediaElement()}),this._remoteTracks={})}_registerPKMsgListener(e){this._onRecvPKMsg=e}_quitAllPKRoom(){}}var jn,ln,nr;(function(n){n[n.CROP=1]="CROP",n[n.WHOLE=2]="WHOLE"})(jn||(jn={})),function(n){n[n.CUSTOMIZE=1]="CUSTOMIZE",n[n.SUSPENSION=2]="SUSPENSION",n[n.ADAPTATION=3]="ADAPTATION"}(ln||(ln={})),function(n){n[n.CROP=1]="CROP",n[n.WHOLE=2]="WHOLE"}(nr||(nr={}));const xc=()=>({version:1,mode:ln.SUSPENSION});class xf{constructor(e,t,r){this._onFlush=e,this._isValidTrackId=t,this._sendCDNInfoSignal=r,this._values=xc()}setHostVideoTrack(e){if(!this._isValidTrackId(e))return P.error(`setHostVideoTrack failed: videoTrackId is invalid -> ${e}`),this;const{mediaType:t,tag:r,userId:i}=Ge(e);return t!==me.VIDEO_ONLY?(P.error(`setHostVideoTrack failed: kind of resource is not 'video' -> ${e}`),this):(this._values.host_stream_id=ss(i,r),this)}setMixLayoutMode(e){return[ln.CUSTOMIZE,ln.SUSPENSION,ln.ADAPTATION].includes(e)?(this._values.mode=e,this):(P.error(`layout mode is invalid: ${e}`),this)}_addOutputValue(e,t,r="normal"){const i=this._values.output||(this._values.output={video:{normal:{width:640,height:480}}});if(e==="cdn")return void(i.cdn=t);if(e==="audio")return void(i.audio={bitrate:t});const s=i.video;if(r!=="normal"&&r!=="tiny")if(r!=="backgroundColor")if(r!=="exparams"){if(r==="backgroundPicture"){const o=s.backgroundPicture||(s.backgroundPicture={fillMode:jn.CROP,picture:[]});Object.assign(o,t)}}else s.exparams={renderMode:t};else s.backgroundColor=t;else{const o=s[r]||(s[r]={});Object.assign(o,t)}}setOutputVideoResolution(e){if(!dn(e))return P.warn("setOutputVideoResolution failed: `resolution` is invalid"),this;const{width:t,height:r}=Et(e);return this._addOutputValue("video",{width:t,height:r},"normal"),this}setOutputVideoFPS(e){if(!Xs(e))return P.warn("setOutputVideoFPS failed: `fps` is invalid"),this;const t=Rt(e);return this._addOutputValue("video",{fps:t},"normal"),this}setOutputVideoBitrate(e){return!Ie(e)||e<=0?P.error(`bitrate is invalid: ${e}`):this._addOutputValue("video",{bitrate:e},"normal"),this}setOutputTinyVideoResolution(e){if(!dn(e))return P.warn("setOutputTinyVideoResolution failed: `resolution` is invalid"),this;const{width:t,height:r}=Et(e);return this._addOutputValue("video",{width:t,height:r},"tiny"),this}setOutputTinyVideoFPS(e){if(!Xs(e))return P.warn("setOutputTinyVideoFPS failed: `fps` is invalid"),this;const t=Rt(e);return this._addOutputValue("video",{fps:t},"tiny"),this}setOutputTinyVideoBitrate(e){return!Ie(e)||e<=0?P.error(`bitrate is invalid: ${e}`):this._addOutputValue("video",{bitrate:e},"tiny"),this}setOutputVideoRenderMode(e){return[nr.CROP,nr.WHOLE].includes(e)?this._addOutputValue("video",e,"exparams"):P.error(`renderMode is invalid: ${e}`),this}setOutputAudioBitrate(e){return Ie(e)&&e>0?this._addOutputValue("audio",e):P.error(`bitrate is invalid: ${e}`),this}setOutputBackgroundColor(e){return/^0x[a-fA-F0-9]{6}$/.test(e)?this._addOutputValue("video",e,"backgroundColor"):P.error(`color is invalid: ${e}`),this}addOutputBackgroundPicture(e,t,r,i,s){var o,c,d;if(!Yn(e))return P.error(`uri is invalid: ${e}`),this;if([t,r,i,s].some(h=>!Ie(h)||h<0||h>1))return P.error(`some attrs of (x, y, w, h) is invalid: ${t}, ${r}, ${i}, ${s}`),this;const l=((d=(c=(o=this._values.output)===null||o===void 0?void 0:o.video)===null||c===void 0?void 0:c.backgroundPicture)===null||d===void 0?void 0:d.picture)||[];return l.push({uri:e,w:i,h:s,x:t,y:r}),this._addOutputValue("video",{picture:l},"backgroundPicture"),this}removeOutputBackgroundPicture(e){var t,r,i;if(!Yn(e))return P.error(`uri is invalid: ${e}`),this;let s=(i=(r=(t=this._values.output)===null||t===void 0?void 0:t.video)===null||r===void 0?void 0:r.backgroundPicture)===null||i===void 0?void 0:i.picture;return s&&(s=s.filter(o=>o.uri!==e),this._addOutputValue("video",{pictures:s},"backgroundPicture")),this}clearOutputBackgroundPicture(){return this._addOutputValue("video",{pictures:[]},"backgroundPicture"),this}setOutputBackgroundPictureFillMode(e){return[jn.CROP,jn.WHOLE].includes(e)?this._addOutputValue("video",{fillMode:e},"backgroundPicture"):P.error(`fillMode is invalid: ${e}`),this}addPublishStreamUrls(e){var t,r;const i=/^rtmp:\/\/.+/;if(!ze(e)||e.length===0||e.some(c=>!i.test(c)))return P.error(`urls is invalid: ${e}`),this;const s=((r=(t=this._values.output)===null||t===void 0?void 0:t.cdn)===null||r===void 0?void 0:r.concat())||[];let o=!1;return e.forEach(c=>{s.some(d=>d.pushurl===c)||(o=!0,s.push({pushurl:c}))}),s.length>5?(P.error("publish stream url no more than 5"),this):(o&&this._addOutputValue("cdn",s),this)}removePublishStreamUrls(e){var t,r;const i=/^rtmp:\/\/.+/;if(!ze(e)||e.length===0||e.some(o=>!i.test(o)))return P.error(`urls is invalid: ${e}`),this;const s=((r=(t=this._values.output)===null||t===void 0?void 0:t.cdn)===null||r===void 0?void 0:r.concat())||[];for(let o=s.length-1;o>=0;o-=1){const{pushurl:c}=s[o],d=e.indexOf(c);d>=0&&(e.splice(d,1),s.splice(o,1))}return this._addOutputValue("cdn",s),this}clearPublishStreamUrls(){return this._addOutputValue("cdn",[]),this}addCustomizeLayoutVideo(e,t,r,i,s){if(!this._isValidTrackId(e))return P.error(`trackId is invalid: ${e}`),this;if(!Ie(t)||!Ie(r))return P.error(`some attrs of (x, y) is invalid: ${t}, ${r}`),this;if([i,s].some(h=>!Ie(h)||h<0))return P.error(`some attrs of (width, height) is invalid: ${i}, ${s}`),this;const{userId:o,tag:c,mediaType:d}=Ge(e);if(d!==me.VIDEO_ONLY)return P.error(`kind of resource is not 'video': ${e}`),this;const l=ss(o,c);return(this._values.input||(this._values.input={video:[]})).video.push({user_id:o,stream_id:l,x:t,y:r,width:i,height:s}),this}removeCustomizeLayoutVideo(e){if(!this._isValidTrackId(e))return P.error(`trackId is invalid: ${e}`),this;const{userId:t,tag:r,mediaType:i}=Ge(e);if(i!==me.VIDEO_ONLY)return P.error(`kind of resource is not 'video': ${e}`),this;const s=ss(t,r),o=this._values.input||(this._values.input={video:[]});return o.video=o.video.filter(c=>c.stream_id===s),this}clearCustomizeLayoutVideo(){return(this._values.input||(this._values.input={video:[]})).video=[],this}flush(){var e,t,r,i;return $(this,void 0,void 0,function*(){const s=JSON.parse(JSON.stringify(this._values)),{code:o}=yield this._onFlush(s);return o===M.SUCCESS&&(((t=(e=this._values.output)===null||e===void 0?void 0:e.video.normal)===null||t===void 0?void 0:t.width)||((i=(r=this._values.output)===null||r===void 0?void 0:r.video.normal)===null||i===void 0?void 0:i.fps))&&this._sendCDNInfoSignal(),this._values=xc(),{code:o}})}}var ci,ui,di,pt;(function(n){n[n.OPEN=1]="OPEN",n[n.STOP=2]="STOP"})(ci||(ci={})),function(n){n[n.SPREAD=0]="SPREAD",n[n.NO_SPREAD=-1]="NO_SPREAD"}(ui||(ui={})),function(n){n[n.AUTOMATIC=0]="AUTOMATIC",n[n.MANUAL=1]="MANUAL"}(di||(di={})),function(n){n[n.VIDEO=0]="VIDEO",n[n.AUDIO=1]="AUDIO"}(pt||(pt={}));const Bd=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(n){const e=16*Math.random()|0;return(n==="x"?e:3&e|8).toString(16)});class Bf{constructor(e,t,r,i,s,o,c,d){this._context=e,this._runtime=t,this._service=r,this._initOptions=i,this._mainLivingRoom=s,this._registerPKMsgListener=o,this._onJoinedPKRoom=c,this._onLeavePKRoom=d,this._inviteTimeout=30,this._PKInfo={},this._appListener=null,this._joinedPKRooms={},this._registerPKMsgListener(this._onRecvPKMsg.bind(this)),this._mainRoomId=this._mainLivingRoom.getRoomId()}_callAppListener(e,...t){var r;const i=(r=this._appListener)===null||r===void 0?void 0:r[e];if(i)try{i(...t)}catch(s){P.error(s)}}_onInvite(e){const t=e.inviteInfo||{},{inviterRoomId:r,inviterUserId:i,extra:s}=t,o={inviterRoomId:r,inviterUserId:i};s&&Object.assign(o,{extra:s}),this._PKInfo[r]=t,this._callAppListener("onRequestJoinOtherRoom",o)}_onCancelInvite(e){const{inviterRoomId:t,inviterUserId:r,extra:i}=e.inviteInfo||{},s={inviterRoomId:t,inviterUserId:r};i&&Object.assign(s,{extra:i}),delete this._PKInfo[t],this._callAppListener("onCancelRequestOtherRoom",s)}_onInviteTimeout(e){}_onInviteAnswer(e){const{answerCode:t,inviteContent:r,inviteeUserAutoMix:i}=e,{inviterUserId:s,inviterRoomId:o,inviteeUserId:c,inviteeRoomId:d,extra:l}=r,h={agree:t===1,inviterRoomId:o,inviterUserId:s,inviteeRoomId:d,inviteeUserId:c};this._PKInfo[d].inviteeUserAutoMix=i,this._callAppListener("onResponseJoinOtherRoom",h)}_onPKEnd(e){return $(this,void 0,void 0,function*(){const{inviteeRoomId:t,inviterRoomId:r,userId:i}=e.inviteInfo,s=r===this._mainRoomId?t:r,o={endRoomId:s,endUserId:i};yield this.leaveOtherRoom(this._joinedPKRooms[s]),delete this._PKInfo[s],this._callAppListener("onFinishOtherRoom",o)})}_onRecvPKMsg(e){const{targetId:t,content:r,messageType:i}=e;switch(i){case ce.PK_INVITE:this._onInvite(r);break;case ce.PK_CANCEL_INVITE:this._onCancelInvite(r);break;case ce.PK_INVITE_TIMEOUT:this._onInviteTimeout(r);break;case ce.PK_INVITE_ANSWER:this._onInviteAnswer(r);break;case ce.PK_END:this._onPKEnd(r)}}registerRoomPKEventListener(e){this._appListener=e}requestJoinOtherRoom(e,t,r){return $(this,void 0,void 0,function*(){if(!Ee("inviteeRoomId",e,Ze,!0)||!Ee("inviteeUserId",t,Ze,!0))return{code:M.PARAMS_ERROR};P.debug(`requestRoomPK -> inviteeRoomId: ${e}; inviteeUserId: ${t}; options: ${JSON.stringify(r||{})}`);const i=Bd(),s=!qr(r==null?void 0:r.autoMix)||(r==null?void 0:r.autoMix),o={inviteSessionId:i,inviterRoomId:this._mainRoomId,inviterUserId:this._context.getCurrentId(),inviterUserAutoMix:s,inviteeRoomId:e,inviteeUserId:t,inviteeTimeoutTime:this._inviteTimeout,extra:(r==null?void 0:r.extra)||""},c={roomId:this._mainRoomId,invitedRoomId:e,invitedUserId:t,inviteTimeout:this._inviteTimeout,inviteInfo:JSON.stringify(o),inviteSessionId:i};P.debug(`requestRoomPK -> params: ${JSON.stringify(c)}`);const d=yield this._context.requestRoomPK(c);return d!==N.SUCCESS?(P.error(`requestRoomPK failed: ${d}`),{code:d}):(P.debug("requestRoomPK success"),this._PKInfo[e]={inviteSessionId:i,inviterRoomId:this._mainRoomId,inviterUserId:this._context.getCurrentId(),inviterUserAutoMix:s,inviteeRoomId:e},{code:M.SUCCESS})})}cancelRequestJoinOtherRoom(e,t,r){return $(this,void 0,void 0,function*(){if(!Ee("inviteeRoomId",e,Ze,!0)||!Ee("inviteeUserId",t,Ze,!0))return{code:M.PARAMS_ERROR};if(!this._PKInfo[e])return P.error(`\u672A\u53D1\u8D77\u8FC7\u4E0E ${e} \u623F\u95F4\u5185 ${t} \u8FDE\u9EA6\u7684\u8BF7\u6C42`),{code:M.PARAMS_ERROR};P.debug(`canceRequestJoinPK -> inviteeRoomId: ${e}; inviteeUserId: ${t}; extra: ${r}`);const i={inviterRoomId:this._mainRoomId,inviterUserId:this._context.getCurrentId(),inviteeRoomId:e,inviteeUserId:t,extra:r||""},s={roomId:this._mainRoomId,invitedRoomId:e,invitedUserId:t,inviteSessionId:this._PKInfo[e].inviteSessionId,inviteInfo:JSON.stringify(i)};P.debug(`canceRequestJoinPK -> params: ${JSON.stringify(s)}`);const o=yield this._context.cancelRoomPK(s);return o!==N.SUCCESS?(P.error(`canceRequestJoinPK failed: ${o}`),{code:o}):(P.debug("canceRequestJoinPK success"),delete this._PKInfo[e],{code:M.SUCCESS})})}responseJoinOtherRoom(e,t,r,i){return $(this,void 0,void 0,function*(){if(!Ee("inviterRoomId",e,Ze,!0)||!Ee("inviterUserId",t,Ze,!0))return{code:M.PARAMS_ERROR};if(!this._PKInfo[e])return P.error(`${e} \u623F\u95F4\u5185\u7684 ${t} \u672A\u53D1\u8D77\u8FC7\u8FDE\u9EA6\u8BF7\u6C42`),{code:M.PARAMS_ERROR};P.debug(`responseRoomPK -> inviterRoomId: ${e}; inviterUserId: ${t}; agree: ${r}; options: ${JSON.stringify(i||{})}`);const{inviteSessionId:s,inviterUserAutoMix:o}=this._PKInfo[e],c=!qr(i==null?void 0:i.autoMix)||(i==null?void 0:i.autoMix),d={inviteSessionId:s,inviterRoomId:e,inviterUserId:t,inviteeRoomId:this._mainRoomId,inviteeUserId:this._context.getCurrentId(),inviteeUserAutoMix:c},l=Object.assign(d,{inviterUserAutoMix:o}),h=r?Object.assign(d,{MultiRoomKey:`${e}|${this._mainRoomId}`,MultiRoomValue:JSON.stringify(l)}):d;!ge(i==null?void 0:i.extra)&&Object.assign(h,{extra:i.extra});const a={agree:r,roomId:this._mainRoomId,inviteSessionId:s,inviteRoomId:e,inviteUserId:t,content:JSON.stringify(h),key:`${e}|${t}`,value:JSON.stringify(d)};P.debug(`responseRoomPK -> params: ${JSON.stringify(a)}`);const u=yield this._context.responseRoomPK(a);return u!==N.SUCCESS?(P.error(`responseRoomPK failed: ${u}`),{code:u}):(P.debug("responseRoomPK success"),this._PKInfo[e].inviteeUserAutoMix=c,{code:M.SUCCESS})})}_quitRoomPK(e){return $(this,void 0,void 0,function*(){const{inviterRoomId:t,inviteeRoomId:r,inviterUserId:i}=this._PKInfo[e],s={inviteeRoomId:r,inviterRoomId:t,userId:this._context.getCurrentId()},o={roomId:this._mainRoomId,endRoomId:e,sessionId:this._PKInfo[e].inviteSessionId,content:JSON.stringify(s),keys:[`${t}|${i}`]};P.debug(`quitRoomPK -> params: ${JSON.stringify(o)}`);const c=yield this._context.endRoomPK(o);return c!==N.SUCCESS?(P.error(`quitRoomPK failed: ${c}`),{code:M.SIGNAL_ERROR}):(P.debug("quitRoomPK success"),delete this._PKInfo[e],{code:M.SUCCESS})})}_relaseCrtRoom(){}joinOtherRoom(e){return $(this,void 0,void 0,function*(){if(!Ee("roomId",e,Ze,!0))return{code:M.PARAMS_ERROR};if(this._context.getConnectionStatus()!==re.CONNECTED)return{code:M.SIGNAL_DISCONNECTED};if(P.debug(`joinPKRoom, roomId: ${e}`),this._joinedPKRooms[e])return{code:M.REPERT_JOIN_ROOM};const t=pt.VIDEO,{code:r,data:i}=yield this._context.joinRTCRoom(e,Ye.LIVE,t);if(r!==N.SUCCESS)return P.error(`joinRoom failed -> code: ${r}`),{code:r};P.debug(`JoinPKRoom success -> userId: ${this._context.getCurrentId()}, roomId: ${e}, data: ${JSON.stringify(i)}`);const s=new kt(this._context,this._runtime,e,i,this._service,this._initOptions,this._relaseCrtRoom.bind(this),t,!1,!1);return this._joinedPKRooms[e]=s,this._onJoinedPKRoom(e,s),{room:s,code:M.SUCCESS,userIds:s.getRemoteUserIds(),tracks:s.getRemoteTracks()}})}leaveOtherRoom(e,t){return $(this,void 0,void 0,function*(){return be(()=>$(this,void 0,void 0,function*(){const r=e.getRoomId();return P.debug(`leavePKRoom -> userId: ${this._context.getCurrentId()} , roomId: ${r}`),yield e.__destroy(!0),delete this._joinedPKRooms[r],this._onLeavePKRoom(r),this._PKInfo[r]?(t&&this._quitRoomPK(r),{code:M.SUCCESS}):{code:M.SUCCESS}}))})}getPKInfo(e){return this._PKInfo[e]}getJoinedPKRooms(){return this._joinedPKRooms}}class kt extends xd{constructor(e,t,r,i,s,o,c,d,l=!1,h){var a;super(e,t,r,i,Ye.LIVE,s,o,c,l,h),this._livingType=d,this._isMainRoom=h,this._CDNUris=null,this._CDNEnable=!1,this._mcuConfigBuilder=new xf(this._onMCUConfigFlush.bind(this),this._isValidResourceId.bind(this),this._sendCDNInfoSignal.bind(this)),this._isMainRoom&&(this._roomPKHandler=new Bf(e,t,s,o,this,super._registerPKMsgListener.bind(this),this._onJoinedPKRoom.bind(this),this._onLeavePKRoom.bind(this)));const u=(a=i.roomInfo.filter(f=>f.key==="cdn_uris")[0])===null||a===void 0?void 0:a.value;u&&(this._CDNUris=JSON.parse(u)[0])}_isValidResourceId(e){var t;const{userId:r}=Ge(e),i=!!((t=this._roomResources[r])===null||t===void 0?void 0:t.find(h=>fe(h)===e));let s=!1;const{code:o,roomPKHandler:c}=this.getRoomPKHandler();if(o!==M.SUCCESS||!c)return i;const d=c.getJoinedPKRooms(),l=[];return Object.values(d).map(h=>{l.push(...h.getRemoteTracks())}),s=l.some(h=>e===h.getTrackId()),i||s}getLivingType(){return this._livingType}getMCUConfigBuilder(){return this._isMainRoom?this._mcuConfigBuilder:(P.error("the `getMCUConfigBuilder` is disabled in PK room "),{code:M.THE_FUNCTION_IS_DISABLED_IN_PKROOM})}_onMCUConfigFlush(e){return $(this,void 0,void 0,function*(){const t={"App-Key":this._context.getAppkey(),Token:this._token,RoomId:this.getRoomId(),UserId:this._context.getCurrentId(),SessionId:this.getSessionId()},{code:r,res:i}=yield this._service.setMcuConfig(t,e);return r!==M.SUCCESS?(P.error(`set MCU config failed: ${r}`),{code:r}):(P.info("set MCU config success"),i.pull_url&&(this._CDNUris=JSON.parse(i.pull_url)),{code:r,res:i})})}__onReconnected(){const e=Object.create(null,{__onReconnected:{get:()=>super.__onReconnected}});var t,r;return $(this,void 0,void 0,function*(){const i=yield e.__onReconnected.call(this,this._livingType);if(!i||!i.data)return;const s=i.data.roomInfo,o=(t=s.filter(d=>d.key==="cdn_uris")[0])===null||t===void 0?void 0:t.value;if(!o)return;const c=JSON.parse(o);((r=this._CDNUris)===null||r===void 0?void 0:r.enableInnerCDN)!==c.enableInnerCDN&&this._callAppListener("onCDNEnableChange",c.enableInnerCDN),this._CDNUris=c})}enableInnerCDN(e){return $(this,void 0,void 0,function*(){if(!this._isMainRoom)return P.error("the `enableInnerCDN` is disabled in PK room "),{code:M.THE_FUNCTION_IS_DISABLED_IN_PKROOM};if(!qr(e))return P.error("`enable` is invalid"),{code:M.PARAMS_ERROR};this._CDNEnable=e;const t={version:2,output:{inCDNModel:e?ci.OPEN:ci.STOP}},{code:r}=yield this._onMCUConfigFlush(t);if(r!==M.SUCCESS)return P.error(`enableInnerCDN failed -> code: ${r}`),{code:M.SIGNAL_ERROR};if(this._CDNUris&&this._CDNUris.broadcast!==ui.SPREAD)return P.info("enableInnerCDN succeed"),{code:M.SUCCESS};const{code:i}=yield be(()=>$(this,void 0,void 0,function*(){return this._sendCDNInfoSignal()}));return i===M.SUCCESS?(P.info("enableInnerCDN succeed"),{code:M.SUCCESS}):(P.error(`enableInnerCDN failed -> code: ${i}`),{code:i})})}_sendCDNInfoSignal(){return $(this,void 0,void 0,function*(){return this._CDNUris=Object.assign({},this._CDNUris,{enableInnerCDN:this._CDNEnable}),(yield Promise.all([this._spreadCDNInfo(this._CDNUris),this._setRoomCDNInfo(this._CDNUris)])).every(e=>e.code===M.SUCCESS)?{code:M.SUCCESS}:{code:M.SIGNAL_ERROR}})}_spreadCDNInfo(e){return $(this,void 0,void 0,function*(){const t=yield this._context.setRTCCDNUris(this._roomId,ce.TOTAL_CONTENT_RESOURCE,JSON.stringify([e]));return t!==N.SUCCESS?(P.error(`spreadCDNInfo failed -> code: ${t}`),{code:M.SIGNAL_ERROR}):(P.info("spreadCDNInfo succeed"),{code:M.SUCCESS})})}_setRoomCDNInfo(e){return $(this,void 0,void 0,function*(){const t=yield this._context.setRTCData(this._roomId,"cdn_uris",JSON.stringify([e]),!0,yt.ROOM);return t!==N.SUCCESS?(P.error(`setRoomCDNInfo failed -> code: ${t}`),{code:M.SIGNAL_ERROR}):(P.info("setRoomCDNInfo succeed"),{code:M.SUCCESS})})}_resourceHandle(e,t,r){const i=Object.create(null,{_resourceHandle:{get:()=>super._resourceHandle}});var s;return $(this,void 0,void 0,function*(){i._resourceHandle.call(this,e,t,r),e.cdn_uris&&(((s=this._CDNUris)===null||s===void 0?void 0:s.enableInnerCDN)!==e.cdn_uris[0].enableInnerCDN&&this._callAppListener("onCDNEnableChange",!this.__getCDNEnable()),this._CDNUris=e.cdn_uris[0])})}_exchangeHandle(e){var t,r,i;return $(this,void 0,void 0,function*(){const s=yield this._service.exchange(this._getRTCReqestHeaders(),e),o=(r=(t=s.data)===null||t===void 0?void 0:t.urls)===null||r===void 0?void 0:r.pull_url;return s.code===M.SUCCESS&&o&&(this._CDNUris=JSON.parse(o),((i=this._CDNUris)===null||i===void 0?void 0:i.broadcast)===ui.SPREAD&&(this._CDNEnable=!0,this._sendCDNInfoSignal())),s})}_afterChangedRole(e){const t=eo(e),r=this._context.getCurrentId(),i=Object.keys(t);setTimeout(()=>{var s,o,c;const d=i.filter(l=>l!==r);d.length>0&&this._callAppListener("onUserJoin",d);for(const l in t)l!==r&&this._resourceHandle({uris:t[l]},ce.TOTAL_CONTENT_RESOURCE,l);((s=e.roomInfo.filter(l=>l.key==="cdn_uris")[0])===null||s===void 0?void 0:s.value)&&((o=this._CDNUris)===null||o===void 0?void 0:o.push_mode)===di.MANUAL&&this._callAppListener("onCDNEnableChange",(c=this._CDNUris)===null||c===void 0?void 0:c.enableInnerCDN)})}__getCDNEnable(){var e;return(e=this._CDNUris)===null||e===void 0?void 0:e.enableInnerCDN}__getCDNPushMode(){var e;return(e=this._CDNUris)===null||e===void 0?void 0:e.push_mode}_onJoinedPKRoom(e,t){const{code:r,roomPKHandler:i}=this.getRoomPKHandler();if(r===M.SUCCESS&&i){if(!i.getPKInfo(e))return;this._exchangeWithPushOtherRoom()}}_onLeavePKRoom(e){const{code:t,roomPKHandler:r}=this.getRoomPKHandler();if(t===M.SUCCESS&&r){if(!r.getPKInfo(e))return;this._exchangeWithPushOtherRoom()}}_exchangeWithPushOtherRoom(){return $(this,void 0,void 0,function*(){if(!this.getLocalTracks().length)return;const e=yield this._createExchangeParams(this._subscribedList,!1),t=this._getPushOtherRoomsParams();t&&(e.pushOtherRooms=t);const r=yield this._exchangeHandle(e);if(r.code!==M.SUCCESS)return P.error(`reTryExchange failed: ${r.code}`),{code:r.code};const{sdp:i,resultCode:s}=r.data;if(s!==M.SUCCESS)return P.error(`exchange with pushOtherRoom failed: ${s}`),{code:s};const o=yield this._pc.setRemoteAnswer(i.sdp);return o!==M.SUCCESS?{code:o}:void 0})}getRoomPKHandler(){return this._isMainRoom?{code:M.SUCCESS,roomPKHandler:this._roomPKHandler}:(P.error("the `getRoomPKHandler` is disabled in PK room "),{code:M.THE_FUNCTION_IS_DISABLED_IN_PKROOM})}_quitAllPKRoom(){const e=this._roomPKHandler.getJoinedPKRooms();for(const t in e){const r=e[t];this._roomPKHandler.leaveOtherRoom(r)}}}class Vf extends xd{constructor(e,t,r,i,s,o,c){super(e,t,r,i,Ye.RTC,s,o,c,!1)}}const os=()=>({"Content-Type":"application/json;charset=UTF-8","Cache-Control":"no-cache",ClientType:`web|${dt.browser}|${dt.version}`,ClientVersion:"5.3.1","Client-Session-Id":Bd(),"Request-Id":Date.now().toString()});class fa{constructor(e,t,r,i=5e3){this._runtime=e,this._context=t,this._msUrl=r,this._timeout=i,this._msInNavi=[],this._failedMs=[],this._rtcFinger=void 0,this._clusterId="",this._configUrl=""}getNaviMS(){return this._msUrl?[this._msUrl]:this._clusterId?[`https://${this._clusterId}`]:(this._msInNavi.length===0&&(this._failedMs.length===0?this._msInNavi.push(...(e=>{var t;if(!e)return[];let r;try{r=JSON.parse(e.voipCallInfo||'{ "strategy": 0 }')}catch{return P.warn("parse `voipCallInfo` of navi failed: "+e.voipCallInfo),[]}if(r.strategy===0)return[];const i=(t=r.callEngine)===null||t===void 0?void 0:t.filter(c=>c.engineType===4);if(!i||i.length===0)return[];const s=i[0],o=[];return s.mediaServer&&o.push(s.mediaServer.replace(/^(https?:\/\/)?/,"https://")),s.backupMediaServer&&s.backupMediaServer.forEach(c=>{o.push(c.replace(/^(https?:\/\/)?/,"https://"))}),o})(this._context.getNaviInfo())):(this._msInNavi.push(...this._failedMs),this._failedMs.length=0)),this._msInNavi.map(e=>e.trim()))}_request(e,t,r){return $(this,void 0,void 0,function*(){const i=this.getNaviMS();if(i.length===0)return{code:M.NOT_OPEN_VIDEO_AUDIO_SERVER};this._rtcFinger&&(r.rtcFinger=this._rtcFinger);for(let s=0;s<i.length;s+=1){const o=`${i[s]}${e}`,c=os();P.debug(`request -> Request-Id: ${c["Request-Id"]}, url: ${o}`);const{status:d,data:l}=yield this._runtime.httpReq({url:o,body:JSON.stringify(r),headers:Object.assign(Object.assign({},c),t),method:gt.POST,timeout:this._timeout});if(d===200){const h=JSON.parse(l);return h.rtcFinger&&(this._rtcFinger=h.rtcFinger),h.clusterId&&(this._clusterId=h.clusterId),P.debug(`request success -> Request-Id: ${c["Request-Id"]}`),{code:M.SUCCESS,data:h}}P.warn(`request failed -> Request-Id: ${c["Request-Id"]}, status: ${d}, url: ${o}`),this._failedMs.push(...this._msInNavi.splice(s,1))}return{code:M.REQUEST_FAILED}})}exchange(e,t){var r;return $(this,void 0,void 0,function*(){const i=yield this._request("/exchange",e,t);if(i.code===M.SUCCESS&&((r=i.data)===null||r===void 0?void 0:r.resultCode)===M.SUCCESS){const s=i.data.urls;s&&(this._configUrl=s.configUrl)}return i})}exit(e){return $(this,void 0,void 0,function*(){const{code:t}=yield this._request("/exit",e,{});return t})}broadcastSubscribe(e,t){return this._request("/broadcast/subscribe",e,t)}broadcastExit(e){return $(this,void 0,void 0,function*(){const{code:t}=yield this._request("/broadcast/exit",e,{});return{code:t}})}setMcuConfig(e,t){return $(this,void 0,void 0,function*(){if(!this._configUrl)return{code:M.MCU_SERVER_NOT_FOUND};const r=`${this._configUrl.replace(/^(https?:\/\/)?/,"https://")}/server/mcu/config`,i=os();P.debug(`request -> Request-Id: ${i["Request-Id"]}, url: ${r}`);const{status:s,data:o}=yield this._runtime.httpReq({url:r,headers:Object.assign(Object.assign({},i),e),body:JSON.stringify(t),method:gt.POST});if(s===200){P.debug(`request success -> Request-Id: ${i["Request-Id"]}`);const c=JSON.parse(o);return{code:c.resultCode,res:c}}return{code:M.REQUEST_FAILED}})}getCDNResourceInfo(e,t){return $(this,void 0,void 0,function*(){const r=os(),{status:i,data:s}=yield this._runtime.httpReq({url:t,headers:Object.assign(Object.assign({},r),e),method:gt.GET});if(i===200){const o=JSON.parse(s);return{code:o.resultCode,res:o}}return P.warn(`request failed -> Request-Id: ${r["Request-Id"]}, status: ${i}, url: ${t}`),{code:M.REQUEST_FAILED}})}}class Ff{constructor(e,t,r){this._context=e,this._rtcToken="",this._liveUrl="",this._subTracks=[],this._livingType=null,this._mediaType=null,this._subTiny=!1,this._fromRetry=!1,this._appListener=null,this._service=new fa(t,e,r.mediaServer)}_getReqHeaders(e){return $(this,void 0,void 0,function*(){const t=this._context.getCurrentId(),r=t;if(!this._rtcToken){const{code:i,data:s}=yield this._context.getRTCToken(r,Ye.LIVE,e);if(i!==N.SUCCESS)return P.error(`getRTCToken failed: ${i}`),{code:M.SIGNAL_ERROR};this._rtcToken=s.rtcToken}return{code:M.SUCCESS,headers:{"App-Key":this._context.getAppkey(),UserId:t,RoomId:r,RoomType:Ye.LIVE,Token:this._rtcToken}}})}_clearSubscribeInfo(){var e;this._liveUrl="",this._livingType=null,this._mediaType=null,this._subTiny=!1,this._subTracks.length=0,(e=this._pc)===null||e===void 0||e.destroy(),this._pc=null}_reTryExchange(){var e;return $(this,void 0,void 0,function*(){this._fromRetry=!0;const{code:t}=yield this.subscribe(this._liveUrl,this._livingType,this._mediaType,this._subTiny);t===M.SUCCESS&&((e=this._pc)===null||e===void 0||e.clearReTryExchangeTimer())})}subscribe(e,t,r,i=!1){return $(this,void 0,void 0,function*(){return be(()=>this.__subscribe(e,t,r,i))})}__subscribe(e,t,r,i=!1){var s;return $(this,void 0,void 0,function*(){const o=[];if($r(this._context.getNaviInfo()))return{code:M.PACKAGE_ENVIRONMENT_ERROR,tracks:o};if(!this._fromRetry&&((s=this._pc)===null||s===void 0||s.clearReTryExchangeTimer()),this._fromRetry=!1,!et(e))return P.error(`liveUrl is invalid: ${e}`),{code:M.PARAMS_ERROR,tracks:o};if(![pt.AUDIO,pt.VIDEO].includes(t))return P.error(`livingType is invalid: ${t}`),{code:M.PARAMS_ERROR,tracks:o};if(![me.AUDIO_ONLY,me.VIDEO_ONLY,me.AUDIO_VIDEO].includes(r))return P.error(`mediaType is invalid: ${r}`),{code:M.PARAMS_ERROR,tracks:o};if(this._liveUrl&&this._liveUrl!==e)return{code:M.BROADCAST_SUB_LIST_NOT_EMPTY,tracks:o};this._pc||(this._pc=new It(this._reTryExchange.bind(this)),this._pc.on(It.__INNER_EVENT_TRACK_READY__,this._onTrackReady,this),this.registerReportListener(this._reportListener)),this._liveUrl=e;const{code:c,headers:d}=yield this._getReqHeaders(t);if(c!==M.SUCCESS)return{code:c,tracks:o};const l=`rc_mcu_${Date.now()}`,h="RongCloudRTC";this._subTracks.length===0&&(this._subTracks.push(new Ot(h,l),new At(h,l)),this._pc.updateSubRemoteTracks(this._subTracks.slice()));const a={sdp:yield this._pc.createOffer(!0),liveUrl:e,mediaType:r,simulcast:i?ct.TINY:ct.NORMAL,switchstream:!1},u=yield this._service.broadcastSubscribe(d,a);if(u.code!==M.SUCCESS)return P.error(`andience subscribe failed: ${u.code}`),{code:u.code,tracks:o};const f=u.data;if(f.resultCode!==M.SUCCESS)return P.error(`andience subscribe failed! code: ${f.resultCode}; message: ${f.message}`),{code:f.resultCode,tracks:o};P.debug(`andience subscribe success: ${e}`),this._livingType=t,this._mediaType=r,this._subTiny=i;const{sdp:p,subscribedList:m}=f,_=[];return m.forEach(v=>{const{mediaType:y}=v,C=this._subTracks[y];_.push(C),C.__innerSetRemoteMuted(!0)}),this._pc.setRemoteAnswer(p.sdp),{code:M.SUCCESS,tracks:_}})}unsubscribe(){return $(this,void 0,void 0,function*(){return be(()=>this.__unsubscribe())})}__unsubscribe(){var e;return $(this,void 0,void 0,function*(){if((e=this._pc)===null||e===void 0||e.clearReTryExchangeTimer(),!this._rtcToken||!this._liveUrl)return{code:M.SUCCESS};const{headers:t}=yield this._getReqHeaders(),{code:r}=yield this._service.broadcastExit(t);return r!==M.SUCCESS?P.error(`broadcast unsubscribe failed: ${r}`):P.debug("broadcast unsubscribe success"),this._clearSubscribeInfo(),{code:r}})}registerReportListener(e){var t;this._reportListener=e,(t=this._pc)===null||t===void 0||t.registerReportListener(e)}registerTrackEventListener(e){this._appListener=e}_onTrackReady(e){var t,r;const i=e.receiver.track,s=i.kind==="audio"?me.AUDIO_ONLY:me.VIDEO_ONLY,o=this._subTracks[s];o.__innerSetMediaStreamTrack(i);try{(r=(t=this._appListener)===null||t===void 0?void 0:t.onTrackReady)===null||r===void 0||r.call(t,o)}catch(c){P.error(c)}}}var to,Kn;(function(n){n.RTMP="rtmp",n.FLV="flv",n.HLS="hls"})(to||(to={})),function(n){n[n.NOT_HTTPS=0]="NOT_HTTPS",n[n.HTTPS=1]="HTTPS"}(Kn||(Kn={}));const Hf=Object.assign(Object.assign({},Et(Re.W176_H144)),{frameRate:Rt(Ct.FPS_15)});class Bc{constructor(e,t,r,i,s,o){this._context=e,this._runtime=t,this._initOptions=r,this._roomId=i,this._joinResData=s,this._livingType=o,this._roomAnchorList=[],this._roomRes={},this._roomAnchorRes={},this._remoteTracks={},this._appListener=null,this._subscribedList=[],this._sessionId="",this._destroyed=!1,this._setInitData(),this._service=new fa(this._runtime,this._context,this._initOptions.mediaServer,this._initOptions.timeout),this._polarisReport=new Ud(this._context,this._runtime,this._roomId,this,oi.Audience),this._polarisReport.sendR1(),this._pc=new It(this._reTryExchange.bind(this),this._polarisReport),this._pc.on(It.__INNER_EVENT_TRACK_READY__,c=>{const d=c.streams[0].id,l=c.receiver.track,h=[d,l.kind==="audio"?me.AUDIO_ONLY:me.VIDEO_ONLY].join("_"),a=this._remoteTracks[h];a?(a.__innerSetMediaStreamTrack(l),this._callAppListener("onTrackReady",a)):P.warn("cannot found RCRemoteTrack:",l.id)}),this._context.onrtcdatachange=this.singalDataChange.bind(this)}_setInitData(){const{sessionId:e,remoteUserIds:t,remoteRTCUris:r,remoteMUCUris:i,remoteTracks:s,CDNUris:o}=((c,d)=>{const l=d.filter(y=>y.key==="RC_RTC_SESSIONID")[0],h=l?l.value:"",a=d.filter(y=>y.key==="RC_ANCHOR_LIST").map(y=>JSON.parse(y.value||"[]"))[0],u=d.filter(y=>y.key.includes("RC_RES_")).map(y=>JSON.parse(y.value||"{}")),f=u.length?JSON.parse(u[0].mcu_uris||"[]"):[],p=[];f.forEach(y=>{const{mediaType:C,tag:b}=y,O=C===me.AUDIO_ONLY?new Ot(b,"",c):new At(b,"",c);p.push(O)});const m=[],_=[];u.forEach(y=>{const C=JSON.parse(y.uris||"[]");m.push(...C),C.forEach(b=>{const{mediaType:O,tag:S,msid:E}=b,w=E.split("_")[0],V=O===me.AUDIO_ONLY?new Ot(S,w):new At(S,w);_.push(V)})});const v=d.filter(y=>y.key==="RC_CDN").map(y=>{const C=JSON.parse(y.value||"[]");return JSON.parse(C.cdn_uris)[0]})[0];return{sessionId:h,remoteUserIds:a||[],remoteRTCUris:m,remoteMUCUris:f,remoteRTCTracks:_,remoteMCUTracks:p,remoteTracks:[..._,...p],CDNUris:v||{}}})(this._roomId,this._joinResData.kvEntries);this._sessionId=e,this._roomAnchorList=t,s.forEach(c=>{this._remoteTracks[c.getTrackId()]=c}),this._CDNUris=o,r.forEach(c=>{const d=c.msid.split("_")[0];this._roomAnchorRes[d]?this._roomAnchorRes[d].push(c):this._roomAnchorRes[d]=[c]}),i.forEach(c=>{const{mediaType:d,tag:l}=c,h=[this._roomId,l,d].join("_");this._roomRes[h]=c}),r.forEach(c=>{const d=fe(c);this._roomRes[d]=c})}_assertRoomDestroyed(){if(this._destroyed){const e="This room has been destroyed. Please use `RCRTCClient.joinLivingRoomAsAudience` to catch another instance.";return P.warn(e),M.ROOM_HAS_BEEN_DESTROYED}}singalDataChange(e,t){var r;if(t!==this._roomId)return void P.warn(`singalDataChange -> not the current room data: data roomId: ${t}, current roomId: ${this._roomId}`);P.debug("singalDataChange -> singalData:",JSON.stringify(e||{}));const i=[],s=(r=e.filter(o=>o.key==="RC_CDN")[0])===null||r===void 0?void 0:r.value;s&&this._diffCDNUris(JSON.parse(JSON.parse(s).cdn_uris)[0]),e.forEach(o=>{const{key:c,value:d,timestamp:l,uid:h}=o;if(c.indexOf("RC_RES_")!==-1){const a=JSON.parse(d||"{}"),u=JSON.parse(a.mcu_uris||"[]"),f=JSON.parse(a.uris||"[]");return i.push(...u),void this._diffAnchorResource(f,h)}if(c==="RC_ANCHOR_LIST"){const a=JSON.parse(d||"[]"),{joinUserIds:u,leftUserIds:f}=this._diffAnchorList(a);u.length>0&&this._handleNewJoinedAnchor(u),f.length>0&&this._handleLeftedAnchor(f)}}),this._diffRoomResource(i)}_diffAnchorList(e){const t=e.filter(r=>this._roomAnchorList.indexOf(r)<0);return{leftUserIds:this._roomAnchorList.filter(r=>e.indexOf(r)<0),joinUserIds:t}}_handleNewJoinedAnchor(e){this._roomAnchorList.push(...e),this._callAppListener("onAnchorJoin",e)}_handleLeftedAnchor(e){return $(this,void 0,void 0,function*(){this._roomAnchorList=this._roomAnchorList.filter(r=>!(e.indexOf(r)>-1));const t=[];e.forEach(r=>{t.push(...this.getRemoteTracksByUserId(r)),delete this._roomAnchorRes[r]}),t.length&&(yield this.unsubscribe(t),t.forEach(r=>delete this._remoteTracks[r.getTrackId()])),this._callAppListener("onAnchorLeave",e)})}_diffRoomResource(e){return $(this,void 0,void 0,function*(){const t=[],r=[],i=[];e.forEach(s=>{const o=fe(s),{userId:c,tag:d,mediaType:l}=Ge(o),h=[this._roomId,d,l].join("_");if(!this._remoteTracks[h]){const a=l===me.AUDIO_ONLY?new Ot(d,"",this._roomId):new At(d,"",this._roomId);t.push(a),this._remoteTracks[h]=a,this._roomRes[a.getTrackId()]=s}i.push(h)}),Object.keys(this._remoteTracks).forEach(s=>{i.indexOf(s)<0&&this._remoteTracks[s].isMCUTrack()&&r.push(this._remoteTracks[s])}),t.length>0&&this._callAppListener("onTrackPublish",t),r.length>0&&this._onUserUnpublish(r,"onTrackUnpublish")})}_diffAnchorResource(e,t){return $(this,void 0,void 0,function*(){const r=this._roomAnchorRes[t]||(this._roomAnchorRes[t]=[]),{publishedList:i,unpublishedList:s,modifiedList:o}=Hr(r,e);if(i.length){const c=r.map(fe),d=[],l=[];if(i.forEach(h=>{const a=fe(h),u=c.indexOf(a),{userId:f,tag:p,mediaType:m}=Ge(a);u>-1?r[u]=h:r.push(h);let _=this._remoteTracks[a];this._roomRes[a]=h,_?_.isSubscribed()&&d.push(_):(_=m===me.AUDIO_ONLY?new Ot(p,f):new At(p,f),this._remoteTracks[a]=_,l.push(_)),_.__innerSetRemoteMuted(h.state===0)}),d.length){const h=d.map(u=>u.getTrackId());P.debug(`resub tracks -> ${JSON.stringify(h)}`);const{code:a}=yield be(()=>this._subscribeHandle(d,!0));a!==M.SUCCESS&&P.error(`resub tracks failed -> code: ${a}, ids: ${JSON.stringify(h)}`)}this._callAppListener("onAnchorTrackPublish",l)}if(s.length){const c=s.map(fe);for(let l=r.length-1;l>=0;l-=1){const h=r[l];c.includes(fe(h))&&r.splice(l,1)}const d=s.map(l=>{const h=fe(l);return this._remoteTracks[h]});yield this._onUserUnpublish(d,"onAnchorTrackUnpublish")}if(o.length){const c=r.map(fe);for(let d=0;d<o.length;d++){const l=o[d],h=fe(l),a=c.indexOf(h);r[a].state=l.state;const u=this._remoteTracks[h];u.__innerSetRemoteMuted(l.state===0),u.isAudioTrack()?this._callAppListener("onAudioMuteChange",u):this._callAppListener("onVideoMuteChange",u)}}})}_onUserUnpublish(e,t){return $(this,void 0,void 0,function*(){yield this.unsubscribe(e),e.forEach(r=>{this._subscribedList=this._subscribedList.filter(i=>i.track.getTrackId()!==r.getTrackId()),delete this._roomRes[r.getTrackId()],r.__innerDestroy(),delete this._remoteTracks[r.getTrackId()]}),this._callAppListener(t,e)})}_callAppListener(e,...t){var r;const i=(r=this._appListener)===null||r===void 0?void 0:r[e];if(i)try{i(...t)}catch(s){P.error(s)}}_reTryExchange(){return $(this,void 0,void 0,function*(){be(()=>$(this,void 0,void 0,function*(){var e;const{reqBody:t}=yield this._createSubscribeParams(this._subscribedList,{},!0),r=yield this._exchangeHandle(t);if(r.code!==M.SUCCESS)return P.error(`reTryExchange failed: ${r.code}`),{code:r.code};const{sdp:i,resultCode:s}=r.data;if(s!==M.SUCCESS)return P.error(`reTryExchange failed: ${s}`),{code:s};this._pc.clearReTryExchangeTimer();const o=this._subscribedList.filter(d=>d.track.isMCUTrack());if(o.length>0){const d=o[0].track.getTrackId(),l=(e=this._roomRes[d])===null||e===void 0?void 0:e.msid,h=[this._roomId,"RongCloudRTC"].join("_");i.sdp=i.sdp.replace(new RegExp(l,"g"),h)}const c=yield this._pc.setRemoteAnswer(i.sdp);return c!==M.SUCCESS?{code:c}:void 0}))})}_createSubscribeParams(e,t,r){return $(this,void 0,void 0,function*(){const i=yield this._pc.createOffer(r),s={resolutionInfo:[]},o={min:0,max:0};return Object.keys(t).forEach(c=>{const{mediaStream:d,tinyStream:l}=t[c];[d,l].forEach((h,a)=>{var u;const f=a===1?[c,"tiny"].join("_"):c;i.sdp=(u=i.sdp)===null||u===void 0?void 0:u.replace(new RegExp(h.id,"g"),f);const p=h.getVideoTracks()[0];if(!p)return;const m=a===0,{width:_,height:v,frameRate:y}=m?la(p):Hf;s.resolutionInfo.push({trackId:p.id,simulcast:m?ct.NORMAL:ct.TINY,resolution:`${_}x${v}`});const C=Ad(_,v),b=Md(y);o.min+=C.minBitrate*b,o.max+=C.maxBitrate*b})}),{reqBody:{sdp:i,switchstream:!1,newVersionFlag:!0,subscribeList:e.map(c=>({simulcast:c.subTiny?ct.TINY:ct.NORMAL,resolution:"",uri:this._roomRes[c.track.getTrackId()].uri}))},dynamicBitrate:o,offer:i}})}_subscribeHandle(e,t=!1){var r;return $(this,void 0,void 0,function*(){if(this._assertRoomDestroyed())return{code:M.ROOM_HAS_BEEN_DESTROYED};if(!Ee("tracks",e,()=>ze(e)&&e.length>0&&e.every(d=>d instanceof Fe||d.track instanceof Fe),!0))return{code:M.PARAMS_ERROR};const i=this._subscribedList.map(d=>Object.assign({},d)),s=e.map(d=>d instanceof Fe?{track:d}:d);let o=!1;const c=[];return s.forEach(d=>{const l=d.track.getTrackId();c.push(l);const h=i.find(a=>a.track.getTrackId()===l);h&&h.subTiny===d.subTiny||(h?h.subTiny=d.subTiny:i.push(d),o=!0)}),o||t?((r=this._polarisReport)===null||r===void 0||r.sendR2(Pt.SUBSCRIBE,Lt.BEGIN,c),this._updateSubListHandle(i,!0)):{code:M.SUCCESS}})}_getReqHeaders(){const e=this._context.getCurrentId();return{"App-Key":this._context.getAppkey(),RoomId:e,Token:this._joinResData.token,RoomType:Ye.LIVE,UserId:e,"Session-Id":this._sessionId}}_exchangeHandle(e){return this._service.broadcastSubscribe(this._getReqHeaders(),e)}_updateSubListHandle(e,t=!1){var r;return $(this,void 0,void 0,function*(){if(this._assertRoomDestroyed())return{code:M.ROOM_HAS_BEEN_DESTROYED};if(!Ee("resources",e,()=>ze(e)&&e.every(y=>y instanceof Fe||y.track instanceof Fe),!0))return{code:M.PARAMS_ERROR};let i=e.map(y=>y instanceof Fe?{track:y}:Object.assign({},y));const s={};i=i.filter(y=>{const C=y.track.getTrackId();return!s[C]&&(s[C]=!0)}).map(y=>Object.assign({},y));const o=this._subscribedList.map(y=>Object.assign({},y));if(!t){let y=!1;if(i.forEach(C=>{const b=o.findIndex(O=>O.track===C.track);if(b===-1)return void(y=!0);o.splice(b,1)[0].subTiny!==C.subTiny&&(y=!0)}),o.length&&(y=!0),!y)return{code:M.SUCCESS}}this._pc.clearReTryExchangeTimer(),this._pc.updateSubRemoteTracks(i.map(y=>y.track));const{reqBody:c}=yield this._createSubscribeParams(i,{},!1),d=yield this._exchangeHandle(c);if(o.length){const y=[];o.forEach(C=>{y.push(C.track.getTrackId())}),(r=this._pc.reportParser)===null||r===void 0||r.clearLatestPacketsRecv(y)}if(d.code!==M.SUCCESS)return{code:d.code};const{sdp:l,resultCode:h,message:a,subscribedList:u}=d.data;if(h!==M.SUCCESS)return P.error("change subscribe list failed:",a,h),{code:h};i.forEach(y=>{const{track:C}=y;if(C.isMCUTrack()){const b=this._roomRes[C.getTrackId()].msid,{tag:O,userId:S}=Ge(C.getTrackId()),E=[S,O].join("_");l.sdp=l.sdp.replace(new RegExp(b,"g"),E)}});const f=yield this._pc.setRemoteAnswer(l.sdp);if(f!==M.SUCCESS)return{code:f};const p=u==null?void 0:u.map(y=>`${y.msid}_${y.mediaType}`),m=i.filter(y=>{if(y.track.isMCUTrack()){const C=this._roomRes[y.track.getTrackId()],b=`${C.msid}_${C.mediaType}`;return p.includes(b)}return p==null?void 0:p.includes(y.track.getTrackId())}),_=m==null?void 0:m.map(y=>`${y.track.getTrackId()}`),v=i.filter(y=>!(_==null?void 0:_.includes(y.track.getTrackId())));for(const y in this._remoteTracks){const C=m.some(b=>b.track.getTrackId()===y);this._remoteTracks[y].__innerSetSubscribed(C)}return this._subscribedList.splice(0,this._subscribedList.length,...m),v.length?{code:M.SUCCESS,failedList:v}:{code:M.SUCCESS}})}_diffCDNUris(e){return $(this,void 0,void 0,function*(){if(this._CDNUris.url&&!e.url)return this._callAppListener("onCDNInfoDisable"),void(this._CDNUris=e);(!this._CDNUris||!this._CDNUris.url&&e.url)&&this._callAppListener("onCDNInfoEnable",{resolution:`W${e.w}_H${e.h}`,fps:`FPS_${e.fps}`});const t=this._CDNUris.w&&e.w&&this._CDNUris.w!==e.w,r=this._CDNUris.h&&e.h&&this._CDNUris.h!==e.h,i=this._CDNUris.fps&&e.fps&&this._CDNUris.fps!==e.fps;(t||r||i)&&this._callAppListener("onCDNInfoChange",{resolution:`W${e.w}_H${e.h}`,fps:`FPS_${e.fps}`}),this._CDNUris=e})}_getCDNPlayUrl(e){return $(this,void 0,void 0,function*(){const{w:t,h:r,fps:i}=e,s=this._initOptions.pullInnerCDNProtocol||to.FLV,o=this._initOptions.pullInnerCDNUseHttps===Kn.NOT_HTTPS?Kn.NOT_HTTPS:Kn.HTTPS;if(!this._CDNUris.url)return P.error(`cdn_uris url is empty, the anchor need to open or push CDN, code: ${M.CDN_RESOURCE_IS_EMPTY}`),{code:M.CDN_RESOURCE_IS_EMPTY};const c={"App-Key":this._context.getAppkey(),Token:this._joinResData.token,RoomId:this.getRoomId(),UserId:this._context.getCurrentId(),SessionId:this.getSessionId()},d=[];t&&d.push(`w=${t}`),r&&d.push(`h=${r}`),i&&d.push(`fps=${i}`),d.push(`kind=${s}`),d.push(`is_https=${o}`);const l=d.join("&");let h=`${this._CDNUris.url}?`;l&&(h+=l);const{code:a,res:u}=yield this._service.getCDNResourceInfo(c,h);return a!==M.SUCCESS?(P.error(`getCDNPlayUrl failed: ${a}`),{code:a}):(P.info(`getCDNPlayUrl success: ${u==null?void 0:u.data.pull_url}`),{code:a,CDNPlayUrl:u==null?void 0:u.data.pull_url})})}getCDNPlayUrl(e,t){return $(this,void 0,void 0,function*(){if(e&&!dn(e))return P.error("`resolution` is invalid"),{code:M.PARAMS_ERROR};if(t&&!Xs(t))return P.error("`fps` is invalid"),{code:M.PARAMS_ERROR};const{width:r,height:i}=e?Et(e):{width:null,height:null},s=t?Rt(t):null,o={};return r&&(o.w=r),i&&(o.h=i),s&&(o.fps=s),this._getCDNPlayUrl(o)})}subscribe(e){return $(this,void 0,void 0,function*(){return be(()=>this._subscribeHandle(e,!1))})}__unsubscribe(e){var t;return $(this,void 0,void 0,function*(){if(!Ee("tracks",e,()=>ze(e)&&e.length>0&&e.every(i=>i instanceof Fe),!0))return P.error(`unsubscribe failed, tracks is invalid -> roomId: ${this._roomId}`),{code:M.PARAMS_ERROR};const r=this._subscribedList.map(i=>Object.assign({},i)).filter(i=>!e.includes(i.track));return(t=this._polarisReport)===null||t===void 0||t.sendR2(Pt.SUBSCRIBE,Lt.END,e.map(i=>i.getTrackId())),this._updateSubListHandle(r,!1)})}unsubscribe(e){return $(this,void 0,void 0,function*(){return be(()=>this.__unsubscribe(e))})}__destroy(e){var t;return $(this,void 0,void 0,function*(){this._destroyed||(this._destroyed=!0,(t=this._audioLevelReport)===null||t===void 0||t.clearAudioLevelReportTimer(),e&&(yield this._context.quitLivingRoomAsAudience(this._roomId)),yield this._service.broadcastExit(this._getReqHeaders()),this._pc.destroy(),this._polarisReport=null,this._context.onrtcdatachange=()=>{})})}getRemoteTrack(e){return this._remoteTracks[e]}__getPC(){return this._pc}getLocalTrack(e){return{}}__onReconnected(){return $(this,void 0,void 0,function*(){const{code:e}=yield this._context.joinLivingRoomAsAudience(this._roomId,Ye.LIVE);e!==N.SUCCESS&&P.error("join living room error when on reconnected")})}registerRoomEventListener(e){this._appListener=e}onAudioLevelChange(e,t){var r;(r=this._audioLevelReport)===null||r===void 0||r.clearAudioLevelReportTimer(),this._audioLevelReport=new Dd(this),this._audioLevelReport.onAudioLevelChange(e,t||1e3)}registerReportListener(e){var t;(t=this._pc)===null||t===void 0||t.registerReportListener(e)}getRoomId(){return this._roomId}getCrtUserId(){return this._context.getCurrentId()}getSessionId(){return this._sessionId}getRemoteUserIds(){return this._roomAnchorList}getRemoteTracksByUserId(e){const t=[];for(const r in this._remoteTracks){const i=this._remoteTracks[r];i.getUserId()===e&&t.push(i)}return t}getRemoteTracks(){const e=[],t=[];for(const r in this._remoteTracks){if(t.length===2)break;const i=this._remoteTracks[r];i.isMCUTrack()&&t.push(i)}return this._roomAnchorList.forEach(r=>{e.push(...this.getRemoteTracksByUserId(r))}),[...t,...e]}getRemoteRTCTracks(){const e=[];for(const t in this._remoteTracks){const r=this._remoteTracks[t];r.isMCUTrack()||e.push(r)}return e}getRemoteMCUTracks(){const e=[];for(const t in this._remoteTracks){const r=this._remoteTracks[t];r.isMCUTrack()&&e.push(r)}return e}getCDNInfo(){return this._CDNUris.w?{resolution:`W${this._CDNUris.w}_H${this._CDNUris.h}`,fps:`FPS_${this._CDNUris.fps}`,CDNEnable:this._CDNUris.enableInnerCDN}:{CDNEnable:!1}}}const Vc=(n,e)=>{const t=[];return t[0]=(e==null?void 0:e.withoutAudio)?void 0:n.getAudioTracks()[0],t[1]=(e==null?void 0:e.withoutVideo)?void 0:n.getVideoTracks()[0],t};class $f{constructor(e,t,r){this._context=e,this._runtime=t,this._options=r,this._crtRoom=null,this._audience=null,this._crtAudienceLivingRoom=null,Tn.setSdpSemantics(r.sdpSemantics||"plan-b"),this._service=new fa(this._runtime,this._context,this._options.mediaServer,this._options.timeout),this._context.onconnectionstatechange=this._onIMStatusChange.bind(this),this._context.ondisconnect=this._onIMDisconnect.bind(this),this._context.ondestroy=this._onIMUninit.bind(this),this._context.onmessage=this._handleMessage.bind(this)}_handleMessage(e){var t;return e.conversationType!==Q.RTC_ROOM?!1:(this._crtRoom instanceof kt&&this._getJoinedPKRoomList().forEach(r=>{r.__parseInnerMessage(e)}),(t=this._crtRoom)===null||t===void 0||t.__parseInnerMessage(e),!0)}_getJoinedPKRoomList(){const{code:e,roomPKHandler:t}=this._crtRoom.getRoomPKHandler();if(e===M.SUCCESS&&t){const r=t.getJoinedPKRooms()||{};return Object.values(r)}return[]}getCurrentId(){return this._context.getCurrentId()}joinRTCRoom(e,t){return be(()=>this._joinRTCRoom(e,t))}_joinRTCRoom(e,t){return $(this,void 0,void 0,function*(){if($r(this._context.getNaviInfo()))return{code:M.PACKAGE_ENVIRONMENT_ERROR};if(!Ee("roomId",e,Ze,!0))return{code:M.PARAMS_ERROR};if(this._crtRoom)return{code:M.REPERT_JOIN_ROOM};if(this._context.getConnectionStatus()!==re.CONNECTED)return{code:M.SIGNAL_DISCONNECTED};if(!this._service.getNaviMS().length)return{code:M.NOT_OPEN_VIDEO_AUDIO_SERVER};P.debug(`joinRoom -> roomId: ${e}; joinType: ${t||Us.KICK}`);const{code:r,data:i}=yield this._context.joinRTCRoom(e,Ye.RTC,void 0,t);if(r!==N.SUCCESS)return P.error(`joinRoom failed -> code: ${r}`),{code:r===Ks.JOIN_REFUSED?M.SIGNAL_JOIN_RTC_ROOM_REFUSED:r};P.debug(`joinRoom success -> userId: ${this._context.getCurrentId()}, roomId: ${e}, data: ${JSON.stringify(i)}`);const s=new Vf(this._context,this._runtime,e,i,this._service,this._options,this._releaseCrtRoomObj.bind(this));return this._crtRoom=s,{room:s,code:M.SUCCESS,userIds:s.getRemoteUserIds(),tracks:s.getRemoteTracks()}})}joinLivingRoom(e,t){return be(()=>this._joinLivingRoom(e,t))}_joinLivingRoom(e,t){return $(this,void 0,void 0,function*(){if($r(this._context.getNaviInfo()))return{code:M.PACKAGE_ENVIRONMENT_ERROR};if(!Ee("roomId",e,Ze,!0)||!Ee("livingType",t,c=>c===pt.AUDIO||c===pt.VIDEO))return{code:M.PARAMS_ERROR};if(this._crtRoom)return{code:M.REPERT_JOIN_ROOM};if(this._context.getConnectionStatus()!==re.CONNECTED)return{code:M.SIGNAL_DISCONNECTED};if(!this._service.getNaviMS().length)return{code:M.NOT_OPEN_VIDEO_AUDIO_SERVER};P.debug(`joinRoom, roomId: ${e}`);const{code:r,data:i}=yield this._context.joinRTCRoom(e,Ye.LIVE,t);if(r!==N.SUCCESS)return P.error(`joinRoom failed -> code: ${r}`),{code:r};P.debug(`JoinRoom success -> userId: ${this._context.getCurrentId()}, roomId: ${e}, data: ${JSON.stringify(i)}`);const s=new kt(this._context,this._runtime,e,i,this._service,this._options,this._releaseCrtRoomObj.bind(this),t,!1,!0);this._crtRoom=s;const o={room:s,code:M.SUCCESS,userIds:s.getRemoteUserIds(),tracks:s.getRemoteTracks()};return s.__getCDNPushMode()===di.MANUAL&&Object.assign(o,{CDNEnable:s.__getCDNEnable()}),o})}getAudienceClient(){return this._audience||(this._audience=new Ff(this._context,this._runtime,this._options)),this._audience}_onIMStatusChange(e){P.debug(`signal server connection state change: ${e}`),e===re.CONNECTED&&(this._crtRoom instanceof kt&&this._getJoinedPKRoomList().forEach(t=>{t.__onReconnected()}),this._crtRoom&&this._crtRoom.__onReconnected())}_onIMDisconnect(){P.debug("TODO -> on IM disconnect")}_onIMUninit(){P.debug("TODO -> on IM client ondestroy")}leaveRoom(e){return be(()=>this._leaveRoom(e))}_leaveRoom(e){return $(this,void 0,void 0,function*(){return this._crtRoom?(yield this._crtRoom.__destroy(!0),P.debug(`quitRTCRoom -> userId: ${this._context.getCurrentId()} , roomId: ${this._crtRoom.getRoomId()}`),this._crtRoom=null,{code:M.SUCCESS}):{code:M.SUCCESS}})}_releaseCrtRoomObj(){this._crtRoom=null}_getMediaStream(e,t="getUserMedia"){return $(this,void 0,void 0,function*(){try{const r=yield navigator.mediaDevices[t](e);return{code:M.SUCCESS,stream:r}}catch(r){if(r.message==="Permission denied")return{code:M.PERMISSION_DENIED};P.error(`get user media failed -> ${r.message}`)}return{code:t==="getUserMedia"?M.GET_USER_MEDIA_FAILED:M.GET_DISPLAY_MEDIA_FAILED}})}createMicrophoneAudioTrack(e="RongCloudRTC",t){return $(this,void 0,void 0,function*(){if(!bt(e))return{code:M.INVALID_TAGS};const r=this._context.getCurrentId();if(!r)return{code:M.INVALID_USER_ID};const{stream:i,code:s}=yield this._getMediaStream({audio:{deviceId:t==null?void 0:t.micphoneId,sampleRate:t==null?void 0:t.sampleRate}});if(s!==M.SUCCESS)return{code:s};const o=i.getAudioTracks()[0];return{code:s,track:new Lc(e,r,o)}})}createCameraVideoTrack(e="RongCloudRTC",t){return $(this,void 0,void 0,function*(){if(!bt(e))return{code:M.INVALID_TAGS};const r=this._context.getCurrentId();if(!r)return{code:M.INVALID_USER_ID};const i=dn(t==null?void 0:t.resolution)?t.resolution:Re.W640_H480,{width:s,height:o}=Et(i),{stream:c,code:d}=yield this._getMediaStream({video:{deviceId:t==null?void 0:t.cameraId,frameRate:Rt((t==null?void 0:t.frameRate)||Ct.FPS_15),width:s,height:o,facingMode:t==null?void 0:t.faceMode}});if(d!==M.SUCCESS)return{code:d};const l=c.getVideoTracks()[0];return{code:d,track:new kc(e,r,l)}})}createMicrophoneAndCameraTracks(e="RongCloudRTC",t){var r,i,s,o,c,d;return $(this,void 0,void 0,function*(){const l=[];if(!bt(e))return{code:M.INVALID_TAGS,tracks:l};const h=this._context.getCurrentId();if(!h)return{code:M.INVALID_USER_ID,tracks:l};const a=dn((r=t==null?void 0:t.video)===null||r===void 0?void 0:r.resolution)?t.video.resolution:Re.W640_H480,{width:u,height:f}=Et(a),{stream:p,code:m}=yield this._getMediaStream({video:{deviceId:(i=t==null?void 0:t.video)===null||i===void 0?void 0:i.cameraId,frameRate:Rt(((s=t==null?void 0:t.video)===null||s===void 0?void 0:s.frameRate)||Ct.FPS_15),width:u,height:f,facingMode:(o=t==null?void 0:t.video)===null||o===void 0?void 0:o.faceMode},audio:{deviceId:(c=t==null?void 0:t.audio)===null||c===void 0?void 0:c.micphoneId,sampleRate:(d=t==null?void 0:t.audio)===null||d===void 0?void 0:d.sampleRate}});return m!==M.SUCCESS||p.getTracks().forEach(_=>{_.kind==="video"?l.push(new kc(e,h,_)):l.unshift(new Lc(e,h,_))}),{code:m,tracks:l}})}createScreenVideoTrack(e="screenshare",t){return $(this,void 0,void 0,function*(){if(!bt(e))return{code:M.INVALID_TAGS};const r=this._context.getCurrentId();if(!r)return{code:M.INVALID_USER_ID};if(!Ld())return{code:M.BROWSER_NOT_SUPPORT};const i=/Electron/.test(navigator.userAgent);if(i&&!(t==null?void 0:t.chromeMediaSourceId))return{code:M.PARAMS_ERROR};const s=dn(t==null?void 0:t.resolution)?t.resolution:Re.W1280_H720,{width:o,height:c}=Et(s),d=i?{mandatory:{chromeMediaSourceId:t.chromeMediaSourceId,chromeMediaSource:"desktop",minWidth:o,maxWidth:o,minHeight:c,maxHeight:c}}:{frameRate:Rt((t==null?void 0:t.frameRate)||Ct.FPS_15),width:o,height:c},{stream:l,code:h}=yield this._getMediaStream({video:d,audio:!1},i?"getUserMedia":"getDisplayMedia");if(h!==M.SUCCESS)return{code:h};const a=l.getVideoTracks()[0];return{code:h,track:new wf(e,r,a)}})}createLocalAudioTrack(e,t){return $(this,void 0,void 0,function*(){if(!bt(e))return{code:M.INVALID_TAGS};if(!t||t.toString()!=="[object MediaStreamTrack]"||t.kind!=="audio")return{code:M.CREATE_CUSTOM_TRACK_FAILED};const r=this._context.getCurrentId();return r?{code:M.SUCCESS,track:new Qs(e,r,t)}:{code:M.INVALID_USER_ID}})}createLocalVideoTrack(e,t){return $(this,void 0,void 0,function*(){if(!bt(e))return{code:M.INVALID_TAGS};if(!t||t.toString()!=="[object MediaStreamTrack]"||t.kind!=="video")return{code:M.CREATE_CUSTOM_TRACK_FAILED};const r=this._context.getCurrentId();return r?{code:M.SUCCESS,track:new pn(e,r,t)}:{code:M.INVALID_USER_ID}})}createLocalFileTracks(e,t,r){return $(this,void 0,void 0,function*(){if(!bt(e))return{code:M.INVALID_TAGS,tracks:[]};if(!Pd())return{code:M.BROWSER_NOT_SUPPORT,tracks:[]};const i=t instanceof File?URL.createObjectURL(t):t;if(!Yn(i)&&!/^blob:/.test(i))return P.warn(`createLocalFileTracks failed: params error -> url: ${i}`),{code:M.PARAMS_ERROR,tracks:[]};const s=this._context.getCurrentId();return s?new Promise(o=>{const c=document.createElement("video");(r==null?void 0:r.withoutAudio)&&(c.muted=!0),c.onloadedmetadata=()=>{const d=[];let l;try{const u=c.mozCaptureStream?"mozCaptureStream":"captureStream";l=c[u]()}catch(u){P.error(`create RCLocalFileTrack failed, captureSteam error. -> url: ${i}`),P.error(u),o({code:M.CREATE_FILE_TRACK_FAILED,tracks:d})}const[h,a]=Vc(l,r);h&&d.push(new bf(e,s,h,c)),a&&d.push(new If(e,s,a,c)),d.length===0&&(c.pause(),c.src=""),c.onerror=null,o({code:M.SUCCESS,tracks:d})},c.onerror=()=>{P.error(`create RCLocalFileTrack failed -> url: ${i}`),o({code:M.CREATE_FILE_TRACK_FAILED,tracks:[]})},c.src=i,c.loop=!0,c.play()}):{code:M.INVALID_USER_ID,tracks:[]}})}createLocalTracks(e,t,r){return $(this,void 0,void 0,function*(){const i=[];if(!bt(e))return{code:M.INVALID_TAGS,tracks:i};if(!(t instanceof MediaStream))return{code:M.PARAMS_ERROR,tracks:i};const s=this._context.getCurrentId();if(!s)return{code:M.INVALID_USER_ID,tracks:i};const[o,c]=Vc(t,r);return o&&i.push(new Qs(e,s,o)),c&&i.push(new pn(e,s,c)),{code:M.SUCCESS,tracks:i}})}joinLivingRoomAsAudience(e,t){return $(this,void 0,void 0,function*(){if($r(this._context.getNaviInfo()))return{code:M.PACKAGE_ENVIRONMENT_ERROR};if(!Ee("roomId",e,Ze,!0)||!Ee("livingType",t,o=>o===pt.AUDIO||o===pt.VIDEO))return{code:M.PARAMS_ERROR};if(this._crtAudienceLivingRoom)return{code:M.REPERT_JOIN_ROOM};if(!this._service.getNaviMS().length)return{code:M.NOT_OPEN_VIDEO_AUDIO_SERVER};const{code:r,data:i}=yield this._context.joinLivingRoomAsAudience(e,Ye.LIVE,t);if(r!==N.SUCCESS)return P.error("audienceJoinLivingRoomError:",r),{code:M.SIGNAL_AUDIENCE_JOIN_ROOM_FAILED};P.info(`joinLivingRoomAsAudience success, room data: ${JSON.stringify(i)}`);const s=new Bc(this._context,this._runtime,this._options,e,i,t);return this._crtAudienceLivingRoom=s,{room:s,code:M.SUCCESS,userIds:s.getRemoteUserIds(),RTCTracks:s.getRemoteRTCTracks(),MCUTracks:s.getRemoteMCUTracks(),CDNUris:s.getCDNInfo()}})}leaveLivingRoomAsAudience(e){return $(this,void 0,void 0,function*(){return this._crtAudienceLivingRoom?this._crtAudienceLivingRoom!==e?{code:M.PARAMS_ERROR}:(yield this._crtAudienceLivingRoom.__destroy(!0),this._crtAudienceLivingRoom=null,{code:M.SUCCESS}):{code:M.SUCCESS}})}upgradeToAnchorRoom(e){return $(this,void 0,void 0,function*(){if(!Ee("room._roomId",e._roomId,Ze,!0))return{code:M.PARAMS_ERROR};if(this._crtRoom)return{code:M.REPERT_JOIN_ROOM};const{code:t,data:r}=yield this._context.rtcIdentityChange(e._roomId,Yr.ViewerToAnchor,e._livingType);if(t!==N.SUCCESS)return P.error("change room identity error",t),{code:M.SIGNAL_ROOM_CHANGE_IDENTITY_FAILED};yield this._crtAudienceLivingRoom.__destroy(!1);const i=new kt(this._context,this._runtime,e._roomId,r,this._service,this._options,this._releaseCrtRoomObj.bind(this),e._livingType,!0,!0);return this._crtRoom=i,this._crtAudienceLivingRoom=null,{room:i,code:M.SUCCESS,userIds:e.getRemoteUserIds(),tracks:i.getRemoteTracks()}})}downgradeToAudienceRoom(e){return $(this,void 0,void 0,function*(){if(!Ee("room._roomId",e._roomId,Ze,!0))return{code:M.PARAMS_ERROR};if(this._crtAudienceLivingRoom)return{code:M.REPERT_JOIN_ROOM};const{code:t,data:r}=yield this._context.rtcIdentityChange(e._roomId,Yr.AnchorToViewer,e.getLivingType());if(t!==N.SUCCESS)return P.error("change room identity error",t),{code:M.SIGNAL_ROOM_CHANGE_IDENTITY_FAILED};P.info(`downgradeToAudienceRoom success, room data: ${JSON.stringify(r)}`);const i=new Bc(this._context,this._runtime,this._options,e._roomId,r,e.getLivingType());return this._crtAudienceLivingRoom=i,this._crtRoom.__destroy(!1),this._crtRoom=null,{room:i,code:M.SUCCESS,userIds:i.getRemoteUserIds(),RTCTracks:i.getRemoteRTCTracks(),MCUTracks:i.getRemoteMCUTracks(),CDNUris:i.getCDNInfo()}})}getJoinedRoomInfo(){return $(this,void 0,void 0,function*(){const{code:e,data:t}=yield this._context.getRTCJoinedUserInfo(this._context.getCurrentId());return e!==N.SUCCESS?(P.error("getJoinedUserInfo error",e),{code:M.SIGNAL_ROOM_CHANGE_IDENTITY_FAILED}):{code:M.SUCCESS,data:t}})}}var Fc;(function(n){n[n.SERVER_KICK=1]="SERVER_KICK",n[n.OTHER_KICK=2]="OTHER_KICK"})(Fc||(Fc={}));const jf={tag:"RCRTC",verify:n=>n.tag!=="browser"?(P.error(`RCRTC Plugin is not support the runtime '${n.tag}'`),!1):Nf?(Yt.add("plugin-rtc","5.3.1"),!!Yt.validEngine("5.1.0")||(P.error(`The current engine version '${Yt.getInfo().engine}' error, plugin-rtc required engine version at least '5.1.0'.`),!1)):(P.error("Please use the https protocol or use `http://localhost` to open the page!"),!1),setup:(n,e,t={})=>(P.setLogLevel(t.logLevel),P.setLogStdout(t.logStdout),P.warn("RCRTC Version: 5.3.1, Commit: e1af0f5ccb06a0084c94e1219d8af54c9793c06b"),P.warn(`browserInfo.browser -> ${dt.browser}`),P.warn(`browserInfo.supportsUnifiedPlan -> ${dt.supportsUnifiedPlan}`),P.warn(`browserInfo.version -> ${dt.version}`),xe("options.mediaServer",t.mediaServer,r=>!(!Yn(r)||location.protocol==="https:"&&!/^https/.test(r))),xe("options.timeout",t.timeout,r=>Ie(r)&&r>=5e3&&r<=3e4),xe("options.pingGap",t.pingGap,r=>Ie(r)&&r>=3e3&&r<=1e4),new $f(n,e,t))},Kf={transResolution:Et,transFrameRate:Rt,parseTrackId:Ge,ifSupportLocalFileTrack:Pd,ifSupportScreenShare:Ld};function qf(n){return{all:n=n||new Map,on:function(e,t){var r=n.get(e);r?r.push(t):n.set(e,[t])},off:function(e,t){var r=n.get(e);r&&(t?r.splice(r.indexOf(t)>>>0,1):n.set(e,[]))},emit:function(e,t){var r=n.get(e);r&&r.slice().map(function(i){i(t)}),(r=n.get("*"))&&r.slice().map(function(i){i(e,t)})}}}const Ue={"RC:Chatroom:Welcome":"Welcome","RC:TxtMsg":"Text","RC:Chatroom:Barrage":"Barrage","RC:Chatroom:Like":"Like","RC:Chatroom:SeatsCtrl":"SeatsCtrl","RC:Chatroom:ChatBan":"ChatBan","RC:Chatroom:SeatApply":"SeatApply","RC:Chatroom:SeatResponse":"SeatResponse","RM:RTC:TrackUnpublish":"TrackUnpublish","RM:RTC:SwitchRole":"SwitchRole","RM:RTC:UserLeave":"UserLeave","RC:Chatroom:Leave":"Leave"};var De=qf();const pa="start-live-time",ga="start-live-status",Y=co({roomUid:"LIVE-2112263-12345",imConnectStatus:"connecting",screenShareStatus:!1,videoRef:uo(null),rtcClient:null,joinedRoom:null,mediaStreamTrack:[],mediaStreams:null,videoStatus:"init",microphones:[],cameras:[],selectedCamera:null,selectedMicrophone:null,likeCount:0,lastLikeCount:0,activeTracks:{},allowSeatsCtrl:!0,allowChatCtrl:!0,deviceStatus:{microphone:"init",camera:"init",screen:"init"}});var ne=Y;const Gf="c9kqb3rdc451j";Xh({appkey:Gf});const Yf=Mi("RC:Chatroom:SeatsCtrl",!0,!0),Jf=Mi("RC:Chatroom:ChatBan",!0,!0),Wf=Mi("RC:Chatroom:SeatApply",!0,!0),zf=Mi("RC:Chatroom:SeatResponse",!0,!0),dr=Ne,Oa=dr,{MESSAGES:M_}=Oa,Qf=Na(Oa,["MESSAGES"]);cr(dr.MESSAGES,n=>{console.log(n,"\u6536\u5230\u6D88\u606F");const{messages:e}=n;for(const t of e)Ue[t.messageType]&&De.emit(Ue[t.messageType],bn(it({},t.content),{$EventMessage:t}))});for(const n of Object.values(Qf))cr(n,e=>{console.log(n,e),De.emit(n,{$EventMessage:null})});cr(dr.CONNECTING,()=>{console.log("connecting"),Y.imConnectStatus="connecting"});cr(dr.CONNECTED,()=>{console.log("connected"),Y.imConnectStatus="connected"});cr(dr.DISCONNECT,()=>{console.log("disconnect"),Y.imConnectStatus="disconnect"});const Xf=async n=>{var e;try{const t=await ef(n);return Y.rtcClient=Zh(jf,{}),console.log("connect success",(e=t.data)==null?void 0:e.userId),t}catch(t){throw t}},Zf=n=>{Y.videoRef&&(Y.videoRef.volume=n/100)},ep=async()=>{var n;if(Y.rtcClient){const e=await xt("screen"),t=Y.activeTracks.camera;(n=Y.joinedRoom)==null||n.unpublish([t]),Bt([e],"screen"),Y.videoRef&&(e.play(Y.videoRef),Y.screenShareStatus=!0),e==null||e.on(pe.EVENT_LOCAL_TRACK_END,r=>{Y.screenShareStatus=!1,r.destroy(),t&&(Bt([t],"camera"),Y.videoRef&&t.play(Y.videoRef))})}},tp=async()=>{const n=await ua.getMicrophones();return Y.microphones=n,n},np=async()=>{const n=await ua.getCameras();return Y.cameras=n,n},Vd=async n=>{Y.selectedCamera=n;const e=Y.activeTracks.camera;e&&await Li([e],"camera",e.isPublished());const t=await xt("camera");Bt([t],"camera",Y.videoStatus==="liveing")},Fd=async n=>{Y.selectedMicrophone=n;const e=Y.activeTracks.microphone;e&&await Li([e],"microphone",e.isPublished());const t=await xt("microphone");Bt([t],"microphone",Y.videoStatus==="liveing")},xt=async n=>{var r,i,s,o,c;let e,t=null;return n==="microphone"?e=await((i=Y.rtcClient)==null?void 0:i.createMicrophoneAudioTrack("RongCloudRTC",{micphoneId:(r=Y.selectedMicrophone)==null?void 0:r.deviceId})):n==="camera"?e=await((o=Y.rtcClient)==null?void 0:o.createCameraVideoTrack("RongCloudRTC",{cameraId:(s=Y.selectedCamera)==null?void 0:s.deviceId,faceMode:"user",frameRate:Ct.FPS_24,resolution:Re.W1920_H1080})):e=await((c=Y==null?void 0:Y.rtcClient)==null?void 0:c.createScreenVideoTrack()),t=e==null?void 0:e.track,(n==="camera"&&!Y.cameras.length||n==="microphone"&&!Y.microphones.length||n==="screen"&&!Y.screenShareStatus)&&(Y.deviceStatus[n]="none"),e.code===M.PERMISSION_DENIED?Y.deviceStatus[n]="denied":Y.deviceStatus[n]="granted",t},Bt=async(n,e,t=!0)=>{var r;for(const i of n)Y.activeTracks[e]=i;t&&await((r=Y.joinedRoom)==null?void 0:r.publish(n))},Li=async(n,e,t=!0)=>{var r;for(const i of n)i.destroy(),Y.activeTracks[e]=null;t&&await((r=Y.joinedRoom)==null?void 0:r.unpublish(n))},rp=async(n,e,t)=>{var i,s;await tf(n,{count:-1});const r=await((i=Y.rtcClient)==null?void 0:i.joinLivingRoom(n,e));if((r==null?void 0:r.code)!=M.SUCCESS)throw Error("\u52A0\u5165\u623F\u95F4\u5931\u8D25");return(s=r.room)==null||s.registerRoomEventListener(t),r},ip=async(n,e,t)=>{var r;try{await Jt.get("/api-web/imLiveBroadcastRoom/joinRoom",{params:{roomUid:Y.roomUid,userId:(r=ve.user)==null?void 0:r.speakerId}})}catch{}return await rp(n,e,t)},Hd=async()=>{var e,t;if(Y.videoStatus!=="stream")throw Error("\u5F53\u524D\u65E0\u89C6\u9891\u6D41");if(Y.joinedRoom){const r=await xt("microphone"),i=await xt("camera");await Bt([i],"camera"),await Bt([r],"microphone");const s=await((e=Y.joinedRoom)==null?void 0:e.getMCUConfigBuilder());await((t=s.setOutputVideoRenderMode)==null?void 0:t.call(s,nr.WHOLE)),await s.flush(),Y.videoStatus="liveing"}sessionStorage.setItem(pa,Tt().valueOf().toString()),sessionStorage.setItem(ga,"liveing")},sp=async()=>{sessionStorage.removeItem(pa),sessionStorage.removeItem(ga),Y.videoStatus="stream";for(const n in Y.activeTracks)if(Object.prototype.hasOwnProperty.call(Y.activeTracks,n)){const e=Y.activeTracks[n];e&&Li([e],n)}},$d=async()=>{if((Y.likeCount!==Y.lastLikeCount||Y.likeCount===0)&&ve.user)try{await Jt.get("/api-web/imLiveBroadcastRoom/syncLike",{hideLoading:!0,hideMessage:!0,params:{likeNum:Y.likeCount,roomUid:Y.roomUid}}),Y.lastLikeCount=Y.likeCount}catch{}setTimeout(()=>{$d()},1e3*60)},li=()=>{var n,e,t,r;return{id:(n=ve.user)==null?void 0:n.speakerId,name:(e=ve.user)==null?void 0:e.speakerName,userId:(t=ve.user)==null?void 0:t.speakerId,userName:(r=ve.user)==null?void 0:r.speakerName}},zt=async(n,e="text")=>{var i;let t=null;if(!n)return;const r={conversationType:Q.CHATROOM,targetId:(i=Y.joinedRoom)==null?void 0:i._roomId};if(e==="text"?t=new of({user:li(),content:n}):e==="SeatsCtrl"?t=new Yf(n):e==="ChatBan"?t=new Jf(n):e==="SeatApply"?t=new Wf(n):e==="SeatResponse"&&(t=new zf(n)),!!t)return console.log(t),await Ju(r,t)},jd=async(n,e=!0)=>{var t;if(n==="microphone"&&Y.activeTracks[n])(t=Y.activeTracks[n])==null||t.unmute();else{const r=await xt(n);await Bt([r],n,e),Y.videoRef&&r.play(Y.videoRef)}},hi=async(n,e=!0)=>{const t=Y.activeTracks[n];n!=="microphone"?(await Li([t],n,e),t==null||t.destroy()):t==null||t.mute()},op=async n=>{const e=Y.activeTracks[n],t=Y.videoStatus==="liveing";e?(n==="camera"&&(Y.deviceStatus.camera="closed"),hi(n,t)):(n==="camera"&&(Y.deviceStatus.camera="granted"),jd(n,t))};var ap=Be({methods:{async loginOut(){try{await Jt.post("/api-auth/exit",{data:{}}),hi("camera"),hi("microphone"),ve.user=null,Ur.success("\u9000\u51FA\u6210\u529F"),yl(),this.$router.push({path:"/login",query:it({},this.$route.query)})}catch{}}},render(){var n,e,t;return I("div",{class:Ht.liveHeader},[I("div",{class:Ht.liveHeaderLeft},[I("div",{class:Ht.liveHeaderLeftIcon},[I("img",{class:Ht.liveLogo,src:(n=ve.user)==null?void 0:n.tenantLogo,alt:""},null),(e=ve.user)==null?void 0:e.tenantName]),I("div",{class:Ht.liveHeaderLeftText},[z("\u300A"),(t=ve.user)==null?void 0:t.roomTitle,z("\u300B")])]),I(Dr,{trigger:"hover"},{default:()=>{var r;return[I("div",{class:Ht.avatarWrapper},[I("img",{class:Ht.userAvatar,src:"/src/assets/home/placehorder-icon.png"},null),I("span",null,[(r=ve.user)==null?void 0:r.speakerName])])]},dropdown:()=>I(Cs,null,{default:()=>[I(Es,{command:"1",onClick:this.loginOut},{default:()=>[I("span",null,[z("\u5B89\u5168\u9000\u51FA")])]})]})})])}});const cp="_header_22t18_1",up="_title_22t18_9";var Hc={header:cp,title:up},dp=Be({name:"LiveBroadcastHeader",methods:{async startLive(){try{await Aa.confirm("\u662F\u5426\u786E\u8BA4\u5F00\u59CB\u76F4\u64AD\uFF1F","\u63D0\u793A",{confirmButtonText:"\u786E\u5B9A",cancelButtonText:"\u53D6\u6D88",type:"warning"}),await Hd()}catch(n){console.log(n)}},async closeLive(){try{await Aa.confirm("\u662F\u5426\u786E\u8BA4\u7ED3\u675F\u76F4\u64AD\uFF1F","\u63D0\u793A",{confirmButtonText:"\u786E\u5B9A",cancelButtonText:"\u53D6\u6D88",type:"warning"}),await sp()}catch{}}},render(){var n;return I("div",{class:Hc.header},[I("h3",{class:Hc.title},[z("\u76F4\u64AD\u5185\u5BB9\uFF1A"),(n=ve.user)==null?void 0:n.liveRemark]),ne.videoStatus==="liveing"?I(ht,{type:"danger",color:"#EA4132",onClick:this.closeLive},{default:()=>[z("\u5173\u95ED\u76F4\u64AD")]}):I(ht,{type:"primary",color:"#01A79E",onClick:this.startLive},{default:()=>[z("\u5F00\u59CB\u76F4\u64AD")]})])}});const lp="_volumeSlider_1akc3_71",hp="_volumeIcon_1akc3_80",fp="_btnInner_1akc3_85";var Se={"action-bar":"_action-bar_1akc3_1","bar-btn":"_bar-btn_1akc3_12","bar-btn-text":"_bar-btn-text_1akc3_19",volumeSlider:lp,volumeIcon:hp,btnInner:fp};const pp="_shareWrap_d61fv_1",gp="_shareBtn_d61fv_27";var vt={shareWrap:pp,shareBtn:gp};function mp(){let n=window.location.href,e="";return/online/.test(n)?e="https://mstuonline.dayaedu.com":/dev/.test(n)?e="http://mstudev.dayaedu.com":/test/.test(n)?e="http://mstutest.dayaedu.com":e="http://mstudev.dayaedu.com",e}var Kd=globalThis&&globalThis.__awaiter||function(n,e,t,r){function i(s){return s instanceof t?s:new t(function(o){o(s)})}return new(t||(t=Promise))(function(s,o){function c(h){try{l(r.next(h))}catch(a){o(a)}}function d(h){try{l(r.throw(h))}catch(a){o(a)}}function l(h){h.done?s(h.value):i(h.value).then(c,d)}l((r=r.apply(n,e||[])).next())})};const $c="application/font-woff",jc="image/jpeg",_p={woff:$c,woff2:$c,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:jc,jpeg:jc,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml"};function vp(n){const e=/\.([^./]*?)$/g.exec(n);return e?e[1]:""}function fi(n){const e=vp(n).toLowerCase();return _p[e]||""}function yp(n,e){if(n.match(/^[a-z]+:\/\//i))return n;if(n.match(/^\/\//))return window.location.protocol+n;if(n.match(/^[a-z]+:/i))return n;const t=document.implementation.createHTMLDocument(),r=t.createElement("base"),i=t.createElement("a");return t.head.appendChild(r),t.body.appendChild(i),e&&(r.href=e),i.href=n,i.href}function no(n){return n.search(/^(data:)/)!==-1}function pi(n,e){return`data:${e};base64,${n}`}function Cp(n){return n.split(/,/)[1]}const Ep=function(){let e=0;const t=()=>`0000${(Math.random()*Math.pow(36,4)<<0).toString(36)}`.slice(-4);return()=>(e+=1,`u${t()}${e}`)}();function Vt(n){const e=[];for(let t=0,r=n.length;t<r;t+=1)e.push(n[t]);return e}function gi(n,e){const t=window.getComputedStyle(n).getPropertyValue(e);return parseFloat(t.replace("px",""))}function Rp(n){const e=gi(n,"border-left-width"),t=gi(n,"border-right-width");return n.clientWidth+e+t}function Tp(n){const e=gi(n,"border-top-width"),t=gi(n,"border-bottom-width");return n.clientHeight+e+t}function Sp(){let n,e;try{e=process}catch{}const t=e&&e.env?e.env.devicePixelRatio:null;return t&&(n=parseInt(t,10),Number.isNaN(n)&&(n=1)),n||window.devicePixelRatio||1}function ma(n){return new Promise((e,t)=>{const r=new Image;r.onload=()=>e(r),r.onerror=t,r.crossOrigin="anonymous",r.decoding="sync",r.src=n})}function Ip(n){return Kd(this,void 0,void 0,function*(){return Promise.resolve().then(()=>new XMLSerializer().serializeToString(n)).then(encodeURIComponent).then(e=>`data:image/svg+xml;charset=utf-8,${e}`)})}function bp(n,e,t){return Kd(this,void 0,void 0,function*(){const r="http://www.w3.org/2000/svg",i=document.createElementNS(r,"svg"),s=document.createElementNS(r,"foreignObject");return i.setAttribute("width",`${e}`),i.setAttribute("height",`${t}`),i.setAttribute("viewBox",`0 0 ${e} ${t}`),s.setAttribute("width","100%"),s.setAttribute("height","100%"),s.setAttribute("x","0"),s.setAttribute("y","0"),s.setAttribute("externalResourcesRequired","true"),i.appendChild(s),s.appendChild(n),Ip(i)})}const as={};function wp(n){let e=n.replace(/\?.*/,"");return/ttf|otf|eot|woff2?/i.test(e)&&(e=e.replace(/.*\//,"")),e}function _a(n,e){const t=wp(n);if(as[t]!=null)return as[t];e.cacheBust&&(n+=(/\?/.test(n)?"&":"?")+new Date().getTime());const r=s=>{let o="";if(e.imagePlaceholder){const d=e.imagePlaceholder.split(/,/);d&&d[1]&&(o=d[1])}let c=`Failed to fetch resource: ${n}`;return s&&(c=typeof s=="string"?s:s.message),c&&console.error(c),{blob:o,contentType:""}},i=window.fetch(n).then(s=>s.blob().then(o=>({blob:o,contentType:s.headers.get("Content-Type")||""}))).then(({blob:s,contentType:o})=>new Promise((c,d)=>{const l=new FileReader;l.onloadend=()=>c({contentType:o,blob:l.result}),l.onerror=d,l.readAsDataURL(s)})).then(({blob:s,contentType:o})=>({contentType:o,blob:Cp(s)})).catch(r);return as[t]=i,i}function Np(n){const e=n.getPropertyValue("content");return`${n.cssText} content: '${e.replace(/'|"/g,"")}';`}function Op(n){return Vt(n).map(e=>{const t=n.getPropertyValue(e),r=n.getPropertyPriority(e);return`${e}: ${t}${r?" !important":""};`}).join(" ")}function Ap(n,e,t){const r=`.${n}:${e}`,i=t.cssText?Np(t):Op(t);return document.createTextNode(`${r}{${i}}`)}function Kc(n,e,t){const r=window.getComputedStyle(n,t),i=r.getPropertyValue("content");if(i===""||i==="none")return;const s=Ep();try{e.className=`${e.className} ${s}`}catch{return}const o=document.createElement("style");o.appendChild(Ap(s,t,r)),e.appendChild(o)}function Mp(n,e){Kc(n,e,":before"),Kc(n,e,":after")}var Sn=globalThis&&globalThis.__awaiter||function(n,e,t,r){function i(s){return s instanceof t?s:new t(function(o){o(s)})}return new(t||(t=Promise))(function(s,o){function c(h){try{l(r.next(h))}catch(a){o(a)}}function d(h){try{l(r.throw(h))}catch(a){o(a)}}function l(h){h.done?s(h.value):i(h.value).then(c,d)}l((r=r.apply(n,e||[])).next())})};function Pp(n){return Sn(this,void 0,void 0,function*(){const e=n.toDataURL();return e==="data:,"?Promise.resolve(n.cloneNode(!1)):ma(e)})}function Lp(n,e){return Sn(this,void 0,void 0,function*(){return Promise.resolve(n.poster).then(t=>_a(t,e)).then(t=>pi(t.blob,fi(n.poster)||t.contentType)).then(t=>ma(t))})}function kp(n,e){return Sn(this,void 0,void 0,function*(){return n instanceof HTMLCanvasElement?Pp(n):n instanceof HTMLVideoElement&&n.poster?Lp(n,e):Promise.resolve(n.cloneNode(!1))})}const Up=n=>n.tagName!=null&&n.tagName.toUpperCase()==="SLOT";function Dp(n,e,t){var r;return Sn(this,void 0,void 0,function*(){const i=Up(n)&&n.assignedNodes?Vt(n.assignedNodes()):Vt(((r=n.shadowRoot)!==null&&r!==void 0?r:n).childNodes);return i.length===0||n instanceof HTMLVideoElement?Promise.resolve(e):i.reduce((s,o)=>s.then(()=>qd(o,t)).then(c=>{c&&e.appendChild(c)}),Promise.resolve()).then(()=>e)})}function xp(n,e){const t=window.getComputedStyle(n),r=e.style;!r||(t.cssText?r.cssText=t.cssText:Vt(t).forEach(i=>{r.setProperty(i,t.getPropertyValue(i),t.getPropertyPriority(i))}))}function Bp(n,e){n instanceof HTMLTextAreaElement&&(e.innerHTML=n.value),n instanceof HTMLInputElement&&e.setAttribute("value",n.value)}function Vp(n,e){return Sn(this,void 0,void 0,function*(){return e instanceof Element?Promise.resolve().then(()=>xp(n,e)).then(()=>Mp(n,e)).then(()=>Bp(n,e)).then(()=>e):Promise.resolve(e)})}function qd(n,e,t){return Sn(this,void 0,void 0,function*(){return!t&&e.filter&&!e.filter(n)?Promise.resolve(null):Promise.resolve(n).then(r=>kp(r,e)).then(r=>Dp(n,r,e)).then(r=>Vp(n,r))})}var Fp=globalThis&&globalThis.__awaiter||function(n,e,t,r){function i(s){return s instanceof t?s:new t(function(o){o(s)})}return new(t||(t=Promise))(function(s,o){function c(h){try{l(r.next(h))}catch(a){o(a)}}function d(h){try{l(r.throw(h))}catch(a){o(a)}}function l(h){h.done?s(h.value):i(h.value).then(c,d)}l((r=r.apply(n,e||[])).next())})};const Gd=/url\((['"]?)([^'"]+?)\1\)/g,Hp=/url\([^)]+\)\s*format\((["'])([^"']+)\1\)/g,$p=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function jp(n){const e=n.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return new RegExp(`(url\\(['"]?)(${e})(['"]?\\))`,"g")}function Kp(n){const e=[];return n.replace(Gd,(t,r,i)=>(e.push(i),t)),e.filter(t=>!no(t))}function qp(n,e,t,r,i){const s=t?yp(e,t):e;return Promise.resolve(s).then(o=>i?i(o):_a(o,r)).then(o=>typeof o=="string"?pi(o,fi(e)):pi(o.blob,fi(e)||o.contentType)).then(o=>n.replace(jp(e),`$1${o}$3`)).then(o=>o,()=>s)}function Gp(n,{preferredFontFormat:e}){return e?n.replace($p,t=>{for(;;){const[r,,i]=Hp.exec(t)||[];if(!i)return"";if(i===e)return`src: ${r};`}}):n}function Yd(n){return n.search(Gd)!==-1}function Jd(n,e,t){return Fp(this,void 0,void 0,function*(){if(!Yd(n))return Promise.resolve(n);const r=Gp(n,t);return Promise.resolve(r).then(Kp).then(i=>i.reduce((s,o)=>s.then(c=>qp(c,o,e,t)),Promise.resolve(r)))})}var ki=globalThis&&globalThis.__awaiter||function(n,e,t,r){function i(s){return s instanceof t?s:new t(function(o){o(s)})}return new(t||(t=Promise))(function(s,o){function c(h){try{l(r.next(h))}catch(a){o(a)}}function d(h){try{l(r.throw(h))}catch(a){o(a)}}function l(h){h.done?s(h.value):i(h.value).then(c,d)}l((r=r.apply(n,e||[])).next())})};function Yp(n,e){var t;return ki(this,void 0,void 0,function*(){const r=(t=n.style)===null||t===void 0?void 0:t.getPropertyValue("background");return r?Promise.resolve(r).then(i=>Jd(i,null,e)).then(i=>(n.style.setProperty("background",i,n.style.getPropertyPriority("background")),n)):Promise.resolve(n)})}function Jp(n,e){return ki(this,void 0,void 0,function*(){if(!(n instanceof HTMLImageElement&&!no(n.src))&&!(n instanceof SVGImageElement&&!no(n.href.baseVal)))return Promise.resolve(n);const t=n instanceof HTMLImageElement?n.src:n.href.baseVal;return Promise.resolve(t).then(r=>_a(r,e)).then(r=>pi(r.blob,fi(t)||r.contentType)).then(r=>new Promise((i,s)=>{n.onload=i,n.onerror=s,n instanceof HTMLImageElement?(n.srcset="",n.src=r):n.href.baseVal=r})).then(()=>n,()=>n)})}function Wp(n,e){return ki(this,void 0,void 0,function*(){const r=Vt(n.childNodes).map(i=>Wd(i,e));return Promise.all(r).then(()=>n)})}function Wd(n,e){return ki(this,void 0,void 0,function*(){return n instanceof Element?Promise.resolve(n).then(t=>Yp(t,e)).then(t=>Jp(t,e)).then(t=>Wp(t,e)):Promise.resolve(n)})}function zp(n,e){const{style:t}=n;e.backgroundColor&&(t.backgroundColor=e.backgroundColor),e.width&&(t.width=`${e.width}px`),e.height&&(t.height=`${e.height}px`);const r=e.style;return r!=null&&Object.keys(r).forEach(i=>{t[i]=r[i]}),n}var lr=globalThis&&globalThis.__awaiter||function(n,e,t,r){function i(s){return s instanceof t?s:new t(function(o){o(s)})}return new(t||(t=Promise))(function(s,o){function c(h){try{l(r.next(h))}catch(a){o(a)}}function d(h){try{l(r.throw(h))}catch(a){o(a)}}function l(h){h.done?s(h.value):i(h.value).then(c,d)}l((r=r.apply(n,e||[])).next())})};const qc={};function Gc(n){const e=qc[n];if(e!=null)return e;const t=window.fetch(n).then(r=>({url:n,cssText:r.text()}));return qc[n]=t,t}function Yc(n){return lr(this,void 0,void 0,function*(){return n.cssText.then(e=>{let t=e;const r=/url\(["']?([^"')]+)["']?\)/g,s=(t.match(/url\([^)]+\)/g)||[]).map(o=>{let c=o.replace(r,"$1");return c.startsWith("https://")||(c=new URL(c,n.url).href),window.fetch(c).then(d=>d.blob()).then(d=>new Promise((l,h)=>{const a=new FileReader;a.onloadend=()=>{t=t.replace(o,`url(${a.result})`),l([o,a.result])},a.onerror=h,a.readAsDataURL(d)}))});return Promise.all(s).then(()=>t)})})}function Jc(n){if(n==null)return[];const e=[],t=/(\/\*[\s\S]*?\*\/)/gi;let r=n.replace(t,"");const i=new RegExp("((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})","gi");for(;;){const d=i.exec(r);if(d===null)break;e.push(d[0])}r=r.replace(i,"");const s=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,o="((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})",c=new RegExp(o,"gi");for(;;){let d=s.exec(r);if(d===null){if(d=c.exec(r),d===null)break;s.lastIndex=c.lastIndex}else c.lastIndex=s.lastIndex;e.push(d[0])}return e}function Qp(n){return lr(this,void 0,void 0,function*(){const e=[],t=[];return n.forEach(r=>{if("cssRules"in r)try{Vt(r.cssRules).forEach((i,s)=>{if(i.type===CSSRule.IMPORT_RULE){let o=s+1;const c=i.href,d=Gc(c).then(l=>l?Yc(l):"").then(l=>Jc(l).forEach(h=>{try{r.insertRule(h,h.startsWith("@import")?o+=1:r.cssRules.length)}catch(a){console.error("Error inserting rule from remote css",{rule:h,error:a})}})).catch(l=>{console.error("Error loading remote css",l.toString())});t.push(d)}})}catch(i){const s=n.find(o=>o.href==null)||document.styleSheets[0];r.href!=null&&t.push(Gc(r.href).then(o=>o?Yc(o):"").then(o=>Jc(o).forEach(c=>{s.insertRule(c,r.cssRules.length)})).catch(o=>{console.error("Error loading remote stylesheet",o.toString())})),console.error("Error inlining remote css file",i.toString())}}),Promise.all(t).then(()=>(n.forEach(r=>{if("cssRules"in r)try{Vt(r.cssRules).forEach(i=>{e.push(i)})}catch(i){console.error(`Error while reading CSS rules from ${r.href}`,i.toString())}}),e))})}function Xp(n){return n.filter(e=>e.type===CSSRule.FONT_FACE_RULE).filter(e=>Yd(e.style.getPropertyValue("src")))}function Zp(n){return lr(this,void 0,void 0,function*(){return new Promise((e,t)=>{n.ownerDocument==null&&t(new Error("Provided element is not within a Document")),e(Vt(n.ownerDocument.styleSheets))}).then(e=>Qp(e)).then(Xp)})}function eg(n,e){return lr(this,void 0,void 0,function*(){return Zp(n).then(t=>Promise.all(t.map(r=>{const i=r.parentStyleSheet?r.parentStyleSheet.href:null;return Jd(r.cssText,i,e)}))).then(t=>t.join(`
  902. `))})}function tg(n,e){return lr(this,void 0,void 0,function*(){return(e.fontEmbedCSS!=null?Promise.resolve(e.fontEmbedCSS):eg(n,e)).then(t=>{const r=document.createElement("style"),i=document.createTextNode(t);return r.appendChild(i),n.firstChild?n.insertBefore(r,n.firstChild):n.appendChild(r),n})})}var va=globalThis&&globalThis.__awaiter||function(n,e,t,r){function i(s){return s instanceof t?s:new t(function(o){o(s)})}return new(t||(t=Promise))(function(s,o){function c(h){try{l(r.next(h))}catch(a){o(a)}}function d(h){try{l(r.throw(h))}catch(a){o(a)}}function l(h){h.done?s(h.value):i(h.value).then(c,d)}l((r=r.apply(n,e||[])).next())})};function zd(n,e={}){const t=e.width||Rp(n),r=e.height||Tp(n);return{width:t,height:r}}function ng(n,e={}){return va(this,void 0,void 0,function*(){const{width:t,height:r}=zd(n,e);return Promise.resolve(n).then(i=>qd(i,e,!0)).then(i=>tg(i,e)).then(i=>Wd(i,e)).then(i=>zp(i,e)).then(i=>bp(i,t,r))})}const Qe=16384;function rg(n){(n.width>Qe||n.height>Qe)&&(n.width>Qe&&n.height>Qe?n.width>n.height?(n.height*=Qe/n.width,n.width=Qe):(n.width*=Qe/n.height,n.height=Qe):n.width>Qe?(n.height*=Qe/n.width,n.width=Qe):(n.width*=Qe/n.height,n.height=Qe))}function ig(n,e={}){return va(this,void 0,void 0,function*(){return ng(n,e).then(ma).then(t=>{const r=document.createElement("canvas"),i=r.getContext("2d"),s=e.pixelRatio||Sp(),{width:o,height:c}=zd(n,e),d=e.canvasWidth||o,l=e.canvasHeight||c;return r.width=d*s,r.height=l*s,e.skipAutoScale||rg(r),r.style.width=`${d}`,r.style.height=`${l}`,e.backgroundColor&&(i.fillStyle=e.backgroundColor,i.fillRect(0,0,r.width,r.height)),i.drawImage(t,0,0,r.width,r.height),r})})}function sg(n,e={}){return va(this,void 0,void 0,function*(){return ig(n,e).then(t=>t.toDataURL())})}var og=function(){var n=document.getSelection();if(!n.rangeCount)return function(){};for(var e=document.activeElement,t=[],r=0;r<n.rangeCount;r++)t.push(n.getRangeAt(r));switch(e.tagName.toUpperCase()){case"INPUT":case"TEXTAREA":e.blur();break;default:e=null;break}return n.removeAllRanges(),function(){n.type==="Caret"&&n.removeAllRanges(),n.rangeCount||t.forEach(function(i){n.addRange(i)}),e&&e.focus()}},ag=og,Wc={"text/plain":"Text","text/html":"Url",default:"Text"},cg="Copy to clipboard: #{key}, Enter";function ug(n){var e=(/mac os x/i.test(navigator.userAgent)?"\u2318":"Ctrl")+"+C";return n.replace(/#{\s*key\s*}/g,e)}function dg(n,e){var t,r,i,s,o,c,d=!1;e||(e={}),t=e.debug||!1;try{i=ag(),s=document.createRange(),o=document.getSelection(),c=document.createElement("span"),c.textContent=n,c.style.all="unset",c.style.position="fixed",c.style.top=0,c.style.clip="rect(0, 0, 0, 0)",c.style.whiteSpace="pre",c.style.webkitUserSelect="text",c.style.MozUserSelect="text",c.style.msUserSelect="text",c.style.userSelect="text",c.addEventListener("copy",function(h){if(h.stopPropagation(),e.format)if(h.preventDefault(),typeof h.clipboardData=="undefined"){t&&console.warn("unable to use e.clipboardData"),t&&console.warn("trying IE specific stuff"),window.clipboardData.clearData();var a=Wc[e.format]||Wc.default;window.clipboardData.setData(a,n)}else h.clipboardData.clearData(),h.clipboardData.setData(e.format,n);e.onCopy&&(h.preventDefault(),e.onCopy(h.clipboardData))}),document.body.appendChild(c),s.selectNodeContents(c),o.addRange(s);var l=document.execCommand("copy");if(!l)throw new Error("copy command was unsuccessful");d=!0}catch(h){t&&console.error("unable to copy using execCommand: ",h),t&&console.warn("trying IE specific stuff");try{window.clipboardData.setData(e.format||"text",n),e.onCopy&&e.onCopy(window.clipboardData),d=!0}catch(a){t&&console.error("unable to copy using clipboardData: ",a),t&&console.error("falling back to prompt"),r=ug("message"in e?e.message:cg),window.prompt(r,n)}}finally{o&&(typeof o.removeRange=="function"?o.removeRange(s):o.removeAllRanges()),c&&document.body.removeChild(c),i()}return d}var lg=dg,hg=lg;const fg="_shareWrap_ap100_1",pg="_chioseBox_ap100_5",gg="_cell_ap100_17",mg="_dotle_ap100_27",_g="_teamInfo_ap100_38",vg="_title_ap100_42",yg="_subInfo_ap100_47",Cg="_tableWrap_ap100_51";var wt={shareWrap:fg,chioseBox:pg,cell:gg,dotle:mg,teamInfo:_g,title:vg,subInfo:yg,tableWrap:Cg};function Eg(n){return typeof n=="function"||Object.prototype.toString.call(n)==="[object Object]"&&!uu(n)}var Rg=Be({name:"LiveBroadcastGroupChat",data(){return{searchForm:{search:""},checkList:[],tableList:[]}},async mounted(){this.getList()},beforeUnmount(){},methods:{onReSet(){this.searchForm.search="",this.checkList=[],this.search()},search(){this.getList()},async getList(){try{const n=await Jt("/api-web/imGroup/queryGroupList",{params:it({},this.searchForm)});this.tableList=n.data}catch(n){console.log(n)}},resectCheck(n){const e=n;this.checkList.indexOf(e)==-1?this.checkList.push(e):this.checkList.splice(this.checkList.indexOf(e),1)}},render(){let n;return I("div",null,[I(au,{model:this.searchForm,ref:"form",inline:!0,class:wt.form},{default:()=>[I(Rs,null,{default:()=>[I(cu,{clearable:!0,placeholder:"\u7FA4\u804A\u540D\u79F0/\u4E50\u56E2\u7F16\u53F7",modelValue:this.searchForm.search,onInput:e=>this.searchForm.search=e},null)]}),I(Rs,null,{default:()=>[I(ht,{type:"primary",onClick:this.search},{default:()=>[z("\u641C\u7D22")]}),I(ht,{type:"danger",onClick:this.onReSet},{default:()=>[z("\u91CD\u7F6E")]})]})]}),I("div",{class:wt.tableWrap},[I(Cl,{modelValue:this.checkList},Eg(n=this.tableList.map(e=>I("div",{class:wt.cell,onClick:()=>this.resectCheck(e.id)},[I(El,{class:wt.chioseBox,label:e.id,onChange:()=>this.resectCheck(e.id)},{default:()=>[I("br",null,null)]}),I("div",{class:wt.dotle},[e.type=="MUSIC"?"\u4E50\u56E2":"VIP"]),I("div",{class:wt.teamInfo},[I("p",{class:wt.title},[e.name]),I("p",{class:wt.subInfo},[e.memo,z("\uFF08\u5171"),e.memberNum,z("\u4EBA\uFF09")])])])))?n:{default:()=>[n]})])])}});const Tg="_third_z0wkr_1",Sg="_preCore_z0wkr_15",Ig="_title_z0wkr_15",bg="_second_z0wkr_18",wg="_first_z0wkr_35",Ng="_icon_z0wkr_49",Og="_teacher_z0wkr_56",Ag="_start_z0wkr_73",Mg="_time_z0wkr_92",Pg="_content_z0wkr_101",Lg="_pre_z0wkr_15",kg="_end_z0wkr_121",Ug="_bottom_z0wkr_128",Dg="_logo_z0wkr_134",xg="_code_z0wkr_138";var se={third:Tg,preCore:Sg,title:Ig,second:bg,first:wg,icon:Ng,teacher:Og,start:Ag,time:Mg,content:Pg,pre:Lg,end:kg,bottom:Ug,logo:Dg,code:xg},hr={},Bg=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then},Qd={},rt={};let ya;const Vg=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];rt.getSymbolSize=function(e){if(!e)throw new Error('"version" cannot be null or undefined');if(e<1||e>40)throw new Error('"version" should be in range from 1 to 40');return e*4+17};rt.getSymbolTotalCodewords=function(e){return Vg[e]};rt.getBCHDigit=function(n){let e=0;for(;n!==0;)e++,n>>>=1;return e};rt.setToSJISFunction=function(e){if(typeof e!="function")throw new Error('"toSJISFunc" is not a valid function.');ya=e};rt.isKanjiModeEnabled=function(){return typeof ya!="undefined"};rt.toSJIS=function(e){return ya(e)};var Ui={};(function(n){n.L={bit:1},n.M={bit:0},n.Q={bit:3},n.H={bit:2};function e(t){if(typeof t!="string")throw new Error("Param is not a string");switch(t.toLowerCase()){case"l":case"low":return n.L;case"m":case"medium":return n.M;case"q":case"quartile":return n.Q;case"h":case"high":return n.H;default:throw new Error("Unknown EC Level: "+t)}}n.isValid=function(r){return r&&typeof r.bit!="undefined"&&r.bit>=0&&r.bit<4},n.from=function(r,i){if(n.isValid(r))return r;try{return e(r)}catch{return i}}})(Ui);function Xd(){this.buffer=[],this.length=0}Xd.prototype={get:function(n){const e=Math.floor(n/8);return(this.buffer[e]>>>7-n%8&1)===1},put:function(n,e){for(let t=0;t<e;t++)this.putBit((n>>>e-t-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(n){const e=Math.floor(this.length/8);this.buffer.length<=e&&this.buffer.push(0),n&&(this.buffer[e]|=128>>>this.length%8),this.length++}};var Fg=Xd;function fr(n){if(!n||n<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=n,this.data=new Uint8Array(n*n),this.reservedBit=new Uint8Array(n*n)}fr.prototype.set=function(n,e,t,r){const i=n*this.size+e;this.data[i]=t,r&&(this.reservedBit[i]=!0)};fr.prototype.get=function(n,e){return this.data[n*this.size+e]};fr.prototype.xor=function(n,e,t){this.data[n*this.size+e]^=t};fr.prototype.isReserved=function(n,e){return this.reservedBit[n*this.size+e]};var Hg=fr,Zd={};(function(n){const e=rt.getSymbolSize;n.getRowColCoords=function(r){if(r===1)return[];const i=Math.floor(r/7)+2,s=e(r),o=s===145?26:Math.ceil((s-13)/(2*i-2))*2,c=[s-7];for(let d=1;d<i-1;d++)c[d]=c[d-1]-o;return c.push(6),c.reverse()},n.getPositions=function(r){const i=[],s=n.getRowColCoords(r),o=s.length;for(let c=0;c<o;c++)for(let d=0;d<o;d++)c===0&&d===0||c===0&&d===o-1||c===o-1&&d===0||i.push([s[c],s[d]]);return i}})(Zd);var el={};const $g=rt.getSymbolSize,zc=7;el.getPositions=function(e){const t=$g(e);return[[0,0],[t-zc,0],[0,t-zc]]};var tl={};(function(n){n.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const e={N1:3,N2:3,N3:40,N4:10};n.isValid=function(i){return i!=null&&i!==""&&!isNaN(i)&&i>=0&&i<=7},n.from=function(i){return n.isValid(i)?parseInt(i,10):void 0},n.getPenaltyN1=function(i){const s=i.size;let o=0,c=0,d=0,l=null,h=null;for(let a=0;a<s;a++){c=d=0,l=h=null;for(let u=0;u<s;u++){let f=i.get(a,u);f===l?c++:(c>=5&&(o+=e.N1+(c-5)),l=f,c=1),f=i.get(u,a),f===h?d++:(d>=5&&(o+=e.N1+(d-5)),h=f,d=1)}c>=5&&(o+=e.N1+(c-5)),d>=5&&(o+=e.N1+(d-5))}return o},n.getPenaltyN2=function(i){const s=i.size;let o=0;for(let c=0;c<s-1;c++)for(let d=0;d<s-1;d++){const l=i.get(c,d)+i.get(c,d+1)+i.get(c+1,d)+i.get(c+1,d+1);(l===4||l===0)&&o++}return o*e.N2},n.getPenaltyN3=function(i){const s=i.size;let o=0,c=0,d=0;for(let l=0;l<s;l++){c=d=0;for(let h=0;h<s;h++)c=c<<1&2047|i.get(l,h),h>=10&&(c===1488||c===93)&&o++,d=d<<1&2047|i.get(h,l),h>=10&&(d===1488||d===93)&&o++}return o*e.N3},n.getPenaltyN4=function(i){let s=0;const o=i.data.length;for(let d=0;d<o;d++)s+=i.data[d];return Math.abs(Math.ceil(s*100/o/5)-10)*e.N4};function t(r,i,s){switch(r){case n.Patterns.PATTERN000:return(i+s)%2===0;case n.Patterns.PATTERN001:return i%2===0;case n.Patterns.PATTERN010:return s%3===0;case n.Patterns.PATTERN011:return(i+s)%3===0;case n.Patterns.PATTERN100:return(Math.floor(i/2)+Math.floor(s/3))%2===0;case n.Patterns.PATTERN101:return i*s%2+i*s%3===0;case n.Patterns.PATTERN110:return(i*s%2+i*s%3)%2===0;case n.Patterns.PATTERN111:return(i*s%3+(i+s)%2)%2===0;default:throw new Error("bad maskPattern:"+r)}}n.applyMask=function(i,s){const o=s.size;for(let c=0;c<o;c++)for(let d=0;d<o;d++)s.isReserved(d,c)||s.xor(d,c,t(i,d,c))},n.getBestMask=function(i,s){const o=Object.keys(n.Patterns).length;let c=0,d=1/0;for(let l=0;l<o;l++){s(l),n.applyMask(l,i);const h=n.getPenaltyN1(i)+n.getPenaltyN2(i)+n.getPenaltyN3(i)+n.getPenaltyN4(i);n.applyMask(l,i),h<d&&(d=h,c=l)}return c}})(tl);var Di={};const Ut=Ui,Pr=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],Lr=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];Di.getBlocksCount=function(e,t){switch(t){case Ut.L:return Pr[(e-1)*4+0];case Ut.M:return Pr[(e-1)*4+1];case Ut.Q:return Pr[(e-1)*4+2];case Ut.H:return Pr[(e-1)*4+3];default:return}};Di.getTotalCodewordsCount=function(e,t){switch(t){case Ut.L:return Lr[(e-1)*4+0];case Ut.M:return Lr[(e-1)*4+1];case Ut.Q:return Lr[(e-1)*4+2];case Ut.H:return Lr[(e-1)*4+3];default:return}};var nl={},xi={};const qn=new Uint8Array(512),mi=new Uint8Array(256);(function(){let e=1;for(let t=0;t<255;t++)qn[t]=e,mi[e]=t,e<<=1,e&256&&(e^=285);for(let t=255;t<512;t++)qn[t]=qn[t-255]})();xi.log=function(e){if(e<1)throw new Error("log("+e+")");return mi[e]};xi.exp=function(e){return qn[e]};xi.mul=function(e,t){return e===0||t===0?0:qn[mi[e]+mi[t]]};(function(n){const e=xi;n.mul=function(r,i){const s=new Uint8Array(r.length+i.length-1);for(let o=0;o<r.length;o++)for(let c=0;c<i.length;c++)s[o+c]^=e.mul(r[o],i[c]);return s},n.mod=function(r,i){let s=new Uint8Array(r);for(;s.length-i.length>=0;){const o=s[0];for(let d=0;d<i.length;d++)s[d]^=e.mul(i[d],o);let c=0;for(;c<s.length&&s[c]===0;)c++;s=s.slice(c)}return s},n.generateECPolynomial=function(r){let i=new Uint8Array([1]);for(let s=0;s<r;s++)i=n.mul(i,new Uint8Array([1,e.exp(s)]));return i}})(nl);const rl=nl;function Ca(n){this.genPoly=void 0,this.degree=n,this.degree&&this.initialize(this.degree)}Ca.prototype.initialize=function(e){this.degree=e,this.genPoly=rl.generateECPolynomial(this.degree)};Ca.prototype.encode=function(e){if(!this.genPoly)throw new Error("Encoder not initialized");const t=new Uint8Array(e.length+this.degree);t.set(e);const r=rl.mod(t,this.genPoly),i=this.degree-r.length;if(i>0){const s=new Uint8Array(this.degree);return s.set(r,i),s}return r};var jg=Ca,il={},Ft={},Ea={};Ea.isValid=function(e){return!isNaN(e)&&e>=1&&e<=40};var mt={};const sl="[0-9]+",Kg="[A-Z $%*+\\-./:]+";let rr="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";rr=rr.replace(/u/g,"\\u");const qg="(?:(?![A-Z0-9 $%*+\\-./:]|"+rr+`)(?:.|[\r
  903. ]))+`;mt.KANJI=new RegExp(rr,"g");mt.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g");mt.BYTE=new RegExp(qg,"g");mt.NUMERIC=new RegExp(sl,"g");mt.ALPHANUMERIC=new RegExp(Kg,"g");const Gg=new RegExp("^"+rr+"$"),Yg=new RegExp("^"+sl+"$"),Jg=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");mt.testKanji=function(e){return Gg.test(e)};mt.testNumeric=function(e){return Yg.test(e)};mt.testAlphanumeric=function(e){return Jg.test(e)};(function(n){const e=Ea,t=mt;n.NUMERIC={id:"Numeric",bit:1<<0,ccBits:[10,12,14]},n.ALPHANUMERIC={id:"Alphanumeric",bit:1<<1,ccBits:[9,11,13]},n.BYTE={id:"Byte",bit:1<<2,ccBits:[8,16,16]},n.KANJI={id:"Kanji",bit:1<<3,ccBits:[8,10,12]},n.MIXED={bit:-1},n.getCharCountIndicator=function(s,o){if(!s.ccBits)throw new Error("Invalid mode: "+s);if(!e.isValid(o))throw new Error("Invalid version: "+o);return o>=1&&o<10?s.ccBits[0]:o<27?s.ccBits[1]:s.ccBits[2]},n.getBestModeForData=function(s){return t.testNumeric(s)?n.NUMERIC:t.testAlphanumeric(s)?n.ALPHANUMERIC:t.testKanji(s)?n.KANJI:n.BYTE},n.toString=function(s){if(s&&s.id)return s.id;throw new Error("Invalid mode")},n.isValid=function(s){return s&&s.bit&&s.ccBits};function r(i){if(typeof i!="string")throw new Error("Param is not a string");switch(i.toLowerCase()){case"numeric":return n.NUMERIC;case"alphanumeric":return n.ALPHANUMERIC;case"kanji":return n.KANJI;case"byte":return n.BYTE;default:throw new Error("Unknown mode: "+i)}}n.from=function(s,o){if(n.isValid(s))return s;try{return r(s)}catch{return o}}})(Ft);(function(n){const e=rt,t=Di,r=Ui,i=Ft,s=Ea,o=1<<12|1<<11|1<<10|1<<9|1<<8|1<<5|1<<2|1<<0,c=e.getBCHDigit(o);function d(u,f,p){for(let m=1;m<=40;m++)if(f<=n.getCapacity(m,p,u))return m}function l(u,f){return i.getCharCountIndicator(u,f)+4}function h(u,f){let p=0;return u.forEach(function(m){p+=l(m.mode,f)+m.getBitsLength()}),p}function a(u,f){for(let p=1;p<=40;p++)if(h(u,p)<=n.getCapacity(p,f,i.MIXED))return p}n.from=function(f,p){return s.isValid(f)?parseInt(f,10):p},n.getCapacity=function(f,p,m){if(!s.isValid(f))throw new Error("Invalid QR Code version");typeof m=="undefined"&&(m=i.BYTE);const _=e.getSymbolTotalCodewords(f),v=t.getTotalCodewordsCount(f,p),y=(_-v)*8;if(m===i.MIXED)return y;const C=y-l(m,f);switch(m){case i.NUMERIC:return Math.floor(C/10*3);case i.ALPHANUMERIC:return Math.floor(C/11*2);case i.KANJI:return Math.floor(C/13);case i.BYTE:default:return Math.floor(C/8)}},n.getBestVersionForData=function(f,p){let m;const _=r.from(p,r.M);if(Array.isArray(f)){if(f.length>1)return a(f,_);if(f.length===0)return 1;m=f[0]}else m=f;return d(m.mode,m.getLength(),_)},n.getEncodedBits=function(f){if(!s.isValid(f)||f<7)throw new Error("Invalid QR Code version");let p=f<<12;for(;e.getBCHDigit(p)-c>=0;)p^=o<<e.getBCHDigit(p)-c;return f<<12|p}})(il);var ol={};const ro=rt,al=1<<10|1<<8|1<<5|1<<4|1<<2|1<<1|1<<0,Wg=1<<14|1<<12|1<<10|1<<4|1<<1,Qc=ro.getBCHDigit(al);ol.getEncodedBits=function(e,t){const r=e.bit<<3|t;let i=r<<10;for(;ro.getBCHDigit(i)-Qc>=0;)i^=al<<ro.getBCHDigit(i)-Qc;return(r<<10|i)^Wg};var cl={};const zg=Ft;function mn(n){this.mode=zg.NUMERIC,this.data=n.toString()}mn.getBitsLength=function(e){return 10*Math.floor(e/3)+(e%3?e%3*3+1:0)};mn.prototype.getLength=function(){return this.data.length};mn.prototype.getBitsLength=function(){return mn.getBitsLength(this.data.length)};mn.prototype.write=function(e){let t,r,i;for(t=0;t+3<=this.data.length;t+=3)r=this.data.substr(t,3),i=parseInt(r,10),e.put(i,10);const s=this.data.length-t;s>0&&(r=this.data.substr(t),i=parseInt(r,10),e.put(i,s*3+1))};var Qg=mn;const Xg=Ft,cs=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function _n(n){this.mode=Xg.ALPHANUMERIC,this.data=n}_n.getBitsLength=function(e){return 11*Math.floor(e/2)+6*(e%2)};_n.prototype.getLength=function(){return this.data.length};_n.prototype.getBitsLength=function(){return _n.getBitsLength(this.data.length)};_n.prototype.write=function(e){let t;for(t=0;t+2<=this.data.length;t+=2){let r=cs.indexOf(this.data[t])*45;r+=cs.indexOf(this.data[t+1]),e.put(r,11)}this.data.length%2&&e.put(cs.indexOf(this.data[t]),6)};var Zg=_n,em=function(e){for(var t=[],r=e.length,i=0;i<r;i++){var s=e.charCodeAt(i);if(s>=55296&&s<=56319&&r>i+1){var o=e.charCodeAt(i+1);o>=56320&&o<=57343&&(s=(s-55296)*1024+o-56320+65536,i+=1)}if(s<128){t.push(s);continue}if(s<2048){t.push(s>>6|192),t.push(s&63|128);continue}if(s<55296||s>=57344&&s<65536){t.push(s>>12|224),t.push(s>>6&63|128),t.push(s&63|128);continue}if(s>=65536&&s<=1114111){t.push(s>>18|240),t.push(s>>12&63|128),t.push(s>>6&63|128),t.push(s&63|128);continue}t.push(239,191,189)}return new Uint8Array(t).buffer};const tm=em,nm=Ft;function vn(n){this.mode=nm.BYTE,this.data=new Uint8Array(tm(n))}vn.getBitsLength=function(e){return e*8};vn.prototype.getLength=function(){return this.data.length};vn.prototype.getBitsLength=function(){return vn.getBitsLength(this.data.length)};vn.prototype.write=function(n){for(let e=0,t=this.data.length;e<t;e++)n.put(this.data[e],8)};var rm=vn;const im=Ft,sm=rt;function yn(n){this.mode=im.KANJI,this.data=n}yn.getBitsLength=function(e){return e*13};yn.prototype.getLength=function(){return this.data.length};yn.prototype.getBitsLength=function(){return yn.getBitsLength(this.data.length)};yn.prototype.write=function(n){let e;for(e=0;e<this.data.length;e++){let t=sm.toSJIS(this.data[e]);if(t>=33088&&t<=40956)t-=33088;else if(t>=57408&&t<=60351)t-=49472;else throw new Error("Invalid SJIS character: "+this.data[e]+`
  904. Make sure your charset is UTF-8`);t=(t>>>8&255)*192+(t&255),n.put(t,13)}};var om=yn,ul={exports:{}};(function(n){var e={single_source_shortest_paths:function(t,r,i){var s={},o={};o[r]=0;var c=e.PriorityQueue.make();c.push(r,0);for(var d,l,h,a,u,f,p,m,_;!c.empty();){d=c.pop(),l=d.value,a=d.cost,u=t[l]||{};for(h in u)u.hasOwnProperty(h)&&(f=u[h],p=a+f,m=o[h],_=typeof o[h]=="undefined",(_||m>p)&&(o[h]=p,c.push(h,p),s[h]=l))}if(typeof i!="undefined"&&typeof o[i]=="undefined"){var v=["Could not find a path from ",r," to ",i,"."].join("");throw new Error(v)}return s},extract_shortest_path_from_predecessor_list:function(t,r){for(var i=[],s=r;s;)i.push(s),s=t[s];return i.reverse(),i},find_path:function(t,r,i){var s=e.single_source_shortest_paths(t,r,i);return e.extract_shortest_path_from_predecessor_list(s,i)},PriorityQueue:{make:function(t){var r=e.PriorityQueue,i={},s;t=t||{};for(s in r)r.hasOwnProperty(s)&&(i[s]=r[s]);return i.queue=[],i.sorter=t.sorter||r.default_sorter,i},default_sorter:function(t,r){return t.cost-r.cost},push:function(t,r){var i={value:t,cost:r};this.queue.push(i),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};n.exports=e})(ul);(function(n){const e=Ft,t=Qg,r=Zg,i=rm,s=om,o=mt,c=rt,d=ul.exports;function l(v){return unescape(encodeURIComponent(v)).length}function h(v,y,C){const b=[];let O;for(;(O=v.exec(C))!==null;)b.push({data:O[0],index:O.index,mode:y,length:O[0].length});return b}function a(v){const y=h(o.NUMERIC,e.NUMERIC,v),C=h(o.ALPHANUMERIC,e.ALPHANUMERIC,v);let b,O;return c.isKanjiModeEnabled()?(b=h(o.BYTE,e.BYTE,v),O=h(o.KANJI,e.KANJI,v)):(b=h(o.BYTE_KANJI,e.BYTE,v),O=[]),y.concat(C,b,O).sort(function(E,w){return E.index-w.index}).map(function(E){return{data:E.data,mode:E.mode,length:E.length}})}function u(v,y){switch(y){case e.NUMERIC:return t.getBitsLength(v);case e.ALPHANUMERIC:return r.getBitsLength(v);case e.KANJI:return s.getBitsLength(v);case e.BYTE:return i.getBitsLength(v)}}function f(v){return v.reduce(function(y,C){const b=y.length-1>=0?y[y.length-1]:null;return b&&b.mode===C.mode?(y[y.length-1].data+=C.data,y):(y.push(C),y)},[])}function p(v){const y=[];for(let C=0;C<v.length;C++){const b=v[C];switch(b.mode){case e.NUMERIC:y.push([b,{data:b.data,mode:e.ALPHANUMERIC,length:b.length},{data:b.data,mode:e.BYTE,length:b.length}]);break;case e.ALPHANUMERIC:y.push([b,{data:b.data,mode:e.BYTE,length:b.length}]);break;case e.KANJI:y.push([b,{data:b.data,mode:e.BYTE,length:l(b.data)}]);break;case e.BYTE:y.push([{data:b.data,mode:e.BYTE,length:l(b.data)}])}}return y}function m(v,y){const C={},b={start:{}};let O=["start"];for(let S=0;S<v.length;S++){const E=v[S],w=[];for(let V=0;V<E.length;V++){const j=E[V],R=""+S+V;w.push(R),C[R]={node:j,lastCount:0},b[R]={};for(let T=0;T<O.length;T++){const A=O[T];C[A]&&C[A].node.mode===j.mode?(b[A][R]=u(C[A].lastCount+j.length,j.mode)-u(C[A].lastCount,j.mode),C[A].lastCount+=j.length):(C[A]&&(C[A].lastCount=j.length),b[A][R]=u(j.length,j.mode)+4+e.getCharCountIndicator(j.mode,y))}}O=w}for(let S=0;S<O.length;S++)b[O[S]].end=0;return{map:b,table:C}}function _(v,y){let C;const b=e.getBestModeForData(v);if(C=e.from(y,b),C!==e.BYTE&&C.bit<b.bit)throw new Error('"'+v+'" cannot be encoded with mode '+e.toString(C)+`.
  905. Suggested mode is: `+e.toString(b));switch(C===e.KANJI&&!c.isKanjiModeEnabled()&&(C=e.BYTE),C){case e.NUMERIC:return new t(v);case e.ALPHANUMERIC:return new r(v);case e.KANJI:return new s(v);case e.BYTE:return new i(v)}}n.fromArray=function(y){return y.reduce(function(C,b){return typeof b=="string"?C.push(_(b,null)):b.data&&C.push(_(b.data,b.mode)),C},[])},n.fromString=function(y,C){const b=a(y,c.isKanjiModeEnabled()),O=p(b),S=m(O,C),E=d.find_path(S.map,"start","end"),w=[];for(let V=1;V<E.length-1;V++)w.push(S.table[E[V]].node);return n.fromArray(f(w))},n.rawSplit=function(y){return n.fromArray(a(y,c.isKanjiModeEnabled()))}})(cl);const Bi=rt,us=Ui,am=Fg,cm=Hg,um=Zd,dm=el,io=tl,so=Di,lm=jg,_i=il,hm=ol,fm=Ft,ds=cl;function pm(n,e){const t=n.size,r=dm.getPositions(e);for(let i=0;i<r.length;i++){const s=r[i][0],o=r[i][1];for(let c=-1;c<=7;c++)if(!(s+c<=-1||t<=s+c))for(let d=-1;d<=7;d++)o+d<=-1||t<=o+d||(c>=0&&c<=6&&(d===0||d===6)||d>=0&&d<=6&&(c===0||c===6)||c>=2&&c<=4&&d>=2&&d<=4?n.set(s+c,o+d,!0,!0):n.set(s+c,o+d,!1,!0))}}function gm(n){const e=n.size;for(let t=8;t<e-8;t++){const r=t%2===0;n.set(t,6,r,!0),n.set(6,t,r,!0)}}function mm(n,e){const t=um.getPositions(e);for(let r=0;r<t.length;r++){const i=t[r][0],s=t[r][1];for(let o=-2;o<=2;o++)for(let c=-2;c<=2;c++)o===-2||o===2||c===-2||c===2||o===0&&c===0?n.set(i+o,s+c,!0,!0):n.set(i+o,s+c,!1,!0)}}function _m(n,e){const t=n.size,r=_i.getEncodedBits(e);let i,s,o;for(let c=0;c<18;c++)i=Math.floor(c/3),s=c%3+t-8-3,o=(r>>c&1)===1,n.set(i,s,o,!0),n.set(s,i,o,!0)}function ls(n,e,t){const r=n.size,i=hm.getEncodedBits(e,t);let s,o;for(s=0;s<15;s++)o=(i>>s&1)===1,s<6?n.set(s,8,o,!0):s<8?n.set(s+1,8,o,!0):n.set(r-15+s,8,o,!0),s<8?n.set(8,r-s-1,o,!0):s<9?n.set(8,15-s-1+1,o,!0):n.set(8,15-s-1,o,!0);n.set(r-8,8,1,!0)}function vm(n,e){const t=n.size;let r=-1,i=t-1,s=7,o=0;for(let c=t-1;c>0;c-=2)for(c===6&&c--;;){for(let d=0;d<2;d++)if(!n.isReserved(i,c-d)){let l=!1;o<e.length&&(l=(e[o]>>>s&1)===1),n.set(i,c-d,l),s--,s===-1&&(o++,s=7)}if(i+=r,i<0||t<=i){i-=r,r=-r;break}}}function ym(n,e,t){const r=new am;t.forEach(function(d){r.put(d.mode.bit,4),r.put(d.getLength(),fm.getCharCountIndicator(d.mode,n)),d.write(r)});const i=Bi.getSymbolTotalCodewords(n),s=so.getTotalCodewordsCount(n,e),o=(i-s)*8;for(r.getLengthInBits()+4<=o&&r.put(0,4);r.getLengthInBits()%8!==0;)r.putBit(0);const c=(o-r.getLengthInBits())/8;for(let d=0;d<c;d++)r.put(d%2?17:236,8);return Cm(r,n,e)}function Cm(n,e,t){const r=Bi.getSymbolTotalCodewords(e),i=so.getTotalCodewordsCount(e,t),s=r-i,o=so.getBlocksCount(e,t),c=r%o,d=o-c,l=Math.floor(r/o),h=Math.floor(s/o),a=h+1,u=l-h,f=new lm(u);let p=0;const m=new Array(o),_=new Array(o);let v=0;const y=new Uint8Array(n.buffer);for(let E=0;E<o;E++){const w=E<d?h:a;m[E]=y.slice(p,p+w),_[E]=f.encode(m[E]),p+=w,v=Math.max(v,w)}const C=new Uint8Array(r);let b=0,O,S;for(O=0;O<v;O++)for(S=0;S<o;S++)O<m[S].length&&(C[b++]=m[S][O]);for(O=0;O<u;O++)for(S=0;S<o;S++)C[b++]=_[S][O];return C}function Em(n,e,t,r){let i;if(Array.isArray(n))i=ds.fromArray(n);else if(typeof n=="string"){let l=e;if(!l){const h=ds.rawSplit(n);l=_i.getBestVersionForData(h,t)}i=ds.fromString(n,l||40)}else throw new Error("Invalid data");const s=_i.getBestVersionForData(i,t);if(!s)throw new Error("The amount of data is too big to be stored in a QR Code");if(!e)e=s;else if(e<s)throw new Error(`
  906. The chosen QR Code version cannot contain this amount of data.
  907. Minimum version required to store current data is: `+s+`.
  908. `);const o=ym(e,t,i),c=Bi.getSymbolSize(e),d=new cm(c);return pm(d,e),gm(d),mm(d,e),ls(d,t,0),e>=7&&_m(d,e),vm(d,o),isNaN(r)&&(r=io.getBestMask(d,ls.bind(null,d,t))),io.applyMask(r,d),ls(d,t,r),{modules:d,version:e,errorCorrectionLevel:t,maskPattern:r,segments:i}}Qd.create=function(e,t){if(typeof e=="undefined"||e==="")throw new Error("No input text");let r=us.M,i,s;return typeof t!="undefined"&&(r=us.from(t.errorCorrectionLevel,us.M),i=_i.from(t.version),s=io.from(t.maskPattern),t.toSJISFunc&&Bi.setToSJISFunction(t.toSJISFunc)),Em(e,i,r,s)};var dl={},Ra={};(function(n){function e(t){if(typeof t=="number"&&(t=t.toString()),typeof t!="string")throw new Error("Color should be defined as hex string");let r=t.slice().replace("#","").split("");if(r.length<3||r.length===5||r.length>8)throw new Error("Invalid hex color: "+t);(r.length===3||r.length===4)&&(r=Array.prototype.concat.apply([],r.map(function(s){return[s,s]}))),r.length===6&&r.push("F","F");const i=parseInt(r.join(""),16);return{r:i>>24&255,g:i>>16&255,b:i>>8&255,a:i&255,hex:"#"+r.slice(0,6).join("")}}n.getOptions=function(r){r||(r={}),r.color||(r.color={});const i=typeof r.margin=="undefined"||r.margin===null||r.margin<0?4:r.margin,s=r.width&&r.width>=21?r.width:void 0,o=r.scale||4;return{width:s,scale:s?4:o,margin:i,color:{dark:e(r.color.dark||"#000000ff"),light:e(r.color.light||"#ffffffff")},type:r.type,rendererOpts:r.rendererOpts||{}}},n.getScale=function(r,i){return i.width&&i.width>=r+i.margin*2?i.width/(r+i.margin*2):i.scale},n.getImageWidth=function(r,i){const s=n.getScale(r,i);return Math.floor((r+i.margin*2)*s)},n.qrToImageData=function(r,i,s){const o=i.modules.size,c=i.modules.data,d=n.getScale(o,s),l=Math.floor((o+s.margin*2)*d),h=s.margin*d,a=[s.color.light,s.color.dark];for(let u=0;u<l;u++)for(let f=0;f<l;f++){let p=(u*l+f)*4,m=s.color.light;if(u>=h&&f>=h&&u<l-h&&f<l-h){const _=Math.floor((u-h)/d),v=Math.floor((f-h)/d);m=a[c[_*o+v]?1:0]}r[p++]=m.r,r[p++]=m.g,r[p++]=m.b,r[p]=m.a}}})(Ra);(function(n){const e=Ra;function t(i,s,o){i.clearRect(0,0,s.width,s.height),s.style||(s.style={}),s.height=o,s.width=o,s.style.height=o+"px",s.style.width=o+"px"}function r(){try{return document.createElement("canvas")}catch{throw new Error("You need to specify a canvas element")}}n.render=function(s,o,c){let d=c,l=o;typeof d=="undefined"&&(!o||!o.getContext)&&(d=o,o=void 0),o||(l=r()),d=e.getOptions(d);const h=e.getImageWidth(s.modules.size,d),a=l.getContext("2d"),u=a.createImageData(h,h);return e.qrToImageData(u.data,s,d),t(a,l,h),a.putImageData(u,0,0),l},n.renderToDataURL=function(s,o,c){let d=c;typeof d=="undefined"&&(!o||!o.getContext)&&(d=o,o=void 0),d||(d={});const l=n.render(s,o,d),h=d.type||"image/png",a=d.rendererOpts||{};return l.toDataURL(h,a.quality)}})(dl);var ll={};const Rm=Ra;function Xc(n,e){const t=n.a/255,r=e+'="'+n.hex+'"';return t<1?r+" "+e+'-opacity="'+t.toFixed(2).slice(1)+'"':r}function hs(n,e,t){let r=n+e;return typeof t!="undefined"&&(r+=" "+t),r}function Tm(n,e,t){let r="",i=0,s=!1,o=0;for(let c=0;c<n.length;c++){const d=Math.floor(c%e),l=Math.floor(c/e);!d&&!s&&(s=!0),n[c]?(o++,c>0&&d>0&&n[c-1]||(r+=s?hs("M",d+t,.5+l+t):hs("m",i,0),i=0,s=!1),d+1<e&&n[c+1]||(r+=hs("h",o),o=0)):i++}return r}ll.render=function(e,t,r){const i=Rm.getOptions(t),s=e.modules.size,o=e.modules.data,c=s+i.margin*2,d=i.color.light.a?"<path "+Xc(i.color.light,"fill")+' d="M0 0h'+c+"v"+c+'H0z"/>':"",l="<path "+Xc(i.color.dark,"stroke")+' d="'+Tm(o,s,i.margin)+'"/>',h='viewBox="0 0 '+c+" "+c+'"',a=i.width?'width="'+i.width+'" height="'+i.width+'" ':"",u='<svg xmlns="http://www.w3.org/2000/svg" '+a+h+' shape-rendering="crispEdges">'+d+l+`</svg>
  909. `;return typeof r=="function"&&r(null,u),u};const Sm=Bg,oo=Qd,hl=dl,Im=ll;function Ta(n,e,t,r,i){const s=[].slice.call(arguments,1),o=s.length,c=typeof s[o-1]=="function";if(!c&&!Sm())throw new Error("Callback required as last argument");if(c){if(o<2)throw new Error("Too few arguments provided");o===2?(i=t,t=e,e=r=void 0):o===3&&(e.getContext&&typeof i=="undefined"?(i=r,r=void 0):(i=r,r=t,t=e,e=void 0))}else{if(o<1)throw new Error("Too few arguments provided");return o===1?(t=e,e=r=void 0):o===2&&!e.getContext&&(r=t,t=e,e=void 0),new Promise(function(d,l){try{const h=oo.create(t,r);d(n(h,e,r))}catch(h){l(h)}})}try{const d=oo.create(t,r);i(null,n(d,e,r))}catch(d){i(d)}}hr.create=oo.create;hr.toCanvas=Ta.bind(null,hl.render);hr.toDataURL=Ta.bind(null,hl.renderToDataURL);hr.toString=Ta.bind(null,function(n,e,t){return Im.render(n,t)});var bm=hr,wm="./assets/icon1.ef6bbd86.png",Nm="./assets/icon2.e7f0fa2e.png",Om="./assets/icon3.0d23bbac.png",fs="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACoAAAAmCAYAAACyAQkgAAAAAXNSR0IArs4c6QAAA7pJREFUWEftmF1oHFUUx8+5k2yhIVILUosSv0AtrYKiSO2DaB9E1EIfUpBiQaxLqybM3hkCfqBBq+JmzrkLiwuNWCOUolBEFFREqgiiVkQUg5FiaWkrwopIoiZNsvfILK2kde98RZ/ceVr2nvOf3/zvOXfuXAQACMOwr9Vq3RT/LnDNGmMOJ+UNDw8PeJ53RQFtUEodI6LjGCdXKpXrEPHbIkIAcJSZr0rK1Vo/AQB7iuiLyNPGmGe6oEvd6zqas5a6NRob1m2mTmXTbaZuM+V0oNtMLsP+F80EAE8x87P/xqZkkpk3/Ie7pxFjzFgbdHBw0BsYGLjQdTMReQgAnneMf87MG5NAy+Xyyv7+/pUJ+u8BgGs/vIuZ97ZB064wDLdaa990xH3AzHemaSSNB0Hwtojc2ylGRLYbYw5kBd1mrX2jkxAiHiSiweWAaq0/BIDNDtAtxph3MoEGQbBTRF52wDAzB8sBDYLgGxG53mHEbUT0SSbQlOXlQWbetxxQrfXPALCmk0ZPT88l1Wr1p6ygBwDgPsfU3JL2cZf0ECMjI5cuLi6ecMT8wswXxWNZQb8HgGs7iFml1AVRFP1R1NEgCLaLyH7HtB8ionbtpoL6vn+lUupHh9BnRHRrUcg4T2sd1/5Oh0aNmSuZQLXWIQCMOYQeZ+YXioLG5wnW2pMAsMphxFYieisVdHR0tGd6evoIAFzuqM8NxpjJoqBa690A0HDk/7awsHBxvV4/nQoahuED1lpXR08x87qikENDQytKpVK8LF3j0HiFmf8uCWeN+r6/Vin1HQCsdgi1X21FQbXWdQB41JWvlNocRdGhs+MdQSuVympEfB8AbnYINUXkMmPMbBHQIAjuF5HXXM2MiB8T0e1Ltf8B6vv+RqVU3InrXRBnP2HzQpbL5d6+vr4xRBx2QYpIy/O8G6MoOucsrA16pvt2AMA9InIXIjpLQkR+AIAb8riptb5aRB5GxG0AsDbpARGxQUSPnB+Tdz+6gIibiOjLPG5m3eEj4hczMzN3jI+P/7lc0CeZ+bk8kGcW9dRjR0Q8Mj8/v6lerzc7rqnxnxnORy0iPkZE1byQGUGnrLV312q1oy79LFM/i4g7iOhgEcgMoPvn5uZ2NxqN3xNrN8HR04j4aqvVerFWqx0rCpkAOqmU2hNF0etZtM93NH5dfQ0AH4nIS8aYU1lE0mKWNNOvIvKp53l7oyh6Nz6sS8s9Z8H3fX9Vb2/v+maz+dXExMRc1uSscb7vryuVSlCtVqfywC3V/ws13CRFlZXvUwAAAABJRU5ErkJggg==",ps="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACoAAAAoCAYAAACIC2hQAAAAAXNSR0IArs4c6QAAA/dJREFUWEftmF9oHUUUxr9zbwgqmJAo/kET6luMKCoo1KAIIv6hoYpESkEIiD7UJu7MXGLUQhatKNe7Z3OTglp9UEECKlJC7YMKFdqCgloQBAsSUR9UEB9iija5mSNzzY2x7uxuNlgQ7jzunPPNb7+ZM7OzhP9JoyKcQRBcXi6Xh0RkO4BPmPmdIjpJOWEYlpaWlgattU77lkajMTUzM/P9pkCDIBgqlUoTAHYAKLmBiOiJKIqqWwUdGxvr6uzs3CsijwO4pKVHRFdHUfR1LtDx8fH+crn8BhHdfjbQVkFHRkbKfX19TwFQAHoS9POBaq13ENHrInJRkmtbAZ2YmLiw0Wi8DeBu34zkclQptQfAASLyOl8UVCl1BYAjRHRd2rLJBDXG3Cci7wIoZwhteo266e7v7z+2VoypyzsVVCl1MxF9DOD8rCIRkbE4jg9kxW3s11o/DWB/jpwz1trB6enphX9N6drbfiEiaVPyB4BYRN6K4/irHAOuh2itb3BbGoDOlLyTRPQMEX1Yq9VON3eXs4O11o+5dZki8g2AB5n55GYAW7HGmHkRGfblishUd3f3/jAM7caYf4BOTk72LC8vO5Bej9BPq6ur19fr9Z8LQg6IiJuB5h6csBU9GUXRC4l9Gx8qpfYS0awHworIPXEcf1AE0uUYY14RkUc9+UeZ+Q4AkgmqtT7hji2P0Bwz7y4KGYbhBYuLi794CtQS0TXuBPLpr099EATbiGghZc/czsyuCAq1SqWy01p7yJM8z8w704TXQY0xRkRqnuDPmPmmQoRrSVrr1wA87NEYZubDeUHnRGSXJ3gfMz+3BVDSWv8I4NIEjdNdXV0Xh2HotjxvW3dUa+2qcTApUkRui+P4WFHQSqVylbV2waP9URzHd2ZpN0FHR0fP6+3t/Q1AR0LC7ysrKz2zs7NnssR8/UqpYSKa9/RPM7P7ckptTdAgCG4slUqfJ0US0akoigayhNL6jTGTIvK8J2YPM7+Upd8E1VrfC+B9T/BxZr41SyitXyn1JhE95DFidxRFc1n6TVCl1C4i8gUfYub7s4QyHD3iDgtPTGbFu7yWo48AOOgROszM3rM5zwtorY8DGPI4+kAURe9l6bQcNUTk20O/I6KXfUKNRuNovV7/NG0grfWXAK71GUFE7kRMbNbag3Ec/9pydApAmPVWHkcyP5y11t8C2FZQ/+87kzHmWRHZV0TI3UprtdqLGcX0AxFdWUS/o6NjoFqtnmo62gZds1Ap1XY093Jqr9E1q9rFlLRm2sWUu5Lcvbe94f9lV7uY/tNi0loHANw/pyKtysyvZnzmuYvhZUXErbV3Jf7NKyJ2LnJy/cM/FyBZY/wJeqwNR6eju2QAAAAASUVORK5CYII=",gs="./assets/logo.6e1120ae.png",ms="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAAB2CAYAAAA+/DbEAAAAAXNSR0IArs4c6QAADDRJREFUeF7tnXtwHXUVx7/f3aRNSqE8hkcRkbZJ7oYGqpSRljJIEWxxHHGqWKkjomJ5yKPFNvemKF4HaO6mD0BsoQgoIFaLDI4ODx9UdAaUl1htm5ublOIUseUhBZomTe7d4+zeNDQ1j737unvvZv9qJ+d3zvl9P/vbu4/f7/yI0SNUCjBU2QSUjLQnDwPeBmvveC+gkLbDRBNI69JPoLIiy5rmZ2wrFZBhNIGkGxeBSg9jqbUB6Ww7TFSBPACii7GWy20rFZBhNIG0JbZApJOa/vGAdLYdJnJApGPJMcgqOwFmka0+kg3JPbbVCsAwekDS8S8C+IWlrWAu6/XfBqCz7RDRA5JJ3AlDrrAUIpYzpt9gW60ADKMHpDXeDqImry3/Qi11ZgA62w4RKSCydUkDFPWfB6hjIGt8iA0rdtpWzGfDaAFpbfweyOQATRVcwTp9nc8623YfLSBtiU0QOXWgOnySWuoC24r5bBgZILIlPhUqNg+iZw9U5QTWNr/ps9a23EcHSCZxOwy5dlBVFGUp65pX2lLMZ6NIAJEdi6vRWfk6wMOH0DNDTY/5rLUt99EAkmn6GgzjvuEV4SeppTbaUs1Ho7IHIpJU0Na9BRBtWB0Fv2e9/ikftbbluvyBZOILYOAhW2qoMpO1LX+1ZeuTUVkDsUZHpmszBPW29COeYEz/tC1bn4zKG0g6fiWAwj5CCeewPvU7n/Qe0W3ZApFNS47BWDUN4IgRVRhokIG691TW3rGvwHaemJcvkNb4/SAucajSd6npNzts66pZWQKRTOM8CH8JgdP+7YNwFutTL7lS10Fjpwk7CBVME2lNnATK3xxcqgYmSHZA6Zwe9FShsgIi25NV6Ol+GiJneINfHkasZT4J8cbfyF7KBojIRSoyk83L1OdG7nYBFsRqxvRvF9DClWn5AGlLrIPIQldqDNmYjdRSK/zxfdCVMoggfsboGxl3QvBNH+MIyBsYSzX7GMNyXdIjRJ5dXI0jx6wHcKHfQvWpdQfWVy9iMmn4Fa9kgciWRA1U+TmA6X6JM7hfeRyqeqlfH7RKEoikG78MKmshcliwMPqjmd9WvuLH6/qSAiIdiRrkcCtEPlMkEAeGNUD8GGpuGWtWvuFVPiUBRFqbjoJiLIFgMYCxXnXeIz/vgrwJh1bdyeOTe936DDUQ66lbkesh+DqAQ9x21tf2xFsA1wC9P2Rs1VtOY4UOiLW6SbrnQWQBRM4FqDrtXJHadQN4DArXo7LqMU5Kmv+3fRQdSP45YtJ0gOdCMBvA2QCqbPcg3IbvgXgKIk9D+Edo+uaRXsMEAkTarxmL3jHHAepEqMpEgJMgRgOABgimghgXbl09yo7YDeEWiLEFxBYAr4LYiV7uxNTqnWSyJyAg5iLLzo/BUE+DyGkAzgJwkkfdLDU35keBbRA+Z0FRjHYYbEd3roPTVnYGAmQwxaxb2KycD2IOROYCDNvdk3egia0QPA5iIwzledY3vz2U86IBOTAh2RafgJwyDzljAYhzASjeqVEkT8TLEHkAovyK9alX7WYRCiAD4LQ21UExroXgqwDG2+1ISOw6QZgT8u5lTN/kJKfQAdnfCdm+6HD0VC+GGNeHH4zsBrAGzN3m5hnE7HtogfSDeWXZsegxbrS+dRAVTs46/9pIDlTWoQrf4UdS73gRJ/RA+sFsXXoaFN4L8KNedNwDHy9A5eWsTb3sga9+FyUDxMxYJFmBTFej+Q+AlV4KYdsXYUBkFfbsvoGn391ru51Nw5IC0j9a0ktnAcoGAMfb7KdXZu+igl9iTepJrxwe7KckgVijxfxt2ZfbAFqvWoI4XscY9QJOXv4PP4OVLBALivlKJjfOnNn+eT9Fsp6sDZ5XyPOE03xKGogFZcNFKqZN9m+SA7ELSuUs1t68zanIhbQreSD9vyv+TAN6H6p6DmuXmzMhAznKB4i1UqrLrGHyBQ+Vm09NN28eAjvKBoh1+dqcHIOKLrOYzDkeKLiOmp6viRLgUVZALChm+aWc+hIEJzjWkdyKMVXTC/3a5zjeAQ3LDkj+7qtpJnLG0wDGFC6SCFSZzdoVfyq8rfsWZQnEgpJOxAFJFS6RPEitxelCn8LDHdSifIGY3+rbJj9X4MzGPehVa3jK8l2ulXXooGyBWKOkLT4NghcA2H3v1UJNjzvU0pNmZQ2k79J1OzBEjZOBEu4BqycxlnQ8p8oLIuUPpL3paBjSYWMe8Epq+lIvRHXjo+yB9F26boTg+8MIZQC5Gmort7sR04u20QDSfs1hyI3bAWCo2fJPUCtuBYf9MCMBJP9bEr8NwHWDn8VyIbWWX3txhrv1ER0g7UunwFDaIBg4V9icJP169UTOTmbdiulF+8gAyY+SxicAzh0gHHkPYyk/1ycWxClaQLbGL4GC+wcopHIOa4tXbOZgWtECkm48FOQuCKotIQTvQKs+hgzH5cpMKVJA+m6BH4FgXt+Z+Qg13cvvJwVdngYzjiCQxEKI5AsnK7ySdam7XKvooYPoAckkJsOQ/Pdxw6jjySvaPdTTtavIAem7bG0DpJKxlhNdK+ixA1+BWPVydwA889Yuj/N25U7yxc3GUdMvcuXIh8b+AtnaOANjK7OccsuLPuTu2KWYm4JBGUstpTt24lNDf4GYRSjJXsZS9/iUvyO3komfDYMVflRicJTQAY38BdKWeACQbsZ0n8omOeu+tfRa6SKn6O868+BfK5+BxHdAsDcsddX9k9E7z74BkbYmDWK0wiyP1y0nclrLa96lXb6efATS2AThcks68lth3FUzjFj9A5KOm3dW+2tZPUVNPy+MAoQtJ1+ASHrZqUDug1WoRA657BSevOpfYRMgbPn4A6QtsQYiVw3sLG+ilroxbAKELR/PgeS3NlVf+b9ySsSbmJCbxONWdoZNhDDl4z2QdKIFkMGn0yhsZF0w5VbDJHIhuXgKpK8wpblx41Dlld5BRU7zsiReIZ0tBVtvgaTj5urUOcN3nA9SSxVtMnPYoXgGRNJxc4qNOdVm5IO4mDHdLPE6ehykgCdApC1+FgR/KKBA5XuoUGexZvlgGz1GGpJrINKxrAHZ3J8dbA/xb4ypmMXJt4w+mxxwCroCIq1LZoLqbwAc5fC0fg05zOVU3Sx3N3q4mXUi6aZvAMYPALf1EmU3RLmM9alHRok4mAYk2+InImtWl+6fSuNeR/ONMPETdOUSnOZdlWj3iQXvwfYlS15dNhHduUUQXO1bFdF81c7VEK4dri5h8DIFF3FYINYkhb2VcyBYAPCzBdxFue1BJ0hzQtt6ZKs2siHZ49ZhqbS3gOTrUPUeC+SOh0gMChtgYAYgMwKEMJRmeyF4FuRzEKvWbQY0/oPYuDfCNAXUK+B5IOZIeL9yGlROh1hVEMzKoEd6FcS1H8L89v0swOch8jIUyYBdrxRr80fX/RnGwaCXrHyFnUnnALwYgvlFKkL5FhT+DDk8is7/PuNH9TY/hXXqe8Qfdas6aG/1ZRBru4hjnQay346boSKFfVUPR+m3Y78+IwLZbyibk+NR2b0EIuY6bj+K5e8EEUed/uBIBevtwy09S9tA+sFYs0nkPkBmetZdhQ+jsnshJ91m1r+N9FEwEOsm4MWFlRh/RAuI61zsN2u6MrcNWsqYvjrSFA7ovCMgH4yWxEJA1v7fQko76poTHwSXUtN/asc8KjaugFijpS0xH2I8VPBOOMTVjOlroiK03X66BmJBaU0shCJ32b58ET8K23xfu4L5becJkDyU+GrQ2kVtpKMVh/RM54fDtWZkpKSD+rt3QMzXL21dZhW2M4dJXqAqs1nbXJRqbUGJ6iaOZ0CsUbKtqQ5Z4+/9y44PzozYwJhuPvmPHkMo4CmQ/I98fKjKOwZU5RTWNm8dpTG0At4D2bTkEIxVOwAcNyCs4FHW6/vXh48yCWqE9I0Sc3fOVQNiKjyfdSlzZsroMYwCno8QC8iL8QkYb66/xaF9sbcjpk+J8jsqu2ehL0D6RsndEPRV2ZEV1Foa7SYVZTv/gHQsm41sbqMlrpKbwbqVZsnW0WMEBfwDki+Ob+4zTsSqjyaTxiiNkRXwDYh12Uo3bgCohK3izsiyFM/CXyBtjVeBrGSdfnvxulhakf0Fkmk6A0a2gtqKZ0pLluJl6y8QczbLrgnk6cm9xetiaUX2FUhpSRGObP8HG0q4pBQy2GYAAAAASUVORK5CYII=",Am=Be({name:"LiveBroadcastSharePreview",props:["form","url"],data(){return{detail:{roomTitle:"",liveStartTime:"",liveRemark:""}}},mounted(){let n=document.getElementById("canvas"),e=this.url;bm.toCanvas(n,e,{width:80},function(t){t&&console.error(t),console.log("QRCode success!")})},methods:{copyText(){},shareImage(){}},render(){return I("div",{id:"preview"},[this.form.preTemplate==="1"?I("div",{class:se.first},[I("h2",null,[this.form.roomTitle]),I("p",{class:se.teacher},[z(" \u4E3B\u8BB2\u4EBA\uFF1A"),this.form.speakerName]),I("img",{src:wm,class:se.icon,alt:""},null),I("div",{class:se.preCore},[I("img",{src:ms,class:se.start,alt:""},null),I("p",{class:se.title},[z("\u5F00\u64AD\u65F6\u95F4")]),I("p",{class:se.time},[this.form.liveStartTime]),I("p",{class:se.title},[z("\u76F4\u64AD\u5185\u5BB9")]),I("div",{class:se.content},[I("img",{class:se.pre,src:ps,alt:""},null),I("img",{class:se.end,src:fs,alt:""},null),this.form.liveRemark])]),I("div",{class:se.bottom},[I("img",{class:se.logo,src:gs,alt:""},null),I("div",{class:se.code},[I("div",null,[I("canvas",{id:"canvas",height:"80",width:"80",style:"width: 80px; margin:0"},null)])])])]):null,this.form.preTemplate==="2"?I("div",{class:se.second},[I("h2",null,[this.form.roomTitle]),I("p",{class:se.teacher},[z("\u4E3B\u8BB2\u4EBA\uFF1A"),this.form.speakerName]),I("img",{src:Nm,class:se.icon,alt:""},null),I("div",{class:se.preCore},[I("img",{src:ms,class:se.start,alt:""},null),I("p",{class:se.title},[z("\u5F00\u64AD\u65F6\u95F4")]),I("p",{class:se.time},[this.form.liveStartTime]),I("p",{class:se.title},[z("\u76F4\u64AD\u5185\u5BB9")]),I("div",{class:se.content},[I("img",{class:se.pre,src:ps,alt:""},null),I("img",{class:se.end,src:fs,alt:""},null),this.form.liveRemark])]),I("div",{class:se.bottom},[I("img",{class:se.logo,src:gs,alt:""},null),I("div",{class:se.code},[I("div",null,[I("canvas",{id:"canvas",height:"80",width:"80",style:"width: 80px; margin:0"},null)])])])]):null,this.form.preTemplate==="3"?I("div",{class:se.third},[I("h2",null,[this.form.roomTitle]),I("p",{class:se.teacher},[z("\u4E3B\u8BB2\u4EBA\uFF1A"),this.form.speakerName]),I("img",{src:Om,class:se.icon,alt:""},null),I("div",{class:se.preCore},[I("img",{src:ms,class:se.start,alt:""},null),I("p",{class:se.title},[z("\u5F00\u64AD\u65F6\u95F4")]),I("p",{class:se.time},[this.form.liveStartTime]),I("p",{class:se.title},[z("\u76F4\u64AD\u5185\u5BB9")]),I("div",{class:se.content},[I("img",{class:se.pre,src:ps,alt:""},null),I("img",{class:se.end,src:fs,alt:""},null),this.form.liveRemark])]),I("div",{class:se.bottom},[I("img",{class:se.logo,src:gs,alt:""},null),I("div",{class:se.code},[I("div",null,[I("canvas",{id:"canvas",height:"80",width:"80",style:"width: 80px; margin:0"},null)])])])]):null])}});const Zc=uo(null);var Mm=Be({name:"LiveBroadcastShare",props:{onClose:{type:Function,default:()=>{}}},data(){return{form:{shareType:"1"},detail:{roomTitle:"",liveStartTime:"",liveRemark:"",roomUid:""},url:""}},async mounted(){let n=JSON.parse(sessionStorage.getItem("details")||"");if(n)this.detail=it({},n);else{const e=sessionStorage.getItem("roomUid"),t=await Jt.get("/api-web/imLiveBroadcastRoom/queryRoom",{params:{roomUid:e}});sessionStorage.setItem("details",t.data),this.detail=it({},t.data)}this.url=mp()+`/#/liveClassTransfer?roomUid=${this.detail.roomUid}`},methods:{copyText(){let n=`\u4E50\u56E2\u8001\u5E08\u9080\u8BF7\u60A8\u53C2\u4E0E\u76F4\u64AD\u8BFE\uFF01
  910. ${this.detail.roomTitle||""}
  911. \u76F4\u64AD\u65F6\u95F4:${this.detail.liveStartTime||""}
  912. \u76F4\u64AD\u5185\u5BB9:${this.detail.liveRemark||""}
  913. \u76F4\u64AD\u5730\u5740:${this.url}
  914. `;n&&(hg(n),Ur.success("\u590D\u5236\u6210\u529F"),this.onClose())},shareImage(){var n=document.getElementById("preview");n&&sg(n).then(e=>{var t=new Image;t.src=e;let r=document.createElement("a"),i=this.detail.roomTitle||"\u5206\u4EAB\u56FE\u7247\u6587\u4EF6.png";r.href=e,r.setAttribute("download",i),document.body.appendChild(r),r.click(),this.onClose()}).catch(function(e){console.error("oops, something went wrong!",e)})},async shareChat(){var e;let n=((e=Zc.value)==null?void 0:e.checkList)||[];if(!(n.length>0)){Ur.error("\u8BF7\u81F3\u5C11\u9009\u62E9\u4E00\u4E2A\u7FA4\u804A");return}try{let t={groupIds:n.join(","),roomUid:this.detail.roomUid};const r=await Jt.get("/api-web/imLiveBroadcastRoom/shareGroup",{params:it({},t)});Ur.success("\u5206\u4EAB\u6210\u529F"),this.onClose()}catch(t){console.log(t)}},changeRafdio(n){this.form.shareType=n}},render(){return I("div",null,[I(au,{model:this.form,ref:"form",class:vt.form},{default:()=>[I(Rs,{label:"\u5206\u4EAB\u65B9\u5F0F"},{default:()=>[I(Hi,{modelValue:this.form.shareType,onChange:()=>{this.changeRafdio("1")},label:"1"},{default:()=>[z("\u94FE\u63A5\u5206\u4EAB")]}),I(Hi,{modelValue:this.form.shareType,onChange:()=>{this.changeRafdio("2")},label:"2"},{default:()=>[z("\u4E8C\u7EF4\u7801\u5206\u4EAB")]}),I(Hi,{modelValue:this.form.shareType,onChange:()=>{this.changeRafdio("3")},label:"3"},{default:()=>[z("\u7FA4\u804A\u5206\u4EAB")]})]})]}),I("div",null,[this.form.shareType==="1"?I("div",{class:"linkWrap"},[I("div",{class:vt.shareWrap},[I("h2",null,[z("\u4E50\u56E2\u8001\u5E08\u9080\u8BF7\u60A8\u53C2\u4E0E\u76F4\u64AD\u8BFE\uFF01")]),I("h4",null,[this.detail.roomTitle]),I("p",null,[z("\u76F4\u64AD\u65F6\u95F4:"),this.detail.liveStartTime]),I("p",null,[z("\u76F4\u64AD\u5185\u5BB9:"),this.detail.liveRemark]),I("p",null,[z("\u76F4\u64AD\u5730\u5740:"),this.url])]),I("div",{class:vt.shareBtn,onClick:this.copyText},[z("\u590D\u5236\u5206\u4EAB\u5185\u5BB9")])]):null]),this.form.shareType==="2"?I("div",{class:vt.codeWrap},[I("div",{class:vt.shareWrap},[I(Am,{form:this.detail,url:this.url},null)]),I("div",{class:vt.shareBtn,onClick:this.shareImage},[z("\u590D\u5236\u5206\u4EAB\u5185\u5BB9")])]):null,this.form.shareType=="3"?I("div",{class:vt.shareWrap},[I("div",{class:vt.groupWrap},[I(Rg,{ref:Zc},null)]),I("div",{class:vt.shareBtn,onClick:this.shareChat},[z("\u53D1\u9001\u5206\u4EAB\u4FE1\u606F")])]):null])}});function eu(n){return typeof n=="function"||Object.prototype.toString.call(n)==="[object Object]"&&!uu(n)}var Pm=Be({name:"LiveBroadcast-ActionBar",data(){return{volume:30,barStatus:{camera:!1,volume:!1,microphone:!1,screen:!1,share:!1},shareVisiable:!1}},computed:{isCameraDisabled(){return this.barStatus.camera&&ne.deviceStatus.camera!=="denied"&&ne.cameras.length},isMicrophoneDisabled(){return this.barStatus.microphone&&ne.deviceStatus.microphone!=="denied"&&ne.microphones.length},isVolumeDisabled(){return this.barStatus.volume&&this.volume===0}},methods:{startShare(){console.log("\u8C03\u7528"),this.shareVisiable=!0},volumeChange(n){this.volume=n,Zf(n)}},render(){return I("div",{class:Se["action-bar"],id:"action-bar"},[I("div",{style:{display:"flex"}},[I("div",{class:Se["bar-btn"]},[I("div",{class:Se.btnInner},[I(Ae("SvgIcon"),{onClick:()=>{this.barStatus.camera=!this.barStatus.camera,op("camera")},name:this.isCameraDisabled?"bar-camera-disabled":"bar-camera",style:{width:"22px",cursor:"pointer"}},null),I(Dr,{placement:"top",disabled:ne.cameras.length===0,onCommand:Vd},{default:()=>[I("div",{class:Se["bar-btn"],style:{height:"32px"}},[I(Ae("SvgIcon"),{name:"bar-arrow-down",style:{width:"18px"}},null)])],dropdown:()=>{let n;return I(Cs,null,eu(n=ne.cameras.map(e=>I(Es,{disabled:e===ne.selectedCamera,command:e},{default:()=>[e.label]})))?n:{default:()=>[n]})}})]),I("span",{class:Se["bar-btn-text"]},[z("\u6444\u50CF\u5934")])]),I("div",{class:Se["bar-btn"]},[I("div",{class:Se.btnInner},[I(Ae("SvgIcon"),{onClick:()=>{this.barStatus.volume=!this.barStatus.volume,this.barStatus.volume?(sessionStorage.setItem("volume",this.volume.toString()),this.volumeChange(0)):sessionStorage.getItem("volume")&&this.volumeChange(Number(sessionStorage.getItem("volume")))},name:this.isVolumeDisabled?"bar-volume-disabled":"bar-volume",style:{width:"22px",cursor:"pointer"}},null),I(Dr,{placement:"top-start","popper-options":{boundariesElement:"#action-bar",gpuAcceleration:!1}},{default:()=>[I("div",{class:Se["bar-btn"],style:{height:"32px"}},[I(Ae("SvgIcon"),{name:"bar-arrow-down",style:{width:"18px"}},null)])],dropdown:()=>I("div",{class:Se.volumeSlider},[I(Ae("SvgIcon"),{class:Se.volumeIcon,name:"message-voice",color:"#fff"},null),I(Rl,{modelValue:this.volume,onInput:this.volumeChange,size:"small"},null)])})]),I("span",{class:Se["bar-btn-text"]},[z("\u97F3\u91CF\u8C03\u8282")])]),I("div",{class:Se["bar-btn"],onClick:ep},[I("div",{class:Se.btnInner},[I(Ae("SvgIcon"),{name:"bar-screen-share",style:{width:"22px",cursor:"pointer"}},null)]),I("span",{class:Se["bar-btn-text"]},[z("\u5C4F\u5E55\u5171\u4EAB")])]),I("div",{class:Se["bar-btn"]},[I("div",{class:Se.btnInner},[I(Ae("SvgIcon"),{onClick:()=>{const n=ne.videoStatus==="liveing";this.barStatus.microphone=!this.barStatus.microphone,this.barStatus.microphone?hi("microphone",n):jd("microphone",n)},name:this.isMicrophoneDisabled?"bar-mike-disabled":"bar-mike",style:{width:"22px",cursor:"pointer"}},null),I(Dr,{placement:"top-start",disabled:ne.microphones.length===0,"popper-options":{boundariesElement:"#action-bar",gpuAcceleration:!1},onCommand:Fd},{default:()=>[I("div",{class:Se["bar-btn"],style:{height:"32px"}},[I(Ae("SvgIcon"),{name:"bar-arrow-down",style:{width:"18px"}},null)])],dropdown:()=>{let n;return I(Cs,null,eu(n=ne.microphones.map(e=>I(Es,{disabled:e===ne.selectedMicrophone,command:e},{default:()=>[e.label]})))?n:{default:()=>[n]})}})]),I("span",{class:Se["bar-btn-text"]},[z("\u9EA6\u514B\u98CE")])])]),I("div",{style:{display:"flex"},onClick:this.startShare},[I("div",{class:Se["bar-btn"]},[I("div",{class:Se.btnInner},[I(Ae("SvgIcon"),{name:"bar-share",style:{width:"22px",cursor:"pointer"}},null)]),I("span",{class:Se["bar-btn-text"]},[z("\u5206\u4EAB")])])]),I(Tl,{width:"510px","destroy-on-close":!0,"append-to-body":!0,modelValue:this.shareVisiable,title:"\u5206\u4EAB","before-close":()=>{this.shareVisiable=!1}},{default:()=>[I(Mm,{onClose:()=>this.shareVisiable=!1},null)]})])}});const Lm="_container_19awp_1",km="_title_19awp_21",Um="_tips_19awp_25";var Pe={container:Lm,title:km,tips:Um},Dm=Be({name:"VideoStatus",render(){return I("div",{class:Pe.container},[ne.deviceStatus.camera==="denied"?I("div",{class:Pe.denied},[I(Ae("SvgIcon"),{name:"camera-status",class:Pe.icon},null),I("p",{class:Pe.title},[z("\u6444\u50CF\u5934\u88AB\u7981\u7528")]),I("p",{class:Pe.tips},[z("\u8BF7\u6388\u6743\u5141\u8BB8\u8BBF\u95EE\u6444\u50CF\u5934")])]):null,ne.deviceStatus.camera==="init"?I("div",{class:Pe.init},[I(Ae("SvgIcon"),{name:"camera-status",class:Pe.icon},null),I("p",{class:Pe.title},[z("\u8BF7\u5B8C\u6210\u6444\u50CF\u5934\u6388\u6743")]),I("p",{class:Pe.tips},[z("\u8BF7\u6388\u6743\u5141\u8BB8\u8BBF\u95EE\u6444\u50CF\u5934")])]):null,ne.deviceStatus.camera==="closed"?I("div",{class:Pe.closed},[I(Ae("SvgIcon"),{name:"camera-status",class:Pe.icon},null),I("p",{class:Pe.title},[z("\u6444\u50CF\u5934\u5DF2\u5173\u95ED")]),I("p",{class:Pe.tips},[z("\u60A8\u5DF2\u5173\u95ED\u6444\u50CF\u5934")])]):null,ne.deviceStatus.camera==="none"?I("div",{class:Pe.none},[I(Ae("SvgIcon"),{name:"camera-status",class:Pe.icon},null),I("p",{class:Pe.title},[z("\u6682\u65E0\u6444\u50CF\u5934")]),I("p",{class:Pe.tips},[z("\u8BE5\u8BBE\u5907\u65E0\u6444\u50CF\u5934")])]):null])}}),fl={exports:{}};(function(n,e){(function(t,r){n.exports=r()})(Sl,function(){var t,r,i=1e3,s=6e4,o=36e5,c=864e5,d=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,l=31536e6,h=2592e6,a=/^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/,u={years:l,months:h,days:c,hours:o,minutes:s,seconds:i,milliseconds:1,weeks:6048e5},f=function(O){return O instanceof b},p=function(O,S,E){return new b(O,E,S.$l)},m=function(O){return r.p(O)+"s"},_=function(O){return O<0},v=function(O){return _(O)?Math.ceil(O):Math.floor(O)},y=function(O){return Math.abs(O)},C=function(O,S){return O?_(O)?{negative:!0,format:""+y(O)+S}:{negative:!1,format:""+O+S}:{negative:!1,format:""}},b=function(){function O(E,w,V){var j=this;if(this.$d={},this.$l=V,E===void 0&&(this.$ms=0,this.parseFromMilliseconds()),w)return p(E*u[m(w)],this);if(typeof E=="number")return this.$ms=E,this.parseFromMilliseconds(),this;if(typeof E=="object")return Object.keys(E).forEach(function(A){j.$d[m(A)]=E[A]}),this.calMilliseconds(),this;if(typeof E=="string"){var R=E.match(a);if(R){var T=R.slice(2).map(function(A){return A!=null?Number(A):0});return this.$d.years=T[0],this.$d.months=T[1],this.$d.weeks=T[2],this.$d.days=T[3],this.$d.hours=T[4],this.$d.minutes=T[5],this.$d.seconds=T[6],this.calMilliseconds(),this}}return this}var S=O.prototype;return S.calMilliseconds=function(){var E=this;this.$ms=Object.keys(this.$d).reduce(function(w,V){return w+(E.$d[V]||0)*u[V]},0)},S.parseFromMilliseconds=function(){var E=this.$ms;this.$d.years=v(E/l),E%=l,this.$d.months=v(E/h),E%=h,this.$d.days=v(E/c),E%=c,this.$d.hours=v(E/o),E%=o,this.$d.minutes=v(E/s),E%=s,this.$d.seconds=v(E/i),E%=i,this.$d.milliseconds=E},S.toISOString=function(){var E=C(this.$d.years,"Y"),w=C(this.$d.months,"M"),V=+this.$d.days||0;this.$d.weeks&&(V+=7*this.$d.weeks);var j=C(V,"D"),R=C(this.$d.hours,"H"),T=C(this.$d.minutes,"M"),A=this.$d.seconds||0;this.$d.milliseconds&&(A+=this.$d.milliseconds/1e3);var L=C(A,"S"),k=E.negative||w.negative||j.negative||R.negative||T.negative||L.negative,F=R.format||T.format||L.format?"T":"",H=(k?"-":"")+"P"+E.format+w.format+j.format+F+R.format+T.format+L.format;return H==="P"||H==="-P"?"P0D":H},S.toJSON=function(){return this.toISOString()},S.format=function(E){var w=E||"YYYY-MM-DDTHH:mm:ss",V={Y:this.$d.years,YY:r.s(this.$d.years,2,"0"),YYYY:r.s(this.$d.years,4,"0"),M:this.$d.months,MM:r.s(this.$d.months,2,"0"),D:this.$d.days,DD:r.s(this.$d.days,2,"0"),H:this.$d.hours,HH:r.s(this.$d.hours,2,"0"),m:this.$d.minutes,mm:r.s(this.$d.minutes,2,"0"),s:this.$d.seconds,ss:r.s(this.$d.seconds,2,"0"),SSS:r.s(this.$d.milliseconds,3,"0")};return w.replace(d,function(j,R){return R||String(V[j])})},S.as=function(E){return this.$ms/u[m(E)]},S.get=function(E){var w=this.$ms,V=m(E);return V==="milliseconds"?w%=1e3:w=V==="weeks"?v(w/u[V]):this.$d[V],w===0?0:w},S.add=function(E,w,V){var j;return j=w?E*u[m(w)]:f(E)?E.$ms:p(E,this).$ms,p(this.$ms+j*(V?-1:1),this)},S.subtract=function(E,w){return this.add(E,w,!0)},S.locale=function(E){var w=this.clone();return w.$l=E,w},S.clone=function(){return p(this.$ms,this)},S.humanize=function(E){return t().add(this.$ms,"ms").locale(this.$l).fromNow(!E)},S.milliseconds=function(){return this.get("milliseconds")},S.asMilliseconds=function(){return this.as("milliseconds")},S.seconds=function(){return this.get("seconds")},S.asSeconds=function(){return this.as("seconds")},S.minutes=function(){return this.get("minutes")},S.asMinutes=function(){return this.as("minutes")},S.hours=function(){return this.get("hours")},S.asHours=function(){return this.as("hours")},S.days=function(){return this.get("days")},S.asDays=function(){return this.as("days")},S.weeks=function(){return this.get("weeks")},S.asWeeks=function(){return this.as("weeks")},S.months=function(){return this.get("months")},S.asMonths=function(){return this.as("months")},S.years=function(){return this.get("years")},S.asYears=function(){return this.as("years")},O}();return function(O,S,E){t=E,r=E().$utils(),E.duration=function(j,R){var T=E.locale();return p(j,{$l:T},R)},E.isDuration=f;var w=S.prototype.add,V=S.prototype.subtract;S.prototype.add=function(j,R){return f(j)&&(j=j.asMilliseconds()),w.bind(this)(j,R)},S.prototype.subtract=function(j,R){return f(j)&&(j=j.asMilliseconds()),V.bind(this)(j,R)}}})})(fl);var xm=fl.exports;const Bm="_time_1c1wd_1",Vm="_status_1c1wd_14",Fm="_text_1c1wd_27";var _s={time:Bm,status:Vm,text:Fm};Tt.extend(xm);var Hm=Be({setup(){const n=co({duration:""}),e=sessionStorage.getItem(pa),t=Number(e);let r=null;return Il(()=>{r=setInterval(()=>{const i=Tt().valueOf();t&&i-t&&(n.duration=Tt.duration(i-t).format("HH:mm:ss"))})}),bl(()=>{r&&clearInterval(r)}),()=>ne.videoStatus==="liveing"&&t?I("div",{class:_s.time},[I("div",{class:_s.status},[I("div",{class:"line-scale-pulse-out"},[I("div",null,null),I("div",null,null),I("div",null,null)]),I("span",null,[z("\u76F4\u64AD\u4E2D")])]),I("span",{class:_s.text},[n.duration])]):null}});const $m=async(n,e)=>{if(!navigator)throw new Error("\u6D4F\u89C8\u5668\u7248\u672C\u8FC7\u4F4E");return n?(e||[]).map(t=>n.removeTrack(t)):[]},jm="_main_1b4ip_1",Km="_video_1b4ip_12";var tu={main:jm,video:Km};const nu=uo(null);let ru,vs;var qm=Be({name:"LiveBroadcast",async mounted(){this.initializeRoom(),$d(),De.on(Ue["RC:Chatroom:Like"],this.onLikeMessage)},beforeUnmount(){De.off(Ue["RC:Chatroom:Like"],this.onLikeMessage)},methods:{onLikeMessage(n){ne.likeCount+=n.counts},async initializeRoom(){var n,e;if(!ve.user)throw Error("\u8BF7\u5148\u767B\u5F55");try{await Xf((n=ve.user)==null?void 0:n.imToken),ne.videoRef=nu.value,await tp(),await np(),Vd(ne.cameras[0]),Fd(ne.microphones[0]),vs=await xt("camera"),ne.videoRef&&vs.play(ne.videoRef),await Bt([vs],"camera"),ru=await xt("microphone"),ne.videoRef&&ru.play(ne.videoRef),console.log(ne.deviceStatus),ne.videoStatus="stream";const t=await ip((e=ve.user)==null?void 0:e.roomUid,pt.VIDEO,{onMessageReceive(r,i){console.log(r,i)},onKickOff(r){console.log(r)},async onTrackPublish(r){var s;const i=await((s=t==null?void 0:t.room)==null?void 0:s.subscribe(r));console.log(i),(i==null?void 0:i.code)&&i.code!==M.SUCCESS&&console.log("\u8D44\u6E90\u8BA2\u9605\u5931\u8D25 ->",i.code)},onTrackUnpublish(r){console.log(r),De.emit(Ue["RM:RTC:TrackUnpublish"],r)},onSwitchRole(r,i){De.emit(Ue["RM:RTC:SwitchRole"],{userId:r,role:i})},onTrackReady(r){r.isAudioTrack()&&r.play()},onUserJoin(r){console.log("onUserJoin",r)},onUserLeave(r){De.emit(Ue["RM:RTC:UserLeave"],r),console.log("onUserLeave",r)}});sessionStorage.getItem(ga)==="liveing"&&await Hd(),t.room&&t.code===M.SUCCESS&&(ne.joinedRoom=t.room)}catch(t){ne.videoStatus="error",console.log(t)}},closeLive(){$m(ne.mediaStreams,ne.mediaStreamTrack),ne.videoStatus="stopped"}},render(){return I("div",{class:tu.main},[I(dp,null,null),I("div",{class:tu.video},[I("video",{ref:nu},null),ne.screenShareStatus?null:I(Dm,null,null),ne.videoStatus==="liveing"?I(Hm,null,null):null]),I(Pm,null,null)])}});const Gm="_container_1cod9_1",Ym="_dataCount_1cod9_6",Jm="_num_1cod9_17",Wm="_text_1cod9_22",zm="_dataIcon_1cod9_26",Qm="_tabContainer_1cod9_31",Xm="_tabIcon_1cod9_31",Zm="_point_1cod9_36",e_="_tabContent_1cod9_67",t_="_tabList_1cod9_73";var $e={container:Gm,dataCount:Ym,num:Jm,text:Wm,dataIcon:zm,tabContainer:Qm,tabIcon:Xm,point:Zm,tabContent:e_,tabList:t_};const n_="_message_4zab7_1",r_="_buttonGroup_4zab7_1";var iu={message:n_,buttonGroup:r_},i_=Be({name:"message",data(){return{options:"ALL"}},methods:{async SeatsCtrl(){await zt(it({seatBan:ne.allowSeatsCtrl},li()),"SeatsCtrl"),ne.allowSeatsCtrl=!ne.allowSeatsCtrl},async ChatBan(){await zt(it({chatBan:ne.allowChatCtrl},li()),"ChatBan"),ne.allowChatCtrl=!ne.allowChatCtrl}},render(){return I("div",{class:iu.message},[I("div",{class:iu.buttonGroup},[I(ht,{type:ne.allowChatCtrl?"info":"primary",onClick:this.ChatBan},{default:()=>[ne.allowChatCtrl?"\u5168\u4F53\u7981\u8A00":"\u5173\u95ED\u5168\u4F53\u7981\u8A00"]}),I(ht,{type:ne.allowSeatsCtrl?"info":"primary",onClick:this.SeatsCtrl},{default:()=>[ne.allowSeatsCtrl?"\u7981\u6B62\u8FDE\u9EA6":"\u5173\u95ED\u7981\u6B62\u8FDE\u9EA6"]})])])}});const s_="_sendMessage_p2cnx_1",o_="_form_p2cnx_10";var su={sendMessage:s_,form:o_};const Qt=co({messageList:[],joinList:{},joinTips:!1,lookList:{}});var Te=Qt;const ao=n=>{Qt.messageList.push(n)},jr=(n,e)=>{Qt.joinTips=!0,Qt.joinList[n]=e},kr=n=>{delete Qt.joinList[n]},Vn=(n,e)=>{Qt.lookList[n]=e},a_=n=>{delete Qt.lookList[n]};var c_=Be({data(){return{message:""}},methods:{onKeyDown(n){n.keyCode===13&&this.message.trim()!==""&&this.sendMessage()},async sendMessage(){try{await zt(this.message);const n=li();ao({id:n.id,name:n.name,content:this.message,isSelf:!0,sendTime:Tt(new Date).format("HH:mm:ss")}),this.message="",this.scrollToBottom()}catch{}},scrollToBottom(){this.$nextTick(()=>{var n,e;(e=document.querySelector("#tabList"))==null||e.scrollTo(0,((n=document.querySelector("#messageList"))==null?void 0:n.scrollHeight)||0)})}},render(){return I("div",{class:su.sendMessage},[I("div",{class:su.form},[I(cu,{modelValue:this.message,onKeydown:this.onKeyDown,onInput:n=>this.message=n,placeholder:"\u8BF7\u8F93\u5165\u6D88\u606F"},null),I(ht,{disabled:!this.message,onClick:this.sendMessage,round:!0,type:"primary"},{default:()=>[z("\u53D1\u9001")]})])])}});const u_="_itemContent_1wo39_1",d_="_itemInfo_1wo39_11",l_="_itemName_1wo39_14",h_="_userName_1wo39_20",f_="_rightTime_1wo39_30",p_="_itemText_1wo39_38",g_="_active_1wo39_42",m_="_joinText_1wo39_45",__="_join_1wo39_45",v_="_btn_1wo39_54",y_="_downBtn_1wo39_66",C_="_loadingStyle_1wo39_71";var le={itemContent:u_,itemInfo:d_,itemName:l_,userName:h_,"name-style":"_name-style_1wo39_26",rightTime:f_,itemText:p_,active:g_,joinText:m_,join:__,btn:v_,downBtn:y_,loadingStyle:C_};const E_="_icon_1svqd_9";var ys={"empty-container":"_empty-container_1svqd_1",icon:E_},Sa=Be({props:{text:{type:String,default:"\u6682\u65E0\u6570\u636E"},icon:{type:String,default:"noData-no-message"}},render(){return I("div",{class:ys["empty-container"]},[I(Ae("SvgIcon"),{name:this.icon,class:[ys.icon]},null),I("p",{class:ys["empty-text"]},[this.text])])}}),R_=Be({data(){return{joinList:{},loadingJoin:!1}},computed:{count(){let n=0;for(const e in Te.joinList)if(Object.prototype.hasOwnProperty.call(Te.joinList,e)&&(Te.joinList[e].type===3&&(n+=1),n>3))break;return n}},mounted(){De.on(Ue["RC:Chatroom:SeatApply"],this.onSeatApply),De.on(Ue["RC:Chatroom:SeatResponse"],this.onSeatApply),De.on(Ue["RM:RTC:UserLeave"],this.onSeatApply),De.on(Ue["RM:RTC:SwitchRole"],this.onSwitchRole),De.on(Ue["RC:Chatroom:Leave"],this.onLeave)},methods:{onLeave(n){kr(n.userId),a_(n.userId)},onSeatApply(n){if(Array.isArray(n)){for(const r of n)console.log("onSeatApply",r),kr(r);return}const t=n.$EventMessage.messageType==="RC:Chatroom:SeatResponse"?4:3;if(n.type===3){const r={name:n.audienceName,id:n.audienceId,userRoomType:t,type:n.type};jr(n.audienceId,r),Vn(n.audienceId,r)}if(n.type===4&&(console.log(n,"\u53D6\u6D88\u8FDE\u9EA6"),Te.joinList[n.audienceId]&&kr(n.audienceId),Te.lookList[n.audienceId])){let r=Te.lookList[n.audienceId];r.userRoomType=1,Vn(n.audienceId,r)}},agree(n){var t,r;if(this.count>3)return;const e=bn(it({},n),{audienceName:n.name,audienceId:n.id,teacherId:(t=ve.user)==null?void 0:t.id,teacherName:(r=ve.user)==null?void 0:r.speakerName,userRoomType:4,type:1});jr(n.id,e),Vn(n.id,e),zt(e,"SeatResponse")},refuse(n){var t,r;const e=bn(it({},n),{audienceName:n.name,audienceId:n.id,teacherId:(t=ve.user)==null?void 0:t.id,teacherName:(r=ve.user)==null?void 0:r.speakerName,userRoomType:4,type:5});jr(n.id,e),zt(e,"SeatApply")},onSwitchRole(n){if(console.log(n,"onSwitchRole"),Te.joinList[n.userId]&&n.role===2&&kr(n.userId),Te.lookList[n.userId]&&n.role===2){let e=Te.lookList[n.userId];e.userRoomType=1,Vn(n.userId,e)}}},render(){const n=Object.values(Te.joinList);return I("div",{style:{minHeight:"100%",position:"relative"}},[n.length>0?n.map(e=>I("div",{class:le.itemContent},[I("div",{class:le.itemInfo},[I("div",{class:le.itemName},[I("p",{class:le.userName},[I("span",{class:le["name-style"]},[e.name]),e.userRoomType!==4?I("span",{style:{paddingLeft:"10px"}},[z("\u7533\u8BF7\u8FDE\u9EA6")]):I("span",{style:{paddingLeft:"10px",color:"var(--live-text-color)"}},[z("\u6B63\u5728\u8FDE\u9EA6")])]),e.userRoomType!==4?I("div",{class:le.joinText},[I("div",{class:le.join},null),I(ht,{size:"small",type:"primary",disabled:this.count>3,class:le.btn,onClick:()=>this.agree(e)},{default:()=>[z("\u4E0A\u9EA6")]})]):I("div",{class:le.joinText},[I("div",{class:le.join},null),I(ht,{size:"small",plain:!0,class:[le.btn,le.downBtn],onClick:()=>this.refuse(e)},{default:()=>[z("\u4E0B\u9EA6")]})])])])])):this.loadingJoin?I("div",{class:le.loadingStyle},[I("div",{class:"el-loading-mask",style:"background-color: rgba(0, 0, 0, 0.8);"},[I("div",{class:"el-loading-spinner"},[I("svg",{class:"circular",viewBox:"25 25 50 50"},[I("circle",{class:"path",cx:"50",cy:"50",r:"20",fill:"none"},null)])])])]):I(Sa,{style:{paddingTop:"120px"},text:"\u6682\u65E0\u5B66\u5458\u53D1\u8D77\u8FDE\u9EA6\uFF01",icon:"noData-no-join"},null)])}}),T_=Be({data(){return{loadingLook:!1}},computed:{count(){let n=0;for(const e in Te.joinList)if(Object.prototype.hasOwnProperty.call(Te.joinList,e)&&(Te.joinList[e].type===3&&(n+=1),n>3))break;return n}},async mounted(){await this._init(),this.loadingLook=!0,De.on(Ue["RC:Chatroom:Welcome"],this.onWelcome),setTimeout(()=>{this.loadingLook=!1})},methods:{async _init(){try{const n=sessionStorage.getItem("roomUid");(await Jt.get("/api-web/imLiveBroadcastRoom/queryRoomUserInfo",{params:{roomUid:n}})).data.forEach(r=>{Te.lookList[r.userId]||(Te.lookList[r.userId]={id:r.userId,name:r.userName,type:3,userRoomType:1,time:Tt().format("YYYY-MM-DD HH:mm:ss")})})}catch{}},onWelcome(n){if(n&&n.user){const e=Tt(n.$EventMessage.sentTime||new Date).format("HH:mm:ss");let t={name:n.user.name,id:n.user.id,sendTime:e,userRoomType:1,type:3};!!Te.lookList[t.id]||Vn(t.id,t),this.loadingLook=!1}},async onUpLook(n){var e,t;try{const r={audienceName:n.name,audienceId:n.id,teacherId:(e=ve.user)==null?void 0:e.id,teacherName:(t=ve.user)==null?void 0:t.speakerName,userRoomType:2,type:1};await zt(r,"SeatApply")}catch{}},async onDownLook(n){var e,t;try{const r=bn(it({},n),{audienceName:n.name,audienceId:n.id,teacherId:(e=ve.user)==null?void 0:e.id,teacherName:(t=ve.user)==null?void 0:t.speakerName,type:5});jr(n.id,r),zt(r,"SeatApply")}catch{}}},render(){const n=Object.values(Te.lookList);return I("div",null,[n.length>0?n.map(e=>I("div",{class:le.itemContent},[I("div",{class:le.itemInfo},[I("div",{class:le.itemName},[I("p",{class:le.userName},[I("span",{class:le["name-style"]},[e.name])]),e.userRoomType!==4?I(ht,{size:"small",type:"primary",disabled:this.count>3,class:le.btn,onClick:()=>this.onUpLook(e)},{default:()=>[z("\u4E0A\u9EA6")]}):I(ht,{size:"small",plain:!0,class:[le.btn,le.downBtn],onClick:()=>this.onDownLook(e)},{default:()=>[z("\u4E0B\u9EA6")]})])])])):this.loadingLook?I("div",{class:le.loadingStyle},[I("div",{class:"el-loading-mask",style:"background-color: rgba(0, 0, 0, 0.8);"},[I("div",{class:"el-loading-spinner"},[I("svg",{class:"circular",viewBox:"25 25 50 50"},[I("circle",{class:"path",cx:"50",cy:"50",r:"20",fill:"none"},null)])])])]):I(Sa,{style:{paddingTop:"120px"},text:"\u6682\u65E0\u5B66\u5458\u89C2\u770B\uFF01",icon:"noData-no-user"},null)])}}),S_=Be({data(){return{messageList:[],loadingMessage:!1}},mounted(){this.loadingMessage=!0,De.on(Ue["RC:TxtMsg"],this.onMessage),De.on(Ue["RC:Chatroom:Like"],this.onLike),setTimeout(()=>{this.loadingMessage=!1},2e3),this.scrollToBottom()},beforeUnmount(){De.off(Ue["RC:TxtMsg"],this.onMessage),De.off(Ue["RC:Chatroom:Like"],this.onLike)},methods:{onLike(n){var e;if(n&&n.user){const t=Tt(n.$EventMessage.sentTime||new Date).format("HH:mm:ss");console.log(n,"like");let r={name:(e=n.user)==null?void 0:e.name,id:n.user.id,isSelf:!1,content:"\u7ED9\u60A8\u70B9\u4E86"+n.counts+"\u4E2A\u8D5E",sendTime:t};ao(r),this.loadingMessage=!1}this.scrollToBottom()},onMessage(n){var e;if(n&&n.user){const t=Tt(n.$EventMessage.sentTime||new Date).format("HH:mm:ss");let r={name:(e=n.user)==null?void 0:e.name,id:n.user.id,isSelf:!1,content:n.content,sendTime:t};n.user.id===ve.user.speakerId&&(r.isSelf=!0),ao(r),this.loadingMessage=!1}this.scrollToBottom()},scrollToBottom(){this.$nextTick(()=>{var n,e;(e=document.querySelector("#tabList"))==null||e.scrollTo(0,((n=document.querySelector("#messageList"))==null?void 0:n.scrollHeight)||0)})}},render(){return I("div",{style:{minHeight:"100%",position:"relative"},id:"messageList"},[Te.messageList.length>0?Te.messageList.map(n=>I("div",{class:le.itemContent},[I("div",{class:le.itemInfo},[I("div",{class:le.itemName},[I("div",{class:le.userName},[n.isSelf?I(wl,{effect:"dark",color:"#01A79E"},{default:()=>[z("\u4E3B\u8BB2\u4EBA")]}):null,I("span",{class:le["name-style"]},[n.name,z("\uFF1A")]),I("span",{class:[le.itemText,n.isSelf?le.active:null]},[n.content])]),I("p",{class:le.rightTime},[n.sendTime])])])])):this.loadingMessage?I("div",{class:le.loadingStyle},[I("div",{class:"el-loading-mask",style:"background-color: rgba(0, 0, 0, 0.8);"},[I("div",{class:"el-loading-spinner"},[I("svg",{class:"circular",viewBox:"25 25 50 50"},[I("circle",{class:"path",cx:"50",cy:"50",r:"20",fill:"none"},null)])])])]):I(Sa,{style:{paddingTop:"120px"},text:"\u6682\u65E0\u5B66\u5458\u4E92\u52A8\uFF01",icon:"noData-no-message"},null)])}}),I_=Be({name:"LiveMessage",data(){return{modelIndex:"message"}},computed:{joinStatus(){console.log(this.modelIndex);let n=Te.joinTips;return Te.joinTips&&this.modelIndex==="join"&&(n=!1,Te.joinTips=!1),n}},mounted(){var n;ne.likeCount=((n=ve.user)==null?void 0:n.likeNum)||0},methods:{tabChange(n){this.modelIndex=n.props.name}},render(){var n;return I("div",{class:$e.container},[I("div",{class:$e.dataCount},[I("div",null,[I("p",{class:$e.num},[(n=ve.user)==null?void 0:n.likeNum]),I("p",{class:$e.text},[I(Ae("SvgIcon"),{name:"message-look",color:"#fff",class:$e.dataIcon},null),z("\u5F53\u524D\u89C2\u770B")])]),I("div",null,[I("p",{class:$e.num},[ne.likeCount]),I("p",{class:$e.text},[I(Ae("SvgIcon"),{name:"message-giveUp",color:"#fff",class:$e.dataIcon},null),z("\u7D2F\u8BA1\u70B9\u8D5E")])])]),I(Nl,{modelValue:this.modelIndex,"onTab-click":this.tabChange,class:$e.tabContainer},{default:()=>[I($i,{name:"message"},{label:()=>I("span",{style:{display:"flex",alignItems:"center"}},[I(Ae("SvgIcon"),{name:"message-message",color:this.modelIndex==="message"?"#00FFF0":"#fff",class:$e.tabIcon},null),z("\u804A\u5929")])}),I($i,{name:"join"},{label:()=>I("span",{style:{display:"flex",alignItems:"center",position:"relative"}},[I(Ae("SvgIcon"),{name:"message-evenEtc",color:this.modelIndex==="join"?"#00FFF0":"#fff",class:$e.tabIcon},null),z("\u8FDE\u9EA6 "),this.joinStatus?I("i",{class:$e.point},null):null])}),I($i,{name:"look"},{label:()=>I("span",{style:{display:"flex",alignItems:"center"}},[I(Ae("SvgIcon"),{name:"message-look",color:this.modelIndex==="look"?"#00FFF0":"#fff",class:$e.tabIcon},null),z("\u89C2\u770B")])})]}),I("div",{class:$e.tabContent},[I(i_,null,null),I("div",{class:$e.tabList,id:"tabList"},[ji(I(S_,null,null),[[Ki,this.modelIndex==="message"]]),ji(I(R_,null,null),[[Ki,this.modelIndex==="join"]]),ji(I(T_,null,null),[[Ki,this.modelIndex==="look"]])]),I(c_,null,null)])])}});const b_="_container_13n1h_1",w_="_home_13n1h_4";var ou={container:b_,home:w_},P_=Be({render(){return I("div",{class:ou.home},[I(ap,null,null),I("div",{class:ou.container},[I(qm,null,null),I(I_,null,null)])])}});export{P_ as default};