| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946 |
- var Il=Object.defineProperty,bl=Object.defineProperties;var wl=Object.getOwnPropertyDescriptors;var yr=Object.getOwnPropertySymbols;var wa=Object.prototype.hasOwnProperty,Oa=Object.prototype.propertyIsEnumerable;var ba=(t,e,n)=>e in t?Il(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,ot=(t,e)=>{for(var n in e||(e={}))wa.call(e,n)&&ba(t,n,e[n]);if(yr)for(var n of yr(e))Oa.call(e,n)&&ba(t,n,e[n]);return t},Mn=(t,e)=>bl(t,wl(e));var Na=(t,e)=>{var n={};for(var r in t)wa.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&yr)for(var r of yr(t))e.indexOf(r)<0&&Oa.call(t,r)&&(n[r]=t[r]);return n};import{s as he,r as vt,a as au}from"./index.3f974276.js";import{j as Ei,n as Ri,i as Jt,p as ft,d as Ve,a as I,l as ne,t as Vr,v as Io,x as bo,y as Ma,A as pt,B as Ol,C as cu,D as uu,F as wo,G as du,H as Nl,I as Al,J as lu,K as Ml,L as qi,r as Pe,M as Pl,N as Ll,O as kl,P as Ul,Q as Dl,R as xl,S as Gi,T as Yi,U as Ji}from"./vendor.9de3b924.js";const Bl="_liveHeader_turek_1",Vl="_liveLogo_turek_12",Fl="_liveHeaderLeft_turek_17",Hl="_liveHeaderLeftIcon_turek_23",jl="_liveHeaderLeftText_turek_27",$l="_avatarWrapper_turek_30",Kl="_userAvatar_turek_37";var At={liveHeader:Bl,liveLogo:Vl,liveHeaderLeft:Fl,liveHeaderLeftIcon:Hl,liveHeaderLeftText:jl,avatarWrapper:$l,userAvatar:Kl},Oo;(function(t){t[t.READ=1]="READ",t[t.LISTENED=2]="LISTENED",t[t.DOWNLOADED=4]="DOWNLOADED",t[t.RETRIEVED=8]="RETRIEVED",t[t.UNREAD=0]="UNREAD"})(Oo||(Oo={}));var Lt,Wi,Qn=Oo,ql=["https://nav.cn.ronghub.com","https://nav2-cn.ronghub.com"],Gl=["wsproxy.cn.ronghub.com","wsap-cn.ronghub.com"],Yl=["cometproxy-cn.ronghub.com","mini-cn.ronghub.com"],Pa={"RC:TxtMsg":{isCounted:!0,isPersited:!0},"RC:ImgMsg":{isCounted:!0,isPersited:!0},"RC:VcMsg":{isCounted:!0,isPersited:!0},"RC:ImgTextMsg":{isCounted:!0,isPersited:!0},"RC:FileMsg":{isCounted:!0,isPersited:!0},"RC:HQVCMsg":{isCounted:!0,isPersited:!0},"RC:LBSMsg":{isCounted:!0,isPersited:!0},"RC:PSImgTxtMsg":{isCounted:!0,isPersited:!0},"RC:PSMultiImgTxtMsg":{isCounted:!0,isPersited:!0},"RCJrmf:RpMsg":{isCounted:!0,isPersited:!0},"RCJrmf:RpOpendMsg":{isCounted:!0,isPersited:!0},"RC:CombineMsg":{isCounted:!0,isPersited:!0},"RC:ReferenceMsg":{isCounted:!0,isPersited:!0},"RC:SightMsg":{isCounted:!0,isPersited:!0},"RC:GIFMsg":{isCounted:!0,isPersited:!0},"RC:InfoNtf":{isCounted:!1,isPersited:!0},"RC:ContactNtf":{isCounted:!1,isPersited:!0},"RC:ProfileNtf":{isCounted:!1,isPersited:!0},"RC:CmdNtf":{isCounted:!1,isPersited:!0},"RC:GrpNtf":{isCounted:!1,isPersited:!0},"RC:RcCmd":{isCounted:!1,isPersited:!0},"RC:CmdMsg":{isCounted:!1,isPersited:!1},"RC:TypSts":{isCounted:!1,isPersited:!1},"RC:PSCmd":{isCounted:!1,isPersited:!1},"RC:SRSMsg":{isCounted:!1,isPersited:!1},"RC:RRReqMsg":{isCounted:!1,isPersited:!1},"RC:RRRspMsg":{isCounted:!1,isPersited:!1},"RC:CsChaR":{isCounted:!1,isPersited:!1},"RC:CSCha":{isCounted:!1,isPersited:!1},"RC:CsEva":{isCounted:!1,isPersited:!1},"RC:CsContact":{isCounted:!1,isPersited:!1},"RC:CsHs":{isCounted:!1,isPersited:!1},"RC:CsHsR":{isCounted:!1,isPersited:!1},"RC:CsSp":{isCounted:!1,isPersited:!1},"RC:CsEnd":{isCounted:!1,isPersited:!1},"RC:CsUpdate":{isCounted:!1,isPersited:!1},"RC:ReadNtf":{isCounted:!1,isPersited:!1},"RC:chrmKVNotiMsg":{isCounted:!1,isPersited:!1},"RC:VCAccept":{isCounted:!1,isPersited:!1},"RC:VCRinging":{isCounted:!1,isPersited:!1},"RC:VCSummary":{isCounted:!1,isPersited:!1},"RC:VCHangup":{isCounted:!1,isPersited:!1},"RC:VCInvite":{isCounted:!1,isPersited:!1},"RC:VCModifyMedia":{isCounted:!1,isPersited:!1},"RC:VCModifyMem":{isCounted:!1,isPersited:!1},"RC:MsgExMsg":{isCounted:!1,isPersited:!1},"RC:RRMsg":{isCounted:!1,isPersited:!1},"RC:LogCmdMsg":{isCounted:!1,isPersited:!1},"RC:InterceptMsg":{isCounted:!1,isPersited:!1}},Jl=["RC:TypSts","RC:InterceptMsg"];(function(t){t.WEBSOCKET="websocket",t.COMET="comet"})(Lt||(Lt={}));var Ti=function(t){return Wi||(Wi={set:function(e,n){t.localStorage.setItem(e,JSON.stringify(n))},get:function(e){var n;try{n=JSON.parse(t.localStorage.getItem(e))}catch{n=null}return n},remove:function(e){return t.localStorage.removeItem(e)},getKeys:function(){var e=[];for(var n in t.localStorage)e.push(n);return e}}),Wi},Wl=function(){function t(e){this._caches={},e&&(this._caches=e)}return t.prototype.set=function(e,n){this._caches[e]=n},t.prototype.remove=function(e){var n=this.get(e);return delete this._caches[e],n},t.prototype.get=function(e){return this._caches[e]},t.prototype.getKeys=function(){var e=[];for(var n in this._caches)e.push(n);return e},t}(),La=function(){function t(e,n){var r,i=n?"RCV4-"+n:"RCV4-";this._rootStorage=Ti(e);var o=this._rootStorage.get(i)||{};this._cache=new Wl(((r={})[i]=o,r)),this._storageKey=i}return t.prototype._get=function(){var e=this._storageKey;return this._cache.get(e)||{}},t.prototype._set=function(e){var n=this._storageKey;e=e||{},this._cache.set(n,e),this._rootStorage.set(n,e)},t.prototype.set=function(e,n){var r=this._get();r[e]=n,this._set(r)},t.prototype.remove=function(e){var n=this._get();delete n[e],this._set(n)},t.prototype.clear=function(){var e=this._storageKey;this._rootStorage.remove(e),this._cache.remove(e)},t.prototype.get=function(e){return this._get()[e]},t.prototype.getKeys=function(){var e=this._get(),n=[];for(var r in e)n.push(r);return n},t.prototype.getValues=function(){return this._get()||{}},t}(),hu=function(t,e){return(hu=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(n[i]=r[i])})(t,e)};function Oe(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}hu(t,e),t.prototype=e===null?Object.create(e):(n.prototype=e.prototype,new n)}var Ee=function(){return(Ee=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)};function x(t,e,n,r){return new(n||(n=Promise))(function(i,o){function s(l){try{d(r.next(l))}catch(h){o(h)}}function c(l){try{d(r.throw(l))}catch(h){o(h)}}function d(l){var h;l.done?i(l.value):(h=l.value,h instanceof n?h:new n(function(a){a(h)})).then(s,c)}d((r=r.apply(t,e||[])).next())})}function B(t,e){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function c(d){return function(l){return function(h){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=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 s.label++,{value:h[1],done:!1};case 5:s.label++,r=h[1],h=[0];continue;case 7:h=s.ops.pop(),s.trys.pop();continue;default:if(i=s.trys,!((i=i.length>0&&i[i.length-1])||h[0]!==6&&h[0]!==2)){s=0;continue}if(h[0]===3&&(!i||h[1]>i[0]&&h[1]<i[3])){s.label=h[1];break}if(h[0]===6&&s.label<i[1]){s.label=i[1],i=h;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(h);break}i[2]&&s.ops.pop(),s.trys.pop();continue}h=e.call(t,s)}catch(a){h=[6,a],r=0}finally{n=i=0}if(5&h[0])throw h[1];return{value:h[0]?h[1]:void 0,done:!0}}([d,l])}}}function Wt(t,e){for(var n=0,r=e.length,i=t.length;n<r;n++,i++)t[i]=e[n];return t}var Ue,Yr;(function(t){function e(n){return t.call(this,"TODO => "+n)||this}return Oe(e,t),e})(Error);var ka=function(t,e,n){if(e===void 0||n===void 0)return t.toUpperCase();var r=t.slice(e,n);return t=t.replace(r,function(i){return i.toUpperCase()})},fu=function(t,e){e===void 0&&(e="utf-8");var n,r=0;if(e==="utf-16")for(var i=0,o=t.length;i<o;i++)r+=(n=t.charCodeAt(i))<=65535?2:4;else for(i=0,o=t.length;i<o;i++)r+=(n=t.charCodeAt(i))<127?1:n<=2047?2:n<=65535?3:4;return r},Si=function(t,e){if(t=t.replace(/\?$/,""),!e)return t;var n=Object.keys(e).map(function(r){return r+"="+e[r]}).filter(function(r){return!!r});return n.length?[t,n.join("&")].join("?"):t},hs=function(t){return t.match(/\d+(\.\d+){2}/)[0]};(function(t){t[t.LOG=0]="LOG",t[t.DEBUG=0]="DEBUG",t[t.INFO=1]="INFO",t[t.WARN=2]="WARN",t[t.ERROR=3]="ERROR",t[t.FATAL=4]="FATAL",t[t.NONE=1e3]="NONE"})(Ue||(Ue={})),function(t){t.IM="IM",t.RTC="RTC"}(Yr||(Yr={}));var cn="RC_Logs";function zl(t){var e=t.target.result;t.oldVersion===1&&e.deleteObjectStore(cn),function(n,r,i){var o;if(!n.objectStoreNames.contains(r)){var s=Ee({},i.objectStoreParams);o=n.createObjectStore(r,s),i.indexs&&i.indexs.length>0&&i.indexs.forEach(function(c){o.createIndex(c.indexName,c.key,{unique:c.unique})})}}(e,cn,{indexs:[{indexName:"time",key:"time",unique:!1}],objectStoreParams:{autoIncrement:!0}})}var No,fs=function(){function t(){}return t.init=function(){if(typeof window!="undefined"&&window&&window.indexedDB){var e=window.indexedDB.open("RC_ENGINE_DB",2);e.onerror=function(n){console.warn("open indexDB request failed "+n.target.error)},e.onsuccess=function(n){t._db=n.target.result,t._db&&(t._db.onclose=function(r){var i;console.warn("The database "+((i=t._db)===null||i===void 0?void 0:i.name)+" has unexpectedly closed.",r),t._db=null,t._instance=null},t._db.onerror=function(r){var i;console.warn("The database "+((i=t._db)===null||i===void 0?void 0:i.name)+" has opening error.",r),t._db=null,t._instance=null},t._db.onabort=function(r){var i;console.warn("The database "+((i=t._db)===null||i===void 0?void 0:i.name)+" has opening aborted.",r),t._db=null,t._instance=null}),t._instance=new t},e.onupgradeneeded=function(n){t._db=n.target.result,zl(n)}}else console.debug("IndexDB is not currently supported in the environment!")},t.getInstance=function(){return t._instance},t.prototype.addList=function(e,n){return new Promise(function(r){if(t._db){var i=t._db.transaction([e],"readwrite"),o=i.objectStore(e);n.forEach(function(s){o==null||o.add(s)}),i.oncomplete=function(s){r(!0)},i.onerror=function(s){r(!1)}}else r(!1)})},t.prototype.getRangeData=function(e,n,r,i){return new Promise(function(o){if(t._db){var s=t._db.transaction([e],"readwrite").objectStore(e),c=IDBKeyRange.bound(r,i),d=s.index(n),l=[],h=d.openCursor(c);h.onsuccess=function(a){var u=a.target.result;u?(l.push(u.value),u.continue()):o(l)},h.onerror=function(a){console.error(a),o([])}}else o([])})},t.prototype.getCount=function(e,n){return new Promise(function(r){if(t._db){var i=t._db.transaction([e],"readonly").objectStore(e).count();i.onsuccess=function(){r(i.result)},i.onerror=function(o){console.error(o),r(0)}}else r(0)})},t.prototype.removeFirstData=function(e,n,r){return new Promise(function(i){if(t._db){var o=t._db.transaction([e],"readwrite").objectStore(e),s=o.getAllKeys(IDBKeyRange.lowerBound(0),r);s.onsuccess=function(){var c=s.result;c.length>0&&(o.delete(IDBKeyRange.bound(c[0],c[c.length-1])).onsuccess=function(){i(!0)})}}else i(!1)})},t._db=null,t}(),pu=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var e=16*Math.random()|0;return(t==="x"?e:3&e|8).toString(16)})},gu=function(){var t=pu();if(t=t.replace(/-/g,"")+"a",(t=function(r){var i="0123456789abcdefghigklmnopqrstuvwxyzABCDEFGHIGKLMNOPQRSTUVWXYZa0".split(""),o=i.length+1,s=+r,c=[];do{var d=s%o;s=(s-d)/o,c.unshift(i[d])}while(s);return c.join("")}(t=parseInt(t,16))).length>22&&(t=t.slice(0,22)),t.length<22)for(var e=22-t.length,n=0;n<e;n++)t+="0";return t};(function(t){t[t.NONE=0]="NONE",t[t.PRIVATE=1]="PRIVATE",t[t.DISCUSSION=2]="DISCUSSION",t[t.GROUP=3]="GROUP",t[t.CHATROOM=4]="CHATROOM",t[t.CUSTOMER_SERVICE=5]="CUSTOMER_SERVICE",t[t.SYSTEM=6]="SYSTEM",t[t.APP_PUBLIC_SERVICE=7]="APP_PUBLIC_SERVICE",t[t.PUBLIC_SERVICE=8]="PUBLIC_SERVICE",t[t.RTC_ROOM=12]="RTC_ROOM"})(No||(No={}));var Ao,re=No;(function(t){t[t.IMAGE=1]="IMAGE",t[t.AUDIO=2]="AUDIO",t[t.VIDEO=3]="VIDEO",t[t.FILE=4]="FILE",t[t.SIGHT=5]="SIGHT",t[t.COMBINE_HTML=6]="COMBINE_HTML"})(Ao||(Ao={}));var en,Mo,De=Ao,nt=function(t){return typeof t=="string"},Jr=function(t){return typeof t=="boolean"},be=function(t){return typeof t=="number"&&!isNaN(t)},Qe=function(t){return Object.prototype.toString.call(t).indexOf("Array")!==-1},mu=function(t){return Object.prototype.toString.call(t)==="[object ArrayBuffer]"},et=function(t){return nt(t)&&t.length>0},je=function(t){return Object.prototype.toString.call(t)==="[object Object]"},Wr=function(t){return Object.prototype.toString.call(t)==="[object Function]"},me=function(t){return t===void 0||Object.prototype.toString.call(t)==="[object Undefined]"},Ua=function(t){return Object.prototype.toString.call(t)==="[object Null]"},Xn=function(t){return nt(t)&&/https?:\/\//.test(t)},qn=function(t){for(var e in t)return!0;return!1},Ql=function(t){return be(t)&&Object.prototype.hasOwnProperty.call(De,t)},Da=((en={})[Ue.DEBUG]=console.debug.bind(console),en[Ue.INFO]=console.info.bind(console),en[Ue.WARN]=console.warn.bind(console),en[Ue.ERROR]=console.error.bind(console),en[Ue.FATAL]=console.log.bind(console),en),xa=function(t){return nt(t)||be(t)||me(t)||Jr(t)?t:t instanceof Error?JSON.stringify({name:t.name,message:t.message,stack:t.stack}):JSON.stringify(t)},Ht=function(){function t(e,n,r){this.tag=e,this.type=n,this.initiator=r,this._outLevel=Ue.WARN,this.debug=this.log.bind(this,Ue.DEBUG),this.info=this.log.bind(this,Ue.INFO),this.warn=this.log.bind(this,Ue.WARN),this.error=this.log.bind(this,Ue.ERROR),this.fatal=this.log.bind(this,Ue.FATAL)}return t.init=function(e){t.userId=e},t.reset=function(){t.userId=""},t.prototype._defaultStdout=function(e,n){for(var r=[],i=2;i<arguments.length;i++)r[i-2]=arguments[i];Da[e].apply(Da,Wt([n+":"],r))},t.prototype.__pushLocalLog=function(e,n,r){var i;i=this.type?this.type:["RCRTCLog","RCCall","RCRTC","RTC-A"].includes(this.tag)?Yr.RTC:Yr.IM;var o=Date.now();fu(n)>=1e3&&(n=function(l,h,a){if(a===void 0&&(a="utf-8"),!l||!h)return"";var u=a==="utf-8"?3:2,f=0,p=0,m="";for(p=0;p<l.length;p++){if(l.charCodeAt(p)>255?f+=u:f++,f>h)return m;m+=l.charAt(p)}return l}(n,1e3));var s=JSON.stringify({message:n,userId:t.userId}).replace(/"/g,'""'),c=/^[\w]+-[\w]+-[\w]+?/.test(r)?r:(this.initiator||"L")+"-"+r+"-O",d={sessionId:t.sessionId,time:o,level:4-e,content:t.sessionId+","+Date.now()+","+i+","+(4-e)+","+c+',"'+s+`"
- `,userId:t.userId};t.databaseLogList.push(d),(t.databaseLogList.length>=100||e===Ue.FATAL)&&this.__insertLogIntoDatabase()},t.prototype.__insertLogIntoDatabase=function(){return x(this,void 0,void 0,function(){var e,n,r;return B(this,function(i){switch(i.label){case 0:return e=Wt([],t.databaseLogList),t.databaseLogList=[],(n=fs.getInstance())?[4,n.addList(cn,e)]:[3,3];case 1:return r=i.sent(),[4,n.getCount(cn,"time")];case 2:return i.sent()>1e5&&n.removeFirstData(cn,"time",2e3),[2,r];case 3:return[2,!1]}})})},t.prototype.setLogLevel=function(e){this._outLevel=typeof e!="number"?Ue.WARN:e},t.prototype.setLogStdout=function(e){this._logStdout=e},t.prototype.log=function(e){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];if(e>Ue.DEBUG&&this.__pushLocalLog(e,n.map(xa).join(" "),this.tag),!(e<this._outLevel)){var i=new Date().toISOString()+"["+this.tag+"]["+Ue[e]+"]",o=i+" - "+n.map(xa).join(" ");this._logStdout?this._logStdout(e,o):this._stdout?this._stdout(e,o):this._defaultStdout.apply(this,Wt([e,i],n))}},t.prototype.reportLog=function(e,n,r){this.__pushLocalLog(4-e,r,n);var i=JSON.stringify({message:r}).replace(/"/g,'""');i='"'+i+'"';var o={level:e,content:[t.sessionId,Date.now(),this.type,e,n,i].join()+`
- `};t.realTimeLogList.push(o),t.realTimeLogList.length>=600&&(t.realTimeLogList=t.realTimeLogList.slice(-500))},t.prototype.set=function(e,n){this.warn("logger.set has being deprecated!")},t.prototype.setStdout=function(e){this._stdout=e},t.prototype.__clearRealTimeLog=function(){t.realTimeLogList=[]},t.databaseLogList=[],t.realTimeLogList=[],t.sessionId=gu(),t.userId="",t}(),G=new Ht("RCLog"),cr=function(){function t(){this._map={}}return t.prototype.on=function(e,n,r){var i=this._map[e]||(this._map[e]=[]);i.some(function(o){return o.listener===n&&o.target===r})||i.push({listener:n,target:r})},t.prototype.once=function(e,n,r){var i=this._map[e]||(this._map[e]=[]);i.some(function(o){return o.listener===n&&o.target===r})||i.push({listener:n,target:r,once:!0})},t.prototype.off=function(e,n,r){var i=this._map[e];i&&((i=i.filter(function(o){return o.listener!==n||o.target!==r})).length?this._map[e]=i:delete this._map[e])},t.prototype.emit=function(e){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];var i=this._map[e];if(i)for(var o=i.length-1;o>=0;o-=1){var s=i[o],c=s.target,d=s.once,l=s.listener;d&&i.splice(o,1);try{l.call.apply(l,Wt([c],n))}catch(h){G.error(h)}}},t.prototype.removeAll=function(e){delete this._map[e]},t.prototype.clear=function(){Object.keys(this._map).forEach(this.removeAll,this)},t}();(function(t){t[t.SEND=1]="SEND",t[t.RECEIVE=2]="RECEIVE"})(Mo||(Mo={}));var Po,ct=Mo;(function(t){t[t.TIMEOUT=-1]="TIMEOUT",t[t.UNKNOWN=-2]="UNKNOWN",t[t.PARAMETER_ERROR=-3]="PARAMETER_ERROR",t[t.EXTRA_METHOD_UNDEFINED=-4]="EXTRA_METHOD_UNDEFINED",t[t.MAIN_PROCESS_ERROR=-5]="MAIN_PROCESS_ERROR",t[t.PARAMETER_CHANGED=-6]="PARAMETER_CHANGED",t[t.SUCCESS=0]="SUCCESS",t[t.RC_MSG_UNAUTHORIZED=20406]="RC_MSG_UNAUTHORIZED",t[t.RC_DISCUSSION_GROUP_ID_INVALID=20407]="RC_DISCUSSION_GROUP_ID_INVALID",t[t.SEND_FREQUENCY_TOO_FAST=20604]="SEND_FREQUENCY_TOO_FAST",t[t.NOT_IN_DISCUSSION=21406]="NOT_IN_DISCUSSION",t[t.FORBIDDEN_IN_GROUP=22408]="FORBIDDEN_IN_GROUP",t[t.RECALL_MESSAGE=25101]="RECALL_MESSAGE",t[t.NOT_IN_GROUP=22406]="NOT_IN_GROUP",t[t.NOT_IN_CHATROOM=23406]="NOT_IN_CHATROOM",t[t.FORBIDDEN_IN_CHATROOM=23408]="FORBIDDEN_IN_CHATROOM",t[t.RC_CHATROOM_USER_KICKED=23409]="RC_CHATROOM_USER_KICKED",t[t.RC_CHATROOM_NOT_EXIST=23410]="RC_CHATROOM_NOT_EXIST",t[t.RC_CHATROOM_IS_FULL=23411]="RC_CHATROOM_IS_FULL",t[t.RC_CHATROOM_PATAMETER_INVALID=23412]="RC_CHATROOM_PATAMETER_INVALID",t[t.CHATROOM_GET_HISTORYMSG_ERROR=23413]="CHATROOM_GET_HISTORYMSG_ERROR",t[t.CHATROOM_NOT_OPEN_HISTORYMSG_STORE=23414]="CHATROOM_NOT_OPEN_HISTORYMSG_STORE",t[t.CHATROOM_KV_EXCEED=23423]="CHATROOM_KV_EXCEED",t[t.CHATROOM_KV_OVERWRITE_INVALID=23424]="CHATROOM_KV_OVERWRITE_INVALID",t[t.CHATROOM_KV_STORE_NOT_OPEN=23426]="CHATROOM_KV_STORE_NOT_OPEN",t[t.CHATROOM_KEY_NOT_EXIST=23427]="CHATROOM_KEY_NOT_EXIST",t[t.SENSITIVE_SHIELD=21501]="SENSITIVE_SHIELD",t[t.SENSITIVE_REPLACE=21502]="SENSITIVE_REPLACE",t[t.JOIN_IN_DISCUSSION=21407]="JOIN_IN_DISCUSSION",t[t.CREATE_DISCUSSION=21408]="CREATE_DISCUSSION",t[t.INVITE_DICUSSION=21409]="INVITE_DICUSSION",t[t.GET_USERINFO_ERROR=23407]="GET_USERINFO_ERROR",t[t.REJECTED_BY_BLACKLIST=405]="REJECTED_BY_BLACKLIST",t[t.RC_NET_CHANNEL_INVALID=30001]="RC_NET_CHANNEL_INVALID",t[t.RC_NET_UNAVAILABLE=30002]="RC_NET_UNAVAILABLE",t[t.RC_MSG_RESP_TIMEOUT=30003]="RC_MSG_RESP_TIMEOUT",t[t.RC_HTTP_SEND_FAIL=30004]="RC_HTTP_SEND_FAIL",t[t.RC_HTTP_REQ_TIMEOUT=30005]="RC_HTTP_REQ_TIMEOUT",t[t.RC_HTTP_RECV_FAIL=30006]="RC_HTTP_RECV_FAIL",t[t.RC_NAVI_RESOURCE_ERROR=30007]="RC_NAVI_RESOURCE_ERROR",t[t.RC_NODE_NOT_FOUND=30008]="RC_NODE_NOT_FOUND",t[t.RC_DOMAIN_NOT_RESOLVE=30009]="RC_DOMAIN_NOT_RESOLVE",t[t.RC_SOCKET_NOT_CREATED=30010]="RC_SOCKET_NOT_CREATED",t[t.RC_SOCKET_DISCONNECTED=30011]="RC_SOCKET_DISCONNECTED",t[t.RC_PING_SEND_FAIL=30012]="RC_PING_SEND_FAIL",t[t.RC_PONG_RECV_FAIL=30013]="RC_PONG_RECV_FAIL",t[t.RC_MSG_SEND_FAIL=30014]="RC_MSG_SEND_FAIL",t[t.RC_MSG_CONTENT_EXCEED_LIMIT=30016]="RC_MSG_CONTENT_EXCEED_LIMIT",t[t.RC_CONN_ACK_TIMEOUT=31e3]="RC_CONN_ACK_TIMEOUT",t[t.RC_CONN_PROTO_VERSION_ERROR=31001]="RC_CONN_PROTO_VERSION_ERROR",t[t.RC_CONN_ID_REJECT=31002]="RC_CONN_ID_REJECT",t[t.RC_CONN_SERVER_UNAVAILABLE=31003]="RC_CONN_SERVER_UNAVAILABLE",t[t.RC_CONN_USER_OR_PASSWD_ERROR=31004]="RC_CONN_USER_OR_PASSWD_ERROR",t[t.RC_CONN_NOT_AUTHRORIZED=31005]="RC_CONN_NOT_AUTHRORIZED",t[t.RC_CONN_REDIRECTED=31006]="RC_CONN_REDIRECTED",t[t.RC_CONN_PACKAGE_NAME_INVALID=31007]="RC_CONN_PACKAGE_NAME_INVALID",t[t.RC_CONN_APP_BLOCKED_OR_DELETED=31008]="RC_CONN_APP_BLOCKED_OR_DELETED",t[t.RC_CONN_USER_BLOCKED=31009]="RC_CONN_USER_BLOCKED",t[t.RC_DISCONN_KICK=31010]="RC_DISCONN_KICK",t[t.RC_DISCONN_EXCEPTION=31011]="RC_DISCONN_EXCEPTION",t[t.RC_APP_AUTH_NOT_PASS=31026]="RC_APP_AUTH_NOT_PASS",t[t.RC_OTP_USED=31027]="RC_OTP_USED",t[t.RC_PLATFORM_ERROR=31028]="RC_PLATFORM_ERROR",t[t.RC_QUERY_ACK_NO_DATA=32001]="RC_QUERY_ACK_NO_DATA",t[t.RC_MSG_DATA_INCOMPLETE=32002]="RC_MSG_DATA_INCOMPLETE",t[t.BIZ_ERROR_CLIENT_NOT_INIT=33001]="BIZ_ERROR_CLIENT_NOT_INIT",t[t.BIZ_ERROR_DATABASE_ERROR=33002]="BIZ_ERROR_DATABASE_ERROR",t[t.BIZ_ERROR_INVALID_PARAMETER=33003]="BIZ_ERROR_INVALID_PARAMETER",t[t.BIZ_ERROR_NO_CHANNEL=33004]="BIZ_ERROR_NO_CHANNEL",t[t.BIZ_ERROR_RECONNECT_SUCCESS=33005]="BIZ_ERROR_RECONNECT_SUCCESS",t[t.BIZ_ERROR_CONNECTING=33006]="BIZ_ERROR_CONNECTING",t[t.MSG_ROAMING_SERVICE_UNAVAILABLE=33007]="MSG_ROAMING_SERVICE_UNAVAILABLE",t[t.MSG_INSERT_ERROR=33008]="MSG_INSERT_ERROR",t[t.MSG_DEL_ERROR=33009]="MSG_DEL_ERROR",t[t.TAG_EXISTS=33101]="TAG_EXISTS",t[t.TAG_NOT_EXIST=33100]="TAG_NOT_EXIST",t[t.NO_TAG_IN_CONVER=33102]="NO_TAG_IN_CONVER",t[t.CONVER_REMOVE_ERROR=34001]="CONVER_REMOVE_ERROR",t[t.CONVER_GETLIST_ERROR=34002]="CONVER_GETLIST_ERROR",t[t.CONVER_SETOP_ERROR=34003]="CONVER_SETOP_ERROR",t[t.CONVER_TOTAL_UNREAD_ERROR=34004]="CONVER_TOTAL_UNREAD_ERROR",t[t.CONVER_TYPE_UNREAD_ERROR=34005]="CONVER_TYPE_UNREAD_ERROR",t[t.CONVER_ID_TYPE_UNREAD_ERROR=34006]="CONVER_ID_TYPE_UNREAD_ERROR",t[t.CONVER_CLEAR_ERROR=34007]="CONVER_CLEAR_ERROR",t[t.EXPANSION_LIMIT_EXCEET=34010]="EXPANSION_LIMIT_EXCEET",t[t.MESSAGE_KV_NOT_SUPPORT=34008]="MESSAGE_KV_NOT_SUPPORT",t[t.CLEAR_HIS_TIME_ERROR=34011]="CLEAR_HIS_TIME_ERROR",t[t.CONVER_OUT_LIMIT_ERROR=34013]="CONVER_OUT_LIMIT_ERROR",t[t.CONVER_GET_ERROR=35021]="CONVER_GET_ERROR",t[t.GROUP_SYNC_ERROR=35001]="GROUP_SYNC_ERROR",t[t.GROUP_MATCH_ERROR=35002]="GROUP_MATCH_ERROR",t[t.READ_RECEIPT_ERROR=35003]="READ_RECEIPT_ERROR",t[t.PACKAGE_ENVIRONMENT_ERROR=35006]="PACKAGE_ENVIRONMENT_ERROR",t[t.CAN_NOT_RECONNECT=35007]="CAN_NOT_RECONNECT",t[t.SERVER_UNAVAILABLE=35008]="SERVER_UNAVAILABLE",t[t.HOSTNAME_ERROR=35009]="HOSTNAME_ERROR",t[t.HAS_OHTER_SAME_CLIENT_ON_LINE=35010]="HAS_OHTER_SAME_CLIENT_ON_LINE",t[t.UPLOAD_FILE_FAILED=35020]="UPLOAD_FILE_FAILED",t[t.CHATROOM_ID_ISNULL=36001]="CHATROOM_ID_ISNULL",t[t.CHARTOOM_JOIN_ERROR=36002]="CHARTOOM_JOIN_ERROR",t[t.CHATROOM_HISMESSAGE_ERROR=36003]="CHATROOM_HISMESSAGE_ERROR",t[t.CHATROOM_KV_NOT_FOUND=36004]="CHATROOM_KV_NOT_FOUND",t[t.BLACK_ADD_ERROR=37001]="BLACK_ADD_ERROR",t[t.BLACK_GETSTATUS_ERROR=37002]="BLACK_GETSTATUS_ERROR",t[t.BLACK_REMOVE_ERROR=37003]="BLACK_REMOVE_ERROR",t[t.DRAF_GET_ERROR=38001]="DRAF_GET_ERROR",t[t.DRAF_SAVE_ERROR=38002]="DRAF_SAVE_ERROR",t[t.DRAF_REMOVE_ERROR=38003]="DRAF_REMOVE_ERROR",t[t.SUBSCRIBE_ERROR=39001]="SUBSCRIBE_ERROR",t[t.NOT_SUPPORT=39002]="NOT_SUPPORT",t[t.QNTKN_FILETYPE_ERROR=41001]="QNTKN_FILETYPE_ERROR",t[t.QNTKN_GET_ERROR=41002]="QNTKN_GET_ERROR",t[t.COOKIE_ENABLE=51001]="COOKIE_ENABLE",t[t.GET_MESSAGE_BY_ID_ERROR=61001]="GET_MESSAGE_BY_ID_ERROR",t[t.HAVNODEVICEID=24001]="HAVNODEVICEID",t[t.DEVICEIDISHAVE=24002]="DEVICEIDISHAVE",t[t.FEILD=24009]="FEILD",t[t.VOIPISNULL=24013]="VOIPISNULL",t[t.NOENGINETYPE=24010]="NOENGINETYPE",t[t.NULLCHANNELNAME=24011]="NULLCHANNELNAME",t[t.VOIPDYANMICERROR=24012]="VOIPDYANMICERROR",t[t.NOVOIP=24014]="NOVOIP",t[t.INTERNALERRROR=24015]="INTERNALERRROR",t[t.VOIPCLOSE=24016]="VOIPCLOSE",t[t.CLOSE_BEFORE_OPEN=51001]="CLOSE_BEFORE_OPEN",t[t.ALREADY_IN_USE=51002]="ALREADY_IN_USE",t[t.INVALID_CHANNEL_NAME=51003]="INVALID_CHANNEL_NAME",t[t.VIDEO_CONTAINER_IS_NULL=51004]="VIDEO_CONTAINER_IS_NULL",t[t.DELETE_MESSAGE_ID_IS_NULL=61001]="DELETE_MESSAGE_ID_IS_NULL",t[t.CANCEL=1]="CANCEL",t[t.REJECT=2]="REJECT",t[t.HANGUP=3]="HANGUP",t[t.BUSYLINE=4]="BUSYLINE",t[t.NO_RESPONSE=5]="NO_RESPONSE",t[t.ENGINE_UN_SUPPORTED=6]="ENGINE_UN_SUPPORTED",t[t.NETWORK_ERROR=7]="NETWORK_ERROR",t[t.REMOTE_CANCEL=11]="REMOTE_CANCEL",t[t.REMOTE_REJECT=12]="REMOTE_REJECT",t[t.REMOTE_HANGUP=13]="REMOTE_HANGUP",t[t.REMOTE_BUSYLINE=14]="REMOTE_BUSYLINE",t[t.REMOTE_NO_RESPONSE=15]="REMOTE_NO_RESPONSE",t[t.REMOTE_ENGINE_UN_SUPPORTED=16]="REMOTE_ENGINE_UN_SUPPORTED",t[t.REMOTE_NETWORK_ERROR=17]="REMOTE_NETWORK_ERROR",t[t.VOIP_NOT_AVALIABLE=18]="VOIP_NOT_AVALIABLE",t[t.CHATROOM_KV_STORE_NOT_ALL_SUCCESS=23428]="CHATROOM_KV_STORE_NOT_ALL_SUCCESS",t[t.CHATROOM_KV_STORE_OUT_LIMIT=23429]="CHATROOM_KV_STORE_OUT_LIMIT"})(Po||(Po={}));var Lo,O=Po;(function(t){t[t.CONNECTED=0]="CONNECTED",t[t.CONNECTING=1]="CONNECTING",t[t.DISCONNECTED=2]="DISCONNECTED",t[t.NETWORK_UNAVAILABLE=3]="NETWORK_UNAVAILABLE",t[t.CONNECTION_CLOSED=4]="CONNECTION_CLOSED",t[t.KICKED_OFFLINE_BY_OTHER_CLIENT=6]="KICKED_OFFLINE_BY_OTHER_CLIENT",t[t.WEBSOCKET_UNAVAILABLE=7]="WEBSOCKET_UNAVAILABLE",t[t.WEBSOCKET_ERROR=8]="WEBSOCKET_ERROR",t[t.BLOCKED=9]="BLOCKED",t[t.DOMAIN_INCORRECT=12]="DOMAIN_INCORRECT",t[t.DISCONNECT_BY_SERVER=13]="DISCONNECT_BY_SERVER",t[t.REDIRECT=14]="REDIRECT",t[t.APPKEY_IS_FAKE=20]="APPKEY_IS_FAKE",t[t.ULTRALIMIT=1101]="ULTRALIMIT",t[t.REQUEST_NAVI=201]="REQUEST_NAVI",t[t.RESPONSE_NAVI=202]="RESPONSE_NAVI",t[t.RESPONSE_NAVI_ERROR=203]="RESPONSE_NAVI_ERROR",t[t.RESPONSE_NAVI_TIMEOUT=204]="RESPONSE_NAVI_TIMEOUT"})(Lo||(Lo={}));var ko,ae=Lo,Ke={ACCEPTED:0,UNACCEPTABLE_PROTOCOL_VERSION:1,IDENTIFIER_REJECTED:2,SERVER_UNAVAILABLE:3,TOKEN_INCORRECT:4,NOT_AUTHORIZED:5,REDIRECT:6,PACKAGE_ERROR:7,APP_BLOCK_OR_DELETE:8,BLOCK:9,TOKEN_EXPIRE:10,DEVICE_ERROR:11,HOSTNAME_ERROR:12,HASOHTERSAMECLIENTONLINE:13,IN_OTHER_CLUSTER:15,APP_AUTH_NOT_PASS:16,OTP_USED:17,PLATFORM_ERROR:18};(function(t){t.TextMessage="RC:TxtMsg",t.VOICE="RC:VcMsg",t.HQ_VOICE="RC:HQVCMsg",t.IMAGE="RC:ImgMsg",t.GIF="RC:GIFMsg",t.RICH_CONTENT="RC:ImgTextMsg",t.LOCATION="RC:LBSMsg",t.FILE="RC:FileMsg",t.SIGHT="RC:SightMsg",t.COMBINE="RC:CombineMsg",t.CHRM_KV_NOTIFY="RC:chrmKVNotiMsg",t.LOG_COMMAND="RC:LogCmdMsg",t.EXPANSION_NOTIFY="RC:MsgExMsg",t.REFERENCE="RC:ReferenceMsg",t.RECALL="RC:RcCmd",t.READ_RECEIPT="RC:ReadNtf",t.READ_RECEIPT_REQUEST="RC:RRReqMsg",t.READ_RECEIPT_RESPONSE="RC:RRRspMsg",t.SYNC_READ_STATUS="RC:SRSMsg",t.GROUP_READ_RECEIPT_REQUEST="RC:RRMsg",t.CHATROOM_JOIN="RC:ChrmJoinNtf",t.CHATROOM_LEFT="RC:ChrmQuitNtf",t.CHATROOM_MERGE_CHANGE="RC:ChrmMemChange",t.TYPING_STATUS="RC:TypSts",t.INTERCEPT="RC:InterceptMsg"})(ko||(ko={}));var Uo,Ge=ko;(function(t){t[t.OPEN=1]="OPEN",t[t.CLOSE=2]="CLOSE"})(Uo||(Uo={}));var Do,on=Uo;(function(t){t[t.ALL=1]="ALL",t[t.SINGAL=2]="SINGAL"})(Do||(Do={}));var xo,ps=Do;(function(t){t[t.QINIU=1]="QINIU",t[t.ALI=2]="ALI",t[t.AWS=3]="AWS",t[t.STC=4]="STC"})(xo||(xo={}));var Bo,ze=xo;(function(t){t[t.UPDATE=1]="UPDATE",t[t.DELETE=2]="DELETE"})(Bo||(Bo={}));var Vo,Ze=Bo;(function(t){t[t.QUIT=0]="QUIT",t[t.JOIN=1]="JOIN"})(Vo||(Vo={}));var Ba,Va=Vo;(function(t){/*!
- 全局敏感词:命中了融云内置的全局敏感词
- */t[t.GLOBAL=1]="GLOBAL",t[t.CUSTOM=2]="CUSTOM",t[t.THIRD_PARTY=3]="THIRD_PARTY"})(Ba||(Ba={}));var Je,Fa,Ha;(function(t){t[t.RTC=0]="RTC",t[t.LIVE=2]="LIVE"})(Je||(Je={})),function(t){t[t.AUDIO_AND_VIDEO=0]="AUDIO_AND_VIDEO",t[t.AUDIO=1]="AUDIO"}(Fa||(Fa={})),function(t){t[t.ANCHOR=1]="ANCHOR",t[t.AUDIENCE=2]="AUDIENCE"}(Ha||(Ha={}));var Rt,zr,Fo,Xl={"RC:VCAccept":"RC:VCAccept","RC:VCRinging":"RC:VCRinging","RC:VCSummary":"RC:VCSummary","RC:VCHangup":"RC:VCHangup","RC:VCInvite":"RC:VCInvite","RC:VCModifyMedia":"RC:VCModifyMedia","RC:VCModifyMem":"RC:VCModifyMem"};(function(t){t[t.ROOM=1]="ROOM",t[t.PERSON=2]="PERSON"})(Rt||(Rt={})),function(t){t[t.AnchorToViewer=1]="AnchorToViewer",t[t.ViewerToAnchor=2]="ViewerToAnchor"}(zr||(zr={})),function(t){t[t.KICK=0]="KICK",t[t.REFUSE=1]="REFUSE",t[t.COEXIST=2]="COEXIST"}(Fo||(Fo={}));var Ct,Le,zi={engine:"5.1.1"},zt=function(){function t(){}return t.add=function(e,n){zi[e]=n},t.validEngine=function(e){var n=e.match(/\d+\.\d+\.\d+/);if(!n)return G.warn("The validation engine version '"+e+"' is invalid!"),!1;var r=n[0].split(".").map(function(i){return i.padStart(3,"0")}).join("");return zi.engine.match(/\d+\.\d+\.\d+/)[0].split(".").map(function(i){return i.padStart(3,"0")}).join("")>=r},t.getInfo=function(){return zi},t}();(function(t){t[t.STRING=0]="STRING",t[t.ONLY_STRING=1]="ONLY_STRING",t[t.NUMBER=2]="NUMBER",t[t.BOOLEAN=3]="BOOLEAN",t[t.OBJECT=4]="OBJECT",t[t.ARRAY=5]="ARRAY",t[t.CALLBACK=6]="CALLBACK",t[t.CHANNEL_ID=7]="CHANNEL_ID"})(Le||(Le={}));var wt,qe,rt,Qt,Gt,Zl=((Ct={})[Le.STRING]=et,Ct[Le.ONLY_STRING]=nt,Ct[Le.NUMBER]=be,Ct[Le.BOOLEAN]=function(t){return typeof t=="boolean"},Ct[Le.OBJECT]=je,Ct[Le.ARRAY]=Qe,Ct[Le.CALLBACK]=function(t){var e=!0;return je(t)||(e=!1),(t=t||{}).onSuccess&&!Wr(t.onSuccess)&&(e=!1),t.onError&&!Wr(t.onError)&&(e=!1),e},Ct[Le.CHANNEL_ID]=function(t){var e=!1;return nt(t)&&!/_/g.test(t)&&t.length<=20&&(e=!0),e},Ct),eh=function(t){function e(n){var r=t.call(this,n)||this;return r.name="RCAssertError",r}return Oe(e,t),e}(Error),Be=function(t,e,n,r){if(r===void 0&&(r=!1),!Re(t,e,n,r))throw new eh("'"+t+"' is invalid: "+JSON.stringify(e))},Re=function(t,e,n,r){r===void 0&&(r=!1),n=Zl[n]||n;var i=r&&!n(e)||!r&&!(me(e)||e===null||n(e));return i&&G.error("'"+t+"' is invalid: "+JSON.stringify(e)),!i},st=function(t){if(!je(t)||t.low===void 0||t.high===void 0)return t;var e=t.low;return e<0&&(e+=4294967296),e=e.toString(16),parseInt(t.high.toString(16)+"00000000".replace(new RegExp("0{"+e.length+"}$"),e),16)},th=function(t,e){var n=Math.floor(1e3*Math.random()%1e4),r=pu(),i=function(d){d=d||"-";var l=new Date;return""+l.getFullYear()+d+(l.getMonth()+1)+d+l.getDate()}(),o=new Date().getTime(),s="";if(e){var c=e.split(".");s="."+c[c.length-1]}return t+"__RC-"+i+"_"+n+"_"+o+r+s},nh=function(t,e){t===void 0&&(t={}),e===void 0&&(e={});var n=t.threadId,r=t.apnsCollapseId,i=t.category,o=t.richMediaUri,s=e.channelIdMi,c=e.channelIdHW,d=e.channelIdOPPO,l=e.typeVivo,h=e.googleConfig,a={};a["thread-id"]=n||"",a["apns-collapse-id"]=r||"",a.category=i||"",a.richMediaUri=o||"";var u={};u.collapse_key=h==null?void 0:h.collapseKey,u.imageUrl=h==null?void 0:h.imageUrl;var f=h==null?void 0:h.priority;f&&!["high","normal"].includes(f)&&(f="normal"),u.priority=f;var p=[{HW:{channelId:c||""}},{MI:{channelId:s||""}},{OPPO:{channelId:d||""}},{VIVO:{classification:l||""}},{APNS:a},{FCM:u}];return JSON.stringify(p)},ja=function(t,e){var n={},r={notificationId:e||""};if(!t)return{iOSConfig:n,androidConfig:r};try{var i=JSON.parse(t);i==null||i.forEach(function(o){var s,c,d,l,h=Object.keys(o);if(h.length!==0){var a=h[0];switch(a){case"HW":return void(r.channelIdHW=(s=o[a])===null||s===void 0?void 0:s.channelId);case"MI":return void(r.channelIdMi=(c=o[a])===null||c===void 0?void 0:c.channelId);case"OPPO":return void(r.channelIdOPPO=(d=o[a])===null||d===void 0?void 0:d.channelId);case"VIVO":return void(r.typeVivo=(l=o[a])===null||l===void 0?void 0:l.classification);case"APNS":return n.threadId=o[a]["thread-id"],n.apnsCollapseId=o[a]["apns-collapse-id"],n.category=o[a].category,void(n.richMediaUri=o[a].richMediaUri);case"FCM":r.googleConfig={collapseKey:o[a].collapse_key||"",imageUrl:o[a].imageUrl||"",priority:o[a].priority||""}}}})}catch{G.error("Wrong format for pushConfigs field! content: "+t)}return{iOSConfig:n,androidConfig:r}},tn=function(t){var e=/^[A-Za-z0-9_=+-]+$/.test(t),n=t.length;return e&&n<=128&&n>=1},Qi=function(t){var e=t.length;return e<=4096&&e>=1},Me=function(t,e,n){e=e||function(){};var r=(n=n||{}).isReverse;je(t)&&function(){for(var i in t)e(t[i],i,t)}(),(Qe(t)||nt(t))&&function(){if(r)for(var i=t.length-1;i>=0;i--)e(t[i],i);else for(var o=0,s=t.length;o<s;o++)e(t[o],o)}()},Cr=function(t,e){return Me(t,function(n,r){t[r]=e(n,r)}),t},rh=function(t,e){if(t.indexOf)return t.indexOf(e);var n=-1;return Me(t,function(r,i){e===r&&(n=i)}),n},ih=function(t,e){var n=[];return Me(t,function(r){n.push(r)}),rh(n,e)!==-1},Fr=function(t){return JSON.parse(JSON.stringify(t))},$a=function(){return typeof RCCppEngine!="undefined"},oh=function(t){if(t.tag!=="browser")return{type:t.tag,version:"UnKonw"};var e,n,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 o in i)if(i.hasOwnProperty(o)){var s=r.match(i[o]);if(s){n=o,e=s[1]||s[2];break}}return{type:n||"UnKonw",version:e||"UnKonw"}},_u=function(t){switch(t){case Ke.SERVER_UNAVAILABLE:return O.SERVER_UNAVAILABLE;case Ke.TOKEN_INCORRECT:return O.RC_CONN_USER_OR_PASSWD_ERROR;case Ke.REDIRECT:return O.RC_CONN_REDIRECTED;case Ke.APP_BLOCK_OR_DELETE:return O.RC_CONN_APP_BLOCKED_OR_DELETED;case Ke.BLOCK:return O.RC_CONN_USER_BLOCKED;case Ke.TOKEN_EXPIRE:return O.RC_CONN_USER_OR_PASSWD_ERROR;case Ke.HOSTNAME_ERROR:return O.HOSTNAME_ERROR;case Ke.HASOHTERSAMECLIENTONLINE:return O.HAS_OHTER_SAME_CLIENT_ON_LINE;case Ke.APP_AUTH_NOT_PASS:return O.RC_APP_AUTH_NOT_PASS;case Ke.OTP_USED:return O.RC_OTP_USED;case Ke.PLATFORM_ERROR:return O.RC_PLATFORM_ERROR;default:return O.RC_NET_UNAVAILABLE}},Ka=function(t){var e={},n=JSON.parse(t);return Me(n,function(r,i){e[i]=r.v}),e},sn={_delayTime:0,setTime:function(t){var e=new Date().getTime();sn._delayTime=e-t},getTime:function(){var t=sn._delayTime;return new Date().getTime()-t}},qa=function(t,e){var n=0;return t.isAutoDelete&&(n|=1),t.isOverwrite&&(n|=2),e===2&&(n|=4),n};(function(t){t[t.AT_MOST_ONCE=0]="AT_MOST_ONCE",t[t.AT_LEAST_ONCE=1]="AT_LEAST_ONCE",t[t.EXACTLY_ONCE=2]="EXACTLY_ONCE",t[t.DEFAULT=3]="DEFAULT"})(wt||(wt={})),function(t){t[t.SYMMETRIC=0]="SYMMETRIC",t[t.CONNECT=1]="CONNECT",t[t.CONN_ACK=2]="CONN_ACK",t[t.PUBLISH=3]="PUBLISH",t[t.PUB_ACK=4]="PUB_ACK",t[t.QUERY=5]="QUERY",t[t.QUERY_ACK=6]="QUERY_ACK",t[t.QUERY_CONFIRM=7]="QUERY_CONFIRM",t[t.SUBSCRIBE=8]="SUBSCRIBE",t[t.SUB_ACK=9]="SUB_ACK",t[t.UNSUBSCRIBE=10]="UNSUBSCRIBE",t[t.UNSUB_ACK=11]="UNSUB_ACK",t[t.PING_REQ=12]="PING_REQ",t[t.PING_RESP=13]="PING_RESP",t[t.DISCONNECT=14]="DISCONNECT",t[t.RESERVER2=15]="RESERVER2"}(qe||(qe={})),function(t){t.CONN_ACK="ConnAckMessage",t.DISCONNECT="DisconnectMessage",t.PING_REQ="PingReqMessage",t.PING_RESP="PingRespMessage",t.PUBLISH="PublishMessage",t.PUB_ACK="PubAckMessage",t.QUERY="QueryMessage",t.QUERY_CON="QueryConMessage",t.QUERY_ACK="QueryAckMessage"}(rt||(rt={})),function(t){t.PUB="pub",t.QUERY="qry"}(Qt||(Qt={})),function(t){t[t.V4=4]="V4",t[t.V3=3]="V3"}(Gt||(Gt={}));var Y,gs=function(){function t(e,n,r,i){n===void 0&&(n=!1),r===void 0&&(r=wt.AT_LEAST_ONCE),i===void 0&&(i=!1),this._retain=!1,this.qos=wt.AT_LEAST_ONCE,this._dup=!1,this.syncMsg=!1;var o=e>0;e&&o&&arguments.length===1?(this._retain=(1&e)>0,this.qos=(6&e)>>1,this._dup=(8&e)>0,this.type=e>>4&15,this.syncMsg=(8&e)==8):(this.type=e,this._retain=n,this.qos=r,this._dup=i)}return t.prototype.encode=function(){var e=this.type<<4;return e|=this._retain?1:0,e|=this.qos<<1,e|=this._dup?8:0},t}(),ur=function(){function t(){}return t.writeUTF=function(e,n){var r=[],i=0;if(nt(e))for(var o=0,s=e.length;o<s;o++){var c=e.charCodeAt(o);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(o=0,s=r.length;o<s;o++)r[o]>255&&(r[o]&=255);return n?r:i<=255?[0,i].concat(r):[i>>8,255&i].concat(r)},t.readUTF=function(e){for(var n,r,i=[],o=-1,s=e,c="";++o<s.length;){var d=Number(s[o]);if(d===(127&d)||((240&d)==240?d=(d=(d=(d^=240)<<6|128^s[++o])<<6|128^s[++o])<<6|128^s[++o]:(224&d)==224?d=(d=(d^=224)<<6|128^s[++o])<<6|128^s[++o]:(192&d)==192&&(d=(d^=192)<<6|128^s[++o])),!isFinite(d)||d<0||d>1114111||Math.floor(d)!==d)throw RangeError("Invalid code point: "+d);d<=65535?i.push(d):(n=(d-=65536)>>10|55296,r=d%1024|56320,i.push(n,r)),(o+1===s.length||i.length>16384)&&(c+=String.fromCharCode.apply(null,i),i.length=0)}return c},t}(),sh=function(){function t(e){this._position=0,this._poolLen=0,this._pool=e,this._poolLen=e.length}return t.prototype.check=function(){return this._position>=this._pool.length},t.prototype.read2Byte=function(){var e=this;if(e.check())return-1;for(var n="",r=0;r<2;r++){var i=e._pool[e._position++].toString(16);i.length===1&&(i="0"+i),n+=i.toString()}return parseInt(n,16)},t.prototype.readInt=function(){var e=this;if(e.check())return-1;for(var n="",r=0;r<4;r++){var i=e._pool[e._position++].toString(16);i.length===1&&(i="0"+i),n+=i.toString()}return parseInt(n,16)},t.prototype.readLong=function(){var e=this;if(e.check())return-1;for(var n="",r=0;r<8;r++){var i=e._pool[e._position++].toString(16);i.length===1&&(i="0"+i),n+=i}return parseInt(n,16)},t.prototype.readByte=function(){if(this.check())return-1;var e=this._pool[this._position++];return e>255&&(e&=255),e},t.prototype.readUTF=function(){if(this.check())return"";var e=this.readByte()<<8|this.readByte(),n=this._pool.subarray(this._position,this._position+=e);return ur.readUTF(n)},t.prototype.readAll=function(){return this._pool.subarray(this._position,this._poolLen)},t}(),ah=function(){function t(){this._pool=[],this._position=0,this._writen=0}return t.prototype.write=function(e){return Object.prototype.toString.call(e).indexOf("Array")!==-1?this._pool=this._pool.concat(e):e>=0&&(e>255&&(e&=255),this._pool.push(e),this._writen++),e},t.prototype.writeArr=function(e){return this._pool=this._pool.concat(e),e},t.prototype.writeUTF=function(e){var n=ur.writeUTF(e);this._pool=this._pool.concat(n),this._writen+=n.length},t.prototype.getBytesArray=function(){return this._pool},t}(),Zn="UpStreamMessage",ms="PushExtra",Ii="DownStreamMessage",er="DownStreamMessages",_s="SessionsAttQryInput",vu="SessionsAttOutput",vs="SyncRequestMsg",ys="ChrmPullMsg",Qr="NotifyMsg",Cs="HistoryMsgInput",tr="HistoryMsgOuput",Xr="RelationQryInput",nr="RelationsOutput",Es="DeleteSessionsInput",Rs="SessionInfo",yu="DeleteSessionsOutput",Ts="RelationsInput",Ss="DeleteMsgInput",Is="CleanHisMsgInput",bs="SessionMsgReadInput",ws="ChrmInput",Os="ChrmOutput",Ns="QueryChatRoomInfoInput",bi="QueryChatRoomInfoOutput",Zr="RtcInput",Yt="RtcUserListOutput",As="SetUserStatusInput",Ms="RtcSetDataInput",ei="RtcUserSetDataInput",ti="RtcDataInput",Ps="RtcSetOutDataInput",Ls="MCFollowInput",wi="RtcTokenOutput",Oi="RtcQryOutput",ks="RtcQryUserOutDataInput",Cu="RtcUserOutDataOutput",Us="RtcQueryListInput",Eu="RtcRoomInfoOutput",at="RtcValueInfo",Ds="RtcKeyDeleteInput",xs="GetQNupTokenInput",Bs="GetQNupTokenOutput",Vs="GetQNdownloadUrlInput",Fs="GetDownloadUrlInput",Hs="GetQNdownloadUrlOutput",js="GetDownloadUrlOutput",$s="SetChrmKV",Ks="SetChrmKVS",Ru="DeleteChrmKVS",un="ChrmKVOutput",qs="ChrmKVSOutput",Tu="ChrmKVSOutputEntity",Gs="QueryChrmKV",Su="SetUserSettingInput",dn="SetUserSettingOutput",Ys="PullUserSettingInput",Ni="PullUserSettingOutput",Ai="UserSettingNotification",Js="SessionReq",Mi="SessionStates",ni="SessionState",ri="SessionStateItem",ii="SessionStateModifyReq",Ws="SessionStateModifyResp",oi="GrpReadReceiptMsg",Iu="GrpReadReceiptQryReq",Pi="GrpReadReceiptQryResp",bu="GrpMsgReadUser",zs="SessionTagAddInput",Gn="SessionTagItem",Qs="SessionTagDelInput",Xs="SessionDisTagReq",Zs="ReportSDKInput",wu="ReportSDKOutput",ea="RtcNotifyMsg",ta="RtcPullKV",Li="RtcKVOutput",na="RtcQueryUserJoinedInput",ki="RtcQueryUserJoinedOutput",Ou="RtcViewerJoinedOutput",ra="RtcInviteInput",ia="RtcCancelInviteInput",oa="RtcInviteAnswerInput",sa="RtcEndInviteInput",Nu=((Y={})[Zn]=["sessionId","classname","content","pushText","userId","configFlag","appData","extraContent","pushExt","busChannel"],Y[er]=["list","syncTime","finished"],Y[Ii]=["fromUserId","type","groupId","classname","content","dataTime","status","msgId","extraContent","pushContent","configFlag","pushExt","busChannel"],Y[ms]=["title","templateIdNoUse","pushId","pushConfigs","templateId"],Y[_s]=["nothing"],Y[vu]=["inboxTime","sendboxTime","totalUnreadCount"],Y[vs]=["syncTime","ispolling","isweb","isPullSend","isKeeping","sendBoxSyncTime"],Y[ys]=["syncTime","count"],Y[Qr]=["type","time","chrmId"],Y[Cs]=["targetId","time","count","order","busChannel"],Y[tr]=["list","syncTime","hasMsg"],Y[Xr]=["type","count","startTime","order"],Y[nr]=["info"],Y[Es]=["sessions"],Y[Rs]=["type","channelId","busChannel"],Y[yu]=["nothing"],Y[Ts]=["type","msg","count","busChannel","startTime","endTime"],Y[Ss]=["type","conversationId","msgs","busChannel"],Y[Is]=["targetId","dataTime","conversationType","busChannel"],Y[bs]=["type","msgTime","channelId"],Y[ws]=["nothing"],Y[Os]=["nothing","sessionId","joinTime"],Y[Ns]=["count","order"],Y[bi]=["userTotalNums","userInfos"],Y[xs]=["type","key","httpMethod","queryString"],Y[Vs]=["type","key","fileName"],Y[Fs]=["type","key","fileName"],Y[Bs]=["deadline","token","bosToken","bosDate","path","osskeyId","ossPolicy","ossSign","ossBucketName"],Y[Hs]=["downloadUrl"],Y[js]=["downloadUrl"],Y[$s]=["entry","bNotify","notification","type"],Y[Ks]=["entry","bNotify","notification","type"],Y[Ru]=["entry","bNotify","notification","type"],Y[un]=["entries","bFullUpdate","syncTime"],Y[qs]=["timestamp","errorKeys"],Y[Tu]=["key","errorCode"],Y[Gs]=["timestamp"],Y[Su]=["version","value"],Y[dn]=["version","reserve"],Y[Ys]=["version","reserve"],Y[Ni]=["items","version"],Y.UserSettingItem=["targetId","type","key","value","version","status","tags"],Y[Js]=["time"],Y[Mi]=["version","state"],Y[ni]=["type","channelId","time","stateItem","busChannel"],Y[ri]=["sessionStateType","value","tags"],Y[ii]=["version","state"],Y[Ws]=["version"],Y[oi]=["msgId","busChannel"],Y[Iu]=["msgId","busChannel"],Y[Pi]=["totalMemberNum","list"],Y[bu]=["readTime","userId"],Y[zs]=["version","tags"],Y[Gn]=["tagId","name","createdTime","isTop"],Y[Qs]=["version","tags"],Y[Xs]=["tagId"],Y[Ai]=["version","reserve"],Y[Zs]=["sdkInfo"],Y[wu]=["nothing"],Y[Zr]=["roomType","broadcastType","extraInnerData","needSysChatroom","identityChangeType","joinType"],Y[Yt]=["users","token","sessionId","roomInfo"],Y[As]=["status"],Y[Ms]=["interior","target","key","value","objectName","content"],Y[ei]=["valueInfo","objectName","content"],Y[ti]=["interior","target","key","objectName","content"],Y[Ps]=["target","valueInfo","objectName","content"],Y[Ls]=["state"],Y[wi]=["rtcToken"],Y[Oi]=["outInfo"],Y[ks]=["userId"],Y[Cu]=["user"],Y[Us]=["order"],Y[Eu]=["roomId","roomData","userCount","list"],Y[at]=["key","value"],Y[Ds]=["key"],Y[ea]=["type","time","roomId"],Y[ta]=["timestamp","roomId"],Y[Li]=["entries","bFullUpdate","syncTime"],Y[na]=["userId"],Y[ki]=["info"],Y[ra]=["invitedUserId","timeoutTime","invitedRoomId","inviteInfo","inviteSessionId"],Y[ia]=["invitedUserId","invitedRoomId","inviteInfo","inviteSessionId"],Y[oa]=["inviteUserID","answerCode","inviteRoomId","inviteSessionId","content","key","value"],Y[sa]=["inviteRoomId","inviteSessionId","inviteContent","inviteRoomKeys"],Y),rr={},ch=function(t){var e=Nu[t];rr[t]=function(){for(var n={},r={getArrayData:function(){return n}},i=function(s){var c=e[s],d="set"+ka(c,0,1);r[d]=function(l){n[c]=l}},o=0;o<e.length;o++)i(o);return r},rr[t].decode=function(n){var r={};nt(n)&&(n=JSON.parse(n));var i=function(s){var c="get"+ka(s,0,1);r[s]=n[s],r[c]=function(){return n[s]}};for(var o in n)i(o);return r}};for(var uh in Nu)ch(uh);rr.getModule=function(t){return rr[t]()};var dh=`
- package Modules;
- message probuf {
- message `+As+`
- {
- optional int32 status=1;
- }
- message SetUserStatusOutput
- {
- optional int32 nothing=1;
- }
- message GetUserStatusInput
- {
- optional int32 nothing=1;
- }
- message GetUserStatusOutput
- {
- optional string status=1;
- optional string subUserId=2;
- }
- message SubUserStatusInput
- {
- repeated string userid =1;
- }
- message SubUserStatusOutput
- {
- optional int32 nothing=1;
- }
- message VoipDynamicInput
- {
- required int32 engineType = 1;
- required string channelName = 2;
- optional string channelExtra = 3;
- }
- message VoipDynamicOutput
- {
- required string dynamicKey=1;
- }
- message `+Qr+` {
- required int32 type = 1;
- optional int64 time = 2;
- optional string chrmId=3;
- }
- message `+vs+` {
- required int64 syncTime = 1;
- required bool ispolling = 2;
- optional bool isweb=3;
- optional bool isPullSend=4;
- optional bool isKeeping=5;
- optional int64 sendBoxSyncTime=6;
- }
- message `+Zn+` {
- required int32 sessionId = 1;
- required string classname = 2;
- required bytes content = 3;
- optional string pushText = 4;
- optional string appData = 5;
- repeated string userId = 6;
- optional int64 delMsgTime = 7;
- optional string delMsgId = 8;
- optional int32 configFlag = 9;
- optional int64 clientUniqueId = 10;
- optional string extraContent = 11;
- optional PushExtra pushExt = 12;
- optional string busChannel = 13; // \u8BE5\u6D88\u606F\u6240\u5C5E\u4F1A\u8BDD\u7684\u4E1A\u52A1\u6807\u8BC6
- }
- message `+ms+` {
- optional string title = 1;
- optional int32 templateIdNoUse= 2;
- optional string pushId = 3;
- optional string pushConfigs = 4;
- optional string templateId = 5;
- }
- message `+er+` {
- repeated DownStreamMessage list = 1;
- required int64 syncTime = 2;
- optional bool finished = 3;
- }
- message `+Ii+` {
- required string fromUserId = 1;
- required ChannelType type = 2;
- optional string groupId = 3;
- required string classname = 4;
- required bytes content = 5;
- required int64 dataTime = 6;
- required int64 status = 7;
- optional int64 extra = 8;
- optional string msgId = 9;
- optional int32 direction = 10;
- optional int32 plantform =11;
- optional int32 isRemoved = 12;
- optional string source = 13;
- optional int64 clientUniqueId = 14;
- optional string extraContent = 15;
- optional string pushContent = 16;
- optional int32 configFlag = 17;
- optional PushExtra pushExt = 18;
- optional string busChannel = 19; // \u8BE5\u6D88\u606F\u6240\u5C5E\u4F1A\u8BDD\u7684\u4E1A\u52A1\u6807\u8BC6\uFF0C\u9650\u523620\u5B57\u7B26\u4EE5\u5185
- }
- enum ChannelType {
- PERSON = 1;
- PERSONS = 2;
- GROUP = 3;
- TEMPGROUP = 4;
- CUSTOMERSERVICE = 5;
- NOTIFY = 6;
- MC=7;
- MP=8;
- }
- message CreateDiscussionInput {
- optional string name = 1;
- }
- message CreateDiscussionOutput {
- required string id = 1;
- }
- message ChannelInvitationInput {
- repeated string users = 1;
- }
- message LeaveChannelInput {
- required int32 nothing = 1;
- }
- message ChannelEvictionInput {
- required string user = 1;
- }
- message RenameChannelInput {
- required string name = 1;
- }
- message ChannelInfoInput {
- required int32 nothing = 1;
- }
- message ChannelInfoOutput {
- required ChannelType type = 1;
- required string channelId = 2;
- required string channelName = 3;
- required string adminUserId = 4;
- repeated string firstTenUserIds = 5;
- required int32 openStatus = 6;
- }
- message ChannelInfosInput {
- required int32 page = 1;
- optional int32 number = 2;
- }
- message ChannelInfosOutput {
- repeated ChannelInfoOutput channels = 1;
- required int32 total = 2;
- }
- message MemberInfo {
- required string userId = 1;
- required string userName = 2;
- required string userPortrait = 3;
- required string extension = 4;
- }
- message GroupMembersInput {
- required int32 page = 1;
- optional int32 number = 2;
- }
- message GroupMembersOutput {
- repeated MemberInfo members = 1;
- required int32 total = 2;
- }
- message GetUserInfoInput {
- required int32 nothing = 1;
- }
- message GetUserInfoOutput {
- required string userId = 1;
- required string userName = 2;
- required string userPortrait = 3;
- }
- message GetSessionIdInput {
- required int32 nothing = 1;
- }
- message GetSessionIdOutput {
- required int32 sessionId = 1;
- }
- enum FileType {
- image = `+De.IMAGE+`;
- audio = `+De.AUDIO+`;
- video = `+De.VIDEO+`;
- file = `+De.FILE+`;
- }
- message `+xs+` {
- required FileType type = 1;
- optional string key = 2;
- optional string httpMethod = 3;
- optional string queryString = 4;
- }
- message `+Vs+` {
- required FileType type = 1;
- required string key = 2;
- optional string fileName = 3;
- }
- message `+Fs+` {
- required FileType type = 1;
- required string key = 2;
- optional string fileName = 3;
- }
- message `+Bs+` {
- required int64 deadline = 1;
- required string token = 2;
- optional string bosToken = 3;
- optional string bosDate = 4;
- optional string path = 5;
- optional string osskeyId = 6;
- optional string ossPolicy = 7;
- optional string ossSign = 8;
- optional string ossBucketName = 9;
- optional string s3Credential = 10;
- optional string s3Algorithm = 11;
- optional string s3Date = 12;
- optional string s3Policy = 13;
- optional string s3Signature = 14;
- optional string s3BucketName = 15;
- optional string stcAuthorization = 16;
- optional string stcContentSha256 = 17;
- optional string stcDate = 18;
- optional string stcBucketName = 19;
- }
- message `+Hs+` {
- required string downloadUrl = 1;
- }
- message `+js+` {
- required string downloadUrl = 1;
- }
- message Add2BlackListInput {
- required string userId = 1;
- }
- message RemoveFromBlackListInput {
- required string userId = 1;
- }
- message QueryBlackListInput {
- required int32 nothing = 1;
- }
- message QueryBlackListOutput {
- repeated string userIds = 1;
- }
- message BlackListStatusInput {
- required string userId = 1;
- }
- message BlockPushInput {
- required string blockeeId = 1;
- }
- message ModifyPermissionInput {
- required int32 openStatus = 1;
- }
- message GroupInput {
- repeated GroupInfo groupInfo = 1;
- }
- message GroupOutput {
- required int32 nothing = 1;
- }
- message GroupInfo {
- required string id = 1;
- required string name = 2;
- }
- message GroupHashInput {
- required string userId = 1;
- required string groupHashCode = 2;
- }
- message GroupHashOutput {
- required GroupHashType result = 1;
- }
- enum GroupHashType {
- group_success = 0x00;
- group_failure = 0x01;
- }
- message `+ws+` {
- required int32 nothing = 1;
- }
- message `+Os+` {
- required int32 nothing = 1;
- optional string sessionId = 2;
- optional int64 joinTime = 3;
- }
- message `+ys+` {
- required int64 syncTime = 1;
- required int32 count = 2;
- }
- message ChrmPullMsgNew
- {
- required int32 count = 1;
- required int64 syncTime = 2;
- optional string chrmId=3;
- }
- message `+Xr+`
- {
- optional ChannelType type = 1;
- optional int32 count = 2;
- optional int64 startTime = 3;
- optional int32 order = 4;
- }
- message `+Ts+`
- {
- required ChannelType type = 1;
- optional DownStreamMessage msg =2;
- optional int32 count = 3;
- optional string busChannel = 4;
- optional int64 startTime = 5;
- optional int64 endTime = 6;
- }
- message `+nr+`
- {
- repeated RelationInfo info = 1;
- }
- message RelationInfo
- {
- required ChannelType type = 1;
- required string userId = 2;
- optional DownStreamMessage msg =3;
- optional int64 readMsgTime= 4;
- optional int64 unreadCount= 5;
- optional string busChannel = 6;//\u8BE5\u6D88\u606F\u6240\u5C5E\u4F1A\u8BDD\u7684\u4E1A\u52A1\u6807\u8BC6
- }
- message RelationInfoReadTime
- {
- required ChannelType type = 1;
- required int64 readMsgTime= 2;
- required string targetId = 3;
- }
- message `+Is+`
- {
- required string targetId = 1;
- required int64 dataTime = 2;
- optional int32 conversationType= 3;
- optional string busChannel = 4; //\u8BE5\u6D88\u606F\u6240\u5C5E\u4F1A\u8BDD\u7684\u4E1A\u52A1\u6807\u8BC6\uFF0C\u9650\u523620\u5B57\u7B26\u4EE5\u5185
- }
- message HistoryMessageInput
- {
- required string targetId = 1;
- required int64 dataTime =2;
- required int32 size = 3;
- }
- message HistoryMessagesOuput
- {
- repeated DownStreamMessage list = 1;
- required int64 syncTime = 2;
- required int32 hasMsg = 3;
- }
- message `+Ns+`
- {
- required int32 count= 1;
- optional int32 order= 2;
- }
- message `+bi+`
- {
- optional int32 userTotalNums = 1;
- repeated ChrmMember userInfos = 2;
- }
- message ChrmMember
- {
- required int64 time = 1;
- required string id = 2;
- }
- message MPFollowInput
- {
- required string id = 1;
- }
- message MPFollowOutput
- {
- required int32 nothing = 1;
- optional MpInfo info =2;
- }
- message `+Ls+`
- {
- required string state = 1;
- }
- message MCFollowOutput
- {
- required int32 nothing = 1;
- optional MpInfo info =2;
- }
- message MpInfo
- {
- required string mpid=1;
- required string name = 2;
- required string type = 3;
- required int64 time=4;
- optional string portraitUrl=5;
- optional string extra =6;
- }
- message SearchMpInput
- {
- required int32 type=1;
- required string id=2;
- }
- message SearchMpOutput
- {
- required int32 nothing=1;
- repeated MpInfo info = 2;
- }
- message PullMpInput
- {
- required int64 time=1;
- required string mpid=2;
- }
- message PullMpOutput
- {
- required int32 status=1;
- repeated MpInfo info = 2;
- }
- message `+Cs+`
- {
- optional string targetId = 1;
- optional int64 time = 2;
- optional int32 count = 3;
- optional int32 order = 4;
- optional string busChannel = 5; //\u8BE5\u6D88\u606F\u6240\u5C5E\u4F1A\u8BDD\u7684\u4E1A\u52A1\u6807\u8BC6\uFF0C\u9650\u523620\u5B57\u7B26\u4EE5\u5185
- }
- message `+tr+`
- {
- repeated DownStreamMessage list=1;
- required int64 syncTime=2;
- required int32 hasMsg=3;
- }
- message `+Us+`{
- optional int32 order=1;
- }
- message `+Ds+`{
- repeated string key=1;
- }
- message `+at+`{
- required string key=1;
- required string value=2;
- }
- message RtcUserInfo{
- required string userId=1;
- repeated `+at+` userData=2; //\u7528\u6237\u8D44\u6E90\u4FE1\u606F
- }
- message `+Yt+`{
- repeated RtcUserInfo users=1;
- optional string token=2;
- optional string sessionId=3;
- repeated RtcValueInfo roomInfo = 4; //\u623F\u95F4key value
- repeated RtcKVEntity entries = 5;//\u76F4\u64ADKV\u5C5E\u6027\u5BF9\u8C61\u96C6\u5408
- optional int64 syncTime = 6;//\u6240\u6709\u5C5E\u6027\u7684\u6700\u5927\u65F6\u95F4\u6233\uFF08\u4E0B\u6B21\u62C9\u53D6KV\u65F6\u7528\uFF09\u3002
- optional int32 offlineKickTime = 7;//server\u8D85\u65F6\u8E22\u4EBA\u65F6\u95F4\uFF0C\u9ED8\u8BA460s
- }
- message RtcRoomInfoOutput{
- optional string roomId = 1;
- repeated `+at+` roomData = 2;
- optional int32 userCount = 3;
- repeated RtcUserInfo list=4;
- }
- message `+Zr+`{
- required int32 roomType=1;
- optional int32 broadcastType=2;
- optional RtcValueInfo extraInnerData = 3;
- optional bool needSysChatroom = 4; //\u662F\u5426\u9700\u8981\u540C\u6B65\u804A\u5929\u5BA4
- optional IdentityChangeType identityChangeType = 5; //\u8EAB\u4EFD\u53D8\u66F4\u7C7B\u578B
- optional JoinType joinType = 6; // \u52A0\u5165\u623F\u95F4\u7C7B\u578B
- }
- enum JoinType {
- KICK = 0; //\u8E22\u524D\u4E00\u4E2A\u8BBE\u5907
- REFUSE = 1; //\u5F53\u524D\u52A0\u5165\u62D2\u7EDD
- COEXIST = 2; //\u4E24\u4E2A\u8BBE\u5907\u5171\u5B58
- }
- message RtcQryInput{
- required bool isInterior=1;
- required targetType target=2;
- repeated string key=3;
- }
- message `+Oi+`{
- repeated `+at+` outInfo=1;
- }
- message RtcDelDataInput{
- repeated string key=1;
- required bool isInterior=2;
- required targetType target=3;
- }
- message `+ti+`{
- required bool interior=1;
- required targetType target=2;
- repeated string key=3;
- optional string objectName=4;
- optional string content=5;
- }
- message `+Ms+`{
- required bool interior=1;
- required targetType target=2;
- required string key=3;
- required string value=4;
- optional string objectName=5;
- optional string content=6;
- }
- message `+ei+` {
- repeated `+at+` valueInfo = 1;
- required string objectName = 2;
- repeated `+at+` content = 3;
- }
- message RtcOutput
- {
- optional int32 nothing=1;
- }
- message `+wi+`{
- required string rtcToken=1;
- }
- enum targetType {
- ROOM =1 ;
- PERSON = 2;
- }
- message `+Ps+`{
- required targetType target=1;
- repeated `+at+` valueInfo=2;
- optional string objectName=3;
- optional string content=4;
- }
- message `+ks+`{
- repeated string userId = 1;
- }
- message `+Cu+`{
- repeated RtcUserInfo user = 1;
- }
- message `+_s+`{
- required int32 nothing = 1;
- }
- message `+vu+`{
- required int64 inboxTime = 1;
- required int64 sendboxTime = 2;
- required int64 totalUnreadCount = 3;
- }
- message `+bs+`
- {
- required ChannelType type = 1;
- required int64 msgTime = 2;
- required string channelId = 3;
- }
- message SessionMsgReadOutput
- {
- optional int32 nothing=1;
- }
- message `+Es+`
- {
- repeated SessionInfo sessions = 1;
- }
- message `+Rs+`
- {
- required ChannelType type = 1;
- required string channelId = 2;
- optional string busChannel = 3;//\u6240\u5C5E\u4F1A\u8BDD\u4E1A\u52A1\u6807\u8BC6
- }
- message `+yu+`
- {
- optional int32 nothing=1;
- }
- message `+Ss+`
- {
- optional ChannelType type = 1;
- optional string conversationId = 2;
- repeated DeleteMsg msgs = 3;
- optional string busChannel = 4; //\u8BE5\u6D88\u606F\u6240\u5C5E\u4F1A\u8BDD\u7684\u4E1A\u52A1\u6807\u8BC6\uFF0C\u9650\u523620\u5B57\u7B26\u4EE5\u5185
- }
- message DeleteMsg
- {
- optional string msgId = 1;
- optional int64 msgDataTime = 2;
- optional int32 direct = 3;
- }
- message ChrmKVEntity {
- required string key = 1;
- required string value = 2;
- optional int32 status = 3;
- optional int64 timestamp = 4;
- optional string uid = 5;
- }
- message `+$s+` {
- required ChrmKVEntity entry = 1;
- optional bool bNotify = 2;
- optional UpStreamMessage notification = 3;
- optional ChannelType type = 4;
- }
- message `+Ks+` {
- repeated ChrmKVEntity entry = 1;
- optional bool bNotify = 2;
- optional UpStreamMessage notification = 3;
- optional ChannelType type = 4;
- }
- message `+Ru+` {
- repeated ChrmKVEntity entry = 1;
- optional bool bNotify = 2;
- optional UpStreamMessage notification = 3;
- optional ChannelType type = 4;
- }
- message `+un+` {
- repeated ChrmKVEntity entries = 1;
- optional bool bFullUpdate = 2;
- optional int64 syncTime = 3;
- }
- message `+qs+` {
- repeated ChrmKVSOutputEntity errorKeys = 1;
- }
- message `+Tu+`
- {
- optional string key = 1;
- optional int32 errorCode = 2;
- }
- message `+Gs+` {
- required int64 timestamp = 1;
- }
- message `+Su+` {
- required int64 version=1;
- required string value=2;
- }
- message `+dn+` {
- required int64 version=1;
- required bool reserve=2;
- }
- message `+Ys+` {
- required int64 version=1;
- optional bool reserve=2;
- }
- message `+Ni+` {
- repeated UserSettingItem items = 1;
- required int64 version=2;
- }
- message UserSettingItem {
- required string targetId= 1;
- required ChannelType type = 2;
- required string key = 4;
- required bytes value = 5;
- required int64 version=6;
- required int32 status=7;
- repeated SessionTagItem tags= 8;
- }
- message `+Js+` {
- required int64 time = 1;
- }
- message `+Mi+` {
- required int64 version=1;
- repeated SessionState state= 2;
- }
- message `+ni+` {
- required ChannelType type = 1;
- required string channelId = 2;
- optional int64 time = 3;
- repeated SessionStateItem stateItem = 4;
- optional string busChannel = 5;//\u8BE5\u6D88\u606F\u6240\u5C5E\u4F1A\u8BDD\u7684\u4E1A\u52A1\u6807\u8BC6
- }
- message `+ri+` {
- required SessionStateType sessionStateType = 1;
- required string value = 2;
- repeated SessionTagItem tags = 3;
- }
- enum SessionStateType {
- IsSilent = 1;
- IsTop = 2;
- Tags = 3;
- }
- message `+ii+` {
- required int64 version=1;
- repeated SessionState state= 2;
- }
- message `+Ws+` {
- required int64 version=1;
- }
- message `+oi+` {
- repeated string msgId=1; //\u5DF2\u8BFB\u6D88\u606FID
- optional string channelId = 2; // \u8BE5\u6D88\u606F\u6240\u5C5E\u4F1A\u8BDD\u7684\u4E1A\u52A1\u6807\u8BC6
- }
- message `+Iu+` {
- repeated string msgId=1; //\u5DF2\u8BFB\u6D88\u606FID
- optional string channelId = 2; // \u8BE5\u6D88\u606F\u6240\u5C5E\u4F1A\u8BDD\u7684\u4E1A\u52A1\u6807\u8BC6
- }
- message `+Pi+` {
- required int32 totalMemberNum = 1;//\u7FA4\u5185\u603B\u4EBA\u6570
- repeated GrpMsgReadUser list = 2;//\u5DF2\u8BFB\u7528\u6237\u5217\u8868\uFF08list\u590D\u7C7B\u578B\uFF09
- }
- message `+bu+` {
- required int64 readTime = 1;//\u5DF2\u8BFB\u65F6\u95F4
- required string userId = 2;//\u5DF2\u8BFB\u7528\u6237id
- }
- message `+zs+` {
- required int64 version=1;
- repeated SessionTagItem tags=2;
- }
- message `+Gn+` {
- required string tagId=1;
- optional string name=2;
- optional int64 createdTime=3;
- optional bool isTop=4;
- }
- message `+Qs+` {
- required int64 version=1;
- repeated SessionTagItem tags=2;
- }
- message `+Xs+` {
- repeated string tagId=1;
- }
- message `+Ai+` {
- required int64 version=1;
- required bool reserve=2;
- }
- message `+Zs+` {
- required string sdkInfo=1; // \u7528\u6237\u96C6\u6210\u7684 sdk \u4FE1\u606F,json \u683C\u5F0F {"web-rtc": "4.0.3.7"}
- }
- message `+wu+`
- {
- optional int32 nothing=1; //\u5360\u4F4D
- }
- message `+ea+`
- {
- required int32 type= 1; //(\u901A\u77E5\u7C7B\u578B 1:rtc\u623F\u95F4\u72B6\u6001KV\u53D8\u66F4\u901A\u77E5)
- optional int64 time= 2; //\u6D88\u606F\u4EA7\u751F\u65F6\u95F4
- optional string roomId=3; //\u4E3B\u64AD\u623F\u95F4id
- }
- message `+ta+`
- {
- required int64 timestamp = 1;
- required string roomId = 2;
- }
- message `+Li+`
- {
- repeated RtcKVEntity entries = 1;
- optional bool bFullUpdate = 2;
- optional int64 syncTime = 3;
- }
- message RtcKVEntity
- {
- required string key = 1;
- required string value = 2;
- optional int32 status = 3;
- optional int64 timestamp = 4;
- optional string uid = 5;
- }
- enum IdentityChangeType
- {
- AnchorToViewer = 1; //1\u4E3A\u4E3B\u64AD\u53D8\u89C2\u4F17
- ViewerToAnchor = 2; //2\u4E3A\u89C2\u4F17\u53D8\u4E3B\u64AD
- }
- message `+na+`
- {
- required string userId = 1;
- }
- message `+ki+`
- {
- repeated RtcJoinedInfo info = 1;
- }
- message RtcJoinedInfo
- {
- required string deviceId = 1; //\u8BBE\u5907ID
- required string roomId = 2; //\u52A0\u5165\u7684\u623F\u95F4ID
- optional int64 joinTime = 3; //\u52A0\u5165\u7684\u65F6\u95F4
- }
- message `+Ou+`
- {
- required string rtcToken=1;
- repeated RtcKVEntity entries = 2;//KV\u5C5E\u6027\u5BF9\u8C61\u96C6\u5408
- optional int64 syncTime = 3;//\u6240\u6709\u5C5E\u6027\u7684\u6700\u5927\u65F6\u95F4\u6233\uFF08\u4E0B\u6B21\u62C9\u53D6KV\u65F6\u7528\uFF09\u3002
- }
- message `+ra+`
- {
- required string invitedUserId=1; //\u88AB\u9080\u8BF7\u7684\u4EBA\u7684uid
- optional int32 timeoutTime=2; //\u9080\u8BF7\u8D85\u65F6\u65F6\u95F4(\u79D2),\u9ED8\u8BA4\u4E09\u5341\u79D2
- required string invitedRoomId=3; //\u88AB\u9080\u8BF7\u7684\u623F\u95F4
- 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
- required string inviteSessionId= 5; //\u5BA2\u6237\u7AEF\u4FDD\u8BC1\u552F\u4E00\u6027(\u5EFA\u8BAEroomid_userid_\u65F6\u95F4\u6233_\u968F\u673A\u6570)
- }
- message `+ia+`
- {
- required string invitedUserId=1; //\u88AB\u9080\u8BF7\u7684\u4EBA\u7684uid
- required string invitedRoomId=2; //\u88AB\u9080\u8BF7\u7684\u623F\u95F4
- 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
- required string inviteSessionId=4; //\u9080\u8BF7\u7684sessionId,\u5BA2\u6237\u7AEF\u53D1\u8D77\u9080\u8BF7\u65F6\u4EA7\u751F
- }
- message `+oa+`
- {
- required string inviteUserId=1; //\u9080\u8BF7\u7684\u4EBA\u7684uid
- required int32 answerCode=2; //\u662F\u5426\u63A5\u53D7\u8FDE\u9EA6\u9080\u8BF7.0\u4E3A\u62D2\u7EDD,1\u4E3A\u63A5\u53D7
- required string inviteRoomId=3; //\u9080\u8BF7\u7684\u623F\u95F4
- required string inviteSessionId=4; //\u9080\u8BF7\u7684sessionId
- required string content=5; //\u9700\u8981\u8F6C\u53D1\u7684content
- 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
- 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
- }
- message `+sa+`
- {
- required string inviteRoomId=1; //\u9080\u8BF7\u7684\u623F\u95F4
- required string inviteSessionId=2; //\u9080\u8BF7\u7684sessionId
- required string inviteContent=3; //\u7ED3\u675F\u8FDE\u9EA6\u7684\u4FE1\u606F(\u9700\u8981\u900F\u4F20\u7ED9\u623F\u95F4\u5185\u5176\u4ED6\u4EBA)
- repeated string inviteRoomKeys=4; //\u9700\u8981\u5220\u9664\u8FDE\u9EA6\u7684\u4FE1\u606F\u7684key
- }
- }
- `,Ga,Ya,Pn,nn,Ln,Ho=(Ga=dh,function(t,e){var n,r,i={};return i.ByteBuffer=t,i.c=t,n=t,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 o={};return o.IS_NODE=!(typeof process!="object"||process+""!="[object process]"||process.browser),o.XHR=function(){var s,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(s=0;s<c.length;s++){try{d=c[s]()}catch{continue}break}if(!d)throw Error("XMLHttpRequest is not supported");return d},o.fetch=function(s,c){if(c&&typeof c!="function"&&(c=null),o.IS_NODE)if(c)g.readFile(s,function(l,h){c(l?null:""+h)});else try{return g.readFileSync(s)}catch{return null}else{var d=o.XHR();if(d.open("GET",s,!!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)}},o.toCamelCase=function(s){return s.replace(/_([a-zA-Z])/g,function(c,d){return d.toUpperCase()})},o}(),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(o,s){function c(m,_){var v=-1,y=1;if(m.charAt(0)=="-"&&(y=-1,m=m.substring(1)),s.NUMBER_DEC.test(m))v=parseInt(m);else if(s.NUMBER_HEX.test(m))v=parseInt(m.substring(2),16);else{if(!s.NUMBER_OCT.test(m))throw Error("illegal id value: "+(y<0?"-":"")+m);v=parseInt(m.substring(1),8)}if(v=0|y*v,!_&&v<0)throw Error("illegal id value: "+(y<0?"-":"")+m);return v}function d(m){var _=1;if(m.charAt(0)=="-"&&(_=-1,m=m.substring(1)),s.NUMBER_DEC.test(m))return _*parseInt(m,10);if(s.NUMBER_HEX.test(m))return _*parseInt(m.substring(2),16);if(s.NUMBER_OCT.test(m))return _*parseInt(m.substring(1),8);if(m==="inf")return 1/0*_;if(m==="nan")return NaN;if(s.NUMBER_FLT.test(m))return _*parseFloat(m);throw Error("illegal number value: "+(_<0?"-":"")+m)}function l(m,_,v){m[_]===void 0?m[_]=v:(Array.isArray(m[_])||(m[_]=[m[_]]),m[_].push(v))}var h,a,u={},f=function(m){this.source=m+"",this.index=0,this.line=1,this.stack=[],this._stringOpen=null},p=f.prototype;return p._readString=function(){var m,_=this._stringOpen==='"'?s.STRING_DQ:s.STRING_SQ;if(_.lastIndex=this.index-1,!(m=_.exec(this.source)))throw Error("unterminated string");return this.index=_.lastIndex,this.stack.push(this._stringOpen),this._stringOpen=null,m[1]},p.next=function(){var m,_,v,y,C;if(this.stack.length>0)return this.stack.shift();if(this.index>=this.source.length)return null;if(this._stringOpen!==null)return this._readString();do{for(m=!1;s.WHITESPACE.test(v=this.source.charAt(this.index));)if(v===`
- `&&++this.line,++this.index===this.source.length)return null;if(this.source.charAt(this.index)==="/")if(++this.index,this.source.charAt(this.index)==="/"){for(;this.source.charAt(++this.index)!==`
- `;)if(this.index==this.source.length)return null;++this.index,++this.line,m=!0}else{if((v=this.source.charAt(this.index))!=="*")return"/";do{if(v===`
- `&&++this.line,++this.index===this.source.length)return null;_=v,v=this.source.charAt(this.index)}while(_!=="*"||v!=="/");++this.index,m=!0}}while(m);if(this.index===this.source.length)return null;if(y=this.index,s.DELIM.lastIndex=0,!s.DELIM.test(this.source.charAt(y++)))for(;y<this.source.length&&!s.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(),!s.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(),s.NUMBER.test(_))return d(_);if(s.BOOL.test(_))return _.toLowerCase()==="true";if(m&&s.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()),!s.TYPEREF.test(y))throw Error("illegal option name: "+y);v=y,C&&(this.tn.skip(")"),v="("+v+")",y=this.tn.peek(),s.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(!s.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(!s.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(!s.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()),!s.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(!s.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(s.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(!s.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(!s.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(),!s.TYPE.test(C)&&!s.TYPEREF.test(C))throw Error("illegal message field type: "+C);if(y.keytype=C,this.tn.skip(","),C=this.tn.next(),!s.TYPE.test(C)&&!s.TYPEREF.test(C))throw Error("illegal message field: "+C);if(y.type=C,this.tn.skip(">"),C=this.tn.next(),!s.NAME.test(C))throw Error("illegal message field name: "+C);y.name=C,this.tn.skip("="),y.id=c(this.tn.next()),(C=this.tn.peek())==="["&&this._parseFieldOptions(y),this.tn.skip(";")}else if((v=v!==void 0?v:this.tn.next())==="group"){if(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(!s.TYPE.test(v)&&!s.TYPEREF.test(v))throw Error("illegal message field type: "+v);if(y.type=v,C=this.tn.next(),!s.NAME.test(C))throw Error("illegal message field name: "+C);y.name=C,this.tn.skip("="),y.id=c(this.tn.next()),(C=this.tn.peek())==="["&&this._parseFieldOptions(y),this.tn.skip(";")}return m.fields.push(y),y},a._parseMessageOneOf=function(m){var _,v,y,C=this.tn.next();if(!s.NAME.test(C))throw Error("illegal oneof name: "+C);for(v=C,y=[],this.tn.skip("{");(C=this.tn.next())!=="}";)(_=this._parseMessageField(m,"optional",C)).oneof=v,y.push(_.id);this.tn.omit(";"),m.oneofs[v]=y},a._parseFieldOptions=function(m){this.tn.skip("[");for(var _=!0;this.tn.peek()!=="]";)_||this.tn.skip(","),this._parseOption(m,!0),_=!1;this.tn.next()},a._parseEnum=function(m){var _,v={name:"",values:[],options:{}},y=this.tn.next();if(!s.NAME.test(y))throw Error("illegal name: "+y);for(v.name=y,this.tn.skip("{");(y=this.tn.next())!=="}";)if(y==="option")this._parseOption(v);else{if(!s.NAME.test(y))throw Error("illegal name: "+y);this.tn.skip("="),_={name:y,id:c(this.tn.next(),!0)},(y=this.tn.peek())==="["&&this._parseFieldOptions({options:{}}),this.tn.skip(";"),v.values.push(_)}this.tn.omit(";"),m.enums.push(v)},a._parseExtensionRanges=function(){var m,_,v,y=[];do{for(_=[];;){switch(m=this.tn.next()){case"min":v=o.ID_MIN;break;case"max":v=o.ID_MAX;break;default:v=d(m)}if(_.push(v),_.length===2)break;if(this.tn.peek()!=="to"){_.push(v);break}this.tn.next()}y.push(_)}while(this.tn.omit(","));return this.tn.skip(";"),y},a._parseExtend=function(m){var _,v=this.tn.next();if(!s.TYPEREF.test(v))throw Error("illegal extend reference: "+v);for(_={ref:v,fields:[]},this.tn.skip("{");(v=this.tn.next())!=="}";)if(s.RULE.test(v))this._parseMessageField(_,v);else{if(!s.TYPEREF.test(v))throw Error("illegal extend token: "+v);if(!this.proto3)throw Error("illegal field rule: "+v);this._parseMessageField(_,"optional",v)}return this.tn.omit(";"),m.messages.push(_),_},a.toString=function(){return"Parser at line "+this.tn.line},u.Parser=h,u}(i,i.Lang),i.Reflect=function(o){function s(R,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 o.Long(R.low,R.high,T===void 0?R.unsigned:T);if(typeof R=="string")return o.Long.fromString(R,T||!1,10);if(typeof R=="number")return o.Long.fromNumber(R,T||!1);throw Error("not convertible to Long")}function c(R,T){var A=T.readVarint32(),k=7&A,U=A>>>3;switch(k){case o.WIRE_TYPES.VARINT:do A=T.readUint8();while((128&A)==128);break;case o.WIRE_TYPES.BITS64:T.offset+=8;break;case o.WIRE_TYPES.LDELIM:A=T.readVarint32(),T.offset+=A;break;case o.WIRE_TYPES.STARTGROUP:c(U,T);break;case o.WIRE_TYPES.ENDGROUP:if(U===R)return!1;throw Error("Illegal GROUPEND after unknown group: "+U+" ("+R+" expected)");case o.WIRE_TYPES.BITS32:T.offset+=4;break;default:throw Error("Illegal wire type in unknown group "+R+": "+k)}return!0}var d,l,h,a,u,f,p,m,_,v,y,C,b,N,S,E,w={},V=function(R,T,A){this.builder=R,this.parent=T,this.name=A,this.className},K=V.prototype;return K.fqn=function(){for(var R=this.name,T=this;(T=T.parent)!=null;)R=T.name+"."+R;return R},K.toString=function(R){return(R?this.className+" ":"")+this.fqn()},K.build=function(){throw Error(this.toString(!0)+" cannot be built directly")},w.T=V,(l=(d=function(R,T,A,k,U){V.call(this,R,T,A),this.className="Namespace",this.children=[],this.options=k||{},this.syntax=U||"proto2"}).prototype=Object.create(V.prototype)).getChildren=function(R){var T,A,k;if((R=R||null)==null)return this.children.slice();for(T=[],A=0,k=this.children.length;k>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,k=typeof R=="number"?"id":"name";for(T=0,A=this.children.length;A>T;++T)if(this.children[T][k]===R)return this.children[T];return null},l.resolve=function(R,T){var A,k=typeof R=="string"?R.split("."):R,U=this,F=0;if(k[F]===""){for(;U.parent!==null;)U=U.parent;F++}do{do{if(!(U instanceof w.Namespace)){U=null;break}if(!((A=U.getChild(k[F]))&&A instanceof w.T&&(!T||A instanceof w.Namespace))){U=null;break}U=A,F++}while(F<k.length);if(U!=null)break;if(this.parent!==null)return this.parent.resolve(R,T)}while(U!=null);return U},l.qn=function(R){var T,A,k=[],U=R;do k.unshift(U.name),U=U.parent;while(U!==null);for(T=1;T<=k.length;T++)if(A=k.slice(k.length-T),R===this.resolve(A,R instanceof w.Namespace))return A.join(".");return R.fqn()},l.build=function(){var R,T,A,k={},U=this.children;for(T=0,A=U.length;A>T;++T)(R=U[T])instanceof d&&(k[R.name]=R.build());return Object.defineProperty&&Object.defineProperty(k,"$options",{value:this.buildOpt()}),k},l.buildOpt=function(){var R,T,A,k,U={},F=Object.keys(this.options);for(R=0,T=F.length;T>R;++R)A=F[R],k=this.options[F[R]],U[A]=k;return U},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,k){if(this.type=R,this.resolvedType=T,this.isMapKey=A,this.syntax=k,A&&o.MAP_KEY_TYPES.indexOf(R)<0)throw Error("Invalid map key type: "+R.name)}).prototype,h.defaultFieldValue=function(R){if(typeof R=="string"&&(R=o.TYPES[R]),R.defaultValue===void 0)throw Error("default value for type "+R.name+" is not supported");return R==o.TYPES.bytes?new n(0):R.defaultValue},a.verifyValue=function(R){var T,A,k,U=function(F,H){throw Error("Illegal value for "+this.toString(!0)+" of type "+this.type.name+": "+F+" ("+H+")")}.bind(this);switch(this.type){case o.TYPES.int32:case o.TYPES.sint32:case o.TYPES.sfixed32:return(typeof R!="number"||R==R&&R%1!=0)&&U(typeof R,"not an integer"),R>4294967295?0|R:R;case o.TYPES.uint32:case o.TYPES.fixed32:return(typeof R!="number"||R==R&&R%1!=0)&&U(typeof R,"not an integer"),R<0?R>>>0:R;case o.TYPES.int64:case o.TYPES.sint64:case o.TYPES.sfixed64:if(o.Long)try{return s(R,!1)}catch(F){U(typeof R,F.message)}else U(typeof R,"requires Long.js");case o.TYPES.uint64:case o.TYPES.fixed64:if(o.Long)try{return s(R,!0)}catch(F){U(typeof R,F.message)}else U(typeof R,"requires Long.js");case o.TYPES.bool:return typeof R!="boolean"&&U(typeof R,"not a boolean"),R;case o.TYPES.float:case o.TYPES.double:return typeof R!="number"&&U(typeof R,"not a number"),R;case o.TYPES.string:return typeof R=="string"||R&&R instanceof String||U(typeof R,"not a string"),""+R;case o.TYPES.bytes:return t.isByteBuffer(R)?R:t.wrap(R);case o.TYPES.enum:for(T=this.resolvedType.getChildren(o.Reflect.Enum.Value),k=0;k<T.length;k++)if(T[k].name==R||T[k].id==R)return T[k].id;if(this.syntax==="proto3")return(typeof R!="number"||R==R&&R%1!=0)&&U(typeof R,"not an integer"),(R>4294967295||R<0)&&U(typeof R,"not in range for uint32"),R;U(R,"not a valid enum value");case o.TYPES.group:case o.TYPES.message:if(R&&typeof R=="object"||U(typeof R,"object expected"),R instanceof this.resolvedType.clazz)return R;if(R instanceof o.Builder.Message){for(k in A={},R)R.hasOwnProperty(k)&&(A[k]=R[k]);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 o.TYPES.int32:return T<0?n.calculateVarint64(T):n.calculateVarint32(T);case o.TYPES.uint32:return n.calculateVarint32(T);case o.TYPES.sint32:return n.calculateVarint32(n.zigZagEncode32(T));case o.TYPES.fixed32:case o.TYPES.sfixed32:case o.TYPES.float:return 4;case o.TYPES.int64:case o.TYPES.uint64:return n.calculateVarint64(T);case o.TYPES.sint64:return n.calculateVarint64(n.zigZagEncode64(T));case o.TYPES.fixed64:case o.TYPES.sfixed64:return 8;case o.TYPES.bool:return 1;case o.TYPES.enum:return n.calculateVarint32(T);case o.TYPES.double:return 8;case o.TYPES.string:return A=n.calculateUTF8Bytes(T),n.calculateVarint32(A)+A;case o.TYPES.bytes:if(T.remaining()<0)throw Error("Illegal value for "+this.toString(!0)+": "+T.remaining()+" bytes remaining");return n.calculateVarint32(T.remaining())+T.remaining();case o.TYPES.message:return A=this.resolvedType.calculate(T),n.calculateVarint32(A)+A;case o.TYPES.group:return(A=this.resolvedType.calculate(T))+n.calculateVarint32(R<<3|o.WIRE_TYPES.ENDGROUP)}throw Error("[INTERNAL] Illegal value to encode in "+this.toString(!0)+": "+T+" (unknown type)")},a.encodeValue=function(R,T,A){var k,U;if(T===null)return A;switch(this.type){case o.TYPES.int32:T<0?A.writeVarint64(T):A.writeVarint32(T);break;case o.TYPES.uint32:A.writeVarint32(T);break;case o.TYPES.sint32:A.writeVarint32ZigZag(T);break;case o.TYPES.fixed32:A.writeUint32(T);break;case o.TYPES.sfixed32:A.writeInt32(T);break;case o.TYPES.int64:case o.TYPES.uint64:A.writeVarint64(T);break;case o.TYPES.sint64:A.writeVarint64ZigZag(T);break;case o.TYPES.fixed64:A.writeUint64(T);break;case o.TYPES.sfixed64:A.writeInt64(T);break;case o.TYPES.bool:typeof T=="string"?A.writeVarint32(T.toLowerCase()==="false"?0:!!T):A.writeVarint32(T?1:0);break;case o.TYPES.enum:A.writeVarint32(T);break;case o.TYPES.float:A.writeFloat32(T);break;case o.TYPES.double:A.writeFloat64(T);break;case o.TYPES.string:A.writeVString(T);break;case o.TYPES.bytes:if(T.remaining()<0)throw Error("Illegal value for "+this.toString(!0)+": "+T.remaining()+" bytes remaining");k=T.offset,A.writeVarint32(T.remaining()),A.append(T),T.offset=k;break;case o.TYPES.message:U=new n().LE(),this.resolvedType.encode(T,U),A.writeVarint32(U.offset),A.append(U.flip());break;case o.TYPES.group:this.resolvedType.encode(T,A),A.writeVarint32(R<<3|o.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 k,U;switch(this.type){case o.TYPES.int32:return 0|R.readVarint32();case o.TYPES.uint32:return R.readVarint32()>>>0;case o.TYPES.sint32:return 0|R.readVarint32ZigZag();case o.TYPES.fixed32:return R.readUint32()>>>0;case o.TYPES.sfixed32:return 0|R.readInt32();case o.TYPES.int64:return R.readVarint64();case o.TYPES.uint64:return R.readVarint64().toUnsigned();case o.TYPES.sint64:return R.readVarint64ZigZag();case o.TYPES.fixed64:return R.readUint64();case o.TYPES.sfixed64:return R.readInt64();case o.TYPES.bool:return!!R.readVarint32();case o.TYPES.enum:return R.readVarint32();case o.TYPES.float:return R.readFloat();case o.TYPES.double:return R.readDouble();case o.TYPES.string:return R.readVString();case o.TYPES.bytes:if(U=R.readVarint32(),R.remaining()<U)throw Error("Illegal number of bytes for "+this.toString(!0)+": "+U+" required but got only "+R.remaining());return(k=R.clone()).limit=k.offset+U,R.offset+=U,k;case o.TYPES.message:return U=R.readVarint32(),this.resolvedType.decode(R,U);case o.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 o.TYPES.int32:case o.TYPES.sint32:case o.TYPES.sfixed32:case o.TYPES.uint32:case o.TYPES.fixed32:return this.verifyValue(parseInt(R));case o.TYPES.int64:case o.TYPES.sint64:case o.TYPES.sfixed64:case o.TYPES.uint64:case o.TYPES.fixed64:return this.verifyValue(R);case o.TYPES.bool:return R==="true";case o.TYPES.string:return this.verifyValue(R);case o.TYPES.bytes:return n.fromBinary(R)}},a.valueToString=function(R){if(!this.isMapKey)throw Error("valueToString() called on non-map-key element");return this.type===o.TYPES.bytes?R.toString("binary"):R.toString()},w.Element=h,(f=(u=function(R,T,A,k,U,F){d.call(this,R,T,A,k,F),this.className="Message",this.extensions=void 0,this.clazz=null,this.isGroup=!!U,this._fields=null,this._fieldsById=null,this._fieldsByName=null}).prototype=Object.create(d.prototype)).build=function(R){var T,A,k,U;if(this.clazz&&!R)return this.clazz;for(T=function(F,H){function Q(L,$,te,se){var le,Ce,vr,An,$i,Ki,Zt;if(L===null||typeof L!="object")return se&&se instanceof F.Reflect.Enum&&(le=F.Reflect.Enum.getName(se.object,L))!==null?le:L;if(n.isByteBuffer(L))return $?L.toBase64():L.toBuffer();if(F.Long.isLong(L))return te?L.toString():F.Long.fromValue(L);if(Array.isArray(L))return Ce=[],L.forEach(function(Tl,Sl){Ce[Sl]=Q(Tl,$,te,se)}),Ce;if(Ce={},L instanceof F.Map){for(An=(vr=L.entries()).next();!An.done;An=vr.next())Ce[L.keyElem.valueToString(An.value[0])]=Q(An.value[1],$,te,L.valueElem.resolvedType);return Ce}for(Zt in $i=L.$type,Ki=void 0,L)L.hasOwnProperty(Zt)&&(Ce[Zt]=$i&&(Ki=$i.getChild(Zt))?Q(L[Zt],$,te,Ki.resolvedType):Q(L[Zt],$,te));return Ce}var ee,ce,X=H.getChildren(F.Reflect.Message.Field),z=H.getChildren(F.Reflect.Message.OneOf),q=function(L){var $,te,se,le;for(F.Builder.Message.call(this),$=0,te=z.length;te>$;++$)this[z[$].name]=null;for($=0,te=X.length;te>$;++$)this[(se=X[$]).name]=se.repeated?[]:se.map?new F.Map(se):null,!se.required&&H.syntax!=="proto3"||se.defaultValue===null||(this[se.name]=se.defaultValue);if(arguments.length>0)if(arguments.length!==1||L===null||typeof L!="object"||!(typeof L.encode!="function"||L instanceof q)||Array.isArray(L)||L instanceof F.Map||n.isByteBuffer(L)||L instanceof ArrayBuffer||F.Long&&L instanceof F.Long)for($=0,te=arguments.length;te>$;++$)(le=arguments[$])!==void 0&&this.$set(X[$].name,le);else this.$set(L)},J=q.prototype=Object.create(F.Builder.Message.prototype);for(J.add=function(L,$,te){var se=H._fieldsByName[L];if(!te){if(!se)throw Error(this+"#"+L+" is undefined");if(!(se instanceof F.Reflect.Message.Field))throw Error(this+"#"+L+" is not a field: "+se.toString(!0));if(!se.repeated)throw Error(this+"#"+L+" is not a repeated field");$=se.verifyValue($,!0)}return this[L]===null&&(this[L]=[]),this[L].push($),this},J.$add=J.add,J.set=function(L,$,te){var se,le,Ce;if(L&&typeof L=="object"){for(se in te=$,L)L.hasOwnProperty(se)&&($=L[se])!==void 0&&this.$set(se,$,te);return this}if(le=H._fieldsByName[L],te)this[L]=$;else{if(!le)throw Error(this+"#"+L+" is not a field: undefined");if(!(le instanceof F.Reflect.Message.Field))throw Error(this+"#"+L+" is not a field: "+le.toString(!0));this[le.name]=$=le.verifyValue($)}return le&&le.oneof&&(Ce=this[le.oneof.name],$!==null?(Ce!==null&&Ce!==le.name&&(this[Ce]=null),this[le.oneof.name]=le.name):Ce===L&&(this[le.oneof.name]=null)),this},J.$set=J.set,J.get=function(L,$){if($)return this[L];var te=H._fieldsByName[L];if(!(te&&te instanceof F.Reflect.Message.Field))throw Error(this+"#"+L+" is not a field: undefined");if(!(te instanceof F.Reflect.Message.Field))throw Error(this+"#"+L+" is not a field: "+te.toString(!0));return this[te.name]},J.$get=J.get,ee=0;ee<X.length;ee++)(ce=X[ee])instanceof F.Reflect.Message.ExtensionField||H.builder.options.populateAccessors&&function(L){var $,te,se,le=L.originalName.replace(/(_[a-zA-Z])/g,function(Ce){return Ce.toUpperCase().replace("_","")});le=le.substring(0,1).toUpperCase()+le.substring(1),$=L.originalName.replace(/([A-Z])/g,function(Ce){return"_"+Ce}),te=function(Ce,vr){return this[L.name]=vr?Ce:L.verifyValue(Ce),this},se=function(){return this[L.name]},H.getChild("set"+le)===null&&(J["set"+le]=te),H.getChild("set_"+$)===null&&(J["set_"+$]=te),H.getChild("get"+le)===null&&(J["get"+le]=se),H.getChild("get_"+$)===null&&(J["get_"+$]=se)}(ce);return J.encode=function(L,$){var te,se;typeof L=="boolean"&&($=L,L=void 0),te=!1,L||(L=new t,te=!0),se=L.littleEndian;try{return H.encode(this,L.LE(),$),(te?L.flip():L).LE(se)}catch(le){throw L.LE(se),le}},q.encode=function(L,$,te){return new q(L).encode($,te)},J.calculate=function(){return H.calculate(this)},J.encodeDelimited=function(L){var $,te=!1;return L||(L=new n,te=!0),$=new n().LE(),H.encode(this,$).flip(),L.writeVarint32($.remaining()),L.append($),te?L.flip():L},J.encodeAB=function(){try{return this.encode().toArrayBuffer()}catch(L){throw L.encoded&&(L.encoded=L.encoded.toArrayBuffer()),L}},J.toArrayBuffer=J.encodeAB,J.encodeNB=function(){try{return this.encode().toBuffer()}catch(L){throw L.encoded&&(L.encoded=L.encoded.toBuffer()),L}},J.toBuffer=J.encodeNB,J.encode64=function(){try{return this.encode().toBase64()}catch(L){throw L.encoded&&(L.encoded=L.encoded.toBase64()),L}},J.toBase64=J.encode64,J.encodeHex=function(){try{return this.encode().toHex()}catch(L){throw L.encoded&&(L.encoded=L.encoded.toHex()),L}},J.toHex=J.encodeHex,J.toRaw=function(L,$){return Q(this,!!L,!!$,this.$type)},J.encodeJSON=function(){return JSON.stringify(Q(this,!0,!0,this.$type))},q.decode=function(L,$){var te,se;typeof L=="string"&&(L=n.wrap(L,$||"base64")),te=(L=n.isByteBuffer(L)?L:n.wrap(L)).littleEndian;try{return se=H.decode(L.LE()),L.LE(te),se}catch(le){throw L.LE(te),le}},q.decodeDelimited=function(L,$){var te,se,le;if(typeof L=="string"&&(L=n.wrap(L,$||"base64")),(L=n.isByteBuffer(L)?L:n.wrap(L)).remaining()<1)return null;if(te=L.offset,se=L.readVarint32(),L.remaining()<se)return L.offset=te,null;try{return le=H.decode(L.slice(L.offset,L.offset+se).LE()),L.offset+=se,le}catch(Ce){throw L.offset+=se,Ce}},q.decode64=function(L){return q.decode(L,"base64")},q.decodeHex=function(L){return q.decode(L,"hex")},q.decodeJSON=function(L){return new q(JSON.parse(L))},J.toString=function(){return H.toString()},Object.defineProperty&&(Object.defineProperty(q,"$options",{value:H.buildOpt()}),Object.defineProperty(J,"$options",{value:q.$options}),Object.defineProperty(q,"$type",{value:H}),Object.defineProperty(J,"$type",{value:H})),q}(o,this),this._fields=[],this._fieldsById={},this._fieldsByName={},k=0,U=this.children.length;U>k;k++)if((A=this.children[k])instanceof y||A instanceof u||A instanceof N){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[k].toString(!0));return this.clazz=T},f.encode=function(R,T,A){var k,U,F,H,Q,ee=null;for(F=0,H=this._fields.length;H>F;++F)U=R[(k=this._fields[F]).name],k.required&&U===null?ee===null&&(ee=k):k.encode(A?U:k.verifyValue(U),T,R);if(ee!==null)throw(Q=Error("Missing at least one required field for "+this.toString(!0)+": "+ee)).encoded=T,Q;return T},f.calculate=function(R){for(var T,A,k=0,U=0,F=this._fields.length;F>U;++U){if(A=R[(T=this._fields[U]).name],T.required&&A===null)throw Error("Missing at least one required field for "+this.toString(!0)+": "+T);k+=T.calculate(A,R)}return k},f.decode=function(R,T,A){var k,U,F,H,Q,ee,ce,X,z,q,J,L;for(T=typeof T=="number"?T:-1,Q=R.offset,ee=new this.clazz;R.offset<Q+T||T===-1&&R.remaining()>0;){if(F=(k=R.readVarint32())>>>3,(U=7&k)===o.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?ee[H.name].push(H.decode(U,R)):H.map?(X=H.decode(U,R),ee[H.name].set(X[0],X[1])):(ee[H.name]=H.decode(U,R),H.oneof&&((z=ee[H.oneof.name])!==null&&z!==H.name&&(ee[z]=null),ee[H.oneof.name]=H.name));else switch(U){case o.WIRE_TYPES.VARINT:R.readVarint32();break;case o.WIRE_TYPES.BITS32:R.offset+=4;break;case o.WIRE_TYPES.BITS64:R.offset+=8;break;case o.WIRE_TYPES.LDELIM:ce=R.readVarint32(),R.offset+=ce;break;case o.WIRE_TYPES.STARTGROUP:for(;c(F,R););break;default:throw Error("Illegal wire type for unknown field "+F+" in "+this.toString(!0)+"#decode: "+U)}}for(q=0,J=this._fields.length;J>q;++q)if(ee[(H=this._fields[q]).name]===null)if(this.syntax==="proto3")ee[H.name]=H.defaultValue;else{if(H.required)throw(L=Error("Missing at least one required field for "+this.toString(!0)+": "+H.name)).decoded=ee,L;o.populateDefaults&&H.defaultValue!==null&&(ee[H.name]=H.defaultValue)}return ee},w.Message=u,(m=(p=function(R,T,A,k,U,F,H,Q,ee,ce){V.call(this,R,T,F),this.className="Message.Field",this.required=A==="required",this.repeated=A==="repeated",this.map=A==="map",this.keyType=k||null,this.type=U,this.resolvedType=null,this.id=H,this.options=Q||{},this.defaultValue=null,this.oneof=ee||null,this.syntax=ce||"proto2",this.originalName=this.name,this.element=null,this.keyElement=null,!this.builder.options.convertFieldsToCamelCase||this instanceof u.ExtensionField||(this.name=o.Util.toCamelCase(this.name))}).prototype=Object.create(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,k,U;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!==o.TYPES.message&&A(typeof R,"proto3 field without field presence cannot be null"),null;if(this.repeated&&!T){for(Array.isArray(R)||(R=[R]),U=[],k=0;k<R.length;k++)U.push(this.element.verifyValue(R[k]));return U}return this.map&&!T?R instanceof o.Map?R:(R instanceof Object||A(typeof R,"expected ProtoBuf.Map or raw object for map field"),new o.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 o.TYPES.int32:case o.TYPES.sint32:case o.TYPES.sfixed32:case o.TYPES.uint32:case o.TYPES.fixed32:return R!==0;case o.TYPES.int64:case o.TYPES.sint64:case o.TYPES.sfixed64:case o.TYPES.uint64:case o.TYPES.fixed64:return R.low!==0||R.high!==0;case o.TYPES.bool:return R;case o.TYPES.float:case o.TYPES.double:return R!==0;case o.TYPES.string:return R.length>0;case o.TYPES.bytes:return R.remaining()>0;case o.TYPES.enum:return R!==0;case o.TYPES.message:return R!==null;default:return!0}},m.encode=function(R,T,A){var k,U,F,H,Q;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&&o.PACKABLE_WIRE_TYPES.indexOf(this.type.wireType)>=0){for(T.writeVarint32(this.id<<3|o.WIRE_TYPES.LDELIM),T.ensureCapacity(T.offset+=1),U=T.offset,k=0;k<R.length;k++)this.element.encodeValue(this.id,R[k],T);F=T.offset-U,(H=n.calculateVarint32(F))>1&&(Q=T.slice(U,T.offset),U+=H-1,T.offset=U,T.append(Q)),T.writeVarint32(F,U-H)}else for(k=0;k<R.length;k++)T.writeVarint32(this.id<<3|this.type.wireType),this.element.encodeValue(this.id,R[k],T);else this.map?R.forEach(function(ee,ce){var X=n.calculateVarint32(8|this.keyType.wireType)+this.keyElement.calculateLength(1,ce)+n.calculateVarint32(16|this.type.wireType)+this.element.calculateLength(2,ee);T.writeVarint32(this.id<<3|o.WIRE_TYPES.LDELIM),T.writeVarint32(X),T.writeVarint32(8|this.keyType.wireType),this.keyElement.encodeValue(1,ce,T),T.writeVarint32(16|this.type.wireType),this.element.encodeValue(2,ee,T)},this):this.hasWirePresence(R,A)&&(T.writeVarint32(this.id<<3|this.type.wireType),this.element.encodeValue(this.id,R,T))}catch(ee){throw Error("Illegal value for "+this.toString(!0)+": "+R+" ("+ee+")")}return T},m.calculate=function(R,T){var A,k,U;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&&o.PACKABLE_WIRE_TYPES.indexOf(this.type.wireType)>=0){for(A+=n.calculateVarint32(this.id<<3|o.WIRE_TYPES.LDELIM),U=0,k=0;k<R.length;k++)U+=this.element.calculateLength(this.id,R[k]);A+=n.calculateVarint32(U),A+=U}else for(k=0;k<R.length;k++)A+=n.calculateVarint32(this.id<<3|this.type.wireType),A+=this.element.calculateLength(this.id,R[k]);else this.map?R.forEach(function(F,H){var Q=n.calculateVarint32(8|this.keyType.wireType)+this.keyElement.calculateLength(1,H)+n.calculateVarint32(16|this.type.wireType)+this.element.calculateLength(2,F);A+=n.calculateVarint32(this.id<<3|o.WIRE_TYPES.LDELIM),A+=n.calculateVarint32(Q),A+=Q},this):this.hasWirePresence(R,T)&&(A+=n.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 k,U,F,H,Q,ee,ce;if(!(!this.map&&R==this.type.wireType||!A&&this.repeated&&this.options.packed&&R==o.WIRE_TYPES.LDELIM||this.map&&R==o.WIRE_TYPES.LDELIM))throw Error("Illegal wire type for field "+this.toString(!0)+": "+R+" ("+this.type.wireType+" expected)");if(R==o.WIRE_TYPES.LDELIM&&this.repeated&&this.options.packed&&o.PACKABLE_WIRE_TYPES.indexOf(this.type.wireType)>=0&&!A){for(U=T.readVarint32(),U=T.offset+U,F=[];T.offset<U;)F.push(this.decode(this.type.wireType,T,!0));return F}if(this.map){if(H=h.defaultFieldValue(this.keyType),k=h.defaultFieldValue(this.type),U=T.readVarint32(),T.remaining()<U)throw Error("Illegal number of bytes for "+this.toString(!0)+": "+U+" required but got only "+T.remaining());for((Q=T.clone()).limit=Q.offset+U,T.offset+=U;Q.remaining()>0;)if(R=7&(ee=Q.readVarint32()),(ce=ee>>>3)==1)H=this.keyElement.decode(Q,R,ce);else{if(ce!==2)throw Error("Unexpected tag in map field key/value submessage");k=this.element.decode(Q,R,ce)}return[H,k]}return this.element.decode(T,R,this.id)},w.Message.Field=p,(_=function(R,T,A,k,U,F,H){p.call(this,R,T,A,null,k,U,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,k,U){d.call(this,R,T,A,k,U),this.className="Enum",this.object=null}).getName=function(R,T){var A,k,U=Object.keys(R);for(k=0;k<U.length;++k)if(R[A=U[k]]===T)return A;return null},(y.prototype=Object.create(d.prototype)).build=function(R){var T,A,k,U;if(this.object&&!R)return this.object;for(T=new o.Builder.Enum,k=0,U=(A=this.getChildren(y.Value)).length;U>k;++k)T[A[k].name]=A[k].id;return Object.defineProperty&&Object.defineProperty(T,"$options",{value:this.buildOpt(),enumerable:!1}),this.object=T},w.Enum=y,(C=function(R,T,A,k){V.call(this,R,T,A),this.className="Enum.Value",this.id=k}).prototype=Object.create(V.prototype),w.Enum.Value=C,(b=function(R,T,A,k){V.call(this,R,T,A),this.field=k}).prototype=Object.create(V.prototype),w.Extension=b,((N=function(R,T,A,k){d.call(this,R,T,A,k),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 k,U=function(Q){T.Builder.Service.call(this),this.rpcImpl=Q||function(ee,ce,X){setTimeout(X.bind(this,Error("Not implemented, see: https://github.com/dcodeIO/ProtoBuf.js/wiki/Services")),0)}},F=U.prototype=Object.create(T.Builder.Service.prototype),H=A.getChildren(T.Reflect.Service.RPCMethod);for(k=0;k<H.length;k++)(function(Q){F[Q.name]=function(ee,ce){try{try{ee=Q.resolvedRequestType.clazz.decode(n.wrap(ee))}catch(X){if(!(X instanceof TypeError))throw X}if(ee===null||typeof ee!="object")throw Error("Illegal arguments");ee instanceof Q.resolvedRequestType.clazz||(ee=new Q.resolvedRequestType.clazz(ee)),this.rpcImpl(Q.fqn(),ee,function(X,z){if(!X){try{z=Q.resolvedResponseType.clazz.decode(z)}catch{}return z&&z instanceof Q.resolvedResponseType.clazz?void ce(null,z):void ce(Error("Illegal response type received in service method "+A.name+"#"+Q.name))}ce(X)})}catch(X){setTimeout(ce.bind(this,X),0)}},U[Q.name]=function(ee,ce,X){new U(ee)[Q.name](ce,X)},Object.defineProperty&&(Object.defineProperty(U[Q.name],"$options",{value:Q.buildOpt()}),Object.defineProperty(F[Q.name],"$options",{value:U[Q.name].$options}))})(H[k]);return Object.defineProperty&&(Object.defineProperty(U,"$options",{value:A.buildOpt()}),Object.defineProperty(F,"$options",{value:U.$options}),Object.defineProperty(U,"$type",{value:A}),Object.defineProperty(F,"$type",{value:A})),U}(o,this)},w.Service=N,((S=function(R,T,A,k){V.call(this,R,T,A),this.className="Service.Method",this.options=k||{}}).prototype=Object.create(V.prototype)).buildOpt=l.buildOpt,w.Service.Method=S,(E=function(R,T,A,k,U,F,H,Q){S.call(this,R,T,A,Q),this.className="Service.RPCMethod",this.requestName=k,this.responseName=U,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(o,s,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"||!s.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,N;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=o.Util.toCamelCase(C)),b=new c.Message.ExtensionField(this,p,v.rule,v.type,this.ptr.fqn()+"."+C,v.id,v.options),N=new c.Extension(this,this.ptr,v.name,b),b.extension=N,this.ptr.addChild(N),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,N="/";if(typeof u=="string"){if(o.Util.IS_NODE,this.files[u]===!0)return this.reset();this.files[u]=!0}else if(typeof u=="object"){if(f=u.root,o.Util.IS_NODE,(f.indexOf("\\")>=0||u.file.indexOf("\\")>=0)&&(N="\\"),p=f+N+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)&&(N="\\")):typeof u=="string"?this.importRoot?m=this.importRoot:u.indexOf("/")>=0?(m=u.replace(/\/[^\/]*$/,""))===""&&(m="/"):u.indexOf("\\")>=0?(m=u.replace(/\\[^\\]*$/,""),N="\\"):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+N+y,this.files[y]===!0))continue;if(/\.proto$/i.test(y)&&!o.DotProto&&(y=y.replace(/\.proto$/,".json")),(C=o.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(o.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(s.TYPE.test(this.ptr.type))this.ptr.type=o.TYPES[this.ptr.type];else{if(!s.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=o.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?o.TYPES.group:o.TYPES.message}}if(this.ptr.map){if(!s.TYPE.test(this.ptr.keyType))throw Error("illegal key type for map field in "+this.ptr.toString(!0)+": "+this.ptr.keyType);this.ptr.keyType=o.TYPES[this.ptr.keyType]}}else if(this.ptr instanceof o.Reflect.Service.Method){if(!(this.ptr instanceof o.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 o.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 o.Reflect.Message))throw Error("Illegal type reference in "+this.ptr.toString(!0)+": "+this.ptr.responseName);this.ptr.resolvedResponseType=a}else if(!(this.ptr instanceof o.Reflect.Message.OneOf||this.ptr instanceof o.Reflect.Extension||this.ptr instanceof o.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(o,s){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 s.Element(h.keyType,null,!0,h.syntax),this.valueElem=new s.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(o,s,c){return(typeof s=="string"||s&&typeof s.file=="string"&&typeof s.root=="string")&&(c=s,s=void 0),i.loadJson(i.DotProto.Parser.parse(o),s,c)},i.protoFromString=i.loadProto,i.loadProtoFile=function(o,s,c){if(s&&typeof s=="object"?(c=s,s=null):s&&typeof s=="function"||(s=null),s)return i.Util.fetch(typeof o=="string"?o:o.root+"/"+o.file,function(l){if(l!==null)try{s(null,i.loadProto(l,c,o))}catch(h){s(h)}else s(Error("Failed to fetch file"))});var d=i.Util.fetch(typeof o=="object"?o.root+"/"+o.file:o);return d===null?null:i.loadProto(d,c,o)},i.protoFromFile=i.loadProtoFile,i.newBuilder=function(o){return(o=o||{}).convertFieldsToCamelCase===void 0&&(o.convertFieldsToCamelCase=i.convertFieldsToCamelCase),o.populateAccessors===void 0&&(o.populateAccessors=i.populateAccessors),new i.Builder(o)},i.loadJson=function(o,s,c){return(typeof s=="string"||s&&typeof s.file=="string"&&typeof s.root=="string")&&(c=s,s=null),s&&typeof s=="object"||(s=i.newBuilder()),typeof o=="string"&&(o=JSON.parse(o)),s.import(o,c),s.resolveAll(),s},i.loadJsonFile=function(o,s,c){if(s&&typeof s=="object"?(c=s,s=null):s&&typeof s=="function"||(s=null),s)return i.Util.fetch(typeof o=="string"?o:o.root+"/"+o.file,function(l){if(l!==null)try{s(null,i.loadJson(JSON.parse(l),c,o))}catch(h){s(h)}else s(Error("Failed to fetch file"))});var d=i.Util.fetch(typeof o=="object"?o.root+"/"+o.file:o);return d===null?null:i.loadJson(JSON.parse(d),c,o)},r=Ga,i.loadProto(r,void 0,"").build("Modules").probuf}(function(t){function e(a){var u=0;return function(){return u<a.length?a.charCodeAt(u++):null}}function n(){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,N=-7,S=f?m-1:0,E=f?-1:1,w=a[u+S];for(S+=E,_=w&(1<<-N)-1,w>>=-N,N+=y;N>0;_=256*_+a[u+S],S+=E,N-=8);for(v=_&(1<<-N)-1,_>>=-N,N+=p;N>0;v=256*v+a[u+S],S+=E,N-=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,N=(1<<b)-1,S=N>>1,E=m===23?Math.pow(2,-24)-Math.pow(2,-77):0,w=p?0:_-1,V=p?1:-1,K=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=N):(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>=N?(y=0,v=N):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*K}var o,s,c,d,l,h=function(a,u,f){if(a===void 0&&(a=h.DEFAULT_CAPACITY),u===void 0&&(u=h.DEFAULT_ENDIAN),f===void 0&&(f=h.DEFAULT_NOASSERT),!f){if((a|=0)<0)throw RangeError("Illegal capacity");u=!!u,f=!!f}this.buffer=a===0?s:new ArrayBuffer(a),this.view=a===0?null:new Uint8Array(this.buffer),this.offset=0,this.markedOffset=-1,this.limit=a,this.littleEndian=u,this.noAssert=f};return h.VERSION="5.0.1",h.LITTLE_ENDIAN=!0,h.BIG_ENDIAN=!1,h.DEFAULT_CAPACITY=16,h.DEFAULT_ENDIAN=h.BIG_ENDIAN,h.DEFAULT_NOASSERT=!1,h.Long=t||null,(o=h.prototype).__isByteBuffer__,Object.defineProperty(o,"__isByteBuffer__",{value:!0,enumerable:!1,configurable:!1}),s=new ArrayBuffer(0),c=String.fromCharCode,h.accessor=function(){return Uint8Array},h.allocate=function(a,u,f){return new h(a,u,f)},h.concat=function(a,u,f,p){var m,_,v,y,C,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=o.clone.call(a)).markedOffset=-1,m;if(a instanceof Uint8Array)m=new h(0,f,p),a.length>0&&(m.buffer=a.buffer,m.offset=a.byteOffset,m.limit=a.byteOffset+a.byteLength,m.view=new Uint8Array(a.buffer));else if(a instanceof ArrayBuffer)m=new h(0,f,p),a.byteLength>0&&(m.buffer=a,m.offset=0,m.limit=a.byteLength,m.view=a.byteLength>0?new Uint8Array(a):null);else{if(Object.prototype.toString.call(a)!=="[object Array]")throw TypeError("Illegal buffer");for((m=new h(a.length,f,p)).limit=a.length,_=0;_<a.length;++_)m.view[_]=a[_]}return m},o.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},o.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},o.readBytes=function(a,u){var f,p=u===void 0;if(p&&(u=this.offset),!this.noAssert){if(typeof u!="number"||u%1!=0)throw TypeError("Illegal offset: "+u+" (not an integer)");if((u>>>=0)<0||u+a>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+u+" (+"+a+") <= "+this.buffer.byteLength)}return f=this.slice(u,u+a),p&&(this.offset+=a),f},o.writeBytes=o.append,o.writeInt8=function(a,u){var f,p=u===void 0;if(p&&(u=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal value: "+a+" (not an integer)");if(a|=0,typeof u!="number"||u%1!=0)throw TypeError("Illegal offset: "+u+" (not an integer)");if((u>>>=0)<0||u+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+u+" (+0) <= "+this.buffer.byteLength)}return(u+=1)>(f=this.buffer.byteLength)&&this.resize((f*=2)>u?f:u),u-=1,this.view[u]=a,p&&(this.offset+=1),this},o.writeByte=o.writeInt8,o.readInt8=function(a){var u,f=a===void 0;if(f&&(a=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal offset: "+a+" (not an integer)");if((a>>>=0)<0||a+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+1) <= "+this.buffer.byteLength)}return(128&(u=this.view[a]))==128&&(u=-(255-u+1)),f&&(this.offset+=1),u},o.readByte=o.readInt8,o.writeUint8=function(a,u){var f,p=u===void 0;if(p&&(u=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal value: "+a+" (not an integer)");if(a>>>=0,typeof u!="number"||u%1!=0)throw TypeError("Illegal offset: "+u+" (not an integer)");if((u>>>=0)<0||u+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+u+" (+0) <= "+this.buffer.byteLength)}return(u+=1)>(f=this.buffer.byteLength)&&this.resize((f*=2)>u?f:u),u-=1,this.view[u]=a,p&&(this.offset+=1),this},o.writeUInt8=o.writeUint8,o.readUint8=function(a){var u,f=a===void 0;if(f&&(a=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal offset: "+a+" (not an integer)");if((a>>>=0)<0||a+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+1) <= "+this.buffer.byteLength)}return u=this.view[a],f&&(this.offset+=1),u},o.readUInt8=o.readUint8,o.writeInt16=function(a,u){var f,p=u===void 0;if(p&&(u=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal value: "+a+" (not an integer)");if(a|=0,typeof u!="number"||u%1!=0)throw TypeError("Illegal offset: "+u+" (not an integer)");if((u>>>=0)<0||u+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+u+" (+0) <= "+this.buffer.byteLength)}return(u+=2)>(f=this.buffer.byteLength)&&this.resize((f*=2)>u?f:u),u-=2,this.littleEndian?(this.view[u+1]=(65280&a)>>>8,this.view[u]=255&a):(this.view[u]=(65280&a)>>>8,this.view[u+1]=255&a),p&&(this.offset+=2),this},o.writeShort=o.writeInt16,o.readInt16=function(a){var u,f=a===void 0;if(f&&(a=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal offset: "+a+" (not an integer)");if((a>>>=0)<0||a+2>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+2) <= "+this.buffer.byteLength)}return u=0,this.littleEndian?(u=this.view[a],u|=this.view[a+1]<<8):(u=this.view[a]<<8,u|=this.view[a+1]),(32768&u)==32768&&(u=-(65535-u+1)),f&&(this.offset+=2),u},o.readShort=o.readInt16,o.writeUint16=function(a,u){var f,p=u===void 0;if(p&&(u=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal value: "+a+" (not an integer)");if(a>>>=0,typeof u!="number"||u%1!=0)throw TypeError("Illegal offset: "+u+" (not an integer)");if((u>>>=0)<0||u+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+u+" (+0) <= "+this.buffer.byteLength)}return(u+=2)>(f=this.buffer.byteLength)&&this.resize((f*=2)>u?f:u),u-=2,this.littleEndian?(this.view[u+1]=(65280&a)>>>8,this.view[u]=255&a):(this.view[u]=(65280&a)>>>8,this.view[u+1]=255&a),p&&(this.offset+=2),this},o.writeUInt16=o.writeUint16,o.readUint16=function(a){var u,f=a===void 0;if(f&&(a=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal offset: "+a+" (not an integer)");if((a>>>=0)<0||a+2>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+2) <= "+this.buffer.byteLength)}return u=0,this.littleEndian?(u=this.view[a],u|=this.view[a+1]<<8):(u=this.view[a]<<8,u|=this.view[a+1]),f&&(this.offset+=2),u},o.readUInt16=o.readUint16,o.writeInt32=function(a,u){var f,p=u===void 0;if(p&&(u=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal value: "+a+" (not an integer)");if(a|=0,typeof u!="number"||u%1!=0)throw TypeError("Illegal offset: "+u+" (not an integer)");if((u>>>=0)<0||u+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+u+" (+0) <= "+this.buffer.byteLength)}return(u+=4)>(f=this.buffer.byteLength)&&this.resize((f*=2)>u?f:u),u-=4,this.littleEndian?(this.view[u+3]=255&a>>>24,this.view[u+2]=255&a>>>16,this.view[u+1]=255&a>>>8,this.view[u]=255&a):(this.view[u]=255&a>>>24,this.view[u+1]=255&a>>>16,this.view[u+2]=255&a>>>8,this.view[u+3]=255&a),p&&(this.offset+=4),this},o.writeInt=o.writeInt32,o.readInt32=function(a){var u,f=a===void 0;if(f&&(a=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal offset: "+a+" (not an integer)");if((a>>>=0)<0||a+4>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+4) <= "+this.buffer.byteLength)}return u=0,this.littleEndian?(u=this.view[a+2]<<16,u|=this.view[a+1]<<8,u|=this.view[a],u+=this.view[a+3]<<24>>>0):(u=this.view[a+1]<<16,u|=this.view[a+2]<<8,u|=this.view[a+3],u+=this.view[a]<<24>>>0),u|=0,f&&(this.offset+=4),u},o.readInt=o.readInt32,o.writeUint32=function(a,u){var f,p=u===void 0;if(p&&(u=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal value: "+a+" (not an integer)");if(a>>>=0,typeof u!="number"||u%1!=0)throw TypeError("Illegal offset: "+u+" (not an integer)");if((u>>>=0)<0||u+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+u+" (+0) <= "+this.buffer.byteLength)}return(u+=4)>(f=this.buffer.byteLength)&&this.resize((f*=2)>u?f:u),u-=4,this.littleEndian?(this.view[u+3]=255&a>>>24,this.view[u+2]=255&a>>>16,this.view[u+1]=255&a>>>8,this.view[u]=255&a):(this.view[u]=255&a>>>24,this.view[u+1]=255&a>>>16,this.view[u+2]=255&a>>>8,this.view[u+3]=255&a),p&&(this.offset+=4),this},o.writeUInt32=o.writeUint32,o.readUint32=function(a){var u,f=a===void 0;if(f&&(a=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal offset: "+a+" (not an integer)");if((a>>>=0)<0||a+4>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+4) <= "+this.buffer.byteLength)}return u=0,this.littleEndian?(u=this.view[a+2]<<16,u|=this.view[a+1]<<8,u|=this.view[a],u+=this.view[a+3]<<24>>>0):(u=this.view[a+1]<<16,u|=this.view[a+2]<<8,u|=this.view[a+3],u+=this.view[a]<<24>>>0),f&&(this.offset+=4),u},o.readUInt32=o.readUint32,t&&(o.writeInt64=function(a,u){var f,p,m,_=u===void 0;if(_&&(u=this.offset),!this.noAssert){if(typeof a=="number")a=t.fromNumber(a);else if(typeof a=="string")a=t.fromString(a);else if(!(a&&a instanceof t))throw TypeError("Illegal value: "+a+" (not an integer or Long)");if(typeof u!="number"||u%1!=0)throw TypeError("Illegal offset: "+u+" (not an integer)");if((u>>>=0)<0||u+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+u+" (+0) <= "+this.buffer.byteLength)}return typeof a=="number"?a=t.fromNumber(a):typeof a=="string"&&(a=t.fromString(a)),(u+=8)>(f=this.buffer.byteLength)&&this.resize((f*=2)>u?f:u),u-=8,p=a.low,m=a.high,this.littleEndian?(this.view[u+3]=255&p>>>24,this.view[u+2]=255&p>>>16,this.view[u+1]=255&p>>>8,this.view[u]=255&p,u+=4,this.view[u+3]=255&m>>>24,this.view[u+2]=255&m>>>16,this.view[u+1]=255&m>>>8,this.view[u]=255&m):(this.view[u]=255&m>>>24,this.view[u+1]=255&m>>>16,this.view[u+2]=255&m>>>8,this.view[u+3]=255&m,u+=4,this.view[u]=255&p>>>24,this.view[u+1]=255&p>>>16,this.view[u+2]=255&p>>>8,this.view[u+3]=255&p),_&&(this.offset+=8),this},o.writeLong=o.writeInt64,o.readInt64=function(a){var u,f,p,m=a===void 0;if(m&&(a=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal offset: "+a+" (not an integer)");if((a>>>=0)<0||a+8>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+8) <= "+this.buffer.byteLength)}return u=0,f=0,this.littleEndian?(u=this.view[a+2]<<16,u|=this.view[a+1]<<8,u|=this.view[a],u+=this.view[a+3]<<24>>>0,a+=4,f=this.view[a+2]<<16,f|=this.view[a+1]<<8,f|=this.view[a],f+=this.view[a+3]<<24>>>0):(f=this.view[a+1]<<16,f|=this.view[a+2]<<8,f|=this.view[a+3],f+=this.view[a]<<24>>>0,a+=4,u=this.view[a+1]<<16,u|=this.view[a+2]<<8,u|=this.view[a+3],u+=this.view[a]<<24>>>0),p=new t(u,f,!1),m&&(this.offset+=8),p},o.readLong=o.readInt64,o.writeUint64=function(a,u){var f,p,m,_=u===void 0;if(_&&(u=this.offset),!this.noAssert){if(typeof a=="number")a=t.fromNumber(a);else if(typeof a=="string")a=t.fromString(a);else if(!(a&&a instanceof t))throw TypeError("Illegal value: "+a+" (not an integer or Long)");if(typeof u!="number"||u%1!=0)throw TypeError("Illegal offset: "+u+" (not an integer)");if((u>>>=0)<0||u+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+u+" (+0) <= "+this.buffer.byteLength)}return typeof a=="number"?a=t.fromNumber(a):typeof a=="string"&&(a=t.fromString(a)),(u+=8)>(f=this.buffer.byteLength)&&this.resize((f*=2)>u?f:u),u-=8,p=a.low,m=a.high,this.littleEndian?(this.view[u+3]=255&p>>>24,this.view[u+2]=255&p>>>16,this.view[u+1]=255&p>>>8,this.view[u]=255&p,u+=4,this.view[u+3]=255&m>>>24,this.view[u+2]=255&m>>>16,this.view[u+1]=255&m>>>8,this.view[u]=255&m):(this.view[u]=255&m>>>24,this.view[u+1]=255&m>>>16,this.view[u+2]=255&m>>>8,this.view[u+3]=255&m,u+=4,this.view[u]=255&p>>>24,this.view[u+1]=255&p>>>16,this.view[u+2]=255&p>>>8,this.view[u+3]=255&p),_&&(this.offset+=8),this},o.writeUInt64=o.writeUint64,o.readUint64=function(a){var u,f,p,m=a===void 0;if(m&&(a=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal offset: "+a+" (not an integer)");if((a>>>=0)<0||a+8>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+8) <= "+this.buffer.byteLength)}return u=0,f=0,this.littleEndian?(u=this.view[a+2]<<16,u|=this.view[a+1]<<8,u|=this.view[a],u+=this.view[a+3]<<24>>>0,a+=4,f=this.view[a+2]<<16,f|=this.view[a+1]<<8,f|=this.view[a],f+=this.view[a+3]<<24>>>0):(f=this.view[a+1]<<16,f|=this.view[a+2]<<8,f|=this.view[a+3],f+=this.view[a]<<24>>>0,a+=4,u=this.view[a+1]<<16,u|=this.view[a+2]<<8,u|=this.view[a+3],u+=this.view[a]<<24>>>0),p=new t(u,f,!0),m&&(this.offset+=8),p},o.readUInt64=o.readUint64),o.writeFloat32=function(a,u){var f,p=u===void 0;if(p&&(u=this.offset),!this.noAssert){if(typeof a!="number")throw TypeError("Illegal value: "+a+" (not a number)");if(typeof u!="number"||u%1!=0)throw TypeError("Illegal offset: "+u+" (not an integer)");if((u>>>=0)<0||u+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+u+" (+0) <= "+this.buffer.byteLength)}return(u+=4)>(f=this.buffer.byteLength)&&this.resize((f*=2)>u?f:u),u-=4,i(this.view,a,u,this.littleEndian,23,4),p&&(this.offset+=4),this},o.writeFloat=o.writeFloat32,o.readFloat32=function(a){var u,f=a===void 0;if(f&&(a=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal offset: "+a+" (not an integer)");if((a>>>=0)<0||a+4>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+4) <= "+this.buffer.byteLength)}return u=r(this.view,a,this.littleEndian,23,4),f&&(this.offset+=4),u},o.readFloat=o.readFloat32,o.writeFloat64=function(a,u){var f,p=u===void 0;if(p&&(u=this.offset),!this.noAssert){if(typeof a!="number")throw TypeError("Illegal value: "+a+" (not a number)");if(typeof u!="number"||u%1!=0)throw TypeError("Illegal offset: "+u+" (not an integer)");if((u>>>=0)<0||u+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+u+" (+0) <= "+this.buffer.byteLength)}return(u+=8)>(f=this.buffer.byteLength)&&this.resize((f*=2)>u?f:u),u-=8,i(this.view,a,u,this.littleEndian,52,8),p&&(this.offset+=8),this},o.writeDouble=o.writeFloat64,o.readFloat64=function(a){var u,f=a===void 0;if(f&&(a=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal offset: "+a+" (not an integer)");if((a>>>=0)<0||a+8>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+8) <= "+this.buffer.byteLength)}return u=r(this.view,a,this.littleEndian,52,8),f&&(this.offset+=8),u},o.readDouble=o.readFloat64,h.MAX_VARINT32_BYTES=5,h.calculateVarint32=function(a){return(a>>>=0)<128?1:a<16384?2:1<<21>a?3:1<<28>a?4:5},h.zigZagEncode32=function(a){return((a|=0)<<1^a>>31)>>>0},h.zigZagDecode32=function(a){return 0|a>>>1^-(1&a)},o.writeVarint32=function(a,u){var f,p,m,_=u===void 0;if(_&&(u=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal value: "+a+" (not an integer)");if(a|=0,typeof u!="number"||u%1!=0)throw TypeError("Illegal offset: "+u+" (not an integer)");if((u>>>=0)<0||u+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+u+" (+0) <= "+this.buffer.byteLength)}for((u+=p=h.calculateVarint32(a))>(m=this.buffer.byteLength)&&this.resize((m*=2)>u?m:u),u-=p,a>>>=0;a>=128;)f=128|127&a,this.view[u++]=f,a>>>=7;return this.view[u++]=a,_?(this.offset=u,this):p},o.writeVarint32ZigZag=function(a,u){return this.writeVarint32(h.zigZagEncode32(a),u)},o.readVarint32=function(a){var u,f,p,m,_=a===void 0;if(_&&(a=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal offset: "+a+" (not an integer)");if((a>>>=0)<0||a+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+1) <= "+this.buffer.byteLength)}f=0,p=0;do{if(!this.noAssert&&a>this.limit)throw(m=Error("Truncated")).truncated=!0,m;u=this.view[a++],f<5&&(p|=(127&u)<<7*f),++f}while((128&u)!=0);return p|=0,_?(this.offset=a,p):{value:p,length:f}},o.readVarint32ZigZag=function(a){var u=this.readVarint32(a);return typeof u=="object"?u.value=h.zigZagDecode32(u.value):u=h.zigZagDecode32(u),u},t&&(h.MAX_VARINT64_BYTES=10,h.calculateVarint64=function(a){typeof a=="number"?a=t.fromNumber(a):typeof a=="string"&&(a=t.fromString(a));var u=a.toInt()>>>0,f=a.shiftRightUnsigned(28).toInt()>>>0,p=a.shiftRightUnsigned(56).toInt()>>>0;return p==0?f==0?u<16384?u<128?1:2:1<<21>u?3:4:f<16384?f<128?5:6:1<<21>f?7:8:p<128?9:10},h.zigZagEncode64=function(a){return typeof a=="number"?a=t.fromNumber(a,!1):typeof a=="string"?a=t.fromString(a,!1):a.unsigned!==!1&&(a=a.toSigned()),a.shiftLeft(1).xor(a.shiftRight(63)).toUnsigned()},h.zigZagDecode64=function(a){return typeof a=="number"?a=t.fromNumber(a,!1):typeof a=="string"?a=t.fromString(a,!1):a.unsigned!==!1&&(a=a.toSigned()),a.shiftRightUnsigned(1).xor(a.and(t.ONE).toSigned().negate()).toSigned()},o.writeVarint64=function(a,u){var f,p,m,_,v,y=u===void 0;if(y&&(u=this.offset),!this.noAssert){if(typeof a=="number")a=t.fromNumber(a);else if(typeof a=="string")a=t.fromString(a);else if(!(a&&a instanceof t))throw TypeError("Illegal value: "+a+" (not an integer or Long)");if(typeof u!="number"||u%1!=0)throw TypeError("Illegal offset: "+u+" (not an integer)");if((u>>>=0)<0||u+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+u+" (+0) <= "+this.buffer.byteLength)}switch(typeof a=="number"?a=t.fromNumber(a,!1):typeof a=="string"?a=t.fromString(a,!1):a.unsigned!==!1&&(a=a.toSigned()),f=h.calculateVarint64(a),p=a.toInt()>>>0,m=a.shiftRightUnsigned(28).toInt()>>>0,_=a.shiftRightUnsigned(56).toInt()>>>0,(u+=f)>(v=this.buffer.byteLength)&&this.resize((v*=2)>u?v:u),u-=f,f){case 10:this.view[u+9]=1&_>>>7;case 9:this.view[u+8]=f!==9?128|_:127&_;case 8:this.view[u+7]=f!==8?128|m>>>21:127&m>>>21;case 7:this.view[u+6]=f!==7?128|m>>>14:127&m>>>14;case 6:this.view[u+5]=f!==6?128|m>>>7:127&m>>>7;case 5:this.view[u+4]=f!==5?128|m:127&m;case 4:this.view[u+3]=f!==4?128|p>>>21:127&p>>>21;case 3:this.view[u+2]=f!==3?128|p>>>14:127&p>>>14;case 2:this.view[u+1]=f!==2?128|p>>>7:127&p>>>7;case 1:this.view[u]=f!==1?128|p:127&p}return y?(this.offset+=f,this):f},o.writeVarint64ZigZag=function(a,u){return this.writeVarint64(h.zigZagEncode64(a),u)},o.readVarint64=function(a){var u,f,p,m,_,v,y=a===void 0;if(y&&(a=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal offset: "+a+" (not an integer)");if((a>>>=0)<0||a+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+1) <= "+this.buffer.byteLength)}if(u=a,f=0,p=0,m=0,_=0,f=127&(_=this.view[a++]),128&_&&(f|=(127&(_=this.view[a++]))<<7,(128&_||this.noAssert&&_===void 0)&&(f|=(127&(_=this.view[a++]))<<14,(128&_||this.noAssert&&_===void 0)&&(f|=(127&(_=this.view[a++]))<<21,(128&_||this.noAssert&&_===void 0)&&(p=127&(_=this.view[a++]),(128&_||this.noAssert&&_===void 0)&&(p|=(127&(_=this.view[a++]))<<7,(128&_||this.noAssert&&_===void 0)&&(p|=(127&(_=this.view[a++]))<<14,(128&_||this.noAssert&&_===void 0)&&(p|=(127&(_=this.view[a++]))<<21,(128&_||this.noAssert&&_===void 0)&&(m=127&(_=this.view[a++]),(128&_||this.noAssert&&_===void 0)&&(m|=(127&(_=this.view[a++]))<<7,128&_||this.noAssert&&_===void 0))))))))))throw Error("Buffer overrun");return v=t.fromBits(f|p<<28,p>>>4|m<<24,!1),y?(this.offset=a,v):{value:v,length:a-u}},o.readVarint64ZigZag=function(a){var u=this.readVarint64(a);return u&&u.value instanceof t?u.value=h.zigZagDecode64(u.value):u=h.zigZagDecode64(u),u}),o.writeCString=function(a,u){var f,p,m,_=u===void 0;if(_&&(u=this.offset),p=a.length,!this.noAssert){if(typeof a!="string")throw TypeError("Illegal str: Not a string");for(f=0;p>f;++f)if(a.charCodeAt(f)===0)throw RangeError("Illegal str: Contains NULL-characters");if(typeof u!="number"||u%1!=0)throw TypeError("Illegal offset: "+u+" (not an integer)");if((u>>>=0)<0||u+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+u+" (+0) <= "+this.buffer.byteLength)}return p=l.calculateUTF16asUTF8(e(a))[1],u+=p+1,m=this.buffer.byteLength,u>m&&this.resize((m*=2)>u?m:u),u-=p+1,l.encodeUTF16toUTF8(e(a),function(v){this.view[u++]=v}.bind(this)),this.view[u++]=0,_?(this.offset=u,this):p},o.readCString=function(a){var u,f,p,m=a===void 0;if(m&&(a=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal offset: "+a+" (not an integer)");if((a>>>=0)<0||a+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+1) <= "+this.buffer.byteLength)}return u=a,p=-1,l.decodeUTF8toUTF16(function(){if(p===0)return null;if(a>=this.limit)throw RangeError("Illegal range: Truncated data, "+a+" < "+this.limit);return(p=this.view[a++])===0?null:p}.bind(this),f=n(),!0),m?(this.offset=a,f()):{string:f(),length:a-u}},o.writeIString=function(a,u){var f,p,m,_=u===void 0;if(_&&(u=this.offset),!this.noAssert){if(typeof a!="string")throw TypeError("Illegal str: Not a string");if(typeof u!="number"||u%1!=0)throw TypeError("Illegal offset: "+u+" (not an integer)");if((u>>>=0)<0||u+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+u+" (+0) <= "+this.buffer.byteLength)}if(p=u,f=l.calculateUTF16asUTF8(e(a),this.noAssert)[1],u+=4+f,m=this.buffer.byteLength,u>m&&this.resize((m*=2)>u?m:u),u-=4+f,this.littleEndian?(this.view[u+3]=255&f>>>24,this.view[u+2]=255&f>>>16,this.view[u+1]=255&f>>>8,this.view[u]=255&f):(this.view[u]=255&f>>>24,this.view[u+1]=255&f>>>16,this.view[u+2]=255&f>>>8,this.view[u+3]=255&f),u+=4,l.encodeUTF16toUTF8(e(a),function(v){this.view[u++]=v}.bind(this)),u!==p+4+f)throw RangeError("Illegal range: Truncated data, "+u+" == "+(u+4+f));return _?(this.offset=u,this):u-p},o.readIString=function(a){var u,f,p,m=a===void 0;if(m&&(a=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal offset: "+a+" (not an integer)");if((a>>>=0)<0||a+4>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+4) <= "+this.buffer.byteLength)}return u=a,f=this.readUint32(a),p=this.readUTF8String(f,h.METRICS_BYTES,a+=4),a+=p.length,m?(this.offset=a,p.string):{string:p.string,length:a-u}},h.METRICS_CHARS="c",h.METRICS_BYTES="b",o.writeUTF8String=function(a,u){var f,p,m,_=u===void 0;if(_&&(u=this.offset),!this.noAssert){if(typeof u!="number"||u%1!=0)throw TypeError("Illegal offset: "+u+" (not an integer)");if((u>>>=0)<0||u+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+u+" (+0) <= "+this.buffer.byteLength)}return p=u,f=l.calculateUTF16asUTF8(e(a))[1],u+=f,m=this.buffer.byteLength,u>m&&this.resize((m*=2)>u?m:u),u-=f,l.encodeUTF16toUTF8(e(a),function(v){this.view[u++]=v}.bind(this)),_?(this.offset=u,this):u-p},o.writeString=o.writeUTF8String,h.calculateUTF8Chars=function(a){return l.calculateUTF16asUTF8(e(a))[0]},h.calculateUTF8Bytes=function(a){return l.calculateUTF16asUTF8(e(a))[1]},h.calculateString=h.calculateUTF8Bytes,o.readUTF8String=function(a,u,f){var p,m,_,v,y;if(typeof u=="number"&&(f=u,u=void 0),(p=f===void 0)&&(f=this.offset),u===void 0&&(u=h.METRICS_CHARS),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal length: "+a+" (not an integer)");if(a|=0,typeof f!="number"||f%1!=0)throw TypeError("Illegal offset: "+f+" (not an integer)");if((f>>>=0)<0||f+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+f+" (+0) <= "+this.buffer.byteLength)}if(_=0,v=f,u===h.METRICS_CHARS){if(m=n(),l.decodeUTF8(function(){return a>_&&f<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=n(),this.noAssert),f!==y)throw RangeError("Illegal range: Truncated data, "+f+" == "+y);return p?(this.offset=f,m()):{string:m(),length:f-v}}throw TypeError("Unsupported metrics: "+u)},o.readString=o.readUTF8String,o.writeVString=function(a,u){var f,p,m,_,v=u===void 0;if(v&&(u=this.offset),!this.noAssert){if(typeof a!="string")throw TypeError("Illegal str: Not a string");if(typeof u!="number"||u%1!=0)throw TypeError("Illegal offset: "+u+" (not an integer)");if((u>>>=0)<0||u+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+u+" (+0) <= "+this.buffer.byteLength)}if(m=u,f=l.calculateUTF16asUTF8(e(a),this.noAssert)[1],p=h.calculateVarint32(f),u+=p+f,_=this.buffer.byteLength,u>_&&this.resize((_*=2)>u?_:u),u-=p+f,u+=this.writeVarint32(f,u),l.encodeUTF16toUTF8(e(a),function(y){this.view[u++]=y}.bind(this)),u!==m+f+p)throw RangeError("Illegal range: Truncated data, "+u+" == "+(u+f+p));return v?(this.offset=u,this):u-m},o.readVString=function(a){var u,f,p,m=a===void 0;if(m&&(a=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal offset: "+a+" (not an integer)");if((a>>>=0)<0||a+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+1) <= "+this.buffer.byteLength)}return u=a,f=this.readVarint32(a),p=this.readUTF8String(f.value,h.METRICS_BYTES,a+=f.length),a+=p.length,m?(this.offset=a,p.string):{string:p.string,length:a-u}},o.append=function(a,u,f){var p,m,_;if((typeof u=="number"||typeof u!="string")&&(f=u,u=void 0),(p=f===void 0)&&(f=this.offset),!this.noAssert){if(typeof f!="number"||f%1!=0)throw TypeError("Illegal offset: "+f+" (not an integer)");if((f>>>=0)<0||f+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+f+" (+0) <= "+this.buffer.byteLength)}return a instanceof h||(a=h.wrap(a,u)),(m=a.limit-a.offset)<=0||((f+=m)>(_=this.buffer.byteLength)&&this.resize((_*=2)>f?_:f),f-=m,this.view.set(a.view.subarray(a.offset,a.limit),f),a.offset+=m,p&&(this.offset+=m)),this},o.appendTo=function(a,u){return a.append(this,u),this},o.assert=function(a){return this.noAssert=!a,this},o.capacity=function(){return this.buffer.byteLength},o.clear=function(){return this.offset=0,this.limit=this.buffer.byteLength,this.markedOffset=-1,this},o.clone=function(a){var u=new h(0,this.littleEndian,this.noAssert);return a?(u.buffer=new ArrayBuffer(this.buffer.byteLength),u.view=new Uint8Array(u.buffer)):(u.buffer=this.buffer,u.view=this.view),u.offset=this.offset,u.markedOffset=this.markedOffset,u.limit=this.limit,u},o.compact=function(a,u){var f,p,m;if(a===void 0&&(a=this.offset),u===void 0&&(u=this.limit),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal begin: Not an integer");if(a>>>=0,typeof u!="number"||u%1!=0)throw TypeError("Illegal end: Not an integer");if(u>>>=0,a<0||a>u||u>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+a+" <= "+u+" <= "+this.buffer.byteLength)}return a===0&&u===this.buffer.byteLength?this:(f=u-a)==0?(this.buffer=s,this.view=null,this.markedOffset>=0&&(this.markedOffset-=a),this.offset=0,this.limit=0,this):(p=new ArrayBuffer(f),(m=new Uint8Array(p)).set(this.view.subarray(a,u)),this.buffer=p,this.view=m,this.markedOffset>=0&&(this.markedOffset-=a),this.offset=0,this.limit=f,this)},o.copy=function(a,u){if(a===void 0&&(a=this.offset),u===void 0&&(u=this.limit),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal begin: Not an integer");if(a>>>=0,typeof u!="number"||u%1!=0)throw TypeError("Illegal end: Not an integer");if(u>>>=0,a<0||a>u||u>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+a+" <= "+u+" <= "+this.buffer.byteLength)}if(a===u)return new h(0,this.littleEndian,this.noAssert);var f=u-a,p=new h(f,this.littleEndian,this.noAssert);return p.offset=0,p.limit=f,p.markedOffset>=0&&(p.markedOffset-=a),this.copyTo(p,0,a,u),p},o.copyTo=function(a,u,f,p){var m,_,v;if(!this.noAssert&&!h.isByteBuffer(a))throw TypeError("Illegal target: Not a ByteBuffer");if(u=(_=u===void 0)?a.offset:0|u,f=(m=f===void 0)?this.offset:0|f,p=p===void 0?this.limit:0|p,u<0||u>a.buffer.byteLength)throw RangeError("Illegal target range: 0 <= "+u+" <= "+a.buffer.byteLength);if(f<0||p>this.buffer.byteLength)throw RangeError("Illegal source range: 0 <= "+f+" <= "+this.buffer.byteLength);return(v=p-f)==0?a:(a.ensureCapacity(u+v),a.view.set(this.view.subarray(f,p),u),m&&(this.offset+=v),_&&(a.offset+=v),this)},o.ensureCapacity=function(a){var u=this.buffer.byteLength;return a>u?this.resize((u*=2)>a?u:a):this},o.fill=function(a,u,f){var p=u===void 0;if(p&&(u=this.offset),typeof a=="string"&&a.length>0&&(a=a.charCodeAt(0)),u===void 0&&(u=this.offset),f===void 0&&(f=this.limit),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal value: "+a+" (not an integer)");if(a|=0,typeof u!="number"||u%1!=0)throw TypeError("Illegal begin: Not an integer");if(u>>>=0,typeof f!="number"||f%1!=0)throw TypeError("Illegal end: Not an integer");if(f>>>=0,u<0||u>f||f>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+u+" <= "+f+" <= "+this.buffer.byteLength)}if(u>=f)return this;for(;f>u;)this.view[u++]=a;return p&&(this.offset=u),this},o.flip=function(){return this.limit=this.offset,this.offset=0,this},o.mark=function(a){if(a=a===void 0?this.offset:a,!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal offset: "+a+" (not an integer)");if((a>>>=0)<0||a+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+0) <= "+this.buffer.byteLength)}return this.markedOffset=a,this},o.order=function(a){if(!this.noAssert&&typeof a!="boolean")throw TypeError("Illegal littleEndian: Not a boolean");return this.littleEndian=!!a,this},o.LE=function(a){return this.littleEndian=a===void 0||!!a,this},o.BE=function(a){return this.littleEndian=a!==void 0&&!a,this},o.prepend=function(a,u,f){var p,m,_,v,y;if((typeof u=="number"||typeof u!="string")&&(f=u,u=void 0),(p=f===void 0)&&(f=this.offset),!this.noAssert){if(typeof f!="number"||f%1!=0)throw TypeError("Illegal offset: "+f+" (not an integer)");if((f>>>=0)<0||f+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+f+" (+0) <= "+this.buffer.byteLength)}return a instanceof h||(a=h.wrap(a,u)),(m=a.limit-a.offset)<=0||((_=m-f)>0?(v=new ArrayBuffer(this.buffer.byteLength+_),(y=new Uint8Array(v)).set(this.view.subarray(f,this.buffer.byteLength),m),this.buffer=v,this.view=y,this.offset+=_,this.markedOffset>=0&&(this.markedOffset+=_),this.limit+=_,f+=_):new Uint8Array(this.buffer),this.view.set(a.view.subarray(a.offset,a.limit),f-m),a.offset=a.limit,p&&(this.offset-=m)),this},o.prependTo=function(a,u){return a.prepend(this,u),this},o.printDebug=function(a){typeof a!="function"&&(a=console.log.bind(console)),a(this.toString()+`
- -------------------------------------------------------------------
- `+this.toDebug(!0))},o.remaining=function(){return this.limit-this.offset},o.reset=function(){return this.markedOffset>=0?(this.offset=this.markedOffset,this.markedOffset=-1):this.offset=0,this},o.resize=function(a){var u,f;if(!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal capacity: "+a+" (not an integer)");if((a|=0)<0)throw RangeError("Illegal capacity: 0 <= "+a)}return this.buffer.byteLength<a&&(u=new ArrayBuffer(a),(f=new Uint8Array(u)).set(this.view),this.buffer=u,this.view=f),this},o.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},o.skip=function(a){if(!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal length: "+a+" (not an integer)");a|=0}var u=this.offset+a;if(!this.noAssert&&(u<0||u>this.buffer.byteLength))throw RangeError("Illegal length: 0 <= "+this.offset+" + "+a+" <= "+this.buffer.byteLength);return this.offset=u,this},o.slice=function(a,u){if(a===void 0&&(a=this.offset),u===void 0&&(u=this.limit),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal begin: Not an integer");if(a>>>=0,typeof u!="number"||u%1!=0)throw TypeError("Illegal end: Not an integer");if(u>>>=0,a<0||a>u||u>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+a+" <= "+u+" <= "+this.buffer.byteLength)}var f=this.clone();return f.offset=a,f.limit=u,f},o.toBuffer=function(a){var u,f=this.offset,p=this.limit;if(!this.noAssert){if(typeof f!="number"||f%1!=0)throw TypeError("Illegal offset: Not an integer");if(f>>>=0,typeof p!="number"||p%1!=0)throw TypeError("Illegal limit: Not an integer");if(p>>>=0,f<0||f>p||p>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+f+" <= "+p+" <= "+this.buffer.byteLength)}return a||f!==0||p!==this.buffer.byteLength?f===p?s:(u=new ArrayBuffer(p-f),new Uint8Array(u).set(new Uint8Array(this.buffer).subarray(f,p),0),u):this.buffer},o.toArrayBuffer=o.toBuffer,o.toString=function(a,u,f){if(a===void 0)return"ByteBufferAB(offset="+this.offset+",markedOffset="+this.markedOffset+",limit="+this.limit+",capacity="+this.capacity()+")";switch(typeof a=="number"&&(f=u=a="utf8"),a){case"utf8":return this.toUTF8(u,f);case"base64":return this.toBase64(u,f);case"hex":return this.toHex(u,f);case"binary":return this.toBinary(u,f);case"debug":return this.toDebug();case"columns":return this.toColumns();default:throw Error("Unsupported encoding: "+a)}},d=function(){var a,u,f={},p=[65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,48,49,50,51,52,53,54,55,56,57,43,47],m=[];for(a=0,u=p.length;u>a;++a)m[p[a]]=a;return f.encode=function(_,v){for(var y,C;(y=_())!==null;)v(p[63&y>>2]),C=(3&y)<<4,(y=_())!==null?(v(p[63&((C|=15&y>>4)|15&y>>4)]),C=(15&y)<<2,(y=_())!==null?(v(p[63&(C|3&y>>6)]),v(p[63&y])):(v(p[63&C]),v(61))):(v(p[63&C]),v(61),v(61))},f.decode=function(_,v){function y(S){throw Error("Illegal character code: "+S)}for(var C,b,N;(C=_())!==null;)if((b=m[C])===void 0&&y(C),(C=_())!==null&&((N=m[C])===void 0&&y(C),v(b<<2>>>0|(48&N)>>4),(C=_())!==null)){if((b=m[C])===void 0){if(C===61)break;y(C)}if(v((15&N)<<4>>>0|(60&b)>>2),(C=_())!==null){if((N=m[C])===void 0){if(C===61)break;y(C)}v((3&b)<<6>>>0|N)}}},f.test=function(_){return/^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/.test(_)},f}(),o.toBase64=function(a,u){if(a===void 0&&(a=this.offset),u===void 0&&(u=this.limit),u|=0,(a|=0)<0||u>this.capacity||a>u)throw RangeError("begin, end");var f;return d.encode(function(){return u>a?this.view[a++]:null}.bind(this),f=n()),f()},h.fromBase64=function(a,u){if(typeof a!="string")throw TypeError("str");var f=new h(a.length/4*3,u),p=0;return d.decode(e(a),function(m){f.view[p++]=m}),f.limit=p,f},h.btoa=function(a){return h.fromBinary(a).toBase64()},h.atob=function(a){return h.fromBase64(a).toBinary()},o.toBinary=function(a,u){if(a===void 0&&(a=this.offset),u===void 0&&(u=this.limit),u|=0,(a|=0)<0||u>this.capacity()||a>u)throw RangeError("begin, end");if(a===u)return"";for(var f=[],p=[];u>a;)f.push(this.view[a++]),f.length>=1024&&(p.push(String.fromCharCode.apply(String,f)),f=[]);return p.join("")+String.fromCharCode.apply(String,f)},h.fromBinary=function(a,u){if(typeof a!="string")throw TypeError("str");for(var f,p=0,m=a.length,_=new h(m,u);m>p;){if((f=a.charCodeAt(p))>255)throw RangeError("illegal char code: "+f);_.view[p++]=f}return _.limit=m,_},o.toDebug=function(a){for(var u,f=-1,p=this.buffer.byteLength,m="",_="",v="";p>f;){if(f!==-1&&(m+=(u=this.view[f])<16?"0"+u.toString(16).toUpperCase():u.toString(16).toUpperCase(),a&&(_+=u>32&&u<127?String.fromCharCode(u):".")),++f,a&&f>0&&f%16==0&&f!==p){for(;m.length<51;)m+=" ";v+=m+_+`
- `,m=_=""}m+=f===this.offset&&f===this.limit?f===this.markedOffset?"!":"|":f===this.offset?f===this.markedOffset?"[":"<":f===this.limit?f===this.markedOffset?"]":">":f===this.markedOffset?"'":a||f!==0&&f!==p?" ":""}if(a&&m!==" "){for(;m.length<51;)m+=" ";v+=m+_+`
- `}return a?v:m},h.fromDebug=function(a,u,f){for(var p,m,_=a.length,v=new h(0|(_+1)/3,u,f),y=0,C=0,b=!1,N=!1,S=!1,E=!1,w=!1;_>y;){switch(p=a.charAt(y++)){case"!":if(!f){if(N||S||E){w=!0;break}N=S=E=!0}v.offset=v.markedOffset=v.limit=C,b=!1;break;case"|":if(!f){if(N||E){w=!0;break}N=E=!0}v.offset=v.limit=C,b=!1;break;case"[":if(!f){if(N||S){w=!0;break}N=S=!0}v.offset=v.markedOffset=C,b=!1;break;case"<":if(!f){if(N){w=!0;break}N=!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(!N||!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},o.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}(),o.toUTF8=function(a,u){if(a===void 0&&(a=this.offset),u===void 0&&(u=this.limit),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal begin: Not an integer");if(a>>>=0,typeof u!="number"||u%1!=0)throw TypeError("Illegal end: Not an integer");if(u>>>=0,a<0||a>u||u>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+a+" <= "+u+" <= "+this.buffer.byteLength)}var f;try{l.decodeUTF8toUTF16(function(){return u>a?this.view[a++]:null}.bind(this),f=n())}catch{if(a!==u)throw RangeError("Illegal range: Truncated data, "+a+" != "+u)}return f()},h.fromUTF8=function(a,u,f){if(!f&&typeof a!="string")throw TypeError("Illegal str: Not a string");var p=new h(l.calculateUTF16asUTF8(e(a),!0)[1],u,f),m=0;return l.encodeUTF16toUTF8(e(a),function(_){p.view[m++]=_}),p.limit=m,p},h}(Ya=function(){function t(E,w,V){this.low=0|E,this.high=0|w,this.unsigned=!!V}function e(E){return(E&&E.__isLong__)===!0}function n(E,w){var V,K,R;return w?(R=(E>>>=0)>=0&&E<256)&&(K=d[E])?K:(V=i(E,(0|E)<0?-1:0,!0),R&&(d[E]=V),V):(R=(E|=0)>=-128&&E<128)&&(K=c[E])?K:(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 N;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 t(E,w,V)}function o(E,w,V){var K,R,T,A,k,U,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((K=E.indexOf("-"))>0)throw Error("interior hyphen");if(K===0)return o(E.substring(1),w,V).neg();for(R=r(l(V,8)),T=p,A=0;A<E.length;A+=8)k=Math.min(8,E.length-A),U=parseInt(E.substring(A,A+k),V),k<8?(F=r(l(V,k)),T=T.mul(F).add(r(U))):T=(T=T.mul(R)).add(r(U));return T.unsigned=w,T}function s(E){return E instanceof t?E:typeof E=="number"?r(E):typeof E=="string"?o(E):i(E.low,E.high,E.unsigned)}var c,d,l,h,a,u,f,p,m,_,v,y,C,b,N,S;return t.prototype.__isLong__,Object.defineProperty(t.prototype,"__isLong__",{value:!0,enumerable:!1,configurable:!1}),t.isLong=e,c={},d={},t.fromInt=n,t.fromNumber=r,t.fromBits=i,l=Math.pow,t.fromString=o,t.fromValue=s,u=(a=(h=4294967296)*h)/2,f=n(16777216),p=n(0),t.ZERO=p,m=n(0,!0),t.UZERO=m,_=n(1),t.ONE=_,v=n(1,!0),t.UONE=v,y=n(-1),t.NEG_ONE=y,C=i(-1,2147483647,!1),t.MAX_VALUE=C,b=i(-1,-1,!0),t.MAX_UNSIGNED_VALUE=b,N=i(0,-2147483648,!1),t.MIN_VALUE=N,(S=t.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,K,R,T,A,k,U;if((E=E||10)<2||E>36)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative())return this.eq(N)?(w=r(E),K=(V=this.div(w)).mul(w).sub(this),V.toString(E)+K.toInt().toString(E)):"-"+this.neg().toString(E);for(R=r(l(E,6),this.unsigned),T=this,A="";;){if(k=T.div(R),U=(T.sub(k.mul(R)).toInt()>>>0).toString(E),(T=k).isZero())return U+A;for(;U.length<6;)U="0"+U;A=""+U+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(N)?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=s(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=s(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(N)?N:this.not().add(_)},S.neg=S.negate,S.add=function(E){var w,V,K,R,T,A,k,U,F,H,Q;return e(E)||(E=s(E)),w=this.high>>>16,V=65535&this.high,K=this.low>>>16,R=65535&this.low,T=E.high>>>16,A=65535&E.high,k=E.low>>>16,U=0,F=0,H=0,Q=0,H+=(Q+=R+(65535&E.low))>>>16,F+=(H+=K+k)>>>16,U+=(F+=V+A)>>>16,U+=w+T,i((H&=65535)<<16|(Q&=65535),(U&=65535)<<16|(F&=65535),this.unsigned)},S.subtract=function(E){return e(E)||(E=s(E)),this.add(E.neg())},S.sub=S.subtract,S.multiply=function(E){var w,V,K,R,T,A,k,U,F,H,Q,ee;return this.isZero()?p:(e(E)||(E=s(E)),E.isZero()?p:this.eq(N)?E.isOdd()?N:p:E.eq(N)?this.isOdd()?N: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,K=this.low>>>16,R=65535&this.low,T=E.high>>>16,A=65535&E.high,k=E.low>>>16,F=0,H=0,Q=0,ee=0,Q+=(ee+=R*(U=65535&E.low))>>>16,H+=(Q+=K*U)>>>16,Q&=65535,H+=(Q+=R*k)>>>16,F+=(H+=V*U)>>>16,H&=65535,F+=(H+=K*k)>>>16,H&=65535,F+=(H+=R*A)>>>16,F+=w*U+V*k+K*A+R*T,i((Q&=65535)<<16|(ee&=65535),(F&=65535)<<16|(H&=65535),this.unsigned)))},S.mul=S.multiply,S.divide=function(E){var w,V,K,R,T,A,k;if(e(E)||(E=s(E)),E.isZero())throw Error("division by zero");if(this.isZero())return this.unsigned?m:p;if(this.unsigned){if(E.unsigned||(E=E.toUnsigned()),E.gt(this))return m;if(E.gt(this.shru(1)))return v;K=m}else{if(this.eq(N))return E.eq(_)||E.eq(y)?N:E.eq(N)?_:(w=this.shr(1).div(E).shl(1)).eq(p)?E.isNegative()?_:y:(V=this.sub(E.mul(w)),K=w.add(V.div(E)));if(E.eq(N))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();K=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),k=(A=r(w)).mul(E);k.isNegative()||k.gt(V);)k=(A=r(w-=T,this.unsigned)).mul(E);A.isZero()&&(A=_),K=K.add(A),V=V.sub(k)}return K},S.div=S.divide,S.modulo=function(E){return e(E)||(E=s(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=s(E)),i(this.low&E.low,this.high&E.high,this.unsigned)},S.or=function(E){return e(E)||(E=s(E)),i(this.low|E.low,this.high|E.high,this.unsigned)},S.xor=function(E){return e(E)||(E=s(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]},t}()),Ya));Ho.getModule=function(t){var e=new Ho[t];return e.getArrayData=function(){var n=e.toArrayBuffer();return n=mu(n)?[].slice.call(new Int8Array(n)):n},e};var jo,lh="pgMsgP",hh="chatMsg",fh="pcMsgP",ph={PRIVATE:"ppMsgS",GROUP:"pgMsgS",CHATROOM:"chatMsgS"},gh="delMsg",mh="joinChrm",_h="joinChrmR",vh="exitChrm",yh="setKV",Ch="delKV",Eh="setKVS",Rh="delKVS",Ja="qryRelationR",Th="delRelation",Sh="setSeAtt",Er={PRIVATE:"cleanPMsg",GROUP:"cleanGMsg",CUSTOMER_SERVICE:"cleanCMsg",SYSTEM:"cleanSMsg"},Au="qryPMsg",Ih="qryGMsg",Mu="qryCHMsg",bh="qryCMsg",wh="qrySMsg",Oh=((Pn={}).ppMsgP=re.PRIVATE,Pn[lh]=re.GROUP,Pn[hh]=re.CHATROOM,Pn[fh]=re.CUSTOMER_SERVICE,Pn),Nh=((nn={})[re.PRIVATE]=Au,nn[re.GROUP]=Ih,nn[re.CHATROOM]=Mu,nn[re.CUSTOMER_SERVICE]=bh,nn[re.SYSTEM]=wh,nn),Ah=((Ln={})[re.PRIVATE]=Er.PRIVATE,Ln[re.GROUP]=Er.GROUP,Ln[re.CUSTOMER_SERVICE]=Er.CUSTOMER_SERVICE,Ln[re.SYSTEM]=Er.SYSTEM,Ln),Xi="1",Mh="0",Wa=1,za=2,Qa=3,Ph=function(){function t(e){this._codec=e==="websocket"?Ho:rr,this._connectType=e}return t.prototype.decodeByPBName=function(e,n,r){var i,o=this,s=e,c=((i={})[er]=o._formatSyncMessages,i[Ii]=o._formatReceivedMessage,i[Zn]=o._formatSentMessage,i[tr]=o._formatHistoryMessages,i[nr]=o._formatConversationList,i[bi]=o._formatChatRoomInfos,i[Yt]=o._formatRTCUserList,i[Oi]=o._formatRTCData,i[un]=o._formatChatRoomKVList,i[Ni]=o._formatUserSetting,i[Mi]=o._formatConversationStatus,i[Pi]=o._formatGrpReadReceiptQryResp,i[dn]=o._formatSetUserSettingOutput,i[Ai]=o._formatUserSettingNotification,i[Li]=o._formatRTCRoomKVList,i[wi]=o._formatRTCAuidenceJoinRoomData,i[ki]=o._formatRTCJoinedUserInfo,i)[n];try{s=e.length>0&&o._codec[n].decode(e),je(s)&&(s=function(d){for(var l in d)je(d[l])&&(d[l]=st(d[l]));return d}(s)),Wr(c)&&(s=c.call(this,s,r))}catch(d){G.error(`PB parse error
- `,d,e,n)}return s},t.prototype._readBytes=function(e){var n=e.offset,r=e.buffer,i=e.limit;if(n)try{var o=mu(r)?new Uint8Array(r):r;return ur.readUTF(o.subarray(n,i))}catch(s){G.info(`readBytes error
- `,s)}return e},t.prototype._formatBytes=function(e){var n=this._readBytes(e);try{n=JSON.parse(n)}catch(r){G.info(`formatBytes error
- `,r)}return n||e},t.prototype._formatSyncMessages=function(e,n){n=n||{};var r=this,i=e.list,o=e.syncTime,s=e.finished;return(me(s)||s===null)&&(e.finished=!0),e.syncTime=st(o),e.list=Cr(i,function(c){return r._formatReceivedMessage(c,n)}),e},t.prototype._formatReceivedMessage=function(e,n){var r=(n=n||{}).currentUserId,i=n.connectedTime,o=e.content,s=e.fromUserId,c=e.type,d=e.groupId,l=e.status,h=e.dataTime,a=e.classname,u=e.msgId,f=e.extraContent,p=e.pushContent,m=e.pushExt,_=e.configFlag,v=(e.direction||ct.RECEIVE)===ct.SEND,y=function(q){var J=Qn.READ;return{isPersited:!!(16&q),isCounted:!!(32&q),isMentioned:!!(64&q),disableNotification:!!(512&q),receivedStatus:J=2&q?Qn.RETRIEVED:J,canIncludeExpansion:!!(1024&q)}}(l),C=y.isPersited,b=y.isCounted,N=y.isMentioned,S=y.disableNotification,E=y.receivedStatus,w=y.canIncludeExpansion,V=[re.GROUP,re.CHATROOM,re.RTC_ROOM].indexOf(c)>-1?d:s,K=v?r:s,R=st(h),T=R<i,A=c===re.CHATROOM,k=this._formatBytes(o),U={};if(m&&(U=ja(m.pushConfigs,m.pushId)),k.user){var F=k.user,H=F.portrait,Q=F.portraitUri,ee=H||Q;ee&&(k.user.portrait=k.user.portraitUri=ee)}var ce,X=Ee(Ee({},U),{pushTitle:m==null?void 0:m.title,pushContent:p,pushData:p,disablePushTitle:!!_&&Boolean(4&_),forceShowDetailContent:!!_&&Boolean(8&_),templateId:m==null?void 0:m.templateId}),z=v?ct.SEND:ct.RECEIVE;return A&&s===r&&(z=ct.SEND),f&&(ce={},ce=Ka(f)),{conversationType:c,targetId:V,senderUserId:K,messageType:a,messageUId:u,isPersited:C,isCounted:b,isMentioned:N,sentTime:R,isOffLineMessage:T,messageDirection:z,receivedTime:sn.getTime(),disableNotification:S,receivedStatus:E,canIncludeExpansion:w,content:k,expansion:ce,configFlag:_,pushConfig:X,channelId:e.busChannel||""}},t.prototype._formatSentMessage=function(e,n){var r,i=e.content,o=e.classname,s=e.sessionId,c=e.msgId,d=e.extraContent,l=e.pushExt,h=e.pushContent,a=e.configFlag,u=n.signal,f=n.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)}}(s),y=v.isPersited,C=v.isCounted,b=v.disableNotification,N=v.canIncludeExpansion,S=Oh[m]||re.PRIVATE,E=ih(ph,m),w=this._formatBytes(i),V=_;o===Ge.RECALL&&(S=w.conversationType||S,V=w.targetId||_),d&&(r={},r=Ka(d));var K={};l&&(K=ja(l.pushConfigs,l.pushId));var R=Ee(Ee({},K),{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:o,messageUId:c,isPersited:y,isCounted:C,isStatusMessage:E,senderUserId:f,content:this._formatBytes(i),sentTime:1e3*p,receivedTime:sn.getTime(),messageDirection:ct.SEND,isOffLineMessage:!1,disableNotification:b,canIncludeExpansion:N,expansion:r,pushConfig:R,channelId:e.busChannel||""}},t.prototype._formatHistoryMessages=function(e,n){var r=this,i=n.conversation||{},o=e.list,s=e.hasMsg,c=i.targetId,d=st(e.syncTime),l=[];return Me(o,function(h){var a=r._formatReceivedMessage(h,n);a.targetId=c,l.push(a)},{isReverse:!0}),{syncTime:d,list:l,hasMore:!!s}},t.prototype._formatConversationList=function(e,n){var r=this,i=e.info,o=n.afterDecode||function(){};return(i=Cr(i,function(s){var c=s.msg,d=s.userId,l=s.type,h=s.unreadCount,a=s.busChannel,u=null;c&&((u=r._formatReceivedMessage(c,n)).targetId=d);var f={targetId:d,conversationType:l,unreadMessageCount:h,latestMessage:u,channelId:a||""};return o(f)||f}))||[]},t.prototype._formatSetUserSettingOutput=function(e){return e},t.prototype._formatChatRoomInfos=function(e){var n=e.userTotalNums,r=e.userInfos;return{userCount:n,userInfos:Cr(r,function(i){var o=i.id,s=i.time;return{id:o,time:st(s)}})}},t.prototype._formatChatRoomKVList=function(e){var n=e.entries,r=e.bFullUpdate,i=e.syncTime;return{kvEntries:n=Cr(n=n||[],function(o){var s=o.key,c=o.value,d=o.status,l=o.timestamp,h=o.uid,a=function(u){return{isAutoDelete:!!(1&u),isOverwrite:!!(2&u),type:4&u?Ze.DELETE:Ze.UPDATE}}(d);return{key:s,value:c,isAutoDelete:a.isAutoDelete,isOverwrite:a.isOverwrite,type:a.type,userId:h,timestamp:st(l)}}),isFullUpdate:r,syncTime:i}},t.prototype._formatUserSetting=function(e){var n=this,r=e.items,i=e.version,o={};return Me(r||[],function(s){var c=s.key,d=s.version,l=s.value;s.version=st(d),s.value=n._readBytes(l),c==="Tag"&&s.tags.forEach(function(h){h.createdTime=st(h.createdTime),h.tagName=h.name}),o[c]=s}),{settings:o,version:i}},t.prototype._formatConversationStatus=function(e){var n=e.state,r=[];return Me(n,function(i){var o=i.type,s=i.channelId,c=i.time,d=i.stateItem,l=i.busChannel,h=on.CLOSE,a=!1,u=[];Me(d,function(f){var p=f.sessionStateType,m=f.value,_=f.tags;switch(p){case Wa:h=m===Xi?on.OPEN:on.CLOSE;break;case za:a=m===Xi;break;case Qa:u=_}}),r.push({conversationType:o,type:o,targetId:s,notificationStatus:h,isTop:a,updatedTime:st(c),tags:u,channelId:l||""})}),r},t.prototype._formatRTCUserList=function(e){var n=e.users,r=e.token,i=e.sessionId,o=e.roomInfo,s=e.entries,c={};return Me(n,function(d){var l=d.userId,h=d.userData,a={};Me(h,function(u){var f=u.key,p=u.value;a[f]=p}),c[l]=a}),{users:c,token:r,sessionId:i,roomInfo:o,kvEntries:s}},t.prototype._formatRTCData=function(e){var n=e.outInfo,r={};return Me(n,function(i){r[i.key]=i.value}),r},t.prototype._formatRTCRoomInfo=function(e){var n=e.roomId,r=e.userCount,i=e.roomData,o={id:n,total:r};return Me(i,function(s){o[s.key]=s.value}),o},t.prototype._formatGrpReadReceiptQryResp=function(e){var n=e.totalMemberNum,r=e.list;return r.forEach(function(i){i.readTime=st(i.readTime)}),{totalMemberCount:n,list:r}},t.prototype._formatUserSettingNotification=function(e){return e},t.prototype._formatRTCRoomKVList=function(e){var n=e.entries,r=e.bFullUpdate,i=e.syncTime;return{kvEntries:n=(n=n||[]).map(function(o){var s=o.timestamp;return Object.assign(o,{timestamp:st(s)})}),isFullUpdate:r,syncTime:i}},t.prototype._formatRTCAuidenceJoinRoomData=function(e){return e},t.prototype._formatRTCJoinedUserInfo=function(e){return(e.info||[]).map(function(n){return{deviceId:n.deviceId,roomId:n.roomId,joinTime:st(n.joinTime)}})},t.prototype.encodeServerConfParams=function(){var e=this._codec.getModule(_s);return e.setNothing(1),e.getArrayData()},t.prototype._getUpMsgModule=function(e,n){var r,i,o,s=this._connectType==="comet",c=(e.conversationType,n.messageType),d=n.isMentioned,l=n.mentionedType,h=n.mentionedUserIdList,a=n.content,u=n.pushContent,f=n.pushData,p=n.directionalUserIdList,m=n.isFilerWhiteBlacklist,_=n.isVoipPush,v=n.canIncludeExpansion,y=n.expansion,C=n.pushConfig,b=n.channelId;re.GROUP;var N=this._codec.getModule(Zn),S=function(z){var q=z.isStatusMessage,J=z.isPersited,L=z.isCounted;q&&(J=L=!1);var $=0;return J&&($|=1),L&&($|=2),z.isMentioned&&($|=4),z.disableNotification&&($|=32),z.canIncludeExpansion&&($|=64),$}(n),E=C||{},w=E.pushTitle,V=E.pushContent,K=E.pushData,R=E.iOSConfig,T=E.androidConfig,A=E.templateId,k=E.disablePushTitle,U=E.forceShowDetailContent,F=0;N.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||ps.ALL,mentionedContent:((o=a.mentionedInfo)===null||o===void 0?void 0:o.mentionedContent)||""});var H=V||u||"",Q=K||f||"";if(H&&N.setPushText(H),Q&&N.setAppData(Q),p&&N.setUserId(p),F|=_?1:0,F|=m?2:0,F|=k?4:0,F|=U?8:0,N.setConfigFlag(F),N.setClassname(c),a.user&&a.user.portraitUri&&(a.user.portrait=a.user.portraitUri),N.setContent(JSON.stringify(a)),v&&y){var ee={};Me(y,function(z,q){ee[q]={v:z}}),N.setExtraContent(JSON.stringify(ee))}if(C){var ce=this._codec.getModule(ms);if(w&&ce.setTitle(w),R&&T){var X=nh(R,T);ce.setPushConfigs(X)}(T==null?void 0:T.notificationId)&&ce.setPushId(T==null?void 0:T.notificationId),ce.setTemplateId(A||""),N.setPushExt(s?ce.getArrayData():ce)}return me(b)||N.setBusChannel(b),N},t.prototype.encodeUpMsg=function(e,n){return this._getUpMsgModule(e,n).getArrayData()},t.prototype.encodeSyncMsg=function(e){var n=e.sendboxTime,r=e.inboxTime,i=this._codec.getModule(vs);return i.setIspolling(!1),i.setIsPullSend(!0),i.setSendBoxSyncTime(n),i.setSyncTime(r),i.getArrayData()},t.prototype.encodeChrmSyncMsg=function(e,n){e=e||0,n=n||0;var r=this._codec.getModule(ys);return r.setCount(n),r.setSyncTime(e),r.getArrayData()},t.prototype.encodeGetHistoryMsg=function(e,n){var r=n.count,i=n.order,o=n.timestamp,s=n.channelId,c=this._codec.getModule(Cs);return c.setTargetId(e),c.setTime(o),c.setCount(r),c.setOrder(i),c.setBusChannel(s||""),c.getArrayData()},t.prototype.encodeGetConversationList=function(e){var n=(e=e||{}).count,r=e.startTime,i=this._codec.getModule(Xr);return i.setType(1),i.setCount(n),i.setStartTime(r),i.getArrayData()},t.prototype.encodeOldConversationList=function(e){var n=(e=e||{}).count,r=e.type,i=e.startTime,o=e.order;n=n||0,i=i||0,o=o||0;var s=this._codec.getModule(Xr);return s.setType(r),s.setCount(n),s.setStartTime(i),s.setOrder(o),s.getArrayData()},t.prototype.encodeRemoveOldConversationList=function(e){var n=(e=e||{}).conversationType,r=e.channelId,i=this._codec.getModule(Ts);return i.setType(n),i.setBusChannel(r),i.getArrayData()},t.prototype.encodeRemoveConversationList=function(e){var n=this,r=this._codec.getModule(Es),i=[];return Me(e,function(o){var s=o.conversationType,c=o.targetId,d=n._codec.getModule(Rs);d.setType(s),d.setChannelId(c),i.push(d)}),r.setSessions(i),r.getArrayData()},t.prototype.encodeDeleteMessages=function(e,n,r,i){var o=this._codec.getModule(Ss),s=[];return Me(r,function(c){s.push({msgId:c.messageUId,msgDataTime:c.sentTime,direct:c.messageDirection})}),o.setType(e),o.setConversationId(n),o.setMsgs(s),o.setBusChannel(i),o.getArrayData()},t.prototype.encodeClearMessages=function(e,n,r){var i=this._codec.getModule(Is);return n=n||new Date().getTime(),i.setDataTime(n),i.setTargetId(e),i.setBusChannel(r),i.getArrayData()},t.prototype.encodeClearUnreadCount=function(e,n){var r=e.conversationType,i=e.targetId,o=n.timestamp,s=this._codec.getModule(bs);return o=o||+new Date,s.setType(r),s.setChannelId(i),s.setMsgTime(o),s.getArrayData()},t.prototype.encodeJoinOrQuitChatRoom=function(){var e=this._codec.getModule(ws);return e.setNothing(1),e.getArrayData()},t.prototype.encodeGetChatRoomInfo=function(e,n){var r=this._codec.getModule(Ns);return r.setCount(e),r.setOrder(n),r.getArrayData()},t.prototype.encodeGetFileToken=function(e,n,r,i){var o=this._codec.getModule(xs);return o.setType(e),o.setKey(n),o.setHttpMethod(r),o.setQueryString(i),o.getArrayData()},t.prototype.encodeGetFileUrl=function(e,n,r,i){var o=this._codec.getModule(e);return o.setType(n),o.setKey(r),i&&o.setFileName(i),o.getArrayData()},t.prototype.encodeModifyChatRoomKV=function(e,n,r){var i=this._connectType==="comet",o=this._codec.getModule($s),s=n.key,c=n.value,d=n.notificationExtra,l=n.isSendNotification,h=n.type||Ze.UPDATE,a=qa(n,h),u={key:s,value:c||"",uid:r};if(me(a)||(u.status=a),o.setEntry(u),l){var f={conversationType:re.CHATROOM,targetId:e},p={key:s,value:c,extra:d,type:h},m=this._getUpMsgModule(f,{messageType:Ge.CHRM_KV_NOTIFY,content:p,isPersited:!1,isCounted:!1});i?o.setNotification(m.getArrayData()):o.setNotification(m),o.setBNotify(!0),o.setType(re.CHATROOM)}return o.getArrayData()},t.prototype.encodeModifyChatRoomKVS=function(e,n,r){this._connectType;var i=this._codec.getModule(Ks),o=n.entries,s=n.type||Ze.UPDATE,c=qa(n,s),d=[];return o.forEach(function(l){var h={key:l.key,value:l.value||"",uid:r};me(c)||(h.status=c),d.push(h)}),i.setEntry(d),i.getArrayData()},t.prototype.encodePullChatRoomKV=function(e){var n=this._codec.getModule(Gs);return n.setTimestamp(e),n.getArrayData()},t.prototype.encodePullUserSetting=function(e){var n=this._codec.getModule(Ys);return n.setVersion(e),n.getArrayData()},t.prototype.encodeGetConversationStatus=function(e){var n=this._codec.getModule(Js);return n.setTime(e),n.getArrayData()},t.prototype.encodeSetConversationStatus=function(e){var n=this,r=this._connectType==="comet",i=this._codec.getModule(ii),o=sn.getTime(),s=[];return Me(e,function(c){var d=n._codec.getModule(ni),l=c.conversationType,h=c.targetId,a=c.notificationStatus,u=c.isTop,f=c.channelId,p=[];d.setType(l),d.setChannelId(h),d.setTime(o),d.setBusChannel(f);var m=a===on.OPEN,_={};me(a)||(_[Wa]=m),me(u)||(_[za]=u),Me(_,function(y,C){if(!me(y)){var b=n._codec.getModule(ri);y=y?Xi:Mh,b.setSessionStateType(Number(C)),b.setValue(y);var N=r?b.getArrayData():b;p.push(N)}}),d.setStateItem(p);var v=r?d.getArrayData():d;s.push(v)}),i.setVersion(o),i.setState(s),i.getArrayData()},t.prototype.encodeReadReceipt=function(e,n){var r=this._codec.getModule(oi);return r.setMsgId(e),n&&r.setChannelId(n),r.getArrayData()},t.prototype.encodeCreateTag=function(e,n){var r=this,i=this._connectType==="comet",o=this._codec.getModule(zs),s=[];return e.forEach(function(c){var d=r._codec.getModule(Gn);d.setTagId(c.tagId),d.setName(c.tagName),s.push(i?d.getArrayData():d)}),o.setTags(s),o.setVersion(n),o.getArrayData()},t.prototype.encodeMessageReader=function(e,n){var r=this._codec.getModule(oi);return r.setMsgId(e),n&&r.setChannelId(n),r.getArrayData()},t.prototype.encodeRemoveTag=function(e,n){var r=this,i=this._connectType==="comet",o=this._codec.getModule(Qs),s=[];return e.forEach(function(c){var d=r._codec.getModule(Gn);d.setTagId(c),s.push(i?d.getArrayData():d)}),o.setTags(s),o.setVersion(n),o.getArrayData()},t.prototype.encodeDisConversationTag=function(e){var n=this._codec.getModule(Xs);return n.setTagId(e),n.getArrayData()},t.prototype.encodeUpdateConversationTag=function(e,n){var r=this,i=this._connectType==="comet",o=this._codec.getModule(ii),s=[];return n.forEach(function(c){var d=r._codec.getModule(ni),l=r._codec.getModule(ri),h=[];e.forEach(function(a){var u=r._codec.getModule(Gn);u.setTagId(a.tagId),me(a.isTop)||u.setIsTop(a.isTop),h.push(i?u.getArrayData():u)}),l.setSessionStateType(Qa),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]),s.push(i?d.getArrayData():d)}),o.setState(s),o.setVersion(sn.getTime()),o.getArrayData()},t.prototype.encodeReportSDKInfo=function(e){var n=this._codec.getModule(Zs);return n.setSdkInfo(e),n.getArrayData()},t.prototype.encodeJoinRTCRoom=function(e,n,r){var i=this._codec.getModule(Zr);return e=e||0,i.setRoomType(e),me(n)||i.setBroadcastType(n),me(r)||i.setJoinType(r),i.getArrayData()},t.prototype.encodeQuitRTCRoom=function(){return this._codec.getModule(As).getArrayData()},t.prototype.encodeSetRTCData=function(e,n,r,i,o){var s=this._codec.getModule(Ms);if(s.setInterior(r),s.setTarget(i),s.setKey(e),s.setValue(n),o){o.name&&s.setObjectName(o.name);var c=o.content;c&&(je(c)&&(c=JSON.stringify(c)),s.setContent(c))}return s.getArrayData()},t.prototype.encodeUserSetRTCData=function(e,n,r,i){var o=this,s=this._connectType==="comet",c=this._codec.getModule(ei);c.setObjectName(r);var d=this._codec.getModule(at);d.setKey(e.name),d.setValue(e.content),s?c.setContent([d.getArrayData()]):c.setContent(d);var l=[];return["uris","mcu_uris"].forEach(function(h){var a=o._codec.getModule(at);a.setKey(h);var u=h==="uris"?n:i;a.setValue(u),s?l.push(a.getArrayData()):l.push(a)}),c.setValueInfo(l),c.getArrayData()},t.prototype.encodeUserSetRTCCDNUris=function(e,n){this._connectType;var r=this._codec.getModule(ei);r.setObjectName(e);var i=this._codec.getModule(at);return i.setKey("cdn_uris"),i.setValue(n),r.setValueInfo(i),r.getArrayData()},t.prototype.encodeGetRTCData=function(e,n,r){var i=this._codec.getModule(ti);return i.setInterior(n),i.setTarget(r),i.setKey(e),i.getArrayData()},t.prototype.encodeRemoveRTCData=function(e,n,r,i){var o=this._codec.getModule(ti);o.setInterior(n),o.setTarget(r),o.setKey(e);var s=(i=i||{}).name,c=i.content;return!me(s)&&o.setObjectName(s),me(c)||(je(c)&&(c=JSON.stringify(c)),o.setContent(c)),o.getArrayData()},t.prototype.encodeSetRTCOutData=function(e,n,r){var i=this._codec.getModule(Ps);i.setTarget(n),Qe(e)||(e=[e]),Me(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 o=(r=r||{}).name,s=r.content;return!me(o)&&i.setObjectName(o),me(s)||(je(s)&&(s=JSON.stringify(s)),i.setContent(s)),i.getArrayData()},t.prototype.ecnodeGetRTCOutData=function(e){var n=this._codec.getModule(ks);return n.setUserId(e),n.getArrayData()},t.prototype.encodeSetRTCState=function(e){var n=this._codec.getModule(Ls);return n.setState(e),n.getArrayData()},t.prototype.encodeGetRTCRoomInfo=function(){var e=this._codec.getModule(Us);return e.setOrder(2),e.getArrayData()},t.prototype.encodeSetRTCUserInfo=function(e,n){var r=this._codec.getModule(at);return r.setKey(e),r.setValue(n),r.getArrayData()},t.prototype.encodeRemoveRTCUserInfo=function(e){var n=this._codec.getModule(Ds);return n.setKey(e),n.getArrayData()},t.prototype.encodeIdentityChangeInfo=function(e,n,r){r===void 0&&(r=!1);var i=this._codec.getModule(Zr);return i.setRoomType(Je.LIVE),n&&i.setBroadcastType(n),i.setIdentityChangeType(e),i.setNeedSysChatroom(r),i.getArrayData()},t.prototype.encodePullRTCRoomKV=function(e,n){var r=this._codec.getModule(ta);return r.setTimestamp(n),r.setRoomId(e),r.getArrayData()},t.prototype.encodeQueryUserJoinedInfo=function(e){var n=this._codec.getModule(na);return n.setUserId(e),n.getArrayData()},t.prototype.encodeRequestRoomPK=function(e){var n=e.invitedRoomId,r=e.invitedUserId,i=e.inviteSessionId,o=e.inviteTimeout,s=e.inviteInfo,c=this._codec.getModule(ra);return c.setInvitedRoomId(n),c.setInvitedUserId(r),c.setInviteSessionId(i),c.setTimeoutTime(o),c.setInviteInfo(s),c.getArrayData()},t.prototype.encodeCancelRoomPK=function(e){var n=e.invitedRoomId,r=e.invitedUserId,i=e.inviteSessionId,o=e.inviteInfo,s=this._codec.getModule(ia);return s.setInvitedRoomId(n),s.setInvitedUserId(r),s.setInviteSessionId(i),s.setInviteInfo(o),s.getArrayData()},t.prototype.encodeResponseRoomPK=function(e){var n=e.inviteUserId,r=e.inviteRoomId,i=e.inviteSessionId,o=e.content,s=e.key,c=e.value,d=e.agree?1:0,l=this._codec.getModule(oa);return l.setInviteUserId(n),l.setInviteRoomId(r),l.setInviteSessionId(i),l.setContent(o),l.setKey(s),l.setValue(c),l.setAnswerCode(d),l.getArrayData()},t.prototype.encodeEndRoomPK=function(e){var n=e.endRoomId,r=e.sessionId,i=e.content,o=e.keys,s=this._codec.getModule(sa);return s.setInviteRoomId(n),s.setInviteSessionId(r),s.setInviteContent(i),s.setInviteRoomKeys(o),s.getArrayData()},t}(),Pu=function(t,e){this._watcher=e,this.codec=new Ph(t)},Lu=function(t,e){return t&&e?e+"_"+t:t||Date.now()},dr=function(){function t(e){this.header=e,this._name=null,this.lengthSize=0,this.messageId=0,this.timestamp=0,this.syncMsg=!1,this.identifier=""}return t.prototype.getIdentifier=function(){var e=this.messageId,n=this.identifier;return Lu(e,n)},t.prototype.read=function(e,n,r){this.readMessage(e,n,r)},t.prototype.readMessage=function(e,n,r){return{stream:e,length:n}},t}(),ku=function(){function t(e){this.lengthSize=0,this.messageId=0,this.topic="",this.targetId="",this.identifier="",this._header=new gs(e,!1,wt.AT_MOST_ONCE,!1)}return t.prototype.getIdentifier=function(){var e=this.messageId,n=this.identifier;return Lu(e,n)},t.prototype.write=function(e){var n=this.getHeaderFlag();e.write(n),this.writeMessage(e)},t.prototype.setHeaderQos=function(e){this._header.qos=e},t.prototype.getHeaderFlag=function(){return this._header.encode()},t.prototype.getLengthSize=function(){return this.lengthSize},t.prototype.getBufferData=function(){var e=new ah;this.write(e);var n=e.getBytesArray();return new Int8Array(n)},t.prototype.getCometData=function(){var e=this.data||{};return JSON.stringify(e)},t}(),Uu=function(t){function e(){var n=t!==null&&t.apply(this,arguments)||this;return n._name=rt.CONN_ACK,n.status=null,n.userId=null,n.timestamp=0,n}return Oe(e,t),e.prototype.readMessage=function(n,r,i){if(n.readByte(),this.status=+n.readByte(),r<=e.MESSAGE_LENGTH)return{stream:n,length:r};if(i===Gt.V4){var o=n.readByte();1&o&&(this.userId=n.readUTF()),2&o&&n.readUTF(),4&o&&(this.timestamp=n.readLong()),8&o&&(this.messageId=n.read2Byte())}else{this.userId=n.readUTF();var s=n.readUTF();G.debug("server sessionId -> "+s),this.timestamp=n.readLong()}return{stream:n,length:r}},e.MESSAGE_LENGTH=2,e}(dr),aa=function(t){function e(){var n=t!==null&&t.apply(this,arguments)||this;return n._name=rt.DISCONNECT,n.status=0,n}return Oe(e,t),e.prototype.readMessage=function(n,r){return n.readByte(),this.status=+n.readByte(),{stream:n,length:r}},e.MESSAGE_LENGTH=2,e}(dr),Lh=function(t){function e(){var n=t.call(this,qe.PING_REQ)||this;return n._name=rt.PING_REQ,n}return Oe(e,t),e.prototype.writeMessage=function(n){},e}(ku),Du=function(t){function e(n){var r=t.call(this,n)||this;return r._name=rt.PING_RESP,r}return Oe(e,t),e}(dr),ca=function(t){function e(){var n=t!==null&&t.apply(this,arguments)||this;return n.messageId=0,n}return Oe(e,t),e.prototype.readMessage=function(n,r){var i=256*n.readByte()+n.readByte();return this.messageId=parseInt(i.toString(),10),{stream:n,length:r}},e}(dr),Ui=function(t){function e(){var n=t!==null&&t.apply(this,arguments)||this;return n.messageId=0,n}return Oe(e,t),e.prototype.writeMessage=function(n){var r=this.messageId,i=255&r,o=(65280&r)>>8;n.write(o),n.write(i)},e}(ku),ir=function(t){function e(){var n=t!==null&&t.apply(this,arguments)||this;return n._name=rt.PUBLISH,n.topic="",n.targetId="",n.syncMsg=!1,n.identifier=Qt.PUB,n}return Oe(e,t),e.prototype.readMessage=function(n,r){return this.date=n.readInt(),this.topic=n.readUTF(),this.targetId=n.readUTF(),t.prototype.readMessage.call(this,n,r),this.data=n.readAll(),{stream:n,length:r}},e}(ca),kn=function(t){function e(n,r,i){var o=t.call(this,qe.PUBLISH)||this;return o._name=rt.PUBLISH,o.syncMsg=!1,o.identifier=Qt.PUB,o.topic=n,o.data=nt(r)?ur.writeUTF(r):r,o.targetId=i,o}return Oe(e,t),e.prototype.writeMessage=function(n){n.writeUTF(this.topic),n.writeUTF(this.targetId),t.prototype.writeMessage.call(this,n),n.write(this.data)},e}(Ui),$o=function(t){function e(){var n=t!==null&&t.apply(this,arguments)||this;return n._name=rt.PUB_ACK,n.status=0,n.date=0,n.millisecond=0,n.messageUId="",n.timestamp=0,n.identifier=Qt.PUB,n.topic="",n.targetId="",n}return Oe(e,t),e.prototype.readMessage=function(n,r){return t.prototype.readMessage.call(this,n,r),this.date=n.readInt(),this.status=256*n.readByte()+n.readByte(),this.millisecond=256*n.readByte()+n.readByte(),this.timestamp=1e3*this.date+this.millisecond,this.messageUId=n.readUTF(),{stream:n,length:r}},e}(ca),xu=function(t){function e(n){var r=t.call(this,qe.PUB_ACK)||this;return r._name=rt.PUB_ACK,r.status=0,r.date=0,r.millisecond=0,r.messageUId="",r.timestamp=0,r.messageId=n,r}return Oe(e,t),e.prototype.writeMessage=function(n){t.prototype.writeMessage.call(this,n)},e}(Ui),ie=function(t){function e(n,r,i){var o=t.call(this,qe.QUERY)||this;return o.name=rt.QUERY,o.identifier=Qt.QUERY,o.topic=n,o.data=nt(r)?ur.writeUTF(r):r,o.targetId=i,o}return Oe(e,t),e.prototype.writeMessage=function(n){n.writeUTF(this.topic),n.writeUTF(this.targetId),t.prototype.writeMessage.call(this,n),n.write(this.data)},e}(Ui),Bu=function(t){function e(n){var r=t.call(this,qe.QUERY_CONFIRM)||this;return r._name=rt.QUERY_CON,r.messageId=n,r}return Oe(e,t),e}(Ui),Yn=function(t){function e(){var n=t!==null&&t.apply(this,arguments)||this;return n._name=rt.QUERY_ACK,n.status=0,n.identifier=Qt.QUERY,n.topic="",n.targetId="",n}return Oe(e,t),e.prototype.readMessage=function(n,r){return t.prototype.readMessage.call(this,n,r),this.date=n.readInt(),this.status=256*n.readByte()+n.readByte(),this.data=n.readAll(),{stream:n,length:r}},e}(ca),Vu=function(t){var e,n=t.type;switch(n){case qe.CONN_ACK:e=new Uu(t);break;case qe.PUBLISH:(e=new ir(t)).syncMsg=t.syncMsg;break;case qe.PUB_ACK:e=new $o(t);break;case qe.QUERY_ACK:e=new Yn(t);break;case qe.SUB_ACK:case qe.UNSUB_ACK:case qe.PING_RESP:e=new Du(t);break;case qe.DISCONNECT:e=new aa(t);break;default:e=new dr(t),G.error("No support for deserializing "+n+" messages")}return e};(function(t){t[t.ppMsgP=1]="ppMsgP",t[t.ppMsgN=2]="ppMsgN",t[t.ppMsgS=3]="ppMsgS",t[t.pgMsgP=4]="pgMsgP",t[t.chatMsg=5]="chatMsg",t[t.pcMsgP=6]="pcMsgP",t[t.qryPMsg=7]="qryPMsg",t[t.qryGMsg=8]="qryGMsg",t[t.qryCHMsg=9]="qryCHMsg",t[t.qryCMsg=10]="qryCMsg",t[t.qrySMsg=11]="qrySMsg",t[t.recallMsg=12]="recallMsg",t[t.prMsgS=13]="prMsgS",t[t.rrMsg=14]="rrMsg",t[t.rrList=15]="rrList",t[t.s_ntf=16]="s_ntf",t[t.s_msg=17]="s_msg",t[t.s_stat=18]="s_stat",t[t.s_cmd=19]="s_cmd",t[t.s_us=20]="s_us",t[t.pullUS=21]="pullUS",t[t.pgMsgS=22]="pgMsgS",t[t.chatMsgS=23]="chatMsgS",t[t.qrySessionsAtt=24]="qrySessionsAtt",t[t.pullMsg=25]="pullMsg",t[t.qrySessions=26]="qrySessions",t[t.delSessions=27]="delSessions",t[t.delMsg=28]="delMsg",t[t.updRRTime=29]="updRRTime",t[t.chrmPull=30]="chrmPull",t[t.joinChrm=31]="joinChrm",t[t.joinChrmR=32]="joinChrmR",t[t.exitChrm=33]="exitChrm",t[t.queryChrmI=34]="queryChrmI",t[t.setKV=35]="setKV",t[t.delKV=36]="delKV",t[t.pullKV=37]="pullKV",t[t.qryRelation=38]="qryRelation",t[t.delRelation=39]="delRelation",t[t.pullSeAtts=40]="pullSeAtts",t[t.setSeAtt=41]="setSeAtt",t[t.qnTkn=42]="qnTkn",t[t.qnUrl=43]="qnUrl",t[t.aliUrl=44]="aliUrl",t[t.s3Url=45]="s3Url",t[t.stcUrl=46]="stcUrl",t[t.cleanPMsg=47]="cleanPMsg",t[t.cleanGMsg=48]="cleanGMsg",t[t.cleanCMsg=49]="cleanCMsg",t[t.cleanSMsg=50]="cleanSMsg",t[t.rtcRJoin_data=51]="rtcRJoin_data",t[t.rtcRExit=52]="rtcRExit",t[t.rtcPing=53]="rtcPing",t[t.rtcSetData=54]="rtcSetData",t[t.rtc_ntf=55]="rtc_ntf",t[t.viewerJoinR=56]="viewerJoinR",t[t.viewerExitR=57]="viewerExitR",t[t.rtcPullKv=58]="rtcPullKv",t[t.rtcIdentityChange=59]="rtcIdentityChange",t[t.userSetData=60]="userSetData",t[t.rtcQryData=61]="rtcQryData",t[t.rtcDelData=62]="rtcDelData",t[t.rtcSetOutData=63]="rtcSetOutData",t[t.rtcQryUserOutData=64]="rtcQryUserOutData",t[t.rtcToken=65]="rtcToken",t[t.rtcUserState=66]="rtcUserState",t[t.rtcRInfo=67]="rtcRInfo",t[t.rtcUData=68]="rtcUData",t[t.rtcUPut=69]="rtcUPut",t[t.rtcUDel=70]="rtcUDel",t[t.rtcUList=71]="rtcUList",t[t.rtcQueryJoined=72]="rtcQueryJoined",t[t.addSeTag=73]="addSeTag",t[t.delSeTag=74]="delSeTag",t[t.addTag=75]="addTag",t[t.delTag=76]="delTag",t[t.disTag=77]="disTag",t[t.reportsdk=78]="reportsdk",t[t.rtcInvite=79]="rtcInvite",t[t.rtcCancelInvite=80]="rtcCancelInvite",t[t.rtcInviteAnswer=81]="rtcInviteAnswer",t[t.rtcEndInvite=82]="rtcEndInvite"})(jo||(jo={}));var gt,D=jo,Fu=function(t,e,n,r){return x(void 0,void 0,void 0,function(){var i;return B(this,function(o){return i=0,t.forEach(function(s){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+"://"+s+"/ping?r="+(a=9999,(h=1e3)+Math.floor(Math.random()*(a-h))),G.debug("start ping",c),[4,n.httpReq({url:c,timeout:5e3})];case 1:return d=l.sent(),G.debug("end ping",i,c,d.status),i++,r({finished:i===t.length,code:d.status,host:s}),[2]}var h,a})})}),[2]})})},Hu=function(t,e,n,r,i,o,s,c){return t+"://"+e+"/websocket?appId="+n+"&token="+encodeURIComponent(r)+"&sdkVer="+o+"&pid="+s+"&apiVer="+(i.isFromUniapp?"uniapp":"normal")+(i.connectPlatform?"&platform="+i.connectPlatform:"")+(c?"&protocolVer="+c:"")},ju=function(t){return[D.ppMsgS,D.pgMsgS,D.chatMsgS].map(function(e){return D[e]}).indexOf(t)>=0};(function(t){t[t.REDIRECT=0]="REDIRECT",t[t.OTHER_DEVICE_LOGIN=1]="OTHER_DEVICE_LOGIN",t[t.BLOCK=2]="BLOCK",t[t.REMOTE_CLOSE=3]="REMOTE_CLOSE",t[t.LOGOUT=4]="LOGOUT",t[t.BLOCK_NEW=5]="BLOCK_NEW",t[t.REDIRECT_NEW=6]="REDIRECT_NEW"})(gt||(gt={}));var _t,Xa=function(t,e){G.info("websocket send -> messageId: "+t.messageId);var n=t.getBufferData();e.send(n.buffer)},Sn=function(t){function e(n,r){var i=t.call(this,"websocket",r)||this;return i._runtime=n,i._socket=null,i._messageIds={},i._syncMessageIds={},i._failedCount=0,i.ALLOW_FAILED_TIMES=2,i._timer=null,i._idCount=0,i._generateMessageId=function(){return i._idCount>=65535&&(i._idCount=0),++i._idCount},i}return Oe(e,t),e.prototype.connect=function(n,r,i,o,s,c){return 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(n,r,a.shift(),o,s,c)]);case 1:if((_=v.sent())===O.SUCCESS)this._checkAlive(),h(_);else if(_===Ke.REDIRECT)h(_);else{if(p&&a.length===0)return h(_u(_)),[2];f=!1,m()}return[2]}})})};s=hs(s),d._watcher.status(ae.CONNECTING),Fu(i,o,d._runtime,function(_){var v=_.code,y=_.finished,C=_.host;p=y,v===200&&(a.push(C),u++,m()),y&&u===0&&(G.error("No valid websocket server hosts!"),h(O.RC_SOCKET_NOT_CREATED))})})]})})},e.prototype._connect=function(n,r,i,o,s,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=o.replace("http","ws"),l=Hu(d,i,n,r,this._runtime,s,"",c),G.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 N=new Uint8Array(C),S=new sh(N),E=S.readByte(),w=new gs(E),V=Vu(w);return V.read(S,N.length-1,b),V}(_,c);if(v instanceof Du&&f._pingResolve)return f._pingResolve(O.SUCCESS),void(f._pingResolve=void 0);if(v instanceof Uu)return G.debug("recv connect ack -> "+v.status),v.status!==Ke.ACCEPTED?(G.warn("connect failed: "+v.status),void m(v.status)):(G.info("connect success -> "+l),f.connectedTime=v.timestamp,f.userId=v.userId||"",f._idCount=v.messageId,void m(O.SUCCESS));if(v instanceof aa){var y=v.status;switch(G.warn("recv disconnect signal -> status: "+y),y){case gt.BLOCK:f._watcher.status(ae.BLOCKED);break;case gt.OTHER_DEVICE_LOGIN:f._watcher.status(ae.KICKED_OFFLINE_BY_OTHER_CLIENT);break;case gt.REDIRECT_NEW:case gt.REDIRECT:f._watcher.status(ae.REDIRECT);break;default:f._watcher.status(ae.DISCONNECT_BY_SERVER)}}else f._onReceiveSignal(v)}else G.error("Socket received invalid data:",_)}),h.onClose(function(_,v){for(var y in G.warn("websocket closed! code:",_,"reason:",v),a(ae.CONNECTION_CLOSED),f._messageIds){var C=f._messageIds[y];delete f._messageIds[y],C(O.RC_NET_CHANNEL_INVALID)}m(_)}),h.onError(function(_){var v;for(var y in G.error("websocket error!",(v=_)===null||v===void 0?void 0:v.stack),a(ae.WEBSOCKET_ERROR),f._messageIds){var C=f._messageIds[y];delete f._messageIds[y],C(O.RC_NET_CHANNEL_INVALID)}m(O.NETWORK_ERROR)}),h.onOpen(function(){return G.debug("websocket open =>",l)}),setTimeout(function(){m(O.TIMEOUT)},5e3)})];case 1:return(u=p.sent())===O.SUCCESS?this._socket=h:(G.warn("connect result -> code: "+u+", url: "+l),h.close()),[2,u]}})})},e.prototype._checkAlive=function(){var n;return x(this,void 0,void 0,function(){var r,i=this;return B(this,function(o){switch(o.label){case 0:return this._socket?(G.debug("send ping ->"),this.sendOnly(new Lh),[4,new Promise(function(s){i._pingResolve=s,i._timer&&clearTimeout(i._timer),i._timer=setTimeout(function(){i._pingResolve=void 0,s(O.TIMEOUT)},15e3)})]):[2];case 1:return(r=o.sent())!==O.SUCCESS?(this._failedCount+=1,G.warn("ping failed count: "+this._failedCount+", code: "+r),this._failedCount>=this.ALLOW_FAILED_TIMES?(this._failedCount=0,G.warn("ping timeout, close current websocket to reconnect!"),(n=this._socket)===null||n===void 0||n.close(),this._watcher.status(ae.NETWORK_UNAVAILABLE)):this._checkAlive(),[2]):(G.debug("recv pong <-"),this._failedCount=0,setTimeout(function(){return i._checkAlive()},15e3),[2])}})})},e.prototype._onReceiveSignal=function(n){return x(this,void 0,void 0,function(){var r,i,o,s,c,d,l=this;return B(this,function(h){switch(h.label){case 0:return r=n.messageId,n.header&&n.header.qos!==wt.AT_MOST_ONCE&&(n instanceof ir&&!n.syncMsg&&(G.debug("send pubAck -> "+r),this.sendOnly(new xu(r))),n instanceof Yn&&(G.debug("send queryCon -> "+r),this.sendOnly(new Bu(r)))),r>0&&(n instanceof $o||n instanceof Yn)&&(G.debug("recv ack -> messageId: "+r),(i=this._messageIds[r])&&(i(n),delete this._messageIds[r]),(o=this._syncMessageIds[r])&&(delete this._syncMessageIds[r],o(n))),n instanceof ir?(s=n.syncMsg,(c=n.topic)===D[D.userSetData]?[2]:!s||ju(c)?(this._watcher.signal(n),[2]):[4,new Promise(function(a){l._syncMessageIds[r]=a})]):[3,2];case 1:d=h.sent(),delete this._syncMessageIds[r],this._watcher.signal(n,d),h.label=2;case 2:return[2]}})})},e.prototype.sendOnly=function(n){this._socket&&Xa(n,this._socket)},e.prototype.send=function(n,r,i,o){return o===void 0&&(o=3e4),x(this,void 0,void 0,function(){var s,c,d,l=this;return B(this,function(h){switch(h.label){case 0:return this._socket?(s=this._generateMessageId(),n.messageId=s,Xa(n,this._socket),[4,new Promise(function(a){l._messageIds[s]=a,setTimeout(function(){l._messageIds[s]&&delete l._messageIds[s],a()},o)})]):[3,2];case 1:return(c=h.sent())?c instanceof Yn||c instanceof $o?(d=r&&c.data?this.codec.decodeByPBName(c.data,r,i):c,c.status!==0?(G.warn("send failed -> message: "+s+", respPBName: "+r+", status: "+c.status),[2,{code:c.status,data:r&&c.data?d:null}]):[2,{code:O.SUCCESS,data:d}]):[2,{code:c}]:(G.warn("send timeout -> message: "+s+", respPBName: "+r+", timeout: "+o),[2,{code:O.TIMEOUT}]);case 2:return[2,{code:O.RC_NET_CHANNEL_INVALID}]}})})},e.prototype.close=function(){this._socket&&(this._socket.close(),this._socket=null,this._watcher.status(ae.DISCONNECTED))},e}(Pu);(function(t){t.GET="GET",t.POST="POST"})(_t||(_t={}));var In=function(t){function e(n,r){var i=t.call(this,"comet",r)||this;return i._runtime=n,i._messageIds={},i._syncMessageIds={},i._idCount=0,i._generateMessageId=function(){return++i._idCount},i._pid=encodeURIComponent(new Date().getTime()+Math.random()+""),i}return Oe(e,t),e.prototype.handleCometRes=function(n){var r=this;if(n.status!==200&&n.status!==202)return!1;var i=nt(n.data)?JSON.parse(n.data):n.data;return i?!Qe(i)||(Me(i,function(o){return x(r,void 0,void 0,function(){var s,c,d,l,h,a,u,f,p,m,_,v=this;return B(this,function(y){switch(y.label){case 0:if((s=o.sessionid)&&(this._sessionid=s),c=function(C){var b=C.headerCode,N=new gs(b),S=Vu(N);for(var E in C)S[E]=C[E];return S}(o),d=c.messageId,l=c._header,h=c.status,c.identifier,a=l&&l.qos!==wt.AT_MOST_ONCE,d&&c.getIdentifier&&((u=this._messageIds[d])&&u(c),this._syncMessageIds[d]&&this._syncMessageIds[d](c)),a&&(c instanceof ir&&!c.syncMsg&&(f=new xu(d),this.sendOnly(f)),c instanceof Yn&&(f=new Bu(d),this.sendOnly(f))),c instanceof aa){switch(h){case gt.OTHER_DEVICE_LOGIN:this._watcher.status(ae.KICKED_OFFLINE_BY_OTHER_CLIENT);break;case gt.BLOCK:this._watcher.status(ae.BLOCKED);break;case gt.REDIRECT_NEW:case gt.REDIRECT:this._watcher.status(ae.REDIRECT);break;default:this._watcher.status(ae.DISCONNECT_BY_SERVER)}return[2]}return c instanceof ir?(p=c.syncMsg,m=c.topic,!p||ju(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):(G.error("received data is not a validJson",i),!1)},e.prototype._startPullSignal=function(n){return x(this,void 0,void 0,function(){var r,i,o,s;return B(this,function(c){switch(c.label){case 0:return r=new Date().getTime(),i=n+"://"+this._domain+"/pullmsg.js?sessionid="+this._sessionid+"×trap="+r+"&pid="+this._pid,[4,this._runtime.httpReq({url:i,body:{pid:this._pid},timeout:45e3})];case 1:return o=c.sent(),s=this.handleCometRes(o),this._isDisconnected||(s?this._startPullSignal(n):(this._isDisconnected=!0,this._watcher.status(ae.NETWORK_UNAVAILABLE))),[2]}})})},e.prototype.connect=function(n,r,i,o,s,c){return x(this,void 0,void 0,function(){var d,l,h,a,u=this;return B(this,function(f){return s=hs(s),this._protocol=o,this._isDisconnected=!1,this._watcher.status(ae.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(n,r,d.shift(),o,s)]);case 1:if((_=v.sent())===O.SUCCESS)this._startPullSignal(o),p(_);else if(_===Ke.REDIRECT)p(_);else{if(a&&d.length===0)return p(_u(_)),[2];h=!1,m()}return[2]}})})};u._watcher.status(ae.CONNECTING),Fu(i,o,u._runtime,function(_){var v=_.code,y=_.finished,C=_.host;a=y,v===200&&(d.push(C),l++,m()),y&&l===0&&(G.error("No valid websocket server hosts!"),p(O.RC_SOCKET_NOT_CREATED))})})]})})},e.prototype._connect=function(n,r,i,o,s){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?(G.error("handle comet res -> res: "+JSON.stringify(u||{})),!1):!!u.data&&(function(f){if(je(f))return!0;var p=!1;try{var m=JSON.parse(f);p=JSON.stringify(m)===f}catch{p=!1}return p}(u.data)?je(u.data)?u.data:JSON.parse(u.data):(G.error("received data is not a validJson",u.data),!1))},d=Hu(o,i,n,r,this._runtime,s,this._pid),this.sendConnectTime=Date.now(),G.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):G.warn("connect result -> code: "+(h==null?void 0:h.status)+", url: "+d),[2,h==null?void 0:h.status]}})})},e.prototype.sendCometData=function(n,r){return x(this,void 0,void 0,function(){var i,o,s,c,d,l,h,a,u,f;return B(this,function(p){switch(p.label){case 0:return o=(i=this)._domain,s=i._sessionid,c=i._pid,d=n.messageId,l=n.topic,h=n.targetId,n.identifier,a=n.getHeaderFlag(),u=l?this._protocol+"://"+o+"/websocket?messageid="+d+"&header="+a+"&sessionid="+s+"&topic="+l+"&targetid="+h+"&pid="+c:this._protocol+"://"+o+"/websocket?messageid="+d+"&header="+a+"&sessionid="+s+"&pid="+c,[4,this._runtime.httpReq({url:u,method:_t.POST,body:n.getCometData()})];case 1:return f=p.sent(),this.handleCometRes(f),[2]}})})},e.prototype.sendOnly=function(n){this.sendCometData(n)},e.prototype.send=function(n,r,i,o){return o===void 0&&(o=3e4),x(this,void 0,void 0,function(){var s,c,d,l=this;return B(this,function(h){switch(h.label){case 0:return s=this._generateMessageId(),n.messageId=s,this.sendCometData(n),[4,new Promise(function(a){l._messageIds[s]=a,setTimeout(function(){delete l._messageIds[s],a()},o)})];case 1:return(c=h.sent())?(d=r&&c.data?this.codec.decodeByPBName(c.data,r,i):c,c.status!==0?[2,{code:c.status,data:r&&c.data?d:null}]:[2,{code:O.SUCCESS,data:d}]):[2,{code:O.TIMEOUT}]}})})},e.prototype.close=function(){this._isDisconnected=!0,this._watcher.status(ae.DISCONNECTED)},e}(Pu),kh=function(t,e,n){this.runtime=t,this._watcher=e,this._options=n,this.currentUserId="",this._appkey=this._options.appkey,this._apiVer=this._options.apiVersion,this.navi=this._createNavi()},Zi=function(t){return["navi",t].join("_")},Uh=function(){function t(e,n){this._runtime=e,this._options=n,this._naviInfo=null,this._appkey=this._options.appkey,this._apiVersion=hs(this._options.apiVersion)}return t.prototype.getInfo=function(e,n,r,i){return x(this,void 0,void 0,function(){var o,s;return B(this,function(c){switch(c.label){case 0:return r&&this._clear(e),(o=function(d,l,h){var a,u,f=Zi(d);try{var p=h.getItem(f);u=p?JSON.parse(p):[]}catch{u=[]}var m=Date.now();return u.length>0&&(u=u.filter(function(_){return m-_.timestamp<72e5})),u.length===0?h.removeItem(f):h.setItem(f,JSON.stringify(u)),((a=u.find(function(_){return _.token===l}))===null||a===void 0?void 0:a.naviInfo)||null}(this._appkey,e,this._runtime.localStorage))?(this._naviInfo=o,[2,o]):(s=this._options.navigators.slice(),n.length&&n.forEach(function(d){s.indexOf(d)<0&&s.unshift(d)}),[4,this._reqNavi(s,this._appkey,e,i)]);case 1:return(o=c.sent())?(this._naviInfo=o,this.setNaviInfo2Cache(e,o),[2,o]):[2,o]}})})},t.prototype.setNaviInfo2Cache=function(e,n){this._naviInfo=n,function(r,i,o,s){var c,d=Zi(r);try{var l=s.getItem(d);c=l?JSON.parse(l):[]}catch{c=[]}var h=Date.now();c.length>0&&(c=c.filter(function(a){return h-a.timestamp<72e5&&i!==a.token})),c.push({timestamp:h,naviInfo:o,token:i}),s.setItem(d,JSON.stringify(c))}(this._appkey,e,n,this._runtime.localStorage)},t.prototype.getInfoFromCache=function(e){return this._naviInfo},t.prototype._clear=function(e){(function(n,r,i){var o,s=Zi(n);try{var c=i.getItem(s);o=c?JSON.parse(c):[]}catch{o=[]}var d=Date.now();o.length>0&&(o=o.filter(function(l){return d-l.timestamp<72e5&&r!==l.token})),o.length===0?i.removeItem(s):i.setItem(s,JSON.stringify(o))})(this._appkey,e,this._runtime.localStorage)},t}(),Rr=function(t,e,n){return[t,e,n].join("_")},Dh=function(){function t(e,n){this._runtime=e,this._appkey=n,this._users={}}return t.prototype._getMemData=function(e){return this._users[e]||(this._users[e]={inboxTime:0,outboxTime:0})},t.prototype.setInboxTime=function(e,n){var r=this._getMemData(n);if(!(r.inboxTime>e)){r.inboxTime=e;var i=Rr("inbox",this._appkey,n);this._runtime.localStorage.setItem(i,e.toString())}},t.prototype.getInboxTime=function(e){var n=this._getMemData(e);if(n.inboxTime===0){var r=Rr("inbox",this._appkey,e);n.inboxTime=parseInt(this._runtime.localStorage.getItem(r))||0}return n.inboxTime},t.prototype.setOutboxTime=function(e,n){var r=this._getMemData(n);if(!(r.outboxTime>=e)){r.outboxTime=e;var i=Rr("outbox",this._appkey,n);this._runtime.localStorage.setItem(i,e.toString())}},t.prototype.getOutboxTime=function(e){var n=this._getMemData(e);if(n.outboxTime===0){var r=Rr("outbox",this._appkey,e);n.outboxTime=parseInt(this._runtime.localStorage.getItem(r))||0}return n.outboxTime},t}(),eo={_caches:{},set:function(t,e){this._caches[t]=e},get:function(t){return this._caches[t]||0},clear:function(t){this._caches[t]=0}},xh=function(){function t(e,n){this._kvCaches={},this._chatroomId=e,this._currentUserId=n}return t.prototype._add=function(e){var n=e.key;e.isDeleted=!1,this._kvCaches[n]=e},t.prototype._remove=function(e){var n=e.key,r=this._kvCaches[n];r&&(r.isDeleted=!0,this._kvCaches[n]=r)},t.prototype._setEntry=function(e,n){var r=e.key,i=e.type,o=e.isOverwrite,s=e.userId,c=this._getSetUserId(r),d=i===Ze.DELETE,l=c===s,h=!this._isExisted(r),a=d?this._remove:this._add;(n||o||l||h)&&a.call(this,e)},t.prototype.getValue=function(e){var n=this._kvCaches[e]||{};return n.isDeleted?null:n.value},t.prototype.getAllValue=function(){var e={};for(var n in this._kvCaches)this._kvCaches[n].isDeleted||(e[n]=this._kvCaches[n].value);return e},t.prototype._getSetUserId=function(e){return(this._kvCaches[e]||{}).userId},t.prototype._isExisted=function(e){var n=this._kvCaches[e]||{},r=n.value,i=n.isDeleted;return r&&!i},t.prototype.setEntries=function(e){var n=this,r=e.kvEntries,i=e.isFullUpdate;r=r||[],(i=i||!1)&&this.clear(),r.forEach(function(o){n._setEntry(o,i)}),G.debug("end setEntries")},t.prototype.clear=function(){this._kvCaches={}},t}(),Bh=function(){function t(e){this._pullQueue=[],this._isPulling=!1,this._storeCaches={},this._engine=e}return t.prototype._startPull=function(){return x(this,void 0,void 0,function(){var e,n,r,i,o,s,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],n=e.chrmId,r=e.timestamp,(i=eo.get(n))>r?(this._isPulling=!1,this._startPull(),[2]):[4,this._engine.pullChatroomEntry(n,i)]);case 1:return o=d.sent(),s=o.code,c=o.data,this._isPulling=!1,s===O.SUCCESS?(eo.set(n,c.syncTime||0),this._startPull()):this._startPull(),[2]}})})},t.prototype.reset=function(e){eo.clear(e);var n=this._storeCaches[e];n&&n.clear()},t.prototype.pullEntry=function(e,n){this._pullQueue.push({chrmId:e,timestamp:n}),this._startPull()},t.prototype.setLocal=function(e,n,r){var i=this._storeCaches[e];qn(i)||(i=new xh(e,r)),i.setEntries(n),this._storeCaches[e]=i},t.prototype.getValue=function(e,n){var r=this._storeCaches[e];return r?r.getValue(n):null},t.prototype.getAll=function(e){var n=this._storeCaches[e],r={};return n&&(r=n.getAllValue()),r},t}(),Vh=function(){function t(e,n,r,i){this._runtime=e,this._appkey=n,this._userId=r,this._canJoinMulipleChrm=i,this._sessionKey="",this._joinedChrmsInfo={},this._sessionKey="sync-chrm-"+this._appkey+"-"+this._userId}return t.prototype.set=function(e,n){n===void 0&&(n=10),!this._canJoinMulipleChrm&&(this._joinedChrmsInfo={}),this._joinedChrmsInfo[e]=n,this._runtime.sessionStorage.setItem(this._sessionKey,JSON.stringify(this._joinedChrmsInfo))},t.prototype.get=function(){var e,n;try{n=this._runtime.sessionStorage.getItem(this._sessionKey),e=JSON.parse(n||"{}")}catch{G.error("parse rejoined chrm infos error -> "+n),e={}}return e},t.prototype.remove=function(e){delete this._joinedChrmsInfo[e],qn(this._joinedChrmsInfo)?this._runtime.sessionStorage.setItem(this._sessionKey,JSON.stringify(this._joinedChrmsInfo)):this.clear()},t.prototype.clear=function(){this._joinedChrmsInfo={},this._runtime.sessionStorage.removeItem(this._sessionKey)},t}(),to="converStatusChanged",Fh=function(){function t(e,n,r){this._eventEmitter=new cr,this._pullQueue=[],this._isPulling=!1,this._storage=Ti(e.runtime),this._appkey=n,this._currentUserId=r,this._engine=e,this._storagePullTimeKey="con-s-"+n+"-"+r}return t.prototype._set=function(e){var n=this;if(!me(e)&&Array.isArray(e)){var r=this._storage.get(this._storagePullTimeKey)||0,i=e.length;e.forEach(function(o,s){var c=o.updatedTime||0;r=c>r?c:r,o.conversationType=o.type,n._eventEmitter.emit(to,{statusItem:o,isLastPull:s===i-1})}),this._storage.set(this._storagePullTimeKey,r)}},t.prototype._startPull=function(){return x(this,void 0,void 0,function(){var e,n,r,i;return B(this,function(o){switch(o.label){case 0:return this._isPulling||this._pullQueue.length===0?[2]:(this._isPulling=!0,e=this._pullQueue.splice(0,1)[0],[4,this._engine.pullConversationStatus(e)]);case 1:return n=o.sent(),r=n.code,i=n.data,r===O.SUCCESS?(this._isPulling=!1,this._set(i),this._startPull()):this._startPull(),[2]}})})},t.prototype.pull=function(e){var n=this._storage.get(this._storagePullTimeKey)||0;(e>n||e===0)&&(this._pullQueue.push(n),this._startPull())},t.prototype.watch=function(e){this._eventEmitter.on(to,function(n){e(n)})},t.prototype.unwatch=function(){this._eventEmitter.off(to,function(e){})},t}(),qt={c:{keyName:"unreadMessageCount",defaultVal:0},hm:{keyName:"hasMentioned",defaultVal:!1},m:{keyName:"mentionedInfo",defaultVal:null},t:{keyName:"lastUnreadTime",defaultVal:0},nc:{keyName:"notificationStatus",defaultVal:2},to:{keyName:"isTop",defaultVal:!1},tg:{keyName:"tags",defaultVal:{}},mc:{keyName:"unreadMentionedCount",defaultVal:0}},Hr={};for(var Za in qt){var Hh=qt[Za].keyName;Hr[Hh]=Za}var Un,jh=function(){function t(e,n,r){this._appkey=n,this._currentUserId=r;var i="con-"+n+"-"+r;this.storage=new La(e,i),this._localStore=new La(e,"CONVER-"+n+"-"+r)}return t.prototype._getStoreKey=function(e,n,r){return r+"_"+e+"_"+n},t.prototype._getConOptionByKey=function(e){var n=(e=e||"").split("_");if(n.length>=2){var r=n.shift(),i=n.shift(),o=n.join("_");return{conversationType:Number(i),targetId:o,channelId:r}}return{conversationType:re.PRIVATE,targetId:"",channelId:""}},t.prototype.updateMentionedData=function(e){var n=this,r=e.conversationType,i=e.targetId,o=e.messageType,s=e.isMentioned,c=e.content,d=e.senderUserId,l=e.channelId,h=this._getStoreKey(r,i,l),a=this._localStore.get(h)||{},u=Hr.mentionedInfo,f=Hr.hasMentioned,p=a[u]||{},m=p.userIdList||[],_=c.mentionedInfo;if(_){if(s&&r===re.GROUP&&((_.userIdList||[]).forEach(function(y){y===n._currentUserId&&m.indexOf(d)<0&&m.push(d)}),_.type===ps.ALL&&m.indexOf(d)<0&&m.push(d)),o===Ge.RECALL&&r===re.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]),qn(a)?this._localStore.set(h,a):this._localStore.remove(h)}},t.prototype.set=function(e,n,r,i){var o=this._getStoreKey(e,n,i),s=this._localStore.get(o)||{};for(var c in r){var d=Hr[c],l=r[c];if(!me(d)&&!me(l)&&c!=="hasMentioned"&&c!=="MentionedInfo"){if(l===qt[d].defaultVal||c==="tags"&&!qn(l))delete s[d];else if(c==="tags"){var h=l;for(var a in h)h[a].isTop||delete h[a].isTop;s[d]=l}else s[d]=l;s.c||(delete s.t,delete s.hm,delete s.m,delete s.mc)}}qn(s)?this._localStore.set(o,s):this._localStore.remove(o)},t.prototype.get=function(e,n,r){r===void 0&&(r="");var i=this._getStoreKey(e,n,r),o=this._localStore.get(i)||{},s={};for(var c in qt){var d=qt[c],l=d.keyName,h=d.defaultVal;s[l]=o[c]||Fr(h)}return s},t.prototype.getValue=function(e){var n=this._localStore.getValues()||{},r=[];for(var i in n){var o=this._getConOptionByKey(i),s={conversationType:o.conversationType,targetId:o.targetId,channelId:o.channelId},c=n[i];for(var d in c){var l=qt[d],h=l.keyName,a=l.defaultVal;s[h]=c[d]||Fr(a)}s=e?e(s):s,r.push(s)}return r},t.prototype.getValueForTag=function(){var e=this._localStore.getValues()||{},n={};for(var r in e){var i=this._getConOptionByKey(r),o=i.conversationType,s=i.targetId,c={},d=e[r];for(var l in d){var h=qt[l],a=h.keyName,u=h.defaultVal;c[a]=d[l]||Fr(u)}for(var f in c.tags){me(n[f])&&(n[f]=[]);var p=Object.assign({},c,{conversationType:o,targetId:s});delete p.tags,n[f].push(p)}}return n},t.prototype.adaptOldStore=function(){try{var e=this.storage.getValues();if(Object.keys(e).length===0)return;for(var n in e){var r="_"+n;this._localStore.set(r,e[n])}}catch(i){G.error("adaptOldStore error: "+i.message)}},t}(),$h=[re.PRIVATE,re.GROUP,re.SYSTEM,re.PUBLIC_SERVICE,re.APP_PUBLIC_SERVICE],ec="conversationChanged",tc="conTagStatusChanged",Kh=function(){function t(e,n,r,i,o){var s=this;this._updatedConversations={},this._conTagStatusChanged=!1,this._eventEmitter=new cr,this._draftMap={},this._appkey=n,this._loginUserId=r,this._store=new jh(e.runtime,n,r),this._statusManager=new Fh(e,n,r),this._statusManager.watch(function(c){var d=c.statusItem,l=c.isLastPull;s.addStatus(d,l)}),this._eventEmitter.on(ec,function(c){i(c)}),this._eventEmitter.on(tc,function(){o()})}return t.prototype._calcUnreadCount=function(e,n){var r=e.content,i=e.messageType,o=e.sentTime,s=e.isCounted,c=e.messageDirection,d=e.senderUserId,l=c===ct.SEND&&d===this._loginUserId,h=i===Ge.RECALL,a=je(r),u=!1,f={},p=n.lastUnreadTime||0,m=n.unreadMessageCount||0;return p>o||l?{hasChanged:u,localConversation:n,updateItems:f}:(s&&(n.unreadMessageCount=m+1,n.lastUnreadTime=o,u=!0),h&&a&&p>=r.sentTime&&m&&(n.unreadMessageCount=m-1,u=!0),u&&(f.unreadMessageCount={val:n.unreadMessageCount,time:o}),{hasChanged:u,localConversation:n,updateItems:f})},t.prototype._calcMentionedInfo=function(e,n){var r=e.content,i=(e.messageDirection,e.isMentioned),o=e.sentTime;ct.SEND;var s=je(r),c=!1,d={};return i&&s&&r.mentionedInfo&&(n.hasMentioned=!0,c=!0,d.hasMentioned={val:!0,time:o},d.mentionedInfo={val:r.mentionedInfo,time:o}),{hasChanged:c,localConversation:n,updateItems:d}},t.prototype._calcMentionedCount=function(e,n){var r=e.content,i=e.messageDirection,o=!1;if(e.isMentioned&&i===ct.RECEIVE&&(r==null?void 0:r.mentionedInfo)){var s=r.mentionedInfo,c=s.type,d=s.userIdList;if(c===ps.ALL||(d||[]).includes(this._loginUserId)){o=!0;var l=n.unreadMentionedCount||0;n.unreadMentionedCount=l+1}}return{hasChanged:o,localConversation:n}},t.prototype._setUpdatedConversation=function(e){if(je(e)){var n=e.conversationType,r=e.targetId,i=e.channelId,o=n+"_"+r,s=this._store.get(n,r,i)||{};this._updatedConversations[o]=Object.assign(s,e)}},t.prototype._setConTagStatusChanged=function(e,n,r,i){var o=(this._store.get(e,n,i)||{}).tags||{};if(Object.keys(o).length===Object.keys(r).length){for(var s in o)if(!r[s]||o[s].isTop!==r[s].isTop)return void(this._conTagStatusChanged=!0)}else this._conTagStatusChanged=!0},t.prototype.addStatus=function(e,n){var r=e.conversationType,i=e.targetId,o=e.updatedTime,s=e.notificationStatus,c=e.isTop,d=e.tags,l=e.channelId,h={},a={};me(s)||(a.notificationStatus={time:o,val:s}),me(c)||(a.isTop={time:o,val:c}),me(d)||(a.tags={time:o,val:d},d==null||d.forEach(function(u){h[u.tagId]={isTop:u.isTop}})),this._setConTagStatusChanged(r,i,h,l),this._store.set(r,i,{notificationStatus:s,isTop:c,tags:h},l),this._setUpdatedConversation({conversationType:r,targetId:i,updatedItems:a,channelId:l}),n&&this._notifyConversationChanged()},t.prototype._notifyConversationChanged=function(){var e=[];for(var n in this._updatedConversations)e.push(this._updatedConversations[n]);e.length!==0&&(this._eventEmitter.emit(ec,e),this._updatedConversations={},this._conTagStatusChanged&&(this._eventEmitter.emit(tc),this._conTagStatusChanged=!1))},t.prototype.setConversationCacheByMessage=function(e,n){var r=this,i=e.conversationType,o=e.isPersited,s=e.targetId,c=e.channelId;if($h.indexOf(i)>=0){var d=!1,l=this._store.get(i,s,c),h={};if([this._calcUnreadCount,this._calcMentionedInfo,this._calcMentionedCount].forEach(function(f){var p=f.call(r,e,l),m=p.hasChanged,_=p.localConversation,v=p.updateItems;d=d||m,h=Ee(Ee({},h),v),l=Fr(_)}),d&&this._store.set(i,s,l,c),this._store.updateMentionedData(e),o){var a=this._store.get(i,s,c);a.updatedItems=Ee({latestMessage:{time:e.sentTime,val:e}},h),a.latestMessage=e;var u=Object.assign(a,{conversationType:i,targetId:s,channelId:c});this._setUpdatedConversation(u)}(d||o)&&this._notifyConversationChanged()}},t.prototype.get=function(e,n,r){return r===void 0&&(r=""),this._store.get(e,n,r)},t.prototype.getAllUnreadCount=function(e,n,r){var i=this._store.getValue(),o=0;return i.forEach(function(s){var c=s.unreadMessageCount,d=s.notificationStatus,l=s.conversationType;c=c||0,(r||d!==1)&&(n.length>0?n.includes(Number(l))&&(o+=Number(c)):o+=Number(c))}),o},t.prototype.getUnreadCountByTag=function(e,n){var r=this._store.getValueForTag()[e]||[],i=0;return r.forEach(function(o){var s=o.unreadMessageCount,c=o.notificationStatus;(n||c!==1)&&(s=s||0,i+=Number(s))}),i},t.prototype.getUnreadCount=function(e,n,r){return this._store.get(e,n,r).unreadMessageCount||0},t.prototype.clearUnreadCount=function(e,n,r,i){i===void 0&&(i=!0);var o=this._store.get(e,n,r),s=o.unreadMessageCount,c=o.hasMentioned,d={};if(s&&(o.unreadMessageCount=0,d.unreadMessageCount={val:0,time:Date.now()}),c&&(o.hasMentioned=!1,o.unreadMentionedCount=0,o.mentionedInfo=void 0,d.hasMentioned={val:!1,time:Date.now()},d.mentionedInfo={val:void 0,time:Date.now()}),this._store.set(e,n,o,r),i&&Object.keys(d).length!==0){var l=Object.assign(o,{conversationType:e,targetId:n,channelId:r,updatedItems:d});this._setUpdatedConversation(l),this._notifyConversationChanged()}},t.prototype.clearAllUnreadCount=function(){var e=this;this._store.getValue().forEach(function(n){n.unreadMessageCount&&(n.unreadMessageCount=0,e._store.set(n.conversationType,n.targetId,n,n.channelId))})},t.prototype.startPullConversationStatus=function(e){this._statusManager.pull(e)},t.prototype.setDraft=function(e,n,r,i){var o=e+"_"+n+"_"+i;this._draftMap[o]=r},t.prototype.getDraft=function(e,n,r){var i=e+"_"+n+"_"+r;return this._draftMap[i]},t.prototype.clearDraft=function(e,n,r){var i=e+"_"+n+"_"+r;delete this._draftMap[i]},t.prototype.addTagStatus=function(e,n,r,i){i===void 0&&(i="");var o=this._store.get(e,n,i).tags;o=Object.assign(o,r),this._store.set(e,n,{tags:o},i)},t.prototype.deleteTagStatus=function(e,n,r,i){i===void 0&&(i="");var o=this._store.get(e,n,i).tags;r.forEach(function(s){delete o[s]}),this._store.set(e,n,{tags:o},i)},t.prototype.getConversationListForTag=function(){return this._store.getValueForTag()},t.prototype.getBlockConversationList=function(){return this._store.getValue().filter(function(e){return e.notificationStatus===on.OPEN}).map(function(e){return{conversationType:e.conversationType,targetId:e.targetId,channelId:e.channelId}})},t.prototype.getTopConversationList=function(){return(this._store.getValue()||{}).filter(function(e){return e.isTop}).map(function(e){return{conversationType:e.conversationType,targetId:e.targetId,channelId:e.channelId}})},t.prototype.adaptOldStore=function(){this._store.adaptOldStore()},t.prototype.getUnreadMentionedCount=function(e,n,r){return e===void 0&&(e=""),this.get(n,r,e).unreadMentionedCount||0},t.prototype.getAllUnreadMentionedCount=function(){var e=this._store.getValue(),n=0;return e.forEach(function(r){var i=r.unreadMentionedCount;i=i||0,n+=Number(i)}),n},t}(),qh=function(){function t(e,n,r,i){this._pullQueue=[],this._isPulling=!1,this._storageTagKey="tag-"+n+"-"+r,this._storagePullTimeKey="us-s-"+n+"-"+r,this._storage=Ti(e.runtime),this._engine=e,this._tagWatcherFunc=i}return t.prototype._updateTag=function(e){var n=e.tags,r={};n.forEach(function(i){r[i.tagId]={tagName:i.tagName,createdTime:i.createdTime}}),this._storage.set(this._storageTagKey,r),this._tagWatcherFunc()},t.prototype.addTag=function(e,n){var r=this._storage.get(this._storageTagKey)||{};e.forEach(function(i){var o,s=((o=r[i.tagId])===null||o===void 0?void 0:o.createdTime)||i.createdTime||0;r[i.tagId]={tagName:i.tagName,createdTime:s}}),this._storage.set(this._storageTagKey,r),this._storage.set(this._storagePullTimeKey,n)},t.prototype.deleteTag=function(e,n){var r=this._storage.get(this._storageTagKey)||{};e.forEach(function(i){delete r[i]}),this._storage.set(this._storageTagKey,r),this._storage.set(this._storagePullTimeKey,n)},t.prototype.getTagsInfo=function(){return this._storage.get(this._storageTagKey)||{}},t.prototype.getTags=function(){var e=this._storage.get(this._storageTagKey)||{},n=[];for(var r in e)n.push({tagId:r,tagName:e[r].tagName,createdTime:e[r].createdTime,conversationCount:0});return n.sort(function(i,o){return(i.createdTime||0)-(o.createdTime||0)})},t.prototype.getTagById=function(e){var n=this._storage.get(this._storageTagKey)||{};return n[e]?{tagId:e,tagName:n[e].tagName,createdTime:n[e].createdTime,conversationCount:0}:null},t.prototype._startPull=function(){return x(this,void 0,void 0,function(){var e,n,r,i,o,s,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 n=l.sent(),r=n.code,i=n.data,r!==O.SUCCESS||me(i)?(this._isPulling=!1,this._startPull()):(s=(o=i).settings,c=o.version,d=s.Tag,me(d)||this._updateTag(d),this._storage.set(this._storagePullTimeKey,c),this._isPulling=!1,this._startPull()),[2]}})})},t.prototype.pullUserSettings=function(e){var n=this._storage.get(this._storagePullTimeKey)||0;(e>n||e===0)&&(this._pullQueue.push(n),this._startPull())},t.prototype.getVersion=function(){return this._storage.get(this._storagePullTimeKey)||0},t}(),Gh=function(t){function e(n,r){var i=t.call(this,n,r)||this;return i._miniConnectUrl="",i._connectType=r.connectionType,i}return Oe(e,t),e.prototype._formatJSONPUrl=function(n,r,i,o){return n+"/"+(this._runtime.isSupportSocket()&&this._connectType==="websocket"?"navi":"cometnavi")+".js?appId="+i+"&token="+encodeURIComponent(r)+"&callBack="+o+"&v="+this._apiVersion+"&r="+Date.now()},e.prototype.getInfo=function(n,r,i){var o;return x(this,void 0,void 0,function(){var s;return B(this,function(c){return this._runtime.useNavi||(s=void 0,s=this._runtime.isSupportSocket()&&this._connectType==="websocket"?Gl.join(","):Yl.join(","),this._miniConnectUrl=((o=this._options.miniCMPProxy)===null||o===void 0?void 0:o.length)?this._options.miniCMPProxy.join(","):s||"",r=[]),[2,t.prototype.getInfo.call(this,n,r,i)]})})},e.prototype._reqNavi=function(n,r,i){return x(this,void 0,void 0,function(){var o,s,c,d,l,h,a,u,f;return B(this,function(p){switch(p.label){case 0:o="getServerEndpoint",s=0,c=n.length,p.label=1;case 1:return s<c?(d=this._formatJSONPUrl(n[s],i,r,o),G.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?G.error("request navi error: "+O.RC_CONN_USER_OR_PASSWD_ERROR):l.status===401&&G.error("request navi error: "+O.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){G.error("parse navi err =>",m)}p.label=3;case 3:return s+=1,[3,1];case 4:return this._runtime.useNavi?[2,null]:[2,f={code:200,protocol:"https",server:"",voipCallInfo:"",kvStorage:0,openHttpDNS:!1,historyMsg:!1,chatroomMsg:!1,uploadServer:"https://upload.qiniup.com",bosAddr:"https://gz.bcebos.com",location:"",monitor:0,joinMChrm:!1,openMp:0,openUS:0,grpMsgLimit:0,isFormatted:0,gifSize:2048,logSwitch:0,logPolicy:"",compDays:0,msgAck:"",activeServer:"",qnAddr:"",extkitSwitch:0,alone:!1,voipServer:"",offlinelogserver:"",backupServer:this._miniConnectUrl}]}})})},e}(Uh),Yh=function(){function t(e){this._pullQueue=[],this._isPulling=!1,this._pullTime=0,this._engine=e}return t.prototype._startPull=function(){return x(this,void 0,void 0,function(){var e,n,r,i,o,s,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],n=e.roomId,r=e.timestamp,(i=this._pullTime)>r?(this._isPulling=!1,this._startPull(),[2]):[4,this._engine.pullRTCRoomEntry(n,i)]);case 1:return o=d.sent(),s=o.code,c=o.data,s===O.SUCCESS?(this._isPulling=!1,this._pullTime=c.syncTime||0,this._startPull()):this._startPull(),[2]}})})},t.prototype.pullEntry=function(e,n){this._pullQueue.push({roomId:e,timestamp:n}),this._startPull()},t.prototype.reset=function(){this._pullTime=0,this._isPulling=!1},t}(),no=function(t,e){return["send_msg",t,e].join("_")},Jh=function(){function t(e,n){this._runtime=e,this._appkey=n,this._sendMessageMap={},this._userId=""}return t.prototype.init=function(e){this._userId=e;var n=no(this._appkey,e);this._sendMessageMap=this._getLocalInfo(n)},t.prototype._getLocalInfo=function(e){var n=this._runtime.localStorage.getItem(e);try{return n?JSON.parse(n):{}}catch{return{}}},t.prototype.setMessage=function(e,n){this._sendMessageMap[e]=n;var r=no(this._appkey,this._userId),i=this._getLocalInfo(r);i[e]=n,this._runtime.localStorage.setItem(r,JSON.stringify(i))},t.prototype.getSendMessageMap=function(){return this._sendMessageMap},t.prototype.removeByUID=function(e){delete this._sendMessageMap[e]},t.prototype.removeByTimestamp=function(e){var n=no(this._appkey,this._userId),r=this._getLocalInfo(n);Object.keys(r).forEach(function(i){r[i]<e&&delete r[i]}),this._runtime.localStorage.setItem(n,JSON.stringify(r))},t}(),$u=function(t){var e="RCDeviceId",n=Ti(t),r="",i=n.get(e);return i?r=i:(r=gu(),n.set(e,r)),r};(Un={})[re.PRIVATE]=D.qryPMsg,Un[re.GROUP]=D.qryGMsg,Un[re.CHATROOM]=D.qryCHMsg,Un[re.CUSTOMER_SERVICE]=D.qryCMsg,Un[re.SYSTEM]=D.qrySMsg;var Wh=[D[D.recallMsg],D[D.ppMsgS],D[D.pgMsgS],D[D.ppMsgP],D[D.pgMsgP],D[D.chatMsg],D[D.pcMsgP],D[D.prMsgS]],ro=function(t,e,n,r,i,o){return{conversationType:t,targetId:e,senderUserId:o,messageDirection:ct.SEND,isCounted:!!n.isCounted,isMentioned:!!n.isMentioned,content:n.content,messageType:n.messageType,isOffLineMessage:!1,isPersited:!!n.isPersited,messageUId:r,sentTime:i,receivedTime:0,disableNotification:!!n.disableNotification,isStatusMessage:!!n.isStatusMessage,canIncludeExpansion:!!n.canIncludeExpansion,expansion:n.canIncludeExpansion?n.expansion:null,receivedStatus:Qn.UNREAD,pushConfig:n.pushConfig,channelId:n.channelId}},zh=function(t){function e(n,r,i){var o=t.call(this,n,r,i)||this;return o._customMessageType={},o._reconnectTimer=-1,o._pullOfflineFinished=!1,o._connectedTime=0,o._localConnectedTime=0,o._pullingMsg=!1,o._pullQueue=[],o._chrmsQueue={},o._latestSyncTimestamp=0,o._intervalTimer=-1,o._letterbox=new Dh(n,i.appkey),o._sendMessageStore=new Jh(n,i.appkey),o._chrmEntryHandler=new Bh(o),o}return Oe(e,t),e.prototype._createNavi=function(){return new Gh(this.runtime,this._options)},e.prototype.getConnectedTime=function(){return this._connectedTime},e.prototype.connect=function(n,r){return x(this,void 0,void 0,function(){var i,o,s,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):G.warn("navi.server is invalid"),(o=r.backupServer)&&o.split(",").forEach(function(a){i.indexOf(a)<0&&i.push(a)}),i.length===0?(G.error("navi invaild.",i),[2,O.UNKNOWN]):(s=this.runtime.createDataChannel({status:function(a){l._connectionStatusHandler(a,n,i,r.protocol)},signal:this._signalHandler.bind(this)},this._options.connectionType),c=Gt.V3,r.openAnti===1&&(c=Gt.V4),[4,s.connect(this._appkey,n,i,r.protocol,this._apiVer,c)]);case 1:return(d=h.sent())===O.SUCCESS?(this._channel=s,this.currentUserId=s.userId,this._connectedTime=s.connectedTime,this._localConnectedTime=Math.floor((Date.now()+s.sendConnectTime)/2),this._watcher.status(ae.CONNECTED),this._pullOfflineFinished=!1,this._conversationManager=new Kh(this,this._appkey,this.currentUserId,this._watcher.conversation,this._watcher.conversationTag),this._conversationManager.startPullConversationStatus(0),this._userSettingManager=new qh(this,this._appkey,this.currentUserId,this._watcher.tag),this._userSettingManager.pullUserSettings(0),this._sendMessageStore.init(this.currentUserId),this._conversationManager.adaptOldStore(),this._rtcKVManager=new Yh(this),this._joinedChrmManager=new Vh(this.runtime,this._appkey,this.currentUserId,r.joinMChrm),this._startSyncInterval()):s.close(),[2,d]}})})},e.prototype._connectionStatusHandler=function(n,r,i,o){if(G.warn("connection status changed:",n),n!==ae.CONNECTING)if(n!==ae.CONNECTED){if(this._channel&&n!==ae.DISCONNECTED)return n===ae.BLOCKED||n===ae.KICKED_OFFLINE_BY_OTHER_CLIENT||n===ae.DISCONNECT_BY_SERVER?(this.disconnect(),void this._watcher.status(n)):void(n!==ae.REDIRECT?(this._watcher.status(n),this._try2Reconnect(r,i,o)):this._watcher.status(n));this._watcher.status(n)}else this._watcher.status(n);else this._watcher.status(n)},e.prototype._try2Reconnect=function(n,r,i){return x(this,void 0,void 0,function(){var o,s=this;return B(this,function(c){switch(c.label){case 0:return this._channel?(o=Gt.V3,this._naviInfo.openAnti===1&&(o=Gt.V4),[4,this._channel.connect(this._appkey,n,r,i,this._apiVer,o)]):[2];case 1:return c.sent()===O.SUCCESS?(this._pullOfflineFinished=!1,this._startSyncInterval(),this._watcher.status(ae.CONNECTED),this._rejoinChrm(),G.__insertLogIntoDatabase(),[2]):(this._watcher.status(ae.WEBSOCKET_UNAVAILABLE),this._reconnectTimer=setTimeout(function(){s._reconnectTimer=-1,s._try2Reconnect(n,r,i)},5e3),[2])}})})},e.prototype._signalHandler=function(n,r){var i=n.syncMsg,o=n.topic;if(i)this._receiveSyncMsg(n,r);else{var s=D[o];if(s)switch(s){case D.s_ntf:G.info("recv s_ntf -> signal.messageId: "+n.messageId),this._pullMsg(n);break;case D.s_msg:this._receiveMsg(n);break;case D.s_cmd:this._receiveStateNotify(n);break;case D.s_us:this._receiveSettingNotify(n);break;case D.rtc_ntf:this._receiveRtcKv(n)}else G.error("unknown topic:",o)}},e.prototype._receiveStateNotify=function(n){var r,i=(r=this._channel)===null||r===void 0?void 0:r.codec.decodeByPBName(n.data,Qr),o=i.time,s=i.type,c=i.chrmId;switch(s){case 2:this._chrmEntryHandler.pullEntry(c,o);break;case 3:this._conversationManager.startPullConversationStatus(o);break;case 4:this._chrmEntryHandler.reset(c),this._watcher.chatroom({chatroomDestroyed:n.targetId})}},e.prototype._receiveSettingNotify=function(n){var r,i=((r=this._channel)===null||r===void 0?void 0:r.codec.decodeByPBName(n.data,Ai)).version;this._userSettingManager.pullUserSettings(i)},e.prototype._receiveRtcKv=function(n){var r,i=(r=this._channel)===null||r===void 0?void 0:r.codec.decodeByPBName(n.data,ea),o=i.time,s=i.type,c=i.roomId;switch(s){case 1:this._rtcKVManager.pullEntry(c,o)}},e.prototype._receiveMessageExpansion=function(n){var r=n.content,i=r.put,o=r.del,s=r.mid;i&&this._watcher.expansion({updatedExpansion:{messageUId:s,expansion:i}}),o&&this._watcher.expansion({deletedExpansion:{messageUId:s,deletedKeys:o}})},e.prototype._receiveSyncMsg=function(n,r){var i;if(Wh.includes(n.topic)){var o=(i=this._channel)===null||i===void 0?void 0:i.codec.decodeByPBName(n.data,Zn,{currentUserId:this.currentUserId,signal:n});o=this._handleMsgProperties(o),r&&(o.sentTime=r.timestamp,o.messageUId=r.messageUId),this._pullingMsg?this._pullQueue.push((r==null?void 0:r.timestamp)||o.sentTime):(r&&this._sendMessageStore.setMessage(r.messageUId,r.timestamp),o.messageType!==Ge.EXPANSION_NOTIFY?(o.messageType===Ge.SYNC_READ_STATUS&&this._conversationManager.clearUnreadCount(o.conversationType,o.targetId,o.channelId),this._conversationManager.setConversationCacheByMessage(o,!0),this._watcher.batchMessage([o])):this._receiveMessageExpansion(o))}},e.prototype._pullMsg=function(n){if(this._channel){var r=this._channel.codec.decodeByPBName(n.data,Qr),i=r.type,o=r.chrmId,s=r.time;if(G.info("s_ntf -> type: "+i+", chrmId: "+o+", time: "+s),i===2){var c=this._chrmsQueue[o];if(!c)return;c.queue.push(s),this._pullChrmMsg(o)}else this._pullQueue.push(s),this._syncMsg()}},e.prototype._startSyncInterval=function(){var n=this;this._stopSyncInterval(),this._intervalTimer=setInterval(function(){Date.now()-n._latestSyncTimestamp>=18e4&&n._syncMsg()},3e4),this._latestSyncTimestamp=Date.now(),this._syncMsg()},e.prototype._stopSyncInterval=function(){this._intervalTimer!==-1&&(clearInterval(this._intervalTimer),this._intervalTimer=-1)},e.prototype._syncMsg=function(){return x(this,void 0,void 0,function(){var n,r,i,o,s,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,n=this._letterbox.getOutboxTime(this.currentUserId),r=this._letterbox.getInboxTime(this.currentUserId),G.info("pullMsg -> sendboxTime: "+n+", inboxTime: "+r),i=this._channel.codec.encodeSyncMsg({sendboxTime:n,inboxTime:r}),o=new ie(D[D.pullMsg],i,this.currentUserId),[4,this._channel.send(o,er,{connectedTime:this._channel.connectedTime,currentUserId:this.currentUserId})]):(this._pullingMsg=!1,[2]);case 1:return s=v.sent(),c=s.code,d=s.data,this._latestSyncTimestamp=Date.now(),c===O.SUCCESS&&d?(l=d.list,h=d.finished,a=d.syncTime,G.info("pullMsg success -> syncTime: "+a+", finished: "+h),u=0,f=[],l.forEach(function(y){if(y.messageDirection===ct.SEND&&(u=Math.max(y.sentTime,u),_._sendMessageStore.getSendMessageMap()[y.messageUId]))return void _._sendMessageStore.removeByUID(y.messageUId);if(y.messageType!==Ge.EXPANSION_NOTIFY){if(y.messageType===Ge.SYNC_READ_STATUS){if(y.senderUserId!==_.currentUserId)return;_._conversationManager.clearUnreadCount(y.conversationType,y.targetId,y.channelId)}var C=_._handleMsgProperties(y);_._conversationManager.setConversationCacheByMessage(C,!0),f.push(C)}else _._receiveMessageExpansion(y)}),this._watcher.batchMessage(f),this._letterbox.setInboxTime(a,this.currentUserId),this._letterbox.setOutboxTime(u,this.currentUserId),this._sendMessageStore.removeByTimestamp(u),this._pullingMsg=!1,p=this._pullQueue.filter(function(y){return y>a}),this._pullQueue.length=0,(m=this._pullQueue).push.apply(m,p),h&&!this._pullOfflineFinished&&(this._pullOfflineFinished=!0,this._watcher.pullFinished()),(!h||p.length>0)&&this._syncMsg(),[2]):(G.warn("pullMsg failed -> code:",c,", data: ",d),this._pullingMsg=!1,[2])}})})},e.prototype._receiveMsg=function(n){if(this._channel&&!this._pullingMsg)if(this._pullQueue.length>0)this._syncMsg();else{var r=this._channel.codec.decodeByPBName(n.data,Ii,{currentUserId:this.currentUserId,connectedTime:this._channel.connectedTime});(r=this._handleMsgProperties(r)).senderUserId===this.currentUserId&&this._sendMessageStore.setMessage(r.messageUId,r.sentTime),r.isStatusMessage||r.senderUserId===this.currentUserId||this._letterbox.setInboxTime(r.sentTime,this.currentUserId),r.messageType!==Ge.EXPANSION_NOTIFY?r.messageType===Ge.SYNC_READ_STATUS&&r.senderUserId!==this.currentUserId||(this._conversationManager.setConversationCacheByMessage(r,!0),this._watcher.batchMessage([r])):this._receiveMessageExpansion(r)}},e.prototype._handleMsgProperties=function(n,r){r===void 0&&(r=!1);var i,o=n.messageType,s=n.isCounted,c=n.isPersited,d=n.isStatusMessage,l=o in Pa,h=o in this._customMessageType;if(i=l?Pa[o]:h?this._customMessageType[o]:{isCounted:!Ua(s)&&s,isPersited:!Ua(c)&&c},Object.assign(n,{isCounted:i.isCounted,isPersited:i.isPersited,isStatusMessage:Jl.includes(o)}),r&&(n.isStatusMessage=d),!r){var a=n.content.user;if(a){var u=a.portrait,f=a.portraitUri,p=u||f;p&&(a.portrait=a.portraitUri=p)}}return n},e.prototype.getHistoryMessage=function(n,r,i,o,s,c){return c===void 0&&(c=""),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=Nh[n]||Au,u=o===1&&i===0,h?(f=h.codec.encodeGetHistoryMsg(r,{timestamp:i,count:u?2:o,order:s,channelId:c}),[4,h.send(new ie(a,f,l),tr,{currentUserId:l,connectedTime:h.connectedTime,conversation:{targetId:r}})]):[3,2];case 1:return p=v.sent(),(m=p.code)!==O.SUCCESS?[2,{code:m}]:(_=p.data,u&&_.list.length===2&&(_.hasMore=!0,s===0?_.list.shift():_.list.pop()),[2,{code:m,data:{list:_.list,hasMore:_.hasMore}}]);case 2:return[2,{code:O.RC_NET_CHANNEL_INVALID}]}})})},e.prototype.reportSDKInfo=function(n){var r=this.currentUserId,i=this._channel;if(i){G.debug("reportSDKInfo ->",n);var o=i.codec.encodeReportSDKInfo(JSON.stringify(n)),s=new ie(D[D.reportsdk],o,r);i.send(s).then(function(c){var d=c.code;d!==O.SUCCESS&&G.warn("reportSDKInfo failed -> code: "+d)})}},e.prototype.deleteRemoteMessage=function(n,r,i,o){return x(this,void 0,void 0,function(){var s,c,d,l,h,a,u;return B(this,function(f){switch(f.label){case 0:return c=(s=this).currentUserId,(d=s._channel)?(l=d.codec.encodeDeleteMessages(n,r,i,o),h=new ie(gh,l,c),[4,d.send(h)]):[3,2];case 1:return a=f.sent(),u=a.code,O.SUCCESS,[2,u];case 2:return[2,O.RC_NET_CHANNEL_INVALID]}})})},e.prototype.deleteRemoteMessageByTimestamp=function(n,r,i,o){return x(this,void 0,void 0,function(){var s,c,d,l,h,a,u,f;return B(this,function(p){switch(p.label){case 0:return c=(s=this).currentUserId,(d=s._channel)?(l=d.codec.encodeClearMessages(r,i,o),h=Ah[n],a=new ie(h,l,c),[4,d.send(a)]):[3,2];case 1:return u=p.sent(),f=u.code,O.SUCCESS,[2,f];case 2:return[2,O.RC_NET_CHANNEL_INVALID]}})})},e.prototype.getConversationList=function(n,r,i,o,s){return n===void 0&&(n=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||re.PRIVATE,l?(h=l.codec.encodeOldConversationList({count:n,type:r,startTime:i,order:o}),a=new ie(Ja,h,d),[4,l.send(a,nr,{currentUserId:d,connectedTime:l.connectedTime,afterDecode:function(v){var y=v.conversationType,C=v.targetId,b=v.channelId,N=m._conversationManager.get(y,C,b);return Object.assign(v,N),v}})]):[3,2];case 1:return u=_.sent(),f=u.code,p=u.data,f!==O.SUCCESS?[2,{code:f}]:[2,{code:f,data:p}];case 2:return[2,{code:O.RC_NET_CHANNEL_INVALID}]}})})},e.prototype.removeConversation=function(n,r,i){return x(this,void 0,void 0,function(){var o,s,c,d,l;return B(this,function(h){switch(h.label){case 0:return(o=this._channel)?(s=o.codec.encodeRemoveOldConversationList({conversationType:n,channelId:i,targetId:r}),c=new ie(Th,s,r),[4,o.send(c)]):[3,2];case 1:return d=h.sent(),G.info("RemoveConversation =>",d),l=d.code,O.SUCCESS,[2,l];case 2:return[2,O.RC_NET_CHANNEL_INVALID]}})})},e.prototype.getConversation=function(n,r,i){return x(this,void 0,void 0,function(){var o,s,c,d,l,h;return B(this,function(a){switch(a.label){case 0:return(o=this._conversationManager.get(n,r,i))?[4,this.getHistoryMessage(n,r,0,1,0)]:[2,{code:O.CONVER_GET_ERROR}];case 1:return s=a.sent(),c=s.code,d=s.data,c!==O.SUCCESS?[2,{code:O.CONVER_GET_ERROR}]:(l=(d==null?void 0:d.list[0])||null,h={conversationType:n,targetId:r,channelId:i,unreadMessageCount:o.unreadMessageCount||0,latestMessage:l,notificationStatus:o.notificationStatus||on.CLOSE,isTop:o.isTop||!1,lastUnreadTime:o.lastUnreadTime||0,unreadMentionedCount:o.unreadMentionedCount||0},[2,{code:O.SUCCESS,data:h}])}})})},e.prototype.getAllConversationUnreadCount=function(n,r,i){var o=this._conversationManager.getAllUnreadCount(n,r,i);return Promise.resolve({code:O.SUCCESS,data:o})},e.prototype.getConversationUnreadCount=function(n,r,i){var o=this._conversationManager.getUnreadCount(n,r,i);return Promise.resolve({code:O.SUCCESS,data:o})},e.prototype.clearConversationUnreadCount=function(n,r,i){return this._conversationManager.clearUnreadCount(n,r,i,!1),Promise.resolve(O.SUCCESS)},e.prototype.clearAllUnreadCount=function(){return this._conversationManager.clearAllUnreadCount(),Promise.resolve(O.SUCCESS)},e.prototype.getFirstUnreadMessage=function(n,r){throw new Error("Method not implemented.")},e.prototype.saveConversationMessageDraft=function(n,r,i,o){return this._conversationManager.setDraft(n,r,i,o),Promise.resolve(O.SUCCESS)},e.prototype.getConversationMessageDraft=function(n,r,i){var o=this._conversationManager.getDraft(n,r,i);return Promise.resolve({code:O.SUCCESS,data:o})},e.prototype.clearConversationMessageDraft=function(n,r,i){return this._conversationManager.clearDraft(n,r,i),Promise.resolve(O.SUCCESS)},e.prototype.pullConversationStatus=function(n){return x(this,void 0,void 0,function(){var r,i,o,s,c,d,l,h;return B(this,function(a){switch(a.label){case 0:return i=(r=this)._channel,o=r.currentUserId,i?(s=i.codec.encodeGetConversationStatus(n),c=new ie(D[D.pullSeAtts],s,o),[4,i.send(c,Mi)]):[3,2];case 1:return d=a.sent(),l=d.code,h=d.data,l!==O.SUCCESS?[2,{code:l}]:[2,{code:l,data:h}];case 2:return[2,{code:O.RC_NET_CHANNEL_INVALID}]}})})},e.prototype.batchSetConversationStatus=function(n){return x(this,void 0,void 0,function(){var r,i,o,s,c,d,l,h,a,u=this;return B(this,function(f){switch(f.label){case 0:return i=(r=this).currentUserId,(o=r._channel)?(s=o.codec.encodeSetConversationStatus(n),c=new ie(Sh,s,i),[4,o.send(c,Ws)]):[3,2];case 1:return d=f.sent(),l=d.code,h=d.data,l===O.SUCCESS?(a=h,n.forEach(function(p){u._conversationManager.addStatus(Ee(Ee({},p),{updatedTime:a.version}),!0)}),[2,l]):[2,l];case 2:return[2,O.RC_NET_CHANNEL_INVALID]}})})},e.prototype._joinChrm=function(n,r,i){return x(this,void 0,void 0,function(){var o,s,c,d,l,h,a;return B(this,function(u){switch(u.label){case 0:return(o=this._channel)?(s=o.codec.encodeJoinOrQuitChatRoom(),c=new ie(i?_h:mh,s,n),[4,o.send(c,Os)]):[2,O.RC_NET_CHANNEL_INVALID];case 1:return d=u.sent(),l=d.code,h=d.data,l===O.SUCCESS&&(a=h.joinTime,this._chrmsQueue[n]||(this._chrmsQueue[n]={pulling:!1,queue:[],timestamp:0}),this._pullChrmMsg(n,r,a),this._naviInfo.kvStorage&&this._chrmEntryHandler.pullEntry(n,0),this._joinedChrmManager.set(n,r)),[2,l]}})})},e.prototype._rejoinChrm=function(){return x(this,void 0,void 0,function(){var n,r,i,o,s,c;return B(this,function(d){switch(d.label){case 0:for(i in n=this._joinedChrmManager.get(),r=[],n)r.push(i);o=0,d.label=1;case 1:return o<r.length?(s=r[o],[4,this._joinChrm(s,n[s]||10,!0)]):[3,4];case 2:(c=d.sent())===O.SUCCESS?this._watcher.chatroom({rejoinedRoom:{chatroomId:s,count:n[s]}}):this._watcher.chatroom({rejoinedRoom:{chatroomId:s,errorCode:c}}),d.label=3;case 3:return o++,[3,1];case 4:return[2]}})})},e.prototype._pullChrmMsg=function(n,r,i){return r===void 0&&(r=10),i===void 0&&(i=0),x(this,void 0,void 0,function(){var o,s,c,d,l,h,a,u,f,p,m,_;return B(this,function(v){switch(v.label){case 0:return this._channel?(o=this._chrmsQueue[n],s=o.pulling,c=o.timestamp,s?[2]:(o.pulling=!0,d=this._channel.codec.encodeChrmSyncMsg(c,r),l=new ie(D[D.chrmPull],d,n),[4,this._channel.send(l,er,{connectedTime:this._channel.connectedTime,currentUserId:this.currentUserId})])):[2];case 1:return h=v.sent(),a=h.code,u=h.data,o.pulling=!1,a===O.SUCCESS&&u?(f=u.list,p=u.syncTime,m=u.finished,o.timestamp=i?Math.max(p,i):p,o.queue=o.queue.filter(function(y){return y>p}),_=[],f.forEach(function(y){y.sentTime<c||_.push(y)}),this._watcher.batchMessage(_),(!m||o.queue.length>0)&&this._pullChrmMsg(n),[2]):(G.warn("pull chatroom msg failed, code:",a,", data:",u),[2])}})})},e.prototype.joinChatroom=function(n,r){return x(this,void 0,void 0,function(){return B(this,function(i){return[2,this._joinChrm(n,r,!1)]})})},e.prototype.joinExistChatroom=function(n,r){return x(this,void 0,void 0,function(){return B(this,function(i){return[2,this._joinChrm(n,r,!0)]})})},e.prototype.quitChatroom=function(n){return x(this,void 0,void 0,function(){var r,i,o,s,c;return B(this,function(d){switch(d.label){case 0:return(r=this._channel)?(i=r.codec.encodeJoinOrQuitChatRoom(),o=new ie(vh,i,n),[4,r.send(o)]):[2,O.RC_NET_CHANNEL_INVALID];case 1:return s=d.sent(),(c=s.code)===O.SUCCESS&&(delete this._chrmsQueue[n],this._chrmEntryHandler.reset(n),this._joinedChrmManager.remove(n)),[2,c]}})})},e.prototype.getChatroomInfo=function(n,r,i){return x(this,void 0,void 0,function(){var o,s,c,d,l,h;return B(this,function(a){switch(a.label){case 0:return(o=this._channel)?(s=o.codec.encodeGetChatRoomInfo(r,i),c=new ie(D[D.queryChrmI],s,n),[4,o.send(c,bi)]):[2,{code:O.RC_NET_CHANNEL_INVALID}];case 1:return d=a.sent(),l=d.code,h=d.data,l!==O.SUCCESS?[2,{code:l}]:[2,{code:l,data:h}]}})})},e.prototype.getChatroomHistoryMessages=function(n,r,i,o){return x(this,void 0,void 0,function(){var s,c,d,l,h,a;return B(this,function(u){switch(u.label){case 0:return(s=this._channel)?(c=s.codec.encodeGetHistoryMsg(n,{timestamp:r,count:i,order:o}),d=new ie(Mu,c,n),[4,s.send(d,tr,{conversation:{targetId:n}})]):[2,{code:O.RC_NET_CHANNEL_INVALID}];case 1:return l=u.sent(),h=l.code,a=l.data,h!==O.SUCCESS?[2,{code:h}]:[2,{code:h,data:{list:a.list,hasMore:a.hasMore}}]}})})},e.prototype._modifyChatroomKV=function(n,r){return x(this,void 0,void 0,function(){var i,o,s,c,d,l,h,a;return B(this,function(u){switch(u.label){case 0:return o=(i=this)._channel,s=i.currentUserId,o?(c=o.codec.encodeModifyChatRoomKV(n,r,s),d=r.type===Ze.UPDATE?yh:Ch,l=new ie(d,c,n),[4,o.send(l)]):[2,O.RC_NET_CHANNEL_INVALID];case 1:return h=u.sent(),(a=h.code)===O.SUCCESS?(this._chrmEntryHandler.setLocal(n,{kvEntries:[r],syncTime:new Date().getTime()},s),[2,a]):[2,a]}})})},e.prototype._modifyChatroomKVS=function(n,r){return x(this,void 0,void 0,function(){var i,o,s,c,d,l,h,a,u,f,p,m;return B(this,function(_){switch(_.label){case 0:return o=(i=this)._channel,s=i.currentUserId,o?(c=o.codec.encodeModifyChatRoomKVS(n,r,s),d=r.type===Ze.UPDATE?Eh:Rh,l=new ie(d,c,n),[4,o.send(l,qs)]):[2,{code:O.RC_NET_CHANNEL_INVALID}];case 1:return h=_.sent(),a=h.code,[O.SUCCESS,O.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===O.CHATROOM_KV_STORE_NOT_ALL_SUCCESS&&(m=h.data,G.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)})),G.warn("\u8BBE\u7F6E\u6210\u529F\u7684\u5C5E\u6027\uFF1A",f),this._chrmEntryHandler.setLocal(n,{kvEntries:f,syncTime:new Date().getTime()},s)),[2,{code:a,data:u}]}})})},e.prototype.setChatroomEntry=function(n,r){return x(this,void 0,void 0,function(){return B(this,function(i){return r.type=Ze.UPDATE,r.userId=r.userId||this.currentUserId,[2,this._modifyChatroomKV(n,r)]})})},e.prototype.setChatroomEntries=function(n,r){return x(this,void 0,void 0,function(){return B(this,function(i){return r.type=Ze.UPDATE,r.userId=r.userId||this.currentUserId,[2,this._modifyChatroomKVS(n,r)]})})},e.prototype.forceSetChatroomEntry=function(n,r){return x(this,void 0,void 0,function(){return B(this,function(i){return r.type=Ze.UPDATE,r.isOverwrite=!0,r.userId=r.userId||this.currentUserId,[2,this._modifyChatroomKV(n,r)]})})},e.prototype.removeChatroomEntry=function(n,r){return x(this,void 0,void 0,function(){return B(this,function(i){return r.type=Ze.DELETE,r.userId=r.userId||this.currentUserId,[2,this._modifyChatroomKV(n,r)]})})},e.prototype.removeChatroomEntries=function(n,r){return x(this,void 0,void 0,function(){return B(this,function(i){return r.type=Ze.DELETE,r.userId=r.userId||this.currentUserId,[2,this._modifyChatroomKVS(n,r)]})})},e.prototype.forceRemoveChatroomEntry=function(n,r){return x(this,void 0,void 0,function(){return B(this,function(i){return r.type=Ze.DELETE,r.isOverwrite=!0,r.userId=r.userId||this.currentUserId,[2,this._modifyChatroomKV(n,r)]})})},e.prototype.getChatroomEntry=function(n,r){return x(this,void 0,void 0,function(){var i,o,s,c,d,l,h;return B(this,function(a){switch(a.label){case 0:return(i=this._chrmEntryHandler.getValue(n,r))?[2,Promise.resolve({code:O.SUCCESS,data:i})]:[3,1];case 1:return(o=this._channel)?(s=o.codec.encodePullChatRoomKV(0),c=new ie(D[D.pullKV],s,n),[4,o.send(c,un)]):[2,Promise.reject({code:O.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:O.SUCCESS,data:h==null?void 0:h.value})]:[2,Promise.resolve({code:O.CHATROOM_KEY_NOT_EXIST})]}})})},e.prototype.getAllChatroomEntry=function(n){return x(this,void 0,void 0,function(){var r,i,o,s,c,d,l;return B(this,function(h){switch(h.label){case 0:return(r=this._chrmEntryHandler.getAll(n))&&Object.keys(r).length?[2,Promise.resolve({code:O.SUCCESS,data:r})]:[3,1];case 1:return(i=this._channel)?(o={},s=i.codec.encodePullChatRoomKV(0),c=new ie(D[D.pullKV],s,n),[4,i.send(c,un)]):[2,Promise.reject({code:O.RC_NET_CHANNEL_INVALID})];case 2:return d=h.sent(),(l=d.data||{})&&l.kvEntries&&l.kvEntries.length&&l.kvEntries.forEach(function(a){a.key&&(o[a.key]=a.value||"")}),[2,Promise.resolve({code:O.SUCCESS,data:o})]}})})},e.prototype.pullChatroomEntry=function(n,r){return x(this,void 0,void 0,function(){var i,o,s,c,d,l,h,a,u,f;return B(this,function(p){switch(p.label){case 0:return o=(i=this)._channel,s=i.currentUserId,o?(c=o.codec.encodePullChatRoomKV(r),d=new ie(D[D.pullKV],c,n),[4,o.send(d,un)]):[2,{code:O.RC_NET_CHANNEL_INVALID}];case 1:return l=p.sent(),h=l.code,a=l.data,h===O.SUCCESS?(G.info("Pull success ChrmKV, "+JSON.stringify(l)),this._chrmEntryHandler.setLocal(n,a,s),G.info("Save into cache success!"),u=a.kvEntries,f=[],u.length>0&&(u.forEach(function(m){var _=m.key,v=m.value,y=m.type,C=m.timestamp;f.push({key:_,value:v,type:y,timestamp:C,chatroomId:n})}),this._watcher.chatroom({updatedEntries:f})),[2,{code:h,data:a}]):[2,{code:h}]}})})},e.prototype.sendMessage=function(n,r,i){return x(this,void 0,void 0,function(){var o,s,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),o=!![re.PRIVATE,re.GROUP].includes(n)&&i.isStatusMessage,s=o?function(_){var v;return(v={},v[re.PRIVATE]=D.ppMsgS,v[re.GROUP]=D.pgMsgS,v)[_]}(n):function(_){var v;return(v={},v[re.PRIVATE]=D.ppMsgP,v[re.GROUP]=D.pgMsgP,v[re.CHATROOM]=D.chatMsg,v[re.CUSTOMER_SERVICE]=D.pcMsgP,v[re.RTC_ROOM]=D.prMsgS,v)[_]}(n)||D.ppMsgP,o&&(i.isPersited=!1,i.isCounted=!1),c=this._channel.codec.encodeUpMsg({conversationType:n,targetId:r},i),(d=new kn(D[s],c,r)).setHeaderQos(wt.AT_LEAST_ONCE),o?(this._channel.sendOnly(d),[2,{code:O.SUCCESS,data:ro(n,r,Ee({},i),"",0,this.currentUserId)}]):(l=Date.now()-this._localConnectedTime+this._connectedTime,h=ro(n,r,Ee({},i),"",l,this.currentUserId),[4,this._channel.send(d)])):[2,{code:O.RC_NET_CHANNEL_INVALID}];case 1:return a=m.sent(),u=a.code,f=a.data,u!==O.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:O.SUCCESS,data:h}])}})})},e.prototype.recallMsg=function(n,r,i,o,s){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=s.user,l={content:{conversationType:n,targetId:r,messageUId:i,sentTime:o,user:d},messageType:"RC:RcCmd",disableNotification:s==null?void 0:s.disableNotification,pushConfig:s==null?void 0:s.pushConfig,pushContent:((c=s.pushConfig)===null||c===void 0?void 0:c.pushContent)||s.pushContent||"",channelId:s.channelId},h=D[D.recallMsg],a=this._channel.codec.encodeUpMsg({conversationType:n,targetId:r},l),(u=new kn(h,a,this.currentUserId)).setHeaderQos(wt.AT_LEAST_ONCE),[4,this._channel.send(u)]):[2,{code:O.RC_NET_CHANNEL_INVALID}];case 1:return f=y.sent(),p=f.code,m=f.data,p!==O.SUCCESS?[2,{code:p}]:(_=m,this._sendMessageStore.setMessage(_.messageUId,_.timestamp),v=ro(n,r,Ee(Ee({},l),{isPersited:!0}),_.messageUId,_.timestamp,this.currentUserId),this._conversationManager.setConversationCacheByMessage(v,!0),[2,{code:O.SUCCESS,data:v}])}})})},e.prototype.sendReadReceiptMessage=function(n,r,i){return x(this,void 0,void 0,function(){var o,s;return B(this,function(c){switch(c.label){case 0:return this._channel?(o=this._channel.codec.encodeReadReceipt(r,i),s=new ie(D[D.rrMsg],o,n),[4,this._channel.send(s)]):[2,{code:O.RC_NET_CHANNEL_INVALID}];case 1:return[2,c.sent()]}})})},e.prototype.getMessageReader=function(n,r,i){return x(this,void 0,void 0,function(){var o,s;return B(this,function(c){switch(c.label){case 0:return this._channel?(o=this._channel.codec.encodeMessageReader(r,i),s=new ie(D[D.rrList],o,n),[4,this._channel.send(s,Pi)]):[2,{code:O.RC_NET_CHANNEL_INVALID}];case 1:return[2,c.sent()]}})})},e.prototype.pullUserSettings=function(n){return x(this,void 0,void 0,function(){var r,i;return B(this,function(o){return this._channel?(r=this._channel.codec.encodePullUserSetting(n),i=new ie(D[D.pullUS],r,this.currentUserId),[2,this._channel.send(i,Ni)]):[2,{code:O.RC_NET_CHANNEL_INVALID}]})})},e.prototype.getFileToken=function(n,r,i,o){return x(this,void 0,void 0,function(){var s,c,d,l,h,a;return B(this,function(u){switch(u.label){case 0:return this._channel?(s=o&&o!=="uploads"?r||"":th(n,r),c=this._channel.codec.encodeGetFileToken(n,s,i||"",o||""),d=new ie(D[D.qnTkn],c,this.currentUserId),[4,this._channel.send(d,Bs)]):[2,{code:O.RC_NET_CHANNEL_INVALID}];case 1:return l=u.sent(),h=l.code,a=l.data,a=Object.assign(a,{fileName:s}),h===O.SUCCESS?[2,{code:h,data:a}]:[2,{code:h}]}})})},e.prototype.getFileUrl=function(n,r,i,o){return x(this,void 0,void 0,function(){var s,c,d,l,h,a,u,f,p;return B(this,function(m){switch(m.label){case 0:return this._channel?(s="",c="",d="",r===ze.QINIU?(c=Vs,d=Hs):(c=Fs,d=js),s=r===ze.QINIU?D[D.qnUrl]:r===ze.AWS?D[D.s3Url]:r===ze.STC?D[D.stcUrl]:D[D.aliUrl],l=this._channel.codec.encodeGetFileUrl(c,n,i,o),h=new ie(s,l,this.currentUserId),[4,this._channel.send(h,d)]):[2,{code:O.RC_NET_CHANNEL_INVALID}];case 1:return a=m.sent(),u=a.code,f=a.data,p=f,u===O.SUCCESS?[2,{code:u,data:p}]:[2,{code:u}]}})})},e.prototype.disconnect=function(){this._reconnectTimer!==-1&&(clearTimeout(this._reconnectTimer),this._reconnectTimer=-1),this._channel&&(this._channel.close(),this._channel=void 0),this._pullQueue.length=0,this._stopSyncInterval()},e.prototype.destroy=function(){throw new Error("JSEngine's method not implemented.")},e.prototype.registerMessageType=function(n,r,i,o){this._customMessageType[n]={isPersited:r,isCounted:i}},e.prototype.getServerTime=function(){return Date.now()-this._localConnectedTime+this._connectedTime},e.prototype.getCurrentUserId=function(){return this.currentUserId},e.prototype.createTag=function(n){return x(this,void 0,void 0,function(){var r,i,o,s,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([n],r),o=new ie(D[D.addSeTag],i,this.currentUserId),[4,this._channel.send(o,dn)]):[2,{code:O.RC_NET_CHANNEL_INVALID}];case 1:return s=h.sent(),c=s.code,d=s.data,c!==O.SUCCESS?[2,{code:c}]:(l=d.version,this._userSettingManager.addTag([Ee(Ee({},n),{createdTime:l})],l),[2,{code:O.SUCCESS,data:d}])}})})},e.prototype.removeTag=function(n){return x(this,void 0,void 0,function(){var r,i,o,s,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([n],r),o=new ie(D[D.delSeTag],i,this.currentUserId),[4,this._channel.send(o,dn)]):[2,{code:O.RC_NET_CHANNEL_INVALID}];case 1:return s=h.sent(),c=s.code,d=s.data,c!==O.SUCCESS?[2,{code:c}]:(l=d.version,this._userSettingManager.deleteTag([n],l),[2,{code:O.SUCCESS}])}})})},e.prototype.updateTag=function(n){return x(this,void 0,void 0,function(){var r,i,o,s,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([n],r),o=new ie(D[D.addSeTag],i,this.currentUserId),[4,this._channel.send(o,dn)]):[2,{code:O.RC_NET_CHANNEL_INVALID}];case 1:return s=h.sent(),c=s.code,d=s.data,c!==O.SUCCESS?[2,{code:c}]:(l=d.version,this._userSettingManager.addTag([n],l),[2,{code:O.SUCCESS,data:d}])}})})},e.prototype.getTagList=function(){return x(this,void 0,void 0,function(){var n,r;return B(this,function(i){return n=this._userSettingManager.getTags(),r=this._conversationManager.getConversationListForTag(),n.forEach(function(o){o.conversationCount=r[o.tagId]?r[o.tagId].length:0}),[2,{code:O.SUCCESS,data:n}]})})},e.prototype.addTagForConversations=function(n,r){return x(this,void 0,void 0,function(){var i,o,s,c,d=this;return B(this,function(l){switch(l.label){case 0:return this._channel?this._userSettingManager.getTagById(n)?(i=this._channel.codec.encodeUpdateConversationTag([{tagId:n}],r),o=new ie(D[D.addTag],i,this.currentUserId),[4,this._channel.send(o)]):[2,{code:O.TAG_NOT_EXIST}]:[2,{code:O.RC_NET_CHANNEL_INVALID}];case 1:return(s=l.sent().code)!==O.SUCCESS?[2,{code:s}]:((c={})[n]={},r.forEach(function(h){d._conversationManager.addTagStatus(h.conversationType,h.targetId,c,h.channelId)}),[2,{code:O.SUCCESS}])}})})},e.prototype.removeTagForConversations=function(n,r){return x(this,void 0,void 0,function(){var i,o,s,c=this;return B(this,function(d){switch(d.label){case 0:return this._channel?(i=this._channel.codec.encodeUpdateConversationTag([{tagId:n}],r),o=new ie(D[D.delTag],i,this.currentUserId),[4,this._channel.send(o)]):[2,{code:O.RC_NET_CHANNEL_INVALID}];case 1:return(s=d.sent().code)!==O.SUCCESS?[2,{code:s}]:(r.forEach(function(l){c._conversationManager.deleteTagStatus(l.conversationType,l.targetId,[n],l.channelId)}),[2,{code:O.SUCCESS}])}})})},e.prototype.removeTagsForConversation=function(n,r){return x(this,void 0,void 0,function(){var i,o,s,c,d,l,h;return B(this,function(a){switch(a.label){case 0:return this._channel?(i=n.conversationType,o=n.targetId,s=n.channelId,c=r.map(function(u){return{tagId:u}}),d=this._channel.codec.encodeUpdateConversationTag(c,[n]),l=new ie(D[D.delTag],d,this.currentUserId),[4,this._channel.send(l)]):[2,{code:O.RC_NET_CHANNEL_INVALID}];case 1:return(h=a.sent().code)!==O.SUCCESS?[2,{code:h}]:(this._conversationManager.deleteTagStatus(i,o,r,s),[2,{code:O.SUCCESS}])}})})},e.prototype.getConversationListByTag=function(n,r,i){return x(this,void 0,void 0,function(){var o,s,c,d,l,h,a,u,f;return B(this,function(p){switch(p.label){case 0:return s=(o=this).currentUserId,(c=o._channel)?(d=c.codec.encodeOldConversationList({count:i,type:re.PRIVATE,startTime:r}),l=new ie(Ja,d,s),[4,c.send(l,nr,{currentUserId:s,connectedTime:c.connectedTime})]):[2,{code:O.RC_NET_CHANNEL_INVALID}];case 1:return h=p.sent(),a=h.code,u=h.data,f=this._conversationHasTagFilter(n,u),G.info("GetConversationListByTag",f),a!==O.SUCCESS?[2,{code:a}]:[2,{code:a,data:f}]}})})},e.prototype._conversationHasTagFilter=function(n,r){var i=this,o=[],s=[];function c(d,l){return d.latestMessage&&l.latestMessage?d.latestMessage.sentTime-l.latestMessage.sentTime:0}return r.forEach(function(d){var l=d.conversationType,h=d.targetId,a=d.channelId,u=i._conversationManager.get(l,h,a),f=u.hasMentioned,p=u.mentionedInfo,m=u.lastUnreadTime,_=u.notificationStatus,v=u.isTop,y=u.tags,C=u.unreadMessageCount,b=y&&y[n];if(b){var N=Ee(Ee({},d),{hasMentioned:f,mentionedInfo:p,lastUnreadTime:m,notificationStatus:_,isTop:v,unreadMessageCount:C});b.isTop?o.push(Ee(Ee({},N),{isTopInTag:!0})):s.push(Ee(Ee({},N),{isTopInTag:!1}))}}),Wt(Wt([],o.sort(c)),s.sort(c))},e.prototype.getUnreadCountByTag=function(n,r){return x(this,void 0,void 0,function(){var i;return B(this,function(o){return this._channel?(i=this._conversationManager.getUnreadCountByTag(n,r),[2,{code:O.SUCCESS,data:i}]):[2,{code:O.RC_NET_CHANNEL_INVALID}]})})},e.prototype.setConversationStatusInTag=function(n,r,i){return x(this,void 0,void 0,function(){var o,s,c,d,l,h,a,u,f,p;return B(this,function(m){switch(m.label){case 0:return this._channel?(o=r.targetId,s=r.conversationType,c=r.channelId,d=i.isTop,l=[{tagId:n,isTop:d}],(h=this._conversationManager.get(s,o,c)).tags&&Object.hasOwnProperty.call(h.tags,n)?(a=this._channel.codec.encodeUpdateConversationTag(l,[r]),u=new ie(D[D.addTag],a,this.currentUserId),[4,this._channel.send(u)]):[2,{code:O.NO_TAG_IN_CONVER}]):[2,{code:O.RC_NET_CHANNEL_INVALID}];case 1:return(f=m.sent().code)!==O.SUCCESS?[2,{code:f}]:((p={})[n]={},d&&(p[n].isTop=!0),this._conversationManager.addTagStatus(s,o,p,c),[2,{code:O.SUCCESS}])}})})},e.prototype.getTagsForConversation=function(n){var r;return x(this,void 0,void 0,function(){var i,o,s,c;return B(this,function(d){if(!this._channel)return[2,{code:O.RC_NET_CHANNEL_INVALID}];if(i=this._conversationManager.get(n.conversationType,n.targetId,n.channelId),o=this._userSettingManager.getTagsInfo(),s=[],i.tags)for(c in i.tags)s.push({tagId:c,tagName:(r=o[c])===null||r===void 0?void 0:r.tagName});return[2,{code:O.SUCCESS,data:s}]})})},e.prototype.getBlockConversationList=function(){var n=this._conversationManager.getBlockConversationList();return Promise.resolve({code:O.SUCCESS,data:n})},e.prototype.getTopConversationList=function(){var n=this._conversationManager.getTopConversationList();return Promise.resolve({code:O.SUCCESS,data:n})},e.prototype.getUnreadMentionedCount=function(n){var r=this._conversationManager.getUnreadMentionedCount(n.channelId,n.conversationType,n.targetId);return Promise.resolve({code:O.SUCCESS,data:r})},e.prototype.getAllUnreadMentionedCount=function(){var n=this._conversationManager.getAllUnreadMentionedCount();return Promise.resolve({code:O.SUCCESS,data:n})},e.prototype.joinRTCRoom=function(n,r,i,o){return x(this,void 0,void 0,function(){var s,c;return B(this,function(d){return this._channel?(s=this._channel.codec.encodeJoinRTCRoom(r,i,o),c=new ie(D[D.rtcRJoin_data],s,n),[2,this._channel.send(c,Yt)]):[2,{code:O.RC_NET_CHANNEL_INVALID}]})})},e.prototype.quitRTCRoom=function(n){return x(this,void 0,void 0,function(){var r,i;return B(this,function(o){switch(o.label){case 0:return this._channel?(r=this._channel.codec.encodeQuitRTCRoom(),i=new ie(D[D.rtcRExit],r,n),[4,this._channel.send(i)]):[2,O.RC_NET_CHANNEL_INVALID];case 1:return[2,o.sent().code]}})})},e.prototype.rtcPing=function(n,r,i){return x(this,void 0,void 0,function(){var o,s;return B(this,function(c){switch(c.label){case 0:return this._channel?(o=this._channel.codec.encodeJoinRTCRoom(r,i),s=new ie(D[D.rtcPing],o,n),[4,this._channel.send(s)]):[2,O.RC_NET_CHANNEL_INVALID];case 1:return[2,c.sent().code]}})})},e.prototype.getRTCRoomInfo=function(n){return x(this,void 0,void 0,function(){var r,i;return B(this,function(o){return this._channel?(r=this._channel.codec.encodeGetRTCRoomInfo(),i=new ie(D[D.rtcRInfo],r,n),[2,this._channel.send(i,Eu)]):[2,{code:O.RC_NET_CHANNEL_INVALID}]})})},e.prototype.getRTCUserInfoList=function(n){return x(this,void 0,void 0,function(){var r,i,o,s,c;return B(this,function(d){switch(d.label){case 0:return this._channel?(r=this._channel.codec.encodeGetRTCRoomInfo(),i=new ie(D[D.rtcUData],r,n),[4,this._channel.send(i,Yt)]):[2,{code:O.RC_NET_CHANNEL_INVALID}];case 1:return o=d.sent(),s=o.code,c=o.data,[2,{code:s,data:c&&{users:c.users}}]}})})},e.prototype.setRTCUserInfo=function(n,r,i){return x(this,void 0,void 0,function(){var o,s;return B(this,function(c){switch(c.label){case 0:return this._channel?(o=this._channel.codec.encodeSetRTCUserInfo(r,i),s=new ie(D[D.rtcUPut],o,n),[4,this._channel.send(s)]):[2,O.RC_NET_CHANNEL_INVALID];case 1:return[2,c.sent().code]}})})},e.prototype.removeRTCUserInfo=function(n,r){return x(this,void 0,void 0,function(){var i,o;return B(this,function(s){switch(s.label){case 0:return this._channel?(i=this._channel.codec.encodeRemoveRTCUserInfo(r),o=new kn(D[D.rtcUDel],i,n),[4,this._channel.send(o)]):[2,O.RC_NET_CHANNEL_INVALID];case 1:return[2,s.sent().code]}})})},e.prototype.setRTCData=function(n,r,i,o,s,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,o,s,c),l=new kn(D[D.rtcSetData],d,n),[4,this._channel.send(l)]):[2,O.RC_NET_CHANNEL_INVALID];case 1:return[2,h.sent().code]}})})},e.prototype.setRTCTotalRes=function(n,r,i,o,s){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,o,s),d=new ie(D[D.userSetData],c,n),[4,this._channel.send(d)]):[2,O.RC_NET_CHANNEL_INVALID];case 1:return[2,l.sent().code]}})})},e.prototype.setRTCCDNUris=function(n,r,i){return x(this,void 0,void 0,function(){var o,s;return B(this,function(c){switch(c.label){case 0:return this._channel?(o=this._channel.codec.encodeUserSetRTCCDNUris(r,i),s=new ie(D[D.userSetData],o,n),[4,this._channel.send(s)]):[2,O.RC_NET_CHANNEL_INVALID];case 1:return[2,c.sent().code]}})})},e.prototype.getRTCData=function(n,r,i,o){if(!this._channel)return Promise.resolve({code:O.RC_NET_CHANNEL_INVALID});var s=this._channel.codec.encodeGetRTCData(r,i,o),c=new ie(D[D.rtcQryData],s,n);return this._channel.send(c,Oi)},e.prototype.removeRTCData=function(n,r,i,o,s){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,o,s),d=new kn(D[D.rtcDelData],c,n),[4,this._channel.send(d)]):[2,O.RC_NET_CHANNEL_INVALID];case 1:return[2,l.sent().code]}})})},e.prototype.setRTCOutData=function(n,r,i,o){throw new Error("JSEngine's method not implemented.")},e.prototype.getRTCOutData=function(n,r){throw new Error("JSEngine's method not implemented.")},e.prototype.getRTCToken=function(n,r,i){return x(this,void 0,void 0,function(){var o,s;return B(this,function(c){return this._channel?(o=this._channel.codec.encodeJoinRTCRoom(r,i),s=new ie(D[D.rtcToken],o,n),[2,this._channel.send(s,wi)]):[2,{code:O.RC_NET_CHANNEL_INVALID}]})})},e.prototype.setRTCState=function(n,r){return x(this,void 0,void 0,function(){var i,o;return B(this,function(s){switch(s.label){case 0:return this._channel?(i=this._channel.codec.encodeSetRTCState(r),o=new ie(D[D.rtcUserState],i,n),[4,this._channel.send(o)]):[2,O.RC_NET_CHANNEL_INVALID];case 1:return[2,s.sent().code]}})})},e.prototype.getRTCUserInfo=function(n){return x(this,void 0,void 0,function(){return B(this,function(r){throw new Error("Method not implemented.")})})},e.prototype.getRTCUserList=function(n){if(!this._channel)return Promise.resolve({code:O.RC_NET_CHANNEL_INVALID});var r=this._channel.codec.encodeGetRTCRoomInfo(),i=new ie(D[D.rtcUList],r,n);return this._channel.send(i,Yt)},e.prototype.joinLivingRoomAsAudience=function(n,r,i){return r===void 0&&(r=Je.LIVE),x(this,void 0,void 0,function(){var o,s,c,d,l,h,a,u;return B(this,function(f){switch(f.label){case 0:return this._channel?(o=this._channel.codec.encodeJoinRTCRoom(r,i),s=new ie(D[D.viewerJoinR],o,n),[4,this._channel.send(s,Ou)]):[2,{code:O.RC_NET_CHANNEL_INVALID}];case 1:return c=f.sent(),d=c.code,l=c.data,d!==O.SUCCESS?[2,{code:d}]:(a=(h=l).rtcToken,u=h.entries,[2,{code:d,data:{token:a,kvEntries:u}}])}})})},e.prototype.quitLivingRoomAsAudience=function(n){return x(this,void 0,void 0,function(){var r,i,o;return B(this,function(s){switch(s.label){case 0:return this._channel?(r=this._channel.codec.encodeQuitRTCRoom(),i=new ie(D[D.viewerExitR],r,n),[4,this._channel.send(i)]):[2,O.RC_NET_CHANNEL_INVALID];case 1:return o=s.sent().code,this._rtcKVManager.reset(),[2,o]}})})},e.prototype.rtcIdentityChange=function(n,r,i){return x(this,void 0,void 0,function(){var o,s,c,d,l;return B(this,function(h){switch(h.label){case 0:return this._channel?(o=this._channel.codec.encodeIdentityChangeInfo(r,i),s=new ie(D[D.rtcIdentityChange],o,n),[4,this._channel.send(s,Yt)]):[2,{code:O.RC_NET_CHANNEL_INVALID}];case 1:return c=h.sent(),d=c.code,l=c.data,d!==O.SUCCESS?[2,{code:d}]:[2,{code:d,data:l}]}})})},e.prototype.pullRTCRoomEntry=function(n,r){return x(this,void 0,void 0,function(){var i,o,s,c,d,l,h,a,u;return B(this,function(f){switch(f.label){case 0:return o=(i=this)._channel,s=i.currentUserId,o?(G.info("audience in room start pull KV"),c=o.codec.encodePullRTCRoomKV(n,0),d=new ie(D[D.rtcPullKv],c,s),[4,o.send(d,Li)]):[2,{code:O.RC_NET_CHANNEL_INVALID}];case 1:return l=f.sent(),h=l.code,a=l.data,G.info("audience in room end pull KV, code: "+h+", data: "+JSON.stringify(a||{})),h===O.SUCCESS?(u=a.kvEntries,this._watcher.onRTCDataChange(u,n),[2,{code:h,data:a}]):[2,{code:h}]}})})},e.prototype.getRTCJoinedUserInfo=function(n){return x(this,void 0,void 0,function(){var r,i,o,s,c,d,l,h;return B(this,function(a){switch(a.label){case 0:return i=(r=this)._channel,o=r.currentUserId,i?(s=i.codec.encodeQueryUserJoinedInfo(n),c=new ie(D[D.rtcQueryJoined],s,o),[4,i.send(c,ki)]):[2,{code:O.RC_NET_CHANNEL_INVALID}];case 1:return d=a.sent(),l=d.code,h=d.data,l===O.SUCCESS?[2,{code:l,data:h}]:[2,{code:l}]}})})},e.prototype.getDeviceId=function(){return $u(this.runtime)},e.prototype.requestRoomPK=function(n){return x(this,void 0,void 0,function(){var r,i,o;return B(this,function(s){switch(s.label){case 0:return this._channel?(r=this._channel.codec.encodeRequestRoomPK(n),i=new ie(D[D.rtcInvite],r,n.roomId),[4,this._channel.send(i)]):[2,O.RC_NET_CHANNEL_INVALID];case 1:return o=s.sent().code,this._rtcKVManager.reset(),[2,o]}})})},e.prototype.cancelRoomPK=function(n){return x(this,void 0,void 0,function(){var r,i,o;return B(this,function(s){switch(s.label){case 0:return this._channel?(r=this._channel.codec.encodeCancelRoomPK(n),i=new ie(D[D.rtcCancelInvite],r,n.roomId),[4,this._channel.send(i)]):[2,O.RC_NET_CHANNEL_INVALID];case 1:return o=s.sent().code,this._rtcKVManager.reset(),[2,o]}})})},e.prototype.responseRoomPK=function(n){return x(this,void 0,void 0,function(){var r,i,o;return B(this,function(s){switch(s.label){case 0:return this._channel?(r=this._channel.codec.encodeResponseRoomPK(n),i=new ie(D[D.rtcInviteAnswer],r,n.roomId),[4,this._channel.send(i)]):[2,O.RC_NET_CHANNEL_INVALID];case 1:return o=s.sent().code,this._rtcKVManager.reset(),[2,o]}})})},e.prototype.endRoomPK=function(n){return x(this,void 0,void 0,function(){var r,i,o;return B(this,function(s){switch(s.label){case 0:return this._channel?(r=this._channel.codec.encodeEndRoomPK(n),i=new ie(D[D.rtcEndInvite],r,n.roomId),[4,this._channel.send(i)]):[2,O.RC_NET_CHANNEL_INVALID];case 1:return o=s.sent().code,this._rtcKVManager.reset(),[2,o]}})})},e.prototype.callExtra=function(n){for(var r=[],i=1;i<arguments.length;i++)r[i-1]=arguments[i];return Promise.resolve({code:O.EXTRA_METHOD_UNDEFINED})},e.prototype.getConversationListWithAllChannel=function(){throw new Error("Method not implemented.")},e.prototype.getConversationListWithAllChannelByPage=function(n,r){throw new Error("Method not implemented.")},e.prototype.clearConversations=function(){throw new Error("Method not implemented.")},e.prototype.setUserStatusListener=function(n,r){throw new Error("Method not implemented.")},e.prototype.setUserStatus=function(n){throw new Error("Method not implemented.")},e.prototype.subscribeUserStatus=function(n){throw new Error("Method not implemented.")},e.prototype.getUserStatus=function(n){throw new Error("Method not implemented.")},e.prototype.addToBlacklist=function(n){throw new Error("Method not implemented.")},e.prototype.removeFromBlacklist=function(n){throw new Error("Method not implemented.")},e.prototype.getBlacklist=function(){throw new Error("Method not implemented.")},e.prototype.getBlacklistStatus=function(n){throw new Error("Method not implemented.")},e.prototype.insertMessage=function(n,r,i){throw new Error("Method not implemented.")},e.prototype.deleteMessages=function(n){throw new Error("Method not implemented.")},e.prototype.deleteMessagesByTimestamp=function(n,r,i,o,s){throw new Error("Method not implemented.")},e.prototype.clearMessages=function(n,r,i){throw new Error("Method not implemented.")},e.prototype.getMessage=function(n){throw new Error("Method not implemented.")},e.prototype.setMessageContent=function(n,r,i){throw new Error("Method not implemented.")},e.prototype.setMessageSearchField=function(n,r,i){throw new Error("Method not implemented.")},e.prototype.searchConversationByContent=function(n,r,i,o){throw new Error("Method not implemented.")},e.prototype.searchMessageByContent=function(n,r,i,o,s,c){throw new Error("Method not implemented.")},e.prototype.getUnreadMentionedMessages=function(n,r){throw new Error("Method not implemented.")},e.prototype.setMessageSentStatus=function(n,r){throw new Error("Method not implemented.")},e.prototype.setMessageReceivedStatus=function(n,r){throw new Error("Method not implemented.")},e.prototype.clearUnreadCountByTimestamp=function(n,r,i,o){throw new Error("Method not implemented.")},e.prototype.getConversationNotificationStatus=function(n,r,i){var o=this._conversationManager.get(n,r,i);return o?Promise.resolve({code:O.SUCCESS,data:o.notificationStatus}):Promise.resolve({code:O.CONVER_GET_ERROR})},e.prototype.getRemoteHistoryMessages=function(n,r,i,o,s,c){return this.getHistoryMessage(n,r,i,o,s,c)},e}(kh),Ku=function(){function t(e){this._context=e}return t.prototype.getCoreVersion=function(){return this._context.coreVersion},t.prototype.getAPIVersion=function(){return this._context.apiVersion},t.prototype.getAppkey=function(){return this._context.appkey},t.prototype.getCurrentId=function(){return this._context.getCurrentUserId()},t.prototype.getConnectionStatus=function(){return this._context.getConnectionStatus()},t.prototype.getDeviceId=function(){return this._context.getDeviceId()},t.prototype.sendMessage=function(e,n,r){return this._context.sendMessage(e,n,r)},t.prototype.registerMessageType=function(e,n,r,i){i===void 0&&(i=[]),this._context.registerMessageType(e,n,r,i)},t.prototype.getServerTime=function(){return this._context.getServerTime()},t.prototype.getRTCJoinedUserInfo=function(e){return this._context.getRTCJoinedUserInfo(e)},t}(),Qh=function(t){function e(){return t!==null&&t.apply(this,arguments)||this}return Oe(e,t),e.prototype.getNaviInfo=function(){return this._context.getInfoFromCache()},e.prototype.joinRTCRoom=function(n,r,i,o){return this._context.joinRTCRoom(n,r,i,o)},e.prototype.quitRTCRoom=function(n){return this._context.quitRTCRoom(n)},e.prototype.rtcPing=function(n,r,i){return this._context.rtcPing(n,r,i)},e.prototype.getRTCRoomInfo=function(n){return this._context.getRTCRoomInfo(n)},e.prototype.getRTCUserInfoList=function(n){return this._context.getRTCUserInfoList(n)},e.prototype.getRTCUserInfo=function(n){return this._context.getRTCUserInfo(n)},e.prototype.setRTCUserInfo=function(n,r,i){return this._context.setRTCUserInfo(n,r,i)},e.prototype.removeRTCUserInfo=function(n,r){return this._context.removeRTCUserInfo(n,r)},e.prototype.setRTCData=function(n,r,i,o,s,c){return this._context.setRTCData(n,r,i,o,s,c)},e.prototype.setRTCTotalRes=function(n,r,i,o,s){return this._context.setRTCTotalRes(n,r,i,o,s)},e.prototype.setRTCCDNUris=function(n,r,i){return this._context.setRTCCDNUris(n,r,i)},e.prototype.getRTCData=function(n,r,i,o){return this._context.getRTCData(n,r,i,o)},e.prototype.removeRTCData=function(n,r,i,o,s){return this._context.removeRTCData(n,r,i,o,s)},e.prototype.setRTCOutData=function(n,r,i,o){return this._context.setRTCOutData(n,r,i,o)},e.prototype.getRTCOutData=function(n,r){return this._context.getRTCOutData(n,r)},e.prototype.getRTCToken=function(n,r,i){return this._context.getRTCToken(n,r,i)},e.prototype.setRTCState=function(n,r){return this._context.setRTCState(n,r)},e.prototype.getRTCUserList=function(n){return this._context.getRTCUserList(n)},e.prototype.joinLivingRoomAsAudience=function(n,r,i){return this._context.joinLivingRoomAsAudience(n,r,i)},e.prototype.quitLivingRoomAsAudience=function(n){return this._context.quitLivingRoomAsAudience(n)},e.prototype.rtcIdentityChange=function(n,r,i){return this._context.rtcIdentityChange(n,r,i)},e.prototype.requestRoomPK=function(n){return this._context.requestRoomPK(n)},e.prototype.cancelRoomPK=function(n){return this._context.cancelRoomPK(n)},e.prototype.responseRoomPK=function(n){return this._context.responseRoomPK(n)},e.prototype.endRoomPK=function(n){return this._context.endRoomPK(n)},e}(Ku),nc=function(){function t(){}return t.compress=function(e){for(var n=this,r={},i=0;i<e.length-1;i++){var o=e.charAt(i)+e.charAt(i+1);r.hasOwnProperty(o)?r[o].push(i):r[o]=[i]}for(var s=[],c=[],d=function(){if(c.length>0){var _=c.join("");if(c=[],_.length>26){var v=n.numberEncode(_.length),y=String.fromCharCode(n.dataType.NormalExt|v.length);s.push(y+v)}else{var C=String.fromCharCode(n.dataType.Normal|_.length);s.push(C)}s.push(_)}},l=0;l<e.length;){var h=n.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=n.numberEncode(l-h.offset),u=n.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(n.dataType.Compressed|a.length<<2|u.length);s.push(f+a+u),l+=h.length}}}d();var p=n.numberEncode(e.length),m=String.fromCharCode(n.dataType.Tail|p.length);return s.push(m+p),s.join("")},t.uncompress=function(e){var n=this,r=0,i="";e:do{var o=e.charCodeAt(r++),s=o&n.dataType.Mark,c=15&o,d=void 0;switch(s){case n.dataType.Compressed:var l=c>>2,h=3&c;if(l===0||h===0)throw new Error("Data parsing error,at "+r);var a=n.numberDecode(e.substr(r,l)),u=n.numberDecode(e.substr(r+=l,h));if((a=i.length-a)+u>i.length)throw new Error("Data parsing error,at "+r);r+=h,i+=i.substr(a,u);break;case n.dataType.Tail:if((d=n.numberDecode(e.substr(r,c)))!==i.length)throw console.log(i.length),console.log(d),new Error("Data parsing error,at "+r);r+=c;break e;case n.dataType.NormalExt:d=n.numberDecode(e.substr(r,c)),i+=e.substr(r+=c,d),r+=d;break;case n.dataType.Normal:i+=e.substr(r,c),r+=c;break;case n.dataType.Mark:if(c>10)throw new Error("Data parsing error,at "+r);i+=e.substr(r,16+c),r+=16+c;break;default:throw new Error("Data parsing error,at "+r+" header:"+s)}}while(r<e.length);return i},t.indexOf=function(e,n,r){var i={length:0,offset:-1};if(n.length,r>=n.length-1)return i;var o=e[n.charAt(r)+n.charAt(r+1)];if(o[0]===r)return i;for(var s=n.length-r,c=0,d=o.length;c<d;c++){var l=o[c],h=r-l;if(!(h>this.max)){var a=Math.min(s,h);if(a<=i.length)break;if(!(i.length>2&&n.charAt(l+i.length-1)!==n.charAt(r+i.length-1))){for(var u=2,f=u;f<a&&n.charAt(l+f)===n.charAt(r+f);f++)u++;u>=i.length&&(i.length=u,i.offset=l)}}}return i},t.numberEncode=function(e){var n=this,r=[],i=0;do i=e%n.scale,r.push(n.chars.charAt(i)),e=(e-i)/n.scale;while(e>0);return r.join("")},t.numberDecode=function(e){for(var n=0,r=0,i=e.length-1;i>=0;i--){if((r=this.chars.indexOf(e.charAt(i)))===-1)throw new Error('decode number error, data is "'+e+'"');n=n*this.scale+r}return n},t.dataType={Tail:48,Compressed:64,NormalExt:80,Normal:96,Mark:112},t.chars="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",t.scale=t.chars.length,t.max=238327,t}(),Dn=1,xn=!1,rc=typeof location!="undefined"&&location.protocol==="https://"?"https://":"http://",Tr=function(){function t(e){this.info=e,this.logUrl="logcollection.ronghub.com",this.level=1,this.itv=30,this.times=5,this.deviceId="",this.deviceInfo="",this.logSwitch=0,this.logUrl=e.logPolicy.url||this.logUrl,this.level=e.logPolicy.level||this.level,this.itv=e.logPolicy.itv||this.itv,this.times=e.logPolicy.times||this.times,this.deviceId=$u(e.runtime),this.logSwitch=e.logSwitch;var n=oh(e.runtime);this.deviceInfo=n.type+"|"+n.version+"|"+Ht.sessionId,this.startReport()}return t.init=function(e){return xn=!0,t._instance||(t._instance=new t(e)),t._instance},t.getInstance=function(){return t._instance},t.prototype.startReport=function(){var e=this;if(this.logSwitch&&xn){var n=this.itv*Math.pow(2,Dn-1);Dn<this.times&&Dn++,setTimeout(function(){e.reportRealtimeLog()},1e3*n)}},t.prototype.reportRealtimeLog=function(){var e=this,n=Ht.realTimeLogList.filter(function(o){return o.level<=e.level});if(n.length!==0){var r=nc.compress(n.map(function(o){return o.content}).join("")),i=""+rc+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(o){G.__clearRealTimeLog(),G.debug("report real-time log success");var s=o.data;s&&(s=JSON.parse(s),e.itv=s.nextTime,e.level=s.level,e.logSwitch=s.logSwitch,Dn=1),e.startReport()}).catch(function(o){G.debug("report real-time log error -> "+o),e.startReport()})}else this.startReport()},t.prototype.reportFullLog=function(e){return x(this,void 0,void 0,function(){var n,r,i,o,s,c,d,l,h,a,u=this;return B(this,function(f){switch(f.label){case 0:return n=e.startTime,r=e.endTime,i=e.platform,o=e.logId,s=e.uri,c=fs.getInstance(),G.debug("received report log msg, "+i.toLowerCase(),c),i.toLowerCase()==="web"&&c?n>r?(G.warn("report error: The start time("+n+") cannot be greater than the end time("+n+")"),[2]):[4,G.__insertLogIntoDatabase()]:[2];case 1:return f.sent(),[4,c.getRangeData(cn,"time",n,r)];case 2:return d=(d=f.sent()).filter(function(p){return!p.userId||p.userId===u.info.userId}),l=nc.compress(d.map(function(p){return p.content}).join("")||"no data"),h=1,(a=function(){if(!(h>3)&&xn){var p=s||u.logUrl,m=""+rc+p+"?version="+u.info.version+"&appkey="+u.info.appkey+"&userId="+u.info.userId+"&logId="+o+"&deviceId="+u.deviceId+"&deviceInfo="+u.deviceInfo+"&platform=Web",_=5e3*(h-1);h++,setTimeout(function(){xn&&u.info.runtime.httpReq({url:m,method:"POST",body:l}).then(function(){G.debug("report full log success!")}).catch(function(v){a(),G.warn("report full log error -> "+v)})},_)}})(),[2]}})})},t.prototype.distroy=function(){Dn=1,xn=!1},t}();function Sr(t){return Object.assign({},t)}var ic,Xh=function(){function t(e,n){var r;this._runtime=e,this._token="",this._pluginContextQueue=[],this._pluginInstanseMap={},this.coreVersion="5.1.1",this._versionInfo={},this._typingInfo={},this._isInternalConnected=!1,this._connectionStatus=ae.DISCONNECTED,this._canRedirectConnect=!1,this._watcher={message:void 0,batchMessage:void 0,conversationState:void 0,chatroomState:void 0,connectionState:void 0,rtcInnerWatcher:void 0,expansion:void 0,tag:void 0,conversationTagChanged:void 0,pullFinished:void 0,onConnecting:void 0,onConnected:void 0,onDisconnect:void 0,onSuspend:void 0,readReceiptReceived:void 0,messageReceiptRequest:void 0,messageReceiptResponse:void 0,typingState:void 0,messageBlocked:void 0},this._typingInternalTimer=-1,this._typingExpireTime=2e3,this._typingChangedList=[],this.getChatRoomHistoryMessages=this.getChatroomHistoryMessages,this._options=Object.assign({},n),this.appkey=this._options.appkey,this.apiVersion=this._options.apiVersion,this._options.typingExpireTime&&(this._options.typingExpireTime<2e3?this._typingExpireTime=2e3:this._options.typingExpireTime>6e3?this._typingExpireTime=6e3:this._typingExpireTime=this._options.typingExpireTime),this._options.navigators=this._options.navigators.filter(function(o){return/^https?:\/\//.test(o)}),this._options.navigators=this._options.navigators.map(function(o){return o.replace(/\/$/g,"")}),this._options.navigators.length===0&&(r=this._options.navigators).push.apply(r,ql);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 zh(e,i,this._options)}return t.init=function(e,n){return G.setLogLevel(n.logLevel),G.setLogStdout(n.logStdout),(n.indexDBSwitch||me(n.indexDBSwitch))&&fs.init(),G.debug("APIContext.init =>",n.appkey,n.navigators),this._context?(G.error("Repeat initialize!"),this._context):(G.warn("RCEngine Commit:","41dbe38d1b376ca0a791b23ed94be291e3f92e81"),this._context=new t(e,n),G.__insertLogIntoDatabase(),this._context)},t.destroy=function(){this._context&&(this._context._destroy(),this._context=void 0)},t.prototype.install=function(e,n){if(this._pluginInstanseMap[e.tag])return G.warn("Repeat install plugin: "+e.tag),this._pluginInstanseMap[e.tag];var r=e.tag==="RCRTC"?new Qh(this):new Ku(this),i=null;try{if(!e.verify(this._runtime))return null;i=e.setup(r,this._runtime,n)}catch(o){G.error(`install plugin error!
- `,o)}return["RCRTC","RCCall"].includes(e.tag)&&e.version&&e.name&&(this._versionInfo[e.name]=e.version),i&&this._pluginContextQueue.push(r),i&&(this._pluginInstanseMap[e.tag]=i),i},t.prototype._handleRedirect=function(){return x(this,void 0,void 0,function(){var e=this;return B(this,function(n){switch(n.label){case 0:return G.debug("_handleRedirct",this._token),[4,this.connect(this._token,!0)];case 1:return n.sent().code!==O.SUCCESS&&this._canRedirectConnect&&(this._handleSuspend(),setTimeout(function(){e._handleRedirect()},5e3)),[2]}})})},t.prototype._connectionStatusListener=function(e){var n;return x(this,void 0,void 0,function(){return B(this,function(r){return e===ae.REDIRECT?(this._canRedirectConnect=!0,this._handleSuspend(),this._handleRedirect()):e===ae.BLOCKED||e===ae.KICKED_OFFLINE_BY_OTHER_CLIENT||e===ae.DISCONNECT_BY_SERVER?(this._canRedirectConnect=!1,this._handleDisconnect()):e===ae.CONNECTING?this._handleConnecting():e===ae.CONNECTED?this._handleConnected():e===ae.DISCONNECTED?this._handleDisconnect():e===ae.NETWORK_UNAVAILABLE&&this._handleSuspend(),this._connectionStatus=e,((n=this._watcher.rtcInnerWatcher)===null||n===void 0?void 0:n.status)&&this._watcher.rtcInnerWatcher.status(e),this._pluginContextQueue.forEach(function(i){i.onconnectionstatechange&&i.onconnectionstatechange(e)}),this._watcher.connectionState&&this._watcher.connectionState(e),[2]})})},t.prototype._handleConnecting=function(){this._watcher.onConnecting&&this._watcher.onConnecting()},t.prototype._handleConnected=function(){this._watcher.onConnected&&this._watcher.onConnected()},t.prototype._handleDisconnect=function(){this._watcher.onDisconnect&&this._watcher.onDisconnect()},t.prototype._handleSuspend=function(){this._watcher.onSuspend&&this._watcher.onSuspend()},t.prototype._messageReceiver=function(e,n,r){var i,o,s;if((e.conversationType===re.RTC_ROOM||Object.prototype.hasOwnProperty.call(Xl,e.messageType))&&this._watcher.rtcInnerWatcher&&this._watcher.rtcInnerWatcher.message)this._watcher.rtcInnerWatcher.message(Sr(e));else if(["RC:ChrmJoinNtf","RC:ChrmQuitNtf"].indexOf(e.messageType)===-1||typeof this._watcher.chatroomState!="function"){if(e.messageType!=="RC:ChrmMemChange"){if(e.messageType!==Ge.TYPING_STATUS||(this._addTypingInfo(Sr(e)),!this._watcher.typingState))if(e.messageType!==Ge.LOG_COMMAND||e.senderUserId!=="rongcloudsystem")if(e.messageType!==Ge.INTERCEPT){if(!this._pluginContextQueue.some(function(v){if(!v.onmessage)return!1;try{return v.onmessage(Sr(e))}catch(y){return G.error("plugin error =>",y),!1}}))if(e.messageType!=="RC:ReadNtf")if(e.messageType!=="RC:RRReqMsg"){if(e.messageType!=="RC:RRRspMsg")return this._watcher.message&&this._watcher.message(Sr(e),n,r),e;var c=(s=e.content)===null||s===void 0?void 0:s.receiptMessageDic;c&&Array.isArray(c[this._engine.currentUserId])&&typeof this._watcher.messageReceiptResponse=="function"&&this._watcher.messageReceiptResponse({conversationType:e.conversationType,targetId:e.targetId,channelId:e.channelId},e.senderUserId,c[this._engine.currentUserId])}else typeof this._watcher.messageReceiptRequest=="function"&&this._watcher.messageReceiptRequest({conversationType:e.conversationType,targetId:e.targetId,channelId:e.channelId},e.content.messageUId,e.senderUserId);else typeof this._watcher.readReceiptReceived=="function"&&this._watcher.readReceiptReceived({conversationType:e.conversationType,targetId:e.targetId,channelId:e.channelId},e.content.messageUId,e.content.lastMessageSendTime)}else this._MessageBlockedListener({conversationType:e.conversationType,targetId:e.targetId,channelId:e.channelId||"",blockType:e.content.interceptType,blockedMessageUId:e.content.msgUId});else{var d=e.content,l=d.startTime,h=d.endTime,a=d.platform,u=d.logId,f=d.uri,p=d.packageName,m={startTime:parseInt(l),endTime:parseInt(h),platform:a,logId:u,uri:f,packageName:p};(o=Tr.getInstance())===null||o===void 0||o.reportFullLog(m)}}else if(typeof this._watcher.chatroomState=="function"){var _={};Array.isArray(e.content.userList)&&e.content.userList.forEach(function(v){_[v.userId]=v.status}),this._watcher.chatroomState({userChange:{users:_,chatroomId:e.targetId}})}}else this._watcher.chatroomState({userChange:{users:(i={},i[e.senderUserId]=e.messageType==="RC:ChrmQuitNtf"?Va.QUIT:Va.JOIN,i),chatroomId:e.targetId}})},t.prototype._batchMessageReceiver=function(e,n,r){var i=this,o=[];e.forEach(function(s){var c=i._messageReceiver(s,n,r);c&&o.push(c)}),o.length&&this._watcher.batchMessage&&this._watcher.batchMessage(o)},t.prototype._chatroomInfoListener=function(e){this._watcher.chatroomState&&this._watcher.chatroomState(e)},t.prototype._conversationInfoListener=function(e){this._watcher.conversationState&&this._watcher.conversationState(e)},t.prototype._expansionInfoListener=function(e){this._watcher.expansion&&this._watcher.expansion(e)},t.prototype._tagListener=function(){this._watcher.tag&&this._watcher.tag()},t.prototype._conversationTagListener=function(){this._watcher.conversationTagChanged&&this._watcher.conversationTagChanged()},t.prototype._typingStatusListener=function(e){this._watcher.typingState&&this._watcher.typingState(e)},t.prototype._pullFinishedListener=function(){this._watcher.pullFinished&&this._watcher.pullFinished()},t.prototype._MessageBlockedListener=function(e){this._watcher.messageBlocked&&this._watcher.messageBlocked(e)},t.prototype._rtcDataChange=function(e,n){this._pluginContextQueue.forEach(function(r){r.onrtcdatachange&&r.onrtcdatachange(e,n)})},t.prototype.assignWatcher=function(e){var n=this;Object.keys(this._watcher).forEach(function(r){if(Object.prototype.hasOwnProperty.call(e,r)){var i=e[r];n._watcher[r]=Wr(i)||je(i)?i:void 0}})},t.prototype.resetWatcher=function(){var e=this;Object.keys(this._watcher).forEach(function(n){e._watcher[n]=void 0})},t.prototype._addTypingInfo=function(e){var n=e.senderUserId,r=e.conversationType,i=e.targetId,o=e.content,s=e.channelId,c=o.typingContentType,d=r+"#"+i+"#"+(s||"");this._typingInfo[d]||(this._typingInfo[d]=[]);var l=this._typingInfo[d].findIndex(function(h){return h.userId===n});l>=0&&this._typingInfo[d][l].messageType===c?this._typingInfo[d][l].timestamp=Date.now():(l>=0&&this._typingInfo[d].splice(l,1),this._typingInfo[d].push({userId:n,messageType:c,timestamp:Date.now()}),this._typingChangedList.includes(d)||this._typingChangedList.push(d),this._startCheckTypingInfo())},t.prototype._startCheckTypingInfo=function(){var e=this;this._typingInternalTimer===-1&&Object.keys(this._typingInfo).length!==0&&(this._typingInternalTimer=setInterval(function(){for(var n in e._typingInfo){var r=e._typingInfo[n].length;e._typingInfo[n]=e._typingInfo[n].filter(function(o){return Date.now()-o.timestamp<e._typingExpireTime}),e._typingInfo[n].length===r||e._typingChangedList.includes(n)||e._typingChangedList.push(n),e._typingInfo[n].length===0&&delete e._typingInfo[n]}if(e._typingChangedList.length>0){var i=e._typingChangedList.map(function(o){return{conversationType:Number(o.split("#")[0]),targetId:o.split("#")[1],channelId:o.split("#")[2],list:e._typingInfo[o]||[]}});e._typingStatusListener(i),e._typingChangedList=[]}Object.keys(e._typingInfo).length===0&&(clearInterval(e._typingInternalTimer),e._typingInternalTimer=-1)},500))},t.prototype.getConnectedTime=function(){return this._engine.getConnectedTime()},t.prototype.getServerTime=function(){return this._engine.getServerTime()},t.prototype.getDeviceId=function(){return this._engine.getDeviceId()},t.prototype.getCurrentUserId=function(){return this._engine.currentUserId},t.prototype.getConnectionStatus=function(){return this._connectionStatus},Object.defineProperty(t.prototype,"token",{get:function(){return this._token},enumerable:!1,configurable:!0}),t.prototype.connect=function(e,n){return n===void 0&&(n=!1),x(this,void 0,void 0,function(){var r,i,o,s,c,d;return B(this,function(l){switch(l.label){case 0:return this._connectionStatus===ae.CONNECTED?[2,{code:O.SUCCESS,userId:this._engine.currentUserId}]:this._connectionStatus===ae.CONNECTING?[2,{code:O.BIZ_ERROR_CONNECTING}]:typeof e!="string"||e.length===0?[2,{code:O.RC_CONN_USER_OR_PASSWD_ERROR}]:(this._token=e,r=e.split("@"),i=r[1],o=i?i.split(";").map(function(h){return/^https?:/.test(h)?h:"https://"+h}):[],[4,this._engine.navi.getInfo(this._getTokenWithoutNavi(),o,n,this._options.checkCA)]);case 1:return(s=l.sent())?(s==null?void 0:s.type)===1?[2,{code:O.PACKAGE_ENVIRONMENT_ERROR}]:(c=zt.getInfo(),[4,this._engine.connect(this._getTokenWithoutNavi(),s)]):[2,{code:O.RC_NAVI_RESOURCE_ERROR}];case 2:return d=l.sent(),G.__insertLogIntoDatabase(),d!==Ke.REDIRECT?[3,4]:(this._connectionStatus=ae.REDIRECT,[4,this.connect(e,!0)]);case 3:return[2,l.sent()];case 4:return d===O.SUCCESS&&(G.info("connect success, userId: "+this._engine.currentUserId),(s==null?void 0:s.type)!==1&&this._engine.reportSDKInfo&&this._engine.reportSDKInfo(c),Tr.init({runtime:this._runtime,logSwitch:(s==null?void 0:s.logSwitch)||0,logPolicy:JSON.parse((s==null?void 0:s.logPolicy)||"{}"),appkey:this.appkey,version:this.apiVersion,userId:this._engine.currentUserId}),Ht.init(this._engine.currentUserId),this._isInternalConnected=!0),d!==O.SUCCESS||$a()||s.openUS===1&&this._pullUserSettings(),d!==O.SUCCESS&&(this._connectionStatus=ae.CONNECTION_CLOSED),[2,{code:d,userId:this._engine.currentUserId}]}})})},t.prototype._pullUserSettings=function(){return x(this,void 0,void 0,function(){return B(this,function(e){return[2]})})},t.prototype.disconnect=function(){var e;return this._isInternalConnected=!1,clearInterval(this._typingInternalTimer),this._typingInternalTimer=-1,(e=Tr.getInstance())===null||e===void 0||e.distroy(),G.__insertLogIntoDatabase(),Ht.reset(),this._engine.disconnect(),this._pluginContextQueue.forEach(function(n){if(n.ondisconnect)try{n.ondisconnect()}catch(r){G.error("plugin error =>",r)}}),Promise.resolve()},t.prototype.reconnect=function(){return this._isInternalConnected?Promise.resolve({code:O.CAN_NOT_RECONNECT}):this.connect(this._getTokenWithoutNavi())},t.prototype._getTokenWithoutNavi=function(){return this._token.replace(/@.+$/,"@")},t.prototype.getInfoFromCache=function(){return this._engine.navi.getInfoFromCache(this._getTokenWithoutNavi())},t.prototype.registerMessageType=function(e,n,r,i){i===void 0&&(i=[]),this._engine.registerMessageType(e,n,r,i)},t.prototype.sendMessage=function(e,n,r,i){var o=this.getInfoFromCache();if(((o==null?void 0:o.grpRRVer)||0)===1&&r.messageType===Ge.READ_RECEIPT_RESPONSE)return Promise.resolve({code:O.READ_RECEIPT_ERROR});var s=JSON.stringify(r.content);return fu(s)>131072?Promise.resolve({code:O.RC_MSG_CONTENT_EXCEED_LIMIT}):this._engine.sendMessage(e,n,r,i)},t.prototype.sendExpansionMessage=function(e){return x(this,void 0,void 0,function(){var n,r,i,o,s,c,d,l,h,a,u,f,p,m;return B(this,function(_){switch(_.label){case 0:if(n=e.channelId,r=e.conversationType,i=e.targetId,o=e.messageUId,s=e.keys,c=e.expansion,d=e.removeAll,!e.canIncludeExpansion)return[2,{code:O.MESSAGE_KV_NOT_SUPPORT}];if(l=!1,h=!1,a=!1,je(c)){for(f in u=Object.keys(c).length,l=u>20,c)if(p=c[f],h=nt(f)&&!/^[A-Za-z0-9_=+-]+$/.test(f),(a=f.length>32||p.length>64)||h)break}return l||a?[2,{code:O.EXPANSION_LIMIT_EXCEET}]:h?[2,{code:O.BIZ_ERROR_INVALID_PARAMETER}]:(m={mid:o},c&&(m.put=c),s&&(m.del=s),d&&(m.removeAll=1),[4,this._engine.sendMessage(r,i,{content:m,messageType:Ge.EXPANSION_NOTIFY,channelId:n})]);case 1:return[2,{code:_.sent().code}]}})})},t.prototype.sendReadReceiptMessage=function(e,n,r){return x(this,void 0,void 0,function(){var i;return B(this,function(o){return i=this.getInfoFromCache(),((i==null?void 0:i.grpRRVer)||0)===0?[2,{code:O.READ_RECEIPT_ERROR,data:"The read receipt switch is not on, please call the sendMessage method!"}]:[2,this._engine.sendReadReceiptMessage(e,n,r)]})})},t.prototype.getMessageReader=function(e,n,r){return x(this,void 0,void 0,function(){var i;return B(this,function(o){return i=this.getInfoFromCache(),((i==null?void 0:i.grpRRVer)||0)===0?[2,{code:O.READ_RECEIPT_ERROR}]:[2,this._engine.getMessageReader(e,n,r)]})})},t.prototype._destroy=function(){var e;this._isInternalConnected=!1,this._watcher={batchMessage:void 0,message:void 0,conversationState:void 0,chatroomState:void 0,connectionState:void 0,rtcInnerWatcher:void 0,expansion:void 0,tag:void 0,conversationTagChanged:void 0,typingState:void 0,pullFinished:void 0,onConnecting:void 0,onConnected:void 0,onDisconnect:void 0,onSuspend:void 0},this._engine.disconnect(),this._pluginContextQueue.forEach(function(n){if(n.ondestroy)try{n.ondestroy()}catch(r){G.error("plugin error =>",r)}}),this._pluginContextQueue.length=0,this._pluginInstanseMap={},(e=Tr.getInstance())===null||e===void 0||e.distroy(),Ht.reset()},t.prototype.getHistoryMessage=function(e,n,r,i,o,s,c){return r===void 0&&(r=0),i===void 0&&(i=20),o===void 0&&(o=0),s===void 0&&(s=""),c===void 0&&(c=""),this._engine.getHistoryMessage(e,n,r,i,o,s,c||"")},t.prototype.getConversationList=function(e,n,r,i,o){return e===void 0&&(e=300),o===void 0&&(o=""),this._engine.getConversationList(e,n,r,i,o)},t.prototype.getConversation=function(e,n,r){return this._engine.getConversation(e,n,r)},t.prototype.removeConversation=function(e,n,r){return r===void 0&&(r=""),this._engine.removeConversation(e,n,r)},t.prototype.clearUnreadCount=function(e,n,r){return r===void 0&&(r=""),this._engine.clearConversationUnreadCount(e,n,r)},t.prototype.clearAllUnreadCount=function(){return this._engine.clearAllUnreadCount()},t.prototype.getUnreadCount=function(e,n,r){return r===void 0&&(r=""),this._engine.getConversationUnreadCount(e,n,r)},t.prototype.getTotalUnreadCount=function(e,n,r){return this._engine.getAllConversationUnreadCount(e,n&&n.length>0?n:[re.PRIVATE,re.GROUP,re.SYSTEM,re.PUBLIC_SERVICE],!!r)},t.prototype.getFirstUnreadMessage=function(e,n,r){return r===void 0&&(r=""),this._engine.getFirstUnreadMessage(e,n,r)},t.prototype.setConversationStatus=function(e,n,r,i,o){o===void 0&&(o="");var s=[{conversationType:e,targetId:n,isTop:r,notificationStatus:i,channelId:o}];return this._engine.batchSetConversationStatus(s)},t.prototype.saveConversationMessageDraft=function(e,n,r,i){return i===void 0&&(i=""),this._engine.saveConversationMessageDraft(e,n,r,i)},t.prototype.getConversationMessageDraft=function(e,n,r){return r===void 0&&(r=""),this._engine.getConversationMessageDraft(e,n,r)},t.prototype.clearConversationMessageDraft=function(e,n,r){return r===void 0&&(r=""),this._engine.clearConversationMessageDraft(e,n,r)},t.prototype.recallMessage=function(e,n,r,i,o){return this._engine.recallMsg(e,n,r,i,o)},t.prototype.deleteRemoteMessage=function(e,n,r,i){return i===void 0&&(i=""),this._engine.deleteRemoteMessage(e,n,r,i)},t.prototype.deleteRemoteMessageByTimestamp=function(e,n,r,i){return i===void 0&&(i=""),this._engine.deleteRemoteMessageByTimestamp(e,n,r,i)},t.prototype.joinChatroom=function(e,n){return n===void 0&&(n=10),this._engine.joinChatroom(e,n)},t.prototype.joinExistChatroom=function(e,n){return n===void 0&&(n=10),this._engine.joinExistChatroom(e,n)},t.prototype.quitChatroom=function(e){return this._engine.quitChatroom(e)},t.prototype.getChatroomInfo=function(e,n,r){return n===void 0&&(n=0),r===void 0&&(r=0),this._engine.getChatroomInfo(e,n,r)},t.prototype.setChatroomEntry=function(e,n){var r=n.key,i=n.value;return tn(r)&&Qi(i)?this._engine.setChatroomEntry(e,n):Promise.resolve(O.BIZ_ERROR_INVALID_PARAMETER)},t.prototype.setChatroomEntries=function(e,n){for(var r=0;r<n.entries.length;r++){var i=n.entries[r],o=i.key,s=i.value;if(!tn(o)||!Qi(s))return Promise.resolve({code:O.BIZ_ERROR_INVALID_PARAMETER})}return this._engine.setChatroomEntries(e,n)},t.prototype.forceSetChatroomEntry=function(e,n){var r=n.key,i=n.value;return tn(r)&&Qi(i)?this._engine.forceSetChatroomEntry(e,n):Promise.resolve(O.BIZ_ERROR_INVALID_PARAMETER)},t.prototype.removeChatroomEntry=function(e,n){var r=n.key;return tn(r)?this._engine.removeChatroomEntry(e,n):Promise.resolve(O.BIZ_ERROR_INVALID_PARAMETER)},t.prototype.removeChatroomEntries=function(e,n){for(var r=0;r<n.entries.length;r++){var i=n.entries[r].key;if(!tn(i))return Promise.resolve({code:O.BIZ_ERROR_INVALID_PARAMETER})}return this._engine.removeChatroomEntries(e,n)},t.prototype.forceRemoveChatroomEntry=function(e,n){var r=n.key;return tn(r)?this._engine.forceRemoveChatroomEntry(e,n):Promise.resolve(O.BIZ_ERROR_INVALID_PARAMETER)},t.prototype.getChatroomEntry=function(e,n){return this._engine.getChatroomEntry(e,n)},t.prototype.getAllChatroomEntries=function(e){return this._engine.getAllChatroomEntry(e)},t.prototype.getChatroomHistoryMessages=function(e,n,r,i){return n===void 0&&(n=20),r===void 0&&(r=0),i===void 0&&(i=0),this._engine.getChatroomHistoryMessages(e,i,n,r)},t.prototype.getFileToken=function(e,n,r,i){return x(this,void 0,void 0,function(){var o,s,c,d,l,h,a;return B(this,function(u){switch(u.label){case 0:return o=this.getInfoFromCache(),s=(o==null?void 0:o.bosAddr)||"",c=(o==null?void 0:o.uploadServer)||"",d=(o==null?void 0:o.ossConfig)||"",[4,this._engine.getFileToken(e,n,r,i)];case 1:return l=u.sent(),h=l.code,a=l.data,h===O.SUCCESS?[2,Promise.resolve(Object.assign(a,{bos:s,qiniu:c,ossConfig:d}))]:[2,Promise.reject(h)]}})})},t.prototype.getFileUrl=function(e,n,r,i,o){return o===void 0&&(o=ze.QINIU),x(this,void 0,void 0,function(){var s,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,o,n,r)];case 1:return s=l.sent(),c=s.code,d=s.data,c===O.SUCCESS?[2,Promise.resolve(d)]:[2,Promise.reject(c)]}})})},t.prototype.createTag=function(e){return x(this,void 0,void 0,function(){return B(this,function(n){return[2,this._engine.createTag(e)]})})},t.prototype.removeTag=function(e){return x(this,void 0,void 0,function(){return B(this,function(n){return[2,this._engine.removeTag(e)]})})},t.prototype.updateTag=function(e){return x(this,void 0,void 0,function(){return B(this,function(n){return[2,this._engine.updateTag(e)]})})},t.prototype.getTagList=function(){return x(this,void 0,void 0,function(){return B(this,function(e){return[2,this._engine.getTagList()]})})},t.prototype.addTagForConversations=function(e,n){return x(this,void 0,void 0,function(){return B(this,function(r){return n.length>1e3?[2,Promise.reject(O.CONVER_OUT_LIMIT_ERROR)]:[2,this._engine.addTagForConversations(e,n)]})})},t.prototype.removeTagForConversations=function(e,n){return x(this,void 0,void 0,function(){return B(this,function(r){return[2,this._engine.removeTagForConversations(e,n)]})})},t.prototype.removeTagsForConversation=function(e,n){return x(this,void 0,void 0,function(){return B(this,function(r){return[2,this._engine.removeTagsForConversation(e,n)]})})},t.prototype.getConversationListByTag=function(e,n,r,i){return x(this,void 0,void 0,function(){return B(this,function(o){return[2,this._engine.getConversationListByTag(e,n,r,i)]})})},t.prototype.getUnreadCountByTag=function(e,n){return x(this,void 0,void 0,function(){return B(this,function(r){return[2,this._engine.getUnreadCountByTag(e,n)]})})},t.prototype.setConversationStatusInTag=function(e,n,r){return x(this,void 0,void 0,function(){return B(this,function(i){return[2,this._engine.setConversationStatusInTag(e,n,r)]})})},t.prototype.getTagsForConversation=function(e){return x(this,void 0,void 0,function(){return B(this,function(n){return[2,this._engine.getTagsForConversation(e)]})})},t.prototype.getBlockConversationList=function(){return this._engine.getBlockConversationList()},t.prototype.getTopConversationList=function(){return this._engine.getTopConversationList()},t.prototype.getUnreadMentionedCount=function(e){return this._engine.getUnreadMentionedCount(e)},t.prototype.getAllUnreadMentionedCount=function(){return this._engine.getAllUnreadMentionedCount()},t.prototype.callExtra=function(e){for(var n,r=[],i=1;i<arguments.length;i++)r[i-1]=arguments[i];return(n=this._engine).callExtra.apply(n,Wt([e],r))},t.prototype.clearConversations=function(e,n){return x(this,void 0,void 0,function(){return B(this,function(r){switch(r.label){case 0:return[4,this._engine.clearConversations(e,n)];case 1:return[2,r.sent()]}})})},t.prototype.setUserStatusListener=function(e,n){return this._engine.setUserStatusListener(e,function(r){try{n(r)}catch(i){G.error(i)}})},t.prototype.addToBlacklist=function(e){return x(this,void 0,void 0,function(){return B(this,function(n){return[2,this._engine.addToBlacklist(e)]})})},t.prototype.removeFromBlacklist=function(e){return x(this,void 0,void 0,function(){return B(this,function(n){return[2,this._engine.removeFromBlacklist(e)]})})},t.prototype.getBlacklist=function(){return x(this,void 0,void 0,function(){return B(this,function(e){return[2,this._engine.getBlacklist()]})})},t.prototype.getBlacklistStatus=function(e){return x(this,void 0,void 0,function(){return B(this,function(n){return[2,this._engine.getBlacklistStatus(e)]})})},t.prototype.insertMessage=function(e,n,r){return x(this,void 0,void 0,function(){return B(this,function(i){return[2,this._engine.insertMessage(e,n,r)]})})},t.prototype.deleteMessages=function(e){return x(this,void 0,void 0,function(){return B(this,function(n){return[2,this._engine.deleteMessages(e)]})})},t.prototype.deleteMessagesByTimestamp=function(e,n,r,i,o){return o===void 0&&(o=""),x(this,void 0,void 0,function(){return B(this,function(s){return[2,this._engine.deleteMessagesByTimestamp(e,n,r,i,o)]})})},t.prototype.clearMessages=function(e,n,r){return r===void 0&&(r=""),x(this,void 0,void 0,function(){return B(this,function(i){return[2,this._engine.clearMessages(e,n,r)]})})},t.prototype.getMessage=function(e){return x(this,void 0,void 0,function(){return B(this,function(n){return[2,this._engine.getMessage(e)]})})},t.prototype.setMessageContent=function(e,n,r){return x(this,void 0,void 0,function(){return B(this,function(i){return[2,this._engine.setMessageContent(e,n,r)]})})},t.prototype.setMessageSearchField=function(e,n,r){return x(this,void 0,void 0,function(){return B(this,function(i){return[2,this._engine.setMessageSearchField(e,n,r)]})})},t.prototype.setMessageSentStatus=function(e,n){return x(this,void 0,void 0,function(){return B(this,function(r){return[2,this._engine.setMessageSentStatus(e,n)]})})},t.prototype.setMessageReceivedStatus=function(e,n){return x(this,void 0,void 0,function(){return B(this,function(r){return[2,this._engine.setMessageReceivedStatus(e,n)]})})},t.prototype.setUserStatus=function(e){return x(this,void 0,void 0,function(){return B(this,function(n){return[2,this._engine.setUserStatus(e)]})})},t.prototype.subscribeUserStatus=function(e){return x(this,void 0,void 0,function(){return B(this,function(n){return[2,this._engine.subscribeUserStatus(e)]})})},t.prototype.getUserStatus=function(e){return x(this,void 0,void 0,function(){return B(this,function(n){return[2,this._engine.getUserStatus(e)]})})},t.prototype.searchConversationByContent=function(e,n,r,i){return n===void 0&&(n=[]),r===void 0&&(r=""),x(this,void 0,void 0,function(){return B(this,function(o){return[2,this._engine.searchConversationByContent(e,n,r,i)]})})},t.prototype.searchMessageByContent=function(e,n,r,i,o,s,c){return c===void 0&&(c=""),x(this,void 0,void 0,function(){return B(this,function(d){return[2,this._engine.searchMessageByContent(e,n,r,i,o,s,c)]})})},t.prototype.getUnreadMentionedMessages=function(e,n,r){return r===void 0&&(r=""),this._engine.getUnreadMentionedMessages(e,n,r)},t.prototype.clearUnreadCountByTimestamp=function(e,n,r,i){return i===void 0&&(i=""),this._engine.clearUnreadCountByTimestamp(e,n,r,i)},t.prototype.getConversationNotificationStatus=function(e,n,r){return r===void 0&&(r=""),this._engine.getConversationNotificationStatus(e,n,r)},t.prototype.getRemoteHistoryMessages=function(e,n,r,i,o,s){return this._engine.getRemoteHistoryMessages(e,n,r,i,o,s)},t.prototype.getConversationListWithAllChannel=function(){return this._engine.getConversationListWithAllChannel()},t.prototype.getConversationListWithAllChannelByPage=function(e,n){return this._engine.getConversationListWithAllChannelByPage(e,n)},t.prototype.joinRTCRoom=function(e,n,r,i){return this._engine.joinRTCRoom(e,n,r,i)},t.prototype.quitRTCRoom=function(e){return this._engine.quitRTCRoom(e)},t.prototype.rtcPing=function(e,n,r){return this._engine.rtcPing(e,n,r)},t.prototype.getRTCRoomInfo=function(e){return this._engine.getRTCRoomInfo(e)},t.prototype.getRTCUserInfoList=function(e){return this._engine.getRTCUserInfoList(e)},t.prototype.getRTCUserInfo=function(e){return this._engine.getRTCUserInfo(e)},t.prototype.setRTCUserInfo=function(e,n,r){return this._engine.setRTCUserInfo(e,n,r)},t.prototype.removeRTCUserInfo=function(e,n){return this._engine.removeRTCUserInfo(e,n)},t.prototype.setRTCData=function(e,n,r,i,o,s){return this._engine.setRTCData(e,n,r,i,o,s)},t.prototype.setRTCTotalRes=function(e,n,r,i,o){return o===void 0&&(o=""),this._engine.setRTCTotalRes(e,n,r,i,o)},t.prototype.setRTCCDNUris=function(e,n,r){return this._engine.setRTCCDNUris(e,n,r)},t.prototype.getRTCData=function(e,n,r,i){return this._engine.getRTCData(e,n,r,i)},t.prototype.removeRTCData=function(e,n,r,i,o){return this._engine.removeRTCData(e,n,r,i,o)},t.prototype.setRTCOutData=function(e,n,r,i){return this._engine.setRTCOutData(e,n,r,i)},t.prototype.getRTCOutData=function(e,n){return this._engine.getRTCOutData(e,n)},t.prototype.getRTCToken=function(e,n,r){return this._engine.getRTCToken(e,n,r)},t.prototype.setRTCState=function(e,n){return this._engine.setRTCState(e,n)},t.prototype.getRTCUserList=function(e){return this._engine.getRTCUserList(e)},t.prototype.joinLivingRoomAsAudience=function(e,n,r){return this._engine.joinLivingRoomAsAudience(e,n,r)},t.prototype.quitLivingRoomAsAudience=function(e){return this._engine.quitLivingRoomAsAudience(e)},t.prototype.rtcIdentityChange=function(e,n,r){return this._engine.rtcIdentityChange(e,n,r)},t.prototype.getRTCJoinedUserInfo=function(e){return this._engine.getRTCJoinedUserInfo(e)},t.prototype.requestRoomPK=function(e){return this._engine.requestRoomPK(e)},t.prototype.cancelRoomPK=function(e){return this._engine.cancelRoomPK(e)},t.prototype.responseRoomPK=function(e){return this._engine.responseRoomPK(e)},t.prototype.endRoomPK=function(e){return this._engine.endRoomPK(e)},t}();(function(t){t[t.add=1]="add",t[t.update=2]="update",t[t.delete=3]="delete"})(ic||(ic={}));/*! *****************************************************************************
- Copyright (c) Microsoft Corporation.
- Permission to use, copy, modify, and/or distribute this software for any
- purpose with or without fee is hereby granted.
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- PERFORMANCE OF THIS SOFTWARE.
- ***************************************************************************** */var Ko=function(t,e){return Ko=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(n[i]=r[i])},Ko(t,e)},qo=function(){return qo=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},qo.apply(this,arguments)};function or(t,e,n,r){return new(n||(n=Promise))(function(i,o){function s(l){try{d(r.next(l))}catch(h){o(h)}}function c(l){try{d(r.throw(l))}catch(h){o(h)}}function d(l){var h;l.done?i(l.value):(h=l.value,h instanceof n?h:new n(function(a){a(h)})).then(s,c)}d((r=r.apply(t,e||[])).next())})}function sr(t,e){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function c(d){return function(l){return function(h){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=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 s.label++,{value:h[1],done:!1};case 5:s.label++,r=h[1],h=[0];continue;case 7:h=s.ops.pop(),s.trys.pop();continue;default:if(i=s.trys,!((i=i.length>0&&i[i.length-1])||h[0]!==6&&h[0]!==2)){s=0;continue}if(h[0]===3&&(!i||h[1]>i[0]&&h[1]<i[3])){s.label=h[1];break}if(h[0]===6&&s.label<i[1]){s.label=i[1],i=h;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(h);break}i[2]&&s.ops.pop(),s.trys.pop();continue}h=e.call(t,s)}catch(a){h=[6,a],r=0}finally{n=i=0}if(5&h[0])throw h[1];return{value:h[0]?h[1]:void 0,done:!0}}([d,l])}}}var We=new Ht("RCIM"),lr=function(){return!(typeof uni=="undefined"||!function(t){for(var e=["canIUse","getSystemInfo"],n=0,r=e.length;n<r;n++)if(!t[e[n]])return!1;return!0}(uni))},Zh=lr(),Ae,oc={tag:"browser",httpReq:function(t){var e=t.method||_t.GET,n=t.timeout||6e4,r=t.headers,i=t.query,o=t.body,s=Si(t.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,s),r&&l.setRequestHeader)for(var a in r)l.setRequestHeader(a,r[a]);if(h){l.timeout=n,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 o=="object"?JSON.stringify(o):o;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})},n),l.send(o)})},localStorage:window==null?void 0:window.localStorage,sessionStorage:window==null?void 0:window.sessionStorage,isSupportSocket:function(){var t=typeof WebSocket!="undefined";return t||We.warn("websocket not support"),t},useNavi:!0,connectPlatform:"",isFromUniapp:Zh,createWebSocket:function(t,e){var n=new WebSocket(t,e);return n.binaryType="arraybuffer",{onClose:function(r){n.onclose=function(i){var o=i.code,s=i.reason;r(o,s)}},onError:function(r){n.onerror=r},onMessage:function(r){n.onmessage=function(i){r(i.data)}},onOpen:function(r){n.onopen=r},send:function(r){n.send(r)},close:function(r,i){n.close(r,i)}}},createDataChannel:function(t,e){return this.isSupportSocket()&&e==="websocket"?new Sn(this,t):new In(this,t)}},ef=lr(),Ir=function(t){return function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];try{return wx[t].apply(wx,e)}catch(r){We.error(r)}}},sc={setItem:Ir("setStorageSync"),getItem:Ir("getStorageSync"),removeItem:Ir("removeStorageSync"),clear:Ir("clearStorageSync")},ac={tag:"wechat",httpReq:function(t){var e=t.method||_t.GET,n=t.timeout||6e4,r=t.headers,i=t.query,o=t.body,s=Si(t.url,i);return new Promise(function(c){wx.request({url:s,method:e,headers:r,timeout:n,data:o,success:function(d){c({data:d.data,status:d.statusCode})},fail:function(){c({status:O.RC_HTTP_REQ_TIMEOUT})}})})},localStorage:sc,sessionStorage:sc,isSupportSocket:function(){return!0},useNavi:!1,connectPlatform:"MiniProgram",isFromUniapp:ef,createWebSocket:function(t,e){var n=wx.connectSocket({url:t,protocols:e});return{onClose:function(r){n.onClose(function(i){r(i.code,i.reason)})},onError:function(r){n.onError(function(i){r(i.errMsg)})},onMessage:function(r){n.onMessage(function(i){r(i.data)})},onOpen:function(r){n.onOpen(r)},send:function(r){n.send({data:r})},close:function(r,i){n.close({code:r,reason:i})}}},createDataChannel:function(t,e){return e==="websocket"?new Sn(this,t):new In(this,t)}},tf=lr(),br=function(t){return function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];try{return my[t].apply(my,e)}catch(r){We.error(r)}}},cc={setItem:br("setStorageSync"),getItem:br("getStorageSync"),removeItem:br("removeStorageSync"),clear:br("clearStorageSync")},uc={tag:"alipay",httpReq:function(t){var e=t.method||_t.GET,n=t.timeout||6e4,r=t.headers,i=t.query,o=t.body,s=Si(t.url,i),c=t.dataType||"json";return new Promise(function(d){my.request({url:s,method:e,headers:r,timeout:n,data:o,dataType:c,success:function(l){d({data:l.data,status:l.status})},fail:function(){d({status:O.RC_HTTP_REQ_TIMEOUT})}})})},localStorage:cc,sessionStorage:cc,isSupportSocket:function(){return!1},useNavi:!1,connectPlatform:"MiniProgram",isFromUniapp:tf,createDataChannel:function(t,e){return e==="websocket"?new Sn(this,t):new In(this,t)}},nf=lr(),wr=function(t){return function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];try{return console.log("tt",tt),tt[t].apply(tt,e)}catch(r){We.error(r)}}},dc={setItem:wr("setStorageSync"),getItem:wr("getStorageSync"),removeItem:wr("removeStorageSync"),clear:wr("clearStorageSync")},lc={tag:"toutiao",isSupportSocket:function(){return!0},useNavi:!1,connectPlatform:"MiniProgram",isFromUniapp:nf,localStorage:dc,sessionStorage:dc,httpReq:function(t){return new Promise(function(e,n){tt.request({url:t.url,data:t.body,header:t.headers,method:t.method,success:function(r){console.log("\u8C03\u7528\u6210\u529F",r.data);var i=(r==null?void 0:r.data)||{},o={data:JSON.stringify(i),status:r.statusCode};e(o)},fail:function(r){console.log("\u8C03\u7528\u5931\u8D25",r.errMsg),n({data:r.errMsg})}})})},createWebSocket:function(t,e){var n=tt.connectSocket({url:t,protocols:e});return{onOpen:function(r){n.onOpen(r)},onClose:function(r){n.onClose(function(i){return r(i.code,i.reason)})},onError:function(r){n.onError(function(i){return r(i.errMsg)})},onMessage:function(r){n.onMessage(function(i){return r(i.data)})},send:function(r){n.send({data:r})},close:function(r,i){n.close({code:r,reason:i})}}},createDataChannel:function(t,e){return e==="websocket"?new Sn(this,t):new In(this,t)}},rf=lr(),Or=function(t){return function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];try{return console.log("swan",swan),swan[t].apply(swan,e)}catch(r){We.error(r)}}},hc={setItem:Or("setStorageSync"),getItem:Or("getStorageSync"),removeItem:Or("removeStorageSync"),clear:Or("clearStorageSync")},fc={tag:"baidu",isSupportSocket:function(){return!0},useNavi:!1,connectPlatform:"MiniProgram",isFromUniapp:rf,localStorage:hc,sessionStorage:hc,httpReq:function(t){return new Promise(function(e,n){swan.request({url:t.url,data:t.body,header:t.headers,method:t.method,success:function(r){console.log("\u8C03\u7528\u6210\u529F",r.data);var i=(r==null?void 0:r.data)||{},o={data:JSON.stringify(i),status:r.statusCode};e(o)},fail:function(r){console.log("\u8C03\u7528\u5931\u8D25",r.errorCode),n({data:r.errorCode})}})})},createWebSocket:function(t,e){var n=swan.connectSocket({url:t,protocols:e});return{onOpen:function(r){n.onOpen(r)},onClose:function(r){n.onClose(function(i){return r(i.code,i.reason)})},onError:function(r){n.onError(function(i){return r(i.errMsg)})},onMessage:function(r){n.onMessage(function(i){return r(i.data)})},send:function(r){n.send({data:r})},close:function(r,i){n.close({code:r,reason:i})}}},createDataChannel:function(t,e){return e==="websocket"?new Sn(this,t):new In(this,t)}},Nr=function(t){return function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];try{return uni[t].apply(uni,e)}catch(r){We.error(r)}}},pc={setItem:Nr("setStorageSync"),getItem:Nr("getStorageSync"),removeItem:Nr("removeStorageSync"),clear:Nr("clearStorageSync")},of={tag:"uniapp",httpReq:function(t){var e=t.method||_t.GET,n=t.timeout||6e4,r=t.headers,i=t.query,o=t.body,s=Si(t.url,i);return new Promise(function(c){uni.request({url:s,method:e,headers:r,timeout:n,data:o,success:function(d){c({data:d.data,status:d.statusCode})},fail:function(){c({status:O.RC_HTTP_REQ_TIMEOUT})}})})},localStorage:pc,sessionStorage:pc,isSupportSocket:function(){return!0},useNavi:!0,connectPlatform:"",isFromUniapp:!0,createWebSocket:function(t,e){var n={complete:function(){},url:t,protocols:e},r=uni.connectSocket(n);return{onClose:function(i){r.onClose(function(o){i(o.code,o.reason)})},onError:function(i){r.onError(function(o){i(o.errMsg)})},onMessage:function(i){r.onMessage(function(o){i(o.data)})},onOpen:function(i){r.onOpen(i)},send:function(i){r.send({data:i})},close:function(i,o){r.close({code:i,reason:o})}}},createDataChannel:function(t,e){return e==="websocket"?new Sn(this,t):new In(this,t)}},Bn=function(t){return t&&t.canIUse&&t.getSystemInfo},sf=typeof uni!="undefined"&&Bn(uni)?function(){switch({}.VUE_APP_PLATFORM){case"app-plus":return of;case"mp-baidu":return fc;case"mp-toutiao":return lc;case"mp-alipay":return uc;case"mp-weixin":return ac;default:return oc}}():typeof wx!="undefined"&&Bn(wx)?ac:typeof my!="undefined"&&Bn(my)?uc:typeof tt!="undefined"&&Bn(tt)?lc:typeof swan!="undefined"&&Bn(swan)?fc:oc;function si(t){var e=t.conversationType,n=t.channelId,r=t.messageType,i=t.content,o=t.senderUserId,s=t.targetId,c=t.sentTime,d=t.receivedTime,l=t.messageUId,h=t.messageDirection,a=t.isPersited,u=t.isCounted,f=t.isOffLineMessage,p=t.canIncludeExpansion,m=t.expansion,_=t.receivedStatus,v=t.disableNotification,y=t.isMentioned,C=t.isStatusMessage,b=t.readReceiptInfo,N=t.pushConfig,S=t.messageId;return _||(_=Qn.UNREAD),{messageType:r,channelId:n||"",content:i,senderUserId:o,targetId:s,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:N,messageId:S}}(function(t){t.CONNECTING="CONNECTING",t.CONNECTED="CONNECTED",t.DISCONNECT="DISCONNECT",t.SUSPEND="SUSPEND",t.MESSAGES="MESSAGES",t.READ_RECEIPT_RECEIVED="READ_RECEIPT_RECEIVED",t.MESSAGE_RECEIPT_REQUEST="MESSAGE_RECEIPT_REQUEST",t.MESSAGE_RECEIPT_RESPONSE="MESSAGE_RECEIPT_RESPONSE",t.CONVERSATION="CONVERSATION",t.CHATROOM="CHATROOM",t.EXPANSION="EXPANSION",t.PULL_OFFLINE_MESSAGE_FINISHED="PULL_OFFLINE_MESSAGE_FINISHED",t.TAG="TAG",t.CONVERSATION_TAG="CONVERSATION_TAG",t.TYPING_STATUS="TYPING_STATUS",t.MESSAGE_BLOCKED="MESSAGE_BLOCKED"})(Ae||(Ae={}));var pn,ht=function(t){function e(n){var r=t.call(this)||this;if(e.imClient)return We.error("Please do not repeatedly perform the init method"),e.imClient;Be("options.navigators",n.navigators,function(o){return Qe(o)&&(o.length===0||o.every(Xn))});var i=n==null?void 0:n.connectType;return i?Lt.WEBSOCKET!==i&&Lt.COMET!==i&&(We.warn("RongIMLib connectionType must be "+Lt.WEBSOCKET+" or "+Lt.COMET),i=Lt.WEBSOCKET):i=Lt.WEBSOCKET,r._context=Xh.init(sf,{appkey:n.appkey,apiVersion:"5.1.1",navigators:n.navigators||[],miniCMPProxy:n.customCMP||[],connectionType:i,logLevel:n.logLevel,logStdout:n.logStdout,indexDBSwitch:n.indexDBSwitch,checkCA:n.checkCA}),r.watch(),e.imClient=r,r}return function(n,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=n}Ko(n,r),n.prototype=r===null?Object.create(r):(i.prototype=r.prototype,new i)}(e,t),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 n=this,r={onConnecting:function(){n.emit(Ae.CONNECTING)},onConnected:function(){n.emit(Ae.CONNECTED)},onDisconnect:function(){n.emit(Ae.DISCONNECT)},onSuspend:function(){n.emit(Ae.SUSPEND)},batchMessage:function(i){n.emit(Ae.MESSAGES,{messages:i.map(function(o){return si(o)})})},typingState:function(i){n.emit(Ae.TYPING_STATUS,{status:i})},readReceiptReceived:function(i,o,s){n.emit(Ae.READ_RECEIPT_RECEIVED,{conversation:i,messageUId:o,sentTime:s})},messageReceiptRequest:function(i,o,s){n.emit(Ae.MESSAGE_RECEIPT_REQUEST,{conversation:i,messageUId:o,senderUserId:s})},messageReceiptResponse:function(i,o,s){n.emit(Ae.MESSAGE_RECEIPT_RESPONSE,{conversation:i,receivedUserId:o,messageUIdList:s})},conversationState:function(i){var o=i.map(function(s){return{conversation:{conversationType:s.conversationType,latestMessage:s.latestMessage?si(s.latestMessage):null,targetId:s.targetId,unreadMessageCount:s.unreadMessageCount,hasMentioned:s.hasMentioned,mentionedInfo:s.mentionedInfo,lastUnreadTime:s.lastUnreadTime,notificationStatus:s.notificationStatus,isTop:s.isTop,channelId:s.channelId,unreadMentionedCount:s.unreadMentionedCount},updatedItems:s.updatedItems}});n.emit(Ae.CONVERSATION,{conversationList:o})},chatroomState:function(i){n.emit(Ae.CHATROOM,i)},expansion:function(i){n.emit(Ae.EXPANSION,i)},pullFinished:function(){n.emit(Ae.PULL_OFFLINE_MESSAGE_FINISHED)},tag:function(){n.emit(Ae.TAG)},conversationTagChanged:function(){n.emit(Ae.CONVERSATION_TAG)},messageBlocked:function(i){n.emit(Ae.MESSAGE_BLOCKED,i)}};this.context.assignWatcher(r)},e}(cr),ai={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:O.NOT_SUPPORT,msg:"The method is not supported in a browser!"}},gn={},af={};for(var gc in ai){var mc=ai[gc],_c=mc.code;gn[_c]=gc,af[_c]=mc}ai.ROAMING_SERVICE_UNAVAILABLE.code;var cf=function(t){pn=pn||new ht(t)};function uf(t,e){return pn==null?void 0:pn.context.install(t,e)}function df(t){return or(this,void 0,void 0,function(){var e;return sr(this,function(n){switch(n.label){case 0:return Be("token",t,Le.STRING,!0),We.warn("RongIMLib Version: 5.1.1, Commit: 756868a83166be55e30e49e5685b1644456ea30f"),[4,pn.context.connect(t,!0)];case 1:return(e=n.sent()).code===O.SUCCESS?[2,{code:e.code,data:{userId:e.userId}}]:[2,{code:e.code,msg:gn[e.code]}]}})})}function hr(t,e,n){pn.on(t,e,n)}function lf(t,e){return or(this,void 0,void 0,function(){var n,r;return sr(this,function(i){switch(i.label){case 0:return Be("options.count",e.count,Le.NUMBER,!0),n="id:"+t,We.debug("join chatroom ->"+n),[4,ht.imClient.context.joinChatroom(t,e.count)];case 1:return(r=i.sent())!==O.SUCCESS?(We.warn("join chatroom fail ->code+:"+gn[r]+","+n),[2,{code:r,msg:gn[r]}]):[2,{code:r}]}})})}var qu=function(t,e,n,r){n===void 0&&(n=!0),r===void 0&&(r=!0),this.messageType=t,this.content=e,this.isPersited=n,this.isCounted=r};function dt(t,e,n){return e===void 0&&(e=!0),n===void 0&&(n=!0),function(r){return new qu(t,r,e,n)}}var Gu,Go,hf=dt("RC:ImgMsg"),ff=dt("RC:HQVCMsg"),pf=dt("RC:SightMsg"),gf=dt("RC:TxtMsg"),mf=dt("RC:CombineMsg"),_f=dt("RC:FileMsg");dt("RC:GIFMsg");dt("RC:VcMsg");dt("RC:LBSMsg");dt("RC:ReferenceMsg");dt("RC:ImgTextMsg");var rn={qiniu:function(t,e,n,r){var i,o="https://"+e.uploadHost.qiniu;i=Vn()+ve[0][1]||o,ve.shift();var s=new XMLHttpRequest;s.upload&&e.support_options&&(s.upload.onprogress=function(c){n.onProgress(c.loaded,c.total)}),s.onreadystatechange=function(){if(s.readyState===4){var c=s.responseText||"{}";(c=JSON.parse(c)).filename=e.uniqueValue,c.uploadMethod=ze?ze.QINIU:"",s.status===200?n.onCompleted(c):ve.length?rn[ve[0][0]](t,e,n,r):n.onError("upload fail")}},e.isChunk&&(i=function(c,d){var l="";return yc(d,function(h,a){h!=="token"&&(l+=(l?"&":"")+encodeURIComponent(h)+"="+encodeURIComponent(a))}),l&&(c+=(c.indexOf("?")>0?"&":"?")+l),c}(i+="/mkblk/"+t.size,e.multi_parmas)),s.open(e.method,i,!0),n.onOpen(s),e.stream&&s.setRequestHeader("authorization","UpToken "+e.multi_parmas.token),yc(e.headers,function(c,d){s.setRequestHeader(c,d)}),s.send(t)},baidu:function(t,e,n,r){if(console.log(r,e),r.size>vc)throw new Error("the file size is over 5GB!");var i=e||{};e=e||Go;var o=new XMLHttpRequest,s=Vn();if(!(!i.uploadHost.bos&&!i.bosUploadPath)){var c=s+ve[0][1]+i.bosUploadPath;ve.shift();var d=i.bosHeader||{},l={filename:e.uniqueValue||r.uniqueName,name:r.name,downloadUrl:c,isBosRes:!0};o.upload&&e.support_options&&(o.upload.onprogress=function(h){n.onProgress(h.loaded,h.total,!0)}),o.onreadystatechange=function(){if(o.readyState===4){var h=o.responseText||"{}";(h=JSON.parse(h)).filename=e.uniqueValue,o.status===200?n.onCompleted(l,!0):ve.length?rn[ve[0][0]](t,e,n,r):n.onError("upload fail")}},o.open(e.method,c,!0),o.setRequestHeader("authorization",d.bosToken),o.setRequestHeader("x-bce-date",d.bosDate),o.send(r)}},aliyun:function(t,e,n,r){if(r.size>vc)throw new Error("the file size is over 5GB!");const i=new FormData;i.set("file",t.get("file")),i.set("key",t.get("key")),i.set("token",t.get("token"));const o=ve[0][1];ve.shift(),t=t||Gu,e=(e=e||{})||Go;var s=new XMLHttpRequest,c=Vn()+e.ossBucketName+"."+o;s.upload&&e.support_options&&(s.upload.onprogress=function(l){n.onProgress(l.loaded,l.total)}),s.onreadystatechange=function(){if(s.readyState===4){var l=s.responseText||"{}";(l=JSON.parse(l)).name=e.uniqueValue,l.filename=e.uploadFileName,l.uploadMethod=ze?ze.ALI:"",s.status===200?n.onCompleted(l):ve.length?rn[ve[0][0]](i,e,n,r):n.onError("upload fail")}},s.open(e.method,c,!0),console.log("ali:url",c);var d=e.aliHeader||{};t.set("OSSAccessKeyId",d.osskeyId),t.set("policy",d.ossPolicy),t.set("Signature",d.ossSign),t.set("success_action_status",200),t.delete("key"),t.append("key",e.uploadFileName),t.delete("file"),t.append("file",r),s.send(t)},s3:function(t,e,n,r){var i=new FormData,o=new XMLHttpRequest,s=Vn();const c=ve[0][1];var d=s+e.s3BucketName+"."+c;console.log("uploadS3:url",d),ve.shift(),o.upload&&e.support_options&&(o.upload.onprogress=function(a){n.onProgress(a.loaded,a.total)}),o.onreadystatechange=function(){if(o.readyState===4){var a=o.responseText||"{}";if((a=JSON.parse(a)).name=e.uniqueValue,a.filename=e.uploadFileName,a.uploadMethod=ze.AWS,console.log("UploadMethod:",ze),o.status===200||o.status===204)n.onCompleted(a);else if(ve.length){const u=new FormData;u.set("file",t.get("file")),u.set("key",t.get("key")),u.set("token",t.get("token")),rn[ve[0][0]](u,e,n,r)}else n.onError("upload fail")}},o.open(e.method,d,!0);var l=e?e.s3Header:{},h=r&&r.type;h==="text/html"?i.set("Content-Disposition","inline;"):i.set("Content-Disposition","attachment;"),i.set("Content-Type",h),i.set("x-amz-credential",l.s3Credential),i.set("x-amz-algorithm",l.s3Algorithm),i.set("x-amz-date",l.s3Date),i.set("policy",l.s3Policy),i.set("x-amz-signature",l.s3Signature),i.set("key",e.uploadFileName),i.set("file",r),o.send(i)},stc:function(t,e,n,r){new FormData;var i=new XMLHttpRequest;Vn();var o="https://"+ve[0][1]+"/"+e.stcBucketName+"/"+e.uploadFileName;ve.shift(),i.upload&&e.support_options&&(i.upload.onprogress=function(c){n.onProgress(c.loaded,c.total)}),i.onreadystatechange=function(){if(i.readyState===4){var c=i.responseText||"{}";if((c=JSON.parse(c)).name=e.uniqueValue,c.filename=e.uploadFileName,c.uploadMethod=ze?ze.STC:"",i.status===200||i.status===204)n.onCompleted(c);else if(ve.length){const d=new FormData;d.set("file",t.get("file")),d.set("key",t.get("key")),d.set("token",t.get("token")),rn[ve[0][0]](d,e,n,r)}else n.onError("upload fail")}},i.open("PUT",o,!0);var s=e?e.stcHeader:{};i.setRequestHeader("Content-Type",r.type),r.type==="text/html"?i.setRequestHeader("Content-Disposition","inline;"):i.setRequestHeader("Content-Disposition","attachment;"),i.setRequestHeader("Authorization",s.stcAuthorization),i.setRequestHeader("x-amz-content-sha256",s.stcContentSha256),i.setRequestHeader("x-amz-date",s.stcDate),i.send(r)}},ve=[],vc=5368709120;function yc(t,e){for(var n in t)e(n,t[n])}function Vn(){var t="https://";return location.protocol!=="http:"&&location.protocol!=="file:"||(t="http://"),t}function vf(t,e,n){var r,i,o=t&&t.type||"text/plain",s=o.indexOf("image")>-1?1:4,c=Math.ceil(t.size/e.stc_chunk_size),d=e&&JSON.parse(e.ossConfig?e.ossConfig:"");Array.isArray(d)||(d=[]);var l=d.find(m=>Object.keys(m).includes("stc")),h="uploads";ht.imClient.getFileToken(s,r,"POST",h).then(function(m){r=m.fileName,i="https://"+l.stc+"/"+e.stcBucketName+"/"+r,console.log("uploadStcMultipart:url",i);var _=new XMLHttpRequest;_.open("POST",i+"?"+h,!0),o==="text/html"?_.setRequestHeader("Content-Disposition","inline;"):_.setRequestHeader("Content-Disposition","attacshment;"),_.setRequestHeader("Authorization",m&&m.stcAuthorization),_.setRequestHeader("x-amz-content-sha256",m&&m.stcContentSha256),_.setRequestHeader("x-amz-date",m&&m.stcDate),_.setRequestHeader("Content-Type",o),_.send(),_.onreadystatechange=function(v){if(_.readyState===4){var y=_.response.match(/(?:<UploadId>)(\S*?)(?:<\/UploadId>)/);console.log("uploadId",y),_.status===200||_.status===204?function(C){for(var b=[],N=1;N<=c;N++)b.push(p(C,N));f(C,b)}(Array.isArray(y)&&y[1]):n.onError("uploadStcMultipart:did not get uploadId")}}},function(m){n.onError("uploadStcMultipart:"+m)});var a=[],u=new Map;function f(m,_){_&&Array.isArray(_)&&_.length!==0&&Promise.all(_).then(()=>{var v="uploadId="+m;if(u.size===c)ht.imClient.context.getFileToken(s,r,"POST",v).then(function(b){console.log("onSuccess",b),console.log("onSuccess:uploadId",m);var N=new XMLHttpRequest;N.open("POST",i+"?"+v,!0),N.setRequestHeader("Authorization",b&&b.stcAuthorization),N.setRequestHeader("x-amz-content-sha256",b&&b.stcContentSha256),N.setRequestHeader("x-amz-date",b&&b.stcDate),N.setRequestHeader("Content-Type",o);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>",N.send(S),console.log("xml",S),N.onreadystatechange=function(){if(N.readyState===4)if(N.status===200||N.status===204){var w={};w.name=t.name,w.filename=e.uploadFileName,w.uploadMethod=ze.STC,n.onCompleted(w)}else n.onError("uploadStcMultipart:upload does not end")}},function(b){n.onError("uploadStcMultipart:"+b)});else{var y=[];for(var C of a)y.push(p(m,C));f(m,y)}},v=>{console.error(v),n.onError("uploadStcMultipart: chunkFiles upload failed and those will reupload");var y=[];for(var C of a)y.push(p(m,C));f(m,y)})}function p(m,_){return new Promise((v,y)=>{var C="partNumber="+_+"&uploadId="+m;ht.imClient.context.getFileToken(s,r,"PUT",C).then(function(b){console.log("signature "+_+" onSuccess",b);var N=t&&t.slice((_-1)*e.stc_chunk_size,_*e.stc_chunk_size);console.log("fileChunk:size",N.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",o),S.send(N),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 Yu={form:function(t,e){var n=new FormData;if(e.unique_key){var r=t.name.substr(t.name.lastIndexOf(".")),i=Yo()+r;n.append(e.unique_key,i),e.uniqueValue=i}return n.append(e.file_data_name,t),Jo(e.multi_parmas,function(o,s){n.append(o,s)}),n},json:function(t,e){var n={};if(e.unique_key){var r=t.name.substr(t.name.lastIndexOf(".")),i=Yo()+r;n[e.unique_key]=i,e.uniqueValue=i}return n[e.file_data_name]=t,Jo(e.multi_parmas,function(o,s){n[o]=s}),JSON.stringify(n)},data:function(t,e){return t}};function Yo(){var t=new Date().getTime();return"xxxxxx4xxxyxxxxxxx".replace(/[xy]/g,function(e){var n=(t+16*Math.random())%16|0;return t=Math.floor(t/16),(e==="x"?n:3&n|8).toString(16)})}function Jo(t,e){for(var n in t)e(n,t[n])}var Ar,io=0;function yf(t){this.options=function(e){var n={domain:"",method:"POST",file_data_name:"file",unique_key:"key",base64_size:4194304,chunk_size:4194304,bos_chunk_size:4294967296,stc_chunk_size:10485760,headers:{},multi_parmas:{},query:{},support_options:!0,data:Yu.form,genUId:Yo};if(!e||!e.domain)throw new Error("domain is null");for(var r in e)n[r]=e[r];return n}(t),this.setOptions=function(e){var n=this;Jo(e,function(r,i){n.options[r]=i})},console.log("options",t),this.upload=function(e,n){if(e){var r=this;(function(i,o,s){if(Gu=i,Go=o,ve=[],o.ossConfig){const h=JSON.parse(o.ossConfig);let a,u,f="";const p=[];h.forEach(m=>{const _=Number(m.p)-1;for(const v in m)v==="aliyun"&&(f=m[v]),v==="s3"&&(a=m[v]),v==="stc"&&(u=m[v]),v!=="p"&&(p[_]=[v,m[v]])}),p.forEach(function(m){m&&ve.push(m)}),h.length!==ve.length&&(ve=[["qiniu",o.domain],["baidu",o.uploadHost.bos],["aliyun",f],["s3",a],["stc",u]])}else ve=[["qiniu",o.domain],["baidu",o.uploadHost.bos]];var c;if(o.ossConfig){var d=o&&JSON.parse(o.ossConfig);Array.isArray(d)||(d=[]),c=d.find(h=>Object.keys(h).includes("stc"))}if(c&&parseInt(c.p)===1&&i.size>=4194304)vf(i,o,s);else{var l=o.data(i,o);rn[ve[0][0]](l,o,s,i)}})(e,this.options,{onProgress:function(i,o,s){Ar=i,s?Ar=io+i/o*(o-io):io=Ar,n.onProgress(Ar,o)},onCompleted:function(i){n.onCompleted(i)},onError:function(i){n.onError(i)},onOpen:function(i){r.xhr=i}})}else n.onError("upload file is null.")},this.cancel=function(){this.xhr&&this.xhr.abort()}}var Cc={init:function(t){return new yf(t)},dataType:Yu,resize:function(t,e,n){t.type;var r=document.createElement("canvas"),i=new FileReader;i.readAsDataURL(t),i.onload=function(o){var s=o.target.result,c=new Image;c.src=s;var d=c.width,l=c.height,h=function(u,f){var p=1,m=u.width,_=f.maxWidth||0;_>0&&m>_&&(p=_/m);var v=u.height,y=f.maxHeight||0;if(y>0&&v>y){var C=y/v;p=Math.min(p,C)}var b=f.maxSize||0,N=Math.ceil(u.size/1e3);if(N>b){var S=b/N;p=Math.min(p,S)}return p}({width:d,height:l,size:o.total},e),a=s;h<1&&(a=function(u,f,p){r.width=f,r.height=p,r.getContext("2d").drawImage(u,0,0,f,p);var m="image/jpg";return r.toDataURL(m)}(c,d*h,l*h)),n(a)}}};const Cf=function(t,e,n){var r=document.createElement("canvas"),i=r.getContext("2d"),o=new Image;o.onload=function(){var s=function(l,h,a){var u,f,p,m=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})}(o.width,o.height,e);r.width=s.w>e.maxWidth?e.maxWidth:s.w,r.height=s.h>e.maxHeight?e.maxHeight:s.h,i.drawImage(o,s.x,s.y,s.w,s.h);try{var c=r.toDataURL(t.type,e.quality),d=new RegExp("^data:image/[^;]+;base64,");c=c.replace(d,""),n(c)}catch(l){throw new Error(l)}},o.src=typeof t=="string"?"data:image/jpg;base64,"+t:function(s){var c=window.URL||window.webkitURL;return c?c.createObjectURL(s):""}(t)},Ef=function(t,e){var n=t.file,r=t.compress;Cf(n,r,e)},Ju=function(t,e){if(t.getToken)t.getToken(function(r,i){i=i||{},t.multi_parmas||(t.multi_parmas={}),t.multi_parmas.token=r,t.uploadHost||(t.uploadHost={}),t.uploadHost.bos=i.bos,t.ossConfig=i.ossConfig,t.bosHeader||(t.bosHeader={}),t.bosHeader.bosDate=i.bosDate,t.bosHeader.bosToken=i.bosToken,t.bosUploadPath=i.path,t.aliHeader={},t.aliHeader.osskeyId=i.osskeyId,t.aliHeader.ossPolicy=i.ossPolicy,t.aliHeader.ossSign=i.ossSign,t.ossBucketName=i.ossBucketName,t.uploadFileName=i.fileName,t.s3Header={},t.s3Header.s3Credential=i.s3Credential,t.s3Header.s3Algorithm=i.s3Algorithm,t.s3Header.s3Date=i.s3Date,t.s3Header.s3Policy=i.s3Policy,t.s3Header.s3Signature=i.s3Signature,t.s3BucketName=i.s3BucketName,t.stcHeader={},t.stcHeader.stcAuthorization=i.stcAuthorization,t.stcHeader.stcContentSha256=i.stcContentSha256,t.stcHeader.stcDate=i.stcDate,t.stcBucketName=i.stcBucketName,t.headers||(t.headers={}),t.base64&&(t.headers["Content-type"]="application/octet-stream",t.headers.Authorization="UpToken "+r),console.log("data",i);var o=Cc.init(t);e(o)});else{t.headers||(t.headers={}),t.base64&&(t.headers["Content-type"]="application/octet-stream");var n=Cc.init(t);e(n)}};var oo,Mr,Wu=function(t,e,n){e.upload(t.file,{onError:function(r){n.onError(r)},onProgress:function(r,i){n.onProgress(r,i)},onCompleted:function(r){r.filename||(r.filename=r.hash);var i=t.compressThumbnail||Ef;t.compress?i(t,function(o){r.thumbnail=o,n.onCompleted(r)}):n.onCompleted(r)}})},Rf=function(t){var e=this;this.instance=t,this.upload=function(n,r){Wu({file:n},e.instance,r)},this.cancel=function(){e.instance.cancel()}},Tf=function(t,e){var n=this;this.cfg=e,this.instance=t,this.upload=function(r,i){var o={file:r,compress:n.cfg};Wu(o,n.instance,i)},this.cancel=function(){n.instance.cancel()}},Sf=function(t,e){Ju(t,function(n){var r={maxHeight:t.maxHeight||160,maxWidth:t.maxWidth||160,quality:t.quality||.5,scale:t.scale||2.4},i=new Tf(n,r);e(i)})},If=function(t,e){Ju(t,function(n){var r=new Rf(n);e(r)})},bf=Sf;function Ec(t){return oo=oo||new AudioContext,new Promise(function(e,n){oo.decodeAudioData(t,function(r){e({duration:r.duration,length:r.length})},n)})}function wf(t,e,n,r,i){return Be("fileType",t,Ql,!0),Be("filename",e,Le.STRING),Be("saveName",n,Le.STRING),Be("serverType",i,Le.NUMBER),new Promise(function(o){ht.imClient.context.getFileUrl(t,e,n,r,i).then(function(s){o({code:O.SUCCESS,data:s})}).catch(function(s){o({code:s})})})}function zu(t,e,n){return or(this,void 0,void 0,function(){var r,i,o,s,c,d,l,h,a;return sr(this,function(u){switch(u.label){case 0:return n=n||{},e instanceof qu?(Be("conversation.channelId",t==null?void 0:t.channelId,Le.CHANNEL_ID),r=t.conversationType,i=t.targetId,o=t.channelId,s="conversationType:"+r+",targetId:"+i,We.debug("send message ->"+s),(c=Object.assign(n,e)).channelId=o||"",[4,ht.imClient.context.sendMessage(r,i,c)]):(We.warn("send message fail -> message parameter is not an instance of BaseMessage"),[2,ai.ILLGAL_PARAMS]);case 1:return d=u.sent(),l=d.code,h=d.data,l===O.SUCCESS?(a=si(h),[2,{code:l,data:a}]):(We.warn("send message fail ->"+l+":"+gn[l]+","+s),[2,{code:l,msg:gn[l],data:si({isMentioned:!!n.isMentioned,content:e.content,messageType:e.messageType,isPersited:e.isPersited||!1,isCounted:e.isCounted||!1,disableNotification:!!(n==null?void 0:n.disableNotification),canIncludeExpansion:!!(n==null?void 0:n.canIncludeExpansion),expansion:(n==null?void 0:n.expansion)||null,conversationType:r,targetId:i,channelId:o||"",senderUserId:ht.imClient.context.getCurrentUserId(),messageUId:"",messageDirection:ct.SEND,isOffLineMessage:!1,sentTime:(h==null?void 0:h.sentTime)||0,receivedTime:0,isStatusMessage:n.isStatusMessage||!1,receivedStatus:Qn.UNREAD})}])}})})}function fr(t,e){return function(n,r,i,o){return new Promise(function(s){var c;(function(d,l,h,a){var u,f=this;if(l===void 0&&(l=De.FILE),u=l===De.IMAGE?De.IMAGE:De.FILE,!Mr){Mr="upload.qiniup.com";var p=ht.imClient.context.getInfoFromCache();if(p&&p.ossConfig)try{var m=JSON.parse(p.ossConfig).find(function(v){return v.qiniu!==void 0});m&&(Mr=m.qiniu)}catch{}}var _=qo({domain:Mr,getToken:function(v){ht.imClient.context.getFileToken(u).then(function(y){v(y.token,y)}).catch(function(y){h.onFail(y)})}},a);(u===De.IMAGE?bf:If)(_,function(v){v.upload(d,{onProgress:function(y,C){var b,N=Math.floor(y/C*100);(b=h.onProgress)===null||b===void 0||b.call(h,N)},onCompleted:function(y){return or(f,void 0,void 0,function(){var C=this;return sr(this,function(b){return wf(u,y.filename,y.name,y,y.uploadMethod).then(function(N){return or(C,void 0,void 0,function(){var S,E;return sr(this,function(w){return N.code!==0?(h.onFail(N),[2]):((S=N.data).type=d.type,S.name=y.name||y.filename,l===De.AUDIO?(typeof d.arrayBuffer=="function"?d.arrayBuffer().then(Ec).then(function(V){Object.assign(S,V),h.onSuccess(S)},function(){h.onSuccess(S)}):((E=new FileReader).onload=function(){E.result?Ec(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===De.IMAGE&&(S.thumbnail=y.thumbnail),h.onSuccess(S),[2]))})})}).catch(function(N){h.onFail(N)}),[2]})})},onError:function(y){h.onFail(y)}})})})(r.file,t,{onProgress:i==null?void 0:i.onProgress,onSuccess:function(d){var l,h=((l=i==null?void 0:i.onComplete)===null||l===void 0?void 0:l.call(i,{url:d.downloadUrl}))||e(d,r);zu(n,h,o).then(s)},onFail:function(d){s({code:O.UPLOAD_FILE_FAILED,msg:d||O[O.UPLOAD_FILE_FAILED]})}},((c=o)===null||c===void 0?void 0:c.thumbnailConfig)||{})})}}fr(De.FILE,function(t,e){return new _f({name:t.name,size:e.file.size,type:e.file.type,fileUrl:t.downloadUrl,user:e.user,extra:e.extra})});fr(De.IMAGE,function(t,e){return new hf({content:t.thumbnail,imageUri:t.downloadUrl,user:e.user,extra:e.extra})});fr(De.AUDIO,function(t,e){return new ff({remoteUrl:t.downloadUrl,duration:t.duration,type:t.type,user:e.user,extra:e.extra})});fr(De.SIGHT,function(t,e){return new pf({sightUrl:t.downloadUrl,content:e.thumbnail,duration:e.duration,size:e.file.size||t.size,name:e.name||t.name,user:e.user,extra:e.extra})});function bn(t,e,n,r){return Be("messageType",t,Le.STRING,!0),Be("isPersited",e,Le.BOOLEAN,!0),Be("isCounted",n,Le.BOOLEAN,!0),ht.imClient.context.registerMessageType(t,e,n,r),dt(t,e,n)}fr(De.COMBINE_HTML,function(t,e){return new mf({remoteUrl:t.downloadUrl,nameList:e.nameList,summaryList:e.summaryList,conversationType:e.conversationType,user:e.user,extra:e.extra})});zt.add("imlib","5.1.1"),zt.validEngine("~5.1.1")||We.error("The current engine version '"+zt.getInfo().engine+"' error\uFF0Cimlib required engine version at least '~5.1.1'.");/*! *****************************************************************************
- Copyright (c) Microsoft Corporation.
- Permission to use, copy, modify, and/or distribute this software for any
- purpose with or without fee is hereby granted.
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- PERFORMANCE OF THIS SOFTWARE.
- ***************************************************************************** */function j(t,e,n,r){return new(n||(n=Promise))(function(i,o){function s(l){try{d(r.next(l))}catch(h){o(h)}}function c(l){try{d(r.throw(l))}catch(h){o(h)}}function d(l){var h;l.done?i(l.value):(h=l.value,h instanceof n?h:new n(function(a){a(h)})).then(s,c)}d((r=r.apply(t,e||[])).next())})}const P=new Ht("RCRTC");var M,Wo;(function(t){t[t.SUCCESS=1e4]="SUCCESS",t[t.SIGNAL_DISCONNECTED=5e4]="SIGNAL_DISCONNECTED",t[t.PARAMS_ERROR=50001]="PARAMS_ERROR",t[t.REPERT_JOIN_ROOM=50002]="REPERT_JOIN_ROOM",t[t.NOT_IN_ROOM=50003]="NOT_IN_ROOM",t[t.SERVICE_INVALID=50004]="SERVICE_INVALID",t[t.RTC_TOKEN_INVALID=50006]="RTC_TOKEN_INVALID",t[t.SIGNAL_ERROR=53001]="SIGNAL_ERROR",t[t.CREATE_OFFER_FAILED=53003]="CREATE_OFFER_FAILED",t[t.REQUEST_FAILED=53004]="REQUEST_FAILED",t[t.MCU_SERVER_NOT_FOUND=53005]="MCU_SERVER_NOT_FOUND",t[t.BROADCAST_SUB_LIST_NOT_EMPTY=53007]="BROADCAST_SUB_LIST_NOT_EMPTY",t[t.ROOM_HAS_BEEN_DESTROYED=53008]="ROOM_HAS_BEEN_DESTROYED",t[t.NOT_OPEN_VIDEO_AUDIO_SERVER=53009]="NOT_OPEN_VIDEO_AUDIO_SERVER",t[t.GET_USER_MEDIA_FAILED=53010]="GET_USER_MEDIA_FAILED",t[t.GET_DISPLAY_MEDIA_FAILED=53011]="GET_DISPLAY_MEDIA_FAILED",t[t.PERMISSION_DENIED=53012]="PERMISSION_DENIED",t[t.CREATE_CUSTOM_TRACK_FAILED=53013]="CREATE_CUSTOM_TRACK_FAILED",t[t.INVALID_TAGS=53014]="INVALID_TAGS",t[t.INVALID_USER_ID=53015]="INVALID_USER_ID",t[t.CREATE_FILE_TRACK_FAILED=53016]="CREATE_FILE_TRACK_FAILED",t[t.INVALID_FILE_INSTANCE=53017]="INVALID_FILE_INSTANCE",t[t.SET_REMOTE_DESCRIPTION_FAILED=53018]="SET_REMOTE_DESCRIPTION_FAILED",t[t.BROWSER_NOT_SUPPORT=53019]="BROWSER_NOT_SUPPORT",t[t.TRACK_NOT_READY=53020]="TRACK_NOT_READY",t[t.VIDEO_TRACK_MISS_MEDIA_ELEMENT=53021]="VIDEO_TRACK_MISS_MEDIA_ELEMENT",t[t.TRACK_PLAY_ERROR=53022]="TRACK_PLAY_ERROR",t[t.SIGNAL_AUDIENCE_JOIN_ROOM_FAILED=53023]="SIGNAL_AUDIENCE_JOIN_ROOM_FAILED",t[t.SIGNAL_ROOM_CHANGE_IDENTITY_FAILED=53024]="SIGNAL_ROOM_CHANGE_IDENTITY_FAILED",t[t.PACKAGE_ENVIRONMENT_ERROR=53025]="PACKAGE_ENVIRONMENT_ERROR",t[t.PUBLISH_TRACK_LIMIT_EXCEEDED=53026]="PUBLISH_TRACK_LIMIT_EXCEEDED",t[t.CDN_RESOURCE_IS_EMPTY=53027]="CDN_RESOURCE_IS_EMPTY",t[t.SIGNAL_JOIN_RTC_ROOM_REFUSED=53028]="SIGNAL_JOIN_RTC_ROOM_REFUSED",t[t.NO_PERMISSION_TO_USE_REQUESTED_DEVICE=53029]="NO_PERMISSION_TO_USE_REQUESTED_DEVICE",t[t.THE_FUNCTION_IS_DISABLED_IN_PKROOM=53030]="THE_FUNCTION_IS_DISABLED_IN_PKROOM"})(M||(M={})),function(t){t[t.JOIN_REFUSED=40032]="JOIN_REFUSED"}(Wo||(Wo={}));class Qu{constructor(){this.queue=[],this.locked=!1}checkToStart(){return j(this,void 0,void 0,function*(){if(this.queue.length===0||this.locked)return;this.locked=!0;const{resolve:e,task:n,reject:r}=this.queue.shift();let i;try{i=yield n(),e(i)}catch(o){r(o)}this.locked=!1,this.checkToStart()})}push(e){const n=new Promise((r,i)=>{this.queue.push({resolve:r,task:e,reject:i})});return this.checkToStart(),n}}const Of=new Qu,we=t=>Of.push(t);let Xu=!0,Zu=!0;function Fn(t,e,n){const r=t.match(e);return r&&r.length>=n&&parseInt(r[n],10)}function wn(t,e,n){if(!t.RTCPeerConnection)return;const r=t.RTCPeerConnection.prototype,i=r.addEventListener;r.addEventListener=function(s,c){if(s!==e)return i.apply(this,arguments);const d=l=>{const h=n(l);h&&(c.handleEvent?c.handleEvent(h):c(h))};return this._eventMap=this._eventMap||{},this._eventMap[e]||(this._eventMap[e]=new Map),this._eventMap[e].set(c,d),i.apply(this,[s,d])};const o=r.removeEventListener;r.removeEventListener=function(s,c){if(s!==e||!this._eventMap||!this._eventMap[e])return o.apply(this,arguments);if(!this._eventMap[e].has(c))return o.apply(this,arguments);const d=this._eventMap[e].get(c);return this._eventMap[e].delete(c),this._eventMap[e].size===0&&delete this._eventMap[e],Object.keys(this._eventMap).length===0&&delete this._eventMap,o.apply(this,[s,d])},Object.defineProperty(r,"on"+e,{get(){return this["_on"+e]},set(s){this["_on"+e]&&(this.removeEventListener(e,this["_on"+e]),delete this["_on"+e]),s&&this.addEventListener(e,this["_on"+e]=s)},enumerable:!0,configurable:!0})}function Nf(t){return typeof t!="boolean"?new Error("Argument type: "+typeof t+". Please use a boolean."):(Xu=t,t?"adapter.js logging disabled":"adapter.js logging enabled")}function Af(t){return typeof t!="boolean"?new Error("Argument type: "+typeof t+". Please use a boolean."):(Zu=!t,"adapter.js deprecation warnings "+(t?"disabled":"enabled"))}function ua(){if(typeof window=="object"){if(Xu)return;typeof console!="undefined"&&typeof console.log=="function"&&console.log.apply(console,arguments)}}function Di(t,e){Zu&&console.warn(t+" is deprecated, please use "+e+" instead.")}function Rc(t){return Object.prototype.toString.call(t)==="[object Object]"}function ed(t){return Rc(t)?Object.keys(t).reduce(function(e,n){const r=Rc(t[n]),i=r?ed(t[n]):t[n],o=r&&!Object.keys(i).length;return i===void 0||o?e:Object.assign(e,{[n]:i})},{}):t}function zo(t,e,n){e&&!n.has(e.id)&&(n.set(e.id,e),Object.keys(e).forEach(r=>{r.endsWith("Id")?zo(t,t.get(e[r]),n):r.endsWith("Ids")&&e[r].forEach(i=>{zo(t,t.get(i),n)})}))}function Tc(t,e,n){const r=n?"outbound-rtp":"inbound-rtp",i=new Map;if(e===null)return i;const o=[];return t.forEach(s=>{s.type==="track"&&s.trackIdentifier===e.id&&o.push(s)}),o.forEach(s=>{t.forEach(c=>{c.type===r&&c.trackId===s.id&&zo(t,c,i)})}),i}const Sc=ua;function td(t,e){const n=t&&t.navigator;if(!n.mediaDevices)return;const r=function(s){if(typeof s!="object"||s.mandatory||s.optional)return s;const c={};return Object.keys(s).forEach(d=>{if(d==="require"||d==="advanced"||d==="mediaSource")return;const l=typeof s[d]=="object"?s[d]:{ideal:s[d]};l.exact!==void 0&&typeof l.exact=="number"&&(l.min=l.max=l.exact);const h=function(a,u){return a?a+u.charAt(0).toUpperCase()+u.slice(1):u==="deviceId"?"sourceId":u};if(l.ideal!==void 0){c.optional=c.optional||[];let a={};typeof l.ideal=="number"?(a[h("min",d)]=l.ideal,c.optional.push(a),a={},a[h("max",d)]=l.ideal,c.optional.push(a)):(a[h("",d)]=l.ideal,c.optional.push(a))}l.exact!==void 0&&typeof l.exact!="number"?(c.mandatory=c.mandatory||{},c.mandatory[h("",d)]=l.exact):["min","max"].forEach(a=>{l[a]!==void 0&&(c.mandatory=c.mandatory||{},c.mandatory[h(a,d)]=l[a])})}),s.advanced&&(c.optional=(c.optional||[]).concat(s.advanced)),c},i=function(s,c){if(e.version>=61)return c(s);if((s=JSON.parse(JSON.stringify(s)))&&typeof s.audio=="object"){const d=function(l,h,a){h in l&&!(a in l)&&(l[a]=l[h],delete l[h])};d((s=JSON.parse(JSON.stringify(s))).audio,"autoGainControl","googAutoGainControl"),d(s.audio,"noiseSuppression","googNoiseSuppression"),s.audio=r(s.audio)}if(s&&typeof s.video=="object"){let d=s.video.facingMode;d=d&&(typeof d=="object"?d:{ideal:d});const l=e.version<66;if(d&&(d.exact==="user"||d.exact==="environment"||d.ideal==="user"||d.ideal==="environment")&&(!n.mediaDevices.getSupportedConstraints||!n.mediaDevices.getSupportedConstraints().facingMode||l)){let h;if(delete s.video.facingMode,d.exact==="environment"||d.ideal==="environment"?h=["back","rear"]:d.exact!=="user"&&d.ideal!=="user"||(h=["front"]),h)return n.mediaDevices.enumerateDevices().then(a=>{let u=(a=a.filter(f=>f.kind==="videoinput")).find(f=>h.some(p=>f.label.toLowerCase().includes(p)));return!u&&a.length&&h.includes("back")&&(u=a[a.length-1]),u&&(s.video.deviceId=d.exact?{exact:u.deviceId}:{ideal:u.deviceId}),s.video=r(s.video),Sc("chrome: "+JSON.stringify(s)),c(s)})}s.video=r(s.video)}return Sc("chrome: "+JSON.stringify(s)),c(s)},o=function(s){return e.version>=64?s:{name:{PermissionDeniedError:"NotAllowedError",PermissionDismissedError:"NotAllowedError",InvalidStateError:"NotAllowedError",DevicesNotFoundError:"NotFoundError",ConstraintNotSatisfiedError:"OverconstrainedError",TrackStartError:"NotReadableError",MediaDeviceFailedDueToShutdown:"NotAllowedError",MediaDeviceKillSwitchOn:"NotAllowedError",TabCaptureError:"AbortError",ScreenCaptureError:"AbortError",DeviceCaptureError:"AbortError"}[s.name]||s.name,message:s.message,constraint:s.constraint||s.constraintName,toString(){return this.name+(this.message&&": ")+this.message}}};if(n.getUserMedia=function(s,c,d){i(s,l=>{n.webkitGetUserMedia(l,c,h=>{d&&d(o(h))})})}.bind(n),n.mediaDevices.getUserMedia){const s=n.mediaDevices.getUserMedia.bind(n.mediaDevices);n.mediaDevices.getUserMedia=function(c){return i(c,d=>s(d).then(l=>{if(d.audio&&!l.getAudioTracks().length||d.video&&!l.getVideoTracks().length)throw l.getTracks().forEach(h=>{h.stop()}),new DOMException("","NotFoundError");return l},l=>Promise.reject(o(l))))}}}function nd(t){t.MediaStream=t.MediaStream||t.webkitMediaStream}function rd(t){if(typeof t=="object"&&t.RTCPeerConnection&&!("ontrack"in t.RTCPeerConnection.prototype)){Object.defineProperty(t.RTCPeerConnection.prototype,"ontrack",{get(){return this._ontrack},set(n){this._ontrack&&this.removeEventListener("track",this._ontrack),this.addEventListener("track",this._ontrack=n)},enumerable:!0,configurable:!0});const e=t.RTCPeerConnection.prototype.setRemoteDescription;t.RTCPeerConnection.prototype.setRemoteDescription=function(){return this._ontrackpoly||(this._ontrackpoly=n=>{n.stream.addEventListener("addtrack",r=>{let i;i=t.RTCPeerConnection.prototype.getReceivers?this.getReceivers().find(s=>s.track&&s.track.id===r.track.id):{track:r.track};const o=new Event("track");o.track=r.track,o.receiver=i,o.transceiver={receiver:i},o.streams=[n.stream],this.dispatchEvent(o)}),n.stream.getTracks().forEach(r=>{let i;i=t.RTCPeerConnection.prototype.getReceivers?this.getReceivers().find(s=>s.track&&s.track.id===r.id):{track:r};const o=new Event("track");o.track=r,o.receiver=i,o.transceiver={receiver:i},o.streams=[n.stream],this.dispatchEvent(o)})},this.addEventListener("addstream",this._ontrackpoly)),e.apply(this,arguments)}}else wn(t,"track",e=>(e.transceiver||Object.defineProperty(e,"transceiver",{value:{receiver:e.receiver}}),e))}function id(t){if(typeof t=="object"&&t.RTCPeerConnection&&!("getSenders"in t.RTCPeerConnection.prototype)&&"createDTMFSender"in t.RTCPeerConnection.prototype){const e=function(i,o){return{track:o,get dtmf(){return this._dtmf===void 0&&(o.kind==="audio"?this._dtmf=i.createDTMFSender(o):this._dtmf=null),this._dtmf},_pc:i}};if(!t.RTCPeerConnection.prototype.getSenders){t.RTCPeerConnection.prototype.getSenders=function(){return this._senders=this._senders||[],this._senders.slice()};const i=t.RTCPeerConnection.prototype.addTrack;t.RTCPeerConnection.prototype.addTrack=function(s,c){let d=i.apply(this,arguments);return d||(d=e(this,s),this._senders.push(d)),d};const o=t.RTCPeerConnection.prototype.removeTrack;t.RTCPeerConnection.prototype.removeTrack=function(s){o.apply(this,arguments);const c=this._senders.indexOf(s);c!==-1&&this._senders.splice(c,1)}}const n=t.RTCPeerConnection.prototype.addStream;t.RTCPeerConnection.prototype.addStream=function(i){this._senders=this._senders||[],n.apply(this,[i]),i.getTracks().forEach(o=>{this._senders.push(e(this,o))})};const r=t.RTCPeerConnection.prototype.removeStream;t.RTCPeerConnection.prototype.removeStream=function(i){this._senders=this._senders||[],r.apply(this,[i]),i.getTracks().forEach(o=>{const s=this._senders.find(c=>c.track===o);s&&this._senders.splice(this._senders.indexOf(s),1)})}}else if(typeof t=="object"&&t.RTCPeerConnection&&"getSenders"in t.RTCPeerConnection.prototype&&"createDTMFSender"in t.RTCPeerConnection.prototype&&t.RTCRtpSender&&!("dtmf"in t.RTCRtpSender.prototype)){const e=t.RTCPeerConnection.prototype.getSenders;t.RTCPeerConnection.prototype.getSenders=function(){const n=e.apply(this,[]);return n.forEach(r=>r._pc=this),n},Object.defineProperty(t.RTCRtpSender.prototype,"dtmf",{get(){return this._dtmf===void 0&&(this.track.kind==="audio"?this._dtmf=this._pc.createDTMFSender(this.track):this._dtmf=null),this._dtmf}})}}function od(t){if(!t.RTCPeerConnection)return;const e=t.RTCPeerConnection.prototype.getStats;t.RTCPeerConnection.prototype.getStats=function(){const[n,r,i]=arguments;if(arguments.length>0&&typeof n=="function")return e.apply(this,arguments);if(e.length===0&&(arguments.length===0||typeof n!="function"))return e.apply(this,[]);const o=function(c){const d={};return c.result().forEach(l=>{const h={id:l.id,timestamp:l.timestamp,type:{localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[l.type]||l.type};l.names().forEach(a=>{h[a]=l.stat(a)}),d[h.id]=h}),d},s=function(c){return new Map(Object.keys(c).map(d=>[d,c[d]]))};if(arguments.length>=2){const c=function(d){r(s(o(d)))};return e.apply(this,[c,n])}return new Promise((c,d)=>{e.apply(this,[function(l){c(s(o(l)))},d])}).then(r,i)}}function sd(t){if(!(typeof t=="object"&&t.RTCPeerConnection&&t.RTCRtpSender&&t.RTCRtpReceiver))return;if(!("getStats"in t.RTCRtpSender.prototype)){const n=t.RTCPeerConnection.prototype.getSenders;n&&(t.RTCPeerConnection.prototype.getSenders=function(){const i=n.apply(this,[]);return i.forEach(o=>o._pc=this),i});const r=t.RTCPeerConnection.prototype.addTrack;r&&(t.RTCPeerConnection.prototype.addTrack=function(){const i=r.apply(this,arguments);return i._pc=this,i}),t.RTCRtpSender.prototype.getStats=function(){const i=this;return this._pc.getStats().then(o=>Tc(o,i.track,!0))}}if(!("getStats"in t.RTCRtpReceiver.prototype)){const n=t.RTCPeerConnection.prototype.getReceivers;n&&(t.RTCPeerConnection.prototype.getReceivers=function(){const r=n.apply(this,[]);return r.forEach(i=>i._pc=this),r}),wn(t,"track",r=>(r.receiver._pc=r.srcElement,r)),t.RTCRtpReceiver.prototype.getStats=function(){const r=this;return this._pc.getStats().then(i=>Tc(i,r.track,!1))}}if(!("getStats"in t.RTCRtpSender.prototype)||!("getStats"in t.RTCRtpReceiver.prototype))return;const e=t.RTCPeerConnection.prototype.getStats;t.RTCPeerConnection.prototype.getStats=function(){if(arguments.length>0&&arguments[0]instanceof t.MediaStreamTrack){const n=arguments[0];let r,i,o;return this.getSenders().forEach(s=>{s.track===n&&(r?o=!0:r=s)}),this.getReceivers().forEach(s=>(s.track===n&&(i?o=!0:i=s),s.track===n)),o||r&&i?Promise.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):r?r.getStats():i?i.getStats():Promise.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return e.apply(this,arguments)}}function ad(t){t.RTCPeerConnection.prototype.getLocalStreams=function(){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},Object.keys(this._shimmedLocalStreams).map(o=>this._shimmedLocalStreams[o][0])};const e=t.RTCPeerConnection.prototype.addTrack;t.RTCPeerConnection.prototype.addTrack=function(o,s){if(!s)return e.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};const c=e.apply(this,arguments);return this._shimmedLocalStreams[s.id]?this._shimmedLocalStreams[s.id].indexOf(c)===-1&&this._shimmedLocalStreams[s.id].push(c):this._shimmedLocalStreams[s.id]=[s,c],c};const n=t.RTCPeerConnection.prototype.addStream;t.RTCPeerConnection.prototype.addStream=function(o){this._shimmedLocalStreams=this._shimmedLocalStreams||{},o.getTracks().forEach(d=>{if(this.getSenders().find(l=>l.track===d))throw new DOMException("Track already exists.","InvalidAccessError")});const s=this.getSenders();n.apply(this,arguments);const c=this.getSenders().filter(d=>s.indexOf(d)===-1);this._shimmedLocalStreams[o.id]=[o].concat(c)};const r=t.RTCPeerConnection.prototype.removeStream;t.RTCPeerConnection.prototype.removeStream=function(o){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},delete this._shimmedLocalStreams[o.id],r.apply(this,arguments)};const i=t.RTCPeerConnection.prototype.removeTrack;t.RTCPeerConnection.prototype.removeTrack=function(o){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},o&&Object.keys(this._shimmedLocalStreams).forEach(s=>{const c=this._shimmedLocalStreams[s].indexOf(o);c!==-1&&this._shimmedLocalStreams[s].splice(c,1),this._shimmedLocalStreams[s].length===1&&delete this._shimmedLocalStreams[s]}),i.apply(this,arguments)}}function cd(t,e){if(!t.RTCPeerConnection)return;if(t.RTCPeerConnection.prototype.addTrack&&e.version>=65)return ad(t);const n=t.RTCPeerConnection.prototype.getLocalStreams;t.RTCPeerConnection.prototype.getLocalStreams=function(){const l=n.apply(this);return this._reverseStreams=this._reverseStreams||{},l.map(h=>this._reverseStreams[h.id])};const r=t.RTCPeerConnection.prototype.addStream;t.RTCPeerConnection.prototype.addStream=function(l){if(this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},l.getTracks().forEach(h=>{if(this.getSenders().find(a=>a.track===h))throw new DOMException("Track already exists.","InvalidAccessError")}),!this._reverseStreams[l.id]){const h=new t.MediaStream(l.getTracks());this._streams[l.id]=h,this._reverseStreams[h.id]=l,l=h}r.apply(this,[l])};const i=t.RTCPeerConnection.prototype.removeStream;function o(l,h){let a=h.sdp;return Object.keys(l._reverseStreams||[]).forEach(u=>{const f=l._reverseStreams[u],p=l._streams[f.id];a=a.replace(new RegExp(p.id,"g"),f.id)}),new RTCSessionDescription({type:h.type,sdp:a})}function s(l,h){let a=h.sdp;return Object.keys(l._reverseStreams||[]).forEach(u=>{const f=l._reverseStreams[u],p=l._streams[f.id];a=a.replace(new RegExp(f.id,"g"),p.id)}),new RTCSessionDescription({type:h.type,sdp:a})}t.RTCPeerConnection.prototype.removeStream=function(l){this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},i.apply(this,[this._streams[l.id]||l]),delete this._reverseStreams[this._streams[l.id]?this._streams[l.id].id:l.id],delete this._streams[l.id]},t.RTCPeerConnection.prototype.addTrack=function(l,h){if(this.signalingState==="closed")throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");const a=[].slice.call(arguments,1);if(a.length!==1||!a[0].getTracks().find(p=>p===l))throw new DOMException("The adapter.js addTrack polyfill only supports a single stream which is associated with the specified track.","NotSupportedError");if(this.getSenders().find(p=>p.track===l))throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};const f=this._streams[h.id];if(f)f.addTrack(l),Promise.resolve().then(()=>{this.dispatchEvent(new Event("negotiationneeded"))});else{const p=new t.MediaStream([l]);this._streams[h.id]=p,this._reverseStreams[p.id]=h,this.addStream(p)}return this.getSenders().find(p=>p.track===l)},["createOffer","createAnswer"].forEach(function(l){const h=t.RTCPeerConnection.prototype[l],a={[l](){const u=arguments;return arguments.length&&typeof arguments[0]=="function"?h.apply(this,[f=>{const p=o(this,f);u[0].apply(null,[p])},f=>{u[1]&&u[1].apply(null,f)},arguments[2]]):h.apply(this,arguments).then(f=>o(this,f))}};t.RTCPeerConnection.prototype[l]=a[l]});const c=t.RTCPeerConnection.prototype.setLocalDescription;t.RTCPeerConnection.prototype.setLocalDescription=function(){return arguments.length&&arguments[0].type?(arguments[0]=s(this,arguments[0]),c.apply(this,arguments)):c.apply(this,arguments)};const d=Object.getOwnPropertyDescriptor(t.RTCPeerConnection.prototype,"localDescription");Object.defineProperty(t.RTCPeerConnection.prototype,"localDescription",{get(){const l=d.get.apply(this);return l.type===""?l:o(this,l)}}),t.RTCPeerConnection.prototype.removeTrack=function(l){if(this.signalingState==="closed")throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");if(!l._pc)throw new DOMException("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.","TypeError");if(l._pc!==this)throw new DOMException("Sender was not created by this connection.","InvalidAccessError");let h;this._streams=this._streams||{},Object.keys(this._streams).forEach(a=>{this._streams[a].getTracks().find(u=>l.track===u)&&(h=this._streams[a])}),h&&(h.getTracks().length===1?this.removeStream(this._reverseStreams[h.id]):h.removeTrack(l.track),this.dispatchEvent(new Event("negotiationneeded")))}}function Qo(t,e){!t.RTCPeerConnection&&t.webkitRTCPeerConnection&&(t.RTCPeerConnection=t.webkitRTCPeerConnection),t.RTCPeerConnection&&e.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(n){const r=t.RTCPeerConnection.prototype[n],i={[n](){return arguments[0]=new(n==="addIceCandidate"?t.RTCIceCandidate:t.RTCSessionDescription)(arguments[0]),r.apply(this,arguments)}};t.RTCPeerConnection.prototype[n]=i[n]})}function ud(t,e){wn(t,"negotiationneeded",n=>{const r=n.target;if(!(e.version<72||r.getConfiguration&&r.getConfiguration().sdpSemantics==="plan-b")||r.signalingState==="stable")return n})}var Ic=Object.freeze({__proto__:null,shimMediaStream:nd,shimOnTrack:rd,shimGetSendersWithDtmf:id,shimGetStats:od,shimSenderReceiverGetStats:sd,shimAddTrackRemoveTrackWithNative:ad,shimAddTrackRemoveTrack:cd,shimPeerConnection:Qo,fixNegotiationNeeded:ud,shimGetUserMedia:td,shimGetDisplayMedia:function(t,e){t.navigator.mediaDevices&&"getDisplayMedia"in t.navigator.mediaDevices||t.navigator.mediaDevices&&(typeof e=="function"?t.navigator.mediaDevices.getDisplayMedia=function(n){return e(n).then(r=>{const i=n.video&&n.video.width,o=n.video&&n.video.height,s=n.video&&n.video.frameRate;return n.video={mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:r,maxFrameRate:s||3}},i&&(n.video.mandatory.maxWidth=i),o&&(n.video.mandatory.maxHeight=o),t.navigator.mediaDevices.getUserMedia(n)})}:console.error("shimGetDisplayMedia: getSourceId argument is not a function"))}}),bc,so,oe=(bc=function(t){var e={generateIdentifier:function(){return Math.random().toString(36).substr(2,10)}};e.localCName=e.generateIdentifier(),e.splitLines=function(n){return n.trim().split(`
- `).map(function(r){return r.trim()})},e.splitSections=function(n){return n.split(`
- m=`).map(function(r,i){return(i>0?"m="+r:r).trim()+`\r
- `})},e.getDescription=function(n){var r=e.splitSections(n);return r&&r[0]},e.getMediaSections=function(n){var r=e.splitSections(n);return r.shift(),r},e.matchPrefix=function(n,r){return e.splitLines(n).filter(function(i){return i.indexOf(r)===0})},e.parseCandidate=function(n){for(var r,i={foundation:(r=n.indexOf("a=candidate:")===0?n.substring(12).split(" "):n.substring(10).split(" "))[0],component:parseInt(r[1],10),protocol:r[2].toLowerCase(),priority:parseInt(r[3],10),ip:r[4],address:r[4],port:parseInt(r[5],10),type:r[7]},o=8;o<r.length;o+=2)switch(r[o]){case"raddr":i.relatedAddress=r[o+1];break;case"rport":i.relatedPort=parseInt(r[o+1],10);break;case"tcptype":i.tcpType=r[o+1];break;case"ufrag":i.ufrag=r[o+1],i.usernameFragment=r[o+1];break;default:i[r[o]]=r[o+1]}return i},e.writeCandidate=function(n){var r=[];r.push(n.foundation),r.push(n.component),r.push(n.protocol.toUpperCase()),r.push(n.priority),r.push(n.address||n.ip),r.push(n.port);var i=n.type;return r.push("typ"),r.push(i),i!=="host"&&n.relatedAddress&&n.relatedPort&&(r.push("raddr"),r.push(n.relatedAddress),r.push("rport"),r.push(n.relatedPort)),n.tcpType&&n.protocol.toLowerCase()==="tcp"&&(r.push("tcptype"),r.push(n.tcpType)),(n.usernameFragment||n.ufrag)&&(r.push("ufrag"),r.push(n.usernameFragment||n.ufrag)),"candidate:"+r.join(" ")},e.parseIceOptions=function(n){return n.substr(14).split(" ")},e.parseRtpMap=function(n){var r=n.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(n){var r=n.payloadType;n.preferredPayloadType!==void 0&&(r=n.preferredPayloadType);var i=n.channels||n.numChannels||1;return"a=rtpmap:"+r+" "+n.name+"/"+n.clockRate+(i!==1?"/"+i:"")+`\r
- `},e.parseExtmap=function(n){var r=n.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(n){return"a=extmap:"+(n.id||n.preferredId)+(n.direction&&n.direction!=="sendrecv"?"/"+n.direction:"")+" "+n.uri+`\r
- `},e.parseFmtp=function(n){for(var r,i={},o=n.substr(n.indexOf(" ")+1).split(";"),s=0;s<o.length;s++)i[(r=o[s].trim().split("="))[0].trim()]=r[1];return i},e.writeFmtp=function(n){var r="",i=n.payloadType;if(n.preferredPayloadType!==void 0&&(i=n.preferredPayloadType),n.parameters&&Object.keys(n.parameters).length){var o=[];Object.keys(n.parameters).forEach(function(s){n.parameters[s]?o.push(s+"="+n.parameters[s]):o.push(s)}),r+="a=fmtp:"+i+" "+o.join(";")+`\r
- `}return r},e.parseRtcpFb=function(n){var r=n.substr(n.indexOf(" ")+1).split(" ");return{type:r.shift(),parameter:r.join(" ")}},e.writeRtcpFb=function(n){var r="",i=n.payloadType;return n.preferredPayloadType!==void 0&&(i=n.preferredPayloadType),n.rtcpFeedback&&n.rtcpFeedback.length&&n.rtcpFeedback.forEach(function(o){r+="a=rtcp-fb:"+i+" "+o.type+(o.parameter&&o.parameter.length?" "+o.parameter:"")+`\r
- `}),r},e.parseSsrcMedia=function(n){var r=n.indexOf(" "),i={ssrc:parseInt(n.substr(7,r-7),10)},o=n.indexOf(":",r);return o>-1?(i.attribute=n.substr(r+1,o-r-1),i.value=n.substr(o+1)):i.attribute=n.substr(r+1),i},e.parseSsrcGroup=function(n){var r=n.substr(13).split(" ");return{semantics:r.shift(),ssrcs:r.map(function(i){return parseInt(i,10)})}},e.getMid=function(n){var r=e.matchPrefix(n,"a=mid:")[0];if(r)return r.substr(6)},e.parseFingerprint=function(n){var r=n.substr(14).split(" ");return{algorithm:r[0].toLowerCase(),value:r[1]}},e.getDtlsParameters=function(n,r){return{role:"auto",fingerprints:e.matchPrefix(n+r,"a=fingerprint:").map(e.parseFingerprint)}},e.writeDtlsParameters=function(n,r){var i="a=setup:"+r+`\r
- `;return n.fingerprints.forEach(function(o){i+="a=fingerprint:"+o.algorithm+" "+o.value+`\r
- `}),i},e.parseCryptoLine=function(n){var r=n.substr(9).split(" ");return{tag:parseInt(r[0],10),cryptoSuite:r[1],keyParams:r[2],sessionParams:r.slice(3)}},e.writeCryptoLine=function(n){return"a=crypto:"+n.tag+" "+n.cryptoSuite+" "+(typeof n.keyParams=="object"?e.writeCryptoKeyParams(n.keyParams):n.keyParams)+(n.sessionParams?" "+n.sessionParams.join(" "):"")+`\r
- `},e.parseCryptoKeyParams=function(n){if(n.indexOf("inline:")!==0)return null;var r=n.substr(7).split("|");return{keyMethod:"inline",keySalt:r[0],lifeTime:r[1],mkiValue:r[2]?r[2].split(":")[0]:void 0,mkiLength:r[2]?r[2].split(":")[1]:void 0}},e.writeCryptoKeyParams=function(n){return n.keyMethod+":"+n.keySalt+(n.lifeTime?"|"+n.lifeTime:"")+(n.mkiValue&&n.mkiLength?"|"+n.mkiValue+":"+n.mkiLength:"")},e.getCryptoParameters=function(n,r){return e.matchPrefix(n+r,"a=crypto:").map(e.parseCryptoLine)},e.getIceParameters=function(n,r){var i=e.matchPrefix(n+r,"a=ice-ufrag:")[0],o=e.matchPrefix(n+r,"a=ice-pwd:")[0];return i&&o?{usernameFragment:i.substr(12),password:o.substr(10)}:null},e.writeIceParameters=function(n){return"a=ice-ufrag:"+n.usernameFragment+`\r
- a=ice-pwd:`+n.password+`\r
- `},e.parseRtpParameters=function(n){for(var r={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},i=e.splitLines(n)[0].split(" "),o=3;o<i.length;o++){var s=i[o],c=e.matchPrefix(n,"a=rtpmap:"+s+" ")[0];if(c){var d=e.parseRtpMap(c),l=e.matchPrefix(n,"a=fmtp:"+s+" ");switch(d.parameters=l.length?e.parseFmtp(l[0]):{},d.rtcpFeedback=e.matchPrefix(n,"a=rtcp-fb:"+s+" ").map(e.parseRtcpFb),r.codecs.push(d),d.name.toUpperCase()){case"RED":case"ULPFEC":r.fecMechanisms.push(d.name.toUpperCase())}}}return e.matchPrefix(n,"a=extmap:").forEach(function(h){r.headerExtensions.push(e.parseExtmap(h))}),r},e.writeRtpDescription=function(n,r){var i="";i+="m="+n+" ",i+=r.codecs.length>0?"9":"0",i+=" UDP/TLS/RTP/SAVPF ",i+=r.codecs.map(function(s){return s.preferredPayloadType!==void 0?s.preferredPayloadType:s.payloadType}).join(" ")+`\r
- `,i+=`c=IN IP4 0.0.0.0\r
- `,i+=`a=rtcp:9 IN IP4 0.0.0.0\r
- `,r.codecs.forEach(function(s){i+=e.writeRtpMap(s),i+=e.writeFmtp(s),i+=e.writeRtcpFb(s)});var o=0;return r.codecs.forEach(function(s){s.maxptime>o&&(o=s.maxptime)}),o>0&&(i+="a=maxptime:"+o+`\r
- `),i+=`a=rtcp-mux\r
- `,r.headerExtensions&&r.headerExtensions.forEach(function(s){i+=e.writeExtmap(s)}),i},e.parseRtpEncodingParameters=function(n){var r,i=[],o=e.parseRtpParameters(n),s=o.fecMechanisms.indexOf("RED")!==-1,c=o.fecMechanisms.indexOf("ULPFEC")!==-1,d=e.matchPrefix(n,"a=ssrc:").map(function(u){return e.parseSsrcMedia(u)}).filter(function(u){return u.attribute==="cname"}),l=d.length>0&&d[0].ssrc,h=e.matchPrefix(n,"a=ssrc-group:FID").map(function(u){return u.substr(17).split(" ").map(function(f){return parseInt(f,10)})});h.length>0&&h[0].length>1&&h[0][0]===l&&(r=h[0][1]),o.codecs.forEach(function(u){if(u.name.toUpperCase()==="RTX"&&u.parameters.apt){var f={ssrc:l,codecPayloadType:parseInt(u.parameters.apt,10)};l&&r&&(f.rtx={ssrc:r}),i.push(f),s&&((f=JSON.parse(JSON.stringify(f))).fec={ssrc:l,mechanism:c?"red+ulpfec":"red"},i.push(f))}}),i.length===0&&l&&i.push({ssrc:l});var a=e.matchPrefix(n,"b=");return a.length&&(a=a[0].indexOf("b=TIAS:")===0?parseInt(a[0].substr(7),10):a[0].indexOf("b=AS:")===0?1e3*parseInt(a[0].substr(5),10)*.95-16e3:void 0,i.forEach(function(u){u.maxBitrate=a})),i},e.parseRtcpParameters=function(n){var r={},i=e.matchPrefix(n,"a=ssrc:").map(function(c){return e.parseSsrcMedia(c)}).filter(function(c){return c.attribute==="cname"})[0];i&&(r.cname=i.value,r.ssrc=i.ssrc);var o=e.matchPrefix(n,"a=rtcp-rsize");r.reducedSize=o.length>0,r.compound=o.length===0;var s=e.matchPrefix(n,"a=rtcp-mux");return r.mux=s.length>0,r},e.parseMsid=function(n){var r,i=e.matchPrefix(n,"a=msid:");if(i.length===1)return{stream:(r=i[0].substr(7).split(" "))[0],track:r[1]};var o=e.matchPrefix(n,"a=ssrc:").map(function(s){return e.parseSsrcMedia(s)}).filter(function(s){return s.attribute==="msid"});return o.length>0?{stream:(r=o[0].value.split(" "))[0],track:r[1]}:void 0},e.parseSctpDescription=function(n){var r,i=e.parseMLine(n),o=e.matchPrefix(n,"a=max-message-size:");o.length>0&&(r=parseInt(o[0].substr(19),10)),isNaN(r)&&(r=65536);var s=e.matchPrefix(n,"a=sctp-port:");if(s.length>0)return{port:parseInt(s[0].substr(12),10),protocol:i.fmt,maxMessageSize:r};if(e.matchPrefix(n,"a=sctpmap:").length>0){var c=e.matchPrefix(n,"a=sctpmap:")[0].substr(10).split(" ");return{port:parseInt(c[0],10),protocol:c[1],maxMessageSize:r}}},e.writeSctpDescription=function(n,r){var i=[];return i=n.protocol!=="DTLS/SCTP"?["m="+n.kind+" 9 "+n.protocol+" "+r.protocol+`\r
- `,`c=IN IP4 0.0.0.0\r
- `,"a=sctp-port:"+r.port+`\r
- `]:["m="+n.kind+" 9 "+n.protocol+" "+r.port+`\r
- `,`c=IN IP4 0.0.0.0\r
- `,"a=sctpmap:"+r.port+" "+r.protocol+` 65535\r
- `],r.maxMessageSize!==void 0&&i.push("a=max-message-size:"+r.maxMessageSize+`\r
- `),i.join("")},e.generateSessionId=function(){return Math.random().toString().substr(2,21)},e.writeSessionBoilerplate=function(n,r,i){var o=r!==void 0?r:2;return`v=0\r
- o=`+(i||"thisisadapterortc")+" "+(n||e.generateSessionId())+" "+o+` IN IP4 127.0.0.1\r
- s=-\r
- t=0 0\r
- `},e.writeMediaSection=function(n,r,i,o){var s=e.writeRtpDescription(n.kind,r);if(s+=e.writeIceParameters(n.iceGatherer.getLocalParameters()),s+=e.writeDtlsParameters(n.dtlsTransport.getLocalParameters(),i==="offer"?"actpass":"active"),s+="a=mid:"+n.mid+`\r
- `,n.direction?s+="a="+n.direction+`\r
- `:n.rtpSender&&n.rtpReceiver?s+=`a=sendrecv\r
- `:n.rtpSender?s+=`a=sendonly\r
- `:n.rtpReceiver?s+=`a=recvonly\r
- `:s+=`a=inactive\r
- `,n.rtpSender){var c="msid:"+o.id+" "+n.rtpSender.track.id+`\r
- `;s+="a="+c,s+="a=ssrc:"+n.sendEncodingParameters[0].ssrc+" "+c,n.sendEncodingParameters[0].rtx&&(s+="a=ssrc:"+n.sendEncodingParameters[0].rtx.ssrc+" "+c,s+="a=ssrc-group:FID "+n.sendEncodingParameters[0].ssrc+" "+n.sendEncodingParameters[0].rtx.ssrc+`\r
- `)}return s+="a=ssrc:"+n.sendEncodingParameters[0].ssrc+" cname:"+e.localCName+`\r
- `,n.rtpSender&&n.sendEncodingParameters[0].rtx&&(s+="a=ssrc:"+n.sendEncodingParameters[0].rtx.ssrc+" cname:"+e.localCName+`\r
- `),s},e.getDirection=function(n,r){for(var i=e.splitLines(n),o=0;o<i.length;o++)switch(i[o]){case"a=sendrecv":case"a=sendonly":case"a=recvonly":case"a=inactive":return i[o].substr(2)}return r?e.getDirection(r):"sendrecv"},e.getKind=function(n){return e.splitLines(n)[0].split(" ")[0].substr(2)},e.isRejected=function(n){return n.split(" ",2)[1]==="0"},e.parseMLine=function(n){var r=e.splitLines(n)[0].substr(2).split(" ");return{kind:r[0],port:parseInt(r[1],10),protocol:r[2],fmt:r.slice(3).join(" ")}},e.parseOLine=function(n){var r=e.matchPrefix(n,"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(n){if(typeof n!="string"||n.length===0)return!1;for(var r=e.splitLines(n),i=0;i<r.length;i++)if(r[i].length<2||r[i].charAt(1)!=="=")return!1;return!0},t.exports=e},bc(so={exports:{}},so.exports),so.exports);function wc(t,e,n,r,i){var o=oe.writeRtpDescription(t.kind,e);if(o+=oe.writeIceParameters(t.iceGatherer.getLocalParameters()),o+=oe.writeDtlsParameters(t.dtlsTransport.getLocalParameters(),n==="offer"?"actpass":i||"active"),o+="a=mid:"+t.mid+`\r
- `,t.rtpSender&&t.rtpReceiver?o+=`a=sendrecv\r
- `:t.rtpSender?o+=`a=sendonly\r
- `:t.rtpReceiver?o+=`a=recvonly\r
- `:o+=`a=inactive\r
- `,t.rtpSender){var s=t.rtpSender._initialTrackId||t.rtpSender.track.id;t.rtpSender._initialTrackId=s;var c="msid:"+(r?r.id:"-")+" "+s+`\r
- `;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
- `)}return o+="a=ssrc:"+t.sendEncodingParameters[0].ssrc+" cname:"+oe.localCName+`\r
- `,t.rtpSender&&t.sendEncodingParameters[0].rtx&&(o+="a=ssrc:"+t.sendEncodingParameters[0].rtx.ssrc+" cname:"+oe.localCName+`\r
- `),o}function Pr(t,e){var n={codecs:[],headerExtensions:[],fecMechanisms:[]},r=function(o,s){o=parseInt(o,10);for(var c=0;c<s.length;c++)if(s[c].payloadType===o||s[c].preferredPayloadType===o)return s[c]},i=function(o,s,c,d){var l=r(o.parameters.apt,c),h=r(s.parameters.apt,d);return l&&h&&l.name.toLowerCase()===h.name.toLowerCase()};return t.codecs.forEach(function(o){for(var s=0;s<e.codecs.length;s++){var c=e.codecs[s];if(o.name.toLowerCase()===c.name.toLowerCase()&&o.clockRate===c.clockRate){if(o.name.toLowerCase()==="rtx"&&o.parameters&&c.parameters.apt&&!i(o,c,t.codecs,e.codecs))continue;(c=JSON.parse(JSON.stringify(c))).numChannels=Math.min(o.numChannels,c.numChannels),n.codecs.push(c),c.rtcpFeedback=c.rtcpFeedback.filter(function(d){for(var l=0;l<o.rtcpFeedback.length;l++)if(o.rtcpFeedback[l].type===d.type&&o.rtcpFeedback[l].parameter===d.parameter)return!0;return!1});break}}}),t.headerExtensions.forEach(function(o){for(var s=0;s<e.headerExtensions.length;s++){var c=e.headerExtensions[s];if(o.uri===c.uri){n.headerExtensions.push(c);break}}}),n}function Oc(t,e,n){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][t].indexOf(n)!==-1}function ao(t,e){var n=t.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 n||t.addRemoteCandidate(e),!n}function Fe(t,e){var n=new Error(e);return n.name=t,n.code={NotSupportedError:9,InvalidStateError:11,InvalidAccessError:15,TypeError:void 0,OperationError:void 0}[t],n}var Mf=function(t,e){function n(s,c){c.addTrack(s),c.dispatchEvent(new t.MediaStreamTrackEvent("addtrack",{track:s}))}function r(s,c,d,l){var h=new Event("track");h.track=c,h.receiver=d,h.transceiver={receiver:d},h.streams=l,t.setTimeout(function(){s._dispatchEvent("track",h)})}var i=function(s){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",s=JSON.parse(JSON.stringify(s||{})),this.usingBundle=s.bundlePolicy==="max-bundle",s.rtcpMuxPolicy==="negotiate")throw Fe("NotSupportedError","rtcpMuxPolicy 'negotiate' is not supported");switch(s.rtcpMuxPolicy||(s.rtcpMuxPolicy="require"),s.iceTransportPolicy){case"all":case"relay":break;default:s.iceTransportPolicy="all"}switch(s.bundlePolicy){case"balanced":case"max-compat":case"max-bundle":break;default:s.bundlePolicy="balanced"}if(s.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}})}(s.iceServers||[],e),this._iceGatherers=[],s.iceCandidatePoolSize)for(var l=s.iceCandidatePoolSize;l>0;l--)this._iceGatherers.push(new t.RTCIceGatherer({iceServers:s.iceServers,gatherPolicy:s.iceTransportPolicy}));else s.iceCandidatePoolSize=0;this._config=s,this.transceivers=[],this._sdpSessionId=oe.generateSessionId(),this._sdpSessionVersion=0,this._dtlsRole=void 0,this._isClosed=!1};Object.defineProperty(i.prototype,"localDescription",{configurable:!0,get:function(){return this._localDescription}}),Object.defineProperty(i.prototype,"remoteDescription",{configurable:!0,get:function(){return this._remoteDescription}}),i.prototype.onicecandidate=null,i.prototype.onaddstream=null,i.prototype.ontrack=null,i.prototype.onremovestream=null,i.prototype.onsignalingstatechange=null,i.prototype.oniceconnectionstatechange=null,i.prototype.onconnectionstatechange=null,i.prototype.onicegatheringstatechange=null,i.prototype.onnegotiationneeded=null,i.prototype.ondatachannel=null,i.prototype._dispatchEvent=function(s,c){this._isClosed||(this.dispatchEvent(c),typeof this["on"+s]=="function"&&this["on"+s](c))},i.prototype._emitGatheringStateChange=function(){var s=new Event("icegatheringstatechange");this._dispatchEvent("icegatheringstatechange",s)},i.prototype.getConfiguration=function(){return this._config},i.prototype.getLocalStreams=function(){return this.localStreams},i.prototype.getRemoteStreams=function(){return this.remoteStreams},i.prototype._createTransceiver=function(s,c){var d=this.transceivers.length>0,l={track:null,iceGatherer:null,iceTransport:null,dtlsTransport:null,localCapabilities:null,remoteCapabilities:null,rtpSender:null,rtpReceiver:null,kind:s,mid:null,sendEncodingParameters:null,recvEncodingParameters:null,stream:null,associatedRemoteMediaStreams:[],wantReceive:!0};if(this.usingBundle&&d)l.iceTransport=this.transceivers[0].iceTransport,l.dtlsTransport=this.transceivers[0].dtlsTransport;else{var h=this._createIceAndDtlsTransports();l.iceTransport=h.iceTransport,l.dtlsTransport=h.dtlsTransport}return c||this.transceivers.push(l),l},i.prototype.addTrack=function(s,c){if(this._isClosed)throw Fe("InvalidStateError","Attempted to call addTrack on a closed peerconnection.");var d;if(this.transceivers.find(function(h){return h.track===s}))throw Fe("InvalidAccessError","Track already exists.");for(var l=0;l<this.transceivers.length;l++)this.transceivers[l].track||this.transceivers[l].kind!==s.kind||(d=this.transceivers[l]);return d||(d=this._createTransceiver(s.kind)),this._maybeFireNegotiationNeeded(),this.localStreams.indexOf(c)===-1&&this.localStreams.push(c),d.track=s,d.stream=c,d.rtpSender=new t.RTCRtpSender(s,d.dtlsTransport),d.rtpSender},i.prototype.addStream=function(s){var c=this;if(e>=15025)s.getTracks().forEach(function(l){c.addTrack(l,s)});else{var d=s.clone();s.getTracks().forEach(function(l,h){var a=d.getTracks()[h];l.addEventListener("enabled",function(u){a.enabled=u.enabled})}),d.getTracks().forEach(function(l){c.addTrack(l,d)})}},i.prototype.removeTrack=function(s){if(this._isClosed)throw Fe("InvalidStateError","Attempted to call removeTrack on a closed peerconnection.");if(!(s instanceof t.RTCRtpSender))throw new TypeError("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.");var c=this.transceivers.find(function(l){return l.rtpSender===s});if(!c)throw Fe("InvalidAccessError","Sender was not created by this connection.");var d=c.stream;c.rtpSender.stop(),c.rtpSender=null,c.track=null,c.stream=null,this.transceivers.map(function(l){return l.stream}).indexOf(d)===-1&&this.localStreams.indexOf(d)>-1&&this.localStreams.splice(this.localStreams.indexOf(d),1),this._maybeFireNegotiationNeeded()},i.prototype.removeStream=function(s){var c=this;s.getTracks().forEach(function(d){var l=c.getSenders().find(function(h){return h.track===d});l&&c.removeTrack(l)})},i.prototype.getSenders=function(){return this.transceivers.filter(function(s){return!!s.rtpSender}).map(function(s){return s.rtpSender})},i.prototype.getReceivers=function(){return this.transceivers.filter(function(s){return!!s.rtpReceiver}).map(function(s){return s.rtpReceiver})},i.prototype._createIceGatherer=function(s,c){var d=this;if(c&&s>0)return this.transceivers[0].iceGatherer;if(this._iceGatherers.length)return this._iceGatherers.shift();var l=new t.RTCIceGatherer({iceServers:this._config.iceServers,gatherPolicy:this._config.iceTransportPolicy});return Object.defineProperty(l,"state",{value:"new",writable:!0}),this.transceivers[s].bufferedCandidateEvents=[],this.transceivers[s].bufferCandidates=function(h){var a=!h.candidate||Object.keys(h.candidate).length===0;l.state=a?"completed":"gathering",d.transceivers[s].bufferedCandidateEvents!==null&&d.transceivers[s].bufferedCandidateEvents.push(h)},l.addEventListener("localcandidate",this.transceivers[s].bufferCandidates),l},i.prototype._gather=function(s,c){var d=this,l=this.transceivers[c].iceGatherer;if(!l.onlocalcandidate){var h=this.transceivers[c].bufferedCandidateEvents;this.transceivers[c].bufferedCandidateEvents=null,l.removeEventListener("localcandidate",this.transceivers[c].bufferCandidates),l.onlocalcandidate=function(a){if(!(d.usingBundle&&c>0)){var u=new Event("icecandidate");u.candidate={sdpMid:s,sdpMLineIndex:c};var f=a.candidate,p=!f||Object.keys(f).length===0;if(p)l.state!=="new"&&l.state!=="gathering"||(l.state="completed");else{l.state==="new"&&(l.state="gathering"),f.component=1,f.ufrag=l.getLocalParameters().usernameFragment;var m=oe.writeCandidate(f);u.candidate=Object.assign(u.candidate,oe.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 _=oe.getMediaSections(d._localDescription.sdp);_[u.candidate.sdpMLineIndex]+=p?`a=end-of-candidates\r
- `:"a="+u.candidate.candidate+`\r
- `,d._localDescription.sdp=oe.getDescription(d._localDescription.sdp)+_.join("");var v=d.transceivers.every(function(y){return y.iceGatherer&&y.iceGatherer.state==="completed"});d.iceGatheringState!=="gathering"&&(d.iceGatheringState="gathering",d._emitGatheringStateChange()),p||d._dispatchEvent("icecandidate",u),v&&(d._dispatchEvent("icecandidate",new Event("icecandidate")),d.iceGatheringState="complete",d._emitGatheringStateChange())}},t.setTimeout(function(){h.forEach(function(a){l.onlocalcandidate(a)})},0)}},i.prototype._createIceAndDtlsTransports=function(){var s=this,c=new t.RTCIceTransport(null);c.onicestatechange=function(){s._updateIceConnectionState(),s._updateConnectionState()};var d=new t.RTCDtlsTransport(c);return d.ondtlsstatechange=function(){s._updateConnectionState()},d.onerror=function(){Object.defineProperty(d,"state",{value:"failed",writable:!0}),s._updateConnectionState()},{iceTransport:c,dtlsTransport:d}},i.prototype._disposeIceAndDtlsTransports=function(s){var c=this.transceivers[s].iceGatherer;c&&(delete c.onlocalcandidate,delete this.transceivers[s].iceGatherer);var d=this.transceivers[s].iceTransport;d&&(delete d.onicestatechange,delete this.transceivers[s].iceTransport);var l=this.transceivers[s].dtlsTransport;l&&(delete l.ondtlsstatechange,delete l.onerror,delete this.transceivers[s].dtlsTransport)},i.prototype._transceive=function(s,c,d){var l=Pr(s.localCapabilities,s.remoteCapabilities);c&&s.rtpSender&&(l.encodings=s.sendEncodingParameters,l.rtcp={cname:oe.localCName,compound:s.rtcpParameters.compound},s.recvEncodingParameters.length&&(l.rtcp.ssrc=s.recvEncodingParameters[0].ssrc),s.rtpSender.send(l)),d&&s.rtpReceiver&&l.codecs.length>0&&(s.kind==="video"&&s.recvEncodingParameters&&e<15019&&s.recvEncodingParameters.forEach(function(h){delete h.rtx}),s.recvEncodingParameters.length?l.encodings=s.recvEncodingParameters:l.encodings=[{}],l.rtcp={compound:s.rtcpParameters.compound},s.rtcpParameters.cname&&(l.rtcp.cname=s.rtcpParameters.cname),s.sendEncodingParameters.length&&(l.rtcp.ssrc=s.sendEncodingParameters[0].ssrc),s.rtpReceiver.receive(l))},i.prototype.setLocalDescription=function(s){var c,d,l=this;if(["offer","answer"].indexOf(s.type)===-1)return Promise.reject(Fe("TypeError",'Unsupported type "'+s.type+'"'));if(!Oc("setLocalDescription",s.type,l.signalingState)||l._isClosed)return Promise.reject(Fe("InvalidStateError","Can not set local "+s.type+" in state "+l.signalingState));if(s.type==="offer")c=oe.splitSections(s.sdp),d=c.shift(),c.forEach(function(a,u){var f=oe.parseRtpParameters(a);l.transceivers[u].localCapabilities=f}),l.transceivers.forEach(function(a,u){l._gather(a.mid,u)});else if(s.type==="answer"){c=oe.splitSections(l._remoteDescription.sdp),d=c.shift();var h=oe.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(!(oe.isRejected(a)&&oe.matchPrefix(a,"a=bundle-only").length===0)&&!f.rejected){var C=oe.getIceParameters(a,d),b=oe.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 N=Pr(v,y);l._transceive(f,N.codecs.length>0,!1)}})}return l._localDescription={type:s.type,sdp:s.sdp},s.type==="offer"?l._updateSignalingState("have-local-offer"):l._updateSignalingState("stable"),Promise.resolve()},i.prototype.setRemoteDescription=function(s){var c=this;if(["offer","answer"].indexOf(s.type)===-1)return Promise.reject(Fe("TypeError",'Unsupported type "'+s.type+'"'));if(!Oc("setRemoteDescription",s.type,c.signalingState)||c._isClosed)return Promise.reject(Fe("InvalidStateError","Can not set remote "+s.type+" in state "+c.signalingState));var d={};c.remoteStreams.forEach(function(m){d[m.id]=m});var l=[],h=oe.splitSections(s.sdp),a=h.shift(),u=oe.matchPrefix(a,"a=ice-lite").length>0,f=oe.matchPrefix(a,"a=group:BUNDLE ").length>0;c.usingBundle=f;var p=oe.matchPrefix(a,"a=ice-options:")[0];return c.canTrickleIceCandidates=!!p&&p.substr(14).split(" ").indexOf("trickle")>=0,h.forEach(function(m,_){var v=oe.splitLines(m),y=oe.getKind(m),C=oe.isRejected(m)&&oe.matchPrefix(m,"a=bundle-only").length===0,b=v[0].substr(2).split(" ")[2],N=oe.getDirection(m,a),S=oe.parseMsid(m),E=oe.getMid(m)||oe.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,K,R,T,A,k,U,F;!C&&c.transceivers[_]&&c.transceivers[_].rejected&&(c.transceivers[_]=c._createTransceiver(y,!0));var H,Q,ee=oe.parseRtpParameters(m);C||(H=oe.getIceParameters(m,a),(Q=oe.getDtlsParameters(m,a)).role="client"),k=oe.parseRtpEncodingParameters(m);var ce=oe.parseRtcpParameters(m),X=oe.matchPrefix(m,"a=end-of-candidates",a).length>0,z=oe.matchPrefix(m,"a=candidate:").map(function(L){return oe.parseCandidate(L)}).filter(function(L){return L.component===1});if((s.type==="offer"||s.type==="answer")&&!C&&f&&_>0&&c.transceivers[_]&&(c._disposeIceAndDtlsTransports(_),c.transceivers[_].iceGatherer=c.transceivers[0].iceGatherer,c.transceivers[_].iceTransport=c.transceivers[0].iceTransport,c.transceivers[_].dtlsTransport=c.transceivers[0].dtlsTransport,c.transceivers[_].rtpSender&&c.transceivers[_].rtpSender.setTransport(c.transceivers[0].dtlsTransport),c.transceivers[_].rtpReceiver&&c.transceivers[_].rtpReceiver.setTransport(c.transceivers[0].dtlsTransport)),s.type!=="offer"||C)s.type==="answer"&&!C&&(V=(w=c.transceivers[_]).iceGatherer,K=w.iceTransport,R=w.dtlsTransport,T=w.rtpReceiver,A=w.sendEncodingParameters,U=w.localCapabilities,c.transceivers[_].recvEncodingParameters=k,c.transceivers[_].remoteCapabilities=ee,c.transceivers[_].rtcpParameters=ce,z.length&&K.state==="new"&&(!u&&!X||f&&_!==0?z.forEach(function(L){ao(w.iceTransport,L)}):K.setRemoteCandidates(z)),f&&_!==0||(K.state==="new"&&K.start(V,H,"controlling"),R.state==="new"&&R.start(Q)),!Pr(w.localCapabilities,w.remoteCapabilities).codecs.filter(function(L){return L.name.toLowerCase()==="rtx"}).length&&w.sendEncodingParameters[0].rtx&&delete w.sendEncodingParameters[0].rtx,c._transceive(w,N==="sendrecv"||N==="recvonly",N==="sendrecv"||N==="sendonly"),!T||N!=="sendrecv"&&N!=="sendonly"?delete w.rtpReceiver:(F=T.track,S?(d[S.stream]||(d[S.stream]=new t.MediaStream),n(F,d[S.stream]),l.push([F,T,d[S.stream]])):(d.default||(d.default=new t.MediaStream),n(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)),z.length&&w.iceTransport.state==="new"&&(!X||f&&_!==0?z.forEach(function(L){ao(w.iceTransport,L)}):w.iceTransport.setRemoteCandidates(z)),U=t.RTCRtpReceiver.getCapabilities(y),e<15019&&(U.codecs=U.codecs.filter(function(L){return L.name!=="rtx"})),A=w.sendEncodingParameters||[{ssrc:1001*(2*_+2)}];var q,J=!1;N==="sendrecv"||N==="sendonly"?(J=!w.rtpReceiver,T=w.rtpReceiver||new t.RTCRtpReceiver(w.dtlsTransport,y),J&&(F=T.track,S&&S.stream==="-"||(S?(d[S.stream]||(d[S.stream]=new t.MediaStream,Object.defineProperty(d[S.stream],"id",{get:function(){return S.stream}})),Object.defineProperty(F,"id",{get:function(){return S.track}}),q=d[S.stream]):(d.default||(d.default=new t.MediaStream),q=d.default)),q&&(n(F,q),w.associatedRemoteMediaStreams.push(q)),l.push([F,T,q]))):w.rtpReceiver&&w.rtpReceiver.track&&(w.associatedRemoteMediaStreams.forEach(function(L){var $=L.getTracks().find(function(te){return te.id===w.rtpReceiver.track.id});$&&function(te,se){se.removeTrack(te),se.dispatchEvent(new t.MediaStreamTrackEvent("removetrack",{track:te}))}($,L)}),w.associatedRemoteMediaStreams=[]),w.localCapabilities=U,w.remoteCapabilities=ee,w.rtpReceiver=T,w.rtcpParameters=ce,w.sendEncodingParameters=A,w.recvEncodingParameters=k,c._transceive(c.transceivers[_],!1,J)}}}),c._dtlsRole===void 0&&(c._dtlsRole=s.type==="offer"?"active":"passive"),c._remoteDescription={type:s.type,sdp:s.sdp},s.type==="offer"?c._updateSignalingState("have-remote-offer"):c._updateSignalingState("stable"),Object.keys(d).forEach(function(m){var _=d[m];if(_.getTracks().length){if(c.remoteStreams.indexOf(_)===-1){c.remoteStreams.push(_);var v=new Event("addstream");v.stream=_,t.setTimeout(function(){c._dispatchEvent("addstream",v)})}l.forEach(function(y){var C=y[0],b=y[1];_.id===y[2].id&&r(c,C,b,[_])})}}),l.forEach(function(m){m[2]||r(c,m[0],m[1],[])}),t.setTimeout(function(){c&&c.transceivers&&c.transceivers.forEach(function(m){m.iceTransport&&m.iceTransport.state==="new"&&m.iceTransport.getRemoteCandidates().length>0&&(console.warn("Timeout for addRemoteCandidate. Consider sending an end-of-candidates notification"),m.iceTransport.addRemoteCandidate({}))})},4e3),Promise.resolve()},i.prototype.close=function(){this.transceivers.forEach(function(s){s.iceTransport&&s.iceTransport.stop(),s.dtlsTransport&&s.dtlsTransport.stop(),s.rtpSender&&s.rtpSender.stop(),s.rtpReceiver&&s.rtpReceiver.stop()}),this._isClosed=!0,this._updateSignalingState("closed")},i.prototype._updateSignalingState=function(s){this.signalingState=s;var c=new Event("signalingstatechange");this._dispatchEvent("signalingstatechange",c)},i.prototype._maybeFireNegotiationNeeded=function(){var s=this;this.signalingState==="stable"&&this.needNegotiation!==!0&&(this.needNegotiation=!0,t.setTimeout(function(){if(s.needNegotiation){s.needNegotiation=!1;var c=new Event("negotiationneeded");s._dispatchEvent("negotiationneeded",c)}},0))},i.prototype._updateIceConnectionState=function(){var s,c={new:0,closed:0,checking:0,connected:0,completed:0,disconnected:0,failed:0};if(this.transceivers.forEach(function(l){l.iceTransport&&!l.rejected&&c[l.iceTransport.state]++}),s="new",c.failed>0?s="failed":c.checking>0?s="checking":c.disconnected>0?s="disconnected":c.new>0?s="new":c.connected>0?s="connected":c.completed>0&&(s="completed"),s!==this.iceConnectionState){this.iceConnectionState=s;var d=new Event("iceconnectionstatechange");this._dispatchEvent("iceconnectionstatechange",d)}},i.prototype._updateConnectionState=function(){var s,c={new:0,closed:0,connecting:0,connected:0,completed:0,disconnected:0,failed:0};if(this.transceivers.forEach(function(l){l.iceTransport&&l.dtlsTransport&&!l.rejected&&(c[l.iceTransport.state]++,c[l.dtlsTransport.state]++)}),c.connected+=c.completed,s="new",c.failed>0?s="failed":c.connecting>0?s="connecting":c.disconnected>0?s="disconnected":c.new>0?s="new":c.connected>0&&(s="connected"),s!==this.connectionState){this.connectionState=s;var d=new Event("connectionstatechange");this._dispatchEvent("connectionstatechange",d)}},i.prototype.createOffer=function(){var s=this;if(s._isClosed)return Promise.reject(Fe("InvalidStateError","Can not call createOffer after close"));var c=s.transceivers.filter(function(u){return u.kind==="audio"}).length,d=s.transceivers.filter(function(u){return u.kind==="video"}).length,l=arguments[0];if(l){if(l.mandatory||l.optional)throw new TypeError("Legacy mandatory/optional constraints not supported.");l.offerToReceiveAudio!==void 0&&(c=l.offerToReceiveAudio===!0?1:l.offerToReceiveAudio===!1?0:l.offerToReceiveAudio),l.offerToReceiveVideo!==void 0&&(d=l.offerToReceiveVideo===!0?1:l.offerToReceiveVideo===!1?0:l.offerToReceiveVideo)}for(s.transceivers.forEach(function(u){u.kind==="audio"?--c<0&&(u.wantReceive=!1):u.kind==="video"&&--d<0&&(u.wantReceive=!1)});c>0||d>0;)c>0&&(s._createTransceiver("audio"),c--),d>0&&(s._createTransceiver("video"),d--);var h=oe.writeSessionBoilerplate(s._sdpSessionId,s._sdpSessionVersion++);s.transceivers.forEach(function(u,f){var p=u.track,m=u.kind,_=u.mid||oe.generateIdentifier();u.mid=_,u.iceGatherer||(u.iceGatherer=s._createIceGatherer(f,s.usingBundle));var v=t.RTCRtpSender.getCapabilities(m);e<15019&&(v.codecs=v.codecs.filter(function(C){return C.name!=="rtx"})),v.codecs.forEach(function(C){C.name==="H264"&&C.parameters["level-asymmetry-allowed"]===void 0&&(C.parameters["level-asymmetry-allowed"]="1"),u.remoteCapabilities&&u.remoteCapabilities.codecs&&u.remoteCapabilities.codecs.forEach(function(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 t.RTCRtpReceiver(u.dtlsTransport,m)),u.localCapabilities=v,u.sendEncodingParameters=y}),s._config.bundlePolicy!=="max-compat"&&(h+="a=group:BUNDLE "+s.transceivers.map(function(u){return u.mid}).join(" ")+`\r
- `),h+=`a=ice-options:trickle\r
- `,s.transceivers.forEach(function(u,f){h+=wc(u,u.localCapabilities,"offer",u.stream,s._dtlsRole),h+=`a=rtcp-rsize\r
- `,!u.iceGatherer||s.iceGatheringState==="new"||f!==0&&s.usingBundle||(u.iceGatherer.getLocalCandidates().forEach(function(p){p.component=1,h+="a="+oe.writeCandidate(p)+`\r
- `}),u.iceGatherer.state==="completed"&&(h+=`a=end-of-candidates\r
- `))});var a=new t.RTCSessionDescription({type:"offer",sdp:h});return Promise.resolve(a)},i.prototype.createAnswer=function(){var s=this;if(s._isClosed)return Promise.reject(Fe("InvalidStateError","Can not call createAnswer after close"));if(s.signalingState!=="have-remote-offer"&&s.signalingState!=="have-local-pranswer")return Promise.reject(Fe("InvalidStateError","Can not call createAnswer in signalingState "+s.signalingState));var c=oe.writeSessionBoilerplate(s._sdpSessionId,s._sdpSessionVersion++);s.usingBundle&&(c+="a=group:BUNDLE "+s.transceivers.map(function(h){return h.mid}).join(" ")+`\r
- `),c+=`a=ice-options:trickle\r
- `;var d=oe.getMediaSections(s._remoteDescription.sdp).length;s.transceivers.forEach(function(h,a){if(!(a+1>d)){if(h.rejected)return h.kind==="application"?h.protocol==="DTLS/SCTP"?c+=`m=application 0 DTLS/SCTP 5000\r
- `:c+="m=application 0 "+h.protocol+` webrtc-datachannel\r
- `:h.kind==="audio"?c+=`m=audio 0 UDP/TLS/RTP/SAVPF 0\r
- a=rtpmap:0 PCMU/8000\r
- `:h.kind==="video"&&(c+=`m=video 0 UDP/TLS/RTP/SAVPF 120\r
- a=rtpmap:120 VP8/90000\r
- `),void(c+=`c=IN IP4 0.0.0.0\r
- a=inactive\r
- a=mid:`+h.mid+`\r
- `);var u;h.stream&&(h.kind==="audio"?u=h.stream.getAudioTracks()[0]:h.kind==="video"&&(u=h.stream.getVideoTracks()[0]),u&&e>=15019&&h.kind==="video"&&!h.sendEncodingParameters[0].rtx&&(h.sendEncodingParameters[0].rtx={ssrc:h.sendEncodingParameters[0].ssrc+1}));var f=Pr(h.localCapabilities,h.remoteCapabilities);!f.codecs.filter(function(p){return p.name.toLowerCase()==="rtx"}).length&&h.sendEncodingParameters[0].rtx&&delete h.sendEncodingParameters[0].rtx,c+=wc(h,f,"answer",h.stream,s._dtlsRole),h.rtcpParameters&&h.rtcpParameters.reducedSize&&(c+=`a=rtcp-rsize\r
- `)}});var l=new t.RTCSessionDescription({type:"answer",sdp:c});return Promise.resolve(l)},i.prototype.addIceCandidate=function(s){var c,d=this;return s&&s.sdpMLineIndex===void 0&&!s.sdpMid?Promise.reject(new TypeError("sdpMLineIndex or sdpMid required")):new Promise(function(l,h){if(!d._remoteDescription)return h(Fe("InvalidStateError","Can not add ICE candidate without a remote description"));if(s&&s.candidate!==""){var a=s.sdpMLineIndex;if(s.sdpMid){for(var u=0;u<d.transceivers.length;u++)if(d.transceivers[u].mid===s.sdpMid){a=u;break}}var f=d.transceivers[a];if(!f)return h(Fe("OperationError","Can not add ICE candidate"));if(f.rejected)return l();var p=Object.keys(s.candidate).length>0?oe.parseCandidate(s.candidate):{};if(p.protocol==="tcp"&&(p.port===0||p.port===9)||p.component&&p.component!==1)return l();if((a===0||a>0&&f.iceTransport!==d.transceivers[0].iceTransport)&&!ao(f.iceTransport,p))return h(Fe("OperationError","Can not add ICE candidate"));var m=s.candidate.trim();m.indexOf("a=")===0&&(m=m.substr(2)),(c=oe.getMediaSections(d._remoteDescription.sdp))[a]+="a="+(p.type?m:"end-of-candidates")+`\r
- `,d._remoteDescription.sdp=oe.getDescription(d._remoteDescription.sdp)+c.join("")}else for(var _=0;_<d.transceivers.length&&(d.transceivers[_].rejected||(d.transceivers[_].iceTransport.addRemoteCandidate({}),(c=oe.getMediaSections(d._remoteDescription.sdp))[_]+=`a=end-of-candidates\r
- `,d._remoteDescription.sdp=oe.getDescription(d._remoteDescription.sdp)+c.join(""),!d.usingBundle));_++);l()})},i.prototype.getStats=function(s){if(s&&s instanceof t.MediaStreamTrack){var c=null;if(this.transceivers.forEach(function(l){l.rtpSender&&l.rtpSender.track===s?c=l.rtpSender:l.rtpReceiver&&l.rtpReceiver.track===s&&(c=l.rtpReceiver)}),!c)throw Fe("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(s){var c=t[s];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 o=["createOffer","createAnswer"];return o.forEach(function(s){var c=i.prototype[s];i.prototype[s]=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)}}),(o=["setLocalDescription","setRemoteDescription","addIceCandidate"]).forEach(function(s){var c=i.prototype[s];i.prototype[s]=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(s){var c=i.prototype[s];i.prototype[s]=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 dd(t){const e=t&&t.navigator,n=e.mediaDevices.getUserMedia.bind(e.mediaDevices);e.mediaDevices.getUserMedia=function(r){return n(r).catch(i=>Promise.reject(function(o){return{name:{PermissionDeniedError:"NotAllowedError"}[o.name]||o.name,message:o.message,constraint:o.constraint,toString(){return this.name}}}(i)))}}function ld(t){"getDisplayMedia"in t.navigator&&t.navigator.mediaDevices&&(t.navigator.mediaDevices&&"getDisplayMedia"in t.navigator.mediaDevices||(t.navigator.mediaDevices.getDisplayMedia=t.navigator.getDisplayMedia.bind(t.navigator)))}function Xo(t,e){if(t.RTCIceGatherer&&(t.RTCIceCandidate||(t.RTCIceCandidate=function(r){return r}),t.RTCSessionDescription||(t.RTCSessionDescription=function(r){return r}),e.version<15025)){const r=Object.getOwnPropertyDescriptor(t.MediaStreamTrack.prototype,"enabled");Object.defineProperty(t.MediaStreamTrack.prototype,"enabled",{set(i){r.set.call(this,i);const o=new Event("enabled");o.enabled=i,this.dispatchEvent(o)}})}t.RTCRtpSender&&!("dtmf"in t.RTCRtpSender.prototype)&&Object.defineProperty(t.RTCRtpSender.prototype,"dtmf",{get(){return this._dtmf===void 0&&(this.track.kind==="audio"?this._dtmf=new t.RTCDtmfSender(this):this.track.kind==="video"&&(this._dtmf=null)),this._dtmf}}),t.RTCDtmfSender&&!t.RTCDTMFSender&&(t.RTCDTMFSender=t.RTCDtmfSender);const n=Mf(t,e.version);t.RTCPeerConnection=function(r){return r&&r.iceServers&&(r.iceServers=function(i,o){let s=!1;return(i=JSON.parse(JSON.stringify(i))).filter(c=>{if(c&&(c.urls||c.url)){let d=c.urls||c.url;c.url&&!c.urls&&Di("RTCIceServer.url","RTCIceServer.urls");const l=typeof d=="string";return l&&(d=[d]),d=d.filter(h=>{if(h.indexOf("stun:")===0)return!1;const a=h.startsWith("turn")&&!h.startsWith("turn:[")&&h.includes("transport=udp");return a&&!s?(s=!0,!0):a&&!s}),delete c.url,c.urls=l?d[0]:d,!!d.length}})}(r.iceServers,e.version),ua("ICE servers after filtering:",r.iceServers)),new n(r)},t.RTCPeerConnection.prototype=n.prototype}function hd(t){t.RTCRtpSender&&!("replaceTrack"in t.RTCRtpSender.prototype)&&(t.RTCRtpSender.prototype.replaceTrack=t.RTCRtpSender.prototype.setTrack)}var Nc=Object.freeze({__proto__:null,shimPeerConnection:Xo,shimReplaceTrack:hd,shimGetUserMedia:dd,shimGetDisplayMedia:ld});function fd(t,e){const n=t&&t.navigator,r=t&&t.MediaStreamTrack;if(n.getUserMedia=function(i,o,s){Di("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),n.mediaDevices.getUserMedia(i).then(o,s)},!(e.version>55&&"autoGainControl"in n.mediaDevices.getSupportedConstraints())){const i=function(s,c,d){c in s&&!(d in s)&&(s[d]=s[c],delete s[c])},o=n.mediaDevices.getUserMedia.bind(n.mediaDevices);if(n.mediaDevices.getUserMedia=function(s){return typeof s=="object"&&typeof s.audio=="object"&&(s=JSON.parse(JSON.stringify(s)),i(s.audio,"autoGainControl","mozAutoGainControl"),i(s.audio,"noiseSuppression","mozNoiseSuppression")),o(s)},r&&r.prototype.getSettings){const s=r.prototype.getSettings;r.prototype.getSettings=function(){const c=s.apply(this,arguments);return i(c,"mozAutoGainControl","autoGainControl"),i(c,"mozNoiseSuppression","noiseSuppression"),c}}if(r&&r.prototype.applyConstraints){const s=r.prototype.applyConstraints;r.prototype.applyConstraints=function(c){return this.kind==="audio"&&typeof c=="object"&&(c=JSON.parse(JSON.stringify(c)),i(c,"autoGainControl","mozAutoGainControl"),i(c,"noiseSuppression","mozNoiseSuppression")),s.apply(this,[c])}}}}function pd(t){typeof t=="object"&&t.RTCTrackEvent&&"receiver"in t.RTCTrackEvent.prototype&&!("transceiver"in t.RTCTrackEvent.prototype)&&Object.defineProperty(t.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function Zo(t,e){if(typeof t!="object"||!t.RTCPeerConnection&&!t.mozRTCPeerConnection)return;!t.RTCPeerConnection&&t.mozRTCPeerConnection&&(t.RTCPeerConnection=t.mozRTCPeerConnection),e.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(i){const o=t.RTCPeerConnection.prototype[i],s={[i](){return arguments[0]=new(i==="addIceCandidate"?t.RTCIceCandidate:t.RTCSessionDescription)(arguments[0]),o.apply(this,arguments)}};t.RTCPeerConnection.prototype[i]=s[i]});const n={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"},r=t.RTCPeerConnection.prototype.getStats;t.RTCPeerConnection.prototype.getStats=function(){const[i,o,s]=arguments;return r.apply(this,[i||null]).then(c=>{if(e.version<53&&!o)try{c.forEach(d=>{d.type=n[d.type]||d.type})}catch(d){if(d.name!=="TypeError")throw d;c.forEach((l,h)=>{c.set(h,Object.assign({},l,{type:n[l.type]||l.type}))})}return c}).then(o,s)}}function gd(t){if(typeof t!="object"||!t.RTCPeerConnection||!t.RTCRtpSender||t.RTCRtpSender&&"getStats"in t.RTCRtpSender.prototype)return;const e=t.RTCPeerConnection.prototype.getSenders;e&&(t.RTCPeerConnection.prototype.getSenders=function(){const r=e.apply(this,[]);return r.forEach(i=>i._pc=this),r});const n=t.RTCPeerConnection.prototype.addTrack;n&&(t.RTCPeerConnection.prototype.addTrack=function(){const r=n.apply(this,arguments);return r._pc=this,r}),t.RTCRtpSender.prototype.getStats=function(){return this.track?this._pc.getStats(this.track):Promise.resolve(new Map)}}function md(t){if(typeof t!="object"||!t.RTCPeerConnection||!t.RTCRtpSender||t.RTCRtpSender&&"getStats"in t.RTCRtpReceiver.prototype)return;const e=t.RTCPeerConnection.prototype.getReceivers;e&&(t.RTCPeerConnection.prototype.getReceivers=function(){const n=e.apply(this,[]);return n.forEach(r=>r._pc=this),n}),wn(t,"track",n=>(n.receiver._pc=n.srcElement,n)),t.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}function _d(t){t.RTCPeerConnection&&!("removeStream"in t.RTCPeerConnection.prototype)&&(t.RTCPeerConnection.prototype.removeStream=function(e){Di("removeStream","removeTrack"),this.getSenders().forEach(n=>{n.track&&e.getTracks().includes(n.track)&&this.removeTrack(n)})})}function vd(t){t.DataChannel&&!t.RTCDataChannel&&(t.RTCDataChannel=t.DataChannel)}function yd(t){if(typeof t!="object"||!t.RTCPeerConnection)return;const e=t.RTCPeerConnection.prototype.addTransceiver;e&&(t.RTCPeerConnection.prototype.addTransceiver=function(){this.setParametersPromises=[];const n=arguments[1],r=n&&"sendEncodings"in n;r&&n.sendEncodings.forEach(o=>{if("rid"in o&&!/^[a-z0-9]{0,16}$/i.test(o.rid))throw new TypeError("Invalid RID value provided.");if("scaleResolutionDownBy"in o&&!(parseFloat(o.scaleResolutionDownBy)>=1))throw new RangeError("scale_resolution_down_by must be >= 1.0");if("maxFramerate"in o&&!(parseFloat(o.maxFramerate)>=0))throw new RangeError("max_framerate must be >= 0.0")});const i=e.apply(this,arguments);if(r){const{sender:o}=i,s=o.getParameters();(!("encodings"in s)||s.encodings.length===1&&Object.keys(s.encodings[0]).length===0)&&(s.encodings=n.sendEncodings,o.sendEncodings=n.sendEncodings,this.setParametersPromises.push(o.setParameters(s).then(()=>{delete o.sendEncodings}).catch(()=>{delete o.sendEncodings})))}return i})}function Cd(t){if(typeof t!="object"||!t.RTCRtpSender)return;const e=t.RTCRtpSender.prototype.getParameters;e&&(t.RTCRtpSender.prototype.getParameters=function(){const n=e.apply(this,arguments);return"encodings"in n||(n.encodings=[].concat(this.sendEncodings||[{}])),n})}function Ed(t){if(typeof t!="object"||!t.RTCPeerConnection)return;const e=t.RTCPeerConnection.prototype.createOffer;t.RTCPeerConnection.prototype.createOffer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(()=>e.apply(this,arguments)).finally(()=>{this.setParametersPromises=[]}):e.apply(this,arguments)}}function Rd(t){if(typeof t!="object"||!t.RTCPeerConnection)return;const e=t.RTCPeerConnection.prototype.createAnswer;t.RTCPeerConnection.prototype.createAnswer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(()=>e.apply(this,arguments)).finally(()=>{this.setParametersPromises=[]}):e.apply(this,arguments)}}var Ac=Object.freeze({__proto__:null,shimOnTrack:pd,shimPeerConnection:Zo,shimSenderGetStats:gd,shimReceiverGetStats:md,shimRemoveStream:_d,shimRTCDataChannel:vd,shimAddTransceiver:yd,shimGetParameters:Cd,shimCreateOffer:Ed,shimCreateAnswer:Rd,shimGetUserMedia:fd,shimGetDisplayMedia:function(t,e){t.navigator.mediaDevices&&"getDisplayMedia"in t.navigator.mediaDevices||t.navigator.mediaDevices&&(t.navigator.mediaDevices.getDisplayMedia=function(n){if(!n||!n.video){const r=new DOMException("getDisplayMedia without video constraints is undefined");return r.name="NotFoundError",r.code=8,Promise.reject(r)}return n.video===!0?n.video={mediaSource:e}:n.video.mediaSource=e,t.navigator.mediaDevices.getUserMedia(n)})}});function Td(t){if(typeof t=="object"&&t.RTCPeerConnection){if("getLocalStreams"in t.RTCPeerConnection.prototype||(t.RTCPeerConnection.prototype.getLocalStreams=function(){return this._localStreams||(this._localStreams=[]),this._localStreams}),!("addStream"in t.RTCPeerConnection.prototype)){const e=t.RTCPeerConnection.prototype.addTrack;t.RTCPeerConnection.prototype.addStream=function(n){this._localStreams||(this._localStreams=[]),this._localStreams.includes(n)||this._localStreams.push(n),n.getAudioTracks().forEach(r=>e.call(this,r,n)),n.getVideoTracks().forEach(r=>e.call(this,r,n))},t.RTCPeerConnection.prototype.addTrack=function(n,...r){return r&&r.forEach(i=>{this._localStreams?this._localStreams.includes(i)||this._localStreams.push(i):this._localStreams=[i]}),e.apply(this,arguments)}}"removeStream"in t.RTCPeerConnection.prototype||(t.RTCPeerConnection.prototype.removeStream=function(e){this._localStreams||(this._localStreams=[]);const n=this._localStreams.indexOf(e);if(n===-1)return;this._localStreams.splice(n,1);const r=e.getTracks();this.getSenders().forEach(i=>{r.includes(i.track)&&this.removeTrack(i)})})}}function Sd(t){if(typeof t=="object"&&t.RTCPeerConnection&&("getRemoteStreams"in t.RTCPeerConnection.prototype||(t.RTCPeerConnection.prototype.getRemoteStreams=function(){return this._remoteStreams?this._remoteStreams:[]}),!("onaddstream"in t.RTCPeerConnection.prototype))){Object.defineProperty(t.RTCPeerConnection.prototype,"onaddstream",{get(){return this._onaddstream},set(n){this._onaddstream&&(this.removeEventListener("addstream",this._onaddstream),this.removeEventListener("track",this._onaddstreampoly)),this.addEventListener("addstream",this._onaddstream=n),this.addEventListener("track",this._onaddstreampoly=r=>{r.streams.forEach(i=>{if(this._remoteStreams||(this._remoteStreams=[]),this._remoteStreams.includes(i))return;this._remoteStreams.push(i);const o=new Event("addstream");o.stream=i,this.dispatchEvent(o)})})}});const e=t.RTCPeerConnection.prototype.setRemoteDescription;t.RTCPeerConnection.prototype.setRemoteDescription=function(){const n=this;return this._onaddstreampoly||this.addEventListener("track",this._onaddstreampoly=function(r){r.streams.forEach(i=>{if(n._remoteStreams||(n._remoteStreams=[]),n._remoteStreams.indexOf(i)>=0)return;n._remoteStreams.push(i);const o=new Event("addstream");o.stream=i,n.dispatchEvent(o)})}),e.apply(n,arguments)}}}function Id(t){if(typeof t!="object"||!t.RTCPeerConnection)return;const e=t.RTCPeerConnection.prototype,n=e.createOffer,r=e.createAnswer,i=e.setLocalDescription,o=e.setRemoteDescription,s=e.addIceCandidate;e.createOffer=function(d,l){const h=arguments.length>=2?arguments[2]:arguments[0],a=n.apply(this,[h]);return l?(a.then(d,l),Promise.resolve()):a},e.createAnswer=function(d,l){const h=arguments.length>=2?arguments[2]:arguments[0],a=r.apply(this,[h]);return l?(a.then(d,l),Promise.resolve()):a};let c=function(d,l,h){const a=i.apply(this,[d]);return h?(a.then(l,h),Promise.resolve()):a};e.setLocalDescription=c,c=function(d,l,h){const a=o.apply(this,[d]);return h?(a.then(l,h),Promise.resolve()):a},e.setRemoteDescription=c,c=function(d,l,h){const a=s.apply(this,[d]);return h?(a.then(l,h),Promise.resolve()):a},e.addIceCandidate=c}function bd(t){const e=t&&t.navigator;if(e.mediaDevices&&e.mediaDevices.getUserMedia){const n=e.mediaDevices,r=n.getUserMedia.bind(n);e.mediaDevices.getUserMedia=i=>r(wd(i))}!e.getUserMedia&&e.mediaDevices&&e.mediaDevices.getUserMedia&&(e.getUserMedia=function(n,r,i){e.mediaDevices.getUserMedia(n).then(r,i)}.bind(e))}function wd(t){return t&&t.video!==void 0?Object.assign({},t,{video:ed(t.video)}):t}function Od(t){if(!t.RTCPeerConnection)return;const e=t.RTCPeerConnection;t.RTCPeerConnection=function(n,r){if(n&&n.iceServers){const i=[];for(let o=0;o<n.iceServers.length;o++){let s=n.iceServers[o];!s.hasOwnProperty("urls")&&s.hasOwnProperty("url")?(Di("RTCIceServer.url","RTCIceServer.urls"),s=JSON.parse(JSON.stringify(s)),s.urls=s.url,delete s.url,i.push(s)):i.push(n.iceServers[o])}n.iceServers=i}return new e(n,r)},t.RTCPeerConnection.prototype=e.prototype,"generateCertificate"in e&&Object.defineProperty(t.RTCPeerConnection,"generateCertificate",{get:()=>e.generateCertificate})}function Nd(t){typeof t=="object"&&t.RTCTrackEvent&&"receiver"in t.RTCTrackEvent.prototype&&!("transceiver"in t.RTCTrackEvent.prototype)&&Object.defineProperty(t.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function Ad(t){const e=t.RTCPeerConnection.prototype.createOffer;t.RTCPeerConnection.prototype.createOffer=function(n){if(n){n.offerToReceiveAudio!==void 0&&(n.offerToReceiveAudio=!!n.offerToReceiveAudio);const r=this.getTransceivers().find(o=>o.receiver.track.kind==="audio");n.offerToReceiveAudio===!1&&r?r.direction==="sendrecv"?r.setDirection?r.setDirection("sendonly"):r.direction="sendonly":r.direction==="recvonly"&&(r.setDirection?r.setDirection("inactive"):r.direction="inactive"):n.offerToReceiveAudio!==!0||r||this.addTransceiver("audio"),n.offerToReceiveVideo!==void 0&&(n.offerToReceiveVideo=!!n.offerToReceiveVideo);const i=this.getTransceivers().find(o=>o.receiver.track.kind==="video");n.offerToReceiveVideo===!1&&i?i.direction==="sendrecv"?i.setDirection?i.setDirection("sendonly"):i.direction="sendonly":i.direction==="recvonly"&&(i.setDirection?i.setDirection("inactive"):i.direction="inactive"):n.offerToReceiveVideo!==!0||i||this.addTransceiver("video")}return e.apply(this,arguments)}}function Md(t){typeof t!="object"||t.AudioContext||(t.AudioContext=t.webkitAudioContext)}var Mc=Object.freeze({__proto__:null,shimLocalStreamsAPI:Td,shimRemoteStreamsAPI:Sd,shimCallbacksAPI:Id,shimGetUserMedia:bd,shimConstraints:wd,shimRTCIceServerUrls:Od,shimTrackEventTransceiver:Nd,shimCreateOfferLegacy:Ad,shimAudioContext:Md});function jr(t){if(!t.RTCIceCandidate||t.RTCIceCandidate&&"foundation"in t.RTCIceCandidate.prototype)return;const e=t.RTCIceCandidate;t.RTCIceCandidate=function(n){if(typeof n=="object"&&n.candidate&&n.candidate.indexOf("a=")===0&&((n=JSON.parse(JSON.stringify(n))).candidate=n.candidate.substr(2)),n.candidate&&n.candidate.length){const r=new e(n),i=oe.parseCandidate(n.candidate),o=Object.assign(r,i);return o.toJSON=function(){return{candidate:o.candidate,sdpMid:o.sdpMid,sdpMLineIndex:o.sdpMLineIndex,usernameFragment:o.usernameFragment}},o}return new e(n)},t.RTCIceCandidate.prototype=e.prototype,wn(t,"icecandidate",n=>(n.candidate&&Object.defineProperty(n,"candidate",{value:new t.RTCIceCandidate(n.candidate),writable:"false"}),n))}function jn(t,e){if(!t.RTCPeerConnection)return;"sctp"in t.RTCPeerConnection.prototype||Object.defineProperty(t.RTCPeerConnection.prototype,"sctp",{get(){return this._sctp===void 0?null:this._sctp}});const n=function(c){if(!c||!c.sdp)return!1;const d=oe.splitSections(c.sdp);return d.shift(),d.some(l=>{const h=oe.parseMLine(l);return h&&h.kind==="application"&&h.protocol.indexOf("SCTP")!==-1})},r=function(c){const d=c.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);if(d===null||d.length<2)return-1;const l=parseInt(d[1],10);return l!=l?-1:l},i=function(c){let d=65536;return e.browser==="firefox"&&(d=e.version<57?c===-1?16384:2147483637:e.version<60?e.version===57?65535:65536:2147483637),d},o=function(c,d){let l=65536;e.browser==="firefox"&&e.version===57&&(l=65535);const h=oe.matchPrefix(c.sdp,"a=max-message-size:");return h.length>0?l=parseInt(h[0].substr(19),10):e.browser==="firefox"&&d!==-1&&(l=2147483637),l},s=t.RTCPeerConnection.prototype.setRemoteDescription;t.RTCPeerConnection.prototype.setRemoteDescription=function(){if(this._sctp=null,e.browser==="chrome"&&e.version>=76){const{sdpSemantics:c}=this.getConfiguration();c==="plan-b"&&Object.defineProperty(this,"sctp",{get(){return this._sctp===void 0?null:this._sctp},enumerable:!0,configurable:!0})}if(n(arguments[0])){const c=r(arguments[0]),d=i(c),l=o(arguments[0],c);let h;h=d===0&&l===0?Number.POSITIVE_INFINITY:d===0||l===0?Math.max(d,l):Math.min(d,l);const a={};Object.defineProperty(a,"maxMessageSize",{get:()=>h}),this._sctp=a}return s.apply(this,arguments)}}function $n(t){if(!t.RTCPeerConnection||!("createDataChannel"in t.RTCPeerConnection.prototype))return;function e(r,i){const o=r.send;r.send=function(){const s=arguments[0],c=s.length||s.size||s.byteLength;if(r.readyState==="open"&&i.sctp&&c>i.sctp.maxMessageSize)throw new TypeError("Message too large (can send a maximum of "+i.sctp.maxMessageSize+" bytes)");return o.apply(r,arguments)}}const n=t.RTCPeerConnection.prototype.createDataChannel;t.RTCPeerConnection.prototype.createDataChannel=function(){const r=n.apply(this,arguments);return e(r,this),r},wn(t,"datachannel",r=>(e(r.channel,r.target),r))}function es(t){if(!t.RTCPeerConnection||"connectionState"in t.RTCPeerConnection.prototype)return;const e=t.RTCPeerConnection.prototype;Object.defineProperty(e,"connectionState",{get(){return{completed:"connected",checking:"connecting"}[this.iceConnectionState]||this.iceConnectionState},enumerable:!0,configurable:!0}),Object.defineProperty(e,"onconnectionstatechange",{get(){return this._onconnectionstatechange||null},set(n){this._onconnectionstatechange&&(this.removeEventListener("connectionstatechange",this._onconnectionstatechange),delete this._onconnectionstatechange),n&&this.addEventListener("connectionstatechange",this._onconnectionstatechange=n)},enumerable:!0,configurable:!0}),["setLocalDescription","setRemoteDescription"].forEach(n=>{const r=e[n];e[n]=function(){return this._connectionstatechangepoly||(this._connectionstatechangepoly=i=>{const o=i.target;if(o._lastConnectionState!==o.connectionState){o._lastConnectionState=o.connectionState;const s=new Event("connectionstatechange",i);o.dispatchEvent(s)}return i},this.addEventListener("iceconnectionstatechange",this._connectionstatechangepoly)),r.apply(this,arguments)}})}function ts(t,e){if(!t.RTCPeerConnection||e.browser==="chrome"&&e.version>=71||e.browser==="safari"&&e.version>=605)return;const n=t.RTCPeerConnection.prototype.setRemoteDescription;t.RTCPeerConnection.prototype.setRemoteDescription=function(r){if(r&&r.sdp&&r.sdp.indexOf(`
- a=extmap-allow-mixed`)!==-1){const i=r.sdp.split(`
- `).filter(o=>o.trim()!=="a=extmap-allow-mixed").join(`
- `);t.RTCSessionDescription&&r instanceof t.RTCSessionDescription?arguments[0]=new t.RTCSessionDescription({type:r.type,sdp:i}):r.sdp=i}return n.apply(this,arguments)}}function $r(t,e){if(!t.RTCPeerConnection||!t.RTCPeerConnection.prototype)return;const n=t.RTCPeerConnection.prototype.addIceCandidate;n&&n.length!==0&&(t.RTCPeerConnection.prototype.addIceCandidate=function(){return arguments[0]?(e.browser==="chrome"&&e.version<78||e.browser==="firefox"&&e.version<68||e.browser==="safari")&&arguments[0]&&arguments[0].candidate===""?Promise.resolve():n.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())})}var Pf=Object.freeze({__proto__:null,shimRTCIceCandidate:jr,shimMaxMessageSize:jn,shimSendThrowTypeError:$n,shimConnectionState:es,removeExtmapAllowMixed:ts,shimAddIceCandidateNullOrEmpty:$r});const Lf=function({window:t}={},e={shimChrome:!0,shimFirefox:!0,shimEdge:!0,shimSafari:!0}){const n=ua,r=function(o){const s={browser:null,version:null};if(o===void 0||!o.navigator)return s.browser="Not a browser.",s;const{navigator:c}=o;if(c.mozGetUserMedia)s.browser="firefox",s.version=Fn(c.userAgent,/Firefox\/(\d+)\./,1);else if(c.webkitGetUserMedia||o.isSecureContext===!1&&o.webkitRTCPeerConnection&&!o.RTCIceGatherer)s.browser="chrome",s.version=Fn(c.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else if(c.mediaDevices&&c.userAgent.match(/Edge\/(\d+).(\d+)$/))s.browser="edge",s.version=Fn(c.userAgent,/Edge\/(\d+).(\d+)$/,2);else{if(!o.RTCPeerConnection||!c.userAgent.match(/AppleWebKit\/(\d+)\./))return s.browser="Not a supported browser.",s;s.browser="safari",s.version=Fn(c.userAgent,/AppleWebKit\/(\d+)\./,1),s.supportsUnifiedPlan=o.RTCRtpTransceiver&&"currentDirection"in o.RTCRtpTransceiver.prototype}return s}(t),i={browserDetails:r,commonShim:Pf,extractVersion:Fn,disableLog:Nf,disableWarnings:Af};switch(r.browser){case"chrome":if(!Ic||!Qo||!e.shimChrome)return n("Chrome shim is not included in this adapter release."),i;if(r.version===null)return n("Chrome shim can not determine version, not shimming."),i;n("adapter.js shimming chrome."),i.browserShim=Ic,$r(t,r),td(t,r),nd(t),Qo(t,r),rd(t),cd(t,r),id(t),od(t),sd(t),ud(t,r),jr(t),es(t),jn(t,r),$n(t),ts(t,r);break;case"firefox":if(!Ac||!Zo||!e.shimFirefox)return n("Firefox shim is not included in this adapter release."),i;n("adapter.js shimming firefox."),i.browserShim=Ac,$r(t,r),fd(t,r),Zo(t,r),pd(t),_d(t),gd(t),md(t),vd(t),yd(t),Cd(t),Ed(t),Rd(t),jr(t),es(t),jn(t,r),$n(t);break;case"edge":if(!Nc||!Xo||!e.shimEdge)return n("MS edge shim is not included in this adapter release."),i;n("adapter.js shimming edge."),i.browserShim=Nc,dd(t),ld(t),Xo(t,r),hd(t),jn(t,r),$n(t);break;case"safari":if(!Mc||!e.shimSafari)return n("Safari shim is not included in this adapter release."),i;n("adapter.js shimming safari."),i.browserShim=Mc,$r(t,r),Od(t),Ad(t),Id(t),Td(t),Sd(t),Nd(t),bd(t),Md(t),jr(t),jn(t,r),$n(t),ts(t,r);break;default:n("Unsupported browser!")}return i}({window:typeof window=="undefined"?void 0:window});var Tt,Te,_e;(function(t){t.FPS_10="FPS_10",t.FPS_15="FPS_15",t.FPS_24="FPS_24",t.FPS_30="FPS_30"})(Tt||(Tt={})),function(t){t.W176_H132="W176_H132",t.W176_H144="W176_H144",t.W256_H144="W256_H144",t.W320_H180="W320_H180",t.W240_H240="W240_H240",t.W320_H240="W320_H240",t.W480_H360="W480_H360",t.W640_H360="W640_H360",t.W480_H480="W480_H480",t.W640_H480="W640_H480",t.W720_H480="W720_H480",t.W1280_H720="W1280_H720",t.W1920_H1080="W1920_H1080"}(Te||(Te={})),function(t){t[t.AUDIO_ONLY=0]="AUDIO_ONLY",t[t.VIDEO_ONLY=1]="VIDEO_ONLY",t[t.AUDIO_VIDEO=2]="AUDIO_VIDEO"}(_e||(_e={}));const Pc={[Te.W176_H132]:{width:176,height:132,maxBitrate:150,minBitrate:80},[Te.W176_H144]:{width:176,height:144,maxBitrate:160,minBitrate:80},[Te.W256_H144]:{width:256,height:144,maxBitrate:240,minBitrate:120},[Te.W320_H180]:{width:320,height:180,maxBitrate:280,minBitrate:120},[Te.W240_H240]:{width:240,height:240,maxBitrate:280,minBitrate:120},[Te.W320_H240]:{width:320,height:240,maxBitrate:400,minBitrate:120},[Te.W480_H360]:{width:480,height:360,maxBitrate:650,minBitrate:150},[Te.W640_H360]:{width:640,height:360,maxBitrate:800,minBitrate:180},[Te.W480_H480]:{width:480,height:480,maxBitrate:800,minBitrate:180},[Te.W640_H480]:{width:640,height:480,maxBitrate:900,minBitrate:200},[Te.W720_H480]:{width:720,height:480,maxBitrate:1e3,minBitrate:200},[Te.W1280_H720]:{width:1280,height:720,maxBitrate:2200,minBitrate:250},[Te.W1920_H1080]:{width:1920,height:1080,maxBitrate:4e3,minBitrate:400}},Pd=(t,e)=>{const n=t*e;let r=Number.MAX_VALUE,i=null;for(const o in Pc){const s=Pc[o],c=Math.abs(s.width*s.height-n);c<r&&(i=s,r=c)}return i},Lc={10:1,15:1,24:1.5,30:1.5},Ld=t=>{let e=Number.MAX_VALUE,n=1;for(const r in Lc){const i=Math.abs(t-parseInt(r));i<e&&(e=i,n=Lc[r])}return n},da={getCameras:()=>j(void 0,void 0,void 0,function*(){return(yield navigator.mediaDevices.enumerateDevices()).filter(t=>t.kind==="videoinput")}),getMicrophones:()=>j(void 0,void 0,void 0,function*(){return(yield navigator.mediaDevices.enumerateDevices()).filter(t=>t.kind==="audioinput")}),getSpeakers:()=>j(void 0,void 0,void 0,function*(){return(yield navigator.mediaDevices.enumerateDevices()).filter(t=>t.kind==="audiooutput")})};class la extends cr{constructor(e,n,r,i,o){super(),this._tag=e,this._userId=n,this._kind=r,this._isLocalTrack=i,this._roomId=o,this._localMuted=!1,this._remoteMuted=!1,this._streamId=[this._userId||this._roomId,this._tag].join("_"),this._id=[this._streamId,this.isAudioTrack()?0:1].join("_")}getStreamId(){return this._streamId}getTrackId(){return this._id}getUserId(){return this._userId}__innerGetMediaStreamTrack(){return this._msTrack}getTag(){return this._tag}isLocalTrack(){return this._isLocalTrack}isVideoTrack(){return this._kind==="video"}isAudioTrack(){return this._kind==="audio"}isReady(){var e;return((e=this._msTrack)===null||e===void 0?void 0:e.readyState)==="live"}__innerSetMediaStreamTrack(e){this._msTrack=e,this._setLocalMuted(this._localMuted);const n=this._msStream=this._msStream||new MediaStream,r=n.getTracks()[0];r&&n.removeTrack(r),e?n.addTrack(e):this._element&&(this._element.pause(),this._element.srcObject=null)}_setLocalMuted(e){this._msTrack&&(this._msTrack.enabled=!e),this._localMuted=e}mute(){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,n){return j(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}`),n==null?void 0:n.volume){if(!be(n==null?void 0:n.volume))return P.error(`${n==null?void 0:n.volume} is not a number, the valid range of options.volume is 0-100`),{code:M.PARAMS_ERROR};(n==null?void 0:n.volume)<0&&(n.volume=0,P.warn("the valid range of options.volume is 0-100, the value of volume has been set 0")),(n==null?void 0:n.volume)>100&&(n.volume=100,P.warn("the valid range of options.volume is 0-100, the value of volume has been set 100"))}if((n==null?void 0:n.audioDeviceId)&&!(yield da.getSpeakers()).map(i=>i.deviceId).includes(n.audioDeviceId))return P.error(`the options.audioDeviceId is invalid --> ${n.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 o;P.debug(`HTMLMediaElement onloadstart -> id: ${(o=i.target)===null||o===void 0?void 0:o.id}, trackId: ${this._id}`)},this._element.ondurationchange=i=>{var o;P.debug(`HTMLMediaElement ondurationchange -> id: ${(o=i.target)===null||o===void 0?void 0:o.id}, trackId: ${this._id}`)},this._element.onloadedmetadata=i=>{var o;P.debug(`HTMLMediaElement onloadedmetadata -> id: ${(o=i.target)===null||o===void 0?void 0:o.id}, trackId: ${this._id}`)},this._element.onloadeddata=i=>{var o;P.debug(`HTMLMediaElement onloadeddata -> id: ${(o=i.target)===null||o===void 0?void 0:o.id}, trackId: ${this._id}`)},this._element.onabort=i=>{var o;P.info(`HTMLMediaElement onabort -> id: ${(o=i.target)===null||o===void 0?void 0:o.id}, trackId: ${this._id}`)},this._element.oncanplay=i=>{var o;P.info(`HTMLMediaElement oncanplay -> id: ${(o=i.target)===null||o===void 0?void 0:o.id}, trackId: ${this._id}`)},this._element.onvolumechange=i=>{var o;const s=Math.floor(100*((o=i.target)===null||o===void 0?void 0:o.volume));P.info(`HTMLMediaElement onvolumechange -> volume: ${s}, 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||!(n==null?void 0:n.volume)&&(n==null?void 0:n.volume)!==0||(this._element.volume=(n==null?void 0:n.volume)/100);try{(n==null?void 0:n.audioDeviceId)&&!r?yield this._element.setSinkId(n.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 ge extends la{constructor(e,n,r,i){super(e,n,r,!0),this._isPublished=!1,this.__innerSetMediaStreamTrack(i),i.onended=()=>{i.onended=null,this.emit(ge.EVENT_LOCAL_TRACK_END,this),this.removeAll(ge.EVENT_LOCAL_TRACK_END)}}_setLocalMuted(e){const n=this._localMuted!==e;super._setLocalMuted(e),this._remoteMuted=this._localMuted,n&&this.emit(ge.__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(ge.__INNER_EVENT_DESTROY__,this)}setBitrate(e=0,n=0,r=0){!be(e)||!be(n)||!be(r)||e<=0||n<=0||e<n?P.error("setBitrate params error ->"):this._bitrateInfo={max:e,min:n,start:r}}getBitrate(){var e,n;const{min:r,max:i}=this._msTrack?Bf(this._msTrack):{min:0,max:0};return{min:((e=this._bitrateInfo)===null||e===void 0?void 0:e.min)||r,max:((n=this._bitrateInfo)===null||n===void 0?void 0:n.max)||i}}}ge.EVENT_LOCAL_TRACK_END="local-track-end",ge.__INNER_EVENT_MUTED_CHANGE__="inner-muted-change",ge.__INNER_EVENT_DESTROY__="inner-destroy";class ns extends ge{constructor(e,n,r){super(e,n,"audio",r)}setBitrate(e,n,r){P.warn("`setBitrate` invalid for audio track")}getBitrate(){return{start:32,max:32,min:32}}}class mn extends ge{constructor(e,n,r,i=!1){super(e,n,"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 _n extends ge{constructor(e,n,r,i,o){super(e,n,r,i),this._resource=o,_n.__innerSetMapping(this.getTrackId(),o)}static __innerSetMapping(e,n){const r=this._mapping.get(n)||[];r.push(e),this._mapping.set(n,r)}static __innerRemoveMapping(e,n){var r,i;const o=(r=this._mapping.get(n))===null||r===void 0?void 0:r.filter(s=>s!==e);o&&o.length>0?this._mapping.set(n,o):(this._mapping.delete(n),n.pause(),n.src="",(i=n.parentNode)===null||i===void 0||i.removeChild(n))}destroy(){this.isAudioTrack()&&this.mute(),_n.__innerRemoveMapping(this.getTrackId(),this._resource),super.destroy()}}_n._mapping=new Map;class kf extends _n{constructor(e,n,r,i){super(e,n,"video",r,i)}}class Uf extends _n{constructor(e,n,r,i){super(e,n,"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 kc extends ns{}class Uc extends mn{}class Df extends mn{}class He extends la{constructor(e,n,r,i){super(e,n,r,!1,i),this._isSubscribed=!1}__innerSetRemoteMuted(e){this._remoteMuted=e}__innerSetSubscribed(e){this._isSubscribed=e}isSubscribed(){return this._isSubscribed}}class kt extends He{constructor(e,n,r){super(e,n,"audio",r)}}class Ut extends He{constructor(e,n,r){super(e,n,"video",r)}}const Lr=(t,e)=>({name:t,content:JSON.stringify({uris:e,ignore:!0})}),Kt=t=>JSON.stringify(t),Mt=t=>/^[a-zA-Z\d-=]+$/g.test(t),xf=location.protocol!=="http:"||["localhost","127.0.0.1"].includes(location.hostname),co=t=>{if(t===void 0)return 0;if(be(t))return t;const e=t;return e.exact||e.ideal||e.max||0},ha=t=>{const e=t.getConstraints();return{width:co(e.width),height:co(e.height),frameRate:co(e.frameRate)}},Bf=t=>{const{width:e,height:n,frameRate:r}=ha(t),i=Pd(e,n),o=Ld(r);return{min:i.minBitrate*o,max:i.maxBitrate*o}},pe=t=>[t.msid,t.mediaType].join("_"),Ye=t=>{const e=t.split("_");return{mediaType:parseInt(e.pop()),tag:e.pop(),userId:e.join("_")}},uo=(t,e)=>[t,e].join("_"),kr=t=>t.map(e=>Object.assign({},e)),Kr=(t,e,n=!1)=>{t=t.slice();const r=[],i=[],o=[];return e.forEach(s=>{const c=pe(s);let d=t.findIndex(h=>pe(h)===c);if(n&&(d=t.findIndex(h=>h.uri===s.uri)),d===-1)return void r.push(s);const l=t[d];l.uri!==s.uri?r.push(s):l.state!==s.state&&o.push(s),t.splice(d,1)}),i.push(...t),{publishedList:r,unpublishedList:i,modifiedList:o}},Vf=()=>{let t="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){const n=16*Math.random()|0;return(e==="x"?n:3&n|8).toString(16)});return t=t.replace(/-/g,"")+"0",t=parseInt(t,16),t=(e=>{const n="0123456789abcdefghigklmnopqrstuvwxyzABCDEFGHIGKLMNOPQRSTUVWXYZ+/".split(""),r=n.length+1;let i=+e;const o=[];do{const s=i%r;i=(i-s)/r,o.unshift(n[s])}while(i);return o.join("")})(t),t.length>22&&(t=t.slice(0,22)),t},St=t=>{const[e,n]=t.split("_").map(r=>parseInt(r.replace(/[^\d]/g,"")));return{width:e,height:n}},ln=t=>!!Te[t],rs=t=>!!Tt[t],It=t=>parseInt(t.replace("FPS_","")),lt=(()=>{const{browser:t,version:e,supportsUnifiedPlan:n}=Lf.browserDetails;return{browser:t,version:e,supportsUnifiedPlan:n!==!1}})();function kd(){return"captureStream"in HTMLMediaElement.prototype||"mozCaptureStream"in HTMLMediaElement.prototype}function Ud(){return"mediaDevices"in navigator&&"getDisplayMedia"in navigator.mediaDevices}const is=t=>Object.prototype.toString.call(t)==="[object Null]",qr=t=>t.type===1,os=t=>{const e={},n=Object.keys(t.users);return n.length&&n.forEach(r=>{const i=[],o=t.users[r];if(o.uris)try{i.push(...JSON.parse(o.uris))}catch{P.warn(`invalid user data -> userId: ${r}, userData: ${o}`)}e[r]=i}),e};var de,ci;(function(t){t.PUBLISH="RCRTC:PublishResource",t.UNPUBLISH="RCRTC:UnpublishResource",t.MODIFY="RCRTC:ModifyResource",t.TOTAL_CONTENT_RESOURCE="RCRTC:TotalContentResources",t.STATE="RCRTC:state",t.ROOM_NOTIFY="RCRTC:RoomNtf",t.USER_NOTIFY="RCRTC:UserNtf",t.KICK="RCRTC:kick",t.PK_INVITE="RCRTC:invite",t.PK_INVITE_TIMEOUT="RCRTC:inviteTimeout",t.PK_CANCEL_INVITE="RCRTC:cancelInvite",t.PK_INVITE_ANSWER="RCRTC:answerInvite",t.PK_END="RCRTC:endInvite",t.OTHER_ROOM_OFFLINE="RCRTC:otherRoomOffline"})(de||(de={})),function(t){t.SUCCESS="Success",t.FAIL="Fail"}(ci||(ci={}));class Ff{constructor(e,n,r,i=1e4){this._roomId=e,this._roomMode=n,this._context=r,this._gap=i,this._latestTimestamp=Date.now(),this._timer=null}start(){return j(this,void 0,void 0,function*(){this._timer||(this._timer=setInterval(this._loop.bind(this),this._gap))})}_loop(){var e,n,r;return j(this,void 0,void 0,function*(){const i=yield new Promise(s=>{this._context.rtcPing(this._roomId,this._roomMode).then(s).catch(c=>{P.error(`rtcping receive unknown error -> ${c}`),s(O.UNKNOWN)}),setTimeout(s,1e4,O.TIMEOUT)}),o=Date.now();if(i===O.SUCCESS)return this._latestTimestamp=o,void((e=this.onPingResult)===null||e===void 0||e.call(this,ci.SUCCESS));(n=this.onPingResult)===null||n===void 0||n.call(this,ci.FAIL),P.warn(`rtcping failed -> code: ${i}`),(i===40003||o-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 ut;(function(t){t[t.NORMAL=1]="NORMAL",t[t.TINY=2]="TINY"})(ut||(ut={}));const Dc=(t,e)=>Math.round(8*e/t),xc=(t,e=2)=>{const n=10**e;return Math.round(t*n)/n},Dt=(t,e=2)=>{t>1&&(t/=32767);const n=10**e;return Math.ceil(t*n)},Ur=(t,e,n,r)=>{if(e===0)return 0;if(!n||!r)return xc(t/e,3);const i=e-r;if(i===0)return 0;const o=t-n;return o<0||i<0?0:xc(o/i,3)},Dd=t=>{const{jitter:e,rtt:n,packetsLostRate:r}=t;return!is(e)||!is(n)||r!==0};class fa{constructor(e,n){this._rtcPeerConn=e,this._sdpSemantics=n,this._latestPacketsSent={},this._latestBytesSent={},this._latestBytesRecv={},this._latestPacketsRecv={}}updateBytesSent(e,n,r){let i,o;if(this._latestBytesSent[e]&&n<this._latestBytesSent[e].bytesSent&&this.clearLatestpacketsSent([e]),this._latestBytesSent[e]){const{bytesSent:s,timestamp:c}=this._latestBytesSent[e];i=n-s,o=r-c,this._latestBytesSent[e]={bytesSent:n,timestamp:r}}else i=n,o=1e3,this._latestBytesSent[e]={bytesSent:n,timestamp:r};return Dc(o,i)}updateBytesRecv(e,n,r){let i,o;if(this._latestBytesRecv[e]&&n<this._latestBytesRecv[e].bytesRecv&&this.clearLatestPacketsRecv([e]),this._latestBytesRecv[e]){const{bytesRecv:s,timestamp:c}=this._latestBytesRecv[e];i=n-s,o=r-c,this._latestBytesRecv[e]={bytesRecv:n,timestamp:r}}else i=n,o=1e3,this._latestBytesRecv[e]={bytesRecv:n,timestamp:r};return Dc(o,i)}updateSenderPacketsLost(e,n,r){let i;if(Object.prototype.hasOwnProperty.call(this._latestPacketsSent[e],"packetsSent")){const{packetsLost:o,packetsSent:s}=this._latestPacketsSent[e];i=Ur(n,r,o,s),this._latestPacketsSent[e].packetsLost=n,this._latestPacketsSent[e].packetsSent=o===n?s:r}else i=Ur(n,r),this._latestPacketsSent[e].packetsLost=n,this._latestPacketsSent[e].packetsSent=r;return i}updateReceiverPacketsLost(e,n,r){let i;if(this._latestPacketsRecv[e]){const{packetsLost:o,packetsRecv:s}=this._latestPacketsRecv[e];i=Ur(n,r+n,o,s+o)}else i=Ur(n,r);return this._latestPacketsRecv[e]={packetsLost:n,packetsRecv:r},i}clearLatestpacketsSent(e){e.forEach(n=>{if(parseInt(n.split("_").pop())===_e.VIDEO_ONLY){const r=`${n}_tiny`;delete this._latestPacketsSent[r],delete this._latestBytesSent[r]}delete this._latestPacketsSent[n],delete this._latestBytesSent[n]})}clearLatestPacketsRecv(e){e.forEach(n=>{delete this._latestPacketsRecv[n],delete this._latestBytesRecv[n]})}parseRTCStatsReport(e){const n=e.keys(),r={};let i=n.next();for(;!i.done;){const o=i.value,s=e.get(o);/^RTCCodec_/.test(o)||(r[o]=s),i=n.next()}return r}formatRCRTCStateReport(e){return{senders:[],receivers:[]}}getAudioLevelList(e){return[]}getResourceIdByParseSdp(e){var n,r;const i=e.ssrc,o=e.kind||e.mediaType,s=(n=this._rtcPeerConn.currentLocalDescription)===null||n===void 0?void 0:n.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=s==null?void 0:s.split(`\r
- 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}_${o==="video"?1:0}`;const f=c==null?void 0:c.split(`\r
- 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}_${o==="video"?1:0}`}isValidSender(e){var n;const r=(n=this._rtcPeerConn.currentLocalDescription)===null||n===void 0?void 0:n.sdp,{ssrc:i}=e;return!(r==null?void 0:r.split(`\r
- m=`).some(o=>o.includes(i)&&o.includes("a=inactive")))}isValidReceiver(e){var n;const r=(n=this._rtcPeerConn.currentRemoteDescription)===null||n===void 0?void 0:n.sdp,{ssrc:i}=e;return!(r==null?void 0:r.split(`\r
- m=`).some(o=>o.includes(i)&&o.includes("a=inactive")))}}class Hf extends fa{formatRCRTCStateReport(e){const n={senders:[],receivers:[]},r=Math.floor(e.RTCPeerConnection.timestamp);n.timestamp=r;const i=Object.keys(e);let o=0,s=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:N,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 K=e[m];let R=null,T=null,A=0;K&&(R=K.jitter,T=K.roundTripTime,A=K.packetsLost),o+=A;const k=this.getResourceIdByParseSdp(h),U=p?e[p].audioLevel:e[y].audioLevel;let F=null;!this._latestPacketsSent[k]&&(this._latestPacketsSent[k]={}),K?F=this.updateSenderPacketsLost(k,A,_):this._latestPacketsSent[k].crtPacketsSent=_;let H=this.updateBytesSent(k,v,r);H<0&&(H=0),s+=H,n.senders.push({id:a,trackId:k,kind:u,packetsLostRate:F,remoteResource:!1,audioLevel:U||U===0?Dt(U):null,frameWidth:w,frameHeight:V,frameRate:E,bitrate:H,jitter:R&&Math.round(1e3*R),rtt:T,encoderImplementation:C,pliCount:b,nackCount:N,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=n.senders.filter(m=>m.id===h)[0];if(p&&!Dd(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:N,frameHeight:S,audioLevel:E}=h;v==="video"?N||S||(N=e[a].frameWidth,S=e[a].frameHeight):E||(E=e[a].audioLevel),o+=u;const w=this.getResourceIdByParseSdp(h),V=this.updateReceiverPacketsLost(w,u,f);let K=this.updateBytesRecv(w,m,r);K<0&&(K=0),c+=K,n.receivers.push({trackId:w,kind:v,packetsLostRate:V,remoteResource:!0,audioLevel:E||E===0?Dt(E):null,frameWidth:N,frameHeight:S,frameRate:_,bitrate:K,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,N=e[_],{ip:S,port:E,protocol:w}=N;n.iceCandidatePair={IP:y,port:C,networkType:b,remoteIP:S,remotePort:E,protocol:w,bitrateRecv:c,bitrateSend:s,rtt:1e3*p,availableOutgoingBitrate:u,availableIncomingBitrate:f,totalPacketsLost:o},n.receivers.forEach(V=>{V.rtt=p})}}return n}getAudioLevelList(e){const n=[],r=Object.keys(e);return r.filter(i=>/^RTCOutboundRTPAudioStream_/.test(i)).forEach(i=>{var o;const s=e[i];if(this._sdpSemantics==="unified-plan"&&!this.isValidSender(s))return;const{mediaSourceId:c,trackId:d}=s,l=this.getResourceIdByParseSdp(s),h=c&&e[c]?e[c].audioLevel:((o=e[d])===null||o===void 0?void 0:o.audioLevel)||null;n.push({trackId:l,audioLevel:h||h===0?Dt(h):null})}),r.filter(i=>/^RTCInboundRTPAudioStream_/.test(i)).forEach(i=>{const o=e[i];if(this._sdpSemantics==="unified-plan"&&!this.isValidReceiver(o))return;const{trackId:s}=o,c=o.audioLevel||e[s].audioLevel,d=this.getResourceIdByParseSdp(o);n.push({trackId:d,audioLevel:c||c===0?Dt(c):null})}),n}}class jf extends fa{formatRCRTCStateReport(e){const n=+new Date,r={senders:[],receivers:[],timestamp:n};let i=0,o=0,s=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:N}=y?e[y]:{jitter:null,roundTripTime:null,packetsLost:0},S=this.getResourceIdByParseSdp(d);i+=N;let E=null;!this._latestPacketsSent[S]&&(this._latestPacketsSent[S]={}),y?E=this.updateSenderPacketsLost(S,N,f):this._latestPacketsSent[S].crtPacketsSent=f;let w=0;a==="video"?p&&(w=Math.floor(p/1e3)):w=this.updateBytesSent(S,u,n),w<0&&(w=0),o+=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&&Dd(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 N=this.updateReceiverPacketsLost(b,a,f);let S=0;_==="video"?v&&(S=Math.floor(v/1e3)):S=this.updateBytesRecv(b,u,n),S<0&&(S=0),s+=S,r.receivers.push({trackId:b,kind:_,packetsLostRate:N,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:s,bitrateSend:o,rtt:null,availableOutgoingBitrate:null,availableIncomingBitrate:null,totalPacketsLost:i}}}return r.iceCandidatePair&&(r.iceCandidatePair.bitrateSend=o),r.iceCandidatePair&&(r.iceCandidatePair.bitrateRecv=s),r}getAudioLevelList(e){const n=[];for(const r in e){const i=e[r],o=i.type;if(o==="outbound-rtp"){if(this._sdpSemantics==="unified-plan"&&!this.isValidSender(i))continue;const{kind:s}=i;if(s==="video")continue;const c=this.getResourceIdByParseSdp(i);n.push({trackId:c,audioLevel:null})}if(o==="inbound-rtp"){if(this._sdpSemantics==="unified-plan"&&!this.isValidReceiver(i))continue;const{kind:s}=i;if(s==="video")continue;const c=this.getResourceIdByParseSdp(i);n.push({trackId:c,audioLevel:null})}}return n}}class $f extends fa{formatRCRTCStateReport(e){const n={senders:[],receivers:[]},r=Math.floor(e.RTCPeerConnection.timestamp);n.timestamp=r;const i=Object.keys(e);let o=0,s=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:N}=h;if(!v)return;const{audioLevel:S,frameHeight:E,frameWidth:w}=e[v];let V=this.updateBytesSent(a,_,r);V<0&&(V=0),s+=V,n.senders.push({trackId:a,kind:u,packetsLostRate:null,remoteResource:!1,audioLevel:S||S===0?Dt(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:N,audioLevel:S}=e[a];o+=u;const E=this.updateReceiverPacketsLost(C,u,f);let w=this.updateBytesRecv(C,m,r);w<0&&(w=0),c+=w,n.receivers.push({trackId:C,kind:_,packetsLostRate:E,remoteResource:!0,audioLevel:S||S===0?Dt(S):null,frameWidth:N,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:N,port:S,protocol:E}=b;n.iceCandidatePair={IP:y||null,port:C,networkType:null,remoteIP:N,remotePort:S,protocol:E,bitrateRecv:c,bitrateSend:s,rtt:1e3*p,availableOutgoingBitrate:u,availableIncomingBitrate:f,totalPacketsLost:o},n.receivers.forEach(w=>{w.rtt=p})}}return n}getAudioLevelList(e){const n=[],r=Object.keys(e);return r.filter(i=>/^RTCOutboundRTP(Video|Audio)Stream_/.test(i)).forEach(i=>{const o=e[i];if(this._sdpSemantics==="unified-plan"&&!this.isValidSender(o))return;const{trackId:s,mediaType:c}=o;if(c==="video")return;const d=this.getResourceIdByParseSdp(o),l=e[s];n.push({trackId:d,audioLevel:l||l===0?Dt(l):null})}),r.filter(i=>/^RTCInboundRTP(Video|Audio)Stream_/.test(i)).forEach(i=>{const o=e[i];if(this._sdpSemantics==="unified-plan"&&!this.isValidReceiver(o))return;const{trackId:s,mediaType:c}=o;if(!s||c==="video")return;const{audioLevel:d}=e[s],l=this.getResourceIdByParseSdp(o);n.push({trackId:l,audioLevel:d||d===0?Dt(d):null})}),n}}class On{constructor(e){this._peer=e,this._outboundStreams={}}static setSdpSemantics(e){const{browser:n,version:r,supportsUnifiedPlan:i}=lt;i?/chrome/i.test(n)?this._sdpSemantics=r>92?"unified-plan":r<72?"plan-b":e:/firefox/i.test(n)?this._sdpSemantics="unified-plan":/safari/i.test(n)?this._sdpSemantics=r<12?"plan-b":"unified-plan":this._sdpSemantics="unified-plan":this._sdpSemantics="plan-b"}static getSdpSemantics(){return On._sdpSemantics}getOutboundVideoInfo(){const e=[];for(const n in this._outboundStreams){const r=this._outboundStreams[n].getVideoTracks()[0];if(!r)continue;const i=/_tiny$/.test(n),{width:o,height:s}=ha(r);e.push({trackId:r.id,simulcast:i?ut.TINY:ut.NORMAL,resolution:`${o}x${s}`})}return e}setRemoteAnswer(e){return j(this,void 0,void 0,function*(){e=e.replace(/\s+\r\n/g,`\r
- `);try{yield this._peer.setRemoteDescription({type:"answer",sdp:e})}catch(n){return P.error(n),M.SET_REMOTE_DESCRIPTION_FAILED}return M.SUCCESS})}getStatParsr(e,n){return/chrome/i.test(lt.browser)?new Hf(e,n):/Firefox/i.test(lt.browser)?new jf(e,n):/Safari/i.test(lt.browser)?new $f(e,n):null}}class Kf extends On{constructor(){super(...arguments),this.senders={},this._localTracks=[]}addLocalTrack(e){this._localTracks.includes(e)||this._localTracks.push(e);const n=e.getStreamId(),r=e.__innerGetMediaStreamTrack(),i=this._outboundStreams[n]||(this._outboundStreams[n]=new MediaStream);i.getTracks().forEach(c=>{c.kind===r.kind&&i.removeTrack(c)}),i.addTrack(r);const o=e.getTrackId(),s=this.senders[o];s?s.replaceTrack(r):this.senders[o]=this._peer.addTrack(r,i)}removeLocalTrack(e){const n=this._localTracks.findIndex(o=>o===e);n>=0&&this._localTracks.splice(n,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,n){}setBitrate(e,n,r){this._maxBitrate=e,this._minBitrate=n,this._startBitrate=r||.7*e}createOffer(e){return j(this,void 0,void 0,function*(){const n=yield this._peer.createOffer({iceRestart:e,offerToReceiveAudio:!0,offerToReceiveVideo:!0});for(const r in this._outboundStreams){const i=this._outboundStreams[r].id;n.sdp=n.sdp.replace(new RegExp(i,"g"),r)}return yield this._peer.setLocalDescription(n),{type:"offer",semantics:"plan-b",sdp:n.sdp}})}setRemoteAnswer(e){let n=0,r=0;this._localTracks.forEach(c=>{const{min:d,max:l}=c.getBitrate();r+=d,n+=l}),n=this._maxBitrate&&this._maxBitrate>0?Math.min(n,this._maxBitrate):n,r=this._minBitrate&&this._minBitrate>0?Math.max(r,this._minBitrate):r;const i=this._startBitrate||Math.round(.7*n),o=`b=AS:${n}`;e=e.replace(/[\r\n]+m=video[^\r\n]+/,c=>`${c}\r
- ${o}`);const s=[`;x-google-min-bitrate=${r}`,`;x-google-max-bitrate=${n}`,`;x-google-start-bitrate=${i}`].join("");return e=e.replace(/[\r\n]+[^\r\n]+profile-level-id[^\r\n]+/g,c=>c+s),super.setRemoteAnswer(e)}}class qf extends On{constructor(){super(...arguments),this._sendTransceiver={},this._localTracks={},this._recvAudio=[],this._recvVideo=[],this._recvTransceiver={},this._subedTracks=[]}setBitrate(e,n,r){P.warn("the interface named `setBitrate` is invalid while sdpSemantics value is `unified-plan`")}addLocalTrack(e){const n=e.getTrackId(),r=e.getStreamId(),i=e.__innerGetMediaStreamTrack();this._localTracks[n]=e;const o=this._outboundStreams[r]||(this._outboundStreams[r]=new MediaStream);o.getTracks().forEach(c=>{c.kind===i.kind&&o.removeTrack(c)}),o.addTrack(i);const s=this._sendTransceiver[n];s?(s.sender.replaceTrack(i),s.direction="sendonly"):this._sendTransceiver[n]=this._peer.addTransceiver(i,{direction:"sendonly",streams:[o]})}removeLocalTrack(e){const n=e.getTrackId(),r=e.getStreamId();e.__innerGetMediaStreamTrack(),delete this._localTracks[n];const i=this._sendTransceiver[n];if(!i)return;i.direction="inactive",this._peer.removeTrack(i.sender),i.sender.replaceTrack(null);const o=this._outboundStreams[r];(e.isAudioTrack()?o.getAudioTracks():o.getVideoTracks()).forEach(l=>o.removeTrack(l));const s=this._sendTransceiver[`${n}_tiny`];if(!s||s.direction==="inactive")return;s.direction="inactive";const c=s.sender,d=c.track;this._peer.removeTrack(c),c.replaceTrack(null),this._outboundStreams[`${r}_tiny`].removeTrack(d),d.stop()}updateRecvTransceiverMap(e,n){const{mediaType:r}=Ye(e);this._recvTransceiver[e]=n;const i=r===_e.AUDIO_ONLY?this._recvAudio:this._recvVideo,o=i.findIndex(s=>s===n);o>=0&&i.splice(o,1)}updateSubRemoteTracks(e){const n=e.slice(),r=this._subedTracks.slice();this._subedTracks=e.slice();for(let o=n.length-1;o>=0;o-=1){const s=n[o],c=r.findIndex(d=>d===s);c>=0&&(n.splice(o,1),r.splice(c,1))}r.length&&r.forEach(o=>{const s=o.getTrackId();o.__innerSetMediaStreamTrack(void 0);const c=this._recvTransceiver[s];c&&(c.direction="inactive")});const i={audio:0,video:0};n.length&&n.forEach(o=>{const s=o.isAudioTrack()?"audio":"video",c=this._recvTransceiver[o.getTrackId()];c?c.direction="recvonly":i[s]+=1});for(let o=this._recvAudio.length;o<i.audio;o+=1)this._recvAudio.push(this._peer.addTransceiver("audio",{direction:"recvonly"}));for(let o=this._recvVideo.length;o<i.video;o+=1)this._recvVideo.push(this._peer.addTransceiver("video",{direction:"recvonly"}))}createOffer(e){return j(this,void 0,void 0,function*(){const n=yield this._peer.createOffer({iceRestart:e});let r=n.sdp;for(const i in this._outboundStreams){const o=this._outboundStreams[i].id;r=r.replace(new RegExp(o,"g"),i)}return r=(i=>i.split(/\r\n(?=m=)/).map(o=>(s=>/a=(recvonly|inactive)/.test(s)?s.replace(/\r\na=(ssrc|msid)[^\r\n]+/g,""):s)(o)).join(`\r
- `))(r),r=r.replace(/a=ice-options:trickle/g,`a=ice-options:trickle\r
- a=ice-options:renomination`),n.sdp=r,yield this._peer.setLocalDescription(n),{type:"offer",semantics:"unified-plan",sdp:r}})}setRemoteAnswer(e){e=e.split(/\r\n(?=m=)/).map(r=>{var i;const o=r.match(/a=mid:[^\s]+/);if(!o)return r;const s=o[0].replace("a=mid:","");let c="";for(const p in this._sendTransceiver)if(this._sendTransceiver[p].mid===s){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
- `);const n=/[\r\n]+\r\n[\r\n]+/g;return n.test(e)&&(P.warn(`answer sdp invalid -> ${JSON.stringify(e)}`),e=e.replace(n,`\r
- `)),super.setRemoteAnswer(e)}}class Ot extends cr{constructor(e,n){super(),this._reTryExchange=e,this._polarisReport=n,this.pubLocalTracks={},this._reTryExchangeTimer=null,this._reportStatsTimer=null,this._reportListener=null;const r=On.getSdpSemantics(),i=this._rtcPeerConn=new RTCPeerConnection({sdpSemantics:r});this._sdpStrategy=r==="plan-b"?new Kf(i):new qf(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,n;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{(n=(e=this._reportListener)===null||e===void 0?void 0:e.onICEConnectionStateChange)===null||n===void 0||n.call(e,this._rtcPeerConn.iceConnectionState)}catch(r){P.error("onICEConnectionStateChange error",r)}}_onTrackReady(e){if(!e.streams.length)return;const n=[e.streams[0].id,e.receiver.track.kind==="audio"?_e.AUDIO_ONLY:_e.VIDEO_ONLY].join("_");this._updateRecvTransceiverMap(n,e.transceiver),this.emit(Ot.__INNER_EVENT_TRACK_READY__,e)}setBitrate(e,n,r){return j(this,void 0,void 0,function*(){this._sdpStrategy.setBitrate(e,n,r)})}createOffer(e){return j(this,void 0,void 0,function*(){const n=yield this._sdpStrategy.createOffer(e);return P.debug(`offer -> ${JSON.stringify(n.sdp)}`),n})}setRemoteAnswer(e){return j(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(ge.__INNER_EVENT_MUTED_CHANGE__,this._onLocalTrackMuted,this),e.off(ge.__INNER_EVENT_DESTROY__,this._onLocalTrackDestroied,this),e.on(ge.__INNER_EVENT_MUTED_CHANGE__,this._onLocalTrackMuted,this),e.on(ge.__INNER_EVENT_DESTROY__,this._onLocalTrackDestroied,this)}removeLocalTrackById(e){const n=this.getLocalTrack(e);n&&this.removeLocalTrack(n)}removeAllLocalTrack(){Object.keys(this.pubLocalTracks).forEach(e=>{/_tiny$/.test(e)||this.removeLocalTrackById(e)})}removeLocalTrack(e){const n=e.getTrackId();delete this.pubLocalTracks[n],this._sdpStrategy.removeLocalTrack(e),e.__innerSetPublished(!1),e.off(ge.__INNER_EVENT_MUTED_CHANGE__,this._onLocalTrackMuted,this),e.off(ge.__INNER_EVENT_DESTROY__,this._onLocalTrackDestroied,this);const r=`${n}_tiny`,i=this.getLocalTrack(r);i&&(this._sdpStrategy.removeLocalTrack(i),delete this.pubLocalTracks[r],i.destroy())}_updateRecvTransceiverMap(e,n){this._sdpStrategy.updateRecvTransceiverMap(e,n)}updateSubRemoteTracks(e){this._sdpStrategy.updateSubRemoteTracks(e)}getOutboundVideoInfo(){return this._sdpStrategy.getOutboundVideoInfo()}_onLocalTrackMuted(e){const n=this.getLocalTrack(`${e.getTrackId()}_tiny`);n&&(n.__innerGetMediaStreamTrack().enabled=!e.isLocalMuted()),this.emit(ge.__INNER_EVENT_MUTED_CHANGE__,e)}_onLocalTrackDestroied(e){this.emit(ge.__INNER_EVENT_DESTROY__,e)}registerReportListener(e){this._reportListener=e}_createRCRTCStateReport(e){const{timestamp:n,iceCandidatePair:r,senders:i,receivers:o}=JSON.parse(JSON.stringify(e));r==null||delete r.totalPacketsLost;for(const s in r)is(r[s])&&delete r[s];return{timestamp:n,iceCandidatePair:r,senders:i.map(s=>{const c={};return s.trackId&&(c.trackId=s.trackId),s.kind&&(c.kind=s.kind),(s.packetsLostRate||s.packetsLostRate===0)&&(c.packetsLostRate=s.packetsLostRate),c.remoteResource=s.remoteResource,(s.audioLevel||s.audioLevel===0)&&(c.audioLevel=s.audioLevel),s.frameWidth&&(c.frameWidth=s.frameWidth),s.frameHeight&&(c.frameHeight=s.frameHeight),s.frameRate&&(c.frameRate=s.frameRate),(s.bitrate||s.bitrate===0)&&(c.bitrate=s.bitrate),s.jitter&&(c.jitter=s.jitter),c}),receivers:o.map(s=>{const c={};return s.trackId&&(c.trackId=s.trackId),s.kind&&(c.kind=s.kind),(s.packetsLostRate||s.packetsLostRate===0)&&(c.packetsLostRate=s.packetsLostRate),c.remoteResource=s.remoteResource,(s.audioLevel||s.audioLevel===0)&&(c.audioLevel=s.audioLevel),s.frameWidth&&(c.frameWidth=s.frameWidth),s.frameHeight&&(c.frameHeight=s.frameHeight),s.frameRate&&(c.frameRate=s.frameRate),(s.bitrate||s.bitrate===0)&&(c.bitrate=s.bitrate),s.jitter&&(c.jitter=s.jitter),c})}}_getStatsData(){var e,n;return j(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(n=this.reportParser)===null||n===void 0?void 0:n.formatRCRTCStateReport(i)})}getAudioLevelReportData(){var e,n;return j(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?(n=this.reportParser)===null||n===void 0?void 0:n.getAudioLevelList(i):[]})}_reportHandle(){var e,n,r;return j(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 o=this._createRCRTCStateReport(i);(r=(n=this._reportListener)===null||n===void 0?void 0:n.onStateReport)===null||r===void 0||r.call(n,o)})}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 an,ui,xt,Bt,di;Ot.__INNER_EVENT_TRACK_READY__="inner-track-ready",function(t){t[t.DISABLE=0]="DISABLE",t[t.ENABLE=1]="ENABLE"}(an||(an={})),function(t){t[t.MeetingOrAnchor=1]="MeetingOrAnchor",t[t.Audience=2]="Audience"}(ui||(ui={}));class xd{constructor(e,n,r,i,o=ui.MeetingOrAnchor){this._context=e,this._runtime=n,this._roomId=r,this._crtRTCRoom=i,this._userRole=o}_send(e){this._context.getConnectionStatus()===ae.CONNECTED&&this._context.setRTCState(this._roomId,e)}_getClientID(){const e="uuid";let n=this._runtime.localStorage.getItem(e);return n||(n=Vf(),this._runtime.localStorage.setItem(e,n)),n}_getRealResourceId(e){let n=e;const r=e.indexOf("_tiny");return r>-1&&(n=e.slice(0,r)),n}_getPolarisTrackId(e){let n="";const r=e.split("_");if(e.includes("_tiny")){const i=r.pop(),o=parseInt(r.pop())===_e.AUDIO_ONLY?"audio":"video",s=r.pop();n=[r.join("_"),s,i,o].join("_")}else{const i=parseInt(r.pop())===_e.AUDIO_ONLY?"audio":"video",o=r.pop();n=[r.join("_"),o,i].join("_")}return n}sendR3R4Data(e){const{iceCandidatePair:n,senders:r,receivers:i}=e,o=(n==null?void 0:n.bitrateSend)||-1,s=(n==null?void 0:n.bitrateRecv)||-1,c=(n==null?void 0:n.networkType)||"unknown",d=(n==null?void 0:n.rtt)||-1,l=`${(n==null?void 0:n.IP)||-1}:${n==null?void 0:n.port}`,h=(n==null||n.remoteIP,n==null||n.remotePort,(n==null?void 0:n.availableIncomingBitrate)||-1),a=(n==null?void 0:n.availableOutgoingBitrate)||-1,u=(n==null?void 0:n.totalPacketsLost)||-1,f=this._context.getCurrentId();let p=`R3 ${o} -1 -1 -1 ${c} ${d} ${l} ${h} ${a} ${u} ${f}\r`,m=`R4 ${s} -1 -1 -1 ${c} ${d} ${l} ${h} ${a} ${u} ${f}\r`;const _=r.map(y=>{var C;const{trackId:b,audioLevel:N,samplingRate:S,bitrate:E,packetsLostRate:w,frameRate:V,frameWidth:K,frameHeight:R,googRenderDelayMs:T,jitter:A,nackCount:k,pliCount:U,rtt:F,googFirsSent:H,encoderImplementation:Q}=y,ee=this._getPolarisTrackId(b),ce=this._getRealResourceId(b);return{trackId:ee,googCodecName:Q||String(-1),audioLevel:N||N===0?N:-1,bitrate:E||E===0?E:-1,packetsLostRate:w||w===0?w:-1,frameRate:V||-1,resolution:K&&R?`${K} * ${R}`:"-1",jitter:A||-1,nackCount:k||k===0?k:-1,pliCount:U||U===0?U:-1,rtt:F||-1,googFirsSent:H,samplingRate:S,googRenderDelayMs:T,encoderImplementation:Q||String(-1),trackState:((C=this._crtRTCRoom.getLocalTrack(ce))===null||C===void 0?void 0:C.isLocalMuted())?an.DISABLE:an.ENABLE}}),v=i.filter(y=>!!y.trackId).map(y=>{var C;const{trackId:b,audioLevel:N,samplingRate:S,bitrate:E,packetsLostRate:w,frameRate:V,frameWidth:K,frameHeight:R,googRenderDelayMs:T,jitter:A,nackCount:k,pliCount:U,rtt:F,googFirsReceived:H,codecImplementationName:Q}=y,ee=this._getPolarisTrackId(b),ce=this._getRealResourceId(b);return{trackId:ee,googCodecName:Q||String(-1),audioLevel:N||N===0?N:-1,bitrate:E||E===0?E:-1,packetsLostRate:w||w===0?w:-1,frameRate:V||-1,resolution:K&&R?`${K} * ${R}`:"-1",jitter:A||-1,nackCount:k||k===0?k:-1,pliCount:U||U===0?U:-1,rtt:F||-1,googFirsReceived:H,samplingRate:S,googRenderDelayMs:T,codecImplementationName:Q||String(-1),trackState:((C=this._crtRTCRoom.getRemoteTrack(ce))===null||C===void 0?void 0:C.isLocalMuted())?an.DISABLE:an.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(`
- `),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(`
- `),e.receivers.length&&this._send(m+`\r${this._userRole}`)}sendR1(){const e=`R1 5.3.1 ${this._context.getCoreVersion()} web ${navigator.platform} -1 ${lt.browser} ${lt.version} ${this._getClientID()} ${this._userRole}`;this._send(e)}sendR2(e,n,r){const i=`R2 ${e} ${n} ${this._getClientID()}\r${r.join(" ")}\r${this._userRole}`;this._send(i)}}(function(t){t.PUBLISH="publish",t.SUBSCRIBE="subscribe"})(xt||(xt={})),function(t){t.BEGIN="begin",t.END="end"}(Bt||(Bt={}));class Bd{constructor(e){this._room=e,this._audioLevelChangeHandler=null,this._timer=null,this._pc=this._room.__getPC()}_audioLevelReport(){return j(this,void 0,void 0,function*(){if(this._pc.getRTCPeerConn().iceConnectionState==="new"||!this._audioLevelChangeHandler)return;const e=(yield this._pc.getAudioLevelReportData()).map(n=>{const{userId:r}=Zf.parseTrackId(n.trackId);return{track:this._room.getCrtUserId()===r?this._room.getLocalTrack(n.trackId):this._room.getRemoteTrack(n.trackId),audioLevel:n.audioLevel||0}}).filter(n=>n.track);this._audioLevelChangeHandler(e)})}onAudioLevelChange(e,n){n<300||n>1e3?P.error('the valid range of onAudioLevelChange params "gap" is: > 300 && < 1000'):e?(this._audioLevelChangeHandler=e,this._timer=setInterval(this._audioLevelReport.bind(this),n)):this._audioLevelChangeHandler=null}clearAudioLevelReportTimer(){this._timer&&(clearInterval(this._timer),this._timer=null)}}(function(t){t[t.ANCHOR=1]="ANCHOR",t[t.AUDIENCE=2]="AUDIENCE"})(di||(di={}));const Hn=t=>t instanceof la?t.getTrackId():t.track.getTrackId();class Vd{constructor(e,n,r,i,o,s,c,d,l,h){this._context=e,this._runtime=n,this._roomId=r,this._roomMode=o,this._service=s,this._initOptions=c,this._ntfClearRoomItem=d,this._isMainRoom=h,this._remoteTracks={},this._subscribedList=[],this._destroyed=!1,this.msgTaskQueue=new Qu,this._appListener=null,this._onRecvPKMsg=null,this._token=i.token,this._sessionId=i.sessionId,this._roomResources=l?{}:os(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&&we(()=>this._unpublishPrev(u)),l&&this._afterChangedRole(i),this._pinger=new Ff(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 xd(this._context,this._runtime,this._roomId,this),this._polarisReport.sendR1(),this._pc=new Ot(this._reTryExchange.bind(this),this._polarisReport),this._pc.on(Ot.__INNER_EVENT_TRACK_READY__,this._onTrackReady,this),this._pc.on(ge.__INNER_EVENT_MUTED_CHANGE__,this._onLocalTrackMuted,this),this._pc.on(ge.__INNER_EVENT_DESTROY__,this._onLocalTrackDestroied,this)}_initRemoteTracks(){const e=this._context.getCurrentId();for(const n in this._roomResources){const r=this._roomResources[n];n!==e&&r.length!==0&&r.forEach(i=>{const o=pe(i),{tag:s,userId:c,mediaType:d}=Ye(o),l=d===_e.AUDIO_ONLY?new kt(s,c):new Ut(s,c);l.__innerSetRemoteMuted(i.state===0),this._remoteTracks[o]=l})}}_handlePingResult(e){this._callAppListener("onPing",e)}setBitrate(e,n,r){P.warn("`RCAbstractRoom.setBitrate` will be deprecated, use `RCLocalTrack.setBitrate` instead."),Be("max",e,i=>be(i)&&i>Math.max(n||1,200),!0),Be("min",n,i=>be(i)&&i>=1&&(!be(e)||i<e),!0),Be("start",r,i=>be(i)&&i>n&&i<=e),this._pc.setBitrate(e,n,r)}_onTrackReady(e){const n=e.streams[0].id,r=e.receiver.track,i=[n,r.kind==="audio"?_e.AUDIO_ONLY:_e.VIDEO_ONLY].join("_"),o=this._remoteTracks[i];o?(o.__innerSetMediaStreamTrack(r),this._callAppListener("onTrackReady",o)):P.warn(`cannot found remote track ${r.id}`)}_callAppListener(e,...n){var r;const i=(r=this._appListener)===null||r===void 0?void 0:r[e];if(i)try{i(...n)}catch(o){P.error(o)}}_onUserUnpublish(e){return j(this,void 0,void 0,function*(){yield this.unsubscribe(e),e.forEach(n=>{n.__innerDestroy(),delete this._remoteTracks[n.getTrackId()]}),this._onTrackUnpublish(e)})}_onTrackUnpublish(e){this._callAppListener("onTrackUnpublish",e)}_unpublishPrev(e){return j(this,void 0,void 0,function*(){const n=e.slice();e.length=0,P.info(`unpublish uris prev login: ${JSON.stringify(n)}`);const r=yield this._context.setRTCTotalRes(this._roomId,Lr(de.UNPUBLISH,n),Kt([]),de.TOTAL_CONTENT_RESOURCE,Kt([]));r!==O.SUCCESS?P.error(`unpublish prev uris failed -> code: ${r}`):P.debug("unpublish uris prev login succeed")})}__parseInnerMessage(e){const{targetId:n,conversationType:r}=e;if(r!==re.RTC_ROOM)return!1;if(n!==this._roomId)return!0;P.info(`recv inner msg -> message: ${JSON.stringify(e)} | roomid: ${this._roomId}`);const i=e.content;switch(e.messageType){case de.KICK:this._kickoff(!0,i);break;case de.STATE:this.msgTaskQueue.push(()=>this._stateHandle(i));break;case de.MODIFY:case de.PUBLISH:case de.UNPUBLISH:case de.TOTAL_CONTENT_RESOURCE:this.msgTaskQueue.push(()=>this._resourceHandle(i,e.messageType,e.senderUserId));break;case de.ROOM_NOTIFY:this._callAppListener("onRoomAttributeChange",e.messageType,e.content);break;case de.USER_NOTIFY:P.warn(`TODO: ${de.USER_NOTIFY}`);break;case de.PK_INVITE:case de.PK_CANCEL_INVITE:case de.PK_INVITE_TIMEOUT:case de.PK_INVITE_ANSWER:case de.PK_END:this._onRecvPKMsg&&this._onRecvPKMsg(e);break;case de.OTHER_ROOM_OFFLINE:break;default:this._callAppListener("onMessageReceive",e.messageType,e.content,e.senderUserId,e.messageUId)}return!0}_kickoff(e,n){let r;P.warn(`onKickOff -> byServer: ${e}`),this._ntfClearRoomItem(),this._leaveHandle(!e),e&&((n==null?void 0:n.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,n,r){return j(this,void 0,void 0,function*(){if(this._assertRoomDestroyed())return void P.warn(`room has been destroyed. -> roomId: ${this._roomId}`);const{uris:i,ignore:o}=e;if(o||!i)return;const s=[],c=[],d=[];let l;const h=this._roomResources[r]||(this._roomResources[r]=[]);switch(n){case de.MODIFY:d.push(...i);break;case de.PUBLISH:s.push(...i);break;case de.UNPUBLISH:c.push(...i);break;case de.TOTAL_CONTENT_RESOURCE:l=Kr(h,i),s.push(...l.publishedList),c.push(...l.unpublishedList),d.push(...l.modifiedList)}if(s.length>0){const a=h.map(pe),u=[],f=[];if(s.forEach(p=>{const m=pe(p),_=a.indexOf(m),{userId:v,tag:y,mediaType:C}=Ye(m);_>-1?h[_]=p:h.push(p);let b=this._remoteTracks[m];b?b.isSubscribed()&&u.push(b):(b=C===_e.AUDIO_ONLY?new kt(y,v):new Ut(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 we(()=>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(pe);for(let f=h.length-1;f>=0;f-=1){const p=h[f];a.includes(pe(p))&&h.splice(f,1)}const u=c.map(f=>{const p=pe(f);return this._remoteTracks[p]});yield this._onUserUnpublish(u)}if(d.length>0){const a=h.map(pe);for(let u=0;u<d.length;u+=1){const f=d[u],p=pe(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 n;return j(this,void 0,void 0,function*(){const{users:r}=e;if(r.length===0)return;const i=[],o=[],s=[],c=[];r.forEach(h=>{+h.state==0?(P.debug(`user joined -> ${h.userId}`),this._roomResources[h.userId]||(h.switchRoleType?s.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):o.push(h.userId))});const d=[...i,...s],l=[...o,...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((n=this._appListener)===null||n===void 0?void 0:n.onSwitchRole)return s.length&&s.forEach(h=>this._callAppListener("onSwitchRole",h,di.ANCHOR)),c.length&&c.forEach(h=>this._callAppListener("onSwitchRole",h,di.AUDIENCE)),i.length&&this._callAppListener("onUserJoin",i),void(o.length&&this._callAppListener("onUserLeave",o));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(n=>n!==e)}getRemoteTracks(){const e=[];return this.getRemoteUserIds().forEach(n=>{e.push(...this.getRemoteTracksByUserId(n))}),e}getRemoteTracksByUserId(e){const n=[];for(const r in this._remoteTracks){const i=this._remoteTracks[r];i.getUserId()===e&&n.push(i)}return n}getSessionId(){return this._sessionId}sendMessage(e,n){return j(this,void 0,void 0,function*(){const{code:r}=yield this._context.sendMessage(re.RTC_ROOM,this._roomId,{messageType:e,content:n,isStatusMessage:!0});return r!==O.SUCCESS?(P.error(`send message failed -> code: ${r}`),{code:M.SIGNAL_ERROR}):{code:M.SUCCESS}})}setRoomAttribute(e,n,r,i=!1){return j(this,void 0,void 0,function*(){const o=yield this._context.setRTCData(this._roomId,e,n,i,Rt.ROOM,r);return o!==O.SUCCESS?(P.error(`SetRoomAttributeValue Failed: ${o}`),{code:M.SIGNAL_ERROR}):{code:M.SUCCESS}})}deleteRoomAttributes(e,n,r=!1){return j(this,void 0,void 0,function*(){const i=yield this._context.removeRTCData(this._roomId,e,r,Rt.ROOM,n);return i!==O.SUCCESS?(P.error(`DeleteRoomAttribute Failed: ${i}`),{code:M.SIGNAL_ERROR}):{code:M.SUCCESS}})}getRoomAttributes(e=[],n=!1){return j(this,void 0,void 0,function*(){const{code:r,data:i}=yield this._context.getRTCData(this._roomId,e,n,Rt.ROOM);return r!==O.SUCCESS?(P.error(`GetRoomAttributes Failed: ${r}`),{code:M.SIGNAL_ERROR}):{code:M.SUCCESS,data:i}})}_setUserAttributeValue(e,n,r){return this._context.setRTCData(this._roomId,e,n,!1,Rt.PERSON,r)}_deleteUserAttributes(e,n){return this._context.removeRTCData(this._roomId,e,!1,Rt.PERSON,n)}_getUserAttributes(e){return this._context.getRTCData(this._roomId,e,!1,Rt.PERSON)}isDestroyed(){return this._destroyed}__destroy(e){return this._leaveHandle(e)}_leaveHandle(e){var n;return j(this,void 0,void 0,function*(){this._destroyed||(this._destroyed=!0,(n=this._audioLevelReport)===null||n===void 0||n.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 mn&&e.__isTiny()||this.unpublish([e])}_onLocalTrackMuted(e){return j(this,void 0,void 0,function*(){const n=e.getTrackId(),r=this._context.getCurrentId(),i=[{resourceId:n,enabled:!e.isLocalMuted()}],o=this._roomResources[r]||[],s=[];for(let d=0;d<o.length;d+=1){const l=o[d],h=pe(l),a=i.findIndex(u=>u.resourceId===h);if(a>=0){const{enabled:u}=i[a];l.state=u?1:0,s.push(l);break}}const c=yield we(()=>this._context.setRTCTotalRes(this._roomId,Lr(de.MODIFY,s),Kt(o),de.TOTAL_CONTENT_RESOURCE));c!==O.SUCCESS&&P.error("notice `track.enabled` change failed -> code: "+c)})}_removePubFailedTracks(e){e.forEach(n=>{const r=n instanceof ge?n:n.track;P.debug(`remove pub failed track from peerconnection -> trackId: ${r.getTrackId()}`),this._pc.removeLocalTrackById(r.getTrackId())})}publish(e){return j(this,void 0,void 0,function*(){return we(()=>this.__publish(e))})}__publish(e){return j(this,void 0,void 0,function*(){if(!this._isMainRoom&&this instanceof Vt)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(!Re("tracks",e,()=>Qe(e)&&e.length>0&&e.every(C=>C instanceof ge||C.track instanceof ge),!0))return P.error(`publish failed, tracks is invalid -> roomId: ${this._roomId}`),{code:M.PARAMS_ERROR};const n=this._context.getCurrentId();if(this._pc.getLocalTracks().length+(C=>{let b=0;return C.forEach(N=>{N instanceof ge?b++:N.pubTiny&&N.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(Hn)}`),e.forEach(C=>{const{track:b,pubTiny:N}=C instanceof ge?{pubTiny:!1,track:C}:C;if(this._pc.addLocalTrack(b),b.isVideoTrack()&&N){let S;try{S=b.__innerGetMediaStreamTrack().clone();const E=N.frameRate||Tt.FPS_15,w=N.resolution||Te.W176_H144,{width:V,height:K}=St(w),R=It(E);S.applyConstraints({width:V,height:K,frameRate:R})}catch(E){return S==null||S.stop(),void P.warn(`pubTiny failed -> id: ${b.getTrackId()}, msg: ${E.message}`)}this._pc.addLocalTrack(new mn(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 o=yield this._exchangeHandle(r);if(o.code!==M.SUCCESS)return P.error(`publish failed -> roomId: ${this._roomId}, code: ${o.code}`),this._removePubFailedTracks(e),{code:o.code};const{publishList:s,sdp:c,resultCode:d,message:l,urls:h,mcuPublishList:a}=o.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[n],p=s.map(C=>Object.assign({tag:C.msid.split("_").pop(),state:this._getResourceState(pe(C))},C)),{publishedList:m}=Kr(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,Lr(de.PUBLISH,m),Kt(p),de.TOTAL_CONTENT_RESOURCE,Kt(_));if(v!==O.SUCCESS)return P.error(`send publish streams notification failed: ${v}`),{code:M.SIGNAL_ERROR};this._roomResources[n]=p;const y=m.map(C=>pe(C));return this._polarisReport&&this._polarisReport.sendR2(xt.PUBLISH,Bt.BEGIN,y),e.forEach(C=>{const{track:b}=C instanceof ge?{track:C}:C;b.__innerSetPublished(!0)}),P.debug(`publish success: ${y.join(",")}`),this._roomMode===Je.LIVE?{code:M.SUCCESS,liveUrl:h==null?void 0:h.liveUrl}:{code:M.SUCCESS}})}_getPushOtherRoomsParams(){if(this instanceof Vt){const{code:e,roomPKHandler:n}=this.getRoomPKHandler(),r=[];if(e===M.SUCCESS&&n){const i=n.getJoinedPKRooms();for(const o in i){const s=i[o].getSessionId(),c=n.getPKInfo(o);if(!c)return;const{inviterUserAutoMix:d,inviteeUserAutoMix:l,inviterUserId:h}=c,a=this._context.getCurrentId()===h;r.push({roomId:o,sessionId:s,autoMix:a?!!d:!!l})}}return r}}_reTryExchange(){return j(this,void 0,void 0,function*(){we(()=>j(this,void 0,void 0,function*(){const e=yield this._createExchangeParams(this._subscribedList,!0),n=this._getPushOtherRoomsParams();n&&(e.pushOtherRooms=n);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:o}=r.data;if(o!==M.SUCCESS)return P.error(`reTryExchange failed: ${o}`),{code:o};this._pc.clearReTryExchangeTimer();const s=yield this._pc.setRemoteAnswer(i.sdp);return s!==M.SUCCESS?{code:s}: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,n){return j(this,void 0,void 0,function*(){return{sdp:yield this._pc.createOffer(n),extend:JSON.stringify({resolutionInfo:this._pc.getOutboundVideoInfo()}),subscribeList:e.filter(r=>{const i=r.track.getTrackId(),{userId:o}=Ye(i);return this._roomResources[o]?this._roomResources[o].filter(c=>i===`${c.msid}_${c.mediaType}`).length:!1}).map(r=>({simulcast:r.subTiny?ut.TINY:ut.NORMAL,resolution:"",uri:this._getResourceById(r.track.getTrackId()).uri})),switchstream:!1}})}_getResourceState(e){var n;return((n=this.getLocalTrack(e))===null||n===void 0?void 0:n.isLocalMuted())?0:1}unpublish(e){return j(this,void 0,void 0,function*(){return we(()=>this.__unpublish(e))})}__unpublish(e){var n;return j(this,void 0,void 0,function*(){if(!this._isMainRoom&&this instanceof Vt)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(!Re("tracks",e,()=>e.every(C=>C.getUserId()===r&&C instanceof ge),!0))return P.warn(`unpublish failed, tracks is invalid -> roomId: ${this._roomId}, tracks: ${e.map(Hn)}`),{code:M.PARAMS_ERROR};const i=e.map(C=>C.getTrackId()),o=i.map(this._getResourceById.bind(this)).filter(C=>!!C);if(o.length===0)return{code:M.SUCCESS};const s=this._roomResources[r].filter(C=>!o.includes(C));i.forEach(C=>this._pc.removeLocalTrackById(C)),(n=this._polarisReport)===null||n===void 0||n.sendR2(xt.PUBLISH,Bt.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,Lr(de.UNPUBLISH,o),Kt(s),de.TOTAL_CONTENT_RESOURCE,Kt(m));if(_!==O.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(pe(C))},C));return this._roomResources[r]=y,{code:M.SUCCESS}})}_getResourceById(e){const{userId:n}=Ye(e);return this._roomResources[n].find(r=>pe(r)===e)}_isValidResourceId(e){var n;const{userId:r}=Ye(e);return!!((n=this._roomResources[r])===null||n===void 0?void 0:n.find(i=>pe(i)===e))}subscribe(e){return j(this,void 0,void 0,function*(){return we(()=>this.__subscribe(e,!1))})}__subscribe(e,n=!1){var r;return j(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(!Re("tracks",e,()=>Qe(e)&&e.length>0&&e.every(d=>d instanceof He||d.track instanceof He),!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(Hn)}`);const i=this._subscribedList.map(d=>Object.assign({},d)),o=e.map(d=>d instanceof He?{track:d}:d);let s=!1;const c=[];return o.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),s=!0)}),s||n?((r=this._polarisReport)===null||r===void 0||r.sendR2(xt.SUBSCRIBE,Bt.BEGIN,c),this._updateSubListHandle(i,!0)):{code:M.SUCCESS}})}unsubscribe(e){return j(this,void 0,void 0,function*(){return we(()=>this.__unsubscribe(e))})}__unsubscribe(e){var n;return j(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(!Re("tracks",e,()=>Qe(e)&&e.length>0&&e.every(i=>i instanceof He),!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(Hn)}`);const r=this._subscribedList.map(i=>Object.assign({},i)).filter(i=>!e.includes(i.track));return(n=this._polarisReport)===null||n===void 0||n.sendR2(xt.SUBSCRIBE,Bt.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 j(this,void 0,void 0,function*(){return we(()=>this._updateSubListHandle(e,!1))})}_updateSubListHandle(e,n=!1){return j(this,void 0,void 0,function*(){if(this._assertRoomDestroyed())return{code:M.ROOM_HAS_BEEN_DESTROYED};if(!Re("resources",e,()=>Qe(e)&&e.every(y=>y instanceof He||y.track instanceof He),!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: ${n}, tracks: ${e.map(Hn)}`);let r=e.map(y=>y instanceof He?{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 o=this._subscribedList.map(y=>Object.assign({},y));if(!n){let y=!1;if(r.forEach(C=>{const b=o.findIndex(N=>N.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(r.map(y=>y.track));const s=yield this._createExchangeParams(r,!1),c=this._getPushOtherRoomsParams();c&&(s.pushOtherRooms=c);const d=yield this._exchangeHandle(s),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,n){var r;(r=this._audioLevelReport)===null||r===void 0||r.clearAudioLevelReportTimer(),this._audioLevelReport=new Bd(this),this._audioLevelReport.onAudioLevelChange(e,n||1e3)}__onReconnected(e){return j(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:n,data:r}=yield this._context.joinRTCRoom(this._roomId,this._roomMode,e);if(n!==O.SUCCESS)return void P.error(`RTC __onReconnected getRTCRoomInfo failed: ${n}`);P.debug(`RTC __onReconnected getRTCRoomInfo success: ${JSON.stringify(r)}`);const i=[],o={},s={},c={},d=os(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),o[u]=kr(d[u]);continue}const p=this._roomResources[u],m=d[u],{publishedList:_,modifiedList:v,unpublishedList:y}=Kr(p,m,!0);o[u]=kr(_),s[u]=kr(y),c[u]=kr(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 s){const u=s[a];if(u.length){const f=u.map(p=>this._remoteTracks[pe(p)]);yield this._onUserUnpublish(f)}}return Object.keys(o).forEach(a=>{const u=o[a];if(u.length===0)return;const f=u.map(p=>{const m=pe(p),{userId:_,tag:v,mediaType:y}=Ye(m),C=this._remoteTracks[m]=y===_e.AUDIO_ONLY?new kt(v,_):new Ut(v,_);return C.__innerSetRemoteMuted(p.state===0),C});this._onTrackPublish(f)}),Object.keys(c).forEach(a=>{c[a].forEach(u=>{const f=pe(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(n=>{n.isAudioTrack()&&n.__releaseMediaElement()}),this._remoteTracks={})}_registerPKMsgListener(e){this._onRecvPKMsg=e}_quitAllPKRoom(){}}var Jn,hn,li;(function(t){t[t.CROP=1]="CROP",t[t.WHOLE=2]="WHOLE"})(Jn||(Jn={})),function(t){t[t.CUSTOMIZE=1]="CUSTOMIZE",t[t.SUSPENSION=2]="SUSPENSION",t[t.ADAPTATION=3]="ADAPTATION"}(hn||(hn={})),function(t){t[t.CROP=1]="CROP",t[t.WHOLE=2]="WHOLE"}(li||(li={}));const Bc=()=>({version:1,mode:hn.SUSPENSION});class Gf{constructor(e,n,r){this._onFlush=e,this._isValidTrackId=n,this._sendCDNInfoSignal=r,this._values=Bc()}setHostVideoTrack(e){if(!this._isValidTrackId(e))return P.error(`setHostVideoTrack failed: videoTrackId is invalid -> ${e}`),this;const{mediaType:n,tag:r,userId:i}=Ye(e);return n!==_e.VIDEO_ONLY?(P.error(`setHostVideoTrack failed: kind of resource is not 'video' -> ${e}`),this):(this._values.host_stream_id=uo(i,r),this)}setMixLayoutMode(e){return[hn.CUSTOMIZE,hn.SUSPENSION,hn.ADAPTATION].includes(e)?(this._values.mode=e,this):(P.error(`layout mode is invalid: ${e}`),this)}_addOutputValue(e,n,r="normal"){const i=this._values.output||(this._values.output={video:{normal:{width:640,height:480}}});if(e==="cdn")return void(i.cdn=n);if(e==="audio")return void(i.audio={bitrate:n});const o=i.video;if(r!=="normal"&&r!=="tiny")if(r!=="backgroundColor")if(r!=="exparams"){if(r==="backgroundPicture"){const s=o.backgroundPicture||(o.backgroundPicture={fillMode:Jn.CROP,picture:[]});Object.assign(s,n)}}else o.exparams={renderMode:n};else o.backgroundColor=n;else{const s=o[r]||(o[r]={});Object.assign(s,n)}}setOutputVideoResolution(e){if(!ln(e))return P.warn("setOutputVideoResolution failed: `resolution` is invalid"),this;const{width:n,height:r}=St(e);return this._addOutputValue("video",{width:n,height:r},"normal"),this}setOutputVideoFPS(e){if(!rs(e))return P.warn("setOutputVideoFPS failed: `fps` is invalid"),this;const n=It(e);return this._addOutputValue("video",{fps:n},"normal"),this}setOutputVideoBitrate(e){return!be(e)||e<=0?P.error(`bitrate is invalid: ${e}`):this._addOutputValue("video",{bitrate:e},"normal"),this}setOutputTinyVideoResolution(e){if(!ln(e))return P.warn("setOutputTinyVideoResolution failed: `resolution` is invalid"),this;const{width:n,height:r}=St(e);return this._addOutputValue("video",{width:n,height:r},"tiny"),this}setOutputTinyVideoFPS(e){if(!rs(e))return P.warn("setOutputTinyVideoFPS failed: `fps` is invalid"),this;const n=It(e);return this._addOutputValue("video",{fps:n},"tiny"),this}setOutputTinyVideoBitrate(e){return!be(e)||e<=0?P.error(`bitrate is invalid: ${e}`):this._addOutputValue("video",{bitrate:e},"tiny"),this}setOutputVideoRenderMode(e){return[li.CROP,li.WHOLE].includes(e)?this._addOutputValue("video",e,"exparams"):P.error(`renderMode is invalid: ${e}`),this}setOutputAudioBitrate(e){return be(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,n,r,i,o){var s,c,d;if(!Xn(e))return P.error(`uri is invalid: ${e}`),this;if([n,r,i,o].some(h=>!be(h)||h<0||h>1))return P.error(`some attrs of (x, y, w, h) is invalid: ${n}, ${r}, ${i}, ${o}`),this;const l=((d=(c=(s=this._values.output)===null||s===void 0?void 0:s.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:o,x:n,y:r}),this._addOutputValue("video",{picture:l},"backgroundPicture"),this}removeOutputBackgroundPicture(e){var n,r,i;if(!Xn(e))return P.error(`uri is invalid: ${e}`),this;let o=(i=(r=(n=this._values.output)===null||n===void 0?void 0:n.video)===null||r===void 0?void 0:r.backgroundPicture)===null||i===void 0?void 0:i.picture;return o&&(o=o.filter(s=>s.uri!==e),this._addOutputValue("video",{pictures:o},"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 n,r;const i=/^rtmp:\/\/.+/;if(!Qe(e)||e.length===0||e.some(c=>!i.test(c)))return P.error(`urls is invalid: ${e}`),this;const o=((r=(n=this._values.output)===null||n===void 0?void 0:n.cdn)===null||r===void 0?void 0:r.concat())||[];let s=!1;return e.forEach(c=>{o.some(d=>d.pushurl===c)||(s=!0,o.push({pushurl:c}))}),o.length>5?(P.error("publish stream url no more than 5"),this):(s&&this._addOutputValue("cdn",o),this)}removePublishStreamUrls(e){var n,r;const i=/^rtmp:\/\/.+/;if(!Qe(e)||e.length===0||e.some(s=>!i.test(s)))return P.error(`urls is invalid: ${e}`),this;const o=((r=(n=this._values.output)===null||n===void 0?void 0:n.cdn)===null||r===void 0?void 0:r.concat())||[];for(let s=o.length-1;s>=0;s-=1){const{pushurl:c}=o[s],d=e.indexOf(c);d>=0&&(e.splice(d,1),o.splice(s,1))}return this._addOutputValue("cdn",o),this}clearPublishStreamUrls(){return this._addOutputValue("cdn",[]),this}addCustomizeLayoutVideo(e,n,r,i,o){if(!this._isValidTrackId(e))return P.error(`trackId is invalid: ${e}`),this;if(!be(n)||!be(r))return P.error(`some attrs of (x, y) is invalid: ${n}, ${r}`),this;if([i,o].some(h=>!be(h)||h<0))return P.error(`some attrs of (width, height) is invalid: ${i}, ${o}`),this;const{userId:s,tag:c,mediaType:d}=Ye(e);if(d!==_e.VIDEO_ONLY)return P.error(`kind of resource is not 'video': ${e}`),this;const l=uo(s,c);return(this._values.input||(this._values.input={video:[]})).video.push({user_id:s,stream_id:l,x:n,y:r,width:i,height:o}),this}removeCustomizeLayoutVideo(e){if(!this._isValidTrackId(e))return P.error(`trackId is invalid: ${e}`),this;const{userId:n,tag:r,mediaType:i}=Ye(e);if(i!==_e.VIDEO_ONLY)return P.error(`kind of resource is not 'video': ${e}`),this;const o=uo(n,r),s=this._values.input||(this._values.input={video:[]});return s.video=s.video.filter(c=>c.stream_id===o),this}clearCustomizeLayoutVideo(){return(this._values.input||(this._values.input={video:[]})).video=[],this}flush(){var e,n,r,i;return j(this,void 0,void 0,function*(){const o=JSON.parse(JSON.stringify(this._values)),{code:s}=yield this._onFlush(o);return s===M.SUCCESS&&(((n=(e=this._values.output)===null||e===void 0?void 0:e.video.normal)===null||n===void 0?void 0:n.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=Bc(),{code:s}})}}var hi,fi,pi,mt;(function(t){t[t.OPEN=1]="OPEN",t[t.STOP=2]="STOP"})(hi||(hi={})),function(t){t[t.SPREAD=0]="SPREAD",t[t.NO_SPREAD=-1]="NO_SPREAD"}(fi||(fi={})),function(t){t[t.AUTOMATIC=0]="AUTOMATIC",t[t.MANUAL=1]="MANUAL"}(pi||(pi={})),function(t){t[t.VIDEO=0]="VIDEO",t[t.AUDIO=1]="AUDIO"}(mt||(mt={}));const Fd=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){const e=16*Math.random()|0;return(t==="x"?e:3&e|8).toString(16)});class Yf{constructor(e,n,r,i,o,s,c,d){this._context=e,this._runtime=n,this._service=r,this._initOptions=i,this._mainLivingRoom=o,this._registerPKMsgListener=s,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,...n){var r;const i=(r=this._appListener)===null||r===void 0?void 0:r[e];if(i)try{i(...n)}catch(o){P.error(o)}}_onInvite(e){const n=e.inviteInfo||{},{inviterRoomId:r,inviterUserId:i,extra:o}=n,s={inviterRoomId:r,inviterUserId:i};o&&Object.assign(s,{extra:o}),this._PKInfo[r]=n,this._callAppListener("onRequestJoinOtherRoom",s)}_onCancelInvite(e){const{inviterRoomId:n,inviterUserId:r,extra:i}=e.inviteInfo||{},o={inviterRoomId:n,inviterUserId:r};i&&Object.assign(o,{extra:i}),delete this._PKInfo[n],this._callAppListener("onCancelRequestOtherRoom",o)}_onInviteTimeout(e){}_onInviteAnswer(e){const{answerCode:n,inviteContent:r,inviteeUserAutoMix:i}=e,{inviterUserId:o,inviterRoomId:s,inviteeUserId:c,inviteeRoomId:d,extra:l}=r,h={agree:n===1,inviterRoomId:s,inviterUserId:o,inviteeRoomId:d,inviteeUserId:c};this._PKInfo[d].inviteeUserAutoMix=i,this._callAppListener("onResponseJoinOtherRoom",h)}_onPKEnd(e){return j(this,void 0,void 0,function*(){const{inviteeRoomId:n,inviterRoomId:r,userId:i}=e.inviteInfo,o=r===this._mainRoomId?n:r,s={endRoomId:o,endUserId:i};yield this.leaveOtherRoom(this._joinedPKRooms[o]),delete this._PKInfo[o],this._callAppListener("onFinishOtherRoom",s)})}_onRecvPKMsg(e){const{targetId:n,content:r,messageType:i}=e;switch(i){case de.PK_INVITE:this._onInvite(r);break;case de.PK_CANCEL_INVITE:this._onCancelInvite(r);break;case de.PK_INVITE_TIMEOUT:this._onInviteTimeout(r);break;case de.PK_INVITE_ANSWER:this._onInviteAnswer(r);break;case de.PK_END:this._onPKEnd(r)}}registerRoomPKEventListener(e){this._appListener=e}requestJoinOtherRoom(e,n,r){return j(this,void 0,void 0,function*(){if(!Re("inviteeRoomId",e,et,!0)||!Re("inviteeUserId",n,et,!0))return{code:M.PARAMS_ERROR};P.debug(`requestRoomPK -> inviteeRoomId: ${e}; inviteeUserId: ${n}; options: ${JSON.stringify(r||{})}`);const i=Fd(),o=!Jr(r==null?void 0:r.autoMix)||(r==null?void 0:r.autoMix),s={inviteSessionId:i,inviterRoomId:this._mainRoomId,inviterUserId:this._context.getCurrentId(),inviterUserAutoMix:o,inviteeRoomId:e,inviteeUserId:n,inviteeTimeoutTime:this._inviteTimeout,extra:(r==null?void 0:r.extra)||""},c={roomId:this._mainRoomId,invitedRoomId:e,invitedUserId:n,inviteTimeout:this._inviteTimeout,inviteInfo:JSON.stringify(s),inviteSessionId:i};P.debug(`requestRoomPK -> params: ${JSON.stringify(c)}`);const d=yield this._context.requestRoomPK(c);return d!==O.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:o,inviteeRoomId:e},{code:M.SUCCESS})})}cancelRequestJoinOtherRoom(e,n,r){return j(this,void 0,void 0,function*(){if(!Re("inviteeRoomId",e,et,!0)||!Re("inviteeUserId",n,et,!0))return{code:M.PARAMS_ERROR};if(!this._PKInfo[e])return P.error(`\u672A\u53D1\u8D77\u8FC7\u4E0E ${e} \u623F\u95F4\u5185 ${n} \u8FDE\u9EA6\u7684\u8BF7\u6C42`),{code:M.PARAMS_ERROR};P.debug(`canceRequestJoinPK -> inviteeRoomId: ${e}; inviteeUserId: ${n}; extra: ${r}`);const i={inviterRoomId:this._mainRoomId,inviterUserId:this._context.getCurrentId(),inviteeRoomId:e,inviteeUserId:n,extra:r||""},o={roomId:this._mainRoomId,invitedRoomId:e,invitedUserId:n,inviteSessionId:this._PKInfo[e].inviteSessionId,inviteInfo:JSON.stringify(i)};P.debug(`canceRequestJoinPK -> params: ${JSON.stringify(o)}`);const s=yield this._context.cancelRoomPK(o);return s!==O.SUCCESS?(P.error(`canceRequestJoinPK failed: ${s}`),{code:s}):(P.debug("canceRequestJoinPK success"),delete this._PKInfo[e],{code:M.SUCCESS})})}responseJoinOtherRoom(e,n,r,i){return j(this,void 0,void 0,function*(){if(!Re("inviterRoomId",e,et,!0)||!Re("inviterUserId",n,et,!0))return{code:M.PARAMS_ERROR};if(!this._PKInfo[e])return P.error(`${e} \u623F\u95F4\u5185\u7684 ${n} \u672A\u53D1\u8D77\u8FC7\u8FDE\u9EA6\u8BF7\u6C42`),{code:M.PARAMS_ERROR};P.debug(`responseRoomPK -> inviterRoomId: ${e}; inviterUserId: ${n}; agree: ${r}; options: ${JSON.stringify(i||{})}`);const{inviteSessionId:o,inviterUserAutoMix:s}=this._PKInfo[e],c=!Jr(i==null?void 0:i.autoMix)||(i==null?void 0:i.autoMix),d={inviteSessionId:o,inviterRoomId:e,inviterUserId:n,inviteeRoomId:this._mainRoomId,inviteeUserId:this._context.getCurrentId(),inviteeUserAutoMix:c},l=Object.assign(d,{inviterUserAutoMix:s}),h=r?Object.assign(d,{MultiRoomKey:`${e}|${this._mainRoomId}`,MultiRoomValue:JSON.stringify(l)}):d;!me(i==null?void 0:i.extra)&&Object.assign(h,{extra:i.extra});const a={agree:r,roomId:this._mainRoomId,inviteSessionId:o,inviteRoomId:e,inviteUserId:n,content:JSON.stringify(h),key:`${e}|${n}`,value:JSON.stringify(d)};P.debug(`responseRoomPK -> params: ${JSON.stringify(a)}`);const u=yield this._context.responseRoomPK(a);return u!==O.SUCCESS?(P.error(`responseRoomPK failed: ${u}`),{code:u}):(P.debug("responseRoomPK success"),this._PKInfo[e].inviteeUserAutoMix=c,{code:M.SUCCESS})})}_quitRoomPK(e){return j(this,void 0,void 0,function*(){const{inviterRoomId:n,inviteeRoomId:r,inviterUserId:i}=this._PKInfo[e],o={inviteeRoomId:r,inviterRoomId:n,userId:this._context.getCurrentId()},s={roomId:this._mainRoomId,endRoomId:e,sessionId:this._PKInfo[e].inviteSessionId,content:JSON.stringify(o),keys:[`${n}|${i}`]};P.debug(`quitRoomPK -> params: ${JSON.stringify(s)}`);const c=yield this._context.endRoomPK(s);return c!==O.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 j(this,void 0,void 0,function*(){if(!Re("roomId",e,et,!0))return{code:M.PARAMS_ERROR};if(this._context.getConnectionStatus()!==ae.CONNECTED)return{code:M.SIGNAL_DISCONNECTED};if(P.debug(`joinPKRoom, roomId: ${e}`),this._joinedPKRooms[e])return{code:M.REPERT_JOIN_ROOM};const n=mt.VIDEO,{code:r,data:i}=yield this._context.joinRTCRoom(e,Je.LIVE,n);if(r!==O.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 o=new Vt(this._context,this._runtime,e,i,this._service,this._initOptions,this._relaseCrtRoom.bind(this),n,!1,!1);return this._joinedPKRooms[e]=o,this._onJoinedPKRoom(e,o),{room:o,code:M.SUCCESS,userIds:o.getRemoteUserIds(),tracks:o.getRemoteTracks()}})}leaveOtherRoom(e,n){return j(this,void 0,void 0,function*(){return we(()=>j(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]?(n&&this._quitRoomPK(r),{code:M.SUCCESS}):{code:M.SUCCESS}}))})}getPKInfo(e){return this._PKInfo[e]}getJoinedPKRooms(){return this._joinedPKRooms}}class Vt extends Vd{constructor(e,n,r,i,o,s,c,d,l=!1,h){var a;super(e,n,r,i,Je.LIVE,o,s,c,l,h),this._livingType=d,this._isMainRoom=h,this._CDNUris=null,this._CDNEnable=!1,this._mcuConfigBuilder=new Gf(this._onMCUConfigFlush.bind(this),this._isValidResourceId.bind(this),this._sendCDNInfoSignal.bind(this)),this._isMainRoom&&(this._roomPKHandler=new Yf(e,n,o,s,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 n;const{userId:r}=Ye(e),i=!!((n=this._roomResources[r])===null||n===void 0?void 0:n.find(h=>pe(h)===e));let o=!1;const{code:s,roomPKHandler:c}=this.getRoomPKHandler();if(s!==M.SUCCESS||!c)return i;const d=c.getJoinedPKRooms(),l=[];return Object.values(d).map(h=>{l.push(...h.getRemoteTracks())}),o=l.some(h=>e===h.getTrackId()),i||o}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 j(this,void 0,void 0,function*(){const n={"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(n,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 n,r;return j(this,void 0,void 0,function*(){const i=yield e.__onReconnected.call(this,this._livingType);if(!i||!i.data)return;const o=i.data.roomInfo,s=(n=o.filter(d=>d.key==="cdn_uris")[0])===null||n===void 0?void 0:n.value;if(!s)return;const c=JSON.parse(s);((r=this._CDNUris)===null||r===void 0?void 0:r.enableInnerCDN)!==c.enableInnerCDN&&this._callAppListener("onCDNEnableChange",c.enableInnerCDN),this._CDNUris=c})}enableInnerCDN(e){return j(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(!Jr(e))return P.error("`enable` is invalid"),{code:M.PARAMS_ERROR};this._CDNEnable=e;const n={version:2,output:{inCDNModel:e?hi.OPEN:hi.STOP}},{code:r}=yield this._onMCUConfigFlush(n);if(r!==M.SUCCESS)return P.error(`enableInnerCDN failed -> code: ${r}`),{code:M.SIGNAL_ERROR};if(this._CDNUris&&this._CDNUris.broadcast!==fi.SPREAD)return P.info("enableInnerCDN succeed"),{code:M.SUCCESS};const{code:i}=yield we(()=>j(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 j(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 j(this,void 0,void 0,function*(){const n=yield this._context.setRTCCDNUris(this._roomId,de.TOTAL_CONTENT_RESOURCE,JSON.stringify([e]));return n!==O.SUCCESS?(P.error(`spreadCDNInfo failed -> code: ${n}`),{code:M.SIGNAL_ERROR}):(P.info("spreadCDNInfo succeed"),{code:M.SUCCESS})})}_setRoomCDNInfo(e){return j(this,void 0,void 0,function*(){const n=yield this._context.setRTCData(this._roomId,"cdn_uris",JSON.stringify([e]),!0,Rt.ROOM);return n!==O.SUCCESS?(P.error(`setRoomCDNInfo failed -> code: ${n}`),{code:M.SIGNAL_ERROR}):(P.info("setRoomCDNInfo succeed"),{code:M.SUCCESS})})}_resourceHandle(e,n,r){const i=Object.create(null,{_resourceHandle:{get:()=>super._resourceHandle}});var o;return j(this,void 0,void 0,function*(){i._resourceHandle.call(this,e,n,r),e.cdn_uris&&(((o=this._CDNUris)===null||o===void 0?void 0:o.enableInnerCDN)!==e.cdn_uris[0].enableInnerCDN&&this._callAppListener("onCDNEnableChange",!this.__getCDNEnable()),this._CDNUris=e.cdn_uris[0])})}_exchangeHandle(e){var n,r,i;return j(this,void 0,void 0,function*(){const o=yield this._service.exchange(this._getRTCReqestHeaders(),e),s=(r=(n=o.data)===null||n===void 0?void 0:n.urls)===null||r===void 0?void 0:r.pull_url;return o.code===M.SUCCESS&&s&&(this._CDNUris=JSON.parse(s),((i=this._CDNUris)===null||i===void 0?void 0:i.broadcast)===fi.SPREAD&&(this._CDNEnable=!0,this._sendCDNInfoSignal())),o})}_afterChangedRole(e){const n=os(e),r=this._context.getCurrentId(),i=Object.keys(n);setTimeout(()=>{var o,s,c;const d=i.filter(l=>l!==r);d.length>0&&this._callAppListener("onUserJoin",d);for(const l in n)l!==r&&this._resourceHandle({uris:n[l]},de.TOTAL_CONTENT_RESOURCE,l);((o=e.roomInfo.filter(l=>l.key==="cdn_uris")[0])===null||o===void 0?void 0:o.value)&&((s=this._CDNUris)===null||s===void 0?void 0:s.push_mode)===pi.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,n){const{code:r,roomPKHandler:i}=this.getRoomPKHandler();if(r===M.SUCCESS&&i){if(!i.getPKInfo(e))return;this._exchangeWithPushOtherRoom()}}_onLeavePKRoom(e){const{code:n,roomPKHandler:r}=this.getRoomPKHandler();if(n===M.SUCCESS&&r){if(!r.getPKInfo(e))return;this._exchangeWithPushOtherRoom()}}_exchangeWithPushOtherRoom(){return j(this,void 0,void 0,function*(){if(!this.getLocalTracks().length)return;const e=yield this._createExchangeParams(this._subscribedList,!1),n=this._getPushOtherRoomsParams();n&&(e.pushOtherRooms=n);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:o}=r.data;if(o!==M.SUCCESS)return P.error(`exchange with pushOtherRoom failed: ${o}`),{code:o};const s=yield this._pc.setRemoteAnswer(i.sdp);return s!==M.SUCCESS?{code:s}: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 n in e){const r=e[n];this._roomPKHandler.leaveOtherRoom(r)}}}class Jf extends Vd{constructor(e,n,r,i,o,s,c){super(e,n,r,i,Je.RTC,o,s,c,!1)}}const lo=()=>({"Content-Type":"application/json;charset=UTF-8","Cache-Control":"no-cache",ClientType:`web|${lt.browser}|${lt.version}`,ClientVersion:"5.3.1","Client-Session-Id":Fd(),"Request-Id":Date.now().toString()});class pa{constructor(e,n,r,i=5e3){this._runtime=e,this._context=n,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 n;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=(n=r.callEngine)===null||n===void 0?void 0:n.filter(c=>c.engineType===4);if(!i||i.length===0)return[];const o=i[0],s=[];return o.mediaServer&&s.push(o.mediaServer.replace(/^(https?:\/\/)?/,"https://")),o.backupMediaServer&&o.backupMediaServer.forEach(c=>{s.push(c.replace(/^(https?:\/\/)?/,"https://"))}),s})(this._context.getNaviInfo())):(this._msInNavi.push(...this._failedMs),this._failedMs.length=0)),this._msInNavi.map(e=>e.trim()))}_request(e,n,r){return j(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 o=0;o<i.length;o+=1){const s=`${i[o]}${e}`,c=lo();P.debug(`request -> Request-Id: ${c["Request-Id"]}, url: ${s}`);const{status:d,data:l}=yield this._runtime.httpReq({url:s,body:JSON.stringify(r),headers:Object.assign(Object.assign({},c),n),method:_t.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: ${s}`),this._failedMs.push(...this._msInNavi.splice(o,1))}return{code:M.REQUEST_FAILED}})}exchange(e,n){var r;return j(this,void 0,void 0,function*(){const i=yield this._request("/exchange",e,n);if(i.code===M.SUCCESS&&((r=i.data)===null||r===void 0?void 0:r.resultCode)===M.SUCCESS){const o=i.data.urls;o&&(this._configUrl=o.configUrl)}return i})}exit(e){return j(this,void 0,void 0,function*(){const{code:n}=yield this._request("/exit",e,{});return n})}broadcastSubscribe(e,n){return this._request("/broadcast/subscribe",e,n)}broadcastExit(e){return j(this,void 0,void 0,function*(){const{code:n}=yield this._request("/broadcast/exit",e,{});return{code:n}})}setMcuConfig(e,n){return j(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=lo();P.debug(`request -> Request-Id: ${i["Request-Id"]}, url: ${r}`);const{status:o,data:s}=yield this._runtime.httpReq({url:r,headers:Object.assign(Object.assign({},i),e),body:JSON.stringify(n),method:_t.POST});if(o===200){P.debug(`request success -> Request-Id: ${i["Request-Id"]}`);const c=JSON.parse(s);return{code:c.resultCode,res:c}}return{code:M.REQUEST_FAILED}})}getCDNResourceInfo(e,n){return j(this,void 0,void 0,function*(){const r=lo(),{status:i,data:o}=yield this._runtime.httpReq({url:n,headers:Object.assign(Object.assign({},r),e),method:_t.GET});if(i===200){const s=JSON.parse(o);return{code:s.resultCode,res:s}}return P.warn(`request failed -> Request-Id: ${r["Request-Id"]}, status: ${i}, url: ${n}`),{code:M.REQUEST_FAILED}})}}class Wf{constructor(e,n,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 pa(n,e,r.mediaServer)}_getReqHeaders(e){return j(this,void 0,void 0,function*(){const n=this._context.getCurrentId(),r=n;if(!this._rtcToken){const{code:i,data:o}=yield this._context.getRTCToken(r,Je.LIVE,e);if(i!==O.SUCCESS)return P.error(`getRTCToken failed: ${i}`),{code:M.SIGNAL_ERROR};this._rtcToken=o.rtcToken}return{code:M.SUCCESS,headers:{"App-Key":this._context.getAppkey(),UserId:n,RoomId:r,RoomType:Je.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 j(this,void 0,void 0,function*(){this._fromRetry=!0;const{code:n}=yield this.subscribe(this._liveUrl,this._livingType,this._mediaType,this._subTiny);n===M.SUCCESS&&((e=this._pc)===null||e===void 0||e.clearReTryExchangeTimer())})}subscribe(e,n,r,i=!1){return j(this,void 0,void 0,function*(){return we(()=>this.__subscribe(e,n,r,i))})}__subscribe(e,n,r,i=!1){var o;return j(this,void 0,void 0,function*(){const s=[];if(qr(this._context.getNaviInfo()))return{code:M.PACKAGE_ENVIRONMENT_ERROR,tracks:s};if(!this._fromRetry&&((o=this._pc)===null||o===void 0||o.clearReTryExchangeTimer()),this._fromRetry=!1,!nt(e))return P.error(`liveUrl is invalid: ${e}`),{code:M.PARAMS_ERROR,tracks:s};if(![mt.AUDIO,mt.VIDEO].includes(n))return P.error(`livingType is invalid: ${n}`),{code:M.PARAMS_ERROR,tracks:s};if(![_e.AUDIO_ONLY,_e.VIDEO_ONLY,_e.AUDIO_VIDEO].includes(r))return P.error(`mediaType is invalid: ${r}`),{code:M.PARAMS_ERROR,tracks:s};if(this._liveUrl&&this._liveUrl!==e)return{code:M.BROADCAST_SUB_LIST_NOT_EMPTY,tracks:s};this._pc||(this._pc=new Ot(this._reTryExchange.bind(this)),this._pc.on(Ot.__INNER_EVENT_TRACK_READY__,this._onTrackReady,this),this.registerReportListener(this._reportListener)),this._liveUrl=e;const{code:c,headers:d}=yield this._getReqHeaders(n);if(c!==M.SUCCESS)return{code:c,tracks:s};const l=`rc_mcu_${Date.now()}`,h="RongCloudRTC";this._subTracks.length===0&&(this._subTracks.push(new kt(h,l),new Ut(h,l)),this._pc.updateSubRemoteTracks(this._subTracks.slice()));const a={sdp:yield this._pc.createOffer(!0),liveUrl:e,mediaType:r,simulcast:i?ut.TINY:ut.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:s};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:s};P.debug(`andience subscribe success: ${e}`),this._livingType=n,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 j(this,void 0,void 0,function*(){return we(()=>this.__unsubscribe())})}__unsubscribe(){var e;return j(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:n}=yield this._getReqHeaders(),{code:r}=yield this._service.broadcastExit(n);return r!==M.SUCCESS?P.error(`broadcast unsubscribe failed: ${r}`):P.debug("broadcast unsubscribe success"),this._clearSubscribeInfo(),{code:r}})}registerReportListener(e){var n;this._reportListener=e,(n=this._pc)===null||n===void 0||n.registerReportListener(e)}registerTrackEventListener(e){this._appListener=e}_onTrackReady(e){var n,r;const i=e.receiver.track,o=i.kind==="audio"?_e.AUDIO_ONLY:_e.VIDEO_ONLY,s=this._subTracks[o];s.__innerSetMediaStreamTrack(i);try{(r=(n=this._appListener)===null||n===void 0?void 0:n.onTrackReady)===null||r===void 0||r.call(n,s)}catch(c){P.error(c)}}}var ss,Wn;(function(t){t.RTMP="rtmp",t.FLV="flv",t.HLS="hls"})(ss||(ss={})),function(t){t[t.NOT_HTTPS=0]="NOT_HTTPS",t[t.HTTPS=1]="HTTPS"}(Wn||(Wn={}));const zf=Object.assign(Object.assign({},St(Te.W176_H144)),{frameRate:It(Tt.FPS_15)});class Vc{constructor(e,n,r,i,o,s){this._context=e,this._runtime=n,this._initOptions=r,this._roomId=i,this._joinResData=o,this._livingType=s,this._roomAnchorList=[],this._roomRes={},this._roomAnchorRes={},this._remoteTracks={},this._appListener=null,this._subscribedList=[],this._sessionId="",this._destroyed=!1,this._setInitData(),this._service=new pa(this._runtime,this._context,this._initOptions.mediaServer,this._initOptions.timeout),this._polarisReport=new xd(this._context,this._runtime,this._roomId,this,ui.Audience),this._polarisReport.sendR1(),this._pc=new Ot(this._reTryExchange.bind(this),this._polarisReport),this._pc.on(Ot.__INNER_EVENT_TRACK_READY__,c=>{const d=c.streams[0].id,l=c.receiver.track,h=[d,l.kind==="audio"?_e.AUDIO_ONLY:_e.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:n,remoteRTCUris:r,remoteMUCUris:i,remoteTracks:o,CDNUris:s}=((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,N=C===_e.AUDIO_ONLY?new kt(b,"",c):new Ut(b,"",c);p.push(N)});const m=[],_=[];u.forEach(y=>{const C=JSON.parse(y.uris||"[]");m.push(...C),C.forEach(b=>{const{mediaType:N,tag:S,msid:E}=b,w=E.split("_")[0],V=N===_e.AUDIO_ONLY?new kt(S,w):new Ut(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=n,o.forEach(c=>{this._remoteTracks[c.getTrackId()]=c}),this._CDNUris=s,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=pe(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,n){var r;if(n!==this._roomId)return void P.warn(`singalDataChange -> not the current room data: data roomId: ${n}, current roomId: ${this._roomId}`);P.debug("singalDataChange -> singalData:",JSON.stringify(e||{}));const i=[],o=(r=e.filter(s=>s.key==="RC_CDN")[0])===null||r===void 0?void 0:r.value;o&&this._diffCDNUris(JSON.parse(JSON.parse(o).cdn_uris)[0]),e.forEach(s=>{const{key:c,value:d,timestamp:l,uid:h}=s;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 n=e.filter(r=>this._roomAnchorList.indexOf(r)<0);return{leftUserIds:this._roomAnchorList.filter(r=>e.indexOf(r)<0),joinUserIds:n}}_handleNewJoinedAnchor(e){this._roomAnchorList.push(...e),this._callAppListener("onAnchorJoin",e)}_handleLeftedAnchor(e){return j(this,void 0,void 0,function*(){this._roomAnchorList=this._roomAnchorList.filter(r=>!(e.indexOf(r)>-1));const n=[];e.forEach(r=>{n.push(...this.getRemoteTracksByUserId(r)),delete this._roomAnchorRes[r]}),n.length&&(yield this.unsubscribe(n),n.forEach(r=>delete this._remoteTracks[r.getTrackId()])),this._callAppListener("onAnchorLeave",e)})}_diffRoomResource(e){return j(this,void 0,void 0,function*(){const n=[],r=[],i=[];e.forEach(o=>{const s=pe(o),{userId:c,tag:d,mediaType:l}=Ye(s),h=[this._roomId,d,l].join("_");if(!this._remoteTracks[h]){const a=l===_e.AUDIO_ONLY?new kt(d,"",this._roomId):new Ut(d,"",this._roomId);n.push(a),this._remoteTracks[h]=a,this._roomRes[a.getTrackId()]=o}i.push(h)}),Object.keys(this._remoteTracks).forEach(o=>{i.indexOf(o)<0&&this._remoteTracks[o].isMCUTrack()&&r.push(this._remoteTracks[o])}),n.length>0&&this._callAppListener("onTrackPublish",n),r.length>0&&this._onUserUnpublish(r,"onTrackUnpublish")})}_diffAnchorResource(e,n){return j(this,void 0,void 0,function*(){const r=this._roomAnchorRes[n]||(this._roomAnchorRes[n]=[]),{publishedList:i,unpublishedList:o,modifiedList:s}=Kr(r,e);if(i.length){const c=r.map(pe),d=[],l=[];if(i.forEach(h=>{const a=pe(h),u=c.indexOf(a),{userId:f,tag:p,mediaType:m}=Ye(a);u>-1?r[u]=h:r.push(h);let _=this._remoteTracks[a];this._roomRes[a]=h,_?_.isSubscribed()&&d.push(_):(_=m===_e.AUDIO_ONLY?new kt(p,f):new Ut(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 we(()=>this._subscribeHandle(d,!0));a!==M.SUCCESS&&P.error(`resub tracks failed -> code: ${a}, ids: ${JSON.stringify(h)}`)}this._callAppListener("onAnchorTrackPublish",l)}if(o.length){const c=o.map(pe);for(let l=r.length-1;l>=0;l-=1){const h=r[l];c.includes(pe(h))&&r.splice(l,1)}const d=o.map(l=>{const h=pe(l);return this._remoteTracks[h]});yield this._onUserUnpublish(d,"onAnchorTrackUnpublish")}if(s.length){const c=r.map(pe);for(let d=0;d<s.length;d++){const l=s[d],h=pe(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,n){return j(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(n,e)})}_callAppListener(e,...n){var r;const i=(r=this._appListener)===null||r===void 0?void 0:r[e];if(i)try{i(...n)}catch(o){P.error(o)}}_reTryExchange(){return j(this,void 0,void 0,function*(){we(()=>j(this,void 0,void 0,function*(){var e;const{reqBody:n}=yield this._createSubscribeParams(this._subscribedList,{},!0),r=yield this._exchangeHandle(n);if(r.code!==M.SUCCESS)return P.error(`reTryExchange failed: ${r.code}`),{code:r.code};const{sdp:i,resultCode:o}=r.data;if(o!==M.SUCCESS)return P.error(`reTryExchange failed: ${o}`),{code:o};this._pc.clearReTryExchangeTimer();const s=this._subscribedList.filter(d=>d.track.isMCUTrack());if(s.length>0){const d=s[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,n,r){return j(this,void 0,void 0,function*(){const i=yield this._pc.createOffer(r),o={resolutionInfo:[]},s={min:0,max:0};return Object.keys(n).forEach(c=>{const{mediaStream:d,tinyStream:l}=n[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?ha(p):zf;o.resolutionInfo.push({trackId:p.id,simulcast:m?ut.NORMAL:ut.TINY,resolution:`${_}x${v}`});const C=Pd(_,v),b=Ld(y);s.min+=C.minBitrate*b,s.max+=C.maxBitrate*b})}),{reqBody:{sdp:i,switchstream:!1,newVersionFlag:!0,subscribeList:e.map(c=>({simulcast:c.subTiny?ut.TINY:ut.NORMAL,resolution:"",uri:this._roomRes[c.track.getTrackId()].uri}))},dynamicBitrate:s,offer:i}})}_subscribeHandle(e,n=!1){var r;return j(this,void 0,void 0,function*(){if(this._assertRoomDestroyed())return{code:M.ROOM_HAS_BEEN_DESTROYED};if(!Re("tracks",e,()=>Qe(e)&&e.length>0&&e.every(d=>d instanceof He||d.track instanceof He),!0))return{code:M.PARAMS_ERROR};const i=this._subscribedList.map(d=>Object.assign({},d)),o=e.map(d=>d instanceof He?{track:d}:d);let s=!1;const c=[];return o.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),s=!0)}),s||n?((r=this._polarisReport)===null||r===void 0||r.sendR2(xt.SUBSCRIBE,Bt.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:Je.LIVE,UserId:e,"Session-Id":this._sessionId}}_exchangeHandle(e){return this._service.broadcastSubscribe(this._getReqHeaders(),e)}_updateSubListHandle(e,n=!1){var r;return j(this,void 0,void 0,function*(){if(this._assertRoomDestroyed())return{code:M.ROOM_HAS_BEEN_DESTROYED};if(!Re("resources",e,()=>Qe(e)&&e.every(y=>y instanceof He||y.track instanceof He),!0))return{code:M.PARAMS_ERROR};let i=e.map(y=>y instanceof He?{track:y}:Object.assign({},y));const o={};i=i.filter(y=>{const C=y.track.getTrackId();return!o[C]&&(o[C]=!0)}).map(y=>Object.assign({},y));const s=this._subscribedList.map(y=>Object.assign({},y));if(!n){let y=!1;if(i.forEach(C=>{const b=s.findIndex(N=>N.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(i.map(y=>y.track));const{reqBody:c}=yield this._createSubscribeParams(i,{},!1),d=yield this._exchangeHandle(c);if(s.length){const y=[];s.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:N,userId:S}=Ye(C.getTrackId()),E=[S,N].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 j(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 n=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;(n||r||i)&&this._callAppListener("onCDNInfoChange",{resolution:`W${e.w}_H${e.h}`,fps:`FPS_${e.fps}`}),this._CDNUris=e})}_getCDNPlayUrl(e){return j(this,void 0,void 0,function*(){const{w:n,h:r,fps:i}=e,o=this._initOptions.pullInnerCDNProtocol||ss.FLV,s=this._initOptions.pullInnerCDNUseHttps===Wn.NOT_HTTPS?Wn.NOT_HTTPS:Wn.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=[];n&&d.push(`w=${n}`),r&&d.push(`h=${r}`),i&&d.push(`fps=${i}`),d.push(`kind=${o}`),d.push(`is_https=${s}`);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,n){return j(this,void 0,void 0,function*(){if(e&&!ln(e))return P.error("`resolution` is invalid"),{code:M.PARAMS_ERROR};if(n&&!rs(n))return P.error("`fps` is invalid"),{code:M.PARAMS_ERROR};const{width:r,height:i}=e?St(e):{width:null,height:null},o=n?It(n):null,s={};return r&&(s.w=r),i&&(s.h=i),o&&(s.fps=o),this._getCDNPlayUrl(s)})}subscribe(e){return j(this,void 0,void 0,function*(){return we(()=>this._subscribeHandle(e,!1))})}__unsubscribe(e){var n;return j(this,void 0,void 0,function*(){if(!Re("tracks",e,()=>Qe(e)&&e.length>0&&e.every(i=>i instanceof He),!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(n=this._polarisReport)===null||n===void 0||n.sendR2(xt.SUBSCRIBE,Bt.END,e.map(i=>i.getTrackId())),this._updateSubListHandle(r,!1)})}unsubscribe(e){return j(this,void 0,void 0,function*(){return we(()=>this.__unsubscribe(e))})}__destroy(e){var n;return j(this,void 0,void 0,function*(){this._destroyed||(this._destroyed=!0,(n=this._audioLevelReport)===null||n===void 0||n.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 j(this,void 0,void 0,function*(){const{code:e}=yield this._context.joinLivingRoomAsAudience(this._roomId,Je.LIVE);e!==O.SUCCESS&&P.error("join living room error when on reconnected")})}registerRoomEventListener(e){this._appListener=e}onAudioLevelChange(e,n){var r;(r=this._audioLevelReport)===null||r===void 0||r.clearAudioLevelReportTimer(),this._audioLevelReport=new Bd(this),this._audioLevelReport.onAudioLevelChange(e,n||1e3)}registerReportListener(e){var n;(n=this._pc)===null||n===void 0||n.registerReportListener(e)}getRoomId(){return this._roomId}getCrtUserId(){return this._context.getCurrentId()}getSessionId(){return this._sessionId}getRemoteUserIds(){return this._roomAnchorList}getRemoteTracksByUserId(e){const n=[];for(const r in this._remoteTracks){const i=this._remoteTracks[r];i.getUserId()===e&&n.push(i)}return n}getRemoteTracks(){const e=[],n=[];for(const r in this._remoteTracks){if(n.length===2)break;const i=this._remoteTracks[r];i.isMCUTrack()&&n.push(i)}return this._roomAnchorList.forEach(r=>{e.push(...this.getRemoteTracksByUserId(r))}),[...n,...e]}getRemoteRTCTracks(){const e=[];for(const n in this._remoteTracks){const r=this._remoteTracks[n];r.isMCUTrack()||e.push(r)}return e}getRemoteMCUTracks(){const e=[];for(const n in this._remoteTracks){const r=this._remoteTracks[n];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 Fc=(t,e)=>{const n=[];return n[0]=(e==null?void 0:e.withoutAudio)?void 0:t.getAudioTracks()[0],n[1]=(e==null?void 0:e.withoutVideo)?void 0:t.getVideoTracks()[0],n};class Qf{constructor(e,n,r){this._context=e,this._runtime=n,this._options=r,this._crtRoom=null,this._audience=null,this._crtAudienceLivingRoom=null,On.setSdpSemantics(r.sdpSemantics||"plan-b"),this._service=new pa(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 n;return e.conversationType!==re.RTC_ROOM?!1:(this._crtRoom instanceof Vt&&this._getJoinedPKRoomList().forEach(r=>{r.__parseInnerMessage(e)}),(n=this._crtRoom)===null||n===void 0||n.__parseInnerMessage(e),!0)}_getJoinedPKRoomList(){const{code:e,roomPKHandler:n}=this._crtRoom.getRoomPKHandler();if(e===M.SUCCESS&&n){const r=n.getJoinedPKRooms()||{};return Object.values(r)}return[]}getCurrentId(){return this._context.getCurrentId()}joinRTCRoom(e,n){return we(()=>this._joinRTCRoom(e,n))}_joinRTCRoom(e,n){return j(this,void 0,void 0,function*(){if(qr(this._context.getNaviInfo()))return{code:M.PACKAGE_ENVIRONMENT_ERROR};if(!Re("roomId",e,et,!0))return{code:M.PARAMS_ERROR};if(this._crtRoom)return{code:M.REPERT_JOIN_ROOM};if(this._context.getConnectionStatus()!==ae.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: ${n||Fo.KICK}`);const{code:r,data:i}=yield this._context.joinRTCRoom(e,Je.RTC,void 0,n);if(r!==O.SUCCESS)return P.error(`joinRoom failed -> code: ${r}`),{code:r===Wo.JOIN_REFUSED?M.SIGNAL_JOIN_RTC_ROOM_REFUSED:r};P.debug(`joinRoom success -> userId: ${this._context.getCurrentId()}, roomId: ${e}, data: ${JSON.stringify(i)}`);const o=new Jf(this._context,this._runtime,e,i,this._service,this._options,this._releaseCrtRoomObj.bind(this));return this._crtRoom=o,{room:o,code:M.SUCCESS,userIds:o.getRemoteUserIds(),tracks:o.getRemoteTracks()}})}joinLivingRoom(e,n){return we(()=>this._joinLivingRoom(e,n))}_joinLivingRoom(e,n){return j(this,void 0,void 0,function*(){if(qr(this._context.getNaviInfo()))return{code:M.PACKAGE_ENVIRONMENT_ERROR};if(!Re("roomId",e,et,!0)||!Re("livingType",n,c=>c===mt.AUDIO||c===mt.VIDEO))return{code:M.PARAMS_ERROR};if(this._crtRoom)return{code:M.REPERT_JOIN_ROOM};if(this._context.getConnectionStatus()!==ae.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,Je.LIVE,n);if(r!==O.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 o=new Vt(this._context,this._runtime,e,i,this._service,this._options,this._releaseCrtRoomObj.bind(this),n,!1,!0);this._crtRoom=o;const s={room:o,code:M.SUCCESS,userIds:o.getRemoteUserIds(),tracks:o.getRemoteTracks()};return o.__getCDNPushMode()===pi.MANUAL&&Object.assign(s,{CDNEnable:o.__getCDNEnable()}),s})}getAudienceClient(){return this._audience||(this._audience=new Wf(this._context,this._runtime,this._options)),this._audience}_onIMStatusChange(e){P.debug(`signal server connection state change: ${e}`),e===ae.CONNECTED&&(this._crtRoom instanceof Vt&&this._getJoinedPKRoomList().forEach(n=>{n.__onReconnected()}),this._crtRoom&&this._crtRoom.__onReconnected())}_onIMDisconnect(){P.debug("TODO -> on IM disconnect")}_onIMUninit(){P.debug("TODO -> on IM client ondestroy")}leaveRoom(e){return we(()=>this._leaveRoom(e))}_leaveRoom(e){return j(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,n="getUserMedia"){return j(this,void 0,void 0,function*(){try{const r=yield navigator.mediaDevices[n](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:n==="getUserMedia"?M.GET_USER_MEDIA_FAILED:M.GET_DISPLAY_MEDIA_FAILED}})}createMicrophoneAudioTrack(e="RongCloudRTC",n){return j(this,void 0,void 0,function*(){if(!Mt(e))return{code:M.INVALID_TAGS};const r=this._context.getCurrentId();if(!r)return{code:M.INVALID_USER_ID};const{stream:i,code:o}=yield this._getMediaStream({audio:{deviceId:n==null?void 0:n.micphoneId,sampleRate:n==null?void 0:n.sampleRate}});if(o!==M.SUCCESS)return{code:o};const s=i.getAudioTracks()[0];return{code:o,track:new kc(e,r,s)}})}createCameraVideoTrack(e="RongCloudRTC",n){return j(this,void 0,void 0,function*(){if(!Mt(e))return{code:M.INVALID_TAGS};const r=this._context.getCurrentId();if(!r)return{code:M.INVALID_USER_ID};const i=ln(n==null?void 0:n.resolution)?n.resolution:Te.W640_H480,{width:o,height:s}=St(i),{stream:c,code:d}=yield this._getMediaStream({video:{deviceId:n==null?void 0:n.cameraId,frameRate:It((n==null?void 0:n.frameRate)||Tt.FPS_15),width:o,height:s,facingMode:n==null?void 0:n.faceMode}});if(d!==M.SUCCESS)return{code:d};const l=c.getVideoTracks()[0];return{code:d,track:new Uc(e,r,l)}})}createMicrophoneAndCameraTracks(e="RongCloudRTC",n){var r,i,o,s,c,d;return j(this,void 0,void 0,function*(){const l=[];if(!Mt(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=ln((r=n==null?void 0:n.video)===null||r===void 0?void 0:r.resolution)?n.video.resolution:Te.W640_H480,{width:u,height:f}=St(a),{stream:p,code:m}=yield this._getMediaStream({video:{deviceId:(i=n==null?void 0:n.video)===null||i===void 0?void 0:i.cameraId,frameRate:It(((o=n==null?void 0:n.video)===null||o===void 0?void 0:o.frameRate)||Tt.FPS_15),width:u,height:f,facingMode:(s=n==null?void 0:n.video)===null||s===void 0?void 0:s.faceMode},audio:{deviceId:(c=n==null?void 0:n.audio)===null||c===void 0?void 0:c.micphoneId,sampleRate:(d=n==null?void 0:n.audio)===null||d===void 0?void 0:d.sampleRate}});return m!==M.SUCCESS||p.getTracks().forEach(_=>{_.kind==="video"?l.push(new Uc(e,h,_)):l.unshift(new kc(e,h,_))}),{code:m,tracks:l}})}createScreenVideoTrack(e="screenshare",n){return j(this,void 0,void 0,function*(){if(!Mt(e))return{code:M.INVALID_TAGS};const r=this._context.getCurrentId();if(!r)return{code:M.INVALID_USER_ID};if(!Ud())return{code:M.BROWSER_NOT_SUPPORT};const i=/Electron/.test(navigator.userAgent);if(i&&!(n==null?void 0:n.chromeMediaSourceId))return{code:M.PARAMS_ERROR};const o=ln(n==null?void 0:n.resolution)?n.resolution:Te.W1280_H720,{width:s,height:c}=St(o),d=i?{mandatory:{chromeMediaSourceId:n.chromeMediaSourceId,chromeMediaSource:"desktop",minWidth:s,maxWidth:s,minHeight:c,maxHeight:c}}:{frameRate:It((n==null?void 0:n.frameRate)||Tt.FPS_15),width:s,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 Df(e,r,a)}})}createLocalAudioTrack(e,n){return j(this,void 0,void 0,function*(){if(!Mt(e))return{code:M.INVALID_TAGS};if(!n||n.toString()!=="[object MediaStreamTrack]"||n.kind!=="audio")return{code:M.CREATE_CUSTOM_TRACK_FAILED};const r=this._context.getCurrentId();return r?{code:M.SUCCESS,track:new ns(e,r,n)}:{code:M.INVALID_USER_ID}})}createLocalVideoTrack(e,n){return j(this,void 0,void 0,function*(){if(!Mt(e))return{code:M.INVALID_TAGS};if(!n||n.toString()!=="[object MediaStreamTrack]"||n.kind!=="video")return{code:M.CREATE_CUSTOM_TRACK_FAILED};const r=this._context.getCurrentId();return r?{code:M.SUCCESS,track:new mn(e,r,n)}:{code:M.INVALID_USER_ID}})}createLocalFileTracks(e,n,r){return j(this,void 0,void 0,function*(){if(!Mt(e))return{code:M.INVALID_TAGS,tracks:[]};if(!kd())return{code:M.BROWSER_NOT_SUPPORT,tracks:[]};const i=n instanceof File?URL.createObjectURL(n):n;if(!Xn(i)&&!/^blob:/.test(i))return P.warn(`createLocalFileTracks failed: params error -> url: ${i}`),{code:M.PARAMS_ERROR,tracks:[]};const o=this._context.getCurrentId();return o?new Promise(s=>{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),s({code:M.CREATE_FILE_TRACK_FAILED,tracks:d})}const[h,a]=Fc(l,r);h&&d.push(new Uf(e,o,h,c)),a&&d.push(new kf(e,o,a,c)),d.length===0&&(c.pause(),c.src=""),c.onerror=null,s({code:M.SUCCESS,tracks:d})},c.onerror=()=>{P.error(`create RCLocalFileTrack failed -> url: ${i}`),s({code:M.CREATE_FILE_TRACK_FAILED,tracks:[]})},c.src=i,c.loop=!0,c.play()}):{code:M.INVALID_USER_ID,tracks:[]}})}createLocalTracks(e,n,r){return j(this,void 0,void 0,function*(){const i=[];if(!Mt(e))return{code:M.INVALID_TAGS,tracks:i};if(!(n instanceof MediaStream))return{code:M.PARAMS_ERROR,tracks:i};const o=this._context.getCurrentId();if(!o)return{code:M.INVALID_USER_ID,tracks:i};const[s,c]=Fc(n,r);return s&&i.push(new ns(e,o,s)),c&&i.push(new mn(e,o,c)),{code:M.SUCCESS,tracks:i}})}joinLivingRoomAsAudience(e,n){return j(this,void 0,void 0,function*(){if(qr(this._context.getNaviInfo()))return{code:M.PACKAGE_ENVIRONMENT_ERROR};if(!Re("roomId",e,et,!0)||!Re("livingType",n,s=>s===mt.AUDIO||s===mt.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,Je.LIVE,n);if(r!==O.SUCCESS)return P.error("audienceJoinLivingRoomError:",r),{code:M.SIGNAL_AUDIENCE_JOIN_ROOM_FAILED};P.info(`joinLivingRoomAsAudience success, room data: ${JSON.stringify(i)}`);const o=new Vc(this._context,this._runtime,this._options,e,i,n);return this._crtAudienceLivingRoom=o,{room:o,code:M.SUCCESS,userIds:o.getRemoteUserIds(),RTCTracks:o.getRemoteRTCTracks(),MCUTracks:o.getRemoteMCUTracks(),CDNUris:o.getCDNInfo()}})}leaveLivingRoomAsAudience(e){return j(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 j(this,void 0,void 0,function*(){if(!Re("room._roomId",e._roomId,et,!0))return{code:M.PARAMS_ERROR};if(this._crtRoom)return{code:M.REPERT_JOIN_ROOM};const{code:n,data:r}=yield this._context.rtcIdentityChange(e._roomId,zr.ViewerToAnchor,e._livingType);if(n!==O.SUCCESS)return P.error("change room identity error",n),{code:M.SIGNAL_ROOM_CHANGE_IDENTITY_FAILED};yield this._crtAudienceLivingRoom.__destroy(!1);const i=new Vt(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 j(this,void 0,void 0,function*(){if(!Re("room._roomId",e._roomId,et,!0))return{code:M.PARAMS_ERROR};if(this._crtAudienceLivingRoom)return{code:M.REPERT_JOIN_ROOM};const{code:n,data:r}=yield this._context.rtcIdentityChange(e._roomId,zr.AnchorToViewer,e.getLivingType());if(n!==O.SUCCESS)return P.error("change room identity error",n),{code:M.SIGNAL_ROOM_CHANGE_IDENTITY_FAILED};P.info(`downgradeToAudienceRoom success, room data: ${JSON.stringify(r)}`);const i=new Vc(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 j(this,void 0,void 0,function*(){const{code:e,data:n}=yield this._context.getRTCJoinedUserInfo(this._context.getCurrentId());return e!==O.SUCCESS?(P.error("getJoinedUserInfo error",e),{code:M.SIGNAL_ROOM_CHANGE_IDENTITY_FAILED}):{code:M.SUCCESS,data:n}})}}var Hc;(function(t){t[t.SERVER_KICK=1]="SERVER_KICK",t[t.OTHER_KICK=2]="OTHER_KICK"})(Hc||(Hc={}));const Xf={tag:"RCRTC",verify:t=>t.tag!=="browser"?(P.error(`RCRTC Plugin is not support the runtime '${t.tag}'`),!1):xf?(zt.add("plugin-rtc","5.3.1"),!!zt.validEngine("5.1.0")||(P.error(`The current engine version '${zt.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:(t,e,n={})=>(P.setLogLevel(n.logLevel),P.setLogStdout(n.logStdout),P.warn("RCRTC Version: 5.3.1, Commit: e1af0f5ccb06a0084c94e1219d8af54c9793c06b"),P.warn(`browserInfo.browser -> ${lt.browser}`),P.warn(`browserInfo.supportsUnifiedPlan -> ${lt.supportsUnifiedPlan}`),P.warn(`browserInfo.version -> ${lt.version}`),Be("options.mediaServer",n.mediaServer,r=>!(!Xn(r)||location.protocol==="https:"&&!/^https/.test(r))),Be("options.timeout",n.timeout,r=>be(r)&&r>=5e3&&r<=3e4),Be("options.pingGap",n.pingGap,r=>be(r)&&r>=3e3&&r<=1e4),new Qf(t,e,n))},Zf={transResolution:St,transFrameRate:It,parseTrackId:Ye,ifSupportLocalFileTrack:kd,ifSupportScreenShare:Ud};function ep(t){return{all:t=t||new Map,on:function(e,n){var r=t.get(e);r?r.push(n):t.set(e,[n])},off:function(e,n){var r=t.get(e);r&&(n?r.splice(r.indexOf(n)>>>0,1):t.set(e,[]))},emit:function(e,n){var r=t.get(e);r&&r.slice().map(function(i){i(n)}),(r=t.get("*"))&&r.slice().map(function(i){i(e,n)})}}}const xe={"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","RC:ForcedOffline":"ForcedOffline","RC:LookerLoginOut":"LookerLoginOut"};var Ie=ep();const ga="start-live-time",ma="start-live-status",Hd="video-deviceId",jd="audio-deviceId",$d="audio-device-volume",W=Ei({roomUid:sessionStorage.getItem("roomUid")||"",imConnectStatus:"connecting",screenShareStatus:!1,videoRef:Ri(null),rtcClient:null,joinedRoom:null,mediaStreamTrack:[],mediaStreams:null,videoStatus:"init",microphones:[],cameras:[],selectedCamera:null,selectedMicrophone:null,likeCount:0,lookCount:0,lastLikeCount:0,activeTracks:{},allowSeatsCtrl:!0,allowChatCtrl:!0,deviceStatus:{microphone:"init",camera:"init",screen:"init"}});var Z=W;const tp="c9kqb3rdc451j";cf({appkey:tp});const np=bn("RC:Chatroom:SeatsCtrl",!0,!0),rp=bn("RC:Chatroom:ChatBan",!0,!0),ip=bn("RC:Chatroom:SeatApply",!0,!0),op=bn("RC:Chatroom:SeatResponse",!0,!0),sp=bn("RC:Chatroom:MemberCount",!0,!0),ap=bn("RC:Chatroom:SeatMember",!0,!0),pr=Ae,Aa=pr,{MESSAGES:k_}=Aa,cp=Na(Aa,["MESSAGES"]);hr(pr.MESSAGES,t=>{console.log(t,"\u6536\u5230\u6D88\u606F");const{messages:e}=t;for(const n of e)xe[n.messageType]&&Ie.emit(xe[n.messageType],Mn(ot({},n.content),{$EventMessage:n}))});for(const t of Object.values(cp))hr(t,e=>{console.log(t,e),Ie.emit(t,{$EventMessage:null})});hr(pr.CONNECTING,()=>{console.log("connecting"),W.imConnectStatus="connecting"});hr(pr.CONNECTED,()=>{console.log("connected"),W.imConnectStatus="connected"});hr(pr.DISCONNECT,()=>{console.log("disconnect"),W.imConnectStatus="disconnect"});const up=async t=>{var e;try{const n=await df(t);return W.rtcClient=uf(Xf,{}),console.log("connect success",(e=n.data)==null?void 0:e.userId),n}catch(n){throw n}},Kd=t=>{localStorage.setItem($d,t.toString()),W.videoRef&&(W.videoRef.volume=t/100),W.activeTracks.microphone&&W.activeTracks.microphone._element&&(W.activeTracks.microphone._element.volume=t/100)},dp=async()=>{var t;if(W.rtcClient&&!W.screenShareStatus){const e=await vn("screen"),n=W.activeTracks.camera;(t=W.joinedRoom)==null||t.unpublish([n]),Nt([e],"screen"),W.videoRef&&(e.play(W.videoRef),W.screenShareStatus=!0),e==null||e.on(ge.EVENT_LOCAL_TRACK_END,r=>{W.screenShareStatus=!1,r.destroy(),n&&(Nt([n],"camera"),W.videoRef&&n.play(W.videoRef))})}},lp=async()=>{const t=await da.getMicrophones();return W.microphones=t,t},hp=async()=>{const t=await da.getCameras();return W.cameras=t,t},qd=async t=>{W.selectedCamera=t,localStorage.setItem(Hd,t.deviceId);const e=W.activeTracks.camera;e&&await xi([e],"camera",e.isPublished());const n=await vn("camera");Nt([n],"camera",W.videoStatus==="liveing")},Gd=async t=>{W.selectedMicrophone=t,localStorage.setItem(jd,t.deviceId);const e=W.activeTracks.microphone;e&&await xi([e],"microphone",e.isPublished());const n=await vn("microphone");Nt([n],"microphone",W.videoStatus==="liveing")},vn=async t=>{var r,i,o,s,c;let e,n=null;return t==="microphone"?e=await((i=W.rtcClient)==null?void 0:i.createMicrophoneAudioTrack("RongCloudRTC",{micphoneId:(r=W.selectedMicrophone)==null?void 0:r.deviceId})):t==="camera"?e=await((s=W.rtcClient)==null?void 0:s.createCameraVideoTrack("RongCloudRTC",{cameraId:(o=W.selectedCamera)==null?void 0:o.deviceId,faceMode:"user",frameRate:Tt.FPS_24,resolution:Te.W1920_H1080})):e=await((c=W==null?void 0:W.rtcClient)==null?void 0:c.createScreenVideoTrack()),n=e==null?void 0:e.track,(t==="camera"&&!W.cameras.length||t==="microphone"&&!W.microphones.length||t==="screen"&&!W.screenShareStatus)&&(W.deviceStatus[t]="none"),e.code===M.PERMISSION_DENIED?W.deviceStatus[t]="denied":W.deviceStatus[t]="granted",n},Nt=async(t,e,n=!0)=>{var r;for(const i of t)e==="microphone"&&(console.log("\u6DFB\u52A0\u9EA6\u514B\u98CE"),i==null||i.play()),W.activeTracks[e]=i;n&&await((r=W.joinedRoom)==null?void 0:r.publish(t.filter(i=>!!i)))},xi=async(t,e,n=!0)=>{var r;n&&await((r=W.joinedRoom)==null?void 0:r.unpublish(t.filter(i=>!!i)));for(const i of t)i==null||i.destroy(),W.activeTracks[e]=null},fp=async(t,e,n)=>{var i,o;await lf(t,{count:-1});const r=await((i=W.rtcClient)==null?void 0:i.joinLivingRoom(t,e));if((r==null?void 0:r.code)!=M.SUCCESS)throw Error("\u52A0\u5165\u623F\u95F4\u5931\u8D25");return(o=r.room)==null||o.registerRoomEventListener(n),r},pp=async(t,e,n)=>await fp(t,e,n),Yd=async(t=!0)=>{var n;if(W.videoStatus!=="stream"){const r="\u8BF7\u786E\u5B9A\u6444\u50CF\u5934\u5DF2\u7ECF\u5F00\u542F";throw Jt.error(r),Error(r)}W.joinedRoom&&(await Nt([W.activeTracks.camera],"camera"),await Nt([W.activeTracks.microphone],"microphone"),await vt.get("/api-web/imLiveBroadcastRoom/opsLiveVideo",{params:{type:"1",roomUid:W.roomUid,userId:(n=he.user)==null?void 0:n.speakerId}}),W.videoStatus="liveing"),t&&sessionStorage.setItem(ga,ft().valueOf().toString()),sessionStorage.setItem(ma,"liveing")},Jd=async(t=!1)=>{var e,n;await vt.get("/api-web/imLiveBroadcastRoom/opsLiveVideo",{params:{type:"2",roomUid:W.roomUid,userId:(e=he.user)==null?void 0:e.speakerId}}),sessionStorage.removeItem(ga),sessionStorage.removeItem(ma);for(const r in W.activeTracks)if(Object.prototype.hasOwnProperty.call(W.activeTracks,r)){const i=W.activeTracks[r];i&&(await((n=W.joinedRoom)==null?void 0:n.unpublish([i])),t&&await xi([i],r))}W.videoStatus="stream"},Wd=async()=>{if((W.likeCount!==W.lastLikeCount||W.likeCount===0)&&he.user)try{await vt.get("/api-web/imLiveBroadcastRoom/syncLike",{hideLoading:!0,hideMessage:!0,params:{likeNum:W.likeCount,roomUid:W.roomUid}}),W.lastLikeCount=W.likeCount}catch{}setTimeout(()=>{Wd()},1e3*30)},gi=()=>{var t,e,n,r;return{id:String((t=he.user)==null?void 0:t.speakerId),name:(e=he.user)==null?void 0:e.speakerName,userId:String((n=he.user)==null?void 0:n.speakerId),userName:(r=he.user)==null?void 0:r.speakerName}},bt=async(t,e="text")=>{var i;let n=null;if(!t)return;const r={conversationType:re.CHATROOM,targetId:(i=W.joinedRoom)==null?void 0:i._roomId};if(e==="text"?n=new gf({user:gi(),content:t}):e==="SeatsCtrl"?n=new np(t):e==="ChatBan"?n=new rp(t):e==="SeatApply"?n=new ip(t):e==="SeatResponse"?n=new op(t):e==="MemberCount"?n=new sp(t):e==="SeatMember"&&(n=new ap(t)),!!n)return console.log(n),await zu(r,n)},zd=async(t,e=!0)=>{var n;if(t==="microphone"&&W.activeTracks[t])(n=W.activeTracks[t])==null||n.unmute();else{const r=await vn(t);await Nt([r],t,e),W.videoRef&&(r==null||r.play(W.videoRef))}},yn=async(t,e=!0)=>{const n=W.activeTracks[t];t!=="microphone"?await xi([n],t,e):n==null||n.mute()},gp=async t=>{const e=W.activeTracks[t],n=W.videoStatus==="liveing";e?(t==="camera"&&(W.deviceStatus.camera="closed"),yn(t,n)):(t==="camera"&&(W.deviceStatus.camera="granted"),zd(t,n))},Qd=async()=>{var t;await Jd(!0),W.joinedRoom&&(await((t=W.rtcClient)==null?void 0:t.leaveRoom(W.joinedRoom)),W.joinedRoom=null)};var mp="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAJy0lEQVRYR62ZeXTTVRbHPy9tU5qmC90oqSylDBYBPbgM6PEIOqioVEekMgocdMTDjkwtAxTBslNgKrJDBaWnIoyKMgozc8bBQQdBFodddlpKW5bSJulC0yS/35z3a9KmadIUZ945yR959933fffd+73v3gh+wVBVVQc8CDwBPADcDXQEIlzqqoAy4CxwBNgDHBZCKHe6nbiTBaqqJgETgZFAJ/daVVVp+CigAgKE0CGE0D6uUQwUAGuEECVt3bdNAFVVjQXmAW8AoVK5BHTt6hVOHTnEyYMHuF50icobZThs9QTr9UQnmujT/1GeHPoyCSZ5rsZhAzYBc4QQtwIBDQhQVdXhwGogTipzOp2cOHSAr/M3U3b+JDHGcBJjowgNCUGnkzevwcfpVLlZaaH4lpX0yZkMTHvRY14TKgcmCSG2twbSL0BVVYOBlcC4hksDq7mS/PdyuHDgO5JN8UQYwjyv0Oc+druD45eKeSVzDo889Yy3vHSI9cAUIYTDlwKfAFVVDQM+BZ5zLzLfuknO1PEYbVZMCfLG2z4cTifHr9xg1vp8Ejt19rVwF5AuhLjtPdkCoMtyX3qCq7fZmDd2NFGOKuKiIl32bDtAKVlWXoHpoYG89vZMfwslyN96W9IXwLXAeM8I/eLDPP7z1TaSTQkBr9Tf7k6nwumyCmZ/sJX2cfH+xNYJISZ4TjYD6AqIT9w+JwWrLWamD0+jbzcTQY1BcGfWc0uX3qzAQiivTZ9Nz74P+jqs9MlXPAOnEaCLSs64o9Wt9O+ffsK+rRtJTkr8Zai8VtXV13P0Qgnv5BXQKaW7L50yulPdFOQJcA3QzLyS65ZMHUdUbTlhofqAAJ2Kovna9QorApWOce3pENseXRNZazrMVTUEdU5lyvyl/nSuFULIhNBAH64McdFNwq7f2Pv1Tj5fv4K+XRMD+p6luobCmxb6Pf08jz31LE5rBbu//JzSn4+SnNShGRB58NPXq5j30TYMRnd2bCYiyTxFZhw3wEVAs/CqtlqYMGQQBqHQr0+PVqynUm62ctMezNiZc0lJ7SlPDNVmLOYK5rw1nvuSTS0OeKLoOjM3FhDf0eRP92IhRJZwJf5Cz9wqV5QWXWbBmFeJDtPzq85+lSAtV1zlYM7qD4hqH9O0WXUlqqKwauli6q5dIj46qhmQE4Vl/FHy4l0+eVHKytzdVQL8NfCj9zGKL13g/Slv0C0xlrB2WvptMWpu13HuuoWZ762nozcB11hAcXK9rIx5mVPok2wiNEQmp4ZxqrSSdzdvIyI6ujXf7icBzgAWe0uZK24xd/Qw+nTu4NP/aurqOFtawVsLc+nes5cP9FZQHNqj4vCBH9iyKpfUTomEG9pRZ6vnlj6arFV53vnZW89MCVCmtGHeM1JxztRxhFSUEBPl6cgqVTV1nL9hZvLcpfTofa9vC9RawdmUXk8dP8qWtatIDA+m0lpNyoBnGT01M1DwfSYBHgf6+AK4dMYMzuzfw/3dkzAawlAUlZKbt6h0BpGxMJdOyd38X8/tKnDYm82XlVxl0cxpOFWV0JgujMnMoNf9ff3qUFX1hAR405uc5YobZdfYsCSHUWNeZ3lWBkF1VYh2Ru4fMIhhr72JwWhszXfgdjU46pvLqHDm9El2fPEVacNfZe+3e5k0S3qY31EuAdZ58p9btPhyIds3bCQzew5/3pJPu3Z6Hh88GGNkVKBraVDhw4Ly50qzmfz87aSlD2Pn5zv4w9x3WwNo8wvQbrfzzviJTMiYSuGFi1gtVtLSX2rdap6zXj7onjpz5hw/HTuN2WwmpVcvnn7xhdauWAPo84rlqrMnT7Fq/kLi4uLQ6/VkLV7QdoA1DVHsPT7d9hk7d+6m/+MDGTstgxC9/xSqqqp2xT6DxK1YvgV/PnaczStWsmzdGvRtyMna2mozyCLKY0hmWDB3Ea9OnkK3Hj0QutYrDkVRtCDxSTPeinNmzOKFYUPp2ad3YCtqqa6yhVxFRSXvr9zAu6tWBOI/ba2qqhrN+CRqb+3HDx3mX7t2M3n6tMBBojhBZhKv8ZeduzAkdGTQ80MCHxJwOBwaUftMdd4aZDWXPWUqvx8/juTuKa1vIOlF0ozHqKquZvnylUxfmoMhPDwgQEVRZAWppTpZK7Z4LPjScProMbbnbWJ2ziKCg5vyagtZWy3US/ZqGPKZvCnvI1If6sejT/4mIDgpoChKsU6n6+r3ueVLizzV1g15OG02Rr75BkFBQS3FpP9JipHX7Crwv/9+H8fPXGTc9GmtH8x9IFXW1c7FISEhWX4frP6O6XA4WL1gERHhRkaNHaPRT7PhtEOtbM1oVmDPP/ey/9BPZC6cT5jB0Fbr2Ww2W4rBYGh4sLpO2uLJ70+b4lTYUfAxe3f/VbPkQw/3RyetqVmvClVxcKXoCpvzttClZ09GTRjXKt9572O329fq9fqmJ78LoKzGWxRNvkBKPjt28BCL3s7grq4p2lXHxscRLh8U9nqqLFZqamu5UlzCsg83Yerc2GcKaEGn01leW1ubGhkZqfVtApadvjReLSxiReaLdI4pIfXJNTwy4DHKiy5RV1urEXlsXCxlpaXkLX+dkPYPkr3+Y9qFyWZF60NVVdVut78SGhra2K8JWLh7qpSWc9jtbFyeS8+QZSTEKOw4OoLZCxcgZOQ2+QtbC7bSwbmEE+f0hPXIZMjwdBJNJoL8RL+m2+FYp9fr/RfurquW/NGs9SEXX71cyGf5Bfzj4I+UWirJGXKWQf3r+dMWI6beE3kpfbgWBA67jX/v/YZvdy4ma0w5K7eGs9E2EIPZwj2hBtIGDyZteDoRUU01itRvt9t36fX6wK0PF8jG5pG5ooKP1qzj4/37uNarB3WmRIKrqhh5LJ8lkyzU3Ba8lRPJeboRZozAXmmmd0QRORkWFAVG5HZh/7MjIEiHqLcTfrGQ7oWlTBw1kmeGDtVcwgWubc0jj6gOLrp0aeXsGVnjvouLFDU9UrRNXCFP0jd7WPrwIXb+YORv8QOw9rkHWZ9LEPEHDjIi8giJMU7mW5+h6t57ZMu10QN0NhsxR07wu6Su6tvZs9cbjcY7a795+p1p1rTh9QnxqxENDUz3CDZbifvmOyoe6099QrMpjW4M5y8TcfocN54bhOpRzbnXh+h05d2KSiftW5b7yxqYnmAiVi+K1TtD5gmhNraAtfwlv7zaGk2B4nteJ4TNGKLfdF9C9Jwvho7+31vAnkBj1+Um4bBPBDFSqE1N9ED0Ief1QUHFQUJXcF9czJqvXx79/22itwCQna2LjQmT/bMnUMUDOqHejSo6qqgRslEkhND+hhBCd1ZVlCOxkeF7Tl++fpjs7Dv+G+K/XpA1Lg9OfHQAAAAASUVORK5CYII=",_p=Ve({methods:{async loginOut(){try{await Qd(),await vt.post("/api-auth/exit",{data:{}}),yn("camera"),yn("microphone"),he.user=null,Jt.success("\u9000\u51FA\u6210\u529F"),au(),this.$router.push({path:"/login",query:ot({},this.$route.query)})}catch{}}},render(){var t,e,n;return I("div",{class:At.liveHeader},[I("div",{class:At.liveHeaderLeft},[I("div",{class:At.liveHeaderLeftIcon},[I("img",{class:At.liveLogo,src:(t=he.user)==null?void 0:t.tenantLogo,alt:""},null),(e=he.user)==null?void 0:e.tenantName]),I("div",{class:At.liveHeaderLeftText},[ne("\u300A"),(n=he.user)==null?void 0:n.roomTitle,ne("\u300B")])]),I(Vr,{trigger:"hover"},{default:()=>{var r,i,o;return[I("div",{class:At.avatarWrapper},[((r=he.user)==null?void 0:r.speakerPic)?I("img",{class:At.userAvatar,src:(i=he.user)==null?void 0:i.speakerPic},null):I("img",{class:At.userAvatar,src:mp},null),I("span",null,[(o=he.user)==null?void 0:o.speakerName])])]},dropdown:()=>I(Io,null,{default:()=>[I(bo,{command:"1",onClick:this.loginOut},{default:()=>[I("span",null,[ne("\u5B89\u5168\u9000\u51FA")])]})]})})])}});const vp="_header_22t18_1",yp="_title_22t18_9";var jc={header:vp,title:yp},Cp=Ve({name:"LiveBroadcastHeader",methods:{async startLive(){try{await Ma.confirm("\u662F\u5426\u786E\u8BA4\u5F00\u59CB\u76F4\u64AD\uFF1F","\u63D0\u793A",{confirmButtonText:"\u786E\u5B9A",cancelButtonText:"\u53D6\u6D88",type:"warning"}),await Yd(),Jt.success("\u5F00\u542F\u6210\u529F")}catch(t){console.log(t)}},async closeLive(){try{await Ma.confirm("\u662F\u5426\u786E\u8BA4\u7ED3\u675F\u76F4\u64AD\uFF1F","\u63D0\u793A",{confirmButtonText:"\u786E\u5B9A",cancelButtonText:"\u53D6\u6D88",type:"warning"}),await Jd(),Jt.success("\u5173\u95ED\u6210\u529F")}catch{}}},render(){var t;return I("div",{class:jc.header},[I("h3",{class:jc.title},[ne("\u76F4\u64AD\u5185\u5BB9\uFF1A"),(t=he.user)==null?void 0:t.liveRemark]),Z.videoStatus==="liveing"?I(pt,{type:"danger",color:"#EA4132",onClick:this.closeLive},{default:()=>[ne("\u5173\u95ED\u76F4\u64AD")]}):I(pt,{type:"primary",color:"#01A79E",onClick:this.startLive},{default:()=>[ne("\u5F00\u59CB\u76F4\u64AD")]})])}});const Ep="_volumeSlider_1akc3_71",Rp="_volumeIcon_1akc3_80",Tp="_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:Ep,volumeIcon:Rp,btnInner:Tp};const Sp="_shareWrap_d61fv_1",Ip="_shareBtn_d61fv_27";var Et={shareWrap:Sp,shareBtn:Ip};function bp(){let t=window.location.href,e="";return/online/.test(t)?e="https://mstuonline.dayaedu.com":/dev/.test(t)?e="http://mstudev.dayaedu.com":/test/.test(t)?e="http://mstutest.dayaedu.com":e="http://mstudev.dayaedu.com",e}var Xd=globalThis&&globalThis.__awaiter||function(t,e,n,r){function i(o){return o instanceof n?o:new n(function(s){s(o)})}return new(n||(n=Promise))(function(o,s){function c(h){try{l(r.next(h))}catch(a){s(a)}}function d(h){try{l(r.throw(h))}catch(a){s(a)}}function l(h){h.done?o(h.value):i(h.value).then(c,d)}l((r=r.apply(t,e||[])).next())})};const $c="application/font-woff",Kc="image/jpeg",wp={woff:$c,woff2:$c,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:Kc,jpeg:Kc,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml"};function Op(t){const e=/\.([^./]*?)$/g.exec(t);return e?e[1]:""}function mi(t){const e=Op(t).toLowerCase();return wp[e]||""}function Np(t,e){if(t.match(/^[a-z]+:\/\//i))return t;if(t.match(/^\/\//))return window.location.protocol+t;if(t.match(/^[a-z]+:/i))return t;const n=document.implementation.createHTMLDocument(),r=n.createElement("base"),i=n.createElement("a");return n.head.appendChild(r),n.body.appendChild(i),e&&(r.href=e),i.href=t,i.href}function as(t){return t.search(/^(data:)/)!==-1}function _i(t,e){return`data:${e};base64,${t}`}function Ap(t){return t.split(/,/)[1]}const Mp=function(){let e=0;const n=()=>`0000${(Math.random()*Math.pow(36,4)<<0).toString(36)}`.slice(-4);return()=>(e+=1,`u${n()}${e}`)}();function jt(t){const e=[];for(let n=0,r=t.length;n<r;n+=1)e.push(t[n]);return e}function vi(t,e){const n=window.getComputedStyle(t).getPropertyValue(e);return parseFloat(n.replace("px",""))}function Pp(t){const e=vi(t,"border-left-width"),n=vi(t,"border-right-width");return t.clientWidth+e+n}function Lp(t){const e=vi(t,"border-top-width"),n=vi(t,"border-bottom-width");return t.clientHeight+e+n}function kp(){let t,e;try{e=process}catch{}const n=e&&e.env?e.env.devicePixelRatio:null;return n&&(t=parseInt(n,10),Number.isNaN(t)&&(t=1)),t||window.devicePixelRatio||1}function _a(t){return new Promise((e,n)=>{const r=new Image;r.onload=()=>e(r),r.onerror=n,r.crossOrigin="anonymous",r.decoding="sync",r.src=t})}function Up(t){return Xd(this,void 0,void 0,function*(){return Promise.resolve().then(()=>new XMLSerializer().serializeToString(t)).then(encodeURIComponent).then(e=>`data:image/svg+xml;charset=utf-8,${e}`)})}function Dp(t,e,n){return Xd(this,void 0,void 0,function*(){const r="http://www.w3.org/2000/svg",i=document.createElementNS(r,"svg"),o=document.createElementNS(r,"foreignObject");return i.setAttribute("width",`${e}`),i.setAttribute("height",`${n}`),i.setAttribute("viewBox",`0 0 ${e} ${n}`),o.setAttribute("width","100%"),o.setAttribute("height","100%"),o.setAttribute("x","0"),o.setAttribute("y","0"),o.setAttribute("externalResourcesRequired","true"),i.appendChild(o),o.appendChild(t),Up(i)})}const ho={};function xp(t){let e=t.replace(/\?.*/,"");return/ttf|otf|eot|woff2?/i.test(e)&&(e=e.replace(/.*\//,"")),e}function va(t,e){const n=xp(t);if(ho[n]!=null)return ho[n];e.cacheBust&&(t+=(/\?/.test(t)?"&":"?")+new Date().getTime());const r=o=>{let s="";if(e.imagePlaceholder){const d=e.imagePlaceholder.split(/,/);d&&d[1]&&(s=d[1])}let c=`Failed to fetch resource: ${t}`;return o&&(c=typeof o=="string"?o:o.message),c&&console.error(c),{blob:s,contentType:""}},i=window.fetch(t).then(o=>o.blob().then(s=>({blob:s,contentType:o.headers.get("Content-Type")||""}))).then(({blob:o,contentType:s})=>new Promise((c,d)=>{const l=new FileReader;l.onloadend=()=>c({contentType:s,blob:l.result}),l.onerror=d,l.readAsDataURL(o)})).then(({blob:o,contentType:s})=>({contentType:s,blob:Ap(o)})).catch(r);return ho[n]=i,i}function Bp(t){const e=t.getPropertyValue("content");return`${t.cssText} content: '${e.replace(/'|"/g,"")}';`}function Vp(t){return jt(t).map(e=>{const n=t.getPropertyValue(e),r=t.getPropertyPriority(e);return`${e}: ${n}${r?" !important":""};`}).join(" ")}function Fp(t,e,n){const r=`.${t}:${e}`,i=n.cssText?Bp(n):Vp(n);return document.createTextNode(`${r}{${i}}`)}function qc(t,e,n){const r=window.getComputedStyle(t,n),i=r.getPropertyValue("content");if(i===""||i==="none")return;const o=Mp();try{e.className=`${e.className} ${o}`}catch{return}const s=document.createElement("style");s.appendChild(Fp(o,n,r)),e.appendChild(s)}function Hp(t,e){qc(t,e,":before"),qc(t,e,":after")}var Nn=globalThis&&globalThis.__awaiter||function(t,e,n,r){function i(o){return o instanceof n?o:new n(function(s){s(o)})}return new(n||(n=Promise))(function(o,s){function c(h){try{l(r.next(h))}catch(a){s(a)}}function d(h){try{l(r.throw(h))}catch(a){s(a)}}function l(h){h.done?o(h.value):i(h.value).then(c,d)}l((r=r.apply(t,e||[])).next())})};function jp(t){return Nn(this,void 0,void 0,function*(){const e=t.toDataURL();return e==="data:,"?Promise.resolve(t.cloneNode(!1)):_a(e)})}function $p(t,e){return Nn(this,void 0,void 0,function*(){return Promise.resolve(t.poster).then(n=>va(n,e)).then(n=>_i(n.blob,mi(t.poster)||n.contentType)).then(n=>_a(n))})}function Kp(t,e){return Nn(this,void 0,void 0,function*(){return t instanceof HTMLCanvasElement?jp(t):t instanceof HTMLVideoElement&&t.poster?$p(t,e):Promise.resolve(t.cloneNode(!1))})}const qp=t=>t.tagName!=null&&t.tagName.toUpperCase()==="SLOT";function Gp(t,e,n){var r;return Nn(this,void 0,void 0,function*(){const i=qp(t)&&t.assignedNodes?jt(t.assignedNodes()):jt(((r=t.shadowRoot)!==null&&r!==void 0?r:t).childNodes);return i.length===0||t instanceof HTMLVideoElement?Promise.resolve(e):i.reduce((o,s)=>o.then(()=>Zd(s,n)).then(c=>{c&&e.appendChild(c)}),Promise.resolve()).then(()=>e)})}function Yp(t,e){const n=window.getComputedStyle(t),r=e.style;!r||(n.cssText?r.cssText=n.cssText:jt(n).forEach(i=>{r.setProperty(i,n.getPropertyValue(i),n.getPropertyPriority(i))}))}function Jp(t,e){t instanceof HTMLTextAreaElement&&(e.innerHTML=t.value),t instanceof HTMLInputElement&&e.setAttribute("value",t.value)}function Wp(t,e){return Nn(this,void 0,void 0,function*(){return e instanceof Element?Promise.resolve().then(()=>Yp(t,e)).then(()=>Hp(t,e)).then(()=>Jp(t,e)).then(()=>e):Promise.resolve(e)})}function Zd(t,e,n){return Nn(this,void 0,void 0,function*(){return!n&&e.filter&&!e.filter(t)?Promise.resolve(null):Promise.resolve(t).then(r=>Kp(r,e)).then(r=>Gp(t,r,e)).then(r=>Wp(t,r))})}var zp=globalThis&&globalThis.__awaiter||function(t,e,n,r){function i(o){return o instanceof n?o:new n(function(s){s(o)})}return new(n||(n=Promise))(function(o,s){function c(h){try{l(r.next(h))}catch(a){s(a)}}function d(h){try{l(r.throw(h))}catch(a){s(a)}}function l(h){h.done?o(h.value):i(h.value).then(c,d)}l((r=r.apply(t,e||[])).next())})};const el=/url\((['"]?)([^'"]+?)\1\)/g,Qp=/url\([^)]+\)\s*format\((["'])([^"']+)\1\)/g,Xp=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function Zp(t){const e=t.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return new RegExp(`(url\\(['"]?)(${e})(['"]?\\))`,"g")}function eg(t){const e=[];return t.replace(el,(n,r,i)=>(e.push(i),n)),e.filter(n=>!as(n))}function tg(t,e,n,r,i){const o=n?Np(e,n):e;return Promise.resolve(o).then(s=>i?i(s):va(s,r)).then(s=>typeof s=="string"?_i(s,mi(e)):_i(s.blob,mi(e)||s.contentType)).then(s=>t.replace(Zp(e),`$1${s}$3`)).then(s=>s,()=>o)}function ng(t,{preferredFontFormat:e}){return e?t.replace(Xp,n=>{for(;;){const[r,,i]=Qp.exec(n)||[];if(!i)return"";if(i===e)return`src: ${r};`}}):t}function tl(t){return t.search(el)!==-1}function nl(t,e,n){return zp(this,void 0,void 0,function*(){if(!tl(t))return Promise.resolve(t);const r=ng(t,n);return Promise.resolve(r).then(eg).then(i=>i.reduce((o,s)=>o.then(c=>tg(c,s,e,n)),Promise.resolve(r)))})}var Bi=globalThis&&globalThis.__awaiter||function(t,e,n,r){function i(o){return o instanceof n?o:new n(function(s){s(o)})}return new(n||(n=Promise))(function(o,s){function c(h){try{l(r.next(h))}catch(a){s(a)}}function d(h){try{l(r.throw(h))}catch(a){s(a)}}function l(h){h.done?o(h.value):i(h.value).then(c,d)}l((r=r.apply(t,e||[])).next())})};function rg(t,e){var n;return Bi(this,void 0,void 0,function*(){const r=(n=t.style)===null||n===void 0?void 0:n.getPropertyValue("background");return r?Promise.resolve(r).then(i=>nl(i,null,e)).then(i=>(t.style.setProperty("background",i,t.style.getPropertyPriority("background")),t)):Promise.resolve(t)})}function ig(t,e){return Bi(this,void 0,void 0,function*(){if(!(t instanceof HTMLImageElement&&!as(t.src))&&!(t instanceof SVGImageElement&&!as(t.href.baseVal)))return Promise.resolve(t);const n=t instanceof HTMLImageElement?t.src:t.href.baseVal;return Promise.resolve(n).then(r=>va(r,e)).then(r=>_i(r.blob,mi(n)||r.contentType)).then(r=>new Promise((i,o)=>{t.onload=i,t.onerror=o,t instanceof HTMLImageElement?(t.srcset="",t.src=r):t.href.baseVal=r})).then(()=>t,()=>t)})}function og(t,e){return Bi(this,void 0,void 0,function*(){const r=jt(t.childNodes).map(i=>rl(i,e));return Promise.all(r).then(()=>t)})}function rl(t,e){return Bi(this,void 0,void 0,function*(){return t instanceof Element?Promise.resolve(t).then(n=>rg(n,e)).then(n=>ig(n,e)).then(n=>og(n,e)):Promise.resolve(t)})}function sg(t,e){const{style:n}=t;e.backgroundColor&&(n.backgroundColor=e.backgroundColor),e.width&&(n.width=`${e.width}px`),e.height&&(n.height=`${e.height}px`);const r=e.style;return r!=null&&Object.keys(r).forEach(i=>{n[i]=r[i]}),t}var gr=globalThis&&globalThis.__awaiter||function(t,e,n,r){function i(o){return o instanceof n?o:new n(function(s){s(o)})}return new(n||(n=Promise))(function(o,s){function c(h){try{l(r.next(h))}catch(a){s(a)}}function d(h){try{l(r.throw(h))}catch(a){s(a)}}function l(h){h.done?o(h.value):i(h.value).then(c,d)}l((r=r.apply(t,e||[])).next())})};const Gc={};function Yc(t){const e=Gc[t];if(e!=null)return e;const n=window.fetch(t).then(r=>({url:t,cssText:r.text()}));return Gc[t]=n,n}function Jc(t){return gr(this,void 0,void 0,function*(){return t.cssText.then(e=>{let n=e;const r=/url\(["']?([^"')]+)["']?\)/g,o=(n.match(/url\([^)]+\)/g)||[]).map(s=>{let c=s.replace(r,"$1");return c.startsWith("https://")||(c=new URL(c,t.url).href),window.fetch(c).then(d=>d.blob()).then(d=>new Promise((l,h)=>{const a=new FileReader;a.onloadend=()=>{n=n.replace(s,`url(${a.result})`),l([s,a.result])},a.onerror=h,a.readAsDataURL(d)}))});return Promise.all(o).then(()=>n)})})}function Wc(t){if(t==null)return[];const e=[],n=/(\/\*[\s\S]*?\*\/)/gi;let r=t.replace(n,"");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 o=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,s="((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})",c=new RegExp(s,"gi");for(;;){let d=o.exec(r);if(d===null){if(d=c.exec(r),d===null)break;o.lastIndex=c.lastIndex}else c.lastIndex=o.lastIndex;e.push(d[0])}return e}function ag(t){return gr(this,void 0,void 0,function*(){const e=[],n=[];return t.forEach(r=>{if("cssRules"in r)try{jt(r.cssRules).forEach((i,o)=>{if(i.type===CSSRule.IMPORT_RULE){let s=o+1;const c=i.href,d=Yc(c).then(l=>l?Jc(l):"").then(l=>Wc(l).forEach(h=>{try{r.insertRule(h,h.startsWith("@import")?s+=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())});n.push(d)}})}catch(i){const o=t.find(s=>s.href==null)||document.styleSheets[0];r.href!=null&&n.push(Yc(r.href).then(s=>s?Jc(s):"").then(s=>Wc(s).forEach(c=>{o.insertRule(c,r.cssRules.length)})).catch(s=>{console.error("Error loading remote stylesheet",s.toString())})),console.error("Error inlining remote css file",i.toString())}}),Promise.all(n).then(()=>(t.forEach(r=>{if("cssRules"in r)try{jt(r.cssRules).forEach(i=>{e.push(i)})}catch(i){console.error(`Error while reading CSS rules from ${r.href}`,i.toString())}}),e))})}function cg(t){return t.filter(e=>e.type===CSSRule.FONT_FACE_RULE).filter(e=>tl(e.style.getPropertyValue("src")))}function ug(t){return gr(this,void 0,void 0,function*(){return new Promise((e,n)=>{t.ownerDocument==null&&n(new Error("Provided element is not within a Document")),e(jt(t.ownerDocument.styleSheets))}).then(e=>ag(e)).then(cg)})}function dg(t,e){return gr(this,void 0,void 0,function*(){return ug(t).then(n=>Promise.all(n.map(r=>{const i=r.parentStyleSheet?r.parentStyleSheet.href:null;return nl(r.cssText,i,e)}))).then(n=>n.join(`
- `))})}function lg(t,e){return gr(this,void 0,void 0,function*(){return(e.fontEmbedCSS!=null?Promise.resolve(e.fontEmbedCSS):dg(t,e)).then(n=>{const r=document.createElement("style"),i=document.createTextNode(n);return r.appendChild(i),t.firstChild?t.insertBefore(r,t.firstChild):t.appendChild(r),t})})}var ya=globalThis&&globalThis.__awaiter||function(t,e,n,r){function i(o){return o instanceof n?o:new n(function(s){s(o)})}return new(n||(n=Promise))(function(o,s){function c(h){try{l(r.next(h))}catch(a){s(a)}}function d(h){try{l(r.throw(h))}catch(a){s(a)}}function l(h){h.done?o(h.value):i(h.value).then(c,d)}l((r=r.apply(t,e||[])).next())})};function il(t,e={}){const n=e.width||Pp(t),r=e.height||Lp(t);return{width:n,height:r}}function hg(t,e={}){return ya(this,void 0,void 0,function*(){const{width:n,height:r}=il(t,e);return Promise.resolve(t).then(i=>Zd(i,e,!0)).then(i=>lg(i,e)).then(i=>rl(i,e)).then(i=>sg(i,e)).then(i=>Dp(i,n,r))})}const Xe=16384;function fg(t){(t.width>Xe||t.height>Xe)&&(t.width>Xe&&t.height>Xe?t.width>t.height?(t.height*=Xe/t.width,t.width=Xe):(t.width*=Xe/t.height,t.height=Xe):t.width>Xe?(t.height*=Xe/t.width,t.width=Xe):(t.width*=Xe/t.height,t.height=Xe))}function pg(t,e={}){return ya(this,void 0,void 0,function*(){return hg(t,e).then(_a).then(n=>{const r=document.createElement("canvas"),i=r.getContext("2d"),o=e.pixelRatio||kp(),{width:s,height:c}=il(t,e),d=e.canvasWidth||s,l=e.canvasHeight||c;return r.width=d*o,r.height=l*o,e.skipAutoScale||fg(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(n,0,0,r.width,r.height),r})})}function gg(t,e={}){return ya(this,void 0,void 0,function*(){return pg(t,e).then(n=>n.toDataURL())})}var ol={exports:{}};/*!
- * clipboard.js v2.0.10
- * https://clipboardjs.com/
- *
- * Licensed MIT © Zeno Rocha
- */(function(t,e){(function(r,i){t.exports=i()})(cu,function(){return function(){var n={686:function(o,s,c){c.d(s,{default:function(){return ce}});var d=c(279),l=c.n(d),h=c(370),a=c.n(h),u=c(817),f=c.n(u);function p(X){try{return document.execCommand(X)}catch{return!1}}var m=function(z){var q=f()(z);return p("cut"),q},_=m;function v(X){var z=document.documentElement.getAttribute("dir")==="rtl",q=document.createElement("textarea");q.style.fontSize="12pt",q.style.border="0",q.style.padding="0",q.style.margin="0",q.style.position="absolute",q.style[z?"right":"left"]="-9999px";var J=window.pageYOffset||document.documentElement.scrollTop;return q.style.top="".concat(J,"px"),q.setAttribute("readonly",""),q.value=X,q}var y=function(z){var q=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{container:document.body},J="";if(typeof z=="string"){var L=v(z);q.container.appendChild(L),J=f()(L),p("copy"),L.remove()}else J=f()(z),p("copy");return J},C=y;function b(X){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?b=function(q){return typeof q}:b=function(q){return q&&typeof Symbol=="function"&&q.constructor===Symbol&&q!==Symbol.prototype?"symbol":typeof q},b(X)}var N=function(){var z=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},q=z.action,J=q===void 0?"copy":q,L=z.container,$=z.target,te=z.text;if(J!=="copy"&&J!=="cut")throw new Error('Invalid "action" value, use either "copy" or "cut"');if($!==void 0)if($&&b($)==="object"&&$.nodeType===1){if(J==="copy"&&$.hasAttribute("disabled"))throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute');if(J==="cut"&&($.hasAttribute("readonly")||$.hasAttribute("disabled")))throw new Error(`Invalid "target" attribute. You can't cut text from elements with "readonly" or "disabled" attributes`)}else throw new Error('Invalid "target" value, use a valid Element');if(te)return C(te,{container:L});if($)return J==="cut"?_($):C($,{container:L})},S=N;function E(X){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?E=function(q){return typeof q}:E=function(q){return q&&typeof Symbol=="function"&&q.constructor===Symbol&&q!==Symbol.prototype?"symbol":typeof q},E(X)}function w(X,z){if(!(X instanceof z))throw new TypeError("Cannot call a class as a function")}function V(X,z){for(var q=0;q<z.length;q++){var J=z[q];J.enumerable=J.enumerable||!1,J.configurable=!0,"value"in J&&(J.writable=!0),Object.defineProperty(X,J.key,J)}}function K(X,z,q){return z&&V(X.prototype,z),q&&V(X,q),X}function R(X,z){if(typeof z!="function"&&z!==null)throw new TypeError("Super expression must either be null or a function");X.prototype=Object.create(z&&z.prototype,{constructor:{value:X,writable:!0,configurable:!0}}),z&&T(X,z)}function T(X,z){return T=Object.setPrototypeOf||function(J,L){return J.__proto__=L,J},T(X,z)}function A(X){var z=F();return function(){var J=H(X),L;if(z){var $=H(this).constructor;L=Reflect.construct(J,arguments,$)}else L=J.apply(this,arguments);return k(this,L)}}function k(X,z){return z&&(E(z)==="object"||typeof z=="function")?z:U(X)}function U(X){if(X===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return X}function F(){if(typeof Reflect=="undefined"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function H(X){return H=Object.setPrototypeOf?Object.getPrototypeOf:function(q){return q.__proto__||Object.getPrototypeOf(q)},H(X)}function Q(X,z){var q="data-clipboard-".concat(X);if(!!z.hasAttribute(q))return z.getAttribute(q)}var ee=function(X){R(q,X);var z=A(q);function q(J,L){var $;return w(this,q),$=z.call(this),$.resolveOptions(L),$.listenClick(J),$}return K(q,[{key:"resolveOptions",value:function(){var L=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.action=typeof L.action=="function"?L.action:this.defaultAction,this.target=typeof L.target=="function"?L.target:this.defaultTarget,this.text=typeof L.text=="function"?L.text:this.defaultText,this.container=E(L.container)==="object"?L.container:document.body}},{key:"listenClick",value:function(L){var $=this;this.listener=a()(L,"click",function(te){return $.onClick(te)})}},{key:"onClick",value:function(L){var $=L.delegateTarget||L.currentTarget,te=this.action($)||"copy",se=S({action:te,container:this.container,target:this.target($),text:this.text($)});this.emit(se?"success":"error",{action:te,text:se,trigger:$,clearSelection:function(){$&&$.focus(),document.activeElement.blur(),window.getSelection().removeAllRanges()}})}},{key:"defaultAction",value:function(L){return Q("action",L)}},{key:"defaultTarget",value:function(L){var $=Q("target",L);if($)return document.querySelector($)}},{key:"defaultText",value:function(L){return Q("text",L)}},{key:"destroy",value:function(){this.listener.destroy()}}],[{key:"copy",value:function(L){var $=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{container:document.body};return C(L,$)}},{key:"cut",value:function(L){return _(L)}},{key:"isSupported",value:function(){var L=arguments.length>0&&arguments[0]!==void 0?arguments[0]:["copy","cut"],$=typeof L=="string"?[L]:L,te=!!document.queryCommandSupported;return $.forEach(function(se){te=te&&!!document.queryCommandSupported(se)}),te}}]),q}(l()),ce=ee},828:function(o){var s=9;if(typeof Element!="undefined"&&!Element.prototype.matches){var c=Element.prototype;c.matches=c.matchesSelector||c.mozMatchesSelector||c.msMatchesSelector||c.oMatchesSelector||c.webkitMatchesSelector}function d(l,h){for(;l&&l.nodeType!==s;){if(typeof l.matches=="function"&&l.matches(h))return l;l=l.parentNode}}o.exports=d},438:function(o,s,c){var d=c(828);function l(u,f,p,m,_){var v=a.apply(this,arguments);return u.addEventListener(p,v,_),{destroy:function(){u.removeEventListener(p,v,_)}}}function h(u,f,p,m,_){return typeof u.addEventListener=="function"?l.apply(null,arguments):typeof p=="function"?l.bind(null,document).apply(null,arguments):(typeof u=="string"&&(u=document.querySelectorAll(u)),Array.prototype.map.call(u,function(v){return l(v,f,p,m,_)}))}function a(u,f,p,m){return function(_){_.delegateTarget=d(_.target,f),_.delegateTarget&&m.call(u,_)}}o.exports=h},879:function(o,s){s.node=function(c){return c!==void 0&&c instanceof HTMLElement&&c.nodeType===1},s.nodeList=function(c){var d=Object.prototype.toString.call(c);return c!==void 0&&(d==="[object NodeList]"||d==="[object HTMLCollection]")&&"length"in c&&(c.length===0||s.node(c[0]))},s.string=function(c){return typeof c=="string"||c instanceof String},s.fn=function(c){var d=Object.prototype.toString.call(c);return d==="[object Function]"}},370:function(o,s,c){var d=c(879),l=c(438);function h(p,m,_){if(!p&&!m&&!_)throw new Error("Missing required arguments");if(!d.string(m))throw new TypeError("Second argument must be a String");if(!d.fn(_))throw new TypeError("Third argument must be a Function");if(d.node(p))return a(p,m,_);if(d.nodeList(p))return u(p,m,_);if(d.string(p))return f(p,m,_);throw new TypeError("First argument must be a String, HTMLElement, HTMLCollection, or NodeList")}function a(p,m,_){return p.addEventListener(m,_),{destroy:function(){p.removeEventListener(m,_)}}}function u(p,m,_){return Array.prototype.forEach.call(p,function(v){v.addEventListener(m,_)}),{destroy:function(){Array.prototype.forEach.call(p,function(v){v.removeEventListener(m,_)})}}}function f(p,m,_){return l(document.body,p,m,_)}o.exports=h},817:function(o){function s(c){var d;if(c.nodeName==="SELECT")c.focus(),d=c.value;else if(c.nodeName==="INPUT"||c.nodeName==="TEXTAREA"){var l=c.hasAttribute("readonly");l||c.setAttribute("readonly",""),c.select(),c.setSelectionRange(0,c.value.length),l||c.removeAttribute("readonly"),d=c.value}else{c.hasAttribute("contenteditable")&&c.focus();var h=window.getSelection(),a=document.createRange();a.selectNodeContents(c),h.removeAllRanges(),h.addRange(a),d=h.toString()}return d}o.exports=s},279:function(o){function s(){}s.prototype={on:function(c,d,l){var h=this.e||(this.e={});return(h[c]||(h[c]=[])).push({fn:d,ctx:l}),this},once:function(c,d,l){var h=this;function a(){h.off(c,a),d.apply(l,arguments)}return a._=d,this.on(c,a,l)},emit:function(c){var d=[].slice.call(arguments,1),l=((this.e||(this.e={}))[c]||[]).slice(),h=0,a=l.length;for(h;h<a;h++)l[h].fn.apply(l[h].ctx,d);return this},off:function(c,d){var l=this.e||(this.e={}),h=l[c],a=[];if(h&&d)for(var u=0,f=h.length;u<f;u++)h[u].fn!==d&&h[u].fn._!==d&&a.push(h[u]);return a.length?l[c]=a:delete l[c],this}},o.exports=s,o.exports.TinyEmitter=s}},r={};function i(o){if(r[o])return r[o].exports;var s=r[o]={exports:{}};return n[o](s,s.exports,i),s.exports}return function(){i.n=function(o){var s=o&&o.__esModule?function(){return o.default}:function(){return o};return i.d(s,{a:s}),s}}(),function(){i.d=function(o,s){for(var c in s)i.o(s,c)&&!i.o(o,c)&&Object.defineProperty(o,c,{enumerable:!0,get:s[c]})}}(),function(){i.o=function(o,s){return Object.prototype.hasOwnProperty.call(o,s)}}(),i(686)}().default})})(ol);var mg=Ol(ol.exports);const _g="_shareWrap_ap100_1",vg="_chioseBox_ap100_5",yg="_cell_ap100_17",Cg="_dotle_ap100_27",Eg="_teamInfo_ap100_38",Rg="_title_ap100_42",Tg="_subInfo_ap100_47",Sg="_tableWrap_ap100_51";var Pt={shareWrap:_g,chioseBox:vg,cell:yg,dotle:Cg,teamInfo:Eg,title:Rg,subInfo:Tg,tableWrap:Sg};function Ig(t){return typeof t=="function"||Object.prototype.toString.call(t)==="[object Object]"&&!lu(t)}var bg=Ve({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 t=await vt("/api-web/imGroup/queryGroupList",{params:ot({},this.searchForm)});this.tableList=t.data}catch(t){console.log(t)}},resectCheck(t){const e=t;this.checkList.indexOf(e)==-1?this.checkList.push(e):this.checkList.splice(this.checkList.indexOf(e),1)}},render(){let t;return I("div",null,[I(uu,{model:this.searchForm,ref:"form",inline:!0,class:Pt.form},{default:()=>[I(wo,null,{default:()=>[I(du,{clearable:!0,placeholder:"\u7FA4\u804A\u540D\u79F0/\u8BFE\u7A0B\u540D\u79F0",modelValue:this.searchForm.search,onInput:e=>this.searchForm.search=e},null)]}),I(wo,null,{default:()=>[I(pt,{type:"primary",onClick:this.search},{default:()=>[ne("\u641C\u7D22")]}),I(pt,{type:"danger",onClick:this.onReSet},{default:()=>[ne("\u91CD\u7F6E")]})]})]}),this.tableList.length>0?I("div",{class:Pt.tableWrap},[I(Nl,{modelValue:this.checkList},Ig(t=this.tableList.map(e=>I("div",{class:Pt.cell,onClick:()=>this.resectCheck(e.id)},[I(Al,{class:Pt.chioseBox,label:e.id,onChange:()=>this.resectCheck(e.id)},{default:()=>[I("br",null,null)]}),I("div",{class:Pt.dotle},[e.type=="MUSIC"?"\u4E50\u56E2":"VIP"]),I("div",{class:Pt.teamInfo},[I("p",{class:Pt.title},[e.name]),I("p",{class:Pt.subInfo},[e.memo,ne("\uFF08\u5171"),e.memberNum,ne("\u4EBA\uFF09")])])])))?t:{default:()=>[t]})]):I(Ml,{description:"\u6682\u65E0\u7FA4\u804A"},null)])}});const wg="_third_a6fb3_1",Og="_preCore_a6fb3_19",Ng="_title_a6fb3_19",Ag="_second_a6fb3_22",Mg="_first_a6fb3_43",Pg="_icon_a6fb3_61",Lg="_teacher_a6fb3_68",kg="_start_a6fb3_85",Ug="_time_a6fb3_104",Dg="_content_a6fb3_113",xg="_pre_a6fb3_19",Bg="_end_a6fb3_133",Vg="_bottom_a6fb3_140",Fg="_logo_a6fb3_146",Hg="_code_a6fb3_150";var ue={third:wg,preCore:Og,title:Ng,second:Ag,first:Mg,icon:Pg,teacher:Lg,start:kg,time:Ug,content:Dg,pre:xg,end:Bg,bottom:Vg,logo:Fg,code:Hg},mr={},jg=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then},sl={},it={};let Ca;const $g=[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];it.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};it.getSymbolTotalCodewords=function(e){return $g[e]};it.getBCHDigit=function(t){let e=0;for(;t!==0;)e++,t>>>=1;return e};it.setToSJISFunction=function(e){if(typeof e!="function")throw new Error('"toSJISFunc" is not a valid function.');Ca=e};it.isKanjiModeEnabled=function(){return typeof Ca!="undefined"};it.toSJIS=function(e){return Ca(e)};var Vi={};(function(t){t.L={bit:1},t.M={bit:0},t.Q={bit:3},t.H={bit:2};function e(n){if(typeof n!="string")throw new Error("Param is not a string");switch(n.toLowerCase()){case"l":case"low":return t.L;case"m":case"medium":return t.M;case"q":case"quartile":return t.Q;case"h":case"high":return t.H;default:throw new Error("Unknown EC Level: "+n)}}t.isValid=function(r){return r&&typeof r.bit!="undefined"&&r.bit>=0&&r.bit<4},t.from=function(r,i){if(t.isValid(r))return r;try{return e(r)}catch{return i}}})(Vi);function al(){this.buffer=[],this.length=0}al.prototype={get:function(t){const e=Math.floor(t/8);return(this.buffer[e]>>>7-t%8&1)===1},put:function(t,e){for(let n=0;n<e;n++)this.putBit((t>>>e-n-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(t){const e=Math.floor(this.length/8);this.buffer.length<=e&&this.buffer.push(0),t&&(this.buffer[e]|=128>>>this.length%8),this.length++}};var Kg=al;function _r(t){if(!t||t<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=t,this.data=new Uint8Array(t*t),this.reservedBit=new Uint8Array(t*t)}_r.prototype.set=function(t,e,n,r){const i=t*this.size+e;this.data[i]=n,r&&(this.reservedBit[i]=!0)};_r.prototype.get=function(t,e){return this.data[t*this.size+e]};_r.prototype.xor=function(t,e,n){this.data[t*this.size+e]^=n};_r.prototype.isReserved=function(t,e){return this.reservedBit[t*this.size+e]};var qg=_r,cl={};(function(t){const e=it.getSymbolSize;t.getRowColCoords=function(r){if(r===1)return[];const i=Math.floor(r/7)+2,o=e(r),s=o===145?26:Math.ceil((o-13)/(2*i-2))*2,c=[o-7];for(let d=1;d<i-1;d++)c[d]=c[d-1]-s;return c.push(6),c.reverse()},t.getPositions=function(r){const i=[],o=t.getRowColCoords(r),s=o.length;for(let c=0;c<s;c++)for(let d=0;d<s;d++)c===0&&d===0||c===0&&d===s-1||c===s-1&&d===0||i.push([o[c],o[d]]);return i}})(cl);var ul={};const Gg=it.getSymbolSize,zc=7;ul.getPositions=function(e){const n=Gg(e);return[[0,0],[n-zc,0],[0,n-zc]]};var dl={};(function(t){t.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};t.isValid=function(i){return i!=null&&i!==""&&!isNaN(i)&&i>=0&&i<=7},t.from=function(i){return t.isValid(i)?parseInt(i,10):void 0},t.getPenaltyN1=function(i){const o=i.size;let s=0,c=0,d=0,l=null,h=null;for(let a=0;a<o;a++){c=d=0,l=h=null;for(let u=0;u<o;u++){let f=i.get(a,u);f===l?c++:(c>=5&&(s+=e.N1+(c-5)),l=f,c=1),f=i.get(u,a),f===h?d++:(d>=5&&(s+=e.N1+(d-5)),h=f,d=1)}c>=5&&(s+=e.N1+(c-5)),d>=5&&(s+=e.N1+(d-5))}return s},t.getPenaltyN2=function(i){const o=i.size;let s=0;for(let c=0;c<o-1;c++)for(let d=0;d<o-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)&&s++}return s*e.N2},t.getPenaltyN3=function(i){const o=i.size;let s=0,c=0,d=0;for(let l=0;l<o;l++){c=d=0;for(let h=0;h<o;h++)c=c<<1&2047|i.get(l,h),h>=10&&(c===1488||c===93)&&s++,d=d<<1&2047|i.get(h,l),h>=10&&(d===1488||d===93)&&s++}return s*e.N3},t.getPenaltyN4=function(i){let o=0;const s=i.data.length;for(let d=0;d<s;d++)o+=i.data[d];return Math.abs(Math.ceil(o*100/s/5)-10)*e.N4};function n(r,i,o){switch(r){case t.Patterns.PATTERN000:return(i+o)%2===0;case t.Patterns.PATTERN001:return i%2===0;case t.Patterns.PATTERN010:return o%3===0;case t.Patterns.PATTERN011:return(i+o)%3===0;case t.Patterns.PATTERN100:return(Math.floor(i/2)+Math.floor(o/3))%2===0;case t.Patterns.PATTERN101:return i*o%2+i*o%3===0;case t.Patterns.PATTERN110:return(i*o%2+i*o%3)%2===0;case t.Patterns.PATTERN111:return(i*o%3+(i+o)%2)%2===0;default:throw new Error("bad maskPattern:"+r)}}t.applyMask=function(i,o){const s=o.size;for(let c=0;c<s;c++)for(let d=0;d<s;d++)o.isReserved(d,c)||o.xor(d,c,n(i,d,c))},t.getBestMask=function(i,o){const s=Object.keys(t.Patterns).length;let c=0,d=1/0;for(let l=0;l<s;l++){o(l),t.applyMask(l,i);const h=t.getPenaltyN1(i)+t.getPenaltyN2(i)+t.getPenaltyN3(i)+t.getPenaltyN4(i);t.applyMask(l,i),h<d&&(d=h,c=l)}return c}})(dl);var Fi={};const Ft=Vi,Dr=[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],xr=[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];Fi.getBlocksCount=function(e,n){switch(n){case Ft.L:return Dr[(e-1)*4+0];case Ft.M:return Dr[(e-1)*4+1];case Ft.Q:return Dr[(e-1)*4+2];case Ft.H:return Dr[(e-1)*4+3];default:return}};Fi.getTotalCodewordsCount=function(e,n){switch(n){case Ft.L:return xr[(e-1)*4+0];case Ft.M:return xr[(e-1)*4+1];case Ft.Q:return xr[(e-1)*4+2];case Ft.H:return xr[(e-1)*4+3];default:return}};var ll={},Hi={};const zn=new Uint8Array(512),yi=new Uint8Array(256);(function(){let e=1;for(let n=0;n<255;n++)zn[n]=e,yi[e]=n,e<<=1,e&256&&(e^=285);for(let n=255;n<512;n++)zn[n]=zn[n-255]})();Hi.log=function(e){if(e<1)throw new Error("log("+e+")");return yi[e]};Hi.exp=function(e){return zn[e]};Hi.mul=function(e,n){return e===0||n===0?0:zn[yi[e]+yi[n]]};(function(t){const e=Hi;t.mul=function(r,i){const o=new Uint8Array(r.length+i.length-1);for(let s=0;s<r.length;s++)for(let c=0;c<i.length;c++)o[s+c]^=e.mul(r[s],i[c]);return o},t.mod=function(r,i){let o=new Uint8Array(r);for(;o.length-i.length>=0;){const s=o[0];for(let d=0;d<i.length;d++)o[d]^=e.mul(i[d],s);let c=0;for(;c<o.length&&o[c]===0;)c++;o=o.slice(c)}return o},t.generateECPolynomial=function(r){let i=new Uint8Array([1]);for(let o=0;o<r;o++)i=t.mul(i,new Uint8Array([1,e.exp(o)]));return i}})(ll);const hl=ll;function Ea(t){this.genPoly=void 0,this.degree=t,this.degree&&this.initialize(this.degree)}Ea.prototype.initialize=function(e){this.degree=e,this.genPoly=hl.generateECPolynomial(this.degree)};Ea.prototype.encode=function(e){if(!this.genPoly)throw new Error("Encoder not initialized");const n=new Uint8Array(e.length+this.degree);n.set(e);const r=hl.mod(n,this.genPoly),i=this.degree-r.length;if(i>0){const o=new Uint8Array(this.degree);return o.set(r,i),o}return r};var Yg=Ea,fl={},$t={},Ra={};Ra.isValid=function(e){return!isNaN(e)&&e>=1&&e<=40};var yt={};const pl="[0-9]+",Jg="[A-Z $%*+\\-./:]+";let ar="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";ar=ar.replace(/u/g,"\\u");const Wg="(?:(?![A-Z0-9 $%*+\\-./:]|"+ar+`)(?:.|[\r
- ]))+`;yt.KANJI=new RegExp(ar,"g");yt.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g");yt.BYTE=new RegExp(Wg,"g");yt.NUMERIC=new RegExp(pl,"g");yt.ALPHANUMERIC=new RegExp(Jg,"g");const zg=new RegExp("^"+ar+"$"),Qg=new RegExp("^"+pl+"$"),Xg=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");yt.testKanji=function(e){return zg.test(e)};yt.testNumeric=function(e){return Qg.test(e)};yt.testAlphanumeric=function(e){return Xg.test(e)};(function(t){const e=Ra,n=yt;t.NUMERIC={id:"Numeric",bit:1<<0,ccBits:[10,12,14]},t.ALPHANUMERIC={id:"Alphanumeric",bit:1<<1,ccBits:[9,11,13]},t.BYTE={id:"Byte",bit:1<<2,ccBits:[8,16,16]},t.KANJI={id:"Kanji",bit:1<<3,ccBits:[8,10,12]},t.MIXED={bit:-1},t.getCharCountIndicator=function(o,s){if(!o.ccBits)throw new Error("Invalid mode: "+o);if(!e.isValid(s))throw new Error("Invalid version: "+s);return s>=1&&s<10?o.ccBits[0]:s<27?o.ccBits[1]:o.ccBits[2]},t.getBestModeForData=function(o){return n.testNumeric(o)?t.NUMERIC:n.testAlphanumeric(o)?t.ALPHANUMERIC:n.testKanji(o)?t.KANJI:t.BYTE},t.toString=function(o){if(o&&o.id)return o.id;throw new Error("Invalid mode")},t.isValid=function(o){return o&&o.bit&&o.ccBits};function r(i){if(typeof i!="string")throw new Error("Param is not a string");switch(i.toLowerCase()){case"numeric":return t.NUMERIC;case"alphanumeric":return t.ALPHANUMERIC;case"kanji":return t.KANJI;case"byte":return t.BYTE;default:throw new Error("Unknown mode: "+i)}}t.from=function(o,s){if(t.isValid(o))return o;try{return r(o)}catch{return s}}})($t);(function(t){const e=it,n=Fi,r=Vi,i=$t,o=Ra,s=1<<12|1<<11|1<<10|1<<9|1<<8|1<<5|1<<2|1<<0,c=e.getBCHDigit(s);function d(u,f,p){for(let m=1;m<=40;m++)if(f<=t.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)<=t.getCapacity(p,f,i.MIXED))return p}t.from=function(f,p){return o.isValid(f)?parseInt(f,10):p},t.getCapacity=function(f,p,m){if(!o.isValid(f))throw new Error("Invalid QR Code version");typeof m=="undefined"&&(m=i.BYTE);const _=e.getSymbolTotalCodewords(f),v=n.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)}},t.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(),_)},t.getEncodedBits=function(f){if(!o.isValid(f)||f<7)throw new Error("Invalid QR Code version");let p=f<<12;for(;e.getBCHDigit(p)-c>=0;)p^=s<<e.getBCHDigit(p)-c;return f<<12|p}})(fl);var gl={};const cs=it,ml=1<<10|1<<8|1<<5|1<<4|1<<2|1<<1|1<<0,Zg=1<<14|1<<12|1<<10|1<<4|1<<1,Qc=cs.getBCHDigit(ml);gl.getEncodedBits=function(e,n){const r=e.bit<<3|n;let i=r<<10;for(;cs.getBCHDigit(i)-Qc>=0;)i^=ml<<cs.getBCHDigit(i)-Qc;return(r<<10|i)^Zg};var _l={};const em=$t;function Cn(t){this.mode=em.NUMERIC,this.data=t.toString()}Cn.getBitsLength=function(e){return 10*Math.floor(e/3)+(e%3?e%3*3+1:0)};Cn.prototype.getLength=function(){return this.data.length};Cn.prototype.getBitsLength=function(){return Cn.getBitsLength(this.data.length)};Cn.prototype.write=function(e){let n,r,i;for(n=0;n+3<=this.data.length;n+=3)r=this.data.substr(n,3),i=parseInt(r,10),e.put(i,10);const o=this.data.length-n;o>0&&(r=this.data.substr(n),i=parseInt(r,10),e.put(i,o*3+1))};var tm=Cn;const nm=$t,fo=["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 En(t){this.mode=nm.ALPHANUMERIC,this.data=t}En.getBitsLength=function(e){return 11*Math.floor(e/2)+6*(e%2)};En.prototype.getLength=function(){return this.data.length};En.prototype.getBitsLength=function(){return En.getBitsLength(this.data.length)};En.prototype.write=function(e){let n;for(n=0;n+2<=this.data.length;n+=2){let r=fo.indexOf(this.data[n])*45;r+=fo.indexOf(this.data[n+1]),e.put(r,11)}this.data.length%2&&e.put(fo.indexOf(this.data[n]),6)};var rm=En,im=function(e){for(var n=[],r=e.length,i=0;i<r;i++){var o=e.charCodeAt(i);if(o>=55296&&o<=56319&&r>i+1){var s=e.charCodeAt(i+1);s>=56320&&s<=57343&&(o=(o-55296)*1024+s-56320+65536,i+=1)}if(o<128){n.push(o);continue}if(o<2048){n.push(o>>6|192),n.push(o&63|128);continue}if(o<55296||o>=57344&&o<65536){n.push(o>>12|224),n.push(o>>6&63|128),n.push(o&63|128);continue}if(o>=65536&&o<=1114111){n.push(o>>18|240),n.push(o>>12&63|128),n.push(o>>6&63|128),n.push(o&63|128);continue}n.push(239,191,189)}return new Uint8Array(n).buffer};const om=im,sm=$t;function Rn(t){this.mode=sm.BYTE,this.data=new Uint8Array(om(t))}Rn.getBitsLength=function(e){return e*8};Rn.prototype.getLength=function(){return this.data.length};Rn.prototype.getBitsLength=function(){return Rn.getBitsLength(this.data.length)};Rn.prototype.write=function(t){for(let e=0,n=this.data.length;e<n;e++)t.put(this.data[e],8)};var am=Rn;const cm=$t,um=it;function Tn(t){this.mode=cm.KANJI,this.data=t}Tn.getBitsLength=function(e){return e*13};Tn.prototype.getLength=function(){return this.data.length};Tn.prototype.getBitsLength=function(){return Tn.getBitsLength(this.data.length)};Tn.prototype.write=function(t){let e;for(e=0;e<this.data.length;e++){let n=um.toSJIS(this.data[e]);if(n>=33088&&n<=40956)n-=33088;else if(n>=57408&&n<=60351)n-=49472;else throw new Error("Invalid SJIS character: "+this.data[e]+`
- Make sure your charset is UTF-8`);n=(n>>>8&255)*192+(n&255),t.put(n,13)}};var dm=Tn,vl={exports:{}};(function(t){var e={single_source_shortest_paths:function(n,r,i){var o={},s={};s[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=n[l]||{};for(h in u)u.hasOwnProperty(h)&&(f=u[h],p=a+f,m=s[h],_=typeof s[h]=="undefined",(_||m>p)&&(s[h]=p,c.push(h,p),o[h]=l))}if(typeof i!="undefined"&&typeof s[i]=="undefined"){var v=["Could not find a path from ",r," to ",i,"."].join("");throw new Error(v)}return o},extract_shortest_path_from_predecessor_list:function(n,r){for(var i=[],o=r;o;)i.push(o),o=n[o];return i.reverse(),i},find_path:function(n,r,i){var o=e.single_source_shortest_paths(n,r,i);return e.extract_shortest_path_from_predecessor_list(o,i)},PriorityQueue:{make:function(n){var r=e.PriorityQueue,i={},o;n=n||{};for(o in r)r.hasOwnProperty(o)&&(i[o]=r[o]);return i.queue=[],i.sorter=n.sorter||r.default_sorter,i},default_sorter:function(n,r){return n.cost-r.cost},push:function(n,r){var i={value:n,cost:r};this.queue.push(i),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};t.exports=e})(vl);(function(t){const e=$t,n=tm,r=rm,i=am,o=dm,s=yt,c=it,d=vl.exports;function l(v){return unescape(encodeURIComponent(v)).length}function h(v,y,C){const b=[];let N;for(;(N=v.exec(C))!==null;)b.push({data:N[0],index:N.index,mode:y,length:N[0].length});return b}function a(v){const y=h(s.NUMERIC,e.NUMERIC,v),C=h(s.ALPHANUMERIC,e.ALPHANUMERIC,v);let b,N;return c.isKanjiModeEnabled()?(b=h(s.BYTE,e.BYTE,v),N=h(s.KANJI,e.KANJI,v)):(b=h(s.BYTE_KANJI,e.BYTE,v),N=[]),y.concat(C,b,N).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 n.getBitsLength(v);case e.ALPHANUMERIC:return r.getBitsLength(v);case e.KANJI:return o.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 N=["start"];for(let S=0;S<v.length;S++){const E=v[S],w=[];for(let V=0;V<E.length;V++){const K=E[V],R=""+S+V;w.push(R),C[R]={node:K,lastCount:0},b[R]={};for(let T=0;T<N.length;T++){const A=N[T];C[A]&&C[A].node.mode===K.mode?(b[A][R]=u(C[A].lastCount+K.length,K.mode)-u(C[A].lastCount,K.mode),C[A].lastCount+=K.length):(C[A]&&(C[A].lastCount=K.length),b[A][R]=u(K.length,K.mode)+4+e.getCharCountIndicator(K.mode,y))}}N=w}for(let S=0;S<N.length;S++)b[N[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)+`.
- Suggested mode is: `+e.toString(b));switch(C===e.KANJI&&!c.isKanjiModeEnabled()&&(C=e.BYTE),C){case e.NUMERIC:return new n(v);case e.ALPHANUMERIC:return new r(v);case e.KANJI:return new o(v);case e.BYTE:return new i(v)}}t.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},[])},t.fromString=function(y,C){const b=a(y,c.isKanjiModeEnabled()),N=p(b),S=m(N,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 t.fromArray(f(w))},t.rawSplit=function(y){return t.fromArray(a(y,c.isKanjiModeEnabled()))}})(_l);const ji=it,po=Vi,lm=Kg,hm=qg,fm=cl,pm=ul,us=dl,ds=Fi,gm=Yg,Ci=fl,mm=gl,_m=$t,go=_l;function vm(t,e){const n=t.size,r=pm.getPositions(e);for(let i=0;i<r.length;i++){const o=r[i][0],s=r[i][1];for(let c=-1;c<=7;c++)if(!(o+c<=-1||n<=o+c))for(let d=-1;d<=7;d++)s+d<=-1||n<=s+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?t.set(o+c,s+d,!0,!0):t.set(o+c,s+d,!1,!0))}}function ym(t){const e=t.size;for(let n=8;n<e-8;n++){const r=n%2===0;t.set(n,6,r,!0),t.set(6,n,r,!0)}}function Cm(t,e){const n=fm.getPositions(e);for(let r=0;r<n.length;r++){const i=n[r][0],o=n[r][1];for(let s=-2;s<=2;s++)for(let c=-2;c<=2;c++)s===-2||s===2||c===-2||c===2||s===0&&c===0?t.set(i+s,o+c,!0,!0):t.set(i+s,o+c,!1,!0)}}function Em(t,e){const n=t.size,r=Ci.getEncodedBits(e);let i,o,s;for(let c=0;c<18;c++)i=Math.floor(c/3),o=c%3+n-8-3,s=(r>>c&1)===1,t.set(i,o,s,!0),t.set(o,i,s,!0)}function mo(t,e,n){const r=t.size,i=mm.getEncodedBits(e,n);let o,s;for(o=0;o<15;o++)s=(i>>o&1)===1,o<6?t.set(o,8,s,!0):o<8?t.set(o+1,8,s,!0):t.set(r-15+o,8,s,!0),o<8?t.set(8,r-o-1,s,!0):o<9?t.set(8,15-o-1+1,s,!0):t.set(8,15-o-1,s,!0);t.set(r-8,8,1,!0)}function Rm(t,e){const n=t.size;let r=-1,i=n-1,o=7,s=0;for(let c=n-1;c>0;c-=2)for(c===6&&c--;;){for(let d=0;d<2;d++)if(!t.isReserved(i,c-d)){let l=!1;s<e.length&&(l=(e[s]>>>o&1)===1),t.set(i,c-d,l),o--,o===-1&&(s++,o=7)}if(i+=r,i<0||n<=i){i-=r,r=-r;break}}}function Tm(t,e,n){const r=new lm;n.forEach(function(d){r.put(d.mode.bit,4),r.put(d.getLength(),_m.getCharCountIndicator(d.mode,t)),d.write(r)});const i=ji.getSymbolTotalCodewords(t),o=ds.getTotalCodewordsCount(t,e),s=(i-o)*8;for(r.getLengthInBits()+4<=s&&r.put(0,4);r.getLengthInBits()%8!==0;)r.putBit(0);const c=(s-r.getLengthInBits())/8;for(let d=0;d<c;d++)r.put(d%2?17:236,8);return Sm(r,t,e)}function Sm(t,e,n){const r=ji.getSymbolTotalCodewords(e),i=ds.getTotalCodewordsCount(e,n),o=r-i,s=ds.getBlocksCount(e,n),c=r%s,d=s-c,l=Math.floor(r/s),h=Math.floor(o/s),a=h+1,u=l-h,f=new gm(u);let p=0;const m=new Array(s),_=new Array(s);let v=0;const y=new Uint8Array(t.buffer);for(let E=0;E<s;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,N,S;for(N=0;N<v;N++)for(S=0;S<s;S++)N<m[S].length&&(C[b++]=m[S][N]);for(N=0;N<u;N++)for(S=0;S<s;S++)C[b++]=_[S][N];return C}function Im(t,e,n,r){let i;if(Array.isArray(t))i=go.fromArray(t);else if(typeof t=="string"){let l=e;if(!l){const h=go.rawSplit(t);l=Ci.getBestVersionForData(h,n)}i=go.fromString(t,l||40)}else throw new Error("Invalid data");const o=Ci.getBestVersionForData(i,n);if(!o)throw new Error("The amount of data is too big to be stored in a QR Code");if(!e)e=o;else if(e<o)throw new Error(`
- The chosen QR Code version cannot contain this amount of data.
- Minimum version required to store current data is: `+o+`.
- `);const s=Tm(e,n,i),c=ji.getSymbolSize(e),d=new hm(c);return vm(d,e),ym(d),Cm(d,e),mo(d,n,0),e>=7&&Em(d,e),Rm(d,s),isNaN(r)&&(r=us.getBestMask(d,mo.bind(null,d,n))),us.applyMask(r,d),mo(d,n,r),{modules:d,version:e,errorCorrectionLevel:n,maskPattern:r,segments:i}}sl.create=function(e,n){if(typeof e=="undefined"||e==="")throw new Error("No input text");let r=po.M,i,o;return typeof n!="undefined"&&(r=po.from(n.errorCorrectionLevel,po.M),i=Ci.from(n.version),o=us.from(n.maskPattern),n.toSJISFunc&&ji.setToSJISFunction(n.toSJISFunc)),Im(e,i,r,o)};var yl={},Ta={};(function(t){function e(n){if(typeof n=="number"&&(n=n.toString()),typeof n!="string")throw new Error("Color should be defined as hex string");let r=n.slice().replace("#","").split("");if(r.length<3||r.length===5||r.length>8)throw new Error("Invalid hex color: "+n);(r.length===3||r.length===4)&&(r=Array.prototype.concat.apply([],r.map(function(o){return[o,o]}))),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("")}}t.getOptions=function(r){r||(r={}),r.color||(r.color={});const i=typeof r.margin=="undefined"||r.margin===null||r.margin<0?4:r.margin,o=r.width&&r.width>=21?r.width:void 0,s=r.scale||4;return{width:o,scale:o?4:s,margin:i,color:{dark:e(r.color.dark||"#000000ff"),light:e(r.color.light||"#ffffffff")},type:r.type,rendererOpts:r.rendererOpts||{}}},t.getScale=function(r,i){return i.width&&i.width>=r+i.margin*2?i.width/(r+i.margin*2):i.scale},t.getImageWidth=function(r,i){const o=t.getScale(r,i);return Math.floor((r+i.margin*2)*o)},t.qrToImageData=function(r,i,o){const s=i.modules.size,c=i.modules.data,d=t.getScale(s,o),l=Math.floor((s+o.margin*2)*d),h=o.margin*d,a=[o.color.light,o.color.dark];for(let u=0;u<l;u++)for(let f=0;f<l;f++){let p=(u*l+f)*4,m=o.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[_*s+v]?1:0]}r[p++]=m.r,r[p++]=m.g,r[p++]=m.b,r[p]=m.a}}})(Ta);(function(t){const e=Ta;function n(i,o,s){i.clearRect(0,0,o.width,o.height),o.style||(o.style={}),o.height=s,o.width=s,o.style.height=s+"px",o.style.width=s+"px"}function r(){try{return document.createElement("canvas")}catch{throw new Error("You need to specify a canvas element")}}t.render=function(o,s,c){let d=c,l=s;typeof d=="undefined"&&(!s||!s.getContext)&&(d=s,s=void 0),s||(l=r()),d=e.getOptions(d);const h=e.getImageWidth(o.modules.size,d),a=l.getContext("2d"),u=a.createImageData(h,h);return e.qrToImageData(u.data,o,d),n(a,l,h),a.putImageData(u,0,0),l},t.renderToDataURL=function(o,s,c){let d=c;typeof d=="undefined"&&(!s||!s.getContext)&&(d=s,s=void 0),d||(d={});const l=t.render(o,s,d),h=d.type||"image/png",a=d.rendererOpts||{};return l.toDataURL(h,a.quality)}})(yl);var Cl={};const bm=Ta;function Xc(t,e){const n=t.a/255,r=e+'="'+t.hex+'"';return n<1?r+" "+e+'-opacity="'+n.toFixed(2).slice(1)+'"':r}function _o(t,e,n){let r=t+e;return typeof n!="undefined"&&(r+=" "+n),r}function wm(t,e,n){let r="",i=0,o=!1,s=0;for(let c=0;c<t.length;c++){const d=Math.floor(c%e),l=Math.floor(c/e);!d&&!o&&(o=!0),t[c]?(s++,c>0&&d>0&&t[c-1]||(r+=o?_o("M",d+n,.5+l+n):_o("m",i,0),i=0,o=!1),d+1<e&&t[c+1]||(r+=_o("h",s),s=0)):i++}return r}Cl.render=function(e,n,r){const i=bm.getOptions(n),o=e.modules.size,s=e.modules.data,c=o+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="'+wm(s,o,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>
- `;return typeof r=="function"&&r(null,u),u};const Om=jg,ls=sl,El=yl,Nm=Cl;function Sa(t,e,n,r,i){const o=[].slice.call(arguments,1),s=o.length,c=typeof o[s-1]=="function";if(!c&&!Om())throw new Error("Callback required as last argument");if(c){if(s<2)throw new Error("Too few arguments provided");s===2?(i=n,n=e,e=r=void 0):s===3&&(e.getContext&&typeof i=="undefined"?(i=r,r=void 0):(i=r,r=n,n=e,e=void 0))}else{if(s<1)throw new Error("Too few arguments provided");return s===1?(n=e,e=r=void 0):s===2&&!e.getContext&&(r=n,n=e,e=void 0),new Promise(function(d,l){try{const h=ls.create(n,r);d(t(h,e,r))}catch(h){l(h)}})}try{const d=ls.create(n,r);i(null,t(d,e,r))}catch(d){i(d)}}mr.create=ls.create;mr.toCanvas=Sa.bind(null,El.render);mr.toDataURL=Sa.bind(null,El.renderToDataURL);mr.toString=Sa.bind(null,function(t,e,n){return Nm.render(t,n)});var Am=mr,Mm="./assets/icon1.ef6bbd86.png",Pm="./assets/icon2.e7f0fa2e.png",Lm="./assets/icon3.0d23bbac.png",vo="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==",yo="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=",Co="./assets/logo.6e1120ae.png",Eo="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=",km=Ve({name:"LiveBroadcastSharePreview",props:["form","url"],data(){return{detail:{roomTitle:"",liveStartTime:"",liveRemark:""}}},mounted(){let t=document.getElementById("canvas"),e=this.url;Am.toCanvas(t,e,{width:79,margin:1},function(n){n&&console.error(n),console.log("QRCode success!")})},methods:{copyText(){},shareImage(){}},render(){return I("div",{id:"preview"},[this.form.preTemplate==="1"?I("div",{class:ue.first},[I("h2",null,[this.form.roomTitle]),I("p",{class:ue.teacher},[ne(" \u4E3B\u8BB2\u4EBA\uFF1A"),this.form.speakerName]),I("img",{src:Mm,class:ue.icon,alt:""},null),I("div",{class:ue.preCore},[I("img",{src:Eo,class:ue.start,alt:""},null),I("p",{class:ue.title},[ne("\u5F00\u64AD\u65F6\u95F4")]),I("p",{class:ue.time},[this.form.liveStartTime]),I("p",{class:ue.title},[ne("\u76F4\u64AD\u5185\u5BB9")]),I("div",{class:ue.content},[I("img",{class:ue.pre,src:yo,alt:""},null),I("img",{class:ue.end,src:vo,alt:""},null),this.form.liveRemark])]),I("div",{class:ue.bottom},[I("img",{class:ue.logo,src:Co,alt:""},null),I("div",{class:ue.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:ue.second},[I("h2",null,[this.form.roomTitle]),I("p",{class:ue.teacher},[ne("\u4E3B\u8BB2\u4EBA\uFF1A"),this.form.speakerName]),I("img",{src:Lm,class:ue.icon,alt:""},null),I("div",{class:ue.preCore},[I("img",{src:Eo,class:ue.start,alt:""},null),I("p",{class:ue.title},[ne("\u5F00\u64AD\u65F6\u95F4")]),I("p",{class:ue.time},[this.form.liveStartTime]),I("p",{class:ue.title},[ne("\u76F4\u64AD\u5185\u5BB9")]),I("div",{class:ue.content},[I("img",{class:ue.pre,src:yo,alt:""},null),I("img",{class:ue.end,src:vo,alt:""},null),this.form.liveRemark])]),I("div",{class:ue.bottom},[I("img",{class:ue.logo,src:Co,alt:""},null),I("div",{class:ue.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:ue.third},[I("h2",null,[this.form.roomTitle]),I("p",{class:ue.teacher},[ne("\u4E3B\u8BB2\u4EBA\uFF1A"),this.form.speakerName]),I("img",{src:Pm,class:ue.icon,alt:""},null),I("div",{class:ue.preCore},[I("img",{src:Eo,class:ue.start,alt:""},null),I("p",{class:ue.title},[ne("\u5F00\u64AD\u65F6\u95F4")]),I("p",{class:ue.time},[this.form.liveStartTime]),I("p",{class:ue.title},[ne("\u76F4\u64AD\u5185\u5BB9")]),I("div",{class:ue.content},[I("img",{class:ue.pre,src:yo,alt:""},null),I("img",{class:ue.end,src:vo,alt:""},null),this.form.liveRemark])]),I("div",{class:ue.bottom},[I("img",{class:ue.logo,src:Co,alt:""},null),I("div",{class:ue.code},[I("div",null,[I("canvas",{id:"canvas",height:"80",width:"80",style:"width: 80px; margin:0"},null)])])])]):null])}});const Zc=Ri(null);Ri(null);var Um=Ve({name:"LiveBroadcastShare",props:{onClose:{type:Function,default:()=>{}}},data(){return{form:{shareType:"1"},detail:{roomTitle:"",liveStartTime:"",liveRemark:"",roomUid:"",speakerName:""},url:""}},async mounted(){this.detail=ot({},he.user),this.url=bp()+`/#/liveClassTransfer?roomUid=${this.detail.roomUid}`},methods:{copyText(){let t=`\u4E50\u56E2\u8001\u5E08\u9080\u8BF7\u60A8\u53C2\u4E0E\u76F4\u64AD\u8BFE\uFF01
- ${this.detail.roomTitle||""}
- \u4E3B\u8BB2\u4EBA\uFF1A${this.detail.speakerName}
- \u76F4\u64AD\u65F6\u95F4\uFF1A${this.detail.liveStartTime||""}
- \u76F4\u64AD\u5185\u5BB9\uFF1A${this.detail.liveRemark||""}
- \u76F4\u64AD\u5730\u5740\uFF1A${this.url}
- `;if(t){const n=document.createElement("button");var e=new mg(n,{text:function(){return t}});e.on("success",()=>{Jt.success("\u590D\u5236\u6210\u529F"),this.onClose(),e.destroy()}),e.on("error",()=>{console.log("\u8BE5\u6D4F\u89C8\u5668\u4E0D\u652F\u6301\u81EA\u52A8\u590D\u5236"),e.destroy()}),n.click()}},shareImage(){var t=document.getElementById("preview");t&&gg(t).then(e=>{var n=new Image;n.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 t=((e=Zc.value)==null?void 0:e.checkList)||[];if(!(t.length>0)){Jt.error("\u8BF7\u81F3\u5C11\u9009\u62E9\u4E00\u4E2A\u7FA4\u804A");return}try{let n={groupIds:t.join(","),roomUid:this.detail.roomUid};const r=await vt.get("/api-web/imLiveBroadcastRoom/shareGroup",{params:ot({},n)});Jt.success("\u5206\u4EAB\u6210\u529F"),this.onClose()}catch(n){console.log(n)}},changeRafdio(t){this.form.shareType=t}},render(){return I("div",null,[I(uu,{model:this.form,ref:"form",class:Et.form},{default:()=>[I(wo,{label:"\u5206\u4EAB\u65B9\u5F0F"},{default:()=>[I(qi,{modelValue:this.form.shareType,onChange:()=>{this.changeRafdio("1")},label:"1"},{default:()=>[ne("\u94FE\u63A5\u5206\u4EAB")]}),I(qi,{modelValue:this.form.shareType,onChange:()=>{this.changeRafdio("2")},label:"2"},{default:()=>[ne("\u4E8C\u7EF4\u7801\u5206\u4EAB")]}),I(qi,{modelValue:this.form.shareType,onChange:()=>{this.changeRafdio("3")},label:"3"},{default:()=>[ne("\u7FA4\u804A\u5206\u4EAB")]})]})]}),I("div",null,[this.form.shareType==="1"?I("div",{class:"linkWrap"},[I("div",{class:Et.shareWrap},[I("h2",null,[ne("\u4E50\u56E2\u8001\u5E08\u9080\u8BF7\u60A8\u53C2\u4E0E\u76F4\u64AD\u8BFE\uFF01")]),I("h4",null,[this.detail.roomTitle]),I("p",null,[ne("\u4E3B\u8BB2\u4EBA\uFF1A"),this.detail.speakerName]),I("p",null,[ne("\u5F00\u64AD\u65F6\u95F4\uFF1A"),this.detail.liveStartTime]),I("p",null,[ne("\u76F4\u64AD\u5185\u5BB9\uFF1A"),this.detail.liveRemark]),I("p",null,[ne("\u76F4\u64AD\u5730\u5740\uFF1A"),this.url])]),I("div",{class:[Et.shareBtn,"shareText"],onClick:this.copyText,ref:"shareText","data-clipboard-action":"copy"},[ne("\u590D\u5236\u5206\u4EAB\u5185\u5BB9")])]):null]),this.form.shareType==="2"?I("div",{class:Et.codeWrap},[I("div",{class:Et.shareWrap},[I(km,{form:this.detail,url:this.url},null)]),I("div",{class:Et.shareBtn,onClick:this.shareImage},[ne("\u590D\u5236\u5206\u4EAB\u5185\u5BB9")])]):null,this.form.shareType=="3"?I("div",{class:Et.shareWrap},[I("div",{class:Et.groupWrap},[I(bg,{ref:Zc},null)]),I("div",{class:Et.shareBtn,onClick:this.shareChat},[ne("\u53D1\u9001\u5206\u4EAB\u4FE1\u606F")])]):null])}});function eu(t){return typeof t=="function"||Object.prototype.toString.call(t)==="[object Object]"&&!lu(t)}const Ne=Ei({volume:30,barStatus:{camera:!1,volume:!1,microphone:!1,screen:!1,share:!1},shareVisiable:!1});var Dm=Ve({name:"LiveBroadcast-ActionBar",computed:{isCameraDisabled(){return Ne.barStatus.camera&&Z.deviceStatus.camera!=="denied"&&Z.cameras.length},isMicrophoneDisabled(){return Ne.barStatus.microphone&&Z.deviceStatus.microphone!=="denied"&&Z.microphones.length},isVolumeDisabled(){return Ne.volume===0}},mounted(){console.log(Z.cameras,Z.cameras.length)},methods:{startShare(){console.log("\u8C03\u7528"),Ne.shareVisiable=!0},volumeChange(t){Ne.volume=t,Kd(t)}},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(Pe("SvgIcon"),{onClick:()=>{Ne.barStatus.camera=!Ne.barStatus.camera,gp("camera")},name:this.isCameraDisabled?"bar-camera-disabled":"bar-camera",style:{width:"22px",cursor:"pointer"}},null),Z.cameras.length===0?null:I(Vr,{placement:"top",disabled:Z.cameras.length===0,onCommand:qd},{default:()=>[I("div",{class:Se["bar-btn"],style:{height:"32px"}},[I(Pe("SvgIcon"),{name:"bar-arrow-down",style:{width:"18px"}},null)])],dropdown:()=>{let t;return I(Io,null,eu(t=Z.cameras.map(e=>I(bo,{disabled:e===Z.selectedCamera,command:e},{default:()=>[e.label]})))?t:{default:()=>[t]})}})]),I("span",{class:Se["bar-btn-text"]},[ne("\u6444\u50CF\u5934")])]),I("div",{class:Se["bar-btn"]},[I("div",{class:Se.btnInner},[I(Pe("SvgIcon"),{onClick:()=>{Ne.barStatus.volume=!Ne.barStatus.volume,Ne.barStatus.volume?(sessionStorage.setItem("volume",Ne.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(Vr,{placement:"top-start","popper-options":{boundariesElement:"#action-bar",gpuAcceleration:!1}},{default:()=>[I("div",{class:Se["bar-btn"],style:{height:"32px"}},[I(Pe("SvgIcon"),{name:"bar-arrow-down",style:{width:"18px"}},null)])],dropdown:()=>I("div",{class:Se.volumeSlider},[I(Pe("SvgIcon"),{class:Se.volumeIcon,name:"message-voice",color:"#fff"},null),I(Pl,{modelValue:Ne.volume,onInput:this.volumeChange,size:"small"},null)])})]),I("span",{class:Se["bar-btn-text"]},[ne("\u97F3\u91CF\u8C03\u8282")])]),I("div",{class:Se["bar-btn"],onClick:dp},[I("div",{class:Se.btnInner},[I(Pe("SvgIcon"),{name:"bar-screen-share",style:{width:"22px",cursor:"pointer"}},null)]),I("span",{class:Se["bar-btn-text"]},[ne("\u5C4F\u5E55\u5171\u4EAB")])]),I("div",{class:Se["bar-btn"]},[I("div",{class:Se.btnInner},[I(Pe("SvgIcon"),{onClick:()=>{const t=Z.videoStatus==="liveing";Ne.barStatus.microphone=!Ne.barStatus.microphone,Ne.barStatus.microphone?yn("microphone",t):zd("microphone",t)},name:this.isMicrophoneDisabled?"bar-mike-disabled":"bar-mike",style:{width:"22px",cursor:"pointer"}},null),Z.microphones.length===0?null:I(Vr,{placement:"top-start",disabled:Z.microphones.length===0,"popper-options":{boundariesElement:"#action-bar",gpuAcceleration:!1},onCommand:Gd},{default:()=>[I("div",{class:Se["bar-btn"],style:{height:"32px"}},[I(Pe("SvgIcon"),{name:"bar-arrow-down",style:{width:"18px"}},null)])],dropdown:()=>{let t;return I(Io,null,eu(t=Z.microphones.map(e=>I(bo,{disabled:e===Z.selectedMicrophone,command:e},{default:()=>[e.label]})))?t:{default:()=>[t]})}})]),I("span",{class:Se["bar-btn-text"]},[ne("\u9EA6\u514B\u98CE")])])]),I("div",{style:{display:"flex"},onClick:this.startShare},[I("div",{class:Se["bar-btn"]},[I("div",{class:Se.btnInner},[I(Pe("SvgIcon"),{name:"bar-share",style:{width:"22px",cursor:"pointer"}},null)]),I("span",{class:Se["bar-btn-text"]},[ne("\u5206\u4EAB")])])]),I(Ll,{width:"510px","destroy-on-close":!0,"append-to-body":!0,modelValue:Ne.shareVisiable,title:"\u5206\u4EAB","before-close":()=>{Ne.shareVisiable=!1}},{default:()=>[I(Um,{onClose:()=>Ne.shareVisiable=!1},null)]})])}});const xm="_container_19awp_1",Bm="_title_19awp_21",Vm="_tips_19awp_25";var ke={container:xm,title:Bm,tips:Vm},Fm=Ve({name:"VideoStatus",render(){return I("div",{class:ke.container},[Z.deviceStatus.camera==="denied"?I("div",{class:ke.denied},[I(Pe("SvgIcon"),{name:"camera-status",class:ke.icon},null),I("p",{class:ke.title},[ne("\u6444\u50CF\u5934\u88AB\u7981\u7528")]),I("p",{class:ke.tips},[ne("\u8BF7\u6388\u6743\u5141\u8BB8\u8BBF\u95EE\u6444\u50CF\u5934")])]):null,Z.deviceStatus.camera==="init"?I("div",{class:ke.init},[I(Pe("SvgIcon"),{name:"camera-status",class:ke.icon},null),I("p",{class:ke.title},[ne("\u8BF7\u5B8C\u6210\u6444\u50CF\u5934\u6388\u6743")]),I("p",{class:ke.tips},[ne("\u8BF7\u6388\u6743\u5141\u8BB8\u8BBF\u95EE\u6444\u50CF\u5934")])]):null,Z.deviceStatus.camera==="closed"?I("div",{class:ke.closed},[I(Pe("SvgIcon"),{name:"camera-status",class:ke.icon},null),I("p",{class:ke.title},[ne("\u6444\u50CF\u5934\u5DF2\u5173\u95ED")]),I("p",{class:ke.tips},[ne("\u60A8\u5DF2\u5173\u95ED\u6444\u50CF\u5934")])]):null,Z.deviceStatus.camera==="none"?I("div",{class:ke.none},[I(Pe("SvgIcon"),{name:"camera-status",class:ke.icon},null),I("p",{class:ke.title},[ne("\u6682\u65E0\u6444\u50CF\u5934")]),I("p",{class:ke.tips},[ne("\u8BE5\u8BBE\u5907\u65E0\u6444\u50CF\u5934")])]):null])}}),Rl={exports:{}};(function(t,e){(function(n,r){t.exports=r()})(cu,function(){var n,r,i=1e3,o=6e4,s=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:s,minutes:o,seconds:i,milliseconds:1,weeks:6048e5},f=function(N){return N instanceof b},p=function(N,S,E){return new b(N,E,S.$l)},m=function(N){return r.p(N)+"s"},_=function(N){return N<0},v=function(N){return _(N)?Math.ceil(N):Math.floor(N)},y=function(N){return Math.abs(N)},C=function(N,S){return N?_(N)?{negative:!0,format:""+y(N)+S}:{negative:!1,format:""+N+S}:{negative:!1,format:""}},b=function(){function N(E,w,V){var K=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){K.$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=N.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/s),E%=s,this.$d.minutes=v(E/o),E%=o,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 K=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 k=C(A,"S"),U=E.negative||w.negative||K.negative||R.negative||T.negative||k.negative,F=R.format||T.format||k.format?"T":"",H=(U?"-":"")+"P"+E.format+w.format+K.format+F+R.format+T.format+k.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(K,R){return R||String(V[K])})},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 K;return K=w?E*u[m(w)]:f(E)?E.$ms:p(E,this).$ms,p(this.$ms+K*(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 n().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")},N}();return function(N,S,E){n=E,r=E().$utils(),E.duration=function(K,R){var T=E.locale();return p(K,{$l:T},R)},E.isDuration=f;var w=S.prototype.add,V=S.prototype.subtract;S.prototype.add=function(K,R){return f(K)&&(K=K.asMilliseconds()),w.bind(this)(K,R)},S.prototype.subtract=function(K,R){return f(K)&&(K=K.asMilliseconds()),V.bind(this)(K,R)}}})})(Rl);var Hm=Rl.exports;const jm="_time_1c1wd_1",$m="_status_1c1wd_14",Km="_text_1c1wd_27";var Ro={time:jm,status:$m,text:Km};ft.extend(Hm);var qm=Ve({setup(){const t=Ei({duration:""}),e=sessionStorage.getItem(ga),n=Number(e);let r=null;return kl(()=>{r=setInterval(()=>{const i=ft().valueOf();n&&i-n&&(t.duration=ft.duration(i-n).format("HH:mm:ss"))})}),Ul(()=>{r&&clearInterval(r)}),()=>Z.videoStatus==="liveing"&&n?I("div",{class:Ro.time},[I("div",{class:Ro.status},[I("div",{class:"line-scale-pulse-out"},[I("div",null,null),I("div",null,null),I("div",null,null)]),I("span",null,[ne("\u76F4\u64AD\u4E2D")])]),I("span",{class:Ro.text},[t.duration])]):null}});const Gm="_main_1b4ip_1",Ym="_video_1b4ip_12";var tu={main:Gm,video:Ym};const nu=Ri(null);let ru,To;var Jm=Ve({name:"LiveBroadcast",async mounted(){this.initializeRoom(),Wd(),Ie.on(xe["RC:Chatroom:Like"],this.onLikeMessage),window.onbeforeunload=this.beforeunload},beforeUnmount(){Ie.off(xe["RC:Chatroom:Like"],this.onLikeMessage),window.onbeforeunload=null},methods:{beforeunload(){if(Z.videoStatus==="liveing")return"\u5F53\u524D\u6B63\u5728\u76F4\u64AD\u4E2D\u662F\u5426\u786E\u8BA4\u5173\u95ED\u9875\u9762\uFF1F"},onLikeMessage(t){Z.likeCount+=t.counts},getDeviceByDeviceType(t){const e=localStorage.getItem(Hd),n=localStorage.getItem(jd);return t==="camera"?e&&Z.cameras.find(r=>r.deviceId===e)||Z.cameras[0]:n&&Z.microphones.find(r=>r.deviceId===n)||Z.microphones[0]},async initializeRoom(){var t,e,n,r;if(!he.user)throw Error("\u8BF7\u5148\u767B\u5F55");try{Z.likeCount=((t=he.user)==null?void 0:t.likeNum)||0,Z.lookCount=((e=he.user)==null?void 0:e.lookNum)||0;const i=sessionStorage.getItem(ma)==="liveing";await up((n=he.user)==null?void 0:n.imToken),Z.videoRef=nu.value,await lp(),await hp(),qd(this.getDeviceByDeviceType("camera")),Gd(this.getDeviceByDeviceType("microphone")),To=await vn("camera"),Z.videoRef&&To.play(Z.videoRef),ru=await vn("microphone"),Z.videoStatus="stream";const o=await pp((r=he.user)==null?void 0:r.roomUid,mt.VIDEO,{onMessageReceive(c,d){console.log(c,d)},onKickOff(c){console.log(c)},async onTrackPublish(c){var l;const d=await((l=o==null?void 0:o.room)==null?void 0:l.subscribe(c));console.log(d),(d==null?void 0:d.code)&&d.code!==M.SUCCESS&&console.log("\u8D44\u6E90\u8BA2\u9605\u5931\u8D25 ->",d.code)},onTrackUnpublish(c){console.log(c),Ie.emit(xe["RM:RTC:TrackUnpublish"],c)},onSwitchRole(c,d){Ie.emit(xe["RM:RTC:SwitchRole"],{userId:c,role:d})},onTrackReady(c){c.isAudioTrack()&&c.play()},onUserJoin(c){console.log("onUserJoin",c)},onUserLeave(c){Ie.emit(xe["RM:RTC:UserLeave"],c),console.log("onUserLeave",c)}});o.room&&o.code===M.SUCCESS&&(Z.joinedRoom=o.room),i?(await Yd(!1),Z.videoStatus="liveing"):(await Nt([To],"camera",!1),await Nt([ru],"microphone",!1));const s=localStorage.getItem($d);s&&(Ne.volume=parseInt(s),Kd(parseInt(s)))}catch(i){Z.videoStatus="error",console.log(i)}},closeLive(){Z.videoStatus="stream"}},render(){return I("div",{class:tu.main},[I(Cp,null,null),I("div",{class:tu.video},[I("video",{ref:nu},null),Z.screenShareStatus?null:I(Fm,null,null),Z.videoStatus==="liveing"?I(qm,null,null):null]),I(Dm,null,null)])}});const Wm="_container_1cod9_1",zm="_dataCount_1cod9_6",Qm="_num_1cod9_17",Xm="_text_1cod9_22",Zm="_dataIcon_1cod9_26",e_="_tabContainer_1cod9_31",t_="_tabIcon_1cod9_31",n_="_point_1cod9_36",r_="_tabContent_1cod9_67",i_="_tabList_1cod9_73";var $e={container:Wm,dataCount:zm,num:Qm,text:Xm,dataIcon:Zm,tabContainer:e_,tabIcon:t_,point:n_,tabContent:r_,tabList:i_};const o_="_message_4zab7_1",s_="_buttonGroup_4zab7_1";var iu={message:o_,buttonGroup:s_},a_=Ve({name:"message",data(){return{options:"ALL"}},mounted(){var e,n;const t=((e=he.user)==null?void 0:e.roomConfig)?JSON.parse((n=he.user)==null?void 0:n.roomConfig):{};Z.allowChatCtrl=t.whether_chat===0,Z.allowSeatsCtrl=t.whether_mic===0},methods:{async SeatsCtrl(){try{const t=he.user,e=(t==null?void 0:t.roomConfig)?JSON.parse(t==null?void 0:t.roomConfig):{};await vt.post("/api-web/imLiveBroadcastRoom/update",{requestType:"json",data:{id:t.id,liveRemark:t.liveRemark,liveStartTime:t.liveStartTime,preTemplate:t.preTemplate,roomConfig:{whether_chat:e.whether_chat,whether_like:e.whether_like,whether_mic:Z.allowSeatsCtrl?1:0,whether_video:e.whether_video},roomTitle:t.roomTitle,speakerId:t.speakerId,tenantId:t.tenantId}}),await bt(ot({seatBan:Z.allowSeatsCtrl},gi()),"SeatsCtrl"),Z.allowSeatsCtrl=!Z.allowSeatsCtrl}catch{}},async ChatBan(){try{const t=he.user,e=(t==null?void 0:t.roomConfig)?JSON.parse(t==null?void 0:t.roomConfig):{};await vt.post("/api-web/imLiveBroadcastRoom/update",{requestType:"json",data:{id:t.id,liveRemark:t.liveRemark,liveStartTime:t.liveStartTime,preTemplate:t.preTemplate,roomConfig:{whether_chat:Z.allowChatCtrl?1:0,whether_like:e.whether_like,whether_video:e.whether_video,whether_mic:e.whether_mic},roomTitle:t.roomTitle,speakerId:t.speakerId,tenantId:t.tenantId}}),await bt(ot({chatBan:Z.allowChatCtrl},gi()),"ChatBan"),Z.allowChatCtrl=!Z.allowChatCtrl}catch{}}},render(){return I("div",{class:iu.message},[I("div",{class:iu.buttonGroup},[I(pt,{type:Z.allowChatCtrl?"info":"primary",onClick:this.ChatBan},{default:()=>[Z.allowChatCtrl?"\u5173\u95ED\u804A\u5929":"\u5F00\u542F\u804A\u5929"]}),I(pt,{type:Z.allowSeatsCtrl?"info":"primary",onClick:this.SeatsCtrl},{default:()=>[Z.allowSeatsCtrl?"\u5173\u95ED\u8FDE\u9EA6":"\u5F00\u542F\u8FDE\u9EA6"]})])])}});const c_="_sendMessage_p2cnx_1",u_="_form_p2cnx_10";var ou={sendMessage:c_,form:u_};const Xt=Ei({messageList:[],joinList:{},joinTips:!1,lookList:{}});var ye=Xt;const fn=t=>{Xt.messageList.push(t)},Gr=(t,e)=>{Xt.joinTips=!0,Xt.joinList[t]=e},Br=t=>{delete Xt.joinList[t]},Kn=(t,e)=>{Xt.lookList[t]=e},d_=t=>{delete Xt.lookList[t]};var l_=Ve({data(){return{message:""}},methods:{onKeyDown(t){t.keyCode===13&&this.message.trim()!==""&&this.sendMessage()},async sendMessage(){try{await bt(this.message);const t=gi();fn({id:String(t.id),name:t.name,content:this.message,isSelf:!0,sendTime:ft(new Date).format("HH:mm:ss")}),this.message="",this.scrollToBottom()}catch{}},scrollToBottom(){this.$nextTick(()=>{var t,e;(e=document.querySelector("#tabList"))==null||e.scrollTo(0,((t=document.querySelector("#messageList"))==null?void 0:t.scrollHeight)||0)})}},render(){return I("div",{class:ou.sendMessage},[I("div",{class:ou.form},[I(du,{modelValue:this.message,onKeydown:this.onKeyDown,onInput:t=>this.message=t,placeholder:"\u8BF7\u8F93\u5165\u6D88\u606F"},null),I(pt,{disabled:!this.message,onClick:this.sendMessage,round:!0,type:"primary"},{default:()=>[ne("\u53D1\u9001")]})])])}});const h_="_itemContent_169yn_1",f_="_itemInfo_169yn_11",p_="_itemName_169yn_14",g_="_userName_169yn_20",m_="_rightTime_169yn_30",__="_itemText_169yn_38",v_="_active_169yn_42",y_="_joinText_169yn_45",C_="_join_169yn_45",E_="_btn_169yn_54",R_="_downBtn_169yn_66",T_="_loadingStyle_169yn_71";var fe={itemContent:h_,itemInfo:f_,itemName:p_,userName:g_,"name-style":"_name-style_169yn_26",rightTime:m_,itemText:__,active:v_,joinText:y_,join:C_,btn:E_,downBtn:R_,loadingStyle:T_};const S_="_icon_1svqd_9";var So={"empty-container":"_empty-container_1svqd_1",icon:S_},Ia=Ve({props:{text:{type:String,default:"\u6682\u65E0\u6570\u636E"},icon:{type:String,default:"noData-no-message"}},render(){return I("div",{class:So["empty-container"]},[I(Pe("SvgIcon"),{name:this.icon,class:[So.icon]},null),I("p",{class:So["empty-text"]},[this.text])])}}),I_=Ve({data(){return{joinList:{},loadingJoin:!1}},computed:{count(){let t=0;for(const e in ye.joinList)if(Object.prototype.hasOwnProperty.call(ye.joinList,e)&&(ye.joinList[e].type===3&&(t+=1),t>3))break;return t}},mounted(){Ie.on(xe["RC:Chatroom:SeatApply"],this.onSeatApply),Ie.on(xe["RC:Chatroom:SeatResponse"],this.onSeatApply),Ie.on(xe["RM:RTC:UserLeave"],this.onSeatApply),Ie.on(xe["RM:RTC:SwitchRole"],this.onSwitchRole),Ie.on(xe["RC:Chatroom:Leave"],this.onLeave),Ie.on(xe["RC:LookerLoginOut"],this.onLeave)},methods:{async onLeave(t){Z.lookCount=Z.lookCount-1>=0?Z.lookCount-1:0;const e=t.userId||t.fromUserId;ye.joinList[e]&&Br(e),ye.lookList[e]&&d_(e),await bt({count:Z.lookCount},"MemberCount")},onSeatApply(t){if(Array.isArray(t)){for(const o of t)console.log("onSeatApply",o),Br(o);return}const e=t.$EventMessage.messageType==="RC:Chatroom:SeatResponse",n=e?4:3,r=ft(t.$EventMessage.sentTime||new Date).format("HH:mm:ss");let i={name:t.audienceName,id:String(t.audienceId),system:1,isSelf:!1,content:"",sendTime:r};if(t.type===3){console.log(t,"\u7533\u8BF7\u8FDE\u9EA6");const o={name:t.audienceName,id:t.audienceId,userRoomType:n,type:t.type};Gr(t.audienceId,o),Kn(t.audienceId,o),i.content=e?"\u540C\u610F\u4E86\u8FDE\u9EA6\u7533\u8BF7":"\u53D1\u8D77\u4E86\u8FDE\u9EA6\u7533\u8BF7",fn(i),Ie.emit("MESSAGE:Change")}if(t.type===4){if(console.log(t,"\u53D6\u6D88\u8FDE\u9EA6"),ye.joinList[t.audienceId]&&Br(t.audienceId),ye.lookList[t.audienceId]){let o=ye.lookList[t.audienceId];o.userRoomType=1,Kn(t.audienceId,o)}i.content=e?"\u62D2\u7EDD\u4E86\u8FDE\u9EA6\u7533\u8BF7":"\u53D6\u6D88\u4E86\u8FDE\u9EA6\u7533\u8BF7",fn(i),Ie.emit("MESSAGE:Change")}},agree(t){var n,r;if(this.count>3)return;const e=Mn(ot({},t),{audienceName:t.name,audienceId:String(t.id),teacherId:String((n=he.user)==null?void 0:n.id),teacherName:(r=he.user)==null?void 0:r.speakerName,userRoomType:4,type:1});Gr(t.id,e),Kn(t.id,e),bt(e,"SeatResponse")},refuse(t){var n,r;const e=Mn(ot({},t),{audienceName:t.name,audienceId:String(t.id),teacherId:String((n=he.user)==null?void 0:n.id),teacherName:(r=he.user)==null?void 0:r.speakerName,userRoomType:4,type:5});Gr(t.id,e),bt(e,"SeatApply")},onSwitchRole(t){if(console.log(t,"onSwitchRole"),ye.joinList[t.userId]&&t.role===2){const e=ye.joinList[t.userId],n=ft(new Date).format("HH:mm:ss");let r={name:e.audienceName,id:e.audienceId,system:1,isSelf:!1,content:"\u53D1\u8D77\u4E86\u8FDE\u9EA6\u7533\u8BF7",sendTime:n};fn(r),Ie.emit("MESSAGE:Change"),Br(t.userId)}if(ye.lookList[t.userId]&&t.role===2){let e=ye.lookList[t.userId];e.userRoomType=1,Kn(t.userId,e)}}},render(){const t=Object.values(ye.joinList);return I("div",{style:{minHeight:"100%",position:"relative"}},[t.length>0?t.map(e=>I("div",{class:fe.itemContent},[I("div",{class:fe.itemInfo},[I("div",{class:fe.itemName},[I("p",{class:fe.userName},[I("span",{class:fe["name-style"]},[e.name]),e.userRoomType!==4?I("span",{style:{paddingLeft:"10px"}},[ne("\u7533\u8BF7\u8FDE\u9EA6")]):I("span",{style:{paddingLeft:"10px",color:"var(--live-text-color)"}},[ne("\u6B63\u5728\u8FDE\u9EA6")])]),e.userRoomType!==4?I("div",{class:fe.joinText},[I("div",{class:fe.join},null),I(pt,{size:"small",type:"primary",disabled:this.count>3,class:fe.btn,onClick:()=>this.agree(e)},{default:()=>[ne("\u4E0A\u9EA6")]})]):I("div",{class:fe.joinText},[I("div",{class:fe.join},null),I(pt,{size:"small",plain:!0,class:[fe.btn,fe.downBtn],onClick:()=>this.refuse(e)},{default:()=>[ne("\u4E0B\u9EA6")]})])])])])):this.loadingJoin?I("div",{class:fe.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(Ia,{style:{paddingTop:"120px"},text:"\u6682\u65E0\u5B66\u5458\u53D1\u8D77\u8FDE\u9EA6\uFF01",icon:"noData-no-join"},null)])}}),b_=Ve({data(){return{loadingLook:!1}},computed:{count(){let t=0;for(const e in ye.joinList)if(Object.prototype.hasOwnProperty.call(ye.joinList,e)&&(ye.joinList[e].type===3&&(t+=1),t>3))break;return t}},async mounted(){await this._init(),this.loadingLook=!0,Ie.on(xe["RC:Chatroom:Welcome"],this.onWelcome),setTimeout(()=>{this.loadingLook=!1})},methods:{async _init(){try{const t=sessionStorage.getItem("roomUid");(await vt.get("/api-web/imLiveBroadcastRoom/queryRoomUserInfo",{params:{roomUid:t}})).data.forEach(r=>{ye.lookList[r.userId]||(ye.lookList[r.userId]={id:r.userId,name:r.userName,type:3,userRoomType:1,time:ft().format("YYYY-MM-DD HH:mm:ss")})})}catch{}},async onWelcome(t){if(t&&t.user){const e=ft(t.$EventMessage.sentTime||new Date).format("HH:mm:ss");let n={name:t.user.name,id:t.user.id,sendTime:e,userRoomType:1,type:3};!!ye.lookList[n.id]||(Kn(n.id,n),console.log("\u6DFB\u52A0\u89C2\u770B\u4EBA\u5458",n),Z.lookCount+=1,await bt({count:Z.lookCount},"MemberCount")),this.loadingLook=!1}},async onUpLook(t){var e,n;try{const r={audienceName:t.name,audienceId:String(t.id),teacherId:String((e=he.user)==null?void 0:e.id),teacherName:(n=he.user)==null?void 0:n.speakerName,userRoomType:2,type:1};t.userRoomType=2,await bt(r,"SeatApply")}catch{}},async onDownLook(t){var e,n;try{const r=Mn(ot({},t),{audienceName:t.name,audienceId:String(t.id),teacherId:String((e=he.user)==null?void 0:e.id),teacherName:(n=he.user)==null?void 0:n.speakerName,type:5});Gr(t.id,r),bt(r,"SeatApply")}catch{}}},render(){const t=Object.values(ye.lookList);return I("div",null,[t.length>0?t.map(e=>I("div",{class:fe.itemContent},[I("div",{class:fe.itemInfo},[I("div",{class:fe.itemName},[I("p",{class:fe.userName},[I("span",{class:fe["name-style"]},[e.name])]),e.userRoomType!==4?I(pt,{size:"small",type:"primary",disabled:this.count>3||e.userRoomType===2||Z.videoStatus!=="liveing",class:fe.btn,onClick:()=>this.onUpLook(e)},{default:()=>[ne("\u4E0A\u9EA6")]}):I(pt,{size:"small",plain:!0,class:[fe.btn,fe.downBtn],onClick:()=>this.onDownLook(e)},{default:()=>[ne("\u4E0B\u9EA6")]})])])])):this.loadingLook?I("div",{class:fe.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(Ia,{style:{paddingTop:"120px"},text:"\u6682\u65E0\u5B66\u5458\u89C2\u770B\uFF01",icon:"noData-no-user"},null)])}}),w_=Ve({data(){return{messageList:[],loadingMessage:!1}},mounted(){this.loadingMessage=!0,Ie.on(xe["RC:TxtMsg"],this.onMessage),Ie.on(xe["RC:ForcedOffline"],this.onForcedOffline),Ie.on("MESSAGE:Change",this.scrollToBottom),setTimeout(()=>{this.loadingMessage=!1},2e3),this.scrollToBottom()},beforeUnmount(){Ie.off(xe["RC:TxtMsg"],this.onMessage)},methods:{async onForcedOffline(){try{await Qd(),await vt.post("/api-auth/exit",{data:{}}),yn("camera"),yn("microphone"),he.user=null,au(),this.$router.push({path:"/login",query:ot({},this.$route.query)})}catch{}},onLike(t){var e;if(t&&t.user){const n=ft(t.$EventMessage.sentTime||new Date).format("HH:mm:ss");console.log(t,"like");let r={name:(e=t.user)==null?void 0:e.name,id:t.user.id,isSelf:!1,content:"\u7ED9\u60A8\u70B9\u4E86"+t.counts+"\u4E2A\u8D5E",sendTime:n};fn(r),this.loadingMessage=!1}this.scrollToBottom()},onMessage(t){var e;if(t&&t.user){const n=ft(t.$EventMessage.sentTime||new Date).format("HH:mm:ss");let r={name:(e=t.user)==null?void 0:e.name,id:t.user.id,isSelf:!1,content:t.content,sendTime:n};t.user.id===he.user.speakerId&&(r.isSelf=!0),fn(r),this.loadingMessage=!1}this.scrollToBottom()},scrollToBottom(){this.$nextTick(()=>{var t,e;(e=document.querySelector("#tabList"))==null||e.scrollTo(0,((t=document.querySelector("#messageList"))==null?void 0:t.scrollHeight)||0)})}},render(){return I("div",{style:{minHeight:"100%",position:"relative"},id:"messageList"},[ye.messageList.length>0?ye.messageList.map(t=>I("div",{class:fe.itemContent},[I("div",{class:fe.itemInfo},[I("div",{class:fe.itemName},[I("div",{class:fe.userName},[t.isSelf?I(Dl,{effect:"dark",color:"#01A79E"},{default:()=>[ne("\u4E3B\u8BB2\u4EBA")]}):null,I("span",{class:fe["name-style"]},[t.name,t.system?null:"\uFF1A"]),I("span",{class:[fe.itemText,t.isSelf?fe.active:null]},[t.content])]),I("p",{class:fe.rightTime},[t.sendTime])])])])):this.loadingMessage?I("div",{class:fe.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(Ia,{style:{paddingTop:"120px"},text:"\u6682\u65E0\u5B66\u5458\u4E92\u52A8\uFF01",icon:"noData-no-message"},null)])}}),O_=Ve({name:"LiveMessage",data(){return{modelIndex:"message"}},computed:{joinStatus(){console.log(this.modelIndex);let t=ye.joinTips;const e=Object.values(ye.joinList);return(ye.joinTips&&this.modelIndex==="join"||e.length<=0)&&(t=!1,ye.joinTips=!1),t}},methods:{tabChange(t){this.modelIndex=t.props.name,this.modelIndex==="message"&&this.$refs.messageModel.scrollToBottom()}},render(){return I("div",{class:$e.container},[I("div",{class:$e.dataCount},[I("div",null,[I("p",{class:$e.num},[Z.lookCount]),I("p",{class:$e.text},[I(Pe("SvgIcon"),{name:"message-look",color:"#fff",class:$e.dataIcon},null),ne("\u5F53\u524D\u89C2\u770B")])]),I("div",null,[I("p",{class:$e.num},[Z.likeCount]),I("p",{class:$e.text},[I(Pe("SvgIcon"),{name:"message-giveUp",color:"#fff",class:$e.dataIcon},null),ne("\u7D2F\u8BA1\u70B9\u8D5E")])])]),I(xl,{modelValue:this.modelIndex,"onTab-click":this.tabChange,class:$e.tabContainer},{default:()=>[I(Gi,{name:"message"},{label:()=>I("span",{style:{display:"flex",alignItems:"center"}},[I(Pe("SvgIcon"),{name:"message-message",color:this.modelIndex==="message"?"#00FFF0":"#fff",class:$e.tabIcon},null),ne("\u804A\u5929")])}),I(Gi,{name:"join"},{label:()=>I("span",{style:{display:"flex",alignItems:"center",position:"relative"}},[I(Pe("SvgIcon"),{name:"message-evenEtc",color:this.modelIndex==="join"?"#00FFF0":"#fff",class:$e.tabIcon},null),ne("\u8FDE\u9EA6 "),this.joinStatus?I("i",{class:$e.point},null):null])}),I(Gi,{name:"look"},{label:()=>I("span",{style:{display:"flex",alignItems:"center"}},[I(Pe("SvgIcon"),{name:"message-look",color:this.modelIndex==="look"?"#00FFF0":"#fff",class:$e.tabIcon},null),ne("\u89C2\u770B")])})]}),I("div",{class:$e.tabContent},[I(a_,null,null),I("div",{class:$e.tabList,id:"tabList"},[Yi(I(w_,{ref:"messageModel"},null),[[Ji,this.modelIndex==="message"]]),Yi(I(I_,null,null),[[Ji,this.modelIndex==="join"]]),Yi(I(b_,null,null),[[Ji,this.modelIndex==="look"]])]),I(l_,null,null)])])}});const N_="_container_13n1h_1",A_="_home_13n1h_4";var su={container:N_,home:A_},U_=Ve({render(){return I("div",{class:su.home},[I(_p,null,null),I("div",{class:su.container},[I(Jm,null,null),I(O_,null,null)])])}});export{U_ as default};
|