@nexconn/call 26.1.0 → 26.2.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.cjs +3 -0
- package/index.d.ts +1249 -9557
- package/index.esm.js +2 -2
- package/package.json +7 -7
- package/index.js +0 -3
package/index.esm.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__install__ as e}from"@nexconn/chat";import{ConversationType as t,RCConnectionStatus as i,VersionManage as r,SentStatus as n,MessageDirection as s,ReceivedStatus as o}from"@nexconn/engine";var a,l,_,c;!function(e){e[e.PRIVATE=1]="PRIVATE",e[e.GROUP=2]="GROUP",e[e.SYSTEM=3]="SYSTEM",e[e.CUSTOM=4]="CUSTOM",e[e.RTC_ROOM=7]="RTC_ROOM"}(a||(a={})),function(e){e[e.DISCONNECTED=0]="DISCONNECTED",e[e.CONNECTING=1]="CONNECTING",e[e.CONNECTED=2]="CONNECTED",e[e.SUSPENDED=3]="SUSPENDED"}(l||(l={})),function(e){e[e.Debug=0]="Debug",e[e.Info=1]="Info",e[e.Warn=2]="Warn",e[e.Error=3]="Error",e[e.STATISTICS=6]="STATISTICS"}(_||(_={})),function(e){e.RTC="RTC",e.CallPlus="CallPlus"}(c||(c={}));class d{constructor(e){Object.defineProperty(this,"_writer",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_traceId",{enumerable:!0,configurable:!0,writable:!0,value:0})}debug(e,t,i){this._writer.writeLog(_.Debug,e,null!=t?t:"",i)}info(e,t,i){this._writer.writeLog(_.Info,e,null!=t?t:"",i)}warn(e,t,i){this._writer.writeLog(_.Warn,e,null!=t?t:"",i)}error(e,t,i){this._writer.writeLog(_.Error,e,null!=t?t:"",i)}createTraceId(){return""+ ++this._traceId}setOutputLevel(e){this._writer.setOutputLevel(e)}__statistics(e,t,i){this._writer.writeLog(_.STATISTICS,e,null!=t?t:"",i)}}const u={toCommon:e=>e,toNative:e=>e},h={[t.PRIVATE]:a.PRIVATE,[t.GROUP]:a.GROUP,[t.SYSTEM]:a.SYSTEM,[t.CHATROOM]:a.CUSTOM,[t.APP_PUBLIC_SERVICE]:a.RTC_ROOM,[t.RTC_ROOM]:a.RTC_ROOM},g={[a.PRIVATE]:t.PRIVATE,[a.GROUP]:t.GROUP,[a.SYSTEM]:t.SYSTEM,[a.CUSTOM]:t.CHATROOM,[a.RTC_ROOM]:t.APP_PUBLIC_SERVICE},p={toCommon(e){var t;return null!==(t=h[e])&&void 0!==t?t:e},toNative(e){var t;return null!==(t=g[e])&&void 0!==t?t:e}},f={[i.CONNECTED]:l.CONNECTED,[i.CONNECTING]:l.CONNECTING,[i.DISCONNECTED]:l.DISCONNECTED,[i.SUSPENDED]:l.SUSPENDED},E={[l.DISCONNECTED]:i.DISCONNECTED,[l.CONNECTING]:i.CONNECTING,[l.CONNECTED]:i.CONNECTED,[l.SUSPENDED]:i.SUSPENDED},T={toNative:e=>Object.assign({},e)},m={errorCode:u,conversationType:p,connectionStatus:{toCommon(e){var t;return null!==(t=f[e])&&void 0!==t?t:e},toNative(e){var t;return null!==(t=E[e])&&void 0!==t?t:e}},sendMsgOptions:T,receivedMessage:{toCommon:e=>e},naviInfo:{toCommon(e){var t,i,r;return{voipCallInfo:null!==(t=e.voipCallInfo)&&void 0!==t?t:void 0,rtcAISwitch:e.rtcAISwitch,jwtToken:null!==(i=e.jwtToken)&&void 0!==i?i:e.jwt,logServer:e.logServer,dataCenter:null!==(r=e.dataCenter)&&void 0!==r?r:e.dc,openGzip:e.openGzip,ipType:e.ipType}}}};function I(e,t,i,r){return new(i||(i=Promise))(function(n,s){function o(e){try{l(r.next(e))}catch(e){s(e)}}function a(e){try{l(r.throw(e))}catch(e){s(e)}}function l(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(o,a)}l((r=r.apply(e,t||[])).next())})}function R(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)}function S(e){const t={logger:(c.RTC,i=e.createLogger("NCCall","RTC"),new d({writeLog(e,t,r,n){switch(e){case _.Debug:i.debug(t,r,n);break;case _.Info:i.info(t,r,n);break;case _.Warn:i.warn(t,r,n);break;case _.Error:i.error(t,r,n);break;case _.STATISTICS:i.__statistics(t,r,n);break;default:i.info(t,r,n)}},setOutputLevel(e){i.setOutputLevel(e)}})),rtcSignaling(t,i,r,n){return I(this,void 0,void 0,function*(){const s=yield e.rtcSignaling(t,i,r,n);return{code:m.errorCode.toCommon(null==s?void 0:s.code),buffer:null==s?void 0:s.buffer}})},registerRTCSignalListener(t){e.registerRTCSignalListener(t)},sendGroupCallSignalInfo(t,i,r){return I(this,void 0,void 0,function*(){const n=yield e.setCallInfo(t,i,r);return{code:m.errorCode.toCommon(n.code),data:n.data}})},registerGroupCallSignalInfoListener(t){e.onCallInfo=e=>{t(e)}},setOnnavidatachange(t){const i=t?e=>{const i=m.naviInfo.toCommon(e);t(i)}:void 0;e.onnavidatachange=i},refetchNaviInfo:e.refetchNaviInfo?()=>I(this,void 0,void 0,function*(){yield e.refetchNaviInfo()}):void 0,registerConnectionStateChangeListener(t){e.onconnectionstatechange=(e,i)=>{t(m.connectionStatus.toCommon(e),m.errorCode.toCommon(null!=i?i:0))}},registerDisconnectListener(t){e.ondisconnect=t},registerDestroyListener(t){e.ondestroy=t},registerMessageListener(t){const i=t?e=>t(m.receivedMessage.toCommon(e)):void 0;e.onmessage=i},sendMessage(t,i,r){return I(this,void 0,void 0,function*(){const n=m.conversationType.toNative(t),s=m.sendMsgOptions.toNative(r),o=yield e.sendMessage(n,i,s);return{code:m.errorCode.toCommon(o.code),data:void 0!==o.data?m.receivedMessage.toCommon(o.data):void 0}})},getCurrentId:()=>e.getCurrentId(),getNaviInfo(){const t=e.getNaviInfo();return null!=t?m.naviInfo.toCommon(t):null},getConnectionStatus:()=>m.connectionStatus.toCommon(e.getConnectionStatus()),getAppkey:()=>e.getAppkey(),getCoreVersion:()=>e.getCoreVersion(),registerMessageType(t,i,r,n){e.registerMessageType(t,i,r,n)}};var i;return e.rtcPingResVersion&&(t.rtcPingResVersion=(t,i,r)=>I(this,void 0,void 0,function*(){const n=yield e.rtcPingResVersion(t,i,r);return{code:m.errorCode.toCommon(n.code),data:n.data}})),t}"function"==typeof SuppressedError&&SuppressedError;const C=e=>"string"==typeof e,L=e=>"boolean"==typeof e,O=e=>"number"==typeof e&&!Number.isNaN(e),v=e=>-1!==Object.prototype.toString.call(e).indexOf("Array"),b=e=>C(e)&&e.length>0,A=e=>v(e)&&e.length>0,y=e=>"[object Object]"===Object.prototype.toString.call(e),N=e=>"function"==typeof e,P=e=>void 0===e||"[object Undefined]"===Object.prototype.toString.call(e),U=e=>C(e)&&/https?:\/\//.test(e);var D;!function(e){e[e.STRING=0]="STRING",e[e.ONLY_STRING=1]="ONLY_STRING",e[e.NUMBER=2]="NUMBER",e[e.BOOLEAN=3]="BOOLEAN",e[e.OBJECT=4]="OBJECT",e[e.ARRAY=5]="ARRAY",e[e.CALLBACK=6]="CALLBACK"}(D||(D={}));const M={[D.STRING]:b,[D.ONLY_STRING]:C,[D.NUMBER]:O,[D.BOOLEAN]:e=>"boolean"==typeof e,[D.OBJECT]:y,[D.ARRAY]:v,[D.CALLBACK]:e=>{let t=!0;return y(e)||(t=!1),(e=e||{}).onSuccess&&!N(e.onSuccess)&&(t=!1),e.onError&&!N(e.onError)&&(t=!1),t}};class w extends Error{constructor(e){super(e),this.name="RCAssertError"}}const k=(e,t,i,r=!1)=>{if(!x(e,t,i,r))throw new w(`'${e}' is invalid: ${JSON.stringify(t)}`)},x=(e,t,i,r=!1)=>{i=M[i]||i;const n=r?i(t):P(t)||null==t||i(t);return n||null===console||void 0===console||console.error(`'${e}' is invalid: ${JSON.stringify(t)}`),n};class B{constructor(){Object.defineProperty(this,"_map",{enumerable:!0,configurable:!0,writable:!0,value:{}})}on(e,t,i){const r=this._map[e]||(this._map[e]=[]);r.some(e=>e.listener===t&&e.target===i)||r.push({listener:t,target:i})}once(e,t,i){const r=this._map[e]||(this._map[e]=[]);r.some(e=>e.listener===t&&e.target===i)||r.push({listener:t,target:i,once:!0})}off(e,t,i){let r=this._map[e];r&&(r=r.filter(e=>e.listener!==t||e.target!==i),r.length?this._map[e]=r:delete this._map[e])}emit(e,...t){const i=this._map[e];if(i)for(let e=0;e<i.length;e+=1){const{target:r,once:n,listener:s}=i[e];n&&(i.splice(e,1),e-=1);try{s.call(r,...t)}catch(e){null===console||void 0===console||console.error(e)}}}removeAll(e){delete this._map[e]}clear(){Object.keys(this._map).forEach(this.removeAll,this)}}var V,G,F;!function(e){e.GET="GET",e.POST="POST",e.PUT="PUT"}(V||(V={})),function(e){e.WIFI="wifi",e.FOUR_G="4g",e.THREE_G="3g",e.TWO_G="2g",e.FIVE_G="2g",e.THREE_GENT="3gnet",e.UNKONWN="unknown"}(G||(G={})),function(e){e[e.RMTP=1]="RMTP",e[e.TLS=2]="TLS",e[e.RPP=3]="RPP",e[e.QUIC=4]="QUIC",e[e.WS=5]="WS",e[e.WSS=6]="WSS",e[e.HTTP=11]="HTTP",e[e.HTTPS=12]="HTTPS"}(F||(F={}));const j=(e,t,i)=>{const r=null==i?void 0:i.isReverse;y(e)&&(()=>{for(const i in e)t(e[i],i,e)})(),(v(e)||C(e))&&(()=>{if(r)for(let i=e.length-1;i>=0;i--)t(e[i],i);else for(let i=0,r=e.length;i<r;i++)t(e[i],i)})()};var H;!function(e){e[e.RTC=0]="RTC",e[e.LIVE=2]="LIVE",e[e.SIP=4]="SIP",e[e.CALL=5]="CALL",e[e.MEETING=6]="MEETING",e[e.CROSS_MUTI=7]="CROSS_MUTI",e[e.CROSS_LIVE=8]="CROSS_LIVE"}(H||(H={}));const J={gen:()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=Math.floor(36*Math.random());return("x"===e?t:3&t|8).toString(36)}),genWithLen(e=22){const t=Date.now(),i=t.toString(36),r=Math.floor(Math.random()*t).toString(36),n=e-i.length-r.length;var s;return[r,i,n>0?(s=n,Array.from({length:s}).map(()=>Math.floor(36*Math.random()).toString(36)).join("")):""].join("").slice(0,e)}};class ${constructor(e,t){Object.defineProperty(this,"_promise",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_resolve",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_onCancel",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._promise=new Promise(t=>{this._resolve=t,e(this._onResolve.bind(this))}),this._onCancel=t}_onResolve(e){this._resolve(e)}result(){return this._promise}abort(){this._onCancel(this._onResolve.bind(this))}}function K(e){const t=e.method||V.GET,i=e.timeout||6e4,{headers:r,query:n,body:s,onProgress:o}=e,a=((e,t)=>{if(e=e.replace(/\?$/,""),!t)return e;const i=Object.keys(t).map(e=>`${e}=${t[e]}`).filter(e=>!!e);return i.length?[e,i.join("&")].join("?"):e})(e.url,n),l=new XMLHttpRequest;if(l.open(t,a),r&&l.setRequestHeader)for(const e in r)l.setRequestHeader(e,r[e]);return function(e,t,i,r){return new $(n=>{e.onreadystatechange=()=>{4===e.readyState&&n({data:e.responseText,status:e.status,xhr:e})},e.onerror=()=>{n({status:e.status})},r&&(e.upload.onprogress=e=>r(e)),0!==t&&setTimeout(()=>{e.abort(),n({status:e.status})},t),e.send(i)},t=>{e.abort(),t({status:-1})})}(l,i,s,o)}class Y{constructor(e,t,i){Object.defineProperty(this,"isOk",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"msg",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.isOk=0===e,this.code=e,this.msg=t,this.data=i}next(e){return I(this,void 0,void 0,function*(){return this.isOk?e(this.data):this.wipe()})}or(e){return I(this,void 0,void 0,function*(){return this.isOk?this:e(this.code)})}orSync(e){return this.isOk?this:e(this.code)}trans(e){return this.isOk?q(e(this.data)):this.wipe()}tryTrans(e){return this.isOk?e(this.data):this.wipe()}errmsg(){return JSON.stringify({code:this.code,msg:this.msg})}wipe(){return this.isOk?q(void 0,this.msg):W(this.code,this.msg)}}const q=(e,t)=>new Y(0,t||"success",e),W=(e,t,i)=>new Y(e,t||`fail: ${e}`,i);var z,Q,Z;class X{constructor(e){z.add(this),Q.set(this,void 0),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),function(e,t,i,r,n){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");"a"===r?n.call(e,i):n?n.value=i:t.set(e,i)}(this,Q,e,"f"),this._logger=e.logger}open(e){return I(this,void 0,void 0,function*(){return e=e.sort((e,t)=>t.weight-e.weight),R(this,z,"m",Z).call(this,e,R(this,Q,"f"))})}}Q=new WeakMap,z=new WeakSet,Z=function e(t,i){return I(this,void 0,void 0,function*(){if(0===t.length)return W(39005,"All addrs failed");const r=t.shift();let n=function(e,t){var i;if(!e)return"";const r="undefined"!=typeof window&&"https:"===(null===(i=null===window||void 0===window?void 0:window.location)||void 0===i?void 0:i.protocol);return/^https?:\/\//.test(e)?r?e.replace(/^https?:\/\//i,"https://"):e:t!==F.HTTP||r?`https://${e}`:`http://${e}`}(r.addr,r.protocol);n=`${n}/v3/message/get_stream.json?sdkVersion=26.1.0&platform=Websocket&messageUID=${i.msgUId}`,this._logger.info("L-req_stream_msg_content-O",`try open -> ${n}`);const s=yield this._openHandler(n,i);return s.or(r=>I(this,void 0,void 0,function*(){return-1===r?R(this,z,"m",e).call(this,t,i):s}))})};class ee extends X{_openHandler(e,t){return I(this,void 0,void 0,function*(){const{resolve:i,promise:r}=(()=>{let e,t=new Promise(t=>{e=t});return{resolve:e,promise:t}})(),n=new XMLHttpRequest;return n.open("GET",e,!0),n.timeout=t.timeout,n.ontimeout=()=>{this._logger.warn("L-req_stream_msg_content-E",`timeout -> ${e}`),i(W(-1,"timeout"))},n.onreadystatechange=r=>{if(n.readyState!==XMLHttpRequest.HEADERS_RECEIVED)return;const s=n.getResponseHeader("Content-Type"),o=null==s?void 0:s.startsWith("text/event-stream");if(200!==n.status||!o)return void(n.onloadend=()=>{const e=JSON.parse(n.response);i(W(e.code,e.message))});i(q());let a=0;n.onprogress=e=>{const i=n.response.slice(a);a=n.response.length,t.onRawContent(i)},n.onerror=i=>{this._logger.warn("L-req_stream_msg_content-E",`network error in transit -> ${e}`),n.onprogress=null,n.abort(),t.onNetworkError(39005)}},n.onerror=t=>{this._logger.warn("L-req_stream_msg_content-E",`req fail -> ${e}`),i(W(-1))},n.setRequestHeader("Content-Type","application/json;charset=UTF-8"),n.setRequestHeader("App-Key",t.appkey),n.setRequestHeader("Authorization",`Bearer ${t.token}`),n.send(),r})}}const te=!("undefined"==typeof uni||!(e=>{const t=["request","getSystemInfo"];for(let i=0,r=t.length;i<r;i++)if(!e[t[i]])return!1;return!0})(uni));let ie=null;const re=e=>I(void 0,void 0,void 0,function*(){const t=yield ne.getNetworkType();ie({status:"online"===e.type,type:t})});const ne={tag:"browser",httpReq:e=>K(e).result(),localStorage:null===window||void 0===window?void 0:window.localStorage,sessionStorage:null===window||void 0===window?void 0:window.sessionStorage,useNavi:!0,connectPlatform:"",isFromUniapp:te,createWebSocket:function(e,t){const i=new WebSocket(e,t);return i.binaryType="arraybuffer",Promise.resolve(q({id:Date.now(),onClose(e){i.onclose=t=>{const{code:i,reason:r}=t;e(i,r)}},onError(e){i.onerror=e},onMessage(e){i.onmessage=t=>{e(t.data)}},onOpen(e){i.onopen=e},send(e){i.send(e)},close(e,t){i.close()}}))},getNetworkType(){const{type:e,effectiveType:t}=navigator.connection||navigator.mozConnection||navigator.webkitConnection||{effectiveType:G.UNKONWN},i=e||t||G.UNKONWN;return Promise.resolve(i)},setNetworkStatusListener:function(e){ie=e,"undefined"!=typeof window&&window&&(window.addEventListener("offline",re),window.addEventListener("online",re))},removeNetworkStatusListener:function(){"undefined"!=typeof window&&window&&(window.removeEventListener("offline",re),window.removeEventListener("online",re)),ie=null},createSSEClient:e=>q(new ee(e)),getApiVer:()=>{const{type:e,version:t}=ne.runtimeInfo;return`|${e}|${t}`},get runtimeInfo(){const{userAgent:e}=navigator;let t,i;const r={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(const n in r){if(!r.hasOwnProperty(n))continue;let s=e.match(r[n]);if(s){i=n,t=s[1]||s[2];break}}return{type:i||"Unknown",version:t||"Unknown"}}},se=ne,oe=0,ae=2,le=-1,_e=30001,ce=30002,de=30003;var ue,he,ge;!function(e){e[e.SUCCESS=1e4]="SUCCESS",e[e.PB_ERROR=40001]="PB_ERROR",e[e.SIGNAL_DISCONNECTED=5e4]="SIGNAL_DISCONNECTED",e[e.PARAMS_ERROR=50001]="PARAMS_ERROR",e[e.REPERT_JOIN_ROOM=50002]="REPERT_JOIN_ROOM",e[e.NOT_IN_ROOM=50003]="NOT_IN_ROOM",e[e.SERVICE_INVALID=50004]="SERVICE_INVALID",e[e.RTC_TOKEN_INVALID=50006]="RTC_TOKEN_INVALID",e[e.ASR_NOT_AVAILABLE=50034]="ASR_NOT_AVAILABLE",e[e.ASR_NOT_START=50035]="ASR_NOT_START",e[e.SIGNAL_ERROR=53001]="SIGNAL_ERROR",e[e.CREATE_OFFER_FAILED=53003]="CREATE_OFFER_FAILED",e[e.REQUEST_FAILED=53004]="REQUEST_FAILED",e[e.MCU_SERVER_NOT_FOUND=53005]="MCU_SERVER_NOT_FOUND",e[e.BROADCAST_SUB_LIST_NOT_EMPTY=53007]="BROADCAST_SUB_LIST_NOT_EMPTY",e[e.ROOM_HAS_BEEN_DESTROYED=53008]="ROOM_HAS_BEEN_DESTROYED",e[e.NOT_OPEN_VIDEO_AUDIO_SERVER=53009]="NOT_OPEN_VIDEO_AUDIO_SERVER",e[e.GET_USER_MEDIA_FAILED=53010]="GET_USER_MEDIA_FAILED",e[e.GET_DISPLAY_MEDIA_FAILED=53011]="GET_DISPLAY_MEDIA_FAILED",e[e.BROWSER_PERMISSION_DENIED=53012]="BROWSER_PERMISSION_DENIED",e[e.CREATE_CUSTOM_TRACK_FAILED=53013]="CREATE_CUSTOM_TRACK_FAILED",e[e.INVALID_TAGS=53014]="INVALID_TAGS",e[e.INVALID_USER_ID=53015]="INVALID_USER_ID",e[e.CREATE_FILE_TRACK_FAILED=53016]="CREATE_FILE_TRACK_FAILED",e[e.INVALID_FILE_INSTANCE=53017]="INVALID_FILE_INSTANCE",e[e.SET_REMOTE_DESCRIPTION_FAILED=53018]="SET_REMOTE_DESCRIPTION_FAILED",e[e.BROWSER_NOT_SUPPORT=53019]="BROWSER_NOT_SUPPORT",e[e.TRACK_NOT_READY=53020]="TRACK_NOT_READY",e[e.VIDEO_TRACK_MISS_MEDIA_ELEMENT=53021]="VIDEO_TRACK_MISS_MEDIA_ELEMENT",e[e.TRACK_PLAY_ERROR=53022]="TRACK_PLAY_ERROR",e[e.SIGNAL_AUDIENCE_JOIN_ROOM_FAILED=53023]="SIGNAL_AUDIENCE_JOIN_ROOM_FAILED",e[e.SIGNAL_ROOM_CHANGE_IDENTITY_FAILED=53024]="SIGNAL_ROOM_CHANGE_IDENTITY_FAILED",e[e.PACKAGE_ENVIRONMENT_ERROR=53025]="PACKAGE_ENVIRONMENT_ERROR",e[e.PUBLISH_TRACK_LIMIT_EXCEEDED=53026]="PUBLISH_TRACK_LIMIT_EXCEEDED",e[e.CDN_RESOURCE_IS_EMPTY=53027]="CDN_RESOURCE_IS_EMPTY",e[e.SIGNAL_JOIN_RTC_ROOM_REFUSED=53028]="SIGNAL_JOIN_RTC_ROOM_REFUSED",e[e.NO_PERMISSION_TO_USE_REQUESTED_DEVICE=53029]="NO_PERMISSION_TO_USE_REQUESTED_DEVICE",e[e.THE_FUNCTION_IS_DISABLED_IN_PKROOM=53030]="THE_FUNCTION_IS_DISABLED_IN_PKROOM",e[e.SOME_TRACKS_PUBLISH_FAILED=53031]="SOME_TRACKS_PUBLISH_FAILED",e[e.MAC_IN_ELECTRON_NOT_SUPPORT_SCREEN_SHARE_WITH_AUDIO=53032]="MAC_IN_ELECTRON_NOT_SUPPORT_SCREEN_SHARE_WITH_AUDIO",e[e.JWT_TIME_OUT=1004]="JWT_TIME_OUT",e[e.SYSTEM_PERMISSION_DENIED=53033]="SYSTEM_PERMISSION_DENIED",e[e.PUBLISH_TRACKS_IS_INVALID=53034]="PUBLISH_TRACKS_IS_INVALID",e[e.TRACK_READYSTATE_IS_ENDED=53035]="TRACK_READYSTATE_IS_ENDED",e[e.APPLY_3A_NOISE_WORKLET_BEFORE_PUBLISH=53036]="APPLY_3A_NOISE_WORKLET_BEFORE_PUBLISH",e[e.LOAD_3A_MODULE_FAILED=53037]="LOAD_3A_MODULE_FAILED"}(ue||(ue={})),function(e){e.L_INDEX_INSTALL_RTC_PLUGIN_O="L-index_install_rtc_plugin-O",e.L_RTC_CLIENT_IM_CONNECTION_STATE_S="L-rtc_client_im_connection_state-S",e.L_RTC_CLIENT_MESSAGE_O="L-rtc_client_message-O",e.L_RTC_CLIENT_DESTROY_S="L-rtc_client_destroy-S",e.L_RTC_CLIENT_JOIN_RTC_ROOM_T="L-rtc_client_join_rtc_room-T",e.L_RTC_CLIENT_JOIN_RTC_ROOM_O="L-rtc_client_join_rtc_room-O",e.L_RTC_CLIENT_JOIN_RTC_ROOM_R="L-rtc_client_join_rtc_room-R",e.L_RTC_CLIENT_JOIN_LIVING_ROOM_T="L-rtc_client_join_living_room-T",e.L_RTC_CLIENT_JOIN_LIVING_ROOM_R="L-rtc_client_join_living_room-R",e.L_RTC_CLIENT_GET_AUDIENCE_CLIENT_O="L-rtc_client_get_audience_client-O",e.L_RTC_CLIENT_LEAVE_ROOM_T="L-rtc_client_leave_room-T",e.L_RTC_CLIENT_LEAVE_ROOM_R="L-rtc_client_leave_room-R",e.L_RTC_CLIENT_CREATE_MICROPHONE_AUDIO_TRACK_O="L-rtc_client_create_microphone_audio_track-O",e.L_RTC_CLIENT_CREATE_CAMERA_VIDEO_TRACK_O="L-rtc_client_create_camera_video_track-O",e.L_RTC_CLIENT_CREATE_MICROPHONE_AND_CAMERA_TRACKS_O="L-rtc_client_create_microphone_and_camera_tracks-O",e.L_RTC_CLIENT_CREATE_SCREEN_VIDEO_TRACK_O="L-rtc_client_create_screen_video_track-O",e.L_RTC_CLIENT_CREATE_SCREEN_VIDEO_AND_AUDIO_TRACKS_O="L-rtc_client_create_screen_video_and_audio_tracks-O",e.L_RTC_CLIENT_CREATE_LOCAL_AUDIO_TRACK_O="L-rtc_client_create_local_audio_track-O",e.L_RTC_CLIENT_CREATE_LOCAL_VIDEO_TRACK_O="L-rtc_client_create_local_video_track-O",e.L_RTC_CLIENT_CREATE_LOCAL_FILE_TRACKS_O="L-rtc_client_create_local_file_tracks-O",e.L_RTC_CLIENT_CREATE_LOCAL_TRACKS_O="L-rtc_client_create_local_tracks-O",e.L_RTC_CLIENT_APPLY_VIDEO_ASPECT_RATIO_O="L-rtc_client_apply_video_aspect_ratio-O",e.L_RTC_CLIENT_JOIN_LIVING_ROOM_AS_AUDIENCE_T="L-rtc_client_join_living_room_as_audience-T",e.L_RTC_CLIENT_JOIN_LIVING_ROOM_AS_AUDIENCE_R="L-rtc_client_join_living_room_as_audience_R",e.L_RTC_CLIENT_LEAVE_LIVING_ROOM_AS_AUDIENCE_T="L-rtc_client_leave_living_room_as_audience-T",e.L_RTC_CLIENT_LEAVE_LIVING_ROOM_AS_AUDIENCE_R="L-rtc_client_leave_living_room_as_audience-R",e.L_RTC_CLIENT_UPGRADE_TO_ANCHOR_ROOM_T="L-rtc_client_upgrade_to_anchor_room-T",e.L_RTC_CLIENT_UPGRADE_TO_ANCHOR_ROOM_R="L-rtc_client_upgrade_to_anchor_room-R",e.L_RTC_CLIENT_DOWNGRADE_TO_AUDIENCE_ROOM_T="L-rtc_client_downgrade_to_audience_room-T",e.L_RTC_CLIENT_DOWNGRADE_TO_AUDIENCE_ROOM_R="L-rtc_client_downgrade_to_audience_room-R",e.L_RTC_CLIENT_GET_JOINED_ROOM_INFO_T="L-rtc_client_get_joined_room_info-T",e.L_RTC_CLIENT_GET_JOINED_ROOM_INFO_R="L-rtc_client_get_joined_room_info-R",e.L_RTC_CLIENT_GENERATE_SUMMARIZATION_T="L-rtc_client_generate_summarization-T",e.L_RTC_CLIENT_GENERATE_SUMMARIZATION_R="L-rtc_client_generate_summarization-R",e.L_RTC_CLIENT_GET_ASR_CONTENT_T="L-rtc_client_get_asr_content-T",e.L_RTC_CLIENT_GET_ASR_CONTENT_R="L-rtc_client_get_asr_content-R",e.L_AUDIENCE_CLIENT_CALL_ONTRACKREADY_O="L-audinence_client_call_onTrackReady-O",e.L_AUDIENCE_CLIENT_SUBSCRIBE_T="L-audinence_client_subscribe-T",e.L_AUDIENCE_CLIENT_SUBSCRIBE_R="L-audinence_client_subscribe-R",e.L_AUDIENCE_CLIENT_UNSUBSCRIBE_T="L-audinence_client_unsubscribe-T",e.L_AUDIENCE_CLIENT_UNSUBSCRIBE_R="L-audinence_client_unsubscribe-R",e.L_PINGER_START_O="L-pinger_start-O",e.L_PINGER_STOP_O="L-pinger_stop-O",e.L_PINGER_SEND_RTCPING_E="L-pinger_send_rtcping-E",e.L_ABSTRACT_ROOM_SEND_MESSAGE_T="L-abstract_room_send_message-T",e.L_ABSTRACT_ROOM_SEND_MESSAGE_R="L-abstract_room_send_message-R",e.L_ABSTRACT_ROOM_SET_ROOM_ATTRIBUTE_T="L-abstract_room_set_room_attribute-T",e.L_ABSTRACT_ROOM_SET_ROOM_ATTRIBUTE_R="L-abstract_room_set_room_attribute_R",e.L_ABSTRACT_ROOM_DELETE_ROOM_ATTRIBUTE_T="L-abstract_room_delete_room_attribute_T",e.L_ABSTRACT_ROOM_DELETE_ROOM_ATTRIBUTE_R="L-abstract_room_delete_room_attribute_R",e.L_ABSTRACT_ROOM_GET_ROOM_ATTRIBUTE_T="L-abstract_room_get_room_attribute_T",e.L_ABSTRACT_ROOM_GET_ROOM_ATTRIBUTE_R="L-abstract_room_get_room_attribute_R",e.L_ABSTRACT_ROOM_PUBLISH_T="L-abstract_room_publish-T",e.L_ABSTRACT_ROOM_PUBLISH_R="L-abstract_room_publish-R",e.L_ABSTRACT_ROOM_PUBLISH_E="L-abstract_room_publish-E",e.L_ABSTRACT_ROOM_UNPUBLISH_T="L-abstract_room_unpublish-T",e.L_ABSTRACT_ROOM_UNPUBLISH_R="L-abstract_room_unpublish-R",e.L_ABSTRACT_ROOM_UNPUBLISH_E="L-abstract_room_unpublish-E",e.L_ABSTRACT_ROOM_UNPUBLISH_P="L-abstract_room_unpublish-P",e.L_ABSTRACT_ROOM_SUBSCRIBE_T="L-abstract_room_subscribe-T",e.L_ABSTRACT_ROOM_SUBSCRIBE_R="L-abstract_room_subscribe-R",e.L_ABSTRACT_ROOM_SUBSCRIBE_E="L-abstract_room_subscribe-E",e.L_ABSTRACT_ROOM_UNSUBSCRIBE_T="L-abstract_room_unsubscribe-T",e.L_ABSTRACT_ROOM_UNSUBSCRIBE_R="L-abstract_room_unsubscribe-R",e.L_ABSTRACT_ROOM_UNSUBSCRIBE_E="L-abstract_room_unsubscribe-E",e.L_ABSTRACT_ROOM_SET_SRC_LANGUAGE_T="L-abstract_room_set_src_language-T",e.L_ABSTRACT_ROOM_SET_SRC_LANGUAGE_R="L-abstract_room_set_src_language-R",e.L_ABSTRACT_ROOM_OPERATE_ASR_STATUS_T="L-abstract_room_operate_asr_status-T",e.L_ABSTRACT_ROOM_OPERATE_ASR_STATUS_R="L-abstract_room_operate_asr_status-R",e.L_ABSTRACT_ROOM_SET_ENABLE_ASR_T="L-abstract_room_set_enable_asr-T",e.L_ABSTRACT_ROOM_SET_ENABLE_ASR_R="L-abstract_room_set_enable_asr-R",e.L_ABSTRACT_ROOM_OPERATE_REALTIME_TRANSLATION_T="L-abstract_room_operate_realtime_translation-T",e.L_ABSTRACT_ROOM_OPERATE_REALTIME_TRANSLATION_R="L-abstract_room_operate_realtime_translation-R",e.L_ABSTRACT_ROOM_OPERATE_SUMMARIZATION_T="L-abstract_room_operate_summarization-T",e.L_ABSTRACT_ROOM_OPERATE_SUMMARIZATION_R="L-abstract_room_operate_summarization-R",e.L_APP_CALL_UNSUBSCRIBE_O="L-app_call_unsubscribe-O",e.L_USER_LEFT_UNSUBSCRIBE_O="L-user_left_unsubscribe-O",e.L_RES_UNPUB_UNSUBSCRIBE_O="L-res_unpub_unsubscribe-O",e.L_ABSTRACT_ROOM_REGISTER_ROOM_EVENT_LISTENER_O="L-abstract_room_register_room_event_listener-O",e.L_ABSTRACT_ROOM_REGISTER_REPORT_LISTENER_O="L-abstract_room_register_report_listener-O",e.L_ABSTRACT_ROOM_AUDIO_LEVEL_O="L-abstract_room_audio_level-O",e.L_ABSTRACT_ROOM_IM_RECONNECTED_T="L-abstract_room_im_reconnected-T",e.L_ABSTRACT_ROOM_IM_RECONNECTED_R="L-abstract_room_im_reconnected-R",e.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O="L-abstract_room_call_app_listener-O",e.L_ABSTRACT_ROOM_SETBITRATE_O="L-abstract_room_setBitrate-O",e.L_ABSTRACT_ROOM_ONTRACKREADY_O="L-abstract_room_onTrackReady-O",e.L_ABSTRACT_ROOM_RECEIVE_MESSAGE_O="L-abstract_room_receive_message-O",e.L_ABSTRACT_ROOM_ONKICKOFF_O="L-abstract_room_onKickoff-O",e.L_LIVING_ROOM_RECONNECTED_T="L-living_room_reconnected-T",e.L_LIVING_ROOM_RECONNECTED_R="L-living_room_reconnected-R",e.L_LIVING_ROOM_ENABLE_INNER_CDN_T="L-living_room_enable_inner_cdn-T",e.L_LIVING_ROOM_ENABLE_INNER_CDN_R="L-living_room_enable_inner_cdn-R",e.L_LIVING_ROOM_SPREAD_CDN_INFO_T="L-living_room_spread_cdn_info-T",e.L_LIVING_ROOM_SPREAD_CDN_INFO_R="L-living_room_spread_cdn_info-R",e.L_LIVING_ROOM_SET_ROOM_CDN_INFO_T="L-living_room_set_room_cdn_info-T",e.L_LIVING_ROOM_SET_ROOM_CDN_INFO_R="L-living_room_set_room_cdn_info-R",e.L_LIVING_ROOM_JOINED_PK_ROOM_T="L-living_room_joined_pk_room-T",e.L_LIVING_ROOM_JOINED_PK_ROOM_R="L-living_room_joined_pk_room-R",e.L_LIVING_ROOM_LEAVE_PK_ROOM_T="L-living_room_leave_pk_room-T",e.L_LIVING_ROOM_LEAVE_PK_ROOM_R="L-living_room_leave_pk_room-R",e.L_APP_CALL_LEAVE_PK_ROOM_O="L-app_call_leave_pk_room-O",e.L_QUIT_PK_LEAVE_PK_ROOM_O="L-quit_pk_leave_pk_room-O",e.L_LIVING_ROOM_GET_ROOM_PK_HANDLER_O="L-living_room_get_room_pk_handler-O",e.L_LIVING_ROOM_GET_MCU_CONFIG_BUILDER_O="L-living_room_get_mcu_config_builder-O",e.L_LIVING_ROOM_QUIT_ALL_PK_ROOM_O="L-living_room_quit_all_pk_room-O",e.L_LIVING_PK_HANDLER_REGISTER_ROOM_PK_EVENT_LISTENER_O="L-living_pk_handler_register_room_pk_event_listener-O",e.L_LIVING_PK_HANDLER_CALL_APP_LISTENER_O="L-living_pk_handler_call_app_listener-O",e.L_LIVING_PK_HANDLER_REQUEST_JOIN_OTHER_ROOM_T="L-living_pk_handler_request_join_other_room-T",e.L_LIVING_PK_HANDLER_REQUEST_JOIN_OTHER_ROOM_R="L-living_pk_handler_request_join_other_room-R",e.L_LIVING_PK_HANDLER_CANCEL_REQUEST_JOIN_OTHER_ROOM_T="L-living_pk_handler_cancel_request_join_other_room-T",e.L_LIVING_PK_HANDLER_CANCEL_REQUEST_JOIN_OTHER_ROOM_R="L-living_pk_handler_cancel_request_join_other_room-R",e.L_LIVING_PK_HANDLER_RESPONSE_JOIN_OTHER_ROOM_T="L-living_pk_handler_response_join_other_room-T",e.L_LIVING_PK_HANDLER_RESPONSE_JOIN_OTHER_ROOM_R="L-living_pk_handler_response_join_other_room-R",e.L_LIVING_PK_HANDLER_JOIN_OTHER_ROOM_T="L-living_pk_handler_join_other_room-T",e.L_LIVING_PK_HANDLER_JOIN_OTHER_ROOM_R="L-living_pk_handler_join_other_room-R",e.L_LIVING_PK_HANDLER_LEAVE_OTHER_ROOM_T="L-living_pk_handler_leave_other_room-T",e.L_LIVING_PK_HANDLER_LEAVE_OTHER_ROOM_R="L-living_pk_handler_leave_other_room-R",e.L_QUIT_PK_T="L-quit_pk-T",e.L_QUIT_PK_R="L-quit_pk-R",e.L_EXCHANGE_WITH_PUSHOTHERROOM_T="L-exchange_with_pushotherroom-T",e.L_EXCHANGE_WITH_PUSHOTHERROOM_R="L-exchange_with_pushotherroom-R",e.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O="L-audience_living_room_call_app_listener-O",e.L_AUDIENCE_LIVING_ROOM_PULL_KVENTRIES_O="L-audience_living_room_pull_kvEntries-O",e.L_AUDIENCE_LIVING_ROOM_PULL_KVENTRIES_T="L_AUDIENCE_LIVING_ROOM_PULL_KVENTRIES_T",e.L_AUDIENCE_LIVING_ROOM_PULL_KVENTRIES_R="L_AUDIENCE_LIVING_ROOM_PULL_KVENTRIES_R",e.L_AUDIENCE_LIVING_ROOM_SINGAL_DATA_CHANGE_P="L-audience_living_room_singal_data_change-P",e.L_AUDIENCE_LIVING_ROOM_GET_CDN_PLAY_URL_T="L-audience_living_room_get_cdn_play_url-T",e.L_AUDIENCE_LIVING_ROOM_GET_CDN_PLAY_URL_R="L-audience_living_room_get_cdn_play_url-R",e.L_AUDIENCE_LIVING_ROOM_SUBSCRIBE_T="L-audience_living_room_subscribe-T",e.L_AUDIENCE_LIVING_ROOM_SUBSCRIBE_R="L-audience_living_room_subscribe-R",e.L_AUDIENCE_LIVING_ROOM_UNSUBSCRIBE_T="L-audience_living_room_unsubscribe-T",e.L_AUDIENCE_LIVING_ROOM_UNSUBSCRIBE_R="L-audience_living_room_unsubscribe-R",e.L_AUDIENCE_LIVING_ROOM_UPDATE_SUBSCRIBELIST_T="L-audience_living_room_update_subscribeList-T",e.L_AUDIENCE_LIVING_ROOM_UPDATE_SUBSCRIBELIST_R="L-audience_living_room_update_subscribeList-R",e.L_AUDIENCE_LIVING_ROOM_ONTRACKREADY_O="L-audience_living_room_onTrackReady-O",e.L_AUDIENCE_LIVING_ROOM_IM_RECONNECTED_R="L-audience_living_room_im_reconnected-R",e.L_AUDIENCE_LIVING_ROOM_IM_RECONNECTED_T="L-audience_living_room_im_reconnected-T",e.L_MCU_CONFIG_BUILDER_SET_HOST_VIDEO_TRACK_O="L-mcu_config_builder_set_host_video_track-O",e.L_MCU_CONFIG_BUILDER_SET_MIX_LAYOUT_MODE_O="L-mcu_config_builder_set_mix_layout_mode-O",e.L_MCU_CONFIG_BUILDER_SET_OUTPUT_VIDEO_RESOLUTION_O="L-mcu_config_builder_set_output_video_resolution-O",e.L_MCU_CONFIG_BUILDER_SET_OUTPUT_VIDEO_FPS_O="L-mcu_config_builder_set_output_video_fps-O",e.L_MCU_CONFIG_BUILDER_SET_OUTPUT_VIDEO_BITRATE_O="L-mcu_config_builder_set_output_video_bitrate-O",e.L_MCU_CONFIG_BUILDER_SET_OUTPUT_TINY_VIDEO_RESOLUTION_O="L-mcu_config_builder_set_output_tiny_video_resolution-O",e.L_MCU_CONFIG_BUILDER_SET_OUTPUT_TINY_VIDEO_FPS_O="L-mcu_config_builder_set_output_tiny_video_fps-O",e.L_MCU_CONFIG_BUILDER_SET_OUTPUT_TINY_VIDEO_BITRATE_O="L-mcu_config_builder_set_output_tiny_video_bitrate-O",e.L_MCU_CONFIG_BUILDER_SET_OUTPUT_VIDEO_RENDER_MODE_O="L-mcu_config_builder_set_output_video_render_mode-O",e.L_MCU_CONFIG_BUILDER_SET_OUTPUT_AUDIO_BITRATE_O="L-mcu_config_builder_set_output_audio_bitrate-O",e.L_MCU_CONFIG_BUILDER_SET_OUTPUT_BACKGROUND_COLOR_O="L-mcu_config_builder_set_output_background_color-O",e.L_MCU_CONFIG_BUILDER_SET_OUTPUT_BACKGROUND_PICTURE_O="L-mcu_config_builder_add_output_background_picture-O",e.L_MCU_CONFIG_BUILDER_REMOVE_OUTPUT_BACKGROUND_PICTURE_O="L-mcu_config_builder_remove_output_background_picture-O",e.L_MCU_CONFIG_BUILDER_CLEAR_OUTPUT_BACKGROUND_PICTURE_O="L-mcu_config_builder_clear_output_background_picture-O",e.L_MCU_CONFIG_BUILDER_SET_OUTPUT_BACKGROUND_PICTURE_FILL_MODE_O="L-mcu_config_builder_set_output_background_picture-fill-mode-O",e.L_MCU_CONFIG_BUILDER_ADD_PUBLISH_STREAM_URLS_O="L-mcu_config_builder_add_publish_stream_urls-O",e.L_MCU_CONFIG_BUILDER_REMOVE_PUBLISH_STREAM_URLS_O="L-mcu_config_builder_remove_publish_stream_urls-O",e.L_MCU_CONFIG_BUILDER_CLEAR_PUBLISH_STREAM_URLS_O="L-mcu_config_builder_clear_publish_stream_urls-O",e.L_MCU_CONFIG_BUILDER_ADD_CUSTOMIZE_LAYOUT_VIDEO_O="L-mcu_config_builder_add_customize_layout_video-O",e.L_MCU_CONFIG_BUILDER_REMOVE_CUSTOMIZE_LAYOUT_VIDEO_O="L-mcu_config_builder_remove_customize_layout_video-O",e.L_MCU_CONFIG_BUILDER_CLEAR_CUSTOMIZE_LAYOUT_VIDEO_O="L-mcu_config_builder_clear_customize_layout_video-O",e.L_MCU_CONFIG_BUILDER_SET_CUSTOMIZE_INPUT_AUDIO_O="L-mcu_config_builder_set_customize_input_audio-O",e.L_MCU_CONFIG_BUILDER_ADD_CUSTOMIZE_INPUT_AUDIO_O="L-mcu_config_builder_add_customize_input_audio-O",e.L_MCU_CONFIG_BUILDER_REMOVE_CUSTOMIZE_INPUT_AUDIO_O="L-mcu_config_builder_remove_customize_input_audio-O",e.L_MCU_CONFIG_BUILDER_CLEAR_CUSTOMIZE_INPUT_AUDIO_O="L-mcu_config_builder_clear_customize_input_audio-O",e.L_MCU_CONFIG_BUILDER_RESET_O="L-mcu_config_builder_reset-O",e.L_MCU_CONFIG_BUILDER_ADD_SINGLE_WATER_MARK_O="L-mcu_config_builder_add_single_water_mark-O",e.L_MCU_CONFIG_BUILDER_REMOVE_SINGLE_WATER_MARK_O="L-mcu_config_builder_remove_single_water_mark-O",e.L_MCU_CONFIG_BUILDER_CLEAR_SINGLE_WATER_MARK_O="L-mcu_config_builder_clear_single_water_mark-O",e.L_MEDIA_SERVICE_SET_MCU_CONFIG_T="L-media_service_set_mcu_config-T",e.L_MEDIA_SERVICE_SET_MCU_CONFIG_R="L-media_service_set_mcu_config-R",e.L_MEDIA_SERVICE_GET_CDN_RESOURCE_INFO_T="L-media_service_get_cnd_resource_info-T",e.L_MEDIA_SERVICE_GET_CDN_RESOURCE_INFO_R="L-media_service_get_cnd_resource_info-R",e.L_MEDIA_SERVICE_MSLIST_CHANGE_O="L-media_service_msList_change-O",e.L_MEDIA_SERVICE_PARSE_NAVI_CALLVOIP_INFO_O="L-media_service_parse_navi_callvoip_info-O",e.L_MEDIA_SERVICE_REQUEST_T="L-media_service_request-T",e.L_MEDIA_SERVICE_REQUEST_R="L-media_service_request-R",e.L_LOCAL_TRACK_DESTROY_O="L-loacl_track_destroy-O",e.L_LOCAL_TRACK_SET_BITRATE_O="L-loacl_track_set_bitrate-O",e.L_LOCAL_TRACK_SET_LOCAL_MUTED_O="L-loacl_track_set_local_muted-O",e.L_LOCAL_TRACK_SET_LOCAL_MUTED_SPREAD_T="L-loacl_track_set_local_muted_spread-T",e.L_LOCAL_TRACK_SET_LOCAL_MUTED_SPREAD_R="L-loacl_track_set_local_muted_spread-R",e.L_TRACK_PLAY_O="L-track_play-O",e.L_TRACK_PLAY_E="L-track_play-E",e.L_TRACK_LOAD_START_O="L-track_load_start-O",e.L_TRACK_DURATION_CHANGE_O="L-track_duration_change-O",e.L_TRACK_LOADED_META_DATA_O="L-track_loaded_meta_data-O",e.L_TRACK_LOADED_DATA_O="L-track_loaded_data-O",e.L_TRACK_ABORT_O="L-track_abort-O",e.L_TRACK_VOLUME_CHANGE_O="L-track_volume_change-O",e.L_TRACK_CANPLAY_O="L-track_canplay-O",e.L_ABSTRACT_STAT_PARSER_FORMAT_RTC_STATE_REPORT_O="L-abstract_stat_parser_format_rtc_state_report-O",e.L_A_SDP_STRATEGY_SET_SDP_SEMANTICS_O="L-a_sdp_strategy_set_sdp_semantics-O",e.L_A_SDP_STRATEGY_SET_REMOTE_ANSWER_O="L-a_sdp_strategy_set_remote_answer-O",e.L_RTC_PEER_CONNECTION_ADD_LOCAL_TRACK_O="L-rtc_peer_connection_add_local_track-O",e.L_RTC_PEER_CONNECTION_ICE_CONNECTION_STATE_S="L-rtc_peer_connection_ice_connection_state-S",e.L_RTC_PEER_CONNECTION_ICE_CONNECTION_STATE_REPORT_R="L-rtc_peer_connection_ice_connection_state_report-R",e.L_RTC_PEER_CONNECTION_CONNECTION_STATE_S="L-rtc_peer_connection_connection_state-S",e.L_RTC_PEER_CONNECTION_SET_BITRATE_O="L-rtc_peer_connection_set_bitrate-O",e.L_RTC_PEER_CONNECTION_CREATE_OFFER_O="L-rtc_peer_connection_create_offer-O",e.L_RTC_PEER_CONNECTION_REMOVE_LOCAL_TRACK_BY_ID_O="L-rtc_peer_connection_remove_local_track_by_id-O",e.L_RTC_PEER_CONNECTION_REMOVE_ALL_LOCAL_TRACK_O="L-rtc_peer_connection_remove_all_local_track-O",e.L_RTC_PEER_CONNECTION_REMOVE_LOCAL_TRACK_O="L-rtc_peer_connection_remove_local_track-O",e.L_RTC_PEER_CONNECTION_DESTROY_O="L-rtc_peer_connection_destroy-O",e.L_RTC_SET_RECOMMEND_BITRATE_O="L_rtc_set_recommend_bitrate_O",e.L_RTC_3ANOISE_NODE_O="L_RTC_AAAnoiseNode_O",e.L_RTC_3ANOISE_NODE_E="L_RTC_AAAnoiseNode_E",e.L_RTC_3ANOISE_NODE_STOP_O="L_RTC_AAAnoiseNode_Stop_O",e.L_QS_JOIN_ROOM_S="RTC-joinRoomRtc-S",e.L_QS_SUBSCRIBE_S="RTC-subscribe-S",e.L_QS_UNSUBSCRIBE_S="RTC-unsubscribe-S",e.L_QS_PUBLISH_S="RTC-publishRtc-S",e.L_QS_UNPUBLISH_S="RTC-unpublishRtc-S",e.L_QS_ICE_STATUS_S="RTC-iceStatus-S",e.L_QS_KICKED_S="RTC-forcedOffline-S",e.L_QS_PUB_ICE_STATUS_S="RTC-pubIceConnected-S",e.L_QS_SUB_ICE_STATUS_S="RTC-subIceConnected-S",e.L_QS_RECV_PUB_MSG_S="RTC-recvPubMsg-S",e.L_SET_ENCODER_PREFERENCES_S="RTC-set_Encoder_Preferences-S",e.L_RTCNTF_PULL_ROOM_STATUS_O="L-rtcntf_pull_room_status-O",e.L_RTCPING_PULL_ROOM_STATUS_O="L-rtcping_pull_room_status-O",e.L_PULL_ROOM_STATUS_T="L-pull_room_status-T",e.L_PULL_ROOM_STATUS_R="L-pull_room_status-R",e.L_OLD_DAILY_RECORD_O="L-old_daily_record-O",e.L_REMOTE_USER_JOINED_RESOURCES_O="L-remote_user_joined_resources-O",e.L_REMOTE_USER_STATE_HANDLE_O="L-remote_user_state_handle-O",e.L_UPDATE_SUBSCRIBELIST_COMMAND_T="L-update_subscribeList_command-T",e.L_UPDATE_SUBSCRIBELIST_COMMAND_P="L-update_subscribeList_command-P",e.L_UPDATE_SUBSCRIBELIST_COMMAND_R="L-update_subscribeList_command-R",e.L_RTC_CLIENT_NAVI_CHANGE_O="L-rtc_client_navi_change-O",e.L_UNPUBLISH_PREV_COMMAND_T="L-unpublish_prev_command-T",e.L_UNPUBLISH_PREV_COMMAND_R="L-unpublish_prev_command-R",e.L_RETRY_EXCHANGE_COMMAND_T="L-retry_exchange_command-T",e.L_RETRY_EXCHANGE_SPREAD_T="L-retry_exchange_spread-T",e.L_RETRY_EXCHANGE_SPREAD_R="L-retry_exchange_spread-R",e.L_PARSE_USERSTATE_COMMAND_R="L-parse_userstate_command-R",e.L_RESUB_REPUB_RES_R="L-resub_repub_res-R",e.L_PARSE_ROOMDATA_URIS_R="L-parse_roomdata_uris-R",e.L_SET_AUDIO_CONSTRAINTS_O="L-set_audio_constraints-O",e.L_FUNCTION_IS_UNAVAILABLE="L-function_is_unavailable",e.L_CLEAR_UNSUBSCRIBE_LIST_O="L-clear_unsubscribe_list-O",e.L_INVOKER_PUSH_O="L-invoker_push-O",e.L_INVOKER_EXECUTE_T="L-invoker_execute-T",e.L_INVOKER_EXECUTE_R="L-invoker_execute-R",e.L_INVOKER_DESTROY_O="L-invoker_destroy-R",e.L_PARSE_VOIP_SERVER_CONF_E="L_PARSE_VOIP_SERVER_CONF_E",e.L_GET_MEDIA_STREAM_E="L_GET_MEDIA_STREAM_E",e.L_INNER_SET_TRACK_O="L_INNER_SET_TRACK_O",e.A_APPLY_3A_NOISE_WORKLET_T="A-apply_3a_noise_worklet-T",e.A_APPLY_3A_NOISE_WORKLET_R="A-apply_3a_noise_worklet-R",e.L_ENCRYPTOR_ENCODE_E="L-encryptor_encode-E",e.L_ENCRYPTOR_DECODE_E="L-encryptor_decode-E",e.L_RTC_CLIENT_CHANGE_MEDIA_DEVICE_T="L-rtc_client_change_media_device-T",e.L_RTC_CLIENT_CHANGE_MEDIA_DEVICE_R="L-rtc_client_change_media_device-R"}(he||(he={})),function(e){e.FAILED="fail",e.SUCCESSED="success",e.TIMEOUT="timeout",e.INFO="info"}(ge||(ge={}));let pe=!0,fe=!0;function Ee(e,t,i){const r=e.match(t);return r&&r.length>=i&&parseInt(r[i],10)}function Te(e,t,i){if(!e.RTCPeerConnection)return;const r=e.RTCPeerConnection.prototype,n=r.addEventListener;r.addEventListener=function(e,r){if(e!==t)return n.apply(this,arguments);const s=e=>{const t=i(e);t&&(r.handleEvent?r.handleEvent(t):r(t))};return this._eventMap=this._eventMap||{},this._eventMap[t]||(this._eventMap[t]=new Map),this._eventMap[t].set(r,s),n.apply(this,[e,s])};const s=r.removeEventListener;r.removeEventListener=function(e,i){if(e!==t||!this._eventMap||!this._eventMap[t])return s.apply(this,arguments);if(!this._eventMap[t].has(i))return s.apply(this,arguments);const r=this._eventMap[t].get(i);return this._eventMap[t].delete(i),0===this._eventMap[t].size&&delete this._eventMap[t],0===Object.keys(this._eventMap).length&&delete this._eventMap,s.apply(this,[e,r])},Object.defineProperty(r,"on"+t,{get(){return this["_on"+t]},set(e){this["_on"+t]&&(this.removeEventListener(t,this["_on"+t]),delete this["_on"+t]),e&&this.addEventListener(t,this["_on"+t]=e)},enumerable:!0,configurable:!0})}function me(e){return"boolean"!=typeof e?new Error("Argument type: "+typeof e+". Please use a boolean."):(pe=e,e?"adapter.js logging disabled":"adapter.js logging enabled")}function Ie(e){return"boolean"!=typeof e?new Error("Argument type: "+typeof e+". Please use a boolean."):(fe=!e,"adapter.js deprecation warnings "+(e?"disabled":"enabled"))}function Re(){if("object"==typeof window){if(pe)return;"undefined"!=typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)}}function Se(e,t){fe&&console.warn(e+" is deprecated, please use "+t+" instead.")}function Ce(e){return"[object Object]"===Object.prototype.toString.call(e)}function Le(e){return Ce(e)?Object.keys(e).reduce(function(t,i){const r=Ce(e[i]),n=r?Le(e[i]):e[i],s=r&&!Object.keys(n).length;return void 0===n||s?t:Object.assign(t,{[i]:n})},{}):e}function Oe(e,t,i){t&&!i.has(t.id)&&(i.set(t.id,t),Object.keys(t).forEach(r=>{r.endsWith("Id")?Oe(e,e.get(t[r]),i):r.endsWith("Ids")&&t[r].forEach(t=>{Oe(e,e.get(t),i)})}))}function ve(e,t,i){const r=i?"outbound-rtp":"inbound-rtp",n=new Map;if(null===t)return n;const s=[];return e.forEach(e=>{"track"===e.type&&e.trackIdentifier===t.id&&s.push(e)}),s.forEach(t=>{e.forEach(i=>{i.type===r&&i.trackId===t.id&&Oe(e,i,n)})}),n}const be=Re;function Ae(e,t){const i=e&&e.navigator;if(!i.mediaDevices)return;const r=function(e){if("object"!=typeof e||e.mandatory||e.optional)return e;const t={};return Object.keys(e).forEach(i=>{if("require"===i||"advanced"===i||"mediaSource"===i)return;const r="object"==typeof e[i]?e[i]:{ideal:e[i]};void 0!==r.exact&&"number"==typeof r.exact&&(r.min=r.max=r.exact);const n=function(e,t){return e?e+t.charAt(0).toUpperCase()+t.slice(1):"deviceId"===t?"sourceId":t};if(void 0!==r.ideal){t.optional=t.optional||[];let e={};"number"==typeof r.ideal?(e[n("min",i)]=r.ideal,t.optional.push(e),e={},e[n("max",i)]=r.ideal,t.optional.push(e)):(e[n("",i)]=r.ideal,t.optional.push(e))}void 0!==r.exact&&"number"!=typeof r.exact?(t.mandatory=t.mandatory||{},t.mandatory[n("",i)]=r.exact):["min","max"].forEach(e=>{void 0!==r[e]&&(t.mandatory=t.mandatory||{},t.mandatory[n(e,i)]=r[e])})}),e.advanced&&(t.optional=(t.optional||[]).concat(e.advanced)),t},n=function(e,n){if(t.version>=61)return n(e);if((e=JSON.parse(JSON.stringify(e)))&&"object"==typeof e.audio){const t=function(e,t,i){t in e&&!(i in e)&&(e[i]=e[t],delete e[t])};t((e=JSON.parse(JSON.stringify(e))).audio,"autoGainControl","googAutoGainControl"),t(e.audio,"noiseSuppression","googNoiseSuppression"),e.audio=r(e.audio)}if(e&&"object"==typeof e.video){let s=e.video.facingMode;s=s&&("object"==typeof s?s:{ideal:s});const o=t.version<66;if(s&&("user"===s.exact||"environment"===s.exact||"user"===s.ideal||"environment"===s.ideal)&&(!i.mediaDevices.getSupportedConstraints||!i.mediaDevices.getSupportedConstraints().facingMode||o)){let t;if(delete e.video.facingMode,"environment"===s.exact||"environment"===s.ideal?t=["back","rear"]:"user"!==s.exact&&"user"!==s.ideal||(t=["front"]),t)return i.mediaDevices.enumerateDevices().then(i=>{let o=(i=i.filter(e=>"videoinput"===e.kind)).find(e=>t.some(t=>e.label.toLowerCase().includes(t)));return!o&&i.length&&t.includes("back")&&(o=i[i.length-1]),o&&(e.video.deviceId=s.exact?{exact:o.deviceId}:{ideal:o.deviceId}),e.video=r(e.video),be("chrome: "+JSON.stringify(e)),n(e)})}e.video=r(e.video)}return be("chrome: "+JSON.stringify(e)),n(e)},s=function(e){return t.version>=64?e:{name:{PermissionDeniedError:"NotAllowedError",PermissionDismissedError:"NotAllowedError",InvalidStateError:"NotAllowedError",DevicesNotFoundError:"NotFoundError",ConstraintNotSatisfiedError:"OverconstrainedError",TrackStartError:"NotReadableError",MediaDeviceFailedDueToShutdown:"NotAllowedError",MediaDeviceKillSwitchOn:"NotAllowedError",TabCaptureError:"AbortError",ScreenCaptureError:"AbortError",DeviceCaptureError:"AbortError"}[e.name]||e.name,message:e.message,constraint:e.constraint||e.constraintName,toString(){return this.name+(this.message&&": ")+this.message}}};if(i.getUserMedia=function(e,t,r){n(e,e=>{i.webkitGetUserMedia(e,t,e=>{r&&r(s(e))})})}.bind(i),i.mediaDevices.getUserMedia){const e=i.mediaDevices.getUserMedia.bind(i.mediaDevices);i.mediaDevices.getUserMedia=function(t){return n(t,t=>e(t).then(e=>{if(t.audio&&!e.getAudioTracks().length||t.video&&!e.getVideoTracks().length)throw e.getTracks().forEach(e=>{e.stop()}),new DOMException("","NotFoundError");return e},e=>Promise.reject(s(e))))}}}function ye(e){e.MediaStream=e.MediaStream||e.webkitMediaStream}function Ne(e){if("object"==typeof e&&e.RTCPeerConnection&&!("ontrack"in e.RTCPeerConnection.prototype)){Object.defineProperty(e.RTCPeerConnection.prototype,"ontrack",{get(){return this._ontrack},set(e){this._ontrack&&this.removeEventListener("track",this._ontrack),this.addEventListener("track",this._ontrack=e)},enumerable:!0,configurable:!0});const t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){return this._ontrackpoly||(this._ontrackpoly=t=>{t.stream.addEventListener("addtrack",i=>{let r;r=e.RTCPeerConnection.prototype.getReceivers?this.getReceivers().find(e=>e.track&&e.track.id===i.track.id):{track:i.track};const n=new Event("track");n.track=i.track,n.receiver=r,n.transceiver={receiver:r},n.streams=[t.stream],this.dispatchEvent(n)}),t.stream.getTracks().forEach(i=>{let r;r=e.RTCPeerConnection.prototype.getReceivers?this.getReceivers().find(e=>e.track&&e.track.id===i.id):{track:i};const n=new Event("track");n.track=i,n.receiver=r,n.transceiver={receiver:r},n.streams=[t.stream],this.dispatchEvent(n)})},this.addEventListener("addstream",this._ontrackpoly)),t.apply(this,arguments)}}else Te(e,"track",e=>(e.transceiver||Object.defineProperty(e,"transceiver",{value:{receiver:e.receiver}}),e))}function Pe(e){if("object"==typeof e&&e.RTCPeerConnection&&!("getSenders"in e.RTCPeerConnection.prototype)&&"createDTMFSender"in e.RTCPeerConnection.prototype){const t=function(e,t){return{track:t,get dtmf(){return void 0===this._dtmf&&("audio"===t.kind?this._dtmf=e.createDTMFSender(t):this._dtmf=null),this._dtmf},_pc:e}};if(!e.RTCPeerConnection.prototype.getSenders){e.RTCPeerConnection.prototype.getSenders=function(){return this._senders=this._senders||[],this._senders.slice()};const i=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,r){let n=i.apply(this,arguments);return n||(n=t(this,e),this._senders.push(n)),n};const r=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){r.apply(this,arguments);const t=this._senders.indexOf(e);-1!==t&&this._senders.splice(t,1)}}const i=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){this._senders=this._senders||[],i.apply(this,[e]),e.getTracks().forEach(e=>{this._senders.push(t(this,e))})};const r=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){this._senders=this._senders||[],r.apply(this,[e]),e.getTracks().forEach(e=>{const t=this._senders.find(t=>t.track===e);t&&this._senders.splice(this._senders.indexOf(t),1)})}}else if("object"==typeof e&&e.RTCPeerConnection&&"getSenders"in e.RTCPeerConnection.prototype&&"createDTMFSender"in e.RTCPeerConnection.prototype&&e.RTCRtpSender&&!("dtmf"in e.RTCRtpSender.prototype)){const t=e.RTCPeerConnection.prototype.getSenders;e.RTCPeerConnection.prototype.getSenders=function(){const e=t.apply(this,[]);return e.forEach(e=>e._pc=this),e},Object.defineProperty(e.RTCRtpSender.prototype,"dtmf",{get(){return void 0===this._dtmf&&("audio"===this.track.kind?this._dtmf=this._pc.createDTMFSender(this.track):this._dtmf=null),this._dtmf}})}}function Ue(e){if(!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){const[e,i,r]=arguments;if(arguments.length>0&&"function"==typeof e)return t.apply(this,arguments);if(0===t.length&&(0===arguments.length||"function"!=typeof e))return t.apply(this,[]);const n=function(e){const t={};return e.result().forEach(e=>{const i={id:e.id,timestamp:e.timestamp,type:{localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[e.type]||e.type};e.names().forEach(t=>{i[t]=e.stat(t)}),t[i.id]=i}),t},s=function(e){return new Map(Object.keys(e).map(t=>[t,e[t]]))};if(arguments.length>=2){const r=function(e){i(s(n(e)))};return t.apply(this,[r,e])}return new Promise((e,i)=>{t.apply(this,[function(t){e(s(n(t)))},i])}).then(i,r)}}function De(e){if(!("object"==typeof e&&e.RTCPeerConnection&&e.RTCRtpSender&&e.RTCRtpReceiver))return;if(!("getStats"in e.RTCRtpSender.prototype)){const t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){const e=t.apply(this,[]);return e.forEach(e=>e._pc=this),e});const i=e.RTCPeerConnection.prototype.addTrack;i&&(e.RTCPeerConnection.prototype.addTrack=function(){const e=i.apply(this,arguments);return e._pc=this,e}),e.RTCRtpSender.prototype.getStats=function(){const e=this;return this._pc.getStats().then(t=>ve(t,e.track,!0))}}if(!("getStats"in e.RTCRtpReceiver.prototype)){const t=e.RTCPeerConnection.prototype.getReceivers;t&&(e.RTCPeerConnection.prototype.getReceivers=function(){const e=t.apply(this,[]);return e.forEach(e=>e._pc=this),e}),Te(e,"track",e=>(e.receiver._pc=e.srcElement,e)),e.RTCRtpReceiver.prototype.getStats=function(){const e=this;return this._pc.getStats().then(t=>ve(t,e.track,!1))}}if(!("getStats"in e.RTCRtpSender.prototype)||!("getStats"in e.RTCRtpReceiver.prototype))return;const t=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){if(arguments.length>0&&arguments[0]instanceof e.MediaStreamTrack){const e=arguments[0];let t,i,r;return this.getSenders().forEach(i=>{i.track===e&&(t?r=!0:t=i)}),this.getReceivers().forEach(t=>(t.track===e&&(i?r=!0:i=t),t.track===e)),r||t&&i?Promise.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):t?t.getStats():i?i.getStats():Promise.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return t.apply(this,arguments)}}function Me(e){e.RTCPeerConnection.prototype.getLocalStreams=function(){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},Object.keys(this._shimmedLocalStreams).map(e=>this._shimmedLocalStreams[e][0])};const t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,i){if(!i)return t.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};const r=t.apply(this,arguments);return this._shimmedLocalStreams[i.id]?-1===this._shimmedLocalStreams[i.id].indexOf(r)&&this._shimmedLocalStreams[i.id].push(r):this._shimmedLocalStreams[i.id]=[i,r],r};const i=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){this._shimmedLocalStreams=this._shimmedLocalStreams||{},e.getTracks().forEach(e=>{if(this.getSenders().find(t=>t.track===e))throw new DOMException("Track already exists.","InvalidAccessError")});const t=this.getSenders();i.apply(this,arguments);const r=this.getSenders().filter(e=>-1===t.indexOf(e));this._shimmedLocalStreams[e.id]=[e].concat(r)};const r=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},delete this._shimmedLocalStreams[e.id],r.apply(this,arguments)};const n=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},e&&Object.keys(this._shimmedLocalStreams).forEach(t=>{const i=this._shimmedLocalStreams[t].indexOf(e);-1!==i&&this._shimmedLocalStreams[t].splice(i,1),1===this._shimmedLocalStreams[t].length&&delete this._shimmedLocalStreams[t]}),n.apply(this,arguments)}}function we(e,t){if(!e.RTCPeerConnection)return;if(e.RTCPeerConnection.prototype.addTrack&&t.version>=65)return Me(e);const i=e.RTCPeerConnection.prototype.getLocalStreams;e.RTCPeerConnection.prototype.getLocalStreams=function(){const e=i.apply(this);return this._reverseStreams=this._reverseStreams||{},e.map(e=>this._reverseStreams[e.id])};const r=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(t){if(this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},t.getTracks().forEach(e=>{if(this.getSenders().find(t=>t.track===e))throw new DOMException("Track already exists.","InvalidAccessError")}),!this._reverseStreams[t.id]){const i=new e.MediaStream(t.getTracks());this._streams[t.id]=i,this._reverseStreams[i.id]=t,t=i}r.apply(this,[t])};const n=e.RTCPeerConnection.prototype.removeStream;function s(e,t){let i=t.sdp;return Object.keys(e._reverseStreams||[]).forEach(t=>{const r=e._reverseStreams[t],n=e._streams[r.id];i=i.replace(new RegExp(n.id,"g"),r.id)}),new RTCSessionDescription({type:t.type,sdp:i})}e.RTCPeerConnection.prototype.removeStream=function(e){this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},n.apply(this,[this._streams[e.id]||e]),delete this._reverseStreams[this._streams[e.id]?this._streams[e.id].id:e.id],delete this._streams[e.id]},e.RTCPeerConnection.prototype.addTrack=function(t,i){if("closed"===this.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");const r=[].slice.call(arguments,1);if(1!==r.length||!r[0].getTracks().find(e=>e===t))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(e=>e.track===t))throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};const n=this._streams[i.id];if(n)n.addTrack(t),Promise.resolve().then(()=>{this.dispatchEvent(new Event("negotiationneeded"))});else{const r=new e.MediaStream([t]);this._streams[i.id]=r,this._reverseStreams[r.id]=i,this.addStream(r)}return this.getSenders().find(e=>e.track===t)},["createOffer","createAnswer"].forEach(function(t){const i=e.RTCPeerConnection.prototype[t],r={[t](){const e=arguments;return arguments.length&&"function"==typeof arguments[0]?i.apply(this,[t=>{const i=s(this,t);e[0].apply(null,[i])},t=>{e[1]&&e[1].apply(null,t)},arguments[2]]):i.apply(this,arguments).then(e=>s(this,e))}};e.RTCPeerConnection.prototype[t]=r[t]});const o=e.RTCPeerConnection.prototype.setLocalDescription;e.RTCPeerConnection.prototype.setLocalDescription=function(){return arguments.length&&arguments[0].type?(arguments[0]=function(e,t){let i=t.sdp;return Object.keys(e._reverseStreams||[]).forEach(t=>{const r=e._reverseStreams[t],n=e._streams[r.id];i=i.replace(new RegExp(r.id,"g"),n.id)}),new RTCSessionDescription({type:t.type,sdp:i})}(this,arguments[0]),o.apply(this,arguments)):o.apply(this,arguments)};const a=Object.getOwnPropertyDescriptor(e.RTCPeerConnection.prototype,"localDescription");Object.defineProperty(e.RTCPeerConnection.prototype,"localDescription",{get(){const e=a.get.apply(this);return""===e.type?e:s(this,e)}}),e.RTCPeerConnection.prototype.removeTrack=function(e){if("closed"===this.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");if(!e._pc)throw new DOMException("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.","TypeError");if(!(e._pc===this))throw new DOMException("Sender was not created by this connection.","InvalidAccessError");let t;this._streams=this._streams||{},Object.keys(this._streams).forEach(i=>{this._streams[i].getTracks().find(t=>e.track===t)&&(t=this._streams[i])}),t&&(1===t.getTracks().length?this.removeStream(this._reverseStreams[t.id]):t.removeTrack(e.track),this.dispatchEvent(new Event("negotiationneeded")))}}function ke(e,t){!e.RTCPeerConnection&&e.webkitRTCPeerConnection&&(e.RTCPeerConnection=e.webkitRTCPeerConnection),e.RTCPeerConnection&&t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(t){const i=e.RTCPeerConnection.prototype[t],r={[t](){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),i.apply(this,arguments)}};e.RTCPeerConnection.prototype[t]=r[t]})}function xe(e,t){Te(e,"negotiationneeded",e=>{const i=e.target;if(!(t.version<72||i.getConfiguration&&"plan-b"===i.getConfiguration().sdpSemantics)||"stable"===i.signalingState)return e})}var Be=Object.freeze({__proto__:null,shimMediaStream:ye,shimOnTrack:Ne,shimGetSendersWithDtmf:Pe,shimGetStats:Ue,shimSenderReceiverGetStats:De,shimAddTrackRemoveTrackWithNative:Me,shimAddTrackRemoveTrack:we,shimPeerConnection:ke,fixNegotiationNeeded:xe,shimGetUserMedia:Ae,shimGetDisplayMedia:function(e,t){e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||e.navigator.mediaDevices&&("function"==typeof t?e.navigator.mediaDevices.getDisplayMedia=function(i){return t(i).then(t=>{const r=i.video&&i.video.width,n=i.video&&i.video.height,s=i.video&&i.video.frameRate;return i.video={mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:t,maxFrameRate:s||3}},r&&(i.video.mandatory.maxWidth=r),n&&(i.video.mandatory.maxHeight=n),e.navigator.mediaDevices.getUserMedia(i)})}:console.error("shimGetDisplayMedia: getSourceId argument is not a function"))}});var Ve,Ge,Fe=(Ve=function(e){var t={generateIdentifier:function(){return Math.random().toString(36).substr(2,10)}};t.localCName=t.generateIdentifier(),t.splitLines=function(e){return e.trim().split("\n").map(function(e){return e.trim()})},t.splitSections=function(e){return e.split("\nm=").map(function(e,t){return(t>0?"m="+e:e).trim()+"\r\n"})},t.getDescription=function(e){var i=t.splitSections(e);return i&&i[0]},t.getMediaSections=function(e){var i=t.splitSections(e);return i.shift(),i},t.matchPrefix=function(e,i){return t.splitLines(e).filter(function(e){return 0===e.indexOf(i)})},t.parseCandidate=function(e){for(var t,i={foundation:(t=0===e.indexOf("a=candidate:")?e.substring(12).split(" "):e.substring(10).split(" "))[0],component:parseInt(t[1],10),protocol:t[2].toLowerCase(),priority:parseInt(t[3],10),ip:t[4],address:t[4],port:parseInt(t[5],10),type:t[7]},r=8;r<t.length;r+=2)switch(t[r]){case"raddr":i.relatedAddress=t[r+1];break;case"rport":i.relatedPort=parseInt(t[r+1],10);break;case"tcptype":i.tcpType=t[r+1];break;case"ufrag":i.ufrag=t[r+1],i.usernameFragment=t[r+1];break;default:i[t[r]]=t[r+1]}return i},t.writeCandidate=function(e){var t=[];t.push(e.foundation),t.push(e.component),t.push(e.protocol.toUpperCase()),t.push(e.priority),t.push(e.address||e.ip),t.push(e.port);var i=e.type;return t.push("typ"),t.push(i),"host"!==i&&e.relatedAddress&&e.relatedPort&&(t.push("raddr"),t.push(e.relatedAddress),t.push("rport"),t.push(e.relatedPort)),e.tcpType&&"tcp"===e.protocol.toLowerCase()&&(t.push("tcptype"),t.push(e.tcpType)),(e.usernameFragment||e.ufrag)&&(t.push("ufrag"),t.push(e.usernameFragment||e.ufrag)),"candidate:"+t.join(" ")},t.parseIceOptions=function(e){return e.substr(14).split(" ")},t.parseRtpMap=function(e){var t=e.substr(9).split(" "),i={payloadType:parseInt(t.shift(),10)};return t=t[0].split("/"),i.name=t[0],i.clockRate=parseInt(t[1],10),i.channels=3===t.length?parseInt(t[2],10):1,i.numChannels=i.channels,i},t.writeRtpMap=function(e){var t=e.payloadType;void 0!==e.preferredPayloadType&&(t=e.preferredPayloadType);var i=e.channels||e.numChannels||1;return"a=rtpmap:"+t+" "+e.name+"/"+e.clockRate+(1!==i?"/"+i:"")+"\r\n"},t.parseExtmap=function(e){var t=e.substr(9).split(" ");return{id:parseInt(t[0],10),direction:t[0].indexOf("/")>0?t[0].split("/")[1]:"sendrecv",uri:t[1]}},t.writeExtmap=function(e){return"a=extmap:"+(e.id||e.preferredId)+(e.direction&&"sendrecv"!==e.direction?"/"+e.direction:"")+" "+e.uri+"\r\n"},t.parseFmtp=function(e){for(var t,i={},r=e.substr(e.indexOf(" ")+1).split(";"),n=0;n<r.length;n++)i[(t=r[n].trim().split("="))[0].trim()]=t[1];return i},t.writeFmtp=function(e){var t="",i=e.payloadType;if(void 0!==e.preferredPayloadType&&(i=e.preferredPayloadType),e.parameters&&Object.keys(e.parameters).length){var r=[];Object.keys(e.parameters).forEach(function(t){e.parameters[t]?r.push(t+"="+e.parameters[t]):r.push(t)}),t+="a=fmtp:"+i+" "+r.join(";")+"\r\n"}return t},t.parseRtcpFb=function(e){var t=e.substr(e.indexOf(" ")+1).split(" ");return{type:t.shift(),parameter:t.join(" ")}},t.writeRtcpFb=function(e){var t="",i=e.payloadType;return void 0!==e.preferredPayloadType&&(i=e.preferredPayloadType),e.rtcpFeedback&&e.rtcpFeedback.length&&e.rtcpFeedback.forEach(function(e){t+="a=rtcp-fb:"+i+" "+e.type+(e.parameter&&e.parameter.length?" "+e.parameter:"")+"\r\n"}),t},t.parseSsrcMedia=function(e){var t=e.indexOf(" "),i={ssrc:parseInt(e.substr(7,t-7),10)},r=e.indexOf(":",t);return r>-1?(i.attribute=e.substr(t+1,r-t-1),i.value=e.substr(r+1)):i.attribute=e.substr(t+1),i},t.parseSsrcGroup=function(e){var t=e.substr(13).split(" ");return{semantics:t.shift(),ssrcs:t.map(function(e){return parseInt(e,10)})}},t.getMid=function(e){var i=t.matchPrefix(e,"a=mid:")[0];if(i)return i.substr(6)},t.parseFingerprint=function(e){var t=e.substr(14).split(" ");return{algorithm:t[0].toLowerCase(),value:t[1]}},t.getDtlsParameters=function(e,i){return{role:"auto",fingerprints:t.matchPrefix(e+i,"a=fingerprint:").map(t.parseFingerprint)}},t.writeDtlsParameters=function(e,t){var i="a=setup:"+t+"\r\n";return e.fingerprints.forEach(function(e){i+="a=fingerprint:"+e.algorithm+" "+e.value+"\r\n"}),i},t.parseCryptoLine=function(e){var t=e.substr(9).split(" ");return{tag:parseInt(t[0],10),cryptoSuite:t[1],keyParams:t[2],sessionParams:t.slice(3)}},t.writeCryptoLine=function(e){return"a=crypto:"+e.tag+" "+e.cryptoSuite+" "+("object"==typeof e.keyParams?t.writeCryptoKeyParams(e.keyParams):e.keyParams)+(e.sessionParams?" "+e.sessionParams.join(" "):"")+"\r\n"},t.parseCryptoKeyParams=function(e){if(0!==e.indexOf("inline:"))return null;var t=e.substr(7).split("|");return{keyMethod:"inline",keySalt:t[0],lifeTime:t[1],mkiValue:t[2]?t[2].split(":")[0]:void 0,mkiLength:t[2]?t[2].split(":")[1]:void 0}},t.writeCryptoKeyParams=function(e){return e.keyMethod+":"+e.keySalt+(e.lifeTime?"|"+e.lifeTime:"")+(e.mkiValue&&e.mkiLength?"|"+e.mkiValue+":"+e.mkiLength:"")},t.getCryptoParameters=function(e,i){return t.matchPrefix(e+i,"a=crypto:").map(t.parseCryptoLine)},t.getIceParameters=function(e,i){var r=t.matchPrefix(e+i,"a=ice-ufrag:")[0],n=t.matchPrefix(e+i,"a=ice-pwd:")[0];return r&&n?{usernameFragment:r.substr(12),password:n.substr(10)}:null},t.writeIceParameters=function(e){return"a=ice-ufrag:"+e.usernameFragment+"\r\na=ice-pwd:"+e.password+"\r\n"},t.parseRtpParameters=function(e){for(var i={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},r=t.splitLines(e)[0].split(" "),n=3;n<r.length;n++){var s=r[n],o=t.matchPrefix(e,"a=rtpmap:"+s+" ")[0];if(o){var a=t.parseRtpMap(o),l=t.matchPrefix(e,"a=fmtp:"+s+" ");switch(a.parameters=l.length?t.parseFmtp(l[0]):{},a.rtcpFeedback=t.matchPrefix(e,"a=rtcp-fb:"+s+" ").map(t.parseRtcpFb),i.codecs.push(a),a.name.toUpperCase()){case"RED":case"ULPFEC":i.fecMechanisms.push(a.name.toUpperCase())}}}return t.matchPrefix(e,"a=extmap:").forEach(function(e){i.headerExtensions.push(t.parseExtmap(e))}),i},t.writeRtpDescription=function(e,i){var r="";r+="m="+e+" ",r+=i.codecs.length>0?"9":"0",r+=" UDP/TLS/RTP/SAVPF ",r+=i.codecs.map(function(e){return void 0!==e.preferredPayloadType?e.preferredPayloadType:e.payloadType}).join(" ")+"\r\n",r+="c=IN IP4 0.0.0.0\r\n",r+="a=rtcp:9 IN IP4 0.0.0.0\r\n",i.codecs.forEach(function(e){r+=t.writeRtpMap(e),r+=t.writeFmtp(e),r+=t.writeRtcpFb(e)});var n=0;return i.codecs.forEach(function(e){e.maxptime>n&&(n=e.maxptime)}),n>0&&(r+="a=maxptime:"+n+"\r\n"),r+="a=rtcp-mux\r\n",i.headerExtensions&&i.headerExtensions.forEach(function(e){r+=t.writeExtmap(e)}),r},t.parseRtpEncodingParameters=function(e){var i,r=[],n=t.parseRtpParameters(e),s=-1!==n.fecMechanisms.indexOf("RED"),o=-1!==n.fecMechanisms.indexOf("ULPFEC"),a=t.matchPrefix(e,"a=ssrc:").map(function(e){return t.parseSsrcMedia(e)}).filter(function(e){return"cname"===e.attribute}),l=a.length>0&&a[0].ssrc,_=t.matchPrefix(e,"a=ssrc-group:FID").map(function(e){return e.substr(17).split(" ").map(function(e){return parseInt(e,10)})});_.length>0&&_[0].length>1&&_[0][0]===l&&(i=_[0][1]),n.codecs.forEach(function(e){if("RTX"===e.name.toUpperCase()&&e.parameters.apt){var t={ssrc:l,codecPayloadType:parseInt(e.parameters.apt,10)};l&&i&&(t.rtx={ssrc:i}),r.push(t),s&&((t=JSON.parse(JSON.stringify(t))).fec={ssrc:l,mechanism:o?"red+ulpfec":"red"},r.push(t))}}),0===r.length&&l&&r.push({ssrc:l});var c=t.matchPrefix(e,"b=");return c.length&&(c=0===c[0].indexOf("b=TIAS:")?parseInt(c[0].substr(7),10):0===c[0].indexOf("b=AS:")?1e3*parseInt(c[0].substr(5),10)*.95-16e3:void 0,r.forEach(function(e){e.maxBitrate=c})),r},t.parseRtcpParameters=function(e){var i={},r=t.matchPrefix(e,"a=ssrc:").map(function(e){return t.parseSsrcMedia(e)}).filter(function(e){return"cname"===e.attribute})[0];r&&(i.cname=r.value,i.ssrc=r.ssrc);var n=t.matchPrefix(e,"a=rtcp-rsize");i.reducedSize=n.length>0,i.compound=0===n.length;var s=t.matchPrefix(e,"a=rtcp-mux");return i.mux=s.length>0,i},t.parseMsid=function(e){var i,r=t.matchPrefix(e,"a=msid:");if(1===r.length)return{stream:(i=r[0].substr(7).split(" "))[0],track:i[1]};var n=t.matchPrefix(e,"a=ssrc:").map(function(e){return t.parseSsrcMedia(e)}).filter(function(e){return"msid"===e.attribute});return n.length>0?{stream:(i=n[0].value.split(" "))[0],track:i[1]}:void 0},t.parseSctpDescription=function(e){var i,r=t.parseMLine(e),n=t.matchPrefix(e,"a=max-message-size:");n.length>0&&(i=parseInt(n[0].substr(19),10)),isNaN(i)&&(i=65536);var s=t.matchPrefix(e,"a=sctp-port:");if(s.length>0)return{port:parseInt(s[0].substr(12),10),protocol:r.fmt,maxMessageSize:i};if(t.matchPrefix(e,"a=sctpmap:").length>0){var o=t.matchPrefix(e,"a=sctpmap:")[0].substr(10).split(" ");return{port:parseInt(o[0],10),protocol:o[1],maxMessageSize:i}}},t.writeSctpDescription=function(e,t){var i=[];return i="DTLS/SCTP"!==e.protocol?["m="+e.kind+" 9 "+e.protocol+" "+t.protocol+"\r\n","c=IN IP4 0.0.0.0\r\n","a=sctp-port:"+t.port+"\r\n"]:["m="+e.kind+" 9 "+e.protocol+" "+t.port+"\r\n","c=IN IP4 0.0.0.0\r\n","a=sctpmap:"+t.port+" "+t.protocol+" 65535\r\n"],void 0!==t.maxMessageSize&&i.push("a=max-message-size:"+t.maxMessageSize+"\r\n"),i.join("")},t.generateSessionId=function(){return Math.random().toString().substr(2,21)},t.writeSessionBoilerplate=function(e,i,r){var n=void 0!==i?i:2;return"v=0\r\no="+(r||"thisisadapterortc")+" "+(e||t.generateSessionId())+" "+n+" IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\n"},t.writeMediaSection=function(e,i,r,n){var s=t.writeRtpDescription(e.kind,i);if(s+=t.writeIceParameters(e.iceGatherer.getLocalParameters()),s+=t.writeDtlsParameters(e.dtlsTransport.getLocalParameters(),"offer"===r?"actpass":"active"),s+="a=mid:"+e.mid+"\r\n",e.direction?s+="a="+e.direction+"\r\n":e.rtpSender&&e.rtpReceiver?s+="a=sendrecv\r\n":e.rtpSender?s+="a=sendonly\r\n":e.rtpReceiver?s+="a=recvonly\r\n":s+="a=inactive\r\n",e.rtpSender){var o="msid:"+n.id+" "+e.rtpSender.track.id+"\r\n";s+="a="+o,s+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" "+o,e.sendEncodingParameters[0].rtx&&(s+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" "+o,s+="a=ssrc-group:FID "+e.sendEncodingParameters[0].ssrc+" "+e.sendEncodingParameters[0].rtx.ssrc+"\r\n")}return s+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" cname:"+t.localCName+"\r\n",e.rtpSender&&e.sendEncodingParameters[0].rtx&&(s+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" cname:"+t.localCName+"\r\n"),s},t.getDirection=function(e,i){for(var r=t.splitLines(e),n=0;n<r.length;n++)switch(r[n]){case"a=sendrecv":case"a=sendonly":case"a=recvonly":case"a=inactive":return r[n].substr(2)}return i?t.getDirection(i):"sendrecv"},t.getKind=function(e){return t.splitLines(e)[0].split(" ")[0].substr(2)},t.isRejected=function(e){return"0"===e.split(" ",2)[1]},t.parseMLine=function(e){var i=t.splitLines(e)[0].substr(2).split(" ");return{kind:i[0],port:parseInt(i[1],10),protocol:i[2],fmt:i.slice(3).join(" ")}},t.parseOLine=function(e){var i=t.matchPrefix(e,"o=")[0].substr(2).split(" ");return{username:i[0],sessionId:i[1],sessionVersion:parseInt(i[2],10),netType:i[3],addressType:i[4],address:i[5]}},t.isValidSDP=function(e){if("string"!=typeof e||0===e.length)return!1;for(var i=t.splitLines(e),r=0;r<i.length;r++)if(i[r].length<2||"="!==i[r].charAt(1))return!1;return!0},e.exports=t},Ve(Ge={exports:{}},Ge.exports),Ge.exports);function je(e,t,i,r,n){var s=Fe.writeRtpDescription(e.kind,t);if(s+=Fe.writeIceParameters(e.iceGatherer.getLocalParameters()),s+=Fe.writeDtlsParameters(e.dtlsTransport.getLocalParameters(),"offer"===i?"actpass":n||"active"),s+="a=mid:"+e.mid+"\r\n",e.rtpSender&&e.rtpReceiver?s+="a=sendrecv\r\n":e.rtpSender?s+="a=sendonly\r\n":e.rtpReceiver?s+="a=recvonly\r\n":s+="a=inactive\r\n",e.rtpSender){var o=e.rtpSender._initialTrackId||e.rtpSender.track.id;e.rtpSender._initialTrackId=o;var a="msid:"+(r?r.id:"-")+" "+o+"\r\n";s+="a="+a,s+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" "+a,e.sendEncodingParameters[0].rtx&&(s+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" "+a,s+="a=ssrc-group:FID "+e.sendEncodingParameters[0].ssrc+" "+e.sendEncodingParameters[0].rtx.ssrc+"\r\n")}return s+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" cname:"+Fe.localCName+"\r\n",e.rtpSender&&e.sendEncodingParameters[0].rtx&&(s+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" cname:"+Fe.localCName+"\r\n"),s}function He(e,t){var i={codecs:[],headerExtensions:[],fecMechanisms:[]},r=function(e,t){e=parseInt(e,10);for(var i=0;i<t.length;i++)if(t[i].payloadType===e||t[i].preferredPayloadType===e)return t[i]},n=function(e,t,i,n){var s=r(e.parameters.apt,i),o=r(t.parameters.apt,n);return s&&o&&s.name.toLowerCase()===o.name.toLowerCase()};return e.codecs.forEach(function(r){for(var s=0;s<t.codecs.length;s++){var o=t.codecs[s];if(r.name.toLowerCase()===o.name.toLowerCase()&&r.clockRate===o.clockRate){if("rtx"===r.name.toLowerCase()&&r.parameters&&o.parameters.apt&&!n(r,o,e.codecs,t.codecs))continue;(o=JSON.parse(JSON.stringify(o))).numChannels=Math.min(r.numChannels,o.numChannels),i.codecs.push(o),o.rtcpFeedback=o.rtcpFeedback.filter(function(e){for(var t=0;t<r.rtcpFeedback.length;t++)if(r.rtcpFeedback[t].type===e.type&&r.rtcpFeedback[t].parameter===e.parameter)return!0;return!1});break}}}),e.headerExtensions.forEach(function(e){for(var r=0;r<t.headerExtensions.length;r++){var n=t.headerExtensions[r];if(e.uri===n.uri){i.headerExtensions.push(n);break}}}),i}function Je(e,t,i){return-1!=={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"]}}[t][e].indexOf(i)}function $e(e,t){var i=e.getRemoteCandidates().find(function(e){return t.foundation===e.foundation&&t.ip===e.ip&&t.port===e.port&&t.priority===e.priority&&t.protocol===e.protocol&&t.type===e.type});return i||e.addRemoteCandidate(t),!i}function Ke(e,t){var i=new Error(t);return i.name=e,i.code={NotSupportedError:9,InvalidStateError:11,InvalidAccessError:15,TypeError:void 0,OperationError:void 0}[e],i}var Ye=function(e,t){function i(t,i){i.addTrack(t),i.dispatchEvent(new e.MediaStreamTrackEvent("addtrack",{track:t}))}function r(t,i,r,n){var s=new Event("track");s.track=i,s.receiver=r,s.transceiver={receiver:r},s.streams=n,e.setTimeout(function(){t._dispatchEvent("track",s)})}var n=function(i){var r=this,n=document.createDocumentFragment();if(["addEventListener","removeEventListener","dispatchEvent"].forEach(function(e){r[e]=n[e].bind(n)}),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",i=JSON.parse(JSON.stringify(i||{})),this.usingBundle="max-bundle"===i.bundlePolicy,"negotiate"===i.rtcpMuxPolicy)throw Ke("NotSupportedError","rtcpMuxPolicy 'negotiate' is not supported");switch(i.rtcpMuxPolicy||(i.rtcpMuxPolicy="require"),i.iceTransportPolicy){case"all":case"relay":break;default:i.iceTransportPolicy="all"}switch(i.bundlePolicy){case"balanced":case"max-compat":case"max-bundle":break;default:i.bundlePolicy="balanced"}if(i.iceServers=function(e,t){var i=!1;return(e=JSON.parse(JSON.stringify(e))).filter(function(e){if(e&&(e.urls||e.url)){var r=e.urls||e.url;e.url&&!e.urls&&console.warn("RTCIceServer.url is deprecated! Use urls instead.");var n="string"==typeof r;return n&&(r=[r]),r=r.filter(function(e){return 0!==e.indexOf("turn:")||-1===e.indexOf("transport=udp")||-1!==e.indexOf("turn:[")||i?0===e.indexOf("stun:")&&t>=14393&&-1===e.indexOf("?transport=udp"):(i=!0,!0)}),delete e.url,e.urls=n?r[0]:r,!!r.length}})}(i.iceServers||[],t),this._iceGatherers=[],i.iceCandidatePoolSize)for(var s=i.iceCandidatePoolSize;s>0;s--)this._iceGatherers.push(new e.RTCIceGatherer({iceServers:i.iceServers,gatherPolicy:i.iceTransportPolicy}));else i.iceCandidatePoolSize=0;this._config=i,this.transceivers=[],this._sdpSessionId=Fe.generateSessionId(),this._sdpSessionVersion=0,this._dtlsRole=void 0,this._isClosed=!1};Object.defineProperty(n.prototype,"localDescription",{configurable:!0,get:function(){return this._localDescription}}),Object.defineProperty(n.prototype,"remoteDescription",{configurable:!0,get:function(){return this._remoteDescription}}),n.prototype.onicecandidate=null,n.prototype.onaddstream=null,n.prototype.ontrack=null,n.prototype.onremovestream=null,n.prototype.onsignalingstatechange=null,n.prototype.oniceconnectionstatechange=null,n.prototype.onconnectionstatechange=null,n.prototype.onicegatheringstatechange=null,n.prototype.onnegotiationneeded=null,n.prototype.ondatachannel=null,n.prototype._dispatchEvent=function(e,t){this._isClosed||(this.dispatchEvent(t),"function"==typeof this["on"+e]&&this["on"+e](t))},n.prototype._emitGatheringStateChange=function(){var e=new Event("icegatheringstatechange");this._dispatchEvent("icegatheringstatechange",e)},n.prototype.getConfiguration=function(){return this._config},n.prototype.getLocalStreams=function(){return this.localStreams},n.prototype.getRemoteStreams=function(){return this.remoteStreams},n.prototype._createTransceiver=function(e,t){var i=this.transceivers.length>0,r={track:null,iceGatherer:null,iceTransport:null,dtlsTransport:null,localCapabilities:null,remoteCapabilities:null,rtpSender:null,rtpReceiver:null,kind:e,mid:null,sendEncodingParameters:null,recvEncodingParameters:null,stream:null,associatedRemoteMediaStreams:[],wantReceive:!0};if(this.usingBundle&&i)r.iceTransport=this.transceivers[0].iceTransport,r.dtlsTransport=this.transceivers[0].dtlsTransport;else{var n=this._createIceAndDtlsTransports();r.iceTransport=n.iceTransport,r.dtlsTransport=n.dtlsTransport}return t||this.transceivers.push(r),r},n.prototype.addTrack=function(t,i){if(this._isClosed)throw Ke("InvalidStateError","Attempted to call addTrack on a closed peerconnection.");var r;if(this.transceivers.find(function(e){return e.track===t}))throw Ke("InvalidAccessError","Track already exists.");for(var n=0;n<this.transceivers.length;n++)this.transceivers[n].track||this.transceivers[n].kind!==t.kind||(r=this.transceivers[n]);return r||(r=this._createTransceiver(t.kind)),this._maybeFireNegotiationNeeded(),-1===this.localStreams.indexOf(i)&&this.localStreams.push(i),r.track=t,r.stream=i,r.rtpSender=new e.RTCRtpSender(t,r.dtlsTransport),r.rtpSender},n.prototype.addStream=function(e){var i=this;if(t>=15025)e.getTracks().forEach(function(t){i.addTrack(t,e)});else{var r=e.clone();e.getTracks().forEach(function(e,t){var i=r.getTracks()[t];e.addEventListener("enabled",function(e){i.enabled=e.enabled})}),r.getTracks().forEach(function(e){i.addTrack(e,r)})}},n.prototype.removeTrack=function(t){if(this._isClosed)throw Ke("InvalidStateError","Attempted to call removeTrack on a closed peerconnection.");if(!(t instanceof e.RTCRtpSender))throw new TypeError("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.");var i=this.transceivers.find(function(e){return e.rtpSender===t});if(!i)throw Ke("InvalidAccessError","Sender was not created by this connection.");var r=i.stream;i.rtpSender.stop(),i.rtpSender=null,i.track=null,i.stream=null,-1===this.transceivers.map(function(e){return e.stream}).indexOf(r)&&this.localStreams.indexOf(r)>-1&&this.localStreams.splice(this.localStreams.indexOf(r),1),this._maybeFireNegotiationNeeded()},n.prototype.removeStream=function(e){var t=this;e.getTracks().forEach(function(e){var i=t.getSenders().find(function(t){return t.track===e});i&&t.removeTrack(i)})},n.prototype.getSenders=function(){return this.transceivers.filter(function(e){return!!e.rtpSender}).map(function(e){return e.rtpSender})},n.prototype.getReceivers=function(){return this.transceivers.filter(function(e){return!!e.rtpReceiver}).map(function(e){return e.rtpReceiver})},n.prototype._createIceGatherer=function(t,i){var r=this;if(i&&t>0)return this.transceivers[0].iceGatherer;if(this._iceGatherers.length)return this._iceGatherers.shift();var n=new e.RTCIceGatherer({iceServers:this._config.iceServers,gatherPolicy:this._config.iceTransportPolicy});return Object.defineProperty(n,"state",{value:"new",writable:!0}),this.transceivers[t].bufferedCandidateEvents=[],this.transceivers[t].bufferCandidates=function(e){var i=!e.candidate||0===Object.keys(e.candidate).length;n.state=i?"completed":"gathering",null!==r.transceivers[t].bufferedCandidateEvents&&r.transceivers[t].bufferedCandidateEvents.push(e)},n.addEventListener("localcandidate",this.transceivers[t].bufferCandidates),n},n.prototype._gather=function(t,i){var r=this,n=this.transceivers[i].iceGatherer;if(!n.onlocalcandidate){var s=this.transceivers[i].bufferedCandidateEvents;this.transceivers[i].bufferedCandidateEvents=null,n.removeEventListener("localcandidate",this.transceivers[i].bufferCandidates),n.onlocalcandidate=function(e){if(!(r.usingBundle&&i>0)){var s=new Event("icecandidate");s.candidate={sdpMid:t,sdpMLineIndex:i};var o=e.candidate,a=!o||0===Object.keys(o).length;if(a)"new"!==n.state&&"gathering"!==n.state||(n.state="completed");else{"new"===n.state&&(n.state="gathering"),o.component=1,o.ufrag=n.getLocalParameters().usernameFragment;var l=Fe.writeCandidate(o);s.candidate=Object.assign(s.candidate,Fe.parseCandidate(l)),s.candidate.candidate=l,s.candidate.toJSON=function(){return{candidate:s.candidate.candidate,sdpMid:s.candidate.sdpMid,sdpMLineIndex:s.candidate.sdpMLineIndex,usernameFragment:s.candidate.usernameFragment}}}var _=Fe.getMediaSections(r._localDescription.sdp);_[s.candidate.sdpMLineIndex]+=a?"a=end-of-candidates\r\n":"a="+s.candidate.candidate+"\r\n",r._localDescription.sdp=Fe.getDescription(r._localDescription.sdp)+_.join("");var c=r.transceivers.every(function(e){return e.iceGatherer&&"completed"===e.iceGatherer.state});"gathering"!==r.iceGatheringState&&(r.iceGatheringState="gathering",r._emitGatheringStateChange()),a||r._dispatchEvent("icecandidate",s),c&&(r._dispatchEvent("icecandidate",new Event("icecandidate")),r.iceGatheringState="complete",r._emitGatheringStateChange())}},e.setTimeout(function(){s.forEach(function(e){n.onlocalcandidate(e)})},0)}},n.prototype._createIceAndDtlsTransports=function(){var t=this,i=new e.RTCIceTransport(null);i.onicestatechange=function(){t._updateIceConnectionState(),t._updateConnectionState()};var r=new e.RTCDtlsTransport(i);return r.ondtlsstatechange=function(){t._updateConnectionState()},r.onerror=function(){Object.defineProperty(r,"state",{value:"failed",writable:!0}),t._updateConnectionState()},{iceTransport:i,dtlsTransport:r}},n.prototype._disposeIceAndDtlsTransports=function(e){var t=this.transceivers[e].iceGatherer;t&&(delete t.onlocalcandidate,delete this.transceivers[e].iceGatherer);var i=this.transceivers[e].iceTransport;i&&(delete i.onicestatechange,delete this.transceivers[e].iceTransport);var r=this.transceivers[e].dtlsTransport;r&&(delete r.ondtlsstatechange,delete r.onerror,delete this.transceivers[e].dtlsTransport)},n.prototype._transceive=function(e,i,r){var n=He(e.localCapabilities,e.remoteCapabilities);i&&e.rtpSender&&(n.encodings=e.sendEncodingParameters,n.rtcp={cname:Fe.localCName,compound:e.rtcpParameters.compound},e.recvEncodingParameters.length&&(n.rtcp.ssrc=e.recvEncodingParameters[0].ssrc),e.rtpSender.send(n)),r&&e.rtpReceiver&&n.codecs.length>0&&("video"===e.kind&&e.recvEncodingParameters&&t<15019&&e.recvEncodingParameters.forEach(function(e){delete e.rtx}),e.recvEncodingParameters.length?n.encodings=e.recvEncodingParameters:n.encodings=[{}],n.rtcp={compound:e.rtcpParameters.compound},e.rtcpParameters.cname&&(n.rtcp.cname=e.rtcpParameters.cname),e.sendEncodingParameters.length&&(n.rtcp.ssrc=e.sendEncodingParameters[0].ssrc),e.rtpReceiver.receive(n))},n.prototype.setLocalDescription=function(e){var t,i,r=this;if(-1===["offer","answer"].indexOf(e.type))return Promise.reject(Ke("TypeError",'Unsupported type "'+e.type+'"'));if(!Je("setLocalDescription",e.type,r.signalingState)||r._isClosed)return Promise.reject(Ke("InvalidStateError","Can not set local "+e.type+" in state "+r.signalingState));if("offer"===e.type)t=Fe.splitSections(e.sdp),i=t.shift(),t.forEach(function(e,t){var i=Fe.parseRtpParameters(e);r.transceivers[t].localCapabilities=i}),r.transceivers.forEach(function(e,t){r._gather(e.mid,t)});else if("answer"===e.type){t=Fe.splitSections(r._remoteDescription.sdp),i=t.shift();var n=Fe.matchPrefix(i,"a=ice-lite").length>0;t.forEach(function(e,t){var s=r.transceivers[t],o=s.iceGatherer,a=s.iceTransport,l=s.dtlsTransport,_=s.localCapabilities,c=s.remoteCapabilities;if(!(Fe.isRejected(e)&&0===Fe.matchPrefix(e,"a=bundle-only").length)&&!s.rejected){var d=Fe.getIceParameters(e,i),u=Fe.getDtlsParameters(e,i);n&&(u.role="server"),r.usingBundle&&0!==t||(r._gather(s.mid,t),"new"===a.state&&a.start(o,d,n?"controlling":"controlled"),"new"===l.state&&l.start(u));var h=He(_,c);r._transceive(s,h.codecs.length>0,!1)}})}return r._localDescription={type:e.type,sdp:e.sdp},"offer"===e.type?r._updateSignalingState("have-local-offer"):r._updateSignalingState("stable"),Promise.resolve()},n.prototype.setRemoteDescription=function(n){var s=this;if(-1===["offer","answer"].indexOf(n.type))return Promise.reject(Ke("TypeError",'Unsupported type "'+n.type+'"'));if(!Je("setRemoteDescription",n.type,s.signalingState)||s._isClosed)return Promise.reject(Ke("InvalidStateError","Can not set remote "+n.type+" in state "+s.signalingState));var o={};s.remoteStreams.forEach(function(e){o[e.id]=e});var a=[],l=Fe.splitSections(n.sdp),_=l.shift(),c=Fe.matchPrefix(_,"a=ice-lite").length>0,d=Fe.matchPrefix(_,"a=group:BUNDLE ").length>0;s.usingBundle=d;var u=Fe.matchPrefix(_,"a=ice-options:")[0];return s.canTrickleIceCandidates=!!u&&u.substr(14).split(" ").indexOf("trickle")>=0,l.forEach(function(r,l){var u=Fe.splitLines(r),h=Fe.getKind(r),g=Fe.isRejected(r)&&0===Fe.matchPrefix(r,"a=bundle-only").length,p=u[0].substr(2).split(" ")[2],f=Fe.getDirection(r,_),E=Fe.parseMsid(r),T=Fe.getMid(r)||Fe.generateIdentifier();if(g||"application"===h&&("DTLS/SCTP"===p||"UDP/DTLS/SCTP"===p))s.transceivers[l]={mid:T,kind:h,protocol:p,rejected:!0};else{var m,I,R,S,C,L,O,v,b;!g&&s.transceivers[l]&&s.transceivers[l].rejected&&(s.transceivers[l]=s._createTransceiver(h,!0));var A,y,N=Fe.parseRtpParameters(r);g||(A=Fe.getIceParameters(r,_),(y=Fe.getDtlsParameters(r,_)).role="client"),O=Fe.parseRtpEncodingParameters(r);var P=Fe.parseRtcpParameters(r),U=Fe.matchPrefix(r,"a=end-of-candidates",_).length>0,D=Fe.matchPrefix(r,"a=candidate:").map(function(e){return Fe.parseCandidate(e)}).filter(function(e){return 1===e.component});if(("offer"===n.type||"answer"===n.type)&&!g&&d&&l>0&&s.transceivers[l]&&(s._disposeIceAndDtlsTransports(l),s.transceivers[l].iceGatherer=s.transceivers[0].iceGatherer,s.transceivers[l].iceTransport=s.transceivers[0].iceTransport,s.transceivers[l].dtlsTransport=s.transceivers[0].dtlsTransport,s.transceivers[l].rtpSender&&s.transceivers[l].rtpSender.setTransport(s.transceivers[0].dtlsTransport),s.transceivers[l].rtpReceiver&&s.transceivers[l].rtpReceiver.setTransport(s.transceivers[0].dtlsTransport)),"offer"!==n.type||g){if("answer"===n.type&&!g){I=(m=s.transceivers[l]).iceGatherer,R=m.iceTransport,S=m.dtlsTransport,C=m.rtpReceiver,L=m.sendEncodingParameters,v=m.localCapabilities,s.transceivers[l].recvEncodingParameters=O,s.transceivers[l].remoteCapabilities=N,s.transceivers[l].rtcpParameters=P,D.length&&"new"===R.state&&(!c&&!U||d&&0!==l?D.forEach(function(e){$e(m.iceTransport,e)}):R.setRemoteCandidates(D)),d&&0!==l||("new"===R.state&&R.start(I,A,"controlling"),"new"===S.state&&S.start(y)),!He(m.localCapabilities,m.remoteCapabilities).codecs.filter(function(e){return"rtx"===e.name.toLowerCase()}).length&&m.sendEncodingParameters[0].rtx&&delete m.sendEncodingParameters[0].rtx,s._transceive(m,"sendrecv"===f||"recvonly"===f,"sendrecv"===f||"sendonly"===f),!C||"sendrecv"!==f&&"sendonly"!==f?delete m.rtpReceiver:(b=C.track,E?(o[E.stream]||(o[E.stream]=new e.MediaStream),i(b,o[E.stream]),a.push([b,C,o[E.stream]])):(o.default||(o.default=new e.MediaStream),i(b,o.default),a.push([b,C,o.default])))}}else{(m=s.transceivers[l]||s._createTransceiver(h)).mid=T,m.iceGatherer||(m.iceGatherer=s._createIceGatherer(l,d)),D.length&&"new"===m.iceTransport.state&&(!U||d&&0!==l?D.forEach(function(e){$e(m.iceTransport,e)}):m.iceTransport.setRemoteCandidates(D)),v=e.RTCRtpReceiver.getCapabilities(h),t<15019&&(v.codecs=v.codecs.filter(function(e){return"rtx"!==e.name})),L=m.sendEncodingParameters||[{ssrc:1001*(2*l+2)}];var M,w=!1;if("sendrecv"===f||"sendonly"===f){if(w=!m.rtpReceiver,C=m.rtpReceiver||new e.RTCRtpReceiver(m.dtlsTransport,h),w)b=C.track,E&&"-"===E.stream||(E?(o[E.stream]||(o[E.stream]=new e.MediaStream,Object.defineProperty(o[E.stream],"id",{get:function(){return E.stream}})),Object.defineProperty(b,"id",{get:function(){return E.track}}),M=o[E.stream]):(o.default||(o.default=new e.MediaStream),M=o.default)),M&&(i(b,M),m.associatedRemoteMediaStreams.push(M)),a.push([b,C,M])}else m.rtpReceiver&&m.rtpReceiver.track&&(m.associatedRemoteMediaStreams.forEach(function(t){var i=t.getTracks().find(function(e){return e.id===m.rtpReceiver.track.id});i&&function(t,i){i.removeTrack(t),i.dispatchEvent(new e.MediaStreamTrackEvent("removetrack",{track:t}))}(i,t)}),m.associatedRemoteMediaStreams=[]);m.localCapabilities=v,m.remoteCapabilities=N,m.rtpReceiver=C,m.rtcpParameters=P,m.sendEncodingParameters=L,m.recvEncodingParameters=O,s._transceive(s.transceivers[l],!1,w)}}}),void 0===s._dtlsRole&&(s._dtlsRole="offer"===n.type?"active":"passive"),s._remoteDescription={type:n.type,sdp:n.sdp},"offer"===n.type?s._updateSignalingState("have-remote-offer"):s._updateSignalingState("stable"),Object.keys(o).forEach(function(t){var i=o[t];if(i.getTracks().length){if(-1===s.remoteStreams.indexOf(i)){s.remoteStreams.push(i);var n=new Event("addstream");n.stream=i,e.setTimeout(function(){s._dispatchEvent("addstream",n)})}a.forEach(function(e){var t=e[0],n=e[1];i.id===e[2].id&&r(s,t,n,[i])})}}),a.forEach(function(e){e[2]||r(s,e[0],e[1],[])}),e.setTimeout(function(){s&&s.transceivers&&s.transceivers.forEach(function(e){e.iceTransport&&"new"===e.iceTransport.state&&e.iceTransport.getRemoteCandidates().length>0&&(console.warn("Timeout for addRemoteCandidate. Consider sending an end-of-candidates notification"),e.iceTransport.addRemoteCandidate({}))})},4e3),Promise.resolve()},n.prototype.close=function(){this.transceivers.forEach(function(e){e.iceTransport&&e.iceTransport.stop(),e.dtlsTransport&&e.dtlsTransport.stop(),e.rtpSender&&e.rtpSender.stop(),e.rtpReceiver&&e.rtpReceiver.stop()}),this._isClosed=!0,this._updateSignalingState("closed")},n.prototype._updateSignalingState=function(e){this.signalingState=e;var t=new Event("signalingstatechange");this._dispatchEvent("signalingstatechange",t)},n.prototype._maybeFireNegotiationNeeded=function(){var t=this;"stable"===this.signalingState&&!0!==this.needNegotiation&&(this.needNegotiation=!0,e.setTimeout(function(){if(t.needNegotiation){t.needNegotiation=!1;var e=new Event("negotiationneeded");t._dispatchEvent("negotiationneeded",e)}},0))},n.prototype._updateIceConnectionState=function(){var e,t={new:0,closed:0,checking:0,connected:0,completed:0,disconnected:0,failed:0};if(this.transceivers.forEach(function(e){e.iceTransport&&!e.rejected&&t[e.iceTransport.state]++}),e="new",t.failed>0?e="failed":t.checking>0?e="checking":t.disconnected>0?e="disconnected":t.new>0?e="new":t.connected>0?e="connected":t.completed>0&&(e="completed"),e!==this.iceConnectionState){this.iceConnectionState=e;var i=new Event("iceconnectionstatechange");this._dispatchEvent("iceconnectionstatechange",i)}},n.prototype._updateConnectionState=function(){var e,t={new:0,closed:0,connecting:0,connected:0,completed:0,disconnected:0,failed:0};if(this.transceivers.forEach(function(e){e.iceTransport&&e.dtlsTransport&&!e.rejected&&(t[e.iceTransport.state]++,t[e.dtlsTransport.state]++)}),t.connected+=t.completed,e="new",t.failed>0?e="failed":t.connecting>0?e="connecting":t.disconnected>0?e="disconnected":t.new>0?e="new":t.connected>0&&(e="connected"),e!==this.connectionState){this.connectionState=e;var i=new Event("connectionstatechange");this._dispatchEvent("connectionstatechange",i)}},n.prototype.createOffer=function(){var i=this;if(i._isClosed)return Promise.reject(Ke("InvalidStateError","Can not call createOffer after close"));var r=i.transceivers.filter(function(e){return"audio"===e.kind}).length,n=i.transceivers.filter(function(e){return"video"===e.kind}).length,s=arguments[0];if(s){if(s.mandatory||s.optional)throw new TypeError("Legacy mandatory/optional constraints not supported.");void 0!==s.offerToReceiveAudio&&(r=!0===s.offerToReceiveAudio?1:!1===s.offerToReceiveAudio?0:s.offerToReceiveAudio),void 0!==s.offerToReceiveVideo&&(n=!0===s.offerToReceiveVideo?1:!1===s.offerToReceiveVideo?0:s.offerToReceiveVideo)}for(i.transceivers.forEach(function(e){"audio"===e.kind?--r<0&&(e.wantReceive=!1):"video"===e.kind&&--n<0&&(e.wantReceive=!1)});r>0||n>0;)r>0&&(i._createTransceiver("audio"),r--),n>0&&(i._createTransceiver("video"),n--);var o=Fe.writeSessionBoilerplate(i._sdpSessionId,i._sdpSessionVersion++);i.transceivers.forEach(function(r,n){var s=r.track,o=r.kind,a=r.mid||Fe.generateIdentifier();r.mid=a,r.iceGatherer||(r.iceGatherer=i._createIceGatherer(n,i.usingBundle));var l=e.RTCRtpSender.getCapabilities(o);t<15019&&(l.codecs=l.codecs.filter(function(e){return"rtx"!==e.name})),l.codecs.forEach(function(e){"H264"===e.name&&void 0===e.parameters["level-asymmetry-allowed"]&&(e.parameters["level-asymmetry-allowed"]="1"),r.remoteCapabilities&&r.remoteCapabilities.codecs&&r.remoteCapabilities.codecs.forEach(function(t){e.name.toLowerCase()===t.name.toLowerCase()&&e.clockRate===t.clockRate&&(e.preferredPayloadType=t.payloadType)})}),l.headerExtensions.forEach(function(e){(r.remoteCapabilities&&r.remoteCapabilities.headerExtensions||[]).forEach(function(t){e.uri===t.uri&&(e.id=t.id)})});var _=r.sendEncodingParameters||[{ssrc:1001*(2*n+1)}];s&&t>=15019&&"video"===o&&!_[0].rtx&&(_[0].rtx={ssrc:_[0].ssrc+1}),r.wantReceive&&(r.rtpReceiver=new e.RTCRtpReceiver(r.dtlsTransport,o)),r.localCapabilities=l,r.sendEncodingParameters=_}),"max-compat"!==i._config.bundlePolicy&&(o+="a=group:BUNDLE "+i.transceivers.map(function(e){return e.mid}).join(" ")+"\r\n"),o+="a=ice-options:trickle\r\n",i.transceivers.forEach(function(e,t){o+=je(e,e.localCapabilities,"offer",e.stream,i._dtlsRole),o+="a=rtcp-rsize\r\n",!e.iceGatherer||"new"===i.iceGatheringState||0!==t&&i.usingBundle||(e.iceGatherer.getLocalCandidates().forEach(function(e){e.component=1,o+="a="+Fe.writeCandidate(e)+"\r\n"}),"completed"===e.iceGatherer.state&&(o+="a=end-of-candidates\r\n"))});var a=new e.RTCSessionDescription({type:"offer",sdp:o});return Promise.resolve(a)},n.prototype.createAnswer=function(){var i=this;if(i._isClosed)return Promise.reject(Ke("InvalidStateError","Can not call createAnswer after close"));if("have-remote-offer"!==i.signalingState&&"have-local-pranswer"!==i.signalingState)return Promise.reject(Ke("InvalidStateError","Can not call createAnswer in signalingState "+i.signalingState));var r=Fe.writeSessionBoilerplate(i._sdpSessionId,i._sdpSessionVersion++);i.usingBundle&&(r+="a=group:BUNDLE "+i.transceivers.map(function(e){return e.mid}).join(" ")+"\r\n"),r+="a=ice-options:trickle\r\n";var n=Fe.getMediaSections(i._remoteDescription.sdp).length;i.transceivers.forEach(function(e,s){if(!(s+1>n)){if(e.rejected)return"application"===e.kind?"DTLS/SCTP"===e.protocol?r+="m=application 0 DTLS/SCTP 5000\r\n":r+="m=application 0 "+e.protocol+" webrtc-datachannel\r\n":"audio"===e.kind?r+="m=audio 0 UDP/TLS/RTP/SAVPF 0\r\na=rtpmap:0 PCMU/8000\r\n":"video"===e.kind&&(r+="m=video 0 UDP/TLS/RTP/SAVPF 120\r\na=rtpmap:120 VP8/90000\r\n"),void(r+="c=IN IP4 0.0.0.0\r\na=inactive\r\na=mid:"+e.mid+"\r\n");var o;if(e.stream)"audio"===e.kind?o=e.stream.getAudioTracks()[0]:"video"===e.kind&&(o=e.stream.getVideoTracks()[0]),o&&t>=15019&&"video"===e.kind&&!e.sendEncodingParameters[0].rtx&&(e.sendEncodingParameters[0].rtx={ssrc:e.sendEncodingParameters[0].ssrc+1});var a=He(e.localCapabilities,e.remoteCapabilities);!a.codecs.filter(function(e){return"rtx"===e.name.toLowerCase()}).length&&e.sendEncodingParameters[0].rtx&&delete e.sendEncodingParameters[0].rtx,r+=je(e,a,"answer",e.stream,i._dtlsRole),e.rtcpParameters&&e.rtcpParameters.reducedSize&&(r+="a=rtcp-rsize\r\n")}});var s=new e.RTCSessionDescription({type:"answer",sdp:r});return Promise.resolve(s)},n.prototype.addIceCandidate=function(e){var t,i=this;return e&&void 0===e.sdpMLineIndex&&!e.sdpMid?Promise.reject(new TypeError("sdpMLineIndex or sdpMid required")):new Promise(function(r,n){if(!i._remoteDescription)return n(Ke("InvalidStateError","Can not add ICE candidate without a remote description"));if(e&&""!==e.candidate){var s=e.sdpMLineIndex;if(e.sdpMid)for(var o=0;o<i.transceivers.length;o++)if(i.transceivers[o].mid===e.sdpMid){s=o;break}var a=i.transceivers[s];if(!a)return n(Ke("OperationError","Can not add ICE candidate"));if(a.rejected)return r();var l=Object.keys(e.candidate).length>0?Fe.parseCandidate(e.candidate):{};if("tcp"===l.protocol&&(0===l.port||9===l.port))return r();if(l.component&&1!==l.component)return r();if((0===s||s>0&&a.iceTransport!==i.transceivers[0].iceTransport)&&!$e(a.iceTransport,l))return n(Ke("OperationError","Can not add ICE candidate"));var _=e.candidate.trim();0===_.indexOf("a=")&&(_=_.substr(2)),(t=Fe.getMediaSections(i._remoteDescription.sdp))[s]+="a="+(l.type?_:"end-of-candidates")+"\r\n",i._remoteDescription.sdp=Fe.getDescription(i._remoteDescription.sdp)+t.join("")}else for(var c=0;c<i.transceivers.length&&(i.transceivers[c].rejected||(i.transceivers[c].iceTransport.addRemoteCandidate({}),(t=Fe.getMediaSections(i._remoteDescription.sdp))[c]+="a=end-of-candidates\r\n",i._remoteDescription.sdp=Fe.getDescription(i._remoteDescription.sdp)+t.join(""),!i.usingBundle));c++);r()})},n.prototype.getStats=function(t){if(t&&t instanceof e.MediaStreamTrack){var i=null;if(this.transceivers.forEach(function(e){e.rtpSender&&e.rtpSender.track===t?i=e.rtpSender:e.rtpReceiver&&e.rtpReceiver.track===t&&(i=e.rtpReceiver)}),!i)throw Ke("InvalidAccessError","Invalid selector.");return i.getStats()}var r=[];return this.transceivers.forEach(function(e){["rtpSender","rtpReceiver","iceGatherer","iceTransport","dtlsTransport"].forEach(function(t){e[t]&&r.push(e[t].getStats())})}),Promise.all(r).then(function(e){var t=new Map;return e.forEach(function(e){e.forEach(function(e){t.set(e.id,e)})}),t})};["RTCRtpSender","RTCRtpReceiver","RTCIceGatherer","RTCIceTransport","RTCDtlsTransport"].forEach(function(t){var i=e[t];if(i&&i.prototype&&i.prototype.getStats){var r=i.prototype.getStats;i.prototype.getStats=function(){return r.apply(this).then(function(e){var t=new Map;return Object.keys(e).forEach(function(i){var r;e[i].type={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[(r=e[i]).type]||r.type,t.set(i,e[i])}),t})}}});var s=["createOffer","createAnswer"];return s.forEach(function(e){var t=n.prototype[e];n.prototype[e]=function(){var e=arguments;return"function"==typeof e[0]||"function"==typeof e[1]?t.apply(this,[arguments[2]]).then(function(t){"function"==typeof e[0]&&e[0].apply(null,[t])},function(t){"function"==typeof e[1]&&e[1].apply(null,[t])}):t.apply(this,arguments)}}),(s=["setLocalDescription","setRemoteDescription","addIceCandidate"]).forEach(function(e){var t=n.prototype[e];n.prototype[e]=function(){var e=arguments;return"function"==typeof e[1]||"function"==typeof e[2]?t.apply(this,arguments).then(function(){"function"==typeof e[1]&&e[1].apply(null)},function(t){"function"==typeof e[2]&&e[2].apply(null,[t])}):t.apply(this,arguments)}}),["getStats"].forEach(function(e){var t=n.prototype[e];n.prototype[e]=function(){var e=arguments;return"function"==typeof e[1]?t.apply(this,arguments).then(function(){"function"==typeof e[1]&&e[1].apply(null)}):t.apply(this,arguments)}}),n};function qe(e){const t=e&&e.navigator,i=t.mediaDevices.getUserMedia.bind(t.mediaDevices);t.mediaDevices.getUserMedia=function(e){return i(e).catch(e=>Promise.reject(function(e){return{name:{PermissionDeniedError:"NotAllowedError"}[e.name]||e.name,message:e.message,constraint:e.constraint,toString(){return this.name}}}(e)))}}function We(e){"getDisplayMedia"in e.navigator&&e.navigator.mediaDevices&&(e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||(e.navigator.mediaDevices.getDisplayMedia=e.navigator.getDisplayMedia.bind(e.navigator)))}function ze(e,t){if(e.RTCIceGatherer&&(e.RTCIceCandidate||(e.RTCIceCandidate=function(e){return e}),e.RTCSessionDescription||(e.RTCSessionDescription=function(e){return e}),t.version<15025)){const t=Object.getOwnPropertyDescriptor(e.MediaStreamTrack.prototype,"enabled");Object.defineProperty(e.MediaStreamTrack.prototype,"enabled",{set(e){t.set.call(this,e);const i=new Event("enabled");i.enabled=e,this.dispatchEvent(i)}})}e.RTCRtpSender&&!("dtmf"in e.RTCRtpSender.prototype)&&Object.defineProperty(e.RTCRtpSender.prototype,"dtmf",{get(){return void 0===this._dtmf&&("audio"===this.track.kind?this._dtmf=new e.RTCDtmfSender(this):"video"===this.track.kind&&(this._dtmf=null)),this._dtmf}}),e.RTCDtmfSender&&!e.RTCDTMFSender&&(e.RTCDTMFSender=e.RTCDtmfSender);const i=Ye(e,t.version);e.RTCPeerConnection=function(e){return e&&e.iceServers&&(e.iceServers=function(e){let t=!1;return(e=JSON.parse(JSON.stringify(e))).filter(e=>{if(e&&(e.urls||e.url)){let i=e.urls||e.url;e.url&&!e.urls&&Se("RTCIceServer.url","RTCIceServer.urls");const r="string"==typeof i;return r&&(i=[i]),i=i.filter(e=>{if(0===e.indexOf("stun:"))return!1;const i=e.startsWith("turn")&&!e.startsWith("turn:[")&&e.includes("transport=udp");return i&&!t?(t=!0,!0):i&&!t}),delete e.url,e.urls=r?i[0]:i,!!i.length}})}(e.iceServers,t.version),Re("ICE servers after filtering:",e.iceServers)),new i(e)},e.RTCPeerConnection.prototype=i.prototype}function Qe(e){e.RTCRtpSender&&!("replaceTrack"in e.RTCRtpSender.prototype)&&(e.RTCRtpSender.prototype.replaceTrack=e.RTCRtpSender.prototype.setTrack)}var Ze=Object.freeze({__proto__:null,shimPeerConnection:ze,shimReplaceTrack:Qe,shimGetUserMedia:qe,shimGetDisplayMedia:We});function Xe(e,t){const i=e&&e.navigator,r=e&&e.MediaStreamTrack;if(i.getUserMedia=function(e,t,r){Se("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),i.mediaDevices.getUserMedia(e).then(t,r)},!(t.version>55&&"autoGainControl"in i.mediaDevices.getSupportedConstraints())){const e=function(e,t,i){t in e&&!(i in e)&&(e[i]=e[t],delete e[t])},t=i.mediaDevices.getUserMedia.bind(i.mediaDevices);if(i.mediaDevices.getUserMedia=function(i){return"object"==typeof i&&"object"==typeof i.audio&&(i=JSON.parse(JSON.stringify(i)),e(i.audio,"autoGainControl","mozAutoGainControl"),e(i.audio,"noiseSuppression","mozNoiseSuppression")),t(i)},r&&r.prototype.getSettings){const t=r.prototype.getSettings;r.prototype.getSettings=function(){const i=t.apply(this,arguments);return e(i,"mozAutoGainControl","autoGainControl"),e(i,"mozNoiseSuppression","noiseSuppression"),i}}if(r&&r.prototype.applyConstraints){const t=r.prototype.applyConstraints;r.prototype.applyConstraints=function(i){return"audio"===this.kind&&"object"==typeof i&&(i=JSON.parse(JSON.stringify(i)),e(i,"autoGainControl","mozAutoGainControl"),e(i,"noiseSuppression","mozNoiseSuppression")),t.apply(this,[i])}}}}function et(e){"object"==typeof e&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&Object.defineProperty(e.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function tt(e,t){if("object"!=typeof e||!e.RTCPeerConnection&&!e.mozRTCPeerConnection)return;!e.RTCPeerConnection&&e.mozRTCPeerConnection&&(e.RTCPeerConnection=e.mozRTCPeerConnection),t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(t){const i=e.RTCPeerConnection.prototype[t],r={[t](){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),i.apply(this,arguments)}};e.RTCPeerConnection.prototype[t]=r[t]});const i={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"},r=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){const[e,n,s]=arguments;return r.apply(this,[e||null]).then(e=>{if(t.version<53&&!n)try{e.forEach(e=>{e.type=i[e.type]||e.type})}catch(t){if("TypeError"!==t.name)throw t;e.forEach((t,r)=>{e.set(r,Object.assign({},t,{type:i[t.type]||t.type}))})}return e}).then(n,s)}}function it(e){if("object"!=typeof e||!e.RTCPeerConnection||!e.RTCRtpSender)return;if(e.RTCRtpSender&&"getStats"in e.RTCRtpSender.prototype)return;const t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){const e=t.apply(this,[]);return e.forEach(e=>e._pc=this),e});const i=e.RTCPeerConnection.prototype.addTrack;i&&(e.RTCPeerConnection.prototype.addTrack=function(){const e=i.apply(this,arguments);return e._pc=this,e}),e.RTCRtpSender.prototype.getStats=function(){return this.track?this._pc.getStats(this.track):Promise.resolve(new Map)}}function rt(e){if("object"!=typeof e||!e.RTCPeerConnection||!e.RTCRtpSender)return;if(e.RTCRtpSender&&"getStats"in e.RTCRtpReceiver.prototype)return;const t=e.RTCPeerConnection.prototype.getReceivers;t&&(e.RTCPeerConnection.prototype.getReceivers=function(){const e=t.apply(this,[]);return e.forEach(e=>e._pc=this),e}),Te(e,"track",e=>(e.receiver._pc=e.srcElement,e)),e.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}function nt(e){e.RTCPeerConnection&&!("removeStream"in e.RTCPeerConnection.prototype)&&(e.RTCPeerConnection.prototype.removeStream=function(e){Se("removeStream","removeTrack"),this.getSenders().forEach(t=>{t.track&&e.getTracks().includes(t.track)&&this.removeTrack(t)})})}function st(e){e.DataChannel&&!e.RTCDataChannel&&(e.RTCDataChannel=e.DataChannel)}function ot(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype.addTransceiver;t&&(e.RTCPeerConnection.prototype.addTransceiver=function(){this.setParametersPromises=[];const e=arguments[1],i=e&&"sendEncodings"in e;i&&e.sendEncodings.forEach(e=>{if("rid"in e){if(!/^[a-z0-9]{0,16}$/i.test(e.rid))throw new TypeError("Invalid RID value provided.")}if("scaleResolutionDownBy"in e&&!(parseFloat(e.scaleResolutionDownBy)>=1))throw new RangeError("scale_resolution_down_by must be >= 1.0");if("maxFramerate"in e&&!(parseFloat(e.maxFramerate)>=0))throw new RangeError("max_framerate must be >= 0.0")});const r=t.apply(this,arguments);if(i){const{sender:t}=r,i=t.getParameters();(!("encodings"in i)||1===i.encodings.length&&0===Object.keys(i.encodings[0]).length)&&(i.encodings=e.sendEncodings,t.sendEncodings=e.sendEncodings,this.setParametersPromises.push(t.setParameters(i).then(()=>{delete t.sendEncodings}).catch(()=>{delete t.sendEncodings})))}return r})}function at(e){if("object"!=typeof e||!e.RTCRtpSender)return;const t=e.RTCRtpSender.prototype.getParameters;t&&(e.RTCRtpSender.prototype.getParameters=function(){const e=t.apply(this,arguments);return"encodings"in e||(e.encodings=[].concat(this.sendEncodings||[{}])),e})}function lt(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(()=>t.apply(this,arguments)).finally(()=>{this.setParametersPromises=[]}):t.apply(this,arguments)}}function _t(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype.createAnswer;e.RTCPeerConnection.prototype.createAnswer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(()=>t.apply(this,arguments)).finally(()=>{this.setParametersPromises=[]}):t.apply(this,arguments)}}var ct=Object.freeze({__proto__:null,shimOnTrack:et,shimPeerConnection:tt,shimSenderGetStats:it,shimReceiverGetStats:rt,shimRemoveStream:nt,shimRTCDataChannel:st,shimAddTransceiver:ot,shimGetParameters:at,shimCreateOffer:lt,shimCreateAnswer:_t,shimGetUserMedia:Xe,shimGetDisplayMedia:function(e,t){e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||e.navigator.mediaDevices&&(e.navigator.mediaDevices.getDisplayMedia=function(i){if(!i||!i.video){const e=new DOMException("getDisplayMedia without video constraints is undefined");return e.name="NotFoundError",e.code=8,Promise.reject(e)}return!0===i.video?i.video={mediaSource:t}:i.video.mediaSource=t,e.navigator.mediaDevices.getUserMedia(i)})}});function dt(e){if("object"==typeof e&&e.RTCPeerConnection){if("getLocalStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getLocalStreams=function(){return this._localStreams||(this._localStreams=[]),this._localStreams}),!("addStream"in e.RTCPeerConnection.prototype)){const t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addStream=function(e){this._localStreams||(this._localStreams=[]),this._localStreams.includes(e)||this._localStreams.push(e),e.getAudioTracks().forEach(i=>t.call(this,i,e)),e.getVideoTracks().forEach(i=>t.call(this,i,e))},e.RTCPeerConnection.prototype.addTrack=function(e,...i){return i&&i.forEach(e=>{this._localStreams?this._localStreams.includes(e)||this._localStreams.push(e):this._localStreams=[e]}),t.apply(this,arguments)}}"removeStream"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.removeStream=function(e){this._localStreams||(this._localStreams=[]);const t=this._localStreams.indexOf(e);if(-1===t)return;this._localStreams.splice(t,1);const i=e.getTracks();this.getSenders().forEach(e=>{i.includes(e.track)&&this.removeTrack(e)})})}}function ut(e){if("object"==typeof e&&e.RTCPeerConnection&&("getRemoteStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getRemoteStreams=function(){return this._remoteStreams?this._remoteStreams:[]}),!("onaddstream"in e.RTCPeerConnection.prototype))){Object.defineProperty(e.RTCPeerConnection.prototype,"onaddstream",{get(){return this._onaddstream},set(e){this._onaddstream&&(this.removeEventListener("addstream",this._onaddstream),this.removeEventListener("track",this._onaddstreampoly)),this.addEventListener("addstream",this._onaddstream=e),this.addEventListener("track",this._onaddstreampoly=e=>{e.streams.forEach(e=>{if(this._remoteStreams||(this._remoteStreams=[]),this._remoteStreams.includes(e))return;this._remoteStreams.push(e);const t=new Event("addstream");t.stream=e,this.dispatchEvent(t)})})}});const t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){const e=this;return this._onaddstreampoly||this.addEventListener("track",this._onaddstreampoly=function(t){t.streams.forEach(t=>{if(e._remoteStreams||(e._remoteStreams=[]),e._remoteStreams.indexOf(t)>=0)return;e._remoteStreams.push(t);const i=new Event("addstream");i.stream=t,e.dispatchEvent(i)})}),t.apply(e,arguments)}}}function ht(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype,i=t.createOffer,r=t.createAnswer,n=t.setLocalDescription,s=t.setRemoteDescription,o=t.addIceCandidate;t.createOffer=function(e,t){const r=arguments.length>=2?arguments[2]:arguments[0],n=i.apply(this,[r]);return t?(n.then(e,t),Promise.resolve()):n},t.createAnswer=function(e,t){const i=arguments.length>=2?arguments[2]:arguments[0],n=r.apply(this,[i]);return t?(n.then(e,t),Promise.resolve()):n};let a=function(e,t,i){const r=n.apply(this,[e]);return i?(r.then(t,i),Promise.resolve()):r};t.setLocalDescription=a,a=function(e,t,i){const r=s.apply(this,[e]);return i?(r.then(t,i),Promise.resolve()):r},t.setRemoteDescription=a,a=function(e,t,i){const r=o.apply(this,[e]);return i?(r.then(t,i),Promise.resolve()):r},t.addIceCandidate=a}function gt(e){const t=e&&e.navigator;if(t.mediaDevices&&t.mediaDevices.getUserMedia){const e=t.mediaDevices,i=e.getUserMedia.bind(e);t.mediaDevices.getUserMedia=e=>i(pt(e))}!t.getUserMedia&&t.mediaDevices&&t.mediaDevices.getUserMedia&&(t.getUserMedia=function(e,i,r){t.mediaDevices.getUserMedia(e).then(i,r)}.bind(t))}function pt(e){return e&&void 0!==e.video?Object.assign({},e,{video:Le(e.video)}):e}function ft(e){if(!e.RTCPeerConnection)return;const t=e.RTCPeerConnection;e.RTCPeerConnection=function(e,i){if(e&&e.iceServers){const t=[];for(let i=0;i<e.iceServers.length;i++){let r=e.iceServers[i];!r.hasOwnProperty("urls")&&r.hasOwnProperty("url")?(Se("RTCIceServer.url","RTCIceServer.urls"),r=JSON.parse(JSON.stringify(r)),r.urls=r.url,delete r.url,t.push(r)):t.push(e.iceServers[i])}e.iceServers=t}return new t(e,i)},e.RTCPeerConnection.prototype=t.prototype,"generateCertificate"in t&&Object.defineProperty(e.RTCPeerConnection,"generateCertificate",{get:()=>t.generateCertificate})}function Et(e){"object"==typeof e&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&Object.defineProperty(e.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function Tt(e){const t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(e){if(e){void 0!==e.offerToReceiveAudio&&(e.offerToReceiveAudio=!!e.offerToReceiveAudio);const t=this.getTransceivers().find(e=>"audio"===e.receiver.track.kind);!1===e.offerToReceiveAudio&&t?"sendrecv"===t.direction?t.setDirection?t.setDirection("sendonly"):t.direction="sendonly":"recvonly"===t.direction&&(t.setDirection?t.setDirection("inactive"):t.direction="inactive"):!0!==e.offerToReceiveAudio||t||this.addTransceiver("audio"),void 0!==e.offerToReceiveVideo&&(e.offerToReceiveVideo=!!e.offerToReceiveVideo);const i=this.getTransceivers().find(e=>"video"===e.receiver.track.kind);!1===e.offerToReceiveVideo&&i?"sendrecv"===i.direction?i.setDirection?i.setDirection("sendonly"):i.direction="sendonly":"recvonly"===i.direction&&(i.setDirection?i.setDirection("inactive"):i.direction="inactive"):!0!==e.offerToReceiveVideo||i||this.addTransceiver("video")}return t.apply(this,arguments)}}function mt(e){"object"!=typeof e||e.AudioContext||(e.AudioContext=e.webkitAudioContext)}var It=Object.freeze({__proto__:null,shimLocalStreamsAPI:dt,shimRemoteStreamsAPI:ut,shimCallbacksAPI:ht,shimGetUserMedia:gt,shimConstraints:pt,shimRTCIceServerUrls:ft,shimTrackEventTransceiver:Et,shimCreateOfferLegacy:Tt,shimAudioContext:mt});function Rt(e){if(!e.RTCIceCandidate||e.RTCIceCandidate&&"foundation"in e.RTCIceCandidate.prototype)return;const t=e.RTCIceCandidate;e.RTCIceCandidate=function(e){if("object"==typeof e&&e.candidate&&0===e.candidate.indexOf("a=")&&((e=JSON.parse(JSON.stringify(e))).candidate=e.candidate.substr(2)),e.candidate&&e.candidate.length){const i=new t(e),r=Fe.parseCandidate(e.candidate),n=Object.assign(i,r);return n.toJSON=function(){return{candidate:n.candidate,sdpMid:n.sdpMid,sdpMLineIndex:n.sdpMLineIndex,usernameFragment:n.usernameFragment}},n}return new t(e)},e.RTCIceCandidate.prototype=t.prototype,Te(e,"icecandidate",t=>(t.candidate&&Object.defineProperty(t,"candidate",{value:new e.RTCIceCandidate(t.candidate),writable:"false"}),t))}function St(e,t){if(!e.RTCPeerConnection)return;"sctp"in e.RTCPeerConnection.prototype||Object.defineProperty(e.RTCPeerConnection.prototype,"sctp",{get(){return void 0===this._sctp?null:this._sctp}});const i=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){if(this._sctp=null,"chrome"===t.browser&&t.version>=76){const{sdpSemantics:e}=this.getConfiguration();"plan-b"===e&&Object.defineProperty(this,"sctp",{get(){return void 0===this._sctp?null:this._sctp},enumerable:!0,configurable:!0})}if(function(e){if(!e||!e.sdp)return!1;const t=Fe.splitSections(e.sdp);return t.shift(),t.some(e=>{const t=Fe.parseMLine(e);return t&&"application"===t.kind&&-1!==t.protocol.indexOf("SCTP")})}(arguments[0])){const e=function(e){const t=e.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);if(null===t||t.length<2)return-1;const i=parseInt(t[1],10);return i!=i?-1:i}(arguments[0]),i=function(e){let i=65536;return"firefox"===t.browser&&(i=t.version<57?-1===e?16384:2147483637:t.version<60?57===t.version?65535:65536:2147483637),i}(e),r=function(e,i){let r=65536;"firefox"===t.browser&&57===t.version&&(r=65535);const n=Fe.matchPrefix(e.sdp,"a=max-message-size:");return n.length>0?r=parseInt(n[0].substr(19),10):"firefox"===t.browser&&-1!==i&&(r=2147483637),r}(arguments[0],e);let n;n=0===i&&0===r?Number.POSITIVE_INFINITY:0===i||0===r?Math.max(i,r):Math.min(i,r);const s={};Object.defineProperty(s,"maxMessageSize",{get:()=>n}),this._sctp=s}return i.apply(this,arguments)}}function Ct(e){if(!e.RTCPeerConnection||!("createDataChannel"in e.RTCPeerConnection.prototype))return;function t(e,t){const i=e.send;e.send=function(){const r=arguments[0],n=r.length||r.size||r.byteLength;if("open"===e.readyState&&t.sctp&&n>t.sctp.maxMessageSize)throw new TypeError("Message too large (can send a maximum of "+t.sctp.maxMessageSize+" bytes)");return i.apply(e,arguments)}}const i=e.RTCPeerConnection.prototype.createDataChannel;e.RTCPeerConnection.prototype.createDataChannel=function(){const e=i.apply(this,arguments);return t(e,this),e},Te(e,"datachannel",e=>(t(e.channel,e.target),e))}function Lt(e){if(!e.RTCPeerConnection||"connectionState"in e.RTCPeerConnection.prototype)return;const t=e.RTCPeerConnection.prototype;Object.defineProperty(t,"connectionState",{get(){return{completed:"connected",checking:"connecting"}[this.iceConnectionState]||this.iceConnectionState},enumerable:!0,configurable:!0}),Object.defineProperty(t,"onconnectionstatechange",{get(){return this._onconnectionstatechange||null},set(e){this._onconnectionstatechange&&(this.removeEventListener("connectionstatechange",this._onconnectionstatechange),delete this._onconnectionstatechange),e&&this.addEventListener("connectionstatechange",this._onconnectionstatechange=e)},enumerable:!0,configurable:!0}),["setLocalDescription","setRemoteDescription"].forEach(e=>{const i=t[e];t[e]=function(){return this._connectionstatechangepoly||(this._connectionstatechangepoly=e=>{const t=e.target;if(t._lastConnectionState!==t.connectionState){t._lastConnectionState=t.connectionState;const i=new Event("connectionstatechange",e);t.dispatchEvent(i)}return e},this.addEventListener("iceconnectionstatechange",this._connectionstatechangepoly)),i.apply(this,arguments)}})}function Ot(e,t){if(!e.RTCPeerConnection)return;if("chrome"===t.browser&&t.version>=71)return;if("safari"===t.browser&&t.version>=605)return;const i=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(t){if(t&&t.sdp&&-1!==t.sdp.indexOf("\na=extmap-allow-mixed")){const i=t.sdp.split("\n").filter(e=>"a=extmap-allow-mixed"!==e.trim()).join("\n");e.RTCSessionDescription&&t instanceof e.RTCSessionDescription?arguments[0]=new e.RTCSessionDescription({type:t.type,sdp:i}):t.sdp=i}return i.apply(this,arguments)}}function vt(e,t){if(!e.RTCPeerConnection||!e.RTCPeerConnection.prototype)return;const i=e.RTCPeerConnection.prototype.addIceCandidate;i&&0!==i.length&&(e.RTCPeerConnection.prototype.addIceCandidate=function(){return arguments[0]?("chrome"===t.browser&&t.version<78||"firefox"===t.browser&&t.version<68||"safari"===t.browser)&&arguments[0]&&""===arguments[0].candidate?Promise.resolve():i.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())})}var bt=Object.freeze({__proto__:null,shimRTCIceCandidate:Rt,shimMaxMessageSize:St,shimSendThrowTypeError:Ct,shimConnectionState:Lt,removeExtmapAllowMixed:Ot,shimAddIceCandidateNullOrEmpty:vt});const At=function({window:e}={},t={shimChrome:!0,shimFirefox:!0,shimEdge:!0,shimSafari:!0}){const i=Re,r=function(e){const t={browser:null,version:null};if(void 0===e||!e.navigator)return t.browser="Not a browser.",t;const{navigator:i}=e;if(i.mozGetUserMedia)t.browser="firefox",t.version=Ee(i.userAgent,/Firefox\/(\d+)\./,1);else if(i.webkitGetUserMedia||!1===e.isSecureContext&&e.webkitRTCPeerConnection&&!e.RTCIceGatherer)t.browser="chrome",t.version=Ee(i.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else if(i.mediaDevices&&i.userAgent.match(/Edge\/(\d+).(\d+)$/))t.browser="edge",t.version=Ee(i.userAgent,/Edge\/(\d+).(\d+)$/,2);else{if(!e.RTCPeerConnection||!i.userAgent.match(/AppleWebKit\/(\d+)\./))return t.browser="Not a supported browser.",t;t.browser="safari",t.version=Ee(i.userAgent,/AppleWebKit\/(\d+)\./,1),t.supportsUnifiedPlan=e.RTCRtpTransceiver&&"currentDirection"in e.RTCRtpTransceiver.prototype}return t}(e),n={browserDetails:r,commonShim:bt,extractVersion:Ee,disableLog:me,disableWarnings:Ie};switch(r.browser){case"chrome":if(!Be||!ke||!t.shimChrome)return i("Chrome shim is not included in this adapter release."),n;if(null===r.version)return i("Chrome shim can not determine version, not shimming."),n;i("adapter.js shimming chrome."),n.browserShim=Be,vt(e,r),Ae(e,r),ye(e),ke(e,r),Ne(e),we(e,r),Pe(e),Ue(e),De(e),xe(e,r),Rt(e),Lt(e),St(e,r),Ct(e),Ot(e,r);break;case"firefox":if(!ct||!tt||!t.shimFirefox)return i("Firefox shim is not included in this adapter release."),n;i("adapter.js shimming firefox."),n.browserShim=ct,vt(e,r),Xe(e,r),tt(e,r),et(e),nt(e),it(e),rt(e),st(e),ot(e),at(e),lt(e),_t(e),Rt(e),Lt(e),St(e,r),Ct(e);break;case"edge":if(!Ze||!ze||!t.shimEdge)return i("MS edge shim is not included in this adapter release."),n;i("adapter.js shimming edge."),n.browserShim=Ze,qe(e),We(e),ze(e,r),Qe(e),St(e,r),Ct(e);break;case"safari":if(!It||!t.shimSafari)return i("Safari shim is not included in this adapter release."),n;i("adapter.js shimming safari."),n.browserShim=It,vt(e,r),ft(e),Tt(e),ht(e),dt(e),ut(e),Et(e),gt(e),mt(e),Rt(e),St(e,r),Ct(e),Ot(e,r);break;default:i("Unsupported browser!")}return n}({window:"undefined"==typeof window?void 0:window});var yt,Nt,Pt;!function(e){e.FPS_10="FPS_10",e.FPS_15="FPS_15",e.FPS_24="FPS_24",e.FPS_30="FPS_30"}(yt||(yt={})),function(e){e.W176_H132="W176_H132",e.W176_H144="W176_H144",e.W180_H180="W180_H180",e.W240_H180="W240_H180",e.W240_H240="W240_H240",e.W256_H144="W256_H144",e.W320_H180="W320_H180",e.W320_H240="W320_H240",e.W360_H360="W360_H360",e.W480_H360="W480_H360",e.W480_H480="W480_H480",e.W640_H360="W640_H360",e.W640_H480="W640_H480",e.W720_H480="W720_H480",e.W848_H480="W848_H480",e.W960_H720="W960_H720",e.W1280_H720="W1280_H720",e.W1920_H1080="W1920_H1080",e.W144_H176="W144_H176",e.W144_H256="W144_H256",e.W180_H240="W180_H240",e.W180_H320="W180_H320",e.W240_H320="W240_H320",e.W360_H480="W360_H480",e.W360_H640="W360_H640",e.W480_H640="W480_H640",e.W480_H720="W480_H720",e.W480_H848="W480_H848",e.W720_H1280="W720_H1280",e.W720_H960="W720_H960",e.W1080_H1920="W1080_H1920"}(Nt||(Nt={})),function(e){e[e.AUDIO_ONLY=0]="AUDIO_ONLY",e[e.VIDEO_ONLY=1]="VIDEO_ONLY",e[e.AUDIO_VIDEO=2]="AUDIO_VIDEO"}(Pt||(Pt={}));const Ut={[Nt.W176_H132]:{width:176,height:132,maxBitrate:150,minBitrate:80},[Nt.W176_H144]:{width:176,height:144,maxBitrate:150,minBitrate:80},[Nt.W180_H180]:{width:180,height:180,maxBitrate:200,minBitrate:100},[Nt.W240_H180]:{width:240,height:180,maxBitrate:240,minBitrate:120},[Nt.W240_H240]:{width:240,height:240,maxBitrate:280,minBitrate:120},[Nt.W256_H144]:{width:256,height:144,maxBitrate:240,minBitrate:120},[Nt.W320_H180]:{width:320,height:180,maxBitrate:280,minBitrate:120},[Nt.W320_H240]:{width:320,height:240,maxBitrate:400,minBitrate:120},[Nt.W360_H360]:{width:360,height:360,maxBitrate:520,minBitrate:140},[Nt.W480_H360]:{width:480,height:360,maxBitrate:650,minBitrate:150},[Nt.W480_H480]:{width:480,height:480,maxBitrate:800,minBitrate:180},[Nt.W640_H360]:{width:640,height:360,maxBitrate:800,minBitrate:180},[Nt.W640_H480]:{width:640,height:480,maxBitrate:900,minBitrate:200},[Nt.W720_H480]:{width:720,height:480,maxBitrate:1e3,minBitrate:200},[Nt.W848_H480]:{width:848,height:480,maxBitrate:1860,minBitrate:200},[Nt.W960_H720]:{width:960,height:720,maxBitrate:2e3,minBitrate:250},[Nt.W1280_H720]:{width:1280,height:720,maxBitrate:2200,minBitrate:250},[Nt.W1920_H1080]:{width:1920,height:1080,maxBitrate:4e3,minBitrate:400},[Nt.W144_H176]:{width:144,height:176,maxBitrate:150,minBitrate:80},[Nt.W144_H256]:{width:144,height:256,maxBitrate:240,minBitrate:120},[Nt.W180_H240]:{width:180,height:240,maxBitrate:240,minBitrate:120},[Nt.W180_H320]:{width:180,height:320,maxBitrate:280,minBitrate:120},[Nt.W240_H320]:{width:240,height:320,maxBitrate:400,minBitrate:120},[Nt.W360_H480]:{width:360,height:480,maxBitrate:650,minBitrate:150},[Nt.W360_H640]:{width:360,height:640,maxBitrate:800,minBitrate:180},[Nt.W480_H640]:{width:480,height:640,maxBitrate:900,minBitrate:200},[Nt.W480_H720]:{width:480,height:720,maxBitrate:1e3,minBitrate:200},[Nt.W480_H848]:{width:480,height:848,maxBitrate:1860,minBitrate:930},[Nt.W720_H1280]:{width:720,height:1280,maxBitrate:2200,minBitrate:250},[Nt.W720_H960]:{width:720,height:960,maxBitrate:2760,minBitrate:910},[Nt.W1080_H1920]:{width:1080,height:1920,maxBitrate:4e3,minBitrate:400}},Dt=e=>{const t={192:180,368:360,1088:1080};return t[e]?t[e]:e},Mt=(e,t)=>{e=Dt(e),t=Dt(t);const i=Ut[`W${e}_H${t}`];if(i)return i;const r=e*t;return Object.keys(Ut).map(e=>Ut[e]).sort((e,t)=>e.height*e.width-t.width*t.height).filter(e=>e.height*e.width>=r)[0]||Ut.W1920_H1080},wt={10:1,15:1,24:1.5,30:1.5},kt=e=>{let t=Number.MAX_VALUE,i=1;for(const r in wt){const n=Math.abs(e-parseInt(r));n<t&&(t=n,i=wt[r])}return i},xt=()=>I(void 0,void 0,void 0,function*(){return(yield navigator.mediaDevices.enumerateDevices()).filter(e=>"videoinput"===e.kind)}),Bt=()=>I(void 0,void 0,void 0,function*(){return(yield navigator.mediaDevices.enumerateDevices()).filter(e=>"audioinput"===e.kind)}),Vt=()=>I(void 0,void 0,void 0,function*(){return(yield navigator.mediaDevices.enumerateDevices()).filter(e=>"audiooutput"===e.kind)});var Gt,Ft;!function(e){e.AUDIO="audio",e.VIDEO="video"}(Gt||(Gt={}));class jt extends B{constructor(e,t,i,r,n,s){super(),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_tag",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_userId",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_kind",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_isLocalTrack",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"_roomId",{enumerable:!0,configurable:!0,writable:!0,value:s}),Object.defineProperty(this,"_localMuted",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_remoteMuted",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_id",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_streamId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_msTrack",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_msStream",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"DataTrackId",{enumerable:!0,configurable:!0,writable:!0,value:"data-track-id"}),Object.defineProperty(this,"_element",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),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}get streamTrack(){return this._msTrack}getTag(){return this._tag}isLocalTrack(){return this._isLocalTrack}isVideoTrack(){return"video"===this._kind}isAudioTrack(){return"audio"===this._kind}isReady(){var e;return"live"===(null===(e=this._msTrack)||void 0===e?void 0:e.readyState)}__innerSetMediaStreamTrack(e){this._msTrack=e,this._setLocalMuted(this._localMuted);const t=this._msStream=this._msStream||new MediaStream,i=t.getTracks()[0];i&&t.removeTrack(i),this._isLocalTrack||this._logger.warn(he.L_INNER_SET_TRACK_O,`trackId: ${this._id}, track: ${e?e.id:"undefined"}`),e?t.addTrack(e):this._element&&this._element.getAttribute(this.DataTrackId)===this.getTrackId()&&(this._element.pause(),this._element.srcObject=null)}_setLocalMuted(e){return I(this,void 0,void 0,function*(){return this._msTrack&&(this._msTrack.enabled=!e),this._localMuted=e,ue.SUCCESS})}mute(){return I(this,void 0,void 0,function*(){return this._setLocalMuted(!0)})}unmute(){return I(this,void 0,void 0,function*(){return this._setLocalMuted(!1)})}isLocalMuted(){return this._localMuted}isMCUTrack(){return Boolean(this._roomId)}isOwnerMuted(){return this._remoteMuted}_validateVolume(e){if(null==e?void 0:e.volume){if(!O(null==e?void 0:e.volume))return this._logger.error(he.L_TRACK_PLAY_E,JSON.stringify({status:ge.FAILED,code:ue.PARAMS_ERROR,msg:"params error -> options.volume not a number"})),{code:ue.PARAMS_ERROR};(null==e?void 0:e.volume)<0&&(e.volume=0,this._logger.warn(he.L_TRACK_PLAY_E,JSON.stringify({status:ge.FAILED,msg:"params error -> options.volume < 0",tips:"the valid range of options.volume is 0-100, the value of volume has been set 0"}))),(null==e?void 0:e.volume)>100&&(e.volume=100,this._logger.warn(he.L_TRACK_PLAY_E,JSON.stringify({status:ge.FAILED,msg:"params error -> options.volume > 100",tips:"the valid range of options.volume is 0-100, the value of volume has been set 100"})))}}_validatePlayOptions(e,t){return I(this,void 0,void 0,function*(){if(!this._msTrack)return this._logger.error(he.L_TRACK_PLAY_E,JSON.stringify({status:ge.FAILED,code:ue.TRACK_NOT_READY,kind:this._kind,msg:`the track is not ready to play -> id: ${this._id}`})),{code:ue.TRACK_NOT_READY};"ended"===this._msTrack.readyState&&this._logger.warn(he.L_TRACK_PLAY_E,`track readyState is ended -> id: ${this._id}`);const i=this._validateVolume(t);if(i)return i;if(null==t?void 0:t.audioDeviceId){if(!(yield Vt()).map(e=>e.deviceId).includes(t.audioDeviceId))return this._logger.error(he.L_TRACK_PLAY_E,JSON.stringify({status:ge.FAILED,code:ue.PARAMS_ERROR,msg:"params error -> options.audioDeviceId"})),{code:ue.PARAMS_ERROR}}return!this.isVideoTrack()||e&&(e instanceof HTMLVideoElement||this._validateVideoNodeName(e))?void 0:(this._logger.error(he.L_TRACK_PLAY_E,JSON.stringify({status:ge.FAILED,code:ue.VIDEO_TRACK_MISS_MEDIA_ELEMENT,kind:this._kind,msg:"params element is not a HTMLVideoElement"})),{code:ue.VIDEO_TRACK_MISS_MEDIA_ELEMENT})})}_setPlayAttrs(e,t){return I(this,void 0,void 0,function*(){var i;e&&(this._element.playsInline=!0,this._element.x5PlaysInline=!0,this._element.webkitPlaysInline=!0),(null==t?void 0:t.audioDeviceId)&&!e&&(yield this._element.setSinkId(t.audioDeviceId)),e||!(null==t?void 0:t.volume)&&0!==(null==t?void 0:t.volume)||(this._element.volume=t.volume/100),null===(i=this._element)||void 0===i||i.setAttribute(this.DataTrackId,this.getTrackId())})}play(e,t){return I(this,void 0,void 0,function*(){this._logger.info(he.L_TRACK_PLAY_O,JSON.stringify({elementId:null==e?void 0:e.id,trackId:this._id,kind:this._kind,options:t?{volume:null==t?void 0:t.volume,audioDeviceId:t.audioDeviceId}:void 0}));const i=yield this._validatePlayOptions(e,t);if(i)return i;const r=this.isVideoTrack();return 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=e=>{var t;this._logger.info(he.L_TRACK_LOAD_START_O,JSON.stringify({status:ge.INFO,kind:this._kind,msg:`HTMLMediaElement onloadstart -> id: ${null===(t=e.target)||void 0===t?void 0:t.id}, trackId: ${this._id}`}))},this._element.ondurationchange=e=>{var t;this._logger.info(he.L_TRACK_DURATION_CHANGE_O,JSON.stringify({status:ge.INFO,kind:this._kind,msg:`HTMLMediaElement ondurationchange -> id: ${null===(t=e.target)||void 0===t?void 0:t.id}, trackId: ${this._id}`}))},this._element.onloadedmetadata=e=>{var t;this._logger.info(he.L_TRACK_LOADED_META_DATA_O,JSON.stringify({status:ge.INFO,kind:this._kind,msg:`HTMLMediaElement onloadedmetadata -> id: ${null===(t=e.target)||void 0===t?void 0:t.id}, trackId: ${this._id}`}))},this._element.onloadeddata=e=>{var t;this._logger.info(he.L_TRACK_LOADED_DATA_O,JSON.stringify({status:ge.INFO,kind:this._kind,msg:`HTMLMediaElement onloadeddata -> id: ${null===(t=e.target)||void 0===t?void 0:t.id}, trackId: ${this._id}`}))},this._element.onabort=e=>{var t;this._logger.info(he.L_TRACK_ABORT_O,JSON.stringify({status:ge.INFO,kind:this._kind,msg:`HTMLMediaElement onabort -> id: ${null===(t=e.target)||void 0===t?void 0:t.id}, trackId: ${this._id}`}))},this._element.oncanplay=e=>I(this,void 0,void 0,function*(){var i,n;this._logger.info(he.L_TRACK_CANPLAY_O,JSON.stringify({status:ge.INFO,kind:this._kind,msg:`HTMLMediaElement oncanplay -> id: ${null===(i=e.target)||void 0===i?void 0:i.id}, trackId: ${this._id}`}));try{(null==t?void 0:t.audioDeviceId)&&!r&&(yield this._element.setSinkId(t.audioDeviceId)),yield null===(n=this._element)||void 0===n?void 0:n.play()}catch(e){if("No permission to use requested device"===e.message)return void this._logger.error(he.L_TRACK_PLAY_E,JSON.stringify({status:ge.FAILED,kind:this._kind,code:ue.NO_PERMISSION_TO_USE_REQUESTED_DEVICE,msg:`setSinkId failed, error msg: ${e.message}`}));this._logger.error(he.L_TRACK_PLAY_E,JSON.stringify({status:ge.FAILED,code:ue.TRACK_PLAY_ERROR,kind:this._kind,msg:`play error, error msg: ${e.message}`}))}}),this._element.onvolumechange=e=>{var t,i;const r=Math.floor(100*(null===(t=e.target)||void 0===t?void 0:t.volume));this._logger.info(he.L_TRACK_VOLUME_CHANGE_O,JSON.stringify({status:ge.INFO,msg:`HTMLMediaElement onvolumechange -> id: ${null===(i=e.target)||void 0===i?void 0:i.id}, volume: ${r}, trackId: ${this._id}`}))},this._element.srcObject=this._msStream,this._element.autoplay=!0,yield this._setPlayAttrs(r,t),{code:ue.SUCCESS}})}__innerDestroy(){this.__innerSetMediaStreamTrack(void 0)}__releaseMediaElement(){this._element&&this._element.getAttribute(this.DataTrackId)===this.getTrackId()&&(this._element.remove(),this._element.srcObject=null)}_validateVideoNodeName(e){return e&&e.nodeName&&"VIDEO"===e.nodeName.toUpperCase()}}!function(e){e.Speech="Speech",e.Music="Music",e.MusicHigh="MusicHigh"}(Ft||(Ft={}));const Ht={[Ft.Music]:{max:64,min:64},[Ft.MusicHigh]:{max:128,min:128},[Ft.Speech]:{max:32,min:32}};var Jt;!function(e){e.LEVEL0="LEVEL0",e.LEVEL1="LEVEL1",e.LEVEL2="LEVEL2",e.LEVEL3="LEVEL3",e.LEVEL4="LEVEL4",e.LEVEL5="LEVEL5"}(Jt||(Jt={}));const $t={[Jt.LEVEL0]:{max:150,min:80},[Jt.LEVEL1]:{max:280,min:120},[Jt.LEVEL2]:{max:650,min:150},[Jt.LEVEL3]:{max:1e3,min:200},[Jt.LEVEL4]:{max:2200,min:250},[Jt.LEVEL5]:{max:4e3,min:400}};class Kt{static apply3ANoiseWorklet(e){return I(this,void 0,void 0,function*(){const t=new AudioContext({sampleRate:44100});let i;try{yield t.audioWorklet.addModule(Kt.SCRIPT_URL);const e=yield fetch(Kt.WASM_URL,{cache:"force-cache",credentials:"same-origin"});i=yield e.arrayBuffer()}catch(e){return{code:ue.LOAD_3A_MODULE_FAILED}}const r=t.createMediaStreamSource(new MediaStream([e])),n=new AudioWorkletNode(t,"process-worklet",{numberOfInputs:1,numberOfOutputs:1,outputChannelCount:[1],processorOptions:{binary:i}}),s=t.createMediaStreamDestination();r.connect(n).connect(s);const o=s.stream.getAudioTracks()[0];return Kt._maps.set(e.id,t),{code:ue.SUCCESS,track:o}})}static release3ANoiseWorklet(e){const t=Kt._maps.get(e.id);t&&(t.close(),Kt._maps.delete(e.id))}}Object.defineProperty(Kt,"WASM_URL",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(Kt,"SCRIPT_URL",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(Kt,"_maps",{enumerable:!0,configurable:!0,writable:!0,value:new Map});class Yt extends jt{constructor(e,t,i,r,n){super(e,t,i,r,!0),Object.defineProperty(this,"_isDestroyed",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_isPublished",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_bitrateInfo",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.__innerSetMediaStreamTrack(n),n.onended=()=>{n.onended=null,this._onTrackEnded()}}_onTrackEnded(){this.emit(Yt.EVENT_LOCAL_TRACK_END,this),this.removeAll(Yt.EVENT_LOCAL_TRACK_END)}_setLocalMuted(e){return new Promise(t=>{const i=this._localMuted!==e;super._setLocalMuted(e),this._remoteMuted=this._localMuted,i&&this._isPublished?this.emit(Yt.__INNER_EVENT_MUTED_CHANGE__,this,t):t(ue.SUCCESS),this._logger.info(he.L_LOCAL_TRACK_SET_LOCAL_MUTED_O,JSON.stringify({enable:e,trackId:this._id}))})}__innerSetPublished(e){this._isPublished=e}isPublished(){return this._isPublished}destroy(e=!0){var t;this._isDestroyed||(this._logger.info(he.L_LOCAL_TRACK_DESTROY_O,this._id),this._isDestroyed=!0,null===(t=this._msTrack)||void 0===t||t.stop(),super.__innerDestroy(),this.isAudioTrack()&&super.__releaseMediaElement(),this._isPublished&&e&&this.emit(Yt.__INNER_EVENT_DESTROY__,this))}isDestroyed(){return this._isDestroyed}setBitrate(e=0,t=0,i=0){!O(e)||!O(t)||!O(i)||e<=0||t<=0||e<t?this._logger.error(he.L_LOCAL_TRACK_SET_BITRATE_O,JSON.stringify({status:ge.FAILED,msg:`params error -> max: ${e},min: ${t}, start: ${i}`,trackId:this._id})):(this._logger.info(he.L_LOCAL_TRACK_SET_BITRATE_O,JSON.stringify({status:ge.SUCCESSED,max:e,min:t,start:i,trackId:this._id})),this._bitrateInfo={max:e,min:t,start:i})}getBitrate(){var e,t,i,r,n,s,o;let{min:a,max:l,start:_}={min:0,max:0,start:0};return(null===(e=this._msTrack)||void 0===e?void 0:e.kind)===Gt.VIDEO?({min:a,max:l}=ui(this._msTrack)):(null===(t=this._msTrack)||void 0===t?void 0:t.kind)===Gt.AUDIO&&({min:a,max:l}={min:32,max:32}),(null===(i=this._bitrateInfo)||void 0===i?void 0:i.max)&&(_=.7*(null===(r=this._bitrateInfo)||void 0===r?void 0:r.max)),{min:(null===(n=this._bitrateInfo)||void 0===n?void 0:n.min)||a,max:(null===(s=this._bitrateInfo)||void 0===s?void 0:s.max)||l,start:(null===(o=this._bitrateInfo)||void 0===o?void 0:o.start)||_}}getSettings(){var e;return null===(e=this._msTrack)||void 0===e?void 0:e.getSettings()}}Object.defineProperty(Yt,"EVENT_LOCAL_TRACK_END",{enumerable:!0,configurable:!0,writable:!0,value:"local-track-end"}),Object.defineProperty(Yt,"__INNER_EVENT_MUTED_CHANGE__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-muted-change"}),Object.defineProperty(Yt,"__INNER_EVENT_DESTROY__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-destroy"});class qt extends Yt{constructor(e,t,i,r){super(e,t,i,"audio",r)}setRecommendBitrate(e){if(!x("audioBitrate",e,e=>e in Ft))return void this._logger.warn(he.L_RTC_SET_RECOMMEND_BITRATE_O,JSON.stringify({status:ge.FAILED,msg:"params error -> params type is RCAudioBitrate"}));const t=Ht[e];this.setBitrate(t.max,t.min,t.start||.7*t.max)}setBitrate(e,...t){const[i=1,r=.7*e||1]=t;super.setBitrate(e,i,r)}}class Wt extends Yt{constructor(e,t,i,r,n=!1){super(e,t,i,"video",r),Object.defineProperty(this,"_isTiny",{enumerable:!0,configurable:!0,writable:!0,value:n})}__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}setRecommendBitrate(e){if(!x("videoBitrate",e,e=>e in Jt))return void this._logger.warn(he.L_RTC_SET_RECOMMEND_BITRATE_O,JSON.stringify({status:ge.FAILED,msg:"params error -> params type is RCVideoBitrate"}));const t=$t[e];this.setBitrate(t.max,t.min,t.start||.7*t.max)}setBitrate(e,...t){const[i=1,r=.7*e||1]=t;super.setBitrate(e,i,r)}}class zt extends Yt{static _innerSetMapping(e,t){const i=this._mapping.get(t)||[];i.push(e),this._mapping.set(t,i)}static _innerRemoveMapping(e,t){var i,r;const n=null===(i=this._mapping.get(t))||void 0===i?void 0:i.filter(t=>t!==e);n&&n.length>0?this._mapping.set(t,n):(this._mapping.delete(t),t.pause(),t.src="",null===(r=t.parentNode)||void 0===r||r.removeChild(t))}constructor(e,t,i,r,n,s){super(e,t,i,r,n),Object.defineProperty(this,"_resource",{enumerable:!0,configurable:!0,writable:!0,value:s}),zt._innerSetMapping(this.getTrackId(),s)}destroy(){this.isAudioTrack()&&this.mute(),zt._innerRemoveMapping(this.getTrackId(),this._resource),super.destroy()}}Object.defineProperty(zt,"_mapping",{enumerable:!0,configurable:!0,writable:!0,value:new Map});class Qt extends zt{constructor(e,t,i,r,n){super(e,t,i,"video",r,n)}}class Zt extends zt{constructor(e,t,i,r,n){super(e,t,i,"audio",r,n)}_setLocalMuted(e){const t=Object.create(null,{_setLocalMuted:{get:()=>super._setLocalMuted}});return I(this,void 0,void 0,function*(){return this._resource&&(this._resource.muted=e),t._setLocalMuted.call(this,e)})}play(){return I(this,void 0,void 0,function*(){return{code:yield this._setLocalMuted(!1)}})}}class Xt extends qt{constructor(){super(...arguments),Object.defineProperty(this,"_originTrack",{enumerable:!0,configurable:!0,writable:!0,value:null})}apply3ANoiseWorklet(){return I(this,void 0,void 0,function*(){if(this._logger.info(he.A_APPLY_3A_NOISE_WORKLET_T),this._originTrack)return this._logger.warn(he.A_APPLY_3A_NOISE_WORKLET_R,JSON.stringify({status:ge.FAILED,msg:"3A noise module already applied"})),{code:ue.SUCCESS};if(!this._msTrack||this.isDestroyed())return this._logger.warn(he.A_APPLY_3A_NOISE_WORKLET_R,JSON.stringify({status:ge.FAILED,msg:"track not ready"})),{code:ue.TRACK_NOT_READY};if(this.isPublished())return this._logger.warn(he.A_APPLY_3A_NOISE_WORKLET_R,JSON.stringify({status:ge.FAILED,msg:"track already published"})),{code:ue.APPLY_3A_NOISE_WORKLET_BEFORE_PUBLISH};const{code:e,track:t}=yield Kt.apply3ANoiseWorklet(this._msTrack);return e===ue.SUCCESS&&t?(this._originTrack=this._msTrack,this._msTrack=t,this._logger.info(he.A_APPLY_3A_NOISE_WORKLET_R,JSON.stringify({status:ge.SUCCESSED})),{code:ue.SUCCESS}):(this._logger.warn(he.A_APPLY_3A_NOISE_WORKLET_R,JSON.stringify({status:ge.FAILED,msg:`apply 3A noise module failed: ${e}`,SCRIPT_URL:Kt.SCRIPT_URL,WASM_URL:Kt.WASM_URL})),{code:e})})}__innerSetMediaStreamTrack(e){!e&&this._originTrack&&(Kt.release3ANoiseWorklet(this._originTrack),this._originTrack.stop(),this._originTrack=null),super.__innerSetMediaStreamTrack(e)}replaceInnerTrack(e){}}class ei extends Wt{constructor(e,t,i,r,n=!1){super(e,t,i,r,n)}replaceInnerTrack(e){}}class ti extends Wt{_onTrackEnded(){super._onTrackEnded(),this.isPublished()&&this.emit(Yt.__INNER_EVENT_DESTROY__,this)}}class ii extends qt{_onTrackEnded(){super._onTrackEnded(),this.isPublished()&&this.emit(Yt.__INNER_EVENT_DESTROY__,this)}}class ri extends jt{constructor(e,t,i,r,n){super(e,t,i,r,!1,n),Object.defineProperty(this,"_isSubscribed",{enumerable:!0,configurable:!0,writable:!0,value:!1})}__innerSetRemoteMuted(e){this._remoteMuted=e}__innerSetSubscribed(e){this._isSubscribed=e}isSubscribed(){return this._isSubscribed}}class ni extends ri{constructor(e,t,i,r){super(e,t,i,"audio",r)}_setLocalMuted(e){const{browser:t,version:i}=Ci;return this._element&&i&&/chrome/i.test(t)&&i>=130&&(this._element.muted=e),super._setLocalMuted(e)}getVolume(){var e;return 100*((null===(e=this._element)||void 0===e?void 0:e.volume)||0)}}class si extends ri{constructor(e,t,i,r){super(e,t,i,"video",r),Object.defineProperty(this,"_isSubTiny",{enumerable:!0,configurable:!0,writable:!0,value:!1})}__innerSetIsTinyTrack(e){this._isSubTiny=e}isSubTiny(){return this._isSubTiny}}var oi;!function(e){e[e.MARK_DOWN=0]="MARK_DOWN",e[e.JSON=1]="JSON"}(oi||(oi={}));const ai=(e,t)=>({name:e,content:JSON.stringify({uris:t,ignore:!0})}),li=e=>JSON.stringify(e),_i=e=>/^[a-zA-Z\d-=]+$/g.test(e),ci=e=>{if(void 0===e)return 0;if(O(e))return e;const t=e;return t.exact||t.ideal||t.max||0},di=e=>{const t=e.getSettings(),i=e.getConstraints();return{width:ci(i.width)||t.width||0,height:ci(i.height)||t.height||0,frameRate:t.frameRate||ci(i.frameRate)}},ui=e=>{const{width:t,height:i,frameRate:r}=di(e),n=Mt(t||1920,i||1080),s=kt(r);return{min:n.minBitrate*s,max:n.maxBitrate*s}},hi=e=>[e.msid,e.mediaType].join("_"),gi=e=>{const t=e.split("_");return{mediaType:parseInt(t.pop()),tag:t.pop(),userId:t.join("_")}},pi=(e,t)=>[e,t].join("_"),fi=e=>e.map(e=>Object.assign({},e)),Ei=(e,t,i=!1)=>{e=e.slice();const r=[],n=[],s=[];return t.forEach(t=>{const n=hi(t);let o=e.findIndex(e=>hi(e)===n);if(i&&(o=e.findIndex(e=>e.uri===t.uri)),-1===o)return void r.push(t);const a=e[o];a.uri!==t.uri?r.push(t):a.state!==t.state&&s.push(t),e.splice(o,1)}),n.push(...e),{publishedList:r,unpublishedList:n,modifiedList:s}},Ti=()=>{let e="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)});return e=`${e.replace(/-/g,"")}0`,e=parseInt(e,16),e=(e=>{const t="0123456789abcdefghigklmnopqrstuvwxyzABCDEFGHIGKLMNOPQRSTUVWXYZ+/".split(""),i=t.length+1;let r=+e;const n=[];do{const e=r%i;r=(r-e)/i,n.unshift(t[e])}while(r);return n.join("")})(e),e.length>22&&(e=e.slice(0,22)),e},mi=e=>{if(Ut[e]){const{width:t,height:i}=Ut[e];return{width:t,height:i}}const[t,i]=e.split("_").map(e=>parseInt(e.replace(/[^\d]/g,"")));return{width:t,height:i}},Ii=e=>!!Nt[e],Ri=e=>!!yt[e],Si=e=>parseInt(e.replace("FPS_","")),Ci=(()=>{const{browser:e,version:t,supportsUnifiedPlan:i}=At.browserDetails;return{browser:e,version:t,supportsUnifiedPlan:!1!==i}})();function Li(){return"captureStream"in HTMLMediaElement.prototype||"mozCaptureStream"in HTMLMediaElement.prototype}function Oi(){return"mediaDevices"in navigator&&"getDisplayMedia"in navigator.mediaDevices}const vi=e=>"[object Null]"===Object.prototype.toString.call(e),bi=e=>1===e.type,Ai=(e,t,i,r)=>{const n={},s=Object.keys(e.users);return s.length&&s.forEach(s=>{const o=[],a=e.users[s];if(a.extra){const{roomId:e}=JSON.parse(a.extra);if(t!==e)return}if(a.uris)try{o.push(...JSON.parse(a.uris))}catch(e){i.warn(he.L_PARSE_ROOMDATA_URIS_R,`invalid user data -> userId: ${s}, userData: ${a}`,r)}n[s]=o}),n},yi=e=>e instanceof jt?e.getTrackId():e.track.getTrackId(),Ni=e=>{if(!y(e)||void 0===e.low||void 0===e.high)return e;let{low:t}=e;t<0&&(t+=4294967296),t=t.toString(16);return parseInt(e.high.toString(16)+"00000000".replace(new RegExp(`0{${t.length}}$`),t),16)};var Pi,Ui;!function(e){e.PUBLISH="RCRTC:PublishResource",e.UNPUBLISH="RCRTC:UnpublishResource",e.MODIFY="RCRTC:ModifyResource",e.TOTAL_CONTENT_RESOURCE="RCRTC:TotalContentResources",e.STATE="RCRTC:state",e.ROOM_NOTIFY="RCRTC:RoomNtf",e.USER_NOTIFY="RCRTC:UserNtf",e.KICK="RCRTC:kick",e.PK_INVITE="RCRTC:invite",e.PK_INVITE_TIMEOUT="RCRTC:inviteTimeout",e.PK_CANCEL_INVITE="RCRTC:cancelInvite",e.PK_INVITE_ANSWER="RCRTC:answerInvite",e.PK_END="RCRTC:endInvite",e.OTHER_ROOM_OFFLINE="RCRTC:otherRoomOffline",e.ROOM_TASK_FINISH="RCRTC:roomTaskFinish",e.ASR_STATUS="RCRTC:AsrStatus",e.ASR_SEI="RCRTC:PublishSeiAi",e.SUMMARIZATION_STATUS="RCRTC:Summarization"}(Pi||(Pi={})),function(e){e.SUCCESS="Success",e.FAIL="Fail"}(Ui||(Ui={}));class Di{constructor(e,t,i,r=5e3){Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_roomId",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_roomMode",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_gap",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_latestTimestamp",{enumerable:!0,configurable:!0,writable:!0,value:Date.now()}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"onFailed",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"onPingResult",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_started",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_timer",{enumerable:!0,configurable:!0,writable:!0,value:null}),this._logger=this._context.logger}start(e){this._started||(e<15e3&&(e=15e3),this._logger.info(he.L_PINGER_START_O,JSON.stringify({interval:this._gap,offlineKickTime:e})),this._started=!0,this._checkAlive(e))}_sendPing(){return new Promise(e=>{this._context.rtcPing(this._roomId,this._roomMode).then(e),setTimeout(e,5e3,{code:le})})}_checkAlive(e){return I(this,void 0,void 0,function*(){const{logger:t}=this._context,i=t.createTraceId(),{code:r,data:n}=yield this._sendPing();if(!this._started)return;const s=Date.now();return r===oe?(this._latestTimestamp=s,this.onPingResult(Ui.SUCCESS,n.version),void(this._timer=setTimeout(()=>this._checkAlive(e),this._gap))):(t.error(he.L_PINGER_SEND_RTCPING_E,JSON.stringify({roomId:this._roomId,code:r}),i),this.onPingResult(Ui.FAIL),40003===r||s-this._latestTimestamp>e?(this.stop(),void this.onFailed(40003===r)):void(this._timer=setTimeout(()=>this._checkAlive(e),this._gap)))})}stop(){this._started&&(this._logger.info(he.L_PINGER_STOP_O),this._started=!1,this._timer&&(clearTimeout(this._timer),this._timer=null))}}
|
|
2
|
-
/*! pako 2.1.0 https://github.com/nodeca/pako @license (MIT AND Zlib) */function Mi(e){let t=e.length;for(;--t>=0;)e[t]=0}const wi=256,ki=286,xi=30,Bi=15,Vi=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),Gi=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),Fi=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),ji=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Hi=new Array(576);Mi(Hi);const Ji=new Array(60);Mi(Ji);const $i=new Array(512);Mi($i);const Ki=new Array(256);Mi(Ki);const Yi=new Array(29);Mi(Yi);const qi=new Array(xi);function Wi(e,t,i,r,n){this.static_tree=e,this.extra_bits=t,this.extra_base=i,this.elems=r,this.max_length=n,this.has_stree=e&&e.length}let zi,Qi,Zi;function Xi(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}Mi(qi);const er=e=>e<256?$i[e]:$i[256+(e>>>7)],tr=(e,t)=>{e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255},ir=(e,t,i)=>{e.bi_valid>16-i?(e.bi_buf|=t<<e.bi_valid&65535,tr(e,e.bi_buf),e.bi_buf=t>>16-e.bi_valid,e.bi_valid+=i-16):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=i)},rr=(e,t,i)=>{ir(e,i[2*t],i[2*t+1])},nr=(e,t)=>{let i=0;do{i|=1&e,e>>>=1,i<<=1}while(--t>0);return i>>>1},sr=(e,t,i)=>{const r=new Array(16);let n,s,o=0;for(n=1;n<=Bi;n++)o=o+i[n-1]<<1,r[n]=o;for(s=0;s<=t;s++){let t=e[2*s+1];0!==t&&(e[2*s]=nr(r[t]++,t))}},or=e=>{let t;for(t=0;t<ki;t++)e.dyn_ltree[2*t]=0;for(t=0;t<xi;t++)e.dyn_dtree[2*t]=0;for(t=0;t<19;t++)e.bl_tree[2*t]=0;e.dyn_ltree[512]=1,e.opt_len=e.static_len=0,e.sym_next=e.matches=0},ar=e=>{e.bi_valid>8?tr(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},lr=(e,t,i,r)=>{const n=2*t,s=2*i;return e[n]<e[s]||e[n]===e[s]&&r[t]<=r[i]},_r=(e,t,i)=>{const r=e.heap[i];let n=i<<1;for(;n<=e.heap_len&&(n<e.heap_len&&lr(t,e.heap[n+1],e.heap[n],e.depth)&&n++,!lr(t,r,e.heap[n],e.depth));)e.heap[i]=e.heap[n],i=n,n<<=1;e.heap[i]=r},cr=(e,t,i)=>{let r,n,s,o,a=0;if(0!==e.sym_next)do{r=255&e.pending_buf[e.sym_buf+a++],r+=(255&e.pending_buf[e.sym_buf+a++])<<8,n=e.pending_buf[e.sym_buf+a++],0===r?rr(e,n,t):(s=Ki[n],rr(e,s+wi+1,t),o=Vi[s],0!==o&&(n-=Yi[s],ir(e,n,o)),r--,s=er(r),rr(e,s,i),o=Gi[s],0!==o&&(r-=qi[s],ir(e,r,o)))}while(a<e.sym_next);rr(e,256,t)},dr=(e,t)=>{const i=t.dyn_tree,r=t.stat_desc.static_tree,n=t.stat_desc.has_stree,s=t.stat_desc.elems;let o,a,l,_=-1;for(e.heap_len=0,e.heap_max=573,o=0;o<s;o++)0!==i[2*o]?(e.heap[++e.heap_len]=_=o,e.depth[o]=0):i[2*o+1]=0;for(;e.heap_len<2;)l=e.heap[++e.heap_len]=_<2?++_:0,i[2*l]=1,e.depth[l]=0,e.opt_len--,n&&(e.static_len-=r[2*l+1]);for(t.max_code=_,o=e.heap_len>>1;o>=1;o--)_r(e,i,o);l=s;do{o=e.heap[1],e.heap[1]=e.heap[e.heap_len--],_r(e,i,1),a=e.heap[1],e.heap[--e.heap_max]=o,e.heap[--e.heap_max]=a,i[2*l]=i[2*o]+i[2*a],e.depth[l]=(e.depth[o]>=e.depth[a]?e.depth[o]:e.depth[a])+1,i[2*o+1]=i[2*a+1]=l,e.heap[1]=l++,_r(e,i,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],((e,t)=>{const i=t.dyn_tree,r=t.max_code,n=t.stat_desc.static_tree,s=t.stat_desc.has_stree,o=t.stat_desc.extra_bits,a=t.stat_desc.extra_base,l=t.stat_desc.max_length;let _,c,d,u,h,g,p=0;for(u=0;u<=Bi;u++)e.bl_count[u]=0;for(i[2*e.heap[e.heap_max]+1]=0,_=e.heap_max+1;_<573;_++)c=e.heap[_],u=i[2*i[2*c+1]+1]+1,u>l&&(u=l,p++),i[2*c+1]=u,c>r||(e.bl_count[u]++,h=0,c>=a&&(h=o[c-a]),g=i[2*c],e.opt_len+=g*(u+h),s&&(e.static_len+=g*(n[2*c+1]+h)));if(0!==p){do{for(u=l-1;0===e.bl_count[u];)u--;e.bl_count[u]--,e.bl_count[u+1]+=2,e.bl_count[l]--,p-=2}while(p>0);for(u=l;0!==u;u--)for(c=e.bl_count[u];0!==c;)d=e.heap[--_],d>r||(i[2*d+1]!==u&&(e.opt_len+=(u-i[2*d+1])*i[2*d],i[2*d+1]=u),c--)}})(e,t),sr(i,_,e.bl_count)},ur=(e,t,i)=>{let r,n,s=-1,o=t[1],a=0,l=7,_=4;for(0===o&&(l=138,_=3),t[2*(i+1)+1]=65535,r=0;r<=i;r++)n=o,o=t[2*(r+1)+1],++a<l&&n===o||(a<_?e.bl_tree[2*n]+=a:0!==n?(n!==s&&e.bl_tree[2*n]++,e.bl_tree[32]++):a<=10?e.bl_tree[34]++:e.bl_tree[36]++,a=0,s=n,0===o?(l=138,_=3):n===o?(l=6,_=3):(l=7,_=4))},hr=(e,t,i)=>{let r,n,s=-1,o=t[1],a=0,l=7,_=4;for(0===o&&(l=138,_=3),r=0;r<=i;r++)if(n=o,o=t[2*(r+1)+1],!(++a<l&&n===o)){if(a<_)do{rr(e,n,e.bl_tree)}while(0!==--a);else 0!==n?(n!==s&&(rr(e,n,e.bl_tree),a--),rr(e,16,e.bl_tree),ir(e,a-3,2)):a<=10?(rr(e,17,e.bl_tree),ir(e,a-3,3)):(rr(e,18,e.bl_tree),ir(e,a-11,7));a=0,s=n,0===o?(l=138,_=3):n===o?(l=6,_=3):(l=7,_=4)}};let gr=!1;const pr=(e,t,i,r)=>{ir(e,0+(r?1:0),3),ar(e),tr(e,i),tr(e,~i),i&&e.pending_buf.set(e.window.subarray(t,t+i),e.pending),e.pending+=i};var fr=(e,t,i,r)=>{let n,s,o=0;e.level>0?(2===e.strm.data_type&&(e.strm.data_type=(e=>{let t,i=4093624447;for(t=0;t<=31;t++,i>>>=1)if(1&i&&0!==e.dyn_ltree[2*t])return 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(t=32;t<wi;t++)if(0!==e.dyn_ltree[2*t])return 1;return 0})(e)),dr(e,e.l_desc),dr(e,e.d_desc),o=(e=>{let t;for(ur(e,e.dyn_ltree,e.l_desc.max_code),ur(e,e.dyn_dtree,e.d_desc.max_code),dr(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*ji[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t})(e),n=e.opt_len+3+7>>>3,s=e.static_len+3+7>>>3,s<=n&&(n=s)):n=s=i+5,i+4<=n&&-1!==t?pr(e,t,i,r):4===e.strategy||s===n?(ir(e,2+(r?1:0),3),cr(e,Hi,Ji)):(ir(e,4+(r?1:0),3),((e,t,i,r)=>{let n;for(ir(e,t-257,5),ir(e,i-1,5),ir(e,r-4,4),n=0;n<r;n++)ir(e,e.bl_tree[2*ji[n]+1],3);hr(e,e.dyn_ltree,t-1),hr(e,e.dyn_dtree,i-1)})(e,e.l_desc.max_code+1,e.d_desc.max_code+1,o+1),cr(e,e.dyn_ltree,e.dyn_dtree)),or(e),r&&ar(e)},Er={_tr_init:e=>{gr||((()=>{let e,t,i,r,n;const s=new Array(16);for(i=0,r=0;r<28;r++)for(Yi[r]=i,e=0;e<1<<Vi[r];e++)Ki[i++]=r;for(Ki[i-1]=r,n=0,r=0;r<16;r++)for(qi[r]=n,e=0;e<1<<Gi[r];e++)$i[n++]=r;for(n>>=7;r<xi;r++)for(qi[r]=n<<7,e=0;e<1<<Gi[r]-7;e++)$i[256+n++]=r;for(t=0;t<=Bi;t++)s[t]=0;for(e=0;e<=143;)Hi[2*e+1]=8,e++,s[8]++;for(;e<=255;)Hi[2*e+1]=9,e++,s[9]++;for(;e<=279;)Hi[2*e+1]=7,e++,s[7]++;for(;e<=287;)Hi[2*e+1]=8,e++,s[8]++;for(sr(Hi,287,s),e=0;e<xi;e++)Ji[2*e+1]=5,Ji[2*e]=nr(e,5);zi=new Wi(Hi,Vi,257,ki,Bi),Qi=new Wi(Ji,Gi,0,xi,Bi),Zi=new Wi(new Array(0),Fi,0,19,7)})(),gr=!0),e.l_desc=new Xi(e.dyn_ltree,zi),e.d_desc=new Xi(e.dyn_dtree,Qi),e.bl_desc=new Xi(e.bl_tree,Zi),e.bi_buf=0,e.bi_valid=0,or(e)},_tr_stored_block:pr,_tr_flush_block:fr,_tr_tally:(e,t,i)=>(e.pending_buf[e.sym_buf+e.sym_next++]=t,e.pending_buf[e.sym_buf+e.sym_next++]=t>>8,e.pending_buf[e.sym_buf+e.sym_next++]=i,0===t?e.dyn_ltree[2*i]++:(e.matches++,t--,e.dyn_ltree[2*(Ki[i]+wi+1)]++,e.dyn_dtree[2*er(t)]++),e.sym_next===e.sym_end),_tr_align:e=>{ir(e,2,3),rr(e,256,Hi),(e=>{16===e.bi_valid?(tr(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)})(e)}};var Tr=(e,t,i,r)=>{let n=65535&e,s=e>>>16&65535,o=0;for(;0!==i;){o=i>2e3?2e3:i,i-=o;do{n=n+t[r++]|0,s=s+n|0}while(--o);n%=65521,s%=65521}return n|s<<16};const mr=new Uint32Array((()=>{let e,t=[];for(var i=0;i<256;i++){e=i;for(var r=0;r<8;r++)e=1&e?3988292384^e>>>1:e>>>1;t[i]=e}return t})());var Ir=(e,t,i,r)=>{const n=mr,s=r+i;e^=-1;for(let i=r;i<s;i++)e=e>>>8^n[255&(e^t[i])];return-1^e},Rr={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},Sr={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};const{_tr_init:Cr,_tr_stored_block:Lr,_tr_flush_block:Or,_tr_tally:vr,_tr_align:br}=Er,{Z_NO_FLUSH:Ar,Z_PARTIAL_FLUSH:yr,Z_FULL_FLUSH:Nr,Z_FINISH:Pr,Z_BLOCK:Ur,Z_OK:Dr,Z_STREAM_END:Mr,Z_STREAM_ERROR:wr,Z_DATA_ERROR:kr,Z_BUF_ERROR:xr,Z_DEFAULT_COMPRESSION:Br,Z_FILTERED:Vr,Z_HUFFMAN_ONLY:Gr,Z_RLE:Fr,Z_FIXED:jr,Z_DEFAULT_STRATEGY:Hr,Z_UNKNOWN:Jr,Z_DEFLATED:$r}=Sr,Kr=258,Yr=262,qr=42,Wr=113,zr=666,Qr=(e,t)=>(e.msg=Rr[t],t),Zr=e=>2*e-(e>4?9:0),Xr=e=>{let t=e.length;for(;--t>=0;)e[t]=0},en=e=>{let t,i,r,n=e.w_size;t=e.hash_size,r=t;do{i=e.head[--r],e.head[r]=i>=n?i-n:0}while(--t);t=n,r=t;do{i=e.prev[--r],e.prev[r]=i>=n?i-n:0}while(--t)};let tn=(e,t,i)=>(t<<e.hash_shift^i)&e.hash_mask;const rn=e=>{const t=e.state;let i=t.pending;i>e.avail_out&&(i=e.avail_out),0!==i&&(e.output.set(t.pending_buf.subarray(t.pending_out,t.pending_out+i),e.next_out),e.next_out+=i,t.pending_out+=i,e.total_out+=i,e.avail_out-=i,t.pending-=i,0===t.pending&&(t.pending_out=0))},nn=(e,t)=>{Or(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,rn(e.strm)},sn=(e,t)=>{e.pending_buf[e.pending++]=t},on=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t},an=(e,t,i,r)=>{let n=e.avail_in;return n>r&&(n=r),0===n?0:(e.avail_in-=n,t.set(e.input.subarray(e.next_in,e.next_in+n),i),1===e.state.wrap?e.adler=Tr(e.adler,t,n,i):2===e.state.wrap&&(e.adler=Ir(e.adler,t,n,i)),e.next_in+=n,e.total_in+=n,n)},ln=(e,t)=>{let i,r,n=e.max_chain_length,s=e.strstart,o=e.prev_length,a=e.nice_match;const l=e.strstart>e.w_size-Yr?e.strstart-(e.w_size-Yr):0,_=e.window,c=e.w_mask,d=e.prev,u=e.strstart+Kr;let h=_[s+o-1],g=_[s+o];e.prev_length>=e.good_match&&(n>>=2),a>e.lookahead&&(a=e.lookahead);do{if(i=t,_[i+o]===g&&_[i+o-1]===h&&_[i]===_[s]&&_[++i]===_[s+1]){s+=2,i++;do{}while(_[++s]===_[++i]&&_[++s]===_[++i]&&_[++s]===_[++i]&&_[++s]===_[++i]&&_[++s]===_[++i]&&_[++s]===_[++i]&&_[++s]===_[++i]&&_[++s]===_[++i]&&s<u);if(r=Kr-(u-s),s=u-Kr,r>o){if(e.match_start=t,o=r,r>=a)break;h=_[s+o-1],g=_[s+o]}}}while((t=d[t&c])>l&&0!==--n);return o<=e.lookahead?o:e.lookahead},_n=e=>{const t=e.w_size;let i,r,n;do{if(r=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-Yr)&&(e.window.set(e.window.subarray(t,t+t-r),0),e.match_start-=t,e.strstart-=t,e.block_start-=t,e.insert>e.strstart&&(e.insert=e.strstart),en(e),r+=t),0===e.strm.avail_in)break;if(i=an(e.strm,e.window,e.strstart+e.lookahead,r),e.lookahead+=i,e.lookahead+e.insert>=3)for(n=e.strstart-e.insert,e.ins_h=e.window[n],e.ins_h=tn(e,e.ins_h,e.window[n+1]);e.insert&&(e.ins_h=tn(e,e.ins_h,e.window[n+3-1]),e.prev[n&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=n,n++,e.insert--,!(e.lookahead+e.insert<3)););}while(e.lookahead<Yr&&0!==e.strm.avail_in)},cn=(e,t)=>{let i,r,n,s=e.pending_buf_size-5>e.w_size?e.w_size:e.pending_buf_size-5,o=0,a=e.strm.avail_in;do{if(i=65535,n=e.bi_valid+42>>3,e.strm.avail_out<n)break;if(n=e.strm.avail_out-n,r=e.strstart-e.block_start,i>r+e.strm.avail_in&&(i=r+e.strm.avail_in),i>n&&(i=n),i<s&&(0===i&&t!==Pr||t===Ar||i!==r+e.strm.avail_in))break;o=t===Pr&&i===r+e.strm.avail_in?1:0,Lr(e,0,0,o),e.pending_buf[e.pending-4]=i,e.pending_buf[e.pending-3]=i>>8,e.pending_buf[e.pending-2]=~i,e.pending_buf[e.pending-1]=~i>>8,rn(e.strm),r&&(r>i&&(r=i),e.strm.output.set(e.window.subarray(e.block_start,e.block_start+r),e.strm.next_out),e.strm.next_out+=r,e.strm.avail_out-=r,e.strm.total_out+=r,e.block_start+=r,i-=r),i&&(an(e.strm,e.strm.output,e.strm.next_out,i),e.strm.next_out+=i,e.strm.avail_out-=i,e.strm.total_out+=i)}while(0===o);return a-=e.strm.avail_in,a&&(a>=e.w_size?(e.matches=2,e.window.set(e.strm.input.subarray(e.strm.next_in-e.w_size,e.strm.next_in),0),e.strstart=e.w_size,e.insert=e.strstart):(e.window_size-e.strstart<=a&&(e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,e.insert>e.strstart&&(e.insert=e.strstart)),e.window.set(e.strm.input.subarray(e.strm.next_in-a,e.strm.next_in),e.strstart),e.strstart+=a,e.insert+=a>e.w_size-e.insert?e.w_size-e.insert:a),e.block_start=e.strstart),e.high_water<e.strstart&&(e.high_water=e.strstart),o?4:t!==Ar&&t!==Pr&&0===e.strm.avail_in&&e.strstart===e.block_start?2:(n=e.window_size-e.strstart,e.strm.avail_in>n&&e.block_start>=e.w_size&&(e.block_start-=e.w_size,e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,n+=e.w_size,e.insert>e.strstart&&(e.insert=e.strstart)),n>e.strm.avail_in&&(n=e.strm.avail_in),n&&(an(e.strm,e.window,e.strstart,n),e.strstart+=n,e.insert+=n>e.w_size-e.insert?e.w_size-e.insert:n),e.high_water<e.strstart&&(e.high_water=e.strstart),n=e.bi_valid+42>>3,n=e.pending_buf_size-n>65535?65535:e.pending_buf_size-n,s=n>e.w_size?e.w_size:n,r=e.strstart-e.block_start,(r>=s||(r||t===Pr)&&t!==Ar&&0===e.strm.avail_in&&r<=n)&&(i=r>n?n:r,o=t===Pr&&0===e.strm.avail_in&&i===r?1:0,Lr(e,e.block_start,i,o),e.block_start+=i,rn(e.strm)),o?3:1)},dn=(e,t)=>{let i,r;for(;;){if(e.lookahead<Yr){if(_n(e),e.lookahead<Yr&&t===Ar)return 1;if(0===e.lookahead)break}if(i=0,e.lookahead>=3&&(e.ins_h=tn(e,e.ins_h,e.window[e.strstart+3-1]),i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==i&&e.strstart-i<=e.w_size-Yr&&(e.match_length=ln(e,i)),e.match_length>=3)if(r=vr(e,e.strstart-e.match_start,e.match_length-3),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=3){e.match_length--;do{e.strstart++,e.ins_h=tn(e,e.ins_h,e.window[e.strstart+3-1]),i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart}while(0!==--e.match_length);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=tn(e,e.ins_h,e.window[e.strstart+1]);else r=vr(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(r&&(nn(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,t===Pr?(nn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(nn(e,!1),0===e.strm.avail_out)?1:2},un=(e,t)=>{let i,r,n;for(;;){if(e.lookahead<Yr){if(_n(e),e.lookahead<Yr&&t===Ar)return 1;if(0===e.lookahead)break}if(i=0,e.lookahead>=3&&(e.ins_h=tn(e,e.ins_h,e.window[e.strstart+3-1]),i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=2,0!==i&&e.prev_length<e.max_lazy_match&&e.strstart-i<=e.w_size-Yr&&(e.match_length=ln(e,i),e.match_length<=5&&(e.strategy===Vr||3===e.match_length&&e.strstart-e.match_start>4096)&&(e.match_length=2)),e.prev_length>=3&&e.match_length<=e.prev_length){n=e.strstart+e.lookahead-3,r=vr(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=n&&(e.ins_h=tn(e,e.ins_h,e.window[e.strstart+3-1]),i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart)}while(0!==--e.prev_length);if(e.match_available=0,e.match_length=2,e.strstart++,r&&(nn(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if(r=vr(e,0,e.window[e.strstart-1]),r&&nn(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return 1}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(r=vr(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,t===Pr?(nn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(nn(e,!1),0===e.strm.avail_out)?1:2};function hn(e,t,i,r,n){this.good_length=e,this.max_lazy=t,this.nice_length=i,this.max_chain=r,this.func=n}const gn=[new hn(0,0,0,0,cn),new hn(4,4,8,4,dn),new hn(4,5,16,8,dn),new hn(4,6,32,32,dn),new hn(4,4,16,16,un),new hn(8,16,32,32,un),new hn(8,16,128,128,un),new hn(8,32,128,256,un),new hn(32,128,258,1024,un),new hn(32,258,258,4096,un)];function pn(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=$r,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(1146),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),Xr(this.dyn_ltree),Xr(this.dyn_dtree),Xr(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),Xr(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),Xr(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const fn=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.status!==qr&&57!==t.status&&69!==t.status&&73!==t.status&&91!==t.status&&103!==t.status&&t.status!==Wr&&t.status!==zr?1:0},En=e=>{if(fn(e))return Qr(e,wr);e.total_in=e.total_out=0,e.data_type=Jr;const t=e.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=2===t.wrap?57:t.wrap?qr:Wr,e.adler=2===t.wrap?0:1,t.last_flush=-2,Cr(t),Dr},Tn=e=>{const t=En(e);var i;return t===Dr&&((i=e.state).window_size=2*i.w_size,Xr(i.head),i.max_lazy_match=gn[i.level].max_lazy,i.good_match=gn[i.level].good_length,i.nice_match=gn[i.level].nice_length,i.max_chain_length=gn[i.level].max_chain,i.strstart=0,i.block_start=0,i.lookahead=0,i.insert=0,i.match_length=i.prev_length=2,i.match_available=0,i.ins_h=0),t},mn=(e,t,i,r,n,s)=>{if(!e)return wr;let o=1;if(t===Br&&(t=6),r<0?(o=0,r=-r):r>15&&(o=2,r-=16),n<1||n>9||i!==$r||r<8||r>15||t<0||t>9||s<0||s>jr||8===r&&1!==o)return Qr(e,wr);8===r&&(r=9);const a=new pn;return e.state=a,a.strm=e,a.status=qr,a.wrap=o,a.gzhead=null,a.w_bits=r,a.w_size=1<<a.w_bits,a.w_mask=a.w_size-1,a.hash_bits=n+7,a.hash_size=1<<a.hash_bits,a.hash_mask=a.hash_size-1,a.hash_shift=~~((a.hash_bits+3-1)/3),a.window=new Uint8Array(2*a.w_size),a.head=new Uint16Array(a.hash_size),a.prev=new Uint16Array(a.w_size),a.lit_bufsize=1<<n+6,a.pending_buf_size=4*a.lit_bufsize,a.pending_buf=new Uint8Array(a.pending_buf_size),a.sym_buf=a.lit_bufsize,a.sym_end=3*(a.lit_bufsize-1),a.level=t,a.strategy=s,a.method=i,Tn(e)};var In={deflateInit:(e,t)=>mn(e,t,$r,15,8,Hr),deflateInit2:mn,deflateReset:Tn,deflateResetKeep:En,deflateSetHeader:(e,t)=>fn(e)||2!==e.state.wrap?wr:(e.state.gzhead=t,Dr),deflate:(e,t)=>{if(fn(e)||t>Ur||t<0)return e?Qr(e,wr):wr;const i=e.state;if(!e.output||0!==e.avail_in&&!e.input||i.status===zr&&t!==Pr)return Qr(e,0===e.avail_out?xr:wr);const r=i.last_flush;if(i.last_flush=t,0!==i.pending){if(rn(e),0===e.avail_out)return i.last_flush=-1,Dr}else if(0===e.avail_in&&Zr(t)<=Zr(r)&&t!==Pr)return Qr(e,xr);if(i.status===zr&&0!==e.avail_in)return Qr(e,xr);if(i.status===qr&&0===i.wrap&&(i.status=Wr),i.status===qr){let t=$r+(i.w_bits-8<<4)<<8,r=-1;if(r=i.strategy>=Gr||i.level<2?0:i.level<6?1:6===i.level?2:3,t|=r<<6,0!==i.strstart&&(t|=32),t+=31-t%31,on(i,t),0!==i.strstart&&(on(i,e.adler>>>16),on(i,65535&e.adler)),e.adler=1,i.status=Wr,rn(e),0!==i.pending)return i.last_flush=-1,Dr}if(57===i.status)if(e.adler=0,sn(i,31),sn(i,139),sn(i,8),i.gzhead)sn(i,(i.gzhead.text?1:0)+(i.gzhead.hcrc?2:0)+(i.gzhead.extra?4:0)+(i.gzhead.name?8:0)+(i.gzhead.comment?16:0)),sn(i,255&i.gzhead.time),sn(i,i.gzhead.time>>8&255),sn(i,i.gzhead.time>>16&255),sn(i,i.gzhead.time>>24&255),sn(i,9===i.level?2:i.strategy>=Gr||i.level<2?4:0),sn(i,255&i.gzhead.os),i.gzhead.extra&&i.gzhead.extra.length&&(sn(i,255&i.gzhead.extra.length),sn(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(e.adler=Ir(e.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=69;else if(sn(i,0),sn(i,0),sn(i,0),sn(i,0),sn(i,0),sn(i,9===i.level?2:i.strategy>=Gr||i.level<2?4:0),sn(i,3),i.status=Wr,rn(e),0!==i.pending)return i.last_flush=-1,Dr;if(69===i.status){if(i.gzhead.extra){let t=i.pending,r=(65535&i.gzhead.extra.length)-i.gzindex;for(;i.pending+r>i.pending_buf_size;){let n=i.pending_buf_size-i.pending;if(i.pending_buf.set(i.gzhead.extra.subarray(i.gzindex,i.gzindex+n),i.pending),i.pending=i.pending_buf_size,i.gzhead.hcrc&&i.pending>t&&(e.adler=Ir(e.adler,i.pending_buf,i.pending-t,t)),i.gzindex+=n,rn(e),0!==i.pending)return i.last_flush=-1,Dr;t=0,r-=n}let n=new Uint8Array(i.gzhead.extra);i.pending_buf.set(n.subarray(i.gzindex,i.gzindex+r),i.pending),i.pending+=r,i.gzhead.hcrc&&i.pending>t&&(e.adler=Ir(e.adler,i.pending_buf,i.pending-t,t)),i.gzindex=0}i.status=73}if(73===i.status){if(i.gzhead.name){let t,r=i.pending;do{if(i.pending===i.pending_buf_size){if(i.gzhead.hcrc&&i.pending>r&&(e.adler=Ir(e.adler,i.pending_buf,i.pending-r,r)),rn(e),0!==i.pending)return i.last_flush=-1,Dr;r=0}t=i.gzindex<i.gzhead.name.length?255&i.gzhead.name.charCodeAt(i.gzindex++):0,sn(i,t)}while(0!==t);i.gzhead.hcrc&&i.pending>r&&(e.adler=Ir(e.adler,i.pending_buf,i.pending-r,r)),i.gzindex=0}i.status=91}if(91===i.status){if(i.gzhead.comment){let t,r=i.pending;do{if(i.pending===i.pending_buf_size){if(i.gzhead.hcrc&&i.pending>r&&(e.adler=Ir(e.adler,i.pending_buf,i.pending-r,r)),rn(e),0!==i.pending)return i.last_flush=-1,Dr;r=0}t=i.gzindex<i.gzhead.comment.length?255&i.gzhead.comment.charCodeAt(i.gzindex++):0,sn(i,t)}while(0!==t);i.gzhead.hcrc&&i.pending>r&&(e.adler=Ir(e.adler,i.pending_buf,i.pending-r,r))}i.status=103}if(103===i.status){if(i.gzhead.hcrc){if(i.pending+2>i.pending_buf_size&&(rn(e),0!==i.pending))return i.last_flush=-1,Dr;sn(i,255&e.adler),sn(i,e.adler>>8&255),e.adler=0}if(i.status=Wr,rn(e),0!==i.pending)return i.last_flush=-1,Dr}if(0!==e.avail_in||0!==i.lookahead||t!==Ar&&i.status!==zr){let r=0===i.level?cn(i,t):i.strategy===Gr?((e,t)=>{let i;for(;;){if(0===e.lookahead&&(_n(e),0===e.lookahead)){if(t===Ar)return 1;break}if(e.match_length=0,i=vr(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,i&&(nn(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===Pr?(nn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(nn(e,!1),0===e.strm.avail_out)?1:2})(i,t):i.strategy===Fr?((e,t)=>{let i,r,n,s;const o=e.window;for(;;){if(e.lookahead<=Kr){if(_n(e),e.lookahead<=Kr&&t===Ar)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&e.strstart>0&&(n=e.strstart-1,r=o[n],r===o[++n]&&r===o[++n]&&r===o[++n])){s=e.strstart+Kr;do{}while(r===o[++n]&&r===o[++n]&&r===o[++n]&&r===o[++n]&&r===o[++n]&&r===o[++n]&&r===o[++n]&&r===o[++n]&&n<s);e.match_length=Kr-(s-n),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(i=vr(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(i=vr(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),i&&(nn(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===Pr?(nn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(nn(e,!1),0===e.strm.avail_out)?1:2})(i,t):gn[i.level].func(i,t);if(3!==r&&4!==r||(i.status=zr),1===r||3===r)return 0===e.avail_out&&(i.last_flush=-1),Dr;if(2===r&&(t===yr?br(i):t!==Ur&&(Lr(i,0,0,!1),t===Nr&&(Xr(i.head),0===i.lookahead&&(i.strstart=0,i.block_start=0,i.insert=0))),rn(e),0===e.avail_out))return i.last_flush=-1,Dr}return t!==Pr?Dr:i.wrap<=0?Mr:(2===i.wrap?(sn(i,255&e.adler),sn(i,e.adler>>8&255),sn(i,e.adler>>16&255),sn(i,e.adler>>24&255),sn(i,255&e.total_in),sn(i,e.total_in>>8&255),sn(i,e.total_in>>16&255),sn(i,e.total_in>>24&255)):(on(i,e.adler>>>16),on(i,65535&e.adler)),rn(e),i.wrap>0&&(i.wrap=-i.wrap),0!==i.pending?Dr:Mr)},deflateEnd:e=>{if(fn(e))return wr;const t=e.state.status;return e.state=null,t===Wr?Qr(e,kr):Dr},deflateSetDictionary:(e,t)=>{let i=t.length;if(fn(e))return wr;const r=e.state,n=r.wrap;if(2===n||1===n&&r.status!==qr||r.lookahead)return wr;if(1===n&&(e.adler=Tr(e.adler,t,i,0)),r.wrap=0,i>=r.w_size){0===n&&(Xr(r.head),r.strstart=0,r.block_start=0,r.insert=0);let e=new Uint8Array(r.w_size);e.set(t.subarray(i-r.w_size,i),0),t=e,i=r.w_size}const s=e.avail_in,o=e.next_in,a=e.input;for(e.avail_in=i,e.next_in=0,e.input=t,_n(r);r.lookahead>=3;){let e=r.strstart,t=r.lookahead-2;do{r.ins_h=tn(r,r.ins_h,r.window[e+3-1]),r.prev[e&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=e,e++}while(--t);r.strstart=e,r.lookahead=2,_n(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=2,r.match_available=0,e.next_in=o,e.input=a,e.avail_in=s,r.wrap=n,Dr},deflateInfo:"pako deflate (from Nodeca project)"};const Rn=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var Sn=function(e){const t=Array.prototype.slice.call(arguments,1);for(;t.length;){const i=t.shift();if(i){if("object"!=typeof i)throw new TypeError(i+"must be non-object");for(const t in i)Rn(i,t)&&(e[t]=i[t])}}return e},Cn=e=>{let t=0;for(let i=0,r=e.length;i<r;i++)t+=e[i].length;const i=new Uint8Array(t);for(let t=0,r=0,n=e.length;t<n;t++){let n=e[t];i.set(n,r),r+=n.length}return i};let Ln=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(e){Ln=!1}const On=new Uint8Array(256);for(let e=0;e<256;e++)On[e]=e>=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;On[254]=On[254]=1;var vn=e=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(e);let t,i,r,n,s,o=e.length,a=0;for(n=0;n<o;n++)i=e.charCodeAt(n),55296==(64512&i)&&n+1<o&&(r=e.charCodeAt(n+1),56320==(64512&r)&&(i=65536+(i-55296<<10)+(r-56320),n++)),a+=i<128?1:i<2048?2:i<65536?3:4;for(t=new Uint8Array(a),s=0,n=0;s<a;n++)i=e.charCodeAt(n),55296==(64512&i)&&n+1<o&&(r=e.charCodeAt(n+1),56320==(64512&r)&&(i=65536+(i-55296<<10)+(r-56320),n++)),i<128?t[s++]=i:i<2048?(t[s++]=192|i>>>6,t[s++]=128|63&i):i<65536?(t[s++]=224|i>>>12,t[s++]=128|i>>>6&63,t[s++]=128|63&i):(t[s++]=240|i>>>18,t[s++]=128|i>>>12&63,t[s++]=128|i>>>6&63,t[s++]=128|63&i);return t},bn=(e,t)=>{const i=t||e.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(e.subarray(0,t));let r,n;const s=new Array(2*i);for(n=0,r=0;r<i;){let t=e[r++];if(t<128){s[n++]=t;continue}let o=On[t];if(o>4)s[n++]=65533,r+=o-1;else{for(t&=2===o?31:3===o?15:7;o>1&&r<i;)t=t<<6|63&e[r++],o--;o>1?s[n++]=65533:t<65536?s[n++]=t:(t-=65536,s[n++]=55296|t>>10&1023,s[n++]=56320|1023&t)}}return((e,t)=>{if(t<65534&&e.subarray&&Ln)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));let i="";for(let r=0;r<t;r++)i+=String.fromCharCode(e[r]);return i})(s,n)},An=(e,t)=>{(t=t||e.length)>e.length&&(t=e.length);let i=t-1;for(;i>=0&&128==(192&e[i]);)i--;return i<0||0===i?t:i+On[e[i]]>t?i:t};var yn=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0};const Nn=Object.prototype.toString,{Z_NO_FLUSH:Pn,Z_SYNC_FLUSH:Un,Z_FULL_FLUSH:Dn,Z_FINISH:Mn,Z_OK:wn,Z_STREAM_END:kn,Z_DEFAULT_COMPRESSION:xn,Z_DEFAULT_STRATEGY:Bn,Z_DEFLATED:Vn}=Sr;function Gn(e){this.options=Sn({level:xn,method:Vn,chunkSize:16384,windowBits:15,memLevel:8,strategy:Bn},e||{});let t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new yn,this.strm.avail_out=0;let i=In.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(i!==wn)throw new Error(Rr[i]);if(t.header&&In.deflateSetHeader(this.strm,t.header),t.dictionary){let e;if(e="string"==typeof t.dictionary?vn(t.dictionary):"[object ArrayBuffer]"===Nn.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,i=In.deflateSetDictionary(this.strm,e),i!==wn)throw new Error(Rr[i]);this._dict_set=!0}}function Fn(e,t){const i=new Gn(t);if(i.push(e,!0),i.err)throw i.msg||Rr[i.err];return i.result}Gn.prototype.push=function(e,t){const i=this.strm,r=this.options.chunkSize;let n,s;if(this.ended)return!1;for(s=t===~~t?t:!0===t?Mn:Pn,"string"==typeof e?i.input=vn(e):"[object ArrayBuffer]"===Nn.call(e)?i.input=new Uint8Array(e):i.input=e,i.next_in=0,i.avail_in=i.input.length;;)if(0===i.avail_out&&(i.output=new Uint8Array(r),i.next_out=0,i.avail_out=r),(s===Un||s===Dn)&&i.avail_out<=6)this.onData(i.output.subarray(0,i.next_out)),i.avail_out=0;else{if(n=In.deflate(i,s),n===kn)return i.next_out>0&&this.onData(i.output.subarray(0,i.next_out)),n=In.deflateEnd(this.strm),this.onEnd(n),this.ended=!0,n===wn;if(0!==i.avail_out){if(s>0&&i.next_out>0)this.onData(i.output.subarray(0,i.next_out)),i.avail_out=0;else if(0===i.avail_in)break}else this.onData(i.output)}return!0},Gn.prototype.onData=function(e){this.chunks.push(e)},Gn.prototype.onEnd=function(e){e===wn&&(this.result=Cn(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var jn={Deflate:Gn,deflate:Fn,deflateRaw:function(e,t){return(t=t||{}).raw=!0,Fn(e,t)},gzip:function(e,t){return(t=t||{}).gzip=!0,Fn(e,t)},constants:Sr};const Hn=16209;var Jn=function(e,t){let i,r,n,s,o,a,l,_,c,d,u,h,g,p,f,E,T,m,I,R,S,C,L,O;const v=e.state;i=e.next_in,L=e.input,r=i+(e.avail_in-5),n=e.next_out,O=e.output,s=n-(t-e.avail_out),o=n+(e.avail_out-257),a=v.dmax,l=v.wsize,_=v.whave,c=v.wnext,d=v.window,u=v.hold,h=v.bits,g=v.lencode,p=v.distcode,f=(1<<v.lenbits)-1,E=(1<<v.distbits)-1;e:do{h<15&&(u+=L[i++]<<h,h+=8,u+=L[i++]<<h,h+=8),T=g[u&f];t:for(;;){if(m=T>>>24,u>>>=m,h-=m,m=T>>>16&255,0===m)O[n++]=65535&T;else{if(!(16&m)){if(64&m){if(32&m){v.mode=16191;break e}e.msg="invalid literal/length code",v.mode=Hn;break e}T=g[(65535&T)+(u&(1<<m)-1)];continue t}for(I=65535&T,m&=15,m&&(h<m&&(u+=L[i++]<<h,h+=8),I+=u&(1<<m)-1,u>>>=m,h-=m),h<15&&(u+=L[i++]<<h,h+=8,u+=L[i++]<<h,h+=8),T=p[u&E];;){if(m=T>>>24,u>>>=m,h-=m,m=T>>>16&255,16&m){if(R=65535&T,m&=15,h<m&&(u+=L[i++]<<h,h+=8,h<m&&(u+=L[i++]<<h,h+=8)),R+=u&(1<<m)-1,R>a){e.msg="invalid distance too far back",v.mode=Hn;break e}if(u>>>=m,h-=m,m=n-s,R>m){if(m=R-m,m>_&&v.sane){e.msg="invalid distance too far back",v.mode=Hn;break e}if(S=0,C=d,0===c){if(S+=l-m,m<I){I-=m;do{O[n++]=d[S++]}while(--m);S=n-R,C=O}}else if(c<m){if(S+=l+c-m,m-=c,m<I){I-=m;do{O[n++]=d[S++]}while(--m);if(S=0,c<I){m=c,I-=m;do{O[n++]=d[S++]}while(--m);S=n-R,C=O}}}else if(S+=c-m,m<I){I-=m;do{O[n++]=d[S++]}while(--m);S=n-R,C=O}for(;I>2;)O[n++]=C[S++],O[n++]=C[S++],O[n++]=C[S++],I-=3;I&&(O[n++]=C[S++],I>1&&(O[n++]=C[S++]))}else{S=n-R;do{O[n++]=O[S++],O[n++]=O[S++],O[n++]=O[S++],I-=3}while(I>2);I&&(O[n++]=O[S++],I>1&&(O[n++]=O[S++]))}break}if(64&m){e.msg="invalid distance code",v.mode=Hn;break e}T=p[(65535&T)+(u&(1<<m)-1)]}}break}}while(i<r&&n<o);I=h>>3,i-=I,h-=I<<3,u&=(1<<h)-1,e.next_in=i,e.next_out=n,e.avail_in=i<r?r-i+5:5-(i-r),e.avail_out=n<o?o-n+257:257-(n-o),v.hold=u,v.bits=h};const $n=15,Kn=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),Yn=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),qn=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),Wn=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]);var zn=(e,t,i,r,n,s,o,a)=>{const l=a.bits;let _,c,d,u,h,g,p=0,f=0,E=0,T=0,m=0,I=0,R=0,S=0,C=0,L=0,O=null;const v=new Uint16Array(16),b=new Uint16Array(16);let A,y,N,P=null;for(p=0;p<=$n;p++)v[p]=0;for(f=0;f<r;f++)v[t[i+f]]++;for(m=l,T=$n;T>=1&&0===v[T];T--);if(m>T&&(m=T),0===T)return n[s++]=20971520,n[s++]=20971520,a.bits=1,0;for(E=1;E<T&&0===v[E];E++);for(m<E&&(m=E),S=1,p=1;p<=$n;p++)if(S<<=1,S-=v[p],S<0)return-1;if(S>0&&(0===e||1!==T))return-1;for(b[1]=0,p=1;p<$n;p++)b[p+1]=b[p]+v[p];for(f=0;f<r;f++)0!==t[i+f]&&(o[b[t[i+f]]++]=f);if(0===e?(O=P=o,g=20):1===e?(O=Kn,P=Yn,g=257):(O=qn,P=Wn,g=0),L=0,f=0,p=E,h=s,I=m,R=0,d=-1,C=1<<m,u=C-1,1===e&&C>852||2===e&&C>592)return 1;for(;;){A=p-R,o[f]+1<g?(y=0,N=o[f]):o[f]>=g?(y=P[o[f]-g],N=O[o[f]-g]):(y=96,N=0),_=1<<p-R,c=1<<I,E=c;do{c-=_,n[h+(L>>R)+c]=A<<24|y<<16|N}while(0!==c);for(_=1<<p-1;L&_;)_>>=1;if(0!==_?(L&=_-1,L+=_):L=0,f++,0===--v[p]){if(p===T)break;p=t[i+o[f]]}if(p>m&&(L&u)!==d){for(0===R&&(R=m),h+=E,I=p-R,S=1<<I;I+R<T&&(S-=v[I+R],!(S<=0));)I++,S<<=1;if(C+=1<<I,1===e&&C>852||2===e&&C>592)return 1;d=L&u,n[d]=m<<24|I<<16|h-s}}return 0!==L&&(n[h+L]=p-R<<24|64<<16),a.bits=m,0};const{Z_FINISH:Qn,Z_BLOCK:Zn,Z_TREES:Xn,Z_OK:es,Z_STREAM_END:ts,Z_NEED_DICT:is,Z_STREAM_ERROR:rs,Z_DATA_ERROR:ns,Z_MEM_ERROR:ss,Z_BUF_ERROR:os,Z_DEFLATED:as}=Sr,ls=16180,_s=16190,cs=16191,ds=16192,us=16194,hs=16199,gs=16200,ps=16206,fs=16209,Es=e=>(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24);function Ts(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const ms=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.mode<ls||t.mode>16211?1:0},Is=e=>{if(ms(e))return rs;const t=e.state;return e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=ls,t.last=0,t.havedict=0,t.flags=-1,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(852),t.distcode=t.distdyn=new Int32Array(592),t.sane=1,t.back=-1,es},Rs=e=>{if(ms(e))return rs;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,Is(e)},Ss=(e,t)=>{let i;if(ms(e))return rs;const r=e.state;return t<0?(i=0,t=-t):(i=5+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?rs:(null!==r.window&&r.wbits!==t&&(r.window=null),r.wrap=i,r.wbits=t,Rs(e))},Cs=(e,t)=>{if(!e)return rs;const i=new Ts;e.state=i,i.strm=e,i.window=null,i.mode=ls;const r=Ss(e,t);return r!==es&&(e.state=null),r};let Ls,Os,vs=!0;const bs=e=>{if(vs){Ls=new Int32Array(512),Os=new Int32Array(32);let t=0;for(;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(zn(1,e.lens,0,288,Ls,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;zn(2,e.lens,0,32,Os,0,e.work,{bits:5}),vs=!1}e.lencode=Ls,e.lenbits=9,e.distcode=Os,e.distbits=5},As=(e,t,i,r)=>{let n;const s=e.state;return null===s.window&&(s.wsize=1<<s.wbits,s.wnext=0,s.whave=0,s.window=new Uint8Array(s.wsize)),r>=s.wsize?(s.window.set(t.subarray(i-s.wsize,i),0),s.wnext=0,s.whave=s.wsize):(n=s.wsize-s.wnext,n>r&&(n=r),s.window.set(t.subarray(i-r,i-r+n),s.wnext),(r-=n)?(s.window.set(t.subarray(i-r,i),0),s.wnext=r,s.whave=s.wsize):(s.wnext+=n,s.wnext===s.wsize&&(s.wnext=0),s.whave<s.wsize&&(s.whave+=n))),0};var ys={inflateReset:Rs,inflateReset2:Ss,inflateResetKeep:Is,inflateInit:e=>Cs(e,15),inflateInit2:Cs,inflate:(e,t)=>{let i,r,n,s,o,a,l,_,c,d,u,h,g,p,f,E,T,m,I,R,S,C,L=0;const O=new Uint8Array(4);let v,b;const A=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(ms(e)||!e.output||!e.input&&0!==e.avail_in)return rs;i=e.state,i.mode===cs&&(i.mode=ds),o=e.next_out,n=e.output,l=e.avail_out,s=e.next_in,r=e.input,a=e.avail_in,_=i.hold,c=i.bits,d=a,u=l,C=es;e:for(;;)switch(i.mode){case ls:if(0===i.wrap){i.mode=ds;break}for(;c<16;){if(0===a)break e;a--,_+=r[s++]<<c,c+=8}if(2&i.wrap&&35615===_){0===i.wbits&&(i.wbits=15),i.check=0,O[0]=255&_,O[1]=_>>>8&255,i.check=Ir(i.check,O,2,0),_=0,c=0,i.mode=16181;break}if(i.head&&(i.head.done=!1),!(1&i.wrap)||(((255&_)<<8)+(_>>8))%31){e.msg="incorrect header check",i.mode=fs;break}if((15&_)!==as){e.msg="unknown compression method",i.mode=fs;break}if(_>>>=4,c-=4,S=8+(15&_),0===i.wbits&&(i.wbits=S),S>15||S>i.wbits){e.msg="invalid window size",i.mode=fs;break}i.dmax=1<<i.wbits,i.flags=0,e.adler=i.check=1,i.mode=512&_?16189:cs,_=0,c=0;break;case 16181:for(;c<16;){if(0===a)break e;a--,_+=r[s++]<<c,c+=8}if(i.flags=_,(255&i.flags)!==as){e.msg="unknown compression method",i.mode=fs;break}if(57344&i.flags){e.msg="unknown header flags set",i.mode=fs;break}i.head&&(i.head.text=_>>8&1),512&i.flags&&4&i.wrap&&(O[0]=255&_,O[1]=_>>>8&255,i.check=Ir(i.check,O,2,0)),_=0,c=0,i.mode=16182;case 16182:for(;c<32;){if(0===a)break e;a--,_+=r[s++]<<c,c+=8}i.head&&(i.head.time=_),512&i.flags&&4&i.wrap&&(O[0]=255&_,O[1]=_>>>8&255,O[2]=_>>>16&255,O[3]=_>>>24&255,i.check=Ir(i.check,O,4,0)),_=0,c=0,i.mode=16183;case 16183:for(;c<16;){if(0===a)break e;a--,_+=r[s++]<<c,c+=8}i.head&&(i.head.xflags=255&_,i.head.os=_>>8),512&i.flags&&4&i.wrap&&(O[0]=255&_,O[1]=_>>>8&255,i.check=Ir(i.check,O,2,0)),_=0,c=0,i.mode=16184;case 16184:if(1024&i.flags){for(;c<16;){if(0===a)break e;a--,_+=r[s++]<<c,c+=8}i.length=_,i.head&&(i.head.extra_len=_),512&i.flags&&4&i.wrap&&(O[0]=255&_,O[1]=_>>>8&255,i.check=Ir(i.check,O,2,0)),_=0,c=0}else i.head&&(i.head.extra=null);i.mode=16185;case 16185:if(1024&i.flags&&(h=i.length,h>a&&(h=a),h&&(i.head&&(S=i.head.extra_len-i.length,i.head.extra||(i.head.extra=new Uint8Array(i.head.extra_len)),i.head.extra.set(r.subarray(s,s+h),S)),512&i.flags&&4&i.wrap&&(i.check=Ir(i.check,r,h,s)),a-=h,s+=h,i.length-=h),i.length))break e;i.length=0,i.mode=16186;case 16186:if(2048&i.flags){if(0===a)break e;h=0;do{S=r[s+h++],i.head&&S&&i.length<65536&&(i.head.name+=String.fromCharCode(S))}while(S&&h<a);if(512&i.flags&&4&i.wrap&&(i.check=Ir(i.check,r,h,s)),a-=h,s+=h,S)break e}else i.head&&(i.head.name=null);i.length=0,i.mode=16187;case 16187:if(4096&i.flags){if(0===a)break e;h=0;do{S=r[s+h++],i.head&&S&&i.length<65536&&(i.head.comment+=String.fromCharCode(S))}while(S&&h<a);if(512&i.flags&&4&i.wrap&&(i.check=Ir(i.check,r,h,s)),a-=h,s+=h,S)break e}else i.head&&(i.head.comment=null);i.mode=16188;case 16188:if(512&i.flags){for(;c<16;){if(0===a)break e;a--,_+=r[s++]<<c,c+=8}if(4&i.wrap&&_!==(65535&i.check)){e.msg="header crc mismatch",i.mode=fs;break}_=0,c=0}i.head&&(i.head.hcrc=i.flags>>9&1,i.head.done=!0),e.adler=i.check=0,i.mode=cs;break;case 16189:for(;c<32;){if(0===a)break e;a--,_+=r[s++]<<c,c+=8}e.adler=i.check=Es(_),_=0,c=0,i.mode=_s;case _s:if(0===i.havedict)return e.next_out=o,e.avail_out=l,e.next_in=s,e.avail_in=a,i.hold=_,i.bits=c,is;e.adler=i.check=1,i.mode=cs;case cs:if(t===Zn||t===Xn)break e;case ds:if(i.last){_>>>=7&c,c-=7&c,i.mode=ps;break}for(;c<3;){if(0===a)break e;a--,_+=r[s++]<<c,c+=8}switch(i.last=1&_,_>>>=1,c-=1,3&_){case 0:i.mode=16193;break;case 1:if(bs(i),i.mode=hs,t===Xn){_>>>=2,c-=2;break e}break;case 2:i.mode=16196;break;case 3:e.msg="invalid block type",i.mode=fs}_>>>=2,c-=2;break;case 16193:for(_>>>=7&c,c-=7&c;c<32;){if(0===a)break e;a--,_+=r[s++]<<c,c+=8}if((65535&_)!=(_>>>16^65535)){e.msg="invalid stored block lengths",i.mode=fs;break}if(i.length=65535&_,_=0,c=0,i.mode=us,t===Xn)break e;case us:i.mode=16195;case 16195:if(h=i.length,h){if(h>a&&(h=a),h>l&&(h=l),0===h)break e;n.set(r.subarray(s,s+h),o),a-=h,s+=h,l-=h,o+=h,i.length-=h;break}i.mode=cs;break;case 16196:for(;c<14;){if(0===a)break e;a--,_+=r[s++]<<c,c+=8}if(i.nlen=257+(31&_),_>>>=5,c-=5,i.ndist=1+(31&_),_>>>=5,c-=5,i.ncode=4+(15&_),_>>>=4,c-=4,i.nlen>286||i.ndist>30){e.msg="too many length or distance symbols",i.mode=fs;break}i.have=0,i.mode=16197;case 16197:for(;i.have<i.ncode;){for(;c<3;){if(0===a)break e;a--,_+=r[s++]<<c,c+=8}i.lens[A[i.have++]]=7&_,_>>>=3,c-=3}for(;i.have<19;)i.lens[A[i.have++]]=0;if(i.lencode=i.lendyn,i.lenbits=7,v={bits:i.lenbits},C=zn(0,i.lens,0,19,i.lencode,0,i.work,v),i.lenbits=v.bits,C){e.msg="invalid code lengths set",i.mode=fs;break}i.have=0,i.mode=16198;case 16198:for(;i.have<i.nlen+i.ndist;){for(;L=i.lencode[_&(1<<i.lenbits)-1],f=L>>>24,E=L>>>16&255,T=65535&L,!(f<=c);){if(0===a)break e;a--,_+=r[s++]<<c,c+=8}if(T<16)_>>>=f,c-=f,i.lens[i.have++]=T;else{if(16===T){for(b=f+2;c<b;){if(0===a)break e;a--,_+=r[s++]<<c,c+=8}if(_>>>=f,c-=f,0===i.have){e.msg="invalid bit length repeat",i.mode=fs;break}S=i.lens[i.have-1],h=3+(3&_),_>>>=2,c-=2}else if(17===T){for(b=f+3;c<b;){if(0===a)break e;a--,_+=r[s++]<<c,c+=8}_>>>=f,c-=f,S=0,h=3+(7&_),_>>>=3,c-=3}else{for(b=f+7;c<b;){if(0===a)break e;a--,_+=r[s++]<<c,c+=8}_>>>=f,c-=f,S=0,h=11+(127&_),_>>>=7,c-=7}if(i.have+h>i.nlen+i.ndist){e.msg="invalid bit length repeat",i.mode=fs;break}for(;h--;)i.lens[i.have++]=S}}if(i.mode===fs)break;if(0===i.lens[256]){e.msg="invalid code -- missing end-of-block",i.mode=fs;break}if(i.lenbits=9,v={bits:i.lenbits},C=zn(1,i.lens,0,i.nlen,i.lencode,0,i.work,v),i.lenbits=v.bits,C){e.msg="invalid literal/lengths set",i.mode=fs;break}if(i.distbits=6,i.distcode=i.distdyn,v={bits:i.distbits},C=zn(2,i.lens,i.nlen,i.ndist,i.distcode,0,i.work,v),i.distbits=v.bits,C){e.msg="invalid distances set",i.mode=fs;break}if(i.mode=hs,t===Xn)break e;case hs:i.mode=gs;case gs:if(a>=6&&l>=258){e.next_out=o,e.avail_out=l,e.next_in=s,e.avail_in=a,i.hold=_,i.bits=c,Jn(e,u),o=e.next_out,n=e.output,l=e.avail_out,s=e.next_in,r=e.input,a=e.avail_in,_=i.hold,c=i.bits,i.mode===cs&&(i.back=-1);break}for(i.back=0;L=i.lencode[_&(1<<i.lenbits)-1],f=L>>>24,E=L>>>16&255,T=65535&L,!(f<=c);){if(0===a)break e;a--,_+=r[s++]<<c,c+=8}if(E&&!(240&E)){for(m=f,I=E,R=T;L=i.lencode[R+((_&(1<<m+I)-1)>>m)],f=L>>>24,E=L>>>16&255,T=65535&L,!(m+f<=c);){if(0===a)break e;a--,_+=r[s++]<<c,c+=8}_>>>=m,c-=m,i.back+=m}if(_>>>=f,c-=f,i.back+=f,i.length=T,0===E){i.mode=16205;break}if(32&E){i.back=-1,i.mode=cs;break}if(64&E){e.msg="invalid literal/length code",i.mode=fs;break}i.extra=15&E,i.mode=16201;case 16201:if(i.extra){for(b=i.extra;c<b;){if(0===a)break e;a--,_+=r[s++]<<c,c+=8}i.length+=_&(1<<i.extra)-1,_>>>=i.extra,c-=i.extra,i.back+=i.extra}i.was=i.length,i.mode=16202;case 16202:for(;L=i.distcode[_&(1<<i.distbits)-1],f=L>>>24,E=L>>>16&255,T=65535&L,!(f<=c);){if(0===a)break e;a--,_+=r[s++]<<c,c+=8}if(!(240&E)){for(m=f,I=E,R=T;L=i.distcode[R+((_&(1<<m+I)-1)>>m)],f=L>>>24,E=L>>>16&255,T=65535&L,!(m+f<=c);){if(0===a)break e;a--,_+=r[s++]<<c,c+=8}_>>>=m,c-=m,i.back+=m}if(_>>>=f,c-=f,i.back+=f,64&E){e.msg="invalid distance code",i.mode=fs;break}i.offset=T,i.extra=15&E,i.mode=16203;case 16203:if(i.extra){for(b=i.extra;c<b;){if(0===a)break e;a--,_+=r[s++]<<c,c+=8}i.offset+=_&(1<<i.extra)-1,_>>>=i.extra,c-=i.extra,i.back+=i.extra}if(i.offset>i.dmax){e.msg="invalid distance too far back",i.mode=fs;break}i.mode=16204;case 16204:if(0===l)break e;if(h=u-l,i.offset>h){if(h=i.offset-h,h>i.whave&&i.sane){e.msg="invalid distance too far back",i.mode=fs;break}h>i.wnext?(h-=i.wnext,g=i.wsize-h):g=i.wnext-h,h>i.length&&(h=i.length),p=i.window}else p=n,g=o-i.offset,h=i.length;h>l&&(h=l),l-=h,i.length-=h;do{n[o++]=p[g++]}while(--h);0===i.length&&(i.mode=gs);break;case 16205:if(0===l)break e;n[o++]=i.length,l--,i.mode=gs;break;case ps:if(i.wrap){for(;c<32;){if(0===a)break e;a--,_|=r[s++]<<c,c+=8}if(u-=l,e.total_out+=u,i.total+=u,4&i.wrap&&u&&(e.adler=i.check=i.flags?Ir(i.check,n,u,o-u):Tr(i.check,n,u,o-u)),u=l,4&i.wrap&&(i.flags?_:Es(_))!==i.check){e.msg="incorrect data check",i.mode=fs;break}_=0,c=0}i.mode=16207;case 16207:if(i.wrap&&i.flags){for(;c<32;){if(0===a)break e;a--,_+=r[s++]<<c,c+=8}if(4&i.wrap&&_!==(4294967295&i.total)){e.msg="incorrect length check",i.mode=fs;break}_=0,c=0}i.mode=16208;case 16208:C=ts;break e;case fs:C=ns;break e;case 16210:return ss;default:return rs}return e.next_out=o,e.avail_out=l,e.next_in=s,e.avail_in=a,i.hold=_,i.bits=c,(i.wsize||u!==e.avail_out&&i.mode<fs&&(i.mode<ps||t!==Qn))&&As(e,e.output,e.next_out,u-e.avail_out),d-=e.avail_in,u-=e.avail_out,e.total_in+=d,e.total_out+=u,i.total+=u,4&i.wrap&&u&&(e.adler=i.check=i.flags?Ir(i.check,n,u,e.next_out-u):Tr(i.check,n,u,e.next_out-u)),e.data_type=i.bits+(i.last?64:0)+(i.mode===cs?128:0)+(i.mode===hs||i.mode===us?256:0),(0===d&&0===u||t===Qn)&&C===es&&(C=os),C},inflateEnd:e=>{if(ms(e))return rs;let t=e.state;return t.window&&(t.window=null),e.state=null,es},inflateGetHeader:(e,t)=>{if(ms(e))return rs;const i=e.state;return 2&i.wrap?(i.head=t,t.done=!1,es):rs},inflateSetDictionary:(e,t)=>{const i=t.length;let r,n,s;return ms(e)?rs:(r=e.state,0!==r.wrap&&r.mode!==_s?rs:r.mode===_s&&(n=1,n=Tr(n,t,i,0),n!==r.check)?ns:(s=As(e,t,i,i),s?(r.mode=16210,ss):(r.havedict=1,es)))},inflateInfo:"pako inflate (from Nodeca project)"};var Ns=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1};const Ps=Object.prototype.toString,{Z_NO_FLUSH:Us,Z_FINISH:Ds,Z_OK:Ms,Z_STREAM_END:ws,Z_NEED_DICT:ks,Z_STREAM_ERROR:xs,Z_DATA_ERROR:Bs,Z_MEM_ERROR:Vs}=Sr;function Gs(e){this.options=Sn({chunkSize:65536,windowBits:15,to:""},e||{});const t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&(15&t.windowBits||(t.windowBits|=15)),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new yn,this.strm.avail_out=0;let i=ys.inflateInit2(this.strm,t.windowBits);if(i!==Ms)throw new Error(Rr[i]);if(this.header=new Ns,ys.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=vn(t.dictionary):"[object ArrayBuffer]"===Ps.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(i=ys.inflateSetDictionary(this.strm,t.dictionary),i!==Ms)))throw new Error(Rr[i])}Gs.prototype.push=function(e,t){const i=this.strm,r=this.options.chunkSize,n=this.options.dictionary;let s,o,a;if(this.ended)return!1;for(o=t===~~t?t:!0===t?Ds:Us,"[object ArrayBuffer]"===Ps.call(e)?i.input=new Uint8Array(e):i.input=e,i.next_in=0,i.avail_in=i.input.length;;){for(0===i.avail_out&&(i.output=new Uint8Array(r),i.next_out=0,i.avail_out=r),s=ys.inflate(i,o),s===ks&&n&&(s=ys.inflateSetDictionary(i,n),s===Ms?s=ys.inflate(i,o):s===Bs&&(s=ks));i.avail_in>0&&s===ws&&i.state.wrap>0&&0!==e[i.next_in];)ys.inflateReset(i),s=ys.inflate(i,o);switch(s){case xs:case Bs:case ks:case Vs:return this.onEnd(s),this.ended=!0,!1}if(a=i.avail_out,i.next_out&&(0===i.avail_out||s===ws))if("string"===this.options.to){let e=An(i.output,i.next_out),t=i.next_out-e,n=bn(i.output,e);i.next_out=t,i.avail_out=r-t,t&&i.output.set(i.output.subarray(e,e+t),0),this.onData(n)}else this.onData(i.output.length===i.next_out?i.output:i.output.subarray(0,i.next_out));if(s!==Ms||0!==a){if(s===ws)return s=ys.inflateEnd(this.strm),this.onEnd(s),this.ended=!0,!0;if(0===i.avail_in)break}}return!0},Gs.prototype.onData=function(e){this.chunks.push(e)},Gs.prototype.onEnd=function(e){e===Ms&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=Cn(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};const{Deflate:Fs,deflate:js,deflateRaw:Hs,gzip:Js}=jn;var $s=Js;const Ks=-1,Ys="RongCloudSEIAI",qs=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}),Ws=(e,t,i)=>I(void 0,void 0,void 0,function*(){const r=[],n=i.jwtToken||"";return new Promise((i,s)=>{e.forEach(e=>I(void 0,void 0,void 0,function*(){const s=`${e.detectorAddr.replace(/^(https?:\/\/)?/,"https://")}/rtc/detector/ping?t=${o=1e3,a=9999,o+Math.floor(Math.random()*(a-o))}`;var o,a;const l={jwt:n};200===(yield t.httpReq({url:s,body:JSON.stringify(l),timeout:5e3,method:V.POST})).status&&r.push(e.clusterId),i(r)}))})}),zs=(e,t)=>{var i;if(!t)return"";let r;try{r=JSON.parse(t.voipCallInfo||'{ "strategy": 0 }')}catch(i){return e.warn(he.L_MEDIA_SERVICE_PARSE_NAVI_CALLVOIP_INFO_O,`parse \`voipCallInfo\` of navi failed: ${t.voipCallInfo}`),""}if(0===r.strategy)return"";const n=null===(i=r.callEngine)||void 0===i?void 0:i.filter(e=>4===e.engineType);if(!n||0===n.length)return"";const s=n[0];return s.detectorManager?s.detectorManager:""};var Qs;!function(e){e.OPEN="2",e.CLOSE="1"}(Qs||(Qs={}));function Zs(e){const t=e.method||V.GET,i=e.timeout||6e4,{headers:r,query:n,body:s,onProgress:o}=e,a=((e,t)=>{if(e=e.replace(/\?$/,""),!t)return e;const i=Object.keys(t).map(e=>`${e}=${t[e]}`).filter(e=>!!e);return i.length?[e,i.join("&")].join("?"):e})(e.url,n),l=new XMLHttpRequest;if(l.open(t,a),r&&l.setRequestHeader)for(const e in r)l.setRequestHeader(e,r[e]);return function(e,t,i,r){return new Promise(n=>{e.onreadystatechange=()=>{r?2===e.readyState?n({data:e.responseText,status:e.status,xhr:e}):4===e.readyState?r(e.responseText,!0):3===e.readyState&&r(e.responseText,!1):4===e.readyState&&n({data:e.responseText,status:e.status,xhr:e})},e.onerror=()=>{n({status:e.status})},0!==t&&setTimeout(()=>{e.abort(),n({status:e.status})},t),e.send(i)})}(l,i,s,o)}const Xs=()=>({"Content-Type":"application/json;charset=UTF-8","Cache-Control":"no-cache",ClientType:`web|${Ci.browser}|${Ci.version}`,ClientVersion:"26.1.0","Client-Session-Id":qs(),"Request-Id":Date.now().toString()});class eo{constructor(e,t,i,r=5e3){Object.defineProperty(this,"_runtime",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_msUrl",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_timeout",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_failedMs",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_rtcFinger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_clusterId",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(this,"_configUrl",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(this,"_msList",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_qualityMsList",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._logger=this._context.logger,t.getConnectionStatus()===l.CONNECTED&&this.isNededDetector()&&this.detectorMediaSever()}isNededDetector(){const e=this._context.getNaviInfo();if(!e)return!1;const t=zs(this._logger,e),i=e.jwtToken||"",r=Date.now();let n=!1;return 0===eo.detectorTime?n=!1:eo.detectValidMinute+eo.detectorTime<r&&(n=!0),!(!t||!i||this._msUrl||n)}detectorMediaSever(){this.clearMSList();const e=this._context.getNaviInfo();this._startDetector(e)}_startDetector(e){return I(this,void 0,void 0,function*(){var t;const{detectoraddrs:i,clientDetectMinute:r,status:n}=yield((e,t,i)=>I(void 0,void 0,void 0,function*(){const r=zs(t,i);let n=120,s=0;const o={jwt:i.jwtToken||"",ipType:i.ipType||0},a=yield e.httpReq({url:`${r}/rtc/detector/servers`,body:JSON.stringify(o),headers:{"Content-Type":"application/json;charset=UTF-8","Cache-Control":"no-cache",ClientType:`web|${Ci.browser}|${Ci.version}`,ClientVersion:"26.1.0","Client-Session-Id":qs(),"Request-Id":Date.now().toString()},method:V.POST}),l=a.data&&JSON.parse(a.data).detectorAddrs||[];return n=a.data&&JSON.parse(a.data).clientDetectMinute,s=a.data&&JSON.parse(a.data).resultCode,{detectoraddrs:l,clientDetectMinute:n,status:s}}))(this._runtime,this._logger,e);if(n===ue.JWT_TIME_OUT){const e=this._context.getPluginContext();return yield null===(t=e.refetchNaviInfo)||void 0===t?void 0:t.call(e),void this.detectorMediaSever()}i.length&&(eo.msInDetector=yield Ws(i,this._runtime,e)),eo.detectorTime=Date.now(),eo.detectValidMinute=60*r*1e3})}clearMSList(){this._msList.length=0}getMsList(){return this._msUrl?[this._msUrl]:(this._sortMediaServiceList(),[...this._msList])}_sortMediaServiceList(){let e=eo.msInDetector[0];const t=eo.msInDetector.slice(1),i=((e,t)=>{var i;if(!e)return[];let r;try{r=JSON.parse(e.voipCallInfo||'{ "strategy": 0 }')}catch(i){return t.warn(he.L_PARSE_VOIP_SERVER_CONF_E,e.voipCallInfo),[]}if(0===r.strategy)return[];const n=null===(i=r.callEngine)||void 0===i?void 0:i.filter(e=>4===e.engineType);if(!n||0===n.length)return[];const s=n[0],o=[];return s.mediaServer&&o.push(s.mediaServer.replace(/^(https?:\/\/)?/,"https://")),s.backupMediaServer&&s.backupMediaServer.forEach(e=>{o.push(e.replace(/^(https?:\/\/)?/,"https://"))}),o})(this._context.getNaviInfo(),this._logger),r=i[0],n=i.slice(1);const s=[this._clusterId,e,r,...t,...n].filter(e=>!!e).map(e=>e.replace(/^(https?:\/\/)?/,"https://"));this._msList=[...new Set(s)],this._logger.info(he.L_MEDIA_SERVICE_MSLIST_CHANGE_O,`MediaServiceList msList -> ${JSON.stringify(this._msList)}`)}_openGzip(e,t){const i=JSON.stringify(t),r=i.length,n=new Uint8Array(r);for(let e=0;e<r;e++)n[e]=i.charCodeAt(e);var s;return{headers:e=Object.assign(Object.assign({},e),{"Content-Encoding":"gzip","Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"}),body:t=$s(n,s)}}_dealRequestSuccessResult(e){const t=JSON.parse(e);return t.rtcFinger&&(this._rtcFinger=t.rtcFinger),t.clusterId&&(this._clusterId!==t.clusterId&&this.clearMSList(),this._clusterId=t.clusterId),{code:ue.SUCCESS,data:t,qualityMsList:this._qualityMsList}}_request(e,t,i,r,n,s){return I(this,void 0,void 0,function*(){this._qualityMsList=[];const{headers:o,body:a}={headers:t,body:i},l=this.getMsList();if(0===l.length)return this._logger.error(he.L_MEDIA_SERVICE_REQUEST_R,JSON.stringify({status:ge.FAILED,code:ue.NOT_OPEN_VIDEO_AUDIO_SERVER,msg:"have no valid service address"}),r),{code:ue.NOT_OPEN_VIDEO_AUDIO_SERVER};this._rtcFinger&&(a.rtcFinger=this._rtcFinger);for(let t=0;t<l.length;t+=1){const i=Date.now(),_=`${l[t]}${e}`,c=Xs(),d=Object.assign(Object.assign({},c),o),u=/x-www-form-urlencoded/.test(d["Content-Type"])?a:JSON.stringify(a),h=c["Request-Id"];let g;this._logger.info(he.L_MEDIA_SERVICE_REQUEST_T,JSON.stringify({url:_,"Request-Id":h}),r);const p={url:_,body:u,headers:d,method:V.POST,timeout:this._timeout};g=s?yield Zs(Object.assign(Object.assign({},p),{onProgress:s})):yield this._runtime.httpReq(Object.assign({},p));const{status:f,data:E,xhr:T}=g;if(n&&this._qualityMsList.push({rsdur:Date.now()-i,rsid:h,rscod:200===f?ue.SUCCESS:ue.REQUEST_FAILED,msa:_}),200===f)return this._logger.info(he.L_MEDIA_SERVICE_REQUEST_R,JSON.stringify({status:ge.SUCCESSED,url:_}),r),s?{code:ue.SUCCESS,data:T}:this._dealRequestSuccessResult(E);this._logger.error(he.L_MEDIA_SERVICE_REQUEST_R,JSON.stringify({status:ge.FAILED,msg:`request error -> Request-Id: ${h}, status: ${f}, url: ${_}`,timeout:this._timeout}),r)}return{code:ue.REQUEST_FAILED,qualityMsList:this._qualityMsList}})}exchange(e,t,i,r){return I(this,void 0,void 0,function*(){var n;const s=yield this._request("/exchange",e,t,i,r);if(s.code===ue.SUCCESS&&(null===(n=s.data)||void 0===n?void 0:n.resultCode)===ue.SUCCESS){const{urls:e}=s.data;e&&(this._configUrl=e.configUrl)}return s})}exit(e){return I(this,void 0,void 0,function*(){const t=this._logger.createTraceId(),{code:i}=yield this._request("/exit",e,{},t);return i})}broadcastSubscribe(e,t){const i=this._logger.createTraceId();return this._request("/broadcast/subscribe",e,t,i,!0)}broadcastExit(e){return I(this,void 0,void 0,function*(){const t=this._logger.createTraceId(),{code:i}=yield this._request("/broadcast/exit",e,{},t,!0);return{code:i}})}setMcuConfig(e,t){return I(this,void 0,void 0,function*(){const i=this._logger.createTraceId();if(this._logger.info(he.L_MEDIA_SERVICE_SET_MCU_CONFIG_T,JSON.stringify({body:t}),i),!this._configUrl)return this._logger.error(he.L_MEDIA_SERVICE_SET_MCU_CONFIG_R,JSON.stringify({status:ge.FAILED,code:ue.MCU_SERVER_NOT_FOUND,msg:"MCU server not found"}),i),{code:ue.MCU_SERVER_NOT_FOUND};const r=`${this._configUrl.replace(/^(https?:\/\/)?/,"https://")}/server/mcu/config`,n=Xs(),s=Object.assign(Object.assign({},n),e),o=JSON.stringify(t),a=n["Request-Id"],{status:l,data:_}=yield this._runtime.httpReq({url:r,headers:s,body:o,method:V.POST});if(200===l){const e=JSON.parse(_),t=e.resultCode;return t===ue.SUCCESS?this._logger.info(he.L_MEDIA_SERVICE_SET_MCU_CONFIG_R,JSON.stringify({status:ge.SUCCESSED,"Request-Id":a}),i):this._logger.warn(he.L_MEDIA_SERVICE_SET_MCU_CONFIG_R,JSON.stringify({code:t,"Request-Id":a}),i),{code:t,res:e}}return this._logger.error(he.L_MEDIA_SERVICE_SET_MCU_CONFIG_R,JSON.stringify({status:ge.FAILED,code:ue.REQUEST_FAILED,msg:`request error -> Request-Id: ${a}, status: ${l}, url: ${r}`}),i),{code:ue.REQUEST_FAILED}})}getCDNResourceInfo(e,t,i){return I(this,void 0,void 0,function*(){const r=Xs(),n=Object.assign(Object.assign({},r),e),s=r["Request-Id"];this._logger.info(he.L_MEDIA_SERVICE_GET_CDN_RESOURCE_INFO_T,`Request-Id: ${s}, url: ${t}`,i);const{status:o,data:a}=yield this._runtime.httpReq({url:t,headers:n,method:V.GET});if(200===o){const e=JSON.parse(a);return this._logger.info(he.L_MEDIA_SERVICE_GET_CDN_RESOURCE_INFO_R,JSON.stringify({status:ge.SUCCESSED,cdnPlayerUrl:null==e?void 0:e.data.pull_url}),i),{code:e.resultCode,res:e}}return this._logger.info(he.L_MEDIA_SERVICE_GET_CDN_RESOURCE_INFO_R,JSON.stringify({status:ge.FAILED,code:ue.REQUEST_FAILED}),i),{code:ue.REQUEST_FAILED}})}updateASRStatus(e,t,i){return I(this,void 0,void 0,function*(){return yield this._request("/rtc/media/v1/asr/update",e,t,i)})}operateRealtimeTranslation(e,t,i){return I(this,void 0,void 0,function*(){return yield this._request("/rtc/media/v1/asr/translation",e,t,i)})}operateSummarization(e,t,i){return I(this,void 0,void 0,function*(){const r="/rtc/media/v1/ai/room/sum/"+(t.status===Qs.OPEN?"start":"stop");return yield this._request(r,e,t,i)})}generateSummarization(e,t,i,r,n,s,o){return I(this,void 0,void 0,function*(){const a={"App-Key":this._context.getAppkey(),UserId:this._context.getCurrentId(),RoomId:e,"X-Stream":!0},l={taskId:t,startTime:i,endTime:r,config:{summarization:n.enableSummarization,summarizationDetails:n.enableSummarizationDetails,chapterSummary:n.enableChapterSummary,todoList:n.enableTodoList,hashtag:n.enableHashtag,language:n.destLang,format:n.format,custom:n.customPrompt}},{code:_,data:c}=yield this._request("/rtc/media/v1/ai/room/sum/gen",a,l,o,!1,(e,t)=>{s(e,t)}),d=null==c?void 0:c.getResponseHeader("x-code"),u=null==c?void 0:c.getResponseHeader("x-msg");return _===ue.SUCCESS&&d&&Number(d)!==ue.SUCCESS?{code:Number(d),msg:u}:{code:_}})}getASRContent(e,t,i,r,n,s,o){return I(this,void 0,void 0,function*(){const a={"App-Key":this._context.getAppkey(),UserId:this._context.getCurrentId(),RoomId:e,"X-Stream":!0},l={taskId:t,startTime:i,endTime:r,language:o},{code:_,data:c}=yield this._request("/rtc/media/v1/ai/room/sum/asr",a,l,s,!1,(e,t)=>{n(e,t)}),d=null==c?void 0:c.getResponseHeader("x-code"),u=null==c?void 0:c.getResponseHeader("x-msg");return _===ue.SUCCESS&&d&&Number(d)!==ue.SUCCESS?{code:Number(d),msg:u}:{code:_}})}}var to;Object.defineProperty(eo,"msInDetector",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(eo,"detectorTime",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(eo,"detectValidMinute",{enumerable:!0,configurable:!0,writable:!0,value:72e5}),function(e){e[e.NORMAL=1]="NORMAL",e[e.TINY=2]="TINY"}(to||(to={}));const io=(e,t)=>Math.round(8*t/e),ro=(e,t=2)=>{const i=10**t;return Math.round(e*i)/i},no=(e,t=2)=>{e>1&&(e=1);const i=10**t;return Math.round(e*i)},so=(e,t,i,r)=>{if(0===t)return 0;if(!i||!r)return ro(e/t,3);const n=t-r;if(0===n)return 0;const s=e-i;return s<0||n<0?0:ro(s/n,3)},oo=e=>{const{jitter:t,rtt:i,packetsLostRate:r}=e;return!vi(t)||!vi(i)||0!==r};var ao,lo;!function(e){e.TRACK="track",e.STREAM="stream",e.MEDIASOURCE="media-source",e.INBOUNDRTP="inbound-rtp",e.OUTBOUNDRTP="outbound-rtp",e.REMOTEINBOUNDRTP="remote-inbound-rtp",e.PEERCONNECTION="peer-connection",e.TRANSPORT="transport",e.CERTIFICATE="certificate",e.CANDIDATEPAIR="candidate-pair",e.REMOTECANDIDATE="remote-candidate",e.LOCALCANDIDATE="local-candidate"}(ao||(ao={}));class _o{constructor(e,t,i,r,n,s){Object.defineProperty(this,"_sdpStrategy",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_rtcPeerConn",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_sdpSemantics",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_currentUserId",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"_store",{enumerable:!0,configurable:!0,writable:!0,value:s}),Object.defineProperty(this,"_latestPacketsSent",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_latestBytesSent",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_latestBytesRecv",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_latestPacketsRecv",{enumerable:!0,configurable:!0,writable:!0,value:{}})}getTrackIdByMid(e){return this._sdpStrategy.getTrackIdByMid(e)}updateBytesSent(e,t,i){let r,n;if(this._latestBytesSent[e]&&t<this._latestBytesSent[e].bytesSent&&this.clearLatestpacketsSent([e]),this._latestBytesSent[e]){const{bytesSent:s,timestamp:o}=this._latestBytesSent[e];r=t-s,n=i-o,this._latestBytesSent[e]={bytesSent:t,timestamp:i}}else r=t,n=1e3,this._latestBytesSent[e]={bytesSent:t,timestamp:i};return io(n,r)}updateBytesRecv(e,t,i){let r,n;if(this._latestBytesRecv[e]&&t<this._latestBytesRecv[e].bytesRecv&&this.clearLatestPacketsRecv([e]),this._latestBytesRecv[e]){const{bytesRecv:s,timestamp:o}=this._latestBytesRecv[e];r=t-s,n=i-o,this._latestBytesRecv[e]={bytesRecv:t,timestamp:i}}else r=t,n=1e3,this._latestBytesRecv[e]={bytesRecv:t,timestamp:i};return io(n,r)}updateSenderPacketsLost(e,t,i){let r;if(Object.prototype.hasOwnProperty.call(this._latestPacketsSent[e],"packetsSent")){const{packetsLost:n,packetsSent:s}=this._latestPacketsSent[e];r=so(t,i,n,s),this._latestPacketsSent[e].packetsLost=t,this._latestPacketsSent[e].packetsSent=n===t?s:i}else r=so(t,i),this._latestPacketsSent[e].packetsLost=t,this._latestPacketsSent[e].packetsSent=i;return r}updateReceiverPacketsLost(e,t,i){let r;if(this._latestPacketsRecv[e]){const{packetsLost:n,packetsRecv:s}=this._latestPacketsRecv[e];r=so(t,i+t,n,s+n)}else r=so(t,i);return this._latestPacketsRecv[e]={packetsLost:t,packetsRecv:i},r}clearLatestpacketsSent(e){e.forEach(e=>{if(parseInt(e.split("_").pop())===Pt.VIDEO_ONLY){const t=`${e}_tiny`;delete this._latestPacketsSent[t],delete this._latestBytesSent[t]}delete this._latestPacketsSent[e],delete this._latestBytesSent[e]})}clearLatestPacketsRecv(e){e.forEach(e=>{delete this._latestPacketsRecv[e],delete this._latestBytesRecv[e]})}parseRTCStatsReport(e){const t={};for(const[i,r]of e.entries())/codec/gi.test(r)&&i.includes("RTCCodec_")||(t[i]=r);return t}formatRCRTCStateReport(e){const t={senders:[],receivers:[]};return this._logger.info(he.L_ABSTRACT_STAT_PARSER_FORMAT_RTC_STATE_REPORT_O,JSON.stringify({status:ge.SUCCESSED,stats:e,reports:t})),t}isValidTranceiver(e,t){var i,r;const n="outbound-rtp"===t?null===(i=this._rtcPeerConn.currentLocalDescription)||void 0===i?void 0:i.sdp:null===(r=this._rtcPeerConn.currentRemoteDescription)||void 0===r?void 0:r.sdp,{ssrc:s}=e;return!(null==n?void 0:n.split("\r\nm=").some(e=>e.includes(s)&&e.includes("a=inactive")))}formatStateData(e){return Object.values(e).reduce((e,t)=>t.type===ao.REMOTEINBOUNDRTP?(e.remoteInbound.push(t),e):t.type===ao.INBOUNDRTP?(e.inbound.push(t),e):t.type===ao.OUTBOUNDRTP?(e.outbound.push(t),e):t.type===ao.TRANSPORT?(e.transport.push(t),e):t.type===ao.PEERCONNECTION?(e.connection.push(t),e):e,{outbound:[],remoteInbound:[],inbound:[],transport:[],connection:[]})}}class co extends _o{formatRCRTCStateReport(e){const{outbound:t,remoteInbound:i,inbound:r,transport:n,connection:s}=this.formatStateData(e),o={senders:[],receivers:[]},a=Math.floor(s[0].timestamp);o.timestamp=a;let l=0,_=0;({totalPacketsLost:l,bitrateSend:_,senders:o.senders}=this.pickOutbound(t,e,l,a,_)),i.length>0&&o.senders.length>0&&this.pickRemoteInbound(i,o.senders,e);let c=0;if(({totalPacketsLost:l,bitrateRecv:c,receivers:o.receivers}=this.pickInbound(r,e,l,a,c)),n.length>0){const t=n[0];this.pickRtcTransport(t,e,o,c,_,l)}return o}pickRtcTransport(e,t,i,r,n,s){const{selectedCandidatePairId:o}=e;if(o){const e=t[o],{availableOutgoingBitrate:a,availableIncomingBitrate:l,currentRoundTripTime:_,localCandidateId:c,remoteCandidateId:d}=e,u=t[c],{ip:h,port:g,networkType:p}=u,f=t[d],{ip:E,port:T,protocol:m}=f;i.iceCandidatePair={IP:h,port:g,networkType:p,remoteIP:E,remotePort:T,protocol:m,bitrateRecv:r,bitrateSend:n,rtt:1e3*_,availableOutgoingBitrate:a,availableIncomingBitrate:l,totalPacketsLost:s},i.receivers.forEach(e=>{e.rtt=1e3*_})}}pickRemoteInbound(e,t,i){e.forEach(e=>{var r;const{localId:n,jitter:s,roundTripTime:o,packetsLost:a}=e,l=t.filter(e=>e.id===n)[0];if(l&&!oo(l)){const e=null===(r=this._store)||void 0===r?void 0:r.getTrackIdBySSRC(i[l.id].ssrc);l.jitter=Math.round(1e3*s),l.rtt=o;const t=this._latestPacketsSent[e].crtPacketsSent;l.packetsLostRate=this.updateSenderPacketsLost(e,a,t)}})}_getOutboundVideoAttrs(e,t,i,r,n){var s,o,a;let{framesPerSecond:l,frameWidth:_,frameHeight:c}=e;return"video"!==i||_||c||l||(_=(null===(s=t[r])||void 0===s?void 0:s.frameWidth)||t[n].width,c=(null===(o=t[r])||void 0===o?void 0:o.frameHeight)||t[n].height,l=(null===(a=t[n])||void 0===a?void 0:a.framesPerSecond)||null),{frameRate:l,frameWidth:_,frameHeight:c}}pickOutbound(e,t,i,r,n){const s=[];return e.forEach(e=>{var o;if("unified-plan"===this._sdpSemantics&&!this.isValidTranceiver(e,"outbound-rtp"))return;const{id:a,kind:l,mediaSourceId:_,remoteId:c,packetsSent:d,bytesSent:u,encoderImplementation:h,pliCount:g,nackCount:p,mid:f}=e;let{trackId:E}=e;if(void 0!==f&&(E=this.getTrackIdByMid(f)),!E)return;const{frameRate:T,frameWidth:m,frameHeight:I}=this._getOutboundVideoAttrs(e,t,l,E,_),R=t[c];let S=null,C=null,L=0;R&&(S=R.jitter,C=R.roundTripTime,L=R.packetsLost),i+=L;const O=null===(o=this._store)||void 0===o?void 0:o.getTrackIdBySSRC(e.ssrc);if(!O)return;const v=_?t[_].audioLevel:t[E].audioLevel;let b=0;!this._latestPacketsSent[O]&&(this._latestPacketsSent[O]={}),R?b=this.updateSenderPacketsLost(O,L,d):this._latestPacketsSent[O].crtPacketsSent=d;let A=this.updateBytesSent(O,u,r);A<0&&(A=0),n+=A,s.push({id:a,trackId:O,kind:l,packetsLostRate:b,remoteResource:!1,audioLevel:v||0===v?no(v):null,frameWidth:m,frameHeight:I,frameRate:T,bitrate:A,jitter:S?Math.round(1e3*S):S,rtt:C?Math.round(1e3*C):C,encoderImplementation:h,pliCount:g,nackCount:p,googFirsSent:Ks,samplingRate:Ks,googRenderDelayMs:Ks,trackState:Ks})}),{totalPacketsLost:i,bitrateSend:n,senders:s}}_getInboundMediaAttrs(e,t,i,r,n){var s,o,a;let{frameWidth:l,frameHeight:_,audioLevel:c}=e;return"video"===n?l||_||(l=(null===(s=t[i])||void 0===s?void 0:s.frameWidth)||t[r].width,_=(null===(o=t[i])||void 0===o?void 0:o.frameHeight)||t[r].height):c||(c=(null===(a=t[i])||void 0===a?void 0:a.audioLevel)||t[r].audioLevel),{frameWidth:l,frameHeight:_,audioLevel:c}}pickInbound(e,t,i,r,n){let s=[];return e.forEach(e=>{var o;if("unified-plan"===this._sdpSemantics&&!this.isValidTranceiver(e,"inbound-rtp"))return;const{packetsLost:a,packetsReceived:l,jitter:_,bytesReceived:c,framesPerSecond:d,kind:u,codecImplementationName:h,nackCount:g,pliCount:p,mid:f,id:E}=e;let{trackId:T}=e;if(void 0!==f&&(T=this.getTrackIdByMid(f)),!T)return;const{frameWidth:m,frameHeight:I,audioLevel:R}=this._getInboundMediaAttrs(e,t,T,E,u);i+=a;const S=null===(o=this._store)||void 0===o?void 0:o.getTrackIdBySSRC(e.ssrc),C=this.updateReceiverPacketsLost(S,a,l);let L=this.updateBytesRecv(S,c,r);L<0&&(L=0),n+=L,s.push({trackId:S,kind:u,packetsLostRate:C,remoteResource:!0,audioLevel:R||0===R?no(R):null,frameWidth:m,frameHeight:I,frameRate:d,bitrate:L,jitter:_?Math.round(1e3*_):0,codecImplementationName:h,nackCount:g,pliCount:p,rtt:null,samplingRate:Ks,googFirsReceived:Ks,googRenderDelayMs:Ks,trackState:Ks})}),{totalPacketsLost:i,bitrateRecv:n,receivers:s}}}class uo extends _o{constructor(){super(...arguments),Object.defineProperty(this,"_reportsData",{enumerable:!0,configurable:!0,writable:!0,value:{senders:[],receivers:[],timestamp:+new Date}}),Object.defineProperty(this,"_totalPacketsLost",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_bitrateSend",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_bitrateRecv",{enumerable:!0,configurable:!0,writable:!0,value:0})}_pickSenderData(e,t,i){var r;if("unified-plan"===this._sdpSemantics&&!this.isValidTranceiver(e,i))return;const{kind:n,bytesSent:s,packetsSent:o,bitrateMean:a,framerateMean:l,nackCount:_,pliCount:c,remoteId:d}=e,{jitter:u,roundTripTime:h,packetsLost:g}=d?t[d]:{jitter:null,roundTripTime:null,packetsLost:0},p=null===(r=this._store)||void 0===r?void 0:r.getTrackIdBySSRC(e.ssrc);this._totalPacketsLost+=g;let f=0;!this._latestPacketsSent[p]&&(this._latestPacketsSent[p]={}),d?f=this.updateSenderPacketsLost(p,g,o):this._latestPacketsSent[p].crtPacketsSent=o;let E=0;"video"===n?a&&(E=Math.floor(a/1e3)):E=this.updateBytesSent(p,s,this._reportsData.timestamp),E<0&&(E=0),this._bitrateSend+=E,this._reportsData.senders.push({trackId:p,kind:n,packetsLostRate:f,remoteResource:!1,audioLevel:null,frameWidth:null,frameHeight:null,frameRate:Math.floor(l),bitrate:E,jitter:u?Math.round(1e3*u):null,rtt:h,encoderImplementation:null,pliCount:c,nackCount:_,googFirsSent:Ks,samplingRate:Ks,googRenderDelayMs:Ks,trackState:Ks})}_addSenderData(e,t){var i;const{localId:r}=t,n=null===(i=this._store)||void 0===i?void 0:i.getTrackIdBySSRC(e[r].ssrc),s=this._reportsData.senders.filter(e=>e.trackId===n)[0];s&&oo(s)&&(s.jitter=Math.round(1e3*t.jitter),s.rtt=t.rtt,s.packetsLostRate=this.updateSenderPacketsLost(n,t.packetsLost,this._latestPacketsSent[n].crtPacketsSent))}_pickReceiverData(e,t){var i;if("unified-plan"===this._sdpSemantics&&!this.isValidTranceiver(e,t))return;const{packetsLost:r,bytesReceived:n,packetsReceived:s,jitter:o,framerateMean:a,kind:l,bitrateMean:_,nackCount:c,pliCount:d}=e,u=null===(i=this._store)||void 0===i?void 0:i.getTrackIdBySSRC(e.ssrc);this._totalPacketsLost+=r;const h=this.updateReceiverPacketsLost(u,r,s);let g=0;"video"===l?_&&(g=Math.floor(_/1e3)):g=this.updateBytesRecv(u,n,this._reportsData.timestamp),g<0&&(g=0),this._bitrateRecv+=g,this._reportsData.receivers.push({trackId:u,kind:l,packetsLostRate:h,remoteResource:!0,audioLevel:null,frameWidth:null,frameHeight:null,frameRate:Math.floor(a),bitrate:g,jitter:o?Math.round(1e3*o):null,codecImplementationName:null,nackCount:c,pliCount:d,rtt:null,samplingRate:Ks,googFirsReceived:Ks,googRenderDelayMs:Ks,trackState:Ks})}_pickIceCandidatePair(e,t){const i=e[t.localCandidateId],{address:r,port:n}=i,s=e[t.remoteCandidateId],{address:o,port:a,protocol:l}=s;this._reportsData.iceCandidatePair={IP:r,port:n,networkType:null,remoteIP:o,remotePort:a,protocol:l,bitrateRecv:this._bitrateRecv,bitrateSend:this._bitrateSend,rtt:null,availableOutgoingBitrate:null,availableIncomingBitrate:null,totalPacketsLost:this._totalPacketsLost}}formatRCRTCStateReport(e){const t=+new Date;this._reportsData={senders:[],receivers:[],timestamp:t},this._totalPacketsLost=0,this._bitrateRecv=0,this._bitrateSend=0;for(const t in e){const i=e[t],{type:r}=i;"outbound-rtp"===r&&this._pickSenderData(i,e,r),"remote-inbound-rtp"===r&&this._addSenderData(e,i),"inbound-rtp"===r&&this._pickReceiverData(i,r),"candidate-pair"===r&&"succeeded"===i.state&&this._pickIceCandidatePair(e,i)}return this._reportsData}}class ho extends _o{constructor(){super(...arguments),Object.defineProperty(this,"_reportsData",{enumerable:!0,configurable:!0,writable:!0,value:{senders:[],receivers:[],timestamp:+new Date}}),Object.defineProperty(this,"_totalPacketsLost",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_bitrateSend",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_bitrateRecv",{enumerable:!0,configurable:!0,writable:!0,value:0})}_pickReceiverData(e,t){e.forEach(e=>{var t;if("unified-plan"===this._sdpSemantics&&!this.isValidTranceiver(e,"inbound-rtp"))return;const{packetsLost:i,packetsReceived:r,jitter:n,bytesReceived:s,kind:o,nackCount:a,pliCount:l,audioLevel:_,frameHeight:c,frameWidth:d}=e,u=null===(t=this._store)||void 0===t?void 0:t.getTrackIdBySSRC(e.ssrc);if(!u)return;this._totalPacketsLost+=i;const h=this.updateReceiverPacketsLost(u,i,r);let g=this.updateBytesRecv(u,s,this._reportsData.timestamp);g<0&&(g=0),this._bitrateRecv+=g,this._reportsData.receivers.push({trackId:u,kind:o,packetsLostRate:h,remoteResource:!0,audioLevel:_||0===_?no(_):null,frameWidth:d,frameHeight:c,frameRate:null,bitrate:g,jitter:n?Math.round(1e3*n):n,codecImplementationName:null,nackCount:a,pliCount:l,rtt:null,samplingRate:Ks,googFirsReceived:Ks,googRenderDelayMs:Ks,trackState:Ks})})}_pickSenderData(e,t){e.forEach(e=>{var i;if("unified-plan"===this._sdpSemantics&&!this.isValidTranceiver(e,"outbound-rtp"))return;const r=null===(i=this._store)||void 0===i?void 0:i.getTrackIdBySSRC(e.ssrc),{kind:n,bytesSent:s,pliCount:o,nackCount:a,audioLevel:l,frameHeight:_,frameWidth:c,codecId:d,remoteId:u,packetsSent:h}=e;if(!r)return;const g=t[u];let p=null,f=null,E=0;g&&(p=g.jitter,f=g.roundTripTime,E=g.packetsLost),this._totalPacketsLost+=E;let T=0;!this._latestPacketsSent[r]&&(this._latestPacketsSent[r]={}),g?T=this.updateSenderPacketsLost(r,E,h):this._latestPacketsSent[r].crtPacketsSent=h;let m=this.updateBytesSent(r,s,this._reportsData.timestamp);m<0&&(m=0),this._bitrateSend+=m,this._reportsData.senders.push({trackId:r,kind:n,packetsLostRate:T,remoteResource:!1,audioLevel:l||0===l?no(l):null,frameWidth:c,frameHeight:_,frameRate:null,bitrate:m,jitter:p?Math.round(1e3*p):p,rtt:f?Math.round(1e3*f):f,encoderImplementation:t[d].mimeType,pliCount:o,nackCount:a,googFirsSent:Ks,samplingRate:Ks,googRenderDelayMs:Ks,trackState:Ks})})}_pickIceCandidatePair(e,t){const{selectedCandidatePairId:i}=e;if(i){const e=t[i],{availableOutgoingBitrate:r,availableIncomingBitrate:n,currentRoundTripTime:s,localCandidateId:o,remoteCandidateId:a}=e,l=t[o],{address:_,port:c}=l,d=t[a],{address:u,port:h,protocol:g}=d;this._reportsData.iceCandidatePair={IP:_||null,port:c,networkType:null,remoteIP:u,remotePort:h,protocol:g,bitrateRecv:this._bitrateRecv,bitrateSend:this._bitrateSend,rtt:1e3*s,availableOutgoingBitrate:r,availableIncomingBitrate:n,totalPacketsLost:this._totalPacketsLost},this._reportsData.receivers.forEach(e=>{e.rtt=1e3*s})}}formatRCRTCStateReport(e){const{outbound:t,inbound:i,transport:r,connection:n}=this.formatStateData(e);this._reportsData={senders:[],receivers:[]};const s=Math.floor(n[0].timestamp);if(this._reportsData.timestamp=s,this._totalPacketsLost=0,this._bitrateSend=0,this._bitrateRecv=0,this._pickSenderData(t,e),this._pickReceiverData(i,e),r.length>0){const t=r[0];this._pickIceCandidatePair(t,e)}return this._reportsData}}class go{get videoSdps(){return this.videoStreams.slice()}get audioSdps(){return this.audioStreams.slice()}constructor(e,t,i){Object.defineProperty(this,"SDP",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"SDPHeader",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(this,"videoStreams",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"audioStreams",{enumerable:!0,configurable:!0,writable:!0,value:[]});const r=this.getStreamIndex();this.spliteStreams(r)}static trimBlankLine(e){return e.replace(/\n\r\s*\r\n/g,"\r\n").replace(/\s+\r\n/g,"\r\n")}getStreamIndex(){const e=/m=(?:video|audio)/gim,t=new Set([0]);let i=e.exec(this.SDP);for(;null!==i;)t.add(null==i?void 0:i.index),i=e.exec(this.SDP);return t.add(this.SDP.length),[...t]}spliteStreams(e){this.SDPHeader=this.SDP.substring(e[0],e[1]).replace(/\r\ns=-/g,`\r\ns=${(new Date).valueOf()}`);for(let t=1;t<e.length;t++){const i=this.SDP.substring(e[t],e[t+1]);/^\bm=video\b/.test(i)?this.videoStreams.push(i):this.audioStreams.push(i)}}static clearInactiveOrRecvonly(e){return/\ba=(recvonly|inactive)\b/.test(e)?e.replace(/\r\na=(ssrc|msid)[^\r\n]+/gi,""):e}setHeaderBitrate(e){this.SDPHeader=this.SDPHeader.replace(/(\r\ns=[^\r\n]+)/gi,`$1\r\nc=IN IP4 0.0.0.0\r\nb=AS:${e*go.KBitrate}\r\nb=TIAS:${e*go.KBitrate*850}`)}setAudiosBitrate(e){return this.audioStreams=this.audioStreams.map(t=>this.setAudioItemBitrate(t,e)),this}setAudioBitrateWithStreamId(e,t){return this.audioStreams=this.audioStreams.map(i=>new RegExp(`\\bmsid:${t}\\b`,"ig").test(i)?this.setAudioItemBitrate(i,e):i),this}setAudioBitrateWithMid(e,t){return this.audioStreams=this.audioStreams.map(i=>new RegExp(`\\bmid:${t}\\b`,"ig").test(i)?this.setAudioItemBitrate(i,e):i),this}setAudioItemBitrate(e,t){if(0===t.max&&/\ba=inactive\b/gi.test(e))return e;if(!/\bmaxaveragebitrate\b/gi.test(e)){const i=["$1","maxaveragebitrate="+t.max*go.KBitrate*1e3];e=e.replace(/(\buseinbandfec=[^\r\n]+)/gi,i.join(";"))}return this.addAudioBlineAS(e,t)}addAudioBlineAS(e,t){return/\bb=AS:\d+\b/gi.test(e)?e:e.replace(/(\bc=IN[^\r\n]+)/gi,`$1\r\nb=AS:${t.max*go.KBitrate}\r\nb=TIAS:${t.max*go.KBitrate*850}`)}setVideosBitrate(e){return this.videoStreams=this.videoStreams.map(t=>this.setVideoItemBitrate(t,e)),this}setVideoBitrateWithStreamId(e,t){return this.videoStreams=this.videoStreams.map(i=>new RegExp(`\\bmsid:${t}\\b`,"ig").test(i)?this.setVideoItemBitrate(i,e):i),this}setVideoBitrateWithMid(e,t){return this.videoStreams=this.videoStreams.map(i=>new RegExp(`\\bmid:${t}\\b`,"ig").test(i)?this.setVideoItemBitrate(i,e):i),this}setVideoItemBitrate(e,t){if(0===t.max&&/\ba=inactive\b/gi.test(e))return e;if(!/\bx-google-max-bitrate\b/.test(e)){const i=["$1","x-google-max-bitrate="+t.max*go.KBitrate,"x-google-min-bitrate="+t.min*go.KBitrate,`x-google-start-bitrate=${t.start||t.max*go.KBitrate*.7}`];e=e.replace(/(\bprofile-level-id=42[e0]01f\b)/gi,i.join(";"))}return this.addVideoBlineAS(e,t)}addVideoBlineAS(e,t){return/\bb=AS:\d+\b/gi.test(e)?e:e.replace(/(\bc=IN[^\r\n]+)/gi,`$1\r\nb=AS:${t.max*go.KBitrate}\r\nb=TIAS:${t.max*go.KBitrate*850}`)}clearnSsrcWithMid(e,t){return this.audioStreams=this.audioStreams.map(i=>new RegExp(`\\bmid:${e}\\b`,"ig").test(i)?this.clearSSRC(i,t):i),this.videoStreams=this.videoStreams.map(i=>new RegExp(`\\bmid:${e}\\b`,"ig").test(i)?this.clearSSRC(i,t):i),this}clearSSRC(e,t){if(t===Io.SENDONLY){if(/\ba=sendonly\b/.test(e))return e.replace(/\r\na=(ssrc|msid)[^\r\n]+/gi,"")}if(t===Io.RECVONLY){if(/\ba=recvonly\b/.test(e))return e.replace(/\r\na=(ssrc|msid)[^\r\n]+/gi,"")}if(t===Io.INACTIVE){if(/\ba=inactive\b/.test(e))return e.replace(/\r\na=(ssrc|msid)[^\r\n]+/gi,"")}return e}}Object.defineProperty(go,"KBitrate",{enumerable:!0,configurable:!0,writable:!0,value:1});class po{static init(e,t){this._audioEncoder=e.encodeAudio,this._audioDecoder=e.decodeAudio,this._videoEncoder=e.encodeVideo,this._videoDecoder=e.decodeVideo,this._logger=t}static isInit(){return!!(this._audioEncoder&&this._audioDecoder&&this._videoEncoder&&this._videoDecoder)}static decodeAudio(e){try{return this._audioDecoder(e)}catch(t){return this._logger.error(he.L_ENCRYPTOR_DECODE_E,null==t?void 0:t.message),console.error(t),e}}static encodeAudio(e){try{return this._audioEncoder(e)}catch(t){return this._logger.error(he.L_ENCRYPTOR_ENCODE_E,null==t?void 0:t.message),console.error(t),e}}static decodeVideo(e){try{return this._videoDecoder(e)}catch(t){return this._logger.error(he.L_ENCRYPTOR_DECODE_E,null==t?void 0:t.message),console.error(t),e}}static encodeVideo(e){try{return this._videoEncoder(e)}catch(t){return this._logger.error(he.L_ENCRYPTOR_ENCODE_E,null==t?void 0:t.message),console.error(t),e}}}!function(e){e[e.NB=0]="NB",e[e.MB=1]="MB",e[e.WB=2]="WB",e[e.SWB=3]="SWB",e[e.FB=4]="FB"}(lo||(lo={})),lo.NB,lo.NB,lo.NB,lo.NB,lo.MB,lo.MB,lo.MB,lo.MB,lo.WB,lo.WB,lo.WB,lo.WB,lo.SWB,lo.SWB,lo.FB,lo.FB,lo.NB,lo.NB,lo.NB,lo.NB,lo.WB,lo.WB,lo.WB,lo.WB,lo.SWB,lo.SWB,lo.SWB,lo.SWB,lo.FB,lo.FB,lo.FB,lo.FB;class fo{static splitSections(e){return e.split("\nm=").map((e,t)=>`${(t>0?`m=${e}`:e).trim()}\r\n`)}static getMediaSections(e){const t=fo.splitSections(e);return t.shift(),t}static parseExtmap(e){const t=e.substr(9).split(" ");return{id:parseInt(t[0],10),direction:t[0].indexOf("/")>0?t[0].split("/")[1]:"sendrecv",uri:t[1]}}static splitLines(e){return e.trim().split("\n").map(e=>e.trim())}static parseMLine(e){const t=fo.splitLines(e)[0].substr(2).split(" ");return{kind:t[0],port:parseInt(t[1],10),protocol:t[2],fmt:t.slice(3).join(" ")}}static matchPrefix(e,t){return fo.splitLines(e).filter(e=>0===e.indexOf(t))}static parseMsid(e){let t;const i=fo.matchPrefix(e,"a=msid:");if(1===i.length)return t=i[0].substr(7).split(" "),{stream:t[0],track:t[1]};const r=fo.matchPrefix(e,"a=ssrc:").map(e=>fo.parseSsrcMedia(e)).filter(e=>"msid"===e.attribute);return r.length>0&&r[0].value?(t=r[0].value.split(" "),{stream:t[0],track:t[1]}):{stream:"",track:""}}static parseSsrcMedia(e){const t=e.indexOf(" "),i={ssrc:parseInt(e.substr(7,t-7),10)},r=e.indexOf(":",t);return r>-1?(i.attribute=e.substr(t+1,r-t-1),i.value=e.substr(r+1)):i.attribute=e.substr(t+1),i}static getMid(e){const t=fo.matchPrefix(e,"a=mid:")[0];if(t)return t.substr(6)}static splitNaluData(e){const t=new Uint8Array(e);let i=0;if(this.isIFrame(t)){const e=t.join(",");let r=e.indexOf("0,0,0,1,101");-1===r&&(r=e.indexOf("0,0,0,1,37"));i=e.substring(0,r).split(",").length-1+4+8}else i=12;return{header:t.slice(0,i),payloadData:t.slice(i)}}static deal0x03(e,t){let i=[];return i="encode"===t?e.join(",").replaceAll(",0,0,1,",",0,0,3,1,").split(",").map(e=>Number(e)):e.join(",").replaceAll(",0,0,3,1,",",0,0,1,").split(",").map(e=>Number(e)),new Uint8Array(i)}static isIFrame(e){let t=e.join("").startsWith("0001103");return t||(t=e.join("").startsWith("000139")),t}static parsePayloadTypes(e){const t=fo.getMediaSections(e).find(e=>"audio"===fo.parseMLine(e).kind);if(!t)return;const i=t.match(/a=rtpmap:(\d+)\s+(\S+)/g);i&&(fo.payloadTypeCodecMap=i.map(e=>{const t=e.match(/a=rtpmap:(\d+)\s+(\w+)/);return t?{payloadType:Number(t[1]),codec:t[2]}:null}).filter(e=>!!e))}}Object.defineProperty(fo,"payloadTypeCodecMap",{enumerable:!0,configurable:!0,writable:!0,value:[]});function Eo(e,t){let i=0,r=t;for(;r<e.length;){const t=e[r];if(i+=t,r++,255!==t)break}return{value:i,nextOffset:r}}function To(e,t){if(t>=e.length)return null;const i=Eo(e,t),r=i.value;let n=i.nextOffset;const s=Eo(e,n),o=s.value;if(n=s.nextOffset,o<16)return null;if(n+o>e.length)return null;const a=e.slice(n,n+16),l=n+16,_=o-16;let c=e.slice(l,l+_);return c.length>=2&&0===c[c.length-2]&&128===c[c.length-1]?c=c.slice(0,c.length-2):c.length>=1&&128===c[c.length-1]&&(c=c.slice(0,c.length-1)),5===r?{payloadSize:o,uuid:a,content:c}:null}var mo,Io,Ro,So,Co,Lo,Oo,vo,bo;!function(e){e.PLANB="plan-b",e.UNIFIEDPLAN="unified-plan"}(mo||(mo={})),function(e){e.SENDONLY="sendonly",e.RECVONLY="recvonly",e.INACTIVE="inactive"}(Io||(Io={}));class Ao{static setSdpSemantics(e,t){const{browser:i,version:r,supportsUnifiedPlan:n}=Ci;if(t.info(he.L_A_SDP_STRATEGY_SET_SDP_SEMANTICS_O,JSON.stringify({sdpSemantics:e,supportsUnifiedPlan:n,browser:i,version:r})),n)return/chrome/i.test(i)?r?void(this._sdpSemantics=r>92?"unified-plan":r<72?"plan-b":e):void(this._sdpSemantics="unified-plan"):void(/firefox/i.test(i)?this._sdpSemantics="unified-plan":/safari/i.test(i)?this._sdpSemantics=r<12?"plan-b":"unified-plan":this._sdpSemantics="unified-plan");this._sdpSemantics="plan-b"}static getSdpSemantics(){return Ao._sdpSemantics}constructor(e,t,i,r){Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_peer",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_useEncrypt",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_onReceiveSeiListener",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_outboundStreams",{enumerable:!0,configurable:!0,writable:!0,value:{}})}setReceiveSeiListener(e){this._onReceiveSeiListener=e}getOutboundVideoInfo(){const e=[];for(const t in this._outboundStreams){const i=this._outboundStreams[t].getVideoTracks()[0];if(!i)continue;const r=/_tiny$/.test(t),{width:n,height:s}=di(i);e.push({trackId:i.id,simulcast:r?to.TINY:to.NORMAL,resolution:`${n}x${s}`})}return e}setRemoteAnswer(e){return I(this,void 0,void 0,function*(){e=go.trimBlankLine(e);try{yield this._peer.setRemoteDescription({type:"answer",sdp:e})}catch(e){return this._logger.info(he.L_A_SDP_STRATEGY_SET_REMOTE_ANSWER_O,JSON.stringify({status:ge.FAILED,msg:e})),ue.SET_REMOTE_DESCRIPTION_FAILED}return this._logger.info(he.L_A_SDP_STRATEGY_SET_REMOTE_ANSWER_O,JSON.stringify({status:ge.SUCCESSED,sdp:e})),ue.SUCCESS})}getStatParsr(e,t,i,r){return/chrome/i.test(Ci.browser)?new co(this,e,this._logger,t,i,r):/Firefox/i.test(Ci.browser)?new uo(this,e,this._logger,t,i,r):/Safari/i.test(Ci.browser)?new ho(this,e,this._logger,t,i,r):null}getTrackIdByMid(e){return null}resetSdp(e){return go.trimBlankLine(e)}_setupSenderTransform(e){if(!this._useEncrypt)return;const t=e.createEncodedStreams(),{readable:i,writable:r}=t,n=new TransformStream({transform:this._encodeRtpChunk.bind(this,e)});i.pipeThrough(n).pipeTo(r)}_setupReceiverTransform(e){const t=e.createEncodedStreams(),{readable:i,writable:r}=t,n=new TransformStream({transform:this._decodeRtpChunk.bind(this,e)});i.pipeThrough(n).pipeTo(r)}_encodeVideoFrame(e){const{header:t,payloadData:i}=fo.splitNaluData(e),r=po.encodeVideo(i),n=fo.deal0x03(r,"encode");return new Uint8Array([...t,...n]).buffer}_decodeVideoFrame(e){var t;const i=new Uint8Array(e),r=i.join(",").indexOf("0,0,0,1,6,5");if(-1!==r&&i.join(",").includes("84,128,131,151,240,35,71,75,183,247,79,50,181,78,6,172")){const n=i.join(",").slice(r);return null===(t=this._onReceiveSeiListener)||void 0===t||t.call(this,n),e}if(!this._useEncrypt)return e;const{header:n,payloadData:s}=fo.splitNaluData(e),o=fo.deal0x03(s,"decode"),a=po.decodeVideo(o);return new Uint8Array([...n,...a]).buffer}_handleAudioREDFrame(e,t){const i=function(e){const t=[];let i=0;for(;;){let r,n,s,o,a=!(e[i]>>7),l=127&e[i];if(a?(r=0,n=e.byteLength-(t.length>0?t.map(e=>4+e.block.byteLength).reduce((e,t)=>e+t):0)-1,s=e.slice(i,i+1),i+=1):(r=(e[i+1]<<6)+(e[i+2]>>2),n=((3&e[i+2])<<8)+e[i+3],s=e.slice(i,i+4),i+=4),o=new Uint8Array(n),t.push({timestampOffset:r,header:s,block:o,isPrimary:a,blockPType:l}),a)break}return t.forEach(t=>{const r=t.block.byteLength,n=e.slice(i,i+r);t.block.set(n),i+=r}),t}(new Uint8Array(e)),r=[],n=[];let s=0;i.forEach(e=>{const i="decode"===t?po.decodeAudio(e.block):po.encodeAudio(e.block);if(i.byteLength!==e.block.byteLength&&!e.isPrimary){let[,,t,r]=e.header;t=(t>>2<<2)+i.byteLength>>8,r=255&i.byteLength,e.header=new Uint8Array([e.header[0],e.header[1],t,r])}e.block=i,s+=e.block.byteLength+e.header.byteLength,r.push(e.header),n.push(e.block)});const o=new Uint8Array(s);let a=0;return[...r,...n].forEach(e=>{o.set(e,a),a+=e.byteLength}),o.buffer}_handleOpusFrame(e,t){const i=new Uint8Array(e);return("encode"===t?po.encodeAudio(i):po.decodeAudio(i)).buffer}_encodeRtpChunk(e,t,i){const r=t.data;if(t instanceof RTCEncodedVideoFrame)t.data=this._encodeVideoFrame(r);else{const{payloadType:e}=t.getMetadata(),{codec:i}=fo.payloadTypeCodecMap.filter(t=>t.payloadType===e)[0];"red"===i?t.data=this._handleAudioREDFrame(r,"encode"):"opus"===i?t.data=this._handleOpusFrame(r,"encode"):console.error(`Unsupport audio payloadType: ${e}, codec: ${i}`)}i.enqueue(t)}_decodeRtpChunk(e,t,i){const r=t.data;if(t instanceof RTCEncodedVideoFrame)t.data=this._decodeVideoFrame(r);else if(this._useEncrypt){const{payloadType:e}=t.getMetadata(),{codec:i}=fo.payloadTypeCodecMap.filter(t=>t.payloadType===e)[0];"red"===i?t.data=this._handleAudioREDFrame(r,"decode"):"opus"===i?t.data=this._handleOpusFrame(r,"decode"):console.error(`Unsupport audio payloadType: ${e}, codec: ${i}`)}i.enqueue(t)}}class yo extends go{constructor(e,t){super(t,mo.PLANB,e),Object.defineProperty(this,"SDP",{enumerable:!0,configurable:!0,writable:!0,value:t})}stringify(){const e=[this.SDPHeader];[...this.audioStreams,...this.videoStreams].forEach(t=>{const i=t.match(/\ba=mid:(video|audio)\b/),r=go.clearInactiveOrRecvonly(t);i&&i[1]===Gt.AUDIO&&(e[1]=r),i&&i[1]===Gt.VIDEO&&(e[2]=r)});const t=e.join("");return go.trimBlankLine(t)}setAudioBitrateWithStreamId(e,t){return this._logger.warn(he.L_FUNCTION_IS_UNAVAILABLE,"plan-b not support set Audio Bitrate With Stream Id"),this}setVideoBitrateWithStreamId(e,t){return this._logger.warn(he.L_FUNCTION_IS_UNAVAILABLE,"plan-b not support set Video Bitrate With Stream Id"),this}}class No extends Ao{constructor(){super(...arguments),Object.defineProperty(this,"senders",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_localTracks",{enumerable:!0,configurable:!0,writable:!0,value:[]})}addLocalTrack(e){this._localTracks.every(t=>t.getTrackId()!==e.getTrackId())&&this._localTracks.push(e);const t=e.getStreamId(),i=e.__innerGetMediaStreamTrack(),r=this._outboundStreams[t]||(this._outboundStreams[t]=new MediaStream);r.getTracks().forEach(e=>{e.kind===i.kind&&r.removeTrack(e)}),r.addTrack(i);const n=e.getTrackId(),s=this.senders[n];s?s.replaceTrack(i):(this.senders[n]=this._peer.addTrack(i,r),Object.defineProperty(i,"trackId",{value:n,writable:!1,enumerable:!1,configurable:!1}))}removeLocalTrack(e){const t=this._localTracks.findIndex(t=>t===e);t>=0&&this._localTracks.splice(t,1);const i=e.getTrackId(),r=this.senders[i];r&&(r.replaceTrack(null),this._peer.removeTrack(r),delete this.senders[i])}updateSubRemoteTracks(e){}updateRecvTransceiverMap(e,t){}setBitrate(e,t,i){}createOffer(e){return I(this,void 0,void 0,function*(){const t=yield this._peer.createOffer({iceRestart:e,offerToReceiveAudio:!0,offerToReceiveVideo:!0});for(const e in this._outboundStreams){const i=this._outboundStreams[e].id;t.sdp=t.sdp.replace(new RegExp(i,"g"),e)}return t.sdp&&(t.sdp=this.resetSdp(t.sdp)),yield this._peer.setLocalDescription(t),{type:"offer",semantics:"plan-b",sdp:t.sdp}})}setRemoteAnswer(e){return e=this.resetSdp(e),super.setRemoteAnswer(e)}_getMaxRangeBitrate(e){const t=this._localTracks.filter(t=>e===Pt.AUDIO_ONLY?t.isAudioTrack():t.isVideoTrack()),i={max:0,min:0};return t.forEach(e=>{const{min:t,max:r,start:n}=e.getBitrate();i.max=i.max<r?r:i.max,i.min=i.min>t?t:i.min,i.max===r?i.start=n:i.start=.7*i.max}),i}resetSdp(e){const t=new yo(this._logger,e),i=this._getMaxRangeBitrate(Pt.VIDEO_ONLY),r=this._getMaxRangeBitrate(Pt.AUDIO_ONLY);return t.setAudiosBitrate(r),t.setVideosBitrate(i),t.stringify()}}class Po extends go{constructor(e,t){super(t,mo.UNIFIEDPLAN,e)}stringify(){const e=[this.SDPHeader];[...this.audioStreams,...this.videoStreams].forEach(t=>{const i=t.match(/\ba=mid:(\d+)\b/);i&&i[1]&&(e[+i[1]+1]=t)}),this.SDPHeader="",this.videoStreams=[],this.audioStreams=[];const t=e.join("");return go.trimBlankLine(t)}}class Uo{constructor(){Object.defineProperty(this,"__streams",{enumerable:!0,configurable:!0,writable:!0,value:new Map})}static getInstance(){return Uo.instance||(Uo.instance=new Uo),Uo.instance}push(e,t){return this.__streams.set(e,t),t}pickup(e){return this.__streams.get(e)}delete(e){return this.__streams.delete(e)}get streams(){const e=new Map;for(const t of this.__streams.keys())e.set(t,this.pickup(t));return e}}class Do extends Ao{constructor(){super(...arguments),Object.defineProperty(this,"_sendTransceiver",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_localTracks",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_recvAudio",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_recvVideo",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_recvTransceiver",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_subedTracks",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"midMsid",{enumerable:!0,configurable:!0,writable:!0,value:{}})}setBitrate(e,t,i){this._logger.warn(he.L_FUNCTION_IS_UNAVAILABLE,"the interface named `setBitrate` is invalid while sdpSemantics value is `unified-plan`")}getTrackIdByMid(e){for(let t in this._sendTransceiver){if(this._sendTransceiver[t].mid===e)return t}for(let t in this._recvTransceiver){if(this._recvTransceiver[t].mid===e)return t}return null}addLocalTrack(e){var t;const i=e.getTrackId(),r=e.getStreamId(),n=e.__innerGetMediaStreamTrack();this._localTracks[i]=e;const s=this._outboundStreams[r]||(this._outboundStreams[r]=new MediaStream);s.getTracks().forEach(e=>{e.kind===n.kind&&s.removeTrack(e)}),s.addTrack(n);const o=this._sendTransceiver[i];if(o)o.sender.replaceTrack(n),o.direction="sendonly";else{const e=this._sendTransceiver[i]=this._peer.addTransceiver(n,{direction:"sendonly",streams:[s]});this._setupSenderTransform(e.sender)}Uo.getInstance().push(i,{msid:r,id:this._outboundStreams[r].id,kind:null===(t=e.streamTrack)||void 0===t?void 0:t.kind})}removeLocalTrack(e,t=!0){const i=e.getTrackId(),r=e.getStreamId();delete this._localTracks[i];const n=this._sendTransceiver[i];if(!n)return;"closed"!==this._peer.connectionState&&(n.direction="inactive",this._peer.removeTrack(n.sender),n.sender.replaceTrack(null));const s=this._outboundStreams[r];(e.isAudioTrack()?s.getAudioTracks():s.getVideoTracks()).forEach(e=>s.removeTrack(e));const o=this._sendTransceiver[`${i}_tiny`];if(o&&"inactive"!==o.direction&&t&&"closed"!==this._peer.connectionState){o.direction="inactive";const{sender:e}=o,t=e.track;this._peer.removeTrack(e),e.replaceTrack(null);this._outboundStreams[`${r}_tiny`].removeTrack(t),t.stop()}}updateRecvTransceiverMap(e,t){const{mediaType:i}=gi(e);this._recvTransceiver[e]=t;const r=i===Pt.AUDIO_ONLY?this._recvAudio:this._recvVideo,n=r.findIndex(e=>e===t);n>=0&&r.splice(n,1)}updateSubRemoteTracks(e){const t=e.slice(),i=this._subedTracks.slice();this._subedTracks=e.slice();for(let e=t.length-1;e>=0;e-=1){const r=t[e],n=i.findIndex(e=>e===r);n>=0&&(t.splice(e,1),i.splice(n,1))}i.length&&i.forEach(e=>{const t=e.getTrackId();e.__innerSetMediaStreamTrack(void 0);const i=this._recvTransceiver[t];i&&(i.direction="inactive")});const r={audio:0,video:0};t.length&&t.forEach(e=>{const t=e.isAudioTrack()?"audio":"video",i=this._recvTransceiver[e.getTrackId()];i?i.direction="recvonly":r[t]+=1});for(let e=this._recvAudio.length;e<r.audio;e+=1){const e=this._peer.addTransceiver("audio",{direction:"recvonly"});this._recvAudio.push(e),this._setupReceiverTransform(e.receiver)}for(let e=this._recvVideo.length;e<r.video;e+=1){const e=this._peer.addTransceiver("video",{direction:"recvonly"});this._recvVideo.push(e),this._setupReceiverTransform(e.receiver)}}createOffer(e){return I(this,void 0,void 0,function*(){const t=yield this._peer.createOffer({iceRestart:e});let i=t.sdp;for(const e in this._outboundStreams){const t=this._outboundStreams[e].id;i=i.replace(new RegExp(t,"g"),e)}return i=this.resetOfferSdp(i),i=i.replace(/(a=ice-options:trickle)/g,"$1\r\na=ice-options:renomination"),t.sdp=i,yield this._peer.setLocalDescription(t),{type:"offer",semantics:"unified-plan",sdp:i}})}setRemoteAnswer(e){e=this.resetAnswerSdp(e);const t=/[\r\n]+\r\n[\r\n]+/g;return t.test(e)&&(e=e.replace(t,"\r\n")),super.setRemoteAnswer(e)}_genarateMid(e,t,i){let r=null;return fo.getMediaSections(e).forEach(e=>{fo.parseExtmap(e);const{kind:n}=fo.parseMLine(e);let{stream:s}=fo.parseMsid(e);const o=fo.getMid(e);"video"===i?/tiny$/.test(s)?s=s.replace(/tiny$/gi,"1_tiny"):s+="_1":s+="_0",s===t&&i===n&&o&&(r=o)}),r}_setSenderTransceiverBitrate(e,t,i,r){const n=this._localTracks[t],s=null==n?void 0:n.getBitrate();r===Gt.AUDIO&&s&&e.setAudioBitrateWithMid(s,i),r===Gt.VIDEO&&s&&e.setVideoBitrateWithMid(s,i)}_resetSenderTransceiver(e,t){var i;for(const r in this._sendTransceiver){const n=this._sendTransceiver[r],s=null===(i=n.sender.track)||void 0===i?void 0:i.kind;let{direction:o,mid:a}=n;a||(a=this._genarateMid(e,r,s)),a&&(o===Io.SENDONLY&&this._setSenderTransceiverBitrate(t,r,a,s),o===Io.INACTIVE&&t.clearnSsrcWithMid(a,Io.INACTIVE))}}_resetRecvTransceiver(e){for(const t in this._recvTransceiver){const i=this._recvTransceiver[t],{direction:r,mid:n}=i;n&&r===Io.INACTIVE&&e.clearnSsrcWithMid(n,Io.RECVONLY)}}resetOfferSdp(e){const t=new Po(this._logger,e);return this._resetSenderTransceiver(e,t),this._resetRecvTransceiver(t),t.stringify()}resetAnswerSdp(e){var t;const i=new Po(this._logger,e);for(const e in this._sendTransceiver){const r=this._sendTransceiver[e],{mid:n}=r;if(n){const s=this._localTracks[e],o=null==s?void 0:s.getBitrate(),a=null===(t=r.sender.track)||void 0===t?void 0:t.kind;a===Gt.AUDIO&&o&&i.setAudioBitrateWithMid(o,n),a===Gt.VIDEO&&o&&i.setVideoBitrateWithMid(o,n)}}return i.stringify()}}class Mo extends B{constructor(e,t,i,r,n,s,o=!1,a=!1){super(),Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_reTryExchange",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_currentUserId",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_store",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"_polarisReport",{enumerable:!0,configurable:!0,writable:!0,value:s}),Object.defineProperty(this,"_isRoomAudience",{enumerable:!0,configurable:!0,writable:!0,value:o}),Object.defineProperty(this,"_rtcPeerConn",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_sdpStrategy",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"reportParser",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"pubLocalTracks",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_reTryExchangeTimer",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_reportStatsTimer",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_reportR3R4ToPolarisTimer",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_isDestroyed",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_formatStatsData",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_inRetry",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_firstConnectFromPub",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_reportListener",{enumerable:!0,configurable:!0,writable:!0,value:null});const l=Ao.getSdpSemantics(),_="unified-plan"===l&&a&&"function"==typeof RTCRtpSender.prototype.createEncodedStreams&&"function"==typeof RTCRtpReceiver.prototype.createEncodedStreams&&po.isInit(),c=this._rtcPeerConn=new RTCPeerConnection({sdpSemantics:l,encodedInsertableStreams:_});this._sdpStrategy="plan-b"===l?new No(e,this._logger,c,!1):new Do(e,this._logger,c,_),this._sdpStrategy.setReceiveSeiListener(this._decodeSeiData.bind(this)),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,l,this._currentUserId,this._store)}getLocalTracks(){return Object.values(this.pubLocalTracks)}_decodeSeiData(e){const t=e.split(",").map(e=>Number(e)),i=function(e){if(e.length>=4&&0===e[0]&&0===e[1]&&(1===e[2]||0===e[2]&&1===e[3])){let t=0;for(;t+4<e.length;)if(0===e[t]&&0===e[t+1]&&(1===e[t+2]||0===e[t+2]&&1===e[t+3])){const i=t+(1===e[t+2]?3:4);if(i>=e.length)break;if(6==(31&e[i])){const t=To(e,i+1);if(t)return{payloadSize:t.payloadSize,content:t.content}}t=i+1}else t++}else{let t=0;for(;t+4<=e.length;){const i=e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3];if(i<=0||t+4+i>e.length)break;const r=t+4;if(6==(31&e[r])){const n=r+1,s=To(e.subarray(n,t+4+i),0);if(s)return{payloadSize:s.payloadSize,content:s.content}}t+=4+i}}return null}(new Uint8Array(t));if(null==i?void 0:i.content.length){const e=this._context.decodeAsrText(i.content,t);e.length&&this.emit(Mo.__INNER_SEI_CONTENT__,e)}}_onConnectionStateChange(){this._logger.info(he.L_RTC_PEER_CONNECTION_CONNECTION_STATE_S,`state: ${this._rtcPeerConn.connectionState}`)}startAutoExecute(e){this.stopAutoExecute(),this._reportStatsTimer=setTimeout(()=>{this._reportHandle(),this.startAutoExecute(e)},e)}stopAutoExecute(){clearTimeout(this._reportStatsTimer)}_onICEConnectionStateChange(){return I(this,void 0,void 0,function*(){var e,t;const{iceConnectionState:i}=this._rtcPeerConn;this._logger.info(he.L_RTC_PEER_CONNECTION_ICE_CONNECTION_STATE_S,JSON.stringify({iceConnectionState:i}));const r=yield this._getStatsData(),n=r?this._createRCRTCStateReport(r).iceCandidatePair:null;this.emit(Mo.__INNER_ICE_STATE_CHANGE__,{status:i,time:Date.now(),iceCandidatePair:n}),"connected"===i?(this.emit(Mo.__INNER_ICE_CONNECTED__,this._firstConnectFromPub),this.startAutoExecute(1e3)):"failed"!==i&&"disconnected"!==i||this._handleRetry();try{null===(t=null===(e=this._reportListener)||void 0===e?void 0:e.onICEConnectionStateChange)||void 0===t||t.call(e,i)}catch(e){this._logger.error(he.L_RTC_PEER_CONNECTION_ICE_CONNECTION_STATE_REPORT_R,JSON.stringify({status:ge.FAILED,mag:e}))}})}_handleRetry(){return I(this,void 0,void 0,function*(){if(this._inRetry)return;this.clearReTryExchangeTimer(),this._inRetry=!0;const{code:e}=yield this._reTryExchange();this._inRetry=!1,e!==ue.SUCCESS&&(this._reTryExchangeTimer=setTimeout(()=>this._handleRetry(),15e3))})}_onTrackReady(e){if(!e.streams.length)return;const t=e.streams[0].id,{track:i}=e.receiver,r=[t,"audio"===i.kind?Pt.AUDIO_ONLY:Pt.VIDEO_ONLY].join("_");Object.defineProperty(i,"trackId",{value:r,writable:!1,enumerable:!1,configurable:!1}),this._updateRecvTransceiverMap(r,e.transceiver);const{tag:n}=gi(r);n!==Ys&&this.emit(Mo.__INNER_EVENT_TRACK_READY__,e)}setBitrate(e,t,i){return I(this,void 0,void 0,function*(){this._sdpStrategy.setBitrate(e,t,i),this._logger.info(he.L_RTC_PEER_CONNECTION_SET_BITRATE_O,JSON.stringify({status:ge.SUCCESSED,max:e,min:t,start:i}))})}createOffer(e){return I(this,void 0,void 0,function*(){const t=yield this._sdpStrategy.createOffer(e);return this._logger.info(he.L_RTC_PEER_CONNECTION_CREATE_OFFER_O,JSON.stringify({offerSDP:t.sdp,sdpDemantics:t.semantics})),t})}setRemoteAnswer(e){return I(this,arguments,void 0,function*(e,t=!1){var i;return fo.parsePayloadTypes(null===(i=this._rtcPeerConn.localDescription)||void 0===i?void 0:i.sdp),this._firstConnectFromPub=t,this._sdpStrategy.setRemoteAnswer(e)})}getLocalTrack(e){return this.pubLocalTracks[e]||null}addLocalTrack(e){this.pubLocalTracks[e.getTrackId()]=e,this._sdpStrategy.addLocalTrack(e),e.off(Yt.__INNER_EVENT_MUTED_CHANGE__,this._onLocalTrackMuted,this),e.off(Yt.__INNER_EVENT_DESTROY__,this._onLocalTrackDestroied,this),e.on(Yt.__INNER_EVENT_MUTED_CHANGE__,this._onLocalTrackMuted,this),e.on(Yt.__INNER_EVENT_DESTROY__,this._onLocalTrackDestroied,this),this._logger.info(he.L_RTC_PEER_CONNECTION_ADD_LOCAL_TRACK_O,`trackId: ${e.getTrackId()}`)}removeLocalTrackById(e){const t=this.getLocalTrack(e);t?(this._logger.info(he.L_RTC_PEER_CONNECTION_REMOVE_LOCAL_TRACK_BY_ID_O,JSON.stringify({status:ge.SUCCESSED,trackId:e})),this.removeLocalTrack(t)):this._logger.warn(he.L_RTC_PEER_CONNECTION_REMOVE_LOCAL_TRACK_BY_ID_O,JSON.stringify({status:ge.FAILED,msg:"track not found",trackId:e}))}removeAllLocalTrack(){Object.keys(this.pubLocalTracks).forEach(e=>{/_tiny$/.test(e)||this.removeLocalTrackById(e)})}removeLocalTrack(e,t=!0){const i=e.getTrackId();delete this.pubLocalTracks[i],this._sdpStrategy.removeLocalTrack(e,t),e.__innerSetPublished(!1),e.off(Yt.__INNER_EVENT_MUTED_CHANGE__,this._onLocalTrackMuted,this),e.off(Yt.__INNER_EVENT_DESTROY__,this._onLocalTrackDestroied,this);const r=`${i}_tiny`,n=this.getLocalTrack(r);n&&t&&(this._sdpStrategy.removeLocalTrack(n,t),delete this.pubLocalTracks[r],n.destroy()),this._logger.info(he.L_RTC_PEER_CONNECTION_REMOVE_LOCAL_TRACK_O,JSON.stringify({trackId:i}))}_updateRecvTransceiverMap(e,t){this._sdpStrategy.updateRecvTransceiverMap(e,t)}updateSubRemoteTracks(e){this._sdpStrategy.updateSubRemoteTracks(e)}getOutboundVideoInfo(){return this._sdpStrategy.getOutboundVideoInfo()}_onLocalTrackMuted(e,t){const i=this.getLocalTrack(`${e.getTrackId()}_tiny`);i&&(i.__innerGetMediaStreamTrack().enabled=!e.isLocalMuted()),this.emit(Yt.__INNER_EVENT_MUTED_CHANGE__,e,t)}_onLocalTrackDestroied(e){this.emit(Yt.__INNER_EVENT_DESTROY__,e)}registerReportListener(e){this._reportListener=e}_createSenderReport(e){return e.filter(e=>e.trackId).map(e=>{const{trackId:t,kind:i,packetsLostRate:r,remoteResource:n,bitrate:s,jitter:o,rtt:a}=e,l={trackId:t,kind:i,packetsLostRate:r,remoteResource:n,bitrate:s,jitter:o,rtt:a};return(e.audioLevel||0===e.audioLevel)&&(l.audioLevel=e.audioLevel),e.frameWidth&&(l.frameWidth=e.frameWidth),e.frameHeight&&(l.frameHeight=e.frameHeight),e.frameRate&&(l.frameRate=e.frameRate),Object.assign({},l)})}_createReceiverReport(e){return e.filter(e=>e.trackId).map(e=>{const{trackId:t,kind:i,packetsLostRate:r,remoteResource:n,bitrate:s,jitter:o,rtt:a}=e,l={trackId:t,kind:i,packetsLostRate:r,remoteResource:n,bitrate:s,jitter:o,rtt:a};return(e.audioLevel||0===e.audioLevel)&&(l.audioLevel=e.audioLevel),e.frameWidth&&(l.frameWidth=e.frameWidth),e.frameHeight&&(l.frameHeight=e.frameHeight),e.frameRate&&(l.frameRate=e.frameRate),Object.assign({},l)})}_createRCRTCStateReport(e){const{timestamp:t,iceCandidatePair:i,senders:r,receivers:n}=e;(null==i?void 0:i.totalPacketsLost)&&(null==i||delete i.totalPacketsLost);for(const e in i)vi(i[e])&&delete i[e];return{timestamp:t,iceCandidatePair:i,senders:this._createSenderReport(r),receivers:this._createReceiverReport(n)}}_getStatsData(){return I(this,void 0,void 0,function*(){var e,t;this._formatStatsData=null;let i=null;const r=yield this._rtcPeerConn.getStats();i=null===(e=this.reportParser)||void 0===e?void 0:e.parseRTCStatsReport(r);const n=null===(t=this.reportParser)||void 0===t?void 0:t.formatRCRTCStateReport(i);return this._formatStatsData=n,n})}_reportHandle(){return I(this,void 0,void 0,function*(){var e,t,i,r,n;const s=yield this._getStatsData();if(!s)return;const o=this._createRCRTCStateReport(s);try{null===(t=null===(e=this._reportListener)||void 0===e?void 0:e.onStateReport)||void 0===t||t.call(e,JSON.parse(JSON.stringify(o)))}catch(e){this._logger.error(he.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,null==e?void 0:e.stack)}const a=[...s.receivers,...s.senders].filter(e=>"audio"===e.kind).map(e=>({trackId:e.trackId,audioLevel:e.audioLevel}));if(this.emit(Mo.__INNER_AUDIOLEVEL_CHANGE__,a),this._isRoomAudience&&(null===(i=this._reportListener)||void 0===i?void 0:i.onReportLiveAudioStates)){const e=this._getLiveAudioState();try{e.length&&(null===(n=null===(r=this._reportListener)||void 0===r?void 0:r.onReportLiveAudioStates)||void 0===n||n.call(r,e))}catch(e){this._logger.error(he.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,null==e?void 0:e.stack)}}})}_getLiveAudioState(){const e=[];return this._rtcPeerConn.getReceivers().forEach(t=>{const i=t.getContributingSources();i.length&&e.push(...i)}),e.map(e=>{const{source:t,audioLevel:i}=e,r=this._store.getTrackIdBySSRC(t);if(!r)return{};const{userId:n}=gi(r);return{audioLevel:no(i),userId:n,trackId:r}}).filter(e=>!!e.userId)}_sendR3R4Data(){return I(this,void 0,void 0,function*(){var e,t,i,r;let n=this._formatStatsData;if(!n)return;const{senders:s,receivers:o}=n;console.log(`sendR3R4: senderTrackId: ${null===(e=s[0])||void 0===e?void 0:e.trackId}, receiverTrackId: ${null===(t=o[0])||void 0===t?void 0:t.trackId}`),s.length&&(yield null===(i=this._polarisReport)||void 0===i?void 0:i.sendR3Data(n)),o.length&&(yield null===(r=this._polarisReport)||void 0===r?void 0:r.sendR4Data(n)),s.length=0,o.length=0,n=null})}__reportR3R4ToPolaris(){return I(this,void 0,void 0,function*(){this._isDestroyed||(clearTimeout(this._reportR3R4ToPolarisTimer),this._reportR3R4ToPolarisTimer=setTimeout(()=>I(this,void 0,void 0,function*(){this._isDestroyed||this._sendR3R4Data().then(()=>{this.__reportR3R4ToPolaris()})}),2e3))})}getRTCPeerConn(){return this._rtcPeerConn}destroy(){this.clear(),this.clearReTryExchangeTimer(),clearTimeout(this._reportR3R4ToPolarisTimer),this.stopAutoExecute(),this.registerReportListener(null),this._rtcPeerConn.close(),this._isDestroyed=!0,this.reportParser=null,this._logger.info(he.L_RTC_PEER_CONNECTION_DESTROY_O,JSON.stringify({status:ge.SUCCESSED}))}clearReTryExchangeTimer(){clearTimeout(this._reTryExchangeTimer),this._reTryExchangeTimer=null}isDestroyed(){return this._isDestroyed}}Object.defineProperty(Mo,"__INNER_EVENT_TRACK_READY__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-track-ready"}),Object.defineProperty(Mo,"__INNER_AUDIOLEVEL_CHANGE__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-audio-level-change"}),Object.defineProperty(Mo,"__INNER_ICE_STATE_CHANGE__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-ice-state-change"}),Object.defineProperty(Mo,"__INNER_ICE_CONNECTED__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-ice-connected"}),Object.defineProperty(Mo,"__INNER_SEI_CONTENT__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-sei-content"});class wo{constructor(e,t){Object.defineProperty(this,"_store",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_peer",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_audioLevelChangeHandler",{enumerable:!0,configurable:!0,writable:!0,value:null})}audioLevelReport(e){if(!this._audioLevelChangeHandler)return;const t=[];e.forEach(e=>{const{userId:i}=gi(e.trackId),r=this._store.crtUserId===i?this._peer.getLocalTrack(e.trackId):this._store.getRemoteTrack(e.trackId);r&&t.push({track:r,audioLevel:e.audioLevel||0})}),this._audioLevelChangeHandler(t)}onAudioLevelChange(e){this._audioLevelChangeHandler=e}}!function(e){e[e.ANCHOR=1]="ANCHOR",e[e.AUDIENCE=2]="AUDIENCE"}(Ro||(Ro={})),function(e){e.UNPUBLISH_PREV="UnpublishPrevCommand",e.PULL_RTCROOM_STATUS="PullRTCRoomStatusCommand",e.JOINROOM="JoinRoomCommand",e.PARSE_REMOTERES="ParseRemoteResCommand",e.PARSE_USERSTATE="ParseUserStateCommand",e.LOCAL_TRACK_MUTE="LocalTrackMuteCommand",e.PUBLISH="PublishCommand",e.RETRY_EXCHANGE="RetryExchangeCommand",e.UNPUBLISH="UnpublishCommand",e.SUBSCRIBE="SubscribeCommand",e.UNSUBSCRIBE="UnsubscribeCommand",e.UPDATE_SUBSCRIBE_LIST="UpdateSubscribeListCommand",e.ON_SIGNAL_RECONNECTED="OnSignalReconnectedCommand",e.LEAVE_OTHER_ROOM="LeaveOtherRoomCommand",e.RTC_IDENTITY_CHANGE="RTCIdentityChangeCommand",e.ENABLE_INNER_CDN="EnableInnerCDNCommand",e.EXCHANGE_WITH_PUSH_OTHER_ROOM="ExchangeWithPushOtherRoomCommand",e.MCUCONFIG_FLUSH="MCUConfigFlushCommand",e.UNKNOWN="Unknown"}(So||(So={})),function(e){e[e.LOW=0]="LOW",e[e.NORMAL=1]="NORMAL",e[e.HIGH=2]="HIGH"}(Co||(Co={})),function(e){e[e.Destroy=40400]="Destroy"}(Lo||(Lo={}));class ko{get priority(){return Co.LOW}get kind(){return So.UNKNOWN}}class xo{constructor(e,t,i,r){Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_store",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"abortCode",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_queue",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_busy",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_isDestroyed",{enumerable:!0,configurable:!0,writable:!0,value:!1})}_next(){this._busy=!1,this._execute()}_execute(){return I(this,void 0,void 0,function*(){if(this._isDestroyed||this._busy||0===this._queue.length)return;this._busy=!0;const{command:e,resolve:t}=this._queue.shift();let i;const r=this._logger.createTraceId();try{this._logger.info(he.L_INVOKER_EXECUTE_T,`kind: ${e.kind}, length: ${this._queue.length}`,r),i=yield e.execute(this._context,this._store,this)}catch(t){return console.error(t),this._logger.error(he.L_INVOKER_EXECUTE_R,e.kind,r),void this._next()}const{code:n}=i;n!==ue.SUCCESS&&n!==oe?this._logger.warn(he.L_INVOKER_EXECUTE_R,`code: ${n}, kind: ${e.kind}`,r):this._logger.info(he.L_INVOKER_EXECUTE_R,`kind: ${e.kind}, Done`,r),t(i),this._next()})}push(e){return I(this,void 0,void 0,function*(){return new Promise(t=>{if(this._logger.info(he.L_INVOKER_PUSH_O,JSON.stringify({isDestroyed:this._isDestroyed,kind:e.kind,length:this._queue.length})),this._isDestroyed)return void t({code:ue.NOT_IN_ROOM});const{priority:i}=e;if(i===Co.LOW)this._queue.push({command:e,resolve:t});else{const r=this._queue.findIndex(e=>e.command.priority<i),n=-1===r?this._queue.length-1:r;this._queue.splice(n,0,{command:e,resolve:t})}setTimeout(()=>{this._execute()},0)})})}isDestroyed(){return this._isDestroyed}destroy(){this._isDestroyed||(this._logger.info(he.L_INVOKER_DESTROY_O),this._isDestroyed=!0,this._queue.forEach(e=>{e.resolve({code:this.abortCode})}),this._queue.length=0)}}class Bo extends xo{constructor(e,t){super(e.logger,e,t,ue.ROOM_HAS_BEEN_DESTROYED)}get store(){return this._context.store}destroy(){super.destroy(),this._store.removeRemoteTracks()}}!function(e){e.VOID="0",e.OPEN="2",e.CLOSE="1"}(Oo||(Oo={}));class Vo{constructor(e,t,i,r,n,s,o,a){Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"clientSessionId",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"appkey",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"roomId",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"crtUserId",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"roomMode",{enumerable:!0,configurable:!0,writable:!0,value:s}),Object.defineProperty(this,"isUpgrade",{enumerable:!0,configurable:!0,writable:!0,value:o}),Object.defineProperty(this,"isMainRoom",{enumerable:!0,configurable:!0,writable:!0,value:a}),Object.defineProperty(this,"_roomResources",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_remoteTracks",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_subscribedList",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_collectSubscribeList",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_token",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_sessionId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_CDNUris",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_CDNEnable",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_destroyed",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_trackIdSSRCMap",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),Object.defineProperty(this,"_roomStatusVersion",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_supportNtf",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"_asrStatus",{enumerable:!0,configurable:!0,writable:!0,value:Oo.VOID}),Object.defineProperty(this,"_asrEnable",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_srcLanguage",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(this,"_asrSeiUris",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_isStartRealTranslate",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_translationLang",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(this,"_summarizationStatusData",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_nickName",{enumerable:!0,configurable:!0,writable:!0,value:""})}getResourcesByUserId(e){return this._roomResources[e]||this._asrSeiUris[e]}getRemoteTrack(e){return this._remoteTracks[e]}getRemoteTracksByUserId(e){const t=[];for(const i in this._remoteTracks){const r=this._remoteTracks[i];r.getUserId()===e&&t.push(r)}return t}getRemoteTracks(){return this._remoteTracks}getSessionId(){return this._sessionId}getAllUserIds(){return Object.keys(this._roomResources)}getRemoteUserIds(){return this.getAllUserIds().filter(e=>e!==this.crtUserId)}getSubscribedList(){return this._subscribedList}getCollectSubscribeList(){return this._collectSubscribeList}getPublishedResourceByTrackId(e){const{tag:t,userId:i}=gi(e);return t===Ys?this._asrSeiUris[i][0]:this._roomResources[i].find(t=>hi(t)===e)}getToken(){return this._token}getCDNEnable(){return this._CDNEnable}getCDNUris(){return this._CDNUris}getRoomStatusVersion(){return this._roomStatusVersion}getTrackIdBySSRC(e){return this._trackIdSSRCMap.get(e)}getRTCRequestHeader(){return{"App-Key":this.appkey,RoomId:this.roomId,Token:this._token,RoomType:this.roomMode,UserId:this.crtUserId,"Client-Session-Id":this.clientSessionId}}getSupportNtf(){return this._supportNtf}getASRIsAvailable(){return!!this.getASRSeiUris().length}getASRStatus(){return this._asrStatus}getASREnable(){return this._asrEnable}getSrcLanguage(){return this._srcLanguage}getASRSeiUris(){const e=Object.values(this._asrSeiUris);return e.length?e[0]:[]}getIsStartRealTranslate(){return this._isStartRealTranslate}getTranslationLang(){return this._translationLang}getSummarizationStatusData(){return this._summarizationStatusData||null}getNickName(){return this._nickName}}class Go extends Vo{_updateTrackIdSSRCMap(){Object.values(this._roomResources).forEach(e=>{e.forEach(e=>{const{ssrc:t,resourceId:i}=JSON.parse(e.uri);this._trackIdSSRCMap.set(t,i)})})}setTrackIdSSRCMap(e,t){this._trackIdSSRCMap.set(e,t)}_initRemoteTracks(){for(const e in this._roomResources){const t=this._roomResources[e];e!==this.crtUserId&&0!==t.length&&t.forEach(e=>{const t=hi(e),{tag:i,userId:r,mediaType:n}=gi(t),s=n===Pt.AUDIO_ONLY?new ni(this._logger,i,r):new si(this._logger,i,r);s.__innerSetRemoteMuted(0===e.state),this._remoteTracks[t]=s})}}initWithRoomData(e,t){this._sessionId=e.sessionId,this._token=e.token,this._roomStatusVersion=Ni(e.version),this._roomResources=Ai(e,this.roomId,this._logger,t),this._updateTrackIdSSRCMap(),this._initRemoteTracks(),this.setResourcesByUserId(this.crtUserId,this.getResourcesByUserId(this.crtUserId)||[]),this._logger.info(he.L_PARSE_ROOMDATA_URIS_R,`room data -> ${JSON.stringify(this._roomResources)}`,t)}assignRoomData(e){Object.assign(this._roomResources,e),this._updateTrackIdSSRCMap()}setResourcesByUserId(e,t){this._roomResources[e]=t,this._updateTrackIdSSRCMap()}removeRemoteTrack(e){delete this._remoteTracks[e]}removeResourcesByUserId(e){delete this._roomResources[e],this._updateTrackIdSSRCMap()}addRemoteTrack(e){this._remoteTracks[e.getTrackId()]=e}removeRemoteTracks(){const e=Object.values(this._remoteTracks);e.length&&(e.forEach(e=>{e.isAudioTrack()&&e.__releaseMediaElement()}),this._remoteTracks={})}setCDNEnabel(e){this._CDNEnable=e}setCDNUris(e){this._CDNUris=e}resetSubscribedList(e){this._subscribedList.splice(0,this._subscribedList.length,...e),this.resetCollectSubscribeList(e)}resetCollectSubscribeList(e){this._collectSubscribeList.splice(0,this._collectSubscribeList.length,...e)}setRoomStatusVersion(e){this._roomStatusVersion=Ni(e)}setASRStatus(e){this._asrStatus=e}setASREnable(e){this._asrEnable=e}setSrcLanguage(e){this._srcLanguage=e}setASRSeiUris(e){if(e.length){const{msid:t}=e[0],i=t.split("_")[0];this._asrSeiUris[i]=e}else this._asrSeiUris={}}addSeiRemoteTrack(e){const{msid:t}=e[0],i=t.split("_"),r=i.pop(),n=i[0],s=new si(this._logger,r,n);this.addRemoteTrack(s)}removeSeiRemoteTrack(){if(!this.getASRSeiUris().length)return;const{msid:e,mediaType:t}=this.getASRSeiUris()[0],i=`${e}_${t}`;this.removeRemoteTrack(i)}setIsStartRealTranslate(e){this._isStartRealTranslate=e}setTranslationLang(e){this._translationLang=e}setSummarizationStatusData(e){this._summarizationStatusData=e}setNickName(e){this._nickName=e}}class Fo extends ko{get kind(){return So.UNPUBLISH_PREV}execute(e,t){return I(this,void 0,void 0,function*(){const{logger:i,context:r}=e,n=t.getResourcesByUserId(t.crtUserId),s=n.slice();n.length=0;const o=i.createTraceId();i.info(he.L_UNPUBLISH_PREV_COMMAND_T,JSON.stringify({resource:s}),o);const a=yield r.setRTCTotalRes(t.roomId,[ai(Pi.UNPUBLISH,s)],li([]),Pi.TOTAL_CONTENT_RESOURCE,li([]));return a!==oe?i.error(he.L_UNPUBLISH_PREV_COMMAND_R,JSON.stringify({status:ge.FAILED,code:a}),o):i.info(he.L_UNPUBLISH_PREV_COMMAND_R,JSON.stringify({status:ge.SUCCESSED}),o),{code:ue.SUCCESS}})}}!function(e){e[e.RTC=0]="RTC",e[e.LIVE=2]="LIVE",e[e.CROSS_MUTI=7]="CROSS_MUTI",e[e.SIP=4]="SIP",e[e.CALL=5]="CALL"}(vo||(vo={}));class jo extends ko{constructor(e,t,i,r,n,s,o,a,l){super(),Object.defineProperty(this,"roomId",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"roomType",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"joinType",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"livingType",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"innerUserDatas",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"outerUserDatas",{enumerable:!0,configurable:!0,writable:!0,value:s}),Object.defineProperty(this,"traceId",{enumerable:!0,configurable:!0,writable:!0,value:o}),Object.defineProperty(this,"srcLanguage",{enumerable:!0,configurable:!0,writable:!0,value:a}),Object.defineProperty(this,"nickName",{enumerable:!0,configurable:!0,writable:!0,value:l})}get kind(){return So.JOINROOM}_getResultTag(){let e=he.L_RTC_CLIENT_JOIN_RTC_ROOM_R;return this.roomType===vo.LIVE&&(e=he.L_RTC_CLIENT_JOIN_LIVING_ROOM_R),e}_validateParams(e,t,i){if(e.getConnectionStatus()!==l.CONNECTED)return t.error(i,JSON.stringify({status:ge.FAILED,code:ue.SIGNAL_DISCONNECTED,msg:"im not connected"}),this.traceId),{code:ue.SIGNAL_DISCONNECTED};if(bi(e.getNaviInfo()))return t.error(i,JSON.stringify({status:ge.FAILED,code:ue.PACKAGE_ENVIRONMENT_ERROR,msg:"package environment error"}),this.traceId),{code:ue.PACKAGE_ENVIRONMENT_ERROR};if(!x("roomId",this.roomId,b,!0))return t.error(i,JSON.stringify({status:ge.FAILED,code:ue.PARAMS_ERROR,msg:"params error -> roomId"}),this.traceId),{code:ue.PARAMS_ERROR};if(!x("roomType",this.roomType,e=>void 0!==vo[e]))return t.error(i,JSON.stringify({status:ge.FAILED,code:ue.PARAMS_ERROR,msg:"params error -> roomType"}),this.traceId),{code:ue.PARAMS_ERROR};if(!x("outerUserDatas",this.outerUserDatas,y,!1))return t.error(i,JSON.stringify({status:ge.FAILED,code:ue.PARAMS_ERROR,msg:"params error -> outerUserDatas"}),this.traceId),{code:ue.PARAMS_ERROR};if(this.outerUserDatas){if(!Object.keys(this.outerUserDatas).every(e=>x(`outerUserDatas.${e}`,this.outerUserDatas[e],C,!0)))return t.error(i,JSON.stringify({status:ge.FAILED,code:ue.PARAMS_ERROR,msg:"params error -> outerUserDatas"}),this.traceId),{code:ue.PARAMS_ERROR}}if(this.nickName){if(!x("nickName",this.nickName,C,!0)||this.nickName.length>64)return t.error(i,JSON.stringify({status:ge.FAILED,code:ue.PARAMS_ERROR,msg:"params error -> nickName"}),this.traceId),{code:ue.PARAMS_ERROR}}if(this.srcLanguage){if(!x("srcLanguage",this.srcLanguage,C,!0)||this.srcLanguage.length>50)return t.error(i,JSON.stringify({status:ge.FAILED,code:ue.PARAMS_ERROR,msg:"params error -> srcLanguage"}),this.traceId),{code:ue.PARAMS_ERROR}}return{code:ue.SUCCESS}}execute(e,t,i){return I(this,void 0,void 0,function*(){var r,n,s,o;const a=Date.now(),{context:l,service:_,logger:c,reportMediaActionLogger:d}=e,u=this._getResultTag(),{code:h}=this._validateParams(l,c,u);if(h!==ue.SUCCESS)return{code:h};if(!_.getMsList().length)return c.error(u,JSON.stringify({status:ge.FAILED,code:ue.NOT_OPEN_VIDEO_AUDIO_SERVER,msg:"No audio / video server address available"}),this.traceId),{code:ue.NOT_OPEN_VIDEO_AUDIO_SERVER};const g=t.getSupportNtf(),{code:p,data:f}=yield l.joinRTCRoom(this.roomId,this.roomType,this.livingType,this.joinType,this.innerUserDatas,this.outerUserDatas,g);if(d.reportQualityJoinRoomData(a,p,this.roomType,null==f?void 0:f.sessionId),p!==oe||!f){const e=40032===p?ue.SIGNAL_JOIN_RTC_ROOM_REFUSED:p;return c.error(u,JSON.stringify({status:ge.FAILED,code:e,msg:"joinRoom failed"}),this.traceId),{code:e}}t.initWithRoomData(f,this.traceId),this.nickName&&t.setNickName(this.nickName),this.srcLanguage&&t.setSrcLanguage(this.srcLanguage);t.getResourcesByUserId(t.crtUserId).length>0&&i.push(new Fo);const E=null===(r=f.roomInfo.filter(e=>"cdn_uris"===e.key)[0])||void 0===r?void 0:r.value;E&&t.setCDNUris(JSON.parse(E)[0]);const T=null===(n=f.roomInfo.filter(e=>"asr_status"===e.key)[0])||void 0===n?void 0:n.value;T&&t.setASRStatus(T);const m=null===(s=f.roomInfo.filter(e=>"sei_ai_uris"===e.key)[0])||void 0===s?void 0:s.value;if(m){const e=JSON.parse(m);e.length&&(t.setASRSeiUris(e),t.addSeiRemoteTrack(e))}const I=null===(o=f.roomInfo.filter(e=>"summarization"===e.key)[0])||void 0===o?void 0:o.value;if(I){const e=JSON.parse(I);t.setSummarizationStatusData(e)}return c.info(u,JSON.stringify({status:ge.SUCCESSED,userId:t.crtUserId,roomId:this.roomId,sessionId:f.sessionId}),this.traceId),{code:ue.SUCCESS,data:f}})}}!function(e){e[e.ROOM=1]="ROOM",e[e.PERSON=2]="PERSON"}(bo||(bo={}));const Ho="PEER_CONNECTION_CLOSED_BY_EXCEPTION",Jo="USER_JOIN",$o="USER_LEAVE",Ko="TRACKS_PUBLISH",Yo="TRACKS_UNPUBLISH",qo="AUDIO_MUTE_CHANGE",Wo="VIDEO_MUTE_CHANGE",zo="CDN_ENABLE_CHANGE",Qo="USER_STATE_CHANGE",Zo="ASR_SEI_PUBLISH",Xo="ASR_SEI_UNPUBLISH",ea="SUMMARIZATION_START",ta="SUMMARIZATION_STOP";class ia extends B{constructor(e,t,i,r,n,s,o,a){super(),Object.defineProperty(this,"logger",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"service",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"context",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"runtime",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"peer",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"store",{enumerable:!0,configurable:!0,writable:!0,value:s}),Object.defineProperty(this,"polarisReport",{enumerable:!0,configurable:!0,writable:!0,value:o}),Object.defineProperty(this,"reportMediaActionLogger",{enumerable:!0,configurable:!0,writable:!0,value:a}),Object.defineProperty(this,"getPushOtherRooms",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}}var ra,na,sa,oa;!function(e){e.PUBLISH="publish",e.SUBSCRIBE="subscribe"}(ra||(ra={})),function(e){e.BEGIN="begin",e.END="end"}(na||(na={})),function(e){e[e.SPREAD=0]="SPREAD",e[e.NO_SPREAD=-1]="NO_SPREAD"}(sa||(sa={}));class aa extends ko{constructor(e,t,i){super(),Object.defineProperty(this,"reqBody",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"traceId",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"isNeedUpdateMsas",{enumerable:!0,configurable:!0,writable:!0,value:i})}execute(e,t,i){return I(this,void 0,void 0,function*(){var i;const{service:r,context:n}=e,s=yield r.exchange(t.getRTCRequestHeader(),this.reqBody,this.traceId,this.isNeedUpdateMsas),{code:o,data:a,qualityMsList:l}=s,_={code:o,data:{data:a,qualityMsList:l}},c=null===(i=null==a?void 0:a.urls)||void 0===i?void 0:i.pull_url;if(t.roomMode===vo.LIVE&&c){const e=JSON.parse(c);if(t.setCDNUris(e),(null==e?void 0:e.broadcast)===sa.SPREAD){t.setCDNEnabel(!0);const i=Object.assign(Object.assign({},e),{enableInnerCDN:!0});ha(n,t.roomId,i)}}return _})}}!function(e){e.PUB="pub",e.UNPUB="unpub",e.SUB="sub",e.UNSUB="unsub"}(oa||(oa={}));class la extends ko{constructor(e,t,i,r=oa.SUB,n){super(),Object.defineProperty(this,"tracks",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"forceReq",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"traceId",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"fromCommand",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"unsubTracks",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"_actionStartTime",{enumerable:!0,configurable:!0,writable:!0,value:Date.now()}),Object.defineProperty(this,"_trackMediaMap",{enumerable:!0,configurable:!0,writable:!0,value:{}})}get kind(){return So.UPDATE_SUBSCRIBE_LIST}_dealSubscribeResult(e,t,i,r){const n=null==r?void 0:r.map(e=>`${e.msid}_${e.mediaType}`),s=i.filter(e=>null==n?void 0:n.includes(e.track.getTrackId())),o=i.filter(e=>!(null==n?void 0:n.includes(e.track.getTrackId())));t.info(he.L_ABSTRACT_ROOM_SUBSCRIBE_R,JSON.stringify({status:ge.SUCCESSED,subSuccessTrackIds:n,failedList:o}),this.traceId);const a=e.getRemoteTracks();for(const e in a){const t=s.some(t=>t.track.getTrackId()===e);a[e].__innerSetSubscribed(t);const i=s.some(t=>t.track.getTrackId()===e&&t.subTiny);a[e].isVideoTrack()&&a[e].__innerSetIsTinyTrack(i)}return e.resetSubscribedList(s),o}_getParams(e,t,i){let r=i.map(e=>e instanceof ri?{track:e}:Object.assign({},e));const n={};return r=r.filter(i=>{const r=i.track.getTrackId();return e.getRemoteTrack(r)?!n[r]&&(n[r]=!0,!0):(t.warn(he.L_UPDATE_SUBSCRIBELIST_COMMAND_P,`track cannot found in room -> trackId: ${r}`,this.traceId),!1)}).map(e=>Object.assign({},e)),r}_validateParams(e,t){return x("tracks",t,()=>v(t)&&t.every(e=>e instanceof ri||e.track instanceof ri),!0)?{code:ue.SUCCESS}:(e.warn(he.L_UPDATE_SUBSCRIBELIST_COMMAND_R,JSON.stringify({status:ge.FAILED,code:ue.PARAMS_ERROR,msg:"tracks is invalid"}),this.traceId),{code:ue.PARAMS_ERROR})}_reportPubOrSubQualityData(e,t,i){(null==i?void 0:i.length)&&e.reportPubOrSubQualityData(this.fromCommand,this._actionStartTime,i,t,this._trackMediaMap)}execute(e,t,i){return I(this,void 0,void 0,function*(){const{logger:r,peer:n,reportMediaActionLogger:s,context:o}=e;this._actionStartTime=Date.now();const{tracks:a,forceReq:l}=this,{roomId:_}=t;r.info(he.L_UPDATE_SUBSCRIBELIST_COMMAND_T,`roomId: ${_}, forceReq: ${l}, trackIds: ${a.map(yi)}`,this.traceId);const{code:c}=this._validateParams(r,a);if(c!==ue.SUCCESS)return{code:c};const d=this._getParams(t,r,a),u=t.getSubscribedList().map(e=>Object.assign({},e));if(!l){if(!Ia(d,u))return r.warn(he.L_UPDATE_SUBSCRIBELIST_COMMAND_R,JSON.stringify({status:ge.SUCCESSED,msg:"subscribe list unchanged"}),this.traceId),{code:ue.SUCCESS};if(u.length){const e=u.map(e=>e.track);r.warn(he.L_CLEAR_UNSUBSCRIBE_LIST_O,JSON.stringify({list:e.map(e=>e.getTrackId())}),this.traceId);const i=t.getSubscribedList().filter(t=>e.every(e=>e.getTrackId()!==t.track.getTrackId()));t.resetSubscribedList(i)}}n.__reportR3R4ToPolaris(),n.clearReTryExchangeTimer(),n.updateSubRemoteTracks(d.map(e=>e.track));const h=yield da(d,!1,n,t,o);h.pushOtherRooms=e.getPushOtherRooms();const g=yield new aa(h,this.traceId,!0).execute(e,t,i);a.forEach(e=>{const t=e instanceof ri?e.getTrackId():e.track.getTrackId();this._trackMediaMap[t]=g.data.qualityMsList||[]});const p=this.fromCommand===oa.SUB?a:this.unsubTracks;if(g.code!==ue.SUCCESS)return this._reportPubOrSubQualityData(s,g.code,p),r.error(he.L_UPDATE_SUBSCRIBELIST_COMMAND_R,JSON.stringify({status:ge.FAILED,code:g.code}),this.traceId),{code:g.code};const{sdp:f,resultCode:E,subscribedList:T}=g.data.data;if(E!==ue.SUCCESS)return this._reportPubOrSubQualityData(s,E,p),r.error(he.L_UPDATE_SUBSCRIBELIST_COMMAND_R,JSON.stringify({status:ge.FAILED,code:E}),this.traceId),{code:E};s.setPubOrSubSuccessTime(Date.now());const m=yield n.setRemoteAnswer(f.sdp);if(this._reportPubOrSubQualityData(s,m,p),m!==ue.SUCCESS)return{code:m};const I=this._dealSubscribeResult(t,r,d,T);return I.length?{code:ue.SUCCESS,data:I}:{code:ue.SUCCESS}})}}class _a extends ko{constructor(e,t){super(),Object.defineProperty(this,"tracks",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"traceId",{enumerable:!0,configurable:!0,writable:!0,value:t})}get kind(){return So.UNSUBSCRIBE}execute(e,t,i){return I(this,void 0,void 0,function*(){const{logger:r,polarisReport:n}=e,{tracks:s}=this;if(!x("tracks",s,()=>v(s)&&s.length>0&&s.every(e=>e instanceof ri),!0))return r.warn(he.L_ABSTRACT_ROOM_UNSUBSCRIBE_E,JSON.stringify({status:ge.FAILED,code:ue.PARAMS_ERROR,msg:"params error -> tracks"}),this.traceId),{code:ue.PARAMS_ERROR};r.info(he.L_ABSTRACT_ROOM_UNSUBSCRIBE_T,JSON.stringify({unSubscribeTrackIds:s.map(yi)}),this.traceId);const o=t.getSubscribedList().map(e=>Object.assign({},e)).filter(e=>s.every(t=>t.getTrackId()!==e.track.getTrackId()));return n.sendR2(ra.SUBSCRIBE,na.END,s.map(e=>e.getTrackId())),new la(o,!1,this.traceId,oa.UNSUB,this.tracks).execute(e,t,i)})}}class ca extends ko{constructor(e){super(),Object.defineProperty(this,"tracks",{enumerable:!0,configurable:!0,writable:!0,value:e})}execute(e,t,i){return I(this,void 0,void 0,function*(){const{logger:r}=e,{tracks:n}=this,s=r.createTraceId();return r.info(he.L_USER_LEFT_UNSUBSCRIBE_O,void 0,s),yield new _a(n,s).execute(e,t,i),n.forEach(e=>{e.__innerDestroy(),t.removeRemoteTrack(e.getTrackId())}),e.emit(Yo,n),{code:ue.SUCCESS}})}}function da(e,t,i,r,n){return I(this,void 0,void 0,function*(){var s;const o=(null===(s=n.getNaviInfo())||void 0===s?void 0:s.ipType)||0,a=yield i.createOffer(t),l=r.getSrcLanguage(),_=r.getNickName(),c={resolutionInfo:i.getOutboundVideoInfo()};l&&Object.assign(c,{srcLanguage:l}),_&&Object.assign(c,{nickName:_});return{asr_status:r.getASRStatus(),ipType:o,sdp:a,extend:JSON.stringify(c),subscribeList:e.filter(e=>{const t=e.track.getTrackId(),{userId:i}=gi(t),n=r.getResourcesByUserId(i);if(!n)return!1;const s=n.filter(e=>t===`${e.msid}_${e.mediaType}`).length;return s}).map(e=>({simulcast:e.subTiny?to.TINY:to.NORMAL,resolution:"",uri:r.getPublishedResourceByTrackId(e.track.getTrackId()).uri})),switchstream:!1}})}function ua(e,t,i){return I(this,void 0,void 0,function*(){const r=e.logger.createTraceId();e.logger.info(he.L_LIVING_ROOM_SPREAD_CDN_INFO_T,JSON.stringify({CDNUris:i}),r);const n=yield e.setRTCCDNUris(t,Pi.TOTAL_CONTENT_RESOURCE,JSON.stringify([i]));return n!==oe?(e.logger.error(he.L_LIVING_ROOM_SPREAD_CDN_INFO_R,`status: ${ge.FAILED}, code: ${n}`,r),{code:ue.SIGNAL_ERROR}):(e.logger.info(he.L_LIVING_ROOM_SPREAD_CDN_INFO_R,`status: ${ge.SUCCESSED}`,r),{code:ue.SUCCESS})})}function ha(e,t,i){return I(this,void 0,void 0,function*(){const r=e.logger.createTraceId();e.logger.info(he.L_LIVING_ROOM_SET_ROOM_CDN_INFO_T,`CDNUris: ${i}`,r);const n=yield e.setRTCData(t,"cdn_uris",JSON.stringify([i]),!0,bo.ROOM);return n!==oe?(e.logger.error(he.L_LIVING_ROOM_SET_ROOM_CDN_INFO_R,`status: ${ge.FAILED}, code: ${n}`,r),{code:ue.SIGNAL_ERROR}):(e.logger.info(he.L_LIVING_ROOM_SET_ROOM_CDN_INFO_R,`status: ${ge.SUCCESSED}`,r),{code:ue.SUCCESS})})}function ga(e,t){return I(this,void 0,void 0,function*(){const{roomId:i}=t,r=Object.assign({},t.getCDNUris(),{enableInnerCDN:t.getCDNEnable()});return(yield Promise.all([ua(e,i,r),ha(e,i,r)])).every(e=>e.code===ue.SUCCESS)?{code:ue.SUCCESS}:{code:ue.SIGNAL_ERROR}})}function pa(e,t,i,r,n,s){return I(this,void 0,void 0,function*(){const{logger:o}=i,{roomId:a,roomMode:l}=t,_=[],c={},d={},u={},h=Ai(e,a,o,s),g=Object.keys(h),p=t.getAllUserIds();for(let e=g.length-1;e>=0;e-=1){const i=g[e],r=p.indexOf(i);if(-1===r){_.push(i),c[i]=fi(h[i]);continue}const n=t.getResourcesByUserId(i),s=h[i],{publishedList:o,modifiedList:a,unpublishedList:l}=Ei(n,s,!0);c[i]=fi(o),d[i]=fi(l),u[i]=fi(a),p.splice(r,1)}p.length&&p.forEach(e=>{t.removeResourcesByUserId(e)}),t.assignRoomData(h),p.length&&(yield fa(p,i,t,r,s),i.emit($o,p)),_.length&&i.emit(Jo,_),yield((e,t,i,r)=>I(void 0,void 0,void 0,function*(){const{crtUserId:n}=e;for(const s in r){if(s===n)continue;const o=r[s];if(o.length){const r=o.map(t=>e.getRemoteTrack(hi(t)));yield new ca(r).execute(t,e,i)}}}))(t,i,r,d),((e,t,i)=>{const{logger:r}=t;Object.keys(i).forEach(n=>{const s=i[n];if(0===s.length)return;const o=s.map(t=>{const i=hi(t),{userId:n,tag:s,mediaType:o}=gi(i),a=o===Pt.AUDIO_ONLY?new ni(r,s,n):new si(r,s,n);return e.addRemoteTrack(a),a.__innerSetRemoteMuted(0===t.state),a});o.length&&t.emit(Ko,o)})})(t,i,c),((e,t,i)=>{Object.keys(i).forEach(r=>{i[r].forEach(i=>{const r=hi(i),n=e.getRemoteTrack(r);n.__innerSetRemoteMuted(0===i.state),n.isAudioTrack()?t.emit(qo,n):t.emit(Wo,n)})})})(t,i,u),l===H.LIVE&&function(e,t,i,r){var n;if(!r)return void i.warn(he.L_LIVING_ROOM_RECONNECTED_R,JSON.stringify({status:ge.FAILED,code:"",msg:"cdn_uris not found"}));const s=JSON.parse(r),o=(null===(n=t.getCDNUris())||void 0===n?void 0:n.enableInnerCDN)!==s.enableInnerCDN;t.setCDNUris(s),o&&e.emit(zo,s.enableInnerCDN)}(i,t,o,n)})}function fa(e,t,i,r,n){return I(this,void 0,void 0,function*(){const s=[],o=[];e.forEach(e=>{s.push(...i.getRemoteTracksByUserId(e)),o.push(e)}),s.length&&(yield new _a(s,n).execute(t,i,r),s.forEach(e=>i.removeRemoteTrack(e.getTrackId()))),o.length&&o.forEach(e=>i.removeResourcesByUserId(e))})}function Ea(e){var t;const{userId:i,userData:r,event:n,switchRoleType:s}=e;return{users:[{userId:i,extra:null===(t=r.filter(e=>"extra"===e.key)[0])||void 0===t?void 0:t.value,state:n,switchRoleType:s}]}}function Ta(e){var t,i;const{userId:r,userData:n}=e,s=(e=>e.some(e=>"uris"===e.key||"cdn_uris"===e.key))(n);if(!s)return;const o=null===(t=n.filter(e=>"uris"===e.key)[0])||void 0===t?void 0:t.value,a=null===(i=n.filter(e=>"cdn_uris"===e.key)[0])||void 0===i?void 0:i.value;return{userId:r,content:{uris:o?JSON.parse(o):[],cdn_uris:a&&JSON.parse(a)}}}const ma=(e,t,i)=>{const r=e.split("\r\nm"),n=i===Pt.AUDIO_ONLY?"audio":"video",s=r.filter(e=>e.includes(`=${n}`)&&e.includes(t))[0];let o=new RegExp(`a=ssrc:(.*?) msid:${t}`);const a=s.match(o);return a?a[1]:""},Ia=(e,t)=>{let i=!1;return e.forEach(e=>{const r=t.findIndex(t=>t.track.getTrackId()===e.track.getTrackId());if(-1===r)return void(i=!0);t.splice(r,1)[0].subTiny!==e.subTiny&&(i=!0)}),t.length&&(i=!0),i};class Ra extends ko{constructor(e,t){super(),Object.defineProperty(this,"msgContent",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"traceId",{enumerable:!0,configurable:!0,writable:!0,value:t})}get kind(){return So.PARSE_USERSTATE}get priority(){return Co.NORMAL}_isPKRoomUser(e,t){for(const i of t){if(i.extra&&i.extra.roomId!==e.roomId)return!0;if(1===Number(i.state)&&!e.getRemoteUserIds().includes(i.userId))return!0}return!1}_dealAddUser(e,t,i,r,n){const s=e.getResourcesByUserId(n);s||(r?i.upgrade.push(n):i.joined.push(n),t.info(he.L_PARSE_USERSTATE_COMMAND_R,JSON.stringify({userId:n,msg:"user "+(r?"upgrade":"joined")}),this.traceId)),e.setResourcesByUserId(n,s||[])}_dealReduceUser(e,t,i,r,n){e.info(he.L_PARSE_USERSTATE_COMMAND_R,JSON.stringify({userId:n,msg:"user "+(r?"downgrade":"left")}),this.traceId),r?t.downgrade.push(n):1!==Number(i)?t.offline.push(n):t.left.push(n)}execute(e,t,i){return I(this,void 0,void 0,function*(){const{logger:r}=e,n={joined:[],left:[],offline:[],upgrade:[],downgrade:[]},{users:s}=this.msgContent;if(0===s.length)return{code:ue.SUCCESS,data:n};if(this._isPKRoomUser(t,s))return{code:ue.SUCCESS,data:n};s.forEach(e=>{const{userId:i}=e;0===Number(e.state)?this._dealAddUser(t,r,n,e.switchRoleType,i):this._dealReduceUser(r,n,e.state,e.switchRoleType,i)});const o=[...n.left,...n.downgrade,...n.offline];return o.length&&(yield fa(o,e,t,i,this.traceId)),{code:ue.SUCCESS,data:n}})}}class Sa extends ko{constructor(e,t,i,r,n){super(),Object.defineProperty(this,"msgContent",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"messageType",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"senderId",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"traceId",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"sentTime",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"_publishedList",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_unpublishedList",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_modifiedList",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_nowResources",{enumerable:!0,configurable:!0,writable:!0,value:[]})}get kind(){return So.PARSE_REMOTERES}get priority(){return Co.NORMAL}_dealPublishList(e,t,i){return I(this,void 0,void 0,function*(){const{logger:r,reportMediaActionLogger:n}=e,s=this._nowResources.map(hi),o=[],a=[];if(this._publishedList.forEach(e=>{const i=hi(e),n=s.indexOf(i),{userId:l,tag:_,mediaType:c}=gi(i);n>-1?this._nowResources[n]=e:this._nowResources.push(e);let d=t.getRemoteTrack(i);d?d.isSubscribed()&&o.push(d):(d=c===Pt.AUDIO_ONLY?new ni(r,_,l):new si(r,_,l),t.addRemoteTrack(d),a.push(d)),d.__innerSetRemoteMuted(0===e.state)}),o.length){const n=o.map(e=>e.getTrackId()),{code:s}=yield new la(o,!0,this.traceId).execute(e,t,i);s!==ue.SUCCESS&&r.error(he.L_RESUB_REPUB_RES_R,JSON.stringify({status:ge.FAILED,trackIds:n,code:s}),this.traceId)}a.length&&e.emit(Ko,a),n.reportQualityRecvPubMsgData(this.sentTime,this.senderId)})}_dealUnpublishList(e,t,i){return I(this,void 0,void 0,function*(){const r=this._unpublishedList.map(hi);for(let e=this._nowResources.length-1;e>=0;e-=1){const t=this._nowResources[e];r.includes(hi(t))&&this._nowResources.splice(e,1)}const n=this._unpublishedList.map(e=>{const i=hi(e);return t.getRemoteTrack(i)});yield new ca(n).execute(e,t,i)})}_dealModifiedList(e,t){return I(this,void 0,void 0,function*(){const i=this._nowResources.map(hi);for(const r of this._modifiedList){const n=hi(r),s=i.indexOf(n);this._nowResources[s].state=r.state;const o=t.getRemoteTrack(n);o.__innerSetRemoteMuted(0===r.state),o.isAudioTrack()?e.emit(qo,o):e.emit(Wo,o)}})}_updateCDNUris(e,t){var i,r;const n=this.msgContent.cdn_uris[0],s=(null===(i=t.getCDNUris())||void 0===i?void 0:i.enableInnerCDN)!==n.enableInnerCDN;t.setCDNUris(n),s&&e.emit(zo,!!(null===(r=t.getCDNUris())||void 0===r?void 0:r.enableInnerCDN))}execute(e,t,i){return I(this,void 0,void 0,function*(){const{uris:r}=this.msgContent;let n;this._publishedList=[],this._unpublishedList=[],this._modifiedList=[];const s=this.senderId,{messageType:o}=this;if(!t.getRemoteUserIds().includes(s))return{code:ue.SUCCESS};switch(this._nowResources=t.getResourcesByUserId(s)||[],o){case Pi.MODIFY:this._modifiedList.push(...r);break;case Pi.PUBLISH:this._publishedList.push(...r);break;case Pi.UNPUBLISH:this._unpublishedList.push(...r);break;case Pi.TOTAL_CONTENT_RESOURCE:n=Ei(this._nowResources,r),this._publishedList.push(...n.publishedList),this._unpublishedList.push(...n.unpublishedList),this._modifiedList.push(...n.modifiedList)}if(this._publishedList.length&&(yield this._dealPublishList(e,t,i)),this._unpublishedList.length&&(yield this._dealUnpublishList(e,t,i)),this._modifiedList.length&&(yield this._dealModifiedList(e,t)),t.setResourcesByUserId(s,this._nowResources),t.roomMode!==vo.LIVE)return{code:ue.SUCCESS};return this.msgContent.cdn_uris?(this._updateCDNUris(e,t),{code:ue.SUCCESS}):{code:ue.SUCCESS}})}}class Ca extends ko{constructor(e,t,i){super(),Object.defineProperty(this,"tracks",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"forceReq",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"traceId",{enumerable:!0,configurable:!0,writable:!0,value:i})}get kind(){return So.SUBSCRIBE}execute(e,t,i){return I(this,void 0,void 0,function*(){const{logger:r,polarisReport:n}=e,{tracks:s,forceReq:o}=this;if(!x("tracks",s,()=>v(s)&&s.length>0&&s.every(e=>e instanceof ri||e.track instanceof ri),!0))return r.error(he.L_ABSTRACT_ROOM_SUBSCRIBE_E,JSON.stringify({status:ge.FAILED,code:ue.PARAMS_ERROR,msg:"params error -> tracks"}),this.traceId),{code:ue.PARAMS_ERROR};r.info(he.L_ABSTRACT_ROOM_SUBSCRIBE_T,JSON.stringify({trackIds:s.map(yi),forceReq:o}),this.traceId);const a=t.getSubscribedList().map(e=>Object.assign({},e)),l=s.map(e=>e instanceof ri?{track:e}:e);let _=!1;const c=[];return l.forEach(e=>{const t=e.track.getTrackId();c.push(t);const i=a.find(e=>e.track.getTrackId()===t);i&&i.subTiny===e.subTiny||(i?i.subTiny=e.subTiny:a.push(e),_=!0)}),_||o?(n.sendR2(ra.SUBSCRIBE,na.BEGIN,c),new la(a,!0,this.traceId).execute(e,t,i)):(r.warn(he.L_ABSTRACT_ROOM_SUBSCRIBE_R,JSON.stringify({status:ge.SUCCESSED,msg:"repeat subscribe"}),this.traceId),{code:ue.SUCCESS})})}}class La extends ko{constructor(e){super(),Object.defineProperty(this,"tracks",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_traceId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_actionStartTime",{enumerable:!0,configurable:!0,writable:!0,value:Date.now()}),Object.defineProperty(this,"_trackMediaMap",{enumerable:!0,configurable:!0,writable:!0,value:{}})}get kind(){return So.PUBLISH}_removePubFailedTracks(e,t){e.forEach(e=>{const i=e instanceof Yt?e:e.track;t.removeLocalTrackById(i.getTrackId())})}_addLocalTracks(e,t){return I(this,void 0,void 0,function*(){const i=[];for(const r of e){const{track:e,pubTiny:n}=r instanceof Yt?{pubTiny:!1,track:r}:r;if(e.isVideoTrack()&&n){let r;try{r=e.__innerGetMediaStreamTrack().clone();const t=n.frameRate||yt.FPS_15,i=n.resolution||Nt.W176_H144,{width:s,height:o}=mi(i),a=Si(t);yield r.applyConstraints({width:s,height:o,frameRate:a})}catch(t){null==r||r.stop(),this._logger.warn(he.L_ABSTRACT_ROOM_PUBLISH_E,`pubTiny failed -> id: ${e.getTrackId()}, msg: ${t.message}`,this._traceId);break}const s=new Wt(this._logger,e.getTag(),e.getUserId(),r,!0);i.push(s),t.addLocalTrack(s)}t.addLocalTrack(e)}return i})}__publish(e,t,i,r){return I(this,void 0,void 0,function*(){const{peer:n,reportMediaActionLogger:s,context:o}=e,a=[];i.forEach(e=>{const{track:t}=e instanceof Yt?{track:e}:e;a.push(t)}),i.sort((e,t)=>{const{track:i}=e instanceof Yt?{track:e}:e,{max:r}=i.getBitrate(),{track:n}=t instanceof Yt?{track:t}:t,{max:s}=n.getBitrate();return r-s});if(n.getLocalTracks().length+((e,t)=>{let i=0;return e.forEach(e=>{const r=e instanceof Yt?e.getTrackId():e.track.getTrackId();t.getLocalTrack(r)||(e instanceof Yt?i++:e.pubTiny&&e.track.isVideoTrack()&&(i+=2))}),i})(i,n)>10)return this._logger.error(he.L_ABSTRACT_ROOM_PUBLISH_E,JSON.stringify({status:ge.FAILED,code:ue.PUBLISH_TRACK_LIMIT_EXCEEDED,trackIds:i.map(yi),msg:"publish track limit exceeded"}),this._traceId),{code:ue.PUBLISH_TRACK_LIMIT_EXCEEDED,tracks:a};const l=yield this._addLocalTracks(i,n);n.clearReTryExchangeTimer();const _=t.getSubscribedList(),c=yield da(_,!1,n,t,o);c.pushOtherRooms=e.getPushOtherRooms();const d=yield new aa(c,this._traceId,!0).execute(e,t,r);if(a.forEach(e=>{const t=e.getTrackId();this._trackMediaMap[t]=d.data.qualityMsList||[]}),d.code!==ue.SUCCESS)return s.reportPubOrSubQualityData(oa.PUB,this._actionStartTime,a,d.code,this._trackMediaMap),this._logger.error(he.L_ABSTRACT_ROOM_PUBLISH_E,JSON.stringify({status:ge.FAILED,tracks:i.map(yi),code:d.code,msg:"exchange failed"}),this._traceId),this._removePubFailedTracks(i,n),{code:d.code,tracks:a};const{sdp:u,resultCode:h,message:g}=d.data.data;if(h!==ue.SUCCESS)return s.reportPubOrSubQualityData(oa.PUB,this._actionStartTime,a,h,this._trackMediaMap),this._logger.error(he.L_ABSTRACT_ROOM_PUBLISH_E,JSON.stringify({status:ge.FAILED,trackIds:i.map(yi),code:h,msg:`exchange inner failed: ${g}`}),this._traceId),this._removePubFailedTracks(i,n),{code:h,tracks:a};s.setPubOrSubSuccessTime(Date.now());const p=yield n.setRemoteAnswer(u.sdp,!0);return p!==ue.SUCCESS?(s.reportPubOrSubQualityData(oa.PUB,this._actionStartTime,a,p,this._trackMediaMap),this._logger.error(he.L_ABSTRACT_ROOM_PUBLISH_E,JSON.stringify({status:ge.FAILED,trackIds:i.map(yi),code:p,msg:"set remote answer error"}),this._traceId),{code:p,tracks:a}):(l.length&&this._updateTinyTrackIdSSRCMap(t,c.sdp.sdp,l),Object.assign(Object.assign({code:h},d.data),{tracks:a}))})}_updateTinyTrackIdSSRCMap(e,t,i){i.forEach(i=>{const r=ma(t,i.getStreamId(),Pt.VIDEO_ONLY);e.setTrackIdSSRCMap(Number(r),i.getTrackId())})}_dealPublishRes(e,t,i){return I(this,void 0,void 0,function*(){const{polarisReport:r,context:n,peer:s,reportMediaActionLogger:o}=i,a=t.crtUserId,{roomId:l}=t;let _="";const c=t.getResourcesByUserId(a),d=[...c];let u=[];const{tracks:h}=e;if(e.code!==ue.SUCCESS)return{code:e.code};const{publishList:g,urls:p,mcuPublishList:f}=e.data;_=null==p?void 0:p.liveUrl;g.map(e=>Object.assign({tag:e.msid.split("_").pop(),state:s.getLocalTrack(hi(e)).isLocalMuted()?0:1},e)).forEach(e=>{const{isInclude:t,index:i}=((e,t)=>{let i=!1,r=0;for(let n=0;n<t.length;n++){const s=t[n];if(`${e.msid}_${e.mediaType}`==`${s.msid}_${s.mediaType}`){i=!0,r=n;break}}return{isInclude:i,index:r}})(e,d);t?d.splice(i,1,e):d.push(e)});u=(null==f?void 0:f.map(e=>Object.assign({tag:e.msid.split("_").pop(),state:1},e)))||[];const{publishedList:E}=Ei(c,d),T=Object.assign(Object.assign({},t.getCDNUris()),{enableInnerCDN:t.getCDNEnable()}),m=T&&T.broadcast===sa.SPREAD?JSON.stringify([T]):"",I=Date.now(),R=yield n.setRTCTotalRes(l,[ai(Pi.PUBLISH,E)],li(d),Pi.TOTAL_CONTENT_RESOURCE,li(u),m);if(o.reportPubOrSubQualityData(oa.PUB,this._actionStartTime,h,R,this._trackMediaMap,[{dur:Date.now()-I,cod:R}]),R!==oe)return this._logger.error(he.L_ABSTRACT_ROOM_PUBLISH_R,JSON.stringify({status:ge.FAILED,code:R,msg:"send publish streams notification failed"}),this._traceId),{code:ue.SIGNAL_ERROR};t.setResourcesByUserId(a,d);const S=E.map(e=>hi(e));r.sendR2(ra.PUBLISH,na.BEGIN,S),E.forEach(e=>{s.getLocalTrack(`${e.msid}_${e.mediaType}`).__innerSetPublished(!0)});const C={code:ue.SUCCESS};return _&&(C.liveUrl=_),C})}execute(e,t,i){return I(this,void 0,void 0,function*(){const{logger:r,peer:n}=e;this._traceId=r.createTraceId(),this._logger=r,this._actionStartTime=Date.now();let{tracks:s}=this;if(!x("tracks",s,()=>v(s)&&s.length>0&&s.every(e=>e instanceof Yt||e.track instanceof Yt),!0))return this._logger.error(he.L_ABSTRACT_ROOM_PUBLISH_E,JSON.stringify({status:ge.FAILED,code:ue.PARAMS_ERROR,msg:"params error -> tracks"}),this._traceId),{code:ue.PARAMS_ERROR};if(this._logger.info(he.L_ABSTRACT_ROOM_PUBLISH_T,JSON.stringify({trackIds:s.map(yi)})),s=s.filter(e=>{const{track:t}=e instanceof Yt?{track:e}:e,i=t.isDestroyed();return i&&this._logger.warn(he.L_ABSTRACT_ROOM_PUBLISH_E,`track '${t.getTrackId()}' has beem destroyed`,this._traceId),!i}),!s.length)return this._logger.error(he.L_ABSTRACT_ROOM_PUBLISH_R,JSON.stringify({status:ge.FAILED,code:ue.PUBLISH_TRACKS_IS_INVALID,msg:"params tracks is empty"}),this._traceId),{code:ue.PUBLISH_TRACKS_IS_INVALID};n.__reportR3R4ToPolaris(),n.clearReTryExchangeTimer();const o=yield this.__publish(e,t,s,i);return yield this._dealPublishRes(o,t,e)})}}class Oa extends ko{constructor(e){super(),Object.defineProperty(this,"tracks",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_traceId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_actionStartTime",{enumerable:!0,configurable:!0,writable:!0,value:Date.now()}),Object.defineProperty(this,"_trackMediaMap",{enumerable:!0,configurable:!0,writable:!0,value:{}})}get kind(){return So.UNPUBLISH}__unpublish(e,t,i,r){return I(this,void 0,void 0,function*(){const{peer:n,polarisReport:s,logger:o,reportMediaActionLogger:a,context:l}=e,_=r.map(e=>e.getTrackId());if(0===_.map(t.getPublishedResourceByTrackId.bind(t)).filter(e=>!!e).length)return{code:ue.SUCCESS,tracks:r};_.forEach(e=>n.removeLocalTrackById(e)),s.sendR2(ra.PUBLISH,na.END,_),n.clearReTryExchangeTimer();const c=t.getSubscribedList(),d=yield da(c,!1,n,t,l),u=e.getPushOtherRooms();u.length&&(d.pushOtherRooms=u);const h=yield new aa(d,this._traceId,!0).execute(e,t,i);if(r.forEach(e=>{const t=e.getTrackId();this._trackMediaMap[t]=h.data.qualityMsList||[]}),h.code!==ue.SUCCESS)return a.reportPubOrSubQualityData(oa.UNPUB,this._actionStartTime,r,h.code,this._trackMediaMap),o.error(he.L_ABSTRACT_ROOM_UNPUBLISH_P,JSON.stringify({status:ge.FAILED,code:h.code,trackIds:r.map(yi),msg:"exchange failed"}),this._traceId),{code:h.code,tracks:r};const{resultCode:g,message:p}=h.data.data;return g!==ue.SUCCESS?(a.reportPubOrSubQualityData(oa.UNPUB,this._actionStartTime,r,h.data.data.resultCode,this._trackMediaMap),o.error(he.L_ABSTRACT_ROOM_UNPUBLISH_P,JSON.stringify({status:ge.FAILED,code:g,trackIds:r.map(yi),msg:`exchange inner failed: ${p}`}),this._traceId),{code:g,tracks:r}):Object.assign(Object.assign({code:h.code},h.data),{tracks:r})})}_dealUnpublishRes(e,t,i){return I(this,void 0,void 0,function*(){const{context:r,logger:n,peer:s,reportMediaActionLogger:o}=e,a=r.getCurrentId(),{roomId:l}=t,_=[];let c=[];const{tracks:d,code:u,data:h}=i;if(u!==ue.SUCCESS)return n.error(he.L_ABSTRACT_ROOM_UNPUBLISH_R,JSON.stringify({code:u,msg:"unpublish failed"}),this._traceId),{code:u};if(!h)return n.info(he.L_ABSTRACT_ROOM_UNPUBLISH_R,JSON.stringify({status:ge.SUCCESSED,msg:"unpublish list is empty "})),{code:ue.SUCCESS};const{mcuPublishList:g}=h,p=d.map(e=>e.getTrackId()),f=p.map(t.getPublishedResourceByTrackId.bind(t)).filter(e=>!!e);_.push(...f);c=g?g.map(e=>Object.assign({tag:e.msid.split("_").pop(),state:1},e)):[];const E=t.getResourcesByUserId(a).filter(e=>!_.includes(e)),T=Date.now(),m=yield r.setRTCTotalRes(l,[ai(Pi.UNPUBLISH,_)],li(E),Pi.TOTAL_CONTENT_RESOURCE,li(c));if(o.reportPubOrSubQualityData(oa.UNPUB,this._actionStartTime,d,m,this._trackMediaMap,[{dur:Date.now()-T,cod:m}]),m!==oe)return n.error(he.L_ABSTRACT_ROOM_UNPUBLISH_R,JSON.stringify({status:ge.FAILED,code:m,msg:"send unpublish notification failed"}),this._traceId),{code:ue.SIGNAL_ERROR};n.info(he.L_ABSTRACT_ROOM_UNPUBLISH_R,JSON.stringify({status:ge.SUCCESSED,code:ue.SUCCESS,msg:"unpublish success",unPubResourceIds:p}),this._traceId);const{sdp:I}=i.data;return yield s.setRemoteAnswer(I.sdp),t.setResourcesByUserId(a,E),{code:ue.SUCCESS}})}execute(e,t,i){return I(this,void 0,void 0,function*(){const{logger:r}=e;this._actionStartTime=Date.now();const{crtUserId:n}=t,{tracks:s}=this;this._traceId=r.createTraceId();if(!x("tracks",s,()=>s.every(e=>e.getUserId()===n&&e instanceof Yt),!0))return r.error(he.L_ABSTRACT_ROOM_UNPUBLISH_E,JSON.stringify({status:ge.FAILED,code:ue.PARAMS_ERROR,msg:"params error -> tracks"})),{code:ue.PARAMS_ERROR};r.info(he.L_ABSTRACT_ROOM_UNPUBLISH_T,JSON.stringify({trackIds:s.map(yi)}));const o=yield this.__unpublish(e,t,i,s);return yield this._dealUnpublishRes(e,t,o)})}}class va extends ko{constructor(e){super(),Object.defineProperty(this,"localTrack",{enumerable:!0,configurable:!0,writable:!0,value:e})}get kind(){return So.LOCAL_TRACK_MUTE}execute(e,t,i){return I(this,void 0,void 0,function*(){const{logger:i,context:r}=e,{localTrack:n}=this,s=n.getTrackId(),{crtUserId:o,roomId:a}=t,l=!n.isLocalMuted(),_=i.createTraceId();i.info(he.L_LOCAL_TRACK_SET_LOCAL_MUTED_SPREAD_T,JSON.stringify({enabled:l,trackId:this.localTrack.getTrackId()}),_);const c=[{resourceId:s,enabled:l}],d=t.getResourcesByUserId(o),u=[];for(const e of d){const t=hi(e),i=c.findIndex(e=>e.resourceId===t);if(i>=0){const{enabled:t}=c[i];e.state=t?1:0,u.push(e);break}}const h=yield r.setRTCTotalRes(a,[ai(Pi.MODIFY,u)],li(d),Pi.TOTAL_CONTENT_RESOURCE);return h!==oe?(i.error(he.L_LOCAL_TRACK_SET_LOCAL_MUTED_SPREAD_R,JSON.stringify({status:ge.FAILED,code:h,msg:"signal error"}),_),{code:h}):(i.info(he.L_LOCAL_TRACK_SET_LOCAL_MUTED_SPREAD_R,JSON.stringify({status:ge.SUCCESSED}),_),{code:ue.SUCCESS})})}}class ba extends ko{get kind(){return So.RETRY_EXCHANGE}get priority(){return Co.HIGH}execute(e,t,i){return I(this,void 0,void 0,function*(){const{logger:r,peer:n,context:s}=e,o=r.createTraceId();r.info(he.L_RETRY_EXCHANGE_COMMAND_T);const a=s.getCurrentId(),l=t.getSubscribedList(),_=yield da(l,!0,n,t,s);_.pushOtherRooms=e.getPushOtherRooms();const c=yield new aa(_,o).execute(e,t,i);if(c.code!==ue.SUCCESS)return{code:c.code};const{sdp:d,resultCode:u}=c.data.data;if(u!==ue.SUCCESS)return{code:u};n.clearReTryExchangeTimer();const h=yield n.setRemoteAnswer(d.sdp);if(h!==ue.SUCCESS)return{code:h};const g=c.data.data.publishList||[],{plus:p,minus:f}=this._diffPublishListChange(g,t,n,a);return(p.length||f.length)&&(yield this._spreadPublishListUri(e,a,p,f,o)),{code:ue.SUCCESS}})}_diffPublishListChange(e,t,i,r){const n=t.getResourcesByUserId(r);let s=JSON.parse(JSON.stringify(n));e.forEach(e=>{var t;const{mediaType:r,msid:n}=e,o=s.findIndex(e=>{const{mediaType:t,msid:i}=e;return r===t&&n===i});if(-1===o){const r=Object.assign({tag:n.split("_").pop(),state:(null===(t=i.getLocalTrack(hi(e)))||void 0===t?void 0:t.isLocalMuted)?0:1},e);s.push(r)}else s[o].uri=e.uri});const{publishedList:o,unpublishedList:a}=Ei(n,s,!0);return t.setResourcesByUserId(r,s),{plus:o,minus:a}}_spreadPublishListUri(e,t,i,r,n){return I(this,void 0,void 0,function*(){const{store:s,logger:o}=e,a=s.getResourcesByUserId(t);o.info(he.L_RETRY_EXCHANGE_SPREAD_T,JSON.stringify({plus:i,minus:r,allPublishList:a}),n);const l=[];r.length&&l.push(ai(Pi.UNPUBLISH,r)),i.length&&l.push(ai(Pi.PUBLISH,i));(yield e.context.setRTCTotalRes(s.roomId,l,li(a),Pi.TOTAL_CONTENT_RESOURCE))===oe?o.info(he.L_RETRY_EXCHANGE_SPREAD_R,`status: ${ge.SUCCESSED}`,n):o.error(he.L_RETRY_EXCHANGE_SPREAD_R,`status: ${ge.FAILED}`,n)})}}var Aa;!function(e){e[e.JOIN=0]="JOIN",e[e.LEAVE=1]="LEAVE",e[e.OFFLINE=2]="OFFLINE",e[e.RESOURCECHANGE=3]="RESOURCECHANGE"}(Aa||(Aa={}));class ya extends ko{constructor(e,t,i,r){super(),Object.defineProperty(this,"_roomId",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_traceId",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_targetPullVersion",{enumerable:!0,configurable:!0,writable:!0,value:r})}get kind(){return So.PULL_RTCROOM_STATUS}execute(e,t,i){return I(this,void 0,void 0,function*(){const{logger:r}=e,n=t.getRoomStatusVersion();if(r.info(he.L_PULL_ROOM_STATUS_T,JSON.stringify({roomId:this._roomId,localVersion:n}),this._traceId),this._targetPullVersion&&this._targetPullVersion<=n)return r.info(he.L_PULL_ROOM_STATUS_R,JSON.stringify({status:ge.SUCCESSED,msg:"the roomData has been pulled",localVersion:n,targetPullVersion:this._targetPullVersion}),this._traceId),{code:oe};const{code:s,data:o}=yield this._context.pullRTCRoomStatus(this._roomId,n);if(s!==oe)return r.info(he.L_PULL_ROOM_STATUS_R,JSON.stringify({status:ge.FAILED,code:s}),this._traceId),{code:s};const{bFullStatus:a,version:l,usersData:_,roomStatus:c}=o;if(r.info(he.L_PULL_ROOM_STATUS_R,JSON.stringify({bFullStatus:a,version:Ni(l),usersData:_,roomStatus:c}),this._traceId),t.setRoomStatusVersion(l),a){const{urisData:r,CDNUris:n}=function(e){const t={users:{}};let i="";return e.forEach(e=>{var r,n;const{userId:s,userData:o}=e;t.users[s]={};const a=null===(r=o.filter(e=>"uris"===e.key)[0])||void 0===r?void 0:r.value,l=null===(n=o.filter(e=>"cdn_uris"===e.key)[0])||void 0===n?void 0:n.value;i=l||i,t.users[s]={uris:a}}),{urisData:t,CDNUris:i&&JSON.stringify(JSON.parse(i)[0])}}(_);return yield pa(r,t,e,i,n,this._traceId),{code:s}}for(const r of c)if(r.event===Aa.RESOURCECHANGE){const n=Ta(r);if(!n)continue;const{content:s,userId:o}=n;if(o===t.crtUserId)continue;yield new Sa(s,Pi.TOTAL_CONTENT_RESOURCE,o,this._traceId).execute(e,t,i)}else{const n=Ea(r),{data:s}=yield new Ra(n,this._traceId).execute(e,t,i);e.emit(Qo,s)}return{code:s}})}}class Na extends ko{constructor(e){super(),Object.defineProperty(this,"livingType",{enumerable:!0,configurable:!0,writable:!0,value:e})}get kind(){return So.ON_SIGNAL_RECONNECTED}get priority(){return Co.HIGH}execute(e,t,i){return I(this,void 0,void 0,function*(){const{logger:r,peer:n,context:s}=e,{roomId:o,roomMode:a}=t,l=r.createTraceId();if(r.info(he.L_ABSTRACT_ROOM_IM_RECONNECTED_T,void 0,l),"closed"===n.getRTCPeerConn().connectionState)return r.error(he.L_ABSTRACT_ROOM_IM_RECONNECTED_R,"RTCPeerConnection closed. Please rejoin room to restore services",l),e.emit(Ho),{code:ue.SUCCESS};const{code:_}=yield s.rtcPing(o,a);if(40001===_){(yield this._joinRoom(e,t,i,l))===oe&&(yield this._restoreMediaServer(e,t,i))}else yield new ya(o,l,s).execute(e,t,i);return{code:ue.SUCCESS}})}_joinRoom(e,t,i,r){return I(this,void 0,void 0,function*(){var n,s,o,a;const{context:l,logger:_}=e,{code:c,data:d}=yield l.joinRTCRoom(t.roomId,t.roomMode,this.livingType);if(c!==oe)return void _.error(he.L_ABSTRACT_ROOM_IM_RECONNECTED_R,JSON.stringify({status:ge.FAILED,code:c,msg:"im reconnect joinRTCRoom failed"}),r);if(!d)return void _.info(he.L_ABSTRACT_ROOM_IM_RECONNECTED_R,JSON.stringify({status:ge.FAILED,msg:"im reconnect joinRTCRoom, roomData is empty"}),r);const u=null===(n=d.roomInfo.filter(e=>"cdn_uris"===e.key)[0])||void 0===n?void 0:n.value;yield pa(d,t,e,i,u,r);const h=null===(s=d.roomInfo.filter(e=>"asr_status"===e.key)[0])||void 0===s?void 0:s.value;h&&t.setASRStatus(h);const g=null===(o=d.roomInfo.filter(e=>"sei_ai_uris"===e.key)[0])||void 0===o?void 0:o.value,p=t.getASRIsAvailable();if(g){const i=JSON.parse(g);if(i.length){p||e.emit(Zo),t.setASRSeiUris(i);const{msid:r,mediaType:n}=i[0],s=`${r}_${n}`;!t.getRemoteTrack(s)&&t.addSeiRemoteTrack(i)}else p&&e.emit(Xo),t.removeSeiRemoteTrack(),t.setASRSeiUris(i)}const f=null===(a=d.roomInfo.filter(e=>"summarization"===e.key)[0])||void 0===a?void 0:a.value;if(f){const i=JSON.parse(f),r=t.getSummarizationStatusData();r&&r.status!==i.status&&e.emit(i.status===Qs.OPEN?ea:ta,i.taskId),t.setSummarizationStatusData(i)}return _.info(he.L_ABSTRACT_ROOM_IM_RECONNECTED_R,JSON.stringify({status:ge.SUCCESSED,roomData:d}),r),c})}_restoreMediaServer(e,t,i){return I(this,void 0,void 0,function*(){const r=e.peer.getLocalTracks(),n=Object.values(t.getRemoteTracks()).filter(e=>!!e.isSubscribed());r.length&&(yield new La(r).execute(e,t,i)),!r.length&&n.length&&(yield new Ca(n,!0).execute(e,t,i))})}}const Pa=1,Ua=5;var Da,Ma,wa,ka,xa,Ba,Va,Ga;!function(e){e[e.new=0]="new",e[e.checking=1]="checking",e[e.connected=2]="connected",e[e.completed=3]="completed",e[e.failed=4]="failed",e[e.disconnected=5]="disconnected",e[e.closed=6]="closed"}(Da||(Da={})),function(e){e[e.SERVER_KICK=1]="SERVER_KICK",e[e.OTHER_KICK=2]="OTHER_KICK",e[e.IM_DISCONNECTED=3]="IM_DISCONNECTED",e[e.IM_LOGOUT=4]="IM_LOGOUT",e[e.OTHER_CLIENT_IM_CONNECTED=5]="OTHER_CLIENT_IM_CONNECTED"}(Ma||(Ma={}));class Fa{constructor(e,t,i,r){Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_roomId",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_clientSessionId",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_userId",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_baseReportData",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_networkReportData",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_pubOrSubSuccessTime",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_peerCStatus",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"reportQualityJoinRoomData",{enumerable:!0,configurable:!0,writable:!0,value:(e,t,i,r)=>{this._baseReportData=Object.assign(this._baseReportData,{snid:r});const n=Object.assign(Object.assign(Object.assign({},this._baseReportData),this._networkReportData),{cod:t,time:e,dur:Date.now()-e,rtp:i});this._logger.__statistics(he.L_QS_JOIN_ROOM_S,JSON.stringify(n))}}),this._baseReportData={rid:this._roomId,csnid:this._clientSessionId,snid:"",time:Date.now(),uid:this._userId},this._networkReportData={cr:"unknown",net:"unknown"}}reportQualityKickedData(e){const t=Object.assign(Object.assign(Object.assign({},this._baseReportData),this._networkReportData),{time:Date.now(),cod:e===Ma.OTHER_KICK?Ua:Pa});this._logger.__statistics(he.L_QS_KICKED_S,JSON.stringify(t))}reportPubOrSubQualityData(e,t,i,r,n,s){i.forEach(i=>{var o,a;const l=i instanceof Yt||i instanceof ri?i:i.track,_=l.getTrackId(),{mediaType:c}=gi(_);let d=!1;d=l instanceof Yt?!!l.isVideoTrack()&&(null===(a=(o=l).__isTiny)||void 0===a?void 0:a.call(o)):i.subTiny||!1;const u=Object.assign(Object.assign(Object.assign({},this._baseReportData),this._networkReportData),{resid:_,mtp:c,smct:d?to.TINY:to.NORMAL,stp:"Rongcloud"!==l.getTag()?1:0,cod:r,msas:n?n[_]:[],sigs:s,time:Date.now(),dur:Date.now()-t});switch(e){case"pub":this._logger.__statistics(he.L_QS_PUBLISH_S,JSON.stringify(u));break;case"unpub":this._logger.__statistics(he.L_QS_UNPUBLISH_S,JSON.stringify(u));break;case"sub":this._logger.__statistics(he.L_QS_SUBSCRIBE_S,JSON.stringify(u));break;case"unsub":this._logger.__statistics(he.L_QS_UNSUBSCRIBE_S,JSON.stringify(u))}})}reportQualityRecvPubMsgData(e,t){const i=Object.assign(Object.assign(Object.assign({},this._baseReportData),this._networkReportData),{puid:t,time:Date.now(),dur:Date.now()-e});this._logger.__statistics(he.L_QS_RECV_PUB_MSG_S,JSON.stringify(i))}setPubOrSubSuccessTime(e){this._pubOrSubSuccessTime=e}reportIceFirstConnectData(e){const t=Object.assign(Object.assign(Object.assign({},this._baseReportData),this._networkReportData),{time:this._pubOrSubSuccessTime,dur:Date.now()-this._pubOrSubSuccessTime}),i="pub"===e?he.L_QS_PUB_ICE_STATUS_S:he.L_QS_SUB_ICE_STATUS_S;this._logger.__statistics(i,JSON.stringify(t))}recordQualityIceStatusData(e,t,i){const{status:r,time:n}=this._peerCStatus||{};if(!n)return void(this._peerCStatus={status:t,time:i});const{IP:s,port:o,networkType:a,remoteIP:l,remotePort:_}=e,c=Object.assign(Object.assign(Object.assign({},this._baseReportData),this._networkReportData),{dur:i-n,time:i,pices:Da[r],ices:Da[t],rcdts:[{ip:`${l}:${_}`}],lcdts:[{ip:`${s}:${o}`,nttp:a}],cncdts:[]});this._logger.__statistics(he.L_QS_ICE_STATUS_S,JSON.stringify(c)),this._peerCStatus={status:t,time:i}}}!function(e){e[e.DISABLE=0]="DISABLE",e[e.ENABLE=1]="ENABLE"}(wa||(wa={})),function(e){e[e.MeetingOrAnchor=1]="MeetingOrAnchor",e[e.Audience=2]="Audience"}(ka||(ka={})),function(e){e[e.NOT_REPORT=-1]="NOT_REPORT",e[e.REPORT_SUCCESS=1e4]="REPORT_SUCCESS",e[e.REPORT_FAIL=0]="REPORT_FAIL",e[e.PB_ERROR=40001]="PB_ERROR"}(xa||(xa={})),function(e){e.R1="R1",e.R2="R2",e.R3="R3",e.R4="R4"}(Ba||(Ba={}));class ja{constructor(e,t,i,r,n=ka.MeetingOrAnchor){Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_runtime",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_roomId",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_crtRTCRoom",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_userRole",{enumerable:!0,configurable:!0,writable:!0,value:n})}_send(e){return I(this,void 0,void 0,function*(){if(this._context.getConnectionStatus()!==l.CONNECTED)return xa.NOT_REPORT;return(yield this._context.setRTCState(this._roomId,e))===oe?xa.REPORT_SUCCESS:xa.REPORT_FAIL})}_getClientID(){const e="uuid";let t=this._runtime.localStorage.getItem(e);return t||(t=Ti(),this._runtime.localStorage.setItem(e,t)),t}_getRealResourceId(e){let t=e;const i=e.indexOf("_tiny");return i>-1&&(t=e.slice(0,i)),t}_getPolarisTrackId(e){let t="";const i=e.split("_");if(e.includes("_tiny")){const e=i.pop(),r=parseInt(i.pop())===Pt.AUDIO_ONLY?"audio":"video",n=i.pop();t=[i.join("_"),n,e,r].join("_")}else{const e=parseInt(i.pop())===Pt.AUDIO_ONLY?"audio":"video",r=i.pop();t=[i.join("_"),r,e].join("_")}return t}_getBaseData(e){return{bitrateSend:(null==e?void 0:e.bitrateSend)||Ks,bitrateRecv:(null==e?void 0:e.bitrateRecv)||Ks,networkType:(null==e?void 0:e.networkType)||"unknown",rtt:(null==e?void 0:e.rtt)||Ks,localAddress:`${(null==e?void 0:e.IP)||Ks}:${null==e?void 0:e.port}`,remoteAddress:`${null==e?void 0:e.remoteIP}:${null==e?void 0:e.remotePort}`,receiveBand:(null==e?void 0:e.availableIncomingBitrate)||Ks,sendBand:(null==e?void 0:e.availableOutgoingBitrate)||Ks,packetsLost:(null==e?void 0:e.totalPacketsLost)||Ks,deviceId:this._context.getCurrentId()}}_getAudioLevel(e){return e||0===e?e:Ks}_getBitrate(e){return e||0===e?e:Ks}_getPacketsLostRate(e){return e||0===e?e:Ks}_getFrameRate(e){return e||Ks}_getResolution(e,t){return e&&t?`${e} * ${t}`:"-1"}_getJitter(e){return e||Ks}_getNackCount(e){return e||0===e?e:Ks}_getPliCount(e){return e||0===e?e:Ks}_getRTT(e){return e||Ks}_getTrackState(e,t){const i=e?this._crtRTCRoom.getLocalTrack(t):this._crtRTCRoom.getRemoteTrack(t);return(null==i?void 0:i.isLocalMuted())?wa.DISABLE:wa.ENABLE}sendR3Data(e){return I(this,void 0,void 0,function*(){const{iceCandidatePair:t,senders:i}=e,r=this._getBaseData(t);let n=`R3\t${r.bitrateSend}\t-1\t-1\t-1\t${r.networkType}\t${r.rtt}\t${r.localAddress}\t${r.receiveBand}\t${r.sendBand}\t${r.packetsLost}\t${r.deviceId}\r`;n+=i.map(e=>{const{trackId:t,audioLevel:i,samplingRate:r,bitrate:n,packetsLostRate:s,frameRate:o,frameWidth:a,frameHeight:l,googRenderDelayMs:_,jitter:c,nackCount:d,pliCount:u,rtt:h,googFirsSent:g,encoderImplementation:p}=e,f=this._getPolarisTrackId(t),E=this._getRealResourceId(t);return{trackId:f,googCodecName:p||String(Ks),audioLevel:this._getAudioLevel(i),bitrate:this._getBitrate(n),packetsLostRate:this._getPacketsLostRate(s),frameRate:this._getFrameRate(o),resolution:this._getResolution(a,l),jitter:this._getJitter(c),nackCount:this._getNackCount(d),pliCount:this._getPliCount(u),rtt:this._getRTT(h),googFirsSent:g,samplingRate:r,googRenderDelayMs:_,encoderImplementation:p||String(Ks),trackState:this._getTrackState(!0,E)}}).map(e=>`${e.trackId}\t${e.googCodecName}\t${e.audioLevel}\t${e.samplingRate}\t${e.bitrate}\t${e.packetsLostRate}\t${e.frameRate}\t${e.resolution}\t${e.googRenderDelayMs}\t${e.jitter}\t${e.nackCount}\t${e.pliCount}\t${e.rtt}\t${e.googFirsSent}\t${e.encoderImplementation}\t${e.trackState}`).join("\n");return(yield this._send(`${n}\r${this._userRole}`))!==xa.REPORT_SUCCESS?xa.REPORT_FAIL:xa.REPORT_SUCCESS})}sendR4Data(e){return I(this,void 0,void 0,function*(){const{iceCandidatePair:t,receivers:i}=e,r=this._getBaseData(t);let n=`R4\t${r.bitrateRecv}\t-1\t-1\t-1\t${r.networkType}\t${r.rtt}\t${r.localAddress}\t${r.receiveBand}\t${r.sendBand}\t${r.packetsLost}\t${r.deviceId}\r`;n+=i.filter(e=>!!e.trackId).map(e=>{const{trackId:t,audioLevel:i,samplingRate:r,bitrate:n,packetsLostRate:s,frameRate:o,frameWidth:a,frameHeight:l,googRenderDelayMs:_,jitter:c,nackCount:d,pliCount:u,rtt:h,googFirsReceived:g,codecImplementationName:p}=e,f=this._getPolarisTrackId(t),E=this._getRealResourceId(t);return{trackId:f,googCodecName:p||String(Ks),audioLevel:this._getAudioLevel(i),bitrate:this._getBitrate(n),packetsLostRate:this._getPacketsLostRate(s),frameRate:this._getFrameRate(o),resolution:this._getResolution(a,l),jitter:this._getJitter(c),nackCount:this._getNackCount(d),pliCount:this._getPliCount(u),rtt:this._getRTT(h),googFirsReceived:g,samplingRate:r,googRenderDelayMs:_,codecImplementationName:p||String(Ks),trackState:this._getTrackState(!1,E)}}).map(e=>`${e.trackId}\t${e.googCodecName}\t${e.audioLevel}\t${e.samplingRate}\t${e.bitrate}\t${e.packetsLostRate}\t${e.frameRate}\t${e.resolution}\t${e.googRenderDelayMs}\t${e.jitter}\t${e.nackCount}\t${e.pliCount}\t${e.rtt}\t${e.googFirsReceived}\t${e.codecImplementationName}\t${e.trackState}`).join("\n");return(yield this._send(`${n}\r${this._userRole}`))!==xa.REPORT_SUCCESS?xa.REPORT_FAIL:xa.REPORT_SUCCESS})}sendR1(){var e;const t=this._context.getCoreVersion(),i=(null===(e=navigator.userAgentData)||void 0===e?void 0:e.platformn)||navigator.platform,r=`R1\t26.1.0\t${t}\tweb\t${i}\t-1\t${Ci.browser}\t${Ci.version}\t${this._getClientID()}\t${this._userRole}`;this._send(r)}sendR2(e,t,i){const r=`R2\t${e}\t${t}\t${this._getClientID()}\r${i.join("\t")}\r${this._userRole}`;this._send(r)}}class Ha extends ko{constructor(e,t){super(),Object.defineProperty(this,"oldTrack",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"newTrack",{enumerable:!0,configurable:!0,writable:!0,value:t})}execute(e,t,i){return I(this,void 0,void 0,function*(){const{peer:r,logger:n}=e;if(!this.oldTrack||!this.newTrack)return n.error(he.L_RTC_CLIENT_CHANGE_MEDIA_DEVICE_R,"oldTrack or newTrack is empty"),{code:ue.PARAMS_ERROR};if([ei,Xt].every(e=>!(this.oldTrack instanceof e)))return n.error(he.L_RTC_CLIENT_CHANGE_MEDIA_DEVICE_R,"oldTrack is not RCCameraVideoTrack or RCMicphoneAudioTrack"),{code:ue.PARAMS_ERROR};if([ei,Xt].every(e=>!(this.newTrack instanceof e)))return n.error(he.L_RTC_CLIENT_CHANGE_MEDIA_DEVICE_R,"newTrack is not RCCameraVideoTrack or RCMicphoneAudioTrack"),{code:ue.PARAMS_ERROR};const s=this.oldTrack.getSettings(),o=this.newTrack.getSettings(),a=this.oldTrack.getTrackId(),l=this.newTrack.getTrackId(),_=this.oldTrack.isAudioTrack()?"audio":"video",c=this.newTrack.isAudioTrack()?"audio":"video";if(n.info(he.L_RTC_CLIENT_CHANGE_MEDIA_DEVICE_T,JSON.stringify({oldTrackId:a,newTrackId:l,oldSettings:s,newSettings:o})),!this.oldTrack.isPublished())return n.error(he.L_RTC_CLIENT_CHANGE_MEDIA_DEVICE_R,"oldTrack is not published"),{code:ue.PARAMS_ERROR};if(a!==l)return n.error(he.L_RTC_CLIENT_CHANGE_MEDIA_DEVICE_R,`oldTrack and newTrack trackId are different, oldTrackId: ${a}, newTrackId: ${l}`),{code:ue.PARAMS_ERROR};if(_!==c)return n.error(he.L_RTC_CLIENT_CHANGE_MEDIA_DEVICE_R,`oldTrack and newTrack are not the same kind, oldTrackKind: ${_}, newTrackKind: ${c}`),{code:ue.PARAMS_ERROR};if((null==s?void 0:s.deviceId)===(null==o?void 0:o.deviceId))return n.error(he.L_RTC_CLIENT_CHANGE_MEDIA_DEVICE_R,`oldTrack and newTrack deviceId are the same, oldDeviceId: ${null==s?void 0:s.deviceId}, newDeviceId: ${null==o?void 0:o.deviceId}`),{code:ue.PARAMS_ERROR};r.addLocalTrack(this.newTrack);const d=(null==s?void 0:s.width)!==(null==o?void 0:o.width)||(null==s?void 0:s.height)!==(null==o?void 0:o.height)||(null==s?void 0:s.frameRate)!==(null==o?void 0:o.frameRate),u=r.getLocalTrack(`${this.oldTrack.getTrackId()}_tiny`);if(!d)return u&&u.destroy(),this.oldTrack.destroy(!1),this.newTrack.__innerSetPublished(!0),n.info(he.L_RTC_CLIENT_CHANGE_MEDIA_DEVICE_R,"changeMediaDevice success"),{code:ue.SUCCESS};const h=yield(new ba).execute(e,t,i);return h.code!==ue.SUCCESS?(r.removeLocalTrack(this.newTrack,!1),r.addLocalTrack(this.oldTrack),this.newTrack.destroy(),n.error(he.L_RTC_CLIENT_CHANGE_MEDIA_DEVICE_R,`negotiation failed, code: ${h.code}`),{code:h.code}):(u&&u.destroy(),this.oldTrack.destroy(!1),this.newTrack.__innerSetPublished(!0),n.info(he.L_RTC_CLIENT_CHANGE_MEDIA_DEVICE_R,"changeMediaDevice success"),{code:h.code})})}}!function(e){e[e.OPEN=1]="OPEN",e[e.CLOSE=0]="CLOSE"}(Va||(Va={}));class Ja extends ko{constructor(e){super(),Object.defineProperty(this,"_type",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_traceId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}execute(e,t,i){return I(this,void 0,void 0,function*(){const{logger:i,context:r,service:n}=e;this._traceId=i.createTraceId(),this._logger=i,this._logger.info(he.L_ABSTRACT_ROOM_OPERATE_ASR_STATUS_T,`type: ${this._type}`,this._traceId);const s=r.getNaviInfo();if((null==s?void 0:s.rtcAISwitch)===Va.CLOSE)return this._logger.error(he.L_ABSTRACT_ROOM_OPERATE_ASR_STATUS_R,JSON.stringify({code:ue.ASR_NOT_AVAILABLE}),this._traceId),{code:ue.ASR_NOT_AVAILABLE};if(this._type===t.getASRStatus())return this._logger.info(he.L_ABSTRACT_ROOM_OPERATE_ASR_STATUS_R,JSON.stringify({code:ue.SUCCESS}),this._traceId),{code:ue.SUCCESS};const{roomId:o}=t,a=yield r.setRTCData(o,"asr_status",this._type.toString(),!0,bo.ROOM,{name:Pi.ASR_STATUS,content:JSON.stringify({asr_status:this._type.toString()})});if(a!==oe)return this._logger.error(he.L_ABSTRACT_ROOM_OPERATE_ASR_STATUS_R,JSON.stringify({code:a}),this._traceId),{code:ue.SIGNAL_ERROR};t.setASRStatus(this._type);const l=yield n.updateASRStatus(t.getRTCRequestHeader(),{asr_status:this._type},this._traceId),{code:_,data:c}=l;if(_!==ue.SUCCESS||(null==c?void 0:c.resultCode)!==ue.SUCCESS&&42200!==(null==c?void 0:c.resultCode)){const e=_!==ue.SUCCESS?_:null==c?void 0:c.resultCode;return this._logger.error(he.L_ABSTRACT_ROOM_OPERATE_ASR_STATUS_R,JSON.stringify({code:e}),this._traceId),{code:e}}return this._logger.info(he.L_ABSTRACT_ROOM_OPERATE_ASR_STATUS_R,JSON.stringify({code:ue.SUCCESS}),this._traceId),{code:ue.SUCCESS}})}}class $a extends ko{constructor(e){super(),Object.defineProperty(this,"_enable",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_traceId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}_updateSubSei(e,t,i,r){const n=`${e[0].msid}_${e[0].mediaType}`,s=i.getRemoteTrack(n);return this._enable?new Ca([s]).execute(t,i,r):new _a([s],this._traceId).execute(t,i,r)}execute(e,t,i){return I(this,void 0,void 0,function*(){const{logger:r,context:n}=e;this._traceId=r.createTraceId(),this._logger=r,this._logger.info(he.L_ABSTRACT_ROOM_SET_ENABLE_ASR_T,`enable: ${this._enable}`,this._traceId),t.setASREnable(this._enable);const s=n.getNaviInfo();if((null==s?void 0:s.rtcAISwitch)===Va.CLOSE)return this._logger.error(he.L_ABSTRACT_ROOM_SET_ENABLE_ASR_R,JSON.stringify({code:ue.ASR_NOT_AVAILABLE}),this._traceId),{code:ue.ASR_NOT_AVAILABLE};const o=t.getASRSeiUris();if(!o.length)return this._logger.info(he.L_ABSTRACT_ROOM_SET_ENABLE_ASR_R,JSON.stringify({code:ue.SUCCESS,asrSeiUrisLength:0}),this._traceId),{code:ue.SUCCESS};const{code:a}=yield this._updateSubSei(o,e,t,i);return a!==ue.SUCCESS?(this._logger.error(he.L_ABSTRACT_ROOM_SET_ENABLE_ASR_R,JSON.stringify({code:a}),this._traceId),{code:a}):(this._logger.info(he.L_ABSTRACT_ROOM_SET_ENABLE_ASR_R,JSON.stringify({code:ue.SUCCESS}),this._traceId),{code:ue.SUCCESS})})}}!function(e){e[e.OPEN=1]="OPEN",e[e.CLOSE=0]="CLOSE"}(Ga||(Ga={}));class Ka extends ko{constructor(e,t){super(),Object.defineProperty(this,"_status",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_destLanguage",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_traceId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}_operateWithRetry(e,t){return I(this,arguments,void 0,function*(e,t,i=3,r=3e3){for(let n=1;n<=i;n++){try{const{code:i,data:r}=yield t.operateRealtimeTranslation(e.getRTCRequestHeader(),{status:this._status},this._traceId);if(i===ue.SUCCESS)return;console.warn(`第 ${n} 次调用失败,code=${i}`)}catch(e){console.error(`第 ${n} 次调用异常:`,e)}n<i&&(yield new Promise(e=>{setTimeout(e,r)}))}})}execute(e,t,i){return I(this,void 0,void 0,function*(){const{logger:i,service:r,context:n}=e;this._traceId=i.createTraceId(),this._logger=i,this._logger.info(he.L_ABSTRACT_ROOM_OPERATE_REALTIME_TRANSLATION_T,JSON.stringify({status:this._status,destLanguage:this._destLanguage}),this._traceId);const s=n.getNaviInfo();if((null==s?void 0:s.rtcAISwitch)===Va.CLOSE)return this._logger.error(he.L_ABSTRACT_ROOM_OPERATE_REALTIME_TRANSLATION_R,JSON.stringify({code:ue.ASR_NOT_AVAILABLE}),this._traceId),{code:ue.ASR_NOT_AVAILABLE};if(this._status===Ga.OPEN){if(!this._destLanguage)return this._logger.error(he.L_ABSTRACT_ROOM_OPERATE_REALTIME_TRANSLATION_R,JSON.stringify({code:ue.PARAMS_ERROR}),this._traceId),{code:ue.PARAMS_ERROR};if(!t.getASRSeiUris().length)return this._logger.error(he.L_ABSTRACT_ROOM_OPERATE_REALTIME_TRANSLATION_R,JSON.stringify({code:ue.ASR_NOT_START}),this._traceId),{code:ue.ASR_NOT_START}}const o={status:this._status};this._destLanguage&&(o.destLanguage=this._destLanguage);const{code:a,data:l}=yield r.operateRealtimeTranslation(t.getRTCRequestHeader(),o,this._traceId);if(this._status===Ga.CLOSE)return t.setIsStartRealTranslate(!1),this._logger.info(he.L_ABSTRACT_ROOM_OPERATE_REALTIME_TRANSLATION_R,JSON.stringify({code:ue.SUCCESS}),this._traceId),a!==ue.SUCCESS&&this._operateWithRetry(t,r),{code:ue.SUCCESS};if(a!==ue.SUCCESS||(null==l?void 0:l.resultCode)!==ue.SUCCESS){const e=a!==ue.SUCCESS?a:null==l?void 0:l.resultCode;return this._logger.error(he.L_ABSTRACT_ROOM_OPERATE_REALTIME_TRANSLATION_R,JSON.stringify({code:e}),this._traceId),{code:e}}return t.setIsStartRealTranslate(!0),this._destLanguage&&t.setTranslationLang(this._destLanguage),this._logger.info(he.L_ABSTRACT_ROOM_OPERATE_REALTIME_TRANSLATION_R,JSON.stringify({code:ue.SUCCESS}),this._traceId),{code:ue.SUCCESS}})}}class Ya extends ko{constructor(e){super(),Object.defineProperty(this,"_type",{enumerable:!0,configurable:!0,writable:!0,value:e})}execute(e,t){return I(this,void 0,void 0,function*(){return t.setASRStatus(this._type),{code:ue.SUCCESS}})}}class qa extends ko{constructor(e){super(),Object.defineProperty(this,"_asrSeiUris",{enumerable:!0,configurable:!0,writable:!0,value:e})}_setEnableAsr(e,t,i){return I(this,void 0,void 0,function*(){const r=t.getASREnable();r&&(yield new $a(this._asrSeiUris.length>0).execute(e,t,i),t.setASREnable(r))})}_onPublish(e,t,i){e.emit(Zo),t.setASRSeiUris(this._asrSeiUris),t.addSeiRemoteTrack(this._asrSeiUris),this._setEnableAsr(e,t,i)}_onUnPublish(e,t,i){return I(this,void 0,void 0,function*(){e.emit(Xo),yield this._setEnableAsr(e,t,i),t.removeSeiRemoteTrack(),t.setASRSeiUris(this._asrSeiUris)})}execute(e,t,i){return I(this,void 0,void 0,function*(){return this._asrSeiUris.length?this._onPublish(e,t,i):this._onUnPublish(e,t,i),{code:ue.SUCCESS}})}}class Wa extends ko{constructor(e){super(),Object.defineProperty(this,"_isStart",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_traceId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}execute(e,t,i){return I(this,void 0,void 0,function*(){var i,r;const{logger:n,context:s,service:o}=e;this._traceId=n.createTraceId(),this._logger=n,this._logger.info(he.L_ABSTRACT_ROOM_OPERATE_SUMMARIZATION_T,`isStart: ${this._isStart}`,this._traceId);const a=s.getNaviInfo();if((null==a?void 0:a.rtcAISwitch)===Va.CLOSE)return this._logger.error(he.L_ABSTRACT_ROOM_OPERATE_SUMMARIZATION_R,JSON.stringify({code:ue.ASR_NOT_AVAILABLE}),this._traceId),{code:ue.ASR_NOT_AVAILABLE};if(!t.getASRSeiUris().length)return this._logger.error(he.L_ABSTRACT_ROOM_OPERATE_REALTIME_TRANSLATION_R,JSON.stringify({code:ue.ASR_NOT_START}),this._traceId),{code:ue.ASR_NOT_START};if((null===(i=t.getSummarizationStatusData())||void 0===i?void 0:i.status)===Qs.OPEN&&this._isStart||(null===(r=t.getSummarizationStatusData())||void 0===r?void 0:r.status)===Qs.CLOSE&&!this._isStart)return this._logger.info(he.L_ABSTRACT_ROOM_OPERATE_SUMMARIZATION_R,JSON.stringify({isStart:this._isStart,code:ue.SUCCESS,taskId:t.getSummarizationStatusData().taskId}),this._traceId),{code:ue.SUCCESS,taskId:t.getSummarizationStatusData().taskId};const l={status:this._isStart?Qs.OPEN:Qs.CLOSE},{code:_,data:c}=yield o.operateSummarization(t.getRTCRequestHeader(),l,this._traceId);return _!==ue.SUCCESS?(this._logger.error(he.L_ABSTRACT_ROOM_OPERATE_SUMMARIZATION_R,JSON.stringify({isStart:this._isStart,code:_}),this._traceId),{code:_}):(t.setSummarizationStatusData({taskId:c.taskId,status:this._isStart?Qs.OPEN:Qs.CLOSE}),this._logger.info(he.L_ABSTRACT_ROOM_OPERATE_SUMMARIZATION_R,JSON.stringify({isStart:this._isStart,code:ue.SUCCESS,taskId:null==c?void 0:c.taskId}),this._traceId),{code:ue.SUCCESS,taskId:null==c?void 0:c.taskId})})}}class za extends ko{constructor(e,t){super(),Object.defineProperty(this,"_status",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_taskId",{enumerable:!0,configurable:!0,writable:!0,value:t})}execute(e,t){return I(this,void 0,void 0,function*(){return t.setSummarizationStatusData({status:this._status,taskId:this._taskId}),e.emit(this._status===Qs.OPEN?ea:ta,this._taskId),{code:ue.SUCCESS}})}}const Qa="evt-leave";class Za extends B{constructor(e,t,i,r,n,s,o,a,l=qs(),_=!1){super(),Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_runtime",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_roomId",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_service",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"_initOptions",{enumerable:!0,configurable:!0,writable:!0,value:s}),Object.defineProperty(this,"_clientSessionId",{enumerable:!0,configurable:!0,writable:!0,value:l}),Object.defineProperty(this,"_pinger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_polarisReport",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_audioLevelReport",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_peerConnection",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_invoker",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_store",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_reportMediaActionLogger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_executeCtx",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_appListener",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_onRecvPKMsg",{enumerable:!0,configurable:!0,writable:!0,value:null});const c=this._logger=this._context.logger;this._reportMediaActionLogger=new Fa(c,this._roomId,this._clientSessionId,this._context.getCurrentId()),this._polarisReport=new ja(this._context,this._runtime,this._roomId,this);const d=this._context.getCurrentId(),u=new Go(c,l,this._context.getAppkey(),i,d,r,o,a),h=this._peerConnection=new Mo(e,c,this._reTryExchange.bind(this),d,u,this._polarisReport,!1,_);this._setPeerConnectionListener();const g=this._executeCtx=new ia(c,this._service,e,t,h,u,this._polarisReport,this._reportMediaActionLogger);g.getPushOtherRooms=()=>this._getPushOtherRoomsParams(),this.setCommandEventListener(),this._invoker=new Bo(g,u),this._store=this._invoker.store,this._audioLevelReport=new wo(this._store,h),h.on(Mo.__INNER_AUDIOLEVEL_CHANGE__,this._audioLevelReport.audioLevelReport,this._audioLevelReport),this._pinger=new Di(this._context,this._roomId,r,this._initOptions.pingGap),this._pinger.onFailed=this.__kickoff.bind(this),this._pinger.onPingResult=this._handlePingResult.bind(this),this._context.registerRTCSignalListener(e=>I(this,void 0,void 0,function*(){const{time:t,type:i,roomId:r}=this._context.decodeRtcNotify(e);if(this._invoker.isDestroyed())this._logger.info(he.L_RTCNTF_PULL_ROOM_STATUS_O,JSON.stringify({isDestroyed:!0,type:i,time:t,roomId:r}));else if(2===i&&r===this._roomId){const e=this._logger.createTraceId();this._logger.info(he.L_RTCNTF_PULL_ROOM_STATUS_O,null,e),this._startPullRTCRoomStatus(r,e,t)}}))}_setPeerConnectionListener(){const e=this._peerConnection;e.on(Mo.__INNER_EVENT_TRACK_READY__,this._onTrackReady,this),e.on(Yt.__INNER_EVENT_MUTED_CHANGE__,this._onLocalTrackMuted,this),e.on(Yt.__INNER_EVENT_DESTROY__,this._onLocalTrackDestroied,this),e.once(Mo.__INNER_ICE_CONNECTED__,e=>{this._reportMediaActionLogger.reportIceFirstConnectData(e?"pub":"sub")},this),e.on(Mo.__INNER_ICE_STATE_CHANGE__,e=>{const{status:t,time:i,iceCandidatePair:r}=e;r&&this._reportMediaActionLogger.recordQualityIceStatusData(r,t,i)}),e.on(Mo.__INNER_SEI_CONTENT__,this._onReceiveAsrSeiContent,this)}setCommandEventListener(){const e=this._executeCtx;e.on(Ho,this._rtcpeerClosed,this),e.on(Jo,this._callAppListener.bind(this,"onUserJoin"),this),e.on($o,this._callAppListener.bind(this,"onUserLeave"),this),e.on(Ko,this._onTrackPublish,this),e.on(Yo,this._onTrackUnpublish,this),e.on(qo,this._onAudioMuteChange,this),e.on(Wo,this._onVideoMuteChange,this),e.on(zo,this._callAppListener.bind(this,"onCDNEnableChange"),this),e.on(Qo,this._dealUserAppListener,this),e.on(Zo,this._callAppListener.bind(this,"onReceiveStartASR"),this),e.on(Xo,this._callAppListener.bind(this,"onReceiveStopASR"),this),e.on(ea,this._callAppListener.bind(this,"onReceiveStartSummarization"),this),e.on(ta,this._callAppListener.bind(this,"onReceiveStopSummarization"),this)}_startPullRTCRoomStatus(e,t,i){return I(this,void 0,void 0,function*(){yield this._invoker.push(new ya(e,t,this._context,i))})}__innerInit(e,t,i,r,n,s,o,a){return I(this,void 0,void 0,function*(){const{code:l,data:_}=yield this._invoker.push(new jo(this._roomId,e,t,i,r,n,s,o,a));return l!==ue.SUCCESS?{code:l}:(this._initWithRoomData(_.offlineKickTime),{code:l,data:_})})}_initWithRoomData(e){this._pinger.start(1e3*e),this._polarisReport.sendR1()}_handlePingResult(e,t){if(e===Ui.SUCCESS){if(t>this._store.getRoomStatusVersion()&&this._store.getSupportNtf()){const e=this._logger.createTraceId();this._logger.info(he.L_RTCPING_PULL_ROOM_STATUS_O,JSON.stringify({dataVersion:t}),e),this._startPullRTCRoomStatus(this._roomId,e,t)}}this._callAppListener("onPing",e)}setBitrate(e,t,i){this._logger.warn(he.L_ABSTRACT_ROOM_SETBITRATE_O,"`RCAbstractRoom.setBitrate` will be deprecated, use `RCLocalTrack.setBitrate` instead."),k("max",e,e=>O(e)&&e>Math.max(t||1,200),!0),k("min",t,t=>O(t)&&t>=1&&(!O(e)||t<e),!0),k("start",i,i=>O(i)&&i>t&&i<=e),this._peerConnection.setBitrate(e,t,i)}_onTrackReady(e){const t=e.streams[0].id,{track:i}=e.receiver,r=[t,"audio"===i.kind?Pt.AUDIO_ONLY:Pt.VIDEO_ONLY].join("_"),n=this._store.getRemoteTrack(r);n?(n.__innerSetMediaStreamTrack(i),this._logger.info(he.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:ge.SUCCESSED,eventType:"onTrackReady",trackId:n.getTrackId()})),this._callAppListener("onTrackReady",n)):this._logger.warn(he.L_ABSTRACT_ROOM_ONTRACKREADY_O,`cannot found remote track ${i.id}`)}_callAppListener(e,...t){var i;const r=null===(i=this._appListener)||void 0===i?void 0:i[e];if(r)try{r(...t)}catch(e){this._logger.error(he.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,null==e?void 0:e.stack)}}_onTrackUnpublish(e){this._logger.info(he.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:ge.SUCCESSED,eventType:"onTrackUnpublish",trackIds:null==e?void 0:e.map(e=>e.getTrackId())})),this._callAppListener("onTrackUnpublish",e)}__parseInnerMessage(e,t){const{targetId:i}=e;if(i!==this._roomId)return void this._logger.warn(he.L_ABSTRACT_ROOM_RECEIVE_MESSAGE_O,JSON.stringify({status:ge.FAILED,message:`roomId is different, msg roomId-> ${i}, this._roomId-> ${this._roomId} `}),t);this._logger.info(he.L_ABSTRACT_ROOM_RECEIVE_MESSAGE_O,`recv inner msg -> message: ${JSON.stringify(e)} | roomid: ${this._roomId}`,t);const{content:r}=e;switch(e.messageType){case Pi.KICK:this.__kickoff(!0,r);break;case Pi.STATE:this._stateHandle(r,t);break;case Pi.MODIFY:case Pi.PUBLISH:case Pi.UNPUBLISH:case Pi.TOTAL_CONTENT_RESOURCE:this._resourceHandle(r,e.messageType,e.senderUserId,e.sentTime,t);break;case Pi.ASR_STATUS:this._invoker.push(new Ya(r.asr_status));break;case Pi.ASR_SEI:this._invoker.push(new qa(JSON.parse(r.sei_ai_uris||[])));break;case Pi.SUMMARIZATION_STATUS:this._invoker.push(new za(r.status,r.taskId));break;case Pi.ROOM_NOTIFY:this._logger.info(he.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:ge.SUCCESSED,eventType:"onRoomAttributeChange",messageType:e.messageType,messageContent:e.content})),this._callAppListener("onRoomAttributeChange",e.messageType,e.content);break;case Pi.USER_NOTIFY:this._logger.warn(he.L_OLD_DAILY_RECORD_O,`TODO: ${Pi.USER_NOTIFY}`);break;case Pi.PK_INVITE:case Pi.PK_CANCEL_INVITE:case Pi.PK_INVITE_TIMEOUT:case Pi.PK_INVITE_ANSWER:case Pi.PK_END:this._onRecvPKMsg&&this._onRecvPKMsg(e);break;case Pi.OTHER_ROOM_OFFLINE:break;default:this._logger.info(he.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:ge.SUCCESSED,eventType:"onMessageReceive",messageType:e.messageType,messageContent:e.content,senderUserId:e.senderUserId,messageUId:e.messageUId})),this._callAppListener("onMessageReceive",e.messageType,r,e.senderUserId,e.messageUId)}}__kickoff(e,t){return I(this,void 0,void 0,function*(){if(this._invoker.isDestroyed())return;let i,r;this._logger.warn(he.L_ABSTRACT_ROOM_ONKICKOFF_O,`onKickOff -> byServer: ${e}, kickContent: ${JSON.stringify(t)}`),this.emit(Qa),this._leaveHandle(!e),e&&((null==t?void 0:t.users)||[]).forEach(e=>{e.userId===this._context.getCurrentId()&&(r=e.type,i=e.kickExtra,this._reportMediaActionLogger.reportQualityKickedData(r))}),this._logger.info(he.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:ge.SUCCESSED,eventType:"onKickOff",byServer:e,kickType:r,kickExtra:i})),this._callAppListener("onKickOff",e,r,i)})}_rtcpeerClosed(){this.emit(Qa),this._leaveHandle(!0),this._logger.info(he.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,"onRTCPeerConnectionCloseByException"),this._callAppListener("onRTCPeerConnectionCloseByException")}_onReceiveAsrSeiContent(e){e.forEach(e=>{"destLangCode"in e?this._store.getIsStartRealTranslate()&&this._store.getTranslationLang()===e.destLangCode&&this._callAppListener("onReceiveRealtimeTranslationContent",e):this._callAppListener("onReceiveASRContent",e)})}_resourceHandle(e,t,i,r,n){return I(this,void 0,void 0,function*(){const{uris:s,ignore:o}=e;!o&&s&&this._invoker.push(new Sa(e,t,i,n,r))})}_onTrackPublish(e,t,i){this._logger.info(he.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:ge.SUCCESSED,eventType:"onTrackPublish",trackIds:null==e?void 0:e.map(e=>e.getTrackId())})),this._callAppListener("onTrackPublish",e)}_stateHandle(e,t){return I(this,void 0,void 0,function*(){const i=(yield this._invoker.push(new Ra(e,t))).data;this._dealUserAppListener(i)})}_dealUserAppListener(e){var t,i;const{left:r,joined:n,upgrade:s,downgrade:o,offline:a}=e,l=[...n],_=[...r];(null===(t=this._appListener)||void 0===t?void 0:t.onSwitchRole)?(null==s||s.forEach(e=>{this._logger.info(he.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:ge.SUCCESSED,eventType:"onSwitchRole",userId:e,role:Ro.ANCHOR})),this._callAppListener("onSwitchRole",e,Ro.ANCHOR)}),null==o||o.forEach(e=>{this._logger.info(he.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:ge.SUCCESSED,eventType:"onSwitchRole",userId:e,role:Ro.AUDIENCE})),this._callAppListener("onSwitchRole",e,Ro.AUDIENCE)})):(l.push(...s),_.push(...o)),a.length&&((null===(i=this._appListener)||void 0===i?void 0:i.onUserOffline)?(this._logger.info(he.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:ge.SUCCESSED,eventType:"onUserOffline",offline:a})),this._callAppListener("onUserOffline",a)):_.push(...a)),l.length>0&&(this._logger.info(he.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:ge.SUCCESSED,eventType:"onUserJoin",allJoined:l})),this._callAppListener("onUserJoin",l)),_.length>0&&(this._logger.info(he.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:ge.SUCCESSED,eventType:"onUserLeave",allLeft:_})),this._callAppListener("onUserLeave",_))}getRoomId(){return this._roomId}getCrtUserId(){return this._context.getCurrentId()}getRemoteUserIds(){return this._store.getRemoteUserIds()}getRemoteTracks(){const e=[];return this.getRemoteUserIds().forEach(t=>{e.push(...this.getRemoteTracksByUserId(t))}),e}getRemoteTracksByUserId(e){return this._store.getRemoteTracksByUserId(e)}getSessionId(){return this._store.getSessionId()}sendMessage(e,t){return I(this,void 0,void 0,function*(){const i=this._logger.createTraceId();this._logger.info(he.L_ABSTRACT_ROOM_SEND_MESSAGE_T,JSON.stringify({name:e,content:t}),i);const{code:r}=yield this._context.sendMessage(a.RTC_ROOM,this._roomId,{messageType:e,content:t,isStatusMessage:!0});return r!==oe?(this._logger.error(he.L_ABSTRACT_ROOM_SEND_MESSAGE_R,JSON.stringify({status:ge.FAILED,code:r}),i),{code:ue.SIGNAL_ERROR}):(this._logger.info(he.L_ABSTRACT_ROOM_SEND_MESSAGE_R,JSON.stringify({status:ge.SUCCESSED,name:e,content:t}),i),{code:ue.SUCCESS})})}setRoomAttribute(e,t,i){return I(this,arguments,void 0,function*(e,t,i,r=!1){const n=this._logger.createTraceId();this._logger.info(he.L_ABSTRACT_ROOM_SET_ROOM_ATTRIBUTE_T,JSON.stringify({roomId:this._roomId,key:e,value:t,message:i,isInner:r}),n);const s=yield this._context.setRTCData(this._roomId,e,t,r,bo.ROOM,i);return s!==oe?(this._logger.error(he.L_ABSTRACT_ROOM_SET_ROOM_ATTRIBUTE_R,JSON.stringify({status:ge.FAILED,code:s}),n),{code:ue.SIGNAL_ERROR}):(this._logger.info(he.L_ABSTRACT_ROOM_SET_ROOM_ATTRIBUTE_R,JSON.stringify({status:ge.SUCCESSED,roomId:this._roomId,key:e,value:t,message:i,isInner:r}),n),{code:ue.SUCCESS})})}deleteRoomAttributes(e,t){return I(this,arguments,void 0,function*(e,t,i=!1){const r=this._logger.createTraceId();this._logger.info(he.L_ABSTRACT_ROOM_DELETE_ROOM_ATTRIBUTE_T,JSON.stringify({roomId:this._roomId,keys:e,message:t,isInner:i}),r);const n=yield this._context.removeRTCData(this._roomId,e,i,bo.ROOM,t);return n!==oe?(this._logger.error(he.L_ABSTRACT_ROOM_DELETE_ROOM_ATTRIBUTE_R,JSON.stringify({status:ge.FAILED,code:n}),r),{code:ue.SIGNAL_ERROR}):(this._logger.info(he.L_ABSTRACT_ROOM_DELETE_ROOM_ATTRIBUTE_R,JSON.stringify({status:ge.SUCCESSED,roomId:this._roomId,keys:e,message:t,isInner:i}),r),{code:ue.SUCCESS})})}getRoomAttributes(){return I(this,arguments,void 0,function*(e=[],t=!1){const i=this._logger.createTraceId();this._logger.info(he.L_ABSTRACT_ROOM_GET_ROOM_ATTRIBUTE_T,JSON.stringify({roomId:this._roomId,keys:e,isInner:t}),i);const{code:r,data:n}=yield this._context.getRTCData(this._roomId,e,t,bo.ROOM);return r!==oe?(this._logger.error(he.L_ABSTRACT_ROOM_GET_ROOM_ATTRIBUTE_R,`GetRoomAttributes Failed: ${r}`,i),{code:ue.SIGNAL_ERROR}):(this._logger.info(he.L_ABSTRACT_ROOM_DELETE_ROOM_ATTRIBUTE_R,JSON.stringify({status:ge.SUCCESSED,data:n}),i),{code:ue.SUCCESS,data:n})})}_setUserAttributeValue(e,t,i){return this._context.setRTCData(this._roomId,e,t,!1,bo.PERSON,i)}_deleteUserAttributes(e,t){return this._context.removeRTCData(this._roomId,e,!1,bo.PERSON,t)}_getUserAttributes(e){return this._context.getRTCData(this._roomId,e,!1,bo.PERSON)}isDestroyed(){return this._invoker.isDestroyed()}__destroy(e){return this._leaveHandle(e)}_muteRemoteTracksBeforeQuit(){const e=Object.values(this._store.getRemoteTracks());e.length&&e.forEach(e=>e.mute())}_leaveHandle(e){return I(this,void 0,void 0,function*(){this._invoker.isDestroyed()||(this._invoker.destroy(),this._muteRemoteTracksBeforeQuit(),e&&(yield this._context.quitRTCRoom(this._roomId)),this._store.isMainRoom&&(yield this._quitAllPKRoom()),this._pinger.stop(),yield this._service.exit(this._store.getRTCRequestHeader()),this._releasePCManager())})}_releasePCManager(){const e=this._peerConnection;e.removeAllLocalTrack(),e.destroy()}_onLocalTrackDestroied(e){e instanceof Wt&&e.__isTiny()||this.unpublish([e])}_onLocalTrackMuted(e,t){return I(this,void 0,void 0,function*(){const{code:i}=yield this._invoker.push(new va(e));t(i)})}publish(e){return I(this,void 0,void 0,function*(){return this._invoker.push(new La(e))})}_getPushOtherRoomsParams(){return[]}_reTryExchange(){return this._invoker.push(new ba)}unpublish(e){return I(this,void 0,void 0,function*(){return this._invoker.push(new Oa(e))})}_isValidResourceId(e){var t;const{userId:i}=gi(e);return!!(null===(t=this._store.getResourcesByUserId(i))||void 0===t?void 0:t.find(t=>hi(t)===e))}subscribe(e){return I(this,void 0,void 0,function*(){return this._invoker.push(new Ca(e,void 0,void 0))})}unsubscribe(e){return I(this,void 0,void 0,function*(){const t=this._logger.createTraceId();return this._logger.info(he.L_APP_CALL_UNSUBSCRIBE_O,void 0,t),this._invoker.push(new _a(e,t))})}updateSubList(e){return I(this,void 0,void 0,function*(){return this._invoker.push(new la(e,!0,this._logger.createTraceId()))})}getLocalTrack(e){return this._peerConnection.getLocalTrack(e)}getLocalTracks(){return this._peerConnection.getLocalTracks()}getRemoteTrack(e){return this._store.getRemoteTrack(e)||null}get subscribedTracks(){return this._store.getSubscribedList().slice()}registerRoomEventListener(e){this._logger.info(he.L_ABSTRACT_ROOM_REGISTER_ROOM_EVENT_LISTENER_O,e?Object.keys(e).join(","):null),this._appListener=e,this.asrIsAvailable()&&this._executeCtx.emit(Zo);const t=this.getSummarizationStatusData();t&&(null==t?void 0:t.status)===Qs.OPEN&&this._executeCtx.emit(ea,t.taskId)}registerReportListener(e){this._logger.info(he.L_ABSTRACT_ROOM_REGISTER_REPORT_LISTENER_O,e?Object.keys(e).join(","):null),this._peerConnection.registerReportListener(e)}onAudioLevelChange(e,t){this._logger.info(he.L_ABSTRACT_ROOM_AUDIO_LEVEL_O),this._audioLevelReport.onAudioLevelChange(e)}__onReconnected(e){this._invoker.push(new Na(e))}_onAudioMuteChange(e){this._logger.info(he.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:ge.SUCCESSED,eventType:"onAudioMuteChange",trackId:e.getTrackId()})),this._callAppListener("onAudioMuteChange",e)}_onVideoMuteChange(e){this._logger.info(he.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:ge.SUCCESSED,eventType:"onVideoMuteChange",trackId:e.getTrackId()})),this._callAppListener("onVideoMuteChange",e)}_registerPKMsgListener(e){this._onRecvPKMsg=e}_quitAllPKRoom(){return I(this,void 0,void 0,function*(){})}getClientSessionId(){return this._store.clientSessionId}changeMediaDevice(e,t){return I(this,void 0,void 0,function*(){return this._invoker.push(new Ha(e,t))})}startASR(){return this._invoker.push(new Ja(Oo.OPEN))}stopASR(){return this._invoker.push(new Ja(Oo.CLOSE))}asrIsAvailable(){return this._store.getASRIsAvailable()}setEnableASR(e){return this._invoker.push(new $a(e))}startRealtimeTranslation(e){return this._invoker.push(new Ka(Ga.OPEN,e))}stopRealtimeTranslation(){return this._invoker.push(new Ka(Ga.CLOSE))}startSummarization(){return this._invoker.push(new Wa(!0))}stopSummarization(){return this._invoker.push(new Wa(!1))}getSummarizationStatusData(){return this._store.getSummarizationStatusData()}}class Xa extends ko{constructor(e,t){super(),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"cdnValues",{enumerable:!0,configurable:!0,writable:!0,value:t})}get kind(){return So.MCUCONFIG_FLUSH}execute(e,t,i){return I(this,void 0,void 0,function*(){var i,r,n,s;const{context:o,service:a}=e,l={"App-Key":o.getAppkey(),Token:t.getToken(),RoomId:t.roomId,UserId:o.getCurrentId(),SessionId:t.getSessionId()},{code:_,res:c}=yield a.setMcuConfig(l,this.data);if(_!==ue.SUCCESS)return{code:_};c.pull_url&&t.setCDNUris(JSON.parse(c.pull_url));const d=this.cdnValues;return _===ue.SUCCESS&&((null===(r=null===(i=d.output)||void 0===i?void 0:i.video.normal)||void 0===r?void 0:r.width)||(null===(s=null===(n=d.output)||void 0===n?void 0:n.video.normal)||void 0===s?void 0:s.fps))&&ga(o,t),{code:_,data:c}})}}var el,tl,il,rl;!function(e){e[e.CROP=1]="CROP",e[e.WHOLE=2]="WHOLE"}(el||(el={})),function(e){e[e.CUSTOMIZE=1]="CUSTOMIZE",e[e.SUSPENSION=2]="SUSPENSION",e[e.ADAPTATION=3]="ADAPTATION"}(tl||(tl={})),function(e){e[e.CROP=1]="CROP",e[e.WHOLE=2]="WHOLE"}(il||(il={})),function(e){e[e.AUDIO_VIDEO_ALL=0]="AUDIO_VIDEO_ALL",e[e.AUDIO_VIDEO_NO=1]="AUDIO_VIDEO_NO",e[e.AUDIO_ALL_VIDEO_NO=2]="AUDIO_ALL_VIDEO_NO",e[e.AUDIO_NO_VIDEO_ALL=3]="AUDIO_NO_VIDEO_ALL",e[e.AUDIO_VIDEO_INPUT=4]="AUDIO_VIDEO_INPUT",e[e.AUDIO_ALL_VIDEO_INPUT=5]="AUDIO_ALL_VIDEO_INPUT",e[e.AUDIO_NO_VIDEO_INPUT=6]="AUDIO_NO_VIDEO_INPUT",e[e.AUDIO_INPUT_VIDEO_ALL=7]="AUDIO_INPUT_VIDEO_ALL",e[e.AUDIO_INPUT_VIDEO_NO=8]="AUDIO_INPUT_VIDEO_NO",e[e.ROOM_AUDIO_VIDEO_APPEND=9]="ROOM_AUDIO_VIDEO_APPEND",e[e.ROOM_AUDIO_VIDEO_NOT_APPEND=10]="ROOM_AUDIO_VIDEO_NOT_APPEND",e[e.ROOM_AUDIO_APPEND=11]="ROOM_AUDIO_APPEND",e[e.ROOM_AUDIO_NOT_APPEND=12]="ROOM_AUDIO_NOT_APPEND",e[e.ROOM_VIDEO_APPEND=13]="ROOM_VIDEO_APPEND",e[e.ROOM_VIDEO_NOT_APPEND=14]="ROOM_VIDEO_NOT_APPEND"}(rl||(rl={}));const nl=()=>({version:2,mode:tl.SUSPENSION});class sl{constructor(e,t,i){Object.defineProperty(this,"_executeCtx",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_invoker",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_isValidTrackId",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_values",{enumerable:!0,configurable:!0,writable:!0,value:nl()}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._logger=this._executeCtx.logger}setHostVideoTrack(e){if(!this._isValidTrackId(e))return this._logger.error(he.L_MCU_CONFIG_BUILDER_SET_HOST_VIDEO_TRACK_O,JSON.stringify({status:ge.FAILED,msg:`videoTrackId: ${e} is invalid`})),this;const{mediaType:t,tag:i,userId:r}=gi(e);return t!==Pt.VIDEO_ONLY?(this._logger.error(he.L_MCU_CONFIG_BUILDER_SET_HOST_VIDEO_TRACK_O,JSON.stringify({status:ge.FAILED,msg:`kind of ${e} is not video`})),this):(this._values.host_stream_id=pi(r,i),this._logger.info(he.L_MCU_CONFIG_BUILDER_SET_HOST_VIDEO_TRACK_O,JSON.stringify({status:ge.SUCCESSED,videoTrackId:e})),this)}setMixLayoutMode(e){return[tl.CUSTOMIZE,tl.SUSPENSION,tl.ADAPTATION].includes(e)?(this._values.mode=e,this._logger.info(he.L_MCU_CONFIG_BUILDER_SET_MIX_LAYOUT_MODE_O,JSON.stringify({status:ge.SUCCESSED,mode:e})),this):(this._logger.error(he.L_MCU_CONFIG_BUILDER_SET_MIX_LAYOUT_MODE_O,JSON.stringify({status:ge.SUCCESSED,msg:`mode: ${e} is invalid`})),this)}_addOutputValue(e,t,i="normal"){const r=this._values.output||(this._values.output={video:{normal:{width:640,height:480}}});if("cdn"===e)return void(r.cdn=t);if("audio"===e)return void(r.audio={bitrate:t});const{video:n}=r;if("normal"===i||"tiny"===i){const e=n[i]||(n[i]={});return void Object.assign(e,t)}if("backgroundColor"!==i)if("exparams"!==i){if("backgroundPicture"===i){const e=n.backgroundPicture||(n.backgroundPicture={fillMode:el.CROP,picture:[]});Object.assign(e,t)}}else n.exparams={renderMode:t};else n.backgroundColor=t}setOutputVideoResolution(e){if(!Ii(e))return this._logger.error(he.L_MCU_CONFIG_BUILDER_SET_OUTPUT_VIDEO_RESOLUTION_O,JSON.stringify({status:ge.FAILED,msg:`params error -> resolution: ${e}`})),this;const{width:t,height:i}=mi(e);return this._addOutputValue("video",{width:t,height:i},"normal"),this._logger.info(he.L_MCU_CONFIG_BUILDER_SET_OUTPUT_VIDEO_RESOLUTION_O,JSON.stringify({status:ge.SUCCESSED,resolution:e})),this}setOutputVideoFPS(e){if(!Ri(e))return this._logger.error(he.L_MCU_CONFIG_BUILDER_SET_OUTPUT_VIDEO_FPS_O,JSON.stringify({status:ge.FAILED,msg:`params error -> fps: ${e}`})),this;const t=Si(e);return this._addOutputValue("video",{fps:t},"normal"),this._logger.info(he.L_MCU_CONFIG_BUILDER_SET_OUTPUT_VIDEO_FPS_O,JSON.stringify({status:ge.SUCCESSED,fps:e})),this}setOutputVideoBitrate(e){return!O(e)||e<=0?(this._logger.error(he.L_MCU_CONFIG_BUILDER_SET_OUTPUT_VIDEO_BITRATE_O,JSON.stringify({status:ge.FAILED,msg:`params error -> bitrate: ${e}`})),this):(this._addOutputValue("video",{bitrate:e},"normal"),this._logger.info(he.L_MCU_CONFIG_BUILDER_SET_OUTPUT_VIDEO_BITRATE_O,JSON.stringify({status:ge.SUCCESSED,bitrate:e})),this)}setOutputTinyVideoResolution(e){if(!Ii(e))return this._logger.error(he.L_MCU_CONFIG_BUILDER_SET_OUTPUT_TINY_VIDEO_RESOLUTION_O,JSON.stringify({status:ge.FAILED,msg:`params error -> resolution: ${e}`})),this;const{width:t,height:i}=mi(e);return this._addOutputValue("video",{width:t,height:i},"tiny"),this._logger.info(he.L_MCU_CONFIG_BUILDER_SET_OUTPUT_TINY_VIDEO_RESOLUTION_O,JSON.stringify({status:ge.SUCCESSED,resolution:e})),this}setOutputTinyVideoFPS(e){if(!Ri(e))return this._logger.error(he.L_MCU_CONFIG_BUILDER_SET_OUTPUT_TINY_VIDEO_FPS_O,JSON.stringify({status:ge.FAILED,msg:`params error -> fps: ${e}`})),this;const t=Si(e);return this._addOutputValue("video",{fps:t},"tiny"),this._logger.info(he.L_MCU_CONFIG_BUILDER_SET_OUTPUT_TINY_VIDEO_FPS_O,JSON.stringify({status:ge.SUCCESSED,fps:e})),this}setOutputTinyVideoBitrate(e){return!O(e)||e<=0?(this._logger.error(he.L_MCU_CONFIG_BUILDER_SET_OUTPUT_TINY_VIDEO_BITRATE_O,JSON.stringify({status:ge.FAILED,msg:`params error -> bitrate: ${e}`})),this):(this._addOutputValue("video",{bitrate:e},"tiny"),this._logger.info(he.L_MCU_CONFIG_BUILDER_SET_OUTPUT_TINY_VIDEO_BITRATE_O,JSON.stringify({status:ge.SUCCESSED,bitrate:e})),this)}setOutputVideoRenderMode(e){return[il.CROP,il.WHOLE].includes(e)?(this._addOutputValue("video",e,"exparams"),this._logger.info(he.L_MCU_CONFIG_BUILDER_SET_OUTPUT_VIDEO_RENDER_MODE_O,JSON.stringify({status:ge.SUCCESSED,renderMode:e})),this):(this._logger.error(he.L_MCU_CONFIG_BUILDER_SET_OUTPUT_VIDEO_RENDER_MODE_O,JSON.stringify({status:ge.FAILED,msg:`params error -> renderMode: ${e}`})),this)}setOutputAudioBitrate(e){return O(e)&&e>0?(this._addOutputValue("audio",e),this._logger.info(he.L_MCU_CONFIG_BUILDER_SET_OUTPUT_AUDIO_BITRATE_O,JSON.stringify({status:ge.SUCCESSED,bitrate:e})),this):(this._logger.error(he.L_MCU_CONFIG_BUILDER_SET_OUTPUT_AUDIO_BITRATE_O,JSON.stringify({status:ge.FAILED,msg:`params error -> bitrate: ${e}`})),this)}setOutputBackgroundColor(e){return/^0x[a-fA-F0-9]{6}$/.test(e)?(this._addOutputValue("video",e,"backgroundColor"),this._logger.info(he.L_MCU_CONFIG_BUILDER_SET_OUTPUT_BACKGROUND_COLOR_O,JSON.stringify({status:ge.SUCCESSED,color:e})),this):(this._logger.error(he.L_MCU_CONFIG_BUILDER_SET_OUTPUT_BACKGROUND_COLOR_O,JSON.stringify({status:ge.FAILED,msg:`params error -> color: ${e}`})),this)}addOutputBackgroundPicture(e,t,i,r,n){var s,o,a;if(!U(e))return this._logger.error(he.L_MCU_CONFIG_BUILDER_SET_OUTPUT_BACKGROUND_PICTURE_O,JSON.stringify({status:ge.FAILED,msg:`params error -> uri: ${e}`})),this;if([t,i,r,n].some(e=>!O(e)||e<0||e>1))return this._logger.error(he.L_MCU_CONFIG_BUILDER_SET_OUTPUT_BACKGROUND_PICTURE_O,JSON.stringify({status:ge.FAILED,msg:`params of (x, y, w, h) error -> x: ${t}, y: ${i}, w: ${r}, h: ${n}`})),this;const l=(null===(a=null===(o=null===(s=this._values.output)||void 0===s?void 0:s.video)||void 0===o?void 0:o.backgroundPicture)||void 0===a?void 0:a.picture)||[];return l.push({uri:e,w:r,h:n,x:t,y:i}),this._addOutputValue("video",{picture:l},"backgroundPicture"),this._logger.info(he.L_MCU_CONFIG_BUILDER_SET_OUTPUT_BACKGROUND_PICTURE_O,JSON.stringify({status:ge.SUCCESSED,uri:e,x:t,y:i,w:r,h:n})),this}removeOutputBackgroundPicture(e){var t,i,r;if(!U(e))return this._logger.error(he.L_MCU_CONFIG_BUILDER_REMOVE_OUTPUT_BACKGROUND_PICTURE_O,JSON.stringify({status:ge.FAILED,msg:`params error -> uri: ${e}`})),this;let n=null===(r=null===(i=null===(t=this._values.output)||void 0===t?void 0:t.video)||void 0===i?void 0:i.backgroundPicture)||void 0===r?void 0:r.picture;return n&&(n=n.filter(t=>t.uri!==e),this._addOutputValue("video",{pictures:n},"backgroundPicture")),this._logger.info(he.L_MCU_CONFIG_BUILDER_REMOVE_OUTPUT_BACKGROUND_PICTURE_O,JSON.stringify({status:ge.SUCCESSED,uri:e})),this}clearOutputBackgroundPicture(){return this._addOutputValue("video",{pictures:[]},"backgroundPicture"),this._logger.info(he.L_MCU_CONFIG_BUILDER_CLEAR_OUTPUT_BACKGROUND_PICTURE_O),this}setOutputBackgroundPictureFillMode(e){return[el.CROP,el.WHOLE].includes(e)?(this._addOutputValue("video",{fillMode:e},"backgroundPicture"),this._logger.info(he.L_MCU_CONFIG_BUILDER_SET_OUTPUT_BACKGROUND_PICTURE_FILL_MODE_O,JSON.stringify({status:ge.SUCCESSED,fillMode:e})),this):(this._logger.error(he.L_MCU_CONFIG_BUILDER_SET_OUTPUT_BACKGROUND_PICTURE_FILL_MODE_O,JSON.stringify({status:ge.FAILED,msg:`params error -> fillMode: ${e}`})),this)}addPublishStreamUrls(e){var t,i;const r=/^rtmp:\/\/.+/;if(!v(e)||0===e.length||e.some(e=>!r.test(e)))return this._logger.error(he.L_MCU_CONFIG_BUILDER_SET_OUTPUT_BACKGROUND_PICTURE_FILL_MODE_O,JSON.stringify({status:ge.FAILED,msg:`params error -> urls: ${e.join(",")}`})),this;const n=(null===(i=null===(t=this._values.output)||void 0===t?void 0:t.cdn)||void 0===i?void 0:i.concat())||[];let s=!1;return e.forEach(e=>{n.some(t=>t.pushurl===e)||(s=!0,n.push({pushurl:e}))}),n.length>5?(this._logger.error(he.L_MCU_CONFIG_BUILDER_SET_OUTPUT_BACKGROUND_PICTURE_FILL_MODE_O,JSON.stringify({status:ge.FAILED,msg:`params error -> publish stream urls no more than 5, length: ${e.length}`})),this):(s&&this._addOutputValue("cdn",n),this._logger.info(he.L_MCU_CONFIG_BUILDER_ADD_PUBLISH_STREAM_URLS_O,JSON.stringify({status:ge.SUCCESSED,urls:e})),this)}removePublishStreamUrls(e){var t,i;const r=/^rtmp:\/\/.+/;if(!v(e)||0===e.length||e.some(e=>!r.test(e)))return this._logger.error(he.L_MCU_CONFIG_BUILDER_REMOVE_PUBLISH_STREAM_URLS_O,JSON.stringify({status:ge.FAILED,msg:`params error -> urls: ${e.join(",")}`})),this;const n=(null===(i=null===(t=this._values.output)||void 0===t?void 0:t.cdn)||void 0===i?void 0:i.concat())||[];for(let t=n.length-1;t>=0;t-=1){const{pushurl:i}=n[t],r=e.indexOf(i);r>=0&&(e.splice(r,1),n.splice(t,1))}return this._addOutputValue("cdn",n),this._logger.info(he.L_MCU_CONFIG_BUILDER_REMOVE_PUBLISH_STREAM_URLS_O,JSON.stringify({status:ge.SUCCESSED,urls:e})),this}clearPublishStreamUrls(){return this._addOutputValue("cdn",[]),this._logger.info(he.L_MCU_CONFIG_BUILDER_CLEAR_PUBLISH_STREAM_URLS_O),this}addCustomizeLayoutVideo(e,t,i,r,n){if(!b(e)||!this._isValidTrackId(e))return this._logger.error(he.L_MCU_CONFIG_BUILDER_ADD_CUSTOMIZE_LAYOUT_VIDEO_O,JSON.stringify({status:ge.FAILED,msg:`params error -> trackId: ${e}`})),this;if(!O(t)||!O(i))return this._logger.error(he.L_MCU_CONFIG_BUILDER_ADD_CUSTOMIZE_LAYOUT_VIDEO_O,JSON.stringify({status:ge.FAILED,msg:`params x or y is error -> x: ${t}, y: ${i}`})),this;if([r,n].some(e=>!O(e)||e<0))return this._logger.error(he.L_MCU_CONFIG_BUILDER_ADD_CUSTOMIZE_LAYOUT_VIDEO_O,JSON.stringify({status:ge.FAILED,msg:`params width or height error -> width: ${r}, height: ${n}`})),this;const{userId:s,tag:o,mediaType:a}=gi(e);if(a!==Pt.VIDEO_ONLY)return this._logger.error(he.L_MCU_CONFIG_BUILDER_ADD_CUSTOMIZE_LAYOUT_VIDEO_O,JSON.stringify({status:ge.FAILED,msg:`type of trackId: ${e} is not video`})),this;const l=pi(s,o),_=this._values.input||(this._values.input={}),c=_.video||(_.video=[]);return c.some(e=>e.height===n&&e.width===r&&e.stream_id===l&&e.user_id===s&&e.x===t&&e.y===i)?(this._logger.warn(he.L_MCU_CONFIG_BUILDER_ADD_CUSTOMIZE_LAYOUT_VIDEO_O,JSON.stringify({status:ge.FAILED,msg:"Duplicate configuration item place ignored"})),this):(c.push({user_id:s,stream_id:l,x:t,y:i,width:r,height:n}),this._logger.info(he.L_MCU_CONFIG_BUILDER_ADD_CUSTOMIZE_LAYOUT_VIDEO_O,JSON.stringify({status:ge.SUCCESSED,trackId:e,x:t,y:i,width:r,height:n})),this)}removeCustomizeLayoutVideo(e){if(!this._isValidTrackId(e))return this._logger.error(he.L_MCU_CONFIG_BUILDER_REMOVE_CUSTOMIZE_LAYOUT_VIDEO_O,JSON.stringify({status:ge.FAILED,msg:`params error -> trackId: ${e}`})),this;const{userId:t,tag:i,mediaType:r}=gi(e);if(r!==Pt.VIDEO_ONLY)return this._logger.error(he.L_MCU_CONFIG_BUILDER_REMOVE_CUSTOMIZE_LAYOUT_VIDEO_O,JSON.stringify({status:ge.FAILED,msg:`type of trackId: ${e} is not video`})),this;const n=pi(t,i),{input:s}=this._values;return(null==s?void 0:s.video)&&s.video.length>0&&(s.video=s.video.filter(e=>e.stream_id===n)),this._logger.info(he.L_MCU_CONFIG_BUILDER_REMOVE_CUSTOMIZE_LAYOUT_VIDEO_O,JSON.stringify({status:ge.SUCCESSED,trackId:e})),this}clearCustomizeLayoutVideo(){const{input:e}=this._values;return null==e||delete e.video,this._logger.info(he.L_MCU_CONFIG_BUILDER_CLEAR_CUSTOMIZE_LAYOUT_VIDEO_O),this}setCustomizeInputAudio(e){if(e.some(e=>this._isValidTrackId(e)))return this._logger.error(he.L_MCU_CONFIG_BUILDER_SET_CUSTOMIZE_INPUT_AUDIO_O,JSON.stringify({status:ge.FAILED,msg:`trackIds contain invalid item -> trackIds: ${e.join(",")}`})),this;return(this._values.input||(this._values.input={})).audio=e.map(e=>{const{userId:t,tag:i}=gi(e);return{stream_id:pi(t,i),user_id:t}}),this._values.inputFilterMode=rl.AUDIO_INPUT_VIDEO_ALL,this._logger.info(he.L_MCU_CONFIG_BUILDER_SET_CUSTOMIZE_INPUT_AUDIO_O,JSON.stringify({status:ge.SUCCESSED,trackIds:e})),this}addCustomizeInputAudio(e){if(!this._isValidTrackId(e))return this._logger.error(he.L_MCU_CONFIG_BUILDER_ADD_CUSTOMIZE_INPUT_AUDIO_O,JSON.stringify({status:ge.FAILED,msg:`params error -> trackId: ${e}`})),this;const t=this._values.input||(this._values.input={}),i=t.audio||(t.audio=[]),{userId:r,tag:n}=gi(e),s=pi(r,n);return i.some(e=>e.stream_id===s&&e.user_id===r)?(this._logger.warn(he.L_MCU_CONFIG_BUILDER_ADD_CUSTOMIZE_INPUT_AUDIO_O,JSON.stringify({status:ge.FAILED,msg:`trackId: ${e} is exist`})),this):(i.push({user_id:r,stream_id:s}),this._values.inputFilterMode=rl.AUDIO_INPUT_VIDEO_ALL,this._logger.info(he.L_MCU_CONFIG_BUILDER_ADD_CUSTOMIZE_INPUT_AUDIO_O,JSON.stringify({status:ge.SUCCESSED,trackId:e})),this)}removeCustomizeInputAudio(e){if(!this._isValidTrackId(e))return this._logger.error(he.L_MCU_CONFIG_BUILDER_REMOVE_CUSTOMIZE_INPUT_AUDIO_O,JSON.stringify({status:ge.FAILED,msg:`params error -> trackId: ${e}`})),this;const{input:t}=this._values;if(!(null==t?void 0:t.audio)||0===t.audio.length)return this._logger.error(he.L_MCU_CONFIG_BUILDER_REMOVE_CUSTOMIZE_INPUT_AUDIO_O,JSON.stringify({status:ge.FAILED,msg:`type of trackId: ${e} is not audio`})),this;const{userId:i,tag:r}=gi(e),n=pi(i,r);return t.audio=t.audio.filter(e=>i!==e.user_id||n!==e.stream_id),this._logger.info(he.L_MCU_CONFIG_BUILDER_REMOVE_CUSTOMIZE_INPUT_AUDIO_O,JSON.stringify({status:ge.SUCCESSED,trackId:e})),this}clearCustomizeInputAudio(){const{input:e}=this._values;return(null==e?void 0:e.audio)&&delete e.audio,this._values.inputFilterMode=rl.AUDIO_VIDEO_ALL,this._logger.info(he.L_MCU_CONFIG_BUILDER_CLEAR_CUSTOMIZE_INPUT_AUDIO_O),this}addPictureWaterMark(e,t,i,r,n,s){if(!this._isValidTrackId(e))return this._logger.error(he.L_MCU_CONFIG_BUILDER_ADD_SINGLE_WATER_MARK_O,JSON.stringify({status:ge.FAILED,msg:`params error -> trackId: ${e}`})),this;if(!U(t))return this._logger.error(he.L_MCU_CONFIG_BUILDER_ADD_SINGLE_WATER_MARK_O,JSON.stringify({status:ge.FAILED,msg:`params error -> uri: ${t}`})),this;if([i,r,n,s].some(e=>!O(e)||e<0||e>1)||i+n>1||r+s>1)return this._logger.error(he.L_MCU_CONFIG_BUILDER_ADD_SINGLE_WATER_MARK_O,JSON.stringify({status:ge.FAILED,msg:`some attrs of (x, y, w, h) is invalid -> x: ${i}, y: ${r}, w: ${n}, h: ${s}`})),this;const{userId:o,tag:a}=gi(e),l=pi(o,a),_=this._values.waterMark||(this._values.waterMark={enable:"on",singleScreen:[]}),{singleScreen:c}=_,d=c.filter(e=>e.streamId===l)[0];return d?d.picture.push({uri:t,w:n,h:s,x:i,y:r}):c.push({streamId:l,picture:[{uri:t,w:n,h:s,x:i,y:r}]}),this._values.waterMark.singleScreen=c,this._logger.info(he.L_MCU_CONFIG_BUILDER_ADD_SINGLE_WATER_MARK_O,JSON.stringify({status:ge.SUCCESSED,trackId:e,uri:t,x:i,y:r,w:n,h:s,singleScreen:c})),this}clearPictureWaterMark(){return(this._values.waterMark||(this._values.waterMark={enable:"on",singleScreen:[]})).singleScreen=[],this._logger.info(he.L_MCU_CONFIG_BUILDER_CLEAR_OUTPUT_BACKGROUND_PICTURE_O),this}removePictureWaterMark(e,t){if(!b(e)||!this._isValidTrackId(e))return this._logger.error(he.L_MCU_CONFIG_BUILDER_REMOVE_SINGLE_WATER_MARK_O,JSON.stringify({status:ge.FAILED,msg:`params error -> trackId: ${e}`})),this;const{userId:i,tag:r}=gi(e),n=pi(i,r),s=this._values.waterMark||(this._values.waterMark={enable:"on",singleScreen:[]}),{singleScreen:o}=s;return o.forEach(e=>{e.streamId===n&&(e.picture=e.picture.filter(e=>e.uri!==t))}),this._logger.info(he.L_MCU_CONFIG_BUILDER_REMOVE_SINGLE_WATER_MARK_O,JSON.stringify({status:ge.SUCCESSED,trackId:e,uri:t})),this}reset(){return this._values=nl(),this._logger.info(he.L_MCU_CONFIG_BUILDER_RESET_O),this}flush(){return I(this,arguments,void 0,function*(e=!0){const t=JSON.parse(JSON.stringify(this._values)),{code:i}=yield this._invoker.push(new Xa(t,this._values));return e&&(this._values=nl()),{code:i}})}__innerGetValues(){return JSON.parse(JSON.stringify(this._values))}}var ol,al,ll;!function(e){e[e.VIDEO=0]="VIDEO",e[e.AUDIO=1]="AUDIO"}(ol||(ol={}));class _l extends ko{constructor(e,t,i){super(),Object.defineProperty(this,"roomId",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"roomPKHandler",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"traceId",{enumerable:!0,configurable:!0,writable:!0,value:i})}_exchangeWithPushOtherRoom(e,t,i){return I(this,void 0,void 0,function*(){const{logger:r,peer:n,context:s}=e;if(!n.getLocalTracks().length)return void r.info(he.L_EXCHANGE_WITH_PUSHOTHERROOM_R,JSON.stringify({status:ge.SUCCESSED,msg:"have not published resource"}),this.traceId);const o=n,a=t.getSubscribedList(),l=yield da(a,!1,o,t,s),_=e.getPushOtherRooms();l.pushOtherRooms=_;const c=yield new aa(l,this.traceId,!0).execute(e,t,i);if(c.code!==ue.SUCCESS)return void r.error(he.L_EXCHANGE_WITH_PUSHOTHERROOM_R,JSON.stringify({status:ge.FAILED,code:c.code,pushOtherRooms:_}),this.traceId);const{sdp:d,resultCode:u}=c.data.data;u===ue.SUCCESS?(r.info(he.L_EXCHANGE_WITH_PUSHOTHERROOM_R,JSON.stringify({status:ge.SUCCESSED,pushOtherRooms:_}),this.traceId),o.setRemoteAnswer(d.sdp)):r.error(he.L_EXCHANGE_WITH_PUSHOTHERROOM_R,JSON.stringify({status:ge.FAILED,code:u,pushOtherRooms:_}),this.traceId)})}get kind(){return So.EXCHANGE_WITH_PUSH_OTHER_ROOM}execute(e,t,i){return I(this,void 0,void 0,function*(){const{logger:r}=e,{roomId:n}=this;if(r.info(he.L_EXCHANGE_WITH_PUSHOTHERROOM_T,n),!this.roomPKHandler)return r.error(he.L_EXCHANGE_WITH_PUSHOTHERROOM_R,JSON.stringify({status:ge.FAILED,msg:"_roomPKHandler not exist"}),this.traceId),{code:ue.SUCCESS};return this.roomPKHandler.getPKInfo(n)?(yield this._exchangeWithPushOtherRoom(e,t,i),{code:ue.SUCCESS}):(r.warn(he.L_EXCHANGE_WITH_PUSHOTHERROOM_R,JSON.stringify({status:ge.FAILED,msg:"PKInfo not exist"}),this.traceId),{code:ue.SUCCESS})})}}class cl extends ko{constructor(e,t,i,r,n,s){super(),Object.defineProperty(this,"pkHandler",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"room",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_PKInfo",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_joinedPKRooms",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"isQuitPK",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"traceId",{enumerable:!0,configurable:!0,writable:!0,value:s})}get kind(){return So.LEAVE_OTHER_ROOM}quitRoomPK(e,t,i,r){return I(this,void 0,void 0,function*(){const{logger:n,context:s}=e;if(n.info(he.L_QUIT_PK_T,`roomId: ${t}`,r),!this._PKInfo[t])return void n.warn(he.L_QUIT_PK_R,`status: ${ge.FAILED}, msg: pkinfo is empty`,r);const{inviterRoomId:o,inviteeRoomId:a,inviterUserId:l,inviteSessionId:_}=this._PKInfo[t],c={inviteeRoomId:a,inviterRoomId:o,userId:i.crtUserId},d={roomId:i.roomId,endRoomId:t,sessionId:_,content:JSON.stringify(c),keys:[`${o}|${l}`]},u=yield s.endRoomPK(d);if(u!==oe)return n.error(he.L_QUIT_PK_R,`status: ${ge.FAILED}, code: ${u}`,r),{code:ue.SIGNAL_ERROR};n.info(he.L_QUIT_PK_R,`status: ${ge.SUCCESSED}`,r),delete this._PKInfo[t]})}execute(e,t,i){return I(this,void 0,void 0,function*(){const{logger:r}=e,{room:n,isQuitPK:s}=this,o=n.getRoomId();return r.info(he.L_LIVING_ROOM_LEAVE_PK_ROOM_T,JSON.stringify({roomId:o,isQuitPK:s}),this.traceId),yield n.__destroy(!0),delete this._joinedPKRooms[o],yield new _l(o,this.pkHandler,this.traceId).execute(e,t,i),s&&this.quitRoomPK(e,o,t,this.traceId),r.info(he.L_LIVING_ROOM_LEAVE_PK_ROOM_R,JSON.stringify({status:ge.SUCCESSED}),this.traceId),{code:ue.SUCCESS}})}}class dl{constructor(e,t,i,r,n,s,o,a,l,_){Object.defineProperty(this,"_invoker",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_PKInfo",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_runtime",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_service",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"_initOptions",{enumerable:!0,configurable:!0,writable:!0,value:s}),Object.defineProperty(this,"_mainLivingRoom",{enumerable:!0,configurable:!0,writable:!0,value:o}),Object.defineProperty(this,"_registerPKMsgListener",{enumerable:!0,configurable:!0,writable:!0,value:a}),Object.defineProperty(this,"_onJoinedPKRoom",{enumerable:!0,configurable:!0,writable:!0,value:l}),Object.defineProperty(this,"_clientSessionId",{enumerable:!0,configurable:!0,writable:!0,value:_}),Object.defineProperty(this,"_inviteTimeout",{enumerable:!0,configurable:!0,writable:!0,value:30}),Object.defineProperty(this,"_appListener",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_mainRoomId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_joinedPKRooms",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._logger=this._context.logger,this._registerPKMsgListener(this._onRecvPKMsg.bind(this)),this._mainRoomId=this._mainLivingRoom.getRoomId()}_callAppListener(e,...t){var i;const r=null===(i=this._appListener)||void 0===i?void 0:i[e];if(r)try{r(...t)}catch(e){this._logger.error(he.L_LIVING_PK_HANDLER_CALL_APP_LISTENER_O,JSON.stringify(e))}}_onInvite(e){const t=e.inviteInfo||{},{inviterRoomId:i,inviterUserId:r,extra:n}=t,s={inviterRoomId:i,inviterUserId:r,extra:n};this._PKInfo[i]=t,this._logger.info(he.L_LIVING_PK_HANDLER_CALL_APP_LISTENER_O,JSON.stringify({eventType:"onRequestJoinOtherRoom",info:s})),this._callAppListener("onRequestJoinOtherRoom",s)}_onCancelInvite(e){const{inviterRoomId:t,inviterUserId:i,extra:r}=e.inviteInfo||{},n={inviterRoomId:t,inviterUserId:i,extra:r};delete this._PKInfo[t],this._logger.info(he.L_LIVING_PK_HANDLER_CALL_APP_LISTENER_O,JSON.stringify({eventType:"onCancelRequestOtherRoom",cancelInfo:n})),this._callAppListener("onCancelRequestOtherRoom",n)}_onInviteTimeout(e){}_onInviteAnswer(e){const{answerCode:t,inviteContent:i}=e,{inviteSessionId:r,inviterUserId:n,inviterRoomId:s,inviteeUserId:o,inviterUserAutoMix:a,inviteeUserAutoMix:l,inviteeRoomId:_,extra:c}=i,d={agree:1===t,inviterRoomId:s,inviterUserId:n,inviteeRoomId:_,inviteeUserId:o,extra:c};this._PKInfo[_]=this._PKInfo[_]||{inviteSessionId:r,inviterRoomId:s,inviterUserId:n,inviterUserAutoMix:a,inviteeRoomId:_},this._PKInfo[_].inviteeUserAutoMix=l,this._logger.info(he.L_LIVING_PK_HANDLER_CALL_APP_LISTENER_O,JSON.stringify({eventType:"onResponseJoinOtherRoom",answerInfo:d})),this._callAppListener("onResponseJoinOtherRoom",d)}createLeaveOtherRoomCommand(e,t,i){return new cl(this,e,this._PKInfo,this._joinedPKRooms,t,i)}_onPKEnd(e){return I(this,void 0,void 0,function*(){const{inviteeRoomId:t,inviterRoomId:i,userId:r}=e.inviteInfo,n=i===this._mainRoomId?t:i,s={endRoomId:n,endUserId:r},o=this._joinedPKRooms[n],a=this._logger.createTraceId();this._logger.info(he.L_QUIT_PK_LEAVE_PK_ROOM_O,void 0,a),o&&(yield this._invoker.push(this.createLeaveOtherRoomCommand(o,!0,a))),delete this._PKInfo[n],this._logger.info(he.L_LIVING_PK_HANDLER_CALL_APP_LISTENER_O,JSON.stringify({eventType:"onFinishOtherRoom",endInfo:s})),this._callAppListener("onFinishOtherRoom",s)})}_onRecvPKMsg(e){const{content:t,messageType:i}=e;switch(i){case Pi.PK_INVITE:this._onInvite(t);break;case Pi.PK_CANCEL_INVITE:this._onCancelInvite(t);break;case Pi.PK_INVITE_TIMEOUT:this._onInviteTimeout(t);break;case Pi.PK_INVITE_ANSWER:this._onInviteAnswer(t);break;case Pi.PK_END:this._onPKEnd(t)}}registerRoomPKEventListener(e){this._logger.info(he.L_LIVING_PK_HANDLER_REGISTER_ROOM_PK_EVENT_LISTENER_O,JSON.stringify({listener:e&&Object.keys(e)})),this._appListener=e}requestJoinOtherRoom(e,t,i){return I(this,void 0,void 0,function*(){const r=this._logger.createTraceId();if(this._logger.info(he.L_LIVING_PK_HANDLER_REQUEST_JOIN_OTHER_ROOM_T,JSON.stringify({inviteeRoomId:e,inviteeUserId:t,options:i}),r),!x("inviteeRoomId",e,b,!0)||!x("inviteeUserId",t,b,!0))return this._logger.error(he.L_LIVING_PK_HANDLER_REQUEST_JOIN_OTHER_ROOM_R,JSON.stringify({status:ge.FAILED,code:ue.PARAMS_ERROR,msg:"params error -> inviteeRoomId or inviteeUserId"}),r),{code:ue.PARAMS_ERROR};const n=qs(),s=!L(null==i?void 0:i.autoMix)||(null==i?void 0:i.autoMix),o={inviteSessionId:n,inviterRoomId:this._mainRoomId,inviterUserId:this._context.getCurrentId(),inviterUserAutoMix:s,inviteeRoomId:e,inviteeUserId:t,inviteeTimeoutTime:this._inviteTimeout,extra:(null==i?void 0:i.extra)||""},a={roomId:this._mainRoomId,invitedRoomId:e,invitedUserId:t,inviteTimeout:this._inviteTimeout,inviteInfo:JSON.stringify(o),inviteSessionId:n},l=yield this._context.requestRoomPK(a);return l!==oe?(this._logger.error(he.L_LIVING_PK_HANDLER_REQUEST_JOIN_OTHER_ROOM_R,JSON.stringify({status:ge.FAILED,code:l}),r),{code:l}):(this._PKInfo[e]={inviteSessionId:n,inviterRoomId:this._mainRoomId,inviterUserId:this._context.getCurrentId(),inviterUserAutoMix:s,inviteeRoomId:e},this._logger.info(he.L_LIVING_PK_HANDLER_REQUEST_JOIN_OTHER_ROOM_R,JSON.stringify({status:ge.SUCCESSED}),r),{code:ue.SUCCESS})})}cancelRequestJoinOtherRoom(e,t,i){return I(this,void 0,void 0,function*(){const r=this._logger.createTraceId();if(this._logger.info(he.L_LIVING_PK_HANDLER_CANCEL_REQUEST_JOIN_OTHER_ROOM_T,JSON.stringify({inviteeRoomId:e,inviteeUserId:t,extra:i}),r),!x("inviteeRoomId",e,b,!0)||!x("inviteeUserId",t,b,!0))return this._logger.error(he.L_LIVING_PK_HANDLER_CANCEL_REQUEST_JOIN_OTHER_ROOM_R,JSON.stringify({status:ge.FAILED,code:ue.PARAMS_ERROR,msg:"params error -> inviteeRoomId or inviteeUserId"}),r),{code:ue.PARAMS_ERROR};if(!this._PKInfo[e])return this._logger.error(he.L_LIVING_PK_HANDLER_CANCEL_REQUEST_JOIN_OTHER_ROOM_R,JSON.stringify({status:ge.FAILED,code:ue.PARAMS_ERROR,msg:`The request to connect with ${t} user in room ${e} is not initiated`}),r),{code:ue.PARAMS_ERROR};const n={inviterRoomId:this._mainRoomId,inviterUserId:this._context.getCurrentId(),inviteeRoomId:e,inviteeUserId:t,extra:i||""},s={roomId:this._mainRoomId,invitedRoomId:e,invitedUserId:t,inviteSessionId:this._PKInfo[e].inviteSessionId,inviteInfo:JSON.stringify(n)},o=yield this._context.cancelRoomPK(s);return o!==oe?(this._logger.error(he.L_LIVING_PK_HANDLER_CANCEL_REQUEST_JOIN_OTHER_ROOM_R,JSON.stringify({status:ge.FAILED,code:o}),r),{code:o}):(this._logger.info(he.L_LIVING_PK_HANDLER_CANCEL_REQUEST_JOIN_OTHER_ROOM_R,JSON.stringify({status:ge.SUCCESSED}),r),delete this._PKInfo[e],{code:ue.SUCCESS})})}responseJoinOtherRoom(e,t,i,r){return I(this,void 0,void 0,function*(){const n=this._logger.createTraceId();if(this._logger.info(he.L_LIVING_PK_HANDLER_RESPONSE_JOIN_OTHER_ROOM_T,JSON.stringify({inviterRoomId:e,inviterUserId:t,agree:i,options:r}),n),!x("inviterRoomId",e,b,!0)||!x("inviterUserId",t,b,!0))return this._logger.error(he.L_LIVING_PK_HANDLER_RESPONSE_JOIN_OTHER_ROOM_R,JSON.stringify({status:ge.FAILED,code:ue.PARAMS_ERROR,msg:"params error -> inviterRoomId or inviterUserId"}),n),{code:ue.PARAMS_ERROR};if(!this._PKInfo[e])return this._logger.error(he.L_LIVING_PK_HANDLER_RESPONSE_JOIN_OTHER_ROOM_R,JSON.stringify({status:ge.FAILED,code:ue.PARAMS_ERROR,msg:`User ${t} in room ${e} did not send a request for connection`}),n),{code:ue.PARAMS_ERROR};const{inviteSessionId:s,inviterUserAutoMix:o}=this._PKInfo[e],a=!L(null==r?void 0:r.autoMix)||(null==r?void 0:r.autoMix),l={inviteSessionId:s,inviterRoomId:e,inviterUserId:t,inviterUserAutoMix:o,inviteeRoomId:this._mainRoomId,inviteeUserId:this._context.getCurrentId(),inviteeUserAutoMix:a},_=Object.assign(l,{inviterUserAutoMix:o}),c=i?Object.assign(l,{MultiRoomKey:`${e}|${this._mainRoomId}`,MultiRoomValue:JSON.stringify(_)}):l;!P(null==r?void 0:r.extra)&&Object.assign(c,{extra:r.extra});const d={agree:i,roomId:this._mainRoomId,inviteSessionId:s,inviteRoomId:e,inviteUserId:t,content:JSON.stringify(c),key:`${e}|${this._mainRoomId}`,value:JSON.stringify(l)},u=yield this._context.responseRoomPK(d);return u!==oe?(this._logger.error(he.L_LIVING_PK_HANDLER_RESPONSE_JOIN_OTHER_ROOM_R,JSON.stringify({status:ge.FAILED,code:u}),n),{code:u}):(this._logger.info(he.L_LIVING_PK_HANDLER_RESPONSE_JOIN_OTHER_ROOM_R,JSON.stringify({status:ge.SUCCESSED}),n),this._PKInfo[e].inviteeUserAutoMix=a,{code:ue.SUCCESS})})}joinOtherRoom(e){return I(this,void 0,void 0,function*(){const t=this._logger.createTraceId();if(this._logger.info(he.L_LIVING_PK_HANDLER_JOIN_OTHER_ROOM_T,JSON.stringify({roomId:e}),t),!x("roomId",e,b,!0))return this._logger.error(he.L_LIVING_PK_HANDLER_JOIN_OTHER_ROOM_R,JSON.stringify({status:ge.FAILED,code:ue.PARAMS_ERROR,msg:"params error -> roomId"}),t),{code:ue.PARAMS_ERROR};if(this._context.getConnectionStatus()!==l.CONNECTED)return this._logger.error(he.L_LIVING_PK_HANDLER_JOIN_OTHER_ROOM_R,JSON.stringify({status:ge.FAILED,code:ue.SIGNAL_DISCONNECTED,msg:"IM disconnected"}),t),{code:ue.SIGNAL_DISCONNECTED};if(this._joinedPKRooms[e])return this._logger.warn(he.L_LIVING_PK_HANDLER_JOIN_OTHER_ROOM_R,JSON.stringify({status:ge.FAILED,code:ue.REPERT_JOIN_ROOM,msg:"Join the room repeatedly"}),t),{code:ue.REPERT_JOIN_ROOM};const i=ol.VIDEO,r={extra:`{"roomId": "${this._mainRoomId}"}`},n=new gl(this._context,this._runtime,e,this._service,this._initOptions,i,!1,!1,this._clientSessionId),{code:s}=yield n.__innerInit(vo.LIVE,void 0,i,r);return s!==ue.SUCCESS?(this._logger.error(he.L_LIVING_PK_HANDLER_JOIN_OTHER_ROOM_R,JSON.stringify({status:ge.FAILED,code:s}),t),{code:s}):(this._joinedPKRooms[e]=n,yield this._onJoinedPKRoom(e,t),this._logger.info(he.L_LIVING_PK_HANDLER_JOIN_OTHER_ROOM_R,JSON.stringify({status:ge.SUCCESSED}),t),{room:n,code:ue.SUCCESS,userIds:n.getRemoteUserIds(),tracks:n.getRemoteTracks()})})}leaveOtherRoom(e,t){return I(this,void 0,void 0,function*(){const i=this._logger.createTraceId();return this._logger.info(he.L_APP_CALL_LEAVE_PK_ROOM_O,void 0,i),this._invoker.push(this.createLeaveOtherRoomCommand(e,t,i))})}getPKInfo(e){return this._PKInfo[e]}getAllPKInfo(){return this._PKInfo}getJoinedPKRooms(){return this._joinedPKRooms}}!function(e){e[e.OPEN=1]="OPEN",e[e.STOP=2]="STOP"}(al||(al={}));class ul extends ko{constructor(e,t){super(),Object.defineProperty(this,"cdnValues",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"enable",{enumerable:!0,configurable:!0,writable:!0,value:t})}get kind(){return So.ENABLE_INNER_CDN}execute(e,t,i){return I(this,void 0,void 0,function*(){const{logger:r,context:n}=e,{enable:s}=this;if(r.info(he.L_LIVING_ROOM_ENABLE_INNER_CDN_T,JSON.stringify({roomId:t.roomId,enable:s})),!t.isMainRoom)return r.error(he.L_LIVING_ROOM_ENABLE_INNER_CDN_R,JSON.stringify({status:ge.FAILED,code:ue.THE_FUNCTION_IS_DISABLED_IN_PKROOM,msg:"method not available in PK room"})),{code:ue.THE_FUNCTION_IS_DISABLED_IN_PKROOM};if(!L(s))return r.error(he.L_LIVING_ROOM_ENABLE_INNER_CDN_R,JSON.stringify({status:ge.FAILED,code:ue.PARAMS_ERROR,msg:"params error -> enable"})),{code:ue.PARAMS_ERROR};t.setCDNEnabel(s);const o={version:2,output:{inCDNModel:s?al.OPEN:al.STOP}},{code:a}=yield new Xa(o,this.cdnValues).execute(e,t,i);if(a!==ue.SUCCESS)return r.error(he.L_LIVING_ROOM_ENABLE_INNER_CDN_R,JSON.stringify({status:ge.FAILED,code:a,msg:"signal error"})),{code:ue.SIGNAL_ERROR};const l=t.getCDNUris();if(l&&l.broadcast!==sa.SPREAD)return r.info(he.L_LIVING_ROOM_ENABLE_INNER_CDN_R,JSON.stringify({status:ge.SUCCESSED,enable:s})),{code:ue.SUCCESS};const{code:_}=yield ga(n,t);return _===ue.SUCCESS?(r.info(he.L_LIVING_ROOM_ENABLE_INNER_CDN_R,JSON.stringify({status:ge.SUCCESSED,enable:s})),{code:ue.SUCCESS}):(r.error(he.L_LIVING_ROOM_ENABLE_INNER_CDN_R,JSON.stringify({status:ge.FAILED,code:_})),{code:_})})}}!function(e){e[e.AnchorToViewer=1]="AnchorToViewer",e[e.ViewerToAnchor=2]="ViewerToAnchor"}(ll||(ll={}));class hl extends ko{constructor(e,t){super(),Object.defineProperty(this,"livingType",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"traceId",{enumerable:!0,configurable:!0,writable:!0,value:t})}get kind(){return So.RTC_IDENTITY_CHANGE}execute(e,t,i){return I(this,void 0,void 0,function*(){var r;const{context:n}=e,{code:s,data:o}=yield n.rtcIdentityChange(t.roomId,ll.ViewerToAnchor,this.livingType);if(s!==oe||!o)return{code:s};t.initWithRoomData(o,this.traceId);t.getResourcesByUserId(t.crtUserId).length>0&&i.push(new Fo);const a=null===(r=o.roomInfo.filter(e=>"cdn_uris"===e.key)[0])||void 0===r?void 0:r.value;return a&&t.setCDNUris(JSON.parse(a)[0]),{code:s,data:o}})}}class gl extends Za{constructor(e,t,i,r,n,s,o,a,l){super(e,t,i,vo.LIVE,r,n,o,a,l),Object.defineProperty(this,"_livingType",{enumerable:!0,configurable:!0,writable:!0,value:s}),Object.defineProperty(this,"_mcuConfigBuilder",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_roomPKHandler",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._mcuConfigBuilder=new sl(this._executeCtx,this._invoker,this._isValidResourceId.bind(this))}_initRoomPKHandler(e){if(this._store.isMainRoom){const t=((e,t)=>{const i={};return t.forEach(t=>{const r=JSON.parse(t.value),{inviterRoomId:n,inviteeRoomId:s}=r;i[e===n?s:n]=JSON.parse(t.value)}),i})(this._roomId,e.roomInfo);this._roomPKHandler=new dl(this._invoker,t,this._context,this._runtime,this._service,this._initOptions,this,super._registerPKMsgListener.bind(this),this._onJoinedPKRoom.bind(this),this._clientSessionId)}}__innerInit(e,t,i,r,n,s){const o=Object.create(null,{__innerInit:{get:()=>super.__innerInit}});return I(this,void 0,void 0,function*(){if(!x("livingType",i,e=>e===ol.AUDIO||e===ol.VIDEO))return this._logger.error(he.L_RTC_CLIENT_JOIN_LIVING_ROOM_R,JSON.stringify({status:ge.FAILED,code:ue.PARAMS_ERROR,msg:"params error -> livingType"}),s),{code:ue.PARAMS_ERROR};const{code:a,data:l}=yield o.__innerInit.call(this,e,t,i,r,n,s);return a===ue.SUCCESS&&l&&this._initRoomPKHandler(l),{code:a,data:l}})}__innerInitByIdentityChange(e){return I(this,void 0,void 0,function*(){const{code:t,data:i}=yield this._invoker.push(new hl(this._livingType,e));return t===oe&&i?(this._initRoomPKHandler(i),this._initWithRoomData(i.offlineKickTime),this._logger.info(he.L_RTC_CLIENT_UPGRADE_TO_ANCHOR_ROOM_R,JSON.stringify({status:ge.SUCCESSED,roomData:i}),e)):this._logger.error(he.L_RTC_CLIENT_UPGRADE_TO_ANCHOR_ROOM_R,JSON.stringify({status:ge.FAILED,code:t}),e),t})}publish(e){const t=Object.create(null,{publish:{get:()=>super.publish}});return I(this,void 0,void 0,function*(){return this._store.isMainRoom?t.publish.call(this,e):(this._logger.error(he.L_ABSTRACT_ROOM_PUBLISH_R,JSON.stringify({status:ge.FAILED,code:ue.THE_FUNCTION_IS_DISABLED_IN_PKROOM,msg:"method not available in PK room"})),{code:ue.THE_FUNCTION_IS_DISABLED_IN_PKROOM})})}unpublish(e){const t=Object.create(null,{unpublish:{get:()=>super.unpublish}});return I(this,void 0,void 0,function*(){return this._store.isMainRoom?t.unpublish.call(this,e):(this._logger.error(he.L_ABSTRACT_ROOM_UNPUBLISH_R,JSON.stringify({status:ge.FAILED,code:ue.THE_FUNCTION_IS_DISABLED_IN_PKROOM,msg:"method not available in PK room"})),{code:ue.THE_FUNCTION_IS_DISABLED_IN_PKROOM})})}_isValidResourceId(e){var t;const{userId:i}=gi(e),r=!!(null===(t=this._store.getResourcesByUserId(i))||void 0===t?void 0:t.find(t=>hi(t)===e));let n=!1;const{code:s,roomPKHandler:o}=this.getRoomPKHandler();if(s!==ue.SUCCESS||!o)return r;const a=o.getJoinedPKRooms(),l=[];return Object.values(a).forEach(e=>{l.push(...e.getRemoteTracks())}),n=l.some(t=>e===t.getTrackId()),r||n}getLivingType(){return this._livingType}getMCUConfigBuilder(){return this._store.isMainRoom?this._mcuConfigBuilder:(this._logger.error(he.L_LIVING_ROOM_GET_MCU_CONFIG_BUILDER_O,"the `getMCUConfigBuilder` is disabled in PK room"),{code:ue.THE_FUNCTION_IS_DISABLED_IN_PKROOM})}enableInnerCDN(e){return I(this,void 0,void 0,function*(){return this._invoker.push(new ul(this._mcuConfigBuilder.__innerGetValues(),e))})}_resourceHandle(e,t,i,r,n){const s=Object.create(null,{_resourceHandle:{get:()=>super._resourceHandle}});return I(this,void 0,void 0,function*(){s._resourceHandle.call(this,e,t,i,r,n)})}__getCDNEnable(){var e;return!!(null===(e=this._store.getCDNUris())||void 0===e?void 0:e.enableInnerCDN)}__getCDNPushMode(){var e;return null===(e=this._store.getCDNUris())||void 0===e?void 0:e.push_mode}_onJoinedPKRoom(e,t){return I(this,void 0,void 0,function*(){this._invoker.push(new _l(e,this._roomPKHandler,t))})}_getPushOtherRoomsParams(){const e=[];if(!this.isMainRoom()||!this._roomPKHandler)return e;const t=this._roomPKHandler.getJoinedPKRooms();for(const i in t){const r=t[i].getSessionId(),n=this._roomPKHandler.getPKInfo(i);if(!n)continue;const{inviterUserAutoMix:s,inviteeUserAutoMix:o,inviterUserId:a}=n,l=this._context.getCurrentId()===a;e.push({roomId:i,sessionId:r,autoMix:l?!!s:!!o})}return e}getRoomPKHandler(){return this._store.isMainRoom?(this._logger.info(he.L_LIVING_ROOM_GET_ROOM_PK_HANDLER_O,JSON.stringify({status:ge.SUCCESSED})),{code:ue.SUCCESS,roomPKHandler:this._roomPKHandler}):(this._logger.error(he.L_LIVING_ROOM_GET_ROOM_PK_HANDLER_O,JSON.stringify({status:ge.SUCCESSED,code:ue.THE_FUNCTION_IS_DISABLED_IN_PKROOM,msg:"method not available in PK room"})),{code:ue.THE_FUNCTION_IS_DISABLED_IN_PKROOM})}_quitAllPKRoom(){return I(this,void 0,void 0,function*(){const e=this._roomPKHandler.getJoinedPKRooms();for(const t in e)this._roomPKHandler.leaveOtherRoom(e[t]);this._logger.info(he.L_LIVING_ROOM_QUIT_ALL_PK_ROOM_O,JSON.stringify({status:ge.SUCCESSED,roomIds:Object.keys(e)}))})}isMainRoom(){return this._store.isMainRoom}}class pl extends Za{constructor(e,t,i,r,n,s=vo.RTC,o=!1){super(e,t,i,s,r,n,!1,!1,qs(),o)}}const fl=new class{constructor(){Object.defineProperty(this,"queue",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"locked",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"taskCount",{enumerable:!0,configurable:!0,writable:!0,value:0})}checkToStart(){return I(this,void 0,void 0,function*(){if(0===this.queue.length||this.locked)return;this.locked=!0;const{resolve:e,task:t,reject:i}=this.queue.shift();let r;try{r=yield t(),e(r)}catch(e){i(e)}this.locked=!1,this.checkToStart()})}push(e,t=""){const i=new Promise((t,i)=>{this.queue.push({resolve:t,task:e,reject:i})});return this.checkToStart(),i}},El=(e,t="")=>fl.push(e,t);class Tl{constructor(e,t,i){Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_pc",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_service",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_rtcToken",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(this,"_liveUrl",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(this,"_subTracks",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_subscribedList",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_reportListener",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_clientSessionId",{enumerable:!0,configurable:!0,writable:!0,value:qs()}),Object.defineProperty(this,"_store",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_crtUserId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_livingType",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_mediaType",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_subTiny",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_fromRetry",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_appListener",{enumerable:!0,configurable:!0,writable:!0,value:null}),this._crtUserId=this._context.getCurrentId(),this._service=new eo(t,e,i.mediaServer),this._logger=this._context.logger,this._store=new Go(this._logger,this._clientSessionId,this._context.getAppkey(),this._crtUserId,this._crtUserId,vo.LIVE)}_getReqHeaders(e){return I(this,void 0,void 0,function*(){const t=this._crtUserId;if(!this._rtcToken){const{code:i,data:r}=yield this._context.getRTCToken(t,vo.LIVE,e);if(i!==oe)return{code:ue.SIGNAL_ERROR};this._rtcToken=r.rtcToken}return{code:ue.SUCCESS,headers:{"App-Key":this._context.getAppkey(),UserId:this._crtUserId,RoomId:t,RoomType:vo.LIVE,Token:this._rtcToken,"Client-Session-Id":this._clientSessionId}}})}_clearSubscribeInfo(){var e;this._liveUrl="",this._livingType=null,this._mediaType=null,this._subTiny=!1,this._subTracks.length=0,null===(e=this._pc)||void 0===e||e.destroy(),this._pc=null}_reTryExchange(){return I(this,void 0,void 0,function*(){var e;this._fromRetry=!0;const{code:t}=yield this.subscribe(this._liveUrl,this._livingType,this._mediaType,this._subTiny);return t===ue.SUCCESS&&(null===(e=this._pc)||void 0===e||e.clearReTryExchangeTimer()),{code:t}})}subscribe(e,t,i){return I(this,arguments,void 0,function*(e,t,i,r=!1){return El(()=>this.__subscribe(e,t,i,r),"audience-client-sub")})}__subscribe(e,t,i){return I(this,arguments,void 0,function*(e,t,i,r=!1){var n;this._logger.info(he.L_AUDIENCE_CLIENT_SUBSCRIBE_T,JSON.stringify({liveUrl:e,livingType:t,mediaType:i,subTiny:r}));const s=[];if(bi(this._context.getNaviInfo()))return this._logger.error(he.L_AUDIENCE_CLIENT_SUBSCRIBE_R,JSON.stringify({status:ge.FAILED,code:ue.PACKAGE_ENVIRONMENT_ERROR,msg:"package environment error"})),{code:ue.PACKAGE_ENVIRONMENT_ERROR,tracks:s};if(!this._fromRetry&&(null===(n=this._pc)||void 0===n||n.clearReTryExchangeTimer()),this._fromRetry=!1,!C(e))return this._logger.error(he.L_AUDIENCE_CLIENT_SUBSCRIBE_R,JSON.stringify({status:ge.FAILED,code:ue.PARAMS_ERROR,msg:`params error -> liveUrl: ${e}`})),{code:ue.PARAMS_ERROR,tracks:s};if(![ol.AUDIO,ol.VIDEO].includes(t))return this._logger.error(`livingType is invalid: ${t}`),this._logger.error(he.L_AUDIENCE_CLIENT_SUBSCRIBE_R,JSON.stringify({status:ge.FAILED,code:ue.PARAMS_ERROR,msg:`params error -> livingType: ${t}`})),{code:ue.PARAMS_ERROR,tracks:s};if(![Pt.AUDIO_ONLY,Pt.VIDEO_ONLY,Pt.AUDIO_VIDEO].includes(i))return this._logger.error(he.L_AUDIENCE_CLIENT_SUBSCRIBE_R,JSON.stringify({status:ge.FAILED,code:ue.PARAMS_ERROR,msg:`params error -> -> mediaType: ${i}`})),{code:ue.PARAMS_ERROR,tracks:s};if(this._liveUrl&&this._liveUrl!==e)return this._logger.error(he.L_AUDIENCE_CLIENT_SUBSCRIBE_R,JSON.stringify({status:ge.FAILED,code:ue.BROADCAST_SUB_LIST_NOT_EMPTY,msg:"repeat subscribe"})),{code:ue.BROADCAST_SUB_LIST_NOT_EMPTY,tracks:s};this._pc||(this._pc=new Mo(this._context,this._logger,this._reTryExchange.bind(this),this._crtUserId,this._store,void 0,!1),this._pc.on(Mo.__INNER_EVENT_TRACK_READY__,this._onTrackReady,this),this._pc.registerReportListener(this._reportListener),this._pc.__reportR3R4ToPolaris()),this._liveUrl=e;const{code:o,headers:a}=yield this._getReqHeaders(t);if(o!==ue.SUCCESS)return this._logger.error(he.L_AUDIENCE_CLIENT_SUBSCRIBE_R,JSON.stringify({status:ge.FAILED,code:o,msg:"getRTCToken failed"})),{code:o,tracks:s};const l=`rc_mcu_${Date.now()}`,_="RongCloudRTC";0===this._subTracks.length&&(this._subTracks.push(new ni(this._logger,_,l),new si(this._logger,_,l)),this._pc.updateSubRemoteTracks(this._subTracks.slice()));const c={sdp:yield this._pc.createOffer(!0),liveUrl:e,mediaType:i,simulcast:r?to.TINY:to.NORMAL,switchstream:!1},d=yield this._service.broadcastSubscribe(a,c);if(d.code!==ue.SUCCESS)return this._logger.error(he.L_AUDIENCE_CLIENT_SUBSCRIBE_R,JSON.stringify({status:ge.FAILED,code:d.code})),{code:d.code,tracks:s};const u=d.data;if(u.resultCode!==ue.SUCCESS)return this._logger.error(he.L_AUDIENCE_CLIENT_SUBSCRIBE_R,JSON.stringify({status:ge.FAILED,code:u.resultCode,msg:u.message})),{code:u.resultCode,tracks:s};this._livingType=t,this._mediaType=i,this._subTiny=r;const{sdp:h,subscribedList:g}=u;this._subscribedList=g;const p=[];return g.forEach(e=>{const{mediaType:t}=e,i=this._subTracks[t];p.push(i),i.__innerSetRemoteMuted(!0)}),this._pc.setRemoteAnswer(h.sdp),p&&this._updateTrackIdSSRCMap(h.sdp,p),this._logger.info(he.L_AUDIENCE_CLIENT_SUBSCRIBE_R,JSON.stringify({status:ge.SUCCESSED,liveUrl:e})),{code:ue.SUCCESS,tracks:p}})}_updateTrackIdSSRCMap(e,t){t.forEach(t=>{const i=t.getTrackId(),{mediaType:r}=gi(i),{msid:n}=this._subscribedList.filter(e=>e.mediaType===r)[0],s=ma(e,n,r);this._store.setTrackIdSSRCMap(Number(s),i)})}unsubscribe(){return I(this,void 0,void 0,function*(){return El(()=>this.__unsubscribe(),"audience-client-unsub")})}__unsubscribe(){return I(this,void 0,void 0,function*(){var e;if(this._logger.info(he.L_AUDIENCE_CLIENT_UNSUBSCRIBE_T,JSON.stringify({liveUrl:this._liveUrl})),null===(e=this._pc)||void 0===e||e.clearReTryExchangeTimer(),!this._rtcToken||!this._liveUrl)return this._logger.warn(he.L_AUDIENCE_CLIENT_UNSUBSCRIBE_R,JSON.stringify({status:ge.FAILED,code:"",msg:"Address does not exist, without unsubscribe"})),{code:ue.SUCCESS};const{headers:t}=yield this._getReqHeaders(),{code:i}=yield this._service.broadcastExit(t);return i!==ue.SUCCESS?this._logger.error(he.L_AUDIENCE_CLIENT_UNSUBSCRIBE_R,JSON.stringify({status:ge.FAILED,code:i})):(this._logger.info(he.L_AUDIENCE_CLIENT_UNSUBSCRIBE_R,JSON.stringify({status:ge.SUCCESSED,liveUrl:this._liveUrl})),this._subscribedList=[]),this._clearSubscribeInfo(),{code:i}})}registerReportListener(e){this._reportListener=e}registerTrackEventListener(e){this._appListener=e}_onTrackReady(e){var t,i;const{track:r}=e.receiver,n="audio"===r.kind?Pt.AUDIO_ONLY:Pt.VIDEO_ONLY,s=this._subTracks[n];s.__innerSetMediaStreamTrack(r);try{this._logger.info(he.L_AUDIENCE_CLIENT_CALL_ONTRACKREADY_O,`trackId: ${s.getTrackId()}`),null===(i=null===(t=this._appListener)||void 0===t?void 0:t.onTrackReady)||void 0===i||i.call(t,s)}catch(e){this._logger.error(he.L_AUDIENCE_CLIENT_CALL_ONTRACKREADY_O,JSON.stringify(e))}}}var ml,Il;!function(e){e.RTMP="rtmp",e.FLV="flv",e.HLS="hls"}(ml||(ml={})),function(e){e[e.NOT_HTTPS=0]="NOT_HTTPS",e[e.HTTPS=1]="HTTPS"}(Il||(Il={}));const Rl=Object.assign(Object.assign({},mi(Nt.W176_H144)),{frameRate:Si(yt.FPS_15)});class Sl{constructor(e,t,i,r,n,s,o=qs()){Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_runtime",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_initOptions",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_roomId",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_joinResData",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"livingType",{enumerable:!0,configurable:!0,writable:!0,value:s}),Object.defineProperty(this,"_clientSessionId",{enumerable:!0,configurable:!0,writable:!0,value:o}),Object.defineProperty(this,"_service",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_roomAnchorList",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_roomRes",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_roomAnchorRes",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_remoteTracks",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_appListener",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_pc",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_subscribedList",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_sessionId",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(this,"_destroyed",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_polarisReport",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_audioLevelReport",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_CDNUris",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_isPulling",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_pullTime",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_store",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_crtUserId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_reportMediaActionLogger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_trackMediaMap",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_reportListener",{enumerable:!0,configurable:!0,writable:!0,value:null}),this._logger=this._context.logger,this._crtUserId=this._context.getCurrentId(),this._polarisReport=new ja(this._context,this._runtime,this._roomId,this,ka.Audience),this._reportMediaActionLogger=new Fa(this._logger,this._roomId,this._clientSessionId,this._crtUserId),this._service=new eo(this._runtime,this._context,this._initOptions.mediaServer,this._initOptions.timeout);const a=this._store=new Go(this._logger,o,e.getAppkey(),r,this._crtUserId,vo.LIVE),l=this._pc=new Mo(this._context,this._logger,this._reTryExchange.bind(this),this._crtUserId,a,this._polarisReport,!0);this._audioLevelReport=new wo(this._store,l),l.on(Mo.__INNER_AUDIOLEVEL_CHANGE__,this._audioLevelReport.audioLevelReport,this._audioLevelReport),this._polarisReport.sendR1(),this._context.registerRTCSignalListener(e=>I(this,void 0,void 0,function*(){const{time:t,type:i,roomId:r}=this._context.decodeRtcNotify(e);1===i&&this._startPull(r,t)})),this._setInitData()}_startPull(e,t){return I(this,void 0,void 0,function*(){if(this._isPulling)return;this._isPulling=!0;if(this._pullTime>t)return void(this._isPulling=!1);const i=this._logger.createTraceId();this._logger.info(he.L_AUDIENCE_LIVING_ROOM_PULL_KVENTRIES_T,`pullTime: ${this._pullTime}`,i);const{code:r,data:n}=yield this._context.pullRTCRoomEntry(e);if(r===oe){this._isPulling=!1,this._pullTime=(null==n?void 0:n.syncTime)||0;const t=(null==n?void 0:n.kvEntries)||[];this._logger.info(he.L_AUDIENCE_LIVING_ROOM_PULL_KVENTRIES_R,`status: ${ge.SUCCESSED}, kvEntries: ${JSON.stringify(t)}`,i),this.singalDataChange(t,e,i)}this._logger.info(he.L_AUDIENCE_LIVING_ROOM_PULL_KVENTRIES_R,`status: ${ge.FAILED}, code: ${r}`,i)})}_setInitData(){const{sessionId:e,remoteUserIds:t,remoteRTCUris:i,remoteMUCUris:r,remoteTracks:n,CDNUris:s}=((e,t,i)=>{const r=t.filter(e=>"RC_RTC_SESSIONID"===e.key)[0],n=r?r.value:"",s=t.filter(e=>"RC_ANCHOR_LIST"===e.key).map(e=>JSON.parse(e.value||"[]"))[0],o=t.filter(e=>e.key.includes("RC_RES_")).map(e=>JSON.parse(e.value||"{}")),a=o.length?JSON.parse(o[0].mcu_uris||"[]"):[],l=[];a.forEach(t=>{const{mediaType:r,tag:n}=t,s=r===Pt.AUDIO_ONLY?new ni(i,n,"",e):new si(i,n,"",e);l.push(s)});const _=[],c=[];o.forEach(e=>{const t=JSON.parse(e.uris||"[]");_.push(...t),t.forEach(e=>{const{mediaType:t,tag:r,msid:n}=e,s=n.split("_");s.pop();const o=s.join("_"),a=t===Pt.AUDIO_ONLY?new ni(i,r,o):new si(i,r,o);c.push(a)})});const d=t.filter(e=>"RC_CDN"===e.key).map(e=>{const t=JSON.parse(e.value||"[]");return JSON.parse(t.cdn_uris)[0]})[0];return{sessionId:n,remoteUserIds:s||[],remoteRTCUris:_,remoteMUCUris:a,remoteRTCTracks:c,remoteMCUTracks:l,remoteTracks:[...c,...l],CDNUris:d||{}}})(this._roomId,this._joinResData.kvEntries,this._logger);this._sessionId=e,this._roomAnchorList=t,n.forEach(e=>{this._remoteTracks[e.getTrackId()]=e}),this._CDNUris=s,i.forEach(e=>{const t=e.msid.split("_")[0];this._roomAnchorRes[t]?this._roomAnchorRes[t].push(e):this._roomAnchorRes[t]=[e];const{ssrc:i,resourceId:r}=JSON.parse(e.uri);this._store.setTrackIdSSRCMap(i,r)}),r.forEach(e=>{const{mediaType:t,tag:i}=e,r=[this._roomId,i,t].join("_");this._roomRes[r]=e;const{ssrc:n}=JSON.parse(e.uri);this._store.setTrackIdSSRCMap(n,r)}),i.forEach(e=>{const t=hi(e);this._roomRes[t]=e})}_assertRoomDestroyed(){if(this._destroyed)return ue.ROOM_HAS_BEEN_DESTROYED}singalDataChange(e,t,i){var r;if(t!==this._roomId)return void this._logger.error(he.L_AUDIENCE_LIVING_ROOM_SINGAL_DATA_CHANGE_P,JSON.stringify({status:ge.FAILED,msg:`roomId inconsistency -> params roomId:${t}, current roomId:${this._roomId}`}),i);const n=[],s=null===(r=e.filter(e=>"RC_CDN"===e.key)[0])||void 0===r?void 0:r.value;s&&this._diffCDNUris(JSON.parse(JSON.parse(s).cdn_uris)[0],i),e.forEach(e=>{const{key:t,value:r,uid:s}=e;if(-1!==t.indexOf("RC_RES_")){const e=JSON.parse(r||"{}"),t=JSON.parse(e.mcu_uris||"[]"),o=JSON.parse(e.uris||"[]");return n.push(...t),void this._diffAnchorResource(o,s,i)}if("RC_ANCHOR_LIST"===t){const e=JSON.parse(r||"[]");this._diffAnchorList(e,i)}}),this._diffRoomResource(n,i)}_diffAnchorList(e,t){const i=e.filter(e=>this._roomAnchorList.indexOf(e)<0),r=this._roomAnchorList.filter(t=>e.indexOf(t)<0);i.length>0&&this._handleNewJoinedAnchor(i,t),r.length>0&&this._handleLeftedAnchor(r,t)}_handleNewJoinedAnchor(e,t){this._roomAnchorList.push(...e),this._logger.info(he.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O,JSON.stringify({eventType:"onAnchorJoin",list:e}),t),this._callAppListener("onAnchorJoin",e)}_handleLeftedAnchor(e,t){return I(this,void 0,void 0,function*(){this._roomAnchorList=this._roomAnchorList.filter(t=>!e.includes(t));const i=[];e.forEach(e=>{i.push(...this.getRemoteTracksByUserId(e)),delete this._roomAnchorRes[e]}),i.length&&(yield this.unsubscribe(i),i.forEach(e=>delete this._remoteTracks[e.getTrackId()])),this._logger.info(he.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O,JSON.stringify({eventType:"onAnchorLeave",list:e}),t),this._callAppListener("onAnchorLeave",e)})}_diffRoomResource(e,t){return I(this,void 0,void 0,function*(){const i=[],r=[],n=[];e.forEach(e=>{const t=hi(e),{tag:r,mediaType:s}=gi(t),o=[this._roomId,r,s].join("_"),{ssrc:a}=JSON.parse(e.uri);if(this._store.setTrackIdSSRCMap(a,o),!this._remoteTracks[o]){const t=s===Pt.AUDIO_ONLY?new ni(this._logger,r,"",this._roomId):new si(this._logger,r,"",this._roomId);i.push(t),this._remoteTracks[o]=t,this._roomRes[t.getTrackId()]=e}n.push(o)}),Object.keys(this._remoteTracks).forEach(e=>{n.indexOf(e)<0&&this._remoteTracks[e].isMCUTrack()&&r.push(this._remoteTracks[e])}),i.length>0&&(this._logger.info(he.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O,JSON.stringify({eventType:"onTrackPublish",trackIds:i.map(e=>e.getTrackId())}),t),this._callAppListener("onTrackPublish",i)),r.length>0&&this._onUserUnpublish(r,"onTrackUnpublish",t)})}_dealPublished(e,t,i){return I(this,void 0,void 0,function*(){const r=e.map(hi),n=[],s=[];if(t.forEach(t=>{const i=hi(t),o=r.indexOf(i),{userId:a,tag:l,mediaType:_}=gi(i),{ssrc:c}=JSON.parse(t.uri);this._store.setTrackIdSSRCMap(c,i),o>-1?e[o]=t:e.push(t);let d=this._remoteTracks[i];this._roomRes[i]=t,d?d.isSubscribed()&&n.push(d):(d=_===Pt.AUDIO_ONLY?new ni(this._logger,l,a):new si(this._logger,l,a),this._remoteTracks[i]=d,s.push(d)),d.__innerSetRemoteMuted(0===t.state)}),n.length){const e=n.map(e=>e.getTrackId()),{code:t}=yield El(()=>this._subscribeHandle(n,!0));t!==ue.SUCCESS&&this._logger.error(he.L_RESUB_REPUB_RES_R,JSON.stringify({status:ge.FAILED,trackIds:e,code:t}))}this._logger.info(he.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O,JSON.stringify({eventType:"onAnchorTrackPublish",trackIds:s.map(e=>e.getTrackId())}),i),this._callAppListener("onAnchorTrackPublish",s)})}_dealUnpublished(e,t,i){return I(this,void 0,void 0,function*(){const r=t.map(hi);for(let t=e.length-1;t>=0;t-=1){const i=e[t];r.includes(hi(i))&&e.splice(t,1)}const n=t.map(e=>{const t=hi(e);return this._remoteTracks[t]});yield this._onUserUnpublish(n,"onAnchorTrackUnpublish",i)})}_dealModified(e,t,i){const r=e.map(hi);for(const n of t){const t=hi(n);e[r.indexOf(t)].state=n.state;const s=this._remoteTracks[t];s.__innerSetRemoteMuted(0===n.state);const o=s.isAudioTrack()?"onAudioMuteChange":"onVideoMuteChange";this._logger.info(he.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O,JSON.stringify({eventType:o,trackId:s.getTrackId()}),i),this._callAppListener(o,s)}}_diffAnchorResource(e,t,i){return I(this,void 0,void 0,function*(){const r=this._roomAnchorRes[t]||(this._roomAnchorRes[t]=[]),{publishedList:n,unpublishedList:s,modifiedList:o}=Ei(r,e);n.length&&(yield this._dealPublished(r,n,i)),s.length&&(yield this._dealUnpublished(r,s,i)),o.length&&this._dealModified(r,o,i)})}_onUserUnpublish(e,t,i){return I(this,void 0,void 0,function*(){yield this.unsubscribe(e),e.forEach(e=>{this._subscribedList=this._subscribedList.filter(t=>t.track.getTrackId()!==e.getTrackId()),delete this._roomRes[e.getTrackId()],e.__innerDestroy(),delete this._remoteTracks[e.getTrackId()]}),this._logger.info(he.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O,JSON.stringify({eventType:t,trackIds:e.map(e=>e.getTrackId())}),i),this._callAppListener(t,e)})}_callAppListener(e,...t){var i;const r=null===(i=this._appListener)||void 0===i?void 0:i[e];if(r)try{r(...t)}catch(e){this._logger.error(he.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O,JSON.stringify(e))}}_reTryExchange(){return I(this,void 0,void 0,function*(){return El(()=>I(this,void 0,void 0,function*(){var e;const{reqBody:t}=yield this._createSubscribeParams(this._subscribedList,{},!0),i=yield this._exchangeHandle(t);if(i.code!==ue.SUCCESS)return{code:i.code};const{sdp:r,resultCode:n}=i.data;if(n!==ue.SUCCESS)return{code:n};this._pc.clearReTryExchangeTimer();const s=this._subscribedList.filter(e=>e.track.isMCUTrack());if(s.length>0){const t=s[0].track.getTrackId(),i=null===(e=this._roomRes[t])||void 0===e?void 0:e.msid,n=[this._roomId,"RongCloudRTC"].join("_");r.sdp=r.sdp.replace(new RegExp(i,"g"),n)}return{code:yield this._pc.setRemoteAnswer(r.sdp)}}),"audience-retry-exchange")})}_createSubscribeParams(e,t,i){return I(this,void 0,void 0,function*(){const r=yield this._pc.createOffer(i),n={resolutionInfo:[]},s={min:0,max:0};Object.keys(t).forEach(e=>{const{mediaStream:i,tinyStream:o}=t[e];[i,o].forEach((t,i)=>{var o;const a=1===i?[e,"tiny"].join("_"):e;r.sdp=null===(o=r.sdp)||void 0===o?void 0:o.replace(new RegExp(t.id,"g"),a);const l=t.getVideoTracks()[0];if(!l)return;const _=0===i,{width:c,height:d,frameRate:u}=_?di(l):Rl;n.resolutionInfo.push({trackId:l.id,simulcast:_?to.NORMAL:to.TINY,resolution:`${c}x${d}`});const h=Mt(c,d),g=kt(u);s.min+=h.minBitrate*g,s.max+=h.maxBitrate*g})});return{reqBody:{sdp:r,switchstream:!1,newVersionFlag:!0,subscribeList:e.map(e=>({simulcast:e.subTiny?to.TINY:to.NORMAL,resolution:"",uri:this._roomRes[e.track.getTrackId()].uri}))},dynamicBitrate:s,offer:r}})}_subscribeHandle(e){return I(this,arguments,void 0,function*(e,t=!1,i=!1){const r=Date.now(),n=i?oa.SUB:void 0,s=this._logger.createTraceId();this._logger.info(he.L_AUDIENCE_LIVING_ROOM_SUBSCRIBE_T,JSON.stringify({trackIds:e.map(yi),forceReq:t}),s);if(this._assertRoomDestroyed())return this._logger.error(he.L_AUDIENCE_LIVING_ROOM_SUBSCRIBE_R,JSON.stringify({status:ge.FAILED,code:ue.ROOM_HAS_BEEN_DESTROYED,msg:"room destroyed"}),s),this._reportPubOrSubQualityData(r,e,ue.ROOM_HAS_BEEN_DESTROYED,n),{code:ue.ROOM_HAS_BEEN_DESTROYED};if(!x("tracks",e,()=>v(e)&&e.length>0&&e.every(e=>e instanceof ri||e.track instanceof ri),!0))return this._logger.error(he.L_AUDIENCE_LIVING_ROOM_SUBSCRIBE_R,JSON.stringify({status:ge.FAILED,code:ue.PARAMS_ERROR,msg:"params error -> tracks"}),s),this._reportPubOrSubQualityData(r,e,ue.PARAMS_ERROR,n),{code:ue.PARAMS_ERROR};this._pc.__reportR3R4ToPolaris(),this._pc.registerReportListener(this._reportListener),this._addPeerCEvent();const o=this._subscribedList.map(e=>Object.assign({},e)),a=e.map(e=>e instanceof ri?{track:e}:e),l=[];return a.forEach(e=>{const t=e.track.getTrackId();l.push(t);const i=o.find(e=>e.track.getTrackId()===t);i&&i.subTiny===e.subTiny||(i?i.subTiny=e.subTiny:o.push(e))}),this._polarisReport.sendR2(ra.SUBSCRIBE,na.BEGIN,l),this._updateSubListHandle(o,s,r,n,!0)})}_addPeerCEvent(){this._pc.on(Mo.__INNER_EVENT_TRACK_READY__,e=>{const t=e.streams[0].id,{track:i}=e.receiver,r=[t,"audio"===i.kind?Pt.AUDIO_ONLY:Pt.VIDEO_ONLY].join("_"),n=this._remoteTracks[r];n?(n.__innerSetMediaStreamTrack(i),this._logger.info(he.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O,JSON.stringify({eventType:"onTrackReady",trackId:n.getTrackId()})),this._callAppListener("onTrackReady",n)):this._logger.warn(he.L_AUDIENCE_LIVING_ROOM_ONTRACKREADY_O,`cannot found RCRemoteTrack: ${i.id}`)}),this._pc.once(Mo.__INNER_ICE_CONNECTED__,()=>{this._reportMediaActionLogger.reportIceFirstConnectData("sub")},this),this._pc.on(Mo.__INNER_ICE_STATE_CHANGE__,e=>{const{status:t,time:i,iceCandidatePair:r}=e;r&&this._reportMediaActionLogger.recordQualityIceStatusData(r,t,i)})}_getReqHeaders(){const e=this._crtUserId;return{"App-Key":this._context.getAppkey(),RoomId:e,Token:this._joinResData.token,RoomType:vo.LIVE,UserId:e,"Session-Id":this._sessionId,"Client-Session-Id":this._clientSessionId}}_exchangeHandle(e){return this._service.broadcastSubscribe(this._getReqHeaders(),e)}_dealSubscribeResult(e,t,i){const r=null==t?void 0:t.map(e=>`${e.msid}_${e.mediaType}`),n=e.filter(e=>{if(e.track.isMCUTrack()){const t=this._roomRes[e.track.getTrackId()],i=`${t.msid}_${t.mediaType}`;return r.includes(i)}return null==r?void 0:r.includes(e.track.getTrackId())}),s=null==n?void 0:n.map(e=>`${e.track.getTrackId()}`),o=e.filter(e=>!(null==s?void 0:s.includes(e.track.getTrackId())));for(const e in this._remoteTracks){const t=n.some(t=>t.track.getTrackId()===e);this._remoteTracks[e].__innerSetSubscribed(t)}return this._subscribedList.splice(0,this._subscribedList.length,...n),this._logger.info(he.L_AUDIENCE_LIVING_ROOM_UPDATE_SUBSCRIBELIST_R,JSON.stringify({status:ge.SUCCESSED,subSuccessTrackIds:r,failedList:o}),i),o}_getParams(e){let t=e.map(e=>e instanceof ri?{track:e}:Object.assign({},e));const i={};return t=t.filter(e=>{const t=e.track.getTrackId();return!i[t]&&(i[t]=!0,!0)}).map(e=>Object.assign({},e)),t}_reportPubOrSubQualityData(e,t,i,r){r&&this._reportMediaActionLogger.reportPubOrSubQualityData(r,e,t,i,this._trackMediaMap)}_updateSubListHandle(e,t,i,r){return I(this,arguments,void 0,function*(e,t,i,r,n=!1){var s;this._logger.info(he.L_AUDIENCE_LIVING_ROOM_UPDATE_SUBSCRIBELIST_T,JSON.stringify({trackIds:e.map(yi),forceReq:n}),t);const o=this._getParams(e),a=this._subscribedList.map(e=>Object.assign({},e));if(!n&&!Ia(o,a))return this._logger.info(he.L_AUDIENCE_LIVING_ROOM_UPDATE_SUBSCRIBELIST_R,JSON.stringify({status:ge.SUCCESSED,msg:"repeat subscribe"}),t),{code:ue.SUCCESS};this._pc.clearReTryExchangeTimer(),this._pc.updateSubRemoteTracks(o.map(e=>e.track));const{reqBody:l}=yield this._createSubscribeParams(o,{},!1),_=yield this._exchangeHandle(l);if(a.length){const e=[];a.forEach(t=>{e.push(t.track.getTrackId())}),null===(s=this._pc.reportParser)||void 0===s||s.clearLatestPacketsRecv(e)}if(e.forEach(e=>{const t=e instanceof ri?e.getTrackId():e.track.getTrackId();this._trackMediaMap[t]=_.qualityMsList||[]}),_.code!==ue.SUCCESS)return this._reportPubOrSubQualityData(i,e,_.code,r),this._logger.error(he.L_AUDIENCE_LIVING_ROOM_UPDATE_SUBSCRIBELIST_R,JSON.stringify({status:ge.FAILED,code:_.code}),t),{code:_.code};const{sdp:c,resultCode:d,message:u,subscribedList:h}=_.data;if(d!==ue.SUCCESS)return this._reportPubOrSubQualityData(i,e,d,r),this._logger.error(he.L_AUDIENCE_LIVING_ROOM_UPDATE_SUBSCRIBELIST_R,JSON.stringify({status:ge.FAILED,code:d,msg:u}),t),{code:d};o.forEach(e=>{const{track:t}=e;if(t.isMCUTrack()){const e=this._roomRes[t.getTrackId()].msid,{tag:i,userId:r}=gi(t.getTrackId()),n=[r,i].join("_");c.sdp=c.sdp.replace(new RegExp(e,"g"),n)}});const g=yield this._pc.setRemoteAnswer(c.sdp);if(this._reportPubOrSubQualityData(i,e,g,r),g!==ue.SUCCESS)return this._logger.error(he.L_AUDIENCE_LIVING_ROOM_UPDATE_SUBSCRIBELIST_R,JSON.stringify({status:ge.FAILED,code:g,msg:"set remote answer error"}),t),{code:g};const p=this._dealSubscribeResult(o,h,t);return p.length?{code:ue.SUCCESS,failedList:p}:{code:ue.SUCCESS}})}_diffCDNUris(e,t){return I(this,void 0,void 0,function*(){if(this._CDNUris.url&&!e.url)return this._logger.info(he.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O,JSON.stringify({eventType:"onCDNInfoDisable"}),t),this._callAppListener("onCDNInfoDisable"),void(this._CDNUris=e);(!this._CDNUris||!this._CDNUris.url&&e.url)&&(this._logger.info(he.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O,JSON.stringify({eventType:"onCDNInfoEnable",resolution:`W${e.w}_H${e.h}`,fps:`FPS_${e.fps}`}),t),this._callAppListener("onCDNInfoEnable",{resolution:`W${e.w}_H${e.h}`,fps:`FPS_${e.fps}`}));const i=this._CDNUris.w&&e.w&&this._CDNUris.w!==e.w,r=this._CDNUris.h&&e.h&&this._CDNUris.h!==e.h,n=this._CDNUris.fps&&e.fps&&this._CDNUris.fps!==e.fps;(i||r||n)&&(this._logger.info(he.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O,JSON.stringify({eventType:"onCDNInfoChange",resolution:`W${e.w}_H${e.h}`,fps:`FPS_${e.fps}`}),t),this._callAppListener("onCDNInfoChange",{resolution:`W${e.w}_H${e.h}`,fps:`FPS_${e.fps}`})),this._CDNUris=e})}_getCDNPlayUrl(e,t){return I(this,void 0,void 0,function*(){const{w:i,h:r,fps:n}=e,s=this._initOptions.pullInnerCDNProtocol||ml.FLV,o=this._initOptions.pullInnerCDNUseHttps===Il.NOT_HTTPS?Il.NOT_HTTPS:Il.HTTPS;if(!this._CDNUris.url)return this._logger.error(he.L_AUDIENCE_LIVING_ROOM_GET_CDN_PLAY_URL_R,JSON.stringify({status:ge.FAILED,code:ue.CDN_RESOURCE_IS_EMPTY,msg:"cdn_uris url is empty, the anchor need to open or push CDN"}),t),{code:ue.CDN_RESOURCE_IS_EMPTY};const a={"App-Key":this._context.getAppkey(),Token:this._joinResData.token,RoomId:this.getRoomId(),UserId:this._crtUserId,SessionId:this.getSessionId()},l=[],{w:_=0,h:c=1}=this._CDNUris;_/c>1?(i&&l.push(`w=${i}`),r&&l.push(`h=${r}`)):(i&&l.push(`h=${i}`),r&&l.push(`w=${r}`)),n&&l.push(`fps=${n}`),l.push(`kind=${s}`),l.push(`is_https=${o}`);const d=l.join("&");let u=`${this._CDNUris.url}?`;d&&(u+=d);const{code:h,res:g}=yield this._service.getCDNResourceInfo(a,u,t);return h!==ue.SUCCESS?{code:h}:{code:h,CDNPlayUrl:null==g?void 0:g.data.pull_url}})}getCDNPlayUrl(e,t){return I(this,void 0,void 0,function*(){const i=this._logger.createTraceId();if(this._logger.info(he.L_AUDIENCE_LIVING_ROOM_GET_CDN_PLAY_URL_T,JSON.stringify({resolution:e,fps:t}),i),e&&!Ii(e))return this._logger.error(he.L_AUDIENCE_LIVING_ROOM_GET_CDN_PLAY_URL_R,JSON.stringify({status:ge.FAILED,code:ue.PARAMS_ERROR,msg:"params error -> resolution"}),i),{code:ue.PARAMS_ERROR};if(t&&!Ri(t))return this._logger.error(he.L_AUDIENCE_LIVING_ROOM_GET_CDN_PLAY_URL_R,JSON.stringify({status:ge.FAILED,code:ue.PARAMS_ERROR,msg:"params error -> fps"}),i),{code:ue.PARAMS_ERROR};const{width:r,height:n}=e?mi(e):{width:null,height:null},s=t?Si(t):null,o={};return r&&(o.w=r),n&&(o.h=n),s&&(o.fps=s),this._getCDNPlayUrl(o,i)})}subscribe(e){return I(this,void 0,void 0,function*(){return El(()=>this._subscribeHandle(e,!1,!0),"audience-sub")})}__unsubscribe(e){return I(this,void 0,void 0,function*(){const t=Date.now(),i=oa.UNSUB,r=this._logger.createTraceId();this._logger.info(he.L_AUDIENCE_LIVING_ROOM_UNSUBSCRIBE_T,JSON.stringify({trackIds:e.map(e=>e.getTrackId())}),r);if(this._assertRoomDestroyed())return this._logger.error(he.L_AUDIENCE_LIVING_ROOM_UNSUBSCRIBE_R,JSON.stringify({status:ge.FAILED,code:ue.ROOM_HAS_BEEN_DESTROYED,msg:"room destroyed"}),r),{code:ue.ROOM_HAS_BEEN_DESTROYED};if(!x("tracks",e,()=>v(e)&&e.length>0&&e.every(e=>e instanceof ri),!0))return this._logger.error(he.L_AUDIENCE_LIVING_ROOM_UNSUBSCRIBE_R,JSON.stringify({status:ge.FAILED,code:ue.PARAMS_ERROR,msg:"params error -> tracks"}),r),{code:ue.PARAMS_ERROR};const n=this._subscribedList.map(e=>Object.assign({},e)).filter(t=>e.every(e=>e.getTrackId()!==t.track.getTrackId()));return this._polarisReport.sendR2(ra.SUBSCRIBE,na.END,e.map(e=>e.getTrackId())),this._updateSubListHandle(n,r,t,i,!1)})}unsubscribe(e){return I(this,void 0,void 0,function*(){return El(()=>this.__unsubscribe(e),"audience-unsub")})}__destroy(e){return I(this,void 0,void 0,function*(){var t;this._destroyed||(this._destroyed=!0,e&&(yield this._context.quitLivingRoomAsAudience(this._roomId)),yield this._service.broadcastExit(this._getReqHeaders()),null===(t=this._pc)||void 0===t||t.destroy(),this._context.registerRTCSignalListener())})}getRemoteTrack(e){return this._remoteTracks[e]}getLocalTrack(e){return{}}__onReconnected(){return I(this,void 0,void 0,function*(){const e=this._logger.createTraceId();this._logger.info(he.L_AUDIENCE_LIVING_ROOM_IM_RECONNECTED_T,void 0,e);const{code:t}=yield this._context.joinLivingRoomAsAudience(this._roomId,vo.LIVE);t!==oe&&this._logger.error(he.L_AUDIENCE_LIVING_ROOM_IM_RECONNECTED_R,`status: ${ge.FAILED}`,e),this._logger.info(he.L_AUDIENCE_LIVING_ROOM_IM_RECONNECTED_R,`status: ${ge.SUCCESSED}`,e)})}registerRoomEventListener(e){this._appListener=e}onAudioLevelChange(e,t){this._logger.info(he.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O),this._audioLevelReport.onAudioLevelChange(e)}registerReportListener(e){this._reportListener=e}getRoomId(){return this._roomId}getCrtUserId(){return this._crtUserId}getSessionId(){return this._sessionId}getRemoteUserIds(){return this._roomAnchorList}getRemoteTracksByUserId(e){const t=[];for(const i in this._remoteTracks){const r=this._remoteTracks[i];r.getUserId()===e&&t.push(r)}return t}getRemoteTracks(){const e=[],t=[];for(const e in this._remoteTracks){if(2===t.length)break;const i=this._remoteTracks[e];i.isMCUTrack()&&t.push(i)}return this._roomAnchorList.forEach(t=>{e.push(...this.getRemoteTracksByUserId(t))}),[...t,...e]}getRemoteRTCTracks(){const e=[];for(const t in this._remoteTracks){const i=this._remoteTracks[t];i.isMCUTrack()||e.push(i)}return e}getRemoteMCUTracks(){const e=[];for(const t in this._remoteTracks){const i=this._remoteTracks[t];i.isMCUTrack()&&e.push(i)}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}}getClientSessionId(){return this._clientSessionId}}var Cl;!function(e){e[e.AUTOMATIC=0]="AUTOMATIC",e[e.MANUAL=1]="MANUAL"}(Cl||(Cl={}));class Ll{constructor(e){Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_isElectron",{enumerable:!0,configurable:!0,writable:!0,value:/Electron/.test(navigator.userAgent)}),this._logger=e.logger}_getMediaStream(e){return I(this,arguments,void 0,function*(e,t="getUserMedia"){try{const i=this.setConstraintsConfig(e),r=yield navigator.mediaDevices[t](i);return{code:ue.SUCCESS,stream:r}}catch(e){if(this._logger.error(he.L_GET_MEDIA_STREAM_E,JSON.stringify({name:e.name,message:e.message})),"Permission denied"===e.message)return{code:ue.BROWSER_PERMISSION_DENIED};if("Permission denied by system"===e.message)return{code:ue.SYSTEM_PERMISSION_DENIED}}return{code:"getUserMedia"===t?ue.GET_USER_MEDIA_FAILED:ue.GET_DISPLAY_MEDIA_FAILED}})}_getMediaStreamErrorReason(e){let t="";return e===ue.BROWSER_PERMISSION_DENIED&&(t="Permission denied"),e===ue.SYSTEM_PERMISSION_DENIED&&(t="Permission denied by system"),t}setConstraintsConfig(e){var t,i;if((null==e?void 0:e.audio)&&!this._isElectron){"boolean"==typeof e.audio&&(e.audio={});const r=null===(i=(t=navigator.mediaDevices).getSupportedConstraints)||void 0===i?void 0:i.call(t);(null==r?void 0:r.noiseSuppression)&&(e.audio.noiseSuppression=!!r.noiseSuppression),(null==r?void 0:r.autoGainControl)&&(e.audio.autoGainControl=!!r.autoGainControl),(null==r?void 0:r.echoCancellation)&&(e.audio.echoCancellation=!!r.echoCancellation),this._logger.info(he.L_SET_AUDIO_CONSTRAINTS_O,`browser supported -> ${JSON.stringify(r)}`)}return e}createMicrophoneAudioTrack(){return I(this,arguments,void 0,function*(e="RongCloudRTC",t){if(!_i(e))return this._logger.error(he.L_RTC_CLIENT_CREATE_MICROPHONE_AUDIO_TRACK_O,JSON.stringify({status:ge.FAILED,code:ue.INVALID_TAGS,msg:"invalid tag"})),{code:ue.INVALID_TAGS};const i=this._context.getCurrentId();if(!i)return this._logger.error(he.L_RTC_CLIENT_CREATE_MICROPHONE_AUDIO_TRACK_O,JSON.stringify({status:ge.FAILED,code:ue.INVALID_USER_ID,msg:"invalid IM connection,invalid userId"})),{code:ue.INVALID_USER_ID};const{stream:r,code:n}=yield this._getMediaStream({audio:{deviceId:(null==t?void 0:t.micphoneId)?{exact:null==t?void 0:t.micphoneId}:void 0,sampleRate:null==t?void 0:t.sampleRate,noiseSuppression:null==t?void 0:t.noiseSuppression,echoCancellation:null==t?void 0:t.echoCancellation,autoGainControl:null==t?void 0:t.autoGainControl}});if(n!==ue.SUCCESS)return this._logger.error(he.L_RTC_CLIENT_CREATE_MICROPHONE_AUDIO_TRACK_O,JSON.stringify({status:ge.FAILED,code:n,msg:this._getMediaStreamErrorReason(n)})),{code:n};const s=r.getAudioTracks()[0],o=new Xt(this._logger,e,i,s);return this._logger.info(he.L_RTC_CLIENT_CREATE_MICROPHONE_AUDIO_TRACK_O,JSON.stringify({status:ge.SUCCESSED,trackId:o.getTrackId()})),{code:n,track:o}})}createCameraVideoTrack(){return I(this,arguments,void 0,function*(e="RongCloudRTC",t){if(!_i(e))return this._logger.error(he.L_RTC_CLIENT_CREATE_CAMERA_VIDEO_TRACK_O,JSON.stringify({status:ge.FAILED,code:ue.INVALID_TAGS,msg:"invalid tag"})),{code:ue.INVALID_TAGS};const i=this._context.getCurrentId();if(!i)return this._logger.error(he.L_RTC_CLIENT_CREATE_CAMERA_VIDEO_TRACK_O,JSON.stringify({status:ge.FAILED,code:ue.INVALID_USER_ID,msg:"invalid IM connection,invalid userId"})),{code:ue.INVALID_USER_ID};const r=Ii(null==t?void 0:t.resolution)?t.resolution:Nt.W640_H480,{width:n,height:s}=mi(r),{stream:o,code:a}=yield this._getMediaStream({video:{deviceId:(null==t?void 0:t.cameraId)?{exact:null==t?void 0:t.cameraId}:void 0,frameRate:Si((null==t?void 0:t.frameRate)||yt.FPS_15),width:{ideal:n,max:n},height:{ideal:s,max:s},facingMode:null==t?void 0:t.faceMode}});if(a!==ue.SUCCESS)return this._logger.error(he.L_RTC_CLIENT_CREATE_CAMERA_VIDEO_TRACK_O,JSON.stringify({status:ge.FAILED,code:a,msg:this._getMediaStreamErrorReason(a)})),{code:a};const l=o.getVideoTracks()[0];yield this._applyVideoAspectRatio(l,n,s);const _=new ei(this._logger,e,i,l);return this._logger.info(he.L_RTC_CLIENT_CREATE_CAMERA_VIDEO_TRACK_O,JSON.stringify({status:ge.SUCCESSED,trackId:_.getTrackId()})),{code:a,track:_}})}createMicrophoneAndCameraTracks(){return I(this,arguments,void 0,function*(e="RongCloudRTC",t){var i;const r=[];if(!_i(e))return this._logger.error(he.L_RTC_CLIENT_CREATE_MICROPHONE_AND_CAMERA_TRACKS_O,JSON.stringify({status:ge.FAILED,code:ue.INVALID_TAGS,msg:"invalid tag"})),{code:ue.INVALID_TAGS,tracks:r};const n=this._context.getCurrentId();if(!n)return this._logger.error(he.L_RTC_CLIENT_CREATE_MICROPHONE_AND_CAMERA_TRACKS_O,JSON.stringify({status:ge.FAILED,code:ue.INVALID_USER_ID,msg:"invalid IM connection,invalid userId"})),{code:ue.INVALID_USER_ID,tracks:r};const s=Ii(null===(i=null==t?void 0:t.video)||void 0===i?void 0:i.resolution)?t.video.resolution:Nt.W640_H480,{width:o,height:a}=mi(s),l=null==t?void 0:t.audio,_=null==t?void 0:t.video,{stream:c,code:d}=yield this._getMediaStream({video:{deviceId:(null==_?void 0:_.cameraId)?{exact:null==_?void 0:_.cameraId}:void 0,frameRate:Si((null==_?void 0:_.frameRate)||yt.FPS_15),width:{ideal:o,max:o},height:{ideal:a,max:a},facingMode:null==_?void 0:_.faceMode},audio:{deviceId:(null==l?void 0:l.micphoneId)?{exact:null==l?void 0:l.micphoneId}:void 0,sampleRate:null==l?void 0:l.sampleRate,noiseSuppression:null==l?void 0:l.noiseSuppression,echoCancellation:null==l?void 0:l.echoCancellation,autoGainControl:null==l?void 0:l.autoGainControl}});if(d!==ue.SUCCESS)return this._logger.error(he.L_RTC_CLIENT_CREATE_MICROPHONE_AND_CAMERA_TRACKS_O,JSON.stringify({status:ge.FAILED,code:d,msg:this._getMediaStreamErrorReason(d)})),{code:d,tracks:r};const u=c.getTracks();for(let t=0;t<u.length;t++){const i=u[t];"video"===i.kind?(yield this._applyVideoAspectRatio(i,o,a),r.push(new ei(this._logger,e,n,i))):r.unshift(new Xt(this._logger,e,n,i))}return this._logger.info(he.L_RTC_CLIENT_CREATE_MICROPHONE_AND_CAMERA_TRACKS_O,JSON.stringify({status:ge.SUCCESSED,trackIds:r.map(e=>e.getTrackId())})),{code:d,tracks:r}})}createScreenVideoTrack(){return I(this,arguments,void 0,function*(e="screenshare",t){const i=yield this._createScreenTracks(e,!1,he.L_RTC_CLIENT_CREATE_SCREEN_VIDEO_TRACK_O,t);return i.code===ue.SUCCESS?{code:i.code,track:i.tracks[0]}:i})}createScreenWithAudioTracks(){return I(this,arguments,void 0,function*(e="screenshare",t){return this._createScreenTracks(e,!0,he.L_RTC_CLIENT_CREATE_SCREEN_VIDEO_AND_AUDIO_TRACKS_O,t)})}_createScreenTracks(e,t,i,r){return I(this,void 0,void 0,function*(){if(!_i(e))return this._logger.error(i,JSON.stringify({status:ge.FAILED,code:ue.INVALID_TAGS,msg:"invalid tag"})),{code:ue.INVALID_TAGS};const n=this._context.getCurrentId();if(!n)return this._logger.error(i,JSON.stringify({status:ge.FAILED,code:ue.INVALID_USER_ID,msg:"invalid IM connection,invalid userId"})),{code:ue.INVALID_USER_ID};if(!Oi())return this._logger.error(he.L_RTC_CLIENT_CREATE_SCREEN_VIDEO_TRACK_O,JSON.stringify({status:ge.FAILED,code:ue.BROWSER_NOT_SUPPORT,msg:"browser not support"})),{code:ue.BROWSER_NOT_SUPPORT};const s=/macintosh|mac os x/i.test(navigator.userAgent),o=(!this._isElectron||!s)&&t,a=Ii(null==r?void 0:r.resolution)?r.resolution:Nt.W1280_H720,{stream:l,code:_}=this._isElectron?yield this._createElectronScreenStream(t,i,a,null==r?void 0:r.chromeMediaSourceId):yield this._createWebScreenStream(t,a,null==r?void 0:r.frameRate);if(_!==ue.SUCCESS)return this._logger.error(i,JSON.stringify({status:ge.FAILED,code:_,msg:this._getMediaStreamErrorReason(_)})),{code:_};const c=l.getVideoTracks()[0],d=[new ti(this._logger,e,n,c)];if(o){const t=l.getAudioTracks()[0];t&&d.push(new ii(this._logger,e,n,t))}return this._logger.info(i,JSON.stringify({status:ge.SUCCESSED,trackIds:d.map(e=>e.getTrackId())})),{code:_,tracks:d}})}_createElectronScreenStream(e,t,i,r){return I(this,void 0,void 0,function*(){var n,s;const o=/macintosh|mac os x/i.test(navigator.userAgent);this._isElectron&&o&&e&&this._logger.warn(t,JSON.stringify({status:ge.INFO,code:ue.MAC_IN_ELECTRON_NOT_SUPPORT_SCREEN_SHARE_WITH_AUDIO,msg:"mac in electron not support screen share with audio"}));const a=(!this._isElectron||!o)&&e;if(this._isElectron&&!P(r)&&!C(r))return this._logger.error(t,JSON.stringify({status:ge.FAILED,code:ue.PARAMS_ERROR,msg:"params error -> options.chromeMediaSourceId type is string"})),{code:ue.PARAMS_ERROR};const{width:l,height:_}=mi(i),c={mandatory:{chromeMediaSourceId:r,chromeMediaSource:"desktop",minWidth:l,maxWidth:l,minHeight:_,maxHeight:_}};!r&&this._isElectron&&(null===(n=c.mandatory)||void 0===n||delete n.chromeMediaSourceId);let d=null;return a&&this._isElectron&&(null===(s=c.mandatory)||void 0===s||delete s.chromeMediaSourceId,d={mandatory:{chromeMediaSource:"desktop"}}),this._getMediaStream({video:c,audio:d||a},"getUserMedia")})}_createWebScreenStream(e,t,i){return I(this,void 0,void 0,function*(){const{width:r,height:n}=mi(t),s={frameRate:Si(i||yt.FPS_15),width:r,height:n};return this._getMediaStream({video:s,audio:e},"getDisplayMedia")})}createLocalAudioTrack(e,t){return I(this,void 0,void 0,function*(){if(!_i(e))return this._logger.error(he.L_RTC_CLIENT_CREATE_LOCAL_AUDIO_TRACK_O,JSON.stringify({status:ge.FAILED,code:ue.INVALID_TAGS,msg:"invalid tag"})),{code:ue.INVALID_TAGS};if(!t||"[object MediaStreamTrack]"!==t.toString()||"audio"!==t.kind)return this._logger.error(he.L_RTC_CLIENT_CREATE_LOCAL_AUDIO_TRACK_O,JSON.stringify({status:ge.FAILED,code:ue.CREATE_CUSTOM_TRACK_FAILED,msg:"params track is not MediaStreamTrack or kind is not audio"})),{code:ue.CREATE_CUSTOM_TRACK_FAILED};const i=this._context.getCurrentId();if(!i)return this._logger.error(he.L_RTC_CLIENT_CREATE_LOCAL_AUDIO_TRACK_O,JSON.stringify({status:ge.FAILED,code:ue.INVALID_USER_ID,msg:"invalid IM connection,invalid userId"})),{code:ue.INVALID_USER_ID};const r=new qt(this._logger,e,i,t);return this._logger.info(he.L_RTC_CLIENT_CREATE_LOCAL_AUDIO_TRACK_O,JSON.stringify({status:ge.SUCCESSED,trackId:r.getTrackId()})),{code:ue.SUCCESS,track:r}})}createLocalVideoTrack(e,t){return I(this,void 0,void 0,function*(){if(!_i(e))return this._logger.error(he.L_RTC_CLIENT_CREATE_LOCAL_VIDEO_TRACK_O,JSON.stringify({status:ge.FAILED,code:ue.INVALID_TAGS,msg:"invalid tag"})),{code:ue.INVALID_TAGS};if(!(t&&t instanceof MediaStreamTrack&&"video"===t.kind))return this._logger.error(he.L_RTC_CLIENT_CREATE_LOCAL_VIDEO_TRACK_O,JSON.stringify({status:ge.FAILED,code:ue.CREATE_CUSTOM_TRACK_FAILED,msg:"params track is not MediaStreamTrack or kind is not video"})),{code:ue.CREATE_CUSTOM_TRACK_FAILED};const i=this._context.getCurrentId();if(!i)return this._logger.error(he.L_RTC_CLIENT_CREATE_LOCAL_VIDEO_TRACK_O,JSON.stringify({status:ge.FAILED,code:ue.INVALID_USER_ID,msg:"invalid IM connection,invalid userId"})),{code:ue.INVALID_USER_ID};const r=new Wt(this._logger,e,i,t);return this._logger.info(he.L_RTC_CLIENT_CREATE_LOCAL_VIDEO_TRACK_O,JSON.stringify({status:ge.SUCCESSED,trackId:r.getTrackId()})),{code:ue.SUCCESS,track:r}})}_validateCreateLocalFileTracks(e,t){if(!_i(e))return this._logger.error(he.L_RTC_CLIENT_CREATE_LOCAL_FILE_TRACKS_O,JSON.stringify({status:ge.FAILED,code:ue.INVALID_TAGS,msg:"invalid tag"})),{code:ue.INVALID_TAGS,tracks:[]};if(!Li())return this._logger.error(he.L_RTC_CLIENT_CREATE_LOCAL_FILE_TRACKS_O,JSON.stringify({status:ge.FAILED,code:ue.BROWSER_NOT_SUPPORT,msg:"browser not support"})),{code:ue.BROWSER_NOT_SUPPORT,tracks:[]};const i=t instanceof File?URL.createObjectURL(t):t;if(!U(i)&&!/^blob:/.test(i))return this._logger.error(he.L_RTC_CLIENT_CREATE_LOCAL_FILE_TRACKS_O,JSON.stringify({status:ge.FAILED,code:ue.PARAMS_ERROR,msg:"params error -> file"})),{code:ue.PARAMS_ERROR,tracks:[]};return this._context.getCurrentId()?{code:ue.SUCCESS,tracks:[],url:i}:(this._logger.error(he.L_RTC_CLIENT_CREATE_LOCAL_FILE_TRACKS_O,JSON.stringify({status:ge.FAILED,code:ue.INVALID_USER_ID,msg:"invalid IM connection,invalid userId"})),{code:ue.INVALID_USER_ID,tracks:[]})}createLocalFileTracks(e,t,i){return I(this,void 0,void 0,function*(){const r=this._validateCreateLocalFileTracks(e,t);if(r.code!==ue.SUCCESS)return r;const n=this._context.getCurrentId();return new Promise(t=>{const s=document.createElement("video");(null==i?void 0:i.withoutAudio)&&(s.muted=!0),s.onloadedmetadata=()=>{const r=[];let o;try{const e=s.mozCaptureStream?"mozCaptureStream":"captureStream";o=s[e]()}catch(e){this._logger.error(he.L_RTC_CLIENT_CREATE_LOCAL_FILE_TRACKS_O,JSON.stringify({status:ge.FAILED,code:ue.CREATE_FILE_TRACK_FAILED,msg:`captureSteam error -> ${JSON.stringify(e)}`})),t({code:ue.CREATE_FILE_TRACK_FAILED,tracks:r})}const[a,l]=Ll.getTracksWithOptions(o,i);a&&r.push(new Zt(this._logger,e,n,a,s)),l&&r.push(new Qt(this._logger,e,n,l,s)),0===r.length&&(s.pause(),s.src=""),s.onerror=null,this._logger.info(he.L_RTC_CLIENT_CREATE_LOCAL_FILE_TRACKS_O,JSON.stringify({status:ge.SUCCESSED,trackIds:r.map(e=>e.getTrackId())})),t({code:ue.SUCCESS,tracks:r})},s.onerror=()=>{this._logger.error(he.L_RTC_CLIENT_CREATE_LOCAL_FILE_TRACKS_O,JSON.stringify({status:ge.FAILED,code:ue.CREATE_FILE_TRACK_FAILED,msg:"Failed to create file stream, video onerror"})),t({code:ue.CREATE_FILE_TRACK_FAILED,tracks:[]})},s.src=r.url,s.loop=!0,s.play()})})}createLocalTracks(e,t,i){return I(this,void 0,void 0,function*(){const r=[];if(!_i(e))return this._logger.error(he.L_RTC_CLIENT_CREATE_LOCAL_TRACKS_O,JSON.stringify({status:ge.FAILED,code:ue.INVALID_TAGS,msg:"invalid tag"})),{code:ue.INVALID_TAGS,tracks:r};if(!(t instanceof MediaStream))return this._logger.error(he.L_RTC_CLIENT_CREATE_LOCAL_TRACKS_O,JSON.stringify({status:ge.FAILED,code:ue.PARAMS_ERROR,msg:"params error -> stream"})),{code:ue.PARAMS_ERROR,tracks:r};const n=this._context.getCurrentId();if(!n)return this._logger.error(he.L_RTC_CLIENT_CREATE_LOCAL_TRACKS_O,JSON.stringify({status:ge.FAILED,code:ue.INVALID_USER_ID,msg:"invalid IM connection,invalid userId"})),{code:ue.INVALID_USER_ID,tracks:r};const[s,o]=Ll.getTracksWithOptions(t,i);return s&&r.push(new qt(this._logger,e,n,s)),o&&r.push(new Wt(this._logger,e,n,o)),this._logger.info(he.L_RTC_CLIENT_CREATE_LOCAL_TRACKS_O,JSON.stringify({status:ge.SUCCESSED,trackIds:r.map(e=>e.getTrackId())})),{code:ue.SUCCESS,tracks:r}})}static getTracksWithOptions(e,t){const i=[];return i[0]=(null==t?void 0:t.withoutAudio)?void 0:e.getAudioTracks()[0],i[1]=(null==t?void 0:t.withoutVideo)?void 0:e.getVideoTracks()[0],i}_applyVideoAspectRatio(e,t,i){return I(this,void 0,void 0,function*(){const{width:r,height:n}=e.getSettings();if(r===t&&n===i)return;const s=t/i>=1?{width:{ideal:r,max:r}}:{height:{ideal:n,max:n}};try{yield e.applyConstraints(Object.assign(Object.assign({},s),{aspectRatio:{ideal:t/i}})),this._logger.info(he.L_RTC_CLIENT_APPLY_VIDEO_ASPECT_RATIO_O,JSON.stringify({status:ge.SUCCESSED,msg:`apply aspectRatio success -> ${t} / ${i}`}))}catch(e){this._logger.warn(he.L_RTC_CLIENT_APPLY_VIDEO_ASPECT_RATIO_O,JSON.stringify({status:ge.FAILED,msg:`apply aspectRatio error -> ${JSON.stringify(e)}`}))}})}}const Ol=function(){var e,t={},i=function(e){var t=function(e,i,n){if(void 0===e&&(e=t.DEFAULT_CAPACITY),void 0===i&&(i=t.DEFAULT_ENDIAN),void 0===n&&(n=t.DEFAULT_NOASSERT),!n){if((e|=0)<0)throw RangeError("Illegal capacity");i=!!i,n=!!n}this.buffer=0===e?r:new ArrayBuffer(e),this.view=0===e?null:new Uint8Array(this.buffer),this.offset=0,this.markedOffset=-1,this.limit=e,this.littleEndian=i,this.noAssert=n};t.VERSION="5.0.1",t.LITTLE_ENDIAN=!0,t.BIG_ENDIAN=!1,t.DEFAULT_CAPACITY=16,t.DEFAULT_ENDIAN=t.BIG_ENDIAN,t.DEFAULT_NOASSERT=!1,t.Long=e||null;var i=t.prototype;i.__isByteBuffer__,Object.defineProperty(i,"__isByteBuffer__",{value:!0,enumerable:!1,configurable:!1});var r=new ArrayBuffer(0),n=String.fromCharCode;function s(e){var t=0;return function(){return t<e.length?e.charCodeAt(t++):null}}function o(){var e=[],t=[];return function(){if(0===arguments.length)return t.join("")+n.apply(String,e);e.length+arguments.length>1024&&(t.push(n.apply(String,e)),e.length=0),Array.prototype.push.apply(e,arguments)}}function a(e,t,i,r,n){var s,o,a=8*n-r-1,l=(1<<a)-1,_=l>>1,c=-7,d=i?n-1:0,u=i?-1:1,h=e[t+d];for(d+=u,s=h&(1<<-c)-1,h>>=-c,c+=a;c>0;s=256*s+e[t+d],d+=u,c-=8);for(o=s&(1<<-c)-1,s>>=-c,c+=r;c>0;o=256*o+e[t+d],d+=u,c-=8);if(0===s)s=1-_;else{if(s===l)return o?NaN:1/0*(h?-1:1);o+=Math.pow(2,r),s-=_}return(h?-1:1)*o*Math.pow(2,s-r)}function l(e,t,i,r,n,s){var o,a,l,_=8*s-n-1,c=(1<<_)-1,d=c>>1,u=23===n?Math.pow(2,-24)-Math.pow(2,-77):0,h=r?0:s-1,g=r?1:-1,p=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,o=c):(o=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-o))<1&&(o--,l*=2),(t+=o+d>=1?u/l:u*Math.pow(2,1-d))*l>=2&&(o++,l/=2),o+d>=c?(a=0,o=c):o+d>=1?(a=(t*l-1)*Math.pow(2,n),o+=d):(a=t*Math.pow(2,d-1)*Math.pow(2,n),o=0));n>=8;e[i+h]=255&a,h+=g,a/=256,n-=8);for(o=o<<n|a,_+=n;_>0;e[i+h]=255&o,h+=g,o/=256,_-=8);e[i+h-g]|=128*p}t.accessor=function(){return Uint8Array},t.allocate=function(e,i,r){return new t(e,i,r)},t.concat=function(e,i,r,n){"boolean"!=typeof i&&"string"==typeof i||(n=r,r=i,i=void 0);for(var s,o=0,a=0,l=e.length;a<l;++a)t.isByteBuffer(e[a])||(e[a]=t.wrap(e[a],i)),(s=e[a].limit-e[a].offset)>0&&(o+=s);if(0===o)return new t(0,r,n);var _,c=new t(o,r,n);for(a=0;a<l;)(s=(_=e[a++]).limit-_.offset)<=0||(c.view.set(_.view.subarray(_.offset,_.limit),c.offset),c.offset+=s);return c.limit=c.offset,c.offset=0,c},t.isByteBuffer=function(e){return!0===(e&&e.__isByteBuffer__)},t.type=function(){return ArrayBuffer},t.wrap=function(e,r,n,s){if("string"!=typeof r&&(s=n,n=r,r=void 0),"string"==typeof e)switch(void 0===r&&(r="utf8"),r){case"base64":return t.fromBase64(e,n);case"hex":return t.fromHex(e,n);case"binary":return t.fromBinary(e,n);case"utf8":return t.fromUTF8(e,n);case"debug":return t.fromDebug(e,n);default:throw Error("Unsupported encoding: "+r)}if(null===e||"object"!=typeof e)throw TypeError("Illegal buffer");var o;if(t.isByteBuffer(e))return(o=i.clone.call(e)).markedOffset=-1,o;if(e instanceof Uint8Array)o=new t(0,n,s),e.length>0&&(o.buffer=e.buffer,o.offset=e.byteOffset,o.limit=e.byteOffset+e.byteLength,o.view=new Uint8Array(e.buffer));else if(e instanceof ArrayBuffer)o=new t(0,n,s),e.byteLength>0&&(o.buffer=e,o.offset=0,o.limit=e.byteLength,o.view=e.byteLength>0?new Uint8Array(e):null);else{if("[object Array]"!==Object.prototype.toString.call(e))throw TypeError("Illegal buffer");(o=new t(e.length,n,s)).limit=e.length;for(var a=0;a<e.length;++a)o.view[a]=e[a]}return o},i.writeBitSet=function(e,t){var i=void 0===t;if(i&&(t=this.offset),!this.noAssert){if(!(e instanceof Array))throw TypeError("Illegal BitSet: Not an array");if("number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: "+t+" (not an integer)");if((t>>>=0)<0||t+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+0) <= "+this.buffer.byteLength)}var r,n=t,s=e.length,o=s>>3,a=0;for(t+=this.writeVarint32(s,t);o--;)r=1&!!e[a++]|(1&!!e[a++])<<1|(1&!!e[a++])<<2|(1&!!e[a++])<<3|(1&!!e[a++])<<4|(1&!!e[a++])<<5|(1&!!e[a++])<<6|(1&!!e[a++])<<7,this.writeByte(r,t++);if(a<s){var l=0;for(r=0;a<s;)r|=(1&!!e[a++])<<l++;this.writeByte(r,t++)}return i?(this.offset=t,this):t-n},i.readBitSet=function(e){var t=void 0===e;t&&(e=this.offset);var i,r=this.readVarint32(e),n=r.value,s=n>>3,o=0,a=[];for(e+=r.length;s--;)i=this.readByte(e++),a[o++]=!!(1&i),a[o++]=!!(2&i),a[o++]=!!(4&i),a[o++]=!!(8&i),a[o++]=!!(16&i),a[o++]=!!(32&i),a[o++]=!!(64&i),a[o++]=!!(128&i);if(o<n){var l=0;for(i=this.readByte(e++);o<n;)a[o++]=!!(i>>l++&1)}return t&&(this.offset=e),a},i.readBytes=function(e,t){var i=void 0===t;if(i&&(t=this.offset),!this.noAssert){if("number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: "+t+" (not an integer)");if((t>>>=0)<0||t+e>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+"+e+") <= "+this.buffer.byteLength)}var r=this.slice(t,t+e);return i&&(this.offset+=e),r},i.writeBytes=i.append,i.writeInt8=function(e,t){var i=void 0===t;if(i&&(t=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal value: "+e+" (not an integer)");if(e|=0,"number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: "+t+" (not an integer)");if((t>>>=0)<0||t+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+0) <= "+this.buffer.byteLength)}t+=1;var r=this.buffer.byteLength;return t>r&&this.resize((r*=2)>t?r:t),t-=1,this.view[t]=e,i&&(this.offset+=1),this},i.writeByte=i.writeInt8,i.readInt8=function(e){var t=void 0===e;if(t&&(e=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal offset: "+e+" (not an integer)");if((e>>>=0)<0||e+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+e+" (+1) <= "+this.buffer.byteLength)}var i=this.view[e];return 128&~i||(i=-(255-i+1)),t&&(this.offset+=1),i},i.readByte=i.readInt8,i.writeUint8=function(e,t){var i=void 0===t;if(i&&(t=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal value: "+e+" (not an integer)");if(e>>>=0,"number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: "+t+" (not an integer)");if((t>>>=0)<0||t+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+0) <= "+this.buffer.byteLength)}t+=1;var r=this.buffer.byteLength;return t>r&&this.resize((r*=2)>t?r:t),t-=1,this.view[t]=e,i&&(this.offset+=1),this},i.writeUInt8=i.writeUint8,i.readUint8=function(e){var t=void 0===e;if(t&&(e=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal offset: "+e+" (not an integer)");if((e>>>=0)<0||e+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+e+" (+1) <= "+this.buffer.byteLength)}var i=this.view[e];return t&&(this.offset+=1),i},i.readUInt8=i.readUint8,i.writeInt16=function(e,t){var i=void 0===t;if(i&&(t=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal value: "+e+" (not an integer)");if(e|=0,"number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: "+t+" (not an integer)");if((t>>>=0)<0||t+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+0) <= "+this.buffer.byteLength)}t+=2;var r=this.buffer.byteLength;return t>r&&this.resize((r*=2)>t?r:t),t-=2,this.littleEndian?(this.view[t+1]=(65280&e)>>>8,this.view[t]=255&e):(this.view[t]=(65280&e)>>>8,this.view[t+1]=255&e),i&&(this.offset+=2),this},i.writeShort=i.writeInt16,i.readInt16=function(e){var t=void 0===e;if(t&&(e=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal offset: "+e+" (not an integer)");if((e>>>=0)<0||e+2>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+e+" (+2) <= "+this.buffer.byteLength)}var i=0;return this.littleEndian?(i=this.view[e],i|=this.view[e+1]<<8):(i=this.view[e]<<8,i|=this.view[e+1]),32768&~i||(i=-(65535-i+1)),t&&(this.offset+=2),i},i.readShort=i.readInt16,i.writeUint16=function(e,t){var i=void 0===t;if(i&&(t=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal value: "+e+" (not an integer)");if(e>>>=0,"number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: "+t+" (not an integer)");if((t>>>=0)<0||t+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+0) <= "+this.buffer.byteLength)}t+=2;var r=this.buffer.byteLength;return t>r&&this.resize((r*=2)>t?r:t),t-=2,this.littleEndian?(this.view[t+1]=(65280&e)>>>8,this.view[t]=255&e):(this.view[t]=(65280&e)>>>8,this.view[t+1]=255&e),i&&(this.offset+=2),this},i.writeUInt16=i.writeUint16,i.readUint16=function(e){var t=void 0===e;if(t&&(e=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal offset: "+e+" (not an integer)");if((e>>>=0)<0||e+2>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+e+" (+2) <= "+this.buffer.byteLength)}var i=0;return this.littleEndian?(i=this.view[e],i|=this.view[e+1]<<8):(i=this.view[e]<<8,i|=this.view[e+1]),t&&(this.offset+=2),i},i.readUInt16=i.readUint16,i.writeInt32=function(e,t){var i=void 0===t;if(i&&(t=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal value: "+e+" (not an integer)");if(e|=0,"number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: "+t+" (not an integer)");if((t>>>=0)<0||t+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+0) <= "+this.buffer.byteLength)}t+=4;var r=this.buffer.byteLength;return t>r&&this.resize((r*=2)>t?r:t),t-=4,this.littleEndian?(this.view[t+3]=e>>>24&255,this.view[t+2]=e>>>16&255,this.view[t+1]=e>>>8&255,this.view[t]=255&e):(this.view[t]=e>>>24&255,this.view[t+1]=e>>>16&255,this.view[t+2]=e>>>8&255,this.view[t+3]=255&e),i&&(this.offset+=4),this},i.writeInt=i.writeInt32,i.readInt32=function(e){var t=void 0===e;if(t&&(e=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal offset: "+e+" (not an integer)");if((e>>>=0)<0||e+4>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+e+" (+4) <= "+this.buffer.byteLength)}var i=0;return this.littleEndian?(i=this.view[e+2]<<16,i|=this.view[e+1]<<8,i|=this.view[e],i+=this.view[e+3]<<24>>>0):(i=this.view[e+1]<<16,i|=this.view[e+2]<<8,i|=this.view[e+3],i+=this.view[e]<<24>>>0),i|=0,t&&(this.offset+=4),i},i.readInt=i.readInt32,i.writeUint32=function(e,t){var i=void 0===t;if(i&&(t=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal value: "+e+" (not an integer)");if(e>>>=0,"number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: "+t+" (not an integer)");if((t>>>=0)<0||t+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+0) <= "+this.buffer.byteLength)}t+=4;var r=this.buffer.byteLength;return t>r&&this.resize((r*=2)>t?r:t),t-=4,this.littleEndian?(this.view[t+3]=e>>>24&255,this.view[t+2]=e>>>16&255,this.view[t+1]=e>>>8&255,this.view[t]=255&e):(this.view[t]=e>>>24&255,this.view[t+1]=e>>>16&255,this.view[t+2]=e>>>8&255,this.view[t+3]=255&e),i&&(this.offset+=4),this},i.writeUInt32=i.writeUint32,i.readUint32=function(e){var t=void 0===e;if(t&&(e=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal offset: "+e+" (not an integer)");if((e>>>=0)<0||e+4>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+e+" (+4) <= "+this.buffer.byteLength)}var i=0;return this.littleEndian?(i=this.view[e+2]<<16,i|=this.view[e+1]<<8,i|=this.view[e],i+=this.view[e+3]<<24>>>0):(i=this.view[e+1]<<16,i|=this.view[e+2]<<8,i|=this.view[e+3],i+=this.view[e]<<24>>>0),t&&(this.offset+=4),i},i.readUInt32=i.readUint32,e&&(i.writeInt64=function(t,i){var r=void 0===i;if(r&&(i=this.offset),!this.noAssert){if("number"==typeof t)t=e.fromNumber(t);else if("string"==typeof t)t=e.fromString(t);else if(!(t&&t instanceof e))throw TypeError("Illegal value: "+t+" (not an integer or Long)");if("number"!=typeof i||i%1!=0)throw TypeError("Illegal offset: "+i+" (not an integer)");if((i>>>=0)<0||i+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+i+" (+0) <= "+this.buffer.byteLength)}"number"==typeof t?t=e.fromNumber(t):"string"==typeof t&&(t=e.fromString(t)),i+=8;var n=this.buffer.byteLength;i>n&&this.resize((n*=2)>i?n:i),i-=8;var s=t.low,o=t.high;return this.littleEndian?(this.view[i+3]=s>>>24&255,this.view[i+2]=s>>>16&255,this.view[i+1]=s>>>8&255,this.view[i]=255&s,i+=4,this.view[i+3]=o>>>24&255,this.view[i+2]=o>>>16&255,this.view[i+1]=o>>>8&255,this.view[i]=255&o):(this.view[i]=o>>>24&255,this.view[i+1]=o>>>16&255,this.view[i+2]=o>>>8&255,this.view[i+3]=255&o,i+=4,this.view[i]=s>>>24&255,this.view[i+1]=s>>>16&255,this.view[i+2]=s>>>8&255,this.view[i+3]=255&s),r&&(this.offset+=8),this},i.writeLong=i.writeInt64,i.readInt64=function(t){var i=void 0===t;if(i&&(t=this.offset),!this.noAssert){if("number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: "+t+" (not an integer)");if((t>>>=0)<0||t+8>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+8) <= "+this.buffer.byteLength)}var r=0,n=0;this.littleEndian?(r=this.view[t+2]<<16,r|=this.view[t+1]<<8,r|=this.view[t],r+=this.view[t+3]<<24>>>0,t+=4,n=this.view[t+2]<<16,n|=this.view[t+1]<<8,n|=this.view[t],n+=this.view[t+3]<<24>>>0):(n=this.view[t+1]<<16,n|=this.view[t+2]<<8,n|=this.view[t+3],n+=this.view[t]<<24>>>0,t+=4,r=this.view[t+1]<<16,r|=this.view[t+2]<<8,r|=this.view[t+3],r+=this.view[t]<<24>>>0);var s=new e(r,n,!1);return i&&(this.offset+=8),s},i.readLong=i.readInt64,i.writeUint64=function(t,i){var r=void 0===i;if(r&&(i=this.offset),!this.noAssert){if("number"==typeof t)t=e.fromNumber(t);else if("string"==typeof t)t=e.fromString(t);else if(!(t&&t instanceof e))throw TypeError("Illegal value: "+t+" (not an integer or Long)");if("number"!=typeof i||i%1!=0)throw TypeError("Illegal offset: "+i+" (not an integer)");if((i>>>=0)<0||i+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+i+" (+0) <= "+this.buffer.byteLength)}"number"==typeof t?t=e.fromNumber(t):"string"==typeof t&&(t=e.fromString(t)),i+=8;var n=this.buffer.byteLength;i>n&&this.resize((n*=2)>i?n:i),i-=8;var s=t.low,o=t.high;return this.littleEndian?(this.view[i+3]=s>>>24&255,this.view[i+2]=s>>>16&255,this.view[i+1]=s>>>8&255,this.view[i]=255&s,i+=4,this.view[i+3]=o>>>24&255,this.view[i+2]=o>>>16&255,this.view[i+1]=o>>>8&255,this.view[i]=255&o):(this.view[i]=o>>>24&255,this.view[i+1]=o>>>16&255,this.view[i+2]=o>>>8&255,this.view[i+3]=255&o,i+=4,this.view[i]=s>>>24&255,this.view[i+1]=s>>>16&255,this.view[i+2]=s>>>8&255,this.view[i+3]=255&s),r&&(this.offset+=8),this},i.writeUInt64=i.writeUint64,i.readUint64=function(t){var i=void 0===t;if(i&&(t=this.offset),!this.noAssert){if("number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: "+t+" (not an integer)");if((t>>>=0)<0||t+8>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+8) <= "+this.buffer.byteLength)}var r=0,n=0;this.littleEndian?(r=this.view[t+2]<<16,r|=this.view[t+1]<<8,r|=this.view[t],r+=this.view[t+3]<<24>>>0,t+=4,n=this.view[t+2]<<16,n|=this.view[t+1]<<8,n|=this.view[t],n+=this.view[t+3]<<24>>>0):(n=this.view[t+1]<<16,n|=this.view[t+2]<<8,n|=this.view[t+3],n+=this.view[t]<<24>>>0,t+=4,r=this.view[t+1]<<16,r|=this.view[t+2]<<8,r|=this.view[t+3],r+=this.view[t]<<24>>>0);var s=new e(r,n,!0);return i&&(this.offset+=8),s},i.readUInt64=i.readUint64),i.writeFloat32=function(e,t){var i=void 0===t;if(i&&(t=this.offset),!this.noAssert){if("number"!=typeof e)throw TypeError("Illegal value: "+e+" (not a number)");if("number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: "+t+" (not an integer)");if((t>>>=0)<0||t+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+0) <= "+this.buffer.byteLength)}t+=4;var r=this.buffer.byteLength;return t>r&&this.resize((r*=2)>t?r:t),t-=4,l(this.view,e,t,this.littleEndian,23,4),i&&(this.offset+=4),this},i.writeFloat=i.writeFloat32,i.readFloat32=function(e){var t=void 0===e;if(t&&(e=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal offset: "+e+" (not an integer)");if((e>>>=0)<0||e+4>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+e+" (+4) <= "+this.buffer.byteLength)}var i=a(this.view,e,this.littleEndian,23,4);return t&&(this.offset+=4),i},i.readFloat=i.readFloat32,i.writeFloat64=function(e,t){var i=void 0===t;if(i&&(t=this.offset),!this.noAssert){if("number"!=typeof e)throw TypeError("Illegal value: "+e+" (not a number)");if("number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: "+t+" (not an integer)");if((t>>>=0)<0||t+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+0) <= "+this.buffer.byteLength)}t+=8;var r=this.buffer.byteLength;return t>r&&this.resize((r*=2)>t?r:t),t-=8,l(this.view,e,t,this.littleEndian,52,8),i&&(this.offset+=8),this},i.writeDouble=i.writeFloat64,i.readFloat64=function(e){var t=void 0===e;if(t&&(e=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal offset: "+e+" (not an integer)");if((e>>>=0)<0||e+8>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+e+" (+8) <= "+this.buffer.byteLength)}var i=a(this.view,e,this.littleEndian,52,8);return t&&(this.offset+=8),i},i.readDouble=i.readFloat64,t.MAX_VARINT32_BYTES=5,t.calculateVarint32=function(e){return(e>>>=0)<128?1:e<16384?2:e<1<<21?3:e<1<<28?4:5},t.zigZagEncode32=function(e){return((e|=0)<<1^e>>31)>>>0},t.zigZagDecode32=function(e){return e>>>1^-(1&e)},i.writeVarint32=function(e,i){var r=void 0===i;if(r&&(i=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal value: "+e+" (not an integer)");if(e|=0,"number"!=typeof i||i%1!=0)throw TypeError("Illegal offset: "+i+" (not an integer)");if((i>>>=0)<0||i+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+i+" (+0) <= "+this.buffer.byteLength)}var n,s=t.calculateVarint32(e);i+=s;var o=this.buffer.byteLength;for(i>o&&this.resize((o*=2)>i?o:i),i-=s,e>>>=0;e>=128;)n=127&e|128,this.view[i++]=n,e>>>=7;return this.view[i++]=e,r?(this.offset=i,this):s},i.writeVarint32ZigZag=function(e,i){return this.writeVarint32(t.zigZagEncode32(e),i)},i.readVarint32=function(e){var t=void 0===e;if(t&&(e=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal offset: "+e+" (not an integer)");if((e>>>=0)<0||e+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+e+" (+1) <= "+this.buffer.byteLength)}var i,r=0,n=0;do{if(!this.noAssert&&e>this.limit){var s=Error("Truncated");throw s.truncated=!0,s}i=this.view[e++],r<5&&(n|=(127&i)<<7*r),++r}while(128&i);return n|=0,t?(this.offset=e,n):{value:n,length:r}},i.readVarint32ZigZag=function(e){var i=this.readVarint32(e);return"object"==typeof i?i.value=t.zigZagDecode32(i.value):i=t.zigZagDecode32(i),i},e&&(t.MAX_VARINT64_BYTES=10,t.calculateVarint64=function(t){"number"==typeof t?t=e.fromNumber(t):"string"==typeof t&&(t=e.fromString(t));var i=t.toInt()>>>0,r=t.shiftRightUnsigned(28).toInt()>>>0,n=t.shiftRightUnsigned(56).toInt()>>>0;return 0==n?0==r?i<16384?i<128?1:2:i<1<<21?3:4:r<16384?r<128?5:6:r<1<<21?7:8:n<128?9:10},t.zigZagEncode64=function(t){return"number"==typeof t?t=e.fromNumber(t,!1):"string"==typeof t?t=e.fromString(t,!1):!1!==t.unsigned&&(t=t.toSigned()),t.shiftLeft(1).xor(t.shiftRight(63)).toUnsigned()},t.zigZagDecode64=function(t){return"number"==typeof t?t=e.fromNumber(t,!1):"string"==typeof t?t=e.fromString(t,!1):!1!==t.unsigned&&(t=t.toSigned()),t.shiftRightUnsigned(1).xor(t.and(e.ONE).toSigned().negate()).toSigned()},i.writeVarint64=function(i,r){var n=void 0===r;if(n&&(r=this.offset),!this.noAssert){if("number"==typeof i)i=e.fromNumber(i);else if("string"==typeof i)i=e.fromString(i);else if(!(i&&i instanceof e))throw TypeError("Illegal value: "+i+" (not an integer or Long)");if("number"!=typeof r||r%1!=0)throw TypeError("Illegal offset: "+r+" (not an integer)");if((r>>>=0)<0||r+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+r+" (+0) <= "+this.buffer.byteLength)}"number"==typeof i?i=e.fromNumber(i,!1):"string"==typeof i?i=e.fromString(i,!1):!1!==i.unsigned&&(i=i.toSigned());var s=t.calculateVarint64(i),o=i.toInt()>>>0,a=i.shiftRightUnsigned(28).toInt()>>>0,l=i.shiftRightUnsigned(56).toInt()>>>0;r+=s;var _=this.buffer.byteLength;switch(r>_&&this.resize((_*=2)>r?_:r),r-=s,s){case 10:this.view[r+9]=l>>>7&1;case 9:this.view[r+8]=9!==s?128|l:127&l;case 8:this.view[r+7]=8!==s?a>>>21|128:a>>>21&127;case 7:this.view[r+6]=7!==s?a>>>14|128:a>>>14&127;case 6:this.view[r+5]=6!==s?a>>>7|128:a>>>7&127;case 5:this.view[r+4]=5!==s?128|a:127&a;case 4:this.view[r+3]=4!==s?o>>>21|128:o>>>21&127;case 3:this.view[r+2]=3!==s?o>>>14|128:o>>>14&127;case 2:this.view[r+1]=2!==s?o>>>7|128:o>>>7&127;case 1:this.view[r]=1!==s?128|o:127&o}return n?(this.offset+=s,this):s},i.writeVarint64ZigZag=function(e,i){return this.writeVarint64(t.zigZagEncode64(e),i)},i.readVarint64=function(t){var i=void 0===t;if(i&&(t=this.offset),!this.noAssert){if("number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: "+t+" (not an integer)");if((t>>>=0)<0||t+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+1) <= "+this.buffer.byteLength)}var r=t,n=0,s=0,o=0,a=0;if(n=127&(a=this.view[t++]),128&a&&(n|=(127&(a=this.view[t++]))<<7,(128&a||this.noAssert&&void 0===a)&&(n|=(127&(a=this.view[t++]))<<14,(128&a||this.noAssert&&void 0===a)&&(n|=(127&(a=this.view[t++]))<<21,(128&a||this.noAssert&&void 0===a)&&(s=127&(a=this.view[t++]),(128&a||this.noAssert&&void 0===a)&&(s|=(127&(a=this.view[t++]))<<7,(128&a||this.noAssert&&void 0===a)&&(s|=(127&(a=this.view[t++]))<<14,(128&a||this.noAssert&&void 0===a)&&(s|=(127&(a=this.view[t++]))<<21,(128&a||this.noAssert&&void 0===a)&&(o=127&(a=this.view[t++]),(128&a||this.noAssert&&void 0===a)&&(o|=(127&(a=this.view[t++]))<<7,128&a||this.noAssert&&void 0===a))))))))))throw Error("Buffer overrun");var l=e.fromBits(n|s<<28,s>>>4|o<<24,!1);return i?(this.offset=t,l):{value:l,length:t-r}},i.readVarint64ZigZag=function(i){var r=this.readVarint64(i);return r&&r.value instanceof e?r.value=t.zigZagDecode64(r.value):r=t.zigZagDecode64(r),r}),i.writeCString=function(e,t){var i=void 0===t;i&&(t=this.offset);var r,n=e.length;if(!this.noAssert){if("string"!=typeof e)throw TypeError("Illegal str: Not a string");for(r=0;r<n;++r)if(0===e.charCodeAt(r))throw RangeError("Illegal str: Contains NULL-characters");if("number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: "+t+" (not an integer)");if((t>>>=0)<0||t+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+0) <= "+this.buffer.byteLength)}n=c.calculateUTF16asUTF8(s(e))[1],t+=n+1;var o=this.buffer.byteLength;return t>o&&this.resize((o*=2)>t?o:t),t-=n+1,c.encodeUTF16toUTF8(s(e),function(e){this.view[t++]=e}.bind(this)),this.view[t++]=0,i?(this.offset=t,this):n},i.readCString=function(e){var t=void 0===e;if(t&&(e=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal offset: "+e+" (not an integer)");if((e>>>=0)<0||e+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+e+" (+1) <= "+this.buffer.byteLength)}var i,r=e,n=-1;return c.decodeUTF8toUTF16(function(){if(0===n)return null;if(e>=this.limit)throw RangeError("Illegal range: Truncated data, "+e+" < "+this.limit);return 0===(n=this.view[e++])?null:n}.bind(this),i=o(),!0),t?(this.offset=e,i()):{string:i(),length:e-r}},i.writeIString=function(e,t){var i=void 0===t;if(i&&(t=this.offset),!this.noAssert){if("string"!=typeof e)throw TypeError("Illegal str: Not a string");if("number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: "+t+" (not an integer)");if((t>>>=0)<0||t+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+0) <= "+this.buffer.byteLength)}var r,n=t;r=c.calculateUTF16asUTF8(s(e),this.noAssert)[1],t+=4+r;var o=this.buffer.byteLength;if(t>o&&this.resize((o*=2)>t?o:t),t-=4+r,this.littleEndian?(this.view[t+3]=r>>>24&255,this.view[t+2]=r>>>16&255,this.view[t+1]=r>>>8&255,this.view[t]=255&r):(this.view[t]=r>>>24&255,this.view[t+1]=r>>>16&255,this.view[t+2]=r>>>8&255,this.view[t+3]=255&r),t+=4,c.encodeUTF16toUTF8(s(e),function(e){this.view[t++]=e}.bind(this)),t!==n+4+r)throw RangeError("Illegal range: Truncated data, "+t+" == "+(t+4+r));return i?(this.offset=t,this):t-n},i.readIString=function(e){var i=void 0===e;if(i&&(e=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal offset: "+e+" (not an integer)");if((e>>>=0)<0||e+4>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+e+" (+4) <= "+this.buffer.byteLength)}var r=e,n=this.readUint32(e),s=this.readUTF8String(n,t.METRICS_BYTES,e+=4);return e+=s.length,i?(this.offset=e,s.string):{string:s.string,length:e-r}},t.METRICS_CHARS="c",t.METRICS_BYTES="b",i.writeUTF8String=function(e,t){var i,r=void 0===t;if(r&&(t=this.offset),!this.noAssert){if("number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: "+t+" (not an integer)");if((t>>>=0)<0||t+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+0) <= "+this.buffer.byteLength)}var n=t;i=c.calculateUTF16asUTF8(s(e))[1],t+=i;var o=this.buffer.byteLength;return t>o&&this.resize((o*=2)>t?o:t),t-=i,c.encodeUTF16toUTF8(s(e),function(e){this.view[t++]=e}.bind(this)),r?(this.offset=t,this):t-n},i.writeString=i.writeUTF8String,t.calculateUTF8Chars=function(e){return c.calculateUTF16asUTF8(s(e))[0]},t.calculateUTF8Bytes=function(e){return c.calculateUTF16asUTF8(s(e))[1]},t.calculateString=t.calculateUTF8Bytes,i.readUTF8String=function(e,i,r){"number"==typeof i&&(r=i,i=void 0);var n=void 0===r;if(n&&(r=this.offset),void 0===i&&(i=t.METRICS_CHARS),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal length: "+e+" (not an integer)");if(e|=0,"number"!=typeof r||r%1!=0)throw TypeError("Illegal offset: "+r+" (not an integer)");if((r>>>=0)<0||r+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+r+" (+0) <= "+this.buffer.byteLength)}var s,a=0,l=r;if(i===t.METRICS_CHARS){if(s=o(),c.decodeUTF8(function(){return a<e&&r<this.limit?this.view[r++]:null}.bind(this),function(e){++a,c.UTF8toUTF16(e,s)}),a!==e)throw RangeError("Illegal range: Truncated data, "+a+" == "+e);return n?(this.offset=r,s()):{string:s(),length:r-l}}if(i===t.METRICS_BYTES){if(!this.noAssert){if("number"!=typeof r||r%1!=0)throw TypeError("Illegal offset: "+r+" (not an integer)");if((r>>>=0)<0||r+e>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+r+" (+"+e+") <= "+this.buffer.byteLength)}var _=r+e;if(c.decodeUTF8toUTF16(function(){return r<_?this.view[r++]:null}.bind(this),s=o(),this.noAssert),r!==_)throw RangeError("Illegal range: Truncated data, "+r+" == "+_);return n?(this.offset=r,s()):{string:s(),length:r-l}}throw TypeError("Unsupported metrics: "+i)},i.readString=i.readUTF8String,i.writeVString=function(e,i){var r=void 0===i;if(r&&(i=this.offset),!this.noAssert){if("string"!=typeof e)throw TypeError("Illegal str: Not a string");if("number"!=typeof i||i%1!=0)throw TypeError("Illegal offset: "+i+" (not an integer)");if((i>>>=0)<0||i+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+i+" (+0) <= "+this.buffer.byteLength)}var n,o,a=i;n=c.calculateUTF16asUTF8(s(e),this.noAssert)[1],o=t.calculateVarint32(n),i+=o+n;var l=this.buffer.byteLength;if(i>l&&this.resize((l*=2)>i?l:i),i-=o+n,i+=this.writeVarint32(n,i),c.encodeUTF16toUTF8(s(e),function(e){this.view[i++]=e}.bind(this)),i!==a+n+o)throw RangeError("Illegal range: Truncated data, "+i+" == "+(i+n+o));return r?(this.offset=i,this):i-a},i.readVString=function(e){var i=void 0===e;if(i&&(e=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal offset: "+e+" (not an integer)");if((e>>>=0)<0||e+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+e+" (+1) <= "+this.buffer.byteLength)}var r=e,n=this.readVarint32(e),s=this.readUTF8String(n.value,t.METRICS_BYTES,e+=n.length);return e+=s.length,i?(this.offset=e,s.string):{string:s.string,length:e-r}},i.append=function(e,i,r){"number"!=typeof i&&"string"==typeof i||(r=i,i=void 0);var n=void 0===r;if(n&&(r=this.offset),!this.noAssert){if("number"!=typeof r||r%1!=0)throw TypeError("Illegal offset: "+r+" (not an integer)");if((r>>>=0)<0||r+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+r+" (+0) <= "+this.buffer.byteLength)}e instanceof t||(e=t.wrap(e,i));var s=e.limit-e.offset;if(s<=0)return this;r+=s;var o=this.buffer.byteLength;return r>o&&this.resize((o*=2)>r?o:r),r-=s,this.view.set(e.view.subarray(e.offset,e.limit),r),e.offset+=s,n&&(this.offset+=s),this},i.appendTo=function(e,t){return e.append(this,t),this},i.assert=function(e){return this.noAssert=!e,this},i.capacity=function(){return this.buffer.byteLength},i.clear=function(){return this.offset=0,this.limit=this.buffer.byteLength,this.markedOffset=-1,this},i.clone=function(e){var i=new t(0,this.littleEndian,this.noAssert);return e?(i.buffer=new ArrayBuffer(this.buffer.byteLength),i.view=new Uint8Array(i.buffer)):(i.buffer=this.buffer,i.view=this.view),i.offset=this.offset,i.markedOffset=this.markedOffset,i.limit=this.limit,i},i.compact=function(e,t){if(void 0===e&&(e=this.offset),void 0===t&&(t=this.limit),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal begin: Not an integer");if(e>>>=0,"number"!=typeof t||t%1!=0)throw TypeError("Illegal end: Not an integer");if(t>>>=0,e<0||e>t||t>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+e+" <= "+t+" <= "+this.buffer.byteLength)}if(0===e&&t===this.buffer.byteLength)return this;var i=t-e;if(0===i)return this.buffer=r,this.view=null,this.markedOffset>=0&&(this.markedOffset-=e),this.offset=0,this.limit=0,this;var n=new ArrayBuffer(i),s=new Uint8Array(n);return s.set(this.view.subarray(e,t)),this.buffer=n,this.view=s,this.markedOffset>=0&&(this.markedOffset-=e),this.offset=0,this.limit=i,this},i.copy=function(e,i){if(void 0===e&&(e=this.offset),void 0===i&&(i=this.limit),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal begin: Not an integer");if(e>>>=0,"number"!=typeof i||i%1!=0)throw TypeError("Illegal end: Not an integer");if(i>>>=0,e<0||e>i||i>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+e+" <= "+i+" <= "+this.buffer.byteLength)}if(e===i)return new t(0,this.littleEndian,this.noAssert);var r=i-e,n=new t(r,this.littleEndian,this.noAssert);return n.offset=0,n.limit=r,n.markedOffset>=0&&(n.markedOffset-=e),this.copyTo(n,0,e,i),n},i.copyTo=function(e,i,r,n){var s,o;if(!this.noAssert&&!t.isByteBuffer(e))throw TypeError("Illegal target: Not a ByteBuffer");if(i=(o=void 0===i)?e.offset:0|i,r=(s=void 0===r)?this.offset:0|r,n=void 0===n?this.limit:0|n,i<0||i>e.buffer.byteLength)throw RangeError("Illegal target range: 0 <= "+i+" <= "+e.buffer.byteLength);if(r<0||n>this.buffer.byteLength)throw RangeError("Illegal source range: 0 <= "+r+" <= "+this.buffer.byteLength);var a=n-r;return 0===a?e:(e.ensureCapacity(i+a),e.view.set(this.view.subarray(r,n),i),s&&(this.offset+=a),o&&(e.offset+=a),this)},i.ensureCapacity=function(e){var t=this.buffer.byteLength;return t<e?this.resize((t*=2)>e?t:e):this},i.fill=function(e,t,i){var r=void 0===t;if(r&&(t=this.offset),"string"==typeof e&&e.length>0&&(e=e.charCodeAt(0)),void 0===t&&(t=this.offset),void 0===i&&(i=this.limit),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal value: "+e+" (not an integer)");if(e|=0,"number"!=typeof t||t%1!=0)throw TypeError("Illegal begin: Not an integer");if(t>>>=0,"number"!=typeof i||i%1!=0)throw TypeError("Illegal end: Not an integer");if(i>>>=0,t<0||t>i||i>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+t+" <= "+i+" <= "+this.buffer.byteLength)}if(t>=i)return this;for(;t<i;)this.view[t++]=e;return r&&(this.offset=t),this},i.flip=function(){return this.limit=this.offset,this.offset=0,this},i.mark=function(e){if(e=void 0===e?this.offset:e,!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal offset: "+e+" (not an integer)");if((e>>>=0)<0||e+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+e+" (+0) <= "+this.buffer.byteLength)}return this.markedOffset=e,this},i.order=function(e){if(!this.noAssert&&"boolean"!=typeof e)throw TypeError("Illegal littleEndian: Not a boolean");return this.littleEndian=!!e,this},i.LE=function(e){return this.littleEndian=void 0===e||!!e,this},i.BE=function(e){return this.littleEndian=void 0!==e&&!e,this},i.prepend=function(e,i,r){"number"!=typeof i&&"string"==typeof i||(r=i,i=void 0);var n=void 0===r;if(n&&(r=this.offset),!this.noAssert){if("number"!=typeof r||r%1!=0)throw TypeError("Illegal offset: "+r+" (not an integer)");if((r>>>=0)<0||r+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+r+" (+0) <= "+this.buffer.byteLength)}e instanceof t||(e=t.wrap(e,i));var s=e.limit-e.offset;if(s<=0)return this;var o=s-r;if(o>0){var a=new ArrayBuffer(this.buffer.byteLength+o),l=new Uint8Array(a);l.set(this.view.subarray(r,this.buffer.byteLength),s),this.buffer=a,this.view=l,this.offset+=o,this.markedOffset>=0&&(this.markedOffset+=o),this.limit+=o,r+=o}else new Uint8Array(this.buffer);return this.view.set(e.view.subarray(e.offset,e.limit),r-s),e.offset=e.limit,n&&(this.offset-=s),this},i.prependTo=function(e,t){return e.prepend(this,t),this},i.printDebug=function(e){"function"!=typeof e&&(e=console.log.bind(console)),e(this.toString()+"\n-------------------------------------------------------------------\n"+this.toDebug(!0))},i.remaining=function(){return this.limit-this.offset},i.reset=function(){return this.markedOffset>=0?(this.offset=this.markedOffset,this.markedOffset=-1):this.offset=0,this},i.resize=function(e){if(!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal capacity: "+e+" (not an integer)");if((e|=0)<0)throw RangeError("Illegal capacity: 0 <= "+e)}if(this.buffer.byteLength<e){var t=new ArrayBuffer(e),i=new Uint8Array(t);i.set(this.view),this.buffer=t,this.view=i}return this},i.reverse=function(e,t){if(void 0===e&&(e=this.offset),void 0===t&&(t=this.limit),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal begin: Not an integer");if(e>>>=0,"number"!=typeof t||t%1!=0)throw TypeError("Illegal end: Not an integer");if(t>>>=0,e<0||e>t||t>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+e+" <= "+t+" <= "+this.buffer.byteLength)}return e===t||Array.prototype.reverse.call(this.view.subarray(e,t)),this},i.skip=function(e){if(!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal length: "+e+" (not an integer)");e|=0}var t=this.offset+e;if(!this.noAssert&&(t<0||t>this.buffer.byteLength))throw RangeError("Illegal length: 0 <= "+this.offset+" + "+e+" <= "+this.buffer.byteLength);return this.offset=t,this},i.slice=function(e,t){if(void 0===e&&(e=this.offset),void 0===t&&(t=this.limit),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal begin: Not an integer");if(e>>>=0,"number"!=typeof t||t%1!=0)throw TypeError("Illegal end: Not an integer");if(t>>>=0,e<0||e>t||t>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+e+" <= "+t+" <= "+this.buffer.byteLength)}var i=this.clone();return i.offset=e,i.limit=t,i},i.toBuffer=function(e){var t=this.offset,i=this.limit;if(!this.noAssert){if("number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: Not an integer");if(t>>>=0,"number"!=typeof i||i%1!=0)throw TypeError("Illegal limit: Not an integer");if(i>>>=0,t<0||t>i||i>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+t+" <= "+i+" <= "+this.buffer.byteLength)}if(!e&&0===t&&i===this.buffer.byteLength)return this.buffer;if(t===i)return r;var n=new ArrayBuffer(i-t);return new Uint8Array(n).set(new Uint8Array(this.buffer).subarray(t,i),0),n},i.toArrayBuffer=i.toBuffer,i.toString=function(e,t,i){if(void 0===e)return"ByteBufferAB(offset="+this.offset+",markedOffset="+this.markedOffset+",limit="+this.limit+",capacity="+this.capacity()+")";switch("number"==typeof e&&(i=t=e="utf8"),e){case"utf8":return this.toUTF8(t,i);case"base64":return this.toBase64(t,i);case"hex":return this.toHex(t,i);case"binary":return this.toBinary(t,i);case"debug":return this.toDebug();case"columns":return this.toColumns();default:throw Error("Unsupported encoding: "+e)}};var _=function(){for(var e={},t=[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],i=[],r=0,n=t.length;r<n;++r)i[t[r]]=r;return e.encode=function(e,i){for(var r,n;null!==(r=e());)i(t[r>>2&63]),n=(3&r)<<4,null!==(r=e())?(i(t[63&((n|=r>>4&15)|r>>4&15)]),n=(15&r)<<2,null!==(r=e())?(i(t[63&(n|r>>6&3)]),i(t[63&r])):(i(t[63&n]),i(61))):(i(t[63&n]),i(61),i(61))},e.decode=function(e,t){var r,n,s;function o(e){throw Error("Illegal character code: "+e)}for(;null!==(r=e());)if(void 0===(n=i[r])&&o(r),null!==(r=e())&&(void 0===(s=i[r])&&o(r),t(n<<2>>>0|(48&s)>>4),null!==(r=e()))){if(void 0===(n=i[r])){if(61===r)break;o(r)}if(t((15&s)<<4>>>0|(60&n)>>2),null!==(r=e())){if(void 0===(s=i[r])){if(61===r)break;o(r)}t((3&n)<<6>>>0|s)}}},e.test=function(e){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(e)},e}();i.toBase64=function(e,t){if(void 0===e&&(e=this.offset),void 0===t&&(t=this.limit),t|=0,(e|=0)<0||t>this.capacity||e>t)throw RangeError("begin, end");var i;return _.encode(function(){return e<t?this.view[e++]:null}.bind(this),i=o()),i()},t.fromBase64=function(e,i){if("string"!=typeof e)throw TypeError("str");var r=new t(e.length/4*3,i),n=0;return _.decode(s(e),function(e){r.view[n++]=e}),r.limit=n,r},t.btoa=function(e){return t.fromBinary(e).toBase64()},t.atob=function(e){return t.fromBase64(e).toBinary()},i.toBinary=function(e,t){if(void 0===e&&(e=this.offset),void 0===t&&(t=this.limit),t|=0,(e|=0)<0||t>this.capacity()||e>t)throw RangeError("begin, end");if(e===t)return"";for(var i=[],r=[];e<t;)i.push(this.view[e++]),i.length>=1024&&(r.push(String.fromCharCode.apply(String,i)),i=[]);return r.join("")+String.fromCharCode.apply(String,i)},t.fromBinary=function(e,i){if("string"!=typeof e)throw TypeError("str");for(var r,n=0,s=e.length,o=new t(s,i);n<s;){if((r=e.charCodeAt(n))>255)throw RangeError("illegal char code: "+r);o.view[n++]=r}return o.limit=s,o},i.toDebug=function(e){for(var t,i=-1,r=this.buffer.byteLength,n="",s="",o="";i<r;){if(-1!==i&&(n+=(t=this.view[i])<16?"0"+t.toString(16).toUpperCase():t.toString(16).toUpperCase(),e&&(s+=t>32&&t<127?String.fromCharCode(t):".")),++i,e&&i>0&&i%16==0&&i!==r){for(;n.length<51;)n+=" ";o+=n+s+"\n",n=s=""}i===this.offset&&i===this.limit?n+=i===this.markedOffset?"!":"|":i===this.offset?n+=i===this.markedOffset?"[":"<":i===this.limit?n+=i===this.markedOffset?"]":">":n+=i===this.markedOffset?"'":e||0!==i&&i!==r?" ":""}if(e&&" "!==n){for(;n.length<51;)n+=" ";o+=n+s+"\n"}return e?o:n},t.fromDebug=function(e,i,r){for(var n,s,o=e.length,a=new t((o+1)/3|0,i,r),l=0,_=0,c=!1,d=!1,u=!1,h=!1,g=!1;l<o;){switch(n=e.charAt(l++)){case"!":if(!r){if(d||u||h){g=!0;break}d=u=h=!0}a.offset=a.markedOffset=a.limit=_,c=!1;break;case"|":if(!r){if(d||h){g=!0;break}d=h=!0}a.offset=a.limit=_,c=!1;break;case"[":if(!r){if(d||u){g=!0;break}d=u=!0}a.offset=a.markedOffset=_,c=!1;break;case"<":if(!r){if(d){g=!0;break}d=!0}a.offset=_,c=!1;break;case"]":if(!r){if(h||u){g=!0;break}h=u=!0}a.limit=a.markedOffset=_,c=!1;break;case">":if(!r){if(h){g=!0;break}h=!0}a.limit=_,c=!1;break;case"'":if(!r){if(u){g=!0;break}u=!0}a.markedOffset=_,c=!1;break;case" ":c=!1;break;default:if(!r&&c){g=!0;break}if(s=parseInt(n+e.charAt(l++),16),!r&&(isNaN(s)||s<0||s>255))throw TypeError("Illegal str: Not a debug encoded string");a.view[_++]=s,c=!0}if(g)throw TypeError("Illegal str: Invalid symbol at "+l)}if(!r){if(!d||!h)throw TypeError("Illegal str: Missing offset or limit");if(_<a.buffer.byteLength)throw TypeError("Illegal str: Not a debug encoded string (is it hex?) "+_+" < "+o)}return a},i.toHex=function(e,t){if(e=void 0===e?this.offset:e,t=void 0===t?this.limit:t,!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal begin: Not an integer");if(e>>>=0,"number"!=typeof t||t%1!=0)throw TypeError("Illegal end: Not an integer");if(t>>>=0,e<0||e>t||t>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+e+" <= "+t+" <= "+this.buffer.byteLength)}for(var i,r=new Array(t-e);e<t;)(i=this.view[e++])<16?r.push("0",i.toString(16)):r.push(i.toString(16));return r.join("")},t.fromHex=function(e,i,r){if(!r){if("string"!=typeof e)throw TypeError("Illegal str: Not a string");if(e.length%2!=0)throw TypeError("Illegal str: Length not a multiple of 2")}for(var n,s=e.length,o=new t(s/2|0,i),a=0,l=0;a<s;a+=2){if(n=parseInt(e.substring(a,a+2),16),!r&&(!isFinite(n)||n<0||n>255))throw TypeError("Illegal str: Contains non-hex characters");o.view[l++]=n}return o.limit=l,o};var c=function(){var e={MAX_CODEPOINT:1114111,encodeUTF8:function(e,t){var i=null;for("number"==typeof e&&(i=e,e=function(){return null});null!==i||null!==(i=e());)i<128?t(127&i):i<2048?(t(i>>6&31|192),t(63&i|128)):i<65536?(t(i>>12&15|224),t(i>>6&63|128),t(63&i|128)):(t(i>>18&7|240),t(i>>12&63|128),t(i>>6&63|128),t(63&i|128)),i=null},decodeUTF8:function(e,t){for(var i,r,n,s,o=function(e){e=e.slice(0,e.indexOf(null));var t=Error(e.toString());throw t.name="TruncatedError",t.bytes=e,t};null!==(i=e());)if(128&i)if(192==(224&i))null===(r=e())&&o([i,r]),t((31&i)<<6|63&r);else if(224==(240&i))(null===(r=e())||null===(n=e()))&&o([i,r,n]),t((15&i)<<12|(63&r)<<6|63&n);else{if(240!=(248&i))throw RangeError("Illegal starting byte: "+i);(null===(r=e())||null===(n=e())||null===(s=e()))&&o([i,r,n,s]),t((7&i)<<18|(63&r)<<12|(63&n)<<6|63&s)}else t(i)},UTF16toUTF8:function(e,t){for(var i,r=null;null!==(i=null!==r?r:e());)i>=55296&&i<=57343&&null!==(r=e())&&r>=56320&&r<=57343?(t(1024*(i-55296)+r-56320+65536),r=null):t(i);null!==r&&t(r)},UTF8toUTF16:function(e,t){var i=null;for("number"==typeof e&&(i=e,e=function(){return null});null!==i||null!==(i=e());)i<=65535?t(i):(t(55296+((i-=65536)>>10)),t(i%1024+56320)),i=null},encodeUTF16toUTF8:function(t,i){e.UTF16toUTF8(t,function(t){e.encodeUTF8(t,i)})},decodeUTF8toUTF16:function(t,i){e.decodeUTF8(t,function(t){e.UTF8toUTF16(t,i)})},calculateCodePoint:function(e){return e<128?1:e<2048?2:e<65536?3:4},calculateUTF8:function(e){for(var t,i=0;null!==(t=e());)i+=t<128?1:t<2048?2:t<65536?3:4;return i},calculateUTF16asUTF8:function(t){var i=0,r=0;return e.UTF16toUTF8(t,function(e){++i,r+=e<128?1:e<2048?2:e<65536?3:4}),[i,r]}};return e}();return i.toUTF8=function(e,t){if(void 0===e&&(e=this.offset),void 0===t&&(t=this.limit),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal begin: Not an integer");if(e>>>=0,"number"!=typeof t||t%1!=0)throw TypeError("Illegal end: Not an integer");if(t>>>=0,e<0||e>t||t>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+e+" <= "+t+" <= "+this.buffer.byteLength)}var i;try{c.decodeUTF8toUTF16(function(){return e<t?this.view[e++]:null}.bind(this),i=o())}catch(i){if(e!==t)throw RangeError("Illegal range: Truncated data, "+e+" != "+t)}return i()},t.fromUTF8=function(e,i,r){if(!r&&"string"!=typeof e)throw TypeError("Illegal str: Not a string");var n=new t(c.calculateUTF16asUTF8(s(e),!0)[1],i,r),o=0;return c.encodeUTF16toUTF8(s(e),function(e){n.view[o++]=e}),n.limit=o,n},t}(function(){function e(e,t,i){this.low=0|e,this.high=0|t,this.unsigned=!!i}function t(e){return!0===(e&&e.__isLong__)}e.prototype.__isLong__,Object.defineProperty(e.prototype,"__isLong__",{value:!0,enumerable:!1,configurable:!1}),e.isLong=t;var i={},r={};function n(e,t){var n,s,a;return t?(a=0<=(e>>>=0)&&e<256)&&(s=r[e])?s:(n=o(e,(0|e)<0?-1:0,!0),a&&(r[e]=n),n):(a=-128<=(e|=0)&&e<128)&&(s=i[e])?s:(n=o(e,e<0?-1:0,!1),a&&(i[e]=n),n)}function s(e,t){if(isNaN(e)||!isFinite(e))return t?p:g;if(t){if(e<0)return p;if(e>=d)return I}else{if(e<=-u)return R;if(e+1>=u)return m}return e<0?s(-e,t).neg():o(e%c|0,e/c|0,t)}function o(t,i,r){return new e(t,i,r)}e.fromInt=n,e.fromNumber=s,e.fromBits=o;var a=Math.pow;function l(e,t,i){if(0===e.length)throw Error("empty string");if("NaN"===e||"Infinity"===e||"+Infinity"===e||"-Infinity"===e)return g;if("number"==typeof t?(i=t,t=!1):t=!!t,(i=i||10)<2||36<i)throw RangeError("radix");var r;if((r=e.indexOf("-"))>0)throw Error("interior hyphen");if(0===r)return l(e.substring(1),t,i).neg();for(var n=s(a(i,8)),o=g,_=0;_<e.length;_+=8){var c=Math.min(8,e.length-_),d=parseInt(e.substring(_,_+c),i);if(c<8){var u=s(a(i,c));o=o.mul(u).add(s(d))}else o=(o=o.mul(n)).add(s(d))}return o.unsigned=t,o}function _(t){return t instanceof e?t:"number"==typeof t?s(t):"string"==typeof t?l(t):o(t.low,t.high,t.unsigned)}e.fromString=l,e.fromValue=_;var c=4294967296,d=c*c,u=d/2,h=n(1<<24),g=n(0);e.ZERO=g;var p=n(0,!0);e.UZERO=p;var f=n(1);e.ONE=f;var E=n(1,!0);e.UONE=E;var T=n(-1);e.NEG_ONE=T;var m=o(-1,2147483647,!1);e.MAX_VALUE=m;var I=o(-1,-1,!0);e.MAX_UNSIGNED_VALUE=I;var R=o(0,-2147483648,!1);e.MIN_VALUE=R;var S=e.prototype;return S.toInt=function(){return this.unsigned?this.low>>>0:this.low},S.toNumber=function(){return this.unsigned?(this.high>>>0)*c+(this.low>>>0):this.high*c+(this.low>>>0)},S.toString=function(e){if((e=e||10)<2||36<e)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative()){if(this.eq(R)){var t=s(e),i=this.div(t),r=i.mul(t).sub(this);return i.toString(e)+r.toInt().toString(e)}return"-"+this.neg().toString(e)}for(var n=s(a(e,6),this.unsigned),o=this,l="";;){var _=o.div(n),c=(o.sub(_.mul(n)).toInt()>>>0).toString(e);if((o=_).isZero())return c+l;for(;c.length<6;)c="0"+c;l=""+c+l}},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(){if(this.isNegative())return this.eq(R)?64:this.neg().getNumBitsAbs();for(var e=0!=this.high?this.high:this.low,t=31;t>0&&!(e&1<<t);t--);return 0!=this.high?t+33:t+1},S.isZero=function(){return 0===this.high&&0===this.low},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)},S.isEven=function(){return!(1&this.low)},S.equals=function(e){return t(e)||(e=_(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(t(e)||(e=_(e)),this.eq(e))return 0;var i=this.isNegative(),r=e.isNegative();return i&&!r?-1:!i&&r?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(R)?R:this.not().add(f)},S.neg=S.negate,S.add=function(e){t(e)||(e=_(e));var i=this.high>>>16,r=65535&this.high,n=this.low>>>16,s=65535&this.low,a=e.high>>>16,l=65535&e.high,c=e.low>>>16,d=0,u=0,h=0,g=0;return h+=(g+=s+(65535&e.low))>>>16,u+=(h+=n+c)>>>16,d+=(u+=r+l)>>>16,d+=i+a,o((h&=65535)<<16|(g&=65535),(d&=65535)<<16|(u&=65535),this.unsigned)},S.subtract=function(e){return t(e)||(e=_(e)),this.add(e.neg())},S.sub=S.subtract,S.multiply=function(e){if(this.isZero())return g;if(t(e)||(e=_(e)),e.isZero())return g;if(this.eq(R))return e.isOdd()?R:g;if(e.eq(R))return this.isOdd()?R:g;if(this.isNegative())return e.isNegative()?this.neg().mul(e.neg()):this.neg().mul(e).neg();if(e.isNegative())return this.mul(e.neg()).neg();if(this.lt(h)&&e.lt(h))return s(this.toNumber()*e.toNumber(),this.unsigned);var i=this.high>>>16,r=65535&this.high,n=this.low>>>16,a=65535&this.low,l=e.high>>>16,c=65535&e.high,d=e.low>>>16,u=65535&e.low,p=0,f=0,E=0,T=0;return E+=(T+=a*u)>>>16,f+=(E+=n*u)>>>16,E&=65535,f+=(E+=a*d)>>>16,p+=(f+=r*u)>>>16,f&=65535,p+=(f+=n*d)>>>16,f&=65535,p+=(f+=a*c)>>>16,p+=i*u+r*d+n*c+a*l,o((E&=65535)<<16|(T&=65535),(p&=65535)<<16|(f&=65535),this.unsigned)},S.mul=S.multiply,S.divide=function(e){if(t(e)||(e=_(e)),e.isZero())throw Error("division by zero");if(this.isZero())return this.unsigned?p:g;var i,r,n;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return p;if(e.gt(this.shru(1)))return E;n=p}else{if(this.eq(R))return e.eq(f)||e.eq(T)?R:e.eq(R)?f:(i=this.shr(1).div(e).shl(1)).eq(g)?e.isNegative()?f:T:(r=this.sub(e.mul(i)),n=i.add(r.div(e)));if(e.eq(R))return this.unsigned?p:g;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();n=g}for(r=this;r.gte(e);){i=Math.max(1,Math.floor(r.toNumber()/e.toNumber()));for(var o=Math.ceil(Math.log(i)/Math.LN2),l=o<=48?1:a(2,o-48),c=s(i),d=c.mul(e);d.isNegative()||d.gt(r);)d=(c=s(i-=l,this.unsigned)).mul(e);c.isZero()&&(c=f),n=n.add(c),r=r.sub(d)}return n},S.div=S.divide,S.modulo=function(e){return t(e)||(e=_(e)),this.sub(this.div(e).mul(e))},S.mod=S.modulo,S.not=function(){return o(~this.low,~this.high,this.unsigned)},S.and=function(e){return t(e)||(e=_(e)),o(this.low&e.low,this.high&e.high,this.unsigned)},S.or=function(e){return t(e)||(e=_(e)),o(this.low|e.low,this.high|e.high,this.unsigned)},S.xor=function(e){return t(e)||(e=_(e)),o(this.low^e.low,this.high^e.high,this.unsigned)},S.shiftLeft=function(e){return t(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?o(this.low<<e,this.high<<e|this.low>>>32-e,this.unsigned):o(0,this.low<<e-32,this.unsigned)},S.shl=S.shiftLeft,S.shiftRight=function(e){return t(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?o(this.low>>>e|this.high<<32-e,this.high>>e,this.unsigned):o(this.high>>e-32,this.high>=0?0:-1,this.unsigned)},S.shr=S.shiftRight,S.shiftRightUnsigned=function(e){if(t(e)&&(e=e.toInt()),0===(e&=63))return this;var i=this.high;return e<32?o(this.low>>>e|i<<32-e,i>>>e,this.unsigned):o(32===e?i:i>>>e-32,0,this.unsigned)},S.shru=S.shiftRightUnsigned,S.toSigned=function(){return this.unsigned?o(this.low,this.high,!1):this},S.toUnsigned=function(){return this.unsigned?this:o(this.low,this.high,!0)},S.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()},S.toBytesLE=function(){var e=this.high,t=this.low;return[255&t,t>>>8&255,t>>>16&255,t>>>24&255,255&e,e>>>8&255,e>>>16&255,e>>>24&255]},S.toBytesBE=function(){var e=this.high,t=this.low;return[e>>>24&255,e>>>16&255,e>>>8&255,255&e,t>>>24&255,t>>>16&255,t>>>8&255,255&t]},e}());return t.ByteBuffer=i,t.Long=i.Long||null,t.VERSION="5.0.3",t.WIRE_TYPES={},t.WIRE_TYPES.VARINT=0,t.WIRE_TYPES.BITS64=1,t.WIRE_TYPES.LDELIM=2,t.WIRE_TYPES.STARTGROUP=3,t.WIRE_TYPES.ENDGROUP=4,t.WIRE_TYPES.BITS32=5,t.PACKABLE_WIRE_TYPES=[t.WIRE_TYPES.VARINT,t.WIRE_TYPES.BITS64,t.WIRE_TYPES.BITS32],t.TYPES={int32:{name:"int32",wireType:t.WIRE_TYPES.VARINT,defaultValue:0},uint32:{name:"uint32",wireType:t.WIRE_TYPES.VARINT,defaultValue:0},sint32:{name:"sint32",wireType:t.WIRE_TYPES.VARINT,defaultValue:0},int64:{name:"int64",wireType:t.WIRE_TYPES.VARINT,defaultValue:t.Long?t.Long.ZERO:void 0},uint64:{name:"uint64",wireType:t.WIRE_TYPES.VARINT,defaultValue:t.Long?t.Long.UZERO:void 0},sint64:{name:"sint64",wireType:t.WIRE_TYPES.VARINT,defaultValue:t.Long?t.Long.ZERO:void 0},bool:{name:"bool",wireType:t.WIRE_TYPES.VARINT,defaultValue:!1},double:{name:"double",wireType:t.WIRE_TYPES.BITS64,defaultValue:0},string:{name:"string",wireType:t.WIRE_TYPES.LDELIM,defaultValue:""},bytes:{name:"bytes",wireType:t.WIRE_TYPES.LDELIM,defaultValue:null},fixed32:{name:"fixed32",wireType:t.WIRE_TYPES.BITS32,defaultValue:0},sfixed32:{name:"sfixed32",wireType:t.WIRE_TYPES.BITS32,defaultValue:0},fixed64:{name:"fixed64",wireType:t.WIRE_TYPES.BITS64,defaultValue:t.Long?t.Long.UZERO:void 0},sfixed64:{name:"sfixed64",wireType:t.WIRE_TYPES.BITS64,defaultValue:t.Long?t.Long.ZERO:void 0},float:{name:"float",wireType:t.WIRE_TYPES.BITS32,defaultValue:0},enum:{name:"enum",wireType:t.WIRE_TYPES.VARINT,defaultValue:0},message:{name:"message",wireType:t.WIRE_TYPES.LDELIM,defaultValue:null},group:{name:"group",wireType:t.WIRE_TYPES.STARTGROUP,defaultValue:null}},t.MAP_KEY_TYPES=[t.TYPES.int32,t.TYPES.sint32,t.TYPES.sfixed32,t.TYPES.uint32,t.TYPES.fixed32,t.TYPES.int64,t.TYPES.sint64,t.TYPES.sfixed64,t.TYPES.uint64,t.TYPES.fixed64,t.TYPES.bool,t.TYPES.string,t.TYPES.bytes],t.ID_MIN=1,t.ID_MAX=536870911,t.convertFieldsToCamelCase=!1,t.populateAccessors=!0,t.populateDefaults=!0,t.Util=((e={}).IS_NODE=!("object"!=typeof process||process+""!="[object process]"||process.browser),e.toCamelCase=function(e){return e.replace(/_([a-zA-Z])/g,function(e,t){return t.toUpperCase()})},e),t.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]*)(?:\.[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},t.DotProto=function(e,t){var i={},r=function(e){this.source=e+"",this.index=0,this.line=1,this.stack=[],this._stringOpen=null},n=r.prototype;n._readString=function(){var e='"'===this._stringOpen?t.STRING_DQ:t.STRING_SQ;e.lastIndex=this.index-1;var i=e.exec(this.source);if(!i)throw Error("unterminated string");return this.index=e.lastIndex,this.stack.push(this._stringOpen),this._stringOpen=null,i[1]},n.next=function(){if(this.stack.length>0)return this.stack.shift();if(this.index>=this.source.length)return null;if(null!==this._stringOpen)return this._readString();var e,i,r;do{for(e=!1;t.WHITESPACE.test(r=this.source.charAt(this.index));)if("\n"===r&&++this.line,++this.index===this.source.length)return null;if("/"===this.source.charAt(this.index))if(++this.index,"/"===this.source.charAt(this.index)){for(;"\n"!==this.source.charAt(++this.index);)if(this.index==this.source.length)return null;++this.index,++this.line,e=!0}else{if("*"!==(r=this.source.charAt(this.index)))return"/";do{if("\n"===r&&++this.line,++this.index===this.source.length)return null;i=r,r=this.source.charAt(this.index)}while("*"!==i||"/"!==r);++this.index,e=!0}}while(e);if(this.index===this.source.length)return null;var n=this.index;if(t.DELIM.lastIndex=0,!t.DELIM.test(this.source.charAt(n++)))for(;n<this.source.length&&!t.DELIM.test(this.source.charAt(n));)++n;var s=this.source.substring(this.index,this.index=n);return'"'!==s&&"'"!==s||(this._stringOpen=s),s},n.peek=function(){if(0===this.stack.length){var e=this.next();if(null===e)return null;this.stack.push(e)}return this.stack[0]},n.skip=function(e){var t=this.next();if(t!==e)throw Error("illegal '"+t+"', '"+e+"' expected")},n.omit=function(e){return this.peek()===e&&(this.next(),!0)},n.toString=function(){return"Tokenizer ("+this.index+"/"+this.source.length+" at line "+this.line+")"},i.Tokenizer=r;var s=function(e){this.tn=new r(e),this.proto3=!1},o=s.prototype;function a(e,i){var r=-1,n=1;if("-"==e.charAt(0)&&(n=-1,e=e.substring(1)),t.NUMBER_DEC.test(e))r=parseInt(e);else if(t.NUMBER_HEX.test(e))r=parseInt(e.substring(2),16);else{if(!t.NUMBER_OCT.test(e))throw Error("illegal id value: "+(n<0?"-":"")+e);r=parseInt(e.substring(1),8)}if(r=n*r|0,!i&&r<0)throw Error("illegal id value: "+(n<0?"-":"")+e);return r}function l(e){var i=1;if("-"==e.charAt(0)&&(i=-1,e=e.substring(1)),t.NUMBER_DEC.test(e))return i*parseInt(e,10);if(t.NUMBER_HEX.test(e))return i*parseInt(e.substring(2),16);if(t.NUMBER_OCT.test(e))return i*parseInt(e.substring(1),8);if("inf"===e)return i*(1/0);if("nan"===e)return NaN;if(t.NUMBER_FLT.test(e))return i*parseFloat(e);throw Error("illegal number value: "+(i<0?"-":"")+e)}function _(e,t,i){void 0===e[t]?e[t]=i:(Array.isArray(e[t])||(e[t]=[e[t]]),e[t].push(i))}return o.parse=function(){var e,i,r={name:"[ROOT]",package:null,messages:[],enums:[],imports:[],options:{},services:[]},n=!0;try{for(;e=this.tn.next();)switch(e){case"package":if(!n||null!==r.package)throw Error("unexpected 'package'");if(e=this.tn.next(),!t.TYPEREF.test(e))throw Error("illegal package name: "+e);this.tn.skip(";"),r.package=e;break;case"import":if(!n)throw Error("unexpected 'import'");("public"===(e=this.tn.peek())||(i="weak"===e))&&this.tn.next(),e=this._readString(),this.tn.skip(";"),i||r.imports.push(e);break;case"syntax":if(!n)throw Error("unexpected 'syntax'");this.tn.skip("="),"proto3"===(r.syntax=this._readString())&&(this.proto3=!0),this.tn.skip(";");break;case"message":this._parseMessage(r,null),n=!1;break;case"enum":this._parseEnum(r),n=!1;break;case"option":this._parseOption(r);break;case"service":this._parseService(r);break;case"extend":this._parseExtend(r);break;default:throw Error("unexpected '"+e+"'")}}catch(e){throw e.message="Parse error at line "+this.tn.line+": "+e.message,e}return delete r.name,r},s.parse=function(e){return new s(e).parse()},o._readString=function(){var e,t,i="";do{if("'"!==(t=this.tn.next())&&'"'!==t)throw Error("illegal string delimiter: "+t);i+=this.tn.next(),this.tn.skip(t),e=this.tn.peek()}while('"'===e||'"'===e);return i},o._readValue=function(e){var i=this.tn.peek();if('"'===i||"'"===i)return this._readString();if(this.tn.next(),t.NUMBER.test(i))return l(i);if(t.BOOL.test(i))return"true"===i.toLowerCase();if(e&&t.TYPEREF.test(i))return i;throw Error("illegal value: "+i)},o._parseOption=function(e,i){var r=this.tn.next(),n=!1;if("("===r&&(n=!0,r=this.tn.next()),!t.TYPEREF.test(r))throw Error("illegal option name: "+r);var s=r;n&&(this.tn.skip(")"),s="("+s+")",r=this.tn.peek(),t.FQTYPEREF.test(r)&&(s+=r,this.tn.next())),this.tn.skip("="),this._parseOptionValue(e,s),i||this.tn.skip(";")},o._parseOptionValue=function(e,i){var r=this.tn.peek();if("{"!==r)_(e.options,i,this._readValue(!0));else for(this.tn.skip("{");"}"!==(r=this.tn.next());){if(!t.NAME.test(r))throw Error("illegal option name: "+i+"."+r);this.tn.omit(":")?_(e.options,i+"."+r,this._readValue(!0)):this._parseOptionValue(e,i+"."+r)}},o._parseService=function(e){var i=this.tn.next();if(!t.NAME.test(i))throw Error("illegal service name at line "+this.tn.line+": "+i);var r={name:i,rpc:{},options:{}};for(this.tn.skip("{");"}"!==(i=this.tn.next());)if("option"===i)this._parseOption(r);else{if("rpc"!==i)throw Error("illegal service token: "+i);this._parseServiceRPC(r)}this.tn.omit(";"),e.services.push(r)},o._parseServiceRPC=function(e){var i="rpc",r=this.tn.next();if(!t.NAME.test(r))throw Error("illegal rpc service method name: "+r);var n=r,s={request:null,response:null,request_stream:!1,response_stream:!1,options:{}};if(this.tn.skip("("),"stream"===(r=this.tn.next()).toLowerCase()&&(s.request_stream=!0,r=this.tn.next()),!t.TYPEREF.test(r))throw Error("illegal rpc service request type: "+r);if(s.request=r,this.tn.skip(")"),"returns"!==(r=this.tn.next()).toLowerCase())throw Error("illegal rpc service request type delimiter: "+r);if(this.tn.skip("("),"stream"===(r=this.tn.next()).toLowerCase()&&(s.response_stream=!0,r=this.tn.next()),s.response=r,this.tn.skip(")"),"{"===(r=this.tn.peek())){for(this.tn.next();"}"!==(r=this.tn.next());){if("option"!==r)throw Error("illegal rpc service token: "+r);this._parseOption(s)}this.tn.omit(";")}else this.tn.skip(";");void 0===e[i]&&(e[i]={}),e[i][n]=s},o._parseMessage=function(e,i){var r=!!i,n=this.tn.next(),s={name:"",fields:[],enums:[],messages:[],options:{},services:[],oneofs:{}};if(!t.NAME.test(n))throw Error("illegal "+(r?"group":"message")+" name: "+n);for(s.name=n,r&&(this.tn.skip("="),i.id=a(this.tn.next()),s.isGroup=!0),"["===(n=this.tn.peek())&&i&&this._parseFieldOptions(i),this.tn.skip("{");"}"!==(n=this.tn.next());)if(t.RULE.test(n))this._parseMessageField(s,n);else if("oneof"===n)this._parseMessageOneOf(s);else if("enum"===n)this._parseEnum(s);else if("message"===n)this._parseMessage(s);else if("option"===n)this._parseOption(s);else if("service"===n)this._parseService(s);else if("extensions"===n)s.hasOwnProperty("extensions")?s.extensions=s.extensions.concat(this._parseExtensionRanges()):s.extensions=this._parseExtensionRanges();else if("reserved"===n)this._parseIgnored();else if("extend"===n)this._parseExtend(s);else{if(!t.TYPEREF.test(n))throw Error("illegal message token: "+n);if(!this.proto3)throw Error("illegal field rule: "+n);this._parseMessageField(s,"optional",n)}return this.tn.omit(";"),e.messages.push(s),s},o._parseIgnored=function(){for(;";"!==this.tn.peek();)this.tn.next();this.tn.skip(";")},o._parseMessageField=function(e,i,r){if(!t.RULE.test(i))throw Error("illegal message field rule: "+i);var n,s={rule:i,type:"",name:"",options:{},id:0};if("map"===i){if(r)throw Error("illegal type: "+r);if(this.tn.skip("<"),n=this.tn.next(),!t.TYPE.test(n)&&!t.TYPEREF.test(n))throw Error("illegal message field type: "+n);if(s.keytype=n,this.tn.skip(","),n=this.tn.next(),!t.TYPE.test(n)&&!t.TYPEREF.test(n))throw Error("illegal message field: "+n);if(s.type=n,this.tn.skip(">"),n=this.tn.next(),!t.NAME.test(n))throw Error("illegal message field name: "+n);s.name=n,this.tn.skip("="),s.id=a(this.tn.next()),"["===(n=this.tn.peek())&&this._parseFieldOptions(s),this.tn.skip(";")}else if("group"===(r=void 0!==r?r:this.tn.next())){var o=this._parseMessage(e,s);if(!/^[A-Z]/.test(o.name))throw Error("illegal group name: "+o.name);s.type=o.name,s.name=o.name.toLowerCase(),this.tn.omit(";")}else{if(!t.TYPE.test(r)&&!t.TYPEREF.test(r))throw Error("illegal message field type: "+r);if(s.type=r,n=this.tn.next(),!t.NAME.test(n))throw Error("illegal message field name: "+n);s.name=n,this.tn.skip("="),s.id=a(this.tn.next()),"["===(n=this.tn.peek())&&this._parseFieldOptions(s),this.tn.skip(";")}return e.fields.push(s),s},o._parseMessageOneOf=function(e){var i=this.tn.next();if(!t.NAME.test(i))throw Error("illegal oneof name: "+i);var r,n=i,s=[];for(this.tn.skip("{");"}"!==(i=this.tn.next());)(r=this._parseMessageField(e,"optional",i)).oneof=n,s.push(r.id);this.tn.omit(";"),e.oneofs[n]=s},o._parseFieldOptions=function(e){this.tn.skip("[");for(var t=!0;"]"!==this.tn.peek();)t||this.tn.skip(","),this._parseOption(e,!0),t=!1;this.tn.next()},o._parseEnum=function(e){var i={name:"",values:[],options:{}},r=this.tn.next();if(!t.NAME.test(r))throw Error("illegal name: "+r);for(i.name=r,this.tn.skip("{");"}"!==(r=this.tn.next());)if("option"===r)this._parseOption(i);else{if(!t.NAME.test(r))throw Error("illegal name: "+r);this.tn.skip("=");var n={name:r,id:a(this.tn.next(),!0)};"["===(r=this.tn.peek())&&this._parseFieldOptions({options:{}}),this.tn.skip(";"),i.values.push(n)}this.tn.omit(";"),e.enums.push(i)},o._parseExtensionRanges=function(){var t,i,r,n=[];do{for(i=[];;){switch(t=this.tn.next()){case"min":r=e.ID_MIN;break;case"max":r=e.ID_MAX;break;default:r=l(t)}if(i.push(r),2===i.length)break;if("to"!==this.tn.peek()){i.push(r);break}this.tn.next()}n.push(i)}while(this.tn.omit(","));return this.tn.skip(";"),n},o._parseExtend=function(e){var i=this.tn.next();if(!t.TYPEREF.test(i))throw Error("illegal extend reference: "+i);var r={ref:i,fields:[]};for(this.tn.skip("{");"}"!==(i=this.tn.next());)if(t.RULE.test(i))this._parseMessageField(r,i);else{if(!t.TYPEREF.test(i))throw Error("illegal extend token: "+i);if(!this.proto3)throw Error("illegal field rule: "+i);this._parseMessageField(r,"optional",i)}return this.tn.omit(";"),e.messages.push(r),r},o.toString=function(){return"Parser at line "+this.tn.line},i.Parser=s,i}(t,t.Lang),t.Reflect=function(e){var t={},r=function(e,t,i){this.builder=e,this.parent=t,this.name=i,this.className},n=r.prototype;n.fqn=function(){for(var e=this.name,t=this;;){if(null==(t=t.parent))break;e=t.name+"."+e}return e},n.toString=function(e){return(e?this.className+" ":"")+this.fqn()},n.build=function(){throw Error(this.toString(!0)+" cannot be built directly")},t.T=r;var s=function(e,t,i,n,s){r.call(this,e,t,i),this.className="Namespace",this.children=[],this.options=n||{},this.syntax=s||"proto2"},o=s.prototype=Object.create(r.prototype);o.getChildren=function(e){if(null==(e=e||null))return this.children.slice();for(var t=[],i=0,r=this.children.length;i<r;++i)this.children[i]instanceof e&&t.push(this.children[i]);return t},o.addChild=function(e){var t;if(t=this.getChild(e.name))if(t instanceof c.Field&&t.name!==t.originalName&&null===this.getChild(t.originalName))t.name=t.originalName;else{if(!(e instanceof c.Field&&e.name!==e.originalName&&null===this.getChild(e.originalName)))throw Error("Duplicate name in namespace "+this.toString(!0)+": "+e.name);e.name=e.originalName}this.children.push(e)},o.getChild=function(e){for(var t="number"==typeof e?"id":"name",i=0,r=this.children.length;i<r;++i)if(this.children[i][t]===e)return this.children[i];return null},o.resolve=function(e,i){var r,n="string"==typeof e?e.split("."):e,s=this,o=0;if(""===n[o]){for(;null!==s.parent;)s=s.parent;o++}do{do{if(!(s instanceof t.Namespace)){s=null;break}if(!(r=s.getChild(n[o]))||!(r instanceof t.T)||i&&!(r instanceof t.Namespace)){s=null;break}s=r,o++}while(o<n.length);if(null!=s)break;if(null!==this.parent)return this.parent.resolve(e,i)}while(null!=s);return s},o.qn=function(e){var i=[],r=e;do{i.unshift(r.name),r=r.parent}while(null!==r);for(var n=1;n<=i.length;n++){var s=i.slice(i.length-n);if(e===this.resolve(s,e instanceof t.Namespace))return s.join(".")}return e.fqn()},o.build=function(){for(var e,t={},i=this.children,r=0,n=i.length;r<n;++r)(e=i[r])instanceof s&&(t[e.name]=e.build());return Object.defineProperty&&Object.defineProperty(t,"$options",{value:this.buildOpt()}),t},o.buildOpt=function(){for(var e={},t=Object.keys(this.options),i=0,r=t.length;i<r;++i){var n=t[i],s=this.options[t[i]];e[n]=s}return e},o.getOption=function(e){return void 0===e?this.options:void 0!==this.options[e]?this.options[e]:null},t.Namespace=s;var a=function(t,i,r,n,s){if(this.type=t,this.resolvedType=i,this.isMapKey=r,this.syntax=n,this.name=s,r&&e.MAP_KEY_TYPES.indexOf(t)<0)throw Error("Invalid map key type: "+t.name)},l=a.prototype;function _(t,i){if(t&&"number"==typeof t.low&&"number"==typeof t.high&&"boolean"==typeof t.unsigned&&t.low==t.low&&t.high==t.high)return new e.Long(t.low,t.high,void 0===i?t.unsigned:i);if("string"==typeof t)return e.Long.fromString(t,i||!1,10);if("number"==typeof t)return e.Long.fromNumber(t,i||!1);throw Error("not convertible to Long")}a.defaultFieldValue=function(t){if("string"==typeof t&&(t=e.TYPES[t]),void 0===t.defaultValue)throw Error("default value for type "+t.name+" is not supported");return t==e.TYPES.bytes?new i(0):t.defaultValue},l.toString=function(){return(this.name||"")+(this.isMapKey?"map":"value")+" element"},l.verifyValue=function(t){var r=this;function n(e,t){throw Error("Illegal value for "+r.toString(!0)+" of type "+r.type.name+": "+e+" ("+t+")")}switch(this.type){case e.TYPES.int32:case e.TYPES.sint32:case e.TYPES.sfixed32:return("number"!=typeof t||t==t&&t%1!=0)&&n(typeof t,"not an integer"),t>4294967295?0|t:t;case e.TYPES.uint32:case e.TYPES.fixed32:return("number"!=typeof t||t==t&&t%1!=0)&&n(typeof t,"not an integer"),t<0?t>>>0:t;case e.TYPES.int64:case e.TYPES.sint64:case e.TYPES.sfixed64:if(e.Long)try{return _(t,!1)}catch(e){n(typeof t,e.message)}else n(typeof t,"requires Long.js");case e.TYPES.uint64:case e.TYPES.fixed64:if(e.Long)try{return _(t,!0)}catch(e){n(typeof t,e.message)}else n(typeof t,"requires Long.js");case e.TYPES.bool:return"boolean"!=typeof t&&n(typeof t,"not a boolean"),t;case e.TYPES.float:case e.TYPES.double:return"number"!=typeof t&&n(typeof t,"not a number"),t;case e.TYPES.string:return"string"==typeof t||t&&t instanceof String||n(typeof t,"not a string"),""+t;case e.TYPES.bytes:return i.isByteBuffer(t)?t:i.wrap(t,"base64");case e.TYPES.enum:var s=this.resolvedType.getChildren(e.Reflect.Enum.Value);for(a=0;a<s.length;a++){if(s[a].name==t)return s[a].id;if(s[a].id==t)return s[a].id}if("proto3"===this.syntax)return("number"!=typeof t||t==t&&t%1!=0)&&n(typeof t,"not an integer"),(t>4294967295||t<0)&&n(typeof t,"not in range for uint32"),t;n(t,"not a valid enum value");case e.TYPES.group:case e.TYPES.message:if(t&&"object"==typeof t||n(typeof t,"object expected"),t instanceof this.resolvedType.clazz)return t;if(t instanceof e.Builder.Message){var o={};for(var a in t)t.hasOwnProperty(a)&&(o[a]=t[a]);t=o}return new this.resolvedType.clazz(t)}throw Error("[INTERNAL] Illegal value for "+this.toString(!0)+": "+t+" (undefined type "+this.type+")")},l.calculateLength=function(t,r){if(null===r)return 0;var n;switch(this.type){case e.TYPES.int32:return r<0?i.calculateVarint64(r):i.calculateVarint32(r);case e.TYPES.uint32:return i.calculateVarint32(r);case e.TYPES.sint32:return i.calculateVarint32(i.zigZagEncode32(r));case e.TYPES.fixed32:case e.TYPES.sfixed32:case e.TYPES.float:return 4;case e.TYPES.int64:case e.TYPES.uint64:return i.calculateVarint64(r);case e.TYPES.sint64:return i.calculateVarint64(i.zigZagEncode64(r));case e.TYPES.fixed64:case e.TYPES.sfixed64:return 8;case e.TYPES.bool:return 1;case e.TYPES.enum:return i.calculateVarint32(r);case e.TYPES.double:return 8;case e.TYPES.string:return n=i.calculateUTF8Bytes(r),i.calculateVarint32(n)+n;case e.TYPES.bytes:if(r.remaining()<0)throw Error("Illegal value for "+this.toString(!0)+": "+r.remaining()+" bytes remaining");return i.calculateVarint32(r.remaining())+r.remaining();case e.TYPES.message:return n=this.resolvedType.calculate(r),i.calculateVarint32(n)+n;case e.TYPES.group:return(n=this.resolvedType.calculate(r))+i.calculateVarint32(t<<3|e.WIRE_TYPES.ENDGROUP)}throw Error("[INTERNAL] Illegal value to encode in "+this.toString(!0)+": "+r+" (unknown type)")},l.encodeValue=function(t,r,n){if(null===r)return n;switch(this.type){case e.TYPES.int32:r<0?n.writeVarint64(r):n.writeVarint32(r);break;case e.TYPES.uint32:n.writeVarint32(r);break;case e.TYPES.sint32:n.writeVarint32ZigZag(r);break;case e.TYPES.fixed32:n.writeUint32(r);break;case e.TYPES.sfixed32:n.writeInt32(r);break;case e.TYPES.int64:case e.TYPES.uint64:n.writeVarint64(r);break;case e.TYPES.sint64:n.writeVarint64ZigZag(r);break;case e.TYPES.fixed64:n.writeUint64(r);break;case e.TYPES.sfixed64:n.writeInt64(r);break;case e.TYPES.bool:"string"==typeof r?n.writeVarint32("false"===r.toLowerCase()?0:!!r):n.writeVarint32(r?1:0);break;case e.TYPES.enum:n.writeVarint32(r);break;case e.TYPES.float:n.writeFloat32(r);break;case e.TYPES.double:n.writeFloat64(r);break;case e.TYPES.string:n.writeVString(r);break;case e.TYPES.bytes:if(r.remaining()<0)throw Error("Illegal value for "+this.toString(!0)+": "+r.remaining()+" bytes remaining");var s=r.offset;n.writeVarint32(r.remaining()),n.append(r),r.offset=s;break;case e.TYPES.message:var o=(new i).LE();this.resolvedType.encode(r,o),n.writeVarint32(o.offset),n.append(o.flip());break;case e.TYPES.group:this.resolvedType.encode(r,n),n.writeVarint32(t<<3|e.WIRE_TYPES.ENDGROUP);break;default:throw Error("[INTERNAL] Illegal value to encode in "+this.toString(!0)+": "+r+" (unknown type)")}return n},l.decode=function(t,i,r){if(i!=this.type.wireType)throw Error("Unexpected wire type for element");var n,s;switch(this.type){case e.TYPES.int32:return 0|t.readVarint32();case e.TYPES.uint32:return t.readVarint32()>>>0;case e.TYPES.sint32:return 0|t.readVarint32ZigZag();case e.TYPES.fixed32:return t.readUint32()>>>0;case e.TYPES.sfixed32:return 0|t.readInt32();case e.TYPES.int64:return t.readVarint64();case e.TYPES.uint64:return t.readVarint64().toUnsigned();case e.TYPES.sint64:return t.readVarint64ZigZag();case e.TYPES.fixed64:return t.readUint64();case e.TYPES.sfixed64:return t.readInt64();case e.TYPES.bool:return!!t.readVarint32();case e.TYPES.enum:return t.readVarint32();case e.TYPES.float:return t.readFloat();case e.TYPES.double:return t.readDouble();case e.TYPES.string:return t.readVString();case e.TYPES.bytes:if(s=t.readVarint32(),t.remaining()<s)throw Error("Illegal number of bytes for "+this.toString(!0)+": "+s+" required but got only "+t.remaining());return(n=t.clone()).limit=n.offset+s,t.offset+=s,n;case e.TYPES.message:return s=t.readVarint32(),this.resolvedType.decode(t,s);case e.TYPES.group:return this.resolvedType.decode(t,-1,r)}throw Error("[INTERNAL] Illegal decode type")},l.valueFromString=function(t){if(!this.isMapKey)throw Error("valueFromString() called on non-map-key element");switch(this.type){case e.TYPES.int32:case e.TYPES.sint32:case e.TYPES.sfixed32:case e.TYPES.uint32:case e.TYPES.fixed32:return this.verifyValue(parseInt(t));case e.TYPES.int64:case e.TYPES.sint64:case e.TYPES.sfixed64:case e.TYPES.uint64:case e.TYPES.fixed64:return this.verifyValue(t);case e.TYPES.bool:return"true"===t;case e.TYPES.string:return this.verifyValue(t);case e.TYPES.bytes:return i.fromBinary(t)}},l.valueToString=function(t){if(!this.isMapKey)throw Error("valueToString() called on non-map-key element");return this.type===e.TYPES.bytes?t.toString("binary"):t.toString()},t.Element=a;var c=function(e,t,i,r,n,o){s.call(this,e,t,i,r,o),this.className="Message",this.extensions=void 0,this.clazz=null,this.isGroup=!!n,this._fields=null,this._fieldsById=null,this._fieldsByName=null},d=c.prototype=Object.create(s.prototype);function u(t,i){var r=i.readVarint32(),n=7&r,s=r>>>3;switch(n){case e.WIRE_TYPES.VARINT:do{r=i.readUint8()}while(!(128&~r));break;case e.WIRE_TYPES.BITS64:i.offset+=8;break;case e.WIRE_TYPES.LDELIM:r=i.readVarint32(),i.offset+=r;break;case e.WIRE_TYPES.STARTGROUP:u(s,i);break;case e.WIRE_TYPES.ENDGROUP:if(s===t)return!1;throw Error("Illegal GROUPEND after unknown group: "+s+" ("+t+" expected)");case e.WIRE_TYPES.BITS32:i.offset+=4;break;default:throw Error("Illegal wire type in unknown group "+t+": "+n)}return!0}d.build=function(t){if(this.clazz&&!t)return this.clazz;var r=function(e,t){var r=t.getChildren(e.Reflect.Message.Field),n=t.getChildren(e.Reflect.Message.OneOf),s=function(o,a){e.Builder.Message.call(this);for(var l=0,_=n.length;l<_;++l)this[n[l].name]=null;for(l=0,_=r.length;l<_;++l){var c=r[l];this[c.name]=c.repeated?[]:c.map?new e.Map(c):null,!c.required&&"proto3"!==t.syntax||null===c.defaultValue||(this[c.name]=c.defaultValue)}var d;if(arguments.length>0)if(1!==arguments.length||null===o||"object"!=typeof o||!("function"!=typeof o.encode||o instanceof s)||Array.isArray(o)||o instanceof e.Map||i.isByteBuffer(o)||o instanceof ArrayBuffer||e.Long&&o instanceof e.Long)for(l=0,_=arguments.length;l<_;++l)void 0!==(d=arguments[l])&&this.$set(r[l].name,d);else this.$set(o)},o=s.prototype=Object.create(e.Builder.Message.prototype);o.add=function(i,r,n){var s=t._fieldsByName[i];if(!n){if(!s)throw Error(this+"#"+i+" is undefined");if(!(s instanceof e.Reflect.Message.Field))throw Error(this+"#"+i+" is not a field: "+s.toString(!0));if(!s.repeated)throw Error(this+"#"+i+" is not a repeated field");r=s.verifyValue(r,!0)}return null===this[i]&&(this[i]=[]),this[i].push(r),this},o.$add=o.add,o.set=function(i,r,n){if(i&&"object"==typeof i){for(var s in n=r,i)i.hasOwnProperty(s)&&void 0!==(r=i[s])&&void 0===t._oneofsByName[s]&&this.$set(s,r,n);return this}var o=t._fieldsByName[i];if(n)this[i]=r;else{if(!o)throw Error(this+"#"+i+" is not a field: undefined");if(!(o instanceof e.Reflect.Message.Field))throw Error(this+"#"+i+" is not a field: "+o.toString(!0));this[o.name]=r=o.verifyValue(r)}if(o&&o.oneof){var a=this[o.oneof.name];null!==r?(null!==a&&a!==o.name&&(this[a]=null),this[o.oneof.name]=o.name):a===i&&(this[o.oneof.name]=null)}return this},o.$set=o.set,o.get=function(i,r){if(r)return this[i];var n=t._fieldsByName[i];if(!(n&&n instanceof e.Reflect.Message.Field))throw Error(this+"#"+i+" is not a field: undefined");if(!(n instanceof e.Reflect.Message.Field))throw Error(this+"#"+i+" is not a field: "+n.toString(!0));return this[n.name]},o.$get=o.get;for(var a=0;a<r.length;a++){var l=r[a];l instanceof e.Reflect.Message.ExtensionField||t.builder.options.populateAccessors&&function(e){var i=e.originalName.replace(/(_[a-zA-Z])/g,function(e){return e.toUpperCase().replace("_","")});i=i.substring(0,1).toUpperCase()+i.substring(1);var r=e.originalName.replace(/([A-Z])/g,function(e){return"_"+e}),n=function(t,i){return this[e.name]=i?t:e.verifyValue(t),this},s=function(){return this[e.name]};null===t.getChild("set"+i)&&(o["set"+i]=n),null===t.getChild("set_"+r)&&(o["set_"+r]=n),null===t.getChild("get"+i)&&(o["get"+i]=s),null===t.getChild("get_"+r)&&(o["get_"+r]=s)}(l)}function _(t,r,n,s){if(null===t||"object"!=typeof t){if(s&&s instanceof e.Reflect.Enum){var o=e.Reflect.Enum.getName(s.object,t);if(null!==o)return o}return t}if(i.isByteBuffer(t))return r?t.toBase64():t.toBuffer();if(e.Long.isLong(t))return n?t.toString():e.Long.fromValue(t);var a;if(Array.isArray(t))return a=[],t.forEach(function(e,t){a[t]=_(e,r,n,s)}),a;if(a={},t instanceof e.Map){for(var l=t.entries(),c=l.next();!c.done;c=l.next())a[t.keyElem.valueToString(c.value[0])]=_(c.value[1],r,n,t.valueElem.resolvedType);return a}var d=t.$type,u=void 0;for(var h in t)t.hasOwnProperty(h)&&(d&&(u=d.getChild(h))?a[h]=_(t[h],r,n,u.resolvedType):a[h]=_(t[h],r,n));return a}return o.encode=function(e,r){"boolean"==typeof e&&(r=e,e=void 0);var n=!1;e||(e=new i,n=!0);var s=e.littleEndian;try{return t.encode(this,e.LE(),r),(n?e.flip():e).LE(s)}catch(t){throw e.LE(s),t}},s.encode=function(e,t,i){return new s(e).encode(t,i)},o.calculate=function(){return t.calculate(this)},o.encodeDelimited=function(e,r){var n=!1;e||(e=new i,n=!0);var s=(new i).LE();return t.encode(this,s,r).flip(),e.writeVarint32(s.remaining()),e.append(s),n?e.flip():e},o.encodeAB=function(){try{return this.encode().toArrayBuffer()}catch(e){throw e.encoded&&(e.encoded=e.encoded.toArrayBuffer()),e}},o.toArrayBuffer=o.encodeAB,o.encodeNB=function(){try{return this.encode().toBuffer()}catch(e){throw e.encoded&&(e.encoded=e.encoded.toBuffer()),e}},o.toBuffer=o.encodeNB,o.encode64=function(){try{return this.encode().toBase64()}catch(e){throw e.encoded&&(e.encoded=e.encoded.toBase64()),e}},o.toBase64=o.encode64,o.encodeHex=function(){try{return this.encode().toHex()}catch(e){throw e.encoded&&(e.encoded=e.encoded.toHex()),e}},o.toHex=o.encodeHex,o.toRaw=function(e,t){return _(this,!!e,!!t,this.$type)},o.encodeJSON=function(){return JSON.stringify(_(this,!0,!0,this.$type))},s.decode=function(e,r,n){"string"==typeof r&&(n=r,r=-1),"string"==typeof e?e=i.wrap(e,n||"base64"):i.isByteBuffer(e)||(e=i.wrap(e));var s=e.littleEndian;try{var o=t.decode(e.LE(),r);return e.LE(s),o}catch(t){throw e.LE(s),t}},s.decodeDelimited=function(e,r){if("string"==typeof e?e=i.wrap(e,r||"base64"):i.isByteBuffer(e)||(e=i.wrap(e)),e.remaining()<1)return null;var n=e.offset,s=e.readVarint32();if(e.remaining()<s)return e.offset=n,null;try{var o=t.decode(e.slice(e.offset,e.offset+s).LE());return e.offset+=s,o}catch(t){throw e.offset+=s,t}},s.decode64=function(e){return s.decode(e,"base64")},s.decodeHex=function(e){return s.decode(e,"hex")},s.decodeJSON=function(e){return new s(JSON.parse(e))},o.toString=function(){return t.toString()},Object.defineProperty&&(Object.defineProperty(s,"$options",{value:t.buildOpt()}),Object.defineProperty(o,"$options",{value:s.$options}),Object.defineProperty(s,"$type",{value:t}),Object.defineProperty(o,"$type",{value:t})),s}(e,this);this._fields=[],this._fieldsById={},this._fieldsByName={},this._oneofsByName={};for(var n,s=0,o=this.children.length;s<o;s++)if((n=this.children[s])instanceof f||n instanceof c||n instanceof m){if(r.hasOwnProperty(n.name))throw Error("Illegal reflect child of "+this.toString(!0)+": "+n.toString(!0)+" cannot override static property '"+n.name+"'");r[n.name]=n.build()}else if(n instanceof c.Field)n.build(),this._fields.push(n),this._fieldsById[n.id]=n,this._fieldsByName[n.name]=n;else if(n instanceof c.OneOf)this._oneofsByName[n.name]=n;else if(!(n instanceof c.OneOf||n instanceof T))throw Error("Illegal reflect child of "+this.toString(!0)+": "+this.children[s].toString(!0));return this.clazz=r},d.encode=function(e,t,i){for(var r,n,s=null,o=0,a=this._fields.length;o<a;++o)n=e[(r=this._fields[o]).name],r.required&&null===n?null===s&&(s=r):r.encode(i?n:r.verifyValue(n),t,e);if(null!==s){var l=Error("Missing at least one required field for "+this.toString(!0)+": "+s);throw l.encoded=t,l}return t},d.calculate=function(e){for(var t,i,r=0,n=0,s=this._fields.length;n<s;++n){if(i=e[(t=this._fields[n]).name],t.required&&null===i)throw Error("Missing at least one required field for "+this.toString(!0)+": "+t);r+=t.calculate(i,e)}return r},d.decode=function(t,i,r){"number"!=typeof i&&(i=-1);for(var n,s,o,a,l=t.offset,_=new this.clazz;t.offset<l+i||-1===i&&t.remaining()>0;){if(o=(n=t.readVarint32())>>>3,(s=7&n)===e.WIRE_TYPES.ENDGROUP){if(o!==r)throw Error("Illegal group end indicator for "+this.toString(!0)+": "+o+" ("+(r?r+" expected":"not a group")+")");break}if(a=this._fieldsById[o]){if(a.repeated&&!a.options.packed)_[a.name].push(a.decode(s,t));else if(a.map){var c=a.decode(s,t);_[a.name].set(c[0],c[1])}else if(_[a.name]=a.decode(s,t),a.oneof){var d=_[a.oneof.name];null!==d&&d!==a.name&&(_[d]=null),_[a.oneof.name]=a.name}}else switch(s){case e.WIRE_TYPES.VARINT:t.readVarint32();break;case e.WIRE_TYPES.BITS32:t.offset+=4;break;case e.WIRE_TYPES.BITS64:t.offset+=8;break;case e.WIRE_TYPES.LDELIM:var h=t.readVarint32();t.offset+=h;break;case e.WIRE_TYPES.STARTGROUP:for(;u(o,t););break;default:throw Error("Illegal wire type for unknown field "+o+" in "+this.toString(!0)+"#decode: "+s)}}for(var g=0,p=this._fields.length;g<p;++g)if(null===_[(a=this._fields[g]).name])if("proto3"===this.syntax)_[a.name]=a.defaultValue;else{if(a.required){var f=Error("Missing at least one required field for "+this.toString(!0)+": "+a.name);throw f.decoded=_,f}e.populateDefaults&&null!==a.defaultValue&&(_[a.name]=a.defaultValue)}return _},t.Message=c;var h=function(t,i,n,s,o,a,l,_,d,u){r.call(this,t,i,a),this.className="Message.Field",this.required="required"===n,this.repeated="repeated"===n,this.map="map"===n,this.keyType=s||null,this.type=o,this.resolvedType=null,this.id=l,this.options=_||{},this.defaultValue=null,this.oneof=d||null,this.syntax=u||"proto2",this.originalName=this.name,this.element=null,this.keyElement=null,!this.builder.options.convertFieldsToCamelCase||this instanceof c.ExtensionField||(this.name=e.Util.toCamelCase(this.name))},g=h.prototype=Object.create(r.prototype);g.build=function(){this.element=new a(this.type,this.resolvedType,!1,this.syntax,this.name),this.map&&(this.keyElement=new a(this.keyType,void 0,!0,this.syntax,this.name)),"proto3"!==this.syntax||this.repeated||this.map?void 0!==this.options.default&&(this.defaultValue=this.verifyValue(this.options.default)):this.defaultValue=a.defaultFieldValue(this.type)},g.verifyValue=function(t,i){i=i||!1;var r,n=this;function s(e,t){throw Error("Illegal value for "+n.toString(!0)+" of type "+n.type.name+": "+e+" ("+t+")")}if(null===t)return this.required&&s(typeof t,"required"),"proto3"===this.syntax&&this.type!==e.TYPES.message&&s(typeof t,"proto3 field without field presence cannot be null"),null;if(this.repeated&&!i){Array.isArray(t)||(t=[t]);var o=[];for(r=0;r<t.length;r++)o.push(this.element.verifyValue(t[r]));return o}return this.map&&!i?t instanceof e.Map?t:(t instanceof Object||s(typeof t,"expected ProtoBuf.Map or raw object for map field"),new e.Map(this,t)):(!this.repeated&&Array.isArray(t)&&s(typeof t,"no array expected"),this.element.verifyValue(t))},g.hasWirePresence=function(t,i){if("proto3"!==this.syntax)return null!==t;if(this.oneof&&i[this.oneof.name]===this.name)return!0;switch(this.type){case e.TYPES.int32:case e.TYPES.sint32:case e.TYPES.sfixed32:case e.TYPES.uint32:case e.TYPES.fixed32:return 0!==t;case e.TYPES.int64:case e.TYPES.sint64:case e.TYPES.sfixed64:case e.TYPES.uint64:case e.TYPES.fixed64:return 0!==t.low||0!==t.high;case e.TYPES.bool:return t;case e.TYPES.float:case e.TYPES.double:return 0!==t;case e.TYPES.string:return t.length>0;case e.TYPES.bytes:return t.remaining()>0;case e.TYPES.enum:return 0!==t;case e.TYPES.message:return null!==t;default:return!0}},g.encode=function(t,r,n){if(null===this.type||"object"!=typeof this.type)throw Error("[INTERNAL] Unresolved type in "+this.toString(!0)+": "+this.type);if(null===t||this.repeated&&0==t.length)return r;try{var s;if(this.repeated)if(this.options.packed&&e.PACKABLE_WIRE_TYPES.indexOf(this.type.wireType)>=0){r.writeVarint32(this.id<<3|e.WIRE_TYPES.LDELIM),r.ensureCapacity(r.offset+=1);var o=r.offset;for(s=0;s<t.length;s++)this.element.encodeValue(this.id,t[s],r);var a=r.offset-o,l=i.calculateVarint32(a);if(l>1){var _=r.slice(o,r.offset);o+=l-1,r.offset=o,r.append(_)}r.writeVarint32(a,o-l)}else for(s=0;s<t.length;s++)r.writeVarint32(this.id<<3|this.type.wireType),this.element.encodeValue(this.id,t[s],r);else this.map?t.forEach(function(t,n,s){var o=i.calculateVarint32(8|this.keyType.wireType)+this.keyElement.calculateLength(1,n)+i.calculateVarint32(16|this.type.wireType)+this.element.calculateLength(2,t);r.writeVarint32(this.id<<3|e.WIRE_TYPES.LDELIM),r.writeVarint32(o),r.writeVarint32(8|this.keyType.wireType),this.keyElement.encodeValue(1,n,r),r.writeVarint32(16|this.type.wireType),this.element.encodeValue(2,t,r)},this):this.hasWirePresence(t,n)&&(r.writeVarint32(this.id<<3|this.type.wireType),this.element.encodeValue(this.id,t,r))}catch(e){throw Error("Illegal value for "+this.toString(!0)+": "+t+" ("+e+")")}return r},g.calculate=function(t,r){if(t=this.verifyValue(t),null===this.type||"object"!=typeof this.type)throw Error("[INTERNAL] Unresolved type in "+this.toString(!0)+": "+this.type);if(null===t||this.repeated&&0==t.length)return 0;var n=0;try{var s,o;if(this.repeated)if(this.options.packed&&e.PACKABLE_WIRE_TYPES.indexOf(this.type.wireType)>=0){for(n+=i.calculateVarint32(this.id<<3|e.WIRE_TYPES.LDELIM),o=0,s=0;s<t.length;s++)o+=this.element.calculateLength(this.id,t[s]);n+=i.calculateVarint32(o),n+=o}else for(s=0;s<t.length;s++)n+=i.calculateVarint32(this.id<<3|this.type.wireType),n+=this.element.calculateLength(this.id,t[s]);else this.map?t.forEach(function(t,r,s){var o=i.calculateVarint32(8|this.keyType.wireType)+this.keyElement.calculateLength(1,r)+i.calculateVarint32(16|this.type.wireType)+this.element.calculateLength(2,t);n+=i.calculateVarint32(this.id<<3|e.WIRE_TYPES.LDELIM),n+=i.calculateVarint32(o),n+=o},this):this.hasWirePresence(t,r)&&(n+=i.calculateVarint32(this.id<<3|this.type.wireType),n+=this.element.calculateLength(this.id,t))}catch(e){throw Error("Illegal value for "+this.toString(!0)+": "+t+" ("+e+")")}return n},g.decode=function(t,i,r){var n,s;if(!(!this.map&&t==this.type.wireType||!r&&this.repeated&&this.options.packed&&t==e.WIRE_TYPES.LDELIM||this.map&&t==e.WIRE_TYPES.LDELIM))throw Error("Illegal wire type for field "+this.toString(!0)+": "+t+" ("+this.type.wireType+" expected)");if(t==e.WIRE_TYPES.LDELIM&&this.repeated&&this.options.packed&&e.PACKABLE_WIRE_TYPES.indexOf(this.type.wireType)>=0&&!r){s=i.readVarint32(),s=i.offset+s;for(var o=[];i.offset<s;)o.push(this.decode(this.type.wireType,i,!0));return o}if(this.map){var l=a.defaultFieldValue(this.keyType);if(n=a.defaultFieldValue(this.type),s=i.readVarint32(),i.remaining()<s)throw Error("Illegal number of bytes for "+this.toString(!0)+": "+s+" required but got only "+i.remaining());var _=i.clone();for(_.limit=_.offset+s,i.offset+=s;_.remaining()>0;){var c=_.readVarint32();t=7&c;var d=c>>>3;if(1===d)l=this.keyElement.decode(_,t,d);else{if(2!==d)throw Error("Unexpected tag in map field key/value submessage");n=this.element.decode(_,t,d)}}return[l,n]}return this.element.decode(i,t,this.id)},t.Message.Field=h;var p=function(e,t,i,r,n,s,o){h.call(this,e,t,i,null,r,n,s,o),this.extension};p.prototype=Object.create(h.prototype),t.Message.ExtensionField=p;t.Message.OneOf=function(e,t,i){r.call(this,e,t,i),this.fields=[]};var f=function(e,t,i,r,n){s.call(this,e,t,i,r,n),this.className="Enum",this.object=null};f.getName=function(e,t){for(var i,r=Object.keys(e),n=0;n<r.length;++n)if(e[i=r[n]]===t)return i;return null},(f.prototype=Object.create(s.prototype)).build=function(t){if(this.object&&!t)return this.object;for(var i=new e.Builder.Enum,r=this.getChildren(f.Value),n=0,s=r.length;n<s;++n)i[r[n].name]=r[n].id;return Object.defineProperty&&Object.defineProperty(i,"$options",{value:this.buildOpt(),enumerable:!1}),this.object=i},t.Enum=f;var E=function(e,t,i,n){r.call(this,e,t,i),this.className="Enum.Value",this.id=n};E.prototype=Object.create(r.prototype),t.Enum.Value=E;var T=function(e,t,i,n){r.call(this,e,t,i),this.field=n};T.prototype=Object.create(r.prototype),t.Extension=T;var m=function(e,t,i,r){s.call(this,e,t,i,r),this.className="Service",this.clazz=null};(m.prototype=Object.create(s.prototype)).build=function(t){return this.clazz&&!t?this.clazz:this.clazz=function(e,t){for(var r=function(t){e.Builder.Service.call(this),this.rpcImpl=t||function(e,t,i){setTimeout(i.bind(this,Error("Not implemented, see: https://github.com/dcodeIO/ProtoBuf.js/wiki/Services")),0)}},n=r.prototype=Object.create(e.Builder.Service.prototype),s=t.getChildren(e.Reflect.Service.RPCMethod),o=0;o<s.length;o++)(function(e){n[e.name]=function(r,n){try{try{r=e.resolvedRequestType.clazz.decode(i.wrap(r))}catch(e){if(!(e instanceof TypeError))throw e}if(null===r||"object"!=typeof r)throw Error("Illegal arguments");r instanceof e.resolvedRequestType.clazz||(r=new e.resolvedRequestType.clazz(r)),this.rpcImpl(e.fqn(),r,function(i,r){if(i)n(i);else{null===r&&(r="");try{r=e.resolvedResponseType.clazz.decode(r)}catch(e){}r&&r instanceof e.resolvedResponseType.clazz?n(null,r):n(Error("Illegal response type received in service method "+t.name+"#"+e.name))}})}catch(e){setTimeout(n.bind(this,e),0)}},r[e.name]=function(t,i,n){new r(t)[e.name](i,n)},Object.defineProperty&&(Object.defineProperty(r[e.name],"$options",{value:e.buildOpt()}),Object.defineProperty(n[e.name],"$options",{value:r[e.name].$options}))})(s[o]);return Object.defineProperty&&(Object.defineProperty(r,"$options",{value:t.buildOpt()}),Object.defineProperty(n,"$options",{value:r.$options}),Object.defineProperty(r,"$type",{value:t}),Object.defineProperty(n,"$type",{value:t})),r}(e,this)},t.Service=m;var I=function(e,t,i,n){r.call(this,e,t,i),this.className="Service.Method",this.options=n||{}};(I.prototype=Object.create(r.prototype)).buildOpt=o.buildOpt,t.Service.Method=I;var R=function(e,t,i,r,n,s,o,a){I.call(this,e,t,i,a),this.className="Service.RPCMethod",this.requestName=r,this.responseName=n,this.requestStream=s,this.responseStream=o,this.resolvedRequestType=null,this.resolvedResponseType=null};return R.prototype=Object.create(I.prototype),t.Service.RPCMethod=R,t}(t),t.Builder=function(e,t,i){var r=function(e){this.ns=new i.Namespace(this,null,""),this.ptr=this.ns,this.resolved=!1,this.result=null,this.files={},this.importRoot=null,this.options=e||{}},n=r.prototype;function s(e){e.messages&&e.messages.forEach(function(t){t.syntax=e.syntax,s(t)}),e.enums&&e.enums.forEach(function(t){t.syntax=e.syntax})}return r.isMessage=function(e){return"string"==typeof e.name&&(void 0===e.values&&void 0===e.rpc)},r.isMessageField=function(e){return"string"==typeof e.rule&&"string"==typeof e.name&&"string"==typeof e.type&&void 0!==e.id},r.isEnum=function(e){return"string"==typeof e.name&&!(void 0===e.values||!Array.isArray(e.values)||0===e.values.length)},r.isService=function(e){return!("string"!=typeof e.name||"object"!=typeof e.rpc||!e.rpc)},r.isExtend=function(e){return"string"==typeof e.ref},n.reset=function(){return this.ptr=this.ns,this},n.define=function(e){if("string"!=typeof e||!t.TYPEREF.test(e))throw Error("illegal namespace: "+e);return e.split(".").forEach(function(e){var t=this.ptr.getChild(e);null===t&&this.ptr.addChild(t=new i.Namespace(this,this.ptr,e)),this.ptr=t},this),this},n.create=function(t){if(!t)return this;if(Array.isArray(t)){if(0===t.length)return this;t=t.slice()}else t=[t];for(var n=[t];n.length>0;){if(t=n.pop(),!Array.isArray(t))throw Error("not a valid namespace: "+JSON.stringify(t));for(;t.length>0;){var s=t.shift();if(r.isMessage(s)){var o=new i.Message(this,this.ptr,s.name,s.options,s.isGroup,s.syntax),a={};s.oneofs&&Object.keys(s.oneofs).forEach(function(e){o.addChild(a[e]=new i.Message.OneOf(this,o,e))},this),s.fields&&s.fields.forEach(function(e){if(null!==o.getChild(0|e.id))throw Error("duplicate or invalid field id in "+o.name+": "+e.id);if(e.options&&"object"!=typeof e.options)throw Error("illegal field options in "+o.name+"#"+e.name);var t=null;if("string"==typeof e.oneof&&!(t=a[e.oneof]))throw Error("illegal oneof in "+o.name+"#"+e.name+": "+e.oneof);e=new i.Message.Field(this,o,e.rule,e.keytype,e.type,e.name,e.id,e.options,t,s.syntax),t&&t.fields.push(e),o.addChild(e)},this);var l=[];if(s.enums&&s.enums.forEach(function(e){l.push(e)}),s.messages&&s.messages.forEach(function(e){l.push(e)}),s.services&&s.services.forEach(function(e){l.push(e)}),s.extensions&&("number"==typeof s.extensions[0]?o.extensions=[s.extensions]:o.extensions=s.extensions),this.ptr.addChild(o),l.length>0){n.push(t),t=l,l=null,this.ptr=o,o=null;continue}l=null}else if(r.isEnum(s))o=new i.Enum(this,this.ptr,s.name,s.options,s.syntax),s.values.forEach(function(e){o.addChild(new i.Enum.Value(this,o,e.name,e.id))},this),this.ptr.addChild(o);else if(r.isService(s))o=new i.Service(this,this.ptr,s.name,s.options),Object.keys(s.rpc).forEach(function(e){var t=s.rpc[e];o.addChild(new i.Service.RPCMethod(this,o,e,t.request,t.response,!!t.request_stream,!!t.response_stream,t.options))},this),this.ptr.addChild(o);else{if(!r.isExtend(s))throw Error("not a valid definition: "+JSON.stringify(s));if(o=this.ptr.resolve(s.ref,!0))s.fields.forEach(function(t){if(null!==o.getChild(0|t.id))throw Error("duplicate extended field id in "+o.name+": "+t.id);if(o.extensions){var r=!1;if(o.extensions.forEach(function(e){t.id>=e[0]&&t.id<=e[1]&&(r=!0)}),!r)throw Error("illegal extended field id in "+o.name+": "+t.id+" (not within valid ranges)")}var n=t.name;this.options.convertFieldsToCamelCase&&(n=e.Util.toCamelCase(n));var s=new i.Message.ExtensionField(this,o,t.rule,t.type,this.ptr.fqn()+"."+n,t.id,t.options),a=new i.Extension(this,this.ptr,t.name,s);s.extension=a,this.ptr.addChild(a),o.addChild(s)},this);else if(!/\.?google\.protobuf\./.test(s.ref))throw Error("extended message "+s.ref+" is not defined")}s=null,o=null}t=null,this.ptr=this.ptr.parent}return this.resolved=!1,this.result=null,this},n.import=function(t,i){var r="/";if("string"==typeof i){if(e.Util.IS_NODE&&(i=require("path").resolve(i)),!0===this.files[i])return this.reset();this.files[i]=!0}else if("object"==typeof i){var n,o=i.root;if(e.Util.IS_NODE&&(o=require("path").resolve(o)),(o.indexOf("\\")>=0||i.file.indexOf("\\")>=0)&&(r="\\"),n=e.Util.IS_NODE?require("path").join(o,i.file):o+r+i.file,!0===this.files[n])return this.reset();this.files[n]=!0}if(t.imports&&t.imports.length>0){var a,l=!1;"object"==typeof i?(this.importRoot=i.root,l=!0,a=this.importRoot,i=i.file,(a.indexOf("\\")>=0||i.indexOf("\\")>=0)&&(r="\\")):"string"==typeof i?this.importRoot?a=this.importRoot:i.indexOf("/")>=0?""===(a=i.replace(/\/[^\/]*$/,""))&&(a="/"):i.indexOf("\\")>=0?(a=i.replace(/\\[^\\]*$/,""),r="\\"):a=".":a=null;for(var _=0;_<t.imports.length;_++)if("string"==typeof t.imports[_]){if(!a)throw Error("cannot determine import root");var c=t.imports[_];if("google/protobuf/descriptor.proto"===c)continue;if(c=e.Util.IS_NODE?require("path").join(a,c):a+r+c,!0===this.files[c])continue;/\.proto$/i.test(c)&&!e.DotProto&&(c=c.replace(/\.proto$/,".json"));var d=e.Util.fetch(c);if(null===d)throw Error("failed to import '"+c+"' in '"+i+"': file not found");/\.json$/i.test(c)?this.import(JSON.parse(d+""),c):this.import(e.DotProto.Parser.parse(d),c)}else i?/\.(\w+)$/.test(i)?this.import(t.imports[_],i.replace(/^(.+)\.(\w+)$/,function(e,t,i){return t+"_import"+_+"."+i})):this.import(t.imports[_],i+"_import"+_):this.import(t.imports[_]);l&&(this.importRoot=null)}t.package&&this.define(t.package),t.syntax&&s(t);var u=this.ptr;return t.options&&Object.keys(t.options).forEach(function(e){u.options[e]=t.options[e]}),t.messages&&(this.create(t.messages),this.ptr=u),t.enums&&(this.create(t.enums),this.ptr=u),t.services&&(this.create(t.services),this.ptr=u),t.extends&&this.create(t.extends),this.reset()},n.resolveAll=function(){var r;if(null==this.ptr||"object"==typeof this.ptr.type)return this;if(this.ptr instanceof i.Namespace)this.ptr.children.forEach(function(e){this.ptr=e,this.resolveAll()},this);else if(this.ptr instanceof i.Message.Field){if(t.TYPE.test(this.ptr.type))this.ptr.type=e.TYPES[this.ptr.type];else{if(!t.TYPEREF.test(this.ptr.type))throw Error("illegal type reference in "+this.ptr.toString(!0)+": "+this.ptr.type);if(!(r=(this.ptr instanceof i.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=r,r instanceof i.Enum){if(this.ptr.type=e.TYPES.enum,"proto3"===this.ptr.syntax&&"proto3"!==r.syntax)throw Error("proto3 message cannot reference proto2 enum")}else{if(!(r instanceof i.Message))throw Error("illegal type reference in "+this.ptr.toString(!0)+": "+this.ptr.type);this.ptr.type=r.isGroup?e.TYPES.group:e.TYPES.message}}if(this.ptr.map){if(!t.TYPE.test(this.ptr.keyType))throw Error("illegal key type for map field in "+this.ptr.toString(!0)+": "+this.ptr.keyType);this.ptr.keyType=e.TYPES[this.ptr.keyType]}"proto3"===this.ptr.syntax&&this.ptr.repeated&&void 0===this.ptr.options.packed&&-1!==e.PACKABLE_WIRE_TYPES.indexOf(this.ptr.type.wireType)&&(this.ptr.options.packed=!0)}else if(this.ptr instanceof e.Reflect.Service.Method){if(!(this.ptr instanceof e.Reflect.Service.RPCMethod))throw Error("illegal service type in "+this.ptr.toString(!0));if(!((r=this.ptr.parent.resolve(this.ptr.requestName,!0))&&r instanceof e.Reflect.Message))throw Error("Illegal type reference in "+this.ptr.toString(!0)+": "+this.ptr.requestName);if(this.ptr.resolvedRequestType=r,!((r=this.ptr.parent.resolve(this.ptr.responseName,!0))&&r instanceof e.Reflect.Message))throw Error("Illegal type reference in "+this.ptr.toString(!0)+": "+this.ptr.responseName);this.ptr.resolvedResponseType=r}else if(!(this.ptr instanceof e.Reflect.Message.OneOf||this.ptr instanceof e.Reflect.Extension||this.ptr instanceof e.Reflect.Enum.Value))throw Error("illegal object in namespace: "+typeof this.ptr+": "+this.ptr);return this.reset()},n.build=function(e){if(this.reset(),this.resolved||(this.resolveAll(),this.resolved=!0,this.result=null),null===this.result&&(this.result=this.ns.build()),!e)return this.result;for(var t="string"==typeof e?e.split("."):e,i=this.result,r=0;r<t.length;r++){if(!i[t[r]]){i=null;break}i=i[t[r]]}return i},n.lookup=function(e,t){return e?this.ns.resolve(e,t):this.ns},n.toString=function(){return"Builder"},r.Message=function(){},r.Enum=function(){},r.Service=function(){},r}(t,t.Lang,t.Reflect),t.Map=function(e,t){var i=function(e,i){if(!e.map)throw Error("field is not a map");if(this.field=e,this.keyElem=new t.Element(e.keyType,null,!0,e.syntax),this.valueElem=new t.Element(e.type,e.resolvedType,!1,e.syntax),this.map={},Object.defineProperty(this,"size",{get:function(){return Object.keys(this.map).length}}),i)for(var r=Object.keys(i),n=0;n<r.length;n++){var s=this.keyElem.valueFromString(r[n]),o=this.valueElem.verifyValue(i[r[n]]);this.map[this.keyElem.valueToString(s)]={key:s,value:o}}},r=i.prototype;function n(e){var t=0;return{next:function(){return t<e.length?{done:!1,value:e[t++]}:{done:!0}}}}return r.clear=function(){this.map={}},r.delete=function(e){var t=this.keyElem.valueToString(this.keyElem.verifyValue(e)),i=t in this.map;return delete this.map[t],i},r.entries=function(){for(var e,t=[],i=Object.keys(this.map),r=0;r<i.length;r++)t.push([(e=this.map[i[r]]).key,e.value]);return n(t)},r.keys=function(){for(var e=[],t=Object.keys(this.map),i=0;i<t.length;i++)e.push(this.map[t[i]].key);return n(e)},r.values=function(){for(var e=[],t=Object.keys(this.map),i=0;i<t.length;i++)e.push(this.map[t[i]].value);return n(e)},r.forEach=function(e,t){for(var i,r=Object.keys(this.map),n=0;n<r.length;n++)e.call(t,(i=this.map[r[n]]).value,i.key,this)},r.set=function(e,t){var i=this.keyElem.verifyValue(e),r=this.valueElem.verifyValue(t);return this.map[this.keyElem.valueToString(i)]={key:i,value:r},this},r.get=function(e){var t=this.keyElem.valueToString(this.keyElem.verifyValue(e));if(t in this.map)return this.map[t].value},r.has=function(e){return this.keyElem.valueToString(this.keyElem.verifyValue(e))in this.map},i}(0,t.Reflect),t.loadProto=function(e,i,r){return("string"==typeof i||i&&"string"==typeof i.file&&"string"==typeof i.root)&&(r=i,i=void 0),t.loadJson(t.DotProto.Parser.parse(e),i,r)},t.newBuilder=function(e){return void 0===(e=e||{}).convertFieldsToCamelCase&&(e.convertFieldsToCamelCase=t.convertFieldsToCamelCase),void 0===e.populateAccessors&&(e.populateAccessors=t.populateAccessors),new t.Builder(e)},t.loadJson=function(e,i,r){return("string"==typeof i||i&&"string"==typeof i.file&&"string"==typeof i.root)&&(r=i,i=null),i&&"object"==typeof i||(i=t.newBuilder()),"string"==typeof e&&(e=JSON.parse(e)),i.import(e,r),i.resolveAll(),i},t}();var vl,bl;class Al{constructor(e){vl.add(this),Object.defineProperty(this,"pbModules",{enumerable:!0,configurable:!0,writable:!0,value:void 0});const t=Ol.loadProto(e);this.pbModules=t.build("Modules").probuf}encode(e,t){return this.pbModules[e].encode(t).toArrayBuffer()}decode(e,t){try{const i=this.pbModules[e].decode(t);return R(this,vl,"m",bl).call(this,i)}catch(t){const i=`name: ${e}, stack: ${t.stack}`;throw null===console||void 0===console||console.error("pb decode error!",i),t}}}vl=new WeakSet,bl=function e(t){if(t instanceof Array)return t.map(t=>R(this,vl,"m",e).call(this,t));if(i=t,"[object Object]"!==Object.prototype.toString.call(i))return t;var i;if(t instanceof Ol.ByteBuffer)return t.toArrayBuffer();if(t instanceof Ol.Long)return t.toNumber();const r={};return Object.keys(t).forEach(i=>{r[i]=R(this,vl,"m",e).call(this,t[i])}),r};var yl,Nl,Pl,Ul,Dl,Ml,wl;!function(e){e[e.PERSON=1]="PERSON",e[e.PERSONS=2]="PERSONS",e[e.GROUP=3]="GROUP",e[e.TEMPGROUP=4]="TEMPGROUP",e[e.CUSTOMERSERVICE=5]="CUSTOMERSERVICE",e[e.NOTIFY=6]="NOTIFY",e[e.MC=7]="MC",e[e.MP=8]="MP",e[e.ULTRAGROUP=10]="ULTRAGROUP"}(yl||(yl={})),function(e){e[e.IMAGE=1]="IMAGE",e[e.AUDIO=2]="AUDIO",e[e.VIDEO=3]="VIDEO",e[e.FILE=4]="FILE",e[e.SIGHT=5]="SIGHT",e[e.COMBINE_HTML=6]="COMBINE_HTML"}(Nl||(Nl={})),function(e){e[e.GROUP_SUCCESS=0]="GROUP_SUCCESS",e[e.GROUP_FAILURE=1]="GROUP_FAILURE"}(Pl||(Pl={})),function(e){e[e.IsSilent=1]="IsSilent",e[e.IsTop=2]="IsTop",e[e.Tags=3]="Tags",e[e.AutoTrans=4]="AutoTrans"}(Ul||(Ul={})),function(e){e[e.KICK=0]="KICK",e[e.REFUSE=1]="REFUSE",e[e.COEXIST=2]="COEXIST"}(Dl||(Dl={})),function(e){e[e.ROOM=1]="ROOM",e[e.PERSON=2]="PERSON"}(Ml||(Ml={})),function(e){e[e.AnchorToViewer=1]="AnchorToViewer",e[e.ViewerToAnchor=2]="ViewerToAnchor"}(wl||(wl={})),new Al("package Modules;\nmessage probuf {\n message SetUserStatusOutput {\n optional int32 nothing=1;\n }\n message GetUserStatusInput {\n optional int32 nothing=1;\n }\n message GetUserStatusOutput {\n optional string status=1;\n optional string subUserId=2;\n }\n message SubUserStatusInput {\n repeated string userid =1;\n }\n message SubUserStatusOutput {\n optional int32 nothing=1;\n }\n message VoipDynamicInput {\n required int32 engineType = 1;\n required string channelName = 2;\n optional string channelExtra = 3;\n }\n message VoipDynamicOutput {\n required string dynamicKey=1;\n }\n message NotifyMsg {\n required int32 type = 1;\n optional int64 time = 2;\n optional string chrmId=3;\n }\n message SyncRequestMsg {\n required int64 syncTime = 1;\n required bool ispolling = 2;\n optional bool isweb=3;\n optional bool isPullSend=4;\n optional bool isKeeping=5;\n optional int64 sendBoxSyncTime=6;\n optional int64 broadcastSyncTime=7;\n optional int64 endTime = 8;\n optional bool compressioEnabled = 9;\n }\n message UpStreamMessage {\n required int32 sessionId = 1;\n required string classname = 2;\n required string content = 3;\n optional string pushText = 4;\n optional string appData = 5;\n repeated string toUserIds = 6;\n optional int64 delMsgTime = 7;\n optional string delMsgId = 8;\n optional int32 configFlag = 9;\n optional int64 clientUniqueId = 10;\n optional string extraContent = 11;\n optional PushExtra pushExt = 12;\n optional string busChannel = 13;\n optional string systemId = 16;\n optional string senderPortrait = 21;\n optional int64 optionBits = 22;\n }\n message PushExtra {\n optional string title = 1;\n optional int32 templateIdNoUse= 2;\n optional string pushId = 3;\n optional string pushConfigs = 4;\n optional string templateId = 5;\n }\n message DownStreamMessages {\n repeated DownStreamMessage list = 1;\n required int64 syncTime = 2;\n optional bool finished = 3;\n optional int64 broadcastSyncTime = 4;\n optional int64 systemTime = 5;\n optional int64 credibleStartTime = 6;\n optional int64 credibleEndTime = 7;\n optional bool compressioEnabled = 8;\n optional bytes compressedData = 9;\n }\n message ChrmDownStreamMessages {\n repeated bytes list = 1;\n required int64 syncTime = 2;\n optional bool compressioEnabled = 3;\n optional bytes compressedData = 4;\n }\n message DownStreamMessage {\n required string fromUserId = 1;\n required ChannelType type = 2;\n optional string groupId = 3;\n required string classname = 4;\n required string content = 5;\n required int64 dataTime = 6;\n required int64 status = 7;\n optional int64 extra = 8;\n optional string msgId = 9;\n optional int32 direction = 10;\n optional int32 plantform =11;\n optional int32 isRemoved = 12;\n optional string source = 13;\n optional int64 clientUniqueId = 14;\n optional string extraContent = 15;\n optional string pushContent = 16;\n optional int32 configFlag = 17;\n optional PushExtra pushExt = 18;\n optional string busChannel = 19;\n optional int64 extStatus = 20;\n repeated string toUserIds = 21;\n optional int32 groupUnpush = 22;\n optional int64 optionBits = 23;\n optional string convertExt = 24;\n optional ExtMsgData extMsgData = 25;\n }\n message ExtMsgData {\n optional int64 seqId = 1;\n optional int64 sendTime = 2;\n }\n enum ChannelType {\n PERSON = 1;\n PERSONS = 2;\n GROUP = 3;\n TEMPGROUP = 4;\n CUSTOMERSERVICE = 5;\n NOTIFY = 6;\n MC=7;\n MP=8;\n ULTRAGROUP = 10;\n }\n message CreateDiscussionInput {\n optional string name = 1;\n }\n message CreateDiscussionOutput {\n required string id = 1;\n }\n message ChannelInvitationInput {\n repeated string users = 1;\n }\n message LeaveChannelInput {\n required int32 nothing = 1;\n }\n message ChannelEvictionInput {\n required string user = 1;\n }\n message RenameChannelInput {\n required string name = 1;\n }\n message ChannelInfoInput {\n required int32 nothing = 1;\n }\n message ChannelInfoOutput {\n required ChannelType type = 1;\n required string channelId = 2;\n required string channelName = 3;\n required string adminUserId = 4;\n repeated string firstTenUserIds = 5;\n required int32 openStatus = 6;\n }\n message ChannelInfosInput {\n required int32 page = 1;\n optional int32 number = 2;\n }\n message ChannelInfosOutput {\n repeated ChannelInfoOutput channels = 1;\n required int32 total = 2;\n }\n message MemberInfo {\n required string userId = 1;\n required string userName = 2;\n required string userPortrait = 3;\n required string extension = 4;\n }\n message GroupMembersInput {\n required int32 page = 1;\n optional int32 number = 2;\n }\n message GroupMembersOutput {\n repeated MemberInfo members = 1;\n required int32 total = 2;\n }\n message GetUserInfoInput {\n required int32 nothing = 1;\n }\n message GetUserInfoOutput {\n required string userId = 1;\n required string userName = 2;\n required string userPortrait = 3;\n }\n message GetSessionIdInput {\n required int32 nothing = 1;\n }\n message GetSessionIdOutput {\n required int32 sessionId = 1;\n }\n enum FileType {\n IMAGE = 1;\n AUDIO = 2;\n VIDEO = 3;\n FILE = 4;\n SIGHT = 5;\n COMBINE_HTML = 6;\n }\n message GetQNupTokenInput {\n required FileType type = 1;\n optional string key = 2;\n optional string httpMethod = 3;\n optional string queryString = 4;\n optional string url = 5;\n optional string ext = 6;\n optional int64 size = 7;\n optional int32 ipType = 8;\n }\n message GetQNdownloadUrlInput {\n required FileType type = 1;\n required string key = 2;\n optional string fileName = 3;\n }\n message GetDownloadUrlInput {\n required FileType type = 1;\n required string key = 2;\n optional string fileName = 3;\n optional string ext = 4;\n optional int64 size = 5;\n optional int32 ipType = 6;\n }\n message GetQNupTokenOutput {\n required int64 deadline = 1;\n required string token = 2;\n optional string bosToken = 3;\n optional string bosDate = 4;\n optional string path = 5;\n\n optional string osskeyId = 6;\n optional string ossPolicy = 7;\n optional string ossSign = 8;\n optional string ossBucketName = 9;\n\n optional string s3Credential = 10;\n optional string s3Algorithm = 11;\n optional string s3Date = 12;\n optional string s3Policy = 13;\n optional string s3Signature = 14;\n optional string s3BucketName = 15;\n\n optional string stcAuthorization = 16;\n optional string stcContentSha256 = 17;\n optional string stcDate = 18;\n optional string stcBucketName = 19;\n\n optional string minioAuthorization = 20;\n optional string minioContentSha256 = 21;\n optional string minioDate = 22;\n optional string minioBucketName = 23;\n\n optional string downloadAuthInfo = 24;\n optional string ossConfig = 25;\n }\n message GetQNdownloadUrlOutput {\n required string downloadUrl = 1;\n }\n message GetDownloadUrlOutput {\n required string downloadUrl = 1;\n }\n message Add2BlackListInput {\n required string userId = 1;\n }\n message RemoveFromBlackListInput {\n required string userId = 1;\n }\n message QueryBlackListInput {\n required int32 nothing = 1;\n }\n message QueryBlackListOutput {\n repeated string userIds = 1;\n }\n message BlackListStatusInput {\n required string userId = 1;\n }\n message BlockPushInput {\n required string blockeeId = 1;\n }\n message ModifyPermissionInput {\n required int32 openStatus = 1;\n }\n message GroupInput {\n repeated GroupInfo groupInfo = 1;\n }\n message GroupOutput {\n required int32 nothing = 1;\n }\n message GroupInfo {\n required string id = 1;\n required string name = 2;\n }\n message GroupHashInput {\n required string userId = 1;\n required string groupHashCode = 2;\n }\n message GroupHashOutput {\n required GroupHashType result = 1;\n }\n enum GroupHashType {\n GROUP_SUCCESS = 0x00;\n GROUP_FAILURE = 0x01;\n }\n message ChrmInput {\n required int32 nothing = 1;\n optional string extra = 2;\n }\n message ChrmOutput {\n required int32 nothing = 1;\n optional string sessionId = 2;\n optional int64 joinTime = 3;\n optional int64 createTime = 4;\n optional int32 memberCount = 5;\n optional int32 chatroomBanState = 6;\n optional int32 whiteListState = 7;\n }\n message ChrmPullMsg {\n required int64 syncTime = 1;\n required int32 count = 2;\n optional int32 pullMsgType = 3;\n optional bool compressioEnabled = 4;\n }\n message ChrmPullMsgNew {\n required int32 count = 1;\n required int64 syncTime = 2;\n optional string chrmId=3;\n }\n message RelationQryInput {\n optional ChannelType type = 1;\n optional int32 count = 2;\n optional int64 startTime = 3;\n optional int32 order = 4;\n optional bool isEraseMsgContent = 5;\n optional int64 endTime = 6;\n optional bool compressioEnabled = 7;\n optional int32 qryType = 8;\n }\n message RelationsOutput {\n repeated RelationInfo info = 1;\n optional bool isFinished = 2;\n optional int64 pullTime = 3;\n optional bool compressioEnabled = 4; \n optional bytes compressedData = 5;\n }\n message RelationInfo {\n required ChannelType type = 1;\n required string userId = 2;\n optional DownStreamMessage msg =3;\n optional int64 readMsgTime= 4;\n optional int64 unreadCount= 5;\n optional string busChannel = 6;\n optional int64 versionTime = 7;\n optional int64 remindCount = 8;\n optional int32 busChannelType = 9;\n optional UnreadMsgInfo msgInfo = 10;\n optional int32 remindMeCount = 11;\n }\n message UnreadMsgInfo {\n required string msgId = 1;\n required int64 msgTime= 2;\n optional int32 remindType= 3;\n optional string className = 4;\n }\n message QryRemindListReq {\n required string groupId = 1;\n optional string busChannel = 2;\n optional int64 msgTime = 3;\n optional int32 size = 4;\n }\n message QryRemindListResp {\n repeated UnreadMsgInfo msgInfo = 1;\n }\n message RelationInfoReadTime {\n required ChannelType type = 1;\n required int64 readMsgTime= 2;\n required string targetId = 3;\n }\n message CleanHisMsgInput {\n required string targetId = 1;\n required int64 dataTime = 2;\n optional int32 conversationType= 3;\n optional string busChannel = 4;\n }\n message CleanMsgBatchReq {\n repeated CleanHisMsgInput input = 1;\n }\n message HistoryMessageInput {\n required string targetId = 1;\n required int64 dataTime =2;\n required int32 size = 3;\n }\n\n message HistoryMessagesOuput {\n repeated DownStreamMessage list = 1;\n required int64 syncTime = 2;\n required int32 hasMsg = 3;\n optional int64 credibleStartTime = 4;\n optional int64 credibleEndTime = 5;\n optional bool compressioEnabled = 6; \n optional bytes compressedData = 7;\n }\n message QueryChatRoomInfoInput {\n required int32 count= 1;\n optional int32 order= 2;\n }\n\n message QueryChatRoomInfoOutput {\n optional int32 userTotalNums = 1;\n repeated ChrmMember userInfos = 2;\n }\n message ChrmMember {\n required int64 time = 1;\n required string id = 2;\n }\n message MPFollowInput {\n required string id = 1;\n }\n\n message MPFollowOutput {\n required int32 nothing = 1;\n optional MpInfo info =2;\n }\n\n message MCFollowOutput {\n required int32 nothing = 1;\n optional MpInfo info =2;\n }\n\n message MpInfo {\n required string mpid=1;\n required string name = 2;\n required string type = 3;\n required int64 time=4;\n optional string portraitUrl=5;\n optional string extra =6;\n }\n\n message SearchMpInput {\n required int32 type=1;\n required string id=2;\n }\n\n message SearchMpOutput {\n required int32 nothing=1;\n repeated MpInfo info = 2;\n }\n\n message PullMpInput {\n required int64 time=1;\n required string mpid=2;\n }\n\n message PullMpOutput {\n required int32 status=1;\n repeated MpInfo info = 2;\n }\n message HistoryMsgInput {\n optional string targetId = 1;\n optional int64 time = 2;\n optional int32 count = 3;\n optional int32 order = 4;\n optional string busChannel = 5;\n optional bool compressioEnabled = 6;\n optional bool ignoreCmd = 10;\n }\n\n message HistoryMsgOuput {\n repeated DownStreamMessage list=1;\n required int64 syncTime=2;\n required int32 hasMsg=3;\n optional int64 credibleStartTime = 4;\n optional int64 credibleEndTime = 5;\n optional bool compressioEnabled = 6;\n optional bytes compressedData = 7;\n }\n message SessionsAttQryInput {\n required int32 nothing = 1;\n }\n message SessionsAttOutput {\n required int64 inboxTime = 1;\n required int64 sendboxTime = 2;\n required int64 totalUnreadCount = 3;\n }\n message SessionMsgReadInput {\n required ChannelType type = 1;\n required int64 msgTime = 2;\n required string channelId = 3;\n optional string busChannel = 4;\n }\n message SessionMsgReadOutput {\n optional int32 nothing=1;\n }\n message DeleteSessionsInput {\n repeated SessionInfo sessions = 1;\n }\n message SessionInfo {\n required ChannelType type = 1;\n required string channelId = 2;\n optional int64 unreadCount = 3;\n optional string busChannel = 4;\n }\n message QuerySessionsInput {\n repeated SessionInfo sessions = 1;\n }\n message QuerySessionsOutPut {\n repeated SessionInfo sessions = 1;\n }\n message DeleteSessionsOutput {\n optional int32 nothing=1;\n }\n message RelationDelBatchReq {\n repeated RelationOpInput relation = 1;\n optional bool cleanMsg = 2;\n }\n message RelationOpInput {\n required string conversationId = 1;\n required ChannelType conversationType = 2;\n optional string busChannel = 3;\n }\n message DeleteMsgInput {\n optional ChannelType type = 1;\n optional string conversationId = 2;\n repeated DeleteMsg msgs = 3;\n optional string busChannel = 4;\n }\n message DeleteMsg {\n optional string msgId = 1;\n optional int64 msgDataTime = 2;\n optional int32 direct = 3;\n }\n message ChrmKVEntity {\n required string key = 1;\n required string value = 2;\n optional int32 status = 3;\n optional int64 timestamp = 4;\n optional string uid = 5;\n optional int64 version = 6;\n }\n message SetChrmKV {\n required ChrmKVEntity entry = 1;\n optional bool bNotify = 2;\n optional UpStreamMessage notification = 3;\n optional ChannelType type = 4;\n }\n message SetChrmKVS {\n repeated ChrmKVEntity entry = 1;\n optional bool bNotify = 2;\n optional UpStreamMessage notification = 3;\n optional ChannelType type = 4;\n }\n message DeleteChrmKVS {\n repeated ChrmKVEntity entry = 1;\n optional bool bNotify = 2;\n optional UpStreamMessage notification = 3;\n optional ChannelType type = 4;\n }\n message ChrmKVOutput {\n repeated ChrmKVEntity entries = 1;\n optional bool bFullUpdate = 2;\n optional int64 syncTime = 3;\n optional bool compressioEnabled = 4; \n optional bytes compressedData = 5;\n }\n message ChrmKVSVersionEntity {\n optional int64 version = 1;\n optional string key = 2;\n }\n\n message ChrmKVSOutput {\n repeated ChrmKVSOutputEntity errorKeys = 1;\n repeated ChrmKVSVersionEntity keysVersion = 2;\n }\n message ChrmKVSOutputEntity {\n optional string key = 1;\n optional int32 errorCode = 2;\n }\n message QueryChrmKV {\n required int64 timestamp = 1;\n optional bool compressioEnabled = 2;\n }\n message SetUserSettingInput {\n required int64 version=1;\n required string value=2;\n optional bool ignoreVersion = 3;\n }\n message SetUserSettingOutput {\n required int64 version=1;\n required bool reserve=2;\n optional bool updateVersion = 3;\n }\n message PullUserSettingInput {\n required int64 version=1;\n optional bool reserve=2;\n optional int32 ipType = 3;\n }\n message PullUserSettingOutput {\n repeated UserSettingItem items = 1;\n required int64 version=2;\n }\n message UserSettingItem {\n required string targetId= 1;\n required ChannelType type = 2;\n required string key = 4;\n required bytes value = 5;\n required int64 version=6;\n required int32 status=7;\n repeated SessionTagItem tags= 8;\n }\n message SessionReq {\n required int64 time = 1;\n }\n message SessionStates {\n required int64 version=1;\n repeated SessionState state= 2;\n }\n message SessionState {\n required ChannelType type = 1;\n required string channelId = 2;\n optional int64 time = 3;\n repeated SessionStateItem stateItem = 4;\n optional string busChannel = 5;\n }\n message SessionStateItem {\n required SessionStateType sessionStateType = 1;\n required string value = 2;\n repeated SessionTagItem tags = 3;\n optional int64 time = 4;\n }\n enum SessionStateType {\n IsSilent = 1;\n IsTop = 2;\n Tags = 3;\n AutoTrans = 4;\n }\n message SessionStateModifyReq {\n required int64 version=1;\n repeated SessionState state= 2;\n optional bool ignoreVersion = 3;\n }\n message GroupUnpushQuery {\n optional string busChannel = 1;\n }\n message GroupUnpushSet{\n optional string busChannel = 1;\n required int32 unpushLevel = 2;\n }\n message GroupUnpushResult {\n required string groupId = 1;\n optional string busChannel = 2;\n required int32 unpushLevel = 3;\n }\n message SessionStateModifyResp {\n required int64 version=1;\n optional bool updateVersion = 2;\n }\n message TypeUnpushInput {\n required ChannelType type = 1;\n required int64 version = 2;\n required int32 unpushLevel = 3;\n optional bool ignoreVersion = 4;\n }\n message TypeUnpushOutput {\n required int64 version = 1;\n optional bool updateVersion = 2;\n }\n message GrpReadReceiptMsg {\n repeated string msgId=1;\n optional string channelId = 2;\n }\n message GrpReadReceiptQryReq {\n repeated string msgId=1;\n optional string channelId = 2;\n }\n message ReadReceipt {\n optional string targetId = 1;\n optional int32 type = 2;\n optional string channelId = 3;\n optional int32 readType =4 ;\n repeated string msgIds= 5 ;\n optional string fromId = 6;\n }\n message QueryReceiptReq {\n optional string targetId = 1;\n optional string busChannel =2;\n optional int32 type = 3;\n repeated string msgIds = 4;\n optional int32 qryType = 5;\n optional int32 order =6;\n optional bool compress = 7;\n optional int32 readType = 8;\n optional int32 pageType = 9; \n optional int32 pageSize = 10;\n optional string pageToken = 11;\n repeated string users = 12;\n }\n message QueryReceiptBatchReq {\n repeated QueryReceipt items = 1;\n optional bool compress = 2;\n }\n message QueryReceipt {\n optional string targetId = 1;\n optional string busChannel = 2;\n optional int32 type = 3;\n repeated string msgIds = 4;\n }\n message ReceiptResp {\n repeated QueryReceiptRespItem resp = 1;\n optional bool compress = 2;\n optional bytes compressData = 3;\n optional string pageToken = 4;\n }\n message QueryReceiptBatchResp {\n repeated QueryReceiptBatchRespItem item = 1;\n optional bool compress = 2;\n optional bytes compressData = 3;\n }\n\n message QueryReceiptBatchRespItem {\n optional string targetId = 1;\n optional string busChannel = 2;\n optional int32 type = 3;\n repeated QueryReceiptRespItem msg = 4;\n }\n message QueryReceiptRespItem {\n optional string msgId = 1;\n optional int64 msgTime = 2;\n optional int32 totalCnt = 3;\n optional int64 readCnt = 4;\n repeated ReceiptUser readUser = 5;\n repeated string unreadList = 6;\n optional int64 unreadCnt = 7;\n repeated ReceiptUser unreadUser = 8;\n }\n message GrpReadReceiptQryResp {\n required int32 totalMemberNum = 1;\n repeated GrpMsgReadUser list = 2;\n }\n message GrpMsgReadUser {\n required int64 readTime = 1;\n required string userId = 2;\n }\n message SessionTagAddInput {\n required int64 version=1;\n repeated SessionTagItem tags=2;\n optional bool ignoreVersion = 3;\n }\n message SessionTagItem {\n required string tagId=1;\n optional string name=2;\n optional int64 createdTime=3;\n optional bool isTop=4;\n }\n message SessionTagDelInput {\n required int64 version=1;\n repeated SessionTagItem tags=2;\n optional bool ignoreVersion = 3;\n }\n message SessionDisTagReq {\n repeated string tagId=1;\n }\n message UserSettingNotification {\n required int64 version=1;\n required bool reserve=2;\n }\n message ReportSDKInput {\n required string sdkInfo=1;\n }\n message ReportSDKOutput {\n optional int32 nothing=1;\n }\n message UltraGrpPullSes {\n required int64 syncTime = 1;\n optional bool isEraseMsgContent = 2;\n }\n message UltraGrpPullMsg {\n required int64 syncTime = 1;\n optional bool compressioEnabled = 2;\n }\n message MsgChangeReq {\n required string fromUserId = 1;\n required string targetId = 2;\n required ChannelType type = 3;\n required string msgUID = 4;\n required int64 msgTime = 5;\n optional string busChannel = 6;\n optional string content = 7;\n }\n message ModifyMsgResp {\n optional int64 modifyTime = 1;\n optional DownStreamMessage msg = 2;\n }\n message QueryMsgChange {\n required int64 syncTime = 1;\n optional int32 needCompress = 2;\n optional int64 onlineTime = 3;\n optional string targetId = 4;\n }\n message EventChangeList {\n repeated EventChange list = 1;\n required int64 syncTime = 2;\n optional bool hasNext = 3 ;\n optional string targetId = 4;\n optional bool isCompress = 5 ;\n }\n message EventChange {\n optional string businessId = 1;\n optional ChannelType channelType = 2;\n optional int64 time = 3;\n optional int32 changeType = 4;\n optional string originalId = 5;\n optional int64 originalTime = 6;\n optional string secondaryId = 7;\n optional bool isAdmin = 8;\n optional bool additionalMark = 9; \n optional string operatorId = 10;\n optional int32 subChangeType = 11;\n optional int32 secondaryType = 12;\n optional bool isRemindMe = 13;\n repeated string extIds = 14;\n optional int32 remindType = 15;\n optional bytes eventData = 16;\n }\n message MsgChangeList {\n repeated MsgChange list = 1;\n required int64 syncTime = 2;\n optional bool hasNext = 3 ;\n }\n message MsgChange {\n required string targetId = 1;\n required ChannelType type = 2;\n required int64 time = 3;\n required int32 changeType = 4;\n required string msgUID = 5;\n required int64 msgTime = 6;\n optional string busChannel = 7;\n optional bool isAdmin = 8;\n optional bool isDel = 9;\n optional string operatorId = 10;\n optional int32 subChangeType = 11;\n optional int32 busChannelType = 12;\n optional bool isRemindMe = 13;\n repeated string userGroupIds = 14;\n optional int32 remindType = 15;\n }\n message MsgQuery {\n required string targetId = 1;\n required ChannelType type = 2;\n repeated MessageQueryInfo query = 3; //\n }\n message MessageQueryInfo {\n required int64 msgTime = 1;\n required string msgUID = 2;\n optional string busChannel = 3;\n }\n message MsgQueryAck {\n repeated DownStreamMessage list = 1;\n repeated string notExistMsgId = 2;\n }\n message OperateStatus {\n optional string targetId = 1;\n optional ChannelType type = 2;\n optional int32 opType = 3;\n optional string busChannel = 4;\n }\n message OperateStatusNotify {\n optional ChannelType type = 1;\n optional int64 notifyType = 2;\n repeated OperateInfo info = 3 ;\n repeated OperateSummary summary = 4 ;\n }\n message OperateInfo {\n optional string targetId = 1;\n optional string busChannel = 2;\n optional string userId = 3;\n optional int32 opType = 4;\n optional int64 optime = 5;\n }\n \n message OperateSummary {\n optional string targetId = 1;\n optional string busChannel = 2;\n optional int32 count = 3;\n optional int32 opType = 4;\n }\n\n message SetRtcRoomIdInput {\n required string rtcRoomId= 1;\n }\n message SetRtcRoomIdOutput {\n required int32 nothing = 1;\n }\n message CallInfoUpStream {\n required string key= 1;\n required string dataContent=2;\n }\n message CallInfoDownStream {\n required string key= 1;\n required string dataContent=2;\n required int64 maxTime=3;\n }\n message KvInput {\n required int64 syncTime = 1;\n }\n message KvOutput {\n required int64 maxTime = 1;\n repeated KvInfo info = 2;\n }\n message KvInfo {\n required string key =1;\n required string value =2;\n }\n message ReadReceiptMsg {\n required string targetId = 1;\n required ChannelType type = 2;\n optional string busChannel = 3;\n optional string startMsgId = 4;\n optional string endMsgId = 5;\n }\n message ReceiptQryReq {\n required string msgId = 1;\n optional string busChannel = 2;\n required string targetId = 3;\n }\n message QueryReceiptResp {\n optional int32 num = 1;\n repeated ReceiptUser list = 2;\n optional int32 readCnt = 3;\n }\n message ReceiptUser {\n optional int64 receiptTime = 1;\n optional string userId = 2;\n optional string name = 3;\n optional string portrait = 4;\n optional bool mentioned= 5;\n }\n message ReceiptCntQryReq {\n optional ChannelType type = 1;\n optional string channelId = 2;\n optional string busChannel = 3;\n repeated string msgId = 4;\n }\n message ReceiptCntQryResp {\n repeated MsgReadCnt result= 1;\n }\n\n message MsgReadCnt {\n optional string msgId = 1;\n optional int32 cnt = 2;\n optional int32 tmn = 3;\n }\n message UpdateUserSubReq {\n optional int32 subType = 1;\n repeated UserSubDetail subUsers = 2;\n optional int32 opType = 3;\n optional int32 expiry = 4;\n }\n message UserSubDetail {\n optional string subUserId = 1;\n }\n message UpdateUserSubResp {\n repeated UserSubDetail subUsers = 1;\n optional int64 subTime = 2;\n }\n message PullUserSubReq {\n optional int64 version = 1;\n optional string pageToken = 2;\n }\n message PUllUserSubResp {\n repeated UserSubList list = 1;\n optional int64 version = 2;\n optional bool hasNext = 3;\n optional string pageToken = 4;\n optional bool isFull = 5;\n }\n message UserSubList {\n repeated UserSubDetail subUsers = 1;\n optional int32 subType = 2;\n optional int64 subTime = 3;\n optional int32 expiry = 4;\n optional int32 opType = 5;\n }\n message PullSubDataReq {\n optional int64 versionTime = 1;\n optional bool needAllData = 2;\n optional string pageToken = 3;\n }\n message PullSubDataResp {\n repeated SubDataDetail list = 1;\n optional int64 versionTime = 2;\n optional bool hasNext = 3;\n optional string pageToken = 4;\n optional bool isFull = 5;\n }\n message SubDataDetail {\n optional string statusStr = 1;\n optional string subUserId = 2;\n repeated SubData data = 3;\n optional int32 subType = 4;\n }\n\n message SubData {\n optional int32 platformInfo = 1;\n optional int32 value = 2;\n optional int64 versionTime = 3;\n }\n message QrySubDataReq {\n optional int32 subType = 1;\n repeated UserSubDetail subUsers = 2;\n }\n message UserProfile {\n optional int64 version = 1;\n optional string userId = 2;\n repeated ProfileInfo userProfile = 3;\n repeated ProfileInfo userExtProfile = 4;\n }\n message ProfileInfo {\n optional string key = 1;\n optional string value = 2;\n }\n message SetUserProfileResp {\n optional int64 version = 1;\n optional string key = 2;\n repeated string censorFailedFields = 3;\n }\n message PullUserProfileReq {\n repeated string userId = 1;\n }\n message UserProfiles {\n repeated UserProfile UserProfile = 1;\n }\n message UserProfileInput {\n required int32 nothing = 1;\n }\n message UserProfilePermission {\n optional int32 permission = 1;\n }\n message UserProfileOutput {\n required int32 nothing = 1;\n }\n message SearchUserProfile {\n optional string uniqueId = 1;\n }\n message ChannelsInput {\n optional string targetId = 1;\n optional ChannelType type = 2;\n repeated ProfileInfo settingProfile = 3;\n repeated ProfileInfo extProfile = 4;\n optional ChannelBaseInfo baseInfo = 5;\n repeated string users = 6;\n }\n\n message ChannelBaseInfo {\n optional string creatorId = 1;\n optional string ownerId = 2;\n optional int64 createTime = 3;\n optional int32 memberCount = 4;\n }\n\n message ChannelsOutput {\n optional int64 operateTime = 1;\n optional int32 flag = 2;\n optional string msg = 3;\n optional int32 processCode = 4;\n optional ChannelsJoinedInfo channelInfo = 5;\n repeated ChannelsUserInfo userInfos = 6;\n optional FriendInviteInfo friendInviteInfo = 7;\n optional FriendUserInfo friendUserInfo = 8;\n repeated string censorFailedFields = 9;\n }\n\n message MultiChannels {\n optional ChannelType type = 1;\n repeated ChannelsInput list = 2;\n }\n\n message ModifyChannelsInput {\n optional string targetId = 1;\n optional ChannelType type = 2;\n optional QuitChannelsSetting settingInfo = 3;\n repeated string users = 4;\n optional int32 operateType = 5;\n }\n\n message QuitChannelsSetting {\n optional bool isQuit = 1;\n optional bool isDelBan = 2;\n optional bool isDelWhite = 3;\n optional bool isDelAttention = 4;\n }\n\n message ChannelsQueryInput {\n optional string targetId = 1;\n optional ChannelType type = 2;\n optional ChannelsPageParam page = 3;\n repeated string ids = 4;\n optional int32 roleType = 5;\n }\n\n message ChannelsPageParam {\n optional int32 size = 1;\n optional string pageToken = 2;\n optional bool hasNext = 3 ;\n optional int32 total = 4 ;\n optional int32 order = 5 ;\n }\n\n message ChannelsListResult {\n optional int32 listType = 1;\n optional bytes result = 2;\n optional ChannelsPageParam page = 3;\n }\n \n message ChannelsInviteStatusInfos {\n repeated ChannelsInviteStatusInfo list = 1;\n }\n \n message ChannelsUserInfos {\n repeated ChannelsUserInfo list = 1;\n }\n \n message ChannelsJoinedInfos {\n repeated ChannelsJoinedInfo list = 1;\n }\n\n message ChannelsUserInfo {\n optional string userId = 1;\n optional ChannelsUserExtInfo ext = 2;\n optional int64 opTime = 3;\n optional string name = 4;\n optional string portraitUrl = 5;\n }\n\n message ChannelsUserExtInfo {\n optional int32 role = 1;\n optional int64 joinTime = 2;\n optional string channelNickName = 3;\n optional string additional = 4;\n optional string remarkName = 5;\n optional bool isBan = 6;\n optional int64 banEndTime = 7;\n }\n\n message ChannelsMemberUpdateInput {\n optional string targetId = 1;\n optional ChannelType type = 2;\n optional string userId = 3;\n optional string channelNickName = 4;\n optional string additional = 5;\n optional int32 operateType = 6;\n }\n message ChannelsJoinedInfo {\n optional string targetId = 1;\n repeated ProfileInfo settingProfile = 2;\n repeated ProfileInfo extProfile = 3;\n optional ChannelBaseInfo baseInfo = 4;\n optional ChannelsUserExtInfo userInfo = 5;\n }\n message ChannelsInviteStatusInfo {\n optional string targetId = 1;\n optional ChannelsUserInfo joinUserInfo = 2;\n optional ChannelsUserInfo inviterInfo = 3;\n optional int32 status = 4;\n optional int32 directionType = 5;\n optional int32 joinType = 6;\n optional string detail = 7;\n optional int64 applyTime = 8;\n optional ChannelsUserInfo processInfo = 9;\n optional int64 processTime = 10;\n }\n message ChannelsMemberResponseInput {\n optional string targetId = 1;\n optional ChannelType type = 2;\n optional int32 optType = 3;\n optional int32 optResult = 4;\n optional string joinUserId = 5;\n optional string inviterId = 6;\n optional string detail = 7;\n }\n message ChannelsMembersInput {\n optional string targetId = 1;\n optional ChannelType type = 2;\n repeated string userIds = 3;\n }\n message FriendInput {\n optional string targetId = 1;\n optional int32 type = 2;\n optional string info = 3;\n }\n message FriendsOutput {\n repeated FriendOutput list = 1;\n }\n message FriendOutput {\n optional string userId = 1;\n optional int64 operateTime = 2;\n optional string flag = 3;\n }\n message FriendsInput {\n repeated string targetId = 1;\n optional int32 type = 2;\n }\n message FriendsCheckOutput {\n repeated FriendCheckOutput list = 1;\n }\n\n message FriendCheckOutput {\n optional string targetId = 1;\n optional int32 status = 2;\n }\n message FriendProfileInput {\n optional string targetId = 1;\n optional string remarkName = 2;\n repeated ProfileInfo extProfile = 3;\n }\n message FriendProfileOutput {\n repeated string censorFailedFields = 1;\n }\n message FriendQueryInput {\n optional int32 queryType = 1;\n optional ChannelsPageParam page = 2;\n optional int32 friendType= 3;\n }\n message FriendUserInfo {\n optional string userId = 1;\n optional int64 relationTime = 2;\n optional int32 friendType = 3;\n optional int32 flag = 4;\n optional string remarkName = 5;\n optional string name = 6;\n optional string portraitUrl = 7;\n repeated ProfileInfo extProfile = 8;\n \n }\n message FriendInviteInfo {\n optional string userId = 1;\n optional string name = 2;\n optional string portraitUrl = 3;\n optional int32 type = 4;\n optional int32 status = 5;\n optional int64 operateTime = 6;\n optional string info = 7;\n optional int32 friendType = 8;\n }\n message FriendsListInput {\n repeated string targetId = 1;\n optional int32 type = 2;\n }\n message FriendLevelSet {\n optional int32 level = 1;\n }\n\n message FriendPageParam {\n optional int32 size = 1;\n optional string pageToken = 2;\n }\n message FriendUserInfos {\n repeated FriendUserInfo list = 1;\n }\n\n message FriendInviteInfos {\n repeated FriendInviteInfo list = 1;\n }\n \n message FriendApplyEvent {\n optional int32 applyType = 1;\n optional int32 friendType = 2;\n optional string info = 3;\n optional string name = 4;\n optional string portraitUrl = 5;\n }\n message UpdateChannnelInfo {\n optional ChannelsJoinedInfo channelInfo = 1;\n optional ChannelsUserInfo userInfo = 2;\n }\n message UpdateUserInfo {\n optional ChannelsUserInfo updatedUserInfo = 1;\n optional ChannelsUserInfo optUserInfo = 2;\n }\n message ChannelApplyInfo {\n repeated ChannelsInviteStatusInfo statusInfo = 1;\n }\n message ChannelEventData {\n optional ChannelsUserInfo optUserInfo = 1;\n optional ChannelsJoinedInfo channelInfo = 2;\n repeated ChannelsUserInfo userInfos = 3;\n optional ChannelsJoinedInfo channelFullInfo = 4;\n }\n message FriendTypeChangeEvent {\n optional string friendId = 1;\n optional int32 friendType = 2;\n }\n message FriendUpdateEvent {\n optional string remarkname = 1;\n repeated ProfileInfo extProfile = 2;\n }\n message AddUnpushPeriodInput {\n required string startTime = 1;\n required int32 spanMinutes = 2;\n optional int32 level = 3;\n optional string timezone = 4;\n }\n message DeleteUnpushPeriodInput {\n required int32 nothing = 1;\n }\n message QueryUnpushPeriodInput {\n required int32 nothing = 1;\n }\n message QueryUnpushPeriodOutput {\n required int32 isUnpush = 1;\n optional string startTime = 2;\n optional int32 spanMinutes = 3;\n optional int32 level = 4;\n optional string timezone = 5;\n }\n message RelationDel {\n optional string targetId = 1;\n optional ChannelType type = 2;\n repeated string busChannel = 3;\n optional bool cleanMsg = 4;\n }\n message MsgReadEvent {\n optional string msgId = 1;\n optional int64 msgTime = 2;\n optional int32 totalCnt = 3;\n optional int32 readCnt = 4;\n optional int32 unreadCnt = 5;\n repeated ReceiptUser readList =6;\n }\n message ConvertMsgInput {\n optional int32 businessType = 1;\n optional bytes businessInfo = 2;\n }\n message SpeechToTextInfo {\n optional string msgId = 1;\n optional string objectName = 2;\n optional string content = 3;\n optional int32 sampleRate = 4;\n optional int32 channelNumber = 5;\n optional string format = 6;\n optional string extra = 7;\n }\n message ConvertMsgOutput {\n optional int32 businessType = 1;\n optional bytes businessResult = 2;\n }\n message SpeechToTextResult {\n optional string result = 1;\n optional string message = 2;\n }\n message TransReq {\n repeated TransInfo transInfos = 1;\n optional int32 model = 2;\n optional bool forceTrans = 3;\n }\n message TransResp {\n repeated TransResult results = 1;\n optional int32 model = 2;\n }\n message TransInfo {\n optional string messageUID = 1;\n optional int32 transType = 2;\n optional string text = 3;\n optional string transFileUrl = 4;\n optional string sourceLan = 5;\n optional string targetLan = 6;\n optional int32 inputSource = 7;\n }\n message TransResult {\n optional string messageUID = 1;\n optional string transResult = 2;\n optional string sourceLan = 3;\n optional string targetLan = 4;\n optional int32 code = 5;\n optional int32 inputSource = 6;\n }\n message PullModifyMsgReq { \n optional int64 pullVersion = 1;\n optional bool compress = 2;\n repeated int32 modifyType = 3;\n }\n message PullModifyMsgResp {\n repeated ModifyMsg msg = 1;\n optional int64 nextVersion = 2;\n optional bool finished = 3;\n optional bool compress = 4;\n optional bytes compressedData = 5;\n }\n message ModifyMsg {\n optional int32 modifyType = 1;\n optional DownStreamMessage msg = 2;\n }\n enum JoinType {\n KICK = 0;\n REFUSE = 1;\n COEXIST = 2;\n }\n enum TargetType {\n ROOM =1 ;\n PERSON = 2;\n }\n message SetUserStatusInput {\n optional int32 status=1;\n }\n message MCFollowInput {\n required string state = 1;\n }\n message RtcQueryListInput {\n optional int32 order=1;\n }\n message RtcKeyDeleteInput {\n repeated string key=1;\n }\n message RtcValueInfo {\n required string key=1;\n required string value=2;\n }\n message RtcUserInfo {\n required string userId=1;\n repeated RtcValueInfo userData=2;\n }\n message RtcUserListOutput {\n repeated RtcUserInfo users=1;\n optional string token=2;\n optional string sessionId=3;\n repeated RtcValueInfo roomInfo = 4;\n repeated RtcKVEntity entries = 5;\n optional int64 syncTime = 6;\n optional int32 offlineKickTime = 7;\n }\n message RtcRoomInfoOutput {\n optional string roomId = 1;\n repeated RtcValueInfo roomData = 2;\n optional int32 userCount = 3;\n repeated RtcUserInfo list=4;\n }\n message RtcInput {\n required int32 roomType=1;\n optional int32 broadcastType=2;\n optional RtcValueInfo extraInnerData = 3;\n optional bool needSysChatroom = 4;\n optional IdentityChangeType identityChangeType = 5;\n optional JoinType joinType = 6;\n repeated RtcValueInfo innerDatas = 7;\n repeated RtcValueInfo outerDatas = 8;\n }\n message RtcQryOutput {\n repeated RtcValueInfo outInfo=1;\n }\n message RtcDataInput {\n required bool interior=1;\n required TargetType target=2;\n repeated string key=3;\n optional string objectName=4;\n optional string content=5;\n }\n message RtcSetDataInput {\n required bool interior=1;\n required TargetType target=2;\n required string key=3;\n required string value=4;\n optional string objectName=5;\n optional string content=6;\n }\n message RtcUserSetDataInput {\n repeated RtcValueInfo valueInfo = 1;\n required string objectName = 2;\n repeated RtcValueInfo content = 3;\n }\n message RtcQryInput {\n required bool isInterior=1;\n required TargetType target=2;\n repeated string key=3;\n }\n message RtcDelDataInput {\n repeated string key=1;\n required bool isInterior=2;\n required TargetType target=3;\n }\n message RtcOutput {\n optional int32 nothing=1;\n optional int64 version=2;\n }\n message RtcTokenOutput {\n required string rtcToken=1;\n }\n message RtcSetOutDataInput {\n required TargetType target=1;\n repeated RtcValueInfo valueInfo=2;\n optional string objectName=3;\n optional string content=4;\n }\n message RtcQryUserOutDataInput {\n repeated string userId = 1;\n }\n message RtcUserOutDataOutput {\n repeated RtcUserInfo user = 1;\n }\n message RtcNotifyMsg {\n required int32 type= 1;\n optional int64 time= 2;\n optional string roomId=3;\n }\n message RtcPullKV {\n required int64 timestamp = 1;\n required string roomId = 2;\n }\n message RtcKVEntity {\n required string key = 1;\n required string value = 2;\n optional int32 status = 3;\n optional int64 timestamp = 4;\n optional string uid = 5;\n }\n message RtcKVOutput {\n repeated RtcKVEntity entries = 1;\n optional bool bFullUpdate = 2;\n optional int64 syncTime = 3; \n }\n enum IdentityChangeType {\n AnchorToViewer = 1;\n ViewerToAnchor = 2;\n }\n message RtcQueryUserJoinedInput {\n required string userId = 1;\n }\n message RtcJoinedInfo {\n required string deviceId = 1;\n required string roomId = 2;\n optional int64 joinTime = 3;\n }\n message RtcQueryUserJoinedOutput {\n repeated RtcJoinedInfo info = 1;\n }\n message RtcViewerJoinedOutput {\n required string rtcToken=1;\n repeated RtcKVEntity entries = 2;\n optional int64 syncTime = 3;\n }\n message RtcInviteInput {\n required string invitedUserId=1;\n optional int32 timeoutTime=2;\n required string invitedRoomId=3;\n required string inviteInfo=4;\n required string inviteSessionId= 5;\n }\n message RtcCancelInviteInput {\n required string invitedUserId=1;\n required string invitedRoomId=2;\n required string inviteInfo=3;\n required string inviteSessionId=4;\n }\n message RtcInviteAnswerInput {\n required string inviteUserId=1;\n required int32 answerCode=2;\n required string inviteRoomId=3;\n required string inviteSessionId=4;\n required string content=5;\n optional string key=6;\n optional string value=7;\n }\n message RtcEndInviteInput {\n required string inviteRoomId=1;\n required string inviteSessionId=2;\n required string inviteContent=3;\n repeated string inviteRoomKeys=4;\n }\n}\n");class kl{constructor(e){Object.defineProperty(this,"pbCodec",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.pbCodec=new Al(e)}encode(e,t,i){return i?t:this.pbCodec.encode(e,t)}decode(e,t){return this.pbCodec.decode(e,t)}}const xl="rtcRJoin_data",Bl="rtcRExit",Vl="rtcRInfo",Gl="rtcUData",Fl="rtcUDel",jl="rtcSetData",Hl="userSetData",Jl="rtcQryData",$l="rtcDelData",Kl="rtcToken",Yl="rtcUserState",ql="rtcUList",Wl="viewerJoinR",zl="viewerExitR",Ql="rtcPullKv",Zl="rtcIdentityChange",Xl="rtcInvite",e_="rtcCancelInvite",t_="rtcInviteAnswer",i_="rtcEndInvite",r_="rtcQueryJoined",n_="rtcPullRoomStatus",s_="reportsdk",o_="rtcPing";var a_;!function(e){e.RtcInput="RtcInput",e.RtcOutput="RtcOutput",e.RtcUserListOutput="RtcUserListOutput",e.SetUserStatusInput="SetUserStatusInput",e.RtcSetDataInput="RtcSetDataInput",e.RtcUserSetDataInput="RtcUserSetDataInput",e.RtcDataInput="RtcDataInput",e.RtcSetOutDataInput="RtcSetOutDataInput",e.MCFollowInput="MCFollowInput",e.RtcTokenOutput="RtcTokenOutput",e.RtcQryOutput="RtcQryOutput",e.RtcQryUserOutDataInput="RtcQryUserOutDataInput",e.RtcUserOutDataOutput="RtcUserOutDataOutput",e.RtcQueryListInput="RtcQueryListInput",e.RtcRoomInfoOutput="RtcRoomInfoOutput",e.RtcValueInfo="RtcValueInfo",e.RtcKeyDeleteInput="RtcKeyDeleteInput",e.RtcNotifyMsg="RtcNotifyMsg",e.RtcPullKV="RtcPullKV",e.RtcKVOutput="RtcKVOutput",e.RtcQueryUserJoinedInput="RtcQueryUserJoinedInput",e.RtcQueryUserJoinedOutput="RtcQueryUserJoinedOutput",e.RtcViewerJoinedOutput="RtcViewerJoinedOutput",e.RtcInviteInput="RtcInviteInput",e.RtcCancelInviteInput="RtcCancelInviteInput",e.RtcInviteAnswerInput="RtcInviteAnswerInput",e.RtcEndInviteInput="RtcEndInviteInput",e.RtcRoomStatusInput="RtcRoomStatusInput",e.RtcRoomStatusOutput="RtcRoomStatusOutput",e.RtcReportSDKInput="RtcReportSDKInput",e.RtcPBPolaris="RCRTCPBPolaris",e.RtcPBR1Info="RCRTCPBR1Info",e.RtcPBR2Info="RCRTCPBR2Info",e.RtcPBR3Info="RCRTCPBR3Info",e.RtcPBR4Info="RCRTCPBR4Info",e.RtcPBStatusInfo="RCRTCPBStatusInfo",e.RtcPBStreamInfo="RCRTCPBStreamInfo",e.AsrTextMsg="AsrTextMsg",e.AsrResTextMsg="AsrResTextMsg"}(a_||(a_={})),a_.RtcInput,a_.RtcOutput,a_.RtcUserListOutput,a_.SetUserStatusInput,a_.RtcSetDataInput,a_.RtcUserSetDataInput,a_.RtcDataInput,a_.RtcSetOutDataInput,a_.MCFollowInput,a_.RtcTokenOutput,a_.RtcQryOutput,a_.RtcQryUserOutDataInput,a_.RtcUserOutDataOutput,a_.RtcQueryListInput,a_.RtcRoomInfoOutput,a_.RtcValueInfo,a_.RtcKeyDeleteInput,a_.RtcNotifyMsg,a_.RtcPullKV,a_.RtcKVOutput,a_.RtcQueryUserJoinedInput,a_.RtcQueryUserJoinedOutput,a_.RtcInviteInput,a_.RtcCancelInviteInput,a_.RtcInviteAnswerInput,a_.RtcEndInviteInput,a_.RtcRoomStatusInput,a_.RtcRoomStatusOutput,a_.RtcReportSDKInput,a_.RtcPBPolaris,a_.RtcPBR1Info,a_.RtcPBR2Info,a_.RtcPBR3Info,a_.RtcPBR4Info,a_.RtcPBStatusInfo,a_.RtcPBStreamInfo,a_.AsrTextMsg,a_.AsrResTextMsg;const l_=`\npackage Modules;\nmessage probuf {\n enum JoinType {\n KICK = 0; //踢前一个设备\n REFUSE = 1; //当前加入拒绝\n COEXIST = 2; //两个设备共存\n }\n enum targetType {\n ROOM =1 ;\n PERSON = 2;\n }\n message ${a_.SetUserStatusInput}\n {\n optional int32 status=1;\n }\n message ${a_.MCFollowInput}\n {\n required string state = 1;\n }\n message ${a_.RtcQueryListInput}{\n optional int32 order=1;\n }\n message ${a_.RtcKeyDeleteInput}{\n repeated string key=1;\n }\n message ${a_.RtcValueInfo}{\n required string key=1;\n required string value=2;\n }\n message RtcUserInfo{\n required string userId=1;\n repeated ${a_.RtcValueInfo} userData=2; //用户资源信息\n }\n message ${a_.RtcRoomStatusInput}{ // rtc 和 living room 拉房间资源状态使用的参数\n required int64 version =1; //当前客户端最大的房间状态的version\n }\n message ${a_.RtcRoomStatusOutput}{ // rtc 和 living room 拉房间资源状态返回的数据\n required bool bFullStatus =1; //标识此次给的数据是否是全量数据\n required int64 version =2; //当前获取后房间的最大版本号\n repeated RtcUserInfo usersData=3;//如果是全量数据,这个不为空,给的是房间全部的人以及发布的资源\n repeated RtcRoomStatus roomStatus=4;//房间增量数据\n }\n message RtcRoomStatus{ //房间状态变动\n required string userId = 1;//用户ID\n required int32 event = 2;//房间状态变更的event(人员加入/退出/离线/发布资源) (0:加入;1:离开;2:离线;3:资源变动) \n required int64 time = 3;//本次变更的版本号\n repeated RtcValueInfo userData = 4;//用户变更的资源(event为0或者3时可能有值)\n optional int32 switchRoleType = 5;//如果是切换角色导致的加入房间或退出房间的类型\n optional string extra = 6;\n }\n message ${a_.RtcUserListOutput}{\n repeated RtcUserInfo users=1;\n optional string token=2;\n optional string sessionId=3;\n repeated RtcValueInfo roomInfo = 4; //房间key value\n repeated RtcKVEntity entries = 5;//直播KV属性对象集合\n optional int64 syncTime = 6;//所有属性的最大时间戳(下次拉取KV时用)。\n optional int32 offlineKickTime = 7;//server超时踢人时间,默认60s\n repeated string codeFormat = 8; //当前房间用户支持的编码交集\n optional int64 roomCreateTime = 9;//房间创建时间\n optional int64 userJoinTime = 10;//用户加入房间\n optional int64 version = 11;//当前房间的版本号\n }\n message RtcRoomInfoOutput{\n optional string roomId = 1;\n repeated ${a_.RtcValueInfo} roomData = 2;\n optional int32 userCount = 3;\n repeated RtcUserInfo list=4;\n }\n message ${a_.RtcInput}{\n required int32 roomType=1;\n optional int32 broadcastType=2;\n optional RtcValueInfo extraInnerData = 3;\n optional bool needSysChatroom = 4; //是否需要同步聊天室\n optional IdentityChangeType identityChangeType = 5; //身份变更类型\n optional JoinType joinType = 6; // 加入房间类型\n repeated ${a_.RtcValueInfo} innerDatas = 7; //用户内部inner数据,角色或者连麦信息等\n repeated ${a_.RtcValueInfo} outerDatas = 8; //用户内部outer数据,自定义数据结构RtcInput。\n optional bool supportNtf = 9; //是否支持房间状态的变更通过通知拉取的方式获取\n }\n message ${a_.RtcQryOutput}{\n repeated ${a_.RtcValueInfo} outInfo=1;\n }\n message ${a_.RtcDataInput}{\n required bool interior=1;\n required targetType target=2;\n repeated string key=3;\n optional string objectName=4;\n optional string content=5;\n }\n message ${a_.RtcSetDataInput}{\n required bool interior=1;\n required targetType target=2;\n required string key=3;\n required string value=4;\n optional string objectName=5;\n optional string content=6;\n }\n message ${a_.RtcUserSetDataInput} {\n repeated ${a_.RtcValueInfo} valueInfo = 1;\n required string objectName = 2;\n repeated ${a_.RtcValueInfo} content = 3;\n }\n message RtcQryInput{\n required bool isInterior=1;\n required targetType target=2;\n repeated string key=3;\n }\n message RtcDelDataInput{\n repeated string key=1;\n required bool isInterior=2;\n required targetType target=3;\n }\n message RtcOutput\n {\n optional int32 nothing=1;\n optional int64 version=2;\n }\n message ${a_.RtcTokenOutput}{\n required string rtcToken=1;\n }\n message ${a_.RtcSetOutDataInput}{\n required targetType target=1;\n repeated ${a_.RtcValueInfo} valueInfo=2;\n optional string objectName=3;\n optional string content=4;\n }\n message ${a_.RtcQryUserOutDataInput}{\n repeated string userId = 1;\n }\n message ${a_.RtcUserOutDataOutput}{\n repeated RtcUserInfo user = 1;\n }\n message ${a_.RtcNotifyMsg} \n {\n required int32 type= 1; //(通知类型 1:rtc房间状态KV变更通知)\n optional int64 time= 2; //消息产生时间\n optional string roomId=3; //主播房间id\n }\n message ${a_.RtcPullKV}\n {\n required int64 timestamp = 1;\n required string roomId = 2;\n }\n message RtcKVEntity \n {\n required string key = 1;\n required string value = 2;\n optional int32 status = 3;\n optional int64 timestamp = 4;\n optional string uid = 5;\n }\n message ${a_.RtcKVOutput}\n {\n repeated RtcKVEntity entries = 1;\n optional bool bFullUpdate = 2;\n optional int64 syncTime = 3; \n }\n enum IdentityChangeType \n {\n AnchorToViewer = 1; //1为主播变观众\n ViewerToAnchor = 2; //2为观众变主播\n }\n message ${a_.RtcQueryUserJoinedInput}\n {\n required string userId = 1;\n }\n message RtcJoinedInfo\n {\n required string deviceId = 1; //设备ID\n required string roomId = 2; //加入的房间ID\n optional int64 joinTime = 3; //加入的时间\n }\n message ${a_.RtcQueryUserJoinedOutput}\n {\n repeated RtcJoinedInfo info = 1;\n }\n message ${a_.RtcViewerJoinedOutput}\n {\n required string rtcToken=1;\n repeated RtcKVEntity entries = 2;//KV属性对象集合\n optional int64 syncTime = 3;//所有属性的最大时间戳(下次拉取KV时用)。\n optional string sessionId=4;\n optional int64 roomCreateTime = 5;//房间创建时间\n optional int64 userJoinTime = 6;//用户加入房间\n }\n message ${a_.RtcInviteInput}\n {\n required string invitedUserId=1; //被邀请的人的uid\n optional int32 timeoutTime=2; //邀请超时时间(秒),默认三十秒\n required string invitedRoomId=3; //被邀请的房间\n required string inviteInfo=4; //邀请的信息(包含邀请人,被邀请人,各自userid)客户端定义好.协议栈和server透传\n required string inviteSessionId= 5; //客户端保证唯一性(建议roomid_userid_时间戳_随机数)\n }\n message ${a_.RtcCancelInviteInput}\n {\n required string invitedUserId=1; //被邀请的人的uid\n required string invitedRoomId=2; //被邀请的房间\n required string inviteInfo=3; //取消邀请的信息(包含邀请人,被邀请人,各自userid)客户端定义好.协议栈和server透传\n required string inviteSessionId=4; //邀请的sessionId,客户端发起邀请时产生\n }\n message ${a_.RtcInviteAnswerInput}\n {\n required string inviteUserId=1; //邀请的人的uid\n required int32 answerCode=2; //是否接受连麦邀请.0为拒绝,1为接受\n required string inviteRoomId=3; //邀请的房间\n required string inviteSessionId=4; //邀请的sessionId\n required string content=5; //需要转发的content\n optional string key=6; //如果接受的话,需要加这个字段,放在room级别的k和v,新加入房间的能拉取到\n optional string value=7; //如果接受的话,需要加这个字段,放在room级别的k和v,新加入房间的能拉取到\n }\n message ${a_.RtcEndInviteInput}\n {\n required string inviteRoomId=1; //邀请的房间\n required string inviteSessionId=2; //邀请的sessionId\n required string inviteContent=3; //结束连麦的信息(需要透传给房间内其他人)\n repeated string inviteRoomKeys=4; //需要删除连麦的信息的key\n }\n message ${a_.RtcReportSDKInput} {\n required string sdkInfo=1; // 用户集成的 sdk 信息,json 格式 {"web-rtc": "4.0.3.7"}\n }\n // ---- 北极星数据上报 -------\n message ${a_.RtcPBPolaris} {\n required string type = 1;//上报数据类型 R1-R4\n required string appKey = 2;\n required string sessionId = 3;//房间通话id\n required string roomId = 4;\n required int64 roomCreateTime = 5;//房间创建时间\n required string userId = 6;\n required int32 userRole = 7;\n required int64 joinTime = 8;\n required string signalDataCenter = 9;//signal数据中心\n optional ${a_.RtcPBR1Info} r1Info = 10;\n optional ${a_.RtcPBR2Info} r2Info = 11;\n optional ${a_.RtcPBR3Info} r3Info = 12;\n optional ${a_.RtcPBR4Info} r4Info = 13;\n }\n message ${a_.RtcPBR1Info} {\n required int64 joinTime = 1;//用户加入房间的时间\n required string rtcVersion = 2;//Rtc版本号\n required string imVersion = 3;//IM SDK 版本\n required string platform = 4;//平台(如:Android、iOS、Web)\n required string device = 5; //设备信息(手机名称+型号)\n required string os = 6;//系统版本(手机系统版本)\n optional string browserName = 7; //浏览器名称, 没有用 -1 表示\n optional string browserVersion = 8;//浏览器版本, 没有用 -1 表示\n optional int64 receiveTime = 9; // 发送数据的时间\n }\n message ${a_.RtcPBR2Info} {\n required int64 joinTime = 1;\n required int64 sendTime = 2;\n required string rtcActionType = 3;//发布类型 subscribe : 订阅 publish : 发布\n required string rtcActionStatus = 4;//发布状态 begin : 开始 tend : 结束\n repeated string trackId = 5;\n optional int64 receiveTime = 6; // 发送数据的时间\n }\n message ${a_.RtcPBR3Info} {\n required ${a_.RtcPBStatusInfo} info = 1;\n }\n message ${a_.RtcPBR4Info} {\n required ${a_.RtcPBStatusInfo} info = 1;\n }\n message ${a_.RtcPBStatusInfo} {\n optional int64 joinTime = 1;//用户加入房间的时间\n optional int64 receiveTime = 2;//用户发布数据流的时间(毫秒),暂时由客户端生成,后期如果有问题服务端做兜底处理\n optional int64 totalBitRate = 3;//总码率\n optional float appCPUUsage = 4;//APP CPU占用率\n optional float systemCPUUsage = 5;////系统 CPU占用率\n optional float systemCPUFrequency = 6;//系统CPU频率 (安卓8.0以上)\n optional string networkStatus = 7;//实时网络状态(2g、3g、4g、wifi)\n optional int32 googleRTTNetwork = 8;//Goog rtt 网络延迟\n optional string ipAddress = 9;//ip地址\n optional string useReceiveBroadBand = 10; //可接收带宽(单位: bit)\n optional string useSendBroadBand = 11;//可用发送带宽(单位: bit)\n optional string packetLossCount = 12;//丢包数\n repeated ${a_.RtcPBStreamInfo} streams = 13;\n }\n message ${a_.RtcPBStreamInfo} {\n required string trackId = 1;\n optional string codeName = 2;//编解码名称\n optional string volume = 3;//音频播放音量\n optional int32 samplingRate = 4; //音频采样率\n optional float bitRate = 5;//下行码率\n optional float packetLossRate = 6;\n optional int32 frameRate = 7;//视频接收帧率(单位:fps)\n optional string resolution = 8;//视频分辨率(格式:640*480)\n optional int64 blockTime = 9;//接收卡顿(间隔时间, 单位: ms)\n optional int32 jitterData = 10;//jitter数据抖动\n optional string nAckCount = 11;//nack数量\n optional string pliCount = 12; //PLI请求数\n optional int64 googleRTTTotalTime = 13; //googRtt往返时长\n optional int32 isReceiveFirstFrameRate = 14;//第一个关键帧是否正常收到\n optional string codeType = 15;//编码方式\n optional int32 isEnabled = 16; //当前流的状态是否可用\n }\n // ---- 北极星数据上报 -------\n message ${a_.AsrTextMsg} {\n optional int32 bms = 1; //开始转写的时间(毫秒)\n optional string t = 2; //翻译的内容\n optional bool isEnd = 3; //是否监测到完整语句\n optional string msgId = 4; //该消息的ID, 跟转写的msgId 需要一样;\n optional string lang = 5; //翻译的目标语言码\n }\n message ${a_.AsrResTextMsg} {\n optional int32 type = 1; //1 为语音识别,后续会扩展其它类型\n required string uid = 2; //对应转写的用户Id\n repeated ${a_.AsrTextMsg} asr = 3; //识别出的结果列表\n }\n}\n`,__=(e,t,i,r,n,s,o)=>{const a=n?Object.keys(n).map(t=>e.encode(a_.RtcValueInfo,{key:t,value:n[t]},!0)):void 0,l=s?Object.keys(s).map(t=>e.encode(a_.RtcValueInfo,{key:t,value:s[t]},!0)):void 0;return e.encode(a_.RtcInput,{roomType:t,broadcastType:i,joinType:r,innerDatas:a,outerDatas:l,supportNtf:o})},c_=(e,t)=>{const i=e.decode(a_.RtcUserListOutput,t),{users:r,token:n,sessionId:s,roomInfo:o,entries:a,offlineKickTime:l=60,codeFormat:_,roomCreateTime:c,userJoinTime:d,version:u}=i,h={};return j(r,e=>{const{userId:t,userData:i}=e,r={};j(i,e=>{const{key:t,value:i}=e;r[t]=i}),h[t]=r}),{users:h,token:n,sessionId:s,roomInfo:o,kvEntries:a,offlineKickTime:l,codeFormat:_,roomCreateTime:Ni(c),userJoinTime:Ni(d),version:u}};var d_,u_;!function(e){e[e.SUBTITLE=1]="SUBTITLE",e[e.TRANSLATION=2]="TRANSLATION"}(d_||(d_={}));class h_{constructor(e){Object.defineProperty(this,"context",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"roomCreateTime",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"userJoinTime",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"codec",{enumerable:!0,configurable:!0,writable:!0,value:new kl(l_)})}get logger(){return this.context.logger}joinRTCRoom(e,t,i,r,n,s,o){return I(this,void 0,void 0,function*(){const a=__(this.codec,t,i,r,n,s,o),{code:l,buffer:_}=yield this.context.rtcSignaling(e,xl,!0,a);let c;if(l===oe&&_){c=c_(this.codec,_);const{users:e,token:t,sessionId:i,roomInfo:r,kvEntries:n,offlineKickTime:s,roomCreateTime:o,userJoinTime:a,version:d}=c;return this.roomCreateTime=o,this.userJoinTime=a,{code:l,data:{users:e,token:t,sessionId:i,roomInfo:r,kvEntries:n,offlineKickTime:s,version:d}}}return{code:l,data:c}})}quitRTCRoom(e){return I(this,void 0,void 0,function*(){const t=this.codec.encode(a_.SetUserStatusInput,{status:0}),{code:i}=yield this.context.rtcSignaling(e,Bl,!0,t);return i})}getRTCRoomInfo(e){return I(this,void 0,void 0,function*(){const t=this.codec.encode(a_.RtcQueryListInput,{order:2}),{code:i,buffer:r}=yield this.context.rtcSignaling(e,Vl,!0,t);let n;return i===oe&&r&&(n=this.codec.decode(a_.RtcRoomInfoOutput,r)),{code:i,data:n}})}getRTCUserInfoList(e){return I(this,void 0,void 0,function*(){const t=this.codec.encode(a_.RtcQueryListInput,{order:2}),{code:i,buffer:r}=yield this.context.rtcSignaling(e,Gl,!0,t);let n;if(i===oe&&r){n={users:c_(this.codec,r).users}}return{code:i,data:n}})}getRTCUserInfo(e){throw new Error("Method not implemented.")}removeRTCUserInfo(e,t){return I(this,void 0,void 0,function*(){const i=this.codec.encode(a_.RtcKeyDeleteInput,{key:t}),{code:r}=yield this.context.rtcSignaling(e,Fl,!1,i);return r})}setRTCData(e,t,i,r,n,s){return I(this,void 0,void 0,function*(){const o=this.codec.encode(a_.RtcSetDataInput,{interior:r,target:n,key:t,value:i,objectName:null==s?void 0:s.name,content:null==s?void 0:s.content}),{code:a}=yield this.context.rtcSignaling(e,jl,!1,o);return a})}setRTCTotalRes(e,t,i,r,n,s){return I(this,void 0,void 0,function*(){const o={objectName:r,content:[],valueInfo:[this.codec.encode(a_.RtcValueInfo,{key:"uris",value:i},!0)]};t.forEach(e=>{const t=this.codec.encode(a_.RtcValueInfo,{key:e.name,value:e.content},!0);o.content.push(t)}),n&&o.valueInfo.push(this.codec.encode(a_.RtcValueInfo,{key:"mcu_uris",value:n},!0)),s&&o.valueInfo.push(this.codec.encode(a_.RtcValueInfo,{key:"cdn_uris",value:s},!0));const a=this.codec.encode(a_.RtcUserSetDataInput,o),{code:l}=yield this.context.rtcSignaling(e,Hl,!0,a);return l})}setRTCCDNUris(e,t,i){return I(this,void 0,void 0,function*(){const r=this.codec.encode(a_.RtcUserSetDataInput,{objectName:t,valueInfo:this.codec.encode(a_.RtcValueInfo,{key:"cdn_uris",value:i},!0)}),{code:n}=yield this.context.rtcSignaling(e,Hl,!0,r);return n})}getRTCData(e,t,i,r){return I(this,void 0,void 0,function*(){const n=this.codec.encode(a_.RtcDataInput,{interior:i,target:r,key:t}),{code:s,buffer:o}=yield this.context.rtcSignaling(e,Jl,!0,n);if(s!==oe||!o)return{code:s};const{outInfo:a}=this.codec.decode(a_.RtcQryOutput,o),l={};return a.forEach(e=>{l[e.key]=e.value}),{code:s,data:l}})}removeRTCData(e,t,i,r,n){return I(this,void 0,void 0,function*(){const s=this.codec.encode(a_.RtcDataInput,{interior:i,target:r,key:t,objectName:(null==n?void 0:n.name)||"",content:(null==n?void 0:n.content)||""}),{code:o}=yield this.context.rtcSignaling(e,$l,!1,s);return o})}setRTCOutData(e,t,i,r){return I(this,void 0,void 0,function*(){throw new Error("JSEngine's method not implemented.")})}getRTCOutData(e,t){return I(this,void 0,void 0,function*(){throw new Error("JSEngine's method not implemented.")})}getRTCToken(e,t,i){return I(this,void 0,void 0,function*(){const r=__(this.codec,t,i),{code:n,buffer:s}=yield this.context.rtcSignaling(e,Kl,!0,r);if(n!==oe||!s)return{code:n};const{rtcToken:o}=this.codec.decode(a_.RtcTokenOutput,s);return{code:n,data:{rtcToken:o}}})}setRTCState(e,t){return I(this,void 0,void 0,function*(){const i=this.codec.encode(a_.MCFollowInput,{state:t}),{code:r}=yield this.context.rtcSignaling(e,Yl,!0,i);return r})}setRTCStateByHttp(e,t,i,r){return I(this,void 0,void 0,function*(){var n;const s=((e,t,i)=>{const{type:r,appKey:n,sessionId:s,roomId:o,roomCreateTime:a,userId:l,userRole:_,joinTime:c,signalDataCenter:d,r1Info:u,r2Info:h,r3Info:g,r4Info:p}=t,f={type:r,appKey:n,sessionId:s,roomId:o,roomCreateTime:a,userId:l,userRole:_,joinTime:c,signalDataCenter:d};if(i===Ba.R1&&u){const t=e.encode(a_.RtcPBR1Info,u,!0);return e.encode(a_.RtcPBPolaris,Object.assign(Object.assign({},f),{r1Info:t}))}if(i===Ba.R2&&h){const t=e.encode(a_.RtcPBR2Info,h,!0);return e.encode(a_.RtcPBPolaris,Object.assign(Object.assign({},f),{r2Info:t}))}if(i===Ba.R3&&g){const{info:t}=g,{streams:i}=t;let r=Array.isArray(i)&&i.map(t=>t&&e.encode(a_.RtcPBStreamInfo,t,!0)),n=e.encode(a_.RtcPBStatusInfo,Object.assign(Object.assign({},t),{streams:r}),!0),s=e.encode(a_.RtcPBR3Info,{info:n},!0);return e.encode(a_.RtcPBPolaris,Object.assign(Object.assign({},f),{r3Info:s}))}if(i===Ba.R4&&p){const{info:t}=p,{streams:i}=t;let r=Array.isArray(i)&&i.map(t=>t&&e.encode(a_.RtcPBStreamInfo,t,!0)),n=e.encode(a_.RtcPBStatusInfo,Object.assign(Object.assign({},t),{streams:r}),!0),s=e.encode(a_.RtcPBR4Info,{info:n},!0);return e.encode(a_.RtcPBPolaris,Object.assign(Object.assign({},f),{r4Info:s}))}return{}})(this.codec,i,r);let o=e;/^https:\/\//.test(e)||(o=`https://${e}`);try{const e=yield t.httpReq({url:`${o}/rtc/logserver/polaris`,body:s,method:V.POST,headers:{jwt:(null===(n=this.context.getNaviInfo())||void 0===n?void 0:n.jwtToken)||""},timeout:2e3});if(!e.data)throw new Error("http request fail");return JSON.parse(e.data).resultCode}catch(e){return xa.REPORT_FAIL}})}getRTCUserList(e){return I(this,void 0,void 0,function*(){const t=this.codec.encode(a_.RtcQueryListInput,{order:2}),{code:i,buffer:r}=yield this.context.rtcSignaling(e,ql,!0,t);if(i!==oe||!r)return{code:i};return{code:i,data:c_(this.codec,r)}})}joinLivingRoomAsAudience(e,t,i){return I(this,void 0,void 0,function*(){const r=__(this.codec,t,i),{code:n,buffer:s}=yield this.context.rtcSignaling(e,Wl,!0,r);if(n!==oe||!s)return{code:n};const{rtcToken:o,entries:a,roomCreateTime:l,userJoinTime:_}=this.codec.decode(a_.RtcViewerJoinedOutput,s);return this.roomCreateTime=Ni(l),this.userJoinTime=Ni(_),{code:n,data:{token:o,kvEntries:a}}})}quitLivingRoomAsAudience(e){return I(this,void 0,void 0,function*(){const t=this.codec.encode(a_.SetUserStatusInput,{status:0}),{code:i}=yield this.context.rtcSignaling(e,zl,!0,t);return i})}rtcIdentityChange(e,t,i){return I(this,void 0,void 0,function*(){const r=this.codec.encode(a_.RtcInput,{roomType:vo.LIVE,broadcastType:i,identityChangeType:t,needSysChatroom:!1}),{code:n,buffer:s}=yield this.context.rtcSignaling(e,Zl,!0,r);if(n!==oe||!s)return{code:n};return{code:n,data:c_(this.codec,s)}})}requestRoomPK(e){return I(this,void 0,void 0,function*(){const{invitedRoomId:t,invitedUserId:i,inviteSessionId:r,inviteTimeout:n,inviteInfo:s,roomId:o}=e,a=this.codec.encode(a_.RtcInviteInput,{invitedRoomId:t,invitedUserId:i,inviteSessionId:r,timeoutTime:n,inviteInfo:s}),{code:l}=yield this.context.rtcSignaling(o,Xl,!0,a);return l})}cancelRoomPK(e){return I(this,void 0,void 0,function*(){const{invitedRoomId:t,invitedUserId:i,inviteSessionId:r,inviteInfo:n,roomId:s}=e,o=this.codec.encode(a_.RtcCancelInviteInput,{invitedRoomId:t,invitedUserId:i,inviteSessionId:r,inviteInfo:n}),{code:a}=yield this.context.rtcSignaling(s,e_,!0,o);return a})}responseRoomPK(e){return I(this,void 0,void 0,function*(){const{inviteUserId:t,inviteRoomId:i,inviteSessionId:r,content:n,key:s,value:o,agree:a,roomId:l}=e,_=this.codec.encode(a_.RtcInviteAnswerInput,{inviteUserId:t,inviteRoomId:i,inviteSessionId:r,content:n,key:s,value:o,answerCode:a?1:0}),{code:c}=yield this.context.rtcSignaling(l,t_,!0,_);return c})}endRoomPK(e){return I(this,void 0,void 0,function*(){const{endRoomId:t,sessionId:i,content:r,keys:n,roomId:s}=e,o=this.codec.encode(a_.RtcEndInviteInput,{inviteRoomId:t,inviteSessionId:i,inviteContent:r,inviteRoomKeys:n}),{code:a}=yield this.context.rtcSignaling(s,i_,!0,o);return a})}getRTCJoinedUserInfo(e){return I(this,void 0,void 0,function*(){const t=this.codec.encode(a_.RtcQueryUserJoinedInput,{userId:e}),{code:i,buffer:r}=yield this.context.rtcSignaling("",r_,!0,t);if(i!==oe||!r)return{code:i};return{code:i,data:(this.codec.decode(a_.RtcQueryUserJoinedOutput,r).info||[]).map(e=>({deviceId:e.deviceId,roomId:e.roomId,joinTime:Ni(e.joinTime)}))}})}pullRTCRoomEntry(e){return I(this,void 0,void 0,function*(){const t=this.codec.encode(a_.RtcPullKV,{timestamp:0,roomId:e}),{code:i,buffer:r}=yield this.context.rtcSignaling(e,Ql,!0,t);if(i!==oe)return{code:i};const n=this.codec.decode(a_.RtcKVOutput,r);let{entries:s,syncTime:o}=n;return s=(s||[]).map(e=>Object.assign(Object.assign({},e),{timestamp:Ni(e.timestamp)})),{code:i,data:{kvEntries:s,syncTime:Ni(o)}}})}pullRTCRoomStatus(e,t){return I(this,void 0,void 0,function*(){const i=this.codec.encode(a_.RtcRoomStatusInput,{version:t}),{code:r,buffer:n}=yield this.context.rtcSignaling(e,n_,!0,i);if(r!==oe)return{code:r};return{code:r,data:this.codec.decode(a_.RtcRoomStatusOutput,n)}})}decodeRtcNotify(e){const{time:t,type:i,roomId:r}=this.codec.decode(a_.RtcNotifyMsg,e);return{time:Ni(t),type:i,roomId:r}}getCurrentId(){return this.context.getCurrentId()}getNaviInfo(){return this.context.getNaviInfo()}getConnectionStatus(){return this.context.getConnectionStatus()}getAppkey(){return this.context.getAppkey()}webRtcPing(e,t,i){return I(this,void 0,void 0,function*(){const r=this.codec.encode(a_.RtcInput,{roomType:t,broadcastType:i}),{code:n,buffer:s}=yield this.context.rtcSignaling(e,o_,!0,r);if(n!==oe)return{code:n};const o=this.codec.decode(a_.RtcOutput,s);return o.version=Ni(o.version),{code:n,data:o}})}rtcPing(e,t,i){var r,n;return/Electron/.test(navigator.userAgent)?null===(n=(r=this.context).rtcPingResVersion)||void 0===n?void 0:n.call(r,e,t,i):this.webRtcPing(e,t,i)}sendMessage(e,t,i){return this.context.sendMessage(e,t,i)}registerRTCSignalListener(e){this.context.registerRTCSignalListener(e)}registerConnectionStateChangeListener(e){var t,i;null===(i=(t=this.context).registerConnectionStateChangeListener)||void 0===i||i.call(t,e)}registerDisconnectListener(e){var t,i;null===(i=(t=this.context).registerDisconnectListener)||void 0===i||i.call(t,e)}registerDestroyListener(e){var t,i;null===(i=(t=this.context).registerDestroyListener)||void 0===i||i.call(t,e)}registerMessageListener(e){var t,i;null===(i=(t=this.context).registerMessageListener)||void 0===i||i.call(t,e)}getCoreVersion(){return this.context.getCoreVersion()}getPluginContext(){return this.context}reportSDKInfo(e){const t=this.codec.encode(a_.RtcReportSDKInput,{sdkInfo:JSON.stringify(e)});this.context.rtcSignaling("",s_,!0,t)}decodeAsrText(e,t){let i;try{i=this.codec.decode(a_.AsrResTextMsg,e)}catch(i){console.error("decodeAsrText error",{error:i,seiFrameData:e.join(","),seiOriginData:t.join(",")})}const{type:r,uid:n,asr:s}=i||{asr:[]};return s.map(e=>{const{bms:t,t:i,isEnd:s,msgId:o,lang:a}=e,l={userID:n,timeUTC:t,msg:i,msgId:o,isEnd:s};return r===d_.SUBTITLE?l:Object.assign(Object.assign({},l),{destLangCode:a})})}}class g_ extends Ll{constructor(e,t,i){var r,n;super(e),Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_runtime",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_options",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_service",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_crtRoom",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_audience",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_crtAudienceLivingRoom",{enumerable:!0,configurable:!0,writable:!0,value:null}),Ao.setSdpSemantics(i.sdpSemantics||"unified-plan",this._logger),this._service=new eo(this._runtime,this._context,this._options.mediaServer,this._options.timeout),this._context.registerConnectionStateChangeListener(this._onIMStatusChange.bind(this)),this._context.registerDestroyListener(this._onIMUninit.bind(this)),this._context.registerMessageListener(this._handleMessage.bind(this)),null===(n=(r=this._context.getPluginContext()).setOnnavidatachange)||void 0===n||n.call(r,this.naviDataChange.bind(this))}static init(e={},t,i){const{logger:r}=t;if(r.warn(he.L_INDEX_INSTALL_RTC_PLUGIN_O,JSON.stringify({"NCRTC Version":"26.1.0",Commit:"ac4bb112f4fbde2c7b94ef9141b75e4e2be81ca7","browserInfo.browser":Ci.browser,"browserInfo.supportsUnifiedPlan":Ci.supportsUnifiedPlan,"browserInfo.version":Ci.version})),k("options",e,D.OBJECT,!0),k("options.mediaServer",e.mediaServer,e=>!(!U(e)||"https:"===location.protocol&&!/^https/.test(e))),k("options.timeout",e.timeout,e=>O(e)&&e>=5e3&&e<=3e4),k("options.pingGap",e.pingGap,e=>O(e)&&e>=3e3&&e<=1e4),e.AAAWorklet){k("options.AAAWorklet",e.AAAWorklet,D.OBJECT,!0);const{scriptUrl:t,wasmUrl:i}=e.AAAWorklet;k("AAAWorklet.scriptUrl",t,D.STRING,!0),k("AAAWorklet.wasmUrl",i,D.STRING,!0),Kt.SCRIPT_URL=t,Kt.WASM_URL=i}return e.encryptor&&(k("options.encrypt",e.encryptor,D.OBJECT,!0),k("options.encrypt.decodeAudio",e.encryptor.decodeAudio,e=>"function"==typeof e,!0),k("options.encrypt.decodeVideo",e.encryptor.decodeVideo,e=>"function"==typeof e,!0),k("options.encrypt.encodeAudio",e.encryptor.encodeAudio,e=>"function"==typeof e,!0),k("options.encrypt.encodeVideo",e.encryptor.encodeVideo,e=>"function"==typeof e,!0),po.init(e.encryptor,r)),g_._instance||(g_._instance=new g_(new h_(t),i,e)),g_._instance}_handleMessage(e){if(e.conversationType!==a.RTC_ROOM)return!1;const t=this._logger.createTraceId();if(this._crtRoom instanceof gl){this._getJoinedPKRoomList().forEach(i=>{i.__parseInnerMessage(e,t)})}return this._logger.info(he.L_RTC_CLIENT_MESSAGE_O,JSON.stringify({status:ge.SUCCESSED,message:e}),t),this._crtRoom?(this._crtRoom.__parseInnerMessage(e,t),!0):(this._logger.warn(he.L_RTC_CLIENT_MESSAGE_O,JSON.stringify({status:ge.FAILED,message:"the crtRoom is empty"}),t),!0)}naviDataChange(e){this._logger.info(he.L_RTC_CLIENT_NAVI_CHANGE_O,`on navi change data => ${JSON.stringify(e)}`),this._service.clearMSList(),this._service.isNededDetector()&&this._service.detectorMediaSever()}_getJoinedPKRoomList(){const{code:e,roomPKHandler:t}=this._crtRoom.getRoomPKHandler();if(e===ue.SUCCESS&&t){const e=t.getJoinedPKRooms()||{};return Object.values(e)}return[]}getPluginContext(){return this._context.getPluginContext()}getCurrentId(){return this._context.getCurrentId()}joinCrossRTCRoom(e,t,i){return I(this,arguments,void 0,function*(e,t,i,r=!1,n=vo.CROSS_MUTI){return console.warn("joinCrossRTCRoom is deprecated, use joinRTCRoomWithOptions instead"),this.joinRTCRoomWithOptions(e,{joinType:t,userData:i,mode:vo.CROSS_MUTI})})}joinRTCRoom(e,t,i){return I(this,arguments,void 0,function*(e,t,i,r=!1,n=vo.RTC){return console.warn("joinRTCRoom is deprecated, use joinRTCRoomWithOptions instead"),this.joinRTCRoomWithOptions(e,{mode:n,joinType:t,userData:i})})}joinRTCRoomWithOptions(e,t){return I(this,void 0,void 0,function*(){const i=this._logger.createTraceId();if(this._logger.info(he.L_RTC_CLIENT_JOIN_RTC_ROOM_T,JSON.stringify({roomId:e,options:t}),i),this._crtRoom)return this._logger.error(he.L_RTC_CLIENT_JOIN_RTC_ROOM_R,JSON.stringify({status:ge.FAILED,code:ue.REPERT_JOIN_ROOM,msg:"Join the room repeatedly"}),i),{code:ue.REPERT_JOIN_ROOM};const r=this._crtRoom=new pl(this._context,this._runtime,e,this._service,this._options,null==t?void 0:t.mode,null==t?void 0:t.encrypt),{code:n}=yield r.__innerInit((null==t?void 0:t.mode)||vo.RTC,null==t?void 0:t.joinType,void 0,void 0,null==t?void 0:t.userData,i,null==t?void 0:t.srcLanguage,null==t?void 0:t.nickName);return n!==ue.SUCCESS?(this._crtRoom=null,{code:n}):(r.once(Qa,()=>{this._crtRoom=null}),{code:n,room:r,userIds:r.getRemoteUserIds(),tracks:r.getRemoteTracks()})})}joinLivingRoom(e,t,i,r){return I(this,arguments,void 0,function*(e,t,i,r,n=!1){const s=this._logger.createTraceId();if(this._logger.info(he.L_RTC_CLIENT_JOIN_LIVING_ROOM_T,JSON.stringify({roomId:e,livingType:t,joinType:i,outerUserDatas:r}),s),this._crtRoom)return this._logger.error(he.L_RTC_CLIENT_JOIN_LIVING_ROOM_R,JSON.stringify({status:ge.FAILED,code:ue.REPERT_JOIN_ROOM,msg:`Join the room repeatedly -> roomId: ${e}`}),s),{code:ue.REPERT_JOIN_ROOM};const o=this._crtRoom=new gl(this._context,this._runtime,e,this._service,this._options,t,!1,!0),{code:a}=yield o.__innerInit(vo.LIVE,i,t,void 0,r,s);if(a!==ue.SUCCESS)return this._crtRoom=null,{code:a};o.once(Qa,()=>{this._crtRoom=null});const l={code:a,room:o,userIds:o.getRemoteUserIds(),tracks:o.getRemoteTracks()};return o.__getCDNPushMode()===Cl.MANUAL&&Object.assign(l,{CDNEnable:o.__getCDNEnable()}),l})}getAudienceClient(e){return this._audience||(this._audience=new Tl(this._context,this._runtime,this._options)),this._logger.info(he.L_RTC_CLIENT_GET_AUDIENCE_CLIENT_O),this._audience}_onIMStatusChange(e,t){if(this._logger.info(he.L_RTC_CLIENT_IM_CONNECTION_STATE_S,JSON.stringify({status:e,code:t,desc:l[e]})),e===l.SUSPENDED&&40001===t&&this._service.clearMSList(),e===l.DISCONNECTED){if(this._crtRoom){let e=Ma.IM_DISCONNECTED;40002===t?e=Ma.OTHER_CLIENT_IM_CONNECTED:t===ae&&(e=Ma.IM_LOGOUT),this._crtRoom.__kickoff(!0,{users:[{userId:this._context.getCurrentId(),type:e}]})}}else if(e===l.CONNECTED){if(this._service.isNededDetector()&&this._service.detectorMediaSever(),this._crtRoom instanceof gl){this._getJoinedPKRoomList().forEach(e=>{e.__onReconnected()})}this._crtRoom&&this._crtRoom.__onReconnected()}}_onIMUninit(){var e;this._logger.info(he.L_RTC_CLIENT_DESTROY_S,JSON.stringify({msg:"TODO -> on IM client ondestroy"})),null===(e=this._crtRoom)||void 0===e||e.__destroy(!0)}leaveRoom(e){return I(this,void 0,void 0,function*(){var t;const i=this._logger.createTraceId();return this._logger.info(he.L_RTC_CLIENT_LEAVE_ROOM_T,JSON.stringify({roomId:e.getRoomId()}),i),this._crtRoom?(yield this._crtRoom.__destroy(!0),this._service.isNededDetector()&&this._service.detectorMediaSever(),this._logger.info(he.L_RTC_CLIENT_LEAVE_ROOM_R,JSON.stringify({status:ge.SUCCESSED,roomId:null===(t=this._crtRoom)||void 0===t?void 0:t.getRoomId()}),i),this._crtRoom=null,{code:ue.SUCCESS}):(this._logger.warn(he.L_RTC_CLIENT_LEAVE_ROOM_R,JSON.stringify({status:ge.FAILED,msg:"Room does not exist, without leave"}),i),{code:ue.SUCCESS})})}joinLivingRoomAsAudience(e,t,i){return I(this,void 0,void 0,function*(){const i=this._logger.createTraceId();if(this._logger.info(he.L_RTC_CLIENT_JOIN_LIVING_ROOM_AS_AUDIENCE_T,JSON.stringify({roomId:e,livingType:t}),i),this._service.isNededDetector()&&this._service.detectorMediaSever(),bi(this._context.getNaviInfo()))return this._logger.error(he.L_RTC_CLIENT_JOIN_LIVING_ROOM_AS_AUDIENCE_R,JSON.stringify({status:ge.FAILED,code:ue.PACKAGE_ENVIRONMENT_ERROR,msg:"package environment error"}),i),{code:ue.PACKAGE_ENVIRONMENT_ERROR};if(!x("roomId",e,b,!0)||!x("livingType",t,e=>e===ol.AUDIO||e===ol.VIDEO))return this._logger.error(he.L_RTC_CLIENT_JOIN_LIVING_ROOM_AS_AUDIENCE_R,JSON.stringify({status:ge.FAILED,code:ue.PARAMS_ERROR,msg:"params error -> roomId or livingType"}),i),{code:ue.PARAMS_ERROR};if(this._crtAudienceLivingRoom)return this._logger.error(he.L_RTC_CLIENT_JOIN_LIVING_ROOM_AS_AUDIENCE_R,JSON.stringify({status:ge.FAILED,code:ue.REPERT_JOIN_ROOM,msg:"Join the room repeatedly"}),i),{code:ue.REPERT_JOIN_ROOM};if(!this._service.getMsList().length)return this._logger.error(he.L_RTC_CLIENT_JOIN_LIVING_ROOM_AS_AUDIENCE_R,JSON.stringify({status:ge.FAILED,code:ue.NOT_OPEN_VIDEO_AUDIO_SERVER,msg:"No audio / video server address available"}),i),{code:ue.NOT_OPEN_VIDEO_AUDIO_SERVER};const{code:r,data:n}=yield this._context.joinLivingRoomAsAudience(e,vo.LIVE,t);if(r!==oe)return this._logger.error(he.L_RTC_CLIENT_JOIN_LIVING_ROOM_AS_AUDIENCE_R,JSON.stringify({status:ge.FAILED,code:r,msg:"signal error -> audience join room"}),i),{code:ue.SIGNAL_AUDIENCE_JOIN_ROOM_FAILED};const s=qs(),o=new Sl(this._context,this._runtime,this._options,e,n,t,s);return this._crtAudienceLivingRoom=o,this._logger.info(he.L_RTC_CLIENT_JOIN_LIVING_ROOM_AS_AUDIENCE_R,JSON.stringify({status:ge.SUCCESSED,roomData:n}),i),{room:o,code:ue.SUCCESS,userIds:o.getRemoteUserIds(),RTCTracks:o.getRemoteRTCTracks(),MCUTracks:o.getRemoteMCUTracks(),CDNUris:o.getCDNInfo()}})}leaveLivingRoomAsAudience(e){return I(this,void 0,void 0,function*(){const t=this._logger.createTraceId();return this._logger.info(he.L_RTC_CLIENT_LEAVE_LIVING_ROOM_AS_AUDIENCE_T,JSON.stringify({roomId:e.getRoomId(),userId:this._context.getCurrentId()}),t),this._crtAudienceLivingRoom?this._crtAudienceLivingRoom!==e?(this._logger.error(he.L_RTC_CLIENT_LEAVE_LIVING_ROOM_AS_AUDIENCE_R,JSON.stringify({status:ge.FAILED,code:ue.PARAMS_ERROR,msg:"params error -> room"}),t),{code:ue.PARAMS_ERROR}):(yield this._crtAudienceLivingRoom.__destroy(!0),this._crtAudienceLivingRoom=null,this._logger.info(he.L_RTC_CLIENT_LEAVE_LIVING_ROOM_AS_AUDIENCE_R,JSON.stringify({status:ge.SUCCESSED}),t),{code:ue.SUCCESS}):(this._logger.warn(he.L_RTC_CLIENT_LEAVE_LIVING_ROOM_AS_AUDIENCE_R,JSON.stringify({status:ge.FAILED,msg:"Room does not exist, without leave"}),t),{code:ue.SUCCESS})})}upgradeToAnchorRoom(e){return I(this,void 0,void 0,function*(){const t=this._logger.createTraceId();if(this._logger.info(he.L_RTC_CLIENT_UPGRADE_TO_ANCHOR_ROOM_T,void 0,t),!x("room",e,()=>e instanceof Sl,!0))return this._logger.error(he.L_RTC_CLIENT_UPGRADE_TO_ANCHOR_ROOM_R,JSON.stringify({status:ge.FAILED,code:ue.PARAMS_ERROR,msg:"params error -> room"}),t),{code:ue.PARAMS_ERROR};const i=e.getRoomId();if(this._crtRoom)return this._logger.error(he.L_RTC_CLIENT_UPGRADE_TO_ANCHOR_ROOM_R,JSON.stringify({status:ge.FAILED,code:ue.REPERT_JOIN_ROOM,msg:"Join the room repeatedly",roomId:i}),t),{code:ue.REPERT_JOIN_ROOM};const r=this._crtRoom=new gl(this._context,this._runtime,i,this._service,this._options,e.livingType,!0,!0,e.getClientSessionId()),n=yield r.__innerInitByIdentityChange(t);if(n!==oe)return this._crtRoom=null,{code:n};r.once(Qa,()=>{this._crtRoom=null}),yield this._crtAudienceLivingRoom.__destroy(!1),this._crtAudienceLivingRoom=null;const s={room:r,code:ue.SUCCESS,userIds:r.getRemoteUserIds(),tracks:r.getRemoteTracks()};return r.__getCDNPushMode()===Cl.MANUAL&&Object.assign(s,{CDNEnable:r.__getCDNEnable()}),s})}downgradeToAudienceRoom(e){return I(this,void 0,void 0,function*(){const t=this._logger.createTraceId();if(this._logger.info(he.L_RTC_CLIENT_DOWNGRADE_TO_AUDIENCE_ROOM_T,JSON.stringify({roomId:e._roomId,userId:this._context.getCurrentId()}),t),!e.isMainRoom())return this._logger.error(he.L_RTC_CLIENT_DOWNGRADE_TO_AUDIENCE_ROOM_R,JSON.stringify({status:ge.FAILED,code:ue.THE_FUNCTION_IS_DISABLED_IN_PKROOM,msg:"the `downgradeToAudienceRoom` is disabled in PK room"}),t),{code:ue.THE_FUNCTION_IS_DISABLED_IN_PKROOM};if(!x("room",e,()=>e instanceof gl,!0))return this._logger.error(he.L_RTC_CLIENT_DOWNGRADE_TO_AUDIENCE_ROOM_R,JSON.stringify({status:ge.FAILED,code:ue.PARAMS_ERROR,msg:"params error -> room"}),t),{code:ue.PARAMS_ERROR};if(this._crtAudienceLivingRoom)return this._logger.error(he.L_RTC_CLIENT_DOWNGRADE_TO_AUDIENCE_ROOM_R,JSON.stringify({status:ge.FAILED,code:ue.REPERT_JOIN_ROOM,msg:"Join the room repeatedly"}),t),{code:ue.REPERT_JOIN_ROOM};const{code:i,data:r}=yield this._context.rtcIdentityChange(e._roomId,ll.AnchorToViewer,e.getLivingType());if(i!==oe)return this._logger.error(he.L_RTC_CLIENT_DOWNGRADE_TO_AUDIENCE_ROOM_R,JSON.stringify({status:ge.FAILED,code:ue.SIGNAL_ROOM_CHANGE_IDENTITY_FAILED}),t),{code:ue.SIGNAL_ROOM_CHANGE_IDENTITY_FAILED};this._logger.info(he.L_RTC_CLIENT_DOWNGRADE_TO_AUDIENCE_ROOM_R,JSON.stringify({status:ge.SUCCESSED,roomData:r}),t);const n=e.getClientSessionId(),s=new Sl(this._context,this._runtime,this._options,e._roomId,r,e.getLivingType(),n);return this._crtAudienceLivingRoom=s,this._crtRoom.__destroy(!1),this._crtRoom=null,{room:s,code:ue.SUCCESS,userIds:s.getRemoteUserIds(),RTCTracks:s.getRemoteRTCTracks(),MCUTracks:s.getRemoteMCUTracks(),CDNUris:s.getCDNInfo()}})}getJoinedRoomInfo(){return I(this,void 0,void 0,function*(){const e=this._logger.createTraceId(),t=this._context.getCurrentId();this._logger.error(he.L_RTC_CLIENT_GET_JOINED_ROOM_INFO_T,JSON.stringify({userId:t}),e);const{code:i,data:r}=yield this._context.getRTCJoinedUserInfo(t);return i!==oe?(this._logger.error(he.L_RTC_CLIENT_GET_JOINED_ROOM_INFO_R,JSON.stringify({status:ge.FAILED,code:i}),e),{code:i}):(this._logger.info(he.L_RTC_CLIENT_GET_JOINED_ROOM_INFO_R,JSON.stringify({status:ge.SUCCESSED,roomInfo:r}),e),{code:ue.SUCCESS,data:r})})}generateSummarization(e,t){return I(this,arguments,void 0,function*(e,t,i=0,r=0,n,s){const o=this._logger.createTraceId();if(this._logger.info(he.L_RTC_CLIENT_GENERATE_SUMMARIZATION_T,JSON.stringify({roomId:e,taskId:t,startTime:i,endTime:r,config:n,contentBlock:s}),o),!x("roomId",e,b,!0))return this._logger.error(he.L_RTC_CLIENT_GENERATE_SUMMARIZATION_R,JSON.stringify({status:ge.FAILED,code:ue.PARAMS_ERROR,msg:"params error -> roomId"}),o),{code:ue.PARAMS_ERROR};if(!x("taskId",t,b,!0))return this._logger.error(he.L_RTC_CLIENT_GENERATE_SUMMARIZATION_R,JSON.stringify({status:ge.FAILED,code:ue.PARAMS_ERROR,msg:"params error -> taskId"}),o),{code:ue.PARAMS_ERROR};if(!O(i)||i<0)return this._logger.error(he.L_RTC_CLIENT_GENERATE_SUMMARIZATION_R,JSON.stringify({status:ge.FAILED,code:ue.PARAMS_ERROR,msg:"params error -> startTime"}),o),{code:ue.PARAMS_ERROR};if(!O(r)||r<0)return this._logger.error(he.L_RTC_CLIENT_GENERATE_SUMMARIZATION_R,JSON.stringify({status:ge.FAILED,code:ue.PARAMS_ERROR,msg:"params error -> endTime"}),o),{code:ue.PARAMS_ERROR};if(!x("config",n,y,!0))return this._logger.error(he.L_RTC_CLIENT_GENERATE_SUMMARIZATION_R,JSON.stringify({status:ge.FAILED,code:ue.PARAMS_ERROR,msg:"params error -> config"}),o),{code:ue.PARAMS_ERROR};const{isValid:a,key:l}=(e=>{if("destLang"in e&&!C(e.destLang))return{isValid:!1,key:"destLang"};if("customPrompt"in e&&!C(e.customPrompt))return{isValid:!1,key:"customPrompt"};if("enableSummarization"in e&&!L(e.enableSummarization))return{isValid:!1,key:"enableSummarization"};if("enableSummarizationDetails"in e&&!L(e.enableSummarizationDetails))return{isValid:!1,key:"enableSummarizationDetails"};if("enableChapterSummary"in e&&!L(e.enableChapterSummary))return{isValid:!1,key:"enableChapterSummary"};if("enableTodoList"in e&&!L(e.enableTodoList))return{isValid:!1,key:"enableTodoList"};if("enableHashtag"in e&&!L(e.enableHashtag))return{isValid:!1,key:"enableHashtag"};if("format"in e&&void 0===oi[e.format])return{isValid:!1,key:"format"};const t=e.enableSummarization||e.enableSummarizationDetails||e.enableChapterSummary||e.enableTodoList||e.enableHashtag;return e.customPrompt||t?{isValid:!0,key:""}:{isValid:!1,key:"at least one of the summary features must be enabled"}})(n);a||this._logger.warn(he.L_RTC_CLIENT_GENERATE_SUMMARIZATION_R,JSON.stringify({status:ge.FAILED,code:ue.PARAMS_ERROR,msg:`params error -> config.${l}`}),o);const{code:_,msg:c}=yield this._service.generateSummarization(e,t,i,r,n,s,o);return _!==ue.SUCCESS?(this._logger.error(he.L_RTC_CLIENT_GENERATE_SUMMARIZATION_R,JSON.stringify({status:ge.FAILED,code:_,msg:c}),o),{code:_}):(this._logger.info(he.L_RTC_CLIENT_GENERATE_SUMMARIZATION_R,JSON.stringify({status:ge.SUCCESSED}),o),{code:_})})}getASRContent(e,t){return I(this,arguments,void 0,function*(e,t,i=0,r=0,n,s){const o=this._logger.createTraceId();if(this._logger.info(he.L_RTC_CLIENT_GET_ASR_CONTENT_T,JSON.stringify({roomId:e,taskId:t,startTime:i,endTime:r,destLang:s,contentBlock:n}),o),!x("roomId",e,b,!0))return this._logger.error(he.L_RTC_CLIENT_GET_ASR_CONTENT_R,JSON.stringify({status:ge.FAILED,code:ue.PARAMS_ERROR,msg:"params error -> roomId"}),o),{code:ue.PARAMS_ERROR};if(!x("taskId",t,b,!0))return this._logger.error(he.L_RTC_CLIENT_GET_ASR_CONTENT_R,JSON.stringify({status:ge.FAILED,code:ue.PARAMS_ERROR,msg:"params error -> taskId"}),o),{code:ue.PARAMS_ERROR};if(!O(i)||i<0)return this._logger.error(he.L_RTC_CLIENT_GET_ASR_CONTENT_R,JSON.stringify({status:ge.FAILED,code:ue.PARAMS_ERROR,msg:"params error -> startTime"}),o),{code:ue.PARAMS_ERROR};if(!O(r)||r<0)return this._logger.error(he.L_RTC_CLIENT_GET_ASR_CONTENT_R,JSON.stringify({status:ge.FAILED,code:ue.PARAMS_ERROR,msg:"params error -> endTime"}),o),{code:ue.PARAMS_ERROR};if(!x("destLang",s,C,!1))return this._logger.error(he.L_RTC_CLIENT_GET_ASR_CONTENT_R,JSON.stringify({status:ge.FAILED,code:ue.PARAMS_ERROR,msg:"params error -> destLang"}),o),{code:ue.PARAMS_ERROR};const{code:a,msg:l}=yield this._service.getASRContent(e,t,i,r,n,o,s);return a!==ue.SUCCESS?(this._logger.error(he.L_RTC_CLIENT_GET_ASR_CONTENT_R,JSON.stringify({status:ge.FAILED,code:a,msg:l}),o),{code:a}):(this._logger.info(he.L_RTC_CLIENT_GET_ASR_CONTENT_R,JSON.stringify({status:ge.SUCCESSED}),o),{code:a})})}}Object.defineProperty(g_,"_instance",{enumerable:!0,configurable:!0,writable:!0,value:null}),function(e){e[e.KICK=0]="KICK",e[e.REFUSE=1]="REFUSE"}(u_||(u_={}));const p_={tag:"RCRTC",verify:()=>"undefined"==typeof isSecureContext||isSecureContext?!!r.validEngine("26.1.0")||(console.error(`The current engine version '${r.getInfo().engine}' error, plugin-rtc required engine version at least '26.1.0'.`),!1):(console.error("Please use the https protocol or use `http://localhost` to open the page!"),!1),setup(e){const t=S(e),{logger:i}=t;return i.warn(he.L_INDEX_INSTALL_RTC_PLUGIN_O,JSON.stringify({"NCRTC Version":"26.1.0",Commit:"ac4bb112f4fbde2c7b94ef9141b75e4e2be81ca7","browserInfo.browser":Ci.browser,"browserInfo.supportsUnifiedPlan":Ci.supportsUnifiedPlan,"browserInfo.version":Ci.version})),new g_(new h_(t),se,{})}},f_=gi,E_={SUCCESS:0,PARAM_ERROR:80001,SESSION_EXIST:80002,NOT_IN_CALL:80003,MEDIATYPE_INVALID:80004,NOT_VIDEO_CALL:80005,RTC_SERVICE_UNAVAILABLE:80006,USER_LIST_INVAILD:80007,CALL_ID_INVALID:80008,TRANSACTION_ID_INVALID:80009,USER_ID_INVALID:80010,SINGLE_CALL_NOT_SUPPORT_MULTI_PERSON:80011,SIGNAL_DISCONNECTED:80012,CAMERA_CLOSED:80100,MICROPHONE_CLOSED:80101,MEDIA_RESOURCE_INVALIED:80102,NOT_INSTALL_RTC_PLUGIN:80103,PLAY_MEDIA_FAILED:80104,VIDEO_VIEW_NOT_SET:80105},T_=E_;var m_,I_,R_;!function(e){e.L_INDEX_INSTALL_CALL_PLUS_PLUGIN_O="L-index_install_call_plus_plugin-O",e.L_CALLPLUS_CLIENT_SET_EVENT_LISTENER_O="L-callplus_client_set_event_listener-O",e.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O="L-callplus_client_call_event_listener-O",e.L_CALLPLUS_CLIENT_SET_STATUS_REPORT_LISTENER_O="L-callplus_client_set_status_report_listener-O",e.L_CALLPLUS_CLIENT_CALL_STATUS_REPORT_LISTENER_O="L-callplus_client_call_status_report_listener-O",e.L_CALLPLUS_CLIENT_SET_VIDEO_CONFIG_T="L-callplus_client_set_video_config-T",e.L_CALLPLUS_CLIENT_SET_VIDEO_CONFIG_R="L-callplus_client_set_video_config-R",e.L_CALLPLUS_VIDEO_CONFIG_SET_FRAME_RATE_O="L-callplus_video_config_set_frame_rate-O",e.L_CALLPLUS_VIDEO_CONFIG_SET_RESOLUTION_O="L-callplus_video_config_set_resolution-O",e.L_CALLPLUS_VIDEO_CONFIG_SET_BITRATE_O="L-callplus_video_config_set_bitrate-O",e.L_CALLPLUS_CLIENT_SET_AUDIO_CONFIG_T="L-callplus_client_set_audio_config-T",e.L_CALLPLUS_CLIENT_SET_AUDIO_CONFIG_R="L-callplus_client_set_audio_config-R",e.L_CALLPLUS_AUDIO_CONFIG_SET_BITRATE_O="L-callplus_audio_config_set_bitrate-O",e.L_CALLPLUS_AUDIO_CONFIG_SET_SAMPLE_RATE_O="L-callplus_audio_config_set_sample_rate-O",e.L_CALLPLUS_CLIENT_PREVIEW_T="L-callplus_client_preview-T",e.L_CALLPLUS_CLIENT_PREVIEW_R="L-callplus_client_preview-R",e.L_CALLPLUS_CLIENT_START_CALL_T="L-callplus_client_start_call-T",e.L_CALLPLUS_CLIENT_START_CALL_R="L-callplus_client_start_call-R",e.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_T="L-callplus_client_join_multi_call-T",e.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_R="L-callplus_client_join_multi_call-R",e.L_CALLPLUS_CLIENT_ACCEPT_T="L-callplus_client_accept-T",e.L_CALLPLUS_CLIENT_ACCEPT_R="L-callplus_client_accept-R",e.L_CALLPLUS_CLIENT_HANGUP_T="L-callplus_client_hangup-T",e.L_CALLPLUS_CLIENT_HANGUP_R="L-callplus_client_hangup-R",e.L_CALLPLUS_CLIENT_INVITE_T="L-callplus_client_invite-T",e.L_CALLPLUS_CLIENT_INVITE_R="L-callplus_client_invite-R",e.L_CALLPLUS_CLIENT_REQUEST_CHANGE_MEDIA_TYPE_T="L-callplus_client_request_change_media_type-T",e.L_CALLPLUS_CLIENT_REQUEST_CHANGE_MEDIA_TYPE_R="L-callplus_client_request_change_media_type-R",e.L_CALLPLUS_CLIENT_CANCEL_CHANGE_MEDIA_TYPE_T="L-callplus_client_cancel_change_media_type-T",e.L_CALLPLUS_CLIENT_CANCEL_CHANGE_MEDIA_TYPE_R="L-callplus_client_cancel_change_media_type-R",e.L_CALLPLUS_CLIENT_REPLY_CHANGE_MEDIA_TYPE_T="L-callplus_client_reply_change_media_type-T",e.L_CALLPLUS_CLIENT_REPLY_CHANGE_MEDIA_TYPE_R="L-callplus_client_reply_change_media_type-R",e.L_CALLPLUS_CLIENT_GET_CURRENT_CALL_SESSION_T="L-callplus_client_get_current_call_session-T",e.L_CALLPLUS_CLIENT_GET_CURRENT_CALL_SESSION_R="L-callplus_client_get_current_call_session-R",e.L_CALLPLUS_CLIENT_GET_AVAILABLE_CALL_RECORDS_FROM_SERVER_T="L-callplus_client_get_available_call_sessions_from_server-T",e.L_CALLPLUS_CLIENT_GET_AVAILABLE_CALL_RECORDS_FROM_SERVER_R="L-callplus_client_get_available_call_sessions_from_server-R",e.L_CALLPLUS_CLIENT_GET_CALL_RECORDS_T="L-callplus_client_get_call_records-T",e.L_CALLPLUS_CLIENT_GET_CALL_RECORDS_R="L-callplus_client_get_call_records-R",e.L_CALLPLUS_CLIENT_DELETE_CALL_RECORDS_BY_CALLID_T="L-callplus_client_delete_call_records_by_callId-T",e.L_CALLPLUS_CLIENT_DELETE_CALL_RECORDS_BY_CALLID_R="L-callplus_client_delete_call_records_by_callId-R",e.L_CALLPLUS_CLIENT_DELETE_ALL_CALL_RECORDS_FROM_SERVER_T="L-callplus_client_delete_all_call_records_from_server-T",e.L_CALLPLUS_CLIENT_DELETE_ALL_CALL_RECORDS_FROM_SERVER_R="L-callplus_client_delete_all_call_records_from_server-R",e.L_CALLPLUS_CLIENT_START_CAMERA_T="L-callplus_client_start_camera-T",e.L_CALLPLUS_CLIENT_START_CAMERA_R="L-callplus_client_start_camera-R",e.L_CALLPLUS_CLIENT_STOP_CAMERA_T="L-callplus_client_stop_camera-T",e.L_CALLPLUS_CLIENT_STOP_CAMERA_R="L-callplus_client_stop_camera-R",e.L_CALLPLUS_CLIENT_SWITCH_CAMERA_T="L-callplus_client_switch_camera-T",e.L_CALLPLUS_CLIENT_SWITCH_CAMERA_R="L-callplus_client_switch_camera-R",e.L_CALLPLUS_CLIENT_START_MICROPHONE_T="L-callplus_client_start_microphone-T",e.L_CALLPLUS_CLIENT_START_MICROPHONE_R="L-callplus_client_start_microphone-R",e.L_CALLPLUS_CLIENT_STOP_MICROPHONE_T="L-callplus_client_stop_microphone-T",e.L_CALLPLUS_CLIENT_STOP_MICROPHONE_R="L-callplus_client_stop_microphone-R",e.L_CALLPLUS_CLIENT_SWITCH_MICROPHONE_T="L-callplus_client_switch_microphone-T",e.L_CALLPLUS_CLIENT_SWITCH_MICROPHONE_R="L-callplus_client_switch_microphone-R",e.L_CALLPLUS_CLIENT_SET_VIDEO_VIEW_T="L-callplus_client_set_video_view-T",e.L_CALLPLUS_CLIENT_SET_VIDEO_VIEW_R="L-callplus_client_set_video_view-R",e.L_RTC_MODULE_SET_VIDEO_VIEW_O="L-rtc_module_set_video_view-O",e.L_CALLPLUS_CLIENT_REMOVE_VIDEO_VIEW_T="L-callplus_client_remove_video_view-T",e.L_CALLPLUS_CLIENT_REMOVE_VIDEO_VIEW_R="L-callplus_client_remove_video_view-R",e.L_RTC_MODULE_REMOVE_VIDEO_VIEW_O="L-rtc_module_remove_video_view-O",e.L_CALLPLUS_CLIENT_PLAY_MEDIA_T="L-callplus_client_play_media-T",e.L_CALLPLUS_CLIENT_PLAY_MEDIA_R="L-callplus_client_play_media-R",e.L_RTC_MODULE_PLAY_MEDIA_T="L-rtc_module_play_media-T",e.L_RTC_MODULE_PLAY_MEDIA_R="L-rtc_module_play_media-R",e.L_RTC_MODULE_SET_ALL_REMOTE_AUDIO_ENABLE_T="L-rtc_module_set_all_remote_audio_enbale-T",e.L_RTC_MODULE_SET_ALL_REMOTE_AUDIO_ENABLE_R="L-rtc_module_set_all_remote_audio_enable-R",e.L_RTC_MODULE_SUBSCRIBE_T="L-rtc_module_subscribe-T",e.L_RTC_MODULE_SUBSCRIBE_R="L-rtc_module_subscribe-R",e.L_RTC_MODULE_UNSUBSCRIBE_T="L-rtc_module_unsubscribe-T",e.L_RTC_MODULE_UNSUBSCRIBE_R="L-rtc_module_unsubscribe-R",e.L_RTC_MODULE_PUBLISH_T="L-rtc_module_publish-T",e.L_RTC_MODULE_PUBLISH_R="L-rtc_module_publish-R",e.L_RTC_MODULE_UNPUBLISH_T="L-rtc_module_unpublish-T",e.L_RTC_MODULE_UNPUBLISH_R="L-rtc_module_unpublish-R",e.L_RTC_MODULE_DESTROY_ALL_TRACKS_O="L-rtc_module_destroy_all_tracks-O",e.L_RTC_MODULE_SESSION_CONNECT_T="L-rtc_module_session_connect-T",e.L_RTC_MODULE_SESSION_CONNECT_P="L-rtc_module_session_connect-P",e.L_RTC_MODULE_SESSION_CONNECT_R="L-rtc_module_session_connect-R",e.L_RTC_MODULE_SESSION_CLOSE_T="L-rtc_module_session_close-T",e.L_RTC_MODULE_SESSION_CLOSE_P="L-rtc_module_session_close-P",e.L_RTC_MODULE_SESSION_CLOSE_R="L-rtc_module_session_close-R",e.L_RTC_MODULE_CREATE_VIDEO_TRACK_T="L-rtc_module_create_video_track-T",e.L_RTC_MODULE_CREATE_VIDEO_TRACK_R="L-rtc_module_create_video_track-R",e.L_RTC_MODULE_CREATE_AUDIO_TRACK_T="L-rtc_module_create_audio_track-T",e.L_RTC_MODULE_CREATE_AUDIO_TRACK_R="L-rtc_module_create_audio_track-R",e.L_RTC_MODULE_RECEIVE_TRACK_PUBLISH_O="L-rtc_module_receive_track_publish-O",e.L_RTC_MODULE_RECEIVE_TRACK_UNPUBLISH_O="L-rtc_module_receive_track_unpublish-O",e.L_RTC_MODULE_RECEIVE_TRACK_ENABLE_CHANGE_O="L-rtc_module_receive_track_enable_change-O",e.L_RTC_MODULE_RECEIVE_KICK_OFF_O="L-rtc_module_receive_kick_off-O",e.L_RTC_MODULE_RECEIVE_PEERCONNECTION_EXCEPT_CLOSE_O="L-rtc_module_receive_peerconnection_except_close-O",e.L_RTC_MODULE_CHANGE_MEDIA_TYPE_T="L-rtc_module_change_media_type-T",e.L_RTC_MODULE_CHANGE_MEDIA_TYPE_R="L-rtc_module_change_media_type-R",e.L_RTC_MODULE_JOIN_RTC_ROOM_T="L-rtc_module_join_rtc_room-T",e.L_RTC_MODULE_JOIN_RTC_ROOM_R="L-rtc_module_join_rtc_room-R",e.L_RTC_MODULE_QUIT_RTC_ROOM_T="L-rtc_module_quit_rtc_room-T",e.L_RTC_MODULE_QUIT_RTC_ROOM_R="L-rtc_module_quit_rtc_room-R",e.L_RTC_MODULE_CREATE_CALL_MEDIA_TRACKS_P="L-rtc_module_create_call_media_tracks-P",e.L_SIGNAL_TRANSPORTER_SINGLE_CALL_T="L-signal_transporter_single_call-T",e.L_SIGNAL_TRANSPORTER_GROUP_CALL_T="L-signal_transporter_group_call-T",e.L_SIGNAL_TRANSPORTER_INVITE_T="L-signal_transporter_invite-T",e.L_SIGNAL_TRANSPORTER_RING_T="L-signal_transporter_ring-T",e.L_SIGNAL_TRANSPORTER_ACCEPT_T="L-signal_transporter_accept-T",e.L_SIGNAL_TRANSPORTER_ACCEPT_R="L-signal_transporter_accept-R",e.L_SIGNAL_TRANSPORTER_JOIN_CALL_T="L-signal_transporter_join_call-T",e.L_SIGNAL_TRANSPORTER_HANGUP_T="L-signal_transporter_hangup-T",e.L_SIGNAL_TRANSPORTER_CALL_STATUS_UP_T="L-signal_transporter_call_status_up-T",e.L_SIGNAL_TRANSPORTER_CALL_EVENT_UP_T="L-signal_transporter_call_event_up-T",e.L_SIGNAL_TRANSPORTER_CALL_DIALOG_UP_T="L-signal_transporter_call_dialog_up-T",e.L_SIGNAL_TRANSPORTER_DELETE_CALL_RECORD_T="L-signal_transporter_delete_call_record-T",e.L_SIGNAL_TRANSPORTER_GET_CALL_RECORD_T="L-signal_transporter_get_call_record-T",e.L_SIGNAL_TRANSPORTER_GET_CALL_SERVER_TIME_T="L-signal_transporter_get_call_server_time-T",e.L_SIGNAL_TRANSPORTER_GET_CALL_TIME_INFO_T="L-signal_transporter_get_call_time_info-T",e.L_SIGNAL_TRANSPORTER_GET_AVAILABLE_CALL_LIST_T="L-signal_transporter_get_available_call_list-T",e.L_SIGNAL_TRANSPORTER_CLEAR_CALL_RECORD_T="L-signal_transporter_clear_call_record-T",e.L_SIGNAL_TRANSPORTER_GET_CALL_INFO_BY_CALLID_T="L-signal_transporter_get_call_info_by_callId-T",e.L_SIGNAL_TRANSPORTER_USER_SYSTEM_STATE_UP_T="L-signal_transporter_user_system_state_up-T",e.L_SIGNAL_TRANSPORTER_RECEIVE_CALL_SIGNAL_DATA_O="L-signal_transporter_receive_call_signal_data-O",e.L_SIGNAL_TRANSPORTER_IM_STATE_CHANGE_O="L-signal_transporter_im_state_change-O",e.L_SIGNAL_TRANSPORTER_RECEIVE_INVITE_O="L-signal_transporter_receive_invite-O",e.L_SIGNAL_TRANSPORTER_RECEIVE_CALL_STATUS_O="L-signal_transporter_receive_call_status-O",e.L_SIGNAL_TRANSPORTER_RECEIVE_MISS_MESSAGE_O="L-signal_transporter_receive_miss_message-O",e.L_CALL_ENGINE_UPDATE_USERS_STATE_O="L-call_engine_update_users_state-O",e.L_CALL_ENGINE_IM_STATE_CHANGE_O="L-call_engine_im_state_change-O",e.L_CALL_ENGINE_CALL_TIMEOUT_O="L-call_engine_call_timeout-O",e.L_CALL_ENGINE_START_CALL_TIMER_O="L-call_engine_start_call_timer-O",e.L_CALL_ENGINE_STOP_CALL_TIMER_O="L-call_engine_stop_call_timer-O",e.L_CALL_ENGINE_UP_ON_PHONE_END_T="L-call_engine_up_on_phone_end-T",e.L_CALL_ENGINE_UP_ON_PHONE_END_R="L-call_engine_up_on_phone_end-R",e.L_CALL_ENGINE_RECEIVE_FIRST_FRAME_TIME_O="L-call_engine_receive_first_frame_time-O",e.L_CALL_ENGINE_RECEIVE_MEDIATYPE_CHANGE_O="L-call_engine_receive_mediatype_change-O",e.L_CALL_ENGINE_RECEIVE_CLOSE_SESSION_O="L-call_engine_receive_close_session-O",e.L_CALL_ENGINE_RECEIVE_CALL_RECORD_O="L-call_engine_receive_call_record-O",e.L_CALL_ENGINE_RECEIVE_COMPLEMENTARY_DATA_O="L-call_engine_receive_complementary_data-O",e.L_CALL_ENGINE_CREATE_SESSION_BY_SERVER_T="L-call_engine_create_session_by_server-T",e.L_CALL_ENGINE_CREATE_SESSION_BY_SERVER_R="L-call_engine_create_session_by_server-R",e.L_CALL_ENGINE_UP_FIRST_FRAME_TIME_T="L-call_engine_up_first_frame_time-T",e.L_CALL_ENGINE_UP_FIRST_FRAME_TIME_R="L-call_engine_up_first_frame_time-R",e.L_TIME_CORRECT_START_O="L-time_correct_start-O",e.L_TIME_CORRECT_STOP_O="L-time_correct_stop-O",e.L_TIME_CORRECT_RESTART_O="L-time_correct_restart-O",e.L_TIME_CORRECT_GET_CALL_CLIENT_TIME_BY_SERVER_T="L-time_correct_get_call_client_time_by_server-T",e.L_TIME_CORRECT_GET_CALL_CLIENT_TIME_BY_SERVER_P="L-time_correct_get_call_client_time_by_server-P",e.L_TIME_CORRECT_GET_CALL_CLIENT_TIME_BY_SERVER_R="L-time_correct_get_call_client_time_by_server-R",e.L_TIME_CORRECT_CALC_CLIENT_START_TIME_T="L-time_correct_calc_client_start_time-T",e.L_TIME_CORRECT_CALC_CLIENT_START_TIME_R="L-time_correct_calc_client_start_time-R",e.L_TIME_CORRECT_SET_DELTA_TIME_O="L-time_correct_set_delta_time-O",e.L_TIME_CORRECT_LOOP_CORRECT_CLINET_TIME_T="L-time_correct_loop_correct_client_time-T",e.L_TIME_CORRECT_LOOP_CORRECT_CLINET_TIME_R="L-time_correct_loop_correct_client_time-R",e.L_INNER_SESSION_UPDATE_USER_STATE_O="L-inner_session_update_user_state-O",e.L_INNER_SESSION_SET_USER_DEVICE_ENABLE_O="L-inner_session_set_user_device_enable-O",e.L_CALLPLUS_SESSION_GET_CREATE_TIME_T="L-callplus_session_get_create_time-T",e.L_CALLPLUS_SESSION_GET_CREATE_TIME_R="L-callplus_session_get_create_time-R",e.L_CALLPLUS_SESSION_GET_DURATION_T="L-callplus_session_get_duration-T",e.L_CALLPLUS_SESSION_GET_DURATION_R="L-callplus_session_get_duration-R",e.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O="L-callplus_set_android_push_config-O",e.L_ABNORMAL_ADD_CALL_ID_E="L-ABNORMAL_ADD_CALL_ID-E",e.L_ABNORMAL_REMOVE_CALL_IDS_E="L-ABNORMAL_REMOVE_CALL_IDS-E",e.L_ABNORMAL_GET_CALL_IDS_E="L-ABNORMAL_GET_CALL_IDS-E",e.L_CALLPLUS_CLIENT_SET_AUDIO_OUTPUT_DEVICE_ID_O="L-set_audio_output_device_id-O"}(m_||(m_={})),function(e){e[e.AUDIO=0]="AUDIO",e[e.AUDIO_VIDEO=1]="AUDIO_VIDEO",e[e.VIDEO=2]="VIDEO"}(I_||(I_={}));class S_{constructor(e,t,i,r,n){Object.defineProperty(this,"_session",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_callEngine",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_rtcModule",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"_startTime",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_duration",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_callId",{enumerable:!0,configurable:!0,writable:!0,value:""}),this._callId=this._session.getCallId()}getCallId(){return this._callId}getState(){return this._session.getSessionState()}getCallType(){return this._session.getCallType()}getMediaType(){return this._session.getMediaType()}getUserList(){return this._session.getUserList().map(e=>{const{userId:t,userState:i}=e;let r=null,n=null;return t===this._context.getCurrentId()?(r=this._rtcModule.getLocalVideoTrack(),n=this._rtcModule.getLocalAudioTrack()):(r=this._rtcModule.getRemoteTrack(t,I_.VIDEO),n=this._rtcModule.getRemoteTrack(t,I_.AUDIO)),{userId:t,state:i,cameraEnable:!!r&&!r.isOwnerMuted(),microphoneEnable:!!n&&!n.isOwnerMuted()}})}getCreatorUserId(){return this._session.getStartCallerId()}getInviterUserId(){return this._session.getCallerId()}getCreateTimestamp(){return I(this,void 0,void 0,function*(){const e=this._logger.createTraceId();if(this._logger.info(m_.L_CALLPLUS_SESSION_GET_CREATE_TIME_T,"",e),this._startTime)return{code:T_.SUCCESS,startTime:this._startTime};const{code:t,clientStartTime:i}=yield this._callEngine.getCallStaringTime({callId:this._callId},e);return t!==T_.SUCCESS?(this._logger.error(m_.L_CALLPLUS_SESSION_GET_CREATE_TIME_R,`errCode: ${t}`,e),{code:t}):(this._logger.info(m_.L_CALLPLUS_SESSION_GET_CREATE_TIME_R,"success",e),this._startTime=i,{code:T_.SUCCESS,startTime:this._startTime})})}getDuration(){return I(this,void 0,void 0,function*(){const e=this._logger.createTraceId();if(this._logger.info(m_.L_CALLPLUS_SESSION_GET_DURATION_T,"",e),this._duration)return this._logger.info(m_.L_CALLPLUS_SESSION_GET_DURATION_R,`code: ${T_.SUCCESS}, duration: ${this._duration}`,e),{code:T_.SUCCESS,duration:this._duration};const{code:t,data:i}=yield this._callEngine.getCallTimeInfo(this._callId,e);return t!==T_.SUCCESS?(this._logger.error(m_.L_CALLPLUS_SESSION_GET_DURATION_R,`code: ${t}`,e),{code:t}):(this._logger.info(m_.L_CALLPLUS_SESSION_GET_DURATION_R,`code: ${T_.SUCCESS}, duration: ${i.duration}`,e),this._duration=i.duration,{code:T_.SUCCESS,duration:this._duration})})}}!function(e){e[e.SINGLE=0]="SINGLE",e[e.MULTI=1]="MULTI"}(R_||(R_={}));const C_=R_;var L_;!function(e){e[e.IDLE=0]="IDLE",e[e.CALLING=100]="CALLING",e[e.INVITED=101]="INVITED",e[e.RINGING=102]="RINGING",e[e.BUSYLINE_RINGING=103]="BUSYLINE_RINGING",e[e.BUSYLINE_WAIT=104]="BUSYLINE_WAIT",e[e.CONNECTING=200]="CONNECTING",e[e.ONCALL=300]="ONCALL",e[e.ONPHONE=301]="ONPHONE",e[e.ENDED=1e3]="ENDED",e[e.NO_ANSWER=1001]="NO_ANSWER",e[e.MISSED=1002]="MISSED",e[e.CANCELLED=1003]="CANCELLED",e[e.DECLINED=1004]="DECLINED",e[e.ERROR=2e3]="ERROR"}(L_||(L_={}));const O_=L_;var v_,b_,A_,y_;!function(e){e[e.IDLE=0]="IDLE",e[e.CALLING=100]="CALLING",e[e.INVITED=101]="INVITED",e[e.RINGING=102]="RINGING",e[e.BUSYLINE_RINGING=103]="BUSYLINE_RINGING",e[e.BUSYLINE_WAIT=104]="BUSYLINE_WAIT",e[e.CONNECTING=200]="CONNECTING",e[e.ONCALL=300]="ONCALL",e[e.ENDED=1e3]="ENDED",e[e.NOANSWER=1001]="NOANSWER",e[e.MISSED=1002]="MISSED",e[e.CANCELED=1003]="CANCELED",e[e.DECLINED=1004]="DECLINED",e[e.ERROR=2e3]="ERROR"}(v_||(v_={})),function(e){e[e.CANCEL_CHANGE_MEDIA_TYPE=0]="CANCEL_CHANGE_MEDIA_TYPE",e[e.REFUSE_CHANGE_MEDIA_TYPE=1]="REFUSE_CHANGE_MEDIA_TYPE",e[e.SERVER_ALLOW_MEDIA_TYPE=2]="SERVER_ALLOW_MEDIA_TYPE",e[e.CHANGE_MEDIA_TYPE_TIMEOUT=3]="CHANGE_MEDIA_TYPE_TIMEOUT"}(b_||(b_={})),function(e){e[e.IDLE=0]="IDLE",e[e.CALLING=100]="CALLING",e[e.INVITED=101]="INVITED",e[e.RINGING=102]="RINGING",e[e.BUSYLINE_RINGING=103]="BUSYLINE_RINGING",e[e.BUSYLINE_WAIT=104]="BUSYLINE_WAIT",e[e.CONNECTING=200]="CONNECTING",e[e.ONCALL=300]="ONCALL",e[e.ON_PHONE=301]="ON_PHONE",e[e.ON_PHONE_END=302]="ON_PHONE_END",e[e.ON_DEVICE_DISABLE=303]="ON_DEVICE_DISABLE",e[e.ON_DEVICE_ENABLE=304]="ON_DEVICE_ENABLE",e[e.ABNORMAL_END=999]="ABNORMAL_END",e[e.ENDED=1e3]="ENDED",e[e.NO_ANSWER=1001]="NO_ANSWER",e[e.MISSED=1002]="MISSED",e[e.CANCELLED=1003]="CANCELLED",e[e.DECLINED=1004]="DECLINED",e[e.OTHER_CLIENT_CALLING=1010]="OTHER_CLIENT_CALLING",e[e.OTHER_CLIENT_ACCEPT=1011]="OTHER_CLIENT_ACCEPT",e[e.JOIN_ROOM_ERR=1105]="JOIN_ROOM_ERR",e[e.PUBLISH_ERR=1106]="PUBLISH_ERR",e[e.SUBSCRIBE_ERR=1107]="SUBSCRIBE_ERR",e[e.ACCEPT_CARRIER=1108]="ACCEPT_CARRIER",e[e.KICKED_BY_SERVER=1109]="KICKED_BY_SERVER",e[e.CONNECTION_ERR=1110]="CONNECTION_ERR",e[e.LOGOUT=1111]="LOGOUT",e[e.OTHER_CLIENT_LOGIN=1112]="OTHER_CLIENT_LOGIN",e[e.OTHER_CLIENT_JOINED=1113]="OTHER_CLIENT_JOINED",e[e.OTHER_CLIENT_IN_ROOM=1114]="OTHER_CLIENT_IN_ROOM",e[e.OTHER_CLIENT_HANGUP=1151]="OTHER_CLIENT_HANGUP",e[e.REMOTE_JOIN_RTC_ERROR=1205]="REMOTE_JOIN_RTC_ERROR",e[e.REMOTE_PUBLISH_ERROR=1206]="REMOTE_PUBLISH_ERROR",e[e.REMOTE_SUBSCRIBE_ERROR=1207]="REMOTE_SUBSCRIBE_ERROR",e[e.REMOTE_KICKED_BY_SERVER=1209]="REMOTE_KICKED_BY_SERVER",e[e.REMOTE_CONNECTION_ERROR=1210]="REMOTE_CONNECTION_ERROR",e[e.REMOTE_LOGOUT=1211]="REMOTE_LOGOUT",e[e.REMOTE_OTHER_CLIENT_LOGIN=1212]="REMOTE_OTHER_CLIENT_LOGIN",e[e.REMOTE_OTHER_JOINED_RTC=1213]="REMOTE_OTHER_JOINED_RTC",e[e.REMOTE_OTHER_CLIENT_IN_RTC=1214]="REMOTE_OTHER_CLIENT_IN_RTC"}(A_||(A_={})),function(e){e[e.START=1]="START",e[e.END=2]="END"}(y_||(y_={}));class N_{constructor(e){Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_audioConfig",{enumerable:!0,configurable:!0,writable:!0,value:{}})}setDefaultMicrophoneId(e){return this._audioConfig.microphoneId=e,this}setBitrate(e,t){return!O(e)||!O(t)||t<=0||e<=0||t<e?(this._logger.error(m_.L_CALLPLUS_AUDIO_CONFIG_SET_BITRATE_O,`params error -> max: ${t},min: ${e}, max and min is a number > 0, max should > min`),this):(this._audioConfig.minBitrate=e,this._audioConfig.maxBitrate=t,this)}setSampleRate(e){return O(e)?(this._audioConfig.sampleRate=e,this):(this._logger.error(m_.L_CALLPLUS_AUDIO_CONFIG_SET_SAMPLE_RATE_O,`params error -> sampleRate: ${e}`),this)}build(){return this._audioConfig}}class P_{constructor(e){Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_videoConfig",{enumerable:!0,configurable:!0,writable:!0,value:{resolution:Nt.W640_H480,frameRate:yt.FPS_15}})}setFrameRate(e){return yt[e]?(this._videoConfig.frameRate=e,this):(this._logger.error(m_.L_CALLPLUS_VIDEO_CONFIG_SET_FRAME_RATE_O,`params error -> fps: ${e}`),this)}setVideoResolution(e){return Nt[e]?(this._videoConfig.resolution=e,this):(this._logger.error(m_.L_CALLPLUS_VIDEO_CONFIG_SET_RESOLUTION_O,`params error -> resolution: ${e}`),this)}setDefaultCameraId(e){return this._videoConfig.cameraId=e,this}setBitrate(e,t){return!O(e)||!O(t)||t<=0||e<=0||t<e?(this._logger.error(m_.L_CALLPLUS_VIDEO_CONFIG_SET_BITRATE_O,`params error -> max: ${t},min: ${e}, max and min is a number > 0, max should > min`),this):(this._videoConfig.minBitrate=e,this._videoConfig.maxBitrate=t,this)}build(){return this._videoConfig}}const U_=e=>{const{callId:t,callType:i,callDir:r,mediaType:n,callingUserId:s,callUserIds:o,callStatus:a,sessionStatus:l,startTime:_,endTime:c,duration:d,syncTime:u,sysStatus:h,crtTime:g}=e;return{callId:t,callType:i,callDirection:r,mediaType:n,callerUserId:s,callUserIds:o,sessionState:a,userState:l,startTimestamp:_,endTimestamp:c,duration:d,syncTimestamp:u,systemState:h,createTimestamp:g}},D_=e=>e&&e.nodeName&&"VIDEO"===e.nodeName.toUpperCase(),M_=e=>{const{voipCallInfo:t}=e;if(!t)return!1;const{strategy:i}=JSON.parse(t);return 1===i},w_=(e,t)=>!e&&0!==e||O(e)&&!(e<=0)?!t&&0!==t||O(t)&&!(t<=0)?e&&t&&t<e?{code:T_.PARAM_ERROR,errorMsg:`params error -> maxBitrate: ${t}, minBitrate: ${e}, maxBitrate should > minBitrate`}:{code:T_.SUCCESS}:{code:T_.PARAM_ERROR,errorMsg:`params error -> maxBitrate: a number of > 0, value: ${t}`}:{code:T_.PARAM_ERROR,errorMsg:`params error -> minBitrate: a number of > 0, value: ${e}`},k_=e=>{const t=[];for(const i in e){const{videoView:r,isTiny:n}=e[i];t.push({userId:i,videoView:r.nodeName,isTiny:n})}return t},x_=(e,t={},i={})=>{const{threadId:r,apnsCollapseId:n,richMediaUri:s}=t,{channelIdMi:o,channelIdHW:a,channelIdOPPO:l,typeVivo:_,fcmChannelId:c,fcmCollapseKey:d,fcmImageUrl:u,importanceHW:h,categoryHW:g,imageUrlHW:p,categoryVivo:f,importanceHonor:E,imageUrlHonor:T}=i,m={};r&&(m["thread-id"]=r),m["apns-collapse-id"]=n||e,s&&(m.richMediaUri=s);const I={};a&&(I.channelId=a),p&&(I.image=p),g&&(I.category=g),I.importance=h||"NORMAL";const R=[{HW:I},{APNS:m}];let S,C,L,O;return(d||u||c)&&(S={},d&&(S.collapse_key=d),u&&(S.imageUrl=u),c&&(S.channelId=c),R[0].FCM=S),o&&(R[0].MI={channelId:o}),l&&(C={},C.channelId=l,R[0].OPPO=C),(_||f)&&(L={},_&&(L.classification=_),f&&(L.category=f),R[0].VIVO=L),(E||T)&&(O={},E&&(O.importance=E),T&&(O.image=T),R[0].HONOR=O),JSON.stringify(R)},B_=(e,t)=>{const{pushTitle:i="",iOSConfig:r,androidConfig:n,disablePushTitle:s,templateId:o}=e,a={pushConfigs:x_(t,r,n)};return L(s)&&(a.disableTitle=s),i&&(a.title=i),o&&(a.templateId=o),JSON.stringify(a)},V_=e=>{const t=["pushTitle","pushContent","iOSConfig","androidConfig","disablePushTitle","templateId"];if(!Object.keys(e).every(e=>t.includes(e)))return{code:T_.PARAM_ERROR,errorMsg:`right key: ${t.join(",")}`};for(let i=0;i<t.length;i++){const r=t[i];if("disablePushTitle"===r){if(!P(e[r])&&!L(e[r]))return{code:T_.PARAM_ERROR,errorMsg:`${r} type is boolean`}}else if(("pushTitle"===r||"templateId"===r||"pushContent"===r)&&e[r]&&!C(e[r]))return{code:T_.PARAM_ERROR,errorMsg:`${r} type is string`}}const{iOSConfig:i,androidConfig:r}=e,n=G_(i||{});if(n.code!==T_.SUCCESS)return n;const s=F_(r||{});return s.code!==T_.SUCCESS?s:{code:T_.SUCCESS}},G_=e=>{const{threadId:t,richMediaUri:i}=e||{};return t&&!C(t)?{code:T_.PARAM_ERROR,errorMsg:"iOSConfig.threadId type is string"}:i&&!C(i)?{code:T_.PARAM_ERROR,errorMsg:"iOSConfig.richMediaUri type is string"}:{code:T_.SUCCESS}},F_=e=>{const t=["channelIdMi","channelIdHW","categoryHW","importanceHW","imageUrlHW","channelIdOPPO","typeVivo","categoryVivo","fcmChannelId","fcmCollapseKey","fcmImageUrl","importanceHonor","imageUrlHonor"];if(!Object.keys(e).every(e=>t.includes(e)))return{code:T_.PARAM_ERROR,errorMsg:`right key: ${t.join(",")}`};for(let i=0;i<t.length;i++){const r=t[i];if("importanceHW"===r||"importanceHonor"===r){if(e[r]&&"LOW"!==e[r]&&"NORMAL"!==e[r])return{code:T_.PARAM_ERROR,errorMsg:`androidConfig.${r} value is NORMAL|LOW`}}else if(e[r]&&!C(e[r]))return{code:T_.PARAM_ERROR,errorMsg:`androidConfig.${r} type is string`}}return{code:T_.SUCCESS}},j_=(e,t="utf-8")=>{let i=0;return i="utf-16"===t?H_(e):J_(e),i},H_=e=>{let t,i=0;for(let r=0,n=e.length;r<n;r++)t=e.charCodeAt(r),i+=t<=65535?2:4;return i},J_=e=>{let t,i=0;for(let r=0,n=e.length;r<n;r++)t=e.charCodeAt(r),i+=t<127?1:t<=2047?2:t<=65535?3:4;return i},$_=/Electron/.test(navigator.userAgent);var K_,Y_,q_,W_,z_,Q_;!function(e){e.L_QS_START_CALL_S="Call-start-S",e.L_QS_ACCEPT_CALL_S="Call-accept-S",e.L_QS_HANGUP_CALL_S="Call-hangup-S",e.L_QS_RECEIVE_CALL_S="Call-recv-S",e.L_QS_ABNORMAL_HANGUP_S="Call-interrupt-S"}(K_||(K_={}));class Z_{constructor(e){Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._logger=this._context.logger}reportStatisticsData(e,t,i,r,n,s,o){const a=+new Date,{mediaType:l,callType:_,callId:c}=r?{mediaType:r.getMediaType(),callType:r.getCallType(),callId:r.getCallId()}:o,d={cr:"unknown",net:"unknown",cod:t,mtp:l,ctp:_,cid:c,time:a,uid:this._context.getCurrentId()};n&&Object.assign(d,{ccid:n});let u=null;switch(e){case K_.L_QS_RECEIVE_CALL_S:u=Object.assign(Object.assign({},d),{rf:s});break;case K_.L_QS_ABNORMAL_HANGUP_S:u=Object.assign({},d);break;default:u=Object.assign(Object.assign({},d),{dur:a-i})}this._logger.__statistics(e,JSON.stringify(u))}}!function(e){e.REQUEST="request",e.ACCEPT="accept",e.REFUSE="refuse",e.CANCEL="cancel",e.NOTICE="notice",e.TIMEOUT="timeout"}(Y_||(Y_={})),function(e){e[e.SWITCH_MEDIA_TYPE=1]="SWITCH_MEDIA_TYPE"}(q_||(q_={})),function(e){e[e.NORMAL=0]="NORMAL",e[e.SECRET=1]="SECRET"}(W_||(W_={})),function(e){e.INVITER="inviter",e.INVITEE="invitee"}(z_||(z_={}));class X_ extends B{constructor(e,t,i,r,n,s,o,a){super(),Object.defineProperty(this,"_callId",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_state",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_callType",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_mediaType",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_startCallerId",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"_callerId",{enumerable:!0,configurable:!0,writable:!0,value:s}),Object.defineProperty(this,"_callUsers",{enumerable:!0,configurable:!0,writable:!0,value:o}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:a}),Object.defineProperty(this,"_reqMediaType",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_inviterTimerId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_inviteeTimerId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_oldDialogData",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"isLocalClientHangup",{enumerable:!0,configurable:!0,writable:!0,value:!1})}getCallId(){return this._callId}getSessionState(){return this._state}getCallType(){return this._callType}getMediaType(){return this._mediaType}getStartCallerId(){return this._startCallerId}getCallerId(){return this._callerId}getUserList(){return this._callUsers}getReqMediaType(){return this._reqMediaType}getInviterTimerId(){return this._inviterTimerId}getInviteeTimerId(){return this._inviteeTimerId}getAllTimerIds(){return[this._inviterTimerId,this._inviteeTimerId]}updateUserList(e,t){const i=[];return e.forEach(e=>{const{userState:t,stateTime:r,systemState:n,userId:s}=e,o=this._callUsers.findIndex(e=>e.userId===s);if(o<0)return this._callUsers.push(e),void i.push(e);const{stateTime:a,systemState:l,userState:_}=this._callUsers[o],c=((e,t)=>{let i=!1;const r=[A_.INVITED,A_.RINGING,A_.BUSYLINE_RINGING,A_.BUSYLINE_WAIT,A_.CONNECTING,A_.ONCALL];return e===A_.ONCALL&&r.includes(t)&&(i=!0),i})(l,n),d=((e,t)=>{let i=!1;const r=[O_.INVITED,O_.RINGING,O_.BUSYLINE_RINGING,O_.BUSYLINE_WAIT,O_.CONNECTING,O_.ONCALL];return e===O_.ONCALL&&r.includes(t)&&(i=!0),i})(_,t),u=n===A_.ON_PHONE_END&&l!==A_.ON_PHONE&&t!==O_.IDLE;r&&a&&r<a||c&&d||(this._callUsers[o]=e,!u&&i.push(e))}),i}setOldDialogData(e){this._oldDialogData=e}updateSessionState(e){this._state=e}updateCallType(e){this._callType=e}updateMediaType(e){this._mediaType=e}updateReqMediaType(e){this._reqMediaType=e}updateTimerId(e,t){e===z_.INVITER?this._inviterTimerId=t:this._inviteeTimerId=t}getOldDialogData(){return this._oldDialogData}setIsLocalClientHangup(e){this.isLocalClientHangup=e}getIsLocalClientHangup(){return this.isLocalClientHangup}}!function(e){e.START_SINGLE_CALL="startSingleCall",e.START_GROUP_CALL="startGroupCall",e.INVITE_CALL="inviteCall",e.PUB_INVITE_CALL="pubInviteCall",e.RINGING_CALL="ringCall",e.ACCEPT_CALL="acceptCall",e.JOIN_CALL="joinCall",e.HANGUP_CALL="hangupCall",e.STATUS_UP_CALL="statusUpCall",e.STATUS_DOWN_CALL="statusDownCall",e.EVENT_UP_CALL="eventUpCall",e.EVENT_DOWN_CALL="eventDownCall",e.DIALOG_UP_CALL="dialogUpCall",e.DIALOG_DOWN_CALL="dialogDownCall",e.GET_CALL_USER_SESSION_LIST="getCallUSerSessionList",e.SYNC_CALL_LOG="syncCallLog",e.PUB_CALL_LOG="pubCallLog",e.DEL_CALL_LOG="deleteCallLog",e.QRY_CALL_STATE="queryUserHasCall",e.QRY_SRV_TIMESTAMP="getCallSrvTimeStamp",e.GET_CALL_STATE_LIST="getUserCallStateList",e.CLEAR_CALL_LOG="cleanCallLog",e.GET_CALL_SESSION="getCallSession",e.GET_CALL_TIME_INFO="getCallTimeInfo",e.END_ABNORMAL_CALL="endUserAbnormalCalls",e.SYS_STATUS_UP="sysStatusUp",e.UP_CALL_LOG_READED="upCallLogReaded",e.PUB_CALL_LOG_READED="pubCallLogReaded",e.PUB_NACK_SEQ_ID="pubNACKSeqId",e.GET_USER_CALL_SESSION_ID_LIST="getUserCallSessionIdList"}(Q_||(Q_={}));const ec=(e,t)=>setTimeout(e,t),tc=[_e,ce,de,ue.SIGNAL_DISCONNECTED,ue.REQUEST_FAILED],ic=e=>I(void 0,[e],void 0,function*({asyncFn:e,fnArgs:t,currentRetryTime:i=Date.now(),maxDuration:r=6e4,intervals:n=[2e3,4e3,8e3,16e3,32e3,64e3],index:s=0,onError:o}){const a=yield e(...t);return a.code===T_.SUCCESS||!tc.includes(a.code)||Date.now()+2e3-i>r?a:(o&&o(a.code),yield(l=2e3,new Promise(e=>{setTimeout(e,l)})),ic({asyncFn:e,fnArgs:t,currentRetryTime:i,maxDuration:r,intervals:n,index:s,onError:o}));var l});var rc,nc,sc;!function(e){e.onBeforePublish="onBeforePublish",e.onPublishRes="onPublishRes",e.onPubInviteCall="onPubInviteCall",e.onPubInviteCallPullKv="onPubInviteCallPullKv",e.onPubInviteCallMiss="onPubInviteCallMiss"}(rc||(rc={})),function(e){e.NOT_CURRENT_DEVICEID="not current device id",e.SECRET_CALL="secret call",e.NOT_INVITEE="not an invitee"}(nc||(nc={})),function(e){e.PUB_INVITE="pubinvitecall",e.PULL_KV_INVITE="pullkv_invitecall",e.PUSH="system_pubsh"}(sc||(sc={}));const oc=131072,ac="RC:CallPlusMiss",lc="RC:CallGroupStatusMsg";class _c extends B{constructor(e,t,i,r,n,s){var o,a,l,_,c,d;super(),Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_runtime",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_initOpts",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_timeCorrectioner",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"_reportAppEventModule",{enumerable:!0,configurable:!0,writable:!0,value:s}),Object.defineProperty(this,"_listener",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_needRetryActions",{enumerable:!0,configurable:!0,writable:!0,value:[Q_.START_SINGLE_CALL,Q_.START_GROUP_CALL,Q_.ACCEPT_CALL,Q_.JOIN_CALL,Q_.EVENT_UP_CALL]}),Object.defineProperty(this,"_sessionId",{enumerable:!0,configurable:!0,writable:!0,value:""}),null===(a=(o=this._context).registerGroupCallSignalInfoListener)||void 0===a||a.call(o,e=>this._onRecvCallSignal(e)),null===(_=(l=this._context).registerConnectionStateChangeListener)||void 0===_||_.call(l,(e,t)=>this._onIMConnectionStateChange(e)),null===(d=(c=this._context).registerMessageListener)||void 0===d||d.call(c,e=>this._onMessage(e)),this._sessionId=J.genWithLen(22)}_onMessage(e){return!![ac,lc].includes(e.messageType)&&(e.messageType===ac?this._dealMissMessage(e):this._dealGroupCallMessage(e),!0)}_dealMissMessage(e){const t=e.content,{callId:i,mediaType:r,startTime:s,callSessionUsers:o}=t,{targetId:a,senderUserId:l}=e,_=this._context.getCurrentId();if(!localStorage.getItem(`missMessageMap-${_}-${i}`)){const t={callId:i,callerUserId:l,targetId:a,mediaType:r,firstFrameTime:0,callStartTime:s-this._timeCorrectioner.getLocalDelayTime(),callEndTime:0,hangupReason:o.filter(({userId:e})=>e===_)[0].sessionStatus};this._logger.info(m_.L_SIGNAL_TRANSPORTER_RECEIVE_MISS_MESSAGE_O,`receive miss message: ${JSON.stringify(e)}`);const c=Object.assign(e,{content:t,sentStatus:n.SENT});this._reportAppEventModule.onReceivedCallPlusSummaryMessage(c),localStorage.setItem(`missMessageMap-${_}-${i}`,i)}}_dealGroupCallMessage(e){this._reportAppEventModule.onReceivedGroupCallStatusMessage(e)}getSessionId(){return this._sessionId}getDeviceId(){return $_&&"function"==typeof this._context.getDeviceId?this._context.getDeviceId():this._sessionId}registerListener(e){this._listener=e}startCall(e,t){return I(this,void 0,void 0,function*(){const{clientCallId:i,callType:r,toUsers:n,mediaType:s,secretChat:o,targetType:a,targetId:l,nickName:_,oldRoomId:c,pushExt:d,pushContent:u,extra:h}=e;return r===C_.SINGLE?this.startSingleCall({clientCallId:i,toUserId:n[0].userId,mediaType:s,secretChat:o,targetType:a,targetId:l,oldRoomId:c,toOrgId:n[0].orgId||"",pushExt:d,pushContent:u,extra:h},t):this.startGroupCall({clientCallId:i,toUsers:n,mediaType:s,targetType:a,targetId:l,nickName:_,oldRoomId:c,pushExt:d,pushContent:u,extra:h},t)})}startSingleCall(e,t){return I(this,void 0,void 0,function*(){return this._logger.info(m_.L_SIGNAL_TRANSPORTER_SINGLE_CALL_T,`params: ${JSON.stringify(e)}`,t),this._sendCallSignal(this._context.getCurrentId(),Q_.START_SINGLE_CALL,e)})}startGroupCall(e,t){return I(this,void 0,void 0,function*(){return this._logger.info(m_.L_SIGNAL_TRANSPORTER_GROUP_CALL_T,`params: ${JSON.stringify(e)}`,t),this._sendCallSignal(this._context.getCurrentId(),Q_.START_GROUP_CALL,e)})}inviteCall(e,t){return I(this,void 0,void 0,function*(){return this._logger.info(m_.L_SIGNAL_TRANSPORTER_INVITE_T,`params: ${JSON.stringify(e)}`,t),this._sendCallSignal(e.callId,Q_.INVITE_CALL,e)})}ringingCall(e,t){return I(this,void 0,void 0,function*(){return this._logger.info(m_.L_SIGNAL_TRANSPORTER_RING_T,`params: ${JSON.stringify(e)}`,t),this._sendCallSignal(e.callId,Q_.RINGING_CALL,e)})}acceptCall(e,t){return I(this,void 0,void 0,function*(){return this._logger.info(m_.L_SIGNAL_TRANSPORTER_ACCEPT_T,`params: ${JSON.stringify(e)}`,t),this._sendCallSignal(e.callId,Q_.ACCEPT_CALL,e)})}joinCall(e,t){return I(this,void 0,void 0,function*(){return this._logger.info(m_.L_SIGNAL_TRANSPORTER_JOIN_CALL_T,`params: ${JSON.stringify(e)}`,t),this._sendCallSignal(e.callId,Q_.JOIN_CALL,e)})}hangupCall(e,t){return I(this,void 0,void 0,function*(){this._logger.info(m_.L_SIGNAL_TRANSPORTER_HANGUP_T,`params: ${JSON.stringify(e)}`,t);const{code:i}=yield this._sendCallSignal(e.callId,Q_.HANGUP_CALL,e);return i===T_.NOT_IN_CALL?{code:T_.SUCCESS}:{code:i}})}statusUpCall(e,t){return I(this,void 0,void 0,function*(){return this._logger.info(m_.L_SIGNAL_TRANSPORTER_CALL_STATUS_UP_T,`call status up params: ${JSON.stringify(e)}`,t),this._sendCallSignal(e.callId,Q_.STATUS_UP_CALL,e)})}eventUpCall(e,t){return I(this,void 0,void 0,function*(){return this._logger.info(m_.L_SIGNAL_TRANSPORTER_CALL_EVENT_UP_T,`params: ${JSON.stringify(e)}`,t),this._sendCallSignal(e.callId,Q_.EVENT_UP_CALL,e)})}dialogUpCall(e,t){return I(this,void 0,void 0,function*(){return this._logger.info(m_.L_SIGNAL_TRANSPORTER_CALL_DIALOG_UP_T,`params: ${JSON.stringify(e)}`,t),this._sendCallSignal(e.callId,Q_.DIALOG_UP_CALL,e)})}deleteCallRecord(e,t,i){return I(this,void 0,void 0,function*(){return this._logger.info(m_.L_SIGNAL_TRANSPORTER_DELETE_CALL_RECORD_T,`callIds: ${JSON.stringify(t)}`,i),this._sendCallSignal(e,Q_.DEL_CALL_LOG,{callIds:t})})}syncCallLog(e,t){return I(this,void 0,void 0,function*(){return this._logger.info(m_.L_SIGNAL_TRANSPORTER_GET_CALL_RECORD_T,`params: ${JSON.stringify(e)}`,t),this._sendCallSignal(e.userId,Q_.SYNC_CALL_LOG,e)})}queryUserHasCall(){return I(this,void 0,void 0,function*(){const e=this._context.getCurrentId();return this._sendCallSignal(e,Q_.QRY_CALL_STATE,null)})}getCallServerTimestamp(e){return I(this,void 0,void 0,function*(){const t=this._context.getCurrentId();return this._logger.info(m_.L_SIGNAL_TRANSPORTER_GET_CALL_SERVER_TIME_T,`userId: ${t}`,e),this._sendCallSignal(t,Q_.QRY_SRV_TIMESTAMP,null)})}getCallTimeInfo(e,t){return I(this,void 0,void 0,function*(){return this._logger.info(m_.L_SIGNAL_TRANSPORTER_GET_CALL_TIME_INFO_T,`callId: ${e}`,t),this._sendCallSignal(e,Q_.GET_CALL_TIME_INFO,{callId:e})})}getUserCallStateList(e){return I(this,void 0,void 0,function*(){const t=this._context.getCurrentId();return this._logger.info(m_.L_SIGNAL_TRANSPORTER_GET_AVAILABLE_CALL_LIST_T,`userId: ${t}`,e),this._sendCallSignal(t,Q_.GET_CALL_STATE_LIST,null)})}clearCallRecord(e){return I(this,void 0,void 0,function*(){const t=this._context.getCurrentId();return this._logger.info(m_.L_SIGNAL_TRANSPORTER_CLEAR_CALL_RECORD_T,`userId: ${t}`,e),this._sendCallSignal(t,Q_.CLEAR_CALL_LOG,null)})}getCallSession(e,t){return I(this,void 0,void 0,function*(){return this._logger.info(m_.L_SIGNAL_TRANSPORTER_GET_CALL_INFO_BY_CALLID_T,`callId: ${e.callId}`,t),this._sendCallSignal(e.callId,Q_.GET_CALL_SESSION,e)})}sysStatusUp(e,t){return I(this,void 0,void 0,function*(){return this._logger.info(m_.L_SIGNAL_TRANSPORTER_USER_SYSTEM_STATE_UP_T,`opts: ${JSON.stringify(e)}`,t),this._sendCallSignal(e.callId,Q_.SYS_STATUS_UP,e)})}upCallLogReaded(e){return I(this,void 0,void 0,function*(){const t=this._context.getCurrentId();return this._sendCallSignal(t,Q_.UP_CALL_LOG_READED,e)})}endUserAbnormalCalls(e){return I(this,void 0,void 0,function*(){return this._sendCallSignal(this._context.getCurrentId(),Q_.END_ABNORMAL_CALL,e)})}_onIMConnectionStateChange(e){const t=this._logger.createTraceId();this._logger.info(m_.L_SIGNAL_TRANSPORTER_IM_STATE_CHANGE_O,`state: ${e}`,t),this._listener.onIMStateChange(e),e===l.CONNECTED?this._timeCorrectioner.start(t):this._timeCorrectioner.stop(t)}_sendCallSignal(e,t,i){return I(this,void 0,void 0,function*(){var r;let n="";i&&(n=$_?JSON.stringify(i):JSON.stringify(Object.assign(Object.assign({},i),{sessionId:this._sessionId})));const s=null===(r=this._context.sendGroupCallSignalInfo)||void 0===r?void 0:r.bind(this._context);if(!s)return{code:T_.SIGNAL_DISCONNECTED};let o;if(this._needRetryActions.includes(t))o=yield ic({asyncFn:(e,t,i)=>s(e,t,i).then(e=>({code:e.code,data:e.data})),fnArgs:[e,t,n]});else{const i=yield s(e,t,n);o={code:i.code,data:i.data}}const{code:a,data:l}=o;if(a!==oe)return{code:a};const _=null==l?void 0:l.value;if(null==_)return{code:T_.PARAM_ERROR};const c=JSON.parse(_).data;return{code:T_.SUCCESS,data:c}})}_onRecvCallSignal(e){const t=this._logger.createTraceId();this._logger.info(m_.L_SIGNAL_TRANSPORTER_RECEIVE_CALL_SIGNAL_DATA_O,`data: ${e}`,t);JSON.parse(e).list.forEach(e=>{const{key:i}=e,r=JSON.parse(e.value);switch(i){case Q_.PUB_INVITE_CALL:this._onPubInviteCall(r,t,!0);break;case Q_.STATUS_DOWN_CALL:this._onStatusDownCall(r,t);break;case Q_.EVENT_DOWN_CALL:this._onEventDownCall(r,t);break;case Q_.DIALOG_DOWN_CALL:this._onDialogDownCall(r,t);break;case Q_.PUB_CALL_LOG:this._onPubCallLog(r,t);break;case Q_.PUB_CALL_LOG_READED:case Q_.PUB_NACK_SEQ_ID:break;default:this._onConpensationData(r,t)}})}isValidData(e){if(t=e,"[object Null]"===Object.prototype.toString.call(t))return!0;var t;const i=e===this.getDeviceId();return!(!C(e)||0!==(null==e?void 0:e.length)&&!i)}_onPubInviteCall(e,t,i=!0){try{const i=this._context.getCurrentId(),r=e.callSessionUsers.find(e=>e.userId===i),n=this._context.getConnectionStatus();this._logger.info(m_.L_SIGNAL_TRANSPORTER_RECEIVE_INVITE_O,`currentUser: ${JSON.stringify(r)}, currentUserId: ${i}, state: ${n}`,t)}catch(e){this._logger.error(m_.L_SIGNAL_TRANSPORTER_RECEIVE_INVITE_O,`error: ${e.message}`,t)}if(!this.isValidData(e.toDeviceId||"")){this._logger.warn(m_.L_SIGNAL_TRANSPORTER_RECEIVE_INVITE_O,`not current deviceId -> deviceInfo: ${JSON.stringify({toDeviceId:e.toDeviceId,clientDeviceId:this.getDeviceId()})}`,t);const r={extra:JSON.stringify(e),reason:nc.NOT_CURRENT_DEVICEID,refer:i?sc.PUB_INVITE:sc.PULL_KV_INVITE};return void this.emit(rc.onPubInviteCallMiss,Object.assign(e,r))}this._listener.onInvite(e,i,t),i?this.emit(rc.onPubInviteCall,Object.assign(e,{extra:JSON.stringify(e)})):this.emit(rc.onPubInviteCallPullKv,Object.assign(e,{extra:JSON.stringify(e)}))}_onStatusDownCall(e,t){if(e.callSessionUsers=e.callSessionUsers.filter(e=>Boolean(e.changed)),this._logger.info(m_.L_SIGNAL_TRANSPORTER_RECEIVE_CALL_STATUS_O,"",t),!this.isValidData(e.toDeviceId||""))return this._logger.warn(m_.L_SIGNAL_TRANSPORTER_RECEIVE_CALL_STATUS_O,`not current deviceId -> deviceInfo: ${JSON.stringify({toDeviceId:e.toDeviceId,clientDeviceId:this.getDeviceId()})}`,t),void this._listener.onOtherClientStatusDown(e,t);this._listener.onStatusDown(e,t,this._sessionId)}_onEventDownCall(e,t){this._listener.onEventDown(e,t)}_onDialogDownCall(e,t){const{dialogType:i}=e;i===q_.SWITCH_MEDIA_TYPE&&this._listener.onSwitchMediaType(e,t)}_onPubCallLog(e,t){this._logger.info(m_.L_CALL_ENGINE_RECEIVE_CALL_RECORD_O,`call record: ${JSON.stringify(e)}`,t),this._listener.onRecvCallEndLog(e,t)}_onConpensationData(e,t){this._logger.info(m_.L_CALL_ENGINE_RECEIVE_COMPLEMENTARY_DATA_O,"",t);const{callId:i,callType:r,mediaType:n,secretChat:s,duration:o,callStatus:a,callingUserId:l,callSessionUsers:_,toDeviceId:c,callDialogEntitys:d,extra:u}=e;_.some(e=>e.sessionStatus===O_.INVITED&&e.userId===this._context.getCurrentId())?this._onPubInviteCall({callId:i,toDeviceId:c,callType:r,mediaType:n,inviteUserId:l,callingUserId:l,callSessionUsers:_,secretChat:s,extra:u},t,!0):this._onStatusDownCall({callId:i,toDeviceId:c,callStatus:a,duration:o,callSessionUsers:_},t),d.length>0&&d.forEach(e=>this._onDialogDownCall(e,t),this)}}const cc=()=>{let e="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)});return e=`${e.replace(/-/g,"")}0`,e=parseInt(e,16),e=(e=>{const t="0123456789abcdefghigklmnopqrstuvwxyzABCDEFGHIGKLMNOPQRSTUVWXYZ+/".split(""),i=t.length+1;let r=+e;const n=[];do{const e=r%i;r=(r-e)/i,n.unshift(t[e])}while(r);return n.join("")})(e),e.length>22&&(e=e.slice(0,22)),e};class dc{constructor(e,t){Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_localStore",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._localStore=e.localStorage}addAbnormallCallId(e,t){try{const i=JSON.parse(this._localStore.getItem(dc._STORAGE_KEY)||"{}");let r=i[e];r?r.push(t):r=[t],i[e]=r,this._localStore.setItem(dc._STORAGE_KEY,JSON.stringify(i))}catch(e){this._logger.error(m_.L_ABNORMAL_ADD_CALL_ID_E,e.message),console.error(e)}}removeAbnormalCallIds(e,t){try{const i=JSON.parse(this._localStore.getItem(dc._STORAGE_KEY)||"{}");let r=i[e];r&&(r=r.filter(e=>!t.includes(e)),r.length>0?i[e]=r:delete i[e],this._localStore.setItem(dc._STORAGE_KEY,JSON.stringify(i)))}catch(e){this._logger.error(m_.L_ABNORMAL_REMOVE_CALL_IDS_E,e.message),console.error(e)}}getAbnormalCallIds(e){let t=null;try{const i=JSON.parse(this._localStore.getItem(dc._STORAGE_KEY)||"{}")[e];i&&(t=i)}catch(e){this._logger.error(m_.L_ABNORMAL_GET_CALL_IDS_E,e.message),console.error(e)}return Promise.resolve(t)}}var uc,hc,gc,pc,fc;Object.defineProperty(dc,"_STORAGE_KEY",{enumerable:!0,configurable:!0,writable:!0,value:"CallPlus_AbnormalCall"}),function(e){e[e.PROMPT=0]="PROMPT",e[e.CALL_DURATION=10]="CALL_DURATION",e[e.FIRST_FRAME=20]="FIRST_FRAME"}(uc||(uc={})),function(e){e[e.SUCCESS=0]="SUCCESS",e[e.INVALID_RESPONSE_TIME=80170]="INVALID_RESPONSE_TIME",e[e.NONOPTIMAL_RES_TIME=80171]="NONOPTIMAL_RES_TIME"}(hc||(hc={}));class Ec{constructor(e,t,i){Object.defineProperty(this,"_callEngine",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_singleCallDurationEv",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_RTT",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_validMinRTT",{enumerable:!0,configurable:!0,writable:!0,value:200}),Object.defineProperty(this,"_validMaxRTT",{enumerable:!0,configurable:!0,writable:!0,value:1e3}),Object.defineProperty(this,"_deltaTime",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_timerId",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_interval",{enumerable:!0,configurable:!0,writable:!0,value:2e3}),Object.defineProperty(this,"_maxRetryTimes",{enumerable:!0,configurable:!0,writable:!0,value:8}),Object.defineProperty(this,"_startTimes",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_retryTimesInCall",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_maxRetryTimesInCall",{enumerable:!0,configurable:!0,writable:!0,value:3})}getCallClientTimeByServer(e,t){return I(this,void 0,void 0,function*(){this._logger.info(m_.L_TIME_CORRECT_GET_CALL_CLIENT_TIME_BY_SERVER_T,`callId: ${e}`,t),(!this._RTT||this._RTT>this._validMinRTT)&&(yield this._getDeltaTime(t)),this._RTT>this._validMaxRTT&&this._logger.error(m_.L_TIME_CORRECT_GET_CALL_CLIENT_TIME_BY_SERVER_R,`code: ${hc.INVALID_RESPONSE_TIME}`,t);const{code:i,data:r}=yield this._callEngine.getCallTimeInfo(e,t);if(i!==T_.SUCCESS)return this._logger.error(m_.L_TIME_CORRECT_GET_CALL_CLIENT_TIME_BY_SERVER_R,`code: ${i}`,t),{code:i};const{startTime:n}=r,s=Math.floor(n-this._deltaTime);let o=(Date.now()+this._deltaTime-n)/1e3;return o<0&&(this._logger.warn(m_.L_TIME_CORRECT_GET_CALL_CLIENT_TIME_BY_SERVER_P,`invalid duration: ${o}`,t),o=0),o=Math.floor(o),this._RTT>this._validMinRTT&&this._RTT<=this._validMaxRTT&&this._logger.error(m_.L_TIME_CORRECT_GET_CALL_CLIENT_TIME_BY_SERVER_R,`code: ${hc.NONOPTIMAL_RES_TIME}`,t),this._logger.info(m_.L_TIME_CORRECT_GET_CALL_CLIENT_TIME_BY_SERVER_R,JSON.stringify({rtt:this._RTT,deltaT:this._deltaTime,serverStartTime:n,clientStartTime:s,duration:o}),t),{code:i,duration:o,clientStartTime:n?s:n}})}calcClientStartTime(e,t,i){if(this._logger.info(m_.L_TIME_CORRECT_CALC_CLIENT_START_TIME_T,`callId: ${e}, startTime: ${t}`,i),this._RTT>this._validMaxRTT)return this._logger.error(m_.L_TIME_CORRECT_CALC_CLIENT_START_TIME_R,`code: ${hc.INVALID_RESPONSE_TIME}`,i),this._loopCorrectClientTime(e,i),{code:hc.INVALID_RESPONSE_TIME};const r=Math.floor(t-this._deltaTime);return this._logger.info(m_.L_TIME_CORRECT_CALC_CLIENT_START_TIME_R,JSON.stringify({rtt:this._RTT,deltaT:this._deltaTime,startT:t,clientStartTime:r}),i),this._RTT>this._validMinRTT&&(this._retryTimesInCall=0,this._loopCorrectClientTime(e,i)),{code:hc.SUCCESS,clientStartTime:r}}start(e){this._timerId||this._startTimes>=this._maxRetryTimes||(this._logger.info(m_.L_TIME_CORRECT_START_O,`timerId: ${this._timerId}`),this._startTimes++,this._getDeltaTime(e),this._timerId=ec(()=>{this._timerId=null,this.start(e)},this._interval))}stop(e){this._logger.info(m_.L_TIME_CORRECT_STOP_O,`timerId: ${this._timerId}`,e),this._timerId&&clearTimeout(this._timerId),this._timerId=null,this._startTimes=0}restart(e){this._logger.info(m_.L_TIME_CORRECT_RESTART_O,`legal rtt time, RTT: ${this._RTT}, validMinRTT: ${this._validMinRTT}`,e),this._RTT<this._validMinRTT||(this.stop(e),this.start(e))}getLocalDelayTime(){return Math.round(this._deltaTime)}getRTT(){return this._RTT}_getDeltaTime(e){return I(this,void 0,void 0,function*(){const t=Date.now(),{code:i,data:r}=yield this._callEngine.getCallServerTimestamp(e),n=Date.now();if(i!==T_.SUCCESS)return{code:i};const s=n-t;return(s<this._RTT||0===this._RTT)&&s<=this._validMaxRTT&&(this._RTT=s),s<this._validMinRTT&&this.stop(e),this._deltaTime=r-t-this._RTT/2,this._logger.info(m_.L_TIME_CORRECT_SET_DELTA_TIME_O,JSON.stringify({rtt:this._RTT,deltaT:this._deltaTime}),e),{code:i,delayTime:this._deltaTime}})}_getDeltaTimeInCall(e,t){return I(this,void 0,void 0,function*(){const i=Date.now(),{code:r,data:n}=yield this._callEngine.getCallTimeInfo(e,t),s=Date.now();if(r!==T_.SUCCESS)return{code:r};const o=s-i;o<this._RTT&&(this._RTT=o),this._deltaTime=n.syncTime-i-this._RTT/2,this._logger.info(m_.L_TIME_CORRECT_SET_DELTA_TIME_O,JSON.stringify({callId:e,rtt:this._RTT,deltaT:this._deltaTime}),t);const a=Math.floor(n.startTime-this._deltaTime),l=Math.floor(n.firstFrametime-this._deltaTime);return o<this._validMinRTT?{code:hc.SUCCESS,clientStartTime:a,clientFirstFrameTime:l}:{code:hc.INVALID_RESPONSE_TIME,clientStartTime:a,clientFirstFrameTime:l}})}_loopCorrectClientTime(e,t){return I(this,void 0,void 0,function*(){this.stop(t),this._logger.info(m_.L_TIME_CORRECT_LOOP_CORRECT_CLINET_TIME_T,`callId: ${e}`,t);const{code:i,clientStartTime:r,clientFirstFrameTime:n}=yield this._getDeltaTimeInCall(e,t);return i===hc.SUCCESS?(this._logger.info(m_.L_TIME_CORRECT_LOOP_CORRECT_CLINET_TIME_R,`code: ${T_.SUCCESS}`,t),void this._singleCallDurationEv(e,r,n,t)):this._retryTimesInCall>this._maxRetryTimesInCall&&i===hc.INVALID_RESPONSE_TIME?(this._logger.info(m_.L_TIME_CORRECT_LOOP_CORRECT_CLINET_TIME_R,`code: ${hc.INVALID_RESPONSE_TIME}`,t),void this._singleCallDurationEv(e,r,n,t)):void(this._retryTimesInCall>this._maxRetryTimesInCall||(this._retryTimesInCall++,setTimeout(()=>{this._loopCorrectClientTime(e,t)},this._interval)))})}}!function(e){e[e.SOON_AFETER=0]="SOON_AFETER",e[e.CURRENT=1]="CURRENT"}(gc||(gc={})),function(e){e[e.PUB_INVITE_CALL=0]="PUB_INVITE_CALL",e[e.PULL_KV_INVITE_CALL=1]="PULL_KV_INVITE_CALL",e[e.SYSTEM_PUSH=2]="SYSTEM_PUSH"}(pc||(pc={})),function(e){e[e.OUT=-1]="OUT",e[e.GROUP=0]="GROUP",e[e.IN=1]="IN"}(fc||(fc={}));const Tc=fc;class mc extends B{constructor(e,t,i,r,n){super(),Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_runtime",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_initOpts",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_reportAppEventModule",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"_mainSession",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_holdSessions",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_signalModule",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_abnormalModule",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_isUpFirstFrameTime",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_callStartMap",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_timeCorrectioner",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_clientCallId",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(this,"_rtcModule",{enumerable:!0,configurable:!0,writable:!0,value:null}),this._timeCorrectioner=new Ec(this,r,this._onRecvSinCallDuration.bind(this)),this._signalModule=new _c(e,t,i,this._timeCorrectioner,this._logger,this._reportAppEventModule),this._signalModule.registerListener({onInvite:this._onInvite.bind(this),onStatusDown:this._onStatusDown.bind(this),onOtherClientStatusDown:this._onOtherClientStatusDown.bind(this),onEventDown:this._onEventDown.bind(this),onSwitchMediaType:this._onSwitchMediaType.bind(this),onRecvCallEndLog:this._onRecvCallEndLog.bind(this),onIMStateChange:this._onIMStateChange.bind(this)}),this._abnormalModule=new dc(t,r)}startCall(e,t){return I(this,void 0,void 0,function*(){const i=this._context.getCurrentId(),{callType:r,mediaType:n,toUsers:s,targetId:o,targetType:a,oldRoomId:l,pushConfig:_,extra:c}=e;this._clientCallId=e.callId;const d=_?B_(_,this._clientCallId):"",{code:u,data:h}=yield this._signalModule.startCall({clientCallId:this._clientCallId,callType:r,mediaType:n,toUsers:s,secretChat:W_.NORMAL,targetType:a,targetId:o,oldRoomId:l,pushExt:d,pushContent:(null==_?void 0:_.pushContent)||"",extra:c},t);if(u!==T_.SUCCESS)return{code:u};const{callId:g,busylineUsers:p}=h;if(this._abnormalModule.addAbnormallCallId(i,g),this._mainSession=new X_(g,v_.INVITED,r,n,i,i,[],this._logger),r===C_.SINGLE){const e=this._startTimer(h.callId,O_.NO_ANSWER,t);this._mainSession.updateTimerId(z_.INVITER,e)}const f={userId:i,userState:O_.CALLING,systemState:A_.CALLING,targetType:a,targetId:o};let E=s.map(({userId:e,targetType:t,targetId:i})=>({userId:e,userState:O_.INVITED,systemState:A_.INVITED,targetType:t,targetId:i})),T=[];p&&(T=p.map(e=>{const{targetType:t,targetId:i}=E.find(t=>t.userId===e.userId);return{userId:e.userId,userState:e.sessionStatus,systemState:A_.BUSYLINE_RINGING,targetType:t,targetId:i}}),E=E.filter(({userId:e})=>T.every(({userId:t})=>t!==e)));const m=this.updateUsersState(g,[f,...E,...T],t);return setTimeout(()=>{m.length>0&&this.reportRemoteUserStateChange(g,m,t)}),{code:u,data:h}})}invite(e,t){return I(this,void 0,void 0,function*(){var i;if(!this._mainSession)return{code:T_.NOT_IN_CALL};const{toUsers:r,pushConfig:n,extra:s}=e,o=n?B_(n,this._clientCallId):"",a=this._mainSession.getCallId(),{code:l,data:_}=yield this._signalModule.inviteCall({callId:a,toUsers:r,pushExt:o,pushContent:(null==n?void 0:n.pushContent)||"",extra:s},t);if(l===T_.SUCCESS){this._mainSession.getCallType()===C_.SINGLE&&(this._mainSession.updateCallType(C_.MULTI),this._onCallTypeChange(this._mainSession.getCallId(),C_.MULTI,t));let e=r.map(({userId:e,targetType:t,targetId:i})=>({userId:e,userState:O_.INVITED,systemState:A_.INVITED,targetType:t,targetId:i})),n=[];_.busylineUsers&&(n=null===(i=_.busylineUsers)||void 0===i?void 0:i.map(t=>{const{targetType:i,targetId:r}=e.find(e=>e.userId===t.userId);return{userId:t.userId,userState:t.sessionStatus,systemState:A_.BUSYLINE_RINGING,targetType:i,targetId:r}}),e=e.filter(({userId:e})=>n.every(({userId:t})=>t!==e)));const s=this.updateUsersState(a,[...e,...n],t);s.length>0&&this.reportRemoteUserStateChange(a,s,t)}return{code:l,data:_}})}clearAllTimer(e,t){[this._mainSession,...this._holdSessions].forEach(i=>{i&&i.getCallId()===e&&i.getAllTimerIds().forEach(e=>this._stopTimer.bind(this)(e,t))})}hangup(e,t){return I(this,void 0,void 0,function*(){const{callId:i,systemState:r,pushConfig:n}=e,s=n?B_(n,this._clientCallId):"",{code:o}=yield this._signalModule.hangupCall({callId:i,sysStatus:r,pushExt:s,pushContent:(null==n?void 0:n.pushContent)||""},t);return this.endCurrentSession(e.systemState,i,t),{code:o}})}accept(e,t){return I(this,void 0,void 0,function*(){if(!this._mainSession)return{code:T_.NOT_IN_CALL};const{callId:i}=e,{code:r}=yield this._signalModule.acceptCall({callId:i},t);return this._stopTimer(this._mainSession.getInviteeTimerId(),t),r!==T_.SUCCESS||(this._clearMobileOnPhone(e.callId,t),this._mainSession.updateSessionState(v_.CONNECTING)),{code:r}})}joinCall(e,t){return I(this,void 0,void 0,function*(){const i=this._context.getCurrentId();this._mainSession&&this._stopTimer(this._mainSession.getInviteeTimerId(),t);const{code:r}=yield this._signalModule.joinCall({callId:e.callId},t);return r!==T_.SUCCESS||(this._abnormalModule.addAbnormallCallId(i,e.callId),this._mainSession?this._clearMobileOnPhone(e.callId,t):yield this._createSessionByServer(e.callId,t,!0)),{code:r}})}requestChangeMediaType(e,t){return I(this,void 0,void 0,function*(){if(!this._mainSession)return{code:T_.NOT_IN_CALL};const i={mediaType:e.mediaType};this._mainSession.updateReqMediaType(e.mediaType);const r=cc(),{code:n}=yield this._signalModule.dialogUpCall({transactionId:r,callId:this._mainSession.getCallId(),toUserIds:e.toUserIds,dialogType:q_.SWITCH_MEDIA_TYPE,action:Y_.REQUEST,extraKeyVal:i},t);return n!==T_.SUCCESS?{code:n}:{code:T_.SUCCESS,data:{transactionId:r}}})}responseChangeMediaType(e,t){return I(this,void 0,void 0,function*(){return this._mainSession?this._signalModule.dialogUpCall({transactionId:e.transactionId,callId:this._mainSession.getCallId(),dialogType:q_.SWITCH_MEDIA_TYPE,action:e.agree?Y_.ACCEPT:Y_.REFUSE},t):{code:T_.NOT_IN_CALL}})}cancelChangeMediaType(e,t){return I(this,void 0,void 0,function*(){return this._mainSession?this._signalModule.dialogUpCall({transactionId:e.transactionId,callId:this._mainSession.getCallId(),dialogType:q_.SWITCH_MEDIA_TYPE,action:Y_.CANCEL},t):{code:T_.NOT_IN_CALL}})}getCallLogList(e,t){return I(this,void 0,void 0,function*(){const i=this._context.getCurrentId(),{timestamp:r,count:n,order:s}=e,{code:o,data:a}=yield this._signalModule.syncCallLog({userId:i,syncTime:r,count:n,order:s},t);if(o!==T_.SUCCESS)return{code:o};const l=a.callLogList.map(e=>U_(e));return{code:T_.SUCCESS,data:{hasMore:Boolean(null==a?void 0:a.hasMore),syncTime:0===s?a.maxTime:a.minTime,list:l}}})}deleteCallLog(e,t){return I(this,void 0,void 0,function*(){const i=this._context.getCurrentId();return this._signalModule.deleteCallRecord(i,e,t)})}getCallServerTimestamp(e){return I(this,void 0,void 0,function*(){const{code:t,data:i}=yield this._signalModule.getCallServerTimestamp(e);return t!==T_.SUCCESS?{code:t}:{code:t,data:i.syncTime}})}getCallTimeInfo(e,t){return I(this,void 0,void 0,function*(){return this._signalModule.getCallTimeInfo(e,t)})}getOpenCallList(e){return I(this,void 0,void 0,function*(){const t=this._context.getCurrentId(),{code:i,data:r}=yield this._signalModule.getUserCallStateList(e);if(i!==T_.SUCCESS)return{code:i};return{code:i,data:r.callStateList.map(i=>{const{callId:r,callType:n,mediaType:s,callingUserId:o,callUserIds:a,callStatus:l,crtTime:_,userSessionStatus:c,startTime:d,syncTime:u}=i,h=o===t?Tc.OUT:Tc.IN,{clientStartTime:g=d}=this._timeCorrectioner.calcClientStartTime(r,d,e);return{callId:r,callType:n,callDirection:h,mediaType:s,callerUserId:o,callUserIds:a,sessionState:l,userState:c,startTimestamp:d,endTimestamp:0,duration:Math.floor((+new Date-g)/1e3),syncTimestamp:u,systemState:0,createTimestamp:_}})}})}removeAllCallLog(e){return I(this,void 0,void 0,function*(){const{code:t}=yield this._signalModule.clearCallRecord(e);return{code:t}})}getCallSession(e,t){return I(this,void 0,void 0,function*(){const{code:i,data:r}=yield this._signalModule.getCallSession(e,t);if(i!==T_.SUCCESS)return{code:i};const{callId:n,callingUserId:s,callType:o,mediaType:a,callStatus:l,callSessionUsers:_,startTime:c,duration:d,syncTime:u}=r;return{code:i,data:{callId:n,startCallerId:s,callType:o,mediaType:a,sessionState:l,callSessionUsers:_.map(e=>{const{userId:t,sessionStatus:i,sysStatus:r,targetType:n,targetId:s}=e;return{userId:t,userState:i,systemState:r,targetType:n,targetId:s,cameraEnable:!1,microphoneEnable:!1}}),startTime:c,duration:d,syncTime:u}}})}getHoldSession(e){const t=this._holdSessions.find(t=>t&&t.getCallId()===e);return t?new S_(t,this,this._logger,this._rtcModule,this._context):null}getLocalMainSession(){return this._mainSession?new S_(this._mainSession,this,this._logger,this._rtcModule,this._context):null}updateMainSessionState(e){var t;null===(t=this._mainSession)||void 0===t||t.updateSessionState(e)}setIsLocalClientHangup(e){var t;null===(t=this._mainSession)||void 0===t||t.setIsLocalClientHangup(e)}updateUsersState(e,t,i){this._logger.info(m_.L_CALL_ENGINE_UPDATE_USERS_STATE_O,`updateUsersState -> users: ${JSON.stringify(t)}`,i);const r=[this._mainSession,...this._holdSessions].find(t=>(null==t?void 0:t.getCallId())===e),n=[];return r?n.push(...r.updateUserList(t,i)):n.push(...t),n}getCallStaringTime(e,t){return I(this,void 0,void 0,function*(){return this._timeCorrectioner.getCallClientTimeByServer(e.callId,t)})}systemStatusUp(e,t){return I(this,void 0,void 0,function*(){return this._signalModule.sysStatusUp(e,t)})}upFirstFrameTime(e){return I(this,void 0,void 0,function*(){if(!this._mainSession||this._mainSession&&this._mainSession.getCallType()!==C_.SINGLE||this._isUpFirstFrameTime)return{code:T_.SUCCESS};const t=Date.now(),i=this._timeCorrectioner.getLocalDelayTime(),r=Math.floor(t+i);this._logger.info(m_.L_CALL_ENGINE_UP_FIRST_FRAME_TIME_T,`now: ${t}; delay: ${i}; streamReadyTime: ${r}`,e),this._isUpFirstFrameTime=!0;const n=this._mainSession.getCallId(),{code:s}=yield this._signalModule.eventUpCall({callId:n,eventType:uc.FIRST_FRAME,eventArgs:{streamReadyTime:r},eventTime:Date.now()},e);return this._logger.info(m_.L_CALL_ENGINE_UP_FIRST_FRAME_TIME_R,`code: ${s}`,e),{code:s}})}endCurrentSession(e,t,i){const r=this._context.getCurrentId();if(this._mainSession&&this._mainSession.getCallId()===t){const t=this._mainSession.getUserList().map(t=>{let{userId:i,systemState:n,targetType:s,targetId:o}=t;return i===r&&(n=e),{userId:i,sessionStatus:O_.ENDED,statusTime:Date.now(),duration:0,changed:1,inviteUserId:this._mainSession.getStartCallerId(),sysStatus:n,targetType:s,targetId:o}}),n={callId:this._mainSession.getCallId(),toDeviceId:this._signalModule.getDeviceId(),callStatus:v_.ENDED,duration:0,callSessionUsers:t};this._onStatusDown(n,i)}}startTimeCorrection(e){this._timeCorrectioner.restart(e)}getDelayTimeInfo(){return{delayTime:this._timeCorrectioner.getLocalDelayTime(),rtt:this._timeCorrectioner.getRTT()}}upgradeMainSession(e){var t;const i=this._holdSessions.findIndex(t=>t.getCallId()===e);this._mainSession=null===(t=this._holdSessions.splice(i,1))||void 0===t?void 0:t[0]}endCurrentUserAbnormalCalls(e){return I(this,void 0,void 0,function*(){const t=this._context.getCurrentId(),i=yield this._abnormalModule.getAbnormalCallIds(t);if(!i)return{code:T_.SUCCESS};const r=i.filter(e=>{var t;return e!==(null===(t=this._mainSession)||void 0===t?void 0:t.getCallId())}),{code:n}=yield this._signalModule.endUserAbnormalCalls({callIds:r,allDevice:e?1:0});return n===T_.SUCCESS&&this._abnormalModule.removeAbnormalCallIds(t,r),{code:n}})}setRTCModule(e){this._rtcModule=e}_onIMStateChange(e){const t=this._logger.createTraceId();let i=0;e===l.DISCONNECTED&&this._mainSession&&this._mainSession.getSessionState()!==v_.ONCALL&&(i=ec(()=>{var e;this._logger.info(m_.L_CALL_ENGINE_IM_STATE_CHANGE_O,"endCurrentSession, IM disconnected for more than 60s",t),this.endCurrentSession(A_.CONNECTION_ERR,null===(e=this._mainSession)||void 0===e?void 0:e.getCallId(),t)},6e4)),e===l.CONNECTED&&(i&&clearTimeout(i),this._initOpts.isAllowNewCallWhenRinging&&this.endCurrentUserAbnormalCalls(!0))}_handleCallTimeout(e,t,i){this._logger.warn(m_.L_CALL_ENGINE_CALL_TIMEOUT_O,`call timeout callId: ${e}, userState: ${t}`,i);const r=[this._mainSession,...this._holdSessions].find(t=>t&&t.getCallId()===e);if(!r)return void this._logger.warn(m_.L_CALL_ENGINE_CALL_TIMEOUT_O,`handleCallTimeout without session, callId: ${e}`,i);const n=this._context.getCurrentId();this._onStatusDown({callId:e,toDeviceId:this._signalModule.getDeviceId(),callStatus:v_.ENDED,duration:0,callSessionUsers:r.getUserList().map(e=>{const{userId:i,targetType:s,targetId:o,stateTime:a}=e;let l,_;return i===n?(l=t===O_.MISSED?A_.MISSED:A_.NO_ANSWER,_=t===O_.MISSED?O_.MISSED:O_.NO_ANSWER):(l=t===O_.MISSED?A_.NO_ANSWER:A_.MISSED,_=t===O_.MISSED?O_.NO_ANSWER:O_.MISSED),{userId:i,sessionStatus:_,statusTime:a?a+1:Date.now(),duration:0,changed:1,inviteUserId:r.getCallerId(),sysStatus:l,targetType:s,targetId:o}})},i)}_startTimer(e,t,i){const r=ec(()=>{this._handleCallTimeout(e,t,i),this._signalModule.statusUpCall({callId:e,sessionStatus:t},i)},6e4);return this._logger.info(m_.L_CALL_ENGINE_START_CALL_TIMER_O,`callId: ${e}, timerId: ${r}`,i),r}_stopTimer(e,t){clearTimeout(e),this._logger.info(m_.L_CALL_ENGINE_STOP_CALL_TIMER_O,`timerId: ${e}`,t)}_onInvite(e,t,i){this._clientCallId=J.gen();const r=this._context.getCurrentId(),{callSessionUsers:n,secretChat:s,extra:o="{}"}=e;if(s===W_.SECRET)return void this.emit(rc.onPubInviteCallMiss,Object.assign(e,{extra:JSON.stringify(e),reason:nc.SECRET_CALL,refer:t?sc.PUB_INVITE:sc.PULL_KV_INVITE}));n.some(e=>e.userId===r)&&this._selfIsInviteeHandle(e,t,i,o),this._othersIsInviteeHandle(e,i)}_selfIsInviteeHandle(e,t,i,r){const{callId:n,inviteUserId:s,callType:o,mediaType:a,callSessionUsers:l}=e,_=this._context.getCurrentId();this._abnormalModule.addAbnormallCallId(_,n);const c=new X_(n,v_.RINGING,o,a,s,s,[],this._logger);this._signalModule.ringingCall({callId:n},i);const d=this._startTimer(n,O_.MISSED,i);c.updateTimerId(z_.INVITEE,d),this._mainSession?(this._holdSessions.push(c),this._mainSession.updateSessionState(v_.BUSYLINE_WAIT)):this._mainSession=c;const u=new S_(c,this,this._logger,this._rtcModule,this._context),h=t?pc.PUB_INVITE_CALL:pc.PULL_KV_INVITE_CALL;this.emit(mc.__INNER_INVITE__,u,h);const g=l.map(({userId:e,sessionStatus:t,sysStatus:i,targetType:r,targetId:n,statusTime:s})=>({userId:e,userState:t,systemState:i,targetType:r,targetId:n,stateTime:s})),p=this.updateUsersState(n,g,i);this._reportAppEventModule.onReceivedCall(u,i,JSON.parse(r||"{}").extra),p.length>0&&this.reportRemoteUserStateChange(n,p,i)}_othersIsInviteeHandle(e,t){var i,r,n;const{callId:s,inviteUserId:o,callSessionUsers:a}=e,l=this._context.getCurrentId(),_=a.filter(e=>e.userId!==l&&e.userId!==o&&e.sessionStatus===O_.INVITED);if(!_.length)return;(null===(i=this._mainSession)||void 0===i?void 0:i.getCallType())===C_.SINGLE&&(null===(r=this._mainSession)||void 0===r?void 0:r.getCallId())===s&&(this._onCallTypeChange(this._mainSession.getCallId(),C_.MULTI,t),null===(n=this._mainSession)||void 0===n||n.updateCallType(C_.MULTI));const c=[],d=[];_.forEach(e=>{const{userId:t,sessionStatus:i,sysStatus:r}=e;c.push({callId:s,userId:t,userState:i}),d.push({userId:t,userState:i,systemState:r})}),this._onOtherMemberInvite(c);const u=this.updateUsersState(s,d,t);u.length>0&&this.reportRemoteUserStateChange(s,u,t)}_onHangup(e,t,i){this._mainSession&&e.forEach(e=>{e.callId===this._mainSession.getCallId()&&(e.userState===O_.CANCELLED?this._stopTimer(this._mainSession.getInviteeTimerId(),i):this._stopTimer(this._mainSession.getInviterTimerId(),i))})}_onAccept(e,t){var i,r,n,s;const o=null===(i=this._mainSession)||void 0===i?void 0:i.getSessionState(),a=[v_.CONNECTING,v_.ONCALL,v_.BUSYLINE_WAIT];if((null===(r=this._mainSession)||void 0===r?void 0:r.getCallType())===C_.SINGLE&&o&&a.includes(o))return;const l=this._mainSession.getStartCallerId(),_=this._context.getCurrentId();if((null===(n=this._mainSession)||void 0===n?void 0:n.getCallType())===C_.SINGLE&&l===_){e.filter(e=>e.fromUserId!==_)&&this.emit(mc.__INNER_SESSION_CONNECT__,this.getLocalMainSession().getCallId(),t)}null===(s=this._mainSession)||void 0===s||s.updateSessionState(v_.CONNECTING),this._stopTimer(this._mainSession.getInviterTimerId(),t)}_onStatusDown(e,t){return I(this,void 0,void 0,function*(){var i,r;const{callStatus:n,startTime:s,callId:o}=e;if(o!==(null===(i=this._mainSession)||void 0===i?void 0:i.getCallId()))return;if(this._callStartMap[o]=this._callStartMap[o]||{},!this._callStartMap[o].isReceiveCallStartTime&&n===v_.ONCALL){this._callStartMap[o].isReceiveCallStartTime=!0;const{code:e,clientStartTime:i}=this._timeCorrectioner.calcClientStartTime(o,s,t);e===hc.SUCCESS&&(this._callStartMap[o].callStartTime=i,this._reportAppEventModule.onReceivedCallStartTime({callId:o,callStartTime:i},t))}let a=!1;const l=this._context.getCurrentId(),_=e.callSessionUsers.map(e=>([O_.IDLE,O_.DECLINED,O_.MISSED,O_.NO_ANSWER,O_.CANCELLED].includes(e.sessionStatus)&&e.sysStatus!==A_.CANCELLED&&e.userId===l&&(a=!0),{userId:e.userId,userState:e.sessionStatus,systemState:e.sysStatus,stateTime:e.statusTime}));if(_.length){const e=this.updateUsersState(o,_,t);e.length>0&&this.reportRemoteUserStateChange(o,e,t)}if(!this._mainSession&&!this._holdSessions.length)return;const{hangupData:c,acceptData:d,otherInvitedData:u}=(e=>{const{callId:t}=e,i=[],r=[],n=[],s=[];return e.callSessionUsers.forEach(e=>{const{userId:o,sessionStatus:a,sysStatus:l}=e;switch(a){case O_.INVITED:s.push({callId:t,userId:o,userState:a});break;case O_.RINGING:i.push({callId:t,fromUserId:o});break;case O_.CONNECTING:n.push({fromUserId:o});break;case O_.CANCELLED:case O_.DECLINED:case O_.ENDED:case O_.IDLE:r.push({callId:t,fromUserId:o,userState:a,systemState:l})}}),{ringingData:i,hangupData:r,acceptData:n,otherInvitedData:s}})(e);c.length>0&&this._onHangup(c,e.callStatus,t),d.length>0&&this._onAccept(d,t),u.length>0&&(null===(r=this._mainSession)||void 0===r?void 0:r.getCallType())===C_.MULTI&&this._onOtherMemberInvite(u),(e.callStatus===v_.ENDED||a)&&this._onSessionClose(e,t,a)})}_onOtherClientStatusDown(e,t){var i,r,n;const{callId:s,callSessionUsers:o}=e,a=this._context.getCurrentId(),l=o.find(({userId:e})=>e===a);if(l&&(this._mainSession||this._holdSessions.length)){const{userId:o,sessionStatus:_,statusTime:c}=l;if(_===O_.CONNECTING){const l=[O_.ONCALL,O_.CONNECTING],d=(null===(i=this._mainSession)||void 0===i?void 0:i.getCallId())===s,u=null===(n=null===(r=this._mainSession)||void 0===r?void 0:r.getUserList().find(e=>e.userId===a))||void 0===n?void 0:n.userState;if(!(d&&u&&l.includes(u))){const i=this.updateUsersState(s,[{userId:o,userState:_,systemState:A_.OTHER_CLIENT_ACCEPT,stateTime:c}],t);i.length>0&&this.reportRemoteUserStateChange(s,i,t),this._onSessionClose(e,t,!1)}}}}_onEventDown(e,t){return I(this,void 0,void 0,function*(){var i;const{callId:r,eventArgs:n,eventType:s}=e;if(r===(null===(i=this._mainSession)||void 0===i?void 0:i.getCallId())&&this._mainSession.getSessionState()===v_.ONCALL&&s===uc.CALL_DURATION){const{firstFrameTime:e}=n,{code:i,clientStartTime:s}=this._timeCorrectioner.calcClientStartTime(r,e,t);this._logger.info(m_.L_CALL_ENGINE_RECEIVE_FIRST_FRAME_TIME_O,`clientFirstFrameTime: ${s}`,t),i===hc.SUCCESS&&(this._callStartMap[r].firstFrameTime=s,this._reportAppEventModule.onReceivedCallFirstFrameTime(r,s,t))}})}_onRecvSinCallDuration(e,t,i,r){var n;(null===(n=this._mainSession)||void 0===n?void 0:n.getCallId())===e&&(this._callStartMap[e].callStartTime=t,this._callStartMap[e].firstFrameTime=i,this._reportAppEventModule.onReceivedCallStartTime(Object.assign({callId:e},{callStartTime:t}),r),this._reportAppEventModule.onReceivedCallFirstFrameTime(e,i,r))}_onSwitchMediaType(e,t){var i,r,n,s,o;const{callId:a,action:l,extraKeyVal:_,transactionId:c,promoterId:d}=e,{mediaType:u,reason:h}=_,g=null===(i=this._mainSession)||void 0===i?void 0:i.getCallId();if(a!==g)return void this._logger.info(m_.L_CALL_ENGINE_RECEIVE_MEDIATYPE_CHANGE_O,`not current session callId: ${g}, recvCallId: ${a}`,t);const{transactionId:p,action:f,mediaType:E}=(null===(r=this._mainSession)||void 0===r?void 0:r.getOldDialogData())||{};if(p!==c||f!==l||E!==u){if(this._logger.info(m_.L_CALL_ENGINE_RECEIVE_MEDIATYPE_CHANGE_O,`action: ${l}, reason: ${h}`,t),null===(n=this._mainSession)||void 0===n||n.setOldDialogData({transactionId:c,action:l,mediaType:u}),l===Y_.REQUEST)this._onRequestChangeMediaType({transactionId:c,userId:d,mediaType:u},t);else{let e=null;switch(h){case Y_.CANCEL:e=b_.CANCEL_CHANGE_MEDIA_TYPE;break;case Y_.ACCEPT:e=b_.SERVER_ALLOW_MEDIA_TYPE,null===(s=this._mainSession)||void 0===s||s.updateMediaType(this._mainSession.getReqMediaType()),null===(o=this._mainSession)||void 0===o||o.updateReqMediaType(null);break;case Y_.REFUSE:e=b_.REFUSE_CHANGE_MEDIA_TYPE;break;case Y_.TIMEOUT:e=b_.CHANGE_MEDIA_TYPE_TIMEOUT}b_[e]&&this._receiveMediaTypeChangeResult({transactionId:c,userId:d,mediaType:u},e,t)}l!==Y_.NOTICE||u!==I_.AUDIO||h||this._receiveMediaTypeChangeResult({transactionId:c,userId:d,mediaType:u},b_.SERVER_ALLOW_MEDIA_TYPE,t)}else this._logger.info(m_.L_CALL_ENGINE_RECEIVE_MEDIATYPE_CHANGE_O,"duplicate dialog data",t)}_onRecvCallEndLog(e,t){const i=U_(e);this._reportAppEventModule.onReceivedCallRecord(i,t)}_onSessionClose(e,t,i){const{callId:r}=e,n=this._context.getCurrentId();this._abnormalModule.removeAbnormalCallIds(n,[r]);let s=[this._mainSession,...this._holdSessions].find(e=>e&&e.getCallId()===r);if(!s)return void this._logger.warn(m_.L_CALL_ENGINE_RECEIVE_CLOSE_SESSION_O,`unexpect session callId -> ${r}`,t);this._logger.warn(m_.L_CALL_ENGINE_RECEIVE_CLOSE_SESSION_O,`callId: ${r}`,t),this.emit(mc.__INNER_SESSION_CLOSE__,r,t);const o=s.getUserList().find(e=>e.userId===n);let a;a=i&&e.toDeviceId!==this._signalModule.getDeviceId()?s.getIsLocalClientHangup()?o.systemState:A_.OTHER_CLIENT_HANGUP:o.systemState,this._reportAppEventModule.onCallEnded(new S_(s,this,this._logger,this._rtcModule,this._context),a,t),this._reportCallPlusSummaryMessage(s,r,a),this._mainSession&&this._mainSession.getCallId()===r&&(this._mainSession.getAllTimerIds().forEach(e=>this._stopTimer.bind(this)(e,t)),s.getCallType()===C_.SINGLE&&(this._isUpFirstFrameTime=!1),delete this._callStartMap[r]),this._removeSession(r)}_reportCallPlusSummaryMessage(e,t,i){var r,l,_;const c=this._context.getCurrentId(),d=e.getUserList().filter(({userId:e})=>e!==c)[0].userId,u=e.getStartCallerId();if(!localStorage.getItem(`missMessageMap-${c}-${t}`)){const h={callId:t,callerUserId:u,targetId:d,mediaType:e.getMediaType(),firstFrameTime:(null===(r=this._callStartMap[t])||void 0===r?void 0:r.firstFrameTime)||0,callStartTime:(null===(l=this._callStartMap[t])||void 0===l?void 0:l.callStartTime)||0,callEndTime:(null===(_=this._callStartMap[t])||void 0===_?void 0:_.callStartTime)?+new Date-this._timeCorrectioner.getLocalDelayTime():0,hangupReason:i};this._reportAppEventModule.onReceivedCallPlusSummaryMessage({messageType:"RC:CallPlusSummary",content:h,senderUserId:u,targetId:d,channelId:"",conversationType:a.PRIVATE,sentTime:+new Date-this._timeCorrectioner.getLocalDelayTime(),receivedTime:+new Date-this._timeCorrectioner.getLocalDelayTime(),messageUId:t,messageDirection:u===c?s.SEND:s.RECEIVE,isPersited:!0,isCounted:!1,isOffLineMessage:!1,canIncludeExpansion:!1,receivedStatus:o.READ,isStatusMessage:!1,isMentioned:!1,expansion:null,disableNotification:!1,sentStatus:n.SENT}),localStorage.setItem(`missMessageMap-${c}-${t}`,t)}}_removeSession(e){var t;if(e===(null===(t=this._mainSession)||void 0===t?void 0:t.getCallId()))this._mainSession=null;else{const t=this._holdSessions.findIndex(t=>(null==t?void 0:t.getCallId())===e);this._holdSessions.splice(t,1)}}_createSessionByServer(e,t){return I(this,arguments,void 0,function*(e,t,i=!1){this._logger.info(m_.L_CALL_ENGINE_CREATE_SESSION_BY_SERVER_T,`callId: ${e}`,t);const{code:r,data:n}=yield this.getCallSession({callId:e},t);if(r!==T_.SUCCESS)return void this._logger.error(m_.L_CALL_ENGINE_CREATE_SESSION_BY_SERVER_R,`errcode: ${r}`,t);this._logger.info(m_.L_CALL_ENGINE_CREATE_SESSION_BY_SERVER_R,`code: ${r}, data: ${JSON.stringify(n)}`,t);const{callType:s,mediaType:o,callSessionUsers:a,startCallerId:l}=n;this._mainSession=new X_(e,v_.CONNECTING,s,o,l,l,[],this._logger),i&&this._clearMobileOnPhone(e,t);const _=this.updateUsersState(e,a,t);_.length>0&&this.reportRemoteUserStateChange(e,_,t)})}_clearMobileOnPhone(e,t){return I(this,void 0,void 0,function*(){const i=[this._mainSession,...this._holdSessions].find(t=>(null==t?void 0:t.getCallId())===e);if(i&&i.getCallType()===C_.MULTI){this._logger.info(m_.L_CALL_ENGINE_UP_ON_PHONE_END_T,`callId: ${e}`,t);const{code:i}=yield this.systemStatusUp({callId:e,sysStatus:A_.ON_PHONE_END,forward:gc.CURRENT},t);i===T_.SUCCESS?this._logger.info(m_.L_CALL_ENGINE_UP_ON_PHONE_END_R,`callId: ${e}`,t):this._logger.warn(m_.L_CALL_ENGINE_UP_ON_PHONE_END_R,`callId: ${e}, errCode: ${i}`,t)}})}reportRemoteUserStateChange(e,t,i){const r=this._context.getCurrentId();t.forEach(t=>{const{userId:n,userState:s,systemState:o}=t;n!==r&&this._reportAppEventModule.onRemoteUserStateChanged({callId:e,userId:n,userState:s,reason:o},i)}),t.forEach(({userId:t,systemState:n})=>{t===r&&n===A_.ABNORMAL_END&&this.emit(mc.__INNER_SESSION_CLOSE__,e,i)})}_onOtherMemberInvite(e){e.forEach(e=>{var t;const{userId:i,callId:r}=e,n=null===(t=this.getLocalMainSession())||void 0===t?void 0:t.getInviterUserId();this._reportAppEventModule.onRemoteUserInvited([i],n,r)})}_onRequestChangeMediaType(e,t){var i;const{userId:r,transactionId:n,mediaType:s}=e;null===(i=this._mainSession)||void 0===i||i.updateReqMediaType(s),this._reportAppEventModule.onReceivedChangeMediaTypeRequest(r,n,s,t)}_receiveMediaTypeChangeResult(e,t,i){t===b_.SERVER_ALLOW_MEDIA_TYPE&&this.emit(mc.__INNER_CHANGE_MEDIA_TYPE__,e.mediaType,i),this._reportAppEventModule.onReceivedChangeMediaTypeResult(Object.assign(Object.assign({},e),{result:t}),i)}_onCallTypeChange(e,t,i){this._reportAppEventModule.onCallTypeChanged(t,e,i)}}var Ic,Rc,Sc;Object.defineProperty(mc,"__INNER_SESSION_CLOSE__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-session-close"}),Object.defineProperty(mc,"__INNER_SESSION_CONNECT__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-session-connect"}),Object.defineProperty(mc,"__INNER_CHANGE_MEDIA_TYPE__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-change-media-type"}),Object.defineProperty(mc,"__INNER_INVITE__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-invite"}),function(e){e.NORMAL="RongCloudRTC",e.SCREEN="ScreenShare"}(Ic||(Ic={}));class Cc extends B{constructor(e,t,i,r,n,s,o){super(),Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_runtime",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_initOpts",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_callEngine",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"_reportAppEventModule",{enumerable:!0,configurable:!0,writable:!0,value:s}),Object.defineProperty(this,"_rtcClient",{enumerable:!0,configurable:!0,writable:!0,value:o}),Object.defineProperty(this,"_localTracks",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_room",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_callId",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(this,"_callMediaType",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_videoConfig",{enumerable:!0,configurable:!0,writable:!0,value:{resolution:Nt.W640_H480,frameRate:yt.FPS_15}}),Object.defineProperty(this,"_audioConfig",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_isPubTiny",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_audioOutputDeviceId",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(this,"_videoConfigIsChange",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_audioConfigIsChange",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_userViewMap",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_callPlusStatusReportListener",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_remoteAudioEnable",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"_preHangupCallId",{enumerable:!0,configurable:!0,writable:!0,value:null}),this._isPubTiny=i.isPubTiny||!1}setCallPlusStatusReportListener(e){this._callPlusStatusReportListener=e}getCameraVideoTrack(e){return I(this,void 0,void 0,function*(){const t=this.getLocalVideoTrack(),{code:i,track:r}=t&&!this._videoConfigIsChange?{track:t,code:T_.SUCCESS}:yield this._createVideoTrack(e);return this._videoConfigIsChange=!1,i!==T_.SUCCESS?{code:i}:{code:T_.SUCCESS,track:r}})}getMicrophoneAudioTrack(e){return I(this,void 0,void 0,function*(){const t=this.getLocalAudioTrack(),{code:i,track:r}=t&&!this._audioConfigIsChange?{track:t,code:T_.SUCCESS}:yield this._createAudioTrack(e);return this._audioConfigIsChange=!1,i!==T_.SUCCESS?{code:i}:{code:T_.SUCCESS,track:r}})}createCallMediaTracks(e,t){return I(this,void 0,void 0,function*(){this._callMediaType=e;const{code:i}=yield this.getMicrophoneAudioTrack(t);if(i!==T_.SUCCESS)return{code:i};if(e===I_.AUDIO_VIDEO){const{code:e}=yield this.getCameraVideoTrack(t);e!==T_.SUCCESS&&this._logger.warn(m_.L_RTC_MODULE_CREATE_CALL_MEDIA_TRACKS_P,`get camera video track error code: ${e}`,t)}return{code:T_.SUCCESS}})}setVideoConfig(e){this._videoConfigIsChange=!0,this._videoConfig=e}setAudioConfig(e){this._audioConfigIsChange=!0,this._audioConfig=e}setAudioOutputDeviceId(e){return I(this,void 0,void 0,function*(){if("string"!=typeof e||0===e.length)return{code:T_.PARAM_ERROR};if(this._audioOutputDeviceId===e)return{code:T_.SUCCESS};if(this._audioOutputDeviceId=e,this._room){this._room.getRemoteTracks().filter(e=>e.isAudioTrack()).forEach(t=>{t.isSubscribed()&&t.play(void 0,{audioDeviceId:e})})}return{code:T_.SUCCESS}})}destroyAllTracks(e){this._logger.info(m_.L_RTC_MODULE_DESTROY_ALL_TRACKS_O,"",e),this._localTracks.forEach(e=>{e.destroy()}),this._localTracks.length=0}setAllRemoteAudioEnable(e,t){if(this._logger.info(m_.L_RTC_MODULE_SET_ALL_REMOTE_AUDIO_ENABLE_T,`enable: ${e}`,t),!L(e))return this._logger.error(m_.L_RTC_MODULE_SET_ALL_REMOTE_AUDIO_ENABLE_R,`param error, enable: type is boolean, value: ${e}`),{code:T_.PARAM_ERROR};if(this._remoteAudioEnable=e,!this._room)return{code:T_.SUCCESS};return this._room.getRemoteTracks().filter(e=>e.isAudioTrack()).forEach(t=>{e?t.unmute():t.mute()}),this._logger.info(m_.L_RTC_MODULE_SET_ALL_REMOTE_AUDIO_ENABLE_R,"success",t),{code:T_.SUCCESS}}destroyTrack(e){return I(this,void 0,void 0,function*(){e.destroy();const t=this._localTracks.findIndex(t=>t.getTrackId()===e.getTrackId());this._localTracks.splice(t,1)})}sessionConnected(e,t){return I(this,void 0,void 0,function*(){if(this._preHangupCallId=null,this._logger.info(m_.L_RTC_MODULE_SESSION_CONNECT_T,`callId: ${e}`,t),!this._room){const{code:i,room:r}=yield this.joinRTCRoom(e,t);if(i!==T_.SUCCESS)return;if(this._room=r,this._preHangupCallId&&this._room.getRoomId()===this._preHangupCallId)return this._rtcClient.leaveRoom(this._room),void this._releaseStoredData();const n=this._room.getRemoteUserIds();this._onSelfJoined(e,n,t)}this._callId=e,this._regRTCListeners();let i=this._room.getRemoteTracks();if(i&&i.length&&this._onRemoteTrackPublish(i),this._localTracks.length>0){this.emit(rc.onBeforePublish);const e=this._isPubTiny?this._localTracks.map(e=>e.isVideoTrack()?{track:e,isPubTiny:!0}:e):this._localTracks,{code:i}=yield this.publish(e,t);this.emit(rc.onPublishRes,i)}else this._logger.warn(m_.L_RTC_MODULE_SESSION_CONNECT_P,"sessionConnected local tracks is empty",t);this._logger.info(m_.L_RTC_MODULE_SESSION_CONNECT_R,`code: ${T_.SUCCESS}`,t)})}sessionClose(e,t){return I(this,void 0,void 0,function*(){var i;this._logger.info(m_.L_RTC_MODULE_SESSION_CLOSE_T,`callId: ${e}`,t),this._preHangupCallId=e,this.destroyAllTracks(t);const r=null===(i=this._room)||void 0===i?void 0:i.getRoomId();if(this._room&&e===r){const{code:e}=yield this._rtcClient.leaveRoom(this._room);if(this._releaseStoredData(),e!==ue.SUCCESS)return void this._logger.error(m_.L_RTC_MODULE_SESSION_CLOSE_R,`leaveRoom failed, code: ${e}`,t);this._logger.info(m_.L_RTC_MODULE_SESSION_CLOSE_R,"leaveRoom success",t)}else this._logger.warn(m_.L_RTC_MODULE_SESSION_CLOSE_R,"leaveRoom throw exception: not in room",t)})}disableVideoTrack(){return I(this,void 0,void 0,function*(){const e=this.getLocalVideoTrack();if(!e)return{code:T_.CAMERA_CLOSED};return{code:yield e.mute(),track:e}})}enableVideoTrack(e){return I(this,void 0,void 0,function*(){const e=this.getLocalVideoTrack();if(!e)return{code:T_.CAMERA_CLOSED};if(!e.isOwnerMuted())return{code:T_.SUCCESS};return{code:yield e.unmute()}})}changeVideoDevice(e){return I(this,void 0,void 0,function*(){const t=[],i=[],{code:r,track:n}=yield this._rtcClient.createCameraVideoTrack(Ic.NORMAL,this._videoConfig);if(r!==ue.SUCCESS)return{code:r};const{minBitrate:s,maxBitrate:o}=this._videoConfig;let a;if((s||o)&&n.setBitrate(o,s),this._localTracks&&this._localTracks.forEach(e=>{e.isVideoTrack()?(e.destroy(),a=e):i.push(e)}),this._localTracks=this._localTracks.filter(e=>a&&e.getTrackId()!==a.getTrackId()),t.push(n),i.push(n),this._localTracks=i,this._onLocalTrackReady(t,e),this._room){const{code:e}=yield this._room.publish(t);if(e!==ue.SUCCESS)return{code:e}}return{code:T_.SUCCESS,track:n}})}changeAudioDevice(e){return I(this,void 0,void 0,function*(){const t=[],i=[],r=Object.assign(Object.assign({},this._audioConfig),{micphoneId:this._audioConfig.microphoneId}),{code:n,track:s}=yield this._rtcClient.createMicrophoneAudioTrack(Ic.NORMAL,r);if(n!==ue.SUCCESS)return{code:n};if(this._localTracks&&this._localTracks.forEach(e=>{e.isAudioTrack()||i.push(e)}),t.push(s),i.push(s),this._localTracks=i,this._onLocalTrackReady(t,e),this._room){const{code:e}=yield this._room.publish(t);if(e!==ue.SUCCESS)return{code:e}}return{code:T_.SUCCESS}})}disableAudioTrack(){return I(this,void 0,void 0,function*(){const e=this.getLocalAudioTrack();if(!e)return{code:T_.MICROPHONE_CLOSED};return{code:yield e.mute(),track:e}})}changeMediaType(e,t){return I(this,void 0,void 0,function*(){let i;this._logger.info(m_.L_RTC_MODULE_CHANGE_MEDIA_TYPE_T,`mediaType: ${e}`,t),i=e===I_.AUDIO_VIDEO?yield this._upgradeMediaType(t):yield this._downgradeMediaType(t),i.code===T_.SUCCESS&&this._logger.info(m_.L_RTC_MODULE_CHANGE_MEDIA_TYPE_R,"success",t)})}_upgradeMediaType(e){return I(this,void 0,void 0,function*(){let t=this.getLocalVideoTrack();if(!t){const{code:i,track:r}=yield this._createVideoTrack(e);if(i!==T_.SUCCESS)return this._logger.error(m_.L_RTC_MODULE_CHANGE_MEDIA_TYPE_R,`create video track errCode: ${i}`,e),{code:i};t=r;const{minBitrate:n,maxBitrate:s}=this._videoConfig;(n||s)&&t.setBitrate(s,n)}const i=this._isPubTiny?{track:t,isPubTiny:!0}:t,{code:r}=yield this.publish([i],e);return r!==T_.SUCCESS&&this._logger.error(m_.L_RTC_MODULE_CHANGE_MEDIA_TYPE_R,`publish errCode: ${r}`,e),{code:r}})}_downgradeMediaType(e){return I(this,void 0,void 0,function*(){const t=this.getLocalVideoTrack();if(t){const{code:i}=yield this._room.unpublish([t]);if(i!==ue.SUCCESS)return this._logger.error(m_.L_RTC_MODULE_CHANGE_MEDIA_TYPE_R,`unpublish errCode: ${i}`,e),{code:i};this.destroyTrack(t)}return{code:T_.SUCCESS}})}joinRTCRoom(e,t){return I(this,void 0,void 0,function*(){this._logger.info(m_.L_RTC_MODULE_JOIN_RTC_ROOM_T,`call: ${e}`,t);const{code:i,room:r,tracks:n}=yield ic({asyncFn:this._rtcClient.joinRTCRoomWithOptions.bind(this._rtcClient),fnArgs:[e,{mode:vo.CALL}]});return i!==ue.SUCCESS?(this._logger.error(m_.L_RTC_MODULE_JOIN_RTC_ROOM_R,`callId: ${e}, errCode: ${i}`,t),this._onRTCMethodFail(A_.JOIN_ROOM_ERR,t),{code:i}):(this._logger.info(m_.L_RTC_MODULE_JOIN_RTC_ROOM_R,"success",t),this._callId=e,{code:T_.SUCCESS,room:r,tracks:n})})}subscribeTracks(e,t){return I(this,void 0,void 0,function*(){if(this._logger.info(m_.L_RTC_MODULE_SUBSCRIBE_T,JSON.stringify({params:e.map(e=>{const{track:t,subTiny:i}=e;return{trackId:t.getTrackId(),subTiny:i}})}),t),!this._room)return{code:T_.SUCCESS};const{code:i}=yield ic({asyncFn:this._room.subscribe.bind(this._room),fnArgs:[e],onError:e=>{}});return i!==ue.SUCCESS?(this._reportAppEventModule.onFetchRemoteMediaError(e,i),this._onRTCMethodFail(A_.SUBSCRIBE_ERR,t),this._logger.error(m_.L_RTC_MODULE_SUBSCRIBE_R,`errorCode: ${i}`,t),{code:i}):(this._logger.info(m_.L_RTC_MODULE_SUBSCRIBE_R,"success",t),{code:T_.SUCCESS})})}unsubscribeTracks(e,t){return I(this,void 0,void 0,function*(){if(this._logger.info(m_.L_RTC_MODULE_UNSUBSCRIBE_T,JSON.stringify({trackIds:e.map(e=>e.getTrackId())}),t),!this._room)return{code:T_.SUCCESS};const{code:i}=yield this._room.unsubscribe(e);return i!==ue.SUCCESS?(this._logger.error(m_.L_RTC_MODULE_UNSUBSCRIBE_R,`errorCode: ${i}`,t),{code:i}):(this._logger.info(m_.L_RTC_MODULE_UNSUBSCRIBE_R,"success",t),{code:T_.SUCCESS})})}_releaseStoredData(){this._room=null,this._remoteAudioEnable=!0,this._userViewMap={},this._preHangupCallId=null}getRemoteTracks(){const e={};if(!this._room)return e;return this._room.getRemoteUserIds().forEach(t=>{e[t]=this._room.getRemoteTracksByUserId(t)}),e}getRemoteTrack(e,t){var i;return null===(i=this._room)||void 0===i?void 0:i.getRemoteTracksByUserId(e).find(e=>t===I_.AUDIO?e.isAudioTrack():e.isVideoTrack())}getRTCSessionId(){return this._room?this._room.getSessionId():null}_regRTCListeners(){this._room.registerRoomEventListener({onKickOff:(e,t)=>{this._onKickOff(e,this._room.getRoomId(),t),this._releaseStoredData()},onUserJoin:e=>{const t=e.map(e=>({callId:this._callId,userId:e})),i=this._logger.createTraceId();this._onOtherMemJoined(t,i)},onUserLeave:e=>{e.forEach(e=>{delete this._userViewMap[e]})},onTrackPublish:this._onRemoteTrackPublish.bind(this),onTrackUnpublish:this._onTrackUnpublish.bind(this),onTrackReady:e=>{this._onRemoteTrackReady([e])},onVideoMuteChange:e=>{this._onVideoMuteChagne({fromUserId:e.getUserId(),muted:e.isOwnerMuted(),trackId:e.getTrackId()})},onAudioMuteChange:e=>{this._onAudioMuteChange({fromUserId:e.getUserId(),muted:e.isOwnerMuted(),trackId:e.getTrackId()})},onRTCPeerConnectionCloseByException:this._onRTCPeerConnectionCloseByException.bind(this)}),this._room.registerReportListener({onStateReport:this._onRTCStateReport.bind(this)}),this._room.onAudioLevelChange(e=>{this._reportAppEventModule.onUserAudioLevelChanged(e)})}_onLocalTrackReady(e,t){this._reportAppEventModule.onUserMediaAvailable(e,t)}_onRemoteTrackReady(e){this._reportAppEventModule.onUserMediaAvailable(e),this.emit(Cc.__INNER_RECEIVE_FIRST_FRAME__)}_onKickOff(e,t,i,r){this._logger.info(m_.L_RTC_MODULE_RECEIVE_KICK_OFF_O,`roonId: ${t}, byServer: ${e}, state: ${i}, kickExtra: ${JSON.stringify(r)}`);let n=A_.CONNECTION_ERR;if(e)if(r)n=r.kickReasonCode;else switch(i){case Ma.SERVER_KICK:n=A_.KICKED_BY_SERVER;break;case Ma.OTHER_KICK:n=A_.OTHER_CLIENT_JOINED;break;case Ma.IM_DISCONNECTED:n=A_.CONNECTION_ERR;break;case Ma.IM_LOGOUT:n=A_.LOGOUT;break;case Ma.OTHER_CLIENT_IM_CONNECTED:n=A_.OTHER_CLIENT_LOGIN}this.emit(Cc.__INNER_ON_KICKOFF__,n,t)}_onRTCPeerConnectionCloseByException(){const e=this._logger.createTraceId();this._logger.info(m_.L_RTC_MODULE_RECEIVE_PEERCONNECTION_EXCEPT_CLOSE_O,"",e),this.emit(Cc.__INNER_RTC_PEERCONNECTION_ABNORMAL_CLOSE__,e)}_onSelfJoined(e,t,i){return I(this,void 0,void 0,function*(){this.emit(Cc.__INNER_ON_SELF_JOINED__,e,t,i)})}_onRemoteTrackPublish(e){const t=this._logger.createTraceId();this._logger.info(m_.L_RTC_MODULE_RECEIVE_TRACK_PUBLISH_O,JSON.stringify({callId:this._callId,trackIds:e.map(e=>e.getTrackId())}),t);const i=[];e.forEach(e=>{var t;const r=e.getUserId();if(e.isAudioTrack())i.push({track:e,subTiny:!1}),this._reportAppEventModule.onRemoteMicrophoneStateChanged(this._callId,e);else if(this._reportAppEventModule.onRemoteCameraStateChanged(this._callId,e),null===(t=this._userViewMap[r])||void 0===t?void 0:t.videoView){const{isTiny:t}=this._userViewMap[r];i.push({track:e,subTiny:t})}}),i.length&&this.subscribeTracks(i,t)}_onTrackUnpublish(e){return I(this,void 0,void 0,function*(){const t=this._logger.createTraceId();this._logger.info(m_.L_RTC_MODULE_RECEIVE_TRACK_UNPUBLISH_O,JSON.stringify({callId:this._callId,trackIds:e.map(e=>e.getTrackId())}),t),yield this.unsubscribeTracks(e,t)})}_onAudioMuteChange(e){const t=this._logger.createTraceId();this._logger.info(m_.L_RTC_MODULE_RECEIVE_TRACK_ENABLE_CHANGE_O,JSON.stringify({info:e}),t);const i=this._room.getRemoteTrack(e.trackId);this._reportAppEventModule.onRemoteMicrophoneStateChanged(this._callId,i)}_onVideoMuteChagne(e){const t=this._logger.createTraceId();this._logger.info(m_.L_RTC_MODULE_RECEIVE_TRACK_ENABLE_CHANGE_O,JSON.stringify({info:e}),t);const i=this._room.getRemoteTrack(e.trackId);this._reportAppEventModule.onRemoteCameraStateChanged(this._callId,i)}_trackStatToQualityStats(e){var t,i,r,n,s,o;const a=null!==(t=e.packetsLostRate)&&void 0!==t?t:0,l=null!==(i=e.bitrate)&&void 0!==i?i:0,_=null!==(r=e.jitter)&&void 0!==r?r:0,c=null!==(n=e.rtt)&&void 0!==n?n:0;return"audio"===e.kind?{audioBitRate:l,jitter:_,rtt:c}:{videoPacketLostRate:a,videoBitRate:l,videoWidth:null!==(s=e.frameWidth)&&void 0!==s?s:0,videoHeight:null!==(o=e.frameHeight)&&void 0!==o?o:0,jitter:_,rtt:c}}_onRTCStateReport(e){var t;const{senders:i,receivers:r}=e,n=null!==(t=this._context.getCurrentId())&&void 0!==t?t:"";i.forEach(e=>{var t,i,r;const{kind:s,packetsLostRate:o,rtt:a}=e;null===(i=null===(t=this._callPlusStatusReportListener)||void 0===t?void 0:t.onSendQualityChanged)||void 0===i||i.call(t,{[n]:this._trackStatToQualityStats(e)}),this._callMediaType===I_.AUDIO_VIDEO&&"audio"===s||null===(r=this._callPlusStatusReportListener)||void 0===r||r.onSendPacketLoss(o||0,a||0)}),r.forEach(e=>{var t,i,r;const{trackId:n,kind:s,packetsLostRate:o,bitrate:a}=e,{userId:l}=f_(n);if(null===(i=null===(t=this._callPlusStatusReportListener)||void 0===t?void 0:t.onReceiveQualityChanged)||void 0===i||i.call(t,{[l]:this._trackStatToQualityStats(e)}),this._callMediaType===I_.AUDIO_VIDEO&&"audio"===s)return;const _={};_[l]={packetLostRate:o||0,bitRate:a},null===(r=this._callPlusStatusReportListener)||void 0===r||r.onReceivePacketLoss(_)})}_onRTCMethodFail(e,t){this.emit(Cc.__INNER_RTC_PROCESS_FAILED__,e,t)}_onOtherMemJoined(e,t){this.emit(Cc.__INNER_ON_OTHER_JOINED__,e,t)}_createAudioTrack(e){return I(this,void 0,void 0,function*(){this._logger.info(m_.L_RTC_MODULE_CREATE_AUDIO_TRACK_T,"",e);const t=Object.assign(this._audioConfig,{micphoneId:this._audioConfig.microphoneId}),{code:i,track:r}=yield this._rtcClient.createMicrophoneAudioTrack(Ic.NORMAL,t);if(i!==ue.SUCCESS)return this._logger.error(m_.L_RTC_MODULE_CREATE_AUDIO_TRACK_R,`errCode: ${i}`,e),{code:i};this._logger.info(m_.L_RTC_MODULE_CREATE_AUDIO_TRACK_R,"success",e);const{minBitrate:n,maxBitrate:s}=this._audioConfig;return(n||s)&&r.setBitrate(s,n),this._localTracks.push(r),this._onLocalTrackReady([r],e),{code:T_.SUCCESS,track:r}})}_createVideoTrack(e){return I(this,void 0,void 0,function*(){this._logger.info(m_.L_RTC_MODULE_CREATE_VIDEO_TRACK_T,"",e);const{code:t,track:i}=yield this._rtcClient.createCameraVideoTrack(Ic.NORMAL,this._videoConfig);if(t!==ue.SUCCESS)return this._logger.error(m_.L_RTC_MODULE_CREATE_VIDEO_TRACK_R,`errCode: ${t}`,e),{code:t};this._logger.info(m_.L_RTC_MODULE_CREATE_VIDEO_TRACK_R,"success",e);const{minBitrate:r,maxBitrate:n}=this._videoConfig;return(r||n)&&i.setBitrate(n,r),this._localTracks.push(i),this._onLocalTrackReady([i],e),{code:T_.SUCCESS,track:i}})}getLocalVideoTrack(){let e;return this._localTracks&&([e]=this._localTracks.filter(e=>e.isVideoTrack())),e}getLocalAudioTrack(){let e;return this._localTracks&&([e]=this._localTracks.filter(e=>e.isAudioTrack())),e}publish(e,t){return I(this,void 0,void 0,function*(){this._logger.info(m_.L_RTC_MODULE_PUBLISH_T,`tracksIds: ${e.map(e=>e instanceof Yt?e.getTrackId():e.track.getTrackId())}`,t);const{code:i}=yield ic({asyncFn:this._room.publish.bind(this._room),fnArgs:[e],onError:e=>{}});return i!==ue.SUCCESS?(this._onRTCMethodFail(A_.PUBLISH_ERR,t),this._logger.error(m_.L_RTC_MODULE_PUBLISH_R,`errCode: ${i}`,t),{code:i}):(this._logger.info(m_.L_RTC_MODULE_PUBLISH_R,`code: ${T_.SUCCESS}`,t),{code:T_.SUCCESS})})}publishVideoTrack(){const e=this.getLocalVideoTrack(),t=this._isPubTiny?{track:e,isPubTiny:!0}:e;return this._room.publish([t])}setVideoView(e,t){const i=[];e.forEach(e=>{const{userId:t,videoElement:r,isTiny:n=!1}=e;if(this._userViewMap[t]={videoView:r,isTiny:n},t===this._context.getCurrentId())return;if(!this._room)return;const s=(this.getRemoteTracks()[t]||[]).map(e=>({track:e,subTiny:n}));i.push(...s)}),this._logger.info(m_.L_RTC_MODULE_SET_VIDEO_VIEW_O,JSON.stringify({userViewMap:k_(this._userViewMap),needSubTrackIds:i.map(({track:e})=>e.getTrackId())}),t),i.length&&this.subscribeTracks(i,t)}removeVideoView(e,t){const i=[];e.forEach(e=>{const t=this.getRemoteTracks()[e];if(t&&t.length){const e=t.filter(e=>e.isVideoTrack());e.length&&i.push(e[0])}delete this._userViewMap[e]}),this._logger.info(m_.L_RTC_MODULE_REMOVE_VIDEO_VIEW_O,JSON.stringify({userViewMap:k_(this._userViewMap),unsubTracks:i.map(e=>e.getTrackId())}),t),i.length&&this.unsubscribeTracks(i,t)}getUserViewMap(){return this._userViewMap}playMedia(e,t,i,r){return I(this,void 0,void 0,function*(){var n;this._logger.info(m_.L_RTC_MODULE_PLAY_MEDIA_T,`userId: ${e}, mediaType: ${t}, videoView: ${null==i?void 0:i.nodeName}`,r);const s=this._context.getCurrentId();if(e===s&&t===I_.AUDIO)return this._logger.error(m_.L_RTC_MODULE_PLAY_MEDIA_R,"please avoid playing local audio to prevent echoes.",r),{code:T_.PLAY_MEDIA_FAILED};let o=null;if(o=e===s?t===I_.AUDIO?null:this.getLocalVideoTrack():null===(n=this.getRemoteTracks()[e])||void 0===n?void 0:n.filter(e=>t===I_.AUDIO?e.isAudioTrack():e.isVideoTrack())[0],!o)return this._logger.error(m_.L_RTC_MODULE_PLAY_MEDIA_R,`error code: ${T_.MEDIA_RESOURCE_INVALIED}`,r),{code:T_.MEDIA_RESOURCE_INVALIED};try{const{code:e}=o.isAudioTrack()?yield o.play(void 0,{audioDeviceId:this._audioOutputDeviceId||void 0}):yield o.play(i);return o.isAudioTrack()&&!this._remoteAudioEnable&&o.mute(),e!==ue.SUCCESS?(this._logger.error(m_.L_RTC_MODULE_PLAY_MEDIA_R,`errCode: ${e}`,r),{code:e}):(this._logger.info(m_.L_RTC_MODULE_PLAY_MEDIA_R,"success",r),{code:T_.SUCCESS})}catch(e){return this._logger.error(m_.L_RTC_MODULE_PLAY_MEDIA_R,`errCode: ${T_.PLAY_MEDIA_FAILED}, message: ${e.message},`,r),{code:T_.PLAY_MEDIA_FAILED}}})}}Object.defineProperty(Cc,"__INNER_RTC_PROCESS_FAILED__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-rtc-process-failed"}),Object.defineProperty(Cc,"__INNER_RTC_PEERCONNECTION_ABNORMAL_CLOSE__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-rtc-peerconnection-abnormal-close"}),Object.defineProperty(Cc,"__INNER_ON_SELF_JOINED__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-on-self-joined"}),Object.defineProperty(Cc,"__INNER_ON_OTHER_JOINED__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-on-other-joined"}),Object.defineProperty(Cc,"__INNER_RECEIVE_FIRST_FRAME__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-receive-first-frame"}),Object.defineProperty(Cc,"__INNER_ON_KICKOFF__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-kickoff-frame"});class Lc{constructor(e){Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_listener",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}registerEventListener(e){this._listener=e}_callAppListener(e,...t){return I(this,void 0,void 0,function*(){var i;const r=null===(i=this._listener)||void 0===i?void 0:i[e];if(r)try{yield r(...t)}catch(e){console.error(e),this._logger.error(m_.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({name:e.name,message:e.message}))}})}onReceivedCall(e,t,i){this._logger.info(m_.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onReceivedCall",callId:e.getCallId()}),t),this._callAppListener("onReceivedCall",e,i)}onRemoteUserInvited(e,t,i){this._logger.info(m_.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onRemoteUserInvited",inviteeUserList:e,inviterUserId:t,callId:i})),this._callAppListener("onRemoteUserInvited",e,t,i)}onCallConnected(e){this._logger.info(m_.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onCallConnected",callId:e.getCallId()})),this._callAppListener("onCallConnected",e)}onCallTypeChanged(e,t,i){this._logger.info(m_.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onCallTypeChanged",callId:t,callType:e}),i),this._callAppListener("onCallTypeChanged",e,t)}onRemoteUserStateChanged(e,t){const{callId:i,userId:r,userState:n,reason:s}=e;this._logger.info(m_.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onRemoteUserStateChanged",callId:i,userId:r,userState:n,reason:s}),t),this._callAppListener("onRemoteUserStateChanged",i,r,n,s)}onCallEnded(e,t,i){this._logger.info(m_.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onCallEnded",callId:e.getCallId(),closeReason:t}),i),this._callAppListener("onCallEnded",e,t)}onRemoteCameraStateChanged(e,t){this._logger.info(m_.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onRemoteCameraStateChanged",callId:e,trackId:null==t?void 0:t.getTrackId(),enable:null==t?void 0:t.isOwnerMuted()}));const i=null==t?void 0:t.getUserId();this._callAppListener("onRemoteCameraStateChanged",e,i,null==t?void 0:t.isOwnerMuted())}onRemoteMicrophoneStateChanged(e,t){this._logger.info(m_.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onRemoteMicrophoneStateChanged",callId:e,trackId:null==t?void 0:t.getTrackId(),enable:null==t?void 0:t.isOwnerMuted()}));const i=null==t?void 0:t.getUserId();this._callAppListener("onRemoteMicrophoneStateChanged",e,i,null==t?void 0:t.isOwnerMuted())}onReceivedCallRecord(e,t){this._logger.info(m_.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onReceivedCallRecord",record:e}),t),this._callAppListener("onReceivedCallRecord",e)}onReceivedChangeMediaTypeRequest(e,t,i,r){this._logger.info(m_.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onReceivedChangeMediaTypeRequest",userId:e,transactionId:t}),r),this._callAppListener("onReceivedChangeMediaTypeRequest",e,t,i)}onReceivedChangeMediaTypeResult(e,t){const{userId:i,transactionId:r,mediaType:n,result:s}=e;this._logger.info(m_.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onReceivedChangeMediaTypeResult",userId:i,mediaType:n}),t),this._callAppListener("onReceivedChangeMediaTypeResult",{userId:i,transactionId:r,mediaType:n,result:s})}onReceivedCallStartTime(e,t){this._logger.info(m_.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onReceivedCallStartTime",info:e}),t),this._callAppListener("onReceivedCallStartTime",e)}onReceivedCallFirstFrameTime(e,t,i){this._logger.info(m_.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onReceivedCallFirstFrameTime",callId:e,callFirstFrameTime:t}),i),this._callAppListener("onReceivedCallFirstFrameTime",e,t)}onUserMediaAvailable(e,t){this._logger.info(m_.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onUserMediaAvailable",trackIds:e.map(e=>e.getTrackId())}),t),e.forEach(e=>{const t=e.getUserId(),i=e.isAudioTrack()?I_.AUDIO:I_.VIDEO;this._callAppListener("onUserMediaAvailable",t,i)})}onFetchRemoteMediaError(e,t){e.forEach(({track:e})=>{const i=e.getUserId();this._callAppListener("onFetchRemoteMediaError",i,t)})}onUserAudioLevelChanged(e){e.forEach(({track:e,audioLevel:t})=>{const i=e.getUserId();this._callAppListener("onUserAudioLevelChanged",i,t)})}onReceivedCallPlusSummaryMessage(e){this._callAppListener("onReceivedCallPlusSummaryMessage",e)}onReceivedGroupCallStatusMessage(e){this._callAppListener("onReceivedGroupCallStatusMessage",e)}}!function(e){e[e.UNKNOW_ERR=41e3]="UNKNOW_ERR",e[e.DB_ERR=41001]="DB_ERR",e[e.JSON_ERR=41002]="JSON_ERR",e[e.INVALID_JSON_ERR=41003]="INVALID_JSON_ERR",e[e.MISSING_PARAMS=41004]="MISSING_PARAMS",e[e.PARAMS_REQUIRED=41005]="PARAMS_REQUIRED",e[e.DATA_FORMAT_ERR=41006]="DATA_FORMAT_ERR",e[e.METHOD_NOT_IMPLEMENTED=41007]="METHOD_NOT_IMPLEMENTED",e[e.CALL_NOT_EXIST=41010]="CALL_NOT_EXIST",e[e.SINGAL_EXCEED_TWO_INVITEE=41011]="SINGAL_EXCEED_TWO_INVITEE",e[e.GROUP_EXCEEDS_QUORUM=41012]="GROUP_EXCEEDS_QUORUM",e[e.OPERATION_EXPIRED=41013]="OPERATION_EXPIRED",e[e.DEVICE_IS_CALLING=41014]="DEVICE_IS_CALLING",e[e.REPORT_STREAM_READY_TIME_IS_INVALID=41018]="REPORT_STREAM_READY_TIME_IS_INVALID",e[e.NOT_CALL_YOURSELF=41019]="NOT_CALL_YOURSELF",e[e.SESSION_STATUS_NOT_EXIST=41020]="SESSION_STATUS_NOT_EXIST",e[e.HANGUP_NOT_ALLOW=41021]="HANGUP_NOT_ALLOW",e[e.ACCEPT_NOT_ALLOW=41022]="ACCEPT_NOT_ALLOW",e[e.OPERATION_NOT_ALLOW=41025]="OPERATION_NOT_ALLOW",e[e.TRANSACTION_ID_ERR=41100]="TRANSACTION_ID_ERR",e[e.UP_VIDEO_CANCELED=41050]="UP_VIDEO_CANCELED",e[e.CURRENT_CALL_IS_AUDIO=41051]="CURRENT_CALL_IS_AUDIO",e[e.CURRENT_CALL_IS_VIDEO=41052]="CURRENT_CALL_IS_VIDEO"}(Rc||(Rc={}));class Oc{constructor(e){Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_androidPushConfig",{enumerable:!0,configurable:!0,writable:!0,value:{}})}setChannelIdMi(e){return C(e)?(this._androidPushConfig.channelIdMi=e,this):(this._logger.error(m_.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: channelIdMi type is string, value: ${e}`),this)}setMiLargeIconUrl(e){return this._logger.warn(m_.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,"`setMiLargeIconUrl` has been deprecated."),this}setChannelIdHW(e){return C(e)?(this._androidPushConfig.channelIdHW=e,this):(this._logger.error(m_.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: channelIdHW type is string, value: ${e}`),this)}setCategoryHW(e){return C(e)?(this._androidPushConfig.categoryHW=e,this):(this._logger.error(m_.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: categoryHW type is string, value: ${e}`),this)}setImportanceHW(e){return"LOW"!==e&&"NORMAL"!==e?(this._logger.error(m_.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: importanceHW value is NORMAL|LOW, value: ${e}`),this):(this._androidPushConfig.importanceHW=e,this)}setImageUrlHW(e){return C(e)?(this._androidPushConfig.imageUrlHW=e,this):(this._logger.error(m_.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: imageUrlHW type is string, value: ${e}`),this)}setChannelIdOPPO(e){return C(e)?(this._androidPushConfig.channelIdOPPO=e,this):(this._logger.error(m_.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: channelIdOPPO type is string, value: ${e}`),this)}setTypeVivo(e){return C(e)?(this._androidPushConfig.typeVivo=e,this):(this._logger.error(m_.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: typeVivo type is string, value: ${e}`),this)}setCategoryVivo(e){return C(e)?(this._androidPushConfig.categoryVivo=e,this):(this._logger.error(m_.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: categoryVivo type is string, value: ${e}`),this)}setFcmChannelId(e){return C(e)?(this._androidPushConfig.fcmChannelId=e,this):(this._logger.error(m_.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: fcmChannelId type is string, value: ${e}`),this)}setFcmCollapseKey(e){return C(e)?(this._androidPushConfig.fcmCollapseKey=e,this):(this._logger.error(m_.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: fcmCollapseKey type is string, value: ${e}`),this)}setFcmImageUrl(e){return C(e)?(this._androidPushConfig.fcmImageUrl=e,this):(this._logger.error(m_.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: fcmImageUrl type is string, value: ${e}`),this)}setimportanceHonor(e){return"LOW"!==e&&"NORMAL"!==e?(this._logger.error(m_.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: importanceHonor value is NORMAL|LOW, value: ${e}`),this):(this._androidPushConfig.importanceHonor=e,this)}setimageUrlHonor(e){return C(e)?(this._androidPushConfig.imageUrlHonor=e,this):(this._logger.error(m_.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: imageUrlHonor type is string, value: ${e}`),this)}build(){return this._androidPushConfig}}class vc{constructor(e,t,i,r){Object.defineProperty(this,"_runtime",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_initOpts",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_rtcPluginContext",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_rtcClient",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_videoConfig",{enumerable:!0,configurable:!0,writable:!0,value:{resolution:Nt.W640_H480,frameRate:yt.FPS_15}}),Object.defineProperty(this,"_audioConfig",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_callPlusStatistics",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_clientCallId",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(this,"_isLaunchHangup",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_needHangupCallId",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_callEngine",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_rtcModule",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_reportAppEventModule",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._logger=this._rtcPluginContext.logger,this._rtcPluginContext.registerMessageType("RC:CallPlusMiss",!0,!1,[]),this._reportAppEventModule=new Lc(this._logger),this._callPlusStatistics=new Z_(this._rtcPluginContext),this._callEngine=new mc(this._rtcPluginContext,this._runtime,this._initOpts,this._logger,this._reportAppEventModule),this._rtcModule=new Cc(this._rtcPluginContext,this._runtime,this._initOpts,this._logger,this._callEngine,this._reportAppEventModule,this._rtcClient),this._callEngine.setRTCModule(this._rtcModule),this._rtcModule.on(Cc.__INNER_RTC_PROCESS_FAILED__,this._rtcProcessFailHandle.bind(this)),this._rtcModule.on(Cc.__INNER_RTC_PEERCONNECTION_ABNORMAL_CLOSE__,this._peerConnectionAbnormalClose.bind(this)),this._rtcModule.on(Cc.__INNER_ON_SELF_JOINED__,this._selfJoinedHandle.bind(this)),this._rtcModule.on(Cc.__INNER_ON_OTHER_JOINED__,this._otherJoinedHandle.bind(this)),this._rtcModule.on(Cc.__INNER_RECEIVE_FIRST_FRAME__,this._receiveFirstFrameHandle.bind(this)),this._rtcModule.on(Cc.__INNER_ON_KICKOFF__,this._kickoffHandle.bind(this)),this._callEngine.on(mc.__INNER_SESSION_CONNECT__,this._rtcModule.sessionConnected.bind(this._rtcModule)),this._callEngine.on(mc.__INNER_SESSION_CLOSE__,this._sessionCloseHandle.bind(this)),this._callEngine.on(mc.__INNER_CHANGE_MEDIA_TYPE__,this._rtcModule.changeMediaType.bind(this._rtcModule)),this._callEngine.on(mc.__INNER_INVITE__,(e,t)=>{this._callPlusStatistics.reportStatisticsData(K_.L_QS_RECEIVE_CALL_S,T_.SUCCESS,+new Date,e,"",t)})}_rtcProcessFailHandle(e,t){const i=this._callEngine.getLocalMainSession();if(i){const r=i.getCallId();this._callEngine.systemStatusUp({callId:r,sysStatus:e,forward:gc.CURRENT},t),this._callPlusStatistics.reportStatisticsData(K_.L_QS_ABNORMAL_HANGUP_S,T_.SUCCESS,+new Date,i),this.__innerHangup({callId:r,systemState:e},t)}}_peerConnectionAbnormalClose(e){const t=this._callEngine.getLocalMainSession();t&&(this._callEngine.systemStatusUp({callId:t.getCallId(),sysStatus:A_.CONNECTION_ERR,forward:gc.CURRENT},e),this._callEngine.endCurrentSession(A_.CONNECTION_ERR,t.getCallId(),e))}_selfJoinedHandle(e,t,i){return I(this,void 0,void 0,function*(){const r=this._rtcPluginContext.getCurrentId(),n=this._callEngine.getLocalMainSession();((null==n?void 0:n.getCallType())===C_.MULTI||t.length)&&this._callEngine.updateMainSessionState(v_.ONCALL);const s=[r,...t].map(e=>({userId:e,userState:O_.ONCALL,systemState:A_.ONCALL})),o=this._callEngine.updateUsersState(e,s,i);this._reportAppEventModule.onCallConnected(n),o.length>0&&this._callEngine.reportRemoteUserStateChange(e,o,i),this._callEngine.startTimeCorrection(i)})}_otherJoinedHandle(e,t){var i;let r="";const n=e.map(e=>(r=e.callId,{userId:e.userId,userState:O_.ONCALL,systemState:A_.ONCALL})),s=this._callEngine.updateUsersState(r,n,t);s.length>0&&this._callEngine.reportRemoteUserStateChange(r,s,t),(null===(i=this._callEngine.getLocalMainSession())||void 0===i?void 0:i.getState())!==v_.ONCALL&&this._callEngine.updateMainSessionState(v_.ONCALL)}_receiveFirstFrameHandle(e){var t;(null===(t=this._callEngine.getLocalMainSession())||void 0===t?void 0:t.getState())!==v_.ONCALL&&this._callEngine.updateMainSessionState(v_.ONCALL),this._callEngine.upFirstFrameTime(e)}_kickoffHandle(e,t,i){if(e===A_.CONNECTION_ERR)return void this._callEngine.endCurrentSession(e,t,i);const r=this._callEngine.getLocalMainSession();if(r){const n=r.getCallId();this._callPlusStatistics.reportStatisticsData(K_.L_QS_ABNORMAL_HANGUP_S,T_.SUCCESS,+new Date,r,this._clientCallId),this._callEngine.systemStatusUp({callId:n,sysStatus:e,forward:gc.CURRENT},i),this._callEngine.endCurrentSession(e,t,i)}}_sessionCloseHandle(e,t){this._isLaunchHangup||(this._clientCallId=""),this._isLaunchHangup=!1,this._rtcModule.sessionClose(e,t)}setCallPlusEventListener(e){this._logger.info(m_.L_CALLPLUS_CLIENT_SET_EVENT_LISTENER_O,e?Object.keys(e).join(","):null),this._reportAppEventModule.registerEventListener(e)}setStatusReportListener(e){this._logger.info(m_.L_CALLPLUS_CLIENT_SET_STATUS_REPORT_LISTENER_O,e?Object.keys(e).join(","):null),this._rtcModule.setCallPlusStatusReportListener(e)}setVideoView(e){const t=this._logger.createTraceId();if(this._logger.info(m_.L_CALLPLUS_CLIENT_SET_VIDEO_VIEW_T,JSON.stringify({list:e.map(e=>{const{userId:t,videoElement:i,isTiny:r}=e;return{userId:t,elementName:null==i?void 0:i.nodeName,isTiny:r}})}),t),!A(e))return this._logger.error(m_.L_CALLPLUS_CLIENT_SET_VIDEO_VIEW_R,`params err, list: not empty array, value: ${JSON.stringify(e)}`,t),{code:T_.PARAM_ERROR};for(const i of e){const{userId:e,videoElement:r}=i;if(!b(e))return this._logger.error(m_.L_CALLPLUS_CLIENT_SET_VIDEO_VIEW_R,`params err, userId: not empty string, value: ${e}`,t),{code:T_.PARAM_ERROR};if(!D_(r))return this._logger.error(m_.L_CALLPLUS_CLIENT_SET_VIDEO_VIEW_R,`params err, videoElement: need a video element, value: ${r instanceof HTMLElement?r.nodeName:r}`,t),{code:T_.PARAM_ERROR}}return this._logger.info(m_.L_CALLPLUS_CLIENT_SET_VIDEO_VIEW_R,"succes",t),this._rtcModule.setVideoView(e,t),{code:T_.SUCCESS}}removeVideoView(e){const t=this._logger.createTraceId();return this._logger.info(m_.L_CALLPLUS_CLIENT_REMOVE_VIDEO_VIEW_T,JSON.stringify({userIds:e}),t),A(e)&&e.every(e=>b(e))?(this._logger.info(m_.L_CALLPLUS_CLIENT_REMOVE_VIDEO_VIEW_R,"succes",t),this._rtcModule.removeVideoView(e,t),{code:T_.SUCCESS}):(this._logger.error(m_.L_CALLPLUS_CLIENT_REMOVE_VIDEO_VIEW_R,`params err, userIds: not empty array, userId: not empty string, value: ${JSON.stringify(e)}`,t),{code:T_.PARAM_ERROR})}playMedia(e,t){return I(this,void 0,void 0,function*(){const i=this._logger.createTraceId();if(this._logger.info(m_.L_CALLPLUS_CLIENT_PLAY_MEDIA_T,JSON.stringify({userId:e,mediaType:t}),i),!b(e))return this._logger.error(m_.L_CALLPLUS_CLIENT_PLAY_MEDIA_R,`params err, userId: not empty string, value: ${e}`,i),{code:T_.PARAM_ERROR};if(P(I_[t]))return this._logger.error(m_.L_CALLPLUS_CLIENT_PLAY_MEDIA_R,`params err, mediaType is illegal, value: ${t}`,i),{code:T_.PARAM_ERROR};if(t===I_.AUDIO&&e===this._rtcPluginContext.getCurrentId())return this._logger.info(m_.L_CALLPLUS_CLIENT_PLAY_MEDIA_R,"success",i),{code:T_.SUCCESS};const{videoView:r}=this._rtcModule.getUserViewMap()[e]||{};return t===I_.AUDIO||r?this._rtcModule.playMedia(e,t,r,i):(this._logger.error(m_.L_CALLPLUS_CLIENT_PLAY_MEDIA_R,`errCode: ${T_.VIDEO_VIEW_NOT_SET}, video view not set`,i),{code:T_.VIDEO_VIEW_NOT_SET})})}createVideoConfigBuilder(){return new P_(this._logger)}setVideoConfig(e){this._logger.info(m_.L_CALLPLUS_CLIENT_SET_VIDEO_CONFIG_T,JSON.stringify(e));const{frameRate:t,resolution:i,maxBitrate:r,minBitrate:n}=e;if(!yt[t])return this._logger.error(m_.L_CALLPLUS_CLIENT_SET_VIDEO_CONFIG_R,`param error, frameRate is illegal, value: ${t}`),{code:T_.PARAM_ERROR};if(!Nt[i])return this._logger.error(m_.L_CALLPLUS_CLIENT_SET_VIDEO_CONFIG_R,`param error, resolution is illegal, value: ${i}`),{code:T_.PARAM_ERROR};const{code:s,errorMsg:o}=w_(n,r);return s!==T_.SUCCESS&&this._logger.error(m_.L_CALLPLUS_CLIENT_SET_VIDEO_CONFIG_R,o),this._logger.info(m_.L_CALLPLUS_CLIENT_SET_VIDEO_CONFIG_R,"success"),this._videoConfig=Object.assign({},e),this._rtcModule.setVideoConfig(this._videoConfig),{code:T_.SUCCESS}}createAudioConfigBuilder(){return new N_(this._logger)}createAndroidPushConfigBuilder(){return new Oc(this._logger)}setAudioConfig(e){this._logger.info(m_.L_CALLPLUS_CLIENT_SET_AUDIO_CONFIG_T,JSON.stringify(e));const{sampleRate:t,minBitrate:i,maxBitrate:r}=e;if(t&&!O(t))return this._logger.error(m_.L_CALLPLUS_CLIENT_SET_AUDIO_CONFIG_R,`param error, sampleRate: type is number, value: ${t}`),{code:T_.PARAM_ERROR};const{code:n,errorMsg:s}=w_(i,r);return n!==T_.SUCCESS&&this._logger.error(m_.L_CALLPLUS_CLIENT_SET_AUDIO_CONFIG_R,s),this._logger.info(m_.L_CALLPLUS_CLIENT_SET_AUDIO_CONFIG_R,"success"),this._audioConfig=Object.assign({},e),this._rtcModule.setAudioConfig(this._audioConfig),{code:T_.SUCCESS}}setAudioOutputDeviceId(e){return this._logger.info(m_.L_CALLPLUS_CLIENT_SET_AUDIO_OUTPUT_DEVICE_ID_O,e),this._rtcModule.setAudioOutputDeviceId(e)}startCall(e){return I(this,arguments,void 0,function*(e,t=C_.SINGLE,i=I_.AUDIO_VIDEO,r,n,s){this._clientCallId=J.gen();const o=+new Date,a=this._logger.createTraceId();if(this._logger.info(m_.L_CALLPLUS_CLIENT_START_CALL_T,`userIds: ${e.join(",")}, callType: ${t}, mediaType: ${i}, pushConfig: ${r}, extra: ${n}`,a),this._rtcPluginContext.getConnectionStatus()!==l.CONNECTED)return this._logger.error(m_.L_CALLPLUS_CLIENT_START_CALL_R,`errCode: ${T_.SIGNAL_DISCONNECTED}`,a),{code:T_.SIGNAL_DISCONNECTED};const _=this._rtcPluginContext.getNaviInfo();if(!_||!M_(_))return this._logger.error(m_.L_CALLPLUS_CLIENT_START_CALL_R,`errCode: ${T_.RTC_SERVICE_UNAVAILABLE}`,a),{code:T_.RTC_SERVICE_UNAVAILABLE};if(!A(e)||!e.every(e=>b(e)))return this._logger.error(m_.L_CALLPLUS_CLIENT_START_CALL_R,`params err, userIds: not empty array, userId: not empty string, value: ${JSON.stringify(e)}`,a),{code:T_.PARAM_ERROR};if(P(C_[t]))return this._logger.error(m_.L_CALLPLUS_CLIENT_START_CALL_R,`params err, callType is illegal, value: ${t}`,a),{code:T_.PARAM_ERROR};if(P(I_[i]))return this._logger.error(m_.L_CALLPLUS_CLIENT_START_CALL_R,`params err, mediaType is illegal, value: ${i}`,a),{code:T_.PARAM_ERROR};if(r){const e=V_(r);if(e.code!==T_.SUCCESS)return this._logger.error(m_.L_CALLPLUS_CLIENT_START_CALL_R,`params err, pushConfig is illegal, msg: ${e.errorMsg}`,a),{code:T_.PARAM_ERROR}}if(n){if(!C(n))return this._logger.error(m_.L_CALLPLUS_CLIENT_START_CALL_R,`params err, extra is illegal, type: string, value: ${n}`,a),{code:T_.PARAM_ERROR};if(j_(n)>oc)return this._logger.error(m_.L_CALLPLUS_CLIENT_START_CALL_R,"params err, extra max size is 128KB",a),{code:T_.PARAM_ERROR}}if(e.length>1&&t===C_.SINGLE)return this._logger.error(m_.L_CALLPLUS_CLIENT_START_CALL_R,`params err, You can only call one person in a single call, userIds: ${e.join(",")}`,a),{code:T_.PARAM_ERROR};if(s&&!C(s))return this._logger.error(m_.L_CALLPLUS_CLIENT_START_CALL_R,`params err, targetId is illegal, type: string, value: ${s}`,a),{code:T_.PARAM_ERROR};if(this._callEngine.getLocalMainSession())return this._logger.error(m_.L_CALLPLUS_CLIENT_START_CALL_R,`errCode: ${T_.SESSION_EXIST}, session exist`,a),{code:T_.SESSION_EXIST};const{code:c}=yield this._rtcModule.createCallMediaTracks(i,a);if(c!==T_.SUCCESS)return this._logger.error(m_.L_CALLPLUS_CLIENT_START_CALL_R,`create meida tracks error code: ${c}`,a),{code:c};const{code:d,data:u}=yield this._callEngine.startCall({toUsers:e.map(e=>({userId:e})),callType:t,mediaType:i,callId:this._clientCallId,pushConfig:r,extra:JSON.stringify({userId:this._rtcPluginContext.getCurrentId(),extra:n}),targetId:s},a);if(this._callPlusStatistics.reportStatisticsData(K_.L_QS_START_CALL_S,d,o,null,this._clientCallId,null,{mediaType:i,callType:t,callId:(null==u?void 0:u.callId)||""}),d!==T_.SUCCESS)return this._rtcModule.destroyAllTracks(a),this._logger.error(m_.L_CALLPLUS_CLIENT_START_CALL_R,`signal error code: ${d}`,a),{code:d};const{callId:h,clientCallId:g}=u;return this._needHangupCallId===g?(this._callEngine.clearAllTimer(h,a),this._callEngine.hangup({callId:h,systemState:A_.CANCELLED},a),this._logger.info(m_.L_CALLPLUS_CLIENT_START_CALL_R,`the ${h} call has been hangup`,a),{code:T_.SUCCESS}):(t===C_.MULTI&&this._rtcModule.sessionConnected(h,a),this._logger.info(m_.L_CALLPLUS_CLIENT_START_CALL_R,JSON.stringify({data:u,code:d}),a),{code:T_.SUCCESS,callId:h})})}joinMultiCall(e){return I(this,void 0,void 0,function*(){const t=this._logger.createTraceId();if(this._logger.info(m_.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_T,`callId: ${e}`,t),this._rtcPluginContext.getConnectionStatus()!==l.CONNECTED)return this._logger.error(m_.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_R,`code: ${T_.SIGNAL_DISCONNECTED}`,t),{code:T_.SIGNAL_DISCONNECTED};const i=this._rtcPluginContext.getNaviInfo();if(!i||!M_(i))return this._logger.error(m_.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_R,`code: ${T_.RTC_SERVICE_UNAVAILABLE}`,t),{code:T_.RTC_SERVICE_UNAVAILABLE};if(!b(e))return this._logger.error(m_.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_R,`params err, callId: not empty string, value: ${e}`,t),{code:T_.PARAM_ERROR};const{code:r,data:n}=yield this._callEngine.getCallSession({callId:e},t);if(r!==T_.SUCCESS)return this._logger.error(m_.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_R,`get call data error, code: ${r}`,t),{code:r};const{mediaType:s}=n,o=this._callEngine.getLocalMainSession();if(o&&o.getCallId()!==e)return{code:T_.SESSION_EXIST};const{code:a}=yield this._rtcModule.createCallMediaTracks(s,t);if(a!==T_.SUCCESS)return this._logger.error(m_.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_R,`create meida tracks error code: ${a}`,t),{code:a};const{code:_}=yield this._callEngine.joinCall({callId:e,mediaType:s},t);return _!==T_.SUCCESS?(this._rtcModule.destroyAllTracks(t),this._logger.error(m_.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_R,`signal error code: ${_}`,t),{code:_}):(this._logger.info(m_.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_R,`code: ${T_.SUCCESS}`,t),yield this._rtcModule.sessionConnected(e,t),{code:T_.SUCCESS})})}invite(e,t,i){return I(this,void 0,void 0,function*(){var r;const n=this._logger.createTraceId();if(this._logger.info(m_.L_CALLPLUS_CLIENT_INVITE_T,`callId: ${e.join(",")}, pushConfig: ${t}, extra: ${i}`,n),!A(e)||!e.every(e=>b(e)))return this._logger.error(m_.L_CALLPLUS_CLIENT_INVITE_R,`params err, userIds: not empty array, userId: not empty string, value: ${JSON.stringify(e)}`,n),{code:T_.PARAM_ERROR};if(t){const e=V_(t);if(e.code!==T_.SUCCESS)return this._logger.error(m_.L_CALLPLUS_CLIENT_INVITE_R,`params err, pushConfig is illegal, msg: ${e.errorMsg}`,n),{code:T_.PARAM_ERROR}}if(i){if(!C(i))return this._logger.error(m_.L_CALLPLUS_CLIENT_INVITE_R,`params err, extra is illegal, value: ${i}`,n),{code:T_.PARAM_ERROR};if(j_(i)>oc)return this._logger.error(m_.L_CALLPLUS_CLIENT_INVITE_R,"params err, extra max size is 128KB",n),{code:T_.PARAM_ERROR}}const{code:s,data:o}=yield this._callEngine.invite({toUsers:e.map(e=>({userId:e})),pushConfig:t,extra:JSON.stringify({userId:this._rtcPluginContext.getCurrentId(),extra:i})},n);if(s!==T_.SUCCESS)return this._logger.error(m_.L_CALLPLUS_CLIENT_INVITE_R,`signal error code: ${s}`,n),{code:s};const a=[];return(null===(r=o.busylineUsers)||void 0===r?void 0:r.length)&&a.push(...o.busylineUsers.map(e=>({userId:e.userId,state:e.sessionStatus}))),this._logger.info(m_.L_CALLPLUS_CLIENT_INVITE_R,`success busyUsers: ${JSON.stringify(a)}`,n),{code:T_.SUCCESS,busyUsers:a}})}accept(e,t){return I(this,void 0,void 0,function*(){const i=+new Date,r=this._logger.createTraceId();if(this._logger.info(m_.L_CALLPLUS_CLIENT_ACCEPT_T,`callId: ${e}, pushConfig: ${t}`,r),this._rtcPluginContext.getConnectionStatus()!==l.CONNECTED)return this._logger.error(m_.L_CALLPLUS_CLIENT_ACCEPT_R,`errCode: ${T_.SIGNAL_DISCONNECTED}`,r),{code:T_.SIGNAL_DISCONNECTED};const n=this._rtcPluginContext.getNaviInfo();if(!n||!M_(n))return this._logger.error(m_.L_CALLPLUS_CLIENT_ACCEPT_R,`errCode: ${T_.RTC_SERVICE_UNAVAILABLE}`,r),{code:T_.RTC_SERVICE_UNAVAILABLE};if(!b(e))return this._logger.error(m_.L_CALLPLUS_CLIENT_ACCEPT_R,`params err, callId: not empty string, value: ${e}`,r),{code:T_.PARAM_ERROR};if(t){const e=V_(t);if(e.code!==T_.SUCCESS)return this._logger.error(m_.L_CALLPLUS_CLIENT_ACCEPT_R,`params err, pushConfig is illegal, msg: ${e.errorMsg}`,r),{code:T_.PARAM_ERROR}}let s=this._callEngine.getLocalMainSession();const o=this._callEngine.getHoldSession(e);if(!s&&!o)return this._logger.error(m_.L_CALLPLUS_CLIENT_ACCEPT_R,`errCode : ${T_.NOT_IN_CALL}, session not exist`,r),{code:T_.NOT_IN_CALL};if(e===(null==o?void 0:o.getCallId())){const{code:t}=yield this.hangup(s.getCallId());if(t!==T_.SUCCESS)return this._logger.error(m_.L_CALLPLUS_CLIENT_ACCEPT_R,`hangup mainSession error code: ${t}`,r),{code:t};this._callEngine.upgradeMainSession(e),s=this._callEngine.getLocalMainSession()}const a=s.getMediaType(),{code:_}=yield this._rtcModule.createCallMediaTracks(a,r);if(_!==T_.SUCCESS)return this._logger.error(m_.L_CALLPLUS_CLIENT_ACCEPT_R,`create meida tracks error code: ${_}`,r),{code:_};const{code:c}=yield this._callEngine.accept({callId:e},r);return this._callPlusStatistics.reportStatisticsData(K_.L_QS_ACCEPT_CALL_S,c,i,s),c!==T_.SUCCESS?(this._rtcModule.destroyAllTracks(r),this._logger.error(m_.L_CALLPLUS_CLIENT_ACCEPT_R,`signal error code: ${c}`,r),{code:c}):(this._logger.info(m_.L_CALLPLUS_CLIENT_ACCEPT_R,"success",r),this._rtcModule.sessionConnected(e,r),{code:T_.SUCCESS})})}__innerHangup(e,t){return I(this,void 0,void 0,function*(){var i;const{callId:r}=e;this._callEngine.setIsLocalClientHangup(!0),this._callEngine.clearAllTimer(r,t);const{code:n}=yield this._callEngine.hangup(e,t);return n===Rc.CALL_NOT_EXIST?{code:T_.SUCCESS}:(n===T_.SUCCESS&&r===(null===(i=this._callEngine.getLocalMainSession())||void 0===i?void 0:i.getCallId())&&(yield this._rtcModule.sessionClose(r,t)),{code:n})})}hangup(e,t){return I(this,void 0,void 0,function*(){const i=+new Date,r=this._logger.createTraceId();this._logger.info(m_.L_CALLPLUS_CLIENT_HANGUP_T,`callId: ${e}, pushConfig: ${t}`,r);const n=this._callEngine.getLocalMainSession();if(!n)return{code:T_.NOT_IN_CALL};if(e&&!C(e))return this._logger.error(m_.L_CALLPLUS_CLIENT_HANGUP_R,`params err, callId: type is string, value: ${e}`,r),{code:T_.PARAM_ERROR};if(t){const e=V_(t);if(e.code!==T_.SUCCESS)return this._logger.error(m_.L_CALLPLUS_CLIENT_HANGUP_R,`params err, pushConfig is illegal, msg: ${e.errorMsg}`,r),{code:T_.PARAM_ERROR}}const s=n.getCallId();if(e&&e!==s&&!this._callEngine.getHoldSession(e))return this._logger.error(m_.L_CALLPLUS_CLIENT_HANGUP_R,`params err, callId is invalid, value: ${e}`,r),{code:T_.CALL_ID_INVALID};this._isLaunchHangup=!0,this._needHangupCallId=e||s;const o=this._callEngine.getHoldSession(this._needHangupCallId)||n,a=this._rtcPluginContext.getCurrentId(),l=((e,t)=>{let i;switch(e){case O_.CALLING:i=A_.CANCELLED;break;case O_.RINGING:case O_.INVITED:i=A_.DECLINED;break;case O_.CONNECTING:i=t?A_.DECLINED:A_.CANCELLED;break;case O_.ONCALL:i=A_.ENDED}return i})(n.getUserList().filter(e=>e.userId===a)[0].state,[n.getCreatorUserId(),n.getInviterUserId()].includes(a))||A_.ENDED,{code:_}=yield this.__innerHangup({callId:this._needHangupCallId,systemState:l,pushConfig:t},r);return this._callPlusStatistics.reportStatisticsData(K_.L_QS_HANGUP_CALL_S,_,i,o,this._clientCallId),_!==T_.SUCCESS?(this._logger.error(m_.L_CALLPLUS_CLIENT_HANGUP_R,`signal error code : ${_}`,r),{code:_}):(this._needHangupCallId=null,this._logger.info(m_.L_CALLPLUS_CLIENT_HANGUP_R,"success",r),{code:T_.SUCCESS})})}requestChangeMediaType(e){return I(this,void 0,void 0,function*(){const t=this._logger.createTraceId();if(this._logger.info(m_.L_CALLPLUS_CLIENT_REQUEST_CHANGE_MEDIA_TYPE_T,`mediaType: ${e}`,t),P(I_[e]))return this._logger.error(m_.L_CALLPLUS_CLIENT_REQUEST_CHANGE_MEDIA_TYPE_R,`params err, mediaType is illegal, value: ${e}`,t),{code:T_.PARAM_ERROR};const i=this.getCurrentCallSession(),r=null==i?void 0:i.getMediaType();if(e===r)return this._logger.error(m_.L_CALLPLUS_CLIENT_REQUEST_CHANGE_MEDIA_TYPE_R,`error code: ${T_.MEDIATYPE_INVALID}`,t),{code:T_.MEDIATYPE_INVALID};if(!this._callEngine.getLocalMainSession())return this._logger.error(m_.L_CALLPLUS_CLIENT_REQUEST_CHANGE_MEDIA_TYPE_R,`error code : ${T_.NOT_IN_CALL}, session not exist`,t),{code:T_.NOT_IN_CALL};const n=null==i?void 0:i.getUserList().filter(e=>e.userId!==this._rtcPluginContext.getCurrentId()).map(e=>e.userId),{code:s,data:o}=yield this._callEngine.requestChangeMediaType({mediaType:e,toUserIds:n||[]},t);return s!==T_.SUCCESS?(this._logger.error(m_.L_CALLPLUS_CLIENT_REQUEST_CHANGE_MEDIA_TYPE_R,`signal error code: ${s}`,t),{code:s}):(this._logger.info(m_.L_CALLPLUS_CLIENT_REQUEST_CHANGE_MEDIA_TYPE_R,`success transactionId: ${o.transactionId}`,t),{code:T_.SUCCESS,transactionId:o.transactionId})})}cancelChangeMediaType(e){return I(this,void 0,void 0,function*(){const t=this._logger.createTraceId();if(this._logger.info(m_.L_CALLPLUS_CLIENT_CANCEL_CHANGE_MEDIA_TYPE_T,`transactionId: ${e}`,t),!b(e))return this._logger.error(m_.L_CALLPLUS_CLIENT_CANCEL_CHANGE_MEDIA_TYPE_R,`param error, transactionId: not empty string, value: ${e}`,t),{code:T_.PARAM_ERROR};if(!this._callEngine.getLocalMainSession())return this._logger.error(m_.L_CALLPLUS_CLIENT_CANCEL_CHANGE_MEDIA_TYPE_R,`error code : ${T_.NOT_IN_CALL}, session not exist`,t),{code:T_.NOT_IN_CALL};const{code:i}=yield this._callEngine.cancelChangeMediaType({transactionId:e},t);return i!==T_.SUCCESS?(this._logger.error(m_.L_CALLPLUS_CLIENT_CANCEL_CHANGE_MEDIA_TYPE_R,`signal error code: ${i}`,t),{code:i}):(this._logger.info(m_.L_CALLPLUS_CLIENT_CANCEL_CHANGE_MEDIA_TYPE_R,"success",t),{code:T_.SUCCESS})})}replyChangeMediaType(e,t){return I(this,void 0,void 0,function*(){const i=this._logger.createTraceId();if(this._logger.info(m_.L_CALLPLUS_CLIENT_REPLY_CHANGE_MEDIA_TYPE_T,`transactionId: ${e}`,i),!b(e))return this._logger.error(m_.L_CALLPLUS_CLIENT_REPLY_CHANGE_MEDIA_TYPE_R,`param error, transactionId: not empty string, value: ${e}`,i),{code:T_.PARAM_ERROR};if(!L(t))return this._logger.error(m_.L_CALLPLUS_CLIENT_REPLY_CHANGE_MEDIA_TYPE_R,`param error, isAgree: type is boolean, value: ${t}`,i),{code:T_.PARAM_ERROR};if(!this._callEngine.getLocalMainSession())return this._logger.error(m_.L_CALLPLUS_CLIENT_REPLY_CHANGE_MEDIA_TYPE_R,`error code : ${T_.NOT_IN_CALL}, session not exist`,i),{code:T_.NOT_IN_CALL};const{code:r}=yield this._callEngine.responseChangeMediaType({transactionId:e,agree:t},i);return r!==T_.SUCCESS?(this._logger.error(m_.L_CALLPLUS_CLIENT_REPLY_CHANGE_MEDIA_TYPE_R,`signal error: ${r}`,i),{code:r}):(this._logger.info(m_.L_CALLPLUS_CLIENT_REPLY_CHANGE_MEDIA_TYPE_R,"success",i),{code:T_.SUCCESS})})}getCurrentCallSession(){return this._callEngine.getLocalMainSession()}getAvailableCallRecordsFromServer(){return I(this,void 0,void 0,function*(){const e=this._logger.createTraceId();this._logger.info(m_.L_CALLPLUS_CLIENT_GET_AVAILABLE_CALL_RECORDS_FROM_SERVER_T,"",e);const{code:t,data:i}=yield this._callEngine.getOpenCallList(e);return t!==T_.SUCCESS?(this._logger.error(m_.L_CALLPLUS_CLIENT_GET_AVAILABLE_CALL_RECORDS_FROM_SERVER_R,`signal error code: ${t}`,e),{code:t}):(this._logger.info(m_.L_CALLPLUS_CLIENT_GET_AVAILABLE_CALL_RECORDS_FROM_SERVER_R,`success, data: ${JSON.stringify(i)}`,e),{code:T_.SUCCESS,records:i})})}getCallRecords(e,t){return I(this,arguments,void 0,function*(e,t,i=0){const r=this._logger.createTraceId();if(this._logger.info(m_.L_CALLPLUS_CLIENT_GET_CALL_RECORDS_T,`startTimestamp: ${e}, count: ${t}`,r),!(O(e)&&e>=0))return this._logger.error(m_.L_CALLPLUS_CLIENT_GET_CALL_RECORDS_R,`params error, startTimestamp: is a number >= 0, value: ${e}`,r),{code:T_.PARAM_ERROR};if(!(O(t)&&t>0))return this._logger.error(m_.L_CALLPLUS_CLIENT_GET_CALL_RECORDS_R,`params error, count: is a number >= 0, value: ${t}`,r),{code:T_.PARAM_ERROR};const{code:n,data:s}=yield this._callEngine.getCallLogList({timestamp:e,count:t,order:i},r);return n!==T_.SUCCESS?(this._logger.error(m_.L_CALLPLUS_CLIENT_GET_CALL_RECORDS_R,`signal error code: ${n}`,r),{code:n}):(this._logger.info(m_.L_CALLPLUS_CLIENT_GET_CALL_RECORDS_R,"success",r),{code:T_.SUCCESS,result:s})})}deleteCallRecordsFromServer(e){return I(this,void 0,void 0,function*(){const t=this._logger.createTraceId();if(this._logger.info(m_.L_CALLPLUS_CLIENT_DELETE_CALL_RECORDS_BY_CALLID_T,`callIds: ${e.join(",")}`,t),!A(e)||!e.every(e=>b(e)))return this._logger.error(m_.L_CALLPLUS_CLIENT_DELETE_CALL_RECORDS_BY_CALLID_R,`params err, callIds: not empty array, callId: not empty string, callIds: ${JSON.stringify(e)}`,t),{code:T_.PARAM_ERROR};const{code:i}=yield this._callEngine.deleteCallLog(e,t);return i!==T_.SUCCESS?(this._logger.error(m_.L_CALLPLUS_CLIENT_DELETE_CALL_RECORDS_BY_CALLID_R,`signal error code: ${i}`,t),{code:i}):(this._logger.info(m_.L_CALLPLUS_CLIENT_DELETE_CALL_RECORDS_BY_CALLID_R,"success",t),{code:T_.SUCCESS})})}deleteAllCallRecordsFromServer(){return I(this,void 0,void 0,function*(){const e=this._logger.createTraceId();this._logger.info(m_.L_CALLPLUS_CLIENT_DELETE_ALL_CALL_RECORDS_FROM_SERVER_T,"",e);const{code:t}=yield this._callEngine.removeAllCallLog(e);return t!==T_.SUCCESS?(this._logger.error(m_.L_CALLPLUS_CLIENT_DELETE_ALL_CALL_RECORDS_FROM_SERVER_R,`signal error code: ${t}`,e),{code:t}):(this._logger.info(m_.L_CALLPLUS_CLIENT_DELETE_ALL_CALL_RECORDS_FROM_SERVER_R,"success",e),{code:T_.SUCCESS})})}startCamera(){return I(this,void 0,void 0,function*(){var e;const t=this._logger.createTraceId();this._logger.info(m_.L_CALLPLUS_CLIENT_START_CAMERA_T,"",t);const{code:i,track:r}=yield this._rtcModule.getCameraVideoTrack(t);if(i!==T_.SUCCESS)return this._logger.error(m_.L_CALLPLUS_CLIENT_START_CAMERA_R,`create video track error code: ${i}`,t),{code:i};if(!(null==r?void 0:r.isPublished())&&(null===(e=this._callEngine.getLocalMainSession())||void 0===e?void 0:e.getState())===v_.ONCALL){const{code:e}=yield this._rtcModule.publishVideoTrack();return e!==ue.SUCCESS?(this._logger.error(m_.L_CALLPLUS_CLIENT_START_CAMERA_R,`publish error code: ${e}`,t),{code:e}):(this._logger.info(m_.L_CALLPLUS_CLIENT_START_CAMERA_R,"success",t),{code:T_.SUCCESS})}const{code:n}=yield this._rtcModule.enableVideoTrack(t);return n!==ue.SUCCESS&&n!==T_.SUCCESS?(this._logger.error(m_.L_CALLPLUS_CLIENT_START_CAMERA_R,`signal error code: ${n}`,t),{code:n}):(this._logger.info(m_.L_CALLPLUS_CLIENT_START_CAMERA_R,"success",t),{code:T_.SUCCESS})})}stopCamera(){return I(this,void 0,void 0,function*(){const e=this._logger.createTraceId();this._logger.info(m_.L_CALLPLUS_CLIENT_STOP_CAMERA_T,"",e);const{code:t,track:i}=yield this._rtcModule.disableVideoTrack();return t!==T_.SUCCESS&&t!==ue.SUCCESS?(this._logger.error(m_.L_CALLPLUS_CLIENT_STOP_CAMERA_R,`error code: ${t}`,e),{code:t}):(this._rtcModule.destroyTrack(i),this._logger.info(m_.L_CALLPLUS_CLIENT_STOP_CAMERA_R,"success",e),{code:T_.SUCCESS})})}switchCamera(e){return I(this,void 0,void 0,function*(){const t=this._logger.createTraceId();if(this._logger.info(m_.L_CALLPLUS_CLIENT_SWITCH_CAMERA_T,`cameraId: ${e}`,t),!b(e))return this._logger.error(m_.L_CALLPLUS_CLIENT_SWITCH_CAMERA_R,`param error, cameraId: not empty string, value: ${e}`,t),{code:T_.PARAM_ERROR};const i=this._callEngine.getLocalMainSession();if(!i)return this._logger.error(m_.L_CALLPLUS_CLIENT_SWITCH_CAMERA_R,`errCode: ${T_.NOT_IN_CALL}`,t),{code:T_.NOT_IN_CALL};if(i.getMediaType()===I_.AUDIO)return this._logger.error(m_.L_CALLPLUS_CLIENT_SWITCH_CAMERA_R,`errCode: ${T_.NOT_VIDEO_CALL}`,t),{code:T_.NOT_VIDEO_CALL};this._videoConfig.cameraId=e,this._rtcModule.setVideoConfig(this._videoConfig);const{code:r}=yield this._rtcModule.changeVideoDevice(t);return r!==T_.SUCCESS?(this._logger.error(m_.L_CALLPLUS_CLIENT_SWITCH_CAMERA_R,`call client changeVideoDevice error code: ${r}`,t),{code:r}):(this._logger.info(m_.L_CALLPLUS_CLIENT_SWITCH_CAMERA_R,"success",t),{code:T_.SUCCESS})})}startMicrophone(){return I(this,void 0,void 0,function*(){const e=this._logger.createTraceId();this._logger.info(m_.L_CALLPLUS_CLIENT_START_MICROPHONE_T,"",e);const{code:t,track:i}=yield this._rtcModule.getMicrophoneAudioTrack(e);if(t!==T_.SUCCESS)return this._logger.error(m_.L_CALLPLUS_CLIENT_START_MICROPHONE_R,`create microphone audio track error code: ${t}`,e),{code:t};if(!i.isOwnerMuted())return this._logger.info(m_.L_CALLPLUS_CLIENT_START_MICROPHONE_R,"success",e),{code:T_.SUCCESS};const r=yield i.unmute();return r!==ue.SUCCESS?(this._logger.error(m_.L_CALLPLUS_CLIENT_START_MICROPHONE_R,`signal error code: ${t}`,e),{code:r}):(this._logger.info(m_.L_CALLPLUS_CLIENT_START_MICROPHONE_R,"success",e),{code:T_.SUCCESS})})}stopMicrophone(){return I(this,void 0,void 0,function*(){const e=this._logger.createTraceId();this._logger.info(m_.L_CALLPLUS_CLIENT_STOP_MICROPHONE_T,"",e);const{code:t}=yield this._rtcModule.disableAudioTrack();return t!==T_.SUCCESS&&t!==ue.SUCCESS?(this._logger.error(m_.L_CALLPLUS_CLIENT_STOP_MICROPHONE_R,`signal error code: ${t}`,e),{code:t}):(this._logger.info(m_.L_CALLPLUS_CLIENT_STOP_MICROPHONE_R,"success",e),{code:T_.SUCCESS})})}isMicrophoneEnabled(){const e=this._rtcModule.getLocalAudioTrack();return!!e&&!e.isOwnerMuted()}setAllRemoteAudioEnable(e){return I(this,void 0,void 0,function*(){const t=this._logger.createTraceId();return this._rtcModule.setAllRemoteAudioEnable(e,t)})}getVersion(){return"26.1.0"}getCameras(){return I(this,void 0,void 0,function*(){return xt()})}getMicrophones(){return I(this,void 0,void 0,function*(){return Bt()})}getSpeakers(){return I(this,void 0,void 0,function*(){return Vt()})}getRTCSessionId(){return this._rtcModule.getRTCSessionId()}switchMicrophone(e){return I(this,void 0,void 0,function*(){const t=this._logger.createTraceId();if(this._logger.info(m_.L_CALLPLUS_CLIENT_SWITCH_MICROPHONE_T,`microphoneId: ${e}`,t),!b(e))return this._logger.error(m_.L_CALLPLUS_CLIENT_SWITCH_MICROPHONE_R,`param error, microphoneId: not empty string, value: ${e}`,t),{code:T_.PARAM_ERROR};if(!this._callEngine.getLocalMainSession())return this._logger.error(m_.L_CALLPLUS_CLIENT_SWITCH_MICROPHONE_R,`errCode: ${T_.NOT_IN_CALL}`,t),{code:T_.NOT_IN_CALL};this._audioConfig.microphoneId=e,this._rtcModule.setAudioConfig(this._audioConfig);const{code:i}=yield this._rtcModule.changeAudioDevice(t);return i!==T_.SUCCESS?(this._logger.error(m_.L_CALLPLUS_CLIENT_SWITCH_MICROPHONE_R,`call client changeAudioDevice error code: ${i}`,t),{code:i}):(this._logger.info(m_.L_CALLPLUS_CLIENT_SWITCH_MICROPHONE_R,"success",t),{code:T_.SUCCESS})})}}class bc{constructor(e){Object.defineProperty(this,"_rc",{enumerable:!0,configurable:!0,writable:!0,value:e})}setDefaultMicrophoneId(e){return this._rc.setDefaultMicrophoneId(e),this}setBitrate(e,t){return this._rc.setBitrate(e,t),this}setSampleRate(e){return this._rc.setSampleRate(e),this}build(){return this._rc.build()}}class Ac{constructor(e){Object.defineProperty(this,"_rc",{enumerable:!0,configurable:!0,writable:!0,value:e})}setFrameRate(e){return this._rc.setFrameRate(e),this}setVideoResolution(e){return this._rc.setVideoResolution(e),this}setDefaultCameraId(e){return this._rc.setDefaultCameraId(e),this}setBitrate(e,t){return this._rc.setBitrate(e,t),this}build(){return this._rc.build()}}class yc{constructor(e){Object.defineProperty(this,"_rc",{enumerable:!0,configurable:!0,writable:!0,value:e})}setChannelIdHW(e){return this._rc.setChannelIdHW(e),this}setCategoryHW(e){return this._rc.setCategoryHW(e),this}setImportanceHW(e){return this._rc.setImportanceHW(e),this}setImageUrlHW(e){return this._rc.setImageUrlHW(e),this}setFcmChannelId(e){return this._rc.setFcmChannelId(e),this}setFcmCollapseKey(e){return this._rc.setFcmCollapseKey(e),this}setFcmImageUrl(e){return this._rc.setFcmImageUrl(e),this}build(){const e=this._rc.build();return{channelIdHW:e.channelIdHW,categoryHW:e.categoryHW,importanceHW:e.importanceHW,imageUrlHW:e.imageUrlHW,fcmChannelId:e.fcmChannelId,fcmCollapseKey:e.fcmCollapseKey,fcmImageUrl:e.fcmImageUrl}}}!function(e){e[e.AUDIO=0]="AUDIO",e[e.VIDEO=1]="VIDEO"}(Sc||(Sc={}));class Nc{constructor(e){Object.defineProperty(this,"_session",{enumerable:!0,configurable:!0,writable:!0,value:e})}getCallId(){return this._session.getCallId()}getCallState(){return this._session.getState()}getCallType(){return this._session.getCallType()}getMediaType(){return this._session.getMediaType()===I_.AUDIO?Sc.AUDIO:Sc.VIDEO}getParticipants(){return this._session.getUserList().map(e=>({userId:e.userId,userState:e.state,isCameraEnabled:e.cameraEnable,isMicrophoneEnabled:e.microphoneEnable}))}getCallerUserId(){return this._session.getCreatorUserId()}getInvitorUserId(){return this._session.getInviterUserId()}getStartTime(){return I(this,void 0,void 0,function*(){return this._session.getCreateTimestamp()})}getDuration(){return I(this,void 0,void 0,function*(){return this._session.getDuration()})}}function Pc(e){return{logOutputLevel:e.logOutputLevel,isPubTiny:e.isPubLowResolutionStream}}function Uc(e){const t=e.mediaType===I_.AUDIO?Sc.AUDIO:Sc.VIDEO;return{callId:e.callId,callType:e.callType,callDirection:e.callDirection,mediaType:t,callerUserId:e.callerUserId,participants:e.callUserIds,callState:e.sessionState,currentUserState:e.userState,startTime:e.startTimestamp,endTime:e.endTimestamp,duration:e.duration,syncTime:e.syncTimestamp,callEndReason:e.systemState,creationTime:e.createTimestamp}}function Dc(e){return e===Sc.AUDIO?I_.AUDIO:I_.AUDIO_VIDEO}function Mc(e){return e===I_.AUDIO?Sc.AUDIO:Sc.VIDEO}function wc(e,t,i){var r;const n={onReceivedCall:(t,i)=>e.onCallReceived(new Nc(t),i),onCallEnded:(t,i)=>e.onCallEnded(new Nc(t),i),onCallConnected:t=>e.onCallConnected(new Nc(t)),onReceivedCallPlusSummaryMessage:t=>{var r,n;const s=null!==(r=null==i?void 0:i())&&void 0!==r?r:"";null===(n=e.onLocalCallLogReceived)||void 0===n||n.call(e,function(e,t){const i=e.content,{messageDirection:r,sentTime:n}=e,{callId:s,callerUserId:o,targetId:a,callStartTime:l,callEndTime:_,mediaType:c,hangupReason:d}=i,u=_>0&&l>0?Math.max(0,Math.floor((_-l)/1e3)):0,h=1===r?fc.OUT:fc.IN,g=c===I_.AUDIO?Sc.AUDIO:Sc.VIDEO,p="number"==typeof n?n:0;return{callId:s,callType:R_.SINGLE,callDirection:h,mediaType:g,callerUserId:o,participants:[t,a].filter(Boolean),callState:v_.ENDED,currentUserState:L_.ENDED,startTime:l,endTime:_,duration:u,syncTime:p,callEndReason:d,creationTime:p}}(t,s))},onReceivedCallRecord:t=>{var i;return null===(i=e.onServerCallLogReceived)||void 0===i?void 0:i.call(e,Uc(t))},onReceivedChangeMediaTypeRequest:(t,i,r)=>{var n;return null===(n=e.onMediaTypeChangeRequestReceived)||void 0===n?void 0:n.call(e,t,i,Mc(r))},onReceivedChangeMediaTypeResult:t=>{var i;return null===(i=e.onMediaTypeChangeResultReceived)||void 0===i?void 0:i.call(e,{userId:t.userId,transactionId:t.transactionId,mediaType:Mc(t.mediaType),result:t.result})},onRemoteCameraStateChanged:e.onRemoteCameraStateChanged,onRemoteMicrophoneStateChanged:e.onRemoteMicrophoneStateChanged,onRemoteUserInvited:null!==(r=e.onRemoteUserInvited)&&void 0!==r?r:()=>{},onRemoteUserStateChanged:e.onRemoteUserStateChanged,onUserMediaAvailable:(t,i)=>{var r;return null===(r=e.onUserMediaAvailable)||void 0===r?void 0:r.call(e,t,Mc(i))},onReceivedCallStartTime:t=>{var i;return null===(i=e.onStartTimeReceived)||void 0===i?void 0:i.call(e,Object.assign(Object.assign({},t),{callType:t.callType}))}};return t&&(n.onUserAudioLevelChanged=t),n}r.add("nexconncall","26.1.0");const kc={tag:"NexconnCall",verify:()=>!!r.validEngine("26.1.0")||(console.error(`The current engine version '${r.getInfo().engine}' error, plugin-call-plus required engine version at least '26.1.0'.`),!1),setup:e=>S(e)};class xc{constructor(t,i){Object.defineProperty(this,"_client",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_callEventsListener",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_connectionQualityListener",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"rtcPluginContext",{enumerable:!0,configurable:!0,writable:!0,value:null}),this.rtcPluginContext=e(kc,void 0);const r=e(p_,void 0),n=Pc(i);this.rtcPluginContext.logger.setOutputLevel(i.logOutputLevel),this._client=new vc(t,n,this.rtcPluginContext,r)}static init(e){const t=Pc(e),i=(r=t)?y(r)?{isLegal:!0}:{isLegal:!1,msg:"Initialization options must be an object"}:{isLegal:!1,msg:"Initialization missing parameter -> options"};var r;if(!i.isLegal)throw new Error(`[CallPlusLib installer steup]${i.msg}`);return xc._instance||(xc._instance=new xc(se,e)),xc._instance}getCurrentRtcUserId(){var e,t;return null!==(t=null===(e=this.rtcPluginContext)||void 0===e?void 0:e.getCurrentId())&&void 0!==t?t:""}applyClientStatusReportListener(e){var t;this._client.setStatusReportListener((t=e,{onSendPacketLoss(){},onReceivePacketLoss(){},onSendQualityChanged(e){var i;null===(i=t.onSendQualityChanged)||void 0===i||i.call(t,e)},onReceiveQualityChanged(e){var i;null===(i=t.onReceiveQualityChanged)||void 0===i||i.call(t,e)}}))}applyClientCallPlusEventListener(e,t){const i=t?(e,i)=>{var r;return null===(r=t.onAudioVolumeChanged)||void 0===r?void 0:r.call(t,{[e]:i})}:void 0;this._client.setCallPlusEventListener(wc(e,i,()=>this.getCurrentRtcUserId()))}setCallEventsListener(e){this._callEventsListener=e,this.applyClientCallPlusEventListener(e,this._connectionQualityListener)}setConnectionQualityListener(e){this._connectionQualityListener=e,this.applyClientStatusReportListener(e),this._callEventsListener&&this.applyClientCallPlusEventListener(this._callEventsListener,e)}setVideoView(e){return this._client.setVideoView(e.map(({userId:e,videoElement:t,useTinyStream:i})=>({userId:e,videoElement:t,isTiny:i})))}removeVideoView(e){return this._client.removeVideoView(e)}playMedia(e,t){return this._client.playMedia(e,Dc(t))}createVideoConfigBuilder(){return new Ac(this._client.createVideoConfigBuilder())}setVideoConfig(e){return this._client.setVideoConfig(e)}createAudioConfigBuilder(){return new bc(this._client.createAudioConfigBuilder())}createAndroidPushConfigBuilder(){return new yc(this._client.createAndroidPushConfigBuilder())}setAudioConfig(e){return this._client.setAudioConfig(e)}startCall(e,t=R_.SINGLE,i=Sc.VIDEO,r,n,s){const o=Array.isArray(e)?e:[e];return this._client.startCall(o,t,Dc(i),r,n,s)}joinCall(e){return this._client.joinMultiCall(e)}inviteToCall(e,t,i){return this._client.invite(e,t,i).then(e=>{var t;return Object.assign(Object.assign({},e),{busyUsers:null===(t=e.busyUsers)||void 0===t?void 0:t.map(({userId:e,state:t})=>({userId:e,userState:t}))})})}acceptCall(e,t){return this._client.accept(e,t)}endCall(e,t){return this._client.hangup(e,t)}requestChangeMediaType(e){return this._client.requestChangeMediaType(Dc(e))}cancelChangeMediaType(e){return this._client.cancelChangeMediaType(e)}replyChangeMediaType(e,t){return this._client.replyChangeMediaType(e,t)}getCurrentCallSession(){const e=this._client.getCurrentCallSession();return e?new Nc(e):null}getOngoingCallLogs(){return this._client.getAvailableCallRecordsFromServer().then(e=>{var t;return Object.assign(Object.assign({},e),{records:null===(t=e.records)||void 0===t?void 0:t.map(Uc)})})}getHistoryCallLogs(e,t,i){return this._client.getCallRecords(e,t,null!=i?i:0).then(e=>e.result?Object.assign(Object.assign({},e),{result:{hasMore:e.result.hasMore,callLogList:e.result.list.map(Uc),syncTime:e.result.syncTime}}):e)}deleteCallLogsForMe(e){return this._client.deleteCallRecordsFromServer(e)}deleteAllCallLogsForMe(){return this._client.deleteAllCallRecordsFromServer()}enableCamera(e){return e?this._client.startCamera():this._client.stopCamera()}switchCamera(e){return this._client.switchCamera(e)}enableMicrophone(e){return e?this._client.startMicrophone():this._client.stopMicrophone()}getAudioInputDevices(){return this._client.getMicrophones()}selectAudioInputDevice(e){return this._client.switchMicrophone(e)}getAudioOutputDevices(){return this._client.getSpeakers()}selectAudioOutputDevice(e){return this._client.setAudioOutputDeviceId(e)}getVersion(){return this._client.getVersion()}getVideoInputDevices(){return this._client.getCameras()}isMicrophoneEnabled(){return this._client.isMicrophoneEnabled()}}Object.defineProperty(xc,"_instance",{enumerable:!0,configurable:!0,writable:!0,value:null});var Bc=Object.freeze({__proto__:null,NCCallEngine:xc,NCCallSession:Nc,NCAudioConfigBuilder:bc,NCVideoConfigBuilder:Ac,NCAndroidPushConfigBuilder:yc,NCCallCode:E_,get NCCallDirection(){return fc},get NCCallMediaTypeChangeResult(){return b_},get NCCallMediaType(){return Sc},get NCCallEndReason(){return A_},get NCCallState(){return v_},get NCCallType(){return R_},get NCCallUserState(){return L_},get NCCallVideoFrameRate(){return yt},get NCCallVideoResolution(){return Nt}});export{Bc as NC,yc as NCAndroidPushConfigBuilder,bc as NCAudioConfigBuilder,E_ as NCCallCode,fc as NCCallDirection,A_ as NCCallEndReason,xc as NCCallEngine,Sc as NCCallMediaType,b_ as NCCallMediaTypeChangeResult,Nc as NCCallSession,v_ as NCCallState,R_ as NCCallType,L_ as NCCallUserState,yt as NCCallVideoFrameRate,Nt as NCCallVideoResolution,Ac as NCVideoConfigBuilder};
|
|
1
|
+
import{__install__ as e}from"@nexconn/chat";import{ConversationType as t,RCConnectionStatus as i,VersionManage as r,SentStatus as n,MessageDirection as s,ReceivedStatus as o}from"@nexconn/engine";var a,l,_,c;!function(e){e[e.PRIVATE=1]="PRIVATE",e[e.GROUP=2]="GROUP",e[e.SYSTEM=3]="SYSTEM",e[e.CUSTOM=4]="CUSTOM",e[e.RTC_ROOM=7]="RTC_ROOM"}(a||(a={})),function(e){e[e.DISCONNECTED=0]="DISCONNECTED",e[e.CONNECTING=1]="CONNECTING",e[e.CONNECTED=2]="CONNECTED",e[e.SUSPENDED=3]="SUSPENDED"}(l||(l={})),function(e){e[e.Debug=0]="Debug",e[e.Info=1]="Info",e[e.Warn=2]="Warn",e[e.Error=3]="Error",e[e.STATISTICS=6]="STATISTICS"}(_||(_={})),function(e){e.RTC="RTC",e.CallPlus="CallPlus"}(c||(c={}));class d{constructor(e){Object.defineProperty(this,"_writer",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_traceId",{enumerable:!0,configurable:!0,writable:!0,value:0})}debug(e,t,i){this._writer.writeLog(_.Debug,e,null!=t?t:"",i)}info(e,t,i){this._writer.writeLog(_.Info,e,null!=t?t:"",i)}warn(e,t,i){this._writer.writeLog(_.Warn,e,null!=t?t:"",i)}error(e,t,i){this._writer.writeLog(_.Error,e,null!=t?t:"",i)}createTraceId(){return""+ ++this._traceId}setOutputLevel(e){this._writer.setOutputLevel(e)}__statistics(e,t,i){this._writer.writeLog(_.STATISTICS,e,null!=t?t:"",i)}}const u={toCommon:e=>e,toNative:e=>e},h={[t.PRIVATE]:a.PRIVATE,[t.GROUP]:a.GROUP,[t.SYSTEM]:a.SYSTEM,[t.CHATROOM]:a.CUSTOM,[t.APP_PUBLIC_SERVICE]:a.RTC_ROOM,[t.RTC_ROOM]:a.RTC_ROOM},g={[a.PRIVATE]:t.PRIVATE,[a.GROUP]:t.GROUP,[a.SYSTEM]:t.SYSTEM,[a.CUSTOM]:t.CHATROOM,[a.RTC_ROOM]:t.APP_PUBLIC_SERVICE},p={toCommon(e){var t;return null!==(t=h[e])&&void 0!==t?t:e},toNative(e){var t;return null!==(t=g[e])&&void 0!==t?t:e}},f={[i.CONNECTED]:l.CONNECTED,[i.CONNECTING]:l.CONNECTING,[i.DISCONNECTED]:l.DISCONNECTED,[i.SUSPENDED]:l.SUSPENDED},E={[l.DISCONNECTED]:i.DISCONNECTED,[l.CONNECTING]:i.CONNECTING,[l.CONNECTED]:i.CONNECTED,[l.SUSPENDED]:i.SUSPENDED},I={toNative:e=>Object.assign({},e)},T={errorCode:u,conversationType:p,connectionStatus:{toCommon(e){var t;return null!==(t=f[e])&&void 0!==t?t:e},toNative(e){var t;return null!==(t=E[e])&&void 0!==t?t:e}},sendMsgOptions:I,receivedMessage:{toCommon:e=>e},naviInfo:{toCommon(e){var t,i,r;return{voipCallInfo:null!==(t=e.voipCallInfo)&&void 0!==t?t:void 0,rtcAISwitch:e.rtcAISwitch,jwtToken:null!==(i=e.jwtToken)&&void 0!==i?i:e.jwt,logServer:e.logServer,dataCenter:null!==(r=e.dataCenter)&&void 0!==r?r:e.dc,openGzip:e.openGzip,ipType:e.ipType}}}};function m(e,t,i,r){return new(i||(i=Promise))((function(n,s){function o(e){try{l(r.next(e))}catch(e){s(e)}}function a(e){try{l(r.throw(e))}catch(e){s(e)}}function l(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((r=r.apply(e,t||[])).next())}))}function R(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)}function S(e){const t={logger:(c.RTC,i=e.createLogger("NCCall","RTC"),new d({writeLog(e,t,r,n){switch(e){case _.Debug:i.debug(t,r,n);break;case _.Info:i.info(t,r,n);break;case _.Warn:i.warn(t,r,n);break;case _.Error:i.error(t,r,n);break;case _.STATISTICS:i.__statistics(t,r,n);break;default:i.info(t,r,n)}},setOutputLevel(e){i.setOutputLevel(e)}})),rtcSignaling(t,i,r,n){return m(this,void 0,void 0,(function*(){const s=yield e.rtcSignaling(t,i,r,n);return{code:T.errorCode.toCommon(null==s?void 0:s.code),buffer:null==s?void 0:s.buffer}}))},registerRTCSignalListener(t){e.registerRTCSignalListener(t)},sendGroupCallSignalInfo(t,i,r){return m(this,void 0,void 0,(function*(){const n=yield e.setCallInfo(t,i,r);return{code:T.errorCode.toCommon(n.code),data:n.data}}))},registerGroupCallSignalInfoListener(t){e.onCallInfo=e=>{t(e)}},setOnnavidatachange(t){const i=t?e=>{const i=T.naviInfo.toCommon(e);t(i)}:void 0;e.onnavidatachange=i},refetchNaviInfo:e.refetchNaviInfo?()=>m(this,void 0,void 0,(function*(){yield e.refetchNaviInfo()})):void 0,registerConnectionStateChangeListener(t){e.onconnectionstatechange=(e,i)=>{t(T.connectionStatus.toCommon(e),T.errorCode.toCommon(null!=i?i:0))}},registerDisconnectListener(t){e.ondisconnect=t},registerDestroyListener(t){e.ondestroy=t},registerMessageListener(t){const i=t?e=>t(T.receivedMessage.toCommon(e)):void 0;e.onmessage=i},sendMessage(t,i,r){return m(this,void 0,void 0,(function*(){const n=T.conversationType.toNative(t),s=T.sendMsgOptions.toNative(r),o=yield e.sendMessage(n,i,s);return{code:T.errorCode.toCommon(o.code),data:void 0!==o.data?T.receivedMessage.toCommon(o.data):void 0}}))},getCurrentId:()=>e.getCurrentId(),getNaviInfo(){const t=e.getNaviInfo();return null!=t?T.naviInfo.toCommon(t):null},getConnectionStatus:()=>T.connectionStatus.toCommon(e.getConnectionStatus()),getAppkey:()=>e.getAppkey(),getCoreVersion:()=>e.getCoreVersion(),registerMessageType(t,i,r,n){e.registerMessageType(t,i,r,n)}};var i;return e.rtcPingResVersion&&(t.rtcPingResVersion=(t,i,r)=>m(this,void 0,void 0,(function*(){const n=yield e.rtcPingResVersion(t,i,r);return{code:T.errorCode.toCommon(n.code),data:n.data}}))),t}"function"==typeof SuppressedError&&SuppressedError;const C=e=>"string"==typeof e,L=e=>"boolean"==typeof e,O=e=>"number"==typeof e&&!Number.isNaN(e),v=e=>-1!==Object.prototype.toString.call(e).indexOf("Array"),b=e=>C(e)&&e.length>0,A=e=>v(e)&&e.length>0,N=e=>"[object Object]"===Object.prototype.toString.call(e),y=e=>"function"==typeof e,P=e=>void 0===e||"[object Undefined]"===Object.prototype.toString.call(e),U=e=>C(e)&&/https?:\/\//.test(e);var D;!function(e){e[e.STRING=0]="STRING",e[e.ONLY_STRING=1]="ONLY_STRING",e[e.NUMBER=2]="NUMBER",e[e.BOOLEAN=3]="BOOLEAN",e[e.OBJECT=4]="OBJECT",e[e.ARRAY=5]="ARRAY",e[e.CALLBACK=6]="CALLBACK"}(D||(D={}));const M={[D.STRING]:b,[D.ONLY_STRING]:C,[D.NUMBER]:O,[D.BOOLEAN]:e=>"boolean"==typeof e,[D.OBJECT]:N,[D.ARRAY]:v,[D.CALLBACK]:e=>{let t=!0;return N(e)||(t=!1),(e=e||{}).onSuccess&&!y(e.onSuccess)&&(t=!1),e.onError&&!y(e.onError)&&(t=!1),t}};class w extends Error{constructor(e){super(e),this.name="RCAssertError"}}const k=(e,t,i,r=!1)=>{if(!x(e,t,i,r))throw new w(`'${e}' is invalid: ${JSON.stringify(t)}`)},x=(e,t,i,r=!1)=>{i=M[i]||i;const n=r?i(t):P(t)||null==t||i(t);return n||null===console||void 0===console||console.error(`'${e}' is invalid: ${JSON.stringify(t)}`),n};class B{constructor(){Object.defineProperty(this,"_map",{enumerable:!0,configurable:!0,writable:!0,value:{}})}on(e,t,i){const r=this._map[e]||(this._map[e]=[]);r.some((e=>e.listener===t&&e.target===i))||r.push({listener:t,target:i})}once(e,t,i){const r=this._map[e]||(this._map[e]=[]);r.some((e=>e.listener===t&&e.target===i))||r.push({listener:t,target:i,once:!0})}off(e,t,i){let r=this._map[e];r&&(r=r.filter((e=>e.listener!==t||e.target!==i)),r.length?this._map[e]=r:delete this._map[e])}emit(e,...t){const i=this._map[e];if(i)for(let e=0;e<i.length;e+=1){const{target:r,once:n,listener:s}=i[e];n&&(i.splice(e,1),e-=1);try{s.call(r,...t)}catch(e){null===console||void 0===console||console.error(e)}}}removeAll(e){delete this._map[e]}clear(){Object.keys(this._map).forEach(this.removeAll,this)}}var V,G,F;!function(e){e.GET="GET",e.POST="POST",e.PUT="PUT"}(V||(V={})),function(e){e.WIFI="wifi",e.FOUR_G="4g",e.THREE_G="3g",e.TWO_G="2g",e.FIVE_G="2g",e.THREE_GENT="3gnet",e.UNKONWN="unknown"}(G||(G={})),function(e){e[e.RMTP=1]="RMTP",e[e.TLS=2]="TLS",e[e.RPP=3]="RPP",e[e.QUIC=4]="QUIC",e[e.WS=5]="WS",e[e.WSS=6]="WSS",e[e.HTTP=11]="HTTP",e[e.HTTPS=12]="HTTPS"}(F||(F={}));const j=(e,t,i)=>{const r=null==i?void 0:i.isReverse;N(e)&&(()=>{for(const i in e)t(e[i],i,e)})(),(v(e)||C(e))&&(()=>{if(r)for(let i=e.length-1;i>=0;i--)t(e[i],i);else for(let i=0,r=e.length;i<r;i++)t(e[i],i)})()};var H;!function(e){e[e.RTC=0]="RTC",e[e.LIVE=2]="LIVE",e[e.SIP=4]="SIP",e[e.CALL=5]="CALL",e[e.MEETING=6]="MEETING",e[e.CROSS_MUTI=7]="CROSS_MUTI",e[e.CROSS_LIVE=8]="CROSS_LIVE"}(H||(H={}));const J={gen:()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(e=>{const t=Math.floor(36*Math.random());return("x"===e?t:3&t|8).toString(36)})),genWithLen(e=22){const t=Date.now(),i=t.toString(36),r=Math.floor(Math.random()*t).toString(36),n=e-i.length-r.length;var s;return[r,i,n>0?(s=n,Array.from({length:s}).map((()=>Math.floor(36*Math.random()).toString(36))).join("")):""].join("").slice(0,e)}};class ${constructor(e,t){Object.defineProperty(this,"_promise",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_resolve",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_onCancel",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._promise=new Promise((t=>{this._resolve=t,e(this._onResolve.bind(this))})),this._onCancel=t}_onResolve(e){this._resolve(e)}result(){return this._promise}abort(){this._onCancel(this._onResolve.bind(this))}}function K(e){const t=e.method||V.GET,i=e.timeout||6e4,{headers:r,query:n,body:s,onProgress:o}=e,a=((e,t)=>{if(e=e.replace(/\?$/,""),!t)return e;const i=Object.keys(t).map((e=>`${e}=${t[e]}`)).filter((e=>!!e));return i.length?[e,i.join("&")].join("?"):e})(e.url,n),l=new XMLHttpRequest;if(l.open(t,a),r&&l.setRequestHeader)for(const e in r)l.setRequestHeader(e,r[e]);return function(e,t,i,r){return new $((n=>{e.onreadystatechange=()=>{4===e.readyState&&n({data:e.responseText,status:e.status,xhr:e})},e.onerror=()=>{n({status:e.status})},r&&(e.upload.onprogress=e=>r(e)),0!==t&&setTimeout((()=>{e.abort(),n({status:e.status})}),t),e.send(i)}),(t=>{e.abort(),t({status:-1})}))}(l,i,s,o)}class Y{constructor(e,t,i){Object.defineProperty(this,"isOk",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"msg",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.isOk=0===e,this.code=e,this.msg=t,this.data=i}next(e){return m(this,void 0,void 0,(function*(){return this.isOk?e(this.data):this.wipe()}))}or(e){return m(this,void 0,void 0,(function*(){return this.isOk?this:e(this.code)}))}orSync(e){return this.isOk?this:e(this.code)}trans(e){return this.isOk?q(e(this.data)):this.wipe()}tryTrans(e){return this.isOk?e(this.data):this.wipe()}errmsg(){return JSON.stringify({code:this.code,msg:this.msg})}wipe(){return this.isOk?q(void 0,this.msg):W(this.code,this.msg)}}const q=(e,t)=>new Y(0,t||"success",e),W=(e,t,i)=>new Y(e,t||`fail: ${e}`,i);var z,Q,Z;class X{constructor(e){z.add(this),Q.set(this,void 0),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),function(e,t,i,r,n){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");"a"===r?n.call(e,i):n?n.value=i:t.set(e,i)}(this,Q,e,"f"),this._logger=e.logger}open(e){return m(this,void 0,void 0,(function*(){return e=e.sort(((e,t)=>t.weight-e.weight)),R(this,z,"m",Z).call(this,e,R(this,Q,"f"))}))}}Q=new WeakMap,z=new WeakSet,Z=function e(t,i){return m(this,void 0,void 0,(function*(){if(0===t.length)return W(39005,"All addrs failed");const r=t.shift();let n=function(e,t){var i;if(!e)return"";const r="undefined"!=typeof window&&"https:"===(null===(i=null===window||void 0===window?void 0:window.location)||void 0===i?void 0:i.protocol);return/^https?:\/\//.test(e)?r?e.replace(/^https?:\/\//i,"https://"):e:t!==F.HTTP||r?`https://${e}`:`http://${e}`}(r.addr,r.protocol);n=`${n}/v3/message/get_stream.json?sdkVersion=26.2.0-alpha.2&platform=Websocket&messageUID=${i.msgUId}`,this._logger.info("L-req_stream_msg_content-O",`try open -> ${n}`);const s=yield this._openHandler(n,i);return s.or((r=>m(this,void 0,void 0,(function*(){return-1===r?R(this,z,"m",e).call(this,t,i):s}))))}))};class ee extends X{_openHandler(e,t){return m(this,void 0,void 0,(function*(){const{resolve:i,promise:r}=(()=>{let e,t=new Promise((t=>{e=t}));return{resolve:e,promise:t}})(),n=new XMLHttpRequest;return n.open("GET",e,!0),n.timeout=t.timeout,n.ontimeout=()=>{this._logger.warn("L-req_stream_msg_content-E",`timeout -> ${e}`),i(W(-1,"timeout"))},n.onreadystatechange=r=>{if(n.readyState!==XMLHttpRequest.HEADERS_RECEIVED)return;const s=n.getResponseHeader("Content-Type"),o=null==s?void 0:s.startsWith("text/event-stream");if(200!==n.status||!o)return void(n.onloadend=()=>{const e=JSON.parse(n.response);i(W(e.code,e.message))});i(q());let a=0;n.onprogress=e=>{const i=n.response.slice(a);a=n.response.length,t.onRawContent(i)},n.onerror=i=>{this._logger.warn("L-req_stream_msg_content-E",`network error in transit -> ${e}`),n.onprogress=null,n.abort(),t.onNetworkError(39005)}},n.onerror=t=>{this._logger.warn("L-req_stream_msg_content-E",`req fail -> ${e}`),i(W(-1))},n.setRequestHeader("Content-Type","application/json;charset=UTF-8"),n.setRequestHeader("App-Key",t.appkey),n.setRequestHeader("Authorization",`Bearer ${t.token}`),n.send(),r}))}}const te=!("undefined"==typeof uni||!(e=>{const t=["request","getSystemInfo"];for(let i=0,r=t.length;i<r;i++)if(!e[t[i]])return!1;return!0})(uni));let ie=null;const re=e=>m(void 0,void 0,void 0,(function*(){const t=yield ne.getNetworkType();ie({status:"online"===e.type,type:t})}));const ne={tag:"browser",httpReq:e=>K(e).result(),localStorage:null===window||void 0===window?void 0:window.localStorage,sessionStorage:null===window||void 0===window?void 0:window.sessionStorage,useNavi:!0,connectPlatform:"",isFromUniapp:te,createWebSocket:function(e,t){const i=new WebSocket(e,t);return i.binaryType="arraybuffer",Promise.resolve(q({id:Date.now(),onClose(e){i.onclose=t=>{const{code:i,reason:r}=t;e(i,r)}},onError(e){i.onerror=e},onMessage(e){i.onmessage=t=>{e(t.data)}},onOpen(e){i.onopen=e},send(e){i.send(e)},close(e,t){i.close()}}))},getNetworkType(){const{type:e,effectiveType:t}=navigator.connection||navigator.mozConnection||navigator.webkitConnection||{effectiveType:G.UNKONWN},i=e||t||G.UNKONWN;return Promise.resolve(i)},setNetworkStatusListener:function(e){ie=e,"undefined"!=typeof window&&window&&(window.addEventListener("offline",re),window.addEventListener("online",re))},removeNetworkStatusListener:function(){"undefined"!=typeof window&&window&&(window.removeEventListener("offline",re),window.removeEventListener("online",re)),ie=null},createSSEClient:e=>q(new ee(e)),getApiVer:()=>{const{type:e,version:t}=ne.runtimeInfo;return`|${e}|${t}`},get runtimeInfo(){const{userAgent:e}=navigator;let t,i;const r={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(const n in r){if(!r.hasOwnProperty(n))continue;let s=e.match(r[n]);if(s){i=n,t=s[1]||s[2];break}}return{type:i||"Unknown",version:t||"Unknown"}}},se=ne,oe={SUCCESS:0,ACTIVE_DISCONNECT:2,RC_CONN_REDIRECTED:31006,RC_DISCONN_KICK:31010,TIMEOUT:-1,RC_NET_CHANNEL_INVALID:30001,RC_NET_UNAVAILABLE:30002,RC_MSG_RESP_TIMEOUT:30003};var ae,le,_e;!function(e){e[e.SUCCESS=1e4]="SUCCESS",e[e.PB_ERROR=40001]="PB_ERROR",e[e.SIGNAL_DISCONNECTED=5e4]="SIGNAL_DISCONNECTED",e[e.PARAMS_ERROR=50001]="PARAMS_ERROR",e[e.REPERT_JOIN_ROOM=50002]="REPERT_JOIN_ROOM",e[e.NOT_IN_ROOM=50003]="NOT_IN_ROOM",e[e.SERVICE_INVALID=50004]="SERVICE_INVALID",e[e.RTC_TOKEN_INVALID=50006]="RTC_TOKEN_INVALID",e[e.ASR_NOT_AVAILABLE=50034]="ASR_NOT_AVAILABLE",e[e.ASR_NOT_START=50035]="ASR_NOT_START",e[e.SIGNAL_ERROR=53001]="SIGNAL_ERROR",e[e.CREATE_OFFER_FAILED=53003]="CREATE_OFFER_FAILED",e[e.REQUEST_FAILED=53004]="REQUEST_FAILED",e[e.MCU_SERVER_NOT_FOUND=53005]="MCU_SERVER_NOT_FOUND",e[e.BROADCAST_SUB_LIST_NOT_EMPTY=53007]="BROADCAST_SUB_LIST_NOT_EMPTY",e[e.ROOM_HAS_BEEN_DESTROYED=53008]="ROOM_HAS_BEEN_DESTROYED",e[e.NOT_OPEN_VIDEO_AUDIO_SERVER=53009]="NOT_OPEN_VIDEO_AUDIO_SERVER",e[e.GET_USER_MEDIA_FAILED=53010]="GET_USER_MEDIA_FAILED",e[e.GET_DISPLAY_MEDIA_FAILED=53011]="GET_DISPLAY_MEDIA_FAILED",e[e.BROWSER_PERMISSION_DENIED=53012]="BROWSER_PERMISSION_DENIED",e[e.CREATE_CUSTOM_TRACK_FAILED=53013]="CREATE_CUSTOM_TRACK_FAILED",e[e.INVALID_TAGS=53014]="INVALID_TAGS",e[e.INVALID_USER_ID=53015]="INVALID_USER_ID",e[e.CREATE_FILE_TRACK_FAILED=53016]="CREATE_FILE_TRACK_FAILED",e[e.INVALID_FILE_INSTANCE=53017]="INVALID_FILE_INSTANCE",e[e.SET_REMOTE_DESCRIPTION_FAILED=53018]="SET_REMOTE_DESCRIPTION_FAILED",e[e.BROWSER_NOT_SUPPORT=53019]="BROWSER_NOT_SUPPORT",e[e.TRACK_NOT_READY=53020]="TRACK_NOT_READY",e[e.VIDEO_TRACK_MISS_MEDIA_ELEMENT=53021]="VIDEO_TRACK_MISS_MEDIA_ELEMENT",e[e.TRACK_PLAY_ERROR=53022]="TRACK_PLAY_ERROR",e[e.SIGNAL_AUDIENCE_JOIN_ROOM_FAILED=53023]="SIGNAL_AUDIENCE_JOIN_ROOM_FAILED",e[e.SIGNAL_ROOM_CHANGE_IDENTITY_FAILED=53024]="SIGNAL_ROOM_CHANGE_IDENTITY_FAILED",e[e.PACKAGE_ENVIRONMENT_ERROR=53025]="PACKAGE_ENVIRONMENT_ERROR",e[e.PUBLISH_TRACK_LIMIT_EXCEEDED=53026]="PUBLISH_TRACK_LIMIT_EXCEEDED",e[e.CDN_RESOURCE_IS_EMPTY=53027]="CDN_RESOURCE_IS_EMPTY",e[e.SIGNAL_JOIN_RTC_ROOM_REFUSED=53028]="SIGNAL_JOIN_RTC_ROOM_REFUSED",e[e.NO_PERMISSION_TO_USE_REQUESTED_DEVICE=53029]="NO_PERMISSION_TO_USE_REQUESTED_DEVICE",e[e.THE_FUNCTION_IS_DISABLED_IN_PKROOM=53030]="THE_FUNCTION_IS_DISABLED_IN_PKROOM",e[e.SOME_TRACKS_PUBLISH_FAILED=53031]="SOME_TRACKS_PUBLISH_FAILED",e[e.MAC_IN_ELECTRON_NOT_SUPPORT_SCREEN_SHARE_WITH_AUDIO=53032]="MAC_IN_ELECTRON_NOT_SUPPORT_SCREEN_SHARE_WITH_AUDIO",e[e.JWT_TIME_OUT=1004]="JWT_TIME_OUT",e[e.SYSTEM_PERMISSION_DENIED=53033]="SYSTEM_PERMISSION_DENIED",e[e.PUBLISH_TRACKS_IS_INVALID=53034]="PUBLISH_TRACKS_IS_INVALID",e[e.TRACK_READYSTATE_IS_ENDED=53035]="TRACK_READYSTATE_IS_ENDED",e[e.APPLY_3A_NOISE_WORKLET_BEFORE_PUBLISH=53036]="APPLY_3A_NOISE_WORKLET_BEFORE_PUBLISH",e[e.LOAD_3A_MODULE_FAILED=53037]="LOAD_3A_MODULE_FAILED"}(ae||(ae={})),function(e){e.L_INDEX_INSTALL_RTC_PLUGIN_O="L-index_install_rtc_plugin-O",e.L_RTC_CLIENT_IM_CONNECTION_STATE_S="L-rtc_client_im_connection_state-S",e.L_RTC_CLIENT_MESSAGE_O="L-rtc_client_message-O",e.L_RTC_CLIENT_DESTROY_S="L-rtc_client_destroy-S",e.L_RTC_CLIENT_JOIN_RTC_ROOM_T="L-rtc_client_join_rtc_room-T",e.L_RTC_CLIENT_JOIN_RTC_ROOM_O="L-rtc_client_join_rtc_room-O",e.L_RTC_CLIENT_JOIN_RTC_ROOM_R="L-rtc_client_join_rtc_room-R",e.L_RTC_CLIENT_JOIN_LIVING_ROOM_T="L-rtc_client_join_living_room-T",e.L_RTC_CLIENT_JOIN_LIVING_ROOM_R="L-rtc_client_join_living_room-R",e.L_RTC_CLIENT_GET_AUDIENCE_CLIENT_O="L-rtc_client_get_audience_client-O",e.L_RTC_CLIENT_LEAVE_ROOM_T="L-rtc_client_leave_room-T",e.L_RTC_CLIENT_LEAVE_ROOM_R="L-rtc_client_leave_room-R",e.L_RTC_CLIENT_CREATE_MICROPHONE_AUDIO_TRACK_O="L-rtc_client_create_microphone_audio_track-O",e.L_RTC_CLIENT_CREATE_CAMERA_VIDEO_TRACK_O="L-rtc_client_create_camera_video_track-O",e.L_RTC_CLIENT_CREATE_MICROPHONE_AND_CAMERA_TRACKS_O="L-rtc_client_create_microphone_and_camera_tracks-O",e.L_RTC_CLIENT_CREATE_SCREEN_VIDEO_TRACK_O="L-rtc_client_create_screen_video_track-O",e.L_RTC_CLIENT_CREATE_SCREEN_VIDEO_AND_AUDIO_TRACKS_O="L-rtc_client_create_screen_video_and_audio_tracks-O",e.L_RTC_CLIENT_CREATE_LOCAL_AUDIO_TRACK_O="L-rtc_client_create_local_audio_track-O",e.L_RTC_CLIENT_CREATE_LOCAL_VIDEO_TRACK_O="L-rtc_client_create_local_video_track-O",e.L_RTC_CLIENT_CREATE_LOCAL_FILE_TRACKS_O="L-rtc_client_create_local_file_tracks-O",e.L_RTC_CLIENT_CREATE_LOCAL_TRACKS_O="L-rtc_client_create_local_tracks-O",e.L_RTC_CLIENT_APPLY_VIDEO_ASPECT_RATIO_O="L-rtc_client_apply_video_aspect_ratio-O",e.L_RTC_CLIENT_JOIN_LIVING_ROOM_AS_AUDIENCE_T="L-rtc_client_join_living_room_as_audience-T",e.L_RTC_CLIENT_JOIN_LIVING_ROOM_AS_AUDIENCE_R="L-rtc_client_join_living_room_as_audience_R",e.L_RTC_CLIENT_LEAVE_LIVING_ROOM_AS_AUDIENCE_T="L-rtc_client_leave_living_room_as_audience-T",e.L_RTC_CLIENT_LEAVE_LIVING_ROOM_AS_AUDIENCE_R="L-rtc_client_leave_living_room_as_audience-R",e.L_RTC_CLIENT_UPGRADE_TO_ANCHOR_ROOM_T="L-rtc_client_upgrade_to_anchor_room-T",e.L_RTC_CLIENT_UPGRADE_TO_ANCHOR_ROOM_R="L-rtc_client_upgrade_to_anchor_room-R",e.L_RTC_CLIENT_DOWNGRADE_TO_AUDIENCE_ROOM_T="L-rtc_client_downgrade_to_audience_room-T",e.L_RTC_CLIENT_DOWNGRADE_TO_AUDIENCE_ROOM_R="L-rtc_client_downgrade_to_audience_room-R",e.L_RTC_CLIENT_GET_JOINED_ROOM_INFO_T="L-rtc_client_get_joined_room_info-T",e.L_RTC_CLIENT_GET_JOINED_ROOM_INFO_R="L-rtc_client_get_joined_room_info-R",e.L_RTC_CLIENT_GENERATE_SUMMARIZATION_T="L-rtc_client_generate_summarization-T",e.L_RTC_CLIENT_GENERATE_SUMMARIZATION_R="L-rtc_client_generate_summarization-R",e.L_RTC_CLIENT_GET_ASR_CONTENT_T="L-rtc_client_get_asr_content-T",e.L_RTC_CLIENT_GET_ASR_CONTENT_R="L-rtc_client_get_asr_content-R",e.L_AUDIENCE_CLIENT_CALL_ONTRACKREADY_O="L-audinence_client_call_onTrackReady-O",e.L_AUDIENCE_CLIENT_SUBSCRIBE_T="L-audinence_client_subscribe-T",e.L_AUDIENCE_CLIENT_SUBSCRIBE_R="L-audinence_client_subscribe-R",e.L_AUDIENCE_CLIENT_UNSUBSCRIBE_T="L-audinence_client_unsubscribe-T",e.L_AUDIENCE_CLIENT_UNSUBSCRIBE_R="L-audinence_client_unsubscribe-R",e.L_PINGER_START_O="L-pinger_start-O",e.L_PINGER_STOP_O="L-pinger_stop-O",e.L_PINGER_SEND_RTCPING_E="L-pinger_send_rtcping-E",e.L_ABSTRACT_ROOM_SEND_MESSAGE_T="L-abstract_room_send_message-T",e.L_ABSTRACT_ROOM_SEND_MESSAGE_R="L-abstract_room_send_message-R",e.L_ABSTRACT_ROOM_SET_ROOM_ATTRIBUTE_T="L-abstract_room_set_room_attribute-T",e.L_ABSTRACT_ROOM_SET_ROOM_ATTRIBUTE_R="L-abstract_room_set_room_attribute_R",e.L_ABSTRACT_ROOM_DELETE_ROOM_ATTRIBUTE_T="L-abstract_room_delete_room_attribute_T",e.L_ABSTRACT_ROOM_DELETE_ROOM_ATTRIBUTE_R="L-abstract_room_delete_room_attribute_R",e.L_ABSTRACT_ROOM_GET_ROOM_ATTRIBUTE_T="L-abstract_room_get_room_attribute_T",e.L_ABSTRACT_ROOM_GET_ROOM_ATTRIBUTE_R="L-abstract_room_get_room_attribute_R",e.L_ABSTRACT_ROOM_PUBLISH_T="L-abstract_room_publish-T",e.L_ABSTRACT_ROOM_PUBLISH_R="L-abstract_room_publish-R",e.L_ABSTRACT_ROOM_PUBLISH_E="L-abstract_room_publish-E",e.L_ABSTRACT_ROOM_UNPUBLISH_T="L-abstract_room_unpublish-T",e.L_ABSTRACT_ROOM_UNPUBLISH_R="L-abstract_room_unpublish-R",e.L_ABSTRACT_ROOM_UNPUBLISH_E="L-abstract_room_unpublish-E",e.L_ABSTRACT_ROOM_UNPUBLISH_P="L-abstract_room_unpublish-P",e.L_ABSTRACT_ROOM_SUBSCRIBE_T="L-abstract_room_subscribe-T",e.L_ABSTRACT_ROOM_SUBSCRIBE_R="L-abstract_room_subscribe-R",e.L_ABSTRACT_ROOM_SUBSCRIBE_E="L-abstract_room_subscribe-E",e.L_ABSTRACT_ROOM_UNSUBSCRIBE_T="L-abstract_room_unsubscribe-T",e.L_ABSTRACT_ROOM_UNSUBSCRIBE_R="L-abstract_room_unsubscribe-R",e.L_ABSTRACT_ROOM_UNSUBSCRIBE_E="L-abstract_room_unsubscribe-E",e.L_ABSTRACT_ROOM_SET_SRC_LANGUAGE_T="L-abstract_room_set_src_language-T",e.L_ABSTRACT_ROOM_SET_SRC_LANGUAGE_R="L-abstract_room_set_src_language-R",e.L_ABSTRACT_ROOM_OPERATE_ASR_STATUS_T="L-abstract_room_operate_asr_status-T",e.L_ABSTRACT_ROOM_OPERATE_ASR_STATUS_R="L-abstract_room_operate_asr_status-R",e.L_ABSTRACT_ROOM_SET_ENABLE_ASR_T="L-abstract_room_set_enable_asr-T",e.L_ABSTRACT_ROOM_SET_ENABLE_ASR_R="L-abstract_room_set_enable_asr-R",e.L_ABSTRACT_ROOM_OPERATE_REALTIME_TRANSLATION_T="L-abstract_room_operate_realtime_translation-T",e.L_ABSTRACT_ROOM_OPERATE_REALTIME_TRANSLATION_R="L-abstract_room_operate_realtime_translation-R",e.L_ABSTRACT_ROOM_OPERATE_SUMMARIZATION_T="L-abstract_room_operate_summarization-T",e.L_ABSTRACT_ROOM_OPERATE_SUMMARIZATION_R="L-abstract_room_operate_summarization-R",e.L_APP_CALL_UNSUBSCRIBE_O="L-app_call_unsubscribe-O",e.L_USER_LEFT_UNSUBSCRIBE_O="L-user_left_unsubscribe-O",e.L_RES_UNPUB_UNSUBSCRIBE_O="L-res_unpub_unsubscribe-O",e.L_ABSTRACT_ROOM_REGISTER_ROOM_EVENT_LISTENER_O="L-abstract_room_register_room_event_listener-O",e.L_ABSTRACT_ROOM_REGISTER_REPORT_LISTENER_O="L-abstract_room_register_report_listener-O",e.L_ABSTRACT_ROOM_AUDIO_LEVEL_O="L-abstract_room_audio_level-O",e.L_ABSTRACT_ROOM_IM_RECONNECTED_T="L-abstract_room_im_reconnected-T",e.L_ABSTRACT_ROOM_IM_RECONNECTED_R="L-abstract_room_im_reconnected-R",e.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O="L-abstract_room_call_app_listener-O",e.L_ABSTRACT_ROOM_SETBITRATE_O="L-abstract_room_setBitrate-O",e.L_ABSTRACT_ROOM_ONTRACKREADY_O="L-abstract_room_onTrackReady-O",e.L_ABSTRACT_ROOM_RECEIVE_MESSAGE_O="L-abstract_room_receive_message-O",e.L_ABSTRACT_ROOM_ONKICKOFF_O="L-abstract_room_onKickoff-O",e.L_LIVING_ROOM_RECONNECTED_T="L-living_room_reconnected-T",e.L_LIVING_ROOM_RECONNECTED_R="L-living_room_reconnected-R",e.L_LIVING_ROOM_ENABLE_INNER_CDN_T="L-living_room_enable_inner_cdn-T",e.L_LIVING_ROOM_ENABLE_INNER_CDN_R="L-living_room_enable_inner_cdn-R",e.L_LIVING_ROOM_SPREAD_CDN_INFO_T="L-living_room_spread_cdn_info-T",e.L_LIVING_ROOM_SPREAD_CDN_INFO_R="L-living_room_spread_cdn_info-R",e.L_LIVING_ROOM_SET_ROOM_CDN_INFO_T="L-living_room_set_room_cdn_info-T",e.L_LIVING_ROOM_SET_ROOM_CDN_INFO_R="L-living_room_set_room_cdn_info-R",e.L_LIVING_ROOM_JOINED_PK_ROOM_T="L-living_room_joined_pk_room-T",e.L_LIVING_ROOM_JOINED_PK_ROOM_R="L-living_room_joined_pk_room-R",e.L_LIVING_ROOM_LEAVE_PK_ROOM_T="L-living_room_leave_pk_room-T",e.L_LIVING_ROOM_LEAVE_PK_ROOM_R="L-living_room_leave_pk_room-R",e.L_APP_CALL_LEAVE_PK_ROOM_O="L-app_call_leave_pk_room-O",e.L_QUIT_PK_LEAVE_PK_ROOM_O="L-quit_pk_leave_pk_room-O",e.L_LIVING_ROOM_GET_ROOM_PK_HANDLER_O="L-living_room_get_room_pk_handler-O",e.L_LIVING_ROOM_GET_MCU_CONFIG_BUILDER_O="L-living_room_get_mcu_config_builder-O",e.L_LIVING_ROOM_QUIT_ALL_PK_ROOM_O="L-living_room_quit_all_pk_room-O",e.L_LIVING_PK_HANDLER_REGISTER_ROOM_PK_EVENT_LISTENER_O="L-living_pk_handler_register_room_pk_event_listener-O",e.L_LIVING_PK_HANDLER_CALL_APP_LISTENER_O="L-living_pk_handler_call_app_listener-O",e.L_LIVING_PK_HANDLER_REQUEST_JOIN_OTHER_ROOM_T="L-living_pk_handler_request_join_other_room-T",e.L_LIVING_PK_HANDLER_REQUEST_JOIN_OTHER_ROOM_R="L-living_pk_handler_request_join_other_room-R",e.L_LIVING_PK_HANDLER_CANCEL_REQUEST_JOIN_OTHER_ROOM_T="L-living_pk_handler_cancel_request_join_other_room-T",e.L_LIVING_PK_HANDLER_CANCEL_REQUEST_JOIN_OTHER_ROOM_R="L-living_pk_handler_cancel_request_join_other_room-R",e.L_LIVING_PK_HANDLER_RESPONSE_JOIN_OTHER_ROOM_T="L-living_pk_handler_response_join_other_room-T",e.L_LIVING_PK_HANDLER_RESPONSE_JOIN_OTHER_ROOM_R="L-living_pk_handler_response_join_other_room-R",e.L_LIVING_PK_HANDLER_JOIN_OTHER_ROOM_T="L-living_pk_handler_join_other_room-T",e.L_LIVING_PK_HANDLER_JOIN_OTHER_ROOM_R="L-living_pk_handler_join_other_room-R",e.L_LIVING_PK_HANDLER_LEAVE_OTHER_ROOM_T="L-living_pk_handler_leave_other_room-T",e.L_LIVING_PK_HANDLER_LEAVE_OTHER_ROOM_R="L-living_pk_handler_leave_other_room-R",e.L_QUIT_PK_T="L-quit_pk-T",e.L_QUIT_PK_R="L-quit_pk-R",e.L_EXCHANGE_WITH_PUSHOTHERROOM_T="L-exchange_with_pushotherroom-T",e.L_EXCHANGE_WITH_PUSHOTHERROOM_R="L-exchange_with_pushotherroom-R",e.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O="L-audience_living_room_call_app_listener-O",e.L_AUDIENCE_LIVING_ROOM_PULL_KVENTRIES_O="L-audience_living_room_pull_kvEntries-O",e.L_AUDIENCE_LIVING_ROOM_PULL_KVENTRIES_T="L_AUDIENCE_LIVING_ROOM_PULL_KVENTRIES_T",e.L_AUDIENCE_LIVING_ROOM_PULL_KVENTRIES_R="L_AUDIENCE_LIVING_ROOM_PULL_KVENTRIES_R",e.L_AUDIENCE_LIVING_ROOM_SINGAL_DATA_CHANGE_P="L-audience_living_room_singal_data_change-P",e.L_AUDIENCE_LIVING_ROOM_GET_CDN_PLAY_URL_T="L-audience_living_room_get_cdn_play_url-T",e.L_AUDIENCE_LIVING_ROOM_GET_CDN_PLAY_URL_R="L-audience_living_room_get_cdn_play_url-R",e.L_AUDIENCE_LIVING_ROOM_SUBSCRIBE_T="L-audience_living_room_subscribe-T",e.L_AUDIENCE_LIVING_ROOM_SUBSCRIBE_R="L-audience_living_room_subscribe-R",e.L_AUDIENCE_LIVING_ROOM_UNSUBSCRIBE_T="L-audience_living_room_unsubscribe-T",e.L_AUDIENCE_LIVING_ROOM_UNSUBSCRIBE_R="L-audience_living_room_unsubscribe-R",e.L_AUDIENCE_LIVING_ROOM_UPDATE_SUBSCRIBELIST_T="L-audience_living_room_update_subscribeList-T",e.L_AUDIENCE_LIVING_ROOM_UPDATE_SUBSCRIBELIST_R="L-audience_living_room_update_subscribeList-R",e.L_AUDIENCE_LIVING_ROOM_ONTRACKREADY_O="L-audience_living_room_onTrackReady-O",e.L_AUDIENCE_LIVING_ROOM_IM_RECONNECTED_R="L-audience_living_room_im_reconnected-R",e.L_AUDIENCE_LIVING_ROOM_IM_RECONNECTED_T="L-audience_living_room_im_reconnected-T",e.L_MCU_CONFIG_BUILDER_SET_HOST_VIDEO_TRACK_O="L-mcu_config_builder_set_host_video_track-O",e.L_MCU_CONFIG_BUILDER_SET_MIX_LAYOUT_MODE_O="L-mcu_config_builder_set_mix_layout_mode-O",e.L_MCU_CONFIG_BUILDER_SET_OUTPUT_VIDEO_RESOLUTION_O="L-mcu_config_builder_set_output_video_resolution-O",e.L_MCU_CONFIG_BUILDER_SET_OUTPUT_VIDEO_FPS_O="L-mcu_config_builder_set_output_video_fps-O",e.L_MCU_CONFIG_BUILDER_SET_OUTPUT_VIDEO_BITRATE_O="L-mcu_config_builder_set_output_video_bitrate-O",e.L_MCU_CONFIG_BUILDER_SET_OUTPUT_TINY_VIDEO_RESOLUTION_O="L-mcu_config_builder_set_output_tiny_video_resolution-O",e.L_MCU_CONFIG_BUILDER_SET_OUTPUT_TINY_VIDEO_FPS_O="L-mcu_config_builder_set_output_tiny_video_fps-O",e.L_MCU_CONFIG_BUILDER_SET_OUTPUT_TINY_VIDEO_BITRATE_O="L-mcu_config_builder_set_output_tiny_video_bitrate-O",e.L_MCU_CONFIG_BUILDER_SET_OUTPUT_VIDEO_RENDER_MODE_O="L-mcu_config_builder_set_output_video_render_mode-O",e.L_MCU_CONFIG_BUILDER_SET_OUTPUT_AUDIO_BITRATE_O="L-mcu_config_builder_set_output_audio_bitrate-O",e.L_MCU_CONFIG_BUILDER_SET_OUTPUT_BACKGROUND_COLOR_O="L-mcu_config_builder_set_output_background_color-O",e.L_MCU_CONFIG_BUILDER_SET_OUTPUT_BACKGROUND_PICTURE_O="L-mcu_config_builder_add_output_background_picture-O",e.L_MCU_CONFIG_BUILDER_REMOVE_OUTPUT_BACKGROUND_PICTURE_O="L-mcu_config_builder_remove_output_background_picture-O",e.L_MCU_CONFIG_BUILDER_CLEAR_OUTPUT_BACKGROUND_PICTURE_O="L-mcu_config_builder_clear_output_background_picture-O",e.L_MCU_CONFIG_BUILDER_SET_OUTPUT_BACKGROUND_PICTURE_FILL_MODE_O="L-mcu_config_builder_set_output_background_picture-fill-mode-O",e.L_MCU_CONFIG_BUILDER_ADD_PUBLISH_STREAM_URLS_O="L-mcu_config_builder_add_publish_stream_urls-O",e.L_MCU_CONFIG_BUILDER_REMOVE_PUBLISH_STREAM_URLS_O="L-mcu_config_builder_remove_publish_stream_urls-O",e.L_MCU_CONFIG_BUILDER_CLEAR_PUBLISH_STREAM_URLS_O="L-mcu_config_builder_clear_publish_stream_urls-O",e.L_MCU_CONFIG_BUILDER_ADD_CUSTOMIZE_LAYOUT_VIDEO_O="L-mcu_config_builder_add_customize_layout_video-O",e.L_MCU_CONFIG_BUILDER_REMOVE_CUSTOMIZE_LAYOUT_VIDEO_O="L-mcu_config_builder_remove_customize_layout_video-O",e.L_MCU_CONFIG_BUILDER_CLEAR_CUSTOMIZE_LAYOUT_VIDEO_O="L-mcu_config_builder_clear_customize_layout_video-O",e.L_MCU_CONFIG_BUILDER_SET_CUSTOMIZE_INPUT_AUDIO_O="L-mcu_config_builder_set_customize_input_audio-O",e.L_MCU_CONFIG_BUILDER_ADD_CUSTOMIZE_INPUT_AUDIO_O="L-mcu_config_builder_add_customize_input_audio-O",e.L_MCU_CONFIG_BUILDER_REMOVE_CUSTOMIZE_INPUT_AUDIO_O="L-mcu_config_builder_remove_customize_input_audio-O",e.L_MCU_CONFIG_BUILDER_CLEAR_CUSTOMIZE_INPUT_AUDIO_O="L-mcu_config_builder_clear_customize_input_audio-O",e.L_MCU_CONFIG_BUILDER_RESET_O="L-mcu_config_builder_reset-O",e.L_MCU_CONFIG_BUILDER_ADD_SINGLE_WATER_MARK_O="L-mcu_config_builder_add_single_water_mark-O",e.L_MCU_CONFIG_BUILDER_REMOVE_SINGLE_WATER_MARK_O="L-mcu_config_builder_remove_single_water_mark-O",e.L_MCU_CONFIG_BUILDER_CLEAR_SINGLE_WATER_MARK_O="L-mcu_config_builder_clear_single_water_mark-O",e.L_MEDIA_SERVICE_SET_MCU_CONFIG_T="L-media_service_set_mcu_config-T",e.L_MEDIA_SERVICE_SET_MCU_CONFIG_R="L-media_service_set_mcu_config-R",e.L_MEDIA_SERVICE_GET_CDN_RESOURCE_INFO_T="L-media_service_get_cnd_resource_info-T",e.L_MEDIA_SERVICE_GET_CDN_RESOURCE_INFO_R="L-media_service_get_cnd_resource_info-R",e.L_MEDIA_SERVICE_MSLIST_CHANGE_O="L-media_service_msList_change-O",e.L_MEDIA_SERVICE_PARSE_NAVI_CALLVOIP_INFO_O="L-media_service_parse_navi_callvoip_info-O",e.L_MEDIA_SERVICE_REQUEST_T="L-media_service_request-T",e.L_MEDIA_SERVICE_REQUEST_R="L-media_service_request-R",e.L_LOCAL_TRACK_DESTROY_O="L-loacl_track_destroy-O",e.L_LOCAL_TRACK_SET_BITRATE_O="L-loacl_track_set_bitrate-O",e.L_LOCAL_TRACK_SET_LOCAL_MUTED_O="L-loacl_track_set_local_muted-O",e.L_LOCAL_TRACK_SET_LOCAL_MUTED_SPREAD_T="L-loacl_track_set_local_muted_spread-T",e.L_LOCAL_TRACK_SET_LOCAL_MUTED_SPREAD_R="L-loacl_track_set_local_muted_spread-R",e.L_TRACK_PLAY_O="L-track_play-O",e.L_TRACK_PLAY_E="L-track_play-E",e.L_TRACK_LOAD_START_O="L-track_load_start-O",e.L_TRACK_DURATION_CHANGE_O="L-track_duration_change-O",e.L_TRACK_LOADED_META_DATA_O="L-track_loaded_meta_data-O",e.L_TRACK_LOADED_DATA_O="L-track_loaded_data-O",e.L_TRACK_ABORT_O="L-track_abort-O",e.L_TRACK_VOLUME_CHANGE_O="L-track_volume_change-O",e.L_TRACK_CANPLAY_O="L-track_canplay-O",e.L_ABSTRACT_STAT_PARSER_FORMAT_RTC_STATE_REPORT_O="L-abstract_stat_parser_format_rtc_state_report-O",e.L_A_SDP_STRATEGY_SET_SDP_SEMANTICS_O="L-a_sdp_strategy_set_sdp_semantics-O",e.L_A_SDP_STRATEGY_SET_REMOTE_ANSWER_O="L-a_sdp_strategy_set_remote_answer-O",e.L_RTC_PEER_CONNECTION_ADD_LOCAL_TRACK_O="L-rtc_peer_connection_add_local_track-O",e.L_RTC_PEER_CONNECTION_ICE_CONNECTION_STATE_S="L-rtc_peer_connection_ice_connection_state-S",e.L_RTC_PEER_CONNECTION_ICE_CONNECTION_STATE_REPORT_R="L-rtc_peer_connection_ice_connection_state_report-R",e.L_RTC_PEER_CONNECTION_CONNECTION_STATE_S="L-rtc_peer_connection_connection_state-S",e.L_RTC_PEER_CONNECTION_SET_BITRATE_O="L-rtc_peer_connection_set_bitrate-O",e.L_RTC_PEER_CONNECTION_CREATE_OFFER_O="L-rtc_peer_connection_create_offer-O",e.L_RTC_PEER_CONNECTION_REMOVE_LOCAL_TRACK_BY_ID_O="L-rtc_peer_connection_remove_local_track_by_id-O",e.L_RTC_PEER_CONNECTION_REMOVE_ALL_LOCAL_TRACK_O="L-rtc_peer_connection_remove_all_local_track-O",e.L_RTC_PEER_CONNECTION_REMOVE_LOCAL_TRACK_O="L-rtc_peer_connection_remove_local_track-O",e.L_RTC_PEER_CONNECTION_DESTROY_O="L-rtc_peer_connection_destroy-O",e.L_RTC_SET_RECOMMEND_BITRATE_O="L_rtc_set_recommend_bitrate_O",e.L_RTC_3ANOISE_NODE_O="L_RTC_AAAnoiseNode_O",e.L_RTC_3ANOISE_NODE_E="L_RTC_AAAnoiseNode_E",e.L_RTC_3ANOISE_NODE_STOP_O="L_RTC_AAAnoiseNode_Stop_O",e.L_QS_JOIN_ROOM_S="RTC-joinRoomRtc-S",e.L_QS_SUBSCRIBE_S="RTC-subscribe-S",e.L_QS_UNSUBSCRIBE_S="RTC-unsubscribe-S",e.L_QS_PUBLISH_S="RTC-publishRtc-S",e.L_QS_UNPUBLISH_S="RTC-unpublishRtc-S",e.L_QS_ICE_STATUS_S="RTC-iceStatus-S",e.L_QS_KICKED_S="RTC-forcedOffline-S",e.L_QS_PUB_ICE_STATUS_S="RTC-pubIceConnected-S",e.L_QS_SUB_ICE_STATUS_S="RTC-subIceConnected-S",e.L_QS_RECV_PUB_MSG_S="RTC-recvPubMsg-S",e.L_SET_ENCODER_PREFERENCES_S="RTC-set_Encoder_Preferences-S",e.L_RTCNTF_PULL_ROOM_STATUS_O="L-rtcntf_pull_room_status-O",e.L_RTCPING_PULL_ROOM_STATUS_O="L-rtcping_pull_room_status-O",e.L_PULL_ROOM_STATUS_T="L-pull_room_status-T",e.L_PULL_ROOM_STATUS_R="L-pull_room_status-R",e.L_OLD_DAILY_RECORD_O="L-old_daily_record-O",e.L_REMOTE_USER_JOINED_RESOURCES_O="L-remote_user_joined_resources-O",e.L_REMOTE_USER_STATE_HANDLE_O="L-remote_user_state_handle-O",e.L_UPDATE_SUBSCRIBELIST_COMMAND_T="L-update_subscribeList_command-T",e.L_UPDATE_SUBSCRIBELIST_COMMAND_P="L-update_subscribeList_command-P",e.L_UPDATE_SUBSCRIBELIST_COMMAND_R="L-update_subscribeList_command-R",e.L_RTC_CLIENT_NAVI_CHANGE_O="L-rtc_client_navi_change-O",e.L_UNPUBLISH_PREV_COMMAND_T="L-unpublish_prev_command-T",e.L_UNPUBLISH_PREV_COMMAND_R="L-unpublish_prev_command-R",e.L_RETRY_EXCHANGE_COMMAND_T="L-retry_exchange_command-T",e.L_RETRY_EXCHANGE_SPREAD_T="L-retry_exchange_spread-T",e.L_RETRY_EXCHANGE_SPREAD_R="L-retry_exchange_spread-R",e.L_PARSE_USERSTATE_COMMAND_R="L-parse_userstate_command-R",e.L_RESUB_REPUB_RES_R="L-resub_repub_res-R",e.L_PARSE_ROOMDATA_URIS_R="L-parse_roomdata_uris-R",e.L_SET_AUDIO_CONSTRAINTS_O="L-set_audio_constraints-O",e.L_FUNCTION_IS_UNAVAILABLE="L-function_is_unavailable",e.L_CLEAR_UNSUBSCRIBE_LIST_O="L-clear_unsubscribe_list-O",e.L_INVOKER_PUSH_O="L-invoker_push-O",e.L_INVOKER_EXECUTE_T="L-invoker_execute-T",e.L_INVOKER_EXECUTE_R="L-invoker_execute-R",e.L_INVOKER_DESTROY_O="L-invoker_destroy-R",e.L_PARSE_VOIP_SERVER_CONF_E="L_PARSE_VOIP_SERVER_CONF_E",e.L_GET_MEDIA_STREAM_E="L_GET_MEDIA_STREAM_E",e.L_INNER_SET_TRACK_O="L_INNER_SET_TRACK_O",e.A_APPLY_3A_NOISE_WORKLET_T="A-apply_3a_noise_worklet-T",e.A_APPLY_3A_NOISE_WORKLET_R="A-apply_3a_noise_worklet-R",e.L_ENCRYPTOR_ENCODE_E="L-encryptor_encode-E",e.L_ENCRYPTOR_DECODE_E="L-encryptor_decode-E",e.L_RTC_CLIENT_CHANGE_MEDIA_DEVICE_T="L-rtc_client_change_media_device-T",e.L_RTC_CLIENT_CHANGE_MEDIA_DEVICE_R="L-rtc_client_change_media_device-R"}(le||(le={})),function(e){e.FAILED="fail",e.SUCCESSED="success",e.TIMEOUT="timeout",e.INFO="info"}(_e||(_e={}));let ce=!0,de=!0;function ue(e,t,i){const r=e.match(t);return r&&r.length>=i&&parseInt(r[i],10)}function he(e,t,i){if(!e.RTCPeerConnection)return;const r=e.RTCPeerConnection.prototype,n=r.addEventListener;r.addEventListener=function(e,r){if(e!==t)return n.apply(this,arguments);const s=e=>{const t=i(e);t&&(r.handleEvent?r.handleEvent(t):r(t))};return this._eventMap=this._eventMap||{},this._eventMap[t]||(this._eventMap[t]=new Map),this._eventMap[t].set(r,s),n.apply(this,[e,s])};const s=r.removeEventListener;r.removeEventListener=function(e,i){if(e!==t||!this._eventMap||!this._eventMap[t])return s.apply(this,arguments);if(!this._eventMap[t].has(i))return s.apply(this,arguments);const r=this._eventMap[t].get(i);return this._eventMap[t].delete(i),0===this._eventMap[t].size&&delete this._eventMap[t],0===Object.keys(this._eventMap).length&&delete this._eventMap,s.apply(this,[e,r])},Object.defineProperty(r,"on"+t,{get(){return this["_on"+t]},set(e){this["_on"+t]&&(this.removeEventListener(t,this["_on"+t]),delete this["_on"+t]),e&&this.addEventListener(t,this["_on"+t]=e)},enumerable:!0,configurable:!0})}function ge(e){return"boolean"!=typeof e?new Error("Argument type: "+typeof e+". Please use a boolean."):(ce=e,e?"adapter.js logging disabled":"adapter.js logging enabled")}function pe(e){return"boolean"!=typeof e?new Error("Argument type: "+typeof e+". Please use a boolean."):(de=!e,"adapter.js deprecation warnings "+(e?"disabled":"enabled"))}function fe(){if("object"==typeof window){if(ce)return;"undefined"!=typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)}}function Ee(e,t){de&&console.warn(e+" is deprecated, please use "+t+" instead.")}function Ie(e){return"[object Object]"===Object.prototype.toString.call(e)}function Te(e){return Ie(e)?Object.keys(e).reduce((function(t,i){const r=Ie(e[i]),n=r?Te(e[i]):e[i],s=r&&!Object.keys(n).length;return void 0===n||s?t:Object.assign(t,{[i]:n})}),{}):e}function me(e,t,i){t&&!i.has(t.id)&&(i.set(t.id,t),Object.keys(t).forEach((r=>{r.endsWith("Id")?me(e,e.get(t[r]),i):r.endsWith("Ids")&&t[r].forEach((t=>{me(e,e.get(t),i)}))})))}function Re(e,t,i){const r=i?"outbound-rtp":"inbound-rtp",n=new Map;if(null===t)return n;const s=[];return e.forEach((e=>{"track"===e.type&&e.trackIdentifier===t.id&&s.push(e)})),s.forEach((t=>{e.forEach((i=>{i.type===r&&i.trackId===t.id&&me(e,i,n)}))})),n}const Se=fe;function Ce(e,t){const i=e&&e.navigator;if(!i.mediaDevices)return;const r=function(e){if("object"!=typeof e||e.mandatory||e.optional)return e;const t={};return Object.keys(e).forEach((i=>{if("require"===i||"advanced"===i||"mediaSource"===i)return;const r="object"==typeof e[i]?e[i]:{ideal:e[i]};void 0!==r.exact&&"number"==typeof r.exact&&(r.min=r.max=r.exact);const n=function(e,t){return e?e+t.charAt(0).toUpperCase()+t.slice(1):"deviceId"===t?"sourceId":t};if(void 0!==r.ideal){t.optional=t.optional||[];let e={};"number"==typeof r.ideal?(e[n("min",i)]=r.ideal,t.optional.push(e),e={},e[n("max",i)]=r.ideal,t.optional.push(e)):(e[n("",i)]=r.ideal,t.optional.push(e))}void 0!==r.exact&&"number"!=typeof r.exact?(t.mandatory=t.mandatory||{},t.mandatory[n("",i)]=r.exact):["min","max"].forEach((e=>{void 0!==r[e]&&(t.mandatory=t.mandatory||{},t.mandatory[n(e,i)]=r[e])}))})),e.advanced&&(t.optional=(t.optional||[]).concat(e.advanced)),t},n=function(e,n){if(t.version>=61)return n(e);if((e=JSON.parse(JSON.stringify(e)))&&"object"==typeof e.audio){const t=function(e,t,i){t in e&&!(i in e)&&(e[i]=e[t],delete e[t])};t((e=JSON.parse(JSON.stringify(e))).audio,"autoGainControl","googAutoGainControl"),t(e.audio,"noiseSuppression","googNoiseSuppression"),e.audio=r(e.audio)}if(e&&"object"==typeof e.video){let s=e.video.facingMode;s=s&&("object"==typeof s?s:{ideal:s});const o=t.version<66;if(s&&("user"===s.exact||"environment"===s.exact||"user"===s.ideal||"environment"===s.ideal)&&(!i.mediaDevices.getSupportedConstraints||!i.mediaDevices.getSupportedConstraints().facingMode||o)){let t;if(delete e.video.facingMode,"environment"===s.exact||"environment"===s.ideal?t=["back","rear"]:"user"!==s.exact&&"user"!==s.ideal||(t=["front"]),t)return i.mediaDevices.enumerateDevices().then((i=>{let o=(i=i.filter((e=>"videoinput"===e.kind))).find((e=>t.some((t=>e.label.toLowerCase().includes(t)))));return!o&&i.length&&t.includes("back")&&(o=i[i.length-1]),o&&(e.video.deviceId=s.exact?{exact:o.deviceId}:{ideal:o.deviceId}),e.video=r(e.video),Se("chrome: "+JSON.stringify(e)),n(e)}))}e.video=r(e.video)}return Se("chrome: "+JSON.stringify(e)),n(e)},s=function(e){return t.version>=64?e:{name:{PermissionDeniedError:"NotAllowedError",PermissionDismissedError:"NotAllowedError",InvalidStateError:"NotAllowedError",DevicesNotFoundError:"NotFoundError",ConstraintNotSatisfiedError:"OverconstrainedError",TrackStartError:"NotReadableError",MediaDeviceFailedDueToShutdown:"NotAllowedError",MediaDeviceKillSwitchOn:"NotAllowedError",TabCaptureError:"AbortError",ScreenCaptureError:"AbortError",DeviceCaptureError:"AbortError"}[e.name]||e.name,message:e.message,constraint:e.constraint||e.constraintName,toString(){return this.name+(this.message&&": ")+this.message}}};if(i.getUserMedia=function(e,t,r){n(e,(e=>{i.webkitGetUserMedia(e,t,(e=>{r&&r(s(e))}))}))}.bind(i),i.mediaDevices.getUserMedia){const e=i.mediaDevices.getUserMedia.bind(i.mediaDevices);i.mediaDevices.getUserMedia=function(t){return n(t,(t=>e(t).then((e=>{if(t.audio&&!e.getAudioTracks().length||t.video&&!e.getVideoTracks().length)throw e.getTracks().forEach((e=>{e.stop()})),new DOMException("","NotFoundError");return e}),(e=>Promise.reject(s(e))))))}}}function Le(e){e.MediaStream=e.MediaStream||e.webkitMediaStream}function Oe(e){if("object"==typeof e&&e.RTCPeerConnection&&!("ontrack"in e.RTCPeerConnection.prototype)){Object.defineProperty(e.RTCPeerConnection.prototype,"ontrack",{get(){return this._ontrack},set(e){this._ontrack&&this.removeEventListener("track",this._ontrack),this.addEventListener("track",this._ontrack=e)},enumerable:!0,configurable:!0});const t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){return this._ontrackpoly||(this._ontrackpoly=t=>{t.stream.addEventListener("addtrack",(i=>{let r;r=e.RTCPeerConnection.prototype.getReceivers?this.getReceivers().find((e=>e.track&&e.track.id===i.track.id)):{track:i.track};const n=new Event("track");n.track=i.track,n.receiver=r,n.transceiver={receiver:r},n.streams=[t.stream],this.dispatchEvent(n)})),t.stream.getTracks().forEach((i=>{let r;r=e.RTCPeerConnection.prototype.getReceivers?this.getReceivers().find((e=>e.track&&e.track.id===i.id)):{track:i};const n=new Event("track");n.track=i,n.receiver=r,n.transceiver={receiver:r},n.streams=[t.stream],this.dispatchEvent(n)}))},this.addEventListener("addstream",this._ontrackpoly)),t.apply(this,arguments)}}else he(e,"track",(e=>(e.transceiver||Object.defineProperty(e,"transceiver",{value:{receiver:e.receiver}}),e)))}function ve(e){if("object"==typeof e&&e.RTCPeerConnection&&!("getSenders"in e.RTCPeerConnection.prototype)&&"createDTMFSender"in e.RTCPeerConnection.prototype){const t=function(e,t){return{track:t,get dtmf(){return void 0===this._dtmf&&("audio"===t.kind?this._dtmf=e.createDTMFSender(t):this._dtmf=null),this._dtmf},_pc:e}};if(!e.RTCPeerConnection.prototype.getSenders){e.RTCPeerConnection.prototype.getSenders=function(){return this._senders=this._senders||[],this._senders.slice()};const i=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,r){let n=i.apply(this,arguments);return n||(n=t(this,e),this._senders.push(n)),n};const r=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){r.apply(this,arguments);const t=this._senders.indexOf(e);-1!==t&&this._senders.splice(t,1)}}const i=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){this._senders=this._senders||[],i.apply(this,[e]),e.getTracks().forEach((e=>{this._senders.push(t(this,e))}))};const r=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){this._senders=this._senders||[],r.apply(this,[e]),e.getTracks().forEach((e=>{const t=this._senders.find((t=>t.track===e));t&&this._senders.splice(this._senders.indexOf(t),1)}))}}else if("object"==typeof e&&e.RTCPeerConnection&&"getSenders"in e.RTCPeerConnection.prototype&&"createDTMFSender"in e.RTCPeerConnection.prototype&&e.RTCRtpSender&&!("dtmf"in e.RTCRtpSender.prototype)){const t=e.RTCPeerConnection.prototype.getSenders;e.RTCPeerConnection.prototype.getSenders=function(){const e=t.apply(this,[]);return e.forEach((e=>e._pc=this)),e},Object.defineProperty(e.RTCRtpSender.prototype,"dtmf",{get(){return void 0===this._dtmf&&("audio"===this.track.kind?this._dtmf=this._pc.createDTMFSender(this.track):this._dtmf=null),this._dtmf}})}}function be(e){if(!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){const[e,i,r]=arguments;if(arguments.length>0&&"function"==typeof e)return t.apply(this,arguments);if(0===t.length&&(0===arguments.length||"function"!=typeof e))return t.apply(this,[]);const n=function(e){const t={};return e.result().forEach((e=>{const i={id:e.id,timestamp:e.timestamp,type:{localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[e.type]||e.type};e.names().forEach((t=>{i[t]=e.stat(t)})),t[i.id]=i})),t},s=function(e){return new Map(Object.keys(e).map((t=>[t,e[t]])))};if(arguments.length>=2){const r=function(e){i(s(n(e)))};return t.apply(this,[r,e])}return new Promise(((e,i)=>{t.apply(this,[function(t){e(s(n(t)))},i])})).then(i,r)}}function Ae(e){if(!("object"==typeof e&&e.RTCPeerConnection&&e.RTCRtpSender&&e.RTCRtpReceiver))return;if(!("getStats"in e.RTCRtpSender.prototype)){const t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){const e=t.apply(this,[]);return e.forEach((e=>e._pc=this)),e});const i=e.RTCPeerConnection.prototype.addTrack;i&&(e.RTCPeerConnection.prototype.addTrack=function(){const e=i.apply(this,arguments);return e._pc=this,e}),e.RTCRtpSender.prototype.getStats=function(){const e=this;return this._pc.getStats().then((t=>Re(t,e.track,!0)))}}if(!("getStats"in e.RTCRtpReceiver.prototype)){const t=e.RTCPeerConnection.prototype.getReceivers;t&&(e.RTCPeerConnection.prototype.getReceivers=function(){const e=t.apply(this,[]);return e.forEach((e=>e._pc=this)),e}),he(e,"track",(e=>(e.receiver._pc=e.srcElement,e))),e.RTCRtpReceiver.prototype.getStats=function(){const e=this;return this._pc.getStats().then((t=>Re(t,e.track,!1)))}}if(!("getStats"in e.RTCRtpSender.prototype)||!("getStats"in e.RTCRtpReceiver.prototype))return;const t=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){if(arguments.length>0&&arguments[0]instanceof e.MediaStreamTrack){const e=arguments[0];let t,i,r;return this.getSenders().forEach((i=>{i.track===e&&(t?r=!0:t=i)})),this.getReceivers().forEach((t=>(t.track===e&&(i?r=!0:i=t),t.track===e))),r||t&&i?Promise.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):t?t.getStats():i?i.getStats():Promise.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return t.apply(this,arguments)}}function Ne(e){e.RTCPeerConnection.prototype.getLocalStreams=function(){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},Object.keys(this._shimmedLocalStreams).map((e=>this._shimmedLocalStreams[e][0]))};const t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,i){if(!i)return t.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};const r=t.apply(this,arguments);return this._shimmedLocalStreams[i.id]?-1===this._shimmedLocalStreams[i.id].indexOf(r)&&this._shimmedLocalStreams[i.id].push(r):this._shimmedLocalStreams[i.id]=[i,r],r};const i=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){this._shimmedLocalStreams=this._shimmedLocalStreams||{},e.getTracks().forEach((e=>{if(this.getSenders().find((t=>t.track===e)))throw new DOMException("Track already exists.","InvalidAccessError")}));const t=this.getSenders();i.apply(this,arguments);const r=this.getSenders().filter((e=>-1===t.indexOf(e)));this._shimmedLocalStreams[e.id]=[e].concat(r)};const r=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},delete this._shimmedLocalStreams[e.id],r.apply(this,arguments)};const n=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},e&&Object.keys(this._shimmedLocalStreams).forEach((t=>{const i=this._shimmedLocalStreams[t].indexOf(e);-1!==i&&this._shimmedLocalStreams[t].splice(i,1),1===this._shimmedLocalStreams[t].length&&delete this._shimmedLocalStreams[t]})),n.apply(this,arguments)}}function ye(e,t){if(!e.RTCPeerConnection)return;if(e.RTCPeerConnection.prototype.addTrack&&t.version>=65)return Ne(e);const i=e.RTCPeerConnection.prototype.getLocalStreams;e.RTCPeerConnection.prototype.getLocalStreams=function(){const e=i.apply(this);return this._reverseStreams=this._reverseStreams||{},e.map((e=>this._reverseStreams[e.id]))};const r=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(t){if(this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},t.getTracks().forEach((e=>{if(this.getSenders().find((t=>t.track===e)))throw new DOMException("Track already exists.","InvalidAccessError")})),!this._reverseStreams[t.id]){const i=new e.MediaStream(t.getTracks());this._streams[t.id]=i,this._reverseStreams[i.id]=t,t=i}r.apply(this,[t])};const n=e.RTCPeerConnection.prototype.removeStream;function s(e,t){let i=t.sdp;return Object.keys(e._reverseStreams||[]).forEach((t=>{const r=e._reverseStreams[t],n=e._streams[r.id];i=i.replace(new RegExp(n.id,"g"),r.id)})),new RTCSessionDescription({type:t.type,sdp:i})}e.RTCPeerConnection.prototype.removeStream=function(e){this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},n.apply(this,[this._streams[e.id]||e]),delete this._reverseStreams[this._streams[e.id]?this._streams[e.id].id:e.id],delete this._streams[e.id]},e.RTCPeerConnection.prototype.addTrack=function(t,i){if("closed"===this.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");const r=[].slice.call(arguments,1);if(1!==r.length||!r[0].getTracks().find((e=>e===t)))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((e=>e.track===t)))throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};const n=this._streams[i.id];if(n)n.addTrack(t),Promise.resolve().then((()=>{this.dispatchEvent(new Event("negotiationneeded"))}));else{const r=new e.MediaStream([t]);this._streams[i.id]=r,this._reverseStreams[r.id]=i,this.addStream(r)}return this.getSenders().find((e=>e.track===t))},["createOffer","createAnswer"].forEach((function(t){const i=e.RTCPeerConnection.prototype[t],r={[t](){const e=arguments;return arguments.length&&"function"==typeof arguments[0]?i.apply(this,[t=>{const i=s(this,t);e[0].apply(null,[i])},t=>{e[1]&&e[1].apply(null,t)},arguments[2]]):i.apply(this,arguments).then((e=>s(this,e)))}};e.RTCPeerConnection.prototype[t]=r[t]}));const o=e.RTCPeerConnection.prototype.setLocalDescription;e.RTCPeerConnection.prototype.setLocalDescription=function(){return arguments.length&&arguments[0].type?(arguments[0]=function(e,t){let i=t.sdp;return Object.keys(e._reverseStreams||[]).forEach((t=>{const r=e._reverseStreams[t],n=e._streams[r.id];i=i.replace(new RegExp(r.id,"g"),n.id)})),new RTCSessionDescription({type:t.type,sdp:i})}(this,arguments[0]),o.apply(this,arguments)):o.apply(this,arguments)};const a=Object.getOwnPropertyDescriptor(e.RTCPeerConnection.prototype,"localDescription");Object.defineProperty(e.RTCPeerConnection.prototype,"localDescription",{get(){const e=a.get.apply(this);return""===e.type?e:s(this,e)}}),e.RTCPeerConnection.prototype.removeTrack=function(e){if("closed"===this.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");if(!e._pc)throw new DOMException("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.","TypeError");if(!(e._pc===this))throw new DOMException("Sender was not created by this connection.","InvalidAccessError");let t;this._streams=this._streams||{},Object.keys(this._streams).forEach((i=>{this._streams[i].getTracks().find((t=>e.track===t))&&(t=this._streams[i])})),t&&(1===t.getTracks().length?this.removeStream(this._reverseStreams[t.id]):t.removeTrack(e.track),this.dispatchEvent(new Event("negotiationneeded")))}}function Pe(e,t){!e.RTCPeerConnection&&e.webkitRTCPeerConnection&&(e.RTCPeerConnection=e.webkitRTCPeerConnection),e.RTCPeerConnection&&t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach((function(t){const i=e.RTCPeerConnection.prototype[t],r={[t](){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),i.apply(this,arguments)}};e.RTCPeerConnection.prototype[t]=r[t]}))}function Ue(e,t){he(e,"negotiationneeded",(e=>{const i=e.target;if(!(t.version<72||i.getConfiguration&&"plan-b"===i.getConfiguration().sdpSemantics)||"stable"===i.signalingState)return e}))}var De=Object.freeze({__proto__:null,shimMediaStream:Le,shimOnTrack:Oe,shimGetSendersWithDtmf:ve,shimGetStats:be,shimSenderReceiverGetStats:Ae,shimAddTrackRemoveTrackWithNative:Ne,shimAddTrackRemoveTrack:ye,shimPeerConnection:Pe,fixNegotiationNeeded:Ue,shimGetUserMedia:Ce,shimGetDisplayMedia:function(e,t){e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||e.navigator.mediaDevices&&("function"==typeof t?e.navigator.mediaDevices.getDisplayMedia=function(i){return t(i).then((t=>{const r=i.video&&i.video.width,n=i.video&&i.video.height,s=i.video&&i.video.frameRate;return i.video={mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:t,maxFrameRate:s||3}},r&&(i.video.mandatory.maxWidth=r),n&&(i.video.mandatory.maxHeight=n),e.navigator.mediaDevices.getUserMedia(i)}))}:console.error("shimGetDisplayMedia: getSourceId argument is not a function"))}});var Me,we,ke=(Me=function(e){var t={generateIdentifier:function(){return Math.random().toString(36).substr(2,10)}};t.localCName=t.generateIdentifier(),t.splitLines=function(e){return e.trim().split("\n").map((function(e){return e.trim()}))},t.splitSections=function(e){return e.split("\nm=").map((function(e,t){return(t>0?"m="+e:e).trim()+"\r\n"}))},t.getDescription=function(e){var i=t.splitSections(e);return i&&i[0]},t.getMediaSections=function(e){var i=t.splitSections(e);return i.shift(),i},t.matchPrefix=function(e,i){return t.splitLines(e).filter((function(e){return 0===e.indexOf(i)}))},t.parseCandidate=function(e){for(var t,i={foundation:(t=0===e.indexOf("a=candidate:")?e.substring(12).split(" "):e.substring(10).split(" "))[0],component:parseInt(t[1],10),protocol:t[2].toLowerCase(),priority:parseInt(t[3],10),ip:t[4],address:t[4],port:parseInt(t[5],10),type:t[7]},r=8;r<t.length;r+=2)switch(t[r]){case"raddr":i.relatedAddress=t[r+1];break;case"rport":i.relatedPort=parseInt(t[r+1],10);break;case"tcptype":i.tcpType=t[r+1];break;case"ufrag":i.ufrag=t[r+1],i.usernameFragment=t[r+1];break;default:i[t[r]]=t[r+1]}return i},t.writeCandidate=function(e){var t=[];t.push(e.foundation),t.push(e.component),t.push(e.protocol.toUpperCase()),t.push(e.priority),t.push(e.address||e.ip),t.push(e.port);var i=e.type;return t.push("typ"),t.push(i),"host"!==i&&e.relatedAddress&&e.relatedPort&&(t.push("raddr"),t.push(e.relatedAddress),t.push("rport"),t.push(e.relatedPort)),e.tcpType&&"tcp"===e.protocol.toLowerCase()&&(t.push("tcptype"),t.push(e.tcpType)),(e.usernameFragment||e.ufrag)&&(t.push("ufrag"),t.push(e.usernameFragment||e.ufrag)),"candidate:"+t.join(" ")},t.parseIceOptions=function(e){return e.substr(14).split(" ")},t.parseRtpMap=function(e){var t=e.substr(9).split(" "),i={payloadType:parseInt(t.shift(),10)};return t=t[0].split("/"),i.name=t[0],i.clockRate=parseInt(t[1],10),i.channels=3===t.length?parseInt(t[2],10):1,i.numChannels=i.channels,i},t.writeRtpMap=function(e){var t=e.payloadType;void 0!==e.preferredPayloadType&&(t=e.preferredPayloadType);var i=e.channels||e.numChannels||1;return"a=rtpmap:"+t+" "+e.name+"/"+e.clockRate+(1!==i?"/"+i:"")+"\r\n"},t.parseExtmap=function(e){var t=e.substr(9).split(" ");return{id:parseInt(t[0],10),direction:t[0].indexOf("/")>0?t[0].split("/")[1]:"sendrecv",uri:t[1]}},t.writeExtmap=function(e){return"a=extmap:"+(e.id||e.preferredId)+(e.direction&&"sendrecv"!==e.direction?"/"+e.direction:"")+" "+e.uri+"\r\n"},t.parseFmtp=function(e){for(var t,i={},r=e.substr(e.indexOf(" ")+1).split(";"),n=0;n<r.length;n++)i[(t=r[n].trim().split("="))[0].trim()]=t[1];return i},t.writeFmtp=function(e){var t="",i=e.payloadType;if(void 0!==e.preferredPayloadType&&(i=e.preferredPayloadType),e.parameters&&Object.keys(e.parameters).length){var r=[];Object.keys(e.parameters).forEach((function(t){e.parameters[t]?r.push(t+"="+e.parameters[t]):r.push(t)})),t+="a=fmtp:"+i+" "+r.join(";")+"\r\n"}return t},t.parseRtcpFb=function(e){var t=e.substr(e.indexOf(" ")+1).split(" ");return{type:t.shift(),parameter:t.join(" ")}},t.writeRtcpFb=function(e){var t="",i=e.payloadType;return void 0!==e.preferredPayloadType&&(i=e.preferredPayloadType),e.rtcpFeedback&&e.rtcpFeedback.length&&e.rtcpFeedback.forEach((function(e){t+="a=rtcp-fb:"+i+" "+e.type+(e.parameter&&e.parameter.length?" "+e.parameter:"")+"\r\n"})),t},t.parseSsrcMedia=function(e){var t=e.indexOf(" "),i={ssrc:parseInt(e.substr(7,t-7),10)},r=e.indexOf(":",t);return r>-1?(i.attribute=e.substr(t+1,r-t-1),i.value=e.substr(r+1)):i.attribute=e.substr(t+1),i},t.parseSsrcGroup=function(e){var t=e.substr(13).split(" ");return{semantics:t.shift(),ssrcs:t.map((function(e){return parseInt(e,10)}))}},t.getMid=function(e){var i=t.matchPrefix(e,"a=mid:")[0];if(i)return i.substr(6)},t.parseFingerprint=function(e){var t=e.substr(14).split(" ");return{algorithm:t[0].toLowerCase(),value:t[1]}},t.getDtlsParameters=function(e,i){return{role:"auto",fingerprints:t.matchPrefix(e+i,"a=fingerprint:").map(t.parseFingerprint)}},t.writeDtlsParameters=function(e,t){var i="a=setup:"+t+"\r\n";return e.fingerprints.forEach((function(e){i+="a=fingerprint:"+e.algorithm+" "+e.value+"\r\n"})),i},t.parseCryptoLine=function(e){var t=e.substr(9).split(" ");return{tag:parseInt(t[0],10),cryptoSuite:t[1],keyParams:t[2],sessionParams:t.slice(3)}},t.writeCryptoLine=function(e){return"a=crypto:"+e.tag+" "+e.cryptoSuite+" "+("object"==typeof e.keyParams?t.writeCryptoKeyParams(e.keyParams):e.keyParams)+(e.sessionParams?" "+e.sessionParams.join(" "):"")+"\r\n"},t.parseCryptoKeyParams=function(e){if(0!==e.indexOf("inline:"))return null;var t=e.substr(7).split("|");return{keyMethod:"inline",keySalt:t[0],lifeTime:t[1],mkiValue:t[2]?t[2].split(":")[0]:void 0,mkiLength:t[2]?t[2].split(":")[1]:void 0}},t.writeCryptoKeyParams=function(e){return e.keyMethod+":"+e.keySalt+(e.lifeTime?"|"+e.lifeTime:"")+(e.mkiValue&&e.mkiLength?"|"+e.mkiValue+":"+e.mkiLength:"")},t.getCryptoParameters=function(e,i){return t.matchPrefix(e+i,"a=crypto:").map(t.parseCryptoLine)},t.getIceParameters=function(e,i){var r=t.matchPrefix(e+i,"a=ice-ufrag:")[0],n=t.matchPrefix(e+i,"a=ice-pwd:")[0];return r&&n?{usernameFragment:r.substr(12),password:n.substr(10)}:null},t.writeIceParameters=function(e){return"a=ice-ufrag:"+e.usernameFragment+"\r\na=ice-pwd:"+e.password+"\r\n"},t.parseRtpParameters=function(e){for(var i={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},r=t.splitLines(e)[0].split(" "),n=3;n<r.length;n++){var s=r[n],o=t.matchPrefix(e,"a=rtpmap:"+s+" ")[0];if(o){var a=t.parseRtpMap(o),l=t.matchPrefix(e,"a=fmtp:"+s+" ");switch(a.parameters=l.length?t.parseFmtp(l[0]):{},a.rtcpFeedback=t.matchPrefix(e,"a=rtcp-fb:"+s+" ").map(t.parseRtcpFb),i.codecs.push(a),a.name.toUpperCase()){case"RED":case"ULPFEC":i.fecMechanisms.push(a.name.toUpperCase())}}}return t.matchPrefix(e,"a=extmap:").forEach((function(e){i.headerExtensions.push(t.parseExtmap(e))})),i},t.writeRtpDescription=function(e,i){var r="";r+="m="+e+" ",r+=i.codecs.length>0?"9":"0",r+=" UDP/TLS/RTP/SAVPF ",r+=i.codecs.map((function(e){return void 0!==e.preferredPayloadType?e.preferredPayloadType:e.payloadType})).join(" ")+"\r\n",r+="c=IN IP4 0.0.0.0\r\n",r+="a=rtcp:9 IN IP4 0.0.0.0\r\n",i.codecs.forEach((function(e){r+=t.writeRtpMap(e),r+=t.writeFmtp(e),r+=t.writeRtcpFb(e)}));var n=0;return i.codecs.forEach((function(e){e.maxptime>n&&(n=e.maxptime)})),n>0&&(r+="a=maxptime:"+n+"\r\n"),r+="a=rtcp-mux\r\n",i.headerExtensions&&i.headerExtensions.forEach((function(e){r+=t.writeExtmap(e)})),r},t.parseRtpEncodingParameters=function(e){var i,r=[],n=t.parseRtpParameters(e),s=-1!==n.fecMechanisms.indexOf("RED"),o=-1!==n.fecMechanisms.indexOf("ULPFEC"),a=t.matchPrefix(e,"a=ssrc:").map((function(e){return t.parseSsrcMedia(e)})).filter((function(e){return"cname"===e.attribute})),l=a.length>0&&a[0].ssrc,_=t.matchPrefix(e,"a=ssrc-group:FID").map((function(e){return e.substr(17).split(" ").map((function(e){return parseInt(e,10)}))}));_.length>0&&_[0].length>1&&_[0][0]===l&&(i=_[0][1]),n.codecs.forEach((function(e){if("RTX"===e.name.toUpperCase()&&e.parameters.apt){var t={ssrc:l,codecPayloadType:parseInt(e.parameters.apt,10)};l&&i&&(t.rtx={ssrc:i}),r.push(t),s&&((t=JSON.parse(JSON.stringify(t))).fec={ssrc:l,mechanism:o?"red+ulpfec":"red"},r.push(t))}})),0===r.length&&l&&r.push({ssrc:l});var c=t.matchPrefix(e,"b=");return c.length&&(c=0===c[0].indexOf("b=TIAS:")?parseInt(c[0].substr(7),10):0===c[0].indexOf("b=AS:")?1e3*parseInt(c[0].substr(5),10)*.95-16e3:void 0,r.forEach((function(e){e.maxBitrate=c}))),r},t.parseRtcpParameters=function(e){var i={},r=t.matchPrefix(e,"a=ssrc:").map((function(e){return t.parseSsrcMedia(e)})).filter((function(e){return"cname"===e.attribute}))[0];r&&(i.cname=r.value,i.ssrc=r.ssrc);var n=t.matchPrefix(e,"a=rtcp-rsize");i.reducedSize=n.length>0,i.compound=0===n.length;var s=t.matchPrefix(e,"a=rtcp-mux");return i.mux=s.length>0,i},t.parseMsid=function(e){var i,r=t.matchPrefix(e,"a=msid:");if(1===r.length)return{stream:(i=r[0].substr(7).split(" "))[0],track:i[1]};var n=t.matchPrefix(e,"a=ssrc:").map((function(e){return t.parseSsrcMedia(e)})).filter((function(e){return"msid"===e.attribute}));return n.length>0?{stream:(i=n[0].value.split(" "))[0],track:i[1]}:void 0},t.parseSctpDescription=function(e){var i,r=t.parseMLine(e),n=t.matchPrefix(e,"a=max-message-size:");n.length>0&&(i=parseInt(n[0].substr(19),10)),isNaN(i)&&(i=65536);var s=t.matchPrefix(e,"a=sctp-port:");if(s.length>0)return{port:parseInt(s[0].substr(12),10),protocol:r.fmt,maxMessageSize:i};if(t.matchPrefix(e,"a=sctpmap:").length>0){var o=t.matchPrefix(e,"a=sctpmap:")[0].substr(10).split(" ");return{port:parseInt(o[0],10),protocol:o[1],maxMessageSize:i}}},t.writeSctpDescription=function(e,t){var i=[];return i="DTLS/SCTP"!==e.protocol?["m="+e.kind+" 9 "+e.protocol+" "+t.protocol+"\r\n","c=IN IP4 0.0.0.0\r\n","a=sctp-port:"+t.port+"\r\n"]:["m="+e.kind+" 9 "+e.protocol+" "+t.port+"\r\n","c=IN IP4 0.0.0.0\r\n","a=sctpmap:"+t.port+" "+t.protocol+" 65535\r\n"],void 0!==t.maxMessageSize&&i.push("a=max-message-size:"+t.maxMessageSize+"\r\n"),i.join("")},t.generateSessionId=function(){return Math.random().toString().substr(2,21)},t.writeSessionBoilerplate=function(e,i,r){var n=void 0!==i?i:2;return"v=0\r\no="+(r||"thisisadapterortc")+" "+(e||t.generateSessionId())+" "+n+" IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\n"},t.writeMediaSection=function(e,i,r,n){var s=t.writeRtpDescription(e.kind,i);if(s+=t.writeIceParameters(e.iceGatherer.getLocalParameters()),s+=t.writeDtlsParameters(e.dtlsTransport.getLocalParameters(),"offer"===r?"actpass":"active"),s+="a=mid:"+e.mid+"\r\n",e.direction?s+="a="+e.direction+"\r\n":e.rtpSender&&e.rtpReceiver?s+="a=sendrecv\r\n":e.rtpSender?s+="a=sendonly\r\n":e.rtpReceiver?s+="a=recvonly\r\n":s+="a=inactive\r\n",e.rtpSender){var o="msid:"+n.id+" "+e.rtpSender.track.id+"\r\n";s+="a="+o,s+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" "+o,e.sendEncodingParameters[0].rtx&&(s+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" "+o,s+="a=ssrc-group:FID "+e.sendEncodingParameters[0].ssrc+" "+e.sendEncodingParameters[0].rtx.ssrc+"\r\n")}return s+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" cname:"+t.localCName+"\r\n",e.rtpSender&&e.sendEncodingParameters[0].rtx&&(s+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" cname:"+t.localCName+"\r\n"),s},t.getDirection=function(e,i){for(var r=t.splitLines(e),n=0;n<r.length;n++)switch(r[n]){case"a=sendrecv":case"a=sendonly":case"a=recvonly":case"a=inactive":return r[n].substr(2)}return i?t.getDirection(i):"sendrecv"},t.getKind=function(e){return t.splitLines(e)[0].split(" ")[0].substr(2)},t.isRejected=function(e){return"0"===e.split(" ",2)[1]},t.parseMLine=function(e){var i=t.splitLines(e)[0].substr(2).split(" ");return{kind:i[0],port:parseInt(i[1],10),protocol:i[2],fmt:i.slice(3).join(" ")}},t.parseOLine=function(e){var i=t.matchPrefix(e,"o=")[0].substr(2).split(" ");return{username:i[0],sessionId:i[1],sessionVersion:parseInt(i[2],10),netType:i[3],addressType:i[4],address:i[5]}},t.isValidSDP=function(e){if("string"!=typeof e||0===e.length)return!1;for(var i=t.splitLines(e),r=0;r<i.length;r++)if(i[r].length<2||"="!==i[r].charAt(1))return!1;return!0},e.exports=t},Me(we={exports:{}},we.exports),we.exports);function xe(e,t,i,r,n){var s=ke.writeRtpDescription(e.kind,t);if(s+=ke.writeIceParameters(e.iceGatherer.getLocalParameters()),s+=ke.writeDtlsParameters(e.dtlsTransport.getLocalParameters(),"offer"===i?"actpass":n||"active"),s+="a=mid:"+e.mid+"\r\n",e.rtpSender&&e.rtpReceiver?s+="a=sendrecv\r\n":e.rtpSender?s+="a=sendonly\r\n":e.rtpReceiver?s+="a=recvonly\r\n":s+="a=inactive\r\n",e.rtpSender){var o=e.rtpSender._initialTrackId||e.rtpSender.track.id;e.rtpSender._initialTrackId=o;var a="msid:"+(r?r.id:"-")+" "+o+"\r\n";s+="a="+a,s+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" "+a,e.sendEncodingParameters[0].rtx&&(s+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" "+a,s+="a=ssrc-group:FID "+e.sendEncodingParameters[0].ssrc+" "+e.sendEncodingParameters[0].rtx.ssrc+"\r\n")}return s+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" cname:"+ke.localCName+"\r\n",e.rtpSender&&e.sendEncodingParameters[0].rtx&&(s+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" cname:"+ke.localCName+"\r\n"),s}function Be(e,t){var i={codecs:[],headerExtensions:[],fecMechanisms:[]},r=function(e,t){e=parseInt(e,10);for(var i=0;i<t.length;i++)if(t[i].payloadType===e||t[i].preferredPayloadType===e)return t[i]},n=function(e,t,i,n){var s=r(e.parameters.apt,i),o=r(t.parameters.apt,n);return s&&o&&s.name.toLowerCase()===o.name.toLowerCase()};return e.codecs.forEach((function(r){for(var s=0;s<t.codecs.length;s++){var o=t.codecs[s];if(r.name.toLowerCase()===o.name.toLowerCase()&&r.clockRate===o.clockRate){if("rtx"===r.name.toLowerCase()&&r.parameters&&o.parameters.apt&&!n(r,o,e.codecs,t.codecs))continue;(o=JSON.parse(JSON.stringify(o))).numChannels=Math.min(r.numChannels,o.numChannels),i.codecs.push(o),o.rtcpFeedback=o.rtcpFeedback.filter((function(e){for(var t=0;t<r.rtcpFeedback.length;t++)if(r.rtcpFeedback[t].type===e.type&&r.rtcpFeedback[t].parameter===e.parameter)return!0;return!1}));break}}})),e.headerExtensions.forEach((function(e){for(var r=0;r<t.headerExtensions.length;r++){var n=t.headerExtensions[r];if(e.uri===n.uri){i.headerExtensions.push(n);break}}})),i}function Ve(e,t,i){return-1!=={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"]}}[t][e].indexOf(i)}function Ge(e,t){var i=e.getRemoteCandidates().find((function(e){return t.foundation===e.foundation&&t.ip===e.ip&&t.port===e.port&&t.priority===e.priority&&t.protocol===e.protocol&&t.type===e.type}));return i||e.addRemoteCandidate(t),!i}function Fe(e,t){var i=new Error(t);return i.name=e,i.code={NotSupportedError:9,InvalidStateError:11,InvalidAccessError:15,TypeError:void 0,OperationError:void 0}[e],i}var je=function(e,t){function i(t,i){i.addTrack(t),i.dispatchEvent(new e.MediaStreamTrackEvent("addtrack",{track:t}))}function r(t,i,r,n){var s=new Event("track");s.track=i,s.receiver=r,s.transceiver={receiver:r},s.streams=n,e.setTimeout((function(){t._dispatchEvent("track",s)}))}var n=function(i){var r=this,n=document.createDocumentFragment();if(["addEventListener","removeEventListener","dispatchEvent"].forEach((function(e){r[e]=n[e].bind(n)})),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",i=JSON.parse(JSON.stringify(i||{})),this.usingBundle="max-bundle"===i.bundlePolicy,"negotiate"===i.rtcpMuxPolicy)throw Fe("NotSupportedError","rtcpMuxPolicy 'negotiate' is not supported");switch(i.rtcpMuxPolicy||(i.rtcpMuxPolicy="require"),i.iceTransportPolicy){case"all":case"relay":break;default:i.iceTransportPolicy="all"}switch(i.bundlePolicy){case"balanced":case"max-compat":case"max-bundle":break;default:i.bundlePolicy="balanced"}if(i.iceServers=function(e,t){var i=!1;return(e=JSON.parse(JSON.stringify(e))).filter((function(e){if(e&&(e.urls||e.url)){var r=e.urls||e.url;e.url&&!e.urls&&console.warn("RTCIceServer.url is deprecated! Use urls instead.");var n="string"==typeof r;return n&&(r=[r]),r=r.filter((function(e){return 0!==e.indexOf("turn:")||-1===e.indexOf("transport=udp")||-1!==e.indexOf("turn:[")||i?0===e.indexOf("stun:")&&t>=14393&&-1===e.indexOf("?transport=udp"):(i=!0,!0)})),delete e.url,e.urls=n?r[0]:r,!!r.length}}))}(i.iceServers||[],t),this._iceGatherers=[],i.iceCandidatePoolSize)for(var s=i.iceCandidatePoolSize;s>0;s--)this._iceGatherers.push(new e.RTCIceGatherer({iceServers:i.iceServers,gatherPolicy:i.iceTransportPolicy}));else i.iceCandidatePoolSize=0;this._config=i,this.transceivers=[],this._sdpSessionId=ke.generateSessionId(),this._sdpSessionVersion=0,this._dtlsRole=void 0,this._isClosed=!1};Object.defineProperty(n.prototype,"localDescription",{configurable:!0,get:function(){return this._localDescription}}),Object.defineProperty(n.prototype,"remoteDescription",{configurable:!0,get:function(){return this._remoteDescription}}),n.prototype.onicecandidate=null,n.prototype.onaddstream=null,n.prototype.ontrack=null,n.prototype.onremovestream=null,n.prototype.onsignalingstatechange=null,n.prototype.oniceconnectionstatechange=null,n.prototype.onconnectionstatechange=null,n.prototype.onicegatheringstatechange=null,n.prototype.onnegotiationneeded=null,n.prototype.ondatachannel=null,n.prototype._dispatchEvent=function(e,t){this._isClosed||(this.dispatchEvent(t),"function"==typeof this["on"+e]&&this["on"+e](t))},n.prototype._emitGatheringStateChange=function(){var e=new Event("icegatheringstatechange");this._dispatchEvent("icegatheringstatechange",e)},n.prototype.getConfiguration=function(){return this._config},n.prototype.getLocalStreams=function(){return this.localStreams},n.prototype.getRemoteStreams=function(){return this.remoteStreams},n.prototype._createTransceiver=function(e,t){var i=this.transceivers.length>0,r={track:null,iceGatherer:null,iceTransport:null,dtlsTransport:null,localCapabilities:null,remoteCapabilities:null,rtpSender:null,rtpReceiver:null,kind:e,mid:null,sendEncodingParameters:null,recvEncodingParameters:null,stream:null,associatedRemoteMediaStreams:[],wantReceive:!0};if(this.usingBundle&&i)r.iceTransport=this.transceivers[0].iceTransport,r.dtlsTransport=this.transceivers[0].dtlsTransport;else{var n=this._createIceAndDtlsTransports();r.iceTransport=n.iceTransport,r.dtlsTransport=n.dtlsTransport}return t||this.transceivers.push(r),r},n.prototype.addTrack=function(t,i){if(this._isClosed)throw Fe("InvalidStateError","Attempted to call addTrack on a closed peerconnection.");var r;if(this.transceivers.find((function(e){return e.track===t})))throw Fe("InvalidAccessError","Track already exists.");for(var n=0;n<this.transceivers.length;n++)this.transceivers[n].track||this.transceivers[n].kind!==t.kind||(r=this.transceivers[n]);return r||(r=this._createTransceiver(t.kind)),this._maybeFireNegotiationNeeded(),-1===this.localStreams.indexOf(i)&&this.localStreams.push(i),r.track=t,r.stream=i,r.rtpSender=new e.RTCRtpSender(t,r.dtlsTransport),r.rtpSender},n.prototype.addStream=function(e){var i=this;if(t>=15025)e.getTracks().forEach((function(t){i.addTrack(t,e)}));else{var r=e.clone();e.getTracks().forEach((function(e,t){var i=r.getTracks()[t];e.addEventListener("enabled",(function(e){i.enabled=e.enabled}))})),r.getTracks().forEach((function(e){i.addTrack(e,r)}))}},n.prototype.removeTrack=function(t){if(this._isClosed)throw Fe("InvalidStateError","Attempted to call removeTrack on a closed peerconnection.");if(!(t instanceof e.RTCRtpSender))throw new TypeError("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.");var i=this.transceivers.find((function(e){return e.rtpSender===t}));if(!i)throw Fe("InvalidAccessError","Sender was not created by this connection.");var r=i.stream;i.rtpSender.stop(),i.rtpSender=null,i.track=null,i.stream=null,-1===this.transceivers.map((function(e){return e.stream})).indexOf(r)&&this.localStreams.indexOf(r)>-1&&this.localStreams.splice(this.localStreams.indexOf(r),1),this._maybeFireNegotiationNeeded()},n.prototype.removeStream=function(e){var t=this;e.getTracks().forEach((function(e){var i=t.getSenders().find((function(t){return t.track===e}));i&&t.removeTrack(i)}))},n.prototype.getSenders=function(){return this.transceivers.filter((function(e){return!!e.rtpSender})).map((function(e){return e.rtpSender}))},n.prototype.getReceivers=function(){return this.transceivers.filter((function(e){return!!e.rtpReceiver})).map((function(e){return e.rtpReceiver}))},n.prototype._createIceGatherer=function(t,i){var r=this;if(i&&t>0)return this.transceivers[0].iceGatherer;if(this._iceGatherers.length)return this._iceGatherers.shift();var n=new e.RTCIceGatherer({iceServers:this._config.iceServers,gatherPolicy:this._config.iceTransportPolicy});return Object.defineProperty(n,"state",{value:"new",writable:!0}),this.transceivers[t].bufferedCandidateEvents=[],this.transceivers[t].bufferCandidates=function(e){var i=!e.candidate||0===Object.keys(e.candidate).length;n.state=i?"completed":"gathering",null!==r.transceivers[t].bufferedCandidateEvents&&r.transceivers[t].bufferedCandidateEvents.push(e)},n.addEventListener("localcandidate",this.transceivers[t].bufferCandidates),n},n.prototype._gather=function(t,i){var r=this,n=this.transceivers[i].iceGatherer;if(!n.onlocalcandidate){var s=this.transceivers[i].bufferedCandidateEvents;this.transceivers[i].bufferedCandidateEvents=null,n.removeEventListener("localcandidate",this.transceivers[i].bufferCandidates),n.onlocalcandidate=function(e){if(!(r.usingBundle&&i>0)){var s=new Event("icecandidate");s.candidate={sdpMid:t,sdpMLineIndex:i};var o=e.candidate,a=!o||0===Object.keys(o).length;if(a)"new"!==n.state&&"gathering"!==n.state||(n.state="completed");else{"new"===n.state&&(n.state="gathering"),o.component=1,o.ufrag=n.getLocalParameters().usernameFragment;var l=ke.writeCandidate(o);s.candidate=Object.assign(s.candidate,ke.parseCandidate(l)),s.candidate.candidate=l,s.candidate.toJSON=function(){return{candidate:s.candidate.candidate,sdpMid:s.candidate.sdpMid,sdpMLineIndex:s.candidate.sdpMLineIndex,usernameFragment:s.candidate.usernameFragment}}}var _=ke.getMediaSections(r._localDescription.sdp);_[s.candidate.sdpMLineIndex]+=a?"a=end-of-candidates\r\n":"a="+s.candidate.candidate+"\r\n",r._localDescription.sdp=ke.getDescription(r._localDescription.sdp)+_.join("");var c=r.transceivers.every((function(e){return e.iceGatherer&&"completed"===e.iceGatherer.state}));"gathering"!==r.iceGatheringState&&(r.iceGatheringState="gathering",r._emitGatheringStateChange()),a||r._dispatchEvent("icecandidate",s),c&&(r._dispatchEvent("icecandidate",new Event("icecandidate")),r.iceGatheringState="complete",r._emitGatheringStateChange())}},e.setTimeout((function(){s.forEach((function(e){n.onlocalcandidate(e)}))}),0)}},n.prototype._createIceAndDtlsTransports=function(){var t=this,i=new e.RTCIceTransport(null);i.onicestatechange=function(){t._updateIceConnectionState(),t._updateConnectionState()};var r=new e.RTCDtlsTransport(i);return r.ondtlsstatechange=function(){t._updateConnectionState()},r.onerror=function(){Object.defineProperty(r,"state",{value:"failed",writable:!0}),t._updateConnectionState()},{iceTransport:i,dtlsTransport:r}},n.prototype._disposeIceAndDtlsTransports=function(e){var t=this.transceivers[e].iceGatherer;t&&(delete t.onlocalcandidate,delete this.transceivers[e].iceGatherer);var i=this.transceivers[e].iceTransport;i&&(delete i.onicestatechange,delete this.transceivers[e].iceTransport);var r=this.transceivers[e].dtlsTransport;r&&(delete r.ondtlsstatechange,delete r.onerror,delete this.transceivers[e].dtlsTransport)},n.prototype._transceive=function(e,i,r){var n=Be(e.localCapabilities,e.remoteCapabilities);i&&e.rtpSender&&(n.encodings=e.sendEncodingParameters,n.rtcp={cname:ke.localCName,compound:e.rtcpParameters.compound},e.recvEncodingParameters.length&&(n.rtcp.ssrc=e.recvEncodingParameters[0].ssrc),e.rtpSender.send(n)),r&&e.rtpReceiver&&n.codecs.length>0&&("video"===e.kind&&e.recvEncodingParameters&&t<15019&&e.recvEncodingParameters.forEach((function(e){delete e.rtx})),e.recvEncodingParameters.length?n.encodings=e.recvEncodingParameters:n.encodings=[{}],n.rtcp={compound:e.rtcpParameters.compound},e.rtcpParameters.cname&&(n.rtcp.cname=e.rtcpParameters.cname),e.sendEncodingParameters.length&&(n.rtcp.ssrc=e.sendEncodingParameters[0].ssrc),e.rtpReceiver.receive(n))},n.prototype.setLocalDescription=function(e){var t,i,r=this;if(-1===["offer","answer"].indexOf(e.type))return Promise.reject(Fe("TypeError",'Unsupported type "'+e.type+'"'));if(!Ve("setLocalDescription",e.type,r.signalingState)||r._isClosed)return Promise.reject(Fe("InvalidStateError","Can not set local "+e.type+" in state "+r.signalingState));if("offer"===e.type)t=ke.splitSections(e.sdp),i=t.shift(),t.forEach((function(e,t){var i=ke.parseRtpParameters(e);r.transceivers[t].localCapabilities=i})),r.transceivers.forEach((function(e,t){r._gather(e.mid,t)}));else if("answer"===e.type){t=ke.splitSections(r._remoteDescription.sdp),i=t.shift();var n=ke.matchPrefix(i,"a=ice-lite").length>0;t.forEach((function(e,t){var s=r.transceivers[t],o=s.iceGatherer,a=s.iceTransport,l=s.dtlsTransport,_=s.localCapabilities,c=s.remoteCapabilities;if(!(ke.isRejected(e)&&0===ke.matchPrefix(e,"a=bundle-only").length)&&!s.rejected){var d=ke.getIceParameters(e,i),u=ke.getDtlsParameters(e,i);n&&(u.role="server"),r.usingBundle&&0!==t||(r._gather(s.mid,t),"new"===a.state&&a.start(o,d,n?"controlling":"controlled"),"new"===l.state&&l.start(u));var h=Be(_,c);r._transceive(s,h.codecs.length>0,!1)}}))}return r._localDescription={type:e.type,sdp:e.sdp},"offer"===e.type?r._updateSignalingState("have-local-offer"):r._updateSignalingState("stable"),Promise.resolve()},n.prototype.setRemoteDescription=function(n){var s=this;if(-1===["offer","answer"].indexOf(n.type))return Promise.reject(Fe("TypeError",'Unsupported type "'+n.type+'"'));if(!Ve("setRemoteDescription",n.type,s.signalingState)||s._isClosed)return Promise.reject(Fe("InvalidStateError","Can not set remote "+n.type+" in state "+s.signalingState));var o={};s.remoteStreams.forEach((function(e){o[e.id]=e}));var a=[],l=ke.splitSections(n.sdp),_=l.shift(),c=ke.matchPrefix(_,"a=ice-lite").length>0,d=ke.matchPrefix(_,"a=group:BUNDLE ").length>0;s.usingBundle=d;var u=ke.matchPrefix(_,"a=ice-options:")[0];return s.canTrickleIceCandidates=!!u&&u.substr(14).split(" ").indexOf("trickle")>=0,l.forEach((function(r,l){var u=ke.splitLines(r),h=ke.getKind(r),g=ke.isRejected(r)&&0===ke.matchPrefix(r,"a=bundle-only").length,p=u[0].substr(2).split(" ")[2],f=ke.getDirection(r,_),E=ke.parseMsid(r),I=ke.getMid(r)||ke.generateIdentifier();if(g||"application"===h&&("DTLS/SCTP"===p||"UDP/DTLS/SCTP"===p))s.transceivers[l]={mid:I,kind:h,protocol:p,rejected:!0};else{var T,m,R,S,C,L,O,v,b;!g&&s.transceivers[l]&&s.transceivers[l].rejected&&(s.transceivers[l]=s._createTransceiver(h,!0));var A,N,y=ke.parseRtpParameters(r);g||(A=ke.getIceParameters(r,_),(N=ke.getDtlsParameters(r,_)).role="client"),O=ke.parseRtpEncodingParameters(r);var P=ke.parseRtcpParameters(r),U=ke.matchPrefix(r,"a=end-of-candidates",_).length>0,D=ke.matchPrefix(r,"a=candidate:").map((function(e){return ke.parseCandidate(e)})).filter((function(e){return 1===e.component}));if(("offer"===n.type||"answer"===n.type)&&!g&&d&&l>0&&s.transceivers[l]&&(s._disposeIceAndDtlsTransports(l),s.transceivers[l].iceGatherer=s.transceivers[0].iceGatherer,s.transceivers[l].iceTransport=s.transceivers[0].iceTransport,s.transceivers[l].dtlsTransport=s.transceivers[0].dtlsTransport,s.transceivers[l].rtpSender&&s.transceivers[l].rtpSender.setTransport(s.transceivers[0].dtlsTransport),s.transceivers[l].rtpReceiver&&s.transceivers[l].rtpReceiver.setTransport(s.transceivers[0].dtlsTransport)),"offer"!==n.type||g){if("answer"===n.type&&!g){m=(T=s.transceivers[l]).iceGatherer,R=T.iceTransport,S=T.dtlsTransport,C=T.rtpReceiver,L=T.sendEncodingParameters,v=T.localCapabilities,s.transceivers[l].recvEncodingParameters=O,s.transceivers[l].remoteCapabilities=y,s.transceivers[l].rtcpParameters=P,D.length&&"new"===R.state&&(!c&&!U||d&&0!==l?D.forEach((function(e){Ge(T.iceTransport,e)})):R.setRemoteCandidates(D)),d&&0!==l||("new"===R.state&&R.start(m,A,"controlling"),"new"===S.state&&S.start(N)),!Be(T.localCapabilities,T.remoteCapabilities).codecs.filter((function(e){return"rtx"===e.name.toLowerCase()})).length&&T.sendEncodingParameters[0].rtx&&delete T.sendEncodingParameters[0].rtx,s._transceive(T,"sendrecv"===f||"recvonly"===f,"sendrecv"===f||"sendonly"===f),!C||"sendrecv"!==f&&"sendonly"!==f?delete T.rtpReceiver:(b=C.track,E?(o[E.stream]||(o[E.stream]=new e.MediaStream),i(b,o[E.stream]),a.push([b,C,o[E.stream]])):(o.default||(o.default=new e.MediaStream),i(b,o.default),a.push([b,C,o.default])))}}else{(T=s.transceivers[l]||s._createTransceiver(h)).mid=I,T.iceGatherer||(T.iceGatherer=s._createIceGatherer(l,d)),D.length&&"new"===T.iceTransport.state&&(!U||d&&0!==l?D.forEach((function(e){Ge(T.iceTransport,e)})):T.iceTransport.setRemoteCandidates(D)),v=e.RTCRtpReceiver.getCapabilities(h),t<15019&&(v.codecs=v.codecs.filter((function(e){return"rtx"!==e.name}))),L=T.sendEncodingParameters||[{ssrc:1001*(2*l+2)}];var M,w=!1;if("sendrecv"===f||"sendonly"===f){if(w=!T.rtpReceiver,C=T.rtpReceiver||new e.RTCRtpReceiver(T.dtlsTransport,h),w)b=C.track,E&&"-"===E.stream||(E?(o[E.stream]||(o[E.stream]=new e.MediaStream,Object.defineProperty(o[E.stream],"id",{get:function(){return E.stream}})),Object.defineProperty(b,"id",{get:function(){return E.track}}),M=o[E.stream]):(o.default||(o.default=new e.MediaStream),M=o.default)),M&&(i(b,M),T.associatedRemoteMediaStreams.push(M)),a.push([b,C,M])}else T.rtpReceiver&&T.rtpReceiver.track&&(T.associatedRemoteMediaStreams.forEach((function(t){var i=t.getTracks().find((function(e){return e.id===T.rtpReceiver.track.id}));i&&function(t,i){i.removeTrack(t),i.dispatchEvent(new e.MediaStreamTrackEvent("removetrack",{track:t}))}(i,t)})),T.associatedRemoteMediaStreams=[]);T.localCapabilities=v,T.remoteCapabilities=y,T.rtpReceiver=C,T.rtcpParameters=P,T.sendEncodingParameters=L,T.recvEncodingParameters=O,s._transceive(s.transceivers[l],!1,w)}}})),void 0===s._dtlsRole&&(s._dtlsRole="offer"===n.type?"active":"passive"),s._remoteDescription={type:n.type,sdp:n.sdp},"offer"===n.type?s._updateSignalingState("have-remote-offer"):s._updateSignalingState("stable"),Object.keys(o).forEach((function(t){var i=o[t];if(i.getTracks().length){if(-1===s.remoteStreams.indexOf(i)){s.remoteStreams.push(i);var n=new Event("addstream");n.stream=i,e.setTimeout((function(){s._dispatchEvent("addstream",n)}))}a.forEach((function(e){var t=e[0],n=e[1];i.id===e[2].id&&r(s,t,n,[i])}))}})),a.forEach((function(e){e[2]||r(s,e[0],e[1],[])})),e.setTimeout((function(){s&&s.transceivers&&s.transceivers.forEach((function(e){e.iceTransport&&"new"===e.iceTransport.state&&e.iceTransport.getRemoteCandidates().length>0&&(console.warn("Timeout for addRemoteCandidate. Consider sending an end-of-candidates notification"),e.iceTransport.addRemoteCandidate({}))}))}),4e3),Promise.resolve()},n.prototype.close=function(){this.transceivers.forEach((function(e){e.iceTransport&&e.iceTransport.stop(),e.dtlsTransport&&e.dtlsTransport.stop(),e.rtpSender&&e.rtpSender.stop(),e.rtpReceiver&&e.rtpReceiver.stop()})),this._isClosed=!0,this._updateSignalingState("closed")},n.prototype._updateSignalingState=function(e){this.signalingState=e;var t=new Event("signalingstatechange");this._dispatchEvent("signalingstatechange",t)},n.prototype._maybeFireNegotiationNeeded=function(){var t=this;"stable"===this.signalingState&&!0!==this.needNegotiation&&(this.needNegotiation=!0,e.setTimeout((function(){if(t.needNegotiation){t.needNegotiation=!1;var e=new Event("negotiationneeded");t._dispatchEvent("negotiationneeded",e)}}),0))},n.prototype._updateIceConnectionState=function(){var e,t={new:0,closed:0,checking:0,connected:0,completed:0,disconnected:0,failed:0};if(this.transceivers.forEach((function(e){e.iceTransport&&!e.rejected&&t[e.iceTransport.state]++})),e="new",t.failed>0?e="failed":t.checking>0?e="checking":t.disconnected>0?e="disconnected":t.new>0?e="new":t.connected>0?e="connected":t.completed>0&&(e="completed"),e!==this.iceConnectionState){this.iceConnectionState=e;var i=new Event("iceconnectionstatechange");this._dispatchEvent("iceconnectionstatechange",i)}},n.prototype._updateConnectionState=function(){var e,t={new:0,closed:0,connecting:0,connected:0,completed:0,disconnected:0,failed:0};if(this.transceivers.forEach((function(e){e.iceTransport&&e.dtlsTransport&&!e.rejected&&(t[e.iceTransport.state]++,t[e.dtlsTransport.state]++)})),t.connected+=t.completed,e="new",t.failed>0?e="failed":t.connecting>0?e="connecting":t.disconnected>0?e="disconnected":t.new>0?e="new":t.connected>0&&(e="connected"),e!==this.connectionState){this.connectionState=e;var i=new Event("connectionstatechange");this._dispatchEvent("connectionstatechange",i)}},n.prototype.createOffer=function(){var i=this;if(i._isClosed)return Promise.reject(Fe("InvalidStateError","Can not call createOffer after close"));var r=i.transceivers.filter((function(e){return"audio"===e.kind})).length,n=i.transceivers.filter((function(e){return"video"===e.kind})).length,s=arguments[0];if(s){if(s.mandatory||s.optional)throw new TypeError("Legacy mandatory/optional constraints not supported.");void 0!==s.offerToReceiveAudio&&(r=!0===s.offerToReceiveAudio?1:!1===s.offerToReceiveAudio?0:s.offerToReceiveAudio),void 0!==s.offerToReceiveVideo&&(n=!0===s.offerToReceiveVideo?1:!1===s.offerToReceiveVideo?0:s.offerToReceiveVideo)}for(i.transceivers.forEach((function(e){"audio"===e.kind?--r<0&&(e.wantReceive=!1):"video"===e.kind&&--n<0&&(e.wantReceive=!1)}));r>0||n>0;)r>0&&(i._createTransceiver("audio"),r--),n>0&&(i._createTransceiver("video"),n--);var o=ke.writeSessionBoilerplate(i._sdpSessionId,i._sdpSessionVersion++);i.transceivers.forEach((function(r,n){var s=r.track,o=r.kind,a=r.mid||ke.generateIdentifier();r.mid=a,r.iceGatherer||(r.iceGatherer=i._createIceGatherer(n,i.usingBundle));var l=e.RTCRtpSender.getCapabilities(o);t<15019&&(l.codecs=l.codecs.filter((function(e){return"rtx"!==e.name}))),l.codecs.forEach((function(e){"H264"===e.name&&void 0===e.parameters["level-asymmetry-allowed"]&&(e.parameters["level-asymmetry-allowed"]="1"),r.remoteCapabilities&&r.remoteCapabilities.codecs&&r.remoteCapabilities.codecs.forEach((function(t){e.name.toLowerCase()===t.name.toLowerCase()&&e.clockRate===t.clockRate&&(e.preferredPayloadType=t.payloadType)}))})),l.headerExtensions.forEach((function(e){(r.remoteCapabilities&&r.remoteCapabilities.headerExtensions||[]).forEach((function(t){e.uri===t.uri&&(e.id=t.id)}))}));var _=r.sendEncodingParameters||[{ssrc:1001*(2*n+1)}];s&&t>=15019&&"video"===o&&!_[0].rtx&&(_[0].rtx={ssrc:_[0].ssrc+1}),r.wantReceive&&(r.rtpReceiver=new e.RTCRtpReceiver(r.dtlsTransport,o)),r.localCapabilities=l,r.sendEncodingParameters=_})),"max-compat"!==i._config.bundlePolicy&&(o+="a=group:BUNDLE "+i.transceivers.map((function(e){return e.mid})).join(" ")+"\r\n"),o+="a=ice-options:trickle\r\n",i.transceivers.forEach((function(e,t){o+=xe(e,e.localCapabilities,"offer",e.stream,i._dtlsRole),o+="a=rtcp-rsize\r\n",!e.iceGatherer||"new"===i.iceGatheringState||0!==t&&i.usingBundle||(e.iceGatherer.getLocalCandidates().forEach((function(e){e.component=1,o+="a="+ke.writeCandidate(e)+"\r\n"})),"completed"===e.iceGatherer.state&&(o+="a=end-of-candidates\r\n"))}));var a=new e.RTCSessionDescription({type:"offer",sdp:o});return Promise.resolve(a)},n.prototype.createAnswer=function(){var i=this;if(i._isClosed)return Promise.reject(Fe("InvalidStateError","Can not call createAnswer after close"));if("have-remote-offer"!==i.signalingState&&"have-local-pranswer"!==i.signalingState)return Promise.reject(Fe("InvalidStateError","Can not call createAnswer in signalingState "+i.signalingState));var r=ke.writeSessionBoilerplate(i._sdpSessionId,i._sdpSessionVersion++);i.usingBundle&&(r+="a=group:BUNDLE "+i.transceivers.map((function(e){return e.mid})).join(" ")+"\r\n"),r+="a=ice-options:trickle\r\n";var n=ke.getMediaSections(i._remoteDescription.sdp).length;i.transceivers.forEach((function(e,s){if(!(s+1>n)){if(e.rejected)return"application"===e.kind?"DTLS/SCTP"===e.protocol?r+="m=application 0 DTLS/SCTP 5000\r\n":r+="m=application 0 "+e.protocol+" webrtc-datachannel\r\n":"audio"===e.kind?r+="m=audio 0 UDP/TLS/RTP/SAVPF 0\r\na=rtpmap:0 PCMU/8000\r\n":"video"===e.kind&&(r+="m=video 0 UDP/TLS/RTP/SAVPF 120\r\na=rtpmap:120 VP8/90000\r\n"),void(r+="c=IN IP4 0.0.0.0\r\na=inactive\r\na=mid:"+e.mid+"\r\n");var o;if(e.stream)"audio"===e.kind?o=e.stream.getAudioTracks()[0]:"video"===e.kind&&(o=e.stream.getVideoTracks()[0]),o&&t>=15019&&"video"===e.kind&&!e.sendEncodingParameters[0].rtx&&(e.sendEncodingParameters[0].rtx={ssrc:e.sendEncodingParameters[0].ssrc+1});var a=Be(e.localCapabilities,e.remoteCapabilities);!a.codecs.filter((function(e){return"rtx"===e.name.toLowerCase()})).length&&e.sendEncodingParameters[0].rtx&&delete e.sendEncodingParameters[0].rtx,r+=xe(e,a,"answer",e.stream,i._dtlsRole),e.rtcpParameters&&e.rtcpParameters.reducedSize&&(r+="a=rtcp-rsize\r\n")}}));var s=new e.RTCSessionDescription({type:"answer",sdp:r});return Promise.resolve(s)},n.prototype.addIceCandidate=function(e){var t,i=this;return e&&void 0===e.sdpMLineIndex&&!e.sdpMid?Promise.reject(new TypeError("sdpMLineIndex or sdpMid required")):new Promise((function(r,n){if(!i._remoteDescription)return n(Fe("InvalidStateError","Can not add ICE candidate without a remote description"));if(e&&""!==e.candidate){var s=e.sdpMLineIndex;if(e.sdpMid)for(var o=0;o<i.transceivers.length;o++)if(i.transceivers[o].mid===e.sdpMid){s=o;break}var a=i.transceivers[s];if(!a)return n(Fe("OperationError","Can not add ICE candidate"));if(a.rejected)return r();var l=Object.keys(e.candidate).length>0?ke.parseCandidate(e.candidate):{};if("tcp"===l.protocol&&(0===l.port||9===l.port))return r();if(l.component&&1!==l.component)return r();if((0===s||s>0&&a.iceTransport!==i.transceivers[0].iceTransport)&&!Ge(a.iceTransport,l))return n(Fe("OperationError","Can not add ICE candidate"));var _=e.candidate.trim();0===_.indexOf("a=")&&(_=_.substr(2)),(t=ke.getMediaSections(i._remoteDescription.sdp))[s]+="a="+(l.type?_:"end-of-candidates")+"\r\n",i._remoteDescription.sdp=ke.getDescription(i._remoteDescription.sdp)+t.join("")}else for(var c=0;c<i.transceivers.length&&(i.transceivers[c].rejected||(i.transceivers[c].iceTransport.addRemoteCandidate({}),(t=ke.getMediaSections(i._remoteDescription.sdp))[c]+="a=end-of-candidates\r\n",i._remoteDescription.sdp=ke.getDescription(i._remoteDescription.sdp)+t.join(""),!i.usingBundle));c++);r()}))},n.prototype.getStats=function(t){if(t&&t instanceof e.MediaStreamTrack){var i=null;if(this.transceivers.forEach((function(e){e.rtpSender&&e.rtpSender.track===t?i=e.rtpSender:e.rtpReceiver&&e.rtpReceiver.track===t&&(i=e.rtpReceiver)})),!i)throw Fe("InvalidAccessError","Invalid selector.");return i.getStats()}var r=[];return this.transceivers.forEach((function(e){["rtpSender","rtpReceiver","iceGatherer","iceTransport","dtlsTransport"].forEach((function(t){e[t]&&r.push(e[t].getStats())}))})),Promise.all(r).then((function(e){var t=new Map;return e.forEach((function(e){e.forEach((function(e){t.set(e.id,e)}))})),t}))};["RTCRtpSender","RTCRtpReceiver","RTCIceGatherer","RTCIceTransport","RTCDtlsTransport"].forEach((function(t){var i=e[t];if(i&&i.prototype&&i.prototype.getStats){var r=i.prototype.getStats;i.prototype.getStats=function(){return r.apply(this).then((function(e){var t=new Map;return Object.keys(e).forEach((function(i){var r;e[i].type={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[(r=e[i]).type]||r.type,t.set(i,e[i])})),t}))}}}));var s=["createOffer","createAnswer"];return s.forEach((function(e){var t=n.prototype[e];n.prototype[e]=function(){var e=arguments;return"function"==typeof e[0]||"function"==typeof e[1]?t.apply(this,[arguments[2]]).then((function(t){"function"==typeof e[0]&&e[0].apply(null,[t])}),(function(t){"function"==typeof e[1]&&e[1].apply(null,[t])})):t.apply(this,arguments)}})),(s=["setLocalDescription","setRemoteDescription","addIceCandidate"]).forEach((function(e){var t=n.prototype[e];n.prototype[e]=function(){var e=arguments;return"function"==typeof e[1]||"function"==typeof e[2]?t.apply(this,arguments).then((function(){"function"==typeof e[1]&&e[1].apply(null)}),(function(t){"function"==typeof e[2]&&e[2].apply(null,[t])})):t.apply(this,arguments)}})),["getStats"].forEach((function(e){var t=n.prototype[e];n.prototype[e]=function(){var e=arguments;return"function"==typeof e[1]?t.apply(this,arguments).then((function(){"function"==typeof e[1]&&e[1].apply(null)})):t.apply(this,arguments)}})),n};function He(e){const t=e&&e.navigator,i=t.mediaDevices.getUserMedia.bind(t.mediaDevices);t.mediaDevices.getUserMedia=function(e){return i(e).catch((e=>Promise.reject(function(e){return{name:{PermissionDeniedError:"NotAllowedError"}[e.name]||e.name,message:e.message,constraint:e.constraint,toString(){return this.name}}}(e))))}}function Je(e){"getDisplayMedia"in e.navigator&&e.navigator.mediaDevices&&(e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||(e.navigator.mediaDevices.getDisplayMedia=e.navigator.getDisplayMedia.bind(e.navigator)))}function $e(e,t){if(e.RTCIceGatherer&&(e.RTCIceCandidate||(e.RTCIceCandidate=function(e){return e}),e.RTCSessionDescription||(e.RTCSessionDescription=function(e){return e}),t.version<15025)){const t=Object.getOwnPropertyDescriptor(e.MediaStreamTrack.prototype,"enabled");Object.defineProperty(e.MediaStreamTrack.prototype,"enabled",{set(e){t.set.call(this,e);const i=new Event("enabled");i.enabled=e,this.dispatchEvent(i)}})}e.RTCRtpSender&&!("dtmf"in e.RTCRtpSender.prototype)&&Object.defineProperty(e.RTCRtpSender.prototype,"dtmf",{get(){return void 0===this._dtmf&&("audio"===this.track.kind?this._dtmf=new e.RTCDtmfSender(this):"video"===this.track.kind&&(this._dtmf=null)),this._dtmf}}),e.RTCDtmfSender&&!e.RTCDTMFSender&&(e.RTCDTMFSender=e.RTCDtmfSender);const i=je(e,t.version);e.RTCPeerConnection=function(e){return e&&e.iceServers&&(e.iceServers=function(e,t){let i=!1;return(e=JSON.parse(JSON.stringify(e))).filter((e=>{if(e&&(e.urls||e.url)){let t=e.urls||e.url;e.url&&!e.urls&&Ee("RTCIceServer.url","RTCIceServer.urls");const r="string"==typeof t;return r&&(t=[t]),t=t.filter((e=>{if(0===e.indexOf("stun:"))return!1;const t=e.startsWith("turn")&&!e.startsWith("turn:[")&&e.includes("transport=udp");return t&&!i?(i=!0,!0):t&&!i})),delete e.url,e.urls=r?t[0]:t,!!t.length}}))}(e.iceServers,t.version),fe("ICE servers after filtering:",e.iceServers)),new i(e)},e.RTCPeerConnection.prototype=i.prototype}function Ke(e){e.RTCRtpSender&&!("replaceTrack"in e.RTCRtpSender.prototype)&&(e.RTCRtpSender.prototype.replaceTrack=e.RTCRtpSender.prototype.setTrack)}var Ye=Object.freeze({__proto__:null,shimPeerConnection:$e,shimReplaceTrack:Ke,shimGetUserMedia:He,shimGetDisplayMedia:Je});function qe(e,t){const i=e&&e.navigator,r=e&&e.MediaStreamTrack;if(i.getUserMedia=function(e,t,r){Ee("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),i.mediaDevices.getUserMedia(e).then(t,r)},!(t.version>55&&"autoGainControl"in i.mediaDevices.getSupportedConstraints())){const e=function(e,t,i){t in e&&!(i in e)&&(e[i]=e[t],delete e[t])},t=i.mediaDevices.getUserMedia.bind(i.mediaDevices);if(i.mediaDevices.getUserMedia=function(i){return"object"==typeof i&&"object"==typeof i.audio&&(i=JSON.parse(JSON.stringify(i)),e(i.audio,"autoGainControl","mozAutoGainControl"),e(i.audio,"noiseSuppression","mozNoiseSuppression")),t(i)},r&&r.prototype.getSettings){const t=r.prototype.getSettings;r.prototype.getSettings=function(){const i=t.apply(this,arguments);return e(i,"mozAutoGainControl","autoGainControl"),e(i,"mozNoiseSuppression","noiseSuppression"),i}}if(r&&r.prototype.applyConstraints){const t=r.prototype.applyConstraints;r.prototype.applyConstraints=function(i){return"audio"===this.kind&&"object"==typeof i&&(i=JSON.parse(JSON.stringify(i)),e(i,"autoGainControl","mozAutoGainControl"),e(i,"noiseSuppression","mozNoiseSuppression")),t.apply(this,[i])}}}}function We(e){"object"==typeof e&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&Object.defineProperty(e.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function ze(e,t){if("object"!=typeof e||!e.RTCPeerConnection&&!e.mozRTCPeerConnection)return;!e.RTCPeerConnection&&e.mozRTCPeerConnection&&(e.RTCPeerConnection=e.mozRTCPeerConnection),t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach((function(t){const i=e.RTCPeerConnection.prototype[t],r={[t](){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),i.apply(this,arguments)}};e.RTCPeerConnection.prototype[t]=r[t]}));const i={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"},r=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){const[e,n,s]=arguments;return r.apply(this,[e||null]).then((e=>{if(t.version<53&&!n)try{e.forEach((e=>{e.type=i[e.type]||e.type}))}catch(t){if("TypeError"!==t.name)throw t;e.forEach(((t,r)=>{e.set(r,Object.assign({},t,{type:i[t.type]||t.type}))}))}return e})).then(n,s)}}function Qe(e){if("object"!=typeof e||!e.RTCPeerConnection||!e.RTCRtpSender)return;if(e.RTCRtpSender&&"getStats"in e.RTCRtpSender.prototype)return;const t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){const e=t.apply(this,[]);return e.forEach((e=>e._pc=this)),e});const i=e.RTCPeerConnection.prototype.addTrack;i&&(e.RTCPeerConnection.prototype.addTrack=function(){const e=i.apply(this,arguments);return e._pc=this,e}),e.RTCRtpSender.prototype.getStats=function(){return this.track?this._pc.getStats(this.track):Promise.resolve(new Map)}}function Ze(e){if("object"!=typeof e||!e.RTCPeerConnection||!e.RTCRtpSender)return;if(e.RTCRtpSender&&"getStats"in e.RTCRtpReceiver.prototype)return;const t=e.RTCPeerConnection.prototype.getReceivers;t&&(e.RTCPeerConnection.prototype.getReceivers=function(){const e=t.apply(this,[]);return e.forEach((e=>e._pc=this)),e}),he(e,"track",(e=>(e.receiver._pc=e.srcElement,e))),e.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}function Xe(e){e.RTCPeerConnection&&!("removeStream"in e.RTCPeerConnection.prototype)&&(e.RTCPeerConnection.prototype.removeStream=function(e){Ee("removeStream","removeTrack"),this.getSenders().forEach((t=>{t.track&&e.getTracks().includes(t.track)&&this.removeTrack(t)}))})}function et(e){e.DataChannel&&!e.RTCDataChannel&&(e.RTCDataChannel=e.DataChannel)}function tt(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype.addTransceiver;t&&(e.RTCPeerConnection.prototype.addTransceiver=function(){this.setParametersPromises=[];const e=arguments[1],i=e&&"sendEncodings"in e;i&&e.sendEncodings.forEach((e=>{if("rid"in e){if(!/^[a-z0-9]{0,16}$/i.test(e.rid))throw new TypeError("Invalid RID value provided.")}if("scaleResolutionDownBy"in e&&!(parseFloat(e.scaleResolutionDownBy)>=1))throw new RangeError("scale_resolution_down_by must be >= 1.0");if("maxFramerate"in e&&!(parseFloat(e.maxFramerate)>=0))throw new RangeError("max_framerate must be >= 0.0")}));const r=t.apply(this,arguments);if(i){const{sender:t}=r,i=t.getParameters();(!("encodings"in i)||1===i.encodings.length&&0===Object.keys(i.encodings[0]).length)&&(i.encodings=e.sendEncodings,t.sendEncodings=e.sendEncodings,this.setParametersPromises.push(t.setParameters(i).then((()=>{delete t.sendEncodings})).catch((()=>{delete t.sendEncodings}))))}return r})}function it(e){if("object"!=typeof e||!e.RTCRtpSender)return;const t=e.RTCRtpSender.prototype.getParameters;t&&(e.RTCRtpSender.prototype.getParameters=function(){const e=t.apply(this,arguments);return"encodings"in e||(e.encodings=[].concat(this.sendEncodings||[{}])),e})}function rt(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then((()=>t.apply(this,arguments))).finally((()=>{this.setParametersPromises=[]})):t.apply(this,arguments)}}function nt(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype.createAnswer;e.RTCPeerConnection.prototype.createAnswer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then((()=>t.apply(this,arguments))).finally((()=>{this.setParametersPromises=[]})):t.apply(this,arguments)}}var st=Object.freeze({__proto__:null,shimOnTrack:We,shimPeerConnection:ze,shimSenderGetStats:Qe,shimReceiverGetStats:Ze,shimRemoveStream:Xe,shimRTCDataChannel:et,shimAddTransceiver:tt,shimGetParameters:it,shimCreateOffer:rt,shimCreateAnswer:nt,shimGetUserMedia:qe,shimGetDisplayMedia:function(e,t){e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||e.navigator.mediaDevices&&(e.navigator.mediaDevices.getDisplayMedia=function(i){if(!i||!i.video){const e=new DOMException("getDisplayMedia without video constraints is undefined");return e.name="NotFoundError",e.code=8,Promise.reject(e)}return!0===i.video?i.video={mediaSource:t}:i.video.mediaSource=t,e.navigator.mediaDevices.getUserMedia(i)})}});function ot(e){if("object"==typeof e&&e.RTCPeerConnection){if("getLocalStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getLocalStreams=function(){return this._localStreams||(this._localStreams=[]),this._localStreams}),!("addStream"in e.RTCPeerConnection.prototype)){const t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addStream=function(e){this._localStreams||(this._localStreams=[]),this._localStreams.includes(e)||this._localStreams.push(e),e.getAudioTracks().forEach((i=>t.call(this,i,e))),e.getVideoTracks().forEach((i=>t.call(this,i,e)))},e.RTCPeerConnection.prototype.addTrack=function(e,...i){return i&&i.forEach((e=>{this._localStreams?this._localStreams.includes(e)||this._localStreams.push(e):this._localStreams=[e]})),t.apply(this,arguments)}}"removeStream"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.removeStream=function(e){this._localStreams||(this._localStreams=[]);const t=this._localStreams.indexOf(e);if(-1===t)return;this._localStreams.splice(t,1);const i=e.getTracks();this.getSenders().forEach((e=>{i.includes(e.track)&&this.removeTrack(e)}))})}}function at(e){if("object"==typeof e&&e.RTCPeerConnection&&("getRemoteStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getRemoteStreams=function(){return this._remoteStreams?this._remoteStreams:[]}),!("onaddstream"in e.RTCPeerConnection.prototype))){Object.defineProperty(e.RTCPeerConnection.prototype,"onaddstream",{get(){return this._onaddstream},set(e){this._onaddstream&&(this.removeEventListener("addstream",this._onaddstream),this.removeEventListener("track",this._onaddstreampoly)),this.addEventListener("addstream",this._onaddstream=e),this.addEventListener("track",this._onaddstreampoly=e=>{e.streams.forEach((e=>{if(this._remoteStreams||(this._remoteStreams=[]),this._remoteStreams.includes(e))return;this._remoteStreams.push(e);const t=new Event("addstream");t.stream=e,this.dispatchEvent(t)}))})}});const t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){const e=this;return this._onaddstreampoly||this.addEventListener("track",this._onaddstreampoly=function(t){t.streams.forEach((t=>{if(e._remoteStreams||(e._remoteStreams=[]),e._remoteStreams.indexOf(t)>=0)return;e._remoteStreams.push(t);const i=new Event("addstream");i.stream=t,e.dispatchEvent(i)}))}),t.apply(e,arguments)}}}function lt(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype,i=t.createOffer,r=t.createAnswer,n=t.setLocalDescription,s=t.setRemoteDescription,o=t.addIceCandidate;t.createOffer=function(e,t){const r=arguments.length>=2?arguments[2]:arguments[0],n=i.apply(this,[r]);return t?(n.then(e,t),Promise.resolve()):n},t.createAnswer=function(e,t){const i=arguments.length>=2?arguments[2]:arguments[0],n=r.apply(this,[i]);return t?(n.then(e,t),Promise.resolve()):n};let a=function(e,t,i){const r=n.apply(this,[e]);return i?(r.then(t,i),Promise.resolve()):r};t.setLocalDescription=a,a=function(e,t,i){const r=s.apply(this,[e]);return i?(r.then(t,i),Promise.resolve()):r},t.setRemoteDescription=a,a=function(e,t,i){const r=o.apply(this,[e]);return i?(r.then(t,i),Promise.resolve()):r},t.addIceCandidate=a}function _t(e){const t=e&&e.navigator;if(t.mediaDevices&&t.mediaDevices.getUserMedia){const e=t.mediaDevices,i=e.getUserMedia.bind(e);t.mediaDevices.getUserMedia=e=>i(ct(e))}!t.getUserMedia&&t.mediaDevices&&t.mediaDevices.getUserMedia&&(t.getUserMedia=function(e,i,r){t.mediaDevices.getUserMedia(e).then(i,r)}.bind(t))}function ct(e){return e&&void 0!==e.video?Object.assign({},e,{video:Te(e.video)}):e}function dt(e){if(!e.RTCPeerConnection)return;const t=e.RTCPeerConnection;e.RTCPeerConnection=function(e,i){if(e&&e.iceServers){const t=[];for(let i=0;i<e.iceServers.length;i++){let r=e.iceServers[i];!r.hasOwnProperty("urls")&&r.hasOwnProperty("url")?(Ee("RTCIceServer.url","RTCIceServer.urls"),r=JSON.parse(JSON.stringify(r)),r.urls=r.url,delete r.url,t.push(r)):t.push(e.iceServers[i])}e.iceServers=t}return new t(e,i)},e.RTCPeerConnection.prototype=t.prototype,"generateCertificate"in t&&Object.defineProperty(e.RTCPeerConnection,"generateCertificate",{get:()=>t.generateCertificate})}function ut(e){"object"==typeof e&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&Object.defineProperty(e.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function ht(e){const t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(e){if(e){void 0!==e.offerToReceiveAudio&&(e.offerToReceiveAudio=!!e.offerToReceiveAudio);const t=this.getTransceivers().find((e=>"audio"===e.receiver.track.kind));!1===e.offerToReceiveAudio&&t?"sendrecv"===t.direction?t.setDirection?t.setDirection("sendonly"):t.direction="sendonly":"recvonly"===t.direction&&(t.setDirection?t.setDirection("inactive"):t.direction="inactive"):!0!==e.offerToReceiveAudio||t||this.addTransceiver("audio"),void 0!==e.offerToReceiveVideo&&(e.offerToReceiveVideo=!!e.offerToReceiveVideo);const i=this.getTransceivers().find((e=>"video"===e.receiver.track.kind));!1===e.offerToReceiveVideo&&i?"sendrecv"===i.direction?i.setDirection?i.setDirection("sendonly"):i.direction="sendonly":"recvonly"===i.direction&&(i.setDirection?i.setDirection("inactive"):i.direction="inactive"):!0!==e.offerToReceiveVideo||i||this.addTransceiver("video")}return t.apply(this,arguments)}}function gt(e){"object"!=typeof e||e.AudioContext||(e.AudioContext=e.webkitAudioContext)}var pt=Object.freeze({__proto__:null,shimLocalStreamsAPI:ot,shimRemoteStreamsAPI:at,shimCallbacksAPI:lt,shimGetUserMedia:_t,shimConstraints:ct,shimRTCIceServerUrls:dt,shimTrackEventTransceiver:ut,shimCreateOfferLegacy:ht,shimAudioContext:gt});function ft(e){if(!e.RTCIceCandidate||e.RTCIceCandidate&&"foundation"in e.RTCIceCandidate.prototype)return;const t=e.RTCIceCandidate;e.RTCIceCandidate=function(e){if("object"==typeof e&&e.candidate&&0===e.candidate.indexOf("a=")&&((e=JSON.parse(JSON.stringify(e))).candidate=e.candidate.substr(2)),e.candidate&&e.candidate.length){const i=new t(e),r=ke.parseCandidate(e.candidate),n=Object.assign(i,r);return n.toJSON=function(){return{candidate:n.candidate,sdpMid:n.sdpMid,sdpMLineIndex:n.sdpMLineIndex,usernameFragment:n.usernameFragment}},n}return new t(e)},e.RTCIceCandidate.prototype=t.prototype,he(e,"icecandidate",(t=>(t.candidate&&Object.defineProperty(t,"candidate",{value:new e.RTCIceCandidate(t.candidate),writable:"false"}),t)))}function Et(e,t){if(!e.RTCPeerConnection)return;"sctp"in e.RTCPeerConnection.prototype||Object.defineProperty(e.RTCPeerConnection.prototype,"sctp",{get(){return void 0===this._sctp?null:this._sctp}});const i=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){if(this._sctp=null,"chrome"===t.browser&&t.version>=76){const{sdpSemantics:e}=this.getConfiguration();"plan-b"===e&&Object.defineProperty(this,"sctp",{get(){return void 0===this._sctp?null:this._sctp},enumerable:!0,configurable:!0})}if(function(e){if(!e||!e.sdp)return!1;const t=ke.splitSections(e.sdp);return t.shift(),t.some((e=>{const t=ke.parseMLine(e);return t&&"application"===t.kind&&-1!==t.protocol.indexOf("SCTP")}))}(arguments[0])){const e=function(e){const t=e.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);if(null===t||t.length<2)return-1;const i=parseInt(t[1],10);return i!=i?-1:i}(arguments[0]),i=function(e){let i=65536;return"firefox"===t.browser&&(i=t.version<57?-1===e?16384:2147483637:t.version<60?57===t.version?65535:65536:2147483637),i}(e),r=function(e,i){let r=65536;"firefox"===t.browser&&57===t.version&&(r=65535);const n=ke.matchPrefix(e.sdp,"a=max-message-size:");return n.length>0?r=parseInt(n[0].substr(19),10):"firefox"===t.browser&&-1!==i&&(r=2147483637),r}(arguments[0],e);let n;n=0===i&&0===r?Number.POSITIVE_INFINITY:0===i||0===r?Math.max(i,r):Math.min(i,r);const s={};Object.defineProperty(s,"maxMessageSize",{get:()=>n}),this._sctp=s}return i.apply(this,arguments)}}function It(e){if(!e.RTCPeerConnection||!("createDataChannel"in e.RTCPeerConnection.prototype))return;function t(e,t){const i=e.send;e.send=function(){const r=arguments[0],n=r.length||r.size||r.byteLength;if("open"===e.readyState&&t.sctp&&n>t.sctp.maxMessageSize)throw new TypeError("Message too large (can send a maximum of "+t.sctp.maxMessageSize+" bytes)");return i.apply(e,arguments)}}const i=e.RTCPeerConnection.prototype.createDataChannel;e.RTCPeerConnection.prototype.createDataChannel=function(){const e=i.apply(this,arguments);return t(e,this),e},he(e,"datachannel",(e=>(t(e.channel,e.target),e)))}function Tt(e){if(!e.RTCPeerConnection||"connectionState"in e.RTCPeerConnection.prototype)return;const t=e.RTCPeerConnection.prototype;Object.defineProperty(t,"connectionState",{get(){return{completed:"connected",checking:"connecting"}[this.iceConnectionState]||this.iceConnectionState},enumerable:!0,configurable:!0}),Object.defineProperty(t,"onconnectionstatechange",{get(){return this._onconnectionstatechange||null},set(e){this._onconnectionstatechange&&(this.removeEventListener("connectionstatechange",this._onconnectionstatechange),delete this._onconnectionstatechange),e&&this.addEventListener("connectionstatechange",this._onconnectionstatechange=e)},enumerable:!0,configurable:!0}),["setLocalDescription","setRemoteDescription"].forEach((e=>{const i=t[e];t[e]=function(){return this._connectionstatechangepoly||(this._connectionstatechangepoly=e=>{const t=e.target;if(t._lastConnectionState!==t.connectionState){t._lastConnectionState=t.connectionState;const i=new Event("connectionstatechange",e);t.dispatchEvent(i)}return e},this.addEventListener("iceconnectionstatechange",this._connectionstatechangepoly)),i.apply(this,arguments)}}))}function mt(e,t){if(!e.RTCPeerConnection)return;if("chrome"===t.browser&&t.version>=71)return;if("safari"===t.browser&&t.version>=605)return;const i=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(t){if(t&&t.sdp&&-1!==t.sdp.indexOf("\na=extmap-allow-mixed")){const i=t.sdp.split("\n").filter((e=>"a=extmap-allow-mixed"!==e.trim())).join("\n");e.RTCSessionDescription&&t instanceof e.RTCSessionDescription?arguments[0]=new e.RTCSessionDescription({type:t.type,sdp:i}):t.sdp=i}return i.apply(this,arguments)}}function Rt(e,t){if(!e.RTCPeerConnection||!e.RTCPeerConnection.prototype)return;const i=e.RTCPeerConnection.prototype.addIceCandidate;i&&0!==i.length&&(e.RTCPeerConnection.prototype.addIceCandidate=function(){return arguments[0]?("chrome"===t.browser&&t.version<78||"firefox"===t.browser&&t.version<68||"safari"===t.browser)&&arguments[0]&&""===arguments[0].candidate?Promise.resolve():i.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())})}var St=Object.freeze({__proto__:null,shimRTCIceCandidate:ft,shimMaxMessageSize:Et,shimSendThrowTypeError:It,shimConnectionState:Tt,removeExtmapAllowMixed:mt,shimAddIceCandidateNullOrEmpty:Rt});const Ct=function({window:e}={},t={shimChrome:!0,shimFirefox:!0,shimEdge:!0,shimSafari:!0}){const i=fe,r=function(e){const t={browser:null,version:null};if(void 0===e||!e.navigator)return t.browser="Not a browser.",t;const{navigator:i}=e;if(i.mozGetUserMedia)t.browser="firefox",t.version=ue(i.userAgent,/Firefox\/(\d+)\./,1);else if(i.webkitGetUserMedia||!1===e.isSecureContext&&e.webkitRTCPeerConnection&&!e.RTCIceGatherer)t.browser="chrome",t.version=ue(i.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else if(i.mediaDevices&&i.userAgent.match(/Edge\/(\d+).(\d+)$/))t.browser="edge",t.version=ue(i.userAgent,/Edge\/(\d+).(\d+)$/,2);else{if(!e.RTCPeerConnection||!i.userAgent.match(/AppleWebKit\/(\d+)\./))return t.browser="Not a supported browser.",t;t.browser="safari",t.version=ue(i.userAgent,/AppleWebKit\/(\d+)\./,1),t.supportsUnifiedPlan=e.RTCRtpTransceiver&&"currentDirection"in e.RTCRtpTransceiver.prototype}return t}(e),n={browserDetails:r,commonShim:St,extractVersion:ue,disableLog:ge,disableWarnings:pe};switch(r.browser){case"chrome":if(!De||!Pe||!t.shimChrome)return i("Chrome shim is not included in this adapter release."),n;if(null===r.version)return i("Chrome shim can not determine version, not shimming."),n;i("adapter.js shimming chrome."),n.browserShim=De,Rt(e,r),Ce(e,r),Le(e),Pe(e,r),Oe(e),ye(e,r),ve(e),be(e),Ae(e),Ue(e,r),ft(e),Tt(e),Et(e,r),It(e),mt(e,r);break;case"firefox":if(!st||!ze||!t.shimFirefox)return i("Firefox shim is not included in this adapter release."),n;i("adapter.js shimming firefox."),n.browserShim=st,Rt(e,r),qe(e,r),ze(e,r),We(e),Xe(e),Qe(e),Ze(e),et(e),tt(e),it(e),rt(e),nt(e),ft(e),Tt(e),Et(e,r),It(e);break;case"edge":if(!Ye||!$e||!t.shimEdge)return i("MS edge shim is not included in this adapter release."),n;i("adapter.js shimming edge."),n.browserShim=Ye,He(e),Je(e),$e(e,r),Ke(e),Et(e,r),It(e);break;case"safari":if(!pt||!t.shimSafari)return i("Safari shim is not included in this adapter release."),n;i("adapter.js shimming safari."),n.browserShim=pt,Rt(e,r),dt(e),ht(e),lt(e),ot(e),at(e),ut(e),_t(e),gt(e),ft(e),Et(e,r),It(e),mt(e,r);break;default:i("Unsupported browser!")}return n}({window:"undefined"==typeof window?void 0:window});var Lt,Ot,vt;!function(e){e.FPS_10="FPS_10",e.FPS_15="FPS_15",e.FPS_24="FPS_24",e.FPS_30="FPS_30"}(Lt||(Lt={})),function(e){e.W176_H132="W176_H132",e.W176_H144="W176_H144",e.W180_H180="W180_H180",e.W240_H180="W240_H180",e.W240_H240="W240_H240",e.W256_H144="W256_H144",e.W320_H180="W320_H180",e.W320_H240="W320_H240",e.W360_H360="W360_H360",e.W480_H360="W480_H360",e.W480_H480="W480_H480",e.W640_H360="W640_H360",e.W640_H480="W640_H480",e.W720_H480="W720_H480",e.W848_H480="W848_H480",e.W960_H720="W960_H720",e.W1280_H720="W1280_H720",e.W1920_H1080="W1920_H1080",e.W144_H176="W144_H176",e.W144_H256="W144_H256",e.W180_H240="W180_H240",e.W180_H320="W180_H320",e.W240_H320="W240_H320",e.W360_H480="W360_H480",e.W360_H640="W360_H640",e.W480_H640="W480_H640",e.W480_H720="W480_H720",e.W480_H848="W480_H848",e.W720_H1280="W720_H1280",e.W720_H960="W720_H960",e.W1080_H1920="W1080_H1920"}(Ot||(Ot={})),function(e){e[e.AUDIO_ONLY=0]="AUDIO_ONLY",e[e.VIDEO_ONLY=1]="VIDEO_ONLY",e[e.AUDIO_VIDEO=2]="AUDIO_VIDEO"}(vt||(vt={}));const bt={[Ot.W176_H132]:{width:176,height:132,maxBitrate:150,minBitrate:80},[Ot.W176_H144]:{width:176,height:144,maxBitrate:150,minBitrate:80},[Ot.W180_H180]:{width:180,height:180,maxBitrate:200,minBitrate:100},[Ot.W240_H180]:{width:240,height:180,maxBitrate:240,minBitrate:120},[Ot.W240_H240]:{width:240,height:240,maxBitrate:280,minBitrate:120},[Ot.W256_H144]:{width:256,height:144,maxBitrate:240,minBitrate:120},[Ot.W320_H180]:{width:320,height:180,maxBitrate:280,minBitrate:120},[Ot.W320_H240]:{width:320,height:240,maxBitrate:400,minBitrate:120},[Ot.W360_H360]:{width:360,height:360,maxBitrate:520,minBitrate:140},[Ot.W480_H360]:{width:480,height:360,maxBitrate:650,minBitrate:150},[Ot.W480_H480]:{width:480,height:480,maxBitrate:800,minBitrate:180},[Ot.W640_H360]:{width:640,height:360,maxBitrate:800,minBitrate:180},[Ot.W640_H480]:{width:640,height:480,maxBitrate:900,minBitrate:200},[Ot.W720_H480]:{width:720,height:480,maxBitrate:1e3,minBitrate:200},[Ot.W848_H480]:{width:848,height:480,maxBitrate:1860,minBitrate:200},[Ot.W960_H720]:{width:960,height:720,maxBitrate:2e3,minBitrate:250},[Ot.W1280_H720]:{width:1280,height:720,maxBitrate:2200,minBitrate:250},[Ot.W1920_H1080]:{width:1920,height:1080,maxBitrate:4e3,minBitrate:400},[Ot.W144_H176]:{width:144,height:176,maxBitrate:150,minBitrate:80},[Ot.W144_H256]:{width:144,height:256,maxBitrate:240,minBitrate:120},[Ot.W180_H240]:{width:180,height:240,maxBitrate:240,minBitrate:120},[Ot.W180_H320]:{width:180,height:320,maxBitrate:280,minBitrate:120},[Ot.W240_H320]:{width:240,height:320,maxBitrate:400,minBitrate:120},[Ot.W360_H480]:{width:360,height:480,maxBitrate:650,minBitrate:150},[Ot.W360_H640]:{width:360,height:640,maxBitrate:800,minBitrate:180},[Ot.W480_H640]:{width:480,height:640,maxBitrate:900,minBitrate:200},[Ot.W480_H720]:{width:480,height:720,maxBitrate:1e3,minBitrate:200},[Ot.W480_H848]:{width:480,height:848,maxBitrate:1860,minBitrate:930},[Ot.W720_H1280]:{width:720,height:1280,maxBitrate:2200,minBitrate:250},[Ot.W720_H960]:{width:720,height:960,maxBitrate:2760,minBitrate:910},[Ot.W1080_H1920]:{width:1080,height:1920,maxBitrate:4e3,minBitrate:400}},At=e=>{const t={192:180,368:360,1088:1080};return t[e]?t[e]:e},Nt=(e,t)=>{e=At(e),t=At(t);const i=bt[`W${e}_H${t}`];if(i)return i;const r=e*t;return Object.keys(bt).map((e=>bt[e])).sort(((e,t)=>e.height*e.width-t.width*t.height)).filter((e=>e.height*e.width>=r))[0]||bt.W1920_H1080},yt={10:1,15:1,24:1.5,30:1.5},Pt=e=>{let t=Number.MAX_VALUE,i=1;for(const r in yt){const n=Math.abs(e-parseInt(r));n<t&&(t=n,i=yt[r])}return i},Ut=()=>m(void 0,void 0,void 0,(function*(){return(yield navigator.mediaDevices.enumerateDevices()).filter((e=>"videoinput"===e.kind))})),Dt=()=>m(void 0,void 0,void 0,(function*(){return(yield navigator.mediaDevices.enumerateDevices()).filter((e=>"audioinput"===e.kind))})),Mt=()=>m(void 0,void 0,void 0,(function*(){return(yield navigator.mediaDevices.enumerateDevices()).filter((e=>"audiooutput"===e.kind))}));var wt,kt;!function(e){e.AUDIO="audio",e.VIDEO="video"}(wt||(wt={}));class xt extends B{constructor(e,t,i,r,n,s){super(),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_tag",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_userId",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_kind",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_isLocalTrack",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"_roomId",{enumerable:!0,configurable:!0,writable:!0,value:s}),Object.defineProperty(this,"_localMuted",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_remoteMuted",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_id",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_streamId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_msTrack",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_msStream",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"DataTrackId",{enumerable:!0,configurable:!0,writable:!0,value:"data-track-id"}),Object.defineProperty(this,"_element",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),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}get streamTrack(){return this._msTrack}getTag(){return this._tag}isLocalTrack(){return this._isLocalTrack}isVideoTrack(){return"video"===this._kind}isAudioTrack(){return"audio"===this._kind}isReady(){var e;return"live"===(null===(e=this._msTrack)||void 0===e?void 0:e.readyState)}__innerSetMediaStreamTrack(e){this._msTrack=e,this._setLocalMuted(this._localMuted);const t=this._msStream=this._msStream||new MediaStream,i=t.getTracks()[0];i&&t.removeTrack(i),this._isLocalTrack||this._logger.warn(le.L_INNER_SET_TRACK_O,`trackId: ${this._id}, track: ${e?e.id:"undefined"}`),e?t.addTrack(e):this._element&&this._element.getAttribute(this.DataTrackId)===this.getTrackId()&&(this._element.pause(),this._element.srcObject=null)}_setLocalMuted(e){return m(this,void 0,void 0,(function*(){return this._msTrack&&(this._msTrack.enabled=!e),this._localMuted=e,ae.SUCCESS}))}mute(){return m(this,void 0,void 0,(function*(){return this._setLocalMuted(!0)}))}unmute(){return m(this,void 0,void 0,(function*(){return this._setLocalMuted(!1)}))}isLocalMuted(){return this._localMuted}isMCUTrack(){return Boolean(this._roomId)}isOwnerMuted(){return this._remoteMuted}_validateVolume(e){if(null==e?void 0:e.volume){if(!O(null==e?void 0:e.volume))return this._logger.error(le.L_TRACK_PLAY_E,JSON.stringify({status:_e.FAILED,code:ae.PARAMS_ERROR,msg:"params error -> options.volume not a number"})),{code:ae.PARAMS_ERROR};(null==e?void 0:e.volume)<0&&(e.volume=0,this._logger.warn(le.L_TRACK_PLAY_E,JSON.stringify({status:_e.FAILED,msg:"params error -> options.volume < 0",tips:"the valid range of options.volume is 0-100, the value of volume has been set 0"}))),(null==e?void 0:e.volume)>100&&(e.volume=100,this._logger.warn(le.L_TRACK_PLAY_E,JSON.stringify({status:_e.FAILED,msg:"params error -> options.volume > 100",tips:"the valid range of options.volume is 0-100, the value of volume has been set 100"})))}}_validatePlayOptions(e,t){return m(this,void 0,void 0,(function*(){if(!this._msTrack)return this._logger.error(le.L_TRACK_PLAY_E,JSON.stringify({status:_e.FAILED,code:ae.TRACK_NOT_READY,kind:this._kind,msg:`the track is not ready to play -> id: ${this._id}`})),{code:ae.TRACK_NOT_READY};"ended"===this._msTrack.readyState&&this._logger.warn(le.L_TRACK_PLAY_E,`track readyState is ended -> id: ${this._id}`);const i=this._validateVolume(t);if(i)return i;if(null==t?void 0:t.audioDeviceId){if(!(yield Mt()).map((e=>e.deviceId)).includes(t.audioDeviceId))return this._logger.error(le.L_TRACK_PLAY_E,JSON.stringify({status:_e.FAILED,code:ae.PARAMS_ERROR,msg:"params error -> options.audioDeviceId"})),{code:ae.PARAMS_ERROR}}return!this.isVideoTrack()||e&&(e instanceof HTMLVideoElement||this._validateVideoNodeName(e))?void 0:(this._logger.error(le.L_TRACK_PLAY_E,JSON.stringify({status:_e.FAILED,code:ae.VIDEO_TRACK_MISS_MEDIA_ELEMENT,kind:this._kind,msg:"params element is not a HTMLVideoElement"})),{code:ae.VIDEO_TRACK_MISS_MEDIA_ELEMENT})}))}_setPlayAttrs(e,t){return m(this,void 0,void 0,(function*(){var i;e&&(this._element.playsInline=!0,this._element.x5PlaysInline=!0,this._element.webkitPlaysInline=!0),(null==t?void 0:t.audioDeviceId)&&!e&&(yield this._element.setSinkId(t.audioDeviceId)),e||!(null==t?void 0:t.volume)&&0!==(null==t?void 0:t.volume)||(this._element.volume=t.volume/100),null===(i=this._element)||void 0===i||i.setAttribute(this.DataTrackId,this.getTrackId())}))}play(e,t){return m(this,void 0,void 0,(function*(){this._logger.info(le.L_TRACK_PLAY_O,JSON.stringify({elementId:null==e?void 0:e.id,trackId:this._id,kind:this._kind,options:t?{volume:null==t?void 0:t.volume,audioDeviceId:t.audioDeviceId}:void 0}));const i=yield this._validatePlayOptions(e,t);if(i)return i;const r=this.isVideoTrack();return 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=e=>{var t;this._logger.info(le.L_TRACK_LOAD_START_O,JSON.stringify({status:_e.INFO,kind:this._kind,msg:`HTMLMediaElement onloadstart -> id: ${null===(t=e.target)||void 0===t?void 0:t.id}, trackId: ${this._id}`}))},this._element.ondurationchange=e=>{var t;this._logger.info(le.L_TRACK_DURATION_CHANGE_O,JSON.stringify({status:_e.INFO,kind:this._kind,msg:`HTMLMediaElement ondurationchange -> id: ${null===(t=e.target)||void 0===t?void 0:t.id}, trackId: ${this._id}`}))},this._element.onloadedmetadata=e=>{var t;this._logger.info(le.L_TRACK_LOADED_META_DATA_O,JSON.stringify({status:_e.INFO,kind:this._kind,msg:`HTMLMediaElement onloadedmetadata -> id: ${null===(t=e.target)||void 0===t?void 0:t.id}, trackId: ${this._id}`}))},this._element.onloadeddata=e=>{var t;this._logger.info(le.L_TRACK_LOADED_DATA_O,JSON.stringify({status:_e.INFO,kind:this._kind,msg:`HTMLMediaElement onloadeddata -> id: ${null===(t=e.target)||void 0===t?void 0:t.id}, trackId: ${this._id}`}))},this._element.onabort=e=>{var t;this._logger.info(le.L_TRACK_ABORT_O,JSON.stringify({status:_e.INFO,kind:this._kind,msg:`HTMLMediaElement onabort -> id: ${null===(t=e.target)||void 0===t?void 0:t.id}, trackId: ${this._id}`}))},this._element.oncanplay=e=>m(this,void 0,void 0,(function*(){var i,n;this._logger.info(le.L_TRACK_CANPLAY_O,JSON.stringify({status:_e.INFO,kind:this._kind,msg:`HTMLMediaElement oncanplay -> id: ${null===(i=e.target)||void 0===i?void 0:i.id}, trackId: ${this._id}`}));try{(null==t?void 0:t.audioDeviceId)&&!r&&(yield this._element.setSinkId(t.audioDeviceId)),yield null===(n=this._element)||void 0===n?void 0:n.play()}catch(e){if("No permission to use requested device"===e.message)return void this._logger.error(le.L_TRACK_PLAY_E,JSON.stringify({status:_e.FAILED,kind:this._kind,code:ae.NO_PERMISSION_TO_USE_REQUESTED_DEVICE,msg:`setSinkId failed, error msg: ${e.message}`}));this._logger.error(le.L_TRACK_PLAY_E,JSON.stringify({status:_e.FAILED,code:ae.TRACK_PLAY_ERROR,kind:this._kind,msg:`play error, error msg: ${e.message}`}))}})),this._element.onvolumechange=e=>{var t,i;const r=Math.floor(100*(null===(t=e.target)||void 0===t?void 0:t.volume));this._logger.info(le.L_TRACK_VOLUME_CHANGE_O,JSON.stringify({status:_e.INFO,msg:`HTMLMediaElement onvolumechange -> id: ${null===(i=e.target)||void 0===i?void 0:i.id}, volume: ${r}, trackId: ${this._id}`}))},this._element.srcObject=this._msStream,this._element.autoplay=!0,yield this._setPlayAttrs(r,t),{code:ae.SUCCESS}}))}__innerDestroy(){this.__innerSetMediaStreamTrack(void 0)}__releaseMediaElement(){this._element&&this._element.getAttribute(this.DataTrackId)===this.getTrackId()&&(this._element.remove(),this._element.srcObject=null)}_validateVideoNodeName(e){return e&&e.nodeName&&"VIDEO"===e.nodeName.toUpperCase()}}!function(e){e.Speech="Speech",e.Music="Music",e.MusicHigh="MusicHigh"}(kt||(kt={}));const Bt={[kt.Music]:{max:64,min:64},[kt.MusicHigh]:{max:128,min:128},[kt.Speech]:{max:32,min:32}};var Vt;!function(e){e.LEVEL0="LEVEL0",e.LEVEL1="LEVEL1",e.LEVEL2="LEVEL2",e.LEVEL3="LEVEL3",e.LEVEL4="LEVEL4",e.LEVEL5="LEVEL5"}(Vt||(Vt={}));const Gt={[Vt.LEVEL0]:{max:150,min:80},[Vt.LEVEL1]:{max:280,min:120},[Vt.LEVEL2]:{max:650,min:150},[Vt.LEVEL3]:{max:1e3,min:200},[Vt.LEVEL4]:{max:2200,min:250},[Vt.LEVEL5]:{max:4e3,min:400}};class Ft{static apply3ANoiseWorklet(e){return m(this,void 0,void 0,(function*(){const t=new AudioContext({sampleRate:44100});let i;try{yield t.audioWorklet.addModule(Ft.SCRIPT_URL);const e=yield fetch(Ft.WASM_URL,{cache:"force-cache",credentials:"same-origin"});i=yield e.arrayBuffer()}catch(e){return{code:ae.LOAD_3A_MODULE_FAILED}}const r=t.createMediaStreamSource(new MediaStream([e])),n=new AudioWorkletNode(t,"process-worklet",{numberOfInputs:1,numberOfOutputs:1,outputChannelCount:[1],processorOptions:{binary:i}}),s=t.createMediaStreamDestination();r.connect(n).connect(s);const o=s.stream.getAudioTracks()[0];return Ft._maps.set(e.id,t),{code:ae.SUCCESS,track:o}}))}static release3ANoiseWorklet(e){const t=Ft._maps.get(e.id);t&&(t.close(),Ft._maps.delete(e.id))}}Object.defineProperty(Ft,"WASM_URL",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(Ft,"SCRIPT_URL",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(Ft,"_maps",{enumerable:!0,configurable:!0,writable:!0,value:new Map});class jt extends xt{constructor(e,t,i,r,n){super(e,t,i,r,!0),Object.defineProperty(this,"_isDestroyed",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_isPublished",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_bitrateInfo",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.__innerSetMediaStreamTrack(n),n.onended=()=>{n.onended=null,this._onTrackEnded()}}_onTrackEnded(){this.emit(jt.EVENT_LOCAL_TRACK_END,this),this.removeAll(jt.EVENT_LOCAL_TRACK_END)}_setLocalMuted(e){return new Promise((t=>{const i=this._localMuted!==e;super._setLocalMuted(e),this._remoteMuted=this._localMuted,i&&this._isPublished?this.emit(jt.__INNER_EVENT_MUTED_CHANGE__,this,t):t(ae.SUCCESS),this._logger.info(le.L_LOCAL_TRACK_SET_LOCAL_MUTED_O,JSON.stringify({enable:e,trackId:this._id}))}))}__innerSetPublished(e){this._isPublished=e}isPublished(){return this._isPublished}destroy(e=!0){var t;this._isDestroyed||(this._logger.info(le.L_LOCAL_TRACK_DESTROY_O,this._id),this._isDestroyed=!0,null===(t=this._msTrack)||void 0===t||t.stop(),super.__innerDestroy(),this.isAudioTrack()&&super.__releaseMediaElement(),this._isPublished&&e&&this.emit(jt.__INNER_EVENT_DESTROY__,this))}isDestroyed(){return this._isDestroyed}setBitrate(e=0,t=0,i=0){!O(e)||!O(t)||!O(i)||e<=0||t<=0||e<t?this._logger.error(le.L_LOCAL_TRACK_SET_BITRATE_O,JSON.stringify({status:_e.FAILED,msg:`params error -> max: ${e},min: ${t}, start: ${i}`,trackId:this._id})):(this._logger.info(le.L_LOCAL_TRACK_SET_BITRATE_O,JSON.stringify({status:_e.SUCCESSED,max:e,min:t,start:i,trackId:this._id})),this._bitrateInfo={max:e,min:t,start:i})}getBitrate(){var e,t,i,r,n,s,o;let{min:a,max:l,start:_}={min:0,max:0,start:0};return(null===(e=this._msTrack)||void 0===e?void 0:e.kind)===wt.VIDEO?({min:a,max:l}=ai(this._msTrack)):(null===(t=this._msTrack)||void 0===t?void 0:t.kind)===wt.AUDIO&&({min:a,max:l}={min:32,max:32}),(null===(i=this._bitrateInfo)||void 0===i?void 0:i.max)&&(_=.7*(null===(r=this._bitrateInfo)||void 0===r?void 0:r.max)),{min:(null===(n=this._bitrateInfo)||void 0===n?void 0:n.min)||a,max:(null===(s=this._bitrateInfo)||void 0===s?void 0:s.max)||l,start:(null===(o=this._bitrateInfo)||void 0===o?void 0:o.start)||_}}getSettings(){var e;return null===(e=this._msTrack)||void 0===e?void 0:e.getSettings()}}Object.defineProperty(jt,"EVENT_LOCAL_TRACK_END",{enumerable:!0,configurable:!0,writable:!0,value:"local-track-end"}),Object.defineProperty(jt,"__INNER_EVENT_MUTED_CHANGE__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-muted-change"}),Object.defineProperty(jt,"__INNER_EVENT_DESTROY__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-destroy"});class Ht extends jt{constructor(e,t,i,r){super(e,t,i,"audio",r)}setRecommendBitrate(e){if(!x("audioBitrate",e,(e=>e in kt)))return void this._logger.warn(le.L_RTC_SET_RECOMMEND_BITRATE_O,JSON.stringify({status:_e.FAILED,msg:"params error -> params type is RCAudioBitrate"}));const t=Bt[e];this.setBitrate(t.max,t.min,t.start||.7*t.max)}setBitrate(e,...t){const[i=1,r=.7*e||1]=t;super.setBitrate(e,i,r)}}class Jt extends jt{constructor(e,t,i,r,n=!1){super(e,t,i,"video",r),Object.defineProperty(this,"_isTiny",{enumerable:!0,configurable:!0,writable:!0,value:n})}__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}setRecommendBitrate(e){if(!x("videoBitrate",e,(e=>e in Vt)))return void this._logger.warn(le.L_RTC_SET_RECOMMEND_BITRATE_O,JSON.stringify({status:_e.FAILED,msg:"params error -> params type is RCVideoBitrate"}));const t=Gt[e];this.setBitrate(t.max,t.min,t.start||.7*t.max)}setBitrate(e,...t){const[i=1,r=.7*e||1]=t;super.setBitrate(e,i,r)}}class $t extends jt{static _innerSetMapping(e,t){const i=this._mapping.get(t)||[];i.push(e),this._mapping.set(t,i)}static _innerRemoveMapping(e,t){var i,r;const n=null===(i=this._mapping.get(t))||void 0===i?void 0:i.filter((t=>t!==e));n&&n.length>0?this._mapping.set(t,n):(this._mapping.delete(t),t.pause(),t.src="",null===(r=t.parentNode)||void 0===r||r.removeChild(t))}constructor(e,t,i,r,n,s){super(e,t,i,r,n),Object.defineProperty(this,"_resource",{enumerable:!0,configurable:!0,writable:!0,value:s}),$t._innerSetMapping(this.getTrackId(),s)}destroy(){this.isAudioTrack()&&this.mute(),$t._innerRemoveMapping(this.getTrackId(),this._resource),super.destroy()}}Object.defineProperty($t,"_mapping",{enumerable:!0,configurable:!0,writable:!0,value:new Map});class Kt extends $t{constructor(e,t,i,r,n){super(e,t,i,"video",r,n)}}class Yt extends $t{constructor(e,t,i,r,n){super(e,t,i,"audio",r,n)}_setLocalMuted(e){const t=Object.create(null,{_setLocalMuted:{get:()=>super._setLocalMuted}});return m(this,void 0,void 0,(function*(){return this._resource&&(this._resource.muted=e),t._setLocalMuted.call(this,e)}))}play(){return m(this,void 0,void 0,(function*(){return{code:yield this._setLocalMuted(!1)}}))}}class qt extends Ht{constructor(){super(...arguments),Object.defineProperty(this,"_originTrack",{enumerable:!0,configurable:!0,writable:!0,value:null})}apply3ANoiseWorklet(){return m(this,void 0,void 0,(function*(){if(this._logger.info(le.A_APPLY_3A_NOISE_WORKLET_T),this._originTrack)return this._logger.warn(le.A_APPLY_3A_NOISE_WORKLET_R,JSON.stringify({status:_e.FAILED,msg:"3A noise module already applied"})),{code:ae.SUCCESS};if(!this._msTrack||this.isDestroyed())return this._logger.warn(le.A_APPLY_3A_NOISE_WORKLET_R,JSON.stringify({status:_e.FAILED,msg:"track not ready"})),{code:ae.TRACK_NOT_READY};if(this.isPublished())return this._logger.warn(le.A_APPLY_3A_NOISE_WORKLET_R,JSON.stringify({status:_e.FAILED,msg:"track already published"})),{code:ae.APPLY_3A_NOISE_WORKLET_BEFORE_PUBLISH};const{code:e,track:t}=yield Ft.apply3ANoiseWorklet(this._msTrack);return e===ae.SUCCESS&&t?(this._originTrack=this._msTrack,this._msTrack=t,this._logger.info(le.A_APPLY_3A_NOISE_WORKLET_R,JSON.stringify({status:_e.SUCCESSED})),{code:ae.SUCCESS}):(this._logger.warn(le.A_APPLY_3A_NOISE_WORKLET_R,JSON.stringify({status:_e.FAILED,msg:`apply 3A noise module failed: ${e}`,SCRIPT_URL:Ft.SCRIPT_URL,WASM_URL:Ft.WASM_URL})),{code:e})}))}__innerSetMediaStreamTrack(e){!e&&this._originTrack&&(Ft.release3ANoiseWorklet(this._originTrack),this._originTrack.stop(),this._originTrack=null),super.__innerSetMediaStreamTrack(e)}replaceInnerTrack(e){}}class Wt extends Jt{constructor(e,t,i,r,n=!1){super(e,t,i,r,n)}replaceInnerTrack(e){}}class zt extends Jt{_onTrackEnded(){super._onTrackEnded(),this.isPublished()&&this.emit(jt.__INNER_EVENT_DESTROY__,this)}}class Qt extends Ht{_onTrackEnded(){super._onTrackEnded(),this.isPublished()&&this.emit(jt.__INNER_EVENT_DESTROY__,this)}}class Zt extends xt{constructor(e,t,i,r,n){super(e,t,i,r,!1,n),Object.defineProperty(this,"_isSubscribed",{enumerable:!0,configurable:!0,writable:!0,value:!1})}__innerSetRemoteMuted(e){this._remoteMuted=e}__innerSetSubscribed(e){this._isSubscribed=e}isSubscribed(){return this._isSubscribed}}class Xt extends Zt{constructor(e,t,i,r){super(e,t,i,"audio",r)}_setLocalMuted(e){const{browser:t,version:i}=Ii;return this._element&&i&&/chrome/i.test(t)&&i>=130&&(this._element.muted=e),super._setLocalMuted(e)}getVolume(){var e;return 100*((null===(e=this._element)||void 0===e?void 0:e.volume)||0)}}class ei extends Zt{constructor(e,t,i,r){super(e,t,i,"video",r),Object.defineProperty(this,"_isSubTiny",{enumerable:!0,configurable:!0,writable:!0,value:!1})}__innerSetIsTinyTrack(e){this._isSubTiny=e}isSubTiny(){return this._isSubTiny}}var ti;!function(e){e[e.MARK_DOWN=0]="MARK_DOWN",e[e.JSON=1]="JSON"}(ti||(ti={}));const ii=(e,t)=>({name:e,content:JSON.stringify({uris:t,ignore:!0})}),ri=e=>JSON.stringify(e),ni=e=>/^[a-zA-Z\d-=]+$/g.test(e),si=e=>{if(void 0===e)return 0;if(O(e))return e;const t=e;return t.exact||t.ideal||t.max||0},oi=e=>{const t=e.getSettings(),i=e.getConstraints();return{width:si(i.width)||t.width||0,height:si(i.height)||t.height||0,frameRate:t.frameRate||si(i.frameRate)}},ai=e=>{const{width:t,height:i,frameRate:r}=oi(e),n=Nt(t||1920,i||1080),s=Pt(r);return{min:n.minBitrate*s,max:n.maxBitrate*s}},li=e=>[e.msid,e.mediaType].join("_"),_i=e=>{const t=e.split("_");return{mediaType:parseInt(t.pop()),tag:t.pop(),userId:t.join("_")}},ci=(e,t)=>[e,t].join("_"),di=e=>e.map((e=>Object.assign({},e))),ui=(e,t,i=!1)=>{e=e.slice();const r=[],n=[],s=[];return t.forEach((t=>{const n=li(t);let o=e.findIndex((e=>li(e)===n));if(i&&(o=e.findIndex((e=>e.uri===t.uri))),-1===o)return void r.push(t);const a=e[o];a.uri!==t.uri?r.push(t):a.state!==t.state&&s.push(t),e.splice(o,1)})),n.push(...e),{publishedList:r,unpublishedList:n,modifiedList:s}},hi=()=>{let e="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(e=>{const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}));return e=`${e.replace(/-/g,"")}0`,e=parseInt(e,16),e=(e=>{const t="0123456789abcdefghigklmnopqrstuvwxyzABCDEFGHIGKLMNOPQRSTUVWXYZ+/".split(""),i=t.length+1;let r=+e;const n=[];do{const e=r%i;r=(r-e)/i,n.unshift(t[e])}while(r);return n.join("")})(e),e.length>22&&(e=e.slice(0,22)),e},gi=e=>{if(bt[e]){const{width:t,height:i}=bt[e];return{width:t,height:i}}const[t,i]=e.split("_").map((e=>parseInt(e.replace(/[^\d]/g,""))));return{width:t,height:i}},pi=e=>!!Ot[e],fi=e=>!!Lt[e],Ei=e=>parseInt(e.replace("FPS_","")),Ii=(()=>{const{browser:e,version:t,supportsUnifiedPlan:i}=Ct.browserDetails;return{browser:e,version:t,supportsUnifiedPlan:!1!==i}})();function Ti(){return"captureStream"in HTMLMediaElement.prototype||"mozCaptureStream"in HTMLMediaElement.prototype}function mi(){return"mediaDevices"in navigator&&"getDisplayMedia"in navigator.mediaDevices}const Ri=e=>"[object Null]"===Object.prototype.toString.call(e),Si=e=>1===e.type,Ci=(e,t,i,r)=>{const n={},s=Object.keys(e.users);return s.length&&s.forEach((s=>{const o=[],a=e.users[s];if(a.extra){const{roomId:e}=JSON.parse(a.extra);if(t!==e)return}if(a.uris)try{o.push(...JSON.parse(a.uris))}catch(e){i.warn(le.L_PARSE_ROOMDATA_URIS_R,`invalid user data -> userId: ${s}, userData: ${a}`,r)}n[s]=o})),n},Li=e=>e instanceof xt?e.getTrackId():e.track.getTrackId(),Oi=e=>{if(!N(e)||void 0===e.low||void 0===e.high)return e;let{low:t}=e;t<0&&(t+=4294967296),t=t.toString(16);return parseInt(e.high.toString(16)+"00000000".replace(new RegExp(`0{${t.length}}$`),t),16)};var vi,bi;!function(e){e.PUBLISH="RCRTC:PublishResource",e.UNPUBLISH="RCRTC:UnpublishResource",e.MODIFY="RCRTC:ModifyResource",e.TOTAL_CONTENT_RESOURCE="RCRTC:TotalContentResources",e.STATE="RCRTC:state",e.ROOM_NOTIFY="RCRTC:RoomNtf",e.USER_NOTIFY="RCRTC:UserNtf",e.KICK="RCRTC:kick",e.PK_INVITE="RCRTC:invite",e.PK_INVITE_TIMEOUT="RCRTC:inviteTimeout",e.PK_CANCEL_INVITE="RCRTC:cancelInvite",e.PK_INVITE_ANSWER="RCRTC:answerInvite",e.PK_END="RCRTC:endInvite",e.OTHER_ROOM_OFFLINE="RCRTC:otherRoomOffline",e.ROOM_TASK_FINISH="RCRTC:roomTaskFinish",e.ASR_STATUS="RCRTC:AsrStatus",e.ASR_SEI="RCRTC:PublishSeiAi",e.SUMMARIZATION_STATUS="RCRTC:Summarization"}(vi||(vi={})),function(e){e.SUCCESS="Success",e.FAIL="Fail"}(bi||(bi={}));class Ai{constructor(e,t,i,r=5e3){Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_roomId",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_roomMode",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_gap",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_latestTimestamp",{enumerable:!0,configurable:!0,writable:!0,value:Date.now()}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"onFailed",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"onPingResult",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_started",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_timer",{enumerable:!0,configurable:!0,writable:!0,value:null}),this._logger=this._context.logger}start(e){this._started||(e<15e3&&(e=15e3),this._logger.info(le.L_PINGER_START_O,JSON.stringify({interval:this._gap,offlineKickTime:e})),this._started=!0,this._checkAlive(e))}_sendPing(){return new Promise((e=>{this._context.rtcPing(this._roomId,this._roomMode).then(e),setTimeout(e,5e3,{code:oe.TIMEOUT})}))}_checkAlive(e){return m(this,void 0,void 0,(function*(){const{logger:t}=this._context,i=t.createTraceId(),{code:r,data:n}=yield this._sendPing();if(!this._started)return;const s=Date.now();return r===oe.SUCCESS?(this._latestTimestamp=s,this.onPingResult(bi.SUCCESS,n.version),void(this._timer=setTimeout((()=>this._checkAlive(e)),this._gap))):(t.error(le.L_PINGER_SEND_RTCPING_E,JSON.stringify({roomId:this._roomId,code:r}),i),this.onPingResult(bi.FAIL),40003===r||s-this._latestTimestamp>e?(this.stop(),void this.onFailed(40003===r)):void(this._timer=setTimeout((()=>this._checkAlive(e)),this._gap)))}))}stop(){this._started&&(this._logger.info(le.L_PINGER_STOP_O),this._started=!1,this._timer&&(clearTimeout(this._timer),this._timer=null))}}
|
|
2
|
+
/*! pako 2.1.0 https://github.com/nodeca/pako @license (MIT AND Zlib) */function Ni(e){let t=e.length;for(;--t>=0;)e[t]=0}const yi=256,Pi=286,Ui=30,Di=15,Mi=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),wi=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),ki=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),xi=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Bi=new Array(576);Ni(Bi);const Vi=new Array(60);Ni(Vi);const Gi=new Array(512);Ni(Gi);const Fi=new Array(256);Ni(Fi);const ji=new Array(29);Ni(ji);const Hi=new Array(Ui);function Ji(e,t,i,r,n){this.static_tree=e,this.extra_bits=t,this.extra_base=i,this.elems=r,this.max_length=n,this.has_stree=e&&e.length}let $i,Ki,Yi;function qi(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}Ni(Hi);const Wi=e=>e<256?Gi[e]:Gi[256+(e>>>7)],zi=(e,t)=>{e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255},Qi=(e,t,i)=>{e.bi_valid>16-i?(e.bi_buf|=t<<e.bi_valid&65535,zi(e,e.bi_buf),e.bi_buf=t>>16-e.bi_valid,e.bi_valid+=i-16):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=i)},Zi=(e,t,i)=>{Qi(e,i[2*t],i[2*t+1])},Xi=(e,t)=>{let i=0;do{i|=1&e,e>>>=1,i<<=1}while(--t>0);return i>>>1},er=(e,t,i)=>{const r=new Array(16);let n,s,o=0;for(n=1;n<=Di;n++)o=o+i[n-1]<<1,r[n]=o;for(s=0;s<=t;s++){let t=e[2*s+1];0!==t&&(e[2*s]=Xi(r[t]++,t))}},tr=e=>{let t;for(t=0;t<Pi;t++)e.dyn_ltree[2*t]=0;for(t=0;t<Ui;t++)e.dyn_dtree[2*t]=0;for(t=0;t<19;t++)e.bl_tree[2*t]=0;e.dyn_ltree[512]=1,e.opt_len=e.static_len=0,e.sym_next=e.matches=0},ir=e=>{e.bi_valid>8?zi(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},rr=(e,t,i,r)=>{const n=2*t,s=2*i;return e[n]<e[s]||e[n]===e[s]&&r[t]<=r[i]},nr=(e,t,i)=>{const r=e.heap[i];let n=i<<1;for(;n<=e.heap_len&&(n<e.heap_len&&rr(t,e.heap[n+1],e.heap[n],e.depth)&&n++,!rr(t,r,e.heap[n],e.depth));)e.heap[i]=e.heap[n],i=n,n<<=1;e.heap[i]=r},sr=(e,t,i)=>{let r,n,s,o,a=0;if(0!==e.sym_next)do{r=255&e.pending_buf[e.sym_buf+a++],r+=(255&e.pending_buf[e.sym_buf+a++])<<8,n=e.pending_buf[e.sym_buf+a++],0===r?Zi(e,n,t):(s=Fi[n],Zi(e,s+yi+1,t),o=Mi[s],0!==o&&(n-=ji[s],Qi(e,n,o)),r--,s=Wi(r),Zi(e,s,i),o=wi[s],0!==o&&(r-=Hi[s],Qi(e,r,o)))}while(a<e.sym_next);Zi(e,256,t)},or=(e,t)=>{const i=t.dyn_tree,r=t.stat_desc.static_tree,n=t.stat_desc.has_stree,s=t.stat_desc.elems;let o,a,l,_=-1;for(e.heap_len=0,e.heap_max=573,o=0;o<s;o++)0!==i[2*o]?(e.heap[++e.heap_len]=_=o,e.depth[o]=0):i[2*o+1]=0;for(;e.heap_len<2;)l=e.heap[++e.heap_len]=_<2?++_:0,i[2*l]=1,e.depth[l]=0,e.opt_len--,n&&(e.static_len-=r[2*l+1]);for(t.max_code=_,o=e.heap_len>>1;o>=1;o--)nr(e,i,o);l=s;do{o=e.heap[1],e.heap[1]=e.heap[e.heap_len--],nr(e,i,1),a=e.heap[1],e.heap[--e.heap_max]=o,e.heap[--e.heap_max]=a,i[2*l]=i[2*o]+i[2*a],e.depth[l]=(e.depth[o]>=e.depth[a]?e.depth[o]:e.depth[a])+1,i[2*o+1]=i[2*a+1]=l,e.heap[1]=l++,nr(e,i,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],((e,t)=>{const i=t.dyn_tree,r=t.max_code,n=t.stat_desc.static_tree,s=t.stat_desc.has_stree,o=t.stat_desc.extra_bits,a=t.stat_desc.extra_base,l=t.stat_desc.max_length;let _,c,d,u,h,g,p=0;for(u=0;u<=Di;u++)e.bl_count[u]=0;for(i[2*e.heap[e.heap_max]+1]=0,_=e.heap_max+1;_<573;_++)c=e.heap[_],u=i[2*i[2*c+1]+1]+1,u>l&&(u=l,p++),i[2*c+1]=u,c>r||(e.bl_count[u]++,h=0,c>=a&&(h=o[c-a]),g=i[2*c],e.opt_len+=g*(u+h),s&&(e.static_len+=g*(n[2*c+1]+h)));if(0!==p){do{for(u=l-1;0===e.bl_count[u];)u--;e.bl_count[u]--,e.bl_count[u+1]+=2,e.bl_count[l]--,p-=2}while(p>0);for(u=l;0!==u;u--)for(c=e.bl_count[u];0!==c;)d=e.heap[--_],d>r||(i[2*d+1]!==u&&(e.opt_len+=(u-i[2*d+1])*i[2*d],i[2*d+1]=u),c--)}})(e,t),er(i,_,e.bl_count)},ar=(e,t,i)=>{let r,n,s=-1,o=t[1],a=0,l=7,_=4;for(0===o&&(l=138,_=3),t[2*(i+1)+1]=65535,r=0;r<=i;r++)n=o,o=t[2*(r+1)+1],++a<l&&n===o||(a<_?e.bl_tree[2*n]+=a:0!==n?(n!==s&&e.bl_tree[2*n]++,e.bl_tree[32]++):a<=10?e.bl_tree[34]++:e.bl_tree[36]++,a=0,s=n,0===o?(l=138,_=3):n===o?(l=6,_=3):(l=7,_=4))},lr=(e,t,i)=>{let r,n,s=-1,o=t[1],a=0,l=7,_=4;for(0===o&&(l=138,_=3),r=0;r<=i;r++)if(n=o,o=t[2*(r+1)+1],!(++a<l&&n===o)){if(a<_)do{Zi(e,n,e.bl_tree)}while(0!=--a);else 0!==n?(n!==s&&(Zi(e,n,e.bl_tree),a--),Zi(e,16,e.bl_tree),Qi(e,a-3,2)):a<=10?(Zi(e,17,e.bl_tree),Qi(e,a-3,3)):(Zi(e,18,e.bl_tree),Qi(e,a-11,7));a=0,s=n,0===o?(l=138,_=3):n===o?(l=6,_=3):(l=7,_=4)}};let _r=!1;const cr=(e,t,i,r)=>{Qi(e,0+(r?1:0),3),ir(e),zi(e,i),zi(e,~i),i&&e.pending_buf.set(e.window.subarray(t,t+i),e.pending),e.pending+=i};var dr=(e,t,i,r)=>{let n,s,o=0;e.level>0?(2===e.strm.data_type&&(e.strm.data_type=(e=>{let t,i=4093624447;for(t=0;t<=31;t++,i>>>=1)if(1&i&&0!==e.dyn_ltree[2*t])return 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(t=32;t<yi;t++)if(0!==e.dyn_ltree[2*t])return 1;return 0})(e)),or(e,e.l_desc),or(e,e.d_desc),o=(e=>{let t;for(ar(e,e.dyn_ltree,e.l_desc.max_code),ar(e,e.dyn_dtree,e.d_desc.max_code),or(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*xi[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t})(e),n=e.opt_len+3+7>>>3,s=e.static_len+3+7>>>3,s<=n&&(n=s)):n=s=i+5,i+4<=n&&-1!==t?cr(e,t,i,r):4===e.strategy||s===n?(Qi(e,2+(r?1:0),3),sr(e,Bi,Vi)):(Qi(e,4+(r?1:0),3),((e,t,i,r)=>{let n;for(Qi(e,t-257,5),Qi(e,i-1,5),Qi(e,r-4,4),n=0;n<r;n++)Qi(e,e.bl_tree[2*xi[n]+1],3);lr(e,e.dyn_ltree,t-1),lr(e,e.dyn_dtree,i-1)})(e,e.l_desc.max_code+1,e.d_desc.max_code+1,o+1),sr(e,e.dyn_ltree,e.dyn_dtree)),tr(e),r&&ir(e)},ur={_tr_init:e=>{_r||((()=>{let e,t,i,r,n;const s=new Array(16);for(i=0,r=0;r<28;r++)for(ji[r]=i,e=0;e<1<<Mi[r];e++)Fi[i++]=r;for(Fi[i-1]=r,n=0,r=0;r<16;r++)for(Hi[r]=n,e=0;e<1<<wi[r];e++)Gi[n++]=r;for(n>>=7;r<Ui;r++)for(Hi[r]=n<<7,e=0;e<1<<wi[r]-7;e++)Gi[256+n++]=r;for(t=0;t<=Di;t++)s[t]=0;for(e=0;e<=143;)Bi[2*e+1]=8,e++,s[8]++;for(;e<=255;)Bi[2*e+1]=9,e++,s[9]++;for(;e<=279;)Bi[2*e+1]=7,e++,s[7]++;for(;e<=287;)Bi[2*e+1]=8,e++,s[8]++;for(er(Bi,287,s),e=0;e<Ui;e++)Vi[2*e+1]=5,Vi[2*e]=Xi(e,5);$i=new Ji(Bi,Mi,257,Pi,Di),Ki=new Ji(Vi,wi,0,Ui,Di),Yi=new Ji(new Array(0),ki,0,19,7)})(),_r=!0),e.l_desc=new qi(e.dyn_ltree,$i),e.d_desc=new qi(e.dyn_dtree,Ki),e.bl_desc=new qi(e.bl_tree,Yi),e.bi_buf=0,e.bi_valid=0,tr(e)},_tr_stored_block:cr,_tr_flush_block:dr,_tr_tally:(e,t,i)=>(e.pending_buf[e.sym_buf+e.sym_next++]=t,e.pending_buf[e.sym_buf+e.sym_next++]=t>>8,e.pending_buf[e.sym_buf+e.sym_next++]=i,0===t?e.dyn_ltree[2*i]++:(e.matches++,t--,e.dyn_ltree[2*(Fi[i]+yi+1)]++,e.dyn_dtree[2*Wi(t)]++),e.sym_next===e.sym_end),_tr_align:e=>{Qi(e,2,3),Zi(e,256,Bi),(e=>{16===e.bi_valid?(zi(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)})(e)}};var hr=(e,t,i,r)=>{let n=65535&e,s=e>>>16&65535,o=0;for(;0!==i;){o=i>2e3?2e3:i,i-=o;do{n=n+t[r++]|0,s=s+n|0}while(--o);n%=65521,s%=65521}return n|s<<16};const gr=new Uint32Array((()=>{let e,t=[];for(var i=0;i<256;i++){e=i;for(var r=0;r<8;r++)e=1&e?3988292384^e>>>1:e>>>1;t[i]=e}return t})());var pr=(e,t,i,r)=>{const n=gr,s=r+i;e^=-1;for(let i=r;i<s;i++)e=e>>>8^n[255&(e^t[i])];return~e},fr={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},Er={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};const{_tr_init:Ir,_tr_stored_block:Tr,_tr_flush_block:mr,_tr_tally:Rr,_tr_align:Sr}=ur,{Z_NO_FLUSH:Cr,Z_PARTIAL_FLUSH:Lr,Z_FULL_FLUSH:Or,Z_FINISH:vr,Z_BLOCK:br,Z_OK:Ar,Z_STREAM_END:Nr,Z_STREAM_ERROR:yr,Z_DATA_ERROR:Pr,Z_BUF_ERROR:Ur,Z_DEFAULT_COMPRESSION:Dr,Z_FILTERED:Mr,Z_HUFFMAN_ONLY:wr,Z_RLE:kr,Z_FIXED:xr,Z_DEFAULT_STRATEGY:Br,Z_UNKNOWN:Vr,Z_DEFLATED:Gr}=Er,Fr=258,jr=262,Hr=42,Jr=113,$r=666,Kr=(e,t)=>(e.msg=fr[t],t),Yr=e=>2*e-(e>4?9:0),qr=e=>{let t=e.length;for(;--t>=0;)e[t]=0},Wr=e=>{let t,i,r,n=e.w_size;t=e.hash_size,r=t;do{i=e.head[--r],e.head[r]=i>=n?i-n:0}while(--t);t=n,r=t;do{i=e.prev[--r],e.prev[r]=i>=n?i-n:0}while(--t)};let zr=(e,t,i)=>(t<<e.hash_shift^i)&e.hash_mask;const Qr=e=>{const t=e.state;let i=t.pending;i>e.avail_out&&(i=e.avail_out),0!==i&&(e.output.set(t.pending_buf.subarray(t.pending_out,t.pending_out+i),e.next_out),e.next_out+=i,t.pending_out+=i,e.total_out+=i,e.avail_out-=i,t.pending-=i,0===t.pending&&(t.pending_out=0))},Zr=(e,t)=>{mr(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,Qr(e.strm)},Xr=(e,t)=>{e.pending_buf[e.pending++]=t},en=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t},tn=(e,t,i,r)=>{let n=e.avail_in;return n>r&&(n=r),0===n?0:(e.avail_in-=n,t.set(e.input.subarray(e.next_in,e.next_in+n),i),1===e.state.wrap?e.adler=hr(e.adler,t,n,i):2===e.state.wrap&&(e.adler=pr(e.adler,t,n,i)),e.next_in+=n,e.total_in+=n,n)},rn=(e,t)=>{let i,r,n=e.max_chain_length,s=e.strstart,o=e.prev_length,a=e.nice_match;const l=e.strstart>e.w_size-jr?e.strstart-(e.w_size-jr):0,_=e.window,c=e.w_mask,d=e.prev,u=e.strstart+Fr;let h=_[s+o-1],g=_[s+o];e.prev_length>=e.good_match&&(n>>=2),a>e.lookahead&&(a=e.lookahead);do{if(i=t,_[i+o]===g&&_[i+o-1]===h&&_[i]===_[s]&&_[++i]===_[s+1]){s+=2,i++;do{}while(_[++s]===_[++i]&&_[++s]===_[++i]&&_[++s]===_[++i]&&_[++s]===_[++i]&&_[++s]===_[++i]&&_[++s]===_[++i]&&_[++s]===_[++i]&&_[++s]===_[++i]&&s<u);if(r=Fr-(u-s),s=u-Fr,r>o){if(e.match_start=t,o=r,r>=a)break;h=_[s+o-1],g=_[s+o]}}}while((t=d[t&c])>l&&0!=--n);return o<=e.lookahead?o:e.lookahead},nn=e=>{const t=e.w_size;let i,r,n;do{if(r=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-jr)&&(e.window.set(e.window.subarray(t,t+t-r),0),e.match_start-=t,e.strstart-=t,e.block_start-=t,e.insert>e.strstart&&(e.insert=e.strstart),Wr(e),r+=t),0===e.strm.avail_in)break;if(i=tn(e.strm,e.window,e.strstart+e.lookahead,r),e.lookahead+=i,e.lookahead+e.insert>=3)for(n=e.strstart-e.insert,e.ins_h=e.window[n],e.ins_h=zr(e,e.ins_h,e.window[n+1]);e.insert&&(e.ins_h=zr(e,e.ins_h,e.window[n+3-1]),e.prev[n&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=n,n++,e.insert--,!(e.lookahead+e.insert<3)););}while(e.lookahead<jr&&0!==e.strm.avail_in)},sn=(e,t)=>{let i,r,n,s=e.pending_buf_size-5>e.w_size?e.w_size:e.pending_buf_size-5,o=0,a=e.strm.avail_in;do{if(i=65535,n=e.bi_valid+42>>3,e.strm.avail_out<n)break;if(n=e.strm.avail_out-n,r=e.strstart-e.block_start,i>r+e.strm.avail_in&&(i=r+e.strm.avail_in),i>n&&(i=n),i<s&&(0===i&&t!==vr||t===Cr||i!==r+e.strm.avail_in))break;o=t===vr&&i===r+e.strm.avail_in?1:0,Tr(e,0,0,o),e.pending_buf[e.pending-4]=i,e.pending_buf[e.pending-3]=i>>8,e.pending_buf[e.pending-2]=~i,e.pending_buf[e.pending-1]=~i>>8,Qr(e.strm),r&&(r>i&&(r=i),e.strm.output.set(e.window.subarray(e.block_start,e.block_start+r),e.strm.next_out),e.strm.next_out+=r,e.strm.avail_out-=r,e.strm.total_out+=r,e.block_start+=r,i-=r),i&&(tn(e.strm,e.strm.output,e.strm.next_out,i),e.strm.next_out+=i,e.strm.avail_out-=i,e.strm.total_out+=i)}while(0===o);return a-=e.strm.avail_in,a&&(a>=e.w_size?(e.matches=2,e.window.set(e.strm.input.subarray(e.strm.next_in-e.w_size,e.strm.next_in),0),e.strstart=e.w_size,e.insert=e.strstart):(e.window_size-e.strstart<=a&&(e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,e.insert>e.strstart&&(e.insert=e.strstart)),e.window.set(e.strm.input.subarray(e.strm.next_in-a,e.strm.next_in),e.strstart),e.strstart+=a,e.insert+=a>e.w_size-e.insert?e.w_size-e.insert:a),e.block_start=e.strstart),e.high_water<e.strstart&&(e.high_water=e.strstart),o?4:t!==Cr&&t!==vr&&0===e.strm.avail_in&&e.strstart===e.block_start?2:(n=e.window_size-e.strstart,e.strm.avail_in>n&&e.block_start>=e.w_size&&(e.block_start-=e.w_size,e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,n+=e.w_size,e.insert>e.strstart&&(e.insert=e.strstart)),n>e.strm.avail_in&&(n=e.strm.avail_in),n&&(tn(e.strm,e.window,e.strstart,n),e.strstart+=n,e.insert+=n>e.w_size-e.insert?e.w_size-e.insert:n),e.high_water<e.strstart&&(e.high_water=e.strstart),n=e.bi_valid+42>>3,n=e.pending_buf_size-n>65535?65535:e.pending_buf_size-n,s=n>e.w_size?e.w_size:n,r=e.strstart-e.block_start,(r>=s||(r||t===vr)&&t!==Cr&&0===e.strm.avail_in&&r<=n)&&(i=r>n?n:r,o=t===vr&&0===e.strm.avail_in&&i===r?1:0,Tr(e,e.block_start,i,o),e.block_start+=i,Qr(e.strm)),o?3:1)},on=(e,t)=>{let i,r;for(;;){if(e.lookahead<jr){if(nn(e),e.lookahead<jr&&t===Cr)return 1;if(0===e.lookahead)break}if(i=0,e.lookahead>=3&&(e.ins_h=zr(e,e.ins_h,e.window[e.strstart+3-1]),i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==i&&e.strstart-i<=e.w_size-jr&&(e.match_length=rn(e,i)),e.match_length>=3)if(r=Rr(e,e.strstart-e.match_start,e.match_length-3),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=3){e.match_length--;do{e.strstart++,e.ins_h=zr(e,e.ins_h,e.window[e.strstart+3-1]),i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart}while(0!=--e.match_length);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=zr(e,e.ins_h,e.window[e.strstart+1]);else r=Rr(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(r&&(Zr(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,t===vr?(Zr(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(Zr(e,!1),0===e.strm.avail_out)?1:2},an=(e,t)=>{let i,r,n;for(;;){if(e.lookahead<jr){if(nn(e),e.lookahead<jr&&t===Cr)return 1;if(0===e.lookahead)break}if(i=0,e.lookahead>=3&&(e.ins_h=zr(e,e.ins_h,e.window[e.strstart+3-1]),i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=2,0!==i&&e.prev_length<e.max_lazy_match&&e.strstart-i<=e.w_size-jr&&(e.match_length=rn(e,i),e.match_length<=5&&(e.strategy===Mr||3===e.match_length&&e.strstart-e.match_start>4096)&&(e.match_length=2)),e.prev_length>=3&&e.match_length<=e.prev_length){n=e.strstart+e.lookahead-3,r=Rr(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=n&&(e.ins_h=zr(e,e.ins_h,e.window[e.strstart+3-1]),i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart)}while(0!=--e.prev_length);if(e.match_available=0,e.match_length=2,e.strstart++,r&&(Zr(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if(r=Rr(e,0,e.window[e.strstart-1]),r&&Zr(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return 1}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(r=Rr(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,t===vr?(Zr(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(Zr(e,!1),0===e.strm.avail_out)?1:2};function ln(e,t,i,r,n){this.good_length=e,this.max_lazy=t,this.nice_length=i,this.max_chain=r,this.func=n}const _n=[new ln(0,0,0,0,sn),new ln(4,4,8,4,on),new ln(4,5,16,8,on),new ln(4,6,32,32,on),new ln(4,4,16,16,an),new ln(8,16,32,32,an),new ln(8,16,128,128,an),new ln(8,32,128,256,an),new ln(32,128,258,1024,an),new ln(32,258,258,4096,an)];function cn(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=Gr,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(1146),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),qr(this.dyn_ltree),qr(this.dyn_dtree),qr(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),qr(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),qr(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const dn=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.status!==Hr&&57!==t.status&&69!==t.status&&73!==t.status&&91!==t.status&&103!==t.status&&t.status!==Jr&&t.status!==$r?1:0},un=e=>{if(dn(e))return Kr(e,yr);e.total_in=e.total_out=0,e.data_type=Vr;const t=e.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=2===t.wrap?57:t.wrap?Hr:Jr,e.adler=2===t.wrap?0:1,t.last_flush=-2,Ir(t),Ar},hn=e=>{const t=un(e);var i;return t===Ar&&((i=e.state).window_size=2*i.w_size,qr(i.head),i.max_lazy_match=_n[i.level].max_lazy,i.good_match=_n[i.level].good_length,i.nice_match=_n[i.level].nice_length,i.max_chain_length=_n[i.level].max_chain,i.strstart=0,i.block_start=0,i.lookahead=0,i.insert=0,i.match_length=i.prev_length=2,i.match_available=0,i.ins_h=0),t},gn=(e,t,i,r,n,s)=>{if(!e)return yr;let o=1;if(t===Dr&&(t=6),r<0?(o=0,r=-r):r>15&&(o=2,r-=16),n<1||n>9||i!==Gr||r<8||r>15||t<0||t>9||s<0||s>xr||8===r&&1!==o)return Kr(e,yr);8===r&&(r=9);const a=new cn;return e.state=a,a.strm=e,a.status=Hr,a.wrap=o,a.gzhead=null,a.w_bits=r,a.w_size=1<<a.w_bits,a.w_mask=a.w_size-1,a.hash_bits=n+7,a.hash_size=1<<a.hash_bits,a.hash_mask=a.hash_size-1,a.hash_shift=~~((a.hash_bits+3-1)/3),a.window=new Uint8Array(2*a.w_size),a.head=new Uint16Array(a.hash_size),a.prev=new Uint16Array(a.w_size),a.lit_bufsize=1<<n+6,a.pending_buf_size=4*a.lit_bufsize,a.pending_buf=new Uint8Array(a.pending_buf_size),a.sym_buf=a.lit_bufsize,a.sym_end=3*(a.lit_bufsize-1),a.level=t,a.strategy=s,a.method=i,hn(e)};var pn={deflateInit:(e,t)=>gn(e,t,Gr,15,8,Br),deflateInit2:gn,deflateReset:hn,deflateResetKeep:un,deflateSetHeader:(e,t)=>dn(e)||2!==e.state.wrap?yr:(e.state.gzhead=t,Ar),deflate:(e,t)=>{if(dn(e)||t>br||t<0)return e?Kr(e,yr):yr;const i=e.state;if(!e.output||0!==e.avail_in&&!e.input||i.status===$r&&t!==vr)return Kr(e,0===e.avail_out?Ur:yr);const r=i.last_flush;if(i.last_flush=t,0!==i.pending){if(Qr(e),0===e.avail_out)return i.last_flush=-1,Ar}else if(0===e.avail_in&&Yr(t)<=Yr(r)&&t!==vr)return Kr(e,Ur);if(i.status===$r&&0!==e.avail_in)return Kr(e,Ur);if(i.status===Hr&&0===i.wrap&&(i.status=Jr),i.status===Hr){let t=Gr+(i.w_bits-8<<4)<<8,r=-1;if(r=i.strategy>=wr||i.level<2?0:i.level<6?1:6===i.level?2:3,t|=r<<6,0!==i.strstart&&(t|=32),t+=31-t%31,en(i,t),0!==i.strstart&&(en(i,e.adler>>>16),en(i,65535&e.adler)),e.adler=1,i.status=Jr,Qr(e),0!==i.pending)return i.last_flush=-1,Ar}if(57===i.status)if(e.adler=0,Xr(i,31),Xr(i,139),Xr(i,8),i.gzhead)Xr(i,(i.gzhead.text?1:0)+(i.gzhead.hcrc?2:0)+(i.gzhead.extra?4:0)+(i.gzhead.name?8:0)+(i.gzhead.comment?16:0)),Xr(i,255&i.gzhead.time),Xr(i,i.gzhead.time>>8&255),Xr(i,i.gzhead.time>>16&255),Xr(i,i.gzhead.time>>24&255),Xr(i,9===i.level?2:i.strategy>=wr||i.level<2?4:0),Xr(i,255&i.gzhead.os),i.gzhead.extra&&i.gzhead.extra.length&&(Xr(i,255&i.gzhead.extra.length),Xr(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(e.adler=pr(e.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=69;else if(Xr(i,0),Xr(i,0),Xr(i,0),Xr(i,0),Xr(i,0),Xr(i,9===i.level?2:i.strategy>=wr||i.level<2?4:0),Xr(i,3),i.status=Jr,Qr(e),0!==i.pending)return i.last_flush=-1,Ar;if(69===i.status){if(i.gzhead.extra){let t=i.pending,r=(65535&i.gzhead.extra.length)-i.gzindex;for(;i.pending+r>i.pending_buf_size;){let n=i.pending_buf_size-i.pending;if(i.pending_buf.set(i.gzhead.extra.subarray(i.gzindex,i.gzindex+n),i.pending),i.pending=i.pending_buf_size,i.gzhead.hcrc&&i.pending>t&&(e.adler=pr(e.adler,i.pending_buf,i.pending-t,t)),i.gzindex+=n,Qr(e),0!==i.pending)return i.last_flush=-1,Ar;t=0,r-=n}let n=new Uint8Array(i.gzhead.extra);i.pending_buf.set(n.subarray(i.gzindex,i.gzindex+r),i.pending),i.pending+=r,i.gzhead.hcrc&&i.pending>t&&(e.adler=pr(e.adler,i.pending_buf,i.pending-t,t)),i.gzindex=0}i.status=73}if(73===i.status){if(i.gzhead.name){let t,r=i.pending;do{if(i.pending===i.pending_buf_size){if(i.gzhead.hcrc&&i.pending>r&&(e.adler=pr(e.adler,i.pending_buf,i.pending-r,r)),Qr(e),0!==i.pending)return i.last_flush=-1,Ar;r=0}t=i.gzindex<i.gzhead.name.length?255&i.gzhead.name.charCodeAt(i.gzindex++):0,Xr(i,t)}while(0!==t);i.gzhead.hcrc&&i.pending>r&&(e.adler=pr(e.adler,i.pending_buf,i.pending-r,r)),i.gzindex=0}i.status=91}if(91===i.status){if(i.gzhead.comment){let t,r=i.pending;do{if(i.pending===i.pending_buf_size){if(i.gzhead.hcrc&&i.pending>r&&(e.adler=pr(e.adler,i.pending_buf,i.pending-r,r)),Qr(e),0!==i.pending)return i.last_flush=-1,Ar;r=0}t=i.gzindex<i.gzhead.comment.length?255&i.gzhead.comment.charCodeAt(i.gzindex++):0,Xr(i,t)}while(0!==t);i.gzhead.hcrc&&i.pending>r&&(e.adler=pr(e.adler,i.pending_buf,i.pending-r,r))}i.status=103}if(103===i.status){if(i.gzhead.hcrc){if(i.pending+2>i.pending_buf_size&&(Qr(e),0!==i.pending))return i.last_flush=-1,Ar;Xr(i,255&e.adler),Xr(i,e.adler>>8&255),e.adler=0}if(i.status=Jr,Qr(e),0!==i.pending)return i.last_flush=-1,Ar}if(0!==e.avail_in||0!==i.lookahead||t!==Cr&&i.status!==$r){let r=0===i.level?sn(i,t):i.strategy===wr?((e,t)=>{let i;for(;;){if(0===e.lookahead&&(nn(e),0===e.lookahead)){if(t===Cr)return 1;break}if(e.match_length=0,i=Rr(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,i&&(Zr(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===vr?(Zr(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(Zr(e,!1),0===e.strm.avail_out)?1:2})(i,t):i.strategy===kr?((e,t)=>{let i,r,n,s;const o=e.window;for(;;){if(e.lookahead<=Fr){if(nn(e),e.lookahead<=Fr&&t===Cr)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&e.strstart>0&&(n=e.strstart-1,r=o[n],r===o[++n]&&r===o[++n]&&r===o[++n])){s=e.strstart+Fr;do{}while(r===o[++n]&&r===o[++n]&&r===o[++n]&&r===o[++n]&&r===o[++n]&&r===o[++n]&&r===o[++n]&&r===o[++n]&&n<s);e.match_length=Fr-(s-n),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(i=Rr(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(i=Rr(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),i&&(Zr(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===vr?(Zr(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(Zr(e,!1),0===e.strm.avail_out)?1:2})(i,t):_n[i.level].func(i,t);if(3!==r&&4!==r||(i.status=$r),1===r||3===r)return 0===e.avail_out&&(i.last_flush=-1),Ar;if(2===r&&(t===Lr?Sr(i):t!==br&&(Tr(i,0,0,!1),t===Or&&(qr(i.head),0===i.lookahead&&(i.strstart=0,i.block_start=0,i.insert=0))),Qr(e),0===e.avail_out))return i.last_flush=-1,Ar}return t!==vr?Ar:i.wrap<=0?Nr:(2===i.wrap?(Xr(i,255&e.adler),Xr(i,e.adler>>8&255),Xr(i,e.adler>>16&255),Xr(i,e.adler>>24&255),Xr(i,255&e.total_in),Xr(i,e.total_in>>8&255),Xr(i,e.total_in>>16&255),Xr(i,e.total_in>>24&255)):(en(i,e.adler>>>16),en(i,65535&e.adler)),Qr(e),i.wrap>0&&(i.wrap=-i.wrap),0!==i.pending?Ar:Nr)},deflateEnd:e=>{if(dn(e))return yr;const t=e.state.status;return e.state=null,t===Jr?Kr(e,Pr):Ar},deflateSetDictionary:(e,t)=>{let i=t.length;if(dn(e))return yr;const r=e.state,n=r.wrap;if(2===n||1===n&&r.status!==Hr||r.lookahead)return yr;if(1===n&&(e.adler=hr(e.adler,t,i,0)),r.wrap=0,i>=r.w_size){0===n&&(qr(r.head),r.strstart=0,r.block_start=0,r.insert=0);let e=new Uint8Array(r.w_size);e.set(t.subarray(i-r.w_size,i),0),t=e,i=r.w_size}const s=e.avail_in,o=e.next_in,a=e.input;for(e.avail_in=i,e.next_in=0,e.input=t,nn(r);r.lookahead>=3;){let e=r.strstart,t=r.lookahead-2;do{r.ins_h=zr(r,r.ins_h,r.window[e+3-1]),r.prev[e&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=e,e++}while(--t);r.strstart=e,r.lookahead=2,nn(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=2,r.match_available=0,e.next_in=o,e.input=a,e.avail_in=s,r.wrap=n,Ar},deflateInfo:"pako deflate (from Nodeca project)"};const fn=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var En={assign:function(e){const t=Array.prototype.slice.call(arguments,1);for(;t.length;){const i=t.shift();if(i){if("object"!=typeof i)throw new TypeError(i+"must be non-object");for(const t in i)fn(i,t)&&(e[t]=i[t])}}return e},flattenChunks:e=>{let t=0;for(let i=0,r=e.length;i<r;i++)t+=e[i].length;const i=new Uint8Array(t);for(let t=0,r=0,n=e.length;t<n;t++){let n=e[t];i.set(n,r),r+=n.length}return i}};let In=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(e){In=!1}const Tn=new Uint8Array(256);for(let e=0;e<256;e++)Tn[e]=e>=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;Tn[254]=Tn[254]=1;var mn={string2buf:e=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(e);let t,i,r,n,s,o=e.length,a=0;for(n=0;n<o;n++)i=e.charCodeAt(n),55296==(64512&i)&&n+1<o&&(r=e.charCodeAt(n+1),56320==(64512&r)&&(i=65536+(i-55296<<10)+(r-56320),n++)),a+=i<128?1:i<2048?2:i<65536?3:4;for(t=new Uint8Array(a),s=0,n=0;s<a;n++)i=e.charCodeAt(n),55296==(64512&i)&&n+1<o&&(r=e.charCodeAt(n+1),56320==(64512&r)&&(i=65536+(i-55296<<10)+(r-56320),n++)),i<128?t[s++]=i:i<2048?(t[s++]=192|i>>>6,t[s++]=128|63&i):i<65536?(t[s++]=224|i>>>12,t[s++]=128|i>>>6&63,t[s++]=128|63&i):(t[s++]=240|i>>>18,t[s++]=128|i>>>12&63,t[s++]=128|i>>>6&63,t[s++]=128|63&i);return t},buf2string:(e,t)=>{const i=t||e.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(e.subarray(0,t));let r,n;const s=new Array(2*i);for(n=0,r=0;r<i;){let t=e[r++];if(t<128){s[n++]=t;continue}let o=Tn[t];if(o>4)s[n++]=65533,r+=o-1;else{for(t&=2===o?31:3===o?15:7;o>1&&r<i;)t=t<<6|63&e[r++],o--;o>1?s[n++]=65533:t<65536?s[n++]=t:(t-=65536,s[n++]=55296|t>>10&1023,s[n++]=56320|1023&t)}}return((e,t)=>{if(t<65534&&e.subarray&&In)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));let i="";for(let r=0;r<t;r++)i+=String.fromCharCode(e[r]);return i})(s,n)},utf8border:(e,t)=>{(t=t||e.length)>e.length&&(t=e.length);let i=t-1;for(;i>=0&&128==(192&e[i]);)i--;return i<0||0===i?t:i+Tn[e[i]]>t?i:t}};var Rn=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0};const Sn=Object.prototype.toString,{Z_NO_FLUSH:Cn,Z_SYNC_FLUSH:Ln,Z_FULL_FLUSH:On,Z_FINISH:vn,Z_OK:bn,Z_STREAM_END:An,Z_DEFAULT_COMPRESSION:Nn,Z_DEFAULT_STRATEGY:yn,Z_DEFLATED:Pn}=Er;function Un(e){this.options=En.assign({level:Nn,method:Pn,chunkSize:16384,windowBits:15,memLevel:8,strategy:yn},e||{});let t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Rn,this.strm.avail_out=0;let i=pn.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(i!==bn)throw new Error(fr[i]);if(t.header&&pn.deflateSetHeader(this.strm,t.header),t.dictionary){let e;if(e="string"==typeof t.dictionary?mn.string2buf(t.dictionary):"[object ArrayBuffer]"===Sn.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,i=pn.deflateSetDictionary(this.strm,e),i!==bn)throw new Error(fr[i]);this._dict_set=!0}}function Dn(e,t){const i=new Un(t);if(i.push(e,!0),i.err)throw i.msg||fr[i.err];return i.result}Un.prototype.push=function(e,t){const i=this.strm,r=this.options.chunkSize;let n,s;if(this.ended)return!1;for(s=t===~~t?t:!0===t?vn:Cn,"string"==typeof e?i.input=mn.string2buf(e):"[object ArrayBuffer]"===Sn.call(e)?i.input=new Uint8Array(e):i.input=e,i.next_in=0,i.avail_in=i.input.length;;)if(0===i.avail_out&&(i.output=new Uint8Array(r),i.next_out=0,i.avail_out=r),(s===Ln||s===On)&&i.avail_out<=6)this.onData(i.output.subarray(0,i.next_out)),i.avail_out=0;else{if(n=pn.deflate(i,s),n===An)return i.next_out>0&&this.onData(i.output.subarray(0,i.next_out)),n=pn.deflateEnd(this.strm),this.onEnd(n),this.ended=!0,n===bn;if(0!==i.avail_out){if(s>0&&i.next_out>0)this.onData(i.output.subarray(0,i.next_out)),i.avail_out=0;else if(0===i.avail_in)break}else this.onData(i.output)}return!0},Un.prototype.onData=function(e){this.chunks.push(e)},Un.prototype.onEnd=function(e){e===bn&&(this.result=En.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var Mn={Deflate:Un,deflate:Dn,deflateRaw:function(e,t){return(t=t||{}).raw=!0,Dn(e,t)},gzip:function(e,t){return(t=t||{}).gzip=!0,Dn(e,t)},constants:Er};const wn=16209;var kn=function(e,t){let i,r,n,s,o,a,l,_,c,d,u,h,g,p,f,E,I,T,m,R,S,C,L,O;const v=e.state;i=e.next_in,L=e.input,r=i+(e.avail_in-5),n=e.next_out,O=e.output,s=n-(t-e.avail_out),o=n+(e.avail_out-257),a=v.dmax,l=v.wsize,_=v.whave,c=v.wnext,d=v.window,u=v.hold,h=v.bits,g=v.lencode,p=v.distcode,f=(1<<v.lenbits)-1,E=(1<<v.distbits)-1;e:do{h<15&&(u+=L[i++]<<h,h+=8,u+=L[i++]<<h,h+=8),I=g[u&f];t:for(;;){if(T=I>>>24,u>>>=T,h-=T,T=I>>>16&255,0===T)O[n++]=65535&I;else{if(!(16&T)){if(64&T){if(32&T){v.mode=16191;break e}e.msg="invalid literal/length code",v.mode=wn;break e}I=g[(65535&I)+(u&(1<<T)-1)];continue t}for(m=65535&I,T&=15,T&&(h<T&&(u+=L[i++]<<h,h+=8),m+=u&(1<<T)-1,u>>>=T,h-=T),h<15&&(u+=L[i++]<<h,h+=8,u+=L[i++]<<h,h+=8),I=p[u&E];;){if(T=I>>>24,u>>>=T,h-=T,T=I>>>16&255,16&T){if(R=65535&I,T&=15,h<T&&(u+=L[i++]<<h,h+=8,h<T&&(u+=L[i++]<<h,h+=8)),R+=u&(1<<T)-1,R>a){e.msg="invalid distance too far back",v.mode=wn;break e}if(u>>>=T,h-=T,T=n-s,R>T){if(T=R-T,T>_&&v.sane){e.msg="invalid distance too far back",v.mode=wn;break e}if(S=0,C=d,0===c){if(S+=l-T,T<m){m-=T;do{O[n++]=d[S++]}while(--T);S=n-R,C=O}}else if(c<T){if(S+=l+c-T,T-=c,T<m){m-=T;do{O[n++]=d[S++]}while(--T);if(S=0,c<m){T=c,m-=T;do{O[n++]=d[S++]}while(--T);S=n-R,C=O}}}else if(S+=c-T,T<m){m-=T;do{O[n++]=d[S++]}while(--T);S=n-R,C=O}for(;m>2;)O[n++]=C[S++],O[n++]=C[S++],O[n++]=C[S++],m-=3;m&&(O[n++]=C[S++],m>1&&(O[n++]=C[S++]))}else{S=n-R;do{O[n++]=O[S++],O[n++]=O[S++],O[n++]=O[S++],m-=3}while(m>2);m&&(O[n++]=O[S++],m>1&&(O[n++]=O[S++]))}break}if(64&T){e.msg="invalid distance code",v.mode=wn;break e}I=p[(65535&I)+(u&(1<<T)-1)]}}break}}while(i<r&&n<o);m=h>>3,i-=m,h-=m<<3,u&=(1<<h)-1,e.next_in=i,e.next_out=n,e.avail_in=i<r?r-i+5:5-(i-r),e.avail_out=n<o?o-n+257:257-(n-o),v.hold=u,v.bits=h};const xn=15,Bn=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),Vn=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),Gn=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),Fn=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]);var jn=(e,t,i,r,n,s,o,a)=>{const l=a.bits;let _,c,d,u,h,g,p=0,f=0,E=0,I=0,T=0,m=0,R=0,S=0,C=0,L=0,O=null;const v=new Uint16Array(16),b=new Uint16Array(16);let A,N,y,P=null;for(p=0;p<=xn;p++)v[p]=0;for(f=0;f<r;f++)v[t[i+f]]++;for(T=l,I=xn;I>=1&&0===v[I];I--);if(T>I&&(T=I),0===I)return n[s++]=20971520,n[s++]=20971520,a.bits=1,0;for(E=1;E<I&&0===v[E];E++);for(T<E&&(T=E),S=1,p=1;p<=xn;p++)if(S<<=1,S-=v[p],S<0)return-1;if(S>0&&(0===e||1!==I))return-1;for(b[1]=0,p=1;p<xn;p++)b[p+1]=b[p]+v[p];for(f=0;f<r;f++)0!==t[i+f]&&(o[b[t[i+f]]++]=f);if(0===e?(O=P=o,g=20):1===e?(O=Bn,P=Vn,g=257):(O=Gn,P=Fn,g=0),L=0,f=0,p=E,h=s,m=T,R=0,d=-1,C=1<<T,u=C-1,1===e&&C>852||2===e&&C>592)return 1;for(;;){A=p-R,o[f]+1<g?(N=0,y=o[f]):o[f]>=g?(N=P[o[f]-g],y=O[o[f]-g]):(N=96,y=0),_=1<<p-R,c=1<<m,E=c;do{c-=_,n[h+(L>>R)+c]=A<<24|N<<16|y}while(0!==c);for(_=1<<p-1;L&_;)_>>=1;if(0!==_?(L&=_-1,L+=_):L=0,f++,0==--v[p]){if(p===I)break;p=t[i+o[f]]}if(p>T&&(L&u)!==d){for(0===R&&(R=T),h+=E,m=p-R,S=1<<m;m+R<I&&(S-=v[m+R],!(S<=0));)m++,S<<=1;if(C+=1<<m,1===e&&C>852||2===e&&C>592)return 1;d=L&u,n[d]=T<<24|m<<16|h-s}}return 0!==L&&(n[h+L]=p-R<<24|64<<16),a.bits=T,0};const{Z_FINISH:Hn,Z_BLOCK:Jn,Z_TREES:$n,Z_OK:Kn,Z_STREAM_END:Yn,Z_NEED_DICT:qn,Z_STREAM_ERROR:Wn,Z_DATA_ERROR:zn,Z_MEM_ERROR:Qn,Z_BUF_ERROR:Zn,Z_DEFLATED:Xn}=Er,es=16180,ts=16190,is=16191,rs=16192,ns=16194,ss=16199,os=16200,as=16206,ls=16209,_s=e=>(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24);function cs(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const ds=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.mode<es||t.mode>16211?1:0},us=e=>{if(ds(e))return Wn;const t=e.state;return e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=es,t.last=0,t.havedict=0,t.flags=-1,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(852),t.distcode=t.distdyn=new Int32Array(592),t.sane=1,t.back=-1,Kn},hs=e=>{if(ds(e))return Wn;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,us(e)},gs=(e,t)=>{let i;if(ds(e))return Wn;const r=e.state;return t<0?(i=0,t=-t):(i=5+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?Wn:(null!==r.window&&r.wbits!==t&&(r.window=null),r.wrap=i,r.wbits=t,hs(e))},ps=(e,t)=>{if(!e)return Wn;const i=new cs;e.state=i,i.strm=e,i.window=null,i.mode=es;const r=gs(e,t);return r!==Kn&&(e.state=null),r};let fs,Es,Is=!0;const Ts=e=>{if(Is){fs=new Int32Array(512),Es=new Int32Array(32);let t=0;for(;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(jn(1,e.lens,0,288,fs,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;jn(2,e.lens,0,32,Es,0,e.work,{bits:5}),Is=!1}e.lencode=fs,e.lenbits=9,e.distcode=Es,e.distbits=5},ms=(e,t,i,r)=>{let n;const s=e.state;return null===s.window&&(s.wsize=1<<s.wbits,s.wnext=0,s.whave=0,s.window=new Uint8Array(s.wsize)),r>=s.wsize?(s.window.set(t.subarray(i-s.wsize,i),0),s.wnext=0,s.whave=s.wsize):(n=s.wsize-s.wnext,n>r&&(n=r),s.window.set(t.subarray(i-r,i-r+n),s.wnext),(r-=n)?(s.window.set(t.subarray(i-r,i),0),s.wnext=r,s.whave=s.wsize):(s.wnext+=n,s.wnext===s.wsize&&(s.wnext=0),s.whave<s.wsize&&(s.whave+=n))),0};var Rs={inflateReset:hs,inflateReset2:gs,inflateResetKeep:us,inflateInit:e=>ps(e,15),inflateInit2:ps,inflate:(e,t)=>{let i,r,n,s,o,a,l,_,c,d,u,h,g,p,f,E,I,T,m,R,S,C,L=0;const O=new Uint8Array(4);let v,b;const A=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(ds(e)||!e.output||!e.input&&0!==e.avail_in)return Wn;i=e.state,i.mode===is&&(i.mode=rs),o=e.next_out,n=e.output,l=e.avail_out,s=e.next_in,r=e.input,a=e.avail_in,_=i.hold,c=i.bits,d=a,u=l,C=Kn;e:for(;;)switch(i.mode){case es:if(0===i.wrap){i.mode=rs;break}for(;c<16;){if(0===a)break e;a--,_+=r[s++]<<c,c+=8}if(2&i.wrap&&35615===_){0===i.wbits&&(i.wbits=15),i.check=0,O[0]=255&_,O[1]=_>>>8&255,i.check=pr(i.check,O,2,0),_=0,c=0,i.mode=16181;break}if(i.head&&(i.head.done=!1),!(1&i.wrap)||(((255&_)<<8)+(_>>8))%31){e.msg="incorrect header check",i.mode=ls;break}if((15&_)!==Xn){e.msg="unknown compression method",i.mode=ls;break}if(_>>>=4,c-=4,S=8+(15&_),0===i.wbits&&(i.wbits=S),S>15||S>i.wbits){e.msg="invalid window size",i.mode=ls;break}i.dmax=1<<i.wbits,i.flags=0,e.adler=i.check=1,i.mode=512&_?16189:is,_=0,c=0;break;case 16181:for(;c<16;){if(0===a)break e;a--,_+=r[s++]<<c,c+=8}if(i.flags=_,(255&i.flags)!==Xn){e.msg="unknown compression method",i.mode=ls;break}if(57344&i.flags){e.msg="unknown header flags set",i.mode=ls;break}i.head&&(i.head.text=_>>8&1),512&i.flags&&4&i.wrap&&(O[0]=255&_,O[1]=_>>>8&255,i.check=pr(i.check,O,2,0)),_=0,c=0,i.mode=16182;case 16182:for(;c<32;){if(0===a)break e;a--,_+=r[s++]<<c,c+=8}i.head&&(i.head.time=_),512&i.flags&&4&i.wrap&&(O[0]=255&_,O[1]=_>>>8&255,O[2]=_>>>16&255,O[3]=_>>>24&255,i.check=pr(i.check,O,4,0)),_=0,c=0,i.mode=16183;case 16183:for(;c<16;){if(0===a)break e;a--,_+=r[s++]<<c,c+=8}i.head&&(i.head.xflags=255&_,i.head.os=_>>8),512&i.flags&&4&i.wrap&&(O[0]=255&_,O[1]=_>>>8&255,i.check=pr(i.check,O,2,0)),_=0,c=0,i.mode=16184;case 16184:if(1024&i.flags){for(;c<16;){if(0===a)break e;a--,_+=r[s++]<<c,c+=8}i.length=_,i.head&&(i.head.extra_len=_),512&i.flags&&4&i.wrap&&(O[0]=255&_,O[1]=_>>>8&255,i.check=pr(i.check,O,2,0)),_=0,c=0}else i.head&&(i.head.extra=null);i.mode=16185;case 16185:if(1024&i.flags&&(h=i.length,h>a&&(h=a),h&&(i.head&&(S=i.head.extra_len-i.length,i.head.extra||(i.head.extra=new Uint8Array(i.head.extra_len)),i.head.extra.set(r.subarray(s,s+h),S)),512&i.flags&&4&i.wrap&&(i.check=pr(i.check,r,h,s)),a-=h,s+=h,i.length-=h),i.length))break e;i.length=0,i.mode=16186;case 16186:if(2048&i.flags){if(0===a)break e;h=0;do{S=r[s+h++],i.head&&S&&i.length<65536&&(i.head.name+=String.fromCharCode(S))}while(S&&h<a);if(512&i.flags&&4&i.wrap&&(i.check=pr(i.check,r,h,s)),a-=h,s+=h,S)break e}else i.head&&(i.head.name=null);i.length=0,i.mode=16187;case 16187:if(4096&i.flags){if(0===a)break e;h=0;do{S=r[s+h++],i.head&&S&&i.length<65536&&(i.head.comment+=String.fromCharCode(S))}while(S&&h<a);if(512&i.flags&&4&i.wrap&&(i.check=pr(i.check,r,h,s)),a-=h,s+=h,S)break e}else i.head&&(i.head.comment=null);i.mode=16188;case 16188:if(512&i.flags){for(;c<16;){if(0===a)break e;a--,_+=r[s++]<<c,c+=8}if(4&i.wrap&&_!==(65535&i.check)){e.msg="header crc mismatch",i.mode=ls;break}_=0,c=0}i.head&&(i.head.hcrc=i.flags>>9&1,i.head.done=!0),e.adler=i.check=0,i.mode=is;break;case 16189:for(;c<32;){if(0===a)break e;a--,_+=r[s++]<<c,c+=8}e.adler=i.check=_s(_),_=0,c=0,i.mode=ts;case ts:if(0===i.havedict)return e.next_out=o,e.avail_out=l,e.next_in=s,e.avail_in=a,i.hold=_,i.bits=c,qn;e.adler=i.check=1,i.mode=is;case is:if(t===Jn||t===$n)break e;case rs:if(i.last){_>>>=7&c,c-=7&c,i.mode=as;break}for(;c<3;){if(0===a)break e;a--,_+=r[s++]<<c,c+=8}switch(i.last=1&_,_>>>=1,c-=1,3&_){case 0:i.mode=16193;break;case 1:if(Ts(i),i.mode=ss,t===$n){_>>>=2,c-=2;break e}break;case 2:i.mode=16196;break;case 3:e.msg="invalid block type",i.mode=ls}_>>>=2,c-=2;break;case 16193:for(_>>>=7&c,c-=7&c;c<32;){if(0===a)break e;a--,_+=r[s++]<<c,c+=8}if((65535&_)!=(_>>>16^65535)){e.msg="invalid stored block lengths",i.mode=ls;break}if(i.length=65535&_,_=0,c=0,i.mode=ns,t===$n)break e;case ns:i.mode=16195;case 16195:if(h=i.length,h){if(h>a&&(h=a),h>l&&(h=l),0===h)break e;n.set(r.subarray(s,s+h),o),a-=h,s+=h,l-=h,o+=h,i.length-=h;break}i.mode=is;break;case 16196:for(;c<14;){if(0===a)break e;a--,_+=r[s++]<<c,c+=8}if(i.nlen=257+(31&_),_>>>=5,c-=5,i.ndist=1+(31&_),_>>>=5,c-=5,i.ncode=4+(15&_),_>>>=4,c-=4,i.nlen>286||i.ndist>30){e.msg="too many length or distance symbols",i.mode=ls;break}i.have=0,i.mode=16197;case 16197:for(;i.have<i.ncode;){for(;c<3;){if(0===a)break e;a--,_+=r[s++]<<c,c+=8}i.lens[A[i.have++]]=7&_,_>>>=3,c-=3}for(;i.have<19;)i.lens[A[i.have++]]=0;if(i.lencode=i.lendyn,i.lenbits=7,v={bits:i.lenbits},C=jn(0,i.lens,0,19,i.lencode,0,i.work,v),i.lenbits=v.bits,C){e.msg="invalid code lengths set",i.mode=ls;break}i.have=0,i.mode=16198;case 16198:for(;i.have<i.nlen+i.ndist;){for(;L=i.lencode[_&(1<<i.lenbits)-1],f=L>>>24,E=L>>>16&255,I=65535&L,!(f<=c);){if(0===a)break e;a--,_+=r[s++]<<c,c+=8}if(I<16)_>>>=f,c-=f,i.lens[i.have++]=I;else{if(16===I){for(b=f+2;c<b;){if(0===a)break e;a--,_+=r[s++]<<c,c+=8}if(_>>>=f,c-=f,0===i.have){e.msg="invalid bit length repeat",i.mode=ls;break}S=i.lens[i.have-1],h=3+(3&_),_>>>=2,c-=2}else if(17===I){for(b=f+3;c<b;){if(0===a)break e;a--,_+=r[s++]<<c,c+=8}_>>>=f,c-=f,S=0,h=3+(7&_),_>>>=3,c-=3}else{for(b=f+7;c<b;){if(0===a)break e;a--,_+=r[s++]<<c,c+=8}_>>>=f,c-=f,S=0,h=11+(127&_),_>>>=7,c-=7}if(i.have+h>i.nlen+i.ndist){e.msg="invalid bit length repeat",i.mode=ls;break}for(;h--;)i.lens[i.have++]=S}}if(i.mode===ls)break;if(0===i.lens[256]){e.msg="invalid code -- missing end-of-block",i.mode=ls;break}if(i.lenbits=9,v={bits:i.lenbits},C=jn(1,i.lens,0,i.nlen,i.lencode,0,i.work,v),i.lenbits=v.bits,C){e.msg="invalid literal/lengths set",i.mode=ls;break}if(i.distbits=6,i.distcode=i.distdyn,v={bits:i.distbits},C=jn(2,i.lens,i.nlen,i.ndist,i.distcode,0,i.work,v),i.distbits=v.bits,C){e.msg="invalid distances set",i.mode=ls;break}if(i.mode=ss,t===$n)break e;case ss:i.mode=os;case os:if(a>=6&&l>=258){e.next_out=o,e.avail_out=l,e.next_in=s,e.avail_in=a,i.hold=_,i.bits=c,kn(e,u),o=e.next_out,n=e.output,l=e.avail_out,s=e.next_in,r=e.input,a=e.avail_in,_=i.hold,c=i.bits,i.mode===is&&(i.back=-1);break}for(i.back=0;L=i.lencode[_&(1<<i.lenbits)-1],f=L>>>24,E=L>>>16&255,I=65535&L,!(f<=c);){if(0===a)break e;a--,_+=r[s++]<<c,c+=8}if(E&&!(240&E)){for(T=f,m=E,R=I;L=i.lencode[R+((_&(1<<T+m)-1)>>T)],f=L>>>24,E=L>>>16&255,I=65535&L,!(T+f<=c);){if(0===a)break e;a--,_+=r[s++]<<c,c+=8}_>>>=T,c-=T,i.back+=T}if(_>>>=f,c-=f,i.back+=f,i.length=I,0===E){i.mode=16205;break}if(32&E){i.back=-1,i.mode=is;break}if(64&E){e.msg="invalid literal/length code",i.mode=ls;break}i.extra=15&E,i.mode=16201;case 16201:if(i.extra){for(b=i.extra;c<b;){if(0===a)break e;a--,_+=r[s++]<<c,c+=8}i.length+=_&(1<<i.extra)-1,_>>>=i.extra,c-=i.extra,i.back+=i.extra}i.was=i.length,i.mode=16202;case 16202:for(;L=i.distcode[_&(1<<i.distbits)-1],f=L>>>24,E=L>>>16&255,I=65535&L,!(f<=c);){if(0===a)break e;a--,_+=r[s++]<<c,c+=8}if(!(240&E)){for(T=f,m=E,R=I;L=i.distcode[R+((_&(1<<T+m)-1)>>T)],f=L>>>24,E=L>>>16&255,I=65535&L,!(T+f<=c);){if(0===a)break e;a--,_+=r[s++]<<c,c+=8}_>>>=T,c-=T,i.back+=T}if(_>>>=f,c-=f,i.back+=f,64&E){e.msg="invalid distance code",i.mode=ls;break}i.offset=I,i.extra=15&E,i.mode=16203;case 16203:if(i.extra){for(b=i.extra;c<b;){if(0===a)break e;a--,_+=r[s++]<<c,c+=8}i.offset+=_&(1<<i.extra)-1,_>>>=i.extra,c-=i.extra,i.back+=i.extra}if(i.offset>i.dmax){e.msg="invalid distance too far back",i.mode=ls;break}i.mode=16204;case 16204:if(0===l)break e;if(h=u-l,i.offset>h){if(h=i.offset-h,h>i.whave&&i.sane){e.msg="invalid distance too far back",i.mode=ls;break}h>i.wnext?(h-=i.wnext,g=i.wsize-h):g=i.wnext-h,h>i.length&&(h=i.length),p=i.window}else p=n,g=o-i.offset,h=i.length;h>l&&(h=l),l-=h,i.length-=h;do{n[o++]=p[g++]}while(--h);0===i.length&&(i.mode=os);break;case 16205:if(0===l)break e;n[o++]=i.length,l--,i.mode=os;break;case as:if(i.wrap){for(;c<32;){if(0===a)break e;a--,_|=r[s++]<<c,c+=8}if(u-=l,e.total_out+=u,i.total+=u,4&i.wrap&&u&&(e.adler=i.check=i.flags?pr(i.check,n,u,o-u):hr(i.check,n,u,o-u)),u=l,4&i.wrap&&(i.flags?_:_s(_))!==i.check){e.msg="incorrect data check",i.mode=ls;break}_=0,c=0}i.mode=16207;case 16207:if(i.wrap&&i.flags){for(;c<32;){if(0===a)break e;a--,_+=r[s++]<<c,c+=8}if(4&i.wrap&&_!==(4294967295&i.total)){e.msg="incorrect length check",i.mode=ls;break}_=0,c=0}i.mode=16208;case 16208:C=Yn;break e;case ls:C=zn;break e;case 16210:return Qn;default:return Wn}return e.next_out=o,e.avail_out=l,e.next_in=s,e.avail_in=a,i.hold=_,i.bits=c,(i.wsize||u!==e.avail_out&&i.mode<ls&&(i.mode<as||t!==Hn))&&ms(e,e.output,e.next_out,u-e.avail_out),d-=e.avail_in,u-=e.avail_out,e.total_in+=d,e.total_out+=u,i.total+=u,4&i.wrap&&u&&(e.adler=i.check=i.flags?pr(i.check,n,u,e.next_out-u):hr(i.check,n,u,e.next_out-u)),e.data_type=i.bits+(i.last?64:0)+(i.mode===is?128:0)+(i.mode===ss||i.mode===ns?256:0),(0===d&&0===u||t===Hn)&&C===Kn&&(C=Zn),C},inflateEnd:e=>{if(ds(e))return Wn;let t=e.state;return t.window&&(t.window=null),e.state=null,Kn},inflateGetHeader:(e,t)=>{if(ds(e))return Wn;const i=e.state;return 2&i.wrap?(i.head=t,t.done=!1,Kn):Wn},inflateSetDictionary:(e,t)=>{const i=t.length;let r,n,s;return ds(e)?Wn:(r=e.state,0!==r.wrap&&r.mode!==ts?Wn:r.mode===ts&&(n=1,n=hr(n,t,i,0),n!==r.check)?zn:(s=ms(e,t,i,i),s?(r.mode=16210,Qn):(r.havedict=1,Kn)))},inflateInfo:"pako inflate (from Nodeca project)"};var Ss=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1};const Cs=Object.prototype.toString,{Z_NO_FLUSH:Ls,Z_FINISH:Os,Z_OK:vs,Z_STREAM_END:bs,Z_NEED_DICT:As,Z_STREAM_ERROR:Ns,Z_DATA_ERROR:ys,Z_MEM_ERROR:Ps}=Er;function Us(e){this.options=En.assign({chunkSize:65536,windowBits:15,to:""},e||{});const t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&(15&t.windowBits||(t.windowBits|=15)),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Rn,this.strm.avail_out=0;let i=Rs.inflateInit2(this.strm,t.windowBits);if(i!==vs)throw new Error(fr[i]);if(this.header=new Ss,Rs.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=mn.string2buf(t.dictionary):"[object ArrayBuffer]"===Cs.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(i=Rs.inflateSetDictionary(this.strm,t.dictionary),i!==vs)))throw new Error(fr[i])}Us.prototype.push=function(e,t){const i=this.strm,r=this.options.chunkSize,n=this.options.dictionary;let s,o,a;if(this.ended)return!1;for(o=t===~~t?t:!0===t?Os:Ls,"[object ArrayBuffer]"===Cs.call(e)?i.input=new Uint8Array(e):i.input=e,i.next_in=0,i.avail_in=i.input.length;;){for(0===i.avail_out&&(i.output=new Uint8Array(r),i.next_out=0,i.avail_out=r),s=Rs.inflate(i,o),s===As&&n&&(s=Rs.inflateSetDictionary(i,n),s===vs?s=Rs.inflate(i,o):s===ys&&(s=As));i.avail_in>0&&s===bs&&i.state.wrap>0&&0!==e[i.next_in];)Rs.inflateReset(i),s=Rs.inflate(i,o);switch(s){case Ns:case ys:case As:case Ps:return this.onEnd(s),this.ended=!0,!1}if(a=i.avail_out,i.next_out&&(0===i.avail_out||s===bs))if("string"===this.options.to){let e=mn.utf8border(i.output,i.next_out),t=i.next_out-e,n=mn.buf2string(i.output,e);i.next_out=t,i.avail_out=r-t,t&&i.output.set(i.output.subarray(e,e+t),0),this.onData(n)}else this.onData(i.output.length===i.next_out?i.output:i.output.subarray(0,i.next_out));if(s!==vs||0!==a){if(s===bs)return s=Rs.inflateEnd(this.strm),this.onEnd(s),this.ended=!0,!0;if(0===i.avail_in)break}}return!0},Us.prototype.onData=function(e){this.chunks.push(e)},Us.prototype.onEnd=function(e){e===vs&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=En.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};const{Deflate:Ds,deflate:Ms,deflateRaw:ws,gzip:ks}=Mn;var xs=ks;const Bs=-1,Vs="RongCloudSEIAI",Gs=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(e=>{const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})),Fs=(e,t,i)=>m(void 0,void 0,void 0,(function*(){const r=[],n=i.jwtToken||"";return new Promise(((i,s)=>{e.forEach((e=>m(void 0,void 0,void 0,(function*(){const s=`${e.detectorAddr.replace(/^(https?:\/\/)?/,"https://")}/rtc/detector/ping?t=${o=1e3,a=9999,o+Math.floor(Math.random()*(a-o))}`;var o,a;const l={jwt:n};200===(yield t.httpReq({url:s,body:JSON.stringify(l),timeout:5e3,method:V.POST})).status&&r.push(e.clusterId),i(r)}))))}))})),js=(e,t)=>{var i;if(!t)return"";let r;try{r=JSON.parse(t.voipCallInfo||'{ "strategy": 0 }')}catch(i){return e.warn(le.L_MEDIA_SERVICE_PARSE_NAVI_CALLVOIP_INFO_O,`parse \`voipCallInfo\` of navi failed: ${t.voipCallInfo}`),""}if(0===r.strategy)return"";const n=null===(i=r.callEngine)||void 0===i?void 0:i.filter((e=>4===e.engineType));if(!n||0===n.length)return"";const s=n[0];return s.detectorManager?s.detectorManager:""};var Hs;!function(e){e.OPEN="2",e.CLOSE="1"}(Hs||(Hs={}));function Js(e){const t=e.method||V.GET,i=e.timeout||6e4,{headers:r,query:n,body:s,onProgress:o}=e,a=((e,t)=>{if(e=e.replace(/\?$/,""),!t)return e;const i=Object.keys(t).map((e=>`${e}=${t[e]}`)).filter((e=>!!e));return i.length?[e,i.join("&")].join("?"):e})(e.url,n),l=new XMLHttpRequest;if(l.open(t,a),r&&l.setRequestHeader)for(const e in r)l.setRequestHeader(e,r[e]);return function(e,t,i,r){return new Promise((n=>{e.onreadystatechange=()=>{r?2===e.readyState?n({data:e.responseText,status:e.status,xhr:e}):4===e.readyState?r(e.responseText,!0):3===e.readyState&&r(e.responseText,!1):4===e.readyState&&n({data:e.responseText,status:e.status,xhr:e})},e.onerror=()=>{n({status:e.status})},0!==t&&setTimeout((()=>{e.abort(),n({status:e.status})}),t),e.send(i)}))}(l,i,s,o)}const $s=()=>({"Content-Type":"application/json;charset=UTF-8","Cache-Control":"no-cache",ClientType:`web|${Ii.browser}|${Ii.version}`,ClientVersion:"26.2.0-alpha.2","Client-Session-Id":Gs(),"Request-Id":Date.now().toString()});class Ks{constructor(e,t,i,r=5e3){Object.defineProperty(this,"_runtime",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_msUrl",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_timeout",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_failedMs",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_rtcFinger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_clusterId",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(this,"_configUrl",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(this,"_msList",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_qualityMsList",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._logger=this._context.logger,t.getConnectionStatus()===l.CONNECTED&&this.isNededDetector()&&this.detectorMediaSever()}isNededDetector(){const e=this._context.getNaviInfo();if(!e)return!1;const t=js(this._logger,e),i=e.jwtToken||"",r=Date.now();let n=!1;return 0===Ks.detectorTime?n=!1:Ks.detectValidMinute+Ks.detectorTime<r&&(n=!0),!(!t||!i||this._msUrl||n)}detectorMediaSever(){this.clearMSList();const e=this._context.getNaviInfo();this._startDetector(e)}_startDetector(e){return m(this,void 0,void 0,(function*(){var t;const{detectoraddrs:i,clientDetectMinute:r,status:n}=yield((e,t,i)=>m(void 0,void 0,void 0,(function*(){const r=js(t,i);let n=120,s=0;const o={jwt:i.jwtToken||"",ipType:i.ipType||0},a=yield e.httpReq({url:`${r}/rtc/detector/servers`,body:JSON.stringify(o),headers:{"Content-Type":"application/json;charset=UTF-8","Cache-Control":"no-cache",ClientType:`web|${Ii.browser}|${Ii.version}`,ClientVersion:"26.2.0-alpha.2","Client-Session-Id":Gs(),"Request-Id":Date.now().toString()},method:V.POST}),l=a.data&&JSON.parse(a.data).detectorAddrs||[];return n=a.data&&JSON.parse(a.data).clientDetectMinute,s=a.data&&JSON.parse(a.data).resultCode,{detectoraddrs:l,clientDetectMinute:n,status:s}})))(this._runtime,this._logger,e);if(n===ae.JWT_TIME_OUT){const e=this._context.getPluginContext();return yield null===(t=e.refetchNaviInfo)||void 0===t?void 0:t.call(e),void this.detectorMediaSever()}i.length&&(Ks.msInDetector=yield Fs(i,this._runtime,e)),Ks.detectorTime=Date.now(),Ks.detectValidMinute=60*r*1e3}))}clearMSList(){this._msList.length=0}getMsList(){return this._msUrl?[this._msUrl]:(this._sortMediaServiceList(),[...this._msList])}_sortMediaServiceList(){let e=Ks.msInDetector[0];const t=Ks.msInDetector.slice(1),i=((e,t)=>{var i;if(!e)return[];let r;try{r=JSON.parse(e.voipCallInfo||'{ "strategy": 0 }')}catch(i){return t.warn(le.L_PARSE_VOIP_SERVER_CONF_E,e.voipCallInfo),[]}if(0===r.strategy)return[];const n=null===(i=r.callEngine)||void 0===i?void 0:i.filter((e=>4===e.engineType));if(!n||0===n.length)return[];const s=n[0],o=[];return s.mediaServer&&o.push(s.mediaServer.replace(/^(https?:\/\/)?/,"https://")),s.backupMediaServer&&s.backupMediaServer.forEach((e=>{o.push(e.replace(/^(https?:\/\/)?/,"https://"))})),o})(this._context.getNaviInfo(),this._logger),r=i[0],n=i.slice(1);const s=[this._clusterId,e,r,...t,...n].filter((e=>!!e)).map((e=>e.replace(/^(https?:\/\/)?/,"https://")));this._msList=[...new Set(s)],this._logger.info(le.L_MEDIA_SERVICE_MSLIST_CHANGE_O,`MediaServiceList msList -> ${JSON.stringify(this._msList)}`)}_openGzip(e,t){const i=JSON.stringify(t),r=i.length,n=new Uint8Array(r);for(let e=0;e<r;e++)n[e]=i.charCodeAt(e);var s;return{headers:e=Object.assign(Object.assign({},e),{"Content-Encoding":"gzip","Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"}),body:t=xs(n,s)}}_dealRequestSuccessResult(e){const t=JSON.parse(e);return t.rtcFinger&&(this._rtcFinger=t.rtcFinger),t.clusterId&&(this._clusterId!==t.clusterId&&this.clearMSList(),this._clusterId=t.clusterId),{code:ae.SUCCESS,data:t,qualityMsList:this._qualityMsList}}_request(e,t,i,r,n,s){return m(this,void 0,void 0,(function*(){this._qualityMsList=[];const{headers:o,body:a}={headers:t,body:i},l=this.getMsList();if(0===l.length)return this._logger.error(le.L_MEDIA_SERVICE_REQUEST_R,JSON.stringify({status:_e.FAILED,code:ae.NOT_OPEN_VIDEO_AUDIO_SERVER,msg:"have no valid service address"}),r),{code:ae.NOT_OPEN_VIDEO_AUDIO_SERVER};this._rtcFinger&&(a.rtcFinger=this._rtcFinger);for(let t=0;t<l.length;t+=1){const i=Date.now(),_=`${l[t]}${e}`,c=$s(),d=Object.assign(Object.assign({},c),o),u=/x-www-form-urlencoded/.test(d["Content-Type"])?a:JSON.stringify(a),h=c["Request-Id"];let g;this._logger.info(le.L_MEDIA_SERVICE_REQUEST_T,JSON.stringify({url:_,"Request-Id":h}),r);const p={url:_,body:u,headers:d,method:V.POST,timeout:this._timeout};g=s?yield Js(Object.assign(Object.assign({},p),{onProgress:s})):yield this._runtime.httpReq(Object.assign({},p));const{status:f,data:E,xhr:I}=g;if(n&&this._qualityMsList.push({rsdur:Date.now()-i,rsid:h,rscod:200===f?ae.SUCCESS:ae.REQUEST_FAILED,msa:_}),200===f)return this._logger.info(le.L_MEDIA_SERVICE_REQUEST_R,JSON.stringify({status:_e.SUCCESSED,url:_}),r),s?{code:ae.SUCCESS,data:I}:this._dealRequestSuccessResult(E);this._logger.error(le.L_MEDIA_SERVICE_REQUEST_R,JSON.stringify({status:_e.FAILED,msg:`request error -> Request-Id: ${h}, status: ${f}, url: ${_}`,timeout:this._timeout}),r)}return{code:ae.REQUEST_FAILED,qualityMsList:this._qualityMsList}}))}exchange(e,t,i,r){return m(this,void 0,void 0,(function*(){var n;const s=yield this._request("/exchange",e,t,i,r);if(s.code===ae.SUCCESS&&(null===(n=s.data)||void 0===n?void 0:n.resultCode)===ae.SUCCESS){const{urls:e}=s.data;e&&(this._configUrl=e.configUrl)}return s}))}exit(e){return m(this,void 0,void 0,(function*(){const t=this._logger.createTraceId(),{code:i}=yield this._request("/exit",e,{},t);return i}))}broadcastSubscribe(e,t){const i=this._logger.createTraceId();return this._request("/broadcast/subscribe",e,t,i,!0)}broadcastExit(e){return m(this,void 0,void 0,(function*(){const t=this._logger.createTraceId(),{code:i}=yield this._request("/broadcast/exit",e,{},t,!0);return{code:i}}))}setMcuConfig(e,t){return m(this,void 0,void 0,(function*(){const i=this._logger.createTraceId();if(this._logger.info(le.L_MEDIA_SERVICE_SET_MCU_CONFIG_T,JSON.stringify({body:t}),i),!this._configUrl)return this._logger.error(le.L_MEDIA_SERVICE_SET_MCU_CONFIG_R,JSON.stringify({status:_e.FAILED,code:ae.MCU_SERVER_NOT_FOUND,msg:"MCU server not found"}),i),{code:ae.MCU_SERVER_NOT_FOUND};const r=`${this._configUrl.replace(/^(https?:\/\/)?/,"https://")}/server/mcu/config`,n=$s(),s=Object.assign(Object.assign({},n),e),o=JSON.stringify(t),a=n["Request-Id"],{status:l,data:_}=yield this._runtime.httpReq({url:r,headers:s,body:o,method:V.POST});if(200===l){const e=JSON.parse(_),t=e.resultCode;return t===ae.SUCCESS?this._logger.info(le.L_MEDIA_SERVICE_SET_MCU_CONFIG_R,JSON.stringify({status:_e.SUCCESSED,"Request-Id":a}),i):this._logger.warn(le.L_MEDIA_SERVICE_SET_MCU_CONFIG_R,JSON.stringify({code:t,"Request-Id":a}),i),{code:t,res:e}}return this._logger.error(le.L_MEDIA_SERVICE_SET_MCU_CONFIG_R,JSON.stringify({status:_e.FAILED,code:ae.REQUEST_FAILED,msg:`request error -> Request-Id: ${a}, status: ${l}, url: ${r}`}),i),{code:ae.REQUEST_FAILED}}))}getCDNResourceInfo(e,t,i){return m(this,void 0,void 0,(function*(){const r=$s(),n=Object.assign(Object.assign({},r),e),s=r["Request-Id"];this._logger.info(le.L_MEDIA_SERVICE_GET_CDN_RESOURCE_INFO_T,`Request-Id: ${s}, url: ${t}`,i);const{status:o,data:a}=yield this._runtime.httpReq({url:t,headers:n,method:V.GET});if(200===o){const e=JSON.parse(a);return this._logger.info(le.L_MEDIA_SERVICE_GET_CDN_RESOURCE_INFO_R,JSON.stringify({status:_e.SUCCESSED,cdnPlayerUrl:null==e?void 0:e.data.pull_url}),i),{code:e.resultCode,res:e}}return this._logger.info(le.L_MEDIA_SERVICE_GET_CDN_RESOURCE_INFO_R,JSON.stringify({status:_e.FAILED,code:ae.REQUEST_FAILED}),i),{code:ae.REQUEST_FAILED}}))}updateASRStatus(e,t,i){return m(this,void 0,void 0,(function*(){return yield this._request("/rtc/media/v1/asr/update",e,t,i)}))}operateRealtimeTranslation(e,t,i){return m(this,void 0,void 0,(function*(){return yield this._request("/rtc/media/v1/asr/translation",e,t,i)}))}operateSummarization(e,t,i){return m(this,void 0,void 0,(function*(){const r="/rtc/media/v1/ai/room/sum/"+(t.status===Hs.OPEN?"start":"stop");return yield this._request(r,e,t,i)}))}generateSummarization(e,t,i,r,n,s,o){return m(this,void 0,void 0,(function*(){const a={"App-Key":this._context.getAppkey(),UserId:this._context.getCurrentId(),RoomId:e,"X-Stream":!0},l={taskId:t,startTime:i,endTime:r,config:{summarization:n.enableSummarization,summarizationDetails:n.enableSummarizationDetails,chapterSummary:n.enableChapterSummary,todoList:n.enableTodoList,hashtag:n.enableHashtag,language:n.destLang,format:n.format,custom:n.customPrompt}},{code:_,data:c}=yield this._request("/rtc/media/v1/ai/room/sum/gen",a,l,o,!1,((e,t)=>{s(e,t)})),d=null==c?void 0:c.getResponseHeader("x-code"),u=null==c?void 0:c.getResponseHeader("x-msg");return _===ae.SUCCESS&&d&&Number(d)!==ae.SUCCESS?{code:Number(d),msg:u}:{code:_}}))}getASRContent(e,t,i,r,n,s,o){return m(this,void 0,void 0,(function*(){const a={"App-Key":this._context.getAppkey(),UserId:this._context.getCurrentId(),RoomId:e,"X-Stream":!0},l={taskId:t,startTime:i,endTime:r,language:o},{code:_,data:c}=yield this._request("/rtc/media/v1/ai/room/sum/asr",a,l,s,!1,((e,t)=>{n(e,t)})),d=null==c?void 0:c.getResponseHeader("x-code"),u=null==c?void 0:c.getResponseHeader("x-msg");return _===ae.SUCCESS&&d&&Number(d)!==ae.SUCCESS?{code:Number(d),msg:u}:{code:_}}))}}var Ys;Object.defineProperty(Ks,"msInDetector",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(Ks,"detectorTime",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(Ks,"detectValidMinute",{enumerable:!0,configurable:!0,writable:!0,value:72e5}),function(e){e[e.NORMAL=1]="NORMAL",e[e.TINY=2]="TINY"}(Ys||(Ys={}));const qs=(e,t)=>Math.round(8*t/e),Ws=(e,t=2)=>{const i=10**t;return Math.round(e*i)/i},zs=(e,t=2)=>{e>1&&(e=1);const i=10**t;return Math.round(e*i)},Qs=(e,t,i,r)=>{if(0===t)return 0;if(!i||!r)return Ws(e/t,3);const n=t-r;if(0===n)return 0;const s=e-i;return s<0||n<0?0:Ws(s/n,3)},Zs=e=>{const{jitter:t,rtt:i,packetsLostRate:r}=e;return!Ri(t)||!Ri(i)||0!==r};var Xs,eo;!function(e){e.TRACK="track",e.STREAM="stream",e.MEDIASOURCE="media-source",e.INBOUNDRTP="inbound-rtp",e.OUTBOUNDRTP="outbound-rtp",e.REMOTEINBOUNDRTP="remote-inbound-rtp",e.PEERCONNECTION="peer-connection",e.TRANSPORT="transport",e.CERTIFICATE="certificate",e.CANDIDATEPAIR="candidate-pair",e.REMOTECANDIDATE="remote-candidate",e.LOCALCANDIDATE="local-candidate"}(Xs||(Xs={}));class to{constructor(e,t,i,r,n,s){Object.defineProperty(this,"_sdpStrategy",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_rtcPeerConn",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_sdpSemantics",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_currentUserId",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"_store",{enumerable:!0,configurable:!0,writable:!0,value:s}),Object.defineProperty(this,"_latestPacketsSent",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_latestBytesSent",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_latestBytesRecv",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_latestPacketsRecv",{enumerable:!0,configurable:!0,writable:!0,value:{}})}getTrackIdByMid(e){return this._sdpStrategy.getTrackIdByMid(e)}updateBytesSent(e,t,i){let r,n;if(this._latestBytesSent[e]&&t<this._latestBytesSent[e].bytesSent&&this.clearLatestpacketsSent([e]),this._latestBytesSent[e]){const{bytesSent:s,timestamp:o}=this._latestBytesSent[e];r=t-s,n=i-o,this._latestBytesSent[e]={bytesSent:t,timestamp:i}}else r=t,n=1e3,this._latestBytesSent[e]={bytesSent:t,timestamp:i};return qs(n,r)}updateBytesRecv(e,t,i){let r,n;if(this._latestBytesRecv[e]&&t<this._latestBytesRecv[e].bytesRecv&&this.clearLatestPacketsRecv([e]),this._latestBytesRecv[e]){const{bytesRecv:s,timestamp:o}=this._latestBytesRecv[e];r=t-s,n=i-o,this._latestBytesRecv[e]={bytesRecv:t,timestamp:i}}else r=t,n=1e3,this._latestBytesRecv[e]={bytesRecv:t,timestamp:i};return qs(n,r)}updateSenderPacketsLost(e,t,i){let r;if(Object.prototype.hasOwnProperty.call(this._latestPacketsSent[e],"packetsSent")){const{packetsLost:n,packetsSent:s}=this._latestPacketsSent[e];r=Qs(t,i,n,s),this._latestPacketsSent[e].packetsLost=t,this._latestPacketsSent[e].packetsSent=n===t?s:i}else r=Qs(t,i),this._latestPacketsSent[e].packetsLost=t,this._latestPacketsSent[e].packetsSent=i;return r}updateReceiverPacketsLost(e,t,i){let r;if(this._latestPacketsRecv[e]){const{packetsLost:n,packetsRecv:s}=this._latestPacketsRecv[e];r=Qs(t,i+t,n,s+n)}else r=Qs(t,i);return this._latestPacketsRecv[e]={packetsLost:t,packetsRecv:i},r}clearLatestpacketsSent(e){e.forEach((e=>{if(parseInt(e.split("_").pop())===vt.VIDEO_ONLY){const t=`${e}_tiny`;delete this._latestPacketsSent[t],delete this._latestBytesSent[t]}delete this._latestPacketsSent[e],delete this._latestBytesSent[e]}))}clearLatestPacketsRecv(e){e.forEach((e=>{delete this._latestPacketsRecv[e],delete this._latestBytesRecv[e]}))}parseRTCStatsReport(e){const t={};for(const[i,r]of e.entries())/codec/gi.test(r)&&i.includes("RTCCodec_")||(t[i]=r);return t}formatRCRTCStateReport(e){const t={senders:[],receivers:[]};return this._logger.info(le.L_ABSTRACT_STAT_PARSER_FORMAT_RTC_STATE_REPORT_O,JSON.stringify({status:_e.SUCCESSED,stats:e,reports:t})),t}isValidTranceiver(e,t){var i,r;const n="outbound-rtp"===t?null===(i=this._rtcPeerConn.currentLocalDescription)||void 0===i?void 0:i.sdp:null===(r=this._rtcPeerConn.currentRemoteDescription)||void 0===r?void 0:r.sdp,{ssrc:s}=e;return!(null==n?void 0:n.split("\r\nm=").some((e=>e.includes(s)&&e.includes("a=inactive"))))}formatStateData(e){return Object.values(e).reduce(((e,t)=>t.type===Xs.REMOTEINBOUNDRTP?(e.remoteInbound.push(t),e):t.type===Xs.INBOUNDRTP?(e.inbound.push(t),e):t.type===Xs.OUTBOUNDRTP?(e.outbound.push(t),e):t.type===Xs.TRANSPORT?(e.transport.push(t),e):t.type===Xs.PEERCONNECTION?(e.connection.push(t),e):e),{outbound:[],remoteInbound:[],inbound:[],transport:[],connection:[]})}}class io extends to{formatRCRTCStateReport(e){const{outbound:t,remoteInbound:i,inbound:r,transport:n,connection:s}=this.formatStateData(e),o={senders:[],receivers:[]},a=Math.floor(s[0].timestamp);o.timestamp=a;let l=0,_=0;({totalPacketsLost:l,bitrateSend:_,senders:o.senders}=this.pickOutbound(t,e,l,a,_)),i.length>0&&o.senders.length>0&&this.pickRemoteInbound(i,o.senders,e);let c=0;if(({totalPacketsLost:l,bitrateRecv:c,receivers:o.receivers}=this.pickInbound(r,e,l,a,c)),n.length>0){const t=n[0];this.pickRtcTransport(t,e,o,c,_,l)}return o}pickRtcTransport(e,t,i,r,n,s){const{selectedCandidatePairId:o}=e;if(o){const e=t[o],{availableOutgoingBitrate:a,availableIncomingBitrate:l,currentRoundTripTime:_,localCandidateId:c,remoteCandidateId:d}=e,u=t[c],{ip:h,port:g,networkType:p}=u,f=t[d],{ip:E,port:I,protocol:T}=f;i.iceCandidatePair={IP:h,port:g,networkType:p,remoteIP:E,remotePort:I,protocol:T,bitrateRecv:r,bitrateSend:n,rtt:1e3*_,availableOutgoingBitrate:a,availableIncomingBitrate:l,totalPacketsLost:s},i.receivers.forEach((e=>{e.rtt=1e3*_}))}}pickRemoteInbound(e,t,i){e.forEach((e=>{var r;const{localId:n,jitter:s,roundTripTime:o,packetsLost:a}=e,l=t.filter((e=>e.id===n))[0];if(l&&!Zs(l)){const e=null===(r=this._store)||void 0===r?void 0:r.getTrackIdBySSRC(i[l.id].ssrc);l.jitter=Math.round(1e3*s),l.rtt=o;const t=this._latestPacketsSent[e].crtPacketsSent;l.packetsLostRate=this.updateSenderPacketsLost(e,a,t)}}))}_getOutboundVideoAttrs(e,t,i,r,n){var s,o,a;let{framesPerSecond:l,frameWidth:_,frameHeight:c}=e;return"video"!==i||_||c||l||(_=(null===(s=t[r])||void 0===s?void 0:s.frameWidth)||t[n].width,c=(null===(o=t[r])||void 0===o?void 0:o.frameHeight)||t[n].height,l=(null===(a=t[n])||void 0===a?void 0:a.framesPerSecond)||null),{frameRate:l,frameWidth:_,frameHeight:c}}pickOutbound(e,t,i,r,n){const s=[];return e.forEach((e=>{var o;if("unified-plan"===this._sdpSemantics&&!this.isValidTranceiver(e,"outbound-rtp"))return;const{id:a,kind:l,mediaSourceId:_,remoteId:c,packetsSent:d,bytesSent:u,encoderImplementation:h,pliCount:g,nackCount:p,mid:f}=e;let{trackId:E}=e;if(void 0!==f&&(E=this.getTrackIdByMid(f)),!E)return;const{frameRate:I,frameWidth:T,frameHeight:m}=this._getOutboundVideoAttrs(e,t,l,E,_),R=t[c];let S=null,C=null,L=0;R&&(S=R.jitter,C=R.roundTripTime,L=R.packetsLost),i+=L;const O=null===(o=this._store)||void 0===o?void 0:o.getTrackIdBySSRC(e.ssrc);if(!O)return;const v=_?t[_].audioLevel:t[E].audioLevel;let b=0;!this._latestPacketsSent[O]&&(this._latestPacketsSent[O]={}),R?b=this.updateSenderPacketsLost(O,L,d):this._latestPacketsSent[O].crtPacketsSent=d;let A=this.updateBytesSent(O,u,r);A<0&&(A=0),n+=A,s.push({id:a,trackId:O,kind:l,packetsLostRate:b,remoteResource:!1,audioLevel:v||0===v?zs(v):null,frameWidth:T,frameHeight:m,frameRate:I,bitrate:A,jitter:S?Math.round(1e3*S):S,rtt:C?Math.round(1e3*C):C,encoderImplementation:h,pliCount:g,nackCount:p,googFirsSent:Bs,samplingRate:Bs,googRenderDelayMs:Bs,trackState:Bs})})),{totalPacketsLost:i,bitrateSend:n,senders:s}}_getInboundMediaAttrs(e,t,i,r,n){var s,o,a;let{frameWidth:l,frameHeight:_,audioLevel:c}=e;return"video"===n?l||_||(l=(null===(s=t[i])||void 0===s?void 0:s.frameWidth)||t[r].width,_=(null===(o=t[i])||void 0===o?void 0:o.frameHeight)||t[r].height):c||(c=(null===(a=t[i])||void 0===a?void 0:a.audioLevel)||t[r].audioLevel),{frameWidth:l,frameHeight:_,audioLevel:c}}pickInbound(e,t,i,r,n){let s=[];return e.forEach((e=>{var o;if("unified-plan"===this._sdpSemantics&&!this.isValidTranceiver(e,"inbound-rtp"))return;const{packetsLost:a,packetsReceived:l,jitter:_,bytesReceived:c,framesPerSecond:d,kind:u,codecImplementationName:h,nackCount:g,pliCount:p,mid:f,id:E}=e;let{trackId:I}=e;if(void 0!==f&&(I=this.getTrackIdByMid(f)),!I)return;const{frameWidth:T,frameHeight:m,audioLevel:R}=this._getInboundMediaAttrs(e,t,I,E,u);i+=a;const S=null===(o=this._store)||void 0===o?void 0:o.getTrackIdBySSRC(e.ssrc),C=this.updateReceiverPacketsLost(S,a,l);let L=this.updateBytesRecv(S,c,r);L<0&&(L=0),n+=L,s.push({trackId:S,kind:u,packetsLostRate:C,remoteResource:!0,audioLevel:R||0===R?zs(R):null,frameWidth:T,frameHeight:m,frameRate:d,bitrate:L,jitter:_?Math.round(1e3*_):0,codecImplementationName:h,nackCount:g,pliCount:p,rtt:null,samplingRate:Bs,googFirsReceived:Bs,googRenderDelayMs:Bs,trackState:Bs})})),{totalPacketsLost:i,bitrateRecv:n,receivers:s}}}class ro extends to{constructor(){super(...arguments),Object.defineProperty(this,"_reportsData",{enumerable:!0,configurable:!0,writable:!0,value:{senders:[],receivers:[],timestamp:+new Date}}),Object.defineProperty(this,"_totalPacketsLost",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_bitrateSend",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_bitrateRecv",{enumerable:!0,configurable:!0,writable:!0,value:0})}_pickSenderData(e,t,i){var r;if("unified-plan"===this._sdpSemantics&&!this.isValidTranceiver(e,i))return;const{kind:n,bytesSent:s,packetsSent:o,bitrateMean:a,framerateMean:l,nackCount:_,pliCount:c,remoteId:d}=e,{jitter:u,roundTripTime:h,packetsLost:g}=d?t[d]:{jitter:null,roundTripTime:null,packetsLost:0},p=null===(r=this._store)||void 0===r?void 0:r.getTrackIdBySSRC(e.ssrc);this._totalPacketsLost+=g;let f=0;!this._latestPacketsSent[p]&&(this._latestPacketsSent[p]={}),d?f=this.updateSenderPacketsLost(p,g,o):this._latestPacketsSent[p].crtPacketsSent=o;let E=0;"video"===n?a&&(E=Math.floor(a/1e3)):E=this.updateBytesSent(p,s,this._reportsData.timestamp),E<0&&(E=0),this._bitrateSend+=E,this._reportsData.senders.push({trackId:p,kind:n,packetsLostRate:f,remoteResource:!1,audioLevel:null,frameWidth:null,frameHeight:null,frameRate:Math.floor(l),bitrate:E,jitter:u?Math.round(1e3*u):null,rtt:h,encoderImplementation:null,pliCount:c,nackCount:_,googFirsSent:Bs,samplingRate:Bs,googRenderDelayMs:Bs,trackState:Bs})}_addSenderData(e,t){var i;const{localId:r}=t,n=null===(i=this._store)||void 0===i?void 0:i.getTrackIdBySSRC(e[r].ssrc),s=this._reportsData.senders.filter((e=>e.trackId===n))[0];s&&Zs(s)&&(s.jitter=Math.round(1e3*t.jitter),s.rtt=t.rtt,s.packetsLostRate=this.updateSenderPacketsLost(n,t.packetsLost,this._latestPacketsSent[n].crtPacketsSent))}_pickReceiverData(e,t){var i;if("unified-plan"===this._sdpSemantics&&!this.isValidTranceiver(e,t))return;const{packetsLost:r,bytesReceived:n,packetsReceived:s,jitter:o,framerateMean:a,kind:l,bitrateMean:_,nackCount:c,pliCount:d}=e,u=null===(i=this._store)||void 0===i?void 0:i.getTrackIdBySSRC(e.ssrc);this._totalPacketsLost+=r;const h=this.updateReceiverPacketsLost(u,r,s);let g=0;"video"===l?_&&(g=Math.floor(_/1e3)):g=this.updateBytesRecv(u,n,this._reportsData.timestamp),g<0&&(g=0),this._bitrateRecv+=g,this._reportsData.receivers.push({trackId:u,kind:l,packetsLostRate:h,remoteResource:!0,audioLevel:null,frameWidth:null,frameHeight:null,frameRate:Math.floor(a),bitrate:g,jitter:o?Math.round(1e3*o):null,codecImplementationName:null,nackCount:c,pliCount:d,rtt:null,samplingRate:Bs,googFirsReceived:Bs,googRenderDelayMs:Bs,trackState:Bs})}_pickIceCandidatePair(e,t){const i=e[t.localCandidateId],{address:r,port:n}=i,s=e[t.remoteCandidateId],{address:o,port:a,protocol:l}=s;this._reportsData.iceCandidatePair={IP:r,port:n,networkType:null,remoteIP:o,remotePort:a,protocol:l,bitrateRecv:this._bitrateRecv,bitrateSend:this._bitrateSend,rtt:null,availableOutgoingBitrate:null,availableIncomingBitrate:null,totalPacketsLost:this._totalPacketsLost}}formatRCRTCStateReport(e){const t=+new Date;this._reportsData={senders:[],receivers:[],timestamp:t},this._totalPacketsLost=0,this._bitrateRecv=0,this._bitrateSend=0;for(const t in e){const i=e[t],{type:r}=i;"outbound-rtp"===r&&this._pickSenderData(i,e,r),"remote-inbound-rtp"===r&&this._addSenderData(e,i),"inbound-rtp"===r&&this._pickReceiverData(i,r),"candidate-pair"===r&&"succeeded"===i.state&&this._pickIceCandidatePair(e,i)}return this._reportsData}}class no extends to{constructor(){super(...arguments),Object.defineProperty(this,"_reportsData",{enumerable:!0,configurable:!0,writable:!0,value:{senders:[],receivers:[],timestamp:+new Date}}),Object.defineProperty(this,"_totalPacketsLost",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_bitrateSend",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_bitrateRecv",{enumerable:!0,configurable:!0,writable:!0,value:0})}_pickReceiverData(e,t){e.forEach((e=>{var t;if("unified-plan"===this._sdpSemantics&&!this.isValidTranceiver(e,"inbound-rtp"))return;const{packetsLost:i,packetsReceived:r,jitter:n,bytesReceived:s,kind:o,nackCount:a,pliCount:l,audioLevel:_,frameHeight:c,frameWidth:d}=e,u=null===(t=this._store)||void 0===t?void 0:t.getTrackIdBySSRC(e.ssrc);if(!u)return;this._totalPacketsLost+=i;const h=this.updateReceiverPacketsLost(u,i,r);let g=this.updateBytesRecv(u,s,this._reportsData.timestamp);g<0&&(g=0),this._bitrateRecv+=g,this._reportsData.receivers.push({trackId:u,kind:o,packetsLostRate:h,remoteResource:!0,audioLevel:_||0===_?zs(_):null,frameWidth:d,frameHeight:c,frameRate:null,bitrate:g,jitter:n?Math.round(1e3*n):n,codecImplementationName:null,nackCount:a,pliCount:l,rtt:null,samplingRate:Bs,googFirsReceived:Bs,googRenderDelayMs:Bs,trackState:Bs})}))}_pickSenderData(e,t){e.forEach((e=>{var i;if("unified-plan"===this._sdpSemantics&&!this.isValidTranceiver(e,"outbound-rtp"))return;const r=null===(i=this._store)||void 0===i?void 0:i.getTrackIdBySSRC(e.ssrc),{kind:n,bytesSent:s,pliCount:o,nackCount:a,audioLevel:l,frameHeight:_,frameWidth:c,codecId:d,remoteId:u,packetsSent:h}=e;if(!r)return;const g=t[u];let p=null,f=null,E=0;g&&(p=g.jitter,f=g.roundTripTime,E=g.packetsLost),this._totalPacketsLost+=E;let I=0;!this._latestPacketsSent[r]&&(this._latestPacketsSent[r]={}),g?I=this.updateSenderPacketsLost(r,E,h):this._latestPacketsSent[r].crtPacketsSent=h;let T=this.updateBytesSent(r,s,this._reportsData.timestamp);T<0&&(T=0),this._bitrateSend+=T,this._reportsData.senders.push({trackId:r,kind:n,packetsLostRate:I,remoteResource:!1,audioLevel:l||0===l?zs(l):null,frameWidth:c,frameHeight:_,frameRate:null,bitrate:T,jitter:p?Math.round(1e3*p):p,rtt:f?Math.round(1e3*f):f,encoderImplementation:t[d].mimeType,pliCount:o,nackCount:a,googFirsSent:Bs,samplingRate:Bs,googRenderDelayMs:Bs,trackState:Bs})}))}_pickIceCandidatePair(e,t){const{selectedCandidatePairId:i}=e;if(i){const e=t[i],{availableOutgoingBitrate:r,availableIncomingBitrate:n,currentRoundTripTime:s,localCandidateId:o,remoteCandidateId:a}=e,l=t[o],{address:_,port:c}=l,d=t[a],{address:u,port:h,protocol:g}=d;this._reportsData.iceCandidatePair={IP:_||null,port:c,networkType:null,remoteIP:u,remotePort:h,protocol:g,bitrateRecv:this._bitrateRecv,bitrateSend:this._bitrateSend,rtt:1e3*s,availableOutgoingBitrate:r,availableIncomingBitrate:n,totalPacketsLost:this._totalPacketsLost},this._reportsData.receivers.forEach((e=>{e.rtt=1e3*s}))}}formatRCRTCStateReport(e){const{outbound:t,inbound:i,transport:r,connection:n}=this.formatStateData(e);this._reportsData={senders:[],receivers:[]};const s=Math.floor(n[0].timestamp);if(this._reportsData.timestamp=s,this._totalPacketsLost=0,this._bitrateSend=0,this._bitrateRecv=0,this._pickSenderData(t,e),this._pickReceiverData(i,e),r.length>0){const t=r[0];this._pickIceCandidatePair(t,e)}return this._reportsData}}class so{get videoSdps(){return this.videoStreams.slice()}get audioSdps(){return this.audioStreams.slice()}constructor(e,t,i){Object.defineProperty(this,"SDP",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"SDPHeader",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(this,"videoStreams",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"audioStreams",{enumerable:!0,configurable:!0,writable:!0,value:[]});const r=this.getStreamIndex();this.spliteStreams(r)}static trimBlankLine(e){return e.replace(/\n\r\s*\r\n/g,"\r\n").replace(/\s+\r\n/g,"\r\n")}getStreamIndex(){const e=/m=(?:video|audio)/gim,t=new Set([0]);let i=e.exec(this.SDP);for(;null!==i;)t.add(null==i?void 0:i.index),i=e.exec(this.SDP);return t.add(this.SDP.length),[...t]}spliteStreams(e){this.SDPHeader=this.SDP.substring(e[0],e[1]).replace(/\r\ns=-/g,`\r\ns=${(new Date).valueOf()}`);for(let t=1;t<e.length;t++){const i=this.SDP.substring(e[t],e[t+1]);/^\bm=video\b/.test(i)?this.videoStreams.push(i):this.audioStreams.push(i)}}static clearInactiveOrRecvonly(e){return/\ba=(recvonly|inactive)\b/.test(e)?e.replace(/\r\na=(ssrc|msid)[^\r\n]+/gi,""):e}setHeaderBitrate(e){this.SDPHeader=this.SDPHeader.replace(/(\r\ns=[^\r\n]+)/gi,`$1\r\nc=IN IP4 0.0.0.0\r\nb=AS:${e*so.KBitrate}\r\nb=TIAS:${e*so.KBitrate*850}`)}setAudiosBitrate(e){return this.audioStreams=this.audioStreams.map((t=>this.setAudioItemBitrate(t,e))),this}setAudioBitrateWithStreamId(e,t){return this.audioStreams=this.audioStreams.map((i=>new RegExp(`\\bmsid:${t}\\b`,"ig").test(i)?this.setAudioItemBitrate(i,e):i)),this}setAudioBitrateWithMid(e,t){return this.audioStreams=this.audioStreams.map((i=>new RegExp(`\\bmid:${t}\\b`,"ig").test(i)?this.setAudioItemBitrate(i,e):i)),this}setAudioItemBitrate(e,t){if(0===t.max&&/\ba=inactive\b/gi.test(e))return e;if(!/\bmaxaveragebitrate\b/gi.test(e)){const i=["$1","maxaveragebitrate="+t.max*so.KBitrate*1e3];e=e.replace(/(\buseinbandfec=[^\r\n]+)/gi,i.join(";"))}return this.addAudioBlineAS(e,t)}addAudioBlineAS(e,t){return/\bb=AS:\d+\b/gi.test(e)?e:e.replace(/(\bc=IN[^\r\n]+)/gi,`$1\r\nb=AS:${t.max*so.KBitrate}\r\nb=TIAS:${t.max*so.KBitrate*850}`)}setVideosBitrate(e){return this.videoStreams=this.videoStreams.map((t=>this.setVideoItemBitrate(t,e))),this}setVideoBitrateWithStreamId(e,t){return this.videoStreams=this.videoStreams.map((i=>new RegExp(`\\bmsid:${t}\\b`,"ig").test(i)?this.setVideoItemBitrate(i,e):i)),this}setVideoBitrateWithMid(e,t){return this.videoStreams=this.videoStreams.map((i=>new RegExp(`\\bmid:${t}\\b`,"ig").test(i)?this.setVideoItemBitrate(i,e):i)),this}setVideoItemBitrate(e,t){if(0===t.max&&/\ba=inactive\b/gi.test(e))return e;if(!/\bx-google-max-bitrate\b/.test(e)){const i=["$1","x-google-max-bitrate="+t.max*so.KBitrate,"x-google-min-bitrate="+t.min*so.KBitrate,`x-google-start-bitrate=${t.start||t.max*so.KBitrate*.7}`];e=e.replace(/(\bprofile-level-id=42[e0]01f\b)/gi,i.join(";"))}return this.addVideoBlineAS(e,t)}addVideoBlineAS(e,t){return/\bb=AS:\d+\b/gi.test(e)?e:e.replace(/(\bc=IN[^\r\n]+)/gi,`$1\r\nb=AS:${t.max*so.KBitrate}\r\nb=TIAS:${t.max*so.KBitrate*850}`)}clearnSsrcWithMid(e,t){return this.audioStreams=this.audioStreams.map((i=>new RegExp(`\\bmid:${e}\\b`,"ig").test(i)?this.clearSSRC(i,t):i)),this.videoStreams=this.videoStreams.map((i=>new RegExp(`\\bmid:${e}\\b`,"ig").test(i)?this.clearSSRC(i,t):i)),this}clearSSRC(e,t){if(t===ho.SENDONLY){if(/\ba=sendonly\b/.test(e))return e.replace(/\r\na=(ssrc|msid)[^\r\n]+/gi,"")}if(t===ho.RECVONLY){if(/\ba=recvonly\b/.test(e))return e.replace(/\r\na=(ssrc|msid)[^\r\n]+/gi,"")}if(t===ho.INACTIVE){if(/\ba=inactive\b/.test(e))return e.replace(/\r\na=(ssrc|msid)[^\r\n]+/gi,"")}return e}}Object.defineProperty(so,"KBitrate",{enumerable:!0,configurable:!0,writable:!0,value:1});class oo{static init(e,t){this._audioEncoder=e.encodeAudio,this._audioDecoder=e.decodeAudio,this._videoEncoder=e.encodeVideo,this._videoDecoder=e.decodeVideo,this._logger=t}static isInit(){return!!(this._audioEncoder&&this._audioDecoder&&this._videoEncoder&&this._videoDecoder)}static decodeAudio(e){try{return this._audioDecoder(e)}catch(t){return this._logger.error(le.L_ENCRYPTOR_DECODE_E,null==t?void 0:t.message),console.error(t),e}}static encodeAudio(e){try{return this._audioEncoder(e)}catch(t){return this._logger.error(le.L_ENCRYPTOR_ENCODE_E,null==t?void 0:t.message),console.error(t),e}}static decodeVideo(e){try{return this._videoDecoder(e)}catch(t){return this._logger.error(le.L_ENCRYPTOR_DECODE_E,null==t?void 0:t.message),console.error(t),e}}static encodeVideo(e){try{return this._videoEncoder(e)}catch(t){return this._logger.error(le.L_ENCRYPTOR_ENCODE_E,null==t?void 0:t.message),console.error(t),e}}}!function(e){e[e.NB=0]="NB",e[e.MB=1]="MB",e[e.WB=2]="WB",e[e.SWB=3]="SWB",e[e.FB=4]="FB"}(eo||(eo={})),eo.NB,eo.NB,eo.NB,eo.NB,eo.MB,eo.MB,eo.MB,eo.MB,eo.WB,eo.WB,eo.WB,eo.WB,eo.SWB,eo.SWB,eo.FB,eo.FB,eo.NB,eo.NB,eo.NB,eo.NB,eo.WB,eo.WB,eo.WB,eo.WB,eo.SWB,eo.SWB,eo.SWB,eo.SWB,eo.FB,eo.FB,eo.FB,eo.FB;class ao{static splitSections(e){return e.split("\nm=").map(((e,t)=>`${(t>0?`m=${e}`:e).trim()}\r\n`))}static getMediaSections(e){const t=ao.splitSections(e);return t.shift(),t}static parseExtmap(e){const t=e.substr(9).split(" ");return{id:parseInt(t[0],10),direction:t[0].indexOf("/")>0?t[0].split("/")[1]:"sendrecv",uri:t[1]}}static splitLines(e){return e.trim().split("\n").map((e=>e.trim()))}static parseMLine(e){const t=ao.splitLines(e)[0].substr(2).split(" ");return{kind:t[0],port:parseInt(t[1],10),protocol:t[2],fmt:t.slice(3).join(" ")}}static matchPrefix(e,t){return ao.splitLines(e).filter((e=>0===e.indexOf(t)))}static parseMsid(e){let t;const i=ao.matchPrefix(e,"a=msid:");if(1===i.length)return t=i[0].substr(7).split(" "),{stream:t[0],track:t[1]};const r=ao.matchPrefix(e,"a=ssrc:").map((e=>ao.parseSsrcMedia(e))).filter((e=>"msid"===e.attribute));return r.length>0&&r[0].value?(t=r[0].value.split(" "),{stream:t[0],track:t[1]}):{stream:"",track:""}}static parseSsrcMedia(e){const t=e.indexOf(" "),i={ssrc:parseInt(e.substr(7,t-7),10)},r=e.indexOf(":",t);return r>-1?(i.attribute=e.substr(t+1,r-t-1),i.value=e.substr(r+1)):i.attribute=e.substr(t+1),i}static getMid(e){const t=ao.matchPrefix(e,"a=mid:")[0];if(t)return t.substr(6)}static splitNaluData(e){const t=new Uint8Array(e);let i=0;if(this.isIFrame(t)){const e=t.join(",");let r=e.indexOf("0,0,0,1,101");-1===r&&(r=e.indexOf("0,0,0,1,37"));i=e.substring(0,r).split(",").length-1+4+8}else i=12;return{header:t.slice(0,i),payloadData:t.slice(i)}}static deal0x03(e,t){let i=[];return i="encode"===t?e.join(",").replaceAll(",0,0,1,",",0,0,3,1,").split(",").map((e=>Number(e))):e.join(",").replaceAll(",0,0,3,1,",",0,0,1,").split(",").map((e=>Number(e))),new Uint8Array(i)}static isIFrame(e){let t=e.join("").startsWith("0001103");return t||(t=e.join("").startsWith("000139")),t}static parsePayloadTypes(e){const t=ao.getMediaSections(e).find((e=>"audio"===ao.parseMLine(e).kind));if(!t)return;const i=t.match(/a=rtpmap:(\d+)\s+(\S+)/g);i&&(ao.payloadTypeCodecMap=i.map((e=>{const t=e.match(/a=rtpmap:(\d+)\s+(\w+)/);return t?{payloadType:Number(t[1]),codec:t[2]}:null})).filter((e=>!!e)))}}Object.defineProperty(ao,"payloadTypeCodecMap",{enumerable:!0,configurable:!0,writable:!0,value:[]});const lo=16;function _o(e,t){let i=0,r=t;for(;r<e.length;){const t=e[r];if(i+=t,r++,255!==t)break}return{value:i,nextOffset:r}}function co(e,t){if(t>=e.length)return null;const i=_o(e,t),r=i.value;let n=i.nextOffset;const s=_o(e,n),o=s.value;if(n=s.nextOffset,o<lo)return null;if(n+o>e.length)return null;const a=e.slice(n,n+lo),l=n+lo,_=o-lo;let c=e.slice(l,l+_);return c.length>=2&&0===c[c.length-2]&&128===c[c.length-1]?c=c.slice(0,c.length-2):c.length>=1&&128===c[c.length-1]&&(c=c.slice(0,c.length-1)),5===r?{payloadSize:o,uuid:a,content:c}:null}var uo,ho,go,po,fo,Eo,Io,To,mo;!function(e){e.PLANB="plan-b",e.UNIFIEDPLAN="unified-plan"}(uo||(uo={})),function(e){e.SENDONLY="sendonly",e.RECVONLY="recvonly",e.INACTIVE="inactive"}(ho||(ho={}));class Ro{static setSdpSemantics(e,t){const{browser:i,version:r,supportsUnifiedPlan:n}=Ii;if(t.info(le.L_A_SDP_STRATEGY_SET_SDP_SEMANTICS_O,JSON.stringify({sdpSemantics:e,supportsUnifiedPlan:n,browser:i,version:r})),n)return/chrome/i.test(i)?r?void(this._sdpSemantics=r>92?"unified-plan":r<72?"plan-b":e):void(this._sdpSemantics="unified-plan"):void(/firefox/i.test(i)?this._sdpSemantics="unified-plan":/safari/i.test(i)?this._sdpSemantics=r<12?"plan-b":"unified-plan":this._sdpSemantics="unified-plan");this._sdpSemantics="plan-b"}static getSdpSemantics(){return Ro._sdpSemantics}constructor(e,t,i,r){Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_peer",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_useEncrypt",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_onReceiveSeiListener",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_outboundStreams",{enumerable:!0,configurable:!0,writable:!0,value:{}})}setReceiveSeiListener(e){this._onReceiveSeiListener=e}getOutboundVideoInfo(){const e=[];for(const t in this._outboundStreams){const i=this._outboundStreams[t].getVideoTracks()[0];if(!i)continue;const r=/_tiny$/.test(t),{width:n,height:s}=oi(i);e.push({trackId:i.id,simulcast:r?Ys.TINY:Ys.NORMAL,resolution:`${n}x${s}`})}return e}setRemoteAnswer(e){return m(this,void 0,void 0,(function*(){e=so.trimBlankLine(e);try{yield this._peer.setRemoteDescription({type:"answer",sdp:e})}catch(e){return this._logger.info(le.L_A_SDP_STRATEGY_SET_REMOTE_ANSWER_O,JSON.stringify({status:_e.FAILED,msg:e})),ae.SET_REMOTE_DESCRIPTION_FAILED}return this._logger.info(le.L_A_SDP_STRATEGY_SET_REMOTE_ANSWER_O,JSON.stringify({status:_e.SUCCESSED,sdp:e})),ae.SUCCESS}))}getStatParsr(e,t,i,r){return/chrome/i.test(Ii.browser)?new io(this,e,this._logger,t,i,r):/Firefox/i.test(Ii.browser)?new ro(this,e,this._logger,t,i,r):/Safari/i.test(Ii.browser)?new no(this,e,this._logger,t,i,r):null}getTrackIdByMid(e){return null}resetSdp(e){return so.trimBlankLine(e)}_setupSenderTransform(e){if(!this._useEncrypt)return;const t=e.createEncodedStreams(),{readable:i,writable:r}=t,n=new TransformStream({transform:this._encodeRtpChunk.bind(this,e)});i.pipeThrough(n).pipeTo(r)}_setupReceiverTransform(e){const t=e.createEncodedStreams(),{readable:i,writable:r}=t,n=new TransformStream({transform:this._decodeRtpChunk.bind(this,e)});i.pipeThrough(n).pipeTo(r)}_encodeVideoFrame(e){const{header:t,payloadData:i}=ao.splitNaluData(e),r=oo.encodeVideo(i),n=ao.deal0x03(r,"encode");return new Uint8Array([...t,...n]).buffer}_decodeVideoFrame(e){var t;const i=new Uint8Array(e),r=i.join(",").indexOf("0,0,0,1,6,5");if(-1!==r&&i.join(",").includes("84,128,131,151,240,35,71,75,183,247,79,50,181,78,6,172")){const n=i.join(",").slice(r);return null===(t=this._onReceiveSeiListener)||void 0===t||t.call(this,n),e}if(!this._useEncrypt)return e;const{header:n,payloadData:s}=ao.splitNaluData(e),o=ao.deal0x03(s,"decode"),a=oo.decodeVideo(o);return new Uint8Array([...n,...a]).buffer}_handleAudioREDFrame(e,t){const i=function(e){const t=[];let i=0;for(;;){let r,n,s,o,a=!(e[i]>>7),l=127&e[i];if(a?(r=0,n=e.byteLength-(t.length>0?t.map((e=>4+e.block.byteLength)).reduce(((e,t)=>e+t)):0)-1,s=e.slice(i,i+1),i+=1):(r=(e[i+1]<<6)+(e[i+2]>>2),n=((3&e[i+2])<<8)+e[i+3],s=e.slice(i,i+4),i+=4),o=new Uint8Array(n),t.push({timestampOffset:r,header:s,block:o,isPrimary:a,blockPType:l}),a)break}return t.forEach((t=>{const r=t.block.byteLength,n=e.slice(i,i+r);t.block.set(n),i+=r})),t}(new Uint8Array(e)),r=[],n=[];let s=0;i.forEach((e=>{const i="decode"===t?oo.decodeAudio(e.block):oo.encodeAudio(e.block);if(i.byteLength!==e.block.byteLength&&!e.isPrimary){let[,,t,r]=e.header;t=(t>>2<<2)+i.byteLength>>8,r=255&i.byteLength,e.header=new Uint8Array([e.header[0],e.header[1],t,r])}e.block=i,s+=e.block.byteLength+e.header.byteLength,r.push(e.header),n.push(e.block)}));const o=new Uint8Array(s);let a=0;return[...r,...n].forEach((e=>{o.set(e,a),a+=e.byteLength})),o.buffer}_handleOpusFrame(e,t){const i=new Uint8Array(e);return("encode"===t?oo.encodeAudio(i):oo.decodeAudio(i)).buffer}_encodeRtpChunk(e,t,i){const r=t.data;if(t instanceof RTCEncodedVideoFrame)t.data=this._encodeVideoFrame(r);else{const{payloadType:e}=t.getMetadata(),{codec:i}=ao.payloadTypeCodecMap.filter((t=>t.payloadType===e))[0];"red"===i?t.data=this._handleAudioREDFrame(r,"encode"):"opus"===i?t.data=this._handleOpusFrame(r,"encode"):console.error(`Unsupport audio payloadType: ${e}, codec: ${i}`)}i.enqueue(t)}_decodeRtpChunk(e,t,i){const r=t.data;if(t instanceof RTCEncodedVideoFrame)t.data=this._decodeVideoFrame(r);else if(this._useEncrypt){const{payloadType:e}=t.getMetadata(),{codec:i}=ao.payloadTypeCodecMap.filter((t=>t.payloadType===e))[0];"red"===i?t.data=this._handleAudioREDFrame(r,"decode"):"opus"===i?t.data=this._handleOpusFrame(r,"decode"):console.error(`Unsupport audio payloadType: ${e}, codec: ${i}`)}i.enqueue(t)}}class So extends so{constructor(e,t){super(t,uo.PLANB,e),Object.defineProperty(this,"SDP",{enumerable:!0,configurable:!0,writable:!0,value:t})}stringify(){const e=[this.SDPHeader];[...this.audioStreams,...this.videoStreams].forEach((t=>{const i=t.match(/\ba=mid:(video|audio)\b/),r=so.clearInactiveOrRecvonly(t);i&&i[1]===wt.AUDIO&&(e[1]=r),i&&i[1]===wt.VIDEO&&(e[2]=r)}));const t=e.join("");return so.trimBlankLine(t)}setAudioBitrateWithStreamId(e,t){return this._logger.warn(le.L_FUNCTION_IS_UNAVAILABLE,"plan-b not support set Audio Bitrate With Stream Id"),this}setVideoBitrateWithStreamId(e,t){return this._logger.warn(le.L_FUNCTION_IS_UNAVAILABLE,"plan-b not support set Video Bitrate With Stream Id"),this}}class Co extends Ro{constructor(){super(...arguments),Object.defineProperty(this,"senders",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_localTracks",{enumerable:!0,configurable:!0,writable:!0,value:[]})}addLocalTrack(e){this._localTracks.every((t=>t.getTrackId()!==e.getTrackId()))&&this._localTracks.push(e);const t=e.getStreamId(),i=e.__innerGetMediaStreamTrack(),r=this._outboundStreams[t]||(this._outboundStreams[t]=new MediaStream);r.getTracks().forEach((e=>{e.kind===i.kind&&r.removeTrack(e)})),r.addTrack(i);const n=e.getTrackId(),s=this.senders[n];s?s.replaceTrack(i):(this.senders[n]=this._peer.addTrack(i,r),Object.defineProperty(i,"trackId",{value:n,writable:!1,enumerable:!1,configurable:!1}))}removeLocalTrack(e){const t=this._localTracks.findIndex((t=>t===e));t>=0&&this._localTracks.splice(t,1);const i=e.getTrackId(),r=this.senders[i];r&&(r.replaceTrack(null),this._peer.removeTrack(r),delete this.senders[i])}updateSubRemoteTracks(e){}updateRecvTransceiverMap(e,t){}setBitrate(e,t,i){}createOffer(e){return m(this,void 0,void 0,(function*(){const t=yield this._peer.createOffer({iceRestart:e,offerToReceiveAudio:!0,offerToReceiveVideo:!0});for(const e in this._outboundStreams){const i=this._outboundStreams[e].id;t.sdp=t.sdp.replace(new RegExp(i,"g"),e)}return t.sdp&&(t.sdp=this.resetSdp(t.sdp)),yield this._peer.setLocalDescription(t),{type:"offer",semantics:"plan-b",sdp:t.sdp}}))}setRemoteAnswer(e){return e=this.resetSdp(e),super.setRemoteAnswer(e)}_getMaxRangeBitrate(e){const t=this._localTracks.filter((t=>e===vt.AUDIO_ONLY?t.isAudioTrack():t.isVideoTrack())),i={max:0,min:0};return t.forEach((e=>{const{min:t,max:r,start:n}=e.getBitrate();i.max=i.max<r?r:i.max,i.min=i.min>t?t:i.min,i.max===r?i.start=n:i.start=.7*i.max})),i}resetSdp(e){const t=new So(this._logger,e),i=this._getMaxRangeBitrate(vt.VIDEO_ONLY),r=this._getMaxRangeBitrate(vt.AUDIO_ONLY);return t.setAudiosBitrate(r),t.setVideosBitrate(i),t.stringify()}}class Lo extends so{constructor(e,t){super(t,uo.UNIFIEDPLAN,e)}stringify(){const e=[this.SDPHeader];[...this.audioStreams,...this.videoStreams].forEach((t=>{const i=t.match(/\ba=mid:(\d+)\b/);i&&i[1]&&(e[+i[1]+1]=t)})),this.SDPHeader="",this.videoStreams=[],this.audioStreams=[];const t=e.join("");return so.trimBlankLine(t)}}class Oo{constructor(){Object.defineProperty(this,"__streams",{enumerable:!0,configurable:!0,writable:!0,value:new Map})}static getInstance(){return Oo.instance||(Oo.instance=new Oo),Oo.instance}push(e,t){return this.__streams.set(e,t),t}pickup(e){return this.__streams.get(e)}delete(e){return this.__streams.delete(e)}get streams(){const e=new Map;for(const t of this.__streams.keys())e.set(t,this.pickup(t));return e}}class vo extends Ro{constructor(){super(...arguments),Object.defineProperty(this,"_sendTransceiver",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_localTracks",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_recvAudio",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_recvVideo",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_recvTransceiver",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_subedTracks",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"midMsid",{enumerable:!0,configurable:!0,writable:!0,value:{}})}setBitrate(e,t,i){this._logger.warn(le.L_FUNCTION_IS_UNAVAILABLE,"the interface named `setBitrate` is invalid while sdpSemantics value is `unified-plan`")}getTrackIdByMid(e){for(let t in this._sendTransceiver){if(this._sendTransceiver[t].mid===e)return t}for(let t in this._recvTransceiver){if(this._recvTransceiver[t].mid===e)return t}return null}addLocalTrack(e){var t;const i=e.getTrackId(),r=e.getStreamId(),n=e.__innerGetMediaStreamTrack();this._localTracks[i]=e;const s=this._outboundStreams[r]||(this._outboundStreams[r]=new MediaStream);s.getTracks().forEach((e=>{e.kind===n.kind&&s.removeTrack(e)})),s.addTrack(n);const o=this._sendTransceiver[i];if(o)o.sender.replaceTrack(n),o.direction="sendonly";else{const e=this._sendTransceiver[i]=this._peer.addTransceiver(n,{direction:"sendonly",streams:[s]});this._setupSenderTransform(e.sender)}Oo.getInstance().push(i,{msid:r,id:this._outboundStreams[r].id,kind:null===(t=e.streamTrack)||void 0===t?void 0:t.kind})}removeLocalTrack(e,t=!0){const i=e.getTrackId(),r=e.getStreamId();delete this._localTracks[i];const n=this._sendTransceiver[i];if(!n)return;"closed"!==this._peer.connectionState&&(n.direction="inactive",this._peer.removeTrack(n.sender),n.sender.replaceTrack(null));const s=this._outboundStreams[r];(e.isAudioTrack()?s.getAudioTracks():s.getVideoTracks()).forEach((e=>s.removeTrack(e)));const o=this._sendTransceiver[`${i}_tiny`];if(o&&"inactive"!==o.direction&&t&&"closed"!==this._peer.connectionState){o.direction="inactive";const{sender:e}=o,t=e.track;this._peer.removeTrack(e),e.replaceTrack(null);this._outboundStreams[`${r}_tiny`].removeTrack(t),t.stop()}}updateRecvTransceiverMap(e,t){const{mediaType:i}=_i(e);this._recvTransceiver[e]=t;const r=i===vt.AUDIO_ONLY?this._recvAudio:this._recvVideo,n=r.findIndex((e=>e===t));n>=0&&r.splice(n,1)}updateSubRemoteTracks(e){const t=e.slice(),i=this._subedTracks.slice();this._subedTracks=e.slice();for(let e=t.length-1;e>=0;e-=1){const r=t[e],n=i.findIndex((e=>e===r));n>=0&&(t.splice(e,1),i.splice(n,1))}i.length&&i.forEach((e=>{const t=e.getTrackId();e.__innerSetMediaStreamTrack(void 0);const i=this._recvTransceiver[t];i&&(i.direction="inactive")}));const r={audio:0,video:0};t.length&&t.forEach((e=>{const t=e.isAudioTrack()?"audio":"video",i=this._recvTransceiver[e.getTrackId()];i?i.direction="recvonly":r[t]+=1}));for(let e=this._recvAudio.length;e<r.audio;e+=1){const e=this._peer.addTransceiver("audio",{direction:"recvonly"});this._recvAudio.push(e),this._setupReceiverTransform(e.receiver)}for(let e=this._recvVideo.length;e<r.video;e+=1){const e=this._peer.addTransceiver("video",{direction:"recvonly"});this._recvVideo.push(e),this._setupReceiverTransform(e.receiver)}}createOffer(e){return m(this,void 0,void 0,(function*(){const t=yield this._peer.createOffer({iceRestart:e});let i=t.sdp;for(const e in this._outboundStreams){const t=this._outboundStreams[e].id;i=i.replace(new RegExp(t,"g"),e)}return i=this.resetOfferSdp(i),i=i.replace(/(a=ice-options:trickle)/g,"$1\r\na=ice-options:renomination"),t.sdp=i,yield this._peer.setLocalDescription(t),{type:"offer",semantics:"unified-plan",sdp:i}}))}setRemoteAnswer(e){e=this.resetAnswerSdp(e);const t=/[\r\n]+\r\n[\r\n]+/g;return t.test(e)&&(e=e.replace(t,"\r\n")),super.setRemoteAnswer(e)}_genarateMid(e,t,i){let r=null;return ao.getMediaSections(e).forEach((e=>{ao.parseExtmap(e);const{kind:n}=ao.parseMLine(e);let{stream:s}=ao.parseMsid(e);const o=ao.getMid(e);"video"===i?/tiny$/.test(s)?s=s.replace(/tiny$/gi,"1_tiny"):s+="_1":s+="_0",s===t&&i===n&&o&&(r=o)})),r}_setSenderTransceiverBitrate(e,t,i,r){const n=this._localTracks[t],s=null==n?void 0:n.getBitrate();r===wt.AUDIO&&s&&e.setAudioBitrateWithMid(s,i),r===wt.VIDEO&&s&&e.setVideoBitrateWithMid(s,i)}_resetSenderTransceiver(e,t){var i;for(const r in this._sendTransceiver){const n=this._sendTransceiver[r],s=null===(i=n.sender.track)||void 0===i?void 0:i.kind;let{direction:o,mid:a}=n;a||(a=this._genarateMid(e,r,s)),a&&(o===ho.SENDONLY&&this._setSenderTransceiverBitrate(t,r,a,s),o===ho.INACTIVE&&t.clearnSsrcWithMid(a,ho.INACTIVE))}}_resetRecvTransceiver(e){for(const t in this._recvTransceiver){const i=this._recvTransceiver[t],{direction:r,mid:n}=i;n&&r===ho.INACTIVE&&e.clearnSsrcWithMid(n,ho.RECVONLY)}}resetOfferSdp(e){const t=new Lo(this._logger,e);return this._resetSenderTransceiver(e,t),this._resetRecvTransceiver(t),t.stringify()}resetAnswerSdp(e){var t;const i=new Lo(this._logger,e);for(const e in this._sendTransceiver){const r=this._sendTransceiver[e],{mid:n}=r;if(n){const s=this._localTracks[e],o=null==s?void 0:s.getBitrate(),a=null===(t=r.sender.track)||void 0===t?void 0:t.kind;a===wt.AUDIO&&o&&i.setAudioBitrateWithMid(o,n),a===wt.VIDEO&&o&&i.setVideoBitrateWithMid(o,n)}}return i.stringify()}}class bo extends B{constructor(e,t,i,r,n,s,o=!1,a=!1){super(),Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_reTryExchange",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_currentUserId",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_store",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"_polarisReport",{enumerable:!0,configurable:!0,writable:!0,value:s}),Object.defineProperty(this,"_isRoomAudience",{enumerable:!0,configurable:!0,writable:!0,value:o}),Object.defineProperty(this,"_rtcPeerConn",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_sdpStrategy",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"reportParser",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"pubLocalTracks",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_reTryExchangeTimer",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_reportStatsTimer",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_reportR3R4ToPolarisTimer",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_isDestroyed",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_formatStatsData",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_inRetry",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_firstConnectFromPub",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_reportListener",{enumerable:!0,configurable:!0,writable:!0,value:null});const l=Ro.getSdpSemantics(),_="unified-plan"===l&&a&&"function"==typeof RTCRtpSender.prototype.createEncodedStreams&&"function"==typeof RTCRtpReceiver.prototype.createEncodedStreams&&oo.isInit(),c=this._rtcPeerConn=new RTCPeerConnection({sdpSemantics:l,encodedInsertableStreams:_});this._sdpStrategy="plan-b"===l?new Co(e,this._logger,c,!1):new vo(e,this._logger,c,_),this._sdpStrategy.setReceiveSeiListener(this._decodeSeiData.bind(this)),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,l,this._currentUserId,this._store)}getLocalTracks(){return Object.values(this.pubLocalTracks)}_decodeSeiData(e){const t=e.split(",").map((e=>Number(e))),i=function(e){if(e.length>=4&&0===e[0]&&0===e[1]&&(1===e[2]||0===e[2]&&1===e[3])){let t=0;for(;t+4<e.length;)if(0===e[t]&&0===e[t+1]&&(1===e[t+2]||0===e[t+2]&&1===e[t+3])){const i=t+(1===e[t+2]?3:4);if(i>=e.length)break;if(6==(31&e[i])){const t=co(e,i+1);if(t)return{payloadSize:t.payloadSize,content:t.content}}t=i+1}else t++}else{let t=0;for(;t+4<=e.length;){const i=e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3];if(i<=0||t+4+i>e.length)break;const r=t+4;if(6==(31&e[r])){const n=r+1,s=co(e.subarray(n,t+4+i),0);if(s)return{payloadSize:s.payloadSize,content:s.content}}t+=4+i}}return null}(new Uint8Array(t));if(null==i?void 0:i.content.length){const e=this._context.decodeAsrText(i.content,t);e.length&&this.emit(bo.__INNER_SEI_CONTENT__,e)}}_onConnectionStateChange(){this._logger.info(le.L_RTC_PEER_CONNECTION_CONNECTION_STATE_S,`state: ${this._rtcPeerConn.connectionState}`)}startAutoExecute(e){this.stopAutoExecute(),this._reportStatsTimer=setTimeout((()=>{this._reportHandle(),this.startAutoExecute(e)}),e)}stopAutoExecute(){clearTimeout(this._reportStatsTimer)}_onICEConnectionStateChange(){return m(this,void 0,void 0,(function*(){var e,t;const{iceConnectionState:i}=this._rtcPeerConn;this._logger.info(le.L_RTC_PEER_CONNECTION_ICE_CONNECTION_STATE_S,JSON.stringify({iceConnectionState:i}));const r=yield this._getStatsData(),n=r?this._createRCRTCStateReport(r).iceCandidatePair:null;this.emit(bo.__INNER_ICE_STATE_CHANGE__,{status:i,time:Date.now(),iceCandidatePair:n}),"connected"===i?(this.emit(bo.__INNER_ICE_CONNECTED__,this._firstConnectFromPub),this.startAutoExecute(1e3)):"failed"!==i&&"disconnected"!==i||this._handleRetry();try{null===(t=null===(e=this._reportListener)||void 0===e?void 0:e.onICEConnectionStateChange)||void 0===t||t.call(e,i)}catch(e){this._logger.error(le.L_RTC_PEER_CONNECTION_ICE_CONNECTION_STATE_REPORT_R,JSON.stringify({status:_e.FAILED,mag:e}))}}))}_handleRetry(){return m(this,void 0,void 0,(function*(){if(this._inRetry)return;this.clearReTryExchangeTimer(),this._inRetry=!0;const{code:e}=yield this._reTryExchange();this._inRetry=!1,e!==ae.SUCCESS&&(this._reTryExchangeTimer=setTimeout((()=>this._handleRetry()),15e3))}))}_onTrackReady(e){if(!e.streams.length)return;const t=e.streams[0].id,{track:i}=e.receiver,r=[t,"audio"===i.kind?vt.AUDIO_ONLY:vt.VIDEO_ONLY].join("_");Object.defineProperty(i,"trackId",{value:r,writable:!1,enumerable:!1,configurable:!1}),this._updateRecvTransceiverMap(r,e.transceiver);const{tag:n}=_i(r);n!==Vs&&this.emit(bo.__INNER_EVENT_TRACK_READY__,e)}setBitrate(e,t,i){return m(this,void 0,void 0,(function*(){this._sdpStrategy.setBitrate(e,t,i),this._logger.info(le.L_RTC_PEER_CONNECTION_SET_BITRATE_O,JSON.stringify({status:_e.SUCCESSED,max:e,min:t,start:i}))}))}createOffer(e){return m(this,void 0,void 0,(function*(){const t=yield this._sdpStrategy.createOffer(e);return this._logger.info(le.L_RTC_PEER_CONNECTION_CREATE_OFFER_O,JSON.stringify({offerSDP:t.sdp,sdpDemantics:t.semantics})),t}))}setRemoteAnswer(e){return m(this,arguments,void 0,(function*(e,t=!1){var i;return ao.parsePayloadTypes(null===(i=this._rtcPeerConn.localDescription)||void 0===i?void 0:i.sdp),this._firstConnectFromPub=t,this._sdpStrategy.setRemoteAnswer(e)}))}getLocalTrack(e){return this.pubLocalTracks[e]||null}addLocalTrack(e){this.pubLocalTracks[e.getTrackId()]=e,this._sdpStrategy.addLocalTrack(e),e.off(jt.__INNER_EVENT_MUTED_CHANGE__,this._onLocalTrackMuted,this),e.off(jt.__INNER_EVENT_DESTROY__,this._onLocalTrackDestroied,this),e.on(jt.__INNER_EVENT_MUTED_CHANGE__,this._onLocalTrackMuted,this),e.on(jt.__INNER_EVENT_DESTROY__,this._onLocalTrackDestroied,this),this._logger.info(le.L_RTC_PEER_CONNECTION_ADD_LOCAL_TRACK_O,`trackId: ${e.getTrackId()}`)}removeLocalTrackById(e){const t=this.getLocalTrack(e);t?(this._logger.info(le.L_RTC_PEER_CONNECTION_REMOVE_LOCAL_TRACK_BY_ID_O,JSON.stringify({status:_e.SUCCESSED,trackId:e})),this.removeLocalTrack(t)):this._logger.warn(le.L_RTC_PEER_CONNECTION_REMOVE_LOCAL_TRACK_BY_ID_O,JSON.stringify({status:_e.FAILED,msg:"track not found",trackId:e}))}removeAllLocalTrack(){Object.keys(this.pubLocalTracks).forEach((e=>{/_tiny$/.test(e)||this.removeLocalTrackById(e)}))}removeLocalTrack(e,t=!0){const i=e.getTrackId();delete this.pubLocalTracks[i],this._sdpStrategy.removeLocalTrack(e,t),e.__innerSetPublished(!1),e.off(jt.__INNER_EVENT_MUTED_CHANGE__,this._onLocalTrackMuted,this),e.off(jt.__INNER_EVENT_DESTROY__,this._onLocalTrackDestroied,this);const r=`${i}_tiny`,n=this.getLocalTrack(r);n&&t&&(this._sdpStrategy.removeLocalTrack(n,t),delete this.pubLocalTracks[r],n.destroy()),this._logger.info(le.L_RTC_PEER_CONNECTION_REMOVE_LOCAL_TRACK_O,JSON.stringify({trackId:i}))}_updateRecvTransceiverMap(e,t){this._sdpStrategy.updateRecvTransceiverMap(e,t)}updateSubRemoteTracks(e){this._sdpStrategy.updateSubRemoteTracks(e)}getOutboundVideoInfo(){return this._sdpStrategy.getOutboundVideoInfo()}_onLocalTrackMuted(e,t){const i=this.getLocalTrack(`${e.getTrackId()}_tiny`);i&&(i.__innerGetMediaStreamTrack().enabled=!e.isLocalMuted()),this.emit(jt.__INNER_EVENT_MUTED_CHANGE__,e,t)}_onLocalTrackDestroied(e){this.emit(jt.__INNER_EVENT_DESTROY__,e)}registerReportListener(e){this._reportListener=e}_createSenderReport(e){return e.filter((e=>e.trackId)).map((e=>{const{trackId:t,kind:i,packetsLostRate:r,remoteResource:n,bitrate:s,jitter:o,rtt:a}=e,l={trackId:t,kind:i,packetsLostRate:r,remoteResource:n,bitrate:s,jitter:o,rtt:a};return(e.audioLevel||0===e.audioLevel)&&(l.audioLevel=e.audioLevel),e.frameWidth&&(l.frameWidth=e.frameWidth),e.frameHeight&&(l.frameHeight=e.frameHeight),e.frameRate&&(l.frameRate=e.frameRate),Object.assign({},l)}))}_createReceiverReport(e){return e.filter((e=>e.trackId)).map((e=>{const{trackId:t,kind:i,packetsLostRate:r,remoteResource:n,bitrate:s,jitter:o,rtt:a}=e,l={trackId:t,kind:i,packetsLostRate:r,remoteResource:n,bitrate:s,jitter:o,rtt:a};return(e.audioLevel||0===e.audioLevel)&&(l.audioLevel=e.audioLevel),e.frameWidth&&(l.frameWidth=e.frameWidth),e.frameHeight&&(l.frameHeight=e.frameHeight),e.frameRate&&(l.frameRate=e.frameRate),Object.assign({},l)}))}_createRCRTCStateReport(e){const{timestamp:t,iceCandidatePair:i,senders:r,receivers:n}=e;(null==i?void 0:i.totalPacketsLost)&&(null==i||delete i.totalPacketsLost);for(const e in i)Ri(i[e])&&delete i[e];return{timestamp:t,iceCandidatePair:i,senders:this._createSenderReport(r),receivers:this._createReceiverReport(n)}}_getStatsData(){return m(this,void 0,void 0,(function*(){var e,t;this._formatStatsData=null;let i=null;const r=yield this._rtcPeerConn.getStats();i=null===(e=this.reportParser)||void 0===e?void 0:e.parseRTCStatsReport(r);const n=null===(t=this.reportParser)||void 0===t?void 0:t.formatRCRTCStateReport(i);return this._formatStatsData=n,n}))}_reportHandle(){return m(this,void 0,void 0,(function*(){var e,t,i,r,n;const s=yield this._getStatsData();if(!s)return;const o=this._createRCRTCStateReport(s);try{null===(t=null===(e=this._reportListener)||void 0===e?void 0:e.onStateReport)||void 0===t||t.call(e,JSON.parse(JSON.stringify(o)))}catch(e){this._logger.error(le.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,null==e?void 0:e.stack)}const a=[...s.receivers,...s.senders].filter((e=>"audio"===e.kind)).map((e=>({trackId:e.trackId,audioLevel:e.audioLevel})));if(this.emit(bo.__INNER_AUDIOLEVEL_CHANGE__,a),this._isRoomAudience&&(null===(i=this._reportListener)||void 0===i?void 0:i.onReportLiveAudioStates)){const e=this._getLiveAudioState();try{e.length&&(null===(n=null===(r=this._reportListener)||void 0===r?void 0:r.onReportLiveAudioStates)||void 0===n||n.call(r,e))}catch(e){this._logger.error(le.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,null==e?void 0:e.stack)}}}))}_getLiveAudioState(){const e=[];return this._rtcPeerConn.getReceivers().forEach((t=>{const i=t.getContributingSources();i.length&&e.push(...i)})),e.map((e=>{const{source:t,audioLevel:i}=e,r=this._store.getTrackIdBySSRC(t);if(!r)return{};const{userId:n}=_i(r);return{audioLevel:zs(i),userId:n,trackId:r}})).filter((e=>!!e.userId))}_sendR3R4Data(){return m(this,void 0,void 0,(function*(){var e,t,i,r;let n=this._formatStatsData;if(!n)return;const{senders:s,receivers:o}=n;console.log(`sendR3R4: senderTrackId: ${null===(e=s[0])||void 0===e?void 0:e.trackId}, receiverTrackId: ${null===(t=o[0])||void 0===t?void 0:t.trackId}`),s.length&&(yield null===(i=this._polarisReport)||void 0===i?void 0:i.sendR3Data(n)),o.length&&(yield null===(r=this._polarisReport)||void 0===r?void 0:r.sendR4Data(n)),s.length=0,o.length=0,n=null}))}__reportR3R4ToPolaris(){return m(this,void 0,void 0,(function*(){this._isDestroyed||(clearTimeout(this._reportR3R4ToPolarisTimer),this._reportR3R4ToPolarisTimer=setTimeout((()=>m(this,void 0,void 0,(function*(){this._isDestroyed||this._sendR3R4Data().then((()=>{this.__reportR3R4ToPolaris()}))}))),2e3))}))}getRTCPeerConn(){return this._rtcPeerConn}destroy(){this.clear(),this.clearReTryExchangeTimer(),clearTimeout(this._reportR3R4ToPolarisTimer),this.stopAutoExecute(),this.registerReportListener(null),this._rtcPeerConn.close(),this._isDestroyed=!0,this.reportParser=null,this._logger.info(le.L_RTC_PEER_CONNECTION_DESTROY_O,JSON.stringify({status:_e.SUCCESSED}))}clearReTryExchangeTimer(){clearTimeout(this._reTryExchangeTimer),this._reTryExchangeTimer=null}isDestroyed(){return this._isDestroyed}}Object.defineProperty(bo,"__INNER_EVENT_TRACK_READY__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-track-ready"}),Object.defineProperty(bo,"__INNER_AUDIOLEVEL_CHANGE__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-audio-level-change"}),Object.defineProperty(bo,"__INNER_ICE_STATE_CHANGE__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-ice-state-change"}),Object.defineProperty(bo,"__INNER_ICE_CONNECTED__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-ice-connected"}),Object.defineProperty(bo,"__INNER_SEI_CONTENT__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-sei-content"});class Ao{constructor(e,t){Object.defineProperty(this,"_store",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_peer",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_audioLevelChangeHandler",{enumerable:!0,configurable:!0,writable:!0,value:null})}audioLevelReport(e){if(!this._audioLevelChangeHandler)return;const t=[];e.forEach((e=>{const{userId:i}=_i(e.trackId),r=this._store.crtUserId===i?this._peer.getLocalTrack(e.trackId):this._store.getRemoteTrack(e.trackId);r&&t.push({track:r,audioLevel:e.audioLevel||0})})),this._audioLevelChangeHandler(t)}onAudioLevelChange(e){this._audioLevelChangeHandler=e}}!function(e){e[e.ANCHOR=1]="ANCHOR",e[e.AUDIENCE=2]="AUDIENCE"}(go||(go={})),function(e){e.UNPUBLISH_PREV="UnpublishPrevCommand",e.PULL_RTCROOM_STATUS="PullRTCRoomStatusCommand",e.JOINROOM="JoinRoomCommand",e.PARSE_REMOTERES="ParseRemoteResCommand",e.PARSE_USERSTATE="ParseUserStateCommand",e.LOCAL_TRACK_MUTE="LocalTrackMuteCommand",e.PUBLISH="PublishCommand",e.RETRY_EXCHANGE="RetryExchangeCommand",e.UNPUBLISH="UnpublishCommand",e.SUBSCRIBE="SubscribeCommand",e.UNSUBSCRIBE="UnsubscribeCommand",e.UPDATE_SUBSCRIBE_LIST="UpdateSubscribeListCommand",e.ON_SIGNAL_RECONNECTED="OnSignalReconnectedCommand",e.LEAVE_OTHER_ROOM="LeaveOtherRoomCommand",e.RTC_IDENTITY_CHANGE="RTCIdentityChangeCommand",e.ENABLE_INNER_CDN="EnableInnerCDNCommand",e.EXCHANGE_WITH_PUSH_OTHER_ROOM="ExchangeWithPushOtherRoomCommand",e.MCUCONFIG_FLUSH="MCUConfigFlushCommand",e.UNKNOWN="Unknown"}(po||(po={})),function(e){e[e.LOW=0]="LOW",e[e.NORMAL=1]="NORMAL",e[e.HIGH=2]="HIGH"}(fo||(fo={})),function(e){e[e.Destroy=40400]="Destroy"}(Eo||(Eo={}));class No{get priority(){return fo.LOW}get kind(){return po.UNKNOWN}}class yo{constructor(e,t,i,r){Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_store",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"abortCode",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_queue",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_busy",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_isDestroyed",{enumerable:!0,configurable:!0,writable:!0,value:!1})}_next(){this._busy=!1,this._execute()}_execute(){return m(this,void 0,void 0,(function*(){if(this._isDestroyed||this._busy||0===this._queue.length)return;this._busy=!0;const{command:e,resolve:t}=this._queue.shift();let i;const r=this._logger.createTraceId();try{this._logger.info(le.L_INVOKER_EXECUTE_T,`kind: ${e.kind}, length: ${this._queue.length}`,r),i=yield e.execute(this._context,this._store,this)}catch(t){return console.error(t),this._logger.error(le.L_INVOKER_EXECUTE_R,e.kind,r),void this._next()}const{code:n}=i;n!==ae.SUCCESS&&n!==oe.SUCCESS?this._logger.warn(le.L_INVOKER_EXECUTE_R,`code: ${n}, kind: ${e.kind}`,r):this._logger.info(le.L_INVOKER_EXECUTE_R,`kind: ${e.kind}, Done`,r),t(i),this._next()}))}push(e){return m(this,void 0,void 0,(function*(){return new Promise((t=>{if(this._logger.info(le.L_INVOKER_PUSH_O,JSON.stringify({isDestroyed:this._isDestroyed,kind:e.kind,length:this._queue.length})),this._isDestroyed)return void t({code:ae.NOT_IN_ROOM});const{priority:i}=e;if(i===fo.LOW)this._queue.push({command:e,resolve:t});else{const r=this._queue.findIndex((e=>e.command.priority<i)),n=-1===r?this._queue.length-1:r;this._queue.splice(n,0,{command:e,resolve:t})}setTimeout((()=>{this._execute()}),0)}))}))}isDestroyed(){return this._isDestroyed}destroy(){this._isDestroyed||(this._logger.info(le.L_INVOKER_DESTROY_O),this._isDestroyed=!0,this._queue.forEach((e=>{e.resolve({code:this.abortCode})})),this._queue.length=0)}}class Po extends yo{constructor(e,t){super(e.logger,e,t,ae.ROOM_HAS_BEEN_DESTROYED)}get store(){return this._context.store}destroy(){super.destroy(),this._store.removeRemoteTracks()}}!function(e){e.VOID="0",e.OPEN="2",e.CLOSE="1"}(Io||(Io={}));class Uo{constructor(e,t,i,r,n,s,o,a){Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"clientSessionId",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"appkey",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"roomId",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"crtUserId",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"roomMode",{enumerable:!0,configurable:!0,writable:!0,value:s}),Object.defineProperty(this,"isUpgrade",{enumerable:!0,configurable:!0,writable:!0,value:o}),Object.defineProperty(this,"isMainRoom",{enumerable:!0,configurable:!0,writable:!0,value:a}),Object.defineProperty(this,"_roomResources",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_remoteTracks",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_subscribedList",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_collectSubscribeList",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_token",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_sessionId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_CDNUris",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_CDNEnable",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_destroyed",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_trackIdSSRCMap",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),Object.defineProperty(this,"_roomStatusVersion",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_supportNtf",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"_asrStatus",{enumerable:!0,configurable:!0,writable:!0,value:Io.VOID}),Object.defineProperty(this,"_asrEnable",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_srcLanguage",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(this,"_asrSeiUris",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_isStartRealTranslate",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_translationLang",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(this,"_summarizationStatusData",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_nickName",{enumerable:!0,configurable:!0,writable:!0,value:""})}getResourcesByUserId(e){return this._roomResources[e]||this._asrSeiUris[e]}getRemoteTrack(e){return this._remoteTracks[e]}getRemoteTracksByUserId(e){const t=[];for(const i in this._remoteTracks){const r=this._remoteTracks[i];r.getUserId()===e&&t.push(r)}return t}getRemoteTracks(){return this._remoteTracks}getSessionId(){return this._sessionId}getAllUserIds(){return Object.keys(this._roomResources)}getRemoteUserIds(){return this.getAllUserIds().filter((e=>e!==this.crtUserId))}getSubscribedList(){return this._subscribedList}getCollectSubscribeList(){return this._collectSubscribeList}getPublishedResourceByTrackId(e){const{tag:t,userId:i}=_i(e);return t===Vs?this._asrSeiUris[i][0]:this._roomResources[i].find((t=>li(t)===e))}getToken(){return this._token}getCDNEnable(){return this._CDNEnable}getCDNUris(){return this._CDNUris}getRoomStatusVersion(){return this._roomStatusVersion}getTrackIdBySSRC(e){return this._trackIdSSRCMap.get(e)}getRTCRequestHeader(){return{"App-Key":this.appkey,RoomId:this.roomId,Token:this._token,RoomType:this.roomMode,UserId:this.crtUserId,"Client-Session-Id":this.clientSessionId}}getSupportNtf(){return this._supportNtf}getASRIsAvailable(){return!!this.getASRSeiUris().length}getASRStatus(){return this._asrStatus}getASREnable(){return this._asrEnable}getSrcLanguage(){return this._srcLanguage}getASRSeiUris(){const e=Object.values(this._asrSeiUris);return e.length?e[0]:[]}getIsStartRealTranslate(){return this._isStartRealTranslate}getTranslationLang(){return this._translationLang}getSummarizationStatusData(){return this._summarizationStatusData||null}getNickName(){return this._nickName}}class Do extends Uo{_updateTrackIdSSRCMap(){Object.values(this._roomResources).forEach((e=>{e.forEach((e=>{const{ssrc:t,resourceId:i}=JSON.parse(e.uri);this._trackIdSSRCMap.set(t,i)}))}))}setTrackIdSSRCMap(e,t){this._trackIdSSRCMap.set(e,t)}_initRemoteTracks(){for(const e in this._roomResources){const t=this._roomResources[e];e!==this.crtUserId&&0!==t.length&&t.forEach((e=>{const t=li(e),{tag:i,userId:r,mediaType:n}=_i(t),s=n===vt.AUDIO_ONLY?new Xt(this._logger,i,r):new ei(this._logger,i,r);s.__innerSetRemoteMuted(0===e.state),this._remoteTracks[t]=s}))}}initWithRoomData(e,t){this._sessionId=e.sessionId,this._token=e.token,this._roomStatusVersion=Oi(e.version),this._roomResources=Ci(e,this.roomId,this._logger,t),this._updateTrackIdSSRCMap(),this._initRemoteTracks(),this.setResourcesByUserId(this.crtUserId,this.getResourcesByUserId(this.crtUserId)||[]),this._logger.info(le.L_PARSE_ROOMDATA_URIS_R,`room data -> ${JSON.stringify(this._roomResources)}`,t)}assignRoomData(e){Object.assign(this._roomResources,e),this._updateTrackIdSSRCMap()}setResourcesByUserId(e,t){this._roomResources[e]=t,this._updateTrackIdSSRCMap()}removeRemoteTrack(e){delete this._remoteTracks[e]}removeResourcesByUserId(e){delete this._roomResources[e],this._updateTrackIdSSRCMap()}addRemoteTrack(e){this._remoteTracks[e.getTrackId()]=e}removeRemoteTracks(){const e=Object.values(this._remoteTracks);e.length&&(e.forEach((e=>{e.isAudioTrack()&&e.__releaseMediaElement()})),this._remoteTracks={})}setCDNEnabel(e){this._CDNEnable=e}setCDNUris(e){this._CDNUris=e}resetSubscribedList(e){this._subscribedList.splice(0,this._subscribedList.length,...e),this.resetCollectSubscribeList(e)}resetCollectSubscribeList(e){this._collectSubscribeList.splice(0,this._collectSubscribeList.length,...e)}setRoomStatusVersion(e){this._roomStatusVersion=Oi(e)}setASRStatus(e){this._asrStatus=e}setASREnable(e){this._asrEnable=e}setSrcLanguage(e){this._srcLanguage=e}setASRSeiUris(e){if(e.length){const{msid:t}=e[0],i=t.split("_")[0];this._asrSeiUris[i]=e}else this._asrSeiUris={}}addSeiRemoteTrack(e){const{msid:t}=e[0],i=t.split("_"),r=i.pop(),n=i[0],s=new ei(this._logger,r,n);this.addRemoteTrack(s)}removeSeiRemoteTrack(){if(!this.getASRSeiUris().length)return;const{msid:e,mediaType:t}=this.getASRSeiUris()[0],i=`${e}_${t}`;this.removeRemoteTrack(i)}setIsStartRealTranslate(e){this._isStartRealTranslate=e}setTranslationLang(e){this._translationLang=e}setSummarizationStatusData(e){this._summarizationStatusData=e}setNickName(e){this._nickName=e}}class Mo extends No{get kind(){return po.UNPUBLISH_PREV}execute(e,t){return m(this,void 0,void 0,(function*(){const{logger:i,context:r}=e,n=t.getResourcesByUserId(t.crtUserId),s=n.slice();n.length=0;const o=i.createTraceId();i.info(le.L_UNPUBLISH_PREV_COMMAND_T,JSON.stringify({resource:s}),o);const a=yield r.setRTCTotalRes(t.roomId,[ii(vi.UNPUBLISH,s)],ri([]),vi.TOTAL_CONTENT_RESOURCE,ri([]));return a!==oe.SUCCESS?i.error(le.L_UNPUBLISH_PREV_COMMAND_R,JSON.stringify({status:_e.FAILED,code:a}),o):i.info(le.L_UNPUBLISH_PREV_COMMAND_R,JSON.stringify({status:_e.SUCCESSED}),o),{code:ae.SUCCESS}}))}}!function(e){e[e.RTC=0]="RTC",e[e.LIVE=2]="LIVE",e[e.CROSS_MUTI=7]="CROSS_MUTI",e[e.SIP=4]="SIP",e[e.CALL=5]="CALL"}(To||(To={}));class wo extends No{constructor(e,t,i,r,n,s,o,a,l){super(),Object.defineProperty(this,"roomId",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"roomType",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"joinType",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"livingType",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"innerUserDatas",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"outerUserDatas",{enumerable:!0,configurable:!0,writable:!0,value:s}),Object.defineProperty(this,"traceId",{enumerable:!0,configurable:!0,writable:!0,value:o}),Object.defineProperty(this,"srcLanguage",{enumerable:!0,configurable:!0,writable:!0,value:a}),Object.defineProperty(this,"nickName",{enumerable:!0,configurable:!0,writable:!0,value:l})}get kind(){return po.JOINROOM}_getResultTag(){let e=le.L_RTC_CLIENT_JOIN_RTC_ROOM_R;return this.roomType===To.LIVE&&(e=le.L_RTC_CLIENT_JOIN_LIVING_ROOM_R),e}_validateParams(e,t,i){if(e.getConnectionStatus()!==l.CONNECTED)return t.error(i,JSON.stringify({status:_e.FAILED,code:ae.SIGNAL_DISCONNECTED,msg:"im not connected"}),this.traceId),{code:ae.SIGNAL_DISCONNECTED};if(Si(e.getNaviInfo()))return t.error(i,JSON.stringify({status:_e.FAILED,code:ae.PACKAGE_ENVIRONMENT_ERROR,msg:"package environment error"}),this.traceId),{code:ae.PACKAGE_ENVIRONMENT_ERROR};if(!x("roomId",this.roomId,b,!0))return t.error(i,JSON.stringify({status:_e.FAILED,code:ae.PARAMS_ERROR,msg:"params error -> roomId"}),this.traceId),{code:ae.PARAMS_ERROR};if(!x("roomType",this.roomType,(e=>void 0!==To[e])))return t.error(i,JSON.stringify({status:_e.FAILED,code:ae.PARAMS_ERROR,msg:"params error -> roomType"}),this.traceId),{code:ae.PARAMS_ERROR};if(!x("outerUserDatas",this.outerUserDatas,N,!1))return t.error(i,JSON.stringify({status:_e.FAILED,code:ae.PARAMS_ERROR,msg:"params error -> outerUserDatas"}),this.traceId),{code:ae.PARAMS_ERROR};if(this.outerUserDatas){if(!Object.keys(this.outerUserDatas).every((e=>x(`outerUserDatas.${e}`,this.outerUserDatas[e],C,!0))))return t.error(i,JSON.stringify({status:_e.FAILED,code:ae.PARAMS_ERROR,msg:"params error -> outerUserDatas"}),this.traceId),{code:ae.PARAMS_ERROR}}if(this.nickName){if(!x("nickName",this.nickName,C,!0)||this.nickName.length>64)return t.error(i,JSON.stringify({status:_e.FAILED,code:ae.PARAMS_ERROR,msg:"params error -> nickName"}),this.traceId),{code:ae.PARAMS_ERROR}}if(this.srcLanguage){if(!x("srcLanguage",this.srcLanguage,C,!0)||this.srcLanguage.length>50)return t.error(i,JSON.stringify({status:_e.FAILED,code:ae.PARAMS_ERROR,msg:"params error -> srcLanguage"}),this.traceId),{code:ae.PARAMS_ERROR}}return{code:ae.SUCCESS}}execute(e,t,i){return m(this,void 0,void 0,(function*(){var r,n,s,o;const a=Date.now(),{context:l,service:_,logger:c,reportMediaActionLogger:d}=e,u=this._getResultTag(),{code:h}=this._validateParams(l,c,u);if(h!==ae.SUCCESS)return{code:h};if(!_.getMsList().length)return c.error(u,JSON.stringify({status:_e.FAILED,code:ae.NOT_OPEN_VIDEO_AUDIO_SERVER,msg:"No audio / video server address available"}),this.traceId),{code:ae.NOT_OPEN_VIDEO_AUDIO_SERVER};const g=t.getSupportNtf(),{code:p,data:f}=yield l.joinRTCRoom(this.roomId,this.roomType,this.livingType,this.joinType,this.innerUserDatas,this.outerUserDatas,g);if(d.reportQualityJoinRoomData(a,p,this.roomType,null==f?void 0:f.sessionId),p!==oe.SUCCESS||!f){const e=40032===p?ae.SIGNAL_JOIN_RTC_ROOM_REFUSED:p;return c.error(u,JSON.stringify({status:_e.FAILED,code:e,msg:"joinRoom failed"}),this.traceId),{code:e}}t.initWithRoomData(f,this.traceId),this.nickName&&t.setNickName(this.nickName),this.srcLanguage&&t.setSrcLanguage(this.srcLanguage);t.getResourcesByUserId(t.crtUserId).length>0&&i.push(new Mo);const E=null===(r=f.roomInfo.filter((e=>"cdn_uris"===e.key))[0])||void 0===r?void 0:r.value;E&&t.setCDNUris(JSON.parse(E)[0]);const I=null===(n=f.roomInfo.filter((e=>"asr_status"===e.key))[0])||void 0===n?void 0:n.value;I&&t.setASRStatus(I);const T=null===(s=f.roomInfo.filter((e=>"sei_ai_uris"===e.key))[0])||void 0===s?void 0:s.value;if(T){const e=JSON.parse(T);e.length&&(t.setASRSeiUris(e),t.addSeiRemoteTrack(e))}const m=null===(o=f.roomInfo.filter((e=>"summarization"===e.key))[0])||void 0===o?void 0:o.value;if(m){const e=JSON.parse(m);t.setSummarizationStatusData(e)}return c.info(u,JSON.stringify({status:_e.SUCCESSED,userId:t.crtUserId,roomId:this.roomId,sessionId:f.sessionId}),this.traceId),{code:ae.SUCCESS,data:f}}))}}!function(e){e[e.ROOM=1]="ROOM",e[e.PERSON=2]="PERSON"}(mo||(mo={}));const ko={PEER_CONNECTION_CLOSED_BY_EXCEPTION:"PEER_CONNECTION_CLOSED_BY_EXCEPTION",USER_JOIN:"USER_JOIN",USER_LEAVE:"USER_LEAVE",TRACKS_PUBLISH:"TRACKS_PUBLISH",TRACKS_UNPUBLISH:"TRACKS_UNPUBLISH",AUDIO_MUTE_CHANGE:"AUDIO_MUTE_CHANGE",VIDEO_MUTE_CHANGE:"VIDEO_MUTE_CHANGE",CDN_ENABLE_CHANGE:"CDN_ENABLE_CHANGE",USER_STATE_CHANGE:"USER_STATE_CHANGE",ASR_SEI_PUBLISH:"ASR_SEI_PUBLISH",ASR_SEI_UNPUBLISH:"ASR_SEI_UNPUBLISH",SUMMARIZATION_START:"SUMMARIZATION_START",SUMMARIZATION_STOP:"SUMMARIZATION_STOP"};class xo extends B{constructor(e,t,i,r,n,s,o,a){super(),Object.defineProperty(this,"logger",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"service",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"context",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"runtime",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"peer",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"store",{enumerable:!0,configurable:!0,writable:!0,value:s}),Object.defineProperty(this,"polarisReport",{enumerable:!0,configurable:!0,writable:!0,value:o}),Object.defineProperty(this,"reportMediaActionLogger",{enumerable:!0,configurable:!0,writable:!0,value:a}),Object.defineProperty(this,"getPushOtherRooms",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}}var Bo,Vo,Go,Fo;!function(e){e.PUBLISH="publish",e.SUBSCRIBE="subscribe"}(Bo||(Bo={})),function(e){e.BEGIN="begin",e.END="end"}(Vo||(Vo={})),function(e){e[e.SPREAD=0]="SPREAD",e[e.NO_SPREAD=-1]="NO_SPREAD"}(Go||(Go={}));class jo extends No{constructor(e,t,i){super(),Object.defineProperty(this,"reqBody",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"traceId",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"isNeedUpdateMsas",{enumerable:!0,configurable:!0,writable:!0,value:i})}execute(e,t,i){return m(this,void 0,void 0,(function*(){var i;const{service:r,context:n}=e,s=yield r.exchange(t.getRTCRequestHeader(),this.reqBody,this.traceId,this.isNeedUpdateMsas),{code:o,data:a,qualityMsList:l}=s,_={code:o,data:{data:a,qualityMsList:l}},c=null===(i=null==a?void 0:a.urls)||void 0===i?void 0:i.pull_url;if(t.roomMode===To.LIVE&&c){const e=JSON.parse(c);if(t.setCDNUris(e),(null==e?void 0:e.broadcast)===Go.SPREAD){t.setCDNEnabel(!0);const i=Object.assign(Object.assign({},e),{enableInnerCDN:!0});qo(n,t.roomId,i)}}return _}))}}!function(e){e.PUB="pub",e.UNPUB="unpub",e.SUB="sub",e.UNSUB="unsub"}(Fo||(Fo={}));class Ho extends No{constructor(e,t,i,r=Fo.SUB,n){super(),Object.defineProperty(this,"tracks",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"forceReq",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"traceId",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"fromCommand",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"unsubTracks",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"_actionStartTime",{enumerable:!0,configurable:!0,writable:!0,value:Date.now()}),Object.defineProperty(this,"_trackMediaMap",{enumerable:!0,configurable:!0,writable:!0,value:{}})}get kind(){return po.UPDATE_SUBSCRIBE_LIST}_dealSubscribeResult(e,t,i,r){const n=null==r?void 0:r.map((e=>`${e.msid}_${e.mediaType}`)),s=i.filter((e=>null==n?void 0:n.includes(e.track.getTrackId()))),o=i.filter((e=>!(null==n?void 0:n.includes(e.track.getTrackId()))));t.info(le.L_ABSTRACT_ROOM_SUBSCRIBE_R,JSON.stringify({status:_e.SUCCESSED,subSuccessTrackIds:n,failedList:o}),this.traceId);const a=e.getRemoteTracks();for(const e in a){const t=s.some((t=>t.track.getTrackId()===e));a[e].__innerSetSubscribed(t);const i=s.some((t=>t.track.getTrackId()===e&&t.subTiny));a[e].isVideoTrack()&&a[e].__innerSetIsTinyTrack(i)}return e.resetSubscribedList(s),o}_getParams(e,t,i){let r=i.map((e=>e instanceof Zt?{track:e}:Object.assign({},e)));const n={};return r=r.filter((i=>{const r=i.track.getTrackId();return e.getRemoteTrack(r)?!n[r]&&(n[r]=!0,!0):(t.warn(le.L_UPDATE_SUBSCRIBELIST_COMMAND_P,`track cannot found in room -> trackId: ${r}`,this.traceId),!1)})).map((e=>Object.assign({},e))),r}_validateParams(e,t){return x("tracks",t,(()=>v(t)&&t.every((e=>e instanceof Zt||e.track instanceof Zt))),!0)?{code:ae.SUCCESS}:(e.warn(le.L_UPDATE_SUBSCRIBELIST_COMMAND_R,JSON.stringify({status:_e.FAILED,code:ae.PARAMS_ERROR,msg:"tracks is invalid"}),this.traceId),{code:ae.PARAMS_ERROR})}_reportPubOrSubQualityData(e,t,i){(null==i?void 0:i.length)&&e.reportPubOrSubQualityData(this.fromCommand,this._actionStartTime,i,t,this._trackMediaMap)}execute(e,t,i){return m(this,void 0,void 0,(function*(){const{logger:r,peer:n,reportMediaActionLogger:s,context:o}=e;this._actionStartTime=Date.now();const{tracks:a,forceReq:l}=this,{roomId:_}=t;r.info(le.L_UPDATE_SUBSCRIBELIST_COMMAND_T,`roomId: ${_}, forceReq: ${l}, trackIds: ${a.map(Li)}`,this.traceId);const{code:c}=this._validateParams(r,a);if(c!==ae.SUCCESS)return{code:c};const d=this._getParams(t,r,a),u=t.getSubscribedList().map((e=>Object.assign({},e)));if(!l){if(!ta(d,u))return r.warn(le.L_UPDATE_SUBSCRIBELIST_COMMAND_R,JSON.stringify({status:_e.SUCCESSED,msg:"subscribe list unchanged"}),this.traceId),{code:ae.SUCCESS};if(u.length){const e=u.map((e=>e.track));r.warn(le.L_CLEAR_UNSUBSCRIBE_LIST_O,JSON.stringify({list:e.map((e=>e.getTrackId()))}),this.traceId);const i=t.getSubscribedList().filter((t=>e.every((e=>e.getTrackId()!==t.track.getTrackId()))));t.resetSubscribedList(i)}}n.__reportR3R4ToPolaris(),n.clearReTryExchangeTimer(),n.updateSubRemoteTracks(d.map((e=>e.track)));const h=yield Ko(d,!1,n,t,o);h.pushOtherRooms=e.getPushOtherRooms();const g=yield new jo(h,this.traceId,!0).execute(e,t,i);a.forEach((e=>{const t=e instanceof Zt?e.getTrackId():e.track.getTrackId();this._trackMediaMap[t]=g.data.qualityMsList||[]}));const p=this.fromCommand===Fo.SUB?a:this.unsubTracks;if(g.code!==ae.SUCCESS)return this._reportPubOrSubQualityData(s,g.code,p),r.error(le.L_UPDATE_SUBSCRIBELIST_COMMAND_R,JSON.stringify({status:_e.FAILED,code:g.code}),this.traceId),{code:g.code};const{sdp:f,resultCode:E,subscribedList:I}=g.data.data;if(E!==ae.SUCCESS)return this._reportPubOrSubQualityData(s,E,p),r.error(le.L_UPDATE_SUBSCRIBELIST_COMMAND_R,JSON.stringify({status:_e.FAILED,code:E}),this.traceId),{code:E};s.setPubOrSubSuccessTime(Date.now());const T=yield n.setRemoteAnswer(f.sdp);if(this._reportPubOrSubQualityData(s,T,p),T!==ae.SUCCESS)return{code:T};const m=this._dealSubscribeResult(t,r,d,I);return m.length?{code:ae.SUCCESS,data:m}:{code:ae.SUCCESS}}))}}class Jo extends No{constructor(e,t){super(),Object.defineProperty(this,"tracks",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"traceId",{enumerable:!0,configurable:!0,writable:!0,value:t})}get kind(){return po.UNSUBSCRIBE}execute(e,t,i){return m(this,void 0,void 0,(function*(){const{logger:r,polarisReport:n}=e,{tracks:s}=this;if(!x("tracks",s,(()=>v(s)&&s.length>0&&s.every((e=>e instanceof Zt))),!0))return r.warn(le.L_ABSTRACT_ROOM_UNSUBSCRIBE_E,JSON.stringify({status:_e.FAILED,code:ae.PARAMS_ERROR,msg:"params error -> tracks"}),this.traceId),{code:ae.PARAMS_ERROR};r.info(le.L_ABSTRACT_ROOM_UNSUBSCRIBE_T,JSON.stringify({unSubscribeTrackIds:s.map(Li)}),this.traceId);const o=t.getSubscribedList().map((e=>Object.assign({},e))).filter((e=>s.every((t=>t.getTrackId()!==e.track.getTrackId()))));return n.sendR2(Bo.SUBSCRIBE,Vo.END,s.map((e=>e.getTrackId()))),new Ho(o,!1,this.traceId,Fo.UNSUB,this.tracks).execute(e,t,i)}))}}class $o extends No{constructor(e){super(),Object.defineProperty(this,"tracks",{enumerable:!0,configurable:!0,writable:!0,value:e})}execute(e,t,i){return m(this,void 0,void 0,(function*(){const{logger:r}=e,{tracks:n}=this,s=r.createTraceId();return r.info(le.L_USER_LEFT_UNSUBSCRIBE_O,void 0,s),yield new Jo(n,s).execute(e,t,i),n.forEach((e=>{e.__innerDestroy(),t.removeRemoteTrack(e.getTrackId())})),e.emit(ko.TRACKS_UNPUBLISH,n),{code:ae.SUCCESS}}))}}function Ko(e,t,i,r,n){return m(this,void 0,void 0,(function*(){var s;const o=(null===(s=n.getNaviInfo())||void 0===s?void 0:s.ipType)||0,a=yield i.createOffer(t),l=r.getSrcLanguage(),_=r.getNickName(),c={resolutionInfo:i.getOutboundVideoInfo()};l&&Object.assign(c,{srcLanguage:l}),_&&Object.assign(c,{nickName:_});return{asr_status:r.getASRStatus(),ipType:o,sdp:a,extend:JSON.stringify(c),subscribeList:e.filter((e=>{const t=e.track.getTrackId(),{userId:i}=_i(t),n=r.getResourcesByUserId(i);if(!n)return!1;const s=n.filter((e=>t===`${e.msid}_${e.mediaType}`)).length;return s})).map((e=>({simulcast:e.subTiny?Ys.TINY:Ys.NORMAL,resolution:"",uri:r.getPublishedResourceByTrackId(e.track.getTrackId()).uri}))),switchstream:!1}}))}function Yo(e,t,i){return m(this,void 0,void 0,(function*(){const r=e.logger.createTraceId();e.logger.info(le.L_LIVING_ROOM_SPREAD_CDN_INFO_T,JSON.stringify({CDNUris:i}),r);const n=yield e.setRTCCDNUris(t,vi.TOTAL_CONTENT_RESOURCE,JSON.stringify([i]));return n!==oe.SUCCESS?(e.logger.error(le.L_LIVING_ROOM_SPREAD_CDN_INFO_R,`status: ${_e.FAILED}, code: ${n}`,r),{code:ae.SIGNAL_ERROR}):(e.logger.info(le.L_LIVING_ROOM_SPREAD_CDN_INFO_R,`status: ${_e.SUCCESSED}`,r),{code:ae.SUCCESS})}))}function qo(e,t,i){return m(this,void 0,void 0,(function*(){const r=e.logger.createTraceId();e.logger.info(le.L_LIVING_ROOM_SET_ROOM_CDN_INFO_T,`CDNUris: ${i}`,r);const n=yield e.setRTCData(t,"cdn_uris",JSON.stringify([i]),!0,mo.ROOM);return n!==oe.SUCCESS?(e.logger.error(le.L_LIVING_ROOM_SET_ROOM_CDN_INFO_R,`status: ${_e.FAILED}, code: ${n}`,r),{code:ae.SIGNAL_ERROR}):(e.logger.info(le.L_LIVING_ROOM_SET_ROOM_CDN_INFO_R,`status: ${_e.SUCCESSED}`,r),{code:ae.SUCCESS})}))}function Wo(e,t){return m(this,void 0,void 0,(function*(){const{roomId:i}=t,r=Object.assign({},t.getCDNUris(),{enableInnerCDN:t.getCDNEnable()});return(yield Promise.all([Yo(e,i,r),qo(e,i,r)])).every((e=>e.code===ae.SUCCESS))?{code:ae.SUCCESS}:{code:ae.SIGNAL_ERROR}}))}function zo(e,t,i,r,n,s){return m(this,void 0,void 0,(function*(){const{logger:o}=i,{roomId:a,roomMode:l}=t,_=[],c={},d={},u={},h=Ci(e,a,o,s),g=Object.keys(h),p=t.getAllUserIds();for(let e=g.length-1;e>=0;e-=1){const i=g[e],r=p.indexOf(i);if(-1===r){_.push(i),c[i]=di(h[i]);continue}const n=t.getResourcesByUserId(i),s=h[i],{publishedList:o,modifiedList:a,unpublishedList:l}=ui(n,s,!0);c[i]=di(o),d[i]=di(l),u[i]=di(a),p.splice(r,1)}p.length&&p.forEach((e=>{t.removeResourcesByUserId(e)})),t.assignRoomData(h),p.length&&(yield Qo(p,i,t,r,s),i.emit(ko.USER_LEAVE,p)),_.length&&i.emit(ko.USER_JOIN,_),yield((e,t,i,r)=>m(void 0,void 0,void 0,(function*(){const{crtUserId:n}=e;for(const s in r){if(s===n)continue;const o=r[s];if(o.length){const r=o.map((t=>e.getRemoteTrack(li(t))));yield new $o(r).execute(t,e,i)}}})))(t,i,r,d),((e,t,i)=>{const{logger:r}=t;Object.keys(i).forEach((n=>{const s=i[n];if(0===s.length)return;const o=s.map((t=>{const i=li(t),{userId:n,tag:s,mediaType:o}=_i(i),a=o===vt.AUDIO_ONLY?new Xt(r,s,n):new ei(r,s,n);return e.addRemoteTrack(a),a.__innerSetRemoteMuted(0===t.state),a}));o.length&&t.emit(ko.TRACKS_PUBLISH,o)}))})(t,i,c),((e,t,i)=>{Object.keys(i).forEach((r=>{i[r].forEach((i=>{const r=li(i),n=e.getRemoteTrack(r);n.__innerSetRemoteMuted(0===i.state),n.isAudioTrack()?t.emit(ko.AUDIO_MUTE_CHANGE,n):t.emit(ko.VIDEO_MUTE_CHANGE,n)}))}))})(t,i,u),l===H.LIVE&&function(e,t,i,r){var n;if(!r)return void i.warn(le.L_LIVING_ROOM_RECONNECTED_R,JSON.stringify({status:_e.FAILED,code:"",msg:"cdn_uris not found"}));const s=JSON.parse(r),o=(null===(n=t.getCDNUris())||void 0===n?void 0:n.enableInnerCDN)!==s.enableInnerCDN;t.setCDNUris(s),o&&e.emit(ko.CDN_ENABLE_CHANGE,s.enableInnerCDN)}(i,t,o,n)}))}function Qo(e,t,i,r,n){return m(this,void 0,void 0,(function*(){const s=[],o=[];e.forEach((e=>{s.push(...i.getRemoteTracksByUserId(e)),o.push(e)})),s.length&&(yield new Jo(s,n).execute(t,i,r),s.forEach((e=>i.removeRemoteTrack(e.getTrackId())))),o.length&&o.forEach((e=>i.removeResourcesByUserId(e)))}))}function Zo(e){var t;const{userId:i,userData:r,event:n,switchRoleType:s}=e;return{users:[{userId:i,extra:null===(t=r.filter((e=>"extra"===e.key))[0])||void 0===t?void 0:t.value,state:n,switchRoleType:s}]}}function Xo(e){var t,i;const{userId:r,userData:n}=e,s=(e=>e.some((e=>"uris"===e.key||"cdn_uris"===e.key)))(n);if(!s)return;const o=null===(t=n.filter((e=>"uris"===e.key))[0])||void 0===t?void 0:t.value,a=null===(i=n.filter((e=>"cdn_uris"===e.key))[0])||void 0===i?void 0:i.value;return{userId:r,content:{uris:o?JSON.parse(o):[],cdn_uris:a&&JSON.parse(a)}}}const ea=(e,t,i)=>{const r=e.split("\r\nm"),n=i===vt.AUDIO_ONLY?"audio":"video",s=r.filter((e=>e.includes(`=${n}`)&&e.includes(t)))[0];let o=new RegExp(`a=ssrc:(.*?) msid:${t}`);const a=s.match(o);return a?a[1]:""},ta=(e,t)=>{let i=!1;return e.forEach((e=>{const r=t.findIndex((t=>t.track.getTrackId()===e.track.getTrackId()));if(-1===r)return void(i=!0);t.splice(r,1)[0].subTiny!==e.subTiny&&(i=!0)})),t.length&&(i=!0),i};class ia extends No{constructor(e,t){super(),Object.defineProperty(this,"msgContent",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"traceId",{enumerable:!0,configurable:!0,writable:!0,value:t})}get kind(){return po.PARSE_USERSTATE}get priority(){return fo.NORMAL}_isPKRoomUser(e,t){for(const i of t){if(i.extra&&i.extra.roomId!==e.roomId)return!0;if(1===Number(i.state)&&!e.getRemoteUserIds().includes(i.userId))return!0}return!1}_dealAddUser(e,t,i,r,n){const s=e.getResourcesByUserId(n);s||(r?i.upgrade.push(n):i.joined.push(n),t.info(le.L_PARSE_USERSTATE_COMMAND_R,JSON.stringify({userId:n,msg:"user "+(r?"upgrade":"joined")}),this.traceId)),e.setResourcesByUserId(n,s||[])}_dealReduceUser(e,t,i,r,n){e.info(le.L_PARSE_USERSTATE_COMMAND_R,JSON.stringify({userId:n,msg:"user "+(r?"downgrade":"left")}),this.traceId),r?t.downgrade.push(n):1!==Number(i)?t.offline.push(n):t.left.push(n)}execute(e,t,i){return m(this,void 0,void 0,(function*(){const{logger:r}=e,n={joined:[],left:[],offline:[],upgrade:[],downgrade:[]},{users:s}=this.msgContent;if(0===s.length)return{code:ae.SUCCESS,data:n};if(this._isPKRoomUser(t,s))return{code:ae.SUCCESS,data:n};s.forEach((e=>{const{userId:i}=e;0===Number(e.state)?this._dealAddUser(t,r,n,e.switchRoleType,i):this._dealReduceUser(r,n,e.state,e.switchRoleType,i)}));const o=[...n.left,...n.downgrade,...n.offline];return o.length&&(yield Qo(o,e,t,i,this.traceId)),{code:ae.SUCCESS,data:n}}))}}class ra extends No{constructor(e,t,i,r,n){super(),Object.defineProperty(this,"msgContent",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"messageType",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"senderId",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"traceId",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"sentTime",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"_publishedList",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_unpublishedList",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_modifiedList",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_nowResources",{enumerable:!0,configurable:!0,writable:!0,value:[]})}get kind(){return po.PARSE_REMOTERES}get priority(){return fo.NORMAL}_dealPublishList(e,t,i){return m(this,void 0,void 0,(function*(){const{logger:r,reportMediaActionLogger:n}=e,s=this._nowResources.map(li),o=[],a=[];if(this._publishedList.forEach((e=>{const i=li(e),n=s.indexOf(i),{userId:l,tag:_,mediaType:c}=_i(i);n>-1?this._nowResources[n]=e:this._nowResources.push(e);let d=t.getRemoteTrack(i);d?d.isSubscribed()&&o.push(d):(d=c===vt.AUDIO_ONLY?new Xt(r,_,l):new ei(r,_,l),t.addRemoteTrack(d),a.push(d)),d.__innerSetRemoteMuted(0===e.state)})),o.length){const n=o.map((e=>e.getTrackId())),{code:s}=yield new Ho(o,!0,this.traceId).execute(e,t,i);s!==ae.SUCCESS&&r.error(le.L_RESUB_REPUB_RES_R,JSON.stringify({status:_e.FAILED,trackIds:n,code:s}),this.traceId)}a.length&&e.emit(ko.TRACKS_PUBLISH,a),n.reportQualityRecvPubMsgData(this.sentTime,this.senderId)}))}_dealUnpublishList(e,t,i){return m(this,void 0,void 0,(function*(){const r=this._unpublishedList.map(li);for(let e=this._nowResources.length-1;e>=0;e-=1){const t=this._nowResources[e];r.includes(li(t))&&this._nowResources.splice(e,1)}const n=this._unpublishedList.map((e=>{const i=li(e);return t.getRemoteTrack(i)}));yield new $o(n).execute(e,t,i)}))}_dealModifiedList(e,t){return m(this,void 0,void 0,(function*(){const i=this._nowResources.map(li);for(const r of this._modifiedList){const n=li(r),s=i.indexOf(n);this._nowResources[s].state=r.state;const o=t.getRemoteTrack(n);o.__innerSetRemoteMuted(0===r.state),o.isAudioTrack()?e.emit(ko.AUDIO_MUTE_CHANGE,o):e.emit(ko.VIDEO_MUTE_CHANGE,o)}}))}_updateCDNUris(e,t){var i,r;const n=this.msgContent.cdn_uris[0],s=(null===(i=t.getCDNUris())||void 0===i?void 0:i.enableInnerCDN)!==n.enableInnerCDN;t.setCDNUris(n),s&&e.emit(ko.CDN_ENABLE_CHANGE,!!(null===(r=t.getCDNUris())||void 0===r?void 0:r.enableInnerCDN))}execute(e,t,i){return m(this,void 0,void 0,(function*(){const{uris:r}=this.msgContent;let n;this._publishedList=[],this._unpublishedList=[],this._modifiedList=[];const s=this.senderId,{messageType:o}=this;if(!t.getRemoteUserIds().includes(s))return{code:ae.SUCCESS};switch(this._nowResources=t.getResourcesByUserId(s)||[],o){case vi.MODIFY:this._modifiedList.push(...r);break;case vi.PUBLISH:this._publishedList.push(...r);break;case vi.UNPUBLISH:this._unpublishedList.push(...r);break;case vi.TOTAL_CONTENT_RESOURCE:n=ui(this._nowResources,r),this._publishedList.push(...n.publishedList),this._unpublishedList.push(...n.unpublishedList),this._modifiedList.push(...n.modifiedList)}if(this._publishedList.length&&(yield this._dealPublishList(e,t,i)),this._unpublishedList.length&&(yield this._dealUnpublishList(e,t,i)),this._modifiedList.length&&(yield this._dealModifiedList(e,t)),t.setResourcesByUserId(s,this._nowResources),t.roomMode!==To.LIVE)return{code:ae.SUCCESS};return this.msgContent.cdn_uris?(this._updateCDNUris(e,t),{code:ae.SUCCESS}):{code:ae.SUCCESS}}))}}class na extends No{constructor(e,t,i){super(),Object.defineProperty(this,"tracks",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"forceReq",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"traceId",{enumerable:!0,configurable:!0,writable:!0,value:i})}get kind(){return po.SUBSCRIBE}execute(e,t,i){return m(this,void 0,void 0,(function*(){const{logger:r,polarisReport:n}=e,{tracks:s,forceReq:o}=this;if(!x("tracks",s,(()=>v(s)&&s.length>0&&s.every((e=>e instanceof Zt||e.track instanceof Zt))),!0))return r.error(le.L_ABSTRACT_ROOM_SUBSCRIBE_E,JSON.stringify({status:_e.FAILED,code:ae.PARAMS_ERROR,msg:"params error -> tracks"}),this.traceId),{code:ae.PARAMS_ERROR};r.info(le.L_ABSTRACT_ROOM_SUBSCRIBE_T,JSON.stringify({trackIds:s.map(Li),forceReq:o}),this.traceId);const a=t.getSubscribedList().map((e=>Object.assign({},e))),l=s.map((e=>e instanceof Zt?{track:e}:e));let _=!1;const c=[];return l.forEach((e=>{const t=e.track.getTrackId();c.push(t);const i=a.find((e=>e.track.getTrackId()===t));i&&i.subTiny===e.subTiny||(i?i.subTiny=e.subTiny:a.push(e),_=!0)})),_||o?(n.sendR2(Bo.SUBSCRIBE,Vo.BEGIN,c),new Ho(a,!0,this.traceId).execute(e,t,i)):(r.warn(le.L_ABSTRACT_ROOM_SUBSCRIBE_R,JSON.stringify({status:_e.SUCCESSED,msg:"repeat subscribe"}),this.traceId),{code:ae.SUCCESS})}))}}class sa extends No{constructor(e){super(),Object.defineProperty(this,"tracks",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_traceId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_actionStartTime",{enumerable:!0,configurable:!0,writable:!0,value:Date.now()}),Object.defineProperty(this,"_trackMediaMap",{enumerable:!0,configurable:!0,writable:!0,value:{}})}get kind(){return po.PUBLISH}_removePubFailedTracks(e,t){e.forEach((e=>{const i=e instanceof jt?e:e.track;t.removeLocalTrackById(i.getTrackId())}))}_addLocalTracks(e,t){return m(this,void 0,void 0,(function*(){const i=[];for(const r of e){const{track:e,pubTiny:n}=r instanceof jt?{pubTiny:!1,track:r}:r;if(e.isVideoTrack()&&n){let r;try{r=e.__innerGetMediaStreamTrack().clone();const t=n.frameRate||Lt.FPS_15,i=n.resolution||Ot.W176_H144,{width:s,height:o}=gi(i),a=Ei(t);yield r.applyConstraints({width:s,height:o,frameRate:a})}catch(t){null==r||r.stop(),this._logger.warn(le.L_ABSTRACT_ROOM_PUBLISH_E,`pubTiny failed -> id: ${e.getTrackId()}, msg: ${t.message}`,this._traceId);break}const s=new Jt(this._logger,e.getTag(),e.getUserId(),r,!0);i.push(s),t.addLocalTrack(s)}t.addLocalTrack(e)}return i}))}__publish(e,t,i,r){return m(this,void 0,void 0,(function*(){const{peer:n,reportMediaActionLogger:s,context:o}=e,a=[];i.forEach((e=>{const{track:t}=e instanceof jt?{track:e}:e;a.push(t)})),i.sort(((e,t)=>{const{track:i}=e instanceof jt?{track:e}:e,{max:r}=i.getBitrate(),{track:n}=t instanceof jt?{track:t}:t,{max:s}=n.getBitrate();return r-s}));if(n.getLocalTracks().length+((e,t)=>{let i=0;return e.forEach((e=>{const r=e instanceof jt?e.getTrackId():e.track.getTrackId();t.getLocalTrack(r)||(e instanceof jt?i++:e.pubTiny&&e.track.isVideoTrack()&&(i+=2))})),i})(i,n)>10)return this._logger.error(le.L_ABSTRACT_ROOM_PUBLISH_E,JSON.stringify({status:_e.FAILED,code:ae.PUBLISH_TRACK_LIMIT_EXCEEDED,trackIds:i.map(Li),msg:"publish track limit exceeded"}),this._traceId),{code:ae.PUBLISH_TRACK_LIMIT_EXCEEDED,tracks:a};const l=yield this._addLocalTracks(i,n);n.clearReTryExchangeTimer();const _=t.getSubscribedList(),c=yield Ko(_,!1,n,t,o);c.pushOtherRooms=e.getPushOtherRooms();const d=yield new jo(c,this._traceId,!0).execute(e,t,r);if(a.forEach((e=>{const t=e.getTrackId();this._trackMediaMap[t]=d.data.qualityMsList||[]})),d.code!==ae.SUCCESS)return s.reportPubOrSubQualityData(Fo.PUB,this._actionStartTime,a,d.code,this._trackMediaMap),this._logger.error(le.L_ABSTRACT_ROOM_PUBLISH_E,JSON.stringify({status:_e.FAILED,tracks:i.map(Li),code:d.code,msg:"exchange failed"}),this._traceId),this._removePubFailedTracks(i,n),{code:d.code,tracks:a};const{sdp:u,resultCode:h,message:g}=d.data.data;if(h!==ae.SUCCESS)return s.reportPubOrSubQualityData(Fo.PUB,this._actionStartTime,a,h,this._trackMediaMap),this._logger.error(le.L_ABSTRACT_ROOM_PUBLISH_E,JSON.stringify({status:_e.FAILED,trackIds:i.map(Li),code:h,msg:`exchange inner failed: ${g}`}),this._traceId),this._removePubFailedTracks(i,n),{code:h,tracks:a};s.setPubOrSubSuccessTime(Date.now());const p=yield n.setRemoteAnswer(u.sdp,!0);return p!==ae.SUCCESS?(s.reportPubOrSubQualityData(Fo.PUB,this._actionStartTime,a,p,this._trackMediaMap),this._logger.error(le.L_ABSTRACT_ROOM_PUBLISH_E,JSON.stringify({status:_e.FAILED,trackIds:i.map(Li),code:p,msg:"set remote answer error"}),this._traceId),{code:p,tracks:a}):(l.length&&this._updateTinyTrackIdSSRCMap(t,c.sdp.sdp,l),Object.assign(Object.assign({code:h},d.data),{tracks:a}))}))}_updateTinyTrackIdSSRCMap(e,t,i){i.forEach((i=>{const r=ea(t,i.getStreamId(),vt.VIDEO_ONLY);e.setTrackIdSSRCMap(Number(r),i.getTrackId())}))}_dealPublishRes(e,t,i){return m(this,void 0,void 0,(function*(){const{polarisReport:r,context:n,peer:s,reportMediaActionLogger:o}=i,a=t.crtUserId,{roomId:l}=t;let _="";const c=t.getResourcesByUserId(a),d=[...c];let u=[];const{tracks:h}=e;if(e.code!==ae.SUCCESS)return{code:e.code};const{publishList:g,urls:p,mcuPublishList:f}=e.data;_=null==p?void 0:p.liveUrl;g.map((e=>Object.assign({tag:e.msid.split("_").pop(),state:s.getLocalTrack(li(e)).isLocalMuted()?0:1},e))).forEach((e=>{const{isInclude:t,index:i}=((e,t)=>{let i=!1,r=0;for(let n=0;n<t.length;n++){const s=t[n];if(`${e.msid}_${e.mediaType}`==`${s.msid}_${s.mediaType}`){i=!0,r=n;break}}return{isInclude:i,index:r}})(e,d);t?d.splice(i,1,e):d.push(e)}));u=(null==f?void 0:f.map((e=>Object.assign({tag:e.msid.split("_").pop(),state:1},e))))||[];const{publishedList:E}=ui(c,d),I=Object.assign(Object.assign({},t.getCDNUris()),{enableInnerCDN:t.getCDNEnable()}),T=I&&I.broadcast===Go.SPREAD?JSON.stringify([I]):"",m=Date.now(),R=yield n.setRTCTotalRes(l,[ii(vi.PUBLISH,E)],ri(d),vi.TOTAL_CONTENT_RESOURCE,ri(u),T);if(o.reportPubOrSubQualityData(Fo.PUB,this._actionStartTime,h,R,this._trackMediaMap,[{dur:Date.now()-m,cod:R}]),R!==oe.SUCCESS)return this._logger.error(le.L_ABSTRACT_ROOM_PUBLISH_R,JSON.stringify({status:_e.FAILED,code:R,msg:"send publish streams notification failed"}),this._traceId),{code:ae.SIGNAL_ERROR};t.setResourcesByUserId(a,d);const S=E.map((e=>li(e)));r.sendR2(Bo.PUBLISH,Vo.BEGIN,S),E.forEach((e=>{s.getLocalTrack(`${e.msid}_${e.mediaType}`).__innerSetPublished(!0)}));const C={code:ae.SUCCESS};return _&&(C.liveUrl=_),C}))}execute(e,t,i){return m(this,void 0,void 0,(function*(){const{logger:r,peer:n}=e;this._traceId=r.createTraceId(),this._logger=r,this._actionStartTime=Date.now();let{tracks:s}=this;if(!x("tracks",s,(()=>v(s)&&s.length>0&&s.every((e=>e instanceof jt||e.track instanceof jt))),!0))return this._logger.error(le.L_ABSTRACT_ROOM_PUBLISH_E,JSON.stringify({status:_e.FAILED,code:ae.PARAMS_ERROR,msg:"params error -> tracks"}),this._traceId),{code:ae.PARAMS_ERROR};if(this._logger.info(le.L_ABSTRACT_ROOM_PUBLISH_T,JSON.stringify({trackIds:s.map(Li)})),s=s.filter((e=>{const{track:t}=e instanceof jt?{track:e}:e,i=t.isDestroyed();return i&&this._logger.warn(le.L_ABSTRACT_ROOM_PUBLISH_E,`track '${t.getTrackId()}' has beem destroyed`,this._traceId),!i})),!s.length)return this._logger.error(le.L_ABSTRACT_ROOM_PUBLISH_R,JSON.stringify({status:_e.FAILED,code:ae.PUBLISH_TRACKS_IS_INVALID,msg:"params tracks is empty"}),this._traceId),{code:ae.PUBLISH_TRACKS_IS_INVALID};n.__reportR3R4ToPolaris(),n.clearReTryExchangeTimer();const o=yield this.__publish(e,t,s,i);return yield this._dealPublishRes(o,t,e)}))}}class oa extends No{constructor(e){super(),Object.defineProperty(this,"tracks",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_traceId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_actionStartTime",{enumerable:!0,configurable:!0,writable:!0,value:Date.now()}),Object.defineProperty(this,"_trackMediaMap",{enumerable:!0,configurable:!0,writable:!0,value:{}})}get kind(){return po.UNPUBLISH}__unpublish(e,t,i,r){return m(this,void 0,void 0,(function*(){const{peer:n,polarisReport:s,logger:o,reportMediaActionLogger:a,context:l}=e,_=r.map((e=>e.getTrackId()));if(0===_.map(t.getPublishedResourceByTrackId.bind(t)).filter((e=>!!e)).length)return{code:ae.SUCCESS,tracks:r};_.forEach((e=>n.removeLocalTrackById(e))),s.sendR2(Bo.PUBLISH,Vo.END,_),n.clearReTryExchangeTimer();const c=t.getSubscribedList(),d=yield Ko(c,!1,n,t,l),u=e.getPushOtherRooms();u.length&&(d.pushOtherRooms=u);const h=yield new jo(d,this._traceId,!0).execute(e,t,i);if(r.forEach((e=>{const t=e.getTrackId();this._trackMediaMap[t]=h.data.qualityMsList||[]})),h.code!==ae.SUCCESS)return a.reportPubOrSubQualityData(Fo.UNPUB,this._actionStartTime,r,h.code,this._trackMediaMap),o.error(le.L_ABSTRACT_ROOM_UNPUBLISH_P,JSON.stringify({status:_e.FAILED,code:h.code,trackIds:r.map(Li),msg:"exchange failed"}),this._traceId),{code:h.code,tracks:r};const{resultCode:g,message:p}=h.data.data;return g!==ae.SUCCESS?(a.reportPubOrSubQualityData(Fo.UNPUB,this._actionStartTime,r,h.data.data.resultCode,this._trackMediaMap),o.error(le.L_ABSTRACT_ROOM_UNPUBLISH_P,JSON.stringify({status:_e.FAILED,code:g,trackIds:r.map(Li),msg:`exchange inner failed: ${p}`}),this._traceId),{code:g,tracks:r}):Object.assign(Object.assign({code:h.code},h.data),{tracks:r})}))}_dealUnpublishRes(e,t,i){return m(this,void 0,void 0,(function*(){const{context:r,logger:n,peer:s,reportMediaActionLogger:o}=e,a=r.getCurrentId(),{roomId:l}=t,_=[];let c=[];const{tracks:d,code:u,data:h}=i;if(u!==ae.SUCCESS)return n.error(le.L_ABSTRACT_ROOM_UNPUBLISH_R,JSON.stringify({code:u,msg:"unpublish failed"}),this._traceId),{code:u};if(!h)return n.info(le.L_ABSTRACT_ROOM_UNPUBLISH_R,JSON.stringify({status:_e.SUCCESSED,msg:"unpublish list is empty "})),{code:ae.SUCCESS};const{mcuPublishList:g}=h,p=d.map((e=>e.getTrackId())),f=p.map(t.getPublishedResourceByTrackId.bind(t)).filter((e=>!!e));_.push(...f);c=g?g.map((e=>Object.assign({tag:e.msid.split("_").pop(),state:1},e))):[];const E=t.getResourcesByUserId(a).filter((e=>!_.includes(e))),I=Date.now(),T=yield r.setRTCTotalRes(l,[ii(vi.UNPUBLISH,_)],ri(E),vi.TOTAL_CONTENT_RESOURCE,ri(c));if(o.reportPubOrSubQualityData(Fo.UNPUB,this._actionStartTime,d,T,this._trackMediaMap,[{dur:Date.now()-I,cod:T}]),T!==oe.SUCCESS)return n.error(le.L_ABSTRACT_ROOM_UNPUBLISH_R,JSON.stringify({status:_e.FAILED,code:T,msg:"send unpublish notification failed"}),this._traceId),{code:ae.SIGNAL_ERROR};n.info(le.L_ABSTRACT_ROOM_UNPUBLISH_R,JSON.stringify({status:_e.SUCCESSED,code:ae.SUCCESS,msg:"unpublish success",unPubResourceIds:p}),this._traceId);const{sdp:m}=i.data;return yield s.setRemoteAnswer(m.sdp),t.setResourcesByUserId(a,E),{code:ae.SUCCESS}}))}execute(e,t,i){return m(this,void 0,void 0,(function*(){const{logger:r}=e;this._actionStartTime=Date.now();const{crtUserId:n}=t,{tracks:s}=this;this._traceId=r.createTraceId();if(!x("tracks",s,(()=>s.every((e=>e.getUserId()===n&&e instanceof jt))),!0))return r.error(le.L_ABSTRACT_ROOM_UNPUBLISH_E,JSON.stringify({status:_e.FAILED,code:ae.PARAMS_ERROR,msg:"params error -> tracks"})),{code:ae.PARAMS_ERROR};r.info(le.L_ABSTRACT_ROOM_UNPUBLISH_T,JSON.stringify({trackIds:s.map(Li)}));const o=yield this.__unpublish(e,t,i,s);return yield this._dealUnpublishRes(e,t,o)}))}}class aa extends No{constructor(e){super(),Object.defineProperty(this,"localTrack",{enumerable:!0,configurable:!0,writable:!0,value:e})}get kind(){return po.LOCAL_TRACK_MUTE}execute(e,t,i){return m(this,void 0,void 0,(function*(){const{logger:i,context:r}=e,{localTrack:n}=this,s=n.getTrackId(),{crtUserId:o,roomId:a}=t,l=!n.isLocalMuted(),_=i.createTraceId();i.info(le.L_LOCAL_TRACK_SET_LOCAL_MUTED_SPREAD_T,JSON.stringify({enabled:l,trackId:this.localTrack.getTrackId()}),_);const c=[{resourceId:s,enabled:l}],d=t.getResourcesByUserId(o),u=[];for(const e of d){const t=li(e),i=c.findIndex((e=>e.resourceId===t));if(i>=0){const{enabled:t}=c[i];e.state=t?1:0,u.push(e);break}}const h=yield r.setRTCTotalRes(a,[ii(vi.MODIFY,u)],ri(d),vi.TOTAL_CONTENT_RESOURCE);return h!==oe.SUCCESS?(i.error(le.L_LOCAL_TRACK_SET_LOCAL_MUTED_SPREAD_R,JSON.stringify({status:_e.FAILED,code:h,msg:"signal error"}),_),{code:h}):(i.info(le.L_LOCAL_TRACK_SET_LOCAL_MUTED_SPREAD_R,JSON.stringify({status:_e.SUCCESSED}),_),{code:ae.SUCCESS})}))}}class la extends No{get kind(){return po.RETRY_EXCHANGE}get priority(){return fo.HIGH}execute(e,t,i){return m(this,void 0,void 0,(function*(){const{logger:r,peer:n,context:s}=e,o=r.createTraceId();r.info(le.L_RETRY_EXCHANGE_COMMAND_T);const a=s.getCurrentId(),l=t.getSubscribedList(),_=yield Ko(l,!0,n,t,s);_.pushOtherRooms=e.getPushOtherRooms();const c=yield new jo(_,o).execute(e,t,i);if(c.code!==ae.SUCCESS)return{code:c.code};const{sdp:d,resultCode:u}=c.data.data;if(u!==ae.SUCCESS)return{code:u};n.clearReTryExchangeTimer();const h=yield n.setRemoteAnswer(d.sdp);if(h!==ae.SUCCESS)return{code:h};const g=c.data.data.publishList||[],{plus:p,minus:f}=this._diffPublishListChange(g,t,n,a);return(p.length||f.length)&&(yield this._spreadPublishListUri(e,a,p,f,o)),{code:ae.SUCCESS}}))}_diffPublishListChange(e,t,i,r){const n=t.getResourcesByUserId(r);let s=JSON.parse(JSON.stringify(n));e.forEach((e=>{var t;const{mediaType:r,msid:n}=e,o=s.findIndex((e=>{const{mediaType:t,msid:i}=e;return r===t&&n===i}));if(-1===o){const r=Object.assign({tag:n.split("_").pop(),state:(null===(t=i.getLocalTrack(li(e)))||void 0===t?void 0:t.isLocalMuted)?0:1},e);s.push(r)}else s[o].uri=e.uri}));const{publishedList:o,unpublishedList:a}=ui(n,s,!0);return t.setResourcesByUserId(r,s),{plus:o,minus:a}}_spreadPublishListUri(e,t,i,r,n){return m(this,void 0,void 0,(function*(){const{store:s,logger:o}=e,a=s.getResourcesByUserId(t);o.info(le.L_RETRY_EXCHANGE_SPREAD_T,JSON.stringify({plus:i,minus:r,allPublishList:a}),n);const l=[];r.length&&l.push(ii(vi.UNPUBLISH,r)),i.length&&l.push(ii(vi.PUBLISH,i));(yield e.context.setRTCTotalRes(s.roomId,l,ri(a),vi.TOTAL_CONTENT_RESOURCE))===oe.SUCCESS?o.info(le.L_RETRY_EXCHANGE_SPREAD_R,`status: ${_e.SUCCESSED}`,n):o.error(le.L_RETRY_EXCHANGE_SPREAD_R,`status: ${_e.FAILED}`,n)}))}}var _a;!function(e){e[e.JOIN=0]="JOIN",e[e.LEAVE=1]="LEAVE",e[e.OFFLINE=2]="OFFLINE",e[e.RESOURCECHANGE=3]="RESOURCECHANGE"}(_a||(_a={}));class ca extends No{constructor(e,t,i,r){super(),Object.defineProperty(this,"_roomId",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_traceId",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_targetPullVersion",{enumerable:!0,configurable:!0,writable:!0,value:r})}get kind(){return po.PULL_RTCROOM_STATUS}execute(e,t,i){return m(this,void 0,void 0,(function*(){const{logger:r}=e,n=t.getRoomStatusVersion();if(r.info(le.L_PULL_ROOM_STATUS_T,JSON.stringify({roomId:this._roomId,localVersion:n}),this._traceId),this._targetPullVersion&&this._targetPullVersion<=n)return r.info(le.L_PULL_ROOM_STATUS_R,JSON.stringify({status:_e.SUCCESSED,msg:"the roomData has been pulled",localVersion:n,targetPullVersion:this._targetPullVersion}),this._traceId),{code:oe.SUCCESS};const{code:s,data:o}=yield this._context.pullRTCRoomStatus(this._roomId,n);if(s!==oe.SUCCESS)return r.info(le.L_PULL_ROOM_STATUS_R,JSON.stringify({status:_e.FAILED,code:s}),this._traceId),{code:s};const{bFullStatus:a,version:l,usersData:_,roomStatus:c}=o;if(r.info(le.L_PULL_ROOM_STATUS_R,JSON.stringify({bFullStatus:a,version:Oi(l),usersData:_,roomStatus:c}),this._traceId),t.setRoomStatusVersion(l),a){const{urisData:r,CDNUris:n}=function(e){const t={users:{}};let i="";return e.forEach((e=>{var r,n;const{userId:s,userData:o}=e;t.users[s]={};const a=null===(r=o.filter((e=>"uris"===e.key))[0])||void 0===r?void 0:r.value,l=null===(n=o.filter((e=>"cdn_uris"===e.key))[0])||void 0===n?void 0:n.value;i=l||i,t.users[s]={uris:a}})),{urisData:t,CDNUris:i&&JSON.stringify(JSON.parse(i)[0])}}(_);return yield zo(r,t,e,i,n,this._traceId),{code:s}}for(const r of c)if(r.event===_a.RESOURCECHANGE){const n=Xo(r);if(!n)continue;const{content:s,userId:o}=n;if(o===t.crtUserId)continue;yield new ra(s,vi.TOTAL_CONTENT_RESOURCE,o,this._traceId).execute(e,t,i)}else{const n=Zo(r),{data:s}=yield new ia(n,this._traceId).execute(e,t,i);e.emit(ko.USER_STATE_CHANGE,s)}return{code:s}}))}}class da extends No{constructor(e){super(),Object.defineProperty(this,"livingType",{enumerable:!0,configurable:!0,writable:!0,value:e})}get kind(){return po.ON_SIGNAL_RECONNECTED}get priority(){return fo.HIGH}execute(e,t,i){return m(this,void 0,void 0,(function*(){const{logger:r,peer:n,context:s}=e,{roomId:o,roomMode:a}=t,l=r.createTraceId();if(r.info(le.L_ABSTRACT_ROOM_IM_RECONNECTED_T,void 0,l),"closed"===n.getRTCPeerConn().connectionState)return r.error(le.L_ABSTRACT_ROOM_IM_RECONNECTED_R,"RTCPeerConnection closed. Please rejoin room to restore services",l),e.emit(ko.PEER_CONNECTION_CLOSED_BY_EXCEPTION),{code:ae.SUCCESS};const{code:_}=yield s.rtcPing(o,a);if(40001===_){(yield this._joinRoom(e,t,i,l))===oe.SUCCESS&&(yield this._restoreMediaServer(e,t,i))}else yield new ca(o,l,s).execute(e,t,i);return{code:ae.SUCCESS}}))}_joinRoom(e,t,i,r){return m(this,void 0,void 0,(function*(){var n,s,o,a;const{context:l,logger:_}=e,{code:c,data:d}=yield l.joinRTCRoom(t.roomId,t.roomMode,this.livingType);if(c!==oe.SUCCESS)return void _.error(le.L_ABSTRACT_ROOM_IM_RECONNECTED_R,JSON.stringify({status:_e.FAILED,code:c,msg:"im reconnect joinRTCRoom failed"}),r);if(!d)return void _.info(le.L_ABSTRACT_ROOM_IM_RECONNECTED_R,JSON.stringify({status:_e.FAILED,msg:"im reconnect joinRTCRoom, roomData is empty"}),r);const u=null===(n=d.roomInfo.filter((e=>"cdn_uris"===e.key))[0])||void 0===n?void 0:n.value;yield zo(d,t,e,i,u,r);const h=null===(s=d.roomInfo.filter((e=>"asr_status"===e.key))[0])||void 0===s?void 0:s.value;h&&t.setASRStatus(h);const g=null===(o=d.roomInfo.filter((e=>"sei_ai_uris"===e.key))[0])||void 0===o?void 0:o.value,p=t.getASRIsAvailable();if(g){const i=JSON.parse(g);if(i.length){p||e.emit(ko.ASR_SEI_PUBLISH),t.setASRSeiUris(i);const{msid:r,mediaType:n}=i[0],s=`${r}_${n}`;!t.getRemoteTrack(s)&&t.addSeiRemoteTrack(i)}else p&&e.emit(ko.ASR_SEI_UNPUBLISH),t.removeSeiRemoteTrack(),t.setASRSeiUris(i)}const f=null===(a=d.roomInfo.filter((e=>"summarization"===e.key))[0])||void 0===a?void 0:a.value;if(f){const i=JSON.parse(f),r=t.getSummarizationStatusData();r&&r.status!==i.status&&e.emit(i.status===Hs.OPEN?ko.SUMMARIZATION_START:ko.SUMMARIZATION_STOP,i.taskId),t.setSummarizationStatusData(i)}return _.info(le.L_ABSTRACT_ROOM_IM_RECONNECTED_R,JSON.stringify({status:_e.SUCCESSED,roomData:d}),r),c}))}_restoreMediaServer(e,t,i){return m(this,void 0,void 0,(function*(){const r=e.peer.getLocalTracks(),n=Object.values(t.getRemoteTracks()).filter((e=>!!e.isSubscribed()));r.length&&(yield new sa(r).execute(e,t,i)),!r.length&&n.length&&(yield new na(n,!0).execute(e,t,i))}))}}const ua=1,ha=5;var ga,pa,fa,Ea,Ia,Ta,ma,Ra;!function(e){e[e.new=0]="new",e[e.checking=1]="checking",e[e.connected=2]="connected",e[e.completed=3]="completed",e[e.failed=4]="failed",e[e.disconnected=5]="disconnected",e[e.closed=6]="closed"}(ga||(ga={})),function(e){e[e.SERVER_KICK=1]="SERVER_KICK",e[e.OTHER_KICK=2]="OTHER_KICK",e[e.IM_DISCONNECTED=3]="IM_DISCONNECTED",e[e.IM_LOGOUT=4]="IM_LOGOUT",e[e.OTHER_CLIENT_IM_CONNECTED=5]="OTHER_CLIENT_IM_CONNECTED"}(pa||(pa={}));class Sa{constructor(e,t,i,r){Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_roomId",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_clientSessionId",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_userId",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_baseReportData",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_networkReportData",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_pubOrSubSuccessTime",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_peerCStatus",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"reportQualityJoinRoomData",{enumerable:!0,configurable:!0,writable:!0,value:(e,t,i,r)=>{this._baseReportData=Object.assign(this._baseReportData,{snid:r});const n=Object.assign(Object.assign(Object.assign({},this._baseReportData),this._networkReportData),{cod:t,time:e,dur:Date.now()-e,rtp:i});this._logger.__statistics(le.L_QS_JOIN_ROOM_S,JSON.stringify(n))}}),this._baseReportData={rid:this._roomId,csnid:this._clientSessionId,snid:"",time:Date.now(),uid:this._userId},this._networkReportData={cr:"unknown",net:"unknown"}}reportQualityKickedData(e){const t=Object.assign(Object.assign(Object.assign({},this._baseReportData),this._networkReportData),{time:Date.now(),cod:e===pa.OTHER_KICK?ha:ua});this._logger.__statistics(le.L_QS_KICKED_S,JSON.stringify(t))}reportPubOrSubQualityData(e,t,i,r,n,s){i.forEach((i=>{var o,a;const l=i instanceof jt||i instanceof Zt?i:i.track,_=l.getTrackId(),{mediaType:c}=_i(_);let d=!1;d=l instanceof jt?!!l.isVideoTrack()&&(null===(a=(o=l).__isTiny)||void 0===a?void 0:a.call(o)):i.subTiny||!1;const u=Object.assign(Object.assign(Object.assign({},this._baseReportData),this._networkReportData),{resid:_,mtp:c,smct:d?Ys.TINY:Ys.NORMAL,stp:"Rongcloud"!==l.getTag()?1:0,cod:r,msas:n?n[_]:[],sigs:s,time:Date.now(),dur:Date.now()-t});switch(e){case"pub":this._logger.__statistics(le.L_QS_PUBLISH_S,JSON.stringify(u));break;case"unpub":this._logger.__statistics(le.L_QS_UNPUBLISH_S,JSON.stringify(u));break;case"sub":this._logger.__statistics(le.L_QS_SUBSCRIBE_S,JSON.stringify(u));break;case"unsub":this._logger.__statistics(le.L_QS_UNSUBSCRIBE_S,JSON.stringify(u))}}))}reportQualityRecvPubMsgData(e,t){const i=Object.assign(Object.assign(Object.assign({},this._baseReportData),this._networkReportData),{puid:t,time:Date.now(),dur:Date.now()-e});this._logger.__statistics(le.L_QS_RECV_PUB_MSG_S,JSON.stringify(i))}setPubOrSubSuccessTime(e){this._pubOrSubSuccessTime=e}reportIceFirstConnectData(e){const t=Object.assign(Object.assign(Object.assign({},this._baseReportData),this._networkReportData),{time:this._pubOrSubSuccessTime,dur:Date.now()-this._pubOrSubSuccessTime}),i="pub"===e?le.L_QS_PUB_ICE_STATUS_S:le.L_QS_SUB_ICE_STATUS_S;this._logger.__statistics(i,JSON.stringify(t))}recordQualityIceStatusData(e,t,i){const{status:r,time:n}=this._peerCStatus||{};if(!n)return void(this._peerCStatus={status:t,time:i});const{IP:s,port:o,networkType:a,remoteIP:l,remotePort:_}=e,c=Object.assign(Object.assign(Object.assign({},this._baseReportData),this._networkReportData),{dur:i-n,time:i,pices:ga[r],ices:ga[t],rcdts:[{ip:`${l}:${_}`}],lcdts:[{ip:`${s}:${o}`,nttp:a}],cncdts:[]});this._logger.__statistics(le.L_QS_ICE_STATUS_S,JSON.stringify(c)),this._peerCStatus={status:t,time:i}}}!function(e){e[e.DISABLE=0]="DISABLE",e[e.ENABLE=1]="ENABLE"}(fa||(fa={})),function(e){e[e.MeetingOrAnchor=1]="MeetingOrAnchor",e[e.Audience=2]="Audience"}(Ea||(Ea={})),function(e){e[e.NOT_REPORT=-1]="NOT_REPORT",e[e.REPORT_SUCCESS=1e4]="REPORT_SUCCESS",e[e.REPORT_FAIL=0]="REPORT_FAIL",e[e.PB_ERROR=40001]="PB_ERROR"}(Ia||(Ia={})),function(e){e.R1="R1",e.R2="R2",e.R3="R3",e.R4="R4"}(Ta||(Ta={}));class Ca{constructor(e,t,i,r,n=Ea.MeetingOrAnchor){Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_runtime",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_roomId",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_crtRTCRoom",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_userRole",{enumerable:!0,configurable:!0,writable:!0,value:n})}_send(e){return m(this,void 0,void 0,(function*(){if(this._context.getConnectionStatus()!==l.CONNECTED)return Ia.NOT_REPORT;return(yield this._context.setRTCState(this._roomId,e))===oe.SUCCESS?Ia.REPORT_SUCCESS:Ia.REPORT_FAIL}))}_getClientID(){const e="uuid";let t=this._runtime.localStorage.getItem(e);return t||(t=hi(),this._runtime.localStorage.setItem(e,t)),t}_getRealResourceId(e){let t=e;const i=e.indexOf("_tiny");return i>-1&&(t=e.slice(0,i)),t}_getPolarisTrackId(e){let t="";const i=e.split("_");if(e.includes("_tiny")){const e=i.pop(),r=parseInt(i.pop())===vt.AUDIO_ONLY?"audio":"video",n=i.pop();t=[i.join("_"),n,e,r].join("_")}else{const e=parseInt(i.pop())===vt.AUDIO_ONLY?"audio":"video",r=i.pop();t=[i.join("_"),r,e].join("_")}return t}_getBaseData(e){return{bitrateSend:(null==e?void 0:e.bitrateSend)||Bs,bitrateRecv:(null==e?void 0:e.bitrateRecv)||Bs,networkType:(null==e?void 0:e.networkType)||"unknown",rtt:(null==e?void 0:e.rtt)||Bs,localAddress:`${(null==e?void 0:e.IP)||Bs}:${null==e?void 0:e.port}`,remoteAddress:`${null==e?void 0:e.remoteIP}:${null==e?void 0:e.remotePort}`,receiveBand:(null==e?void 0:e.availableIncomingBitrate)||Bs,sendBand:(null==e?void 0:e.availableOutgoingBitrate)||Bs,packetsLost:(null==e?void 0:e.totalPacketsLost)||Bs,deviceId:this._context.getCurrentId()}}_getAudioLevel(e){return e||0===e?e:Bs}_getBitrate(e){return e||0===e?e:Bs}_getPacketsLostRate(e){return e||0===e?e:Bs}_getFrameRate(e){return e||Bs}_getResolution(e,t){return e&&t?`${e} * ${t}`:"-1"}_getJitter(e){return e||Bs}_getNackCount(e){return e||0===e?e:Bs}_getPliCount(e){return e||0===e?e:Bs}_getRTT(e){return e||Bs}_getTrackState(e,t){const i=e?this._crtRTCRoom.getLocalTrack(t):this._crtRTCRoom.getRemoteTrack(t);return(null==i?void 0:i.isLocalMuted())?fa.DISABLE:fa.ENABLE}sendR3Data(e){return m(this,void 0,void 0,(function*(){const{iceCandidatePair:t,senders:i}=e,r=this._getBaseData(t);let n=`R3\t${r.bitrateSend}\t-1\t-1\t-1\t${r.networkType}\t${r.rtt}\t${r.localAddress}\t${r.receiveBand}\t${r.sendBand}\t${r.packetsLost}\t${r.deviceId}\r`;n+=i.map((e=>{const{trackId:t,audioLevel:i,samplingRate:r,bitrate:n,packetsLostRate:s,frameRate:o,frameWidth:a,frameHeight:l,googRenderDelayMs:_,jitter:c,nackCount:d,pliCount:u,rtt:h,googFirsSent:g,encoderImplementation:p}=e,f=this._getPolarisTrackId(t),E=this._getRealResourceId(t);return{trackId:f,googCodecName:p||String(Bs),audioLevel:this._getAudioLevel(i),bitrate:this._getBitrate(n),packetsLostRate:this._getPacketsLostRate(s),frameRate:this._getFrameRate(o),resolution:this._getResolution(a,l),jitter:this._getJitter(c),nackCount:this._getNackCount(d),pliCount:this._getPliCount(u),rtt:this._getRTT(h),googFirsSent:g,samplingRate:r,googRenderDelayMs:_,encoderImplementation:p||String(Bs),trackState:this._getTrackState(!0,E)}})).map((e=>`${e.trackId}\t${e.googCodecName}\t${e.audioLevel}\t${e.samplingRate}\t${e.bitrate}\t${e.packetsLostRate}\t${e.frameRate}\t${e.resolution}\t${e.googRenderDelayMs}\t${e.jitter}\t${e.nackCount}\t${e.pliCount}\t${e.rtt}\t${e.googFirsSent}\t${e.encoderImplementation}\t${e.trackState}`)).join("\n");return(yield this._send(`${n}\r${this._userRole}`))!==Ia.REPORT_SUCCESS?Ia.REPORT_FAIL:Ia.REPORT_SUCCESS}))}sendR4Data(e){return m(this,void 0,void 0,(function*(){const{iceCandidatePair:t,receivers:i}=e,r=this._getBaseData(t);let n=`R4\t${r.bitrateRecv}\t-1\t-1\t-1\t${r.networkType}\t${r.rtt}\t${r.localAddress}\t${r.receiveBand}\t${r.sendBand}\t${r.packetsLost}\t${r.deviceId}\r`;n+=i.filter((e=>!!e.trackId)).map((e=>{const{trackId:t,audioLevel:i,samplingRate:r,bitrate:n,packetsLostRate:s,frameRate:o,frameWidth:a,frameHeight:l,googRenderDelayMs:_,jitter:c,nackCount:d,pliCount:u,rtt:h,googFirsReceived:g,codecImplementationName:p}=e,f=this._getPolarisTrackId(t),E=this._getRealResourceId(t);return{trackId:f,googCodecName:p||String(Bs),audioLevel:this._getAudioLevel(i),bitrate:this._getBitrate(n),packetsLostRate:this._getPacketsLostRate(s),frameRate:this._getFrameRate(o),resolution:this._getResolution(a,l),jitter:this._getJitter(c),nackCount:this._getNackCount(d),pliCount:this._getPliCount(u),rtt:this._getRTT(h),googFirsReceived:g,samplingRate:r,googRenderDelayMs:_,codecImplementationName:p||String(Bs),trackState:this._getTrackState(!1,E)}})).map((e=>`${e.trackId}\t${e.googCodecName}\t${e.audioLevel}\t${e.samplingRate}\t${e.bitrate}\t${e.packetsLostRate}\t${e.frameRate}\t${e.resolution}\t${e.googRenderDelayMs}\t${e.jitter}\t${e.nackCount}\t${e.pliCount}\t${e.rtt}\t${e.googFirsReceived}\t${e.codecImplementationName}\t${e.trackState}`)).join("\n");return(yield this._send(`${n}\r${this._userRole}`))!==Ia.REPORT_SUCCESS?Ia.REPORT_FAIL:Ia.REPORT_SUCCESS}))}sendR1(){var e;const t=this._context.getCoreVersion(),i=(null===(e=navigator.userAgentData)||void 0===e?void 0:e.platformn)||navigator.platform,r=`R1\t26.2.0-alpha.2\t${t}\tweb\t${i}\t-1\t${Ii.browser}\t${Ii.version}\t${this._getClientID()}\t${this._userRole}`;this._send(r)}sendR2(e,t,i){const r=`R2\t${e}\t${t}\t${this._getClientID()}\r${i.join("\t")}\r${this._userRole}`;this._send(r)}}class La extends No{constructor(e,t){super(),Object.defineProperty(this,"oldTrack",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"newTrack",{enumerable:!0,configurable:!0,writable:!0,value:t})}execute(e,t,i){return m(this,void 0,void 0,(function*(){const{peer:r,logger:n}=e;if(!this.oldTrack||!this.newTrack)return n.error(le.L_RTC_CLIENT_CHANGE_MEDIA_DEVICE_R,"oldTrack or newTrack is empty"),{code:ae.PARAMS_ERROR};if([Wt,qt].every((e=>!(this.oldTrack instanceof e))))return n.error(le.L_RTC_CLIENT_CHANGE_MEDIA_DEVICE_R,"oldTrack is not RCCameraVideoTrack or RCMicphoneAudioTrack"),{code:ae.PARAMS_ERROR};if([Wt,qt].every((e=>!(this.newTrack instanceof e))))return n.error(le.L_RTC_CLIENT_CHANGE_MEDIA_DEVICE_R,"newTrack is not RCCameraVideoTrack or RCMicphoneAudioTrack"),{code:ae.PARAMS_ERROR};const s=this.oldTrack.getSettings(),o=this.newTrack.getSettings(),a=this.oldTrack.getTrackId(),l=this.newTrack.getTrackId(),_=this.oldTrack.isAudioTrack()?"audio":"video",c=this.newTrack.isAudioTrack()?"audio":"video";if(n.info(le.L_RTC_CLIENT_CHANGE_MEDIA_DEVICE_T,JSON.stringify({oldTrackId:a,newTrackId:l,oldSettings:s,newSettings:o})),!this.oldTrack.isPublished())return n.error(le.L_RTC_CLIENT_CHANGE_MEDIA_DEVICE_R,"oldTrack is not published"),{code:ae.PARAMS_ERROR};if(a!==l)return n.error(le.L_RTC_CLIENT_CHANGE_MEDIA_DEVICE_R,`oldTrack and newTrack trackId are different, oldTrackId: ${a}, newTrackId: ${l}`),{code:ae.PARAMS_ERROR};if(_!==c)return n.error(le.L_RTC_CLIENT_CHANGE_MEDIA_DEVICE_R,`oldTrack and newTrack are not the same kind, oldTrackKind: ${_}, newTrackKind: ${c}`),{code:ae.PARAMS_ERROR};if((null==s?void 0:s.deviceId)===(null==o?void 0:o.deviceId))return n.error(le.L_RTC_CLIENT_CHANGE_MEDIA_DEVICE_R,`oldTrack and newTrack deviceId are the same, oldDeviceId: ${null==s?void 0:s.deviceId}, newDeviceId: ${null==o?void 0:o.deviceId}`),{code:ae.PARAMS_ERROR};r.addLocalTrack(this.newTrack);const d=(null==s?void 0:s.width)!==(null==o?void 0:o.width)||(null==s?void 0:s.height)!==(null==o?void 0:o.height)||(null==s?void 0:s.frameRate)!==(null==o?void 0:o.frameRate),u=r.getLocalTrack(`${this.oldTrack.getTrackId()}_tiny`);if(!d)return u&&u.destroy(),this.oldTrack.destroy(!1),this.newTrack.__innerSetPublished(!0),n.info(le.L_RTC_CLIENT_CHANGE_MEDIA_DEVICE_R,"changeMediaDevice success"),{code:ae.SUCCESS};const h=yield(new la).execute(e,t,i);return h.code!==ae.SUCCESS?(r.removeLocalTrack(this.newTrack,!1),r.addLocalTrack(this.oldTrack),this.newTrack.destroy(),n.error(le.L_RTC_CLIENT_CHANGE_MEDIA_DEVICE_R,`negotiation failed, code: ${h.code}`),{code:h.code}):(u&&u.destroy(),this.oldTrack.destroy(!1),this.newTrack.__innerSetPublished(!0),n.info(le.L_RTC_CLIENT_CHANGE_MEDIA_DEVICE_R,"changeMediaDevice success"),{code:h.code})}))}}!function(e){e[e.OPEN=1]="OPEN",e[e.CLOSE=0]="CLOSE"}(ma||(ma={}));class Oa extends No{constructor(e){super(),Object.defineProperty(this,"_type",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_traceId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}execute(e,t,i){return m(this,void 0,void 0,(function*(){const{logger:i,context:r,service:n}=e;this._traceId=i.createTraceId(),this._logger=i,this._logger.info(le.L_ABSTRACT_ROOM_OPERATE_ASR_STATUS_T,`type: ${this._type}`,this._traceId);const s=r.getNaviInfo();if((null==s?void 0:s.rtcAISwitch)===ma.CLOSE)return this._logger.error(le.L_ABSTRACT_ROOM_OPERATE_ASR_STATUS_R,JSON.stringify({code:ae.ASR_NOT_AVAILABLE}),this._traceId),{code:ae.ASR_NOT_AVAILABLE};if(this._type===t.getASRStatus())return this._logger.info(le.L_ABSTRACT_ROOM_OPERATE_ASR_STATUS_R,JSON.stringify({code:ae.SUCCESS}),this._traceId),{code:ae.SUCCESS};const{roomId:o}=t,a=yield r.setRTCData(o,"asr_status",this._type.toString(),!0,mo.ROOM,{name:vi.ASR_STATUS,content:JSON.stringify({asr_status:this._type.toString()})});if(a!==oe.SUCCESS)return this._logger.error(le.L_ABSTRACT_ROOM_OPERATE_ASR_STATUS_R,JSON.stringify({code:a}),this._traceId),{code:ae.SIGNAL_ERROR};t.setASRStatus(this._type);const l=yield n.updateASRStatus(t.getRTCRequestHeader(),{asr_status:this._type},this._traceId),{code:_,data:c}=l;if(_!==ae.SUCCESS||(null==c?void 0:c.resultCode)!==ae.SUCCESS&&42200!==(null==c?void 0:c.resultCode)){const e=_!==ae.SUCCESS?_:null==c?void 0:c.resultCode;return this._logger.error(le.L_ABSTRACT_ROOM_OPERATE_ASR_STATUS_R,JSON.stringify({code:e}),this._traceId),{code:e}}return this._logger.info(le.L_ABSTRACT_ROOM_OPERATE_ASR_STATUS_R,JSON.stringify({code:ae.SUCCESS}),this._traceId),{code:ae.SUCCESS}}))}}class va extends No{constructor(e){super(),Object.defineProperty(this,"_enable",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_traceId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}_updateSubSei(e,t,i,r){const n=`${e[0].msid}_${e[0].mediaType}`,s=i.getRemoteTrack(n);return this._enable?new na([s]).execute(t,i,r):new Jo([s],this._traceId).execute(t,i,r)}execute(e,t,i){return m(this,void 0,void 0,(function*(){const{logger:r,context:n}=e;this._traceId=r.createTraceId(),this._logger=r,this._logger.info(le.L_ABSTRACT_ROOM_SET_ENABLE_ASR_T,`enable: ${this._enable}`,this._traceId),t.setASREnable(this._enable);const s=n.getNaviInfo();if((null==s?void 0:s.rtcAISwitch)===ma.CLOSE)return this._logger.error(le.L_ABSTRACT_ROOM_SET_ENABLE_ASR_R,JSON.stringify({code:ae.ASR_NOT_AVAILABLE}),this._traceId),{code:ae.ASR_NOT_AVAILABLE};const o=t.getASRSeiUris();if(!o.length)return this._logger.info(le.L_ABSTRACT_ROOM_SET_ENABLE_ASR_R,JSON.stringify({code:ae.SUCCESS,asrSeiUrisLength:0}),this._traceId),{code:ae.SUCCESS};const{code:a}=yield this._updateSubSei(o,e,t,i);return a!==ae.SUCCESS?(this._logger.error(le.L_ABSTRACT_ROOM_SET_ENABLE_ASR_R,JSON.stringify({code:a}),this._traceId),{code:a}):(this._logger.info(le.L_ABSTRACT_ROOM_SET_ENABLE_ASR_R,JSON.stringify({code:ae.SUCCESS}),this._traceId),{code:ae.SUCCESS})}))}}!function(e){e[e.OPEN=1]="OPEN",e[e.CLOSE=0]="CLOSE"}(Ra||(Ra={}));class ba extends No{constructor(e,t){super(),Object.defineProperty(this,"_status",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_destLanguage",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_traceId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}_operateWithRetry(e,t){return m(this,arguments,void 0,(function*(e,t,i=3,r=3e3){for(let n=1;n<=i;n++){try{const{code:i,data:r}=yield t.operateRealtimeTranslation(e.getRTCRequestHeader(),{status:this._status},this._traceId);if(i===ae.SUCCESS)return;console.warn(`第 ${n} 次调用失败,code=${i}`)}catch(e){console.error(`第 ${n} 次调用异常:`,e)}n<i&&(yield new Promise((e=>{setTimeout(e,r)})))}}))}execute(e,t,i){return m(this,void 0,void 0,(function*(){const{logger:i,service:r,context:n}=e;this._traceId=i.createTraceId(),this._logger=i,this._logger.info(le.L_ABSTRACT_ROOM_OPERATE_REALTIME_TRANSLATION_T,JSON.stringify({status:this._status,destLanguage:this._destLanguage}),this._traceId);const s=n.getNaviInfo();if((null==s?void 0:s.rtcAISwitch)===ma.CLOSE)return this._logger.error(le.L_ABSTRACT_ROOM_OPERATE_REALTIME_TRANSLATION_R,JSON.stringify({code:ae.ASR_NOT_AVAILABLE}),this._traceId),{code:ae.ASR_NOT_AVAILABLE};if(this._status===Ra.OPEN){if(!this._destLanguage)return this._logger.error(le.L_ABSTRACT_ROOM_OPERATE_REALTIME_TRANSLATION_R,JSON.stringify({code:ae.PARAMS_ERROR}),this._traceId),{code:ae.PARAMS_ERROR};if(!t.getASRSeiUris().length)return this._logger.error(le.L_ABSTRACT_ROOM_OPERATE_REALTIME_TRANSLATION_R,JSON.stringify({code:ae.ASR_NOT_START}),this._traceId),{code:ae.ASR_NOT_START}}const o={status:this._status};this._destLanguage&&(o.destLanguage=this._destLanguage);const{code:a,data:l}=yield r.operateRealtimeTranslation(t.getRTCRequestHeader(),o,this._traceId);if(this._status===Ra.CLOSE)return t.setIsStartRealTranslate(!1),this._logger.info(le.L_ABSTRACT_ROOM_OPERATE_REALTIME_TRANSLATION_R,JSON.stringify({code:ae.SUCCESS}),this._traceId),a!==ae.SUCCESS&&this._operateWithRetry(t,r),{code:ae.SUCCESS};if(a!==ae.SUCCESS||(null==l?void 0:l.resultCode)!==ae.SUCCESS){const e=a!==ae.SUCCESS?a:null==l?void 0:l.resultCode;return this._logger.error(le.L_ABSTRACT_ROOM_OPERATE_REALTIME_TRANSLATION_R,JSON.stringify({code:e}),this._traceId),{code:e}}return t.setIsStartRealTranslate(!0),this._destLanguage&&t.setTranslationLang(this._destLanguage),this._logger.info(le.L_ABSTRACT_ROOM_OPERATE_REALTIME_TRANSLATION_R,JSON.stringify({code:ae.SUCCESS}),this._traceId),{code:ae.SUCCESS}}))}}class Aa extends No{constructor(e){super(),Object.defineProperty(this,"_type",{enumerable:!0,configurable:!0,writable:!0,value:e})}execute(e,t){return m(this,void 0,void 0,(function*(){return t.setASRStatus(this._type),{code:ae.SUCCESS}}))}}class Na extends No{constructor(e){super(),Object.defineProperty(this,"_asrSeiUris",{enumerable:!0,configurable:!0,writable:!0,value:e})}_setEnableAsr(e,t,i){return m(this,void 0,void 0,(function*(){const r=t.getASREnable();r&&(yield new va(this._asrSeiUris.length>0).execute(e,t,i),t.setASREnable(r))}))}_onPublish(e,t,i){e.emit(ko.ASR_SEI_PUBLISH),t.setASRSeiUris(this._asrSeiUris),t.addSeiRemoteTrack(this._asrSeiUris),this._setEnableAsr(e,t,i)}_onUnPublish(e,t,i){return m(this,void 0,void 0,(function*(){e.emit(ko.ASR_SEI_UNPUBLISH),yield this._setEnableAsr(e,t,i),t.removeSeiRemoteTrack(),t.setASRSeiUris(this._asrSeiUris)}))}execute(e,t,i){return m(this,void 0,void 0,(function*(){return this._asrSeiUris.length?this._onPublish(e,t,i):this._onUnPublish(e,t,i),{code:ae.SUCCESS}}))}}class ya extends No{constructor(e){super(),Object.defineProperty(this,"_isStart",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_traceId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}execute(e,t,i){return m(this,void 0,void 0,(function*(){var i,r;const{logger:n,context:s,service:o}=e;this._traceId=n.createTraceId(),this._logger=n,this._logger.info(le.L_ABSTRACT_ROOM_OPERATE_SUMMARIZATION_T,`isStart: ${this._isStart}`,this._traceId);const a=s.getNaviInfo();if((null==a?void 0:a.rtcAISwitch)===ma.CLOSE)return this._logger.error(le.L_ABSTRACT_ROOM_OPERATE_SUMMARIZATION_R,JSON.stringify({code:ae.ASR_NOT_AVAILABLE}),this._traceId),{code:ae.ASR_NOT_AVAILABLE};if(!t.getASRSeiUris().length)return this._logger.error(le.L_ABSTRACT_ROOM_OPERATE_REALTIME_TRANSLATION_R,JSON.stringify({code:ae.ASR_NOT_START}),this._traceId),{code:ae.ASR_NOT_START};if((null===(i=t.getSummarizationStatusData())||void 0===i?void 0:i.status)===Hs.OPEN&&this._isStart||(null===(r=t.getSummarizationStatusData())||void 0===r?void 0:r.status)===Hs.CLOSE&&!this._isStart)return this._logger.info(le.L_ABSTRACT_ROOM_OPERATE_SUMMARIZATION_R,JSON.stringify({isStart:this._isStart,code:ae.SUCCESS,taskId:t.getSummarizationStatusData().taskId}),this._traceId),{code:ae.SUCCESS,taskId:t.getSummarizationStatusData().taskId};const l={status:this._isStart?Hs.OPEN:Hs.CLOSE},{code:_,data:c}=yield o.operateSummarization(t.getRTCRequestHeader(),l,this._traceId);return _!==ae.SUCCESS?(this._logger.error(le.L_ABSTRACT_ROOM_OPERATE_SUMMARIZATION_R,JSON.stringify({isStart:this._isStart,code:_}),this._traceId),{code:_}):(t.setSummarizationStatusData({taskId:c.taskId,status:this._isStart?Hs.OPEN:Hs.CLOSE}),this._logger.info(le.L_ABSTRACT_ROOM_OPERATE_SUMMARIZATION_R,JSON.stringify({isStart:this._isStart,code:ae.SUCCESS,taskId:null==c?void 0:c.taskId}),this._traceId),{code:ae.SUCCESS,taskId:null==c?void 0:c.taskId})}))}}class Pa extends No{constructor(e,t){super(),Object.defineProperty(this,"_status",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_taskId",{enumerable:!0,configurable:!0,writable:!0,value:t})}execute(e,t){return m(this,void 0,void 0,(function*(){return t.setSummarizationStatusData({status:this._status,taskId:this._taskId}),e.emit(this._status===Hs.OPEN?ko.SUMMARIZATION_START:ko.SUMMARIZATION_STOP,this._taskId),{code:ae.SUCCESS}}))}}const Ua="evt-leave";class Da extends B{constructor(e,t,i,r,n,s,o,a,l=Gs(),_=!1){super(),Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_runtime",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_roomId",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_service",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"_initOptions",{enumerable:!0,configurable:!0,writable:!0,value:s}),Object.defineProperty(this,"_clientSessionId",{enumerable:!0,configurable:!0,writable:!0,value:l}),Object.defineProperty(this,"_pinger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_polarisReport",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_audioLevelReport",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_peerConnection",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_invoker",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_store",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_reportMediaActionLogger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_executeCtx",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_appListener",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_onRecvPKMsg",{enumerable:!0,configurable:!0,writable:!0,value:null});const c=this._logger=this._context.logger;this._reportMediaActionLogger=new Sa(c,this._roomId,this._clientSessionId,this._context.getCurrentId()),this._polarisReport=new Ca(this._context,this._runtime,this._roomId,this);const d=this._context.getCurrentId(),u=new Do(c,l,this._context.getAppkey(),i,d,r,o,a),h=this._peerConnection=new bo(e,c,this._reTryExchange.bind(this),d,u,this._polarisReport,!1,_);this._setPeerConnectionListener();const g=this._executeCtx=new xo(c,this._service,e,t,h,u,this._polarisReport,this._reportMediaActionLogger);g.getPushOtherRooms=()=>this._getPushOtherRoomsParams(),this.setCommandEventListener(),this._invoker=new Po(g,u),this._store=this._invoker.store,this._audioLevelReport=new Ao(this._store,h),h.on(bo.__INNER_AUDIOLEVEL_CHANGE__,this._audioLevelReport.audioLevelReport,this._audioLevelReport),this._pinger=new Ai(this._context,this._roomId,r,this._initOptions.pingGap),this._pinger.onFailed=this.__kickoff.bind(this),this._pinger.onPingResult=this._handlePingResult.bind(this),this._context.registerRTCSignalListener((e=>m(this,void 0,void 0,(function*(){const{time:t,type:i,roomId:r}=this._context.decodeRtcNotify(e);if(this._invoker.isDestroyed())this._logger.info(le.L_RTCNTF_PULL_ROOM_STATUS_O,JSON.stringify({isDestroyed:!0,type:i,time:t,roomId:r}));else if(2===i&&r===this._roomId){const e=this._logger.createTraceId();this._logger.info(le.L_RTCNTF_PULL_ROOM_STATUS_O,null,e),this._startPullRTCRoomStatus(r,e,t)}}))))}_setPeerConnectionListener(){const e=this._peerConnection;e.on(bo.__INNER_EVENT_TRACK_READY__,this._onTrackReady,this),e.on(jt.__INNER_EVENT_MUTED_CHANGE__,this._onLocalTrackMuted,this),e.on(jt.__INNER_EVENT_DESTROY__,this._onLocalTrackDestroied,this),e.once(bo.__INNER_ICE_CONNECTED__,(e=>{this._reportMediaActionLogger.reportIceFirstConnectData(e?"pub":"sub")}),this),e.on(bo.__INNER_ICE_STATE_CHANGE__,(e=>{const{status:t,time:i,iceCandidatePair:r}=e;r&&this._reportMediaActionLogger.recordQualityIceStatusData(r,t,i)})),e.on(bo.__INNER_SEI_CONTENT__,this._onReceiveAsrSeiContent,this)}setCommandEventListener(){const e=this._executeCtx;e.on(ko.PEER_CONNECTION_CLOSED_BY_EXCEPTION,this._rtcpeerClosed,this),e.on(ko.USER_JOIN,this._callAppListener.bind(this,"onUserJoin"),this),e.on(ko.USER_LEAVE,this._callAppListener.bind(this,"onUserLeave"),this),e.on(ko.TRACKS_PUBLISH,this._onTrackPublish,this),e.on(ko.TRACKS_UNPUBLISH,this._onTrackUnpublish,this),e.on(ko.AUDIO_MUTE_CHANGE,this._onAudioMuteChange,this),e.on(ko.VIDEO_MUTE_CHANGE,this._onVideoMuteChange,this),e.on(ko.CDN_ENABLE_CHANGE,this._callAppListener.bind(this,"onCDNEnableChange"),this),e.on(ko.USER_STATE_CHANGE,this._dealUserAppListener,this),e.on(ko.ASR_SEI_PUBLISH,this._callAppListener.bind(this,"onReceiveStartASR"),this),e.on(ko.ASR_SEI_UNPUBLISH,this._callAppListener.bind(this,"onReceiveStopASR"),this),e.on(ko.SUMMARIZATION_START,this._callAppListener.bind(this,"onReceiveStartSummarization"),this),e.on(ko.SUMMARIZATION_STOP,this._callAppListener.bind(this,"onReceiveStopSummarization"),this)}_startPullRTCRoomStatus(e,t,i){return m(this,void 0,void 0,(function*(){yield this._invoker.push(new ca(e,t,this._context,i))}))}__innerInit(e,t,i,r,n,s,o,a){return m(this,void 0,void 0,(function*(){const{code:l,data:_}=yield this._invoker.push(new wo(this._roomId,e,t,i,r,n,s,o,a));return l!==ae.SUCCESS?{code:l}:(this._initWithRoomData(_.offlineKickTime),{code:l,data:_})}))}_initWithRoomData(e){this._pinger.start(1e3*e),this._polarisReport.sendR1()}_handlePingResult(e,t){if(e===bi.SUCCESS){if(t>this._store.getRoomStatusVersion()&&this._store.getSupportNtf()){const e=this._logger.createTraceId();this._logger.info(le.L_RTCPING_PULL_ROOM_STATUS_O,JSON.stringify({dataVersion:t}),e),this._startPullRTCRoomStatus(this._roomId,e,t)}}this._callAppListener("onPing",e)}setBitrate(e,t,i){this._logger.warn(le.L_ABSTRACT_ROOM_SETBITRATE_O,"`RCAbstractRoom.setBitrate` will be deprecated, use `RCLocalTrack.setBitrate` instead."),k("max",e,(e=>O(e)&&e>Math.max(t||1,200)),!0),k("min",t,(t=>O(t)&&t>=1&&(!O(e)||t<e)),!0),k("start",i,(i=>O(i)&&i>t&&i<=e)),this._peerConnection.setBitrate(e,t,i)}_onTrackReady(e){const t=e.streams[0].id,{track:i}=e.receiver,r=[t,"audio"===i.kind?vt.AUDIO_ONLY:vt.VIDEO_ONLY].join("_"),n=this._store.getRemoteTrack(r);n?(n.__innerSetMediaStreamTrack(i),this._logger.info(le.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:_e.SUCCESSED,eventType:"onTrackReady",trackId:n.getTrackId()})),this._callAppListener("onTrackReady",n)):this._logger.warn(le.L_ABSTRACT_ROOM_ONTRACKREADY_O,`cannot found remote track ${i.id}`)}_callAppListener(e,...t){var i;const r=null===(i=this._appListener)||void 0===i?void 0:i[e];if(r)try{r(...t)}catch(e){this._logger.error(le.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,null==e?void 0:e.stack)}}_onTrackUnpublish(e){this._logger.info(le.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:_e.SUCCESSED,eventType:"onTrackUnpublish",trackIds:null==e?void 0:e.map((e=>e.getTrackId()))})),this._callAppListener("onTrackUnpublish",e)}__parseInnerMessage(e,t){const{targetId:i}=e;if(i!==this._roomId)return void this._logger.warn(le.L_ABSTRACT_ROOM_RECEIVE_MESSAGE_O,JSON.stringify({status:_e.FAILED,message:`roomId is different, msg roomId-> ${i}, this._roomId-> ${this._roomId} `}),t);this._logger.info(le.L_ABSTRACT_ROOM_RECEIVE_MESSAGE_O,`recv inner msg -> message: ${JSON.stringify(e)} | roomid: ${this._roomId}`,t);const{content:r}=e;switch(e.messageType){case vi.KICK:this.__kickoff(!0,r);break;case vi.STATE:this._stateHandle(r,t);break;case vi.MODIFY:case vi.PUBLISH:case vi.UNPUBLISH:case vi.TOTAL_CONTENT_RESOURCE:this._resourceHandle(r,e.messageType,e.senderUserId,e.sentTime,t);break;case vi.ASR_STATUS:this._invoker.push(new Aa(r.asr_status));break;case vi.ASR_SEI:this._invoker.push(new Na(JSON.parse(r.sei_ai_uris||[])));break;case vi.SUMMARIZATION_STATUS:this._invoker.push(new Pa(r.status,r.taskId));break;case vi.ROOM_NOTIFY:this._logger.info(le.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:_e.SUCCESSED,eventType:"onRoomAttributeChange",messageType:e.messageType,messageContent:e.content})),this._callAppListener("onRoomAttributeChange",e.messageType,e.content);break;case vi.USER_NOTIFY:this._logger.warn(le.L_OLD_DAILY_RECORD_O,`TODO: ${vi.USER_NOTIFY}`);break;case vi.PK_INVITE:case vi.PK_CANCEL_INVITE:case vi.PK_INVITE_TIMEOUT:case vi.PK_INVITE_ANSWER:case vi.PK_END:this._onRecvPKMsg&&this._onRecvPKMsg(e);break;case vi.OTHER_ROOM_OFFLINE:break;default:this._logger.info(le.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:_e.SUCCESSED,eventType:"onMessageReceive",messageType:e.messageType,messageContent:e.content,senderUserId:e.senderUserId,messageUId:e.messageUId})),this._callAppListener("onMessageReceive",e.messageType,r,e.senderUserId,e.messageUId)}}__kickoff(e,t){return m(this,void 0,void 0,(function*(){if(this._invoker.isDestroyed())return;let i,r;this._logger.warn(le.L_ABSTRACT_ROOM_ONKICKOFF_O,`onKickOff -> byServer: ${e}, kickContent: ${JSON.stringify(t)}`),this.emit(Ua),this._leaveHandle(!e),e&&((null==t?void 0:t.users)||[]).forEach((e=>{e.userId===this._context.getCurrentId()&&(r=e.type,i=e.kickExtra,this._reportMediaActionLogger.reportQualityKickedData(r))})),this._logger.info(le.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:_e.SUCCESSED,eventType:"onKickOff",byServer:e,kickType:r,kickExtra:i})),this._callAppListener("onKickOff",e,r,i)}))}_rtcpeerClosed(){this.emit(Ua),this._leaveHandle(!0),this._logger.info(le.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,"onRTCPeerConnectionCloseByException"),this._callAppListener("onRTCPeerConnectionCloseByException")}_onReceiveAsrSeiContent(e){e.forEach((e=>{"destLangCode"in e?this._store.getIsStartRealTranslate()&&this._store.getTranslationLang()===e.destLangCode&&this._callAppListener("onReceiveRealtimeTranslationContent",e):this._callAppListener("onReceiveASRContent",e)}))}_resourceHandle(e,t,i,r,n){return m(this,void 0,void 0,(function*(){const{uris:s,ignore:o}=e;!o&&s&&this._invoker.push(new ra(e,t,i,n,r))}))}_onTrackPublish(e,t,i){this._logger.info(le.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:_e.SUCCESSED,eventType:"onTrackPublish",trackIds:null==e?void 0:e.map((e=>e.getTrackId()))})),this._callAppListener("onTrackPublish",e)}_stateHandle(e,t){return m(this,void 0,void 0,(function*(){const i=(yield this._invoker.push(new ia(e,t))).data;this._dealUserAppListener(i)}))}_dealUserAppListener(e){var t,i;const{left:r,joined:n,upgrade:s,downgrade:o,offline:a}=e,l=[...n],_=[...r];(null===(t=this._appListener)||void 0===t?void 0:t.onSwitchRole)?(null==s||s.forEach((e=>{this._logger.info(le.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:_e.SUCCESSED,eventType:"onSwitchRole",userId:e,role:go.ANCHOR})),this._callAppListener("onSwitchRole",e,go.ANCHOR)})),null==o||o.forEach((e=>{this._logger.info(le.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:_e.SUCCESSED,eventType:"onSwitchRole",userId:e,role:go.AUDIENCE})),this._callAppListener("onSwitchRole",e,go.AUDIENCE)}))):(l.push(...s),_.push(...o)),a.length&&((null===(i=this._appListener)||void 0===i?void 0:i.onUserOffline)?(this._logger.info(le.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:_e.SUCCESSED,eventType:"onUserOffline",offline:a})),this._callAppListener("onUserOffline",a)):_.push(...a)),l.length>0&&(this._logger.info(le.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:_e.SUCCESSED,eventType:"onUserJoin",allJoined:l})),this._callAppListener("onUserJoin",l)),_.length>0&&(this._logger.info(le.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:_e.SUCCESSED,eventType:"onUserLeave",allLeft:_})),this._callAppListener("onUserLeave",_))}getRoomId(){return this._roomId}getCrtUserId(){return this._context.getCurrentId()}getRemoteUserIds(){return this._store.getRemoteUserIds()}getRemoteTracks(){const e=[];return this.getRemoteUserIds().forEach((t=>{e.push(...this.getRemoteTracksByUserId(t))})),e}getRemoteTracksByUserId(e){return this._store.getRemoteTracksByUserId(e)}getSessionId(){return this._store.getSessionId()}sendMessage(e,t){return m(this,void 0,void 0,(function*(){const i=this._logger.createTraceId();this._logger.info(le.L_ABSTRACT_ROOM_SEND_MESSAGE_T,JSON.stringify({name:e,content:t}),i);const{code:r}=yield this._context.sendMessage(a.RTC_ROOM,this._roomId,{messageType:e,content:t,isStatusMessage:!0});return r!==oe.SUCCESS?(this._logger.error(le.L_ABSTRACT_ROOM_SEND_MESSAGE_R,JSON.stringify({status:_e.FAILED,code:r}),i),{code:ae.SIGNAL_ERROR}):(this._logger.info(le.L_ABSTRACT_ROOM_SEND_MESSAGE_R,JSON.stringify({status:_e.SUCCESSED,name:e,content:t}),i),{code:ae.SUCCESS})}))}setRoomAttribute(e,t,i){return m(this,arguments,void 0,(function*(e,t,i,r=!1){const n=this._logger.createTraceId();this._logger.info(le.L_ABSTRACT_ROOM_SET_ROOM_ATTRIBUTE_T,JSON.stringify({roomId:this._roomId,key:e,value:t,message:i,isInner:r}),n);const s=yield this._context.setRTCData(this._roomId,e,t,r,mo.ROOM,i);return s!==oe.SUCCESS?(this._logger.error(le.L_ABSTRACT_ROOM_SET_ROOM_ATTRIBUTE_R,JSON.stringify({status:_e.FAILED,code:s}),n),{code:ae.SIGNAL_ERROR}):(this._logger.info(le.L_ABSTRACT_ROOM_SET_ROOM_ATTRIBUTE_R,JSON.stringify({status:_e.SUCCESSED,roomId:this._roomId,key:e,value:t,message:i,isInner:r}),n),{code:ae.SUCCESS})}))}deleteRoomAttributes(e,t){return m(this,arguments,void 0,(function*(e,t,i=!1){const r=this._logger.createTraceId();this._logger.info(le.L_ABSTRACT_ROOM_DELETE_ROOM_ATTRIBUTE_T,JSON.stringify({roomId:this._roomId,keys:e,message:t,isInner:i}),r);const n=yield this._context.removeRTCData(this._roomId,e,i,mo.ROOM,t);return n!==oe.SUCCESS?(this._logger.error(le.L_ABSTRACT_ROOM_DELETE_ROOM_ATTRIBUTE_R,JSON.stringify({status:_e.FAILED,code:n}),r),{code:ae.SIGNAL_ERROR}):(this._logger.info(le.L_ABSTRACT_ROOM_DELETE_ROOM_ATTRIBUTE_R,JSON.stringify({status:_e.SUCCESSED,roomId:this._roomId,keys:e,message:t,isInner:i}),r),{code:ae.SUCCESS})}))}getRoomAttributes(){return m(this,arguments,void 0,(function*(e=[],t=!1){const i=this._logger.createTraceId();this._logger.info(le.L_ABSTRACT_ROOM_GET_ROOM_ATTRIBUTE_T,JSON.stringify({roomId:this._roomId,keys:e,isInner:t}),i);const{code:r,data:n}=yield this._context.getRTCData(this._roomId,e,t,mo.ROOM);return r!==oe.SUCCESS?(this._logger.error(le.L_ABSTRACT_ROOM_GET_ROOM_ATTRIBUTE_R,`GetRoomAttributes Failed: ${r}`,i),{code:ae.SIGNAL_ERROR}):(this._logger.info(le.L_ABSTRACT_ROOM_DELETE_ROOM_ATTRIBUTE_R,JSON.stringify({status:_e.SUCCESSED,data:n}),i),{code:ae.SUCCESS,data:n})}))}_setUserAttributeValue(e,t,i){return this._context.setRTCData(this._roomId,e,t,!1,mo.PERSON,i)}_deleteUserAttributes(e,t){return this._context.removeRTCData(this._roomId,e,!1,mo.PERSON,t)}_getUserAttributes(e){return this._context.getRTCData(this._roomId,e,!1,mo.PERSON)}isDestroyed(){return this._invoker.isDestroyed()}__destroy(e){return this._leaveHandle(e)}_muteRemoteTracksBeforeQuit(){const e=Object.values(this._store.getRemoteTracks());e.length&&e.forEach((e=>e.mute()))}_leaveHandle(e){return m(this,void 0,void 0,(function*(){this._invoker.isDestroyed()||(this._invoker.destroy(),this._muteRemoteTracksBeforeQuit(),e&&(yield this._context.quitRTCRoom(this._roomId)),this._store.isMainRoom&&(yield this._quitAllPKRoom()),this._pinger.stop(),yield this._service.exit(this._store.getRTCRequestHeader()),this._releasePCManager())}))}_releasePCManager(){const e=this._peerConnection;e.removeAllLocalTrack(),e.destroy()}_onLocalTrackDestroied(e){e instanceof Jt&&e.__isTiny()||this.unpublish([e])}_onLocalTrackMuted(e,t){return m(this,void 0,void 0,(function*(){const{code:i}=yield this._invoker.push(new aa(e));t(i)}))}publish(e){return m(this,void 0,void 0,(function*(){return this._invoker.push(new sa(e))}))}_getPushOtherRoomsParams(){return[]}_reTryExchange(){return this._invoker.push(new la)}unpublish(e){return m(this,void 0,void 0,(function*(){return this._invoker.push(new oa(e))}))}_isValidResourceId(e){var t;const{userId:i}=_i(e);return!!(null===(t=this._store.getResourcesByUserId(i))||void 0===t?void 0:t.find((t=>li(t)===e)))}subscribe(e){return m(this,void 0,void 0,(function*(){return this._invoker.push(new na(e,void 0,void 0))}))}unsubscribe(e){return m(this,void 0,void 0,(function*(){const t=this._logger.createTraceId();return this._logger.info(le.L_APP_CALL_UNSUBSCRIBE_O,void 0,t),this._invoker.push(new Jo(e,t))}))}updateSubList(e){return m(this,void 0,void 0,(function*(){return this._invoker.push(new Ho(e,!0,this._logger.createTraceId()))}))}getLocalTrack(e){return this._peerConnection.getLocalTrack(e)}getLocalTracks(){return this._peerConnection.getLocalTracks()}getRemoteTrack(e){return this._store.getRemoteTrack(e)||null}get subscribedTracks(){return this._store.getSubscribedList().slice()}registerRoomEventListener(e){this._logger.info(le.L_ABSTRACT_ROOM_REGISTER_ROOM_EVENT_LISTENER_O,e?Object.keys(e).join(","):null),this._appListener=e,this.asrIsAvailable()&&this._executeCtx.emit(ko.ASR_SEI_PUBLISH);const t=this.getSummarizationStatusData();t&&(null==t?void 0:t.status)===Hs.OPEN&&this._executeCtx.emit(ko.SUMMARIZATION_START,t.taskId)}registerReportListener(e){this._logger.info(le.L_ABSTRACT_ROOM_REGISTER_REPORT_LISTENER_O,e?Object.keys(e).join(","):null),this._peerConnection.registerReportListener(e)}onAudioLevelChange(e,t){this._logger.info(le.L_ABSTRACT_ROOM_AUDIO_LEVEL_O),this._audioLevelReport.onAudioLevelChange(e)}__onReconnected(e){this._invoker.push(new da(e))}_onAudioMuteChange(e){this._logger.info(le.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:_e.SUCCESSED,eventType:"onAudioMuteChange",trackId:e.getTrackId()})),this._callAppListener("onAudioMuteChange",e)}_onVideoMuteChange(e){this._logger.info(le.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:_e.SUCCESSED,eventType:"onVideoMuteChange",trackId:e.getTrackId()})),this._callAppListener("onVideoMuteChange",e)}_registerPKMsgListener(e){this._onRecvPKMsg=e}_quitAllPKRoom(){return m(this,void 0,void 0,(function*(){}))}getClientSessionId(){return this._store.clientSessionId}changeMediaDevice(e,t){return m(this,void 0,void 0,(function*(){return this._invoker.push(new La(e,t))}))}startASR(){return this._invoker.push(new Oa(Io.OPEN))}stopASR(){return this._invoker.push(new Oa(Io.CLOSE))}asrIsAvailable(){return this._store.getASRIsAvailable()}setEnableASR(e){return this._invoker.push(new va(e))}startRealtimeTranslation(e){return this._invoker.push(new ba(Ra.OPEN,e))}stopRealtimeTranslation(){return this._invoker.push(new ba(Ra.CLOSE))}startSummarization(){return this._invoker.push(new ya(!0))}stopSummarization(){return this._invoker.push(new ya(!1))}getSummarizationStatusData(){return this._store.getSummarizationStatusData()}}class Ma extends No{constructor(e,t){super(),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"cdnValues",{enumerable:!0,configurable:!0,writable:!0,value:t})}get kind(){return po.MCUCONFIG_FLUSH}execute(e,t,i){return m(this,void 0,void 0,(function*(){var i,r,n,s;const{context:o,service:a}=e,l={"App-Key":o.getAppkey(),Token:t.getToken(),RoomId:t.roomId,UserId:o.getCurrentId(),SessionId:t.getSessionId()},{code:_,res:c}=yield a.setMcuConfig(l,this.data);if(_!==ae.SUCCESS)return{code:_};c.pull_url&&t.setCDNUris(JSON.parse(c.pull_url));const d=this.cdnValues;return _===ae.SUCCESS&&((null===(r=null===(i=d.output)||void 0===i?void 0:i.video.normal)||void 0===r?void 0:r.width)||(null===(s=null===(n=d.output)||void 0===n?void 0:n.video.normal)||void 0===s?void 0:s.fps))&&Wo(o,t),{code:_,data:c}}))}}var wa,ka,xa,Ba;!function(e){e[e.CROP=1]="CROP",e[e.WHOLE=2]="WHOLE"}(wa||(wa={})),function(e){e[e.CUSTOMIZE=1]="CUSTOMIZE",e[e.SUSPENSION=2]="SUSPENSION",e[e.ADAPTATION=3]="ADAPTATION"}(ka||(ka={})),function(e){e[e.CROP=1]="CROP",e[e.WHOLE=2]="WHOLE"}(xa||(xa={})),function(e){e[e.AUDIO_VIDEO_ALL=0]="AUDIO_VIDEO_ALL",e[e.AUDIO_VIDEO_NO=1]="AUDIO_VIDEO_NO",e[e.AUDIO_ALL_VIDEO_NO=2]="AUDIO_ALL_VIDEO_NO",e[e.AUDIO_NO_VIDEO_ALL=3]="AUDIO_NO_VIDEO_ALL",e[e.AUDIO_VIDEO_INPUT=4]="AUDIO_VIDEO_INPUT",e[e.AUDIO_ALL_VIDEO_INPUT=5]="AUDIO_ALL_VIDEO_INPUT",e[e.AUDIO_NO_VIDEO_INPUT=6]="AUDIO_NO_VIDEO_INPUT",e[e.AUDIO_INPUT_VIDEO_ALL=7]="AUDIO_INPUT_VIDEO_ALL",e[e.AUDIO_INPUT_VIDEO_NO=8]="AUDIO_INPUT_VIDEO_NO",e[e.ROOM_AUDIO_VIDEO_APPEND=9]="ROOM_AUDIO_VIDEO_APPEND",e[e.ROOM_AUDIO_VIDEO_NOT_APPEND=10]="ROOM_AUDIO_VIDEO_NOT_APPEND",e[e.ROOM_AUDIO_APPEND=11]="ROOM_AUDIO_APPEND",e[e.ROOM_AUDIO_NOT_APPEND=12]="ROOM_AUDIO_NOT_APPEND",e[e.ROOM_VIDEO_APPEND=13]="ROOM_VIDEO_APPEND",e[e.ROOM_VIDEO_NOT_APPEND=14]="ROOM_VIDEO_NOT_APPEND"}(Ba||(Ba={}));const Va=()=>({version:2,mode:ka.SUSPENSION});class Ga{constructor(e,t,i){Object.defineProperty(this,"_executeCtx",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_invoker",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_isValidTrackId",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_values",{enumerable:!0,configurable:!0,writable:!0,value:Va()}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._logger=this._executeCtx.logger}setHostVideoTrack(e){if(!this._isValidTrackId(e))return this._logger.error(le.L_MCU_CONFIG_BUILDER_SET_HOST_VIDEO_TRACK_O,JSON.stringify({status:_e.FAILED,msg:`videoTrackId: ${e} is invalid`})),this;const{mediaType:t,tag:i,userId:r}=_i(e);return t!==vt.VIDEO_ONLY?(this._logger.error(le.L_MCU_CONFIG_BUILDER_SET_HOST_VIDEO_TRACK_O,JSON.stringify({status:_e.FAILED,msg:`kind of ${e} is not video`})),this):(this._values.host_stream_id=ci(r,i),this._logger.info(le.L_MCU_CONFIG_BUILDER_SET_HOST_VIDEO_TRACK_O,JSON.stringify({status:_e.SUCCESSED,videoTrackId:e})),this)}setMixLayoutMode(e){return[ka.CUSTOMIZE,ka.SUSPENSION,ka.ADAPTATION].includes(e)?(this._values.mode=e,this._logger.info(le.L_MCU_CONFIG_BUILDER_SET_MIX_LAYOUT_MODE_O,JSON.stringify({status:_e.SUCCESSED,mode:e})),this):(this._logger.error(le.L_MCU_CONFIG_BUILDER_SET_MIX_LAYOUT_MODE_O,JSON.stringify({status:_e.SUCCESSED,msg:`mode: ${e} is invalid`})),this)}_addOutputValue(e,t,i="normal"){const r=this._values.output||(this._values.output={video:{normal:{width:640,height:480}}});if("cdn"===e)return void(r.cdn=t);if("audio"===e)return void(r.audio={bitrate:t});const{video:n}=r;if("normal"!==i&&"tiny"!==i)if("backgroundColor"!==i)if("exparams"!==i){if("backgroundPicture"===i){const e=n.backgroundPicture||(n.backgroundPicture={fillMode:wa.CROP,picture:[]});Object.assign(e,t)}}else n.exparams={renderMode:t};else n.backgroundColor=t;else{const e=n[i]||(n[i]={});Object.assign(e,t)}}setOutputVideoResolution(e){if(!pi(e))return this._logger.error(le.L_MCU_CONFIG_BUILDER_SET_OUTPUT_VIDEO_RESOLUTION_O,JSON.stringify({status:_e.FAILED,msg:`params error -> resolution: ${e}`})),this;const{width:t,height:i}=gi(e);return this._addOutputValue("video",{width:t,height:i},"normal"),this._logger.info(le.L_MCU_CONFIG_BUILDER_SET_OUTPUT_VIDEO_RESOLUTION_O,JSON.stringify({status:_e.SUCCESSED,resolution:e})),this}setOutputVideoFPS(e){if(!fi(e))return this._logger.error(le.L_MCU_CONFIG_BUILDER_SET_OUTPUT_VIDEO_FPS_O,JSON.stringify({status:_e.FAILED,msg:`params error -> fps: ${e}`})),this;const t=Ei(e);return this._addOutputValue("video",{fps:t},"normal"),this._logger.info(le.L_MCU_CONFIG_BUILDER_SET_OUTPUT_VIDEO_FPS_O,JSON.stringify({status:_e.SUCCESSED,fps:e})),this}setOutputVideoBitrate(e){return!O(e)||e<=0?(this._logger.error(le.L_MCU_CONFIG_BUILDER_SET_OUTPUT_VIDEO_BITRATE_O,JSON.stringify({status:_e.FAILED,msg:`params error -> bitrate: ${e}`})),this):(this._addOutputValue("video",{bitrate:e},"normal"),this._logger.info(le.L_MCU_CONFIG_BUILDER_SET_OUTPUT_VIDEO_BITRATE_O,JSON.stringify({status:_e.SUCCESSED,bitrate:e})),this)}setOutputTinyVideoResolution(e){if(!pi(e))return this._logger.error(le.L_MCU_CONFIG_BUILDER_SET_OUTPUT_TINY_VIDEO_RESOLUTION_O,JSON.stringify({status:_e.FAILED,msg:`params error -> resolution: ${e}`})),this;const{width:t,height:i}=gi(e);return this._addOutputValue("video",{width:t,height:i},"tiny"),this._logger.info(le.L_MCU_CONFIG_BUILDER_SET_OUTPUT_TINY_VIDEO_RESOLUTION_O,JSON.stringify({status:_e.SUCCESSED,resolution:e})),this}setOutputTinyVideoFPS(e){if(!fi(e))return this._logger.error(le.L_MCU_CONFIG_BUILDER_SET_OUTPUT_TINY_VIDEO_FPS_O,JSON.stringify({status:_e.FAILED,msg:`params error -> fps: ${e}`})),this;const t=Ei(e);return this._addOutputValue("video",{fps:t},"tiny"),this._logger.info(le.L_MCU_CONFIG_BUILDER_SET_OUTPUT_TINY_VIDEO_FPS_O,JSON.stringify({status:_e.SUCCESSED,fps:e})),this}setOutputTinyVideoBitrate(e){return!O(e)||e<=0?(this._logger.error(le.L_MCU_CONFIG_BUILDER_SET_OUTPUT_TINY_VIDEO_BITRATE_O,JSON.stringify({status:_e.FAILED,msg:`params error -> bitrate: ${e}`})),this):(this._addOutputValue("video",{bitrate:e},"tiny"),this._logger.info(le.L_MCU_CONFIG_BUILDER_SET_OUTPUT_TINY_VIDEO_BITRATE_O,JSON.stringify({status:_e.SUCCESSED,bitrate:e})),this)}setOutputVideoRenderMode(e){return[xa.CROP,xa.WHOLE].includes(e)?(this._addOutputValue("video",e,"exparams"),this._logger.info(le.L_MCU_CONFIG_BUILDER_SET_OUTPUT_VIDEO_RENDER_MODE_O,JSON.stringify({status:_e.SUCCESSED,renderMode:e})),this):(this._logger.error(le.L_MCU_CONFIG_BUILDER_SET_OUTPUT_VIDEO_RENDER_MODE_O,JSON.stringify({status:_e.FAILED,msg:`params error -> renderMode: ${e}`})),this)}setOutputAudioBitrate(e){return O(e)&&e>0?(this._addOutputValue("audio",e),this._logger.info(le.L_MCU_CONFIG_BUILDER_SET_OUTPUT_AUDIO_BITRATE_O,JSON.stringify({status:_e.SUCCESSED,bitrate:e})),this):(this._logger.error(le.L_MCU_CONFIG_BUILDER_SET_OUTPUT_AUDIO_BITRATE_O,JSON.stringify({status:_e.FAILED,msg:`params error -> bitrate: ${e}`})),this)}setOutputBackgroundColor(e){return/^0x[a-fA-F0-9]{6}$/.test(e)?(this._addOutputValue("video",e,"backgroundColor"),this._logger.info(le.L_MCU_CONFIG_BUILDER_SET_OUTPUT_BACKGROUND_COLOR_O,JSON.stringify({status:_e.SUCCESSED,color:e})),this):(this._logger.error(le.L_MCU_CONFIG_BUILDER_SET_OUTPUT_BACKGROUND_COLOR_O,JSON.stringify({status:_e.FAILED,msg:`params error -> color: ${e}`})),this)}addOutputBackgroundPicture(e,t,i,r,n){var s,o,a;if(!U(e))return this._logger.error(le.L_MCU_CONFIG_BUILDER_SET_OUTPUT_BACKGROUND_PICTURE_O,JSON.stringify({status:_e.FAILED,msg:`params error -> uri: ${e}`})),this;if([t,i,r,n].some((e=>!O(e)||e<0||e>1)))return this._logger.error(le.L_MCU_CONFIG_BUILDER_SET_OUTPUT_BACKGROUND_PICTURE_O,JSON.stringify({status:_e.FAILED,msg:`params of (x, y, w, h) error -> x: ${t}, y: ${i}, w: ${r}, h: ${n}`})),this;const l=(null===(a=null===(o=null===(s=this._values.output)||void 0===s?void 0:s.video)||void 0===o?void 0:o.backgroundPicture)||void 0===a?void 0:a.picture)||[];return l.push({uri:e,w:r,h:n,x:t,y:i}),this._addOutputValue("video",{picture:l},"backgroundPicture"),this._logger.info(le.L_MCU_CONFIG_BUILDER_SET_OUTPUT_BACKGROUND_PICTURE_O,JSON.stringify({status:_e.SUCCESSED,uri:e,x:t,y:i,w:r,h:n})),this}removeOutputBackgroundPicture(e){var t,i,r;if(!U(e))return this._logger.error(le.L_MCU_CONFIG_BUILDER_REMOVE_OUTPUT_BACKGROUND_PICTURE_O,JSON.stringify({status:_e.FAILED,msg:`params error -> uri: ${e}`})),this;let n=null===(r=null===(i=null===(t=this._values.output)||void 0===t?void 0:t.video)||void 0===i?void 0:i.backgroundPicture)||void 0===r?void 0:r.picture;return n&&(n=n.filter((t=>t.uri!==e)),this._addOutputValue("video",{pictures:n},"backgroundPicture")),this._logger.info(le.L_MCU_CONFIG_BUILDER_REMOVE_OUTPUT_BACKGROUND_PICTURE_O,JSON.stringify({status:_e.SUCCESSED,uri:e})),this}clearOutputBackgroundPicture(){return this._addOutputValue("video",{pictures:[]},"backgroundPicture"),this._logger.info(le.L_MCU_CONFIG_BUILDER_CLEAR_OUTPUT_BACKGROUND_PICTURE_O),this}setOutputBackgroundPictureFillMode(e){return[wa.CROP,wa.WHOLE].includes(e)?(this._addOutputValue("video",{fillMode:e},"backgroundPicture"),this._logger.info(le.L_MCU_CONFIG_BUILDER_SET_OUTPUT_BACKGROUND_PICTURE_FILL_MODE_O,JSON.stringify({status:_e.SUCCESSED,fillMode:e})),this):(this._logger.error(le.L_MCU_CONFIG_BUILDER_SET_OUTPUT_BACKGROUND_PICTURE_FILL_MODE_O,JSON.stringify({status:_e.FAILED,msg:`params error -> fillMode: ${e}`})),this)}addPublishStreamUrls(e){var t,i;const r=/^rtmp:\/\/.+/;if(!v(e)||0===e.length||e.some((e=>!r.test(e))))return this._logger.error(le.L_MCU_CONFIG_BUILDER_SET_OUTPUT_BACKGROUND_PICTURE_FILL_MODE_O,JSON.stringify({status:_e.FAILED,msg:`params error -> urls: ${e.join(",")}`})),this;const n=(null===(i=null===(t=this._values.output)||void 0===t?void 0:t.cdn)||void 0===i?void 0:i.concat())||[];let s=!1;return e.forEach((e=>{n.some((t=>t.pushurl===e))||(s=!0,n.push({pushurl:e}))})),n.length>5?(this._logger.error(le.L_MCU_CONFIG_BUILDER_SET_OUTPUT_BACKGROUND_PICTURE_FILL_MODE_O,JSON.stringify({status:_e.FAILED,msg:`params error -> publish stream urls no more than 5, length: ${e.length}`})),this):(s&&this._addOutputValue("cdn",n),this._logger.info(le.L_MCU_CONFIG_BUILDER_ADD_PUBLISH_STREAM_URLS_O,JSON.stringify({status:_e.SUCCESSED,urls:e})),this)}removePublishStreamUrls(e){var t,i;const r=/^rtmp:\/\/.+/;if(!v(e)||0===e.length||e.some((e=>!r.test(e))))return this._logger.error(le.L_MCU_CONFIG_BUILDER_REMOVE_PUBLISH_STREAM_URLS_O,JSON.stringify({status:_e.FAILED,msg:`params error -> urls: ${e.join(",")}`})),this;const n=(null===(i=null===(t=this._values.output)||void 0===t?void 0:t.cdn)||void 0===i?void 0:i.concat())||[];for(let t=n.length-1;t>=0;t-=1){const{pushurl:i}=n[t],r=e.indexOf(i);r>=0&&(e.splice(r,1),n.splice(t,1))}return this._addOutputValue("cdn",n),this._logger.info(le.L_MCU_CONFIG_BUILDER_REMOVE_PUBLISH_STREAM_URLS_O,JSON.stringify({status:_e.SUCCESSED,urls:e})),this}clearPublishStreamUrls(){return this._addOutputValue("cdn",[]),this._logger.info(le.L_MCU_CONFIG_BUILDER_CLEAR_PUBLISH_STREAM_URLS_O),this}addCustomizeLayoutVideo(e,t,i,r,n){if(!b(e)||!this._isValidTrackId(e))return this._logger.error(le.L_MCU_CONFIG_BUILDER_ADD_CUSTOMIZE_LAYOUT_VIDEO_O,JSON.stringify({status:_e.FAILED,msg:`params error -> trackId: ${e}`})),this;if(!O(t)||!O(i))return this._logger.error(le.L_MCU_CONFIG_BUILDER_ADD_CUSTOMIZE_LAYOUT_VIDEO_O,JSON.stringify({status:_e.FAILED,msg:`params x or y is error -> x: ${t}, y: ${i}`})),this;if([r,n].some((e=>!O(e)||e<0)))return this._logger.error(le.L_MCU_CONFIG_BUILDER_ADD_CUSTOMIZE_LAYOUT_VIDEO_O,JSON.stringify({status:_e.FAILED,msg:`params width or height error -> width: ${r}, height: ${n}`})),this;const{userId:s,tag:o,mediaType:a}=_i(e);if(a!==vt.VIDEO_ONLY)return this._logger.error(le.L_MCU_CONFIG_BUILDER_ADD_CUSTOMIZE_LAYOUT_VIDEO_O,JSON.stringify({status:_e.FAILED,msg:`type of trackId: ${e} is not video`})),this;const l=ci(s,o),_=this._values.input||(this._values.input={}),c=_.video||(_.video=[]);return c.some((e=>e.height===n&&e.width===r&&e.stream_id===l&&e.user_id===s&&e.x===t&&e.y===i))?(this._logger.warn(le.L_MCU_CONFIG_BUILDER_ADD_CUSTOMIZE_LAYOUT_VIDEO_O,JSON.stringify({status:_e.FAILED,msg:"Duplicate configuration item place ignored"})),this):(c.push({user_id:s,stream_id:l,x:t,y:i,width:r,height:n}),this._logger.info(le.L_MCU_CONFIG_BUILDER_ADD_CUSTOMIZE_LAYOUT_VIDEO_O,JSON.stringify({status:_e.SUCCESSED,trackId:e,x:t,y:i,width:r,height:n})),this)}removeCustomizeLayoutVideo(e){if(!this._isValidTrackId(e))return this._logger.error(le.L_MCU_CONFIG_BUILDER_REMOVE_CUSTOMIZE_LAYOUT_VIDEO_O,JSON.stringify({status:_e.FAILED,msg:`params error -> trackId: ${e}`})),this;const{userId:t,tag:i,mediaType:r}=_i(e);if(r!==vt.VIDEO_ONLY)return this._logger.error(le.L_MCU_CONFIG_BUILDER_REMOVE_CUSTOMIZE_LAYOUT_VIDEO_O,JSON.stringify({status:_e.FAILED,msg:`type of trackId: ${e} is not video`})),this;const n=ci(t,i),{input:s}=this._values;return(null==s?void 0:s.video)&&s.video.length>0&&(s.video=s.video.filter((e=>e.stream_id===n))),this._logger.info(le.L_MCU_CONFIG_BUILDER_REMOVE_CUSTOMIZE_LAYOUT_VIDEO_O,JSON.stringify({status:_e.SUCCESSED,trackId:e})),this}clearCustomizeLayoutVideo(){const{input:e}=this._values;return null==e||delete e.video,this._logger.info(le.L_MCU_CONFIG_BUILDER_CLEAR_CUSTOMIZE_LAYOUT_VIDEO_O),this}setCustomizeInputAudio(e){if(e.some((e=>this._isValidTrackId(e))))return this._logger.error(le.L_MCU_CONFIG_BUILDER_SET_CUSTOMIZE_INPUT_AUDIO_O,JSON.stringify({status:_e.FAILED,msg:`trackIds contain invalid item -> trackIds: ${e.join(",")}`})),this;return(this._values.input||(this._values.input={})).audio=e.map((e=>{const{userId:t,tag:i}=_i(e);return{stream_id:ci(t,i),user_id:t}})),this._values.inputFilterMode=Ba.AUDIO_INPUT_VIDEO_ALL,this._logger.info(le.L_MCU_CONFIG_BUILDER_SET_CUSTOMIZE_INPUT_AUDIO_O,JSON.stringify({status:_e.SUCCESSED,trackIds:e})),this}addCustomizeInputAudio(e){if(!this._isValidTrackId(e))return this._logger.error(le.L_MCU_CONFIG_BUILDER_ADD_CUSTOMIZE_INPUT_AUDIO_O,JSON.stringify({status:_e.FAILED,msg:`params error -> trackId: ${e}`})),this;const t=this._values.input||(this._values.input={}),i=t.audio||(t.audio=[]),{userId:r,tag:n}=_i(e),s=ci(r,n);return i.some((e=>e.stream_id===s&&e.user_id===r))?(this._logger.warn(le.L_MCU_CONFIG_BUILDER_ADD_CUSTOMIZE_INPUT_AUDIO_O,JSON.stringify({status:_e.FAILED,msg:`trackId: ${e} is exist`})),this):(i.push({user_id:r,stream_id:s}),this._values.inputFilterMode=Ba.AUDIO_INPUT_VIDEO_ALL,this._logger.info(le.L_MCU_CONFIG_BUILDER_ADD_CUSTOMIZE_INPUT_AUDIO_O,JSON.stringify({status:_e.SUCCESSED,trackId:e})),this)}removeCustomizeInputAudio(e){if(!this._isValidTrackId(e))return this._logger.error(le.L_MCU_CONFIG_BUILDER_REMOVE_CUSTOMIZE_INPUT_AUDIO_O,JSON.stringify({status:_e.FAILED,msg:`params error -> trackId: ${e}`})),this;const{input:t}=this._values;if(!(null==t?void 0:t.audio)||0===t.audio.length)return this._logger.error(le.L_MCU_CONFIG_BUILDER_REMOVE_CUSTOMIZE_INPUT_AUDIO_O,JSON.stringify({status:_e.FAILED,msg:`type of trackId: ${e} is not audio`})),this;const{userId:i,tag:r}=_i(e),n=ci(i,r);return t.audio=t.audio.filter((e=>i!==e.user_id||n!==e.stream_id)),this._logger.info(le.L_MCU_CONFIG_BUILDER_REMOVE_CUSTOMIZE_INPUT_AUDIO_O,JSON.stringify({status:_e.SUCCESSED,trackId:e})),this}clearCustomizeInputAudio(){const{input:e}=this._values;return(null==e?void 0:e.audio)&&delete e.audio,this._values.inputFilterMode=Ba.AUDIO_VIDEO_ALL,this._logger.info(le.L_MCU_CONFIG_BUILDER_CLEAR_CUSTOMIZE_INPUT_AUDIO_O),this}addPictureWaterMark(e,t,i,r,n,s){if(!this._isValidTrackId(e))return this._logger.error(le.L_MCU_CONFIG_BUILDER_ADD_SINGLE_WATER_MARK_O,JSON.stringify({status:_e.FAILED,msg:`params error -> trackId: ${e}`})),this;if(!U(t))return this._logger.error(le.L_MCU_CONFIG_BUILDER_ADD_SINGLE_WATER_MARK_O,JSON.stringify({status:_e.FAILED,msg:`params error -> uri: ${t}`})),this;if([i,r,n,s].some((e=>!O(e)||e<0||e>1))||i+n>1||r+s>1)return this._logger.error(le.L_MCU_CONFIG_BUILDER_ADD_SINGLE_WATER_MARK_O,JSON.stringify({status:_e.FAILED,msg:`some attrs of (x, y, w, h) is invalid -> x: ${i}, y: ${r}, w: ${n}, h: ${s}`})),this;const{userId:o,tag:a}=_i(e),l=ci(o,a),_=this._values.waterMark||(this._values.waterMark={enable:"on",singleScreen:[]}),{singleScreen:c}=_,d=c.filter((e=>e.streamId===l))[0];return d?d.picture.push({uri:t,w:n,h:s,x:i,y:r}):c.push({streamId:l,picture:[{uri:t,w:n,h:s,x:i,y:r}]}),this._values.waterMark.singleScreen=c,this._logger.info(le.L_MCU_CONFIG_BUILDER_ADD_SINGLE_WATER_MARK_O,JSON.stringify({status:_e.SUCCESSED,trackId:e,uri:t,x:i,y:r,w:n,h:s,singleScreen:c})),this}clearPictureWaterMark(){return(this._values.waterMark||(this._values.waterMark={enable:"on",singleScreen:[]})).singleScreen=[],this._logger.info(le.L_MCU_CONFIG_BUILDER_CLEAR_OUTPUT_BACKGROUND_PICTURE_O),this}removePictureWaterMark(e,t){if(!b(e)||!this._isValidTrackId(e))return this._logger.error(le.L_MCU_CONFIG_BUILDER_REMOVE_SINGLE_WATER_MARK_O,JSON.stringify({status:_e.FAILED,msg:`params error -> trackId: ${e}`})),this;const{userId:i,tag:r}=_i(e),n=ci(i,r),s=this._values.waterMark||(this._values.waterMark={enable:"on",singleScreen:[]}),{singleScreen:o}=s;return o.forEach((e=>{e.streamId===n&&(e.picture=e.picture.filter((e=>e.uri!==t)))})),this._logger.info(le.L_MCU_CONFIG_BUILDER_REMOVE_SINGLE_WATER_MARK_O,JSON.stringify({status:_e.SUCCESSED,trackId:e,uri:t})),this}reset(){return this._values=Va(),this._logger.info(le.L_MCU_CONFIG_BUILDER_RESET_O),this}flush(){return m(this,arguments,void 0,(function*(e=!0){const t=JSON.parse(JSON.stringify(this._values)),{code:i}=yield this._invoker.push(new Ma(t,this._values));return e&&(this._values=Va()),{code:i}}))}__innerGetValues(){return JSON.parse(JSON.stringify(this._values))}}var Fa,ja,Ha;!function(e){e[e.VIDEO=0]="VIDEO",e[e.AUDIO=1]="AUDIO"}(Fa||(Fa={}));class Ja extends No{constructor(e,t,i){super(),Object.defineProperty(this,"roomId",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"roomPKHandler",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"traceId",{enumerable:!0,configurable:!0,writable:!0,value:i})}_exchangeWithPushOtherRoom(e,t,i){return m(this,void 0,void 0,(function*(){const{logger:r,peer:n,context:s}=e;if(!n.getLocalTracks().length)return void r.info(le.L_EXCHANGE_WITH_PUSHOTHERROOM_R,JSON.stringify({status:_e.SUCCESSED,msg:"have not published resource"}),this.traceId);const o=n,a=t.getSubscribedList(),l=yield Ko(a,!1,o,t,s),_=e.getPushOtherRooms();l.pushOtherRooms=_;const c=yield new jo(l,this.traceId,!0).execute(e,t,i);if(c.code!==ae.SUCCESS)return void r.error(le.L_EXCHANGE_WITH_PUSHOTHERROOM_R,JSON.stringify({status:_e.FAILED,code:c.code,pushOtherRooms:_}),this.traceId);const{sdp:d,resultCode:u}=c.data.data;u===ae.SUCCESS?(r.info(le.L_EXCHANGE_WITH_PUSHOTHERROOM_R,JSON.stringify({status:_e.SUCCESSED,pushOtherRooms:_}),this.traceId),o.setRemoteAnswer(d.sdp)):r.error(le.L_EXCHANGE_WITH_PUSHOTHERROOM_R,JSON.stringify({status:_e.FAILED,code:u,pushOtherRooms:_}),this.traceId)}))}get kind(){return po.EXCHANGE_WITH_PUSH_OTHER_ROOM}execute(e,t,i){return m(this,void 0,void 0,(function*(){const{logger:r}=e,{roomId:n}=this;if(r.info(le.L_EXCHANGE_WITH_PUSHOTHERROOM_T,n),!this.roomPKHandler)return r.error(le.L_EXCHANGE_WITH_PUSHOTHERROOM_R,JSON.stringify({status:_e.FAILED,msg:"_roomPKHandler not exist"}),this.traceId),{code:ae.SUCCESS};return this.roomPKHandler.getPKInfo(n)?(yield this._exchangeWithPushOtherRoom(e,t,i),{code:ae.SUCCESS}):(r.warn(le.L_EXCHANGE_WITH_PUSHOTHERROOM_R,JSON.stringify({status:_e.FAILED,msg:"PKInfo not exist"}),this.traceId),{code:ae.SUCCESS})}))}}class $a extends No{constructor(e,t,i,r,n,s){super(),Object.defineProperty(this,"pkHandler",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"room",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_PKInfo",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_joinedPKRooms",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"isQuitPK",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"traceId",{enumerable:!0,configurable:!0,writable:!0,value:s})}get kind(){return po.LEAVE_OTHER_ROOM}quitRoomPK(e,t,i,r){return m(this,void 0,void 0,(function*(){const{logger:n,context:s}=e;if(n.info(le.L_QUIT_PK_T,`roomId: ${t}`,r),!this._PKInfo[t])return void n.warn(le.L_QUIT_PK_R,`status: ${_e.FAILED}, msg: pkinfo is empty`,r);const{inviterRoomId:o,inviteeRoomId:a,inviterUserId:l,inviteSessionId:_}=this._PKInfo[t],c={inviteeRoomId:a,inviterRoomId:o,userId:i.crtUserId},d={roomId:i.roomId,endRoomId:t,sessionId:_,content:JSON.stringify(c),keys:[`${o}|${l}`]},u=yield s.endRoomPK(d);if(u!==oe.SUCCESS)return n.error(le.L_QUIT_PK_R,`status: ${_e.FAILED}, code: ${u}`,r),{code:ae.SIGNAL_ERROR};n.info(le.L_QUIT_PK_R,`status: ${_e.SUCCESSED}`,r),delete this._PKInfo[t]}))}execute(e,t,i){return m(this,void 0,void 0,(function*(){const{logger:r}=e,{room:n,isQuitPK:s}=this,o=n.getRoomId();return r.info(le.L_LIVING_ROOM_LEAVE_PK_ROOM_T,JSON.stringify({roomId:o,isQuitPK:s}),this.traceId),yield n.__destroy(!0),delete this._joinedPKRooms[o],yield new Ja(o,this.pkHandler,this.traceId).execute(e,t,i),s&&this.quitRoomPK(e,o,t,this.traceId),r.info(le.L_LIVING_ROOM_LEAVE_PK_ROOM_R,JSON.stringify({status:_e.SUCCESSED}),this.traceId),{code:ae.SUCCESS}}))}}class Ka{constructor(e,t,i,r,n,s,o,a,l,_){Object.defineProperty(this,"_invoker",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_PKInfo",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_runtime",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_service",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"_initOptions",{enumerable:!0,configurable:!0,writable:!0,value:s}),Object.defineProperty(this,"_mainLivingRoom",{enumerable:!0,configurable:!0,writable:!0,value:o}),Object.defineProperty(this,"_registerPKMsgListener",{enumerable:!0,configurable:!0,writable:!0,value:a}),Object.defineProperty(this,"_onJoinedPKRoom",{enumerable:!0,configurable:!0,writable:!0,value:l}),Object.defineProperty(this,"_clientSessionId",{enumerable:!0,configurable:!0,writable:!0,value:_}),Object.defineProperty(this,"_inviteTimeout",{enumerable:!0,configurable:!0,writable:!0,value:30}),Object.defineProperty(this,"_appListener",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_mainRoomId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_joinedPKRooms",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._logger=this._context.logger,this._registerPKMsgListener(this._onRecvPKMsg.bind(this)),this._mainRoomId=this._mainLivingRoom.getRoomId()}_callAppListener(e,...t){var i;const r=null===(i=this._appListener)||void 0===i?void 0:i[e];if(r)try{r(...t)}catch(e){this._logger.error(le.L_LIVING_PK_HANDLER_CALL_APP_LISTENER_O,JSON.stringify(e))}}_onInvite(e){const t=e.inviteInfo||{},{inviterRoomId:i,inviterUserId:r,extra:n}=t,s={inviterRoomId:i,inviterUserId:r,extra:n};this._PKInfo[i]=t,this._logger.info(le.L_LIVING_PK_HANDLER_CALL_APP_LISTENER_O,JSON.stringify({eventType:"onRequestJoinOtherRoom",info:s})),this._callAppListener("onRequestJoinOtherRoom",s)}_onCancelInvite(e){const{inviterRoomId:t,inviterUserId:i,extra:r}=e.inviteInfo||{},n={inviterRoomId:t,inviterUserId:i,extra:r};delete this._PKInfo[t],this._logger.info(le.L_LIVING_PK_HANDLER_CALL_APP_LISTENER_O,JSON.stringify({eventType:"onCancelRequestOtherRoom",cancelInfo:n})),this._callAppListener("onCancelRequestOtherRoom",n)}_onInviteTimeout(e){}_onInviteAnswer(e){const{answerCode:t,inviteContent:i}=e,{inviteSessionId:r,inviterUserId:n,inviterRoomId:s,inviteeUserId:o,inviterUserAutoMix:a,inviteeUserAutoMix:l,inviteeRoomId:_,extra:c}=i,d={agree:1===t,inviterRoomId:s,inviterUserId:n,inviteeRoomId:_,inviteeUserId:o,extra:c};this._PKInfo[_]=this._PKInfo[_]||{inviteSessionId:r,inviterRoomId:s,inviterUserId:n,inviterUserAutoMix:a,inviteeRoomId:_},this._PKInfo[_].inviteeUserAutoMix=l,this._logger.info(le.L_LIVING_PK_HANDLER_CALL_APP_LISTENER_O,JSON.stringify({eventType:"onResponseJoinOtherRoom",answerInfo:d})),this._callAppListener("onResponseJoinOtherRoom",d)}createLeaveOtherRoomCommand(e,t,i){return new $a(this,e,this._PKInfo,this._joinedPKRooms,t,i)}_onPKEnd(e){return m(this,void 0,void 0,(function*(){const{inviteeRoomId:t,inviterRoomId:i,userId:r}=e.inviteInfo,n=i===this._mainRoomId?t:i,s={endRoomId:n,endUserId:r},o=this._joinedPKRooms[n],a=this._logger.createTraceId();this._logger.info(le.L_QUIT_PK_LEAVE_PK_ROOM_O,void 0,a),o&&(yield this._invoker.push(this.createLeaveOtherRoomCommand(o,!0,a))),delete this._PKInfo[n],this._logger.info(le.L_LIVING_PK_HANDLER_CALL_APP_LISTENER_O,JSON.stringify({eventType:"onFinishOtherRoom",endInfo:s})),this._callAppListener("onFinishOtherRoom",s)}))}_onRecvPKMsg(e){const{content:t,messageType:i}=e;switch(i){case vi.PK_INVITE:this._onInvite(t);break;case vi.PK_CANCEL_INVITE:this._onCancelInvite(t);break;case vi.PK_INVITE_TIMEOUT:this._onInviteTimeout(t);break;case vi.PK_INVITE_ANSWER:this._onInviteAnswer(t);break;case vi.PK_END:this._onPKEnd(t)}}registerRoomPKEventListener(e){this._logger.info(le.L_LIVING_PK_HANDLER_REGISTER_ROOM_PK_EVENT_LISTENER_O,JSON.stringify({listener:e&&Object.keys(e)})),this._appListener=e}requestJoinOtherRoom(e,t,i){return m(this,void 0,void 0,(function*(){const r=this._logger.createTraceId();if(this._logger.info(le.L_LIVING_PK_HANDLER_REQUEST_JOIN_OTHER_ROOM_T,JSON.stringify({inviteeRoomId:e,inviteeUserId:t,options:i}),r),!x("inviteeRoomId",e,b,!0)||!x("inviteeUserId",t,b,!0))return this._logger.error(le.L_LIVING_PK_HANDLER_REQUEST_JOIN_OTHER_ROOM_R,JSON.stringify({status:_e.FAILED,code:ae.PARAMS_ERROR,msg:"params error -> inviteeRoomId or inviteeUserId"}),r),{code:ae.PARAMS_ERROR};const n=Gs(),s=!L(null==i?void 0:i.autoMix)||(null==i?void 0:i.autoMix),o={inviteSessionId:n,inviterRoomId:this._mainRoomId,inviterUserId:this._context.getCurrentId(),inviterUserAutoMix:s,inviteeRoomId:e,inviteeUserId:t,inviteeTimeoutTime:this._inviteTimeout,extra:(null==i?void 0:i.extra)||""},a={roomId:this._mainRoomId,invitedRoomId:e,invitedUserId:t,inviteTimeout:this._inviteTimeout,inviteInfo:JSON.stringify(o),inviteSessionId:n},l=yield this._context.requestRoomPK(a);return l!==oe.SUCCESS?(this._logger.error(le.L_LIVING_PK_HANDLER_REQUEST_JOIN_OTHER_ROOM_R,JSON.stringify({status:_e.FAILED,code:l}),r),{code:l}):(this._PKInfo[e]={inviteSessionId:n,inviterRoomId:this._mainRoomId,inviterUserId:this._context.getCurrentId(),inviterUserAutoMix:s,inviteeRoomId:e},this._logger.info(le.L_LIVING_PK_HANDLER_REQUEST_JOIN_OTHER_ROOM_R,JSON.stringify({status:_e.SUCCESSED}),r),{code:ae.SUCCESS})}))}cancelRequestJoinOtherRoom(e,t,i){return m(this,void 0,void 0,(function*(){const r=this._logger.createTraceId();if(this._logger.info(le.L_LIVING_PK_HANDLER_CANCEL_REQUEST_JOIN_OTHER_ROOM_T,JSON.stringify({inviteeRoomId:e,inviteeUserId:t,extra:i}),r),!x("inviteeRoomId",e,b,!0)||!x("inviteeUserId",t,b,!0))return this._logger.error(le.L_LIVING_PK_HANDLER_CANCEL_REQUEST_JOIN_OTHER_ROOM_R,JSON.stringify({status:_e.FAILED,code:ae.PARAMS_ERROR,msg:"params error -> inviteeRoomId or inviteeUserId"}),r),{code:ae.PARAMS_ERROR};if(!this._PKInfo[e])return this._logger.error(le.L_LIVING_PK_HANDLER_CANCEL_REQUEST_JOIN_OTHER_ROOM_R,JSON.stringify({status:_e.FAILED,code:ae.PARAMS_ERROR,msg:`The request to connect with ${t} user in room ${e} is not initiated`}),r),{code:ae.PARAMS_ERROR};const n={inviterRoomId:this._mainRoomId,inviterUserId:this._context.getCurrentId(),inviteeRoomId:e,inviteeUserId:t,extra:i||""},s={roomId:this._mainRoomId,invitedRoomId:e,invitedUserId:t,inviteSessionId:this._PKInfo[e].inviteSessionId,inviteInfo:JSON.stringify(n)},o=yield this._context.cancelRoomPK(s);return o!==oe.SUCCESS?(this._logger.error(le.L_LIVING_PK_HANDLER_CANCEL_REQUEST_JOIN_OTHER_ROOM_R,JSON.stringify({status:_e.FAILED,code:o}),r),{code:o}):(this._logger.info(le.L_LIVING_PK_HANDLER_CANCEL_REQUEST_JOIN_OTHER_ROOM_R,JSON.stringify({status:_e.SUCCESSED}),r),delete this._PKInfo[e],{code:ae.SUCCESS})}))}responseJoinOtherRoom(e,t,i,r){return m(this,void 0,void 0,(function*(){const n=this._logger.createTraceId();if(this._logger.info(le.L_LIVING_PK_HANDLER_RESPONSE_JOIN_OTHER_ROOM_T,JSON.stringify({inviterRoomId:e,inviterUserId:t,agree:i,options:r}),n),!x("inviterRoomId",e,b,!0)||!x("inviterUserId",t,b,!0))return this._logger.error(le.L_LIVING_PK_HANDLER_RESPONSE_JOIN_OTHER_ROOM_R,JSON.stringify({status:_e.FAILED,code:ae.PARAMS_ERROR,msg:"params error -> inviterRoomId or inviterUserId"}),n),{code:ae.PARAMS_ERROR};if(!this._PKInfo[e])return this._logger.error(le.L_LIVING_PK_HANDLER_RESPONSE_JOIN_OTHER_ROOM_R,JSON.stringify({status:_e.FAILED,code:ae.PARAMS_ERROR,msg:`User ${t} in room ${e} did not send a request for connection`}),n),{code:ae.PARAMS_ERROR};const{inviteSessionId:s,inviterUserAutoMix:o}=this._PKInfo[e],a=!L(null==r?void 0:r.autoMix)||(null==r?void 0:r.autoMix),l={inviteSessionId:s,inviterRoomId:e,inviterUserId:t,inviterUserAutoMix:o,inviteeRoomId:this._mainRoomId,inviteeUserId:this._context.getCurrentId(),inviteeUserAutoMix:a},_=Object.assign(l,{inviterUserAutoMix:o}),c=i?Object.assign(l,{MultiRoomKey:`${e}|${this._mainRoomId}`,MultiRoomValue:JSON.stringify(_)}):l;!P(null==r?void 0:r.extra)&&Object.assign(c,{extra:r.extra});const d={agree:i,roomId:this._mainRoomId,inviteSessionId:s,inviteRoomId:e,inviteUserId:t,content:JSON.stringify(c),key:`${e}|${this._mainRoomId}`,value:JSON.stringify(l)},u=yield this._context.responseRoomPK(d);return u!==oe.SUCCESS?(this._logger.error(le.L_LIVING_PK_HANDLER_RESPONSE_JOIN_OTHER_ROOM_R,JSON.stringify({status:_e.FAILED,code:u}),n),{code:u}):(this._logger.info(le.L_LIVING_PK_HANDLER_RESPONSE_JOIN_OTHER_ROOM_R,JSON.stringify({status:_e.SUCCESSED}),n),this._PKInfo[e].inviteeUserAutoMix=a,{code:ae.SUCCESS})}))}joinOtherRoom(e){return m(this,void 0,void 0,(function*(){const t=this._logger.createTraceId();if(this._logger.info(le.L_LIVING_PK_HANDLER_JOIN_OTHER_ROOM_T,JSON.stringify({roomId:e}),t),!x("roomId",e,b,!0))return this._logger.error(le.L_LIVING_PK_HANDLER_JOIN_OTHER_ROOM_R,JSON.stringify({status:_e.FAILED,code:ae.PARAMS_ERROR,msg:"params error -> roomId"}),t),{code:ae.PARAMS_ERROR};if(this._context.getConnectionStatus()!==l.CONNECTED)return this._logger.error(le.L_LIVING_PK_HANDLER_JOIN_OTHER_ROOM_R,JSON.stringify({status:_e.FAILED,code:ae.SIGNAL_DISCONNECTED,msg:"IM disconnected"}),t),{code:ae.SIGNAL_DISCONNECTED};if(this._joinedPKRooms[e])return this._logger.warn(le.L_LIVING_PK_HANDLER_JOIN_OTHER_ROOM_R,JSON.stringify({status:_e.FAILED,code:ae.REPERT_JOIN_ROOM,msg:"Join the room repeatedly"}),t),{code:ae.REPERT_JOIN_ROOM};const i=Fa.VIDEO,r={extra:`{"roomId": "${this._mainRoomId}"}`},n=new Wa(this._context,this._runtime,e,this._service,this._initOptions,i,!1,!1,this._clientSessionId),{code:s}=yield n.__innerInit(To.LIVE,void 0,i,r);return s!==ae.SUCCESS?(this._logger.error(le.L_LIVING_PK_HANDLER_JOIN_OTHER_ROOM_R,JSON.stringify({status:_e.FAILED,code:s}),t),{code:s}):(this._joinedPKRooms[e]=n,yield this._onJoinedPKRoom(e,t),this._logger.info(le.L_LIVING_PK_HANDLER_JOIN_OTHER_ROOM_R,JSON.stringify({status:_e.SUCCESSED}),t),{room:n,code:ae.SUCCESS,userIds:n.getRemoteUserIds(),tracks:n.getRemoteTracks()})}))}leaveOtherRoom(e,t){return m(this,void 0,void 0,(function*(){const i=this._logger.createTraceId();return this._logger.info(le.L_APP_CALL_LEAVE_PK_ROOM_O,void 0,i),this._invoker.push(this.createLeaveOtherRoomCommand(e,t,i))}))}getPKInfo(e){return this._PKInfo[e]}getAllPKInfo(){return this._PKInfo}getJoinedPKRooms(){return this._joinedPKRooms}}!function(e){e[e.OPEN=1]="OPEN",e[e.STOP=2]="STOP"}(ja||(ja={}));class Ya extends No{constructor(e,t){super(),Object.defineProperty(this,"cdnValues",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"enable",{enumerable:!0,configurable:!0,writable:!0,value:t})}get kind(){return po.ENABLE_INNER_CDN}execute(e,t,i){return m(this,void 0,void 0,(function*(){const{logger:r,context:n}=e,{enable:s}=this;if(r.info(le.L_LIVING_ROOM_ENABLE_INNER_CDN_T,JSON.stringify({roomId:t.roomId,enable:s})),!t.isMainRoom)return r.error(le.L_LIVING_ROOM_ENABLE_INNER_CDN_R,JSON.stringify({status:_e.FAILED,code:ae.THE_FUNCTION_IS_DISABLED_IN_PKROOM,msg:"method not available in PK room"})),{code:ae.THE_FUNCTION_IS_DISABLED_IN_PKROOM};if(!L(s))return r.error(le.L_LIVING_ROOM_ENABLE_INNER_CDN_R,JSON.stringify({status:_e.FAILED,code:ae.PARAMS_ERROR,msg:"params error -> enable"})),{code:ae.PARAMS_ERROR};t.setCDNEnabel(s);const o={version:2,output:{inCDNModel:s?ja.OPEN:ja.STOP}},{code:a}=yield new Ma(o,this.cdnValues).execute(e,t,i);if(a!==ae.SUCCESS)return r.error(le.L_LIVING_ROOM_ENABLE_INNER_CDN_R,JSON.stringify({status:_e.FAILED,code:a,msg:"signal error"})),{code:ae.SIGNAL_ERROR};const l=t.getCDNUris();if(l&&l.broadcast!==Go.SPREAD)return r.info(le.L_LIVING_ROOM_ENABLE_INNER_CDN_R,JSON.stringify({status:_e.SUCCESSED,enable:s})),{code:ae.SUCCESS};const{code:_}=yield Wo(n,t);return _===ae.SUCCESS?(r.info(le.L_LIVING_ROOM_ENABLE_INNER_CDN_R,JSON.stringify({status:_e.SUCCESSED,enable:s})),{code:ae.SUCCESS}):(r.error(le.L_LIVING_ROOM_ENABLE_INNER_CDN_R,JSON.stringify({status:_e.FAILED,code:_})),{code:_})}))}}!function(e){e[e.AnchorToViewer=1]="AnchorToViewer",e[e.ViewerToAnchor=2]="ViewerToAnchor"}(Ha||(Ha={}));class qa extends No{constructor(e,t){super(),Object.defineProperty(this,"livingType",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"traceId",{enumerable:!0,configurable:!0,writable:!0,value:t})}get kind(){return po.RTC_IDENTITY_CHANGE}execute(e,t,i){return m(this,void 0,void 0,(function*(){var r;const{context:n}=e,{code:s,data:o}=yield n.rtcIdentityChange(t.roomId,Ha.ViewerToAnchor,this.livingType);if(s!==oe.SUCCESS||!o)return{code:s};t.initWithRoomData(o,this.traceId);t.getResourcesByUserId(t.crtUserId).length>0&&i.push(new Mo);const a=null===(r=o.roomInfo.filter((e=>"cdn_uris"===e.key))[0])||void 0===r?void 0:r.value;return a&&t.setCDNUris(JSON.parse(a)[0]),{code:s,data:o}}))}}class Wa extends Da{constructor(e,t,i,r,n,s,o,a,l){super(e,t,i,To.LIVE,r,n,o,a,l),Object.defineProperty(this,"_livingType",{enumerable:!0,configurable:!0,writable:!0,value:s}),Object.defineProperty(this,"_mcuConfigBuilder",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_roomPKHandler",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._mcuConfigBuilder=new Ga(this._executeCtx,this._invoker,this._isValidResourceId.bind(this))}_initRoomPKHandler(e){if(this._store.isMainRoom){const t=((e,t)=>{const i={};return t.forEach((t=>{const r=JSON.parse(t.value),{inviterRoomId:n,inviteeRoomId:s}=r;i[e===n?s:n]=JSON.parse(t.value)})),i})(this._roomId,e.roomInfo);this._roomPKHandler=new Ka(this._invoker,t,this._context,this._runtime,this._service,this._initOptions,this,super._registerPKMsgListener.bind(this),this._onJoinedPKRoom.bind(this),this._clientSessionId)}}__innerInit(e,t,i,r,n,s){const o=Object.create(null,{__innerInit:{get:()=>super.__innerInit}});return m(this,void 0,void 0,(function*(){if(!x("livingType",i,(e=>e===Fa.AUDIO||e===Fa.VIDEO)))return this._logger.error(le.L_RTC_CLIENT_JOIN_LIVING_ROOM_R,JSON.stringify({status:_e.FAILED,code:ae.PARAMS_ERROR,msg:"params error -> livingType"}),s),{code:ae.PARAMS_ERROR};const{code:a,data:l}=yield o.__innerInit.call(this,e,t,i,r,n,s);return a===ae.SUCCESS&&l&&this._initRoomPKHandler(l),{code:a,data:l}}))}__innerInitByIdentityChange(e){return m(this,void 0,void 0,(function*(){const{code:t,data:i}=yield this._invoker.push(new qa(this._livingType,e));return t===oe.SUCCESS&&i?(this._initRoomPKHandler(i),this._initWithRoomData(i.offlineKickTime),this._logger.info(le.L_RTC_CLIENT_UPGRADE_TO_ANCHOR_ROOM_R,JSON.stringify({status:_e.SUCCESSED,roomData:i}),e)):this._logger.error(le.L_RTC_CLIENT_UPGRADE_TO_ANCHOR_ROOM_R,JSON.stringify({status:_e.FAILED,code:t}),e),t}))}publish(e){const t=Object.create(null,{publish:{get:()=>super.publish}});return m(this,void 0,void 0,(function*(){return this._store.isMainRoom?t.publish.call(this,e):(this._logger.error(le.L_ABSTRACT_ROOM_PUBLISH_R,JSON.stringify({status:_e.FAILED,code:ae.THE_FUNCTION_IS_DISABLED_IN_PKROOM,msg:"method not available in PK room"})),{code:ae.THE_FUNCTION_IS_DISABLED_IN_PKROOM})}))}unpublish(e){const t=Object.create(null,{unpublish:{get:()=>super.unpublish}});return m(this,void 0,void 0,(function*(){return this._store.isMainRoom?t.unpublish.call(this,e):(this._logger.error(le.L_ABSTRACT_ROOM_UNPUBLISH_R,JSON.stringify({status:_e.FAILED,code:ae.THE_FUNCTION_IS_DISABLED_IN_PKROOM,msg:"method not available in PK room"})),{code:ae.THE_FUNCTION_IS_DISABLED_IN_PKROOM})}))}_isValidResourceId(e){var t;const{userId:i}=_i(e),r=!!(null===(t=this._store.getResourcesByUserId(i))||void 0===t?void 0:t.find((t=>li(t)===e)));let n=!1;const{code:s,roomPKHandler:o}=this.getRoomPKHandler();if(s!==ae.SUCCESS||!o)return r;const a=o.getJoinedPKRooms(),l=[];return Object.values(a).forEach((e=>{l.push(...e.getRemoteTracks())})),n=l.some((t=>e===t.getTrackId())),r||n}getLivingType(){return this._livingType}getMCUConfigBuilder(){return this._store.isMainRoom?this._mcuConfigBuilder:(this._logger.error(le.L_LIVING_ROOM_GET_MCU_CONFIG_BUILDER_O,"the `getMCUConfigBuilder` is disabled in PK room"),{code:ae.THE_FUNCTION_IS_DISABLED_IN_PKROOM})}enableInnerCDN(e){return m(this,void 0,void 0,(function*(){return this._invoker.push(new Ya(this._mcuConfigBuilder.__innerGetValues(),e))}))}_resourceHandle(e,t,i,r,n){const s=Object.create(null,{_resourceHandle:{get:()=>super._resourceHandle}});return m(this,void 0,void 0,(function*(){s._resourceHandle.call(this,e,t,i,r,n)}))}__getCDNEnable(){var e;return!!(null===(e=this._store.getCDNUris())||void 0===e?void 0:e.enableInnerCDN)}__getCDNPushMode(){var e;return null===(e=this._store.getCDNUris())||void 0===e?void 0:e.push_mode}_onJoinedPKRoom(e,t){return m(this,void 0,void 0,(function*(){this._invoker.push(new Ja(e,this._roomPKHandler,t))}))}_getPushOtherRoomsParams(){const e=[];if(!this.isMainRoom()||!this._roomPKHandler)return e;const t=this._roomPKHandler.getJoinedPKRooms();for(const i in t){const r=t[i].getSessionId(),n=this._roomPKHandler.getPKInfo(i);if(!n)continue;const{inviterUserAutoMix:s,inviteeUserAutoMix:o,inviterUserId:a}=n,l=this._context.getCurrentId()===a;e.push({roomId:i,sessionId:r,autoMix:l?!!s:!!o})}return e}getRoomPKHandler(){return this._store.isMainRoom?(this._logger.info(le.L_LIVING_ROOM_GET_ROOM_PK_HANDLER_O,JSON.stringify({status:_e.SUCCESSED})),{code:ae.SUCCESS,roomPKHandler:this._roomPKHandler}):(this._logger.error(le.L_LIVING_ROOM_GET_ROOM_PK_HANDLER_O,JSON.stringify({status:_e.SUCCESSED,code:ae.THE_FUNCTION_IS_DISABLED_IN_PKROOM,msg:"method not available in PK room"})),{code:ae.THE_FUNCTION_IS_DISABLED_IN_PKROOM})}_quitAllPKRoom(){return m(this,void 0,void 0,(function*(){const e=this._roomPKHandler.getJoinedPKRooms();for(const t in e)this._roomPKHandler.leaveOtherRoom(e[t]);this._logger.info(le.L_LIVING_ROOM_QUIT_ALL_PK_ROOM_O,JSON.stringify({status:_e.SUCCESSED,roomIds:Object.keys(e)}))}))}isMainRoom(){return this._store.isMainRoom}}class za extends Da{constructor(e,t,i,r,n,s=To.RTC,o=!1){super(e,t,i,s,r,n,!1,!1,Gs(),o)}}const Qa=new class{constructor(){Object.defineProperty(this,"queue",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"locked",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"taskCount",{enumerable:!0,configurable:!0,writable:!0,value:0})}checkToStart(){return m(this,void 0,void 0,(function*(){if(0===this.queue.length||this.locked)return;this.locked=!0;const{resolve:e,task:t,reject:i}=this.queue.shift();let r;try{r=yield t(),e(r)}catch(e){i(e)}this.locked=!1,this.checkToStart()}))}push(e,t=""){const i=new Promise(((t,i)=>{this.queue.push({resolve:t,task:e,reject:i})}));return this.checkToStart(),i}},Za=(e,t="")=>Qa.push(e,t);class Xa{constructor(e,t,i){Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_pc",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_service",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_rtcToken",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(this,"_liveUrl",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(this,"_subTracks",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_subscribedList",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_reportListener",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_clientSessionId",{enumerable:!0,configurable:!0,writable:!0,value:Gs()}),Object.defineProperty(this,"_store",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_crtUserId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_livingType",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_mediaType",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_subTiny",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_fromRetry",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_appListener",{enumerable:!0,configurable:!0,writable:!0,value:null}),this._crtUserId=this._context.getCurrentId(),this._service=new Ks(t,e,i.mediaServer),this._logger=this._context.logger,this._store=new Do(this._logger,this._clientSessionId,this._context.getAppkey(),this._crtUserId,this._crtUserId,To.LIVE)}_getReqHeaders(e){return m(this,void 0,void 0,(function*(){const t=this._crtUserId;if(!this._rtcToken){const{code:i,data:r}=yield this._context.getRTCToken(t,To.LIVE,e);if(i!==oe.SUCCESS)return{code:ae.SIGNAL_ERROR};this._rtcToken=r.rtcToken}return{code:ae.SUCCESS,headers:{"App-Key":this._context.getAppkey(),UserId:this._crtUserId,RoomId:t,RoomType:To.LIVE,Token:this._rtcToken,"Client-Session-Id":this._clientSessionId}}}))}_clearSubscribeInfo(){var e;this._liveUrl="",this._livingType=null,this._mediaType=null,this._subTiny=!1,this._subTracks.length=0,null===(e=this._pc)||void 0===e||e.destroy(),this._pc=null}_reTryExchange(){return m(this,void 0,void 0,(function*(){var e;this._fromRetry=!0;const{code:t}=yield this.subscribe(this._liveUrl,this._livingType,this._mediaType,this._subTiny);return t===ae.SUCCESS&&(null===(e=this._pc)||void 0===e||e.clearReTryExchangeTimer()),{code:t}}))}subscribe(e,t,i){return m(this,arguments,void 0,(function*(e,t,i,r=!1){return Za((()=>this.__subscribe(e,t,i,r)),"audience-client-sub")}))}__subscribe(e,t,i){return m(this,arguments,void 0,(function*(e,t,i,r=!1){var n;this._logger.info(le.L_AUDIENCE_CLIENT_SUBSCRIBE_T,JSON.stringify({liveUrl:e,livingType:t,mediaType:i,subTiny:r}));const s=[];if(Si(this._context.getNaviInfo()))return this._logger.error(le.L_AUDIENCE_CLIENT_SUBSCRIBE_R,JSON.stringify({status:_e.FAILED,code:ae.PACKAGE_ENVIRONMENT_ERROR,msg:"package environment error"})),{code:ae.PACKAGE_ENVIRONMENT_ERROR,tracks:s};if(!this._fromRetry&&(null===(n=this._pc)||void 0===n||n.clearReTryExchangeTimer()),this._fromRetry=!1,!C(e))return this._logger.error(le.L_AUDIENCE_CLIENT_SUBSCRIBE_R,JSON.stringify({status:_e.FAILED,code:ae.PARAMS_ERROR,msg:`params error -> liveUrl: ${e}`})),{code:ae.PARAMS_ERROR,tracks:s};if(![Fa.AUDIO,Fa.VIDEO].includes(t))return this._logger.error(`livingType is invalid: ${t}`),this._logger.error(le.L_AUDIENCE_CLIENT_SUBSCRIBE_R,JSON.stringify({status:_e.FAILED,code:ae.PARAMS_ERROR,msg:`params error -> livingType: ${t}`})),{code:ae.PARAMS_ERROR,tracks:s};if(![vt.AUDIO_ONLY,vt.VIDEO_ONLY,vt.AUDIO_VIDEO].includes(i))return this._logger.error(le.L_AUDIENCE_CLIENT_SUBSCRIBE_R,JSON.stringify({status:_e.FAILED,code:ae.PARAMS_ERROR,msg:`params error -> -> mediaType: ${i}`})),{code:ae.PARAMS_ERROR,tracks:s};if(this._liveUrl&&this._liveUrl!==e)return this._logger.error(le.L_AUDIENCE_CLIENT_SUBSCRIBE_R,JSON.stringify({status:_e.FAILED,code:ae.BROADCAST_SUB_LIST_NOT_EMPTY,msg:"repeat subscribe"})),{code:ae.BROADCAST_SUB_LIST_NOT_EMPTY,tracks:s};this._pc||(this._pc=new bo(this._context,this._logger,this._reTryExchange.bind(this),this._crtUserId,this._store,void 0,!1),this._pc.on(bo.__INNER_EVENT_TRACK_READY__,this._onTrackReady,this),this._pc.registerReportListener(this._reportListener),this._pc.__reportR3R4ToPolaris()),this._liveUrl=e;const{code:o,headers:a}=yield this._getReqHeaders(t);if(o!==ae.SUCCESS)return this._logger.error(le.L_AUDIENCE_CLIENT_SUBSCRIBE_R,JSON.stringify({status:_e.FAILED,code:o,msg:"getRTCToken failed"})),{code:o,tracks:s};const l=`rc_mcu_${Date.now()}`,_="RongCloudRTC";0===this._subTracks.length&&(this._subTracks.push(new Xt(this._logger,_,l),new ei(this._logger,_,l)),this._pc.updateSubRemoteTracks(this._subTracks.slice()));const c={sdp:yield this._pc.createOffer(!0),liveUrl:e,mediaType:i,simulcast:r?Ys.TINY:Ys.NORMAL,switchstream:!1},d=yield this._service.broadcastSubscribe(a,c);if(d.code!==ae.SUCCESS)return this._logger.error(le.L_AUDIENCE_CLIENT_SUBSCRIBE_R,JSON.stringify({status:_e.FAILED,code:d.code})),{code:d.code,tracks:s};const u=d.data;if(u.resultCode!==ae.SUCCESS)return this._logger.error(le.L_AUDIENCE_CLIENT_SUBSCRIBE_R,JSON.stringify({status:_e.FAILED,code:u.resultCode,msg:u.message})),{code:u.resultCode,tracks:s};this._livingType=t,this._mediaType=i,this._subTiny=r;const{sdp:h,subscribedList:g}=u;this._subscribedList=g;const p=[];return g.forEach((e=>{const{mediaType:t}=e,i=this._subTracks[t];p.push(i),i.__innerSetRemoteMuted(!0)})),this._pc.setRemoteAnswer(h.sdp),p&&this._updateTrackIdSSRCMap(h.sdp,p),this._logger.info(le.L_AUDIENCE_CLIENT_SUBSCRIBE_R,JSON.stringify({status:_e.SUCCESSED,liveUrl:e})),{code:ae.SUCCESS,tracks:p}}))}_updateTrackIdSSRCMap(e,t){t.forEach((t=>{const i=t.getTrackId(),{mediaType:r}=_i(i),{msid:n}=this._subscribedList.filter((e=>e.mediaType===r))[0],s=ea(e,n,r);this._store.setTrackIdSSRCMap(Number(s),i)}))}unsubscribe(){return m(this,void 0,void 0,(function*(){return Za((()=>this.__unsubscribe()),"audience-client-unsub")}))}__unsubscribe(){return m(this,void 0,void 0,(function*(){var e;if(this._logger.info(le.L_AUDIENCE_CLIENT_UNSUBSCRIBE_T,JSON.stringify({liveUrl:this._liveUrl})),null===(e=this._pc)||void 0===e||e.clearReTryExchangeTimer(),!this._rtcToken||!this._liveUrl)return this._logger.warn(le.L_AUDIENCE_CLIENT_UNSUBSCRIBE_R,JSON.stringify({status:_e.FAILED,code:"",msg:"Address does not exist, without unsubscribe"})),{code:ae.SUCCESS};const{headers:t}=yield this._getReqHeaders(),{code:i}=yield this._service.broadcastExit(t);return i!==ae.SUCCESS?this._logger.error(le.L_AUDIENCE_CLIENT_UNSUBSCRIBE_R,JSON.stringify({status:_e.FAILED,code:i})):(this._logger.info(le.L_AUDIENCE_CLIENT_UNSUBSCRIBE_R,JSON.stringify({status:_e.SUCCESSED,liveUrl:this._liveUrl})),this._subscribedList=[]),this._clearSubscribeInfo(),{code:i}}))}registerReportListener(e){this._reportListener=e}registerTrackEventListener(e){this._appListener=e}_onTrackReady(e){var t,i;const{track:r}=e.receiver,n="audio"===r.kind?vt.AUDIO_ONLY:vt.VIDEO_ONLY,s=this._subTracks[n];s.__innerSetMediaStreamTrack(r);try{this._logger.info(le.L_AUDIENCE_CLIENT_CALL_ONTRACKREADY_O,`trackId: ${s.getTrackId()}`),null===(i=null===(t=this._appListener)||void 0===t?void 0:t.onTrackReady)||void 0===i||i.call(t,s)}catch(e){this._logger.error(le.L_AUDIENCE_CLIENT_CALL_ONTRACKREADY_O,JSON.stringify(e))}}}var el,tl;!function(e){e.RTMP="rtmp",e.FLV="flv",e.HLS="hls"}(el||(el={})),function(e){e[e.NOT_HTTPS=0]="NOT_HTTPS",e[e.HTTPS=1]="HTTPS"}(tl||(tl={}));const il=Object.assign(Object.assign({},gi(Ot.W176_H144)),{frameRate:Ei(Lt.FPS_15)});class rl{constructor(e,t,i,r,n,s,o=Gs()){Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_runtime",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_initOptions",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_roomId",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_joinResData",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"livingType",{enumerable:!0,configurable:!0,writable:!0,value:s}),Object.defineProperty(this,"_clientSessionId",{enumerable:!0,configurable:!0,writable:!0,value:o}),Object.defineProperty(this,"_service",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_roomAnchorList",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_roomRes",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_roomAnchorRes",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_remoteTracks",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_appListener",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_pc",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_subscribedList",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_sessionId",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(this,"_destroyed",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_polarisReport",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_audioLevelReport",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_CDNUris",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_isPulling",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_pullTime",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_store",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_crtUserId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_reportMediaActionLogger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_trackMediaMap",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_reportListener",{enumerable:!0,configurable:!0,writable:!0,value:null}),this._logger=this._context.logger,this._crtUserId=this._context.getCurrentId(),this._polarisReport=new Ca(this._context,this._runtime,this._roomId,this,Ea.Audience),this._reportMediaActionLogger=new Sa(this._logger,this._roomId,this._clientSessionId,this._crtUserId),this._service=new Ks(this._runtime,this._context,this._initOptions.mediaServer,this._initOptions.timeout);const a=this._store=new Do(this._logger,o,e.getAppkey(),r,this._crtUserId,To.LIVE),l=this._pc=new bo(this._context,this._logger,this._reTryExchange.bind(this),this._crtUserId,a,this._polarisReport,!0);this._audioLevelReport=new Ao(this._store,l),l.on(bo.__INNER_AUDIOLEVEL_CHANGE__,this._audioLevelReport.audioLevelReport,this._audioLevelReport),this._polarisReport.sendR1(),this._context.registerRTCSignalListener((e=>m(this,void 0,void 0,(function*(){const{time:t,type:i,roomId:r}=this._context.decodeRtcNotify(e);1===i&&this._startPull(r,t)})))),this._setInitData()}_startPull(e,t){return m(this,void 0,void 0,(function*(){if(this._isPulling)return;this._isPulling=!0;if(this._pullTime>t)return void(this._isPulling=!1);const i=this._logger.createTraceId();this._logger.info(le.L_AUDIENCE_LIVING_ROOM_PULL_KVENTRIES_T,`pullTime: ${this._pullTime}`,i);const{code:r,data:n}=yield this._context.pullRTCRoomEntry(e);if(r===oe.SUCCESS){this._isPulling=!1,this._pullTime=(null==n?void 0:n.syncTime)||0;const t=(null==n?void 0:n.kvEntries)||[];this._logger.info(le.L_AUDIENCE_LIVING_ROOM_PULL_KVENTRIES_R,`status: ${_e.SUCCESSED}, kvEntries: ${JSON.stringify(t)}`,i),this.singalDataChange(t,e,i)}this._logger.info(le.L_AUDIENCE_LIVING_ROOM_PULL_KVENTRIES_R,`status: ${_e.FAILED}, code: ${r}`,i)}))}_setInitData(){const{sessionId:e,remoteUserIds:t,remoteRTCUris:i,remoteMUCUris:r,remoteTracks:n,CDNUris:s}=((e,t,i)=>{const r=t.filter((e=>"RC_RTC_SESSIONID"===e.key))[0],n=r?r.value:"",s=t.filter((e=>"RC_ANCHOR_LIST"===e.key)).map((e=>JSON.parse(e.value||"[]")))[0],o=t.filter((e=>e.key.includes("RC_RES_"))).map((e=>JSON.parse(e.value||"{}"))),a=o.length?JSON.parse(o[0].mcu_uris||"[]"):[],l=[];a.forEach((t=>{const{mediaType:r,tag:n}=t,s=r===vt.AUDIO_ONLY?new Xt(i,n,"",e):new ei(i,n,"",e);l.push(s)}));const _=[],c=[];o.forEach((e=>{const t=JSON.parse(e.uris||"[]");_.push(...t),t.forEach((e=>{const{mediaType:t,tag:r,msid:n}=e,s=n.split("_");s.pop();const o=s.join("_"),a=t===vt.AUDIO_ONLY?new Xt(i,r,o):new ei(i,r,o);c.push(a)}))}));const d=t.filter((e=>"RC_CDN"===e.key)).map((e=>{const t=JSON.parse(e.value||"[]");return JSON.parse(t.cdn_uris)[0]}))[0];return{sessionId:n,remoteUserIds:s||[],remoteRTCUris:_,remoteMUCUris:a,remoteRTCTracks:c,remoteMCUTracks:l,remoteTracks:[...c,...l],CDNUris:d||{}}})(this._roomId,this._joinResData.kvEntries,this._logger);this._sessionId=e,this._roomAnchorList=t,n.forEach((e=>{this._remoteTracks[e.getTrackId()]=e})),this._CDNUris=s,i.forEach((e=>{const t=e.msid.split("_")[0];this._roomAnchorRes[t]?this._roomAnchorRes[t].push(e):this._roomAnchorRes[t]=[e];const{ssrc:i,resourceId:r}=JSON.parse(e.uri);this._store.setTrackIdSSRCMap(i,r)})),r.forEach((e=>{const{mediaType:t,tag:i}=e,r=[this._roomId,i,t].join("_");this._roomRes[r]=e;const{ssrc:n}=JSON.parse(e.uri);this._store.setTrackIdSSRCMap(n,r)})),i.forEach((e=>{const t=li(e);this._roomRes[t]=e}))}_assertRoomDestroyed(){if(this._destroyed)return ae.ROOM_HAS_BEEN_DESTROYED}singalDataChange(e,t,i){var r;if(t!==this._roomId)return void this._logger.error(le.L_AUDIENCE_LIVING_ROOM_SINGAL_DATA_CHANGE_P,JSON.stringify({status:_e.FAILED,msg:`roomId inconsistency -> params roomId:${t}, current roomId:${this._roomId}`}),i);const n=[],s=null===(r=e.filter((e=>"RC_CDN"===e.key))[0])||void 0===r?void 0:r.value;s&&this._diffCDNUris(JSON.parse(JSON.parse(s).cdn_uris)[0],i),e.forEach((e=>{const{key:t,value:r,uid:s}=e;if(-1!==t.indexOf("RC_RES_")){const e=JSON.parse(r||"{}"),t=JSON.parse(e.mcu_uris||"[]"),o=JSON.parse(e.uris||"[]");return n.push(...t),void this._diffAnchorResource(o,s,i)}if("RC_ANCHOR_LIST"===t){const e=JSON.parse(r||"[]");this._diffAnchorList(e,i)}})),this._diffRoomResource(n,i)}_diffAnchorList(e,t){const i=e.filter((e=>this._roomAnchorList.indexOf(e)<0)),r=this._roomAnchorList.filter((t=>e.indexOf(t)<0));i.length>0&&this._handleNewJoinedAnchor(i,t),r.length>0&&this._handleLeftedAnchor(r,t)}_handleNewJoinedAnchor(e,t){this._roomAnchorList.push(...e),this._logger.info(le.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O,JSON.stringify({eventType:"onAnchorJoin",list:e}),t),this._callAppListener("onAnchorJoin",e)}_handleLeftedAnchor(e,t){return m(this,void 0,void 0,(function*(){this._roomAnchorList=this._roomAnchorList.filter((t=>!e.includes(t)));const i=[];e.forEach((e=>{i.push(...this.getRemoteTracksByUserId(e)),delete this._roomAnchorRes[e]})),i.length&&(yield this.unsubscribe(i),i.forEach((e=>delete this._remoteTracks[e.getTrackId()]))),this._logger.info(le.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O,JSON.stringify({eventType:"onAnchorLeave",list:e}),t),this._callAppListener("onAnchorLeave",e)}))}_diffRoomResource(e,t){return m(this,void 0,void 0,(function*(){const i=[],r=[],n=[];e.forEach((e=>{const t=li(e),{tag:r,mediaType:s}=_i(t),o=[this._roomId,r,s].join("_"),{ssrc:a}=JSON.parse(e.uri);if(this._store.setTrackIdSSRCMap(a,o),!this._remoteTracks[o]){const t=s===vt.AUDIO_ONLY?new Xt(this._logger,r,"",this._roomId):new ei(this._logger,r,"",this._roomId);i.push(t),this._remoteTracks[o]=t,this._roomRes[t.getTrackId()]=e}n.push(o)})),Object.keys(this._remoteTracks).forEach((e=>{n.indexOf(e)<0&&this._remoteTracks[e].isMCUTrack()&&r.push(this._remoteTracks[e])})),i.length>0&&(this._logger.info(le.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O,JSON.stringify({eventType:"onTrackPublish",trackIds:i.map((e=>e.getTrackId()))}),t),this._callAppListener("onTrackPublish",i)),r.length>0&&this._onUserUnpublish(r,"onTrackUnpublish",t)}))}_dealPublished(e,t,i){return m(this,void 0,void 0,(function*(){const r=e.map(li),n=[],s=[];if(t.forEach((t=>{const i=li(t),o=r.indexOf(i),{userId:a,tag:l,mediaType:_}=_i(i),{ssrc:c}=JSON.parse(t.uri);this._store.setTrackIdSSRCMap(c,i),o>-1?e[o]=t:e.push(t);let d=this._remoteTracks[i];this._roomRes[i]=t,d?d.isSubscribed()&&n.push(d):(d=_===vt.AUDIO_ONLY?new Xt(this._logger,l,a):new ei(this._logger,l,a),this._remoteTracks[i]=d,s.push(d)),d.__innerSetRemoteMuted(0===t.state)})),n.length){const e=n.map((e=>e.getTrackId())),{code:t}=yield Za((()=>this._subscribeHandle(n,!0)));t!==ae.SUCCESS&&this._logger.error(le.L_RESUB_REPUB_RES_R,JSON.stringify({status:_e.FAILED,trackIds:e,code:t}))}this._logger.info(le.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O,JSON.stringify({eventType:"onAnchorTrackPublish",trackIds:s.map((e=>e.getTrackId()))}),i),this._callAppListener("onAnchorTrackPublish",s)}))}_dealUnpublished(e,t,i){return m(this,void 0,void 0,(function*(){const r=t.map(li);for(let t=e.length-1;t>=0;t-=1){const i=e[t];r.includes(li(i))&&e.splice(t,1)}const n=t.map((e=>{const t=li(e);return this._remoteTracks[t]}));yield this._onUserUnpublish(n,"onAnchorTrackUnpublish",i)}))}_dealModified(e,t,i){const r=e.map(li);for(const n of t){const t=li(n);e[r.indexOf(t)].state=n.state;const s=this._remoteTracks[t];s.__innerSetRemoteMuted(0===n.state);const o=s.isAudioTrack()?"onAudioMuteChange":"onVideoMuteChange";this._logger.info(le.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O,JSON.stringify({eventType:o,trackId:s.getTrackId()}),i),this._callAppListener(o,s)}}_diffAnchorResource(e,t,i){return m(this,void 0,void 0,(function*(){const r=this._roomAnchorRes[t]||(this._roomAnchorRes[t]=[]),{publishedList:n,unpublishedList:s,modifiedList:o}=ui(r,e);n.length&&(yield this._dealPublished(r,n,i)),s.length&&(yield this._dealUnpublished(r,s,i)),o.length&&this._dealModified(r,o,i)}))}_onUserUnpublish(e,t,i){return m(this,void 0,void 0,(function*(){yield this.unsubscribe(e),e.forEach((e=>{this._subscribedList=this._subscribedList.filter((t=>t.track.getTrackId()!==e.getTrackId())),delete this._roomRes[e.getTrackId()],e.__innerDestroy(),delete this._remoteTracks[e.getTrackId()]})),this._logger.info(le.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O,JSON.stringify({eventType:t,trackIds:e.map((e=>e.getTrackId()))}),i),this._callAppListener(t,e)}))}_callAppListener(e,...t){var i;const r=null===(i=this._appListener)||void 0===i?void 0:i[e];if(r)try{r(...t)}catch(e){this._logger.error(le.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O,JSON.stringify(e))}}_reTryExchange(){return m(this,void 0,void 0,(function*(){return Za((()=>m(this,void 0,void 0,(function*(){var e;const{reqBody:t}=yield this._createSubscribeParams(this._subscribedList,{},!0),i=yield this._exchangeHandle(t);if(i.code!==ae.SUCCESS)return{code:i.code};const{sdp:r,resultCode:n}=i.data;if(n!==ae.SUCCESS)return{code:n};this._pc.clearReTryExchangeTimer();const s=this._subscribedList.filter((e=>e.track.isMCUTrack()));if(s.length>0){const t=s[0].track.getTrackId(),i=null===(e=this._roomRes[t])||void 0===e?void 0:e.msid,n=[this._roomId,"RongCloudRTC"].join("_");r.sdp=r.sdp.replace(new RegExp(i,"g"),n)}return{code:yield this._pc.setRemoteAnswer(r.sdp)}}))),"audience-retry-exchange")}))}_createSubscribeParams(e,t,i){return m(this,void 0,void 0,(function*(){const r=yield this._pc.createOffer(i),n={resolutionInfo:[]},s={min:0,max:0};Object.keys(t).forEach((e=>{const{mediaStream:i,tinyStream:o}=t[e];[i,o].forEach(((t,i)=>{var o;const a=1===i?[e,"tiny"].join("_"):e;r.sdp=null===(o=r.sdp)||void 0===o?void 0:o.replace(new RegExp(t.id,"g"),a);const l=t.getVideoTracks()[0];if(!l)return;const _=0===i,{width:c,height:d,frameRate:u}=_?oi(l):il;n.resolutionInfo.push({trackId:l.id,simulcast:_?Ys.NORMAL:Ys.TINY,resolution:`${c}x${d}`});const h=Nt(c,d),g=Pt(u);s.min+=h.minBitrate*g,s.max+=h.maxBitrate*g}))}));return{reqBody:{sdp:r,switchstream:!1,newVersionFlag:!0,subscribeList:e.map((e=>({simulcast:e.subTiny?Ys.TINY:Ys.NORMAL,resolution:"",uri:this._roomRes[e.track.getTrackId()].uri})))},dynamicBitrate:s,offer:r}}))}_subscribeHandle(e){return m(this,arguments,void 0,(function*(e,t=!1,i=!1){const r=Date.now(),n=i?Fo.SUB:void 0,s=this._logger.createTraceId();this._logger.info(le.L_AUDIENCE_LIVING_ROOM_SUBSCRIBE_T,JSON.stringify({trackIds:e.map(Li),forceReq:t}),s);if(this._assertRoomDestroyed())return this._logger.error(le.L_AUDIENCE_LIVING_ROOM_SUBSCRIBE_R,JSON.stringify({status:_e.FAILED,code:ae.ROOM_HAS_BEEN_DESTROYED,msg:"room destroyed"}),s),this._reportPubOrSubQualityData(r,e,ae.ROOM_HAS_BEEN_DESTROYED,n),{code:ae.ROOM_HAS_BEEN_DESTROYED};if(!x("tracks",e,(()=>v(e)&&e.length>0&&e.every((e=>e instanceof Zt||e.track instanceof Zt))),!0))return this._logger.error(le.L_AUDIENCE_LIVING_ROOM_SUBSCRIBE_R,JSON.stringify({status:_e.FAILED,code:ae.PARAMS_ERROR,msg:"params error -> tracks"}),s),this._reportPubOrSubQualityData(r,e,ae.PARAMS_ERROR,n),{code:ae.PARAMS_ERROR};this._pc.__reportR3R4ToPolaris(),this._pc.registerReportListener(this._reportListener),this._addPeerCEvent();const o=this._subscribedList.map((e=>Object.assign({},e))),a=e.map((e=>e instanceof Zt?{track:e}:e)),l=[];return a.forEach((e=>{const t=e.track.getTrackId();l.push(t);const i=o.find((e=>e.track.getTrackId()===t));i&&i.subTiny===e.subTiny||(i?i.subTiny=e.subTiny:o.push(e))})),this._polarisReport.sendR2(Bo.SUBSCRIBE,Vo.BEGIN,l),this._updateSubListHandle(o,s,r,n,!0)}))}_addPeerCEvent(){this._pc.on(bo.__INNER_EVENT_TRACK_READY__,(e=>{const t=e.streams[0].id,{track:i}=e.receiver,r=[t,"audio"===i.kind?vt.AUDIO_ONLY:vt.VIDEO_ONLY].join("_"),n=this._remoteTracks[r];n?(n.__innerSetMediaStreamTrack(i),this._logger.info(le.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O,JSON.stringify({eventType:"onTrackReady",trackId:n.getTrackId()})),this._callAppListener("onTrackReady",n)):this._logger.warn(le.L_AUDIENCE_LIVING_ROOM_ONTRACKREADY_O,`cannot found RCRemoteTrack: ${i.id}`)})),this._pc.once(bo.__INNER_ICE_CONNECTED__,(()=>{this._reportMediaActionLogger.reportIceFirstConnectData("sub")}),this),this._pc.on(bo.__INNER_ICE_STATE_CHANGE__,(e=>{const{status:t,time:i,iceCandidatePair:r}=e;r&&this._reportMediaActionLogger.recordQualityIceStatusData(r,t,i)}))}_getReqHeaders(){const e=this._crtUserId;return{"App-Key":this._context.getAppkey(),RoomId:e,Token:this._joinResData.token,RoomType:To.LIVE,UserId:e,"Session-Id":this._sessionId,"Client-Session-Id":this._clientSessionId}}_exchangeHandle(e){return this._service.broadcastSubscribe(this._getReqHeaders(),e)}_dealSubscribeResult(e,t,i){const r=null==t?void 0:t.map((e=>`${e.msid}_${e.mediaType}`)),n=e.filter((e=>{if(e.track.isMCUTrack()){const t=this._roomRes[e.track.getTrackId()],i=`${t.msid}_${t.mediaType}`;return r.includes(i)}return null==r?void 0:r.includes(e.track.getTrackId())})),s=null==n?void 0:n.map((e=>`${e.track.getTrackId()}`)),o=e.filter((e=>!(null==s?void 0:s.includes(e.track.getTrackId()))));for(const e in this._remoteTracks){const t=n.some((t=>t.track.getTrackId()===e));this._remoteTracks[e].__innerSetSubscribed(t)}return this._subscribedList.splice(0,this._subscribedList.length,...n),this._logger.info(le.L_AUDIENCE_LIVING_ROOM_UPDATE_SUBSCRIBELIST_R,JSON.stringify({status:_e.SUCCESSED,subSuccessTrackIds:r,failedList:o}),i),o}_getParams(e){let t=e.map((e=>e instanceof Zt?{track:e}:Object.assign({},e)));const i={};return t=t.filter((e=>{const t=e.track.getTrackId();return!i[t]&&(i[t]=!0,!0)})).map((e=>Object.assign({},e))),t}_reportPubOrSubQualityData(e,t,i,r){r&&this._reportMediaActionLogger.reportPubOrSubQualityData(r,e,t,i,this._trackMediaMap)}_updateSubListHandle(e,t,i,r){return m(this,arguments,void 0,(function*(e,t,i,r,n=!1){var s;this._logger.info(le.L_AUDIENCE_LIVING_ROOM_UPDATE_SUBSCRIBELIST_T,JSON.stringify({trackIds:e.map(Li),forceReq:n}),t);const o=this._getParams(e),a=this._subscribedList.map((e=>Object.assign({},e)));if(!n&&!ta(o,a))return this._logger.info(le.L_AUDIENCE_LIVING_ROOM_UPDATE_SUBSCRIBELIST_R,JSON.stringify({status:_e.SUCCESSED,msg:"repeat subscribe"}),t),{code:ae.SUCCESS};this._pc.clearReTryExchangeTimer(),this._pc.updateSubRemoteTracks(o.map((e=>e.track)));const{reqBody:l}=yield this._createSubscribeParams(o,{},!1),_=yield this._exchangeHandle(l);if(a.length){const e=[];a.forEach((t=>{e.push(t.track.getTrackId())})),null===(s=this._pc.reportParser)||void 0===s||s.clearLatestPacketsRecv(e)}if(e.forEach((e=>{const t=e instanceof Zt?e.getTrackId():e.track.getTrackId();this._trackMediaMap[t]=_.qualityMsList||[]})),_.code!==ae.SUCCESS)return this._reportPubOrSubQualityData(i,e,_.code,r),this._logger.error(le.L_AUDIENCE_LIVING_ROOM_UPDATE_SUBSCRIBELIST_R,JSON.stringify({status:_e.FAILED,code:_.code}),t),{code:_.code};const{sdp:c,resultCode:d,message:u,subscribedList:h}=_.data;if(d!==ae.SUCCESS)return this._reportPubOrSubQualityData(i,e,d,r),this._logger.error(le.L_AUDIENCE_LIVING_ROOM_UPDATE_SUBSCRIBELIST_R,JSON.stringify({status:_e.FAILED,code:d,msg:u}),t),{code:d};o.forEach((e=>{const{track:t}=e;if(t.isMCUTrack()){const e=this._roomRes[t.getTrackId()].msid,{tag:i,userId:r}=_i(t.getTrackId()),n=[r,i].join("_");c.sdp=c.sdp.replace(new RegExp(e,"g"),n)}}));const g=yield this._pc.setRemoteAnswer(c.sdp);if(this._reportPubOrSubQualityData(i,e,g,r),g!==ae.SUCCESS)return this._logger.error(le.L_AUDIENCE_LIVING_ROOM_UPDATE_SUBSCRIBELIST_R,JSON.stringify({status:_e.FAILED,code:g,msg:"set remote answer error"}),t),{code:g};const p=this._dealSubscribeResult(o,h,t);return p.length?{code:ae.SUCCESS,failedList:p}:{code:ae.SUCCESS}}))}_diffCDNUris(e,t){return m(this,void 0,void 0,(function*(){if(this._CDNUris.url&&!e.url)return this._logger.info(le.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O,JSON.stringify({eventType:"onCDNInfoDisable"}),t),this._callAppListener("onCDNInfoDisable"),void(this._CDNUris=e);(!this._CDNUris||!this._CDNUris.url&&e.url)&&(this._logger.info(le.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O,JSON.stringify({eventType:"onCDNInfoEnable",resolution:`W${e.w}_H${e.h}`,fps:`FPS_${e.fps}`}),t),this._callAppListener("onCDNInfoEnable",{resolution:`W${e.w}_H${e.h}`,fps:`FPS_${e.fps}`}));const i=this._CDNUris.w&&e.w&&this._CDNUris.w!==e.w,r=this._CDNUris.h&&e.h&&this._CDNUris.h!==e.h,n=this._CDNUris.fps&&e.fps&&this._CDNUris.fps!==e.fps;(i||r||n)&&(this._logger.info(le.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O,JSON.stringify({eventType:"onCDNInfoChange",resolution:`W${e.w}_H${e.h}`,fps:`FPS_${e.fps}`}),t),this._callAppListener("onCDNInfoChange",{resolution:`W${e.w}_H${e.h}`,fps:`FPS_${e.fps}`})),this._CDNUris=e}))}_getCDNPlayUrl(e,t){return m(this,void 0,void 0,(function*(){const{w:i,h:r,fps:n}=e,s=this._initOptions.pullInnerCDNProtocol||el.FLV,o=this._initOptions.pullInnerCDNUseHttps===tl.NOT_HTTPS?tl.NOT_HTTPS:tl.HTTPS;if(!this._CDNUris.url)return this._logger.error(le.L_AUDIENCE_LIVING_ROOM_GET_CDN_PLAY_URL_R,JSON.stringify({status:_e.FAILED,code:ae.CDN_RESOURCE_IS_EMPTY,msg:"cdn_uris url is empty, the anchor need to open or push CDN"}),t),{code:ae.CDN_RESOURCE_IS_EMPTY};const a={"App-Key":this._context.getAppkey(),Token:this._joinResData.token,RoomId:this.getRoomId(),UserId:this._crtUserId,SessionId:this.getSessionId()},l=[],{w:_=0,h:c=1}=this._CDNUris;_/c>1?(i&&l.push(`w=${i}`),r&&l.push(`h=${r}`)):(i&&l.push(`h=${i}`),r&&l.push(`w=${r}`)),n&&l.push(`fps=${n}`),l.push(`kind=${s}`),l.push(`is_https=${o}`);const d=l.join("&");let u=`${this._CDNUris.url}?`;d&&(u+=d);const{code:h,res:g}=yield this._service.getCDNResourceInfo(a,u,t);return h!==ae.SUCCESS?{code:h}:{code:h,CDNPlayUrl:null==g?void 0:g.data.pull_url}}))}getCDNPlayUrl(e,t){return m(this,void 0,void 0,(function*(){const i=this._logger.createTraceId();if(this._logger.info(le.L_AUDIENCE_LIVING_ROOM_GET_CDN_PLAY_URL_T,JSON.stringify({resolution:e,fps:t}),i),e&&!pi(e))return this._logger.error(le.L_AUDIENCE_LIVING_ROOM_GET_CDN_PLAY_URL_R,JSON.stringify({status:_e.FAILED,code:ae.PARAMS_ERROR,msg:"params error -> resolution"}),i),{code:ae.PARAMS_ERROR};if(t&&!fi(t))return this._logger.error(le.L_AUDIENCE_LIVING_ROOM_GET_CDN_PLAY_URL_R,JSON.stringify({status:_e.FAILED,code:ae.PARAMS_ERROR,msg:"params error -> fps"}),i),{code:ae.PARAMS_ERROR};const{width:r,height:n}=e?gi(e):{width:null,height:null},s=t?Ei(t):null,o={};return r&&(o.w=r),n&&(o.h=n),s&&(o.fps=s),this._getCDNPlayUrl(o,i)}))}subscribe(e){return m(this,void 0,void 0,(function*(){return Za((()=>this._subscribeHandle(e,!1,!0)),"audience-sub")}))}__unsubscribe(e){return m(this,void 0,void 0,(function*(){const t=Date.now(),i=Fo.UNSUB,r=this._logger.createTraceId();this._logger.info(le.L_AUDIENCE_LIVING_ROOM_UNSUBSCRIBE_T,JSON.stringify({trackIds:e.map((e=>e.getTrackId()))}),r);if(this._assertRoomDestroyed())return this._logger.error(le.L_AUDIENCE_LIVING_ROOM_UNSUBSCRIBE_R,JSON.stringify({status:_e.FAILED,code:ae.ROOM_HAS_BEEN_DESTROYED,msg:"room destroyed"}),r),{code:ae.ROOM_HAS_BEEN_DESTROYED};if(!x("tracks",e,(()=>v(e)&&e.length>0&&e.every((e=>e instanceof Zt))),!0))return this._logger.error(le.L_AUDIENCE_LIVING_ROOM_UNSUBSCRIBE_R,JSON.stringify({status:_e.FAILED,code:ae.PARAMS_ERROR,msg:"params error -> tracks"}),r),{code:ae.PARAMS_ERROR};const n=this._subscribedList.map((e=>Object.assign({},e))).filter((t=>e.every((e=>e.getTrackId()!==t.track.getTrackId()))));return this._polarisReport.sendR2(Bo.SUBSCRIBE,Vo.END,e.map((e=>e.getTrackId()))),this._updateSubListHandle(n,r,t,i,!1)}))}unsubscribe(e){return m(this,void 0,void 0,(function*(){return Za((()=>this.__unsubscribe(e)),"audience-unsub")}))}__destroy(e){return m(this,void 0,void 0,(function*(){var t;this._destroyed||(this._destroyed=!0,e&&(yield this._context.quitLivingRoomAsAudience(this._roomId)),yield this._service.broadcastExit(this._getReqHeaders()),null===(t=this._pc)||void 0===t||t.destroy(),this._context.registerRTCSignalListener())}))}getRemoteTrack(e){return this._remoteTracks[e]}getLocalTrack(e){return{}}__onReconnected(){return m(this,void 0,void 0,(function*(){const e=this._logger.createTraceId();this._logger.info(le.L_AUDIENCE_LIVING_ROOM_IM_RECONNECTED_T,void 0,e);const{code:t}=yield this._context.joinLivingRoomAsAudience(this._roomId,To.LIVE);t!==oe.SUCCESS&&this._logger.error(le.L_AUDIENCE_LIVING_ROOM_IM_RECONNECTED_R,`status: ${_e.FAILED}`,e),this._logger.info(le.L_AUDIENCE_LIVING_ROOM_IM_RECONNECTED_R,`status: ${_e.SUCCESSED}`,e)}))}registerRoomEventListener(e){this._appListener=e}onAudioLevelChange(e,t){this._logger.info(le.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O),this._audioLevelReport.onAudioLevelChange(e)}registerReportListener(e){this._reportListener=e}getRoomId(){return this._roomId}getCrtUserId(){return this._crtUserId}getSessionId(){return this._sessionId}getRemoteUserIds(){return this._roomAnchorList}getRemoteTracksByUserId(e){const t=[];for(const i in this._remoteTracks){const r=this._remoteTracks[i];r.getUserId()===e&&t.push(r)}return t}getRemoteTracks(){const e=[],t=[];for(const e in this._remoteTracks){if(2===t.length)break;const i=this._remoteTracks[e];i.isMCUTrack()&&t.push(i)}return this._roomAnchorList.forEach((t=>{e.push(...this.getRemoteTracksByUserId(t))})),[...t,...e]}getRemoteRTCTracks(){const e=[];for(const t in this._remoteTracks){const i=this._remoteTracks[t];i.isMCUTrack()||e.push(i)}return e}getRemoteMCUTracks(){const e=[];for(const t in this._remoteTracks){const i=this._remoteTracks[t];i.isMCUTrack()&&e.push(i)}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}}getClientSessionId(){return this._clientSessionId}}var nl;!function(e){e[e.AUTOMATIC=0]="AUTOMATIC",e[e.MANUAL=1]="MANUAL"}(nl||(nl={}));class sl{constructor(e){Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_isElectron",{enumerable:!0,configurable:!0,writable:!0,value:/Electron/.test(navigator.userAgent)}),this._logger=e.logger}_getMediaStream(e){return m(this,arguments,void 0,(function*(e,t="getUserMedia"){try{const i=this.setConstraintsConfig(e),r=yield navigator.mediaDevices[t](i);return{code:ae.SUCCESS,stream:r}}catch(e){if(this._logger.error(le.L_GET_MEDIA_STREAM_E,JSON.stringify({name:e.name,message:e.message})),"Permission denied"===e.message)return{code:ae.BROWSER_PERMISSION_DENIED};if("Permission denied by system"===e.message)return{code:ae.SYSTEM_PERMISSION_DENIED}}return{code:"getUserMedia"===t?ae.GET_USER_MEDIA_FAILED:ae.GET_DISPLAY_MEDIA_FAILED}}))}_getMediaStreamErrorReason(e){let t="";return e===ae.BROWSER_PERMISSION_DENIED&&(t="Permission denied"),e===ae.SYSTEM_PERMISSION_DENIED&&(t="Permission denied by system"),t}setConstraintsConfig(e){var t,i;if((null==e?void 0:e.audio)&&!this._isElectron){"boolean"==typeof e.audio&&(e.audio={});const r=null===(i=(t=navigator.mediaDevices).getSupportedConstraints)||void 0===i?void 0:i.call(t);(null==r?void 0:r.noiseSuppression)&&(e.audio.noiseSuppression=!!r.noiseSuppression),(null==r?void 0:r.autoGainControl)&&(e.audio.autoGainControl=!!r.autoGainControl),(null==r?void 0:r.echoCancellation)&&(e.audio.echoCancellation=!!r.echoCancellation),this._logger.info(le.L_SET_AUDIO_CONSTRAINTS_O,`browser supported -> ${JSON.stringify(r)}`)}return e}createMicrophoneAudioTrack(){return m(this,arguments,void 0,(function*(e="RongCloudRTC",t){if(!ni(e))return this._logger.error(le.L_RTC_CLIENT_CREATE_MICROPHONE_AUDIO_TRACK_O,JSON.stringify({status:_e.FAILED,code:ae.INVALID_TAGS,msg:"invalid tag"})),{code:ae.INVALID_TAGS};const i=this._context.getCurrentId();if(!i)return this._logger.error(le.L_RTC_CLIENT_CREATE_MICROPHONE_AUDIO_TRACK_O,JSON.stringify({status:_e.FAILED,code:ae.INVALID_USER_ID,msg:"invalid IM connection,invalid userId"})),{code:ae.INVALID_USER_ID};const{stream:r,code:n}=yield this._getMediaStream({audio:{deviceId:(null==t?void 0:t.micphoneId)?{exact:null==t?void 0:t.micphoneId}:void 0,sampleRate:null==t?void 0:t.sampleRate,noiseSuppression:null==t?void 0:t.noiseSuppression,echoCancellation:null==t?void 0:t.echoCancellation,autoGainControl:null==t?void 0:t.autoGainControl}});if(n!==ae.SUCCESS)return this._logger.error(le.L_RTC_CLIENT_CREATE_MICROPHONE_AUDIO_TRACK_O,JSON.stringify({status:_e.FAILED,code:n,msg:this._getMediaStreamErrorReason(n)})),{code:n};const s=r.getAudioTracks()[0],o=new qt(this._logger,e,i,s);return this._logger.info(le.L_RTC_CLIENT_CREATE_MICROPHONE_AUDIO_TRACK_O,JSON.stringify({status:_e.SUCCESSED,trackId:o.getTrackId()})),{code:n,track:o}}))}createCameraVideoTrack(){return m(this,arguments,void 0,(function*(e="RongCloudRTC",t){if(!ni(e))return this._logger.error(le.L_RTC_CLIENT_CREATE_CAMERA_VIDEO_TRACK_O,JSON.stringify({status:_e.FAILED,code:ae.INVALID_TAGS,msg:"invalid tag"})),{code:ae.INVALID_TAGS};const i=this._context.getCurrentId();if(!i)return this._logger.error(le.L_RTC_CLIENT_CREATE_CAMERA_VIDEO_TRACK_O,JSON.stringify({status:_e.FAILED,code:ae.INVALID_USER_ID,msg:"invalid IM connection,invalid userId"})),{code:ae.INVALID_USER_ID};const r=pi(null==t?void 0:t.resolution)?t.resolution:Ot.W640_H480,{width:n,height:s}=gi(r),{stream:o,code:a}=yield this._getMediaStream({video:{deviceId:(null==t?void 0:t.cameraId)?{exact:null==t?void 0:t.cameraId}:void 0,frameRate:Ei((null==t?void 0:t.frameRate)||Lt.FPS_15),width:{ideal:n,max:n},height:{ideal:s,max:s},facingMode:null==t?void 0:t.faceMode}});if(a!==ae.SUCCESS)return this._logger.error(le.L_RTC_CLIENT_CREATE_CAMERA_VIDEO_TRACK_O,JSON.stringify({status:_e.FAILED,code:a,msg:this._getMediaStreamErrorReason(a)})),{code:a};const l=o.getVideoTracks()[0];yield this._applyVideoAspectRatio(l,n,s);const _=new Wt(this._logger,e,i,l);return this._logger.info(le.L_RTC_CLIENT_CREATE_CAMERA_VIDEO_TRACK_O,JSON.stringify({status:_e.SUCCESSED,trackId:_.getTrackId()})),{code:a,track:_}}))}createMicrophoneAndCameraTracks(){return m(this,arguments,void 0,(function*(e="RongCloudRTC",t){var i;const r=[];if(!ni(e))return this._logger.error(le.L_RTC_CLIENT_CREATE_MICROPHONE_AND_CAMERA_TRACKS_O,JSON.stringify({status:_e.FAILED,code:ae.INVALID_TAGS,msg:"invalid tag"})),{code:ae.INVALID_TAGS,tracks:r};const n=this._context.getCurrentId();if(!n)return this._logger.error(le.L_RTC_CLIENT_CREATE_MICROPHONE_AND_CAMERA_TRACKS_O,JSON.stringify({status:_e.FAILED,code:ae.INVALID_USER_ID,msg:"invalid IM connection,invalid userId"})),{code:ae.INVALID_USER_ID,tracks:r};const s=pi(null===(i=null==t?void 0:t.video)||void 0===i?void 0:i.resolution)?t.video.resolution:Ot.W640_H480,{width:o,height:a}=gi(s),l=null==t?void 0:t.audio,_=null==t?void 0:t.video,{stream:c,code:d}=yield this._getMediaStream({video:{deviceId:(null==_?void 0:_.cameraId)?{exact:null==_?void 0:_.cameraId}:void 0,frameRate:Ei((null==_?void 0:_.frameRate)||Lt.FPS_15),width:{ideal:o,max:o},height:{ideal:a,max:a},facingMode:null==_?void 0:_.faceMode},audio:{deviceId:(null==l?void 0:l.micphoneId)?{exact:null==l?void 0:l.micphoneId}:void 0,sampleRate:null==l?void 0:l.sampleRate,noiseSuppression:null==l?void 0:l.noiseSuppression,echoCancellation:null==l?void 0:l.echoCancellation,autoGainControl:null==l?void 0:l.autoGainControl}});if(d!==ae.SUCCESS)return this._logger.error(le.L_RTC_CLIENT_CREATE_MICROPHONE_AND_CAMERA_TRACKS_O,JSON.stringify({status:_e.FAILED,code:d,msg:this._getMediaStreamErrorReason(d)})),{code:d,tracks:r};const u=c.getTracks();for(let t=0;t<u.length;t++){const i=u[t];"video"===i.kind?(yield this._applyVideoAspectRatio(i,o,a),r.push(new Wt(this._logger,e,n,i))):r.unshift(new qt(this._logger,e,n,i))}return this._logger.info(le.L_RTC_CLIENT_CREATE_MICROPHONE_AND_CAMERA_TRACKS_O,JSON.stringify({status:_e.SUCCESSED,trackIds:r.map((e=>e.getTrackId()))})),{code:d,tracks:r}}))}createScreenVideoTrack(){return m(this,arguments,void 0,(function*(e="screenshare",t){const i=yield this._createScreenTracks(e,!1,le.L_RTC_CLIENT_CREATE_SCREEN_VIDEO_TRACK_O,t);return i.code===ae.SUCCESS?{code:i.code,track:i.tracks[0]}:i}))}createScreenWithAudioTracks(){return m(this,arguments,void 0,(function*(e="screenshare",t){return this._createScreenTracks(e,!0,le.L_RTC_CLIENT_CREATE_SCREEN_VIDEO_AND_AUDIO_TRACKS_O,t)}))}_createScreenTracks(e,t,i,r){return m(this,void 0,void 0,(function*(){if(!ni(e))return this._logger.error(i,JSON.stringify({status:_e.FAILED,code:ae.INVALID_TAGS,msg:"invalid tag"})),{code:ae.INVALID_TAGS};const n=this._context.getCurrentId();if(!n)return this._logger.error(i,JSON.stringify({status:_e.FAILED,code:ae.INVALID_USER_ID,msg:"invalid IM connection,invalid userId"})),{code:ae.INVALID_USER_ID};if(!mi())return this._logger.error(le.L_RTC_CLIENT_CREATE_SCREEN_VIDEO_TRACK_O,JSON.stringify({status:_e.FAILED,code:ae.BROWSER_NOT_SUPPORT,msg:"browser not support"})),{code:ae.BROWSER_NOT_SUPPORT};const s=/macintosh|mac os x/i.test(navigator.userAgent),o=(!this._isElectron||!s)&&t,a=pi(null==r?void 0:r.resolution)?r.resolution:Ot.W1280_H720,{stream:l,code:_}=this._isElectron?yield this._createElectronScreenStream(t,i,a,null==r?void 0:r.chromeMediaSourceId):yield this._createWebScreenStream(t,a,null==r?void 0:r.frameRate);if(_!==ae.SUCCESS)return this._logger.error(i,JSON.stringify({status:_e.FAILED,code:_,msg:this._getMediaStreamErrorReason(_)})),{code:_};const c=l.getVideoTracks()[0],d=[new zt(this._logger,e,n,c)];if(o){const t=l.getAudioTracks()[0];t&&d.push(new Qt(this._logger,e,n,t))}return this._logger.info(i,JSON.stringify({status:_e.SUCCESSED,trackIds:d.map((e=>e.getTrackId()))})),{code:_,tracks:d}}))}_createElectronScreenStream(e,t,i,r){return m(this,void 0,void 0,(function*(){var n,s;const o=/macintosh|mac os x/i.test(navigator.userAgent);this._isElectron&&o&&e&&this._logger.warn(t,JSON.stringify({status:_e.INFO,code:ae.MAC_IN_ELECTRON_NOT_SUPPORT_SCREEN_SHARE_WITH_AUDIO,msg:"mac in electron not support screen share with audio"}));const a=(!this._isElectron||!o)&&e;if(this._isElectron&&!P(r)&&!C(r))return this._logger.error(t,JSON.stringify({status:_e.FAILED,code:ae.PARAMS_ERROR,msg:"params error -> options.chromeMediaSourceId type is string"})),{code:ae.PARAMS_ERROR};const{width:l,height:_}=gi(i),c={mandatory:{chromeMediaSourceId:r,chromeMediaSource:"desktop",minWidth:l,maxWidth:l,minHeight:_,maxHeight:_}};!r&&this._isElectron&&(null===(n=c.mandatory)||void 0===n||delete n.chromeMediaSourceId);let d=null;return a&&this._isElectron&&(null===(s=c.mandatory)||void 0===s||delete s.chromeMediaSourceId,d={mandatory:{chromeMediaSource:"desktop"}}),this._getMediaStream({video:c,audio:d||a},"getUserMedia")}))}_createWebScreenStream(e,t,i){return m(this,void 0,void 0,(function*(){const{width:r,height:n}=gi(t),s={frameRate:Ei(i||Lt.FPS_15),width:r,height:n};return this._getMediaStream({video:s,audio:e},"getDisplayMedia")}))}createLocalAudioTrack(e,t){return m(this,void 0,void 0,(function*(){if(!ni(e))return this._logger.error(le.L_RTC_CLIENT_CREATE_LOCAL_AUDIO_TRACK_O,JSON.stringify({status:_e.FAILED,code:ae.INVALID_TAGS,msg:"invalid tag"})),{code:ae.INVALID_TAGS};if(!t||"[object MediaStreamTrack]"!==t.toString()||"audio"!==t.kind)return this._logger.error(le.L_RTC_CLIENT_CREATE_LOCAL_AUDIO_TRACK_O,JSON.stringify({status:_e.FAILED,code:ae.CREATE_CUSTOM_TRACK_FAILED,msg:"params track is not MediaStreamTrack or kind is not audio"})),{code:ae.CREATE_CUSTOM_TRACK_FAILED};const i=this._context.getCurrentId();if(!i)return this._logger.error(le.L_RTC_CLIENT_CREATE_LOCAL_AUDIO_TRACK_O,JSON.stringify({status:_e.FAILED,code:ae.INVALID_USER_ID,msg:"invalid IM connection,invalid userId"})),{code:ae.INVALID_USER_ID};const r=new Ht(this._logger,e,i,t);return this._logger.info(le.L_RTC_CLIENT_CREATE_LOCAL_AUDIO_TRACK_O,JSON.stringify({status:_e.SUCCESSED,trackId:r.getTrackId()})),{code:ae.SUCCESS,track:r}}))}createLocalVideoTrack(e,t){return m(this,void 0,void 0,(function*(){if(!ni(e))return this._logger.error(le.L_RTC_CLIENT_CREATE_LOCAL_VIDEO_TRACK_O,JSON.stringify({status:_e.FAILED,code:ae.INVALID_TAGS,msg:"invalid tag"})),{code:ae.INVALID_TAGS};if(!(t&&t instanceof MediaStreamTrack&&"video"===t.kind))return this._logger.error(le.L_RTC_CLIENT_CREATE_LOCAL_VIDEO_TRACK_O,JSON.stringify({status:_e.FAILED,code:ae.CREATE_CUSTOM_TRACK_FAILED,msg:"params track is not MediaStreamTrack or kind is not video"})),{code:ae.CREATE_CUSTOM_TRACK_FAILED};const i=this._context.getCurrentId();if(!i)return this._logger.error(le.L_RTC_CLIENT_CREATE_LOCAL_VIDEO_TRACK_O,JSON.stringify({status:_e.FAILED,code:ae.INVALID_USER_ID,msg:"invalid IM connection,invalid userId"})),{code:ae.INVALID_USER_ID};const r=new Jt(this._logger,e,i,t);return this._logger.info(le.L_RTC_CLIENT_CREATE_LOCAL_VIDEO_TRACK_O,JSON.stringify({status:_e.SUCCESSED,trackId:r.getTrackId()})),{code:ae.SUCCESS,track:r}}))}_validateCreateLocalFileTracks(e,t){if(!ni(e))return this._logger.error(le.L_RTC_CLIENT_CREATE_LOCAL_FILE_TRACKS_O,JSON.stringify({status:_e.FAILED,code:ae.INVALID_TAGS,msg:"invalid tag"})),{code:ae.INVALID_TAGS,tracks:[]};if(!Ti())return this._logger.error(le.L_RTC_CLIENT_CREATE_LOCAL_FILE_TRACKS_O,JSON.stringify({status:_e.FAILED,code:ae.BROWSER_NOT_SUPPORT,msg:"browser not support"})),{code:ae.BROWSER_NOT_SUPPORT,tracks:[]};const i=t instanceof File?URL.createObjectURL(t):t;if(!U(i)&&!/^blob:/.test(i))return this._logger.error(le.L_RTC_CLIENT_CREATE_LOCAL_FILE_TRACKS_O,JSON.stringify({status:_e.FAILED,code:ae.PARAMS_ERROR,msg:"params error -> file"})),{code:ae.PARAMS_ERROR,tracks:[]};return this._context.getCurrentId()?{code:ae.SUCCESS,tracks:[],url:i}:(this._logger.error(le.L_RTC_CLIENT_CREATE_LOCAL_FILE_TRACKS_O,JSON.stringify({status:_e.FAILED,code:ae.INVALID_USER_ID,msg:"invalid IM connection,invalid userId"})),{code:ae.INVALID_USER_ID,tracks:[]})}createLocalFileTracks(e,t,i){return m(this,void 0,void 0,(function*(){const r=this._validateCreateLocalFileTracks(e,t);if(r.code!==ae.SUCCESS)return r;const n=this._context.getCurrentId();return new Promise((t=>{const s=document.createElement("video");(null==i?void 0:i.withoutAudio)&&(s.muted=!0),s.onloadedmetadata=()=>{const r=[];let o;try{const e=s.mozCaptureStream?"mozCaptureStream":"captureStream";o=s[e]()}catch(e){this._logger.error(le.L_RTC_CLIENT_CREATE_LOCAL_FILE_TRACKS_O,JSON.stringify({status:_e.FAILED,code:ae.CREATE_FILE_TRACK_FAILED,msg:`captureSteam error -> ${JSON.stringify(e)}`})),t({code:ae.CREATE_FILE_TRACK_FAILED,tracks:r})}const[a,l]=sl.getTracksWithOptions(o,i);a&&r.push(new Yt(this._logger,e,n,a,s)),l&&r.push(new Kt(this._logger,e,n,l,s)),0===r.length&&(s.pause(),s.src=""),s.onerror=null,this._logger.info(le.L_RTC_CLIENT_CREATE_LOCAL_FILE_TRACKS_O,JSON.stringify({status:_e.SUCCESSED,trackIds:r.map((e=>e.getTrackId()))})),t({code:ae.SUCCESS,tracks:r})},s.onerror=()=>{this._logger.error(le.L_RTC_CLIENT_CREATE_LOCAL_FILE_TRACKS_O,JSON.stringify({status:_e.FAILED,code:ae.CREATE_FILE_TRACK_FAILED,msg:"Failed to create file stream, video onerror"})),t({code:ae.CREATE_FILE_TRACK_FAILED,tracks:[]})},s.src=r.url,s.loop=!0,s.play()}))}))}createLocalTracks(e,t,i){return m(this,void 0,void 0,(function*(){const r=[];if(!ni(e))return this._logger.error(le.L_RTC_CLIENT_CREATE_LOCAL_TRACKS_O,JSON.stringify({status:_e.FAILED,code:ae.INVALID_TAGS,msg:"invalid tag"})),{code:ae.INVALID_TAGS,tracks:r};if(!(t instanceof MediaStream))return this._logger.error(le.L_RTC_CLIENT_CREATE_LOCAL_TRACKS_O,JSON.stringify({status:_e.FAILED,code:ae.PARAMS_ERROR,msg:"params error -> stream"})),{code:ae.PARAMS_ERROR,tracks:r};const n=this._context.getCurrentId();if(!n)return this._logger.error(le.L_RTC_CLIENT_CREATE_LOCAL_TRACKS_O,JSON.stringify({status:_e.FAILED,code:ae.INVALID_USER_ID,msg:"invalid IM connection,invalid userId"})),{code:ae.INVALID_USER_ID,tracks:r};const[s,o]=sl.getTracksWithOptions(t,i);return s&&r.push(new Ht(this._logger,e,n,s)),o&&r.push(new Jt(this._logger,e,n,o)),this._logger.info(le.L_RTC_CLIENT_CREATE_LOCAL_TRACKS_O,JSON.stringify({status:_e.SUCCESSED,trackIds:r.map((e=>e.getTrackId()))})),{code:ae.SUCCESS,tracks:r}}))}static getTracksWithOptions(e,t){const i=[];return i[0]=(null==t?void 0:t.withoutAudio)?void 0:e.getAudioTracks()[0],i[1]=(null==t?void 0:t.withoutVideo)?void 0:e.getVideoTracks()[0],i}_applyVideoAspectRatio(e,t,i){return m(this,void 0,void 0,(function*(){const{width:r,height:n}=e.getSettings();if(r===t&&n===i)return;const s=t/i>=1?{width:{ideal:r,max:r}}:{height:{ideal:n,max:n}};try{yield e.applyConstraints(Object.assign(Object.assign({},s),{aspectRatio:{ideal:t/i}})),this._logger.info(le.L_RTC_CLIENT_APPLY_VIDEO_ASPECT_RATIO_O,JSON.stringify({status:_e.SUCCESSED,msg:`apply aspectRatio success -> ${t} / ${i}`}))}catch(e){this._logger.warn(le.L_RTC_CLIENT_APPLY_VIDEO_ASPECT_RATIO_O,JSON.stringify({status:_e.FAILED,msg:`apply aspectRatio error -> ${JSON.stringify(e)}`}))}}))}}const ol=function(){var e,t={},i=function(e){var t=function(e,i,n){if(void 0===e&&(e=t.DEFAULT_CAPACITY),void 0===i&&(i=t.DEFAULT_ENDIAN),void 0===n&&(n=t.DEFAULT_NOASSERT),!n){if((e|=0)<0)throw RangeError("Illegal capacity");i=!!i,n=!!n}this.buffer=0===e?r:new ArrayBuffer(e),this.view=0===e?null:new Uint8Array(this.buffer),this.offset=0,this.markedOffset=-1,this.limit=e,this.littleEndian=i,this.noAssert=n};t.VERSION="5.0.1",t.LITTLE_ENDIAN=!0,t.BIG_ENDIAN=!1,t.DEFAULT_CAPACITY=16,t.DEFAULT_ENDIAN=t.BIG_ENDIAN,t.DEFAULT_NOASSERT=!1,t.Long=e||null;var i=t.prototype;i.__isByteBuffer__,Object.defineProperty(i,"__isByteBuffer__",{value:!0,enumerable:!1,configurable:!1});var r=new ArrayBuffer(0),n=String.fromCharCode;function s(e){var t=0;return function(){return t<e.length?e.charCodeAt(t++):null}}function o(){var e=[],t=[];return function(){if(0===arguments.length)return t.join("")+n.apply(String,e);e.length+arguments.length>1024&&(t.push(n.apply(String,e)),e.length=0),Array.prototype.push.apply(e,arguments)}}function a(e,t,i,r,n){var s,o,a=8*n-r-1,l=(1<<a)-1,_=l>>1,c=-7,d=i?n-1:0,u=i?-1:1,h=e[t+d];for(d+=u,s=h&(1<<-c)-1,h>>=-c,c+=a;c>0;s=256*s+e[t+d],d+=u,c-=8);for(o=s&(1<<-c)-1,s>>=-c,c+=r;c>0;o=256*o+e[t+d],d+=u,c-=8);if(0===s)s=1-_;else{if(s===l)return o?NaN:1/0*(h?-1:1);o+=Math.pow(2,r),s-=_}return(h?-1:1)*o*Math.pow(2,s-r)}function l(e,t,i,r,n,s){var o,a,l,_=8*s-n-1,c=(1<<_)-1,d=c>>1,u=23===n?Math.pow(2,-24)-Math.pow(2,-77):0,h=r?0:s-1,g=r?1:-1,p=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,o=c):(o=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-o))<1&&(o--,l*=2),(t+=o+d>=1?u/l:u*Math.pow(2,1-d))*l>=2&&(o++,l/=2),o+d>=c?(a=0,o=c):o+d>=1?(a=(t*l-1)*Math.pow(2,n),o+=d):(a=t*Math.pow(2,d-1)*Math.pow(2,n),o=0));n>=8;e[i+h]=255&a,h+=g,a/=256,n-=8);for(o=o<<n|a,_+=n;_>0;e[i+h]=255&o,h+=g,o/=256,_-=8);e[i+h-g]|=128*p}t.accessor=function(){return Uint8Array},t.allocate=function(e,i,r){return new t(e,i,r)},t.concat=function(e,i,r,n){"boolean"!=typeof i&&"string"==typeof i||(n=r,r=i,i=void 0);for(var s,o=0,a=0,l=e.length;a<l;++a)t.isByteBuffer(e[a])||(e[a]=t.wrap(e[a],i)),(s=e[a].limit-e[a].offset)>0&&(o+=s);if(0===o)return new t(0,r,n);var _,c=new t(o,r,n);for(a=0;a<l;)(s=(_=e[a++]).limit-_.offset)<=0||(c.view.set(_.view.subarray(_.offset,_.limit),c.offset),c.offset+=s);return c.limit=c.offset,c.offset=0,c},t.isByteBuffer=function(e){return!0===(e&&e.__isByteBuffer__)},t.type=function(){return ArrayBuffer},t.wrap=function(e,r,n,s){if("string"!=typeof r&&(s=n,n=r,r=void 0),"string"==typeof e)switch(void 0===r&&(r="utf8"),r){case"base64":return t.fromBase64(e,n);case"hex":return t.fromHex(e,n);case"binary":return t.fromBinary(e,n);case"utf8":return t.fromUTF8(e,n);case"debug":return t.fromDebug(e,n);default:throw Error("Unsupported encoding: "+r)}if(null===e||"object"!=typeof e)throw TypeError("Illegal buffer");var o;if(t.isByteBuffer(e))return(o=i.clone.call(e)).markedOffset=-1,o;if(e instanceof Uint8Array)o=new t(0,n,s),e.length>0&&(o.buffer=e.buffer,o.offset=e.byteOffset,o.limit=e.byteOffset+e.byteLength,o.view=new Uint8Array(e.buffer));else if(e instanceof ArrayBuffer)o=new t(0,n,s),e.byteLength>0&&(o.buffer=e,o.offset=0,o.limit=e.byteLength,o.view=e.byteLength>0?new Uint8Array(e):null);else{if("[object Array]"!==Object.prototype.toString.call(e))throw TypeError("Illegal buffer");(o=new t(e.length,n,s)).limit=e.length;for(var a=0;a<e.length;++a)o.view[a]=e[a]}return o},i.writeBitSet=function(e,t){var i=void 0===t;if(i&&(t=this.offset),!this.noAssert){if(!(e instanceof Array))throw TypeError("Illegal BitSet: Not an array");if("number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: "+t+" (not an integer)");if((t>>>=0)<0||t+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+0) <= "+this.buffer.byteLength)}var r,n=t,s=e.length,o=s>>3,a=0;for(t+=this.writeVarint32(s,t);o--;)r=1&!!e[a++]|(1&!!e[a++])<<1|(1&!!e[a++])<<2|(1&!!e[a++])<<3|(1&!!e[a++])<<4|(1&!!e[a++])<<5|(1&!!e[a++])<<6|(1&!!e[a++])<<7,this.writeByte(r,t++);if(a<s){var l=0;for(r=0;a<s;)r|=(1&!!e[a++])<<l++;this.writeByte(r,t++)}return i?(this.offset=t,this):t-n},i.readBitSet=function(e){var t=void 0===e;t&&(e=this.offset);var i,r=this.readVarint32(e),n=r.value,s=n>>3,o=0,a=[];for(e+=r.length;s--;)i=this.readByte(e++),a[o++]=!!(1&i),a[o++]=!!(2&i),a[o++]=!!(4&i),a[o++]=!!(8&i),a[o++]=!!(16&i),a[o++]=!!(32&i),a[o++]=!!(64&i),a[o++]=!!(128&i);if(o<n){var l=0;for(i=this.readByte(e++);o<n;)a[o++]=!!(i>>l++&1)}return t&&(this.offset=e),a},i.readBytes=function(e,t){var i=void 0===t;if(i&&(t=this.offset),!this.noAssert){if("number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: "+t+" (not an integer)");if((t>>>=0)<0||t+e>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+"+e+") <= "+this.buffer.byteLength)}var r=this.slice(t,t+e);return i&&(this.offset+=e),r},i.writeBytes=i.append,i.writeInt8=function(e,t){var i=void 0===t;if(i&&(t=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal value: "+e+" (not an integer)");if(e|=0,"number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: "+t+" (not an integer)");if((t>>>=0)<0||t+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+0) <= "+this.buffer.byteLength)}t+=1;var r=this.buffer.byteLength;return t>r&&this.resize((r*=2)>t?r:t),t-=1,this.view[t]=e,i&&(this.offset+=1),this},i.writeByte=i.writeInt8,i.readInt8=function(e){var t=void 0===e;if(t&&(e=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal offset: "+e+" (not an integer)");if((e>>>=0)<0||e+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+e+" (+1) <= "+this.buffer.byteLength)}var i=this.view[e];return 128&~i||(i=-(255-i+1)),t&&(this.offset+=1),i},i.readByte=i.readInt8,i.writeUint8=function(e,t){var i=void 0===t;if(i&&(t=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal value: "+e+" (not an integer)");if(e>>>=0,"number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: "+t+" (not an integer)");if((t>>>=0)<0||t+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+0) <= "+this.buffer.byteLength)}t+=1;var r=this.buffer.byteLength;return t>r&&this.resize((r*=2)>t?r:t),t-=1,this.view[t]=e,i&&(this.offset+=1),this},i.writeUInt8=i.writeUint8,i.readUint8=function(e){var t=void 0===e;if(t&&(e=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal offset: "+e+" (not an integer)");if((e>>>=0)<0||e+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+e+" (+1) <= "+this.buffer.byteLength)}var i=this.view[e];return t&&(this.offset+=1),i},i.readUInt8=i.readUint8,i.writeInt16=function(e,t){var i=void 0===t;if(i&&(t=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal value: "+e+" (not an integer)");if(e|=0,"number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: "+t+" (not an integer)");if((t>>>=0)<0||t+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+0) <= "+this.buffer.byteLength)}t+=2;var r=this.buffer.byteLength;return t>r&&this.resize((r*=2)>t?r:t),t-=2,this.littleEndian?(this.view[t+1]=(65280&e)>>>8,this.view[t]=255&e):(this.view[t]=(65280&e)>>>8,this.view[t+1]=255&e),i&&(this.offset+=2),this},i.writeShort=i.writeInt16,i.readInt16=function(e){var t=void 0===e;if(t&&(e=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal offset: "+e+" (not an integer)");if((e>>>=0)<0||e+2>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+e+" (+2) <= "+this.buffer.byteLength)}var i=0;return this.littleEndian?(i=this.view[e],i|=this.view[e+1]<<8):(i=this.view[e]<<8,i|=this.view[e+1]),32768&~i||(i=-(65535-i+1)),t&&(this.offset+=2),i},i.readShort=i.readInt16,i.writeUint16=function(e,t){var i=void 0===t;if(i&&(t=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal value: "+e+" (not an integer)");if(e>>>=0,"number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: "+t+" (not an integer)");if((t>>>=0)<0||t+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+0) <= "+this.buffer.byteLength)}t+=2;var r=this.buffer.byteLength;return t>r&&this.resize((r*=2)>t?r:t),t-=2,this.littleEndian?(this.view[t+1]=(65280&e)>>>8,this.view[t]=255&e):(this.view[t]=(65280&e)>>>8,this.view[t+1]=255&e),i&&(this.offset+=2),this},i.writeUInt16=i.writeUint16,i.readUint16=function(e){var t=void 0===e;if(t&&(e=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal offset: "+e+" (not an integer)");if((e>>>=0)<0||e+2>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+e+" (+2) <= "+this.buffer.byteLength)}var i=0;return this.littleEndian?(i=this.view[e],i|=this.view[e+1]<<8):(i=this.view[e]<<8,i|=this.view[e+1]),t&&(this.offset+=2),i},i.readUInt16=i.readUint16,i.writeInt32=function(e,t){var i=void 0===t;if(i&&(t=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal value: "+e+" (not an integer)");if(e|=0,"number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: "+t+" (not an integer)");if((t>>>=0)<0||t+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+0) <= "+this.buffer.byteLength)}t+=4;var r=this.buffer.byteLength;return t>r&&this.resize((r*=2)>t?r:t),t-=4,this.littleEndian?(this.view[t+3]=e>>>24&255,this.view[t+2]=e>>>16&255,this.view[t+1]=e>>>8&255,this.view[t]=255&e):(this.view[t]=e>>>24&255,this.view[t+1]=e>>>16&255,this.view[t+2]=e>>>8&255,this.view[t+3]=255&e),i&&(this.offset+=4),this},i.writeInt=i.writeInt32,i.readInt32=function(e){var t=void 0===e;if(t&&(e=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal offset: "+e+" (not an integer)");if((e>>>=0)<0||e+4>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+e+" (+4) <= "+this.buffer.byteLength)}var i=0;return this.littleEndian?(i=this.view[e+2]<<16,i|=this.view[e+1]<<8,i|=this.view[e],i+=this.view[e+3]<<24>>>0):(i=this.view[e+1]<<16,i|=this.view[e+2]<<8,i|=this.view[e+3],i+=this.view[e]<<24>>>0),i|=0,t&&(this.offset+=4),i},i.readInt=i.readInt32,i.writeUint32=function(e,t){var i=void 0===t;if(i&&(t=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal value: "+e+" (not an integer)");if(e>>>=0,"number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: "+t+" (not an integer)");if((t>>>=0)<0||t+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+0) <= "+this.buffer.byteLength)}t+=4;var r=this.buffer.byteLength;return t>r&&this.resize((r*=2)>t?r:t),t-=4,this.littleEndian?(this.view[t+3]=e>>>24&255,this.view[t+2]=e>>>16&255,this.view[t+1]=e>>>8&255,this.view[t]=255&e):(this.view[t]=e>>>24&255,this.view[t+1]=e>>>16&255,this.view[t+2]=e>>>8&255,this.view[t+3]=255&e),i&&(this.offset+=4),this},i.writeUInt32=i.writeUint32,i.readUint32=function(e){var t=void 0===e;if(t&&(e=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal offset: "+e+" (not an integer)");if((e>>>=0)<0||e+4>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+e+" (+4) <= "+this.buffer.byteLength)}var i=0;return this.littleEndian?(i=this.view[e+2]<<16,i|=this.view[e+1]<<8,i|=this.view[e],i+=this.view[e+3]<<24>>>0):(i=this.view[e+1]<<16,i|=this.view[e+2]<<8,i|=this.view[e+3],i+=this.view[e]<<24>>>0),t&&(this.offset+=4),i},i.readUInt32=i.readUint32,e&&(i.writeInt64=function(t,i){var r=void 0===i;if(r&&(i=this.offset),!this.noAssert){if("number"==typeof t)t=e.fromNumber(t);else if("string"==typeof t)t=e.fromString(t);else if(!(t&&t instanceof e))throw TypeError("Illegal value: "+t+" (not an integer or Long)");if("number"!=typeof i||i%1!=0)throw TypeError("Illegal offset: "+i+" (not an integer)");if((i>>>=0)<0||i+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+i+" (+0) <= "+this.buffer.byteLength)}"number"==typeof t?t=e.fromNumber(t):"string"==typeof t&&(t=e.fromString(t)),i+=8;var n=this.buffer.byteLength;i>n&&this.resize((n*=2)>i?n:i),i-=8;var s=t.low,o=t.high;return this.littleEndian?(this.view[i+3]=s>>>24&255,this.view[i+2]=s>>>16&255,this.view[i+1]=s>>>8&255,this.view[i]=255&s,i+=4,this.view[i+3]=o>>>24&255,this.view[i+2]=o>>>16&255,this.view[i+1]=o>>>8&255,this.view[i]=255&o):(this.view[i]=o>>>24&255,this.view[i+1]=o>>>16&255,this.view[i+2]=o>>>8&255,this.view[i+3]=255&o,i+=4,this.view[i]=s>>>24&255,this.view[i+1]=s>>>16&255,this.view[i+2]=s>>>8&255,this.view[i+3]=255&s),r&&(this.offset+=8),this},i.writeLong=i.writeInt64,i.readInt64=function(t){var i=void 0===t;if(i&&(t=this.offset),!this.noAssert){if("number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: "+t+" (not an integer)");if((t>>>=0)<0||t+8>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+8) <= "+this.buffer.byteLength)}var r=0,n=0;this.littleEndian?(r=this.view[t+2]<<16,r|=this.view[t+1]<<8,r|=this.view[t],r+=this.view[t+3]<<24>>>0,t+=4,n=this.view[t+2]<<16,n|=this.view[t+1]<<8,n|=this.view[t],n+=this.view[t+3]<<24>>>0):(n=this.view[t+1]<<16,n|=this.view[t+2]<<8,n|=this.view[t+3],n+=this.view[t]<<24>>>0,t+=4,r=this.view[t+1]<<16,r|=this.view[t+2]<<8,r|=this.view[t+3],r+=this.view[t]<<24>>>0);var s=new e(r,n,!1);return i&&(this.offset+=8),s},i.readLong=i.readInt64,i.writeUint64=function(t,i){var r=void 0===i;if(r&&(i=this.offset),!this.noAssert){if("number"==typeof t)t=e.fromNumber(t);else if("string"==typeof t)t=e.fromString(t);else if(!(t&&t instanceof e))throw TypeError("Illegal value: "+t+" (not an integer or Long)");if("number"!=typeof i||i%1!=0)throw TypeError("Illegal offset: "+i+" (not an integer)");if((i>>>=0)<0||i+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+i+" (+0) <= "+this.buffer.byteLength)}"number"==typeof t?t=e.fromNumber(t):"string"==typeof t&&(t=e.fromString(t)),i+=8;var n=this.buffer.byteLength;i>n&&this.resize((n*=2)>i?n:i),i-=8;var s=t.low,o=t.high;return this.littleEndian?(this.view[i+3]=s>>>24&255,this.view[i+2]=s>>>16&255,this.view[i+1]=s>>>8&255,this.view[i]=255&s,i+=4,this.view[i+3]=o>>>24&255,this.view[i+2]=o>>>16&255,this.view[i+1]=o>>>8&255,this.view[i]=255&o):(this.view[i]=o>>>24&255,this.view[i+1]=o>>>16&255,this.view[i+2]=o>>>8&255,this.view[i+3]=255&o,i+=4,this.view[i]=s>>>24&255,this.view[i+1]=s>>>16&255,this.view[i+2]=s>>>8&255,this.view[i+3]=255&s),r&&(this.offset+=8),this},i.writeUInt64=i.writeUint64,i.readUint64=function(t){var i=void 0===t;if(i&&(t=this.offset),!this.noAssert){if("number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: "+t+" (not an integer)");if((t>>>=0)<0||t+8>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+8) <= "+this.buffer.byteLength)}var r=0,n=0;this.littleEndian?(r=this.view[t+2]<<16,r|=this.view[t+1]<<8,r|=this.view[t],r+=this.view[t+3]<<24>>>0,t+=4,n=this.view[t+2]<<16,n|=this.view[t+1]<<8,n|=this.view[t],n+=this.view[t+3]<<24>>>0):(n=this.view[t+1]<<16,n|=this.view[t+2]<<8,n|=this.view[t+3],n+=this.view[t]<<24>>>0,t+=4,r=this.view[t+1]<<16,r|=this.view[t+2]<<8,r|=this.view[t+3],r+=this.view[t]<<24>>>0);var s=new e(r,n,!0);return i&&(this.offset+=8),s},i.readUInt64=i.readUint64),i.writeFloat32=function(e,t){var i=void 0===t;if(i&&(t=this.offset),!this.noAssert){if("number"!=typeof e)throw TypeError("Illegal value: "+e+" (not a number)");if("number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: "+t+" (not an integer)");if((t>>>=0)<0||t+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+0) <= "+this.buffer.byteLength)}t+=4;var r=this.buffer.byteLength;return t>r&&this.resize((r*=2)>t?r:t),t-=4,l(this.view,e,t,this.littleEndian,23,4),i&&(this.offset+=4),this},i.writeFloat=i.writeFloat32,i.readFloat32=function(e){var t=void 0===e;if(t&&(e=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal offset: "+e+" (not an integer)");if((e>>>=0)<0||e+4>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+e+" (+4) <= "+this.buffer.byteLength)}var i=a(this.view,e,this.littleEndian,23,4);return t&&(this.offset+=4),i},i.readFloat=i.readFloat32,i.writeFloat64=function(e,t){var i=void 0===t;if(i&&(t=this.offset),!this.noAssert){if("number"!=typeof e)throw TypeError("Illegal value: "+e+" (not a number)");if("number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: "+t+" (not an integer)");if((t>>>=0)<0||t+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+0) <= "+this.buffer.byteLength)}t+=8;var r=this.buffer.byteLength;return t>r&&this.resize((r*=2)>t?r:t),t-=8,l(this.view,e,t,this.littleEndian,52,8),i&&(this.offset+=8),this},i.writeDouble=i.writeFloat64,i.readFloat64=function(e){var t=void 0===e;if(t&&(e=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal offset: "+e+" (not an integer)");if((e>>>=0)<0||e+8>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+e+" (+8) <= "+this.buffer.byteLength)}var i=a(this.view,e,this.littleEndian,52,8);return t&&(this.offset+=8),i},i.readDouble=i.readFloat64,t.MAX_VARINT32_BYTES=5,t.calculateVarint32=function(e){return(e>>>=0)<128?1:e<16384?2:e<1<<21?3:e<1<<28?4:5},t.zigZagEncode32=function(e){return((e|=0)<<1^e>>31)>>>0},t.zigZagDecode32=function(e){return e>>>1^-(1&e)},i.writeVarint32=function(e,i){var r=void 0===i;if(r&&(i=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal value: "+e+" (not an integer)");if(e|=0,"number"!=typeof i||i%1!=0)throw TypeError("Illegal offset: "+i+" (not an integer)");if((i>>>=0)<0||i+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+i+" (+0) <= "+this.buffer.byteLength)}var n,s=t.calculateVarint32(e);i+=s;var o=this.buffer.byteLength;for(i>o&&this.resize((o*=2)>i?o:i),i-=s,e>>>=0;e>=128;)n=127&e|128,this.view[i++]=n,e>>>=7;return this.view[i++]=e,r?(this.offset=i,this):s},i.writeVarint32ZigZag=function(e,i){return this.writeVarint32(t.zigZagEncode32(e),i)},i.readVarint32=function(e){var t=void 0===e;if(t&&(e=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal offset: "+e+" (not an integer)");if((e>>>=0)<0||e+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+e+" (+1) <= "+this.buffer.byteLength)}var i,r=0,n=0;do{if(!this.noAssert&&e>this.limit){var s=Error("Truncated");throw s.truncated=!0,s}i=this.view[e++],r<5&&(n|=(127&i)<<7*r),++r}while(128&i);return n|=0,t?(this.offset=e,n):{value:n,length:r}},i.readVarint32ZigZag=function(e){var i=this.readVarint32(e);return"object"==typeof i?i.value=t.zigZagDecode32(i.value):i=t.zigZagDecode32(i),i},e&&(t.MAX_VARINT64_BYTES=10,t.calculateVarint64=function(t){"number"==typeof t?t=e.fromNumber(t):"string"==typeof t&&(t=e.fromString(t));var i=t.toInt()>>>0,r=t.shiftRightUnsigned(28).toInt()>>>0,n=t.shiftRightUnsigned(56).toInt()>>>0;return 0==n?0==r?i<16384?i<128?1:2:i<1<<21?3:4:r<16384?r<128?5:6:r<1<<21?7:8:n<128?9:10},t.zigZagEncode64=function(t){return"number"==typeof t?t=e.fromNumber(t,!1):"string"==typeof t?t=e.fromString(t,!1):!1!==t.unsigned&&(t=t.toSigned()),t.shiftLeft(1).xor(t.shiftRight(63)).toUnsigned()},t.zigZagDecode64=function(t){return"number"==typeof t?t=e.fromNumber(t,!1):"string"==typeof t?t=e.fromString(t,!1):!1!==t.unsigned&&(t=t.toSigned()),t.shiftRightUnsigned(1).xor(t.and(e.ONE).toSigned().negate()).toSigned()},i.writeVarint64=function(i,r){var n=void 0===r;if(n&&(r=this.offset),!this.noAssert){if("number"==typeof i)i=e.fromNumber(i);else if("string"==typeof i)i=e.fromString(i);else if(!(i&&i instanceof e))throw TypeError("Illegal value: "+i+" (not an integer or Long)");if("number"!=typeof r||r%1!=0)throw TypeError("Illegal offset: "+r+" (not an integer)");if((r>>>=0)<0||r+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+r+" (+0) <= "+this.buffer.byteLength)}"number"==typeof i?i=e.fromNumber(i,!1):"string"==typeof i?i=e.fromString(i,!1):!1!==i.unsigned&&(i=i.toSigned());var s=t.calculateVarint64(i),o=i.toInt()>>>0,a=i.shiftRightUnsigned(28).toInt()>>>0,l=i.shiftRightUnsigned(56).toInt()>>>0;r+=s;var _=this.buffer.byteLength;switch(r>_&&this.resize((_*=2)>r?_:r),r-=s,s){case 10:this.view[r+9]=l>>>7&1;case 9:this.view[r+8]=9!==s?128|l:127&l;case 8:this.view[r+7]=8!==s?a>>>21|128:a>>>21&127;case 7:this.view[r+6]=7!==s?a>>>14|128:a>>>14&127;case 6:this.view[r+5]=6!==s?a>>>7|128:a>>>7&127;case 5:this.view[r+4]=5!==s?128|a:127&a;case 4:this.view[r+3]=4!==s?o>>>21|128:o>>>21&127;case 3:this.view[r+2]=3!==s?o>>>14|128:o>>>14&127;case 2:this.view[r+1]=2!==s?o>>>7|128:o>>>7&127;case 1:this.view[r]=1!==s?128|o:127&o}return n?(this.offset+=s,this):s},i.writeVarint64ZigZag=function(e,i){return this.writeVarint64(t.zigZagEncode64(e),i)},i.readVarint64=function(t){var i=void 0===t;if(i&&(t=this.offset),!this.noAssert){if("number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: "+t+" (not an integer)");if((t>>>=0)<0||t+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+1) <= "+this.buffer.byteLength)}var r=t,n=0,s=0,o=0,a=0;if(n=127&(a=this.view[t++]),128&a&&(n|=(127&(a=this.view[t++]))<<7,(128&a||this.noAssert&&void 0===a)&&(n|=(127&(a=this.view[t++]))<<14,(128&a||this.noAssert&&void 0===a)&&(n|=(127&(a=this.view[t++]))<<21,(128&a||this.noAssert&&void 0===a)&&(s=127&(a=this.view[t++]),(128&a||this.noAssert&&void 0===a)&&(s|=(127&(a=this.view[t++]))<<7,(128&a||this.noAssert&&void 0===a)&&(s|=(127&(a=this.view[t++]))<<14,(128&a||this.noAssert&&void 0===a)&&(s|=(127&(a=this.view[t++]))<<21,(128&a||this.noAssert&&void 0===a)&&(o=127&(a=this.view[t++]),(128&a||this.noAssert&&void 0===a)&&(o|=(127&(a=this.view[t++]))<<7,128&a||this.noAssert&&void 0===a))))))))))throw Error("Buffer overrun");var l=e.fromBits(n|s<<28,s>>>4|o<<24,!1);return i?(this.offset=t,l):{value:l,length:t-r}},i.readVarint64ZigZag=function(i){var r=this.readVarint64(i);return r&&r.value instanceof e?r.value=t.zigZagDecode64(r.value):r=t.zigZagDecode64(r),r}),i.writeCString=function(e,t){var i=void 0===t;i&&(t=this.offset);var r,n=e.length;if(!this.noAssert){if("string"!=typeof e)throw TypeError("Illegal str: Not a string");for(r=0;r<n;++r)if(0===e.charCodeAt(r))throw RangeError("Illegal str: Contains NULL-characters");if("number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: "+t+" (not an integer)");if((t>>>=0)<0||t+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+0) <= "+this.buffer.byteLength)}n=c.calculateUTF16asUTF8(s(e))[1],t+=n+1;var o=this.buffer.byteLength;return t>o&&this.resize((o*=2)>t?o:t),t-=n+1,c.encodeUTF16toUTF8(s(e),function(e){this.view[t++]=e}.bind(this)),this.view[t++]=0,i?(this.offset=t,this):n},i.readCString=function(e){var t=void 0===e;if(t&&(e=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal offset: "+e+" (not an integer)");if((e>>>=0)<0||e+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+e+" (+1) <= "+this.buffer.byteLength)}var i,r=e,n=-1;return c.decodeUTF8toUTF16(function(){if(0===n)return null;if(e>=this.limit)throw RangeError("Illegal range: Truncated data, "+e+" < "+this.limit);return 0===(n=this.view[e++])?null:n}.bind(this),i=o(),!0),t?(this.offset=e,i()):{string:i(),length:e-r}},i.writeIString=function(e,t){var i=void 0===t;if(i&&(t=this.offset),!this.noAssert){if("string"!=typeof e)throw TypeError("Illegal str: Not a string");if("number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: "+t+" (not an integer)");if((t>>>=0)<0||t+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+0) <= "+this.buffer.byteLength)}var r,n=t;r=c.calculateUTF16asUTF8(s(e),this.noAssert)[1],t+=4+r;var o=this.buffer.byteLength;if(t>o&&this.resize((o*=2)>t?o:t),t-=4+r,this.littleEndian?(this.view[t+3]=r>>>24&255,this.view[t+2]=r>>>16&255,this.view[t+1]=r>>>8&255,this.view[t]=255&r):(this.view[t]=r>>>24&255,this.view[t+1]=r>>>16&255,this.view[t+2]=r>>>8&255,this.view[t+3]=255&r),t+=4,c.encodeUTF16toUTF8(s(e),function(e){this.view[t++]=e}.bind(this)),t!==n+4+r)throw RangeError("Illegal range: Truncated data, "+t+" == "+(t+4+r));return i?(this.offset=t,this):t-n},i.readIString=function(e){var i=void 0===e;if(i&&(e=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal offset: "+e+" (not an integer)");if((e>>>=0)<0||e+4>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+e+" (+4) <= "+this.buffer.byteLength)}var r=e,n=this.readUint32(e),s=this.readUTF8String(n,t.METRICS_BYTES,e+=4);return e+=s.length,i?(this.offset=e,s.string):{string:s.string,length:e-r}},t.METRICS_CHARS="c",t.METRICS_BYTES="b",i.writeUTF8String=function(e,t){var i,r=void 0===t;if(r&&(t=this.offset),!this.noAssert){if("number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: "+t+" (not an integer)");if((t>>>=0)<0||t+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+0) <= "+this.buffer.byteLength)}var n=t;i=c.calculateUTF16asUTF8(s(e))[1],t+=i;var o=this.buffer.byteLength;return t>o&&this.resize((o*=2)>t?o:t),t-=i,c.encodeUTF16toUTF8(s(e),function(e){this.view[t++]=e}.bind(this)),r?(this.offset=t,this):t-n},i.writeString=i.writeUTF8String,t.calculateUTF8Chars=function(e){return c.calculateUTF16asUTF8(s(e))[0]},t.calculateUTF8Bytes=function(e){return c.calculateUTF16asUTF8(s(e))[1]},t.calculateString=t.calculateUTF8Bytes,i.readUTF8String=function(e,i,r){"number"==typeof i&&(r=i,i=void 0);var n=void 0===r;if(n&&(r=this.offset),void 0===i&&(i=t.METRICS_CHARS),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal length: "+e+" (not an integer)");if(e|=0,"number"!=typeof r||r%1!=0)throw TypeError("Illegal offset: "+r+" (not an integer)");if((r>>>=0)<0||r+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+r+" (+0) <= "+this.buffer.byteLength)}var s,a=0,l=r;if(i===t.METRICS_CHARS){if(s=o(),c.decodeUTF8(function(){return a<e&&r<this.limit?this.view[r++]:null}.bind(this),(function(e){++a,c.UTF8toUTF16(e,s)})),a!==e)throw RangeError("Illegal range: Truncated data, "+a+" == "+e);return n?(this.offset=r,s()):{string:s(),length:r-l}}if(i===t.METRICS_BYTES){if(!this.noAssert){if("number"!=typeof r||r%1!=0)throw TypeError("Illegal offset: "+r+" (not an integer)");if((r>>>=0)<0||r+e>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+r+" (+"+e+") <= "+this.buffer.byteLength)}var _=r+e;if(c.decodeUTF8toUTF16(function(){return r<_?this.view[r++]:null}.bind(this),s=o(),this.noAssert),r!==_)throw RangeError("Illegal range: Truncated data, "+r+" == "+_);return n?(this.offset=r,s()):{string:s(),length:r-l}}throw TypeError("Unsupported metrics: "+i)},i.readString=i.readUTF8String,i.writeVString=function(e,i){var r=void 0===i;if(r&&(i=this.offset),!this.noAssert){if("string"!=typeof e)throw TypeError("Illegal str: Not a string");if("number"!=typeof i||i%1!=0)throw TypeError("Illegal offset: "+i+" (not an integer)");if((i>>>=0)<0||i+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+i+" (+0) <= "+this.buffer.byteLength)}var n,o,a=i;n=c.calculateUTF16asUTF8(s(e),this.noAssert)[1],o=t.calculateVarint32(n),i+=o+n;var l=this.buffer.byteLength;if(i>l&&this.resize((l*=2)>i?l:i),i-=o+n,i+=this.writeVarint32(n,i),c.encodeUTF16toUTF8(s(e),function(e){this.view[i++]=e}.bind(this)),i!==a+n+o)throw RangeError("Illegal range: Truncated data, "+i+" == "+(i+n+o));return r?(this.offset=i,this):i-a},i.readVString=function(e){var i=void 0===e;if(i&&(e=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal offset: "+e+" (not an integer)");if((e>>>=0)<0||e+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+e+" (+1) <= "+this.buffer.byteLength)}var r=e,n=this.readVarint32(e),s=this.readUTF8String(n.value,t.METRICS_BYTES,e+=n.length);return e+=s.length,i?(this.offset=e,s.string):{string:s.string,length:e-r}},i.append=function(e,i,r){"number"!=typeof i&&"string"==typeof i||(r=i,i=void 0);var n=void 0===r;if(n&&(r=this.offset),!this.noAssert){if("number"!=typeof r||r%1!=0)throw TypeError("Illegal offset: "+r+" (not an integer)");if((r>>>=0)<0||r+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+r+" (+0) <= "+this.buffer.byteLength)}e instanceof t||(e=t.wrap(e,i));var s=e.limit-e.offset;if(s<=0)return this;r+=s;var o=this.buffer.byteLength;return r>o&&this.resize((o*=2)>r?o:r),r-=s,this.view.set(e.view.subarray(e.offset,e.limit),r),e.offset+=s,n&&(this.offset+=s),this},i.appendTo=function(e,t){return e.append(this,t),this},i.assert=function(e){return this.noAssert=!e,this},i.capacity=function(){return this.buffer.byteLength},i.clear=function(){return this.offset=0,this.limit=this.buffer.byteLength,this.markedOffset=-1,this},i.clone=function(e){var i=new t(0,this.littleEndian,this.noAssert);return e?(i.buffer=new ArrayBuffer(this.buffer.byteLength),i.view=new Uint8Array(i.buffer)):(i.buffer=this.buffer,i.view=this.view),i.offset=this.offset,i.markedOffset=this.markedOffset,i.limit=this.limit,i},i.compact=function(e,t){if(void 0===e&&(e=this.offset),void 0===t&&(t=this.limit),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal begin: Not an integer");if(e>>>=0,"number"!=typeof t||t%1!=0)throw TypeError("Illegal end: Not an integer");if(t>>>=0,e<0||e>t||t>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+e+" <= "+t+" <= "+this.buffer.byteLength)}if(0===e&&t===this.buffer.byteLength)return this;var i=t-e;if(0===i)return this.buffer=r,this.view=null,this.markedOffset>=0&&(this.markedOffset-=e),this.offset=0,this.limit=0,this;var n=new ArrayBuffer(i),s=new Uint8Array(n);return s.set(this.view.subarray(e,t)),this.buffer=n,this.view=s,this.markedOffset>=0&&(this.markedOffset-=e),this.offset=0,this.limit=i,this},i.copy=function(e,i){if(void 0===e&&(e=this.offset),void 0===i&&(i=this.limit),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal begin: Not an integer");if(e>>>=0,"number"!=typeof i||i%1!=0)throw TypeError("Illegal end: Not an integer");if(i>>>=0,e<0||e>i||i>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+e+" <= "+i+" <= "+this.buffer.byteLength)}if(e===i)return new t(0,this.littleEndian,this.noAssert);var r=i-e,n=new t(r,this.littleEndian,this.noAssert);return n.offset=0,n.limit=r,n.markedOffset>=0&&(n.markedOffset-=e),this.copyTo(n,0,e,i),n},i.copyTo=function(e,i,r,n){var s,o;if(!this.noAssert&&!t.isByteBuffer(e))throw TypeError("Illegal target: Not a ByteBuffer");if(i=(o=void 0===i)?e.offset:0|i,r=(s=void 0===r)?this.offset:0|r,n=void 0===n?this.limit:0|n,i<0||i>e.buffer.byteLength)throw RangeError("Illegal target range: 0 <= "+i+" <= "+e.buffer.byteLength);if(r<0||n>this.buffer.byteLength)throw RangeError("Illegal source range: 0 <= "+r+" <= "+this.buffer.byteLength);var a=n-r;return 0===a?e:(e.ensureCapacity(i+a),e.view.set(this.view.subarray(r,n),i),s&&(this.offset+=a),o&&(e.offset+=a),this)},i.ensureCapacity=function(e){var t=this.buffer.byteLength;return t<e?this.resize((t*=2)>e?t:e):this},i.fill=function(e,t,i){var r=void 0===t;if(r&&(t=this.offset),"string"==typeof e&&e.length>0&&(e=e.charCodeAt(0)),void 0===t&&(t=this.offset),void 0===i&&(i=this.limit),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal value: "+e+" (not an integer)");if(e|=0,"number"!=typeof t||t%1!=0)throw TypeError("Illegal begin: Not an integer");if(t>>>=0,"number"!=typeof i||i%1!=0)throw TypeError("Illegal end: Not an integer");if(i>>>=0,t<0||t>i||i>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+t+" <= "+i+" <= "+this.buffer.byteLength)}if(t>=i)return this;for(;t<i;)this.view[t++]=e;return r&&(this.offset=t),this},i.flip=function(){return this.limit=this.offset,this.offset=0,this},i.mark=function(e){if(e=void 0===e?this.offset:e,!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal offset: "+e+" (not an integer)");if((e>>>=0)<0||e+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+e+" (+0) <= "+this.buffer.byteLength)}return this.markedOffset=e,this},i.order=function(e){if(!this.noAssert&&"boolean"!=typeof e)throw TypeError("Illegal littleEndian: Not a boolean");return this.littleEndian=!!e,this},i.LE=function(e){return this.littleEndian=void 0===e||!!e,this},i.BE=function(e){return this.littleEndian=void 0!==e&&!e,this},i.prepend=function(e,i,r){"number"!=typeof i&&"string"==typeof i||(r=i,i=void 0);var n=void 0===r;if(n&&(r=this.offset),!this.noAssert){if("number"!=typeof r||r%1!=0)throw TypeError("Illegal offset: "+r+" (not an integer)");if((r>>>=0)<0||r+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+r+" (+0) <= "+this.buffer.byteLength)}e instanceof t||(e=t.wrap(e,i));var s=e.limit-e.offset;if(s<=0)return this;var o=s-r;if(o>0){var a=new ArrayBuffer(this.buffer.byteLength+o),l=new Uint8Array(a);l.set(this.view.subarray(r,this.buffer.byteLength),s),this.buffer=a,this.view=l,this.offset+=o,this.markedOffset>=0&&(this.markedOffset+=o),this.limit+=o,r+=o}else new Uint8Array(this.buffer);return this.view.set(e.view.subarray(e.offset,e.limit),r-s),e.offset=e.limit,n&&(this.offset-=s),this},i.prependTo=function(e,t){return e.prepend(this,t),this},i.printDebug=function(e){"function"!=typeof e&&(e=console.log.bind(console)),e(this.toString()+"\n-------------------------------------------------------------------\n"+this.toDebug(!0))},i.remaining=function(){return this.limit-this.offset},i.reset=function(){return this.markedOffset>=0?(this.offset=this.markedOffset,this.markedOffset=-1):this.offset=0,this},i.resize=function(e){if(!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal capacity: "+e+" (not an integer)");if((e|=0)<0)throw RangeError("Illegal capacity: 0 <= "+e)}if(this.buffer.byteLength<e){var t=new ArrayBuffer(e),i=new Uint8Array(t);i.set(this.view),this.buffer=t,this.view=i}return this},i.reverse=function(e,t){if(void 0===e&&(e=this.offset),void 0===t&&(t=this.limit),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal begin: Not an integer");if(e>>>=0,"number"!=typeof t||t%1!=0)throw TypeError("Illegal end: Not an integer");if(t>>>=0,e<0||e>t||t>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+e+" <= "+t+" <= "+this.buffer.byteLength)}return e===t||Array.prototype.reverse.call(this.view.subarray(e,t)),this},i.skip=function(e){if(!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal length: "+e+" (not an integer)");e|=0}var t=this.offset+e;if(!this.noAssert&&(t<0||t>this.buffer.byteLength))throw RangeError("Illegal length: 0 <= "+this.offset+" + "+e+" <= "+this.buffer.byteLength);return this.offset=t,this},i.slice=function(e,t){if(void 0===e&&(e=this.offset),void 0===t&&(t=this.limit),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal begin: Not an integer");if(e>>>=0,"number"!=typeof t||t%1!=0)throw TypeError("Illegal end: Not an integer");if(t>>>=0,e<0||e>t||t>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+e+" <= "+t+" <= "+this.buffer.byteLength)}var i=this.clone();return i.offset=e,i.limit=t,i},i.toBuffer=function(e){var t=this.offset,i=this.limit;if(!this.noAssert){if("number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: Not an integer");if(t>>>=0,"number"!=typeof i||i%1!=0)throw TypeError("Illegal limit: Not an integer");if(i>>>=0,t<0||t>i||i>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+t+" <= "+i+" <= "+this.buffer.byteLength)}if(!e&&0===t&&i===this.buffer.byteLength)return this.buffer;if(t===i)return r;var n=new ArrayBuffer(i-t);return new Uint8Array(n).set(new Uint8Array(this.buffer).subarray(t,i),0),n},i.toArrayBuffer=i.toBuffer,i.toString=function(e,t,i){if(void 0===e)return"ByteBufferAB(offset="+this.offset+",markedOffset="+this.markedOffset+",limit="+this.limit+",capacity="+this.capacity()+")";switch("number"==typeof e&&(i=t=e="utf8"),e){case"utf8":return this.toUTF8(t,i);case"base64":return this.toBase64(t,i);case"hex":return this.toHex(t,i);case"binary":return this.toBinary(t,i);case"debug":return this.toDebug();case"columns":return this.toColumns();default:throw Error("Unsupported encoding: "+e)}};var _=function(){for(var e={},t=[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],i=[],r=0,n=t.length;r<n;++r)i[t[r]]=r;return e.encode=function(e,i){for(var r,n;null!==(r=e());)i(t[r>>2&63]),n=(3&r)<<4,null!==(r=e())?(i(t[63&((n|=r>>4&15)|r>>4&15)]),n=(15&r)<<2,null!==(r=e())?(i(t[63&(n|r>>6&3)]),i(t[63&r])):(i(t[63&n]),i(61))):(i(t[63&n]),i(61),i(61))},e.decode=function(e,t){var r,n,s;function o(e){throw Error("Illegal character code: "+e)}for(;null!==(r=e());)if(void 0===(n=i[r])&&o(r),null!==(r=e())&&(void 0===(s=i[r])&&o(r),t(n<<2>>>0|(48&s)>>4),null!==(r=e()))){if(void 0===(n=i[r])){if(61===r)break;o(r)}if(t((15&s)<<4>>>0|(60&n)>>2),null!==(r=e())){if(void 0===(s=i[r])){if(61===r)break;o(r)}t((3&n)<<6>>>0|s)}}},e.test=function(e){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(e)},e}();i.toBase64=function(e,t){if(void 0===e&&(e=this.offset),void 0===t&&(t=this.limit),t|=0,(e|=0)<0||t>this.capacity||e>t)throw RangeError("begin, end");var i;return _.encode(function(){return e<t?this.view[e++]:null}.bind(this),i=o()),i()},t.fromBase64=function(e,i){if("string"!=typeof e)throw TypeError("str");var r=new t(e.length/4*3,i),n=0;return _.decode(s(e),(function(e){r.view[n++]=e})),r.limit=n,r},t.btoa=function(e){return t.fromBinary(e).toBase64()},t.atob=function(e){return t.fromBase64(e).toBinary()},i.toBinary=function(e,t){if(void 0===e&&(e=this.offset),void 0===t&&(t=this.limit),t|=0,(e|=0)<0||t>this.capacity()||e>t)throw RangeError("begin, end");if(e===t)return"";for(var i=[],r=[];e<t;)i.push(this.view[e++]),i.length>=1024&&(r.push(String.fromCharCode.apply(String,i)),i=[]);return r.join("")+String.fromCharCode.apply(String,i)},t.fromBinary=function(e,i){if("string"!=typeof e)throw TypeError("str");for(var r,n=0,s=e.length,o=new t(s,i);n<s;){if((r=e.charCodeAt(n))>255)throw RangeError("illegal char code: "+r);o.view[n++]=r}return o.limit=s,o},i.toDebug=function(e){for(var t,i=-1,r=this.buffer.byteLength,n="",s="",o="";i<r;){if(-1!==i&&(n+=(t=this.view[i])<16?"0"+t.toString(16).toUpperCase():t.toString(16).toUpperCase(),e&&(s+=t>32&&t<127?String.fromCharCode(t):".")),++i,e&&i>0&&i%16==0&&i!==r){for(;n.length<51;)n+=" ";o+=n+s+"\n",n=s=""}i===this.offset&&i===this.limit?n+=i===this.markedOffset?"!":"|":i===this.offset?n+=i===this.markedOffset?"[":"<":i===this.limit?n+=i===this.markedOffset?"]":">":n+=i===this.markedOffset?"'":e||0!==i&&i!==r?" ":""}if(e&&" "!==n){for(;n.length<51;)n+=" ";o+=n+s+"\n"}return e?o:n},t.fromDebug=function(e,i,r){for(var n,s,o=e.length,a=new t((o+1)/3|0,i,r),l=0,_=0,c=!1,d=!1,u=!1,h=!1,g=!1;l<o;){switch(n=e.charAt(l++)){case"!":if(!r){if(d||u||h){g=!0;break}d=u=h=!0}a.offset=a.markedOffset=a.limit=_,c=!1;break;case"|":if(!r){if(d||h){g=!0;break}d=h=!0}a.offset=a.limit=_,c=!1;break;case"[":if(!r){if(d||u){g=!0;break}d=u=!0}a.offset=a.markedOffset=_,c=!1;break;case"<":if(!r){if(d){g=!0;break}d=!0}a.offset=_,c=!1;break;case"]":if(!r){if(h||u){g=!0;break}h=u=!0}a.limit=a.markedOffset=_,c=!1;break;case">":if(!r){if(h){g=!0;break}h=!0}a.limit=_,c=!1;break;case"'":if(!r){if(u){g=!0;break}u=!0}a.markedOffset=_,c=!1;break;case" ":c=!1;break;default:if(!r&&c){g=!0;break}if(s=parseInt(n+e.charAt(l++),16),!r&&(isNaN(s)||s<0||s>255))throw TypeError("Illegal str: Not a debug encoded string");a.view[_++]=s,c=!0}if(g)throw TypeError("Illegal str: Invalid symbol at "+l)}if(!r){if(!d||!h)throw TypeError("Illegal str: Missing offset or limit");if(_<a.buffer.byteLength)throw TypeError("Illegal str: Not a debug encoded string (is it hex?) "+_+" < "+o)}return a},i.toHex=function(e,t){if(e=void 0===e?this.offset:e,t=void 0===t?this.limit:t,!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal begin: Not an integer");if(e>>>=0,"number"!=typeof t||t%1!=0)throw TypeError("Illegal end: Not an integer");if(t>>>=0,e<0||e>t||t>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+e+" <= "+t+" <= "+this.buffer.byteLength)}for(var i,r=new Array(t-e);e<t;)(i=this.view[e++])<16?r.push("0",i.toString(16)):r.push(i.toString(16));return r.join("")},t.fromHex=function(e,i,r){if(!r){if("string"!=typeof e)throw TypeError("Illegal str: Not a string");if(e.length%2!=0)throw TypeError("Illegal str: Length not a multiple of 2")}for(var n,s=e.length,o=new t(s/2|0,i),a=0,l=0;a<s;a+=2){if(n=parseInt(e.substring(a,a+2),16),!r&&(!isFinite(n)||n<0||n>255))throw TypeError("Illegal str: Contains non-hex characters");o.view[l++]=n}return o.limit=l,o};var c=function(){var e={MAX_CODEPOINT:1114111,encodeUTF8:function(e,t){var i=null;for("number"==typeof e&&(i=e,e=function(){return null});null!==i||null!==(i=e());)i<128?t(127&i):i<2048?(t(i>>6&31|192),t(63&i|128)):i<65536?(t(i>>12&15|224),t(i>>6&63|128),t(63&i|128)):(t(i>>18&7|240),t(i>>12&63|128),t(i>>6&63|128),t(63&i|128)),i=null},decodeUTF8:function(e,t){for(var i,r,n,s,o=function(e){e=e.slice(0,e.indexOf(null));var t=Error(e.toString());throw t.name="TruncatedError",t.bytes=e,t};null!==(i=e());)if(128&i)if(192==(224&i))null===(r=e())&&o([i,r]),t((31&i)<<6|63&r);else if(224==(240&i))(null===(r=e())||null===(n=e()))&&o([i,r,n]),t((15&i)<<12|(63&r)<<6|63&n);else{if(240!=(248&i))throw RangeError("Illegal starting byte: "+i);(null===(r=e())||null===(n=e())||null===(s=e()))&&o([i,r,n,s]),t((7&i)<<18|(63&r)<<12|(63&n)<<6|63&s)}else t(i)},UTF16toUTF8:function(e,t){for(var i,r=null;null!==(i=null!==r?r:e());)i>=55296&&i<=57343&&null!==(r=e())&&r>=56320&&r<=57343?(t(1024*(i-55296)+r-56320+65536),r=null):t(i);null!==r&&t(r)},UTF8toUTF16:function(e,t){var i=null;for("number"==typeof e&&(i=e,e=function(){return null});null!==i||null!==(i=e());)i<=65535?t(i):(t(55296+((i-=65536)>>10)),t(i%1024+56320)),i=null},encodeUTF16toUTF8:function(t,i){e.UTF16toUTF8(t,(function(t){e.encodeUTF8(t,i)}))},decodeUTF8toUTF16:function(t,i){e.decodeUTF8(t,(function(t){e.UTF8toUTF16(t,i)}))},calculateCodePoint:function(e){return e<128?1:e<2048?2:e<65536?3:4},calculateUTF8:function(e){for(var t,i=0;null!==(t=e());)i+=t<128?1:t<2048?2:t<65536?3:4;return i},calculateUTF16asUTF8:function(t){var i=0,r=0;return e.UTF16toUTF8(t,(function(e){++i,r+=e<128?1:e<2048?2:e<65536?3:4})),[i,r]}};return e}();return i.toUTF8=function(e,t){if(void 0===e&&(e=this.offset),void 0===t&&(t=this.limit),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal begin: Not an integer");if(e>>>=0,"number"!=typeof t||t%1!=0)throw TypeError("Illegal end: Not an integer");if(t>>>=0,e<0||e>t||t>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+e+" <= "+t+" <= "+this.buffer.byteLength)}var i;try{c.decodeUTF8toUTF16(function(){return e<t?this.view[e++]:null}.bind(this),i=o())}catch(i){if(e!==t)throw RangeError("Illegal range: Truncated data, "+e+" != "+t)}return i()},t.fromUTF8=function(e,i,r){if(!r&&"string"!=typeof e)throw TypeError("Illegal str: Not a string");var n=new t(c.calculateUTF16asUTF8(s(e),!0)[1],i,r),o=0;return c.encodeUTF16toUTF8(s(e),(function(e){n.view[o++]=e})),n.limit=o,n},t}(function(){function e(e,t,i){this.low=0|e,this.high=0|t,this.unsigned=!!i}function t(e){return!0===(e&&e.__isLong__)}e.prototype.__isLong__,Object.defineProperty(e.prototype,"__isLong__",{value:!0,enumerable:!1,configurable:!1}),e.isLong=t;var i={},r={};function n(e,t){var n,s,a;return t?(a=0<=(e>>>=0)&&e<256)&&(s=r[e])?s:(n=o(e,(0|e)<0?-1:0,!0),a&&(r[e]=n),n):(a=-128<=(e|=0)&&e<128)&&(s=i[e])?s:(n=o(e,e<0?-1:0,!1),a&&(i[e]=n),n)}function s(e,t){if(isNaN(e)||!isFinite(e))return t?p:g;if(t){if(e<0)return p;if(e>=d)return m}else{if(e<=-u)return R;if(e+1>=u)return T}return e<0?s(-e,t).neg():o(e%c|0,e/c|0,t)}function o(t,i,r){return new e(t,i,r)}e.fromInt=n,e.fromNumber=s,e.fromBits=o;var a=Math.pow;function l(e,t,i){if(0===e.length)throw Error("empty string");if("NaN"===e||"Infinity"===e||"+Infinity"===e||"-Infinity"===e)return g;if("number"==typeof t?(i=t,t=!1):t=!!t,(i=i||10)<2||36<i)throw RangeError("radix");var r;if((r=e.indexOf("-"))>0)throw Error("interior hyphen");if(0===r)return l(e.substring(1),t,i).neg();for(var n=s(a(i,8)),o=g,_=0;_<e.length;_+=8){var c=Math.min(8,e.length-_),d=parseInt(e.substring(_,_+c),i);if(c<8){var u=s(a(i,c));o=o.mul(u).add(s(d))}else o=(o=o.mul(n)).add(s(d))}return o.unsigned=t,o}function _(t){return t instanceof e?t:"number"==typeof t?s(t):"string"==typeof t?l(t):o(t.low,t.high,t.unsigned)}e.fromString=l,e.fromValue=_;var c=4294967296,d=c*c,u=d/2,h=n(1<<24),g=n(0);e.ZERO=g;var p=n(0,!0);e.UZERO=p;var f=n(1);e.ONE=f;var E=n(1,!0);e.UONE=E;var I=n(-1);e.NEG_ONE=I;var T=o(-1,2147483647,!1);e.MAX_VALUE=T;var m=o(-1,-1,!0);e.MAX_UNSIGNED_VALUE=m;var R=o(0,-2147483648,!1);e.MIN_VALUE=R;var S=e.prototype;return S.toInt=function(){return this.unsigned?this.low>>>0:this.low},S.toNumber=function(){return this.unsigned?(this.high>>>0)*c+(this.low>>>0):this.high*c+(this.low>>>0)},S.toString=function(e){if((e=e||10)<2||36<e)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative()){if(this.eq(R)){var t=s(e),i=this.div(t),r=i.mul(t).sub(this);return i.toString(e)+r.toInt().toString(e)}return"-"+this.neg().toString(e)}for(var n=s(a(e,6),this.unsigned),o=this,l="";;){var _=o.div(n),c=(o.sub(_.mul(n)).toInt()>>>0).toString(e);if((o=_).isZero())return c+l;for(;c.length<6;)c="0"+c;l=""+c+l}},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(){if(this.isNegative())return this.eq(R)?64:this.neg().getNumBitsAbs();for(var e=0!=this.high?this.high:this.low,t=31;t>0&&!(e&1<<t);t--);return 0!=this.high?t+33:t+1},S.isZero=function(){return 0===this.high&&0===this.low},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)},S.isEven=function(){return!(1&this.low)},S.equals=function(e){return t(e)||(e=_(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(t(e)||(e=_(e)),this.eq(e))return 0;var i=this.isNegative(),r=e.isNegative();return i&&!r?-1:!i&&r?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(R)?R:this.not().add(f)},S.neg=S.negate,S.add=function(e){t(e)||(e=_(e));var i=this.high>>>16,r=65535&this.high,n=this.low>>>16,s=65535&this.low,a=e.high>>>16,l=65535&e.high,c=e.low>>>16,d=0,u=0,h=0,g=0;return h+=(g+=s+(65535&e.low))>>>16,u+=(h+=n+c)>>>16,d+=(u+=r+l)>>>16,d+=i+a,o((h&=65535)<<16|(g&=65535),(d&=65535)<<16|(u&=65535),this.unsigned)},S.subtract=function(e){return t(e)||(e=_(e)),this.add(e.neg())},S.sub=S.subtract,S.multiply=function(e){if(this.isZero())return g;if(t(e)||(e=_(e)),e.isZero())return g;if(this.eq(R))return e.isOdd()?R:g;if(e.eq(R))return this.isOdd()?R:g;if(this.isNegative())return e.isNegative()?this.neg().mul(e.neg()):this.neg().mul(e).neg();if(e.isNegative())return this.mul(e.neg()).neg();if(this.lt(h)&&e.lt(h))return s(this.toNumber()*e.toNumber(),this.unsigned);var i=this.high>>>16,r=65535&this.high,n=this.low>>>16,a=65535&this.low,l=e.high>>>16,c=65535&e.high,d=e.low>>>16,u=65535&e.low,p=0,f=0,E=0,I=0;return E+=(I+=a*u)>>>16,f+=(E+=n*u)>>>16,E&=65535,f+=(E+=a*d)>>>16,p+=(f+=r*u)>>>16,f&=65535,p+=(f+=n*d)>>>16,f&=65535,p+=(f+=a*c)>>>16,p+=i*u+r*d+n*c+a*l,o((E&=65535)<<16|(I&=65535),(p&=65535)<<16|(f&=65535),this.unsigned)},S.mul=S.multiply,S.divide=function(e){if(t(e)||(e=_(e)),e.isZero())throw Error("division by zero");if(this.isZero())return this.unsigned?p:g;var i,r,n;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return p;if(e.gt(this.shru(1)))return E;n=p}else{if(this.eq(R))return e.eq(f)||e.eq(I)?R:e.eq(R)?f:(i=this.shr(1).div(e).shl(1)).eq(g)?e.isNegative()?f:I:(r=this.sub(e.mul(i)),n=i.add(r.div(e)));if(e.eq(R))return this.unsigned?p:g;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();n=g}for(r=this;r.gte(e);){i=Math.max(1,Math.floor(r.toNumber()/e.toNumber()));for(var o=Math.ceil(Math.log(i)/Math.LN2),l=o<=48?1:a(2,o-48),c=s(i),d=c.mul(e);d.isNegative()||d.gt(r);)d=(c=s(i-=l,this.unsigned)).mul(e);c.isZero()&&(c=f),n=n.add(c),r=r.sub(d)}return n},S.div=S.divide,S.modulo=function(e){return t(e)||(e=_(e)),this.sub(this.div(e).mul(e))},S.mod=S.modulo,S.not=function(){return o(~this.low,~this.high,this.unsigned)},S.and=function(e){return t(e)||(e=_(e)),o(this.low&e.low,this.high&e.high,this.unsigned)},S.or=function(e){return t(e)||(e=_(e)),o(this.low|e.low,this.high|e.high,this.unsigned)},S.xor=function(e){return t(e)||(e=_(e)),o(this.low^e.low,this.high^e.high,this.unsigned)},S.shiftLeft=function(e){return t(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?o(this.low<<e,this.high<<e|this.low>>>32-e,this.unsigned):o(0,this.low<<e-32,this.unsigned)},S.shl=S.shiftLeft,S.shiftRight=function(e){return t(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?o(this.low>>>e|this.high<<32-e,this.high>>e,this.unsigned):o(this.high>>e-32,this.high>=0?0:-1,this.unsigned)},S.shr=S.shiftRight,S.shiftRightUnsigned=function(e){if(t(e)&&(e=e.toInt()),0===(e&=63))return this;var i=this.high;return e<32?o(this.low>>>e|i<<32-e,i>>>e,this.unsigned):o(32===e?i:i>>>e-32,0,this.unsigned)},S.shru=S.shiftRightUnsigned,S.toSigned=function(){return this.unsigned?o(this.low,this.high,!1):this},S.toUnsigned=function(){return this.unsigned?this:o(this.low,this.high,!0)},S.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()},S.toBytesLE=function(){var e=this.high,t=this.low;return[255&t,t>>>8&255,t>>>16&255,t>>>24&255,255&e,e>>>8&255,e>>>16&255,e>>>24&255]},S.toBytesBE=function(){var e=this.high,t=this.low;return[e>>>24&255,e>>>16&255,e>>>8&255,255&e,t>>>24&255,t>>>16&255,t>>>8&255,255&t]},e}());return t.ByteBuffer=i,t.Long=i.Long||null,t.VERSION="5.0.3",t.WIRE_TYPES={},t.WIRE_TYPES.VARINT=0,t.WIRE_TYPES.BITS64=1,t.WIRE_TYPES.LDELIM=2,t.WIRE_TYPES.STARTGROUP=3,t.WIRE_TYPES.ENDGROUP=4,t.WIRE_TYPES.BITS32=5,t.PACKABLE_WIRE_TYPES=[t.WIRE_TYPES.VARINT,t.WIRE_TYPES.BITS64,t.WIRE_TYPES.BITS32],t.TYPES={int32:{name:"int32",wireType:t.WIRE_TYPES.VARINT,defaultValue:0},uint32:{name:"uint32",wireType:t.WIRE_TYPES.VARINT,defaultValue:0},sint32:{name:"sint32",wireType:t.WIRE_TYPES.VARINT,defaultValue:0},int64:{name:"int64",wireType:t.WIRE_TYPES.VARINT,defaultValue:t.Long?t.Long.ZERO:void 0},uint64:{name:"uint64",wireType:t.WIRE_TYPES.VARINT,defaultValue:t.Long?t.Long.UZERO:void 0},sint64:{name:"sint64",wireType:t.WIRE_TYPES.VARINT,defaultValue:t.Long?t.Long.ZERO:void 0},bool:{name:"bool",wireType:t.WIRE_TYPES.VARINT,defaultValue:!1},double:{name:"double",wireType:t.WIRE_TYPES.BITS64,defaultValue:0},string:{name:"string",wireType:t.WIRE_TYPES.LDELIM,defaultValue:""},bytes:{name:"bytes",wireType:t.WIRE_TYPES.LDELIM,defaultValue:null},fixed32:{name:"fixed32",wireType:t.WIRE_TYPES.BITS32,defaultValue:0},sfixed32:{name:"sfixed32",wireType:t.WIRE_TYPES.BITS32,defaultValue:0},fixed64:{name:"fixed64",wireType:t.WIRE_TYPES.BITS64,defaultValue:t.Long?t.Long.UZERO:void 0},sfixed64:{name:"sfixed64",wireType:t.WIRE_TYPES.BITS64,defaultValue:t.Long?t.Long.ZERO:void 0},float:{name:"float",wireType:t.WIRE_TYPES.BITS32,defaultValue:0},enum:{name:"enum",wireType:t.WIRE_TYPES.VARINT,defaultValue:0},message:{name:"message",wireType:t.WIRE_TYPES.LDELIM,defaultValue:null},group:{name:"group",wireType:t.WIRE_TYPES.STARTGROUP,defaultValue:null}},t.MAP_KEY_TYPES=[t.TYPES.int32,t.TYPES.sint32,t.TYPES.sfixed32,t.TYPES.uint32,t.TYPES.fixed32,t.TYPES.int64,t.TYPES.sint64,t.TYPES.sfixed64,t.TYPES.uint64,t.TYPES.fixed64,t.TYPES.bool,t.TYPES.string,t.TYPES.bytes],t.ID_MIN=1,t.ID_MAX=536870911,t.convertFieldsToCamelCase=!1,t.populateAccessors=!0,t.populateDefaults=!0,t.Util=((e={}).IS_NODE=!("object"!=typeof process||process+""!="[object process]"||process.browser),e.toCamelCase=function(e){return e.replace(/_([a-zA-Z])/g,(function(e,t){return t.toUpperCase()}))},e),t.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]*)(?:\.[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},t.DotProto=function(e,t){var i={},r=function(e){this.source=e+"",this.index=0,this.line=1,this.stack=[],this._stringOpen=null},n=r.prototype;n._readString=function(){var e='"'===this._stringOpen?t.STRING_DQ:t.STRING_SQ;e.lastIndex=this.index-1;var i=e.exec(this.source);if(!i)throw Error("unterminated string");return this.index=e.lastIndex,this.stack.push(this._stringOpen),this._stringOpen=null,i[1]},n.next=function(){if(this.stack.length>0)return this.stack.shift();if(this.index>=this.source.length)return null;if(null!==this._stringOpen)return this._readString();var e,i,r;do{for(e=!1;t.WHITESPACE.test(r=this.source.charAt(this.index));)if("\n"===r&&++this.line,++this.index===this.source.length)return null;if("/"===this.source.charAt(this.index))if(++this.index,"/"===this.source.charAt(this.index)){for(;"\n"!==this.source.charAt(++this.index);)if(this.index==this.source.length)return null;++this.index,++this.line,e=!0}else{if("*"!==(r=this.source.charAt(this.index)))return"/";do{if("\n"===r&&++this.line,++this.index===this.source.length)return null;i=r,r=this.source.charAt(this.index)}while("*"!==i||"/"!==r);++this.index,e=!0}}while(e);if(this.index===this.source.length)return null;var n=this.index;if(t.DELIM.lastIndex=0,!t.DELIM.test(this.source.charAt(n++)))for(;n<this.source.length&&!t.DELIM.test(this.source.charAt(n));)++n;var s=this.source.substring(this.index,this.index=n);return'"'!==s&&"'"!==s||(this._stringOpen=s),s},n.peek=function(){if(0===this.stack.length){var e=this.next();if(null===e)return null;this.stack.push(e)}return this.stack[0]},n.skip=function(e){var t=this.next();if(t!==e)throw Error("illegal '"+t+"', '"+e+"' expected")},n.omit=function(e){return this.peek()===e&&(this.next(),!0)},n.toString=function(){return"Tokenizer ("+this.index+"/"+this.source.length+" at line "+this.line+")"},i.Tokenizer=r;var s=function(e){this.tn=new r(e),this.proto3=!1},o=s.prototype;function a(e,i){var r=-1,n=1;if("-"==e.charAt(0)&&(n=-1,e=e.substring(1)),t.NUMBER_DEC.test(e))r=parseInt(e);else if(t.NUMBER_HEX.test(e))r=parseInt(e.substring(2),16);else{if(!t.NUMBER_OCT.test(e))throw Error("illegal id value: "+(n<0?"-":"")+e);r=parseInt(e.substring(1),8)}if(r=n*r|0,!i&&r<0)throw Error("illegal id value: "+(n<0?"-":"")+e);return r}function l(e){var i=1;if("-"==e.charAt(0)&&(i=-1,e=e.substring(1)),t.NUMBER_DEC.test(e))return i*parseInt(e,10);if(t.NUMBER_HEX.test(e))return i*parseInt(e.substring(2),16);if(t.NUMBER_OCT.test(e))return i*parseInt(e.substring(1),8);if("inf"===e)return i*(1/0);if("nan"===e)return NaN;if(t.NUMBER_FLT.test(e))return i*parseFloat(e);throw Error("illegal number value: "+(i<0?"-":"")+e)}function _(e,t,i){void 0===e[t]?e[t]=i:(Array.isArray(e[t])||(e[t]=[e[t]]),e[t].push(i))}return o.parse=function(){var e,i,r={name:"[ROOT]",package:null,messages:[],enums:[],imports:[],options:{},services:[]},n=!0;try{for(;e=this.tn.next();)switch(e){case"package":if(!n||null!==r.package)throw Error("unexpected 'package'");if(e=this.tn.next(),!t.TYPEREF.test(e))throw Error("illegal package name: "+e);this.tn.skip(";"),r.package=e;break;case"import":if(!n)throw Error("unexpected 'import'");("public"===(e=this.tn.peek())||(i="weak"===e))&&this.tn.next(),e=this._readString(),this.tn.skip(";"),i||r.imports.push(e);break;case"syntax":if(!n)throw Error("unexpected 'syntax'");this.tn.skip("="),"proto3"===(r.syntax=this._readString())&&(this.proto3=!0),this.tn.skip(";");break;case"message":this._parseMessage(r,null),n=!1;break;case"enum":this._parseEnum(r),n=!1;break;case"option":this._parseOption(r);break;case"service":this._parseService(r);break;case"extend":this._parseExtend(r);break;default:throw Error("unexpected '"+e+"'")}}catch(e){throw e.message="Parse error at line "+this.tn.line+": "+e.message,e}return delete r.name,r},s.parse=function(e){return new s(e).parse()},o._readString=function(){var e,t,i="";do{if("'"!==(t=this.tn.next())&&'"'!==t)throw Error("illegal string delimiter: "+t);i+=this.tn.next(),this.tn.skip(t),e=this.tn.peek()}while('"'===e||'"'===e);return i},o._readValue=function(e){var i=this.tn.peek();if('"'===i||"'"===i)return this._readString();if(this.tn.next(),t.NUMBER.test(i))return l(i);if(t.BOOL.test(i))return"true"===i.toLowerCase();if(e&&t.TYPEREF.test(i))return i;throw Error("illegal value: "+i)},o._parseOption=function(e,i){var r=this.tn.next(),n=!1;if("("===r&&(n=!0,r=this.tn.next()),!t.TYPEREF.test(r))throw Error("illegal option name: "+r);var s=r;n&&(this.tn.skip(")"),s="("+s+")",r=this.tn.peek(),t.FQTYPEREF.test(r)&&(s+=r,this.tn.next())),this.tn.skip("="),this._parseOptionValue(e,s),i||this.tn.skip(";")},o._parseOptionValue=function(e,i){var r=this.tn.peek();if("{"!==r)_(e.options,i,this._readValue(!0));else for(this.tn.skip("{");"}"!==(r=this.tn.next());){if(!t.NAME.test(r))throw Error("illegal option name: "+i+"."+r);this.tn.omit(":")?_(e.options,i+"."+r,this._readValue(!0)):this._parseOptionValue(e,i+"."+r)}},o._parseService=function(e){var i=this.tn.next();if(!t.NAME.test(i))throw Error("illegal service name at line "+this.tn.line+": "+i);var r={name:i,rpc:{},options:{}};for(this.tn.skip("{");"}"!==(i=this.tn.next());)if("option"===i)this._parseOption(r);else{if("rpc"!==i)throw Error("illegal service token: "+i);this._parseServiceRPC(r)}this.tn.omit(";"),e.services.push(r)},o._parseServiceRPC=function(e){var i="rpc",r=this.tn.next();if(!t.NAME.test(r))throw Error("illegal rpc service method name: "+r);var n=r,s={request:null,response:null,request_stream:!1,response_stream:!1,options:{}};if(this.tn.skip("("),"stream"===(r=this.tn.next()).toLowerCase()&&(s.request_stream=!0,r=this.tn.next()),!t.TYPEREF.test(r))throw Error("illegal rpc service request type: "+r);if(s.request=r,this.tn.skip(")"),"returns"!==(r=this.tn.next()).toLowerCase())throw Error("illegal rpc service request type delimiter: "+r);if(this.tn.skip("("),"stream"===(r=this.tn.next()).toLowerCase()&&(s.response_stream=!0,r=this.tn.next()),s.response=r,this.tn.skip(")"),"{"===(r=this.tn.peek())){for(this.tn.next();"}"!==(r=this.tn.next());){if("option"!==r)throw Error("illegal rpc service token: "+r);this._parseOption(s)}this.tn.omit(";")}else this.tn.skip(";");void 0===e[i]&&(e[i]={}),e[i][n]=s},o._parseMessage=function(e,i){var r=!!i,n=this.tn.next(),s={name:"",fields:[],enums:[],messages:[],options:{},services:[],oneofs:{}};if(!t.NAME.test(n))throw Error("illegal "+(r?"group":"message")+" name: "+n);for(s.name=n,r&&(this.tn.skip("="),i.id=a(this.tn.next()),s.isGroup=!0),"["===(n=this.tn.peek())&&i&&this._parseFieldOptions(i),this.tn.skip("{");"}"!==(n=this.tn.next());)if(t.RULE.test(n))this._parseMessageField(s,n);else if("oneof"===n)this._parseMessageOneOf(s);else if("enum"===n)this._parseEnum(s);else if("message"===n)this._parseMessage(s);else if("option"===n)this._parseOption(s);else if("service"===n)this._parseService(s);else if("extensions"===n)s.hasOwnProperty("extensions")?s.extensions=s.extensions.concat(this._parseExtensionRanges()):s.extensions=this._parseExtensionRanges();else if("reserved"===n)this._parseIgnored();else if("extend"===n)this._parseExtend(s);else{if(!t.TYPEREF.test(n))throw Error("illegal message token: "+n);if(!this.proto3)throw Error("illegal field rule: "+n);this._parseMessageField(s,"optional",n)}return this.tn.omit(";"),e.messages.push(s),s},o._parseIgnored=function(){for(;";"!==this.tn.peek();)this.tn.next();this.tn.skip(";")},o._parseMessageField=function(e,i,r){if(!t.RULE.test(i))throw Error("illegal message field rule: "+i);var n,s={rule:i,type:"",name:"",options:{},id:0};if("map"===i){if(r)throw Error("illegal type: "+r);if(this.tn.skip("<"),n=this.tn.next(),!t.TYPE.test(n)&&!t.TYPEREF.test(n))throw Error("illegal message field type: "+n);if(s.keytype=n,this.tn.skip(","),n=this.tn.next(),!t.TYPE.test(n)&&!t.TYPEREF.test(n))throw Error("illegal message field: "+n);if(s.type=n,this.tn.skip(">"),n=this.tn.next(),!t.NAME.test(n))throw Error("illegal message field name: "+n);s.name=n,this.tn.skip("="),s.id=a(this.tn.next()),"["===(n=this.tn.peek())&&this._parseFieldOptions(s),this.tn.skip(";")}else if("group"===(r=void 0!==r?r:this.tn.next())){var o=this._parseMessage(e,s);if(!/^[A-Z]/.test(o.name))throw Error("illegal group name: "+o.name);s.type=o.name,s.name=o.name.toLowerCase(),this.tn.omit(";")}else{if(!t.TYPE.test(r)&&!t.TYPEREF.test(r))throw Error("illegal message field type: "+r);if(s.type=r,n=this.tn.next(),!t.NAME.test(n))throw Error("illegal message field name: "+n);s.name=n,this.tn.skip("="),s.id=a(this.tn.next()),"["===(n=this.tn.peek())&&this._parseFieldOptions(s),this.tn.skip(";")}return e.fields.push(s),s},o._parseMessageOneOf=function(e){var i=this.tn.next();if(!t.NAME.test(i))throw Error("illegal oneof name: "+i);var r,n=i,s=[];for(this.tn.skip("{");"}"!==(i=this.tn.next());)(r=this._parseMessageField(e,"optional",i)).oneof=n,s.push(r.id);this.tn.omit(";"),e.oneofs[n]=s},o._parseFieldOptions=function(e){this.tn.skip("[");for(var t=!0;"]"!==this.tn.peek();)t||this.tn.skip(","),this._parseOption(e,!0),t=!1;this.tn.next()},o._parseEnum=function(e){var i={name:"",values:[],options:{}},r=this.tn.next();if(!t.NAME.test(r))throw Error("illegal name: "+r);for(i.name=r,this.tn.skip("{");"}"!==(r=this.tn.next());)if("option"===r)this._parseOption(i);else{if(!t.NAME.test(r))throw Error("illegal name: "+r);this.tn.skip("=");var n={name:r,id:a(this.tn.next(),!0)};"["===(r=this.tn.peek())&&this._parseFieldOptions({options:{}}),this.tn.skip(";"),i.values.push(n)}this.tn.omit(";"),e.enums.push(i)},o._parseExtensionRanges=function(){var t,i,r,n=[];do{for(i=[];;){switch(t=this.tn.next()){case"min":r=e.ID_MIN;break;case"max":r=e.ID_MAX;break;default:r=l(t)}if(i.push(r),2===i.length)break;if("to"!==this.tn.peek()){i.push(r);break}this.tn.next()}n.push(i)}while(this.tn.omit(","));return this.tn.skip(";"),n},o._parseExtend=function(e){var i=this.tn.next();if(!t.TYPEREF.test(i))throw Error("illegal extend reference: "+i);var r={ref:i,fields:[]};for(this.tn.skip("{");"}"!==(i=this.tn.next());)if(t.RULE.test(i))this._parseMessageField(r,i);else{if(!t.TYPEREF.test(i))throw Error("illegal extend token: "+i);if(!this.proto3)throw Error("illegal field rule: "+i);this._parseMessageField(r,"optional",i)}return this.tn.omit(";"),e.messages.push(r),r},o.toString=function(){return"Parser at line "+this.tn.line},i.Parser=s,i}(t,t.Lang),t.Reflect=function(e){var t={},r=function(e,t,i){this.builder=e,this.parent=t,this.name=i,this.className},n=r.prototype;n.fqn=function(){for(var e=this.name,t=this;;){if(null==(t=t.parent))break;e=t.name+"."+e}return e},n.toString=function(e){return(e?this.className+" ":"")+this.fqn()},n.build=function(){throw Error(this.toString(!0)+" cannot be built directly")},t.T=r;var s=function(e,t,i,n,s){r.call(this,e,t,i),this.className="Namespace",this.children=[],this.options=n||{},this.syntax=s||"proto2"},o=s.prototype=Object.create(r.prototype);o.getChildren=function(e){if(null==(e=e||null))return this.children.slice();for(var t=[],i=0,r=this.children.length;i<r;++i)this.children[i]instanceof e&&t.push(this.children[i]);return t},o.addChild=function(e){var t;if(t=this.getChild(e.name))if(t instanceof c.Field&&t.name!==t.originalName&&null===this.getChild(t.originalName))t.name=t.originalName;else{if(!(e instanceof c.Field&&e.name!==e.originalName&&null===this.getChild(e.originalName)))throw Error("Duplicate name in namespace "+this.toString(!0)+": "+e.name);e.name=e.originalName}this.children.push(e)},o.getChild=function(e){for(var t="number"==typeof e?"id":"name",i=0,r=this.children.length;i<r;++i)if(this.children[i][t]===e)return this.children[i];return null},o.resolve=function(e,i){var r,n="string"==typeof e?e.split("."):e,s=this,o=0;if(""===n[o]){for(;null!==s.parent;)s=s.parent;o++}do{do{if(!(s instanceof t.Namespace)){s=null;break}if(!(r=s.getChild(n[o]))||!(r instanceof t.T)||i&&!(r instanceof t.Namespace)){s=null;break}s=r,o++}while(o<n.length);if(null!=s)break;if(null!==this.parent)return this.parent.resolve(e,i)}while(null!=s);return s},o.qn=function(e){var i=[],r=e;do{i.unshift(r.name),r=r.parent}while(null!==r);for(var n=1;n<=i.length;n++){var s=i.slice(i.length-n);if(e===this.resolve(s,e instanceof t.Namespace))return s.join(".")}return e.fqn()},o.build=function(){for(var e,t={},i=this.children,r=0,n=i.length;r<n;++r)(e=i[r])instanceof s&&(t[e.name]=e.build());return Object.defineProperty&&Object.defineProperty(t,"$options",{value:this.buildOpt()}),t},o.buildOpt=function(){for(var e={},t=Object.keys(this.options),i=0,r=t.length;i<r;++i){var n=t[i],s=this.options[t[i]];e[n]=s}return e},o.getOption=function(e){return void 0===e?this.options:void 0!==this.options[e]?this.options[e]:null},t.Namespace=s;var a=function(t,i,r,n,s){if(this.type=t,this.resolvedType=i,this.isMapKey=r,this.syntax=n,this.name=s,r&&e.MAP_KEY_TYPES.indexOf(t)<0)throw Error("Invalid map key type: "+t.name)},l=a.prototype;function _(t,i){if(t&&"number"==typeof t.low&&"number"==typeof t.high&&"boolean"==typeof t.unsigned&&t.low==t.low&&t.high==t.high)return new e.Long(t.low,t.high,void 0===i?t.unsigned:i);if("string"==typeof t)return e.Long.fromString(t,i||!1,10);if("number"==typeof t)return e.Long.fromNumber(t,i||!1);throw Error("not convertible to Long")}a.defaultFieldValue=function(t){if("string"==typeof t&&(t=e.TYPES[t]),void 0===t.defaultValue)throw Error("default value for type "+t.name+" is not supported");return t==e.TYPES.bytes?new i(0):t.defaultValue},l.toString=function(){return(this.name||"")+(this.isMapKey?"map":"value")+" element"},l.verifyValue=function(t){var r=this;function n(e,t){throw Error("Illegal value for "+r.toString(!0)+" of type "+r.type.name+": "+e+" ("+t+")")}switch(this.type){case e.TYPES.int32:case e.TYPES.sint32:case e.TYPES.sfixed32:return("number"!=typeof t||t==t&&t%1!=0)&&n(typeof t,"not an integer"),t>4294967295?0|t:t;case e.TYPES.uint32:case e.TYPES.fixed32:return("number"!=typeof t||t==t&&t%1!=0)&&n(typeof t,"not an integer"),t<0?t>>>0:t;case e.TYPES.int64:case e.TYPES.sint64:case e.TYPES.sfixed64:if(e.Long)try{return _(t,!1)}catch(e){n(typeof t,e.message)}else n(typeof t,"requires Long.js");case e.TYPES.uint64:case e.TYPES.fixed64:if(e.Long)try{return _(t,!0)}catch(e){n(typeof t,e.message)}else n(typeof t,"requires Long.js");case e.TYPES.bool:return"boolean"!=typeof t&&n(typeof t,"not a boolean"),t;case e.TYPES.float:case e.TYPES.double:return"number"!=typeof t&&n(typeof t,"not a number"),t;case e.TYPES.string:return"string"==typeof t||t&&t instanceof String||n(typeof t,"not a string"),""+t;case e.TYPES.bytes:return i.isByteBuffer(t)?t:i.wrap(t,"base64");case e.TYPES.enum:var s=this.resolvedType.getChildren(e.Reflect.Enum.Value);for(a=0;a<s.length;a++){if(s[a].name==t)return s[a].id;if(s[a].id==t)return s[a].id}if("proto3"===this.syntax)return("number"!=typeof t||t==t&&t%1!=0)&&n(typeof t,"not an integer"),(t>4294967295||t<0)&&n(typeof t,"not in range for uint32"),t;n(t,"not a valid enum value");case e.TYPES.group:case e.TYPES.message:if(t&&"object"==typeof t||n(typeof t,"object expected"),t instanceof this.resolvedType.clazz)return t;if(t instanceof e.Builder.Message){var o={};for(var a in t)t.hasOwnProperty(a)&&(o[a]=t[a]);t=o}return new this.resolvedType.clazz(t)}throw Error("[INTERNAL] Illegal value for "+this.toString(!0)+": "+t+" (undefined type "+this.type+")")},l.calculateLength=function(t,r){if(null===r)return 0;var n;switch(this.type){case e.TYPES.int32:return r<0?i.calculateVarint64(r):i.calculateVarint32(r);case e.TYPES.uint32:return i.calculateVarint32(r);case e.TYPES.sint32:return i.calculateVarint32(i.zigZagEncode32(r));case e.TYPES.fixed32:case e.TYPES.sfixed32:case e.TYPES.float:return 4;case e.TYPES.int64:case e.TYPES.uint64:return i.calculateVarint64(r);case e.TYPES.sint64:return i.calculateVarint64(i.zigZagEncode64(r));case e.TYPES.fixed64:case e.TYPES.sfixed64:return 8;case e.TYPES.bool:return 1;case e.TYPES.enum:return i.calculateVarint32(r);case e.TYPES.double:return 8;case e.TYPES.string:return n=i.calculateUTF8Bytes(r),i.calculateVarint32(n)+n;case e.TYPES.bytes:if(r.remaining()<0)throw Error("Illegal value for "+this.toString(!0)+": "+r.remaining()+" bytes remaining");return i.calculateVarint32(r.remaining())+r.remaining();case e.TYPES.message:return n=this.resolvedType.calculate(r),i.calculateVarint32(n)+n;case e.TYPES.group:return(n=this.resolvedType.calculate(r))+i.calculateVarint32(t<<3|e.WIRE_TYPES.ENDGROUP)}throw Error("[INTERNAL] Illegal value to encode in "+this.toString(!0)+": "+r+" (unknown type)")},l.encodeValue=function(t,r,n){if(null===r)return n;switch(this.type){case e.TYPES.int32:r<0?n.writeVarint64(r):n.writeVarint32(r);break;case e.TYPES.uint32:n.writeVarint32(r);break;case e.TYPES.sint32:n.writeVarint32ZigZag(r);break;case e.TYPES.fixed32:n.writeUint32(r);break;case e.TYPES.sfixed32:n.writeInt32(r);break;case e.TYPES.int64:case e.TYPES.uint64:n.writeVarint64(r);break;case e.TYPES.sint64:n.writeVarint64ZigZag(r);break;case e.TYPES.fixed64:n.writeUint64(r);break;case e.TYPES.sfixed64:n.writeInt64(r);break;case e.TYPES.bool:"string"==typeof r?n.writeVarint32("false"===r.toLowerCase()?0:!!r):n.writeVarint32(r?1:0);break;case e.TYPES.enum:n.writeVarint32(r);break;case e.TYPES.float:n.writeFloat32(r);break;case e.TYPES.double:n.writeFloat64(r);break;case e.TYPES.string:n.writeVString(r);break;case e.TYPES.bytes:if(r.remaining()<0)throw Error("Illegal value for "+this.toString(!0)+": "+r.remaining()+" bytes remaining");var s=r.offset;n.writeVarint32(r.remaining()),n.append(r),r.offset=s;break;case e.TYPES.message:var o=(new i).LE();this.resolvedType.encode(r,o),n.writeVarint32(o.offset),n.append(o.flip());break;case e.TYPES.group:this.resolvedType.encode(r,n),n.writeVarint32(t<<3|e.WIRE_TYPES.ENDGROUP);break;default:throw Error("[INTERNAL] Illegal value to encode in "+this.toString(!0)+": "+r+" (unknown type)")}return n},l.decode=function(t,i,r){if(i!=this.type.wireType)throw Error("Unexpected wire type for element");var n,s;switch(this.type){case e.TYPES.int32:return 0|t.readVarint32();case e.TYPES.uint32:return t.readVarint32()>>>0;case e.TYPES.sint32:return 0|t.readVarint32ZigZag();case e.TYPES.fixed32:return t.readUint32()>>>0;case e.TYPES.sfixed32:return 0|t.readInt32();case e.TYPES.int64:return t.readVarint64();case e.TYPES.uint64:return t.readVarint64().toUnsigned();case e.TYPES.sint64:return t.readVarint64ZigZag();case e.TYPES.fixed64:return t.readUint64();case e.TYPES.sfixed64:return t.readInt64();case e.TYPES.bool:return!!t.readVarint32();case e.TYPES.enum:return t.readVarint32();case e.TYPES.float:return t.readFloat();case e.TYPES.double:return t.readDouble();case e.TYPES.string:return t.readVString();case e.TYPES.bytes:if(s=t.readVarint32(),t.remaining()<s)throw Error("Illegal number of bytes for "+this.toString(!0)+": "+s+" required but got only "+t.remaining());return(n=t.clone()).limit=n.offset+s,t.offset+=s,n;case e.TYPES.message:return s=t.readVarint32(),this.resolvedType.decode(t,s);case e.TYPES.group:return this.resolvedType.decode(t,-1,r)}throw Error("[INTERNAL] Illegal decode type")},l.valueFromString=function(t){if(!this.isMapKey)throw Error("valueFromString() called on non-map-key element");switch(this.type){case e.TYPES.int32:case e.TYPES.sint32:case e.TYPES.sfixed32:case e.TYPES.uint32:case e.TYPES.fixed32:return this.verifyValue(parseInt(t));case e.TYPES.int64:case e.TYPES.sint64:case e.TYPES.sfixed64:case e.TYPES.uint64:case e.TYPES.fixed64:return this.verifyValue(t);case e.TYPES.bool:return"true"===t;case e.TYPES.string:return this.verifyValue(t);case e.TYPES.bytes:return i.fromBinary(t)}},l.valueToString=function(t){if(!this.isMapKey)throw Error("valueToString() called on non-map-key element");return this.type===e.TYPES.bytes?t.toString("binary"):t.toString()},t.Element=a;var c=function(e,t,i,r,n,o){s.call(this,e,t,i,r,o),this.className="Message",this.extensions=void 0,this.clazz=null,this.isGroup=!!n,this._fields=null,this._fieldsById=null,this._fieldsByName=null},d=c.prototype=Object.create(s.prototype);function u(t,i){var r=i.readVarint32(),n=7&r,s=r>>>3;switch(n){case e.WIRE_TYPES.VARINT:do{r=i.readUint8()}while(!(128&~r));break;case e.WIRE_TYPES.BITS64:i.offset+=8;break;case e.WIRE_TYPES.LDELIM:r=i.readVarint32(),i.offset+=r;break;case e.WIRE_TYPES.STARTGROUP:u(s,i);break;case e.WIRE_TYPES.ENDGROUP:if(s===t)return!1;throw Error("Illegal GROUPEND after unknown group: "+s+" ("+t+" expected)");case e.WIRE_TYPES.BITS32:i.offset+=4;break;default:throw Error("Illegal wire type in unknown group "+t+": "+n)}return!0}d.build=function(t){if(this.clazz&&!t)return this.clazz;var r=function(e,t){var r=t.getChildren(e.Reflect.Message.Field),n=t.getChildren(e.Reflect.Message.OneOf),s=function(o,a){e.Builder.Message.call(this);for(var l=0,_=n.length;l<_;++l)this[n[l].name]=null;for(l=0,_=r.length;l<_;++l){var c=r[l];this[c.name]=c.repeated?[]:c.map?new e.Map(c):null,!c.required&&"proto3"!==t.syntax||null===c.defaultValue||(this[c.name]=c.defaultValue)}var d;if(arguments.length>0)if(1!==arguments.length||null===o||"object"!=typeof o||!("function"!=typeof o.encode||o instanceof s)||Array.isArray(o)||o instanceof e.Map||i.isByteBuffer(o)||o instanceof ArrayBuffer||e.Long&&o instanceof e.Long)for(l=0,_=arguments.length;l<_;++l)void 0!==(d=arguments[l])&&this.$set(r[l].name,d);else this.$set(o)},o=s.prototype=Object.create(e.Builder.Message.prototype);o.add=function(i,r,n){var s=t._fieldsByName[i];if(!n){if(!s)throw Error(this+"#"+i+" is undefined");if(!(s instanceof e.Reflect.Message.Field))throw Error(this+"#"+i+" is not a field: "+s.toString(!0));if(!s.repeated)throw Error(this+"#"+i+" is not a repeated field");r=s.verifyValue(r,!0)}return null===this[i]&&(this[i]=[]),this[i].push(r),this},o.$add=o.add,o.set=function(i,r,n){if(i&&"object"==typeof i){for(var s in n=r,i)i.hasOwnProperty(s)&&void 0!==(r=i[s])&&void 0===t._oneofsByName[s]&&this.$set(s,r,n);return this}var o=t._fieldsByName[i];if(n)this[i]=r;else{if(!o)throw Error(this+"#"+i+" is not a field: undefined");if(!(o instanceof e.Reflect.Message.Field))throw Error(this+"#"+i+" is not a field: "+o.toString(!0));this[o.name]=r=o.verifyValue(r)}if(o&&o.oneof){var a=this[o.oneof.name];null!==r?(null!==a&&a!==o.name&&(this[a]=null),this[o.oneof.name]=o.name):a===i&&(this[o.oneof.name]=null)}return this},o.$set=o.set,o.get=function(i,r){if(r)return this[i];var n=t._fieldsByName[i];if(!(n&&n instanceof e.Reflect.Message.Field))throw Error(this+"#"+i+" is not a field: undefined");if(!(n instanceof e.Reflect.Message.Field))throw Error(this+"#"+i+" is not a field: "+n.toString(!0));return this[n.name]},o.$get=o.get;for(var a=0;a<r.length;a++){var l=r[a];l instanceof e.Reflect.Message.ExtensionField||t.builder.options.populateAccessors&&function(e){var i=e.originalName.replace(/(_[a-zA-Z])/g,(function(e){return e.toUpperCase().replace("_","")}));i=i.substring(0,1).toUpperCase()+i.substring(1);var r=e.originalName.replace(/([A-Z])/g,(function(e){return"_"+e})),n=function(t,i){return this[e.name]=i?t:e.verifyValue(t),this},s=function(){return this[e.name]};null===t.getChild("set"+i)&&(o["set"+i]=n),null===t.getChild("set_"+r)&&(o["set_"+r]=n),null===t.getChild("get"+i)&&(o["get"+i]=s),null===t.getChild("get_"+r)&&(o["get_"+r]=s)}(l)}function _(t,r,n,s){if(null===t||"object"!=typeof t){if(s&&s instanceof e.Reflect.Enum){var o=e.Reflect.Enum.getName(s.object,t);if(null!==o)return o}return t}if(i.isByteBuffer(t))return r?t.toBase64():t.toBuffer();if(e.Long.isLong(t))return n?t.toString():e.Long.fromValue(t);var a;if(Array.isArray(t))return a=[],t.forEach((function(e,t){a[t]=_(e,r,n,s)})),a;if(a={},t instanceof e.Map){for(var l=t.entries(),c=l.next();!c.done;c=l.next())a[t.keyElem.valueToString(c.value[0])]=_(c.value[1],r,n,t.valueElem.resolvedType);return a}var d=t.$type,u=void 0;for(var h in t)t.hasOwnProperty(h)&&(d&&(u=d.getChild(h))?a[h]=_(t[h],r,n,u.resolvedType):a[h]=_(t[h],r,n));return a}return o.encode=function(e,r){"boolean"==typeof e&&(r=e,e=void 0);var n=!1;e||(e=new i,n=!0);var s=e.littleEndian;try{return t.encode(this,e.LE(),r),(n?e.flip():e).LE(s)}catch(t){throw e.LE(s),t}},s.encode=function(e,t,i){return new s(e).encode(t,i)},o.calculate=function(){return t.calculate(this)},o.encodeDelimited=function(e,r){var n=!1;e||(e=new i,n=!0);var s=(new i).LE();return t.encode(this,s,r).flip(),e.writeVarint32(s.remaining()),e.append(s),n?e.flip():e},o.encodeAB=function(){try{return this.encode().toArrayBuffer()}catch(e){throw e.encoded&&(e.encoded=e.encoded.toArrayBuffer()),e}},o.toArrayBuffer=o.encodeAB,o.encodeNB=function(){try{return this.encode().toBuffer()}catch(e){throw e.encoded&&(e.encoded=e.encoded.toBuffer()),e}},o.toBuffer=o.encodeNB,o.encode64=function(){try{return this.encode().toBase64()}catch(e){throw e.encoded&&(e.encoded=e.encoded.toBase64()),e}},o.toBase64=o.encode64,o.encodeHex=function(){try{return this.encode().toHex()}catch(e){throw e.encoded&&(e.encoded=e.encoded.toHex()),e}},o.toHex=o.encodeHex,o.toRaw=function(e,t){return _(this,!!e,!!t,this.$type)},o.encodeJSON=function(){return JSON.stringify(_(this,!0,!0,this.$type))},s.decode=function(e,r,n){"string"==typeof r&&(n=r,r=-1),"string"==typeof e?e=i.wrap(e,n||"base64"):i.isByteBuffer(e)||(e=i.wrap(e));var s=e.littleEndian;try{var o=t.decode(e.LE(),r);return e.LE(s),o}catch(t){throw e.LE(s),t}},s.decodeDelimited=function(e,r){if("string"==typeof e?e=i.wrap(e,r||"base64"):i.isByteBuffer(e)||(e=i.wrap(e)),e.remaining()<1)return null;var n=e.offset,s=e.readVarint32();if(e.remaining()<s)return e.offset=n,null;try{var o=t.decode(e.slice(e.offset,e.offset+s).LE());return e.offset+=s,o}catch(t){throw e.offset+=s,t}},s.decode64=function(e){return s.decode(e,"base64")},s.decodeHex=function(e){return s.decode(e,"hex")},s.decodeJSON=function(e){return new s(JSON.parse(e))},o.toString=function(){return t.toString()},Object.defineProperty&&(Object.defineProperty(s,"$options",{value:t.buildOpt()}),Object.defineProperty(o,"$options",{value:s.$options}),Object.defineProperty(s,"$type",{value:t}),Object.defineProperty(o,"$type",{value:t})),s}(e,this);this._fields=[],this._fieldsById={},this._fieldsByName={},this._oneofsByName={};for(var n,s=0,o=this.children.length;s<o;s++)if((n=this.children[s])instanceof f||n instanceof c||n instanceof T){if(r.hasOwnProperty(n.name))throw Error("Illegal reflect child of "+this.toString(!0)+": "+n.toString(!0)+" cannot override static property '"+n.name+"'");r[n.name]=n.build()}else if(n instanceof c.Field)n.build(),this._fields.push(n),this._fieldsById[n.id]=n,this._fieldsByName[n.name]=n;else if(n instanceof c.OneOf)this._oneofsByName[n.name]=n;else if(!(n instanceof c.OneOf||n instanceof I))throw Error("Illegal reflect child of "+this.toString(!0)+": "+this.children[s].toString(!0));return this.clazz=r},d.encode=function(e,t,i){for(var r,n,s=null,o=0,a=this._fields.length;o<a;++o)n=e[(r=this._fields[o]).name],r.required&&null===n?null===s&&(s=r):r.encode(i?n:r.verifyValue(n),t,e);if(null!==s){var l=Error("Missing at least one required field for "+this.toString(!0)+": "+s);throw l.encoded=t,l}return t},d.calculate=function(e){for(var t,i,r=0,n=0,s=this._fields.length;n<s;++n){if(i=e[(t=this._fields[n]).name],t.required&&null===i)throw Error("Missing at least one required field for "+this.toString(!0)+": "+t);r+=t.calculate(i,e)}return r},d.decode=function(t,i,r){"number"!=typeof i&&(i=-1);for(var n,s,o,a,l=t.offset,_=new this.clazz;t.offset<l+i||-1===i&&t.remaining()>0;){if(o=(n=t.readVarint32())>>>3,(s=7&n)===e.WIRE_TYPES.ENDGROUP){if(o!==r)throw Error("Illegal group end indicator for "+this.toString(!0)+": "+o+" ("+(r?r+" expected":"not a group")+")");break}if(a=this._fieldsById[o]){if(a.repeated&&!a.options.packed)_[a.name].push(a.decode(s,t));else if(a.map){var c=a.decode(s,t);_[a.name].set(c[0],c[1])}else if(_[a.name]=a.decode(s,t),a.oneof){var d=_[a.oneof.name];null!==d&&d!==a.name&&(_[d]=null),_[a.oneof.name]=a.name}}else switch(s){case e.WIRE_TYPES.VARINT:t.readVarint32();break;case e.WIRE_TYPES.BITS32:t.offset+=4;break;case e.WIRE_TYPES.BITS64:t.offset+=8;break;case e.WIRE_TYPES.LDELIM:var h=t.readVarint32();t.offset+=h;break;case e.WIRE_TYPES.STARTGROUP:for(;u(o,t););break;default:throw Error("Illegal wire type for unknown field "+o+" in "+this.toString(!0)+"#decode: "+s)}}for(var g=0,p=this._fields.length;g<p;++g)if(null===_[(a=this._fields[g]).name])if("proto3"===this.syntax)_[a.name]=a.defaultValue;else{if(a.required){var f=Error("Missing at least one required field for "+this.toString(!0)+": "+a.name);throw f.decoded=_,f}e.populateDefaults&&null!==a.defaultValue&&(_[a.name]=a.defaultValue)}return _},t.Message=c;var h=function(t,i,n,s,o,a,l,_,d,u){r.call(this,t,i,a),this.className="Message.Field",this.required="required"===n,this.repeated="repeated"===n,this.map="map"===n,this.keyType=s||null,this.type=o,this.resolvedType=null,this.id=l,this.options=_||{},this.defaultValue=null,this.oneof=d||null,this.syntax=u||"proto2",this.originalName=this.name,this.element=null,this.keyElement=null,!this.builder.options.convertFieldsToCamelCase||this instanceof c.ExtensionField||(this.name=e.Util.toCamelCase(this.name))},g=h.prototype=Object.create(r.prototype);g.build=function(){this.element=new a(this.type,this.resolvedType,!1,this.syntax,this.name),this.map&&(this.keyElement=new a(this.keyType,void 0,!0,this.syntax,this.name)),"proto3"!==this.syntax||this.repeated||this.map?void 0!==this.options.default&&(this.defaultValue=this.verifyValue(this.options.default)):this.defaultValue=a.defaultFieldValue(this.type)},g.verifyValue=function(t,i){i=i||!1;var r,n=this;function s(e,t){throw Error("Illegal value for "+n.toString(!0)+" of type "+n.type.name+": "+e+" ("+t+")")}if(null===t)return this.required&&s(typeof t,"required"),"proto3"===this.syntax&&this.type!==e.TYPES.message&&s(typeof t,"proto3 field without field presence cannot be null"),null;if(this.repeated&&!i){Array.isArray(t)||(t=[t]);var o=[];for(r=0;r<t.length;r++)o.push(this.element.verifyValue(t[r]));return o}return this.map&&!i?t instanceof e.Map?t:(t instanceof Object||s(typeof t,"expected ProtoBuf.Map or raw object for map field"),new e.Map(this,t)):(!this.repeated&&Array.isArray(t)&&s(typeof t,"no array expected"),this.element.verifyValue(t))},g.hasWirePresence=function(t,i){if("proto3"!==this.syntax)return null!==t;if(this.oneof&&i[this.oneof.name]===this.name)return!0;switch(this.type){case e.TYPES.int32:case e.TYPES.sint32:case e.TYPES.sfixed32:case e.TYPES.uint32:case e.TYPES.fixed32:return 0!==t;case e.TYPES.int64:case e.TYPES.sint64:case e.TYPES.sfixed64:case e.TYPES.uint64:case e.TYPES.fixed64:return 0!==t.low||0!==t.high;case e.TYPES.bool:return t;case e.TYPES.float:case e.TYPES.double:return 0!==t;case e.TYPES.string:return t.length>0;case e.TYPES.bytes:return t.remaining()>0;case e.TYPES.enum:return 0!==t;case e.TYPES.message:return null!==t;default:return!0}},g.encode=function(t,r,n){if(null===this.type||"object"!=typeof this.type)throw Error("[INTERNAL] Unresolved type in "+this.toString(!0)+": "+this.type);if(null===t||this.repeated&&0==t.length)return r;try{var s;if(this.repeated)if(this.options.packed&&e.PACKABLE_WIRE_TYPES.indexOf(this.type.wireType)>=0){r.writeVarint32(this.id<<3|e.WIRE_TYPES.LDELIM),r.ensureCapacity(r.offset+=1);var o=r.offset;for(s=0;s<t.length;s++)this.element.encodeValue(this.id,t[s],r);var a=r.offset-o,l=i.calculateVarint32(a);if(l>1){var _=r.slice(o,r.offset);o+=l-1,r.offset=o,r.append(_)}r.writeVarint32(a,o-l)}else for(s=0;s<t.length;s++)r.writeVarint32(this.id<<3|this.type.wireType),this.element.encodeValue(this.id,t[s],r);else this.map?t.forEach((function(t,n,s){var o=i.calculateVarint32(8|this.keyType.wireType)+this.keyElement.calculateLength(1,n)+i.calculateVarint32(16|this.type.wireType)+this.element.calculateLength(2,t);r.writeVarint32(this.id<<3|e.WIRE_TYPES.LDELIM),r.writeVarint32(o),r.writeVarint32(8|this.keyType.wireType),this.keyElement.encodeValue(1,n,r),r.writeVarint32(16|this.type.wireType),this.element.encodeValue(2,t,r)}),this):this.hasWirePresence(t,n)&&(r.writeVarint32(this.id<<3|this.type.wireType),this.element.encodeValue(this.id,t,r))}catch(e){throw Error("Illegal value for "+this.toString(!0)+": "+t+" ("+e+")")}return r},g.calculate=function(t,r){if(t=this.verifyValue(t),null===this.type||"object"!=typeof this.type)throw Error("[INTERNAL] Unresolved type in "+this.toString(!0)+": "+this.type);if(null===t||this.repeated&&0==t.length)return 0;var n=0;try{var s,o;if(this.repeated)if(this.options.packed&&e.PACKABLE_WIRE_TYPES.indexOf(this.type.wireType)>=0){for(n+=i.calculateVarint32(this.id<<3|e.WIRE_TYPES.LDELIM),o=0,s=0;s<t.length;s++)o+=this.element.calculateLength(this.id,t[s]);n+=i.calculateVarint32(o),n+=o}else for(s=0;s<t.length;s++)n+=i.calculateVarint32(this.id<<3|this.type.wireType),n+=this.element.calculateLength(this.id,t[s]);else this.map?t.forEach((function(t,r,s){var o=i.calculateVarint32(8|this.keyType.wireType)+this.keyElement.calculateLength(1,r)+i.calculateVarint32(16|this.type.wireType)+this.element.calculateLength(2,t);n+=i.calculateVarint32(this.id<<3|e.WIRE_TYPES.LDELIM),n+=i.calculateVarint32(o),n+=o}),this):this.hasWirePresence(t,r)&&(n+=i.calculateVarint32(this.id<<3|this.type.wireType),n+=this.element.calculateLength(this.id,t))}catch(e){throw Error("Illegal value for "+this.toString(!0)+": "+t+" ("+e+")")}return n},g.decode=function(t,i,r){var n,s;if(!(!this.map&&t==this.type.wireType||!r&&this.repeated&&this.options.packed&&t==e.WIRE_TYPES.LDELIM||this.map&&t==e.WIRE_TYPES.LDELIM))throw Error("Illegal wire type for field "+this.toString(!0)+": "+t+" ("+this.type.wireType+" expected)");if(t==e.WIRE_TYPES.LDELIM&&this.repeated&&this.options.packed&&e.PACKABLE_WIRE_TYPES.indexOf(this.type.wireType)>=0&&!r){s=i.readVarint32(),s=i.offset+s;for(var o=[];i.offset<s;)o.push(this.decode(this.type.wireType,i,!0));return o}if(this.map){var l=a.defaultFieldValue(this.keyType);if(n=a.defaultFieldValue(this.type),s=i.readVarint32(),i.remaining()<s)throw Error("Illegal number of bytes for "+this.toString(!0)+": "+s+" required but got only "+i.remaining());var _=i.clone();for(_.limit=_.offset+s,i.offset+=s;_.remaining()>0;){var c=_.readVarint32();t=7&c;var d=c>>>3;if(1===d)l=this.keyElement.decode(_,t,d);else{if(2!==d)throw Error("Unexpected tag in map field key/value submessage");n=this.element.decode(_,t,d)}}return[l,n]}return this.element.decode(i,t,this.id)},t.Message.Field=h;var p=function(e,t,i,r,n,s,o){h.call(this,e,t,i,null,r,n,s,o),this.extension};p.prototype=Object.create(h.prototype),t.Message.ExtensionField=p;t.Message.OneOf=function(e,t,i){r.call(this,e,t,i),this.fields=[]};var f=function(e,t,i,r,n){s.call(this,e,t,i,r,n),this.className="Enum",this.object=null};f.getName=function(e,t){for(var i,r=Object.keys(e),n=0;n<r.length;++n)if(e[i=r[n]]===t)return i;return null},(f.prototype=Object.create(s.prototype)).build=function(t){if(this.object&&!t)return this.object;for(var i=new e.Builder.Enum,r=this.getChildren(f.Value),n=0,s=r.length;n<s;++n)i[r[n].name]=r[n].id;return Object.defineProperty&&Object.defineProperty(i,"$options",{value:this.buildOpt(),enumerable:!1}),this.object=i},t.Enum=f;var E=function(e,t,i,n){r.call(this,e,t,i),this.className="Enum.Value",this.id=n};E.prototype=Object.create(r.prototype),t.Enum.Value=E;var I=function(e,t,i,n){r.call(this,e,t,i),this.field=n};I.prototype=Object.create(r.prototype),t.Extension=I;var T=function(e,t,i,r){s.call(this,e,t,i,r),this.className="Service",this.clazz=null};(T.prototype=Object.create(s.prototype)).build=function(t){return this.clazz&&!t?this.clazz:this.clazz=function(e,t){for(var r=function(t){e.Builder.Service.call(this),this.rpcImpl=t||function(e,t,i){setTimeout(i.bind(this,Error("Not implemented, see: https://github.com/dcodeIO/ProtoBuf.js/wiki/Services")),0)}},n=r.prototype=Object.create(e.Builder.Service.prototype),s=t.getChildren(e.Reflect.Service.RPCMethod),o=0;o<s.length;o++)!function(e){n[e.name]=function(r,n){try{try{r=e.resolvedRequestType.clazz.decode(i.wrap(r))}catch(e){if(!(e instanceof TypeError))throw e}if(null===r||"object"!=typeof r)throw Error("Illegal arguments");r instanceof e.resolvedRequestType.clazz||(r=new e.resolvedRequestType.clazz(r)),this.rpcImpl(e.fqn(),r,(function(i,r){if(i)n(i);else{null===r&&(r="");try{r=e.resolvedResponseType.clazz.decode(r)}catch(e){}r&&r instanceof e.resolvedResponseType.clazz?n(null,r):n(Error("Illegal response type received in service method "+t.name+"#"+e.name))}}))}catch(e){setTimeout(n.bind(this,e),0)}},r[e.name]=function(t,i,n){new r(t)[e.name](i,n)},Object.defineProperty&&(Object.defineProperty(r[e.name],"$options",{value:e.buildOpt()}),Object.defineProperty(n[e.name],"$options",{value:r[e.name].$options}))}(s[o]);return Object.defineProperty&&(Object.defineProperty(r,"$options",{value:t.buildOpt()}),Object.defineProperty(n,"$options",{value:r.$options}),Object.defineProperty(r,"$type",{value:t}),Object.defineProperty(n,"$type",{value:t})),r}(e,this)},t.Service=T;var m=function(e,t,i,n){r.call(this,e,t,i),this.className="Service.Method",this.options=n||{}};(m.prototype=Object.create(r.prototype)).buildOpt=o.buildOpt,t.Service.Method=m;var R=function(e,t,i,r,n,s,o,a){m.call(this,e,t,i,a),this.className="Service.RPCMethod",this.requestName=r,this.responseName=n,this.requestStream=s,this.responseStream=o,this.resolvedRequestType=null,this.resolvedResponseType=null};return R.prototype=Object.create(m.prototype),t.Service.RPCMethod=R,t}(t),t.Builder=function(e,t,i){var r=function(e){this.ns=new i.Namespace(this,null,""),this.ptr=this.ns,this.resolved=!1,this.result=null,this.files={},this.importRoot=null,this.options=e||{}},n=r.prototype;function s(e){e.messages&&e.messages.forEach((function(t){t.syntax=e.syntax,s(t)})),e.enums&&e.enums.forEach((function(t){t.syntax=e.syntax}))}return r.isMessage=function(e){return"string"==typeof e.name&&(void 0===e.values&&void 0===e.rpc)},r.isMessageField=function(e){return"string"==typeof e.rule&&"string"==typeof e.name&&"string"==typeof e.type&&void 0!==e.id},r.isEnum=function(e){return"string"==typeof e.name&&!(void 0===e.values||!Array.isArray(e.values)||0===e.values.length)},r.isService=function(e){return!("string"!=typeof e.name||"object"!=typeof e.rpc||!e.rpc)},r.isExtend=function(e){return"string"==typeof e.ref},n.reset=function(){return this.ptr=this.ns,this},n.define=function(e){if("string"!=typeof e||!t.TYPEREF.test(e))throw Error("illegal namespace: "+e);return e.split(".").forEach((function(e){var t=this.ptr.getChild(e);null===t&&this.ptr.addChild(t=new i.Namespace(this,this.ptr,e)),this.ptr=t}),this),this},n.create=function(t){if(!t)return this;if(Array.isArray(t)){if(0===t.length)return this;t=t.slice()}else t=[t];for(var n=[t];n.length>0;){if(t=n.pop(),!Array.isArray(t))throw Error("not a valid namespace: "+JSON.stringify(t));for(;t.length>0;){var s=t.shift();if(r.isMessage(s)){var o=new i.Message(this,this.ptr,s.name,s.options,s.isGroup,s.syntax),a={};s.oneofs&&Object.keys(s.oneofs).forEach((function(e){o.addChild(a[e]=new i.Message.OneOf(this,o,e))}),this),s.fields&&s.fields.forEach((function(e){if(null!==o.getChild(0|e.id))throw Error("duplicate or invalid field id in "+o.name+": "+e.id);if(e.options&&"object"!=typeof e.options)throw Error("illegal field options in "+o.name+"#"+e.name);var t=null;if("string"==typeof e.oneof&&!(t=a[e.oneof]))throw Error("illegal oneof in "+o.name+"#"+e.name+": "+e.oneof);e=new i.Message.Field(this,o,e.rule,e.keytype,e.type,e.name,e.id,e.options,t,s.syntax),t&&t.fields.push(e),o.addChild(e)}),this);var l=[];if(s.enums&&s.enums.forEach((function(e){l.push(e)})),s.messages&&s.messages.forEach((function(e){l.push(e)})),s.services&&s.services.forEach((function(e){l.push(e)})),s.extensions&&("number"==typeof s.extensions[0]?o.extensions=[s.extensions]:o.extensions=s.extensions),this.ptr.addChild(o),l.length>0){n.push(t),t=l,l=null,this.ptr=o,o=null;continue}l=null}else if(r.isEnum(s))o=new i.Enum(this,this.ptr,s.name,s.options,s.syntax),s.values.forEach((function(e){o.addChild(new i.Enum.Value(this,o,e.name,e.id))}),this),this.ptr.addChild(o);else if(r.isService(s))o=new i.Service(this,this.ptr,s.name,s.options),Object.keys(s.rpc).forEach((function(e){var t=s.rpc[e];o.addChild(new i.Service.RPCMethod(this,o,e,t.request,t.response,!!t.request_stream,!!t.response_stream,t.options))}),this),this.ptr.addChild(o);else{if(!r.isExtend(s))throw Error("not a valid definition: "+JSON.stringify(s));if(o=this.ptr.resolve(s.ref,!0))s.fields.forEach((function(t){if(null!==o.getChild(0|t.id))throw Error("duplicate extended field id in "+o.name+": "+t.id);if(o.extensions){var r=!1;if(o.extensions.forEach((function(e){t.id>=e[0]&&t.id<=e[1]&&(r=!0)})),!r)throw Error("illegal extended field id in "+o.name+": "+t.id+" (not within valid ranges)")}var n=t.name;this.options.convertFieldsToCamelCase&&(n=e.Util.toCamelCase(n));var s=new i.Message.ExtensionField(this,o,t.rule,t.type,this.ptr.fqn()+"."+n,t.id,t.options),a=new i.Extension(this,this.ptr,t.name,s);s.extension=a,this.ptr.addChild(a),o.addChild(s)}),this);else if(!/\.?google\.protobuf\./.test(s.ref))throw Error("extended message "+s.ref+" is not defined")}s=null,o=null}t=null,this.ptr=this.ptr.parent}return this.resolved=!1,this.result=null,this},n.import=function(t,i){var r="/";if("string"==typeof i){if(e.Util.IS_NODE&&(i=require("path").resolve(i)),!0===this.files[i])return this.reset();this.files[i]=!0}else if("object"==typeof i){var n,o=i.root;if(e.Util.IS_NODE&&(o=require("path").resolve(o)),(o.indexOf("\\")>=0||i.file.indexOf("\\")>=0)&&(r="\\"),n=e.Util.IS_NODE?require("path").join(o,i.file):o+r+i.file,!0===this.files[n])return this.reset();this.files[n]=!0}if(t.imports&&t.imports.length>0){var a,l=!1;"object"==typeof i?(this.importRoot=i.root,l=!0,a=this.importRoot,i=i.file,(a.indexOf("\\")>=0||i.indexOf("\\")>=0)&&(r="\\")):"string"==typeof i?this.importRoot?a=this.importRoot:i.indexOf("/")>=0?""===(a=i.replace(/\/[^\/]*$/,""))&&(a="/"):i.indexOf("\\")>=0?(a=i.replace(/\\[^\\]*$/,""),r="\\"):a=".":a=null;for(var _=0;_<t.imports.length;_++)if("string"==typeof t.imports[_]){if(!a)throw Error("cannot determine import root");var c=t.imports[_];if("google/protobuf/descriptor.proto"===c)continue;if(c=e.Util.IS_NODE?require("path").join(a,c):a+r+c,!0===this.files[c])continue;/\.proto$/i.test(c)&&!e.DotProto&&(c=c.replace(/\.proto$/,".json"));var d=e.Util.fetch(c);if(null===d)throw Error("failed to import '"+c+"' in '"+i+"': file not found");/\.json$/i.test(c)?this.import(JSON.parse(d+""),c):this.import(e.DotProto.Parser.parse(d),c)}else i?/\.(\w+)$/.test(i)?this.import(t.imports[_],i.replace(/^(.+)\.(\w+)$/,(function(e,t,i){return t+"_import"+_+"."+i}))):this.import(t.imports[_],i+"_import"+_):this.import(t.imports[_]);l&&(this.importRoot=null)}t.package&&this.define(t.package),t.syntax&&s(t);var u=this.ptr;return t.options&&Object.keys(t.options).forEach((function(e){u.options[e]=t.options[e]})),t.messages&&(this.create(t.messages),this.ptr=u),t.enums&&(this.create(t.enums),this.ptr=u),t.services&&(this.create(t.services),this.ptr=u),t.extends&&this.create(t.extends),this.reset()},n.resolveAll=function(){var r;if(null==this.ptr||"object"==typeof this.ptr.type)return this;if(this.ptr instanceof i.Namespace)this.ptr.children.forEach((function(e){this.ptr=e,this.resolveAll()}),this);else if(this.ptr instanceof i.Message.Field){if(t.TYPE.test(this.ptr.type))this.ptr.type=e.TYPES[this.ptr.type];else{if(!t.TYPEREF.test(this.ptr.type))throw Error("illegal type reference in "+this.ptr.toString(!0)+": "+this.ptr.type);if(!(r=(this.ptr instanceof i.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=r,r instanceof i.Enum){if(this.ptr.type=e.TYPES.enum,"proto3"===this.ptr.syntax&&"proto3"!==r.syntax)throw Error("proto3 message cannot reference proto2 enum")}else{if(!(r instanceof i.Message))throw Error("illegal type reference in "+this.ptr.toString(!0)+": "+this.ptr.type);this.ptr.type=r.isGroup?e.TYPES.group:e.TYPES.message}}if(this.ptr.map){if(!t.TYPE.test(this.ptr.keyType))throw Error("illegal key type for map field in "+this.ptr.toString(!0)+": "+this.ptr.keyType);this.ptr.keyType=e.TYPES[this.ptr.keyType]}"proto3"===this.ptr.syntax&&this.ptr.repeated&&void 0===this.ptr.options.packed&&-1!==e.PACKABLE_WIRE_TYPES.indexOf(this.ptr.type.wireType)&&(this.ptr.options.packed=!0)}else if(this.ptr instanceof e.Reflect.Service.Method){if(!(this.ptr instanceof e.Reflect.Service.RPCMethod))throw Error("illegal service type in "+this.ptr.toString(!0));if(!((r=this.ptr.parent.resolve(this.ptr.requestName,!0))&&r instanceof e.Reflect.Message))throw Error("Illegal type reference in "+this.ptr.toString(!0)+": "+this.ptr.requestName);if(this.ptr.resolvedRequestType=r,!((r=this.ptr.parent.resolve(this.ptr.responseName,!0))&&r instanceof e.Reflect.Message))throw Error("Illegal type reference in "+this.ptr.toString(!0)+": "+this.ptr.responseName);this.ptr.resolvedResponseType=r}else if(!(this.ptr instanceof e.Reflect.Message.OneOf||this.ptr instanceof e.Reflect.Extension||this.ptr instanceof e.Reflect.Enum.Value))throw Error("illegal object in namespace: "+typeof this.ptr+": "+this.ptr);return this.reset()},n.build=function(e){if(this.reset(),this.resolved||(this.resolveAll(),this.resolved=!0,this.result=null),null===this.result&&(this.result=this.ns.build()),!e)return this.result;for(var t="string"==typeof e?e.split("."):e,i=this.result,r=0;r<t.length;r++){if(!i[t[r]]){i=null;break}i=i[t[r]]}return i},n.lookup=function(e,t){return e?this.ns.resolve(e,t):this.ns},n.toString=function(){return"Builder"},r.Message=function(){},r.Enum=function(){},r.Service=function(){},r}(t,t.Lang,t.Reflect),t.Map=function(e,t){var i=function(e,i){if(!e.map)throw Error("field is not a map");if(this.field=e,this.keyElem=new t.Element(e.keyType,null,!0,e.syntax),this.valueElem=new t.Element(e.type,e.resolvedType,!1,e.syntax),this.map={},Object.defineProperty(this,"size",{get:function(){return Object.keys(this.map).length}}),i)for(var r=Object.keys(i),n=0;n<r.length;n++){var s=this.keyElem.valueFromString(r[n]),o=this.valueElem.verifyValue(i[r[n]]);this.map[this.keyElem.valueToString(s)]={key:s,value:o}}},r=i.prototype;function n(e){var t=0;return{next:function(){return t<e.length?{done:!1,value:e[t++]}:{done:!0}}}}return r.clear=function(){this.map={}},r.delete=function(e){var t=this.keyElem.valueToString(this.keyElem.verifyValue(e)),i=t in this.map;return delete this.map[t],i},r.entries=function(){for(var e,t=[],i=Object.keys(this.map),r=0;r<i.length;r++)t.push([(e=this.map[i[r]]).key,e.value]);return n(t)},r.keys=function(){for(var e=[],t=Object.keys(this.map),i=0;i<t.length;i++)e.push(this.map[t[i]].key);return n(e)},r.values=function(){for(var e=[],t=Object.keys(this.map),i=0;i<t.length;i++)e.push(this.map[t[i]].value);return n(e)},r.forEach=function(e,t){for(var i,r=Object.keys(this.map),n=0;n<r.length;n++)e.call(t,(i=this.map[r[n]]).value,i.key,this)},r.set=function(e,t){var i=this.keyElem.verifyValue(e),r=this.valueElem.verifyValue(t);return this.map[this.keyElem.valueToString(i)]={key:i,value:r},this},r.get=function(e){var t=this.keyElem.valueToString(this.keyElem.verifyValue(e));if(t in this.map)return this.map[t].value},r.has=function(e){return this.keyElem.valueToString(this.keyElem.verifyValue(e))in this.map},i}(0,t.Reflect),t.loadProto=function(e,i,r){return("string"==typeof i||i&&"string"==typeof i.file&&"string"==typeof i.root)&&(r=i,i=void 0),t.loadJson(t.DotProto.Parser.parse(e),i,r)},t.newBuilder=function(e){return void 0===(e=e||{}).convertFieldsToCamelCase&&(e.convertFieldsToCamelCase=t.convertFieldsToCamelCase),void 0===e.populateAccessors&&(e.populateAccessors=t.populateAccessors),new t.Builder(e)},t.loadJson=function(e,i,r){return("string"==typeof i||i&&"string"==typeof i.file&&"string"==typeof i.root)&&(r=i,i=null),i&&"object"==typeof i||(i=t.newBuilder()),"string"==typeof e&&(e=JSON.parse(e)),i.import(e,r),i.resolveAll(),i},t}();var al,ll;class _l{constructor(e){al.add(this),Object.defineProperty(this,"pbModules",{enumerable:!0,configurable:!0,writable:!0,value:void 0});const t=ol.loadProto(e);this.pbModules=t.build("Modules").probuf}encode(e,t){return this.pbModules[e].encode(t).toArrayBuffer()}decode(e,t){try{const i=this.pbModules[e].decode(t);return R(this,al,"m",ll).call(this,i)}catch(t){const i=`name: ${e}, stack: ${t.stack}`;throw null===console||void 0===console||console.error("pb decode error!",i),t}}}al=new WeakSet,ll=function e(t){if(t instanceof Array)return t.map((t=>R(this,al,"m",e).call(this,t)));if(i=t,"[object Object]"!==Object.prototype.toString.call(i))return t;var i;if(t instanceof ol.ByteBuffer)return t.toArrayBuffer();if(t instanceof ol.Long)return t.toNumber();const r={};return Object.keys(t).forEach((i=>{r[i]=R(this,al,"m",e).call(this,t[i])})),r};var cl,dl,ul,hl,gl,pl,fl;!function(e){e[e.PERSON=1]="PERSON",e[e.PERSONS=2]="PERSONS",e[e.GROUP=3]="GROUP",e[e.TEMPGROUP=4]="TEMPGROUP",e[e.CUSTOMERSERVICE=5]="CUSTOMERSERVICE",e[e.NOTIFY=6]="NOTIFY",e[e.MC=7]="MC",e[e.MP=8]="MP",e[e.ULTRAGROUP=10]="ULTRAGROUP"}(cl||(cl={})),function(e){e[e.IMAGE=1]="IMAGE",e[e.AUDIO=2]="AUDIO",e[e.VIDEO=3]="VIDEO",e[e.FILE=4]="FILE",e[e.SIGHT=5]="SIGHT",e[e.COMBINE_HTML=6]="COMBINE_HTML"}(dl||(dl={})),function(e){e[e.GROUP_SUCCESS=0]="GROUP_SUCCESS",e[e.GROUP_FAILURE=1]="GROUP_FAILURE"}(ul||(ul={})),function(e){e[e.IsSilent=1]="IsSilent",e[e.IsTop=2]="IsTop",e[e.Tags=3]="Tags",e[e.AutoTrans=4]="AutoTrans"}(hl||(hl={})),function(e){e[e.KICK=0]="KICK",e[e.REFUSE=1]="REFUSE",e[e.COEXIST=2]="COEXIST"}(gl||(gl={})),function(e){e[e.ROOM=1]="ROOM",e[e.PERSON=2]="PERSON"}(pl||(pl={})),function(e){e[e.AnchorToViewer=1]="AnchorToViewer",e[e.ViewerToAnchor=2]="ViewerToAnchor"}(fl||(fl={})),new _l("package Modules;\nmessage probuf {\n message SetUserStatusOutput {\n optional int32 nothing=1;\n }\n message GetUserStatusInput {\n optional int32 nothing=1;\n }\n message GetUserStatusOutput {\n optional string status=1;\n optional string subUserId=2;\n }\n message SubUserStatusInput {\n repeated string userid =1;\n }\n message SubUserStatusOutput {\n optional int32 nothing=1;\n }\n message VoipDynamicInput {\n required int32 engineType = 1;\n required string channelName = 2;\n optional string channelExtra = 3;\n }\n message VoipDynamicOutput {\n required string dynamicKey=1;\n }\n message NotifyMsg {\n required int32 type = 1;\n optional int64 time = 2;\n optional string chrmId=3;\n }\n message SyncRequestMsg {\n required int64 syncTime = 1;\n required bool ispolling = 2;\n optional bool isweb=3;\n optional bool isPullSend=4;\n optional bool isKeeping=5;\n optional int64 sendBoxSyncTime=6;\n optional int64 broadcastSyncTime=7;\n optional int64 endTime = 8;\n optional bool compressioEnabled = 9;\n }\n message UpStreamMessage {\n required int32 sessionId = 1;\n required string classname = 2;\n required string content = 3;\n optional string pushText = 4;\n optional string appData = 5;\n repeated string toUserIds = 6;\n optional int64 delMsgTime = 7;\n optional string delMsgId = 8;\n optional int32 configFlag = 9;\n optional int64 clientUniqueId = 10;\n optional string extraContent = 11;\n optional PushExtra pushExt = 12;\n optional string busChannel = 13;\n optional string systemId = 16;\n optional string senderPortrait = 21;\n optional int64 optionBits = 22;\n }\n message PushExtra {\n optional string title = 1;\n optional int32 templateIdNoUse= 2;\n optional string pushId = 3;\n optional string pushConfigs = 4;\n optional string templateId = 5;\n }\n message DownStreamMessages {\n repeated DownStreamMessage list = 1;\n required int64 syncTime = 2;\n optional bool finished = 3;\n optional int64 broadcastSyncTime = 4;\n optional int64 systemTime = 5;\n optional int64 credibleStartTime = 6;\n optional int64 credibleEndTime = 7;\n optional bool compressioEnabled = 8;\n optional bytes compressedData = 9;\n }\n message ChrmDownStreamMessages {\n repeated bytes list = 1;\n required int64 syncTime = 2;\n optional bool compressioEnabled = 3;\n optional bytes compressedData = 4;\n }\n message DownStreamMessage {\n required string fromUserId = 1;\n required ChannelType type = 2;\n optional string groupId = 3;\n required string classname = 4;\n required string content = 5;\n required int64 dataTime = 6;\n required int64 status = 7;\n optional int64 extra = 8;\n optional string msgId = 9;\n optional int32 direction = 10;\n optional int32 plantform =11;\n optional int32 isRemoved = 12;\n optional string source = 13;\n optional int64 clientUniqueId = 14;\n optional string extraContent = 15;\n optional string pushContent = 16;\n optional int32 configFlag = 17;\n optional PushExtra pushExt = 18;\n optional string busChannel = 19;\n optional int64 extStatus = 20;\n repeated string toUserIds = 21;\n optional int32 groupUnpush = 22;\n optional int64 optionBits = 23;\n optional string convertExt = 24;\n optional ExtMsgData extMsgData = 25;\n }\n message ExtMsgData {\n optional int64 seqId = 1;\n optional int64 sendTime = 2;\n }\n enum ChannelType {\n PERSON = 1;\n PERSONS = 2;\n GROUP = 3;\n TEMPGROUP = 4;\n CUSTOMERSERVICE = 5;\n NOTIFY = 6;\n MC=7;\n MP=8;\n ULTRAGROUP = 10;\n }\n message CreateDiscussionInput {\n optional string name = 1;\n }\n message CreateDiscussionOutput {\n required string id = 1;\n }\n message ChannelInvitationInput {\n repeated string users = 1;\n }\n message LeaveChannelInput {\n required int32 nothing = 1;\n }\n message ChannelEvictionInput {\n required string user = 1;\n }\n message RenameChannelInput {\n required string name = 1;\n }\n message ChannelInfoInput {\n required int32 nothing = 1;\n }\n message ChannelInfoOutput {\n required ChannelType type = 1;\n required string channelId = 2;\n required string channelName = 3;\n required string adminUserId = 4;\n repeated string firstTenUserIds = 5;\n required int32 openStatus = 6;\n }\n message ChannelInfosInput {\n required int32 page = 1;\n optional int32 number = 2;\n }\n message ChannelInfosOutput {\n repeated ChannelInfoOutput channels = 1;\n required int32 total = 2;\n }\n message MemberInfo {\n required string userId = 1;\n required string userName = 2;\n required string userPortrait = 3;\n required string extension = 4;\n }\n message GroupMembersInput {\n required int32 page = 1;\n optional int32 number = 2;\n }\n message GroupMembersOutput {\n repeated MemberInfo members = 1;\n required int32 total = 2;\n }\n message GetUserInfoInput {\n required int32 nothing = 1;\n }\n message GetUserInfoOutput {\n required string userId = 1;\n required string userName = 2;\n required string userPortrait = 3;\n }\n message GetSessionIdInput {\n required int32 nothing = 1;\n }\n message GetSessionIdOutput {\n required int32 sessionId = 1;\n }\n enum FileType {\n IMAGE = 1;\n AUDIO = 2;\n VIDEO = 3;\n FILE = 4;\n SIGHT = 5;\n COMBINE_HTML = 6;\n }\n message GetQNupTokenInput {\n required FileType type = 1;\n optional string key = 2;\n optional string httpMethod = 3;\n optional string queryString = 4;\n optional string url = 5;\n optional string ext = 6;\n optional int64 size = 7;\n optional int32 ipType = 8;\n }\n message GetQNdownloadUrlInput {\n required FileType type = 1;\n required string key = 2;\n optional string fileName = 3;\n }\n message GetDownloadUrlInput {\n required FileType type = 1;\n required string key = 2;\n optional string fileName = 3;\n optional string ext = 4;\n optional int64 size = 5;\n optional int32 ipType = 6;\n }\n message GetQNupTokenOutput {\n required int64 deadline = 1;\n required string token = 2;\n optional string bosToken = 3;\n optional string bosDate = 4;\n optional string path = 5;\n\n optional string osskeyId = 6;\n optional string ossPolicy = 7;\n optional string ossSign = 8;\n optional string ossBucketName = 9;\n\n optional string s3Credential = 10;\n optional string s3Algorithm = 11;\n optional string s3Date = 12;\n optional string s3Policy = 13;\n optional string s3Signature = 14;\n optional string s3BucketName = 15;\n\n optional string stcAuthorization = 16;\n optional string stcContentSha256 = 17;\n optional string stcDate = 18;\n optional string stcBucketName = 19;\n\n optional string minioAuthorization = 20;\n optional string minioContentSha256 = 21;\n optional string minioDate = 22;\n optional string minioBucketName = 23;\n\n optional string downloadAuthInfo = 24;\n optional string ossConfig = 25;\n }\n message GetQNdownloadUrlOutput {\n required string downloadUrl = 1;\n }\n message GetDownloadUrlOutput {\n required string downloadUrl = 1;\n }\n message Add2BlackListInput {\n required string userId = 1;\n }\n message RemoveFromBlackListInput {\n required string userId = 1;\n }\n message QueryBlackListInput {\n required int32 nothing = 1;\n }\n message QueryBlackListOutput {\n repeated string userIds = 1;\n }\n message BlackListStatusInput {\n required string userId = 1;\n }\n message BlockPushInput {\n required string blockeeId = 1;\n }\n message ModifyPermissionInput {\n required int32 openStatus = 1;\n }\n message GroupInput {\n repeated GroupInfo groupInfo = 1;\n }\n message GroupOutput {\n required int32 nothing = 1;\n }\n message GroupInfo {\n required string id = 1;\n required string name = 2;\n }\n message GroupHashInput {\n required string userId = 1;\n required string groupHashCode = 2;\n }\n message GroupHashOutput {\n required GroupHashType result = 1;\n }\n enum GroupHashType {\n GROUP_SUCCESS = 0x00;\n GROUP_FAILURE = 0x01;\n }\n message ChrmInput {\n required int32 nothing = 1;\n optional string extra = 2;\n }\n message ChrmOutput {\n required int32 nothing = 1;\n optional string sessionId = 2;\n optional int64 joinTime = 3;\n optional int64 createTime = 4;\n optional int32 memberCount = 5;\n optional int32 chatroomBanState = 6;\n optional int32 whiteListState = 7;\n }\n message ChrmPullMsg {\n required int64 syncTime = 1;\n required int32 count = 2;\n optional int32 pullMsgType = 3;\n optional bool compressioEnabled = 4;\n }\n message ChrmPullMsgNew {\n required int32 count = 1;\n required int64 syncTime = 2;\n optional string chrmId=3;\n }\n message RelationQryInput {\n optional ChannelType type = 1;\n optional int32 count = 2;\n optional int64 startTime = 3;\n optional int32 order = 4;\n optional bool isEraseMsgContent = 5;\n optional int64 endTime = 6;\n optional bool compressioEnabled = 7;\n optional int32 qryType = 8;\n }\n message RelationsOutput {\n repeated RelationInfo info = 1;\n optional bool isFinished = 2;\n optional int64 pullTime = 3;\n optional bool compressioEnabled = 4; \n optional bytes compressedData = 5;\n }\n message RelationInfo {\n required ChannelType type = 1;\n required string userId = 2;\n optional DownStreamMessage msg =3;\n optional int64 readMsgTime= 4;\n optional int64 unreadCount= 5;\n optional string busChannel = 6;\n optional int64 versionTime = 7;\n optional int64 remindCount = 8;\n optional int32 busChannelType = 9;\n optional UnreadMsgInfo msgInfo = 10;\n optional int32 remindMeCount = 11;\n }\n message UnreadMsgInfo {\n required string msgId = 1;\n required int64 msgTime= 2;\n optional int32 remindType= 3;\n optional string className = 4;\n }\n message QryRemindListReq {\n required string groupId = 1;\n optional string busChannel = 2;\n optional int64 msgTime = 3;\n optional int32 size = 4;\n }\n message QryRemindListResp {\n repeated UnreadMsgInfo msgInfo = 1;\n }\n message RelationInfoReadTime {\n required ChannelType type = 1;\n required int64 readMsgTime= 2;\n required string targetId = 3;\n }\n message CleanHisMsgInput {\n required string targetId = 1;\n required int64 dataTime = 2;\n optional int32 conversationType= 3;\n optional string busChannel = 4;\n }\n message CleanMsgBatchReq {\n repeated CleanHisMsgInput input = 1;\n }\n message HistoryMessageInput {\n required string targetId = 1;\n required int64 dataTime =2;\n required int32 size = 3;\n }\n\n message HistoryMessagesOuput {\n repeated DownStreamMessage list = 1;\n required int64 syncTime = 2;\n required int32 hasMsg = 3;\n optional int64 credibleStartTime = 4;\n optional int64 credibleEndTime = 5;\n optional bool compressioEnabled = 6; \n optional bytes compressedData = 7;\n }\n message QueryChatRoomInfoInput {\n required int32 count= 1;\n optional int32 order= 2;\n }\n\n message QueryChatRoomInfoOutput {\n optional int32 userTotalNums = 1;\n repeated ChrmMember userInfos = 2;\n }\n message ChrmMember {\n required int64 time = 1;\n required string id = 2;\n }\n message MPFollowInput {\n required string id = 1;\n }\n\n message MPFollowOutput {\n required int32 nothing = 1;\n optional MpInfo info =2;\n }\n\n message MCFollowOutput {\n required int32 nothing = 1;\n optional MpInfo info =2;\n }\n\n message MpInfo {\n required string mpid=1;\n required string name = 2;\n required string type = 3;\n required int64 time=4;\n optional string portraitUrl=5;\n optional string extra =6;\n }\n\n message SearchMpInput {\n required int32 type=1;\n required string id=2;\n }\n\n message SearchMpOutput {\n required int32 nothing=1;\n repeated MpInfo info = 2;\n }\n\n message PullMpInput {\n required int64 time=1;\n required string mpid=2;\n }\n\n message PullMpOutput {\n required int32 status=1;\n repeated MpInfo info = 2;\n }\n message HistoryMsgInput {\n optional string targetId = 1;\n optional int64 time = 2;\n optional int32 count = 3;\n optional int32 order = 4;\n optional string busChannel = 5;\n optional bool compressioEnabled = 6;\n optional bool ignoreCmd = 10;\n }\n\n message HistoryMsgOuput {\n repeated DownStreamMessage list=1;\n required int64 syncTime=2;\n required int32 hasMsg=3;\n optional int64 credibleStartTime = 4;\n optional int64 credibleEndTime = 5;\n optional bool compressioEnabled = 6;\n optional bytes compressedData = 7;\n }\n message SessionsAttQryInput {\n required int32 nothing = 1;\n }\n message SessionsAttOutput {\n required int64 inboxTime = 1;\n required int64 sendboxTime = 2;\n required int64 totalUnreadCount = 3;\n }\n message SessionMsgReadInput {\n required ChannelType type = 1;\n required int64 msgTime = 2;\n required string channelId = 3;\n optional string busChannel = 4;\n }\n message SessionMsgReadOutput {\n optional int32 nothing=1;\n }\n message DeleteSessionsInput {\n repeated SessionInfo sessions = 1;\n }\n message SessionInfo {\n required ChannelType type = 1;\n required string channelId = 2;\n optional int64 unreadCount = 3;\n optional string busChannel = 4;\n }\n message QuerySessionsInput {\n repeated SessionInfo sessions = 1;\n }\n message QuerySessionsOutPut {\n repeated SessionInfo sessions = 1;\n }\n message DeleteSessionsOutput {\n optional int32 nothing=1;\n }\n message RelationDelBatchReq {\n repeated RelationOpInput relation = 1;\n optional bool cleanMsg = 2;\n }\n message RelationOpInput {\n required string conversationId = 1;\n required ChannelType conversationType = 2;\n optional string busChannel = 3;\n }\n message DeleteMsgInput {\n optional ChannelType type = 1;\n optional string conversationId = 2;\n repeated DeleteMsg msgs = 3;\n optional string busChannel = 4;\n }\n message DeleteMsg {\n optional string msgId = 1;\n optional int64 msgDataTime = 2;\n optional int32 direct = 3;\n }\n message ChrmKVEntity {\n required string key = 1;\n required string value = 2;\n optional int32 status = 3;\n optional int64 timestamp = 4;\n optional string uid = 5;\n optional int64 version = 6;\n }\n message SetChrmKV {\n required ChrmKVEntity entry = 1;\n optional bool bNotify = 2;\n optional UpStreamMessage notification = 3;\n optional ChannelType type = 4;\n }\n message SetChrmKVS {\n repeated ChrmKVEntity entry = 1;\n optional bool bNotify = 2;\n optional UpStreamMessage notification = 3;\n optional ChannelType type = 4;\n }\n message DeleteChrmKVS {\n repeated ChrmKVEntity entry = 1;\n optional bool bNotify = 2;\n optional UpStreamMessage notification = 3;\n optional ChannelType type = 4;\n }\n message ChrmKVOutput {\n repeated ChrmKVEntity entries = 1;\n optional bool bFullUpdate = 2;\n optional int64 syncTime = 3;\n optional bool compressioEnabled = 4; \n optional bytes compressedData = 5;\n }\n message ChrmKVSVersionEntity {\n optional int64 version = 1;\n optional string key = 2;\n }\n\n message ChrmKVSOutput {\n repeated ChrmKVSOutputEntity errorKeys = 1;\n repeated ChrmKVSVersionEntity keysVersion = 2;\n }\n message ChrmKVSOutputEntity {\n optional string key = 1;\n optional int32 errorCode = 2;\n }\n message QueryChrmKV {\n required int64 timestamp = 1;\n optional bool compressioEnabled = 2;\n }\n message SetUserSettingInput {\n required int64 version=1;\n required string value=2;\n optional bool ignoreVersion = 3;\n }\n message SetUserSettingOutput {\n required int64 version=1;\n required bool reserve=2;\n optional bool updateVersion = 3;\n }\n message PullUserSettingInput {\n required int64 version=1;\n optional bool reserve=2;\n optional int32 ipType = 3;\n }\n message PullUserSettingOutput {\n repeated UserSettingItem items = 1;\n required int64 version=2;\n }\n message UserSettingItem {\n required string targetId= 1;\n required ChannelType type = 2;\n required string key = 4;\n required bytes value = 5;\n required int64 version=6;\n required int32 status=7;\n repeated SessionTagItem tags= 8;\n }\n message SessionReq {\n required int64 time = 1;\n }\n message SessionStates {\n required int64 version=1;\n repeated SessionState state= 2;\n }\n message SessionState {\n required ChannelType type = 1;\n required string channelId = 2;\n optional int64 time = 3;\n repeated SessionStateItem stateItem = 4;\n optional string busChannel = 5;\n }\n message SessionStateItem {\n required SessionStateType sessionStateType = 1;\n required string value = 2;\n repeated SessionTagItem tags = 3;\n optional int64 time = 4;\n }\n enum SessionStateType {\n IsSilent = 1;\n IsTop = 2;\n Tags = 3;\n AutoTrans = 4;\n }\n message SessionStateModifyReq {\n required int64 version=1;\n repeated SessionState state= 2;\n optional bool ignoreVersion = 3;\n }\n message GroupUnpushQuery {\n optional string busChannel = 1;\n }\n message GroupUnpushSet{\n optional string busChannel = 1;\n required int32 unpushLevel = 2;\n }\n message GroupUnpushResult {\n required string groupId = 1;\n optional string busChannel = 2;\n required int32 unpushLevel = 3;\n }\n message SessionStateModifyResp {\n required int64 version=1;\n optional bool updateVersion = 2;\n }\n message TypeUnpushInput {\n required ChannelType type = 1;\n required int64 version = 2;\n required int32 unpushLevel = 3;\n optional bool ignoreVersion = 4;\n }\n message TypeUnpushOutput {\n required int64 version = 1;\n optional bool updateVersion = 2;\n }\n message GrpReadReceiptMsg {\n repeated string msgId=1;\n optional string channelId = 2;\n }\n message GrpReadReceiptQryReq {\n repeated string msgId=1;\n optional string channelId = 2;\n }\n message ReadReceipt {\n optional string targetId = 1;\n optional int32 type = 2;\n optional string channelId = 3;\n optional int32 readType =4 ;\n repeated string msgIds= 5 ;\n optional string fromId = 6;\n }\n message QueryReceiptReq {\n optional string targetId = 1;\n optional string busChannel =2;\n optional int32 type = 3;\n repeated string msgIds = 4;\n optional int32 qryType = 5;\n optional int32 order =6;\n optional bool compress = 7;\n optional int32 readType = 8;\n optional int32 pageType = 9; \n optional int32 pageSize = 10;\n optional string pageToken = 11;\n repeated string users = 12;\n }\n message QueryReceiptBatchReq {\n repeated QueryReceipt items = 1;\n optional bool compress = 2;\n }\n message QueryReceipt {\n optional string targetId = 1;\n optional string busChannel = 2;\n optional int32 type = 3;\n repeated string msgIds = 4;\n }\n message ReceiptResp {\n repeated QueryReceiptRespItem resp = 1;\n optional bool compress = 2;\n optional bytes compressData = 3;\n optional string pageToken = 4;\n }\n message QueryReceiptBatchResp {\n repeated QueryReceiptBatchRespItem item = 1;\n optional bool compress = 2;\n optional bytes compressData = 3;\n }\n\n message QueryReceiptBatchRespItem {\n optional string targetId = 1;\n optional string busChannel = 2;\n optional int32 type = 3;\n repeated QueryReceiptRespItem msg = 4;\n }\n message QueryReceiptRespItem {\n optional string msgId = 1;\n optional int64 msgTime = 2;\n optional int32 totalCnt = 3;\n optional int64 readCnt = 4;\n repeated ReceiptUser readUser = 5;\n repeated string unreadList = 6;\n optional int64 unreadCnt = 7;\n repeated ReceiptUser unreadUser = 8;\n }\n message GrpReadReceiptQryResp {\n required int32 totalMemberNum = 1;\n repeated GrpMsgReadUser list = 2;\n }\n message GrpMsgReadUser {\n required int64 readTime = 1;\n required string userId = 2;\n }\n message SessionTagAddInput {\n required int64 version=1;\n repeated SessionTagItem tags=2;\n optional bool ignoreVersion = 3;\n }\n message SessionTagItem {\n required string tagId=1;\n optional string name=2;\n optional int64 createdTime=3;\n optional bool isTop=4;\n }\n message SessionTagDelInput {\n required int64 version=1;\n repeated SessionTagItem tags=2;\n optional bool ignoreVersion = 3;\n }\n message SessionDisTagReq {\n repeated string tagId=1;\n }\n message UserSettingNotification {\n required int64 version=1;\n required bool reserve=2;\n }\n message ReportSDKInput {\n required string sdkInfo=1;\n }\n message ReportSDKOutput {\n optional int32 nothing=1;\n }\n message UltraGrpPullSes {\n required int64 syncTime = 1;\n optional bool isEraseMsgContent = 2;\n }\n message UltraGrpPullMsg {\n required int64 syncTime = 1;\n optional bool compressioEnabled = 2;\n }\n message MsgChangeReq {\n required string fromUserId = 1;\n required string targetId = 2;\n required ChannelType type = 3;\n required string msgUID = 4;\n required int64 msgTime = 5;\n optional string busChannel = 6;\n optional string content = 7;\n }\n message ModifyMsgResp {\n optional int64 modifyTime = 1;\n optional DownStreamMessage msg = 2;\n }\n message QueryMsgChange {\n required int64 syncTime = 1;\n optional int32 needCompress = 2;\n optional int64 onlineTime = 3;\n optional string targetId = 4;\n }\n message EventChangeList {\n repeated EventChange list = 1;\n required int64 syncTime = 2;\n optional bool hasNext = 3 ;\n optional string targetId = 4;\n optional bool isCompress = 5 ;\n }\n message EventChange {\n optional string businessId = 1;\n optional ChannelType channelType = 2;\n optional int64 time = 3;\n optional int32 changeType = 4;\n optional string originalId = 5;\n optional int64 originalTime = 6;\n optional string secondaryId = 7;\n optional bool isAdmin = 8;\n optional bool additionalMark = 9; \n optional string operatorId = 10;\n optional int32 subChangeType = 11;\n optional int32 secondaryType = 12;\n optional bool isRemindMe = 13;\n repeated string extIds = 14;\n optional int32 remindType = 15;\n optional bytes eventData = 16;\n }\n message MsgChangeList {\n repeated MsgChange list = 1;\n required int64 syncTime = 2;\n optional bool hasNext = 3 ;\n }\n message MsgChange {\n required string targetId = 1;\n required ChannelType type = 2;\n required int64 time = 3;\n required int32 changeType = 4;\n required string msgUID = 5;\n required int64 msgTime = 6;\n optional string busChannel = 7;\n optional bool isAdmin = 8;\n optional bool isDel = 9;\n optional string operatorId = 10;\n optional int32 subChangeType = 11;\n optional int32 busChannelType = 12;\n optional bool isRemindMe = 13;\n repeated string userGroupIds = 14;\n optional int32 remindType = 15;\n }\n message MsgQuery {\n required string targetId = 1;\n required ChannelType type = 2;\n repeated MessageQueryInfo query = 3; //\n }\n message MessageQueryInfo {\n required int64 msgTime = 1;\n required string msgUID = 2;\n optional string busChannel = 3;\n }\n message MsgQueryAck {\n repeated DownStreamMessage list = 1;\n repeated string notExistMsgId = 2;\n }\n message OperateStatus {\n optional string targetId = 1;\n optional ChannelType type = 2;\n optional int32 opType = 3;\n optional string busChannel = 4;\n }\n message OperateStatusNotify {\n optional ChannelType type = 1;\n optional int64 notifyType = 2;\n repeated OperateInfo info = 3 ;\n repeated OperateSummary summary = 4 ;\n }\n message OperateInfo {\n optional string targetId = 1;\n optional string busChannel = 2;\n optional string userId = 3;\n optional int32 opType = 4;\n optional int64 optime = 5;\n }\n \n message OperateSummary {\n optional string targetId = 1;\n optional string busChannel = 2;\n optional int32 count = 3;\n optional int32 opType = 4;\n }\n\n message SetRtcRoomIdInput {\n required string rtcRoomId= 1;\n }\n message SetRtcRoomIdOutput {\n required int32 nothing = 1;\n }\n message CallInfoUpStream {\n required string key= 1;\n required string dataContent=2;\n }\n message CallInfoDownStream {\n required string key= 1;\n required string dataContent=2;\n required int64 maxTime=3;\n }\n message KvInput {\n required int64 syncTime = 1;\n }\n message KvOutput {\n required int64 maxTime = 1;\n repeated KvInfo info = 2;\n }\n message KvInfo {\n required string key =1;\n required string value =2;\n }\n message ReadReceiptMsg {\n required string targetId = 1;\n required ChannelType type = 2;\n optional string busChannel = 3;\n optional string startMsgId = 4;\n optional string endMsgId = 5;\n }\n message ReceiptQryReq {\n required string msgId = 1;\n optional string busChannel = 2;\n required string targetId = 3;\n }\n message QueryReceiptResp {\n optional int32 num = 1;\n repeated ReceiptUser list = 2;\n optional int32 readCnt = 3;\n }\n message ReceiptUser {\n optional int64 receiptTime = 1;\n optional string userId = 2;\n optional string name = 3;\n optional string portrait = 4;\n optional bool mentioned= 5;\n }\n message ReceiptCntQryReq {\n optional ChannelType type = 1;\n optional string channelId = 2;\n optional string busChannel = 3;\n repeated string msgId = 4;\n }\n message ReceiptCntQryResp {\n repeated MsgReadCnt result= 1;\n }\n\n message MsgReadCnt {\n optional string msgId = 1;\n optional int32 cnt = 2;\n optional int32 tmn = 3;\n }\n message UpdateUserSubReq {\n optional int32 subType = 1;\n repeated UserSubDetail subUsers = 2;\n optional int32 opType = 3;\n optional int32 expiry = 4;\n }\n message UserSubDetail {\n optional string subUserId = 1;\n }\n message UpdateUserSubResp {\n repeated UserSubDetail subUsers = 1;\n optional int64 subTime = 2;\n }\n message PullUserSubReq {\n optional int64 version = 1;\n optional string pageToken = 2;\n }\n message PUllUserSubResp {\n repeated UserSubList list = 1;\n optional int64 version = 2;\n optional bool hasNext = 3;\n optional string pageToken = 4;\n optional bool isFull = 5;\n }\n message UserSubList {\n repeated UserSubDetail subUsers = 1;\n optional int32 subType = 2;\n optional int64 subTime = 3;\n optional int32 expiry = 4;\n optional int32 opType = 5;\n }\n message PullSubDataReq {\n optional int64 versionTime = 1;\n optional bool needAllData = 2;\n optional string pageToken = 3;\n }\n message PullSubDataResp {\n repeated SubDataDetail list = 1;\n optional int64 versionTime = 2;\n optional bool hasNext = 3;\n optional string pageToken = 4;\n optional bool isFull = 5;\n }\n message SubDataDetail {\n optional string statusStr = 1;\n optional string subUserId = 2;\n repeated SubData data = 3;\n optional int32 subType = 4;\n }\n\n message SubData {\n optional int32 platformInfo = 1;\n optional int32 value = 2;\n optional int64 versionTime = 3;\n }\n message QrySubDataReq {\n optional int32 subType = 1;\n repeated UserSubDetail subUsers = 2;\n }\n message UserProfile {\n optional int64 version = 1;\n optional string userId = 2;\n repeated ProfileInfo userProfile = 3;\n repeated ProfileInfo userExtProfile = 4;\n }\n message ProfileInfo {\n optional string key = 1;\n optional string value = 2;\n }\n message SetUserProfileResp {\n optional int64 version = 1;\n optional string key = 2;\n repeated string censorFailedFields = 3;\n }\n message PullUserProfileReq {\n repeated string userId = 1;\n }\n message UserProfiles {\n repeated UserProfile UserProfile = 1;\n }\n message UserProfileInput {\n required int32 nothing = 1;\n }\n message UserProfilePermission {\n optional int32 permission = 1;\n }\n message UserProfileOutput {\n required int32 nothing = 1;\n }\n message SearchUserProfile {\n optional string uniqueId = 1;\n }\n message ChannelsInput {\n optional string targetId = 1;\n optional ChannelType type = 2;\n repeated ProfileInfo settingProfile = 3;\n repeated ProfileInfo extProfile = 4;\n optional ChannelBaseInfo baseInfo = 5;\n repeated string users = 6;\n }\n\n message ChannelBaseInfo {\n optional string creatorId = 1;\n optional string ownerId = 2;\n optional int64 createTime = 3;\n optional int32 memberCount = 4;\n }\n\n message ChannelsOutput {\n optional int64 operateTime = 1;\n optional int32 flag = 2;\n optional string msg = 3;\n optional int32 processCode = 4;\n optional ChannelsJoinedInfo channelInfo = 5;\n repeated ChannelsUserInfo userInfos = 6;\n optional FriendInviteInfo friendInviteInfo = 7;\n optional FriendUserInfo friendUserInfo = 8;\n repeated string censorFailedFields = 9;\n }\n\n message MultiChannels {\n optional ChannelType type = 1;\n repeated ChannelsInput list = 2;\n }\n\n message ModifyChannelsInput {\n optional string targetId = 1;\n optional ChannelType type = 2;\n optional QuitChannelsSetting settingInfo = 3;\n repeated string users = 4;\n optional int32 operateType = 5;\n }\n\n message QuitChannelsSetting {\n optional bool isQuit = 1;\n optional bool isDelBan = 2;\n optional bool isDelWhite = 3;\n optional bool isDelAttention = 4;\n }\n\n message ChannelsQueryInput {\n optional string targetId = 1;\n optional ChannelType type = 2;\n optional ChannelsPageParam page = 3;\n repeated string ids = 4;\n optional int32 roleType = 5;\n }\n\n message ChannelsPageParam {\n optional int32 size = 1;\n optional string pageToken = 2;\n optional bool hasNext = 3 ;\n optional int32 total = 4 ;\n optional int32 order = 5 ;\n }\n\n message ChannelsListResult {\n optional int32 listType = 1;\n optional bytes result = 2;\n optional ChannelsPageParam page = 3;\n }\n \n message ChannelsInviteStatusInfos {\n repeated ChannelsInviteStatusInfo list = 1;\n }\n \n message ChannelsUserInfos {\n repeated ChannelsUserInfo list = 1;\n }\n \n message ChannelsJoinedInfos {\n repeated ChannelsJoinedInfo list = 1;\n }\n\n message ChannelsUserInfo {\n optional string userId = 1;\n optional ChannelsUserExtInfo ext = 2;\n optional int64 opTime = 3;\n optional string name = 4;\n optional string portraitUrl = 5;\n }\n\n message ChannelsUserExtInfo {\n optional int32 role = 1;\n optional int64 joinTime = 2;\n optional string channelNickName = 3;\n optional string additional = 4;\n optional string remarkName = 5;\n optional bool isBan = 6;\n optional int64 banEndTime = 7;\n }\n\n message ChannelsMemberUpdateInput {\n optional string targetId = 1;\n optional ChannelType type = 2;\n optional string userId = 3;\n optional string channelNickName = 4;\n optional string additional = 5;\n optional int32 operateType = 6;\n }\n message ChannelsJoinedInfo {\n optional string targetId = 1;\n repeated ProfileInfo settingProfile = 2;\n repeated ProfileInfo extProfile = 3;\n optional ChannelBaseInfo baseInfo = 4;\n optional ChannelsUserExtInfo userInfo = 5;\n }\n message ChannelsInviteStatusInfo {\n optional string targetId = 1;\n optional ChannelsUserInfo joinUserInfo = 2;\n optional ChannelsUserInfo inviterInfo = 3;\n optional int32 status = 4;\n optional int32 directionType = 5;\n optional int32 joinType = 6;\n optional string detail = 7;\n optional int64 applyTime = 8;\n optional ChannelsUserInfo processInfo = 9;\n optional int64 processTime = 10;\n }\n message ChannelsMemberResponseInput {\n optional string targetId = 1;\n optional ChannelType type = 2;\n optional int32 optType = 3;\n optional int32 optResult = 4;\n optional string joinUserId = 5;\n optional string inviterId = 6;\n optional string detail = 7;\n }\n message ChannelsMembersInput {\n optional string targetId = 1;\n optional ChannelType type = 2;\n repeated string userIds = 3;\n }\n message FriendInput {\n optional string targetId = 1;\n optional int32 type = 2;\n optional string info = 3;\n }\n message FriendsOutput {\n repeated FriendOutput list = 1;\n }\n message FriendOutput {\n optional string userId = 1;\n optional int64 operateTime = 2;\n optional string flag = 3;\n }\n message FriendsInput {\n repeated string targetId = 1;\n optional int32 type = 2;\n }\n message FriendsCheckOutput {\n repeated FriendCheckOutput list = 1;\n }\n\n message FriendCheckOutput {\n optional string targetId = 1;\n optional int32 status = 2;\n }\n message FriendProfileInput {\n optional string targetId = 1;\n optional string remarkName = 2;\n repeated ProfileInfo extProfile = 3;\n }\n message FriendProfileOutput {\n repeated string censorFailedFields = 1;\n }\n message FriendQueryInput {\n optional int32 queryType = 1;\n optional ChannelsPageParam page = 2;\n optional int32 friendType= 3;\n }\n message FriendUserInfo {\n optional string userId = 1;\n optional int64 relationTime = 2;\n optional int32 friendType = 3;\n optional int32 flag = 4;\n optional string remarkName = 5;\n optional string name = 6;\n optional string portraitUrl = 7;\n repeated ProfileInfo extProfile = 8;\n \n }\n message FriendInviteInfo {\n optional string userId = 1;\n optional string name = 2;\n optional string portraitUrl = 3;\n optional int32 type = 4;\n optional int32 status = 5;\n optional int64 operateTime = 6;\n optional string info = 7;\n optional int32 friendType = 8;\n }\n message FriendsListInput {\n repeated string targetId = 1;\n optional int32 type = 2;\n }\n message FriendLevelSet {\n optional int32 level = 1;\n }\n\n message FriendPageParam {\n optional int32 size = 1;\n optional string pageToken = 2;\n }\n message FriendUserInfos {\n repeated FriendUserInfo list = 1;\n }\n\n message FriendInviteInfos {\n repeated FriendInviteInfo list = 1;\n }\n \n message FriendApplyEvent {\n optional int32 applyType = 1;\n optional int32 friendType = 2;\n optional string info = 3;\n optional string name = 4;\n optional string portraitUrl = 5;\n }\n message UpdateChannnelInfo {\n optional ChannelsJoinedInfo channelInfo = 1;\n optional ChannelsUserInfo userInfo = 2;\n }\n message UpdateUserInfo {\n optional ChannelsUserInfo updatedUserInfo = 1;\n optional ChannelsUserInfo optUserInfo = 2;\n }\n message ChannelApplyInfo {\n repeated ChannelsInviteStatusInfo statusInfo = 1;\n }\n message ChannelEventData {\n optional ChannelsUserInfo optUserInfo = 1;\n optional ChannelsJoinedInfo channelInfo = 2;\n repeated ChannelsUserInfo userInfos = 3;\n optional ChannelsJoinedInfo channelFullInfo = 4;\n }\n message FriendTypeChangeEvent {\n optional string friendId = 1;\n optional int32 friendType = 2;\n }\n message FriendUpdateEvent {\n optional string remarkname = 1;\n repeated ProfileInfo extProfile = 2;\n }\n message AddUnpushPeriodInput {\n required string startTime = 1;\n required int32 spanMinutes = 2;\n optional int32 level = 3;\n optional string timezone = 4;\n }\n message DeleteUnpushPeriodInput {\n required int32 nothing = 1;\n }\n message QueryUnpushPeriodInput {\n required int32 nothing = 1;\n }\n message QueryUnpushPeriodOutput {\n required int32 isUnpush = 1;\n optional string startTime = 2;\n optional int32 spanMinutes = 3;\n optional int32 level = 4;\n optional string timezone = 5;\n }\n message RelationDel {\n optional string targetId = 1;\n optional ChannelType type = 2;\n repeated string busChannel = 3;\n optional bool cleanMsg = 4;\n }\n message MsgReadEvent {\n optional string msgId = 1;\n optional int64 msgTime = 2;\n optional int32 totalCnt = 3;\n optional int32 readCnt = 4;\n optional int32 unreadCnt = 5;\n repeated ReceiptUser readList =6;\n }\n message ConvertMsgInput {\n optional int32 businessType = 1;\n optional bytes businessInfo = 2;\n }\n message SpeechToTextInfo {\n optional string msgId = 1;\n optional string objectName = 2;\n optional string content = 3;\n optional int32 sampleRate = 4;\n optional int32 channelNumber = 5;\n optional string format = 6;\n optional string extra = 7;\n }\n message ConvertMsgOutput {\n optional int32 businessType = 1;\n optional bytes businessResult = 2;\n }\n message SpeechToTextResult {\n optional string result = 1;\n optional string message = 2;\n }\n message TransReq {\n repeated TransInfo transInfos = 1;\n optional int32 model = 2;\n optional bool forceTrans = 3;\n }\n message TransResp {\n repeated TransResult results = 1;\n optional int32 model = 2;\n }\n message TransInfo {\n optional string messageUID = 1;\n optional int32 transType = 2;\n optional string text = 3;\n optional string transFileUrl = 4;\n optional string sourceLan = 5;\n optional string targetLan = 6;\n optional int32 inputSource = 7;\n }\n message TransResult {\n optional string messageUID = 1;\n optional string transResult = 2;\n optional string sourceLan = 3;\n optional string targetLan = 4;\n optional int32 code = 5;\n optional int32 inputSource = 6;\n }\n message PullModifyMsgReq { \n optional int64 pullVersion = 1;\n optional bool compress = 2;\n repeated int32 modifyType = 3;\n }\n message PullModifyMsgResp {\n repeated ModifyMsg msg = 1;\n optional int64 nextVersion = 2;\n optional bool finished = 3;\n optional bool compress = 4;\n optional bytes compressedData = 5;\n }\n message ModifyMsg {\n optional int32 modifyType = 1;\n optional DownStreamMessage msg = 2;\n }\n enum JoinType {\n KICK = 0;\n REFUSE = 1;\n COEXIST = 2;\n }\n enum TargetType {\n ROOM =1 ;\n PERSON = 2;\n }\n message SetUserStatusInput {\n optional int32 status=1;\n }\n message MCFollowInput {\n required string state = 1;\n }\n message RtcQueryListInput {\n optional int32 order=1;\n }\n message RtcKeyDeleteInput {\n repeated string key=1;\n }\n message RtcValueInfo {\n required string key=1;\n required string value=2;\n }\n message RtcUserInfo {\n required string userId=1;\n repeated RtcValueInfo userData=2;\n }\n message RtcUserListOutput {\n repeated RtcUserInfo users=1;\n optional string token=2;\n optional string sessionId=3;\n repeated RtcValueInfo roomInfo = 4;\n repeated RtcKVEntity entries = 5;\n optional int64 syncTime = 6;\n optional int32 offlineKickTime = 7;\n }\n message RtcRoomInfoOutput {\n optional string roomId = 1;\n repeated RtcValueInfo roomData = 2;\n optional int32 userCount = 3;\n repeated RtcUserInfo list=4;\n }\n message RtcInput {\n required int32 roomType=1;\n optional int32 broadcastType=2;\n optional RtcValueInfo extraInnerData = 3;\n optional bool needSysChatroom = 4;\n optional IdentityChangeType identityChangeType = 5;\n optional JoinType joinType = 6;\n repeated RtcValueInfo innerDatas = 7;\n repeated RtcValueInfo outerDatas = 8;\n }\n message RtcQryOutput {\n repeated RtcValueInfo outInfo=1;\n }\n message RtcDataInput {\n required bool interior=1;\n required TargetType target=2;\n repeated string key=3;\n optional string objectName=4;\n optional string content=5;\n }\n message RtcSetDataInput {\n required bool interior=1;\n required TargetType target=2;\n required string key=3;\n required string value=4;\n optional string objectName=5;\n optional string content=6;\n }\n message RtcUserSetDataInput {\n repeated RtcValueInfo valueInfo = 1;\n required string objectName = 2;\n repeated RtcValueInfo content = 3;\n }\n message RtcQryInput {\n required bool isInterior=1;\n required TargetType target=2;\n repeated string key=3;\n }\n message RtcDelDataInput {\n repeated string key=1;\n required bool isInterior=2;\n required TargetType target=3;\n }\n message RtcOutput {\n optional int32 nothing=1;\n optional int64 version=2;\n }\n message RtcTokenOutput {\n required string rtcToken=1;\n }\n message RtcSetOutDataInput {\n required TargetType target=1;\n repeated RtcValueInfo valueInfo=2;\n optional string objectName=3;\n optional string content=4;\n }\n message RtcQryUserOutDataInput {\n repeated string userId = 1;\n }\n message RtcUserOutDataOutput {\n repeated RtcUserInfo user = 1;\n }\n message RtcNotifyMsg {\n required int32 type= 1;\n optional int64 time= 2;\n optional string roomId=3;\n }\n message RtcPullKV {\n required int64 timestamp = 1;\n required string roomId = 2;\n }\n message RtcKVEntity {\n required string key = 1;\n required string value = 2;\n optional int32 status = 3;\n optional int64 timestamp = 4;\n optional string uid = 5;\n }\n message RtcKVOutput {\n repeated RtcKVEntity entries = 1;\n optional bool bFullUpdate = 2;\n optional int64 syncTime = 3; \n }\n enum IdentityChangeType {\n AnchorToViewer = 1;\n ViewerToAnchor = 2;\n }\n message RtcQueryUserJoinedInput {\n required string userId = 1;\n }\n message RtcJoinedInfo {\n required string deviceId = 1;\n required string roomId = 2;\n optional int64 joinTime = 3;\n }\n message RtcQueryUserJoinedOutput {\n repeated RtcJoinedInfo info = 1;\n }\n message RtcViewerJoinedOutput {\n required string rtcToken=1;\n repeated RtcKVEntity entries = 2;\n optional int64 syncTime = 3;\n }\n message RtcInviteInput {\n required string invitedUserId=1;\n optional int32 timeoutTime=2;\n required string invitedRoomId=3;\n required string inviteInfo=4;\n required string inviteSessionId= 5;\n }\n message RtcCancelInviteInput {\n required string invitedUserId=1;\n required string invitedRoomId=2;\n required string inviteInfo=3;\n required string inviteSessionId=4;\n }\n message RtcInviteAnswerInput {\n required string inviteUserId=1;\n required int32 answerCode=2;\n required string inviteRoomId=3;\n required string inviteSessionId=4;\n required string content=5;\n optional string key=6;\n optional string value=7;\n }\n message RtcEndInviteInput {\n required string inviteRoomId=1;\n required string inviteSessionId=2;\n required string inviteContent=3;\n repeated string inviteRoomKeys=4;\n }\n}\n");class El{constructor(e){Object.defineProperty(this,"pbCodec",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.pbCodec=new _l(e)}encode(e,t,i){return i?t:this.pbCodec.encode(e,t)}decode(e,t){return this.pbCodec.decode(e,t)}}const Il="rtcRJoin_data",Tl="rtcRExit",ml="rtcRInfo",Rl="rtcUData",Sl="rtcUDel",Cl="rtcSetData",Ll="userSetData",Ol="rtcQryData",vl="rtcDelData",bl="rtcToken",Al="rtcUserState",Nl="rtcUList",yl="viewerJoinR",Pl="viewerExitR",Ul="rtcPullKv",Dl="rtcIdentityChange",Ml="rtcInvite",wl="rtcCancelInvite",kl="rtcInviteAnswer",xl="rtcEndInvite",Bl="rtcQueryJoined",Vl="rtcPullRoomStatus",Gl="reportsdk",Fl="rtcPing";var jl;!function(e){e.RtcInput="RtcInput",e.RtcOutput="RtcOutput",e.RtcUserListOutput="RtcUserListOutput",e.SetUserStatusInput="SetUserStatusInput",e.RtcSetDataInput="RtcSetDataInput",e.RtcUserSetDataInput="RtcUserSetDataInput",e.RtcDataInput="RtcDataInput",e.RtcSetOutDataInput="RtcSetOutDataInput",e.MCFollowInput="MCFollowInput",e.RtcTokenOutput="RtcTokenOutput",e.RtcQryOutput="RtcQryOutput",e.RtcQryUserOutDataInput="RtcQryUserOutDataInput",e.RtcUserOutDataOutput="RtcUserOutDataOutput",e.RtcQueryListInput="RtcQueryListInput",e.RtcRoomInfoOutput="RtcRoomInfoOutput",e.RtcValueInfo="RtcValueInfo",e.RtcKeyDeleteInput="RtcKeyDeleteInput",e.RtcNotifyMsg="RtcNotifyMsg",e.RtcPullKV="RtcPullKV",e.RtcKVOutput="RtcKVOutput",e.RtcQueryUserJoinedInput="RtcQueryUserJoinedInput",e.RtcQueryUserJoinedOutput="RtcQueryUserJoinedOutput",e.RtcViewerJoinedOutput="RtcViewerJoinedOutput",e.RtcInviteInput="RtcInviteInput",e.RtcCancelInviteInput="RtcCancelInviteInput",e.RtcInviteAnswerInput="RtcInviteAnswerInput",e.RtcEndInviteInput="RtcEndInviteInput",e.RtcRoomStatusInput="RtcRoomStatusInput",e.RtcRoomStatusOutput="RtcRoomStatusOutput",e.RtcReportSDKInput="RtcReportSDKInput",e.RtcPBPolaris="RCRTCPBPolaris",e.RtcPBR1Info="RCRTCPBR1Info",e.RtcPBR2Info="RCRTCPBR2Info",e.RtcPBR3Info="RCRTCPBR3Info",e.RtcPBR4Info="RCRTCPBR4Info",e.RtcPBStatusInfo="RCRTCPBStatusInfo",e.RtcPBStreamInfo="RCRTCPBStreamInfo",e.AsrTextMsg="AsrTextMsg",e.AsrResTextMsg="AsrResTextMsg"}(jl||(jl={})),jl.RtcInput,jl.RtcOutput,jl.RtcUserListOutput,jl.SetUserStatusInput,jl.RtcSetDataInput,jl.RtcUserSetDataInput,jl.RtcDataInput,jl.RtcSetOutDataInput,jl.MCFollowInput,jl.RtcTokenOutput,jl.RtcQryOutput,jl.RtcQryUserOutDataInput,jl.RtcUserOutDataOutput,jl.RtcQueryListInput,jl.RtcRoomInfoOutput,jl.RtcValueInfo,jl.RtcKeyDeleteInput,jl.RtcNotifyMsg,jl.RtcPullKV,jl.RtcKVOutput,jl.RtcQueryUserJoinedInput,jl.RtcQueryUserJoinedOutput,jl.RtcInviteInput,jl.RtcCancelInviteInput,jl.RtcInviteAnswerInput,jl.RtcEndInviteInput,jl.RtcRoomStatusInput,jl.RtcRoomStatusOutput,jl.RtcReportSDKInput,jl.RtcPBPolaris,jl.RtcPBR1Info,jl.RtcPBR2Info,jl.RtcPBR3Info,jl.RtcPBR4Info,jl.RtcPBStatusInfo,jl.RtcPBStreamInfo,jl.AsrTextMsg,jl.AsrResTextMsg;const Hl=`\npackage Modules;\nmessage probuf {\n enum JoinType {\n KICK = 0; //踢前一个设备\n REFUSE = 1; //当前加入拒绝\n COEXIST = 2; //两个设备共存\n }\n enum targetType {\n ROOM =1 ;\n PERSON = 2;\n }\n message ${jl.SetUserStatusInput}\n {\n optional int32 status=1;\n }\n message ${jl.MCFollowInput}\n {\n required string state = 1;\n }\n message ${jl.RtcQueryListInput}{\n optional int32 order=1;\n }\n message ${jl.RtcKeyDeleteInput}{\n repeated string key=1;\n }\n message ${jl.RtcValueInfo}{\n required string key=1;\n required string value=2;\n }\n message RtcUserInfo{\n required string userId=1;\n repeated ${jl.RtcValueInfo} userData=2; //用户资源信息\n }\n message ${jl.RtcRoomStatusInput}{ // rtc 和 living room 拉房间资源状态使用的参数\n required int64 version =1; //当前客户端最大的房间状态的version\n }\n message ${jl.RtcRoomStatusOutput}{ // rtc 和 living room 拉房间资源状态返回的数据\n required bool bFullStatus =1; //标识此次给的数据是否是全量数据\n required int64 version =2; //当前获取后房间的最大版本号\n repeated RtcUserInfo usersData=3;//如果是全量数据,这个不为空,给的是房间全部的人以及发布的资源\n repeated RtcRoomStatus roomStatus=4;//房间增量数据\n }\n message RtcRoomStatus{ //房间状态变动\n required string userId = 1;//用户ID\n required int32 event = 2;//房间状态变更的event(人员加入/退出/离线/发布资源) (0:加入;1:离开;2:离线;3:资源变动) \n required int64 time = 3;//本次变更的版本号\n repeated RtcValueInfo userData = 4;//用户变更的资源(event为0或者3时可能有值)\n optional int32 switchRoleType = 5;//如果是切换角色导致的加入房间或退出房间的类型\n optional string extra = 6;\n }\n message ${jl.RtcUserListOutput}{\n repeated RtcUserInfo users=1;\n optional string token=2;\n optional string sessionId=3;\n repeated RtcValueInfo roomInfo = 4; //房间key value\n repeated RtcKVEntity entries = 5;//直播KV属性对象集合\n optional int64 syncTime = 6;//所有属性的最大时间戳(下次拉取KV时用)。\n optional int32 offlineKickTime = 7;//server超时踢人时间,默认60s\n repeated string codeFormat = 8; //当前房间用户支持的编码交集\n optional int64 roomCreateTime = 9;//房间创建时间\n optional int64 userJoinTime = 10;//用户加入房间\n optional int64 version = 11;//当前房间的版本号\n }\n message RtcRoomInfoOutput{\n optional string roomId = 1;\n repeated ${jl.RtcValueInfo} roomData = 2;\n optional int32 userCount = 3;\n repeated RtcUserInfo list=4;\n }\n message ${jl.RtcInput}{\n required int32 roomType=1;\n optional int32 broadcastType=2;\n optional RtcValueInfo extraInnerData = 3;\n optional bool needSysChatroom = 4; //是否需要同步聊天室\n optional IdentityChangeType identityChangeType = 5; //身份变更类型\n optional JoinType joinType = 6; // 加入房间类型\n repeated ${jl.RtcValueInfo} innerDatas = 7; //用户内部inner数据,角色或者连麦信息等\n repeated ${jl.RtcValueInfo} outerDatas = 8; //用户内部outer数据,自定义数据结构RtcInput。\n optional bool supportNtf = 9; //是否支持房间状态的变更通过通知拉取的方式获取\n }\n message ${jl.RtcQryOutput}{\n repeated ${jl.RtcValueInfo} outInfo=1;\n }\n message ${jl.RtcDataInput}{\n required bool interior=1;\n required targetType target=2;\n repeated string key=3;\n optional string objectName=4;\n optional string content=5;\n }\n message ${jl.RtcSetDataInput}{\n required bool interior=1;\n required targetType target=2;\n required string key=3;\n required string value=4;\n optional string objectName=5;\n optional string content=6;\n }\n message ${jl.RtcUserSetDataInput} {\n repeated ${jl.RtcValueInfo} valueInfo = 1;\n required string objectName = 2;\n repeated ${jl.RtcValueInfo} content = 3;\n }\n message RtcQryInput{\n required bool isInterior=1;\n required targetType target=2;\n repeated string key=3;\n }\n message RtcDelDataInput{\n repeated string key=1;\n required bool isInterior=2;\n required targetType target=3;\n }\n message RtcOutput\n {\n optional int32 nothing=1;\n optional int64 version=2;\n }\n message ${jl.RtcTokenOutput}{\n required string rtcToken=1;\n }\n message ${jl.RtcSetOutDataInput}{\n required targetType target=1;\n repeated ${jl.RtcValueInfo} valueInfo=2;\n optional string objectName=3;\n optional string content=4;\n }\n message ${jl.RtcQryUserOutDataInput}{\n repeated string userId = 1;\n }\n message ${jl.RtcUserOutDataOutput}{\n repeated RtcUserInfo user = 1;\n }\n message ${jl.RtcNotifyMsg} \n {\n required int32 type= 1; //(通知类型 1:rtc房间状态KV变更通知)\n optional int64 time= 2; //消息产生时间\n optional string roomId=3; //主播房间id\n }\n message ${jl.RtcPullKV}\n {\n required int64 timestamp = 1;\n required string roomId = 2;\n }\n message RtcKVEntity \n {\n required string key = 1;\n required string value = 2;\n optional int32 status = 3;\n optional int64 timestamp = 4;\n optional string uid = 5;\n }\n message ${jl.RtcKVOutput}\n {\n repeated RtcKVEntity entries = 1;\n optional bool bFullUpdate = 2;\n optional int64 syncTime = 3; \n }\n enum IdentityChangeType \n {\n AnchorToViewer = 1; //1为主播变观众\n ViewerToAnchor = 2; //2为观众变主播\n }\n message ${jl.RtcQueryUserJoinedInput}\n {\n required string userId = 1;\n }\n message RtcJoinedInfo\n {\n required string deviceId = 1; //设备ID\n required string roomId = 2; //加入的房间ID\n optional int64 joinTime = 3; //加入的时间\n }\n message ${jl.RtcQueryUserJoinedOutput}\n {\n repeated RtcJoinedInfo info = 1;\n }\n message ${jl.RtcViewerJoinedOutput}\n {\n required string rtcToken=1;\n repeated RtcKVEntity entries = 2;//KV属性对象集合\n optional int64 syncTime = 3;//所有属性的最大时间戳(下次拉取KV时用)。\n optional string sessionId=4;\n optional int64 roomCreateTime = 5;//房间创建时间\n optional int64 userJoinTime = 6;//用户加入房间\n }\n message ${jl.RtcInviteInput}\n {\n required string invitedUserId=1; //被邀请的人的uid\n optional int32 timeoutTime=2; //邀请超时时间(秒),默认三十秒\n required string invitedRoomId=3; //被邀请的房间\n required string inviteInfo=4; //邀请的信息(包含邀请人,被邀请人,各自userid)客户端定义好.协议栈和server透传\n required string inviteSessionId= 5; //客户端保证唯一性(建议roomid_userid_时间戳_随机数)\n }\n message ${jl.RtcCancelInviteInput}\n {\n required string invitedUserId=1; //被邀请的人的uid\n required string invitedRoomId=2; //被邀请的房间\n required string inviteInfo=3; //取消邀请的信息(包含邀请人,被邀请人,各自userid)客户端定义好.协议栈和server透传\n required string inviteSessionId=4; //邀请的sessionId,客户端发起邀请时产生\n }\n message ${jl.RtcInviteAnswerInput}\n {\n required string inviteUserId=1; //邀请的人的uid\n required int32 answerCode=2; //是否接受连麦邀请.0为拒绝,1为接受\n required string inviteRoomId=3; //邀请的房间\n required string inviteSessionId=4; //邀请的sessionId\n required string content=5; //需要转发的content\n optional string key=6; //如果接受的话,需要加这个字段,放在room级别的k和v,新加入房间的能拉取到\n optional string value=7; //如果接受的话,需要加这个字段,放在room级别的k和v,新加入房间的能拉取到\n }\n message ${jl.RtcEndInviteInput}\n {\n required string inviteRoomId=1; //邀请的房间\n required string inviteSessionId=2; //邀请的sessionId\n required string inviteContent=3; //结束连麦的信息(需要透传给房间内其他人)\n repeated string inviteRoomKeys=4; //需要删除连麦的信息的key\n }\n message ${jl.RtcReportSDKInput} {\n required string sdkInfo=1; // 用户集成的 sdk 信息,json 格式 {"web-rtc": "4.0.3.7"}\n }\n // ---- 北极星数据上报 -------\n message ${jl.RtcPBPolaris} {\n required string type = 1;//上报数据类型 R1-R4\n required string appKey = 2;\n required string sessionId = 3;//房间通话id\n required string roomId = 4;\n required int64 roomCreateTime = 5;//房间创建时间\n required string userId = 6;\n required int32 userRole = 7;\n required int64 joinTime = 8;\n required string signalDataCenter = 9;//signal数据中心\n optional ${jl.RtcPBR1Info} r1Info = 10;\n optional ${jl.RtcPBR2Info} r2Info = 11;\n optional ${jl.RtcPBR3Info} r3Info = 12;\n optional ${jl.RtcPBR4Info} r4Info = 13;\n }\n message ${jl.RtcPBR1Info} {\n required int64 joinTime = 1;//用户加入房间的时间\n required string rtcVersion = 2;//Rtc版本号\n required string imVersion = 3;//IM SDK 版本\n required string platform = 4;//平台(如:Android、iOS、Web)\n required string device = 5; //设备信息(手机名称+型号)\n required string os = 6;//系统版本(手机系统版本)\n optional string browserName = 7; //浏览器名称, 没有用 -1 表示\n optional string browserVersion = 8;//浏览器版本, 没有用 -1 表示\n optional int64 receiveTime = 9; // 发送数据的时间\n }\n message ${jl.RtcPBR2Info} {\n required int64 joinTime = 1;\n required int64 sendTime = 2;\n required string rtcActionType = 3;//发布类型 subscribe : 订阅 publish : 发布\n required string rtcActionStatus = 4;//发布状态 begin : 开始 tend : 结束\n repeated string trackId = 5;\n optional int64 receiveTime = 6; // 发送数据的时间\n }\n message ${jl.RtcPBR3Info} {\n required ${jl.RtcPBStatusInfo} info = 1;\n }\n message ${jl.RtcPBR4Info} {\n required ${jl.RtcPBStatusInfo} info = 1;\n }\n message ${jl.RtcPBStatusInfo} {\n optional int64 joinTime = 1;//用户加入房间的时间\n optional int64 receiveTime = 2;//用户发布数据流的时间(毫秒),暂时由客户端生成,后期如果有问题服务端做兜底处理\n optional int64 totalBitRate = 3;//总码率\n optional float appCPUUsage = 4;//APP CPU占用率\n optional float systemCPUUsage = 5;////系统 CPU占用率\n optional float systemCPUFrequency = 6;//系统CPU频率 (安卓8.0以上)\n optional string networkStatus = 7;//实时网络状态(2g、3g、4g、wifi)\n optional int32 googleRTTNetwork = 8;//Goog rtt 网络延迟\n optional string ipAddress = 9;//ip地址\n optional string useReceiveBroadBand = 10; //可接收带宽(单位: bit)\n optional string useSendBroadBand = 11;//可用发送带宽(单位: bit)\n optional string packetLossCount = 12;//丢包数\n repeated ${jl.RtcPBStreamInfo} streams = 13;\n }\n message ${jl.RtcPBStreamInfo} {\n required string trackId = 1;\n optional string codeName = 2;//编解码名称\n optional string volume = 3;//音频播放音量\n optional int32 samplingRate = 4; //音频采样率\n optional float bitRate = 5;//下行码率\n optional float packetLossRate = 6;\n optional int32 frameRate = 7;//视频接收帧率(单位:fps)\n optional string resolution = 8;//视频分辨率(格式:640*480)\n optional int64 blockTime = 9;//接收卡顿(间隔时间, 单位: ms)\n optional int32 jitterData = 10;//jitter数据抖动\n optional string nAckCount = 11;//nack数量\n optional string pliCount = 12; //PLI请求数\n optional int64 googleRTTTotalTime = 13; //googRtt往返时长\n optional int32 isReceiveFirstFrameRate = 14;//第一个关键帧是否正常收到\n optional string codeType = 15;//编码方式\n optional int32 isEnabled = 16; //当前流的状态是否可用\n }\n // ---- 北极星数据上报 -------\n message ${jl.AsrTextMsg} {\n optional int32 bms = 1; //开始转写的时间(毫秒)\n optional string t = 2; //翻译的内容\n optional bool isEnd = 3; //是否监测到完整语句\n optional string msgId = 4; //该消息的ID, 跟转写的msgId 需要一样;\n optional string lang = 5; //翻译的目标语言码\n }\n message ${jl.AsrResTextMsg} {\n optional int32 type = 1; //1 为语音识别,后续会扩展其它类型\n required string uid = 2; //对应转写的用户Id\n repeated ${jl.AsrTextMsg} asr = 3; //识别出的结果列表\n }\n}\n`,Jl=(e,t,i,r,n,s,o)=>{const a=n?Object.keys(n).map((t=>e.encode(jl.RtcValueInfo,{key:t,value:n[t]},!0))):void 0,l=s?Object.keys(s).map((t=>e.encode(jl.RtcValueInfo,{key:t,value:s[t]},!0))):void 0;return e.encode(jl.RtcInput,{roomType:t,broadcastType:i,joinType:r,innerDatas:a,outerDatas:l,supportNtf:o})},$l=(e,t)=>{const i=e.decode(jl.RtcUserListOutput,t),{users:r,token:n,sessionId:s,roomInfo:o,entries:a,offlineKickTime:l=60,codeFormat:_,roomCreateTime:c,userJoinTime:d,version:u}=i,h={};return j(r,(e=>{const{userId:t,userData:i}=e,r={};j(i,(e=>{const{key:t,value:i}=e;r[t]=i})),h[t]=r})),{users:h,token:n,sessionId:s,roomInfo:o,kvEntries:a,offlineKickTime:l,codeFormat:_,roomCreateTime:Oi(c),userJoinTime:Oi(d),version:u}};var Kl,Yl;!function(e){e[e.SUBTITLE=1]="SUBTITLE",e[e.TRANSLATION=2]="TRANSLATION"}(Kl||(Kl={}));class ql{constructor(e){Object.defineProperty(this,"context",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"roomCreateTime",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"userJoinTime",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"codec",{enumerable:!0,configurable:!0,writable:!0,value:new El(Hl)})}get logger(){return this.context.logger}joinRTCRoom(e,t,i,r,n,s,o){return m(this,void 0,void 0,(function*(){const a=Jl(this.codec,t,i,r,n,s,o),{code:l,buffer:_}=yield this.context.rtcSignaling(e,Il,!0,a);let c;if(l===oe.SUCCESS&&_){c=$l(this.codec,_);const{users:e,token:t,sessionId:i,roomInfo:r,kvEntries:n,offlineKickTime:s,roomCreateTime:o,userJoinTime:a,version:d}=c;return this.roomCreateTime=o,this.userJoinTime=a,{code:l,data:{users:e,token:t,sessionId:i,roomInfo:r,kvEntries:n,offlineKickTime:s,version:d}}}return{code:l,data:c}}))}quitRTCRoom(e){return m(this,void 0,void 0,(function*(){const t=this.codec.encode(jl.SetUserStatusInput,{status:0}),{code:i}=yield this.context.rtcSignaling(e,Tl,!0,t);return i}))}getRTCRoomInfo(e){return m(this,void 0,void 0,(function*(){const t=this.codec.encode(jl.RtcQueryListInput,{order:2}),{code:i,buffer:r}=yield this.context.rtcSignaling(e,ml,!0,t);let n;return i===oe.SUCCESS&&r&&(n=this.codec.decode(jl.RtcRoomInfoOutput,r)),{code:i,data:n}}))}getRTCUserInfoList(e){return m(this,void 0,void 0,(function*(){const t=this.codec.encode(jl.RtcQueryListInput,{order:2}),{code:i,buffer:r}=yield this.context.rtcSignaling(e,Rl,!0,t);let n;if(i===oe.SUCCESS&&r){n={users:$l(this.codec,r).users}}return{code:i,data:n}}))}getRTCUserInfo(e){throw new Error("Method not implemented.")}removeRTCUserInfo(e,t){return m(this,void 0,void 0,(function*(){const i=this.codec.encode(jl.RtcKeyDeleteInput,{key:t}),{code:r}=yield this.context.rtcSignaling(e,Sl,!1,i);return r}))}setRTCData(e,t,i,r,n,s){return m(this,void 0,void 0,(function*(){const o=this.codec.encode(jl.RtcSetDataInput,{interior:r,target:n,key:t,value:i,objectName:null==s?void 0:s.name,content:null==s?void 0:s.content}),{code:a}=yield this.context.rtcSignaling(e,Cl,!1,o);return a}))}setRTCTotalRes(e,t,i,r,n,s){return m(this,void 0,void 0,(function*(){const o={objectName:r,content:[],valueInfo:[this.codec.encode(jl.RtcValueInfo,{key:"uris",value:i},!0)]};t.forEach((e=>{const t=this.codec.encode(jl.RtcValueInfo,{key:e.name,value:e.content},!0);o.content.push(t)})),n&&o.valueInfo.push(this.codec.encode(jl.RtcValueInfo,{key:"mcu_uris",value:n},!0)),s&&o.valueInfo.push(this.codec.encode(jl.RtcValueInfo,{key:"cdn_uris",value:s},!0));const a=this.codec.encode(jl.RtcUserSetDataInput,o),{code:l}=yield this.context.rtcSignaling(e,Ll,!0,a);return l}))}setRTCCDNUris(e,t,i){return m(this,void 0,void 0,(function*(){const r=this.codec.encode(jl.RtcUserSetDataInput,{objectName:t,valueInfo:this.codec.encode(jl.RtcValueInfo,{key:"cdn_uris",value:i},!0)}),{code:n}=yield this.context.rtcSignaling(e,Ll,!0,r);return n}))}getRTCData(e,t,i,r){return m(this,void 0,void 0,(function*(){const n=this.codec.encode(jl.RtcDataInput,{interior:i,target:r,key:t}),{code:s,buffer:o}=yield this.context.rtcSignaling(e,Ol,!0,n);if(s!==oe.SUCCESS||!o)return{code:s};const{outInfo:a}=this.codec.decode(jl.RtcQryOutput,o),l={};return a.forEach((e=>{l[e.key]=e.value})),{code:s,data:l}}))}removeRTCData(e,t,i,r,n){return m(this,void 0,void 0,(function*(){const s=this.codec.encode(jl.RtcDataInput,{interior:i,target:r,key:t,objectName:(null==n?void 0:n.name)||"",content:(null==n?void 0:n.content)||""}),{code:o}=yield this.context.rtcSignaling(e,vl,!1,s);return o}))}setRTCOutData(e,t,i,r){return m(this,void 0,void 0,(function*(){throw new Error("JSEngine's method not implemented.")}))}getRTCOutData(e,t){return m(this,void 0,void 0,(function*(){throw new Error("JSEngine's method not implemented.")}))}getRTCToken(e,t,i){return m(this,void 0,void 0,(function*(){const r=Jl(this.codec,t,i),{code:n,buffer:s}=yield this.context.rtcSignaling(e,bl,!0,r);if(n!==oe.SUCCESS||!s)return{code:n};const{rtcToken:o}=this.codec.decode(jl.RtcTokenOutput,s);return{code:n,data:{rtcToken:o}}}))}setRTCState(e,t){return m(this,void 0,void 0,(function*(){const i=this.codec.encode(jl.MCFollowInput,{state:t}),{code:r}=yield this.context.rtcSignaling(e,Al,!0,i);return r}))}setRTCStateByHttp(e,t,i,r){return m(this,void 0,void 0,(function*(){var n;const s=((e,t,i)=>{const{type:r,appKey:n,sessionId:s,roomId:o,roomCreateTime:a,userId:l,userRole:_,joinTime:c,signalDataCenter:d,r1Info:u,r2Info:h,r3Info:g,r4Info:p}=t,f={type:r,appKey:n,sessionId:s,roomId:o,roomCreateTime:a,userId:l,userRole:_,joinTime:c,signalDataCenter:d};if(i===Ta.R1&&u){const t=e.encode(jl.RtcPBR1Info,u,!0);return e.encode(jl.RtcPBPolaris,Object.assign(Object.assign({},f),{r1Info:t}))}if(i===Ta.R2&&h){const t=e.encode(jl.RtcPBR2Info,h,!0);return e.encode(jl.RtcPBPolaris,Object.assign(Object.assign({},f),{r2Info:t}))}if(i===Ta.R3&&g){const{info:t}=g,{streams:i}=t;let r=Array.isArray(i)&&i.map((t=>t&&e.encode(jl.RtcPBStreamInfo,t,!0))),n=e.encode(jl.RtcPBStatusInfo,Object.assign(Object.assign({},t),{streams:r}),!0),s=e.encode(jl.RtcPBR3Info,{info:n},!0);return e.encode(jl.RtcPBPolaris,Object.assign(Object.assign({},f),{r3Info:s}))}if(i===Ta.R4&&p){const{info:t}=p,{streams:i}=t;let r=Array.isArray(i)&&i.map((t=>t&&e.encode(jl.RtcPBStreamInfo,t,!0))),n=e.encode(jl.RtcPBStatusInfo,Object.assign(Object.assign({},t),{streams:r}),!0),s=e.encode(jl.RtcPBR4Info,{info:n},!0);return e.encode(jl.RtcPBPolaris,Object.assign(Object.assign({},f),{r4Info:s}))}return{}})(this.codec,i,r);let o=e;/^https:\/\//.test(e)||(o=`https://${e}`);try{const e=yield t.httpReq({url:`${o}/rtc/logserver/polaris`,body:s,method:V.POST,headers:{jwt:(null===(n=this.context.getNaviInfo())||void 0===n?void 0:n.jwtToken)||""},timeout:2e3});if(!e.data)throw new Error("http request fail");return JSON.parse(e.data).resultCode}catch(e){return Ia.REPORT_FAIL}}))}getRTCUserList(e){return m(this,void 0,void 0,(function*(){const t=this.codec.encode(jl.RtcQueryListInput,{order:2}),{code:i,buffer:r}=yield this.context.rtcSignaling(e,Nl,!0,t);if(i!==oe.SUCCESS||!r)return{code:i};return{code:i,data:$l(this.codec,r)}}))}joinLivingRoomAsAudience(e,t,i){return m(this,void 0,void 0,(function*(){const r=Jl(this.codec,t,i),{code:n,buffer:s}=yield this.context.rtcSignaling(e,yl,!0,r);if(n!==oe.SUCCESS||!s)return{code:n};const{rtcToken:o,entries:a,roomCreateTime:l,userJoinTime:_}=this.codec.decode(jl.RtcViewerJoinedOutput,s);return this.roomCreateTime=Oi(l),this.userJoinTime=Oi(_),{code:n,data:{token:o,kvEntries:a}}}))}quitLivingRoomAsAudience(e){return m(this,void 0,void 0,(function*(){const t=this.codec.encode(jl.SetUserStatusInput,{status:0}),{code:i}=yield this.context.rtcSignaling(e,Pl,!0,t);return i}))}rtcIdentityChange(e,t,i){return m(this,void 0,void 0,(function*(){const r=this.codec.encode(jl.RtcInput,{roomType:To.LIVE,broadcastType:i,identityChangeType:t,needSysChatroom:!1}),{code:n,buffer:s}=yield this.context.rtcSignaling(e,Dl,!0,r);if(n!==oe.SUCCESS||!s)return{code:n};return{code:n,data:$l(this.codec,s)}}))}requestRoomPK(e){return m(this,void 0,void 0,(function*(){const{invitedRoomId:t,invitedUserId:i,inviteSessionId:r,inviteTimeout:n,inviteInfo:s,roomId:o}=e,a=this.codec.encode(jl.RtcInviteInput,{invitedRoomId:t,invitedUserId:i,inviteSessionId:r,timeoutTime:n,inviteInfo:s}),{code:l}=yield this.context.rtcSignaling(o,Ml,!0,a);return l}))}cancelRoomPK(e){return m(this,void 0,void 0,(function*(){const{invitedRoomId:t,invitedUserId:i,inviteSessionId:r,inviteInfo:n,roomId:s}=e,o=this.codec.encode(jl.RtcCancelInviteInput,{invitedRoomId:t,invitedUserId:i,inviteSessionId:r,inviteInfo:n}),{code:a}=yield this.context.rtcSignaling(s,wl,!0,o);return a}))}responseRoomPK(e){return m(this,void 0,void 0,(function*(){const{inviteUserId:t,inviteRoomId:i,inviteSessionId:r,content:n,key:s,value:o,agree:a,roomId:l}=e,_=this.codec.encode(jl.RtcInviteAnswerInput,{inviteUserId:t,inviteRoomId:i,inviteSessionId:r,content:n,key:s,value:o,answerCode:a?1:0}),{code:c}=yield this.context.rtcSignaling(l,kl,!0,_);return c}))}endRoomPK(e){return m(this,void 0,void 0,(function*(){const{endRoomId:t,sessionId:i,content:r,keys:n,roomId:s}=e,o=this.codec.encode(jl.RtcEndInviteInput,{inviteRoomId:t,inviteSessionId:i,inviteContent:r,inviteRoomKeys:n}),{code:a}=yield this.context.rtcSignaling(s,xl,!0,o);return a}))}getRTCJoinedUserInfo(e){return m(this,void 0,void 0,(function*(){const t=this.codec.encode(jl.RtcQueryUserJoinedInput,{userId:e}),{code:i,buffer:r}=yield this.context.rtcSignaling("",Bl,!0,t);if(i!==oe.SUCCESS||!r)return{code:i};return{code:i,data:(this.codec.decode(jl.RtcQueryUserJoinedOutput,r).info||[]).map((e=>({deviceId:e.deviceId,roomId:e.roomId,joinTime:Oi(e.joinTime)})))}}))}pullRTCRoomEntry(e){return m(this,void 0,void 0,(function*(){const t=this.codec.encode(jl.RtcPullKV,{timestamp:0,roomId:e}),{code:i,buffer:r}=yield this.context.rtcSignaling(e,Ul,!0,t);if(i!==oe.SUCCESS)return{code:i};const n=this.codec.decode(jl.RtcKVOutput,r);let{entries:s,syncTime:o}=n;return s=(s||[]).map((e=>Object.assign(Object.assign({},e),{timestamp:Oi(e.timestamp)}))),{code:i,data:{kvEntries:s,syncTime:Oi(o)}}}))}pullRTCRoomStatus(e,t){return m(this,void 0,void 0,(function*(){const i=this.codec.encode(jl.RtcRoomStatusInput,{version:t}),{code:r,buffer:n}=yield this.context.rtcSignaling(e,Vl,!0,i);if(r!==oe.SUCCESS)return{code:r};return{code:r,data:this.codec.decode(jl.RtcRoomStatusOutput,n)}}))}decodeRtcNotify(e){const{time:t,type:i,roomId:r}=this.codec.decode(jl.RtcNotifyMsg,e);return{time:Oi(t),type:i,roomId:r}}getCurrentId(){return this.context.getCurrentId()}getNaviInfo(){return this.context.getNaviInfo()}getConnectionStatus(){return this.context.getConnectionStatus()}getAppkey(){return this.context.getAppkey()}webRtcPing(e,t,i){return m(this,void 0,void 0,(function*(){const r=this.codec.encode(jl.RtcInput,{roomType:t,broadcastType:i}),{code:n,buffer:s}=yield this.context.rtcSignaling(e,Fl,!0,r);if(n!==oe.SUCCESS)return{code:n};const o=this.codec.decode(jl.RtcOutput,s);return o.version=Oi(o.version),{code:n,data:o}}))}rtcPing(e,t,i){var r,n;return/Electron/.test(navigator.userAgent)?null===(n=(r=this.context).rtcPingResVersion)||void 0===n?void 0:n.call(r,e,t,i):this.webRtcPing(e,t,i)}sendMessage(e,t,i){return this.context.sendMessage(e,t,i)}registerRTCSignalListener(e){this.context.registerRTCSignalListener(e)}registerConnectionStateChangeListener(e){var t,i;null===(i=(t=this.context).registerConnectionStateChangeListener)||void 0===i||i.call(t,e)}registerDisconnectListener(e){var t,i;null===(i=(t=this.context).registerDisconnectListener)||void 0===i||i.call(t,e)}registerDestroyListener(e){var t,i;null===(i=(t=this.context).registerDestroyListener)||void 0===i||i.call(t,e)}registerMessageListener(e){var t,i;null===(i=(t=this.context).registerMessageListener)||void 0===i||i.call(t,e)}getCoreVersion(){return this.context.getCoreVersion()}getPluginContext(){return this.context}reportSDKInfo(e){const t=this.codec.encode(jl.RtcReportSDKInput,{sdkInfo:JSON.stringify(e)});this.context.rtcSignaling("",Gl,!0,t)}decodeAsrText(e,t){let i;try{i=this.codec.decode(jl.AsrResTextMsg,e)}catch(i){console.error("decodeAsrText error",{error:i,seiFrameData:e.join(","),seiOriginData:t.join(",")})}const{type:r,uid:n,asr:s}=i||{asr:[]};return s.map((e=>{const{bms:t,t:i,isEnd:s,msgId:o,lang:a}=e,l={userID:n,timeUTC:t,msg:i,msgId:o,isEnd:s};return r===Kl.SUBTITLE?l:Object.assign(Object.assign({},l),{destLangCode:a})}))}}class Wl extends sl{constructor(e,t,i){var r,n;super(e),Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_runtime",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_options",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_service",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_crtRoom",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_audience",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_crtAudienceLivingRoom",{enumerable:!0,configurable:!0,writable:!0,value:null}),Ro.setSdpSemantics(i.sdpSemantics||"unified-plan",this._logger),this._service=new Ks(this._runtime,this._context,this._options.mediaServer,this._options.timeout),this._context.registerConnectionStateChangeListener(this._onIMStatusChange.bind(this)),this._context.registerDestroyListener(this._onIMUninit.bind(this)),this._context.registerMessageListener(this._handleMessage.bind(this)),null===(n=(r=this._context.getPluginContext()).setOnnavidatachange)||void 0===n||n.call(r,this.naviDataChange.bind(this))}static init(e={},t,i){const{logger:r}=t;if(r.warn(le.L_INDEX_INSTALL_RTC_PLUGIN_O,JSON.stringify({"NCRTC Version":"26.2.0-alpha.2",Commit:"81d94615a1108f460ca4e29af07e7c0aff5a6b75","browserInfo.browser":Ii.browser,"browserInfo.supportsUnifiedPlan":Ii.supportsUnifiedPlan,"browserInfo.version":Ii.version})),k("options",e,D.OBJECT,!0),k("options.mediaServer",e.mediaServer,(e=>!(!U(e)||"https:"===location.protocol&&!/^https/.test(e)))),k("options.timeout",e.timeout,(e=>O(e)&&e>=5e3&&e<=3e4)),k("options.pingGap",e.pingGap,(e=>O(e)&&e>=3e3&&e<=1e4)),e.AAAWorklet){k("options.AAAWorklet",e.AAAWorklet,D.OBJECT,!0);const{scriptUrl:t,wasmUrl:i}=e.AAAWorklet;k("AAAWorklet.scriptUrl",t,D.STRING,!0),k("AAAWorklet.wasmUrl",i,D.STRING,!0),Ft.SCRIPT_URL=t,Ft.WASM_URL=i}return e.encryptor&&(k("options.encrypt",e.encryptor,D.OBJECT,!0),k("options.encrypt.decodeAudio",e.encryptor.decodeAudio,(e=>"function"==typeof e),!0),k("options.encrypt.decodeVideo",e.encryptor.decodeVideo,(e=>"function"==typeof e),!0),k("options.encrypt.encodeAudio",e.encryptor.encodeAudio,(e=>"function"==typeof e),!0),k("options.encrypt.encodeVideo",e.encryptor.encodeVideo,(e=>"function"==typeof e),!0),oo.init(e.encryptor,r)),Wl._instance||(Wl._instance=new Wl(new ql(t),i,e)),Wl._instance}_handleMessage(e){if(e.conversationType!==a.RTC_ROOM)return!1;const t=this._logger.createTraceId();if(this._crtRoom instanceof Wa){this._getJoinedPKRoomList().forEach((i=>{i.__parseInnerMessage(e,t)}))}return this._logger.info(le.L_RTC_CLIENT_MESSAGE_O,JSON.stringify({status:_e.SUCCESSED,message:e}),t),this._crtRoom?(this._crtRoom.__parseInnerMessage(e,t),!0):(this._logger.warn(le.L_RTC_CLIENT_MESSAGE_O,JSON.stringify({status:_e.FAILED,message:"the crtRoom is empty"}),t),!0)}naviDataChange(e){this._logger.info(le.L_RTC_CLIENT_NAVI_CHANGE_O,`on navi change data => ${JSON.stringify(e)}`),this._service.clearMSList(),this._service.isNededDetector()&&this._service.detectorMediaSever()}_getJoinedPKRoomList(){const{code:e,roomPKHandler:t}=this._crtRoom.getRoomPKHandler();if(e===ae.SUCCESS&&t){const e=t.getJoinedPKRooms()||{};return Object.values(e)}return[]}getPluginContext(){return this._context.getPluginContext()}getCurrentId(){return this._context.getCurrentId()}joinCrossRTCRoom(e,t,i){return m(this,arguments,void 0,(function*(e,t,i,r=!1,n=To.CROSS_MUTI){return console.warn("joinCrossRTCRoom is deprecated, use joinRTCRoomWithOptions instead"),this.joinRTCRoomWithOptions(e,{joinType:t,userData:i,mode:To.CROSS_MUTI})}))}joinRTCRoom(e,t,i){return m(this,arguments,void 0,(function*(e,t,i,r=!1,n=To.RTC){return console.warn("joinRTCRoom is deprecated, use joinRTCRoomWithOptions instead"),this.joinRTCRoomWithOptions(e,{mode:n,joinType:t,userData:i})}))}joinRTCRoomWithOptions(e,t){return m(this,void 0,void 0,(function*(){const i=this._logger.createTraceId();if(this._logger.info(le.L_RTC_CLIENT_JOIN_RTC_ROOM_T,JSON.stringify({roomId:e,options:t}),i),this._crtRoom)return this._logger.error(le.L_RTC_CLIENT_JOIN_RTC_ROOM_R,JSON.stringify({status:_e.FAILED,code:ae.REPERT_JOIN_ROOM,msg:"Join the room repeatedly"}),i),{code:ae.REPERT_JOIN_ROOM};const r=this._crtRoom=new za(this._context,this._runtime,e,this._service,this._options,null==t?void 0:t.mode,null==t?void 0:t.encrypt),{code:n}=yield r.__innerInit((null==t?void 0:t.mode)||To.RTC,null==t?void 0:t.joinType,void 0,void 0,null==t?void 0:t.userData,i,null==t?void 0:t.srcLanguage,null==t?void 0:t.nickName);return n!==ae.SUCCESS?(this._crtRoom=null,{code:n}):(r.once(Ua,(()=>{this._crtRoom=null})),{code:n,room:r,userIds:r.getRemoteUserIds(),tracks:r.getRemoteTracks()})}))}joinLivingRoom(e,t,i,r){return m(this,arguments,void 0,(function*(e,t,i,r,n=!1){const s=this._logger.createTraceId();if(this._logger.info(le.L_RTC_CLIENT_JOIN_LIVING_ROOM_T,JSON.stringify({roomId:e,livingType:t,joinType:i,outerUserDatas:r}),s),this._crtRoom)return this._logger.error(le.L_RTC_CLIENT_JOIN_LIVING_ROOM_R,JSON.stringify({status:_e.FAILED,code:ae.REPERT_JOIN_ROOM,msg:`Join the room repeatedly -> roomId: ${e}`}),s),{code:ae.REPERT_JOIN_ROOM};const o=this._crtRoom=new Wa(this._context,this._runtime,e,this._service,this._options,t,!1,!0),{code:a}=yield o.__innerInit(To.LIVE,i,t,void 0,r,s);if(a!==ae.SUCCESS)return this._crtRoom=null,{code:a};o.once(Ua,(()=>{this._crtRoom=null}));const l={code:a,room:o,userIds:o.getRemoteUserIds(),tracks:o.getRemoteTracks()};return o.__getCDNPushMode()===nl.MANUAL&&Object.assign(l,{CDNEnable:o.__getCDNEnable()}),l}))}getAudienceClient(e){return this._audience||(this._audience=new Xa(this._context,this._runtime,this._options)),this._logger.info(le.L_RTC_CLIENT_GET_AUDIENCE_CLIENT_O),this._audience}_onIMStatusChange(e,t){if(this._logger.info(le.L_RTC_CLIENT_IM_CONNECTION_STATE_S,JSON.stringify({status:e,code:t,desc:l[e]})),e===l.SUSPENDED&&40001===t&&this._service.clearMSList(),e===l.DISCONNECTED){if(this._crtRoom){let e=pa.IM_DISCONNECTED;40002===t?e=pa.OTHER_CLIENT_IM_CONNECTED:t===oe.ACTIVE_DISCONNECT&&(e=pa.IM_LOGOUT),this._crtRoom.__kickoff(!0,{users:[{userId:this._context.getCurrentId(),type:e}]})}}else if(e===l.CONNECTED){if(this._service.isNededDetector()&&this._service.detectorMediaSever(),this._crtRoom instanceof Wa){this._getJoinedPKRoomList().forEach((e=>{e.__onReconnected()}))}this._crtRoom&&this._crtRoom.__onReconnected()}}_onIMUninit(){var e;this._logger.info(le.L_RTC_CLIENT_DESTROY_S,JSON.stringify({msg:"TODO -> on IM client ondestroy"})),null===(e=this._crtRoom)||void 0===e||e.__destroy(!0)}leaveRoom(e){return m(this,void 0,void 0,(function*(){var t;const i=this._logger.createTraceId();return this._logger.info(le.L_RTC_CLIENT_LEAVE_ROOM_T,JSON.stringify({roomId:e.getRoomId()}),i),this._crtRoom?(yield this._crtRoom.__destroy(!0),this._service.isNededDetector()&&this._service.detectorMediaSever(),this._logger.info(le.L_RTC_CLIENT_LEAVE_ROOM_R,JSON.stringify({status:_e.SUCCESSED,roomId:null===(t=this._crtRoom)||void 0===t?void 0:t.getRoomId()}),i),this._crtRoom=null,{code:ae.SUCCESS}):(this._logger.warn(le.L_RTC_CLIENT_LEAVE_ROOM_R,JSON.stringify({status:_e.FAILED,msg:"Room does not exist, without leave"}),i),{code:ae.SUCCESS})}))}joinLivingRoomAsAudience(e,t,i){return m(this,void 0,void 0,(function*(){const i=this._logger.createTraceId();if(this._logger.info(le.L_RTC_CLIENT_JOIN_LIVING_ROOM_AS_AUDIENCE_T,JSON.stringify({roomId:e,livingType:t}),i),this._service.isNededDetector()&&this._service.detectorMediaSever(),Si(this._context.getNaviInfo()))return this._logger.error(le.L_RTC_CLIENT_JOIN_LIVING_ROOM_AS_AUDIENCE_R,JSON.stringify({status:_e.FAILED,code:ae.PACKAGE_ENVIRONMENT_ERROR,msg:"package environment error"}),i),{code:ae.PACKAGE_ENVIRONMENT_ERROR};if(!x("roomId",e,b,!0)||!x("livingType",t,(e=>e===Fa.AUDIO||e===Fa.VIDEO)))return this._logger.error(le.L_RTC_CLIENT_JOIN_LIVING_ROOM_AS_AUDIENCE_R,JSON.stringify({status:_e.FAILED,code:ae.PARAMS_ERROR,msg:"params error -> roomId or livingType"}),i),{code:ae.PARAMS_ERROR};if(this._crtAudienceLivingRoom)return this._logger.error(le.L_RTC_CLIENT_JOIN_LIVING_ROOM_AS_AUDIENCE_R,JSON.stringify({status:_e.FAILED,code:ae.REPERT_JOIN_ROOM,msg:"Join the room repeatedly"}),i),{code:ae.REPERT_JOIN_ROOM};if(!this._service.getMsList().length)return this._logger.error(le.L_RTC_CLIENT_JOIN_LIVING_ROOM_AS_AUDIENCE_R,JSON.stringify({status:_e.FAILED,code:ae.NOT_OPEN_VIDEO_AUDIO_SERVER,msg:"No audio / video server address available"}),i),{code:ae.NOT_OPEN_VIDEO_AUDIO_SERVER};const{code:r,data:n}=yield this._context.joinLivingRoomAsAudience(e,To.LIVE,t);if(r!==oe.SUCCESS)return this._logger.error(le.L_RTC_CLIENT_JOIN_LIVING_ROOM_AS_AUDIENCE_R,JSON.stringify({status:_e.FAILED,code:r,msg:"signal error -> audience join room"}),i),{code:ae.SIGNAL_AUDIENCE_JOIN_ROOM_FAILED};const s=Gs(),o=new rl(this._context,this._runtime,this._options,e,n,t,s);return this._crtAudienceLivingRoom=o,this._logger.info(le.L_RTC_CLIENT_JOIN_LIVING_ROOM_AS_AUDIENCE_R,JSON.stringify({status:_e.SUCCESSED,roomData:n}),i),{room:o,code:ae.SUCCESS,userIds:o.getRemoteUserIds(),RTCTracks:o.getRemoteRTCTracks(),MCUTracks:o.getRemoteMCUTracks(),CDNUris:o.getCDNInfo()}}))}leaveLivingRoomAsAudience(e){return m(this,void 0,void 0,(function*(){const t=this._logger.createTraceId();return this._logger.info(le.L_RTC_CLIENT_LEAVE_LIVING_ROOM_AS_AUDIENCE_T,JSON.stringify({roomId:e.getRoomId(),userId:this._context.getCurrentId()}),t),this._crtAudienceLivingRoom?this._crtAudienceLivingRoom!==e?(this._logger.error(le.L_RTC_CLIENT_LEAVE_LIVING_ROOM_AS_AUDIENCE_R,JSON.stringify({status:_e.FAILED,code:ae.PARAMS_ERROR,msg:"params error -> room"}),t),{code:ae.PARAMS_ERROR}):(yield this._crtAudienceLivingRoom.__destroy(!0),this._crtAudienceLivingRoom=null,this._logger.info(le.L_RTC_CLIENT_LEAVE_LIVING_ROOM_AS_AUDIENCE_R,JSON.stringify({status:_e.SUCCESSED}),t),{code:ae.SUCCESS}):(this._logger.warn(le.L_RTC_CLIENT_LEAVE_LIVING_ROOM_AS_AUDIENCE_R,JSON.stringify({status:_e.FAILED,msg:"Room does not exist, without leave"}),t),{code:ae.SUCCESS})}))}upgradeToAnchorRoom(e){return m(this,void 0,void 0,(function*(){const t=this._logger.createTraceId();if(this._logger.info(le.L_RTC_CLIENT_UPGRADE_TO_ANCHOR_ROOM_T,void 0,t),!x("room",e,(()=>e instanceof rl),!0))return this._logger.error(le.L_RTC_CLIENT_UPGRADE_TO_ANCHOR_ROOM_R,JSON.stringify({status:_e.FAILED,code:ae.PARAMS_ERROR,msg:"params error -> room"}),t),{code:ae.PARAMS_ERROR};const i=e.getRoomId();if(this._crtRoom)return this._logger.error(le.L_RTC_CLIENT_UPGRADE_TO_ANCHOR_ROOM_R,JSON.stringify({status:_e.FAILED,code:ae.REPERT_JOIN_ROOM,msg:"Join the room repeatedly",roomId:i}),t),{code:ae.REPERT_JOIN_ROOM};const r=this._crtRoom=new Wa(this._context,this._runtime,i,this._service,this._options,e.livingType,!0,!0,e.getClientSessionId()),n=yield r.__innerInitByIdentityChange(t);if(n!==oe.SUCCESS)return this._crtRoom=null,{code:n};r.once(Ua,(()=>{this._crtRoom=null})),yield this._crtAudienceLivingRoom.__destroy(!1),this._crtAudienceLivingRoom=null;const s={room:r,code:ae.SUCCESS,userIds:r.getRemoteUserIds(),tracks:r.getRemoteTracks()};return r.__getCDNPushMode()===nl.MANUAL&&Object.assign(s,{CDNEnable:r.__getCDNEnable()}),s}))}downgradeToAudienceRoom(e){return m(this,void 0,void 0,(function*(){const t=this._logger.createTraceId();if(this._logger.info(le.L_RTC_CLIENT_DOWNGRADE_TO_AUDIENCE_ROOM_T,JSON.stringify({roomId:e._roomId,userId:this._context.getCurrentId()}),t),!e.isMainRoom())return this._logger.error(le.L_RTC_CLIENT_DOWNGRADE_TO_AUDIENCE_ROOM_R,JSON.stringify({status:_e.FAILED,code:ae.THE_FUNCTION_IS_DISABLED_IN_PKROOM,msg:"the `downgradeToAudienceRoom` is disabled in PK room"}),t),{code:ae.THE_FUNCTION_IS_DISABLED_IN_PKROOM};if(!x("room",e,(()=>e instanceof Wa),!0))return this._logger.error(le.L_RTC_CLIENT_DOWNGRADE_TO_AUDIENCE_ROOM_R,JSON.stringify({status:_e.FAILED,code:ae.PARAMS_ERROR,msg:"params error -> room"}),t),{code:ae.PARAMS_ERROR};if(this._crtAudienceLivingRoom)return this._logger.error(le.L_RTC_CLIENT_DOWNGRADE_TO_AUDIENCE_ROOM_R,JSON.stringify({status:_e.FAILED,code:ae.REPERT_JOIN_ROOM,msg:"Join the room repeatedly"}),t),{code:ae.REPERT_JOIN_ROOM};const{code:i,data:r}=yield this._context.rtcIdentityChange(e._roomId,Ha.AnchorToViewer,e.getLivingType());if(i!==oe.SUCCESS)return this._logger.error(le.L_RTC_CLIENT_DOWNGRADE_TO_AUDIENCE_ROOM_R,JSON.stringify({status:_e.FAILED,code:ae.SIGNAL_ROOM_CHANGE_IDENTITY_FAILED}),t),{code:ae.SIGNAL_ROOM_CHANGE_IDENTITY_FAILED};this._logger.info(le.L_RTC_CLIENT_DOWNGRADE_TO_AUDIENCE_ROOM_R,JSON.stringify({status:_e.SUCCESSED,roomData:r}),t);const n=e.getClientSessionId(),s=new rl(this._context,this._runtime,this._options,e._roomId,r,e.getLivingType(),n);return this._crtAudienceLivingRoom=s,this._crtRoom.__destroy(!1),this._crtRoom=null,{room:s,code:ae.SUCCESS,userIds:s.getRemoteUserIds(),RTCTracks:s.getRemoteRTCTracks(),MCUTracks:s.getRemoteMCUTracks(),CDNUris:s.getCDNInfo()}}))}getJoinedRoomInfo(){return m(this,void 0,void 0,(function*(){const e=this._logger.createTraceId(),t=this._context.getCurrentId();this._logger.error(le.L_RTC_CLIENT_GET_JOINED_ROOM_INFO_T,JSON.stringify({userId:t}),e);const{code:i,data:r}=yield this._context.getRTCJoinedUserInfo(t);return i!==oe.SUCCESS?(this._logger.error(le.L_RTC_CLIENT_GET_JOINED_ROOM_INFO_R,JSON.stringify({status:_e.FAILED,code:i}),e),{code:i}):(this._logger.info(le.L_RTC_CLIENT_GET_JOINED_ROOM_INFO_R,JSON.stringify({status:_e.SUCCESSED,roomInfo:r}),e),{code:ae.SUCCESS,data:r})}))}generateSummarization(e,t){return m(this,arguments,void 0,(function*(e,t,i=0,r=0,n,s){const o=this._logger.createTraceId();if(this._logger.info(le.L_RTC_CLIENT_GENERATE_SUMMARIZATION_T,JSON.stringify({roomId:e,taskId:t,startTime:i,endTime:r,config:n,contentBlock:s}),o),!x("roomId",e,b,!0))return this._logger.error(le.L_RTC_CLIENT_GENERATE_SUMMARIZATION_R,JSON.stringify({status:_e.FAILED,code:ae.PARAMS_ERROR,msg:"params error -> roomId"}),o),{code:ae.PARAMS_ERROR};if(!x("taskId",t,b,!0))return this._logger.error(le.L_RTC_CLIENT_GENERATE_SUMMARIZATION_R,JSON.stringify({status:_e.FAILED,code:ae.PARAMS_ERROR,msg:"params error -> taskId"}),o),{code:ae.PARAMS_ERROR};if(!O(i)||i<0)return this._logger.error(le.L_RTC_CLIENT_GENERATE_SUMMARIZATION_R,JSON.stringify({status:_e.FAILED,code:ae.PARAMS_ERROR,msg:"params error -> startTime"}),o),{code:ae.PARAMS_ERROR};if(!O(r)||r<0)return this._logger.error(le.L_RTC_CLIENT_GENERATE_SUMMARIZATION_R,JSON.stringify({status:_e.FAILED,code:ae.PARAMS_ERROR,msg:"params error -> endTime"}),o),{code:ae.PARAMS_ERROR};if(!x("config",n,N,!0))return this._logger.error(le.L_RTC_CLIENT_GENERATE_SUMMARIZATION_R,JSON.stringify({status:_e.FAILED,code:ae.PARAMS_ERROR,msg:"params error -> config"}),o),{code:ae.PARAMS_ERROR};const{isValid:a,key:l}=(e=>{if("destLang"in e&&!C(e.destLang))return{isValid:!1,key:"destLang"};if("customPrompt"in e&&!C(e.customPrompt))return{isValid:!1,key:"customPrompt"};if("enableSummarization"in e&&!L(e.enableSummarization))return{isValid:!1,key:"enableSummarization"};if("enableSummarizationDetails"in e&&!L(e.enableSummarizationDetails))return{isValid:!1,key:"enableSummarizationDetails"};if("enableChapterSummary"in e&&!L(e.enableChapterSummary))return{isValid:!1,key:"enableChapterSummary"};if("enableTodoList"in e&&!L(e.enableTodoList))return{isValid:!1,key:"enableTodoList"};if("enableHashtag"in e&&!L(e.enableHashtag))return{isValid:!1,key:"enableHashtag"};if("format"in e&&void 0===ti[e.format])return{isValid:!1,key:"format"};const t=e.enableSummarization||e.enableSummarizationDetails||e.enableChapterSummary||e.enableTodoList||e.enableHashtag;return e.customPrompt||t?{isValid:!0,key:""}:{isValid:!1,key:"at least one of the summary features must be enabled"}})(n);a||this._logger.warn(le.L_RTC_CLIENT_GENERATE_SUMMARIZATION_R,JSON.stringify({status:_e.FAILED,code:ae.PARAMS_ERROR,msg:`params error -> config.${l}`}),o);const{code:_,msg:c}=yield this._service.generateSummarization(e,t,i,r,n,s,o);return _!==ae.SUCCESS?(this._logger.error(le.L_RTC_CLIENT_GENERATE_SUMMARIZATION_R,JSON.stringify({status:_e.FAILED,code:_,msg:c}),o),{code:_}):(this._logger.info(le.L_RTC_CLIENT_GENERATE_SUMMARIZATION_R,JSON.stringify({status:_e.SUCCESSED}),o),{code:_})}))}getASRContent(e,t){return m(this,arguments,void 0,(function*(e,t,i=0,r=0,n,s){const o=this._logger.createTraceId();if(this._logger.info(le.L_RTC_CLIENT_GET_ASR_CONTENT_T,JSON.stringify({roomId:e,taskId:t,startTime:i,endTime:r,destLang:s,contentBlock:n}),o),!x("roomId",e,b,!0))return this._logger.error(le.L_RTC_CLIENT_GET_ASR_CONTENT_R,JSON.stringify({status:_e.FAILED,code:ae.PARAMS_ERROR,msg:"params error -> roomId"}),o),{code:ae.PARAMS_ERROR};if(!x("taskId",t,b,!0))return this._logger.error(le.L_RTC_CLIENT_GET_ASR_CONTENT_R,JSON.stringify({status:_e.FAILED,code:ae.PARAMS_ERROR,msg:"params error -> taskId"}),o),{code:ae.PARAMS_ERROR};if(!O(i)||i<0)return this._logger.error(le.L_RTC_CLIENT_GET_ASR_CONTENT_R,JSON.stringify({status:_e.FAILED,code:ae.PARAMS_ERROR,msg:"params error -> startTime"}),o),{code:ae.PARAMS_ERROR};if(!O(r)||r<0)return this._logger.error(le.L_RTC_CLIENT_GET_ASR_CONTENT_R,JSON.stringify({status:_e.FAILED,code:ae.PARAMS_ERROR,msg:"params error -> endTime"}),o),{code:ae.PARAMS_ERROR};if(!x("destLang",s,C,!1))return this._logger.error(le.L_RTC_CLIENT_GET_ASR_CONTENT_R,JSON.stringify({status:_e.FAILED,code:ae.PARAMS_ERROR,msg:"params error -> destLang"}),o),{code:ae.PARAMS_ERROR};const{code:a,msg:l}=yield this._service.getASRContent(e,t,i,r,n,o,s);return a!==ae.SUCCESS?(this._logger.error(le.L_RTC_CLIENT_GET_ASR_CONTENT_R,JSON.stringify({status:_e.FAILED,code:a,msg:l}),o),{code:a}):(this._logger.info(le.L_RTC_CLIENT_GET_ASR_CONTENT_R,JSON.stringify({status:_e.SUCCESSED}),o),{code:a})}))}}Object.defineProperty(Wl,"_instance",{enumerable:!0,configurable:!0,writable:!0,value:null}),function(e){e[e.KICK=0]="KICK",e[e.REFUSE=1]="REFUSE"}(Yl||(Yl={}));const zl={tag:"RCRTC",verify:()=>"undefined"==typeof isSecureContext||isSecureContext?!!r.validEngine("26.2.0")||(console.error(`The current engine version '${r.getInfo().engine}' error, plugin-rtc required engine version at least '26.2.0'.`),!1):(console.error("Please use the https protocol or use `http://localhost` to open the page!"),!1),setup(e){const t=S(e),{logger:i}=t;return i.warn(le.L_INDEX_INSTALL_RTC_PLUGIN_O,JSON.stringify({"NCRTC Version":"26.2.0-alpha.2",Commit:"81d94615a1108f460ca4e29af07e7c0aff5a6b75","browserInfo.browser":Ii.browser,"browserInfo.supportsUnifiedPlan":Ii.supportsUnifiedPlan,"browserInfo.version":Ii.version})),new Wl(new ql(t),se,{})}},Ql=_i,Zl=0,Xl=80001,e_=80002,t_=80003,i_=80004,r_=80005,n_=80006,s_=80008,o_=80012,a_=80100,l_=80101,__=80102,c_=80104,d_=80105;var u_,h_,g_,p_,f_,E_,I_,T_;!function(e){e.L_INDEX_INSTALL_CALL_PLUS_PLUGIN_O="L-index_install_call_plus_plugin-O",e.L_CALLPLUS_CLIENT_SET_EVENT_LISTENER_O="L-callplus_client_set_event_listener-O",e.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O="L-callplus_client_call_event_listener-O",e.L_CALLPLUS_CLIENT_SET_STATUS_REPORT_LISTENER_O="L-callplus_client_set_status_report_listener-O",e.L_CALLPLUS_CLIENT_CALL_STATUS_REPORT_LISTENER_O="L-callplus_client_call_status_report_listener-O",e.L_CALLPLUS_CLIENT_SET_VIDEO_CONFIG_T="L-callplus_client_set_video_config-T",e.L_CALLPLUS_CLIENT_SET_VIDEO_CONFIG_R="L-callplus_client_set_video_config-R",e.L_CALLPLUS_VIDEO_CONFIG_SET_FRAME_RATE_O="L-callplus_video_config_set_frame_rate-O",e.L_CALLPLUS_VIDEO_CONFIG_SET_RESOLUTION_O="L-callplus_video_config_set_resolution-O",e.L_CALLPLUS_VIDEO_CONFIG_SET_BITRATE_O="L-callplus_video_config_set_bitrate-O",e.L_CALLPLUS_CLIENT_SET_AUDIO_CONFIG_T="L-callplus_client_set_audio_config-T",e.L_CALLPLUS_CLIENT_SET_AUDIO_CONFIG_R="L-callplus_client_set_audio_config-R",e.L_CALLPLUS_AUDIO_CONFIG_SET_BITRATE_O="L-callplus_audio_config_set_bitrate-O",e.L_CALLPLUS_AUDIO_CONFIG_SET_SAMPLE_RATE_O="L-callplus_audio_config_set_sample_rate-O",e.L_CALLPLUS_CLIENT_PREVIEW_T="L-callplus_client_preview-T",e.L_CALLPLUS_CLIENT_PREVIEW_R="L-callplus_client_preview-R",e.L_CALLPLUS_CLIENT_START_CALL_T="L-callplus_client_start_call-T",e.L_CALLPLUS_CLIENT_START_CALL_R="L-callplus_client_start_call-R",e.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_T="L-callplus_client_join_multi_call-T",e.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_R="L-callplus_client_join_multi_call-R",e.L_CALLPLUS_CLIENT_ACCEPT_T="L-callplus_client_accept-T",e.L_CALLPLUS_CLIENT_ACCEPT_R="L-callplus_client_accept-R",e.L_CALLPLUS_CLIENT_HANGUP_T="L-callplus_client_hangup-T",e.L_CALLPLUS_CLIENT_HANGUP_R="L-callplus_client_hangup-R",e.L_CALLPLUS_CLIENT_INVITE_T="L-callplus_client_invite-T",e.L_CALLPLUS_CLIENT_INVITE_R="L-callplus_client_invite-R",e.L_CALLPLUS_CLIENT_REQUEST_CHANGE_MEDIA_TYPE_T="L-callplus_client_request_change_media_type-T",e.L_CALLPLUS_CLIENT_REQUEST_CHANGE_MEDIA_TYPE_R="L-callplus_client_request_change_media_type-R",e.L_CALLPLUS_CLIENT_CANCEL_CHANGE_MEDIA_TYPE_T="L-callplus_client_cancel_change_media_type-T",e.L_CALLPLUS_CLIENT_CANCEL_CHANGE_MEDIA_TYPE_R="L-callplus_client_cancel_change_media_type-R",e.L_CALLPLUS_CLIENT_REPLY_CHANGE_MEDIA_TYPE_T="L-callplus_client_reply_change_media_type-T",e.L_CALLPLUS_CLIENT_REPLY_CHANGE_MEDIA_TYPE_R="L-callplus_client_reply_change_media_type-R",e.L_CALLPLUS_CLIENT_GET_CURRENT_CALL_SESSION_T="L-callplus_client_get_current_call_session-T",e.L_CALLPLUS_CLIENT_GET_CURRENT_CALL_SESSION_R="L-callplus_client_get_current_call_session-R",e.L_CALLPLUS_CLIENT_GET_AVAILABLE_CALL_RECORDS_FROM_SERVER_T="L-callplus_client_get_available_call_sessions_from_server-T",e.L_CALLPLUS_CLIENT_GET_AVAILABLE_CALL_RECORDS_FROM_SERVER_R="L-callplus_client_get_available_call_sessions_from_server-R",e.L_CALLPLUS_CLIENT_GET_CALL_RECORDS_T="L-callplus_client_get_call_records-T",e.L_CALLPLUS_CLIENT_GET_CALL_RECORDS_R="L-callplus_client_get_call_records-R",e.L_CALLPLUS_CLIENT_DELETE_CALL_RECORDS_BY_CALLID_T="L-callplus_client_delete_call_records_by_callId-T",e.L_CALLPLUS_CLIENT_DELETE_CALL_RECORDS_BY_CALLID_R="L-callplus_client_delete_call_records_by_callId-R",e.L_CALLPLUS_CLIENT_DELETE_ALL_CALL_RECORDS_FROM_SERVER_T="L-callplus_client_delete_all_call_records_from_server-T",e.L_CALLPLUS_CLIENT_DELETE_ALL_CALL_RECORDS_FROM_SERVER_R="L-callplus_client_delete_all_call_records_from_server-R",e.L_CALLPLUS_CLIENT_START_CAMERA_T="L-callplus_client_start_camera-T",e.L_CALLPLUS_CLIENT_START_CAMERA_R="L-callplus_client_start_camera-R",e.L_CALLPLUS_CLIENT_STOP_CAMERA_T="L-callplus_client_stop_camera-T",e.L_CALLPLUS_CLIENT_STOP_CAMERA_R="L-callplus_client_stop_camera-R",e.L_CALLPLUS_CLIENT_SWITCH_CAMERA_T="L-callplus_client_switch_camera-T",e.L_CALLPLUS_CLIENT_SWITCH_CAMERA_R="L-callplus_client_switch_camera-R",e.L_CALLPLUS_CLIENT_START_MICROPHONE_T="L-callplus_client_start_microphone-T",e.L_CALLPLUS_CLIENT_START_MICROPHONE_R="L-callplus_client_start_microphone-R",e.L_CALLPLUS_CLIENT_STOP_MICROPHONE_T="L-callplus_client_stop_microphone-T",e.L_CALLPLUS_CLIENT_STOP_MICROPHONE_R="L-callplus_client_stop_microphone-R",e.L_CALLPLUS_CLIENT_SWITCH_MICROPHONE_T="L-callplus_client_switch_microphone-T",e.L_CALLPLUS_CLIENT_SWITCH_MICROPHONE_R="L-callplus_client_switch_microphone-R",e.L_CALLPLUS_CLIENT_SET_VIDEO_VIEW_T="L-callplus_client_set_video_view-T",e.L_CALLPLUS_CLIENT_SET_VIDEO_VIEW_R="L-callplus_client_set_video_view-R",e.L_RTC_MODULE_SET_VIDEO_VIEW_O="L-rtc_module_set_video_view-O",e.L_CALLPLUS_CLIENT_REMOVE_VIDEO_VIEW_T="L-callplus_client_remove_video_view-T",e.L_CALLPLUS_CLIENT_REMOVE_VIDEO_VIEW_R="L-callplus_client_remove_video_view-R",e.L_RTC_MODULE_REMOVE_VIDEO_VIEW_O="L-rtc_module_remove_video_view-O",e.L_CALLPLUS_CLIENT_PLAY_MEDIA_T="L-callplus_client_play_media-T",e.L_CALLPLUS_CLIENT_PLAY_MEDIA_R="L-callplus_client_play_media-R",e.L_RTC_MODULE_PLAY_MEDIA_T="L-rtc_module_play_media-T",e.L_RTC_MODULE_PLAY_MEDIA_R="L-rtc_module_play_media-R",e.L_RTC_MODULE_SET_ALL_REMOTE_AUDIO_ENABLE_T="L-rtc_module_set_all_remote_audio_enbale-T",e.L_RTC_MODULE_SET_ALL_REMOTE_AUDIO_ENABLE_R="L-rtc_module_set_all_remote_audio_enable-R",e.L_RTC_MODULE_SUBSCRIBE_T="L-rtc_module_subscribe-T",e.L_RTC_MODULE_SUBSCRIBE_R="L-rtc_module_subscribe-R",e.L_RTC_MODULE_UNSUBSCRIBE_T="L-rtc_module_unsubscribe-T",e.L_RTC_MODULE_UNSUBSCRIBE_R="L-rtc_module_unsubscribe-R",e.L_RTC_MODULE_PUBLISH_T="L-rtc_module_publish-T",e.L_RTC_MODULE_PUBLISH_R="L-rtc_module_publish-R",e.L_RTC_MODULE_UNPUBLISH_T="L-rtc_module_unpublish-T",e.L_RTC_MODULE_UNPUBLISH_R="L-rtc_module_unpublish-R",e.L_RTC_MODULE_DESTROY_ALL_TRACKS_O="L-rtc_module_destroy_all_tracks-O",e.L_RTC_MODULE_SESSION_CONNECT_T="L-rtc_module_session_connect-T",e.L_RTC_MODULE_SESSION_CONNECT_P="L-rtc_module_session_connect-P",e.L_RTC_MODULE_SESSION_CONNECT_R="L-rtc_module_session_connect-R",e.L_RTC_MODULE_SESSION_CLOSE_T="L-rtc_module_session_close-T",e.L_RTC_MODULE_SESSION_CLOSE_P="L-rtc_module_session_close-P",e.L_RTC_MODULE_SESSION_CLOSE_R="L-rtc_module_session_close-R",e.L_RTC_MODULE_CREATE_VIDEO_TRACK_T="L-rtc_module_create_video_track-T",e.L_RTC_MODULE_CREATE_VIDEO_TRACK_R="L-rtc_module_create_video_track-R",e.L_RTC_MODULE_CREATE_AUDIO_TRACK_T="L-rtc_module_create_audio_track-T",e.L_RTC_MODULE_CREATE_AUDIO_TRACK_R="L-rtc_module_create_audio_track-R",e.L_RTC_MODULE_RECEIVE_TRACK_PUBLISH_O="L-rtc_module_receive_track_publish-O",e.L_RTC_MODULE_RECEIVE_TRACK_UNPUBLISH_O="L-rtc_module_receive_track_unpublish-O",e.L_RTC_MODULE_RECEIVE_TRACK_ENABLE_CHANGE_O="L-rtc_module_receive_track_enable_change-O",e.L_RTC_MODULE_RECEIVE_KICK_OFF_O="L-rtc_module_receive_kick_off-O",e.L_RTC_MODULE_RECEIVE_PEERCONNECTION_EXCEPT_CLOSE_O="L-rtc_module_receive_peerconnection_except_close-O",e.L_RTC_MODULE_CHANGE_MEDIA_TYPE_T="L-rtc_module_change_media_type-T",e.L_RTC_MODULE_CHANGE_MEDIA_TYPE_R="L-rtc_module_change_media_type-R",e.L_RTC_MODULE_JOIN_RTC_ROOM_T="L-rtc_module_join_rtc_room-T",e.L_RTC_MODULE_JOIN_RTC_ROOM_R="L-rtc_module_join_rtc_room-R",e.L_RTC_MODULE_QUIT_RTC_ROOM_T="L-rtc_module_quit_rtc_room-T",e.L_RTC_MODULE_QUIT_RTC_ROOM_R="L-rtc_module_quit_rtc_room-R",e.L_RTC_MODULE_CREATE_CALL_MEDIA_TRACKS_P="L-rtc_module_create_call_media_tracks-P",e.L_SIGNAL_TRANSPORTER_SINGLE_CALL_T="L-signal_transporter_single_call-T",e.L_SIGNAL_TRANSPORTER_GROUP_CALL_T="L-signal_transporter_group_call-T",e.L_SIGNAL_TRANSPORTER_INVITE_T="L-signal_transporter_invite-T",e.L_SIGNAL_TRANSPORTER_RING_T="L-signal_transporter_ring-T",e.L_SIGNAL_TRANSPORTER_ACCEPT_T="L-signal_transporter_accept-T",e.L_SIGNAL_TRANSPORTER_ACCEPT_R="L-signal_transporter_accept-R",e.L_SIGNAL_TRANSPORTER_JOIN_CALL_T="L-signal_transporter_join_call-T",e.L_SIGNAL_TRANSPORTER_HANGUP_T="L-signal_transporter_hangup-T",e.L_SIGNAL_TRANSPORTER_CALL_STATUS_UP_T="L-signal_transporter_call_status_up-T",e.L_SIGNAL_TRANSPORTER_CALL_EVENT_UP_T="L-signal_transporter_call_event_up-T",e.L_SIGNAL_TRANSPORTER_CALL_DIALOG_UP_T="L-signal_transporter_call_dialog_up-T",e.L_SIGNAL_TRANSPORTER_DELETE_CALL_RECORD_T="L-signal_transporter_delete_call_record-T",e.L_SIGNAL_TRANSPORTER_GET_CALL_RECORD_T="L-signal_transporter_get_call_record-T",e.L_SIGNAL_TRANSPORTER_GET_CALL_SERVER_TIME_T="L-signal_transporter_get_call_server_time-T",e.L_SIGNAL_TRANSPORTER_GET_CALL_TIME_INFO_T="L-signal_transporter_get_call_time_info-T",e.L_SIGNAL_TRANSPORTER_GET_AVAILABLE_CALL_LIST_T="L-signal_transporter_get_available_call_list-T",e.L_SIGNAL_TRANSPORTER_CLEAR_CALL_RECORD_T="L-signal_transporter_clear_call_record-T",e.L_SIGNAL_TRANSPORTER_GET_CALL_INFO_BY_CALLID_T="L-signal_transporter_get_call_info_by_callId-T",e.L_SIGNAL_TRANSPORTER_USER_SYSTEM_STATE_UP_T="L-signal_transporter_user_system_state_up-T",e.L_SIGNAL_TRANSPORTER_RECEIVE_CALL_SIGNAL_DATA_O="L-signal_transporter_receive_call_signal_data-O",e.L_SIGNAL_TRANSPORTER_IM_STATE_CHANGE_O="L-signal_transporter_im_state_change-O",e.L_SIGNAL_TRANSPORTER_RECEIVE_INVITE_O="L-signal_transporter_receive_invite-O",e.L_SIGNAL_TRANSPORTER_RECEIVE_CALL_STATUS_O="L-signal_transporter_receive_call_status-O",e.L_SIGNAL_TRANSPORTER_RECEIVE_MISS_MESSAGE_O="L-signal_transporter_receive_miss_message-O",e.L_CALL_ENGINE_UPDATE_USERS_STATE_O="L-call_engine_update_users_state-O",e.L_CALL_ENGINE_IM_STATE_CHANGE_O="L-call_engine_im_state_change-O",e.L_CALL_ENGINE_CALL_TIMEOUT_O="L-call_engine_call_timeout-O",e.L_CALL_ENGINE_START_CALL_TIMER_O="L-call_engine_start_call_timer-O",e.L_CALL_ENGINE_STOP_CALL_TIMER_O="L-call_engine_stop_call_timer-O",e.L_CALL_ENGINE_UP_ON_PHONE_END_T="L-call_engine_up_on_phone_end-T",e.L_CALL_ENGINE_UP_ON_PHONE_END_R="L-call_engine_up_on_phone_end-R",e.L_CALL_ENGINE_RECEIVE_FIRST_FRAME_TIME_O="L-call_engine_receive_first_frame_time-O",e.L_CALL_ENGINE_RECEIVE_MEDIATYPE_CHANGE_O="L-call_engine_receive_mediatype_change-O",e.L_CALL_ENGINE_RECEIVE_CLOSE_SESSION_O="L-call_engine_receive_close_session-O",e.L_CALL_ENGINE_RECEIVE_CALL_RECORD_O="L-call_engine_receive_call_record-O",e.L_CALL_ENGINE_RECEIVE_COMPLEMENTARY_DATA_O="L-call_engine_receive_complementary_data-O",e.L_CALL_ENGINE_CREATE_SESSION_BY_SERVER_T="L-call_engine_create_session_by_server-T",e.L_CALL_ENGINE_CREATE_SESSION_BY_SERVER_R="L-call_engine_create_session_by_server-R",e.L_CALL_ENGINE_UP_FIRST_FRAME_TIME_T="L-call_engine_up_first_frame_time-T",e.L_CALL_ENGINE_UP_FIRST_FRAME_TIME_R="L-call_engine_up_first_frame_time-R",e.L_TIME_CORRECT_START_O="L-time_correct_start-O",e.L_TIME_CORRECT_STOP_O="L-time_correct_stop-O",e.L_TIME_CORRECT_RESTART_O="L-time_correct_restart-O",e.L_TIME_CORRECT_GET_CALL_CLIENT_TIME_BY_SERVER_T="L-time_correct_get_call_client_time_by_server-T",e.L_TIME_CORRECT_GET_CALL_CLIENT_TIME_BY_SERVER_P="L-time_correct_get_call_client_time_by_server-P",e.L_TIME_CORRECT_GET_CALL_CLIENT_TIME_BY_SERVER_R="L-time_correct_get_call_client_time_by_server-R",e.L_TIME_CORRECT_CALC_CLIENT_START_TIME_T="L-time_correct_calc_client_start_time-T",e.L_TIME_CORRECT_CALC_CLIENT_START_TIME_R="L-time_correct_calc_client_start_time-R",e.L_TIME_CORRECT_SET_DELTA_TIME_O="L-time_correct_set_delta_time-O",e.L_TIME_CORRECT_LOOP_CORRECT_CLINET_TIME_T="L-time_correct_loop_correct_client_time-T",e.L_TIME_CORRECT_LOOP_CORRECT_CLINET_TIME_R="L-time_correct_loop_correct_client_time-R",e.L_INNER_SESSION_UPDATE_USER_STATE_O="L-inner_session_update_user_state-O",e.L_INNER_SESSION_SET_USER_DEVICE_ENABLE_O="L-inner_session_set_user_device_enable-O",e.L_CALLPLUS_SESSION_GET_CREATE_TIME_T="L-callplus_session_get_create_time-T",e.L_CALLPLUS_SESSION_GET_CREATE_TIME_R="L-callplus_session_get_create_time-R",e.L_CALLPLUS_SESSION_GET_DURATION_T="L-callplus_session_get_duration-T",e.L_CALLPLUS_SESSION_GET_DURATION_R="L-callplus_session_get_duration-R",e.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O="L-callplus_set_android_push_config-O",e.L_ABNORMAL_ADD_CALL_ID_E="L-ABNORMAL_ADD_CALL_ID-E",e.L_ABNORMAL_REMOVE_CALL_IDS_E="L-ABNORMAL_REMOVE_CALL_IDS-E",e.L_ABNORMAL_GET_CALL_IDS_E="L-ABNORMAL_GET_CALL_IDS-E",e.L_CALLPLUS_CLIENT_SET_AUDIO_OUTPUT_DEVICE_ID_O="L-set_audio_output_device_id-O"}(u_||(u_={})),function(e){e[e.AUDIO=0]="AUDIO",e[e.AUDIO_VIDEO=1]="AUDIO_VIDEO",e[e.VIDEO=2]="VIDEO"}(h_||(h_={}));class m_{constructor(e,t,i,r,n){Object.defineProperty(this,"_session",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_callEngine",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_rtcModule",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"_startTime",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_duration",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_callId",{enumerable:!0,configurable:!0,writable:!0,value:""}),this._callId=this._session.getCallId()}getCallId(){return this._callId}getState(){return this._session.getSessionState()}getCallType(){return this._session.getCallType()}getMediaType(){return this._session.getMediaType()}getUserList(){return this._session.getUserList().map((e=>{const{userId:t,userState:i}=e;let r=null,n=null;return t===this._context.getCurrentId()?(r=this._rtcModule.getLocalVideoTrack(),n=this._rtcModule.getLocalAudioTrack()):(r=this._rtcModule.getRemoteTrack(t,h_.VIDEO),n=this._rtcModule.getRemoteTrack(t,h_.AUDIO)),{userId:t,state:i,cameraEnable:!!r&&!r.isOwnerMuted(),microphoneEnable:!!n&&!n.isOwnerMuted()}}))}getCreatorUserId(){return this._session.getStartCallerId()}getInviterUserId(){return this._session.getCallerId()}getCreateTimestamp(){return m(this,void 0,void 0,(function*(){const e=this._logger.createTraceId();if(this._logger.info(u_.L_CALLPLUS_SESSION_GET_CREATE_TIME_T,"",e),this._startTime)return{code:Zl,startTime:this._startTime};const{code:t,clientStartTime:i}=yield this._callEngine.getCallStaringTime({callId:this._callId},e);return t!==Zl?(this._logger.error(u_.L_CALLPLUS_SESSION_GET_CREATE_TIME_R,`errCode: ${t}`,e),{code:t}):(this._logger.info(u_.L_CALLPLUS_SESSION_GET_CREATE_TIME_R,"success",e),this._startTime=i,{code:Zl,startTime:this._startTime})}))}getDuration(){return m(this,void 0,void 0,(function*(){const e=this._logger.createTraceId();if(this._logger.info(u_.L_CALLPLUS_SESSION_GET_DURATION_T,"",e),this._duration)return this._logger.info(u_.L_CALLPLUS_SESSION_GET_DURATION_R,`code: ${Zl}, duration: ${this._duration}`,e),{code:Zl,duration:this._duration};const{code:t,data:i}=yield this._callEngine.getCallTimeInfo(this._callId,e);return t!==Zl?(this._logger.error(u_.L_CALLPLUS_SESSION_GET_DURATION_R,`code: ${t}`,e),{code:t}):(this._logger.info(u_.L_CALLPLUS_SESSION_GET_DURATION_R,`code: ${Zl}, duration: ${i.duration}`,e),this._duration=i.duration,{code:Zl,duration:this._duration})}))}}!function(e){e[e.SINGLE=0]="SINGLE",e[e.MULTI=1]="MULTI"}(g_||(g_={})),function(e){e[e.IDLE=0]="IDLE",e[e.CALLING=100]="CALLING",e[e.INVITED=101]="INVITED",e[e.RINGING=102]="RINGING",e[e.BUSYLINE_RINGING=103]="BUSYLINE_RINGING",e[e.BUSYLINE_WAIT=104]="BUSYLINE_WAIT",e[e.CONNECTING=200]="CONNECTING",e[e.ONCALL=300]="ONCALL",e[e.ONPHONE=301]="ONPHONE",e[e.ENDED=1e3]="ENDED",e[e.NO_ANSWER=1001]="NO_ANSWER",e[e.MISSED=1002]="MISSED",e[e.CANCELLED=1003]="CANCELLED",e[e.DECLINED=1004]="DECLINED",e[e.ERROR=2e3]="ERROR"}(p_||(p_={})),function(e){e[e.IDLE=0]="IDLE",e[e.CALLING=100]="CALLING",e[e.INVITED=101]="INVITED",e[e.RINGING=102]="RINGING",e[e.BUSYLINE_RINGING=103]="BUSYLINE_RINGING",e[e.BUSYLINE_WAIT=104]="BUSYLINE_WAIT",e[e.CONNECTING=200]="CONNECTING",e[e.ONCALL=300]="ONCALL",e[e.ENDED=1e3]="ENDED",e[e.NOANSWER=1001]="NOANSWER",e[e.MISSED=1002]="MISSED",e[e.CANCELED=1003]="CANCELED",e[e.DECLINED=1004]="DECLINED",e[e.ERROR=2e3]="ERROR"}(f_||(f_={})),function(e){e[e.CANCEL_CHANGE_MEDIA_TYPE=0]="CANCEL_CHANGE_MEDIA_TYPE",e[e.REFUSE_CHANGE_MEDIA_TYPE=1]="REFUSE_CHANGE_MEDIA_TYPE",e[e.SERVER_ALLOW_MEDIA_TYPE=2]="SERVER_ALLOW_MEDIA_TYPE",e[e.CHANGE_MEDIA_TYPE_TIMEOUT=3]="CHANGE_MEDIA_TYPE_TIMEOUT"}(E_||(E_={})),function(e){e[e.IDLE=0]="IDLE",e[e.CALLING=100]="CALLING",e[e.INVITED=101]="INVITED",e[e.RINGING=102]="RINGING",e[e.BUSYLINE_RINGING=103]="BUSYLINE_RINGING",e[e.BUSYLINE_WAIT=104]="BUSYLINE_WAIT",e[e.CONNECTING=200]="CONNECTING",e[e.ONCALL=300]="ONCALL",e[e.ON_PHONE=301]="ON_PHONE",e[e.ON_PHONE_END=302]="ON_PHONE_END",e[e.ON_DEVICE_DISABLE=303]="ON_DEVICE_DISABLE",e[e.ON_DEVICE_ENABLE=304]="ON_DEVICE_ENABLE",e[e.ABNORMAL_END=999]="ABNORMAL_END",e[e.ENDED=1e3]="ENDED",e[e.NO_ANSWER=1001]="NO_ANSWER",e[e.MISSED=1002]="MISSED",e[e.CANCELLED=1003]="CANCELLED",e[e.DECLINED=1004]="DECLINED",e[e.OTHER_CLIENT_CALLING=1010]="OTHER_CLIENT_CALLING",e[e.OTHER_CLIENT_ACCEPT=1011]="OTHER_CLIENT_ACCEPT",e[e.JOIN_ROOM_ERR=1105]="JOIN_ROOM_ERR",e[e.PUBLISH_ERR=1106]="PUBLISH_ERR",e[e.SUBSCRIBE_ERR=1107]="SUBSCRIBE_ERR",e[e.ACCEPT_CARRIER=1108]="ACCEPT_CARRIER",e[e.KICKED_BY_SERVER=1109]="KICKED_BY_SERVER",e[e.CONNECTION_ERR=1110]="CONNECTION_ERR",e[e.LOGOUT=1111]="LOGOUT",e[e.OTHER_CLIENT_LOGIN=1112]="OTHER_CLIENT_LOGIN",e[e.OTHER_CLIENT_JOINED=1113]="OTHER_CLIENT_JOINED",e[e.OTHER_CLIENT_IN_ROOM=1114]="OTHER_CLIENT_IN_ROOM",e[e.OTHER_CLIENT_HANGUP=1151]="OTHER_CLIENT_HANGUP",e[e.REMOTE_JOIN_RTC_ERROR=1205]="REMOTE_JOIN_RTC_ERROR",e[e.REMOTE_PUBLISH_ERROR=1206]="REMOTE_PUBLISH_ERROR",e[e.REMOTE_SUBSCRIBE_ERROR=1207]="REMOTE_SUBSCRIBE_ERROR",e[e.REMOTE_KICKED_BY_SERVER=1209]="REMOTE_KICKED_BY_SERVER",e[e.REMOTE_CONNECTION_ERROR=1210]="REMOTE_CONNECTION_ERROR",e[e.REMOTE_LOGOUT=1211]="REMOTE_LOGOUT",e[e.REMOTE_OTHER_CLIENT_LOGIN=1212]="REMOTE_OTHER_CLIENT_LOGIN",e[e.REMOTE_OTHER_JOINED_RTC=1213]="REMOTE_OTHER_JOINED_RTC",e[e.REMOTE_OTHER_CLIENT_IN_RTC=1214]="REMOTE_OTHER_CLIENT_IN_RTC"}(I_||(I_={})),function(e){e[e.START=1]="START",e[e.END=2]="END"}(T_||(T_={}));class R_{constructor(e){Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_audioConfig",{enumerable:!0,configurable:!0,writable:!0,value:{}})}setDefaultMicrophoneId(e){return this._audioConfig.microphoneId=e,this}setBitrate(e,t){return!O(e)||!O(t)||t<=0||e<=0||t<e?(this._logger.error(u_.L_CALLPLUS_AUDIO_CONFIG_SET_BITRATE_O,`params error -> max: ${t},min: ${e}, max and min is a number > 0, max should > min`),this):(this._audioConfig.minBitrate=e,this._audioConfig.maxBitrate=t,this)}setSampleRate(e){return O(e)?(this._audioConfig.sampleRate=e,this):(this._logger.error(u_.L_CALLPLUS_AUDIO_CONFIG_SET_SAMPLE_RATE_O,`params error -> sampleRate: ${e}`),this)}build(){return this._audioConfig}}class S_{constructor(e){Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_videoConfig",{enumerable:!0,configurable:!0,writable:!0,value:{resolution:Ot.W640_H480,frameRate:Lt.FPS_15}})}setFrameRate(e){return Lt[e]?(this._videoConfig.frameRate=e,this):(this._logger.error(u_.L_CALLPLUS_VIDEO_CONFIG_SET_FRAME_RATE_O,`params error -> fps: ${e}`),this)}setVideoResolution(e){return Ot[e]?(this._videoConfig.resolution=e,this):(this._logger.error(u_.L_CALLPLUS_VIDEO_CONFIG_SET_RESOLUTION_O,`params error -> resolution: ${e}`),this)}setDefaultCameraId(e){return this._videoConfig.cameraId=e,this}setBitrate(e,t){return!O(e)||!O(t)||t<=0||e<=0||t<e?(this._logger.error(u_.L_CALLPLUS_VIDEO_CONFIG_SET_BITRATE_O,`params error -> max: ${t},min: ${e}, max and min is a number > 0, max should > min`),this):(this._videoConfig.minBitrate=e,this._videoConfig.maxBitrate=t,this)}build(){return this._videoConfig}}const C_=e=>{const{callId:t,callType:i,callDir:r,mediaType:n,callingUserId:s,callUserIds:o,callStatus:a,sessionStatus:l,startTime:_,endTime:c,duration:d,syncTime:u,sysStatus:h,crtTime:g}=e;return{callId:t,callType:i,callDirection:r,mediaType:n,callerUserId:s,callUserIds:o,sessionState:a,userState:l,startTimestamp:_,endTimestamp:c,duration:d,syncTimestamp:u,systemState:h,createTimestamp:g}},L_=e=>{const{voipCallInfo:t}=e;if(!t)return!1;const{strategy:i}=JSON.parse(t);return 1===i},O_=(e,t)=>!e&&0!==e||O(e)&&!(e<=0)?!t&&0!==t||O(t)&&!(t<=0)?e&&t&&t<e?{code:Xl,errorMsg:`params error -> maxBitrate: ${t}, minBitrate: ${e}, maxBitrate should > minBitrate`}:{code:Zl}:{code:Xl,errorMsg:`params error -> maxBitrate: a number of > 0, value: ${t}`}:{code:Xl,errorMsg:`params error -> minBitrate: a number of > 0, value: ${e}`},v_=e=>{const t=[];for(const i in e){const{videoView:r,isTiny:n}=e[i];t.push({userId:i,videoView:r.nodeName,isTiny:n})}return t},b_=(e,t={},i={})=>{const{threadId:r,apnsCollapseId:n,richMediaUri:s}=t,{channelIdMi:o,channelIdHW:a,channelIdOPPO:l,typeVivo:_,fcmChannelId:c,fcmCollapseKey:d,fcmImageUrl:u,importanceHW:h,categoryHW:g,imageUrlHW:p,categoryVivo:f,importanceHonor:E,imageUrlHonor:I}=i,T={};r&&(T["thread-id"]=r),T["apns-collapse-id"]=n||e,s&&(T.richMediaUri=s);const m={};a&&(m.channelId=a),p&&(m.image=p),g&&(m.category=g),m.importance=h||"NORMAL";const R=[{HW:m},{APNS:T}];let S,C,L,O;return(d||u||c)&&(S={},d&&(S.collapse_key=d),u&&(S.imageUrl=u),c&&(S.channelId=c),R[0].FCM=S),o&&(R[0].MI={channelId:o}),l&&(C={},C.channelId=l,R[0].OPPO=C),(_||f)&&(L={},_&&(L.classification=_),f&&(L.category=f),R[0].VIVO=L),(E||I)&&(O={},E&&(O.importance=E),I&&(O.image=I),R[0].HONOR=O),JSON.stringify(R)},A_=(e,t)=>{const{pushTitle:i="",iOSConfig:r,androidConfig:n,disablePushTitle:s,templateId:o}=e,a={pushConfigs:b_(t,r,n)};return L(s)&&(a.disableTitle=s),i&&(a.title=i),o&&(a.templateId=o),JSON.stringify(a)},N_=e=>{const t=["pushTitle","pushContent","iOSConfig","androidConfig","disablePushTitle","templateId"];if(!Object.keys(e).every((e=>t.includes(e))))return{code:Xl,errorMsg:`right key: ${t.join(",")}`};for(let i=0;i<t.length;i++){const r=t[i];if("disablePushTitle"===r){if(!P(e[r])&&!L(e[r]))return{code:Xl,errorMsg:`${r} type is boolean`}}else if(("pushTitle"===r||"templateId"===r||"pushContent"===r)&&e[r]&&!C(e[r]))return{code:Xl,errorMsg:`${r} type is string`}}const{iOSConfig:i,androidConfig:r}=e,n=y_(i||{});if(n.code!==Zl)return n;const s=P_(r||{});return s.code!==Zl?s:{code:Zl}},y_=e=>{const{threadId:t,richMediaUri:i}=e||{};return t&&!C(t)?{code:Xl,errorMsg:"iOSConfig.threadId type is string"}:i&&!C(i)?{code:Xl,errorMsg:"iOSConfig.richMediaUri type is string"}:{code:Zl}},P_=e=>{const t=["channelIdMi","channelIdHW","categoryHW","importanceHW","imageUrlHW","channelIdOPPO","typeVivo","categoryVivo","fcmChannelId","fcmCollapseKey","fcmImageUrl","importanceHonor","imageUrlHonor"];if(!Object.keys(e).every((e=>t.includes(e))))return{code:Xl,errorMsg:`right key: ${t.join(",")}`};for(let i=0;i<t.length;i++){const r=t[i];if("importanceHW"===r||"importanceHonor"===r){if(e[r]&&"LOW"!==e[r]&&"NORMAL"!==e[r])return{code:Xl,errorMsg:`androidConfig.${r} value is NORMAL|LOW`}}else if(e[r]&&!C(e[r]))return{code:Xl,errorMsg:`androidConfig.${r} type is string`}}return{code:Zl}},U_=(e,t="utf-8")=>{let i=0;return i="utf-16"===t?D_(e):M_(e),i},D_=e=>{let t,i=0;for(let r=0,n=e.length;r<n;r++)t=e.charCodeAt(r),i+=t<=65535?2:4;return i},M_=e=>{let t,i=0;for(let r=0,n=e.length;r<n;r++)t=e.charCodeAt(r),i+=t<127?1:t<=2047?2:t<=65535?3:4;return i},w_=/Electron/.test(navigator.userAgent);var k_,x_,B_,V_,G_,F_;!function(e){e.L_QS_START_CALL_S="Call-start-S",e.L_QS_ACCEPT_CALL_S="Call-accept-S",e.L_QS_HANGUP_CALL_S="Call-hangup-S",e.L_QS_RECEIVE_CALL_S="Call-recv-S",e.L_QS_ABNORMAL_HANGUP_S="Call-interrupt-S"}(k_||(k_={}));class j_{constructor(e){Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._logger=this._context.logger}reportStatisticsData(e,t,i,r,n,s,o){const a=+new Date,{mediaType:l,callType:_,callId:c}=r?{mediaType:r.getMediaType(),callType:r.getCallType(),callId:r.getCallId()}:o,d={cr:"unknown",net:"unknown",cod:t,mtp:l,ctp:_,cid:c,time:a,uid:this._context.getCurrentId()};n&&Object.assign(d,{ccid:n});let u=null;switch(e){case k_.L_QS_RECEIVE_CALL_S:u=Object.assign(Object.assign({},d),{rf:s});break;case k_.L_QS_ABNORMAL_HANGUP_S:u=Object.assign({},d);break;default:u=Object.assign(Object.assign({},d),{dur:a-i})}this._logger.__statistics(e,JSON.stringify(u))}}!function(e){e.REQUEST="request",e.ACCEPT="accept",e.REFUSE="refuse",e.CANCEL="cancel",e.NOTICE="notice",e.TIMEOUT="timeout"}(x_||(x_={})),function(e){e[e.SWITCH_MEDIA_TYPE=1]="SWITCH_MEDIA_TYPE"}(B_||(B_={})),function(e){e[e.NORMAL=0]="NORMAL",e[e.SECRET=1]="SECRET"}(V_||(V_={})),function(e){e.INVITER="inviter",e.INVITEE="invitee"}(G_||(G_={}));class H_ extends B{constructor(e,t,i,r,n,s,o,a){super(),Object.defineProperty(this,"_callId",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_state",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_callType",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_mediaType",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_startCallerId",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"_callerId",{enumerable:!0,configurable:!0,writable:!0,value:s}),Object.defineProperty(this,"_callUsers",{enumerable:!0,configurable:!0,writable:!0,value:o}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:a}),Object.defineProperty(this,"_reqMediaType",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_inviterTimerId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_inviteeTimerId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_oldDialogData",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"isLocalClientHangup",{enumerable:!0,configurable:!0,writable:!0,value:!1})}getCallId(){return this._callId}getSessionState(){return this._state}getCallType(){return this._callType}getMediaType(){return this._mediaType}getStartCallerId(){return this._startCallerId}getCallerId(){return this._callerId}getUserList(){return this._callUsers}getReqMediaType(){return this._reqMediaType}getInviterTimerId(){return this._inviterTimerId}getInviteeTimerId(){return this._inviteeTimerId}getAllTimerIds(){return[this._inviterTimerId,this._inviteeTimerId]}updateUserList(e,t){const i=[];return e.forEach((e=>{const{userState:t,stateTime:r,systemState:n,userId:s}=e,o=this._callUsers.findIndex((e=>e.userId===s));if(o<0)return this._callUsers.push(e),void i.push(e);const{stateTime:a,systemState:l,userState:_}=this._callUsers[o],c=((e,t)=>{let i=!1;const r=[I_.INVITED,I_.RINGING,I_.BUSYLINE_RINGING,I_.BUSYLINE_WAIT,I_.CONNECTING,I_.ONCALL];return e===I_.ONCALL&&r.includes(t)&&(i=!0),i})(l,n),d=((e,t)=>{let i=!1;const r=[p_.INVITED,p_.RINGING,p_.BUSYLINE_RINGING,p_.BUSYLINE_WAIT,p_.CONNECTING,p_.ONCALL];return e===p_.ONCALL&&r.includes(t)&&(i=!0),i})(_,t),u=n===I_.ON_PHONE_END&&l!==I_.ON_PHONE&&t!==p_.IDLE;r&&a&&r<a||c&&d||(this._callUsers[o]=e,!u&&i.push(e))})),i}setOldDialogData(e){this._oldDialogData=e}updateSessionState(e){this._state=e}updateCallType(e){this._callType=e}updateMediaType(e){this._mediaType=e}updateReqMediaType(e){this._reqMediaType=e}updateTimerId(e,t){e===G_.INVITER?this._inviterTimerId=t:this._inviteeTimerId=t}getOldDialogData(){return this._oldDialogData}setIsLocalClientHangup(e){this.isLocalClientHangup=e}getIsLocalClientHangup(){return this.isLocalClientHangup}}!function(e){e.START_SINGLE_CALL="startSingleCall",e.START_GROUP_CALL="startGroupCall",e.INVITE_CALL="inviteCall",e.PUB_INVITE_CALL="pubInviteCall",e.RINGING_CALL="ringCall",e.ACCEPT_CALL="acceptCall",e.JOIN_CALL="joinCall",e.HANGUP_CALL="hangupCall",e.STATUS_UP_CALL="statusUpCall",e.STATUS_DOWN_CALL="statusDownCall",e.EVENT_UP_CALL="eventUpCall",e.EVENT_DOWN_CALL="eventDownCall",e.DIALOG_UP_CALL="dialogUpCall",e.DIALOG_DOWN_CALL="dialogDownCall",e.GET_CALL_USER_SESSION_LIST="getCallUSerSessionList",e.SYNC_CALL_LOG="syncCallLog",e.PUB_CALL_LOG="pubCallLog",e.DEL_CALL_LOG="deleteCallLog",e.QRY_CALL_STATE="queryUserHasCall",e.QRY_SRV_TIMESTAMP="getCallSrvTimeStamp",e.GET_CALL_STATE_LIST="getUserCallStateList",e.CLEAR_CALL_LOG="cleanCallLog",e.GET_CALL_SESSION="getCallSession",e.GET_CALL_TIME_INFO="getCallTimeInfo",e.END_ABNORMAL_CALL="endUserAbnormalCalls",e.SYS_STATUS_UP="sysStatusUp",e.UP_CALL_LOG_READED="upCallLogReaded",e.PUB_CALL_LOG_READED="pubCallLogReaded",e.PUB_NACK_SEQ_ID="pubNACKSeqId",e.GET_USER_CALL_SESSION_ID_LIST="getUserCallSessionIdList"}(F_||(F_={}));const J_=(e,t)=>setTimeout(e,t),$_=[oe.RC_NET_CHANNEL_INVALID,oe.RC_NET_UNAVAILABLE,oe.RC_MSG_RESP_TIMEOUT,ae.SIGNAL_DISCONNECTED,ae.REQUEST_FAILED],K_=e=>m(void 0,[e],void 0,(function*({asyncFn:e,fnArgs:t,currentRetryTime:i=Date.now(),maxDuration:r=6e4,intervals:n=[2e3,4e3,8e3,16e3,32e3,64e3],index:s=0,onError:o}){const a=yield e(...t);return a.code===Zl||!$_.includes(a.code)||Date.now()+2e3-i>r?a:(o&&o(a.code),yield(l=2e3,new Promise((e=>{setTimeout(e,l)}))),K_({asyncFn:e,fnArgs:t,currentRetryTime:i,maxDuration:r,intervals:n,index:s,onError:o}));var l}));var Y_,q_,W_;!function(e){e.onBeforePublish="onBeforePublish",e.onPublishRes="onPublishRes",e.onPubInviteCall="onPubInviteCall",e.onPubInviteCallPullKv="onPubInviteCallPullKv",e.onPubInviteCallMiss="onPubInviteCallMiss"}(Y_||(Y_={})),function(e){e.NOT_CURRENT_DEVICEID="not current device id",e.SECRET_CALL="secret call",e.NOT_INVITEE="not an invitee"}(q_||(q_={})),function(e){e.PUB_INVITE="pubinvitecall",e.PULL_KV_INVITE="pullkv_invitecall",e.PUSH="system_pubsh"}(W_||(W_={}));const z_=131072,Q_="RC:CallPlusMiss",Z_="RC:CallGroupStatusMsg";class X_ extends B{constructor(e,t,i,r,n,s){var o,a,l,_,c,d;super(),Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_runtime",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_initOpts",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_timeCorrectioner",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"_reportAppEventModule",{enumerable:!0,configurable:!0,writable:!0,value:s}),Object.defineProperty(this,"_listener",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_needRetryActions",{enumerable:!0,configurable:!0,writable:!0,value:[F_.START_SINGLE_CALL,F_.START_GROUP_CALL,F_.ACCEPT_CALL,F_.JOIN_CALL,F_.EVENT_UP_CALL]}),Object.defineProperty(this,"_sessionId",{enumerable:!0,configurable:!0,writable:!0,value:""}),null===(a=(o=this._context).registerGroupCallSignalInfoListener)||void 0===a||a.call(o,(e=>this._onRecvCallSignal(e))),null===(_=(l=this._context).registerConnectionStateChangeListener)||void 0===_||_.call(l,((e,t)=>this._onIMConnectionStateChange(e))),null===(d=(c=this._context).registerMessageListener)||void 0===d||d.call(c,(e=>this._onMessage(e))),this._sessionId=J.genWithLen(22)}_onMessage(e){return!![Q_,Z_].includes(e.messageType)&&(e.messageType===Q_?this._dealMissMessage(e):this._dealGroupCallMessage(e),!0)}_dealMissMessage(e){const t=e.content,{callId:i,mediaType:r,startTime:s,callSessionUsers:o}=t,{targetId:a,senderUserId:l}=e,_=this._context.getCurrentId();if(!localStorage.getItem(`missMessageMap-${_}-${i}`)){const t={callId:i,callerUserId:l,targetId:a,mediaType:r,firstFrameTime:0,callStartTime:s-this._timeCorrectioner.getLocalDelayTime(),callEndTime:0,hangupReason:o.filter((({userId:e})=>e===_))[0].sessionStatus};this._logger.info(u_.L_SIGNAL_TRANSPORTER_RECEIVE_MISS_MESSAGE_O,`receive miss message: ${JSON.stringify(e)}`);const c=Object.assign(e,{content:t,sentStatus:n.SENT});this._reportAppEventModule.onReceivedCallPlusSummaryMessage(c),localStorage.setItem(`missMessageMap-${_}-${i}`,i)}}_dealGroupCallMessage(e){this._reportAppEventModule.onReceivedGroupCallStatusMessage(e)}getSessionId(){return this._sessionId}getDeviceId(){return w_&&"function"==typeof this._context.getDeviceId?this._context.getDeviceId():this._sessionId}registerListener(e){this._listener=e}startCall(e,t){return m(this,void 0,void 0,(function*(){const{clientCallId:i,callType:r,toUsers:n,mediaType:s,secretChat:o,targetType:a,targetId:l,nickName:_,oldRoomId:c,pushExt:d,pushContent:u,extra:h}=e;return r===g_.SINGLE?this.startSingleCall({clientCallId:i,toUserId:n[0].userId,mediaType:s,secretChat:o,targetType:a,targetId:l,oldRoomId:c,toOrgId:n[0].orgId||"",pushExt:d,pushContent:u,extra:h},t):this.startGroupCall({clientCallId:i,toUsers:n,mediaType:s,targetType:a,targetId:l,nickName:_,oldRoomId:c,pushExt:d,pushContent:u,extra:h},t)}))}startSingleCall(e,t){return m(this,void 0,void 0,(function*(){return this._logger.info(u_.L_SIGNAL_TRANSPORTER_SINGLE_CALL_T,`params: ${JSON.stringify(e)}`,t),this._sendCallSignal(this._context.getCurrentId(),F_.START_SINGLE_CALL,e)}))}startGroupCall(e,t){return m(this,void 0,void 0,(function*(){return this._logger.info(u_.L_SIGNAL_TRANSPORTER_GROUP_CALL_T,`params: ${JSON.stringify(e)}`,t),this._sendCallSignal(this._context.getCurrentId(),F_.START_GROUP_CALL,e)}))}inviteCall(e,t){return m(this,void 0,void 0,(function*(){return this._logger.info(u_.L_SIGNAL_TRANSPORTER_INVITE_T,`params: ${JSON.stringify(e)}`,t),this._sendCallSignal(e.callId,F_.INVITE_CALL,e)}))}ringingCall(e,t){return m(this,void 0,void 0,(function*(){return this._logger.info(u_.L_SIGNAL_TRANSPORTER_RING_T,`params: ${JSON.stringify(e)}`,t),this._sendCallSignal(e.callId,F_.RINGING_CALL,e)}))}acceptCall(e,t){return m(this,void 0,void 0,(function*(){return this._logger.info(u_.L_SIGNAL_TRANSPORTER_ACCEPT_T,`params: ${JSON.stringify(e)}`,t),this._sendCallSignal(e.callId,F_.ACCEPT_CALL,e)}))}joinCall(e,t){return m(this,void 0,void 0,(function*(){return this._logger.info(u_.L_SIGNAL_TRANSPORTER_JOIN_CALL_T,`params: ${JSON.stringify(e)}`,t),this._sendCallSignal(e.callId,F_.JOIN_CALL,e)}))}hangupCall(e,t){return m(this,void 0,void 0,(function*(){this._logger.info(u_.L_SIGNAL_TRANSPORTER_HANGUP_T,`params: ${JSON.stringify(e)}`,t);const{code:i}=yield this._sendCallSignal(e.callId,F_.HANGUP_CALL,e);return i===t_?{code:Zl}:{code:i}}))}statusUpCall(e,t){return m(this,void 0,void 0,(function*(){return this._logger.info(u_.L_SIGNAL_TRANSPORTER_CALL_STATUS_UP_T,`call status up params: ${JSON.stringify(e)}`,t),this._sendCallSignal(e.callId,F_.STATUS_UP_CALL,e)}))}eventUpCall(e,t){return m(this,void 0,void 0,(function*(){return this._logger.info(u_.L_SIGNAL_TRANSPORTER_CALL_EVENT_UP_T,`params: ${JSON.stringify(e)}`,t),this._sendCallSignal(e.callId,F_.EVENT_UP_CALL,e)}))}dialogUpCall(e,t){return m(this,void 0,void 0,(function*(){return this._logger.info(u_.L_SIGNAL_TRANSPORTER_CALL_DIALOG_UP_T,`params: ${JSON.stringify(e)}`,t),this._sendCallSignal(e.callId,F_.DIALOG_UP_CALL,e)}))}deleteCallRecord(e,t,i){return m(this,void 0,void 0,(function*(){return this._logger.info(u_.L_SIGNAL_TRANSPORTER_DELETE_CALL_RECORD_T,`callIds: ${JSON.stringify(t)}`,i),this._sendCallSignal(e,F_.DEL_CALL_LOG,{callIds:t})}))}syncCallLog(e,t){return m(this,void 0,void 0,(function*(){return this._logger.info(u_.L_SIGNAL_TRANSPORTER_GET_CALL_RECORD_T,`params: ${JSON.stringify(e)}`,t),this._sendCallSignal(e.userId,F_.SYNC_CALL_LOG,e)}))}queryUserHasCall(){return m(this,void 0,void 0,(function*(){const e=this._context.getCurrentId();return this._sendCallSignal(e,F_.QRY_CALL_STATE,null)}))}getCallServerTimestamp(e){return m(this,void 0,void 0,(function*(){const t=this._context.getCurrentId();return this._logger.info(u_.L_SIGNAL_TRANSPORTER_GET_CALL_SERVER_TIME_T,`userId: ${t}`,e),this._sendCallSignal(t,F_.QRY_SRV_TIMESTAMP,null)}))}getCallTimeInfo(e,t){return m(this,void 0,void 0,(function*(){return this._logger.info(u_.L_SIGNAL_TRANSPORTER_GET_CALL_TIME_INFO_T,`callId: ${e}`,t),this._sendCallSignal(e,F_.GET_CALL_TIME_INFO,{callId:e})}))}getUserCallStateList(e){return m(this,void 0,void 0,(function*(){const t=this._context.getCurrentId();return this._logger.info(u_.L_SIGNAL_TRANSPORTER_GET_AVAILABLE_CALL_LIST_T,`userId: ${t}`,e),this._sendCallSignal(t,F_.GET_CALL_STATE_LIST,null)}))}clearCallRecord(e){return m(this,void 0,void 0,(function*(){const t=this._context.getCurrentId();return this._logger.info(u_.L_SIGNAL_TRANSPORTER_CLEAR_CALL_RECORD_T,`userId: ${t}`,e),this._sendCallSignal(t,F_.CLEAR_CALL_LOG,null)}))}getCallSession(e,t){return m(this,void 0,void 0,(function*(){return this._logger.info(u_.L_SIGNAL_TRANSPORTER_GET_CALL_INFO_BY_CALLID_T,`callId: ${e.callId}`,t),this._sendCallSignal(e.callId,F_.GET_CALL_SESSION,e)}))}sysStatusUp(e,t){return m(this,void 0,void 0,(function*(){return this._logger.info(u_.L_SIGNAL_TRANSPORTER_USER_SYSTEM_STATE_UP_T,`opts: ${JSON.stringify(e)}`,t),this._sendCallSignal(e.callId,F_.SYS_STATUS_UP,e)}))}upCallLogReaded(e){return m(this,void 0,void 0,(function*(){const t=this._context.getCurrentId();return this._sendCallSignal(t,F_.UP_CALL_LOG_READED,e)}))}endUserAbnormalCalls(e){return m(this,void 0,void 0,(function*(){return this._sendCallSignal(this._context.getCurrentId(),F_.END_ABNORMAL_CALL,e)}))}_onIMConnectionStateChange(e){const t=this._logger.createTraceId();this._logger.info(u_.L_SIGNAL_TRANSPORTER_IM_STATE_CHANGE_O,`state: ${e}`,t),this._listener.onIMStateChange(e),e===l.CONNECTED?this._timeCorrectioner.start(t):this._timeCorrectioner.stop(t)}_sendCallSignal(e,t,i){return m(this,void 0,void 0,(function*(){var r;let n="";i&&(n=w_?JSON.stringify(i):JSON.stringify(Object.assign(Object.assign({},i),{sessionId:this._sessionId})));const s=null===(r=this._context.sendGroupCallSignalInfo)||void 0===r?void 0:r.bind(this._context);if(!s)return{code:o_};let o;if(this._needRetryActions.includes(t))o=yield K_({asyncFn:(e,t,i)=>s(e,t,i).then((e=>({code:e.code,data:e.data}))),fnArgs:[e,t,n]});else{const i=yield s(e,t,n);o={code:i.code,data:i.data}}const{code:a,data:l}=o;if(a!==oe.SUCCESS)return{code:a};const _=null==l?void 0:l.value;if(null==_)return{code:Xl};const c=JSON.parse(_).data;return{code:Zl,data:c}}))}_onRecvCallSignal(e){const t=this._logger.createTraceId();this._logger.info(u_.L_SIGNAL_TRANSPORTER_RECEIVE_CALL_SIGNAL_DATA_O,`data: ${e}`,t);JSON.parse(e).list.forEach((e=>{const{key:i}=e,r=JSON.parse(e.value);switch(i){case F_.PUB_INVITE_CALL:this._onPubInviteCall(r,t,!0);break;case F_.STATUS_DOWN_CALL:this._onStatusDownCall(r,t);break;case F_.EVENT_DOWN_CALL:this._onEventDownCall(r,t);break;case F_.DIALOG_DOWN_CALL:this._onDialogDownCall(r,t);break;case F_.PUB_CALL_LOG:this._onPubCallLog(r,t);break;case F_.PUB_CALL_LOG_READED:case F_.PUB_NACK_SEQ_ID:break;default:this._onConpensationData(r,t)}}))}isValidData(e){if(t=e,"[object Null]"===Object.prototype.toString.call(t))return!0;var t;const i=e===this.getDeviceId();return!(!C(e)||0!==(null==e?void 0:e.length)&&!i)}_onPubInviteCall(e,t,i=!0){try{const i=this._context.getCurrentId(),r=e.callSessionUsers.find((e=>e.userId===i)),n=this._context.getConnectionStatus();this._logger.info(u_.L_SIGNAL_TRANSPORTER_RECEIVE_INVITE_O,`currentUser: ${JSON.stringify(r)}, currentUserId: ${i}, state: ${n}`,t)}catch(e){this._logger.error(u_.L_SIGNAL_TRANSPORTER_RECEIVE_INVITE_O,`error: ${e.message}`,t)}if(this.isValidData(e.toDeviceId||""))this._listener.onInvite(e,i,t),i?this.emit(Y_.onPubInviteCall,Object.assign(e,{extra:JSON.stringify(e)})):this.emit(Y_.onPubInviteCallPullKv,Object.assign(e,{extra:JSON.stringify(e)}));else{this._logger.warn(u_.L_SIGNAL_TRANSPORTER_RECEIVE_INVITE_O,`not current deviceId -> deviceInfo: ${JSON.stringify({toDeviceId:e.toDeviceId,clientDeviceId:this.getDeviceId()})}`,t);const r={extra:JSON.stringify(e),reason:q_.NOT_CURRENT_DEVICEID,refer:i?W_.PUB_INVITE:W_.PULL_KV_INVITE};this.emit(Y_.onPubInviteCallMiss,Object.assign(e,r))}}_onStatusDownCall(e,t){if(e.callSessionUsers=e.callSessionUsers.filter((e=>Boolean(e.changed))),this._logger.info(u_.L_SIGNAL_TRANSPORTER_RECEIVE_CALL_STATUS_O,"",t),!this.isValidData(e.toDeviceId||""))return this._logger.warn(u_.L_SIGNAL_TRANSPORTER_RECEIVE_CALL_STATUS_O,`not current deviceId -> deviceInfo: ${JSON.stringify({toDeviceId:e.toDeviceId,clientDeviceId:this.getDeviceId()})}`,t),void this._listener.onOtherClientStatusDown(e,t);this._listener.onStatusDown(e,t,this._sessionId)}_onEventDownCall(e,t){this._listener.onEventDown(e,t)}_onDialogDownCall(e,t){const{dialogType:i}=e;i===B_.SWITCH_MEDIA_TYPE&&this._listener.onSwitchMediaType(e,t)}_onPubCallLog(e,t){this._logger.info(u_.L_CALL_ENGINE_RECEIVE_CALL_RECORD_O,`call record: ${JSON.stringify(e)}`,t),this._listener.onRecvCallEndLog(e,t)}_onConpensationData(e,t){this._logger.info(u_.L_CALL_ENGINE_RECEIVE_COMPLEMENTARY_DATA_O,"",t);const{callId:i,callType:r,mediaType:n,secretChat:s,duration:o,callStatus:a,callingUserId:l,callSessionUsers:_,toDeviceId:c,callDialogEntitys:d,extra:u}=e;_.some((e=>e.sessionStatus===p_.INVITED&&e.userId===this._context.getCurrentId()))?this._onPubInviteCall({callId:i,toDeviceId:c,callType:r,mediaType:n,inviteUserId:l,callingUserId:l,callSessionUsers:_,secretChat:s,extra:u},t,!0):this._onStatusDownCall({callId:i,toDeviceId:c,callStatus:a,duration:o,callSessionUsers:_},t),d.length>0&&d.forEach((e=>this._onDialogDownCall(e,t)),this)}}const ec=()=>{let e="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(e=>{const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}));return e=`${e.replace(/-/g,"")}0`,e=parseInt(e,16),e=(e=>{const t="0123456789abcdefghigklmnopqrstuvwxyzABCDEFGHIGKLMNOPQRSTUVWXYZ+/".split(""),i=t.length+1;let r=+e;const n=[];do{const e=r%i;r=(r-e)/i,n.unshift(t[e])}while(r);return n.join("")})(e),e.length>22&&(e=e.slice(0,22)),e};class tc{constructor(e,t){Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_localStore",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._localStore=e.localStorage}addAbnormallCallId(e,t){try{const i=JSON.parse(this._localStore.getItem(tc._STORAGE_KEY)||"{}");let r=i[e];r?r.push(t):r=[t],i[e]=r,this._localStore.setItem(tc._STORAGE_KEY,JSON.stringify(i))}catch(e){this._logger.error(u_.L_ABNORMAL_ADD_CALL_ID_E,e.message),console.error(e)}}removeAbnormalCallIds(e,t){try{const i=JSON.parse(this._localStore.getItem(tc._STORAGE_KEY)||"{}");let r=i[e];r&&(r=r.filter((e=>!t.includes(e))),r.length>0?i[e]=r:delete i[e],this._localStore.setItem(tc._STORAGE_KEY,JSON.stringify(i)))}catch(e){this._logger.error(u_.L_ABNORMAL_REMOVE_CALL_IDS_E,e.message),console.error(e)}}getAbnormalCallIds(e){let t=null;try{const i=JSON.parse(this._localStore.getItem(tc._STORAGE_KEY)||"{}")[e];i&&(t=i)}catch(e){this._logger.error(u_.L_ABNORMAL_GET_CALL_IDS_E,e.message),console.error(e)}return Promise.resolve(t)}}var ic,rc,nc,sc,oc;Object.defineProperty(tc,"_STORAGE_KEY",{enumerable:!0,configurable:!0,writable:!0,value:"CallPlus_AbnormalCall"}),function(e){e[e.PROMPT=0]="PROMPT",e[e.CALL_DURATION=10]="CALL_DURATION",e[e.FIRST_FRAME=20]="FIRST_FRAME"}(ic||(ic={})),function(e){e[e.SUCCESS=0]="SUCCESS",e[e.INVALID_RESPONSE_TIME=80170]="INVALID_RESPONSE_TIME",e[e.NONOPTIMAL_RES_TIME=80171]="NONOPTIMAL_RES_TIME"}(rc||(rc={}));class ac{constructor(e,t,i){Object.defineProperty(this,"_callEngine",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_singleCallDurationEv",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_RTT",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_validMinRTT",{enumerable:!0,configurable:!0,writable:!0,value:200}),Object.defineProperty(this,"_validMaxRTT",{enumerable:!0,configurable:!0,writable:!0,value:1e3}),Object.defineProperty(this,"_deltaTime",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_timerId",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_interval",{enumerable:!0,configurable:!0,writable:!0,value:2e3}),Object.defineProperty(this,"_maxRetryTimes",{enumerable:!0,configurable:!0,writable:!0,value:8}),Object.defineProperty(this,"_startTimes",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_retryTimesInCall",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_maxRetryTimesInCall",{enumerable:!0,configurable:!0,writable:!0,value:3})}getCallClientTimeByServer(e,t){return m(this,void 0,void 0,(function*(){this._logger.info(u_.L_TIME_CORRECT_GET_CALL_CLIENT_TIME_BY_SERVER_T,`callId: ${e}`,t),(!this._RTT||this._RTT>this._validMinRTT)&&(yield this._getDeltaTime(t)),this._RTT>this._validMaxRTT&&this._logger.error(u_.L_TIME_CORRECT_GET_CALL_CLIENT_TIME_BY_SERVER_R,`code: ${rc.INVALID_RESPONSE_TIME}`,t);const{code:i,data:r}=yield this._callEngine.getCallTimeInfo(e,t);if(i!==Zl)return this._logger.error(u_.L_TIME_CORRECT_GET_CALL_CLIENT_TIME_BY_SERVER_R,`code: ${i}`,t),{code:i};const{startTime:n}=r,s=Math.floor(n-this._deltaTime);let o=(Date.now()+this._deltaTime-n)/1e3;return o<0&&(this._logger.warn(u_.L_TIME_CORRECT_GET_CALL_CLIENT_TIME_BY_SERVER_P,`invalid duration: ${o}`,t),o=0),o=Math.floor(o),this._RTT>this._validMinRTT&&this._RTT<=this._validMaxRTT&&this._logger.error(u_.L_TIME_CORRECT_GET_CALL_CLIENT_TIME_BY_SERVER_R,`code: ${rc.NONOPTIMAL_RES_TIME}`,t),this._logger.info(u_.L_TIME_CORRECT_GET_CALL_CLIENT_TIME_BY_SERVER_R,JSON.stringify({rtt:this._RTT,deltaT:this._deltaTime,serverStartTime:n,clientStartTime:s,duration:o}),t),{code:i,duration:o,clientStartTime:n?s:n}}))}calcClientStartTime(e,t,i){if(this._logger.info(u_.L_TIME_CORRECT_CALC_CLIENT_START_TIME_T,`callId: ${e}, startTime: ${t}`,i),this._RTT>this._validMaxRTT)return this._logger.error(u_.L_TIME_CORRECT_CALC_CLIENT_START_TIME_R,`code: ${rc.INVALID_RESPONSE_TIME}`,i),this._loopCorrectClientTime(e,i),{code:rc.INVALID_RESPONSE_TIME};const r=Math.floor(t-this._deltaTime);return this._logger.info(u_.L_TIME_CORRECT_CALC_CLIENT_START_TIME_R,JSON.stringify({rtt:this._RTT,deltaT:this._deltaTime,startT:t,clientStartTime:r}),i),this._RTT>this._validMinRTT&&(this._retryTimesInCall=0,this._loopCorrectClientTime(e,i)),{code:rc.SUCCESS,clientStartTime:r}}start(e){this._timerId||this._startTimes>=this._maxRetryTimes||(this._logger.info(u_.L_TIME_CORRECT_START_O,`timerId: ${this._timerId}`),this._startTimes++,this._getDeltaTime(e),this._timerId=J_((()=>{this._timerId=null,this.start(e)}),this._interval))}stop(e){this._logger.info(u_.L_TIME_CORRECT_STOP_O,`timerId: ${this._timerId}`,e),this._timerId&&clearTimeout(this._timerId),this._timerId=null,this._startTimes=0}restart(e){this._logger.info(u_.L_TIME_CORRECT_RESTART_O,`legal rtt time, RTT: ${this._RTT}, validMinRTT: ${this._validMinRTT}`,e),this._RTT<this._validMinRTT||(this.stop(e),this.start(e))}getLocalDelayTime(){return Math.round(this._deltaTime)}getRTT(){return this._RTT}_getDeltaTime(e){return m(this,void 0,void 0,(function*(){const t=Date.now(),{code:i,data:r}=yield this._callEngine.getCallServerTimestamp(e),n=Date.now();if(i!==Zl)return{code:i};const s=n-t;return(s<this._RTT||0===this._RTT)&&s<=this._validMaxRTT&&(this._RTT=s),s<this._validMinRTT&&this.stop(e),this._deltaTime=r-t-this._RTT/2,this._logger.info(u_.L_TIME_CORRECT_SET_DELTA_TIME_O,JSON.stringify({rtt:this._RTT,deltaT:this._deltaTime}),e),{code:i,delayTime:this._deltaTime}}))}_getDeltaTimeInCall(e,t){return m(this,void 0,void 0,(function*(){const i=Date.now(),{code:r,data:n}=yield this._callEngine.getCallTimeInfo(e,t),s=Date.now();if(r!==Zl)return{code:r};const o=s-i;o<this._RTT&&(this._RTT=o),this._deltaTime=n.syncTime-i-this._RTT/2,this._logger.info(u_.L_TIME_CORRECT_SET_DELTA_TIME_O,JSON.stringify({callId:e,rtt:this._RTT,deltaT:this._deltaTime}),t);const a=Math.floor(n.startTime-this._deltaTime),l=Math.floor(n.firstFrametime-this._deltaTime);return o<this._validMinRTT?{code:rc.SUCCESS,clientStartTime:a,clientFirstFrameTime:l}:{code:rc.INVALID_RESPONSE_TIME,clientStartTime:a,clientFirstFrameTime:l}}))}_loopCorrectClientTime(e,t){return m(this,void 0,void 0,(function*(){this.stop(t),this._logger.info(u_.L_TIME_CORRECT_LOOP_CORRECT_CLINET_TIME_T,`callId: ${e}`,t);const{code:i,clientStartTime:r,clientFirstFrameTime:n}=yield this._getDeltaTimeInCall(e,t);return i===rc.SUCCESS?(this._logger.info(u_.L_TIME_CORRECT_LOOP_CORRECT_CLINET_TIME_R,`code: ${Zl}`,t),void this._singleCallDurationEv(e,r,n,t)):this._retryTimesInCall>this._maxRetryTimesInCall&&i===rc.INVALID_RESPONSE_TIME?(this._logger.info(u_.L_TIME_CORRECT_LOOP_CORRECT_CLINET_TIME_R,`code: ${rc.INVALID_RESPONSE_TIME}`,t),void this._singleCallDurationEv(e,r,n,t)):void(this._retryTimesInCall>this._maxRetryTimesInCall||(this._retryTimesInCall++,setTimeout((()=>{this._loopCorrectClientTime(e,t)}),this._interval)))}))}}!function(e){e[e.SOON_AFETER=0]="SOON_AFETER",e[e.CURRENT=1]="CURRENT"}(nc||(nc={})),function(e){e[e.PUB_INVITE_CALL=0]="PUB_INVITE_CALL",e[e.PULL_KV_INVITE_CALL=1]="PULL_KV_INVITE_CALL",e[e.SYSTEM_PUSH=2]="SYSTEM_PUSH"}(sc||(sc={})),function(e){e[e.OUT=-1]="OUT",e[e.GROUP=0]="GROUP",e[e.IN=1]="IN"}(oc||(oc={}));class lc extends B{constructor(e,t,i,r,n){super(),Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_runtime",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_initOpts",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_reportAppEventModule",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"_mainSession",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_holdSessions",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_signalModule",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_abnormalModule",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_isUpFirstFrameTime",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_callStartMap",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_timeCorrectioner",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_clientCallId",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(this,"_rtcModule",{enumerable:!0,configurable:!0,writable:!0,value:null}),this._timeCorrectioner=new ac(this,r,this._onRecvSinCallDuration.bind(this)),this._signalModule=new X_(e,t,i,this._timeCorrectioner,this._logger,this._reportAppEventModule),this._signalModule.registerListener({onInvite:this._onInvite.bind(this),onStatusDown:this._onStatusDown.bind(this),onOtherClientStatusDown:this._onOtherClientStatusDown.bind(this),onEventDown:this._onEventDown.bind(this),onSwitchMediaType:this._onSwitchMediaType.bind(this),onRecvCallEndLog:this._onRecvCallEndLog.bind(this),onIMStateChange:this._onIMStateChange.bind(this)}),this._abnormalModule=new tc(t,r)}startCall(e,t){return m(this,void 0,void 0,(function*(){const i=this._context.getCurrentId(),{callType:r,mediaType:n,toUsers:s,targetId:o,targetType:a,oldRoomId:l,pushConfig:_,extra:c}=e;this._clientCallId=e.callId;const d=_?A_(_,this._clientCallId):"",{code:u,data:h}=yield this._signalModule.startCall({clientCallId:this._clientCallId,callType:r,mediaType:n,toUsers:s,secretChat:V_.NORMAL,targetType:a,targetId:o,oldRoomId:l,pushExt:d,pushContent:(null==_?void 0:_.pushContent)||"",extra:c},t);if(u!==Zl)return{code:u};const{callId:g,busylineUsers:p}=h;if(this._abnormalModule.addAbnormallCallId(i,g),this._mainSession=new H_(g,f_.INVITED,r,n,i,i,[],this._logger),r===g_.SINGLE){const e=this._startTimer(h.callId,p_.NO_ANSWER,t);this._mainSession.updateTimerId(G_.INVITER,e)}const f={userId:i,userState:p_.CALLING,systemState:I_.CALLING,targetType:a,targetId:o};let E=s.map((({userId:e,targetType:t,targetId:i})=>({userId:e,userState:p_.INVITED,systemState:I_.INVITED,targetType:t,targetId:i}))),I=[];p&&(I=p.map((e=>{const{targetType:t,targetId:i}=E.find((t=>t.userId===e.userId));return{userId:e.userId,userState:e.sessionStatus,systemState:I_.BUSYLINE_RINGING,targetType:t,targetId:i}})),E=E.filter((({userId:e})=>I.every((({userId:t})=>t!==e)))));const T=this.updateUsersState(g,[f,...E,...I],t);return setTimeout((()=>{T.length>0&&this.reportRemoteUserStateChange(g,T,t)})),{code:u,data:h}}))}invite(e,t){return m(this,void 0,void 0,(function*(){var i;if(!this._mainSession)return{code:t_};const{toUsers:r,pushConfig:n,extra:s}=e,o=n?A_(n,this._clientCallId):"",a=this._mainSession.getCallId(),{code:l,data:_}=yield this._signalModule.inviteCall({callId:a,toUsers:r,pushExt:o,pushContent:(null==n?void 0:n.pushContent)||"",extra:s},t);if(l===Zl){this._mainSession.getCallType()===g_.SINGLE&&(this._mainSession.updateCallType(g_.MULTI),this._onCallTypeChange(this._mainSession.getCallId(),g_.MULTI,t));let e=r.map((({userId:e,targetType:t,targetId:i})=>({userId:e,userState:p_.INVITED,systemState:I_.INVITED,targetType:t,targetId:i}))),n=[];_.busylineUsers&&(n=null===(i=_.busylineUsers)||void 0===i?void 0:i.map((t=>{const{targetType:i,targetId:r}=e.find((e=>e.userId===t.userId));return{userId:t.userId,userState:t.sessionStatus,systemState:I_.BUSYLINE_RINGING,targetType:i,targetId:r}})),e=e.filter((({userId:e})=>n.every((({userId:t})=>t!==e)))));const s=this.updateUsersState(a,[...e,...n],t);s.length>0&&this.reportRemoteUserStateChange(a,s,t)}return{code:l,data:_}}))}clearAllTimer(e,t){[this._mainSession,...this._holdSessions].forEach((i=>{i&&i.getCallId()===e&&i.getAllTimerIds().forEach((e=>this._stopTimer.bind(this)(e,t)))}))}hangup(e,t){return m(this,void 0,void 0,(function*(){const{callId:i,systemState:r,pushConfig:n}=e,s=n?A_(n,this._clientCallId):"",{code:o}=yield this._signalModule.hangupCall({callId:i,sysStatus:r,pushExt:s,pushContent:(null==n?void 0:n.pushContent)||""},t);return this.endCurrentSession(e.systemState,i,t),{code:o}}))}accept(e,t){return m(this,void 0,void 0,(function*(){if(!this._mainSession)return{code:t_};const{callId:i}=e,{code:r}=yield this._signalModule.acceptCall({callId:i},t);return this._stopTimer(this._mainSession.getInviteeTimerId(),t),r!==Zl||(this._clearMobileOnPhone(e.callId,t),this._mainSession.updateSessionState(f_.CONNECTING)),{code:r}}))}joinCall(e,t){return m(this,void 0,void 0,(function*(){const i=this._context.getCurrentId();this._mainSession&&this._stopTimer(this._mainSession.getInviteeTimerId(),t);const{code:r}=yield this._signalModule.joinCall({callId:e.callId},t);return r!==Zl||(this._abnormalModule.addAbnormallCallId(i,e.callId),this._mainSession?this._clearMobileOnPhone(e.callId,t):yield this._createSessionByServer(e.callId,t,!0)),{code:r}}))}requestChangeMediaType(e,t){return m(this,void 0,void 0,(function*(){if(!this._mainSession)return{code:t_};const i={mediaType:e.mediaType};this._mainSession.updateReqMediaType(e.mediaType);const r=ec(),{code:n}=yield this._signalModule.dialogUpCall({transactionId:r,callId:this._mainSession.getCallId(),toUserIds:e.toUserIds,dialogType:B_.SWITCH_MEDIA_TYPE,action:x_.REQUEST,extraKeyVal:i},t);return n!==Zl?{code:n}:{code:Zl,data:{transactionId:r}}}))}responseChangeMediaType(e,t){return m(this,void 0,void 0,(function*(){return this._mainSession?this._signalModule.dialogUpCall({transactionId:e.transactionId,callId:this._mainSession.getCallId(),dialogType:B_.SWITCH_MEDIA_TYPE,action:e.agree?x_.ACCEPT:x_.REFUSE},t):{code:t_}}))}cancelChangeMediaType(e,t){return m(this,void 0,void 0,(function*(){return this._mainSession?this._signalModule.dialogUpCall({transactionId:e.transactionId,callId:this._mainSession.getCallId(),dialogType:B_.SWITCH_MEDIA_TYPE,action:x_.CANCEL},t):{code:t_}}))}getCallLogList(e,t){return m(this,void 0,void 0,(function*(){const i=this._context.getCurrentId(),{timestamp:r,count:n,order:s}=e,{code:o,data:a}=yield this._signalModule.syncCallLog({userId:i,syncTime:r,count:n,order:s},t);if(o!==Zl)return{code:o};const l=a.callLogList.map((e=>C_(e)));return{code:Zl,data:{hasMore:Boolean(null==a?void 0:a.hasMore),syncTime:0===s?a.maxTime:a.minTime,list:l}}}))}deleteCallLog(e,t){return m(this,void 0,void 0,(function*(){const i=this._context.getCurrentId();return this._signalModule.deleteCallRecord(i,e,t)}))}getCallServerTimestamp(e){return m(this,void 0,void 0,(function*(){const{code:t,data:i}=yield this._signalModule.getCallServerTimestamp(e);return t!==Zl?{code:t}:{code:t,data:i.syncTime}}))}getCallTimeInfo(e,t){return m(this,void 0,void 0,(function*(){return this._signalModule.getCallTimeInfo(e,t)}))}getOpenCallList(e){return m(this,void 0,void 0,(function*(){const t=this._context.getCurrentId(),{code:i,data:r}=yield this._signalModule.getUserCallStateList(e);if(i!==Zl)return{code:i};return{code:i,data:r.callStateList.map((i=>{const{callId:r,callType:n,mediaType:s,callingUserId:o,callUserIds:a,callStatus:l,crtTime:_,userSessionStatus:c,startTime:d,syncTime:u}=i,h=o===t?oc.OUT:oc.IN,{clientStartTime:g=d}=this._timeCorrectioner.calcClientStartTime(r,d,e);return{callId:r,callType:n,callDirection:h,mediaType:s,callerUserId:o,callUserIds:a,sessionState:l,userState:c,startTimestamp:d,endTimestamp:0,duration:Math.floor((+new Date-g)/1e3),syncTimestamp:u,systemState:0,createTimestamp:_}}))}}))}removeAllCallLog(e){return m(this,void 0,void 0,(function*(){const{code:t}=yield this._signalModule.clearCallRecord(e);return{code:t}}))}getCallSession(e,t){return m(this,void 0,void 0,(function*(){const{code:i,data:r}=yield this._signalModule.getCallSession(e,t);if(i!==Zl)return{code:i};const{callId:n,callingUserId:s,callType:o,mediaType:a,callStatus:l,callSessionUsers:_,startTime:c,duration:d,syncTime:u}=r;return{code:i,data:{callId:n,startCallerId:s,callType:o,mediaType:a,sessionState:l,callSessionUsers:_.map((e=>{const{userId:t,sessionStatus:i,sysStatus:r,targetType:n,targetId:s}=e;return{userId:t,userState:i,systemState:r,targetType:n,targetId:s,cameraEnable:!1,microphoneEnable:!1}})),startTime:c,duration:d,syncTime:u}}}))}getHoldSession(e){const t=this._holdSessions.find((t=>t&&t.getCallId()===e));return t?new m_(t,this,this._logger,this._rtcModule,this._context):null}getLocalMainSession(){return this._mainSession?new m_(this._mainSession,this,this._logger,this._rtcModule,this._context):null}updateMainSessionState(e){var t;null===(t=this._mainSession)||void 0===t||t.updateSessionState(e)}setIsLocalClientHangup(e){var t;null===(t=this._mainSession)||void 0===t||t.setIsLocalClientHangup(e)}updateUsersState(e,t,i){this._logger.info(u_.L_CALL_ENGINE_UPDATE_USERS_STATE_O,`updateUsersState -> users: ${JSON.stringify(t)}`,i);const r=[this._mainSession,...this._holdSessions].find((t=>(null==t?void 0:t.getCallId())===e)),n=[];return r?n.push(...r.updateUserList(t,i)):n.push(...t),n}getCallStaringTime(e,t){return m(this,void 0,void 0,(function*(){return this._timeCorrectioner.getCallClientTimeByServer(e.callId,t)}))}systemStatusUp(e,t){return m(this,void 0,void 0,(function*(){return this._signalModule.sysStatusUp(e,t)}))}upFirstFrameTime(e){return m(this,void 0,void 0,(function*(){if(!this._mainSession||this._mainSession&&this._mainSession.getCallType()!==g_.SINGLE||this._isUpFirstFrameTime)return{code:Zl};const t=Date.now(),i=this._timeCorrectioner.getLocalDelayTime(),r=Math.floor(t+i);this._logger.info(u_.L_CALL_ENGINE_UP_FIRST_FRAME_TIME_T,`now: ${t}; delay: ${i}; streamReadyTime: ${r}`,e),this._isUpFirstFrameTime=!0;const n=this._mainSession.getCallId(),{code:s}=yield this._signalModule.eventUpCall({callId:n,eventType:ic.FIRST_FRAME,eventArgs:{streamReadyTime:r},eventTime:Date.now()},e);return this._logger.info(u_.L_CALL_ENGINE_UP_FIRST_FRAME_TIME_R,`code: ${s}`,e),{code:s}}))}endCurrentSession(e,t,i){const r=this._context.getCurrentId();if(this._mainSession&&this._mainSession.getCallId()===t){const t=this._mainSession.getUserList().map((t=>{let{userId:i,systemState:n,targetType:s,targetId:o}=t;return i===r&&(n=e),{userId:i,sessionStatus:p_.ENDED,statusTime:Date.now(),duration:0,changed:1,inviteUserId:this._mainSession.getStartCallerId(),sysStatus:n,targetType:s,targetId:o}})),n={callId:this._mainSession.getCallId(),toDeviceId:this._signalModule.getDeviceId(),callStatus:f_.ENDED,duration:0,callSessionUsers:t};this._onStatusDown(n,i)}}startTimeCorrection(e){this._timeCorrectioner.restart(e)}getDelayTimeInfo(){return{delayTime:this._timeCorrectioner.getLocalDelayTime(),rtt:this._timeCorrectioner.getRTT()}}upgradeMainSession(e){var t;const i=this._holdSessions.findIndex((t=>t.getCallId()===e));this._mainSession=null===(t=this._holdSessions.splice(i,1))||void 0===t?void 0:t[0]}endCurrentUserAbnormalCalls(e){return m(this,void 0,void 0,(function*(){const t=this._context.getCurrentId(),i=yield this._abnormalModule.getAbnormalCallIds(t);if(!i)return{code:Zl};const r=i.filter((e=>{var t;return e!==(null===(t=this._mainSession)||void 0===t?void 0:t.getCallId())})),{code:n}=yield this._signalModule.endUserAbnormalCalls({callIds:r,allDevice:e?1:0});return n===Zl&&this._abnormalModule.removeAbnormalCallIds(t,r),{code:n}}))}setRTCModule(e){this._rtcModule=e}_onIMStateChange(e){const t=this._logger.createTraceId();let i=0;e===l.DISCONNECTED&&this._mainSession&&this._mainSession.getSessionState()!==f_.ONCALL&&(i=J_((()=>{var e;this._logger.info(u_.L_CALL_ENGINE_IM_STATE_CHANGE_O,"endCurrentSession, IM disconnected for more than 60s",t),this.endCurrentSession(I_.CONNECTION_ERR,null===(e=this._mainSession)||void 0===e?void 0:e.getCallId(),t)}),6e4)),e===l.CONNECTED&&(i&&clearTimeout(i),this._initOpts.isAllowNewCallWhenRinging&&this.endCurrentUserAbnormalCalls(!0))}_handleCallTimeout(e,t,i){this._logger.warn(u_.L_CALL_ENGINE_CALL_TIMEOUT_O,`call timeout callId: ${e}, userState: ${t}`,i);const r=[this._mainSession,...this._holdSessions].find((t=>t&&t.getCallId()===e));if(!r)return void this._logger.warn(u_.L_CALL_ENGINE_CALL_TIMEOUT_O,`handleCallTimeout without session, callId: ${e}`,i);const n=this._context.getCurrentId();this._onStatusDown({callId:e,toDeviceId:this._signalModule.getDeviceId(),callStatus:f_.ENDED,duration:0,callSessionUsers:r.getUserList().map((e=>{const{userId:i,targetType:s,targetId:o,stateTime:a}=e;let l,_;return i===n?(l=t===p_.MISSED?I_.MISSED:I_.NO_ANSWER,_=t===p_.MISSED?p_.MISSED:p_.NO_ANSWER):(l=t===p_.MISSED?I_.NO_ANSWER:I_.MISSED,_=t===p_.MISSED?p_.NO_ANSWER:p_.MISSED),{userId:i,sessionStatus:_,statusTime:a?a+1:Date.now(),duration:0,changed:1,inviteUserId:r.getCallerId(),sysStatus:l,targetType:s,targetId:o}}))},i)}_startTimer(e,t,i){const r=J_((()=>{this._handleCallTimeout(e,t,i),this._signalModule.statusUpCall({callId:e,sessionStatus:t},i)}),6e4);return this._logger.info(u_.L_CALL_ENGINE_START_CALL_TIMER_O,`callId: ${e}, timerId: ${r}`,i),r}_stopTimer(e,t){clearTimeout(e),this._logger.info(u_.L_CALL_ENGINE_STOP_CALL_TIMER_O,`timerId: ${e}`,t)}_onInvite(e,t,i){this._clientCallId=J.gen();const r=this._context.getCurrentId(),{callSessionUsers:n,secretChat:s,extra:o="{}"}=e;if(s===V_.SECRET)return void this.emit(Y_.onPubInviteCallMiss,Object.assign(e,{extra:JSON.stringify(e),reason:q_.SECRET_CALL,refer:t?W_.PUB_INVITE:W_.PULL_KV_INVITE}));n.some((e=>e.userId===r))&&this._selfIsInviteeHandle(e,t,i,o),this._othersIsInviteeHandle(e,i)}_selfIsInviteeHandle(e,t,i,r){const{callId:n,inviteUserId:s,callType:o,mediaType:a,callSessionUsers:l}=e,_=this._context.getCurrentId();this._abnormalModule.addAbnormallCallId(_,n);const c=new H_(n,f_.RINGING,o,a,s,s,[],this._logger);this._signalModule.ringingCall({callId:n},i);const d=this._startTimer(n,p_.MISSED,i);c.updateTimerId(G_.INVITEE,d),this._mainSession?(this._holdSessions.push(c),this._mainSession.updateSessionState(f_.BUSYLINE_WAIT)):this._mainSession=c;const u=new m_(c,this,this._logger,this._rtcModule,this._context),h=t?sc.PUB_INVITE_CALL:sc.PULL_KV_INVITE_CALL;this.emit(lc.__INNER_INVITE__,u,h);const g=l.map((({userId:e,sessionStatus:t,sysStatus:i,targetType:r,targetId:n,statusTime:s})=>({userId:e,userState:t,systemState:i,targetType:r,targetId:n,stateTime:s}))),p=this.updateUsersState(n,g,i);this._reportAppEventModule.onReceivedCall(u,i,JSON.parse(r||"{}").extra),p.length>0&&this.reportRemoteUserStateChange(n,p,i)}_othersIsInviteeHandle(e,t){var i,r,n;const{callId:s,inviteUserId:o,callSessionUsers:a}=e,l=this._context.getCurrentId(),_=a.filter((e=>e.userId!==l&&e.userId!==o&&e.sessionStatus===p_.INVITED));if(!_.length)return;(null===(i=this._mainSession)||void 0===i?void 0:i.getCallType())===g_.SINGLE&&(null===(r=this._mainSession)||void 0===r?void 0:r.getCallId())===s&&(this._onCallTypeChange(this._mainSession.getCallId(),g_.MULTI,t),null===(n=this._mainSession)||void 0===n||n.updateCallType(g_.MULTI));const c=[],d=[];_.forEach((e=>{const{userId:t,sessionStatus:i,sysStatus:r}=e;c.push({callId:s,userId:t,userState:i}),d.push({userId:t,userState:i,systemState:r})})),this._onOtherMemberInvite(c);const u=this.updateUsersState(s,d,t);u.length>0&&this.reportRemoteUserStateChange(s,u,t)}_onHangup(e,t,i){this._mainSession&&e.forEach((e=>{e.callId===this._mainSession.getCallId()&&(e.userState===p_.CANCELLED?this._stopTimer(this._mainSession.getInviteeTimerId(),i):this._stopTimer(this._mainSession.getInviterTimerId(),i))}))}_onAccept(e,t){var i,r,n,s;const o=null===(i=this._mainSession)||void 0===i?void 0:i.getSessionState(),a=[f_.CONNECTING,f_.ONCALL,f_.BUSYLINE_WAIT];if((null===(r=this._mainSession)||void 0===r?void 0:r.getCallType())===g_.SINGLE&&o&&a.includes(o))return;const l=this._mainSession.getStartCallerId(),_=this._context.getCurrentId();if((null===(n=this._mainSession)||void 0===n?void 0:n.getCallType())===g_.SINGLE&&l===_){e.filter((e=>e.fromUserId!==_))&&this.emit(lc.__INNER_SESSION_CONNECT__,this.getLocalMainSession().getCallId(),t)}null===(s=this._mainSession)||void 0===s||s.updateSessionState(f_.CONNECTING),this._stopTimer(this._mainSession.getInviterTimerId(),t)}_onStatusDown(e,t){return m(this,void 0,void 0,(function*(){var i,r;const{callStatus:n,startTime:s,callId:o}=e;if(o!==(null===(i=this._mainSession)||void 0===i?void 0:i.getCallId()))return;if(this._callStartMap[o]=this._callStartMap[o]||{},!this._callStartMap[o].isReceiveCallStartTime&&n===f_.ONCALL){this._callStartMap[o].isReceiveCallStartTime=!0;const{code:e,clientStartTime:i}=this._timeCorrectioner.calcClientStartTime(o,s,t);e===rc.SUCCESS&&(this._callStartMap[o].callStartTime=i,this._reportAppEventModule.onReceivedCallStartTime({callId:o,callStartTime:i},t))}let a=!1;const l=this._context.getCurrentId(),_=e.callSessionUsers.map((e=>([p_.IDLE,p_.DECLINED,p_.MISSED,p_.NO_ANSWER,p_.CANCELLED].includes(e.sessionStatus)&&e.sysStatus!==I_.CANCELLED&&e.userId===l&&(a=!0),{userId:e.userId,userState:e.sessionStatus,systemState:e.sysStatus,stateTime:e.statusTime})));if(_.length){const e=this.updateUsersState(o,_,t);e.length>0&&this.reportRemoteUserStateChange(o,e,t)}if(!this._mainSession&&!this._holdSessions.length)return;const{hangupData:c,acceptData:d,otherInvitedData:u}=(e=>{const{callId:t}=e,i=[],r=[],n=[],s=[];return e.callSessionUsers.forEach((e=>{const{userId:o,sessionStatus:a,sysStatus:l}=e;switch(a){case p_.INVITED:s.push({callId:t,userId:o,userState:a});break;case p_.RINGING:i.push({callId:t,fromUserId:o});break;case p_.CONNECTING:n.push({fromUserId:o});break;case p_.CANCELLED:case p_.DECLINED:case p_.ENDED:case p_.IDLE:r.push({callId:t,fromUserId:o,userState:a,systemState:l})}})),{ringingData:i,hangupData:r,acceptData:n,otherInvitedData:s}})(e);c.length>0&&this._onHangup(c,e.callStatus,t),d.length>0&&this._onAccept(d,t),u.length>0&&(null===(r=this._mainSession)||void 0===r?void 0:r.getCallType())===g_.MULTI&&this._onOtherMemberInvite(u),(e.callStatus===f_.ENDED||a)&&this._onSessionClose(e,t,a)}))}_onOtherClientStatusDown(e,t){var i,r,n;const{callId:s,callSessionUsers:o}=e,a=this._context.getCurrentId(),l=o.find((({userId:e})=>e===a));if(l&&(this._mainSession||this._holdSessions.length)){const{userId:o,sessionStatus:_,statusTime:c}=l;if(_===p_.CONNECTING){const l=[p_.ONCALL,p_.CONNECTING],d=(null===(i=this._mainSession)||void 0===i?void 0:i.getCallId())===s,u=null===(n=null===(r=this._mainSession)||void 0===r?void 0:r.getUserList().find((e=>e.userId===a)))||void 0===n?void 0:n.userState;if(!(d&&u&&l.includes(u))){const i=this.updateUsersState(s,[{userId:o,userState:_,systemState:I_.OTHER_CLIENT_ACCEPT,stateTime:c}],t);i.length>0&&this.reportRemoteUserStateChange(s,i,t),this._onSessionClose(e,t,!1)}}}}_onEventDown(e,t){return m(this,void 0,void 0,(function*(){var i;const{callId:r,eventArgs:n,eventType:s}=e;if(r===(null===(i=this._mainSession)||void 0===i?void 0:i.getCallId())&&this._mainSession.getSessionState()===f_.ONCALL&&s===ic.CALL_DURATION){const{firstFrameTime:e}=n,{code:i,clientStartTime:s}=this._timeCorrectioner.calcClientStartTime(r,e,t);this._logger.info(u_.L_CALL_ENGINE_RECEIVE_FIRST_FRAME_TIME_O,`clientFirstFrameTime: ${s}`,t),i===rc.SUCCESS&&(this._callStartMap[r].firstFrameTime=s,this._reportAppEventModule.onReceivedCallFirstFrameTime(r,s,t))}}))}_onRecvSinCallDuration(e,t,i,r){var n;(null===(n=this._mainSession)||void 0===n?void 0:n.getCallId())===e&&(this._callStartMap[e].callStartTime=t,this._callStartMap[e].firstFrameTime=i,this._reportAppEventModule.onReceivedCallStartTime(Object.assign({callId:e},{callStartTime:t}),r),this._reportAppEventModule.onReceivedCallFirstFrameTime(e,i,r))}_onSwitchMediaType(e,t){var i,r,n,s,o;const{callId:a,action:l,extraKeyVal:_,transactionId:c,promoterId:d}=e,{mediaType:u,reason:h}=_,g=null===(i=this._mainSession)||void 0===i?void 0:i.getCallId();if(a!==g)return void this._logger.info(u_.L_CALL_ENGINE_RECEIVE_MEDIATYPE_CHANGE_O,`not current session callId: ${g}, recvCallId: ${a}`,t);const{transactionId:p,action:f,mediaType:E}=(null===(r=this._mainSession)||void 0===r?void 0:r.getOldDialogData())||{};if(p!==c||f!==l||E!==u){if(this._logger.info(u_.L_CALL_ENGINE_RECEIVE_MEDIATYPE_CHANGE_O,`action: ${l}, reason: ${h}`,t),null===(n=this._mainSession)||void 0===n||n.setOldDialogData({transactionId:c,action:l,mediaType:u}),l===x_.REQUEST)this._onRequestChangeMediaType({transactionId:c,userId:d,mediaType:u},t);else{let e=null;switch(h){case x_.CANCEL:e=E_.CANCEL_CHANGE_MEDIA_TYPE;break;case x_.ACCEPT:e=E_.SERVER_ALLOW_MEDIA_TYPE,null===(s=this._mainSession)||void 0===s||s.updateMediaType(this._mainSession.getReqMediaType()),null===(o=this._mainSession)||void 0===o||o.updateReqMediaType(null);break;case x_.REFUSE:e=E_.REFUSE_CHANGE_MEDIA_TYPE;break;case x_.TIMEOUT:e=E_.CHANGE_MEDIA_TYPE_TIMEOUT}E_[e]&&this._receiveMediaTypeChangeResult({transactionId:c,userId:d,mediaType:u},e,t)}l!==x_.NOTICE||u!==h_.AUDIO||h||this._receiveMediaTypeChangeResult({transactionId:c,userId:d,mediaType:u},E_.SERVER_ALLOW_MEDIA_TYPE,t)}else this._logger.info(u_.L_CALL_ENGINE_RECEIVE_MEDIATYPE_CHANGE_O,"duplicate dialog data",t)}_onRecvCallEndLog(e,t){const i=C_(e);this._reportAppEventModule.onReceivedCallRecord(i,t)}_onSessionClose(e,t,i){const{callId:r}=e,n=this._context.getCurrentId();this._abnormalModule.removeAbnormalCallIds(n,[r]);let s=[this._mainSession,...this._holdSessions].find((e=>e&&e.getCallId()===r));if(!s)return void this._logger.warn(u_.L_CALL_ENGINE_RECEIVE_CLOSE_SESSION_O,`unexpect session callId -> ${r}`,t);this._logger.warn(u_.L_CALL_ENGINE_RECEIVE_CLOSE_SESSION_O,`callId: ${r}`,t),this.emit(lc.__INNER_SESSION_CLOSE__,r,t);const o=s.getUserList().find((e=>e.userId===n));let a;a=i&&e.toDeviceId!==this._signalModule.getDeviceId()?s.getIsLocalClientHangup()?o.systemState:I_.OTHER_CLIENT_HANGUP:o.systemState,this._reportAppEventModule.onCallEnded(new m_(s,this,this._logger,this._rtcModule,this._context),a,t),this._reportCallPlusSummaryMessage(s,r,a),this._mainSession&&this._mainSession.getCallId()===r&&(this._mainSession.getAllTimerIds().forEach((e=>this._stopTimer.bind(this)(e,t))),s.getCallType()===g_.SINGLE&&(this._isUpFirstFrameTime=!1),delete this._callStartMap[r]),this._removeSession(r)}_reportCallPlusSummaryMessage(e,t,i){var r,l,_;const c=this._context.getCurrentId(),d=e.getUserList().filter((({userId:e})=>e!==c))[0].userId,u=e.getStartCallerId();if(!localStorage.getItem(`missMessageMap-${c}-${t}`)){const h={callId:t,callerUserId:u,targetId:d,mediaType:e.getMediaType(),firstFrameTime:(null===(r=this._callStartMap[t])||void 0===r?void 0:r.firstFrameTime)||0,callStartTime:(null===(l=this._callStartMap[t])||void 0===l?void 0:l.callStartTime)||0,callEndTime:(null===(_=this._callStartMap[t])||void 0===_?void 0:_.callStartTime)?+new Date-this._timeCorrectioner.getLocalDelayTime():0,hangupReason:i};this._reportAppEventModule.onReceivedCallPlusSummaryMessage({messageType:"RC:CallPlusSummary",content:h,senderUserId:u,targetId:d,channelId:"",conversationType:a.PRIVATE,sentTime:+new Date-this._timeCorrectioner.getLocalDelayTime(),receivedTime:+new Date-this._timeCorrectioner.getLocalDelayTime(),messageUId:t,messageDirection:u===c?s.SEND:s.RECEIVE,isPersited:!0,isCounted:!1,isOffLineMessage:!1,canIncludeExpansion:!1,receivedStatus:o.READ,isStatusMessage:!1,isMentioned:!1,expansion:null,disableNotification:!1,sentStatus:n.SENT}),localStorage.setItem(`missMessageMap-${c}-${t}`,t)}}_removeSession(e){var t;if(e===(null===(t=this._mainSession)||void 0===t?void 0:t.getCallId()))this._mainSession=null;else{const t=this._holdSessions.findIndex((t=>(null==t?void 0:t.getCallId())===e));this._holdSessions.splice(t,1)}}_createSessionByServer(e,t){return m(this,arguments,void 0,(function*(e,t,i=!1){this._logger.info(u_.L_CALL_ENGINE_CREATE_SESSION_BY_SERVER_T,`callId: ${e}`,t);const{code:r,data:n}=yield this.getCallSession({callId:e},t);if(r!==Zl)return void this._logger.error(u_.L_CALL_ENGINE_CREATE_SESSION_BY_SERVER_R,`errcode: ${r}`,t);this._logger.info(u_.L_CALL_ENGINE_CREATE_SESSION_BY_SERVER_R,`code: ${r}, data: ${JSON.stringify(n)}`,t);const{callType:s,mediaType:o,callSessionUsers:a,startCallerId:l}=n;this._mainSession=new H_(e,f_.CONNECTING,s,o,l,l,[],this._logger),i&&this._clearMobileOnPhone(e,t);const _=this.updateUsersState(e,a,t);_.length>0&&this.reportRemoteUserStateChange(e,_,t)}))}_clearMobileOnPhone(e,t){return m(this,void 0,void 0,(function*(){const i=[this._mainSession,...this._holdSessions].find((t=>(null==t?void 0:t.getCallId())===e));if(i&&i.getCallType()===g_.MULTI){this._logger.info(u_.L_CALL_ENGINE_UP_ON_PHONE_END_T,`callId: ${e}`,t);const{code:i}=yield this.systemStatusUp({callId:e,sysStatus:I_.ON_PHONE_END,forward:nc.CURRENT},t);i===Zl?this._logger.info(u_.L_CALL_ENGINE_UP_ON_PHONE_END_R,`callId: ${e}`,t):this._logger.warn(u_.L_CALL_ENGINE_UP_ON_PHONE_END_R,`callId: ${e}, errCode: ${i}`,t)}}))}reportRemoteUserStateChange(e,t,i){const r=this._context.getCurrentId();t.forEach((t=>{const{userId:n,userState:s,systemState:o}=t;n!==r&&this._reportAppEventModule.onRemoteUserStateChanged({callId:e,userId:n,userState:s,reason:o},i)})),t.forEach((({userId:t,systemState:n})=>{t===r&&n===I_.ABNORMAL_END&&this.emit(lc.__INNER_SESSION_CLOSE__,e,i)}))}_onOtherMemberInvite(e){e.forEach((e=>{var t;const{userId:i,callId:r}=e,n=null===(t=this.getLocalMainSession())||void 0===t?void 0:t.getInviterUserId();this._reportAppEventModule.onRemoteUserInvited([i],n,r)}))}_onRequestChangeMediaType(e,t){var i;const{userId:r,transactionId:n,mediaType:s}=e;null===(i=this._mainSession)||void 0===i||i.updateReqMediaType(s),this._reportAppEventModule.onReceivedChangeMediaTypeRequest(r,n,s,t)}_receiveMediaTypeChangeResult(e,t,i){t===E_.SERVER_ALLOW_MEDIA_TYPE&&this.emit(lc.__INNER_CHANGE_MEDIA_TYPE__,e.mediaType,i),this._reportAppEventModule.onReceivedChangeMediaTypeResult(Object.assign(Object.assign({},e),{result:t}),i)}_onCallTypeChange(e,t,i){this._reportAppEventModule.onCallTypeChanged(t,e,i)}}var _c,cc;Object.defineProperty(lc,"__INNER_SESSION_CLOSE__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-session-close"}),Object.defineProperty(lc,"__INNER_SESSION_CONNECT__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-session-connect"}),Object.defineProperty(lc,"__INNER_CHANGE_MEDIA_TYPE__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-change-media-type"}),Object.defineProperty(lc,"__INNER_INVITE__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-invite"}),function(e){e.NORMAL="RongCloudRTC",e.SCREEN="ScreenShare"}(_c||(_c={}));class dc extends B{constructor(e,t,i,r,n,s,o){super(),Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_runtime",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_initOpts",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_callEngine",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"_reportAppEventModule",{enumerable:!0,configurable:!0,writable:!0,value:s}),Object.defineProperty(this,"_rtcClient",{enumerable:!0,configurable:!0,writable:!0,value:o}),Object.defineProperty(this,"_localTracks",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_room",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_callId",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(this,"_callMediaType",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_videoConfig",{enumerable:!0,configurable:!0,writable:!0,value:{resolution:Ot.W640_H480,frameRate:Lt.FPS_15}}),Object.defineProperty(this,"_audioConfig",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_isPubTiny",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_audioOutputDeviceId",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(this,"_videoConfigIsChange",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_audioConfigIsChange",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_userViewMap",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_callPlusStatusReportListener",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_remoteAudioEnable",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"_preHangupCallId",{enumerable:!0,configurable:!0,writable:!0,value:null}),this._isPubTiny=i.isPubTiny||!1}setCallPlusStatusReportListener(e){this._callPlusStatusReportListener=e}getCameraVideoTrack(e){return m(this,void 0,void 0,(function*(){const t=this.getLocalVideoTrack(),{code:i,track:r}=t&&!this._videoConfigIsChange?{track:t,code:Zl}:yield this._createVideoTrack(e);return this._videoConfigIsChange=!1,i!==Zl?{code:i}:{code:Zl,track:r}}))}getMicrophoneAudioTrack(e){return m(this,void 0,void 0,(function*(){const t=this.getLocalAudioTrack(),{code:i,track:r}=t&&!this._audioConfigIsChange?{track:t,code:Zl}:yield this._createAudioTrack(e);return this._audioConfigIsChange=!1,i!==Zl?{code:i}:{code:Zl,track:r}}))}createCallMediaTracks(e,t){return m(this,void 0,void 0,(function*(){this._callMediaType=e;const{code:i}=yield this.getMicrophoneAudioTrack(t);if(i!==Zl)return{code:i};if(e===h_.AUDIO_VIDEO){const{code:e}=yield this.getCameraVideoTrack(t);e!==Zl&&this._logger.warn(u_.L_RTC_MODULE_CREATE_CALL_MEDIA_TRACKS_P,`get camera video track error code: ${e}`,t)}return{code:Zl}}))}setVideoConfig(e){this._videoConfigIsChange=!0,this._videoConfig=e}setAudioConfig(e){this._audioConfigIsChange=!0,this._audioConfig=e}setAudioOutputDeviceId(e){return m(this,void 0,void 0,(function*(){if("string"!=typeof e||0===e.length)return{code:Xl};if(this._audioOutputDeviceId===e)return{code:Zl};if(this._audioOutputDeviceId=e,this._room){this._room.getRemoteTracks().filter((e=>e.isAudioTrack())).forEach((t=>{t.isSubscribed()&&t.play(void 0,{audioDeviceId:e})}))}return{code:Zl}}))}destroyAllTracks(e){this._logger.info(u_.L_RTC_MODULE_DESTROY_ALL_TRACKS_O,"",e),this._localTracks.forEach((e=>{e.destroy()})),this._localTracks.length=0}setAllRemoteAudioEnable(e,t){if(this._logger.info(u_.L_RTC_MODULE_SET_ALL_REMOTE_AUDIO_ENABLE_T,`enable: ${e}`,t),!L(e))return this._logger.error(u_.L_RTC_MODULE_SET_ALL_REMOTE_AUDIO_ENABLE_R,`param error, enable: type is boolean, value: ${e}`),{code:Xl};if(this._remoteAudioEnable=e,!this._room)return{code:Zl};return this._room.getRemoteTracks().filter((e=>e.isAudioTrack())).forEach((t=>{e?t.unmute():t.mute()})),this._logger.info(u_.L_RTC_MODULE_SET_ALL_REMOTE_AUDIO_ENABLE_R,"success",t),{code:Zl}}destroyTrack(e){return m(this,void 0,void 0,(function*(){e.destroy();const t=this._localTracks.findIndex((t=>t.getTrackId()===e.getTrackId()));this._localTracks.splice(t,1)}))}sessionConnected(e,t){return m(this,void 0,void 0,(function*(){if(this._preHangupCallId=null,this._logger.info(u_.L_RTC_MODULE_SESSION_CONNECT_T,`callId: ${e}`,t),!this._room){const{code:i,room:r}=yield this.joinRTCRoom(e,t);if(i!==Zl)return;if(this._room=r,this._preHangupCallId&&this._room.getRoomId()===this._preHangupCallId)return this._rtcClient.leaveRoom(this._room),void this._releaseStoredData();const n=this._room.getRemoteUserIds();this._onSelfJoined(e,n,t)}this._callId=e,this._regRTCListeners();let i=this._room.getRemoteTracks();if(i&&i.length&&this._onRemoteTrackPublish(i),this._localTracks.length>0){this.emit(Y_.onBeforePublish);const e=this._isPubTiny?this._localTracks.map((e=>e.isVideoTrack()?{track:e,isPubTiny:!0}:e)):this._localTracks,{code:i}=yield this.publish(e,t);this.emit(Y_.onPublishRes,i)}else this._logger.warn(u_.L_RTC_MODULE_SESSION_CONNECT_P,"sessionConnected local tracks is empty",t);this._logger.info(u_.L_RTC_MODULE_SESSION_CONNECT_R,`code: ${Zl}`,t)}))}sessionClose(e,t){return m(this,void 0,void 0,(function*(){var i;this._logger.info(u_.L_RTC_MODULE_SESSION_CLOSE_T,`callId: ${e}`,t),this._preHangupCallId=e,this.destroyAllTracks(t);const r=null===(i=this._room)||void 0===i?void 0:i.getRoomId();if(this._room&&e===r){const{code:e}=yield this._rtcClient.leaveRoom(this._room);if(this._releaseStoredData(),e!==ae.SUCCESS)return void this._logger.error(u_.L_RTC_MODULE_SESSION_CLOSE_R,`leaveRoom failed, code: ${e}`,t);this._logger.info(u_.L_RTC_MODULE_SESSION_CLOSE_R,"leaveRoom success",t)}else this._logger.warn(u_.L_RTC_MODULE_SESSION_CLOSE_R,"leaveRoom throw exception: not in room",t)}))}disableVideoTrack(){return m(this,void 0,void 0,(function*(){const e=this.getLocalVideoTrack();if(!e)return{code:a_};return{code:yield e.mute(),track:e}}))}enableVideoTrack(e){return m(this,void 0,void 0,(function*(){const e=this.getLocalVideoTrack();if(!e)return{code:a_};if(!e.isOwnerMuted())return{code:Zl};return{code:yield e.unmute()}}))}changeVideoDevice(e){return m(this,void 0,void 0,(function*(){const t=[],i=[],{code:r,track:n}=yield this._rtcClient.createCameraVideoTrack(_c.NORMAL,this._videoConfig);if(r!==ae.SUCCESS)return{code:r};const{minBitrate:s,maxBitrate:o}=this._videoConfig;let a;if((s||o)&&n.setBitrate(o,s),this._localTracks&&this._localTracks.forEach((e=>{e.isVideoTrack()?(e.destroy(),a=e):i.push(e)})),this._localTracks=this._localTracks.filter((e=>a&&e.getTrackId()!==a.getTrackId())),t.push(n),i.push(n),this._localTracks=i,this._onLocalTrackReady(t,e),this._room){const{code:e}=yield this._room.publish(t);if(e!==ae.SUCCESS)return{code:e}}return{code:Zl,track:n}}))}changeAudioDevice(e){return m(this,void 0,void 0,(function*(){const t=[],i=[],r=Object.assign(Object.assign({},this._audioConfig),{micphoneId:this._audioConfig.microphoneId}),{code:n,track:s}=yield this._rtcClient.createMicrophoneAudioTrack(_c.NORMAL,r);if(n!==ae.SUCCESS)return{code:n};if(this._localTracks&&this._localTracks.forEach((e=>{e.isAudioTrack()||i.push(e)})),t.push(s),i.push(s),this._localTracks=i,this._onLocalTrackReady(t,e),this._room){const{code:e}=yield this._room.publish(t);if(e!==ae.SUCCESS)return{code:e}}return{code:Zl}}))}disableAudioTrack(){return m(this,void 0,void 0,(function*(){const e=this.getLocalAudioTrack();if(!e)return{code:l_};return{code:yield e.mute(),track:e}}))}changeMediaType(e,t){return m(this,void 0,void 0,(function*(){let i;this._logger.info(u_.L_RTC_MODULE_CHANGE_MEDIA_TYPE_T,`mediaType: ${e}`,t),i=e===h_.AUDIO_VIDEO?yield this._upgradeMediaType(t):yield this._downgradeMediaType(t),i.code===Zl&&this._logger.info(u_.L_RTC_MODULE_CHANGE_MEDIA_TYPE_R,"success",t)}))}_upgradeMediaType(e){return m(this,void 0,void 0,(function*(){let t=this.getLocalVideoTrack();if(!t){const{code:i,track:r}=yield this._createVideoTrack(e);if(i!==Zl)return this._logger.error(u_.L_RTC_MODULE_CHANGE_MEDIA_TYPE_R,`create video track errCode: ${i}`,e),{code:i};t=r;const{minBitrate:n,maxBitrate:s}=this._videoConfig;(n||s)&&t.setBitrate(s,n)}const i=this._isPubTiny?{track:t,isPubTiny:!0}:t,{code:r}=yield this.publish([i],e);return r!==Zl&&this._logger.error(u_.L_RTC_MODULE_CHANGE_MEDIA_TYPE_R,`publish errCode: ${r}`,e),{code:r}}))}_downgradeMediaType(e){return m(this,void 0,void 0,(function*(){const t=this.getLocalVideoTrack();if(t){const{code:i}=yield this._room.unpublish([t]);if(i!==ae.SUCCESS)return this._logger.error(u_.L_RTC_MODULE_CHANGE_MEDIA_TYPE_R,`unpublish errCode: ${i}`,e),{code:i};this.destroyTrack(t)}return{code:Zl}}))}joinRTCRoom(e,t){return m(this,void 0,void 0,(function*(){this._logger.info(u_.L_RTC_MODULE_JOIN_RTC_ROOM_T,`call: ${e}`,t);const{code:i,room:r,tracks:n}=yield K_({asyncFn:this._rtcClient.joinRTCRoomWithOptions.bind(this._rtcClient),fnArgs:[e,{mode:To.CALL}]});return i!==ae.SUCCESS?(this._logger.error(u_.L_RTC_MODULE_JOIN_RTC_ROOM_R,`callId: ${e}, errCode: ${i}`,t),this._onRTCMethodFail(I_.JOIN_ROOM_ERR,t),{code:i}):(this._logger.info(u_.L_RTC_MODULE_JOIN_RTC_ROOM_R,"success",t),this._callId=e,{code:Zl,room:r,tracks:n})}))}subscribeTracks(e,t){return m(this,void 0,void 0,(function*(){if(this._logger.info(u_.L_RTC_MODULE_SUBSCRIBE_T,JSON.stringify({params:e.map((e=>{const{track:t,subTiny:i}=e;return{trackId:t.getTrackId(),subTiny:i}}))}),t),!this._room)return{code:Zl};const{code:i}=yield K_({asyncFn:this._room.subscribe.bind(this._room),fnArgs:[e],onError:e=>{}});return i!==ae.SUCCESS?(this._reportAppEventModule.onFetchRemoteMediaError(e,i),this._onRTCMethodFail(I_.SUBSCRIBE_ERR,t),this._logger.error(u_.L_RTC_MODULE_SUBSCRIBE_R,`errorCode: ${i}`,t),{code:i}):(this._logger.info(u_.L_RTC_MODULE_SUBSCRIBE_R,"success",t),{code:Zl})}))}unsubscribeTracks(e,t){return m(this,void 0,void 0,(function*(){if(this._logger.info(u_.L_RTC_MODULE_UNSUBSCRIBE_T,JSON.stringify({trackIds:e.map((e=>e.getTrackId()))}),t),!this._room)return{code:Zl};const{code:i}=yield this._room.unsubscribe(e);return i!==ae.SUCCESS?(this._logger.error(u_.L_RTC_MODULE_UNSUBSCRIBE_R,`errorCode: ${i}`,t),{code:i}):(this._logger.info(u_.L_RTC_MODULE_UNSUBSCRIBE_R,"success",t),{code:Zl})}))}_releaseStoredData(){this._room=null,this._remoteAudioEnable=!0,this._userViewMap={},this._preHangupCallId=null}getRemoteTracks(){const e={};if(!this._room)return e;return this._room.getRemoteUserIds().forEach((t=>{e[t]=this._room.getRemoteTracksByUserId(t)})),e}getRemoteTrack(e,t){var i;return null===(i=this._room)||void 0===i?void 0:i.getRemoteTracksByUserId(e).find((e=>t===h_.AUDIO?e.isAudioTrack():e.isVideoTrack()))}getRTCSessionId(){return this._room?this._room.getSessionId():null}_regRTCListeners(){this._room.registerRoomEventListener({onKickOff:(e,t)=>{this._onKickOff(e,this._room.getRoomId(),t),this._releaseStoredData()},onUserJoin:e=>{const t=e.map((e=>({callId:this._callId,userId:e}))),i=this._logger.createTraceId();this._onOtherMemJoined(t,i)},onUserLeave:e=>{e.forEach((e=>{delete this._userViewMap[e]}))},onTrackPublish:this._onRemoteTrackPublish.bind(this),onTrackUnpublish:this._onTrackUnpublish.bind(this),onTrackReady:e=>{this._onRemoteTrackReady([e])},onVideoMuteChange:e=>{this._onVideoMuteChagne({fromUserId:e.getUserId(),muted:e.isOwnerMuted(),trackId:e.getTrackId()})},onAudioMuteChange:e=>{this._onAudioMuteChange({fromUserId:e.getUserId(),muted:e.isOwnerMuted(),trackId:e.getTrackId()})},onRTCPeerConnectionCloseByException:this._onRTCPeerConnectionCloseByException.bind(this)}),this._room.registerReportListener({onStateReport:this._onRTCStateReport.bind(this)}),this._room.onAudioLevelChange((e=>{this._reportAppEventModule.onUserAudioLevelChanged(e)}))}_onLocalTrackReady(e,t){this._reportAppEventModule.onUserMediaAvailable(e,t)}_onRemoteTrackReady(e){this._reportAppEventModule.onUserMediaAvailable(e),this.emit(dc.__INNER_RECEIVE_FIRST_FRAME__)}_onKickOff(e,t,i,r){this._logger.info(u_.L_RTC_MODULE_RECEIVE_KICK_OFF_O,`roonId: ${t}, byServer: ${e}, state: ${i}, kickExtra: ${JSON.stringify(r)}`);let n=I_.CONNECTION_ERR;if(e)if(r)n=r.kickReasonCode;else switch(i){case pa.SERVER_KICK:n=I_.KICKED_BY_SERVER;break;case pa.OTHER_KICK:n=I_.OTHER_CLIENT_JOINED;break;case pa.IM_DISCONNECTED:n=I_.CONNECTION_ERR;break;case pa.IM_LOGOUT:n=I_.LOGOUT;break;case pa.OTHER_CLIENT_IM_CONNECTED:n=I_.OTHER_CLIENT_LOGIN}this.emit(dc.__INNER_ON_KICKOFF__,n,t)}_onRTCPeerConnectionCloseByException(){const e=this._logger.createTraceId();this._logger.info(u_.L_RTC_MODULE_RECEIVE_PEERCONNECTION_EXCEPT_CLOSE_O,"",e),this.emit(dc.__INNER_RTC_PEERCONNECTION_ABNORMAL_CLOSE__,e)}_onSelfJoined(e,t,i){return m(this,void 0,void 0,(function*(){this.emit(dc.__INNER_ON_SELF_JOINED__,e,t,i)}))}_onRemoteTrackPublish(e){const t=this._logger.createTraceId();this._logger.info(u_.L_RTC_MODULE_RECEIVE_TRACK_PUBLISH_O,JSON.stringify({callId:this._callId,trackIds:e.map((e=>e.getTrackId()))}),t);const i=[];e.forEach((e=>{var t;const r=e.getUserId();if(e.isAudioTrack())i.push({track:e,subTiny:!1}),this._reportAppEventModule.onRemoteMicrophoneStateChanged(this._callId,e);else if(this._reportAppEventModule.onRemoteCameraStateChanged(this._callId,e),null===(t=this._userViewMap[r])||void 0===t?void 0:t.videoView){const{isTiny:t}=this._userViewMap[r];i.push({track:e,subTiny:t})}})),i.length&&this.subscribeTracks(i,t)}_onTrackUnpublish(e){return m(this,void 0,void 0,(function*(){const t=this._logger.createTraceId();this._logger.info(u_.L_RTC_MODULE_RECEIVE_TRACK_UNPUBLISH_O,JSON.stringify({callId:this._callId,trackIds:e.map((e=>e.getTrackId()))}),t),yield this.unsubscribeTracks(e,t)}))}_onAudioMuteChange(e){const t=this._logger.createTraceId();this._logger.info(u_.L_RTC_MODULE_RECEIVE_TRACK_ENABLE_CHANGE_O,JSON.stringify({info:e}),t);const i=this._room.getRemoteTrack(e.trackId);this._reportAppEventModule.onRemoteMicrophoneStateChanged(this._callId,i)}_onVideoMuteChagne(e){const t=this._logger.createTraceId();this._logger.info(u_.L_RTC_MODULE_RECEIVE_TRACK_ENABLE_CHANGE_O,JSON.stringify({info:e}),t);const i=this._room.getRemoteTrack(e.trackId);this._reportAppEventModule.onRemoteCameraStateChanged(this._callId,i)}_trackStatToQualityStats(e){var t,i,r,n,s,o;const a=null!==(t=e.packetsLostRate)&&void 0!==t?t:0,l=null!==(i=e.bitrate)&&void 0!==i?i:0,_=null!==(r=e.jitter)&&void 0!==r?r:0,c=null!==(n=e.rtt)&&void 0!==n?n:0;return"audio"===e.kind?{audioBitRate:l,audioPacketLostRate:a,jitter:_,rtt:c}:{videoPacketLostRate:a,videoBitRate:l,videoWidth:null!==(s=e.frameWidth)&&void 0!==s?s:0,videoHeight:null!==(o=e.frameHeight)&&void 0!==o?o:0,jitter:_,rtt:c}}_onRTCStateReport(e){var t;const{senders:i,receivers:r}=e,n=null!==(t=this._context.getCurrentId())&&void 0!==t?t:"";i.forEach((e=>{var t,i,r;const{kind:s,packetsLostRate:o,rtt:a}=e;null===(i=null===(t=this._callPlusStatusReportListener)||void 0===t?void 0:t.onSendQualityChanged)||void 0===i||i.call(t,{[n]:this._trackStatToQualityStats(e)}),this._callMediaType===h_.AUDIO_VIDEO&&"audio"===s||null===(r=this._callPlusStatusReportListener)||void 0===r||r.onSendPacketLoss(o||0,a||0)})),r.forEach((e=>{var t,i,r;const{trackId:n,kind:s,packetsLostRate:o,bitrate:a}=e,{userId:l}=Ql(n);if(null===(i=null===(t=this._callPlusStatusReportListener)||void 0===t?void 0:t.onReceiveQualityChanged)||void 0===i||i.call(t,{[l]:this._trackStatToQualityStats(e)}),this._callMediaType===h_.AUDIO_VIDEO&&"audio"===s)return;const _={};_[l]={packetLostRate:o||0,bitRate:a},null===(r=this._callPlusStatusReportListener)||void 0===r||r.onReceivePacketLoss(_)}))}_onRTCMethodFail(e,t){this.emit(dc.__INNER_RTC_PROCESS_FAILED__,e,t)}_onOtherMemJoined(e,t){this.emit(dc.__INNER_ON_OTHER_JOINED__,e,t)}_createAudioTrack(e){return m(this,void 0,void 0,(function*(){this._logger.info(u_.L_RTC_MODULE_CREATE_AUDIO_TRACK_T,"",e);const t=Object.assign(this._audioConfig,{micphoneId:this._audioConfig.microphoneId}),{code:i,track:r}=yield this._rtcClient.createMicrophoneAudioTrack(_c.NORMAL,t);if(i!==ae.SUCCESS)return this._logger.error(u_.L_RTC_MODULE_CREATE_AUDIO_TRACK_R,`errCode: ${i}`,e),{code:i};this._logger.info(u_.L_RTC_MODULE_CREATE_AUDIO_TRACK_R,"success",e);const{minBitrate:n,maxBitrate:s}=this._audioConfig;return(n||s)&&r.setBitrate(s,n),this._localTracks.push(r),this._onLocalTrackReady([r],e),{code:Zl,track:r}}))}_createVideoTrack(e){return m(this,void 0,void 0,(function*(){this._logger.info(u_.L_RTC_MODULE_CREATE_VIDEO_TRACK_T,"",e);const{code:t,track:i}=yield this._rtcClient.createCameraVideoTrack(_c.NORMAL,this._videoConfig);if(t!==ae.SUCCESS)return this._logger.error(u_.L_RTC_MODULE_CREATE_VIDEO_TRACK_R,`errCode: ${t}`,e),{code:t};this._logger.info(u_.L_RTC_MODULE_CREATE_VIDEO_TRACK_R,"success",e);const{minBitrate:r,maxBitrate:n}=this._videoConfig;return(r||n)&&i.setBitrate(n,r),this._localTracks.push(i),this._onLocalTrackReady([i],e),{code:Zl,track:i}}))}getLocalVideoTrack(){let e;return this._localTracks&&([e]=this._localTracks.filter((e=>e.isVideoTrack()))),e}getLocalAudioTrack(){let e;return this._localTracks&&([e]=this._localTracks.filter((e=>e.isAudioTrack()))),e}publish(e,t){return m(this,void 0,void 0,(function*(){this._logger.info(u_.L_RTC_MODULE_PUBLISH_T,`tracksIds: ${e.map((e=>e instanceof jt?e.getTrackId():e.track.getTrackId()))}`,t);const{code:i}=yield K_({asyncFn:this._room.publish.bind(this._room),fnArgs:[e],onError:e=>{}});return i!==ae.SUCCESS?(this._onRTCMethodFail(I_.PUBLISH_ERR,t),this._logger.error(u_.L_RTC_MODULE_PUBLISH_R,`errCode: ${i}`,t),{code:i}):(this._logger.info(u_.L_RTC_MODULE_PUBLISH_R,`code: ${Zl}`,t),{code:Zl})}))}publishVideoTrack(){const e=this.getLocalVideoTrack(),t=this._isPubTiny?{track:e,isPubTiny:!0}:e;return this._room.publish([t])}setVideoView(e,t){const i=[];e.forEach((e=>{const{userId:t,videoElement:r,isTiny:n=!1}=e;if(this._userViewMap[t]={videoView:r,isTiny:n},t===this._context.getCurrentId())return;if(!this._room)return;const s=(this.getRemoteTracks()[t]||[]).map((e=>({track:e,subTiny:n})));i.push(...s)})),this._logger.info(u_.L_RTC_MODULE_SET_VIDEO_VIEW_O,JSON.stringify({userViewMap:v_(this._userViewMap),needSubTrackIds:i.map((({track:e})=>e.getTrackId()))}),t),i.length&&this.subscribeTracks(i,t)}removeVideoView(e,t){const i=[];e.forEach((e=>{const t=this.getRemoteTracks()[e];if(t&&t.length){const e=t.filter((e=>e.isVideoTrack()));e.length&&i.push(e[0])}delete this._userViewMap[e]})),this._logger.info(u_.L_RTC_MODULE_REMOVE_VIDEO_VIEW_O,JSON.stringify({userViewMap:v_(this._userViewMap),unsubTracks:i.map((e=>e.getTrackId()))}),t),i.length&&this.unsubscribeTracks(i,t)}getUserViewMap(){return this._userViewMap}playMedia(e,t,i,r){return m(this,void 0,void 0,(function*(){var n;this._logger.info(u_.L_RTC_MODULE_PLAY_MEDIA_T,`userId: ${e}, mediaType: ${t}, videoView: ${null==i?void 0:i.nodeName}`,r);const s=this._context.getCurrentId();if(e===s&&t===h_.AUDIO)return this._logger.error(u_.L_RTC_MODULE_PLAY_MEDIA_R,"please avoid playing local audio to prevent echoes.",r),{code:c_};let o=null;if(o=e===s?t===h_.AUDIO?null:this.getLocalVideoTrack():null===(n=this.getRemoteTracks()[e])||void 0===n?void 0:n.filter((e=>t===h_.AUDIO?e.isAudioTrack():e.isVideoTrack()))[0],!o)return this._logger.error(u_.L_RTC_MODULE_PLAY_MEDIA_R,`error code: ${__}`,r),{code:__};try{const{code:e}=o.isAudioTrack()?yield o.play(void 0,{audioDeviceId:this._audioOutputDeviceId||void 0}):yield o.play(i);return o.isAudioTrack()&&!this._remoteAudioEnable&&o.mute(),e!==ae.SUCCESS?(this._logger.error(u_.L_RTC_MODULE_PLAY_MEDIA_R,`errCode: ${e}`,r),{code:e}):(this._logger.info(u_.L_RTC_MODULE_PLAY_MEDIA_R,"success",r),{code:Zl})}catch(e){return this._logger.error(u_.L_RTC_MODULE_PLAY_MEDIA_R,`errCode: ${c_}, message: ${e.message},`,r),{code:c_}}}))}}Object.defineProperty(dc,"__INNER_RTC_PROCESS_FAILED__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-rtc-process-failed"}),Object.defineProperty(dc,"__INNER_RTC_PEERCONNECTION_ABNORMAL_CLOSE__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-rtc-peerconnection-abnormal-close"}),Object.defineProperty(dc,"__INNER_ON_SELF_JOINED__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-on-self-joined"}),Object.defineProperty(dc,"__INNER_ON_OTHER_JOINED__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-on-other-joined"}),Object.defineProperty(dc,"__INNER_RECEIVE_FIRST_FRAME__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-receive-first-frame"}),Object.defineProperty(dc,"__INNER_ON_KICKOFF__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-kickoff-frame"});class uc{constructor(e){Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_listener",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}registerEventListener(e){this._listener=e}_callAppListener(e,...t){return m(this,void 0,void 0,(function*(){var i;const r=null===(i=this._listener)||void 0===i?void 0:i[e];if(r)try{yield r(...t)}catch(e){console.error(e),this._logger.error(u_.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({name:e.name,message:e.message}))}}))}onReceivedCall(e,t,i){this._logger.info(u_.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onReceivedCall",callId:e.getCallId()}),t),this._callAppListener("onReceivedCall",e,i)}onRemoteUserInvited(e,t,i){this._logger.info(u_.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onRemoteUserInvited",inviteeUserList:e,inviterUserId:t,callId:i})),this._callAppListener("onRemoteUserInvited",e,t,i)}onCallConnected(e){this._logger.info(u_.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onCallConnected",callId:e.getCallId()})),this._callAppListener("onCallConnected",e)}onCallTypeChanged(e,t,i){this._logger.info(u_.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onCallTypeChanged",callId:t,callType:e}),i),this._callAppListener("onCallTypeChanged",e,t)}onRemoteUserStateChanged(e,t){const{callId:i,userId:r,userState:n,reason:s}=e;this._logger.info(u_.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onRemoteUserStateChanged",callId:i,userId:r,userState:n,reason:s}),t),this._callAppListener("onRemoteUserStateChanged",i,r,n,s)}onCallEnded(e,t,i){this._logger.info(u_.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onCallEnded",callId:e.getCallId(),closeReason:t}),i),this._callAppListener("onCallEnded",e,t)}onRemoteCameraStateChanged(e,t){this._logger.info(u_.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onRemoteCameraStateChanged",callId:e,trackId:null==t?void 0:t.getTrackId(),enable:null==t?void 0:t.isOwnerMuted()}));const i=null==t?void 0:t.getUserId();this._callAppListener("onRemoteCameraStateChanged",e,i,null==t?void 0:t.isOwnerMuted())}onRemoteMicrophoneStateChanged(e,t){this._logger.info(u_.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onRemoteMicrophoneStateChanged",callId:e,trackId:null==t?void 0:t.getTrackId(),enable:null==t?void 0:t.isOwnerMuted()}));const i=null==t?void 0:t.getUserId();this._callAppListener("onRemoteMicrophoneStateChanged",e,i,null==t?void 0:t.isOwnerMuted())}onReceivedCallRecord(e,t){this._logger.info(u_.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onReceivedCallRecord",record:e}),t),this._callAppListener("onReceivedCallRecord",e)}onReceivedChangeMediaTypeRequest(e,t,i,r){this._logger.info(u_.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onReceivedChangeMediaTypeRequest",userId:e,transactionId:t}),r),this._callAppListener("onReceivedChangeMediaTypeRequest",e,t,i)}onReceivedChangeMediaTypeResult(e,t){const{userId:i,transactionId:r,mediaType:n,result:s}=e;this._logger.info(u_.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onReceivedChangeMediaTypeResult",userId:i,mediaType:n}),t),this._callAppListener("onReceivedChangeMediaTypeResult",{userId:i,transactionId:r,mediaType:n,result:s})}onReceivedCallStartTime(e,t){this._logger.info(u_.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onReceivedCallStartTime",info:e}),t),this._callAppListener("onReceivedCallStartTime",e)}onReceivedCallFirstFrameTime(e,t,i){this._logger.info(u_.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onReceivedCallFirstFrameTime",callId:e,callFirstFrameTime:t}),i),this._callAppListener("onReceivedCallFirstFrameTime",e,t)}onUserMediaAvailable(e,t){this._logger.info(u_.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onUserMediaAvailable",trackIds:e.map((e=>e.getTrackId()))}),t),e.forEach((e=>{const t=e.getUserId(),i=e.isAudioTrack()?h_.AUDIO:h_.VIDEO;this._callAppListener("onUserMediaAvailable",t,i)}))}onFetchRemoteMediaError(e,t){e.forEach((({track:e})=>{const i=e.getUserId();this._callAppListener("onFetchRemoteMediaError",i,t)}))}onUserAudioLevelChanged(e){e.forEach((({track:e,audioLevel:t})=>{const i=e.getUserId();this._callAppListener("onUserAudioLevelChanged",i,t)}))}onReceivedCallPlusSummaryMessage(e){this._callAppListener("onReceivedCallPlusSummaryMessage",e)}onReceivedGroupCallStatusMessage(e){this._callAppListener("onReceivedGroupCallStatusMessage",e)}}!function(e){e[e.UNKNOW_ERR=41e3]="UNKNOW_ERR",e[e.DB_ERR=41001]="DB_ERR",e[e.JSON_ERR=41002]="JSON_ERR",e[e.INVALID_JSON_ERR=41003]="INVALID_JSON_ERR",e[e.MISSING_PARAMS=41004]="MISSING_PARAMS",e[e.PARAMS_REQUIRED=41005]="PARAMS_REQUIRED",e[e.DATA_FORMAT_ERR=41006]="DATA_FORMAT_ERR",e[e.METHOD_NOT_IMPLEMENTED=41007]="METHOD_NOT_IMPLEMENTED",e[e.CALL_NOT_EXIST=41010]="CALL_NOT_EXIST",e[e.SINGAL_EXCEED_TWO_INVITEE=41011]="SINGAL_EXCEED_TWO_INVITEE",e[e.GROUP_EXCEEDS_QUORUM=41012]="GROUP_EXCEEDS_QUORUM",e[e.OPERATION_EXPIRED=41013]="OPERATION_EXPIRED",e[e.DEVICE_IS_CALLING=41014]="DEVICE_IS_CALLING",e[e.REPORT_STREAM_READY_TIME_IS_INVALID=41018]="REPORT_STREAM_READY_TIME_IS_INVALID",e[e.NOT_CALL_YOURSELF=41019]="NOT_CALL_YOURSELF",e[e.SESSION_STATUS_NOT_EXIST=41020]="SESSION_STATUS_NOT_EXIST",e[e.HANGUP_NOT_ALLOW=41021]="HANGUP_NOT_ALLOW",e[e.ACCEPT_NOT_ALLOW=41022]="ACCEPT_NOT_ALLOW",e[e.OPERATION_NOT_ALLOW=41025]="OPERATION_NOT_ALLOW",e[e.TRANSACTION_ID_ERR=41100]="TRANSACTION_ID_ERR",e[e.UP_VIDEO_CANCELED=41050]="UP_VIDEO_CANCELED",e[e.CURRENT_CALL_IS_AUDIO=41051]="CURRENT_CALL_IS_AUDIO",e[e.CURRENT_CALL_IS_VIDEO=41052]="CURRENT_CALL_IS_VIDEO"}(cc||(cc={}));class hc{constructor(e){Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_androidPushConfig",{enumerable:!0,configurable:!0,writable:!0,value:{}})}setChannelIdMi(e){return C(e)?(this._androidPushConfig.channelIdMi=e,this):(this._logger.error(u_.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: channelIdMi type is string, value: ${e}`),this)}setMiLargeIconUrl(e){return this._logger.warn(u_.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,"`setMiLargeIconUrl` has been deprecated."),this}setChannelIdHW(e){return C(e)?(this._androidPushConfig.channelIdHW=e,this):(this._logger.error(u_.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: channelIdHW type is string, value: ${e}`),this)}setCategoryHW(e){return C(e)?(this._androidPushConfig.categoryHW=e,this):(this._logger.error(u_.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: categoryHW type is string, value: ${e}`),this)}setImportanceHW(e){return"LOW"!==e&&"NORMAL"!==e?(this._logger.error(u_.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: importanceHW value is NORMAL|LOW, value: ${e}`),this):(this._androidPushConfig.importanceHW=e,this)}setImageUrlHW(e){return C(e)?(this._androidPushConfig.imageUrlHW=e,this):(this._logger.error(u_.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: imageUrlHW type is string, value: ${e}`),this)}setChannelIdOPPO(e){return C(e)?(this._androidPushConfig.channelIdOPPO=e,this):(this._logger.error(u_.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: channelIdOPPO type is string, value: ${e}`),this)}setTypeVivo(e){return C(e)?(this._androidPushConfig.typeVivo=e,this):(this._logger.error(u_.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: typeVivo type is string, value: ${e}`),this)}setCategoryVivo(e){return C(e)?(this._androidPushConfig.categoryVivo=e,this):(this._logger.error(u_.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: categoryVivo type is string, value: ${e}`),this)}setFcmChannelId(e){return C(e)?(this._androidPushConfig.fcmChannelId=e,this):(this._logger.error(u_.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: fcmChannelId type is string, value: ${e}`),this)}setFcmCollapseKey(e){return C(e)?(this._androidPushConfig.fcmCollapseKey=e,this):(this._logger.error(u_.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: fcmCollapseKey type is string, value: ${e}`),this)}setFcmImageUrl(e){return C(e)?(this._androidPushConfig.fcmImageUrl=e,this):(this._logger.error(u_.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: fcmImageUrl type is string, value: ${e}`),this)}setimportanceHonor(e){return"LOW"!==e&&"NORMAL"!==e?(this._logger.error(u_.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: importanceHonor value is NORMAL|LOW, value: ${e}`),this):(this._androidPushConfig.importanceHonor=e,this)}setimageUrlHonor(e){return C(e)?(this._androidPushConfig.imageUrlHonor=e,this):(this._logger.error(u_.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: imageUrlHonor type is string, value: ${e}`),this)}build(){return this._androidPushConfig}}class gc{constructor(e,t,i,r){Object.defineProperty(this,"_runtime",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_initOpts",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_rtcPluginContext",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_rtcClient",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_videoConfig",{enumerable:!0,configurable:!0,writable:!0,value:{resolution:Ot.W640_H480,frameRate:Lt.FPS_15}}),Object.defineProperty(this,"_audioConfig",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_callPlusStatistics",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_clientCallId",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(this,"_isLaunchHangup",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_needHangupCallId",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_callEngine",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_rtcModule",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_reportAppEventModule",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._logger=this._rtcPluginContext.logger,this._rtcPluginContext.registerMessageType("RC:CallPlusMiss",!0,!1,[]),this._reportAppEventModule=new uc(this._logger),this._callPlusStatistics=new j_(this._rtcPluginContext),this._callEngine=new lc(this._rtcPluginContext,this._runtime,this._initOpts,this._logger,this._reportAppEventModule),this._rtcModule=new dc(this._rtcPluginContext,this._runtime,this._initOpts,this._logger,this._callEngine,this._reportAppEventModule,this._rtcClient),this._callEngine.setRTCModule(this._rtcModule),this._rtcModule.on(dc.__INNER_RTC_PROCESS_FAILED__,this._rtcProcessFailHandle.bind(this)),this._rtcModule.on(dc.__INNER_RTC_PEERCONNECTION_ABNORMAL_CLOSE__,this._peerConnectionAbnormalClose.bind(this)),this._rtcModule.on(dc.__INNER_ON_SELF_JOINED__,this._selfJoinedHandle.bind(this)),this._rtcModule.on(dc.__INNER_ON_OTHER_JOINED__,this._otherJoinedHandle.bind(this)),this._rtcModule.on(dc.__INNER_RECEIVE_FIRST_FRAME__,this._receiveFirstFrameHandle.bind(this)),this._rtcModule.on(dc.__INNER_ON_KICKOFF__,this._kickoffHandle.bind(this)),this._callEngine.on(lc.__INNER_SESSION_CONNECT__,this._rtcModule.sessionConnected.bind(this._rtcModule)),this._callEngine.on(lc.__INNER_SESSION_CLOSE__,this._sessionCloseHandle.bind(this)),this._callEngine.on(lc.__INNER_CHANGE_MEDIA_TYPE__,this._rtcModule.changeMediaType.bind(this._rtcModule)),this._callEngine.on(lc.__INNER_INVITE__,((e,t)=>{this._callPlusStatistics.reportStatisticsData(k_.L_QS_RECEIVE_CALL_S,Zl,+new Date,e,"",t)}))}_rtcProcessFailHandle(e,t){const i=this._callEngine.getLocalMainSession();if(i){const r=i.getCallId();this._callEngine.systemStatusUp({callId:r,sysStatus:e,forward:nc.CURRENT},t),this._callPlusStatistics.reportStatisticsData(k_.L_QS_ABNORMAL_HANGUP_S,Zl,+new Date,i),this.__innerHangup({callId:r,systemState:e},t)}}_peerConnectionAbnormalClose(e){const t=this._callEngine.getLocalMainSession();t&&(this._callEngine.systemStatusUp({callId:t.getCallId(),sysStatus:I_.CONNECTION_ERR,forward:nc.CURRENT},e),this._callEngine.endCurrentSession(I_.CONNECTION_ERR,t.getCallId(),e))}_selfJoinedHandle(e,t,i){return m(this,void 0,void 0,(function*(){const r=this._rtcPluginContext.getCurrentId(),n=this._callEngine.getLocalMainSession();((null==n?void 0:n.getCallType())===g_.MULTI||t.length)&&this._callEngine.updateMainSessionState(f_.ONCALL);const s=[r,...t].map((e=>({userId:e,userState:p_.ONCALL,systemState:I_.ONCALL}))),o=this._callEngine.updateUsersState(e,s,i);this._reportAppEventModule.onCallConnected(n),o.length>0&&this._callEngine.reportRemoteUserStateChange(e,o,i),this._callEngine.startTimeCorrection(i)}))}_otherJoinedHandle(e,t){var i;let r="";const n=e.map((e=>(r=e.callId,{userId:e.userId,userState:p_.ONCALL,systemState:I_.ONCALL}))),s=this._callEngine.updateUsersState(r,n,t);s.length>0&&this._callEngine.reportRemoteUserStateChange(r,s,t),(null===(i=this._callEngine.getLocalMainSession())||void 0===i?void 0:i.getState())!==f_.ONCALL&&this._callEngine.updateMainSessionState(f_.ONCALL)}_receiveFirstFrameHandle(e){var t;(null===(t=this._callEngine.getLocalMainSession())||void 0===t?void 0:t.getState())!==f_.ONCALL&&this._callEngine.updateMainSessionState(f_.ONCALL),this._callEngine.upFirstFrameTime(e)}_kickoffHandle(e,t,i){if(e===I_.CONNECTION_ERR)return void this._callEngine.endCurrentSession(e,t,i);const r=this._callEngine.getLocalMainSession();if(r){const n=r.getCallId();this._callPlusStatistics.reportStatisticsData(k_.L_QS_ABNORMAL_HANGUP_S,Zl,+new Date,r,this._clientCallId),this._callEngine.systemStatusUp({callId:n,sysStatus:e,forward:nc.CURRENT},i),this._callEngine.endCurrentSession(e,t,i)}}_sessionCloseHandle(e,t){this._isLaunchHangup||(this._clientCallId=""),this._isLaunchHangup=!1,this._rtcModule.sessionClose(e,t)}setCallPlusEventListener(e){this._logger.info(u_.L_CALLPLUS_CLIENT_SET_EVENT_LISTENER_O,e?Object.keys(e).join(","):null),this._reportAppEventModule.registerEventListener(e)}setStatusReportListener(e){this._logger.info(u_.L_CALLPLUS_CLIENT_SET_STATUS_REPORT_LISTENER_O,e?Object.keys(e).join(","):null),this._rtcModule.setCallPlusStatusReportListener(e)}setVideoView(e){const t=this._logger.createTraceId();if(this._logger.info(u_.L_CALLPLUS_CLIENT_SET_VIDEO_VIEW_T,JSON.stringify({list:e.map((e=>{const{userId:t,videoElement:i,isTiny:r}=e;return{userId:t,elementName:null==i?void 0:i.nodeName,isTiny:r}}))}),t),!A(e))return this._logger.error(u_.L_CALLPLUS_CLIENT_SET_VIDEO_VIEW_R,`params err, list: not empty array, value: ${JSON.stringify(e)}`,t),{code:Xl};for(const r of e){const{userId:e,videoElement:n}=r;if(!b(e))return this._logger.error(u_.L_CALLPLUS_CLIENT_SET_VIDEO_VIEW_R,`params err, userId: not empty string, value: ${e}`,t),{code:Xl};if(!(i=n)||!i.nodeName||"VIDEO"!==i.nodeName.toUpperCase())return this._logger.error(u_.L_CALLPLUS_CLIENT_SET_VIDEO_VIEW_R,`params err, videoElement: need a video element, value: ${n instanceof HTMLElement?n.nodeName:n}`,t),{code:Xl}}var i;return this._logger.info(u_.L_CALLPLUS_CLIENT_SET_VIDEO_VIEW_R,"succes",t),this._rtcModule.setVideoView(e,t),{code:Zl}}removeVideoView(e){const t=this._logger.createTraceId();return this._logger.info(u_.L_CALLPLUS_CLIENT_REMOVE_VIDEO_VIEW_T,JSON.stringify({userIds:e}),t),A(e)&&e.every((e=>b(e)))?(this._logger.info(u_.L_CALLPLUS_CLIENT_REMOVE_VIDEO_VIEW_R,"succes",t),this._rtcModule.removeVideoView(e,t),{code:Zl}):(this._logger.error(u_.L_CALLPLUS_CLIENT_REMOVE_VIDEO_VIEW_R,`params err, userIds: not empty array, userId: not empty string, value: ${JSON.stringify(e)}`,t),{code:Xl})}playMedia(e,t){return m(this,void 0,void 0,(function*(){const i=this._logger.createTraceId();if(this._logger.info(u_.L_CALLPLUS_CLIENT_PLAY_MEDIA_T,JSON.stringify({userId:e,mediaType:t}),i),!b(e))return this._logger.error(u_.L_CALLPLUS_CLIENT_PLAY_MEDIA_R,`params err, userId: not empty string, value: ${e}`,i),{code:Xl};if(P(h_[t]))return this._logger.error(u_.L_CALLPLUS_CLIENT_PLAY_MEDIA_R,`params err, mediaType is illegal, value: ${t}`,i),{code:Xl};if(t===h_.AUDIO&&e===this._rtcPluginContext.getCurrentId())return this._logger.info(u_.L_CALLPLUS_CLIENT_PLAY_MEDIA_R,"success",i),{code:Zl};const{videoView:r}=this._rtcModule.getUserViewMap()[e]||{};return t===h_.AUDIO||r?this._rtcModule.playMedia(e,t,r,i):(this._logger.error(u_.L_CALLPLUS_CLIENT_PLAY_MEDIA_R,`errCode: ${d_}, video view not set`,i),{code:d_})}))}createVideoConfigBuilder(){return new S_(this._logger)}setVideoConfig(e){this._logger.info(u_.L_CALLPLUS_CLIENT_SET_VIDEO_CONFIG_T,JSON.stringify(e));const{frameRate:t,resolution:i,maxBitrate:r,minBitrate:n}=e;if(!Lt[t])return this._logger.error(u_.L_CALLPLUS_CLIENT_SET_VIDEO_CONFIG_R,`param error, frameRate is illegal, value: ${t}`),{code:Xl};if(!Ot[i])return this._logger.error(u_.L_CALLPLUS_CLIENT_SET_VIDEO_CONFIG_R,`param error, resolution is illegal, value: ${i}`),{code:Xl};const{code:s,errorMsg:o}=O_(n,r);return s!==Zl&&this._logger.error(u_.L_CALLPLUS_CLIENT_SET_VIDEO_CONFIG_R,o),this._logger.info(u_.L_CALLPLUS_CLIENT_SET_VIDEO_CONFIG_R,"success"),this._videoConfig=Object.assign({},e),this._rtcModule.setVideoConfig(this._videoConfig),{code:Zl}}createAudioConfigBuilder(){return new R_(this._logger)}createAndroidPushConfigBuilder(){return new hc(this._logger)}setAudioConfig(e){this._logger.info(u_.L_CALLPLUS_CLIENT_SET_AUDIO_CONFIG_T,JSON.stringify(e));const{sampleRate:t,minBitrate:i,maxBitrate:r}=e;if(t&&!O(t))return this._logger.error(u_.L_CALLPLUS_CLIENT_SET_AUDIO_CONFIG_R,`param error, sampleRate: type is number, value: ${t}`),{code:Xl};const{code:n,errorMsg:s}=O_(i,r);return n!==Zl&&this._logger.error(u_.L_CALLPLUS_CLIENT_SET_AUDIO_CONFIG_R,s),this._logger.info(u_.L_CALLPLUS_CLIENT_SET_AUDIO_CONFIG_R,"success"),this._audioConfig=Object.assign({},e),this._rtcModule.setAudioConfig(this._audioConfig),{code:Zl}}setAudioOutputDeviceId(e){return this._logger.info(u_.L_CALLPLUS_CLIENT_SET_AUDIO_OUTPUT_DEVICE_ID_O,e),this._rtcModule.setAudioOutputDeviceId(e)}startCall(e){return m(this,arguments,void 0,(function*(e,t=g_.SINGLE,i=h_.AUDIO_VIDEO,r,n,s){var o;this._clientCallId=J.gen();const a=+new Date,_=this._logger.createTraceId();if(this._logger.info(u_.L_CALLPLUS_CLIENT_START_CALL_T,`userIds: ${e.join(",")}, callType: ${t}, mediaType: ${i}, pushConfig: ${r}, extra: ${n}`,_),this._rtcPluginContext.getConnectionStatus()!==l.CONNECTED)return this._logger.error(u_.L_CALLPLUS_CLIENT_START_CALL_R,`errCode: ${o_}`,_),{code:o_};const c=this._rtcPluginContext.getNaviInfo();if(!c||!L_(c))return this._logger.error(u_.L_CALLPLUS_CLIENT_START_CALL_R,`errCode: ${n_}`,_),{code:n_};if(!A(e)||!e.every((e=>b(e))))return this._logger.error(u_.L_CALLPLUS_CLIENT_START_CALL_R,`params err, userIds: not empty array, userId: not empty string, value: ${JSON.stringify(e)}`,_),{code:Xl};if(P(g_[t]))return this._logger.error(u_.L_CALLPLUS_CLIENT_START_CALL_R,`params err, callType is illegal, value: ${t}`,_),{code:Xl};if(P(h_[i]))return this._logger.error(u_.L_CALLPLUS_CLIENT_START_CALL_R,`params err, mediaType is illegal, value: ${i}`,_),{code:Xl};if(r){const e=N_(r);if(e.code!==Zl)return this._logger.error(u_.L_CALLPLUS_CLIENT_START_CALL_R,`params err, pushConfig is illegal, msg: ${e.errorMsg}`,_),{code:Xl}}if(n){if(!C(n))return this._logger.error(u_.L_CALLPLUS_CLIENT_START_CALL_R,`params err, extra is illegal, type: string, value: ${n}`,_),{code:Xl};if(U_(n)>z_)return this._logger.error(u_.L_CALLPLUS_CLIENT_START_CALL_R,"params err, extra max size is 128KB",_),{code:Xl}}if(e.length>1&&t===g_.SINGLE)return this._logger.error(u_.L_CALLPLUS_CLIENT_START_CALL_R,`params err, You can only call one person in a single call, userIds: ${e.join(",")}`,_),{code:Xl};if(s&&!C(s))return this._logger.error(u_.L_CALLPLUS_CLIENT_START_CALL_R,`params err, targetId is illegal, type: string, value: ${s}`,_),{code:Xl};if(this._callEngine.getLocalMainSession())return this._logger.error(u_.L_CALLPLUS_CLIENT_START_CALL_R,`errCode: ${e_}, session exist`,_),{code:e_};const{code:d}=yield this._rtcModule.createCallMediaTracks(i,_);if(d!==Zl)return this._logger.error(u_.L_CALLPLUS_CLIENT_START_CALL_R,`create meida tracks error code: ${d}`,_),{code:d};const{code:u,data:h}=yield this._callEngine.startCall({toUsers:e.map((e=>({userId:e}))),callType:t,mediaType:i,callId:this._clientCallId,pushConfig:r,extra:JSON.stringify({userId:this._rtcPluginContext.getCurrentId(),extra:n}),targetId:s},_);if(this._callPlusStatistics.reportStatisticsData(k_.L_QS_START_CALL_S,u,a,null,this._clientCallId,null,{mediaType:i,callType:t,callId:(null==h?void 0:h.callId)||""}),u!==Zl)return this._rtcModule.destroyAllTracks(_),this._logger.error(u_.L_CALLPLUS_CLIENT_START_CALL_R,`signal error code: ${u}`,_),{code:u};const g=[];(null===(o=h.busylineUsers)||void 0===o?void 0:o.length)&&g.push(...h.busylineUsers.map((e=>({userId:e.userId,state:e.sessionStatus}))));const{callId:p,clientCallId:f}=h;return this._needHangupCallId===f?(this._callEngine.clearAllTimer(p,_),this._callEngine.hangup({callId:p,systemState:I_.CANCELLED},_),this._logger.info(u_.L_CALLPLUS_CLIENT_START_CALL_R,`the ${p} call has been hangup`,_),{code:Zl,busyUsers:g}):(t===g_.MULTI&&this._rtcModule.sessionConnected(p,_),this._logger.info(u_.L_CALLPLUS_CLIENT_START_CALL_R,JSON.stringify({data:h,code:u}),_),{code:Zl,callId:p,busyUsers:g})}))}joinMultiCall(e){return m(this,void 0,void 0,(function*(){const t=this._logger.createTraceId();if(this._logger.info(u_.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_T,`callId: ${e}`,t),this._rtcPluginContext.getConnectionStatus()!==l.CONNECTED)return this._logger.error(u_.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_R,`code: ${o_}`,t),{code:o_};const i=this._rtcPluginContext.getNaviInfo();if(!i||!L_(i))return this._logger.error(u_.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_R,`code: ${n_}`,t),{code:n_};if(!b(e))return this._logger.error(u_.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_R,`params err, callId: not empty string, value: ${e}`,t),{code:Xl};const{code:r,data:n}=yield this._callEngine.getCallSession({callId:e},t);if(r!==Zl)return this._logger.error(u_.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_R,`get call data error, code: ${r}`,t),{code:r};const{mediaType:s}=n,o=this._callEngine.getLocalMainSession();if(o&&o.getCallId()!==e)return{code:e_};const{code:a}=yield this._rtcModule.createCallMediaTracks(s,t);if(a!==Zl)return this._logger.error(u_.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_R,`create meida tracks error code: ${a}`,t),{code:a};const{code:_}=yield this._callEngine.joinCall({callId:e,mediaType:s},t);return _!==Zl?(this._rtcModule.destroyAllTracks(t),this._logger.error(u_.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_R,`signal error code: ${_}`,t),{code:_}):(this._logger.info(u_.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_R,`code: ${Zl}`,t),yield this._rtcModule.sessionConnected(e,t),{code:Zl})}))}invite(e,t,i){return m(this,void 0,void 0,(function*(){var r;const n=this._logger.createTraceId();if(this._logger.info(u_.L_CALLPLUS_CLIENT_INVITE_T,`callId: ${e.join(",")}, pushConfig: ${t}, extra: ${i}`,n),!A(e)||!e.every((e=>b(e))))return this._logger.error(u_.L_CALLPLUS_CLIENT_INVITE_R,`params err, userIds: not empty array, userId: not empty string, value: ${JSON.stringify(e)}`,n),{code:Xl};if(t){const e=N_(t);if(e.code!==Zl)return this._logger.error(u_.L_CALLPLUS_CLIENT_INVITE_R,`params err, pushConfig is illegal, msg: ${e.errorMsg}`,n),{code:Xl}}if(i){if(!C(i))return this._logger.error(u_.L_CALLPLUS_CLIENT_INVITE_R,`params err, extra is illegal, value: ${i}`,n),{code:Xl};if(U_(i)>z_)return this._logger.error(u_.L_CALLPLUS_CLIENT_INVITE_R,"params err, extra max size is 128KB",n),{code:Xl}}const{code:s,data:o}=yield this._callEngine.invite({toUsers:e.map((e=>({userId:e}))),pushConfig:t,extra:JSON.stringify({userId:this._rtcPluginContext.getCurrentId(),extra:i})},n);if(s!==Zl)return this._logger.error(u_.L_CALLPLUS_CLIENT_INVITE_R,`signal error code: ${s}`,n),{code:s};const a=[];return(null===(r=o.busylineUsers)||void 0===r?void 0:r.length)&&a.push(...o.busylineUsers.map((e=>({userId:e.userId,state:e.sessionStatus})))),this._logger.info(u_.L_CALLPLUS_CLIENT_INVITE_R,`success busyUsers: ${JSON.stringify(a)}`,n),{code:Zl,busyUsers:a}}))}accept(e,t){return m(this,void 0,void 0,(function*(){const i=+new Date,r=this._logger.createTraceId();if(this._logger.info(u_.L_CALLPLUS_CLIENT_ACCEPT_T,`callId: ${e}, pushConfig: ${t}`,r),this._rtcPluginContext.getConnectionStatus()!==l.CONNECTED)return this._logger.error(u_.L_CALLPLUS_CLIENT_ACCEPT_R,`errCode: ${o_}`,r),{code:o_};const n=this._rtcPluginContext.getNaviInfo();if(!n||!L_(n))return this._logger.error(u_.L_CALLPLUS_CLIENT_ACCEPT_R,`errCode: ${n_}`,r),{code:n_};if(!b(e))return this._logger.error(u_.L_CALLPLUS_CLIENT_ACCEPT_R,`params err, callId: not empty string, value: ${e}`,r),{code:Xl};if(t){const e=N_(t);if(e.code!==Zl)return this._logger.error(u_.L_CALLPLUS_CLIENT_ACCEPT_R,`params err, pushConfig is illegal, msg: ${e.errorMsg}`,r),{code:Xl}}let s=this._callEngine.getLocalMainSession();const o=this._callEngine.getHoldSession(e);if(!s&&!o)return this._logger.error(u_.L_CALLPLUS_CLIENT_ACCEPT_R,`errCode : ${t_}, session not exist`,r),{code:t_};if(e===(null==o?void 0:o.getCallId())){const{code:t}=yield this.hangup(s.getCallId());if(t!==Zl)return this._logger.error(u_.L_CALLPLUS_CLIENT_ACCEPT_R,`hangup mainSession error code: ${t}`,r),{code:t};this._callEngine.upgradeMainSession(e),s=this._callEngine.getLocalMainSession()}const a=s.getMediaType(),{code:_}=yield this._rtcModule.createCallMediaTracks(a,r);if(_!==Zl)return this._logger.error(u_.L_CALLPLUS_CLIENT_ACCEPT_R,`create meida tracks error code: ${_}`,r),{code:_};const{code:c}=yield this._callEngine.accept({callId:e},r);return this._callPlusStatistics.reportStatisticsData(k_.L_QS_ACCEPT_CALL_S,c,i,s),c!==Zl?(this._rtcModule.destroyAllTracks(r),this._logger.error(u_.L_CALLPLUS_CLIENT_ACCEPT_R,`signal error code: ${c}`,r),{code:c}):(this._logger.info(u_.L_CALLPLUS_CLIENT_ACCEPT_R,"success",r),this._rtcModule.sessionConnected(e,r),{code:Zl})}))}__innerHangup(e,t){return m(this,void 0,void 0,(function*(){var i;const{callId:r}=e;this._callEngine.setIsLocalClientHangup(!0),this._callEngine.clearAllTimer(r,t);const{code:n}=yield this._callEngine.hangup(e,t);return n===cc.CALL_NOT_EXIST?{code:Zl}:(n===Zl&&r===(null===(i=this._callEngine.getLocalMainSession())||void 0===i?void 0:i.getCallId())&&(yield this._rtcModule.sessionClose(r,t)),{code:n})}))}hangup(e,t){return m(this,void 0,void 0,(function*(){const i=+new Date,r=this._logger.createTraceId();this._logger.info(u_.L_CALLPLUS_CLIENT_HANGUP_T,`callId: ${e}, pushConfig: ${t}`,r);const n=this._callEngine.getLocalMainSession();if(!n)return{code:t_};if(e&&!C(e))return this._logger.error(u_.L_CALLPLUS_CLIENT_HANGUP_R,`params err, callId: type is string, value: ${e}`,r),{code:Xl};if(t){const e=N_(t);if(e.code!==Zl)return this._logger.error(u_.L_CALLPLUS_CLIENT_HANGUP_R,`params err, pushConfig is illegal, msg: ${e.errorMsg}`,r),{code:Xl}}const s=n.getCallId();if(e&&e!==s&&!this._callEngine.getHoldSession(e))return this._logger.error(u_.L_CALLPLUS_CLIENT_HANGUP_R,`params err, callId is invalid, value: ${e}`,r),{code:s_};this._isLaunchHangup=!0,this._needHangupCallId=e||s;const o=this._callEngine.getHoldSession(this._needHangupCallId)||n,a=this._rtcPluginContext.getCurrentId(),l=((e,t)=>{let i;switch(e){case p_.CALLING:i=I_.CANCELLED;break;case p_.RINGING:case p_.INVITED:i=I_.DECLINED;break;case p_.CONNECTING:i=t?I_.DECLINED:I_.CANCELLED;break;case p_.ONCALL:i=I_.ENDED}return i})(n.getUserList().filter((e=>e.userId===a))[0].state,[n.getCreatorUserId(),n.getInviterUserId()].includes(a))||I_.ENDED,{code:_}=yield this.__innerHangup({callId:this._needHangupCallId,systemState:l,pushConfig:t},r);return this._callPlusStatistics.reportStatisticsData(k_.L_QS_HANGUP_CALL_S,_,i,o,this._clientCallId),_!==Zl?(this._logger.error(u_.L_CALLPLUS_CLIENT_HANGUP_R,`signal error code : ${_}`,r),{code:_}):(this._needHangupCallId=null,this._logger.info(u_.L_CALLPLUS_CLIENT_HANGUP_R,"success",r),{code:Zl})}))}requestChangeMediaType(e){return m(this,void 0,void 0,(function*(){const t=this._logger.createTraceId();if(this._logger.info(u_.L_CALLPLUS_CLIENT_REQUEST_CHANGE_MEDIA_TYPE_T,`mediaType: ${e}`,t),P(h_[e]))return this._logger.error(u_.L_CALLPLUS_CLIENT_REQUEST_CHANGE_MEDIA_TYPE_R,`params err, mediaType is illegal, value: ${e}`,t),{code:Xl};const i=this.getCurrentCallSession(),r=null==i?void 0:i.getMediaType();if(e===r)return this._logger.error(u_.L_CALLPLUS_CLIENT_REQUEST_CHANGE_MEDIA_TYPE_R,`error code: ${i_}`,t),{code:i_};if(!this._callEngine.getLocalMainSession())return this._logger.error(u_.L_CALLPLUS_CLIENT_REQUEST_CHANGE_MEDIA_TYPE_R,`error code : ${t_}, session not exist`,t),{code:t_};const n=null==i?void 0:i.getUserList().filter((e=>e.userId!==this._rtcPluginContext.getCurrentId())).map((e=>e.userId)),{code:s,data:o}=yield this._callEngine.requestChangeMediaType({mediaType:e,toUserIds:n||[]},t);return s!==Zl?(this._logger.error(u_.L_CALLPLUS_CLIENT_REQUEST_CHANGE_MEDIA_TYPE_R,`signal error code: ${s}`,t),{code:s}):(this._logger.info(u_.L_CALLPLUS_CLIENT_REQUEST_CHANGE_MEDIA_TYPE_R,`success transactionId: ${o.transactionId}`,t),{code:Zl,transactionId:o.transactionId})}))}cancelChangeMediaType(e){return m(this,void 0,void 0,(function*(){const t=this._logger.createTraceId();if(this._logger.info(u_.L_CALLPLUS_CLIENT_CANCEL_CHANGE_MEDIA_TYPE_T,`transactionId: ${e}`,t),!b(e))return this._logger.error(u_.L_CALLPLUS_CLIENT_CANCEL_CHANGE_MEDIA_TYPE_R,`param error, transactionId: not empty string, value: ${e}`,t),{code:Xl};if(!this._callEngine.getLocalMainSession())return this._logger.error(u_.L_CALLPLUS_CLIENT_CANCEL_CHANGE_MEDIA_TYPE_R,`error code : ${t_}, session not exist`,t),{code:t_};const{code:i}=yield this._callEngine.cancelChangeMediaType({transactionId:e},t);return i!==Zl?(this._logger.error(u_.L_CALLPLUS_CLIENT_CANCEL_CHANGE_MEDIA_TYPE_R,`signal error code: ${i}`,t),{code:i}):(this._logger.info(u_.L_CALLPLUS_CLIENT_CANCEL_CHANGE_MEDIA_TYPE_R,"success",t),{code:Zl})}))}replyChangeMediaType(e,t){return m(this,void 0,void 0,(function*(){const i=this._logger.createTraceId();if(this._logger.info(u_.L_CALLPLUS_CLIENT_REPLY_CHANGE_MEDIA_TYPE_T,`transactionId: ${e}`,i),!b(e))return this._logger.error(u_.L_CALLPLUS_CLIENT_REPLY_CHANGE_MEDIA_TYPE_R,`param error, transactionId: not empty string, value: ${e}`,i),{code:Xl};if(!L(t))return this._logger.error(u_.L_CALLPLUS_CLIENT_REPLY_CHANGE_MEDIA_TYPE_R,`param error, isAgree: type is boolean, value: ${t}`,i),{code:Xl};if(!this._callEngine.getLocalMainSession())return this._logger.error(u_.L_CALLPLUS_CLIENT_REPLY_CHANGE_MEDIA_TYPE_R,`error code : ${t_}, session not exist`,i),{code:t_};const{code:r}=yield this._callEngine.responseChangeMediaType({transactionId:e,agree:t},i);return r!==Zl?(this._logger.error(u_.L_CALLPLUS_CLIENT_REPLY_CHANGE_MEDIA_TYPE_R,`signal error: ${r}`,i),{code:r}):(this._logger.info(u_.L_CALLPLUS_CLIENT_REPLY_CHANGE_MEDIA_TYPE_R,"success",i),{code:Zl})}))}getCurrentCallSession(){return this._callEngine.getLocalMainSession()}getAvailableCallRecordsFromServer(){return m(this,void 0,void 0,(function*(){const e=this._logger.createTraceId();this._logger.info(u_.L_CALLPLUS_CLIENT_GET_AVAILABLE_CALL_RECORDS_FROM_SERVER_T,"",e);const{code:t,data:i}=yield this._callEngine.getOpenCallList(e);return t!==Zl?(this._logger.error(u_.L_CALLPLUS_CLIENT_GET_AVAILABLE_CALL_RECORDS_FROM_SERVER_R,`signal error code: ${t}`,e),{code:t}):(this._logger.info(u_.L_CALLPLUS_CLIENT_GET_AVAILABLE_CALL_RECORDS_FROM_SERVER_R,`success, data: ${JSON.stringify(i)}`,e),{code:Zl,records:i})}))}getCallRecords(e,t){return m(this,arguments,void 0,(function*(e,t,i=0){const r=this._logger.createTraceId();if(this._logger.info(u_.L_CALLPLUS_CLIENT_GET_CALL_RECORDS_T,`startTimestamp: ${e}, count: ${t}`,r),!(O(e)&&e>=0))return this._logger.error(u_.L_CALLPLUS_CLIENT_GET_CALL_RECORDS_R,`params error, startTimestamp: is a number >= 0, value: ${e}`,r),{code:Xl};if(!(O(t)&&t>0))return this._logger.error(u_.L_CALLPLUS_CLIENT_GET_CALL_RECORDS_R,`params error, count: is a number >= 0, value: ${t}`,r),{code:Xl};const{code:n,data:s}=yield this._callEngine.getCallLogList({timestamp:e,count:t,order:i},r);return n!==Zl?(this._logger.error(u_.L_CALLPLUS_CLIENT_GET_CALL_RECORDS_R,`signal error code: ${n}`,r),{code:n}):(this._logger.info(u_.L_CALLPLUS_CLIENT_GET_CALL_RECORDS_R,"success",r),{code:Zl,result:s})}))}deleteCallRecordsFromServer(e){return m(this,void 0,void 0,(function*(){const t=this._logger.createTraceId();if(this._logger.info(u_.L_CALLPLUS_CLIENT_DELETE_CALL_RECORDS_BY_CALLID_T,`callIds: ${e.join(",")}`,t),!A(e)||!e.every((e=>b(e))))return this._logger.error(u_.L_CALLPLUS_CLIENT_DELETE_CALL_RECORDS_BY_CALLID_R,`params err, callIds: not empty array, callId: not empty string, callIds: ${JSON.stringify(e)}`,t),{code:Xl};const{code:i}=yield this._callEngine.deleteCallLog(e,t);return i!==Zl?(this._logger.error(u_.L_CALLPLUS_CLIENT_DELETE_CALL_RECORDS_BY_CALLID_R,`signal error code: ${i}`,t),{code:i}):(this._logger.info(u_.L_CALLPLUS_CLIENT_DELETE_CALL_RECORDS_BY_CALLID_R,"success",t),{code:Zl})}))}deleteAllCallRecordsFromServer(){return m(this,void 0,void 0,(function*(){const e=this._logger.createTraceId();this._logger.info(u_.L_CALLPLUS_CLIENT_DELETE_ALL_CALL_RECORDS_FROM_SERVER_T,"",e);const{code:t}=yield this._callEngine.removeAllCallLog(e);return t!==Zl?(this._logger.error(u_.L_CALLPLUS_CLIENT_DELETE_ALL_CALL_RECORDS_FROM_SERVER_R,`signal error code: ${t}`,e),{code:t}):(this._logger.info(u_.L_CALLPLUS_CLIENT_DELETE_ALL_CALL_RECORDS_FROM_SERVER_R,"success",e),{code:Zl})}))}startCamera(){return m(this,void 0,void 0,(function*(){var e;const t=this._logger.createTraceId();this._logger.info(u_.L_CALLPLUS_CLIENT_START_CAMERA_T,"",t);const{code:i,track:r}=yield this._rtcModule.getCameraVideoTrack(t);if(i!==Zl)return this._logger.error(u_.L_CALLPLUS_CLIENT_START_CAMERA_R,`create video track error code: ${i}`,t),{code:i};if(!(null==r?void 0:r.isPublished())&&(null===(e=this._callEngine.getLocalMainSession())||void 0===e?void 0:e.getState())===f_.ONCALL){const{code:e}=yield this._rtcModule.publishVideoTrack();return e!==ae.SUCCESS?(this._logger.error(u_.L_CALLPLUS_CLIENT_START_CAMERA_R,`publish error code: ${e}`,t),{code:e}):(this._logger.info(u_.L_CALLPLUS_CLIENT_START_CAMERA_R,"success",t),{code:Zl})}const{code:n}=yield this._rtcModule.enableVideoTrack(t);return n!==ae.SUCCESS&&n!==Zl?(this._logger.error(u_.L_CALLPLUS_CLIENT_START_CAMERA_R,`signal error code: ${n}`,t),{code:n}):(this._logger.info(u_.L_CALLPLUS_CLIENT_START_CAMERA_R,"success",t),{code:Zl})}))}stopCamera(){return m(this,void 0,void 0,(function*(){const e=this._logger.createTraceId();this._logger.info(u_.L_CALLPLUS_CLIENT_STOP_CAMERA_T,"",e);const{code:t,track:i}=yield this._rtcModule.disableVideoTrack();return t!==Zl&&t!==ae.SUCCESS?(this._logger.error(u_.L_CALLPLUS_CLIENT_STOP_CAMERA_R,`error code: ${t}`,e),{code:t}):(this._rtcModule.destroyTrack(i),this._logger.info(u_.L_CALLPLUS_CLIENT_STOP_CAMERA_R,"success",e),{code:Zl})}))}switchCamera(e){return m(this,void 0,void 0,(function*(){const t=this._logger.createTraceId();if(this._logger.info(u_.L_CALLPLUS_CLIENT_SWITCH_CAMERA_T,`cameraId: ${e}`,t),!b(e))return this._logger.error(u_.L_CALLPLUS_CLIENT_SWITCH_CAMERA_R,`param error, cameraId: not empty string, value: ${e}`,t),{code:Xl};const i=this._callEngine.getLocalMainSession();if(!i)return this._logger.error(u_.L_CALLPLUS_CLIENT_SWITCH_CAMERA_R,`errCode: ${t_}`,t),{code:t_};if(i.getMediaType()===h_.AUDIO)return this._logger.error(u_.L_CALLPLUS_CLIENT_SWITCH_CAMERA_R,`errCode: ${r_}`,t),{code:r_};this._videoConfig.cameraId=e,this._rtcModule.setVideoConfig(this._videoConfig);const{code:r}=yield this._rtcModule.changeVideoDevice(t);return r!==Zl?(this._logger.error(u_.L_CALLPLUS_CLIENT_SWITCH_CAMERA_R,`call client changeVideoDevice error code: ${r}`,t),{code:r}):(this._logger.info(u_.L_CALLPLUS_CLIENT_SWITCH_CAMERA_R,"success",t),{code:Zl})}))}startMicrophone(){return m(this,void 0,void 0,(function*(){const e=this._logger.createTraceId();this._logger.info(u_.L_CALLPLUS_CLIENT_START_MICROPHONE_T,"",e);const{code:t,track:i}=yield this._rtcModule.getMicrophoneAudioTrack(e);if(t!==Zl)return this._logger.error(u_.L_CALLPLUS_CLIENT_START_MICROPHONE_R,`create microphone audio track error code: ${t}`,e),{code:t};if(!i.isOwnerMuted())return this._logger.info(u_.L_CALLPLUS_CLIENT_START_MICROPHONE_R,"success",e),{code:Zl};const r=yield i.unmute();return r!==ae.SUCCESS?(this._logger.error(u_.L_CALLPLUS_CLIENT_START_MICROPHONE_R,`signal error code: ${t}`,e),{code:r}):(this._logger.info(u_.L_CALLPLUS_CLIENT_START_MICROPHONE_R,"success",e),{code:Zl})}))}stopMicrophone(){return m(this,void 0,void 0,(function*(){const e=this._logger.createTraceId();this._logger.info(u_.L_CALLPLUS_CLIENT_STOP_MICROPHONE_T,"",e);const{code:t}=yield this._rtcModule.disableAudioTrack();return t!==Zl&&t!==ae.SUCCESS?(this._logger.error(u_.L_CALLPLUS_CLIENT_STOP_MICROPHONE_R,`signal error code: ${t}`,e),{code:t}):(this._logger.info(u_.L_CALLPLUS_CLIENT_STOP_MICROPHONE_R,"success",e),{code:Zl})}))}isMicrophoneEnabled(){const e=this._rtcModule.getLocalAudioTrack();return!!e&&!e.isOwnerMuted()}setAllRemoteAudioEnable(e){return m(this,void 0,void 0,(function*(){const t=this._logger.createTraceId();return this._rtcModule.setAllRemoteAudioEnable(e,t)}))}getVersion(){return"26.2.0-alpha.2"}getCameras(){return m(this,void 0,void 0,(function*(){return Ut()}))}getMicrophones(){return m(this,void 0,void 0,(function*(){return Dt()}))}getSpeakers(){return m(this,void 0,void 0,(function*(){return Mt()}))}getRTCSessionId(){return this._rtcModule.getRTCSessionId()}switchMicrophone(e){return m(this,void 0,void 0,(function*(){const t=this._logger.createTraceId();if(this._logger.info(u_.L_CALLPLUS_CLIENT_SWITCH_MICROPHONE_T,`microphoneId: ${e}`,t),!b(e))return this._logger.error(u_.L_CALLPLUS_CLIENT_SWITCH_MICROPHONE_R,`param error, microphoneId: not empty string, value: ${e}`,t),{code:Xl};if(!this._callEngine.getLocalMainSession())return this._logger.error(u_.L_CALLPLUS_CLIENT_SWITCH_MICROPHONE_R,`errCode: ${t_}`,t),{code:t_};this._audioConfig.microphoneId=e,this._rtcModule.setAudioConfig(this._audioConfig);const{code:i}=yield this._rtcModule.changeAudioDevice(t);return i!==Zl?(this._logger.error(u_.L_CALLPLUS_CLIENT_SWITCH_MICROPHONE_R,`call client changeAudioDevice error code: ${i}`,t),{code:i}):(this._logger.info(u_.L_CALLPLUS_CLIENT_SWITCH_MICROPHONE_R,"success",t),{code:Zl})}))}}class pc{constructor(e){Object.defineProperty(this,"_minBitrate",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_maxBitrate",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_innerVideoConfigBuilder",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._innerVideoConfigBuilder=new S_(e)}setFrameRate(e){return this._innerVideoConfigBuilder.setFrameRate(e),this}setResolution(e){return this._innerVideoConfigBuilder.setVideoResolution(e),this}setMinBitrate(e){return this._minBitrate=e,null!=this._maxBitrate&&this._innerVideoConfigBuilder.setBitrate(e,this._maxBitrate),this}setMaxBitrate(e){return this._maxBitrate=e,null!=this._minBitrate&&this._innerVideoConfigBuilder.setBitrate(this._minBitrate,e),this}build(){return this._innerVideoConfigBuilder.build()}}class fc{constructor(e){Object.defineProperty(this,"_innerAndroidPushConfigBuilder",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._innerAndroidPushConfigBuilder=new hc(e)}setChannelIdHW(e){return this._innerAndroidPushConfigBuilder.setChannelIdHW(e),this}setCategoryHW(e){return this._innerAndroidPushConfigBuilder.setCategoryHW(e),this}setImportanceHW(e){return this._innerAndroidPushConfigBuilder.setImportanceHW(e),this}setImageUrlHW(e){return this._innerAndroidPushConfigBuilder.setImageUrlHW(e),this}setChannelIdFCM(e){return this._innerAndroidPushConfigBuilder.setFcmChannelId(e),this}setCollapseKeyFCM(e){return this._innerAndroidPushConfigBuilder.setFcmCollapseKey(e),this}setImageUrlFCM(e){return this._innerAndroidPushConfigBuilder.setFcmImageUrl(e),this}build(){const e=this._innerAndroidPushConfigBuilder.build();return{channelIdHW:e.channelIdHW,categoryHW:e.categoryHW,importanceHW:e.importanceHW,imageUrlHW:e.imageUrlHW,channelIdFCM:e.fcmChannelId,collapseKeyFCM:e.fcmCollapseKey,imageUrlFCM:e.fcmImageUrl}}}const Ec={SUCCESS:0,PARAM_ERROR:80001,ON_CALLING:80002,NOT_IN_CALL:80003,MEDIA_TYPE_INVALID:80004,NOT_VIDEO_CALL:80005,VOIP_SERVICE_UNAVAILABLE:80006,USER_LIST_INVAILD:80007,CALL_ID_INVALID:80008,TRANSACTION_ID_INVALID:80009,USER_ID_INVALID:80010,SINGLE_CALL_NOT_SUPPORT_MULTI_PERSON:80011,CHAT_DISCONNECTED:80012,CAMERA_CLOSED:80100,MICROPHONE_CLOSED:80101,MEDIA_RESOURCE_INVALIED:80102,PLAY_MEDIA_FAILED:80104,VIDEO_VIEW_NOT_SET:80105};var Ic,Tc,mc,Rc,Sc,Cc,Lc,Oc,vc,bc,Ac;!function(e){e[e.CALL_OUT=-1]="CALL_OUT",e[e.GROUP=0]="GROUP",e[e.CALL_IN=1]="CALL_IN"}(Ic||(Ic={})),function(e){e[e.CANCEL_CHANGE_MEDIA_TYPE=0]="CANCEL_CHANGE_MEDIA_TYPE",e[e.REFUSE_CHANGE_MEDIA_TYPE=1]="REFUSE_CHANGE_MEDIA_TYPE",e[e.SERVER_ALLOW_MEDIA_TYPE=2]="SERVER_ALLOW_MEDIA_TYPE",e[e.CHANGE_MEDIA_TYPE_TIMEOUT=3]="CHANGE_MEDIA_TYPE_TIMEOUT"}(Tc||(Tc={})),function(e){e[e.AUDIO=0]="AUDIO",e[e.AUDIO_VIDEO=1]="AUDIO_VIDEO"}(mc||(mc={})),function(e){e[e.IDLE=0]="IDLE",e[e.CALLING=100]="CALLING",e[e.INVITED=101]="INVITED",e[e.RINGING=102]="RINGING",e[e.BUSY_LINE_RINGING=103]="BUSY_LINE_RINGING",e[e.BUSY_LINE_WAIT=104]="BUSY_LINE_WAIT",e[e.CONNECTING=200]="CONNECTING",e[e.ONCALL=300]="ONCALL",e[e.ON_PHONE=301]="ON_PHONE",e[e.ON_PHONE_END=302]="ON_PHONE_END",e[e.ON_DEVICE_DISABLE=303]="ON_DEVICE_DISABLE",e[e.ON_DEVICE_ENABLE=304]="ON_DEVICE_ENABLE",e[e.ABNORMAL_END=999]="ABNORMAL_END",e[e.ENDED=1e3]="ENDED",e[e.NO_ANSWER=1001]="NO_ANSWER",e[e.MISSED=1002]="MISSED",e[e.CANCELED=1003]="CANCELED",e[e.DECLINED=1004]="DECLINED",e[e.OTHER_CLIENT_CALLING=1010]="OTHER_CLIENT_CALLING",e[e.ACCEPT_BY_OTHER_CLIENT=1011]="ACCEPT_BY_OTHER_CLIENT",e[e.JOIN_ERROR=1105]="JOIN_ERROR",e[e.PUBLISH_ERROR=1106]="PUBLISH_ERROR",e[e.SUBSCRIBE_ERROR=1107]="SUBSCRIBE_ERROR",e[e.ACCEPT_CARRIER=1108]="ACCEPT_CARRIER",e[e.KICKED_BY_SERVER=1109]="KICKED_BY_SERVER",e[e.CONNECTION_ERROR=1110]="CONNECTION_ERROR",e[e.LOGOUT=1111]="LOGOUT",e[e.OTHER_CLIENT_LOGIN=1112]="OTHER_CLIENT_LOGIN",e[e.OTHER_CLIENT_JOINED=1113]="OTHER_CLIENT_JOINED",e[e.OTHER_CLIENT_ON_CALL=1114]="OTHER_CLIENT_ON_CALL",e[e.HANGUP_BY_OTHER_CLIENT=1151]="HANGUP_BY_OTHER_CLIENT",e[e.REMOTE_JOIN_ERROR=1205]="REMOTE_JOIN_ERROR",e[e.REMOTE_PUBLISH_ERROR=1206]="REMOTE_PUBLISH_ERROR",e[e.REMOTE_SUBSCRIBE_ERROR=1207]="REMOTE_SUBSCRIBE_ERROR",e[e.REMOTE_KICKED_BY_SERVER=1209]="REMOTE_KICKED_BY_SERVER",e[e.REMOTE_CONNECTION_ERROR=1210]="REMOTE_CONNECTION_ERROR",e[e.REMOTE_LOGOUT=1211]="REMOTE_LOGOUT",e[e.REMOTE_OTHER_CLIENT_LOGIN=1212]="REMOTE_OTHER_CLIENT_LOGIN",e[e.REMOTE_OTHER_JOINED=1213]="REMOTE_OTHER_JOINED",e[e.REMOTE_OTHER_CLIENT_ONCALL=1214]="REMOTE_OTHER_CLIENT_ONCALL"}(Rc||(Rc={})),function(e){e[e.IDLE=0]="IDLE",e[e.CALLING=100]="CALLING",e[e.INVITED=101]="INVITED",e[e.RINGING=102]="RINGING",e[e.BUSY_LINE_RINGING=103]="BUSY_LINE_RINGING",e[e.BUSY_LINE_WAIT=104]="BUSY_LINE_WAIT",e[e.CONNECTING=200]="CONNECTING",e[e.ONCALL=300]="ONCALL",e[e.ENDED=1e3]="ENDED",e[e.NOANSWER=1001]="NOANSWER",e[e.MISSED=1002]="MISSED",e[e.CANCELED=1003]="CANCELED",e[e.DECLINED=1004]="DECLINED",e[e.ERROR=2e3]="ERROR"}(Sc||(Sc={})),function(e){e[e.SINGLE=0]="SINGLE",e[e.MULTI=1]="MULTI"}(Cc||(Cc={})),function(e){e[e.ASC=0]="ASC",e[e.DESC=1]="DESC"}(Lc||(Lc={})),function(e){e.NORMAL="NORMAL",e.LOW="LOW"}(Oc||(Oc={})),function(e){e[e.IDLE=0]="IDLE",e[e.CALLING=100]="CALLING",e[e.INVITED=101]="INVITED",e[e.RINGING=102]="RINGING",e[e.BUSY_LINE_RINGING=103]="BUSY_LINE_RINGING",e[e.BUSY_LINE_WAIT=104]="BUSY_LINE_WAIT",e[e.CONNECTING=200]="CONNECTING",e[e.ONCALL=300]="ONCALL",e[e.ONPHONE=301]="ONPHONE",e[e.ENDED=1e3]="ENDED",e[e.NO_ANSWER=1001]="NO_ANSWER",e[e.MISSED=1002]="MISSED",e[e.CANCELED=1003]="CANCELED",e[e.DECLINED=1004]="DECLINED",e[e.ERROR=2e3]="ERROR"}(vc||(vc={})),function(e){e.FPS_10="FPS_10",e.FPS_15="FPS_15",e.FPS_24="FPS_24",e.FPS_30="FPS_30"}(bc||(bc={})),function(e){e.RESOLUTION_176X132="W176_H132",e.RESOLUTION_176X144="W176_H144",e.RESOLUTION_180X180="W180_H180",e.RESOLUTION_240X180="W240_H180",e.RESOLUTION_240X240="W240_H240",e.RESOLUTION_256X144="W256_H144",e.RESOLUTION_320X180="W320_H180",e.RESOLUTION_320X240="W320_H240",e.RESOLUTION_360X360="W360_H360",e.RESOLUTION_480X360="W480_H360",e.RESOLUTION_480X480="W480_H480",e.RESOLUTION_640X360="W640_H360",e.RESOLUTION_640X480="W640_H480",e.RESOLUTION_720X480="W720_H480",e.RESOLUTION_848X480="W848_H480",e.RESOLUTION_960X720="W960_H720",e.RESOLUTION_1280X720="W1280_H720",e.RESOLUTION_1920X1080="W1920_H1080",e.RESOLUTION_144X176="W144_H176",e.RESOLUTION_144X256="W144_H256",e.RESOLUTION_180X240="W180_H240",e.RESOLUTION_180X320="W180_H320",e.RESOLUTION_240X320="W240_H320",e.RESOLUTION_360X480="W360_H480",e.RESOLUTION_360X640="W360_H640",e.RESOLUTION_480X640="W480_H640",e.RESOLUTION_480X720="W480_H720",e.RESOLUTION_480X848="W480_H848",e.RESOLUTION_720X1280="W720_H1280",e.RESOLUTION_720X960="W720_H960",e.RESOLUTION_1080X1920="W1080_H1920"}(Ac||(Ac={}));class Nc{constructor(e,t){Object.defineProperty(this,"_session",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_currentUserId",{enumerable:!0,configurable:!0,writable:!0,value:t})}getCallId(){return this._session.getCallId()}getCallState(){return this._session.getState()}getCallType(){return this._session.getCallType()}getMediaType(){return this._session.getMediaType()===h_.AUDIO?mc.AUDIO:mc.AUDIO_VIDEO}getRemoteParticipants(){const e=this._session.getUserList().map((e=>({userId:e.userId,userState:e.state,isCameraEnabled:e.cameraEnable,isMicrophoneEnabled:e.microphoneEnable}))),t=this._currentUserId;return t?e.filter((e=>e.userId!==t)):e}getCallerUserId(){return this._session.getCreatorUserId()}getInviterUserId(){return this._session.getInviterUserId()}}function yc(e){return{logOutputLevel:e.logOutputLevel,isPubTiny:e.isPubLowResolutionStream}}function Pc(e){const t=e.mediaType===h_.AUDIO?mc.AUDIO:mc.AUDIO_VIDEO;return{callId:e.callId,callType:e.callType,callDirection:e.callDirection,mediaType:t,callerUserId:e.callerUserId,participants:e.callUserIds,callState:e.sessionState,currentUserState:e.userState,startTime:e.startTimestamp,endTime:e.endTimestamp,duration:e.duration,syncTime:e.syncTimestamp,endReason:e.systemState,creationTime:e.createTimestamp}}function Uc(e){return e===mc.AUDIO?h_.AUDIO:h_.AUDIO_VIDEO}function Dc(e){return e===h_.AUDIO?mc.AUDIO:mc.AUDIO_VIDEO}function Mc(e,t){const i=e.content,{messageDirection:r,sentTime:n}=e,{callId:s,callerUserId:o,targetId:a,callStartTime:l,callEndTime:_,mediaType:c,hangupReason:d}=i,u=_>0&&l>0?Math.max(0,Math.floor((_-l)/1e3)):0,h=1===r?Ic.CALL_OUT:Ic.CALL_IN,g=c===h_.AUDIO?mc.AUDIO:mc.AUDIO_VIDEO,p="number"==typeof n?n:0;return{callId:s,callType:Cc.SINGLE,callDirection:h,mediaType:g,callerUserId:o,participants:[t,a].filter(Boolean),callState:Sc.ENDED,currentUserState:vc.ENDED,startTime:l,endTime:_,duration:u,syncTime:p,endReason:d,creationTime:p}}r.add("nexconncall","26.2.0-alpha.2");const wc={tag:"NexconnCall",verify:()=>!!r.validEngine("26.2.0")||(console.error(`The current engine version '${r.getInfo().engine}' error, plugin-call-plus required engine version at least '26.2.0'.`),!1),setup:e=>S(e)};class kc{constructor(t){Object.defineProperty(this,"_client",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_callEventHandler",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_connectionQualityHandler",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_callPluginContext",{enumerable:!0,configurable:!0,writable:!0,value:null}),this._callPluginContext=e(wc,void 0);const i=e(zl,void 0);if(!this._callPluginContext||!i)throw new Error("Failed to install plugin context");const r=yc(t);this._callPluginContext.logger.setOutputLevel(t.logOutputLevel),this._client=new gc(se,r,this._callPluginContext,i)}static install(){}static initialize(e){const t=yc(e),i=(r=t)?N(r)?{isLegal:!0}:{isLegal:!1,msg:"Initialization options must be an object"}:{isLegal:!1,msg:"Initialization missing parameter -> options"};var r;if(!i.isLegal)throw new Error(`[CallPlusLib installer steup]${i.msg}`);return kc._instance||(kc._instance=new kc(e)),kc._instance}static getVersion(){return"26.2.0-alpha.2"}_getCurrentRtcUserId(){var e,t;return null!==(t=null===(e=this._callPluginContext)||void 0===e?void 0:e.getCurrentId())&&void 0!==t?t:""}applyClientStatusReportListener(e){this._client.setStatusReportListener(function(e,t){return{onSendPacketLoss(){},onReceivePacketLoss(){},onSendQualityChanged(i){var r,n,s;const o=null!==(n=i[null!==(r=null==t?void 0:t())&&void 0!==r?r:""])&&void 0!==n?n:Object.values(i)[0];null!=o&&(null===(s=e.onSendQualityChanged)||void 0===s||s.call(e,o))},onReceiveQualityChanged(t){var i;null===(i=e.onReceiveQualityChanged)||void 0===i||i.call(e,t)}}}(e,(()=>this._getCurrentRtcUserId())))}applyClientCallEventListener(e,t){const i=t?(e,i)=>{var r;return null===(r=t.onAudioVolumeChanged)||void 0===r?void 0:r.call(t,{[e]:i})}:void 0;this._client.setCallPlusEventListener(function(e,t,i,r){const n=e=>{var t;return new Nc(e,null!==(t=null==r?void 0:r())&&void 0!==t?t:"")},s={onReceivedCall:(t,i)=>e.onCallReceived({session:n(t),extra:i}),onCallEnded:(t,i)=>e.onCallEnded({session:n(t),reason:i}),onCallConnected:t=>e.onCallConnected({session:n(t)}),onReceivedCallPlusSummaryMessage:t=>{var i,n;const s=null!==(i=null==r?void 0:r())&&void 0!==i?i:"";null===(n=e.onLocalCallLogReceived)||void 0===n||n.call(e,{callLog:Mc(t,s)})},onReceivedCallRecord:t=>{var i;return null===(i=e.onServerCallLogReceived)||void 0===i?void 0:i.call(e,{callLog:Pc(t)})},onReceivedChangeMediaTypeRequest:(t,i,r)=>{var n;return null===(n=e.onMediaTypeChangeRequestReceived)||void 0===n?void 0:n.call(e,{userId:t,transactionId:i,mediaType:Dc(r)})},onReceivedChangeMediaTypeResult:t=>{var i;return null===(i=e.onMediaTypeChangeResultReceived)||void 0===i?void 0:i.call(e,{userId:t.userId,transactionId:t.transactionId,mediaType:Dc(t.mediaType),result:t.result})},onRemoteCameraStateChanged:(t,i,r)=>{var n;return null===(n=e.onRemoteCameraStateChanged)||void 0===n?void 0:n.call(e,{callId:t,userId:i,disabled:r})},onRemoteMicrophoneStateChanged:(t,i,r)=>{var n;return null===(n=e.onRemoteMicrophoneStateChanged)||void 0===n?void 0:n.call(e,{callId:t,userId:i,disabled:r})},onRemoteUserInvited:(t,i,r)=>{var n;return null===(n=e.onRemoteUserInvited)||void 0===n?void 0:n.call(e,{inviteeUserList:t,inviterUserId:i,callId:r})},onRemoteUserStateChanged:(t,i,r,n)=>{var s;null===(s=e.onRemoteUserStateChanged)||void 0===s||s.call(e,{callId:t,userId:i,userState:r,reason:n})},onUserMediaAvailable:(e,i)=>{var n;e===(null!==(n=null==r?void 0:r())&&void 0!==n?n:"")&&i===h_.AUDIO||t.playMedia(e,i)},onReceivedCallStartTime:t=>{var i;return null===(i=e.onStartTimeReceived)||void 0===i?void 0:i.call(e,{startTime:t.callStartTime})},onCallTypeChanged:(t,i)=>{var r;return null===(r=e.onCallTypeChanged)||void 0===r?void 0:r.call(e,{callId:i,callType:t})}};return i&&(s.onUserAudioLevelChanged=i),s}(e,this._client,i,(()=>this._getCurrentRtcUserId())))}setCallEventHandler(e){this._callEventHandler=e,this.applyClientCallEventListener(e,this._connectionQualityHandler)}setConnectionQualityHandler(e){this._connectionQualityHandler=e,this.applyClientStatusReportListener(e),this._callEventHandler&&this.applyClientCallEventListener(this._callEventHandler,e)}setLocalVideoView(e){return this._client.setVideoView([{userId:this._getCurrentRtcUserId(),videoElement:e.videoElement}])}setRemoteVideoView(e){return this._client.setVideoView(e.map((({userId:e,videoElement:t,enableLowResolutionStream:i})=>({userId:e,videoElement:t,isTiny:i}))))}removeVideoView(e){return this._client.removeVideoView(e)}createVideoConfigBuilder(){if(!this._callPluginContext)throw new Error("NCCallEngine not initialized. Please call initialize first.");return new pc(this._callPluginContext.logger)}setVideoConfig(e){return this._client.setVideoConfig({frameRate:(t=e).frameRate,resolution:t.resolution,minBitrate:t.minBitrate,maxBitrate:t.maxBitrate});var t}createAndroidPushConfigBuilder(){if(!this._callPluginContext)throw new Error("NCCallEngine not initialized. Please call initialize first.");return new fc(this._callPluginContext.logger)}startCall(e){const{calleeIds:t,callType:i,mediaType:r,pushConfig:n,extra:s,targetId:o}=e,a=Array.isArray(t)?t:[t];return this._client.startCall(a,i,Uc(r),n,s,o).then((e=>{var t;return{code:e.code,callId:e.callId,busyLineUserList:null===(t=e.busyUsers)||void 0===t?void 0:t.map((({userId:e,state:t})=>({userId:e,userState:t})))}}))}joinCall(e){return this._client.joinMultiCall(e.callId)}inviteToCall(e){const{calleeIds:t,pushConfig:i,extra:r}=e;return this._client.invite(t,i,r).then((e=>{var t;return{code:e.code,busyLineUserList:null===(t=e.busyUsers)||void 0===t?void 0:t.map((({userId:e,state:t})=>({userId:e,userState:t})))}}))}acceptCall(e){return this._client.accept(e.callId)}endCall(e){return this._client.hangup(null==e?void 0:e.callId,null==e?void 0:e.pushConfig)}requestChangeMediaType(e){return this._client.requestChangeMediaType(Uc(e.mediaType))}cancelChangeMediaType(e){return this._client.cancelChangeMediaType(e.transactionId)}replyChangeMediaType(e){return this._client.replyChangeMediaType(e.transactionId,e.isAgreed)}getCurrentCallSession(){const e=this._client.getCurrentCallSession();return e?new Nc(e,this._getCurrentRtcUserId()):null}getOngoingCallLogs(){return this._client.getAvailableCallRecordsFromServer().then((e=>{var t;return{code:e.code,logList:null===(t=e.records)||void 0===t?void 0:t.map((e=>Pc(e)))}}))}getHistoryCallLogs(e){const{startTime:t=-1,count:i,order:r=Lc.ASC}=e;return this._client.getCallRecords(t,i,r).then((e=>e.result?{code:e.code,callLogInfo:{hasMore:e.result.hasMore,callLogList:e.result.list.map((e=>Pc(e))),syncTime:e.result.syncTime}}:{code:e.code}))}deleteCallLogsForMe(e){return this._client.deleteCallRecordsFromServer(e.callIds)}deleteAllCallLogsForMe(){return this._client.deleteAllCallRecordsFromServer()}enableCamera(e){return e?this._client.startCamera():this._client.stopCamera()}selectVideoInputDevice(e){return this._client.switchCamera(e.deviceId)}enableMicrophone(e){return e?this._client.startMicrophone():this._client.stopMicrophone()}getAudioInputDevices(){return this._client.getMicrophones()}selectAudioInputDevice(e){return this._client.switchMicrophone(e.deviceId)}getAudioOutputDevices(){return this._client.getSpeakers()}selectAudioOutputDevice(e){return this._client.setAudioOutputDeviceId(e.deviceId)}getVideoInputDevices(){return this._client.getCameras()}isMicrophoneEnabled(){return this._client.isMicrophoneEnabled()}}Object.defineProperty(kc,"_instance",{enumerable:!0,configurable:!0,writable:!0,value:null});const xc={ERROR:1,WARN:2,INFO:3,DEBUG:4};var Bc=Object.freeze({__proto__:null,NCCallEngine:kc,NCCallSession:Nc,NCVideoConfigBuilder:pc,NCAndroidPushConfigBuilder:fc,NCCallLogLevel:xc,NCCallCode:Ec,get NCCallDirection(){return Ic},get NCCallMediaTypeChangeResult(){return Tc},get NCCallMediaType(){return mc},get NCCallEndReason(){return Rc},get NCCallState(){return Sc},get NCCallType(){return Cc},get NCCallLogOrder(){return Lc},get NCCallPushImportanceHW(){return Oc},get NCCallUserState(){return vc},get NCCallVideoFrameRate(){return bc},get NCCallVideoResolution(){return Ac}});export{Bc as NC,fc as NCAndroidPushConfigBuilder,Ec as NCCallCode,Ic as NCCallDirection,Rc as NCCallEndReason,kc as NCCallEngine,xc as NCCallLogLevel,Lc as NCCallLogOrder,mc as NCCallMediaType,Tc as NCCallMediaTypeChangeResult,Oc as NCCallPushImportanceHW,Nc as NCCallSession,Sc as NCCallState,Cc as NCCallType,vc as NCCallUserState,bc as NCCallVideoFrameRate,Ac as NCCallVideoResolution,pc as NCVideoConfigBuilder};
|